Problem 432
Last 9 digits of sum_{i=1}^{10^11} phi(510510*i).
View problem on Project Euler
Performance comparison
| Metric | Our solution | Best known |
| Time complexity | O(n^2) | O(n) |
| Space complexity | O(n^2) | O(n) |
| Approach | Flow solution | Big-integer arithmetic |
| Verdict | Suboptimal |
Flow source
# Project Euler 432
# Last 9 digits of sum_{i=1}^{10^11} phi(510510*i).
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 Phi(
x: i64, LIMIT: i64, MOD: i64, pref: ptr<i64>,
keys: ptr<i64>, vals: ptr<i64>, used: ptr<i8>, HCAP: i64
) -> i64 {
if x <= LIMIT { return pref[x] }
let cached: i64 = hget(keys, vals, used, HCAP, x)
if cached >= 0 { return cached }
let mut ans: i64 = ((x % (2 * MOD)) * ((x + 1) % (2 * MOD)) / 2) % MOD
let mut i: i64 = 2
while i <= x {
let q: i64 = x / i
let j: i64 = x / q
let cnt: i64 = (j - i + 1) % MOD
ans = (ans - cnt * Phi(q, LIMIT, MOD, pref, keys, vals, used, HCAP)) % MOD
if ans < 0 { ans = ans + MOD }
i = j + 1
}
hput(keys, vals, used, HCAP, x, ans)
return ans
}
function main() -> i32 {
let MOD: i64 = 1000000000
let n: i64 = 510510
let m: i64 = 100000000000
let LIMIT: i64 = 5000000
let phi: ptr<i32> = calloc(LIMIT + 1, 4)
let pref: ptr<i64> = calloc(LIMIT + 1, 8)
let primes: ptr<i32> = calloc(LIMIT / 5 + 10, 4)
if phi == null || pref == null || primes == null { return 1 }
phi[1] = 1
let mut pc: i64 = 0
let mut i: i64 = 2
while i <= LIMIT {
if phi[i] == 0 {
phi[i] = (i - 1) as i32
primes[pc] = i as i32
pc = pc + 1
}
let mut j: i64 = 0
while j < pc {
let p: i64 = primes[j] as i64
let ip: i64 = i * p
if ip > LIMIT { break }
if i % p == 0 {
phi[ip] = ((phi[i] as i64) * p) as i32
break
} else {
phi[ip] = ((phi[i] as i64) * (p - 1)) as i32
}
j = j + 1
}
i = i + 1
}
let mut acc: i64 = 0
i = 1
while i <= LIMIT {
acc = (acc + (phi[i] as i64)) % MOD
pref[i] = acc
i = i + 1
}
let pf0: i64 = 2
let pf1: i64 = 3
let pf2: i64 = 5
let pf3: i64 = 7
let pf4: i64 = 11
let pf5: i64 = 13
let pf6: i64 = 17
let kpf: i64 = 7
let nsub: i64 = 128
let prods: ptr<i64> = calloc(nsub, 8)
let signs: ptr<i64> = calloc(nsub, 8)
let mut nlist: i64 = 0
let mut mask: i64 = 1
while mask < nsub {
let mut prod: i64 = 1
let mut bits: i64 = 0
if (mask & 1) != 0 { prod = prod * pf0; bits = bits + 1 }
if (mask & 2) != 0 { prod = prod * pf1; bits = bits + 1 }
if (mask & 4) != 0 { prod = prod * pf2; bits = bits + 1 }
if (mask & 8) != 0 { prod = prod * pf3; bits = bits + 1 }
if (mask & 16) != 0 { prod = prod * pf4; bits = bits + 1 }
if (mask & 32) != 0 { prod = prod * pf5; bits = bits + 1 }
if (mask & 64) != 0 { prod = prod * pf6; bits = bits + 1 }
prods[nlist] = prod
if (bits & 1) == 1 { signs[nlist] = 1 } else { signs[nlist] = -1 }
nlist = nlist + 1
mask = mask + 1
}
let mut a: i64 = 1
while a < nlist {
let mut b2: i64 = a
while b2 > 0 && prods[b2 - 1] > prods[b2] {
let tp: i64 = prods[b2]
prods[b2] = prods[b2 - 1]
prods[b2 - 1] = tp
let ts: i64 = signs[b2]
signs[b2] = signs[b2 - 1]
signs[b2 - 1] = ts
b2 = b2 - 1
}
a = a + 1
}
let phi_n: i64 = phi[n] as i64
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)
let Skeys: ptr<i64> = calloc(HCAP, 8)
let Svals: ptr<i64> = calloc(HCAP, 8)
let Suset: ptr<i8> = calloc(HCAP, 1)
let stack: ptr<i64> = calloc(300000, 8)
if keys == null || Skeys == null || stack == null { return 1 }
let mut top: i64 = 0
stack[top] = m
top = top + 1
while top > 0 {
let mm: i64 = stack[top - 1]
if hget(Skeys, Svals, Suset, HCAP, mm) >= 0 {
top = top - 1
continue
}
let _p: i64 = Phi(mm, LIMIT, MOD, pref, keys, vals, used, HCAP)
let mut ready: i64 = 1
let mut t: i64 = 0
while t < nlist {
let pr: i64 = prods[t]
if pr <= mm {
let q: i64 = mm / pr
if q > 0 && hget(Skeys, Svals, Suset, HCAP, q) < 0 {
stack[top] = q
top = top + 1
ready = 0
}
}
t = t + 1
}
if ready == 1 {
let mut ans: i64 = ((phi_n % MOD) * Phi(mm, LIMIT, MOD, pref, keys, vals, used, HCAP)) % MOD
t = 0
while t < nlist {
let pr2: i64 = prods[t]
if pr2 <= mm {
let q2: i64 = mm / pr2
let sq: i64 = hget(Skeys, Svals, Suset, HCAP, q2)
ans = (ans + signs[t] * sq) % MOD
}
t = t + 1
}
if ans < 0 { ans = ans + MOD }
hput(Skeys, Svals, Suset, HCAP, mm, ans)
top = top - 1
}
}
let answer: i64 = hget(Skeys, Svals, Suset, HCAP, m)
printf("%09lld\n", answer)
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 Phi_i64_i64_i64_ptr_i64_ptr_i64_ptr_i64_ptr_i8_i64(int64_t x, int64_t LIMIT, int64_t MOD, int64_t* pref, int64_t* keys, int64_t* vals, int8_t* used, int64_t HCAP);
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 Phi_i64_i64_i64_ptr_i64_ptr_i64_ptr_i64_ptr_i8_i64(int64_t x, int64_t LIMIT, int64_t MOD, int64_t* pref, int64_t* keys, int64_t* vals, int8_t* used, int64_t HCAP) {
if (x <= LIMIT) {
return pref[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 ans = FLOW_CHECKED_MOD((FLOW_CHECKED_DIV(((FLOW_CHECKED_MOD((x), ((2 * MOD))) * FLOW_CHECKED_MOD(((x + 1)), ((2 * MOD))))), (2))), (MOD));
int64_t i = 2;
while (i <= x) {
int64_t q = FLOW_CHECKED_DIV((x), (i));
int64_t j = FLOW_CHECKED_DIV((x), (q));
int64_t cnt = FLOW_CHECKED_MOD((((j - i) + 1)), (MOD));
ans = FLOW_CHECKED_MOD(((ans - (cnt * Phi_i64_i64_i64_ptr_i64_ptr_i64_ptr_i64_ptr_i8_i64(q, LIMIT, MOD, pref, keys, vals, used, HCAP)))), (MOD));
if (ans < 0) {
ans = (ans + MOD);
}
i = (j + 1);
}
hput_ptr_i64_ptr_i64_ptr_i8_i64_i64_i64(keys, vals, used, HCAP, x, ans);
return ans;
}
int32_t main(void) {
int64_t MOD = 1000000000;
int64_t n = 510510;
int64_t m = 100000000000;
int64_t LIMIT = 5000000;
int32_t* phi = (int32_t*)(calloc((LIMIT + 1), 4));
int64_t* pref = (int64_t*)(calloc((LIMIT + 1), 8));
int32_t* primes = (int32_t*)(calloc((FLOW_CHECKED_DIV((LIMIT), (5)) + 10), 4));
if (((phi == NULL || pref == NULL) || primes == NULL)) {
return 1;
}
phi[1] = 1;
int64_t pc = 0;
int64_t i = 2;
while (i <= LIMIT) {
if (phi[i] == 0) {
phi[i] = ((int32_t)((i - 1)));
primes[pc] = ((int32_t)(i));
pc = (pc + 1);
}
int64_t j = 0;
while (j < pc) {
int64_t p = ((int64_t)(primes[j]));
int64_t ip = (i * p);
if (ip > LIMIT) {
break;
}
if (FLOW_CHECKED_MOD((i), (p)) == 0) {
phi[ip] = ((int32_t)((((int64_t)(phi[i])) * p)));
break;
} else {
phi[ip] = ((int32_t)((((int64_t)(phi[i])) * (p - 1))));
}
j = (j + 1);
}
i = (i + 1);
}
int64_t acc = 0;
i = 1;
while (i <= LIMIT) {
acc = FLOW_CHECKED_MOD(((acc + ((int64_t)(phi[i])))), (MOD));
pref[i] = acc;
i = (i + 1);
}
int64_t pf0 = 2;
int64_t pf1 = 3;
int64_t pf2 = 5;
int64_t pf3 = 7;
int64_t pf4 = 11;
int64_t pf5 = 13;
int64_t pf6 = 17;
int64_t kpf = 7;
int64_t nsub = 128;
int64_t* prods = (int64_t*)(calloc(nsub, 8));
int64_t* signs = (int64_t*)(calloc(nsub, 8));
int64_t nlist = 0;
int64_t mask = 1;
while (mask < nsub) {
int64_t prod = 1;
int64_t bits = 0;
if ((mask & 1) != 0) {
prod = (prod * pf0);
bits = (bits + 1);
}
if ((mask & 2) != 0) {
prod = (prod * pf1);
bits = (bits + 1);
}
if ((mask & 4) != 0) {
prod = (prod * pf2);
bits = (bits + 1);
}
if ((mask & 8) != 0) {
prod = (prod * pf3);
bits = (bits + 1);
}
if ((mask & 16) != 0) {
prod = (prod * pf4);
bits = (bits + 1);
}
if ((mask & 32) != 0) {
prod = (prod * pf5);
bits = (bits + 1);
}
if ((mask & 64) != 0) {
prod = (prod * pf6);
bits = (bits + 1);
}
prods[nlist] = prod;
if ((bits & 1) == 1) {
signs[nlist] = 1;
} else {
signs[nlist] = (-1);
}
nlist = (nlist + 1);
mask = (mask + 1);
}
int64_t a = 1;
while (a < nlist) {
int64_t b2 = a;
while ((b2 > 0 && prods[(b2 - 1)] > prods[b2])) {
int64_t tp = prods[b2];
prods[b2] = prods[(b2 - 1)];
prods[(b2 - 1)] = tp;
int64_t ts = signs[b2];
signs[b2] = signs[(b2 - 1)];
signs[(b2 - 1)] = ts;
b2 = (b2 - 1);
}
a = (a + 1);
}
int64_t phi_n = ((int64_t)(phi[n]));
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));
int64_t* Skeys = (int64_t*)(calloc(HCAP, 8));
int64_t* Svals = (int64_t*)(calloc(HCAP, 8));
int8_t* Suset = (int8_t*)(calloc(HCAP, 1));
int64_t* stack = (int64_t*)(calloc(300000, 8));
if (((keys == NULL || Skeys == NULL) || stack == NULL)) {
return 1;
}
int64_t top = 0;
stack[top] = m;
top = (top + 1);
while (top > 0) {
int64_t mm = stack[(top - 1)];
if (hget_ptr_i64_ptr_i64_ptr_i8_i64_i64(Skeys, Svals, Suset, HCAP, mm) >= 0) {
top = (top - 1);
continue;
}
int64_t _p = Phi_i64_i64_i64_ptr_i64_ptr_i64_ptr_i64_ptr_i8_i64(mm, LIMIT, MOD, pref, keys, vals, used, HCAP);
int64_t ready = 1;
int64_t t = 0;
while (t < nlist) {
int64_t pr = prods[t];
if (pr <= mm) {
int64_t q = FLOW_CHECKED_DIV((mm), (pr));
if ((q > 0 && hget_ptr_i64_ptr_i64_ptr_i8_i64_i64(Skeys, Svals, Suset, HCAP, q) < 0)) {
stack[top] = q;
top = (top + 1);
ready = 0;
}
}
t = (t + 1);
}
if (ready == 1) {
int64_t ans = FLOW_CHECKED_MOD(((FLOW_CHECKED_MOD((phi_n), (MOD)) * Phi_i64_i64_i64_ptr_i64_ptr_i64_ptr_i64_ptr_i8_i64(mm, LIMIT, MOD, pref, keys, vals, used, HCAP))), (MOD));
t = 0;
while (t < nlist) {
int64_t pr2 = prods[t];
if (pr2 <= mm) {
int64_t q2 = FLOW_CHECKED_DIV((mm), (pr2));
int64_t sq = hget_ptr_i64_ptr_i64_ptr_i8_i64_i64(Skeys, Svals, Suset, HCAP, q2);
ans = FLOW_CHECKED_MOD(((ans + (signs[t] * sq))), (MOD));
}
t = (t + 1);
}
if (ans < 0) {
ans = (ans + MOD);
}
hput_ptr_i64_ptr_i64_ptr_i8_i64_i64_i64(Skeys, Svals, Suset, HCAP, mm, ans);
top = (top - 1);
}
}
int64_t answer = hget_ptr_i64_ptr_i64_ptr_i8_i64_i64(Skeys, Svals, Suset, HCAP, m);
printf("%09lld\n", answer);
return 0;
}
Generated MLIR
module {
llvm.func @printf(!llvm.ptr, ...) -> i32
llvm.mlir.global internal constant @str_0("%09lld\n\00") {addr_space = 0 : i32} : !llvm.array<8 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 @Phi(%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 2 : i32
%80 = arith.extsi %78 : i32 to i64
%79 = arith.muli %80, %arg2 : i64
%81 = arith.remsi %arg0, %79 : i64
%82 = arith.constant 1 : i32
%84 = arith.extsi %82 : i32 to i64
%83 = arith.addi %arg0, %84 : i64
%85 = arith.constant 2 : i32
%87 = arith.extsi %85 : i32 to i64
%86 = arith.muli %87, %arg2 : i64
%88 = arith.remsi %83, %86 : i64
%89 = arith.muli %81, %88 : i64
%90 = arith.constant 2 : i32
%92 = arith.extsi %90 : i32 to i64
%91 = arith.divsi %89, %92 : i64
%93 = arith.remsi %91, %arg2 : i64
%94 = llvm.mlir.constant(1 : i64) : i64
%95 = llvm.alloca %94 x i64 : (i64) -> !llvm.ptr
llvm.store %93, %95 : i64, !llvm.ptr
%96 = arith.constant 2 : i32
%97 = arith.extsi %96 : i32 to i64
%98 = llvm.mlir.constant(1 : i64) : i64
%99 = llvm.alloca %98 x i64 : (i64) -> !llvm.ptr
llvm.store %97, %99 : i64, !llvm.ptr
cf.br ^bb30
^bb30:
%100 = llvm.load %99 : !llvm.ptr -> i64
%101 = arith.cmpi sle, %100, %arg0 : i64
cf.cond_br %101, ^bb31, ^bb32
^bb31:
%102 = llvm.load %99 : !llvm.ptr -> i64
%103 = arith.divsi %arg0, %102 : i64
%104 = arith.divsi %arg0, %103 : i64
%105 = llvm.load %99 : !llvm.ptr -> i64
%106 = arith.subi %104, %105 : i64
%107 = arith.constant 1 : i32
%109 = arith.extsi %107 : i32 to i64
%108 = arith.addi %106, %109 : i64
%110 = arith.remsi %108, %arg2 : i64
%111 = llvm.load %95 : !llvm.ptr -> i64
%112 = func.call @Phi(%103, %arg1, %arg2, %arg3, %arg4, %arg5, %arg6, %arg7) : (i64, i64, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64) -> i64
%113 = arith.muli %110, %112 : i64
%114 = arith.subi %111, %113 : i64
%115 = arith.remsi %114, %arg2 : i64
llvm.store %115, %95 : i64, !llvm.ptr
%116 = llvm.load %95 : !llvm.ptr -> i64
%117 = arith.constant 0 : i32
%119 = arith.extsi %117 : i32 to i64
%118 = arith.cmpi slt, %116, %119 : i64
cf.cond_br %118, ^bb33, ^bb34
^bb33:
%120 = llvm.load %95 : !llvm.ptr -> i64
%121 = arith.addi %120, %arg2 : i64
llvm.store %121, %95 : i64, !llvm.ptr
cf.br ^bb35
^bb34:
cf.br ^bb35
^bb35:
%122 = arith.constant 1 : i32
%124 = arith.extsi %122 : i32 to i64
%123 = arith.addi %104, %124 : i64
llvm.store %123, %99 : i64, !llvm.ptr
cf.br ^bb30
^bb32:
%126 = llvm.load %95 : !llvm.ptr -> i64
func.call @hput(%arg4, %arg5, %arg6, %arg7, %arg0, %126) : (!llvm.ptr, !llvm.ptr, !llvm.ptr, i64, i64, i64) -> ()
%127 = llvm.load %95 : !llvm.ptr -> i64
func.return %127 : i64
}
func.func @main() -> i32 {
%128 = arith.constant 1000000000 : i32
%129 = arith.extsi %128 : i32 to i64
%130 = arith.constant 510510 : i32
%131 = arith.extsi %130 : i32 to i64
%132 = arith.constant 95705032704 : i32
%133 = arith.extsi %132 : i32 to i64
%134 = arith.constant 5000000 : i32
%135 = arith.extsi %134 : i32 to i64
%137 = arith.constant 1 : i32
%139 = arith.extsi %137 : i32 to i64
%138 = arith.addi %135, %139 : i64
%140 = arith.constant 4 : i32
%141 = arith.extsi %140 : i32 to i64
%136 = func.call @calloc(%138, %141) : (i64, i64) -> !llvm.ptr
%143 = arith.constant 1 : i32
%145 = arith.extsi %143 : i32 to i64
%144 = arith.addi %135, %145 : i64
%146 = arith.constant 8 : i32
%147 = arith.extsi %146 : i32 to i64
%142 = func.call @calloc(%144, %147) : (i64, i64) -> !llvm.ptr
%149 = arith.constant 5 : i32
%151 = arith.extsi %149 : i32 to i64
%150 = arith.divsi %135, %151 : i64
%152 = arith.constant 10 : i32
%154 = arith.extsi %152 : i32 to i64
%153 = arith.addi %150, %154 : i64
%155 = arith.constant 4 : i32
%156 = arith.extsi %155 : i32 to i64
%148 = func.call @calloc(%153, %156) : (i64, i64) -> !llvm.ptr
%157 = llvm.mlir.zero : !llvm.ptr
%158 = llvm.icmp "eq" %136, %157 : !llvm.ptr
%159 = scf.if %158 -> (i1) {
%160 = arith.constant true
scf.yield %160 : i1
} else {
%161 = llvm.mlir.zero : !llvm.ptr
%162 = llvm.icmp "eq" %142, %161 : !llvm.ptr
scf.yield %162 : i1
}
%163 = scf.if %159 -> (i1) {
%164 = arith.constant true
scf.yield %164 : i1
} else {
%165 = llvm.mlir.zero : !llvm.ptr
%166 = llvm.icmp "eq" %148, %165 : !llvm.ptr
scf.yield %166 : i1
}
cf.cond_br %163, ^bb36, ^bb37
^bb36:
%167 = arith.constant 1 : i32
func.return %167 : i32
^bb37:
cf.br ^bb38
^bb38:
%168 = arith.constant 1 : i32
%169 = arith.constant 1 : i32
%170 = arith.extsi %169 : i32 to i64
%171 = llvm.getelementptr %136[%170] : (!llvm.ptr, i64) -> !llvm.ptr, i32
llvm.store %168, %171 : i32, !llvm.ptr
%172 = arith.constant 0 : i32
%173 = arith.extsi %172 : i32 to i64
%174 = llvm.mlir.constant(1 : i64) : i64
%175 = llvm.alloca %174 x i64 : (i64) -> !llvm.ptr
llvm.store %173, %175 : i64, !llvm.ptr
%176 = arith.constant 2 : i32
%177 = arith.extsi %176 : i32 to i64
%178 = llvm.mlir.constant(1 : i64) : i64
%179 = llvm.alloca %178 x i64 : (i64) -> !llvm.ptr
llvm.store %177, %179 : i64, !llvm.ptr
cf.br ^bb39
^bb39:
%180 = llvm.load %179 : !llvm.ptr -> i64
%181 = arith.cmpi sle, %180, %135 : i64
cf.cond_br %181, ^bb40, ^bb41
^bb40:
%183 = llvm.load %179 : !llvm.ptr -> i64
%184 = llvm.getelementptr %136[%183] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%182 = llvm.load %184 : !llvm.ptr -> i32
%185 = arith.constant 0 : i32
%186 = arith.cmpi eq, %182, %185 : i32
cf.cond_br %186, ^bb42, ^bb43
^bb42:
%187 = llvm.load %179 : !llvm.ptr -> i64
%188 = arith.constant 1 : i32
%190 = arith.extsi %188 : i32 to i64
%189 = arith.subi %187, %190 : i64
%191 = arith.trunci %189 : i64 to i32
%192 = llvm.load %179 : !llvm.ptr -> i64
%193 = llvm.getelementptr %136[%192] : (!llvm.ptr, i64) -> !llvm.ptr, i32
llvm.store %191, %193 : i32, !llvm.ptr
%194 = llvm.load %179 : !llvm.ptr -> i64
%195 = arith.trunci %194 : i64 to i32
%196 = llvm.load %175 : !llvm.ptr -> i64
%197 = llvm.getelementptr %148[%196] : (!llvm.ptr, i64) -> !llvm.ptr, i32
llvm.store %195, %197 : i32, !llvm.ptr
%198 = llvm.load %175 : !llvm.ptr -> i64
%199 = arith.constant 1 : i32
%201 = arith.extsi %199 : i32 to i64
%200 = arith.addi %198, %201 : i64
llvm.store %200, %175 : i64, !llvm.ptr
cf.br ^bb44
^bb43:
cf.br ^bb44
^bb44:
%202 = arith.constant 0 : i32
%203 = arith.extsi %202 : i32 to i64
%204 = llvm.mlir.constant(1 : i64) : i64
%205 = llvm.alloca %204 x i64 : (i64) -> !llvm.ptr
llvm.store %203, %205 : i64, !llvm.ptr
cf.br ^bb45
^bb45:
%206 = llvm.load %205 : !llvm.ptr -> i64
%207 = llvm.load %175 : !llvm.ptr -> i64
%208 = arith.cmpi slt, %206, %207 : i64
cf.cond_br %208, ^bb46, ^bb47
^bb46:
%210 = llvm.load %205 : !llvm.ptr -> i64
%211 = llvm.getelementptr %148[%210] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%209 = llvm.load %211 : !llvm.ptr -> i32
%212 = arith.extsi %209 : i32 to i64
%213 = llvm.load %179 : !llvm.ptr -> i64
%214 = arith.muli %213, %212 : i64
%215 = arith.cmpi sgt, %214, %135 : i64
cf.cond_br %215, ^bb48, ^bb49
^bb48:
cf.br ^bb47
^bb49:
cf.br ^bb50
^bb50:
%216 = llvm.load %179 : !llvm.ptr -> i64
%217 = arith.remsi %216, %212 : i64
%218 = arith.constant 0 : i32
%220 = arith.extsi %218 : i32 to i64
%219 = arith.cmpi eq, %217, %220 : i64
cf.cond_br %219, ^bb51, ^bb52
^bb51:
%222 = llvm.load %179 : !llvm.ptr -> i64
%223 = llvm.getelementptr %136[%222] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%221 = llvm.load %223 : !llvm.ptr -> i32
%224 = arith.extsi %221 : i32 to i64
%225 = arith.muli %224, %212 : i64
%226 = arith.trunci %225 : i64 to i32
%227 = llvm.getelementptr %136[%214] : (!llvm.ptr, i64) -> !llvm.ptr, i32
llvm.store %226, %227 : i32, !llvm.ptr
cf.br ^bb47
^bb52:
%229 = llvm.load %179 : !llvm.ptr -> i64
%230 = llvm.getelementptr %136[%229] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%228 = llvm.load %230 : !llvm.ptr -> i32
%231 = arith.extsi %228 : i32 to i64
%232 = arith.constant 1 : i32
%234 = arith.extsi %232 : i32 to i64
%233 = arith.subi %212, %234 : i64
%235 = arith.muli %231, %233 : i64
%236 = arith.trunci %235 : i64 to i32
%237 = llvm.getelementptr %136[%214] : (!llvm.ptr, i64) -> !llvm.ptr, i32
llvm.store %236, %237 : i32, !llvm.ptr
cf.br ^bb53
^bb53:
%238 = llvm.load %205 : !llvm.ptr -> i64
%239 = arith.constant 1 : i32
%241 = arith.extsi %239 : i32 to i64
%240 = arith.addi %238, %241 : i64
llvm.store %240, %205 : i64, !llvm.ptr
cf.br ^bb45
^bb47:
%242 = llvm.load %179 : !llvm.ptr -> i64
%243 = arith.constant 1 : i32
%245 = arith.extsi %243 : i32 to i64
%244 = arith.addi %242, %245 : i64
llvm.store %244, %179 : i64, !llvm.ptr
cf.br ^bb39
^bb41:
%246 = arith.constant 0 : i32
%247 = arith.extsi %246 : i32 to i64
%248 = llvm.mlir.constant(1 : i64) : i64
%249 = llvm.alloca %248 x i64 : (i64) -> !llvm.ptr
llvm.store %247, %249 : i64, !llvm.ptr
%250 = arith.constant 1 : i32
%251 = arith.extsi %250 : i32 to i64
llvm.store %251, %179 : i64, !llvm.ptr
cf.br ^bb54
^bb54:
%252 = llvm.load %179 : !llvm.ptr -> i64
%253 = arith.cmpi sle, %252, %135 : i64
cf.cond_br %253, ^bb55, ^bb56
^bb55:
%254 = llvm.load %249 : !llvm.ptr -> i64
%256 = llvm.load %179 : !llvm.ptr -> i64
%257 = llvm.getelementptr %136[%256] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%255 = llvm.load %257 : !llvm.ptr -> i32
%258 = arith.extsi %255 : i32 to i64
%259 = arith.addi %254, %258 : i64
%260 = arith.remsi %259, %129 : i64
llvm.store %260, %249 : i64, !llvm.ptr
%261 = llvm.load %249 : !llvm.ptr -> i64
%262 = llvm.load %179 : !llvm.ptr -> i64
%263 = llvm.getelementptr %142[%262] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %261, %263 : i64, !llvm.ptr
%264 = llvm.load %179 : !llvm.ptr -> i64
%265 = arith.constant 1 : i32
%267 = arith.extsi %265 : i32 to i64
%266 = arith.addi %264, %267 : i64
llvm.store %266, %179 : i64, !llvm.ptr
cf.br ^bb54
^bb56:
%268 = arith.constant 2 : i32
%269 = arith.extsi %268 : i32 to i64
%270 = arith.constant 3 : i32
%271 = arith.extsi %270 : i32 to i64
%272 = arith.constant 5 : i32
%273 = arith.extsi %272 : i32 to i64
%274 = arith.constant 7 : i32
%275 = arith.extsi %274 : i32 to i64
%276 = arith.constant 11 : i32
%277 = arith.extsi %276 : i32 to i64
%278 = arith.constant 13 : i32
%279 = arith.extsi %278 : i32 to i64
%280 = arith.constant 17 : i32
%281 = arith.extsi %280 : i32 to i64
%282 = arith.constant 7 : i32
%283 = arith.extsi %282 : i32 to i64
%284 = arith.constant 128 : i32
%285 = arith.extsi %284 : i32 to i64
%287 = arith.constant 8 : i32
%288 = arith.extsi %287 : i32 to i64
%286 = func.call @calloc(%285, %288) : (i64, i64) -> !llvm.ptr
%290 = arith.constant 8 : i32
%291 = arith.extsi %290 : i32 to i64
%289 = func.call @calloc(%285, %291) : (i64, i64) -> !llvm.ptr
%292 = arith.constant 0 : i32
%293 = arith.extsi %292 : i32 to i64
%294 = llvm.mlir.constant(1 : i64) : i64
%295 = llvm.alloca %294 x i64 : (i64) -> !llvm.ptr
llvm.store %293, %295 : i64, !llvm.ptr
%296 = arith.constant 1 : i32
%297 = arith.extsi %296 : i32 to i64
%298 = llvm.mlir.constant(1 : i64) : i64
%299 = llvm.alloca %298 x i64 : (i64) -> !llvm.ptr
llvm.store %297, %299 : i64, !llvm.ptr
cf.br ^bb57
^bb57:
%300 = llvm.load %299 : !llvm.ptr -> i64
%301 = arith.cmpi slt, %300, %285 : i64
cf.cond_br %301, ^bb58, ^bb59
^bb58:
%302 = arith.constant 1 : i32
%303 = arith.extsi %302 : i32 to i64
%304 = llvm.mlir.constant(1 : i64) : i64
%305 = llvm.alloca %304 x i64 : (i64) -> !llvm.ptr
llvm.store %303, %305 : i64, !llvm.ptr
%306 = arith.constant 0 : i32
%307 = arith.extsi %306 : i32 to i64
%308 = llvm.mlir.constant(1 : i64) : i64
%309 = llvm.alloca %308 x i64 : (i64) -> !llvm.ptr
llvm.store %307, %309 : i64, !llvm.ptr
%310 = llvm.load %299 : !llvm.ptr -> i64
%311 = arith.constant 1 : i32
%313 = arith.extsi %311 : i32 to i64
%312 = arith.andi %310, %313 : i64
%314 = arith.constant 0 : i32
%316 = arith.extsi %314 : i32 to i64
%315 = arith.cmpi ne, %312, %316 : i64
cf.cond_br %315, ^bb60, ^bb61
^bb60:
%317 = llvm.load %305 : !llvm.ptr -> i64
%318 = arith.muli %317, %269 : i64
llvm.store %318, %305 : i64, !llvm.ptr
%319 = llvm.load %309 : !llvm.ptr -> i64
%320 = arith.constant 1 : i32
%322 = arith.extsi %320 : i32 to i64
%321 = arith.addi %319, %322 : i64
llvm.store %321, %309 : i64, !llvm.ptr
cf.br ^bb62
^bb61:
cf.br ^bb62
^bb62:
%323 = llvm.load %299 : !llvm.ptr -> i64
%324 = arith.constant 2 : i32
%326 = arith.extsi %324 : i32 to i64
%325 = arith.andi %323, %326 : i64
%327 = arith.constant 0 : i32
%329 = arith.extsi %327 : i32 to i64
%328 = arith.cmpi ne, %325, %329 : i64
cf.cond_br %328, ^bb63, ^bb64
^bb63:
%330 = llvm.load %305 : !llvm.ptr -> i64
%331 = arith.muli %330, %271 : i64
llvm.store %331, %305 : i64, !llvm.ptr
%332 = llvm.load %309 : !llvm.ptr -> i64
%333 = arith.constant 1 : i32
%335 = arith.extsi %333 : i32 to i64
%334 = arith.addi %332, %335 : i64
llvm.store %334, %309 : i64, !llvm.ptr
cf.br ^bb65
^bb64:
cf.br ^bb65
^bb65:
%336 = llvm.load %299 : !llvm.ptr -> i64
%337 = arith.constant 4 : i32
%339 = arith.extsi %337 : i32 to i64
%338 = arith.andi %336, %339 : i64
%340 = arith.constant 0 : i32
%342 = arith.extsi %340 : i32 to i64
%341 = arith.cmpi ne, %338, %342 : i64
cf.cond_br %341, ^bb66, ^bb67
^bb66:
%343 = llvm.load %305 : !llvm.ptr -> i64
%344 = arith.muli %343, %273 : i64
llvm.store %344, %305 : i64, !llvm.ptr
%345 = llvm.load %309 : !llvm.ptr -> i64
%346 = arith.constant 1 : i32
%348 = arith.extsi %346 : i32 to i64
%347 = arith.addi %345, %348 : i64
llvm.store %347, %309 : i64, !llvm.ptr
cf.br ^bb68
^bb67:
cf.br ^bb68
^bb68:
%349 = llvm.load %299 : !llvm.ptr -> i64
%350 = arith.constant 8 : i32
%352 = arith.extsi %350 : i32 to i64
%351 = arith.andi %349, %352 : i64
%353 = arith.constant 0 : i32
%355 = arith.extsi %353 : i32 to i64
%354 = arith.cmpi ne, %351, %355 : i64
cf.cond_br %354, ^bb69, ^bb70
^bb69:
%356 = llvm.load %305 : !llvm.ptr -> i64
%357 = arith.muli %356, %275 : i64
llvm.store %357, %305 : i64, !llvm.ptr
%358 = llvm.load %309 : !llvm.ptr -> i64
%359 = arith.constant 1 : i32
%361 = arith.extsi %359 : i32 to i64
%360 = arith.addi %358, %361 : i64
llvm.store %360, %309 : i64, !llvm.ptr
cf.br ^bb71
^bb70:
cf.br ^bb71
^bb71:
%362 = llvm.load %299 : !llvm.ptr -> i64
%363 = arith.constant 16 : i32
%365 = arith.extsi %363 : i32 to i64
%364 = arith.andi %362, %365 : i64
%366 = arith.constant 0 : i32
%368 = arith.extsi %366 : i32 to i64
%367 = arith.cmpi ne, %364, %368 : i64
cf.cond_br %367, ^bb72, ^bb73
^bb72:
%369 = llvm.load %305 : !llvm.ptr -> i64
%370 = arith.muli %369, %277 : i64
llvm.store %370, %305 : i64, !llvm.ptr
%371 = llvm.load %309 : !llvm.ptr -> i64
%372 = arith.constant 1 : i32
%374 = arith.extsi %372 : i32 to i64
%373 = arith.addi %371, %374 : i64
llvm.store %373, %309 : i64, !llvm.ptr
cf.br ^bb74
^bb73:
cf.br ^bb74
^bb74:
%375 = llvm.load %299 : !llvm.ptr -> i64
%376 = arith.constant 32 : i32
%378 = arith.extsi %376 : i32 to i64
%377 = arith.andi %375, %378 : i64
%379 = arith.constant 0 : i32
%381 = arith.extsi %379 : i32 to i64
%380 = arith.cmpi ne, %377, %381 : i64
cf.cond_br %380, ^bb75, ^bb76
^bb75:
%382 = llvm.load %305 : !llvm.ptr -> i64
%383 = arith.muli %382, %279 : i64
llvm.store %383, %305 : i64, !llvm.ptr
%384 = llvm.load %309 : !llvm.ptr -> i64
%385 = arith.constant 1 : i32
%387 = arith.extsi %385 : i32 to i64
%386 = arith.addi %384, %387 : i64
llvm.store %386, %309 : i64, !llvm.ptr
cf.br ^bb77
^bb76:
cf.br ^bb77
^bb77:
%388 = llvm.load %299 : !llvm.ptr -> i64
%389 = arith.constant 64 : i32
%391 = arith.extsi %389 : i32 to i64
%390 = arith.andi %388, %391 : i64
%392 = arith.constant 0 : i32
%394 = arith.extsi %392 : i32 to i64
%393 = arith.cmpi ne, %390, %394 : i64
cf.cond_br %393, ^bb78, ^bb79
^bb78:
%395 = llvm.load %305 : !llvm.ptr -> i64
%396 = arith.muli %395, %281 : i64
llvm.store %396, %305 : i64, !llvm.ptr
%397 = llvm.load %309 : !llvm.ptr -> i64
%398 = arith.constant 1 : i32
%400 = arith.extsi %398 : i32 to i64
%399 = arith.addi %397, %400 : i64
llvm.store %399, %309 : i64, !llvm.ptr
cf.br ^bb80
^bb79:
cf.br ^bb80
^bb80:
%401 = llvm.load %305 : !llvm.ptr -> i64
%402 = llvm.load %295 : !llvm.ptr -> i64
%403 = llvm.getelementptr %286[%402] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %401, %403 : i64, !llvm.ptr
%404 = llvm.load %309 : !llvm.ptr -> i64
%405 = arith.constant 1 : i32
%407 = arith.extsi %405 : i32 to i64
%406 = arith.andi %404, %407 : i64
%408 = arith.constant 1 : i32
%410 = arith.extsi %408 : i32 to i64
%409 = arith.cmpi eq, %406, %410 : i64
cf.cond_br %409, ^bb81, ^bb82
^bb81:
%411 = arith.constant 1 : i32
%412 = llvm.load %295 : !llvm.ptr -> i64
%413 = arith.extsi %411 : i32 to i64
%414 = llvm.getelementptr %289[%412] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %413, %414 : i64, !llvm.ptr
cf.br ^bb83
^bb82:
%415 = arith.constant 1 : i32
%417 = arith.constant 0 : i32
%416 = arith.subi %417, %415 : i32
%418 = llvm.load %295 : !llvm.ptr -> i64
%419 = arith.extsi %416 : i32 to i64
%420 = llvm.getelementptr %289[%418] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %419, %420 : i64, !llvm.ptr
cf.br ^bb83
^bb83:
%421 = llvm.load %295 : !llvm.ptr -> i64
%422 = arith.constant 1 : i32
%424 = arith.extsi %422 : i32 to i64
%423 = arith.addi %421, %424 : i64
llvm.store %423, %295 : i64, !llvm.ptr
%425 = llvm.load %299 : !llvm.ptr -> i64
%426 = arith.constant 1 : i32
%428 = arith.extsi %426 : i32 to i64
%427 = arith.addi %425, %428 : i64
llvm.store %427, %299 : i64, !llvm.ptr
cf.br ^bb57
^bb59:
%429 = arith.constant 1 : i32
%430 = arith.extsi %429 : i32 to i64
%431 = llvm.mlir.constant(1 : i64) : i64
%432 = llvm.alloca %431 x i64 : (i64) -> !llvm.ptr
llvm.store %430, %432 : i64, !llvm.ptr
cf.br ^bb84
^bb84:
%433 = llvm.load %432 : !llvm.ptr -> i64
%434 = llvm.load %295 : !llvm.ptr -> i64
%435 = arith.cmpi slt, %433, %434 : i64
cf.cond_br %435, ^bb85, ^bb86
^bb85:
%436 = llvm.load %432 : !llvm.ptr -> i64
%437 = llvm.mlir.constant(1 : i64) : i64
%438 = llvm.alloca %437 x i64 : (i64) -> !llvm.ptr
llvm.store %436, %438 : i64, !llvm.ptr
cf.br ^bb87
^bb87:
%439 = llvm.load %438 : !llvm.ptr -> i64
%440 = arith.constant 0 : i32
%442 = arith.extsi %440 : i32 to i64
%441 = arith.cmpi sgt, %439, %442 : i64
%443 = scf.if %441 -> (i1) {
%445 = llvm.load %438 : !llvm.ptr -> i64
%446 = arith.constant 1 : i32
%448 = arith.extsi %446 : i32 to i64
%447 = arith.subi %445, %448 : i64
%449 = llvm.getelementptr %286[%447] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%444 = llvm.load %449 : !llvm.ptr -> i64
%451 = llvm.load %438 : !llvm.ptr -> i64
%452 = llvm.getelementptr %286[%451] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%450 = llvm.load %452 : !llvm.ptr -> i64
%453 = arith.cmpi sgt, %444, %450 : i64
scf.yield %453 : i1
} else {
%454 = arith.constant false
scf.yield %454 : i1
}
cf.cond_br %443, ^bb88, ^bb89
^bb88:
%456 = llvm.load %438 : !llvm.ptr -> i64
%457 = llvm.getelementptr %286[%456] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%455 = llvm.load %457 : !llvm.ptr -> i64
%459 = llvm.load %438 : !llvm.ptr -> i64
%460 = arith.constant 1 : i32
%462 = arith.extsi %460 : i32 to i64
%461 = arith.subi %459, %462 : i64
%463 = llvm.getelementptr %286[%461] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%458 = llvm.load %463 : !llvm.ptr -> i64
%464 = llvm.load %438 : !llvm.ptr -> i64
%465 = llvm.getelementptr %286[%464] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %458, %465 : i64, !llvm.ptr
%466 = llvm.load %438 : !llvm.ptr -> i64
%467 = arith.constant 1 : i32
%469 = arith.extsi %467 : i32 to i64
%468 = arith.subi %466, %469 : i64
%470 = llvm.getelementptr %286[%468] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %455, %470 : i64, !llvm.ptr
%472 = llvm.load %438 : !llvm.ptr -> i64
%473 = llvm.getelementptr %289[%472] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%471 = llvm.load %473 : !llvm.ptr -> i64
%475 = llvm.load %438 : !llvm.ptr -> i64
%476 = arith.constant 1 : i32
%478 = arith.extsi %476 : i32 to i64
%477 = arith.subi %475, %478 : i64
%479 = llvm.getelementptr %289[%477] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%474 = llvm.load %479 : !llvm.ptr -> i64
%480 = llvm.load %438 : !llvm.ptr -> i64
%481 = llvm.getelementptr %289[%480] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %474, %481 : i64, !llvm.ptr
%482 = llvm.load %438 : !llvm.ptr -> i64
%483 = arith.constant 1 : i32
%485 = arith.extsi %483 : i32 to i64
%484 = arith.subi %482, %485 : i64
%486 = llvm.getelementptr %289[%484] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %471, %486 : i64, !llvm.ptr
%487 = llvm.load %438 : !llvm.ptr -> i64
%488 = arith.constant 1 : i32
%490 = arith.extsi %488 : i32 to i64
%489 = arith.subi %487, %490 : i64
llvm.store %489, %438 : i64, !llvm.ptr
cf.br ^bb87
^bb89:
%491 = llvm.load %432 : !llvm.ptr -> i64
%492 = arith.constant 1 : i32
%494 = arith.extsi %492 : i32 to i64
%493 = arith.addi %491, %494 : i64
llvm.store %493, %432 : i64, !llvm.ptr
cf.br ^bb84
^bb86:
%496 = llvm.getelementptr %136[%131] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%495 = llvm.load %496 : !llvm.ptr -> i32
%497 = arith.extsi %495 : i32 to i64
%498 = arith.constant 4000003 : i32
%499 = arith.extsi %498 : i32 to i64
%501 = arith.constant 8 : i32
%502 = arith.extsi %501 : i32 to i64
%500 = func.call @calloc(%499, %502) : (i64, i64) -> !llvm.ptr
%504 = arith.constant 8 : i32
%505 = arith.extsi %504 : i32 to i64
%503 = func.call @calloc(%499, %505) : (i64, i64) -> !llvm.ptr
%507 = arith.constant 1 : i32
%508 = arith.extsi %507 : i32 to i64
%506 = func.call @calloc(%499, %508) : (i64, i64) -> !llvm.ptr
%510 = arith.constant 8 : i32
%511 = arith.extsi %510 : i32 to i64
%509 = func.call @calloc(%499, %511) : (i64, i64) -> !llvm.ptr
%513 = arith.constant 8 : i32
%514 = arith.extsi %513 : i32 to i64
%512 = func.call @calloc(%499, %514) : (i64, i64) -> !llvm.ptr
%516 = arith.constant 1 : i32
%517 = arith.extsi %516 : i32 to i64
%515 = func.call @calloc(%499, %517) : (i64, i64) -> !llvm.ptr
%519 = arith.constant 300000 : i32
%520 = arith.constant 8 : i32
%521 = arith.extsi %519 : i32 to i64
%522 = arith.extsi %520 : i32 to i64
%518 = func.call @calloc(%521, %522) : (i64, i64) -> !llvm.ptr
%523 = llvm.mlir.zero : !llvm.ptr
%524 = llvm.icmp "eq" %500, %523 : !llvm.ptr
%525 = scf.if %524 -> (i1) {
%526 = arith.constant true
scf.yield %526 : i1
} else {
%527 = llvm.mlir.zero : !llvm.ptr
%528 = llvm.icmp "eq" %509, %527 : !llvm.ptr
scf.yield %528 : i1
}
%529 = scf.if %525 -> (i1) {
%530 = arith.constant true
scf.yield %530 : i1
} else {
%531 = llvm.mlir.zero : !llvm.ptr
%532 = llvm.icmp "eq" %518, %531 : !llvm.ptr
scf.yield %532 : i1
}
cf.cond_br %529, ^bb90, ^bb91
^bb90:
%533 = arith.constant 1 : i32
func.return %533 : i32
^bb91:
cf.br ^bb92
^bb92:
%534 = arith.constant 0 : i32
%535 = arith.extsi %534 : i32 to i64
%536 = llvm.mlir.constant(1 : i64) : i64
%537 = llvm.alloca %536 x i64 : (i64) -> !llvm.ptr
llvm.store %535, %537 : i64, !llvm.ptr
%538 = llvm.load %537 : !llvm.ptr -> i64
%539 = llvm.getelementptr %518[%538] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %133, %539 : i64, !llvm.ptr
%540 = llvm.load %537 : !llvm.ptr -> i64
%541 = arith.constant 1 : i32
%543 = arith.extsi %541 : i32 to i64
%542 = arith.addi %540, %543 : i64
llvm.store %542, %537 : i64, !llvm.ptr
cf.br ^bb93
^bb93:
%544 = llvm.load %537 : !llvm.ptr -> i64
%545 = arith.constant 0 : i32
%547 = arith.extsi %545 : i32 to i64
%546 = arith.cmpi sgt, %544, %547 : i64
cf.cond_br %546, ^bb94, ^bb95
^bb94:
%549 = llvm.load %537 : !llvm.ptr -> i64
%550 = arith.constant 1 : i32
%552 = arith.extsi %550 : i32 to i64
%551 = arith.subi %549, %552 : i64
%553 = llvm.getelementptr %518[%551] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%548 = llvm.load %553 : !llvm.ptr -> i64
%554 = func.call @hget(%509, %512, %515, %499, %548) : (!llvm.ptr, !llvm.ptr, !llvm.ptr, i64, i64) -> i64
%555 = arith.constant 0 : i32
%557 = arith.extsi %555 : i32 to i64
%556 = arith.cmpi sge, %554, %557 : i64
cf.cond_br %556, ^bb96, ^bb97
^bb96:
%558 = llvm.load %537 : !llvm.ptr -> i64
%559 = arith.constant 1 : i32
%561 = arith.extsi %559 : i32 to i64
%560 = arith.subi %558, %561 : i64
llvm.store %560, %537 : i64, !llvm.ptr
cf.br ^bb93
^bb97:
cf.br ^bb98
^bb98:
%562 = func.call @Phi(%548, %135, %129, %142, %500, %503, %506, %499) : (i64, i64, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64) -> i64
%563 = arith.constant 1 : i32
%564 = arith.extsi %563 : i32 to i64
%565 = llvm.mlir.constant(1 : i64) : i64
%566 = llvm.alloca %565 x i64 : (i64) -> !llvm.ptr
llvm.store %564, %566 : i64, !llvm.ptr
%567 = arith.constant 0 : i32
%568 = arith.extsi %567 : i32 to i64
%569 = llvm.mlir.constant(1 : i64) : i64
%570 = llvm.alloca %569 x i64 : (i64) -> !llvm.ptr
llvm.store %568, %570 : i64, !llvm.ptr
cf.br ^bb99
^bb99:
%571 = llvm.load %570 : !llvm.ptr -> i64
%572 = llvm.load %295 : !llvm.ptr -> i64
%573 = arith.cmpi slt, %571, %572 : i64
cf.cond_br %573, ^bb100, ^bb101
^bb100:
%575 = llvm.load %570 : !llvm.ptr -> i64
%576 = llvm.getelementptr %286[%575] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%574 = llvm.load %576 : !llvm.ptr -> i64
%577 = arith.cmpi sle, %574, %548 : i64
cf.cond_br %577, ^bb102, ^bb103
^bb102:
%578 = arith.divsi %548, %574 : i64
%579 = arith.constant 0 : i32
%581 = arith.extsi %579 : i32 to i64
%580 = arith.cmpi sgt, %578, %581 : i64
%582 = scf.if %580 -> (i1) {
%583 = func.call @hget(%509, %512, %515, %499, %578) : (!llvm.ptr, !llvm.ptr, !llvm.ptr, i64, i64) -> i64
%584 = arith.constant 0 : i32
%586 = arith.extsi %584 : i32 to i64
%585 = arith.cmpi slt, %583, %586 : i64
scf.yield %585 : i1
} else {
%587 = arith.constant false
scf.yield %587 : i1
}
cf.cond_br %582, ^bb105, ^bb106
^bb105:
%588 = llvm.load %537 : !llvm.ptr -> i64
%589 = llvm.getelementptr %518[%588] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %578, %589 : i64, !llvm.ptr
%590 = llvm.load %537 : !llvm.ptr -> i64
%591 = arith.constant 1 : i32
%593 = arith.extsi %591 : i32 to i64
%592 = arith.addi %590, %593 : i64
llvm.store %592, %537 : i64, !llvm.ptr
%594 = arith.constant 0 : i32
%595 = arith.extsi %594 : i32 to i64
llvm.store %595, %566 : i64, !llvm.ptr
cf.br ^bb107
^bb106:
cf.br ^bb107
^bb107:
cf.br ^bb104
^bb103:
cf.br ^bb104
^bb104:
%596 = llvm.load %570 : !llvm.ptr -> i64
%597 = arith.constant 1 : i32
%599 = arith.extsi %597 : i32 to i64
%598 = arith.addi %596, %599 : i64
llvm.store %598, %570 : i64, !llvm.ptr
cf.br ^bb99
^bb101:
%600 = llvm.load %566 : !llvm.ptr -> i64
%601 = arith.constant 1 : i32
%603 = arith.extsi %601 : i32 to i64
%602 = arith.cmpi eq, %600, %603 : i64
cf.cond_br %602, ^bb108, ^bb109
^bb108:
%604 = arith.remsi %497, %129 : i64
%605 = func.call @Phi(%548, %135, %129, %142, %500, %503, %506, %499) : (i64, i64, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64) -> i64
%606 = arith.muli %604, %605 : i64
%607 = arith.remsi %606, %129 : i64
%608 = llvm.mlir.constant(1 : i64) : i64
%609 = llvm.alloca %608 x i64 : (i64) -> !llvm.ptr
llvm.store %607, %609 : i64, !llvm.ptr
%610 = arith.constant 0 : i32
%611 = arith.extsi %610 : i32 to i64
llvm.store %611, %570 : i64, !llvm.ptr
cf.br ^bb111
^bb111:
%612 = llvm.load %570 : !llvm.ptr -> i64
%613 = llvm.load %295 : !llvm.ptr -> i64
%614 = arith.cmpi slt, %612, %613 : i64
cf.cond_br %614, ^bb112, ^bb113
^bb112:
%616 = llvm.load %570 : !llvm.ptr -> i64
%617 = llvm.getelementptr %286[%616] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%615 = llvm.load %617 : !llvm.ptr -> i64
%618 = arith.cmpi sle, %615, %548 : i64
cf.cond_br %618, ^bb114, ^bb115
^bb114:
%619 = arith.divsi %548, %615 : i64
%620 = func.call @hget(%509, %512, %515, %499, %619) : (!llvm.ptr, !llvm.ptr, !llvm.ptr, i64, i64) -> i64
%621 = llvm.load %609 : !llvm.ptr -> i64
%623 = llvm.load %570 : !llvm.ptr -> i64
%624 = llvm.getelementptr %289[%623] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%622 = llvm.load %624 : !llvm.ptr -> i64
%625 = arith.muli %622, %620 : i64
%626 = arith.addi %621, %625 : i64
%627 = arith.remsi %626, %129 : i64
llvm.store %627, %609 : i64, !llvm.ptr
cf.br ^bb116
^bb115:
cf.br ^bb116
^bb116:
%628 = llvm.load %570 : !llvm.ptr -> i64
%629 = arith.constant 1 : i32
%631 = arith.extsi %629 : i32 to i64
%630 = arith.addi %628, %631 : i64
llvm.store %630, %570 : i64, !llvm.ptr
cf.br ^bb111
^bb113:
%632 = llvm.load %609 : !llvm.ptr -> i64
%633 = arith.constant 0 : i32
%635 = arith.extsi %633 : i32 to i64
%634 = arith.cmpi slt, %632, %635 : i64
cf.cond_br %634, ^bb117, ^bb118
^bb117:
%636 = llvm.load %609 : !llvm.ptr -> i64
%637 = arith.addi %636, %129 : i64
llvm.store %637, %609 : i64, !llvm.ptr
cf.br ^bb119
^bb118:
cf.br ^bb119
^bb119:
%639 = llvm.load %609 : !llvm.ptr -> i64
func.call @hput(%509, %512, %515, %499, %548, %639) : (!llvm.ptr, !llvm.ptr, !llvm.ptr, i64, i64, i64) -> ()
%640 = llvm.load %537 : !llvm.ptr -> i64
%641 = arith.constant 1 : i32
%643 = arith.extsi %641 : i32 to i64
%642 = arith.subi %640, %643 : i64
llvm.store %642, %537 : i64, !llvm.ptr
cf.br ^bb110
^bb109:
cf.br ^bb110
^bb110:
cf.br ^bb93
^bb95:
%644 = func.call @hget(%509, %512, %515, %499, %133) : (!llvm.ptr, !llvm.ptr, !llvm.ptr, i64, i64) -> i64
%645 = llvm.mlir.addressof @str_0 : !llvm.ptr
%646 = llvm.call @printf(%645, %644) vararg(!llvm.func<i32 (ptr, ...)>) : (!llvm.ptr, i64) -> i32
%647 = arith.constant 0 : i32
func.return %647 : i32
}
}