← All problems
Problem 799
Pentagonal Puzzle: smallest pentagonal number expressible as a sum of two pentagonal numbers in more than 100 ways. Uses Miller-Rabin, Pollard Rho, Cornacchia, Gaussian integers, segmented sieve.
View problem on Project Euler
Performance comparison
Metric Our solution Best known
Time complexity O(n^3)O(n!)
Space complexity O(n^2)O(n!)
Approach Flow solution BFS or A* search
Verdict Optimal
Flow source
# Project Euler 799
# Pentagonal Puzzle: smallest pentagonal number expressible as a sum of
# two pentagonal numbers in more than 100 ways.
# Uses Miller-Rabin, Pollard Rho, Cornacchia, Gaussian integers, segmented sieve.
extern {
function calloc(n: i64, size: i64) -> ptr<void>
function free(p: ptr<void>) -> void
function malloc(n: i64) -> ptr<void>
function sqrt(x: f64) -> f64
}
struct PF {
prime: i64
exp: i32
}
struct GInt {
u: i64
v: i64
}
struct RootEntry {
p: i64
r1: i64
r2: i64
}
let mut rng_state: i64 = 88172645463325252
let mut corn_a: i64 = 0
let mut corn_b: i64 = 0
let mut g_roots: ptr<RootEntry> = null
let mut g_n_roots: i64 = 0
let mut g_next_prime: i64 = 0
function mulmod(a: i64, b: i64, m: i64) -> i64 {
return (((a as i128) * (b as i128)) % (m as i128)) as i64
}
function powmod(base0: i64, exp0: i64, m: i64) -> i64 {
let mut result: i64 = 1 % m
let mut base: i64 = base0 % m
if base < 0 {
base = base + m
}
let mut exp: i64 = exp0
while exp > 0 {
if (exp & 1) != 0 {
result = mulmod(result, base, m)
}
base = mulmod(base, base, m)
exp = exp >> 1
}
return result
}
function gcd_u64(a: i64, b: i64) -> i64 {
let mut x: i64 = a
let mut y: i64 = b
while y != 0 {
let t: i64 = x % y
x = y
y = t
}
return x
}
function xorshift64() -> i64 {
let lo51: i64 = rng_state & 2251799813685247
rng_state = rng_state ^ (lo51 << 13)
rng_state = rng_state ^ (rng_state >> 7)
let lo47: i64 = rng_state & 140737488355327
rng_state = rng_state ^ (lo47 << 17)
return rng_state
}
function is_prime(n: i64) -> i32 {
if n < 2 {
return 0
}
if n % 2 == 0 {
if n == 2 {
return 1
}
return 0
}
if n % 3 == 0 {
if n == 3 {
return 1
}
return 0
}
if n % 5 == 0 {
if n == 5 {
return 1
}
return 0
}
if n % 7 == 0 {
if n == 7 {
return 1
}
return 0
}
if n % 11 == 0 {
if n == 11 {
return 1
}
return 0
}
if n % 13 == 0 {
if n == 13 {
return 1
}
return 0
}
if n % 17 == 0 {
if n == 17 {
return 1
}
return 0
}
if n % 19 == 0 {
if n == 19 {
return 1
}
return 0
}
if n % 23 == 0 {
if n == 23 {
return 1
}
return 0
}
if n % 29 == 0 {
if n == 29 {
return 1
}
return 0
}
if n % 31 == 0 {
if n == 31 {
return 1
}
return 0
}
if n % 37 == 0 {
if n == 37 {
return 1
}
return 0
}
let mut d: i64 = n - 1
let mut s: i64 = 0
while (d & 1) == 0 {
d = d >> 1
s = s + 1
}
let bases: ptr<i64> = malloc(7 * 8)
bases[0] = 2
bases[1] = 325
bases[2] = 9375
bases[3] = 28178
bases[4] = 450775
bases[5] = 9780504
bases[6] = 1795265022
let mut i: i64 = 0
while i < 7 {
let a: i64 = bases[i] % n
if a == 0 {
i = i + 1
continue
}
let mut x: i64 = powmod(a, d, n)
if x == 1 || x == n - 1 {
i = i + 1
continue
}
let mut found: i32 = 0
let mut j: i64 = 0
while j < s - 1 {
x = mulmod(x, x, n)
if x == n - 1 {
found = 1
break
}
j = j + 1
}
if found == 0 {
free(bases)
return 0
}
i = i + 1
}
free(bases)
return 1
}
function pollard_rho(n: i64) -> i64 {
if n % 2 == 0 {
return 2
}
if n % 3 == 0 {
return 3
}
while true {
let c: i64 = 1 + xorshift64() % (n - 2)
let mut x: i64 = xorshift64() % n
let mut y: i64 = x
let mut d: i64 = 1
while d == 1 {
x = (mulmod(x, x, n) + c) % n
y = (mulmod(y, y, n) + c) % n
y = (mulmod(y, y, n) + c) % n
let diff: i64 = 0
if x > y {
diff = x - y
} else {
diff = y - x
}
d = gcd_u64(diff, n)
}
if d != n {
return d
}
}
return 0
}
function factorize(n: i64, out: ptr<PF>) -> i64 {
if n <= 1 {
return 0
}
let stack: ptr<i64> = malloc(128 * 8)
let primes: ptr<i64> = malloc(128 * 8)
let mut sp: i64 = 0
stack[sp] = n
sp = sp + 1
let mut np: i64 = 0
while sp > 0 {
sp = sp - 1
let x: i64 = stack[sp]
if x == 1 {
continue
}
if is_prime(x) != 0 {
primes[np] = x
np = np + 1
continue
}
let d: i64 = pollard_rho(x)
stack[sp] = d
sp = sp + 1
stack[sp] = x / d
sp = sp + 1
}
let mut i: i64 = 0
while i < np {
let mut j: i64 = i + 1
while j < np {
if primes[j] < primes[i] {
let tmp: i64 = primes[i]
primes[i] = primes[j]
primes[j] = tmp
}
j = j + 1
}
i = i + 1
}
let mut count: i64 = 0
i = 0
while i < np {
let p: i64 = primes[i]
let mut e: i32 = 0
while i < np && primes[i] == p {
e = e + 1
i = i + 1
}
out[count].prime = p
out[count].exp = e
count = count + 1
}
free(stack)
free(primes)
return count
}
function isqrt_i64(n: i64) -> i64 {
if n <= 0 {
return 0
}
let mut r: i64 = sqrt(n as f64) as i64
while r > 0 && r * r > n {
r = r - 1
}
while (r + 1) * (r + 1) <= n {
r = r + 1
}
return r
}
function sqrt_neg1_mod_p(p: i64) -> i64 {
let bases: ptr<i64> = malloc(12 * 8)
bases[0] = 2
bases[1] = 3
bases[2] = 5
bases[3] = 6
bases[4] = 7
bases[5] = 10
bases[6] = 11
bases[7] = 13
bases[8] = 17
bases[9] = 19
bases[10] = 23
bases[11] = 29
let mut i: i64 = 0
while i < 12 {
let a: i64 = bases[i] % p
if a != 0 {
if powmod(a, (p - 1) / 2, p) == p - 1 {
let result: i64 = powmod(a, (p - 1) / 4, p)
free(bases)
return result
}
}
i = i + 1
}
free(bases)
let mut a: i64 = 2
while true {
if a % p != 0 {
if powmod(a, (p - 1) / 2, p) == p - 1 {
return powmod(a, (p - 1) / 4, p)
}
}
a = a + 1
}
return 0
}
function cornacchia(p: i64) -> void {
let mut t: i64 = sqrt_neg1_mod_p(p)
let mut attempt: i32 = 0
while attempt < 2 {
if attempt == 1 {
t = p - t
}
let mut r0: i64 = p
let mut r1: i64 = t
while (r1 as i128) * (r1 as i128) > (p as i128) {
let tmp: i64 = r0 % r1
r0 = r1
r1 = tmp
}
let a: i64 = r1
let b2: i64 = p - a * a
let b: i64 = isqrt_i64(b2)
if b * b == b2 {
corn_a = a
corn_b = b
return
}
attempt = attempt + 1
}
corn_a = 0
corn_b = 0
}
function gmul(a_u: i64, a_v: i64, b_u: i64, b_v: i64, ru: ptr<i64>, rv: ptr<i64>) -> void {
ru[0] = a_u * b_u - a_v * b_v
rv[0] = a_u * b_v + a_v * b_u
}
function sort_gint(arr: ptr<GInt>, n: i64) -> void {
let mut i: i64 = 1
while i < n {
let mut j: i64 = i
while j > 0 {
let prev: i64 = j - 1
if arr[prev].u > arr[j].u {
let tu: i64 = arr[prev].u
let tv: i64 = arr[prev].v
arr[prev].u = arr[j].u
arr[prev].v = arr[j].v
arr[j].u = tu
arr[j].v = tv
} else {
if arr[prev].u == arr[j].u && arr[prev].v > arr[j].v {
let tu: i64 = arr[prev].u
let tv: i64 = arr[prev].v
arr[prev].u = arr[j].u
arr[prev].v = arr[j].v
arr[j].u = tu
arr[j].v = tv
} else {
break
}
}
j = j - 1
}
i = i + 1
}
}
function count_pentagonal_sum_ways(m: i64) -> i32 {
let x: i64 = 6 * m - 1
let N: i64 = x * x + 1
let fac: ptr<PF> = malloc(64 * 16)
let nfac: i64 = factorize(N, fac)
let opt_u: ptr<i64> = malloc(64 * 64 * 8)
let opt_v: ptr<i64> = malloc(64 * 64 * 8)
let opt_sizes: ptr<i64> = malloc(64 * 8)
let mut n_opts: i64 = 0
let pow_gp_u: ptr<i64> = malloc(64 * 8)
let pow_gp_v: ptr<i64> = malloc(64 * 8)
let pow_gc_u: ptr<i64> = malloc(64 * 8)
let pow_gc_v: ptr<i64> = malloc(64 * 8)
let mut fi: i64 = 0
while fi < nfac {
let p: i64 = fac[fi].prime
let e: i32 = fac[fi].exp
if p == 2 {
fi = fi + 1
continue
}
cornacchia(p)
let gp_u: i64 = corn_a
let gp_v: i64 = corn_b
let gc_u: i64 = corn_a
let gc_v: i64 = 0 - corn_b
pow_gp_u[0] = 1
pow_gp_v[0] = 0
pow_gc_u[0] = 1
pow_gc_v[0] = 0
let mut k: i32 = 1
while k <= e {
gmul(pow_gp_u[k - 1], pow_gp_v[k - 1], gp_u, gp_v, pow_gp_u + k, pow_gp_v + k)
gmul(pow_gc_u[k - 1], pow_gc_v[k - 1], gc_u, gc_v, pow_gc_u + k, pow_gc_v + k)
k = k + 1
}
let mut kk: i32 = 0
while kk <= e {
let ru: i64 = 0
let rv: i64 = 0
let tmp_u: ptr<i64> = malloc(8)
let tmp_v: ptr<i64> = malloc(8)
gmul(pow_gp_u[kk], pow_gp_v[kk], pow_gc_u[e - kk], pow_gc_v[e - kk], tmp_u, tmp_v)
opt_u[n_opts * 64 + kk] = tmp_u[0]
opt_v[n_opts * 64 + kk] = tmp_v[0]
free(tmp_u)
free(tmp_v)
kk = kk + 1
}
opt_sizes[n_opts] = (e + 1) as i64
n_opts = n_opts + 1
fi = fi + 1
}
let reps_u: ptr<i64> = malloc(8192 * 8)
let reps_v: ptr<i64> = malloc(8192 * 8)
let new_reps_u: ptr<i64> = malloc(8192 * 8)
let new_reps_v: ptr<i64> = malloc(8192 * 8)
let mut n_reps: i64 = 1
reps_u[0] = 1
reps_v[0] = 0
let mut oi: i64 = 0
while oi < n_opts {
let mut n_new: i64 = 0
let mut ri: i64 = 0
while ri < n_reps {
let mut ok: i64 = 0
while ok < opt_sizes[oi] {
if n_new < 8192 {
let tmp_u: ptr<i64> = malloc(8)
let tmp_v: ptr<i64> = malloc(8)
gmul(reps_u[ri], reps_v[ri], opt_u[oi * 64 + ok], opt_v[oi * 64 + ok], tmp_u, tmp_v)
new_reps_u[n_new] = tmp_u[0]
new_reps_v[n_new] = tmp_v[0]
free(tmp_u)
free(tmp_v)
n_new = n_new + 1
}
ok = ok + 1
}
ri = ri + 1
}
let mut ci: i64 = 0
while ci < n_new {
reps_u[ci] = new_reps_u[ci]
reps_v[ci] = new_reps_v[ci]
ci = ci + 1
}
n_reps = n_new
oi = oi + 1
}
let mut i: i64 = 0
while i < n_reps {
let tmp_u: ptr<i64> = malloc(8)
let tmp_v: ptr<i64> = malloc(8)
gmul(reps_u[i], reps_v[i], 1, 1, tmp_u, tmp_v)
reps_u[i] = tmp_u[0]
reps_v[i] = tmp_v[0]
free(tmp_u)
free(tmp_v)
i = i + 1
}
let filtered: ptr<GInt> = malloc(8192 * 16)
let mut n_filtered: i64 = 0
i = 0
while i < n_reps {
let mut u: i64 = reps_u[i]
if u < 0 {
u = 0 - u
}
let mut v: i64 = reps_v[i]
if v < 0 {
v = 0 - v
}
if u == 0 || v == 0 {
i = i + 1
continue
}
if u > v {
let tmp: i64 = u
u = v
v = tmp
}
if u % 3 == 2 && v % 3 == 2 {
filtered[n_filtered].u = u
filtered[n_filtered].v = v
n_filtered = n_filtered + 1
}
i = i + 1
}
sort_gint(filtered, n_filtered)
let mut seen: i32 = 0
i = 0
while i < n_filtered {
if i == 0 || filtered[i].u != filtered[i - 1].u || filtered[i].v != filtered[i - 1].v {
seen = seen + 1
}
i = i + 1
}
free(fac)
free(opt_u)
free(opt_v)
free(opt_sizes)
free(pow_gp_u)
free(pow_gp_v)
free(pow_gc_u)
free(pow_gc_v)
free(reps_u)
free(reps_v)
free(new_reps_u)
free(new_reps_v)
free(filtered)
return seen
}
function sieve_primes(limit: i64, primes: ptr<i64>) -> i64 {
let is_comp: ptr<i8> = calloc(limit + 1, 1)
let mut count: i64 = 0
let mut i: i64 = 2
while i <= limit {
if is_comp[i] == 0 {
primes[count] = i
count = count + 1
let mut j: i64 = i * i
while j <= limit {
is_comp[j] = 1
j = j + i
}
}
i = i + 1
}
free(is_comp)
return count
}
function next_prime_after(n: i64) -> i64 {
let mut x: i64 = n + 1
if x % 2 == 0 {
x = x + 1
}
while is_prime(x) == 0 {
x = x + 2
}
return x
}
function precompute_roots(prime_limit: i64) -> void {
let primes: ptr<i64> = malloc(20000 * 8)
let n_primes: i64 = sieve_primes(prime_limit, primes)
g_roots = malloc(16384 * 24)
g_n_roots = 0
let mut i: i64 = 0
while i < n_primes {
let p: i64 = primes[i]
if p % 4 != 1 {
i = i + 1
continue
}
let s: i64 = sqrt_neg1_mod_p(p)
let inv6: i64 = powmod(6, p - 2, p)
g_roots[g_n_roots].p = p
g_roots[g_n_roots].r1 = ((1 + s) * inv6) % p
g_roots[g_n_roots].r2 = ((1 + p - s) * inv6) % p
g_n_roots = g_n_roots + 1
i = i + 1
}
g_next_prime = next_prime_after(prime_limit)
free(primes)
}
function upper_factor_multiplier(rem: i64, min_prime: i64) -> i64 {
if rem <= 1 {
return 1
}
let mut k: i64 = 0
let mut p: i128 = min_prime as i128
while p <= (rem as i128) {
p = p * (min_prime as i128)
k = k + 1
}
return 1 << k
}
function find_answer(block_size: i64, prime_limit: i64) -> i64 {
precompute_roots(prime_limit)
let B: i64 = block_size
let res: ptr<i64> = malloc(B * 8)
let prod: ptr<i64> = malloc(B * 8)
let mut m0: i64 = 1
while true {
let mut x: i64 = 6 * m0 - 1
let mut nn: i64 = x * x + 1
for i in 0..B {
res[i] = nn / 2
prod[i] = 1
x = x + 6
nn = x * x + 1
}
let mut ri: i64 = 0
while ri < g_n_roots {
let p: i64 = g_roots[ri].p
let mp: i64 = m0 % p
let mut r_idx: i64 = 0
while r_idx < 2 {
let r: i64 = 0
if r_idx == 0 {
r = g_roots[ri].r1
} else {
r = g_roots[ri].r2
}
let mut idx: i64 = (r + p - mp) % p
while idx < B {
let val0: i64 = res[idx]
if val0 % p == 0 {
let mut val: i64 = val0
let mut e: i64 = 0
while val % p == 0 {
val = val / p
e = e + 1
}
res[idx] = val
prod[idx] = prod[idx] * (e + 1)
}
idx = idx + p
}
r_idx = r_idx + 1
}
ri = ri + 1
}
for i in 0..B {
let pr: i64 = prod[i]
let rem: i64 = res[i]
let ub: i64 = pr * upper_factor_multiplier(rem, g_next_prime)
if ub < 202 {
continue
}
let m: i64 = m0 + i
let ways: i32 = count_pentagonal_sum_ways(m)
if ways > 100 {
free(res)
free(prod)
return m * (3 * m - 1) / 2
}
}
m0 = m0 + B
}
return 0
}
function main() -> i32 {
printf("%lld\n", find_answer(50000, 200000))
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; }
typedef struct GInt GInt;
typedef struct PF PF;
typedef struct RootEntry RootEntry;
struct GInt {
int64_t u;
int64_t v;
};
struct PF {
int64_t prime;
int32_t exp;
};
struct RootEntry {
int64_t p;
int64_t r1;
int64_t r2;
};
int64_t mulmod_i64_i64_i64(int64_t a, int64_t b, int64_t m);
int64_t powmod_i64_i64_i64(int64_t base0, int64_t exp0, int64_t m);
int64_t gcd_u64_i64_i64(int64_t a, int64_t b);
int64_t xorshift64(void);
int32_t is_prime_i64(int64_t n);
int64_t pollard_rho_i64(int64_t n);
int64_t factorize_i64_ptr_PF(int64_t n, PF* out);
int64_t isqrt_i64_i64(int64_t n);
int64_t sqrt_neg1_mod_p_i64(int64_t p);
void cornacchia_i64(int64_t p);
void gmul_i64_i64_i64_i64_ptr_i64_ptr_i64(int64_t a_u, int64_t a_v, int64_t b_u, int64_t b_v, int64_t* ru, int64_t* rv);
void sort_gint_ptr_GInt_i64(GInt* arr, int64_t n);
int32_t count_pentagonal_sum_ways_i64(int64_t m);
int64_t sieve_primes_i64_ptr_i64(int64_t limit, int64_t* primes);
int64_t next_prime_after_i64(int64_t n);
void precompute_roots_i64(int64_t prime_limit);
int64_t upper_factor_multiplier_i64_i64(int64_t rem, int64_t min_prime);
int64_t find_answer_i64_i64(int64_t block_size, int64_t prime_limit);
int32_t main(void);
/* Module statics */
static int64_t rng_state = 88172645463325252;
static int64_t corn_a = 0;
static int64_t corn_b = 0;
static RootEntry* g_roots = NULL;
static int64_t g_n_roots = 0;
static int64_t g_next_prime = 0;
int64_t mulmod_i64_i64_i64(int64_t a, int64_t b, int64_t m) {
return ((int64_t)(FLOW_CHECKED_MOD(((((__int128)(a)) * ((__int128)(b)))), (((__int128)(m))))));
}
int64_t powmod_i64_i64_i64(int64_t base0, int64_t exp0, int64_t m) {
int64_t result = FLOW_CHECKED_MOD((1), (m));
int64_t base = FLOW_CHECKED_MOD((base0), (m));
if (base < 0) {
base = (base + m);
}
int64_t exp = exp0;
while (exp > 0) {
if ((exp & 1) != 0) {
result = mulmod_i64_i64_i64(result, base, m);
}
base = mulmod_i64_i64_i64(base, base, m);
exp = FLOW_CHECKED_SHR((exp), (1));
}
return result;
}
int64_t gcd_u64_i64_i64(int64_t a, int64_t b) {
int64_t x = a;
int64_t y = b;
while (y != 0) {
int64_t t = FLOW_CHECKED_MOD((x), (y));
x = y;
y = t;
}
return x;
}
int64_t xorshift64(void) {
int64_t lo51 = (rng_state & 2251799813685247);
rng_state = (rng_state ^ FLOW_CHECKED_SHL((lo51), (13)));
rng_state = (rng_state ^ FLOW_CHECKED_SHR((rng_state), (7)));
int64_t lo47 = (rng_state & 140737488355327);
rng_state = (rng_state ^ FLOW_CHECKED_SHL((lo47), (17)));
return rng_state;
}
int32_t is_prime_i64(int64_t n) {
if (n < 2) {
return 0;
}
if (FLOW_CHECKED_MOD((n), (2)) == 0) {
if (n == 2) {
return 1;
}
return 0;
}
if (FLOW_CHECKED_MOD((n), (3)) == 0) {
if (n == 3) {
return 1;
}
return 0;
}
if (FLOW_CHECKED_MOD((n), (5)) == 0) {
if (n == 5) {
return 1;
}
return 0;
}
if (FLOW_CHECKED_MOD((n), (7)) == 0) {
if (n == 7) {
return 1;
}
return 0;
}
if (FLOW_CHECKED_MOD((n), (11)) == 0) {
if (n == 11) {
return 1;
}
return 0;
}
if (FLOW_CHECKED_MOD((n), (13)) == 0) {
if (n == 13) {
return 1;
}
return 0;
}
if (FLOW_CHECKED_MOD((n), (17)) == 0) {
if (n == 17) {
return 1;
}
return 0;
}
if (FLOW_CHECKED_MOD((n), (19)) == 0) {
if (n == 19) {
return 1;
}
return 0;
}
if (FLOW_CHECKED_MOD((n), (23)) == 0) {
if (n == 23) {
return 1;
}
return 0;
}
if (FLOW_CHECKED_MOD((n), (29)) == 0) {
if (n == 29) {
return 1;
}
return 0;
}
if (FLOW_CHECKED_MOD((n), (31)) == 0) {
if (n == 31) {
return 1;
}
return 0;
}
if (FLOW_CHECKED_MOD((n), (37)) == 0) {
if (n == 37) {
return 1;
}
return 0;
}
int64_t d = (n - 1);
int64_t s = 0;
while ((d & 1) == 0) {
d = FLOW_CHECKED_SHR((d), (1));
s = (s + 1);
}
int64_t* bases = (int64_t*)(malloc((7 * 8)));
bases[0] = 2;
bases[1] = 325;
bases[2] = 9375;
bases[3] = 28178;
bases[4] = 450775;
bases[5] = 9780504;
bases[6] = 1795265022;
int64_t i = 0;
while (i < 7) {
int64_t a = FLOW_CHECKED_MOD((bases[i]), (n));
if (a == 0) {
i = (i + 1);
continue;
}
int64_t x = powmod_i64_i64_i64(a, d, n);
if ((x == 1 || x == (n - 1))) {
i = (i + 1);
continue;
}
int32_t found = 0;
int64_t j = 0;
while (j < (s - 1)) {
x = mulmod_i64_i64_i64(x, x, n);
if (x == (n - 1)) {
found = 1;
break;
}
j = (j + 1);
}
if (found == 0) {
free(bases);
return 0;
}
i = (i + 1);
}
free(bases);
return 1;
}
int64_t pollard_rho_i64(int64_t n) {
if (FLOW_CHECKED_MOD((n), (2)) == 0) {
return 2;
}
if (FLOW_CHECKED_MOD((n), (3)) == 0) {
return 3;
}
while (1) {
int64_t c = (1 + FLOW_CHECKED_MOD((xorshift64()), ((n - 2))));
int64_t x = FLOW_CHECKED_MOD((xorshift64()), (n));
int64_t y = x;
int64_t d = 1;
while (d == 1) {
x = FLOW_CHECKED_MOD(((mulmod_i64_i64_i64(x, x, n) + c)), (n));
y = FLOW_CHECKED_MOD(((mulmod_i64_i64_i64(y, y, n) + c)), (n));
y = FLOW_CHECKED_MOD(((mulmod_i64_i64_i64(y, y, n) + c)), (n));
int64_t diff = 0;
if (x > y) {
diff = (x - y);
} else {
diff = (y - x);
}
d = gcd_u64_i64_i64(diff, n);
}
if (d != n) {
return d;
}
}
return 0;
}
int64_t factorize_i64_ptr_PF(int64_t n, PF* out) {
if (n <= 1) {
return 0;
}
int64_t* stack = (int64_t*)(malloc((128 * 8)));
int64_t* primes = (int64_t*)(malloc((128 * 8)));
int64_t sp = 0;
stack[sp] = n;
sp = (sp + 1);
int64_t np = 0;
while (sp > 0) {
sp = (sp - 1);
int64_t x = stack[sp];
if (x == 1) {
continue;
}
if (is_prime_i64(x) != 0) {
primes[np] = x;
np = (np + 1);
continue;
}
int64_t d = pollard_rho_i64(x);
stack[sp] = d;
sp = (sp + 1);
stack[sp] = FLOW_CHECKED_DIV((x), (d));
sp = (sp + 1);
}
int64_t i = 0;
while (i < np) {
int64_t j = (i + 1);
while (j < np) {
if (primes[j] < primes[i]) {
int64_t tmp = primes[i];
primes[i] = primes[j];
primes[j] = tmp;
}
j = (j + 1);
}
i = (i + 1);
}
int64_t count = 0;
i = 0;
while (i < np) {
int64_t p = primes[i];
int32_t e = 0;
while ((i < np && primes[i] == p)) {
e = (e + 1);
i = (i + 1);
}
out[count].prime = p;
out[count].exp = e;
count = (count + 1);
}
free(stack);
free(primes);
return count;
}
int64_t isqrt_i64_i64(int64_t n) {
if (n <= 0) {
return 0;
}
int64_t r = ((int64_t)(sqrt(((double)(n)))));
while ((r > 0 && (r * r) > n)) {
r = (r - 1);
}
while (((r + 1) * (r + 1)) <= n) {
r = (r + 1);
}
return r;
}
int64_t sqrt_neg1_mod_p_i64(int64_t p) {
int64_t* bases = (int64_t*)(malloc((12 * 8)));
bases[0] = 2;
bases[1] = 3;
bases[2] = 5;
bases[3] = 6;
bases[4] = 7;
bases[5] = 10;
bases[6] = 11;
bases[7] = 13;
bases[8] = 17;
bases[9] = 19;
bases[10] = 23;
bases[11] = 29;
int64_t i = 0;
while (i < 12) {
int64_t a = FLOW_CHECKED_MOD((bases[i]), (p));
if (a != 0) {
if (powmod_i64_i64_i64(a, FLOW_CHECKED_DIV(((p - 1)), (2)), p) == (p - 1)) {
int64_t result = powmod_i64_i64_i64(a, FLOW_CHECKED_DIV(((p - 1)), (4)), p);
free(bases);
return result;
}
}
i = (i + 1);
}
free(bases);
int64_t a = 2;
while (1) {
if (FLOW_CHECKED_MOD((a), (p)) != 0) {
if (powmod_i64_i64_i64(a, FLOW_CHECKED_DIV(((p - 1)), (2)), p) == (p - 1)) {
return powmod_i64_i64_i64(a, FLOW_CHECKED_DIV(((p - 1)), (4)), p);
}
}
a = (a + 1);
}
return 0;
}
void cornacchia_i64(int64_t p) {
int64_t t = sqrt_neg1_mod_p_i64(p);
int32_t attempt = 0;
while (attempt < 2) {
if (attempt == 1) {
t = (p - t);
}
int64_t r0 = p;
int64_t r1 = t;
while ((((__int128)(r1)) * ((__int128)(r1))) > ((__int128)(p))) {
int64_t tmp = FLOW_CHECKED_MOD((r0), (r1));
r0 = r1;
r1 = tmp;
}
int64_t a = r1;
int64_t b2 = (p - (a * a));
int64_t b = isqrt_i64_i64(b2);
if ((b * b) == b2) {
corn_a = a;
corn_b = b;
return;
}
attempt = (attempt + 1);
}
corn_a = 0;
corn_b = 0;
}
void gmul_i64_i64_i64_i64_ptr_i64_ptr_i64(int64_t a_u, int64_t a_v, int64_t b_u, int64_t b_v, int64_t* ru, int64_t* rv) {
ru[0] = ((a_u * b_u) - (a_v * b_v));
rv[0] = ((a_u * b_v) + (a_v * b_u));
}
void sort_gint_ptr_GInt_i64(GInt* arr, int64_t n) {
int64_t i = 1;
while (i < n) {
int64_t j = i;
while (j > 0) {
int64_t prev = (j - 1);
if (arr[prev].u > arr[j].u) {
int64_t tu = arr[prev].u;
int64_t tv = arr[prev].v;
arr[prev].u = arr[j].u;
arr[prev].v = arr[j].v;
arr[j].u = tu;
arr[j].v = tv;
} else {
if ((arr[prev].u == arr[j].u && arr[prev].v > arr[j].v)) {
int64_t tu = arr[prev].u;
int64_t tv = arr[prev].v;
arr[prev].u = arr[j].u;
arr[prev].v = arr[j].v;
arr[j].u = tu;
arr[j].v = tv;
} else {
break;
}
}
j = (j - 1);
}
i = (i + 1);
}
}
int32_t count_pentagonal_sum_ways_i64(int64_t m) {
int64_t x = ((6 * m) - 1);
int64_t N = ((x * x) + 1);
PF* fac = (PF*)(malloc((64 * 16)));
int64_t nfac = factorize_i64_ptr_PF(N, fac);
int64_t* opt_u = (int64_t*)(malloc(((64 * 64) * 8)));
int64_t* opt_v = (int64_t*)(malloc(((64 * 64) * 8)));
int64_t* opt_sizes = (int64_t*)(malloc((64 * 8)));
int64_t n_opts = 0;
int64_t* pow_gp_u = (int64_t*)(malloc((64 * 8)));
int64_t* pow_gp_v = (int64_t*)(malloc((64 * 8)));
int64_t* pow_gc_u = (int64_t*)(malloc((64 * 8)));
int64_t* pow_gc_v = (int64_t*)(malloc((64 * 8)));
int64_t fi = 0;
while (fi < nfac) {
int64_t p = fac[fi].prime;
int32_t e = fac[fi].exp;
if (p == 2) {
fi = (fi + 1);
continue;
}
cornacchia_i64(p);
int64_t gp_u = corn_a;
int64_t gp_v = corn_b;
int64_t gc_u = corn_a;
int64_t gc_v = (0 - corn_b);
pow_gp_u[0] = 1;
pow_gp_v[0] = 0;
pow_gc_u[0] = 1;
pow_gc_v[0] = 0;
int32_t k = 1;
while (k <= e) {
gmul_i64_i64_i64_i64_ptr_i64_ptr_i64(pow_gp_u[(k - 1)], pow_gp_v[(k - 1)], gp_u, gp_v, (pow_gp_u + k), (pow_gp_v + k));
gmul_i64_i64_i64_i64_ptr_i64_ptr_i64(pow_gc_u[(k - 1)], pow_gc_v[(k - 1)], gc_u, gc_v, (pow_gc_u + k), (pow_gc_v + k));
k = (k + 1);
}
int32_t kk = 0;
while (kk <= e) {
int64_t ru = 0;
int64_t rv = 0;
int64_t* tmp_u = (int64_t*)(malloc(8));
int64_t* tmp_v = (int64_t*)(malloc(8));
gmul_i64_i64_i64_i64_ptr_i64_ptr_i64(pow_gp_u[kk], pow_gp_v[kk], pow_gc_u[(e - kk)], pow_gc_v[(e - kk)], tmp_u, tmp_v);
opt_u[((n_opts * 64) + kk)] = tmp_u[0];
opt_v[((n_opts * 64) + kk)] = tmp_v[0];
free(tmp_u);
free(tmp_v);
kk = (kk + 1);
}
opt_sizes[n_opts] = ((int64_t)((e + 1)));
n_opts = (n_opts + 1);
fi = (fi + 1);
}
int64_t* reps_u = (int64_t*)(malloc((8192 * 8)));
int64_t* reps_v = (int64_t*)(malloc((8192 * 8)));
int64_t* new_reps_u = (int64_t*)(malloc((8192 * 8)));
int64_t* new_reps_v = (int64_t*)(malloc((8192 * 8)));
int64_t n_reps = 1;
reps_u[0] = 1;
reps_v[0] = 0;
int64_t oi = 0;
while (oi < n_opts) {
int64_t n_new = 0;
int64_t ri = 0;
while (ri < n_reps) {
int64_t ok = 0;
while (ok < opt_sizes[oi]) {
if (n_new < 8192) {
int64_t* tmp_u = (int64_t*)(malloc(8));
int64_t* tmp_v = (int64_t*)(malloc(8));
gmul_i64_i64_i64_i64_ptr_i64_ptr_i64(reps_u[ri], reps_v[ri], opt_u[((oi * 64) + ok)], opt_v[((oi * 64) + ok)], tmp_u, tmp_v);
new_reps_u[n_new] = tmp_u[0];
new_reps_v[n_new] = tmp_v[0];
free(tmp_u);
free(tmp_v);
n_new = (n_new + 1);
}
ok = (ok + 1);
}
ri = (ri + 1);
}
int64_t ci = 0;
while (ci < n_new) {
reps_u[ci] = new_reps_u[ci];
reps_v[ci] = new_reps_v[ci];
ci = (ci + 1);
}
n_reps = n_new;
oi = (oi + 1);
}
int64_t i = 0;
while (i < n_reps) {
int64_t* tmp_u = (int64_t*)(malloc(8));
int64_t* tmp_v = (int64_t*)(malloc(8));
gmul_i64_i64_i64_i64_ptr_i64_ptr_i64(reps_u[i], reps_v[i], 1, 1, tmp_u, tmp_v);
reps_u[i] = tmp_u[0];
reps_v[i] = tmp_v[0];
free(tmp_u);
free(tmp_v);
i = (i + 1);
}
GInt* filtered = (GInt*)(malloc((8192 * 16)));
int64_t n_filtered = 0;
i = 0;
while (i < n_reps) {
int64_t u = reps_u[i];
if (u < 0) {
u = (0 - u);
}
int64_t v = reps_v[i];
if (v < 0) {
v = (0 - v);
}
if ((u == 0 || v == 0)) {
i = (i + 1);
continue;
}
if (u > v) {
int64_t tmp = u;
u = v;
v = tmp;
}
if ((FLOW_CHECKED_MOD((u), (3)) == 2 && FLOW_CHECKED_MOD((v), (3)) == 2)) {
filtered[n_filtered].u = u;
filtered[n_filtered].v = v;
n_filtered = (n_filtered + 1);
}
i = (i + 1);
}
sort_gint_ptr_GInt_i64(filtered, n_filtered);
int32_t seen = 0;
i = 0;
while (i < n_filtered) {
if (((i == 0 || filtered[i].u != filtered[(i - 1)].u) || filtered[i].v != filtered[(i - 1)].v)) {
seen = (seen + 1);
}
i = (i + 1);
}
free(fac);
free(opt_u);
free(opt_v);
free(opt_sizes);
free(pow_gp_u);
free(pow_gp_v);
free(pow_gc_u);
free(pow_gc_v);
free(reps_u);
free(reps_v);
free(new_reps_u);
free(new_reps_v);
free(filtered);
return seen;
}
int64_t sieve_primes_i64_ptr_i64(int64_t limit, int64_t* primes) {
int8_t* is_comp = (int8_t*)(calloc((limit + 1), 1));
int64_t count = 0;
int64_t i = 2;
while (i <= limit) {
if (is_comp[i] == 0) {
primes[count] = i;
count = (count + 1);
int64_t j = (i * i);
while (j <= limit) {
is_comp[j] = 1;
j = (j + i);
}
}
i = (i + 1);
}
free(is_comp);
return count;
}
int64_t next_prime_after_i64(int64_t n) {
int64_t x = (n + 1);
if (FLOW_CHECKED_MOD((x), (2)) == 0) {
x = (x + 1);
}
while (is_prime_i64(x) == 0) {
x = (x + 2);
}
return x;
}
void precompute_roots_i64(int64_t prime_limit) {
int64_t* primes = (int64_t*)(malloc((20000 * 8)));
int64_t n_primes = sieve_primes_i64_ptr_i64(prime_limit, primes);
g_roots = malloc((16384 * 24));
g_n_roots = 0;
int64_t i = 0;
while (i < n_primes) {
int64_t p = primes[i];
if (FLOW_CHECKED_MOD((p), (4)) != 1) {
i = (i + 1);
continue;
}
int64_t s = sqrt_neg1_mod_p_i64(p);
int64_t inv6 = powmod_i64_i64_i64(6, (p - 2), p);
g_roots[g_n_roots].p = p;
g_roots[g_n_roots].r1 = FLOW_CHECKED_MOD((((1 + s) * inv6)), (p));
g_roots[g_n_roots].r2 = FLOW_CHECKED_MOD(((((1 + p) - s) * inv6)), (p));
g_n_roots = (g_n_roots + 1);
i = (i + 1);
}
g_next_prime = next_prime_after_i64(prime_limit);
free(primes);
}
int64_t upper_factor_multiplier_i64_i64(int64_t rem, int64_t min_prime) {
if (rem <= 1) {
return 1;
}
int64_t k = 0;
__int128 p = ((__int128)(min_prime));
while (p <= ((__int128)(rem))) {
p = (p * ((__int128)(min_prime)));
k = (k + 1);
}
return FLOW_CHECKED_SHL((1), (k));
}
int64_t find_answer_i64_i64(int64_t block_size, int64_t prime_limit) {
precompute_roots_i64(prime_limit);
int64_t B = block_size;
int64_t* res = (int64_t*)(malloc((B * 8)));
int64_t* prod = (int64_t*)(malloc((B * 8)));
int64_t m0 = 1;
while (1) {
int64_t x = ((6 * m0) - 1);
int64_t nn = ((x * x) + 1);
int32_t __flow_step_1 = 1;
for (int32_t i = 0; (0 <= B) ? i < B : i > B; i += (0 <= B) ? 1 : -1) {
res[i] = FLOW_CHECKED_DIV((nn), (2));
prod[i] = 1;
x = (x + 6);
nn = ((x * x) + 1);
}
int64_t ri = 0;
while (ri < g_n_roots) {
int64_t p = g_roots[ri].p;
int64_t mp = FLOW_CHECKED_MOD((m0), (p));
int64_t r_idx = 0;
while (r_idx < 2) {
int64_t r = 0;
if (r_idx == 0) {
r = g_roots[ri].r1;
} else {
r = g_roots[ri].r2;
}
int64_t idx = FLOW_CHECKED_MOD((((r + p) - mp)), (p));
while (idx < B) {
int64_t val0 = res[idx];
if (FLOW_CHECKED_MOD((val0), (p)) == 0) {
int64_t val = val0;
int64_t e = 0;
while (FLOW_CHECKED_MOD((val), (p)) == 0) {
val = FLOW_CHECKED_DIV((val), (p));
e = (e + 1);
}
res[idx] = val;
prod[idx] = (prod[idx] * (e + 1));
}
idx = (idx + p);
}
r_idx = (r_idx + 1);
}
ri = (ri + 1);
}
int32_t __flow_step_2 = 1;
for (int32_t i = 0; (0 <= B) ? i < B : i > B; i += (0 <= B) ? 1 : -1) {
int64_t pr = prod[i];
int64_t rem = res[i];
int64_t ub = (pr * upper_factor_multiplier_i64_i64(rem, g_next_prime));
if (ub < 202) {
continue;
}
int64_t m = (m0 + i);
int32_t ways = count_pentagonal_sum_ways_i64(m);
if (ways > 100) {
free(res);
free(prod);
return FLOW_CHECKED_DIV(((m * ((3 * m) - 1))), (2));
}
}
m0 = (m0 + B);
}
return 0;
}
int32_t main(void) {
printf("%lld\n", find_answer_i64_i64(50000, 200000));
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 private @calloc(i64, i64) -> !llvm.ptr
func.func private @free(!llvm.ptr) -> ()
func.func private @malloc(i64) -> !llvm.ptr
func.func private @sqrt(f64) -> f64
// Struct: PF
// Fields:
// prime: i64
// exp: i32
// Struct: GInt
// Fields:
// u: i64
// v: i64
// Struct: RootEntry
// Fields:
// p: i64
// r1: i64
// r2: i64
// Module static: rng_state
llvm.mlir.global internal @rng_state(88172645463325252 : i64) : i64
// Module static: corn_a
llvm.mlir.global internal @corn_a(0 : i64) : i64
// Module static: corn_b
llvm.mlir.global internal @corn_b(0 : i64) : i64
// Module static: g_roots
llvm.mlir.global internal @g_roots() {addr_space = 0 : i32} : !llvm.ptr {
%0 = llvm.mlir.zero : !llvm.ptr
llvm.return %0 : !llvm.ptr
}
// Module static: g_n_roots
llvm.mlir.global internal @g_n_roots(0 : i64) : i64
// Module static: g_next_prime
llvm.mlir.global internal @g_next_prime(0 : i64) : i64
func.func @mulmod(%arg0: i64, %arg1: i64, %arg2: i64) -> i64 {
%1 = arith.extsi %arg0 : i64 to i128
%2 = arith.extsi %arg1 : i64 to i128
%4 = arith.trunci %1 : i128 to i64
%5 = arith.trunci %2 : i128 to i64
%3 = arith.muli %4, %5 : i64
%6 = arith.extsi %arg2 : i64 to i128
%8 = arith.trunci %6 : i128 to i64
%7 = arith.remsi %3, %8 : i64
func.return %7 : i64
}
func.func @powmod(%arg0: i64, %arg1: i64, %arg2: i64) -> i64 {
%9 = arith.constant 1 : i32
%11 = arith.extsi %9 : i32 to i64
%10 = arith.remsi %11, %arg2 : i64
%12 = llvm.mlir.constant(1 : i64) : i64
%13 = llvm.alloca %12 x i64 : (i64) -> !llvm.ptr
llvm.store %10, %13 : i64, !llvm.ptr
%14 = arith.remsi %arg0, %arg2 : i64
%15 = llvm.mlir.constant(1 : i64) : i64
%16 = llvm.alloca %15 x i64 : (i64) -> !llvm.ptr
llvm.store %14, %16 : i64, !llvm.ptr
%17 = llvm.load %16 : !llvm.ptr -> i64
%18 = arith.constant 0 : i32
%20 = arith.extsi %18 : i32 to i64
%19 = arith.cmpi slt, %17, %20 : i64
cf.cond_br %19, ^bb0, ^bb1
^bb0:
%21 = llvm.load %16 : !llvm.ptr -> i64
%22 = arith.addi %21, %arg2 : i64
llvm.store %22, %16 : i64, !llvm.ptr
cf.br ^bb2
^bb1:
cf.br ^bb2
^bb2:
%23 = llvm.mlir.constant(1 : i64) : i64
%24 = llvm.alloca %23 x i64 : (i64) -> !llvm.ptr
llvm.store %arg1, %24 : i64, !llvm.ptr
cf.br ^bb3
^bb3:
%25 = llvm.load %24 : !llvm.ptr -> i64
%26 = arith.constant 0 : i32
%28 = arith.extsi %26 : i32 to i64
%27 = arith.cmpi sgt, %25, %28 : i64
cf.cond_br %27, ^bb4, ^bb5
^bb4:
%29 = llvm.load %24 : !llvm.ptr -> i64
%30 = arith.constant 1 : i32
%32 = arith.extsi %30 : i32 to i64
%31 = arith.andi %29, %32 : i64
%33 = arith.constant 0 : i32
%35 = arith.extsi %33 : i32 to i64
%34 = arith.cmpi ne, %31, %35 : i64
cf.cond_br %34, ^bb6, ^bb7
^bb6:
%37 = llvm.load %13 : !llvm.ptr -> i64
%38 = llvm.load %16 : !llvm.ptr -> i64
%36 = func.call @mulmod(%37, %38, %arg2) : (i64, i64, i64) -> i64
llvm.store %36, %13 : i64, !llvm.ptr
cf.br ^bb8
^bb7:
cf.br ^bb8
^bb8:
%40 = llvm.load %16 : !llvm.ptr -> i64
%41 = llvm.load %16 : !llvm.ptr -> i64
%39 = func.call @mulmod(%40, %41, %arg2) : (i64, i64, i64) -> i64
llvm.store %39, %16 : i64, !llvm.ptr
%42 = llvm.load %24 : !llvm.ptr -> i64
%43 = arith.constant 1 : i32
%45 = arith.extsi %43 : i32 to i64
%44 = arith.shrsi %42, %45 : i64
llvm.store %44, %24 : i64, !llvm.ptr
cf.br ^bb3
^bb5:
%46 = llvm.load %13 : !llvm.ptr -> i64
func.return %46 : i64
}
func.func @gcd_u64(%arg0: i64, %arg1: i64) -> i64 {
%47 = llvm.mlir.constant(1 : i64) : i64
%48 = llvm.alloca %47 x i64 : (i64) -> !llvm.ptr
llvm.store %arg0, %48 : i64, !llvm.ptr
%49 = llvm.mlir.constant(1 : i64) : i64
%50 = llvm.alloca %49 x i64 : (i64) -> !llvm.ptr
llvm.store %arg1, %50 : i64, !llvm.ptr
cf.br ^bb9
^bb9:
%51 = llvm.load %50 : !llvm.ptr -> i64
%52 = arith.constant 0 : i32
%54 = arith.extsi %52 : i32 to i64
%53 = arith.cmpi ne, %51, %54 : i64
cf.cond_br %53, ^bb10, ^bb11
^bb10:
%55 = llvm.load %48 : !llvm.ptr -> i64
%56 = llvm.load %50 : !llvm.ptr -> i64
%57 = arith.remsi %55, %56 : i64
%58 = llvm.load %50 : !llvm.ptr -> i64
llvm.store %58, %48 : i64, !llvm.ptr
llvm.store %57, %50 : i64, !llvm.ptr
cf.br ^bb9
^bb11:
%59 = llvm.load %48 : !llvm.ptr -> i64
func.return %59 : i64
}
func.func @xorshift64() -> i64 {
%60 = llvm.mlir.addressof @rng_state : !llvm.ptr
%61 = llvm.load %60 : !llvm.ptr -> i64
%62 = arith.constant 2251795518717951 : i32
%64 = arith.extsi %62 : i32 to i64
%63 = arith.andi %61, %64 : i64
%65 = llvm.mlir.addressof @rng_state : !llvm.ptr
%66 = llvm.load %65 : !llvm.ptr -> i64
%67 = arith.constant 13 : i32
%69 = arith.extsi %67 : i32 to i64
%68 = arith.shli %63, %69 : i64
%70 = arith.xori %66, %68 : i64
%71 = llvm.mlir.addressof @rng_state : !llvm.ptr
llvm.store %70, %71 : i64, !llvm.ptr
%72 = llvm.mlir.addressof @rng_state : !llvm.ptr
%73 = llvm.load %72 : !llvm.ptr -> i64
%74 = llvm.mlir.addressof @rng_state : !llvm.ptr
%75 = llvm.load %74 : !llvm.ptr -> i64
%76 = arith.constant 7 : i32
%78 = arith.extsi %76 : i32 to i64
%77 = arith.shrsi %75, %78 : i64
%79 = arith.xori %73, %77 : i64
%80 = llvm.mlir.addressof @rng_state : !llvm.ptr
llvm.store %79, %80 : i64, !llvm.ptr
%81 = llvm.mlir.addressof @rng_state : !llvm.ptr
%82 = llvm.load %81 : !llvm.ptr -> i64
%83 = arith.constant 140733193388031 : i32
%85 = arith.extsi %83 : i32 to i64
%84 = arith.andi %82, %85 : i64
%86 = llvm.mlir.addressof @rng_state : !llvm.ptr
%87 = llvm.load %86 : !llvm.ptr -> i64
%88 = arith.constant 17 : i32
%90 = arith.extsi %88 : i32 to i64
%89 = arith.shli %84, %90 : i64
%91 = arith.xori %87, %89 : i64
%92 = llvm.mlir.addressof @rng_state : !llvm.ptr
llvm.store %91, %92 : i64, !llvm.ptr
%93 = llvm.mlir.addressof @rng_state : !llvm.ptr
%94 = llvm.load %93 : !llvm.ptr -> i64
func.return %94 : i64
}
func.func @is_prime(%arg0: i64) -> i32 {
%95 = arith.constant 2 : i32
%97 = arith.extsi %95 : i32 to i64
%96 = arith.cmpi slt, %arg0, %97 : i64
cf.cond_br %96, ^bb12, ^bb13
^bb12:
%98 = arith.constant 0 : i32
func.return %98 : i32
^bb13:
cf.br ^bb14
^bb14:
%99 = arith.constant 2 : i32
%101 = arith.extsi %99 : i32 to i64
%100 = arith.remsi %arg0, %101 : i64
%102 = arith.constant 0 : i32
%104 = arith.extsi %102 : i32 to i64
%103 = arith.cmpi eq, %100, %104 : i64
cf.cond_br %103, ^bb15, ^bb16
^bb15:
%105 = arith.constant 2 : i32
%107 = arith.extsi %105 : i32 to i64
%106 = arith.cmpi eq, %arg0, %107 : i64
cf.cond_br %106, ^bb18, ^bb19
^bb18:
%108 = arith.constant 1 : i32
func.return %108 : i32
^bb19:
cf.br ^bb20
^bb20:
%109 = arith.constant 0 : i32
func.return %109 : i32
^bb16:
cf.br ^bb17
^bb17:
%110 = arith.constant 3 : i32
%112 = arith.extsi %110 : i32 to i64
%111 = arith.remsi %arg0, %112 : i64
%113 = arith.constant 0 : i32
%115 = arith.extsi %113 : i32 to i64
%114 = arith.cmpi eq, %111, %115 : i64
cf.cond_br %114, ^bb21, ^bb22
^bb21:
%116 = arith.constant 3 : i32
%118 = arith.extsi %116 : i32 to i64
%117 = arith.cmpi eq, %arg0, %118 : i64
cf.cond_br %117, ^bb24, ^bb25
^bb24:
%119 = arith.constant 1 : i32
func.return %119 : i32
^bb25:
cf.br ^bb26
^bb26:
%120 = arith.constant 0 : i32
func.return %120 : i32
^bb22:
cf.br ^bb23
^bb23:
%121 = arith.constant 5 : i32
%123 = arith.extsi %121 : i32 to i64
%122 = arith.remsi %arg0, %123 : i64
%124 = arith.constant 0 : i32
%126 = arith.extsi %124 : i32 to i64
%125 = arith.cmpi eq, %122, %126 : i64
cf.cond_br %125, ^bb27, ^bb28
^bb27:
%127 = arith.constant 5 : i32
%129 = arith.extsi %127 : i32 to i64
%128 = arith.cmpi eq, %arg0, %129 : i64
cf.cond_br %128, ^bb30, ^bb31
^bb30:
%130 = arith.constant 1 : i32
func.return %130 : i32
^bb31:
cf.br ^bb32
^bb32:
%131 = arith.constant 0 : i32
func.return %131 : i32
^bb28:
cf.br ^bb29
^bb29:
%132 = arith.constant 7 : i32
%134 = arith.extsi %132 : i32 to i64
%133 = arith.remsi %arg0, %134 : i64
%135 = arith.constant 0 : i32
%137 = arith.extsi %135 : i32 to i64
%136 = arith.cmpi eq, %133, %137 : i64
cf.cond_br %136, ^bb33, ^bb34
^bb33:
%138 = arith.constant 7 : i32
%140 = arith.extsi %138 : i32 to i64
%139 = arith.cmpi eq, %arg0, %140 : i64
cf.cond_br %139, ^bb36, ^bb37
^bb36:
%141 = arith.constant 1 : i32
func.return %141 : i32
^bb37:
cf.br ^bb38
^bb38:
%142 = arith.constant 0 : i32
func.return %142 : i32
^bb34:
cf.br ^bb35
^bb35:
%143 = arith.constant 11 : i32
%145 = arith.extsi %143 : i32 to i64
%144 = arith.remsi %arg0, %145 : i64
%146 = arith.constant 0 : i32
%148 = arith.extsi %146 : i32 to i64
%147 = arith.cmpi eq, %144, %148 : i64
cf.cond_br %147, ^bb39, ^bb40
^bb39:
%149 = arith.constant 11 : i32
%151 = arith.extsi %149 : i32 to i64
%150 = arith.cmpi eq, %arg0, %151 : i64
cf.cond_br %150, ^bb42, ^bb43
^bb42:
%152 = arith.constant 1 : i32
func.return %152 : i32
^bb43:
cf.br ^bb44
^bb44:
%153 = arith.constant 0 : i32
func.return %153 : i32
^bb40:
cf.br ^bb41
^bb41:
%154 = arith.constant 13 : i32
%156 = arith.extsi %154 : i32 to i64
%155 = arith.remsi %arg0, %156 : i64
%157 = arith.constant 0 : i32
%159 = arith.extsi %157 : i32 to i64
%158 = arith.cmpi eq, %155, %159 : i64
cf.cond_br %158, ^bb45, ^bb46
^bb45:
%160 = arith.constant 13 : i32
%162 = arith.extsi %160 : i32 to i64
%161 = arith.cmpi eq, %arg0, %162 : i64
cf.cond_br %161, ^bb48, ^bb49
^bb48:
%163 = arith.constant 1 : i32
func.return %163 : i32
^bb49:
cf.br ^bb50
^bb50:
%164 = arith.constant 0 : i32
func.return %164 : i32
^bb46:
cf.br ^bb47
^bb47:
%165 = arith.constant 17 : i32
%167 = arith.extsi %165 : i32 to i64
%166 = arith.remsi %arg0, %167 : i64
%168 = arith.constant 0 : i32
%170 = arith.extsi %168 : i32 to i64
%169 = arith.cmpi eq, %166, %170 : i64
cf.cond_br %169, ^bb51, ^bb52
^bb51:
%171 = arith.constant 17 : i32
%173 = arith.extsi %171 : i32 to i64
%172 = arith.cmpi eq, %arg0, %173 : i64
cf.cond_br %172, ^bb54, ^bb55
^bb54:
%174 = arith.constant 1 : i32
func.return %174 : i32
^bb55:
cf.br ^bb56
^bb56:
%175 = arith.constant 0 : i32
func.return %175 : i32
^bb52:
cf.br ^bb53
^bb53:
%176 = arith.constant 19 : i32
%178 = arith.extsi %176 : i32 to i64
%177 = arith.remsi %arg0, %178 : i64
%179 = arith.constant 0 : i32
%181 = arith.extsi %179 : i32 to i64
%180 = arith.cmpi eq, %177, %181 : i64
cf.cond_br %180, ^bb57, ^bb58
^bb57:
%182 = arith.constant 19 : i32
%184 = arith.extsi %182 : i32 to i64
%183 = arith.cmpi eq, %arg0, %184 : i64
cf.cond_br %183, ^bb60, ^bb61
^bb60:
%185 = arith.constant 1 : i32
func.return %185 : i32
^bb61:
cf.br ^bb62
^bb62:
%186 = arith.constant 0 : i32
func.return %186 : i32
^bb58:
cf.br ^bb59
^bb59:
%187 = arith.constant 23 : i32
%189 = arith.extsi %187 : i32 to i64
%188 = arith.remsi %arg0, %189 : i64
%190 = arith.constant 0 : i32
%192 = arith.extsi %190 : i32 to i64
%191 = arith.cmpi eq, %188, %192 : i64
cf.cond_br %191, ^bb63, ^bb64
^bb63:
%193 = arith.constant 23 : i32
%195 = arith.extsi %193 : i32 to i64
%194 = arith.cmpi eq, %arg0, %195 : i64
cf.cond_br %194, ^bb66, ^bb67
^bb66:
%196 = arith.constant 1 : i32
func.return %196 : i32
^bb67:
cf.br ^bb68
^bb68:
%197 = arith.constant 0 : i32
func.return %197 : i32
^bb64:
cf.br ^bb65
^bb65:
%198 = arith.constant 29 : i32
%200 = arith.extsi %198 : i32 to i64
%199 = arith.remsi %arg0, %200 : i64
%201 = arith.constant 0 : i32
%203 = arith.extsi %201 : i32 to i64
%202 = arith.cmpi eq, %199, %203 : i64
cf.cond_br %202, ^bb69, ^bb70
^bb69:
%204 = arith.constant 29 : i32
%206 = arith.extsi %204 : i32 to i64
%205 = arith.cmpi eq, %arg0, %206 : i64
cf.cond_br %205, ^bb72, ^bb73
^bb72:
%207 = arith.constant 1 : i32
func.return %207 : i32
^bb73:
cf.br ^bb74
^bb74:
%208 = arith.constant 0 : i32
func.return %208 : i32
^bb70:
cf.br ^bb71
^bb71:
%209 = arith.constant 31 : i32
%211 = arith.extsi %209 : i32 to i64
%210 = arith.remsi %arg0, %211 : i64
%212 = arith.constant 0 : i32
%214 = arith.extsi %212 : i32 to i64
%213 = arith.cmpi eq, %210, %214 : i64
cf.cond_br %213, ^bb75, ^bb76
^bb75:
%215 = arith.constant 31 : i32
%217 = arith.extsi %215 : i32 to i64
%216 = arith.cmpi eq, %arg0, %217 : i64
cf.cond_br %216, ^bb78, ^bb79
^bb78:
%218 = arith.constant 1 : i32
func.return %218 : i32
^bb79:
cf.br ^bb80
^bb80:
%219 = arith.constant 0 : i32
func.return %219 : i32
^bb76:
cf.br ^bb77
^bb77:
%220 = arith.constant 37 : i32
%222 = arith.extsi %220 : i32 to i64
%221 = arith.remsi %arg0, %222 : i64
%223 = arith.constant 0 : i32
%225 = arith.extsi %223 : i32 to i64
%224 = arith.cmpi eq, %221, %225 : i64
cf.cond_br %224, ^bb81, ^bb82
^bb81:
%226 = arith.constant 37 : i32
%228 = arith.extsi %226 : i32 to i64
%227 = arith.cmpi eq, %arg0, %228 : i64
cf.cond_br %227, ^bb84, ^bb85
^bb84:
%229 = arith.constant 1 : i32
func.return %229 : i32
^bb85:
cf.br ^bb86
^bb86:
%230 = arith.constant 0 : i32
func.return %230 : i32
^bb82:
cf.br ^bb83
^bb83:
%231 = arith.constant 1 : i32
%233 = arith.extsi %231 : i32 to i64
%232 = arith.subi %arg0, %233 : i64
%234 = llvm.mlir.constant(1 : i64) : i64
%235 = llvm.alloca %234 x i64 : (i64) -> !llvm.ptr
llvm.store %232, %235 : i64, !llvm.ptr
%236 = arith.constant 0 : i32
%237 = arith.extsi %236 : i32 to i64
%238 = llvm.mlir.constant(1 : i64) : i64
%239 = llvm.alloca %238 x i64 : (i64) -> !llvm.ptr
llvm.store %237, %239 : i64, !llvm.ptr
cf.br ^bb87
^bb87:
%240 = llvm.load %235 : !llvm.ptr -> i64
%241 = arith.constant 1 : i32
%243 = arith.extsi %241 : i32 to i64
%242 = arith.andi %240, %243 : i64
%244 = arith.constant 0 : i32
%246 = arith.extsi %244 : i32 to i64
%245 = arith.cmpi eq, %242, %246 : i64
cf.cond_br %245, ^bb88, ^bb89
^bb88:
%247 = llvm.load %235 : !llvm.ptr -> i64
%248 = arith.constant 1 : i32
%250 = arith.extsi %248 : i32 to i64
%249 = arith.shrsi %247, %250 : i64
llvm.store %249, %235 : i64, !llvm.ptr
%251 = llvm.load %239 : !llvm.ptr -> i64
%252 = arith.constant 1 : i32
%254 = arith.extsi %252 : i32 to i64
%253 = arith.addi %251, %254 : i64
llvm.store %253, %239 : i64, !llvm.ptr
cf.br ^bb87
^bb89:
%256 = arith.constant 7 : i32
%257 = arith.constant 8 : i32
%258 = arith.muli %256, %257 : i32
%259 = arith.extsi %258 : i32 to i64
%255 = func.call @malloc(%259) : (i64) -> !llvm.ptr
%260 = arith.constant 2 : i32
%261 = arith.constant 0 : i32
%262 = arith.extsi %260 : i32 to i64
%263 = arith.extsi %261 : i32 to i64
%264 = llvm.getelementptr %255[%263] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %262, %264 : i64, !llvm.ptr
%265 = arith.constant 325 : i32
%266 = arith.constant 1 : i32
%267 = arith.extsi %265 : i32 to i64
%268 = arith.extsi %266 : i32 to i64
%269 = llvm.getelementptr %255[%268] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %267, %269 : i64, !llvm.ptr
%270 = arith.constant 9375 : i32
%271 = arith.constant 2 : i32
%272 = arith.extsi %270 : i32 to i64
%273 = arith.extsi %271 : i32 to i64
%274 = llvm.getelementptr %255[%273] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %272, %274 : i64, !llvm.ptr
%275 = arith.constant 28178 : i32
%276 = arith.constant 3 : i32
%277 = arith.extsi %275 : i32 to i64
%278 = arith.extsi %276 : i32 to i64
%279 = llvm.getelementptr %255[%278] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %277, %279 : i64, !llvm.ptr
%280 = arith.constant 450775 : i32
%281 = arith.constant 4 : i32
%282 = arith.extsi %280 : i32 to i64
%283 = arith.extsi %281 : i32 to i64
%284 = llvm.getelementptr %255[%283] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %282, %284 : i64, !llvm.ptr
%285 = arith.constant 9780504 : i32
%286 = arith.constant 5 : i32
%287 = arith.extsi %285 : i32 to i64
%288 = arith.extsi %286 : i32 to i64
%289 = llvm.getelementptr %255[%288] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %287, %289 : i64, !llvm.ptr
%290 = arith.constant 1795265022 : i32
%291 = arith.constant 6 : i32
%292 = arith.extsi %290 : i32 to i64
%293 = arith.extsi %291 : i32 to i64
%294 = llvm.getelementptr %255[%293] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %292, %294 : i64, !llvm.ptr
%295 = arith.constant 0 : i32
%296 = arith.extsi %295 : i32 to i64
%297 = llvm.mlir.constant(1 : i64) : i64
%298 = llvm.alloca %297 x i64 : (i64) -> !llvm.ptr
llvm.store %296, %298 : i64, !llvm.ptr
cf.br ^bb90
^bb90:
%299 = llvm.load %298 : !llvm.ptr -> i64
%300 = arith.constant 7 : i32
%302 = arith.extsi %300 : i32 to i64
%301 = arith.cmpi slt, %299, %302 : i64
cf.cond_br %301, ^bb91, ^bb92
^bb91:
%304 = llvm.load %298 : !llvm.ptr -> i64
%305 = llvm.getelementptr %255[%304] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%303 = llvm.load %305 : !llvm.ptr -> i64
%306 = arith.remsi %303, %arg0 : i64
%307 = arith.constant 0 : i32
%309 = arith.extsi %307 : i32 to i64
%308 = arith.cmpi eq, %306, %309 : i64
cf.cond_br %308, ^bb93, ^bb94
^bb93:
%310 = llvm.load %298 : !llvm.ptr -> i64
%311 = arith.constant 1 : i32
%313 = arith.extsi %311 : i32 to i64
%312 = arith.addi %310, %313 : i64
llvm.store %312, %298 : i64, !llvm.ptr
cf.br ^bb90
^bb94:
cf.br ^bb95
^bb95:
%315 = llvm.load %235 : !llvm.ptr -> i64
%314 = func.call @powmod(%306, %315, %arg0) : (i64, i64, i64) -> i64
%316 = llvm.mlir.constant(1 : i64) : i64
%317 = llvm.alloca %316 x i64 : (i64) -> !llvm.ptr
llvm.store %314, %317 : i64, !llvm.ptr
%318 = llvm.load %317 : !llvm.ptr -> i64
%319 = arith.constant 1 : i32
%321 = arith.extsi %319 : i32 to i64
%320 = arith.cmpi eq, %318, %321 : i64
%322 = scf.if %320 -> (i1) {
%323 = arith.constant true
scf.yield %323 : i1
} else {
%324 = llvm.load %317 : !llvm.ptr -> i64
%325 = arith.constant 1 : i32
%327 = arith.extsi %325 : i32 to i64
%326 = arith.subi %arg0, %327 : i64
%328 = arith.cmpi eq, %324, %326 : i64
scf.yield %328 : i1
}
cf.cond_br %322, ^bb96, ^bb97
^bb96:
%329 = llvm.load %298 : !llvm.ptr -> i64
%330 = arith.constant 1 : i32
%332 = arith.extsi %330 : i32 to i64
%331 = arith.addi %329, %332 : i64
llvm.store %331, %298 : i64, !llvm.ptr
cf.br ^bb90
^bb97:
cf.br ^bb98
^bb98:
%333 = arith.constant 0 : i32
%334 = llvm.mlir.constant(1 : i64) : i64
%335 = llvm.alloca %334 x i32 : (i64) -> !llvm.ptr
llvm.store %333, %335 : i32, !llvm.ptr
%336 = arith.constant 0 : i32
%337 = arith.extsi %336 : i32 to i64
%338 = llvm.mlir.constant(1 : i64) : i64
%339 = llvm.alloca %338 x i64 : (i64) -> !llvm.ptr
llvm.store %337, %339 : i64, !llvm.ptr
cf.br ^bb99
^bb99:
%340 = llvm.load %339 : !llvm.ptr -> i64
%341 = llvm.load %239 : !llvm.ptr -> i64
%342 = arith.constant 1 : i32
%344 = arith.extsi %342 : i32 to i64
%343 = arith.subi %341, %344 : i64
%345 = arith.cmpi slt, %340, %343 : i64
cf.cond_br %345, ^bb100, ^bb101
^bb100:
%347 = llvm.load %317 : !llvm.ptr -> i64
%348 = llvm.load %317 : !llvm.ptr -> i64
%346 = func.call @mulmod(%347, %348, %arg0) : (i64, i64, i64) -> i64
llvm.store %346, %317 : i64, !llvm.ptr
%349 = llvm.load %317 : !llvm.ptr -> i64
%350 = arith.constant 1 : i32
%352 = arith.extsi %350 : i32 to i64
%351 = arith.subi %arg0, %352 : i64
%353 = arith.cmpi eq, %349, %351 : i64
cf.cond_br %353, ^bb102, ^bb103
^bb102:
%354 = arith.constant 1 : i32
llvm.store %354, %335 : i32, !llvm.ptr
cf.br ^bb101
^bb103:
cf.br ^bb104
^bb104:
%355 = llvm.load %339 : !llvm.ptr -> i64
%356 = arith.constant 1 : i32
%358 = arith.extsi %356 : i32 to i64
%357 = arith.addi %355, %358 : i64
llvm.store %357, %339 : i64, !llvm.ptr
cf.br ^bb99
^bb101:
%359 = llvm.load %335 : !llvm.ptr -> i32
%360 = arith.constant 0 : i32
%361 = arith.cmpi eq, %359, %360 : i32
cf.cond_br %361, ^bb105, ^bb106
^bb105:
func.call @free(%255) : (!llvm.ptr) -> ()
%363 = arith.constant 0 : i32
func.return %363 : i32
^bb106:
cf.br ^bb107
^bb107:
%364 = llvm.load %298 : !llvm.ptr -> i64
%365 = arith.constant 1 : i32
%367 = arith.extsi %365 : i32 to i64
%366 = arith.addi %364, %367 : i64
llvm.store %366, %298 : i64, !llvm.ptr
cf.br ^bb90
^bb92:
func.call @free(%255) : (!llvm.ptr) -> ()
%369 = arith.constant 1 : i32
func.return %369 : i32
}
func.func @pollard_rho(%arg0: i64) -> i64 {
%370 = arith.constant 2 : i32
%372 = arith.extsi %370 : i32 to i64
%371 = arith.remsi %arg0, %372 : i64
%373 = arith.constant 0 : i32
%375 = arith.extsi %373 : i32 to i64
%374 = arith.cmpi eq, %371, %375 : i64
cf.cond_br %374, ^bb108, ^bb109
^bb108:
%376 = arith.constant 2 : i32
%377 = arith.extsi %376 : i32 to i64
func.return %377 : i64
^bb109:
cf.br ^bb110
^bb110:
%378 = arith.constant 3 : i32
%380 = arith.extsi %378 : i32 to i64
%379 = arith.remsi %arg0, %380 : i64
%381 = arith.constant 0 : i32
%383 = arith.extsi %381 : i32 to i64
%382 = arith.cmpi eq, %379, %383 : i64
cf.cond_br %382, ^bb111, ^bb112
^bb111:
%384 = arith.constant 3 : i32
%385 = arith.extsi %384 : i32 to i64
func.return %385 : i64
^bb112:
cf.br ^bb113
^bb113:
cf.br ^bb114
^bb114:
%386 = arith.constant 1 : i1
cf.cond_br %386, ^bb115, ^bb116
^bb115:
%387 = arith.constant 1 : i32
%388 = func.call @xorshift64() : () -> i64
%389 = arith.constant 2 : i32
%391 = arith.extsi %389 : i32 to i64
%390 = arith.subi %arg0, %391 : i64
%392 = arith.remsi %388, %390 : i64
%394 = arith.extsi %387 : i32 to i64
%393 = arith.addi %394, %392 : i64
%395 = func.call @xorshift64() : () -> i64
%396 = arith.remsi %395, %arg0 : i64
%397 = llvm.mlir.constant(1 : i64) : i64
%398 = llvm.alloca %397 x i64 : (i64) -> !llvm.ptr
llvm.store %396, %398 : i64, !llvm.ptr
%399 = llvm.load %398 : !llvm.ptr -> i64
%400 = llvm.mlir.constant(1 : i64) : i64
%401 = llvm.alloca %400 x i64 : (i64) -> !llvm.ptr
llvm.store %399, %401 : i64, !llvm.ptr
%402 = arith.constant 1 : i32
%403 = arith.extsi %402 : i32 to i64
%404 = llvm.mlir.constant(1 : i64) : i64
%405 = llvm.alloca %404 x i64 : (i64) -> !llvm.ptr
llvm.store %403, %405 : i64, !llvm.ptr
cf.br ^bb117
^bb117:
%406 = llvm.load %405 : !llvm.ptr -> i64
%407 = arith.constant 1 : i32
%409 = arith.extsi %407 : i32 to i64
%408 = arith.cmpi eq, %406, %409 : i64
cf.cond_br %408, ^bb118, ^bb119
^bb118:
%411 = llvm.load %398 : !llvm.ptr -> i64
%412 = llvm.load %398 : !llvm.ptr -> i64
%410 = func.call @mulmod(%411, %412, %arg0) : (i64, i64, i64) -> i64
%413 = arith.addi %410, %393 : i64
%414 = arith.remsi %413, %arg0 : i64
llvm.store %414, %398 : i64, !llvm.ptr
%416 = llvm.load %401 : !llvm.ptr -> i64
%417 = llvm.load %401 : !llvm.ptr -> i64
%415 = func.call @mulmod(%416, %417, %arg0) : (i64, i64, i64) -> i64
%418 = arith.addi %415, %393 : i64
%419 = arith.remsi %418, %arg0 : i64
llvm.store %419, %401 : i64, !llvm.ptr
%421 = llvm.load %401 : !llvm.ptr -> i64
%422 = llvm.load %401 : !llvm.ptr -> i64
%420 = func.call @mulmod(%421, %422, %arg0) : (i64, i64, i64) -> i64
%423 = arith.addi %420, %393 : i64
%424 = arith.remsi %423, %arg0 : i64
llvm.store %424, %401 : i64, !llvm.ptr
%425 = arith.constant 0 : i32
%426 = arith.extsi %425 : i32 to i64
%427 = llvm.load %398 : !llvm.ptr -> i64
%428 = llvm.load %401 : !llvm.ptr -> i64
%429 = arith.cmpi sgt, %427, %428 : i64
%430 = scf.if %429 -> (i64) {
%431 = llvm.load %398 : !llvm.ptr -> i64
%432 = llvm.load %401 : !llvm.ptr -> i64
%433 = arith.subi %431, %432 : i64
scf.yield %433 : i64
} else {
%434 = llvm.load %401 : !llvm.ptr -> i64
%435 = llvm.load %398 : !llvm.ptr -> i64
%436 = arith.subi %434, %435 : i64
scf.yield %436 : i64
}
%437 = func.call @gcd_u64(%430, %arg0) : (i64, i64) -> i64
llvm.store %437, %405 : i64, !llvm.ptr
cf.br ^bb117
^bb119:
%438 = llvm.load %405 : !llvm.ptr -> i64
%439 = arith.cmpi ne, %438, %arg0 : i64
cf.cond_br %439, ^bb120, ^bb121
^bb120:
%440 = llvm.load %405 : !llvm.ptr -> i64
func.return %440 : i64
^bb121:
cf.br ^bb122
^bb122:
cf.br ^bb114
^bb116:
%441 = arith.constant 0 : i32
%442 = arith.extsi %441 : i32 to i64
func.return %442 : i64
}
func.func @factorize(%arg0: i64, %arg1: !llvm.ptr) -> i64 {
%443 = arith.constant 1 : i32
%445 = arith.extsi %443 : i32 to i64
%444 = arith.cmpi sle, %arg0, %445 : i64
cf.cond_br %444, ^bb123, ^bb124
^bb123:
%446 = arith.constant 0 : i32
%447 = arith.extsi %446 : i32 to i64
func.return %447 : i64
^bb124:
cf.br ^bb125
^bb125:
%449 = arith.constant 128 : i32
%450 = arith.constant 8 : i32
%451 = arith.muli %449, %450 : i32
%452 = arith.extsi %451 : i32 to i64
%448 = func.call @malloc(%452) : (i64) -> !llvm.ptr
%454 = arith.constant 128 : i32
%455 = arith.constant 8 : i32
%456 = arith.muli %454, %455 : i32
%457 = arith.extsi %456 : i32 to i64
%453 = func.call @malloc(%457) : (i64) -> !llvm.ptr
%458 = arith.constant 0 : i32
%459 = arith.extsi %458 : i32 to i64
%460 = llvm.mlir.constant(1 : i64) : i64
%461 = llvm.alloca %460 x i64 : (i64) -> !llvm.ptr
llvm.store %459, %461 : i64, !llvm.ptr
%462 = llvm.load %461 : !llvm.ptr -> i64
%463 = llvm.getelementptr %448[%462] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %arg0, %463 : i64, !llvm.ptr
%464 = llvm.load %461 : !llvm.ptr -> i64
%465 = arith.constant 1 : i32
%467 = arith.extsi %465 : i32 to i64
%466 = arith.addi %464, %467 : i64
llvm.store %466, %461 : i64, !llvm.ptr
%468 = arith.constant 0 : i32
%469 = arith.extsi %468 : i32 to i64
%470 = llvm.mlir.constant(1 : i64) : i64
%471 = llvm.alloca %470 x i64 : (i64) -> !llvm.ptr
llvm.store %469, %471 : i64, !llvm.ptr
cf.br ^bb126
^bb126:
%472 = llvm.load %461 : !llvm.ptr -> i64
%473 = arith.constant 0 : i32
%475 = arith.extsi %473 : i32 to i64
%474 = arith.cmpi sgt, %472, %475 : i64
cf.cond_br %474, ^bb127, ^bb128
^bb127:
%476 = llvm.load %461 : !llvm.ptr -> i64
%477 = arith.constant 1 : i32
%479 = arith.extsi %477 : i32 to i64
%478 = arith.subi %476, %479 : i64
llvm.store %478, %461 : i64, !llvm.ptr
%481 = llvm.load %461 : !llvm.ptr -> i64
%482 = llvm.getelementptr %448[%481] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%480 = llvm.load %482 : !llvm.ptr -> i64
%483 = arith.constant 1 : i32
%485 = arith.extsi %483 : i32 to i64
%484 = arith.cmpi eq, %480, %485 : i64
cf.cond_br %484, ^bb129, ^bb130
^bb129:
cf.br ^bb126
^bb130:
cf.br ^bb131
^bb131:
%486 = func.call @is_prime(%480) : (i64) -> i32
%487 = arith.constant 0 : i32
%488 = arith.cmpi ne, %486, %487 : i32
cf.cond_br %488, ^bb132, ^bb133
^bb132:
%489 = llvm.load %471 : !llvm.ptr -> i64
%490 = llvm.getelementptr %453[%489] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %480, %490 : i64, !llvm.ptr
%491 = llvm.load %471 : !llvm.ptr -> i64
%492 = arith.constant 1 : i32
%494 = arith.extsi %492 : i32 to i64
%493 = arith.addi %491, %494 : i64
llvm.store %493, %471 : i64, !llvm.ptr
cf.br ^bb126
^bb133:
cf.br ^bb134
^bb134:
%495 = func.call @pollard_rho(%480) : (i64) -> i64
%496 = llvm.load %461 : !llvm.ptr -> i64
%497 = llvm.getelementptr %448[%496] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %495, %497 : i64, !llvm.ptr
%498 = llvm.load %461 : !llvm.ptr -> i64
%499 = arith.constant 1 : i32
%501 = arith.extsi %499 : i32 to i64
%500 = arith.addi %498, %501 : i64
llvm.store %500, %461 : i64, !llvm.ptr
%502 = arith.divsi %480, %495 : i64
%503 = llvm.load %461 : !llvm.ptr -> i64
%504 = llvm.getelementptr %448[%503] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %502, %504 : i64, !llvm.ptr
%505 = llvm.load %461 : !llvm.ptr -> i64
%506 = arith.constant 1 : i32
%508 = arith.extsi %506 : i32 to i64
%507 = arith.addi %505, %508 : i64
llvm.store %507, %461 : i64, !llvm.ptr
cf.br ^bb126
^bb128:
%509 = arith.constant 0 : i32
%510 = arith.extsi %509 : i32 to i64
%511 = llvm.mlir.constant(1 : i64) : i64
%512 = llvm.alloca %511 x i64 : (i64) -> !llvm.ptr
llvm.store %510, %512 : i64, !llvm.ptr
cf.br ^bb135
^bb135:
%513 = llvm.load %512 : !llvm.ptr -> i64
%514 = llvm.load %471 : !llvm.ptr -> i64
%515 = arith.cmpi slt, %513, %514 : i64
cf.cond_br %515, ^bb136, ^bb137
^bb136:
%516 = llvm.load %512 : !llvm.ptr -> i64
%517 = arith.constant 1 : i32
%519 = arith.extsi %517 : i32 to i64
%518 = arith.addi %516, %519 : i64
%520 = llvm.mlir.constant(1 : i64) : i64
%521 = llvm.alloca %520 x i64 : (i64) -> !llvm.ptr
llvm.store %518, %521 : i64, !llvm.ptr
cf.br ^bb138
^bb138:
%522 = llvm.load %521 : !llvm.ptr -> i64
%523 = llvm.load %471 : !llvm.ptr -> i64
%524 = arith.cmpi slt, %522, %523 : i64
cf.cond_br %524, ^bb139, ^bb140
^bb139:
%526 = llvm.load %521 : !llvm.ptr -> i64
%527 = llvm.getelementptr %453[%526] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%525 = llvm.load %527 : !llvm.ptr -> i64
%529 = llvm.load %512 : !llvm.ptr -> i64
%530 = llvm.getelementptr %453[%529] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%528 = llvm.load %530 : !llvm.ptr -> i64
%531 = arith.cmpi slt, %525, %528 : i64
cf.cond_br %531, ^bb141, ^bb142
^bb141:
%533 = llvm.load %512 : !llvm.ptr -> i64
%534 = llvm.getelementptr %453[%533] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%532 = llvm.load %534 : !llvm.ptr -> i64
%536 = llvm.load %521 : !llvm.ptr -> i64
%537 = llvm.getelementptr %453[%536] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%535 = llvm.load %537 : !llvm.ptr -> i64
%538 = llvm.load %512 : !llvm.ptr -> i64
%539 = llvm.getelementptr %453[%538] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %535, %539 : i64, !llvm.ptr
%540 = llvm.load %521 : !llvm.ptr -> i64
%541 = llvm.getelementptr %453[%540] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %532, %541 : i64, !llvm.ptr
cf.br ^bb143
^bb142:
cf.br ^bb143
^bb143:
%542 = llvm.load %521 : !llvm.ptr -> i64
%543 = arith.constant 1 : i32
%545 = arith.extsi %543 : i32 to i64
%544 = arith.addi %542, %545 : i64
llvm.store %544, %521 : i64, !llvm.ptr
cf.br ^bb138
^bb140:
%546 = llvm.load %512 : !llvm.ptr -> i64
%547 = arith.constant 1 : i32
%549 = arith.extsi %547 : i32 to i64
%548 = arith.addi %546, %549 : i64
llvm.store %548, %512 : i64, !llvm.ptr
cf.br ^bb135
^bb137:
%550 = arith.constant 0 : i32
%551 = arith.extsi %550 : i32 to i64
%552 = llvm.mlir.constant(1 : i64) : i64
%553 = llvm.alloca %552 x i64 : (i64) -> !llvm.ptr
llvm.store %551, %553 : i64, !llvm.ptr
%554 = arith.constant 0 : i32
%555 = arith.extsi %554 : i32 to i64
llvm.store %555, %512 : i64, !llvm.ptr
cf.br ^bb144
^bb144:
%556 = llvm.load %512 : !llvm.ptr -> i64
%557 = llvm.load %471 : !llvm.ptr -> i64
%558 = arith.cmpi slt, %556, %557 : i64
cf.cond_br %558, ^bb145, ^bb146
^bb145:
%560 = llvm.load %512 : !llvm.ptr -> i64
%561 = llvm.getelementptr %453[%560] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%559 = llvm.load %561 : !llvm.ptr -> i64
%562 = arith.constant 0 : i32
%563 = llvm.mlir.constant(1 : i64) : i64
%564 = llvm.alloca %563 x i32 : (i64) -> !llvm.ptr
llvm.store %562, %564 : i32, !llvm.ptr
cf.br ^bb147
^bb147:
%565 = llvm.load %512 : !llvm.ptr -> i64
%566 = llvm.load %471 : !llvm.ptr -> i64
%567 = arith.cmpi slt, %565, %566 : i64
%568 = scf.if %567 -> (i1) {
%570 = llvm.load %512 : !llvm.ptr -> i64
%571 = llvm.getelementptr %453[%570] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%569 = llvm.load %571 : !llvm.ptr -> i64
%572 = arith.cmpi eq, %569, %559 : i64
scf.yield %572 : i1
} else {
%573 = arith.constant false
scf.yield %573 : i1
}
cf.cond_br %568, ^bb148, ^bb149
^bb148:
%574 = llvm.load %564 : !llvm.ptr -> i32
%575 = arith.constant 1 : i32
%576 = arith.addi %574, %575 : i32
llvm.store %576, %564 : i32, !llvm.ptr
%577 = llvm.load %512 : !llvm.ptr -> i64
%578 = arith.constant 1 : i32
%580 = arith.extsi %578 : i32 to i64
%579 = arith.addi %577, %580 : i64
llvm.store %579, %512 : i64, !llvm.ptr
cf.br ^bb147
^bb149:
%581 = llvm.load %553 : !llvm.ptr -> i64
%582 = llvm.getelementptr %arg1[%581] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64, i32)>
%583 = llvm.getelementptr %582[0, 0] : (!llvm.ptr) -> !llvm.ptr, !llvm.struct<(i64, i32)>
llvm.store %559, %583 : i64, !llvm.ptr
%584 = llvm.load %564 : !llvm.ptr -> i32
%585 = llvm.load %553 : !llvm.ptr -> i64
%586 = llvm.getelementptr %arg1[%585] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64, i32)>
%587 = llvm.getelementptr %586[0, 1] : (!llvm.ptr) -> !llvm.ptr, !llvm.struct<(i64, i32)>
llvm.store %584, %587 : i32, !llvm.ptr
%588 = llvm.load %553 : !llvm.ptr -> i64
%589 = arith.constant 1 : i32
%591 = arith.extsi %589 : i32 to i64
%590 = arith.addi %588, %591 : i64
llvm.store %590, %553 : i64, !llvm.ptr
cf.br ^bb144
^bb146:
func.call @free(%448) : (!llvm.ptr) -> ()
func.call @free(%453) : (!llvm.ptr) -> ()
%594 = llvm.load %553 : !llvm.ptr -> i64
func.return %594 : i64
}
func.func @isqrt_i64(%arg0: i64) -> i64 {
%595 = arith.constant 0 : i32
%597 = arith.extsi %595 : i32 to i64
%596 = arith.cmpi sle, %arg0, %597 : i64
cf.cond_br %596, ^bb150, ^bb151
^bb150:
%598 = arith.constant 0 : i32
%599 = arith.extsi %598 : i32 to i64
func.return %599 : i64
^bb151:
cf.br ^bb152
^bb152:
%600 = arith.sitofp %arg0 : i64 to f64
%601 = math.sqrt %600 : f64
%602 = arith.fptosi %601 : f64 to i64
%603 = llvm.mlir.constant(1 : i64) : i64
%604 = llvm.alloca %603 x i64 : (i64) -> !llvm.ptr
llvm.store %602, %604 : i64, !llvm.ptr
cf.br ^bb153
^bb153:
%605 = llvm.load %604 : !llvm.ptr -> i64
%606 = arith.constant 0 : i32
%608 = arith.extsi %606 : i32 to i64
%607 = arith.cmpi sgt, %605, %608 : i64
%609 = scf.if %607 -> (i1) {
%610 = llvm.load %604 : !llvm.ptr -> i64
%611 = llvm.load %604 : !llvm.ptr -> i64
%612 = arith.muli %610, %611 : i64
%613 = arith.cmpi sgt, %612, %arg0 : i64
scf.yield %613 : i1
} else {
%614 = arith.constant false
scf.yield %614 : i1
}
cf.cond_br %609, ^bb154, ^bb155
^bb154:
%615 = llvm.load %604 : !llvm.ptr -> i64
%616 = arith.constant 1 : i32
%618 = arith.extsi %616 : i32 to i64
%617 = arith.subi %615, %618 : i64
llvm.store %617, %604 : i64, !llvm.ptr
cf.br ^bb153
^bb155:
cf.br ^bb156
^bb156:
%619 = llvm.load %604 : !llvm.ptr -> i64
%620 = arith.constant 1 : i32
%622 = arith.extsi %620 : i32 to i64
%621 = arith.addi %619, %622 : i64
%623 = llvm.load %604 : !llvm.ptr -> i64
%624 = arith.constant 1 : i32
%626 = arith.extsi %624 : i32 to i64
%625 = arith.addi %623, %626 : i64
%627 = arith.muli %621, %625 : i64
%628 = arith.cmpi sle, %627, %arg0 : i64
cf.cond_br %628, ^bb157, ^bb158
^bb157:
%629 = llvm.load %604 : !llvm.ptr -> i64
%630 = arith.constant 1 : i32
%632 = arith.extsi %630 : i32 to i64
%631 = arith.addi %629, %632 : i64
llvm.store %631, %604 : i64, !llvm.ptr
cf.br ^bb156
^bb158:
%633 = llvm.load %604 : !llvm.ptr -> i64
func.return %633 : i64
}
func.func @sqrt_neg1_mod_p(%arg0: i64) -> i64 {
%635 = arith.constant 12 : i32
%636 = arith.constant 8 : i32
%637 = arith.muli %635, %636 : i32
%638 = arith.extsi %637 : i32 to i64
%634 = func.call @malloc(%638) : (i64) -> !llvm.ptr
%639 = arith.constant 2 : i32
%640 = arith.constant 0 : i32
%641 = arith.extsi %639 : i32 to i64
%642 = arith.extsi %640 : i32 to i64
%643 = llvm.getelementptr %634[%642] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %641, %643 : i64, !llvm.ptr
%644 = arith.constant 3 : i32
%645 = arith.constant 1 : i32
%646 = arith.extsi %644 : i32 to i64
%647 = arith.extsi %645 : i32 to i64
%648 = llvm.getelementptr %634[%647] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %646, %648 : i64, !llvm.ptr
%649 = arith.constant 5 : i32
%650 = arith.constant 2 : i32
%651 = arith.extsi %649 : i32 to i64
%652 = arith.extsi %650 : i32 to i64
%653 = llvm.getelementptr %634[%652] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %651, %653 : i64, !llvm.ptr
%654 = arith.constant 6 : i32
%655 = arith.constant 3 : i32
%656 = arith.extsi %654 : i32 to i64
%657 = arith.extsi %655 : i32 to i64
%658 = llvm.getelementptr %634[%657] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %656, %658 : i64, !llvm.ptr
%659 = arith.constant 7 : i32
%660 = arith.constant 4 : i32
%661 = arith.extsi %659 : i32 to i64
%662 = arith.extsi %660 : i32 to i64
%663 = llvm.getelementptr %634[%662] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %661, %663 : i64, !llvm.ptr
%664 = arith.constant 10 : i32
%665 = arith.constant 5 : i32
%666 = arith.extsi %664 : i32 to i64
%667 = arith.extsi %665 : i32 to i64
%668 = llvm.getelementptr %634[%667] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %666, %668 : i64, !llvm.ptr
%669 = arith.constant 11 : i32
%670 = arith.constant 6 : i32
%671 = arith.extsi %669 : i32 to i64
%672 = arith.extsi %670 : i32 to i64
%673 = llvm.getelementptr %634[%672] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %671, %673 : i64, !llvm.ptr
%674 = arith.constant 13 : i32
%675 = arith.constant 7 : i32
%676 = arith.extsi %674 : i32 to i64
%677 = arith.extsi %675 : i32 to i64
%678 = llvm.getelementptr %634[%677] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %676, %678 : i64, !llvm.ptr
%679 = arith.constant 17 : i32
%680 = arith.constant 8 : i32
%681 = arith.extsi %679 : i32 to i64
%682 = arith.extsi %680 : i32 to i64
%683 = llvm.getelementptr %634[%682] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %681, %683 : i64, !llvm.ptr
%684 = arith.constant 19 : i32
%685 = arith.constant 9 : i32
%686 = arith.extsi %684 : i32 to i64
%687 = arith.extsi %685 : i32 to i64
%688 = llvm.getelementptr %634[%687] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %686, %688 : i64, !llvm.ptr
%689 = arith.constant 23 : i32
%690 = arith.constant 10 : i32
%691 = arith.extsi %689 : i32 to i64
%692 = arith.extsi %690 : i32 to i64
%693 = llvm.getelementptr %634[%692] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %691, %693 : i64, !llvm.ptr
%694 = arith.constant 29 : i32
%695 = arith.constant 11 : i32
%696 = arith.extsi %694 : i32 to i64
%697 = arith.extsi %695 : i32 to i64
%698 = llvm.getelementptr %634[%697] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %696, %698 : i64, !llvm.ptr
%699 = arith.constant 0 : i32
%700 = arith.extsi %699 : i32 to i64
%701 = llvm.mlir.constant(1 : i64) : i64
%702 = llvm.alloca %701 x i64 : (i64) -> !llvm.ptr
llvm.store %700, %702 : i64, !llvm.ptr
cf.br ^bb159
^bb159:
%703 = llvm.load %702 : !llvm.ptr -> i64
%704 = arith.constant 12 : i32
%706 = arith.extsi %704 : i32 to i64
%705 = arith.cmpi slt, %703, %706 : i64
cf.cond_br %705, ^bb160, ^bb161
^bb160:
%708 = llvm.load %702 : !llvm.ptr -> i64
%709 = llvm.getelementptr %634[%708] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%707 = llvm.load %709 : !llvm.ptr -> i64
%710 = arith.remsi %707, %arg0 : i64
%711 = arith.constant 0 : i32
%713 = arith.extsi %711 : i32 to i64
%712 = arith.cmpi ne, %710, %713 : i64
cf.cond_br %712, ^bb162, ^bb163
^bb162:
%715 = arith.constant 1 : i32
%717 = arith.extsi %715 : i32 to i64
%716 = arith.subi %arg0, %717 : i64
%718 = arith.constant 2 : i32
%720 = arith.extsi %718 : i32 to i64
%719 = arith.divsi %716, %720 : i64
%714 = func.call @powmod(%710, %719, %arg0) : (i64, i64, i64) -> i64
%721 = arith.constant 1 : i32
%723 = arith.extsi %721 : i32 to i64
%722 = arith.subi %arg0, %723 : i64
%724 = arith.cmpi eq, %714, %722 : i64
cf.cond_br %724, ^bb165, ^bb166
^bb165:
%726 = arith.constant 1 : i32
%728 = arith.extsi %726 : i32 to i64
%727 = arith.subi %arg0, %728 : i64
%729 = arith.constant 4 : i32
%731 = arith.extsi %729 : i32 to i64
%730 = arith.divsi %727, %731 : i64
%725 = func.call @powmod(%710, %730, %arg0) : (i64, i64, i64) -> i64
func.call @free(%634) : (!llvm.ptr) -> ()
func.return %725 : i64
^bb166:
cf.br ^bb167
^bb167:
cf.br ^bb164
^bb163:
cf.br ^bb164
^bb164:
%733 = llvm.load %702 : !llvm.ptr -> i64
%734 = arith.constant 1 : i32
%736 = arith.extsi %734 : i32 to i64
%735 = arith.addi %733, %736 : i64
llvm.store %735, %702 : i64, !llvm.ptr
cf.br ^bb159
^bb161:
func.call @free(%634) : (!llvm.ptr) -> ()
%738 = arith.constant 2 : i32
%739 = arith.extsi %738 : i32 to i64
%740 = llvm.mlir.constant(1 : i64) : i64
%741 = llvm.alloca %740 x i64 : (i64) -> !llvm.ptr
llvm.store %739, %741 : i64, !llvm.ptr
cf.br ^bb168
^bb168:
%742 = arith.constant 1 : i1
cf.cond_br %742, ^bb169, ^bb170
^bb169:
%743 = llvm.load %741 : !llvm.ptr -> i64
%744 = arith.remsi %743, %arg0 : i64
%745 = arith.constant 0 : i32
%747 = arith.extsi %745 : i32 to i64
%746 = arith.cmpi ne, %744, %747 : i64
cf.cond_br %746, ^bb171, ^bb172
^bb171:
%749 = llvm.load %741 : !llvm.ptr -> i64
%750 = arith.constant 1 : i32
%752 = arith.extsi %750 : i32 to i64
%751 = arith.subi %arg0, %752 : i64
%753 = arith.constant 2 : i32
%755 = arith.extsi %753 : i32 to i64
%754 = arith.divsi %751, %755 : i64
%748 = func.call @powmod(%749, %754, %arg0) : (i64, i64, i64) -> i64
%756 = arith.constant 1 : i32
%758 = arith.extsi %756 : i32 to i64
%757 = arith.subi %arg0, %758 : i64
%759 = arith.cmpi eq, %748, %757 : i64
cf.cond_br %759, ^bb174, ^bb175
^bb174:
%761 = llvm.load %741 : !llvm.ptr -> i64
%762 = arith.constant 1 : i32
%764 = arith.extsi %762 : i32 to i64
%763 = arith.subi %arg0, %764 : i64
%765 = arith.constant 4 : i32
%767 = arith.extsi %765 : i32 to i64
%766 = arith.divsi %763, %767 : i64
%760 = func.call @powmod(%761, %766, %arg0) : (i64, i64, i64) -> i64
func.return %760 : i64
^bb175:
cf.br ^bb176
^bb176:
cf.br ^bb173
^bb172:
cf.br ^bb173
^bb173:
%768 = llvm.load %741 : !llvm.ptr -> i64
%769 = arith.constant 1 : i32
%771 = arith.extsi %769 : i32 to i64
%770 = arith.addi %768, %771 : i64
llvm.store %770, %741 : i64, !llvm.ptr
cf.br ^bb168
^bb170:
%772 = arith.constant 0 : i32
%773 = arith.extsi %772 : i32 to i64
func.return %773 : i64
}
func.func @cornacchia(%arg0: i64) -> () {
%774 = func.call @sqrt_neg1_mod_p(%arg0) : (i64) -> i64
%775 = llvm.mlir.constant(1 : i64) : i64
%776 = llvm.alloca %775 x i64 : (i64) -> !llvm.ptr
llvm.store %774, %776 : i64, !llvm.ptr
%777 = arith.constant 0 : i32
%778 = llvm.mlir.constant(1 : i64) : i64
%779 = llvm.alloca %778 x i32 : (i64) -> !llvm.ptr
llvm.store %777, %779 : i32, !llvm.ptr
cf.br ^bb177
^bb177:
%780 = llvm.load %779 : !llvm.ptr -> i32
%781 = arith.constant 2 : i32
%782 = arith.cmpi slt, %780, %781 : i32
cf.cond_br %782, ^bb178, ^bb179
^bb178:
%783 = llvm.load %779 : !llvm.ptr -> i32
%784 = arith.constant 1 : i32
%785 = arith.cmpi eq, %783, %784 : i32
cf.cond_br %785, ^bb180, ^bb181
^bb180:
%786 = llvm.load %776 : !llvm.ptr -> i64
%787 = arith.subi %arg0, %786 : i64
llvm.store %787, %776 : i64, !llvm.ptr
cf.br ^bb182
^bb181:
cf.br ^bb182
^bb182:
%788 = llvm.mlir.constant(1 : i64) : i64
%789 = llvm.alloca %788 x i64 : (i64) -> !llvm.ptr
llvm.store %arg0, %789 : i64, !llvm.ptr
%790 = llvm.load %776 : !llvm.ptr -> i64
%791 = llvm.mlir.constant(1 : i64) : i64
%792 = llvm.alloca %791 x i64 : (i64) -> !llvm.ptr
llvm.store %790, %792 : i64, !llvm.ptr
cf.br ^bb183
^bb183:
%793 = llvm.load %792 : !llvm.ptr -> i64
%794 = arith.extsi %793 : i64 to i128
%795 = llvm.load %792 : !llvm.ptr -> i64
%796 = arith.extsi %795 : i64 to i128
%798 = arith.trunci %794 : i128 to i64
%799 = arith.trunci %796 : i128 to i64
%797 = arith.muli %798, %799 : i64
%800 = arith.extsi %arg0 : i64 to i128
%802 = arith.trunci %800 : i128 to i64
%801 = arith.cmpi sgt, %797, %802 : i64
cf.cond_br %801, ^bb184, ^bb185
^bb184:
%803 = llvm.load %789 : !llvm.ptr -> i64
%804 = llvm.load %792 : !llvm.ptr -> i64
%805 = arith.remsi %803, %804 : i64
%806 = llvm.load %792 : !llvm.ptr -> i64
llvm.store %806, %789 : i64, !llvm.ptr
llvm.store %805, %792 : i64, !llvm.ptr
cf.br ^bb183
^bb185:
%807 = llvm.load %792 : !llvm.ptr -> i64
%808 = arith.muli %807, %807 : i64
%809 = arith.subi %arg0, %808 : i64
%810 = func.call @isqrt_i64(%809) : (i64) -> i64
%811 = arith.muli %810, %810 : i64
%812 = arith.cmpi eq, %811, %809 : i64
cf.cond_br %812, ^bb186, ^bb187
^bb186:
%813 = llvm.mlir.addressof @corn_a : !llvm.ptr
llvm.store %807, %813 : i64, !llvm.ptr
%814 = llvm.mlir.addressof @corn_b : !llvm.ptr
llvm.store %810, %814 : i64, !llvm.ptr
func.return
^bb187:
cf.br ^bb188
^bb188:
%815 = llvm.load %779 : !llvm.ptr -> i32
%816 = arith.constant 1 : i32
%817 = arith.addi %815, %816 : i32
llvm.store %817, %779 : i32, !llvm.ptr
cf.br ^bb177
^bb179:
%818 = arith.constant 0 : i32
%819 = arith.extsi %818 : i32 to i64
%820 = llvm.mlir.addressof @corn_a : !llvm.ptr
llvm.store %819, %820 : i64, !llvm.ptr
%821 = arith.constant 0 : i32
%822 = arith.extsi %821 : i32 to i64
%823 = llvm.mlir.addressof @corn_b : !llvm.ptr
llvm.store %822, %823 : i64, !llvm.ptr
func.return
}
func.func @gmul(%arg0: i64, %arg1: i64, %arg2: i64, %arg3: i64, %arg4: !llvm.ptr, %arg5: !llvm.ptr) -> () {
%824 = arith.muli %arg0, %arg2 : i64
%825 = arith.muli %arg1, %arg3 : i64
%826 = arith.subi %824, %825 : i64
%827 = arith.constant 0 : i32
%828 = arith.extsi %827 : i32 to i64
%829 = llvm.getelementptr %arg4[%828] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %826, %829 : i64, !llvm.ptr
%830 = arith.muli %arg0, %arg3 : i64
%831 = arith.muli %arg1, %arg2 : i64
%832 = arith.addi %830, %831 : i64
%833 = arith.constant 0 : i32
%834 = arith.extsi %833 : i32 to i64
%835 = llvm.getelementptr %arg5[%834] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %832, %835 : i64, !llvm.ptr
func.return
}
func.func @sort_gint(%arg0: !llvm.ptr, %arg1: i64) -> () {
%836 = arith.constant 1 : i32
%837 = arith.extsi %836 : i32 to i64
%838 = llvm.mlir.constant(1 : i64) : i64
%839 = llvm.alloca %838 x i64 : (i64) -> !llvm.ptr
llvm.store %837, %839 : i64, !llvm.ptr
cf.br ^bb189
^bb189:
%840 = llvm.load %839 : !llvm.ptr -> i64
%841 = arith.cmpi slt, %840, %arg1 : i64
cf.cond_br %841, ^bb190, ^bb191
^bb190:
%842 = llvm.load %839 : !llvm.ptr -> i64
%843 = llvm.mlir.constant(1 : i64) : i64
%844 = llvm.alloca %843 x i64 : (i64) -> !llvm.ptr
llvm.store %842, %844 : i64, !llvm.ptr
cf.br ^bb192
^bb192:
%845 = llvm.load %844 : !llvm.ptr -> i64
%846 = arith.constant 0 : i32
%848 = arith.extsi %846 : i32 to i64
%847 = arith.cmpi sgt, %845, %848 : i64
cf.cond_br %847, ^bb193, ^bb194
^bb193:
%849 = llvm.load %844 : !llvm.ptr -> i64
%850 = arith.constant 1 : i32
%852 = arith.extsi %850 : i32 to i64
%851 = arith.subi %849, %852 : i64
%854 = llvm.getelementptr %arg0[%851] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64, i64)>
%853 = llvm.load %854 : !llvm.ptr -> !llvm.struct<(i64, i64)>
%855 = llvm.getelementptr %arg0[%851] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64, i64)>
%856 = llvm.getelementptr %855[0, 0] : (!llvm.ptr) -> !llvm.ptr, !llvm.struct<(i64, i64)>
%857 = llvm.load %856 : !llvm.ptr -> i64
%859 = llvm.load %844 : !llvm.ptr -> i64
%860 = llvm.getelementptr %arg0[%859] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64, i64)>
%858 = llvm.load %860 : !llvm.ptr -> !llvm.struct<(i64, i64)>
%861 = llvm.load %844 : !llvm.ptr -> i64
%862 = llvm.getelementptr %arg0[%861] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64, i64)>
%863 = llvm.getelementptr %862[0, 0] : (!llvm.ptr) -> !llvm.ptr, !llvm.struct<(i64, i64)>
%864 = llvm.load %863 : !llvm.ptr -> i64
%865 = arith.cmpi sgt, %857, %864 : i64
cf.cond_br %865, ^bb195, ^bb196
^bb195:
%867 = llvm.getelementptr %arg0[%851] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64, i64)>
%866 = llvm.load %867 : !llvm.ptr -> !llvm.struct<(i64, i64)>
%868 = llvm.getelementptr %arg0[%851] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64, i64)>
%869 = llvm.getelementptr %868[0, 0] : (!llvm.ptr) -> !llvm.ptr, !llvm.struct<(i64, i64)>
%870 = llvm.load %869 : !llvm.ptr -> i64
%872 = llvm.getelementptr %arg0[%851] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64, i64)>
%871 = llvm.load %872 : !llvm.ptr -> !llvm.struct<(i64, i64)>
%873 = llvm.getelementptr %arg0[%851] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64, i64)>
%874 = llvm.getelementptr %873[0, 1] : (!llvm.ptr) -> !llvm.ptr, !llvm.struct<(i64, i64)>
%875 = llvm.load %874 : !llvm.ptr -> i64
%877 = llvm.load %844 : !llvm.ptr -> i64
%878 = llvm.getelementptr %arg0[%877] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64, i64)>
%876 = llvm.load %878 : !llvm.ptr -> !llvm.struct<(i64, i64)>
%879 = llvm.load %844 : !llvm.ptr -> i64
%880 = llvm.getelementptr %arg0[%879] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64, i64)>
%881 = llvm.getelementptr %880[0, 0] : (!llvm.ptr) -> !llvm.ptr, !llvm.struct<(i64, i64)>
%882 = llvm.load %881 : !llvm.ptr -> i64
%883 = llvm.getelementptr %arg0[%851] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64, i64)>
%884 = llvm.getelementptr %883[0, 0] : (!llvm.ptr) -> !llvm.ptr, !llvm.struct<(i64, i64)>
llvm.store %882, %884 : i64, !llvm.ptr
%886 = llvm.load %844 : !llvm.ptr -> i64
%887 = llvm.getelementptr %arg0[%886] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64, i64)>
%885 = llvm.load %887 : !llvm.ptr -> !llvm.struct<(i64, i64)>
%888 = llvm.load %844 : !llvm.ptr -> i64
%889 = llvm.getelementptr %arg0[%888] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64, i64)>
%890 = llvm.getelementptr %889[0, 1] : (!llvm.ptr) -> !llvm.ptr, !llvm.struct<(i64, i64)>
%891 = llvm.load %890 : !llvm.ptr -> i64
%892 = llvm.getelementptr %arg0[%851] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64, i64)>
%893 = llvm.getelementptr %892[0, 1] : (!llvm.ptr) -> !llvm.ptr, !llvm.struct<(i64, i64)>
llvm.store %891, %893 : i64, !llvm.ptr
%894 = llvm.load %844 : !llvm.ptr -> i64
%895 = llvm.getelementptr %arg0[%894] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64, i64)>
%896 = llvm.getelementptr %895[0, 0] : (!llvm.ptr) -> !llvm.ptr, !llvm.struct<(i64, i64)>
llvm.store %870, %896 : i64, !llvm.ptr
%897 = llvm.load %844 : !llvm.ptr -> i64
%898 = llvm.getelementptr %arg0[%897] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64, i64)>
%899 = llvm.getelementptr %898[0, 1] : (!llvm.ptr) -> !llvm.ptr, !llvm.struct<(i64, i64)>
llvm.store %875, %899 : i64, !llvm.ptr
cf.br ^bb197
^bb196:
%901 = llvm.getelementptr %arg0[%851] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64, i64)>
%900 = llvm.load %901 : !llvm.ptr -> !llvm.struct<(i64, i64)>
%902 = llvm.getelementptr %arg0[%851] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64, i64)>
%903 = llvm.getelementptr %902[0, 0] : (!llvm.ptr) -> !llvm.ptr, !llvm.struct<(i64, i64)>
%904 = llvm.load %903 : !llvm.ptr -> i64
%906 = llvm.load %844 : !llvm.ptr -> i64
%907 = llvm.getelementptr %arg0[%906] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64, i64)>
%905 = llvm.load %907 : !llvm.ptr -> !llvm.struct<(i64, i64)>
%908 = llvm.load %844 : !llvm.ptr -> i64
%909 = llvm.getelementptr %arg0[%908] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64, i64)>
%910 = llvm.getelementptr %909[0, 0] : (!llvm.ptr) -> !llvm.ptr, !llvm.struct<(i64, i64)>
%911 = llvm.load %910 : !llvm.ptr -> i64
%912 = arith.cmpi eq, %904, %911 : i64
%913 = scf.if %912 -> (i1) {
%915 = llvm.getelementptr %arg0[%851] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64, i64)>
%914 = llvm.load %915 : !llvm.ptr -> !llvm.struct<(i64, i64)>
%916 = llvm.getelementptr %arg0[%851] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64, i64)>
%917 = llvm.getelementptr %916[0, 1] : (!llvm.ptr) -> !llvm.ptr, !llvm.struct<(i64, i64)>
%918 = llvm.load %917 : !llvm.ptr -> i64
%920 = llvm.load %844 : !llvm.ptr -> i64
%921 = llvm.getelementptr %arg0[%920] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64, i64)>
%919 = llvm.load %921 : !llvm.ptr -> !llvm.struct<(i64, i64)>
%922 = llvm.load %844 : !llvm.ptr -> i64
%923 = llvm.getelementptr %arg0[%922] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64, i64)>
%924 = llvm.getelementptr %923[0, 1] : (!llvm.ptr) -> !llvm.ptr, !llvm.struct<(i64, i64)>
%925 = llvm.load %924 : !llvm.ptr -> i64
%926 = arith.cmpi sgt, %918, %925 : i64
scf.yield %926 : i1
} else {
%927 = arith.constant false
scf.yield %927 : i1
}
cf.cond_br %913, ^bb198, ^bb199
^bb198:
%929 = llvm.getelementptr %arg0[%851] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64, i64)>
%928 = llvm.load %929 : !llvm.ptr -> !llvm.struct<(i64, i64)>
%930 = llvm.getelementptr %arg0[%851] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64, i64)>
%931 = llvm.getelementptr %930[0, 0] : (!llvm.ptr) -> !llvm.ptr, !llvm.struct<(i64, i64)>
%932 = llvm.load %931 : !llvm.ptr -> i64
%934 = llvm.getelementptr %arg0[%851] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64, i64)>
%933 = llvm.load %934 : !llvm.ptr -> !llvm.struct<(i64, i64)>
%935 = llvm.getelementptr %arg0[%851] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64, i64)>
%936 = llvm.getelementptr %935[0, 1] : (!llvm.ptr) -> !llvm.ptr, !llvm.struct<(i64, i64)>
%937 = llvm.load %936 : !llvm.ptr -> i64
%939 = llvm.load %844 : !llvm.ptr -> i64
%940 = llvm.getelementptr %arg0[%939] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64, i64)>
%938 = llvm.load %940 : !llvm.ptr -> !llvm.struct<(i64, i64)>
%941 = llvm.load %844 : !llvm.ptr -> i64
%942 = llvm.getelementptr %arg0[%941] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64, i64)>
%943 = llvm.getelementptr %942[0, 0] : (!llvm.ptr) -> !llvm.ptr, !llvm.struct<(i64, i64)>
%944 = llvm.load %943 : !llvm.ptr -> i64
%945 = llvm.getelementptr %arg0[%851] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64, i64)>
%946 = llvm.getelementptr %945[0, 0] : (!llvm.ptr) -> !llvm.ptr, !llvm.struct<(i64, i64)>
llvm.store %944, %946 : i64, !llvm.ptr
%948 = llvm.load %844 : !llvm.ptr -> i64
%949 = llvm.getelementptr %arg0[%948] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64, i64)>
%947 = llvm.load %949 : !llvm.ptr -> !llvm.struct<(i64, i64)>
%950 = llvm.load %844 : !llvm.ptr -> i64
%951 = llvm.getelementptr %arg0[%950] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64, i64)>
%952 = llvm.getelementptr %951[0, 1] : (!llvm.ptr) -> !llvm.ptr, !llvm.struct<(i64, i64)>
%953 = llvm.load %952 : !llvm.ptr -> i64
%954 = llvm.getelementptr %arg0[%851] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64, i64)>
%955 = llvm.getelementptr %954[0, 1] : (!llvm.ptr) -> !llvm.ptr, !llvm.struct<(i64, i64)>
llvm.store %953, %955 : i64, !llvm.ptr
%956 = llvm.load %844 : !llvm.ptr -> i64
%957 = llvm.getelementptr %arg0[%956] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64, i64)>
%958 = llvm.getelementptr %957[0, 0] : (!llvm.ptr) -> !llvm.ptr, !llvm.struct<(i64, i64)>
llvm.store %932, %958 : i64, !llvm.ptr
%959 = llvm.load %844 : !llvm.ptr -> i64
%960 = llvm.getelementptr %arg0[%959] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64, i64)>
%961 = llvm.getelementptr %960[0, 1] : (!llvm.ptr) -> !llvm.ptr, !llvm.struct<(i64, i64)>
llvm.store %937, %961 : i64, !llvm.ptr
cf.br ^bb200
^bb199:
cf.br ^bb194
^bb200:
cf.br ^bb197
^bb197:
%962 = llvm.load %844 : !llvm.ptr -> i64
%963 = arith.constant 1 : i32
%965 = arith.extsi %963 : i32 to i64
%964 = arith.subi %962, %965 : i64
llvm.store %964, %844 : i64, !llvm.ptr
cf.br ^bb192
^bb194:
%966 = llvm.load %839 : !llvm.ptr -> i64
%967 = arith.constant 1 : i32
%969 = arith.extsi %967 : i32 to i64
%968 = arith.addi %966, %969 : i64
llvm.store %968, %839 : i64, !llvm.ptr
cf.br ^bb189
^bb191:
func.return
}
func.func @count_pentagonal_sum_ways(%arg0: i64) -> i32 {
%970 = arith.constant 6 : i32
%972 = arith.extsi %970 : i32 to i64
%971 = arith.muli %972, %arg0 : i64
%973 = arith.constant 1 : i32
%975 = arith.extsi %973 : i32 to i64
%974 = arith.subi %971, %975 : i64
%976 = arith.muli %974, %974 : i64
%977 = arith.constant 1 : i32
%979 = arith.extsi %977 : i32 to i64
%978 = arith.addi %976, %979 : i64
%981 = arith.constant 64 : i32
%982 = arith.constant 16 : i32
%983 = arith.muli %981, %982 : i32
%984 = arith.extsi %983 : i32 to i64
%980 = func.call @malloc(%984) : (i64) -> !llvm.ptr
%985 = func.call @factorize(%978, %980) : (i64, !llvm.ptr) -> i64
%987 = arith.constant 64 : i32
%988 = arith.constant 64 : i32
%989 = arith.muli %987, %988 : i32
%990 = arith.constant 8 : i32
%991 = arith.muli %989, %990 : i32
%992 = arith.extsi %991 : i32 to i64
%986 = func.call @malloc(%992) : (i64) -> !llvm.ptr
%994 = arith.constant 64 : i32
%995 = arith.constant 64 : i32
%996 = arith.muli %994, %995 : i32
%997 = arith.constant 8 : i32
%998 = arith.muli %996, %997 : i32
%999 = arith.extsi %998 : i32 to i64
%993 = func.call @malloc(%999) : (i64) -> !llvm.ptr
%1001 = arith.constant 64 : i32
%1002 = arith.constant 8 : i32
%1003 = arith.muli %1001, %1002 : i32
%1004 = arith.extsi %1003 : i32 to i64
%1000 = func.call @malloc(%1004) : (i64) -> !llvm.ptr
%1005 = arith.constant 0 : i32
%1006 = arith.extsi %1005 : i32 to i64
%1007 = llvm.mlir.constant(1 : i64) : i64
%1008 = llvm.alloca %1007 x i64 : (i64) -> !llvm.ptr
llvm.store %1006, %1008 : i64, !llvm.ptr
%1010 = arith.constant 64 : i32
%1011 = arith.constant 8 : i32
%1012 = arith.muli %1010, %1011 : i32
%1013 = arith.extsi %1012 : i32 to i64
%1009 = func.call @malloc(%1013) : (i64) -> !llvm.ptr
%1015 = arith.constant 64 : i32
%1016 = arith.constant 8 : i32
%1017 = arith.muli %1015, %1016 : i32
%1018 = arith.extsi %1017 : i32 to i64
%1014 = func.call @malloc(%1018) : (i64) -> !llvm.ptr
%1020 = arith.constant 64 : i32
%1021 = arith.constant 8 : i32
%1022 = arith.muli %1020, %1021 : i32
%1023 = arith.extsi %1022 : i32 to i64
%1019 = func.call @malloc(%1023) : (i64) -> !llvm.ptr
%1025 = arith.constant 64 : i32
%1026 = arith.constant 8 : i32
%1027 = arith.muli %1025, %1026 : i32
%1028 = arith.extsi %1027 : i32 to i64
%1024 = func.call @malloc(%1028) : (i64) -> !llvm.ptr
%1029 = arith.constant 0 : i32
%1030 = arith.extsi %1029 : i32 to i64
%1031 = llvm.mlir.constant(1 : i64) : i64
%1032 = llvm.alloca %1031 x i64 : (i64) -> !llvm.ptr
llvm.store %1030, %1032 : i64, !llvm.ptr
cf.br ^bb201
^bb201:
%1033 = llvm.load %1032 : !llvm.ptr -> i64
%1034 = arith.cmpi slt, %1033, %985 : i64
cf.cond_br %1034, ^bb202, ^bb203
^bb202:
%1036 = llvm.load %1032 : !llvm.ptr -> i64
%1037 = llvm.getelementptr %980[%1036] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64, i32)>
%1035 = llvm.load %1037 : !llvm.ptr -> !llvm.struct<(i64, i32)>
%1038 = llvm.load %1032 : !llvm.ptr -> i64
%1039 = llvm.getelementptr %980[%1038] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64, i32)>
%1040 = llvm.getelementptr %1039[0, 0] : (!llvm.ptr) -> !llvm.ptr, !llvm.struct<(i64, i32)>
%1041 = llvm.load %1040 : !llvm.ptr -> i64
%1043 = llvm.load %1032 : !llvm.ptr -> i64
%1044 = llvm.getelementptr %980[%1043] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64, i32)>
%1042 = llvm.load %1044 : !llvm.ptr -> !llvm.struct<(i64, i32)>
%1045 = llvm.load %1032 : !llvm.ptr -> i64
%1046 = llvm.getelementptr %980[%1045] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64, i32)>
%1047 = llvm.getelementptr %1046[0, 1] : (!llvm.ptr) -> !llvm.ptr, !llvm.struct<(i64, i32)>
%1048 = llvm.load %1047 : !llvm.ptr -> i32
%1049 = arith.constant 2 : i32
%1051 = arith.extsi %1049 : i32 to i64
%1050 = arith.cmpi eq, %1041, %1051 : i64
cf.cond_br %1050, ^bb204, ^bb205
^bb204:
%1052 = llvm.load %1032 : !llvm.ptr -> i64
%1053 = arith.constant 1 : i32
%1055 = arith.extsi %1053 : i32 to i64
%1054 = arith.addi %1052, %1055 : i64
llvm.store %1054, %1032 : i64, !llvm.ptr
cf.br ^bb201
^bb205:
cf.br ^bb206
^bb206:
func.call @cornacchia(%1041) : (i64) -> ()
%1057 = llvm.mlir.addressof @corn_a : !llvm.ptr
%1058 = llvm.load %1057 : !llvm.ptr -> i64
%1059 = llvm.mlir.addressof @corn_b : !llvm.ptr
%1060 = llvm.load %1059 : !llvm.ptr -> i64
%1061 = llvm.mlir.addressof @corn_a : !llvm.ptr
%1062 = llvm.load %1061 : !llvm.ptr -> i64
%1063 = arith.constant 0 : i32
%1064 = llvm.mlir.addressof @corn_b : !llvm.ptr
%1065 = llvm.load %1064 : !llvm.ptr -> i64
%1067 = arith.extsi %1063 : i32 to i64
%1066 = arith.subi %1067, %1065 : i64
%1068 = arith.constant 1 : i32
%1069 = arith.constant 0 : i32
%1070 = arith.extsi %1068 : i32 to i64
%1071 = arith.extsi %1069 : i32 to i64
%1072 = llvm.getelementptr %1009[%1071] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %1070, %1072 : i64, !llvm.ptr
%1073 = arith.constant 0 : i32
%1074 = arith.constant 0 : i32
%1075 = arith.extsi %1073 : i32 to i64
%1076 = arith.extsi %1074 : i32 to i64
%1077 = llvm.getelementptr %1014[%1076] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %1075, %1077 : i64, !llvm.ptr
%1078 = arith.constant 1 : i32
%1079 = arith.constant 0 : i32
%1080 = arith.extsi %1078 : i32 to i64
%1081 = arith.extsi %1079 : i32 to i64
%1082 = llvm.getelementptr %1019[%1081] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %1080, %1082 : i64, !llvm.ptr
%1083 = arith.constant 0 : i32
%1084 = arith.constant 0 : i32
%1085 = arith.extsi %1083 : i32 to i64
%1086 = arith.extsi %1084 : i32 to i64
%1087 = llvm.getelementptr %1024[%1086] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %1085, %1087 : i64, !llvm.ptr
%1088 = arith.constant 1 : i32
%1089 = llvm.mlir.constant(1 : i64) : i64
%1090 = llvm.alloca %1089 x i32 : (i64) -> !llvm.ptr
llvm.store %1088, %1090 : i32, !llvm.ptr
cf.br ^bb207
^bb207:
%1091 = llvm.load %1090 : !llvm.ptr -> i32
%1092 = arith.cmpi sle, %1091, %1048 : i32
cf.cond_br %1092, ^bb208, ^bb209
^bb208:
%1095 = llvm.load %1090 : !llvm.ptr -> i32
%1096 = arith.constant 1 : i32
%1097 = arith.subi %1095, %1096 : i32
%1098 = arith.extsi %1097 : i32 to i64
%1099 = llvm.getelementptr %1009[%1098] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%1094 = llvm.load %1099 : !llvm.ptr -> i64
%1101 = llvm.load %1090 : !llvm.ptr -> i32
%1102 = arith.constant 1 : i32
%1103 = arith.subi %1101, %1102 : i32
%1104 = arith.extsi %1103 : i32 to i64
%1105 = llvm.getelementptr %1014[%1104] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%1100 = llvm.load %1105 : !llvm.ptr -> i64
# String concatenation: !llvm.ptr + i32
# String concatenation: !llvm.ptr + i32
func.call @gmul(%1094, %1100, %1058, %1060, %1106, %1107) : (i64, i64, i64, i64, !llvm.ptr, !llvm.ptr) -> ()
%1110 = llvm.load %1090 : !llvm.ptr -> i32
%1111 = arith.constant 1 : i32
%1112 = arith.subi %1110, %1111 : i32
%1113 = arith.extsi %1112 : i32 to i64
%1114 = llvm.getelementptr %1019[%1113] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%1109 = llvm.load %1114 : !llvm.ptr -> i64
%1116 = llvm.load %1090 : !llvm.ptr -> i32
%1117 = arith.constant 1 : i32
%1118 = arith.subi %1116, %1117 : i32
%1119 = arith.extsi %1118 : i32 to i64
%1120 = llvm.getelementptr %1024[%1119] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%1115 = llvm.load %1120 : !llvm.ptr -> i64
# String concatenation: !llvm.ptr + i32
# String concatenation: !llvm.ptr + i32
func.call @gmul(%1109, %1115, %1062, %1066, %1121, %1122) : (i64, i64, i64, i64, !llvm.ptr, !llvm.ptr) -> ()
%1123 = llvm.load %1090 : !llvm.ptr -> i32
%1124 = arith.constant 1 : i32
%1125 = arith.addi %1123, %1124 : i32
llvm.store %1125, %1090 : i32, !llvm.ptr
cf.br ^bb207
^bb209:
%1126 = arith.constant 0 : i32
%1127 = llvm.mlir.constant(1 : i64) : i64
%1128 = llvm.alloca %1127 x i32 : (i64) -> !llvm.ptr
llvm.store %1126, %1128 : i32, !llvm.ptr
cf.br ^bb210
^bb210:
%1129 = llvm.load %1128 : !llvm.ptr -> i32
%1130 = arith.cmpi sle, %1129, %1048 : i32
cf.cond_br %1130, ^bb211, ^bb212
^bb211:
%1131 = arith.constant 0 : i32
%1132 = arith.extsi %1131 : i32 to i64
%1133 = arith.constant 0 : i32
%1134 = arith.extsi %1133 : i32 to i64
%1136 = arith.constant 8 : i32
%1137 = arith.extsi %1136 : i32 to i64
%1135 = func.call @malloc(%1137) : (i64) -> !llvm.ptr
%1139 = arith.constant 8 : i32
%1140 = arith.extsi %1139 : i32 to i64
%1138 = func.call @malloc(%1140) : (i64) -> !llvm.ptr
%1143 = llvm.load %1128 : !llvm.ptr -> i32
%1144 = arith.extsi %1143 : i32 to i64
%1145 = llvm.getelementptr %1009[%1144] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%1142 = llvm.load %1145 : !llvm.ptr -> i64
%1147 = llvm.load %1128 : !llvm.ptr -> i32
%1148 = arith.extsi %1147 : i32 to i64
%1149 = llvm.getelementptr %1014[%1148] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%1146 = llvm.load %1149 : !llvm.ptr -> i64
%1151 = llvm.load %1128 : !llvm.ptr -> i32
%1152 = arith.subi %1048, %1151 : i32
%1153 = arith.extsi %1152 : i32 to i64
%1154 = llvm.getelementptr %1019[%1153] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%1150 = llvm.load %1154 : !llvm.ptr -> i64
%1156 = llvm.load %1128 : !llvm.ptr -> i32
%1157 = arith.subi %1048, %1156 : i32
%1158 = arith.extsi %1157 : i32 to i64
%1159 = llvm.getelementptr %1024[%1158] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%1155 = llvm.load %1159 : !llvm.ptr -> i64
func.call @gmul(%1142, %1146, %1150, %1155, %1135, %1138) : (i64, i64, i64, i64, !llvm.ptr, !llvm.ptr) -> ()
%1161 = arith.constant 0 : i32
%1162 = arith.extsi %1161 : i32 to i64
%1163 = llvm.getelementptr %1135[%1162] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%1160 = llvm.load %1163 : !llvm.ptr -> i64
%1164 = llvm.load %1008 : !llvm.ptr -> i64
%1165 = arith.constant 64 : i32
%1167 = arith.extsi %1165 : i32 to i64
%1166 = arith.muli %1164, %1167 : i64
%1168 = llvm.load %1128 : !llvm.ptr -> i32
%1170 = arith.extsi %1168 : i32 to i64
%1169 = arith.addi %1166, %1170 : i64
%1171 = llvm.getelementptr %986[%1169] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %1160, %1171 : i64, !llvm.ptr
%1173 = arith.constant 0 : i32
%1174 = arith.extsi %1173 : i32 to i64
%1175 = llvm.getelementptr %1138[%1174] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%1172 = llvm.load %1175 : !llvm.ptr -> i64
%1176 = llvm.load %1008 : !llvm.ptr -> i64
%1177 = arith.constant 64 : i32
%1179 = arith.extsi %1177 : i32 to i64
%1178 = arith.muli %1176, %1179 : i64
%1180 = llvm.load %1128 : !llvm.ptr -> i32
%1182 = arith.extsi %1180 : i32 to i64
%1181 = arith.addi %1178, %1182 : i64
%1183 = llvm.getelementptr %993[%1181] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %1172, %1183 : i64, !llvm.ptr
func.call @free(%1135) : (!llvm.ptr) -> ()
func.call @free(%1138) : (!llvm.ptr) -> ()
%1186 = llvm.load %1128 : !llvm.ptr -> i32
%1187 = arith.constant 1 : i32
%1188 = arith.addi %1186, %1187 : i32
llvm.store %1188, %1128 : i32, !llvm.ptr
cf.br ^bb210
^bb212:
%1189 = arith.constant 1 : i32
%1190 = arith.addi %1048, %1189 : i32
%1191 = arith.extsi %1190 : i32 to i64
%1192 = llvm.load %1008 : !llvm.ptr -> i64
%1193 = llvm.getelementptr %1000[%1192] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %1191, %1193 : i64, !llvm.ptr
%1194 = llvm.load %1008 : !llvm.ptr -> i64
%1195 = arith.constant 1 : i32
%1197 = arith.extsi %1195 : i32 to i64
%1196 = arith.addi %1194, %1197 : i64
llvm.store %1196, %1008 : i64, !llvm.ptr
%1198 = llvm.load %1032 : !llvm.ptr -> i64
%1199 = arith.constant 1 : i32
%1201 = arith.extsi %1199 : i32 to i64
%1200 = arith.addi %1198, %1201 : i64
llvm.store %1200, %1032 : i64, !llvm.ptr
cf.br ^bb201
^bb203:
%1203 = arith.constant 8192 : i32
%1204 = arith.constant 8 : i32
%1205 = arith.muli %1203, %1204 : i32
%1206 = arith.extsi %1205 : i32 to i64
%1202 = func.call @malloc(%1206) : (i64) -> !llvm.ptr
%1208 = arith.constant 8192 : i32
%1209 = arith.constant 8 : i32
%1210 = arith.muli %1208, %1209 : i32
%1211 = arith.extsi %1210 : i32 to i64
%1207 = func.call @malloc(%1211) : (i64) -> !llvm.ptr
%1213 = arith.constant 8192 : i32
%1214 = arith.constant 8 : i32
%1215 = arith.muli %1213, %1214 : i32
%1216 = arith.extsi %1215 : i32 to i64
%1212 = func.call @malloc(%1216) : (i64) -> !llvm.ptr
%1218 = arith.constant 8192 : i32
%1219 = arith.constant 8 : i32
%1220 = arith.muli %1218, %1219 : i32
%1221 = arith.extsi %1220 : i32 to i64
%1217 = func.call @malloc(%1221) : (i64) -> !llvm.ptr
%1222 = arith.constant 1 : i32
%1223 = arith.extsi %1222 : i32 to i64
%1224 = llvm.mlir.constant(1 : i64) : i64
%1225 = llvm.alloca %1224 x i64 : (i64) -> !llvm.ptr
llvm.store %1223, %1225 : i64, !llvm.ptr
%1226 = arith.constant 1 : i32
%1227 = arith.constant 0 : i32
%1228 = arith.extsi %1226 : i32 to i64
%1229 = arith.extsi %1227 : i32 to i64
%1230 = llvm.getelementptr %1202[%1229] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %1228, %1230 : i64, !llvm.ptr
%1231 = arith.constant 0 : i32
%1232 = arith.constant 0 : i32
%1233 = arith.extsi %1231 : i32 to i64
%1234 = arith.extsi %1232 : i32 to i64
%1235 = llvm.getelementptr %1207[%1234] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %1233, %1235 : i64, !llvm.ptr
%1236 = arith.constant 0 : i32
%1237 = arith.extsi %1236 : i32 to i64
%1238 = llvm.mlir.constant(1 : i64) : i64
%1239 = llvm.alloca %1238 x i64 : (i64) -> !llvm.ptr
llvm.store %1237, %1239 : i64, !llvm.ptr
cf.br ^bb213
^bb213:
%1240 = llvm.load %1239 : !llvm.ptr -> i64
%1241 = llvm.load %1008 : !llvm.ptr -> i64
%1242 = arith.cmpi slt, %1240, %1241 : i64
cf.cond_br %1242, ^bb214, ^bb215
^bb214:
%1243 = arith.constant 0 : i32
%1244 = arith.extsi %1243 : i32 to i64
%1245 = llvm.mlir.constant(1 : i64) : i64
%1246 = llvm.alloca %1245 x i64 : (i64) -> !llvm.ptr
llvm.store %1244, %1246 : i64, !llvm.ptr
%1247 = arith.constant 0 : i32
%1248 = arith.extsi %1247 : i32 to i64
%1249 = llvm.mlir.constant(1 : i64) : i64
%1250 = llvm.alloca %1249 x i64 : (i64) -> !llvm.ptr
llvm.store %1248, %1250 : i64, !llvm.ptr
cf.br ^bb216
^bb216:
%1251 = llvm.load %1250 : !llvm.ptr -> i64
%1252 = llvm.load %1225 : !llvm.ptr -> i64
%1253 = arith.cmpi slt, %1251, %1252 : i64
cf.cond_br %1253, ^bb217, ^bb218
^bb217:
%1254 = arith.constant 0 : i32
%1255 = arith.extsi %1254 : i32 to i64
%1256 = llvm.mlir.constant(1 : i64) : i64
%1257 = llvm.alloca %1256 x i64 : (i64) -> !llvm.ptr
llvm.store %1255, %1257 : i64, !llvm.ptr
cf.br ^bb219
^bb219:
%1258 = llvm.load %1257 : !llvm.ptr -> i64
%1260 = llvm.load %1239 : !llvm.ptr -> i64
%1261 = llvm.getelementptr %1000[%1260] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%1259 = llvm.load %1261 : !llvm.ptr -> i64
%1262 = arith.cmpi slt, %1258, %1259 : i64
cf.cond_br %1262, ^bb220, ^bb221
^bb220:
%1263 = llvm.load %1246 : !llvm.ptr -> i64
%1264 = arith.constant 8192 : i32
%1266 = arith.extsi %1264 : i32 to i64
%1265 = arith.cmpi slt, %1263, %1266 : i64
cf.cond_br %1265, ^bb222, ^bb223
^bb222:
%1268 = arith.constant 8 : i32
%1269 = arith.extsi %1268 : i32 to i64
%1267 = func.call @malloc(%1269) : (i64) -> !llvm.ptr
%1271 = arith.constant 8 : i32
%1272 = arith.extsi %1271 : i32 to i64
%1270 = func.call @malloc(%1272) : (i64) -> !llvm.ptr
%1275 = llvm.load %1250 : !llvm.ptr -> i64
%1276 = llvm.getelementptr %1202[%1275] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%1274 = llvm.load %1276 : !llvm.ptr -> i64
%1278 = llvm.load %1250 : !llvm.ptr -> i64
%1279 = llvm.getelementptr %1207[%1278] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%1277 = llvm.load %1279 : !llvm.ptr -> i64
%1281 = llvm.load %1239 : !llvm.ptr -> i64
%1282 = arith.constant 64 : i32
%1284 = arith.extsi %1282 : i32 to i64
%1283 = arith.muli %1281, %1284 : i64
%1285 = llvm.load %1257 : !llvm.ptr -> i64
%1286 = arith.addi %1283, %1285 : i64
%1287 = llvm.getelementptr %986[%1286] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%1280 = llvm.load %1287 : !llvm.ptr -> i64
%1289 = llvm.load %1239 : !llvm.ptr -> i64
%1290 = arith.constant 64 : i32
%1292 = arith.extsi %1290 : i32 to i64
%1291 = arith.muli %1289, %1292 : i64
%1293 = llvm.load %1257 : !llvm.ptr -> i64
%1294 = arith.addi %1291, %1293 : i64
%1295 = llvm.getelementptr %993[%1294] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%1288 = llvm.load %1295 : !llvm.ptr -> i64
func.call @gmul(%1274, %1277, %1280, %1288, %1267, %1270) : (i64, i64, i64, i64, !llvm.ptr, !llvm.ptr) -> ()
%1297 = arith.constant 0 : i32
%1298 = arith.extsi %1297 : i32 to i64
%1299 = llvm.getelementptr %1267[%1298] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%1296 = llvm.load %1299 : !llvm.ptr -> i64
%1300 = llvm.load %1246 : !llvm.ptr -> i64
%1301 = llvm.getelementptr %1212[%1300] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %1296, %1301 : i64, !llvm.ptr
%1303 = arith.constant 0 : i32
%1304 = arith.extsi %1303 : i32 to i64
%1305 = llvm.getelementptr %1270[%1304] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%1302 = llvm.load %1305 : !llvm.ptr -> i64
%1306 = llvm.load %1246 : !llvm.ptr -> i64
%1307 = llvm.getelementptr %1217[%1306] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %1302, %1307 : i64, !llvm.ptr
func.call @free(%1267) : (!llvm.ptr) -> ()
func.call @free(%1270) : (!llvm.ptr) -> ()
%1310 = llvm.load %1246 : !llvm.ptr -> i64
%1311 = arith.constant 1 : i32
%1313 = arith.extsi %1311 : i32 to i64
%1312 = arith.addi %1310, %1313 : i64
llvm.store %1312, %1246 : i64, !llvm.ptr
cf.br ^bb224
^bb223:
cf.br ^bb224
^bb224:
%1314 = llvm.load %1257 : !llvm.ptr -> i64
%1315 = arith.constant 1 : i32
%1317 = arith.extsi %1315 : i32 to i64
%1316 = arith.addi %1314, %1317 : i64
llvm.store %1316, %1257 : i64, !llvm.ptr
cf.br ^bb219
^bb221:
%1318 = llvm.load %1250 : !llvm.ptr -> i64
%1319 = arith.constant 1 : i32
%1321 = arith.extsi %1319 : i32 to i64
%1320 = arith.addi %1318, %1321 : i64
llvm.store %1320, %1250 : i64, !llvm.ptr
cf.br ^bb216
^bb218:
%1322 = arith.constant 0 : i32
%1323 = arith.extsi %1322 : i32 to i64
%1324 = llvm.mlir.constant(1 : i64) : i64
%1325 = llvm.alloca %1324 x i64 : (i64) -> !llvm.ptr
llvm.store %1323, %1325 : i64, !llvm.ptr
cf.br ^bb225
^bb225:
%1326 = llvm.load %1325 : !llvm.ptr -> i64
%1327 = llvm.load %1246 : !llvm.ptr -> i64
%1328 = arith.cmpi slt, %1326, %1327 : i64
cf.cond_br %1328, ^bb226, ^bb227
^bb226:
%1330 = llvm.load %1325 : !llvm.ptr -> i64
%1331 = llvm.getelementptr %1212[%1330] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%1329 = llvm.load %1331 : !llvm.ptr -> i64
%1332 = llvm.load %1325 : !llvm.ptr -> i64
%1333 = llvm.getelementptr %1202[%1332] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %1329, %1333 : i64, !llvm.ptr
%1335 = llvm.load %1325 : !llvm.ptr -> i64
%1336 = llvm.getelementptr %1217[%1335] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%1334 = llvm.load %1336 : !llvm.ptr -> i64
%1337 = llvm.load %1325 : !llvm.ptr -> i64
%1338 = llvm.getelementptr %1207[%1337] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %1334, %1338 : i64, !llvm.ptr
%1339 = llvm.load %1325 : !llvm.ptr -> i64
%1340 = arith.constant 1 : i32
%1342 = arith.extsi %1340 : i32 to i64
%1341 = arith.addi %1339, %1342 : i64
llvm.store %1341, %1325 : i64, !llvm.ptr
cf.br ^bb225
^bb227:
%1343 = llvm.load %1246 : !llvm.ptr -> i64
llvm.store %1343, %1225 : i64, !llvm.ptr
%1344 = llvm.load %1239 : !llvm.ptr -> i64
%1345 = arith.constant 1 : i32
%1347 = arith.extsi %1345 : i32 to i64
%1346 = arith.addi %1344, %1347 : i64
llvm.store %1346, %1239 : i64, !llvm.ptr
cf.br ^bb213
^bb215:
%1348 = arith.constant 0 : i32
%1349 = arith.extsi %1348 : i32 to i64
%1350 = llvm.mlir.constant(1 : i64) : i64
%1351 = llvm.alloca %1350 x i64 : (i64) -> !llvm.ptr
llvm.store %1349, %1351 : i64, !llvm.ptr
cf.br ^bb228
^bb228:
%1352 = llvm.load %1351 : !llvm.ptr -> i64
%1353 = llvm.load %1225 : !llvm.ptr -> i64
%1354 = arith.cmpi slt, %1352, %1353 : i64
cf.cond_br %1354, ^bb229, ^bb230
^bb229:
%1356 = arith.constant 8 : i32
%1357 = arith.extsi %1356 : i32 to i64
%1355 = func.call @malloc(%1357) : (i64) -> !llvm.ptr
%1359 = arith.constant 8 : i32
%1360 = arith.extsi %1359 : i32 to i64
%1358 = func.call @malloc(%1360) : (i64) -> !llvm.ptr
%1363 = llvm.load %1351 : !llvm.ptr -> i64
%1364 = llvm.getelementptr %1202[%1363] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%1362 = llvm.load %1364 : !llvm.ptr -> i64
%1366 = llvm.load %1351 : !llvm.ptr -> i64
%1367 = llvm.getelementptr %1207[%1366] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%1365 = llvm.load %1367 : !llvm.ptr -> i64
%1368 = arith.constant 1 : i32
%1369 = arith.constant 1 : i32
%1370 = arith.extsi %1368 : i32 to i64
%1371 = arith.extsi %1369 : i32 to i64
func.call @gmul(%1362, %1365, %1370, %1371, %1355, %1358) : (i64, i64, i64, i64, !llvm.ptr, !llvm.ptr) -> ()
%1373 = arith.constant 0 : i32
%1374 = arith.extsi %1373 : i32 to i64
%1375 = llvm.getelementptr %1355[%1374] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%1372 = llvm.load %1375 : !llvm.ptr -> i64
%1376 = llvm.load %1351 : !llvm.ptr -> i64
%1377 = llvm.getelementptr %1202[%1376] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %1372, %1377 : i64, !llvm.ptr
%1379 = arith.constant 0 : i32
%1380 = arith.extsi %1379 : i32 to i64
%1381 = llvm.getelementptr %1358[%1380] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%1378 = llvm.load %1381 : !llvm.ptr -> i64
%1382 = llvm.load %1351 : !llvm.ptr -> i64
%1383 = llvm.getelementptr %1207[%1382] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %1378, %1383 : i64, !llvm.ptr
func.call @free(%1355) : (!llvm.ptr) -> ()
func.call @free(%1358) : (!llvm.ptr) -> ()
%1386 = llvm.load %1351 : !llvm.ptr -> i64
%1387 = arith.constant 1 : i32
%1389 = arith.extsi %1387 : i32 to i64
%1388 = arith.addi %1386, %1389 : i64
llvm.store %1388, %1351 : i64, !llvm.ptr
cf.br ^bb228
^bb230:
%1391 = arith.constant 8192 : i32
%1392 = arith.constant 16 : i32
%1393 = arith.muli %1391, %1392 : i32
%1394 = arith.extsi %1393 : i32 to i64
%1390 = func.call @malloc(%1394) : (i64) -> !llvm.ptr
%1395 = arith.constant 0 : i32
%1396 = arith.extsi %1395 : i32 to i64
%1397 = llvm.mlir.constant(1 : i64) : i64
%1398 = llvm.alloca %1397 x i64 : (i64) -> !llvm.ptr
llvm.store %1396, %1398 : i64, !llvm.ptr
%1399 = arith.constant 0 : i32
%1400 = arith.extsi %1399 : i32 to i64
llvm.store %1400, %1351 : i64, !llvm.ptr
cf.br ^bb231
^bb231:
%1401 = llvm.load %1351 : !llvm.ptr -> i64
%1402 = llvm.load %1225 : !llvm.ptr -> i64
%1403 = arith.cmpi slt, %1401, %1402 : i64
cf.cond_br %1403, ^bb232, ^bb233
^bb232:
%1405 = llvm.load %1351 : !llvm.ptr -> i64
%1406 = llvm.getelementptr %1202[%1405] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%1404 = llvm.load %1406 : !llvm.ptr -> i64
%1407 = llvm.mlir.constant(1 : i64) : i64
%1408 = llvm.alloca %1407 x i64 : (i64) -> !llvm.ptr
llvm.store %1404, %1408 : i64, !llvm.ptr
%1409 = llvm.load %1408 : !llvm.ptr -> i64
%1410 = arith.constant 0 : i32
%1412 = arith.extsi %1410 : i32 to i64
%1411 = arith.cmpi slt, %1409, %1412 : i64
cf.cond_br %1411, ^bb234, ^bb235
^bb234:
%1413 = arith.constant 0 : i32
%1414 = llvm.load %1408 : !llvm.ptr -> i64
%1416 = arith.extsi %1413 : i32 to i64
%1415 = arith.subi %1416, %1414 : i64
llvm.store %1415, %1408 : i64, !llvm.ptr
cf.br ^bb236
^bb235:
cf.br ^bb236
^bb236:
%1418 = llvm.load %1351 : !llvm.ptr -> i64
%1419 = llvm.getelementptr %1207[%1418] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%1417 = llvm.load %1419 : !llvm.ptr -> i64
%1420 = llvm.mlir.constant(1 : i64) : i64
%1421 = llvm.alloca %1420 x i64 : (i64) -> !llvm.ptr
llvm.store %1417, %1421 : i64, !llvm.ptr
%1422 = llvm.load %1421 : !llvm.ptr -> i64
%1423 = arith.constant 0 : i32
%1425 = arith.extsi %1423 : i32 to i64
%1424 = arith.cmpi slt, %1422, %1425 : i64
cf.cond_br %1424, ^bb237, ^bb238
^bb237:
%1426 = arith.constant 0 : i32
%1427 = llvm.load %1421 : !llvm.ptr -> i64
%1429 = arith.extsi %1426 : i32 to i64
%1428 = arith.subi %1429, %1427 : i64
llvm.store %1428, %1421 : i64, !llvm.ptr
cf.br ^bb239
^bb238:
cf.br ^bb239
^bb239:
%1430 = llvm.load %1408 : !llvm.ptr -> i64
%1431 = arith.constant 0 : i32
%1433 = arith.extsi %1431 : i32 to i64
%1432 = arith.cmpi eq, %1430, %1433 : i64
%1434 = scf.if %1432 -> (i1) {
%1435 = arith.constant true
scf.yield %1435 : i1
} else {
%1436 = llvm.load %1421 : !llvm.ptr -> i64
%1437 = arith.constant 0 : i32
%1439 = arith.extsi %1437 : i32 to i64
%1438 = arith.cmpi eq, %1436, %1439 : i64
scf.yield %1438 : i1
}
cf.cond_br %1434, ^bb240, ^bb241
^bb240:
%1440 = llvm.load %1351 : !llvm.ptr -> i64
%1441 = arith.constant 1 : i32
%1443 = arith.extsi %1441 : i32 to i64
%1442 = arith.addi %1440, %1443 : i64
llvm.store %1442, %1351 : i64, !llvm.ptr
cf.br ^bb231
^bb241:
cf.br ^bb242
^bb242:
%1444 = llvm.load %1408 : !llvm.ptr -> i64
%1445 = llvm.load %1421 : !llvm.ptr -> i64
%1446 = arith.cmpi sgt, %1444, %1445 : i64
cf.cond_br %1446, ^bb243, ^bb244
^bb243:
%1447 = llvm.load %1408 : !llvm.ptr -> i64
%1448 = llvm.load %1421 : !llvm.ptr -> i64
llvm.store %1448, %1408 : i64, !llvm.ptr
llvm.store %1447, %1421 : i64, !llvm.ptr
cf.br ^bb245
^bb244:
cf.br ^bb245
^bb245:
%1449 = llvm.load %1408 : !llvm.ptr -> i64
%1450 = arith.constant 3 : i32
%1452 = arith.extsi %1450 : i32 to i64
%1451 = arith.remsi %1449, %1452 : i64
%1453 = arith.constant 2 : i32
%1455 = arith.extsi %1453 : i32 to i64
%1454 = arith.cmpi eq, %1451, %1455 : i64
%1456 = scf.if %1454 -> (i1) {
%1457 = llvm.load %1421 : !llvm.ptr -> i64
%1458 = arith.constant 3 : i32
%1460 = arith.extsi %1458 : i32 to i64
%1459 = arith.remsi %1457, %1460 : i64
%1461 = arith.constant 2 : i32
%1463 = arith.extsi %1461 : i32 to i64
%1462 = arith.cmpi eq, %1459, %1463 : i64
scf.yield %1462 : i1
} else {
%1464 = arith.constant false
scf.yield %1464 : i1
}
cf.cond_br %1456, ^bb246, ^bb247
^bb246:
%1465 = llvm.load %1408 : !llvm.ptr -> i64
%1466 = llvm.load %1398 : !llvm.ptr -> i64
%1467 = llvm.getelementptr %1390[%1466] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64, i64)>
%1468 = llvm.getelementptr %1467[0, 0] : (!llvm.ptr) -> !llvm.ptr, !llvm.struct<(i64, i64)>
llvm.store %1465, %1468 : i64, !llvm.ptr
%1469 = llvm.load %1421 : !llvm.ptr -> i64
%1470 = llvm.load %1398 : !llvm.ptr -> i64
%1471 = llvm.getelementptr %1390[%1470] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64, i64)>
%1472 = llvm.getelementptr %1471[0, 1] : (!llvm.ptr) -> !llvm.ptr, !llvm.struct<(i64, i64)>
llvm.store %1469, %1472 : i64, !llvm.ptr
%1473 = llvm.load %1398 : !llvm.ptr -> i64
%1474 = arith.constant 1 : i32
%1476 = arith.extsi %1474 : i32 to i64
%1475 = arith.addi %1473, %1476 : i64
llvm.store %1475, %1398 : i64, !llvm.ptr
cf.br ^bb248
^bb247:
cf.br ^bb248
^bb248:
%1477 = llvm.load %1351 : !llvm.ptr -> i64
%1478 = arith.constant 1 : i32
%1480 = arith.extsi %1478 : i32 to i64
%1479 = arith.addi %1477, %1480 : i64
llvm.store %1479, %1351 : i64, !llvm.ptr
cf.br ^bb231
^bb233:
%1482 = llvm.load %1398 : !llvm.ptr -> i64
func.call @sort_gint(%1390, %1482) : (!llvm.ptr, i64) -> ()
%1483 = arith.constant 0 : i32
%1484 = llvm.mlir.constant(1 : i64) : i64
%1485 = llvm.alloca %1484 x i32 : (i64) -> !llvm.ptr
llvm.store %1483, %1485 : i32, !llvm.ptr
%1486 = arith.constant 0 : i32
%1487 = arith.extsi %1486 : i32 to i64
llvm.store %1487, %1351 : i64, !llvm.ptr
cf.br ^bb249
^bb249:
%1488 = llvm.load %1351 : !llvm.ptr -> i64
%1489 = llvm.load %1398 : !llvm.ptr -> i64
%1490 = arith.cmpi slt, %1488, %1489 : i64
cf.cond_br %1490, ^bb250, ^bb251
^bb250:
%1491 = llvm.load %1351 : !llvm.ptr -> i64
%1492 = arith.constant 0 : i32
%1494 = arith.extsi %1492 : i32 to i64
%1493 = arith.cmpi eq, %1491, %1494 : i64
%1495 = scf.if %1493 -> (i1) {
%1496 = arith.constant true
scf.yield %1496 : i1
} else {
%1498 = llvm.load %1351 : !llvm.ptr -> i64
%1499 = llvm.getelementptr %1390[%1498] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64, i64)>
%1497 = llvm.load %1499 : !llvm.ptr -> !llvm.struct<(i64, i64)>
%1500 = llvm.load %1351 : !llvm.ptr -> i64
%1501 = llvm.getelementptr %1390[%1500] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64, i64)>
%1502 = llvm.getelementptr %1501[0, 0] : (!llvm.ptr) -> !llvm.ptr, !llvm.struct<(i64, i64)>
%1503 = llvm.load %1502 : !llvm.ptr -> i64
%1505 = llvm.load %1351 : !llvm.ptr -> i64
%1506 = arith.constant 1 : i32
%1508 = arith.extsi %1506 : i32 to i64
%1507 = arith.subi %1505, %1508 : i64
%1509 = llvm.getelementptr %1390[%1507] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64, i64)>
%1504 = llvm.load %1509 : !llvm.ptr -> !llvm.struct<(i64, i64)>
%1510 = llvm.load %1351 : !llvm.ptr -> i64
%1511 = arith.constant 1 : i32
%1513 = arith.extsi %1511 : i32 to i64
%1512 = arith.subi %1510, %1513 : i64
%1514 = llvm.getelementptr %1390[%1512] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64, i64)>
%1515 = llvm.getelementptr %1514[0, 0] : (!llvm.ptr) -> !llvm.ptr, !llvm.struct<(i64, i64)>
%1516 = llvm.load %1515 : !llvm.ptr -> i64
%1517 = arith.cmpi ne, %1503, %1516 : i64
scf.yield %1517 : i1
}
%1518 = scf.if %1495 -> (i1) {
%1519 = arith.constant true
scf.yield %1519 : i1
} else {
%1521 = llvm.load %1351 : !llvm.ptr -> i64
%1522 = llvm.getelementptr %1390[%1521] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64, i64)>
%1520 = llvm.load %1522 : !llvm.ptr -> !llvm.struct<(i64, i64)>
%1523 = llvm.load %1351 : !llvm.ptr -> i64
%1524 = llvm.getelementptr %1390[%1523] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64, i64)>
%1525 = llvm.getelementptr %1524[0, 1] : (!llvm.ptr) -> !llvm.ptr, !llvm.struct<(i64, i64)>
%1526 = llvm.load %1525 : !llvm.ptr -> i64
%1528 = llvm.load %1351 : !llvm.ptr -> i64
%1529 = arith.constant 1 : i32
%1531 = arith.extsi %1529 : i32 to i64
%1530 = arith.subi %1528, %1531 : i64
%1532 = llvm.getelementptr %1390[%1530] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64, i64)>
%1527 = llvm.load %1532 : !llvm.ptr -> !llvm.struct<(i64, i64)>
%1533 = llvm.load %1351 : !llvm.ptr -> i64
%1534 = arith.constant 1 : i32
%1536 = arith.extsi %1534 : i32 to i64
%1535 = arith.subi %1533, %1536 : i64
%1537 = llvm.getelementptr %1390[%1535] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64, i64)>
%1538 = llvm.getelementptr %1537[0, 1] : (!llvm.ptr) -> !llvm.ptr, !llvm.struct<(i64, i64)>
%1539 = llvm.load %1538 : !llvm.ptr -> i64
%1540 = arith.cmpi ne, %1526, %1539 : i64
scf.yield %1540 : i1
}
cf.cond_br %1518, ^bb252, ^bb253
^bb252:
%1541 = llvm.load %1485 : !llvm.ptr -> i32
%1542 = arith.constant 1 : i32
%1543 = arith.addi %1541, %1542 : i32
llvm.store %1543, %1485 : i32, !llvm.ptr
cf.br ^bb254
^bb253:
cf.br ^bb254
^bb254:
%1544 = llvm.load %1351 : !llvm.ptr -> i64
%1545 = arith.constant 1 : i32
%1547 = arith.extsi %1545 : i32 to i64
%1546 = arith.addi %1544, %1547 : i64
llvm.store %1546, %1351 : i64, !llvm.ptr
cf.br ^bb249
^bb251:
func.call @free(%980) : (!llvm.ptr) -> ()
func.call @free(%986) : (!llvm.ptr) -> ()
func.call @free(%993) : (!llvm.ptr) -> ()
func.call @free(%1000) : (!llvm.ptr) -> ()
func.call @free(%1009) : (!llvm.ptr) -> ()
func.call @free(%1014) : (!llvm.ptr) -> ()
func.call @free(%1019) : (!llvm.ptr) -> ()
func.call @free(%1024) : (!llvm.ptr) -> ()
func.call @free(%1202) : (!llvm.ptr) -> ()
func.call @free(%1207) : (!llvm.ptr) -> ()
func.call @free(%1212) : (!llvm.ptr) -> ()
func.call @free(%1217) : (!llvm.ptr) -> ()
func.call @free(%1390) : (!llvm.ptr) -> ()
%1561 = llvm.load %1485 : !llvm.ptr -> i32
func.return %1561 : i32
}
func.func @sieve_primes(%arg0: i64, %arg1: !llvm.ptr) -> i64 {
%1563 = arith.constant 1 : i32
%1565 = arith.extsi %1563 : i32 to i64
%1564 = arith.addi %arg0, %1565 : i64
%1566 = arith.constant 1 : i32
%1567 = arith.extsi %1566 : i32 to i64
%1562 = func.call @calloc(%1564, %1567) : (i64, i64) -> !llvm.ptr
%1568 = arith.constant 0 : i32
%1569 = arith.extsi %1568 : i32 to i64
%1570 = llvm.mlir.constant(1 : i64) : i64
%1571 = llvm.alloca %1570 x i64 : (i64) -> !llvm.ptr
llvm.store %1569, %1571 : i64, !llvm.ptr
%1572 = arith.constant 2 : i32
%1573 = arith.extsi %1572 : i32 to i64
%1574 = llvm.mlir.constant(1 : i64) : i64
%1575 = llvm.alloca %1574 x i64 : (i64) -> !llvm.ptr
llvm.store %1573, %1575 : i64, !llvm.ptr
cf.br ^bb255
^bb255:
%1576 = llvm.load %1575 : !llvm.ptr -> i64
%1577 = arith.cmpi sle, %1576, %arg0 : i64
cf.cond_br %1577, ^bb256, ^bb257
^bb256:
%1579 = llvm.load %1575 : !llvm.ptr -> i64
%1580 = llvm.getelementptr %1562[%1579] : (!llvm.ptr, i64) -> !llvm.ptr, i8
%1578 = llvm.load %1580 : !llvm.ptr -> i8
%1581 = arith.constant 0 : i32
%1583 = arith.extsi %1578 : i8 to i32
%1582 = arith.cmpi eq, %1583, %1581 : i32
cf.cond_br %1582, ^bb258, ^bb259
^bb258:
%1584 = llvm.load %1575 : !llvm.ptr -> i64
%1585 = llvm.load %1571 : !llvm.ptr -> i64
%1586 = llvm.getelementptr %arg1[%1585] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %1584, %1586 : i64, !llvm.ptr
%1587 = llvm.load %1571 : !llvm.ptr -> i64
%1588 = arith.constant 1 : i32
%1590 = arith.extsi %1588 : i32 to i64
%1589 = arith.addi %1587, %1590 : i64
llvm.store %1589, %1571 : i64, !llvm.ptr
%1591 = llvm.load %1575 : !llvm.ptr -> i64
%1592 = llvm.load %1575 : !llvm.ptr -> i64
%1593 = arith.muli %1591, %1592 : i64
%1594 = llvm.mlir.constant(1 : i64) : i64
%1595 = llvm.alloca %1594 x i64 : (i64) -> !llvm.ptr
llvm.store %1593, %1595 : i64, !llvm.ptr
cf.br ^bb261
^bb261:
%1596 = llvm.load %1595 : !llvm.ptr -> i64
%1597 = arith.cmpi sle, %1596, %arg0 : i64
cf.cond_br %1597, ^bb262, ^bb263
^bb262:
%1598 = arith.constant 1 : i32
%1599 = llvm.load %1595 : !llvm.ptr -> i64
%1600 = arith.trunci %1598 : i32 to i8
%1601 = llvm.getelementptr %1562[%1599] : (!llvm.ptr, i64) -> !llvm.ptr, i8
llvm.store %1600, %1601 : i8, !llvm.ptr
%1602 = llvm.load %1595 : !llvm.ptr -> i64
%1603 = llvm.load %1575 : !llvm.ptr -> i64
%1604 = arith.addi %1602, %1603 : i64
llvm.store %1604, %1595 : i64, !llvm.ptr
cf.br ^bb261
^bb263:
cf.br ^bb260
^bb259:
cf.br ^bb260
^bb260:
%1605 = llvm.load %1575 : !llvm.ptr -> i64
%1606 = arith.constant 1 : i32
%1608 = arith.extsi %1606 : i32 to i64
%1607 = arith.addi %1605, %1608 : i64
llvm.store %1607, %1575 : i64, !llvm.ptr
cf.br ^bb255
^bb257:
func.call @free(%1562) : (!llvm.ptr) -> ()
%1610 = llvm.load %1571 : !llvm.ptr -> i64
func.return %1610 : i64
}
func.func @next_prime_after(%arg0: i64) -> i64 {
%1611 = arith.constant 1 : i32
%1613 = arith.extsi %1611 : i32 to i64
%1612 = arith.addi %arg0, %1613 : i64
%1614 = llvm.mlir.constant(1 : i64) : i64
%1615 = llvm.alloca %1614 x i64 : (i64) -> !llvm.ptr
llvm.store %1612, %1615 : i64, !llvm.ptr
%1616 = llvm.load %1615 : !llvm.ptr -> i64
%1617 = arith.constant 2 : i32
%1619 = arith.extsi %1617 : i32 to i64
%1618 = arith.remsi %1616, %1619 : i64
%1620 = arith.constant 0 : i32
%1622 = arith.extsi %1620 : i32 to i64
%1621 = arith.cmpi eq, %1618, %1622 : i64
cf.cond_br %1621, ^bb264, ^bb265
^bb264:
%1623 = llvm.load %1615 : !llvm.ptr -> i64
%1624 = arith.constant 1 : i32
%1626 = arith.extsi %1624 : i32 to i64
%1625 = arith.addi %1623, %1626 : i64
llvm.store %1625, %1615 : i64, !llvm.ptr
cf.br ^bb266
^bb265:
cf.br ^bb266
^bb266:
cf.br ^bb267
^bb267:
%1628 = llvm.load %1615 : !llvm.ptr -> i64
%1627 = func.call @is_prime(%1628) : (i64) -> i32
%1629 = arith.constant 0 : i32
%1630 = arith.cmpi eq, %1627, %1629 : i32
cf.cond_br %1630, ^bb268, ^bb269
^bb268:
%1631 = llvm.load %1615 : !llvm.ptr -> i64
%1632 = arith.constant 2 : i32
%1634 = arith.extsi %1632 : i32 to i64
%1633 = arith.addi %1631, %1634 : i64
llvm.store %1633, %1615 : i64, !llvm.ptr
cf.br ^bb267
^bb269:
%1635 = llvm.load %1615 : !llvm.ptr -> i64
func.return %1635 : i64
}
func.func @precompute_roots(%arg0: i64) -> () {
%1637 = arith.constant 20000 : i32
%1638 = arith.constant 8 : i32
%1639 = arith.muli %1637, %1638 : i32
%1640 = arith.extsi %1639 : i32 to i64
%1636 = func.call @malloc(%1640) : (i64) -> !llvm.ptr
%1641 = func.call @sieve_primes(%arg0, %1636) : (i64, !llvm.ptr) -> i64
%1643 = arith.constant 16384 : i32
%1644 = arith.constant 24 : i32
%1645 = arith.muli %1643, %1644 : i32
%1646 = arith.extsi %1645 : i32 to i64
%1642 = func.call @malloc(%1646) : (i64) -> !llvm.ptr
%1647 = llvm.mlir.addressof @g_roots : !llvm.ptr
llvm.store %1642, %1647 : !llvm.ptr, !llvm.ptr
%1648 = arith.constant 0 : i32
%1649 = arith.extsi %1648 : i32 to i64
%1650 = llvm.mlir.addressof @g_n_roots : !llvm.ptr
llvm.store %1649, %1650 : i64, !llvm.ptr
%1651 = arith.constant 0 : i32
%1652 = arith.extsi %1651 : i32 to i64
%1653 = llvm.mlir.constant(1 : i64) : i64
%1654 = llvm.alloca %1653 x i64 : (i64) -> !llvm.ptr
llvm.store %1652, %1654 : i64, !llvm.ptr
cf.br ^bb270
^bb270:
%1655 = llvm.load %1654 : !llvm.ptr -> i64
%1656 = arith.cmpi slt, %1655, %1641 : i64
cf.cond_br %1656, ^bb271, ^bb272
^bb271:
%1658 = llvm.load %1654 : !llvm.ptr -> i64
%1659 = llvm.getelementptr %1636[%1658] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%1657 = llvm.load %1659 : !llvm.ptr -> i64
%1660 = arith.constant 4 : i32
%1662 = arith.extsi %1660 : i32 to i64
%1661 = arith.remsi %1657, %1662 : i64
%1663 = arith.constant 1 : i32
%1665 = arith.extsi %1663 : i32 to i64
%1664 = arith.cmpi ne, %1661, %1665 : i64
cf.cond_br %1664, ^bb273, ^bb274
^bb273:
%1666 = llvm.load %1654 : !llvm.ptr -> i64
%1667 = arith.constant 1 : i32
%1669 = arith.extsi %1667 : i32 to i64
%1668 = arith.addi %1666, %1669 : i64
llvm.store %1668, %1654 : i64, !llvm.ptr
cf.br ^bb270
^bb274:
cf.br ^bb275
^bb275:
%1670 = func.call @sqrt_neg1_mod_p(%1657) : (i64) -> i64
%1672 = arith.constant 6 : i32
%1673 = arith.constant 2 : i32
%1675 = arith.extsi %1673 : i32 to i64
%1674 = arith.subi %1657, %1675 : i64
%1676 = arith.extsi %1672 : i32 to i64
%1671 = func.call @powmod(%1676, %1674, %1657) : (i64, i64, i64) -> i64
%1677 = llvm.mlir.addressof @g_roots : !llvm.ptr
%1678 = llvm.load %1677 : !llvm.ptr -> !llvm.ptr
%1679 = llvm.mlir.addressof @g_n_roots : !llvm.ptr
%1680 = llvm.load %1679 : !llvm.ptr -> i64
%1681 = llvm.getelementptr %1678[%1680] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64, i64, i64)>
%1682 = llvm.getelementptr %1681[0, 0] : (!llvm.ptr) -> !llvm.ptr, !llvm.struct<(i64, i64, i64)>
llvm.store %1657, %1682 : i64, !llvm.ptr
%1683 = arith.constant 1 : i32
%1685 = arith.extsi %1683 : i32 to i64
%1684 = arith.addi %1685, %1670 : i64
%1686 = arith.muli %1684, %1671 : i64
%1687 = arith.remsi %1686, %1657 : i64
%1688 = llvm.mlir.addressof @g_roots : !llvm.ptr
%1689 = llvm.load %1688 : !llvm.ptr -> !llvm.ptr
%1690 = llvm.mlir.addressof @g_n_roots : !llvm.ptr
%1691 = llvm.load %1690 : !llvm.ptr -> i64
%1692 = llvm.getelementptr %1689[%1691] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64, i64, i64)>
%1693 = llvm.getelementptr %1692[0, 1] : (!llvm.ptr) -> !llvm.ptr, !llvm.struct<(i64, i64, i64)>
llvm.store %1687, %1693 : i64, !llvm.ptr
%1694 = arith.constant 1 : i32
%1696 = arith.extsi %1694 : i32 to i64
%1695 = arith.addi %1696, %1657 : i64
%1697 = arith.subi %1695, %1670 : i64
%1698 = arith.muli %1697, %1671 : i64
%1699 = arith.remsi %1698, %1657 : i64
%1700 = llvm.mlir.addressof @g_roots : !llvm.ptr
%1701 = llvm.load %1700 : !llvm.ptr -> !llvm.ptr
%1702 = llvm.mlir.addressof @g_n_roots : !llvm.ptr
%1703 = llvm.load %1702 : !llvm.ptr -> i64
%1704 = llvm.getelementptr %1701[%1703] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64, i64, i64)>
%1705 = llvm.getelementptr %1704[0, 2] : (!llvm.ptr) -> !llvm.ptr, !llvm.struct<(i64, i64, i64)>
llvm.store %1699, %1705 : i64, !llvm.ptr
%1706 = llvm.mlir.addressof @g_n_roots : !llvm.ptr
%1707 = llvm.load %1706 : !llvm.ptr -> i64
%1708 = arith.constant 1 : i32
%1710 = arith.extsi %1708 : i32 to i64
%1709 = arith.addi %1707, %1710 : i64
%1711 = llvm.mlir.addressof @g_n_roots : !llvm.ptr
llvm.store %1709, %1711 : i64, !llvm.ptr
%1712 = llvm.load %1654 : !llvm.ptr -> i64
%1713 = arith.constant 1 : i32
%1715 = arith.extsi %1713 : i32 to i64
%1714 = arith.addi %1712, %1715 : i64
llvm.store %1714, %1654 : i64, !llvm.ptr
cf.br ^bb270
^bb272:
%1716 = func.call @next_prime_after(%arg0) : (i64) -> i64
%1717 = llvm.mlir.addressof @g_next_prime : !llvm.ptr
llvm.store %1716, %1717 : i64, !llvm.ptr
func.call @free(%1636) : (!llvm.ptr) -> ()
func.return
}
func.func @upper_factor_multiplier(%arg0: i64, %arg1: i64) -> i64 {
%1719 = arith.constant 1 : i32
%1721 = arith.extsi %1719 : i32 to i64
%1720 = arith.cmpi sle, %arg0, %1721 : i64
cf.cond_br %1720, ^bb276, ^bb277
^bb276:
%1722 = arith.constant 1 : i32
%1723 = arith.extsi %1722 : i32 to i64
func.return %1723 : i64
^bb277:
cf.br ^bb278
^bb278:
%1724 = arith.constant 0 : i32
%1725 = arith.extsi %1724 : i32 to i64
%1726 = llvm.mlir.constant(1 : i64) : i64
%1727 = llvm.alloca %1726 x i64 : (i64) -> !llvm.ptr
llvm.store %1725, %1727 : i64, !llvm.ptr
%1728 = arith.extsi %arg1 : i64 to i128
%1729 = llvm.mlir.constant(1 : i64) : i64
%1730 = llvm.alloca %1729 x i128 : (i64) -> !llvm.ptr
llvm.store %1728, %1730 : i128, !llvm.ptr
cf.br ^bb279
^bb279:
%1731 = llvm.load %1730 : !llvm.ptr -> i128
%1732 = arith.extsi %arg0 : i64 to i128
%1734 = arith.trunci %1731 : i128 to i64
%1735 = arith.trunci %1732 : i128 to i64
%1733 = arith.cmpi sle, %1734, %1735 : i64
cf.cond_br %1733, ^bb280, ^bb281
^bb280:
%1736 = llvm.load %1730 : !llvm.ptr -> i128
%1737 = arith.extsi %arg1 : i64 to i128
%1739 = arith.trunci %1736 : i128 to i64
%1740 = arith.trunci %1737 : i128 to i64
%1738 = arith.muli %1739, %1740 : i64
%1741 = arith.extsi %1738 : i64 to i128
llvm.store %1741, %1730 : i128, !llvm.ptr
%1742 = llvm.load %1727 : !llvm.ptr -> i64
%1743 = arith.constant 1 : i32
%1745 = arith.extsi %1743 : i32 to i64
%1744 = arith.addi %1742, %1745 : i64
llvm.store %1744, %1727 : i64, !llvm.ptr
cf.br ^bb279
^bb281:
%1746 = arith.constant 1 : i32
%1747 = llvm.load %1727 : !llvm.ptr -> i64
%1749 = arith.extsi %1746 : i32 to i64
%1748 = arith.shli %1749, %1747 : i64
func.return %1748 : i64
}
func.func @find_answer(%arg0: i64, %arg1: i64) -> i64 {
func.call @precompute_roots(%arg1) : (i64) -> ()
%1752 = arith.constant 8 : i32
%1754 = arith.extsi %1752 : i32 to i64
%1753 = arith.muli %arg0, %1754 : i64
%1751 = func.call @malloc(%1753) : (i64) -> !llvm.ptr
%1756 = arith.constant 8 : i32
%1758 = arith.extsi %1756 : i32 to i64
%1757 = arith.muli %arg0, %1758 : i64
%1755 = func.call @malloc(%1757) : (i64) -> !llvm.ptr
%1759 = arith.constant 1 : i32
%1760 = arith.extsi %1759 : i32 to i64
%1761 = llvm.mlir.constant(1 : i64) : i64
%1762 = llvm.alloca %1761 x i64 : (i64) -> !llvm.ptr
llvm.store %1760, %1762 : i64, !llvm.ptr
cf.br ^bb282
^bb282:
%1763 = arith.constant 1 : i1
cf.cond_br %1763, ^bb283, ^bb284
^bb283:
%1764 = arith.constant 6 : i32
%1765 = llvm.load %1762 : !llvm.ptr -> i64
%1767 = arith.extsi %1764 : i32 to i64
%1766 = arith.muli %1767, %1765 : i64
%1768 = arith.constant 1 : i32
%1770 = arith.extsi %1768 : i32 to i64
%1769 = arith.subi %1766, %1770 : i64
%1771 = llvm.mlir.constant(1 : i64) : i64
%1772 = llvm.alloca %1771 x i64 : (i64) -> !llvm.ptr
llvm.store %1769, %1772 : i64, !llvm.ptr
%1773 = llvm.load %1772 : !llvm.ptr -> i64
%1774 = llvm.load %1772 : !llvm.ptr -> i64
%1775 = arith.muli %1773, %1774 : i64
%1776 = arith.constant 1 : i32
%1778 = arith.extsi %1776 : i32 to i64
%1777 = arith.addi %1775, %1778 : i64
%1779 = llvm.mlir.constant(1 : i64) : i64
%1780 = llvm.alloca %1779 x i64 : (i64) -> !llvm.ptr
llvm.store %1777, %1780 : i64, !llvm.ptr
%1781 = arith.constant 0 : i32
%1782 = arith.index_cast %1781 : i32 to index
%1783 = arith.index_cast %arg0 : i32 to index
%1785 = arith.constant 1 : index
%1786 = arith.constant -1 : index
%1787 = arith.cmpi sle, %1782, %1783 : index
%1784 = arith.select %1787, %1785, %1786 : index
cf.br ^bb285(%1782 : index)
^bb285(%1788: index):
%1789 = arith.cmpi slt, %1788, %1783 : index
%1790 = arith.cmpi sgt, %1788, %1783 : index
%1791 = arith.select %1787, %1789, %1790 : i1
cf.cond_br %1791, ^bb286(%1788 : index), ^bb287(%1788 : index)
^bb286(%1792: index):
%1793 = llvm.load %1780 : !llvm.ptr -> i64
%1794 = arith.constant 2 : i32
%1796 = arith.extsi %1794 : i32 to i64
%1795 = arith.divsi %1793, %1796 : i64
%1797 = arith.index_cast %1792 : index to i64
%1798 = llvm.getelementptr %1751[%1797] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %1795, %1798 : i64, !llvm.ptr
%1799 = arith.constant 1 : i32
%1800 = arith.extsi %1799 : i32 to i64
%1801 = arith.index_cast %1792 : index to i64
%1802 = llvm.getelementptr %1755[%1801] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %1800, %1802 : i64, !llvm.ptr
%1803 = llvm.load %1772 : !llvm.ptr -> i64
%1804 = arith.constant 6 : i32
%1806 = arith.extsi %1804 : i32 to i64
%1805 = arith.addi %1803, %1806 : i64
llvm.store %1805, %1772 : i64, !llvm.ptr
%1807 = llvm.load %1772 : !llvm.ptr -> i64
%1808 = llvm.load %1772 : !llvm.ptr -> i64
%1809 = arith.muli %1807, %1808 : i64
%1810 = arith.constant 1 : i32
%1812 = arith.extsi %1810 : i32 to i64
%1811 = arith.addi %1809, %1812 : i64
llvm.store %1811, %1780 : i64, !llvm.ptr
%1813 = arith.addi %1792, %1784 : index
cf.br ^bb285(%1813 : index)
^bb287(%1814: index):
%1815 = arith.constant 0 : i32
%1816 = arith.extsi %1815 : i32 to i64
%1817 = llvm.mlir.constant(1 : i64) : i64
%1818 = llvm.alloca %1817 x i64 : (i64) -> !llvm.ptr
llvm.store %1816, %1818 : i64, !llvm.ptr
cf.br ^bb288
^bb288:
%1819 = llvm.load %1818 : !llvm.ptr -> i64
%1820 = llvm.mlir.addressof @g_n_roots : !llvm.ptr
%1821 = llvm.load %1820 : !llvm.ptr -> i64
%1822 = arith.cmpi slt, %1819, %1821 : i64
cf.cond_br %1822, ^bb289, ^bb290
^bb289:
%1824 = llvm.mlir.addressof @g_roots : !llvm.ptr
%1825 = llvm.load %1824 : !llvm.ptr -> !llvm.ptr
%1826 = llvm.load %1818 : !llvm.ptr -> i64
%1827 = llvm.getelementptr %1825[%1826] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64, i64, i64)>
%1823 = llvm.load %1827 : !llvm.ptr -> !llvm.struct<(i64, i64, i64)>
%1828 = llvm.mlir.addressof @g_roots : !llvm.ptr
%1829 = llvm.load %1828 : !llvm.ptr -> !llvm.ptr
%1830 = llvm.load %1818 : !llvm.ptr -> i64
%1831 = llvm.getelementptr %1829[%1830] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64, i64, i64)>
%1832 = llvm.getelementptr %1831[0, 0] : (!llvm.ptr) -> !llvm.ptr, !llvm.struct<(i64, i64, i64)>
%1833 = llvm.load %1832 : !llvm.ptr -> i64
%1834 = llvm.load %1762 : !llvm.ptr -> i64
%1835 = arith.remsi %1834, %1833 : i64
%1836 = arith.constant 0 : i32
%1837 = arith.extsi %1836 : i32 to i64
%1838 = llvm.mlir.constant(1 : i64) : i64
%1839 = llvm.alloca %1838 x i64 : (i64) -> !llvm.ptr
llvm.store %1837, %1839 : i64, !llvm.ptr
cf.br ^bb291
^bb291:
%1840 = llvm.load %1839 : !llvm.ptr -> i64
%1841 = arith.constant 2 : i32
%1843 = arith.extsi %1841 : i32 to i64
%1842 = arith.cmpi slt, %1840, %1843 : i64
cf.cond_br %1842, ^bb292, ^bb293
^bb292:
%1844 = arith.constant 0 : i32
%1845 = arith.extsi %1844 : i32 to i64
%1846 = llvm.load %1839 : !llvm.ptr -> i64
%1847 = arith.constant 0 : i32
%1849 = arith.extsi %1847 : i32 to i64
%1848 = arith.cmpi eq, %1846, %1849 : i64
%1850 = scf.if %1848 -> (i64) {
%1852 = llvm.mlir.addressof @g_roots : !llvm.ptr
%1853 = llvm.load %1852 : !llvm.ptr -> !llvm.ptr
%1854 = llvm.load %1818 : !llvm.ptr -> i64
%1855 = llvm.getelementptr %1853[%1854] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64, i64, i64)>
%1851 = llvm.load %1855 : !llvm.ptr -> !llvm.struct<(i64, i64, i64)>
%1856 = llvm.mlir.addressof @g_roots : !llvm.ptr
%1857 = llvm.load %1856 : !llvm.ptr -> !llvm.ptr
%1858 = llvm.load %1818 : !llvm.ptr -> i64
%1859 = llvm.getelementptr %1857[%1858] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64, i64, i64)>
%1860 = llvm.getelementptr %1859[0, 1] : (!llvm.ptr) -> !llvm.ptr, !llvm.struct<(i64, i64, i64)>
%1861 = llvm.load %1860 : !llvm.ptr -> i64
scf.yield %1861 : i64
} else {
%1863 = llvm.mlir.addressof @g_roots : !llvm.ptr
%1864 = llvm.load %1863 : !llvm.ptr -> !llvm.ptr
%1865 = llvm.load %1818 : !llvm.ptr -> i64
%1866 = llvm.getelementptr %1864[%1865] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64, i64, i64)>
%1862 = llvm.load %1866 : !llvm.ptr -> !llvm.struct<(i64, i64, i64)>
%1867 = llvm.mlir.addressof @g_roots : !llvm.ptr
%1868 = llvm.load %1867 : !llvm.ptr -> !llvm.ptr
%1869 = llvm.load %1818 : !llvm.ptr -> i64
%1870 = llvm.getelementptr %1868[%1869] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64, i64, i64)>
%1871 = llvm.getelementptr %1870[0, 2] : (!llvm.ptr) -> !llvm.ptr, !llvm.struct<(i64, i64, i64)>
%1872 = llvm.load %1871 : !llvm.ptr -> i64
scf.yield %1872 : i64
}
%1873 = arith.addi %1850, %1833 : i64
%1874 = arith.subi %1873, %1835 : i64
%1875 = arith.remsi %1874, %1833 : i64
%1876 = llvm.mlir.constant(1 : i64) : i64
%1877 = llvm.alloca %1876 x i64 : (i64) -> !llvm.ptr
llvm.store %1875, %1877 : i64, !llvm.ptr
cf.br ^bb294
^bb294:
%1878 = llvm.load %1877 : !llvm.ptr -> i64
%1879 = arith.cmpi slt, %1878, %arg0 : i64
cf.cond_br %1879, ^bb295, ^bb296
^bb295:
%1881 = llvm.load %1877 : !llvm.ptr -> i64
%1882 = llvm.getelementptr %1751[%1881] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%1880 = llvm.load %1882 : !llvm.ptr -> i64
%1883 = arith.remsi %1880, %1833 : i64
%1884 = arith.constant 0 : i32
%1886 = arith.extsi %1884 : i32 to i64
%1885 = arith.cmpi eq, %1883, %1886 : i64
cf.cond_br %1885, ^bb297, ^bb298
^bb297:
%1887 = llvm.mlir.constant(1 : i64) : i64
%1888 = llvm.alloca %1887 x i64 : (i64) -> !llvm.ptr
llvm.store %1880, %1888 : i64, !llvm.ptr
%1889 = arith.constant 0 : i32
%1890 = arith.extsi %1889 : i32 to i64
%1891 = llvm.mlir.constant(1 : i64) : i64
%1892 = llvm.alloca %1891 x i64 : (i64) -> !llvm.ptr
llvm.store %1890, %1892 : i64, !llvm.ptr
cf.br ^bb300
^bb300:
%1893 = llvm.load %1888 : !llvm.ptr -> i64
%1894 = arith.remsi %1893, %1833 : i64
%1895 = arith.constant 0 : i32
%1897 = arith.extsi %1895 : i32 to i64
%1896 = arith.cmpi eq, %1894, %1897 : i64
cf.cond_br %1896, ^bb301, ^bb302
^bb301:
%1898 = llvm.load %1888 : !llvm.ptr -> i64
%1899 = arith.divsi %1898, %1833 : i64
llvm.store %1899, %1888 : i64, !llvm.ptr
%1900 = llvm.load %1892 : !llvm.ptr -> i64
%1901 = arith.constant 1 : i32
%1903 = arith.extsi %1901 : i32 to i64
%1902 = arith.addi %1900, %1903 : i64
llvm.store %1902, %1892 : i64, !llvm.ptr
cf.br ^bb300
^bb302:
%1904 = llvm.load %1888 : !llvm.ptr -> i64
%1905 = llvm.load %1877 : !llvm.ptr -> i64
%1906 = llvm.getelementptr %1751[%1905] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %1904, %1906 : i64, !llvm.ptr
%1908 = llvm.load %1877 : !llvm.ptr -> i64
%1909 = llvm.getelementptr %1755[%1908] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%1907 = llvm.load %1909 : !llvm.ptr -> i64
%1910 = llvm.load %1892 : !llvm.ptr -> i64
%1911 = arith.constant 1 : i32
%1913 = arith.extsi %1911 : i32 to i64
%1912 = arith.addi %1910, %1913 : i64
%1914 = arith.muli %1907, %1912 : i64
%1915 = llvm.load %1877 : !llvm.ptr -> i64
%1916 = llvm.getelementptr %1755[%1915] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %1914, %1916 : i64, !llvm.ptr
cf.br ^bb299
^bb298:
cf.br ^bb299
^bb299:
%1917 = llvm.load %1877 : !llvm.ptr -> i64
%1918 = arith.addi %1917, %1833 : i64
llvm.store %1918, %1877 : i64, !llvm.ptr
cf.br ^bb294
^bb296:
%1919 = llvm.load %1839 : !llvm.ptr -> i64
%1920 = arith.constant 1 : i32
%1922 = arith.extsi %1920 : i32 to i64
%1921 = arith.addi %1919, %1922 : i64
llvm.store %1921, %1839 : i64, !llvm.ptr
cf.br ^bb291
^bb293:
%1923 = llvm.load %1818 : !llvm.ptr -> i64
%1924 = arith.constant 1 : i32
%1926 = arith.extsi %1924 : i32 to i64
%1925 = arith.addi %1923, %1926 : i64
llvm.store %1925, %1818 : i64, !llvm.ptr
cf.br ^bb288
^bb290:
%1927 = arith.constant 0 : i32
%1928 = arith.index_cast %1927 : i32 to index
%1929 = arith.index_cast %arg0 : i32 to index
%1931 = arith.constant 1 : index
%1932 = arith.constant -1 : index
%1933 = arith.cmpi sle, %1928, %1929 : index
%1930 = arith.select %1933, %1931, %1932 : index
cf.br ^bb303(%1928 : index)
^bb303(%1934: index):
%1935 = arith.cmpi slt, %1934, %1929 : index
%1936 = arith.cmpi sgt, %1934, %1929 : index
%1937 = arith.select %1933, %1935, %1936 : i1
cf.cond_br %1937, ^bb304(%1934 : index), ^bb305(%1934 : index)
^bb304(%1938: index):
%1940 = arith.index_cast %1938 : index to i64
%1941 = llvm.getelementptr %1755[%1940] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%1939 = llvm.load %1941 : !llvm.ptr -> i64
%1943 = arith.index_cast %1938 : index to i64
%1944 = llvm.getelementptr %1751[%1943] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%1942 = llvm.load %1944 : !llvm.ptr -> i64
%1946 = llvm.mlir.addressof @g_next_prime : !llvm.ptr
%1947 = llvm.load %1946 : !llvm.ptr -> i64
%1945 = func.call @upper_factor_multiplier(%1942, %1947) : (i64, i64) -> i64
%1948 = arith.muli %1939, %1945 : i64
%1949 = arith.constant 202 : i32
%1951 = arith.extsi %1949 : i32 to i64
%1950 = arith.cmpi slt, %1948, %1951 : i64
cf.cond_br %1950, ^bb306, ^bb307
^bb306:
%1952 = arith.addi %1938, %1930 : index
cf.br ^bb303(%1952 : index)
^bb307:
cf.br ^bb308
^bb308:
%1953 = llvm.load %1762 : !llvm.ptr -> i64
%1955 = arith.trunci %1953 : i64 to i32
%1956 = arith.index_cast %1938 : index to i32
%1954 = arith.addi %1955, %1956 : i32
%1957 = arith.extsi %1954 : i32 to i64
%1958 = func.call @count_pentagonal_sum_ways(%1957) : (i64) -> i32
%1959 = arith.constant 100 : i32
%1960 = arith.cmpi sgt, %1958, %1959 : i32
cf.cond_br %1960, ^bb309, ^bb310
^bb309:
func.call @free(%1751) : (!llvm.ptr) -> ()
func.call @free(%1755) : (!llvm.ptr) -> ()
%1963 = arith.constant 3 : i32
%1965 = arith.extsi %1963 : i32 to i64
%1964 = arith.muli %1965, %1957 : i64
%1966 = arith.constant 1 : i32
%1968 = arith.extsi %1966 : i32 to i64
%1967 = arith.subi %1964, %1968 : i64
%1969 = arith.muli %1957, %1967 : i64
%1970 = arith.constant 2 : i32
%1972 = arith.extsi %1970 : i32 to i64
%1971 = arith.divsi %1969, %1972 : i64
func.return %1971 : i64
^bb310:
cf.br ^bb311
^bb311:
%1973 = arith.addi %1938, %1930 : index
cf.br ^bb303(%1973 : index)
^bb305(%1974: index):
%1975 = llvm.load %1762 : !llvm.ptr -> i64
%1976 = arith.addi %1975, %arg0 : i64
llvm.store %1976, %1762 : i64, !llvm.ptr
cf.br ^bb282
^bb284:
%1977 = arith.constant 0 : i32
%1978 = arith.extsi %1977 : i32 to i64
func.return %1978 : i64
}
func.func @main() -> i32 {
%1979 = llvm.mlir.addressof @str_0 : !llvm.ptr
%1981 = arith.constant 50000 : i32
%1982 = arith.constant 200000 : i32
%1983 = arith.extsi %1981 : i32 to i64
%1984 = arith.extsi %1982 : i32 to i64
%1980 = func.call @find_answer(%1983, %1984) : (i64, i64) -> i64
%1985 = llvm.call @printf(%1979, %1980) vararg(!llvm.func<i32 (ptr, ...)>) : (!llvm.ptr, i64) -> i32
%1986 = arith.constant 0 : i32
func.return %1986 : i32
}
}