← All problems
Problem 399
1e8-th squarefree Fibonacci: last 16 digits + scientific notation.
View problem on Project Euler
Performance comparison
Metric Our solution Best known
Time complexity O(n^2)O(n log log n)
Space complexity O(n^2)O(n)
Approach Flow solution Mobius sieve
Verdict Suboptimal
Flow source
# Project Euler 399
# 1e8-th squarefree Fibonacci: last 16 digits + scientific notation.
import euler.nt { isqrt }
extern {
function calloc(n: i64, size: i64) -> ptr<void>
function free(p: ptr<void>) -> void
function log(x: f64) -> f64
function pow(x: f64, y: f64) -> f64
function floor(x: f64) -> f64
}
function flog10(x: f64) -> f64 {
return log(x) / log(10.0)
}
function gcd_abs(a0: i64, b0: i64) -> i64 {
let mut a: i64 = a0
let mut b: i64 = b0
if a < 0 { a = 0 - a }
if b < 0 { b = 0 - b }
while b != 0 {
let t: i64 = a % b
a = b
b = t
}
return a
}
function modpow(base0: i64, exp0: i64, mod: i64) -> i64 {
let mut r: i64 = 1
let mut b: i64 = base0 % mod
let mut e: i64 = exp0
while e > 0 {
if e % 2 == 1 { r = (r * b) % mod }
b = (b * b) % mod
e = e / 2
}
return r
}
function local_mulmod(a0: i64, b0: i64, mod: i64) -> i64 {
let mut aa: i64 = a0 % mod
if aa < 0 { aa = aa + mod }
let mut bb: i64 = b0 % mod
if bb < 0 { bb = bb + mod }
return (((aa as i128) * (bb as i128)) % (mod as i128)) as i64
}
function fib_mod(n: i64, mod: i64) -> i64 {
let mut a: i64 = 0
let mut b: i64 = 1
if n == 0 { return 0 }
let mut bit: i64 = 63
while bit >= 0 {
if ((n >> bit) & 1) == 1 { break }
bit = bit - 1
}
while bit >= 0 {
let two_b_minus_a: i64 = (2 * b - a) % mod
if two_b_minus_a < 0 { two_b_minus_a = two_b_minus_a + mod }
let c: i64 = local_mulmod(a, two_b_minus_a, mod)
let d: i64 = (local_mulmod(a, a, mod) + local_mulmod(b, b, mod)) % mod
if ((n >> bit) & 1) == 1 {
a = d
b = (c + d) % mod
} else {
a = c
b = d
}
bit = bit - 1
}
return a
}
function legendre5(p: i64) -> i64 {
let r: i64 = modpow(5, (p - 1) / 2, p)
if r == 1 { return 1 }
return 0 - 1
}
function main() -> i32 {
let KTH: i64 = 100000000
let NMAX: i64 = 200000000
let LAST16: i64 = 10000000000000000
# Prime upper bound for moduli: scan small fib like Python
let mut a: i64 = 0
let mut b: i64 = 1
let mut best: i64 = 0
let mut kk: i64 = 1
while kk < 200 {
let tmp: i64 = a + b
a = b
b = tmp
let fk: i64 = a
let mut cand: i64 = NMAX / kk
if fk < cand { cand = fk }
if cand > best { best = cand }
if kk > 60 && (NMAX / kk) <= best { break }
kk = kk + 1
}
let pmax: i64 = best
let sieve: ptr<i8> = calloc(pmax + 1, 1)
let primes: ptr<i32> = calloc(pmax / 5 + 10, 4)
let mut pc: i64 = 0
sieve[0] = 1
sieve[1] = 1
let mut i: i64 = 2
while i <= pmax {
if sieve[i] == 0 {
primes[pc] = i as i32
pc = pc + 1
let mut j: i64 = i * i
while j <= pmax {
sieve[j] = 1
j = j + i
}
}
i = i + 1
}
let sroot: i64 = isqrt(pmax) + 1
let small_primes: ptr<i32> = calloc(sroot / 2 + 10, 4)
let mut spc: i64 = 0
i = 0
while i < pc {
let p: i64 = primes[i] as i64
if p > sroot { break }
small_primes[spc] = p as i32
spc = spc + 1
i = i + 1
}
let mods: ptr<i64> = calloc(pc + 1, 8)
let mut mc: i64 = 0
i = 0
while i < pc {
let p: i64 = primes[i] as i64
let mut zp: i64 = 0
if p == 2 { zp = 3 }
elif p == 5 { zp = 5 }
else {
let s: i64 = legendre5(p)
let mut cand: i64 = p + 1
if s == 1 { cand = p - 1 }
let mut d: i64 = cand
# unique prime factors of cand
let mut x: i64 = cand
let mut fi: i64 = 0
while fi < spc {
let q: i64 = small_primes[fi] as i64
if q * q > x { break }
if x % q == 0 {
while d % q == 0 && fib_mod(d / q, p) == 0 {
d = d / q
}
while x % q == 0 { x = x / q }
}
fi = fi + 1
}
if x > 1 {
while d % x == 0 && fib_mod(d / x, p) == 0 {
d = d / x
}
}
zp = d
}
let m: i64 = p * zp
if m <= NMAX {
mods[mc] = m
mc = mc + 1
}
i = i + 1
}
# sort mods
i = 1
while i < mc {
let key: i64 = mods[i]
let mut j: i64 = i - 1
while j >= 0 && mods[j] > key {
mods[j + 1] = mods[j]
j = j - 1
}
mods[j + 1] = key
i = i + 1
}
# filter redundant
let filtered: ptr<i64> = calloc(mc + 1, 8)
let mut fc: i64 = 0
i = 0
while i < mc {
let m: i64 = mods[i]
let mut redundant: i64 = 0
let mut j: i64 = 0
while j < fc {
if m % filtered[j] == 0 {
redundant = 1
break
}
j = j + 1
}
if redundant == 0 {
filtered[fc] = m
fc = fc + 1
}
i = i + 1
}
# Inclusion-exclusion coefficients via DFS; store in open-addressing map
let CAP: i64 = 1 << 20
let keys: ptr<i64> = calloc(CAP, 8)
let vals: ptr<i64> = calloc(CAP, 8)
let used: ptr<i8> = calloc(CAP, 1)
# put helper as inline loops
# seed coeff[1]=1
let mut slot: i64 = 1 & (CAP - 1)
used[slot] = 1
keys[slot] = 1
vals[slot] = 1
# iterative DFS stack: (start, lcm, sign)
let STMAX: i64 = 100000
let st_start: ptr<i32> = calloc(STMAX, 4)
let st_lcm: ptr<i64> = calloc(STMAX, 8)
let st_sign: ptr<i8> = calloc(STMAX, 1)
st_start[0] = 0
st_lcm[0] = 1
st_sign[0] = 1
let mut sp: i64 = 1
while sp > 0 {
sp = sp - 1
let start: i64 = st_start[sp] as i64
let lcm_val: i64 = st_lcm[sp]
let sign: i64 = st_sign[sp] as i64
let mut idx: i64 = start
while idx < fc {
let m: i64 = filtered[idx]
if lcm_val % m != 0 {
let g: i64 = gcd_abs(lcm_val, m)
let nl: i64 = (lcm_val / g) * m
if nl <= NMAX {
let s: i64 = 0 - sign
# map add
let mut h: i64 = nl
if h < 0 { h = 0 - h }
slot = h & (CAP - 1)
while used[slot] != 0 && keys[slot] != nl {
slot = (slot + 1) & (CAP - 1)
}
if used[slot] == 0 {
used[slot] = 1
keys[slot] = nl
vals[slot] = s
} else {
vals[slot] = vals[slot] + s
}
# push dfs
st_start[sp] = (idx + 1) as i32
st_lcm[sp] = nl
st_sign[sp] = s as i8
sp = sp + 1
}
}
idx = idx + 1
}
}
# collect nonzero coeffs
let lcms: ptr<i64> = calloc(CAP, 8)
let coeffs: ptr<i64> = calloc(CAP, 8)
let mut lc: i64 = 0
i = 0
while i < CAP {
if used[i] != 0 && vals[i] != 0 {
lcms[lc] = keys[i]
coeffs[lc] = vals[i]
lc = lc + 1
}
i = i + 1
}
# binary search for kth index
let mut lo: i64 = 1
let mut hi: i64 = NMAX
while lo < hi {
let mid: i64 = (lo + hi) / 2
let mut total: i64 = 0
i = 0
while i < lc {
total = total + coeffs[i] * (mid / lcms[i])
i = i + 1
}
if total >= KTH {
hi = mid
} else {
lo = mid + 1
}
}
let n: i64 = lo
let last16: i64 = fib_mod(n, LAST16)
let phi: f64 = (1.0 + pow(5.0, 0.5)) / 2.0
let log10F: f64 = (n as f64) * flog10(phi) - 0.5 * flog10(5.0)
let mut expv: i64 = floor(log10F) as i64
let mut mant: f64 = pow(10.0, log10F - (expv as f64))
let mut mant_r: f64 = floor(mant * 10.0 + 0.5) / 10.0
if mant_r >= 10.0 {
mant_r = 1.0
expv = expv + 1
}
printf("%lld,%.1fe%lld\n", last16, mant_r, expv)
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);
double flog10_f64(double x);
int64_t gcd_abs_i64_i64(int64_t a0, int64_t b0);
int64_t modpow_i64_i64_i64(int64_t base0, int64_t exp0, int64_t mod);
int64_t local_mulmod_i64_i64_i64(int64_t a0, int64_t b0, int64_t mod);
int64_t fib_mod_i64_i64(int64_t n, int64_t mod);
int64_t legendre5_i64(int64_t p);
int32_t main(void);
int64_t gcd_i64_i64(int64_t a0, int64_t b0) {
int64_t a = a0;
int64_t b = b0;
while (b != 0) {
int64_t t = FLOW_CHECKED_MOD((a), (b));
a = b;
b = t;
}
return a;
}
int64_t lcm_i64_i64(int64_t a, int64_t b) {
if ((a == 0 || b == 0)) {
return 0;
}
return (FLOW_CHECKED_DIV((a), (gcd_i64_i64(a, b))) * b);
}
int64_t isqrt_i64(int64_t n) {
if (n < 2) {
return n;
}
int64_t x = n;
int64_t y = FLOW_CHECKED_DIV(((x + 1)), (2));
while (y < x) {
x = y;
y = FLOW_CHECKED_DIV(((x + FLOW_CHECKED_DIV((n), (x)))), (2));
}
return x;
}
int64_t mulmod_i64_i64_i64(int64_t a0, int64_t b0, int64_t mod) {
int64_t a = FLOW_CHECKED_MOD((a0), (mod));
int64_t b = FLOW_CHECKED_MOD((b0), (mod));
int64_t result = 0;
while (b > 0) {
if (FLOW_CHECKED_MOD((b), (2)) == 1) {
result = FLOW_CHECKED_MOD(((result + a)), (mod));
}
a = FLOW_CHECKED_MOD(((a * 2)), (mod));
b = FLOW_CHECKED_DIV((b), (2));
}
return result;
}
int64_t mod_pow_i64_i64_i64(int64_t base, int64_t exp, int64_t mod) {
if (mod == 1) {
return 0;
}
int64_t result = 1;
int64_t b = FLOW_CHECKED_MOD((base), (mod));
int64_t e = exp;
while (e > 0) {
if (FLOW_CHECKED_MOD((e), (2)) == 1) {
result = mulmod_i64_i64_i64(result, b, mod);
}
b = mulmod_i64_i64_i64(b, b, mod);
e = FLOW_CHECKED_DIV((e), (2));
}
return result;
}
bool is_prime_i64(int64_t n) {
if (n < 2) {
return 0;
}
if (n < 4) {
return 1;
}
if ((FLOW_CHECKED_MOD((n), (2)) == 0 || FLOW_CHECKED_MOD((n), (3)) == 0)) {
return 0;
}
int64_t i = 5;
while ((i * i) <= n) {
if ((FLOW_CHECKED_MOD((n), (i)) == 0 || FLOW_CHECKED_MOD((n), ((i + 2))) == 0)) {
return 0;
}
i = (i + 6);
}
return 1;
}
double flog10_f64(double x) {
return (log(x) / log(10.0));
}
int64_t gcd_abs_i64_i64(int64_t a0, int64_t b0) {
int64_t a = a0;
int64_t b = b0;
if (a < 0) {
a = (0 - a);
}
if (b < 0) {
b = (0 - b);
}
while (b != 0) {
int64_t t = FLOW_CHECKED_MOD((a), (b));
a = b;
b = t;
}
return a;
}
int64_t modpow_i64_i64_i64(int64_t base0, int64_t exp0, int64_t mod) {
int64_t r = 1;
int64_t b = FLOW_CHECKED_MOD((base0), (mod));
int64_t e = exp0;
while (e > 0) {
if (FLOW_CHECKED_MOD((e), (2)) == 1) {
r = FLOW_CHECKED_MOD(((r * b)), (mod));
}
b = FLOW_CHECKED_MOD(((b * b)), (mod));
e = FLOW_CHECKED_DIV((e), (2));
}
return r;
}
int64_t local_mulmod_i64_i64_i64(int64_t a0, int64_t b0, int64_t mod) {
int64_t aa = FLOW_CHECKED_MOD((a0), (mod));
if (aa < 0) {
aa = (aa + mod);
}
int64_t bb = FLOW_CHECKED_MOD((b0), (mod));
if (bb < 0) {
bb = (bb + mod);
}
return ((int64_t)(FLOW_CHECKED_MOD(((((__int128)(aa)) * ((__int128)(bb)))), (((__int128)(mod))))));
}
int64_t fib_mod_i64_i64(int64_t n, int64_t mod) {
int64_t a = 0;
int64_t b = 1;
if (n == 0) {
return 0;
}
int64_t bit = 63;
while (bit >= 0) {
if ((FLOW_CHECKED_SHR((n), (bit)) & 1) == 1) {
break;
}
bit = (bit - 1);
}
while (bit >= 0) {
int64_t two_b_minus_a = FLOW_CHECKED_MOD((((2 * b) - a)), (mod));
if (two_b_minus_a < 0) {
two_b_minus_a = (two_b_minus_a + mod);
}
int64_t c = local_mulmod_i64_i64_i64(a, two_b_minus_a, mod);
int64_t d = FLOW_CHECKED_MOD(((local_mulmod_i64_i64_i64(a, a, mod) + local_mulmod_i64_i64_i64(b, b, mod))), (mod));
if ((FLOW_CHECKED_SHR((n), (bit)) & 1) == 1) {
a = d;
b = FLOW_CHECKED_MOD(((c + d)), (mod));
} else {
a = c;
b = d;
}
bit = (bit - 1);
}
return a;
}
int64_t legendre5_i64(int64_t p) {
int64_t r = modpow_i64_i64_i64(5, FLOW_CHECKED_DIV(((p - 1)), (2)), p);
if (r == 1) {
return 1;
}
return (0 - 1);
}
int32_t main(void) {
int64_t KTH = 100000000;
int64_t NMAX = 200000000;
int64_t LAST16 = 10000000000000000;
int64_t a = 0;
int64_t b = 1;
int64_t best = 0;
int64_t kk = 1;
while (kk < 200) {
int64_t tmp = (a + b);
a = b;
b = tmp;
int64_t fk = a;
int64_t cand = FLOW_CHECKED_DIV((NMAX), (kk));
if (fk < cand) {
cand = fk;
}
if (cand > best) {
best = cand;
}
if ((kk > 60 && FLOW_CHECKED_DIV((NMAX), (kk)) <= best)) {
break;
}
kk = (kk + 1);
}
int64_t pmax = best;
int8_t* sieve = (int8_t*)(calloc((pmax + 1), 1));
int32_t* primes = (int32_t*)(calloc((FLOW_CHECKED_DIV((pmax), (5)) + 10), 4));
int64_t pc = 0;
sieve[0] = 1;
sieve[1] = 1;
int64_t i = 2;
while (i <= pmax) {
if (sieve[i] == 0) {
primes[pc] = ((int32_t)(i));
pc = (pc + 1);
int64_t j = (i * i);
while (j <= pmax) {
sieve[j] = 1;
j = (j + i);
}
}
i = (i + 1);
}
int64_t sroot = (isqrt_i64(pmax) + 1);
int32_t* small_primes = (int32_t*)(calloc((FLOW_CHECKED_DIV((sroot), (2)) + 10), 4));
int64_t spc = 0;
i = 0;
while (i < pc) {
int64_t p = ((int64_t)(primes[i]));
if (p > sroot) {
break;
}
small_primes[spc] = ((int32_t)(p));
spc = (spc + 1);
i = (i + 1);
}
int64_t* mods = (int64_t*)(calloc((pc + 1), 8));
int64_t mc = 0;
i = 0;
while (i < pc) {
int64_t p = ((int64_t)(primes[i]));
int64_t zp = 0;
if (p == 2) {
zp = 3;
} else if (p == 5) {
zp = 5;
} else {
int64_t s = legendre5_i64(p);
int64_t cand = (p + 1);
if (s == 1) {
cand = (p - 1);
}
int64_t d = cand;
int64_t x = cand;
int64_t fi = 0;
while (fi < spc) {
int64_t q = ((int64_t)(small_primes[fi]));
if ((q * q) > x) {
break;
}
if (FLOW_CHECKED_MOD((x), (q)) == 0) {
while ((FLOW_CHECKED_MOD((d), (q)) == 0 && fib_mod_i64_i64(FLOW_CHECKED_DIV((d), (q)), p) == 0)) {
d = FLOW_CHECKED_DIV((d), (q));
}
while (FLOW_CHECKED_MOD((x), (q)) == 0) {
x = FLOW_CHECKED_DIV((x), (q));
}
}
fi = (fi + 1);
}
if (x > 1) {
while ((FLOW_CHECKED_MOD((d), (x)) == 0 && fib_mod_i64_i64(FLOW_CHECKED_DIV((d), (x)), p) == 0)) {
d = FLOW_CHECKED_DIV((d), (x));
}
}
zp = d;
}
int64_t m = (p * zp);
if (m <= NMAX) {
mods[mc] = m;
mc = (mc + 1);
}
i = (i + 1);
}
i = 1;
while (i < mc) {
int64_t key = mods[i];
int64_t j = (i - 1);
while ((j >= 0 && mods[j] > key)) {
mods[(j + 1)] = mods[j];
j = (j - 1);
}
mods[(j + 1)] = key;
i = (i + 1);
}
int64_t* filtered = (int64_t*)(calloc((mc + 1), 8));
int64_t fc = 0;
i = 0;
while (i < mc) {
int64_t m = mods[i];
int64_t redundant = 0;
int64_t j = 0;
while (j < fc) {
if (FLOW_CHECKED_MOD((m), (filtered[j])) == 0) {
redundant = 1;
break;
}
j = (j + 1);
}
if (redundant == 0) {
filtered[fc] = m;
fc = (fc + 1);
}
i = (i + 1);
}
int64_t CAP = FLOW_CHECKED_SHL((1), (20));
int64_t* keys = (int64_t*)(calloc(CAP, 8));
int64_t* vals = (int64_t*)(calloc(CAP, 8));
int8_t* used = (int8_t*)(calloc(CAP, 1));
int64_t slot = (1 & (CAP - 1));
used[slot] = 1;
keys[slot] = 1;
vals[slot] = 1;
int64_t STMAX = 100000;
int32_t* st_start = (int32_t*)(calloc(STMAX, 4));
int64_t* st_lcm = (int64_t*)(calloc(STMAX, 8));
int8_t* st_sign = (int8_t*)(calloc(STMAX, 1));
st_start[0] = 0;
st_lcm[0] = 1;
st_sign[0] = 1;
int64_t sp = 1;
while (sp > 0) {
sp = (sp - 1);
int64_t start = ((int64_t)(st_start[sp]));
int64_t lcm_val = st_lcm[sp];
int64_t sign = ((int64_t)(st_sign[sp]));
int64_t idx = start;
while (idx < fc) {
int64_t m = filtered[idx];
if (FLOW_CHECKED_MOD((lcm_val), (m)) != 0) {
int64_t g = gcd_abs_i64_i64(lcm_val, m);
int64_t nl = (FLOW_CHECKED_DIV((lcm_val), (g)) * m);
if (nl <= NMAX) {
int64_t s = (0 - sign);
int64_t h = nl;
if (h < 0) {
h = (0 - h);
}
slot = (h & (CAP - 1));
while ((used[slot] != 0 && keys[slot] != nl)) {
slot = ((slot + 1) & (CAP - 1));
}
if (used[slot] == 0) {
used[slot] = 1;
keys[slot] = nl;
vals[slot] = s;
} else {
vals[slot] = (vals[slot] + s);
}
st_start[sp] = ((int32_t)((idx + 1)));
st_lcm[sp] = nl;
st_sign[sp] = ((int8_t)(s));
sp = (sp + 1);
}
}
idx = (idx + 1);
}
}
int64_t* lcms = (int64_t*)(calloc(CAP, 8));
int64_t* coeffs = (int64_t*)(calloc(CAP, 8));
int64_t lc = 0;
i = 0;
while (i < CAP) {
if ((used[i] != 0 && vals[i] != 0)) {
lcms[lc] = keys[i];
coeffs[lc] = vals[i];
lc = (lc + 1);
}
i = (i + 1);
}
int64_t lo = 1;
int64_t hi = NMAX;
while (lo < hi) {
int64_t mid = FLOW_CHECKED_DIV(((lo + hi)), (2));
int64_t total = 0;
i = 0;
while (i < lc) {
total = (total + (coeffs[i] * FLOW_CHECKED_DIV((mid), (lcms[i]))));
i = (i + 1);
}
if (total >= KTH) {
hi = mid;
} else {
lo = (mid + 1);
}
}
int64_t n = lo;
int64_t last16 = fib_mod_i64_i64(n, LAST16);
double phi = ((1.0 + pow(5.0, 0.5)) / 2.0);
double log10F = ((((double)(n)) * flog10_f64(phi)) - (0.5 * flog10_f64(5.0)));
int64_t expv = ((int64_t)(floor(log10F)));
double mant = pow(10.0, (log10F - ((double)(expv))));
double mant_r = (floor(((mant * 10.0) + 0.5)) / 10.0);
if (mant_r >= 10.0) {
mant_r = 1.0;
expv = (expv + 1);
}
printf("%lld,%.1fe%lld\n", last16, mant_r, expv);
return 0;
}
Generated MLIR
module {
llvm.func @printf(!llvm.ptr, ...) -> i32
llvm.mlir.global internal constant @str_0("%lld,%.1fe%lld\n\00") {addr_space = 0 : i32} : !llvm.array<16 x i8>
func.func @gcd(%arg0: i64, %arg1: i64) -> i64 {
%0 = llvm.mlir.constant(1 : i64) : i64
%1 = llvm.alloca %0 x i64 : (i64) -> !llvm.ptr
llvm.store %arg0, %1 : i64, !llvm.ptr
%2 = llvm.mlir.constant(1 : i64) : i64
%3 = llvm.alloca %2 x i64 : (i64) -> !llvm.ptr
llvm.store %arg1, %3 : i64, !llvm.ptr
cf.br ^bb0
^bb0:
%4 = llvm.load %3 : !llvm.ptr -> i64
%5 = arith.constant 0 : i32
%7 = arith.extsi %5 : i32 to i64
%6 = arith.cmpi ne, %4, %7 : i64
cf.cond_br %6, ^bb1, ^bb2
^bb1:
%8 = llvm.load %1 : !llvm.ptr -> i64
%9 = llvm.load %3 : !llvm.ptr -> i64
%10 = arith.remsi %8, %9 : i64
%11 = llvm.load %3 : !llvm.ptr -> i64
llvm.store %11, %1 : i64, !llvm.ptr
llvm.store %10, %3 : i64, !llvm.ptr
cf.br ^bb0
^bb2:
%12 = llvm.load %1 : !llvm.ptr -> i64
func.return %12 : i64
}
func.func @lcm(%arg0: i64, %arg1: i64) -> i64 {
%13 = arith.constant 0 : i32
%15 = arith.extsi %13 : i32 to i64
%14 = arith.cmpi eq, %arg0, %15 : i64
%16 = scf.if %14 -> (i1) {
%17 = arith.constant true
scf.yield %17 : i1
} else {
%18 = arith.constant 0 : i32
%20 = arith.extsi %18 : i32 to i64
%19 = arith.cmpi eq, %arg1, %20 : i64
scf.yield %19 : i1
}
cf.cond_br %16, ^bb3, ^bb4
^bb3:
%21 = arith.constant 0 : i32
%22 = arith.extsi %21 : i32 to i64
func.return %22 : i64
^bb4:
cf.br ^bb5
^bb5:
%23 = func.call @gcd(%arg0, %arg1) : (i64, i64) -> i64
%24 = arith.divsi %arg0, %23 : i64
%25 = arith.muli %24, %arg1 : i64
func.return %25 : i64
}
func.func @isqrt(%arg0: i64) -> i64 {
%26 = arith.constant 2 : i32
%28 = arith.extsi %26 : i32 to i64
%27 = arith.cmpi slt, %arg0, %28 : i64
cf.cond_br %27, ^bb6, ^bb7
^bb6:
func.return %arg0 : i64
^bb7:
cf.br ^bb8
^bb8:
%29 = llvm.mlir.constant(1 : i64) : i64
%30 = llvm.alloca %29 x i64 : (i64) -> !llvm.ptr
llvm.store %arg0, %30 : i64, !llvm.ptr
%31 = llvm.load %30 : !llvm.ptr -> i64
%32 = arith.constant 1 : i32
%34 = arith.extsi %32 : i32 to i64
%33 = arith.addi %31, %34 : i64
%35 = arith.constant 2 : i32
%37 = arith.extsi %35 : i32 to i64
%36 = arith.divsi %33, %37 : i64
%38 = llvm.mlir.constant(1 : i64) : i64
%39 = llvm.alloca %38 x i64 : (i64) -> !llvm.ptr
llvm.store %36, %39 : i64, !llvm.ptr
cf.br ^bb9
^bb9:
%40 = llvm.load %39 : !llvm.ptr -> i64
%41 = llvm.load %30 : !llvm.ptr -> i64
%42 = arith.cmpi slt, %40, %41 : i64
cf.cond_br %42, ^bb10, ^bb11
^bb10:
%43 = llvm.load %39 : !llvm.ptr -> i64
llvm.store %43, %30 : i64, !llvm.ptr
%44 = llvm.load %30 : !llvm.ptr -> i64
%45 = llvm.load %30 : !llvm.ptr -> i64
%46 = arith.divsi %arg0, %45 : i64
%47 = arith.addi %44, %46 : i64
%48 = arith.constant 2 : i32
%50 = arith.extsi %48 : i32 to i64
%49 = arith.divsi %47, %50 : i64
llvm.store %49, %39 : i64, !llvm.ptr
cf.br ^bb9
^bb11:
%51 = llvm.load %30 : !llvm.ptr -> i64
func.return %51 : i64
}
func.func @mulmod(%arg0: i64, %arg1: i64, %arg2: i64) -> i64 {
%52 = arith.remsi %arg0, %arg2 : i64
%53 = llvm.mlir.constant(1 : i64) : i64
%54 = llvm.alloca %53 x i64 : (i64) -> !llvm.ptr
llvm.store %52, %54 : i64, !llvm.ptr
%55 = arith.remsi %arg1, %arg2 : i64
%56 = llvm.mlir.constant(1 : i64) : i64
%57 = llvm.alloca %56 x i64 : (i64) -> !llvm.ptr
llvm.store %55, %57 : i64, !llvm.ptr
%58 = arith.constant 0 : i32
%59 = arith.extsi %58 : i32 to i64
%60 = llvm.mlir.constant(1 : i64) : i64
%61 = llvm.alloca %60 x i64 : (i64) -> !llvm.ptr
llvm.store %59, %61 : i64, !llvm.ptr
cf.br ^bb12
^bb12:
%62 = llvm.load %57 : !llvm.ptr -> i64
%63 = arith.constant 0 : i32
%65 = arith.extsi %63 : i32 to i64
%64 = arith.cmpi sgt, %62, %65 : i64
cf.cond_br %64, ^bb13, ^bb14
^bb13:
%66 = llvm.load %57 : !llvm.ptr -> i64
%67 = arith.constant 2 : i32
%69 = arith.extsi %67 : i32 to i64
%68 = arith.remsi %66, %69 : i64
%70 = arith.constant 1 : i32
%72 = arith.extsi %70 : i32 to i64
%71 = arith.cmpi eq, %68, %72 : i64
cf.cond_br %71, ^bb15, ^bb16
^bb15:
%73 = llvm.load %61 : !llvm.ptr -> i64
%74 = llvm.load %54 : !llvm.ptr -> i64
%75 = arith.addi %73, %74 : i64
%76 = arith.remsi %75, %arg2 : i64
llvm.store %76, %61 : i64, !llvm.ptr
cf.br ^bb17
^bb16:
cf.br ^bb17
^bb17:
%77 = llvm.load %54 : !llvm.ptr -> i64
%78 = arith.constant 2 : i32
%80 = arith.extsi %78 : i32 to i64
%79 = arith.muli %77, %80 : i64
%81 = arith.remsi %79, %arg2 : i64
llvm.store %81, %54 : i64, !llvm.ptr
%82 = llvm.load %57 : !llvm.ptr -> i64
%83 = arith.constant 2 : i32
%85 = arith.extsi %83 : i32 to i64
%84 = arith.divsi %82, %85 : i64
llvm.store %84, %57 : i64, !llvm.ptr
cf.br ^bb12
^bb14:
%86 = llvm.load %61 : !llvm.ptr -> i64
func.return %86 : i64
}
func.func @mod_pow(%arg0: i64, %arg1: i64, %arg2: i64) -> i64 {
%87 = arith.constant 1 : i32
%89 = arith.extsi %87 : i32 to i64
%88 = arith.cmpi eq, %arg2, %89 : i64
cf.cond_br %88, ^bb18, ^bb19
^bb18:
%90 = arith.constant 0 : i32
%91 = arith.extsi %90 : i32 to i64
func.return %91 : i64
^bb19:
cf.br ^bb20
^bb20:
%92 = arith.constant 1 : i32
%93 = arith.extsi %92 : i32 to i64
%94 = llvm.mlir.constant(1 : i64) : i64
%95 = llvm.alloca %94 x i64 : (i64) -> !llvm.ptr
llvm.store %93, %95 : i64, !llvm.ptr
%96 = arith.remsi %arg0, %arg2 : i64
%97 = llvm.mlir.constant(1 : i64) : i64
%98 = llvm.alloca %97 x i64 : (i64) -> !llvm.ptr
llvm.store %96, %98 : i64, !llvm.ptr
%99 = llvm.mlir.constant(1 : i64) : i64
%100 = llvm.alloca %99 x i64 : (i64) -> !llvm.ptr
llvm.store %arg1, %100 : i64, !llvm.ptr
cf.br ^bb21
^bb21:
%101 = llvm.load %100 : !llvm.ptr -> i64
%102 = arith.constant 0 : i32
%104 = arith.extsi %102 : i32 to i64
%103 = arith.cmpi sgt, %101, %104 : i64
cf.cond_br %103, ^bb22, ^bb23
^bb22:
%105 = llvm.load %100 : !llvm.ptr -> i64
%106 = arith.constant 2 : i32
%108 = arith.extsi %106 : i32 to i64
%107 = arith.remsi %105, %108 : i64
%109 = arith.constant 1 : i32
%111 = arith.extsi %109 : i32 to i64
%110 = arith.cmpi eq, %107, %111 : i64
cf.cond_br %110, ^bb24, ^bb25
^bb24:
%113 = llvm.load %95 : !llvm.ptr -> i64
%114 = llvm.load %98 : !llvm.ptr -> i64
%112 = func.call @mulmod(%113, %114, %arg2) : (i64, i64, i64) -> i64
llvm.store %112, %95 : i64, !llvm.ptr
cf.br ^bb26
^bb25:
cf.br ^bb26
^bb26:
%116 = llvm.load %98 : !llvm.ptr -> i64
%117 = llvm.load %98 : !llvm.ptr -> i64
%115 = func.call @mulmod(%116, %117, %arg2) : (i64, i64, i64) -> i64
llvm.store %115, %98 : i64, !llvm.ptr
%118 = llvm.load %100 : !llvm.ptr -> i64
%119 = arith.constant 2 : i32
%121 = arith.extsi %119 : i32 to i64
%120 = arith.divsi %118, %121 : i64
llvm.store %120, %100 : i64, !llvm.ptr
cf.br ^bb21
^bb23:
%122 = llvm.load %95 : !llvm.ptr -> i64
func.return %122 : i64
}
func.func @is_prime(%arg0: i64) -> i1 {
%123 = arith.constant 2 : i32
%125 = arith.extsi %123 : i32 to i64
%124 = arith.cmpi slt, %arg0, %125 : i64
cf.cond_br %124, ^bb27, ^bb28
^bb27:
%126 = arith.constant 0 : i1
func.return %126 : i1
^bb28:
cf.br ^bb29
^bb29:
%127 = arith.constant 4 : i32
%129 = arith.extsi %127 : i32 to i64
%128 = arith.cmpi slt, %arg0, %129 : i64
cf.cond_br %128, ^bb30, ^bb31
^bb30:
%130 = arith.constant 1 : i1
func.return %130 : i1
^bb31:
cf.br ^bb32
^bb32:
%131 = arith.constant 2 : i32
%133 = arith.extsi %131 : i32 to i64
%132 = arith.remsi %arg0, %133 : i64
%134 = arith.constant 0 : i32
%136 = arith.extsi %134 : i32 to i64
%135 = arith.cmpi eq, %132, %136 : i64
%137 = scf.if %135 -> (i1) {
%138 = arith.constant true
scf.yield %138 : i1
} else {
%139 = arith.constant 3 : i32
%141 = arith.extsi %139 : i32 to i64
%140 = arith.remsi %arg0, %141 : i64
%142 = arith.constant 0 : i32
%144 = arith.extsi %142 : i32 to i64
%143 = arith.cmpi eq, %140, %144 : i64
scf.yield %143 : i1
}
cf.cond_br %137, ^bb33, ^bb34
^bb33:
%145 = arith.constant 0 : i1
func.return %145 : i1
^bb34:
cf.br ^bb35
^bb35:
%146 = arith.constant 5 : i32
%147 = arith.extsi %146 : i32 to i64
%148 = llvm.mlir.constant(1 : i64) : i64
%149 = llvm.alloca %148 x i64 : (i64) -> !llvm.ptr
llvm.store %147, %149 : i64, !llvm.ptr
cf.br ^bb36
^bb36:
%150 = llvm.load %149 : !llvm.ptr -> i64
%151 = llvm.load %149 : !llvm.ptr -> i64
%152 = arith.muli %150, %151 : i64
%153 = arith.cmpi sle, %152, %arg0 : i64
cf.cond_br %153, ^bb37, ^bb38
^bb37:
%154 = llvm.load %149 : !llvm.ptr -> i64
%155 = arith.remsi %arg0, %154 : i64
%156 = arith.constant 0 : i32
%158 = arith.extsi %156 : i32 to i64
%157 = arith.cmpi eq, %155, %158 : i64
%159 = scf.if %157 -> (i1) {
%160 = arith.constant true
scf.yield %160 : i1
} else {
%161 = llvm.load %149 : !llvm.ptr -> i64
%162 = arith.constant 2 : i32
%164 = arith.extsi %162 : i32 to i64
%163 = arith.addi %161, %164 : i64
%165 = arith.remsi %arg0, %163 : i64
%166 = arith.constant 0 : i32
%168 = arith.extsi %166 : i32 to i64
%167 = arith.cmpi eq, %165, %168 : i64
scf.yield %167 : i1
}
cf.cond_br %159, ^bb39, ^bb40
^bb39:
%169 = arith.constant 0 : i1
func.return %169 : i1
^bb40:
cf.br ^bb41
^bb41:
%170 = llvm.load %149 : !llvm.ptr -> i64
%171 = arith.constant 6 : i32
%173 = arith.extsi %171 : i32 to i64
%172 = arith.addi %170, %173 : i64
llvm.store %172, %149 : i64, !llvm.ptr
cf.br ^bb36
^bb38:
%174 = arith.constant 1 : i1
func.return %174 : i1
}
func.func private @calloc(i64, i64) -> !llvm.ptr
func.func private @free(!llvm.ptr) -> ()
func.func private @log(f64) -> f64
func.func private @pow(f64, f64) -> f64
func.func private @floor(f64) -> f64
func.func @flog10(%arg0: f64) -> f64 {
%175 = math.log %arg0 : f64
%176 = arith.constant 10.0 : f32
%177 = math.log %176 : f32
%178 = arith.divf %175, %177 : f64
func.return %178 : f64
}
func.func @gcd_abs(%arg0: i64, %arg1: i64) -> i64 {
%179 = llvm.mlir.constant(1 : i64) : i64
%180 = llvm.alloca %179 x i64 : (i64) -> !llvm.ptr
llvm.store %arg0, %180 : i64, !llvm.ptr
%181 = llvm.mlir.constant(1 : i64) : i64
%182 = llvm.alloca %181 x i64 : (i64) -> !llvm.ptr
llvm.store %arg1, %182 : i64, !llvm.ptr
%183 = llvm.load %180 : !llvm.ptr -> i64
%184 = arith.constant 0 : i32
%186 = arith.extsi %184 : i32 to i64
%185 = arith.cmpi slt, %183, %186 : i64
cf.cond_br %185, ^bb42, ^bb43
^bb42:
%187 = arith.constant 0 : i32
%188 = llvm.load %180 : !llvm.ptr -> i64
%190 = arith.extsi %187 : i32 to i64
%189 = arith.subi %190, %188 : i64
llvm.store %189, %180 : i64, !llvm.ptr
cf.br ^bb44
^bb43:
cf.br ^bb44
^bb44:
%191 = llvm.load %182 : !llvm.ptr -> i64
%192 = arith.constant 0 : i32
%194 = arith.extsi %192 : i32 to i64
%193 = arith.cmpi slt, %191, %194 : i64
cf.cond_br %193, ^bb45, ^bb46
^bb45:
%195 = arith.constant 0 : i32
%196 = llvm.load %182 : !llvm.ptr -> i64
%198 = arith.extsi %195 : i32 to i64
%197 = arith.subi %198, %196 : i64
llvm.store %197, %182 : i64, !llvm.ptr
cf.br ^bb47
^bb46:
cf.br ^bb47
^bb47:
cf.br ^bb48
^bb48:
%199 = llvm.load %182 : !llvm.ptr -> i64
%200 = arith.constant 0 : i32
%202 = arith.extsi %200 : i32 to i64
%201 = arith.cmpi ne, %199, %202 : i64
cf.cond_br %201, ^bb49, ^bb50
^bb49:
%203 = llvm.load %180 : !llvm.ptr -> i64
%204 = llvm.load %182 : !llvm.ptr -> i64
%205 = arith.remsi %203, %204 : i64
%206 = llvm.load %182 : !llvm.ptr -> i64
llvm.store %206, %180 : i64, !llvm.ptr
llvm.store %205, %182 : i64, !llvm.ptr
cf.br ^bb48
^bb50:
%207 = llvm.load %180 : !llvm.ptr -> i64
func.return %207 : i64
}
func.func @modpow(%arg0: i64, %arg1: i64, %arg2: i64) -> i64 {
%208 = arith.constant 1 : i32
%209 = arith.extsi %208 : i32 to i64
%210 = llvm.mlir.constant(1 : i64) : i64
%211 = llvm.alloca %210 x i64 : (i64) -> !llvm.ptr
llvm.store %209, %211 : i64, !llvm.ptr
%212 = arith.remsi %arg0, %arg2 : i64
%213 = llvm.mlir.constant(1 : i64) : i64
%214 = llvm.alloca %213 x i64 : (i64) -> !llvm.ptr
llvm.store %212, %214 : i64, !llvm.ptr
%215 = llvm.mlir.constant(1 : i64) : i64
%216 = llvm.alloca %215 x i64 : (i64) -> !llvm.ptr
llvm.store %arg1, %216 : i64, !llvm.ptr
cf.br ^bb51
^bb51:
%217 = llvm.load %216 : !llvm.ptr -> i64
%218 = arith.constant 0 : i32
%220 = arith.extsi %218 : i32 to i64
%219 = arith.cmpi sgt, %217, %220 : i64
cf.cond_br %219, ^bb52, ^bb53
^bb52:
%221 = llvm.load %216 : !llvm.ptr -> i64
%222 = arith.constant 2 : i32
%224 = arith.extsi %222 : i32 to i64
%223 = arith.remsi %221, %224 : i64
%225 = arith.constant 1 : i32
%227 = arith.extsi %225 : i32 to i64
%226 = arith.cmpi eq, %223, %227 : i64
cf.cond_br %226, ^bb54, ^bb55
^bb54:
%228 = llvm.load %211 : !llvm.ptr -> i64
%229 = llvm.load %214 : !llvm.ptr -> i64
%230 = arith.muli %228, %229 : i64
%231 = arith.remsi %230, %arg2 : i64
llvm.store %231, %211 : i64, !llvm.ptr
cf.br ^bb56
^bb55:
cf.br ^bb56
^bb56:
%232 = llvm.load %214 : !llvm.ptr -> i64
%233 = llvm.load %214 : !llvm.ptr -> i64
%234 = arith.muli %232, %233 : i64
%235 = arith.remsi %234, %arg2 : i64
llvm.store %235, %214 : i64, !llvm.ptr
%236 = llvm.load %216 : !llvm.ptr -> i64
%237 = arith.constant 2 : i32
%239 = arith.extsi %237 : i32 to i64
%238 = arith.divsi %236, %239 : i64
llvm.store %238, %216 : i64, !llvm.ptr
cf.br ^bb51
^bb53:
%240 = llvm.load %211 : !llvm.ptr -> i64
func.return %240 : i64
}
func.func @local_mulmod(%arg0: i64, %arg1: i64, %arg2: i64) -> i64 {
%241 = arith.remsi %arg0, %arg2 : i64
%242 = llvm.mlir.constant(1 : i64) : i64
%243 = llvm.alloca %242 x i64 : (i64) -> !llvm.ptr
llvm.store %241, %243 : i64, !llvm.ptr
%244 = llvm.load %243 : !llvm.ptr -> i64
%245 = arith.constant 0 : i32
%247 = arith.extsi %245 : i32 to i64
%246 = arith.cmpi slt, %244, %247 : i64
cf.cond_br %246, ^bb57, ^bb58
^bb57:
%248 = llvm.load %243 : !llvm.ptr -> i64
%249 = arith.addi %248, %arg2 : i64
llvm.store %249, %243 : i64, !llvm.ptr
cf.br ^bb59
^bb58:
cf.br ^bb59
^bb59:
%250 = arith.remsi %arg1, %arg2 : i64
%251 = llvm.mlir.constant(1 : i64) : i64
%252 = llvm.alloca %251 x i64 : (i64) -> !llvm.ptr
llvm.store %250, %252 : i64, !llvm.ptr
%253 = llvm.load %252 : !llvm.ptr -> i64
%254 = arith.constant 0 : i32
%256 = arith.extsi %254 : i32 to i64
%255 = arith.cmpi slt, %253, %256 : i64
cf.cond_br %255, ^bb60, ^bb61
^bb60:
%257 = llvm.load %252 : !llvm.ptr -> i64
%258 = arith.addi %257, %arg2 : i64
llvm.store %258, %252 : i64, !llvm.ptr
cf.br ^bb62
^bb61:
cf.br ^bb62
^bb62:
%259 = llvm.load %243 : !llvm.ptr -> i64
%260 = arith.extsi %259 : i64 to i128
%261 = llvm.load %252 : !llvm.ptr -> i64
%262 = arith.extsi %261 : i64 to i128
%264 = arith.trunci %260 : i128 to i64
%265 = arith.trunci %262 : i128 to i64
%263 = arith.muli %264, %265 : i64
%266 = arith.extsi %arg2 : i64 to i128
%268 = arith.trunci %266 : i128 to i64
%267 = arith.remsi %263, %268 : i64
func.return %267 : i64
}
func.func @fib_mod(%arg0: i64, %arg1: i64) -> i64 {
%269 = arith.constant 0 : i32
%270 = arith.extsi %269 : i32 to i64
%271 = llvm.mlir.constant(1 : i64) : i64
%272 = llvm.alloca %271 x i64 : (i64) -> !llvm.ptr
llvm.store %270, %272 : i64, !llvm.ptr
%273 = arith.constant 1 : i32
%274 = arith.extsi %273 : i32 to i64
%275 = llvm.mlir.constant(1 : i64) : i64
%276 = llvm.alloca %275 x i64 : (i64) -> !llvm.ptr
llvm.store %274, %276 : i64, !llvm.ptr
%277 = arith.constant 0 : i32
%279 = arith.extsi %277 : i32 to i64
%278 = arith.cmpi eq, %arg0, %279 : i64
cf.cond_br %278, ^bb63, ^bb64
^bb63:
%280 = arith.constant 0 : i32
%281 = arith.extsi %280 : i32 to i64
func.return %281 : i64
^bb64:
cf.br ^bb65
^bb65:
%282 = arith.constant 63 : i32
%283 = arith.extsi %282 : i32 to i64
%284 = llvm.mlir.constant(1 : i64) : i64
%285 = llvm.alloca %284 x i64 : (i64) -> !llvm.ptr
llvm.store %283, %285 : i64, !llvm.ptr
cf.br ^bb66
^bb66:
%286 = llvm.load %285 : !llvm.ptr -> i64
%287 = arith.constant 0 : i32
%289 = arith.extsi %287 : i32 to i64
%288 = arith.cmpi sge, %286, %289 : i64
cf.cond_br %288, ^bb67, ^bb68
^bb67:
%290 = llvm.load %285 : !llvm.ptr -> i64
%291 = arith.shrsi %arg0, %290 : i64
%292 = arith.constant 1 : i32
%294 = arith.extsi %292 : i32 to i64
%293 = arith.andi %291, %294 : i64
%295 = arith.constant 1 : i32
%297 = arith.extsi %295 : i32 to i64
%296 = arith.cmpi eq, %293, %297 : i64
cf.cond_br %296, ^bb69, ^bb70
^bb69:
cf.br ^bb68
^bb70:
cf.br ^bb71
^bb71:
%298 = llvm.load %285 : !llvm.ptr -> i64
%299 = arith.constant 1 : i32
%301 = arith.extsi %299 : i32 to i64
%300 = arith.subi %298, %301 : i64
llvm.store %300, %285 : i64, !llvm.ptr
cf.br ^bb66
^bb68:
cf.br ^bb72
^bb72:
%302 = llvm.load %285 : !llvm.ptr -> i64
%303 = arith.constant 0 : i32
%305 = arith.extsi %303 : i32 to i64
%304 = arith.cmpi sge, %302, %305 : i64
cf.cond_br %304, ^bb73, ^bb74
^bb73:
%306 = arith.constant 2 : i32
%307 = llvm.load %276 : !llvm.ptr -> i64
%309 = arith.extsi %306 : i32 to i64
%308 = arith.muli %309, %307 : i64
%310 = llvm.load %272 : !llvm.ptr -> i64
%311 = arith.subi %308, %310 : i64
%312 = arith.remsi %311, %arg1 : i64
%313 = arith.constant 0 : i32
%315 = arith.extsi %313 : i32 to i64
%314 = arith.cmpi slt, %312, %315 : i64
%316 = scf.if %314 -> (i64) {
%317 = arith.addi %312, %arg1 : i64
scf.yield %317 : i64
} else {
scf.yield %312 : i64
}
%319 = llvm.load %272 : !llvm.ptr -> i64
%318 = func.call @local_mulmod(%319, %316, %arg1) : (i64, i64, i64) -> i64
%321 = llvm.load %272 : !llvm.ptr -> i64
%322 = llvm.load %272 : !llvm.ptr -> i64
%320 = func.call @local_mulmod(%321, %322, %arg1) : (i64, i64, i64) -> i64
%324 = llvm.load %276 : !llvm.ptr -> i64
%325 = llvm.load %276 : !llvm.ptr -> i64
%323 = func.call @local_mulmod(%324, %325, %arg1) : (i64, i64, i64) -> i64
%326 = arith.addi %320, %323 : i64
%327 = arith.remsi %326, %arg1 : i64
%328 = llvm.load %285 : !llvm.ptr -> i64
%329 = arith.shrsi %arg0, %328 : i64
%330 = arith.constant 1 : i32
%332 = arith.extsi %330 : i32 to i64
%331 = arith.andi %329, %332 : i64
%333 = arith.constant 1 : i32
%335 = arith.extsi %333 : i32 to i64
%334 = arith.cmpi eq, %331, %335 : i64
cf.cond_br %334, ^bb75, ^bb76
^bb75:
llvm.store %327, %272 : i64, !llvm.ptr
%336 = arith.addi %318, %327 : i64
%337 = arith.remsi %336, %arg1 : i64
llvm.store %337, %276 : i64, !llvm.ptr
cf.br ^bb77
^bb76:
llvm.store %318, %272 : i64, !llvm.ptr
llvm.store %327, %276 : i64, !llvm.ptr
cf.br ^bb77
^bb77:
%338 = llvm.load %285 : !llvm.ptr -> i64
%339 = arith.constant 1 : i32
%341 = arith.extsi %339 : i32 to i64
%340 = arith.subi %338, %341 : i64
llvm.store %340, %285 : i64, !llvm.ptr
cf.br ^bb72
^bb74:
%342 = llvm.load %272 : !llvm.ptr -> i64
func.return %342 : i64
}
func.func @legendre5(%arg0: i64) -> i64 {
%344 = arith.constant 5 : i32
%345 = arith.constant 1 : i32
%347 = arith.extsi %345 : i32 to i64
%346 = arith.subi %arg0, %347 : i64
%348 = arith.constant 2 : i32
%350 = arith.extsi %348 : i32 to i64
%349 = arith.divsi %346, %350 : i64
%351 = arith.extsi %344 : i32 to i64
%343 = func.call @modpow(%351, %349, %arg0) : (i64, i64, i64) -> i64
%352 = arith.constant 1 : i32
%354 = arith.extsi %352 : i32 to i64
%353 = arith.cmpi eq, %343, %354 : i64
cf.cond_br %353, ^bb78, ^bb79
^bb78:
%355 = arith.constant 1 : i32
%356 = arith.extsi %355 : i32 to i64
func.return %356 : i64
^bb79:
cf.br ^bb80
^bb80:
%357 = arith.constant 0 : i32
%358 = arith.constant 1 : i32
%359 = arith.subi %357, %358 : i32
%360 = arith.extsi %359 : i32 to i64
func.return %360 : i64
}
func.func @main() -> i32 {
%361 = arith.constant 100000000 : i32
%362 = arith.extsi %361 : i32 to i64
%363 = arith.constant 200000000 : i32
%364 = arith.extsi %363 : i32 to i64
%365 = arith.constant 9999995705032704 : i32
%366 = arith.extsi %365 : i32 to i64
%367 = arith.constant 0 : i32
%368 = arith.extsi %367 : i32 to i64
%369 = llvm.mlir.constant(1 : i64) : i64
%370 = llvm.alloca %369 x i64 : (i64) -> !llvm.ptr
llvm.store %368, %370 : i64, !llvm.ptr
%371 = arith.constant 1 : i32
%372 = arith.extsi %371 : i32 to i64
%373 = llvm.mlir.constant(1 : i64) : i64
%374 = llvm.alloca %373 x i64 : (i64) -> !llvm.ptr
llvm.store %372, %374 : i64, !llvm.ptr
%375 = arith.constant 0 : i32
%376 = arith.extsi %375 : i32 to i64
%377 = llvm.mlir.constant(1 : i64) : i64
%378 = llvm.alloca %377 x i64 : (i64) -> !llvm.ptr
llvm.store %376, %378 : i64, !llvm.ptr
%379 = arith.constant 1 : i32
%380 = arith.extsi %379 : i32 to i64
%381 = llvm.mlir.constant(1 : i64) : i64
%382 = llvm.alloca %381 x i64 : (i64) -> !llvm.ptr
llvm.store %380, %382 : i64, !llvm.ptr
cf.br ^bb81
^bb81:
%383 = llvm.load %382 : !llvm.ptr -> i64
%384 = arith.constant 200 : i32
%386 = arith.extsi %384 : i32 to i64
%385 = arith.cmpi slt, %383, %386 : i64
cf.cond_br %385, ^bb82, ^bb83
^bb82:
%387 = llvm.load %370 : !llvm.ptr -> i64
%388 = llvm.load %374 : !llvm.ptr -> i64
%389 = arith.addi %387, %388 : i64
%390 = llvm.load %374 : !llvm.ptr -> i64
llvm.store %390, %370 : i64, !llvm.ptr
llvm.store %389, %374 : i64, !llvm.ptr
%391 = llvm.load %370 : !llvm.ptr -> i64
%392 = llvm.load %382 : !llvm.ptr -> i64
%393 = arith.divsi %364, %392 : i64
%394 = llvm.mlir.constant(1 : i64) : i64
%395 = llvm.alloca %394 x i64 : (i64) -> !llvm.ptr
llvm.store %393, %395 : i64, !llvm.ptr
%396 = llvm.load %395 : !llvm.ptr -> i64
%397 = arith.cmpi slt, %391, %396 : i64
cf.cond_br %397, ^bb84, ^bb85
^bb84:
llvm.store %391, %395 : i64, !llvm.ptr
cf.br ^bb86
^bb85:
cf.br ^bb86
^bb86:
%398 = llvm.load %395 : !llvm.ptr -> i64
%399 = llvm.load %378 : !llvm.ptr -> i64
%400 = arith.cmpi sgt, %398, %399 : i64
cf.cond_br %400, ^bb87, ^bb88
^bb87:
%401 = llvm.load %395 : !llvm.ptr -> i64
llvm.store %401, %378 : i64, !llvm.ptr
cf.br ^bb89
^bb88:
cf.br ^bb89
^bb89:
%402 = llvm.load %382 : !llvm.ptr -> i64
%403 = arith.constant 60 : i32
%405 = arith.extsi %403 : i32 to i64
%404 = arith.cmpi sgt, %402, %405 : i64
%406 = scf.if %404 -> (i1) {
%407 = llvm.load %382 : !llvm.ptr -> i64
%408 = arith.divsi %364, %407 : i64
%409 = llvm.load %378 : !llvm.ptr -> i64
%410 = arith.cmpi sle, %408, %409 : i64
scf.yield %410 : i1
} else {
%411 = arith.constant false
scf.yield %411 : i1
}
cf.cond_br %406, ^bb90, ^bb91
^bb90:
cf.br ^bb83
^bb91:
cf.br ^bb92
^bb92:
%412 = llvm.load %382 : !llvm.ptr -> i64
%413 = arith.constant 1 : i32
%415 = arith.extsi %413 : i32 to i64
%414 = arith.addi %412, %415 : i64
llvm.store %414, %382 : i64, !llvm.ptr
cf.br ^bb81
^bb83:
%416 = llvm.load %378 : !llvm.ptr -> i64
%418 = arith.constant 1 : i32
%420 = arith.extsi %418 : i32 to i64
%419 = arith.addi %416, %420 : i64
%421 = arith.constant 1 : i32
%422 = arith.extsi %421 : i32 to i64
%417 = func.call @calloc(%419, %422) : (i64, i64) -> !llvm.ptr
%424 = arith.constant 5 : i32
%426 = arith.extsi %424 : i32 to i64
%425 = arith.divsi %416, %426 : i64
%427 = arith.constant 10 : i32
%429 = arith.extsi %427 : i32 to i64
%428 = arith.addi %425, %429 : i64
%430 = arith.constant 4 : i32
%431 = arith.extsi %430 : i32 to i64
%423 = func.call @calloc(%428, %431) : (i64, i64) -> !llvm.ptr
%432 = arith.constant 0 : i32
%433 = arith.extsi %432 : i32 to i64
%434 = llvm.mlir.constant(1 : i64) : i64
%435 = llvm.alloca %434 x i64 : (i64) -> !llvm.ptr
llvm.store %433, %435 : i64, !llvm.ptr
%436 = arith.constant 1 : i32
%437 = arith.constant 0 : i32
%438 = arith.trunci %436 : i32 to i8
%439 = arith.extsi %437 : i32 to i64
%440 = llvm.getelementptr %417[%439] : (!llvm.ptr, i64) -> !llvm.ptr, i8
llvm.store %438, %440 : i8, !llvm.ptr
%441 = arith.constant 1 : i32
%442 = arith.constant 1 : i32
%443 = arith.trunci %441 : i32 to i8
%444 = arith.extsi %442 : i32 to i64
%445 = llvm.getelementptr %417[%444] : (!llvm.ptr, i64) -> !llvm.ptr, i8
llvm.store %443, %445 : i8, !llvm.ptr
%446 = arith.constant 2 : i32
%447 = arith.extsi %446 : i32 to i64
%448 = llvm.mlir.constant(1 : i64) : i64
%449 = llvm.alloca %448 x i64 : (i64) -> !llvm.ptr
llvm.store %447, %449 : i64, !llvm.ptr
cf.br ^bb93
^bb93:
%450 = llvm.load %449 : !llvm.ptr -> i64
%451 = arith.cmpi sle, %450, %416 : i64
cf.cond_br %451, ^bb94, ^bb95
^bb94:
%453 = llvm.load %449 : !llvm.ptr -> i64
%454 = llvm.getelementptr %417[%453] : (!llvm.ptr, i64) -> !llvm.ptr, i8
%452 = llvm.load %454 : !llvm.ptr -> i8
%455 = arith.constant 0 : i32
%457 = arith.extsi %452 : i8 to i32
%456 = arith.cmpi eq, %457, %455 : i32
cf.cond_br %456, ^bb96, ^bb97
^bb96:
%458 = llvm.load %449 : !llvm.ptr -> i64
%459 = arith.trunci %458 : i64 to i32
%460 = llvm.load %435 : !llvm.ptr -> i64
%461 = llvm.getelementptr %423[%460] : (!llvm.ptr, i64) -> !llvm.ptr, i32
llvm.store %459, %461 : i32, !llvm.ptr
%462 = llvm.load %435 : !llvm.ptr -> i64
%463 = arith.constant 1 : i32
%465 = arith.extsi %463 : i32 to i64
%464 = arith.addi %462, %465 : i64
llvm.store %464, %435 : i64, !llvm.ptr
%466 = llvm.load %449 : !llvm.ptr -> i64
%467 = llvm.load %449 : !llvm.ptr -> i64
%468 = arith.muli %466, %467 : i64
%469 = llvm.mlir.constant(1 : i64) : i64
%470 = llvm.alloca %469 x i64 : (i64) -> !llvm.ptr
llvm.store %468, %470 : i64, !llvm.ptr
cf.br ^bb99
^bb99:
%471 = llvm.load %470 : !llvm.ptr -> i64
%472 = arith.cmpi sle, %471, %416 : i64
cf.cond_br %472, ^bb100, ^bb101
^bb100:
%473 = arith.constant 1 : i32
%474 = llvm.load %470 : !llvm.ptr -> i64
%475 = arith.trunci %473 : i32 to i8
%476 = llvm.getelementptr %417[%474] : (!llvm.ptr, i64) -> !llvm.ptr, i8
llvm.store %475, %476 : i8, !llvm.ptr
%477 = llvm.load %470 : !llvm.ptr -> i64
%478 = llvm.load %449 : !llvm.ptr -> i64
%479 = arith.addi %477, %478 : i64
llvm.store %479, %470 : i64, !llvm.ptr
cf.br ^bb99
^bb101:
cf.br ^bb98
^bb97:
cf.br ^bb98
^bb98:
%480 = llvm.load %449 : !llvm.ptr -> i64
%481 = arith.constant 1 : i32
%483 = arith.extsi %481 : i32 to i64
%482 = arith.addi %480, %483 : i64
llvm.store %482, %449 : i64, !llvm.ptr
cf.br ^bb93
^bb95:
%484 = func.call @isqrt(%416) : (i64) -> i64
%485 = arith.constant 1 : i32
%487 = arith.extsi %485 : i32 to i64
%486 = arith.addi %484, %487 : i64
%489 = arith.constant 2 : i32
%491 = arith.extsi %489 : i32 to i64
%490 = arith.divsi %486, %491 : i64
%492 = arith.constant 10 : i32
%494 = arith.extsi %492 : i32 to i64
%493 = arith.addi %490, %494 : i64
%495 = arith.constant 4 : i32
%496 = arith.extsi %495 : i32 to i64
%488 = func.call @calloc(%493, %496) : (i64, i64) -> !llvm.ptr
%497 = arith.constant 0 : i32
%498 = arith.extsi %497 : i32 to i64
%499 = llvm.mlir.constant(1 : i64) : i64
%500 = llvm.alloca %499 x i64 : (i64) -> !llvm.ptr
llvm.store %498, %500 : i64, !llvm.ptr
%501 = arith.constant 0 : i32
%502 = arith.extsi %501 : i32 to i64
llvm.store %502, %449 : i64, !llvm.ptr
cf.br ^bb102
^bb102:
%503 = llvm.load %449 : !llvm.ptr -> i64
%504 = llvm.load %435 : !llvm.ptr -> i64
%505 = arith.cmpi slt, %503, %504 : i64
cf.cond_br %505, ^bb103, ^bb104
^bb103:
%507 = llvm.load %449 : !llvm.ptr -> i64
%508 = llvm.getelementptr %423[%507] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%506 = llvm.load %508 : !llvm.ptr -> i32
%509 = arith.extsi %506 : i32 to i64
%510 = arith.cmpi sgt, %509, %486 : i64
cf.cond_br %510, ^bb105, ^bb106
^bb105:
cf.br ^bb104
^bb106:
cf.br ^bb107
^bb107:
%511 = arith.trunci %509 : i64 to i32
%512 = llvm.load %500 : !llvm.ptr -> i64
%513 = llvm.getelementptr %488[%512] : (!llvm.ptr, i64) -> !llvm.ptr, i32
llvm.store %511, %513 : i32, !llvm.ptr
%514 = llvm.load %500 : !llvm.ptr -> i64
%515 = arith.constant 1 : i32
%517 = arith.extsi %515 : i32 to i64
%516 = arith.addi %514, %517 : i64
llvm.store %516, %500 : i64, !llvm.ptr
%518 = llvm.load %449 : !llvm.ptr -> i64
%519 = arith.constant 1 : i32
%521 = arith.extsi %519 : i32 to i64
%520 = arith.addi %518, %521 : i64
llvm.store %520, %449 : i64, !llvm.ptr
cf.br ^bb102
^bb104:
%523 = llvm.load %435 : !llvm.ptr -> i64
%524 = arith.constant 1 : i32
%526 = arith.extsi %524 : i32 to i64
%525 = arith.addi %523, %526 : i64
%527 = arith.constant 8 : i32
%528 = arith.extsi %527 : i32 to i64
%522 = func.call @calloc(%525, %528) : (i64, i64) -> !llvm.ptr
%529 = arith.constant 0 : i32
%530 = arith.extsi %529 : i32 to i64
%531 = llvm.mlir.constant(1 : i64) : i64
%532 = llvm.alloca %531 x i64 : (i64) -> !llvm.ptr
llvm.store %530, %532 : i64, !llvm.ptr
%533 = arith.constant 0 : i32
%534 = arith.extsi %533 : i32 to i64
llvm.store %534, %449 : i64, !llvm.ptr
cf.br ^bb108
^bb108:
%535 = llvm.load %449 : !llvm.ptr -> i64
%536 = llvm.load %435 : !llvm.ptr -> i64
%537 = arith.cmpi slt, %535, %536 : i64
cf.cond_br %537, ^bb109, ^bb110
^bb109:
%539 = llvm.load %449 : !llvm.ptr -> i64
%540 = llvm.getelementptr %423[%539] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%538 = llvm.load %540 : !llvm.ptr -> i32
%541 = arith.extsi %538 : i32 to i64
%542 = arith.constant 0 : i32
%543 = arith.extsi %542 : i32 to i64
%544 = llvm.mlir.constant(1 : i64) : i64
%545 = llvm.alloca %544 x i64 : (i64) -> !llvm.ptr
llvm.store %543, %545 : i64, !llvm.ptr
%546 = arith.constant 2 : i32
%548 = arith.extsi %546 : i32 to i64
%547 = arith.cmpi eq, %541, %548 : i64
cf.cond_br %547, ^bb111, ^bb112
^bb111:
%549 = arith.constant 3 : i32
%550 = arith.extsi %549 : i32 to i64
llvm.store %550, %545 : i64, !llvm.ptr
cf.br ^bb113
^bb112:
%551 = arith.constant 5 : i32
%553 = arith.extsi %551 : i32 to i64
%552 = arith.cmpi eq, %541, %553 : i64
cf.cond_br %552, ^bb115, ^bb114
^bb115:
%554 = arith.constant 5 : i32
%555 = arith.extsi %554 : i32 to i64
llvm.store %555, %545 : i64, !llvm.ptr
cf.br ^bb113
^bb114:
%556 = func.call @legendre5(%541) : (i64) -> i64
%557 = arith.constant 1 : i32
%559 = arith.extsi %557 : i32 to i64
%558 = arith.addi %541, %559 : i64
%560 = llvm.mlir.constant(1 : i64) : i64
%561 = llvm.alloca %560 x i64 : (i64) -> !llvm.ptr
llvm.store %558, %561 : i64, !llvm.ptr
%562 = arith.constant 1 : i32
%564 = arith.extsi %562 : i32 to i64
%563 = arith.cmpi eq, %556, %564 : i64
cf.cond_br %563, ^bb116, ^bb117
^bb116:
%565 = arith.constant 1 : i32
%567 = arith.extsi %565 : i32 to i64
%566 = arith.subi %541, %567 : i64
llvm.store %566, %561 : i64, !llvm.ptr
cf.br ^bb118
^bb117:
cf.br ^bb118
^bb118:
%568 = llvm.load %561 : !llvm.ptr -> i64
%569 = llvm.mlir.constant(1 : i64) : i64
%570 = llvm.alloca %569 x i64 : (i64) -> !llvm.ptr
llvm.store %568, %570 : i64, !llvm.ptr
%571 = llvm.load %561 : !llvm.ptr -> i64
%572 = llvm.mlir.constant(1 : i64) : i64
%573 = llvm.alloca %572 x i64 : (i64) -> !llvm.ptr
llvm.store %571, %573 : i64, !llvm.ptr
%574 = arith.constant 0 : i32
%575 = arith.extsi %574 : i32 to i64
%576 = llvm.mlir.constant(1 : i64) : i64
%577 = llvm.alloca %576 x i64 : (i64) -> !llvm.ptr
llvm.store %575, %577 : i64, !llvm.ptr
cf.br ^bb119
^bb119:
%578 = llvm.load %577 : !llvm.ptr -> i64
%579 = llvm.load %500 : !llvm.ptr -> i64
%580 = arith.cmpi slt, %578, %579 : i64
cf.cond_br %580, ^bb120, ^bb121
^bb120:
%582 = llvm.load %577 : !llvm.ptr -> i64
%583 = llvm.getelementptr %488[%582] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%581 = llvm.load %583 : !llvm.ptr -> i32
%584 = arith.extsi %581 : i32 to i64
%585 = arith.muli %584, %584 : i64
%586 = llvm.load %573 : !llvm.ptr -> i64
%587 = arith.cmpi sgt, %585, %586 : i64
cf.cond_br %587, ^bb122, ^bb123
^bb122:
cf.br ^bb121
^bb123:
cf.br ^bb124
^bb124:
%588 = llvm.load %573 : !llvm.ptr -> i64
%589 = arith.remsi %588, %584 : i64
%590 = arith.constant 0 : i32
%592 = arith.extsi %590 : i32 to i64
%591 = arith.cmpi eq, %589, %592 : i64
cf.cond_br %591, ^bb125, ^bb126
^bb125:
cf.br ^bb128
^bb128:
%593 = llvm.load %570 : !llvm.ptr -> i64
%594 = arith.remsi %593, %584 : i64
%595 = arith.constant 0 : i32
%597 = arith.extsi %595 : i32 to i64
%596 = arith.cmpi eq, %594, %597 : i64
%598 = scf.if %596 -> (i1) {
%600 = llvm.load %570 : !llvm.ptr -> i64
%601 = arith.divsi %600, %584 : i64
%599 = func.call @fib_mod(%601, %541) : (i64, i64) -> i64
%602 = arith.constant 0 : i32
%604 = arith.extsi %602 : i32 to i64
%603 = arith.cmpi eq, %599, %604 : i64
scf.yield %603 : i1
} else {
%605 = arith.constant false
scf.yield %605 : i1
}
cf.cond_br %598, ^bb129, ^bb130
^bb129:
%606 = llvm.load %570 : !llvm.ptr -> i64
%607 = arith.divsi %606, %584 : i64
llvm.store %607, %570 : i64, !llvm.ptr
cf.br ^bb128
^bb130:
cf.br ^bb131
^bb131:
%608 = llvm.load %573 : !llvm.ptr -> i64
%609 = arith.remsi %608, %584 : i64
%610 = arith.constant 0 : i32
%612 = arith.extsi %610 : i32 to i64
%611 = arith.cmpi eq, %609, %612 : i64
cf.cond_br %611, ^bb132, ^bb133
^bb132:
%613 = llvm.load %573 : !llvm.ptr -> i64
%614 = arith.divsi %613, %584 : i64
llvm.store %614, %573 : i64, !llvm.ptr
cf.br ^bb131
^bb133:
cf.br ^bb127
^bb126:
cf.br ^bb127
^bb127:
%615 = llvm.load %577 : !llvm.ptr -> i64
%616 = arith.constant 1 : i32
%618 = arith.extsi %616 : i32 to i64
%617 = arith.addi %615, %618 : i64
llvm.store %617, %577 : i64, !llvm.ptr
cf.br ^bb119
^bb121:
%619 = llvm.load %573 : !llvm.ptr -> i64
%620 = arith.constant 1 : i32
%622 = arith.extsi %620 : i32 to i64
%621 = arith.cmpi sgt, %619, %622 : i64
cf.cond_br %621, ^bb134, ^bb135
^bb134:
cf.br ^bb137
^bb137:
%623 = llvm.load %570 : !llvm.ptr -> i64
%624 = llvm.load %573 : !llvm.ptr -> i64
%625 = arith.remsi %623, %624 : i64
%626 = arith.constant 0 : i32
%628 = arith.extsi %626 : i32 to i64
%627 = arith.cmpi eq, %625, %628 : i64
%629 = scf.if %627 -> (i1) {
%631 = llvm.load %570 : !llvm.ptr -> i64
%632 = llvm.load %573 : !llvm.ptr -> i64
%633 = arith.divsi %631, %632 : i64
%630 = func.call @fib_mod(%633, %541) : (i64, i64) -> i64
%634 = arith.constant 0 : i32
%636 = arith.extsi %634 : i32 to i64
%635 = arith.cmpi eq, %630, %636 : i64
scf.yield %635 : i1
} else {
%637 = arith.constant false
scf.yield %637 : i1
}
cf.cond_br %629, ^bb138, ^bb139
^bb138:
%638 = llvm.load %570 : !llvm.ptr -> i64
%639 = llvm.load %573 : !llvm.ptr -> i64
%640 = arith.divsi %638, %639 : i64
llvm.store %640, %570 : i64, !llvm.ptr
cf.br ^bb137
^bb139:
cf.br ^bb136
^bb135:
cf.br ^bb136
^bb136:
%641 = llvm.load %570 : !llvm.ptr -> i64
llvm.store %641, %545 : i64, !llvm.ptr
cf.br ^bb113
^bb113:
%642 = llvm.load %545 : !llvm.ptr -> i64
%643 = arith.muli %541, %642 : i64
%644 = arith.cmpi sle, %643, %364 : i64
cf.cond_br %644, ^bb140, ^bb141
^bb140:
%645 = llvm.load %532 : !llvm.ptr -> i64
%646 = llvm.getelementptr %522[%645] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %643, %646 : i64, !llvm.ptr
%647 = llvm.load %532 : !llvm.ptr -> i64
%648 = arith.constant 1 : i32
%650 = arith.extsi %648 : i32 to i64
%649 = arith.addi %647, %650 : i64
llvm.store %649, %532 : i64, !llvm.ptr
cf.br ^bb142
^bb141:
cf.br ^bb142
^bb142:
%651 = llvm.load %449 : !llvm.ptr -> i64
%652 = arith.constant 1 : i32
%654 = arith.extsi %652 : i32 to i64
%653 = arith.addi %651, %654 : i64
llvm.store %653, %449 : i64, !llvm.ptr
cf.br ^bb108
^bb110:
%655 = arith.constant 1 : i32
%656 = arith.extsi %655 : i32 to i64
llvm.store %656, %449 : i64, !llvm.ptr
cf.br ^bb143
^bb143:
%657 = llvm.load %449 : !llvm.ptr -> i64
%658 = llvm.load %532 : !llvm.ptr -> i64
%659 = arith.cmpi slt, %657, %658 : i64
cf.cond_br %659, ^bb144, ^bb145
^bb144:
%661 = llvm.load %449 : !llvm.ptr -> i64
%662 = llvm.getelementptr %522[%661] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%660 = llvm.load %662 : !llvm.ptr -> i64
%663 = llvm.load %449 : !llvm.ptr -> i64
%664 = arith.constant 1 : i32
%666 = arith.extsi %664 : i32 to i64
%665 = arith.subi %663, %666 : i64
%667 = llvm.mlir.constant(1 : i64) : i64
%668 = llvm.alloca %667 x i64 : (i64) -> !llvm.ptr
llvm.store %665, %668 : i64, !llvm.ptr
cf.br ^bb146
^bb146:
%669 = llvm.load %668 : !llvm.ptr -> i64
%670 = arith.constant 0 : i32
%672 = arith.extsi %670 : i32 to i64
%671 = arith.cmpi sge, %669, %672 : i64
%673 = scf.if %671 -> (i1) {
%675 = llvm.load %668 : !llvm.ptr -> i64
%676 = llvm.getelementptr %522[%675] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%674 = llvm.load %676 : !llvm.ptr -> i64
%677 = arith.cmpi sgt, %674, %660 : i64
scf.yield %677 : i1
} else {
%678 = arith.constant false
scf.yield %678 : i1
}
cf.cond_br %673, ^bb147, ^bb148
^bb147:
%680 = llvm.load %668 : !llvm.ptr -> i64
%681 = llvm.getelementptr %522[%680] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%679 = llvm.load %681 : !llvm.ptr -> i64
%682 = llvm.load %668 : !llvm.ptr -> i64
%683 = arith.constant 1 : i32
%685 = arith.extsi %683 : i32 to i64
%684 = arith.addi %682, %685 : i64
%686 = llvm.getelementptr %522[%684] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %679, %686 : i64, !llvm.ptr
%687 = llvm.load %668 : !llvm.ptr -> i64
%688 = arith.constant 1 : i32
%690 = arith.extsi %688 : i32 to i64
%689 = arith.subi %687, %690 : i64
llvm.store %689, %668 : i64, !llvm.ptr
cf.br ^bb146
^bb148:
%691 = llvm.load %668 : !llvm.ptr -> i64
%692 = arith.constant 1 : i32
%694 = arith.extsi %692 : i32 to i64
%693 = arith.addi %691, %694 : i64
%695 = llvm.getelementptr %522[%693] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %660, %695 : i64, !llvm.ptr
%696 = llvm.load %449 : !llvm.ptr -> i64
%697 = arith.constant 1 : i32
%699 = arith.extsi %697 : i32 to i64
%698 = arith.addi %696, %699 : i64
llvm.store %698, %449 : i64, !llvm.ptr
cf.br ^bb143
^bb145:
%701 = llvm.load %532 : !llvm.ptr -> i64
%702 = arith.constant 1 : i32
%704 = arith.extsi %702 : i32 to i64
%703 = arith.addi %701, %704 : i64
%705 = arith.constant 8 : i32
%706 = arith.extsi %705 : i32 to i64
%700 = func.call @calloc(%703, %706) : (i64, i64) -> !llvm.ptr
%707 = arith.constant 0 : i32
%708 = arith.extsi %707 : i32 to i64
%709 = llvm.mlir.constant(1 : i64) : i64
%710 = llvm.alloca %709 x i64 : (i64) -> !llvm.ptr
llvm.store %708, %710 : i64, !llvm.ptr
%711 = arith.constant 0 : i32
%712 = arith.extsi %711 : i32 to i64
llvm.store %712, %449 : i64, !llvm.ptr
cf.br ^bb149
^bb149:
%713 = llvm.load %449 : !llvm.ptr -> i64
%714 = llvm.load %532 : !llvm.ptr -> i64
%715 = arith.cmpi slt, %713, %714 : i64
cf.cond_br %715, ^bb150, ^bb151
^bb150:
%717 = llvm.load %449 : !llvm.ptr -> i64
%718 = llvm.getelementptr %522[%717] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%716 = llvm.load %718 : !llvm.ptr -> i64
%719 = arith.constant 0 : i32
%720 = arith.extsi %719 : i32 to i64
%721 = llvm.mlir.constant(1 : i64) : i64
%722 = llvm.alloca %721 x i64 : (i64) -> !llvm.ptr
llvm.store %720, %722 : i64, !llvm.ptr
%723 = arith.constant 0 : i32
%724 = arith.extsi %723 : i32 to i64
%725 = llvm.mlir.constant(1 : i64) : i64
%726 = llvm.alloca %725 x i64 : (i64) -> !llvm.ptr
llvm.store %724, %726 : i64, !llvm.ptr
cf.br ^bb152
^bb152:
%727 = llvm.load %726 : !llvm.ptr -> i64
%728 = llvm.load %710 : !llvm.ptr -> i64
%729 = arith.cmpi slt, %727, %728 : i64
cf.cond_br %729, ^bb153, ^bb154
^bb153:
%731 = llvm.load %726 : !llvm.ptr -> i64
%732 = llvm.getelementptr %700[%731] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%730 = llvm.load %732 : !llvm.ptr -> i64
%733 = arith.remsi %716, %730 : i64
%734 = arith.constant 0 : i32
%736 = arith.extsi %734 : i32 to i64
%735 = arith.cmpi eq, %733, %736 : i64
cf.cond_br %735, ^bb155, ^bb156
^bb155:
%737 = arith.constant 1 : i32
%738 = arith.extsi %737 : i32 to i64
llvm.store %738, %722 : i64, !llvm.ptr
cf.br ^bb154
^bb156:
cf.br ^bb157
^bb157:
%739 = llvm.load %726 : !llvm.ptr -> i64
%740 = arith.constant 1 : i32
%742 = arith.extsi %740 : i32 to i64
%741 = arith.addi %739, %742 : i64
llvm.store %741, %726 : i64, !llvm.ptr
cf.br ^bb152
^bb154:
%743 = llvm.load %722 : !llvm.ptr -> i64
%744 = arith.constant 0 : i32
%746 = arith.extsi %744 : i32 to i64
%745 = arith.cmpi eq, %743, %746 : i64
cf.cond_br %745, ^bb158, ^bb159
^bb158:
%747 = llvm.load %710 : !llvm.ptr -> i64
%748 = llvm.getelementptr %700[%747] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %716, %748 : i64, !llvm.ptr
%749 = llvm.load %710 : !llvm.ptr -> i64
%750 = arith.constant 1 : i32
%752 = arith.extsi %750 : i32 to i64
%751 = arith.addi %749, %752 : i64
llvm.store %751, %710 : i64, !llvm.ptr
cf.br ^bb160
^bb159:
cf.br ^bb160
^bb160:
%753 = llvm.load %449 : !llvm.ptr -> i64
%754 = arith.constant 1 : i32
%756 = arith.extsi %754 : i32 to i64
%755 = arith.addi %753, %756 : i64
llvm.store %755, %449 : i64, !llvm.ptr
cf.br ^bb149
^bb151:
%757 = arith.constant 1 : i32
%758 = arith.constant 20 : i32
%759 = arith.shli %757, %758 : i32
%760 = arith.extsi %759 : i32 to i64
%762 = arith.constant 8 : i32
%763 = arith.extsi %762 : i32 to i64
%761 = func.call @calloc(%760, %763) : (i64, i64) -> !llvm.ptr
%765 = arith.constant 8 : i32
%766 = arith.extsi %765 : i32 to i64
%764 = func.call @calloc(%760, %766) : (i64, i64) -> !llvm.ptr
%768 = arith.constant 1 : i32
%769 = arith.extsi %768 : i32 to i64
%767 = func.call @calloc(%760, %769) : (i64, i64) -> !llvm.ptr
%770 = arith.constant 1 : i32
%771 = arith.constant 1 : i32
%773 = arith.extsi %771 : i32 to i64
%772 = arith.subi %760, %773 : i64
%775 = arith.extsi %770 : i32 to i64
%774 = arith.andi %775, %772 : i64
%776 = llvm.mlir.constant(1 : i64) : i64
%777 = llvm.alloca %776 x i64 : (i64) -> !llvm.ptr
llvm.store %774, %777 : i64, !llvm.ptr
%778 = arith.constant 1 : i32
%779 = llvm.load %777 : !llvm.ptr -> i64
%780 = arith.trunci %778 : i32 to i8
%781 = llvm.getelementptr %767[%779] : (!llvm.ptr, i64) -> !llvm.ptr, i8
llvm.store %780, %781 : i8, !llvm.ptr
%782 = arith.constant 1 : i32
%783 = llvm.load %777 : !llvm.ptr -> i64
%784 = arith.extsi %782 : i32 to i64
%785 = llvm.getelementptr %761[%783] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %784, %785 : i64, !llvm.ptr
%786 = arith.constant 1 : i32
%787 = llvm.load %777 : !llvm.ptr -> i64
%788 = arith.extsi %786 : i32 to i64
%789 = llvm.getelementptr %764[%787] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %788, %789 : i64, !llvm.ptr
%790 = arith.constant 100000 : i32
%791 = arith.extsi %790 : i32 to i64
%793 = arith.constant 4 : i32
%794 = arith.extsi %793 : i32 to i64
%792 = func.call @calloc(%791, %794) : (i64, i64) -> !llvm.ptr
%796 = arith.constant 8 : i32
%797 = arith.extsi %796 : i32 to i64
%795 = func.call @calloc(%791, %797) : (i64, i64) -> !llvm.ptr
%799 = arith.constant 1 : i32
%800 = arith.extsi %799 : i32 to i64
%798 = func.call @calloc(%791, %800) : (i64, i64) -> !llvm.ptr
%801 = arith.constant 0 : i32
%802 = arith.constant 0 : i32
%803 = arith.extsi %802 : i32 to i64
%804 = llvm.getelementptr %792[%803] : (!llvm.ptr, i64) -> !llvm.ptr, i32
llvm.store %801, %804 : i32, !llvm.ptr
%805 = arith.constant 1 : i32
%806 = arith.constant 0 : i32
%807 = arith.extsi %805 : i32 to i64
%808 = arith.extsi %806 : i32 to i64
%809 = llvm.getelementptr %795[%808] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %807, %809 : i64, !llvm.ptr
%810 = arith.constant 1 : i32
%811 = arith.constant 0 : i32
%812 = arith.trunci %810 : i32 to i8
%813 = arith.extsi %811 : i32 to i64
%814 = llvm.getelementptr %798[%813] : (!llvm.ptr, i64) -> !llvm.ptr, i8
llvm.store %812, %814 : i8, !llvm.ptr
%815 = arith.constant 1 : i32
%816 = arith.extsi %815 : i32 to i64
%817 = llvm.mlir.constant(1 : i64) : i64
%818 = llvm.alloca %817 x i64 : (i64) -> !llvm.ptr
llvm.store %816, %818 : i64, !llvm.ptr
cf.br ^bb161
^bb161:
%819 = llvm.load %818 : !llvm.ptr -> i64
%820 = arith.constant 0 : i32
%822 = arith.extsi %820 : i32 to i64
%821 = arith.cmpi sgt, %819, %822 : i64
cf.cond_br %821, ^bb162, ^bb163
^bb162:
%823 = llvm.load %818 : !llvm.ptr -> i64
%824 = arith.constant 1 : i32
%826 = arith.extsi %824 : i32 to i64
%825 = arith.subi %823, %826 : i64
llvm.store %825, %818 : i64, !llvm.ptr
%828 = llvm.load %818 : !llvm.ptr -> i64
%829 = llvm.getelementptr %792[%828] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%827 = llvm.load %829 : !llvm.ptr -> i32
%830 = arith.extsi %827 : i32 to i64
%832 = llvm.load %818 : !llvm.ptr -> i64
%833 = llvm.getelementptr %795[%832] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%831 = llvm.load %833 : !llvm.ptr -> i64
%835 = llvm.load %818 : !llvm.ptr -> i64
%836 = llvm.getelementptr %798[%835] : (!llvm.ptr, i64) -> !llvm.ptr, i8
%834 = llvm.load %836 : !llvm.ptr -> i8
%837 = arith.extsi %834 : i8 to i64
%838 = llvm.mlir.constant(1 : i64) : i64
%839 = llvm.alloca %838 x i64 : (i64) -> !llvm.ptr
llvm.store %830, %839 : i64, !llvm.ptr
cf.br ^bb164
^bb164:
%840 = llvm.load %839 : !llvm.ptr -> i64
%841 = llvm.load %710 : !llvm.ptr -> i64
%842 = arith.cmpi slt, %840, %841 : i64
cf.cond_br %842, ^bb165, ^bb166
^bb165:
%844 = llvm.load %839 : !llvm.ptr -> i64
%845 = llvm.getelementptr %700[%844] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%843 = llvm.load %845 : !llvm.ptr -> i64
%846 = arith.remsi %831, %843 : i64
%847 = arith.constant 0 : i32
%849 = arith.extsi %847 : i32 to i64
%848 = arith.cmpi ne, %846, %849 : i64
cf.cond_br %848, ^bb167, ^bb168
^bb167:
%850 = func.call @gcd_abs(%831, %843) : (i64, i64) -> i64
%851 = arith.divsi %831, %850 : i64
%852 = arith.muli %851, %843 : i64
%853 = arith.cmpi sle, %852, %364 : i64
cf.cond_br %853, ^bb170, ^bb171
^bb170:
%854 = arith.constant 0 : i32
%856 = arith.extsi %854 : i32 to i64
%855 = arith.subi %856, %837 : i64
%857 = llvm.mlir.constant(1 : i64) : i64
%858 = llvm.alloca %857 x i64 : (i64) -> !llvm.ptr
llvm.store %852, %858 : i64, !llvm.ptr
%859 = llvm.load %858 : !llvm.ptr -> i64
%860 = arith.constant 0 : i32
%862 = arith.extsi %860 : i32 to i64
%861 = arith.cmpi slt, %859, %862 : i64
cf.cond_br %861, ^bb173, ^bb174
^bb173:
%863 = arith.constant 0 : i32
%864 = llvm.load %858 : !llvm.ptr -> i64
%866 = arith.extsi %863 : i32 to i64
%865 = arith.subi %866, %864 : i64
llvm.store %865, %858 : i64, !llvm.ptr
cf.br ^bb175
^bb174:
cf.br ^bb175
^bb175:
%867 = llvm.load %858 : !llvm.ptr -> i64
%868 = arith.constant 1 : i32
%870 = arith.extsi %868 : i32 to i64
%869 = arith.subi %760, %870 : i64
%871 = arith.andi %867, %869 : i64
llvm.store %871, %777 : i64, !llvm.ptr
cf.br ^bb176
^bb176:
%873 = llvm.load %777 : !llvm.ptr -> i64
%874 = llvm.getelementptr %767[%873] : (!llvm.ptr, i64) -> !llvm.ptr, i8
%872 = llvm.load %874 : !llvm.ptr -> i8
%875 = arith.constant 0 : i32
%877 = arith.extsi %872 : i8 to i32
%876 = arith.cmpi ne, %877, %875 : i32
%878 = scf.if %876 -> (i1) {
%880 = llvm.load %777 : !llvm.ptr -> i64
%881 = llvm.getelementptr %761[%880] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%879 = llvm.load %881 : !llvm.ptr -> i64
%882 = arith.cmpi ne, %879, %852 : i64
scf.yield %882 : i1
} else {
%883 = arith.constant false
scf.yield %883 : i1
}
cf.cond_br %878, ^bb177, ^bb178
^bb177:
%884 = llvm.load %777 : !llvm.ptr -> i64
%885 = arith.constant 1 : i32
%887 = arith.extsi %885 : i32 to i64
%886 = arith.addi %884, %887 : i64
%888 = arith.constant 1 : i32
%890 = arith.extsi %888 : i32 to i64
%889 = arith.subi %760, %890 : i64
%891 = arith.andi %886, %889 : i64
llvm.store %891, %777 : i64, !llvm.ptr
cf.br ^bb176
^bb178:
%893 = llvm.load %777 : !llvm.ptr -> i64
%894 = llvm.getelementptr %767[%893] : (!llvm.ptr, i64) -> !llvm.ptr, i8
%892 = llvm.load %894 : !llvm.ptr -> i8
%895 = arith.constant 0 : i32
%897 = arith.extsi %892 : i8 to i32
%896 = arith.cmpi eq, %897, %895 : i32
cf.cond_br %896, ^bb179, ^bb180
^bb179:
%898 = arith.constant 1 : i32
%899 = llvm.load %777 : !llvm.ptr -> i64
%900 = arith.trunci %898 : i32 to i8
%901 = llvm.getelementptr %767[%899] : (!llvm.ptr, i64) -> !llvm.ptr, i8
llvm.store %900, %901 : i8, !llvm.ptr
%902 = llvm.load %777 : !llvm.ptr -> i64
%903 = llvm.getelementptr %761[%902] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %852, %903 : i64, !llvm.ptr
%904 = llvm.load %777 : !llvm.ptr -> i64
%905 = llvm.getelementptr %764[%904] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %855, %905 : i64, !llvm.ptr
cf.br ^bb181
^bb180:
%907 = llvm.load %777 : !llvm.ptr -> i64
%908 = llvm.getelementptr %764[%907] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%906 = llvm.load %908 : !llvm.ptr -> i64
%909 = arith.addi %906, %855 : i64
%910 = llvm.load %777 : !llvm.ptr -> i64
%911 = llvm.getelementptr %764[%910] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %909, %911 : i64, !llvm.ptr
cf.br ^bb181
^bb181:
%912 = llvm.load %839 : !llvm.ptr -> i64
%913 = arith.constant 1 : i32
%915 = arith.extsi %913 : i32 to i64
%914 = arith.addi %912, %915 : i64
%916 = arith.trunci %914 : i64 to i32
%917 = llvm.load %818 : !llvm.ptr -> i64
%918 = llvm.getelementptr %792[%917] : (!llvm.ptr, i64) -> !llvm.ptr, i32
llvm.store %916, %918 : i32, !llvm.ptr
%919 = llvm.load %818 : !llvm.ptr -> i64
%920 = llvm.getelementptr %795[%919] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %852, %920 : i64, !llvm.ptr
%921 = arith.trunci %855 : i64 to i8
%922 = llvm.load %818 : !llvm.ptr -> i64
%923 = llvm.getelementptr %798[%922] : (!llvm.ptr, i64) -> !llvm.ptr, i8
llvm.store %921, %923 : i8, !llvm.ptr
%924 = llvm.load %818 : !llvm.ptr -> i64
%925 = arith.constant 1 : i32
%927 = arith.extsi %925 : i32 to i64
%926 = arith.addi %924, %927 : i64
llvm.store %926, %818 : i64, !llvm.ptr
cf.br ^bb172
^bb171:
cf.br ^bb172
^bb172:
cf.br ^bb169
^bb168:
cf.br ^bb169
^bb169:
%928 = llvm.load %839 : !llvm.ptr -> i64
%929 = arith.constant 1 : i32
%931 = arith.extsi %929 : i32 to i64
%930 = arith.addi %928, %931 : i64
llvm.store %930, %839 : i64, !llvm.ptr
cf.br ^bb164
^bb166:
cf.br ^bb161
^bb163:
%933 = arith.constant 8 : i32
%934 = arith.extsi %933 : i32 to i64
%932 = func.call @calloc(%760, %934) : (i64, i64) -> !llvm.ptr
%936 = arith.constant 8 : i32
%937 = arith.extsi %936 : i32 to i64
%935 = func.call @calloc(%760, %937) : (i64, i64) -> !llvm.ptr
%938 = arith.constant 0 : i32
%939 = arith.extsi %938 : i32 to i64
%940 = llvm.mlir.constant(1 : i64) : i64
%941 = llvm.alloca %940 x i64 : (i64) -> !llvm.ptr
llvm.store %939, %941 : i64, !llvm.ptr
%942 = arith.constant 0 : i32
%943 = arith.extsi %942 : i32 to i64
llvm.store %943, %449 : i64, !llvm.ptr
cf.br ^bb182
^bb182:
%944 = llvm.load %449 : !llvm.ptr -> i64
%945 = arith.cmpi slt, %944, %760 : i64
cf.cond_br %945, ^bb183, ^bb184
^bb183:
%947 = llvm.load %449 : !llvm.ptr -> i64
%948 = llvm.getelementptr %767[%947] : (!llvm.ptr, i64) -> !llvm.ptr, i8
%946 = llvm.load %948 : !llvm.ptr -> i8
%949 = arith.constant 0 : i32
%951 = arith.extsi %946 : i8 to i32
%950 = arith.cmpi ne, %951, %949 : i32
%952 = scf.if %950 -> (i1) {
%954 = llvm.load %449 : !llvm.ptr -> i64
%955 = llvm.getelementptr %764[%954] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%953 = llvm.load %955 : !llvm.ptr -> i64
%956 = arith.constant 0 : i32
%958 = arith.extsi %956 : i32 to i64
%957 = arith.cmpi ne, %953, %958 : i64
scf.yield %957 : i1
} else {
%959 = arith.constant false
scf.yield %959 : i1
}
cf.cond_br %952, ^bb185, ^bb186
^bb185:
%961 = llvm.load %449 : !llvm.ptr -> i64
%962 = llvm.getelementptr %761[%961] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%960 = llvm.load %962 : !llvm.ptr -> i64
%963 = llvm.load %941 : !llvm.ptr -> i64
%964 = llvm.getelementptr %932[%963] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %960, %964 : i64, !llvm.ptr
%966 = llvm.load %449 : !llvm.ptr -> i64
%967 = llvm.getelementptr %764[%966] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%965 = llvm.load %967 : !llvm.ptr -> i64
%968 = llvm.load %941 : !llvm.ptr -> i64
%969 = llvm.getelementptr %935[%968] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %965, %969 : i64, !llvm.ptr
%970 = llvm.load %941 : !llvm.ptr -> i64
%971 = arith.constant 1 : i32
%973 = arith.extsi %971 : i32 to i64
%972 = arith.addi %970, %973 : i64
llvm.store %972, %941 : i64, !llvm.ptr
cf.br ^bb187
^bb186:
cf.br ^bb187
^bb187:
%974 = llvm.load %449 : !llvm.ptr -> i64
%975 = arith.constant 1 : i32
%977 = arith.extsi %975 : i32 to i64
%976 = arith.addi %974, %977 : i64
llvm.store %976, %449 : i64, !llvm.ptr
cf.br ^bb182
^bb184:
%978 = arith.constant 1 : i32
%979 = arith.extsi %978 : i32 to i64
%980 = llvm.mlir.constant(1 : i64) : i64
%981 = llvm.alloca %980 x i64 : (i64) -> !llvm.ptr
llvm.store %979, %981 : i64, !llvm.ptr
%982 = llvm.mlir.constant(1 : i64) : i64
%983 = llvm.alloca %982 x i64 : (i64) -> !llvm.ptr
llvm.store %364, %983 : i64, !llvm.ptr
cf.br ^bb188
^bb188:
%984 = llvm.load %981 : !llvm.ptr -> i64
%985 = llvm.load %983 : !llvm.ptr -> i64
%986 = arith.cmpi slt, %984, %985 : i64
cf.cond_br %986, ^bb189, ^bb190
^bb189:
%987 = llvm.load %981 : !llvm.ptr -> i64
%988 = llvm.load %983 : !llvm.ptr -> i64
%989 = arith.addi %987, %988 : i64
%990 = arith.constant 2 : i32
%992 = arith.extsi %990 : i32 to i64
%991 = arith.divsi %989, %992 : i64
%993 = arith.constant 0 : i32
%994 = arith.extsi %993 : i32 to i64
%995 = llvm.mlir.constant(1 : i64) : i64
%996 = llvm.alloca %995 x i64 : (i64) -> !llvm.ptr
llvm.store %994, %996 : i64, !llvm.ptr
%997 = arith.constant 0 : i32
%998 = arith.extsi %997 : i32 to i64
llvm.store %998, %449 : i64, !llvm.ptr
cf.br ^bb191
^bb191:
%999 = llvm.load %449 : !llvm.ptr -> i64
%1000 = llvm.load %941 : !llvm.ptr -> i64
%1001 = arith.cmpi slt, %999, %1000 : i64
cf.cond_br %1001, ^bb192, ^bb193
^bb192:
%1002 = llvm.load %996 : !llvm.ptr -> i64
%1004 = llvm.load %449 : !llvm.ptr -> i64
%1005 = llvm.getelementptr %935[%1004] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%1003 = llvm.load %1005 : !llvm.ptr -> i64
%1007 = llvm.load %449 : !llvm.ptr -> i64
%1008 = llvm.getelementptr %932[%1007] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%1006 = llvm.load %1008 : !llvm.ptr -> i64
%1009 = arith.divsi %991, %1006 : i64
%1010 = arith.muli %1003, %1009 : i64
%1011 = arith.addi %1002, %1010 : i64
llvm.store %1011, %996 : i64, !llvm.ptr
%1012 = llvm.load %449 : !llvm.ptr -> i64
%1013 = arith.constant 1 : i32
%1015 = arith.extsi %1013 : i32 to i64
%1014 = arith.addi %1012, %1015 : i64
llvm.store %1014, %449 : i64, !llvm.ptr
cf.br ^bb191
^bb193:
%1016 = llvm.load %996 : !llvm.ptr -> i64
%1017 = arith.cmpi sge, %1016, %362 : i64
cf.cond_br %1017, ^bb194, ^bb195
^bb194:
llvm.store %991, %983 : i64, !llvm.ptr
cf.br ^bb196
^bb195:
%1018 = arith.constant 1 : i32
%1020 = arith.extsi %1018 : i32 to i64
%1019 = arith.addi %991, %1020 : i64
llvm.store %1019, %981 : i64, !llvm.ptr
cf.br ^bb196
^bb196:
cf.br ^bb188
^bb190:
%1021 = llvm.load %981 : !llvm.ptr -> i64
%1022 = func.call @fib_mod(%1021, %366) : (i64, i64) -> i64
%1023 = arith.constant 1.0 : f32
%1025 = arith.constant 5.0 : f32
%1026 = arith.constant 0.5 : f32
%1027 = arith.extf %1025 : f32 to f64
%1028 = arith.extf %1026 : f32 to f64
%1024 = func.call @pow(%1027, %1028) : (f64, f64) -> f64
%1030 = arith.extf %1023 : f32 to f64
%1029 = arith.addf %1030, %1024 : f64
%1031 = arith.constant 2.0 : f32
%1033 = arith.extf %1031 : f32 to f64
%1032 = arith.divf %1029, %1033 : f64
%1034 = arith.sitofp %1021 : i64 to f64
%1035 = func.call @flog10(%1032) : (f64) -> f64
%1036 = arith.mulf %1034, %1035 : f64
%1037 = arith.constant 0.5 : f32
%1039 = arith.constant 5.0 : f32
%1040 = arith.extf %1039 : f32 to f64
%1038 = func.call @flog10(%1040) : (f64) -> f64
%1042 = arith.extf %1037 : f32 to f64
%1041 = arith.mulf %1042, %1038 : f64
%1043 = arith.subf %1036, %1041 : f64
%1044 = func.call @floor(%1043) : (f64) -> f64
%1045 = arith.fptosi %1044 : f64 to i64
%1046 = llvm.mlir.constant(1 : i64) : i64
%1047 = llvm.alloca %1046 x i64 : (i64) -> !llvm.ptr
llvm.store %1045, %1047 : i64, !llvm.ptr
%1049 = arith.constant 10.0 : f32
%1050 = llvm.load %1047 : !llvm.ptr -> i64
%1051 = arith.sitofp %1050 : i64 to f64
%1052 = arith.subf %1043, %1051 : f64
%1053 = arith.extf %1049 : f32 to f64
%1048 = func.call @pow(%1053, %1052) : (f64, f64) -> f64
%1054 = llvm.mlir.constant(1 : i64) : i64
%1055 = llvm.alloca %1054 x f64 : (i64) -> !llvm.ptr
llvm.store %1048, %1055 : f64, !llvm.ptr
%1057 = llvm.load %1055 : !llvm.ptr -> f64
%1058 = arith.constant 10.0 : f32
%1060 = arith.extf %1058 : f32 to f64
%1059 = arith.mulf %1057, %1060 : f64
%1061 = arith.constant 0.5 : f32
%1063 = arith.extf %1061 : f32 to f64
%1062 = arith.addf %1059, %1063 : f64
%1056 = func.call @floor(%1062) : (f64) -> f64
%1064 = arith.constant 10.0 : f32
%1066 = arith.extf %1064 : f32 to f64
%1065 = arith.divf %1056, %1066 : f64
%1067 = llvm.mlir.constant(1 : i64) : i64
%1068 = llvm.alloca %1067 x f64 : (i64) -> !llvm.ptr
llvm.store %1065, %1068 : f64, !llvm.ptr
%1069 = llvm.load %1068 : !llvm.ptr -> f64
%1070 = arith.constant 10.0 : f32
%1072 = arith.extf %1070 : f32 to f64
%1071 = arith.cmpf oge, %1069, %1072 : f64
cf.cond_br %1071, ^bb197, ^bb198
^bb197:
%1073 = arith.constant 1.0 : f32
%1074 = arith.extf %1073 : f32 to f64
llvm.store %1074, %1068 : f64, !llvm.ptr
%1075 = llvm.load %1047 : !llvm.ptr -> i64
%1076 = arith.constant 1 : i32
%1078 = arith.extsi %1076 : i32 to i64
%1077 = arith.addi %1075, %1078 : i64
llvm.store %1077, %1047 : i64, !llvm.ptr
cf.br ^bb199
^bb198:
cf.br ^bb199
^bb199:
%1079 = llvm.mlir.addressof @str_0 : !llvm.ptr
%1080 = llvm.load %1068 : !llvm.ptr -> f64
%1081 = llvm.load %1047 : !llvm.ptr -> i64
%1082 = llvm.call @printf(%1079, %1022, %1080, %1081) vararg(!llvm.func<i32 (ptr, ...)>) : (!llvm.ptr, i64, f64, i64) -> i32
%1083 = arith.constant 0 : i32
func.return %1083 : i32
}
}