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