Problem 362
S(10^10): sum of squarefree-factorization counts via Lehler pi.
View problem on Project Euler
Performance comparison
| Metric | Our solution | Best known |
| Time complexity | O(n^2) | O(sqrt(n)) |
| Space complexity | O(n^2) | O(1) |
| Approach | Flow solution | Trial division or Pollard rho |
| Verdict | Suboptimal |
Flow source
# Project Euler 362
# S(10^10): sum of squarefree-factorization counts via Lehler pi.
import euler.nt { isqrt }
extern {
function calloc(n: i64, size: i64) -> ptr<void>
function free(p: ptr<void>) -> void
}
function iroot(n: i64, k: i64) -> i64 {
if k == 1 { return n }
if n <= 0 { return 0 }
let mut lo: i64 = 1
let mut hi: i64 = n
if k >= 2 {
hi = isqrt(n) + 1
}
if k >= 3 {
hi = iroot(n, k - 1) + 1
}
if hi > n { hi = n }
while lo + 1 < hi {
let mid: i64 = (lo + hi) / 2
let mut p: i64 = 1
let mut ok: i64 = 1
let mut i: i64 = 0
while i < k {
if mid != 0 && p > n / mid {
ok = 0
break
}
p = p * mid
i = i + 1
}
if ok == 1 && p <= n {
lo = mid
} else {
hi = mid
}
}
return lo
}
function ipow(base: i64, exp: i64) -> i64 {
let mut r: i64 = 1
let mut b: i64 = base
let mut e: i64 = exp
while e > 0 {
if (e & 1) == 1 { r = r * b }
b = b * b
e = e / 2
}
return r
}
function hget(keys: ptr<i64>, vals: ptr<i64>, used: ptr<i8>, cap: i64, key: i64) -> i64 {
let mut slot: i64 = key
if slot < 0 { slot = 0 - slot }
slot = slot & (cap - 1)
while used[slot] != 0 {
if keys[slot] == key { return vals[slot] }
slot = (slot + 1) & (cap - 1)
}
return 0 - 1
}
function hput(keys: ptr<i64>, vals: ptr<i64>, used: ptr<i8>, cap: i64, key: i64, val: i64) -> void {
let mut slot: i64 = key
if slot < 0 { slot = 0 - slot }
slot = slot & (cap - 1)
while used[slot] != 0 && keys[slot] != key {
slot = (slot + 1) & (cap - 1)
}
used[slot] = 1
keys[slot] = key
vals[slot] = val
}
# Global-ish via parameters: primes, pi_small, caches
function phi(x: i64, s: i64, primes: ptr<i32>,
phik: ptr<i64>, phiv: ptr<i64>, phiu: ptr<i8>, phic: i64) -> i64 {
if s == 0 { return x }
if s == 1 { return x - x / 2 }
if s == 2 { return x - x / 2 - x / 3 + x / 6 }
if x == 0 { return 0 }
if x < 10000 {
let key: i64 = x * 1000003 + s
let hit: i64 = hget(phik, phiv, phiu, phic, key)
if hit >= 0 { return hit }
let v: i64 = phi(x, s - 1, primes, phik, phiv, phiu, phic) - phi(x / (primes[s - 1] as i64), s - 1, primes, phik, phiv, phiu, phic)
hput(phik, phiv, phiu, phic, key, v)
return v
}
return phi(x, s - 1, primes, phik, phiv, phiu, phic) - phi(x / (primes[s - 1] as i64), s - 1, primes, phik, phiv, phiu, phic)
}
function pi_lehmer(x: i64, primes: ptr<i32>, pc: i64, pi_small: ptr<i32>, SIEVE: i64,
phik: ptr<i64>, phiv: ptr<i64>, phiu: ptr<i8>, phic: i64,
pik: ptr<i64>, piv: ptr<i64>, piu: ptr<i8>, pic: i64) -> i64 {
if x < SIEVE { return pi_small[x] as i64 }
if x < 2 { return 0 }
let hit: i64 = hget(pik, piv, piu, pic, x)
if hit >= 0 { return hit }
let a: i64 = pi_lehmer(iroot(x, 4), primes, pc, pi_small, SIEVE, phik, phiv, phiu, phic, pik, piv, piu, pic)
let b: i64 = pi_lehmer(isqrt(x), primes, pc, pi_small, SIEVE, phik, phiv, phiu, phic, pik, piv, piu, pic)
let c: i64 = pi_lehmer(iroot(x, 3), primes, pc, pi_small, SIEVE, phik, phiv, phiu, phic, pik, piv, piu, pic)
let mut res: i64 = phi(x, a, primes, phik, phiv, phiu, phic) + ((b + a - 2) * (b - a + 1)) / 2
let mut i: i64 = a
while i < b {
let w: i64 = x / (primes[i] as i64)
res = res - pi_lehmer(w, primes, pc, pi_small, SIEVE, phik, phiv, phiu, phic, pik, piv, piu, pic)
if i < c {
let lim: i64 = pi_lehmer(isqrt(w), primes, pc, pi_small, SIEVE, phik, phiv, phiu, phic, pik, piv, piu, pic)
let mut j: i64 = i
while j < lim {
res = res - (pi_lehmer(w / (primes[j] as i64), primes, pc, pi_small, SIEVE, phik, phiv, phiu, phic, pik, piv, piu, pic) - j)
j = j + 1
}
}
i = i + 1
}
hput(pik, piv, piu, pic, x, res)
return res
}
function prime_pi(x: i64, primes: ptr<i32>, pc: i64, pi_small: ptr<i32>, SIEVE: i64,
phik: ptr<i64>, phiv: ptr<i64>, phiu: ptr<i8>, phic: i64,
pik: ptr<i64>, piv: ptr<i64>, piu: ptr<i8>, pic: i64) -> i64 {
if x < SIEVE { return pi_small[x] as i64 }
return pi_lehmer(x, primes, pc, pi_small, SIEVE, phik, phiv, phiu, phic, pik, piv, piu, pic)
}
function fsf_from_exps(exps: ptr<i32>, k: i64, bell: ptr<i64>) -> i64 {
if k == 0 { return 0 }
if k == 1 { return 1 }
let mut all1: i64 = 1
let mut i: i64 = 0
while i < k {
if exps[i] != 1 { all1 = 0 }
i = i + 1
}
if all1 == 1 { return bell[k] }
let bases: ptr<i32> = calloc(k, 4)
let mult: ptr<i64> = calloc(k, 8)
i = 0
while i < k {
bases[i] = (exps[i] + 1) as i32
i = i + 1
}
mult[0] = 1
i = 1
while i < k {
mult[i] = mult[i - 1] * (bases[i - 1] as i64)
i = i + 1
}
let total_states: i64 = mult[k - 1] * (bases[k - 1] as i64)
let dp: ptr<i64> = calloc(total_states, 8)
dp[0] = 1
let digits: ptr<i32> = calloc(k * total_states, 4)
i = 0
while i < k {
let m: i64 = mult[i]
let base: i64 = bases[i] as i64
let mut s: i64 = 0
while s < total_states {
digits[i * total_states + s] = ((s / m) % base) as i32
s = s + 1
}
i = i + 1
}
# for each nonempty subset
let mut mask: i64 = 1
let lim: i64 = 1 << k
while mask < lim {
let mut delta: i64 = 0
i = 0
while i < k {
if ((mask >> i) & 1) == 1 {
delta = delta + mult[i]
}
i = i + 1
}
let mut s: i64 = delta
while s < total_states {
let prev: i64 = s - delta
let mut ok: i64 = 1
i = 0
while i < k {
if ((mask >> i) & 1) == 1 {
if (digits[i * total_states + prev] as i64) >= (exps[i] as i64) {
ok = 0
break
}
}
i = i + 1
}
if ok == 1 {
dp[s] = dp[s] + dp[prev]
}
s = s + 1
}
mask = mask + 1
}
let mut target: i64 = 0
i = 0
while i < k {
target = target + (exps[i] as i64) * mult[i]
i = i + 1
}
let res: i64 = dp[target]
free(digits)
free(dp)
free(mult)
free(bases)
return res
}
function min_suffix(exps: ptr<i32>, k: i64, start: i64, primes: ptr<i32>) -> i64 {
let mut prod: i64 = 1
let mut j: i64 = 0
while j < k {
let e: i64 = exps[j] as i64
let p: i64 = primes[start + j] as i64
let mut t: i64 = 0
while t < e {
prod = prod * p
t = t + 1
}
j = j + 1
}
return prod
}
function process_seq(seq: ptr<i32>, len: i64, TARGET: i64, total_ptr: ptr<i64>, bell: ptr<i64>,
primes: ptr<i32>, pc: i64, pi_small: ptr<i32>, SIEVE: i64,
phik: ptr<i64>, phiv: ptr<i64>, phiu: ptr<i8>, phic: i64,
pik: ptr<i64>, piv: ptr<i64>, piu: ptr<i8>, pic: i64,
fk: ptr<i64>, fv: ptr<i64>, fu: ptr<i8>, fcap: i64) -> void {
let sorted: ptr<i32> = calloc(16, 4)
let mut j: i64 = 0
while j < len {
sorted[j] = seq[j]
j = j + 1
}
j = 1
while j < len {
let keyv: i32 = sorted[j]
let mut p: i64 = j - 1
while p >= 0 && sorted[p] < keyv {
sorted[p + 1] = sorted[p]
p = p - 1
}
sorted[p + 1] = keyv
j = j + 1
}
let mut key: i64 = len
j = 0
while j < len {
key = key * 64 + (sorted[j] as i64)
j = j + 1
}
let hit: i64 = hget(fk, fv, fu, fcap, key)
let mut w: i64 = 0
if hit >= 0 {
w = hit
} else {
w = fsf_from_exps(sorted, len, bell)
hput(fk, fv, fu, fcap, key, w)
}
let cnt: i64 = count_tuples(seq, len, 0, TARGET, primes, pc, pi_small, SIEVE, phik, phiv, phiu, phic, pik, piv, piu, pic)
total_ptr[0] = total_ptr[0] + w * cnt
free(sorted)
}
function gen_rec(ii: i64, prod: i64, len: i64, seq: ptr<i32>, first10: ptr<i64>, TARGET: i64,
total_ptr: ptr<i64>, bell: ptr<i64>,
primes: ptr<i32>, pc: i64, pi_small: ptr<i32>, SIEVE: i64,
phik: ptr<i64>, phiv: ptr<i64>, phiu: ptr<i8>, phic: i64,
pik: ptr<i64>, piv: ptr<i64>, piu: ptr<i8>, pic: i64,
fk: ptr<i64>, fv: ptr<i64>, fu: ptr<i8>, fcap: i64) -> void {
if len > 0 {
process_seq(seq, len, TARGET, total_ptr, bell, primes, pc, pi_small, SIEVE,
phik, phiv, phiu, phic, pik, piv, piu, pic, fk, fv, fu, fcap)
}
if ii >= 10 { return }
let p: i64 = first10[ii]
let mut pe: i64 = p
let mut e: i64 = 1
while prod <= TARGET / pe {
seq[len] = e as i32
gen_rec(ii + 1, prod * pe, len + 1, seq, first10, TARGET, total_ptr, bell,
primes, pc, pi_small, SIEVE, phik, phiv, phiu, phic, pik, piv, piu, pic, fk, fv, fu, fcap)
e = e + 1
if pe > TARGET / p { break }
pe = pe * p
}
}
function count_tuples(exps: ptr<i32>, k: i64, start: i64, limit: i64, primes: ptr<i32>, pc: i64,
pi_small: ptr<i32>, SIEVE: i64,
phik: ptr<i64>, phiv: ptr<i64>, phiu: ptr<i8>, phic: i64,
pik: ptr<i64>, piv: ptr<i64>, piu: ptr<i8>, pic: i64) -> i64 {
if k == 0 { return 1 }
if limit < 2 { return 0 }
if k == 1 {
let e: i64 = exps[0] as i64
let mut max_p: i64 = limit
if e != 1 { max_p = iroot(limit, e) }
if max_p < 2 { return 0 }
let res: i64 = prime_pi(max_p, primes, pc, pi_small, SIEVE, phik, phiv, phiu, phic, pik, piv, piu, pic) - start
if res > 0 { return res }
return 0
}
let e0: i64 = exps[0] as i64
let mut total: i64 = 0
let max_i: i64 = pc - k
let mut i: i64 = start
while i <= max_i {
let p: i64 = primes[i] as i64
let p_pow: i64 = ipow(p, e0)
if p_pow > limit { break }
let new_limit: i64 = limit / p_pow
# suffix exps[1..]
if min_suffix(exps + 1, k - 1, i + 1, primes) > new_limit { break }
total = total + count_tuples(exps + 1, k - 1, i + 1, new_limit, primes, pc, pi_small, SIEVE, phik, phiv, phiu, phic, pik, piv, piu, pic)
i = i + 1
}
return total
}
function main() -> i32 {
let TARGET: i64 = 10000000000
let SIEVE: i64 = 5000000
let sieve: ptr<i8> = calloc(SIEVE + 1, 1)
let primes: ptr<i32> = calloc(SIEVE / 5 + 10, 4)
let pi_small: ptr<i32> = calloc(SIEVE + 1, 4)
let mut pc: i64 = 0
sieve[0] = 1
sieve[1] = 1
let mut i: i64 = 2
while i <= SIEVE {
if sieve[i] == 0 {
primes[pc] = i as i32
pc = pc + 1
let mut j: i64 = i * i
while j <= SIEVE {
sieve[j] = 1
j = j + i
}
}
i = i + 1
}
let mut c: i64 = 0
i = 0
while i <= SIEVE {
if sieve[i] == 0 { c = c + 1 }
pi_small[i] = c as i32
i = i + 1
}
let bell: ptr<i64> = calloc(11, 8)
# Stirling2 -> Bell
let S: ptr<i64> = calloc(11 * 11, 8)
S[0] = 1
let mut n: i64 = 1
while n <= 10 {
let mut k: i64 = 1
while k <= n {
S[n * 11 + k] = S[(n - 1) * 11 + (k - 1)] + k * S[(n - 1) * 11 + k]
k = k + 1
}
n = n + 1
}
n = 0
while n <= 10 {
let mut s: i64 = 0
let mut k: i64 = 0
while k <= n {
s = s + S[n * 11 + k]
k = k + 1
}
bell[n] = s
n = n + 1
}
let CAP: i64 = 1 << 22
let phik: ptr<i64> = calloc(CAP, 8)
let phiv: ptr<i64> = calloc(CAP, 8)
let phiu: ptr<i8> = calloc(CAP, 1)
let pik: ptr<i64> = calloc(CAP, 8)
let piv: ptr<i64> = calloc(CAP, 8)
let piu: ptr<i8> = calloc(CAP, 1)
# fsf cache
let FCAP: i64 = 1 << 18
let fk: ptr<i64> = calloc(FCAP, 8)
let fv: ptr<i64> = calloc(FCAP, 8)
let fu: ptr<i8> = calloc(FCAP, 1)
let first10: ptr<i64> = calloc(10, 8)
first10[0] = 2; first10[1] = 3; first10[2] = 5; first10[3] = 7; first10[4] = 11
first10[5] = 13; first10[6] = 17; first10[7] = 19; first10[8] = 23; first10[9] = 29
let seq: ptr<i32> = calloc(16, 4)
let total_ptr: ptr<i64> = calloc(1, 8)
gen_rec(0, 1, 0, seq, first10, TARGET, total_ptr, bell, primes, pc, pi_small, SIEVE,
phik, phiv, phiu, CAP, pik, piv, piu, CAP, fk, fv, fu, FCAP)
printf("%lld\n", total_ptr[0])
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 iroot_i64_i64(int64_t n, int64_t k);
int64_t ipow_i64_i64(int64_t base, int64_t exp);
int64_t hget_ptr_i64_ptr_i64_ptr_i8_i64_i64(int64_t* keys, int64_t* vals, int8_t* used, int64_t cap, int64_t key);
void hput_ptr_i64_ptr_i64_ptr_i8_i64_i64_i64(int64_t* keys, int64_t* vals, int8_t* used, int64_t cap, int64_t key, int64_t val);
int64_t phi_i64_i64_ptr_i32_ptr_i64_ptr_i64_ptr_i8_i64(int64_t x, int64_t s, int32_t* primes, int64_t* phik, int64_t* phiv, int8_t* phiu, int64_t phic);
int64_t pi_lehmer_i64_ptr_i32_i64_ptr_i32_i64_ptr_i64_ptr_i64_ptr_i8_i64_ptr_i64_ptr_i64_ptr_i8_i64(int64_t x, int32_t* primes, int64_t pc, int32_t* pi_small, int64_t SIEVE, int64_t* phik, int64_t* phiv, int8_t* phiu, int64_t phic, int64_t* pik, int64_t* piv, int8_t* piu, int64_t pic);
int64_t prime_pi_i64_ptr_i32_i64_ptr_i32_i64_ptr_i64_ptr_i64_ptr_i8_i64_ptr_i64_ptr_i64_ptr_i8_i64(int64_t x, int32_t* primes, int64_t pc, int32_t* pi_small, int64_t SIEVE, int64_t* phik, int64_t* phiv, int8_t* phiu, int64_t phic, int64_t* pik, int64_t* piv, int8_t* piu, int64_t pic);
int64_t fsf_from_exps_ptr_i32_i64_ptr_i64(int32_t* exps, int64_t k, int64_t* bell);
int64_t min_suffix_ptr_i32_i64_i64_ptr_i32(int32_t* exps, int64_t k, int64_t start, int32_t* primes);
void process_seq_ptr_i32_i64_i64_ptr_i64_ptr_i64_ptr_i32_i64_ptr_i32_i64_ptr_i64_ptr_i64_ptr_i8_i64_ptr_i64_ptr_i64_ptr_i8_i64_ptr_i64_ptr_i64_ptr_i8_i64(int32_t* seq, int64_t len, int64_t TARGET, int64_t* total_ptr, int64_t* bell, int32_t* primes, int64_t pc, int32_t* pi_small, int64_t SIEVE, int64_t* phik, int64_t* phiv, int8_t* phiu, int64_t phic, int64_t* pik, int64_t* piv, int8_t* piu, int64_t pic, int64_t* fk, int64_t* fv, int8_t* fu, int64_t fcap);
void gen_rec_i64_i64_i64_ptr_i32_ptr_i64_i64_ptr_i64_ptr_i64_ptr_i32_i64_ptr_i32_i64_ptr_i64_ptr_i64_ptr_i8_i64_ptr_i64_ptr_i64_ptr_i8_i64_ptr_i64_ptr_i64_ptr_i8_i64(int64_t ii, int64_t prod, int64_t len, int32_t* seq, int64_t* first10, int64_t TARGET, int64_t* total_ptr, int64_t* bell, int32_t* primes, int64_t pc, int32_t* pi_small, int64_t SIEVE, int64_t* phik, int64_t* phiv, int8_t* phiu, int64_t phic, int64_t* pik, int64_t* piv, int8_t* piu, int64_t pic, int64_t* fk, int64_t* fv, int8_t* fu, int64_t fcap);
int64_t count_tuples_ptr_i32_i64_i64_i64_ptr_i32_i64_ptr_i32_i64_ptr_i64_ptr_i64_ptr_i8_i64_ptr_i64_ptr_i64_ptr_i8_i64(int32_t* exps, int64_t k, int64_t start, int64_t limit, int32_t* primes, int64_t pc, int32_t* pi_small, int64_t SIEVE, int64_t* phik, int64_t* phiv, int8_t* phiu, int64_t phic, int64_t* pik, int64_t* piv, int8_t* piu, int64_t pic);
int32_t main(void);
int64_t gcd_i64_i64(int64_t a0, int64_t b0) {
int64_t a = a0;
int64_t b = b0;
while (b != 0) {
int64_t t = FLOW_CHECKED_MOD((a), (b));
a = b;
b = t;
}
return a;
}
int64_t lcm_i64_i64(int64_t a, int64_t b) {
if ((a == 0 || b == 0)) {
return 0;
}
return (FLOW_CHECKED_DIV((a), (gcd_i64_i64(a, b))) * b);
}
int64_t isqrt_i64(int64_t n) {
if (n < 2) {
return n;
}
int64_t x = n;
int64_t y = FLOW_CHECKED_DIV(((x + 1)), (2));
while (y < x) {
x = y;
y = FLOW_CHECKED_DIV(((x + FLOW_CHECKED_DIV((n), (x)))), (2));
}
return x;
}
int64_t mulmod_i64_i64_i64(int64_t a0, int64_t b0, int64_t mod) {
int64_t a = FLOW_CHECKED_MOD((a0), (mod));
int64_t b = FLOW_CHECKED_MOD((b0), (mod));
int64_t result = 0;
while (b > 0) {
if (FLOW_CHECKED_MOD((b), (2)) == 1) {
result = FLOW_CHECKED_MOD(((result + a)), (mod));
}
a = FLOW_CHECKED_MOD(((a * 2)), (mod));
b = FLOW_CHECKED_DIV((b), (2));
}
return result;
}
int64_t mod_pow_i64_i64_i64(int64_t base, int64_t exp, int64_t mod) {
if (mod == 1) {
return 0;
}
int64_t result = 1;
int64_t b = FLOW_CHECKED_MOD((base), (mod));
int64_t e = exp;
while (e > 0) {
if (FLOW_CHECKED_MOD((e), (2)) == 1) {
result = mulmod_i64_i64_i64(result, b, mod);
}
b = mulmod_i64_i64_i64(b, b, mod);
e = FLOW_CHECKED_DIV((e), (2));
}
return result;
}
bool is_prime_i64(int64_t n) {
if (n < 2) {
return 0;
}
if (n < 4) {
return 1;
}
if ((FLOW_CHECKED_MOD((n), (2)) == 0 || FLOW_CHECKED_MOD((n), (3)) == 0)) {
return 0;
}
int64_t i = 5;
while ((i * i) <= n) {
if ((FLOW_CHECKED_MOD((n), (i)) == 0 || FLOW_CHECKED_MOD((n), ((i + 2))) == 0)) {
return 0;
}
i = (i + 6);
}
return 1;
}
int64_t iroot_i64_i64(int64_t n, int64_t k) {
if (k == 1) {
return n;
}
if (n <= 0) {
return 0;
}
int64_t lo = 1;
int64_t hi = n;
if (k >= 2) {
hi = (isqrt_i64(n) + 1);
}
if (k >= 3) {
hi = (iroot_i64_i64(n, (k - 1)) + 1);
}
if (hi > n) {
hi = n;
}
while ((lo + 1) < hi) {
int64_t mid = FLOW_CHECKED_DIV(((lo + hi)), (2));
int64_t p = 1;
int64_t ok = 1;
int64_t i = 0;
while (i < k) {
if ((mid != 0 && p > FLOW_CHECKED_DIV((n), (mid)))) {
ok = 0;
break;
}
p = (p * mid);
i = (i + 1);
}
if ((ok == 1 && p <= n)) {
lo = mid;
} else {
hi = mid;
}
}
return lo;
}
int64_t ipow_i64_i64(int64_t base, int64_t exp) {
int64_t r = 1;
int64_t b = base;
int64_t e = exp;
while (e > 0) {
if ((e & 1) == 1) {
r = (r * b);
}
b = (b * b);
e = FLOW_CHECKED_DIV((e), (2));
}
return r;
}
int64_t hget_ptr_i64_ptr_i64_ptr_i8_i64_i64(int64_t* keys, int64_t* vals, int8_t* used, int64_t cap, int64_t key) {
int64_t slot = key;
if (slot < 0) {
slot = (0 - slot);
}
slot = (slot & (cap - 1));
while (used[slot] != 0) {
if (keys[slot] == key) {
return vals[slot];
}
slot = ((slot + 1) & (cap - 1));
}
return (0 - 1);
}
void hput_ptr_i64_ptr_i64_ptr_i8_i64_i64_i64(int64_t* keys, int64_t* vals, int8_t* used, int64_t cap, int64_t key, int64_t val) {
int64_t slot = key;
if (slot < 0) {
slot = (0 - slot);
}
slot = (slot & (cap - 1));
while ((used[slot] != 0 && keys[slot] != key)) {
slot = ((slot + 1) & (cap - 1));
}
used[slot] = 1;
keys[slot] = key;
vals[slot] = val;
}
int64_t phi_i64_i64_ptr_i32_ptr_i64_ptr_i64_ptr_i8_i64(int64_t x, int64_t s, int32_t* primes, int64_t* phik, int64_t* phiv, int8_t* phiu, int64_t phic) {
if (s == 0) {
return x;
}
if (s == 1) {
return (x - FLOW_CHECKED_DIV((x), (2)));
}
if (s == 2) {
return (((x - FLOW_CHECKED_DIV((x), (2))) - FLOW_CHECKED_DIV((x), (3))) + FLOW_CHECKED_DIV((x), (6)));
}
if (x == 0) {
return 0;
}
if (x < 10000) {
int64_t key = ((x * 1000003) + s);
int64_t hit = hget_ptr_i64_ptr_i64_ptr_i8_i64_i64(phik, phiv, phiu, phic, key);
if (hit >= 0) {
return hit;
}
int64_t v = (phi_i64_i64_ptr_i32_ptr_i64_ptr_i64_ptr_i8_i64(x, (s - 1), primes, phik, phiv, phiu, phic) - phi_i64_i64_ptr_i32_ptr_i64_ptr_i64_ptr_i8_i64(FLOW_CHECKED_DIV((x), (((int64_t)(primes[(s - 1)])))), (s - 1), primes, phik, phiv, phiu, phic));
hput_ptr_i64_ptr_i64_ptr_i8_i64_i64_i64(phik, phiv, phiu, phic, key, v);
return v;
}
return (phi_i64_i64_ptr_i32_ptr_i64_ptr_i64_ptr_i8_i64(x, (s - 1), primes, phik, phiv, phiu, phic) - phi_i64_i64_ptr_i32_ptr_i64_ptr_i64_ptr_i8_i64(FLOW_CHECKED_DIV((x), (((int64_t)(primes[(s - 1)])))), (s - 1), primes, phik, phiv, phiu, phic));
}
int64_t pi_lehmer_i64_ptr_i32_i64_ptr_i32_i64_ptr_i64_ptr_i64_ptr_i8_i64_ptr_i64_ptr_i64_ptr_i8_i64(int64_t x, int32_t* primes, int64_t pc, int32_t* pi_small, int64_t SIEVE, int64_t* phik, int64_t* phiv, int8_t* phiu, int64_t phic, int64_t* pik, int64_t* piv, int8_t* piu, int64_t pic) {
if (x < SIEVE) {
return ((int64_t)(pi_small[x]));
}
if (x < 2) {
return 0;
}
int64_t hit = hget_ptr_i64_ptr_i64_ptr_i8_i64_i64(pik, piv, piu, pic, x);
if (hit >= 0) {
return hit;
}
int64_t a = pi_lehmer_i64_ptr_i32_i64_ptr_i32_i64_ptr_i64_ptr_i64_ptr_i8_i64_ptr_i64_ptr_i64_ptr_i8_i64(iroot_i64_i64(x, 4), primes, pc, pi_small, SIEVE, phik, phiv, phiu, phic, pik, piv, piu, pic);
int64_t b = pi_lehmer_i64_ptr_i32_i64_ptr_i32_i64_ptr_i64_ptr_i64_ptr_i8_i64_ptr_i64_ptr_i64_ptr_i8_i64(isqrt_i64(x), primes, pc, pi_small, SIEVE, phik, phiv, phiu, phic, pik, piv, piu, pic);
int64_t c = pi_lehmer_i64_ptr_i32_i64_ptr_i32_i64_ptr_i64_ptr_i64_ptr_i8_i64_ptr_i64_ptr_i64_ptr_i8_i64(iroot_i64_i64(x, 3), primes, pc, pi_small, SIEVE, phik, phiv, phiu, phic, pik, piv, piu, pic);
int64_t res = (phi_i64_i64_ptr_i32_ptr_i64_ptr_i64_ptr_i8_i64(x, a, primes, phik, phiv, phiu, phic) + FLOW_CHECKED_DIV(((((b + a) - 2) * ((b - a) + 1))), (2)));
int64_t i = a;
while (i < b) {
int64_t w = FLOW_CHECKED_DIV((x), (((int64_t)(primes[i]))));
res = (res - pi_lehmer_i64_ptr_i32_i64_ptr_i32_i64_ptr_i64_ptr_i64_ptr_i8_i64_ptr_i64_ptr_i64_ptr_i8_i64(w, primes, pc, pi_small, SIEVE, phik, phiv, phiu, phic, pik, piv, piu, pic));
if (i < c) {
int64_t lim = pi_lehmer_i64_ptr_i32_i64_ptr_i32_i64_ptr_i64_ptr_i64_ptr_i8_i64_ptr_i64_ptr_i64_ptr_i8_i64(isqrt_i64(w), primes, pc, pi_small, SIEVE, phik, phiv, phiu, phic, pik, piv, piu, pic);
int64_t j = i;
while (j < lim) {
res = (res - (pi_lehmer_i64_ptr_i32_i64_ptr_i32_i64_ptr_i64_ptr_i64_ptr_i8_i64_ptr_i64_ptr_i64_ptr_i8_i64(FLOW_CHECKED_DIV((w), (((int64_t)(primes[j])))), primes, pc, pi_small, SIEVE, phik, phiv, phiu, phic, pik, piv, piu, pic) - j));
j = (j + 1);
}
}
i = (i + 1);
}
hput_ptr_i64_ptr_i64_ptr_i8_i64_i64_i64(pik, piv, piu, pic, x, res);
return res;
}
int64_t prime_pi_i64_ptr_i32_i64_ptr_i32_i64_ptr_i64_ptr_i64_ptr_i8_i64_ptr_i64_ptr_i64_ptr_i8_i64(int64_t x, int32_t* primes, int64_t pc, int32_t* pi_small, int64_t SIEVE, int64_t* phik, int64_t* phiv, int8_t* phiu, int64_t phic, int64_t* pik, int64_t* piv, int8_t* piu, int64_t pic) {
if (x < SIEVE) {
return ((int64_t)(pi_small[x]));
}
return pi_lehmer_i64_ptr_i32_i64_ptr_i32_i64_ptr_i64_ptr_i64_ptr_i8_i64_ptr_i64_ptr_i64_ptr_i8_i64(x, primes, pc, pi_small, SIEVE, phik, phiv, phiu, phic, pik, piv, piu, pic);
}
int64_t fsf_from_exps_ptr_i32_i64_ptr_i64(int32_t* exps, int64_t k, int64_t* bell) {
if (k == 0) {
return 0;
}
if (k == 1) {
return 1;
}
int64_t all1 = 1;
int64_t i = 0;
while (i < k) {
if (exps[i] != 1) {
all1 = 0;
}
i = (i + 1);
}
if (all1 == 1) {
return bell[k];
}
int32_t* bases = (int32_t*)(calloc(k, 4));
int64_t* mult = (int64_t*)(calloc(k, 8));
i = 0;
while (i < k) {
bases[i] = ((int32_t)((exps[i] + 1)));
i = (i + 1);
}
mult[0] = 1;
i = 1;
while (i < k) {
mult[i] = (mult[(i - 1)] * ((int64_t)(bases[(i - 1)])));
i = (i + 1);
}
int64_t total_states = (mult[(k - 1)] * ((int64_t)(bases[(k - 1)])));
int64_t* dp = (int64_t*)(calloc(total_states, 8));
dp[0] = 1;
int32_t* digits = (int32_t*)(calloc((k * total_states), 4));
i = 0;
while (i < k) {
int64_t m = mult[i];
int64_t base = ((int64_t)(bases[i]));
int64_t s = 0;
while (s < total_states) {
digits[((i * total_states) + s)] = ((int32_t)(FLOW_CHECKED_MOD((FLOW_CHECKED_DIV((s), (m))), (base))));
s = (s + 1);
}
i = (i + 1);
}
int64_t mask = 1;
int64_t lim = FLOW_CHECKED_SHL((1), (k));
while (mask < lim) {
int64_t delta = 0;
i = 0;
while (i < k) {
if ((FLOW_CHECKED_SHR((mask), (i)) & 1) == 1) {
delta = (delta + mult[i]);
}
i = (i + 1);
}
int64_t s = delta;
while (s < total_states) {
int64_t prev = (s - delta);
int64_t ok = 1;
i = 0;
while (i < k) {
if ((FLOW_CHECKED_SHR((mask), (i)) & 1) == 1) {
if (((int64_t)(digits[((i * total_states) + prev)])) >= ((int64_t)(exps[i]))) {
ok = 0;
break;
}
}
i = (i + 1);
}
if (ok == 1) {
dp[s] = (dp[s] + dp[prev]);
}
s = (s + 1);
}
mask = (mask + 1);
}
int64_t target = 0;
i = 0;
while (i < k) {
target = (target + (((int64_t)(exps[i])) * mult[i]));
i = (i + 1);
}
int64_t res = dp[target];
free(digits);
free(dp);
free(mult);
free(bases);
return res;
}
int64_t min_suffix_ptr_i32_i64_i64_ptr_i32(int32_t* exps, int64_t k, int64_t start, int32_t* primes) {
int64_t prod = 1;
int64_t j = 0;
while (j < k) {
int64_t e = ((int64_t)(exps[j]));
int64_t p = ((int64_t)(primes[(start + j)]));
int64_t t = 0;
while (t < e) {
prod = (prod * p);
t = (t + 1);
}
j = (j + 1);
}
return prod;
}
void process_seq_ptr_i32_i64_i64_ptr_i64_ptr_i64_ptr_i32_i64_ptr_i32_i64_ptr_i64_ptr_i64_ptr_i8_i64_ptr_i64_ptr_i64_ptr_i8_i64_ptr_i64_ptr_i64_ptr_i8_i64(int32_t* seq, int64_t len, int64_t TARGET, int64_t* total_ptr, int64_t* bell, int32_t* primes, int64_t pc, int32_t* pi_small, int64_t SIEVE, int64_t* phik, int64_t* phiv, int8_t* phiu, int64_t phic, int64_t* pik, int64_t* piv, int8_t* piu, int64_t pic, int64_t* fk, int64_t* fv, int8_t* fu, int64_t fcap) {
int32_t* sorted = (int32_t*)(calloc(16, 4));
int64_t j = 0;
while (j < len) {
sorted[j] = seq[j];
j = (j + 1);
}
j = 1;
while (j < len) {
int32_t keyv = sorted[j];
int64_t p = (j - 1);
while ((p >= 0 && sorted[p] < keyv)) {
sorted[(p + 1)] = sorted[p];
p = (p - 1);
}
sorted[(p + 1)] = keyv;
j = (j + 1);
}
int64_t key = len;
j = 0;
while (j < len) {
key = ((key * 64) + ((int64_t)(sorted[j])));
j = (j + 1);
}
int64_t hit = hget_ptr_i64_ptr_i64_ptr_i8_i64_i64(fk, fv, fu, fcap, key);
int64_t w = 0;
if (hit >= 0) {
w = hit;
} else {
w = fsf_from_exps_ptr_i32_i64_ptr_i64(sorted, len, bell);
hput_ptr_i64_ptr_i64_ptr_i8_i64_i64_i64(fk, fv, fu, fcap, key, w);
}
int64_t cnt = count_tuples_ptr_i32_i64_i64_i64_ptr_i32_i64_ptr_i32_i64_ptr_i64_ptr_i64_ptr_i8_i64_ptr_i64_ptr_i64_ptr_i8_i64(seq, len, 0, TARGET, primes, pc, pi_small, SIEVE, phik, phiv, phiu, phic, pik, piv, piu, pic);
total_ptr[0] = (total_ptr[0] + (w * cnt));
free(sorted);
}
void gen_rec_i64_i64_i64_ptr_i32_ptr_i64_i64_ptr_i64_ptr_i64_ptr_i32_i64_ptr_i32_i64_ptr_i64_ptr_i64_ptr_i8_i64_ptr_i64_ptr_i64_ptr_i8_i64_ptr_i64_ptr_i64_ptr_i8_i64(int64_t ii, int64_t prod, int64_t len, int32_t* seq, int64_t* first10, int64_t TARGET, int64_t* total_ptr, int64_t* bell, int32_t* primes, int64_t pc, int32_t* pi_small, int64_t SIEVE, int64_t* phik, int64_t* phiv, int8_t* phiu, int64_t phic, int64_t* pik, int64_t* piv, int8_t* piu, int64_t pic, int64_t* fk, int64_t* fv, int8_t* fu, int64_t fcap) {
if (len > 0) {
process_seq_ptr_i32_i64_i64_ptr_i64_ptr_i64_ptr_i32_i64_ptr_i32_i64_ptr_i64_ptr_i64_ptr_i8_i64_ptr_i64_ptr_i64_ptr_i8_i64_ptr_i64_ptr_i64_ptr_i8_i64(seq, len, TARGET, total_ptr, bell, primes, pc, pi_small, SIEVE, phik, phiv, phiu, phic, pik, piv, piu, pic, fk, fv, fu, fcap);
}
if (ii >= 10) {
return;
}
int64_t p = first10[ii];
int64_t pe = p;
int64_t e = 1;
while (prod <= FLOW_CHECKED_DIV((TARGET), (pe))) {
seq[len] = ((int32_t)(e));
gen_rec_i64_i64_i64_ptr_i32_ptr_i64_i64_ptr_i64_ptr_i64_ptr_i32_i64_ptr_i32_i64_ptr_i64_ptr_i64_ptr_i8_i64_ptr_i64_ptr_i64_ptr_i8_i64_ptr_i64_ptr_i64_ptr_i8_i64((ii + 1), (prod * pe), (len + 1), seq, first10, TARGET, total_ptr, bell, primes, pc, pi_small, SIEVE, phik, phiv, phiu, phic, pik, piv, piu, pic, fk, fv, fu, fcap);
e = (e + 1);
if (pe > FLOW_CHECKED_DIV((TARGET), (p))) {
break;
}
pe = (pe * p);
}
}
int64_t count_tuples_ptr_i32_i64_i64_i64_ptr_i32_i64_ptr_i32_i64_ptr_i64_ptr_i64_ptr_i8_i64_ptr_i64_ptr_i64_ptr_i8_i64(int32_t* exps, int64_t k, int64_t start, int64_t limit, int32_t* primes, int64_t pc, int32_t* pi_small, int64_t SIEVE, int64_t* phik, int64_t* phiv, int8_t* phiu, int64_t phic, int64_t* pik, int64_t* piv, int8_t* piu, int64_t pic) {
if (k == 0) {
return 1;
}
if (limit < 2) {
return 0;
}
if (k == 1) {
int64_t e = ((int64_t)(exps[0]));
int64_t max_p = limit;
if (e != 1) {
max_p = iroot_i64_i64(limit, e);
}
if (max_p < 2) {
return 0;
}
int64_t res = (prime_pi_i64_ptr_i32_i64_ptr_i32_i64_ptr_i64_ptr_i64_ptr_i8_i64_ptr_i64_ptr_i64_ptr_i8_i64(max_p, primes, pc, pi_small, SIEVE, phik, phiv, phiu, phic, pik, piv, piu, pic) - start);
if (res > 0) {
return res;
}
return 0;
}
int64_t e0 = ((int64_t)(exps[0]));
int64_t total = 0;
int64_t max_i = (pc - k);
int64_t i = start;
while (i <= max_i) {
int64_t p = ((int64_t)(primes[i]));
int64_t p_pow = ipow_i64_i64(p, e0);
if (p_pow > limit) {
break;
}
int64_t new_limit = FLOW_CHECKED_DIV((limit), (p_pow));
if (min_suffix_ptr_i32_i64_i64_ptr_i32((exps + 1), (k - 1), (i + 1), primes) > new_limit) {
break;
}
total = (total + count_tuples_ptr_i32_i64_i64_i64_ptr_i32_i64_ptr_i32_i64_ptr_i64_ptr_i64_ptr_i8_i64_ptr_i64_ptr_i64_ptr_i8_i64((exps + 1), (k - 1), (i + 1), new_limit, primes, pc, pi_small, SIEVE, phik, phiv, phiu, phic, pik, piv, piu, pic));
i = (i + 1);
}
return total;
}
int32_t main(void) {
int64_t TARGET = 10000000000;
int64_t SIEVE = 5000000;
int8_t* sieve = (int8_t*)(calloc((SIEVE + 1), 1));
int32_t* primes = (int32_t*)(calloc((FLOW_CHECKED_DIV((SIEVE), (5)) + 10), 4));
int32_t* pi_small = (int32_t*)(calloc((SIEVE + 1), 4));
int64_t pc = 0;
sieve[0] = 1;
sieve[1] = 1;
int64_t i = 2;
while (i <= SIEVE) {
if (sieve[i] == 0) {
primes[pc] = ((int32_t)(i));
pc = (pc + 1);
int64_t j = (i * i);
while (j <= SIEVE) {
sieve[j] = 1;
j = (j + i);
}
}
i = (i + 1);
}
int64_t c = 0;
i = 0;
while (i <= SIEVE) {
if (sieve[i] == 0) {
c = (c + 1);
}
pi_small[i] = ((int32_t)(c));
i = (i + 1);
}
int64_t* bell = (int64_t*)(calloc(11, 8));
int64_t* S = (int64_t*)(calloc((11 * 11), 8));
S[0] = 1;
int64_t n = 1;
while (n <= 10) {
int64_t k = 1;
while (k <= n) {
S[((n * 11) + k)] = (S[(((n - 1) * 11) + (k - 1))] + (k * S[(((n - 1) * 11) + k)]));
k = (k + 1);
}
n = (n + 1);
}
n = 0;
while (n <= 10) {
int64_t s = 0;
int64_t k = 0;
while (k <= n) {
s = (s + S[((n * 11) + k)]);
k = (k + 1);
}
bell[n] = s;
n = (n + 1);
}
int64_t CAP = FLOW_CHECKED_SHL((1), (22));
int64_t* phik = (int64_t*)(calloc(CAP, 8));
int64_t* phiv = (int64_t*)(calloc(CAP, 8));
int8_t* phiu = (int8_t*)(calloc(CAP, 1));
int64_t* pik = (int64_t*)(calloc(CAP, 8));
int64_t* piv = (int64_t*)(calloc(CAP, 8));
int8_t* piu = (int8_t*)(calloc(CAP, 1));
int64_t FCAP = FLOW_CHECKED_SHL((1), (18));
int64_t* fk = (int64_t*)(calloc(FCAP, 8));
int64_t* fv = (int64_t*)(calloc(FCAP, 8));
int8_t* fu = (int8_t*)(calloc(FCAP, 1));
int64_t* first10 = (int64_t*)(calloc(10, 8));
first10[0] = 2;
first10[1] = 3;
first10[2] = 5;
first10[3] = 7;
first10[4] = 11;
first10[5] = 13;
first10[6] = 17;
first10[7] = 19;
first10[8] = 23;
first10[9] = 29;
int32_t* seq = (int32_t*)(calloc(16, 4));
int64_t* total_ptr = (int64_t*)(calloc(1, 8));
gen_rec_i64_i64_i64_ptr_i32_ptr_i64_i64_ptr_i64_ptr_i64_ptr_i32_i64_ptr_i32_i64_ptr_i64_ptr_i64_ptr_i8_i64_ptr_i64_ptr_i64_ptr_i8_i64_ptr_i64_ptr_i64_ptr_i8_i64(0, 1, 0, seq, first10, TARGET, total_ptr, bell, primes, pc, pi_small, SIEVE, phik, phiv, phiu, CAP, pik, piv, piu, CAP, fk, fv, fu, FCAP);
printf("%lld\n", total_ptr[0]);
return 0;
}
Generated MLIR
module {
llvm.func @printf(!llvm.ptr, ...) -> i32
llvm.mlir.global internal constant @str_0("%lld\n\00") {addr_space = 0 : i32} : !llvm.array<6 x i8>
func.func @gcd(%arg0: i64, %arg1: i64) -> i64 {
%0 = llvm.mlir.constant(1 : i64) : i64
%1 = llvm.alloca %0 x i64 : (i64) -> !llvm.ptr
llvm.store %arg0, %1 : i64, !llvm.ptr
%2 = llvm.mlir.constant(1 : i64) : i64
%3 = llvm.alloca %2 x i64 : (i64) -> !llvm.ptr
llvm.store %arg1, %3 : i64, !llvm.ptr
cf.br ^bb0
^bb0:
%4 = llvm.load %3 : !llvm.ptr -> i64
%5 = arith.constant 0 : i32
%7 = arith.extsi %5 : i32 to i64
%6 = arith.cmpi ne, %4, %7 : i64
cf.cond_br %6, ^bb1, ^bb2
^bb1:
%8 = llvm.load %1 : !llvm.ptr -> i64
%9 = llvm.load %3 : !llvm.ptr -> i64
%10 = arith.remsi %8, %9 : i64
%11 = llvm.load %3 : !llvm.ptr -> i64
llvm.store %11, %1 : i64, !llvm.ptr
llvm.store %10, %3 : i64, !llvm.ptr
cf.br ^bb0
^bb2:
%12 = llvm.load %1 : !llvm.ptr -> i64
func.return %12 : i64
}
func.func @lcm(%arg0: i64, %arg1: i64) -> i64 {
%13 = arith.constant 0 : i32
%15 = arith.extsi %13 : i32 to i64
%14 = arith.cmpi eq, %arg0, %15 : i64
%16 = scf.if %14 -> (i1) {
%17 = arith.constant true
scf.yield %17 : i1
} else {
%18 = arith.constant 0 : i32
%20 = arith.extsi %18 : i32 to i64
%19 = arith.cmpi eq, %arg1, %20 : i64
scf.yield %19 : i1
}
cf.cond_br %16, ^bb3, ^bb4
^bb3:
%21 = arith.constant 0 : i32
%22 = arith.extsi %21 : i32 to i64
func.return %22 : i64
^bb4:
cf.br ^bb5
^bb5:
%23 = func.call @gcd(%arg0, %arg1) : (i64, i64) -> i64
%24 = arith.divsi %arg0, %23 : i64
%25 = arith.muli %24, %arg1 : i64
func.return %25 : i64
}
func.func @isqrt(%arg0: i64) -> i64 {
%26 = arith.constant 2 : i32
%28 = arith.extsi %26 : i32 to i64
%27 = arith.cmpi slt, %arg0, %28 : i64
cf.cond_br %27, ^bb6, ^bb7
^bb6:
func.return %arg0 : i64
^bb7:
cf.br ^bb8
^bb8:
%29 = llvm.mlir.constant(1 : i64) : i64
%30 = llvm.alloca %29 x i64 : (i64) -> !llvm.ptr
llvm.store %arg0, %30 : i64, !llvm.ptr
%31 = llvm.load %30 : !llvm.ptr -> i64
%32 = arith.constant 1 : i32
%34 = arith.extsi %32 : i32 to i64
%33 = arith.addi %31, %34 : i64
%35 = arith.constant 2 : i32
%37 = arith.extsi %35 : i32 to i64
%36 = arith.divsi %33, %37 : i64
%38 = llvm.mlir.constant(1 : i64) : i64
%39 = llvm.alloca %38 x i64 : (i64) -> !llvm.ptr
llvm.store %36, %39 : i64, !llvm.ptr
cf.br ^bb9
^bb9:
%40 = llvm.load %39 : !llvm.ptr -> i64
%41 = llvm.load %30 : !llvm.ptr -> i64
%42 = arith.cmpi slt, %40, %41 : i64
cf.cond_br %42, ^bb10, ^bb11
^bb10:
%43 = llvm.load %39 : !llvm.ptr -> i64
llvm.store %43, %30 : i64, !llvm.ptr
%44 = llvm.load %30 : !llvm.ptr -> i64
%45 = llvm.load %30 : !llvm.ptr -> i64
%46 = arith.divsi %arg0, %45 : i64
%47 = arith.addi %44, %46 : i64
%48 = arith.constant 2 : i32
%50 = arith.extsi %48 : i32 to i64
%49 = arith.divsi %47, %50 : i64
llvm.store %49, %39 : i64, !llvm.ptr
cf.br ^bb9
^bb11:
%51 = llvm.load %30 : !llvm.ptr -> i64
func.return %51 : i64
}
func.func @mulmod(%arg0: i64, %arg1: i64, %arg2: i64) -> i64 {
%52 = arith.remsi %arg0, %arg2 : i64
%53 = llvm.mlir.constant(1 : i64) : i64
%54 = llvm.alloca %53 x i64 : (i64) -> !llvm.ptr
llvm.store %52, %54 : i64, !llvm.ptr
%55 = arith.remsi %arg1, %arg2 : i64
%56 = llvm.mlir.constant(1 : i64) : i64
%57 = llvm.alloca %56 x i64 : (i64) -> !llvm.ptr
llvm.store %55, %57 : i64, !llvm.ptr
%58 = arith.constant 0 : i32
%59 = arith.extsi %58 : i32 to i64
%60 = llvm.mlir.constant(1 : i64) : i64
%61 = llvm.alloca %60 x i64 : (i64) -> !llvm.ptr
llvm.store %59, %61 : i64, !llvm.ptr
cf.br ^bb12
^bb12:
%62 = llvm.load %57 : !llvm.ptr -> i64
%63 = arith.constant 0 : i32
%65 = arith.extsi %63 : i32 to i64
%64 = arith.cmpi sgt, %62, %65 : i64
cf.cond_br %64, ^bb13, ^bb14
^bb13:
%66 = llvm.load %57 : !llvm.ptr -> i64
%67 = arith.constant 2 : i32
%69 = arith.extsi %67 : i32 to i64
%68 = arith.remsi %66, %69 : i64
%70 = arith.constant 1 : i32
%72 = arith.extsi %70 : i32 to i64
%71 = arith.cmpi eq, %68, %72 : i64
cf.cond_br %71, ^bb15, ^bb16
^bb15:
%73 = llvm.load %61 : !llvm.ptr -> i64
%74 = llvm.load %54 : !llvm.ptr -> i64
%75 = arith.addi %73, %74 : i64
%76 = arith.remsi %75, %arg2 : i64
llvm.store %76, %61 : i64, !llvm.ptr
cf.br ^bb17
^bb16:
cf.br ^bb17
^bb17:
%77 = llvm.load %54 : !llvm.ptr -> i64
%78 = arith.constant 2 : i32
%80 = arith.extsi %78 : i32 to i64
%79 = arith.muli %77, %80 : i64
%81 = arith.remsi %79, %arg2 : i64
llvm.store %81, %54 : i64, !llvm.ptr
%82 = llvm.load %57 : !llvm.ptr -> i64
%83 = arith.constant 2 : i32
%85 = arith.extsi %83 : i32 to i64
%84 = arith.divsi %82, %85 : i64
llvm.store %84, %57 : i64, !llvm.ptr
cf.br ^bb12
^bb14:
%86 = llvm.load %61 : !llvm.ptr -> i64
func.return %86 : i64
}
func.func @mod_pow(%arg0: i64, %arg1: i64, %arg2: i64) -> i64 {
%87 = arith.constant 1 : i32
%89 = arith.extsi %87 : i32 to i64
%88 = arith.cmpi eq, %arg2, %89 : i64
cf.cond_br %88, ^bb18, ^bb19
^bb18:
%90 = arith.constant 0 : i32
%91 = arith.extsi %90 : i32 to i64
func.return %91 : i64
^bb19:
cf.br ^bb20
^bb20:
%92 = arith.constant 1 : i32
%93 = arith.extsi %92 : i32 to i64
%94 = llvm.mlir.constant(1 : i64) : i64
%95 = llvm.alloca %94 x i64 : (i64) -> !llvm.ptr
llvm.store %93, %95 : i64, !llvm.ptr
%96 = arith.remsi %arg0, %arg2 : i64
%97 = llvm.mlir.constant(1 : i64) : i64
%98 = llvm.alloca %97 x i64 : (i64) -> !llvm.ptr
llvm.store %96, %98 : i64, !llvm.ptr
%99 = llvm.mlir.constant(1 : i64) : i64
%100 = llvm.alloca %99 x i64 : (i64) -> !llvm.ptr
llvm.store %arg1, %100 : i64, !llvm.ptr
cf.br ^bb21
^bb21:
%101 = llvm.load %100 : !llvm.ptr -> i64
%102 = arith.constant 0 : i32
%104 = arith.extsi %102 : i32 to i64
%103 = arith.cmpi sgt, %101, %104 : i64
cf.cond_br %103, ^bb22, ^bb23
^bb22:
%105 = llvm.load %100 : !llvm.ptr -> i64
%106 = arith.constant 2 : i32
%108 = arith.extsi %106 : i32 to i64
%107 = arith.remsi %105, %108 : i64
%109 = arith.constant 1 : i32
%111 = arith.extsi %109 : i32 to i64
%110 = arith.cmpi eq, %107, %111 : i64
cf.cond_br %110, ^bb24, ^bb25
^bb24:
%113 = llvm.load %95 : !llvm.ptr -> i64
%114 = llvm.load %98 : !llvm.ptr -> i64
%112 = func.call @mulmod(%113, %114, %arg2) : (i64, i64, i64) -> i64
llvm.store %112, %95 : i64, !llvm.ptr
cf.br ^bb26
^bb25:
cf.br ^bb26
^bb26:
%116 = llvm.load %98 : !llvm.ptr -> i64
%117 = llvm.load %98 : !llvm.ptr -> i64
%115 = func.call @mulmod(%116, %117, %arg2) : (i64, i64, i64) -> i64
llvm.store %115, %98 : i64, !llvm.ptr
%118 = llvm.load %100 : !llvm.ptr -> i64
%119 = arith.constant 2 : i32
%121 = arith.extsi %119 : i32 to i64
%120 = arith.divsi %118, %121 : i64
llvm.store %120, %100 : i64, !llvm.ptr
cf.br ^bb21
^bb23:
%122 = llvm.load %95 : !llvm.ptr -> i64
func.return %122 : i64
}
func.func @is_prime(%arg0: i64) -> i1 {
%123 = arith.constant 2 : i32
%125 = arith.extsi %123 : i32 to i64
%124 = arith.cmpi slt, %arg0, %125 : i64
cf.cond_br %124, ^bb27, ^bb28
^bb27:
%126 = arith.constant 0 : i1
func.return %126 : i1
^bb28:
cf.br ^bb29
^bb29:
%127 = arith.constant 4 : i32
%129 = arith.extsi %127 : i32 to i64
%128 = arith.cmpi slt, %arg0, %129 : i64
cf.cond_br %128, ^bb30, ^bb31
^bb30:
%130 = arith.constant 1 : i1
func.return %130 : i1
^bb31:
cf.br ^bb32
^bb32:
%131 = arith.constant 2 : i32
%133 = arith.extsi %131 : i32 to i64
%132 = arith.remsi %arg0, %133 : i64
%134 = arith.constant 0 : i32
%136 = arith.extsi %134 : i32 to i64
%135 = arith.cmpi eq, %132, %136 : i64
%137 = scf.if %135 -> (i1) {
%138 = arith.constant true
scf.yield %138 : i1
} else {
%139 = arith.constant 3 : i32
%141 = arith.extsi %139 : i32 to i64
%140 = arith.remsi %arg0, %141 : i64
%142 = arith.constant 0 : i32
%144 = arith.extsi %142 : i32 to i64
%143 = arith.cmpi eq, %140, %144 : i64
scf.yield %143 : i1
}
cf.cond_br %137, ^bb33, ^bb34
^bb33:
%145 = arith.constant 0 : i1
func.return %145 : i1
^bb34:
cf.br ^bb35
^bb35:
%146 = arith.constant 5 : i32
%147 = arith.extsi %146 : i32 to i64
%148 = llvm.mlir.constant(1 : i64) : i64
%149 = llvm.alloca %148 x i64 : (i64) -> !llvm.ptr
llvm.store %147, %149 : i64, !llvm.ptr
cf.br ^bb36
^bb36:
%150 = llvm.load %149 : !llvm.ptr -> i64
%151 = llvm.load %149 : !llvm.ptr -> i64
%152 = arith.muli %150, %151 : i64
%153 = arith.cmpi sle, %152, %arg0 : i64
cf.cond_br %153, ^bb37, ^bb38
^bb37:
%154 = llvm.load %149 : !llvm.ptr -> i64
%155 = arith.remsi %arg0, %154 : i64
%156 = arith.constant 0 : i32
%158 = arith.extsi %156 : i32 to i64
%157 = arith.cmpi eq, %155, %158 : i64
%159 = scf.if %157 -> (i1) {
%160 = arith.constant true
scf.yield %160 : i1
} else {
%161 = llvm.load %149 : !llvm.ptr -> i64
%162 = arith.constant 2 : i32
%164 = arith.extsi %162 : i32 to i64
%163 = arith.addi %161, %164 : i64
%165 = arith.remsi %arg0, %163 : i64
%166 = arith.constant 0 : i32
%168 = arith.extsi %166 : i32 to i64
%167 = arith.cmpi eq, %165, %168 : i64
scf.yield %167 : i1
}
cf.cond_br %159, ^bb39, ^bb40
^bb39:
%169 = arith.constant 0 : i1
func.return %169 : i1
^bb40:
cf.br ^bb41
^bb41:
%170 = llvm.load %149 : !llvm.ptr -> i64
%171 = arith.constant 6 : i32
%173 = arith.extsi %171 : i32 to i64
%172 = arith.addi %170, %173 : i64
llvm.store %172, %149 : i64, !llvm.ptr
cf.br ^bb36
^bb38:
%174 = arith.constant 1 : i1
func.return %174 : i1
}
func.func private @calloc(i64, i64) -> !llvm.ptr
func.func private @free(!llvm.ptr) -> ()
func.func @iroot(%arg0: i64, %arg1: i64) -> i64 {
%175 = arith.constant 1 : i32
%177 = arith.extsi %175 : i32 to i64
%176 = arith.cmpi eq, %arg1, %177 : i64
cf.cond_br %176, ^bb42, ^bb43
^bb42:
func.return %arg0 : i64
^bb43:
cf.br ^bb44
^bb44:
%178 = arith.constant 0 : i32
%180 = arith.extsi %178 : i32 to i64
%179 = arith.cmpi sle, %arg0, %180 : i64
cf.cond_br %179, ^bb45, ^bb46
^bb45:
%181 = arith.constant 0 : i32
%182 = arith.extsi %181 : i32 to i64
func.return %182 : i64
^bb46:
cf.br ^bb47
^bb47:
%183 = arith.constant 1 : i32
%184 = arith.extsi %183 : i32 to i64
%185 = llvm.mlir.constant(1 : i64) : i64
%186 = llvm.alloca %185 x i64 : (i64) -> !llvm.ptr
llvm.store %184, %186 : i64, !llvm.ptr
%187 = llvm.mlir.constant(1 : i64) : i64
%188 = llvm.alloca %187 x i64 : (i64) -> !llvm.ptr
llvm.store %arg0, %188 : i64, !llvm.ptr
%189 = arith.constant 2 : i32
%191 = arith.extsi %189 : i32 to i64
%190 = arith.cmpi sge, %arg1, %191 : i64
cf.cond_br %190, ^bb48, ^bb49
^bb48:
%192 = func.call @isqrt(%arg0) : (i64) -> i64
%193 = arith.constant 1 : i32
%195 = arith.extsi %193 : i32 to i64
%194 = arith.addi %192, %195 : i64
llvm.store %194, %188 : i64, !llvm.ptr
cf.br ^bb50
^bb49:
cf.br ^bb50
^bb50:
%196 = arith.constant 3 : i32
%198 = arith.extsi %196 : i32 to i64
%197 = arith.cmpi sge, %arg1, %198 : i64
cf.cond_br %197, ^bb51, ^bb52
^bb51:
%200 = arith.constant 1 : i32
%202 = arith.extsi %200 : i32 to i64
%201 = arith.subi %arg1, %202 : i64
%199 = func.call @iroot(%arg0, %201) : (i64, i64) -> i64
%203 = arith.constant 1 : i32
%205 = arith.extsi %203 : i32 to i64
%204 = arith.addi %199, %205 : i64
llvm.store %204, %188 : i64, !llvm.ptr
cf.br ^bb53
^bb52:
cf.br ^bb53
^bb53:
%206 = llvm.load %188 : !llvm.ptr -> i64
%207 = arith.cmpi sgt, %206, %arg0 : i64
cf.cond_br %207, ^bb54, ^bb55
^bb54:
llvm.store %arg0, %188 : i64, !llvm.ptr
cf.br ^bb56
^bb55:
cf.br ^bb56
^bb56:
cf.br ^bb57
^bb57:
%208 = llvm.load %186 : !llvm.ptr -> i64
%209 = arith.constant 1 : i32
%211 = arith.extsi %209 : i32 to i64
%210 = arith.addi %208, %211 : i64
%212 = llvm.load %188 : !llvm.ptr -> i64
%213 = arith.cmpi slt, %210, %212 : i64
cf.cond_br %213, ^bb58, ^bb59
^bb58:
%214 = llvm.load %186 : !llvm.ptr -> i64
%215 = llvm.load %188 : !llvm.ptr -> i64
%216 = arith.addi %214, %215 : i64
%217 = arith.constant 2 : i32
%219 = arith.extsi %217 : i32 to i64
%218 = arith.divsi %216, %219 : i64
%220 = arith.constant 1 : i32
%221 = arith.extsi %220 : i32 to i64
%222 = llvm.mlir.constant(1 : i64) : i64
%223 = llvm.alloca %222 x i64 : (i64) -> !llvm.ptr
llvm.store %221, %223 : i64, !llvm.ptr
%224 = arith.constant 1 : i32
%225 = arith.extsi %224 : i32 to i64
%226 = llvm.mlir.constant(1 : i64) : i64
%227 = llvm.alloca %226 x i64 : (i64) -> !llvm.ptr
llvm.store %225, %227 : i64, !llvm.ptr
%228 = arith.constant 0 : i32
%229 = arith.extsi %228 : i32 to i64
%230 = llvm.mlir.constant(1 : i64) : i64
%231 = llvm.alloca %230 x i64 : (i64) -> !llvm.ptr
llvm.store %229, %231 : i64, !llvm.ptr
cf.br ^bb60
^bb60:
%232 = llvm.load %231 : !llvm.ptr -> i64
%233 = arith.cmpi slt, %232, %arg1 : i64
cf.cond_br %233, ^bb61, ^bb62
^bb61:
%234 = arith.constant 0 : i32
%236 = arith.extsi %234 : i32 to i64
%235 = arith.cmpi ne, %218, %236 : i64
%237 = scf.if %235 -> (i1) {
%238 = llvm.load %223 : !llvm.ptr -> i64
%239 = arith.divsi %arg0, %218 : i64
%240 = arith.cmpi sgt, %238, %239 : i64
scf.yield %240 : i1
} else {
%241 = arith.constant false
scf.yield %241 : i1
}
cf.cond_br %237, ^bb63, ^bb64
^bb63:
%242 = arith.constant 0 : i32
%243 = arith.extsi %242 : i32 to i64
llvm.store %243, %227 : i64, !llvm.ptr
cf.br ^bb62
^bb64:
cf.br ^bb65
^bb65:
%244 = llvm.load %223 : !llvm.ptr -> i64
%245 = arith.muli %244, %218 : i64
llvm.store %245, %223 : i64, !llvm.ptr
%246 = llvm.load %231 : !llvm.ptr -> i64
%247 = arith.constant 1 : i32
%249 = arith.extsi %247 : i32 to i64
%248 = arith.addi %246, %249 : i64
llvm.store %248, %231 : i64, !llvm.ptr
cf.br ^bb60
^bb62:
%250 = llvm.load %227 : !llvm.ptr -> i64
%251 = arith.constant 1 : i32
%253 = arith.extsi %251 : i32 to i64
%252 = arith.cmpi eq, %250, %253 : i64
%254 = scf.if %252 -> (i1) {
%255 = llvm.load %223 : !llvm.ptr -> i64
%256 = arith.cmpi sle, %255, %arg0 : i64
scf.yield %256 : i1
} else {
%257 = arith.constant false
scf.yield %257 : i1
}
cf.cond_br %254, ^bb66, ^bb67
^bb66:
llvm.store %218, %186 : i64, !llvm.ptr
cf.br ^bb68
^bb67:
llvm.store %218, %188 : i64, !llvm.ptr
cf.br ^bb68
^bb68:
cf.br ^bb57
^bb59:
%258 = llvm.load %186 : !llvm.ptr -> i64
func.return %258 : i64
}
func.func @ipow(%arg0: i64, %arg1: i64) -> i64 {
%259 = arith.constant 1 : i32
%260 = arith.extsi %259 : i32 to i64
%261 = llvm.mlir.constant(1 : i64) : i64
%262 = llvm.alloca %261 x i64 : (i64) -> !llvm.ptr
llvm.store %260, %262 : i64, !llvm.ptr
%263 = llvm.mlir.constant(1 : i64) : i64
%264 = llvm.alloca %263 x i64 : (i64) -> !llvm.ptr
llvm.store %arg0, %264 : i64, !llvm.ptr
%265 = llvm.mlir.constant(1 : i64) : i64
%266 = llvm.alloca %265 x i64 : (i64) -> !llvm.ptr
llvm.store %arg1, %266 : i64, !llvm.ptr
cf.br ^bb69
^bb69:
%267 = llvm.load %266 : !llvm.ptr -> i64
%268 = arith.constant 0 : i32
%270 = arith.extsi %268 : i32 to i64
%269 = arith.cmpi sgt, %267, %270 : i64
cf.cond_br %269, ^bb70, ^bb71
^bb70:
%271 = llvm.load %266 : !llvm.ptr -> i64
%272 = arith.constant 1 : i32
%274 = arith.extsi %272 : i32 to i64
%273 = arith.andi %271, %274 : i64
%275 = arith.constant 1 : i32
%277 = arith.extsi %275 : i32 to i64
%276 = arith.cmpi eq, %273, %277 : i64
cf.cond_br %276, ^bb72, ^bb73
^bb72:
%278 = llvm.load %262 : !llvm.ptr -> i64
%279 = llvm.load %264 : !llvm.ptr -> i64
%280 = arith.muli %278, %279 : i64
llvm.store %280, %262 : i64, !llvm.ptr
cf.br ^bb74
^bb73:
cf.br ^bb74
^bb74:
%281 = llvm.load %264 : !llvm.ptr -> i64
%282 = llvm.load %264 : !llvm.ptr -> i64
%283 = arith.muli %281, %282 : i64
llvm.store %283, %264 : i64, !llvm.ptr
%284 = llvm.load %266 : !llvm.ptr -> i64
%285 = arith.constant 2 : i32
%287 = arith.extsi %285 : i32 to i64
%286 = arith.divsi %284, %287 : i64
llvm.store %286, %266 : i64, !llvm.ptr
cf.br ^bb69
^bb71:
%288 = llvm.load %262 : !llvm.ptr -> i64
func.return %288 : i64
}
func.func @hget(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: !llvm.ptr, %arg3: i64, %arg4: i64) -> i64 {
%289 = llvm.mlir.constant(1 : i64) : i64
%290 = llvm.alloca %289 x i64 : (i64) -> !llvm.ptr
llvm.store %arg4, %290 : i64, !llvm.ptr
%291 = llvm.load %290 : !llvm.ptr -> i64
%292 = arith.constant 0 : i32
%294 = arith.extsi %292 : i32 to i64
%293 = arith.cmpi slt, %291, %294 : i64
cf.cond_br %293, ^bb75, ^bb76
^bb75:
%295 = arith.constant 0 : i32
%296 = llvm.load %290 : !llvm.ptr -> i64
%298 = arith.extsi %295 : i32 to i64
%297 = arith.subi %298, %296 : i64
llvm.store %297, %290 : i64, !llvm.ptr
cf.br ^bb77
^bb76:
cf.br ^bb77
^bb77:
%299 = llvm.load %290 : !llvm.ptr -> i64
%300 = arith.constant 1 : i32
%302 = arith.extsi %300 : i32 to i64
%301 = arith.subi %arg3, %302 : i64
%303 = arith.andi %299, %301 : i64
llvm.store %303, %290 : i64, !llvm.ptr
cf.br ^bb78
^bb78:
%305 = llvm.load %290 : !llvm.ptr -> i64
%306 = llvm.getelementptr %arg2[%305] : (!llvm.ptr, i64) -> !llvm.ptr, i8
%304 = llvm.load %306 : !llvm.ptr -> i8
%307 = arith.constant 0 : i32
%309 = arith.extsi %304 : i8 to i32
%308 = arith.cmpi ne, %309, %307 : i32
cf.cond_br %308, ^bb79, ^bb80
^bb79:
%311 = llvm.load %290 : !llvm.ptr -> i64
%312 = llvm.getelementptr %arg0[%311] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%310 = llvm.load %312 : !llvm.ptr -> i64
%313 = arith.cmpi eq, %310, %arg4 : i64
cf.cond_br %313, ^bb81, ^bb82
^bb81:
%315 = llvm.load %290 : !llvm.ptr -> i64
%316 = llvm.getelementptr %arg1[%315] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%314 = llvm.load %316 : !llvm.ptr -> i64
func.return %314 : i64
^bb82:
cf.br ^bb83
^bb83:
%317 = llvm.load %290 : !llvm.ptr -> i64
%318 = arith.constant 1 : i32
%320 = arith.extsi %318 : i32 to i64
%319 = arith.addi %317, %320 : i64
%321 = arith.constant 1 : i32
%323 = arith.extsi %321 : i32 to i64
%322 = arith.subi %arg3, %323 : i64
%324 = arith.andi %319, %322 : i64
llvm.store %324, %290 : i64, !llvm.ptr
cf.br ^bb78
^bb80:
%325 = arith.constant 0 : i32
%326 = arith.constant 1 : i32
%327 = arith.subi %325, %326 : i32
%328 = arith.extsi %327 : i32 to i64
func.return %328 : i64
}
func.func @hput(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: !llvm.ptr, %arg3: i64, %arg4: i64, %arg5: i64) -> () {
%329 = llvm.mlir.constant(1 : i64) : i64
%330 = llvm.alloca %329 x i64 : (i64) -> !llvm.ptr
llvm.store %arg4, %330 : i64, !llvm.ptr
%331 = llvm.load %330 : !llvm.ptr -> i64
%332 = arith.constant 0 : i32
%334 = arith.extsi %332 : i32 to i64
%333 = arith.cmpi slt, %331, %334 : i64
cf.cond_br %333, ^bb84, ^bb85
^bb84:
%335 = arith.constant 0 : i32
%336 = llvm.load %330 : !llvm.ptr -> i64
%338 = arith.extsi %335 : i32 to i64
%337 = arith.subi %338, %336 : i64
llvm.store %337, %330 : i64, !llvm.ptr
cf.br ^bb86
^bb85:
cf.br ^bb86
^bb86:
%339 = llvm.load %330 : !llvm.ptr -> i64
%340 = arith.constant 1 : i32
%342 = arith.extsi %340 : i32 to i64
%341 = arith.subi %arg3, %342 : i64
%343 = arith.andi %339, %341 : i64
llvm.store %343, %330 : i64, !llvm.ptr
cf.br ^bb87
^bb87:
%345 = llvm.load %330 : !llvm.ptr -> i64
%346 = llvm.getelementptr %arg2[%345] : (!llvm.ptr, i64) -> !llvm.ptr, i8
%344 = llvm.load %346 : !llvm.ptr -> i8
%347 = arith.constant 0 : i32
%349 = arith.extsi %344 : i8 to i32
%348 = arith.cmpi ne, %349, %347 : i32
%350 = scf.if %348 -> (i1) {
%352 = llvm.load %330 : !llvm.ptr -> i64
%353 = llvm.getelementptr %arg0[%352] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%351 = llvm.load %353 : !llvm.ptr -> i64
%354 = arith.cmpi ne, %351, %arg4 : i64
scf.yield %354 : i1
} else {
%355 = arith.constant false
scf.yield %355 : i1
}
cf.cond_br %350, ^bb88, ^bb89
^bb88:
%356 = llvm.load %330 : !llvm.ptr -> i64
%357 = arith.constant 1 : i32
%359 = arith.extsi %357 : i32 to i64
%358 = arith.addi %356, %359 : i64
%360 = arith.constant 1 : i32
%362 = arith.extsi %360 : i32 to i64
%361 = arith.subi %arg3, %362 : i64
%363 = arith.andi %358, %361 : i64
llvm.store %363, %330 : i64, !llvm.ptr
cf.br ^bb87
^bb89:
%364 = arith.constant 1 : i32
%365 = llvm.load %330 : !llvm.ptr -> i64
%366 = arith.trunci %364 : i32 to i8
%367 = llvm.getelementptr %arg2[%365] : (!llvm.ptr, i64) -> !llvm.ptr, i8
llvm.store %366, %367 : i8, !llvm.ptr
%368 = llvm.load %330 : !llvm.ptr -> i64
%369 = llvm.getelementptr %arg0[%368] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %arg4, %369 : i64, !llvm.ptr
%370 = llvm.load %330 : !llvm.ptr -> i64
%371 = llvm.getelementptr %arg1[%370] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %arg5, %371 : i64, !llvm.ptr
func.return
}
func.func @phi(%arg0: i64, %arg1: i64, %arg2: !llvm.ptr, %arg3: !llvm.ptr, %arg4: !llvm.ptr, %arg5: !llvm.ptr, %arg6: i64) -> i64 {
%372 = arith.constant 0 : i32
%374 = arith.extsi %372 : i32 to i64
%373 = arith.cmpi eq, %arg1, %374 : i64
cf.cond_br %373, ^bb90, ^bb91
^bb90:
func.return %arg0 : i64
^bb91:
cf.br ^bb92
^bb92:
%375 = arith.constant 1 : i32
%377 = arith.extsi %375 : i32 to i64
%376 = arith.cmpi eq, %arg1, %377 : i64
cf.cond_br %376, ^bb93, ^bb94
^bb93:
%378 = arith.constant 2 : i32
%380 = arith.extsi %378 : i32 to i64
%379 = arith.divsi %arg0, %380 : i64
%381 = arith.subi %arg0, %379 : i64
func.return %381 : i64
^bb94:
cf.br ^bb95
^bb95:
%382 = arith.constant 2 : i32
%384 = arith.extsi %382 : i32 to i64
%383 = arith.cmpi eq, %arg1, %384 : i64
cf.cond_br %383, ^bb96, ^bb97
^bb96:
%385 = arith.constant 2 : i32
%387 = arith.extsi %385 : i32 to i64
%386 = arith.divsi %arg0, %387 : i64
%388 = arith.subi %arg0, %386 : i64
%389 = arith.constant 3 : i32
%391 = arith.extsi %389 : i32 to i64
%390 = arith.divsi %arg0, %391 : i64
%392 = arith.subi %388, %390 : i64
%393 = arith.constant 6 : i32
%395 = arith.extsi %393 : i32 to i64
%394 = arith.divsi %arg0, %395 : i64
%396 = arith.addi %392, %394 : i64
func.return %396 : i64
^bb97:
cf.br ^bb98
^bb98:
%397 = arith.constant 0 : i32
%399 = arith.extsi %397 : i32 to i64
%398 = arith.cmpi eq, %arg0, %399 : i64
cf.cond_br %398, ^bb99, ^bb100
^bb99:
%400 = arith.constant 0 : i32
%401 = arith.extsi %400 : i32 to i64
func.return %401 : i64
^bb100:
cf.br ^bb101
^bb101:
%402 = arith.constant 10000 : i32
%404 = arith.extsi %402 : i32 to i64
%403 = arith.cmpi slt, %arg0, %404 : i64
cf.cond_br %403, ^bb102, ^bb103
^bb102:
%405 = arith.constant 1000003 : i32
%407 = arith.extsi %405 : i32 to i64
%406 = arith.muli %arg0, %407 : i64
%408 = arith.addi %406, %arg1 : i64
%409 = func.call @hget(%arg3, %arg4, %arg5, %arg6, %408) : (!llvm.ptr, !llvm.ptr, !llvm.ptr, i64, i64) -> i64
%410 = arith.constant 0 : i32
%412 = arith.extsi %410 : i32 to i64
%411 = arith.cmpi sge, %409, %412 : i64
cf.cond_br %411, ^bb105, ^bb106
^bb105:
func.return %409 : i64
^bb106:
cf.br ^bb107
^bb107:
%414 = arith.constant 1 : i32
%416 = arith.extsi %414 : i32 to i64
%415 = arith.subi %arg1, %416 : i64
%413 = func.call @phi(%arg0, %415, %arg2, %arg3, %arg4, %arg5, %arg6) : (i64, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64) -> i64
%419 = arith.constant 1 : i32
%421 = arith.extsi %419 : i32 to i64
%420 = arith.subi %arg1, %421 : i64
%422 = llvm.getelementptr %arg2[%420] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%418 = llvm.load %422 : !llvm.ptr -> i32
%423 = arith.extsi %418 : i32 to i64
%424 = arith.divsi %arg0, %423 : i64
%425 = arith.constant 1 : i32
%427 = arith.extsi %425 : i32 to i64
%426 = arith.subi %arg1, %427 : i64
%417 = func.call @phi(%424, %426, %arg2, %arg3, %arg4, %arg5, %arg6) : (i64, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64) -> i64
%428 = arith.subi %413, %417 : i64
func.call @hput(%arg3, %arg4, %arg5, %arg6, %408, %428) : (!llvm.ptr, !llvm.ptr, !llvm.ptr, i64, i64, i64) -> ()
func.return %428 : i64
^bb103:
cf.br ^bb104
^bb104:
%431 = arith.constant 1 : i32
%433 = arith.extsi %431 : i32 to i64
%432 = arith.subi %arg1, %433 : i64
%430 = func.call @phi(%arg0, %432, %arg2, %arg3, %arg4, %arg5, %arg6) : (i64, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64) -> i64
%436 = arith.constant 1 : i32
%438 = arith.extsi %436 : i32 to i64
%437 = arith.subi %arg1, %438 : i64
%439 = llvm.getelementptr %arg2[%437] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%435 = llvm.load %439 : !llvm.ptr -> i32
%440 = arith.extsi %435 : i32 to i64
%441 = arith.divsi %arg0, %440 : i64
%442 = arith.constant 1 : i32
%444 = arith.extsi %442 : i32 to i64
%443 = arith.subi %arg1, %444 : i64
%434 = func.call @phi(%441, %443, %arg2, %arg3, %arg4, %arg5, %arg6) : (i64, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64) -> i64
%445 = arith.subi %430, %434 : i64
func.return %445 : i64
}
func.func @pi_lehmer(%arg0: i64, %arg1: !llvm.ptr, %arg2: i64, %arg3: !llvm.ptr, %arg4: i64, %arg5: !llvm.ptr, %arg6: !llvm.ptr, %arg7: !llvm.ptr, %arg8: i64, %arg9: !llvm.ptr, %arg10: !llvm.ptr, %arg11: !llvm.ptr, %arg12: i64) -> i64 {
%446 = arith.cmpi slt, %arg0, %arg4 : i64
cf.cond_br %446, ^bb108, ^bb109
^bb108:
%448 = llvm.getelementptr %arg3[%arg0] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%447 = llvm.load %448 : !llvm.ptr -> i32
%449 = arith.extsi %447 : i32 to i64
func.return %449 : i64
^bb109:
cf.br ^bb110
^bb110:
%450 = arith.constant 2 : i32
%452 = arith.extsi %450 : i32 to i64
%451 = arith.cmpi slt, %arg0, %452 : i64
cf.cond_br %451, ^bb111, ^bb112
^bb111:
%453 = arith.constant 0 : i32
%454 = arith.extsi %453 : i32 to i64
func.return %454 : i64
^bb112:
cf.br ^bb113
^bb113:
%455 = func.call @hget(%arg9, %arg10, %arg11, %arg12, %arg0) : (!llvm.ptr, !llvm.ptr, !llvm.ptr, i64, i64) -> i64
%456 = arith.constant 0 : i32
%458 = arith.extsi %456 : i32 to i64
%457 = arith.cmpi sge, %455, %458 : i64
cf.cond_br %457, ^bb114, ^bb115
^bb114:
func.return %455 : i64
^bb115:
cf.br ^bb116
^bb116:
%461 = arith.constant 4 : i32
%462 = arith.extsi %461 : i32 to i64
%460 = func.call @iroot(%arg0, %462) : (i64, i64) -> i64
%459 = func.call @pi_lehmer(%460, %arg1, %arg2, %arg3, %arg4, %arg5, %arg6, %arg7, %arg8, %arg9, %arg10, %arg11, %arg12) : (i64, !llvm.ptr, i64, !llvm.ptr, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64) -> i64
%464 = func.call @isqrt(%arg0) : (i64) -> i64
%463 = func.call @pi_lehmer(%464, %arg1, %arg2, %arg3, %arg4, %arg5, %arg6, %arg7, %arg8, %arg9, %arg10, %arg11, %arg12) : (i64, !llvm.ptr, i64, !llvm.ptr, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64) -> i64
%467 = arith.constant 3 : i32
%468 = arith.extsi %467 : i32 to i64
%466 = func.call @iroot(%arg0, %468) : (i64, i64) -> i64
%465 = func.call @pi_lehmer(%466, %arg1, %arg2, %arg3, %arg4, %arg5, %arg6, %arg7, %arg8, %arg9, %arg10, %arg11, %arg12) : (i64, !llvm.ptr, i64, !llvm.ptr, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64) -> i64
%469 = func.call @phi(%arg0, %459, %arg1, %arg5, %arg6, %arg7, %arg8) : (i64, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64) -> i64
%470 = arith.addi %463, %459 : i64
%471 = arith.constant 2 : i32
%473 = arith.extsi %471 : i32 to i64
%472 = arith.subi %470, %473 : i64
%474 = arith.subi %463, %459 : i64
%475 = arith.constant 1 : i32
%477 = arith.extsi %475 : i32 to i64
%476 = arith.addi %474, %477 : i64
%478 = arith.muli %472, %476 : i64
%479 = arith.constant 2 : i32
%481 = arith.extsi %479 : i32 to i64
%480 = arith.divsi %478, %481 : i64
%482 = arith.addi %469, %480 : i64
%483 = llvm.mlir.constant(1 : i64) : i64
%484 = llvm.alloca %483 x i64 : (i64) -> !llvm.ptr
llvm.store %482, %484 : i64, !llvm.ptr
%485 = llvm.mlir.constant(1 : i64) : i64
%486 = llvm.alloca %485 x i64 : (i64) -> !llvm.ptr
llvm.store %459, %486 : i64, !llvm.ptr
cf.br ^bb117
^bb117:
%487 = llvm.load %486 : !llvm.ptr -> i64
%488 = arith.cmpi slt, %487, %463 : i64
cf.cond_br %488, ^bb118, ^bb119
^bb118:
%490 = llvm.load %486 : !llvm.ptr -> i64
%491 = llvm.getelementptr %arg1[%490] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%489 = llvm.load %491 : !llvm.ptr -> i32
%492 = arith.extsi %489 : i32 to i64
%493 = arith.divsi %arg0, %492 : i64
%494 = llvm.load %484 : !llvm.ptr -> i64
%495 = func.call @pi_lehmer(%493, %arg1, %arg2, %arg3, %arg4, %arg5, %arg6, %arg7, %arg8, %arg9, %arg10, %arg11, %arg12) : (i64, !llvm.ptr, i64, !llvm.ptr, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64) -> i64
%496 = arith.subi %494, %495 : i64
llvm.store %496, %484 : i64, !llvm.ptr
%497 = llvm.load %486 : !llvm.ptr -> i64
%498 = arith.cmpi slt, %497, %465 : i64
cf.cond_br %498, ^bb120, ^bb121
^bb120:
%500 = func.call @isqrt(%493) : (i64) -> i64
%499 = func.call @pi_lehmer(%500, %arg1, %arg2, %arg3, %arg4, %arg5, %arg6, %arg7, %arg8, %arg9, %arg10, %arg11, %arg12) : (i64, !llvm.ptr, i64, !llvm.ptr, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64) -> i64
%501 = llvm.load %486 : !llvm.ptr -> i64
%502 = llvm.mlir.constant(1 : i64) : i64
%503 = llvm.alloca %502 x i64 : (i64) -> !llvm.ptr
llvm.store %501, %503 : i64, !llvm.ptr
cf.br ^bb123
^bb123:
%504 = llvm.load %503 : !llvm.ptr -> i64
%505 = arith.cmpi slt, %504, %499 : i64
cf.cond_br %505, ^bb124, ^bb125
^bb124:
%506 = llvm.load %484 : !llvm.ptr -> i64
%509 = llvm.load %503 : !llvm.ptr -> i64
%510 = llvm.getelementptr %arg1[%509] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%508 = llvm.load %510 : !llvm.ptr -> i32
%511 = arith.extsi %508 : i32 to i64
%512 = arith.divsi %493, %511 : i64
%507 = func.call @pi_lehmer(%512, %arg1, %arg2, %arg3, %arg4, %arg5, %arg6, %arg7, %arg8, %arg9, %arg10, %arg11, %arg12) : (i64, !llvm.ptr, i64, !llvm.ptr, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64) -> i64
%513 = llvm.load %503 : !llvm.ptr -> i64
%514 = arith.subi %507, %513 : i64
%515 = arith.subi %506, %514 : i64
llvm.store %515, %484 : i64, !llvm.ptr
%516 = llvm.load %503 : !llvm.ptr -> i64
%517 = arith.constant 1 : i32
%519 = arith.extsi %517 : i32 to i64
%518 = arith.addi %516, %519 : i64
llvm.store %518, %503 : i64, !llvm.ptr
cf.br ^bb123
^bb125:
cf.br ^bb122
^bb121:
cf.br ^bb122
^bb122:
%520 = llvm.load %486 : !llvm.ptr -> i64
%521 = arith.constant 1 : i32
%523 = arith.extsi %521 : i32 to i64
%522 = arith.addi %520, %523 : i64
llvm.store %522, %486 : i64, !llvm.ptr
cf.br ^bb117
^bb119:
%525 = llvm.load %484 : !llvm.ptr -> i64
func.call @hput(%arg9, %arg10, %arg11, %arg12, %arg0, %525) : (!llvm.ptr, !llvm.ptr, !llvm.ptr, i64, i64, i64) -> ()
%526 = llvm.load %484 : !llvm.ptr -> i64
func.return %526 : i64
}
func.func @prime_pi(%arg0: i64, %arg1: !llvm.ptr, %arg2: i64, %arg3: !llvm.ptr, %arg4: i64, %arg5: !llvm.ptr, %arg6: !llvm.ptr, %arg7: !llvm.ptr, %arg8: i64, %arg9: !llvm.ptr, %arg10: !llvm.ptr, %arg11: !llvm.ptr, %arg12: i64) -> i64 {
%527 = arith.cmpi slt, %arg0, %arg4 : i64
cf.cond_br %527, ^bb126, ^bb127
^bb126:
%529 = llvm.getelementptr %arg3[%arg0] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%528 = llvm.load %529 : !llvm.ptr -> i32
%530 = arith.extsi %528 : i32 to i64
func.return %530 : i64
^bb127:
cf.br ^bb128
^bb128:
%531 = func.call @pi_lehmer(%arg0, %arg1, %arg2, %arg3, %arg4, %arg5, %arg6, %arg7, %arg8, %arg9, %arg10, %arg11, %arg12) : (i64, !llvm.ptr, i64, !llvm.ptr, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64) -> i64
func.return %531 : i64
}
func.func @fsf_from_exps(%arg0: !llvm.ptr, %arg1: i64, %arg2: !llvm.ptr) -> i64 {
%532 = arith.constant 0 : i32
%534 = arith.extsi %532 : i32 to i64
%533 = arith.cmpi eq, %arg1, %534 : i64
cf.cond_br %533, ^bb129, ^bb130
^bb129:
%535 = arith.constant 0 : i32
%536 = arith.extsi %535 : i32 to i64
func.return %536 : i64
^bb130:
cf.br ^bb131
^bb131:
%537 = arith.constant 1 : i32
%539 = arith.extsi %537 : i32 to i64
%538 = arith.cmpi eq, %arg1, %539 : i64
cf.cond_br %538, ^bb132, ^bb133
^bb132:
%540 = arith.constant 1 : i32
%541 = arith.extsi %540 : i32 to i64
func.return %541 : i64
^bb133:
cf.br ^bb134
^bb134:
%542 = arith.constant 1 : 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 0 : i32
%547 = arith.extsi %546 : i32 to i64
%548 = llvm.mlir.constant(1 : i64) : i64
%549 = llvm.alloca %548 x i64 : (i64) -> !llvm.ptr
llvm.store %547, %549 : i64, !llvm.ptr
cf.br ^bb135
^bb135:
%550 = llvm.load %549 : !llvm.ptr -> i64
%551 = arith.cmpi slt, %550, %arg1 : i64
cf.cond_br %551, ^bb136, ^bb137
^bb136:
%553 = llvm.load %549 : !llvm.ptr -> i64
%554 = llvm.getelementptr %arg0[%553] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%552 = llvm.load %554 : !llvm.ptr -> i32
%555 = arith.constant 1 : i32
%556 = arith.cmpi ne, %552, %555 : i32
cf.cond_br %556, ^bb138, ^bb139
^bb138:
%557 = arith.constant 0 : i32
%558 = arith.extsi %557 : i32 to i64
llvm.store %558, %545 : i64, !llvm.ptr
cf.br ^bb140
^bb139:
cf.br ^bb140
^bb140:
%559 = llvm.load %549 : !llvm.ptr -> i64
%560 = arith.constant 1 : i32
%562 = arith.extsi %560 : i32 to i64
%561 = arith.addi %559, %562 : i64
llvm.store %561, %549 : i64, !llvm.ptr
cf.br ^bb135
^bb137:
%563 = llvm.load %545 : !llvm.ptr -> i64
%564 = arith.constant 1 : i32
%566 = arith.extsi %564 : i32 to i64
%565 = arith.cmpi eq, %563, %566 : i64
cf.cond_br %565, ^bb141, ^bb142
^bb141:
%568 = llvm.getelementptr %arg2[%arg1] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%567 = llvm.load %568 : !llvm.ptr -> i64
func.return %567 : i64
^bb142:
cf.br ^bb143
^bb143:
%570 = arith.constant 4 : i32
%571 = arith.extsi %570 : i32 to i64
%569 = func.call @calloc(%arg1, %571) : (i64, i64) -> !llvm.ptr
%573 = arith.constant 8 : i32
%574 = arith.extsi %573 : i32 to i64
%572 = func.call @calloc(%arg1, %574) : (i64, i64) -> !llvm.ptr
%575 = arith.constant 0 : i32
%576 = arith.extsi %575 : i32 to i64
llvm.store %576, %549 : i64, !llvm.ptr
cf.br ^bb144
^bb144:
%577 = llvm.load %549 : !llvm.ptr -> i64
%578 = arith.cmpi slt, %577, %arg1 : i64
cf.cond_br %578, ^bb145, ^bb146
^bb145:
%580 = llvm.load %549 : !llvm.ptr -> i64
%581 = llvm.getelementptr %arg0[%580] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%579 = llvm.load %581 : !llvm.ptr -> i32
%582 = arith.constant 1 : i32
%583 = arith.addi %579, %582 : i32
%584 = llvm.load %549 : !llvm.ptr -> i64
%585 = llvm.getelementptr %569[%584] : (!llvm.ptr, i64) -> !llvm.ptr, i32
llvm.store %583, %585 : i32, !llvm.ptr
%586 = llvm.load %549 : !llvm.ptr -> i64
%587 = arith.constant 1 : i32
%589 = arith.extsi %587 : i32 to i64
%588 = arith.addi %586, %589 : i64
llvm.store %588, %549 : i64, !llvm.ptr
cf.br ^bb144
^bb146:
%590 = arith.constant 1 : i32
%591 = arith.constant 0 : i32
%592 = arith.extsi %590 : i32 to i64
%593 = arith.extsi %591 : i32 to i64
%594 = llvm.getelementptr %572[%593] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %592, %594 : i64, !llvm.ptr
%595 = arith.constant 1 : i32
%596 = arith.extsi %595 : i32 to i64
llvm.store %596, %549 : i64, !llvm.ptr
cf.br ^bb147
^bb147:
%597 = llvm.load %549 : !llvm.ptr -> i64
%598 = arith.cmpi slt, %597, %arg1 : i64
cf.cond_br %598, ^bb148, ^bb149
^bb148:
%600 = llvm.load %549 : !llvm.ptr -> i64
%601 = arith.constant 1 : i32
%603 = arith.extsi %601 : i32 to i64
%602 = arith.subi %600, %603 : i64
%604 = llvm.getelementptr %572[%602] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%599 = llvm.load %604 : !llvm.ptr -> i64
%606 = llvm.load %549 : !llvm.ptr -> i64
%607 = arith.constant 1 : i32
%609 = arith.extsi %607 : i32 to i64
%608 = arith.subi %606, %609 : i64
%610 = llvm.getelementptr %569[%608] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%605 = llvm.load %610 : !llvm.ptr -> i32
%611 = arith.extsi %605 : i32 to i64
%612 = arith.muli %599, %611 : i64
%613 = llvm.load %549 : !llvm.ptr -> i64
%614 = llvm.getelementptr %572[%613] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %612, %614 : i64, !llvm.ptr
%615 = llvm.load %549 : !llvm.ptr -> i64
%616 = arith.constant 1 : i32
%618 = arith.extsi %616 : i32 to i64
%617 = arith.addi %615, %618 : i64
llvm.store %617, %549 : i64, !llvm.ptr
cf.br ^bb147
^bb149:
%620 = arith.constant 1 : i32
%622 = arith.extsi %620 : i32 to i64
%621 = arith.subi %arg1, %622 : i64
%623 = llvm.getelementptr %572[%621] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%619 = llvm.load %623 : !llvm.ptr -> i64
%625 = arith.constant 1 : i32
%627 = arith.extsi %625 : i32 to i64
%626 = arith.subi %arg1, %627 : i64
%628 = llvm.getelementptr %569[%626] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%624 = llvm.load %628 : !llvm.ptr -> i32
%629 = arith.extsi %624 : i32 to i64
%630 = arith.muli %619, %629 : i64
%632 = arith.constant 8 : i32
%633 = arith.extsi %632 : i32 to i64
%631 = func.call @calloc(%630, %633) : (i64, i64) -> !llvm.ptr
%634 = arith.constant 1 : i32
%635 = arith.constant 0 : i32
%636 = arith.extsi %634 : i32 to i64
%637 = arith.extsi %635 : i32 to i64
%638 = llvm.getelementptr %631[%637] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %636, %638 : i64, !llvm.ptr
%640 = arith.muli %arg1, %630 : i64
%641 = arith.constant 4 : i32
%642 = arith.extsi %641 : i32 to i64
%639 = func.call @calloc(%640, %642) : (i64, i64) -> !llvm.ptr
%643 = arith.constant 0 : i32
%644 = arith.extsi %643 : i32 to i64
llvm.store %644, %549 : i64, !llvm.ptr
cf.br ^bb150
^bb150:
%645 = llvm.load %549 : !llvm.ptr -> i64
%646 = arith.cmpi slt, %645, %arg1 : i64
cf.cond_br %646, ^bb151, ^bb152
^bb151:
%648 = llvm.load %549 : !llvm.ptr -> i64
%649 = llvm.getelementptr %572[%648] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%647 = llvm.load %649 : !llvm.ptr -> i64
%651 = llvm.load %549 : !llvm.ptr -> i64
%652 = llvm.getelementptr %569[%651] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%650 = llvm.load %652 : !llvm.ptr -> i32
%653 = arith.extsi %650 : i32 to i64
%654 = arith.constant 0 : i32
%655 = arith.extsi %654 : i32 to i64
%656 = llvm.mlir.constant(1 : i64) : i64
%657 = llvm.alloca %656 x i64 : (i64) -> !llvm.ptr
llvm.store %655, %657 : i64, !llvm.ptr
cf.br ^bb153
^bb153:
%658 = llvm.load %657 : !llvm.ptr -> i64
%659 = arith.cmpi slt, %658, %630 : i64
cf.cond_br %659, ^bb154, ^bb155
^bb154:
%660 = llvm.load %657 : !llvm.ptr -> i64
%661 = arith.divsi %660, %647 : i64
%662 = arith.remsi %661, %653 : i64
%663 = arith.trunci %662 : i64 to i32
%664 = llvm.load %549 : !llvm.ptr -> i64
%665 = arith.muli %664, %630 : i64
%666 = llvm.load %657 : !llvm.ptr -> i64
%667 = arith.addi %665, %666 : i64
%668 = llvm.getelementptr %639[%667] : (!llvm.ptr, i64) -> !llvm.ptr, i32
llvm.store %663, %668 : i32, !llvm.ptr
%669 = llvm.load %657 : !llvm.ptr -> i64
%670 = arith.constant 1 : i32
%672 = arith.extsi %670 : i32 to i64
%671 = arith.addi %669, %672 : i64
llvm.store %671, %657 : i64, !llvm.ptr
cf.br ^bb153
^bb155:
%673 = llvm.load %549 : !llvm.ptr -> i64
%674 = arith.constant 1 : i32
%676 = arith.extsi %674 : i32 to i64
%675 = arith.addi %673, %676 : i64
llvm.store %675, %549 : i64, !llvm.ptr
cf.br ^bb150
^bb152:
%677 = arith.constant 1 : i32
%678 = arith.extsi %677 : i32 to i64
%679 = llvm.mlir.constant(1 : i64) : i64
%680 = llvm.alloca %679 x i64 : (i64) -> !llvm.ptr
llvm.store %678, %680 : i64, !llvm.ptr
%681 = arith.constant 1 : i32
%683 = arith.extsi %681 : i32 to i64
%682 = arith.shli %683, %arg1 : i64
cf.br ^bb156
^bb156:
%684 = llvm.load %680 : !llvm.ptr -> i64
%685 = arith.cmpi slt, %684, %682 : i64
cf.cond_br %685, ^bb157, ^bb158
^bb157:
%686 = arith.constant 0 : i32
%687 = arith.extsi %686 : i32 to i64
%688 = llvm.mlir.constant(1 : i64) : i64
%689 = llvm.alloca %688 x i64 : (i64) -> !llvm.ptr
llvm.store %687, %689 : i64, !llvm.ptr
%690 = arith.constant 0 : i32
%691 = arith.extsi %690 : i32 to i64
llvm.store %691, %549 : i64, !llvm.ptr
cf.br ^bb159
^bb159:
%692 = llvm.load %549 : !llvm.ptr -> i64
%693 = arith.cmpi slt, %692, %arg1 : i64
cf.cond_br %693, ^bb160, ^bb161
^bb160:
%694 = llvm.load %680 : !llvm.ptr -> i64
%695 = llvm.load %549 : !llvm.ptr -> i64
%696 = arith.shrsi %694, %695 : i64
%697 = arith.constant 1 : i32
%699 = arith.extsi %697 : i32 to i64
%698 = arith.andi %696, %699 : i64
%700 = arith.constant 1 : i32
%702 = arith.extsi %700 : i32 to i64
%701 = arith.cmpi eq, %698, %702 : i64
cf.cond_br %701, ^bb162, ^bb163
^bb162:
%703 = llvm.load %689 : !llvm.ptr -> i64
%705 = llvm.load %549 : !llvm.ptr -> i64
%706 = llvm.getelementptr %572[%705] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%704 = llvm.load %706 : !llvm.ptr -> i64
%707 = arith.addi %703, %704 : i64
llvm.store %707, %689 : i64, !llvm.ptr
cf.br ^bb164
^bb163:
cf.br ^bb164
^bb164:
%708 = llvm.load %549 : !llvm.ptr -> i64
%709 = arith.constant 1 : i32
%711 = arith.extsi %709 : i32 to i64
%710 = arith.addi %708, %711 : i64
llvm.store %710, %549 : i64, !llvm.ptr
cf.br ^bb159
^bb161:
%712 = llvm.load %689 : !llvm.ptr -> i64
%713 = llvm.mlir.constant(1 : i64) : i64
%714 = llvm.alloca %713 x i64 : (i64) -> !llvm.ptr
llvm.store %712, %714 : i64, !llvm.ptr
cf.br ^bb165
^bb165:
%715 = llvm.load %714 : !llvm.ptr -> i64
%716 = arith.cmpi slt, %715, %630 : i64
cf.cond_br %716, ^bb166, ^bb167
^bb166:
%717 = llvm.load %714 : !llvm.ptr -> i64
%718 = llvm.load %689 : !llvm.ptr -> i64
%719 = arith.subi %717, %718 : i64
%720 = arith.constant 1 : i32
%721 = arith.extsi %720 : i32 to i64
%722 = llvm.mlir.constant(1 : i64) : i64
%723 = llvm.alloca %722 x i64 : (i64) -> !llvm.ptr
llvm.store %721, %723 : i64, !llvm.ptr
%724 = arith.constant 0 : i32
%725 = arith.extsi %724 : i32 to i64
llvm.store %725, %549 : i64, !llvm.ptr
cf.br ^bb168
^bb168:
%726 = llvm.load %549 : !llvm.ptr -> i64
%727 = arith.cmpi slt, %726, %arg1 : i64
cf.cond_br %727, ^bb169, ^bb170
^bb169:
%728 = llvm.load %680 : !llvm.ptr -> i64
%729 = llvm.load %549 : !llvm.ptr -> i64
%730 = arith.shrsi %728, %729 : i64
%731 = arith.constant 1 : i32
%733 = arith.extsi %731 : i32 to i64
%732 = arith.andi %730, %733 : i64
%734 = arith.constant 1 : i32
%736 = arith.extsi %734 : i32 to i64
%735 = arith.cmpi eq, %732, %736 : i64
cf.cond_br %735, ^bb171, ^bb172
^bb171:
%738 = llvm.load %549 : !llvm.ptr -> i64
%739 = arith.muli %738, %630 : i64
%740 = arith.addi %739, %719 : i64
%741 = llvm.getelementptr %639[%740] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%737 = llvm.load %741 : !llvm.ptr -> i32
%742 = arith.extsi %737 : i32 to i64
%744 = llvm.load %549 : !llvm.ptr -> i64
%745 = llvm.getelementptr %arg0[%744] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%743 = llvm.load %745 : !llvm.ptr -> i32
%746 = arith.extsi %743 : i32 to i64
%747 = arith.cmpi sge, %742, %746 : i64
cf.cond_br %747, ^bb174, ^bb175
^bb174:
%748 = arith.constant 0 : i32
%749 = arith.extsi %748 : i32 to i64
llvm.store %749, %723 : i64, !llvm.ptr
cf.br ^bb170
^bb175:
cf.br ^bb176
^bb176:
cf.br ^bb173
^bb172:
cf.br ^bb173
^bb173:
%750 = llvm.load %549 : !llvm.ptr -> i64
%751 = arith.constant 1 : i32
%753 = arith.extsi %751 : i32 to i64
%752 = arith.addi %750, %753 : i64
llvm.store %752, %549 : i64, !llvm.ptr
cf.br ^bb168
^bb170:
%754 = llvm.load %723 : !llvm.ptr -> i64
%755 = arith.constant 1 : i32
%757 = arith.extsi %755 : i32 to i64
%756 = arith.cmpi eq, %754, %757 : i64
cf.cond_br %756, ^bb177, ^bb178
^bb177:
%759 = llvm.load %714 : !llvm.ptr -> i64
%760 = llvm.getelementptr %631[%759] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%758 = llvm.load %760 : !llvm.ptr -> i64
%762 = llvm.getelementptr %631[%719] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%761 = llvm.load %762 : !llvm.ptr -> i64
%763 = arith.addi %758, %761 : i64
%764 = llvm.load %714 : !llvm.ptr -> i64
%765 = llvm.getelementptr %631[%764] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %763, %765 : i64, !llvm.ptr
cf.br ^bb179
^bb178:
cf.br ^bb179
^bb179:
%766 = llvm.load %714 : !llvm.ptr -> i64
%767 = arith.constant 1 : i32
%769 = arith.extsi %767 : i32 to i64
%768 = arith.addi %766, %769 : i64
llvm.store %768, %714 : i64, !llvm.ptr
cf.br ^bb165
^bb167:
%770 = llvm.load %680 : !llvm.ptr -> i64
%771 = arith.constant 1 : i32
%773 = arith.extsi %771 : i32 to i64
%772 = arith.addi %770, %773 : i64
llvm.store %772, %680 : i64, !llvm.ptr
cf.br ^bb156
^bb158:
%774 = arith.constant 0 : i32
%775 = arith.extsi %774 : i32 to i64
%776 = llvm.mlir.constant(1 : i64) : i64
%777 = llvm.alloca %776 x i64 : (i64) -> !llvm.ptr
llvm.store %775, %777 : i64, !llvm.ptr
%778 = arith.constant 0 : i32
%779 = arith.extsi %778 : i32 to i64
llvm.store %779, %549 : i64, !llvm.ptr
cf.br ^bb180
^bb180:
%780 = llvm.load %549 : !llvm.ptr -> i64
%781 = arith.cmpi slt, %780, %arg1 : i64
cf.cond_br %781, ^bb181, ^bb182
^bb181:
%782 = llvm.load %777 : !llvm.ptr -> i64
%784 = llvm.load %549 : !llvm.ptr -> i64
%785 = llvm.getelementptr %arg0[%784] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%783 = llvm.load %785 : !llvm.ptr -> i32
%786 = arith.extsi %783 : i32 to i64
%788 = llvm.load %549 : !llvm.ptr -> i64
%789 = llvm.getelementptr %572[%788] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%787 = llvm.load %789 : !llvm.ptr -> i64
%790 = arith.muli %786, %787 : i64
%791 = arith.addi %782, %790 : i64
llvm.store %791, %777 : i64, !llvm.ptr
%792 = llvm.load %549 : !llvm.ptr -> i64
%793 = arith.constant 1 : i32
%795 = arith.extsi %793 : i32 to i64
%794 = arith.addi %792, %795 : i64
llvm.store %794, %549 : i64, !llvm.ptr
cf.br ^bb180
^bb182:
%797 = llvm.load %777 : !llvm.ptr -> i64
%798 = llvm.getelementptr %631[%797] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%796 = llvm.load %798 : !llvm.ptr -> i64
func.call @free(%639) : (!llvm.ptr) -> ()
func.call @free(%631) : (!llvm.ptr) -> ()
func.call @free(%572) : (!llvm.ptr) -> ()
func.call @free(%569) : (!llvm.ptr) -> ()
func.return %796 : i64
}
func.func @min_suffix(%arg0: !llvm.ptr, %arg1: i64, %arg2: i64, %arg3: !llvm.ptr) -> i64 {
%803 = arith.constant 1 : i32
%804 = arith.extsi %803 : i32 to i64
%805 = llvm.mlir.constant(1 : i64) : i64
%806 = llvm.alloca %805 x i64 : (i64) -> !llvm.ptr
llvm.store %804, %806 : i64, !llvm.ptr
%807 = arith.constant 0 : i32
%808 = arith.extsi %807 : i32 to i64
%809 = llvm.mlir.constant(1 : i64) : i64
%810 = llvm.alloca %809 x i64 : (i64) -> !llvm.ptr
llvm.store %808, %810 : i64, !llvm.ptr
cf.br ^bb183
^bb183:
%811 = llvm.load %810 : !llvm.ptr -> i64
%812 = arith.cmpi slt, %811, %arg1 : i64
cf.cond_br %812, ^bb184, ^bb185
^bb184:
%814 = llvm.load %810 : !llvm.ptr -> i64
%815 = llvm.getelementptr %arg0[%814] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%813 = llvm.load %815 : !llvm.ptr -> i32
%816 = arith.extsi %813 : i32 to i64
%818 = llvm.load %810 : !llvm.ptr -> i64
%819 = arith.addi %arg2, %818 : i64
%820 = llvm.getelementptr %arg3[%819] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%817 = llvm.load %820 : !llvm.ptr -> i32
%821 = arith.extsi %817 : i32 to i64
%822 = arith.constant 0 : i32
%823 = arith.extsi %822 : i32 to i64
%824 = llvm.mlir.constant(1 : i64) : i64
%825 = llvm.alloca %824 x i64 : (i64) -> !llvm.ptr
llvm.store %823, %825 : i64, !llvm.ptr
cf.br ^bb186
^bb186:
%826 = llvm.load %825 : !llvm.ptr -> i64
%827 = arith.cmpi slt, %826, %816 : i64
cf.cond_br %827, ^bb187, ^bb188
^bb187:
%828 = llvm.load %806 : !llvm.ptr -> i64
%829 = arith.muli %828, %821 : i64
llvm.store %829, %806 : i64, !llvm.ptr
%830 = llvm.load %825 : !llvm.ptr -> i64
%831 = arith.constant 1 : i32
%833 = arith.extsi %831 : i32 to i64
%832 = arith.addi %830, %833 : i64
llvm.store %832, %825 : i64, !llvm.ptr
cf.br ^bb186
^bb188:
%834 = llvm.load %810 : !llvm.ptr -> i64
%835 = arith.constant 1 : i32
%837 = arith.extsi %835 : i32 to i64
%836 = arith.addi %834, %837 : i64
llvm.store %836, %810 : i64, !llvm.ptr
cf.br ^bb183
^bb185:
%838 = llvm.load %806 : !llvm.ptr -> i64
func.return %838 : i64
}
func.func @process_seq(%arg0: !llvm.ptr, %arg1: i64, %arg2: i64, %arg3: !llvm.ptr, %arg4: !llvm.ptr, %arg5: !llvm.ptr, %arg6: i64, %arg7: !llvm.ptr, %arg8: i64, %arg9: !llvm.ptr, %arg10: !llvm.ptr, %arg11: !llvm.ptr, %arg12: i64, %arg13: !llvm.ptr, %arg14: !llvm.ptr, %arg15: !llvm.ptr, %arg16: i64, %arg17: !llvm.ptr, %arg18: !llvm.ptr, %arg19: !llvm.ptr, %arg20: i64) -> () {
%840 = arith.constant 16 : i32
%841 = arith.constant 4 : i32
%842 = arith.extsi %840 : i32 to i64
%843 = arith.extsi %841 : i32 to i64
%839 = func.call @calloc(%842, %843) : (i64, i64) -> !llvm.ptr
%844 = arith.constant 0 : i32
%845 = arith.extsi %844 : i32 to i64
%846 = llvm.mlir.constant(1 : i64) : i64
%847 = llvm.alloca %846 x i64 : (i64) -> !llvm.ptr
llvm.store %845, %847 : i64, !llvm.ptr
cf.br ^bb189
^bb189:
%848 = llvm.load %847 : !llvm.ptr -> i64
%849 = arith.cmpi slt, %848, %arg1 : i64
cf.cond_br %849, ^bb190, ^bb191
^bb190:
%851 = llvm.load %847 : !llvm.ptr -> i64
%852 = llvm.getelementptr %arg0[%851] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%850 = llvm.load %852 : !llvm.ptr -> i32
%853 = llvm.load %847 : !llvm.ptr -> i64
%854 = llvm.getelementptr %839[%853] : (!llvm.ptr, i64) -> !llvm.ptr, i32
llvm.store %850, %854 : i32, !llvm.ptr
%855 = llvm.load %847 : !llvm.ptr -> i64
%856 = arith.constant 1 : i32
%858 = arith.extsi %856 : i32 to i64
%857 = arith.addi %855, %858 : i64
llvm.store %857, %847 : i64, !llvm.ptr
cf.br ^bb189
^bb191:
%859 = arith.constant 1 : i32
%860 = arith.extsi %859 : i32 to i64
llvm.store %860, %847 : i64, !llvm.ptr
cf.br ^bb192
^bb192:
%861 = llvm.load %847 : !llvm.ptr -> i64
%862 = arith.cmpi slt, %861, %arg1 : i64
cf.cond_br %862, ^bb193, ^bb194
^bb193:
%864 = llvm.load %847 : !llvm.ptr -> i64
%865 = llvm.getelementptr %839[%864] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%863 = llvm.load %865 : !llvm.ptr -> i32
%866 = llvm.load %847 : !llvm.ptr -> i64
%867 = arith.constant 1 : i32
%869 = arith.extsi %867 : i32 to i64
%868 = arith.subi %866, %869 : i64
%870 = llvm.mlir.constant(1 : i64) : i64
%871 = llvm.alloca %870 x i64 : (i64) -> !llvm.ptr
llvm.store %868, %871 : i64, !llvm.ptr
cf.br ^bb195
^bb195:
%872 = llvm.load %871 : !llvm.ptr -> i64
%873 = arith.constant 0 : i32
%875 = arith.extsi %873 : i32 to i64
%874 = arith.cmpi sge, %872, %875 : i64
%876 = scf.if %874 -> (i1) {
%878 = llvm.load %871 : !llvm.ptr -> i64
%879 = llvm.getelementptr %839[%878] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%877 = llvm.load %879 : !llvm.ptr -> i32
%880 = arith.cmpi slt, %877, %863 : i32
scf.yield %880 : i1
} else {
%881 = arith.constant false
scf.yield %881 : i1
}
cf.cond_br %876, ^bb196, ^bb197
^bb196:
%883 = llvm.load %871 : !llvm.ptr -> i64
%884 = llvm.getelementptr %839[%883] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%882 = llvm.load %884 : !llvm.ptr -> i32
%885 = llvm.load %871 : !llvm.ptr -> i64
%886 = arith.constant 1 : i32
%888 = arith.extsi %886 : i32 to i64
%887 = arith.addi %885, %888 : i64
%889 = llvm.getelementptr %839[%887] : (!llvm.ptr, i64) -> !llvm.ptr, i32
llvm.store %882, %889 : i32, !llvm.ptr
%890 = llvm.load %871 : !llvm.ptr -> i64
%891 = arith.constant 1 : i32
%893 = arith.extsi %891 : i32 to i64
%892 = arith.subi %890, %893 : i64
llvm.store %892, %871 : i64, !llvm.ptr
cf.br ^bb195
^bb197:
%894 = llvm.load %871 : !llvm.ptr -> i64
%895 = arith.constant 1 : i32
%897 = arith.extsi %895 : i32 to i64
%896 = arith.addi %894, %897 : i64
%898 = llvm.getelementptr %839[%896] : (!llvm.ptr, i64) -> !llvm.ptr, i32
llvm.store %863, %898 : i32, !llvm.ptr
%899 = llvm.load %847 : !llvm.ptr -> i64
%900 = arith.constant 1 : i32
%902 = arith.extsi %900 : i32 to i64
%901 = arith.addi %899, %902 : i64
llvm.store %901, %847 : i64, !llvm.ptr
cf.br ^bb192
^bb194:
%903 = llvm.mlir.constant(1 : i64) : i64
%904 = llvm.alloca %903 x i64 : (i64) -> !llvm.ptr
llvm.store %arg1, %904 : i64, !llvm.ptr
%905 = arith.constant 0 : i32
%906 = arith.extsi %905 : i32 to i64
llvm.store %906, %847 : i64, !llvm.ptr
cf.br ^bb198
^bb198:
%907 = llvm.load %847 : !llvm.ptr -> i64
%908 = arith.cmpi slt, %907, %arg1 : i64
cf.cond_br %908, ^bb199, ^bb200
^bb199:
%909 = llvm.load %904 : !llvm.ptr -> i64
%910 = arith.constant 64 : i32
%912 = arith.extsi %910 : i32 to i64
%911 = arith.muli %909, %912 : i64
%914 = llvm.load %847 : !llvm.ptr -> i64
%915 = llvm.getelementptr %839[%914] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%913 = llvm.load %915 : !llvm.ptr -> i32
%916 = arith.extsi %913 : i32 to i64
%917 = arith.addi %911, %916 : i64
llvm.store %917, %904 : i64, !llvm.ptr
%918 = llvm.load %847 : !llvm.ptr -> i64
%919 = arith.constant 1 : i32
%921 = arith.extsi %919 : i32 to i64
%920 = arith.addi %918, %921 : i64
llvm.store %920, %847 : i64, !llvm.ptr
cf.br ^bb198
^bb200:
%923 = llvm.load %904 : !llvm.ptr -> i64
%922 = func.call @hget(%arg17, %arg18, %arg19, %arg20, %923) : (!llvm.ptr, !llvm.ptr, !llvm.ptr, i64, i64) -> i64
%924 = arith.constant 0 : i32
%925 = arith.extsi %924 : i32 to i64
%926 = llvm.mlir.constant(1 : i64) : i64
%927 = llvm.alloca %926 x i64 : (i64) -> !llvm.ptr
llvm.store %925, %927 : i64, !llvm.ptr
%928 = arith.constant 0 : i32
%930 = arith.extsi %928 : i32 to i64
%929 = arith.cmpi sge, %922, %930 : i64
cf.cond_br %929, ^bb201, ^bb202
^bb201:
llvm.store %922, %927 : i64, !llvm.ptr
cf.br ^bb203
^bb202:
%931 = func.call @fsf_from_exps(%839, %arg1, %arg4) : (!llvm.ptr, i64, !llvm.ptr) -> i64
llvm.store %931, %927 : i64, !llvm.ptr
%933 = llvm.load %904 : !llvm.ptr -> i64
%934 = llvm.load %927 : !llvm.ptr -> i64
func.call @hput(%arg17, %arg18, %arg19, %arg20, %933, %934) : (!llvm.ptr, !llvm.ptr, !llvm.ptr, i64, i64, i64) -> ()
cf.br ^bb203
^bb203:
%936 = arith.constant 0 : i32
%937 = arith.extsi %936 : i32 to i64
%935 = func.call @count_tuples(%arg0, %arg1, %937, %arg2, %arg5, %arg6, %arg7, %arg8, %arg9, %arg10, %arg11, %arg12, %arg13, %arg14, %arg15, %arg16) : (!llvm.ptr, i64, i64, i64, !llvm.ptr, i64, !llvm.ptr, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64) -> i64
%939 = arith.constant 0 : i32
%940 = arith.extsi %939 : i32 to i64
%941 = llvm.getelementptr %arg3[%940] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%938 = llvm.load %941 : !llvm.ptr -> i64
%942 = llvm.load %927 : !llvm.ptr -> i64
%943 = arith.muli %942, %935 : i64
%944 = arith.addi %938, %943 : i64
%945 = arith.constant 0 : i32
%946 = arith.extsi %945 : i32 to i64
%947 = llvm.getelementptr %arg3[%946] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %944, %947 : i64, !llvm.ptr
func.call @free(%839) : (!llvm.ptr) -> ()
func.return
}
func.func @gen_rec(%arg0: i64, %arg1: i64, %arg2: i64, %arg3: !llvm.ptr, %arg4: !llvm.ptr, %arg5: i64, %arg6: !llvm.ptr, %arg7: !llvm.ptr, %arg8: !llvm.ptr, %arg9: i64, %arg10: !llvm.ptr, %arg11: i64, %arg12: !llvm.ptr, %arg13: !llvm.ptr, %arg14: !llvm.ptr, %arg15: i64, %arg16: !llvm.ptr, %arg17: !llvm.ptr, %arg18: !llvm.ptr, %arg19: i64, %arg20: !llvm.ptr, %arg21: !llvm.ptr, %arg22: !llvm.ptr, %arg23: i64) -> () {
%949 = arith.constant 0 : i32
%951 = arith.extsi %949 : i32 to i64
%950 = arith.cmpi sgt, %arg2, %951 : i64
cf.cond_br %950, ^bb204, ^bb205
^bb204:
func.call @process_seq(%arg3, %arg2, %arg5, %arg6, %arg7, %arg8, %arg9, %arg10, %arg11, %arg12, %arg13, %arg14, %arg15, %arg16, %arg17, %arg18, %arg19, %arg20, %arg21, %arg22, %arg23) : (!llvm.ptr, i64, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64, !llvm.ptr, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64) -> ()
cf.br ^bb206
^bb205:
cf.br ^bb206
^bb206:
%953 = arith.constant 10 : i32
%955 = arith.extsi %953 : i32 to i64
%954 = arith.cmpi sge, %arg0, %955 : i64
cf.cond_br %954, ^bb207, ^bb208
^bb207:
func.return
^bb208:
cf.br ^bb209
^bb209:
%957 = llvm.getelementptr %arg4[%arg0] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%956 = llvm.load %957 : !llvm.ptr -> i64
%958 = llvm.mlir.constant(1 : i64) : i64
%959 = llvm.alloca %958 x i64 : (i64) -> !llvm.ptr
llvm.store %956, %959 : i64, !llvm.ptr
%960 = arith.constant 1 : i32
%961 = arith.extsi %960 : i32 to i64
%962 = llvm.mlir.constant(1 : i64) : i64
%963 = llvm.alloca %962 x i64 : (i64) -> !llvm.ptr
llvm.store %961, %963 : i64, !llvm.ptr
cf.br ^bb210
^bb210:
%964 = llvm.load %959 : !llvm.ptr -> i64
%965 = arith.divsi %arg5, %964 : i64
%966 = arith.cmpi sle, %arg1, %965 : i64
cf.cond_br %966, ^bb211, ^bb212
^bb211:
%967 = llvm.load %963 : !llvm.ptr -> i64
%968 = arith.trunci %967 : i64 to i32
%969 = llvm.getelementptr %arg3[%arg2] : (!llvm.ptr, i64) -> !llvm.ptr, i32
llvm.store %968, %969 : i32, !llvm.ptr
%971 = arith.constant 1 : i32
%973 = arith.extsi %971 : i32 to i64
%972 = arith.addi %arg0, %973 : i64
%974 = llvm.load %959 : !llvm.ptr -> i64
%975 = arith.muli %arg1, %974 : i64
%976 = arith.constant 1 : i32
%978 = arith.extsi %976 : i32 to i64
%977 = arith.addi %arg2, %978 : i64
func.call @gen_rec(%972, %975, %977, %arg3, %arg4, %arg5, %arg6, %arg7, %arg8, %arg9, %arg10, %arg11, %arg12, %arg13, %arg14, %arg15, %arg16, %arg17, %arg18, %arg19, %arg20, %arg21, %arg22, %arg23) : (i64, i64, i64, !llvm.ptr, !llvm.ptr, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64, !llvm.ptr, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64) -> ()
%979 = llvm.load %963 : !llvm.ptr -> i64
%980 = arith.constant 1 : i32
%982 = arith.extsi %980 : i32 to i64
%981 = arith.addi %979, %982 : i64
llvm.store %981, %963 : i64, !llvm.ptr
%983 = llvm.load %959 : !llvm.ptr -> i64
%984 = arith.divsi %arg5, %956 : i64
%985 = arith.cmpi sgt, %983, %984 : i64
cf.cond_br %985, ^bb213, ^bb214
^bb213:
cf.br ^bb212
^bb214:
cf.br ^bb215
^bb215:
%986 = llvm.load %959 : !llvm.ptr -> i64
%987 = arith.muli %986, %956 : i64
llvm.store %987, %959 : i64, !llvm.ptr
cf.br ^bb210
^bb212:
func.return
}
func.func @count_tuples(%arg0: !llvm.ptr, %arg1: i64, %arg2: i64, %arg3: i64, %arg4: !llvm.ptr, %arg5: i64, %arg6: !llvm.ptr, %arg7: i64, %arg8: !llvm.ptr, %arg9: !llvm.ptr, %arg10: !llvm.ptr, %arg11: i64, %arg12: !llvm.ptr, %arg13: !llvm.ptr, %arg14: !llvm.ptr, %arg15: i64) -> i64 {
%988 = arith.constant 0 : i32
%990 = arith.extsi %988 : i32 to i64
%989 = arith.cmpi eq, %arg1, %990 : i64
cf.cond_br %989, ^bb216, ^bb217
^bb216:
%991 = arith.constant 1 : i32
%992 = arith.extsi %991 : i32 to i64
func.return %992 : i64
^bb217:
cf.br ^bb218
^bb218:
%993 = arith.constant 2 : i32
%995 = arith.extsi %993 : i32 to i64
%994 = arith.cmpi slt, %arg3, %995 : i64
cf.cond_br %994, ^bb219, ^bb220
^bb219:
%996 = arith.constant 0 : i32
%997 = arith.extsi %996 : i32 to i64
func.return %997 : i64
^bb220:
cf.br ^bb221
^bb221:
%998 = arith.constant 1 : i32
%1000 = arith.extsi %998 : i32 to i64
%999 = arith.cmpi eq, %arg1, %1000 : i64
cf.cond_br %999, ^bb222, ^bb223
^bb222:
%1002 = arith.constant 0 : i32
%1003 = arith.extsi %1002 : i32 to i64
%1004 = llvm.getelementptr %arg0[%1003] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%1001 = llvm.load %1004 : !llvm.ptr -> i32
%1005 = arith.extsi %1001 : i32 to i64
%1006 = llvm.mlir.constant(1 : i64) : i64
%1007 = llvm.alloca %1006 x i64 : (i64) -> !llvm.ptr
llvm.store %arg3, %1007 : i64, !llvm.ptr
%1008 = arith.constant 1 : i32
%1010 = arith.extsi %1008 : i32 to i64
%1009 = arith.cmpi ne, %1005, %1010 : i64
cf.cond_br %1009, ^bb225, ^bb226
^bb225:
%1011 = func.call @iroot(%arg3, %1005) : (i64, i64) -> i64
llvm.store %1011, %1007 : i64, !llvm.ptr
cf.br ^bb227
^bb226:
cf.br ^bb227
^bb227:
%1012 = llvm.load %1007 : !llvm.ptr -> i64
%1013 = arith.constant 2 : i32
%1015 = arith.extsi %1013 : i32 to i64
%1014 = arith.cmpi slt, %1012, %1015 : i64
cf.cond_br %1014, ^bb228, ^bb229
^bb228:
%1016 = arith.constant 0 : i32
%1017 = arith.extsi %1016 : i32 to i64
func.return %1017 : i64
^bb229:
cf.br ^bb230
^bb230:
%1019 = llvm.load %1007 : !llvm.ptr -> i64
%1018 = func.call @prime_pi(%1019, %arg4, %arg5, %arg6, %arg7, %arg8, %arg9, %arg10, %arg11, %arg12, %arg13, %arg14, %arg15) : (i64, !llvm.ptr, i64, !llvm.ptr, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64) -> i64
%1020 = arith.subi %1018, %arg2 : i64
%1021 = arith.constant 0 : i32
%1023 = arith.extsi %1021 : i32 to i64
%1022 = arith.cmpi sgt, %1020, %1023 : i64
cf.cond_br %1022, ^bb231, ^bb232
^bb231:
func.return %1020 : i64
^bb232:
cf.br ^bb233
^bb233:
%1024 = arith.constant 0 : i32
%1025 = arith.extsi %1024 : i32 to i64
func.return %1025 : i64
^bb223:
cf.br ^bb224
^bb224:
%1027 = arith.constant 0 : i32
%1028 = arith.extsi %1027 : i32 to i64
%1029 = llvm.getelementptr %arg0[%1028] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%1026 = llvm.load %1029 : !llvm.ptr -> i32
%1030 = arith.extsi %1026 : i32 to i64
%1031 = arith.constant 0 : i32
%1032 = arith.extsi %1031 : i32 to i64
%1033 = llvm.mlir.constant(1 : i64) : i64
%1034 = llvm.alloca %1033 x i64 : (i64) -> !llvm.ptr
llvm.store %1032, %1034 : i64, !llvm.ptr
%1035 = arith.subi %arg5, %arg1 : i64
%1036 = llvm.mlir.constant(1 : i64) : i64
%1037 = llvm.alloca %1036 x i64 : (i64) -> !llvm.ptr
llvm.store %arg2, %1037 : i64, !llvm.ptr
cf.br ^bb234
^bb234:
%1038 = llvm.load %1037 : !llvm.ptr -> i64
%1039 = arith.cmpi sle, %1038, %1035 : i64
cf.cond_br %1039, ^bb235, ^bb236
^bb235:
%1041 = llvm.load %1037 : !llvm.ptr -> i64
%1042 = llvm.getelementptr %arg4[%1041] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%1040 = llvm.load %1042 : !llvm.ptr -> i32
%1043 = arith.extsi %1040 : i32 to i64
%1044 = func.call @ipow(%1043, %1030) : (i64, i64) -> i64
%1045 = arith.cmpi sgt, %1044, %arg3 : i64
cf.cond_br %1045, ^bb237, ^bb238
^bb237:
cf.br ^bb236
^bb238:
cf.br ^bb239
^bb239:
%1046 = arith.divsi %arg3, %1044 : i64
# String concatenation: !llvm.ptr + i32
%1049 = arith.constant 1 : i32
%1051 = arith.extsi %1049 : i32 to i64
%1050 = arith.subi %arg1, %1051 : i64
%1052 = llvm.load %1037 : !llvm.ptr -> i64
%1053 = arith.constant 1 : i32
%1055 = arith.extsi %1053 : i32 to i64
%1054 = arith.addi %1052, %1055 : i64
%1047 = func.call @min_suffix(%1048, %1050, %1054, %arg4) : (!llvm.ptr, i64, i64, !llvm.ptr) -> i64
%1056 = arith.cmpi sgt, %1047, %1046 : i64
cf.cond_br %1056, ^bb240, ^bb241
^bb240:
cf.br ^bb236
^bb241:
cf.br ^bb242
^bb242:
%1057 = llvm.load %1034 : !llvm.ptr -> i64
# String concatenation: !llvm.ptr + i32
%1060 = arith.constant 1 : i32
%1062 = arith.extsi %1060 : i32 to i64
%1061 = arith.subi %arg1, %1062 : i64
%1063 = llvm.load %1037 : !llvm.ptr -> i64
%1064 = arith.constant 1 : i32
%1066 = arith.extsi %1064 : i32 to i64
%1065 = arith.addi %1063, %1066 : i64
%1058 = func.call @count_tuples(%1059, %1061, %1065, %1046, %arg4, %arg5, %arg6, %arg7, %arg8, %arg9, %arg10, %arg11, %arg12, %arg13, %arg14, %arg15) : (!llvm.ptr, i64, i64, i64, !llvm.ptr, i64, !llvm.ptr, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64) -> i64
%1067 = arith.addi %1057, %1058 : i64
llvm.store %1067, %1034 : i64, !llvm.ptr
%1068 = llvm.load %1037 : !llvm.ptr -> i64
%1069 = arith.constant 1 : i32
%1071 = arith.extsi %1069 : i32 to i64
%1070 = arith.addi %1068, %1071 : i64
llvm.store %1070, %1037 : i64, !llvm.ptr
cf.br ^bb234
^bb236:
%1072 = llvm.load %1034 : !llvm.ptr -> i64
func.return %1072 : i64
}
func.func @main() -> i32 {
%1073 = arith.constant 5705032704 : i32
%1074 = arith.extsi %1073 : i32 to i64
%1075 = arith.constant 5000000 : i32
%1076 = arith.extsi %1075 : i32 to i64
%1078 = arith.constant 1 : i32
%1080 = arith.extsi %1078 : i32 to i64
%1079 = arith.addi %1076, %1080 : i64
%1081 = arith.constant 1 : i32
%1082 = arith.extsi %1081 : i32 to i64
%1077 = func.call @calloc(%1079, %1082) : (i64, i64) -> !llvm.ptr
%1084 = arith.constant 5 : i32
%1086 = arith.extsi %1084 : i32 to i64
%1085 = arith.divsi %1076, %1086 : i64
%1087 = arith.constant 10 : i32
%1089 = arith.extsi %1087 : i32 to i64
%1088 = arith.addi %1085, %1089 : i64
%1090 = arith.constant 4 : i32
%1091 = arith.extsi %1090 : i32 to i64
%1083 = func.call @calloc(%1088, %1091) : (i64, i64) -> !llvm.ptr
%1093 = arith.constant 1 : i32
%1095 = arith.extsi %1093 : i32 to i64
%1094 = arith.addi %1076, %1095 : i64
%1096 = arith.constant 4 : i32
%1097 = arith.extsi %1096 : i32 to i64
%1092 = func.call @calloc(%1094, %1097) : (i64, i64) -> !llvm.ptr
%1098 = arith.constant 0 : i32
%1099 = arith.extsi %1098 : i32 to i64
%1100 = llvm.mlir.constant(1 : i64) : i64
%1101 = llvm.alloca %1100 x i64 : (i64) -> !llvm.ptr
llvm.store %1099, %1101 : i64, !llvm.ptr
%1102 = arith.constant 1 : i32
%1103 = arith.constant 0 : i32
%1104 = arith.trunci %1102 : i32 to i8
%1105 = arith.extsi %1103 : i32 to i64
%1106 = llvm.getelementptr %1077[%1105] : (!llvm.ptr, i64) -> !llvm.ptr, i8
llvm.store %1104, %1106 : i8, !llvm.ptr
%1107 = arith.constant 1 : i32
%1108 = arith.constant 1 : i32
%1109 = arith.trunci %1107 : i32 to i8
%1110 = arith.extsi %1108 : i32 to i64
%1111 = llvm.getelementptr %1077[%1110] : (!llvm.ptr, i64) -> !llvm.ptr, i8
llvm.store %1109, %1111 : i8, !llvm.ptr
%1112 = arith.constant 2 : i32
%1113 = arith.extsi %1112 : i32 to i64
%1114 = llvm.mlir.constant(1 : i64) : i64
%1115 = llvm.alloca %1114 x i64 : (i64) -> !llvm.ptr
llvm.store %1113, %1115 : i64, !llvm.ptr
cf.br ^bb243
^bb243:
%1116 = llvm.load %1115 : !llvm.ptr -> i64
%1117 = arith.cmpi sle, %1116, %1076 : i64
cf.cond_br %1117, ^bb244, ^bb245
^bb244:
%1119 = llvm.load %1115 : !llvm.ptr -> i64
%1120 = llvm.getelementptr %1077[%1119] : (!llvm.ptr, i64) -> !llvm.ptr, i8
%1118 = llvm.load %1120 : !llvm.ptr -> i8
%1121 = arith.constant 0 : i32
%1123 = arith.extsi %1118 : i8 to i32
%1122 = arith.cmpi eq, %1123, %1121 : i32
cf.cond_br %1122, ^bb246, ^bb247
^bb246:
%1124 = llvm.load %1115 : !llvm.ptr -> i64
%1125 = arith.trunci %1124 : i64 to i32
%1126 = llvm.load %1101 : !llvm.ptr -> i64
%1127 = llvm.getelementptr %1083[%1126] : (!llvm.ptr, i64) -> !llvm.ptr, i32
llvm.store %1125, %1127 : i32, !llvm.ptr
%1128 = llvm.load %1101 : !llvm.ptr -> i64
%1129 = arith.constant 1 : i32
%1131 = arith.extsi %1129 : i32 to i64
%1130 = arith.addi %1128, %1131 : i64
llvm.store %1130, %1101 : i64, !llvm.ptr
%1132 = llvm.load %1115 : !llvm.ptr -> i64
%1133 = llvm.load %1115 : !llvm.ptr -> i64
%1134 = arith.muli %1132, %1133 : i64
%1135 = llvm.mlir.constant(1 : i64) : i64
%1136 = llvm.alloca %1135 x i64 : (i64) -> !llvm.ptr
llvm.store %1134, %1136 : i64, !llvm.ptr
cf.br ^bb249
^bb249:
%1137 = llvm.load %1136 : !llvm.ptr -> i64
%1138 = arith.cmpi sle, %1137, %1076 : i64
cf.cond_br %1138, ^bb250, ^bb251
^bb250:
%1139 = arith.constant 1 : i32
%1140 = llvm.load %1136 : !llvm.ptr -> i64
%1141 = arith.trunci %1139 : i32 to i8
%1142 = llvm.getelementptr %1077[%1140] : (!llvm.ptr, i64) -> !llvm.ptr, i8
llvm.store %1141, %1142 : i8, !llvm.ptr
%1143 = llvm.load %1136 : !llvm.ptr -> i64
%1144 = llvm.load %1115 : !llvm.ptr -> i64
%1145 = arith.addi %1143, %1144 : i64
llvm.store %1145, %1136 : i64, !llvm.ptr
cf.br ^bb249
^bb251:
cf.br ^bb248
^bb247:
cf.br ^bb248
^bb248:
%1146 = llvm.load %1115 : !llvm.ptr -> i64
%1147 = arith.constant 1 : i32
%1149 = arith.extsi %1147 : i32 to i64
%1148 = arith.addi %1146, %1149 : i64
llvm.store %1148, %1115 : i64, !llvm.ptr
cf.br ^bb243
^bb245:
%1150 = arith.constant 0 : i32
%1151 = arith.extsi %1150 : i32 to i64
%1152 = llvm.mlir.constant(1 : i64) : i64
%1153 = llvm.alloca %1152 x i64 : (i64) -> !llvm.ptr
llvm.store %1151, %1153 : i64, !llvm.ptr
%1154 = arith.constant 0 : i32
%1155 = arith.extsi %1154 : i32 to i64
llvm.store %1155, %1115 : i64, !llvm.ptr
cf.br ^bb252
^bb252:
%1156 = llvm.load %1115 : !llvm.ptr -> i64
%1157 = arith.cmpi sle, %1156, %1076 : i64
cf.cond_br %1157, ^bb253, ^bb254
^bb253:
%1159 = llvm.load %1115 : !llvm.ptr -> i64
%1160 = llvm.getelementptr %1077[%1159] : (!llvm.ptr, i64) -> !llvm.ptr, i8
%1158 = llvm.load %1160 : !llvm.ptr -> i8
%1161 = arith.constant 0 : i32
%1163 = arith.extsi %1158 : i8 to i32
%1162 = arith.cmpi eq, %1163, %1161 : i32
cf.cond_br %1162, ^bb255, ^bb256
^bb255:
%1164 = llvm.load %1153 : !llvm.ptr -> i64
%1165 = arith.constant 1 : i32
%1167 = arith.extsi %1165 : i32 to i64
%1166 = arith.addi %1164, %1167 : i64
llvm.store %1166, %1153 : i64, !llvm.ptr
cf.br ^bb257
^bb256:
cf.br ^bb257
^bb257:
%1168 = llvm.load %1153 : !llvm.ptr -> i64
%1169 = arith.trunci %1168 : i64 to i32
%1170 = llvm.load %1115 : !llvm.ptr -> i64
%1171 = llvm.getelementptr %1092[%1170] : (!llvm.ptr, i64) -> !llvm.ptr, i32
llvm.store %1169, %1171 : i32, !llvm.ptr
%1172 = llvm.load %1115 : !llvm.ptr -> i64
%1173 = arith.constant 1 : i32
%1175 = arith.extsi %1173 : i32 to i64
%1174 = arith.addi %1172, %1175 : i64
llvm.store %1174, %1115 : i64, !llvm.ptr
cf.br ^bb252
^bb254:
%1177 = arith.constant 11 : i32
%1178 = arith.constant 8 : i32
%1179 = arith.extsi %1177 : i32 to i64
%1180 = arith.extsi %1178 : i32 to i64
%1176 = func.call @calloc(%1179, %1180) : (i64, i64) -> !llvm.ptr
%1182 = arith.constant 11 : i32
%1183 = arith.constant 11 : i32
%1184 = arith.muli %1182, %1183 : i32
%1185 = arith.constant 8 : i32
%1186 = arith.extsi %1184 : i32 to i64
%1187 = arith.extsi %1185 : i32 to i64
%1181 = func.call @calloc(%1186, %1187) : (i64, i64) -> !llvm.ptr
%1188 = arith.constant 1 : i32
%1189 = arith.constant 0 : i32
%1190 = arith.extsi %1188 : i32 to i64
%1191 = arith.extsi %1189 : i32 to i64
%1192 = llvm.getelementptr %1181[%1191] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %1190, %1192 : i64, !llvm.ptr
%1193 = arith.constant 1 : i32
%1194 = arith.extsi %1193 : i32 to i64
%1195 = llvm.mlir.constant(1 : i64) : i64
%1196 = llvm.alloca %1195 x i64 : (i64) -> !llvm.ptr
llvm.store %1194, %1196 : i64, !llvm.ptr
cf.br ^bb258
^bb258:
%1197 = llvm.load %1196 : !llvm.ptr -> i64
%1198 = arith.constant 10 : i32
%1200 = arith.extsi %1198 : i32 to i64
%1199 = arith.cmpi sle, %1197, %1200 : i64
cf.cond_br %1199, ^bb259, ^bb260
^bb259:
%1201 = arith.constant 1 : i32
%1202 = arith.extsi %1201 : i32 to i64
%1203 = llvm.mlir.constant(1 : i64) : i64
%1204 = llvm.alloca %1203 x i64 : (i64) -> !llvm.ptr
llvm.store %1202, %1204 : i64, !llvm.ptr
cf.br ^bb261
^bb261:
%1205 = llvm.load %1204 : !llvm.ptr -> i64
%1206 = llvm.load %1196 : !llvm.ptr -> i64
%1207 = arith.cmpi sle, %1205, %1206 : i64
cf.cond_br %1207, ^bb262, ^bb263
^bb262:
%1209 = llvm.load %1196 : !llvm.ptr -> i64
%1210 = arith.constant 1 : i32
%1212 = arith.extsi %1210 : i32 to i64
%1211 = arith.subi %1209, %1212 : i64
%1213 = arith.constant 11 : i32
%1215 = arith.extsi %1213 : i32 to i64
%1214 = arith.muli %1211, %1215 : i64
%1216 = llvm.load %1204 : !llvm.ptr -> i64
%1217 = arith.constant 1 : i32
%1219 = arith.extsi %1217 : i32 to i64
%1218 = arith.subi %1216, %1219 : i64
%1220 = arith.addi %1214, %1218 : i64
%1221 = llvm.getelementptr %1181[%1220] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%1208 = llvm.load %1221 : !llvm.ptr -> i64
%1222 = llvm.load %1204 : !llvm.ptr -> i64
%1224 = llvm.load %1196 : !llvm.ptr -> i64
%1225 = arith.constant 1 : i32
%1227 = arith.extsi %1225 : i32 to i64
%1226 = arith.subi %1224, %1227 : i64
%1228 = arith.constant 11 : i32
%1230 = arith.extsi %1228 : i32 to i64
%1229 = arith.muli %1226, %1230 : i64
%1231 = llvm.load %1204 : !llvm.ptr -> i64
%1232 = arith.addi %1229, %1231 : i64
%1233 = llvm.getelementptr %1181[%1232] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%1223 = llvm.load %1233 : !llvm.ptr -> i64
%1234 = arith.muli %1222, %1223 : i64
%1235 = arith.addi %1208, %1234 : i64
%1236 = llvm.load %1196 : !llvm.ptr -> i64
%1237 = arith.constant 11 : i32
%1239 = arith.extsi %1237 : i32 to i64
%1238 = arith.muli %1236, %1239 : i64
%1240 = llvm.load %1204 : !llvm.ptr -> i64
%1241 = arith.addi %1238, %1240 : i64
%1242 = llvm.getelementptr %1181[%1241] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %1235, %1242 : i64, !llvm.ptr
%1243 = llvm.load %1204 : !llvm.ptr -> i64
%1244 = arith.constant 1 : i32
%1246 = arith.extsi %1244 : i32 to i64
%1245 = arith.addi %1243, %1246 : i64
llvm.store %1245, %1204 : i64, !llvm.ptr
cf.br ^bb261
^bb263:
%1247 = llvm.load %1196 : !llvm.ptr -> i64
%1248 = arith.constant 1 : i32
%1250 = arith.extsi %1248 : i32 to i64
%1249 = arith.addi %1247, %1250 : i64
llvm.store %1249, %1196 : i64, !llvm.ptr
cf.br ^bb258
^bb260:
%1251 = arith.constant 0 : i32
%1252 = arith.extsi %1251 : i32 to i64
llvm.store %1252, %1196 : i64, !llvm.ptr
cf.br ^bb264
^bb264:
%1253 = llvm.load %1196 : !llvm.ptr -> i64
%1254 = arith.constant 10 : i32
%1256 = arith.extsi %1254 : i32 to i64
%1255 = arith.cmpi sle, %1253, %1256 : i64
cf.cond_br %1255, ^bb265, ^bb266
^bb265:
%1257 = arith.constant 0 : i32
%1258 = arith.extsi %1257 : i32 to i64
%1259 = llvm.mlir.constant(1 : i64) : i64
%1260 = llvm.alloca %1259 x i64 : (i64) -> !llvm.ptr
llvm.store %1258, %1260 : i64, !llvm.ptr
%1261 = arith.constant 0 : i32
%1262 = arith.extsi %1261 : i32 to i64
%1263 = llvm.mlir.constant(1 : i64) : i64
%1264 = llvm.alloca %1263 x i64 : (i64) -> !llvm.ptr
llvm.store %1262, %1264 : i64, !llvm.ptr
cf.br ^bb267
^bb267:
%1265 = llvm.load %1264 : !llvm.ptr -> i64
%1266 = llvm.load %1196 : !llvm.ptr -> i64
%1267 = arith.cmpi sle, %1265, %1266 : i64
cf.cond_br %1267, ^bb268, ^bb269
^bb268:
%1268 = llvm.load %1260 : !llvm.ptr -> i64
%1270 = llvm.load %1196 : !llvm.ptr -> i64
%1271 = arith.constant 11 : i32
%1273 = arith.extsi %1271 : i32 to i64
%1272 = arith.muli %1270, %1273 : i64
%1274 = llvm.load %1264 : !llvm.ptr -> i64
%1275 = arith.addi %1272, %1274 : i64
%1276 = llvm.getelementptr %1181[%1275] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%1269 = llvm.load %1276 : !llvm.ptr -> i64
%1277 = arith.addi %1268, %1269 : i64
llvm.store %1277, %1260 : i64, !llvm.ptr
%1278 = llvm.load %1264 : !llvm.ptr -> i64
%1279 = arith.constant 1 : i32
%1281 = arith.extsi %1279 : i32 to i64
%1280 = arith.addi %1278, %1281 : i64
llvm.store %1280, %1264 : i64, !llvm.ptr
cf.br ^bb267
^bb269:
%1282 = llvm.load %1260 : !llvm.ptr -> i64
%1283 = llvm.load %1196 : !llvm.ptr -> i64
%1284 = llvm.getelementptr %1176[%1283] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %1282, %1284 : i64, !llvm.ptr
%1285 = llvm.load %1196 : !llvm.ptr -> i64
%1286 = arith.constant 1 : i32
%1288 = arith.extsi %1286 : i32 to i64
%1287 = arith.addi %1285, %1288 : i64
llvm.store %1287, %1196 : i64, !llvm.ptr
cf.br ^bb264
^bb266:
%1289 = arith.constant 1 : i32
%1290 = arith.constant 22 : i32
%1291 = arith.shli %1289, %1290 : i32
%1292 = arith.extsi %1291 : i32 to i64
%1294 = arith.constant 8 : i32
%1295 = arith.extsi %1294 : i32 to i64
%1293 = func.call @calloc(%1292, %1295) : (i64, i64) -> !llvm.ptr
%1297 = arith.constant 8 : i32
%1298 = arith.extsi %1297 : i32 to i64
%1296 = func.call @calloc(%1292, %1298) : (i64, i64) -> !llvm.ptr
%1300 = arith.constant 1 : i32
%1301 = arith.extsi %1300 : i32 to i64
%1299 = func.call @calloc(%1292, %1301) : (i64, i64) -> !llvm.ptr
%1303 = arith.constant 8 : i32
%1304 = arith.extsi %1303 : i32 to i64
%1302 = func.call @calloc(%1292, %1304) : (i64, i64) -> !llvm.ptr
%1306 = arith.constant 8 : i32
%1307 = arith.extsi %1306 : i32 to i64
%1305 = func.call @calloc(%1292, %1307) : (i64, i64) -> !llvm.ptr
%1309 = arith.constant 1 : i32
%1310 = arith.extsi %1309 : i32 to i64
%1308 = func.call @calloc(%1292, %1310) : (i64, i64) -> !llvm.ptr
%1311 = arith.constant 1 : i32
%1312 = arith.constant 18 : i32
%1313 = arith.shli %1311, %1312 : i32
%1314 = arith.extsi %1313 : i32 to i64
%1316 = arith.constant 8 : i32
%1317 = arith.extsi %1316 : i32 to i64
%1315 = func.call @calloc(%1314, %1317) : (i64, i64) -> !llvm.ptr
%1319 = arith.constant 8 : i32
%1320 = arith.extsi %1319 : i32 to i64
%1318 = func.call @calloc(%1314, %1320) : (i64, i64) -> !llvm.ptr
%1322 = arith.constant 1 : i32
%1323 = arith.extsi %1322 : i32 to i64
%1321 = func.call @calloc(%1314, %1323) : (i64, i64) -> !llvm.ptr
%1325 = arith.constant 10 : i32
%1326 = arith.constant 8 : i32
%1327 = arith.extsi %1325 : i32 to i64
%1328 = arith.extsi %1326 : i32 to i64
%1324 = func.call @calloc(%1327, %1328) : (i64, i64) -> !llvm.ptr
%1329 = arith.constant 2 : i32
%1330 = arith.constant 0 : i32
%1331 = arith.extsi %1329 : i32 to i64
%1332 = arith.extsi %1330 : i32 to i64
%1333 = llvm.getelementptr %1324[%1332] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %1331, %1333 : i64, !llvm.ptr
%1334 = arith.constant 3 : i32
%1335 = arith.constant 1 : i32
%1336 = arith.extsi %1334 : i32 to i64
%1337 = arith.extsi %1335 : i32 to i64
%1338 = llvm.getelementptr %1324[%1337] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %1336, %1338 : i64, !llvm.ptr
%1339 = arith.constant 5 : i32
%1340 = arith.constant 2 : i32
%1341 = arith.extsi %1339 : i32 to i64
%1342 = arith.extsi %1340 : i32 to i64
%1343 = llvm.getelementptr %1324[%1342] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %1341, %1343 : i64, !llvm.ptr
%1344 = arith.constant 7 : i32
%1345 = arith.constant 3 : i32
%1346 = arith.extsi %1344 : i32 to i64
%1347 = arith.extsi %1345 : i32 to i64
%1348 = llvm.getelementptr %1324[%1347] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %1346, %1348 : i64, !llvm.ptr
%1349 = arith.constant 11 : i32
%1350 = arith.constant 4 : i32
%1351 = arith.extsi %1349 : i32 to i64
%1352 = arith.extsi %1350 : i32 to i64
%1353 = llvm.getelementptr %1324[%1352] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %1351, %1353 : i64, !llvm.ptr
%1354 = arith.constant 13 : i32
%1355 = arith.constant 5 : i32
%1356 = arith.extsi %1354 : i32 to i64
%1357 = arith.extsi %1355 : i32 to i64
%1358 = llvm.getelementptr %1324[%1357] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %1356, %1358 : i64, !llvm.ptr
%1359 = arith.constant 17 : i32
%1360 = arith.constant 6 : i32
%1361 = arith.extsi %1359 : i32 to i64
%1362 = arith.extsi %1360 : i32 to i64
%1363 = llvm.getelementptr %1324[%1362] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %1361, %1363 : i64, !llvm.ptr
%1364 = arith.constant 19 : i32
%1365 = arith.constant 7 : i32
%1366 = arith.extsi %1364 : i32 to i64
%1367 = arith.extsi %1365 : i32 to i64
%1368 = llvm.getelementptr %1324[%1367] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %1366, %1368 : i64, !llvm.ptr
%1369 = arith.constant 23 : i32
%1370 = arith.constant 8 : i32
%1371 = arith.extsi %1369 : i32 to i64
%1372 = arith.extsi %1370 : i32 to i64
%1373 = llvm.getelementptr %1324[%1372] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %1371, %1373 : i64, !llvm.ptr
%1374 = arith.constant 29 : i32
%1375 = arith.constant 9 : i32
%1376 = arith.extsi %1374 : i32 to i64
%1377 = arith.extsi %1375 : i32 to i64
%1378 = llvm.getelementptr %1324[%1377] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %1376, %1378 : i64, !llvm.ptr
%1380 = arith.constant 16 : i32
%1381 = arith.constant 4 : i32
%1382 = arith.extsi %1380 : i32 to i64
%1383 = arith.extsi %1381 : i32 to i64
%1379 = func.call @calloc(%1382, %1383) : (i64, i64) -> !llvm.ptr
%1385 = arith.constant 1 : i32
%1386 = arith.constant 8 : i32
%1387 = arith.extsi %1385 : i32 to i64
%1388 = arith.extsi %1386 : i32 to i64
%1384 = func.call @calloc(%1387, %1388) : (i64, i64) -> !llvm.ptr
%1390 = arith.constant 0 : i32
%1391 = arith.constant 1 : i32
%1392 = arith.constant 0 : i32
%1393 = llvm.load %1101 : !llvm.ptr -> i64
%1394 = arith.extsi %1390 : i32 to i64
%1395 = arith.extsi %1391 : i32 to i64
%1396 = arith.extsi %1392 : i32 to i64
func.call @gen_rec(%1394, %1395, %1396, %1379, %1324, %1074, %1384, %1176, %1083, %1393, %1092, %1076, %1293, %1296, %1299, %1292, %1302, %1305, %1308, %1292, %1315, %1318, %1321, %1314) : (i64, i64, i64, !llvm.ptr, !llvm.ptr, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64, !llvm.ptr, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64) -> ()
%1397 = llvm.mlir.addressof @str_0 : !llvm.ptr
%1399 = arith.constant 0 : i32
%1400 = arith.extsi %1399 : i32 to i64
%1401 = llvm.getelementptr %1384[%1400] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%1398 = llvm.load %1401 : !llvm.ptr -> i64
%1402 = llvm.call @printf(%1397, %1398) vararg(!llvm.func<i32 (ptr, ...)>) : (!llvm.ptr, i64) -> i32
%1403 = arith.constant 0 : i32
func.return %1403 : i32
}
}