Problem 652

Distinct Values of a Proto-logarithmic Function: D(10^18) last 9 digits. Uses Mobius inversion, totient prefix sums, and primitive base counting.

Answer983924497
Output983924497
StatusPASS
Native helperno
Runtime0 ms
Peak memory1072 KB
Time complexityO(n^2) (estimated)
Space complexityO(n^2) (estimated)

Performance comparison

MetricOur solutionBest known
Time complexityO(n^2)O(n)
Space complexityO(n^2)O(n)
ApproachFlow solutionBig-integer arithmetic
VerdictSuboptimal

Flow source

# Project Euler 652
# Distinct Values of a Proto-logarithmic Function: D(10^18) last 9 digits.
# Uses Mobius inversion, totient prefix sums, and primitive base counting.

import euler.nt { gcd, isqrt }

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

const MOD: i64 = 1000000000

# Integer k-th root: floor(n^(1/k))
function kth_root(n: i64, k: i64) -> i64 {
    if k <= 1 { return n }
    if n < 2 { return n }
    # Upper bound: 2^(ceil(bitlen/k))
    let mut bits: i64 = 0
    let mut tmp: i64 = n
    while tmp > 0 { bits = bits + 1; tmp = tmp / 2 }
    let mut high: i64 = 1
    let mut bh: i64 = (bits + k - 1) / k
    while bh > 0 { high = high * 2; bh = bh - 1 }
    let mut low: i64 = 1
    while low + 1 < high {
        let mid: i64 = (low + high) / 2
        # Compute mid^k with overflow check using i128
        let mut p: i128 = 1
        let mut kk: i64 = k
        while kk > 0 {
            p = p * (mid as i128)
            kk = kk - 1
        }
        if p <= (n as i128) { low = mid }
        else { high = mid }
    }
    return low
}

# Count integers u with 2 <= u <= x that are NOT perfect powers.
function primitive_count(x: i64, mu: ptr<i64>) -> i64 {
    if x < 2 { return 0 }
    let mut K: i64 = 0
    let mut tmp: i64 = x
    while tmp > 1 { K = K + 1; tmp = tmp / 2 }
    let mut s: i128 = 0
    for d in 1..(K + 1) {
        let md: i64 = mu[d]
        if md == 0 { continue }
        s = s + (md as i128) * ((kth_root(x, d) - 1) as i128)
    }
    return s as i64
}

function main() -> i32 {
    let N: i64 = 1000000000000000000

    # L = floor(log2(N))
    let mut L: i64 = 0
    let mut tmp: i64 = N
    while tmp > 1 { L = L + 1; tmp = tmp / 2 }

    # Mobius sieve up to L
    let mu: ptr<i64> = calloc(L + 2, 8)
    let primes: ptr<i64> = calloc(L + 10, 8)
    let is_comp: ptr<i8> = calloc(L + 2, 1)
    let mut npc: i64 = 0
    mu[1] = 1
    for i in 2..(L + 2) {
        if is_comp[i] == 0 {
            primes[npc] = i
            npc = npc + 1
            mu[i] = -1
        }
        for j in 0..npc {
            let p: i64 = primes[j]
            let v: i64 = i * p
            if v > L + 1 { break }
            is_comp[v] = 1
            if i % p == 0 { mu[v] = 0; break }
            mu[v] = -mu[i]
        }
    }

    # Totient prefix sums up to L
    let phi: ptr<i64> = calloc(L + 2, 8)
    for i in 0..(L + 2) { phi[i] = i }
    for i in 2..(L + 2) {
        if phi[i] == i {
            let mut j: i64 = i
            while j <= L + 1 {
                phi[j] = phi[j] - phi[j] / i
                j = j + i
            }
        }
    }
    let mut phisum: i64 = 0
    for i in 1..(L + 1) {
        phisum = phisum + phi[i]
    }

    # Distinct rational values: 2 * phisum[L] - 1
    let rational: i64 = 2 * phisum - 1

    # Precompute floor(N^(1/e)) for e=1..L+1
    let rootN: ptr<i64> = calloc(L + 2, 8)
    for e in 1..(L + 2) {
        rootN[e] = kth_root(N, e)
    }

    # P[e] = primitive_count(rootN[e])
    let P: ptr<i64> = calloc(L + 2, 8)
    for e in 1..(L + 2) {
        P[e] = primitive_count(rootN[e], mu)
    }

    # count[e] = P[e] for e=1..L
    let count: ptr<i64> = calloc(L + 1, 8)
    for e in 1..(L + 1) {
        count[e] = P[e]
    }

    # T = total ordered primitive pairs with gcd(exp(m),exp(n)) = 1
    let mut T: i128 = 0
    for e in 1..(L + 1) {
        let ce: i64 = count[e]
        if ce == 0 { continue }
        for f in 1..(L + 1) {
            if gcd(e, f) == 1 {
                T = (T + (ce as i128) * (count[f] as i128)) % (MOD as i128)
            }
        }
    }

    # S = pairs where m,n share same primitive root, gcd(exponents)=1
    let mut S: i128 = 0
    for k in 1..(L + 1) {
        let num_roots: i64 = P[k] - P[k + 1]
        # coprime_pairs_upto_k = 2 * phisum[k] - 1
        let mut ps: i64 = 0
        for i in 1..(k + 1) { ps = ps + phi[i] }
        let coprime_pairs: i64 = 2 * ps - 1
        S = (S + (num_roots as i128) * (coprime_pairs as i128)) % (MOD as i128)
    }

    let irrational: i128 = ((T - S) % (MOD as i128) + (MOD as i128)) % (MOD as i128)
    let ans: i64 = ((rational as i128 + irrational) % (MOD as i128)) as i64
    printf("%09lld\n", ans)

    free(count)
    free(P)
    free(rootN)
    free(phi)
    free(is_comp)
    free(primes)
    free(mu)
    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 kth_root_i64_i64(int64_t n, int64_t k);
int64_t primitive_count_i64_ptr_i64(int64_t x, int64_t* mu);
int32_t main(void);

static const int64_t MOD = 1000000000;

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 kth_root_i64_i64(int64_t n, int64_t k) {
    if (k <= 1) {
        return n;
    }
    if (n < 2) {
        return n;
    }
    int64_t bits = 0;
    int64_t tmp = n;
    while (tmp > 0) {
        bits = (bits + 1);
        tmp = FLOW_CHECKED_DIV((tmp), (2));
    }
    int64_t high = 1;
    int64_t bh = FLOW_CHECKED_DIV((((bits + k) - 1)), (k));
    while (bh > 0) {
        high = (high * 2);
        bh = (bh - 1);
    }
    int64_t low = 1;
    while ((low + 1) < high) {
        int64_t mid = FLOW_CHECKED_DIV(((low + high)), (2));
        __int128 p = 1;
        int64_t kk = k;
        while (kk > 0) {
            p = (p * ((__int128)(mid)));
            kk = (kk - 1);
        }
        if (p <= ((__int128)(n))) {
            low = mid;
        } else {
            high = mid;
        }
    }
    return low;
}

int64_t primitive_count_i64_ptr_i64(int64_t x, int64_t* mu) {
    if (x < 2) {
        return 0;
    }
    int64_t K = 0;
    int64_t tmp = x;
    while (tmp > 1) {
        K = (K + 1);
        tmp = FLOW_CHECKED_DIV((tmp), (2));
    }
    __int128 s = 0;
    int32_t __flow_step_1 = 1;
    for (int32_t d = 1; (1 <= (K + 1)) ? d < (K + 1) : d > (K + 1); d += (1 <= (K + 1)) ? 1 : -1) {
        int64_t md = mu[d];
        if (md == 0) {
            continue;
        }
        s = (s + (((__int128)(md)) * ((__int128)((kth_root_i64_i64(x, d) - 1)))));
    }
    return ((int64_t)(s));
}

int32_t main(void) {
    int64_t N = 1000000000000000000;
    int64_t L = 0;
    int64_t tmp = N;
    while (tmp > 1) {
        L = (L + 1);
        tmp = FLOW_CHECKED_DIV((tmp), (2));
    }
    int64_t* mu = (int64_t*)(calloc((L + 2), 8));
    int64_t* primes = (int64_t*)(calloc((L + 10), 8));
    int8_t* is_comp = (int8_t*)(calloc((L + 2), 1));
    int64_t npc = 0;
    mu[1] = 1;
    int32_t __flow_step_2 = 1;
    for (int32_t i = 2; (2 <= (L + 2)) ? i < (L + 2) : i > (L + 2); i += (2 <= (L + 2)) ? 1 : -1) {
        if (is_comp[i] == 0) {
            primes[npc] = i;
            npc = (npc + 1);
            mu[i] = (-1);
        }
        int32_t __flow_step_3 = 1;
        for (int32_t j = 0; (0 <= npc) ? j < npc : j > npc; j += (0 <= npc) ? 1 : -1) {
            int64_t p = primes[j];
            int64_t v = (i * p);
            if (v > (L + 1)) {
                break;
            }
            is_comp[v] = 1;
            if (FLOW_CHECKED_MOD((i), (p)) == 0) {
                mu[v] = 0;
                break;
            }
            mu[v] = (-mu[i]);
        }
    }
    int64_t* phi = (int64_t*)(calloc((L + 2), 8));
    int32_t __flow_step_4 = 1;
    for (int32_t i = 0; (0 <= (L + 2)) ? i < (L + 2) : i > (L + 2); i += (0 <= (L + 2)) ? 1 : -1) {
        phi[i] = i;
    }
    int32_t __flow_step_5 = 1;
    for (int32_t i = 2; (2 <= (L + 2)) ? i < (L + 2) : i > (L + 2); i += (2 <= (L + 2)) ? 1 : -1) {
        if (phi[i] == i) {
            int64_t j = i;
            while (j <= (L + 1)) {
                phi[j] = (phi[j] - FLOW_CHECKED_DIV((phi[j]), (i)));
                j = (j + i);
            }
        }
    }
    int64_t phisum = 0;
    int32_t __flow_step_6 = 1;
    for (int32_t i = 1; (1 <= (L + 1)) ? i < (L + 1) : i > (L + 1); i += (1 <= (L + 1)) ? 1 : -1) {
        phisum = (phisum + phi[i]);
    }
    int64_t rational = ((2 * phisum) - 1);
    int64_t* rootN = (int64_t*)(calloc((L + 2), 8));
    int32_t __flow_step_7 = 1;
    for (int32_t e = 1; (1 <= (L + 2)) ? e < (L + 2) : e > (L + 2); e += (1 <= (L + 2)) ? 1 : -1) {
        rootN[e] = kth_root_i64_i64(N, e);
    }
    int64_t* P = (int64_t*)(calloc((L + 2), 8));
    int32_t __flow_step_8 = 1;
    for (int32_t e = 1; (1 <= (L + 2)) ? e < (L + 2) : e > (L + 2); e += (1 <= (L + 2)) ? 1 : -1) {
        P[e] = primitive_count_i64_ptr_i64(rootN[e], mu);
    }
    int64_t* count = (int64_t*)(calloc((L + 1), 8));
    int32_t __flow_step_9 = 1;
    for (int32_t e = 1; (1 <= (L + 1)) ? e < (L + 1) : e > (L + 1); e += (1 <= (L + 1)) ? 1 : -1) {
        count[e] = P[e];
    }
    __int128 T = 0;
    int32_t __flow_step_10 = 1;
    for (int32_t e = 1; (1 <= (L + 1)) ? e < (L + 1) : e > (L + 1); e += (1 <= (L + 1)) ? 1 : -1) {
        int64_t ce = count[e];
        if (ce == 0) {
            continue;
        }
        int32_t __flow_step_11 = 1;
        for (int32_t f = 1; (1 <= (L + 1)) ? f < (L + 1) : f > (L + 1); f += (1 <= (L + 1)) ? 1 : -1) {
            if (gcd_i64_i64(e, f) == 1) {
                T = FLOW_CHECKED_MOD(((T + (((__int128)(ce)) * ((__int128)(count[f]))))), (((__int128)(MOD))));
            }
        }
    }
    __int128 S = 0;
    int32_t __flow_step_12 = 1;
    for (int32_t k = 1; (1 <= (L + 1)) ? k < (L + 1) : k > (L + 1); k += (1 <= (L + 1)) ? 1 : -1) {
        int64_t num_roots = (P[k] - P[(k + 1)]);
        int64_t ps = 0;
        int32_t __flow_step_13 = 1;
        for (int32_t i = 1; (1 <= (k + 1)) ? i < (k + 1) : i > (k + 1); i += (1 <= (k + 1)) ? 1 : -1) {
            ps = (ps + phi[i]);
        }
        int64_t coprime_pairs = ((2 * ps) - 1);
        S = FLOW_CHECKED_MOD(((S + (((__int128)(num_roots)) * ((__int128)(coprime_pairs))))), (((__int128)(MOD))));
    }
    __int128 irrational = FLOW_CHECKED_MOD(((FLOW_CHECKED_MOD(((T - S)), (((__int128)(MOD)))) + ((__int128)(MOD)))), (((__int128)(MOD))));
    int64_t ans = ((int64_t)(FLOW_CHECKED_MOD(((((__int128)(rational)) + irrational)), (((__int128)(MOD))))));
    printf("%09lld\n", ans);
    free(count);
    free(P);
    free(rootN);
    free(phi);
    free(is_comp);
    free(primes);
    free(mu);
    return 0;
}

Generated MLIR

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