← All problems
Problem 439
S(10^11) mod 10^9 where S(N)=sum_{i,j<=N} sigma(i*j).
View problem on Project Euler
Performance comparison
Metric Our solution Best known
Time complexity O(n^2)O(n log log n)
Space complexity O(n^2)O(n)
Approach Flow solution Sieve-based divisor sums
Verdict Suboptimal
Flow source
# Project Euler 439
# S(10^11) mod 10^9 where S(N)=sum_{i,j<=N} sigma(i*j).
extern {
function calloc(n: i64, size: i64) -> ptr<void>
function free(p: ptr<void>) -> void
}
function hget(keys: ptr<i64>, vals: ptr<i64>, used: ptr<i8>, cap: i64, key: i64) -> i64 {
let mut h: i64 = key % cap
if h < 0 { h = h + cap }
while used[h] != 0 {
if keys[h] == key { return vals[h] }
h = h + 1
if h >= cap { h = 0 }
}
return -1
}
function hput(keys: ptr<i64>, vals: ptr<i64>, used: ptr<i8>, cap: i64, key: i64, val: i64) -> void {
let mut h: i64 = key % cap
if h < 0 { h = h + cap }
while used[h] != 0 {
if keys[h] == key { vals[h] = val; return }
h = h + 1
if h >= cap { h = 0 }
}
used[h] = 1
keys[h] = key
vals[h] = val
}
function imu(
x: i64, LIMIT: i64, MOD: i64, pre: ptr<i64>,
keys: ptr<i64>, vals: ptr<i64>, used: ptr<i8>, HCAP: i64
) -> i64 {
if x <= LIMIT { return pre[x] }
let cached: i64 = hget(keys, vals, used, HCAP, x)
if cached >= 0 { return cached }
let mut res: i64 = 1 % MOD
let mut i: i64 = 2
while i <= x {
let v: i64 = x / i
let j: i64 = x / v
let cnt: i64 = j - i + 1
let mut sum_i: i64 = ((((i + j) as i128) * (cnt as i128) / (2 as i128)) % (MOD as i128)) as i64
if sum_i < 0 { sum_i = sum_i + MOD }
res = (res - sum_i * imu(v, LIMIT, MOD, pre, keys, vals, used, HCAP)) % MOD
if res < 0 { res = res + MOD }
i = j + 1
}
hput(keys, vals, used, HCAP, x, res)
return res
}
function Hval(x: i64, sqrtN: i64, MOD: i64, Hsmall: ptr<i64>) -> i64 {
if x <= sqrtN { return Hsmall[x] }
let mut res: i64 = 0
let mut i: i64 = 1
while i <= x {
let v: i64 = x / i
let j: i64 = x / v
let cnt: i64 = j - i + 1
let mut sum_i: i64 = ((((i + j) as i128) * (cnt as i128) / (2 as i128)) % (MOD as i128)) as i64
if sum_i < 0 { sum_i = sum_i + MOD }
res = (res + (v % MOD) * sum_i) % MOD
i = j + 1
}
return res
}
function main() -> i32 {
let N: i64 = 100000000000
let MOD: i64 = 1000000000
let mut sqrtN: i64 = 0
while (sqrtN + 1) * (sqrtN + 1) <= N { sqrtN = sqrtN + 1 }
let mut sieve_limit: i64 = 3000000
# N^(2/3) approx for 1e11 is ~2154434, use 3e6
if sieve_limit < sqrtN { sieve_limit = sqrtN }
let mu: ptr<i8> = calloc(sieve_limit + 1, 1)
let is_comp: ptr<i8> = calloc(sieve_limit + 1, 1)
let primes: ptr<i32> = calloc(sieve_limit / 5 + 10, 4)
let pre: ptr<i64> = calloc(sieve_limit + 1, 8)
if mu == null || pre == null { return 1 }
mu[1] = 1
let mut pc: i64 = 0
let mut i: i64 = 2
while i <= sieve_limit {
if is_comp[i] == 0 {
primes[pc] = i as i32
pc = pc + 1
mu[i] = -1
}
let mut j: i64 = 0
while j < pc {
let p: i64 = primes[j] as i64
let ip: i64 = i * p
if ip > sieve_limit { break }
is_comp[ip] = 1
if i % p == 0 {
mu[ip] = 0
break
} else {
mu[ip] = (0 - (mu[i] as i64)) as i8
}
j = j + 1
}
i = i + 1
}
let mut acc: i64 = 0
i = 1
while i <= sieve_limit {
acc = (acc + i * (mu[i] as i64)) % MOD
if acc < 0 { acc = acc + MOD }
pre[i] = acc
i = i + 1
}
let sigma: ptr<i32> = calloc(sqrtN + 1, 4)
let Hsmall: ptr<i64> = calloc(sqrtN + 1, 8)
if sigma == null || Hsmall == null { return 1 }
let mut d: i64 = 1
while d <= sqrtN {
let mut m2: i64 = d
while m2 <= sqrtN {
sigma[m2] = (sigma[m2] as i64 + d) as i32
m2 = m2 + d
}
d = d + 1
}
acc = 0
i = 1
while i <= sqrtN {
acc = (acc + (sigma[i] as i64)) % MOD
Hsmall[i] = acc
i = i + 1
}
let HCAP: i64 = 4000003
let keys: ptr<i64> = calloc(HCAP, 8)
let vals: ptr<i64> = calloc(HCAP, 8)
let used: ptr<i8> = calloc(HCAP, 1)
if keys == null { return 1 }
let mut ans: i64 = 0
let mut k: i64 = 1
let mut prev_imu: i64 = 0
while k <= N {
let q: i64 = N / k
let r: i64 = N / q
let cur_imu: i64 = imu(r, sieve_limit, MOD, pre, keys, vals, used, HCAP)
let seg: i64 = (cur_imu - prev_imu) % MOD
if seg < 0 { seg = seg + MOD }
prev_imu = cur_imu
let hq: i64 = Hval(q, sqrtN, MOD, Hsmall)
ans = (ans + seg * ((hq * hq) % MOD)) % MOD
k = r + 1
}
printf("%lld\n", ans)
return 0
}
Generated C
#include <stdint.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/* Flow runtime helpers */
typedef struct flow_temp_node { struct flow_temp_node* next; } flow_temp_node;
static flow_temp_node* flow_temp_head = NULL;
static int flow_temp_atexit_set = 0;
__attribute__((unused)) static void flow_temp_free_all(void) {
while (flow_temp_head) {
flow_temp_node* n = flow_temp_head;
flow_temp_head = n->next;
free(n);
}
}
__attribute__((unused)) static void* flow_temp_alloc(size_t nbytes) {
flow_temp_node* node = (flow_temp_node*)malloc(sizeof(flow_temp_node) + nbytes);
if (!node) return NULL;
node->next = flow_temp_head;
flow_temp_head = node;
if (!flow_temp_atexit_set) {
flow_temp_atexit_set = 1;
atexit(flow_temp_free_all);
}
return (void*)(node + 1);
}
#ifndef FLOW_DIAG
#define FLOW_DIAG(msg) fprintf(stderr, "%s", (msg))
#endif
#ifndef FLOW_LOG
#define FLOW_LOG(fmt, ...) printf(fmt, __VA_ARGS__)
#endif
#ifndef FLOW_LOG_EMPTY
#define FLOW_LOG_EMPTY(fmt) printf(fmt)
#endif
static char* flow_strcat(const char* a, const char* b) {
size_t la = strlen(a ? a : ""), lb = strlen(b ? b : "");
char* r = (char*)flow_temp_alloc(la + lb + 1);
if (!r) return NULL;
if (la) memcpy(r, a, la);
if (lb) memcpy(r + la, b, lb);
r[la + lb] = '\0';
return r;
}
#define __flow_in_arr(arr, val) __extension__ ({ \
int _found = 0; \
size_t _n = sizeof(arr)/sizeof((arr)[0]); \
for (size_t _i = 0; _i < _n; _i++) { \
if ((arr)[_i] == (val)) { _found = 1; break; } \
} _found; })
/* Unified fault handler (MISRA #279) — override with -DFLOW_FAULT_HANDLER=fn */
#ifndef FLOW_FAULT_HANDLER
__attribute__((unused)) static inline void flow_fault_handler(const char* msg) {
fprintf(stderr, "flow: %s\n", msg ? msg : "fault");
abort();
#if defined(__GNUC__) || defined(__clang__)
__builtin_unreachable();
#endif
}
#else
#define flow_fault_handler FLOW_FAULT_HANDLER
#endif
#define flow_div_by_zero_handler() flow_fault_handler("division by zero")
#define flow_shift_ub_handler() flow_fault_handler("invalid shift (amount out of range or left-shift of negative)")
#ifndef FLOW_CHECKED_DIV
#define FLOW_CHECKED_DIV(L, R) (((R) != 0) ? ((L) / (R)) : (flow_div_by_zero_handler(), (L) * 0))
#endif
#ifndef FLOW_CHECKED_MOD
#define FLOW_CHECKED_MOD(L, R) (((R) != 0) ? ((L) % (R)) : (flow_div_by_zero_handler(), (L) * 0))
#endif
#ifndef FLOW_CHECKED_SHL
#define FLOW_CHECKED_SHL(L, R) ((((R) >= 0) && ((unsigned long long)(R) < (sizeof(L) * 8ull)) && ((L) >= 0)) ? ((L) << (R)) : (flow_shift_ub_handler(), (L) * 0))
#endif
#ifndef FLOW_CHECKED_SHR
#define FLOW_CHECKED_SHR(L, R) ((((R) >= 0) && ((unsigned long long)(R) < (sizeof(L) * 8ull))) ? ((L) >> (R)) : (flow_shift_ub_handler(), (L) * 0))
#endif
#include <math.h>
void* _ui_state = NULL;
static inline float i32_to_f32(int32_t v) { return (float)v; }
/* Host stub for @gpu kernels (device codegen replaces this). */
static inline int32_t gpu_thread_id(void) { return 0; }
int64_t hget_ptr_i64_ptr_i64_ptr_i8_i64_i64(int64_t* keys, int64_t* vals, int8_t* used, int64_t cap, int64_t key);
void hput_ptr_i64_ptr_i64_ptr_i8_i64_i64_i64(int64_t* keys, int64_t* vals, int8_t* used, int64_t cap, int64_t key, int64_t val);
int64_t imu_i64_i64_i64_ptr_i64_ptr_i64_ptr_i64_ptr_i8_i64(int64_t x, int64_t LIMIT, int64_t MOD, int64_t* pre, int64_t* keys, int64_t* vals, int8_t* used, int64_t HCAP);
int64_t Hval_i64_i64_i64_ptr_i64(int64_t x, int64_t sqrtN, int64_t MOD, int64_t* Hsmall);
int32_t main(void);
int64_t hget_ptr_i64_ptr_i64_ptr_i8_i64_i64(int64_t* keys, int64_t* vals, int8_t* used, int64_t cap, int64_t key) {
int64_t h = FLOW_CHECKED_MOD((key), (cap));
if (h < 0) {
h = (h + cap);
}
while (used[h] != 0) {
if (keys[h] == key) {
return vals[h];
}
h = (h + 1);
if (h >= cap) {
h = 0;
}
}
return (-1);
}
void hput_ptr_i64_ptr_i64_ptr_i8_i64_i64_i64(int64_t* keys, int64_t* vals, int8_t* used, int64_t cap, int64_t key, int64_t val) {
int64_t h = FLOW_CHECKED_MOD((key), (cap));
if (h < 0) {
h = (h + cap);
}
while (used[h] != 0) {
if (keys[h] == key) {
vals[h] = val;
return;
}
h = (h + 1);
if (h >= cap) {
h = 0;
}
}
used[h] = 1;
keys[h] = key;
vals[h] = val;
}
int64_t imu_i64_i64_i64_ptr_i64_ptr_i64_ptr_i64_ptr_i8_i64(int64_t x, int64_t LIMIT, int64_t MOD, int64_t* pre, int64_t* keys, int64_t* vals, int8_t* used, int64_t HCAP) {
if (x <= LIMIT) {
return pre[x];
}
int64_t cached = hget_ptr_i64_ptr_i64_ptr_i8_i64_i64(keys, vals, used, HCAP, x);
if (cached >= 0) {
return cached;
}
int64_t res = FLOW_CHECKED_MOD((1), (MOD));
int64_t i = 2;
while (i <= x) {
int64_t v = FLOW_CHECKED_DIV((x), (i));
int64_t j = FLOW_CHECKED_DIV((x), (v));
int64_t cnt = ((j - i) + 1);
int64_t sum_i = ((int64_t)(FLOW_CHECKED_MOD((FLOW_CHECKED_DIV(((((__int128)((i + j))) * ((__int128)(cnt)))), (((__int128)(2))))), (((__int128)(MOD))))));
if (sum_i < 0) {
sum_i = (sum_i + MOD);
}
res = FLOW_CHECKED_MOD(((res - (sum_i * imu_i64_i64_i64_ptr_i64_ptr_i64_ptr_i64_ptr_i8_i64(v, LIMIT, MOD, pre, keys, vals, used, HCAP)))), (MOD));
if (res < 0) {
res = (res + MOD);
}
i = (j + 1);
}
hput_ptr_i64_ptr_i64_ptr_i8_i64_i64_i64(keys, vals, used, HCAP, x, res);
return res;
}
int64_t Hval_i64_i64_i64_ptr_i64(int64_t x, int64_t sqrtN, int64_t MOD, int64_t* Hsmall) {
if (x <= sqrtN) {
return Hsmall[x];
}
int64_t res = 0;
int64_t i = 1;
while (i <= x) {
int64_t v = FLOW_CHECKED_DIV((x), (i));
int64_t j = FLOW_CHECKED_DIV((x), (v));
int64_t cnt = ((j - i) + 1);
int64_t sum_i = ((int64_t)(FLOW_CHECKED_MOD((FLOW_CHECKED_DIV(((((__int128)((i + j))) * ((__int128)(cnt)))), (((__int128)(2))))), (((__int128)(MOD))))));
if (sum_i < 0) {
sum_i = (sum_i + MOD);
}
res = FLOW_CHECKED_MOD(((res + (FLOW_CHECKED_MOD((v), (MOD)) * sum_i))), (MOD));
i = (j + 1);
}
return res;
}
int32_t main(void) {
int64_t N = 100000000000;
int64_t MOD = 1000000000;
int64_t sqrtN = 0;
while (((sqrtN + 1) * (sqrtN + 1)) <= N) {
sqrtN = (sqrtN + 1);
}
int64_t sieve_limit = 3000000;
if (sieve_limit < sqrtN) {
sieve_limit = sqrtN;
}
int8_t* mu = (int8_t*)(calloc((sieve_limit + 1), 1));
int8_t* is_comp = (int8_t*)(calloc((sieve_limit + 1), 1));
int32_t* primes = (int32_t*)(calloc((FLOW_CHECKED_DIV((sieve_limit), (5)) + 10), 4));
int64_t* pre = (int64_t*)(calloc((sieve_limit + 1), 8));
if ((mu == NULL || pre == NULL)) {
return 1;
}
mu[1] = 1;
int64_t pc = 0;
int64_t i = 2;
while (i <= sieve_limit) {
if (is_comp[i] == 0) {
primes[pc] = ((int32_t)(i));
pc = (pc + 1);
mu[i] = (-1);
}
int64_t j = 0;
while (j < pc) {
int64_t p = ((int64_t)(primes[j]));
int64_t ip = (i * p);
if (ip > sieve_limit) {
break;
}
is_comp[ip] = 1;
if (FLOW_CHECKED_MOD((i), (p)) == 0) {
mu[ip] = 0;
break;
} else {
mu[ip] = ((int8_t)((0 - ((int64_t)(mu[i])))));
}
j = (j + 1);
}
i = (i + 1);
}
int64_t acc = 0;
i = 1;
while (i <= sieve_limit) {
acc = FLOW_CHECKED_MOD(((acc + (i * ((int64_t)(mu[i]))))), (MOD));
if (acc < 0) {
acc = (acc + MOD);
}
pre[i] = acc;
i = (i + 1);
}
int32_t* sigma = (int32_t*)(calloc((sqrtN + 1), 4));
int64_t* Hsmall = (int64_t*)(calloc((sqrtN + 1), 8));
if ((sigma == NULL || Hsmall == NULL)) {
return 1;
}
int64_t d = 1;
while (d <= sqrtN) {
int64_t m2 = d;
while (m2 <= sqrtN) {
sigma[m2] = ((int32_t)((((int64_t)(sigma[m2])) + d)));
m2 = (m2 + d);
}
d = (d + 1);
}
acc = 0;
i = 1;
while (i <= sqrtN) {
acc = FLOW_CHECKED_MOD(((acc + ((int64_t)(sigma[i])))), (MOD));
Hsmall[i] = acc;
i = (i + 1);
}
int64_t HCAP = 4000003;
int64_t* keys = (int64_t*)(calloc(HCAP, 8));
int64_t* vals = (int64_t*)(calloc(HCAP, 8));
int8_t* used = (int8_t*)(calloc(HCAP, 1));
if (keys == NULL) {
return 1;
}
int64_t ans = 0;
int64_t k = 1;
int64_t prev_imu = 0;
while (k <= N) {
int64_t q = FLOW_CHECKED_DIV((N), (k));
int64_t r = FLOW_CHECKED_DIV((N), (q));
int64_t cur_imu = imu_i64_i64_i64_ptr_i64_ptr_i64_ptr_i64_ptr_i8_i64(r, sieve_limit, MOD, pre, keys, vals, used, HCAP);
int64_t seg = FLOW_CHECKED_MOD(((cur_imu - prev_imu)), (MOD));
if (seg < 0) {
seg = (seg + MOD);
}
prev_imu = cur_imu;
int64_t hq = Hval_i64_i64_i64_ptr_i64(q, sqrtN, MOD, Hsmall);
ans = FLOW_CHECKED_MOD(((ans + (seg * FLOW_CHECKED_MOD(((hq * hq)), (MOD))))), (MOD));
k = (r + 1);
}
printf("%lld\n", ans);
return 0;
}
Generated MLIR
module {
llvm.func @printf(!llvm.ptr, ...) -> i32
llvm.mlir.global internal constant @str_0("%lld\n\00") {addr_space = 0 : i32} : !llvm.array<6 x i8>
func.func private @calloc(i64, i64) -> !llvm.ptr
func.func private @free(!llvm.ptr) -> ()
func.func @hget(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: !llvm.ptr, %arg3: i64, %arg4: i64) -> i64 {
%0 = arith.remsi %arg4, %arg3 : i64
%1 = llvm.mlir.constant(1 : i64) : i64
%2 = llvm.alloca %1 x i64 : (i64) -> !llvm.ptr
llvm.store %0, %2 : i64, !llvm.ptr
%3 = llvm.load %2 : !llvm.ptr -> i64
%4 = arith.constant 0 : i32
%6 = arith.extsi %4 : i32 to i64
%5 = arith.cmpi slt, %3, %6 : i64
cf.cond_br %5, ^bb0, ^bb1
^bb0:
%7 = llvm.load %2 : !llvm.ptr -> i64
%8 = arith.addi %7, %arg3 : i64
llvm.store %8, %2 : i64, !llvm.ptr
cf.br ^bb2
^bb1:
cf.br ^bb2
^bb2:
cf.br ^bb3
^bb3:
%10 = llvm.load %2 : !llvm.ptr -> i64
%11 = llvm.getelementptr %arg2[%10] : (!llvm.ptr, i64) -> !llvm.ptr, i8
%9 = llvm.load %11 : !llvm.ptr -> i8
%12 = arith.constant 0 : i32
%14 = arith.extsi %9 : i8 to i32
%13 = arith.cmpi ne, %14, %12 : i32
cf.cond_br %13, ^bb4, ^bb5
^bb4:
%16 = llvm.load %2 : !llvm.ptr -> i64
%17 = llvm.getelementptr %arg0[%16] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%15 = llvm.load %17 : !llvm.ptr -> i64
%18 = arith.cmpi eq, %15, %arg4 : i64
cf.cond_br %18, ^bb6, ^bb7
^bb6:
%20 = llvm.load %2 : !llvm.ptr -> i64
%21 = llvm.getelementptr %arg1[%20] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%19 = llvm.load %21 : !llvm.ptr -> i64
func.return %19 : i64
^bb7:
cf.br ^bb8
^bb8:
%22 = llvm.load %2 : !llvm.ptr -> i64
%23 = arith.constant 1 : i32
%25 = arith.extsi %23 : i32 to i64
%24 = arith.addi %22, %25 : i64
llvm.store %24, %2 : i64, !llvm.ptr
%26 = llvm.load %2 : !llvm.ptr -> i64
%27 = arith.cmpi sge, %26, %arg3 : i64
cf.cond_br %27, ^bb9, ^bb10
^bb9:
%28 = arith.constant 0 : i32
%29 = arith.extsi %28 : i32 to i64
llvm.store %29, %2 : i64, !llvm.ptr
cf.br ^bb11
^bb10:
cf.br ^bb11
^bb11:
cf.br ^bb3
^bb5:
%30 = arith.constant 1 : i32
%32 = arith.constant 0 : i32
%31 = arith.subi %32, %30 : i32
%33 = arith.extsi %31 : i32 to i64
func.return %33 : i64
}
func.func @hput(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: !llvm.ptr, %arg3: i64, %arg4: i64, %arg5: i64) -> () {
%34 = arith.remsi %arg4, %arg3 : i64
%35 = llvm.mlir.constant(1 : i64) : i64
%36 = llvm.alloca %35 x i64 : (i64) -> !llvm.ptr
llvm.store %34, %36 : i64, !llvm.ptr
%37 = llvm.load %36 : !llvm.ptr -> i64
%38 = arith.constant 0 : i32
%40 = arith.extsi %38 : i32 to i64
%39 = arith.cmpi slt, %37, %40 : i64
cf.cond_br %39, ^bb12, ^bb13
^bb12:
%41 = llvm.load %36 : !llvm.ptr -> i64
%42 = arith.addi %41, %arg3 : i64
llvm.store %42, %36 : i64, !llvm.ptr
cf.br ^bb14
^bb13:
cf.br ^bb14
^bb14:
cf.br ^bb15
^bb15:
%44 = llvm.load %36 : !llvm.ptr -> i64
%45 = llvm.getelementptr %arg2[%44] : (!llvm.ptr, i64) -> !llvm.ptr, i8
%43 = llvm.load %45 : !llvm.ptr -> i8
%46 = arith.constant 0 : i32
%48 = arith.extsi %43 : i8 to i32
%47 = arith.cmpi ne, %48, %46 : i32
cf.cond_br %47, ^bb16, ^bb17
^bb16:
%50 = llvm.load %36 : !llvm.ptr -> i64
%51 = llvm.getelementptr %arg0[%50] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%49 = llvm.load %51 : !llvm.ptr -> i64
%52 = arith.cmpi eq, %49, %arg4 : i64
cf.cond_br %52, ^bb18, ^bb19
^bb18:
%53 = llvm.load %36 : !llvm.ptr -> i64
%54 = llvm.getelementptr %arg1[%53] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %arg5, %54 : i64, !llvm.ptr
func.return
^bb19:
cf.br ^bb20
^bb20:
%55 = llvm.load %36 : !llvm.ptr -> i64
%56 = arith.constant 1 : i32
%58 = arith.extsi %56 : i32 to i64
%57 = arith.addi %55, %58 : i64
llvm.store %57, %36 : i64, !llvm.ptr
%59 = llvm.load %36 : !llvm.ptr -> i64
%60 = arith.cmpi sge, %59, %arg3 : i64
cf.cond_br %60, ^bb21, ^bb22
^bb21:
%61 = arith.constant 0 : i32
%62 = arith.extsi %61 : i32 to i64
llvm.store %62, %36 : i64, !llvm.ptr
cf.br ^bb23
^bb22:
cf.br ^bb23
^bb23:
cf.br ^bb15
^bb17:
%63 = arith.constant 1 : i32
%64 = llvm.load %36 : !llvm.ptr -> i64
%65 = arith.trunci %63 : i32 to i8
%66 = llvm.getelementptr %arg2[%64] : (!llvm.ptr, i64) -> !llvm.ptr, i8
llvm.store %65, %66 : i8, !llvm.ptr
%67 = llvm.load %36 : !llvm.ptr -> i64
%68 = llvm.getelementptr %arg0[%67] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %arg4, %68 : i64, !llvm.ptr
%69 = llvm.load %36 : !llvm.ptr -> i64
%70 = llvm.getelementptr %arg1[%69] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %arg5, %70 : i64, !llvm.ptr
func.return
}
func.func @imu(%arg0: i64, %arg1: i64, %arg2: i64, %arg3: !llvm.ptr, %arg4: !llvm.ptr, %arg5: !llvm.ptr, %arg6: !llvm.ptr, %arg7: i64) -> i64 {
%71 = arith.cmpi sle, %arg0, %arg1 : i64
cf.cond_br %71, ^bb24, ^bb25
^bb24:
%73 = llvm.getelementptr %arg3[%arg0] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%72 = llvm.load %73 : !llvm.ptr -> i64
func.return %72 : i64
^bb25:
cf.br ^bb26
^bb26:
%74 = func.call @hget(%arg4, %arg5, %arg6, %arg7, %arg0) : (!llvm.ptr, !llvm.ptr, !llvm.ptr, i64, i64) -> i64
%75 = arith.constant 0 : i32
%77 = arith.extsi %75 : i32 to i64
%76 = arith.cmpi sge, %74, %77 : i64
cf.cond_br %76, ^bb27, ^bb28
^bb27:
func.return %74 : i64
^bb28:
cf.br ^bb29
^bb29:
%78 = arith.constant 1 : i32
%80 = arith.extsi %78 : i32 to i64
%79 = arith.remsi %80, %arg2 : i64
%81 = llvm.mlir.constant(1 : i64) : i64
%82 = llvm.alloca %81 x i64 : (i64) -> !llvm.ptr
llvm.store %79, %82 : i64, !llvm.ptr
%83 = arith.constant 2 : i32
%84 = arith.extsi %83 : i32 to i64
%85 = llvm.mlir.constant(1 : i64) : i64
%86 = llvm.alloca %85 x i64 : (i64) -> !llvm.ptr
llvm.store %84, %86 : i64, !llvm.ptr
cf.br ^bb30
^bb30:
%87 = llvm.load %86 : !llvm.ptr -> i64
%88 = arith.cmpi sle, %87, %arg0 : i64
cf.cond_br %88, ^bb31, ^bb32
^bb31:
%89 = llvm.load %86 : !llvm.ptr -> i64
%90 = arith.divsi %arg0, %89 : i64
%91 = arith.divsi %arg0, %90 : i64
%92 = llvm.load %86 : !llvm.ptr -> i64
%93 = arith.subi %91, %92 : i64
%94 = arith.constant 1 : i32
%96 = arith.extsi %94 : i32 to i64
%95 = arith.addi %93, %96 : i64
%97 = llvm.load %86 : !llvm.ptr -> i64
%98 = arith.addi %97, %91 : i64
%99 = arith.extsi %98 : i64 to i128
%100 = arith.extsi %95 : i64 to i128
%102 = arith.trunci %99 : i128 to i64
%103 = arith.trunci %100 : i128 to i64
%101 = arith.muli %102, %103 : i64
%104 = arith.constant 2 : i32
%105 = arith.extsi %104 : i32 to i128
%107 = arith.trunci %105 : i128 to i64
%106 = arith.divsi %101, %107 : i64
%108 = arith.extsi %arg2 : i64 to i128
%110 = arith.trunci %108 : i128 to i64
%109 = arith.remsi %106, %110 : i64
%111 = llvm.mlir.constant(1 : i64) : i64
%112 = llvm.alloca %111 x i64 : (i64) -> !llvm.ptr
llvm.store %109, %112 : i64, !llvm.ptr
%113 = llvm.load %112 : !llvm.ptr -> i64
%114 = arith.constant 0 : i32
%116 = arith.extsi %114 : i32 to i64
%115 = arith.cmpi slt, %113, %116 : i64
cf.cond_br %115, ^bb33, ^bb34
^bb33:
%117 = llvm.load %112 : !llvm.ptr -> i64
%118 = arith.addi %117, %arg2 : i64
llvm.store %118, %112 : i64, !llvm.ptr
cf.br ^bb35
^bb34:
cf.br ^bb35
^bb35:
%119 = llvm.load %82 : !llvm.ptr -> i64
%120 = llvm.load %112 : !llvm.ptr -> i64
%121 = func.call @imu(%90, %arg1, %arg2, %arg3, %arg4, %arg5, %arg6, %arg7) : (i64, i64, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64) -> i64
%122 = arith.muli %120, %121 : i64
%123 = arith.subi %119, %122 : i64
%124 = arith.remsi %123, %arg2 : i64
llvm.store %124, %82 : i64, !llvm.ptr
%125 = llvm.load %82 : !llvm.ptr -> i64
%126 = arith.constant 0 : i32
%128 = arith.extsi %126 : i32 to i64
%127 = arith.cmpi slt, %125, %128 : i64
cf.cond_br %127, ^bb36, ^bb37
^bb36:
%129 = llvm.load %82 : !llvm.ptr -> i64
%130 = arith.addi %129, %arg2 : i64
llvm.store %130, %82 : i64, !llvm.ptr
cf.br ^bb38
^bb37:
cf.br ^bb38
^bb38:
%131 = arith.constant 1 : i32
%133 = arith.extsi %131 : i32 to i64
%132 = arith.addi %91, %133 : i64
llvm.store %132, %86 : i64, !llvm.ptr
cf.br ^bb30
^bb32:
%135 = llvm.load %82 : !llvm.ptr -> i64
func.call @hput(%arg4, %arg5, %arg6, %arg7, %arg0, %135) : (!llvm.ptr, !llvm.ptr, !llvm.ptr, i64, i64, i64) -> ()
%136 = llvm.load %82 : !llvm.ptr -> i64
func.return %136 : i64
}
func.func @Hval(%arg0: i64, %arg1: i64, %arg2: i64, %arg3: !llvm.ptr) -> i64 {
%137 = arith.cmpi sle, %arg0, %arg1 : i64
cf.cond_br %137, ^bb39, ^bb40
^bb39:
%139 = llvm.getelementptr %arg3[%arg0] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%138 = llvm.load %139 : !llvm.ptr -> i64
func.return %138 : i64
^bb40:
cf.br ^bb41
^bb41:
%140 = arith.constant 0 : i32
%141 = arith.extsi %140 : i32 to i64
%142 = llvm.mlir.constant(1 : i64) : i64
%143 = llvm.alloca %142 x i64 : (i64) -> !llvm.ptr
llvm.store %141, %143 : i64, !llvm.ptr
%144 = arith.constant 1 : i32
%145 = arith.extsi %144 : i32 to i64
%146 = llvm.mlir.constant(1 : i64) : i64
%147 = llvm.alloca %146 x i64 : (i64) -> !llvm.ptr
llvm.store %145, %147 : i64, !llvm.ptr
cf.br ^bb42
^bb42:
%148 = llvm.load %147 : !llvm.ptr -> i64
%149 = arith.cmpi sle, %148, %arg0 : i64
cf.cond_br %149, ^bb43, ^bb44
^bb43:
%150 = llvm.load %147 : !llvm.ptr -> i64
%151 = arith.divsi %arg0, %150 : i64
%152 = arith.divsi %arg0, %151 : i64
%153 = llvm.load %147 : !llvm.ptr -> i64
%154 = arith.subi %152, %153 : i64
%155 = arith.constant 1 : i32
%157 = arith.extsi %155 : i32 to i64
%156 = arith.addi %154, %157 : i64
%158 = llvm.load %147 : !llvm.ptr -> i64
%159 = arith.addi %158, %152 : i64
%160 = arith.extsi %159 : i64 to i128
%161 = arith.extsi %156 : i64 to i128
%163 = arith.trunci %160 : i128 to i64
%164 = arith.trunci %161 : i128 to i64
%162 = arith.muli %163, %164 : i64
%165 = arith.constant 2 : i32
%166 = arith.extsi %165 : i32 to i128
%168 = arith.trunci %166 : i128 to i64
%167 = arith.divsi %162, %168 : i64
%169 = arith.extsi %arg2 : i64 to i128
%171 = arith.trunci %169 : i128 to i64
%170 = arith.remsi %167, %171 : i64
%172 = llvm.mlir.constant(1 : i64) : i64
%173 = llvm.alloca %172 x i64 : (i64) -> !llvm.ptr
llvm.store %170, %173 : i64, !llvm.ptr
%174 = llvm.load %173 : !llvm.ptr -> i64
%175 = arith.constant 0 : i32
%177 = arith.extsi %175 : i32 to i64
%176 = arith.cmpi slt, %174, %177 : i64
cf.cond_br %176, ^bb45, ^bb46
^bb45:
%178 = llvm.load %173 : !llvm.ptr -> i64
%179 = arith.addi %178, %arg2 : i64
llvm.store %179, %173 : i64, !llvm.ptr
cf.br ^bb47
^bb46:
cf.br ^bb47
^bb47:
%180 = llvm.load %143 : !llvm.ptr -> i64
%181 = arith.remsi %151, %arg2 : i64
%182 = llvm.load %173 : !llvm.ptr -> i64
%183 = arith.muli %181, %182 : i64
%184 = arith.addi %180, %183 : i64
%185 = arith.remsi %184, %arg2 : i64
llvm.store %185, %143 : i64, !llvm.ptr
%186 = arith.constant 1 : i32
%188 = arith.extsi %186 : i32 to i64
%187 = arith.addi %152, %188 : i64
llvm.store %187, %147 : i64, !llvm.ptr
cf.br ^bb42
^bb44:
%189 = llvm.load %143 : !llvm.ptr -> i64
func.return %189 : i64
}
func.func @main() -> i32 {
%190 = arith.constant 95705032704 : i32
%191 = arith.extsi %190 : i32 to i64
%192 = arith.constant 1000000000 : i32
%193 = arith.extsi %192 : i32 to i64
%194 = arith.constant 0 : i32
%195 = arith.extsi %194 : i32 to i64
%196 = llvm.mlir.constant(1 : i64) : i64
%197 = llvm.alloca %196 x i64 : (i64) -> !llvm.ptr
llvm.store %195, %197 : i64, !llvm.ptr
cf.br ^bb48
^bb48:
%198 = llvm.load %197 : !llvm.ptr -> i64
%199 = arith.constant 1 : i32
%201 = arith.extsi %199 : i32 to i64
%200 = arith.addi %198, %201 : i64
%202 = llvm.load %197 : !llvm.ptr -> i64
%203 = arith.constant 1 : i32
%205 = arith.extsi %203 : i32 to i64
%204 = arith.addi %202, %205 : i64
%206 = arith.muli %200, %204 : i64
%207 = arith.cmpi sle, %206, %191 : i64
cf.cond_br %207, ^bb49, ^bb50
^bb49:
%208 = llvm.load %197 : !llvm.ptr -> i64
%209 = arith.constant 1 : i32
%211 = arith.extsi %209 : i32 to i64
%210 = arith.addi %208, %211 : i64
llvm.store %210, %197 : i64, !llvm.ptr
cf.br ^bb48
^bb50:
%212 = arith.constant 3000000 : i32
%213 = arith.extsi %212 : i32 to i64
%214 = llvm.mlir.constant(1 : i64) : i64
%215 = llvm.alloca %214 x i64 : (i64) -> !llvm.ptr
llvm.store %213, %215 : i64, !llvm.ptr
%216 = llvm.load %215 : !llvm.ptr -> i64
%217 = llvm.load %197 : !llvm.ptr -> i64
%218 = arith.cmpi slt, %216, %217 : i64
cf.cond_br %218, ^bb51, ^bb52
^bb51:
%219 = llvm.load %197 : !llvm.ptr -> i64
llvm.store %219, %215 : i64, !llvm.ptr
cf.br ^bb53
^bb52:
cf.br ^bb53
^bb53:
%221 = llvm.load %215 : !llvm.ptr -> i64
%222 = arith.constant 1 : i32
%224 = arith.extsi %222 : i32 to i64
%223 = arith.addi %221, %224 : i64
%225 = arith.constant 1 : i32
%226 = arith.extsi %225 : i32 to i64
%220 = func.call @calloc(%223, %226) : (i64, i64) -> !llvm.ptr
%228 = llvm.load %215 : !llvm.ptr -> i64
%229 = arith.constant 1 : i32
%231 = arith.extsi %229 : i32 to i64
%230 = arith.addi %228, %231 : i64
%232 = arith.constant 1 : i32
%233 = arith.extsi %232 : i32 to i64
%227 = func.call @calloc(%230, %233) : (i64, i64) -> !llvm.ptr
%235 = llvm.load %215 : !llvm.ptr -> i64
%236 = arith.constant 5 : i32
%238 = arith.extsi %236 : i32 to i64
%237 = arith.divsi %235, %238 : i64
%239 = arith.constant 10 : i32
%241 = arith.extsi %239 : i32 to i64
%240 = arith.addi %237, %241 : i64
%242 = arith.constant 4 : i32
%243 = arith.extsi %242 : i32 to i64
%234 = func.call @calloc(%240, %243) : (i64, i64) -> !llvm.ptr
%245 = llvm.load %215 : !llvm.ptr -> i64
%246 = arith.constant 1 : i32
%248 = arith.extsi %246 : i32 to i64
%247 = arith.addi %245, %248 : i64
%249 = arith.constant 8 : i32
%250 = arith.extsi %249 : i32 to i64
%244 = func.call @calloc(%247, %250) : (i64, i64) -> !llvm.ptr
%251 = llvm.mlir.zero : !llvm.ptr
%252 = llvm.icmp "eq" %220, %251 : !llvm.ptr
%253 = scf.if %252 -> (i1) {
%254 = arith.constant true
scf.yield %254 : i1
} else {
%255 = llvm.mlir.zero : !llvm.ptr
%256 = llvm.icmp "eq" %244, %255 : !llvm.ptr
scf.yield %256 : i1
}
cf.cond_br %253, ^bb54, ^bb55
^bb54:
%257 = arith.constant 1 : i32
func.return %257 : i32
^bb55:
cf.br ^bb56
^bb56:
%258 = arith.constant 1 : i32
%259 = arith.constant 1 : i32
%260 = arith.trunci %258 : i32 to i8
%261 = arith.extsi %259 : i32 to i64
%262 = llvm.getelementptr %220[%261] : (!llvm.ptr, i64) -> !llvm.ptr, i8
llvm.store %260, %262 : i8, !llvm.ptr
%263 = arith.constant 0 : i32
%264 = arith.extsi %263 : i32 to i64
%265 = llvm.mlir.constant(1 : i64) : i64
%266 = llvm.alloca %265 x i64 : (i64) -> !llvm.ptr
llvm.store %264, %266 : i64, !llvm.ptr
%267 = arith.constant 2 : i32
%268 = arith.extsi %267 : i32 to i64
%269 = llvm.mlir.constant(1 : i64) : i64
%270 = llvm.alloca %269 x i64 : (i64) -> !llvm.ptr
llvm.store %268, %270 : i64, !llvm.ptr
cf.br ^bb57
^bb57:
%271 = llvm.load %270 : !llvm.ptr -> i64
%272 = llvm.load %215 : !llvm.ptr -> i64
%273 = arith.cmpi sle, %271, %272 : i64
cf.cond_br %273, ^bb58, ^bb59
^bb58:
%275 = llvm.load %270 : !llvm.ptr -> i64
%276 = llvm.getelementptr %227[%275] : (!llvm.ptr, i64) -> !llvm.ptr, i8
%274 = llvm.load %276 : !llvm.ptr -> i8
%277 = arith.constant 0 : i32
%279 = arith.extsi %274 : i8 to i32
%278 = arith.cmpi eq, %279, %277 : i32
cf.cond_br %278, ^bb60, ^bb61
^bb60:
%280 = llvm.load %270 : !llvm.ptr -> i64
%281 = arith.trunci %280 : i64 to i32
%282 = llvm.load %266 : !llvm.ptr -> i64
%283 = llvm.getelementptr %234[%282] : (!llvm.ptr, i64) -> !llvm.ptr, i32
llvm.store %281, %283 : i32, !llvm.ptr
%284 = llvm.load %266 : !llvm.ptr -> i64
%285 = arith.constant 1 : i32
%287 = arith.extsi %285 : i32 to i64
%286 = arith.addi %284, %287 : i64
llvm.store %286, %266 : i64, !llvm.ptr
%288 = arith.constant 1 : i32
%290 = arith.constant 0 : i32
%289 = arith.subi %290, %288 : i32
%291 = llvm.load %270 : !llvm.ptr -> i64
%292 = arith.trunci %289 : i32 to i8
%293 = llvm.getelementptr %220[%291] : (!llvm.ptr, i64) -> !llvm.ptr, i8
llvm.store %292, %293 : i8, !llvm.ptr
cf.br ^bb62
^bb61:
cf.br ^bb62
^bb62:
%294 = arith.constant 0 : i32
%295 = arith.extsi %294 : i32 to i64
%296 = llvm.mlir.constant(1 : i64) : i64
%297 = llvm.alloca %296 x i64 : (i64) -> !llvm.ptr
llvm.store %295, %297 : i64, !llvm.ptr
cf.br ^bb63
^bb63:
%298 = llvm.load %297 : !llvm.ptr -> i64
%299 = llvm.load %266 : !llvm.ptr -> i64
%300 = arith.cmpi slt, %298, %299 : i64
cf.cond_br %300, ^bb64, ^bb65
^bb64:
%302 = llvm.load %297 : !llvm.ptr -> i64
%303 = llvm.getelementptr %234[%302] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%301 = llvm.load %303 : !llvm.ptr -> i32
%304 = arith.extsi %301 : i32 to i64
%305 = llvm.load %270 : !llvm.ptr -> i64
%306 = arith.muli %305, %304 : i64
%307 = llvm.load %215 : !llvm.ptr -> i64
%308 = arith.cmpi sgt, %306, %307 : i64
cf.cond_br %308, ^bb66, ^bb67
^bb66:
cf.br ^bb65
^bb67:
cf.br ^bb68
^bb68:
%309 = arith.constant 1 : i32
%310 = arith.trunci %309 : i32 to i8
%311 = llvm.getelementptr %227[%306] : (!llvm.ptr, i64) -> !llvm.ptr, i8
llvm.store %310, %311 : i8, !llvm.ptr
%312 = llvm.load %270 : !llvm.ptr -> i64
%313 = arith.remsi %312, %304 : i64
%314 = arith.constant 0 : i32
%316 = arith.extsi %314 : i32 to i64
%315 = arith.cmpi eq, %313, %316 : i64
cf.cond_br %315, ^bb69, ^bb70
^bb69:
%317 = arith.constant 0 : i32
%318 = arith.trunci %317 : i32 to i8
%319 = llvm.getelementptr %220[%306] : (!llvm.ptr, i64) -> !llvm.ptr, i8
llvm.store %318, %319 : i8, !llvm.ptr
cf.br ^bb65
^bb70:
%320 = arith.constant 0 : i32
%322 = llvm.load %270 : !llvm.ptr -> i64
%323 = llvm.getelementptr %220[%322] : (!llvm.ptr, i64) -> !llvm.ptr, i8
%321 = llvm.load %323 : !llvm.ptr -> i8
%324 = arith.extsi %321 : i8 to i64
%326 = arith.extsi %320 : i32 to i64
%325 = arith.subi %326, %324 : i64
%327 = arith.trunci %325 : i64 to i8
%328 = llvm.getelementptr %220[%306] : (!llvm.ptr, i64) -> !llvm.ptr, i8
llvm.store %327, %328 : i8, !llvm.ptr
cf.br ^bb71
^bb71:
%329 = llvm.load %297 : !llvm.ptr -> i64
%330 = arith.constant 1 : i32
%332 = arith.extsi %330 : i32 to i64
%331 = arith.addi %329, %332 : i64
llvm.store %331, %297 : i64, !llvm.ptr
cf.br ^bb63
^bb65:
%333 = llvm.load %270 : !llvm.ptr -> i64
%334 = arith.constant 1 : i32
%336 = arith.extsi %334 : i32 to i64
%335 = arith.addi %333, %336 : i64
llvm.store %335, %270 : i64, !llvm.ptr
cf.br ^bb57
^bb59:
%337 = arith.constant 0 : i32
%338 = arith.extsi %337 : i32 to i64
%339 = llvm.mlir.constant(1 : i64) : i64
%340 = llvm.alloca %339 x i64 : (i64) -> !llvm.ptr
llvm.store %338, %340 : i64, !llvm.ptr
%341 = arith.constant 1 : i32
%342 = arith.extsi %341 : i32 to i64
llvm.store %342, %270 : i64, !llvm.ptr
cf.br ^bb72
^bb72:
%343 = llvm.load %270 : !llvm.ptr -> i64
%344 = llvm.load %215 : !llvm.ptr -> i64
%345 = arith.cmpi sle, %343, %344 : i64
cf.cond_br %345, ^bb73, ^bb74
^bb73:
%346 = llvm.load %340 : !llvm.ptr -> i64
%347 = llvm.load %270 : !llvm.ptr -> i64
%349 = llvm.load %270 : !llvm.ptr -> i64
%350 = llvm.getelementptr %220[%349] : (!llvm.ptr, i64) -> !llvm.ptr, i8
%348 = llvm.load %350 : !llvm.ptr -> i8
%351 = arith.extsi %348 : i8 to i64
%352 = arith.muli %347, %351 : i64
%353 = arith.addi %346, %352 : i64
%354 = arith.remsi %353, %193 : i64
llvm.store %354, %340 : i64, !llvm.ptr
%355 = llvm.load %340 : !llvm.ptr -> i64
%356 = arith.constant 0 : i32
%358 = arith.extsi %356 : i32 to i64
%357 = arith.cmpi slt, %355, %358 : i64
cf.cond_br %357, ^bb75, ^bb76
^bb75:
%359 = llvm.load %340 : !llvm.ptr -> i64
%360 = arith.addi %359, %193 : i64
llvm.store %360, %340 : i64, !llvm.ptr
cf.br ^bb77
^bb76:
cf.br ^bb77
^bb77:
%361 = llvm.load %340 : !llvm.ptr -> i64
%362 = llvm.load %270 : !llvm.ptr -> i64
%363 = llvm.getelementptr %244[%362] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %361, %363 : i64, !llvm.ptr
%364 = llvm.load %270 : !llvm.ptr -> i64
%365 = arith.constant 1 : i32
%367 = arith.extsi %365 : i32 to i64
%366 = arith.addi %364, %367 : i64
llvm.store %366, %270 : i64, !llvm.ptr
cf.br ^bb72
^bb74:
%369 = llvm.load %197 : !llvm.ptr -> i64
%370 = arith.constant 1 : i32
%372 = arith.extsi %370 : i32 to i64
%371 = arith.addi %369, %372 : i64
%373 = arith.constant 4 : i32
%374 = arith.extsi %373 : i32 to i64
%368 = func.call @calloc(%371, %374) : (i64, i64) -> !llvm.ptr
%376 = llvm.load %197 : !llvm.ptr -> i64
%377 = arith.constant 1 : i32
%379 = arith.extsi %377 : i32 to i64
%378 = arith.addi %376, %379 : i64
%380 = arith.constant 8 : i32
%381 = arith.extsi %380 : i32 to i64
%375 = func.call @calloc(%378, %381) : (i64, i64) -> !llvm.ptr
%382 = llvm.mlir.zero : !llvm.ptr
%383 = llvm.icmp "eq" %368, %382 : !llvm.ptr
%384 = scf.if %383 -> (i1) {
%385 = arith.constant true
scf.yield %385 : i1
} else {
%386 = llvm.mlir.zero : !llvm.ptr
%387 = llvm.icmp "eq" %375, %386 : !llvm.ptr
scf.yield %387 : i1
}
cf.cond_br %384, ^bb78, ^bb79
^bb78:
%388 = arith.constant 1 : i32
func.return %388 : i32
^bb79:
cf.br ^bb80
^bb80:
%389 = arith.constant 1 : i32
%390 = arith.extsi %389 : i32 to i64
%391 = llvm.mlir.constant(1 : i64) : i64
%392 = llvm.alloca %391 x i64 : (i64) -> !llvm.ptr
llvm.store %390, %392 : i64, !llvm.ptr
cf.br ^bb81
^bb81:
%393 = llvm.load %392 : !llvm.ptr -> i64
%394 = llvm.load %197 : !llvm.ptr -> i64
%395 = arith.cmpi sle, %393, %394 : i64
cf.cond_br %395, ^bb82, ^bb83
^bb82:
%396 = llvm.load %392 : !llvm.ptr -> i64
%397 = llvm.mlir.constant(1 : i64) : i64
%398 = llvm.alloca %397 x i64 : (i64) -> !llvm.ptr
llvm.store %396, %398 : i64, !llvm.ptr
cf.br ^bb84
^bb84:
%399 = llvm.load %398 : !llvm.ptr -> i64
%400 = llvm.load %197 : !llvm.ptr -> i64
%401 = arith.cmpi sle, %399, %400 : i64
cf.cond_br %401, ^bb85, ^bb86
^bb85:
%403 = llvm.load %398 : !llvm.ptr -> i64
%404 = llvm.getelementptr %368[%403] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%402 = llvm.load %404 : !llvm.ptr -> i32
%405 = arith.extsi %402 : i32 to i64
%406 = llvm.load %392 : !llvm.ptr -> i64
%407 = arith.addi %405, %406 : i64
%408 = arith.trunci %407 : i64 to i32
%409 = llvm.load %398 : !llvm.ptr -> i64
%410 = llvm.getelementptr %368[%409] : (!llvm.ptr, i64) -> !llvm.ptr, i32
llvm.store %408, %410 : i32, !llvm.ptr
%411 = llvm.load %398 : !llvm.ptr -> i64
%412 = llvm.load %392 : !llvm.ptr -> i64
%413 = arith.addi %411, %412 : i64
llvm.store %413, %398 : i64, !llvm.ptr
cf.br ^bb84
^bb86:
%414 = llvm.load %392 : !llvm.ptr -> i64
%415 = arith.constant 1 : i32
%417 = arith.extsi %415 : i32 to i64
%416 = arith.addi %414, %417 : i64
llvm.store %416, %392 : i64, !llvm.ptr
cf.br ^bb81
^bb83:
%418 = arith.constant 0 : i32
%419 = arith.extsi %418 : i32 to i64
llvm.store %419, %340 : i64, !llvm.ptr
%420 = arith.constant 1 : i32
%421 = arith.extsi %420 : i32 to i64
llvm.store %421, %270 : i64, !llvm.ptr
cf.br ^bb87
^bb87:
%422 = llvm.load %270 : !llvm.ptr -> i64
%423 = llvm.load %197 : !llvm.ptr -> i64
%424 = arith.cmpi sle, %422, %423 : i64
cf.cond_br %424, ^bb88, ^bb89
^bb88:
%425 = llvm.load %340 : !llvm.ptr -> i64
%427 = llvm.load %270 : !llvm.ptr -> i64
%428 = llvm.getelementptr %368[%427] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%426 = llvm.load %428 : !llvm.ptr -> i32
%429 = arith.extsi %426 : i32 to i64
%430 = arith.addi %425, %429 : i64
%431 = arith.remsi %430, %193 : i64
llvm.store %431, %340 : i64, !llvm.ptr
%432 = llvm.load %340 : !llvm.ptr -> i64
%433 = llvm.load %270 : !llvm.ptr -> i64
%434 = llvm.getelementptr %375[%433] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %432, %434 : i64, !llvm.ptr
%435 = llvm.load %270 : !llvm.ptr -> i64
%436 = arith.constant 1 : i32
%438 = arith.extsi %436 : i32 to i64
%437 = arith.addi %435, %438 : i64
llvm.store %437, %270 : i64, !llvm.ptr
cf.br ^bb87
^bb89:
%439 = arith.constant 4000003 : i32
%440 = arith.extsi %439 : i32 to i64
%442 = arith.constant 8 : i32
%443 = arith.extsi %442 : i32 to i64
%441 = func.call @calloc(%440, %443) : (i64, i64) -> !llvm.ptr
%445 = arith.constant 8 : i32
%446 = arith.extsi %445 : i32 to i64
%444 = func.call @calloc(%440, %446) : (i64, i64) -> !llvm.ptr
%448 = arith.constant 1 : i32
%449 = arith.extsi %448 : i32 to i64
%447 = func.call @calloc(%440, %449) : (i64, i64) -> !llvm.ptr
%450 = llvm.mlir.zero : !llvm.ptr
%451 = llvm.icmp "eq" %441, %450 : !llvm.ptr
cf.cond_br %451, ^bb90, ^bb91
^bb90:
%452 = arith.constant 1 : i32
func.return %452 : i32
^bb91:
cf.br ^bb92
^bb92:
%453 = arith.constant 0 : i32
%454 = arith.extsi %453 : i32 to i64
%455 = llvm.mlir.constant(1 : i64) : i64
%456 = llvm.alloca %455 x i64 : (i64) -> !llvm.ptr
llvm.store %454, %456 : i64, !llvm.ptr
%457 = arith.constant 1 : i32
%458 = arith.extsi %457 : i32 to i64
%459 = llvm.mlir.constant(1 : i64) : i64
%460 = llvm.alloca %459 x i64 : (i64) -> !llvm.ptr
llvm.store %458, %460 : i64, !llvm.ptr
%461 = arith.constant 0 : i32
%462 = arith.extsi %461 : i32 to i64
%463 = llvm.mlir.constant(1 : i64) : i64
%464 = llvm.alloca %463 x i64 : (i64) -> !llvm.ptr
llvm.store %462, %464 : i64, !llvm.ptr
cf.br ^bb93
^bb93:
%465 = llvm.load %460 : !llvm.ptr -> i64
%466 = arith.cmpi sle, %465, %191 : i64
cf.cond_br %466, ^bb94, ^bb95
^bb94:
%467 = llvm.load %460 : !llvm.ptr -> i64
%468 = arith.divsi %191, %467 : i64
%469 = arith.divsi %191, %468 : i64
%471 = llvm.load %215 : !llvm.ptr -> i64
%470 = func.call @imu(%469, %471, %193, %244, %441, %444, %447, %440) : (i64, i64, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64) -> i64
%472 = llvm.load %464 : !llvm.ptr -> i64
%473 = arith.subi %470, %472 : i64
%474 = arith.remsi %473, %193 : i64
%475 = arith.constant 0 : i32
%477 = arith.extsi %475 : i32 to i64
%476 = arith.cmpi slt, %474, %477 : i64
%478 = scf.if %476 -> (i64) {
%479 = arith.addi %474, %193 : i64
scf.yield %479 : i64
} else {
scf.yield %474 : i64
}
llvm.store %470, %464 : i64, !llvm.ptr
%481 = llvm.load %197 : !llvm.ptr -> i64
%480 = func.call @Hval(%468, %481, %193, %375) : (i64, i64, i64, !llvm.ptr) -> i64
%482 = llvm.load %456 : !llvm.ptr -> i64
%483 = arith.muli %480, %480 : i64
%484 = arith.remsi %483, %193 : i64
%485 = arith.muli %478, %484 : i64
%486 = arith.addi %482, %485 : i64
%487 = arith.remsi %486, %193 : i64
llvm.store %487, %456 : i64, !llvm.ptr
%488 = arith.constant 1 : i32
%490 = arith.extsi %488 : i32 to i64
%489 = arith.addi %469, %490 : i64
llvm.store %489, %460 : i64, !llvm.ptr
cf.br ^bb93
^bb95:
%491 = llvm.mlir.addressof @str_0 : !llvm.ptr
%492 = llvm.load %456 : !llvm.ptr -> i64
%493 = llvm.call @printf(%491, %492) vararg(!llvm.func<i32 (ptr, ...)>) : (!llvm.ptr, i64) -> i32
%494 = arith.constant 0 : i32
func.return %494 : i32
}
}