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