Problem 282

Sum A(n,n) for n=0..6 mod 14^8.

Answer1098988351
Output1098988351
StatusPASS
Native helperno
Runtime0 ms
Peak memory1072 KB
Time complexityO(n) (estimated)
Space complexityO(1) (estimated)

Performance comparison

MetricOur solutionBest known
Time complexityO(n)O(n * a)
Space complexityO(1)O(n)
ApproachFlow solutionModular Ackermann computation
VerdictUnknown

Flow source

# Project Euler 282
# Sum A(n,n) for n=0..6 mod 14^8.

import euler.nt { gcd }

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

function local_mod_pow(base0: i64, exp0: i64, mod: i64) -> i64 {
    if mod == 1 { return 0 }
    let mut result: i64 = 1
    let mut base: i64 = base0 % mod
    let mut exp: i64 = exp0
    while exp > 0 {
        if exp % 2 == 1 { result = (result * base) % mod }
        base = (base * base) % mod
        exp = exp / 2
    }
    return result
}

function local_mulmod(a0: i64, b0: i64, mod: i64) -> i64 {
    let mut a: i64 = a0 % mod
    let mut b: i64 = b0 % mod
    if a < 0 { a = a + mod }
    if b < 0 { b = b + mod }
    let mut result: i64 = 0
    while b > 0 {
        if b % 2 == 1 {
            result = result + a
            if result >= mod { result = result - mod }
        }
        a = a + a
        if a >= mod { a = a - mod }
        b = b / 2
    }
    return result
}

function mod_inverse(a0: i64, m: i64) -> i64 {
    let mut a: i64 = a0 % m
    let mut b: i64 = m
    let mut x0: i64 = 1
    let mut x1: i64 = 0
    while b != 0 {
        let q: i64 = a / b
        let t: i64 = a % b
        a = b
        b = t
        let tx: i64 = x0 - q * x1
        x0 = x1
        x1 = tx
    }
    if x0 < 0 { x0 = x0 + m }
    return x0
}

function carmichael(n0: i64) -> i64 {
    if n0 == 1 { return 1 }
    let mut n: i64 = n0
    let mut lam: i64 = 1
    let mut p: i64 = 2
    while p * p <= n {
        if n % p == 0 {
            let mut k: i64 = 0
            let mut pk: i64 = 1
            while n % p == 0 {
                n = n / p
                k = k + 1
                pk = pk * p
            }
            let mut pk_lam: i64 = 0
            if p == 2 {
                if k == 1 { pk_lam = 1 }
                elif k == 2 { pk_lam = 2 }
                else {
                    let mut t: i64 = 1
                    let mut i: i64 = 0
                    while i < k - 2 {
                        t = t * 2
                        i = i + 1
                    }
                    pk_lam = t
                }
            } else {
                pk_lam = (p - 1) * (pk / p)
            }
            # lcm
            lam = lam / gcd(lam, pk_lam) * pk_lam
        }
        if p == 2 { p = 3 } else { p = p + 2 }
    }
    if n > 1 {
        let pk_lam2: i64 = n - 1
        lam = lam / gcd(lam, pk_lam2) * pk_lam2
    }
    return lam
}

function crt_pair(a1: i64, m1: i64, a2: i64, m2: i64) -> i64 {
    let inv: i64 = mod_inverse(m1 % m2, m2)
    let k: i64 = local_mulmod(((a2 - a1) % m2 + m2) % m2, inv, m2)
    return (a1 + local_mulmod(k, m1, m1 * m2)) % (m1 * m2)
}

function tower_geq(h: i64, limit: i64) -> bool {
    if limit <= 1 { return true }
    let mut v: i64 = 2
    if h == 1 { return v >= limit }
    let mut i: i64 = 2
    while i <= h {
        if v >= 60 { return true }
        # 2^v
        if v >= 63 { return true }
        let one: i64 = 1
        v = one << v
        if v >= limit { return true }
        i = i + 1
    }
    return v >= limit
}

function tetration_exact(h: i64) -> i64 {
    let mut v: i64 = 2
    let mut i: i64 = 2
    while i <= h {
        let one: i64 = 1
        v = one << v
        i = i + 1
    }
    return v
}

# Memo for tetration_mod: height up to 60, few mods — use recursive without cache (small depth)
function tetration_mod(height: i64, mod: i64) -> i64 {
    if mod == 1 { return 0 }
    if height == 1 { return 2 % mod }
    let mut m: i64 = mod
    let mut k: i64 = 0
    while m % 2 == 0 {
        k = k + 1
        m = m / 2
    }
    let mut r2: i64 = 0
    if k > 0 {
        let one: i64 = 1
        let mod2: i64 = one << k
        if tower_geq(height - 1, k) {
            r2 = 0
        } else {
            let exp: i64 = tetration_exact(height - 1)
            if exp >= k { r2 = 0 }
            else { r2 = (one << exp) % mod2 }
        }
        if m == 1 { return r2 }
    }
    let lam: i64 = carmichael(m)
    let exp2: i64 = tetration_mod(height - 1, lam)
    let rodd: i64 = local_mod_pow(2, exp2, m)
    if k == 0 { return rodd }
    let one2: i64 = 1
    return crt_pair(r2, one2 << k, rodd, m)
}

function main() -> i32 {
    let mut mod: i64 = 1
    let mut i: i64 = 0
    while i < 8 {
        mod = mod * 14
        i = i + 1
    }
    let a0: i64 = 1 % mod
    let a1: i64 = 3 % mod
    let a2: i64 = 7 % mod
    let a3: i64 = 61 % mod
    let a4: i64 = (tetration_mod(7, mod) - 3) % mod
    if a4 < 0 { a4 = a4 + mod }

    # find fixed point of tetration
    let mut prev: i64 = tetration_mod(1, mod)
    let mut fixed_h: i64 = 1
    let mut h: i64 = 2
    while h <= 60 {
        let cur: i64 = tetration_mod(h, mod)
        if cur == prev {
            fixed_h = h - 1
            break
        }
        prev = cur
        h = h + 1
    }
    let fixed_val: i64 = (tetration_mod(fixed_h, mod) - 3) % mod
    if fixed_val < 0 { fixed_val = fixed_val + mod }
    let a5: i64 = fixed_val
    let a6: i64 = fixed_val
    let ans: i64 = (a0 + a1 + a2 + a3 + a4 + a5 + a6) % mod
    printf("%lld\n", ans)
    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 local_mod_pow_i64_i64_i64(int64_t base0, int64_t exp0, int64_t mod);
int64_t local_mulmod_i64_i64_i64(int64_t a0, int64_t b0, int64_t mod);
int64_t mod_inverse_i64_i64(int64_t a0, int64_t m);
int64_t carmichael_i64(int64_t n0);
int64_t crt_pair_i64_i64_i64_i64(int64_t a1, int64_t m1, int64_t a2, int64_t m2);
bool tower_geq_i64_i64(int64_t h, int64_t limit);
int64_t tetration_exact_i64(int64_t h);
int64_t tetration_mod_i64_i64(int64_t height, int64_t mod);
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 local_mod_pow_i64_i64_i64(int64_t base0, int64_t exp0, int64_t mod) {
    if (mod == 1) {
        return 0;
    }
    int64_t result = 1;
    int64_t base = FLOW_CHECKED_MOD((base0), (mod));
    int64_t exp = exp0;
    while (exp > 0) {
        if (FLOW_CHECKED_MOD((exp), (2)) == 1) {
            result = FLOW_CHECKED_MOD(((result * base)), (mod));
        }
        base = FLOW_CHECKED_MOD(((base * base)), (mod));
        exp = FLOW_CHECKED_DIV((exp), (2));
    }
    return result;
}

int64_t local_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));
    if (a < 0) {
        a = (a + mod);
    }
    if (b < 0) {
        b = (b + mod);
    }
    int64_t result = 0;
    while (b > 0) {
        if (FLOW_CHECKED_MOD((b), (2)) == 1) {
            result = (result + a);
            if (result >= mod) {
                result = (result - mod);
            }
        }
        a = (a + a);
        if (a >= mod) {
            a = (a - mod);
        }
        b = FLOW_CHECKED_DIV((b), (2));
    }
    return result;
}

int64_t mod_inverse_i64_i64(int64_t a0, int64_t m) {
    int64_t a = FLOW_CHECKED_MOD((a0), (m));
    int64_t b = m;
    int64_t x0 = 1;
    int64_t x1 = 0;
    while (b != 0) {
        int64_t q = FLOW_CHECKED_DIV((a), (b));
        int64_t t = FLOW_CHECKED_MOD((a), (b));
        a = b;
        b = t;
        int64_t tx = (x0 - (q * x1));
        x0 = x1;
        x1 = tx;
    }
    if (x0 < 0) {
        x0 = (x0 + m);
    }
    return x0;
}

int64_t carmichael_i64(int64_t n0) {
    if (n0 == 1) {
        return 1;
    }
    int64_t n = n0;
    int64_t lam = 1;
    int64_t p = 2;
    while ((p * p) <= n) {
        if (FLOW_CHECKED_MOD((n), (p)) == 0) {
            int64_t k = 0;
            int64_t pk = 1;
            while (FLOW_CHECKED_MOD((n), (p)) == 0) {
                n = FLOW_CHECKED_DIV((n), (p));
                k = (k + 1);
                pk = (pk * p);
            }
            int64_t pk_lam = 0;
            if (p == 2) {
                if (k == 1) {
                    pk_lam = 1;
                } else if (k == 2) {
                    pk_lam = 2;
                } else {
                    int64_t t = 1;
                    int64_t i = 0;
                    while (i < (k - 2)) {
                        t = (t * 2);
                        i = (i + 1);
                    }
                    pk_lam = t;
                }
            } else {
                pk_lam = ((p - 1) * FLOW_CHECKED_DIV((pk), (p)));
            }
            lam = (FLOW_CHECKED_DIV((lam), (gcd_i64_i64(lam, pk_lam))) * pk_lam);
        }
        if (p == 2) {
            p = 3;
        } else {
            p = (p + 2);
        }
    }
    if (n > 1) {
        int64_t pk_lam2 = (n - 1);
        lam = (FLOW_CHECKED_DIV((lam), (gcd_i64_i64(lam, pk_lam2))) * pk_lam2);
    }
    return lam;
}

int64_t crt_pair_i64_i64_i64_i64(int64_t a1, int64_t m1, int64_t a2, int64_t m2) {
    int64_t inv = mod_inverse_i64_i64(FLOW_CHECKED_MOD((m1), (m2)), m2);
    int64_t k = local_mulmod_i64_i64_i64(FLOW_CHECKED_MOD(((FLOW_CHECKED_MOD(((a2 - a1)), (m2)) + m2)), (m2)), inv, m2);
    return FLOW_CHECKED_MOD(((a1 + local_mulmod_i64_i64_i64(k, m1, (m1 * m2)))), ((m1 * m2)));
}

bool tower_geq_i64_i64(int64_t h, int64_t limit) {
    if (limit <= 1) {
        return 1;
    }
    int64_t v = 2;
    if (h == 1) {
        return v >= limit;
    }
    int64_t i = 2;
    while (i <= h) {
        if (v >= 60) {
            return 1;
        }
        if (v >= 63) {
            return 1;
        }
        int64_t one = 1;
        v = FLOW_CHECKED_SHL((one), (v));
        if (v >= limit) {
            return 1;
        }
        i = (i + 1);
    }
    return v >= limit;
}

int64_t tetration_exact_i64(int64_t h) {
    int64_t v = 2;
    int64_t i = 2;
    while (i <= h) {
        int64_t one = 1;
        v = FLOW_CHECKED_SHL((one), (v));
        i = (i + 1);
    }
    return v;
}

int64_t tetration_mod_i64_i64(int64_t height, int64_t mod) {
    if (mod == 1) {
        return 0;
    }
    if (height == 1) {
        return FLOW_CHECKED_MOD((2), (mod));
    }
    int64_t m = mod;
    int64_t k = 0;
    while (FLOW_CHECKED_MOD((m), (2)) == 0) {
        k = (k + 1);
        m = FLOW_CHECKED_DIV((m), (2));
    }
    int64_t r2 = 0;
    if (k > 0) {
        int64_t one = 1;
        int64_t mod2 = FLOW_CHECKED_SHL((one), (k));
        if (tower_geq_i64_i64((height - 1), k)) {
            r2 = 0;
        } else {
            int64_t exp = tetration_exact_i64((height - 1));
            if (exp >= k) {
                r2 = 0;
            } else {
                r2 = FLOW_CHECKED_MOD((FLOW_CHECKED_SHL((one), (exp))), (mod2));
            }
        }
        if (m == 1) {
            return r2;
        }
    }
    int64_t lam = carmichael_i64(m);
    int64_t exp2 = tetration_mod_i64_i64((height - 1), lam);
    int64_t rodd = local_mod_pow_i64_i64_i64(2, exp2, m);
    if (k == 0) {
        return rodd;
    }
    int64_t one2 = 1;
    return crt_pair_i64_i64_i64_i64(r2, FLOW_CHECKED_SHL((one2), (k)), rodd, m);
}

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