Problem 593

Fleeting Medians — segmented sieve + discrete-log pow + sliding median counts.

Answer96632320042.0
Output96632320042.0
StatusPASS
Native helperno
Runtime360 ms
Peak memory5552 KB
Time complexityO(n^2) (estimated)
Space complexityO(n^2) (estimated)

Performance comparison

MetricOur solutionBest known
Time complexityO(n^2)?
Space complexityO(n^2)?
ApproachFlow solutionNot curated
VerdictUnknown

Flow source

# Project Euler 593
# Fleeting Medians — segmented sieve + discrete-log pow + sliding median counts.

extern {
    function calloc(n: i64, size: i64) -> ptr<void>
    function free(p: ptr<void>) -> void
    function log(x: f64) -> f64
    function memset(p: ptr<void>, c: i32, n: i64) -> ptr<void>
}

const MOD: i64 = 10007
const PHI: i64 = 10006
const DOM_SZ: i64 = 20013

function isqrt(n: i64) -> i64 {
    if n <= 0 { return 0 }
    let mut x: i64 = n
    let mut y: i64 = (x + 1) / 2
    while y < x {
        x = y
        y = (x + n / x) / 2
    }
    return x
}

function modpow(base0: i64, exp0: i64, modv: i64) -> i64 {
    let mut result: i64 = 1
    let mut base: i64 = base0 % modv
    let mut exp: i64 = exp0
    while exp > 0 {
        if (exp & 1) != 0 {
            result = (result * base) % modv
        }
        base = (base * base) % modv
        exp = exp >> 1
    }
    return result
}

function nth_prime_upper_bound(n: i64) -> i64 {
    if n < 6 { return 15 }
    let x: f64 = n as f64
    return (x * (log(x) + log(log(x))) + 10.0) as i64
}

function sieve_upto(limit: i64, primes: ptr<i64>) -> i64 {
    let s: ptr<i8> = calloc(limit + 1, 1)
    let mut i: i64 = 0
    while i <= limit { s[i] = 1; i = i + 1 }
    s[0] = 0
    s[1] = 0
    i = 2
    while i * i <= limit {
        if s[i] != 0 {
            let mut j: i64 = i * i
            while j <= limit {
                s[j] = 0
                j = j + i
            }
        }
        i = i + 1
    }
    let mut m: i64 = 0
    i = 2
    while i <= limit {
        if s[i] != 0 {
            primes[m] = i
            m = m + 1
        }
        i = i + 1
    }
    free(s)
    return m
}

function build_tables(logt: ptr<i64>, expt: ptr<i64>) -> void {
    # factorize PHI=10006 = 2*5003
    let factors: ptr<i64> = calloc(8, 8)
    factors[0] = 2
    factors[1] = 5003
    let nf: i64 = 2
    let mut g: i64 = 0
    let mut cand: i64 = 2
    while cand < MOD {
        let mut ok: i64 = 1
        let mut qi: i64 = 0
        while qi < nf {
            if modpow(cand, PHI / factors[qi], MOD) == 1 {
                ok = 0
            }
            qi = qi + 1
        }
        if ok != 0 {
            g = cand
            break
        }
        cand = cand + 1
    }
    free(factors)
    let mut x: i64 = 1
    let mut i: i64 = 0
    while i < MOD {
        logt[i] = -1
        i = i + 1
    }
    i = 0
    while i < PHI {
        expt[i] = x
        logt[x] = i
        x = (x * g) % MOD
        i = i + 1
    }
}

function pow_fast(a_mod: i64, e_mod: i64, logt: ptr<i64>, expt: ptr<i64>) -> i64 {
    if a_mod == 0 { return 0 }
    return expt[(logt[a_mod] * e_mod) % PHI]
}

function compute_F2(n: i64, k: i64) -> i64 {
    let logt: ptr<i64> = calloc(MOD, 8)
    let expt: ptr<i64> = calloc(PHI, 8)
    build_tables(logt, expt)

    let counts: ptr<i64> = calloc(DOM_SZ, 8)
    let window: ptr<i64> = calloc(k, 8)
    let mut filled: i64 = 0
    let mut pos: i64 = 0
    let even: i64 = 0
    if (k & 1) == 0 { even = 1 }
    let mut r1: i64 = (k + 1) / 2
    if even != 0 { r1 = k / 2 }
    let mut m1: i64 = 0
    let mut below: i64 = 0
    let mut sum2: i64 = 0

    let offsets: ptr<i64> = calloc(1002, 8)
    let mut e: i64 = 1
    let mut t: i64 = 1
    let mut next_t: i64 = 10000
    let mut idx: i64 = 1

    # prime 2
    let s0: i64 = pow_fast(2 % MOD, e, logt, expt)
    offsets[1] = s0
    let v0: i64 = s0 + s0
    window[0] = v0
    counts[v0] = counts[v0] + 1
    filled = 1

    if k == 1 {
        m1 = v0
        below = 0
        sum2 = sum2 + (m1 << 1)
        if n == 1 {
            free(logt); free(expt); free(counts); free(window); free(offsets)
            return sum2
        }
    }

    let limit: i64 = nth_prime_upper_bound(n)
    let root: i64 = isqrt(limit)
    let base_primes: ptr<i64> = calloc(root + 100, 8)
    let nbase: i64 = sieve_upto(root, base_primes)
    # collect odd base primes
    let base_odds: ptr<i64> = calloc(nbase, 8)
    let base_sq: ptr<i64> = calloc(nbase, 8)
    let mut nob: i64 = 0
    let mut bi: i64 = 0
    while bi < nbase {
        let p: i64 = base_primes[bi]
        if p > 2 {
            base_odds[nob] = p
            base_sq[nob] = p * p
            nob = nob + 1
        }
        bi = bi + 1
    }

    let seg_odds: i64 = 1 << 20
    let mut low: i64 = 3
    while low <= limit {
        let mut high: i64 = low + 2 * seg_odds
        if high > limit + 1 { high = limit + 1 }
        let seg_len: i64 = (high - low) / 2
        let seg: ptr<i8> = calloc(seg_len, 1)
        let mut si: i64 = 0
        while si < seg_len { seg[si] = 1; si = si + 1 }

        bi = 0
        while bi < nob {
            let p: i64 = base_odds[bi]
            let sq: i64 = base_sq[bi]
            if sq >= high { break }
            let mut start: i64 = sq
            if start < low {
                let rem: i64 = low % p
                if rem == 0 {
                    start = low
                } else {
                    start = low + (p - rem)
                }
                if (start & 1) == 0 { start = start + p }
            }
            let mut j: i64 = (start - low) / 2
            while j < seg_len {
                seg[j] = 0
                j = j + p
            }
            bi = bi + 1
        }

        si = 0
        while si < seg_len {
            if seg[si] != 0 {
                let prime: i64 = low + 2 * si
                idx = idx + 1
                e = e + 1
                if e == PHI { e = 0 }
                if idx == next_t {
                    t = t + 1
                    next_t = next_t + 10000
                }
                let pm: i64 = prime % MOD
                let s: i64 = pow_fast(pm, e, logt, expt)
                if idx <= 1001 { offsets[idx] = s }
                let v: i64 = s + offsets[t]

                if filled < k {
                    window[filled] = v
                    counts[v] = counts[v] + 1
                    filled = filled + 1
                    if filled == k {
                        # init m1
                        let mut cum: i64 = 0
                        let mut vv: i64 = 0
                        while cum + counts[vv] < r1 {
                            cum = cum + counts[vv]
                            vv = vv + 1
                        }
                        m1 = vv
                        below = cum
                        # median2
                        if even == 0 {
                            sum2 = sum2 + (m1 << 1)
                        } else {
                            let pos_in: i64 = r1 - below
                            if pos_in < counts[m1] {
                                sum2 = sum2 + (m1 << 1)
                            } else {
                                let mut m2: i64 = m1 + 1
                                while counts[m2] == 0 { m2 = m2 + 1 }
                                sum2 = sum2 + m1 + m2
                            }
                        }
                    }
                    if idx == n {
                        free(seg); free(logt); free(expt); free(counts); free(window); free(offsets)
                        free(base_primes); free(base_odds); free(base_sq)
                        return sum2
                    }
                } else {
                    let outv: i64 = window[pos]
                    if outv != v {
                        counts[outv] = counts[outv] - 1
                        if outv < m1 { below = below - 1 }
                        window[pos] = v
                        counts[v] = counts[v] + 1
                        if v < m1 { below = below + 1 }
                        # adjust m1
                        while below >= r1 {
                            m1 = m1 - 1
                            below = below - counts[m1]
                        }
                        while below + counts[m1] < r1 {
                            below = below + counts[m1]
                            m1 = m1 + 1
                        }
                    } else {
                        window[pos] = v
                    }
                    pos = pos + 1
                    if pos == k { pos = 0 }
                    if even == 0 {
                        sum2 = sum2 + (m1 << 1)
                    } else {
                        let pos_in: i64 = r1 - below
                        if pos_in < counts[m1] {
                            sum2 = sum2 + (m1 << 1)
                        } else {
                            let mut m2: i64 = m1 + 1
                            while counts[m2] == 0 { m2 = m2 + 1 }
                            sum2 = sum2 + m1 + m2
                        }
                    }
                    if idx == n {
                        free(seg); free(logt); free(expt); free(counts); free(window); free(offsets)
                        free(base_primes); free(base_odds); free(base_sq)
                        return sum2
                    }
                }
            }
            si = si + 1
        }
        free(seg)
        low = high | 1
    }
    return sum2
}

function main() -> i32 {
    let ans2: i64 = compute_F2(10000000, 100000)
    # print as half with .0 or .5 — answer is *.0
    printf("%.1f\n", (ans2 as f64) / 2.0)
    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 isqrt_i64(int64_t n);
int64_t modpow_i64_i64_i64(int64_t base0, int64_t exp0, int64_t modv);
int64_t nth_prime_upper_bound_i64(int64_t n);
int64_t sieve_upto_i64_ptr_i64(int64_t limit, int64_t* primes);
void build_tables_ptr_i64_ptr_i64(int64_t* logt, int64_t* expt);
int64_t pow_fast_i64_i64_ptr_i64_ptr_i64(int64_t a_mod, int64_t e_mod, int64_t* logt, int64_t* expt);
int64_t compute_F2_i64_i64(int64_t n, int64_t k);
int32_t main(void);

static const int64_t MOD = 10007;
static const int64_t PHI = 10006;
static const int64_t DOM_SZ = 20013;





int64_t isqrt_i64(int64_t n) {
    if (n <= 0) {
        return 0;
    }
    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 modpow_i64_i64_i64(int64_t base0, int64_t exp0, int64_t modv) {
    int64_t result = 1;
    int64_t base = FLOW_CHECKED_MOD((base0), (modv));
    int64_t exp = exp0;
    while (exp > 0) {
        if ((exp & 1) != 0) {
            result = FLOW_CHECKED_MOD(((result * base)), (modv));
        }
        base = FLOW_CHECKED_MOD(((base * base)), (modv));
        exp = FLOW_CHECKED_SHR((exp), (1));
    }
    return result;
}

int64_t nth_prime_upper_bound_i64(int64_t n) {
    if (n < 6) {
        return 15;
    }
    double x = ((double)(n));
    return ((int64_t)(((x * (log(x) + log(log(x)))) + 10.0)));
}

int64_t sieve_upto_i64_ptr_i64(int64_t limit, int64_t* primes) {
    int8_t* s = (int8_t*)(calloc((limit + 1), 1));
    int64_t i = 0;
    while (i <= limit) {
        s[i] = 1;
        i = (i + 1);
    }
    s[0] = 0;
    s[1] = 0;
    i = 2;
    while ((i * i) <= limit) {
        if (s[i] != 0) {
            int64_t j = (i * i);
            while (j <= limit) {
                s[j] = 0;
                j = (j + i);
            }
        }
        i = (i + 1);
    }
    int64_t m = 0;
    i = 2;
    while (i <= limit) {
        if (s[i] != 0) {
            primes[m] = i;
            m = (m + 1);
        }
        i = (i + 1);
    }
    free(s);
    return m;
}

void build_tables_ptr_i64_ptr_i64(int64_t* logt, int64_t* expt) {
    int64_t* factors = (int64_t*)(calloc(8, 8));
    factors[0] = 2;
    factors[1] = 5003;
    int64_t nf = 2;
    int64_t g = 0;
    int64_t cand = 2;
    while (cand < MOD) {
        int64_t ok = 1;
        int64_t qi = 0;
        while (qi < nf) {
            if (modpow_i64_i64_i64(cand, FLOW_CHECKED_DIV((PHI), (factors[qi])), MOD) == 1) {
                ok = 0;
            }
            qi = (qi + 1);
        }
        if (ok != 0) {
            g = cand;
            break;
        }
        cand = (cand + 1);
    }
    free(factors);
    int64_t x = 1;
    int64_t i = 0;
    while (i < MOD) {
        logt[i] = (-1);
        i = (i + 1);
    }
    i = 0;
    while (i < PHI) {
        expt[i] = x;
        logt[x] = i;
        x = FLOW_CHECKED_MOD(((x * g)), (MOD));
        i = (i + 1);
    }
}

int64_t pow_fast_i64_i64_ptr_i64_ptr_i64(int64_t a_mod, int64_t e_mod, int64_t* logt, int64_t* expt) {
    if (a_mod == 0) {
        return 0;
    }
    return expt[FLOW_CHECKED_MOD(((logt[a_mod] * e_mod)), (PHI))];
}

int64_t compute_F2_i64_i64(int64_t n, int64_t k) {
    int64_t* logt = (int64_t*)(calloc(MOD, 8));
    int64_t* expt = (int64_t*)(calloc(PHI, 8));
    build_tables_ptr_i64_ptr_i64(logt, expt);
    int64_t* counts = (int64_t*)(calloc(DOM_SZ, 8));
    int64_t* window = (int64_t*)(calloc(k, 8));
    int64_t filled = 0;
    int64_t pos = 0;
    int64_t even = 0;
    if ((k & 1) == 0) {
        even = 1;
    }
    int64_t r1 = FLOW_CHECKED_DIV(((k + 1)), (2));
    if (even != 0) {
        r1 = FLOW_CHECKED_DIV((k), (2));
    }
    int64_t m1 = 0;
    int64_t below = 0;
    int64_t sum2 = 0;
    int64_t* offsets = (int64_t*)(calloc(1002, 8));
    int64_t e = 1;
    int64_t t = 1;
    int64_t next_t = 10000;
    int64_t idx = 1;
    int64_t s0 = pow_fast_i64_i64_ptr_i64_ptr_i64(FLOW_CHECKED_MOD((2), (MOD)), e, logt, expt);
    offsets[1] = s0;
    int64_t v0 = (s0 + s0);
    window[0] = v0;
    counts[v0] = (counts[v0] + 1);
    filled = 1;
    if (k == 1) {
        m1 = v0;
        below = 0;
        sum2 = (sum2 + FLOW_CHECKED_SHL((m1), (1)));
        if (n == 1) {
            free(logt);
            free(expt);
            free(counts);
            free(window);
            free(offsets);
            return sum2;
        }
    }
    int64_t limit = nth_prime_upper_bound_i64(n);
    int64_t root = isqrt_i64(limit);
    int64_t* base_primes = (int64_t*)(calloc((root + 100), 8));
    int64_t nbase = sieve_upto_i64_ptr_i64(root, base_primes);
    int64_t* base_odds = (int64_t*)(calloc(nbase, 8));
    int64_t* base_sq = (int64_t*)(calloc(nbase, 8));
    int64_t nob = 0;
    int64_t bi = 0;
    while (bi < nbase) {
        int64_t p = base_primes[bi];
        if (p > 2) {
            base_odds[nob] = p;
            base_sq[nob] = (p * p);
            nob = (nob + 1);
        }
        bi = (bi + 1);
    }
    int64_t seg_odds = FLOW_CHECKED_SHL((1), (20));
    int64_t low = 3;
    while (low <= limit) {
        int64_t high = (low + (2 * seg_odds));
        if (high > (limit + 1)) {
            high = (limit + 1);
        }
        int64_t seg_len = FLOW_CHECKED_DIV(((high - low)), (2));
        int8_t* seg = (int8_t*)(calloc(seg_len, 1));
        int64_t si = 0;
        while (si < seg_len) {
            seg[si] = 1;
            si = (si + 1);
        }
        bi = 0;
        while (bi < nob) {
            int64_t p = base_odds[bi];
            int64_t sq = base_sq[bi];
            if (sq >= high) {
                break;
            }
            int64_t start = sq;
            if (start < low) {
                int64_t rem = FLOW_CHECKED_MOD((low), (p));
                if (rem == 0) {
                    start = low;
                } else {
                    start = (low + (p - rem));
                }
                if ((start & 1) == 0) {
                    start = (start + p);
                }
            }
            int64_t j = FLOW_CHECKED_DIV(((start - low)), (2));
            while (j < seg_len) {
                seg[j] = 0;
                j = (j + p);
            }
            bi = (bi + 1);
        }
        si = 0;
        while (si < seg_len) {
            if (seg[si] != 0) {
                int64_t prime = (low + (2 * si));
                idx = (idx + 1);
                e = (e + 1);
                if (e == PHI) {
                    e = 0;
                }
                if (idx == next_t) {
                    t = (t + 1);
                    next_t = (next_t + 10000);
                }
                int64_t pm = FLOW_CHECKED_MOD((prime), (MOD));
                int64_t s = pow_fast_i64_i64_ptr_i64_ptr_i64(pm, e, logt, expt);
                if (idx <= 1001) {
                    offsets[idx] = s;
                }
                int64_t v = (s + offsets[t]);
                if (filled < k) {
                    window[filled] = v;
                    counts[v] = (counts[v] + 1);
                    filled = (filled + 1);
                    if (filled == k) {
                        int64_t cum = 0;
                        int64_t vv = 0;
                        while ((cum + counts[vv]) < r1) {
                            cum = (cum + counts[vv]);
                            vv = (vv + 1);
                        }
                        m1 = vv;
                        below = cum;
                        if (even == 0) {
                            sum2 = (sum2 + FLOW_CHECKED_SHL((m1), (1)));
                        } else {
                            int64_t pos_in = (r1 - below);
                            if (pos_in < counts[m1]) {
                                sum2 = (sum2 + FLOW_CHECKED_SHL((m1), (1)));
                            } else {
                                int64_t m2 = (m1 + 1);
                                while (counts[m2] == 0) {
                                    m2 = (m2 + 1);
                                }
                                sum2 = ((sum2 + m1) + m2);
                            }
                        }
                    }
                    if (idx == n) {
                        free(seg);
                        free(logt);
                        free(expt);
                        free(counts);
                        free(window);
                        free(offsets);
                        free(base_primes);
                        free(base_odds);
                        free(base_sq);
                        return sum2;
                    }
                } else {
                    int64_t outv = window[pos];
                    if (outv != v) {
                        counts[outv] = (counts[outv] - 1);
                        if (outv < m1) {
                            below = (below - 1);
                        }
                        window[pos] = v;
                        counts[v] = (counts[v] + 1);
                        if (v < m1) {
                            below = (below + 1);
                        }
                        while (below >= r1) {
                            m1 = (m1 - 1);
                            below = (below - counts[m1]);
                        }
                        while ((below + counts[m1]) < r1) {
                            below = (below + counts[m1]);
                            m1 = (m1 + 1);
                        }
                    } else {
                        window[pos] = v;
                    }
                    pos = (pos + 1);
                    if (pos == k) {
                        pos = 0;
                    }
                    if (even == 0) {
                        sum2 = (sum2 + FLOW_CHECKED_SHL((m1), (1)));
                    } else {
                        int64_t pos_in = (r1 - below);
                        if (pos_in < counts[m1]) {
                            sum2 = (sum2 + FLOW_CHECKED_SHL((m1), (1)));
                        } else {
                            int64_t m2 = (m1 + 1);
                            while (counts[m2] == 0) {
                                m2 = (m2 + 1);
                            }
                            sum2 = ((sum2 + m1) + m2);
                        }
                    }
                    if (idx == n) {
                        free(seg);
                        free(logt);
                        free(expt);
                        free(counts);
                        free(window);
                        free(offsets);
                        free(base_primes);
                        free(base_odds);
                        free(base_sq);
                        return sum2;
                    }
                }
            }
            si = (si + 1);
        }
        free(seg);
        low = (high | 1);
    }
    return sum2;
}

int32_t main(void) {
    int64_t ans2 = compute_F2_i64_i64(10000000, 100000);
    printf("%.1f\n", (((double)(ans2)) / 2.0));
    return 0;
}

Generated MLIR

module {
  llvm.func @printf(!llvm.ptr, ...) -> i32
  llvm.mlir.global internal constant @str_0("%.1f\n\00") {addr_space = 0 : i32} : !llvm.array<6 x i8>
  func.func private @calloc(i64, i64) -> !llvm.ptr
  func.func private @free(!llvm.ptr) -> ()
  func.func private @log(f64) -> f64
  func.func private @memset(!llvm.ptr, i32, i64) -> !llvm.ptr
  // Constant: MOD
  llvm.mlir.global internal constant @MOD(10007 : i64) : i64
  // Constant: PHI
  llvm.mlir.global internal constant @PHI(10006 : i64) : i64
  // Constant: DOM_SZ
  llvm.mlir.global internal constant @DOM_SZ(20013 : i64) : i64
  func.func @isqrt(%arg0: i64) -> i64 {
    %0 = arith.constant 0 : i32
    %2 = arith.extsi %0 : i32 to i64
    %1 = arith.cmpi sle, %arg0, %2 : i64
    cf.cond_br %1, ^bb0, ^bb1
    ^bb0:
      %3 = arith.constant 0 : i32
      %4 = arith.extsi %3 : i32 to i64
      func.return %4 : i64
    ^bb1:
      cf.br ^bb2
    ^bb2:
    %5 = llvm.mlir.constant(1 : i64) : i64
    %6 = llvm.alloca %5 x i64 : (i64) -> !llvm.ptr
    llvm.store %arg0, %6 : i64, !llvm.ptr
    %7 = llvm.load %6 : !llvm.ptr -> i64
    %8 = arith.constant 1 : i32
    %10 = arith.extsi %8 : i32 to i64
    %9 = arith.addi %7, %10 : i64
    %11 = arith.constant 2 : i32
    %13 = arith.extsi %11 : i32 to i64
    %12 = arith.divsi %9, %13 : i64
    %14 = llvm.mlir.constant(1 : i64) : i64
    %15 = llvm.alloca %14 x i64 : (i64) -> !llvm.ptr
    llvm.store %12, %15 : i64, !llvm.ptr
    cf.br ^bb3
    ^bb3:
    %16 = llvm.load %15 : !llvm.ptr -> i64
    %17 = llvm.load %6 : !llvm.ptr -> i64
    %18 = arith.cmpi slt, %16, %17 : i64
    cf.cond_br %18, ^bb4, ^bb5
    ^bb4:
      %19 = llvm.load %15 : !llvm.ptr -> i64
      llvm.store %19, %6 : i64, !llvm.ptr
      %20 = llvm.load %6 : !llvm.ptr -> i64
      %21 = llvm.load %6 : !llvm.ptr -> i64
      %22 = arith.divsi %arg0, %21 : i64
      %23 = arith.addi %20, %22 : i64
      %24 = arith.constant 2 : i32
      %26 = arith.extsi %24 : i32 to i64
      %25 = arith.divsi %23, %26 : i64
      llvm.store %25, %15 : i64, !llvm.ptr
      cf.br ^bb3
    ^bb5:
    %27 = llvm.load %6 : !llvm.ptr -> i64
    func.return %27 : i64
  }
  func.func @modpow(%arg0: i64, %arg1: i64, %arg2: i64) -> i64 {
    %28 = arith.constant 1 : i32
    %29 = arith.extsi %28 : i32 to i64
    %30 = llvm.mlir.constant(1 : i64) : i64
    %31 = llvm.alloca %30 x i64 : (i64) -> !llvm.ptr
    llvm.store %29, %31 : i64, !llvm.ptr
    %32 = arith.remsi %arg0, %arg2 : i64
    %33 = llvm.mlir.constant(1 : i64) : i64
    %34 = llvm.alloca %33 x i64 : (i64) -> !llvm.ptr
    llvm.store %32, %34 : i64, !llvm.ptr
    %35 = llvm.mlir.constant(1 : i64) : i64
    %36 = llvm.alloca %35 x i64 : (i64) -> !llvm.ptr
    llvm.store %arg1, %36 : i64, !llvm.ptr
    cf.br ^bb6
    ^bb6:
    %37 = llvm.load %36 : !llvm.ptr -> i64
    %38 = arith.constant 0 : i32
    %40 = arith.extsi %38 : i32 to i64
    %39 = arith.cmpi sgt, %37, %40 : i64
    cf.cond_br %39, ^bb7, ^bb8
    ^bb7:
      %41 = llvm.load %36 : !llvm.ptr -> i64
      %42 = arith.constant 1 : i32
      %44 = arith.extsi %42 : i32 to i64
      %43 = arith.andi %41, %44 : i64
      %45 = arith.constant 0 : i32
      %47 = arith.extsi %45 : i32 to i64
      %46 = arith.cmpi ne, %43, %47 : i64
      cf.cond_br %46, ^bb9, ^bb10
      ^bb9:
        %48 = llvm.load %31 : !llvm.ptr -> i64
        %49 = llvm.load %34 : !llvm.ptr -> i64
        %50 = arith.muli %48, %49 : i64
        %51 = arith.remsi %50, %arg2 : i64
        llvm.store %51, %31 : i64, !llvm.ptr
        cf.br ^bb11
      ^bb10:
        cf.br ^bb11
      ^bb11:
      %52 = llvm.load %34 : !llvm.ptr -> i64
      %53 = llvm.load %34 : !llvm.ptr -> i64
      %54 = arith.muli %52, %53 : i64
      %55 = arith.remsi %54, %arg2 : i64
      llvm.store %55, %34 : i64, !llvm.ptr
      %56 = llvm.load %36 : !llvm.ptr -> i64
      %57 = arith.constant 1 : i32
      %59 = arith.extsi %57 : i32 to i64
      %58 = arith.shrsi %56, %59 : i64
      llvm.store %58, %36 : i64, !llvm.ptr
      cf.br ^bb6
    ^bb8:
    %60 = llvm.load %31 : !llvm.ptr -> i64
    func.return %60 : i64
  }
  func.func @nth_prime_upper_bound(%arg0: i64) -> i64 {
    %61 = arith.constant 6 : i32
    %63 = arith.extsi %61 : i32 to i64
    %62 = arith.cmpi slt, %arg0, %63 : i64
    cf.cond_br %62, ^bb12, ^bb13
    ^bb12:
      %64 = arith.constant 15 : i32
      %65 = arith.extsi %64 : i32 to i64
      func.return %65 : i64
    ^bb13:
      cf.br ^bb14
    ^bb14:
    %66 = arith.sitofp %arg0 : i64 to f64
    %67 = math.log %66 : f64
    %68 = math.log %66 : f64
    %69 = math.log %68 : f64
    %70 = arith.addf %67, %69 : f64
    %71 = arith.mulf %66, %70 : f64
    %72 = arith.constant 10.0 : f32
    %74 = arith.extf %72 : f32 to f64
    %73 = arith.addf %71, %74 : f64
    %75 = arith.fptosi %73 : f64 to i64
    func.return %75 : i64
  }
  func.func @sieve_upto(%arg0: i64, %arg1: !llvm.ptr) -> i64 {
    %77 = arith.constant 1 : i32
    %79 = arith.extsi %77 : i32 to i64
    %78 = arith.addi %arg0, %79 : i64
    %80 = arith.constant 1 : i32
    %81 = arith.extsi %80 : i32 to i64
    %76 = func.call @calloc(%78, %81) : (i64, i64) -> !llvm.ptr
    %82 = arith.constant 0 : i32
    %83 = arith.extsi %82 : i32 to i64
    %84 = llvm.mlir.constant(1 : i64) : i64
    %85 = llvm.alloca %84 x i64 : (i64) -> !llvm.ptr
    llvm.store %83, %85 : i64, !llvm.ptr
    cf.br ^bb15
    ^bb15:
    %86 = llvm.load %85 : !llvm.ptr -> i64
    %87 = arith.cmpi sle, %86, %arg0 : i64
    cf.cond_br %87, ^bb16, ^bb17
    ^bb16:
      %88 = arith.constant 1 : i32
      %89 = llvm.load %85 : !llvm.ptr -> i64
      %90 = arith.trunci %88 : i32 to i8
      %91 = llvm.getelementptr %76[%89] : (!llvm.ptr, i64) -> !llvm.ptr, i8
      llvm.store %90, %91 : i8, !llvm.ptr
      %92 = llvm.load %85 : !llvm.ptr -> i64
      %93 = arith.constant 1 : i32
      %95 = arith.extsi %93 : i32 to i64
      %94 = arith.addi %92, %95 : i64
      llvm.store %94, %85 : i64, !llvm.ptr
      cf.br ^bb15
    ^bb17:
    %96 = arith.constant 0 : i32
    %97 = arith.constant 0 : i32
    %98 = arith.trunci %96 : i32 to i8
    %99 = arith.extsi %97 : i32 to i64
    %100 = llvm.getelementptr %76[%99] : (!llvm.ptr, i64) -> !llvm.ptr, i8
    llvm.store %98, %100 : i8, !llvm.ptr
    %101 = arith.constant 0 : i32
    %102 = arith.constant 1 : i32
    %103 = arith.trunci %101 : i32 to i8
    %104 = arith.extsi %102 : i32 to i64
    %105 = llvm.getelementptr %76[%104] : (!llvm.ptr, i64) -> !llvm.ptr, i8
    llvm.store %103, %105 : i8, !llvm.ptr
    %106 = arith.constant 2 : i32
    %107 = arith.extsi %106 : i32 to i64
    llvm.store %107, %85 : i64, !llvm.ptr
    cf.br ^bb18
    ^bb18:
    %108 = llvm.load %85 : !llvm.ptr -> i64
    %109 = llvm.load %85 : !llvm.ptr -> i64
    %110 = arith.muli %108, %109 : i64
    %111 = arith.cmpi sle, %110, %arg0 : i64
    cf.cond_br %111, ^bb19, ^bb20
    ^bb19:
      %113 = llvm.load %85 : !llvm.ptr -> i64
      %114 = llvm.getelementptr %76[%113] : (!llvm.ptr, i64) -> !llvm.ptr, i8
      %112 = llvm.load %114 : !llvm.ptr -> i8
      %115 = arith.constant 0 : i32
      %117 = arith.extsi %112 : i8 to i32
      %116 = arith.cmpi ne, %117, %115 : i32
      cf.cond_br %116, ^bb21, ^bb22
      ^bb21:
        %118 = llvm.load %85 : !llvm.ptr -> i64
        %119 = llvm.load %85 : !llvm.ptr -> i64
        %120 = arith.muli %118, %119 : i64
        %121 = llvm.mlir.constant(1 : i64) : i64
        %122 = llvm.alloca %121 x i64 : (i64) -> !llvm.ptr
        llvm.store %120, %122 : i64, !llvm.ptr
        cf.br ^bb24
        ^bb24:
        %123 = llvm.load %122 : !llvm.ptr -> i64
        %124 = arith.cmpi sle, %123, %arg0 : i64
        cf.cond_br %124, ^bb25, ^bb26
        ^bb25:
          %125 = arith.constant 0 : i32
          %126 = llvm.load %122 : !llvm.ptr -> i64
          %127 = arith.trunci %125 : i32 to i8
          %128 = llvm.getelementptr %76[%126] : (!llvm.ptr, i64) -> !llvm.ptr, i8
          llvm.store %127, %128 : i8, !llvm.ptr
          %129 = llvm.load %122 : !llvm.ptr -> i64
          %130 = llvm.load %85 : !llvm.ptr -> i64
          %131 = arith.addi %129, %130 : i64
          llvm.store %131, %122 : i64, !llvm.ptr
          cf.br ^bb24
        ^bb26:
        cf.br ^bb23
      ^bb22:
        cf.br ^bb23
      ^bb23:
      %132 = llvm.load %85 : !llvm.ptr -> i64
      %133 = arith.constant 1 : i32
      %135 = arith.extsi %133 : i32 to i64
      %134 = arith.addi %132, %135 : i64
      llvm.store %134, %85 : i64, !llvm.ptr
      cf.br ^bb18
    ^bb20:
    %136 = arith.constant 0 : i32
    %137 = arith.extsi %136 : i32 to i64
    %138 = llvm.mlir.constant(1 : i64) : i64
    %139 = llvm.alloca %138 x i64 : (i64) -> !llvm.ptr
    llvm.store %137, %139 : i64, !llvm.ptr
    %140 = arith.constant 2 : i32
    %141 = arith.extsi %140 : i32 to i64
    llvm.store %141, %85 : i64, !llvm.ptr
    cf.br ^bb27
    ^bb27:
    %142 = llvm.load %85 : !llvm.ptr -> i64
    %143 = arith.cmpi sle, %142, %arg0 : i64
    cf.cond_br %143, ^bb28, ^bb29
    ^bb28:
      %145 = llvm.load %85 : !llvm.ptr -> i64
      %146 = llvm.getelementptr %76[%145] : (!llvm.ptr, i64) -> !llvm.ptr, i8
      %144 = llvm.load %146 : !llvm.ptr -> i8
      %147 = arith.constant 0 : i32
      %149 = arith.extsi %144 : i8 to i32
      %148 = arith.cmpi ne, %149, %147 : i32
      cf.cond_br %148, ^bb30, ^bb31
      ^bb30:
        %150 = llvm.load %85 : !llvm.ptr -> i64
        %151 = llvm.load %139 : !llvm.ptr -> i64
        %152 = llvm.getelementptr %arg1[%151] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        llvm.store %150, %152 : i64, !llvm.ptr
        %153 = llvm.load %139 : !llvm.ptr -> i64
        %154 = arith.constant 1 : i32
        %156 = arith.extsi %154 : i32 to i64
        %155 = arith.addi %153, %156 : i64
        llvm.store %155, %139 : i64, !llvm.ptr
        cf.br ^bb32
      ^bb31:
        cf.br ^bb32
      ^bb32:
      %157 = llvm.load %85 : !llvm.ptr -> i64
      %158 = arith.constant 1 : i32
      %160 = arith.extsi %158 : i32 to i64
      %159 = arith.addi %157, %160 : i64
      llvm.store %159, %85 : i64, !llvm.ptr
      cf.br ^bb27
    ^bb29:
    func.call @free(%76) : (!llvm.ptr) -> ()
    %162 = llvm.load %139 : !llvm.ptr -> i64
    func.return %162 : i64
  }
  func.func @build_tables(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> () {
    %164 = arith.constant 8 : i32
    %165 = arith.constant 8 : i32
    %166 = arith.extsi %164 : i32 to i64
    %167 = arith.extsi %165 : i32 to i64
    %163 = func.call @calloc(%166, %167) : (i64, i64) -> !llvm.ptr
    %168 = arith.constant 2 : i32
    %169 = arith.constant 0 : i32
    %170 = arith.extsi %168 : i32 to i64
    %171 = arith.extsi %169 : i32 to i64
    %172 = llvm.getelementptr %163[%171] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    llvm.store %170, %172 : i64, !llvm.ptr
    %173 = arith.constant 5003 : i32
    %174 = arith.constant 1 : i32
    %175 = arith.extsi %173 : i32 to i64
    %176 = arith.extsi %174 : i32 to i64
    %177 = llvm.getelementptr %163[%176] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    llvm.store %175, %177 : i64, !llvm.ptr
    %178 = arith.constant 2 : i32
    %179 = arith.extsi %178 : i32 to i64
    %180 = arith.constant 0 : i32
    %181 = arith.extsi %180 : i32 to i64
    %182 = llvm.mlir.constant(1 : i64) : i64
    %183 = llvm.alloca %182 x i64 : (i64) -> !llvm.ptr
    llvm.store %181, %183 : i64, !llvm.ptr
    %184 = arith.constant 2 : i32
    %185 = arith.extsi %184 : i32 to i64
    %186 = llvm.mlir.constant(1 : i64) : i64
    %187 = llvm.alloca %186 x i64 : (i64) -> !llvm.ptr
    llvm.store %185, %187 : i64, !llvm.ptr
    cf.br ^bb33
    ^bb33:
    %188 = llvm.load %187 : !llvm.ptr -> i64
    %189 = llvm.mlir.addressof @MOD : !llvm.ptr
    %190 = llvm.load %189 : !llvm.ptr -> i64
    %191 = arith.cmpi slt, %188, %190 : i64
    cf.cond_br %191, ^bb34, ^bb35
    ^bb34:
      %192 = arith.constant 1 : i32
      %193 = arith.extsi %192 : i32 to i64
      %194 = llvm.mlir.constant(1 : i64) : i64
      %195 = llvm.alloca %194 x i64 : (i64) -> !llvm.ptr
      llvm.store %193, %195 : i64, !llvm.ptr
      %196 = arith.constant 0 : i32
      %197 = arith.extsi %196 : i32 to i64
      %198 = llvm.mlir.constant(1 : i64) : i64
      %199 = llvm.alloca %198 x i64 : (i64) -> !llvm.ptr
      llvm.store %197, %199 : i64, !llvm.ptr
      cf.br ^bb36
      ^bb36:
      %200 = llvm.load %199 : !llvm.ptr -> i64
      %201 = arith.cmpi slt, %200, %179 : i64
      cf.cond_br %201, ^bb37, ^bb38
      ^bb37:
        %203 = llvm.load %187 : !llvm.ptr -> i64
        %204 = llvm.mlir.addressof @PHI : !llvm.ptr
        %205 = llvm.load %204 : !llvm.ptr -> i64
        %207 = llvm.load %199 : !llvm.ptr -> i64
        %208 = llvm.getelementptr %163[%207] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %206 = llvm.load %208 : !llvm.ptr -> i64
        %209 = arith.divsi %205, %206 : i64
        %210 = llvm.mlir.addressof @MOD : !llvm.ptr
        %211 = llvm.load %210 : !llvm.ptr -> i64
        %202 = func.call @modpow(%203, %209, %211) : (i64, i64, i64) -> i64
        %212 = arith.constant 1 : i32
        %214 = arith.extsi %212 : i32 to i64
        %213 = arith.cmpi eq, %202, %214 : i64
        cf.cond_br %213, ^bb39, ^bb40
        ^bb39:
          %215 = arith.constant 0 : i32
          %216 = arith.extsi %215 : i32 to i64
          llvm.store %216, %195 : i64, !llvm.ptr
          cf.br ^bb41
        ^bb40:
          cf.br ^bb41
        ^bb41:
        %217 = llvm.load %199 : !llvm.ptr -> i64
        %218 = arith.constant 1 : i32
        %220 = arith.extsi %218 : i32 to i64
        %219 = arith.addi %217, %220 : i64
        llvm.store %219, %199 : i64, !llvm.ptr
        cf.br ^bb36
      ^bb38:
      %221 = llvm.load %195 : !llvm.ptr -> i64
      %222 = arith.constant 0 : i32
      %224 = arith.extsi %222 : i32 to i64
      %223 = arith.cmpi ne, %221, %224 : i64
      cf.cond_br %223, ^bb42, ^bb43
      ^bb42:
        %225 = llvm.load %187 : !llvm.ptr -> i64
        llvm.store %225, %183 : i64, !llvm.ptr
        cf.br ^bb35
      ^bb43:
        cf.br ^bb44
      ^bb44:
      %226 = llvm.load %187 : !llvm.ptr -> i64
      %227 = arith.constant 1 : i32
      %229 = arith.extsi %227 : i32 to i64
      %228 = arith.addi %226, %229 : i64
      llvm.store %228, %187 : i64, !llvm.ptr
      cf.br ^bb33
    ^bb35:
    func.call @free(%163) : (!llvm.ptr) -> ()
    %231 = arith.constant 1 : i32
    %232 = arith.extsi %231 : i32 to i64
    %233 = llvm.mlir.constant(1 : i64) : i64
    %234 = llvm.alloca %233 x i64 : (i64) -> !llvm.ptr
    llvm.store %232, %234 : i64, !llvm.ptr
    %235 = arith.constant 0 : i32
    %236 = arith.extsi %235 : i32 to i64
    %237 = llvm.mlir.constant(1 : i64) : i64
    %238 = llvm.alloca %237 x i64 : (i64) -> !llvm.ptr
    llvm.store %236, %238 : i64, !llvm.ptr
    cf.br ^bb45
    ^bb45:
    %239 = llvm.load %238 : !llvm.ptr -> i64
    %240 = llvm.mlir.addressof @MOD : !llvm.ptr
    %241 = llvm.load %240 : !llvm.ptr -> i64
    %242 = arith.cmpi slt, %239, %241 : i64
    cf.cond_br %242, ^bb46, ^bb47
    ^bb46:
      %243 = arith.constant 1 : i32
      %245 = arith.constant 0 : i32
      %244 = arith.subi %245, %243 : i32
      %246 = llvm.load %238 : !llvm.ptr -> i64
      %247 = arith.extsi %244 : i32 to i64
      %248 = llvm.getelementptr %arg0[%246] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %247, %248 : i64, !llvm.ptr
      %249 = llvm.load %238 : !llvm.ptr -> i64
      %250 = arith.constant 1 : i32
      %252 = arith.extsi %250 : i32 to i64
      %251 = arith.addi %249, %252 : i64
      llvm.store %251, %238 : i64, !llvm.ptr
      cf.br ^bb45
    ^bb47:
    %253 = arith.constant 0 : i32
    %254 = arith.extsi %253 : i32 to i64
    llvm.store %254, %238 : i64, !llvm.ptr
    cf.br ^bb48
    ^bb48:
    %255 = llvm.load %238 : !llvm.ptr -> i64
    %256 = llvm.mlir.addressof @PHI : !llvm.ptr
    %257 = llvm.load %256 : !llvm.ptr -> i64
    %258 = arith.cmpi slt, %255, %257 : i64
    cf.cond_br %258, ^bb49, ^bb50
    ^bb49:
      %259 = llvm.load %234 : !llvm.ptr -> i64
      %260 = llvm.load %238 : !llvm.ptr -> i64
      %261 = llvm.getelementptr %arg1[%260] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %259, %261 : i64, !llvm.ptr
      %262 = llvm.load %238 : !llvm.ptr -> i64
      %263 = llvm.load %234 : !llvm.ptr -> i64
      %264 = llvm.getelementptr %arg0[%263] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %262, %264 : i64, !llvm.ptr
      %265 = llvm.load %234 : !llvm.ptr -> i64
      %266 = llvm.load %183 : !llvm.ptr -> i64
      %267 = arith.muli %265, %266 : i64
      %268 = llvm.mlir.addressof @MOD : !llvm.ptr
      %269 = llvm.load %268 : !llvm.ptr -> i64
      %270 = arith.remsi %267, %269 : i64
      llvm.store %270, %234 : i64, !llvm.ptr
      %271 = llvm.load %238 : !llvm.ptr -> i64
      %272 = arith.constant 1 : i32
      %274 = arith.extsi %272 : i32 to i64
      %273 = arith.addi %271, %274 : i64
      llvm.store %273, %238 : i64, !llvm.ptr
      cf.br ^bb48
    ^bb50:
    func.return
  }
  func.func @pow_fast(%arg0: i64, %arg1: i64, %arg2: !llvm.ptr, %arg3: !llvm.ptr) -> i64 {
    %275 = arith.constant 0 : i32
    %277 = arith.extsi %275 : i32 to i64
    %276 = arith.cmpi eq, %arg0, %277 : i64
    cf.cond_br %276, ^bb51, ^bb52
    ^bb51:
      %278 = arith.constant 0 : i32
      %279 = arith.extsi %278 : i32 to i64
      func.return %279 : i64
    ^bb52:
      cf.br ^bb53
    ^bb53:
    %282 = llvm.getelementptr %arg2[%arg0] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    %281 = llvm.load %282 : !llvm.ptr -> i64
    %283 = arith.muli %281, %arg1 : i64
    %284 = llvm.mlir.addressof @PHI : !llvm.ptr
    %285 = llvm.load %284 : !llvm.ptr -> i64
    %286 = arith.remsi %283, %285 : i64
    %287 = llvm.getelementptr %arg3[%286] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    %280 = llvm.load %287 : !llvm.ptr -> i64
    func.return %280 : i64
  }
  func.func @compute_F2(%arg0: i64, %arg1: i64) -> i64 {
    %289 = llvm.mlir.addressof @MOD : !llvm.ptr
    %290 = llvm.load %289 : !llvm.ptr -> i64
    %291 = arith.constant 8 : i32
    %292 = arith.extsi %291 : i32 to i64
    %288 = func.call @calloc(%290, %292) : (i64, i64) -> !llvm.ptr
    %294 = llvm.mlir.addressof @PHI : !llvm.ptr
    %295 = llvm.load %294 : !llvm.ptr -> i64
    %296 = arith.constant 8 : i32
    %297 = arith.extsi %296 : i32 to i64
    %293 = func.call @calloc(%295, %297) : (i64, i64) -> !llvm.ptr
    func.call @build_tables(%288, %293) : (!llvm.ptr, !llvm.ptr) -> ()
    %300 = llvm.mlir.addressof @DOM_SZ : !llvm.ptr
    %301 = llvm.load %300 : !llvm.ptr -> i64
    %302 = arith.constant 8 : i32
    %303 = arith.extsi %302 : i32 to i64
    %299 = func.call @calloc(%301, %303) : (i64, i64) -> !llvm.ptr
    %305 = arith.constant 8 : i32
    %306 = arith.extsi %305 : i32 to i64
    %304 = func.call @calloc(%arg1, %306) : (i64, i64) -> !llvm.ptr
    %307 = arith.constant 0 : i32
    %308 = arith.extsi %307 : i32 to i64
    %309 = llvm.mlir.constant(1 : i64) : i64
    %310 = llvm.alloca %309 x i64 : (i64) -> !llvm.ptr
    llvm.store %308, %310 : i64, !llvm.ptr
    %311 = arith.constant 0 : i32
    %312 = arith.extsi %311 : i32 to i64
    %313 = llvm.mlir.constant(1 : i64) : i64
    %314 = llvm.alloca %313 x i64 : (i64) -> !llvm.ptr
    llvm.store %312, %314 : i64, !llvm.ptr
    %315 = arith.constant 0 : i32
    %316 = arith.extsi %315 : i32 to i64
    %317 = arith.constant 1 : i32
    %319 = arith.extsi %317 : i32 to i64
    %318 = arith.andi %arg1, %319 : i64
    %320 = arith.constant 0 : i32
    %322 = arith.extsi %320 : i32 to i64
    %321 = arith.cmpi eq, %318, %322 : i64
    %323 = scf.if %321 -> (i64) {
      %324 = arith.constant 1 : i32
      %325 = arith.extsi %324 : i32 to i64
      scf.yield %325 : i64
    } else {
      scf.yield %316 : i64
    }
    %326 = arith.constant 1 : i32
    %328 = arith.extsi %326 : i32 to i64
    %327 = arith.addi %arg1, %328 : i64
    %329 = arith.constant 2 : i32
    %331 = arith.extsi %329 : i32 to i64
    %330 = arith.divsi %327, %331 : i64
    %332 = llvm.mlir.constant(1 : i64) : i64
    %333 = llvm.alloca %332 x i64 : (i64) -> !llvm.ptr
    llvm.store %330, %333 : i64, !llvm.ptr
    %334 = arith.constant 0 : i32
    %336 = arith.extsi %334 : i32 to i64
    %335 = arith.cmpi ne, %323, %336 : i64
    cf.cond_br %335, ^bb54, ^bb55
    ^bb54:
      %337 = arith.constant 2 : i32
      %339 = arith.extsi %337 : i32 to i64
      %338 = arith.divsi %arg1, %339 : i64
      llvm.store %338, %333 : i64, !llvm.ptr
      cf.br ^bb56
    ^bb55:
      cf.br ^bb56
    ^bb56:
    %340 = arith.constant 0 : i32
    %341 = arith.extsi %340 : i32 to i64
    %342 = llvm.mlir.constant(1 : i64) : i64
    %343 = llvm.alloca %342 x i64 : (i64) -> !llvm.ptr
    llvm.store %341, %343 : i64, !llvm.ptr
    %344 = arith.constant 0 : i32
    %345 = arith.extsi %344 : i32 to i64
    %346 = llvm.mlir.constant(1 : i64) : i64
    %347 = llvm.alloca %346 x i64 : (i64) -> !llvm.ptr
    llvm.store %345, %347 : i64, !llvm.ptr
    %348 = arith.constant 0 : i32
    %349 = arith.extsi %348 : i32 to i64
    %350 = llvm.mlir.constant(1 : i64) : i64
    %351 = llvm.alloca %350 x i64 : (i64) -> !llvm.ptr
    llvm.store %349, %351 : i64, !llvm.ptr
    %353 = arith.constant 1002 : i32
    %354 = arith.constant 8 : i32
    %355 = arith.extsi %353 : i32 to i64
    %356 = arith.extsi %354 : i32 to i64
    %352 = func.call @calloc(%355, %356) : (i64, i64) -> !llvm.ptr
    %357 = arith.constant 1 : i32
    %358 = arith.extsi %357 : i32 to i64
    %359 = llvm.mlir.constant(1 : i64) : i64
    %360 = llvm.alloca %359 x i64 : (i64) -> !llvm.ptr
    llvm.store %358, %360 : i64, !llvm.ptr
    %361 = arith.constant 1 : i32
    %362 = arith.extsi %361 : i32 to i64
    %363 = llvm.mlir.constant(1 : i64) : i64
    %364 = llvm.alloca %363 x i64 : (i64) -> !llvm.ptr
    llvm.store %362, %364 : i64, !llvm.ptr
    %365 = arith.constant 10000 : i32
    %366 = arith.extsi %365 : i32 to i64
    %367 = llvm.mlir.constant(1 : i64) : i64
    %368 = llvm.alloca %367 x i64 : (i64) -> !llvm.ptr
    llvm.store %366, %368 : i64, !llvm.ptr
    %369 = arith.constant 1 : i32
    %370 = arith.extsi %369 : i32 to i64
    %371 = llvm.mlir.constant(1 : i64) : i64
    %372 = llvm.alloca %371 x i64 : (i64) -> !llvm.ptr
    llvm.store %370, %372 : i64, !llvm.ptr
    %374 = arith.constant 2 : i32
    %375 = llvm.mlir.addressof @MOD : !llvm.ptr
    %376 = llvm.load %375 : !llvm.ptr -> i64
    %378 = arith.extsi %374 : i32 to i64
    %377 = arith.remsi %378, %376 : i64
    %379 = llvm.load %360 : !llvm.ptr -> i64
    %373 = func.call @pow_fast(%377, %379, %288, %293) : (i64, i64, !llvm.ptr, !llvm.ptr) -> i64
    %380 = arith.constant 1 : i32
    %381 = arith.extsi %380 : i32 to i64
    %382 = llvm.getelementptr %352[%381] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    llvm.store %373, %382 : i64, !llvm.ptr
    %383 = arith.addi %373, %373 : i64
    %384 = arith.constant 0 : i32
    %385 = arith.extsi %384 : i32 to i64
    %386 = llvm.getelementptr %304[%385] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    llvm.store %383, %386 : i64, !llvm.ptr
    %388 = llvm.getelementptr %299[%383] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    %387 = llvm.load %388 : !llvm.ptr -> i64
    %389 = arith.constant 1 : i32
    %391 = arith.extsi %389 : i32 to i64
    %390 = arith.addi %387, %391 : i64
    %392 = llvm.getelementptr %299[%383] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    llvm.store %390, %392 : i64, !llvm.ptr
    %393 = arith.constant 1 : i32
    %394 = arith.extsi %393 : i32 to i64
    llvm.store %394, %310 : i64, !llvm.ptr
    %395 = arith.constant 1 : i32
    %397 = arith.extsi %395 : i32 to i64
    %396 = arith.cmpi eq, %arg1, %397 : i64
    cf.cond_br %396, ^bb57, ^bb58
    ^bb57:
      llvm.store %383, %343 : i64, !llvm.ptr
      %398 = arith.constant 0 : i32
      %399 = arith.extsi %398 : i32 to i64
      llvm.store %399, %347 : i64, !llvm.ptr
      %400 = llvm.load %351 : !llvm.ptr -> i64
      %401 = llvm.load %343 : !llvm.ptr -> i64
      %402 = arith.constant 1 : i32
      %404 = arith.extsi %402 : i32 to i64
      %403 = arith.shli %401, %404 : i64
      %405 = arith.addi %400, %403 : i64
      llvm.store %405, %351 : i64, !llvm.ptr
      %406 = arith.constant 1 : i32
      %408 = arith.extsi %406 : i32 to i64
      %407 = arith.cmpi eq, %arg0, %408 : i64
      cf.cond_br %407, ^bb60, ^bb61
      ^bb60:
        func.call @free(%288) : (!llvm.ptr) -> ()
        func.call @free(%293) : (!llvm.ptr) -> ()
        func.call @free(%299) : (!llvm.ptr) -> ()
        func.call @free(%304) : (!llvm.ptr) -> ()
        func.call @free(%352) : (!llvm.ptr) -> ()
        %414 = llvm.load %351 : !llvm.ptr -> i64
        func.return %414 : i64
      ^bb61:
        cf.br ^bb62
      ^bb62:
      cf.br ^bb59
    ^bb58:
      cf.br ^bb59
    ^bb59:
    %415 = func.call @nth_prime_upper_bound(%arg0) : (i64) -> i64
    %416 = func.call @isqrt(%415) : (i64) -> i64
    %418 = arith.constant 100 : i32
    %420 = arith.extsi %418 : i32 to i64
    %419 = arith.addi %416, %420 : i64
    %421 = arith.constant 8 : i32
    %422 = arith.extsi %421 : i32 to i64
    %417 = func.call @calloc(%419, %422) : (i64, i64) -> !llvm.ptr
    %423 = func.call @sieve_upto(%416, %417) : (i64, !llvm.ptr) -> i64
    %425 = arith.constant 8 : i32
    %426 = arith.extsi %425 : i32 to i64
    %424 = func.call @calloc(%423, %426) : (i64, i64) -> !llvm.ptr
    %428 = arith.constant 8 : i32
    %429 = arith.extsi %428 : i32 to i64
    %427 = func.call @calloc(%423, %429) : (i64, i64) -> !llvm.ptr
    %430 = arith.constant 0 : i32
    %431 = arith.extsi %430 : i32 to i64
    %432 = llvm.mlir.constant(1 : i64) : i64
    %433 = llvm.alloca %432 x i64 : (i64) -> !llvm.ptr
    llvm.store %431, %433 : i64, !llvm.ptr
    %434 = arith.constant 0 : i32
    %435 = arith.extsi %434 : i32 to i64
    %436 = llvm.mlir.constant(1 : i64) : i64
    %437 = llvm.alloca %436 x i64 : (i64) -> !llvm.ptr
    llvm.store %435, %437 : i64, !llvm.ptr
    cf.br ^bb63
    ^bb63:
    %438 = llvm.load %437 : !llvm.ptr -> i64
    %439 = arith.cmpi slt, %438, %423 : i64
    cf.cond_br %439, ^bb64, ^bb65
    ^bb64:
      %441 = llvm.load %437 : !llvm.ptr -> i64
      %442 = llvm.getelementptr %417[%441] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %440 = llvm.load %442 : !llvm.ptr -> i64
      %443 = arith.constant 2 : i32
      %445 = arith.extsi %443 : i32 to i64
      %444 = arith.cmpi sgt, %440, %445 : i64
      cf.cond_br %444, ^bb66, ^bb67
      ^bb66:
        %446 = llvm.load %433 : !llvm.ptr -> i64
        %447 = llvm.getelementptr %424[%446] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        llvm.store %440, %447 : i64, !llvm.ptr
        %448 = arith.muli %440, %440 : i64
        %449 = llvm.load %433 : !llvm.ptr -> i64
        %450 = llvm.getelementptr %427[%449] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        llvm.store %448, %450 : i64, !llvm.ptr
        %451 = llvm.load %433 : !llvm.ptr -> i64
        %452 = arith.constant 1 : i32
        %454 = arith.extsi %452 : i32 to i64
        %453 = arith.addi %451, %454 : i64
        llvm.store %453, %433 : i64, !llvm.ptr
        cf.br ^bb68
      ^bb67:
        cf.br ^bb68
      ^bb68:
      %455 = llvm.load %437 : !llvm.ptr -> i64
      %456 = arith.constant 1 : i32
      %458 = arith.extsi %456 : i32 to i64
      %457 = arith.addi %455, %458 : i64
      llvm.store %457, %437 : i64, !llvm.ptr
      cf.br ^bb63
    ^bb65:
    %459 = arith.constant 1 : i32
    %460 = arith.constant 20 : i32
    %461 = arith.shli %459, %460 : i32
    %462 = arith.extsi %461 : i32 to i64
    %463 = arith.constant 3 : i32
    %464 = arith.extsi %463 : i32 to i64
    %465 = llvm.mlir.constant(1 : i64) : i64
    %466 = llvm.alloca %465 x i64 : (i64) -> !llvm.ptr
    llvm.store %464, %466 : i64, !llvm.ptr
    cf.br ^bb69
    ^bb69:
    %467 = llvm.load %466 : !llvm.ptr -> i64
    %468 = arith.cmpi sle, %467, %415 : i64
    cf.cond_br %468, ^bb70, ^bb71
    ^bb70:
      %469 = llvm.load %466 : !llvm.ptr -> i64
      %470 = arith.constant 2 : i32
      %472 = arith.extsi %470 : i32 to i64
      %471 = arith.muli %472, %462 : i64
      %473 = arith.addi %469, %471 : i64
      %474 = llvm.mlir.constant(1 : i64) : i64
      %475 = llvm.alloca %474 x i64 : (i64) -> !llvm.ptr
      llvm.store %473, %475 : i64, !llvm.ptr
      %476 = llvm.load %475 : !llvm.ptr -> i64
      %477 = arith.constant 1 : i32
      %479 = arith.extsi %477 : i32 to i64
      %478 = arith.addi %415, %479 : i64
      %480 = arith.cmpi sgt, %476, %478 : i64
      cf.cond_br %480, ^bb72, ^bb73
      ^bb72:
        %481 = arith.constant 1 : i32
        %483 = arith.extsi %481 : i32 to i64
        %482 = arith.addi %415, %483 : i64
        llvm.store %482, %475 : i64, !llvm.ptr
        cf.br ^bb74
      ^bb73:
        cf.br ^bb74
      ^bb74:
      %484 = llvm.load %475 : !llvm.ptr -> i64
      %485 = llvm.load %466 : !llvm.ptr -> i64
      %486 = arith.subi %484, %485 : i64
      %487 = arith.constant 2 : i32
      %489 = arith.extsi %487 : i32 to i64
      %488 = arith.divsi %486, %489 : i64
      %491 = arith.constant 1 : i32
      %492 = arith.extsi %491 : i32 to i64
      %490 = func.call @calloc(%488, %492) : (i64, i64) -> !llvm.ptr
      %493 = arith.constant 0 : i32
      %494 = arith.extsi %493 : i32 to i64
      %495 = llvm.mlir.constant(1 : i64) : i64
      %496 = llvm.alloca %495 x i64 : (i64) -> !llvm.ptr
      llvm.store %494, %496 : i64, !llvm.ptr
      cf.br ^bb75
      ^bb75:
      %497 = llvm.load %496 : !llvm.ptr -> i64
      %498 = arith.cmpi slt, %497, %488 : i64
      cf.cond_br %498, ^bb76, ^bb77
      ^bb76:
        %499 = arith.constant 1 : i32
        %500 = llvm.load %496 : !llvm.ptr -> i64
        %501 = arith.trunci %499 : i32 to i8
        %502 = llvm.getelementptr %490[%500] : (!llvm.ptr, i64) -> !llvm.ptr, i8
        llvm.store %501, %502 : i8, !llvm.ptr
        %503 = llvm.load %496 : !llvm.ptr -> i64
        %504 = arith.constant 1 : i32
        %506 = arith.extsi %504 : i32 to i64
        %505 = arith.addi %503, %506 : i64
        llvm.store %505, %496 : i64, !llvm.ptr
        cf.br ^bb75
      ^bb77:
      %507 = arith.constant 0 : i32
      %508 = arith.extsi %507 : i32 to i64
      llvm.store %508, %437 : i64, !llvm.ptr
      cf.br ^bb78
      ^bb78:
      %509 = llvm.load %437 : !llvm.ptr -> i64
      %510 = llvm.load %433 : !llvm.ptr -> i64
      %511 = arith.cmpi slt, %509, %510 : i64
      cf.cond_br %511, ^bb79, ^bb80
      ^bb79:
        %513 = llvm.load %437 : !llvm.ptr -> i64
        %514 = llvm.getelementptr %424[%513] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %512 = llvm.load %514 : !llvm.ptr -> i64
        %516 = llvm.load %437 : !llvm.ptr -> i64
        %517 = llvm.getelementptr %427[%516] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %515 = llvm.load %517 : !llvm.ptr -> i64
        %518 = llvm.load %475 : !llvm.ptr -> i64
        %519 = arith.cmpi sge, %515, %518 : i64
        cf.cond_br %519, ^bb81, ^bb82
        ^bb81:
          cf.br ^bb80
        ^bb82:
          cf.br ^bb83
        ^bb83:
        %520 = llvm.mlir.constant(1 : i64) : i64
        %521 = llvm.alloca %520 x i64 : (i64) -> !llvm.ptr
        llvm.store %515, %521 : i64, !llvm.ptr
        %522 = llvm.load %521 : !llvm.ptr -> i64
        %523 = llvm.load %466 : !llvm.ptr -> i64
        %524 = arith.cmpi slt, %522, %523 : i64
        cf.cond_br %524, ^bb84, ^bb85
        ^bb84:
          %525 = llvm.load %466 : !llvm.ptr -> i64
          %526 = arith.remsi %525, %512 : i64
          %527 = arith.constant 0 : i32
          %529 = arith.extsi %527 : i32 to i64
          %528 = arith.cmpi eq, %526, %529 : i64
          cf.cond_br %528, ^bb87, ^bb88
          ^bb87:
            %530 = llvm.load %466 : !llvm.ptr -> i64
            llvm.store %530, %521 : i64, !llvm.ptr
            cf.br ^bb89
          ^bb88:
            %531 = llvm.load %466 : !llvm.ptr -> i64
            %532 = arith.subi %512, %526 : i64
            %533 = arith.addi %531, %532 : i64
            llvm.store %533, %521 : i64, !llvm.ptr
            cf.br ^bb89
          ^bb89:
          %534 = llvm.load %521 : !llvm.ptr -> i64
          %535 = arith.constant 1 : i32
          %537 = arith.extsi %535 : i32 to i64
          %536 = arith.andi %534, %537 : i64
          %538 = arith.constant 0 : i32
          %540 = arith.extsi %538 : i32 to i64
          %539 = arith.cmpi eq, %536, %540 : i64
          cf.cond_br %539, ^bb90, ^bb91
          ^bb90:
            %541 = llvm.load %521 : !llvm.ptr -> i64
            %542 = arith.addi %541, %512 : i64
            llvm.store %542, %521 : i64, !llvm.ptr
            cf.br ^bb92
          ^bb91:
            cf.br ^bb92
          ^bb92:
          cf.br ^bb86
        ^bb85:
          cf.br ^bb86
        ^bb86:
        %543 = llvm.load %521 : !llvm.ptr -> i64
        %544 = llvm.load %466 : !llvm.ptr -> i64
        %545 = arith.subi %543, %544 : i64
        %546 = arith.constant 2 : i32
        %548 = arith.extsi %546 : i32 to i64
        %547 = arith.divsi %545, %548 : i64
        %549 = llvm.mlir.constant(1 : i64) : i64
        %550 = llvm.alloca %549 x i64 : (i64) -> !llvm.ptr
        llvm.store %547, %550 : i64, !llvm.ptr
        cf.br ^bb93
        ^bb93:
        %551 = llvm.load %550 : !llvm.ptr -> i64
        %552 = arith.cmpi slt, %551, %488 : i64
        cf.cond_br %552, ^bb94, ^bb95
        ^bb94:
          %553 = arith.constant 0 : i32
          %554 = llvm.load %550 : !llvm.ptr -> i64
          %555 = arith.trunci %553 : i32 to i8
          %556 = llvm.getelementptr %490[%554] : (!llvm.ptr, i64) -> !llvm.ptr, i8
          llvm.store %555, %556 : i8, !llvm.ptr
          %557 = llvm.load %550 : !llvm.ptr -> i64
          %558 = arith.addi %557, %512 : i64
          llvm.store %558, %550 : i64, !llvm.ptr
          cf.br ^bb93
        ^bb95:
        %559 = llvm.load %437 : !llvm.ptr -> i64
        %560 = arith.constant 1 : i32
        %562 = arith.extsi %560 : i32 to i64
        %561 = arith.addi %559, %562 : i64
        llvm.store %561, %437 : i64, !llvm.ptr
        cf.br ^bb78
      ^bb80:
      %563 = arith.constant 0 : i32
      %564 = arith.extsi %563 : i32 to i64
      llvm.store %564, %496 : i64, !llvm.ptr
      cf.br ^bb96
      ^bb96:
      %565 = llvm.load %496 : !llvm.ptr -> i64
      %566 = arith.cmpi slt, %565, %488 : i64
      cf.cond_br %566, ^bb97, ^bb98
      ^bb97:
        %568 = llvm.load %496 : !llvm.ptr -> i64
        %569 = llvm.getelementptr %490[%568] : (!llvm.ptr, i64) -> !llvm.ptr, i8
        %567 = llvm.load %569 : !llvm.ptr -> i8
        %570 = arith.constant 0 : i32
        %572 = arith.extsi %567 : i8 to i32
        %571 = arith.cmpi ne, %572, %570 : i32
        cf.cond_br %571, ^bb99, ^bb100
        ^bb99:
          %573 = llvm.load %466 : !llvm.ptr -> i64
          %574 = arith.constant 2 : i32
          %575 = llvm.load %496 : !llvm.ptr -> i64
          %577 = arith.extsi %574 : i32 to i64
          %576 = arith.muli %577, %575 : i64
          %578 = arith.addi %573, %576 : i64
          %579 = llvm.load %372 : !llvm.ptr -> i64
          %580 = arith.constant 1 : i32
          %582 = arith.extsi %580 : i32 to i64
          %581 = arith.addi %579, %582 : i64
          llvm.store %581, %372 : i64, !llvm.ptr
          %583 = llvm.load %360 : !llvm.ptr -> i64
          %584 = arith.constant 1 : i32
          %586 = arith.extsi %584 : i32 to i64
          %585 = arith.addi %583, %586 : i64
          llvm.store %585, %360 : i64, !llvm.ptr
          %587 = llvm.load %360 : !llvm.ptr -> i64
          %588 = llvm.mlir.addressof @PHI : !llvm.ptr
          %589 = llvm.load %588 : !llvm.ptr -> i64
          %590 = arith.cmpi eq, %587, %589 : i64
          cf.cond_br %590, ^bb102, ^bb103
          ^bb102:
            %591 = arith.constant 0 : i32
            %592 = arith.extsi %591 : i32 to i64
            llvm.store %592, %360 : i64, !llvm.ptr
            cf.br ^bb104
          ^bb103:
            cf.br ^bb104
          ^bb104:
          %593 = llvm.load %372 : !llvm.ptr -> i64
          %594 = llvm.load %368 : !llvm.ptr -> i64
          %595 = arith.cmpi eq, %593, %594 : i64
          cf.cond_br %595, ^bb105, ^bb106
          ^bb105:
            %596 = llvm.load %364 : !llvm.ptr -> i64
            %597 = arith.constant 1 : i32
            %599 = arith.extsi %597 : i32 to i64
            %598 = arith.addi %596, %599 : i64
            llvm.store %598, %364 : i64, !llvm.ptr
            %600 = llvm.load %368 : !llvm.ptr -> i64
            %601 = arith.constant 10000 : i32
            %603 = arith.extsi %601 : i32 to i64
            %602 = arith.addi %600, %603 : i64
            llvm.store %602, %368 : i64, !llvm.ptr
            cf.br ^bb107
          ^bb106:
            cf.br ^bb107
          ^bb107:
          %604 = llvm.mlir.addressof @MOD : !llvm.ptr
          %605 = llvm.load %604 : !llvm.ptr -> i64
          %606 = arith.remsi %578, %605 : i64
          %608 = llvm.load %360 : !llvm.ptr -> i64
          %607 = func.call @pow_fast(%606, %608, %288, %293) : (i64, i64, !llvm.ptr, !llvm.ptr) -> i64
          %609 = llvm.load %372 : !llvm.ptr -> i64
          %610 = arith.constant 1001 : i32
          %612 = arith.extsi %610 : i32 to i64
          %611 = arith.cmpi sle, %609, %612 : i64
          cf.cond_br %611, ^bb108, ^bb109
          ^bb108:
            %613 = llvm.load %372 : !llvm.ptr -> i64
            %614 = llvm.getelementptr %352[%613] : (!llvm.ptr, i64) -> !llvm.ptr, i64
            llvm.store %607, %614 : i64, !llvm.ptr
            cf.br ^bb110
          ^bb109:
            cf.br ^bb110
          ^bb110:
          %616 = llvm.load %364 : !llvm.ptr -> i64
          %617 = llvm.getelementptr %352[%616] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          %615 = llvm.load %617 : !llvm.ptr -> i64
          %618 = arith.addi %607, %615 : i64
          %619 = llvm.load %310 : !llvm.ptr -> i64
          %620 = arith.cmpi slt, %619, %arg1 : i64
          cf.cond_br %620, ^bb111, ^bb112
          ^bb111:
            %621 = llvm.load %310 : !llvm.ptr -> i64
            %622 = llvm.getelementptr %304[%621] : (!llvm.ptr, i64) -> !llvm.ptr, i64
            llvm.store %618, %622 : i64, !llvm.ptr
            %624 = llvm.getelementptr %299[%618] : (!llvm.ptr, i64) -> !llvm.ptr, i64
            %623 = llvm.load %624 : !llvm.ptr -> i64
            %625 = arith.constant 1 : i32
            %627 = arith.extsi %625 : i32 to i64
            %626 = arith.addi %623, %627 : i64
            %628 = llvm.getelementptr %299[%618] : (!llvm.ptr, i64) -> !llvm.ptr, i64
            llvm.store %626, %628 : i64, !llvm.ptr
            %629 = llvm.load %310 : !llvm.ptr -> i64
            %630 = arith.constant 1 : i32
            %632 = arith.extsi %630 : i32 to i64
            %631 = arith.addi %629, %632 : i64
            llvm.store %631, %310 : i64, !llvm.ptr
            %633 = llvm.load %310 : !llvm.ptr -> i64
            %634 = arith.cmpi eq, %633, %arg1 : i64
            cf.cond_br %634, ^bb114, ^bb115
            ^bb114:
              %635 = arith.constant 0 : i32
              %636 = arith.extsi %635 : i32 to i64
              %637 = llvm.mlir.constant(1 : i64) : i64
              %638 = llvm.alloca %637 x i64 : (i64) -> !llvm.ptr
              llvm.store %636, %638 : i64, !llvm.ptr
              %639 = arith.constant 0 : i32
              %640 = arith.extsi %639 : i32 to i64
              %641 = llvm.mlir.constant(1 : i64) : i64
              %642 = llvm.alloca %641 x i64 : (i64) -> !llvm.ptr
              llvm.store %640, %642 : i64, !llvm.ptr
              cf.br ^bb117
              ^bb117:
              %643 = llvm.load %638 : !llvm.ptr -> i64
              %645 = llvm.load %642 : !llvm.ptr -> i64
              %646 = llvm.getelementptr %299[%645] : (!llvm.ptr, i64) -> !llvm.ptr, i64
              %644 = llvm.load %646 : !llvm.ptr -> i64
              %647 = arith.addi %643, %644 : i64
              %648 = llvm.load %333 : !llvm.ptr -> i64
              %649 = arith.cmpi slt, %647, %648 : i64
              cf.cond_br %649, ^bb118, ^bb119
              ^bb118:
                %650 = llvm.load %638 : !llvm.ptr -> i64
                %652 = llvm.load %642 : !llvm.ptr -> i64
                %653 = llvm.getelementptr %299[%652] : (!llvm.ptr, i64) -> !llvm.ptr, i64
                %651 = llvm.load %653 : !llvm.ptr -> i64
                %654 = arith.addi %650, %651 : i64
                llvm.store %654, %638 : i64, !llvm.ptr
                %655 = llvm.load %642 : !llvm.ptr -> i64
                %656 = arith.constant 1 : i32
                %658 = arith.extsi %656 : i32 to i64
                %657 = arith.addi %655, %658 : i64
                llvm.store %657, %642 : i64, !llvm.ptr
                cf.br ^bb117
              ^bb119:
              %659 = llvm.load %642 : !llvm.ptr -> i64
              llvm.store %659, %343 : i64, !llvm.ptr
              %660 = llvm.load %638 : !llvm.ptr -> i64
              llvm.store %660, %347 : i64, !llvm.ptr
              %661 = arith.constant 0 : i32
              %663 = arith.extsi %661 : i32 to i64
              %662 = arith.cmpi eq, %323, %663 : i64
              cf.cond_br %662, ^bb120, ^bb121
              ^bb120:
                %664 = llvm.load %351 : !llvm.ptr -> i64
                %665 = llvm.load %343 : !llvm.ptr -> i64
                %666 = arith.constant 1 : i32
                %668 = arith.extsi %666 : i32 to i64
                %667 = arith.shli %665, %668 : i64
                %669 = arith.addi %664, %667 : i64
                llvm.store %669, %351 : i64, !llvm.ptr
                cf.br ^bb122
              ^bb121:
                %670 = llvm.load %333 : !llvm.ptr -> i64
                %671 = llvm.load %347 : !llvm.ptr -> i64
                %672 = arith.subi %670, %671 : i64
                %674 = llvm.load %343 : !llvm.ptr -> i64
                %675 = llvm.getelementptr %299[%674] : (!llvm.ptr, i64) -> !llvm.ptr, i64
                %673 = llvm.load %675 : !llvm.ptr -> i64
                %676 = arith.cmpi slt, %672, %673 : i64
                cf.cond_br %676, ^bb123, ^bb124
                ^bb123:
                  %677 = llvm.load %351 : !llvm.ptr -> i64
                  %678 = llvm.load %343 : !llvm.ptr -> i64
                  %679 = arith.constant 1 : i32
                  %681 = arith.extsi %679 : i32 to i64
                  %680 = arith.shli %678, %681 : i64
                  %682 = arith.addi %677, %680 : i64
                  llvm.store %682, %351 : i64, !llvm.ptr
                  cf.br ^bb125
                ^bb124:
                  %683 = llvm.load %343 : !llvm.ptr -> i64
                  %684 = arith.constant 1 : i32
                  %686 = arith.extsi %684 : i32 to i64
                  %685 = arith.addi %683, %686 : i64
                  %687 = llvm.mlir.constant(1 : i64) : i64
                  %688 = llvm.alloca %687 x i64 : (i64) -> !llvm.ptr
                  llvm.store %685, %688 : i64, !llvm.ptr
                  cf.br ^bb126
                  ^bb126:
                  %690 = llvm.load %688 : !llvm.ptr -> i64
                  %691 = llvm.getelementptr %299[%690] : (!llvm.ptr, i64) -> !llvm.ptr, i64
                  %689 = llvm.load %691 : !llvm.ptr -> i64
                  %692 = arith.constant 0 : i32
                  %694 = arith.extsi %692 : i32 to i64
                  %693 = arith.cmpi eq, %689, %694 : i64
                  cf.cond_br %693, ^bb127, ^bb128
                  ^bb127:
                    %695 = llvm.load %688 : !llvm.ptr -> i64
                    %696 = arith.constant 1 : i32
                    %698 = arith.extsi %696 : i32 to i64
                    %697 = arith.addi %695, %698 : i64
                    llvm.store %697, %688 : i64, !llvm.ptr
                    cf.br ^bb126
                  ^bb128:
                  %699 = llvm.load %351 : !llvm.ptr -> i64
                  %700 = llvm.load %343 : !llvm.ptr -> i64
                  %701 = arith.addi %699, %700 : i64
                  %702 = llvm.load %688 : !llvm.ptr -> i64
                  %703 = arith.addi %701, %702 : i64
                  llvm.store %703, %351 : i64, !llvm.ptr
                  cf.br ^bb125
                ^bb125:
                cf.br ^bb122
              ^bb122:
              cf.br ^bb116
            ^bb115:
              cf.br ^bb116
            ^bb116:
            %704 = llvm.load %372 : !llvm.ptr -> i64
            %705 = arith.cmpi eq, %704, %arg0 : i64
            cf.cond_br %705, ^bb129, ^bb130
            ^bb129:
              func.call @free(%490) : (!llvm.ptr) -> ()
              func.call @free(%288) : (!llvm.ptr) -> ()
              func.call @free(%293) : (!llvm.ptr) -> ()
              func.call @free(%299) : (!llvm.ptr) -> ()
              func.call @free(%304) : (!llvm.ptr) -> ()
              func.call @free(%352) : (!llvm.ptr) -> ()
              func.call @free(%417) : (!llvm.ptr) -> ()
              func.call @free(%424) : (!llvm.ptr) -> ()
              func.call @free(%427) : (!llvm.ptr) -> ()
              %715 = llvm.load %351 : !llvm.ptr -> i64
              func.return %715 : i64
            ^bb130:
              cf.br ^bb131
            ^bb131:
            cf.br ^bb113
          ^bb112:
            %717 = llvm.load %314 : !llvm.ptr -> i64
            %718 = llvm.getelementptr %304[%717] : (!llvm.ptr, i64) -> !llvm.ptr, i64
            %716 = llvm.load %718 : !llvm.ptr -> i64
            %719 = arith.cmpi ne, %716, %618 : i64
            cf.cond_br %719, ^bb132, ^bb133
            ^bb132:
              %721 = llvm.getelementptr %299[%716] : (!llvm.ptr, i64) -> !llvm.ptr, i64
              %720 = llvm.load %721 : !llvm.ptr -> i64
              %722 = arith.constant 1 : i32
              %724 = arith.extsi %722 : i32 to i64
              %723 = arith.subi %720, %724 : i64
              %725 = llvm.getelementptr %299[%716] : (!llvm.ptr, i64) -> !llvm.ptr, i64
              llvm.store %723, %725 : i64, !llvm.ptr
              %726 = llvm.load %343 : !llvm.ptr -> i64
              %727 = arith.cmpi slt, %716, %726 : i64
              cf.cond_br %727, ^bb135, ^bb136
              ^bb135:
                %728 = llvm.load %347 : !llvm.ptr -> i64
                %729 = arith.constant 1 : i32
                %731 = arith.extsi %729 : i32 to i64
                %730 = arith.subi %728, %731 : i64
                llvm.store %730, %347 : i64, !llvm.ptr
                cf.br ^bb137
              ^bb136:
                cf.br ^bb137
              ^bb137:
              %732 = llvm.load %314 : !llvm.ptr -> i64
              %733 = llvm.getelementptr %304[%732] : (!llvm.ptr, i64) -> !llvm.ptr, i64
              llvm.store %618, %733 : i64, !llvm.ptr
              %735 = llvm.getelementptr %299[%618] : (!llvm.ptr, i64) -> !llvm.ptr, i64
              %734 = llvm.load %735 : !llvm.ptr -> i64
              %736 = arith.constant 1 : i32
              %738 = arith.extsi %736 : i32 to i64
              %737 = arith.addi %734, %738 : i64
              %739 = llvm.getelementptr %299[%618] : (!llvm.ptr, i64) -> !llvm.ptr, i64
              llvm.store %737, %739 : i64, !llvm.ptr
              %740 = llvm.load %343 : !llvm.ptr -> i64
              %741 = arith.cmpi slt, %618, %740 : i64
              cf.cond_br %741, ^bb138, ^bb139
              ^bb138:
                %742 = llvm.load %347 : !llvm.ptr -> i64
                %743 = arith.constant 1 : i32
                %745 = arith.extsi %743 : i32 to i64
                %744 = arith.addi %742, %745 : i64
                llvm.store %744, %347 : i64, !llvm.ptr
                cf.br ^bb140
              ^bb139:
                cf.br ^bb140
              ^bb140:
              cf.br ^bb141
              ^bb141:
              %746 = llvm.load %347 : !llvm.ptr -> i64
              %747 = llvm.load %333 : !llvm.ptr -> i64
              %748 = arith.cmpi sge, %746, %747 : i64
              cf.cond_br %748, ^bb142, ^bb143
              ^bb142:
                %749 = llvm.load %343 : !llvm.ptr -> i64
                %750 = arith.constant 1 : i32
                %752 = arith.extsi %750 : i32 to i64
                %751 = arith.subi %749, %752 : i64
                llvm.store %751, %343 : i64, !llvm.ptr
                %753 = llvm.load %347 : !llvm.ptr -> i64
                %755 = llvm.load %343 : !llvm.ptr -> i64
                %756 = llvm.getelementptr %299[%755] : (!llvm.ptr, i64) -> !llvm.ptr, i64
                %754 = llvm.load %756 : !llvm.ptr -> i64
                %757 = arith.subi %753, %754 : i64
                llvm.store %757, %347 : i64, !llvm.ptr
                cf.br ^bb141
              ^bb143:
              cf.br ^bb144
              ^bb144:
              %758 = llvm.load %347 : !llvm.ptr -> i64
              %760 = llvm.load %343 : !llvm.ptr -> i64
              %761 = llvm.getelementptr %299[%760] : (!llvm.ptr, i64) -> !llvm.ptr, i64
              %759 = llvm.load %761 : !llvm.ptr -> i64
              %762 = arith.addi %758, %759 : i64
              %763 = llvm.load %333 : !llvm.ptr -> i64
              %764 = arith.cmpi slt, %762, %763 : i64
              cf.cond_br %764, ^bb145, ^bb146
              ^bb145:
                %765 = llvm.load %347 : !llvm.ptr -> i64
                %767 = llvm.load %343 : !llvm.ptr -> i64
                %768 = llvm.getelementptr %299[%767] : (!llvm.ptr, i64) -> !llvm.ptr, i64
                %766 = llvm.load %768 : !llvm.ptr -> i64
                %769 = arith.addi %765, %766 : i64
                llvm.store %769, %347 : i64, !llvm.ptr
                %770 = llvm.load %343 : !llvm.ptr -> i64
                %771 = arith.constant 1 : i32
                %773 = arith.extsi %771 : i32 to i64
                %772 = arith.addi %770, %773 : i64
                llvm.store %772, %343 : i64, !llvm.ptr
                cf.br ^bb144
              ^bb146:
              cf.br ^bb134
            ^bb133:
              %774 = llvm.load %314 : !llvm.ptr -> i64
              %775 = llvm.getelementptr %304[%774] : (!llvm.ptr, i64) -> !llvm.ptr, i64
              llvm.store %618, %775 : i64, !llvm.ptr
              cf.br ^bb134
            ^bb134:
            %776 = llvm.load %314 : !llvm.ptr -> i64
            %777 = arith.constant 1 : i32
            %779 = arith.extsi %777 : i32 to i64
            %778 = arith.addi %776, %779 : i64
            llvm.store %778, %314 : i64, !llvm.ptr
            %780 = llvm.load %314 : !llvm.ptr -> i64
            %781 = arith.cmpi eq, %780, %arg1 : i64
            cf.cond_br %781, ^bb147, ^bb148
            ^bb147:
              %782 = arith.constant 0 : i32
              %783 = arith.extsi %782 : i32 to i64
              llvm.store %783, %314 : i64, !llvm.ptr
              cf.br ^bb149
            ^bb148:
              cf.br ^bb149
            ^bb149:
            %784 = arith.constant 0 : i32
            %786 = arith.extsi %784 : i32 to i64
            %785 = arith.cmpi eq, %323, %786 : i64
            cf.cond_br %785, ^bb150, ^bb151
            ^bb150:
              %787 = llvm.load %351 : !llvm.ptr -> i64
              %788 = llvm.load %343 : !llvm.ptr -> i64
              %789 = arith.constant 1 : i32
              %791 = arith.extsi %789 : i32 to i64
              %790 = arith.shli %788, %791 : i64
              %792 = arith.addi %787, %790 : i64
              llvm.store %792, %351 : i64, !llvm.ptr
              cf.br ^bb152
            ^bb151:
              %793 = llvm.load %333 : !llvm.ptr -> i64
              %794 = llvm.load %347 : !llvm.ptr -> i64
              %795 = arith.subi %793, %794 : i64
              %797 = llvm.load %343 : !llvm.ptr -> i64
              %798 = llvm.getelementptr %299[%797] : (!llvm.ptr, i64) -> !llvm.ptr, i64
              %796 = llvm.load %798 : !llvm.ptr -> i64
              %799 = arith.cmpi slt, %795, %796 : i64
              cf.cond_br %799, ^bb153, ^bb154
              ^bb153:
                %800 = llvm.load %351 : !llvm.ptr -> i64
                %801 = llvm.load %343 : !llvm.ptr -> i64
                %802 = arith.constant 1 : i32
                %804 = arith.extsi %802 : i32 to i64
                %803 = arith.shli %801, %804 : i64
                %805 = arith.addi %800, %803 : i64
                llvm.store %805, %351 : i64, !llvm.ptr
                cf.br ^bb155
              ^bb154:
                %806 = llvm.load %343 : !llvm.ptr -> i64
                %807 = arith.constant 1 : i32
                %809 = arith.extsi %807 : i32 to i64
                %808 = arith.addi %806, %809 : i64
                %810 = llvm.mlir.constant(1 : i64) : i64
                %811 = llvm.alloca %810 x i64 : (i64) -> !llvm.ptr
                llvm.store %808, %811 : i64, !llvm.ptr
                cf.br ^bb156
                ^bb156:
                %813 = llvm.load %811 : !llvm.ptr -> i64
                %814 = llvm.getelementptr %299[%813] : (!llvm.ptr, i64) -> !llvm.ptr, i64
                %812 = llvm.load %814 : !llvm.ptr -> i64
                %815 = arith.constant 0 : i32
                %817 = arith.extsi %815 : i32 to i64
                %816 = arith.cmpi eq, %812, %817 : i64
                cf.cond_br %816, ^bb157, ^bb158
                ^bb157:
                  %818 = llvm.load %811 : !llvm.ptr -> i64
                  %819 = arith.constant 1 : i32
                  %821 = arith.extsi %819 : i32 to i64
                  %820 = arith.addi %818, %821 : i64
                  llvm.store %820, %811 : i64, !llvm.ptr
                  cf.br ^bb156
                ^bb158:
                %822 = llvm.load %351 : !llvm.ptr -> i64
                %823 = llvm.load %343 : !llvm.ptr -> i64
                %824 = arith.addi %822, %823 : i64
                %825 = llvm.load %811 : !llvm.ptr -> i64
                %826 = arith.addi %824, %825 : i64
                llvm.store %826, %351 : i64, !llvm.ptr
                cf.br ^bb155
              ^bb155:
              cf.br ^bb152
            ^bb152:
            %827 = llvm.load %372 : !llvm.ptr -> i64
            %828 = arith.cmpi eq, %827, %arg0 : i64
            cf.cond_br %828, ^bb159, ^bb160
            ^bb159:
              func.call @free(%490) : (!llvm.ptr) -> ()
              func.call @free(%288) : (!llvm.ptr) -> ()
              func.call @free(%293) : (!llvm.ptr) -> ()
              func.call @free(%299) : (!llvm.ptr) -> ()
              func.call @free(%304) : (!llvm.ptr) -> ()
              func.call @free(%352) : (!llvm.ptr) -> ()
              func.call @free(%417) : (!llvm.ptr) -> ()
              func.call @free(%424) : (!llvm.ptr) -> ()
              func.call @free(%427) : (!llvm.ptr) -> ()
              %838 = llvm.load %351 : !llvm.ptr -> i64
              func.return %838 : i64
            ^bb160:
              cf.br ^bb161
            ^bb161:
            cf.br ^bb113
          ^bb113:
          cf.br ^bb101
        ^bb100:
          cf.br ^bb101
        ^bb101:
        %839 = llvm.load %496 : !llvm.ptr -> i64
        %840 = arith.constant 1 : i32
        %842 = arith.extsi %840 : i32 to i64
        %841 = arith.addi %839, %842 : i64
        llvm.store %841, %496 : i64, !llvm.ptr
        cf.br ^bb96
      ^bb98:
      func.call @free(%490) : (!llvm.ptr) -> ()
      %844 = llvm.load %475 : !llvm.ptr -> i64
      %845 = arith.constant 1 : i32
      %847 = arith.extsi %845 : i32 to i64
      %846 = arith.ori %844, %847 : i64
      llvm.store %846, %466 : i64, !llvm.ptr
      cf.br ^bb69
    ^bb71:
    %848 = llvm.load %351 : !llvm.ptr -> i64
    func.return %848 : i64
  }
  func.func @main() -> i32 {
    %850 = arith.constant 10000000 : i32
    %851 = arith.constant 100000 : i32
    %852 = arith.extsi %850 : i32 to i64
    %853 = arith.extsi %851 : i32 to i64
    %849 = func.call @compute_F2(%852, %853) : (i64, i64) -> i64
    %854 = llvm.mlir.addressof @str_0 : !llvm.ptr
    %855 = arith.sitofp %849 : i64 to f64
    %856 = arith.constant 2.0 : f32
    %858 = arith.extf %856 : f32 to f64
    %857 = arith.divf %855, %858 : f64
    %859 = llvm.call @printf(%854, %857) vararg(!llvm.func<i32 (ptr, ...)>) : (!llvm.ptr, f64) -> i32
    %860 = arith.constant 0 : i32
    func.return %860 : i32
  }
}