Problem 625
G(N) = sum_{j=1..N} sum_{i=1..j} gcd(i,j), G(10^11) mod 998244353. Dirichlet hyperbola: G(N) = sum_{k≤s} k·Φ(N/k) + sum_{k≤s} φ(k)·T(N/k) - T(s)·Φ(s) Φ(x) via memoized bottom-up: Φ(n) = T(n) - sum_{i=2..n} Φ(n/i)
View problem on Project Euler
Performance comparison
| Metric | Our solution | Best known |
| Time complexity | O(n^2) | O(n log n) |
| Space complexity | O(n^2) | O(n) |
| Approach | Flow solution | Geometric enumeration |
| Verdict | Suboptimal |
Flow source
# Project Euler 625
# G(N) = sum_{j=1..N} sum_{i=1..j} gcd(i,j), G(10^11) mod 998244353.
# Dirichlet hyperbola: G(N) = sum_{k≤s} k·Φ(N/k) + sum_{k≤s} φ(k)·T(N/k) - T(s)·Φ(s)
# Φ(x) via memoized bottom-up: Φ(n) = T(n) - sum_{i=2..n} Φ(n/i)
import euler.nt { isqrt }
extern {
function calloc(n: i64, size: i64) -> ptr<void>
function free(p: ptr<void>) -> void
}
function tri(n: i64, MOD: i64, INV2: i64) -> i64 {
let nm: i64 = n % MOD
return ((nm * ((nm + 1) % MOD) % MOD) * INV2) % MOD
}
# Hash lookup for memoized Phi values
function phi_lookup(q: i64, HCAP: i64, hkeys: ptr<i64>, hvals: ptr<i64>, hused: ptr<i8>) -> i64 {
let mut h: i64 = q % HCAP
while hused[h] != 0 {
if hkeys[h] == q { return hvals[h] }
h = h + 1
if h >= HCAP { h = 0 }
}
return 0
}
function phi_store(n: i64, val: i64, HCAP: i64, hkeys: ptr<i64>, hvals: ptr<i64>, hused: ptr<i8>) -> void {
let mut h: i64 = n % HCAP
while hused[h] != 0 {
if hkeys[h] == n { return }
h = h + 1
if h >= HCAP { h = 0 }
}
hused[h] = 1
hkeys[h] = n
hvals[h] = val
}
function main() -> i32 {
let N: i64 = 100000000000
let MOD: i64 = 998244353
let INV2: i64 = (MOD + 1) / 2
let PRECOMP: i64 = 10000000
# Linear sieve for phi
let phi: ptr<i64> = calloc(PRECOMP + 1, 8)
let is_comp: ptr<i8> = calloc(PRECOMP + 1, 1)
let primes: ptr<i32> = calloc(PRECOMP / 5 + 10, 4)
if phi == null || is_comp == null || primes == null { return 1 }
phi[1] = 1
let mut pc: i64 = 0
for i in 2..(PRECOMP + 1) {
if is_comp[i] == 0 {
primes[pc] = i as i32
pc = pc + 1
phi[i] = i - 1
}
for j in 0..pc {
let p: i64 = primes[j] as i64
let ip: i64 = i * p
if ip > PRECOMP { break }
is_comp[ip] = 1
if i % p == 0 { phi[ip] = phi[i] * p; break }
elif i % p != 0 { phi[ip] = phi[i] * (p - 1) }
}
}
# Prefix sums and phi_small
let s: i64 = isqrt(N)
let phi_small: ptr<i64> = calloc(s + 1, 8)
if phi_small == null { return 1 }
for i in 0..(s + 1) { phi_small[i] = phi[i] }
let pref: ptr<i64> = calloc(PRECOMP + 1, 8)
let mut acc: i64 = 0
for i in 1..(PRECOMP + 1) {
acc = (acc + phi[i]) % MOD
pref[i] = acc
}
# Hash table for memoized Phi(n)
let HCAP: i64 = 1 << 20
let hkeys: ptr<i64> = calloc(HCAP, 8)
let hvals: ptr<i64> = calloc(HCAP, 8)
let hused: ptr<i8> = calloc(HCAP, 1)
if hkeys == null || hvals == null || hused == null { return 1 }
# Collect large values of N/k (descending), reverse to ascending
let large_vals: ptr<i64> = calloc(s + 1, 8)
let mut nlarge: i64 = 0
for k in 1..(s + 1) {
let q: i64 = N / k
if q > PRECOMP { large_vals[nlarge] = q; nlarge = nlarge + 1 }
}
for a in 0..(nlarge / 2) {
let tmp: i64 = large_vals[a]
large_vals[a] = large_vals[nlarge - 1 - a]
large_vals[nlarge - 1 - a] = tmp
}
# Compute Phi for each large value bottom-up (ascending)
for idx in 0..nlarge {
let n: i64 = large_vals[idx]
let sn: i64 = isqrt(n)
let mut ans: i64 = tri(n, MOD, INV2)
# Small quotients: use prefix sums
let m_max: i64 = n / sn
for m in 1..m_max {
let coef: i64 = n / m - n / (m + 1)
if coef > 0 { ans = (ans - (coef % MOD) * pref[m]) % MOD }
}
# Large quotients: need Phi(n/i) from hash
let mut ii: i64 = 2
while ii <= sn {
let q: i64 = n / ii
let mut jj: i64 = ii
while jj + 1 <= sn && n / (jj + 1) == q { jj = jj + 1 }
let cnt: i64 = jj - ii + 1
let phi_q: i64 = 0
if q <= PRECOMP { phi_q = pref[q] }
elif q > PRECOMP { phi_q = phi_lookup(q, HCAP, hkeys, hvals, hused) }
ans = (ans - cnt * phi_q) % MOD
ii = jj + 1
}
ans = ans % MOD
if ans < 0 { ans = ans + MOD }
phi_store(n, ans, HCAP, hkeys, hvals, hused)
}
# G(N) via hyperbola split
let mut total: i64 = 0
# sum_{k≤s} k·Φ(N/k) with quotient grouping
let mut k: i64 = 1
while k <= s {
let q: i64 = N / k
let mut j: i64 = k
while j + 1 <= s && N / (j + 1) == q { j = j + 1 }
let sum_k: i64 = (k + j) * (j - k + 1) / 2
let phi_q: i64 = 0
if q <= PRECOMP { phi_q = pref[q] }
elif q > PRECOMP { phi_q = phi_lookup(q, HCAP, hkeys, hvals, hused) }
total = (total + (sum_k % MOD) * phi_q) % MOD
k = j + 1
}
# sum_{k≤s} φ(k)·T(N/k)
for k in 1..(s + 1) {
total = (total + phi_small[k] * tri(N / k, MOD, INV2)) % MOD
}
# subtract T(s)·Φ(s)
let phi_s: i64 = 0
if s <= PRECOMP { phi_s = pref[s] }
elif s > PRECOMP { phi_s = phi_lookup(s, HCAP, hkeys, hvals, hused) }
total = (total - tri(s, MOD, INV2) * phi_s) % MOD
if total < 0 { total = total + MOD }
printf("%lld\n", total)
free(large_vals)
free(hused)
free(hvals)
free(hkeys)
free(pref)
free(phi_small)
free(primes)
free(is_comp)
free(phi)
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 gcd_i64_i64(int64_t a0, int64_t b0);
int64_t lcm_i64_i64(int64_t a, int64_t b);
int64_t isqrt_i64(int64_t n);
int64_t mulmod_i64_i64_i64(int64_t a0, int64_t b0, int64_t mod);
int64_t mod_pow_i64_i64_i64(int64_t base, int64_t exp, int64_t mod);
bool is_prime_i64(int64_t n);
int64_t tri_i64_i64_i64(int64_t n, int64_t MOD, int64_t INV2);
int64_t phi_lookup_i64_i64_ptr_i64_ptr_i64_ptr_i8(int64_t q, int64_t HCAP, int64_t* hkeys, int64_t* hvals, int8_t* hused);
void phi_store_i64_i64_i64_ptr_i64_ptr_i64_ptr_i8(int64_t n, int64_t val, int64_t HCAP, int64_t* hkeys, int64_t* hvals, int8_t* hused);
int32_t main(void);
int64_t gcd_i64_i64(int64_t a0, int64_t b0) {
int64_t a = a0;
int64_t b = b0;
while (b != 0) {
int64_t t = FLOW_CHECKED_MOD((a), (b));
a = b;
b = t;
}
return a;
}
int64_t lcm_i64_i64(int64_t a, int64_t b) {
if ((a == 0 || b == 0)) {
return 0;
}
return (FLOW_CHECKED_DIV((a), (gcd_i64_i64(a, b))) * b);
}
int64_t isqrt_i64(int64_t n) {
if (n < 2) {
return n;
}
int64_t x = n;
int64_t y = FLOW_CHECKED_DIV(((x + 1)), (2));
while (y < x) {
x = y;
y = FLOW_CHECKED_DIV(((x + FLOW_CHECKED_DIV((n), (x)))), (2));
}
return x;
}
int64_t mulmod_i64_i64_i64(int64_t a0, int64_t b0, int64_t mod) {
int64_t a = FLOW_CHECKED_MOD((a0), (mod));
int64_t b = FLOW_CHECKED_MOD((b0), (mod));
int64_t result = 0;
while (b > 0) {
if (FLOW_CHECKED_MOD((b), (2)) == 1) {
result = FLOW_CHECKED_MOD(((result + a)), (mod));
}
a = FLOW_CHECKED_MOD(((a * 2)), (mod));
b = FLOW_CHECKED_DIV((b), (2));
}
return result;
}
int64_t mod_pow_i64_i64_i64(int64_t base, int64_t exp, int64_t mod) {
if (mod == 1) {
return 0;
}
int64_t result = 1;
int64_t b = FLOW_CHECKED_MOD((base), (mod));
int64_t e = exp;
while (e > 0) {
if (FLOW_CHECKED_MOD((e), (2)) == 1) {
result = mulmod_i64_i64_i64(result, b, mod);
}
b = mulmod_i64_i64_i64(b, b, mod);
e = FLOW_CHECKED_DIV((e), (2));
}
return result;
}
bool is_prime_i64(int64_t n) {
if (n < 2) {
return 0;
}
if (n < 4) {
return 1;
}
if ((FLOW_CHECKED_MOD((n), (2)) == 0 || FLOW_CHECKED_MOD((n), (3)) == 0)) {
return 0;
}
int64_t i = 5;
while ((i * i) <= n) {
if ((FLOW_CHECKED_MOD((n), (i)) == 0 || FLOW_CHECKED_MOD((n), ((i + 2))) == 0)) {
return 0;
}
i = (i + 6);
}
return 1;
}
int64_t tri_i64_i64_i64(int64_t n, int64_t MOD, int64_t INV2) {
int64_t nm = FLOW_CHECKED_MOD((n), (MOD));
return FLOW_CHECKED_MOD(((FLOW_CHECKED_MOD(((nm * FLOW_CHECKED_MOD(((nm + 1)), (MOD)))), (MOD)) * INV2)), (MOD));
}
int64_t phi_lookup_i64_i64_ptr_i64_ptr_i64_ptr_i8(int64_t q, int64_t HCAP, int64_t* hkeys, int64_t* hvals, int8_t* hused) {
int64_t h = FLOW_CHECKED_MOD((q), (HCAP));
while (hused[h] != 0) {
if (hkeys[h] == q) {
return hvals[h];
}
h = (h + 1);
if (h >= HCAP) {
h = 0;
}
}
return 0;
}
void phi_store_i64_i64_i64_ptr_i64_ptr_i64_ptr_i8(int64_t n, int64_t val, int64_t HCAP, int64_t* hkeys, int64_t* hvals, int8_t* hused) {
int64_t h = FLOW_CHECKED_MOD((n), (HCAP));
while (hused[h] != 0) {
if (hkeys[h] == n) {
return;
}
h = (h + 1);
if (h >= HCAP) {
h = 0;
}
}
hused[h] = 1;
hkeys[h] = n;
hvals[h] = val;
}
int32_t main(void) {
int64_t N = 100000000000;
int64_t MOD = 998244353;
int64_t INV2 = FLOW_CHECKED_DIV(((MOD + 1)), (2));
int64_t PRECOMP = 10000000;
int64_t* phi = (int64_t*)(calloc((PRECOMP + 1), 8));
int8_t* is_comp = (int8_t*)(calloc((PRECOMP + 1), 1));
int32_t* primes = (int32_t*)(calloc((FLOW_CHECKED_DIV((PRECOMP), (5)) + 10), 4));
if (((phi == NULL || is_comp == NULL) || primes == NULL)) {
return 1;
}
phi[1] = 1;
int64_t pc = 0;
int32_t __flow_step_1 = 1;
for (int32_t i = 2; (2 <= (PRECOMP + 1)) ? i < (PRECOMP + 1) : i > (PRECOMP + 1); i += (2 <= (PRECOMP + 1)) ? 1 : -1) {
if (is_comp[i] == 0) {
primes[pc] = ((int32_t)(i));
pc = (pc + 1);
phi[i] = (i - 1);
}
int32_t __flow_step_2 = 1;
for (int32_t j = 0; (0 <= pc) ? j < pc : j > pc; j += (0 <= pc) ? 1 : -1) {
int64_t p = ((int64_t)(primes[j]));
int64_t ip = (i * p);
if (ip > PRECOMP) {
break;
}
is_comp[ip] = 1;
if (FLOW_CHECKED_MOD((i), (p)) == 0) {
phi[ip] = (phi[i] * p);
break;
} else if (FLOW_CHECKED_MOD((i), (p)) != 0) {
phi[ip] = (phi[i] * (p - 1));
}
}
}
int64_t s = isqrt_i64(N);
int64_t* phi_small = (int64_t*)(calloc((s + 1), 8));
if (phi_small == NULL) {
return 1;
}
int32_t __flow_step_3 = 1;
for (int32_t i = 0; (0 <= (s + 1)) ? i < (s + 1) : i > (s + 1); i += (0 <= (s + 1)) ? 1 : -1) {
phi_small[i] = phi[i];
}
int64_t* pref = (int64_t*)(calloc((PRECOMP + 1), 8));
int64_t acc = 0;
int32_t __flow_step_4 = 1;
for (int32_t i = 1; (1 <= (PRECOMP + 1)) ? i < (PRECOMP + 1) : i > (PRECOMP + 1); i += (1 <= (PRECOMP + 1)) ? 1 : -1) {
acc = FLOW_CHECKED_MOD(((acc + phi[i])), (MOD));
pref[i] = acc;
}
int64_t HCAP = FLOW_CHECKED_SHL((1), (20));
int64_t* hkeys = (int64_t*)(calloc(HCAP, 8));
int64_t* hvals = (int64_t*)(calloc(HCAP, 8));
int8_t* hused = (int8_t*)(calloc(HCAP, 1));
if (((hkeys == NULL || hvals == NULL) || hused == NULL)) {
return 1;
}
int64_t* large_vals = (int64_t*)(calloc((s + 1), 8));
int64_t nlarge = 0;
int32_t __flow_step_5 = 1;
for (int32_t k = 1; (1 <= (s + 1)) ? k < (s + 1) : k > (s + 1); k += (1 <= (s + 1)) ? 1 : -1) {
int64_t q = FLOW_CHECKED_DIV((N), (k));
if (q > PRECOMP) {
large_vals[nlarge] = q;
nlarge = (nlarge + 1);
}
}
int32_t __flow_step_6 = 1;
for (int32_t a = 0; (0 <= FLOW_CHECKED_DIV((nlarge), (2))) ? a < FLOW_CHECKED_DIV((nlarge), (2)) : a > FLOW_CHECKED_DIV((nlarge), (2)); a += (0 <= FLOW_CHECKED_DIV((nlarge), (2))) ? 1 : -1) {
int64_t tmp = large_vals[a];
large_vals[a] = large_vals[((nlarge - 1) - a)];
large_vals[((nlarge - 1) - a)] = tmp;
}
int32_t __flow_step_7 = 1;
for (int32_t idx = 0; (0 <= nlarge) ? idx < nlarge : idx > nlarge; idx += (0 <= nlarge) ? 1 : -1) {
int64_t n = large_vals[idx];
int64_t sn = isqrt_i64(n);
int64_t ans = tri_i64_i64_i64(n, MOD, INV2);
int64_t m_max = FLOW_CHECKED_DIV((n), (sn));
int32_t __flow_step_8 = 1;
for (int32_t m = 1; (1 <= m_max) ? m < m_max : m > m_max; m += (1 <= m_max) ? 1 : -1) {
int64_t coef = (FLOW_CHECKED_DIV((n), (m)) - FLOW_CHECKED_DIV((n), ((m + 1))));
if (coef > 0) {
ans = FLOW_CHECKED_MOD(((ans - (FLOW_CHECKED_MOD((coef), (MOD)) * pref[m]))), (MOD));
}
}
int64_t ii = 2;
while (ii <= sn) {
int64_t q = FLOW_CHECKED_DIV((n), (ii));
int64_t jj = ii;
while (((jj + 1) <= sn && FLOW_CHECKED_DIV((n), ((jj + 1))) == q)) {
jj = (jj + 1);
}
int64_t cnt = ((jj - ii) + 1);
int64_t phi_q = 0;
if (q <= PRECOMP) {
phi_q = pref[q];
} else if (q > PRECOMP) {
phi_q = phi_lookup_i64_i64_ptr_i64_ptr_i64_ptr_i8(q, HCAP, hkeys, hvals, hused);
}
ans = FLOW_CHECKED_MOD(((ans - (cnt * phi_q))), (MOD));
ii = (jj + 1);
}
ans = FLOW_CHECKED_MOD((ans), (MOD));
if (ans < 0) {
ans = (ans + MOD);
}
phi_store_i64_i64_i64_ptr_i64_ptr_i64_ptr_i8(n, ans, HCAP, hkeys, hvals, hused);
}
int64_t total = 0;
int64_t k = 1;
while (k <= s) {
int64_t q = FLOW_CHECKED_DIV((N), (k));
int64_t j = k;
while (((j + 1) <= s && FLOW_CHECKED_DIV((N), ((j + 1))) == q)) {
j = (j + 1);
}
int64_t sum_k = FLOW_CHECKED_DIV((((k + j) * ((j - k) + 1))), (2));
int64_t phi_q = 0;
if (q <= PRECOMP) {
phi_q = pref[q];
} else if (q > PRECOMP) {
phi_q = phi_lookup_i64_i64_ptr_i64_ptr_i64_ptr_i8(q, HCAP, hkeys, hvals, hused);
}
total = FLOW_CHECKED_MOD(((total + (FLOW_CHECKED_MOD((sum_k), (MOD)) * phi_q))), (MOD));
k = (j + 1);
}
int32_t __flow_step_9 = 1;
for (int32_t k = 1; (1 <= (s + 1)) ? k < (s + 1) : k > (s + 1); k += (1 <= (s + 1)) ? 1 : -1) {
total = FLOW_CHECKED_MOD(((total + (phi_small[k] * tri_i64_i64_i64(FLOW_CHECKED_DIV((N), (k)), MOD, INV2)))), (MOD));
}
int64_t phi_s = 0;
if (s <= PRECOMP) {
phi_s = pref[s];
} else if (s > PRECOMP) {
phi_s = phi_lookup_i64_i64_ptr_i64_ptr_i64_ptr_i8(s, HCAP, hkeys, hvals, hused);
}
total = FLOW_CHECKED_MOD(((total - (tri_i64_i64_i64(s, MOD, INV2) * phi_s))), (MOD));
if (total < 0) {
total = (total + MOD);
}
printf("%lld\n", total);
free(large_vals);
free(hused);
free(hvals);
free(hkeys);
free(pref);
free(phi_small);
free(primes);
free(is_comp);
free(phi);
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 @gcd(%arg0: i64, %arg1: i64) -> i64 {
%0 = llvm.mlir.constant(1 : i64) : i64
%1 = llvm.alloca %0 x i64 : (i64) -> !llvm.ptr
llvm.store %arg0, %1 : i64, !llvm.ptr
%2 = llvm.mlir.constant(1 : i64) : i64
%3 = llvm.alloca %2 x i64 : (i64) -> !llvm.ptr
llvm.store %arg1, %3 : i64, !llvm.ptr
cf.br ^bb0
^bb0:
%4 = llvm.load %3 : !llvm.ptr -> i64
%5 = arith.constant 0 : i32
%7 = arith.extsi %5 : i32 to i64
%6 = arith.cmpi ne, %4, %7 : i64
cf.cond_br %6, ^bb1, ^bb2
^bb1:
%8 = llvm.load %1 : !llvm.ptr -> i64
%9 = llvm.load %3 : !llvm.ptr -> i64
%10 = arith.remsi %8, %9 : i64
%11 = llvm.load %3 : !llvm.ptr -> i64
llvm.store %11, %1 : i64, !llvm.ptr
llvm.store %10, %3 : i64, !llvm.ptr
cf.br ^bb0
^bb2:
%12 = llvm.load %1 : !llvm.ptr -> i64
func.return %12 : i64
}
func.func @lcm(%arg0: i64, %arg1: i64) -> i64 {
%13 = arith.constant 0 : i32
%15 = arith.extsi %13 : i32 to i64
%14 = arith.cmpi eq, %arg0, %15 : i64
%16 = scf.if %14 -> (i1) {
%17 = arith.constant true
scf.yield %17 : i1
} else {
%18 = arith.constant 0 : i32
%20 = arith.extsi %18 : i32 to i64
%19 = arith.cmpi eq, %arg1, %20 : i64
scf.yield %19 : i1
}
cf.cond_br %16, ^bb3, ^bb4
^bb3:
%21 = arith.constant 0 : i32
%22 = arith.extsi %21 : i32 to i64
func.return %22 : i64
^bb4:
cf.br ^bb5
^bb5:
%23 = func.call @gcd(%arg0, %arg1) : (i64, i64) -> i64
%24 = arith.divsi %arg0, %23 : i64
%25 = arith.muli %24, %arg1 : i64
func.return %25 : i64
}
func.func @isqrt(%arg0: i64) -> i64 {
%26 = arith.constant 2 : i32
%28 = arith.extsi %26 : i32 to i64
%27 = arith.cmpi slt, %arg0, %28 : i64
cf.cond_br %27, ^bb6, ^bb7
^bb6:
func.return %arg0 : i64
^bb7:
cf.br ^bb8
^bb8:
%29 = llvm.mlir.constant(1 : i64) : i64
%30 = llvm.alloca %29 x i64 : (i64) -> !llvm.ptr
llvm.store %arg0, %30 : i64, !llvm.ptr
%31 = llvm.load %30 : !llvm.ptr -> i64
%32 = arith.constant 1 : i32
%34 = arith.extsi %32 : i32 to i64
%33 = arith.addi %31, %34 : i64
%35 = arith.constant 2 : i32
%37 = arith.extsi %35 : i32 to i64
%36 = arith.divsi %33, %37 : i64
%38 = llvm.mlir.constant(1 : i64) : i64
%39 = llvm.alloca %38 x i64 : (i64) -> !llvm.ptr
llvm.store %36, %39 : i64, !llvm.ptr
cf.br ^bb9
^bb9:
%40 = llvm.load %39 : !llvm.ptr -> i64
%41 = llvm.load %30 : !llvm.ptr -> i64
%42 = arith.cmpi slt, %40, %41 : i64
cf.cond_br %42, ^bb10, ^bb11
^bb10:
%43 = llvm.load %39 : !llvm.ptr -> i64
llvm.store %43, %30 : i64, !llvm.ptr
%44 = llvm.load %30 : !llvm.ptr -> i64
%45 = llvm.load %30 : !llvm.ptr -> i64
%46 = arith.divsi %arg0, %45 : i64
%47 = arith.addi %44, %46 : i64
%48 = arith.constant 2 : i32
%50 = arith.extsi %48 : i32 to i64
%49 = arith.divsi %47, %50 : i64
llvm.store %49, %39 : i64, !llvm.ptr
cf.br ^bb9
^bb11:
%51 = llvm.load %30 : !llvm.ptr -> i64
func.return %51 : i64
}
func.func @mulmod(%arg0: i64, %arg1: i64, %arg2: i64) -> i64 {
%52 = arith.remsi %arg0, %arg2 : i64
%53 = llvm.mlir.constant(1 : i64) : i64
%54 = llvm.alloca %53 x i64 : (i64) -> !llvm.ptr
llvm.store %52, %54 : i64, !llvm.ptr
%55 = arith.remsi %arg1, %arg2 : i64
%56 = llvm.mlir.constant(1 : i64) : i64
%57 = llvm.alloca %56 x i64 : (i64) -> !llvm.ptr
llvm.store %55, %57 : i64, !llvm.ptr
%58 = arith.constant 0 : i32
%59 = arith.extsi %58 : i32 to i64
%60 = llvm.mlir.constant(1 : i64) : i64
%61 = llvm.alloca %60 x i64 : (i64) -> !llvm.ptr
llvm.store %59, %61 : i64, !llvm.ptr
cf.br ^bb12
^bb12:
%62 = llvm.load %57 : !llvm.ptr -> i64
%63 = arith.constant 0 : i32
%65 = arith.extsi %63 : i32 to i64
%64 = arith.cmpi sgt, %62, %65 : i64
cf.cond_br %64, ^bb13, ^bb14
^bb13:
%66 = llvm.load %57 : !llvm.ptr -> i64
%67 = arith.constant 2 : i32
%69 = arith.extsi %67 : i32 to i64
%68 = arith.remsi %66, %69 : i64
%70 = arith.constant 1 : i32
%72 = arith.extsi %70 : i32 to i64
%71 = arith.cmpi eq, %68, %72 : i64
cf.cond_br %71, ^bb15, ^bb16
^bb15:
%73 = llvm.load %61 : !llvm.ptr -> i64
%74 = llvm.load %54 : !llvm.ptr -> i64
%75 = arith.addi %73, %74 : i64
%76 = arith.remsi %75, %arg2 : i64
llvm.store %76, %61 : i64, !llvm.ptr
cf.br ^bb17
^bb16:
cf.br ^bb17
^bb17:
%77 = llvm.load %54 : !llvm.ptr -> i64
%78 = arith.constant 2 : i32
%80 = arith.extsi %78 : i32 to i64
%79 = arith.muli %77, %80 : i64
%81 = arith.remsi %79, %arg2 : i64
llvm.store %81, %54 : i64, !llvm.ptr
%82 = llvm.load %57 : !llvm.ptr -> i64
%83 = arith.constant 2 : i32
%85 = arith.extsi %83 : i32 to i64
%84 = arith.divsi %82, %85 : i64
llvm.store %84, %57 : i64, !llvm.ptr
cf.br ^bb12
^bb14:
%86 = llvm.load %61 : !llvm.ptr -> i64
func.return %86 : i64
}
func.func @mod_pow(%arg0: i64, %arg1: i64, %arg2: i64) -> i64 {
%87 = arith.constant 1 : i32
%89 = arith.extsi %87 : i32 to i64
%88 = arith.cmpi eq, %arg2, %89 : i64
cf.cond_br %88, ^bb18, ^bb19
^bb18:
%90 = arith.constant 0 : i32
%91 = arith.extsi %90 : i32 to i64
func.return %91 : i64
^bb19:
cf.br ^bb20
^bb20:
%92 = arith.constant 1 : i32
%93 = arith.extsi %92 : i32 to 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.remsi %arg0, %arg2 : i64
%97 = llvm.mlir.constant(1 : i64) : i64
%98 = llvm.alloca %97 x i64 : (i64) -> !llvm.ptr
llvm.store %96, %98 : i64, !llvm.ptr
%99 = llvm.mlir.constant(1 : i64) : i64
%100 = llvm.alloca %99 x i64 : (i64) -> !llvm.ptr
llvm.store %arg1, %100 : i64, !llvm.ptr
cf.br ^bb21
^bb21:
%101 = llvm.load %100 : !llvm.ptr -> i64
%102 = arith.constant 0 : i32
%104 = arith.extsi %102 : i32 to i64
%103 = arith.cmpi sgt, %101, %104 : i64
cf.cond_br %103, ^bb22, ^bb23
^bb22:
%105 = llvm.load %100 : !llvm.ptr -> i64
%106 = arith.constant 2 : i32
%108 = arith.extsi %106 : i32 to i64
%107 = arith.remsi %105, %108 : i64
%109 = arith.constant 1 : i32
%111 = arith.extsi %109 : i32 to i64
%110 = arith.cmpi eq, %107, %111 : i64
cf.cond_br %110, ^bb24, ^bb25
^bb24:
%113 = llvm.load %95 : !llvm.ptr -> i64
%114 = llvm.load %98 : !llvm.ptr -> i64
%112 = func.call @mulmod(%113, %114, %arg2) : (i64, i64, i64) -> i64
llvm.store %112, %95 : i64, !llvm.ptr
cf.br ^bb26
^bb25:
cf.br ^bb26
^bb26:
%116 = llvm.load %98 : !llvm.ptr -> i64
%117 = llvm.load %98 : !llvm.ptr -> i64
%115 = func.call @mulmod(%116, %117, %arg2) : (i64, i64, i64) -> i64
llvm.store %115, %98 : i64, !llvm.ptr
%118 = llvm.load %100 : !llvm.ptr -> i64
%119 = arith.constant 2 : i32
%121 = arith.extsi %119 : i32 to i64
%120 = arith.divsi %118, %121 : i64
llvm.store %120, %100 : i64, !llvm.ptr
cf.br ^bb21
^bb23:
%122 = llvm.load %95 : !llvm.ptr -> i64
func.return %122 : i64
}
func.func @is_prime(%arg0: i64) -> i1 {
%123 = arith.constant 2 : i32
%125 = arith.extsi %123 : i32 to i64
%124 = arith.cmpi slt, %arg0, %125 : i64
cf.cond_br %124, ^bb27, ^bb28
^bb27:
%126 = arith.constant 0 : i1
func.return %126 : i1
^bb28:
cf.br ^bb29
^bb29:
%127 = arith.constant 4 : i32
%129 = arith.extsi %127 : i32 to i64
%128 = arith.cmpi slt, %arg0, %129 : i64
cf.cond_br %128, ^bb30, ^bb31
^bb30:
%130 = arith.constant 1 : i1
func.return %130 : i1
^bb31:
cf.br ^bb32
^bb32:
%131 = arith.constant 2 : i32
%133 = arith.extsi %131 : i32 to i64
%132 = arith.remsi %arg0, %133 : i64
%134 = arith.constant 0 : i32
%136 = arith.extsi %134 : i32 to i64
%135 = arith.cmpi eq, %132, %136 : i64
%137 = scf.if %135 -> (i1) {
%138 = arith.constant true
scf.yield %138 : i1
} else {
%139 = arith.constant 3 : i32
%141 = arith.extsi %139 : i32 to i64
%140 = arith.remsi %arg0, %141 : i64
%142 = arith.constant 0 : i32
%144 = arith.extsi %142 : i32 to i64
%143 = arith.cmpi eq, %140, %144 : i64
scf.yield %143 : i1
}
cf.cond_br %137, ^bb33, ^bb34
^bb33:
%145 = arith.constant 0 : i1
func.return %145 : i1
^bb34:
cf.br ^bb35
^bb35:
%146 = arith.constant 5 : i32
%147 = arith.extsi %146 : i32 to i64
%148 = llvm.mlir.constant(1 : i64) : i64
%149 = llvm.alloca %148 x i64 : (i64) -> !llvm.ptr
llvm.store %147, %149 : i64, !llvm.ptr
cf.br ^bb36
^bb36:
%150 = llvm.load %149 : !llvm.ptr -> i64
%151 = llvm.load %149 : !llvm.ptr -> i64
%152 = arith.muli %150, %151 : i64
%153 = arith.cmpi sle, %152, %arg0 : i64
cf.cond_br %153, ^bb37, ^bb38
^bb37:
%154 = llvm.load %149 : !llvm.ptr -> i64
%155 = arith.remsi %arg0, %154 : i64
%156 = arith.constant 0 : i32
%158 = arith.extsi %156 : i32 to i64
%157 = arith.cmpi eq, %155, %158 : i64
%159 = scf.if %157 -> (i1) {
%160 = arith.constant true
scf.yield %160 : i1
} else {
%161 = llvm.load %149 : !llvm.ptr -> i64
%162 = arith.constant 2 : i32
%164 = arith.extsi %162 : i32 to i64
%163 = arith.addi %161, %164 : i64
%165 = arith.remsi %arg0, %163 : i64
%166 = arith.constant 0 : i32
%168 = arith.extsi %166 : i32 to i64
%167 = arith.cmpi eq, %165, %168 : i64
scf.yield %167 : i1
}
cf.cond_br %159, ^bb39, ^bb40
^bb39:
%169 = arith.constant 0 : i1
func.return %169 : i1
^bb40:
cf.br ^bb41
^bb41:
%170 = llvm.load %149 : !llvm.ptr -> i64
%171 = arith.constant 6 : i32
%173 = arith.extsi %171 : i32 to i64
%172 = arith.addi %170, %173 : i64
llvm.store %172, %149 : i64, !llvm.ptr
cf.br ^bb36
^bb38:
%174 = arith.constant 1 : i1
func.return %174 : i1
}
func.func private @calloc(i64, i64) -> !llvm.ptr
func.func private @free(!llvm.ptr) -> ()
func.func @tri(%arg0: i64, %arg1: i64, %arg2: i64) -> i64 {
%175 = arith.remsi %arg0, %arg1 : i64
%176 = arith.constant 1 : i32
%178 = arith.extsi %176 : i32 to i64
%177 = arith.addi %175, %178 : i64
%179 = arith.remsi %177, %arg1 : i64
%180 = arith.muli %175, %179 : i64
%181 = arith.remsi %180, %arg1 : i64
%182 = arith.muli %181, %arg2 : i64
%183 = arith.remsi %182, %arg1 : i64
func.return %183 : i64
}
func.func @phi_lookup(%arg0: i64, %arg1: i64, %arg2: !llvm.ptr, %arg3: !llvm.ptr, %arg4: !llvm.ptr) -> i64 {
%184 = arith.remsi %arg0, %arg1 : i64
%185 = llvm.mlir.constant(1 : i64) : i64
%186 = llvm.alloca %185 x i64 : (i64) -> !llvm.ptr
llvm.store %184, %186 : i64, !llvm.ptr
cf.br ^bb42
^bb42:
%188 = llvm.load %186 : !llvm.ptr -> i64
%189 = llvm.getelementptr %arg4[%188] : (!llvm.ptr, i64) -> !llvm.ptr, i8
%187 = llvm.load %189 : !llvm.ptr -> i8
%190 = arith.constant 0 : i32
%192 = arith.extsi %187 : i8 to i32
%191 = arith.cmpi ne, %192, %190 : i32
cf.cond_br %191, ^bb43, ^bb44
^bb43:
%194 = llvm.load %186 : !llvm.ptr -> i64
%195 = llvm.getelementptr %arg2[%194] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%193 = llvm.load %195 : !llvm.ptr -> i64
%196 = arith.cmpi eq, %193, %arg0 : i64
cf.cond_br %196, ^bb45, ^bb46
^bb45:
%198 = llvm.load %186 : !llvm.ptr -> i64
%199 = llvm.getelementptr %arg3[%198] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%197 = llvm.load %199 : !llvm.ptr -> i64
func.return %197 : i64
^bb46:
cf.br ^bb47
^bb47:
%200 = llvm.load %186 : !llvm.ptr -> i64
%201 = arith.constant 1 : i32
%203 = arith.extsi %201 : i32 to i64
%202 = arith.addi %200, %203 : i64
llvm.store %202, %186 : i64, !llvm.ptr
%204 = llvm.load %186 : !llvm.ptr -> i64
%205 = arith.cmpi sge, %204, %arg1 : i64
cf.cond_br %205, ^bb48, ^bb49
^bb48:
%206 = arith.constant 0 : i32
%207 = arith.extsi %206 : i32 to i64
llvm.store %207, %186 : i64, !llvm.ptr
cf.br ^bb50
^bb49:
cf.br ^bb50
^bb50:
cf.br ^bb42
^bb44:
%208 = arith.constant 0 : i32
%209 = arith.extsi %208 : i32 to i64
func.return %209 : i64
}
func.func @phi_store(%arg0: i64, %arg1: i64, %arg2: i64, %arg3: !llvm.ptr, %arg4: !llvm.ptr, %arg5: !llvm.ptr) -> () {
%210 = arith.remsi %arg0, %arg2 : i64
%211 = llvm.mlir.constant(1 : i64) : i64
%212 = llvm.alloca %211 x i64 : (i64) -> !llvm.ptr
llvm.store %210, %212 : i64, !llvm.ptr
cf.br ^bb51
^bb51:
%214 = llvm.load %212 : !llvm.ptr -> i64
%215 = llvm.getelementptr %arg5[%214] : (!llvm.ptr, i64) -> !llvm.ptr, i8
%213 = llvm.load %215 : !llvm.ptr -> i8
%216 = arith.constant 0 : i32
%218 = arith.extsi %213 : i8 to i32
%217 = arith.cmpi ne, %218, %216 : i32
cf.cond_br %217, ^bb52, ^bb53
^bb52:
%220 = llvm.load %212 : !llvm.ptr -> i64
%221 = llvm.getelementptr %arg3[%220] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%219 = llvm.load %221 : !llvm.ptr -> i64
%222 = arith.cmpi eq, %219, %arg0 : i64
cf.cond_br %222, ^bb54, ^bb55
^bb54:
func.return
^bb55:
cf.br ^bb56
^bb56:
%223 = llvm.load %212 : !llvm.ptr -> i64
%224 = arith.constant 1 : i32
%226 = arith.extsi %224 : i32 to i64
%225 = arith.addi %223, %226 : i64
llvm.store %225, %212 : i64, !llvm.ptr
%227 = llvm.load %212 : !llvm.ptr -> i64
%228 = arith.cmpi sge, %227, %arg2 : i64
cf.cond_br %228, ^bb57, ^bb58
^bb57:
%229 = arith.constant 0 : i32
%230 = arith.extsi %229 : i32 to i64
llvm.store %230, %212 : i64, !llvm.ptr
cf.br ^bb59
^bb58:
cf.br ^bb59
^bb59:
cf.br ^bb51
^bb53:
%231 = arith.constant 1 : i32
%232 = llvm.load %212 : !llvm.ptr -> i64
%233 = arith.trunci %231 : i32 to i8
%234 = llvm.getelementptr %arg5[%232] : (!llvm.ptr, i64) -> !llvm.ptr, i8
llvm.store %233, %234 : i8, !llvm.ptr
%235 = llvm.load %212 : !llvm.ptr -> i64
%236 = llvm.getelementptr %arg3[%235] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %arg0, %236 : i64, !llvm.ptr
%237 = llvm.load %212 : !llvm.ptr -> i64
%238 = llvm.getelementptr %arg4[%237] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %arg1, %238 : i64, !llvm.ptr
func.return
}
func.func @main() -> i32 {
%239 = arith.constant 95705032704 : i32
%240 = arith.extsi %239 : i32 to i64
%241 = arith.constant 998244353 : i32
%242 = arith.extsi %241 : i32 to i64
%243 = arith.constant 1 : i32
%245 = arith.extsi %243 : i32 to i64
%244 = arith.addi %242, %245 : i64
%246 = arith.constant 2 : i32
%248 = arith.extsi %246 : i32 to i64
%247 = arith.divsi %244, %248 : i64
%249 = arith.constant 10000000 : i32
%250 = arith.extsi %249 : i32 to i64
%252 = arith.constant 1 : i32
%254 = arith.extsi %252 : i32 to i64
%253 = arith.addi %250, %254 : i64
%255 = arith.constant 8 : i32
%256 = arith.extsi %255 : i32 to i64
%251 = func.call @calloc(%253, %256) : (i64, i64) -> !llvm.ptr
%258 = arith.constant 1 : i32
%260 = arith.extsi %258 : i32 to i64
%259 = arith.addi %250, %260 : i64
%261 = arith.constant 1 : i32
%262 = arith.extsi %261 : i32 to i64
%257 = func.call @calloc(%259, %262) : (i64, i64) -> !llvm.ptr
%264 = arith.constant 5 : i32
%266 = arith.extsi %264 : i32 to i64
%265 = arith.divsi %250, %266 : i64
%267 = arith.constant 10 : i32
%269 = arith.extsi %267 : i32 to i64
%268 = arith.addi %265, %269 : i64
%270 = arith.constant 4 : i32
%271 = arith.extsi %270 : i32 to i64
%263 = func.call @calloc(%268, %271) : (i64, i64) -> !llvm.ptr
%272 = llvm.mlir.zero : !llvm.ptr
%273 = llvm.icmp "eq" %251, %272 : !llvm.ptr
%274 = scf.if %273 -> (i1) {
%275 = arith.constant true
scf.yield %275 : i1
} else {
%276 = llvm.mlir.zero : !llvm.ptr
%277 = llvm.icmp "eq" %257, %276 : !llvm.ptr
scf.yield %277 : i1
}
%278 = scf.if %274 -> (i1) {
%279 = arith.constant true
scf.yield %279 : i1
} else {
%280 = llvm.mlir.zero : !llvm.ptr
%281 = llvm.icmp "eq" %263, %280 : !llvm.ptr
scf.yield %281 : i1
}
cf.cond_br %278, ^bb60, ^bb61
^bb60:
%282 = arith.constant 1 : i32
func.return %282 : i32
^bb61:
cf.br ^bb62
^bb62:
%283 = arith.constant 1 : i32
%284 = arith.constant 1 : i32
%285 = arith.extsi %283 : i32 to i64
%286 = arith.extsi %284 : i32 to i64
%287 = llvm.getelementptr %251[%286] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %285, %287 : i64, !llvm.ptr
%288 = arith.constant 0 : i32
%289 = arith.extsi %288 : i32 to i64
%290 = llvm.mlir.constant(1 : i64) : i64
%291 = llvm.alloca %290 x i64 : (i64) -> !llvm.ptr
llvm.store %289, %291 : i64, !llvm.ptr
%292 = arith.constant 2 : i32
%293 = arith.constant 1 : i32
%295 = arith.extsi %293 : i32 to i64
%294 = arith.addi %250, %295 : i64
%296 = arith.index_cast %292 : i32 to index
%297 = arith.index_cast %294 : i32 to index
%299 = arith.constant 1 : index
%300 = arith.constant -1 : index
%301 = arith.cmpi sle, %296, %297 : index
%298 = arith.select %301, %299, %300 : index
cf.br ^bb63(%296 : index)
^bb63(%302: index):
%303 = arith.cmpi slt, %302, %297 : index
%304 = arith.cmpi sgt, %302, %297 : index
%305 = arith.select %301, %303, %304 : i1
cf.cond_br %305, ^bb64(%302 : index), ^bb65(%302 : index)
^bb64(%306: index):
%308 = arith.index_cast %306 : index to i64
%309 = llvm.getelementptr %257[%308] : (!llvm.ptr, i64) -> !llvm.ptr, i8
%307 = llvm.load %309 : !llvm.ptr -> i8
%310 = arith.constant 0 : i32
%312 = arith.extsi %307 : i8 to i32
%311 = arith.cmpi eq, %312, %310 : i32
cf.cond_br %311, ^bb66, ^bb67
^bb66:
%313 = arith.index_cast %306 : index to i32
%314 = llvm.load %291 : !llvm.ptr -> i64
%315 = llvm.getelementptr %263[%314] : (!llvm.ptr, i64) -> !llvm.ptr, i32
llvm.store %313, %315 : i32, !llvm.ptr
%316 = llvm.load %291 : !llvm.ptr -> i64
%317 = arith.constant 1 : i32
%319 = arith.extsi %317 : i32 to i64
%318 = arith.addi %316, %319 : i64
llvm.store %318, %291 : i64, !llvm.ptr
%320 = arith.constant 1 : i32
%322 = arith.index_cast %306 : index to i32
%321 = arith.subi %322, %320 : i32
%323 = arith.extsi %321 : i32 to i64
%324 = arith.index_cast %306 : index to i64
%325 = llvm.getelementptr %251[%324] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %323, %325 : i64, !llvm.ptr
cf.br ^bb68
^bb67:
cf.br ^bb68
^bb68:
%326 = arith.constant 0 : i32
%327 = llvm.load %291 : !llvm.ptr -> i64
%328 = arith.index_cast %326 : i32 to index
%329 = arith.index_cast %327 : i32 to index
%331 = arith.constant 1 : index
%332 = arith.constant -1 : index
%333 = arith.cmpi sle, %328, %329 : index
%330 = arith.select %333, %331, %332 : index
cf.br ^bb69(%328 : index)
^bb69(%334: index):
%335 = arith.cmpi slt, %334, %329 : index
%336 = arith.cmpi sgt, %334, %329 : index
%337 = arith.select %333, %335, %336 : i1
cf.cond_br %337, ^bb70(%334 : index), ^bb71(%334 : index)
^bb70(%338: index):
%340 = arith.index_cast %338 : index to i64
%341 = llvm.getelementptr %263[%340] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%339 = llvm.load %341 : !llvm.ptr -> i32
%342 = arith.extsi %339 : i32 to i64
%344 = arith.index_cast %306 : index to i32
%345 = arith.trunci %342 : i64 to i32
%343 = arith.muli %344, %345 : i32
%346 = arith.extsi %343 : i32 to i64
%347 = arith.cmpi sgt, %346, %250 : i64
cf.cond_br %347, ^bb72, ^bb73
^bb72:
cf.br ^bb71(%338 : index)
^bb73:
cf.br ^bb74
^bb74:
%348 = arith.constant 1 : i32
%349 = arith.trunci %348 : i32 to i8
%350 = llvm.getelementptr %257[%346] : (!llvm.ptr, i64) -> !llvm.ptr, i8
llvm.store %349, %350 : i8, !llvm.ptr
%352 = arith.index_cast %306 : index to i32
%353 = arith.trunci %342 : i64 to i32
%351 = arith.remsi %352, %353 : i32
%354 = arith.constant 0 : i32
%355 = arith.cmpi eq, %351, %354 : i32
cf.cond_br %355, ^bb75, ^bb76
^bb75:
%357 = arith.index_cast %306 : index to i64
%358 = llvm.getelementptr %251[%357] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%356 = llvm.load %358 : !llvm.ptr -> i64
%359 = arith.muli %356, %342 : i64
%360 = llvm.getelementptr %251[%346] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %359, %360 : i64, !llvm.ptr
cf.br ^bb71(%338 : index)
^bb76:
%362 = arith.index_cast %306 : index to i32
%363 = arith.trunci %342 : i64 to i32
%361 = arith.remsi %362, %363 : i32
%364 = arith.constant 0 : i32
%365 = arith.cmpi ne, %361, %364 : i32
cf.cond_br %365, ^bb78, ^bb77
^bb78:
%367 = arith.index_cast %306 : index to i64
%368 = llvm.getelementptr %251[%367] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%366 = llvm.load %368 : !llvm.ptr -> i64
%369 = arith.constant 1 : i32
%371 = arith.extsi %369 : i32 to i64
%370 = arith.subi %342, %371 : i64
%372 = arith.muli %366, %370 : i64
%373 = llvm.getelementptr %251[%346] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %372, %373 : i64, !llvm.ptr
cf.br ^bb77
^bb77:
%374 = arith.addi %338, %330 : index
cf.br ^bb69(%374 : index)
^bb71(%375: index):
%376 = arith.addi %306, %298 : index
cf.br ^bb63(%376 : index)
^bb65(%377: index):
%378 = func.call @isqrt(%240) : (i64) -> i64
%380 = arith.constant 1 : i32
%382 = arith.extsi %380 : i32 to i64
%381 = arith.addi %378, %382 : i64
%383 = arith.constant 8 : i32
%384 = arith.extsi %383 : i32 to i64
%379 = func.call @calloc(%381, %384) : (i64, i64) -> !llvm.ptr
%385 = llvm.mlir.zero : !llvm.ptr
%386 = llvm.icmp "eq" %379, %385 : !llvm.ptr
cf.cond_br %386, ^bb79, ^bb80
^bb79:
%387 = arith.constant 1 : i32
func.return %387 : i32
^bb80:
cf.br ^bb81
^bb81:
%388 = arith.constant 0 : i32
%389 = arith.constant 1 : i32
%391 = arith.extsi %389 : i32 to i64
%390 = arith.addi %378, %391 : i64
%392 = arith.index_cast %388 : i32 to index
%393 = arith.index_cast %390 : i32 to index
%395 = arith.constant 1 : index
%396 = arith.constant -1 : index
%397 = arith.cmpi sle, %392, %393 : index
%394 = arith.select %397, %395, %396 : index
cf.br ^bb82(%392 : index)
^bb82(%398: index):
%399 = arith.cmpi slt, %398, %393 : index
%400 = arith.cmpi sgt, %398, %393 : index
%401 = arith.select %397, %399, %400 : i1
cf.cond_br %401, ^bb83(%398 : index), ^bb84(%398 : index)
^bb83(%402: index):
%404 = arith.index_cast %402 : index to i64
%405 = llvm.getelementptr %251[%404] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%403 = llvm.load %405 : !llvm.ptr -> i64
%406 = arith.index_cast %402 : index to i64
%407 = llvm.getelementptr %379[%406] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %403, %407 : i64, !llvm.ptr
%408 = arith.addi %402, %394 : index
cf.br ^bb82(%408 : index)
^bb84(%409: index):
%411 = arith.constant 1 : i32
%413 = arith.extsi %411 : i32 to i64
%412 = arith.addi %250, %413 : i64
%414 = arith.constant 8 : i32
%415 = arith.extsi %414 : i32 to i64
%410 = func.call @calloc(%412, %415) : (i64, i64) -> !llvm.ptr
%416 = arith.constant 0 : i32
%417 = arith.extsi %416 : i32 to i64
%418 = llvm.mlir.constant(1 : i64) : i64
%419 = llvm.alloca %418 x i64 : (i64) -> !llvm.ptr
llvm.store %417, %419 : i64, !llvm.ptr
%420 = arith.constant 1 : i32
%421 = arith.constant 1 : i32
%423 = arith.extsi %421 : i32 to i64
%422 = arith.addi %250, %423 : i64
%424 = arith.index_cast %420 : i32 to index
%425 = arith.index_cast %422 : i32 to index
%427 = arith.constant 1 : index
%428 = arith.constant -1 : index
%429 = arith.cmpi sle, %424, %425 : index
%426 = arith.select %429, %427, %428 : index
cf.br ^bb85(%424 : index)
^bb85(%430: index):
%431 = arith.cmpi slt, %430, %425 : index
%432 = arith.cmpi sgt, %430, %425 : index
%433 = arith.select %429, %431, %432 : i1
cf.cond_br %433, ^bb86(%430 : index), ^bb87(%430 : index)
^bb86(%434: index):
%435 = llvm.load %419 : !llvm.ptr -> i64
%437 = arith.index_cast %434 : index to i64
%438 = llvm.getelementptr %251[%437] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%436 = llvm.load %438 : !llvm.ptr -> i64
%439 = arith.addi %435, %436 : i64
%440 = arith.remsi %439, %242 : i64
llvm.store %440, %419 : i64, !llvm.ptr
%441 = llvm.load %419 : !llvm.ptr -> i64
%442 = arith.index_cast %434 : index to i64
%443 = llvm.getelementptr %410[%442] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %441, %443 : i64, !llvm.ptr
%444 = arith.addi %434, %426 : index
cf.br ^bb85(%444 : index)
^bb87(%445: index):
%446 = arith.constant 1 : i32
%447 = arith.constant 20 : i32
%448 = arith.shli %446, %447 : i32
%449 = arith.extsi %448 : i32 to i64
%451 = arith.constant 8 : i32
%452 = arith.extsi %451 : i32 to i64
%450 = func.call @calloc(%449, %452) : (i64, i64) -> !llvm.ptr
%454 = arith.constant 8 : i32
%455 = arith.extsi %454 : i32 to i64
%453 = func.call @calloc(%449, %455) : (i64, i64) -> !llvm.ptr
%457 = arith.constant 1 : i32
%458 = arith.extsi %457 : i32 to i64
%456 = func.call @calloc(%449, %458) : (i64, i64) -> !llvm.ptr
%459 = llvm.mlir.zero : !llvm.ptr
%460 = llvm.icmp "eq" %450, %459 : !llvm.ptr
%461 = scf.if %460 -> (i1) {
%462 = arith.constant true
scf.yield %462 : i1
} else {
%463 = llvm.mlir.zero : !llvm.ptr
%464 = llvm.icmp "eq" %453, %463 : !llvm.ptr
scf.yield %464 : i1
}
%465 = scf.if %461 -> (i1) {
%466 = arith.constant true
scf.yield %466 : i1
} else {
%467 = llvm.mlir.zero : !llvm.ptr
%468 = llvm.icmp "eq" %456, %467 : !llvm.ptr
scf.yield %468 : i1
}
cf.cond_br %465, ^bb88, ^bb89
^bb88:
%469 = arith.constant 1 : i32
func.return %469 : i32
^bb89:
cf.br ^bb90
^bb90:
%471 = arith.constant 1 : i32
%473 = arith.extsi %471 : i32 to i64
%472 = arith.addi %378, %473 : i64
%474 = arith.constant 8 : i32
%475 = arith.extsi %474 : i32 to i64
%470 = func.call @calloc(%472, %475) : (i64, i64) -> !llvm.ptr
%476 = arith.constant 0 : i32
%477 = arith.extsi %476 : i32 to i64
%478 = llvm.mlir.constant(1 : i64) : i64
%479 = llvm.alloca %478 x i64 : (i64) -> !llvm.ptr
llvm.store %477, %479 : i64, !llvm.ptr
%480 = arith.constant 1 : i32
%481 = arith.constant 1 : i32
%483 = arith.extsi %481 : i32 to i64
%482 = arith.addi %378, %483 : i64
%484 = arith.index_cast %480 : i32 to index
%485 = arith.index_cast %482 : i32 to index
%487 = arith.constant 1 : index
%488 = arith.constant -1 : index
%489 = arith.cmpi sle, %484, %485 : index
%486 = arith.select %489, %487, %488 : index
cf.br ^bb91(%484 : index)
^bb91(%490: index):
%491 = arith.cmpi slt, %490, %485 : index
%492 = arith.cmpi sgt, %490, %485 : index
%493 = arith.select %489, %491, %492 : i1
cf.cond_br %493, ^bb92(%490 : index), ^bb93(%490 : index)
^bb92(%494: index):
%496 = arith.trunci %240 : i64 to i32
%497 = arith.index_cast %494 : index to i32
%495 = arith.divsi %496, %497 : i32
%498 = arith.extsi %495 : i32 to i64
%499 = arith.cmpi sgt, %498, %250 : i64
cf.cond_br %499, ^bb94, ^bb95
^bb94:
%500 = llvm.load %479 : !llvm.ptr -> i64
%501 = llvm.getelementptr %470[%500] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %498, %501 : i64, !llvm.ptr
%502 = llvm.load %479 : !llvm.ptr -> i64
%503 = arith.constant 1 : i32
%505 = arith.extsi %503 : i32 to i64
%504 = arith.addi %502, %505 : i64
llvm.store %504, %479 : i64, !llvm.ptr
cf.br ^bb96
^bb95:
cf.br ^bb96
^bb96:
%506 = arith.addi %494, %486 : index
cf.br ^bb91(%506 : index)
^bb93(%507: index):
%508 = arith.constant 0 : i32
%509 = llvm.load %479 : !llvm.ptr -> i64
%510 = arith.constant 2 : i32
%512 = arith.extsi %510 : i32 to i64
%511 = arith.divsi %509, %512 : i64
%513 = arith.index_cast %508 : i32 to index
%514 = arith.index_cast %511 : i32 to index
%516 = arith.constant 1 : index
%517 = arith.constant -1 : index
%518 = arith.cmpi sle, %513, %514 : index
%515 = arith.select %518, %516, %517 : index
cf.br ^bb97(%513 : index)
^bb97(%519: index):
%520 = arith.cmpi slt, %519, %514 : index
%521 = arith.cmpi sgt, %519, %514 : index
%522 = arith.select %518, %520, %521 : i1
cf.cond_br %522, ^bb98(%519 : index), ^bb99(%519 : index)
^bb98(%523: index):
%525 = arith.index_cast %523 : index to i64
%526 = llvm.getelementptr %470[%525] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%524 = llvm.load %526 : !llvm.ptr -> i64
%528 = llvm.load %479 : !llvm.ptr -> i64
%529 = arith.constant 1 : i32
%531 = arith.extsi %529 : i32 to i64
%530 = arith.subi %528, %531 : i64
%533 = arith.trunci %530 : i64 to i32
%534 = arith.index_cast %523 : index to i32
%532 = arith.subi %533, %534 : i32
%535 = arith.extsi %532 : i32 to i64
%536 = llvm.getelementptr %470[%535] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%527 = llvm.load %536 : !llvm.ptr -> i64
%537 = arith.index_cast %523 : index to i64
%538 = llvm.getelementptr %470[%537] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %527, %538 : i64, !llvm.ptr
%539 = llvm.load %479 : !llvm.ptr -> i64
%540 = arith.constant 1 : i32
%542 = arith.extsi %540 : i32 to i64
%541 = arith.subi %539, %542 : i64
%544 = arith.trunci %541 : i64 to i32
%545 = arith.index_cast %523 : index to i32
%543 = arith.subi %544, %545 : i32
%546 = arith.extsi %543 : i32 to i64
%547 = llvm.getelementptr %470[%546] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %524, %547 : i64, !llvm.ptr
%548 = arith.addi %523, %515 : index
cf.br ^bb97(%548 : index)
^bb99(%549: index):
%550 = arith.constant 0 : i32
%551 = llvm.load %479 : !llvm.ptr -> i64
%552 = arith.index_cast %550 : i32 to index
%553 = arith.index_cast %551 : i32 to index
%555 = arith.constant 1 : index
%556 = arith.constant -1 : index
%557 = arith.cmpi sle, %552, %553 : index
%554 = arith.select %557, %555, %556 : index
cf.br ^bb100(%552 : index)
^bb100(%558: index):
%559 = arith.cmpi slt, %558, %553 : index
%560 = arith.cmpi sgt, %558, %553 : index
%561 = arith.select %557, %559, %560 : i1
cf.cond_br %561, ^bb101(%558 : index), ^bb102(%558 : index)
^bb101(%562: index):
%564 = arith.index_cast %562 : index to i64
%565 = llvm.getelementptr %470[%564] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%563 = llvm.load %565 : !llvm.ptr -> i64
%566 = func.call @isqrt(%563) : (i64) -> i64
%567 = func.call @tri(%563, %242, %247) : (i64, i64, i64) -> i64
%568 = llvm.mlir.constant(1 : i64) : i64
%569 = llvm.alloca %568 x i64 : (i64) -> !llvm.ptr
llvm.store %567, %569 : i64, !llvm.ptr
%570 = arith.divsi %563, %566 : i64
%571 = arith.constant 1 : i32
%572 = arith.index_cast %571 : i32 to index
%573 = arith.index_cast %570 : i32 to index
%575 = arith.constant 1 : index
%576 = arith.constant -1 : index
%577 = arith.cmpi sle, %572, %573 : index
%574 = arith.select %577, %575, %576 : index
cf.br ^bb103(%572 : index)
^bb103(%578: index):
%579 = arith.cmpi slt, %578, %573 : index
%580 = arith.cmpi sgt, %578, %573 : index
%581 = arith.select %577, %579, %580 : i1
cf.cond_br %581, ^bb104(%578 : index), ^bb105(%578 : index)
^bb104(%582: index):
%584 = arith.trunci %563 : i64 to i32
%585 = arith.index_cast %582 : index to i32
%583 = arith.divsi %584, %585 : i32
%586 = arith.constant 1 : i32
%588 = arith.index_cast %582 : index to i32
%587 = arith.addi %588, %586 : i32
%590 = arith.extsi %587 : i32 to i64
%589 = arith.divsi %563, %590 : i64
%592 = arith.extsi %583 : i32 to i64
%591 = arith.subi %592, %589 : i64
%593 = arith.constant 0 : i32
%595 = arith.extsi %593 : i32 to i64
%594 = arith.cmpi sgt, %591, %595 : i64
cf.cond_br %594, ^bb106, ^bb107
^bb106:
%596 = llvm.load %569 : !llvm.ptr -> i64
%597 = arith.remsi %591, %242 : i64
%599 = arith.index_cast %582 : index to i64
%600 = llvm.getelementptr %410[%599] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%598 = llvm.load %600 : !llvm.ptr -> i64
%601 = arith.muli %597, %598 : i64
%602 = arith.subi %596, %601 : i64
%603 = arith.remsi %602, %242 : i64
llvm.store %603, %569 : i64, !llvm.ptr
cf.br ^bb108
^bb107:
cf.br ^bb108
^bb108:
%604 = arith.addi %582, %574 : index
cf.br ^bb103(%604 : index)
^bb105(%605: index):
%606 = arith.constant 2 : i32
%607 = arith.extsi %606 : i32 to i64
%608 = llvm.mlir.constant(1 : i64) : i64
%609 = llvm.alloca %608 x i64 : (i64) -> !llvm.ptr
llvm.store %607, %609 : i64, !llvm.ptr
cf.br ^bb109
^bb109:
%610 = llvm.load %609 : !llvm.ptr -> i64
%611 = arith.cmpi sle, %610, %566 : i64
cf.cond_br %611, ^bb110, ^bb111
^bb110:
%612 = llvm.load %609 : !llvm.ptr -> i64
%613 = arith.divsi %563, %612 : i64
%614 = llvm.load %609 : !llvm.ptr -> i64
%615 = llvm.mlir.constant(1 : i64) : i64
%616 = llvm.alloca %615 x i64 : (i64) -> !llvm.ptr
llvm.store %614, %616 : i64, !llvm.ptr
cf.br ^bb112
^bb112:
%617 = llvm.load %616 : !llvm.ptr -> i64
%618 = arith.constant 1 : i32
%620 = arith.extsi %618 : i32 to i64
%619 = arith.addi %617, %620 : i64
%621 = arith.cmpi sle, %619, %566 : i64
%622 = scf.if %621 -> (i1) {
%623 = llvm.load %616 : !llvm.ptr -> i64
%624 = arith.constant 1 : i32
%626 = arith.extsi %624 : i32 to i64
%625 = arith.addi %623, %626 : i64
%627 = arith.divsi %563, %625 : i64
%628 = arith.cmpi eq, %627, %613 : i64
scf.yield %628 : i1
} else {
%629 = arith.constant false
scf.yield %629 : i1
}
cf.cond_br %622, ^bb113, ^bb114
^bb113:
%630 = llvm.load %616 : !llvm.ptr -> i64
%631 = arith.constant 1 : i32
%633 = arith.extsi %631 : i32 to i64
%632 = arith.addi %630, %633 : i64
llvm.store %632, %616 : i64, !llvm.ptr
cf.br ^bb112
^bb114:
%634 = llvm.load %616 : !llvm.ptr -> i64
%635 = llvm.load %609 : !llvm.ptr -> i64
%636 = arith.subi %634, %635 : i64
%637 = arith.constant 1 : i32
%639 = arith.extsi %637 : i32 to i64
%638 = arith.addi %636, %639 : i64
%640 = arith.constant 0 : i32
%641 = arith.extsi %640 : i32 to i64
%642 = arith.cmpi sle, %613, %250 : i64
cf.cond_br %642, ^bb115, ^bb116
^bb115:
%644 = llvm.getelementptr %410[%613] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%643 = llvm.load %644 : !llvm.ptr -> i64
cf.br ^bb117(%643 : i64)
^bb116:
%645 = arith.cmpi sgt, %613, %250 : i64
cf.cond_br %645, ^bb118, ^bb117(%641 : i64)
^bb118:
%646 = func.call @phi_lookup(%613, %449, %450, %453, %456) : (i64, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr) -> i64
cf.br ^bb117(%646 : i64)
^bb117(%647: i64):
%648 = llvm.load %569 : !llvm.ptr -> i64
%649 = arith.muli %638, %647 : i64
%650 = arith.subi %648, %649 : i64
%651 = arith.remsi %650, %242 : i64
llvm.store %651, %569 : i64, !llvm.ptr
%652 = llvm.load %616 : !llvm.ptr -> i64
%653 = arith.constant 1 : i32
%655 = arith.extsi %653 : i32 to i64
%654 = arith.addi %652, %655 : i64
llvm.store %654, %609 : i64, !llvm.ptr
cf.br ^bb109
^bb111:
%656 = llvm.load %569 : !llvm.ptr -> i64
%657 = arith.remsi %656, %242 : i64
llvm.store %657, %569 : i64, !llvm.ptr
%658 = llvm.load %569 : !llvm.ptr -> i64
%659 = arith.constant 0 : i32
%661 = arith.extsi %659 : i32 to i64
%660 = arith.cmpi slt, %658, %661 : i64
cf.cond_br %660, ^bb119, ^bb120
^bb119:
%662 = llvm.load %569 : !llvm.ptr -> i64
%663 = arith.addi %662, %242 : i64
llvm.store %663, %569 : i64, !llvm.ptr
cf.br ^bb121
^bb120:
cf.br ^bb121
^bb121:
%665 = llvm.load %569 : !llvm.ptr -> i64
func.call @phi_store(%563, %665, %449, %450, %453, %456) : (i64, i64, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr) -> ()
%666 = arith.addi %562, %554 : index
cf.br ^bb100(%666 : index)
^bb102(%667: index):
%668 = arith.constant 0 : i32
%669 = arith.extsi %668 : i32 to i64
%670 = llvm.mlir.constant(1 : i64) : i64
%671 = llvm.alloca %670 x i64 : (i64) -> !llvm.ptr
llvm.store %669, %671 : i64, !llvm.ptr
%672 = arith.constant 1 : i32
%673 = arith.extsi %672 : i32 to i64
%674 = llvm.mlir.constant(1 : i64) : i64
%675 = llvm.alloca %674 x i64 : (i64) -> !llvm.ptr
llvm.store %673, %675 : i64, !llvm.ptr
cf.br ^bb122
^bb122:
%676 = llvm.load %675 : !llvm.ptr -> i64
%677 = arith.cmpi sle, %676, %378 : i64
cf.cond_br %677, ^bb123, ^bb124
^bb123:
%678 = llvm.load %675 : !llvm.ptr -> i64
%679 = arith.divsi %240, %678 : i64
%680 = llvm.load %675 : !llvm.ptr -> i64
%681 = llvm.mlir.constant(1 : i64) : i64
%682 = llvm.alloca %681 x i64 : (i64) -> !llvm.ptr
llvm.store %680, %682 : i64, !llvm.ptr
cf.br ^bb125
^bb125:
%683 = llvm.load %682 : !llvm.ptr -> i64
%684 = arith.constant 1 : i32
%686 = arith.extsi %684 : i32 to i64
%685 = arith.addi %683, %686 : i64
%687 = arith.cmpi sle, %685, %378 : i64
%688 = scf.if %687 -> (i1) {
%689 = llvm.load %682 : !llvm.ptr -> i64
%690 = arith.constant 1 : i32
%692 = arith.extsi %690 : i32 to i64
%691 = arith.addi %689, %692 : i64
%693 = arith.divsi %240, %691 : i64
%694 = arith.cmpi eq, %693, %679 : i64
scf.yield %694 : i1
} else {
%695 = arith.constant false
scf.yield %695 : i1
}
cf.cond_br %688, ^bb126, ^bb127
^bb126:
%696 = llvm.load %682 : !llvm.ptr -> i64
%697 = arith.constant 1 : i32
%699 = arith.extsi %697 : i32 to i64
%698 = arith.addi %696, %699 : i64
llvm.store %698, %682 : i64, !llvm.ptr
cf.br ^bb125
^bb127:
%700 = llvm.load %675 : !llvm.ptr -> i64
%701 = llvm.load %682 : !llvm.ptr -> i64
%702 = arith.addi %700, %701 : i64
%703 = llvm.load %682 : !llvm.ptr -> i64
%704 = llvm.load %675 : !llvm.ptr -> i64
%705 = arith.subi %703, %704 : i64
%706 = arith.constant 1 : i32
%708 = arith.extsi %706 : i32 to i64
%707 = arith.addi %705, %708 : i64
%709 = arith.muli %702, %707 : i64
%710 = arith.constant 2 : i32
%712 = arith.extsi %710 : i32 to i64
%711 = arith.divsi %709, %712 : i64
%713 = arith.constant 0 : i32
%714 = arith.extsi %713 : i32 to i64
%715 = arith.cmpi sle, %679, %250 : i64
cf.cond_br %715, ^bb128, ^bb129
^bb128:
%717 = llvm.getelementptr %410[%679] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%716 = llvm.load %717 : !llvm.ptr -> i64
cf.br ^bb130(%716 : i64)
^bb129:
%718 = arith.cmpi sgt, %679, %250 : i64
cf.cond_br %718, ^bb131, ^bb130(%714 : i64)
^bb131:
%719 = func.call @phi_lookup(%679, %449, %450, %453, %456) : (i64, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr) -> i64
cf.br ^bb130(%719 : i64)
^bb130(%720: i64):
%721 = llvm.load %671 : !llvm.ptr -> i64
%722 = arith.remsi %711, %242 : i64
%723 = arith.muli %722, %720 : i64
%724 = arith.addi %721, %723 : i64
%725 = arith.remsi %724, %242 : i64
llvm.store %725, %671 : i64, !llvm.ptr
%726 = llvm.load %682 : !llvm.ptr -> i64
%727 = arith.constant 1 : i32
%729 = arith.extsi %727 : i32 to i64
%728 = arith.addi %726, %729 : i64
llvm.store %728, %675 : i64, !llvm.ptr
cf.br ^bb122
^bb124:
%730 = arith.constant 1 : i32
%731 = arith.constant 1 : i32
%733 = arith.extsi %731 : i32 to i64
%732 = arith.addi %378, %733 : i64
%734 = arith.index_cast %730 : i32 to index
%735 = arith.index_cast %732 : i32 to index
%737 = arith.constant 1 : index
%738 = arith.constant -1 : index
%739 = arith.cmpi sle, %734, %735 : index
%736 = arith.select %739, %737, %738 : index
cf.br ^bb132(%734 : index)
^bb132(%740: index):
%741 = arith.cmpi slt, %740, %735 : index
%742 = arith.cmpi sgt, %740, %735 : index
%743 = arith.select %739, %741, %742 : i1
cf.cond_br %743, ^bb133(%740 : index), ^bb134(%740 : index)
^bb133(%744: index):
%745 = llvm.load %671 : !llvm.ptr -> i64
%747 = arith.index_cast %744 : index to i64
%748 = llvm.getelementptr %379[%747] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%746 = llvm.load %748 : !llvm.ptr -> i64
%751 = arith.trunci %240 : i64 to i32
%752 = arith.index_cast %744 : index to i32
%750 = arith.divsi %751, %752 : i32
%753 = arith.extsi %750 : i32 to i64
%749 = func.call @tri(%753, %242, %247) : (i64, i64, i64) -> i64
%754 = arith.muli %746, %749 : i64
%755 = arith.addi %745, %754 : i64
%756 = arith.remsi %755, %242 : i64
llvm.store %756, %671 : i64, !llvm.ptr
%757 = arith.addi %744, %736 : index
cf.br ^bb132(%757 : index)
^bb134(%758: index):
%759 = arith.constant 0 : i32
%760 = arith.extsi %759 : i32 to i64
%761 = arith.cmpi sle, %378, %250 : i64
cf.cond_br %761, ^bb135, ^bb136
^bb135:
%763 = llvm.getelementptr %410[%378] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%762 = llvm.load %763 : !llvm.ptr -> i64
cf.br ^bb137(%762 : i64)
^bb136:
%764 = arith.cmpi sgt, %378, %250 : i64
cf.cond_br %764, ^bb138, ^bb137(%760 : i64)
^bb138:
%765 = func.call @phi_lookup(%378, %449, %450, %453, %456) : (i64, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr) -> i64
cf.br ^bb137(%765 : i64)
^bb137(%766: i64):
%767 = llvm.load %671 : !llvm.ptr -> i64
%768 = func.call @tri(%378, %242, %247) : (i64, i64, i64) -> i64
%769 = arith.muli %768, %766 : i64
%770 = arith.subi %767, %769 : i64
%771 = arith.remsi %770, %242 : i64
llvm.store %771, %671 : i64, !llvm.ptr
%772 = llvm.load %671 : !llvm.ptr -> i64
%773 = arith.constant 0 : i32
%775 = arith.extsi %773 : i32 to i64
%774 = arith.cmpi slt, %772, %775 : i64
cf.cond_br %774, ^bb139, ^bb140
^bb139:
%776 = llvm.load %671 : !llvm.ptr -> i64
%777 = arith.addi %776, %242 : i64
llvm.store %777, %671 : i64, !llvm.ptr
cf.br ^bb141
^bb140:
cf.br ^bb141
^bb141:
%778 = llvm.mlir.addressof @str_0 : !llvm.ptr
%779 = llvm.load %671 : !llvm.ptr -> i64
%780 = llvm.call @printf(%778, %779) vararg(!llvm.func<i32 (ptr, ...)>) : (!llvm.ptr, i64) -> i32
func.call @free(%470) : (!llvm.ptr) -> ()
func.call @free(%456) : (!llvm.ptr) -> ()
func.call @free(%453) : (!llvm.ptr) -> ()
func.call @free(%450) : (!llvm.ptr) -> ()
func.call @free(%410) : (!llvm.ptr) -> ()
func.call @free(%379) : (!llvm.ptr) -> ()
func.call @free(%263) : (!llvm.ptr) -> ()
func.call @free(%257) : (!llvm.ptr) -> ()
func.call @free(%251) : (!llvm.ptr) -> ()
%790 = arith.constant 0 : i32
func.return %790 : i32
}
}