Problem 976

F(10^7, 10^7) modulo 1234567891. Port of the C reference solver to pure Flow.

Answer675608326
Output675608326
StatusPASS
Native helperno
Runtime440 ms
Peak memory118320 KB
Time complexityO(n) (estimated)
Space complexityO(n) (estimated)

Performance comparison

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

Flow source

# Project Euler 976
# F(10^7, 10^7) modulo 1234567891.
# Port of the C reference solver to pure Flow.

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

const MOD: i64 = 1234567891

function build_inverses(n: i64, mod: i64) -> ptr<i64> {
    let inv: ptr<i64> = calloc(n + 1, 8)
    if n >= 1 { inv[1] = 1 }
    let mut i: i64 = 2
    while i <= n {
        inv[i] = mod - (mod / i) * inv[mod % i] % mod
        i = i + 1
    }
    return inv
}

function main() -> i32 {
    let n: i64 = 10000000
    let k: i64 = 10000000

    let e: i64 = n / 2
    let a_cnt: i64 = (n + 3) / 4
    let b_cnt: i64 = (n + 1) / 4
    let c: i64 = b_cnt - a_cnt

    if e == 0 {
        let inv: ptr<i64> = build_inverses(k + 2, MOD)
        let inv2: i64 = (MOD + 1) / 2
        let mut h: i64 = 1
        let mut qv: i64 = 1
        let mut sum_odd_a: i64 = 0
        let mut ans: i64 = 0
        let mut s: i64 = 0
        while s <= k {
            if s > 0 {
                h = h * (a_cnt + b_cnt + s - 1) % MOD * inv[s] % MOD
                if s % 2 == 0 {
                    let r: i64 = s / 2
                    qv = qv * (a_cnt + r - 1) % MOD * inv[r] % MOD
                }
            }
            let mut coeff: i64 = 0
            if c == 0 {
                if s % 2 == 0 { coeff = qv } else { coeff = 0 }
            } else {
                if c == 1 {
                    coeff = qv
                } else {
                    if s % 2 == 0 { coeff = qv } else { coeff = MOD - qv }
                }
            }
            let mut diff: i64 = (h - coeff) % MOD
            if diff < 0 { diff = diff + MOD }
            let h_odd_a: i64 = diff * inv2 % MOD
            sum_odd_a = (sum_odd_a + h_odd_a) % MOD
            ans = sum_odd_a
            s = s + 1
        }
        free(inv as ptr<void>)
        printf("%lld\n", ans % MOD)
        return 0
    }

    let max_inv: i64 = e + k + 2
    let inv: ptr<i64> = build_inverses(max_inv, MOD)
    let inv2: i64 = (MOD + 1) / 2

    # total_even at m = k: C(e + k - 1, k)
    let mut total_even: i64 = 1
    let mut m: i64 = 0
    while m < k {
        total_even = total_even * (e + m) % MOD * inv[m + 1] % MOD
        m = m + 1
    }

    # e0 at q = k / 2: C(e + q - 1, q)
    let qmax: i64 = k / 2
    let mut e0: i64 = 1
    let mut q: i64 = 0
    while q < qmax {
        e0 = e0 * (e + q) % MOD * inv[q + 1] % MOD
        q = q + 1
    }

    let mut h: i64 = 1
    let mut qv: i64 = 1
    let mut qsum: i64 = 1
    let mut sum_even: i64 = 0
    let mut sum_odd: i64 = 0
    let mut sum_odd_a: i64 = 0
    let mut ans: i64 = 0
    let ab: i64 = a_cnt + b_cnt

    let mut s: i64 = 0
    while s <= k {
        if s > 0 {
            h = h * (ab + s - 1) % MOD * inv[s] % MOD
            if s % 2 == 0 {
                let r: i64 = s / 2
                qv = qv * (a_cnt + r - 1) % MOD * inv[r] % MOD
                if c == 1 {
                    qsum = qsum * (a_cnt + r) % MOD * inv[r] % MOD
                }
            }
        }

        let mut coeff: i64 = 0
        if c == 0 {
            if s % 2 == 0 { coeff = qv } else { coeff = 0 }
        } else {
            if c == 1 {
                coeff = qsum
            } else {
                if s % 2 == 0 { coeff = qv } else { coeff = MOD - qv }
            }
        }

        let mut diff: i64 = (h - coeff) % MOD
        if diff < 0 { diff = diff + MOD }
        let h_odd_a: i64 = diff * inv2 % MOD

        if s % 2 == 0 {
            sum_even = (sum_even + h) % MOD
        } else {
            sum_odd = (sum_odd + h) % MOD
        }
        sum_odd_a = (sum_odd_a + h_odd_a) % MOD

        let m: i64 = k - s
        let mut t0: i64 = 0
        let mut t1: i64 = 0
        if m % 2 == 0 {
            let e0_m: i64 = e0
            t0 = e0_m * sum_odd_a % MOD
            let mut d1: i64 = (total_even - e0_m) % MOD
            if d1 < 0 { d1 = d1 + MOD }
            t1 = d1 * sum_even % MOD
        } else {
            t0 = 0
            t1 = total_even * sum_odd % MOD
        }
        ans = (ans + t0 + t1) % MOD

        if m > 0 {
            total_even = total_even * m % MOD * inv[e + m - 1] % MOD
        }
        if m % 2 == 0 {
            if m >= 2 {
                let qcur: i64 = m / 2
                e0 = e0 * qcur % MOD * inv[e + qcur - 1] % MOD
            }
        }

        s = s + 1
    }

    free(inv as ptr<void>)
    printf("%lld\n", ans % MOD)
    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* build_inverses_i64_i64(int64_t n, int64_t mod);
int32_t main(void);

static const int64_t MOD = 1234567891;



int64_t* build_inverses_i64_i64(int64_t n, int64_t mod) {
    int64_t* inv = (int64_t*)(calloc((n + 1), 8));
    if (n >= 1) {
        inv[1] = 1;
    }
    int64_t i = 2;
    while (i <= n) {
        inv[i] = (mod - FLOW_CHECKED_MOD(((FLOW_CHECKED_DIV((mod), (i)) * inv[FLOW_CHECKED_MOD((mod), (i))])), (mod)));
        i = (i + 1);
    }
    return inv;
}

int32_t main(void) {
    int64_t n = 10000000;
    int64_t k = 10000000;
    int64_t e = FLOW_CHECKED_DIV((n), (2));
    int64_t a_cnt = FLOW_CHECKED_DIV(((n + 3)), (4));
    int64_t b_cnt = FLOW_CHECKED_DIV(((n + 1)), (4));
    int64_t c = (b_cnt - a_cnt);
    if (e == 0) {
        int64_t* inv = (int64_t*)(build_inverses_i64_i64((k + 2), MOD));
        int64_t inv2 = FLOW_CHECKED_DIV(((MOD + 1)), (2));
        int64_t h = 1;
        int64_t qv = 1;
        int64_t sum_odd_a = 0;
        int64_t ans = 0;
        int64_t s = 0;
        while (s <= k) {
            if (s > 0) {
                h = FLOW_CHECKED_MOD(((FLOW_CHECKED_MOD(((h * (((a_cnt + b_cnt) + s) - 1))), (MOD)) * inv[s])), (MOD));
                if (FLOW_CHECKED_MOD((s), (2)) == 0) {
                    int64_t r = FLOW_CHECKED_DIV((s), (2));
                    qv = FLOW_CHECKED_MOD(((FLOW_CHECKED_MOD(((qv * ((a_cnt + r) - 1))), (MOD)) * inv[r])), (MOD));
                }
            }
            int64_t coeff = 0;
            if (c == 0) {
                if (FLOW_CHECKED_MOD((s), (2)) == 0) {
                    coeff = qv;
                } else {
                    coeff = 0;
                }
            } else {
                if (c == 1) {
                    coeff = qv;
                } else {
                    if (FLOW_CHECKED_MOD((s), (2)) == 0) {
                        coeff = qv;
                    } else {
                        coeff = (MOD - qv);
                    }
                }
            }
            int64_t diff = FLOW_CHECKED_MOD(((h - coeff)), (MOD));
            if (diff < 0) {
                diff = (diff + MOD);
            }
            int64_t h_odd_a = FLOW_CHECKED_MOD(((diff * inv2)), (MOD));
            sum_odd_a = FLOW_CHECKED_MOD(((sum_odd_a + h_odd_a)), (MOD));
            ans = sum_odd_a;
            s = (s + 1);
        }
        free(((void*)(inv)));
        printf("%lld\n", FLOW_CHECKED_MOD((ans), (MOD)));
        return 0;
    }
    int64_t max_inv = ((e + k) + 2);
    int64_t* inv = (int64_t*)(build_inverses_i64_i64(max_inv, MOD));
    int64_t inv2 = FLOW_CHECKED_DIV(((MOD + 1)), (2));
    int64_t total_even = 1;
    int64_t m = 0;
    while (m < k) {
        total_even = FLOW_CHECKED_MOD(((FLOW_CHECKED_MOD(((total_even * (e + m))), (MOD)) * inv[(m + 1)])), (MOD));
        m = (m + 1);
    }
    int64_t qmax = FLOW_CHECKED_DIV((k), (2));
    int64_t e0 = 1;
    int64_t q = 0;
    while (q < qmax) {
        e0 = FLOW_CHECKED_MOD(((FLOW_CHECKED_MOD(((e0 * (e + q))), (MOD)) * inv[(q + 1)])), (MOD));
        q = (q + 1);
    }
    int64_t h = 1;
    int64_t qv = 1;
    int64_t qsum = 1;
    int64_t sum_even = 0;
    int64_t sum_odd = 0;
    int64_t sum_odd_a = 0;
    int64_t ans = 0;
    int64_t ab = (a_cnt + b_cnt);
    int64_t s = 0;
    while (s <= k) {
        if (s > 0) {
            h = FLOW_CHECKED_MOD(((FLOW_CHECKED_MOD(((h * ((ab + s) - 1))), (MOD)) * inv[s])), (MOD));
            if (FLOW_CHECKED_MOD((s), (2)) == 0) {
                int64_t r = FLOW_CHECKED_DIV((s), (2));
                qv = FLOW_CHECKED_MOD(((FLOW_CHECKED_MOD(((qv * ((a_cnt + r) - 1))), (MOD)) * inv[r])), (MOD));
                if (c == 1) {
                    qsum = FLOW_CHECKED_MOD(((FLOW_CHECKED_MOD(((qsum * (a_cnt + r))), (MOD)) * inv[r])), (MOD));
                }
            }
        }
        int64_t coeff = 0;
        if (c == 0) {
            if (FLOW_CHECKED_MOD((s), (2)) == 0) {
                coeff = qv;
            } else {
                coeff = 0;
            }
        } else {
            if (c == 1) {
                coeff = qsum;
            } else {
                if (FLOW_CHECKED_MOD((s), (2)) == 0) {
                    coeff = qv;
                } else {
                    coeff = (MOD - qv);
                }
            }
        }
        int64_t diff = FLOW_CHECKED_MOD(((h - coeff)), (MOD));
        if (diff < 0) {
            diff = (diff + MOD);
        }
        int64_t h_odd_a = FLOW_CHECKED_MOD(((diff * inv2)), (MOD));
        if (FLOW_CHECKED_MOD((s), (2)) == 0) {
            sum_even = FLOW_CHECKED_MOD(((sum_even + h)), (MOD));
        } else {
            sum_odd = FLOW_CHECKED_MOD(((sum_odd + h)), (MOD));
        }
        sum_odd_a = FLOW_CHECKED_MOD(((sum_odd_a + h_odd_a)), (MOD));
        int64_t m = (k - s);
        int64_t t0 = 0;
        int64_t t1 = 0;
        if (FLOW_CHECKED_MOD((m), (2)) == 0) {
            int64_t e0_m = e0;
            t0 = FLOW_CHECKED_MOD(((e0_m * sum_odd_a)), (MOD));
            int64_t d1 = FLOW_CHECKED_MOD(((total_even - e0_m)), (MOD));
            if (d1 < 0) {
                d1 = (d1 + MOD);
            }
            t1 = FLOW_CHECKED_MOD(((d1 * sum_even)), (MOD));
        } else {
            t0 = 0;
            t1 = FLOW_CHECKED_MOD(((total_even * sum_odd)), (MOD));
        }
        ans = FLOW_CHECKED_MOD((((ans + t0) + t1)), (MOD));
        if (m > 0) {
            total_even = FLOW_CHECKED_MOD(((FLOW_CHECKED_MOD(((total_even * m)), (MOD)) * inv[((e + m) - 1)])), (MOD));
        }
        if (FLOW_CHECKED_MOD((m), (2)) == 0) {
            if (m >= 2) {
                int64_t qcur = FLOW_CHECKED_DIV((m), (2));
                e0 = FLOW_CHECKED_MOD(((FLOW_CHECKED_MOD(((e0 * qcur)), (MOD)) * inv[((e + qcur) - 1)])), (MOD));
            }
        }
        s = (s + 1);
    }
    free(((void*)(inv)));
    printf("%lld\n", FLOW_CHECKED_MOD((ans), (MOD)));
    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 private @calloc(i64, i64) -> !llvm.ptr
  func.func private @free(!llvm.ptr) -> ()
  // Constant: MOD
  llvm.mlir.global internal constant @MOD(1234567891 : i64) : i64
  func.func @build_inverses(%arg0: i64, %arg1: i64) -> !llvm.ptr {
    %1 = arith.constant 1 : i32
    %3 = arith.extsi %1 : i32 to i64
    %2 = arith.addi %arg0, %3 : i64
    %4 = arith.constant 8 : i32
    %5 = arith.extsi %4 : i32 to i64
    %0 = func.call @calloc(%2, %5) : (i64, i64) -> !llvm.ptr
    %6 = arith.constant 1 : i32
    %8 = arith.extsi %6 : i32 to i64
    %7 = arith.cmpi sge, %arg0, %8 : i64
    cf.cond_br %7, ^bb0, ^bb1
    ^bb0:
      %9 = arith.constant 1 : i32
      %10 = arith.constant 1 : i32
      %11 = arith.extsi %9 : i32 to i64
      %12 = arith.extsi %10 : i32 to i64
      %13 = llvm.getelementptr %0[%12] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %11, %13 : i64, !llvm.ptr
      cf.br ^bb2
    ^bb1:
      cf.br ^bb2
    ^bb2:
    %14 = arith.constant 2 : i32
    %15 = arith.extsi %14 : i32 to i64
    %16 = llvm.mlir.constant(1 : i64) : i64
    %17 = llvm.alloca %16 x i64 : (i64) -> !llvm.ptr
    llvm.store %15, %17 : i64, !llvm.ptr
    cf.br ^bb3
    ^bb3:
    %18 = llvm.load %17 : !llvm.ptr -> i64
    %19 = arith.cmpi sle, %18, %arg0 : i64
    cf.cond_br %19, ^bb4, ^bb5
    ^bb4:
      %20 = llvm.load %17 : !llvm.ptr -> i64
      %21 = arith.divsi %arg1, %20 : i64
      %23 = llvm.load %17 : !llvm.ptr -> i64
      %24 = arith.remsi %arg1, %23 : i64
      %25 = llvm.getelementptr %0[%24] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %22 = llvm.load %25 : !llvm.ptr -> i64
      %26 = arith.muli %21, %22 : i64
      %27 = arith.remsi %26, %arg1 : i64
      %28 = arith.subi %arg1, %27 : i64
      %29 = llvm.load %17 : !llvm.ptr -> i64
      %30 = llvm.getelementptr %0[%29] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %28, %30 : i64, !llvm.ptr
      %31 = llvm.load %17 : !llvm.ptr -> i64
      %32 = arith.constant 1 : i32
      %34 = arith.extsi %32 : i32 to i64
      %33 = arith.addi %31, %34 : i64
      llvm.store %33, %17 : i64, !llvm.ptr
      cf.br ^bb3
    ^bb5:
    func.return %0 : !llvm.ptr
  }
  func.func @main() -> i32 {
    %35 = arith.constant 10000000 : i32
    %36 = arith.extsi %35 : i32 to i64
    %37 = arith.constant 10000000 : i32
    %38 = arith.extsi %37 : i32 to i64
    %39 = arith.constant 2 : i32
    %41 = arith.extsi %39 : i32 to i64
    %40 = arith.divsi %36, %41 : i64
    %42 = arith.constant 3 : i32
    %44 = arith.extsi %42 : i32 to i64
    %43 = arith.addi %36, %44 : i64
    %45 = arith.constant 4 : i32
    %47 = arith.extsi %45 : i32 to i64
    %46 = arith.divsi %43, %47 : i64
    %48 = arith.constant 1 : i32
    %50 = arith.extsi %48 : i32 to i64
    %49 = arith.addi %36, %50 : i64
    %51 = arith.constant 4 : i32
    %53 = arith.extsi %51 : i32 to i64
    %52 = arith.divsi %49, %53 : i64
    %54 = arith.subi %52, %46 : i64
    %55 = arith.constant 0 : i32
    %57 = arith.extsi %55 : i32 to i64
    %56 = arith.cmpi eq, %40, %57 : i64
    cf.cond_br %56, ^bb6, ^bb7
    ^bb6:
      %59 = arith.constant 2 : i32
      %61 = arith.extsi %59 : i32 to i64
      %60 = arith.addi %38, %61 : i64
      %62 = llvm.mlir.addressof @MOD : !llvm.ptr
      %63 = llvm.load %62 : !llvm.ptr -> i64
      %58 = func.call @build_inverses(%60, %63) : (i64, i64) -> !llvm.ptr
      %64 = llvm.mlir.addressof @MOD : !llvm.ptr
      %65 = llvm.load %64 : !llvm.ptr -> i64
      %66 = arith.constant 1 : i32
      %68 = arith.extsi %66 : i32 to i64
      %67 = arith.addi %65, %68 : i64
      %69 = arith.constant 2 : i32
      %71 = arith.extsi %69 : i32 to i64
      %70 = arith.divsi %67, %71 : i64
      %72 = arith.constant 1 : i32
      %73 = arith.extsi %72 : i32 to i64
      %74 = llvm.mlir.constant(1 : i64) : i64
      %75 = llvm.alloca %74 x i64 : (i64) -> !llvm.ptr
      llvm.store %73, %75 : i64, !llvm.ptr
      %76 = arith.constant 1 : i32
      %77 = arith.extsi %76 : i32 to i64
      %78 = llvm.mlir.constant(1 : i64) : i64
      %79 = llvm.alloca %78 x i64 : (i64) -> !llvm.ptr
      llvm.store %77, %79 : i64, !llvm.ptr
      %80 = arith.constant 0 : i32
      %81 = arith.extsi %80 : i32 to i64
      %82 = llvm.mlir.constant(1 : i64) : i64
      %83 = llvm.alloca %82 x i64 : (i64) -> !llvm.ptr
      llvm.store %81, %83 : i64, !llvm.ptr
      %84 = arith.constant 0 : i32
      %85 = arith.extsi %84 : i32 to i64
      %86 = llvm.mlir.constant(1 : i64) : i64
      %87 = llvm.alloca %86 x i64 : (i64) -> !llvm.ptr
      llvm.store %85, %87 : i64, !llvm.ptr
      %88 = arith.constant 0 : i32
      %89 = arith.extsi %88 : i32 to i64
      %90 = llvm.mlir.constant(1 : i64) : i64
      %91 = llvm.alloca %90 x i64 : (i64) -> !llvm.ptr
      llvm.store %89, %91 : i64, !llvm.ptr
      cf.br ^bb9
      ^bb9:
      %92 = llvm.load %91 : !llvm.ptr -> i64
      %93 = arith.cmpi sle, %92, %38 : i64
      cf.cond_br %93, ^bb10, ^bb11
      ^bb10:
        %94 = llvm.load %91 : !llvm.ptr -> i64
        %95 = arith.constant 0 : i32
        %97 = arith.extsi %95 : i32 to i64
        %96 = arith.cmpi sgt, %94, %97 : i64
        cf.cond_br %96, ^bb12, ^bb13
        ^bb12:
          %98 = llvm.load %75 : !llvm.ptr -> i64
          %99 = arith.addi %46, %52 : i64
          %100 = llvm.load %91 : !llvm.ptr -> i64
          %101 = arith.addi %99, %100 : i64
          %102 = arith.constant 1 : i32
          %104 = arith.extsi %102 : i32 to i64
          %103 = arith.subi %101, %104 : i64
          %105 = arith.muli %98, %103 : i64
          %106 = llvm.mlir.addressof @MOD : !llvm.ptr
          %107 = llvm.load %106 : !llvm.ptr -> i64
          %108 = arith.remsi %105, %107 : i64
          %110 = llvm.load %91 : !llvm.ptr -> i64
          %111 = llvm.getelementptr %58[%110] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          %109 = llvm.load %111 : !llvm.ptr -> i64
          %112 = arith.muli %108, %109 : i64
          %113 = llvm.mlir.addressof @MOD : !llvm.ptr
          %114 = llvm.load %113 : !llvm.ptr -> i64
          %115 = arith.remsi %112, %114 : i64
          llvm.store %115, %75 : i64, !llvm.ptr
          %116 = llvm.load %91 : !llvm.ptr -> i64
          %117 = arith.constant 2 : i32
          %119 = arith.extsi %117 : i32 to i64
          %118 = arith.remsi %116, %119 : i64
          %120 = arith.constant 0 : i32
          %122 = arith.extsi %120 : i32 to i64
          %121 = arith.cmpi eq, %118, %122 : i64
          cf.cond_br %121, ^bb15, ^bb16
          ^bb15:
            %123 = llvm.load %91 : !llvm.ptr -> i64
            %124 = arith.constant 2 : i32
            %126 = arith.extsi %124 : i32 to i64
            %125 = arith.divsi %123, %126 : i64
            %127 = llvm.load %79 : !llvm.ptr -> i64
            %128 = arith.addi %46, %125 : i64
            %129 = arith.constant 1 : i32
            %131 = arith.extsi %129 : i32 to i64
            %130 = arith.subi %128, %131 : i64
            %132 = arith.muli %127, %130 : i64
            %133 = llvm.mlir.addressof @MOD : !llvm.ptr
            %134 = llvm.load %133 : !llvm.ptr -> i64
            %135 = arith.remsi %132, %134 : i64
            %137 = llvm.getelementptr %58[%125] : (!llvm.ptr, i64) -> !llvm.ptr, i64
            %136 = llvm.load %137 : !llvm.ptr -> i64
            %138 = arith.muli %135, %136 : i64
            %139 = llvm.mlir.addressof @MOD : !llvm.ptr
            %140 = llvm.load %139 : !llvm.ptr -> i64
            %141 = arith.remsi %138, %140 : i64
            llvm.store %141, %79 : i64, !llvm.ptr
            cf.br ^bb17
          ^bb16:
            cf.br ^bb17
          ^bb17:
          cf.br ^bb14
        ^bb13:
          cf.br ^bb14
        ^bb14:
        %142 = arith.constant 0 : i32
        %143 = arith.extsi %142 : i32 to i64
        %144 = llvm.mlir.constant(1 : i64) : i64
        %145 = llvm.alloca %144 x i64 : (i64) -> !llvm.ptr
        llvm.store %143, %145 : i64, !llvm.ptr
        %146 = arith.constant 0 : i32
        %148 = arith.extsi %146 : i32 to i64
        %147 = arith.cmpi eq, %54, %148 : i64
        cf.cond_br %147, ^bb18, ^bb19
        ^bb18:
          %149 = llvm.load %91 : !llvm.ptr -> i64
          %150 = arith.constant 2 : i32
          %152 = arith.extsi %150 : i32 to i64
          %151 = arith.remsi %149, %152 : i64
          %153 = arith.constant 0 : i32
          %155 = arith.extsi %153 : i32 to i64
          %154 = arith.cmpi eq, %151, %155 : i64
          cf.cond_br %154, ^bb21, ^bb22
          ^bb21:
            %156 = llvm.load %79 : !llvm.ptr -> i64
            llvm.store %156, %145 : i64, !llvm.ptr
            cf.br ^bb23
          ^bb22:
            %157 = arith.constant 0 : i32
            %158 = arith.extsi %157 : i32 to i64
            llvm.store %158, %145 : i64, !llvm.ptr
            cf.br ^bb23
          ^bb23:
          cf.br ^bb20
        ^bb19:
          %159 = arith.constant 1 : i32
          %161 = arith.extsi %159 : i32 to i64
          %160 = arith.cmpi eq, %54, %161 : i64
          cf.cond_br %160, ^bb24, ^bb25
          ^bb24:
            %162 = llvm.load %79 : !llvm.ptr -> i64
            llvm.store %162, %145 : i64, !llvm.ptr
            cf.br ^bb26
          ^bb25:
            %163 = llvm.load %91 : !llvm.ptr -> i64
            %164 = arith.constant 2 : i32
            %166 = arith.extsi %164 : i32 to i64
            %165 = arith.remsi %163, %166 : i64
            %167 = arith.constant 0 : i32
            %169 = arith.extsi %167 : i32 to i64
            %168 = arith.cmpi eq, %165, %169 : i64
            cf.cond_br %168, ^bb27, ^bb28
            ^bb27:
              %170 = llvm.load %79 : !llvm.ptr -> i64
              llvm.store %170, %145 : i64, !llvm.ptr
              cf.br ^bb29
            ^bb28:
              %171 = llvm.mlir.addressof @MOD : !llvm.ptr
              %172 = llvm.load %171 : !llvm.ptr -> i64
              %173 = llvm.load %79 : !llvm.ptr -> i64
              %174 = arith.subi %172, %173 : i64
              llvm.store %174, %145 : i64, !llvm.ptr
              cf.br ^bb29
            ^bb29:
            cf.br ^bb26
          ^bb26:
          cf.br ^bb20
        ^bb20:
        %175 = llvm.load %75 : !llvm.ptr -> i64
        %176 = llvm.load %145 : !llvm.ptr -> i64
        %177 = arith.subi %175, %176 : i64
        %178 = llvm.mlir.addressof @MOD : !llvm.ptr
        %179 = llvm.load %178 : !llvm.ptr -> i64
        %180 = arith.remsi %177, %179 : i64
        %181 = llvm.mlir.constant(1 : i64) : i64
        %182 = llvm.alloca %181 x i64 : (i64) -> !llvm.ptr
        llvm.store %180, %182 : i64, !llvm.ptr
        %183 = llvm.load %182 : !llvm.ptr -> i64
        %184 = arith.constant 0 : i32
        %186 = arith.extsi %184 : i32 to i64
        %185 = arith.cmpi slt, %183, %186 : i64
        cf.cond_br %185, ^bb30, ^bb31
        ^bb30:
          %187 = llvm.load %182 : !llvm.ptr -> i64
          %188 = llvm.mlir.addressof @MOD : !llvm.ptr
          %189 = llvm.load %188 : !llvm.ptr -> i64
          %190 = arith.addi %187, %189 : i64
          llvm.store %190, %182 : i64, !llvm.ptr
          cf.br ^bb32
        ^bb31:
          cf.br ^bb32
        ^bb32:
        %191 = llvm.load %182 : !llvm.ptr -> i64
        %192 = arith.muli %191, %70 : i64
        %193 = llvm.mlir.addressof @MOD : !llvm.ptr
        %194 = llvm.load %193 : !llvm.ptr -> i64
        %195 = arith.remsi %192, %194 : i64
        %196 = llvm.load %83 : !llvm.ptr -> i64
        %197 = arith.addi %196, %195 : i64
        %198 = llvm.mlir.addressof @MOD : !llvm.ptr
        %199 = llvm.load %198 : !llvm.ptr -> i64
        %200 = arith.remsi %197, %199 : i64
        llvm.store %200, %83 : i64, !llvm.ptr
        %201 = llvm.load %83 : !llvm.ptr -> i64
        llvm.store %201, %87 : i64, !llvm.ptr
        %202 = llvm.load %91 : !llvm.ptr -> i64
        %203 = arith.constant 1 : i32
        %205 = arith.extsi %203 : i32 to i64
        %204 = arith.addi %202, %205 : i64
        llvm.store %204, %91 : i64, !llvm.ptr
        cf.br ^bb9
      ^bb11:
      func.call @free(%58) : (!llvm.ptr) -> ()
      %207 = llvm.mlir.addressof @str_0 : !llvm.ptr
      %208 = llvm.load %87 : !llvm.ptr -> i64
      %209 = llvm.mlir.addressof @MOD : !llvm.ptr
      %210 = llvm.load %209 : !llvm.ptr -> i64
      %211 = arith.remsi %208, %210 : i64
      %212 = llvm.call @printf(%207, %211) vararg(!llvm.func<i32 (ptr, ...)>) : (!llvm.ptr, i64) -> i32
      %213 = arith.constant 0 : i32
      func.return %213 : i32
    ^bb7:
      cf.br ^bb8
    ^bb8:
    %214 = arith.addi %40, %38 : i64
    %215 = arith.constant 2 : i32
    %217 = arith.extsi %215 : i32 to i64
    %216 = arith.addi %214, %217 : i64
    %219 = llvm.mlir.addressof @MOD : !llvm.ptr
    %220 = llvm.load %219 : !llvm.ptr -> i64
    %218 = func.call @build_inverses(%216, %220) : (i64, i64) -> !llvm.ptr
    %221 = llvm.mlir.addressof @MOD : !llvm.ptr
    %222 = llvm.load %221 : !llvm.ptr -> i64
    %223 = arith.constant 1 : i32
    %225 = arith.extsi %223 : i32 to i64
    %224 = arith.addi %222, %225 : i64
    %226 = arith.constant 2 : i32
    %228 = arith.extsi %226 : i32 to i64
    %227 = arith.divsi %224, %228 : i64
    %229 = arith.constant 1 : i32
    %230 = arith.extsi %229 : i32 to i64
    %231 = llvm.mlir.constant(1 : i64) : i64
    %232 = llvm.alloca %231 x i64 : (i64) -> !llvm.ptr
    llvm.store %230, %232 : i64, !llvm.ptr
    %233 = arith.constant 0 : i32
    %234 = arith.extsi %233 : i32 to i64
    %235 = llvm.mlir.constant(1 : i64) : i64
    %236 = llvm.alloca %235 x i64 : (i64) -> !llvm.ptr
    llvm.store %234, %236 : i64, !llvm.ptr
    cf.br ^bb33
    ^bb33:
    %237 = llvm.load %236 : !llvm.ptr -> i64
    %238 = arith.cmpi slt, %237, %38 : i64
    cf.cond_br %238, ^bb34, ^bb35
    ^bb34:
      %239 = llvm.load %232 : !llvm.ptr -> i64
      %240 = llvm.load %236 : !llvm.ptr -> i64
      %241 = arith.addi %40, %240 : i64
      %242 = arith.muli %239, %241 : i64
      %243 = llvm.mlir.addressof @MOD : !llvm.ptr
      %244 = llvm.load %243 : !llvm.ptr -> i64
      %245 = arith.remsi %242, %244 : i64
      %247 = llvm.load %236 : !llvm.ptr -> i64
      %248 = arith.constant 1 : i32
      %250 = arith.extsi %248 : i32 to i64
      %249 = arith.addi %247, %250 : i64
      %251 = llvm.getelementptr %218[%249] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %246 = llvm.load %251 : !llvm.ptr -> i64
      %252 = arith.muli %245, %246 : i64
      %253 = llvm.mlir.addressof @MOD : !llvm.ptr
      %254 = llvm.load %253 : !llvm.ptr -> i64
      %255 = arith.remsi %252, %254 : i64
      llvm.store %255, %232 : i64, !llvm.ptr
      %256 = llvm.load %236 : !llvm.ptr -> i64
      %257 = arith.constant 1 : i32
      %259 = arith.extsi %257 : i32 to i64
      %258 = arith.addi %256, %259 : i64
      llvm.store %258, %236 : i64, !llvm.ptr
      cf.br ^bb33
    ^bb35:
    %260 = arith.constant 2 : i32
    %262 = arith.extsi %260 : i32 to i64
    %261 = arith.divsi %38, %262 : i64
    %263 = arith.constant 1 : i32
    %264 = arith.extsi %263 : i32 to i64
    %265 = llvm.mlir.constant(1 : i64) : i64
    %266 = llvm.alloca %265 x i64 : (i64) -> !llvm.ptr
    llvm.store %264, %266 : i64, !llvm.ptr
    %267 = arith.constant 0 : i32
    %268 = arith.extsi %267 : i32 to i64
    %269 = llvm.mlir.constant(1 : i64) : i64
    %270 = llvm.alloca %269 x i64 : (i64) -> !llvm.ptr
    llvm.store %268, %270 : i64, !llvm.ptr
    cf.br ^bb36
    ^bb36:
    %271 = llvm.load %270 : !llvm.ptr -> i64
    %272 = arith.cmpi slt, %271, %261 : i64
    cf.cond_br %272, ^bb37, ^bb38
    ^bb37:
      %273 = llvm.load %266 : !llvm.ptr -> i64
      %274 = llvm.load %270 : !llvm.ptr -> i64
      %275 = arith.addi %40, %274 : i64
      %276 = arith.muli %273, %275 : i64
      %277 = llvm.mlir.addressof @MOD : !llvm.ptr
      %278 = llvm.load %277 : !llvm.ptr -> i64
      %279 = arith.remsi %276, %278 : i64
      %281 = llvm.load %270 : !llvm.ptr -> i64
      %282 = arith.constant 1 : i32
      %284 = arith.extsi %282 : i32 to i64
      %283 = arith.addi %281, %284 : i64
      %285 = llvm.getelementptr %218[%283] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %280 = llvm.load %285 : !llvm.ptr -> i64
      %286 = arith.muli %279, %280 : i64
      %287 = llvm.mlir.addressof @MOD : !llvm.ptr
      %288 = llvm.load %287 : !llvm.ptr -> i64
      %289 = arith.remsi %286, %288 : i64
      llvm.store %289, %266 : i64, !llvm.ptr
      %290 = llvm.load %270 : !llvm.ptr -> i64
      %291 = arith.constant 1 : i32
      %293 = arith.extsi %291 : i32 to i64
      %292 = arith.addi %290, %293 : i64
      llvm.store %292, %270 : i64, !llvm.ptr
      cf.br ^bb36
    ^bb38:
    %294 = arith.constant 1 : i32
    %295 = arith.extsi %294 : i32 to i64
    %296 = llvm.mlir.constant(1 : i64) : i64
    %297 = llvm.alloca %296 x i64 : (i64) -> !llvm.ptr
    llvm.store %295, %297 : i64, !llvm.ptr
    %298 = arith.constant 1 : i32
    %299 = arith.extsi %298 : i32 to i64
    %300 = llvm.mlir.constant(1 : i64) : i64
    %301 = llvm.alloca %300 x i64 : (i64) -> !llvm.ptr
    llvm.store %299, %301 : i64, !llvm.ptr
    %302 = arith.constant 1 : i32
    %303 = arith.extsi %302 : i32 to i64
    %304 = llvm.mlir.constant(1 : i64) : i64
    %305 = llvm.alloca %304 x i64 : (i64) -> !llvm.ptr
    llvm.store %303, %305 : i64, !llvm.ptr
    %306 = arith.constant 0 : i32
    %307 = arith.extsi %306 : i32 to i64
    %308 = llvm.mlir.constant(1 : i64) : i64
    %309 = llvm.alloca %308 x i64 : (i64) -> !llvm.ptr
    llvm.store %307, %309 : i64, !llvm.ptr
    %310 = arith.constant 0 : i32
    %311 = arith.extsi %310 : i32 to i64
    %312 = llvm.mlir.constant(1 : i64) : i64
    %313 = llvm.alloca %312 x i64 : (i64) -> !llvm.ptr
    llvm.store %311, %313 : i64, !llvm.ptr
    %314 = arith.constant 0 : i32
    %315 = arith.extsi %314 : i32 to i64
    %316 = llvm.mlir.constant(1 : i64) : i64
    %317 = llvm.alloca %316 x i64 : (i64) -> !llvm.ptr
    llvm.store %315, %317 : i64, !llvm.ptr
    %318 = arith.constant 0 : i32
    %319 = arith.extsi %318 : i32 to i64
    %320 = llvm.mlir.constant(1 : i64) : i64
    %321 = llvm.alloca %320 x i64 : (i64) -> !llvm.ptr
    llvm.store %319, %321 : i64, !llvm.ptr
    %322 = arith.addi %46, %52 : i64
    %323 = arith.constant 0 : i32
    %324 = arith.extsi %323 : i32 to i64
    %325 = llvm.mlir.constant(1 : i64) : i64
    %326 = llvm.alloca %325 x i64 : (i64) -> !llvm.ptr
    llvm.store %324, %326 : i64, !llvm.ptr
    cf.br ^bb39
    ^bb39:
    %327 = llvm.load %326 : !llvm.ptr -> i64
    %328 = arith.cmpi sle, %327, %38 : i64
    cf.cond_br %328, ^bb40, ^bb41
    ^bb40:
      %329 = llvm.load %326 : !llvm.ptr -> i64
      %330 = arith.constant 0 : i32
      %332 = arith.extsi %330 : i32 to i64
      %331 = arith.cmpi sgt, %329, %332 : i64
      cf.cond_br %331, ^bb42, ^bb43
      ^bb42:
        %333 = llvm.load %297 : !llvm.ptr -> i64
        %334 = llvm.load %326 : !llvm.ptr -> i64
        %335 = arith.addi %322, %334 : i64
        %336 = arith.constant 1 : i32
        %338 = arith.extsi %336 : i32 to i64
        %337 = arith.subi %335, %338 : i64
        %339 = arith.muli %333, %337 : i64
        %340 = llvm.mlir.addressof @MOD : !llvm.ptr
        %341 = llvm.load %340 : !llvm.ptr -> i64
        %342 = arith.remsi %339, %341 : i64
        %344 = llvm.load %326 : !llvm.ptr -> i64
        %345 = llvm.getelementptr %218[%344] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %343 = llvm.load %345 : !llvm.ptr -> i64
        %346 = arith.muli %342, %343 : i64
        %347 = llvm.mlir.addressof @MOD : !llvm.ptr
        %348 = llvm.load %347 : !llvm.ptr -> i64
        %349 = arith.remsi %346, %348 : i64
        llvm.store %349, %297 : i64, !llvm.ptr
        %350 = llvm.load %326 : !llvm.ptr -> i64
        %351 = arith.constant 2 : i32
        %353 = arith.extsi %351 : i32 to i64
        %352 = arith.remsi %350, %353 : i64
        %354 = arith.constant 0 : i32
        %356 = arith.extsi %354 : i32 to i64
        %355 = arith.cmpi eq, %352, %356 : i64
        cf.cond_br %355, ^bb45, ^bb46
        ^bb45:
          %357 = llvm.load %326 : !llvm.ptr -> i64
          %358 = arith.constant 2 : i32
          %360 = arith.extsi %358 : i32 to i64
          %359 = arith.divsi %357, %360 : i64
          %361 = llvm.load %301 : !llvm.ptr -> i64
          %362 = arith.addi %46, %359 : i64
          %363 = arith.constant 1 : i32
          %365 = arith.extsi %363 : i32 to i64
          %364 = arith.subi %362, %365 : i64
          %366 = arith.muli %361, %364 : i64
          %367 = llvm.mlir.addressof @MOD : !llvm.ptr
          %368 = llvm.load %367 : !llvm.ptr -> i64
          %369 = arith.remsi %366, %368 : i64
          %371 = llvm.getelementptr %218[%359] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          %370 = llvm.load %371 : !llvm.ptr -> i64
          %372 = arith.muli %369, %370 : i64
          %373 = llvm.mlir.addressof @MOD : !llvm.ptr
          %374 = llvm.load %373 : !llvm.ptr -> i64
          %375 = arith.remsi %372, %374 : i64
          llvm.store %375, %301 : i64, !llvm.ptr
          %376 = arith.constant 1 : i32
          %378 = arith.extsi %376 : i32 to i64
          %377 = arith.cmpi eq, %54, %378 : i64
          cf.cond_br %377, ^bb48, ^bb49
          ^bb48:
            %379 = llvm.load %305 : !llvm.ptr -> i64
            %380 = arith.addi %46, %359 : i64
            %381 = arith.muli %379, %380 : i64
            %382 = llvm.mlir.addressof @MOD : !llvm.ptr
            %383 = llvm.load %382 : !llvm.ptr -> i64
            %384 = arith.remsi %381, %383 : i64
            %386 = llvm.getelementptr %218[%359] : (!llvm.ptr, i64) -> !llvm.ptr, i64
            %385 = llvm.load %386 : !llvm.ptr -> i64
            %387 = arith.muli %384, %385 : i64
            %388 = llvm.mlir.addressof @MOD : !llvm.ptr
            %389 = llvm.load %388 : !llvm.ptr -> i64
            %390 = arith.remsi %387, %389 : i64
            llvm.store %390, %305 : i64, !llvm.ptr
            cf.br ^bb50
          ^bb49:
            cf.br ^bb50
          ^bb50:
          cf.br ^bb47
        ^bb46:
          cf.br ^bb47
        ^bb47:
        cf.br ^bb44
      ^bb43:
        cf.br ^bb44
      ^bb44:
      %391 = arith.constant 0 : i32
      %392 = arith.extsi %391 : i32 to i64
      %393 = llvm.mlir.constant(1 : i64) : i64
      %394 = llvm.alloca %393 x i64 : (i64) -> !llvm.ptr
      llvm.store %392, %394 : i64, !llvm.ptr
      %395 = arith.constant 0 : i32
      %397 = arith.extsi %395 : i32 to i64
      %396 = arith.cmpi eq, %54, %397 : i64
      cf.cond_br %396, ^bb51, ^bb52
      ^bb51:
        %398 = llvm.load %326 : !llvm.ptr -> i64
        %399 = arith.constant 2 : i32
        %401 = arith.extsi %399 : i32 to i64
        %400 = arith.remsi %398, %401 : i64
        %402 = arith.constant 0 : i32
        %404 = arith.extsi %402 : i32 to i64
        %403 = arith.cmpi eq, %400, %404 : i64
        cf.cond_br %403, ^bb54, ^bb55
        ^bb54:
          %405 = llvm.load %301 : !llvm.ptr -> i64
          llvm.store %405, %394 : i64, !llvm.ptr
          cf.br ^bb56
        ^bb55:
          %406 = arith.constant 0 : i32
          %407 = arith.extsi %406 : i32 to i64
          llvm.store %407, %394 : i64, !llvm.ptr
          cf.br ^bb56
        ^bb56:
        cf.br ^bb53
      ^bb52:
        %408 = arith.constant 1 : i32
        %410 = arith.extsi %408 : i32 to i64
        %409 = arith.cmpi eq, %54, %410 : i64
        cf.cond_br %409, ^bb57, ^bb58
        ^bb57:
          %411 = llvm.load %305 : !llvm.ptr -> i64
          llvm.store %411, %394 : i64, !llvm.ptr
          cf.br ^bb59
        ^bb58:
          %412 = llvm.load %326 : !llvm.ptr -> i64
          %413 = arith.constant 2 : i32
          %415 = arith.extsi %413 : i32 to i64
          %414 = arith.remsi %412, %415 : i64
          %416 = arith.constant 0 : i32
          %418 = arith.extsi %416 : i32 to i64
          %417 = arith.cmpi eq, %414, %418 : i64
          cf.cond_br %417, ^bb60, ^bb61
          ^bb60:
            %419 = llvm.load %301 : !llvm.ptr -> i64
            llvm.store %419, %394 : i64, !llvm.ptr
            cf.br ^bb62
          ^bb61:
            %420 = llvm.mlir.addressof @MOD : !llvm.ptr
            %421 = llvm.load %420 : !llvm.ptr -> i64
            %422 = llvm.load %301 : !llvm.ptr -> i64
            %423 = arith.subi %421, %422 : i64
            llvm.store %423, %394 : i64, !llvm.ptr
            cf.br ^bb62
          ^bb62:
          cf.br ^bb59
        ^bb59:
        cf.br ^bb53
      ^bb53:
      %424 = llvm.load %297 : !llvm.ptr -> i64
      %425 = llvm.load %394 : !llvm.ptr -> i64
      %426 = arith.subi %424, %425 : i64
      %427 = llvm.mlir.addressof @MOD : !llvm.ptr
      %428 = llvm.load %427 : !llvm.ptr -> i64
      %429 = arith.remsi %426, %428 : i64
      %430 = llvm.mlir.constant(1 : i64) : i64
      %431 = llvm.alloca %430 x i64 : (i64) -> !llvm.ptr
      llvm.store %429, %431 : i64, !llvm.ptr
      %432 = llvm.load %431 : !llvm.ptr -> i64
      %433 = arith.constant 0 : i32
      %435 = arith.extsi %433 : i32 to i64
      %434 = arith.cmpi slt, %432, %435 : i64
      cf.cond_br %434, ^bb63, ^bb64
      ^bb63:
        %436 = llvm.load %431 : !llvm.ptr -> i64
        %437 = llvm.mlir.addressof @MOD : !llvm.ptr
        %438 = llvm.load %437 : !llvm.ptr -> i64
        %439 = arith.addi %436, %438 : i64
        llvm.store %439, %431 : i64, !llvm.ptr
        cf.br ^bb65
      ^bb64:
        cf.br ^bb65
      ^bb65:
      %440 = llvm.load %431 : !llvm.ptr -> i64
      %441 = arith.muli %440, %227 : i64
      %442 = llvm.mlir.addressof @MOD : !llvm.ptr
      %443 = llvm.load %442 : !llvm.ptr -> i64
      %444 = arith.remsi %441, %443 : i64
      %445 = llvm.load %326 : !llvm.ptr -> i64
      %446 = arith.constant 2 : i32
      %448 = arith.extsi %446 : i32 to i64
      %447 = arith.remsi %445, %448 : i64
      %449 = arith.constant 0 : i32
      %451 = arith.extsi %449 : i32 to i64
      %450 = arith.cmpi eq, %447, %451 : i64
      cf.cond_br %450, ^bb66, ^bb67
      ^bb66:
        %452 = llvm.load %309 : !llvm.ptr -> i64
        %453 = llvm.load %297 : !llvm.ptr -> i64
        %454 = arith.addi %452, %453 : i64
        %455 = llvm.mlir.addressof @MOD : !llvm.ptr
        %456 = llvm.load %455 : !llvm.ptr -> i64
        %457 = arith.remsi %454, %456 : i64
        llvm.store %457, %309 : i64, !llvm.ptr
        cf.br ^bb68
      ^bb67:
        %458 = llvm.load %313 : !llvm.ptr -> i64
        %459 = llvm.load %297 : !llvm.ptr -> i64
        %460 = arith.addi %458, %459 : i64
        %461 = llvm.mlir.addressof @MOD : !llvm.ptr
        %462 = llvm.load %461 : !llvm.ptr -> i64
        %463 = arith.remsi %460, %462 : i64
        llvm.store %463, %313 : i64, !llvm.ptr
        cf.br ^bb68
      ^bb68:
      %464 = llvm.load %317 : !llvm.ptr -> i64
      %465 = arith.addi %464, %444 : i64
      %466 = llvm.mlir.addressof @MOD : !llvm.ptr
      %467 = llvm.load %466 : !llvm.ptr -> i64
      %468 = arith.remsi %465, %467 : i64
      llvm.store %468, %317 : i64, !llvm.ptr
      %469 = llvm.load %326 : !llvm.ptr -> i64
      %470 = arith.subi %38, %469 : i64
      %471 = arith.constant 0 : i32
      %472 = arith.extsi %471 : i32 to i64
      %473 = llvm.mlir.constant(1 : i64) : i64
      %474 = llvm.alloca %473 x i64 : (i64) -> !llvm.ptr
      llvm.store %472, %474 : i64, !llvm.ptr
      %475 = arith.constant 0 : i32
      %476 = arith.extsi %475 : i32 to i64
      %477 = llvm.mlir.constant(1 : i64) : i64
      %478 = llvm.alloca %477 x i64 : (i64) -> !llvm.ptr
      llvm.store %476, %478 : i64, !llvm.ptr
      %479 = arith.constant 2 : i32
      %481 = arith.extsi %479 : i32 to i64
      %480 = arith.remsi %470, %481 : i64
      %482 = arith.constant 0 : i32
      %484 = arith.extsi %482 : i32 to i64
      %483 = arith.cmpi eq, %480, %484 : i64
      cf.cond_br %483, ^bb69, ^bb70
      ^bb69:
        %485 = llvm.load %266 : !llvm.ptr -> i64
        %486 = llvm.load %317 : !llvm.ptr -> i64
        %487 = arith.muli %485, %486 : i64
        %488 = llvm.mlir.addressof @MOD : !llvm.ptr
        %489 = llvm.load %488 : !llvm.ptr -> i64
        %490 = arith.remsi %487, %489 : i64
        llvm.store %490, %474 : i64, !llvm.ptr
        %491 = llvm.load %232 : !llvm.ptr -> i64
        %492 = arith.subi %491, %485 : i64
        %493 = llvm.mlir.addressof @MOD : !llvm.ptr
        %494 = llvm.load %493 : !llvm.ptr -> i64
        %495 = arith.remsi %492, %494 : i64
        %496 = llvm.mlir.constant(1 : i64) : i64
        %497 = llvm.alloca %496 x i64 : (i64) -> !llvm.ptr
        llvm.store %495, %497 : i64, !llvm.ptr
        %498 = llvm.load %497 : !llvm.ptr -> i64
        %499 = arith.constant 0 : i32
        %501 = arith.extsi %499 : i32 to i64
        %500 = arith.cmpi slt, %498, %501 : i64
        cf.cond_br %500, ^bb72, ^bb73
        ^bb72:
          %502 = llvm.load %497 : !llvm.ptr -> i64
          %503 = llvm.mlir.addressof @MOD : !llvm.ptr
          %504 = llvm.load %503 : !llvm.ptr -> i64
          %505 = arith.addi %502, %504 : i64
          llvm.store %505, %497 : i64, !llvm.ptr
          cf.br ^bb74
        ^bb73:
          cf.br ^bb74
        ^bb74:
        %506 = llvm.load %497 : !llvm.ptr -> i64
        %507 = llvm.load %309 : !llvm.ptr -> i64
        %508 = arith.muli %506, %507 : i64
        %509 = llvm.mlir.addressof @MOD : !llvm.ptr
        %510 = llvm.load %509 : !llvm.ptr -> i64
        %511 = arith.remsi %508, %510 : i64
        llvm.store %511, %478 : i64, !llvm.ptr
        cf.br ^bb71
      ^bb70:
        %512 = arith.constant 0 : i32
        %513 = arith.extsi %512 : i32 to i64
        llvm.store %513, %474 : i64, !llvm.ptr
        %514 = llvm.load %232 : !llvm.ptr -> i64
        %515 = llvm.load %313 : !llvm.ptr -> i64
        %516 = arith.muli %514, %515 : i64
        %517 = llvm.mlir.addressof @MOD : !llvm.ptr
        %518 = llvm.load %517 : !llvm.ptr -> i64
        %519 = arith.remsi %516, %518 : i64
        llvm.store %519, %478 : i64, !llvm.ptr
        cf.br ^bb71
      ^bb71:
      %520 = llvm.load %321 : !llvm.ptr -> i64
      %521 = llvm.load %474 : !llvm.ptr -> i64
      %522 = arith.addi %520, %521 : i64
      %523 = llvm.load %478 : !llvm.ptr -> i64
      %524 = arith.addi %522, %523 : i64
      %525 = llvm.mlir.addressof @MOD : !llvm.ptr
      %526 = llvm.load %525 : !llvm.ptr -> i64
      %527 = arith.remsi %524, %526 : i64
      llvm.store %527, %321 : i64, !llvm.ptr
      %528 = arith.constant 0 : i32
      %530 = arith.extsi %528 : i32 to i64
      %529 = arith.cmpi sgt, %470, %530 : i64
      cf.cond_br %529, ^bb75, ^bb76
      ^bb75:
        %531 = llvm.load %232 : !llvm.ptr -> i64
        %532 = arith.muli %531, %470 : i64
        %533 = llvm.mlir.addressof @MOD : !llvm.ptr
        %534 = llvm.load %533 : !llvm.ptr -> i64
        %535 = arith.remsi %532, %534 : i64
        %537 = arith.addi %40, %470 : i64
        %538 = arith.constant 1 : i32
        %540 = arith.extsi %538 : i32 to i64
        %539 = arith.subi %537, %540 : i64
        %541 = llvm.getelementptr %218[%539] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %536 = llvm.load %541 : !llvm.ptr -> i64
        %542 = arith.muli %535, %536 : i64
        %543 = llvm.mlir.addressof @MOD : !llvm.ptr
        %544 = llvm.load %543 : !llvm.ptr -> i64
        %545 = arith.remsi %542, %544 : i64
        llvm.store %545, %232 : i64, !llvm.ptr
        cf.br ^bb77
      ^bb76:
        cf.br ^bb77
      ^bb77:
      %546 = arith.constant 2 : i32
      %548 = arith.extsi %546 : i32 to i64
      %547 = arith.remsi %470, %548 : i64
      %549 = arith.constant 0 : i32
      %551 = arith.extsi %549 : i32 to i64
      %550 = arith.cmpi eq, %547, %551 : i64
      cf.cond_br %550, ^bb78, ^bb79
      ^bb78:
        %552 = arith.constant 2 : i32
        %554 = arith.extsi %552 : i32 to i64
        %553 = arith.cmpi sge, %470, %554 : i64
        cf.cond_br %553, ^bb81, ^bb82
        ^bb81:
          %555 = arith.constant 2 : i32
          %557 = arith.extsi %555 : i32 to i64
          %556 = arith.divsi %470, %557 : i64
          %558 = llvm.load %266 : !llvm.ptr -> i64
          %559 = arith.muli %558, %556 : i64
          %560 = llvm.mlir.addressof @MOD : !llvm.ptr
          %561 = llvm.load %560 : !llvm.ptr -> i64
          %562 = arith.remsi %559, %561 : i64
          %564 = arith.addi %40, %556 : i64
          %565 = arith.constant 1 : i32
          %567 = arith.extsi %565 : i32 to i64
          %566 = arith.subi %564, %567 : i64
          %568 = llvm.getelementptr %218[%566] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          %563 = llvm.load %568 : !llvm.ptr -> i64
          %569 = arith.muli %562, %563 : i64
          %570 = llvm.mlir.addressof @MOD : !llvm.ptr
          %571 = llvm.load %570 : !llvm.ptr -> i64
          %572 = arith.remsi %569, %571 : i64
          llvm.store %572, %266 : i64, !llvm.ptr
          cf.br ^bb83
        ^bb82:
          cf.br ^bb83
        ^bb83:
        cf.br ^bb80
      ^bb79:
        cf.br ^bb80
      ^bb80:
      %573 = llvm.load %326 : !llvm.ptr -> i64
      %574 = arith.constant 1 : i32
      %576 = arith.extsi %574 : i32 to i64
      %575 = arith.addi %573, %576 : i64
      llvm.store %575, %326 : i64, !llvm.ptr
      cf.br ^bb39
    ^bb41:
    func.call @free(%218) : (!llvm.ptr) -> ()
    %578 = llvm.mlir.addressof @str_0 : !llvm.ptr
    %579 = llvm.load %321 : !llvm.ptr -> i64
    %580 = llvm.mlir.addressof @MOD : !llvm.ptr
    %581 = llvm.load %580 : !llvm.ptr -> i64
    %582 = arith.remsi %579, %581 : i64
    %583 = llvm.call @printf(%578, %582) vararg(!llvm.func<i32 (ptr, ...)>) : (!llvm.ptr, i64) -> i32
    %584 = arith.constant 0 : i32
    func.return %584 : i32
  }
}