Problem 520

Simbers — sum Q(2^u) for u=1..39 mod 1000000123.

Answer238413705
Output238413705
StatusPASS
Native helperno
Runtime0 ms
Peak memory1088 KB
Time complexityO(n) (estimated)
Space complexityO(n^2) (estimated)

Performance comparison

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

Flow source

# Project Euler 520
# Simbers — sum Q(2^u) for u=1..39 mod 1000000123.

const MOD: i64 = 1000000123
const NTERMS: i64 = 21

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

function egcd(a0: i64, b0: i64, x: ptr<i64>, y: ptr<i64>) -> i64 {
    let mut a: i64 = a0
    let mut b: i64 = b0
    let mut x1: i64 = 1
    let mut y1: i64 = 0
    let mut x2: i64 = 0
    let mut y2: i64 = 1
    while b != 0 {
        let q: i64 = a / b
        let tx: i64 = x1 - q * x2
        let ty: i64 = y1 - q * y2
        x1 = x2
        y1 = y2
        x2 = tx
        y2 = ty
        let ta: i64 = a
        a = b
        b = ta % b
    }
    x[0] = x1
    y[0] = y1
    return a
}

function inv_mod(a0: i64) -> i64 {
    let mut a: i64 = a0 % MOD
    if a < 0 { a = a + MOD }
    let xy: ptr<i64> = calloc(2, 8)
    if xy == null { return 0 }
    let g: i64 = egcd(a, MOD, xy, xy + 1)
    let res: i64 = xy[0] % MOD
    free(xy)
    if res < 0 { return res + MOD }
    return res
}

function modpow(base0: i64, exp0: i64) -> i64 {
    let mut r: i64 = 1
    let mut b: i64 = base0 % MOD
    if b < 0 { b = b + MOD }
    let mut e: i64 = exp0
    while e > 0 {
        if (e & 1) != 0 {
            r = ((r as i128) * (b as i128) % (MOD as i128)) as i64
        }
        b = ((b as i128) * (b as i128) % (MOD as i128)) as i64
        e = e >> 1
    }
    return r
}

function t_mod(exp: i64) -> i64 {
    let mut t: i64 = exp % MOD
    if t < 0 { t = t + MOD }
    return t
}

function geom_start1(exp: i64, n: i64) -> i64 {
    if n <= 0 { return 0 }
    let tm: i64 = t_mod(exp)
    if tm == 1 { return n % MOD }
    if tm == 0 { return 0 }
    let num: i64 = (modpow(tm, n + 1) - tm + MOD) % MOD
    return ((num as i128) * (inv_mod((tm - 1 + MOD) % MOD) as i128) % (MOD as i128)) as i64
}

function geom_start0(exp: i64, n: i64) -> i64 {
    if n <= 0 { return 0 }
    let tm: i64 = t_mod(exp)
    if tm == 1 { return n % MOD }
    let num: i64 = (modpow(tm, n) - 1 + MOD) % MOD
    return ((num as i128) * (inv_mod((tm - 1 + MOD) % MOD) as i128) % (MOD as i128)) as i64
}

function ipow2(u: i64) -> i64 {
    let mut r: i64 = 1
    let mut e: i64 = u
    while e > 0 {
        r = r * 2
        e = e - 1
    }
    return r
}

function Q(n: i64, f_exp: ptr<i64>, f_coef: ptr<i64>, g_exp: ptr<i64>, g_coef: ptr<i64>) -> i64 {
    let mut sum_a: i64 = 0
    let mut i: i64 = 0
    while i < NTERMS {
        if f_coef[i] != 0 {
            sum_a = (sum_a + ((f_coef[i] as i128) * (geom_start1(f_exp[i], n) as i128) % (MOD as i128)) as i64) % MOD
        }
        i = i + 1
    }
    let mut sum_c: i64 = 0
    i = 0
    while i < NTERMS {
        if g_coef[i] != 0 {
            sum_c = (sum_c + ((g_coef[i] as i128) * (geom_start0(g_exp[i], n) as i128) % (MOD as i128)) as i64) % MOD
        }
        i = i + 1
    }
    return (sum_a - sum_c + MOD) % MOD
}

function main() -> i32 {
    let f_exp: ptr<i64> = calloc(NTERMS, 8)
    let f_coef: ptr<i64> = calloc(NTERMS, 8)
    let g_exp: ptr<i64> = calloc(NTERMS, 8)
    let g_coef: ptr<i64> = calloc(NTERMS, 8)
    if f_exp == null || f_coef == null || g_exp == null || g_coef == null { return 1 }

    # F = cosh(x)^5 * (1+sinh(x))^5
    f_exp[0] = -10; f_coef[0] = 174804709
    f_exp[1] = -9; f_coef[1] = 251953156
    f_exp[2] = -8; f_coef[2] = 992187622
    f_exp[3] = -7; f_coef[3] = 267578158
    f_exp[4] = -6; f_coef[4] = 94726574
    f_exp[5] = -5; f_coef[5] = 445312555
    f_exp[6] = -4; f_coef[6] = 953125117
    f_exp[7] = -3; f_coef[7] = 39062505
    f_exp[8] = -2; f_coef[8] = 716796963
    f_exp[9] = -1; f_coef[9] = 496093811
    f_exp[10] = 0; f_coef[10] = 0
    f_exp[11] = 1; f_coef[11] = 496093811
    f_exp[12] = 2; f_coef[12] = 283203160
    f_exp[13] = 3; f_coef[13] = 39062505
    f_exp[14] = 4; f_coef[14] = 46875006
    f_exp[15] = 5; f_coef[15] = 445312555
    f_exp[16] = 6; f_coef[16] = 905273549
    f_exp[17] = 7; f_coef[17] = 267578158
    f_exp[18] = 8; f_coef[18] = 7812501
    f_exp[19] = 9; f_coef[19] = 251953156
    f_exp[20] = 10; f_coef[20] = 825195414

    g_exp[0] = -10; g_coef[0] = 825195414
    g_exp[1] = -9; g_coef[1] = 748046967
    g_exp[2] = -8; g_coef[2] = 357421919
    g_exp[3] = -7; g_coef[3] = 236328154
    g_exp[4] = -6; g_coef[4] = 540039129
    g_exp[5] = -5; g_coef[5] = 585937572
    g_exp[6] = -4; g_coef[6] = 601562574
    g_exp[7] = -3; g_coef[7] = 820312601
    g_exp[8] = -2; g_coef[8] = 634765703
    g_exp[9] = -1; g_coef[9] = 722656339
    g_exp[10] = 0; g_coef[10] = 82031260
    g_exp[11] = 1; g_coef[11] = 277343784
    g_exp[12] = 2; g_coef[12] = 634765703
    g_exp[13] = 3; g_coef[13] = 179687522
    g_exp[14] = 4; g_coef[14] = 601562574
    g_exp[15] = 5; g_coef[15] = 414062551
    g_exp[16] = 6; g_coef[16] = 540039129
    g_exp[17] = 7; g_coef[17] = 763671969
    g_exp[18] = 8; g_coef[18] = 357421919
    g_exp[19] = 9; g_coef[19] = 251953156
    g_exp[20] = 10; g_coef[20] = 825195414

    let mut total: i64 = 0
    let mut u: i64 = 1
    while u <= 39 {
        total = (total + Q(ipow2(u), f_exp, f_coef, g_exp, g_coef)) % MOD
        u = u + 1
    }

    printf("%lld\n", total)
    free(f_exp); free(f_coef); free(g_exp); free(g_coef)
    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 egcd_i64_i64_ptr_i64_ptr_i64(int64_t a0, int64_t b0, int64_t* x, int64_t* y);
int64_t inv_mod_i64(int64_t a0);
int64_t modpow_i64_i64(int64_t base0, int64_t exp0);
int64_t t_mod_i64(int64_t exp);
int64_t geom_start1_i64_i64(int64_t exp, int64_t n);
int64_t geom_start0_i64_i64(int64_t exp, int64_t n);
int64_t ipow2_i64(int64_t u);
int64_t Q_i64_ptr_i64_ptr_i64_ptr_i64_ptr_i64(int64_t n, int64_t* f_exp, int64_t* f_coef, int64_t* g_exp, int64_t* g_coef);
int32_t main(void);

static const int64_t MOD = 1000000123;
static const int64_t NTERMS = 21;



int64_t egcd_i64_i64_ptr_i64_ptr_i64(int64_t a0, int64_t b0, int64_t* x, int64_t* y) {
    int64_t a = a0;
    int64_t b = b0;
    int64_t x1 = 1;
    int64_t y1 = 0;
    int64_t x2 = 0;
    int64_t y2 = 1;
    while (b != 0) {
        int64_t q = FLOW_CHECKED_DIV((a), (b));
        int64_t tx = (x1 - (q * x2));
        int64_t ty = (y1 - (q * y2));
        x1 = x2;
        y1 = y2;
        x2 = tx;
        y2 = ty;
        int64_t ta = a;
        a = b;
        b = FLOW_CHECKED_MOD((ta), (b));
    }
    x[0] = x1;
    y[0] = y1;
    return a;
}

int64_t inv_mod_i64(int64_t a0) {
    int64_t a = FLOW_CHECKED_MOD((a0), (MOD));
    if (a < 0) {
        a = (a + MOD);
    }
    int64_t* xy = (int64_t*)(calloc(2, 8));
    if (xy == NULL) {
        return 0;
    }
    int64_t g = egcd_i64_i64_ptr_i64_ptr_i64(a, MOD, xy, (xy + 1));
    int64_t res = FLOW_CHECKED_MOD((xy[0]), (MOD));
    free(xy);
    if (res < 0) {
        return (res + MOD);
    }
    return res;
}

int64_t modpow_i64_i64(int64_t base0, int64_t exp0) {
    int64_t r = 1;
    int64_t b = FLOW_CHECKED_MOD((base0), (MOD));
    if (b < 0) {
        b = (b + MOD);
    }
    int64_t e = exp0;
    while (e > 0) {
        if ((e & 1) != 0) {
            r = ((int64_t)(FLOW_CHECKED_MOD(((((__int128)(r)) * ((__int128)(b)))), (((__int128)(MOD))))));
        }
        b = ((int64_t)(FLOW_CHECKED_MOD(((((__int128)(b)) * ((__int128)(b)))), (((__int128)(MOD))))));
        e = FLOW_CHECKED_SHR((e), (1));
    }
    return r;
}

int64_t t_mod_i64(int64_t exp) {
    int64_t t = FLOW_CHECKED_MOD((exp), (MOD));
    if (t < 0) {
        t = (t + MOD);
    }
    return t;
}

int64_t geom_start1_i64_i64(int64_t exp, int64_t n) {
    if (n <= 0) {
        return 0;
    }
    int64_t tm = t_mod_i64(exp);
    if (tm == 1) {
        return FLOW_CHECKED_MOD((n), (MOD));
    }
    if (tm == 0) {
        return 0;
    }
    int64_t num = FLOW_CHECKED_MOD((((modpow_i64_i64(tm, (n + 1)) - tm) + MOD)), (MOD));
    return ((int64_t)(FLOW_CHECKED_MOD(((((__int128)(num)) * ((__int128)(inv_mod_i64(FLOW_CHECKED_MOD((((tm - 1) + MOD)), (MOD))))))), (((__int128)(MOD))))));
}

int64_t geom_start0_i64_i64(int64_t exp, int64_t n) {
    if (n <= 0) {
        return 0;
    }
    int64_t tm = t_mod_i64(exp);
    if (tm == 1) {
        return FLOW_CHECKED_MOD((n), (MOD));
    }
    int64_t num = FLOW_CHECKED_MOD((((modpow_i64_i64(tm, n) - 1) + MOD)), (MOD));
    return ((int64_t)(FLOW_CHECKED_MOD(((((__int128)(num)) * ((__int128)(inv_mod_i64(FLOW_CHECKED_MOD((((tm - 1) + MOD)), (MOD))))))), (((__int128)(MOD))))));
}

int64_t ipow2_i64(int64_t u) {
    int64_t r = 1;
    int64_t e = u;
    while (e > 0) {
        r = (r * 2);
        e = (e - 1);
    }
    return r;
}

int64_t Q_i64_ptr_i64_ptr_i64_ptr_i64_ptr_i64(int64_t n, int64_t* f_exp, int64_t* f_coef, int64_t* g_exp, int64_t* g_coef) {
    int64_t sum_a = 0;
    int64_t i = 0;
    while (i < NTERMS) {
        if (f_coef[i] != 0) {
            sum_a = FLOW_CHECKED_MOD(((sum_a + ((int64_t)(FLOW_CHECKED_MOD(((((__int128)(f_coef[i])) * ((__int128)(geom_start1_i64_i64(f_exp[i], n))))), (((__int128)(MOD)))))))), (MOD));
        }
        i = (i + 1);
    }
    int64_t sum_c = 0;
    i = 0;
    while (i < NTERMS) {
        if (g_coef[i] != 0) {
            sum_c = FLOW_CHECKED_MOD(((sum_c + ((int64_t)(FLOW_CHECKED_MOD(((((__int128)(g_coef[i])) * ((__int128)(geom_start0_i64_i64(g_exp[i], n))))), (((__int128)(MOD)))))))), (MOD));
        }
        i = (i + 1);
    }
    return FLOW_CHECKED_MOD((((sum_a - sum_c) + MOD)), (MOD));
}

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