Problem 233

Sum of N <= 10^11 with f(N)=420 lattice points on circle.

Answer271204031455541309
Output271204031455541309
StatusPASS
Native helperno
Runtime10 ms
Peak memory15616 KB
Time complexityO(n^2) (estimated)
Space complexityO(n^2) (estimated)

Performance comparison

MetricOur solutionBest known
Time complexityO(n^2)O(n^2)
Space complexityO(n^2)O(n^2)
ApproachFlow solutionCombinatorial or DP counting
VerdictOptimal

Flow source

# Project Euler 233
# Sum of N <= 10^11 with f(N)=420 lattice points on circle.

import euler.nt { isqrt }

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

function iroot(n: i64, k: i32) -> i64 {
    if n <= 1 || k == 1 { return n }
    let mut x: i64 = 1
    # rough init via sqrt repeatedly
    if k == 3 {
        x = (n |> isqrt |> isqrt) + 2
    } elif k == 7 {
        x = (n |> isqrt |> isqrt |> isqrt) + 2
    } else {
        x = isqrt(n)
    }
    while true {
        let mut p: i64 = 1
        let mut i: i32 = 0
        let mut overflow: bool = false
        while i < k {
            if p > n / x { overflow = true; break }
            p = p * x
            i = i + 1
        }
        if !overflow && p <= n {
            let mut p2: i64 = 1
            let mut ok: bool = true
            i = 0
            while i < k {
                if p2 > n / (x + 1) { ok = false; break }
                p2 = p2 * (x + 1)
                i = i + 1
            }
            if ok && p2 <= n {
                x = x + 1
                continue
            }
            return x
        }
        x = x - 1
        if x <= 0 { return 0 }
    }
    return x
}

function bisect_right(a: ptr<i64>, n: i64, v: i64) -> i64 {
    let mut lo: i64 = 0
    let mut hi: i64 = n
    while lo < hi {
        let mid: i64 = (lo + hi) / 2
        if a[mid] <= v { lo = mid + 1 }
        else { hi = mid }
    }
    return lo
}

function main() -> i32 {
    let LIMIT: i64 = 100000000000
    let max_prime: i64 = LIMIT / (125 * 169)
    let sieve: ptr<i8> = calloc(max_prime + 1, 1)
    if sieve == null { return 1 }
    let mut i: i64 = 0
    while i <= max_prime {
        sieve[i] = 1
        i = i + 1
    }
    sieve[0] = 0; sieve[1] = 0
    i = 2
    while i * i <= max_prime {
        if sieve[i] == 1 {
            let mut j: i64 = i * i
            while j <= max_prime {
                sieve[j] = 0
                j = j + i
            }
        }
        i = i + 1
    }
    let primes1: ptr<i64> = calloc(max_prime / 5, 8)
    let mut np: i64 = 0
    i = 5
    while i <= max_prime {
        if sieve[i] == 1 && (i & 3) == 1 {
            primes1[np] = i
            np = np + 1
        }
        i = i + 2
    }

    let gmax: i64 = LIMIT / (125 * 169 * 17)
    let allowed: ptr<i8> = calloc(gmax + 1, 1)
    let prefix: ptr<i64> = calloc(gmax + 1, 8)
    if allowed == null || prefix == null { return 1 }
    i = 0
    while i <= gmax {
        allowed[i] = 1
        i = i + 1
    }
    allowed[0] = 0
    i = 0
    while i < np {
        let p: i64 = primes1[i]
        if p > gmax { break }
        let mut j: i64 = p
        while j <= gmax {
            allowed[j] = 0
            j = j + p
        }
        i = i + 1
    }
    let mut s: i64 = 0
    i = 1
    while i <= gmax {
        if allowed[i] == 1 { s = s + i }
        prefix[i] = s
        i = i + 1
    }

    let mut total: i64 = 0

    # Pattern (10,2): 5^10 * q^2
    let p10: i64 = 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5
    if p10 <= LIMIT {
        let qmax: i64 = isqrt(LIMIT / p10)
        let iq: i64 = bisect_right(primes1, np, qmax)
        let mut j: i64 = 0
        while j < iq {
            let q: i64 = primes1[j]
            if q != 5 {
                let base: i64 = p10 * q * q
                let m: i64 = LIMIT / base
                if m > gmax { m = gmax }
                total = total + base * prefix[m]
            }
            j = j + 1
        }
    }

    # Pattern (7,3)
    let amax: i64 = iroot(LIMIT, 7)
    let ia: i64 = bisect_right(primes1, np, amax)
    let mut ii: i64 = 0
    while ii < ia {
        let a: i64 = primes1[ii]
        let mut a7: i64 = 1
        let mut t: i32 = 0
        while t < 7 {
            a7 = a7 * a
            t = t + 1
        }
        if a7 > LIMIT { break }
        let bmax: i64 = iroot(LIMIT / a7, 3)
        let ib: i64 = bisect_right(primes1, np, bmax)
        let mut j: i64 = 0
        while j < ib {
            let b: i64 = primes1[j]
            if b != a {
                let base: i64 = a7 * b * b * b
                if base <= LIMIT {
                    let m: i64 = LIMIT / base
                    if m > gmax { m = gmax }
                    total = total + base * prefix[m]
                }
            }
            j = j + 1
        }
        ii = ii + 1
    }

    # Pattern (3,2,1)
    let p3max: i64 = iroot(LIMIT, 3)
    let ip3: i64 = bisect_right(primes1, np, p3max)
    ii = 0
    while ii < ip3 {
        let p3: i64 = primes1[ii]
        let p3_3: i64 = p3 * p3 * p3
        if p3_3 > LIMIT { break }
        let q2max: i64 = isqrt(LIMIT / p3_3)
        let iq: i64 = bisect_right(primes1, np, q2max)
        let mut j: i64 = 0
        while j < iq {
            let q: i64 = primes1[j]
            if q != p3 {
                let base_pq: i64 = p3_3 * q * q
                if base_pq <= LIMIT {
                    let rmax: i64 = LIMIT / base_pq
                    let ir: i64 = bisect_right(primes1, np, rmax)
                    let mut kk: i64 = 0
                    while kk < ir {
                        let r: i64 = primes1[kk]
                        if r != p3 && r != q {
                            let base: i64 = base_pq * r
                            let m: i64 = LIMIT / base
                            if m > gmax { m = gmax }
                            total = total + base * prefix[m]
                        }
                        kk = kk + 1
                    }
                }
            }
            j = j + 1
        }
        ii = ii + 1
    }

    printf("%lld\n", total)
    free(sieve); free(primes1); free(allowed); free(prefix)
    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 iroot_i64_i32(int64_t n, int32_t k);
int64_t bisect_right_ptr_i64_i64_i64(int64_t* a, int64_t n, int64_t v);
int32_t main(void);

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 iroot_i64_i32(int64_t n, int32_t k) {
    if ((n <= 1 || k == 1)) {
        return n;
    }
    int64_t x = 1;
    if (k == 3) {
        x = (isqrt_i64(isqrt_i64(n)) + 2);
    } else if (k == 7) {
        x = (isqrt_i64(isqrt_i64(isqrt_i64(n))) + 2);
    } else {
        x = isqrt_i64(n);
    }
    while (1) {
        int64_t p = 1;
        int32_t i = 0;
        bool overflow = 0;
        while (i < k) {
            if (p > FLOW_CHECKED_DIV((n), (x))) {
                overflow = 1;
                break;
            }
            p = (p * x);
            i = (i + 1);
        }
        if (((!(overflow)) && p <= n)) {
            int64_t p2 = 1;
            bool ok = 1;
            i = 0;
            while (i < k) {
                if (p2 > FLOW_CHECKED_DIV((n), ((x + 1)))) {
                    ok = 0;
                    break;
                }
                p2 = (p2 * (x + 1));
                i = (i + 1);
            }
            if ((ok && p2 <= n)) {
                x = (x + 1);
                continue;
            }
            return x;
        }
        x = (x - 1);
        if (x <= 0) {
            return 0;
        }
    }
    return x;
}

int64_t bisect_right_ptr_i64_i64_i64(int64_t* a, int64_t n, int64_t v) {
    int64_t lo = 0;
    int64_t hi = n;
    while (lo < hi) {
        int64_t mid = FLOW_CHECKED_DIV(((lo + hi)), (2));
        if (a[mid] <= v) {
            lo = (mid + 1);
        } else {
            hi = mid;
        }
    }
    return lo;
}

int32_t main(void) {
    int64_t LIMIT = 100000000000;
    int64_t max_prime = FLOW_CHECKED_DIV((LIMIT), ((125 * 169)));
    int8_t* sieve = (int8_t*)(calloc((max_prime + 1), 1));
    if (sieve == NULL) {
        return 1;
    }
    int64_t i = 0;
    while (i <= max_prime) {
        sieve[i] = 1;
        i = (i + 1);
    }
    sieve[0] = 0;
    sieve[1] = 0;
    i = 2;
    while ((i * i) <= max_prime) {
        if (sieve[i] == 1) {
            int64_t j = (i * i);
            while (j <= max_prime) {
                sieve[j] = 0;
                j = (j + i);
            }
        }
        i = (i + 1);
    }
    int64_t* primes1 = (int64_t*)(calloc(FLOW_CHECKED_DIV((max_prime), (5)), 8));
    int64_t np = 0;
    i = 5;
    while (i <= max_prime) {
        if ((sieve[i] == 1 && (i & 3) == 1)) {
            primes1[np] = i;
            np = (np + 1);
        }
        i = (i + 2);
    }
    int64_t gmax = FLOW_CHECKED_DIV((LIMIT), (((125 * 169) * 17)));
    int8_t* allowed = (int8_t*)(calloc((gmax + 1), 1));
    int64_t* prefix = (int64_t*)(calloc((gmax + 1), 8));
    if ((allowed == NULL || prefix == NULL)) {
        return 1;
    }
    i = 0;
    while (i <= gmax) {
        allowed[i] = 1;
        i = (i + 1);
    }
    allowed[0] = 0;
    i = 0;
    while (i < np) {
        int64_t p = primes1[i];
        if (p > gmax) {
            break;
        }
        int64_t j = p;
        while (j <= gmax) {
            allowed[j] = 0;
            j = (j + p);
        }
        i = (i + 1);
    }
    int64_t s = 0;
    i = 1;
    while (i <= gmax) {
        if (allowed[i] == 1) {
            s = (s + i);
        }
        prefix[i] = s;
        i = (i + 1);
    }
    int64_t total = 0;
    int64_t p10 = (((((((((5 * 5) * 5) * 5) * 5) * 5) * 5) * 5) * 5) * 5);
    if (p10 <= LIMIT) {
        int64_t qmax = isqrt_i64(FLOW_CHECKED_DIV((LIMIT), (p10)));
        int64_t iq = bisect_right_ptr_i64_i64_i64(primes1, np, qmax);
        int64_t j = 0;
        while (j < iq) {
            int64_t q = primes1[j];
            if (q != 5) {
                int64_t base = ((p10 * q) * q);
                int64_t m = FLOW_CHECKED_DIV((LIMIT), (base));
                if (m > gmax) {
                    m = gmax;
                }
                total = (total + (base * prefix[m]));
            }
            j = (j + 1);
        }
    }
    int64_t amax = iroot_i64_i32(LIMIT, 7);
    int64_t ia = bisect_right_ptr_i64_i64_i64(primes1, np, amax);
    int64_t ii = 0;
    while (ii < ia) {
        int64_t a = primes1[ii];
        int64_t a7 = 1;
        int32_t t = 0;
        while (t < 7) {
            a7 = (a7 * a);
            t = (t + 1);
        }
        if (a7 > LIMIT) {
            break;
        }
        int64_t bmax = iroot_i64_i32(FLOW_CHECKED_DIV((LIMIT), (a7)), 3);
        int64_t ib = bisect_right_ptr_i64_i64_i64(primes1, np, bmax);
        int64_t j = 0;
        while (j < ib) {
            int64_t b = primes1[j];
            if (b != a) {
                int64_t base = (((a7 * b) * b) * b);
                if (base <= LIMIT) {
                    int64_t m = FLOW_CHECKED_DIV((LIMIT), (base));
                    if (m > gmax) {
                        m = gmax;
                    }
                    total = (total + (base * prefix[m]));
                }
            }
            j = (j + 1);
        }
        ii = (ii + 1);
    }
    int64_t p3max = iroot_i64_i32(LIMIT, 3);
    int64_t ip3 = bisect_right_ptr_i64_i64_i64(primes1, np, p3max);
    ii = 0;
    while (ii < ip3) {
        int64_t p3 = primes1[ii];
        int64_t p3_3 = ((p3 * p3) * p3);
        if (p3_3 > LIMIT) {
            break;
        }
        int64_t q2max = isqrt_i64(FLOW_CHECKED_DIV((LIMIT), (p3_3)));
        int64_t iq = bisect_right_ptr_i64_i64_i64(primes1, np, q2max);
        int64_t j = 0;
        while (j < iq) {
            int64_t q = primes1[j];
            if (q != p3) {
                int64_t base_pq = ((p3_3 * q) * q);
                if (base_pq <= LIMIT) {
                    int64_t rmax = FLOW_CHECKED_DIV((LIMIT), (base_pq));
                    int64_t ir = bisect_right_ptr_i64_i64_i64(primes1, np, rmax);
                    int64_t kk = 0;
                    while (kk < ir) {
                        int64_t r = primes1[kk];
                        if ((r != p3 && r != q)) {
                            int64_t base = (base_pq * r);
                            int64_t m = FLOW_CHECKED_DIV((LIMIT), (base));
                            if (m > gmax) {
                                m = gmax;
                            }
                            total = (total + (base * prefix[m]));
                        }
                        kk = (kk + 1);
                    }
                }
            }
            j = (j + 1);
        }
        ii = (ii + 1);
    }
    printf("%lld\n", total);
    free(sieve);
    free(primes1);
    free(allowed);
    free(prefix);
    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) -> ()
  func.func @iroot(%arg0: i64, %arg1: i32) -> i64 {
    %175 = arith.constant 1 : i32
    %177 = arith.extsi %175 : i32 to i64
    %176 = arith.cmpi sle, %arg0, %177 : i64
    %178 = scf.if %176 -> (i1) {
      %179 = arith.constant true
      scf.yield %179 : i1
    } else {
      %180 = arith.constant 1 : i32
      %181 = arith.cmpi eq, %arg1, %180 : i32
      scf.yield %181 : i1
    }
    cf.cond_br %178, ^bb42, ^bb43
    ^bb42:
      func.return %arg0 : i64
    ^bb43:
      cf.br ^bb44
    ^bb44:
    %182 = arith.constant 1 : i32
    %183 = arith.extsi %182 : i32 to i64
    %184 = llvm.mlir.constant(1 : i64) : i64
    %185 = llvm.alloca %184 x i64 : (i64) -> !llvm.ptr
    llvm.store %183, %185 : i64, !llvm.ptr
    %186 = arith.constant 3 : i32
    %187 = arith.cmpi eq, %arg1, %186 : i32
    cf.cond_br %187, ^bb45, ^bb46
    ^bb45:
      %189 = func.call @isqrt(%arg0) : (i64) -> i64
      %188 = func.call @isqrt(%189) : (i64) -> i64
      %190 = arith.constant 2 : i32
      %192 = arith.extsi %190 : i32 to i64
      %191 = arith.addi %188, %192 : i64
      llvm.store %191, %185 : i64, !llvm.ptr
      cf.br ^bb47
    ^bb46:
      %193 = arith.constant 7 : i32
      %194 = arith.cmpi eq, %arg1, %193 : i32
      cf.cond_br %194, ^bb49, ^bb48
    ^bb49:
      %197 = func.call @isqrt(%arg0) : (i64) -> i64
      %196 = func.call @isqrt(%197) : (i64) -> i64
      %195 = func.call @isqrt(%196) : (i64) -> i64
      %198 = arith.constant 2 : i32
      %200 = arith.extsi %198 : i32 to i64
      %199 = arith.addi %195, %200 : i64
      llvm.store %199, %185 : i64, !llvm.ptr
      cf.br ^bb47
    ^bb48:
      %201 = func.call @isqrt(%arg0) : (i64) -> i64
      llvm.store %201, %185 : i64, !llvm.ptr
      cf.br ^bb47
    ^bb47:
    cf.br ^bb50
    ^bb50:
    %202 = arith.constant 1 : i1
    cf.cond_br %202, ^bb51, ^bb52
    ^bb51:
      %203 = arith.constant 1 : i32
      %204 = arith.extsi %203 : i32 to i64
      %205 = llvm.mlir.constant(1 : i64) : i64
      %206 = llvm.alloca %205 x i64 : (i64) -> !llvm.ptr
      llvm.store %204, %206 : i64, !llvm.ptr
      %207 = arith.constant 0 : i32
      %208 = llvm.mlir.constant(1 : i64) : i64
      %209 = llvm.alloca %208 x i32 : (i64) -> !llvm.ptr
      llvm.store %207, %209 : i32, !llvm.ptr
      %210 = arith.constant 0 : i1
      %211 = llvm.mlir.constant(1 : i64) : i64
      %212 = llvm.alloca %211 x i1 : (i64) -> !llvm.ptr
      llvm.store %210, %212 : i1, !llvm.ptr
      cf.br ^bb53
      ^bb53:
      %213 = llvm.load %209 : !llvm.ptr -> i32
      %214 = arith.cmpi slt, %213, %arg1 : i32
      cf.cond_br %214, ^bb54, ^bb55
      ^bb54:
        %215 = llvm.load %206 : !llvm.ptr -> i64
        %216 = llvm.load %185 : !llvm.ptr -> i64
        %217 = arith.divsi %arg0, %216 : i64
        %218 = arith.cmpi sgt, %215, %217 : i64
        cf.cond_br %218, ^bb56, ^bb57
        ^bb56:
          %219 = arith.constant 1 : i1
          llvm.store %219, %212 : i1, !llvm.ptr
          cf.br ^bb55
        ^bb57:
          cf.br ^bb58
        ^bb58:
        %220 = llvm.load %206 : !llvm.ptr -> i64
        %221 = llvm.load %185 : !llvm.ptr -> i64
        %222 = arith.muli %220, %221 : i64
        llvm.store %222, %206 : i64, !llvm.ptr
        %223 = llvm.load %209 : !llvm.ptr -> i32
        %224 = arith.constant 1 : i32
        %225 = arith.addi %223, %224 : i32
        llvm.store %225, %209 : i32, !llvm.ptr
        cf.br ^bb53
      ^bb55:
      %226 = llvm.load %212 : !llvm.ptr -> i1
      %228 = arith.constant 1 : i1
      %227 = arith.xori %226, %228 : i1
      %230 = scf.if %227 -> (i1) {
        %231 = llvm.load %206 : !llvm.ptr -> i64
        %232 = arith.cmpi sle, %231, %arg0 : i64
        scf.yield %232 : i1
      } else {
        %233 = arith.constant false
        scf.yield %233 : i1
      }
      cf.cond_br %230, ^bb59, ^bb60
      ^bb59:
        %234 = arith.constant 1 : i32
        %235 = arith.extsi %234 : i32 to i64
        %236 = llvm.mlir.constant(1 : i64) : i64
        %237 = llvm.alloca %236 x i64 : (i64) -> !llvm.ptr
        llvm.store %235, %237 : i64, !llvm.ptr
        %238 = arith.constant 1 : i1
        %239 = llvm.mlir.constant(1 : i64) : i64
        %240 = llvm.alloca %239 x i1 : (i64) -> !llvm.ptr
        llvm.store %238, %240 : i1, !llvm.ptr
        %241 = arith.constant 0 : i32
        llvm.store %241, %209 : i32, !llvm.ptr
        cf.br ^bb62
        ^bb62:
        %242 = llvm.load %209 : !llvm.ptr -> i32
        %243 = arith.cmpi slt, %242, %arg1 : i32
        cf.cond_br %243, ^bb63, ^bb64
        ^bb63:
          %244 = llvm.load %237 : !llvm.ptr -> i64
          %245 = llvm.load %185 : !llvm.ptr -> i64
          %246 = arith.constant 1 : i32
          %248 = arith.extsi %246 : i32 to i64
          %247 = arith.addi %245, %248 : i64
          %249 = arith.divsi %arg0, %247 : i64
          %250 = arith.cmpi sgt, %244, %249 : i64
          cf.cond_br %250, ^bb65, ^bb66
          ^bb65:
            %251 = arith.constant 0 : i1
            llvm.store %251, %240 : i1, !llvm.ptr
            cf.br ^bb64
          ^bb66:
            cf.br ^bb67
          ^bb67:
          %252 = llvm.load %237 : !llvm.ptr -> i64
          %253 = llvm.load %185 : !llvm.ptr -> i64
          %254 = arith.constant 1 : i32
          %256 = arith.extsi %254 : i32 to i64
          %255 = arith.addi %253, %256 : i64
          %257 = arith.muli %252, %255 : i64
          llvm.store %257, %237 : i64, !llvm.ptr
          %258 = llvm.load %209 : !llvm.ptr -> i32
          %259 = arith.constant 1 : i32
          %260 = arith.addi %258, %259 : i32
          llvm.store %260, %209 : i32, !llvm.ptr
          cf.br ^bb62
        ^bb64:
        %261 = llvm.load %240 : !llvm.ptr -> i1
        %262 = scf.if %261 -> (i1) {
          %263 = llvm.load %237 : !llvm.ptr -> i64
          %264 = arith.cmpi sle, %263, %arg0 : i64
          scf.yield %264 : i1
        } else {
          %265 = arith.constant false
          scf.yield %265 : i1
        }
        cf.cond_br %262, ^bb68, ^bb69
        ^bb68:
          %266 = llvm.load %185 : !llvm.ptr -> i64
          %267 = arith.constant 1 : i32
          %269 = arith.extsi %267 : i32 to i64
          %268 = arith.addi %266, %269 : i64
          llvm.store %268, %185 : i64, !llvm.ptr
          cf.br ^bb50
        ^bb69:
          cf.br ^bb70
        ^bb70:
        %270 = llvm.load %185 : !llvm.ptr -> i64
        func.return %270 : i64
      ^bb60:
        cf.br ^bb61
      ^bb61:
      %271 = llvm.load %185 : !llvm.ptr -> i64
      %272 = arith.constant 1 : i32
      %274 = arith.extsi %272 : i32 to i64
      %273 = arith.subi %271, %274 : i64
      llvm.store %273, %185 : i64, !llvm.ptr
      %275 = llvm.load %185 : !llvm.ptr -> i64
      %276 = arith.constant 0 : i32
      %278 = arith.extsi %276 : i32 to i64
      %277 = arith.cmpi sle, %275, %278 : i64
      cf.cond_br %277, ^bb71, ^bb72
      ^bb71:
        %279 = arith.constant 0 : i32
        %280 = arith.extsi %279 : i32 to i64
        func.return %280 : i64
      ^bb72:
        cf.br ^bb73
      ^bb73:
      cf.br ^bb50
    ^bb52:
    %281 = llvm.load %185 : !llvm.ptr -> i64
    func.return %281 : i64
  }
  func.func @bisect_right(%arg0: !llvm.ptr, %arg1: i64, %arg2: i64) -> i64 {
    %282 = arith.constant 0 : i32
    %283 = arith.extsi %282 : i32 to i64
    %284 = llvm.mlir.constant(1 : i64) : i64
    %285 = llvm.alloca %284 x i64 : (i64) -> !llvm.ptr
    llvm.store %283, %285 : i64, !llvm.ptr
    %286 = llvm.mlir.constant(1 : i64) : i64
    %287 = llvm.alloca %286 x i64 : (i64) -> !llvm.ptr
    llvm.store %arg1, %287 : i64, !llvm.ptr
    cf.br ^bb74
    ^bb74:
    %288 = llvm.load %285 : !llvm.ptr -> i64
    %289 = llvm.load %287 : !llvm.ptr -> i64
    %290 = arith.cmpi slt, %288, %289 : i64
    cf.cond_br %290, ^bb75, ^bb76
    ^bb75:
      %291 = llvm.load %285 : !llvm.ptr -> i64
      %292 = llvm.load %287 : !llvm.ptr -> i64
      %293 = arith.addi %291, %292 : i64
      %294 = arith.constant 2 : i32
      %296 = arith.extsi %294 : i32 to i64
      %295 = arith.divsi %293, %296 : i64
      %298 = llvm.getelementptr %arg0[%295] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %297 = llvm.load %298 : !llvm.ptr -> i64
      %299 = arith.cmpi sle, %297, %arg2 : i64
      cf.cond_br %299, ^bb77, ^bb78
      ^bb77:
        %300 = arith.constant 1 : i32
        %302 = arith.extsi %300 : i32 to i64
        %301 = arith.addi %295, %302 : i64
        llvm.store %301, %285 : i64, !llvm.ptr
        cf.br ^bb79
      ^bb78:
        llvm.store %295, %287 : i64, !llvm.ptr
        cf.br ^bb79
      ^bb79:
      cf.br ^bb74
    ^bb76:
    %303 = llvm.load %285 : !llvm.ptr -> i64
    func.return %303 : i64
  }
  func.func @main() -> i32 {
    %304 = arith.constant 95705032704 : i32
    %305 = arith.extsi %304 : i32 to i64
    %306 = arith.constant 125 : i32
    %307 = arith.constant 169 : i32
    %308 = arith.muli %306, %307 : i32
    %310 = arith.extsi %308 : i32 to i64
    %309 = arith.divsi %305, %310 : i64
    %312 = arith.constant 1 : i32
    %314 = arith.extsi %312 : i32 to i64
    %313 = arith.addi %309, %314 : i64
    %315 = arith.constant 1 : i32
    %316 = arith.extsi %315 : i32 to i64
    %311 = func.call @calloc(%313, %316) : (i64, i64) -> !llvm.ptr
    %317 = llvm.mlir.zero : !llvm.ptr
    %318 = llvm.icmp "eq" %311, %317 : !llvm.ptr
    cf.cond_br %318, ^bb80, ^bb81
    ^bb80:
      %319 = arith.constant 1 : i32
      func.return %319 : i32
    ^bb81:
      cf.br ^bb82
    ^bb82:
    %320 = arith.constant 0 : i32
    %321 = arith.extsi %320 : i32 to i64
    %322 = llvm.mlir.constant(1 : i64) : i64
    %323 = llvm.alloca %322 x i64 : (i64) -> !llvm.ptr
    llvm.store %321, %323 : i64, !llvm.ptr
    cf.br ^bb83
    ^bb83:
    %324 = llvm.load %323 : !llvm.ptr -> i64
    %325 = arith.cmpi sle, %324, %309 : i64
    cf.cond_br %325, ^bb84, ^bb85
    ^bb84:
      %326 = arith.constant 1 : i32
      %327 = llvm.load %323 : !llvm.ptr -> i64
      %328 = arith.trunci %326 : i32 to i8
      %329 = llvm.getelementptr %311[%327] : (!llvm.ptr, i64) -> !llvm.ptr, i8
      llvm.store %328, %329 : i8, !llvm.ptr
      %330 = llvm.load %323 : !llvm.ptr -> i64
      %331 = arith.constant 1 : i32
      %333 = arith.extsi %331 : i32 to i64
      %332 = arith.addi %330, %333 : i64
      llvm.store %332, %323 : i64, !llvm.ptr
      cf.br ^bb83
    ^bb85:
    %334 = arith.constant 0 : i32
    %335 = arith.constant 0 : i32
    %336 = arith.trunci %334 : i32 to i8
    %337 = arith.extsi %335 : i32 to i64
    %338 = llvm.getelementptr %311[%337] : (!llvm.ptr, i64) -> !llvm.ptr, i8
    llvm.store %336, %338 : i8, !llvm.ptr
    %339 = arith.constant 0 : i32
    %340 = arith.constant 1 : i32
    %341 = arith.trunci %339 : i32 to i8
    %342 = arith.extsi %340 : i32 to i64
    %343 = llvm.getelementptr %311[%342] : (!llvm.ptr, i64) -> !llvm.ptr, i8
    llvm.store %341, %343 : i8, !llvm.ptr
    %344 = arith.constant 2 : i32
    %345 = arith.extsi %344 : i32 to i64
    llvm.store %345, %323 : i64, !llvm.ptr
    cf.br ^bb86
    ^bb86:
    %346 = llvm.load %323 : !llvm.ptr -> i64
    %347 = llvm.load %323 : !llvm.ptr -> i64
    %348 = arith.muli %346, %347 : i64
    %349 = arith.cmpi sle, %348, %309 : i64
    cf.cond_br %349, ^bb87, ^bb88
    ^bb87:
      %351 = llvm.load %323 : !llvm.ptr -> i64
      %352 = llvm.getelementptr %311[%351] : (!llvm.ptr, i64) -> !llvm.ptr, i8
      %350 = llvm.load %352 : !llvm.ptr -> i8
      %353 = arith.constant 1 : i32
      %355 = arith.extsi %350 : i8 to i32
      %354 = arith.cmpi eq, %355, %353 : i32
      cf.cond_br %354, ^bb89, ^bb90
      ^bb89:
        %356 = llvm.load %323 : !llvm.ptr -> i64
        %357 = llvm.load %323 : !llvm.ptr -> i64
        %358 = arith.muli %356, %357 : i64
        %359 = llvm.mlir.constant(1 : i64) : i64
        %360 = llvm.alloca %359 x i64 : (i64) -> !llvm.ptr
        llvm.store %358, %360 : i64, !llvm.ptr
        cf.br ^bb92
        ^bb92:
        %361 = llvm.load %360 : !llvm.ptr -> i64
        %362 = arith.cmpi sle, %361, %309 : i64
        cf.cond_br %362, ^bb93, ^bb94
        ^bb93:
          %363 = arith.constant 0 : i32
          %364 = llvm.load %360 : !llvm.ptr -> i64
          %365 = arith.trunci %363 : i32 to i8
          %366 = llvm.getelementptr %311[%364] : (!llvm.ptr, i64) -> !llvm.ptr, i8
          llvm.store %365, %366 : i8, !llvm.ptr
          %367 = llvm.load %360 : !llvm.ptr -> i64
          %368 = llvm.load %323 : !llvm.ptr -> i64
          %369 = arith.addi %367, %368 : i64
          llvm.store %369, %360 : i64, !llvm.ptr
          cf.br ^bb92
        ^bb94:
        cf.br ^bb91
      ^bb90:
        cf.br ^bb91
      ^bb91:
      %370 = llvm.load %323 : !llvm.ptr -> i64
      %371 = arith.constant 1 : i32
      %373 = arith.extsi %371 : i32 to i64
      %372 = arith.addi %370, %373 : i64
      llvm.store %372, %323 : i64, !llvm.ptr
      cf.br ^bb86
    ^bb88:
    %375 = arith.constant 5 : i32
    %377 = arith.extsi %375 : i32 to i64
    %376 = arith.divsi %309, %377 : i64
    %378 = arith.constant 8 : i32
    %379 = arith.extsi %378 : i32 to i64
    %374 = func.call @calloc(%376, %379) : (i64, i64) -> !llvm.ptr
    %380 = arith.constant 0 : i32
    %381 = arith.extsi %380 : i32 to i64
    %382 = llvm.mlir.constant(1 : i64) : i64
    %383 = llvm.alloca %382 x i64 : (i64) -> !llvm.ptr
    llvm.store %381, %383 : i64, !llvm.ptr
    %384 = arith.constant 5 : i32
    %385 = arith.extsi %384 : i32 to i64
    llvm.store %385, %323 : i64, !llvm.ptr
    cf.br ^bb95
    ^bb95:
    %386 = llvm.load %323 : !llvm.ptr -> i64
    %387 = arith.cmpi sle, %386, %309 : i64
    cf.cond_br %387, ^bb96, ^bb97
    ^bb96:
      %389 = llvm.load %323 : !llvm.ptr -> i64
      %390 = llvm.getelementptr %311[%389] : (!llvm.ptr, i64) -> !llvm.ptr, i8
      %388 = llvm.load %390 : !llvm.ptr -> i8
      %391 = arith.constant 1 : i32
      %393 = arith.extsi %388 : i8 to i32
      %392 = arith.cmpi eq, %393, %391 : i32
      %394 = scf.if %392 -> (i1) {
        %395 = llvm.load %323 : !llvm.ptr -> i64
        %396 = arith.constant 3 : i32
        %398 = arith.extsi %396 : i32 to i64
        %397 = arith.andi %395, %398 : i64
        %399 = arith.constant 1 : i32
        %401 = arith.extsi %399 : i32 to i64
        %400 = arith.cmpi eq, %397, %401 : i64
        scf.yield %400 : i1
      } else {
        %402 = arith.constant false
        scf.yield %402 : i1
      }
      cf.cond_br %394, ^bb98, ^bb99
      ^bb98:
        %403 = llvm.load %323 : !llvm.ptr -> i64
        %404 = llvm.load %383 : !llvm.ptr -> i64
        %405 = llvm.getelementptr %374[%404] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        llvm.store %403, %405 : i64, !llvm.ptr
        %406 = llvm.load %383 : !llvm.ptr -> i64
        %407 = arith.constant 1 : i32
        %409 = arith.extsi %407 : i32 to i64
        %408 = arith.addi %406, %409 : i64
        llvm.store %408, %383 : i64, !llvm.ptr
        cf.br ^bb100
      ^bb99:
        cf.br ^bb100
      ^bb100:
      %410 = llvm.load %323 : !llvm.ptr -> i64
      %411 = arith.constant 2 : i32
      %413 = arith.extsi %411 : i32 to i64
      %412 = arith.addi %410, %413 : i64
      llvm.store %412, %323 : i64, !llvm.ptr
      cf.br ^bb95
    ^bb97:
    %414 = arith.constant 125 : i32
    %415 = arith.constant 169 : i32
    %416 = arith.muli %414, %415 : i32
    %417 = arith.constant 17 : i32
    %418 = arith.muli %416, %417 : i32
    %420 = arith.extsi %418 : i32 to i64
    %419 = arith.divsi %305, %420 : i64
    %422 = arith.constant 1 : i32
    %424 = arith.extsi %422 : i32 to i64
    %423 = arith.addi %419, %424 : i64
    %425 = arith.constant 1 : i32
    %426 = arith.extsi %425 : i32 to i64
    %421 = func.call @calloc(%423, %426) : (i64, i64) -> !llvm.ptr
    %428 = arith.constant 1 : i32
    %430 = arith.extsi %428 : i32 to i64
    %429 = arith.addi %419, %430 : i64
    %431 = arith.constant 8 : i32
    %432 = arith.extsi %431 : i32 to i64
    %427 = func.call @calloc(%429, %432) : (i64, i64) -> !llvm.ptr
    %433 = llvm.mlir.zero : !llvm.ptr
    %434 = llvm.icmp "eq" %421, %433 : !llvm.ptr
    %435 = scf.if %434 -> (i1) {
      %436 = arith.constant true
      scf.yield %436 : i1
    } else {
      %437 = llvm.mlir.zero : !llvm.ptr
      %438 = llvm.icmp "eq" %427, %437 : !llvm.ptr
      scf.yield %438 : i1
    }
    cf.cond_br %435, ^bb101, ^bb102
    ^bb101:
      %439 = arith.constant 1 : i32
      func.return %439 : i32
    ^bb102:
      cf.br ^bb103
    ^bb103:
    %440 = arith.constant 0 : i32
    %441 = arith.extsi %440 : i32 to i64
    llvm.store %441, %323 : i64, !llvm.ptr
    cf.br ^bb104
    ^bb104:
    %442 = llvm.load %323 : !llvm.ptr -> i64
    %443 = arith.cmpi sle, %442, %419 : i64
    cf.cond_br %443, ^bb105, ^bb106
    ^bb105:
      %444 = arith.constant 1 : i32
      %445 = llvm.load %323 : !llvm.ptr -> i64
      %446 = arith.trunci %444 : i32 to i8
      %447 = llvm.getelementptr %421[%445] : (!llvm.ptr, i64) -> !llvm.ptr, i8
      llvm.store %446, %447 : i8, !llvm.ptr
      %448 = llvm.load %323 : !llvm.ptr -> i64
      %449 = arith.constant 1 : i32
      %451 = arith.extsi %449 : i32 to i64
      %450 = arith.addi %448, %451 : i64
      llvm.store %450, %323 : i64, !llvm.ptr
      cf.br ^bb104
    ^bb106:
    %452 = arith.constant 0 : i32
    %453 = arith.constant 0 : i32
    %454 = arith.trunci %452 : i32 to i8
    %455 = arith.extsi %453 : i32 to i64
    %456 = llvm.getelementptr %421[%455] : (!llvm.ptr, i64) -> !llvm.ptr, i8
    llvm.store %454, %456 : i8, !llvm.ptr
    %457 = arith.constant 0 : i32
    %458 = arith.extsi %457 : i32 to i64
    llvm.store %458, %323 : i64, !llvm.ptr
    cf.br ^bb107
    ^bb107:
    %459 = llvm.load %323 : !llvm.ptr -> i64
    %460 = llvm.load %383 : !llvm.ptr -> i64
    %461 = arith.cmpi slt, %459, %460 : i64
    cf.cond_br %461, ^bb108, ^bb109
    ^bb108:
      %463 = llvm.load %323 : !llvm.ptr -> i64
      %464 = llvm.getelementptr %374[%463] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %462 = llvm.load %464 : !llvm.ptr -> i64
      %465 = arith.cmpi sgt, %462, %419 : i64
      cf.cond_br %465, ^bb110, ^bb111
      ^bb110:
        cf.br ^bb109
      ^bb111:
        cf.br ^bb112
      ^bb112:
      %466 = llvm.mlir.constant(1 : i64) : i64
      %467 = llvm.alloca %466 x i64 : (i64) -> !llvm.ptr
      llvm.store %462, %467 : i64, !llvm.ptr
      cf.br ^bb113
      ^bb113:
      %468 = llvm.load %467 : !llvm.ptr -> i64
      %469 = arith.cmpi sle, %468, %419 : i64
      cf.cond_br %469, ^bb114, ^bb115
      ^bb114:
        %470 = arith.constant 0 : i32
        %471 = llvm.load %467 : !llvm.ptr -> i64
        %472 = arith.trunci %470 : i32 to i8
        %473 = llvm.getelementptr %421[%471] : (!llvm.ptr, i64) -> !llvm.ptr, i8
        llvm.store %472, %473 : i8, !llvm.ptr
        %474 = llvm.load %467 : !llvm.ptr -> i64
        %475 = arith.addi %474, %462 : i64
        llvm.store %475, %467 : i64, !llvm.ptr
        cf.br ^bb113
      ^bb115:
      %476 = llvm.load %323 : !llvm.ptr -> i64
      %477 = arith.constant 1 : i32
      %479 = arith.extsi %477 : i32 to i64
      %478 = arith.addi %476, %479 : i64
      llvm.store %478, %323 : i64, !llvm.ptr
      cf.br ^bb107
    ^bb109:
    %480 = arith.constant 0 : i32
    %481 = arith.extsi %480 : i32 to i64
    %482 = llvm.mlir.constant(1 : i64) : i64
    %483 = llvm.alloca %482 x i64 : (i64) -> !llvm.ptr
    llvm.store %481, %483 : i64, !llvm.ptr
    %484 = arith.constant 1 : i32
    %485 = arith.extsi %484 : i32 to i64
    llvm.store %485, %323 : i64, !llvm.ptr
    cf.br ^bb116
    ^bb116:
    %486 = llvm.load %323 : !llvm.ptr -> i64
    %487 = arith.cmpi sle, %486, %419 : i64
    cf.cond_br %487, ^bb117, ^bb118
    ^bb117:
      %489 = llvm.load %323 : !llvm.ptr -> i64
      %490 = llvm.getelementptr %421[%489] : (!llvm.ptr, i64) -> !llvm.ptr, i8
      %488 = llvm.load %490 : !llvm.ptr -> i8
      %491 = arith.constant 1 : i32
      %493 = arith.extsi %488 : i8 to i32
      %492 = arith.cmpi eq, %493, %491 : i32
      cf.cond_br %492, ^bb119, ^bb120
      ^bb119:
        %494 = llvm.load %483 : !llvm.ptr -> i64
        %495 = llvm.load %323 : !llvm.ptr -> i64
        %496 = arith.addi %494, %495 : i64
        llvm.store %496, %483 : i64, !llvm.ptr
        cf.br ^bb121
      ^bb120:
        cf.br ^bb121
      ^bb121:
      %497 = llvm.load %483 : !llvm.ptr -> i64
      %498 = llvm.load %323 : !llvm.ptr -> i64
      %499 = llvm.getelementptr %427[%498] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %497, %499 : i64, !llvm.ptr
      %500 = llvm.load %323 : !llvm.ptr -> i64
      %501 = arith.constant 1 : i32
      %503 = arith.extsi %501 : i32 to i64
      %502 = arith.addi %500, %503 : i64
      llvm.store %502, %323 : i64, !llvm.ptr
      cf.br ^bb116
    ^bb118:
    %504 = arith.constant 0 : i32
    %505 = arith.extsi %504 : i32 to i64
    %506 = llvm.mlir.constant(1 : i64) : i64
    %507 = llvm.alloca %506 x i64 : (i64) -> !llvm.ptr
    llvm.store %505, %507 : i64, !llvm.ptr
    %508 = arith.constant 5 : i32
    %509 = arith.constant 5 : i32
    %510 = arith.muli %508, %509 : i32
    %511 = arith.constant 5 : i32
    %512 = arith.muli %510, %511 : i32
    %513 = arith.constant 5 : i32
    %514 = arith.muli %512, %513 : i32
    %515 = arith.constant 5 : i32
    %516 = arith.muli %514, %515 : i32
    %517 = arith.constant 5 : i32
    %518 = arith.muli %516, %517 : i32
    %519 = arith.constant 5 : i32
    %520 = arith.muli %518, %519 : i32
    %521 = arith.constant 5 : i32
    %522 = arith.muli %520, %521 : i32
    %523 = arith.constant 5 : i32
    %524 = arith.muli %522, %523 : i32
    %525 = arith.constant 5 : i32
    %526 = arith.muli %524, %525 : i32
    %527 = arith.extsi %526 : i32 to i64
    %528 = arith.cmpi sle, %527, %305 : i64
    cf.cond_br %528, ^bb122, ^bb123
    ^bb122:
      %530 = arith.divsi %305, %527 : i64
      %529 = func.call @isqrt(%530) : (i64) -> i64
      %532 = llvm.load %383 : !llvm.ptr -> i64
      %531 = func.call @bisect_right(%374, %532, %529) : (!llvm.ptr, i64, i64) -> i64
      %533 = arith.constant 0 : i32
      %534 = arith.extsi %533 : i32 to i64
      %535 = llvm.mlir.constant(1 : i64) : i64
      %536 = llvm.alloca %535 x i64 : (i64) -> !llvm.ptr
      llvm.store %534, %536 : i64, !llvm.ptr
      cf.br ^bb125
      ^bb125:
      %537 = llvm.load %536 : !llvm.ptr -> i64
      %538 = arith.cmpi slt, %537, %531 : i64
      cf.cond_br %538, ^bb126, ^bb127
      ^bb126:
        %540 = llvm.load %536 : !llvm.ptr -> i64
        %541 = llvm.getelementptr %374[%540] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %539 = llvm.load %541 : !llvm.ptr -> i64
        %542 = arith.constant 5 : i32
        %544 = arith.extsi %542 : i32 to i64
        %543 = arith.cmpi ne, %539, %544 : i64
        cf.cond_br %543, ^bb128, ^bb129
        ^bb128:
          %545 = arith.muli %527, %539 : i64
          %546 = arith.muli %545, %539 : i64
          %547 = arith.divsi %305, %546 : i64
          %548 = arith.cmpi sgt, %547, %419 : i64
          %549 = scf.if %548 -> (i64) {
            scf.yield %419 : i64
          } else {
            scf.yield %547 : i64
          }
          %550 = llvm.load %507 : !llvm.ptr -> i64
          %552 = llvm.getelementptr %427[%549] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          %551 = llvm.load %552 : !llvm.ptr -> i64
          %553 = arith.muli %546, %551 : i64
          %554 = arith.addi %550, %553 : i64
          llvm.store %554, %507 : i64, !llvm.ptr
          cf.br ^bb130
        ^bb129:
          cf.br ^bb130
        ^bb130:
        %555 = llvm.load %536 : !llvm.ptr -> i64
        %556 = arith.constant 1 : i32
        %558 = arith.extsi %556 : i32 to i64
        %557 = arith.addi %555, %558 : i64
        llvm.store %557, %536 : i64, !llvm.ptr
        cf.br ^bb125
      ^bb127:
      cf.br ^bb124
    ^bb123:
      cf.br ^bb124
    ^bb124:
    %560 = arith.constant 7 : i32
    %559 = func.call @iroot(%305, %560) : (i64, i32) -> i64
    %562 = llvm.load %383 : !llvm.ptr -> i64
    %561 = func.call @bisect_right(%374, %562, %559) : (!llvm.ptr, i64, i64) -> i64
    %563 = arith.constant 0 : i32
    %564 = arith.extsi %563 : i32 to i64
    %565 = llvm.mlir.constant(1 : i64) : i64
    %566 = llvm.alloca %565 x i64 : (i64) -> !llvm.ptr
    llvm.store %564, %566 : i64, !llvm.ptr
    cf.br ^bb131
    ^bb131:
    %567 = llvm.load %566 : !llvm.ptr -> i64
    %568 = arith.cmpi slt, %567, %561 : i64
    cf.cond_br %568, ^bb132, ^bb133
    ^bb132:
      %570 = llvm.load %566 : !llvm.ptr -> i64
      %571 = llvm.getelementptr %374[%570] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %569 = llvm.load %571 : !llvm.ptr -> i64
      %572 = arith.constant 1 : i32
      %573 = arith.extsi %572 : i32 to i64
      %574 = llvm.mlir.constant(1 : i64) : i64
      %575 = llvm.alloca %574 x i64 : (i64) -> !llvm.ptr
      llvm.store %573, %575 : i64, !llvm.ptr
      %576 = arith.constant 0 : i32
      %577 = llvm.mlir.constant(1 : i64) : i64
      %578 = llvm.alloca %577 x i32 : (i64) -> !llvm.ptr
      llvm.store %576, %578 : i32, !llvm.ptr
      cf.br ^bb134
      ^bb134:
      %579 = llvm.load %578 : !llvm.ptr -> i32
      %580 = arith.constant 7 : i32
      %581 = arith.cmpi slt, %579, %580 : i32
      cf.cond_br %581, ^bb135, ^bb136
      ^bb135:
        %582 = llvm.load %575 : !llvm.ptr -> i64
        %583 = arith.muli %582, %569 : i64
        llvm.store %583, %575 : i64, !llvm.ptr
        %584 = llvm.load %578 : !llvm.ptr -> i32
        %585 = arith.constant 1 : i32
        %586 = arith.addi %584, %585 : i32
        llvm.store %586, %578 : i32, !llvm.ptr
        cf.br ^bb134
      ^bb136:
      %587 = llvm.load %575 : !llvm.ptr -> i64
      %588 = arith.cmpi sgt, %587, %305 : i64
      cf.cond_br %588, ^bb137, ^bb138
      ^bb137:
        cf.br ^bb133
      ^bb138:
        cf.br ^bb139
      ^bb139:
      %590 = llvm.load %575 : !llvm.ptr -> i64
      %591 = arith.divsi %305, %590 : i64
      %592 = arith.constant 3 : i32
      %589 = func.call @iroot(%591, %592) : (i64, i32) -> i64
      %594 = llvm.load %383 : !llvm.ptr -> i64
      %593 = func.call @bisect_right(%374, %594, %589) : (!llvm.ptr, i64, i64) -> i64
      %595 = arith.constant 0 : i32
      %596 = arith.extsi %595 : i32 to i64
      %597 = llvm.mlir.constant(1 : i64) : i64
      %598 = llvm.alloca %597 x i64 : (i64) -> !llvm.ptr
      llvm.store %596, %598 : i64, !llvm.ptr
      cf.br ^bb140
      ^bb140:
      %599 = llvm.load %598 : !llvm.ptr -> i64
      %600 = arith.cmpi slt, %599, %593 : i64
      cf.cond_br %600, ^bb141, ^bb142
      ^bb141:
        %602 = llvm.load %598 : !llvm.ptr -> i64
        %603 = llvm.getelementptr %374[%602] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %601 = llvm.load %603 : !llvm.ptr -> i64
        %604 = arith.cmpi ne, %601, %569 : i64
        cf.cond_br %604, ^bb143, ^bb144
        ^bb143:
          %605 = llvm.load %575 : !llvm.ptr -> i64
          %606 = arith.muli %605, %601 : i64
          %607 = arith.muli %606, %601 : i64
          %608 = arith.muli %607, %601 : i64
          %609 = arith.cmpi sle, %608, %305 : i64
          cf.cond_br %609, ^bb146, ^bb147
          ^bb146:
            %610 = arith.divsi %305, %608 : i64
            %611 = arith.cmpi sgt, %610, %419 : i64
            %612 = scf.if %611 -> (i64) {
              scf.yield %419 : i64
            } else {
              scf.yield %610 : i64
            }
            %613 = llvm.load %507 : !llvm.ptr -> i64
            %615 = llvm.getelementptr %427[%612] : (!llvm.ptr, i64) -> !llvm.ptr, i64
            %614 = llvm.load %615 : !llvm.ptr -> i64
            %616 = arith.muli %608, %614 : i64
            %617 = arith.addi %613, %616 : i64
            llvm.store %617, %507 : i64, !llvm.ptr
            cf.br ^bb148
          ^bb147:
            cf.br ^bb148
          ^bb148:
          cf.br ^bb145
        ^bb144:
          cf.br ^bb145
        ^bb145:
        %618 = llvm.load %598 : !llvm.ptr -> i64
        %619 = arith.constant 1 : i32
        %621 = arith.extsi %619 : i32 to i64
        %620 = arith.addi %618, %621 : i64
        llvm.store %620, %598 : i64, !llvm.ptr
        cf.br ^bb140
      ^bb142:
      %622 = llvm.load %566 : !llvm.ptr -> i64
      %623 = arith.constant 1 : i32
      %625 = arith.extsi %623 : i32 to i64
      %624 = arith.addi %622, %625 : i64
      llvm.store %624, %566 : i64, !llvm.ptr
      cf.br ^bb131
    ^bb133:
    %627 = arith.constant 3 : i32
    %626 = func.call @iroot(%305, %627) : (i64, i32) -> i64
    %629 = llvm.load %383 : !llvm.ptr -> i64
    %628 = func.call @bisect_right(%374, %629, %626) : (!llvm.ptr, i64, i64) -> i64
    %630 = arith.constant 0 : i32
    %631 = arith.extsi %630 : i32 to i64
    llvm.store %631, %566 : i64, !llvm.ptr
    cf.br ^bb149
    ^bb149:
    %632 = llvm.load %566 : !llvm.ptr -> i64
    %633 = arith.cmpi slt, %632, %628 : i64
    cf.cond_br %633, ^bb150, ^bb151
    ^bb150:
      %635 = llvm.load %566 : !llvm.ptr -> i64
      %636 = llvm.getelementptr %374[%635] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %634 = llvm.load %636 : !llvm.ptr -> i64
      %637 = arith.muli %634, %634 : i64
      %638 = arith.muli %637, %634 : i64
      %639 = arith.cmpi sgt, %638, %305 : i64
      cf.cond_br %639, ^bb152, ^bb153
      ^bb152:
        cf.br ^bb151
      ^bb153:
        cf.br ^bb154
      ^bb154:
      %641 = arith.divsi %305, %638 : i64
      %640 = func.call @isqrt(%641) : (i64) -> i64
      %643 = llvm.load %383 : !llvm.ptr -> i64
      %642 = func.call @bisect_right(%374, %643, %640) : (!llvm.ptr, i64, i64) -> i64
      %644 = arith.constant 0 : i32
      %645 = arith.extsi %644 : i32 to i64
      %646 = llvm.mlir.constant(1 : i64) : i64
      %647 = llvm.alloca %646 x i64 : (i64) -> !llvm.ptr
      llvm.store %645, %647 : i64, !llvm.ptr
      cf.br ^bb155
      ^bb155:
      %648 = llvm.load %647 : !llvm.ptr -> i64
      %649 = arith.cmpi slt, %648, %642 : i64
      cf.cond_br %649, ^bb156, ^bb157
      ^bb156:
        %651 = llvm.load %647 : !llvm.ptr -> i64
        %652 = llvm.getelementptr %374[%651] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %650 = llvm.load %652 : !llvm.ptr -> i64
        %653 = arith.cmpi ne, %650, %634 : i64
        cf.cond_br %653, ^bb158, ^bb159
        ^bb158:
          %654 = arith.muli %638, %650 : i64
          %655 = arith.muli %654, %650 : i64
          %656 = arith.cmpi sle, %655, %305 : i64
          cf.cond_br %656, ^bb161, ^bb162
          ^bb161:
            %657 = arith.divsi %305, %655 : i64
            %659 = llvm.load %383 : !llvm.ptr -> i64
            %658 = func.call @bisect_right(%374, %659, %657) : (!llvm.ptr, i64, i64) -> i64
            %660 = arith.constant 0 : i32
            %661 = arith.extsi %660 : i32 to i64
            %662 = llvm.mlir.constant(1 : i64) : i64
            %663 = llvm.alloca %662 x i64 : (i64) -> !llvm.ptr
            llvm.store %661, %663 : i64, !llvm.ptr
            cf.br ^bb164
            ^bb164:
            %664 = llvm.load %663 : !llvm.ptr -> i64
            %665 = arith.cmpi slt, %664, %658 : i64
            cf.cond_br %665, ^bb165, ^bb166
            ^bb165:
              %667 = llvm.load %663 : !llvm.ptr -> i64
              %668 = llvm.getelementptr %374[%667] : (!llvm.ptr, i64) -> !llvm.ptr, i64
              %666 = llvm.load %668 : !llvm.ptr -> i64
              %669 = arith.cmpi ne, %666, %634 : i64
              %670 = scf.if %669 -> (i1) {
                %671 = arith.cmpi ne, %666, %650 : i64
                scf.yield %671 : i1
              } else {
                %672 = arith.constant false
                scf.yield %672 : i1
              }
              cf.cond_br %670, ^bb167, ^bb168
              ^bb167:
                %673 = arith.muli %655, %666 : i64
                %674 = arith.divsi %305, %673 : i64
                %675 = arith.cmpi sgt, %674, %419 : i64
                %676 = scf.if %675 -> (i64) {
                  scf.yield %419 : i64
                } else {
                  scf.yield %674 : i64
                }
                %677 = llvm.load %507 : !llvm.ptr -> i64
                %679 = llvm.getelementptr %427[%676] : (!llvm.ptr, i64) -> !llvm.ptr, i64
                %678 = llvm.load %679 : !llvm.ptr -> i64
                %680 = arith.muli %673, %678 : i64
                %681 = arith.addi %677, %680 : i64
                llvm.store %681, %507 : i64, !llvm.ptr
                cf.br ^bb169
              ^bb168:
                cf.br ^bb169
              ^bb169:
              %682 = llvm.load %663 : !llvm.ptr -> i64
              %683 = arith.constant 1 : i32
              %685 = arith.extsi %683 : i32 to i64
              %684 = arith.addi %682, %685 : i64
              llvm.store %684, %663 : i64, !llvm.ptr
              cf.br ^bb164
            ^bb166:
            cf.br ^bb163
          ^bb162:
            cf.br ^bb163
          ^bb163:
          cf.br ^bb160
        ^bb159:
          cf.br ^bb160
        ^bb160:
        %686 = llvm.load %647 : !llvm.ptr -> i64
        %687 = arith.constant 1 : i32
        %689 = arith.extsi %687 : i32 to i64
        %688 = arith.addi %686, %689 : i64
        llvm.store %688, %647 : i64, !llvm.ptr
        cf.br ^bb155
      ^bb157:
      %690 = llvm.load %566 : !llvm.ptr -> i64
      %691 = arith.constant 1 : i32
      %693 = arith.extsi %691 : i32 to i64
      %692 = arith.addi %690, %693 : i64
      llvm.store %692, %566 : i64, !llvm.ptr
      cf.br ^bb149
    ^bb151:
    %694 = llvm.mlir.addressof @str_0 : !llvm.ptr
    %695 = llvm.load %507 : !llvm.ptr -> i64
    %696 = llvm.call @printf(%694, %695) vararg(!llvm.func<i32 (ptr, ...)>) : (!llvm.ptr, i64) -> i32
    func.call @free(%311) : (!llvm.ptr) -> ()
    func.call @free(%374) : (!llvm.ptr) -> ()
    func.call @free(%421) : (!llvm.ptr) -> ()
    func.call @free(%427) : (!llvm.ptr) -> ()
    %701 = arith.constant 0 : i32
    func.return %701 : i32
  }
}