Problem 858

LCM - G(800) mod 1e9+7. G(N) = sum over all subsets S of {1..N} of lcm(S). Ported from native C to pure Flow.

Answer973077199
Output973077199
StatusPASS
Native helperno
Runtime30 ms
Peak memory2080 KB
Time complexityO(n^3) (estimated)
Space complexityO(n^2) (estimated)

Performance comparison

MetricOur solutionBest known
Time complexityO(n^3)O(n * sum)
Space complexityO(n^2)O(sum)
ApproachFlow solutionSubset sum DP
VerdictUnknown

Flow source

# Project Euler 858
# LCM - G(800) mod 1e9+7.
# G(N) = sum over all subsets S of {1..N} of lcm(S).
# Ported from native C to pure Flow.

import euler.nt { mod_pow }

extern {
    function calloc(n: i64, size: i64) -> ptr<void>
    function free(p: ptr<void>) -> void
}

const MOD: i64 = 1000000007
const N: i64 = 800
const SQRT_N: i64 = 28
const N_WORDS: i64 = 13
const KMAX: i64 = 27
const LP_CAP: i64 = 65536

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

# Manual popcount for u64
function popcount_u64(x: u64) -> i32 {
    let mut v: u64 = x
    v = v - ((v >> 1) & 0x5555555555555555)
    v = (v & 0x3333333333333333) + ((v >> 2) & 0x3333333333333333)
    v = (v + (v >> 4)) & 0x0F0F0F0F0F0F0F0F
    return ((v * 0x0101010101010101) >> 56) as i32
}

# Sieve state
let mut g_is_prime: ptr<i8> = null
let mut g_primes: ptr<i32> = null
let mut g_num_primes: i32 = 0

function sieve() -> void {
    g_is_prime = calloc(N + 1, 1)
    let mut i: i32 = 0
    while i <= N {
        g_is_prime[i] = 1
        i = i + 1
    }
    g_is_prime[0] = 0
    g_is_prime[1] = 0
    let mut p: i32 = 2
    while p * p <= N {
        if g_is_prime[p] != 0 {
            let mut m: i32 = p * p
            while m <= N {
                g_is_prime[m] = 0
                m = m + p
            }
        }
        p = p + 1
    }
    g_primes = calloc(N + 1, 4)
    g_num_primes = 0
    i = 2
    while i <= N {
        if g_is_prime[i] != 0 {
            g_primes[g_num_primes] = i
            g_num_primes = g_num_primes + 1
        }
        i = i + 1
    }
}

# Global arrays
let mut g_e_val: ptr<i64> = null
let mut g_p_pow_e_mod: ptr<i64> = null
let mut g_inv_p_pow_e: ptr<i64> = null
let mut g_pow2: ptr<i64> = null
let mut g_inv2pow: ptr<i64> = null
let mut g_prefix_masks: ptr<u32> = null

let mut g_small_primes: ptr<i32> = null
let mut g_num_small_primes: i32 = 0
let mut g_large_primes: ptr<i32> = null
let mut g_num_large_primes: i32 = 0
let mut g_w_large: ptr<i64> = null

# Options: stored as flat arrays
# opt_maskN[si * 16 * 13 + j * 13 + w] for small prime si, option j, word w
let mut g_opt_maskN: ptr<u64> = null
let mut g_opt_maskK: ptr<u32> = null
let mut g_opt_weight: ptr<i64> = null
let mut g_opt_count: ptr<i32> = null

# Hash map for large_product memoization
let mut g_lp_key: ptr<u32> = null
let mut g_lp_val: ptr<i64> = null
let mut g_lp_used: ptr<i8> = null

function lp_clear() -> void {
    let mut i: i64 = 0
    while i < LP_CAP {
        g_lp_used[i] = 0
        i = i + 1
    }
}

function lp_lookup(key: u32) -> i64 {
    let mut h: i64 = ((key as i64) * 2654435761) % LP_CAP
    while g_lp_used[h] != 0 {
        if g_lp_key[h] == key { return g_lp_val[h] }
        h = (h + 1) % LP_CAP
    }
    return -1
}

function lp_insert(key: u32, val: i64) -> void {
    let mut h: i64 = ((key as i64) * 2654435761) % LP_CAP
    while g_lp_used[h] != 0 {
        if g_lp_key[h] == key {
            g_lp_val[h] = val
            return
        }
        h = (h + 1) % LP_CAP
    }
    g_lp_used[h] = 1
    g_lp_key[h] = key
    g_lp_val[h] = val
}

function large_product(maskK: u32) -> i64 {
    let cached: i64 = lp_lookup(maskK)
    if cached >= 0 { return cached }

    let mut prod: i64 = 1
    let mut i: i32 = 0
    while i < g_num_large_primes {
        let p: i32 = g_large_primes[i]
        let t: i32 = (N / (p as i64)) as i32
        let mut covered: i32 = 0
        if t > 0 {
            let pmask: u32 = g_prefix_masks[t]
            let masked: u32 = maskK & pmask
            covered = popcount_u64(masked as u64)
        }
        let new_val: i32 = t - covered
        let factor: i64 = (1 - mm(g_w_large[p], g_inv2pow[new_val])) % MOD
        factor = (factor % MOD + MOD) % MOD
        prod = mm(prod, factor)
        i = i + 1
    }
    lp_insert(maskK, prod)
    return prod
}

# DFS state: maskN (ptr<u64> of N_WORDS), maskK (u32), coeff (i64)
let mut g_dfs_total: i64 = 0

function bitset_popcount(bs: ptr<u64>) -> i32 {
    let mut cnt: i32 = 0
    let mut i: i64 = 0
    while i < N_WORDS {
        cnt = cnt + popcount_u64(bs[i])
        i = i + 1
    }
    return cnt
}

function dfs(i: i32, maskN: ptr<u64>, maskK: u32, coeff: i64) -> void {
    if i == g_num_small_primes {
        let covered_count: i32 = bitset_popcount(maskN)
        let base: i64 = g_pow2[N - (covered_count as i64)]
        let lp: i64 = large_product(maskK)
        g_dfs_total = (g_dfs_total + mm(mm(coeff, base), lp)) % MOD
        return
    }
    let mut j: i32 = 0
    while j < g_opt_count[i] {
        # Copy maskN
        let new_maskN: ptr<u64> = calloc(N_WORDS, 8)
        let mut w: i64 = 0
        while w < N_WORDS {
            new_maskN[w] = maskN[w]
            w = w + 1
        }
        # OR in option's maskN
        let base_idx: i64 = (i as i64) * 16 * N_WORDS + (j as i64) * N_WORDS
        w = 0
        while w < N_WORDS {
            new_maskN[w] = new_maskN[w] | g_opt_maskN[base_idx + w]
            w = w + 1
        }
        let new_maskK: u32 = maskK | g_opt_maskK[(i as i64) * 16 + (j as i64)]
        let new_coeff: i64 = mm(coeff, g_opt_weight[(i as i64) * 16 + (j as i64)])
        dfs(i + 1, new_maskN, new_maskK, new_coeff)
        free(new_maskN)
        j = j + 1
    }
}

function main() -> i32 {
    sieve()

    # Allocate global arrays
    g_e_val = calloc(N + 1, 8)
    g_p_pow_e_mod = calloc(N + 1, 8)
    g_inv_p_pow_e = calloc(N + 1, 8)
    g_pow2 = calloc(N + 1, 8)
    g_inv2pow = calloc(KMAX + 1, 8)
    g_prefix_masks = calloc(KMAX + 1, 4)
    g_small_primes = calloc(32, 4)
    g_large_primes = calloc(200, 4)
    g_w_large = calloc(N + 1, 8)
    g_opt_maskN = calloc(32 * 16 * N_WORDS, 8)
    g_opt_maskK = calloc(32 * 16, 4)
    g_opt_weight = calloc(32 * 16, 8)
    g_opt_count = calloc(32, 4)
    g_lp_key = calloc(LP_CAP, 4)
    g_lp_val = calloc(LP_CAP, 8)
    g_lp_used = calloc(LP_CAP, 1)

    # Compute e[p], p^e mod MOD, inv_p^e
    let mut L_mod: i64 = 1
    let mut pi: i32 = 0
    while pi < g_num_primes {
        let p: i32 = g_primes[pi]
        let mut ep: i32 = 0
        let mut t: i64 = p as i64
        while t <= N {
            ep = ep + 1
            t = t * (p as i64)
        }
        g_e_val[p] = ep as i64
        let pe_mod: i64 = mod_pow(p as i64, ep as i64, MOD)
        g_p_pow_e_mod[p] = pe_mod
        g_inv_p_pow_e[p] = mod_pow(pe_mod, MOD - 2, MOD)
        L_mod = mm(L_mod, pe_mod)
        pi = pi + 1
    }

    # Split primes
    g_num_small_primes = 0
    g_num_large_primes = 0
    pi = 0
    while pi < g_num_primes {
        let p: i32 = g_primes[pi]
        if p <= SQRT_N {
            g_small_primes[g_num_small_primes] = p
            g_num_small_primes = g_num_small_primes + 1
        } else {
            g_large_primes[g_num_large_primes] = p
            g_num_large_primes = g_num_large_primes + 1
        }
        pi = pi + 1
    }

    # Precompute pow2 and inv2pow
    g_pow2[0] = 1
    let mut i: i64 = 1
    while i <= N {
        g_pow2[i] = mm(g_pow2[i - 1], 2)
        i = i + 1
    }
    let inv2: i64 = (MOD + 1) / 2
    g_inv2pow[0] = 1
    i = 1
    while i <= KMAX {
        g_inv2pow[i] = mm(g_inv2pow[i - 1], inv2)
        i = i + 1
    }

    # prefix_masks
    g_prefix_masks[0] = 0
    let mut t: i64 = 1
    while t <= KMAX {
        g_prefix_masks[t] = ((1 as i64) << t) - 1
        t = t + 1
    }

    # Build options for each small prime
    let mut si: i32 = 0
    while si < g_num_small_primes {
        let p: i32 = g_small_primes[si]
        let ep: i64 = g_e_val[p]
        let mut nopt: i32 = 0

        # r=0: not selected
        let base0: i64 = (si as i64) * 16 * N_WORDS + (nopt as i64) * N_WORDS
        let mut w: i64 = 0
        while w < N_WORDS {
            g_opt_maskN[base0 + w] = 0
            w = w + 1
        }
        g_opt_maskK[(si as i64) * 16 + nopt] = 0
        g_opt_weight[(si as i64) * 16 + nopt] = 1
        nopt = nopt + 1

        # r=1..ep
        let mut r: i64 = 1
        while r <= ep {
            let mut q: i64 = 1
            let mut j: i64 = 0
            while j < r {
                q = q * (p as i64)
                j = j + 1
            }

            let base_idx: i64 = (si as i64) * 16 * N_WORDS + (nopt as i64) * N_WORDS
            w = 0
            while w < N_WORDS {
                g_opt_maskN[base_idx + w] = 0
                w = w + 1
            }
            let mut m: i64 = q
            while m <= N {
                let pos: i64 = m - 1
                g_opt_maskN[base_idx + pos / 64] = g_opt_maskN[base_idx + pos / 64] | ((1 as u64) << (pos % 64))
                m = m + q
            }

            let mut maskK: u32 = 0
            if q <= KMAX {
                let mut m2: i64 = q
                while m2 <= KMAX {
                    maskK = maskK | ((1 as u32) << ((m2 - 1) as i32))
                    m2 = m2 + q
                }
            }
            g_opt_maskK[(si as i64) * 16 + nopt] = maskK

            # phi(p^r) = p^(r-1) * (p-1)
            let phi: i64 = mm(mod_pow(p as i64, r - 1, MOD), (p - 1) as i64)
            let w_val: i64 = mm(phi, g_inv_p_pow_e[p])
            g_opt_weight[(si as i64) * 16 + nopt] = (MOD - w_val) % MOD
            nopt = nopt + 1
            r = r + 1
        }
        g_opt_count[si] = nopt
        si = si + 1
    }

    # Compute w_large for large primes
    let mut i2: i32 = 0
    while i2 < g_num_large_primes {
        let p: i32 = g_large_primes[i2]
        let invp: i64 = mod_pow(p as i64, MOD - 2, MOD)
        g_w_large[p] = mm((p - 1) as i64, invp)
        i2 = i2 + 1
    }

    # Run DFS
    lp_clear()
    g_dfs_total = 0
    let empty_mask: ptr<u64> = calloc(N_WORDS, 8)
    let mut w: i64 = 0
    while w < N_WORDS {
        empty_mask[w] = 0
        w = w + 1
    }
    dfs(0, empty_mask, 0, 1)
    free(empty_mask)

    printf("%lld\n", mm(L_mod, g_dfs_total))

    free(g_is_prime)
    free(g_primes)
    free(g_e_val)
    free(g_p_pow_e_mod)
    free(g_inv_p_pow_e)
    free(g_pow2)
    free(g_inv2pow)
    free(g_prefix_masks)
    free(g_small_primes)
    free(g_large_primes)
    free(g_w_large)
    free(g_opt_maskN)
    free(g_opt_maskK)
    free(g_opt_weight)
    free(g_opt_count)
    free(g_lp_key)
    free(g_lp_val)
    free(g_lp_used)
    return 0
}

Generated C

#include <stdint.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

/* Flow runtime helpers */
typedef struct flow_temp_node { struct flow_temp_node* next; } flow_temp_node;
static flow_temp_node* flow_temp_head = NULL;
static int flow_temp_atexit_set = 0;
__attribute__((unused)) static void flow_temp_free_all(void) {
    while (flow_temp_head) {
        flow_temp_node* n = flow_temp_head;
        flow_temp_head = n->next;
        free(n);
    }
}
__attribute__((unused)) static void* flow_temp_alloc(size_t nbytes) {
    flow_temp_node* node = (flow_temp_node*)malloc(sizeof(flow_temp_node) + nbytes);
    if (!node) return NULL;
    node->next = flow_temp_head;
    flow_temp_head = node;
    if (!flow_temp_atexit_set) {
        flow_temp_atexit_set = 1;
        atexit(flow_temp_free_all);
    }
    return (void*)(node + 1);
}
#ifndef FLOW_DIAG
#define FLOW_DIAG(msg) fprintf(stderr, "%s", (msg))
#endif
#ifndef FLOW_LOG
#define FLOW_LOG(fmt, ...) printf(fmt, __VA_ARGS__)
#endif
#ifndef FLOW_LOG_EMPTY
#define FLOW_LOG_EMPTY(fmt) printf(fmt)
#endif
static char* flow_strcat(const char* a, const char* b) {
    size_t la = strlen(a ? a : ""), lb = strlen(b ? b : "");
    char* r = (char*)flow_temp_alloc(la + lb + 1);
    if (!r) return NULL;
    if (la) memcpy(r, a, la);
    if (lb) memcpy(r + la, b, lb);
    r[la + lb] = '\0';
    return r;
}

#define __flow_in_arr(arr, val) __extension__ ({ \
    int _found = 0; \
    size_t _n = sizeof(arr)/sizeof((arr)[0]); \
    for (size_t _i = 0; _i < _n; _i++) { \
        if ((arr)[_i] == (val)) { _found = 1; break; } \
    } _found; })

/* Unified fault handler (MISRA #279) — override with -DFLOW_FAULT_HANDLER=fn */
#ifndef FLOW_FAULT_HANDLER
__attribute__((unused)) static inline void flow_fault_handler(const char* msg) {
    fprintf(stderr, "flow: %s\n", msg ? msg : "fault");
    abort();
#if defined(__GNUC__) || defined(__clang__)
    __builtin_unreachable();
#endif
}
#else
#define flow_fault_handler FLOW_FAULT_HANDLER
#endif
#define flow_div_by_zero_handler() flow_fault_handler("division by zero")
#define flow_shift_ub_handler() flow_fault_handler("invalid shift (amount out of range or left-shift of negative)")

#ifndef FLOW_CHECKED_DIV
#define FLOW_CHECKED_DIV(L, R) (((R) != 0) ? ((L) / (R)) : (flow_div_by_zero_handler(), (L) * 0))
#endif
#ifndef FLOW_CHECKED_MOD
#define FLOW_CHECKED_MOD(L, R) (((R) != 0) ? ((L) % (R)) : (flow_div_by_zero_handler(), (L) * 0))
#endif
#ifndef FLOW_CHECKED_SHL
#define FLOW_CHECKED_SHL(L, R) ((((R) >= 0) && ((unsigned long long)(R) < (sizeof(L) * 8ull)) && ((L) >= 0)) ? ((L) << (R)) : (flow_shift_ub_handler(), (L) * 0))
#endif
#ifndef FLOW_CHECKED_SHR
#define FLOW_CHECKED_SHR(L, R) ((((R) >= 0) && ((unsigned long long)(R) < (sizeof(L) * 8ull))) ? ((L) >> (R)) : (flow_shift_ub_handler(), (L) * 0))
#endif

#include <math.h>

void* _ui_state = NULL;

static inline float i32_to_f32(int32_t v) { return (float)v; }

/* Host stub for @gpu kernels (device codegen replaces this). */
static inline int32_t gpu_thread_id(void) { return 0; }

int64_t gcd_i64_i64(int64_t a0, int64_t b0);
int64_t lcm_i64_i64(int64_t a, int64_t b);
int64_t isqrt_i64(int64_t n);
int64_t mulmod_i64_i64_i64(int64_t a0, int64_t b0, int64_t mod);
int64_t mod_pow_i64_i64_i64(int64_t base, int64_t exp, int64_t mod);
bool is_prime_i64(int64_t n);
int64_t mm_i64_i64(int64_t a, int64_t b);
int32_t popcount_u64_u64(uint64_t x);
void sieve(void);
void lp_clear(void);
int64_t lp_lookup_u32(uint32_t key);
void lp_insert_u32_i64(uint32_t key, int64_t val);
int64_t large_product_u32(uint32_t maskK);
int32_t bitset_popcount_ptr_u64(uint64_t* bs);
void dfs_i32_ptr_u64_u32_i64(int32_t i, uint64_t* maskN, uint32_t maskK, int64_t coeff);
int32_t main(void);

static const int64_t MOD = 1000000007;
static const int64_t N = 800;
static const int64_t SQRT_N = 28;
static const int64_t N_WORDS = 13;
static const int64_t KMAX = 27;
static const int64_t LP_CAP = 65536;

/* Module statics */
static int8_t* g_is_prime = NULL;
static int32_t* g_primes = NULL;
static int32_t g_num_primes = 0;
static int64_t* g_e_val = NULL;
static int64_t* g_p_pow_e_mod = NULL;
static int64_t* g_inv_p_pow_e = NULL;
static int64_t* g_pow2 = NULL;
static int64_t* g_inv2pow = NULL;
static uint32_t* g_prefix_masks = NULL;
static int32_t* g_small_primes = NULL;
static int32_t g_num_small_primes = 0;
static int32_t* g_large_primes = NULL;
static int32_t g_num_large_primes = 0;
static int64_t* g_w_large = NULL;
static uint64_t* g_opt_maskN = NULL;
static uint32_t* g_opt_maskK = NULL;
static int64_t* g_opt_weight = NULL;
static int32_t* g_opt_count = NULL;
static uint32_t* g_lp_key = NULL;
static int64_t* g_lp_val = NULL;
static int8_t* g_lp_used = NULL;
static int64_t g_dfs_total = 0;

int64_t gcd_i64_i64(int64_t a0, int64_t b0) {
    int64_t a = a0;
    int64_t b = b0;
    while (b != 0) {
        int64_t t = FLOW_CHECKED_MOD((a), (b));
        a = b;
        b = t;
    }
    return a;
}

int64_t lcm_i64_i64(int64_t a, int64_t b) {
    if ((a == 0 || b == 0)) {
        return 0;
    }
    return (FLOW_CHECKED_DIV((a), (gcd_i64_i64(a, b))) * b);
}

int64_t isqrt_i64(int64_t n) {
    if (n < 2) {
        return n;
    }
    int64_t x = n;
    int64_t y = FLOW_CHECKED_DIV(((x + 1)), (2));
    while (y < x) {
        x = y;
        y = FLOW_CHECKED_DIV(((x + FLOW_CHECKED_DIV((n), (x)))), (2));
    }
    return x;
}

int64_t mulmod_i64_i64_i64(int64_t a0, int64_t b0, int64_t mod) {
    int64_t a = FLOW_CHECKED_MOD((a0), (mod));
    int64_t b = FLOW_CHECKED_MOD((b0), (mod));
    int64_t result = 0;
    while (b > 0) {
        if (FLOW_CHECKED_MOD((b), (2)) == 1) {
            result = FLOW_CHECKED_MOD(((result + a)), (mod));
        }
        a = FLOW_CHECKED_MOD(((a * 2)), (mod));
        b = FLOW_CHECKED_DIV((b), (2));
    }
    return result;
}

int64_t mod_pow_i64_i64_i64(int64_t base, int64_t exp, int64_t mod) {
    if (mod == 1) {
        return 0;
    }
    int64_t result = 1;
    int64_t b = FLOW_CHECKED_MOD((base), (mod));
    int64_t e = exp;
    while (e > 0) {
        if (FLOW_CHECKED_MOD((e), (2)) == 1) {
            result = mulmod_i64_i64_i64(result, b, mod);
        }
        b = mulmod_i64_i64_i64(b, b, mod);
        e = FLOW_CHECKED_DIV((e), (2));
    }
    return result;
}

bool is_prime_i64(int64_t n) {
    if (n < 2) {
        return 0;
    }
    if (n < 4) {
        return 1;
    }
    if ((FLOW_CHECKED_MOD((n), (2)) == 0 || FLOW_CHECKED_MOD((n), (3)) == 0)) {
        return 0;
    }
    int64_t i = 5;
    while ((i * i) <= n) {
        if ((FLOW_CHECKED_MOD((n), (i)) == 0 || FLOW_CHECKED_MOD((n), ((i + 2))) == 0)) {
            return 0;
        }
        i = (i + 6);
    }
    return 1;
}



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

int32_t popcount_u64_u64(uint64_t x) {
    uint64_t v = x;
    v = (v - (FLOW_CHECKED_SHR((v), (1)) & 6148914691236517205));
    v = ((v & 3689348814741910323) + (FLOW_CHECKED_SHR((v), (2)) & 3689348814741910323));
    v = ((v + FLOW_CHECKED_SHR((v), (4))) & 1085102592571150095);
    return ((int32_t)(FLOW_CHECKED_SHR(((v * 72340172838076673)), (56))));
}

void sieve(void) {
    g_is_prime = calloc((N + 1), 1);
    int32_t i = 0;
    while (i <= N) {
        g_is_prime[i] = 1;
        i = (i + 1);
    }
    g_is_prime[0] = 0;
    g_is_prime[1] = 0;
    int32_t p = 2;
    while ((p * p) <= N) {
        if (g_is_prime[p] != 0) {
            int32_t m = (p * p);
            while (m <= N) {
                g_is_prime[m] = 0;
                m = (m + p);
            }
        }
        p = (p + 1);
    }
    g_primes = calloc((N + 1), 4);
    g_num_primes = 0;
    i = 2;
    while (i <= N) {
        if (g_is_prime[i] != 0) {
            g_primes[g_num_primes] = i;
            g_num_primes = (g_num_primes + 1);
        }
        i = (i + 1);
    }
}

void lp_clear(void) {
    int64_t i = 0;
    while (i < LP_CAP) {
        g_lp_used[i] = 0;
        i = (i + 1);
    }
}

int64_t lp_lookup_u32(uint32_t key) {
    int64_t h = FLOW_CHECKED_MOD(((((int64_t)(key)) * 2654435761)), (LP_CAP));
    while (g_lp_used[h] != 0) {
        if (g_lp_key[h] == key) {
            return g_lp_val[h];
        }
        h = FLOW_CHECKED_MOD(((h + 1)), (LP_CAP));
    }
    return (-1);
}

void lp_insert_u32_i64(uint32_t key, int64_t val) {
    int64_t h = FLOW_CHECKED_MOD(((((int64_t)(key)) * 2654435761)), (LP_CAP));
    while (g_lp_used[h] != 0) {
        if (g_lp_key[h] == key) {
            g_lp_val[h] = val;
            return;
        }
        h = FLOW_CHECKED_MOD(((h + 1)), (LP_CAP));
    }
    g_lp_used[h] = 1;
    g_lp_key[h] = key;
    g_lp_val[h] = val;
}

int64_t large_product_u32(uint32_t maskK) {
    int64_t cached = lp_lookup_u32(maskK);
    if (cached >= 0) {
        return cached;
    }
    int64_t prod = 1;
    int32_t i = 0;
    while (i < g_num_large_primes) {
        int32_t p = g_large_primes[i];
        int32_t t = ((int32_t)(FLOW_CHECKED_DIV((N), (((int64_t)(p))))));
        int32_t covered = 0;
        if (t > 0) {
            uint32_t pmask = g_prefix_masks[t];
            uint32_t masked = (maskK & pmask);
            covered = popcount_u64_u64(((uint64_t)(masked)));
        }
        int32_t new_val = (t - covered);
        int64_t factor = FLOW_CHECKED_MOD(((1 - mm_i64_i64(g_w_large[p], g_inv2pow[new_val]))), (MOD));
        factor = FLOW_CHECKED_MOD(((FLOW_CHECKED_MOD((factor), (MOD)) + MOD)), (MOD));
        prod = mm_i64_i64(prod, factor);
        i = (i + 1);
    }
    lp_insert_u32_i64(maskK, prod);
    return prod;
}

int32_t bitset_popcount_ptr_u64(uint64_t* bs) {
    int32_t cnt = 0;
    int64_t i = 0;
    while (i < N_WORDS) {
        cnt = (cnt + popcount_u64_u64(bs[i]));
        i = (i + 1);
    }
    return cnt;
}

void dfs_i32_ptr_u64_u32_i64(int32_t i, uint64_t* maskN, uint32_t maskK, int64_t coeff) {
    if (i == g_num_small_primes) {
        int32_t covered_count = bitset_popcount_ptr_u64(maskN);
        int64_t base = g_pow2[(N - ((int64_t)(covered_count)))];
        int64_t lp = large_product_u32(maskK);
        g_dfs_total = FLOW_CHECKED_MOD(((g_dfs_total + mm_i64_i64(mm_i64_i64(coeff, base), lp))), (MOD));
        return;
    }
    int32_t j = 0;
    while (j < g_opt_count[i]) {
        uint64_t* new_maskN = (uint64_t*)(calloc(N_WORDS, 8));
        int64_t w = 0;
        while (w < N_WORDS) {
            new_maskN[w] = maskN[w];
            w = (w + 1);
        }
        int64_t base_idx = (((((int64_t)(i)) * 16) * N_WORDS) + (((int64_t)(j)) * N_WORDS));
        w = 0;
        while (w < N_WORDS) {
            new_maskN[w] = (new_maskN[w] | g_opt_maskN[(base_idx + w)]);
            w = (w + 1);
        }
        uint32_t new_maskK = (maskK | g_opt_maskK[((((int64_t)(i)) * 16) + ((int64_t)(j)))]);
        int64_t new_coeff = mm_i64_i64(coeff, g_opt_weight[((((int64_t)(i)) * 16) + ((int64_t)(j)))]);
        dfs_i32_ptr_u64_u32_i64((i + 1), new_maskN, new_maskK, new_coeff);
        free(new_maskN);
        j = (j + 1);
    }
}

int32_t main(void) {
    sieve();
    g_e_val = calloc((N + 1), 8);
    g_p_pow_e_mod = calloc((N + 1), 8);
    g_inv_p_pow_e = calloc((N + 1), 8);
    g_pow2 = calloc((N + 1), 8);
    g_inv2pow = calloc((KMAX + 1), 8);
    g_prefix_masks = calloc((KMAX + 1), 4);
    g_small_primes = calloc(32, 4);
    g_large_primes = calloc(200, 4);
    g_w_large = calloc((N + 1), 8);
    g_opt_maskN = calloc(((32 * 16) * N_WORDS), 8);
    g_opt_maskK = calloc((32 * 16), 4);
    g_opt_weight = calloc((32 * 16), 8);
    g_opt_count = calloc(32, 4);
    g_lp_key = calloc(LP_CAP, 4);
    g_lp_val = calloc(LP_CAP, 8);
    g_lp_used = calloc(LP_CAP, 1);
    int64_t L_mod = 1;
    int32_t pi = 0;
    while (pi < g_num_primes) {
        int32_t p = g_primes[pi];
        int32_t ep = 0;
        int64_t t = ((int64_t)(p));
        while (t <= N) {
            ep = (ep + 1);
            t = (t * ((int64_t)(p)));
        }
        g_e_val[p] = ((int64_t)(ep));
        int64_t pe_mod = mod_pow_i64_i64_i64(((int64_t)(p)), ((int64_t)(ep)), MOD);
        g_p_pow_e_mod[p] = pe_mod;
        g_inv_p_pow_e[p] = mod_pow_i64_i64_i64(pe_mod, (MOD - 2), MOD);
        L_mod = mm_i64_i64(L_mod, pe_mod);
        pi = (pi + 1);
    }
    g_num_small_primes = 0;
    g_num_large_primes = 0;
    pi = 0;
    while (pi < g_num_primes) {
        int32_t p = g_primes[pi];
        if (p <= SQRT_N) {
            g_small_primes[g_num_small_primes] = p;
            g_num_small_primes = (g_num_small_primes + 1);
        } else {
            g_large_primes[g_num_large_primes] = p;
            g_num_large_primes = (g_num_large_primes + 1);
        }
        pi = (pi + 1);
    }
    g_pow2[0] = 1;
    int64_t i = 1;
    while (i <= N) {
        g_pow2[i] = mm_i64_i64(g_pow2[(i - 1)], 2);
        i = (i + 1);
    }
    int64_t inv2 = FLOW_CHECKED_DIV(((MOD + 1)), (2));
    g_inv2pow[0] = 1;
    i = 1;
    while (i <= KMAX) {
        g_inv2pow[i] = mm_i64_i64(g_inv2pow[(i - 1)], inv2);
        i = (i + 1);
    }
    g_prefix_masks[0] = 0;
    int64_t t = 1;
    while (t <= KMAX) {
        g_prefix_masks[t] = (FLOW_CHECKED_SHL((((int64_t)(1))), (t)) - 1);
        t = (t + 1);
    }
    int32_t si = 0;
    while (si < g_num_small_primes) {
        int32_t p = g_small_primes[si];
        int64_t ep = g_e_val[p];
        int32_t nopt = 0;
        int64_t base0 = (((((int64_t)(si)) * 16) * N_WORDS) + (((int64_t)(nopt)) * N_WORDS));
        int64_t w = 0;
        while (w < N_WORDS) {
            g_opt_maskN[(base0 + w)] = 0;
            w = (w + 1);
        }
        g_opt_maskK[((((int64_t)(si)) * 16) + nopt)] = 0;
        g_opt_weight[((((int64_t)(si)) * 16) + nopt)] = 1;
        nopt = (nopt + 1);
        int64_t r = 1;
        while (r <= ep) {
            int64_t q = 1;
            int64_t j = 0;
            while (j < r) {
                q = (q * ((int64_t)(p)));
                j = (j + 1);
            }
            int64_t base_idx = (((((int64_t)(si)) * 16) * N_WORDS) + (((int64_t)(nopt)) * N_WORDS));
            w = 0;
            while (w < N_WORDS) {
                g_opt_maskN[(base_idx + w)] = 0;
                w = (w + 1);
            }
            int64_t m = q;
            while (m <= N) {
                int64_t pos = (m - 1);
                g_opt_maskN[(base_idx + FLOW_CHECKED_DIV((pos), (64)))] = (g_opt_maskN[(base_idx + FLOW_CHECKED_DIV((pos), (64)))] | FLOW_CHECKED_SHL((((uint64_t)(1))), (FLOW_CHECKED_MOD((pos), (64)))));
                m = (m + q);
            }
            uint32_t maskK = 0;
            if (q <= KMAX) {
                int64_t m2 = q;
                while (m2 <= KMAX) {
                    maskK = (maskK | FLOW_CHECKED_SHL((((uint32_t)(1))), (((int32_t)((m2 - 1))))));
                    m2 = (m2 + q);
                }
            }
            g_opt_maskK[((((int64_t)(si)) * 16) + nopt)] = maskK;
            int64_t phi = mm_i64_i64(mod_pow_i64_i64_i64(((int64_t)(p)), (r - 1), MOD), ((int64_t)((p - 1))));
            int64_t w_val = mm_i64_i64(phi, g_inv_p_pow_e[p]);
            g_opt_weight[((((int64_t)(si)) * 16) + nopt)] = FLOW_CHECKED_MOD(((MOD - w_val)), (MOD));
            nopt = (nopt + 1);
            r = (r + 1);
        }
        g_opt_count[si] = nopt;
        si = (si + 1);
    }
    int32_t i2 = 0;
    while (i2 < g_num_large_primes) {
        int32_t p = g_large_primes[i2];
        int64_t invp = mod_pow_i64_i64_i64(((int64_t)(p)), (MOD - 2), MOD);
        g_w_large[p] = mm_i64_i64(((int64_t)((p - 1))), invp);
        i2 = (i2 + 1);
    }
    lp_clear();
    g_dfs_total = 0;
    uint64_t* empty_mask = (uint64_t*)(calloc(N_WORDS, 8));
    int64_t w = 0;
    while (w < N_WORDS) {
        empty_mask[w] = 0;
        w = (w + 1);
    }
    dfs_i32_ptr_u64_u32_i64(0, empty_mask, 0, 1);
    free(empty_mask);
    printf("%lld\n", mm_i64_i64(L_mod, g_dfs_total));
    free(g_is_prime);
    free(g_primes);
    free(g_e_val);
    free(g_p_pow_e_mod);
    free(g_inv_p_pow_e);
    free(g_pow2);
    free(g_inv2pow);
    free(g_prefix_masks);
    free(g_small_primes);
    free(g_large_primes);
    free(g_w_large);
    free(g_opt_maskN);
    free(g_opt_maskK);
    free(g_opt_weight);
    free(g_opt_count);
    free(g_lp_key);
    free(g_lp_val);
    free(g_lp_used);
    return 0;
}

Generated MLIR

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