Problem 636

Counts representations of n! of the form: a^1 * b1^2 * b2^2 * c1^3 * c2^3 * c3^3 * d1^4 * d2^4 * d3^4 * d4^4 with pairwise distinct bases. Uses inclusion-exclusion over set partitions of 10 slots, coin-change DP for small exponents, and polynomial quotient-ring recurrence for large exponents. Ported from C, uses i128 modular arithmetic.

Answer888316
Output888316
StatusPASS
Native helperno
Runtime960 ms
Peak memory4496 KB
Time complexityO(n^2) (estimated)
Space complexityO(n^2) (estimated)

Performance comparison

MetricOur solutionBest known
Time complexityO(n^2)O(1)
Space complexityO(n^2)O(1)
ApproachFlow solutionClosed-form formula
VerdictSuboptimal

Flow source

# Project Euler 636 - Restricted Factorisations
# Counts representations of n! of the form:
#   a^1 * b1^2 * b2^2 * c1^3 * c2^3 * c3^3 * d1^4 * d2^4 * d3^4 * d4^4
# with pairwise distinct bases. Uses inclusion-exclusion over set partitions
# of 10 slots, coin-change DP for small exponents, and polynomial quotient-ring
# recurrence for large exponents. Ported from C, uses i128 modular arithmetic.

extern {
    function calloc(n: i64, size: i64) -> ptr<void>
    function free(p: ptr<void>)
    function printf(fmt: ptr<i8>, ...) -> i32
    function memset(s: ptr<void>, c: i32, n: i64) -> ptr<void>
    function memcpy(dst: ptr<void>, src: ptr<void>, n: i64) -> ptr<void>
}

const MOD: i64 = 1000000007
const D: i32 = 30
const NSLOTS: i32 = 10
const MAXBIT: i32 = 20
const MAX_KEYS: i32 = 60000
const MAX_KEY_LEN: i32 = 10

function mod_add(a: i64, b: i64) -> i64 {
    let r: i64 = a + b
    if r >= MOD { r = r - MOD }
    return r
}

function mod_sub(a: i64, b: i64) -> i64 {
    let r: i64 = a - b
    if r < 0 { r = r + MOD }
    return r
}

function mod_mul(a: i64, b: i64) -> i64 {
    return (((a as i128) * (b as i128)) % (MOD as i128)) as i64
}

function mod_pow(a: i64, e: i64) -> i64 {
    let mut r: i64 = 1
    let mut aa: i64 = a % MOD
    if aa < 0 { aa = aa + MOD }
    let mut ee: i64 = e
    while ee > 0 {
        if (ee & 1) == 1 { r = mod_mul(r, aa) }
        aa = mod_mul(aa, aa)
        ee = ee >> 1
    }
    return r
}

# Slot weights: {1,2,2,3,3,3,4,4,4,4}
function slot_weight(i: i32) -> i32 {
    if i == 0 { return 1 }
    if i == 1 { return 2 }
    if i == 2 { return 2 }
    if i == 3 { return 3 }
    if i == 4 { return 3 }
    if i == 5 { return 3 }
    return 4
}

# Global partition state
let mut g_keys: ptr<i64> = null  # flat MAX_KEYS * MAX_KEY_LEN
let mut g_key_lens: ptr<i32> = null
let mut g_coeffs: ptr<i64> = null
let mut g_nkeys: i32 = 0
let mut g_block_members: ptr<i32> = null  # flat 10*10
let mut g_block_sizes: ptr<i32> = null
let mut g_n_blocks: i32 = 0

function factorial_small(n: i32) -> i32 {
    let mut r: i32 = 1
    let mut i: i32 = 2
    while i <= n { r = r * i; i = i + 1 }
    return r
}

function process_partition() -> void {
    let mut mu: i64 = 1
    let sums: ptr<i32> = calloc(10, 4)
    let mut ns: i32 = 0
    let mut b: i32 = 0
    while b < g_n_blocks {
        let bs: i32 = g_block_sizes[b]
        let mut s: i32 = 0
        let mut m: i32 = 0
        while m < bs {
            s = s + slot_weight(g_block_members[b * 10 + m])
            m = m + 1
        }
        sums[ns] = s
        ns = ns + 1
        let sign: i64 = if (bs - 1) % 2 == 0 { 1 } else { -1 }
        mu = mu * sign * ((factorial_small(bs - 1)) as i64)
        b = b + 1
    }
    # insertion sort
    let mut i: i32 = 1
    while i < ns {
        let v: i32 = sums[i]
        let mut j: i32 = i - 1
        while j >= 0 && sums[j] > v { sums[j + 1] = sums[j]; j = j - 1 }
        sums[j + 1] = v
        i = i + 1
    }
    # find or insert key
    let mut found: i32 = -1
    let mut k: i32 = 0
    while k < g_nkeys {
        if g_key_lens[k] != ns { k = k + 1; continue }
        let mut is_match: i32 = 1
        let mut j: i32 = 0
        while j < ns {
            if g_keys[k * MAX_KEY_LEN + j] != (sums[j] as i64) { is_match = 0; break }
            j = j + 1
        }
        if is_match == 1 { found = k; break }
        k = k + 1
    }
    if found >= 0 {
        g_coeffs[found] = g_coeffs[found] + mu
    } else {
        let k2: i32 = g_nkeys
        g_nkeys = g_nkeys + 1
        g_key_lens[k2] = ns
        let mut j2: i32 = 0
        while j2 < ns { g_keys[k2 * MAX_KEY_LEN + j2] = sums[j2] as i64; j2 = j2 + 1 }
        g_coeffs[k2] = mu
    }
    free(sums as ptr<void>)
}

function recurse_partition(i: i32) -> void {
    if i == NSLOTS { process_partition(); return }
    let mut b: i32 = 0
    while b < g_n_blocks {
        g_block_members[b * 10 + g_block_sizes[b]] = i
        g_block_sizes[b] = g_block_sizes[b] + 1
        recurse_partition(i + 1)
        g_block_sizes[b] = g_block_sizes[b] - 1
        b = b + 1
    }
    g_block_members[g_n_blocks * 10 + 0] = i
    g_block_sizes[g_n_blocks] = 1
    g_n_blocks = g_n_blocks + 1
    recurse_partition(i + 1)
    g_n_blocks = g_n_blocks - 1
}

function build_partitions() -> void {
    g_keys = calloc((MAX_KEYS as i64) * (MAX_KEY_LEN as i64), 8)
    g_key_lens = calloc((MAX_KEYS as i64), 4)
    g_coeffs = calloc((MAX_KEYS as i64), 8)
    g_block_members = calloc(100, 4)
    g_block_sizes = calloc(10, 4)
    g_nkeys = 0
    g_n_blocks = 0
    recurse_partition(0)
}

# Prime sieve
function sieve_primes(n: i32, out_count: ptr<i32>) -> ptr<i32> {
    let sieve: ptr<i8> = calloc(((n + 1) as i64), 1)
    let mut count: i32 = 0
    let mut i: i32 = 2
    while i <= n {
        if sieve[i] == 0 {
            count = count + 1
            let mut j: i64 = (i as i64) * (i as i64)
            while j <= (n as i64) {
                sieve[j] = 1
                j = j + (i as i64)
            }
        }
        i = i + 1
    }
    let primes: ptr<i32> = calloc((count as i64), 4)
    let mut idx: i32 = 0
    let mut i2: i32 = 2
    while i2 <= n {
        if sieve[i2] == 0 { primes[idx] = i2; idx = idx + 1 }
        i2 = i2 + 1
    }
    free(sieve as ptr<void>)
    out_count[0] = count
    return primes
}

function factorial_prime_exp(n: i32, p: i32) -> i32 {
    let mut e: i32 = 0
    let mut m: i64 = n as i64
    while m > 0 { m = m / (p as i64); e = e + (m as i32) }
    return e
}

# Coefficients of prod 1/(1-x^w) up to limit
function coeffs_up_to(key: ptr<i64>, klen: i32, limit: i32, dp: ptr<i64>) -> void {
    memset(dp as ptr<void>, 0, ((limit + 1) as i64) * 8)
    dp[0] = 1
    let mut ki: i32 = 0
    while ki < klen {
        let w: i32 = key[ki] as i32
        let mut i: i32 = w
        while i <= limit {
            let v: i64 = dp[i] + dp[i - w]
            if v >= MOD { v = v - MOD }
            dp[i] = v
            i = i + 1
        }
        ki = ki + 1
    }
}

# Q(x) = prod(1 - x^w)
function poly_Q_from_key(key: ptr<i64>, klen: i32, q: ptr<i64>) -> void {
    memset(q as ptr<void>, 0, ((D + 1) as i64) * 8)
    q[0] = 1
    let mut ki: i32 = 0
    while ki < klen {
        let w: i32 = key[ki] as i32
        let mut i: i32 = D - w
        while i >= 0 {
            q[i + w] = q[i + w] - q[i]
            i = i - 1
        }
        ki = ki + 1
    }
}

# Multiply two degree<D polynomials in quotient ring
function mul_mod_poly(a: ptr<i64>, b: ptr<i64>, r: ptr<i64>, out: ptr<i64>) -> void {
    let tmp: ptr<i64> = calloc(((2 * D - 1) as i64), 8)
    let mut i: i32 = 0
    while i < D {
        if a[i] == 0 { i = i + 1; continue }
        let mut j: i32 = 0
        while j < D {
            if b[j] == 0 { j = j + 1; continue }
            tmp[i + j] = mod_add(tmp[i + j], mod_mul(a[i], b[j]))
            j = j + 1
        }
        i = i + 1
    }
    let mut k: i32 = 2 * D - 2
    while k >= D {
        let coef: i64 = tmp[k]
        if coef == 0 { k = k - 1; continue }
        let mut i2: i32 = 0
        while i2 < D {
            let idx: i32 = k - 1 - i2
            tmp[idx] = mod_add(tmp[idx], mod_mul(coef, r[i2]))
            i2 = i2 + 1
        }
        k = k - 1
    }
    memcpy(out as ptr<void>, tmp as ptr<void>, (D as i64) * 8)
    free(tmp as ptr<void>)
}

function precompute_x_powers(r: ptr<i64>, maxbit: i32, pow_polys: ptr<i64>) -> void {
    memset(pow_polys as ptr<void>, 0, ((maxbit * D) as i64) * 8)
    pow_polys[1] = 1  # x^1
    let mut b: i32 = 1
    while b < maxbit {
        mul_mod_poly(pow_polys + ((b - 1) * D), pow_polys + ((b - 1) * D), r, pow_polys + (b * D))
        b = b + 1
    }
}

function poly_x_n(pow_polys: ptr<i64>, n: i64, r: ptr<i64>, out: ptr<i64>) -> void {
    let res: ptr<i64> = calloc((D as i64), 8)
    res[0] = 1
    let tmp: ptr<i64> = calloc((D as i64), 8)
    let mut nn: i64 = n
    let mut bit: i32 = 0
    while nn > 0 {
        if (nn & 1) == 1 {
            memcpy(tmp as ptr<void>, res as ptr<void>, (D as i64) * 8)
            mul_mod_poly(tmp, pow_polys + (bit * D), r, res)
        }
        nn = nn >> 1
        bit = bit + 1
    }
    memcpy(out as ptr<void>, res as ptr<void>, (D as i64) * 8)
    free(res as ptr<void>)
    free(tmp as ptr<void>)
}

function term_from_poly(init: ptr<i64>, poly: ptr<i64>) -> i64 {
    let mut s: i64 = 0
    let mut i: i32 = 0
    while i < D {
        s = mod_add(s, mod_mul(poly[i], init[i]))
        i = i + 1
    }
    return s
}

# Heapsort for i32 array
function heapsort_i32(arr: ptr<i32>, n: i32) -> void {
    let mut start: i32 = (n >> 1) - 1
    while start >= 0 {
        let mut root: i32 = start
        while (root << 1) + 1 < n {
            let child: i32 = (root << 1) + 1
            let mut mx: i32 = child
            if child + 1 < n && arr[child + 1] > arr[child] { mx = child + 1 }
            if arr[root] < arr[mx] {
                let t: i32 = arr[root]; arr[root] = arr[mx]; arr[mx] = t
                root = mx
            } else { break }
        }
        start = start - 1
    }
    let mut end: i32 = n - 1
    while end > 0 {
        let t: i32 = arr[0]; arr[0] = arr[end]; arr[end] = t
        let mut root: i32 = 0
        while (root << 1) + 1 < end {
            let child: i32 = (root << 1) + 1
            let mut mx: i32 = child
            if child + 1 < end && arr[child + 1] > arr[child] { mx = child + 1 }
            if arr[root] < arr[mx] {
                let t2: i32 = arr[root]; arr[root] = arr[mx]; arr[mx] = t2
                root = mx
            } else { break }
        }
        end = end - 1
    }
}

function compute_F(n: i32, cutoff: i32) -> i64 {
    let nprimes_ptr: ptr<i32> = calloc(1, 4)
    let primes: ptr<i32> = sieve_primes(n, nprimes_ptr)
    let nprimes: i32 = nprimes_ptr[0]
    free(nprimes_ptr as ptr<void>)

    let exps: ptr<i32> = calloc((nprimes as i64), 4)
    let mut max_exp: i32 = 0
    let mut i: i32 = 0
    while i < nprimes {
        exps[i] = factorial_prime_exp(n, primes[i])
        if exps[i] > max_exp { max_exp = exps[i] }
        i = i + 1
    }
    heapsort_i32(exps, nprimes)

    # group into (exponent, count) pairs
    let uexp: ptr<i32> = calloc((nprimes as i64), 4)
    let ucnt: ptr<i32> = calloc((nprimes as i64), 4)
    let mut nu: i32 = 0
    let mut i2: i32 = 0
    while i2 < nprimes {
        if nu > 0 && uexp[nu - 1] == exps[i2] {
            ucnt[nu - 1] = ucnt[nu - 1] + 1
        } else {
            uexp[nu] = exps[i2]
            ucnt[nu] = 1
            nu = nu + 1
        }
        i2 = i2 + 1
    }

    let use_cutoff: i32 = if cutoff < max_exp { cutoff } else { max_exp }
    let inv288: i64 = mod_pow(288, MOD - 2)

    let mut has_exp1: i32 = 0
    let mut i3: i32 = 0
    while i3 < nu {
        if uexp[i3] == 1 { has_exp1 = 1; break }
        i3 = i3 + 1
    }

    let dp: ptr<i64> = calloc(((use_cutoff + 1) as i64), 8)
    let large_vals: ptr<i64> = calloc((nu as i64), 8)
    let q: ptr<i64> = calloc(((D + 1) as i64), 8)
    let r: ptr<i64> = calloc((D as i64), 8)
    let init: ptr<i64> = calloc((D as i64), 8)
    let poly_res: ptr<i64> = calloc((D as i64), 8)
    let pow_polys: ptr<i64> = calloc(((MAXBIT * D) as i64), 8)

    let mut total: i64 = 0

    let mut k: i32 = 0
    while k < g_nkeys {
        let klen: i32 = g_key_lens[k]
        let key: ptr<i64> = g_keys + (k * MAX_KEY_LEN)

        if has_exp1 == 1 {
            let mut has1: i32 = 0
            let mut j: i32 = 0
            while j < klen {
                if key[j] == 1 { has1 = 1; break }
                j = j + 1
            }
            if has1 == 0 { k = k + 1; continue }
        }

        coeffs_up_to(key, klen, use_cutoff, dp)

        let mut has_large: i32 = 0
        let mut i4: i32 = 0
        while i4 < nu {
            if uexp[i4] > use_cutoff { has_large = 1; break }
            i4 = i4 + 1
        }

        if has_large == 1 {
            poly_Q_from_key(key, klen, q)
            let mut i5: i32 = 0
            while i5 < D {
                let v: i64 = q[i5 + 1] % MOD
                if v < 0 { v = v + MOD }
                r[i5] = mod_sub(0, v)
                i5 = i5 + 1
            }
            precompute_x_powers(r, MAXBIT, pow_polys)

            let mut i6: i32 = 0
            while i6 < D {
                init[i6] = if i6 <= use_cutoff { dp[i6] } else { 0 }
                i6 = i6 + 1
            }

            let mut i7: i32 = 0
            while i7 < nu {
                if uexp[i7] > use_cutoff {
                    poly_x_n(pow_polys, uexp[i7] as i64, r, poly_res)
                    large_vals[i7] = term_from_poly(init, poly_res)
                }
                i7 = i7 + 1
            }
        }

        let mut prod: i64 = 1
        let mut i8_idx: i32 = 0
        while i8_idx < nu {
            let val: i64 = if uexp[i8_idx] <= use_cutoff { dp[uexp[i8_idx]] } else { large_vals[i8_idx] }
            if val == 0 { prod = 0; break }
            prod = mod_mul(prod, mod_pow(val, ucnt[i8_idx] as i64))
            i8_idx = i8_idx + 1
        }

        if prod != 0 {
            let mut c: i64 = g_coeffs[k] % MOD
            if c < 0 { c = c + MOD }
            total = mod_add(total, mod_mul(c, prod))
        }
        k = k + 1
    }

    total = mod_mul(total, inv288)

    free(large_vals as ptr<void>)
    free(dp as ptr<void>)
    free(q as ptr<void>)
    free(r as ptr<void>)
    free(init as ptr<void>)
    free(poly_res as ptr<void>)
    free(pow_polys as ptr<void>)
    free(ucnt as ptr<void>)
    free(uexp as ptr<void>)
    free(exps as ptr<void>)
    free(primes as ptr<void>)
    return total
}

function main() -> i32 {
    build_partitions()
    let result: i64 = compute_F(1000000, 13000)
    free(g_keys as ptr<void>)
    free(g_key_lens as ptr<void>)
    free(g_coeffs as ptr<void>)
    free(g_block_members as ptr<void>)
    free(g_block_sizes as ptr<void>)
    printf("%lld\n", result)
    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 mod_add_i64_i64(int64_t a, int64_t b);
int64_t mod_sub_i64_i64(int64_t a, int64_t b);
int64_t mod_mul_i64_i64(int64_t a, int64_t b);
int64_t mod_pow_i64_i64(int64_t a, int64_t e);
int32_t slot_weight_i32(int32_t i);
int32_t factorial_small_i32(int32_t n);
void process_partition(void);
void recurse_partition_i32(int32_t i);
void build_partitions(void);
int32_t* sieve_primes_i32_ptr_i32(int32_t n, int32_t* out_count);
int32_t factorial_prime_exp_i32_i32(int32_t n, int32_t p);
void coeffs_up_to_ptr_i64_i32_i32_ptr_i64(int64_t* key, int32_t klen, int32_t limit, int64_t* dp);
void poly_Q_from_key_ptr_i64_i32_ptr_i64(int64_t* key, int32_t klen, int64_t* q);
void mul_mod_poly_ptr_i64_ptr_i64_ptr_i64_ptr_i64(int64_t* a, int64_t* b, int64_t* r, int64_t* out);
void precompute_x_powers_ptr_i64_i32_ptr_i64(int64_t* r, int32_t maxbit, int64_t* pow_polys);
void poly_x_n_ptr_i64_i64_ptr_i64_ptr_i64(int64_t* pow_polys, int64_t n, int64_t* r, int64_t* out);
int64_t term_from_poly_ptr_i64_ptr_i64(int64_t* init, int64_t* poly);
void heapsort_i32_ptr_i32_i32(int32_t* arr, int32_t n);
int64_t compute_F_i32_i32(int32_t n, int32_t cutoff);
int32_t main(void);

static const int64_t MOD = 1000000007;
static const int32_t D = 30;
static const int32_t NSLOTS = 10;
static const int32_t MAXBIT = 20;
static const int32_t MAX_KEYS = 60000;
static const int32_t MAX_KEY_LEN = 10;

/* Module statics */
static int64_t* g_keys = NULL;
static int32_t* g_key_lens = NULL;
static int64_t* g_coeffs = NULL;
static int32_t g_nkeys = 0;
static int32_t* g_block_members = NULL;
static int32_t* g_block_sizes = NULL;
static int32_t g_n_blocks = 0;






int64_t mod_add_i64_i64(int64_t a, int64_t b) {
    int64_t r = (a + b);
    if (r >= MOD) {
        r = (r - MOD);
    }
    return r;
}

int64_t mod_sub_i64_i64(int64_t a, int64_t b) {
    int64_t r = (a - b);
    if (r < 0) {
        r = (r + MOD);
    }
    return r;
}

int64_t mod_mul_i64_i64(int64_t a, int64_t b) {
    return ((int64_t)(FLOW_CHECKED_MOD(((((__int128)(a)) * ((__int128)(b)))), (((__int128)(MOD))))));
}

int64_t mod_pow_i64_i64(int64_t a, int64_t e) {
    int64_t r = 1;
    int64_t aa = FLOW_CHECKED_MOD((a), (MOD));
    if (aa < 0) {
        aa = (aa + MOD);
    }
    int64_t ee = e;
    while (ee > 0) {
        if ((ee & 1) == 1) {
            r = mod_mul_i64_i64(r, aa);
        }
        aa = mod_mul_i64_i64(aa, aa);
        ee = FLOW_CHECKED_SHR((ee), (1));
    }
    return r;
}

int32_t slot_weight_i32(int32_t i) {
    if (i == 0) {
        return 1;
    }
    if (i == 1) {
        return 2;
    }
    if (i == 2) {
        return 2;
    }
    if (i == 3) {
        return 3;
    }
    if (i == 4) {
        return 3;
    }
    if (i == 5) {
        return 3;
    }
    return 4;
}

int32_t factorial_small_i32(int32_t n) {
    int32_t r = 1;
    int32_t i = 2;
    while (i <= n) {
        r = (r * i);
        i = (i + 1);
    }
    return r;
}

void process_partition(void) {
    int64_t mu = 1;
    int32_t* sums = (int32_t*)(calloc(10, 4));
    int32_t ns = 0;
    int32_t b = 0;
    while (b < g_n_blocks) {
        int32_t bs = g_block_sizes[b];
        int32_t s = 0;
        int32_t m = 0;
        while (m < bs) {
            s = (s + slot_weight_i32(g_block_members[((b * 10) + m)]));
            m = (m + 1);
        }
        sums[ns] = s;
        ns = (ns + 1);
        int64_t sign = ((FLOW_CHECKED_MOD(((bs - 1)), (2)) == 0) ? (1) : ((-1)));
        mu = ((mu * sign) * ((int64_t)(factorial_small_i32((bs - 1)))));
        b = (b + 1);
    }
    int32_t i = 1;
    while (i < ns) {
        int32_t v = sums[i];
        int32_t j = (i - 1);
        while ((j >= 0 && sums[j] > v)) {
            sums[(j + 1)] = sums[j];
            j = (j - 1);
        }
        sums[(j + 1)] = v;
        i = (i + 1);
    }
    int32_t found = (-1);
    int32_t k = 0;
    while (k < g_nkeys) {
        if (g_key_lens[k] != ns) {
            k = (k + 1);
            continue;
        }
        int32_t is_match = 1;
        int32_t j = 0;
        while (j < ns) {
            if (g_keys[((k * MAX_KEY_LEN) + j)] != ((int64_t)(sums[j]))) {
                is_match = 0;
                break;
            }
            j = (j + 1);
        }
        if (is_match == 1) {
            found = k;
            break;
        }
        k = (k + 1);
    }
    if (found >= 0) {
        g_coeffs[found] = (g_coeffs[found] + mu);
    } else {
        int32_t k2 = g_nkeys;
        g_nkeys = (g_nkeys + 1);
        g_key_lens[k2] = ns;
        int32_t j2 = 0;
        while (j2 < ns) {
            g_keys[((k2 * MAX_KEY_LEN) + j2)] = ((int64_t)(sums[j2]));
            j2 = (j2 + 1);
        }
        g_coeffs[k2] = mu;
    }
    free(((void*)(sums)));
}

void recurse_partition_i32(int32_t i) {
    if (i == NSLOTS) {
        process_partition();
        return;
    }
    int32_t b = 0;
    while (b < g_n_blocks) {
        g_block_members[((b * 10) + g_block_sizes[b])] = i;
        g_block_sizes[b] = (g_block_sizes[b] + 1);
        recurse_partition_i32((i + 1));
        g_block_sizes[b] = (g_block_sizes[b] - 1);
        b = (b + 1);
    }
    g_block_members[((g_n_blocks * 10) + 0)] = i;
    g_block_sizes[g_n_blocks] = 1;
    g_n_blocks = (g_n_blocks + 1);
    recurse_partition_i32((i + 1));
    g_n_blocks = (g_n_blocks - 1);
}

void build_partitions(void) {
    g_keys = calloc((((int64_t)(MAX_KEYS)) * ((int64_t)(MAX_KEY_LEN))), 8);
    g_key_lens = calloc(((int64_t)(MAX_KEYS)), 4);
    g_coeffs = calloc(((int64_t)(MAX_KEYS)), 8);
    g_block_members = calloc(100, 4);
    g_block_sizes = calloc(10, 4);
    g_nkeys = 0;
    g_n_blocks = 0;
    recurse_partition_i32(0);
}

int32_t* sieve_primes_i32_ptr_i32(int32_t n, int32_t* out_count) {
    int8_t* sieve = (int8_t*)(calloc(((int64_t)((n + 1))), 1));
    int32_t count = 0;
    int32_t i = 2;
    while (i <= n) {
        if (sieve[i] == 0) {
            count = (count + 1);
            int64_t j = (((int64_t)(i)) * ((int64_t)(i)));
            while (j <= ((int64_t)(n))) {
                sieve[j] = 1;
                j = (j + ((int64_t)(i)));
            }
        }
        i = (i + 1);
    }
    int32_t* primes = (int32_t*)(calloc(((int64_t)(count)), 4));
    int32_t idx = 0;
    int32_t i2 = 2;
    while (i2 <= n) {
        if (sieve[i2] == 0) {
            primes[idx] = i2;
            idx = (idx + 1);
        }
        i2 = (i2 + 1);
    }
    free(((void*)(sieve)));
    out_count[0] = count;
    return primes;
}

int32_t factorial_prime_exp_i32_i32(int32_t n, int32_t p) {
    int32_t e = 0;
    int64_t m = ((int64_t)(n));
    while (m > 0) {
        m = FLOW_CHECKED_DIV((m), (((int64_t)(p))));
        e = (e + ((int32_t)(m)));
    }
    return e;
}

void coeffs_up_to_ptr_i64_i32_i32_ptr_i64(int64_t* key, int32_t klen, int32_t limit, int64_t* dp) {
    memset(((void*)(dp)), 0, (((int64_t)((limit + 1))) * 8));
    dp[0] = 1;
    int32_t ki = 0;
    while (ki < klen) {
        int32_t w = ((int32_t)(key[ki]));
        int32_t i = w;
        while (i <= limit) {
            int64_t v = (dp[i] + dp[(i - w)]);
            if (v >= MOD) {
                v = (v - MOD);
            }
            dp[i] = v;
            i = (i + 1);
        }
        ki = (ki + 1);
    }
}

void poly_Q_from_key_ptr_i64_i32_ptr_i64(int64_t* key, int32_t klen, int64_t* q) {
    memset(((void*)(q)), 0, (((int64_t)((D + 1))) * 8));
    q[0] = 1;
    int32_t ki = 0;
    while (ki < klen) {
        int32_t w = ((int32_t)(key[ki]));
        int32_t i = (D - w);
        while (i >= 0) {
            q[(i + w)] = (q[(i + w)] - q[i]);
            i = (i - 1);
        }
        ki = (ki + 1);
    }
}

void mul_mod_poly_ptr_i64_ptr_i64_ptr_i64_ptr_i64(int64_t* a, int64_t* b, int64_t* r, int64_t* out) {
    int64_t* tmp = (int64_t*)(calloc(((int64_t)(((2 * D) - 1))), 8));
    int32_t i = 0;
    while (i < D) {
        if (a[i] == 0) {
            i = (i + 1);
            continue;
        }
        int32_t j = 0;
        while (j < D) {
            if (b[j] == 0) {
                j = (j + 1);
                continue;
            }
            tmp[(i + j)] = mod_add_i64_i64(tmp[(i + j)], mod_mul_i64_i64(a[i], b[j]));
            j = (j + 1);
        }
        i = (i + 1);
    }
    int32_t k = ((2 * D) - 2);
    while (k >= D) {
        int64_t coef = tmp[k];
        if (coef == 0) {
            k = (k - 1);
            continue;
        }
        int32_t i2 = 0;
        while (i2 < D) {
            int32_t idx = ((k - 1) - i2);
            tmp[idx] = mod_add_i64_i64(tmp[idx], mod_mul_i64_i64(coef, r[i2]));
            i2 = (i2 + 1);
        }
        k = (k - 1);
    }
    memcpy(((void*)(out)), ((void*)(tmp)), (((int64_t)(D)) * 8));
    free(((void*)(tmp)));
}

void precompute_x_powers_ptr_i64_i32_ptr_i64(int64_t* r, int32_t maxbit, int64_t* pow_polys) {
    memset(((void*)(pow_polys)), 0, (((int64_t)((maxbit * D))) * 8));
    pow_polys[1] = 1;
    int32_t b = 1;
    while (b < maxbit) {
        mul_mod_poly_ptr_i64_ptr_i64_ptr_i64_ptr_i64((pow_polys + ((b - 1) * D)), (pow_polys + ((b - 1) * D)), r, (pow_polys + (b * D)));
        b = (b + 1);
    }
}

void poly_x_n_ptr_i64_i64_ptr_i64_ptr_i64(int64_t* pow_polys, int64_t n, int64_t* r, int64_t* out) {
    int64_t* res = (int64_t*)(calloc(((int64_t)(D)), 8));
    res[0] = 1;
    int64_t* tmp = (int64_t*)(calloc(((int64_t)(D)), 8));
    int64_t nn = n;
    int32_t bit = 0;
    while (nn > 0) {
        if ((nn & 1) == 1) {
            memcpy(((void*)(tmp)), ((void*)(res)), (((int64_t)(D)) * 8));
            mul_mod_poly_ptr_i64_ptr_i64_ptr_i64_ptr_i64(tmp, (pow_polys + (bit * D)), r, res);
        }
        nn = FLOW_CHECKED_SHR((nn), (1));
        bit = (bit + 1);
    }
    memcpy(((void*)(out)), ((void*)(res)), (((int64_t)(D)) * 8));
    free(((void*)(res)));
    free(((void*)(tmp)));
}

int64_t term_from_poly_ptr_i64_ptr_i64(int64_t* init, int64_t* poly) {
    int64_t s = 0;
    int32_t i = 0;
    while (i < D) {
        s = mod_add_i64_i64(s, mod_mul_i64_i64(poly[i], init[i]));
        i = (i + 1);
    }
    return s;
}

void heapsort_i32_ptr_i32_i32(int32_t* arr, int32_t n) {
    int32_t start = (FLOW_CHECKED_SHR((n), (1)) - 1);
    while (start >= 0) {
        int32_t root = start;
        while ((FLOW_CHECKED_SHL((root), (1)) + 1) < n) {
            int32_t child = (FLOW_CHECKED_SHL((root), (1)) + 1);
            int32_t mx = child;
            if (((child + 1) < n && arr[(child + 1)] > arr[child])) {
                mx = (child + 1);
            }
            if (arr[root] < arr[mx]) {
                int32_t t = arr[root];
                arr[root] = arr[mx];
                arr[mx] = t;
                root = mx;
            } else {
                break;
            }
        }
        start = (start - 1);
    }
    int32_t end = (n - 1);
    while (end > 0) {
        int32_t t = arr[0];
        arr[0] = arr[end];
        arr[end] = t;
        int32_t root = 0;
        while ((FLOW_CHECKED_SHL((root), (1)) + 1) < end) {
            int32_t child = (FLOW_CHECKED_SHL((root), (1)) + 1);
            int32_t mx = child;
            if (((child + 1) < end && arr[(child + 1)] > arr[child])) {
                mx = (child + 1);
            }
            if (arr[root] < arr[mx]) {
                int32_t t2 = arr[root];
                arr[root] = arr[mx];
                arr[mx] = t2;
                root = mx;
            } else {
                break;
            }
        }
        end = (end - 1);
    }
}

int64_t compute_F_i32_i32(int32_t n, int32_t cutoff) {
    int32_t* nprimes_ptr = (int32_t*)(calloc(1, 4));
    int32_t* primes = (int32_t*)(sieve_primes_i32_ptr_i32(n, nprimes_ptr));
    int32_t nprimes = nprimes_ptr[0];
    free(((void*)(nprimes_ptr)));
    int32_t* exps = (int32_t*)(calloc(((int64_t)(nprimes)), 4));
    int32_t max_exp = 0;
    int32_t i = 0;
    while (i < nprimes) {
        exps[i] = factorial_prime_exp_i32_i32(n, primes[i]);
        if (exps[i] > max_exp) {
            max_exp = exps[i];
        }
        i = (i + 1);
    }
    heapsort_i32_ptr_i32_i32(exps, nprimes);
    int32_t* uexp = (int32_t*)(calloc(((int64_t)(nprimes)), 4));
    int32_t* ucnt = (int32_t*)(calloc(((int64_t)(nprimes)), 4));
    int32_t nu = 0;
    int32_t i2 = 0;
    while (i2 < nprimes) {
        if ((nu > 0 && uexp[(nu - 1)] == exps[i2])) {
            ucnt[(nu - 1)] = (ucnt[(nu - 1)] + 1);
        } else {
            uexp[nu] = exps[i2];
            ucnt[nu] = 1;
            nu = (nu + 1);
        }
        i2 = (i2 + 1);
    }
    int32_t use_cutoff = ((cutoff < max_exp) ? (cutoff) : (max_exp));
    int64_t inv288 = mod_pow_i64_i64(288, (MOD - 2));
    int32_t has_exp1 = 0;
    int32_t i3 = 0;
    while (i3 < nu) {
        if (uexp[i3] == 1) {
            has_exp1 = 1;
            break;
        }
        i3 = (i3 + 1);
    }
    int64_t* dp = (int64_t*)(calloc(((int64_t)((use_cutoff + 1))), 8));
    int64_t* large_vals = (int64_t*)(calloc(((int64_t)(nu)), 8));
    int64_t* q = (int64_t*)(calloc(((int64_t)((D + 1))), 8));
    int64_t* r = (int64_t*)(calloc(((int64_t)(D)), 8));
    int64_t* init = (int64_t*)(calloc(((int64_t)(D)), 8));
    int64_t* poly_res = (int64_t*)(calloc(((int64_t)(D)), 8));
    int64_t* pow_polys = (int64_t*)(calloc(((int64_t)((MAXBIT * D))), 8));
    int64_t total = 0;
    int32_t k = 0;
    while (k < g_nkeys) {
        int32_t klen = g_key_lens[k];
        int64_t* key = (int64_t*)((g_keys + (k * MAX_KEY_LEN)));
        if (has_exp1 == 1) {
            int32_t has1 = 0;
            int32_t j = 0;
            while (j < klen) {
                if (key[j] == 1) {
                    has1 = 1;
                    break;
                }
                j = (j + 1);
            }
            if (has1 == 0) {
                k = (k + 1);
                continue;
            }
        }
        coeffs_up_to_ptr_i64_i32_i32_ptr_i64(key, klen, use_cutoff, dp);
        int32_t has_large = 0;
        int32_t i4 = 0;
        while (i4 < nu) {
            if (uexp[i4] > use_cutoff) {
                has_large = 1;
                break;
            }
            i4 = (i4 + 1);
        }
        if (has_large == 1) {
            poly_Q_from_key_ptr_i64_i32_ptr_i64(key, klen, q);
            int32_t i5 = 0;
            while (i5 < D) {
                int64_t v = FLOW_CHECKED_MOD((q[(i5 + 1)]), (MOD));
                if (v < 0) {
                    v = (v + MOD);
                }
                r[i5] = mod_sub_i64_i64(0, v);
                i5 = (i5 + 1);
            }
            precompute_x_powers_ptr_i64_i32_ptr_i64(r, MAXBIT, pow_polys);
            int32_t i6 = 0;
            while (i6 < D) {
                init[i6] = ((i6 <= use_cutoff) ? (dp[i6]) : (0));
                i6 = (i6 + 1);
            }
            int32_t i7 = 0;
            while (i7 < nu) {
                if (uexp[i7] > use_cutoff) {
                    poly_x_n_ptr_i64_i64_ptr_i64_ptr_i64(pow_polys, ((int64_t)(uexp[i7])), r, poly_res);
                    large_vals[i7] = term_from_poly_ptr_i64_ptr_i64(init, poly_res);
                }
                i7 = (i7 + 1);
            }
        }
        int64_t prod = 1;
        int32_t i8_idx = 0;
        while (i8_idx < nu) {
            int64_t val = ((uexp[i8_idx] <= use_cutoff) ? (dp[uexp[i8_idx]]) : (large_vals[i8_idx]));
            if (val == 0) {
                prod = 0;
                break;
            }
            prod = mod_mul_i64_i64(prod, mod_pow_i64_i64(val, ((int64_t)(ucnt[i8_idx]))));
            i8_idx = (i8_idx + 1);
        }
        if (prod != 0) {
            int64_t c = FLOW_CHECKED_MOD((g_coeffs[k]), (MOD));
            if (c < 0) {
                c = (c + MOD);
            }
            total = mod_add_i64_i64(total, mod_mul_i64_i64(c, prod));
        }
        k = (k + 1);
    }
    total = mod_mul_i64_i64(total, inv288);
    free(((void*)(large_vals)));
    free(((void*)(dp)));
    free(((void*)(q)));
    free(((void*)(r)));
    free(((void*)(init)));
    free(((void*)(poly_res)));
    free(((void*)(pow_polys)));
    free(((void*)(ucnt)));
    free(((void*)(uexp)));
    free(((void*)(exps)));
    free(((void*)(primes)));
    return total;
}

int32_t main(void) {
    build_partitions();
    int64_t result = compute_F_i32_i32(1000000, 13000);
    free(((void*)(g_keys)));
    free(((void*)(g_key_lens)));
    free(((void*)(g_coeffs)));
    free(((void*)(g_block_members)));
    free(((void*)(g_block_sizes)));
    printf("%lld\n", result);
    return 0;
}

Generated MLIR

module {
  llvm.func @printf(!llvm.ptr, ...) -> i32
  llvm.mlir.global internal constant @str_0("%lld\n\00") {addr_space = 0 : i32} : !llvm.array<6 x i8>
  func.func private @calloc(i64, i64) -> !llvm.ptr
  func.func private @free(!llvm.ptr) -> ()

  func.func private @memset(!llvm.ptr, i32, i64) -> !llvm.ptr
  func.func private @memcpy(!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr
  // Constant: MOD
  llvm.mlir.global internal constant @MOD(1000000007 : i64) : i64
  // Constant: D
  llvm.mlir.global internal constant @D(30 : i32) : i32
  // Constant: NSLOTS
  llvm.mlir.global internal constant @NSLOTS(10 : i32) : i32
  // Constant: MAXBIT
  llvm.mlir.global internal constant @MAXBIT(20 : i32) : i32
  // Constant: MAX_KEYS
  llvm.mlir.global internal constant @MAX_KEYS(60000 : i32) : i32
  // Constant: MAX_KEY_LEN
  llvm.mlir.global internal constant @MAX_KEY_LEN(10 : i32) : i32
  func.func @mod_add(%arg0: i64, %arg1: i64) -> i64 {
    %0 = arith.addi %arg0, %arg1 : i64
    %1 = llvm.mlir.addressof @MOD : !llvm.ptr
    %2 = llvm.load %1 : !llvm.ptr -> i64
    %3 = arith.cmpi sge, %0, %2 : i64
    %4 = scf.if %3 -> (i64) {
      %5 = llvm.mlir.addressof @MOD : !llvm.ptr
      %6 = llvm.load %5 : !llvm.ptr -> i64
      %7 = arith.subi %0, %6 : i64
      scf.yield %7 : i64
    } else {
      scf.yield %0 : i64
    }
    func.return %4 : i64
  }
  func.func @mod_sub(%arg0: i64, %arg1: i64) -> i64 {
    %8 = arith.subi %arg0, %arg1 : i64
    %9 = arith.constant 0 : i32
    %11 = arith.extsi %9 : i32 to i64
    %10 = arith.cmpi slt, %8, %11 : i64
    %12 = scf.if %10 -> (i64) {
      %13 = llvm.mlir.addressof @MOD : !llvm.ptr
      %14 = llvm.load %13 : !llvm.ptr -> i64
      %15 = arith.addi %8, %14 : i64
      scf.yield %15 : i64
    } else {
      scf.yield %8 : i64
    }
    func.return %12 : i64
  }
  func.func @mod_mul(%arg0: i64, %arg1: i64) -> i64 {
    %16 = arith.extsi %arg0 : i64 to i128
    %17 = arith.extsi %arg1 : i64 to i128
    %19 = arith.trunci %16 : i128 to i64
    %20 = arith.trunci %17 : i128 to i64
    %18 = arith.muli %19, %20 : i64
    %21 = llvm.mlir.addressof @MOD : !llvm.ptr
    %22 = llvm.load %21 : !llvm.ptr -> i64
    %23 = arith.extsi %22 : i64 to i128
    %25 = arith.trunci %23 : i128 to i64
    %24 = arith.remsi %18, %25 : i64
    func.return %24 : i64
  }
  func.func @mod_pow(%arg0: i64, %arg1: i64) -> i64 {
    %26 = arith.constant 1 : i32
    %27 = arith.extsi %26 : i32 to i64
    %28 = llvm.mlir.constant(1 : i64) : i64
    %29 = llvm.alloca %28 x i64 : (i64) -> !llvm.ptr
    llvm.store %27, %29 : i64, !llvm.ptr
    %30 = llvm.mlir.addressof @MOD : !llvm.ptr
    %31 = llvm.load %30 : !llvm.ptr -> i64
    %32 = arith.remsi %arg0, %31 : i64
    %33 = llvm.mlir.constant(1 : i64) : i64
    %34 = llvm.alloca %33 x i64 : (i64) -> !llvm.ptr
    llvm.store %32, %34 : i64, !llvm.ptr
    %35 = llvm.load %34 : !llvm.ptr -> i64
    %36 = arith.constant 0 : i32
    %38 = arith.extsi %36 : i32 to i64
    %37 = arith.cmpi slt, %35, %38 : i64
    cf.cond_br %37, ^bb0, ^bb1
    ^bb0:
      %39 = llvm.load %34 : !llvm.ptr -> i64
      %40 = llvm.mlir.addressof @MOD : !llvm.ptr
      %41 = llvm.load %40 : !llvm.ptr -> i64
      %42 = arith.addi %39, %41 : i64
      llvm.store %42, %34 : i64, !llvm.ptr
      cf.br ^bb2
    ^bb1:
      cf.br ^bb2
    ^bb2:
    %43 = llvm.mlir.constant(1 : i64) : i64
    %44 = llvm.alloca %43 x i64 : (i64) -> !llvm.ptr
    llvm.store %arg1, %44 : i64, !llvm.ptr
    cf.br ^bb3
    ^bb3:
    %45 = llvm.load %44 : !llvm.ptr -> i64
    %46 = arith.constant 0 : i32
    %48 = arith.extsi %46 : i32 to i64
    %47 = arith.cmpi sgt, %45, %48 : i64
    cf.cond_br %47, ^bb4, ^bb5
    ^bb4:
      %49 = llvm.load %44 : !llvm.ptr -> i64
      %50 = arith.constant 1 : i32
      %52 = arith.extsi %50 : i32 to i64
      %51 = arith.andi %49, %52 : i64
      %53 = arith.constant 1 : i32
      %55 = arith.extsi %53 : i32 to i64
      %54 = arith.cmpi eq, %51, %55 : i64
      cf.cond_br %54, ^bb6, ^bb7
      ^bb6:
        %57 = llvm.load %29 : !llvm.ptr -> i64
        %58 = llvm.load %34 : !llvm.ptr -> i64
        %56 = func.call @mod_mul(%57, %58) : (i64, i64) -> i64
        llvm.store %56, %29 : i64, !llvm.ptr
        cf.br ^bb8
      ^bb7:
        cf.br ^bb8
      ^bb8:
      %60 = llvm.load %34 : !llvm.ptr -> i64
      %61 = llvm.load %34 : !llvm.ptr -> i64
      %59 = func.call @mod_mul(%60, %61) : (i64, i64) -> i64
      llvm.store %59, %34 : i64, !llvm.ptr
      %62 = llvm.load %44 : !llvm.ptr -> i64
      %63 = arith.constant 1 : i32
      %65 = arith.extsi %63 : i32 to i64
      %64 = arith.shrsi %62, %65 : i64
      llvm.store %64, %44 : i64, !llvm.ptr
      cf.br ^bb3
    ^bb5:
    %66 = llvm.load %29 : !llvm.ptr -> i64
    func.return %66 : i64
  }
  func.func @slot_weight(%arg0: i32) -> i32 {
    %67 = arith.constant 0 : i32
    %68 = arith.cmpi eq, %arg0, %67 : i32
    cf.cond_br %68, ^bb9, ^bb10
    ^bb9:
      %69 = arith.constant 1 : i32
      func.return %69 : i32
    ^bb10:
      cf.br ^bb11
    ^bb11:
    %70 = arith.constant 1 : i32
    %71 = arith.cmpi eq, %arg0, %70 : i32
    cf.cond_br %71, ^bb12, ^bb13
    ^bb12:
      %72 = arith.constant 2 : i32
      func.return %72 : i32
    ^bb13:
      cf.br ^bb14
    ^bb14:
    %73 = arith.constant 2 : i32
    %74 = arith.cmpi eq, %arg0, %73 : i32
    cf.cond_br %74, ^bb15, ^bb16
    ^bb15:
      %75 = arith.constant 2 : i32
      func.return %75 : i32
    ^bb16:
      cf.br ^bb17
    ^bb17:
    %76 = arith.constant 3 : i32
    %77 = arith.cmpi eq, %arg0, %76 : i32
    cf.cond_br %77, ^bb18, ^bb19
    ^bb18:
      %78 = arith.constant 3 : i32
      func.return %78 : i32
    ^bb19:
      cf.br ^bb20
    ^bb20:
    %79 = arith.constant 4 : i32
    %80 = arith.cmpi eq, %arg0, %79 : i32
    cf.cond_br %80, ^bb21, ^bb22
    ^bb21:
      %81 = arith.constant 3 : i32
      func.return %81 : i32
    ^bb22:
      cf.br ^bb23
    ^bb23:
    %82 = arith.constant 5 : i32
    %83 = arith.cmpi eq, %arg0, %82 : i32
    cf.cond_br %83, ^bb24, ^bb25
    ^bb24:
      %84 = arith.constant 3 : i32
      func.return %84 : i32
    ^bb25:
      cf.br ^bb26
    ^bb26:
    %85 = arith.constant 4 : i32
    func.return %85 : i32
  }
  // Module static: g_keys
  llvm.mlir.global internal @g_keys() {addr_space = 0 : i32} : !llvm.ptr {
    %86 = llvm.mlir.zero : !llvm.ptr
    llvm.return %86 : !llvm.ptr
  }
  // Module static: g_key_lens
  llvm.mlir.global internal @g_key_lens() {addr_space = 0 : i32} : !llvm.ptr {
    %87 = llvm.mlir.zero : !llvm.ptr
    llvm.return %87 : !llvm.ptr
  }
  // Module static: g_coeffs
  llvm.mlir.global internal @g_coeffs() {addr_space = 0 : i32} : !llvm.ptr {
    %88 = llvm.mlir.zero : !llvm.ptr
    llvm.return %88 : !llvm.ptr
  }
  // Module static: g_nkeys
  llvm.mlir.global internal @g_nkeys(0 : i32) : i32
  // Module static: g_block_members
  llvm.mlir.global internal @g_block_members() {addr_space = 0 : i32} : !llvm.ptr {
    %89 = llvm.mlir.zero : !llvm.ptr
    llvm.return %89 : !llvm.ptr
  }
  // Module static: g_block_sizes
  llvm.mlir.global internal @g_block_sizes() {addr_space = 0 : i32} : !llvm.ptr {
    %90 = llvm.mlir.zero : !llvm.ptr
    llvm.return %90 : !llvm.ptr
  }
  // Module static: g_n_blocks
  llvm.mlir.global internal @g_n_blocks(0 : i32) : i32
  func.func @factorial_small(%arg0: i32) -> i32 {
    %91 = arith.constant 1 : i32
    %92 = llvm.mlir.constant(1 : i64) : i64
    %93 = llvm.alloca %92 x i32 : (i64) -> !llvm.ptr
    llvm.store %91, %93 : i32, !llvm.ptr
    %94 = arith.constant 2 : i32
    %95 = llvm.mlir.constant(1 : i64) : i64
    %96 = llvm.alloca %95 x i32 : (i64) -> !llvm.ptr
    llvm.store %94, %96 : i32, !llvm.ptr
    cf.br ^bb27
    ^bb27:
    %97 = llvm.load %96 : !llvm.ptr -> i32
    %98 = arith.cmpi sle, %97, %arg0 : i32
    cf.cond_br %98, ^bb28, ^bb29
    ^bb28:
      %99 = llvm.load %93 : !llvm.ptr -> i32
      %100 = llvm.load %96 : !llvm.ptr -> i32
      %101 = arith.muli %99, %100 : i32
      llvm.store %101, %93 : i32, !llvm.ptr
      %102 = llvm.load %96 : !llvm.ptr -> i32
      %103 = arith.constant 1 : i32
      %104 = arith.addi %102, %103 : i32
      llvm.store %104, %96 : i32, !llvm.ptr
      cf.br ^bb27
    ^bb29:
    %105 = llvm.load %93 : !llvm.ptr -> i32
    func.return %105 : i32
  }
  func.func @process_partition() -> () {
    %106 = arith.constant 1 : i32
    %107 = arith.extsi %106 : i32 to i64
    %108 = llvm.mlir.constant(1 : i64) : i64
    %109 = llvm.alloca %108 x i64 : (i64) -> !llvm.ptr
    llvm.store %107, %109 : i64, !llvm.ptr
    %111 = arith.constant 10 : i32
    %112 = arith.constant 4 : i32
    %113 = arith.extsi %111 : i32 to i64
    %114 = arith.extsi %112 : i32 to i64
    %110 = func.call @calloc(%113, %114) : (i64, i64) -> !llvm.ptr
    %115 = arith.constant 0 : i32
    %116 = llvm.mlir.constant(1 : i64) : i64
    %117 = llvm.alloca %116 x i32 : (i64) -> !llvm.ptr
    llvm.store %115, %117 : i32, !llvm.ptr
    %118 = arith.constant 0 : i32
    %119 = llvm.mlir.constant(1 : i64) : i64
    %120 = llvm.alloca %119 x i32 : (i64) -> !llvm.ptr
    llvm.store %118, %120 : i32, !llvm.ptr
    cf.br ^bb30
    ^bb30:
    %121 = llvm.load %120 : !llvm.ptr -> i32
    %122 = llvm.mlir.addressof @g_n_blocks : !llvm.ptr
    %123 = llvm.load %122 : !llvm.ptr -> i32
    %124 = arith.cmpi slt, %121, %123 : i32
    cf.cond_br %124, ^bb31, ^bb32
    ^bb31:
      %126 = llvm.mlir.addressof @g_block_sizes : !llvm.ptr
      %127 = llvm.load %126 : !llvm.ptr -> !llvm.ptr
      %128 = llvm.load %120 : !llvm.ptr -> i32
      %129 = arith.extsi %128 : i32 to i64
      %130 = llvm.getelementptr %127[%129] : (!llvm.ptr, i64) -> !llvm.ptr, i32
      %125 = llvm.load %130 : !llvm.ptr -> i32
      %131 = arith.constant 0 : i32
      %132 = llvm.mlir.constant(1 : i64) : i64
      %133 = llvm.alloca %132 x i32 : (i64) -> !llvm.ptr
      llvm.store %131, %133 : i32, !llvm.ptr
      %134 = arith.constant 0 : i32
      %135 = llvm.mlir.constant(1 : i64) : i64
      %136 = llvm.alloca %135 x i32 : (i64) -> !llvm.ptr
      llvm.store %134, %136 : i32, !llvm.ptr
      cf.br ^bb33
      ^bb33:
      %137 = llvm.load %136 : !llvm.ptr -> i32
      %138 = arith.cmpi slt, %137, %125 : i32
      cf.cond_br %138, ^bb34, ^bb35
      ^bb34:
        %139 = llvm.load %133 : !llvm.ptr -> i32
        %142 = llvm.mlir.addressof @g_block_members : !llvm.ptr
        %143 = llvm.load %142 : !llvm.ptr -> !llvm.ptr
        %144 = llvm.load %120 : !llvm.ptr -> i32
        %145 = arith.constant 10 : i32
        %146 = arith.muli %144, %145 : i32
        %147 = llvm.load %136 : !llvm.ptr -> i32
        %148 = arith.addi %146, %147 : i32
        %149 = arith.extsi %148 : i32 to i64
        %150 = llvm.getelementptr %143[%149] : (!llvm.ptr, i64) -> !llvm.ptr, i32
        %141 = llvm.load %150 : !llvm.ptr -> i32
        %140 = func.call @slot_weight(%141) : (i32) -> i32
        %151 = arith.addi %139, %140 : i32
        llvm.store %151, %133 : i32, !llvm.ptr
        %152 = llvm.load %136 : !llvm.ptr -> i32
        %153 = arith.constant 1 : i32
        %154 = arith.addi %152, %153 : i32
        llvm.store %154, %136 : i32, !llvm.ptr
        cf.br ^bb33
      ^bb35:
      %155 = llvm.load %133 : !llvm.ptr -> i32
      %156 = llvm.load %117 : !llvm.ptr -> i32
      %157 = arith.extsi %156 : i32 to i64
      %158 = llvm.getelementptr %110[%157] : (!llvm.ptr, i64) -> !llvm.ptr, i32
      llvm.store %155, %158 : i32, !llvm.ptr
      %159 = llvm.load %117 : !llvm.ptr -> i32
      %160 = arith.constant 1 : i32
      %161 = arith.addi %159, %160 : i32
      llvm.store %161, %117 : i32, !llvm.ptr
      %162 = arith.constant 1 : i32
      %163 = arith.subi %125, %162 : i32
      %164 = arith.constant 2 : i32
      %165 = arith.remsi %163, %164 : i32
      %166 = arith.constant 0 : i32
      %167 = arith.cmpi eq, %165, %166 : i32
      %168 = scf.if %167 -> (i32) {
        %169 = arith.constant 1 : i32
        scf.yield %169 : i32
      } else {
        %170 = arith.constant 1 : i32
        %172 = arith.constant 0 : i32
        %171 = arith.subi %172, %170 : i32
        scf.yield %171 : i32
      }
      %173 = arith.extsi %168 : i32 to i64
      %174 = llvm.load %109 : !llvm.ptr -> i64
      %175 = arith.muli %174, %173 : i64
      %177 = arith.constant 1 : i32
      %178 = arith.subi %125, %177 : i32
      %176 = func.call @factorial_small(%178) : (i32) -> i32
      %179 = arith.extsi %176 : i32 to i64
      %180 = arith.muli %175, %179 : i64
      llvm.store %180, %109 : i64, !llvm.ptr
      %181 = llvm.load %120 : !llvm.ptr -> i32
      %182 = arith.constant 1 : i32
      %183 = arith.addi %181, %182 : i32
      llvm.store %183, %120 : i32, !llvm.ptr
      cf.br ^bb30
    ^bb32:
    %184 = arith.constant 1 : i32
    %185 = llvm.mlir.constant(1 : i64) : i64
    %186 = llvm.alloca %185 x i32 : (i64) -> !llvm.ptr
    llvm.store %184, %186 : i32, !llvm.ptr
    cf.br ^bb36
    ^bb36:
    %187 = llvm.load %186 : !llvm.ptr -> i32
    %188 = llvm.load %117 : !llvm.ptr -> i32
    %189 = arith.cmpi slt, %187, %188 : i32
    cf.cond_br %189, ^bb37, ^bb38
    ^bb37:
      %191 = llvm.load %186 : !llvm.ptr -> i32
      %192 = arith.extsi %191 : i32 to i64
      %193 = llvm.getelementptr %110[%192] : (!llvm.ptr, i64) -> !llvm.ptr, i32
      %190 = llvm.load %193 : !llvm.ptr -> i32
      %194 = llvm.load %186 : !llvm.ptr -> i32
      %195 = arith.constant 1 : i32
      %196 = arith.subi %194, %195 : i32
      %197 = llvm.mlir.constant(1 : i64) : i64
      %198 = llvm.alloca %197 x i32 : (i64) -> !llvm.ptr
      llvm.store %196, %198 : i32, !llvm.ptr
      cf.br ^bb39
      ^bb39:
      %199 = llvm.load %198 : !llvm.ptr -> i32
      %200 = arith.constant 0 : i32
      %201 = arith.cmpi sge, %199, %200 : i32
      %202 = scf.if %201 -> (i1) {
        %204 = llvm.load %198 : !llvm.ptr -> i32
        %205 = arith.extsi %204 : i32 to i64
        %206 = llvm.getelementptr %110[%205] : (!llvm.ptr, i64) -> !llvm.ptr, i32
        %203 = llvm.load %206 : !llvm.ptr -> i32
        %207 = arith.cmpi sgt, %203, %190 : i32
        scf.yield %207 : i1
      } else {
        %208 = arith.constant false
        scf.yield %208 : i1
      }
      cf.cond_br %202, ^bb40, ^bb41
      ^bb40:
        %210 = llvm.load %198 : !llvm.ptr -> i32
        %211 = arith.extsi %210 : i32 to i64
        %212 = llvm.getelementptr %110[%211] : (!llvm.ptr, i64) -> !llvm.ptr, i32
        %209 = llvm.load %212 : !llvm.ptr -> i32
        %213 = llvm.load %198 : !llvm.ptr -> i32
        %214 = arith.constant 1 : i32
        %215 = arith.addi %213, %214 : i32
        %216 = arith.extsi %215 : i32 to i64
        %217 = llvm.getelementptr %110[%216] : (!llvm.ptr, i64) -> !llvm.ptr, i32
        llvm.store %209, %217 : i32, !llvm.ptr
        %218 = llvm.load %198 : !llvm.ptr -> i32
        %219 = arith.constant 1 : i32
        %220 = arith.subi %218, %219 : i32
        llvm.store %220, %198 : i32, !llvm.ptr
        cf.br ^bb39
      ^bb41:
      %221 = llvm.load %198 : !llvm.ptr -> i32
      %222 = arith.constant 1 : i32
      %223 = arith.addi %221, %222 : i32
      %224 = arith.extsi %223 : i32 to i64
      %225 = llvm.getelementptr %110[%224] : (!llvm.ptr, i64) -> !llvm.ptr, i32
      llvm.store %190, %225 : i32, !llvm.ptr
      %226 = llvm.load %186 : !llvm.ptr -> i32
      %227 = arith.constant 1 : i32
      %228 = arith.addi %226, %227 : i32
      llvm.store %228, %186 : i32, !llvm.ptr
      cf.br ^bb36
    ^bb38:
    %229 = arith.constant 1 : i32
    %231 = arith.constant 0 : i32
    %230 = arith.subi %231, %229 : i32
    %232 = llvm.mlir.constant(1 : i64) : i64
    %233 = llvm.alloca %232 x i32 : (i64) -> !llvm.ptr
    llvm.store %230, %233 : i32, !llvm.ptr
    %234 = arith.constant 0 : i32
    %235 = llvm.mlir.constant(1 : i64) : i64
    %236 = llvm.alloca %235 x i32 : (i64) -> !llvm.ptr
    llvm.store %234, %236 : i32, !llvm.ptr
    cf.br ^bb42
    ^bb42:
    %237 = llvm.load %236 : !llvm.ptr -> i32
    %238 = llvm.mlir.addressof @g_nkeys : !llvm.ptr
    %239 = llvm.load %238 : !llvm.ptr -> i32
    %240 = arith.cmpi slt, %237, %239 : i32
    cf.cond_br %240, ^bb43, ^bb44
    ^bb43:
      %242 = llvm.mlir.addressof @g_key_lens : !llvm.ptr
      %243 = llvm.load %242 : !llvm.ptr -> !llvm.ptr
      %244 = llvm.load %236 : !llvm.ptr -> i32
      %245 = arith.extsi %244 : i32 to i64
      %246 = llvm.getelementptr %243[%245] : (!llvm.ptr, i64) -> !llvm.ptr, i32
      %241 = llvm.load %246 : !llvm.ptr -> i32
      %247 = llvm.load %117 : !llvm.ptr -> i32
      %248 = arith.cmpi ne, %241, %247 : i32
      cf.cond_br %248, ^bb45, ^bb46
      ^bb45:
        %249 = llvm.load %236 : !llvm.ptr -> i32
        %250 = arith.constant 1 : i32
        %251 = arith.addi %249, %250 : i32
        llvm.store %251, %236 : i32, !llvm.ptr
        cf.br ^bb42
      ^bb46:
        cf.br ^bb47
      ^bb47:
      %252 = arith.constant 1 : i32
      %253 = llvm.mlir.constant(1 : i64) : i64
      %254 = llvm.alloca %253 x i32 : (i64) -> !llvm.ptr
      llvm.store %252, %254 : i32, !llvm.ptr
      %255 = arith.constant 0 : i32
      %256 = llvm.mlir.constant(1 : i64) : i64
      %257 = llvm.alloca %256 x i32 : (i64) -> !llvm.ptr
      llvm.store %255, %257 : i32, !llvm.ptr
      cf.br ^bb48
      ^bb48:
      %258 = llvm.load %257 : !llvm.ptr -> i32
      %259 = llvm.load %117 : !llvm.ptr -> i32
      %260 = arith.cmpi slt, %258, %259 : i32
      cf.cond_br %260, ^bb49, ^bb50
      ^bb49:
        %262 = llvm.mlir.addressof @g_keys : !llvm.ptr
        %263 = llvm.load %262 : !llvm.ptr -> !llvm.ptr
        %264 = llvm.load %236 : !llvm.ptr -> i32
        %265 = llvm.mlir.addressof @MAX_KEY_LEN : !llvm.ptr
        %266 = llvm.load %265 : !llvm.ptr -> i32
        %267 = arith.muli %264, %266 : i32
        %268 = llvm.load %257 : !llvm.ptr -> i32
        %269 = arith.addi %267, %268 : i32
        %270 = arith.extsi %269 : i32 to i64
        %271 = llvm.getelementptr %263[%270] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %261 = llvm.load %271 : !llvm.ptr -> i64
        %273 = llvm.load %257 : !llvm.ptr -> i32
        %274 = arith.extsi %273 : i32 to i64
        %275 = llvm.getelementptr %110[%274] : (!llvm.ptr, i64) -> !llvm.ptr, i32
        %272 = llvm.load %275 : !llvm.ptr -> i32
        %276 = arith.extsi %272 : i32 to i64
        %277 = arith.cmpi ne, %261, %276 : i64
        cf.cond_br %277, ^bb51, ^bb52
        ^bb51:
          %278 = arith.constant 0 : i32
          llvm.store %278, %254 : i32, !llvm.ptr
          cf.br ^bb50
        ^bb52:
          cf.br ^bb53
        ^bb53:
        %279 = llvm.load %257 : !llvm.ptr -> i32
        %280 = arith.constant 1 : i32
        %281 = arith.addi %279, %280 : i32
        llvm.store %281, %257 : i32, !llvm.ptr
        cf.br ^bb48
      ^bb50:
      %282 = llvm.load %254 : !llvm.ptr -> i32
      %283 = arith.constant 1 : i32
      %284 = arith.cmpi eq, %282, %283 : i32
      cf.cond_br %284, ^bb54, ^bb55
      ^bb54:
        %285 = llvm.load %236 : !llvm.ptr -> i32
        llvm.store %285, %233 : i32, !llvm.ptr
        cf.br ^bb44
      ^bb55:
        cf.br ^bb56
      ^bb56:
      %286 = llvm.load %236 : !llvm.ptr -> i32
      %287 = arith.constant 1 : i32
      %288 = arith.addi %286, %287 : i32
      llvm.store %288, %236 : i32, !llvm.ptr
      cf.br ^bb42
    ^bb44:
    %289 = llvm.load %233 : !llvm.ptr -> i32
    %290 = arith.constant 0 : i32
    %291 = arith.cmpi sge, %289, %290 : i32
    cf.cond_br %291, ^bb57, ^bb58
    ^bb57:
      %293 = llvm.mlir.addressof @g_coeffs : !llvm.ptr
      %294 = llvm.load %293 : !llvm.ptr -> !llvm.ptr
      %295 = llvm.load %233 : !llvm.ptr -> i32
      %296 = arith.extsi %295 : i32 to i64
      %297 = llvm.getelementptr %294[%296] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %292 = llvm.load %297 : !llvm.ptr -> i64
      %298 = llvm.load %109 : !llvm.ptr -> i64
      %299 = arith.addi %292, %298 : i64
      %300 = llvm.mlir.addressof @g_coeffs : !llvm.ptr
      %301 = llvm.load %300 : !llvm.ptr -> !llvm.ptr
      %302 = llvm.load %233 : !llvm.ptr -> i32
      %303 = arith.extsi %302 : i32 to i64
      %304 = llvm.getelementptr %301[%303] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %299, %304 : i64, !llvm.ptr
      cf.br ^bb59
    ^bb58:
      %305 = llvm.mlir.addressof @g_nkeys : !llvm.ptr
      %306 = llvm.load %305 : !llvm.ptr -> i32
      %307 = llvm.mlir.addressof @g_nkeys : !llvm.ptr
      %308 = llvm.load %307 : !llvm.ptr -> i32
      %309 = arith.constant 1 : i32
      %310 = arith.addi %308, %309 : i32
      %311 = llvm.mlir.addressof @g_nkeys : !llvm.ptr
      llvm.store %310, %311 : i32, !llvm.ptr
      %312 = llvm.load %117 : !llvm.ptr -> i32
      %313 = llvm.mlir.addressof @g_key_lens : !llvm.ptr
      %314 = llvm.load %313 : !llvm.ptr -> !llvm.ptr
      %315 = arith.extsi %306 : i32 to i64
      %316 = llvm.getelementptr %314[%315] : (!llvm.ptr, i64) -> !llvm.ptr, i32
      llvm.store %312, %316 : i32, !llvm.ptr
      %317 = arith.constant 0 : i32
      %318 = llvm.mlir.constant(1 : i64) : i64
      %319 = llvm.alloca %318 x i32 : (i64) -> !llvm.ptr
      llvm.store %317, %319 : i32, !llvm.ptr
      cf.br ^bb60
      ^bb60:
      %320 = llvm.load %319 : !llvm.ptr -> i32
      %321 = llvm.load %117 : !llvm.ptr -> i32
      %322 = arith.cmpi slt, %320, %321 : i32
      cf.cond_br %322, ^bb61, ^bb62
      ^bb61:
        %324 = llvm.load %319 : !llvm.ptr -> i32
        %325 = arith.extsi %324 : i32 to i64
        %326 = llvm.getelementptr %110[%325] : (!llvm.ptr, i64) -> !llvm.ptr, i32
        %323 = llvm.load %326 : !llvm.ptr -> i32
        %327 = arith.extsi %323 : i32 to i64
        %328 = llvm.mlir.addressof @g_keys : !llvm.ptr
        %329 = llvm.load %328 : !llvm.ptr -> !llvm.ptr
        %330 = llvm.mlir.addressof @MAX_KEY_LEN : !llvm.ptr
        %331 = llvm.load %330 : !llvm.ptr -> i32
        %332 = arith.muli %306, %331 : i32
        %333 = llvm.load %319 : !llvm.ptr -> i32
        %334 = arith.addi %332, %333 : i32
        %335 = arith.extsi %334 : i32 to i64
        %336 = llvm.getelementptr %329[%335] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        llvm.store %327, %336 : i64, !llvm.ptr
        %337 = llvm.load %319 : !llvm.ptr -> i32
        %338 = arith.constant 1 : i32
        %339 = arith.addi %337, %338 : i32
        llvm.store %339, %319 : i32, !llvm.ptr
        cf.br ^bb60
      ^bb62:
      %340 = llvm.load %109 : !llvm.ptr -> i64
      %341 = llvm.mlir.addressof @g_coeffs : !llvm.ptr
      %342 = llvm.load %341 : !llvm.ptr -> !llvm.ptr
      %343 = arith.extsi %306 : i32 to i64
      %344 = llvm.getelementptr %342[%343] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %340, %344 : i64, !llvm.ptr
      cf.br ^bb59
    ^bb59:
    func.call @free(%110) : (!llvm.ptr) -> ()
    func.return
  }
  func.func @recurse_partition(%arg0: i32) -> () {
    %346 = llvm.mlir.addressof @NSLOTS : !llvm.ptr
    %347 = llvm.load %346 : !llvm.ptr -> i32
    %348 = arith.cmpi eq, %arg0, %347 : i32
    cf.cond_br %348, ^bb63, ^bb64
    ^bb63:
      func.call @process_partition() : () -> ()
      func.return
    ^bb64:
      cf.br ^bb65
    ^bb65:
    %350 = arith.constant 0 : i32
    %351 = llvm.mlir.constant(1 : i64) : i64
    %352 = llvm.alloca %351 x i32 : (i64) -> !llvm.ptr
    llvm.store %350, %352 : i32, !llvm.ptr
    cf.br ^bb66
    ^bb66:
    %353 = llvm.load %352 : !llvm.ptr -> i32
    %354 = llvm.mlir.addressof @g_n_blocks : !llvm.ptr
    %355 = llvm.load %354 : !llvm.ptr -> i32
    %356 = arith.cmpi slt, %353, %355 : i32
    cf.cond_br %356, ^bb67, ^bb68
    ^bb67:
      %357 = llvm.mlir.addressof @g_block_members : !llvm.ptr
      %358 = llvm.load %357 : !llvm.ptr -> !llvm.ptr
      %359 = llvm.load %352 : !llvm.ptr -> i32
      %360 = arith.constant 10 : i32
      %361 = arith.muli %359, %360 : i32
      %363 = llvm.mlir.addressof @g_block_sizes : !llvm.ptr
      %364 = llvm.load %363 : !llvm.ptr -> !llvm.ptr
      %365 = llvm.load %352 : !llvm.ptr -> i32
      %366 = arith.extsi %365 : i32 to i64
      %367 = llvm.getelementptr %364[%366] : (!llvm.ptr, i64) -> !llvm.ptr, i32
      %362 = llvm.load %367 : !llvm.ptr -> i32
      %368 = arith.addi %361, %362 : i32
      %369 = arith.extsi %368 : i32 to i64
      %370 = llvm.getelementptr %358[%369] : (!llvm.ptr, i64) -> !llvm.ptr, i32
      llvm.store %arg0, %370 : i32, !llvm.ptr
      %372 = llvm.mlir.addressof @g_block_sizes : !llvm.ptr
      %373 = llvm.load %372 : !llvm.ptr -> !llvm.ptr
      %374 = llvm.load %352 : !llvm.ptr -> i32
      %375 = arith.extsi %374 : i32 to i64
      %376 = llvm.getelementptr %373[%375] : (!llvm.ptr, i64) -> !llvm.ptr, i32
      %371 = llvm.load %376 : !llvm.ptr -> i32
      %377 = arith.constant 1 : i32
      %378 = arith.addi %371, %377 : i32
      %379 = llvm.mlir.addressof @g_block_sizes : !llvm.ptr
      %380 = llvm.load %379 : !llvm.ptr -> !llvm.ptr
      %381 = llvm.load %352 : !llvm.ptr -> i32
      %382 = arith.extsi %381 : i32 to i64
      %383 = llvm.getelementptr %380[%382] : (!llvm.ptr, i64) -> !llvm.ptr, i32
      llvm.store %378, %383 : i32, !llvm.ptr
      %385 = arith.constant 1 : i32
      %386 = arith.addi %arg0, %385 : i32
      func.call @recurse_partition(%386) : (i32) -> ()
      %388 = llvm.mlir.addressof @g_block_sizes : !llvm.ptr
      %389 = llvm.load %388 : !llvm.ptr -> !llvm.ptr
      %390 = llvm.load %352 : !llvm.ptr -> i32
      %391 = arith.extsi %390 : i32 to i64
      %392 = llvm.getelementptr %389[%391] : (!llvm.ptr, i64) -> !llvm.ptr, i32
      %387 = llvm.load %392 : !llvm.ptr -> i32
      %393 = arith.constant 1 : i32
      %394 = arith.subi %387, %393 : i32
      %395 = llvm.mlir.addressof @g_block_sizes : !llvm.ptr
      %396 = llvm.load %395 : !llvm.ptr -> !llvm.ptr
      %397 = llvm.load %352 : !llvm.ptr -> i32
      %398 = arith.extsi %397 : i32 to i64
      %399 = llvm.getelementptr %396[%398] : (!llvm.ptr, i64) -> !llvm.ptr, i32
      llvm.store %394, %399 : i32, !llvm.ptr
      %400 = llvm.load %352 : !llvm.ptr -> i32
      %401 = arith.constant 1 : i32
      %402 = arith.addi %400, %401 : i32
      llvm.store %402, %352 : i32, !llvm.ptr
      cf.br ^bb66
    ^bb68:
    %403 = llvm.mlir.addressof @g_block_members : !llvm.ptr
    %404 = llvm.load %403 : !llvm.ptr -> !llvm.ptr
    %405 = llvm.mlir.addressof @g_n_blocks : !llvm.ptr
    %406 = llvm.load %405 : !llvm.ptr -> i32
    %407 = arith.constant 10 : i32
    %408 = arith.muli %406, %407 : i32
    %409 = arith.constant 0 : i32
    %410 = arith.addi %408, %409 : i32
    %411 = arith.extsi %410 : i32 to i64
    %412 = llvm.getelementptr %404[%411] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    llvm.store %arg0, %412 : i32, !llvm.ptr
    %413 = arith.constant 1 : i32
    %414 = llvm.mlir.addressof @g_block_sizes : !llvm.ptr
    %415 = llvm.load %414 : !llvm.ptr -> !llvm.ptr
    %416 = llvm.mlir.addressof @g_n_blocks : !llvm.ptr
    %417 = llvm.load %416 : !llvm.ptr -> i32
    %418 = arith.extsi %417 : i32 to i64
    %419 = llvm.getelementptr %415[%418] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    llvm.store %413, %419 : i32, !llvm.ptr
    %420 = llvm.mlir.addressof @g_n_blocks : !llvm.ptr
    %421 = llvm.load %420 : !llvm.ptr -> i32
    %422 = arith.constant 1 : i32
    %423 = arith.addi %421, %422 : i32
    %424 = llvm.mlir.addressof @g_n_blocks : !llvm.ptr
    llvm.store %423, %424 : i32, !llvm.ptr
    %426 = arith.constant 1 : i32
    %427 = arith.addi %arg0, %426 : i32
    func.call @recurse_partition(%427) : (i32) -> ()
    %428 = llvm.mlir.addressof @g_n_blocks : !llvm.ptr
    %429 = llvm.load %428 : !llvm.ptr -> i32
    %430 = arith.constant 1 : i32
    %431 = arith.subi %429, %430 : i32
    %432 = llvm.mlir.addressof @g_n_blocks : !llvm.ptr
    llvm.store %431, %432 : i32, !llvm.ptr
    func.return
  }
  func.func @build_partitions() -> () {
    %434 = llvm.mlir.addressof @MAX_KEYS : !llvm.ptr
    %435 = llvm.load %434 : !llvm.ptr -> i32
    %436 = arith.extsi %435 : i32 to i64
    %437 = llvm.mlir.addressof @MAX_KEY_LEN : !llvm.ptr
    %438 = llvm.load %437 : !llvm.ptr -> i32
    %439 = arith.extsi %438 : i32 to i64
    %440 = arith.muli %436, %439 : i64
    %441 = arith.constant 8 : i32
    %442 = arith.extsi %441 : i32 to i64
    %433 = func.call @calloc(%440, %442) : (i64, i64) -> !llvm.ptr
    %443 = llvm.mlir.addressof @g_keys : !llvm.ptr
    llvm.store %433, %443 : !llvm.ptr, !llvm.ptr
    %445 = llvm.mlir.addressof @MAX_KEYS : !llvm.ptr
    %446 = llvm.load %445 : !llvm.ptr -> i32
    %447 = arith.extsi %446 : i32 to i64
    %448 = arith.constant 4 : i32
    %449 = arith.extsi %448 : i32 to i64
    %444 = func.call @calloc(%447, %449) : (i64, i64) -> !llvm.ptr
    %450 = llvm.mlir.addressof @g_key_lens : !llvm.ptr
    llvm.store %444, %450 : !llvm.ptr, !llvm.ptr
    %452 = llvm.mlir.addressof @MAX_KEYS : !llvm.ptr
    %453 = llvm.load %452 : !llvm.ptr -> i32
    %454 = arith.extsi %453 : i32 to i64
    %455 = arith.constant 8 : i32
    %456 = arith.extsi %455 : i32 to i64
    %451 = func.call @calloc(%454, %456) : (i64, i64) -> !llvm.ptr
    %457 = llvm.mlir.addressof @g_coeffs : !llvm.ptr
    llvm.store %451, %457 : !llvm.ptr, !llvm.ptr
    %459 = arith.constant 100 : i32
    %460 = arith.constant 4 : i32
    %461 = arith.extsi %459 : i32 to i64
    %462 = arith.extsi %460 : i32 to i64
    %458 = func.call @calloc(%461, %462) : (i64, i64) -> !llvm.ptr
    %463 = llvm.mlir.addressof @g_block_members : !llvm.ptr
    llvm.store %458, %463 : !llvm.ptr, !llvm.ptr
    %465 = arith.constant 10 : i32
    %466 = arith.constant 4 : i32
    %467 = arith.extsi %465 : i32 to i64
    %468 = arith.extsi %466 : i32 to i64
    %464 = func.call @calloc(%467, %468) : (i64, i64) -> !llvm.ptr
    %469 = llvm.mlir.addressof @g_block_sizes : !llvm.ptr
    llvm.store %464, %469 : !llvm.ptr, !llvm.ptr
    %470 = arith.constant 0 : i32
    %471 = llvm.mlir.addressof @g_nkeys : !llvm.ptr
    llvm.store %470, %471 : i32, !llvm.ptr
    %472 = arith.constant 0 : i32
    %473 = llvm.mlir.addressof @g_n_blocks : !llvm.ptr
    llvm.store %472, %473 : i32, !llvm.ptr
    %475 = arith.constant 0 : i32
    func.call @recurse_partition(%475) : (i32) -> ()
    func.return
  }
  func.func @sieve_primes(%arg0: i32, %arg1: !llvm.ptr) -> !llvm.ptr {
    %477 = arith.constant 1 : i32
    %478 = arith.addi %arg0, %477 : i32
    %479 = arith.extsi %478 : i32 to i64
    %480 = arith.constant 1 : i32
    %481 = arith.extsi %480 : i32 to i64
    %476 = func.call @calloc(%479, %481) : (i64, i64) -> !llvm.ptr
    %482 = arith.constant 0 : i32
    %483 = llvm.mlir.constant(1 : i64) : i64
    %484 = llvm.alloca %483 x i32 : (i64) -> !llvm.ptr
    llvm.store %482, %484 : i32, !llvm.ptr
    %485 = arith.constant 2 : i32
    %486 = llvm.mlir.constant(1 : i64) : i64
    %487 = llvm.alloca %486 x i32 : (i64) -> !llvm.ptr
    llvm.store %485, %487 : i32, !llvm.ptr
    cf.br ^bb69
    ^bb69:
    %488 = llvm.load %487 : !llvm.ptr -> i32
    %489 = arith.cmpi sle, %488, %arg0 : i32
    cf.cond_br %489, ^bb70, ^bb71
    ^bb70:
      %491 = llvm.load %487 : !llvm.ptr -> i32
      %492 = arith.extsi %491 : i32 to i64
      %493 = llvm.getelementptr %476[%492] : (!llvm.ptr, i64) -> !llvm.ptr, i8
      %490 = llvm.load %493 : !llvm.ptr -> i8
      %494 = arith.constant 0 : i32
      %496 = arith.extsi %490 : i8 to i32
      %495 = arith.cmpi eq, %496, %494 : i32
      cf.cond_br %495, ^bb72, ^bb73
      ^bb72:
        %497 = llvm.load %484 : !llvm.ptr -> i32
        %498 = arith.constant 1 : i32
        %499 = arith.addi %497, %498 : i32
        llvm.store %499, %484 : i32, !llvm.ptr
        %500 = llvm.load %487 : !llvm.ptr -> i32
        %501 = arith.extsi %500 : i32 to i64
        %502 = llvm.load %487 : !llvm.ptr -> i32
        %503 = arith.extsi %502 : i32 to i64
        %504 = arith.muli %501, %503 : i64
        %505 = llvm.mlir.constant(1 : i64) : i64
        %506 = llvm.alloca %505 x i64 : (i64) -> !llvm.ptr
        llvm.store %504, %506 : i64, !llvm.ptr
        cf.br ^bb75
        ^bb75:
        %507 = llvm.load %506 : !llvm.ptr -> i64
        %508 = arith.extsi %arg0 : i32 to i64
        %509 = arith.cmpi sle, %507, %508 : i64
        cf.cond_br %509, ^bb76, ^bb77
        ^bb76:
          %510 = arith.constant 1 : i32
          %511 = llvm.load %506 : !llvm.ptr -> i64
          %512 = arith.trunci %510 : i32 to i8
          %513 = llvm.getelementptr %476[%511] : (!llvm.ptr, i64) -> !llvm.ptr, i8
          llvm.store %512, %513 : i8, !llvm.ptr
          %514 = llvm.load %506 : !llvm.ptr -> i64
          %515 = llvm.load %487 : !llvm.ptr -> i32
          %516 = arith.extsi %515 : i32 to i64
          %517 = arith.addi %514, %516 : i64
          llvm.store %517, %506 : i64, !llvm.ptr
          cf.br ^bb75
        ^bb77:
        cf.br ^bb74
      ^bb73:
        cf.br ^bb74
      ^bb74:
      %518 = llvm.load %487 : !llvm.ptr -> i32
      %519 = arith.constant 1 : i32
      %520 = arith.addi %518, %519 : i32
      llvm.store %520, %487 : i32, !llvm.ptr
      cf.br ^bb69
    ^bb71:
    %522 = llvm.load %484 : !llvm.ptr -> i32
    %523 = arith.extsi %522 : i32 to i64
    %524 = arith.constant 4 : i32
    %525 = arith.extsi %524 : i32 to i64
    %521 = func.call @calloc(%523, %525) : (i64, i64) -> !llvm.ptr
    %526 = arith.constant 0 : i32
    %527 = llvm.mlir.constant(1 : i64) : i64
    %528 = llvm.alloca %527 x i32 : (i64) -> !llvm.ptr
    llvm.store %526, %528 : i32, !llvm.ptr
    %529 = arith.constant 2 : i32
    %530 = llvm.mlir.constant(1 : i64) : i64
    %531 = llvm.alloca %530 x i32 : (i64) -> !llvm.ptr
    llvm.store %529, %531 : i32, !llvm.ptr
    cf.br ^bb78
    ^bb78:
    %532 = llvm.load %531 : !llvm.ptr -> i32
    %533 = arith.cmpi sle, %532, %arg0 : i32
    cf.cond_br %533, ^bb79, ^bb80
    ^bb79:
      %535 = llvm.load %531 : !llvm.ptr -> i32
      %536 = arith.extsi %535 : i32 to i64
      %537 = llvm.getelementptr %476[%536] : (!llvm.ptr, i64) -> !llvm.ptr, i8
      %534 = llvm.load %537 : !llvm.ptr -> i8
      %538 = arith.constant 0 : i32
      %540 = arith.extsi %534 : i8 to i32
      %539 = arith.cmpi eq, %540, %538 : i32
      cf.cond_br %539, ^bb81, ^bb82
      ^bb81:
        %541 = llvm.load %531 : !llvm.ptr -> i32
        %542 = llvm.load %528 : !llvm.ptr -> i32
        %543 = arith.extsi %542 : i32 to i64
        %544 = llvm.getelementptr %521[%543] : (!llvm.ptr, i64) -> !llvm.ptr, i32
        llvm.store %541, %544 : i32, !llvm.ptr
        %545 = llvm.load %528 : !llvm.ptr -> i32
        %546 = arith.constant 1 : i32
        %547 = arith.addi %545, %546 : i32
        llvm.store %547, %528 : i32, !llvm.ptr
        cf.br ^bb83
      ^bb82:
        cf.br ^bb83
      ^bb83:
      %548 = llvm.load %531 : !llvm.ptr -> i32
      %549 = arith.constant 1 : i32
      %550 = arith.addi %548, %549 : i32
      llvm.store %550, %531 : i32, !llvm.ptr
      cf.br ^bb78
    ^bb80:
    func.call @free(%476) : (!llvm.ptr) -> ()
    %552 = llvm.load %484 : !llvm.ptr -> i32
    %553 = arith.constant 0 : i32
    %554 = arith.extsi %553 : i32 to i64
    %555 = llvm.getelementptr %arg1[%554] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    llvm.store %552, %555 : i32, !llvm.ptr
    func.return %521 : !llvm.ptr
  }
  func.func @factorial_prime_exp(%arg0: i32, %arg1: i32) -> i32 {
    %556 = arith.constant 0 : i32
    %557 = llvm.mlir.constant(1 : i64) : i64
    %558 = llvm.alloca %557 x i32 : (i64) -> !llvm.ptr
    llvm.store %556, %558 : i32, !llvm.ptr
    %559 = arith.extsi %arg0 : i32 to i64
    %560 = llvm.mlir.constant(1 : i64) : i64
    %561 = llvm.alloca %560 x i64 : (i64) -> !llvm.ptr
    llvm.store %559, %561 : i64, !llvm.ptr
    cf.br ^bb84
    ^bb84:
    %562 = llvm.load %561 : !llvm.ptr -> i64
    %563 = arith.constant 0 : i32
    %565 = arith.extsi %563 : i32 to i64
    %564 = arith.cmpi sgt, %562, %565 : i64
    cf.cond_br %564, ^bb85, ^bb86
    ^bb85:
      %566 = llvm.load %561 : !llvm.ptr -> i64
      %567 = arith.extsi %arg1 : i32 to i64
      %568 = arith.divsi %566, %567 : i64
      llvm.store %568, %561 : i64, !llvm.ptr
      %569 = llvm.load %558 : !llvm.ptr -> i32
      %570 = llvm.load %561 : !llvm.ptr -> i64
      %571 = arith.trunci %570 : i64 to i32
      %572 = arith.addi %569, %571 : i32
      llvm.store %572, %558 : i32, !llvm.ptr
      cf.br ^bb84
    ^bb86:
    %573 = llvm.load %558 : !llvm.ptr -> i32
    func.return %573 : i32
  }
  func.func @coeffs_up_to(%arg0: !llvm.ptr, %arg1: i32, %arg2: i32, %arg3: !llvm.ptr) -> () {
    %575 = arith.constant 0 : i32
    %576 = arith.constant 1 : i32
    %577 = arith.addi %arg2, %576 : i32
    %578 = arith.extsi %577 : i32 to i64
    %579 = arith.constant 8 : i32
    %581 = arith.extsi %579 : i32 to i64
    %580 = arith.muli %578, %581 : i64
    %574 = func.call @memset(%arg3, %575, %580) : (!llvm.ptr, i32, i64) -> !llvm.ptr
    %582 = arith.constant 1 : i32
    %583 = arith.constant 0 : i32
    %584 = arith.extsi %582 : i32 to i64
    %585 = arith.extsi %583 : i32 to i64
    %586 = llvm.getelementptr %arg3[%585] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    llvm.store %584, %586 : i64, !llvm.ptr
    %587 = arith.constant 0 : i32
    %588 = llvm.mlir.constant(1 : i64) : i64
    %589 = llvm.alloca %588 x i32 : (i64) -> !llvm.ptr
    llvm.store %587, %589 : i32, !llvm.ptr
    cf.br ^bb87
    ^bb87:
    %590 = llvm.load %589 : !llvm.ptr -> i32
    %591 = arith.cmpi slt, %590, %arg1 : i32
    cf.cond_br %591, ^bb88, ^bb89
    ^bb88:
      %593 = llvm.load %589 : !llvm.ptr -> i32
      %594 = arith.extsi %593 : i32 to i64
      %595 = llvm.getelementptr %arg0[%594] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %592 = llvm.load %595 : !llvm.ptr -> i64
      %596 = arith.trunci %592 : i64 to i32
      %597 = llvm.mlir.constant(1 : i64) : i64
      %598 = llvm.alloca %597 x i32 : (i64) -> !llvm.ptr
      llvm.store %596, %598 : i32, !llvm.ptr
      cf.br ^bb90
      ^bb90:
      %599 = llvm.load %598 : !llvm.ptr -> i32
      %600 = arith.cmpi sle, %599, %arg2 : i32
      cf.cond_br %600, ^bb91, ^bb92
      ^bb91:
        %602 = llvm.load %598 : !llvm.ptr -> i32
        %603 = arith.extsi %602 : i32 to i64
        %604 = llvm.getelementptr %arg3[%603] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %601 = llvm.load %604 : !llvm.ptr -> i64
        %606 = llvm.load %598 : !llvm.ptr -> i32
        %607 = arith.subi %606, %596 : i32
        %608 = arith.extsi %607 : i32 to i64
        %609 = llvm.getelementptr %arg3[%608] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %605 = llvm.load %609 : !llvm.ptr -> i64
        %610 = arith.addi %601, %605 : i64
        %611 = llvm.mlir.addressof @MOD : !llvm.ptr
        %612 = llvm.load %611 : !llvm.ptr -> i64
        %613 = arith.cmpi sge, %610, %612 : i64
        %614 = scf.if %613 -> (i64) {
          %615 = llvm.mlir.addressof @MOD : !llvm.ptr
          %616 = llvm.load %615 : !llvm.ptr -> i64
          %617 = arith.subi %610, %616 : i64
          scf.yield %617 : i64
        } else {
          scf.yield %610 : i64
        }
        %618 = llvm.load %598 : !llvm.ptr -> i32
        %619 = arith.extsi %618 : i32 to i64
        %620 = llvm.getelementptr %arg3[%619] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        llvm.store %614, %620 : i64, !llvm.ptr
        %621 = llvm.load %598 : !llvm.ptr -> i32
        %622 = arith.constant 1 : i32
        %623 = arith.addi %621, %622 : i32
        llvm.store %623, %598 : i32, !llvm.ptr
        cf.br ^bb90
      ^bb92:
      %624 = llvm.load %589 : !llvm.ptr -> i32
      %625 = arith.constant 1 : i32
      %626 = arith.addi %624, %625 : i32
      llvm.store %626, %589 : i32, !llvm.ptr
      cf.br ^bb87
    ^bb89:
    func.return
  }
  func.func @poly_Q_from_key(%arg0: !llvm.ptr, %arg1: i32, %arg2: !llvm.ptr) -> () {
    %628 = arith.constant 0 : i32
    %629 = llvm.mlir.addressof @D : !llvm.ptr
    %630 = llvm.load %629 : !llvm.ptr -> i32
    %631 = arith.constant 1 : i32
    %632 = arith.addi %630, %631 : i32
    %633 = arith.extsi %632 : i32 to i64
    %634 = arith.constant 8 : i32
    %636 = arith.extsi %634 : i32 to i64
    %635 = arith.muli %633, %636 : i64
    %627 = func.call @memset(%arg2, %628, %635) : (!llvm.ptr, i32, i64) -> !llvm.ptr
    %637 = arith.constant 1 : i32
    %638 = arith.constant 0 : i32
    %639 = arith.extsi %637 : i32 to i64
    %640 = arith.extsi %638 : i32 to i64
    %641 = llvm.getelementptr %arg2[%640] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    llvm.store %639, %641 : i64, !llvm.ptr
    %642 = arith.constant 0 : i32
    %643 = llvm.mlir.constant(1 : i64) : i64
    %644 = llvm.alloca %643 x i32 : (i64) -> !llvm.ptr
    llvm.store %642, %644 : i32, !llvm.ptr
    cf.br ^bb93
    ^bb93:
    %645 = llvm.load %644 : !llvm.ptr -> i32
    %646 = arith.cmpi slt, %645, %arg1 : i32
    cf.cond_br %646, ^bb94, ^bb95
    ^bb94:
      %648 = llvm.load %644 : !llvm.ptr -> i32
      %649 = arith.extsi %648 : i32 to i64
      %650 = llvm.getelementptr %arg0[%649] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %647 = llvm.load %650 : !llvm.ptr -> i64
      %651 = arith.trunci %647 : i64 to i32
      %652 = llvm.mlir.addressof @D : !llvm.ptr
      %653 = llvm.load %652 : !llvm.ptr -> i32
      %654 = arith.subi %653, %651 : i32
      %655 = llvm.mlir.constant(1 : i64) : i64
      %656 = llvm.alloca %655 x i32 : (i64) -> !llvm.ptr
      llvm.store %654, %656 : i32, !llvm.ptr
      cf.br ^bb96
      ^bb96:
      %657 = llvm.load %656 : !llvm.ptr -> i32
      %658 = arith.constant 0 : i32
      %659 = arith.cmpi sge, %657, %658 : i32
      cf.cond_br %659, ^bb97, ^bb98
      ^bb97:
        %661 = llvm.load %656 : !llvm.ptr -> i32
        %662 = arith.addi %661, %651 : i32
        %663 = arith.extsi %662 : i32 to i64
        %664 = llvm.getelementptr %arg2[%663] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %660 = llvm.load %664 : !llvm.ptr -> i64
        %666 = llvm.load %656 : !llvm.ptr -> i32
        %667 = arith.extsi %666 : i32 to i64
        %668 = llvm.getelementptr %arg2[%667] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %665 = llvm.load %668 : !llvm.ptr -> i64
        %669 = arith.subi %660, %665 : i64
        %670 = llvm.load %656 : !llvm.ptr -> i32
        %671 = arith.addi %670, %651 : i32
        %672 = arith.extsi %671 : i32 to i64
        %673 = llvm.getelementptr %arg2[%672] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        llvm.store %669, %673 : i64, !llvm.ptr
        %674 = llvm.load %656 : !llvm.ptr -> i32
        %675 = arith.constant 1 : i32
        %676 = arith.subi %674, %675 : i32
        llvm.store %676, %656 : i32, !llvm.ptr
        cf.br ^bb96
      ^bb98:
      %677 = llvm.load %644 : !llvm.ptr -> i32
      %678 = arith.constant 1 : i32
      %679 = arith.addi %677, %678 : i32
      llvm.store %679, %644 : i32, !llvm.ptr
      cf.br ^bb93
    ^bb95:
    func.return
  }
  func.func @mul_mod_poly(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: !llvm.ptr, %arg3: !llvm.ptr) -> () {
    %681 = arith.constant 2 : i32
    %682 = llvm.mlir.addressof @D : !llvm.ptr
    %683 = llvm.load %682 : !llvm.ptr -> i32
    %684 = arith.muli %681, %683 : i32
    %685 = arith.constant 1 : i32
    %686 = arith.subi %684, %685 : i32
    %687 = arith.extsi %686 : i32 to i64
    %688 = arith.constant 8 : i32
    %689 = arith.extsi %688 : i32 to i64
    %680 = func.call @calloc(%687, %689) : (i64, i64) -> !llvm.ptr
    %690 = arith.constant 0 : i32
    %691 = llvm.mlir.constant(1 : i64) : i64
    %692 = llvm.alloca %691 x i32 : (i64) -> !llvm.ptr
    llvm.store %690, %692 : i32, !llvm.ptr
    cf.br ^bb99
    ^bb99:
    %693 = llvm.load %692 : !llvm.ptr -> i32
    %694 = llvm.mlir.addressof @D : !llvm.ptr
    %695 = llvm.load %694 : !llvm.ptr -> i32
    %696 = arith.cmpi slt, %693, %695 : i32
    cf.cond_br %696, ^bb100, ^bb101
    ^bb100:
      %698 = llvm.load %692 : !llvm.ptr -> i32
      %699 = arith.extsi %698 : i32 to i64
      %700 = llvm.getelementptr %arg0[%699] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %697 = llvm.load %700 : !llvm.ptr -> i64
      %701 = arith.constant 0 : i32
      %703 = arith.extsi %701 : i32 to i64
      %702 = arith.cmpi eq, %697, %703 : i64
      cf.cond_br %702, ^bb102, ^bb103
      ^bb102:
        %704 = llvm.load %692 : !llvm.ptr -> i32
        %705 = arith.constant 1 : i32
        %706 = arith.addi %704, %705 : i32
        llvm.store %706, %692 : i32, !llvm.ptr
        cf.br ^bb99
      ^bb103:
        cf.br ^bb104
      ^bb104:
      %707 = arith.constant 0 : i32
      %708 = llvm.mlir.constant(1 : i64) : i64
      %709 = llvm.alloca %708 x i32 : (i64) -> !llvm.ptr
      llvm.store %707, %709 : i32, !llvm.ptr
      cf.br ^bb105
      ^bb105:
      %710 = llvm.load %709 : !llvm.ptr -> i32
      %711 = llvm.mlir.addressof @D : !llvm.ptr
      %712 = llvm.load %711 : !llvm.ptr -> i32
      %713 = arith.cmpi slt, %710, %712 : i32
      cf.cond_br %713, ^bb106, ^bb107
      ^bb106:
        %715 = llvm.load %709 : !llvm.ptr -> i32
        %716 = arith.extsi %715 : i32 to i64
        %717 = llvm.getelementptr %arg1[%716] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %714 = llvm.load %717 : !llvm.ptr -> i64
        %718 = arith.constant 0 : i32
        %720 = arith.extsi %718 : i32 to i64
        %719 = arith.cmpi eq, %714, %720 : i64
        cf.cond_br %719, ^bb108, ^bb109
        ^bb108:
          %721 = llvm.load %709 : !llvm.ptr -> i32
          %722 = arith.constant 1 : i32
          %723 = arith.addi %721, %722 : i32
          llvm.store %723, %709 : i32, !llvm.ptr
          cf.br ^bb105
        ^bb109:
          cf.br ^bb110
        ^bb110:
        %726 = llvm.load %692 : !llvm.ptr -> i32
        %727 = llvm.load %709 : !llvm.ptr -> i32
        %728 = arith.addi %726, %727 : i32
        %729 = arith.extsi %728 : i32 to i64
        %730 = llvm.getelementptr %680[%729] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %725 = llvm.load %730 : !llvm.ptr -> i64
        %733 = llvm.load %692 : !llvm.ptr -> i32
        %734 = arith.extsi %733 : i32 to i64
        %735 = llvm.getelementptr %arg0[%734] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %732 = llvm.load %735 : !llvm.ptr -> i64
        %737 = llvm.load %709 : !llvm.ptr -> i32
        %738 = arith.extsi %737 : i32 to i64
        %739 = llvm.getelementptr %arg1[%738] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %736 = llvm.load %739 : !llvm.ptr -> i64
        %731 = func.call @mod_mul(%732, %736) : (i64, i64) -> i64
        %724 = func.call @mod_add(%725, %731) : (i64, i64) -> i64
        %740 = llvm.load %692 : !llvm.ptr -> i32
        %741 = llvm.load %709 : !llvm.ptr -> i32
        %742 = arith.addi %740, %741 : i32
        %743 = arith.extsi %742 : i32 to i64
        %744 = llvm.getelementptr %680[%743] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        llvm.store %724, %744 : i64, !llvm.ptr
        %745 = llvm.load %709 : !llvm.ptr -> i32
        %746 = arith.constant 1 : i32
        %747 = arith.addi %745, %746 : i32
        llvm.store %747, %709 : i32, !llvm.ptr
        cf.br ^bb105
      ^bb107:
      %748 = llvm.load %692 : !llvm.ptr -> i32
      %749 = arith.constant 1 : i32
      %750 = arith.addi %748, %749 : i32
      llvm.store %750, %692 : i32, !llvm.ptr
      cf.br ^bb99
    ^bb101:
    %751 = arith.constant 2 : i32
    %752 = llvm.mlir.addressof @D : !llvm.ptr
    %753 = llvm.load %752 : !llvm.ptr -> i32
    %754 = arith.muli %751, %753 : i32
    %755 = arith.constant 2 : i32
    %756 = arith.subi %754, %755 : i32
    %757 = llvm.mlir.constant(1 : i64) : i64
    %758 = llvm.alloca %757 x i32 : (i64) -> !llvm.ptr
    llvm.store %756, %758 : i32, !llvm.ptr
    cf.br ^bb111
    ^bb111:
    %759 = llvm.load %758 : !llvm.ptr -> i32
    %760 = llvm.mlir.addressof @D : !llvm.ptr
    %761 = llvm.load %760 : !llvm.ptr -> i32
    %762 = arith.cmpi sge, %759, %761 : i32
    cf.cond_br %762, ^bb112, ^bb113
    ^bb112:
      %764 = llvm.load %758 : !llvm.ptr -> i32
      %765 = arith.extsi %764 : i32 to i64
      %766 = llvm.getelementptr %680[%765] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %763 = llvm.load %766 : !llvm.ptr -> i64
      %767 = arith.constant 0 : i32
      %769 = arith.extsi %767 : i32 to i64
      %768 = arith.cmpi eq, %763, %769 : i64
      cf.cond_br %768, ^bb114, ^bb115
      ^bb114:
        %770 = llvm.load %758 : !llvm.ptr -> i32
        %771 = arith.constant 1 : i32
        %772 = arith.subi %770, %771 : i32
        llvm.store %772, %758 : i32, !llvm.ptr
        cf.br ^bb111
      ^bb115:
        cf.br ^bb116
      ^bb116:
      %773 = arith.constant 0 : i32
      %774 = llvm.mlir.constant(1 : i64) : i64
      %775 = llvm.alloca %774 x i32 : (i64) -> !llvm.ptr
      llvm.store %773, %775 : i32, !llvm.ptr
      cf.br ^bb117
      ^bb117:
      %776 = llvm.load %775 : !llvm.ptr -> i32
      %777 = llvm.mlir.addressof @D : !llvm.ptr
      %778 = llvm.load %777 : !llvm.ptr -> i32
      %779 = arith.cmpi slt, %776, %778 : i32
      cf.cond_br %779, ^bb118, ^bb119
      ^bb118:
        %780 = llvm.load %758 : !llvm.ptr -> i32
        %781 = arith.constant 1 : i32
        %782 = arith.subi %780, %781 : i32
        %783 = llvm.load %775 : !llvm.ptr -> i32
        %784 = arith.subi %782, %783 : i32
        %787 = arith.extsi %784 : i32 to i64
        %788 = llvm.getelementptr %680[%787] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %786 = llvm.load %788 : !llvm.ptr -> i64
        %791 = llvm.load %775 : !llvm.ptr -> i32
        %792 = arith.extsi %791 : i32 to i64
        %793 = llvm.getelementptr %arg2[%792] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %790 = llvm.load %793 : !llvm.ptr -> i64
        %789 = func.call @mod_mul(%763, %790) : (i64, i64) -> i64
        %785 = func.call @mod_add(%786, %789) : (i64, i64) -> i64
        %794 = arith.extsi %784 : i32 to i64
        %795 = llvm.getelementptr %680[%794] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        llvm.store %785, %795 : i64, !llvm.ptr
        %796 = llvm.load %775 : !llvm.ptr -> i32
        %797 = arith.constant 1 : i32
        %798 = arith.addi %796, %797 : i32
        llvm.store %798, %775 : i32, !llvm.ptr
        cf.br ^bb117
      ^bb119:
      %799 = llvm.load %758 : !llvm.ptr -> i32
      %800 = arith.constant 1 : i32
      %801 = arith.subi %799, %800 : i32
      llvm.store %801, %758 : i32, !llvm.ptr
      cf.br ^bb111
    ^bb113:
    %803 = llvm.mlir.addressof @D : !llvm.ptr
    %804 = llvm.load %803 : !llvm.ptr -> i32
    %805 = arith.extsi %804 : i32 to i64
    %806 = arith.constant 8 : i32
    %808 = arith.extsi %806 : i32 to i64
    %807 = arith.muli %805, %808 : i64
    %802 = func.call @memcpy(%arg3, %680, %807) : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr
    func.call @free(%680) : (!llvm.ptr) -> ()
    func.return
  }
  func.func @precompute_x_powers(%arg0: !llvm.ptr, %arg1: i32, %arg2: !llvm.ptr) -> () {
    %811 = arith.constant 0 : i32
    %812 = llvm.mlir.addressof @D : !llvm.ptr
    %813 = llvm.load %812 : !llvm.ptr -> i32
    %814 = arith.muli %arg1, %813 : i32
    %815 = arith.extsi %814 : i32 to i64
    %816 = arith.constant 8 : i32
    %818 = arith.extsi %816 : i32 to i64
    %817 = arith.muli %815, %818 : i64
    %810 = func.call @memset(%arg2, %811, %817) : (!llvm.ptr, i32, i64) -> !llvm.ptr
    %819 = arith.constant 1 : i32
    %820 = arith.constant 1 : i32
    %821 = arith.extsi %819 : i32 to i64
    %822 = arith.extsi %820 : i32 to i64
    %823 = llvm.getelementptr %arg2[%822] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    llvm.store %821, %823 : i64, !llvm.ptr
    %824 = arith.constant 1 : i32
    %825 = llvm.mlir.constant(1 : i64) : i64
    %826 = llvm.alloca %825 x i32 : (i64) -> !llvm.ptr
    llvm.store %824, %826 : i32, !llvm.ptr
    cf.br ^bb120
    ^bb120:
    %827 = llvm.load %826 : !llvm.ptr -> i32
    %828 = arith.cmpi slt, %827, %arg1 : i32
    cf.cond_br %828, ^bb121, ^bb122
    ^bb121:
      # String concatenation: !llvm.ptr + i32
      # String concatenation: !llvm.ptr + i32
      # String concatenation: !llvm.ptr + i32
      func.call @mul_mod_poly(%830, %831, %arg0, %832) : (!llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr) -> ()
      %833 = llvm.load %826 : !llvm.ptr -> i32
      %834 = arith.constant 1 : i32
      %835 = arith.addi %833, %834 : i32
      llvm.store %835, %826 : i32, !llvm.ptr
      cf.br ^bb120
    ^bb122:
    func.return
  }
  func.func @poly_x_n(%arg0: !llvm.ptr, %arg1: i64, %arg2: !llvm.ptr, %arg3: !llvm.ptr) -> () {
    %837 = llvm.mlir.addressof @D : !llvm.ptr
    %838 = llvm.load %837 : !llvm.ptr -> i32
    %839 = arith.extsi %838 : i32 to i64
    %840 = arith.constant 8 : i32
    %841 = arith.extsi %840 : i32 to i64
    %836 = func.call @calloc(%839, %841) : (i64, i64) -> !llvm.ptr
    %842 = arith.constant 1 : i32
    %843 = arith.constant 0 : i32
    %844 = arith.extsi %842 : i32 to i64
    %845 = arith.extsi %843 : i32 to i64
    %846 = llvm.getelementptr %836[%845] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    llvm.store %844, %846 : i64, !llvm.ptr
    %848 = llvm.mlir.addressof @D : !llvm.ptr
    %849 = llvm.load %848 : !llvm.ptr -> i32
    %850 = arith.extsi %849 : i32 to i64
    %851 = arith.constant 8 : i32
    %852 = arith.extsi %851 : i32 to i64
    %847 = func.call @calloc(%850, %852) : (i64, i64) -> !llvm.ptr
    %853 = llvm.mlir.constant(1 : i64) : i64
    %854 = llvm.alloca %853 x i64 : (i64) -> !llvm.ptr
    llvm.store %arg1, %854 : i64, !llvm.ptr
    %855 = arith.constant 0 : i32
    %856 = llvm.mlir.constant(1 : i64) : i64
    %857 = llvm.alloca %856 x i32 : (i64) -> !llvm.ptr
    llvm.store %855, %857 : i32, !llvm.ptr
    cf.br ^bb123
    ^bb123:
    %858 = llvm.load %854 : !llvm.ptr -> i64
    %859 = arith.constant 0 : i32
    %861 = arith.extsi %859 : i32 to i64
    %860 = arith.cmpi sgt, %858, %861 : i64
    cf.cond_br %860, ^bb124, ^bb125
    ^bb124:
      %862 = llvm.load %854 : !llvm.ptr -> i64
      %863 = arith.constant 1 : i32
      %865 = arith.extsi %863 : i32 to i64
      %864 = arith.andi %862, %865 : i64
      %866 = arith.constant 1 : i32
      %868 = arith.extsi %866 : i32 to i64
      %867 = arith.cmpi eq, %864, %868 : i64
      cf.cond_br %867, ^bb126, ^bb127
      ^bb126:
        %870 = llvm.mlir.addressof @D : !llvm.ptr
        %871 = llvm.load %870 : !llvm.ptr -> i32
        %872 = arith.extsi %871 : i32 to i64
        %873 = arith.constant 8 : i32
        %875 = arith.extsi %873 : i32 to i64
        %874 = arith.muli %872, %875 : i64
        %869 = func.call @memcpy(%847, %836, %874) : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr
        # String concatenation: !llvm.ptr + i32
        func.call @mul_mod_poly(%847, %877, %arg2, %836) : (!llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr) -> ()
        cf.br ^bb128
      ^bb127:
        cf.br ^bb128
      ^bb128:
      %878 = llvm.load %854 : !llvm.ptr -> i64
      %879 = arith.constant 1 : i32
      %881 = arith.extsi %879 : i32 to i64
      %880 = arith.shrsi %878, %881 : i64
      llvm.store %880, %854 : i64, !llvm.ptr
      %882 = llvm.load %857 : !llvm.ptr -> i32
      %883 = arith.constant 1 : i32
      %884 = arith.addi %882, %883 : i32
      llvm.store %884, %857 : i32, !llvm.ptr
      cf.br ^bb123
    ^bb125:
    %886 = llvm.mlir.addressof @D : !llvm.ptr
    %887 = llvm.load %886 : !llvm.ptr -> i32
    %888 = arith.extsi %887 : i32 to i64
    %889 = arith.constant 8 : i32
    %891 = arith.extsi %889 : i32 to i64
    %890 = arith.muli %888, %891 : i64
    %885 = func.call @memcpy(%arg3, %836, %890) : (!llvm.ptr, !llvm.ptr, i64) -> !llvm.ptr
    func.call @free(%836) : (!llvm.ptr) -> ()
    func.call @free(%847) : (!llvm.ptr) -> ()
    func.return
  }
  func.func @term_from_poly(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> i64 {
    %894 = arith.constant 0 : i32
    %895 = arith.extsi %894 : i32 to i64
    %896 = llvm.mlir.constant(1 : i64) : i64
    %897 = llvm.alloca %896 x i64 : (i64) -> !llvm.ptr
    llvm.store %895, %897 : i64, !llvm.ptr
    %898 = arith.constant 0 : i32
    %899 = llvm.mlir.constant(1 : i64) : i64
    %900 = llvm.alloca %899 x i32 : (i64) -> !llvm.ptr
    llvm.store %898, %900 : i32, !llvm.ptr
    cf.br ^bb129
    ^bb129:
    %901 = llvm.load %900 : !llvm.ptr -> i32
    %902 = llvm.mlir.addressof @D : !llvm.ptr
    %903 = llvm.load %902 : !llvm.ptr -> i32
    %904 = arith.cmpi slt, %901, %903 : i32
    cf.cond_br %904, ^bb130, ^bb131
    ^bb130:
      %906 = llvm.load %897 : !llvm.ptr -> i64
      %909 = llvm.load %900 : !llvm.ptr -> i32
      %910 = arith.extsi %909 : i32 to i64
      %911 = llvm.getelementptr %arg1[%910] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %908 = llvm.load %911 : !llvm.ptr -> i64
      %913 = llvm.load %900 : !llvm.ptr -> i32
      %914 = arith.extsi %913 : i32 to i64
      %915 = llvm.getelementptr %arg0[%914] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %912 = llvm.load %915 : !llvm.ptr -> i64
      %907 = func.call @mod_mul(%908, %912) : (i64, i64) -> i64
      %905 = func.call @mod_add(%906, %907) : (i64, i64) -> i64
      llvm.store %905, %897 : i64, !llvm.ptr
      %916 = llvm.load %900 : !llvm.ptr -> i32
      %917 = arith.constant 1 : i32
      %918 = arith.addi %916, %917 : i32
      llvm.store %918, %900 : i32, !llvm.ptr
      cf.br ^bb129
    ^bb131:
    %919 = llvm.load %897 : !llvm.ptr -> i64
    func.return %919 : i64
  }
  func.func @heapsort_i32(%arg0: !llvm.ptr, %arg1: i32) -> () {
    %920 = arith.constant 1 : i32
    %921 = arith.shrsi %arg1, %920 : i32
    %922 = arith.constant 1 : i32
    %923 = arith.subi %921, %922 : i32
    %924 = llvm.mlir.constant(1 : i64) : i64
    %925 = llvm.alloca %924 x i32 : (i64) -> !llvm.ptr
    llvm.store %923, %925 : i32, !llvm.ptr
    cf.br ^bb132
    ^bb132:
    %926 = llvm.load %925 : !llvm.ptr -> i32
    %927 = arith.constant 0 : i32
    %928 = arith.cmpi sge, %926, %927 : i32
    cf.cond_br %928, ^bb133, ^bb134
    ^bb133:
      %929 = llvm.load %925 : !llvm.ptr -> i32
      %930 = llvm.mlir.constant(1 : i64) : i64
      %931 = llvm.alloca %930 x i32 : (i64) -> !llvm.ptr
      llvm.store %929, %931 : i32, !llvm.ptr
      cf.br ^bb135
      ^bb135:
      %932 = llvm.load %931 : !llvm.ptr -> i32
      %933 = arith.constant 1 : i32
      %934 = arith.shli %932, %933 : i32
      %935 = arith.constant 1 : i32
      %936 = arith.addi %934, %935 : i32
      %937 = arith.cmpi slt, %936, %arg1 : i32
      cf.cond_br %937, ^bb136, ^bb137
      ^bb136:
        %938 = llvm.load %931 : !llvm.ptr -> i32
        %939 = arith.constant 1 : i32
        %940 = arith.shli %938, %939 : i32
        %941 = arith.constant 1 : i32
        %942 = arith.addi %940, %941 : i32
        %943 = llvm.mlir.constant(1 : i64) : i64
        %944 = llvm.alloca %943 x i32 : (i64) -> !llvm.ptr
        llvm.store %942, %944 : i32, !llvm.ptr
        %945 = arith.constant 1 : i32
        %946 = arith.addi %942, %945 : i32
        %947 = arith.cmpi slt, %946, %arg1 : i32
        %948 = scf.if %947 -> (i1) {
          %950 = arith.constant 1 : i32
          %951 = arith.addi %942, %950 : i32
          %952 = arith.extsi %951 : i32 to i64
          %953 = llvm.getelementptr %arg0[%952] : (!llvm.ptr, i64) -> !llvm.ptr, i32
          %949 = llvm.load %953 : !llvm.ptr -> i32
          %955 = arith.extsi %942 : i32 to i64
          %956 = llvm.getelementptr %arg0[%955] : (!llvm.ptr, i64) -> !llvm.ptr, i32
          %954 = llvm.load %956 : !llvm.ptr -> i32
          %957 = arith.cmpi sgt, %949, %954 : i32
          scf.yield %957 : i1
        } else {
          %958 = arith.constant false
          scf.yield %958 : i1
        }
        cf.cond_br %948, ^bb138, ^bb139
        ^bb138:
          %959 = arith.constant 1 : i32
          %960 = arith.addi %942, %959 : i32
          llvm.store %960, %944 : i32, !llvm.ptr
          cf.br ^bb140
        ^bb139:
          cf.br ^bb140
        ^bb140:
        %962 = llvm.load %931 : !llvm.ptr -> i32
        %963 = arith.extsi %962 : i32 to i64
        %964 = llvm.getelementptr %arg0[%963] : (!llvm.ptr, i64) -> !llvm.ptr, i32
        %961 = llvm.load %964 : !llvm.ptr -> i32
        %966 = llvm.load %944 : !llvm.ptr -> i32
        %967 = arith.extsi %966 : i32 to i64
        %968 = llvm.getelementptr %arg0[%967] : (!llvm.ptr, i64) -> !llvm.ptr, i32
        %965 = llvm.load %968 : !llvm.ptr -> i32
        %969 = arith.cmpi slt, %961, %965 : i32
        cf.cond_br %969, ^bb141, ^bb142
        ^bb141:
          %971 = llvm.load %931 : !llvm.ptr -> i32
          %972 = arith.extsi %971 : i32 to i64
          %973 = llvm.getelementptr %arg0[%972] : (!llvm.ptr, i64) -> !llvm.ptr, i32
          %970 = llvm.load %973 : !llvm.ptr -> i32
          %975 = llvm.load %944 : !llvm.ptr -> i32
          %976 = arith.extsi %975 : i32 to i64
          %977 = llvm.getelementptr %arg0[%976] : (!llvm.ptr, i64) -> !llvm.ptr, i32
          %974 = llvm.load %977 : !llvm.ptr -> i32
          %978 = llvm.load %931 : !llvm.ptr -> i32
          %979 = arith.extsi %978 : i32 to i64
          %980 = llvm.getelementptr %arg0[%979] : (!llvm.ptr, i64) -> !llvm.ptr, i32
          llvm.store %974, %980 : i32, !llvm.ptr
          %981 = llvm.load %944 : !llvm.ptr -> i32
          %982 = arith.extsi %981 : i32 to i64
          %983 = llvm.getelementptr %arg0[%982] : (!llvm.ptr, i64) -> !llvm.ptr, i32
          llvm.store %970, %983 : i32, !llvm.ptr
          %984 = llvm.load %944 : !llvm.ptr -> i32
          llvm.store %984, %931 : i32, !llvm.ptr
          cf.br ^bb143
        ^bb142:
          cf.br ^bb137
        ^bb143:
        cf.br ^bb135
      ^bb137:
      %985 = llvm.load %925 : !llvm.ptr -> i32
      %986 = arith.constant 1 : i32
      %987 = arith.subi %985, %986 : i32
      llvm.store %987, %925 : i32, !llvm.ptr
      cf.br ^bb132
    ^bb134:
    %988 = arith.constant 1 : i32
    %989 = arith.subi %arg1, %988 : i32
    %990 = llvm.mlir.constant(1 : i64) : i64
    %991 = llvm.alloca %990 x i32 : (i64) -> !llvm.ptr
    llvm.store %989, %991 : i32, !llvm.ptr
    cf.br ^bb144
    ^bb144:
    %992 = llvm.load %991 : !llvm.ptr -> i32
    %993 = arith.constant 0 : i32
    %994 = arith.cmpi sgt, %992, %993 : i32
    cf.cond_br %994, ^bb145, ^bb146
    ^bb145:
      %996 = arith.constant 0 : i32
      %997 = arith.extsi %996 : i32 to i64
      %998 = llvm.getelementptr %arg0[%997] : (!llvm.ptr, i64) -> !llvm.ptr, i32
      %995 = llvm.load %998 : !llvm.ptr -> i32
      %1000 = llvm.load %991 : !llvm.ptr -> i32
      %1001 = arith.extsi %1000 : i32 to i64
      %1002 = llvm.getelementptr %arg0[%1001] : (!llvm.ptr, i64) -> !llvm.ptr, i32
      %999 = llvm.load %1002 : !llvm.ptr -> i32
      %1003 = arith.constant 0 : i32
      %1004 = arith.extsi %1003 : i32 to i64
      %1005 = llvm.getelementptr %arg0[%1004] : (!llvm.ptr, i64) -> !llvm.ptr, i32
      llvm.store %999, %1005 : i32, !llvm.ptr
      %1006 = llvm.load %991 : !llvm.ptr -> i32
      %1007 = arith.extsi %1006 : i32 to i64
      %1008 = llvm.getelementptr %arg0[%1007] : (!llvm.ptr, i64) -> !llvm.ptr, i32
      llvm.store %995, %1008 : i32, !llvm.ptr
      %1009 = arith.constant 0 : i32
      %1010 = llvm.mlir.constant(1 : i64) : i64
      %1011 = llvm.alloca %1010 x i32 : (i64) -> !llvm.ptr
      llvm.store %1009, %1011 : i32, !llvm.ptr
      cf.br ^bb147
      ^bb147:
      %1012 = llvm.load %1011 : !llvm.ptr -> i32
      %1013 = arith.constant 1 : i32
      %1014 = arith.shli %1012, %1013 : i32
      %1015 = arith.constant 1 : i32
      %1016 = arith.addi %1014, %1015 : i32
      %1017 = llvm.load %991 : !llvm.ptr -> i32
      %1018 = arith.cmpi slt, %1016, %1017 : i32
      cf.cond_br %1018, ^bb148, ^bb149
      ^bb148:
        %1019 = llvm.load %1011 : !llvm.ptr -> i32
        %1020 = arith.constant 1 : i32
        %1021 = arith.shli %1019, %1020 : i32
        %1022 = arith.constant 1 : i32
        %1023 = arith.addi %1021, %1022 : i32
        %1024 = llvm.mlir.constant(1 : i64) : i64
        %1025 = llvm.alloca %1024 x i32 : (i64) -> !llvm.ptr
        llvm.store %1023, %1025 : i32, !llvm.ptr
        %1026 = arith.constant 1 : i32
        %1027 = arith.addi %1023, %1026 : i32
        %1028 = llvm.load %991 : !llvm.ptr -> i32
        %1029 = arith.cmpi slt, %1027, %1028 : i32
        %1030 = scf.if %1029 -> (i1) {
          %1032 = arith.constant 1 : i32
          %1033 = arith.addi %1023, %1032 : i32
          %1034 = arith.extsi %1033 : i32 to i64
          %1035 = llvm.getelementptr %arg0[%1034] : (!llvm.ptr, i64) -> !llvm.ptr, i32
          %1031 = llvm.load %1035 : !llvm.ptr -> i32
          %1037 = arith.extsi %1023 : i32 to i64
          %1038 = llvm.getelementptr %arg0[%1037] : (!llvm.ptr, i64) -> !llvm.ptr, i32
          %1036 = llvm.load %1038 : !llvm.ptr -> i32
          %1039 = arith.cmpi sgt, %1031, %1036 : i32
          scf.yield %1039 : i1
        } else {
          %1040 = arith.constant false
          scf.yield %1040 : i1
        }
        cf.cond_br %1030, ^bb150, ^bb151
        ^bb150:
          %1041 = arith.constant 1 : i32
          %1042 = arith.addi %1023, %1041 : i32
          llvm.store %1042, %1025 : i32, !llvm.ptr
          cf.br ^bb152
        ^bb151:
          cf.br ^bb152
        ^bb152:
        %1044 = llvm.load %1011 : !llvm.ptr -> i32
        %1045 = arith.extsi %1044 : i32 to i64
        %1046 = llvm.getelementptr %arg0[%1045] : (!llvm.ptr, i64) -> !llvm.ptr, i32
        %1043 = llvm.load %1046 : !llvm.ptr -> i32
        %1048 = llvm.load %1025 : !llvm.ptr -> i32
        %1049 = arith.extsi %1048 : i32 to i64
        %1050 = llvm.getelementptr %arg0[%1049] : (!llvm.ptr, i64) -> !llvm.ptr, i32
        %1047 = llvm.load %1050 : !llvm.ptr -> i32
        %1051 = arith.cmpi slt, %1043, %1047 : i32
        cf.cond_br %1051, ^bb153, ^bb154
        ^bb153:
          %1053 = llvm.load %1011 : !llvm.ptr -> i32
          %1054 = arith.extsi %1053 : i32 to i64
          %1055 = llvm.getelementptr %arg0[%1054] : (!llvm.ptr, i64) -> !llvm.ptr, i32
          %1052 = llvm.load %1055 : !llvm.ptr -> i32
          %1057 = llvm.load %1025 : !llvm.ptr -> i32
          %1058 = arith.extsi %1057 : i32 to i64
          %1059 = llvm.getelementptr %arg0[%1058] : (!llvm.ptr, i64) -> !llvm.ptr, i32
          %1056 = llvm.load %1059 : !llvm.ptr -> i32
          %1060 = llvm.load %1011 : !llvm.ptr -> i32
          %1061 = arith.extsi %1060 : i32 to i64
          %1062 = llvm.getelementptr %arg0[%1061] : (!llvm.ptr, i64) -> !llvm.ptr, i32
          llvm.store %1056, %1062 : i32, !llvm.ptr
          %1063 = llvm.load %1025 : !llvm.ptr -> i32
          %1064 = arith.extsi %1063 : i32 to i64
          %1065 = llvm.getelementptr %arg0[%1064] : (!llvm.ptr, i64) -> !llvm.ptr, i32
          llvm.store %1052, %1065 : i32, !llvm.ptr
          %1066 = llvm.load %1025 : !llvm.ptr -> i32
          llvm.store %1066, %1011 : i32, !llvm.ptr
          cf.br ^bb155
        ^bb154:
          cf.br ^bb149
        ^bb155:
        cf.br ^bb147
      ^bb149:
      %1067 = llvm.load %991 : !llvm.ptr -> i32
      %1068 = arith.constant 1 : i32
      %1069 = arith.subi %1067, %1068 : i32
      llvm.store %1069, %991 : i32, !llvm.ptr
      cf.br ^bb144
    ^bb146:
    func.return
  }
  func.func @compute_F(%arg0: i32, %arg1: i32) -> i64 {
    %1071 = arith.constant 1 : i32
    %1072 = arith.constant 4 : i32
    %1073 = arith.extsi %1071 : i32 to i64
    %1074 = arith.extsi %1072 : i32 to i64
    %1070 = func.call @calloc(%1073, %1074) : (i64, i64) -> !llvm.ptr
    %1075 = func.call @sieve_primes(%arg0, %1070) : (i32, !llvm.ptr) -> !llvm.ptr
    %1077 = arith.constant 0 : i32
    %1078 = arith.extsi %1077 : i32 to i64
    %1079 = llvm.getelementptr %1070[%1078] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    %1076 = llvm.load %1079 : !llvm.ptr -> i32
    func.call @free(%1070) : (!llvm.ptr) -> ()
    %1082 = arith.extsi %1076 : i32 to i64
    %1083 = arith.constant 4 : i32
    %1084 = arith.extsi %1083 : i32 to i64
    %1081 = func.call @calloc(%1082, %1084) : (i64, i64) -> !llvm.ptr
    %1085 = arith.constant 0 : i32
    %1086 = llvm.mlir.constant(1 : i64) : i64
    %1087 = llvm.alloca %1086 x i32 : (i64) -> !llvm.ptr
    llvm.store %1085, %1087 : i32, !llvm.ptr
    %1088 = arith.constant 0 : i32
    %1089 = llvm.mlir.constant(1 : i64) : i64
    %1090 = llvm.alloca %1089 x i32 : (i64) -> !llvm.ptr
    llvm.store %1088, %1090 : i32, !llvm.ptr
    cf.br ^bb156
    ^bb156:
    %1091 = llvm.load %1090 : !llvm.ptr -> i32
    %1092 = arith.cmpi slt, %1091, %1076 : i32
    cf.cond_br %1092, ^bb157, ^bb158
    ^bb157:
      %1095 = llvm.load %1090 : !llvm.ptr -> i32
      %1096 = arith.extsi %1095 : i32 to i64
      %1097 = llvm.getelementptr %1075[%1096] : (!llvm.ptr, i64) -> !llvm.ptr, i32
      %1094 = llvm.load %1097 : !llvm.ptr -> i32
      %1093 = func.call @factorial_prime_exp(%arg0, %1094) : (i32, i32) -> i32
      %1098 = llvm.load %1090 : !llvm.ptr -> i32
      %1099 = arith.extsi %1098 : i32 to i64
      %1100 = llvm.getelementptr %1081[%1099] : (!llvm.ptr, i64) -> !llvm.ptr, i32
      llvm.store %1093, %1100 : i32, !llvm.ptr
      %1102 = llvm.load %1090 : !llvm.ptr -> i32
      %1103 = arith.extsi %1102 : i32 to i64
      %1104 = llvm.getelementptr %1081[%1103] : (!llvm.ptr, i64) -> !llvm.ptr, i32
      %1101 = llvm.load %1104 : !llvm.ptr -> i32
      %1105 = llvm.load %1087 : !llvm.ptr -> i32
      %1106 = arith.cmpi sgt, %1101, %1105 : i32
      cf.cond_br %1106, ^bb159, ^bb160
      ^bb159:
        %1108 = llvm.load %1090 : !llvm.ptr -> i32
        %1109 = arith.extsi %1108 : i32 to i64
        %1110 = llvm.getelementptr %1081[%1109] : (!llvm.ptr, i64) -> !llvm.ptr, i32
        %1107 = llvm.load %1110 : !llvm.ptr -> i32
        llvm.store %1107, %1087 : i32, !llvm.ptr
        cf.br ^bb161
      ^bb160:
        cf.br ^bb161
      ^bb161:
      %1111 = llvm.load %1090 : !llvm.ptr -> i32
      %1112 = arith.constant 1 : i32
      %1113 = arith.addi %1111, %1112 : i32
      llvm.store %1113, %1090 : i32, !llvm.ptr
      cf.br ^bb156
    ^bb158:
    func.call @heapsort_i32(%1081, %1076) : (!llvm.ptr, i32) -> ()
    %1116 = arith.extsi %1076 : i32 to i64
    %1117 = arith.constant 4 : i32
    %1118 = arith.extsi %1117 : i32 to i64
    %1115 = func.call @calloc(%1116, %1118) : (i64, i64) -> !llvm.ptr
    %1120 = arith.extsi %1076 : i32 to i64
    %1121 = arith.constant 4 : i32
    %1122 = arith.extsi %1121 : i32 to i64
    %1119 = func.call @calloc(%1120, %1122) : (i64, i64) -> !llvm.ptr
    %1123 = arith.constant 0 : i32
    %1124 = llvm.mlir.constant(1 : i64) : i64
    %1125 = llvm.alloca %1124 x i32 : (i64) -> !llvm.ptr
    llvm.store %1123, %1125 : i32, !llvm.ptr
    %1126 = arith.constant 0 : i32
    %1127 = llvm.mlir.constant(1 : i64) : i64
    %1128 = llvm.alloca %1127 x i32 : (i64) -> !llvm.ptr
    llvm.store %1126, %1128 : i32, !llvm.ptr
    cf.br ^bb162
    ^bb162:
    %1129 = llvm.load %1128 : !llvm.ptr -> i32
    %1130 = arith.cmpi slt, %1129, %1076 : i32
    cf.cond_br %1130, ^bb163, ^bb164
    ^bb163:
      %1131 = llvm.load %1125 : !llvm.ptr -> i32
      %1132 = arith.constant 0 : i32
      %1133 = arith.cmpi sgt, %1131, %1132 : i32
      %1134 = scf.if %1133 -> (i1) {
        %1136 = llvm.load %1125 : !llvm.ptr -> i32
        %1137 = arith.constant 1 : i32
        %1138 = arith.subi %1136, %1137 : i32
        %1139 = arith.extsi %1138 : i32 to i64
        %1140 = llvm.getelementptr %1115[%1139] : (!llvm.ptr, i64) -> !llvm.ptr, i32
        %1135 = llvm.load %1140 : !llvm.ptr -> i32
        %1142 = llvm.load %1128 : !llvm.ptr -> i32
        %1143 = arith.extsi %1142 : i32 to i64
        %1144 = llvm.getelementptr %1081[%1143] : (!llvm.ptr, i64) -> !llvm.ptr, i32
        %1141 = llvm.load %1144 : !llvm.ptr -> i32
        %1145 = arith.cmpi eq, %1135, %1141 : i32
        scf.yield %1145 : i1
      } else {
        %1146 = arith.constant false
        scf.yield %1146 : i1
      }
      cf.cond_br %1134, ^bb165, ^bb166
      ^bb165:
        %1148 = llvm.load %1125 : !llvm.ptr -> i32
        %1149 = arith.constant 1 : i32
        %1150 = arith.subi %1148, %1149 : i32
        %1151 = arith.extsi %1150 : i32 to i64
        %1152 = llvm.getelementptr %1119[%1151] : (!llvm.ptr, i64) -> !llvm.ptr, i32
        %1147 = llvm.load %1152 : !llvm.ptr -> i32
        %1153 = arith.constant 1 : i32
        %1154 = arith.addi %1147, %1153 : i32
        %1155 = llvm.load %1125 : !llvm.ptr -> i32
        %1156 = arith.constant 1 : i32
        %1157 = arith.subi %1155, %1156 : i32
        %1158 = arith.extsi %1157 : i32 to i64
        %1159 = llvm.getelementptr %1119[%1158] : (!llvm.ptr, i64) -> !llvm.ptr, i32
        llvm.store %1154, %1159 : i32, !llvm.ptr
        cf.br ^bb167
      ^bb166:
        %1161 = llvm.load %1128 : !llvm.ptr -> i32
        %1162 = arith.extsi %1161 : i32 to i64
        %1163 = llvm.getelementptr %1081[%1162] : (!llvm.ptr, i64) -> !llvm.ptr, i32
        %1160 = llvm.load %1163 : !llvm.ptr -> i32
        %1164 = llvm.load %1125 : !llvm.ptr -> i32
        %1165 = arith.extsi %1164 : i32 to i64
        %1166 = llvm.getelementptr %1115[%1165] : (!llvm.ptr, i64) -> !llvm.ptr, i32
        llvm.store %1160, %1166 : i32, !llvm.ptr
        %1167 = arith.constant 1 : i32
        %1168 = llvm.load %1125 : !llvm.ptr -> i32
        %1169 = arith.extsi %1168 : i32 to i64
        %1170 = llvm.getelementptr %1119[%1169] : (!llvm.ptr, i64) -> !llvm.ptr, i32
        llvm.store %1167, %1170 : i32, !llvm.ptr
        %1171 = llvm.load %1125 : !llvm.ptr -> i32
        %1172 = arith.constant 1 : i32
        %1173 = arith.addi %1171, %1172 : i32
        llvm.store %1173, %1125 : i32, !llvm.ptr
        cf.br ^bb167
      ^bb167:
      %1174 = llvm.load %1128 : !llvm.ptr -> i32
      %1175 = arith.constant 1 : i32
      %1176 = arith.addi %1174, %1175 : i32
      llvm.store %1176, %1128 : i32, !llvm.ptr
      cf.br ^bb162
    ^bb164:
    %1177 = llvm.load %1087 : !llvm.ptr -> i32
    %1178 = arith.cmpi slt, %arg1, %1177 : i32
    %1179 = scf.if %1178 -> (i32) {
      scf.yield %arg1 : i32
    } else {
      %1180 = llvm.load %1087 : !llvm.ptr -> i32
      scf.yield %1180 : i32
    }
    %1182 = arith.constant 288 : i32
    %1183 = llvm.mlir.addressof @MOD : !llvm.ptr
    %1184 = llvm.load %1183 : !llvm.ptr -> i64
    %1185 = arith.constant 2 : i32
    %1187 = arith.extsi %1185 : i32 to i64
    %1186 = arith.subi %1184, %1187 : i64
    %1188 = arith.extsi %1182 : i32 to i64
    %1181 = func.call @mod_pow(%1188, %1186) : (i64, i64) -> i64
    %1189 = arith.constant 0 : i32
    %1190 = llvm.mlir.constant(1 : i64) : i64
    %1191 = llvm.alloca %1190 x i32 : (i64) -> !llvm.ptr
    llvm.store %1189, %1191 : i32, !llvm.ptr
    %1192 = arith.constant 0 : i32
    %1193 = llvm.mlir.constant(1 : i64) : i64
    %1194 = llvm.alloca %1193 x i32 : (i64) -> !llvm.ptr
    llvm.store %1192, %1194 : i32, !llvm.ptr
    cf.br ^bb168
    ^bb168:
    %1195 = llvm.load %1194 : !llvm.ptr -> i32
    %1196 = llvm.load %1125 : !llvm.ptr -> i32
    %1197 = arith.cmpi slt, %1195, %1196 : i32
    cf.cond_br %1197, ^bb169, ^bb170
    ^bb169:
      %1199 = llvm.load %1194 : !llvm.ptr -> i32
      %1200 = arith.extsi %1199 : i32 to i64
      %1201 = llvm.getelementptr %1115[%1200] : (!llvm.ptr, i64) -> !llvm.ptr, i32
      %1198 = llvm.load %1201 : !llvm.ptr -> i32
      %1202 = arith.constant 1 : i32
      %1203 = arith.cmpi eq, %1198, %1202 : i32
      cf.cond_br %1203, ^bb171, ^bb172
      ^bb171:
        %1204 = arith.constant 1 : i32
        llvm.store %1204, %1191 : i32, !llvm.ptr
        cf.br ^bb170
      ^bb172:
        cf.br ^bb173
      ^bb173:
      %1205 = llvm.load %1194 : !llvm.ptr -> i32
      %1206 = arith.constant 1 : i32
      %1207 = arith.addi %1205, %1206 : i32
      llvm.store %1207, %1194 : i32, !llvm.ptr
      cf.br ^bb168
    ^bb170:
    %1209 = arith.constant 1 : i32
    %1210 = arith.addi %1179, %1209 : i32
    %1211 = arith.extsi %1210 : i32 to i64
    %1212 = arith.constant 8 : i32
    %1213 = arith.extsi %1212 : i32 to i64
    %1208 = func.call @calloc(%1211, %1213) : (i64, i64) -> !llvm.ptr
    %1215 = llvm.load %1125 : !llvm.ptr -> i32
    %1216 = arith.extsi %1215 : i32 to i64
    %1217 = arith.constant 8 : i32
    %1218 = arith.extsi %1217 : i32 to i64
    %1214 = func.call @calloc(%1216, %1218) : (i64, i64) -> !llvm.ptr
    %1220 = llvm.mlir.addressof @D : !llvm.ptr
    %1221 = llvm.load %1220 : !llvm.ptr -> i32
    %1222 = arith.constant 1 : i32
    %1223 = arith.addi %1221, %1222 : i32
    %1224 = arith.extsi %1223 : i32 to i64
    %1225 = arith.constant 8 : i32
    %1226 = arith.extsi %1225 : i32 to i64
    %1219 = func.call @calloc(%1224, %1226) : (i64, i64) -> !llvm.ptr
    %1228 = llvm.mlir.addressof @D : !llvm.ptr
    %1229 = llvm.load %1228 : !llvm.ptr -> i32
    %1230 = arith.extsi %1229 : i32 to i64
    %1231 = arith.constant 8 : i32
    %1232 = arith.extsi %1231 : i32 to i64
    %1227 = func.call @calloc(%1230, %1232) : (i64, i64) -> !llvm.ptr
    %1234 = llvm.mlir.addressof @D : !llvm.ptr
    %1235 = llvm.load %1234 : !llvm.ptr -> i32
    %1236 = arith.extsi %1235 : i32 to i64
    %1237 = arith.constant 8 : i32
    %1238 = arith.extsi %1237 : i32 to i64
    %1233 = func.call @calloc(%1236, %1238) : (i64, i64) -> !llvm.ptr
    %1240 = llvm.mlir.addressof @D : !llvm.ptr
    %1241 = llvm.load %1240 : !llvm.ptr -> i32
    %1242 = arith.extsi %1241 : i32 to i64
    %1243 = arith.constant 8 : i32
    %1244 = arith.extsi %1243 : i32 to i64
    %1239 = func.call @calloc(%1242, %1244) : (i64, i64) -> !llvm.ptr
    %1246 = llvm.mlir.addressof @MAXBIT : !llvm.ptr
    %1247 = llvm.load %1246 : !llvm.ptr -> i32
    %1248 = llvm.mlir.addressof @D : !llvm.ptr
    %1249 = llvm.load %1248 : !llvm.ptr -> i32
    %1250 = arith.muli %1247, %1249 : i32
    %1251 = arith.extsi %1250 : i32 to i64
    %1252 = arith.constant 8 : i32
    %1253 = arith.extsi %1252 : i32 to i64
    %1245 = func.call @calloc(%1251, %1253) : (i64, i64) -> !llvm.ptr
    %1254 = arith.constant 0 : i32
    %1255 = arith.extsi %1254 : i32 to i64
    %1256 = llvm.mlir.constant(1 : i64) : i64
    %1257 = llvm.alloca %1256 x i64 : (i64) -> !llvm.ptr
    llvm.store %1255, %1257 : i64, !llvm.ptr
    %1258 = arith.constant 0 : i32
    %1259 = llvm.mlir.constant(1 : i64) : i64
    %1260 = llvm.alloca %1259 x i32 : (i64) -> !llvm.ptr
    llvm.store %1258, %1260 : i32, !llvm.ptr
    cf.br ^bb174
    ^bb174:
    %1261 = llvm.load %1260 : !llvm.ptr -> i32
    %1262 = llvm.mlir.addressof @g_nkeys : !llvm.ptr
    %1263 = llvm.load %1262 : !llvm.ptr -> i32
    %1264 = arith.cmpi slt, %1261, %1263 : i32
    cf.cond_br %1264, ^bb175, ^bb176
    ^bb175:
      %1266 = llvm.mlir.addressof @g_key_lens : !llvm.ptr
      %1267 = llvm.load %1266 : !llvm.ptr -> !llvm.ptr
      %1268 = llvm.load %1260 : !llvm.ptr -> i32
      %1269 = arith.extsi %1268 : i32 to i64
      %1270 = llvm.getelementptr %1267[%1269] : (!llvm.ptr, i64) -> !llvm.ptr, i32
      %1265 = llvm.load %1270 : !llvm.ptr -> i32
      # String concatenation: !llvm.ptr + i32
      %1272 = llvm.load %1191 : !llvm.ptr -> i32
      %1273 = arith.constant 1 : i32
      %1274 = arith.cmpi eq, %1272, %1273 : i32
      cf.cond_br %1274, ^bb177, ^bb178
      ^bb177:
        %1275 = arith.constant 0 : i32
        %1276 = llvm.mlir.constant(1 : i64) : i64
        %1277 = llvm.alloca %1276 x i32 : (i64) -> !llvm.ptr
        llvm.store %1275, %1277 : i32, !llvm.ptr
        %1278 = arith.constant 0 : i32
        %1279 = llvm.mlir.constant(1 : i64) : i64
        %1280 = llvm.alloca %1279 x i32 : (i64) -> !llvm.ptr
        llvm.store %1278, %1280 : i32, !llvm.ptr
        cf.br ^bb180
        ^bb180:
        %1281 = llvm.load %1280 : !llvm.ptr -> i32
        %1282 = arith.cmpi slt, %1281, %1265 : i32
        cf.cond_br %1282, ^bb181, ^bb182
        ^bb181:
          %1284 = llvm.load %1280 : !llvm.ptr -> i32
          %1285 = arith.extsi %1284 : i32 to i64
          %1286 = llvm.getelementptr %1271[%1285] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          %1283 = llvm.load %1286 : !llvm.ptr -> i64
          %1287 = arith.constant 1 : i32
          %1289 = arith.extsi %1287 : i32 to i64
          %1288 = arith.cmpi eq, %1283, %1289 : i64
          cf.cond_br %1288, ^bb183, ^bb184
          ^bb183:
            %1290 = arith.constant 1 : i32
            llvm.store %1290, %1277 : i32, !llvm.ptr
            cf.br ^bb182
          ^bb184:
            cf.br ^bb185
          ^bb185:
          %1291 = llvm.load %1280 : !llvm.ptr -> i32
          %1292 = arith.constant 1 : i32
          %1293 = arith.addi %1291, %1292 : i32
          llvm.store %1293, %1280 : i32, !llvm.ptr
          cf.br ^bb180
        ^bb182:
        %1294 = llvm.load %1277 : !llvm.ptr -> i32
        %1295 = arith.constant 0 : i32
        %1296 = arith.cmpi eq, %1294, %1295 : i32
        cf.cond_br %1296, ^bb186, ^bb187
        ^bb186:
          %1297 = llvm.load %1260 : !llvm.ptr -> i32
          %1298 = arith.constant 1 : i32
          %1299 = arith.addi %1297, %1298 : i32
          llvm.store %1299, %1260 : i32, !llvm.ptr
          cf.br ^bb174
        ^bb187:
          cf.br ^bb188
        ^bb188:
        cf.br ^bb179
      ^bb178:
        cf.br ^bb179
      ^bb179:
      func.call @coeffs_up_to(%1271, %1265, %1179, %1208) : (!llvm.ptr, i32, i32, !llvm.ptr) -> ()
      %1301 = arith.constant 0 : i32
      %1302 = llvm.mlir.constant(1 : i64) : i64
      %1303 = llvm.alloca %1302 x i32 : (i64) -> !llvm.ptr
      llvm.store %1301, %1303 : i32, !llvm.ptr
      %1304 = arith.constant 0 : i32
      %1305 = llvm.mlir.constant(1 : i64) : i64
      %1306 = llvm.alloca %1305 x i32 : (i64) -> !llvm.ptr
      llvm.store %1304, %1306 : i32, !llvm.ptr
      cf.br ^bb189
      ^bb189:
      %1307 = llvm.load %1306 : !llvm.ptr -> i32
      %1308 = llvm.load %1125 : !llvm.ptr -> i32
      %1309 = arith.cmpi slt, %1307, %1308 : i32
      cf.cond_br %1309, ^bb190, ^bb191
      ^bb190:
        %1311 = llvm.load %1306 : !llvm.ptr -> i32
        %1312 = arith.extsi %1311 : i32 to i64
        %1313 = llvm.getelementptr %1115[%1312] : (!llvm.ptr, i64) -> !llvm.ptr, i32
        %1310 = llvm.load %1313 : !llvm.ptr -> i32
        %1314 = arith.cmpi sgt, %1310, %1179 : i32
        cf.cond_br %1314, ^bb192, ^bb193
        ^bb192:
          %1315 = arith.constant 1 : i32
          llvm.store %1315, %1303 : i32, !llvm.ptr
          cf.br ^bb191
        ^bb193:
          cf.br ^bb194
        ^bb194:
        %1316 = llvm.load %1306 : !llvm.ptr -> i32
        %1317 = arith.constant 1 : i32
        %1318 = arith.addi %1316, %1317 : i32
        llvm.store %1318, %1306 : i32, !llvm.ptr
        cf.br ^bb189
      ^bb191:
      %1319 = llvm.load %1303 : !llvm.ptr -> i32
      %1320 = arith.constant 1 : i32
      %1321 = arith.cmpi eq, %1319, %1320 : i32
      cf.cond_br %1321, ^bb195, ^bb196
      ^bb195:
        func.call @poly_Q_from_key(%1271, %1265, %1219) : (!llvm.ptr, i32, !llvm.ptr) -> ()
        %1323 = arith.constant 0 : i32
        %1324 = llvm.mlir.constant(1 : i64) : i64
        %1325 = llvm.alloca %1324 x i32 : (i64) -> !llvm.ptr
        llvm.store %1323, %1325 : i32, !llvm.ptr
        cf.br ^bb198
        ^bb198:
        %1326 = llvm.load %1325 : !llvm.ptr -> i32
        %1327 = llvm.mlir.addressof @D : !llvm.ptr
        %1328 = llvm.load %1327 : !llvm.ptr -> i32
        %1329 = arith.cmpi slt, %1326, %1328 : i32
        cf.cond_br %1329, ^bb199, ^bb200
        ^bb199:
          %1331 = llvm.load %1325 : !llvm.ptr -> i32
          %1332 = arith.constant 1 : i32
          %1333 = arith.addi %1331, %1332 : i32
          %1334 = arith.extsi %1333 : i32 to i64
          %1335 = llvm.getelementptr %1219[%1334] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          %1330 = llvm.load %1335 : !llvm.ptr -> i64
          %1336 = llvm.mlir.addressof @MOD : !llvm.ptr
          %1337 = llvm.load %1336 : !llvm.ptr -> i64
          %1338 = arith.remsi %1330, %1337 : i64
          %1339 = arith.constant 0 : i32
          %1341 = arith.extsi %1339 : i32 to i64
          %1340 = arith.cmpi slt, %1338, %1341 : i64
          %1342 = scf.if %1340 -> (i64) {
            %1343 = llvm.mlir.addressof @MOD : !llvm.ptr
            %1344 = llvm.load %1343 : !llvm.ptr -> i64
            %1345 = arith.addi %1338, %1344 : i64
            scf.yield %1345 : i64
          } else {
            scf.yield %1338 : i64
          }
          %1347 = arith.constant 0 : i32
          %1348 = arith.extsi %1347 : i32 to i64
          %1346 = func.call @mod_sub(%1348, %1342) : (i64, i64) -> i64
          %1349 = llvm.load %1325 : !llvm.ptr -> i32
          %1350 = arith.extsi %1349 : i32 to i64
          %1351 = llvm.getelementptr %1227[%1350] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          llvm.store %1346, %1351 : i64, !llvm.ptr
          %1352 = llvm.load %1325 : !llvm.ptr -> i32
          %1353 = arith.constant 1 : i32
          %1354 = arith.addi %1352, %1353 : i32
          llvm.store %1354, %1325 : i32, !llvm.ptr
          cf.br ^bb198
        ^bb200:
        %1356 = llvm.mlir.addressof @MAXBIT : !llvm.ptr
        %1357 = llvm.load %1356 : !llvm.ptr -> i32
        func.call @precompute_x_powers(%1227, %1357, %1245) : (!llvm.ptr, i32, !llvm.ptr) -> ()
        %1358 = arith.constant 0 : i32
        %1359 = llvm.mlir.constant(1 : i64) : i64
        %1360 = llvm.alloca %1359 x i32 : (i64) -> !llvm.ptr
        llvm.store %1358, %1360 : i32, !llvm.ptr
        cf.br ^bb201
        ^bb201:
        %1361 = llvm.load %1360 : !llvm.ptr -> i32
        %1362 = llvm.mlir.addressof @D : !llvm.ptr
        %1363 = llvm.load %1362 : !llvm.ptr -> i32
        %1364 = arith.cmpi slt, %1361, %1363 : i32
        cf.cond_br %1364, ^bb202, ^bb203
        ^bb202:
          %1365 = llvm.load %1360 : !llvm.ptr -> i32
          %1366 = arith.cmpi sle, %1365, %1179 : i32
          %1367 = scf.if %1366 -> (i64) {
            %1369 = llvm.load %1360 : !llvm.ptr -> i32
            %1370 = arith.extsi %1369 : i32 to i64
            %1371 = llvm.getelementptr %1208[%1370] : (!llvm.ptr, i64) -> !llvm.ptr, i64
            %1368 = llvm.load %1371 : !llvm.ptr -> i64
            scf.yield %1368 : i64
          } else {
            %1372 = arith.constant 0 : i32
            scf.yield %1372 : i32
          }
          %1373 = llvm.load %1360 : !llvm.ptr -> i32
          %1374 = arith.extsi %1373 : i32 to i64
          %1375 = llvm.getelementptr %1233[%1374] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          llvm.store %1367, %1375 : i64, !llvm.ptr
          %1376 = llvm.load %1360 : !llvm.ptr -> i32
          %1377 = arith.constant 1 : i32
          %1378 = arith.addi %1376, %1377 : i32
          llvm.store %1378, %1360 : i32, !llvm.ptr
          cf.br ^bb201
        ^bb203:
        %1379 = arith.constant 0 : i32
        %1380 = llvm.mlir.constant(1 : i64) : i64
        %1381 = llvm.alloca %1380 x i32 : (i64) -> !llvm.ptr
        llvm.store %1379, %1381 : i32, !llvm.ptr
        cf.br ^bb204
        ^bb204:
        %1382 = llvm.load %1381 : !llvm.ptr -> i32
        %1383 = llvm.load %1125 : !llvm.ptr -> i32
        %1384 = arith.cmpi slt, %1382, %1383 : i32
        cf.cond_br %1384, ^bb205, ^bb206
        ^bb205:
          %1386 = llvm.load %1381 : !llvm.ptr -> i32
          %1387 = arith.extsi %1386 : i32 to i64
          %1388 = llvm.getelementptr %1115[%1387] : (!llvm.ptr, i64) -> !llvm.ptr, i32
          %1385 = llvm.load %1388 : !llvm.ptr -> i32
          %1389 = arith.cmpi sgt, %1385, %1179 : i32
          cf.cond_br %1389, ^bb207, ^bb208
          ^bb207:
            %1392 = llvm.load %1381 : !llvm.ptr -> i32
            %1393 = arith.extsi %1392 : i32 to i64
            %1394 = llvm.getelementptr %1115[%1393] : (!llvm.ptr, i64) -> !llvm.ptr, i32
            %1391 = llvm.load %1394 : !llvm.ptr -> i32
            %1395 = arith.extsi %1391 : i32 to i64
            func.call @poly_x_n(%1245, %1395, %1227, %1239) : (!llvm.ptr, i64, !llvm.ptr, !llvm.ptr) -> ()
            %1396 = func.call @term_from_poly(%1233, %1239) : (!llvm.ptr, !llvm.ptr) -> i64
            %1397 = llvm.load %1381 : !llvm.ptr -> i32
            %1398 = arith.extsi %1397 : i32 to i64
            %1399 = llvm.getelementptr %1214[%1398] : (!llvm.ptr, i64) -> !llvm.ptr, i64
            llvm.store %1396, %1399 : i64, !llvm.ptr
            cf.br ^bb209
          ^bb208:
            cf.br ^bb209
          ^bb209:
          %1400 = llvm.load %1381 : !llvm.ptr -> i32
          %1401 = arith.constant 1 : i32
          %1402 = arith.addi %1400, %1401 : i32
          llvm.store %1402, %1381 : i32, !llvm.ptr
          cf.br ^bb204
        ^bb206:
        cf.br ^bb197
      ^bb196:
        cf.br ^bb197
      ^bb197:
      %1403 = arith.constant 1 : i32
      %1404 = arith.extsi %1403 : i32 to i64
      %1405 = llvm.mlir.constant(1 : i64) : i64
      %1406 = llvm.alloca %1405 x i64 : (i64) -> !llvm.ptr
      llvm.store %1404, %1406 : i64, !llvm.ptr
      %1407 = arith.constant 0 : i32
      %1408 = llvm.mlir.constant(1 : i64) : i64
      %1409 = llvm.alloca %1408 x i32 : (i64) -> !llvm.ptr
      llvm.store %1407, %1409 : i32, !llvm.ptr
      cf.br ^bb210
      ^bb210:
      %1410 = llvm.load %1409 : !llvm.ptr -> i32
      %1411 = llvm.load %1125 : !llvm.ptr -> i32
      %1412 = arith.cmpi slt, %1410, %1411 : i32
      cf.cond_br %1412, ^bb211, ^bb212
      ^bb211:
        %1414 = llvm.load %1409 : !llvm.ptr -> i32
        %1415 = arith.extsi %1414 : i32 to i64
        %1416 = llvm.getelementptr %1115[%1415] : (!llvm.ptr, i64) -> !llvm.ptr, i32
        %1413 = llvm.load %1416 : !llvm.ptr -> i32
        %1417 = arith.cmpi sle, %1413, %1179 : i32
        %1418 = scf.if %1417 -> (i64) {
          %1421 = llvm.load %1409 : !llvm.ptr -> i32
          %1422 = arith.extsi %1421 : i32 to i64
          %1423 = llvm.getelementptr %1115[%1422] : (!llvm.ptr, i64) -> !llvm.ptr, i32
          %1420 = llvm.load %1423 : !llvm.ptr -> i32
          %1424 = arith.extsi %1420 : i32 to i64
          %1425 = llvm.getelementptr %1208[%1424] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          %1419 = llvm.load %1425 : !llvm.ptr -> i64
          scf.yield %1419 : i64
        } else {
          %1427 = llvm.load %1409 : !llvm.ptr -> i32
          %1428 = arith.extsi %1427 : i32 to i64
          %1429 = llvm.getelementptr %1214[%1428] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          %1426 = llvm.load %1429 : !llvm.ptr -> i64
          scf.yield %1426 : i64
        }
        %1430 = arith.constant 0 : i32
        %1432 = arith.extsi %1430 : i32 to i64
        %1431 = arith.cmpi eq, %1418, %1432 : i64
        cf.cond_br %1431, ^bb213, ^bb214
        ^bb213:
          %1433 = arith.constant 0 : i32
          %1434 = arith.extsi %1433 : i32 to i64
          llvm.store %1434, %1406 : i64, !llvm.ptr
          cf.br ^bb212
        ^bb214:
          cf.br ^bb215
        ^bb215:
        %1436 = llvm.load %1406 : !llvm.ptr -> i64
        %1439 = llvm.load %1409 : !llvm.ptr -> i32
        %1440 = arith.extsi %1439 : i32 to i64
        %1441 = llvm.getelementptr %1119[%1440] : (!llvm.ptr, i64) -> !llvm.ptr, i32
        %1438 = llvm.load %1441 : !llvm.ptr -> i32
        %1442 = arith.extsi %1438 : i32 to i64
        %1437 = func.call @mod_pow(%1418, %1442) : (i64, i64) -> i64
        %1435 = func.call @mod_mul(%1436, %1437) : (i64, i64) -> i64
        llvm.store %1435, %1406 : i64, !llvm.ptr
        %1443 = llvm.load %1409 : !llvm.ptr -> i32
        %1444 = arith.constant 1 : i32
        %1445 = arith.addi %1443, %1444 : i32
        llvm.store %1445, %1409 : i32, !llvm.ptr
        cf.br ^bb210
      ^bb212:
      %1446 = llvm.load %1406 : !llvm.ptr -> i64
      %1447 = arith.constant 0 : i32
      %1449 = arith.extsi %1447 : i32 to i64
      %1448 = arith.cmpi ne, %1446, %1449 : i64
      cf.cond_br %1448, ^bb216, ^bb217
      ^bb216:
        %1451 = llvm.mlir.addressof @g_coeffs : !llvm.ptr
        %1452 = llvm.load %1451 : !llvm.ptr -> !llvm.ptr
        %1453 = llvm.load %1260 : !llvm.ptr -> i32
        %1454 = arith.extsi %1453 : i32 to i64
        %1455 = llvm.getelementptr %1452[%1454] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %1450 = llvm.load %1455 : !llvm.ptr -> i64
        %1456 = llvm.mlir.addressof @MOD : !llvm.ptr
        %1457 = llvm.load %1456 : !llvm.ptr -> i64
        %1458 = arith.remsi %1450, %1457 : i64
        %1459 = llvm.mlir.constant(1 : i64) : i64
        %1460 = llvm.alloca %1459 x i64 : (i64) -> !llvm.ptr
        llvm.store %1458, %1460 : i64, !llvm.ptr
        %1461 = llvm.load %1460 : !llvm.ptr -> i64
        %1462 = arith.constant 0 : i32
        %1464 = arith.extsi %1462 : i32 to i64
        %1463 = arith.cmpi slt, %1461, %1464 : i64
        cf.cond_br %1463, ^bb219, ^bb220
        ^bb219:
          %1465 = llvm.load %1460 : !llvm.ptr -> i64
          %1466 = llvm.mlir.addressof @MOD : !llvm.ptr
          %1467 = llvm.load %1466 : !llvm.ptr -> i64
          %1468 = arith.addi %1465, %1467 : i64
          llvm.store %1468, %1460 : i64, !llvm.ptr
          cf.br ^bb221
        ^bb220:
          cf.br ^bb221
        ^bb221:
        %1470 = llvm.load %1257 : !llvm.ptr -> i64
        %1472 = llvm.load %1460 : !llvm.ptr -> i64
        %1473 = llvm.load %1406 : !llvm.ptr -> i64
        %1471 = func.call @mod_mul(%1472, %1473) : (i64, i64) -> i64
        %1469 = func.call @mod_add(%1470, %1471) : (i64, i64) -> i64
        llvm.store %1469, %1257 : i64, !llvm.ptr
        cf.br ^bb218
      ^bb217:
        cf.br ^bb218
      ^bb218:
      %1474 = llvm.load %1260 : !llvm.ptr -> i32
      %1475 = arith.constant 1 : i32
      %1476 = arith.addi %1474, %1475 : i32
      llvm.store %1476, %1260 : i32, !llvm.ptr
      cf.br ^bb174
    ^bb176:
    %1478 = llvm.load %1257 : !llvm.ptr -> i64
    %1477 = func.call @mod_mul(%1478, %1181) : (i64, i64) -> i64
    llvm.store %1477, %1257 : i64, !llvm.ptr
    func.call @free(%1214) : (!llvm.ptr) -> ()
    func.call @free(%1208) : (!llvm.ptr) -> ()
    func.call @free(%1219) : (!llvm.ptr) -> ()
    func.call @free(%1227) : (!llvm.ptr) -> ()
    func.call @free(%1233) : (!llvm.ptr) -> ()
    func.call @free(%1239) : (!llvm.ptr) -> ()
    func.call @free(%1245) : (!llvm.ptr) -> ()
    func.call @free(%1119) : (!llvm.ptr) -> ()
    func.call @free(%1115) : (!llvm.ptr) -> ()
    func.call @free(%1081) : (!llvm.ptr) -> ()
    func.call @free(%1075) : (!llvm.ptr) -> ()
    %1490 = llvm.load %1257 : !llvm.ptr -> i64
    func.return %1490 : i64
  }
  func.func @main() -> i32 {
    func.call @build_partitions() : () -> ()
    %1493 = arith.constant 1000000 : i32
    %1494 = arith.constant 13000 : i32
    %1492 = func.call @compute_F(%1493, %1494) : (i32, i32) -> i64
    %1496 = llvm.mlir.addressof @g_keys : !llvm.ptr
    %1497 = llvm.load %1496 : !llvm.ptr -> !llvm.ptr
    func.call @free(%1497) : (!llvm.ptr) -> ()
    %1499 = llvm.mlir.addressof @g_key_lens : !llvm.ptr
    %1500 = llvm.load %1499 : !llvm.ptr -> !llvm.ptr
    func.call @free(%1500) : (!llvm.ptr) -> ()
    %1502 = llvm.mlir.addressof @g_coeffs : !llvm.ptr
    %1503 = llvm.load %1502 : !llvm.ptr -> !llvm.ptr
    func.call @free(%1503) : (!llvm.ptr) -> ()
    %1505 = llvm.mlir.addressof @g_block_members : !llvm.ptr
    %1506 = llvm.load %1505 : !llvm.ptr -> !llvm.ptr
    func.call @free(%1506) : (!llvm.ptr) -> ()
    %1508 = llvm.mlir.addressof @g_block_sizes : !llvm.ptr
    %1509 = llvm.load %1508 : !llvm.ptr -> !llvm.ptr
    func.call @free(%1509) : (!llvm.ptr) -> ()
    %1510 = llvm.mlir.addressof @str_0 : !llvm.ptr
    %1511 = llvm.call @printf(%1510, %1492) vararg(!llvm.func<i32 (ptr, ...)>) : (!llvm.ptr, i64) -> i32
    %1512 = arith.constant 0 : i32
    func.return %1512 : i32
  }
}