Problem 635
Compute (S_2(10^8) + S_3(10^8)) mod 10^9+9. Uses sieve, batch inversion, and recurrences for binomial coefficients.
View problem on Project Euler
Performance comparison
| Metric | Our solution | Best known |
| Time complexity | O(n^2) | O(n^2) |
| Space complexity | O(n^2) | O(n) |
| Approach | Flow solution | Pascal triangle computation |
| Verdict | Optimal |
Flow source
# Project Euler 635: Subset Sums
# Compute (S_2(10^8) + S_3(10^8)) mod 10^9+9.
# Uses sieve, batch inversion, and recurrences for binomial coefficients.
import euler.nt { isqrt }
extern {
function calloc(n: i64, size: i64) -> ptr<void>
function free(p: ptr<void>) -> void
}
const MOD: i64 = 1000000009
function pow_mod(a: i64, e: i64, m: i64) -> i64 {
let mut r: i64 = 1
let mut b: i64 = a % m
let mut ee: i64 = e
while ee > 0 {
if ee & 1 == 1 { r = (r * b) % m }
b = (b * b) % m
ee = ee >> 1
}
return r
}
function main() -> i32 {
let L: i64 = 100000000
# Odd-only sieve: is_prime[i] = 1 if 2*i+1 is prime
let sieve_size: i64 = L / 2 + 1
let is_prime: ptr<i64> = calloc(sieve_size, 8)
for i in 0..sieve_size { is_prime[i] = 1 }
is_prime[0] = 0 # 1 is not prime
let r: i64 = isqrt(L)
let mut p: i64 = 3
while p <= r {
if is_prime[p / 2] == 1 {
let mut j: i64 = (p * p) / 2
while j < sieve_size {
is_prime[j] = 0
j = j + p
}
}
p = p + 2
}
# Batch inversion: inv_half[x] = x^{-1} mod MOD for x=1..max_half
let max_half: i64 = (L + 1) / 2
let inv_half: ptr<i64> = calloc(max_half + 1, 8)
let block: i64 = 1000000
let pref: ptr<i64> = calloc(block + 1, 8)
let mut s: i64 = 1
while s <= max_half {
let cnt: i64 = block
if max_half - s + 1 < cnt { cnt = max_half - s + 1 }
pref[0] = 1
let mut x: i64 = s
for i in 0..cnt {
pref[i + 1] = (pref[i] * x) % MOD
x = x + 1
}
let mut inv_total: i64 = pow_mod(pref[cnt], MOD - 2, MOD)
x = s + cnt - 1
for i in 0..cnt {
inv_half[x] = (pref[cnt - 1 - i] * inv_total) % MOD
inv_total = (inv_total * x) % MOD
x = x - 1
}
s = s + cnt
}
free(pref)
# Batch inversion for odd numbers: inv_odd[i] = (2*i+1)^{-1} mod MOD
let max_odd: i64 = 2 * L + 3
let odd_count: i64 = max_odd / 2 + 1
let inv_odd: ptr<i64> = calloc(odd_count, 8)
let pref2: ptr<i64> = calloc(block + 1, 8)
let mut idx: i64 = 0
while idx < odd_count {
let cnt: i64 = block
if odd_count - idx < cnt { cnt = odd_count - idx }
pref2[0] = 1
let mut x: i64 = 2 * idx + 1
for i in 0..cnt {
pref2[i + 1] = (pref2[i] * x) % MOD
x = x + 2
}
let mut inv_total2: i64 = pow_mod(pref2[cnt], MOD - 2, MOD)
x = 2 * (idx + cnt - 1) + 1
for i in 0..cnt {
inv_odd[idx + cnt - 1 - i] = (pref2[cnt - 1 - i] * inv_total2) % MOD
inv_total2 = (inv_total2 * x) % MOD
x = x - 2
}
idx = idx + cnt
}
free(pref2)
# Compute S2 and S3
let INV2: i64 = (MOD + 1) / 2
let K9: i64 = (9 * INV2) % MOD
let mut S2: i64 = 2 # A_2(2) = 2
let mut S3: i64 = 6 # A_3(2) = 6
let max_i: i64 = (L - 1) / 2
# n=1 (i=0): C(2,1)=2, C(3,1)=3
let mut C: i64 = 2
let mut D: i64 = 3
# State variables
let mut a1: i64 = 3 # 2n+1 = 4*i+3
let mut a3: i64 = 5 # 2n+3 = 4*i+5
let mut idx_a1: i64 = 1 # (2n+1)//2 = 2*i+1
let mut idx_a3: i64 = 2 # (2n+3)//2 = 2*i+2
let mut t1: i64 = 2 # (3n+1)//2 = 3*i+2
let mut t2: i64 = 5 # 3n+2 = 6*i+5
let mut t3: i64 = 7 # 3n+4 = 6*i+7
let mut t4: i64 = 4 # (3n+5)//2 = 3*i+4
let mut i: i64 = 0
while i <= max_i {
if i >= 1 && is_prime[i] == 1 {
let invp: i64 = inv_odd[i]
# n-1 = 2*i
S2 = (S2 + (C + 4 * i) * invp) % MOD
S3 = (S3 + (D + 6 * i) * invp) % MOD
}
# Update to next odd n (i -> i+1)
let invh: i64 = inv_half[i + 1]
let invn2: i64 = inv_odd[i + 1]
# C update
C = (C * a1) % MOD
C = (C * a3) % MOD
C = (C * invh) % MOD
C = (C * invn2) % MOD
C = (C * 2) % MOD
# D update
D = (D * K9) % MOD
D = (D * t1) % MOD
D = (D * t2) % MOD
D = (D * t3) % MOD
D = (D * t4) % MOD
D = (D * invh) % MOD
D = (D * invn2) % MOD
D = (D * inv_odd[idx_a1]) % MOD
D = (D * inv_odd[idx_a3]) % MOD
i = i + 1
a1 = a1 + 4
a3 = a3 + 4
idx_a1 = idx_a1 + 2
idx_a3 = idx_a3 + 2
t1 = t1 + 3
t2 = t2 + 6
t3 = t3 + 6
t4 = t4 + 3
}
let ans: i64 = (S2 + S3) % MOD
printf("%lld\n", ans)
free(inv_odd)
free(inv_half)
free(is_prime)
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 pow_mod_i64_i64_i64(int64_t a, int64_t e, int64_t m);
int32_t main(void);
static const int64_t MOD = 1000000009;
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 pow_mod_i64_i64_i64(int64_t a, int64_t e, int64_t m) {
int64_t r = 1;
int64_t b = FLOW_CHECKED_MOD((a), (m));
int64_t ee = e;
while (ee > 0) {
if ((ee & 1 == 1)) {
r = FLOW_CHECKED_MOD(((r * b)), (m));
}
b = FLOW_CHECKED_MOD(((b * b)), (m));
ee = FLOW_CHECKED_SHR((ee), (1));
}
return r;
}
int32_t main(void) {
int64_t L = 100000000;
int64_t sieve_size = (FLOW_CHECKED_DIV((L), (2)) + 1);
int64_t* is_prime = (int64_t*)(calloc(sieve_size, 8));
int32_t __flow_step_1 = 1;
for (int32_t i = 0; (0 <= sieve_size) ? i < sieve_size : i > sieve_size; i += (0 <= sieve_size) ? 1 : -1) {
is_prime[i] = 1;
}
is_prime[0] = 0;
int64_t r = isqrt_i64(L);
int64_t p = 3;
while (p <= r) {
if (is_prime[FLOW_CHECKED_DIV((p), (2))] == 1) {
int64_t j = FLOW_CHECKED_DIV(((p * p)), (2));
while (j < sieve_size) {
is_prime[j] = 0;
j = (j + p);
}
}
p = (p + 2);
}
int64_t max_half = FLOW_CHECKED_DIV(((L + 1)), (2));
int64_t* inv_half = (int64_t*)(calloc((max_half + 1), 8));
int64_t block = 1000000;
int64_t* pref = (int64_t*)(calloc((block + 1), 8));
int64_t s = 1;
while (s <= max_half) {
int64_t cnt = block;
if (((max_half - s) + 1) < cnt) {
cnt = ((max_half - s) + 1);
}
pref[0] = 1;
int64_t x = s;
int32_t __flow_step_2 = 1;
for (int32_t i = 0; (0 <= cnt) ? i < cnt : i > cnt; i += (0 <= cnt) ? 1 : -1) {
pref[(i + 1)] = FLOW_CHECKED_MOD(((pref[i] * x)), (MOD));
x = (x + 1);
}
int64_t inv_total = pow_mod_i64_i64_i64(pref[cnt], (MOD - 2), MOD);
x = ((s + cnt) - 1);
int32_t __flow_step_3 = 1;
for (int32_t i = 0; (0 <= cnt) ? i < cnt : i > cnt; i += (0 <= cnt) ? 1 : -1) {
inv_half[x] = FLOW_CHECKED_MOD(((pref[((cnt - 1) - i)] * inv_total)), (MOD));
inv_total = FLOW_CHECKED_MOD(((inv_total * x)), (MOD));
x = (x - 1);
}
s = (s + cnt);
}
free(pref);
int64_t max_odd = ((2 * L) + 3);
int64_t odd_count = (FLOW_CHECKED_DIV((max_odd), (2)) + 1);
int64_t* inv_odd = (int64_t*)(calloc(odd_count, 8));
int64_t* pref2 = (int64_t*)(calloc((block + 1), 8));
int64_t idx = 0;
while (idx < odd_count) {
int64_t cnt = block;
if ((odd_count - idx) < cnt) {
cnt = (odd_count - idx);
}
pref2[0] = 1;
int64_t x = ((2 * idx) + 1);
int32_t __flow_step_4 = 1;
for (int32_t i = 0; (0 <= cnt) ? i < cnt : i > cnt; i += (0 <= cnt) ? 1 : -1) {
pref2[(i + 1)] = FLOW_CHECKED_MOD(((pref2[i] * x)), (MOD));
x = (x + 2);
}
int64_t inv_total2 = pow_mod_i64_i64_i64(pref2[cnt], (MOD - 2), MOD);
x = ((2 * ((idx + cnt) - 1)) + 1);
int32_t __flow_step_5 = 1;
for (int32_t i = 0; (0 <= cnt) ? i < cnt : i > cnt; i += (0 <= cnt) ? 1 : -1) {
inv_odd[(((idx + cnt) - 1) - i)] = FLOW_CHECKED_MOD(((pref2[((cnt - 1) - i)] * inv_total2)), (MOD));
inv_total2 = FLOW_CHECKED_MOD(((inv_total2 * x)), (MOD));
x = (x - 2);
}
idx = (idx + cnt);
}
free(pref2);
int64_t INV2 = FLOW_CHECKED_DIV(((MOD + 1)), (2));
int64_t K9 = FLOW_CHECKED_MOD(((9 * INV2)), (MOD));
int64_t S2 = 2;
int64_t S3 = 6;
int64_t max_i = FLOW_CHECKED_DIV(((L - 1)), (2));
int64_t C = 2;
int64_t D = 3;
int64_t a1 = 3;
int64_t a3 = 5;
int64_t idx_a1 = 1;
int64_t idx_a3 = 2;
int64_t t1 = 2;
int64_t t2 = 5;
int64_t t3 = 7;
int64_t t4 = 4;
int64_t i = 0;
while (i <= max_i) {
if ((i >= 1 && is_prime[i] == 1)) {
int64_t invp = inv_odd[i];
S2 = FLOW_CHECKED_MOD(((S2 + ((C + (4 * i)) * invp))), (MOD));
S3 = FLOW_CHECKED_MOD(((S3 + ((D + (6 * i)) * invp))), (MOD));
}
int64_t invh = inv_half[(i + 1)];
int64_t invn2 = inv_odd[(i + 1)];
C = FLOW_CHECKED_MOD(((C * a1)), (MOD));
C = FLOW_CHECKED_MOD(((C * a3)), (MOD));
C = FLOW_CHECKED_MOD(((C * invh)), (MOD));
C = FLOW_CHECKED_MOD(((C * invn2)), (MOD));
C = FLOW_CHECKED_MOD(((C * 2)), (MOD));
D = FLOW_CHECKED_MOD(((D * K9)), (MOD));
D = FLOW_CHECKED_MOD(((D * t1)), (MOD));
D = FLOW_CHECKED_MOD(((D * t2)), (MOD));
D = FLOW_CHECKED_MOD(((D * t3)), (MOD));
D = FLOW_CHECKED_MOD(((D * t4)), (MOD));
D = FLOW_CHECKED_MOD(((D * invh)), (MOD));
D = FLOW_CHECKED_MOD(((D * invn2)), (MOD));
D = FLOW_CHECKED_MOD(((D * inv_odd[idx_a1])), (MOD));
D = FLOW_CHECKED_MOD(((D * inv_odd[idx_a3])), (MOD));
i = (i + 1);
a1 = (a1 + 4);
a3 = (a3 + 4);
idx_a1 = (idx_a1 + 2);
idx_a3 = (idx_a3 + 2);
t1 = (t1 + 3);
t2 = (t2 + 6);
t3 = (t3 + 6);
t4 = (t4 + 3);
}
int64_t ans = FLOW_CHECKED_MOD(((S2 + S3)), (MOD));
printf("%lld\n", ans);
free(inv_odd);
free(inv_half);
free(is_prime);
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) -> ()
// Constant: MOD
llvm.mlir.global internal constant @MOD(1000000009 : i64) : i64
func.func @pow_mod(%arg0: i64, %arg1: i64, %arg2: i64) -> i64 {
%175 = arith.constant 1 : i32
%176 = arith.extsi %175 : i32 to i64
%177 = llvm.mlir.constant(1 : i64) : i64
%178 = llvm.alloca %177 x i64 : (i64) -> !llvm.ptr
llvm.store %176, %178 : i64, !llvm.ptr
%179 = arith.remsi %arg0, %arg2 : i64
%180 = llvm.mlir.constant(1 : i64) : i64
%181 = llvm.alloca %180 x i64 : (i64) -> !llvm.ptr
llvm.store %179, %181 : i64, !llvm.ptr
%182 = llvm.mlir.constant(1 : i64) : i64
%183 = llvm.alloca %182 x i64 : (i64) -> !llvm.ptr
llvm.store %arg1, %183 : i64, !llvm.ptr
cf.br ^bb42
^bb42:
%184 = llvm.load %183 : !llvm.ptr -> i64
%185 = arith.constant 0 : i32
%187 = arith.extsi %185 : i32 to i64
%186 = arith.cmpi sgt, %184, %187 : i64
cf.cond_br %186, ^bb43, ^bb44
^bb43:
%188 = llvm.load %183 : !llvm.ptr -> i64
%189 = arith.constant 1 : i32
%190 = arith.constant 1 : i32
%191 = arith.cmpi eq, %189, %190 : i32
%193 = arith.trunci %188 : i64 to i1
%192 = arith.andi %193, %191 : i1
cf.cond_br %192, ^bb45, ^bb46
^bb45:
%194 = llvm.load %178 : !llvm.ptr -> i64
%195 = llvm.load %181 : !llvm.ptr -> i64
%196 = arith.muli %194, %195 : i64
%197 = arith.remsi %196, %arg2 : i64
llvm.store %197, %178 : i64, !llvm.ptr
cf.br ^bb47
^bb46:
cf.br ^bb47
^bb47:
%198 = llvm.load %181 : !llvm.ptr -> i64
%199 = llvm.load %181 : !llvm.ptr -> i64
%200 = arith.muli %198, %199 : i64
%201 = arith.remsi %200, %arg2 : i64
llvm.store %201, %181 : i64, !llvm.ptr
%202 = llvm.load %183 : !llvm.ptr -> i64
%203 = arith.constant 1 : i32
%205 = arith.extsi %203 : i32 to i64
%204 = arith.shrsi %202, %205 : i64
llvm.store %204, %183 : i64, !llvm.ptr
cf.br ^bb42
^bb44:
%206 = llvm.load %178 : !llvm.ptr -> i64
func.return %206 : i64
}
func.func @main() -> i32 {
%207 = arith.constant 100000000 : i32
%208 = arith.extsi %207 : i32 to i64
%209 = arith.constant 2 : i32
%211 = arith.extsi %209 : i32 to i64
%210 = arith.divsi %208, %211 : i64
%212 = arith.constant 1 : i32
%214 = arith.extsi %212 : i32 to i64
%213 = arith.addi %210, %214 : i64
%216 = arith.constant 8 : i32
%217 = arith.extsi %216 : i32 to i64
%215 = func.call @calloc(%213, %217) : (i64, i64) -> !llvm.ptr
%218 = arith.constant 0 : i32
%219 = arith.index_cast %218 : i32 to index
%220 = arith.index_cast %213 : i32 to index
%222 = arith.constant 1 : index
%223 = arith.constant -1 : index
%224 = arith.cmpi sle, %219, %220 : index
%221 = arith.select %224, %222, %223 : index
cf.br ^bb48(%219 : index)
^bb48(%225: index):
%226 = arith.cmpi slt, %225, %220 : index
%227 = arith.cmpi sgt, %225, %220 : index
%228 = arith.select %224, %226, %227 : i1
cf.cond_br %228, ^bb49(%225 : index), ^bb50(%225 : index)
^bb49(%229: index):
%230 = arith.constant 1 : i32
%231 = arith.extsi %230 : i32 to i64
%232 = arith.index_cast %229 : index to i64
%233 = llvm.getelementptr %215[%232] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %231, %233 : i64, !llvm.ptr
%234 = arith.addi %229, %221 : index
cf.br ^bb48(%234 : index)
^bb50(%235: index):
%236 = arith.constant 0 : i32
%237 = arith.constant 0 : i32
%238 = arith.extsi %236 : i32 to i64
%239 = arith.extsi %237 : i32 to i64
%240 = llvm.getelementptr %215[%239] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %238, %240 : i64, !llvm.ptr
%241 = func.call @isqrt(%208) : (i64) -> i64
%242 = arith.constant 3 : i32
%243 = arith.extsi %242 : i32 to i64
%244 = llvm.mlir.constant(1 : i64) : i64
%245 = llvm.alloca %244 x i64 : (i64) -> !llvm.ptr
llvm.store %243, %245 : i64, !llvm.ptr
cf.br ^bb51
^bb51:
%246 = llvm.load %245 : !llvm.ptr -> i64
%247 = arith.cmpi sle, %246, %241 : i64
cf.cond_br %247, ^bb52, ^bb53
^bb52:
%249 = llvm.load %245 : !llvm.ptr -> i64
%250 = arith.constant 2 : i32
%252 = arith.extsi %250 : i32 to i64
%251 = arith.divsi %249, %252 : i64
%253 = llvm.getelementptr %215[%251] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%248 = llvm.load %253 : !llvm.ptr -> i64
%254 = arith.constant 1 : i32
%256 = arith.extsi %254 : i32 to i64
%255 = arith.cmpi eq, %248, %256 : i64
cf.cond_br %255, ^bb54, ^bb55
^bb54:
%257 = llvm.load %245 : !llvm.ptr -> i64
%258 = llvm.load %245 : !llvm.ptr -> i64
%259 = arith.muli %257, %258 : i64
%260 = arith.constant 2 : i32
%262 = arith.extsi %260 : i32 to i64
%261 = arith.divsi %259, %262 : i64
%263 = llvm.mlir.constant(1 : i64) : i64
%264 = llvm.alloca %263 x i64 : (i64) -> !llvm.ptr
llvm.store %261, %264 : i64, !llvm.ptr
cf.br ^bb57
^bb57:
%265 = llvm.load %264 : !llvm.ptr -> i64
%266 = arith.cmpi slt, %265, %213 : i64
cf.cond_br %266, ^bb58, ^bb59
^bb58:
%267 = arith.constant 0 : i32
%268 = llvm.load %264 : !llvm.ptr -> i64
%269 = arith.extsi %267 : i32 to i64
%270 = llvm.getelementptr %215[%268] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %269, %270 : i64, !llvm.ptr
%271 = llvm.load %264 : !llvm.ptr -> i64
%272 = llvm.load %245 : !llvm.ptr -> i64
%273 = arith.addi %271, %272 : i64
llvm.store %273, %264 : i64, !llvm.ptr
cf.br ^bb57
^bb59:
cf.br ^bb56
^bb55:
cf.br ^bb56
^bb56:
%274 = llvm.load %245 : !llvm.ptr -> i64
%275 = arith.constant 2 : i32
%277 = arith.extsi %275 : i32 to i64
%276 = arith.addi %274, %277 : i64
llvm.store %276, %245 : i64, !llvm.ptr
cf.br ^bb51
^bb53:
%278 = arith.constant 1 : i32
%280 = arith.extsi %278 : i32 to i64
%279 = arith.addi %208, %280 : i64
%281 = arith.constant 2 : i32
%283 = arith.extsi %281 : i32 to i64
%282 = arith.divsi %279, %283 : i64
%285 = arith.constant 1 : i32
%287 = arith.extsi %285 : i32 to i64
%286 = arith.addi %282, %287 : i64
%288 = arith.constant 8 : i32
%289 = arith.extsi %288 : i32 to i64
%284 = func.call @calloc(%286, %289) : (i64, i64) -> !llvm.ptr
%290 = arith.constant 1000000 : i32
%291 = arith.extsi %290 : i32 to i64
%293 = arith.constant 1 : i32
%295 = arith.extsi %293 : i32 to i64
%294 = arith.addi %291, %295 : i64
%296 = arith.constant 8 : i32
%297 = arith.extsi %296 : i32 to i64
%292 = func.call @calloc(%294, %297) : (i64, i64) -> !llvm.ptr
%298 = arith.constant 1 : i32
%299 = arith.extsi %298 : i32 to i64
%300 = llvm.mlir.constant(1 : i64) : i64
%301 = llvm.alloca %300 x i64 : (i64) -> !llvm.ptr
llvm.store %299, %301 : i64, !llvm.ptr
cf.br ^bb60
^bb60:
%302 = llvm.load %301 : !llvm.ptr -> i64
%303 = arith.cmpi sle, %302, %282 : i64
cf.cond_br %303, ^bb61, ^bb62
^bb61:
%304 = llvm.load %301 : !llvm.ptr -> i64
%305 = arith.subi %282, %304 : i64
%306 = arith.constant 1 : i32
%308 = arith.extsi %306 : i32 to i64
%307 = arith.addi %305, %308 : i64
%309 = arith.cmpi slt, %307, %291 : i64
%310 = scf.if %309 -> (i64) {
%311 = llvm.load %301 : !llvm.ptr -> i64
%312 = arith.subi %282, %311 : i64
%313 = arith.constant 1 : i32
%315 = arith.extsi %313 : i32 to i64
%314 = arith.addi %312, %315 : i64
scf.yield %314 : i64
} else {
scf.yield %291 : i64
}
%316 = arith.constant 1 : i32
%317 = arith.constant 0 : i32
%318 = arith.extsi %316 : i32 to i64
%319 = arith.extsi %317 : i32 to i64
%320 = llvm.getelementptr %292[%319] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %318, %320 : i64, !llvm.ptr
%321 = llvm.load %301 : !llvm.ptr -> i64
%322 = llvm.mlir.constant(1 : i64) : i64
%323 = llvm.alloca %322 x i64 : (i64) -> !llvm.ptr
llvm.store %321, %323 : i64, !llvm.ptr
%324 = arith.constant 0 : i32
%325 = arith.index_cast %324 : i32 to index
%326 = arith.index_cast %310 : i32 to index
%328 = arith.constant 1 : index
%329 = arith.constant -1 : index
%330 = arith.cmpi sle, %325, %326 : index
%327 = arith.select %330, %328, %329 : index
cf.br ^bb63(%325 : index)
^bb63(%331: index):
%332 = arith.cmpi slt, %331, %326 : index
%333 = arith.cmpi sgt, %331, %326 : index
%334 = arith.select %330, %332, %333 : i1
cf.cond_br %334, ^bb64(%331 : index), ^bb65(%331 : index)
^bb64(%335: index):
%337 = arith.index_cast %335 : index to i64
%338 = llvm.getelementptr %292[%337] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%336 = llvm.load %338 : !llvm.ptr -> i64
%339 = llvm.load %323 : !llvm.ptr -> i64
%340 = arith.muli %336, %339 : i64
%341 = llvm.mlir.addressof @MOD : !llvm.ptr
%342 = llvm.load %341 : !llvm.ptr -> i64
%343 = arith.remsi %340, %342 : i64
%344 = arith.constant 1 : i32
%346 = arith.index_cast %335 : index to i32
%345 = arith.addi %346, %344 : i32
%347 = arith.extsi %345 : i32 to i64
%348 = llvm.getelementptr %292[%347] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %343, %348 : i64, !llvm.ptr
%349 = llvm.load %323 : !llvm.ptr -> i64
%350 = arith.constant 1 : i32
%352 = arith.extsi %350 : i32 to i64
%351 = arith.addi %349, %352 : i64
llvm.store %351, %323 : i64, !llvm.ptr
%353 = arith.addi %335, %327 : index
cf.br ^bb63(%353 : index)
^bb65(%354: index):
%357 = llvm.getelementptr %292[%310] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%356 = llvm.load %357 : !llvm.ptr -> i64
%358 = llvm.mlir.addressof @MOD : !llvm.ptr
%359 = llvm.load %358 : !llvm.ptr -> i64
%360 = arith.constant 2 : i32
%362 = arith.extsi %360 : i32 to i64
%361 = arith.subi %359, %362 : i64
%363 = llvm.mlir.addressof @MOD : !llvm.ptr
%364 = llvm.load %363 : !llvm.ptr -> i64
%355 = func.call @pow_mod(%356, %361, %364) : (i64, i64, i64) -> i64
%365 = llvm.mlir.constant(1 : i64) : i64
%366 = llvm.alloca %365 x i64 : (i64) -> !llvm.ptr
llvm.store %355, %366 : i64, !llvm.ptr
%367 = llvm.load %301 : !llvm.ptr -> i64
%368 = arith.addi %367, %310 : i64
%369 = arith.constant 1 : i32
%371 = arith.extsi %369 : i32 to i64
%370 = arith.subi %368, %371 : i64
llvm.store %370, %323 : i64, !llvm.ptr
%372 = arith.constant 0 : i32
%373 = arith.index_cast %372 : i32 to index
%374 = arith.index_cast %310 : i32 to index
%376 = arith.constant 1 : index
%377 = arith.constant -1 : index
%378 = arith.cmpi sle, %373, %374 : index
%375 = arith.select %378, %376, %377 : index
cf.br ^bb66(%373 : index)
^bb66(%379: index):
%380 = arith.cmpi slt, %379, %374 : index
%381 = arith.cmpi sgt, %379, %374 : index
%382 = arith.select %378, %380, %381 : i1
cf.cond_br %382, ^bb67(%379 : index), ^bb68(%379 : index)
^bb67(%383: index):
%385 = arith.constant 1 : i32
%387 = arith.extsi %385 : i32 to i64
%386 = arith.subi %310, %387 : i64
%389 = arith.trunci %386 : i64 to i32
%390 = arith.index_cast %383 : index to i32
%388 = arith.subi %389, %390 : i32
%391 = arith.extsi %388 : i32 to i64
%392 = llvm.getelementptr %292[%391] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%384 = llvm.load %392 : !llvm.ptr -> i64
%393 = llvm.load %366 : !llvm.ptr -> i64
%394 = arith.muli %384, %393 : i64
%395 = llvm.mlir.addressof @MOD : !llvm.ptr
%396 = llvm.load %395 : !llvm.ptr -> i64
%397 = arith.remsi %394, %396 : i64
%398 = llvm.load %323 : !llvm.ptr -> i64
%399 = llvm.getelementptr %284[%398] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %397, %399 : i64, !llvm.ptr
%400 = llvm.load %366 : !llvm.ptr -> i64
%401 = llvm.load %323 : !llvm.ptr -> i64
%402 = arith.muli %400, %401 : i64
%403 = llvm.mlir.addressof @MOD : !llvm.ptr
%404 = llvm.load %403 : !llvm.ptr -> i64
%405 = arith.remsi %402, %404 : i64
llvm.store %405, %366 : i64, !llvm.ptr
%406 = llvm.load %323 : !llvm.ptr -> i64
%407 = arith.constant 1 : i32
%409 = arith.extsi %407 : i32 to i64
%408 = arith.subi %406, %409 : i64
llvm.store %408, %323 : i64, !llvm.ptr
%410 = arith.addi %383, %375 : index
cf.br ^bb66(%410 : index)
^bb68(%411: index):
%412 = llvm.load %301 : !llvm.ptr -> i64
%413 = arith.addi %412, %310 : i64
llvm.store %413, %301 : i64, !llvm.ptr
cf.br ^bb60
^bb62:
func.call @free(%292) : (!llvm.ptr) -> ()
%415 = arith.constant 2 : i32
%417 = arith.extsi %415 : i32 to i64
%416 = arith.muli %417, %208 : i64
%418 = arith.constant 3 : i32
%420 = arith.extsi %418 : i32 to i64
%419 = arith.addi %416, %420 : i64
%421 = arith.constant 2 : i32
%423 = arith.extsi %421 : i32 to i64
%422 = arith.divsi %419, %423 : i64
%424 = arith.constant 1 : i32
%426 = arith.extsi %424 : i32 to i64
%425 = arith.addi %422, %426 : i64
%428 = arith.constant 8 : i32
%429 = arith.extsi %428 : i32 to i64
%427 = func.call @calloc(%425, %429) : (i64, i64) -> !llvm.ptr
%431 = arith.constant 1 : i32
%433 = arith.extsi %431 : i32 to i64
%432 = arith.addi %291, %433 : i64
%434 = arith.constant 8 : i32
%435 = arith.extsi %434 : i32 to i64
%430 = func.call @calloc(%432, %435) : (i64, i64) -> !llvm.ptr
%436 = arith.constant 0 : i32
%437 = arith.extsi %436 : i32 to i64
%438 = llvm.mlir.constant(1 : i64) : i64
%439 = llvm.alloca %438 x i64 : (i64) -> !llvm.ptr
llvm.store %437, %439 : i64, !llvm.ptr
cf.br ^bb69
^bb69:
%440 = llvm.load %439 : !llvm.ptr -> i64
%441 = arith.cmpi slt, %440, %425 : i64
cf.cond_br %441, ^bb70, ^bb71
^bb70:
%442 = llvm.load %439 : !llvm.ptr -> i64
%443 = arith.subi %425, %442 : i64
%444 = arith.cmpi slt, %443, %291 : i64
%445 = scf.if %444 -> (i64) {
%446 = llvm.load %439 : !llvm.ptr -> i64
%447 = arith.subi %425, %446 : i64
scf.yield %447 : i64
} else {
scf.yield %291 : i64
}
%448 = arith.constant 1 : i32
%449 = arith.constant 0 : i32
%450 = arith.extsi %448 : i32 to i64
%451 = arith.extsi %449 : i32 to i64
%452 = llvm.getelementptr %430[%451] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %450, %452 : i64, !llvm.ptr
%453 = arith.constant 2 : i32
%454 = llvm.load %439 : !llvm.ptr -> i64
%456 = arith.extsi %453 : i32 to i64
%455 = arith.muli %456, %454 : i64
%457 = arith.constant 1 : i32
%459 = arith.extsi %457 : i32 to i64
%458 = arith.addi %455, %459 : i64
%460 = llvm.mlir.constant(1 : i64) : i64
%461 = llvm.alloca %460 x i64 : (i64) -> !llvm.ptr
llvm.store %458, %461 : i64, !llvm.ptr
%462 = arith.constant 0 : i32
%463 = arith.index_cast %462 : i32 to index
%464 = arith.index_cast %445 : i32 to index
%466 = arith.constant 1 : index
%467 = arith.constant -1 : index
%468 = arith.cmpi sle, %463, %464 : index
%465 = arith.select %468, %466, %467 : index
cf.br ^bb72(%463 : index)
^bb72(%469: index):
%470 = arith.cmpi slt, %469, %464 : index
%471 = arith.cmpi sgt, %469, %464 : index
%472 = arith.select %468, %470, %471 : i1
cf.cond_br %472, ^bb73(%469 : index), ^bb74(%469 : index)
^bb73(%473: index):
%475 = arith.index_cast %473 : index to i64
%476 = llvm.getelementptr %430[%475] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%474 = llvm.load %476 : !llvm.ptr -> i64
%477 = llvm.load %461 : !llvm.ptr -> i64
%478 = arith.muli %474, %477 : i64
%479 = llvm.mlir.addressof @MOD : !llvm.ptr
%480 = llvm.load %479 : !llvm.ptr -> i64
%481 = arith.remsi %478, %480 : i64
%482 = arith.constant 1 : i32
%484 = arith.index_cast %473 : index to i32
%483 = arith.addi %484, %482 : i32
%485 = arith.extsi %483 : i32 to i64
%486 = llvm.getelementptr %430[%485] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %481, %486 : i64, !llvm.ptr
%487 = llvm.load %461 : !llvm.ptr -> i64
%488 = arith.constant 2 : i32
%490 = arith.extsi %488 : i32 to i64
%489 = arith.addi %487, %490 : i64
llvm.store %489, %461 : i64, !llvm.ptr
%491 = arith.addi %473, %465 : index
cf.br ^bb72(%491 : index)
^bb74(%492: index):
%495 = llvm.getelementptr %430[%445] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%494 = llvm.load %495 : !llvm.ptr -> i64
%496 = llvm.mlir.addressof @MOD : !llvm.ptr
%497 = llvm.load %496 : !llvm.ptr -> i64
%498 = arith.constant 2 : i32
%500 = arith.extsi %498 : i32 to i64
%499 = arith.subi %497, %500 : i64
%501 = llvm.mlir.addressof @MOD : !llvm.ptr
%502 = llvm.load %501 : !llvm.ptr -> i64
%493 = func.call @pow_mod(%494, %499, %502) : (i64, i64, i64) -> i64
%503 = llvm.mlir.constant(1 : i64) : i64
%504 = llvm.alloca %503 x i64 : (i64) -> !llvm.ptr
llvm.store %493, %504 : i64, !llvm.ptr
%505 = arith.constant 2 : i32
%506 = llvm.load %439 : !llvm.ptr -> i64
%507 = arith.addi %506, %445 : i64
%508 = arith.constant 1 : i32
%510 = arith.extsi %508 : i32 to i64
%509 = arith.subi %507, %510 : i64
%512 = arith.extsi %505 : i32 to i64
%511 = arith.muli %512, %509 : i64
%513 = arith.constant 1 : i32
%515 = arith.extsi %513 : i32 to i64
%514 = arith.addi %511, %515 : i64
llvm.store %514, %461 : i64, !llvm.ptr
%516 = arith.constant 0 : i32
%517 = arith.index_cast %516 : i32 to index
%518 = arith.index_cast %445 : i32 to index
%520 = arith.constant 1 : index
%521 = arith.constant -1 : index
%522 = arith.cmpi sle, %517, %518 : index
%519 = arith.select %522, %520, %521 : index
cf.br ^bb75(%517 : index)
^bb75(%523: index):
%524 = arith.cmpi slt, %523, %518 : index
%525 = arith.cmpi sgt, %523, %518 : index
%526 = arith.select %522, %524, %525 : i1
cf.cond_br %526, ^bb76(%523 : index), ^bb77(%523 : index)
^bb76(%527: index):
%529 = arith.constant 1 : i32
%531 = arith.extsi %529 : i32 to i64
%530 = arith.subi %445, %531 : i64
%533 = arith.trunci %530 : i64 to i32
%534 = arith.index_cast %527 : index to i32
%532 = arith.subi %533, %534 : i32
%535 = arith.extsi %532 : i32 to i64
%536 = llvm.getelementptr %430[%535] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%528 = llvm.load %536 : !llvm.ptr -> i64
%537 = llvm.load %504 : !llvm.ptr -> i64
%538 = arith.muli %528, %537 : i64
%539 = llvm.mlir.addressof @MOD : !llvm.ptr
%540 = llvm.load %539 : !llvm.ptr -> i64
%541 = arith.remsi %538, %540 : i64
%542 = llvm.load %439 : !llvm.ptr -> i64
%543 = arith.addi %542, %445 : i64
%544 = arith.constant 1 : i32
%546 = arith.extsi %544 : i32 to i64
%545 = arith.subi %543, %546 : i64
%548 = arith.trunci %545 : i64 to i32
%549 = arith.index_cast %527 : index to i32
%547 = arith.subi %548, %549 : i32
%550 = arith.extsi %547 : i32 to i64
%551 = llvm.getelementptr %427[%550] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %541, %551 : i64, !llvm.ptr
%552 = llvm.load %504 : !llvm.ptr -> i64
%553 = llvm.load %461 : !llvm.ptr -> i64
%554 = arith.muli %552, %553 : i64
%555 = llvm.mlir.addressof @MOD : !llvm.ptr
%556 = llvm.load %555 : !llvm.ptr -> i64
%557 = arith.remsi %554, %556 : i64
llvm.store %557, %504 : i64, !llvm.ptr
%558 = llvm.load %461 : !llvm.ptr -> i64
%559 = arith.constant 2 : i32
%561 = arith.extsi %559 : i32 to i64
%560 = arith.subi %558, %561 : i64
llvm.store %560, %461 : i64, !llvm.ptr
%562 = arith.addi %527, %519 : index
cf.br ^bb75(%562 : index)
^bb77(%563: index):
%564 = llvm.load %439 : !llvm.ptr -> i64
%565 = arith.addi %564, %445 : i64
llvm.store %565, %439 : i64, !llvm.ptr
cf.br ^bb69
^bb71:
func.call @free(%430) : (!llvm.ptr) -> ()
%567 = llvm.mlir.addressof @MOD : !llvm.ptr
%568 = llvm.load %567 : !llvm.ptr -> i64
%569 = arith.constant 1 : i32
%571 = arith.extsi %569 : i32 to i64
%570 = arith.addi %568, %571 : i64
%572 = arith.constant 2 : i32
%574 = arith.extsi %572 : i32 to i64
%573 = arith.divsi %570, %574 : i64
%575 = arith.constant 9 : i32
%577 = arith.extsi %575 : i32 to i64
%576 = arith.muli %577, %573 : i64
%578 = llvm.mlir.addressof @MOD : !llvm.ptr
%579 = llvm.load %578 : !llvm.ptr -> i64
%580 = arith.remsi %576, %579 : i64
%581 = arith.constant 2 : i32
%582 = arith.extsi %581 : i32 to i64
%583 = llvm.mlir.constant(1 : i64) : i64
%584 = llvm.alloca %583 x i64 : (i64) -> !llvm.ptr
llvm.store %582, %584 : i64, !llvm.ptr
%585 = arith.constant 6 : i32
%586 = arith.extsi %585 : i32 to i64
%587 = llvm.mlir.constant(1 : i64) : i64
%588 = llvm.alloca %587 x i64 : (i64) -> !llvm.ptr
llvm.store %586, %588 : i64, !llvm.ptr
%589 = arith.constant 1 : i32
%591 = arith.extsi %589 : i32 to i64
%590 = arith.subi %208, %591 : i64
%592 = arith.constant 2 : i32
%594 = arith.extsi %592 : i32 to i64
%593 = arith.divsi %590, %594 : i64
%595 = arith.constant 2 : i32
%596 = arith.extsi %595 : i32 to i64
%597 = llvm.mlir.constant(1 : i64) : i64
%598 = llvm.alloca %597 x i64 : (i64) -> !llvm.ptr
llvm.store %596, %598 : i64, !llvm.ptr
%599 = arith.constant 3 : i32
%600 = arith.extsi %599 : i32 to i64
%601 = llvm.mlir.constant(1 : i64) : i64
%602 = llvm.alloca %601 x i64 : (i64) -> !llvm.ptr
llvm.store %600, %602 : i64, !llvm.ptr
%603 = arith.constant 3 : i32
%604 = arith.extsi %603 : i32 to i64
%605 = llvm.mlir.constant(1 : i64) : i64
%606 = llvm.alloca %605 x i64 : (i64) -> !llvm.ptr
llvm.store %604, %606 : i64, !llvm.ptr
%607 = arith.constant 5 : i32
%608 = arith.extsi %607 : i32 to i64
%609 = llvm.mlir.constant(1 : i64) : i64
%610 = llvm.alloca %609 x i64 : (i64) -> !llvm.ptr
llvm.store %608, %610 : i64, !llvm.ptr
%611 = arith.constant 1 : i32
%612 = arith.extsi %611 : i32 to i64
%613 = llvm.mlir.constant(1 : i64) : i64
%614 = llvm.alloca %613 x i64 : (i64) -> !llvm.ptr
llvm.store %612, %614 : i64, !llvm.ptr
%615 = arith.constant 2 : i32
%616 = arith.extsi %615 : i32 to i64
%617 = llvm.mlir.constant(1 : i64) : i64
%618 = llvm.alloca %617 x i64 : (i64) -> !llvm.ptr
llvm.store %616, %618 : i64, !llvm.ptr
%619 = arith.constant 2 : i32
%620 = arith.extsi %619 : i32 to i64
%621 = llvm.mlir.constant(1 : i64) : i64
%622 = llvm.alloca %621 x i64 : (i64) -> !llvm.ptr
llvm.store %620, %622 : i64, !llvm.ptr
%623 = arith.constant 5 : i32
%624 = arith.extsi %623 : i32 to i64
%625 = llvm.mlir.constant(1 : i64) : i64
%626 = llvm.alloca %625 x i64 : (i64) -> !llvm.ptr
llvm.store %624, %626 : i64, !llvm.ptr
%627 = arith.constant 7 : i32
%628 = arith.extsi %627 : i32 to i64
%629 = llvm.mlir.constant(1 : i64) : i64
%630 = llvm.alloca %629 x i64 : (i64) -> !llvm.ptr
llvm.store %628, %630 : i64, !llvm.ptr
%631 = arith.constant 4 : i32
%632 = arith.extsi %631 : i32 to i64
%633 = llvm.mlir.constant(1 : i64) : i64
%634 = llvm.alloca %633 x i64 : (i64) -> !llvm.ptr
llvm.store %632, %634 : i64, !llvm.ptr
%635 = arith.constant 0 : i32
%636 = arith.extsi %635 : i32 to i64
%637 = llvm.mlir.constant(1 : i64) : i64
%638 = llvm.alloca %637 x i64 : (i64) -> !llvm.ptr
llvm.store %636, %638 : i64, !llvm.ptr
cf.br ^bb78
^bb78:
%639 = llvm.load %638 : !llvm.ptr -> i64
%640 = arith.cmpi sle, %639, %593 : i64
cf.cond_br %640, ^bb79, ^bb80
^bb79:
%641 = llvm.load %638 : !llvm.ptr -> i64
%642 = arith.constant 1 : i32
%644 = arith.extsi %642 : i32 to i64
%643 = arith.cmpi sge, %641, %644 : i64
%645 = scf.if %643 -> (i1) {
%647 = llvm.load %638 : !llvm.ptr -> i64
%648 = llvm.getelementptr %215[%647] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%646 = llvm.load %648 : !llvm.ptr -> i64
%649 = arith.constant 1 : i32
%651 = arith.extsi %649 : i32 to i64
%650 = arith.cmpi eq, %646, %651 : i64
scf.yield %650 : i1
} else {
%652 = arith.constant false
scf.yield %652 : i1
}
cf.cond_br %645, ^bb81, ^bb82
^bb81:
%654 = llvm.load %638 : !llvm.ptr -> i64
%655 = llvm.getelementptr %427[%654] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%653 = llvm.load %655 : !llvm.ptr -> i64
%656 = llvm.load %584 : !llvm.ptr -> i64
%657 = llvm.load %598 : !llvm.ptr -> i64
%658 = arith.constant 4 : i32
%659 = llvm.load %638 : !llvm.ptr -> i64
%661 = arith.extsi %658 : i32 to i64
%660 = arith.muli %661, %659 : i64
%662 = arith.addi %657, %660 : i64
%663 = arith.muli %662, %653 : i64
%664 = arith.addi %656, %663 : i64
%665 = llvm.mlir.addressof @MOD : !llvm.ptr
%666 = llvm.load %665 : !llvm.ptr -> i64
%667 = arith.remsi %664, %666 : i64
llvm.store %667, %584 : i64, !llvm.ptr
%668 = llvm.load %588 : !llvm.ptr -> i64
%669 = llvm.load %602 : !llvm.ptr -> i64
%670 = arith.constant 6 : i32
%671 = llvm.load %638 : !llvm.ptr -> i64
%673 = arith.extsi %670 : i32 to i64
%672 = arith.muli %673, %671 : i64
%674 = arith.addi %669, %672 : i64
%675 = arith.muli %674, %653 : i64
%676 = arith.addi %668, %675 : i64
%677 = llvm.mlir.addressof @MOD : !llvm.ptr
%678 = llvm.load %677 : !llvm.ptr -> i64
%679 = arith.remsi %676, %678 : i64
llvm.store %679, %588 : i64, !llvm.ptr
cf.br ^bb83
^bb82:
cf.br ^bb83
^bb83:
%681 = llvm.load %638 : !llvm.ptr -> i64
%682 = arith.constant 1 : i32
%684 = arith.extsi %682 : i32 to i64
%683 = arith.addi %681, %684 : i64
%685 = llvm.getelementptr %284[%683] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%680 = llvm.load %685 : !llvm.ptr -> i64
%687 = llvm.load %638 : !llvm.ptr -> i64
%688 = arith.constant 1 : i32
%690 = arith.extsi %688 : i32 to i64
%689 = arith.addi %687, %690 : i64
%691 = llvm.getelementptr %427[%689] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%686 = llvm.load %691 : !llvm.ptr -> i64
%692 = llvm.load %598 : !llvm.ptr -> i64
%693 = llvm.load %606 : !llvm.ptr -> i64
%694 = arith.muli %692, %693 : i64
%695 = llvm.mlir.addressof @MOD : !llvm.ptr
%696 = llvm.load %695 : !llvm.ptr -> i64
%697 = arith.remsi %694, %696 : i64
llvm.store %697, %598 : i64, !llvm.ptr
%698 = llvm.load %598 : !llvm.ptr -> i64
%699 = llvm.load %610 : !llvm.ptr -> i64
%700 = arith.muli %698, %699 : i64
%701 = llvm.mlir.addressof @MOD : !llvm.ptr
%702 = llvm.load %701 : !llvm.ptr -> i64
%703 = arith.remsi %700, %702 : i64
llvm.store %703, %598 : i64, !llvm.ptr
%704 = llvm.load %598 : !llvm.ptr -> i64
%705 = arith.muli %704, %680 : i64
%706 = llvm.mlir.addressof @MOD : !llvm.ptr
%707 = llvm.load %706 : !llvm.ptr -> i64
%708 = arith.remsi %705, %707 : i64
llvm.store %708, %598 : i64, !llvm.ptr
%709 = llvm.load %598 : !llvm.ptr -> i64
%710 = arith.muli %709, %686 : i64
%711 = llvm.mlir.addressof @MOD : !llvm.ptr
%712 = llvm.load %711 : !llvm.ptr -> i64
%713 = arith.remsi %710, %712 : i64
llvm.store %713, %598 : i64, !llvm.ptr
%714 = llvm.load %598 : !llvm.ptr -> i64
%715 = arith.constant 2 : i32
%717 = arith.extsi %715 : i32 to i64
%716 = arith.muli %714, %717 : i64
%718 = llvm.mlir.addressof @MOD : !llvm.ptr
%719 = llvm.load %718 : !llvm.ptr -> i64
%720 = arith.remsi %716, %719 : i64
llvm.store %720, %598 : i64, !llvm.ptr
%721 = llvm.load %602 : !llvm.ptr -> i64
%722 = arith.muli %721, %580 : i64
%723 = llvm.mlir.addressof @MOD : !llvm.ptr
%724 = llvm.load %723 : !llvm.ptr -> i64
%725 = arith.remsi %722, %724 : i64
llvm.store %725, %602 : i64, !llvm.ptr
%726 = llvm.load %602 : !llvm.ptr -> i64
%727 = llvm.load %622 : !llvm.ptr -> i64
%728 = arith.muli %726, %727 : i64
%729 = llvm.mlir.addressof @MOD : !llvm.ptr
%730 = llvm.load %729 : !llvm.ptr -> i64
%731 = arith.remsi %728, %730 : i64
llvm.store %731, %602 : i64, !llvm.ptr
%732 = llvm.load %602 : !llvm.ptr -> i64
%733 = llvm.load %626 : !llvm.ptr -> i64
%734 = arith.muli %732, %733 : i64
%735 = llvm.mlir.addressof @MOD : !llvm.ptr
%736 = llvm.load %735 : !llvm.ptr -> i64
%737 = arith.remsi %734, %736 : i64
llvm.store %737, %602 : i64, !llvm.ptr
%738 = llvm.load %602 : !llvm.ptr -> i64
%739 = llvm.load %630 : !llvm.ptr -> i64
%740 = arith.muli %738, %739 : i64
%741 = llvm.mlir.addressof @MOD : !llvm.ptr
%742 = llvm.load %741 : !llvm.ptr -> i64
%743 = arith.remsi %740, %742 : i64
llvm.store %743, %602 : i64, !llvm.ptr
%744 = llvm.load %602 : !llvm.ptr -> i64
%745 = llvm.load %634 : !llvm.ptr -> i64
%746 = arith.muli %744, %745 : i64
%747 = llvm.mlir.addressof @MOD : !llvm.ptr
%748 = llvm.load %747 : !llvm.ptr -> i64
%749 = arith.remsi %746, %748 : i64
llvm.store %749, %602 : i64, !llvm.ptr
%750 = llvm.load %602 : !llvm.ptr -> i64
%751 = arith.muli %750, %680 : i64
%752 = llvm.mlir.addressof @MOD : !llvm.ptr
%753 = llvm.load %752 : !llvm.ptr -> i64
%754 = arith.remsi %751, %753 : i64
llvm.store %754, %602 : i64, !llvm.ptr
%755 = llvm.load %602 : !llvm.ptr -> i64
%756 = arith.muli %755, %686 : i64
%757 = llvm.mlir.addressof @MOD : !llvm.ptr
%758 = llvm.load %757 : !llvm.ptr -> i64
%759 = arith.remsi %756, %758 : i64
llvm.store %759, %602 : i64, !llvm.ptr
%760 = llvm.load %602 : !llvm.ptr -> i64
%762 = llvm.load %614 : !llvm.ptr -> i64
%763 = llvm.getelementptr %427[%762] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%761 = llvm.load %763 : !llvm.ptr -> i64
%764 = arith.muli %760, %761 : i64
%765 = llvm.mlir.addressof @MOD : !llvm.ptr
%766 = llvm.load %765 : !llvm.ptr -> i64
%767 = arith.remsi %764, %766 : i64
llvm.store %767, %602 : i64, !llvm.ptr
%768 = llvm.load %602 : !llvm.ptr -> i64
%770 = llvm.load %618 : !llvm.ptr -> i64
%771 = llvm.getelementptr %427[%770] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%769 = llvm.load %771 : !llvm.ptr -> i64
%772 = arith.muli %768, %769 : i64
%773 = llvm.mlir.addressof @MOD : !llvm.ptr
%774 = llvm.load %773 : !llvm.ptr -> i64
%775 = arith.remsi %772, %774 : i64
llvm.store %775, %602 : i64, !llvm.ptr
%776 = llvm.load %638 : !llvm.ptr -> i64
%777 = arith.constant 1 : i32
%779 = arith.extsi %777 : i32 to i64
%778 = arith.addi %776, %779 : i64
llvm.store %778, %638 : i64, !llvm.ptr
%780 = llvm.load %606 : !llvm.ptr -> i64
%781 = arith.constant 4 : i32
%783 = arith.extsi %781 : i32 to i64
%782 = arith.addi %780, %783 : i64
llvm.store %782, %606 : i64, !llvm.ptr
%784 = llvm.load %610 : !llvm.ptr -> i64
%785 = arith.constant 4 : i32
%787 = arith.extsi %785 : i32 to i64
%786 = arith.addi %784, %787 : i64
llvm.store %786, %610 : i64, !llvm.ptr
%788 = llvm.load %614 : !llvm.ptr -> i64
%789 = arith.constant 2 : i32
%791 = arith.extsi %789 : i32 to i64
%790 = arith.addi %788, %791 : i64
llvm.store %790, %614 : i64, !llvm.ptr
%792 = llvm.load %618 : !llvm.ptr -> i64
%793 = arith.constant 2 : i32
%795 = arith.extsi %793 : i32 to i64
%794 = arith.addi %792, %795 : i64
llvm.store %794, %618 : i64, !llvm.ptr
%796 = llvm.load %622 : !llvm.ptr -> i64
%797 = arith.constant 3 : i32
%799 = arith.extsi %797 : i32 to i64
%798 = arith.addi %796, %799 : i64
llvm.store %798, %622 : i64, !llvm.ptr
%800 = llvm.load %626 : !llvm.ptr -> i64
%801 = arith.constant 6 : i32
%803 = arith.extsi %801 : i32 to i64
%802 = arith.addi %800, %803 : i64
llvm.store %802, %626 : i64, !llvm.ptr
%804 = llvm.load %630 : !llvm.ptr -> i64
%805 = arith.constant 6 : i32
%807 = arith.extsi %805 : i32 to i64
%806 = arith.addi %804, %807 : i64
llvm.store %806, %630 : i64, !llvm.ptr
%808 = llvm.load %634 : !llvm.ptr -> i64
%809 = arith.constant 3 : i32
%811 = arith.extsi %809 : i32 to i64
%810 = arith.addi %808, %811 : i64
llvm.store %810, %634 : i64, !llvm.ptr
cf.br ^bb78
^bb80:
%812 = llvm.load %584 : !llvm.ptr -> i64
%813 = llvm.load %588 : !llvm.ptr -> i64
%814 = arith.addi %812, %813 : i64
%815 = llvm.mlir.addressof @MOD : !llvm.ptr
%816 = llvm.load %815 : !llvm.ptr -> i64
%817 = arith.remsi %814, %816 : i64
%818 = llvm.mlir.addressof @str_0 : !llvm.ptr
%819 = llvm.call @printf(%818, %817) vararg(!llvm.func<i32 (ptr, ...)>) : (!llvm.ptr, i64) -> i32
func.call @free(%427) : (!llvm.ptr) -> ()
func.call @free(%284) : (!llvm.ptr) -> ()
func.call @free(%215) : (!llvm.ptr) -> ()
%823 = arith.constant 0 : i32
func.return %823 : i32
}
}