← All problems
Problem 474
Last Digits of Divisors Count divisors of 10^6! ending with 65432, mod 10^16+61.
View problem on Project Euler
Performance comparison
Metric Our solution Best known
Time complexity O(n^3)O(n)
Space complexity O(n^2)O(n)
Approach Flow solution Big-integer arithmetic
Verdict Suboptimal
Flow source
# Project Euler 474
# Last Digits of Divisors
# Count divisors of 10^6! ending with 65432, mod 10^16+61.
import euler.nt { gcd }
extern {
function calloc(n: i64, size: i64) -> ptr<void>
function free(p: ptr<void>) -> void
}
const MOD: i64 = 10000000000000061
const N: i64 = 1000000
const D: i64 = 65432
const POW10: i64 = 100000
function expo(n0: i64, p: i64) -> i64 {
let mut n: i64 = n0
let mut v: i64 = 0
while n > 0 {
n = n / p
v = v + n
}
return v
}
function main() -> i32 {
let mut dd: i64 = D
let mut alpha: i64 = 0
let mut beta: i64 = 0
while dd % 2 == 0 {
dd = dd / 2
alpha = alpha + 1
}
while dd % 5 == 0 {
dd = dd / 5
beta = beta + 1
}
let mut fixed: i64 = 1
let mut i: i64 = 0
while i < alpha {
fixed = fixed * 2
i = i + 1
}
i = 0
while i < beta {
fixed = fixed * 5
i = i + 1
}
let modulus: i64 = POW10 / fixed
let target: i64 = D / fixed
if gcd(target, modulus) != 1 {
printf("%lld\n", 0)
return 0
}
let units: ptr<i64> = calloc(modulus, 8)
let index: ptr<i64> = calloc(modulus, 8)
if units == null || index == null { return 1 }
i = 0
while i < modulus {
index[i] = -1
i = i + 1
}
let mut nu: i64 = 0
let mut r: i64 = 1
while r < modulus {
if gcd(r, modulus) == 1 {
units[nu] = r
index[r] = nu
nu = nu + 1
}
r = r + 1
}
let sieve: ptr<i8> = calloc(N + 1, 1)
if sieve == null { return 1 }
i = 0
while i <= N {
sieve[i] = 1
i = i + 1
}
sieve[0] = 0
sieve[1] = 0
i = 2
while i * i <= N {
if sieve[i] != 0 {
let mut j: i64 = i * i
while j <= N {
sieve[j] = 0
j = j + i
}
}
i = i + 1
}
let primes: ptr<i64> = calloc(N / 5 + 10, 8)
if primes == null { return 1 }
let mut pc: i64 = 0
i = 2
while i <= N {
if sieve[i] != 0 {
primes[pc] = i
pc = pc + 1
}
i = i + 1
}
free(sieve)
let dp: ptr<i64> = calloc(nu, 8)
let ndp: ptr<i64> = calloc(nu, 8)
let seen: ptr<i8> = calloc(nu, 1)
let cycle: ptr<i64> = calloc(nu, 8)
let vals: ptr<i64> = calloc(nu, 8)
if dp == null || ndp == null || seen == null || cycle == null || vals == null { return 1 }
dp[index[1]] = 1
let mut cur: ptr<i64> = dp
let mut nxt: ptr<i64> = ndp
let mut pi: i64 = 0
while pi < pc {
let p: i64 = primes[pi]
if p != 2 {
if p != 5 {
let terms: i64 = expo(N, p) + 1
let mult: i64 = p % modulus
i = 0
while i < nu {
seen[i] = 0
nxt[i] = 0
i = i + 1
}
let mut start: i64 = 0
while start < nu {
if seen[start] == 0 {
let mut len: i64 = 0
let mut idx: i64 = start
while seen[idx] == 0 {
seen[idx] = 1
cycle[len] = idx
len = len + 1
idx = index[(units[idx] * mult) % modulus]
}
let full_turns: i64 = terms / len
let tail: i64 = terms % len
let mut sumv: i64 = 0
i = 0
while i < len {
vals[i] = cur[cycle[i]]
sumv = sumv + vals[i]
if sumv >= MOD { sumv = sumv - MOD }
i = i + 1
}
let full: i64 = ((full_turns % MOD) * sumv) % MOD
if tail == 0 {
i = 0
while i < len {
nxt[cycle[i]] = full
i = i + 1
}
} else {
let mut window: i64 = 0
let mut j: i64 = 0
while j < tail {
let mut ix: i64 = (0 - j) % len
if ix < 0 { ix = ix + len }
window = window + vals[ix]
if window >= MOD { window = window - MOD }
j = j + 1
}
i = 0
while i < len {
nxt[cycle[i]] = (full + window) % MOD
window = window + vals[(i + 1) % len]
let mut subix: i64 = (i + 1 - tail) % len
if subix < 0 { subix = subix + len }
window = window - vals[subix]
window = window % MOD
if window < 0 { window = window + MOD }
i = i + 1
}
}
}
start = start + 1
}
let tmp: ptr<i64> = cur
cur = nxt
nxt = tmp
}
}
pi = pi + 1
}
printf("%lld\n", cur[index[target % modulus]])
free(vals)
free(cycle)
free(seen)
free(ndp)
free(dp)
free(primes)
free(index)
free(units)
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 expo_i64_i64(int64_t n0, int64_t p);
int32_t main(void);
static const int64_t MOD = 10000000000000061;
static const int64_t N = 1000000;
static const int64_t D = 65432;
static const int64_t POW10 = 100000;
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 expo_i64_i64(int64_t n0, int64_t p) {
int64_t n = n0;
int64_t v = 0;
while (n > 0) {
n = FLOW_CHECKED_DIV((n), (p));
v = (v + n);
}
return v;
}
int32_t main(void) {
int64_t dd = D;
int64_t alpha = 0;
int64_t beta = 0;
while (FLOW_CHECKED_MOD((dd), (2)) == 0) {
dd = FLOW_CHECKED_DIV((dd), (2));
alpha = (alpha + 1);
}
while (FLOW_CHECKED_MOD((dd), (5)) == 0) {
dd = FLOW_CHECKED_DIV((dd), (5));
beta = (beta + 1);
}
int64_t fixed = 1;
int64_t i = 0;
while (i < alpha) {
fixed = (fixed * 2);
i = (i + 1);
}
i = 0;
while (i < beta) {
fixed = (fixed * 5);
i = (i + 1);
}
int64_t modulus = FLOW_CHECKED_DIV((POW10), (fixed));
int64_t target = FLOW_CHECKED_DIV((D), (fixed));
if (gcd_i64_i64(target, modulus) != 1) {
printf("%lld\n", 0);
return 0;
}
int64_t* units = (int64_t*)(calloc(modulus, 8));
int64_t* index = (int64_t*)(calloc(modulus, 8));
if ((units == NULL || index == NULL)) {
return 1;
}
i = 0;
while (i < modulus) {
index[i] = (-1);
i = (i + 1);
}
int64_t nu = 0;
int64_t r = 1;
while (r < modulus) {
if (gcd_i64_i64(r, modulus) == 1) {
units[nu] = r;
index[r] = nu;
nu = (nu + 1);
}
r = (r + 1);
}
int8_t* sieve = (int8_t*)(calloc((N + 1), 1));
if (sieve == NULL) {
return 1;
}
i = 0;
while (i <= N) {
sieve[i] = 1;
i = (i + 1);
}
sieve[0] = 0;
sieve[1] = 0;
i = 2;
while ((i * i) <= N) {
if (sieve[i] != 0) {
int64_t j = (i * i);
while (j <= N) {
sieve[j] = 0;
j = (j + i);
}
}
i = (i + 1);
}
int64_t* primes = (int64_t*)(calloc((FLOW_CHECKED_DIV((N), (5)) + 10), 8));
if (primes == NULL) {
return 1;
}
int64_t pc = 0;
i = 2;
while (i <= N) {
if (sieve[i] != 0) {
primes[pc] = i;
pc = (pc + 1);
}
i = (i + 1);
}
free(sieve);
int64_t* dp = (int64_t*)(calloc(nu, 8));
int64_t* ndp = (int64_t*)(calloc(nu, 8));
int8_t* seen = (int8_t*)(calloc(nu, 1));
int64_t* cycle = (int64_t*)(calloc(nu, 8));
int64_t* vals = (int64_t*)(calloc(nu, 8));
if (((((dp == NULL || ndp == NULL) || seen == NULL) || cycle == NULL) || vals == NULL)) {
return 1;
}
dp[index[1]] = 1;
int64_t* cur = (int64_t*)(dp);
int64_t* nxt = (int64_t*)(ndp);
int64_t pi = 0;
while (pi < pc) {
int64_t p = primes[pi];
if (p != 2) {
if (p != 5) {
int64_t terms = (expo_i64_i64(N, p) + 1);
int64_t mult = FLOW_CHECKED_MOD((p), (modulus));
i = 0;
while (i < nu) {
seen[i] = 0;
nxt[i] = 0;
i = (i + 1);
}
int64_t start = 0;
while (start < nu) {
if (seen[start] == 0) {
int64_t len = 0;
int64_t idx = start;
while (seen[idx] == 0) {
seen[idx] = 1;
cycle[len] = idx;
len = (len + 1);
idx = index[FLOW_CHECKED_MOD(((units[idx] * mult)), (modulus))];
}
int64_t full_turns = FLOW_CHECKED_DIV((terms), (len));
int64_t tail = FLOW_CHECKED_MOD((terms), (len));
int64_t sumv = 0;
i = 0;
while (i < len) {
vals[i] = cur[cycle[i]];
sumv = (sumv + vals[i]);
if (sumv >= MOD) {
sumv = (sumv - MOD);
}
i = (i + 1);
}
int64_t full = FLOW_CHECKED_MOD(((FLOW_CHECKED_MOD((full_turns), (MOD)) * sumv)), (MOD));
if (tail == 0) {
i = 0;
while (i < len) {
nxt[cycle[i]] = full;
i = (i + 1);
}
} else {
int64_t window = 0;
int64_t j = 0;
while (j < tail) {
int64_t ix = FLOW_CHECKED_MOD(((0 - j)), (len));
if (ix < 0) {
ix = (ix + len);
}
window = (window + vals[ix]);
if (window >= MOD) {
window = (window - MOD);
}
j = (j + 1);
}
i = 0;
while (i < len) {
nxt[cycle[i]] = FLOW_CHECKED_MOD(((full + window)), (MOD));
window = (window + vals[FLOW_CHECKED_MOD(((i + 1)), (len))]);
int64_t subix = FLOW_CHECKED_MOD((((i + 1) - tail)), (len));
if (subix < 0) {
subix = (subix + len);
}
window = (window - vals[subix]);
window = FLOW_CHECKED_MOD((window), (MOD));
if (window < 0) {
window = (window + MOD);
}
i = (i + 1);
}
}
}
start = (start + 1);
}
int64_t* tmp = (int64_t*)(cur);
cur = nxt;
nxt = tmp;
}
}
pi = (pi + 1);
}
printf("%lld\n", cur[index[FLOW_CHECKED_MOD((target), (modulus))]]);
free(vals);
free(cycle);
free(seen);
free(ndp);
free(dp);
free(primes);
free(index);
free(units);
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(10000000000000061 : i64) : i64
// Constant: N
llvm.mlir.global internal constant @N(1000000 : i64) : i64
// Constant: D
llvm.mlir.global internal constant @D(65432 : i64) : i64
// Constant: POW10
llvm.mlir.global internal constant @POW10(100000 : i64) : i64
func.func @expo(%arg0: i64, %arg1: i64) -> i64 {
%175 = llvm.mlir.constant(1 : i64) : i64
%176 = llvm.alloca %175 x i64 : (i64) -> !llvm.ptr
llvm.store %arg0, %176 : i64, !llvm.ptr
%177 = arith.constant 0 : i32
%178 = arith.extsi %177 : i32 to i64
%179 = llvm.mlir.constant(1 : i64) : i64
%180 = llvm.alloca %179 x i64 : (i64) -> !llvm.ptr
llvm.store %178, %180 : i64, !llvm.ptr
cf.br ^bb42
^bb42:
%181 = llvm.load %176 : !llvm.ptr -> i64
%182 = arith.constant 0 : i32
%184 = arith.extsi %182 : i32 to i64
%183 = arith.cmpi sgt, %181, %184 : i64
cf.cond_br %183, ^bb43, ^bb44
^bb43:
%185 = llvm.load %176 : !llvm.ptr -> i64
%186 = arith.divsi %185, %arg1 : i64
llvm.store %186, %176 : i64, !llvm.ptr
%187 = llvm.load %180 : !llvm.ptr -> i64
%188 = llvm.load %176 : !llvm.ptr -> i64
%189 = arith.addi %187, %188 : i64
llvm.store %189, %180 : i64, !llvm.ptr
cf.br ^bb42
^bb44:
%190 = llvm.load %180 : !llvm.ptr -> i64
func.return %190 : i64
}
func.func @main() -> i32 {
%191 = llvm.mlir.addressof @D : !llvm.ptr
%192 = llvm.load %191 : !llvm.ptr -> i64
%193 = llvm.mlir.constant(1 : i64) : i64
%194 = llvm.alloca %193 x i64 : (i64) -> !llvm.ptr
llvm.store %192, %194 : i64, !llvm.ptr
%195 = arith.constant 0 : i32
%196 = arith.extsi %195 : i32 to i64
%197 = llvm.mlir.constant(1 : i64) : i64
%198 = llvm.alloca %197 x i64 : (i64) -> !llvm.ptr
llvm.store %196, %198 : i64, !llvm.ptr
%199 = arith.constant 0 : i32
%200 = arith.extsi %199 : i32 to i64
%201 = llvm.mlir.constant(1 : i64) : i64
%202 = llvm.alloca %201 x i64 : (i64) -> !llvm.ptr
llvm.store %200, %202 : i64, !llvm.ptr
cf.br ^bb45
^bb45:
%203 = llvm.load %194 : !llvm.ptr -> i64
%204 = arith.constant 2 : i32
%206 = arith.extsi %204 : i32 to i64
%205 = arith.remsi %203, %206 : i64
%207 = arith.constant 0 : i32
%209 = arith.extsi %207 : i32 to i64
%208 = arith.cmpi eq, %205, %209 : i64
cf.cond_br %208, ^bb46, ^bb47
^bb46:
%210 = llvm.load %194 : !llvm.ptr -> i64
%211 = arith.constant 2 : i32
%213 = arith.extsi %211 : i32 to i64
%212 = arith.divsi %210, %213 : i64
llvm.store %212, %194 : i64, !llvm.ptr
%214 = llvm.load %198 : !llvm.ptr -> i64
%215 = arith.constant 1 : i32
%217 = arith.extsi %215 : i32 to i64
%216 = arith.addi %214, %217 : i64
llvm.store %216, %198 : i64, !llvm.ptr
cf.br ^bb45
^bb47:
cf.br ^bb48
^bb48:
%218 = llvm.load %194 : !llvm.ptr -> i64
%219 = arith.constant 5 : i32
%221 = arith.extsi %219 : i32 to i64
%220 = arith.remsi %218, %221 : i64
%222 = arith.constant 0 : i32
%224 = arith.extsi %222 : i32 to i64
%223 = arith.cmpi eq, %220, %224 : i64
cf.cond_br %223, ^bb49, ^bb50
^bb49:
%225 = llvm.load %194 : !llvm.ptr -> i64
%226 = arith.constant 5 : i32
%228 = arith.extsi %226 : i32 to i64
%227 = arith.divsi %225, %228 : i64
llvm.store %227, %194 : i64, !llvm.ptr
%229 = llvm.load %202 : !llvm.ptr -> i64
%230 = arith.constant 1 : i32
%232 = arith.extsi %230 : i32 to i64
%231 = arith.addi %229, %232 : i64
llvm.store %231, %202 : i64, !llvm.ptr
cf.br ^bb48
^bb50:
%233 = arith.constant 1 : i32
%234 = arith.extsi %233 : i32 to i64
%235 = llvm.mlir.constant(1 : i64) : i64
%236 = llvm.alloca %235 x i64 : (i64) -> !llvm.ptr
llvm.store %234, %236 : i64, !llvm.ptr
%237 = arith.constant 0 : i32
%238 = arith.extsi %237 : i32 to i64
%239 = llvm.mlir.constant(1 : i64) : i64
%240 = llvm.alloca %239 x i64 : (i64) -> !llvm.ptr
llvm.store %238, %240 : i64, !llvm.ptr
cf.br ^bb51
^bb51:
%241 = llvm.load %240 : !llvm.ptr -> i64
%242 = llvm.load %198 : !llvm.ptr -> i64
%243 = arith.cmpi slt, %241, %242 : i64
cf.cond_br %243, ^bb52, ^bb53
^bb52:
%244 = llvm.load %236 : !llvm.ptr -> i64
%245 = arith.constant 2 : i32
%247 = arith.extsi %245 : i32 to i64
%246 = arith.muli %244, %247 : i64
llvm.store %246, %236 : i64, !llvm.ptr
%248 = llvm.load %240 : !llvm.ptr -> i64
%249 = arith.constant 1 : i32
%251 = arith.extsi %249 : i32 to i64
%250 = arith.addi %248, %251 : i64
llvm.store %250, %240 : i64, !llvm.ptr
cf.br ^bb51
^bb53:
%252 = arith.constant 0 : i32
%253 = arith.extsi %252 : i32 to i64
llvm.store %253, %240 : i64, !llvm.ptr
cf.br ^bb54
^bb54:
%254 = llvm.load %240 : !llvm.ptr -> i64
%255 = llvm.load %202 : !llvm.ptr -> i64
%256 = arith.cmpi slt, %254, %255 : i64
cf.cond_br %256, ^bb55, ^bb56
^bb55:
%257 = llvm.load %236 : !llvm.ptr -> i64
%258 = arith.constant 5 : i32
%260 = arith.extsi %258 : i32 to i64
%259 = arith.muli %257, %260 : i64
llvm.store %259, %236 : i64, !llvm.ptr
%261 = llvm.load %240 : !llvm.ptr -> i64
%262 = arith.constant 1 : i32
%264 = arith.extsi %262 : i32 to i64
%263 = arith.addi %261, %264 : i64
llvm.store %263, %240 : i64, !llvm.ptr
cf.br ^bb54
^bb56:
%265 = llvm.mlir.addressof @POW10 : !llvm.ptr
%266 = llvm.load %265 : !llvm.ptr -> i64
%267 = llvm.load %236 : !llvm.ptr -> i64
%268 = arith.divsi %266, %267 : i64
%269 = llvm.mlir.addressof @D : !llvm.ptr
%270 = llvm.load %269 : !llvm.ptr -> i64
%271 = llvm.load %236 : !llvm.ptr -> i64
%272 = arith.divsi %270, %271 : i64
%273 = func.call @gcd(%272, %268) : (i64, i64) -> i64
%274 = arith.constant 1 : i32
%276 = arith.extsi %274 : i32 to i64
%275 = arith.cmpi ne, %273, %276 : i64
cf.cond_br %275, ^bb57, ^bb58
^bb57:
%277 = llvm.mlir.addressof @str_0 : !llvm.ptr
%278 = arith.constant 0 : i32
%279 = llvm.call @printf(%277, %278) vararg(!llvm.func<i32 (ptr, ...)>) : (!llvm.ptr, i32) -> i32
%280 = arith.constant 0 : i32
func.return %280 : i32
^bb58:
cf.br ^bb59
^bb59:
%282 = arith.constant 8 : i32
%283 = arith.extsi %282 : i32 to i64
%281 = func.call @calloc(%268, %283) : (i64, i64) -> !llvm.ptr
%285 = arith.constant 8 : i32
%286 = arith.extsi %285 : i32 to i64
%284 = func.call @calloc(%268, %286) : (i64, i64) -> !llvm.ptr
%287 = llvm.mlir.zero : !llvm.ptr
%288 = llvm.icmp "eq" %281, %287 : !llvm.ptr
%289 = scf.if %288 -> (i1) {
%290 = arith.constant true
scf.yield %290 : i1
} else {
%291 = llvm.mlir.zero : !llvm.ptr
%292 = llvm.icmp "eq" %284, %291 : !llvm.ptr
scf.yield %292 : i1
}
cf.cond_br %289, ^bb60, ^bb61
^bb60:
%293 = arith.constant 1 : i32
func.return %293 : i32
^bb61:
cf.br ^bb62
^bb62:
%294 = arith.constant 0 : i32
%295 = arith.extsi %294 : i32 to i64
llvm.store %295, %240 : i64, !llvm.ptr
cf.br ^bb63
^bb63:
%296 = llvm.load %240 : !llvm.ptr -> i64
%297 = arith.cmpi slt, %296, %268 : i64
cf.cond_br %297, ^bb64, ^bb65
^bb64:
%298 = arith.constant 1 : i32
%300 = arith.constant 0 : i32
%299 = arith.subi %300, %298 : i32
%301 = llvm.load %240 : !llvm.ptr -> i64
%302 = arith.extsi %299 : i32 to i64
%303 = llvm.getelementptr %284[%301] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %302, %303 : i64, !llvm.ptr
%304 = llvm.load %240 : !llvm.ptr -> i64
%305 = arith.constant 1 : i32
%307 = arith.extsi %305 : i32 to i64
%306 = arith.addi %304, %307 : i64
llvm.store %306, %240 : i64, !llvm.ptr
cf.br ^bb63
^bb65:
%308 = arith.constant 0 : i32
%309 = arith.extsi %308 : i32 to i64
%310 = llvm.mlir.constant(1 : i64) : i64
%311 = llvm.alloca %310 x i64 : (i64) -> !llvm.ptr
llvm.store %309, %311 : i64, !llvm.ptr
%312 = arith.constant 1 : i32
%313 = arith.extsi %312 : i32 to i64
%314 = llvm.mlir.constant(1 : i64) : i64
%315 = llvm.alloca %314 x i64 : (i64) -> !llvm.ptr
llvm.store %313, %315 : i64, !llvm.ptr
cf.br ^bb66
^bb66:
%316 = llvm.load %315 : !llvm.ptr -> i64
%317 = arith.cmpi slt, %316, %268 : i64
cf.cond_br %317, ^bb67, ^bb68
^bb67:
%319 = llvm.load %315 : !llvm.ptr -> i64
%318 = func.call @gcd(%319, %268) : (i64, i64) -> i64
%320 = arith.constant 1 : i32
%322 = arith.extsi %320 : i32 to i64
%321 = arith.cmpi eq, %318, %322 : i64
cf.cond_br %321, ^bb69, ^bb70
^bb69:
%323 = llvm.load %315 : !llvm.ptr -> i64
%324 = llvm.load %311 : !llvm.ptr -> i64
%325 = llvm.getelementptr %281[%324] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %323, %325 : i64, !llvm.ptr
%326 = llvm.load %311 : !llvm.ptr -> i64
%327 = llvm.load %315 : !llvm.ptr -> i64
%328 = llvm.getelementptr %284[%327] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %326, %328 : i64, !llvm.ptr
%329 = llvm.load %311 : !llvm.ptr -> i64
%330 = arith.constant 1 : i32
%332 = arith.extsi %330 : i32 to i64
%331 = arith.addi %329, %332 : i64
llvm.store %331, %311 : i64, !llvm.ptr
cf.br ^bb71
^bb70:
cf.br ^bb71
^bb71:
%333 = llvm.load %315 : !llvm.ptr -> i64
%334 = arith.constant 1 : i32
%336 = arith.extsi %334 : i32 to i64
%335 = arith.addi %333, %336 : i64
llvm.store %335, %315 : i64, !llvm.ptr
cf.br ^bb66
^bb68:
%338 = llvm.mlir.addressof @N : !llvm.ptr
%339 = llvm.load %338 : !llvm.ptr -> i64
%340 = arith.constant 1 : i32
%342 = arith.extsi %340 : i32 to i64
%341 = arith.addi %339, %342 : i64
%343 = arith.constant 1 : i32
%344 = arith.extsi %343 : i32 to i64
%337 = func.call @calloc(%341, %344) : (i64, i64) -> !llvm.ptr
%345 = llvm.mlir.zero : !llvm.ptr
%346 = llvm.icmp "eq" %337, %345 : !llvm.ptr
cf.cond_br %346, ^bb72, ^bb73
^bb72:
%347 = arith.constant 1 : i32
func.return %347 : i32
^bb73:
cf.br ^bb74
^bb74:
%348 = arith.constant 0 : i32
%349 = arith.extsi %348 : i32 to i64
llvm.store %349, %240 : i64, !llvm.ptr
cf.br ^bb75
^bb75:
%350 = llvm.load %240 : !llvm.ptr -> i64
%351 = llvm.mlir.addressof @N : !llvm.ptr
%352 = llvm.load %351 : !llvm.ptr -> i64
%353 = arith.cmpi sle, %350, %352 : i64
cf.cond_br %353, ^bb76, ^bb77
^bb76:
%354 = arith.constant 1 : i32
%355 = llvm.load %240 : !llvm.ptr -> i64
%356 = arith.trunci %354 : i32 to i8
%357 = llvm.getelementptr %337[%355] : (!llvm.ptr, i64) -> !llvm.ptr, i8
llvm.store %356, %357 : i8, !llvm.ptr
%358 = llvm.load %240 : !llvm.ptr -> i64
%359 = arith.constant 1 : i32
%361 = arith.extsi %359 : i32 to i64
%360 = arith.addi %358, %361 : i64
llvm.store %360, %240 : i64, !llvm.ptr
cf.br ^bb75
^bb77:
%362 = arith.constant 0 : i32
%363 = arith.constant 0 : i32
%364 = arith.trunci %362 : i32 to i8
%365 = arith.extsi %363 : i32 to i64
%366 = llvm.getelementptr %337[%365] : (!llvm.ptr, i64) -> !llvm.ptr, i8
llvm.store %364, %366 : i8, !llvm.ptr
%367 = arith.constant 0 : i32
%368 = arith.constant 1 : i32
%369 = arith.trunci %367 : i32 to i8
%370 = arith.extsi %368 : i32 to i64
%371 = llvm.getelementptr %337[%370] : (!llvm.ptr, i64) -> !llvm.ptr, i8
llvm.store %369, %371 : i8, !llvm.ptr
%372 = arith.constant 2 : i32
%373 = arith.extsi %372 : i32 to i64
llvm.store %373, %240 : i64, !llvm.ptr
cf.br ^bb78
^bb78:
%374 = llvm.load %240 : !llvm.ptr -> i64
%375 = llvm.load %240 : !llvm.ptr -> i64
%376 = arith.muli %374, %375 : i64
%377 = llvm.mlir.addressof @N : !llvm.ptr
%378 = llvm.load %377 : !llvm.ptr -> i64
%379 = arith.cmpi sle, %376, %378 : i64
cf.cond_br %379, ^bb79, ^bb80
^bb79:
%381 = llvm.load %240 : !llvm.ptr -> i64
%382 = llvm.getelementptr %337[%381] : (!llvm.ptr, i64) -> !llvm.ptr, i8
%380 = llvm.load %382 : !llvm.ptr -> i8
%383 = arith.constant 0 : i32
%385 = arith.extsi %380 : i8 to i32
%384 = arith.cmpi ne, %385, %383 : i32
cf.cond_br %384, ^bb81, ^bb82
^bb81:
%386 = llvm.load %240 : !llvm.ptr -> i64
%387 = llvm.load %240 : !llvm.ptr -> i64
%388 = arith.muli %386, %387 : i64
%389 = llvm.mlir.constant(1 : i64) : i64
%390 = llvm.alloca %389 x i64 : (i64) -> !llvm.ptr
llvm.store %388, %390 : i64, !llvm.ptr
cf.br ^bb84
^bb84:
%391 = llvm.load %390 : !llvm.ptr -> i64
%392 = llvm.mlir.addressof @N : !llvm.ptr
%393 = llvm.load %392 : !llvm.ptr -> i64
%394 = arith.cmpi sle, %391, %393 : i64
cf.cond_br %394, ^bb85, ^bb86
^bb85:
%395 = arith.constant 0 : i32
%396 = llvm.load %390 : !llvm.ptr -> i64
%397 = arith.trunci %395 : i32 to i8
%398 = llvm.getelementptr %337[%396] : (!llvm.ptr, i64) -> !llvm.ptr, i8
llvm.store %397, %398 : i8, !llvm.ptr
%399 = llvm.load %390 : !llvm.ptr -> i64
%400 = llvm.load %240 : !llvm.ptr -> i64
%401 = arith.addi %399, %400 : i64
llvm.store %401, %390 : i64, !llvm.ptr
cf.br ^bb84
^bb86:
cf.br ^bb83
^bb82:
cf.br ^bb83
^bb83:
%402 = llvm.load %240 : !llvm.ptr -> i64
%403 = arith.constant 1 : i32
%405 = arith.extsi %403 : i32 to i64
%404 = arith.addi %402, %405 : i64
llvm.store %404, %240 : i64, !llvm.ptr
cf.br ^bb78
^bb80:
%407 = llvm.mlir.addressof @N : !llvm.ptr
%408 = llvm.load %407 : !llvm.ptr -> i64
%409 = arith.constant 5 : i32
%411 = arith.extsi %409 : i32 to i64
%410 = arith.divsi %408, %411 : i64
%412 = arith.constant 10 : i32
%414 = arith.extsi %412 : i32 to i64
%413 = arith.addi %410, %414 : i64
%415 = arith.constant 8 : i32
%416 = arith.extsi %415 : i32 to i64
%406 = func.call @calloc(%413, %416) : (i64, i64) -> !llvm.ptr
%417 = llvm.mlir.zero : !llvm.ptr
%418 = llvm.icmp "eq" %406, %417 : !llvm.ptr
cf.cond_br %418, ^bb87, ^bb88
^bb87:
%419 = arith.constant 1 : i32
func.return %419 : i32
^bb88:
cf.br ^bb89
^bb89:
%420 = arith.constant 0 : i32
%421 = arith.extsi %420 : i32 to i64
%422 = llvm.mlir.constant(1 : i64) : i64
%423 = llvm.alloca %422 x i64 : (i64) -> !llvm.ptr
llvm.store %421, %423 : i64, !llvm.ptr
%424 = arith.constant 2 : i32
%425 = arith.extsi %424 : i32 to i64
llvm.store %425, %240 : i64, !llvm.ptr
cf.br ^bb90
^bb90:
%426 = llvm.load %240 : !llvm.ptr -> i64
%427 = llvm.mlir.addressof @N : !llvm.ptr
%428 = llvm.load %427 : !llvm.ptr -> i64
%429 = arith.cmpi sle, %426, %428 : i64
cf.cond_br %429, ^bb91, ^bb92
^bb91:
%431 = llvm.load %240 : !llvm.ptr -> i64
%432 = llvm.getelementptr %337[%431] : (!llvm.ptr, i64) -> !llvm.ptr, i8
%430 = llvm.load %432 : !llvm.ptr -> i8
%433 = arith.constant 0 : i32
%435 = arith.extsi %430 : i8 to i32
%434 = arith.cmpi ne, %435, %433 : i32
cf.cond_br %434, ^bb93, ^bb94
^bb93:
%436 = llvm.load %240 : !llvm.ptr -> i64
%437 = llvm.load %423 : !llvm.ptr -> i64
%438 = llvm.getelementptr %406[%437] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %436, %438 : i64, !llvm.ptr
%439 = llvm.load %423 : !llvm.ptr -> i64
%440 = arith.constant 1 : i32
%442 = arith.extsi %440 : i32 to i64
%441 = arith.addi %439, %442 : i64
llvm.store %441, %423 : i64, !llvm.ptr
cf.br ^bb95
^bb94:
cf.br ^bb95
^bb95:
%443 = llvm.load %240 : !llvm.ptr -> i64
%444 = arith.constant 1 : i32
%446 = arith.extsi %444 : i32 to i64
%445 = arith.addi %443, %446 : i64
llvm.store %445, %240 : i64, !llvm.ptr
cf.br ^bb90
^bb92:
func.call @free(%337) : (!llvm.ptr) -> ()
%449 = llvm.load %311 : !llvm.ptr -> i64
%450 = arith.constant 8 : i32
%451 = arith.extsi %450 : i32 to i64
%448 = func.call @calloc(%449, %451) : (i64, i64) -> !llvm.ptr
%453 = llvm.load %311 : !llvm.ptr -> i64
%454 = arith.constant 8 : i32
%455 = arith.extsi %454 : i32 to i64
%452 = func.call @calloc(%453, %455) : (i64, i64) -> !llvm.ptr
%457 = llvm.load %311 : !llvm.ptr -> i64
%458 = arith.constant 1 : i32
%459 = arith.extsi %458 : i32 to i64
%456 = func.call @calloc(%457, %459) : (i64, i64) -> !llvm.ptr
%461 = llvm.load %311 : !llvm.ptr -> i64
%462 = arith.constant 8 : i32
%463 = arith.extsi %462 : i32 to i64
%460 = func.call @calloc(%461, %463) : (i64, i64) -> !llvm.ptr
%465 = llvm.load %311 : !llvm.ptr -> i64
%466 = arith.constant 8 : i32
%467 = arith.extsi %466 : i32 to i64
%464 = func.call @calloc(%465, %467) : (i64, i64) -> !llvm.ptr
%468 = llvm.mlir.zero : !llvm.ptr
%469 = llvm.icmp "eq" %448, %468 : !llvm.ptr
%470 = scf.if %469 -> (i1) {
%471 = arith.constant true
scf.yield %471 : i1
} else {
%472 = llvm.mlir.zero : !llvm.ptr
%473 = llvm.icmp "eq" %452, %472 : !llvm.ptr
scf.yield %473 : i1
}
%474 = scf.if %470 -> (i1) {
%475 = arith.constant true
scf.yield %475 : i1
} else {
%476 = llvm.mlir.zero : !llvm.ptr
%477 = llvm.icmp "eq" %456, %476 : !llvm.ptr
scf.yield %477 : i1
}
%478 = scf.if %474 -> (i1) {
%479 = arith.constant true
scf.yield %479 : i1
} else {
%480 = llvm.mlir.zero : !llvm.ptr
%481 = llvm.icmp "eq" %460, %480 : !llvm.ptr
scf.yield %481 : i1
}
%482 = scf.if %478 -> (i1) {
%483 = arith.constant true
scf.yield %483 : i1
} else {
%484 = llvm.mlir.zero : !llvm.ptr
%485 = llvm.icmp "eq" %464, %484 : !llvm.ptr
scf.yield %485 : i1
}
cf.cond_br %482, ^bb96, ^bb97
^bb96:
%486 = arith.constant 1 : i32
func.return %486 : i32
^bb97:
cf.br ^bb98
^bb98:
%487 = arith.constant 1 : i32
%489 = arith.constant 1 : i32
%490 = arith.extsi %489 : i32 to i64
%491 = llvm.getelementptr %284[%490] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%488 = llvm.load %491 : !llvm.ptr -> i64
%492 = arith.extsi %487 : i32 to i64
%493 = llvm.getelementptr %448[%488] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %492, %493 : i64, !llvm.ptr
%494 = llvm.mlir.constant(1 : i64) : i64
%495 = llvm.alloca %494 x !llvm.ptr : (i64) -> !llvm.ptr
llvm.store %448, %495 : !llvm.ptr, !llvm.ptr
%496 = llvm.mlir.constant(1 : i64) : i64
%497 = llvm.alloca %496 x !llvm.ptr : (i64) -> !llvm.ptr
llvm.store %452, %497 : !llvm.ptr, !llvm.ptr
%498 = arith.constant 0 : i32
%499 = arith.extsi %498 : i32 to i64
%500 = llvm.mlir.constant(1 : i64) : i64
%501 = llvm.alloca %500 x i64 : (i64) -> !llvm.ptr
llvm.store %499, %501 : i64, !llvm.ptr
cf.br ^bb99
^bb99:
%502 = llvm.load %501 : !llvm.ptr -> i64
%503 = llvm.load %423 : !llvm.ptr -> i64
%504 = arith.cmpi slt, %502, %503 : i64
cf.cond_br %504, ^bb100, ^bb101
^bb100:
%506 = llvm.load %501 : !llvm.ptr -> i64
%507 = llvm.getelementptr %406[%506] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%505 = llvm.load %507 : !llvm.ptr -> i64
%508 = arith.constant 2 : i32
%510 = arith.extsi %508 : i32 to i64
%509 = arith.cmpi ne, %505, %510 : i64
cf.cond_br %509, ^bb102, ^bb103
^bb102:
%511 = arith.constant 5 : i32
%513 = arith.extsi %511 : i32 to i64
%512 = arith.cmpi ne, %505, %513 : i64
cf.cond_br %512, ^bb105, ^bb106
^bb105:
%515 = llvm.mlir.addressof @N : !llvm.ptr
%516 = llvm.load %515 : !llvm.ptr -> i64
%514 = func.call @expo(%516, %505) : (i64, i64) -> i64
%517 = arith.constant 1 : i32
%519 = arith.extsi %517 : i32 to i64
%518 = arith.addi %514, %519 : i64
%520 = arith.remsi %505, %268 : i64
%521 = arith.constant 0 : i32
%522 = arith.extsi %521 : i32 to i64
llvm.store %522, %240 : i64, !llvm.ptr
cf.br ^bb108
^bb108:
%523 = llvm.load %240 : !llvm.ptr -> i64
%524 = llvm.load %311 : !llvm.ptr -> i64
%525 = arith.cmpi slt, %523, %524 : i64
cf.cond_br %525, ^bb109, ^bb110
^bb109:
%526 = arith.constant 0 : i32
%527 = llvm.load %240 : !llvm.ptr -> i64
%528 = arith.trunci %526 : i32 to i8
%529 = llvm.getelementptr %456[%527] : (!llvm.ptr, i64) -> !llvm.ptr, i8
llvm.store %528, %529 : i8, !llvm.ptr
%530 = arith.constant 0 : i32
%531 = llvm.load %497 : !llvm.ptr -> !llvm.ptr
%532 = llvm.load %240 : !llvm.ptr -> i64
%533 = arith.extsi %530 : i32 to i64
%534 = llvm.getelementptr %531[%532] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %533, %534 : i64, !llvm.ptr
%535 = llvm.load %240 : !llvm.ptr -> i64
%536 = arith.constant 1 : i32
%538 = arith.extsi %536 : i32 to i64
%537 = arith.addi %535, %538 : i64
llvm.store %537, %240 : i64, !llvm.ptr
cf.br ^bb108
^bb110:
%539 = arith.constant 0 : i32
%540 = arith.extsi %539 : i32 to i64
%541 = llvm.mlir.constant(1 : i64) : i64
%542 = llvm.alloca %541 x i64 : (i64) -> !llvm.ptr
llvm.store %540, %542 : i64, !llvm.ptr
cf.br ^bb111
^bb111:
%543 = llvm.load %542 : !llvm.ptr -> i64
%544 = llvm.load %311 : !llvm.ptr -> i64
%545 = arith.cmpi slt, %543, %544 : i64
cf.cond_br %545, ^bb112, ^bb113
^bb112:
%547 = llvm.load %542 : !llvm.ptr -> i64
%548 = llvm.getelementptr %456[%547] : (!llvm.ptr, i64) -> !llvm.ptr, i8
%546 = llvm.load %548 : !llvm.ptr -> i8
%549 = arith.constant 0 : i32
%551 = arith.extsi %546 : i8 to i32
%550 = arith.cmpi eq, %551, %549 : i32
cf.cond_br %550, ^bb114, ^bb115
^bb114:
%552 = arith.constant 0 : i32
%553 = arith.extsi %552 : i32 to i64
%554 = llvm.mlir.constant(1 : i64) : i64
%555 = llvm.alloca %554 x i64 : (i64) -> !llvm.ptr
llvm.store %553, %555 : i64, !llvm.ptr
%556 = llvm.load %542 : !llvm.ptr -> i64
%557 = llvm.mlir.constant(1 : i64) : i64
%558 = llvm.alloca %557 x i64 : (i64) -> !llvm.ptr
llvm.store %556, %558 : i64, !llvm.ptr
cf.br ^bb117
^bb117:
%560 = llvm.load %558 : !llvm.ptr -> i64
%561 = llvm.getelementptr %456[%560] : (!llvm.ptr, i64) -> !llvm.ptr, i8
%559 = llvm.load %561 : !llvm.ptr -> i8
%562 = arith.constant 0 : i32
%564 = arith.extsi %559 : i8 to i32
%563 = arith.cmpi eq, %564, %562 : i32
cf.cond_br %563, ^bb118, ^bb119
^bb118:
%565 = arith.constant 1 : i32
%566 = llvm.load %558 : !llvm.ptr -> i64
%567 = arith.trunci %565 : i32 to i8
%568 = llvm.getelementptr %456[%566] : (!llvm.ptr, i64) -> !llvm.ptr, i8
llvm.store %567, %568 : i8, !llvm.ptr
%569 = llvm.load %558 : !llvm.ptr -> i64
%570 = llvm.load %555 : !llvm.ptr -> i64
%571 = llvm.getelementptr %460[%570] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %569, %571 : i64, !llvm.ptr
%572 = llvm.load %555 : !llvm.ptr -> i64
%573 = arith.constant 1 : i32
%575 = arith.extsi %573 : i32 to i64
%574 = arith.addi %572, %575 : i64
llvm.store %574, %555 : i64, !llvm.ptr
%578 = llvm.load %558 : !llvm.ptr -> i64
%579 = llvm.getelementptr %281[%578] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%577 = llvm.load %579 : !llvm.ptr -> i64
%580 = arith.muli %577, %520 : i64
%581 = arith.remsi %580, %268 : i64
%582 = llvm.getelementptr %284[%581] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%576 = llvm.load %582 : !llvm.ptr -> i64
llvm.store %576, %558 : i64, !llvm.ptr
cf.br ^bb117
^bb119:
%583 = llvm.load %555 : !llvm.ptr -> i64
%584 = arith.divsi %518, %583 : i64
%585 = llvm.load %555 : !llvm.ptr -> i64
%586 = arith.remsi %518, %585 : i64
%587 = arith.constant 0 : i32
%588 = arith.extsi %587 : i32 to i64
%589 = llvm.mlir.constant(1 : i64) : i64
%590 = llvm.alloca %589 x i64 : (i64) -> !llvm.ptr
llvm.store %588, %590 : i64, !llvm.ptr
%591 = arith.constant 0 : i32
%592 = arith.extsi %591 : i32 to i64
llvm.store %592, %240 : i64, !llvm.ptr
cf.br ^bb120
^bb120:
%593 = llvm.load %240 : !llvm.ptr -> i64
%594 = llvm.load %555 : !llvm.ptr -> i64
%595 = arith.cmpi slt, %593, %594 : i64
cf.cond_br %595, ^bb121, ^bb122
^bb121:
%597 = llvm.load %495 : !llvm.ptr -> !llvm.ptr
%599 = llvm.load %240 : !llvm.ptr -> i64
%600 = llvm.getelementptr %460[%599] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%598 = llvm.load %600 : !llvm.ptr -> i64
%601 = llvm.getelementptr %597[%598] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%596 = llvm.load %601 : !llvm.ptr -> i64
%602 = llvm.load %240 : !llvm.ptr -> i64
%603 = llvm.getelementptr %464[%602] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %596, %603 : i64, !llvm.ptr
%604 = llvm.load %590 : !llvm.ptr -> i64
%606 = llvm.load %240 : !llvm.ptr -> i64
%607 = llvm.getelementptr %464[%606] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%605 = llvm.load %607 : !llvm.ptr -> i64
%608 = arith.addi %604, %605 : i64
llvm.store %608, %590 : i64, !llvm.ptr
%609 = llvm.load %590 : !llvm.ptr -> i64
%610 = llvm.mlir.addressof @MOD : !llvm.ptr
%611 = llvm.load %610 : !llvm.ptr -> i64
%612 = arith.cmpi sge, %609, %611 : i64
cf.cond_br %612, ^bb123, ^bb124
^bb123:
%613 = llvm.load %590 : !llvm.ptr -> i64
%614 = llvm.mlir.addressof @MOD : !llvm.ptr
%615 = llvm.load %614 : !llvm.ptr -> i64
%616 = arith.subi %613, %615 : i64
llvm.store %616, %590 : i64, !llvm.ptr
cf.br ^bb125
^bb124:
cf.br ^bb125
^bb125:
%617 = llvm.load %240 : !llvm.ptr -> i64
%618 = arith.constant 1 : i32
%620 = arith.extsi %618 : i32 to i64
%619 = arith.addi %617, %620 : i64
llvm.store %619, %240 : i64, !llvm.ptr
cf.br ^bb120
^bb122:
%621 = llvm.mlir.addressof @MOD : !llvm.ptr
%622 = llvm.load %621 : !llvm.ptr -> i64
%623 = arith.remsi %584, %622 : i64
%624 = llvm.load %590 : !llvm.ptr -> i64
%625 = arith.muli %623, %624 : i64
%626 = llvm.mlir.addressof @MOD : !llvm.ptr
%627 = llvm.load %626 : !llvm.ptr -> i64
%628 = arith.remsi %625, %627 : i64
%629 = arith.constant 0 : i32
%631 = arith.extsi %629 : i32 to i64
%630 = arith.cmpi eq, %586, %631 : i64
cf.cond_br %630, ^bb126, ^bb127
^bb126:
%632 = arith.constant 0 : i32
%633 = arith.extsi %632 : i32 to i64
llvm.store %633, %240 : i64, !llvm.ptr
cf.br ^bb129
^bb129:
%634 = llvm.load %240 : !llvm.ptr -> i64
%635 = llvm.load %555 : !llvm.ptr -> i64
%636 = arith.cmpi slt, %634, %635 : i64
cf.cond_br %636, ^bb130, ^bb131
^bb130:
%637 = llvm.load %497 : !llvm.ptr -> !llvm.ptr
%639 = llvm.load %240 : !llvm.ptr -> i64
%640 = llvm.getelementptr %460[%639] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%638 = llvm.load %640 : !llvm.ptr -> i64
%641 = llvm.getelementptr %637[%638] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %628, %641 : i64, !llvm.ptr
%642 = llvm.load %240 : !llvm.ptr -> i64
%643 = arith.constant 1 : i32
%645 = arith.extsi %643 : i32 to i64
%644 = arith.addi %642, %645 : i64
llvm.store %644, %240 : i64, !llvm.ptr
cf.br ^bb129
^bb131:
cf.br ^bb128
^bb127:
%646 = arith.constant 0 : i32
%647 = arith.extsi %646 : i32 to i64
%648 = llvm.mlir.constant(1 : i64) : i64
%649 = llvm.alloca %648 x i64 : (i64) -> !llvm.ptr
llvm.store %647, %649 : i64, !llvm.ptr
%650 = arith.constant 0 : i32
%651 = arith.extsi %650 : i32 to i64
%652 = llvm.mlir.constant(1 : i64) : i64
%653 = llvm.alloca %652 x i64 : (i64) -> !llvm.ptr
llvm.store %651, %653 : i64, !llvm.ptr
cf.br ^bb132
^bb132:
%654 = llvm.load %653 : !llvm.ptr -> i64
%655 = arith.cmpi slt, %654, %586 : i64
cf.cond_br %655, ^bb133, ^bb134
^bb133:
%656 = arith.constant 0 : i32
%657 = llvm.load %653 : !llvm.ptr -> i64
%659 = arith.extsi %656 : i32 to i64
%658 = arith.subi %659, %657 : i64
%660 = llvm.load %555 : !llvm.ptr -> i64
%661 = arith.remsi %658, %660 : i64
%662 = llvm.mlir.constant(1 : i64) : i64
%663 = llvm.alloca %662 x i64 : (i64) -> !llvm.ptr
llvm.store %661, %663 : i64, !llvm.ptr
%664 = llvm.load %663 : !llvm.ptr -> i64
%665 = arith.constant 0 : i32
%667 = arith.extsi %665 : i32 to i64
%666 = arith.cmpi slt, %664, %667 : i64
cf.cond_br %666, ^bb135, ^bb136
^bb135:
%668 = llvm.load %663 : !llvm.ptr -> i64
%669 = llvm.load %555 : !llvm.ptr -> i64
%670 = arith.addi %668, %669 : i64
llvm.store %670, %663 : i64, !llvm.ptr
cf.br ^bb137
^bb136:
cf.br ^bb137
^bb137:
%671 = llvm.load %649 : !llvm.ptr -> i64
%673 = llvm.load %663 : !llvm.ptr -> i64
%674 = llvm.getelementptr %464[%673] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%672 = llvm.load %674 : !llvm.ptr -> i64
%675 = arith.addi %671, %672 : i64
llvm.store %675, %649 : i64, !llvm.ptr
%676 = llvm.load %649 : !llvm.ptr -> i64
%677 = llvm.mlir.addressof @MOD : !llvm.ptr
%678 = llvm.load %677 : !llvm.ptr -> i64
%679 = arith.cmpi sge, %676, %678 : i64
cf.cond_br %679, ^bb138, ^bb139
^bb138:
%680 = llvm.load %649 : !llvm.ptr -> i64
%681 = llvm.mlir.addressof @MOD : !llvm.ptr
%682 = llvm.load %681 : !llvm.ptr -> i64
%683 = arith.subi %680, %682 : i64
llvm.store %683, %649 : i64, !llvm.ptr
cf.br ^bb140
^bb139:
cf.br ^bb140
^bb140:
%684 = llvm.load %653 : !llvm.ptr -> i64
%685 = arith.constant 1 : i32
%687 = arith.extsi %685 : i32 to i64
%686 = arith.addi %684, %687 : i64
llvm.store %686, %653 : i64, !llvm.ptr
cf.br ^bb132
^bb134:
%688 = arith.constant 0 : i32
%689 = arith.extsi %688 : i32 to i64
llvm.store %689, %240 : i64, !llvm.ptr
cf.br ^bb141
^bb141:
%690 = llvm.load %240 : !llvm.ptr -> i64
%691 = llvm.load %555 : !llvm.ptr -> i64
%692 = arith.cmpi slt, %690, %691 : i64
cf.cond_br %692, ^bb142, ^bb143
^bb142:
%693 = llvm.load %649 : !llvm.ptr -> i64
%694 = arith.addi %628, %693 : i64
%695 = llvm.mlir.addressof @MOD : !llvm.ptr
%696 = llvm.load %695 : !llvm.ptr -> i64
%697 = arith.remsi %694, %696 : i64
%698 = llvm.load %497 : !llvm.ptr -> !llvm.ptr
%700 = llvm.load %240 : !llvm.ptr -> i64
%701 = llvm.getelementptr %460[%700] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%699 = llvm.load %701 : !llvm.ptr -> i64
%702 = llvm.getelementptr %698[%699] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %697, %702 : i64, !llvm.ptr
%703 = llvm.load %649 : !llvm.ptr -> i64
%705 = llvm.load %240 : !llvm.ptr -> i64
%706 = arith.constant 1 : i32
%708 = arith.extsi %706 : i32 to i64
%707 = arith.addi %705, %708 : i64
%709 = llvm.load %555 : !llvm.ptr -> i64
%710 = arith.remsi %707, %709 : i64
%711 = llvm.getelementptr %464[%710] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%704 = llvm.load %711 : !llvm.ptr -> i64
%712 = arith.addi %703, %704 : i64
llvm.store %712, %649 : i64, !llvm.ptr
%713 = llvm.load %240 : !llvm.ptr -> i64
%714 = arith.constant 1 : i32
%716 = arith.extsi %714 : i32 to i64
%715 = arith.addi %713, %716 : i64
%717 = arith.subi %715, %586 : i64
%718 = llvm.load %555 : !llvm.ptr -> i64
%719 = arith.remsi %717, %718 : i64
%720 = llvm.mlir.constant(1 : i64) : i64
%721 = llvm.alloca %720 x i64 : (i64) -> !llvm.ptr
llvm.store %719, %721 : i64, !llvm.ptr
%722 = llvm.load %721 : !llvm.ptr -> i64
%723 = arith.constant 0 : i32
%725 = arith.extsi %723 : i32 to i64
%724 = arith.cmpi slt, %722, %725 : i64
cf.cond_br %724, ^bb144, ^bb145
^bb144:
%726 = llvm.load %721 : !llvm.ptr -> i64
%727 = llvm.load %555 : !llvm.ptr -> i64
%728 = arith.addi %726, %727 : i64
llvm.store %728, %721 : i64, !llvm.ptr
cf.br ^bb146
^bb145:
cf.br ^bb146
^bb146:
%729 = llvm.load %649 : !llvm.ptr -> i64
%731 = llvm.load %721 : !llvm.ptr -> i64
%732 = llvm.getelementptr %464[%731] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%730 = llvm.load %732 : !llvm.ptr -> i64
%733 = arith.subi %729, %730 : i64
llvm.store %733, %649 : i64, !llvm.ptr
%734 = llvm.load %649 : !llvm.ptr -> i64
%735 = llvm.mlir.addressof @MOD : !llvm.ptr
%736 = llvm.load %735 : !llvm.ptr -> i64
%737 = arith.remsi %734, %736 : i64
llvm.store %737, %649 : i64, !llvm.ptr
%738 = llvm.load %649 : !llvm.ptr -> i64
%739 = arith.constant 0 : i32
%741 = arith.extsi %739 : i32 to i64
%740 = arith.cmpi slt, %738, %741 : i64
cf.cond_br %740, ^bb147, ^bb148
^bb147:
%742 = llvm.load %649 : !llvm.ptr -> i64
%743 = llvm.mlir.addressof @MOD : !llvm.ptr
%744 = llvm.load %743 : !llvm.ptr -> i64
%745 = arith.addi %742, %744 : i64
llvm.store %745, %649 : i64, !llvm.ptr
cf.br ^bb149
^bb148:
cf.br ^bb149
^bb149:
%746 = llvm.load %240 : !llvm.ptr -> i64
%747 = arith.constant 1 : i32
%749 = arith.extsi %747 : i32 to i64
%748 = arith.addi %746, %749 : i64
llvm.store %748, %240 : i64, !llvm.ptr
cf.br ^bb141
^bb143:
cf.br ^bb128
^bb128:
cf.br ^bb116
^bb115:
cf.br ^bb116
^bb116:
%750 = llvm.load %542 : !llvm.ptr -> i64
%751 = arith.constant 1 : i32
%753 = arith.extsi %751 : i32 to i64
%752 = arith.addi %750, %753 : i64
llvm.store %752, %542 : i64, !llvm.ptr
cf.br ^bb111
^bb113:
%754 = llvm.load %495 : !llvm.ptr -> !llvm.ptr
%755 = llvm.load %497 : !llvm.ptr -> !llvm.ptr
llvm.store %755, %495 : !llvm.ptr, !llvm.ptr
llvm.store %754, %497 : !llvm.ptr, !llvm.ptr
cf.br ^bb107
^bb106:
cf.br ^bb107
^bb107:
cf.br ^bb104
^bb103:
cf.br ^bb104
^bb104:
%756 = llvm.load %501 : !llvm.ptr -> i64
%757 = arith.constant 1 : i32
%759 = arith.extsi %757 : i32 to i64
%758 = arith.addi %756, %759 : i64
llvm.store %758, %501 : i64, !llvm.ptr
cf.br ^bb99
^bb101:
%760 = llvm.mlir.addressof @str_0 : !llvm.ptr
%762 = llvm.load %495 : !llvm.ptr -> !llvm.ptr
%764 = arith.remsi %272, %268 : i64
%765 = llvm.getelementptr %284[%764] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%763 = llvm.load %765 : !llvm.ptr -> i64
%766 = llvm.getelementptr %762[%763] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%761 = llvm.load %766 : !llvm.ptr -> i64
%767 = llvm.call @printf(%760, %761) vararg(!llvm.func<i32 (ptr, ...)>) : (!llvm.ptr, i64) -> i32
func.call @free(%464) : (!llvm.ptr) -> ()
func.call @free(%460) : (!llvm.ptr) -> ()
func.call @free(%456) : (!llvm.ptr) -> ()
func.call @free(%452) : (!llvm.ptr) -> ()
func.call @free(%448) : (!llvm.ptr) -> ()
func.call @free(%406) : (!llvm.ptr) -> ()
func.call @free(%284) : (!llvm.ptr) -> ()
func.call @free(%281) : (!llvm.ptr) -> ()
%776 = arith.constant 0 : i32
func.return %776 : i32
}
}