Problem 981

Counts equivalence classes of words over {x,y,z} with cube counts (X,Y,Z) where X,Y,Z are cubes below 88^3, weighted by the canonical-product sign and q-multinomial at q=-1, summed mod 888888883. Pure Flow port of the native C helper. MOD^2 < 7.9e17 so i64 is safe.

Answer794963735
Output794963735
StatusPASS
Native helperno
Runtime20 ms
Peak memory31968 KB
Time complexityO(n^2) (estimated)
Space complexityO(1) (estimated)

Performance comparison

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

Flow source

# Project Euler 981
# Counts equivalence classes of words over {x,y,z} with cube counts
# (X,Y,Z) where X,Y,Z are cubes below 88^3, weighted by the
# canonical-product sign and q-multinomial at q=-1, summed mod 888888883.
# Pure Flow port of the native C helper. MOD^2 < 7.9e17 so i64 is safe.

import euler.nt { mod_pow }

const MOD: i64 = 888888883

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

function main() -> i32 {
    let NC: i32 = 88
    let cubes: ptr<i64> = malloc((NC as i64) * 8)
    let mut i: i32 = 0
    while i < NC {
        let ii: i64 = (i as i64)
        cubes[i] = ii * ii * ii
        i = i + 1
    }

    let max_n: i64 = 3 * cubes[NC - 1]

    # factorials and inverse factorials mod MOD
    let fact: ptr<i64> = malloc((max_n + 1) * 8)
    let invfact: ptr<i64> = malloc((max_n + 1) * 8)

    fact[0] = 1 % MOD
    let mut i1: i64 = 1
    while i1 <= max_n {
        fact[i1] = fact[i1 - 1] * (i1 % MOD) % MOD
        i1 = i1 + 1
    }
    invfact[max_n] = mod_pow(fact[max_n], MOD - 2, MOD)
    let mut i2: i64 = max_n
    while i2 >= 1 {
        invfact[i2 - 1] = invfact[i2] * (i2 % MOD) % MOD
        i2 = i2 - 1
    }

    let inv2: i64 = (MOD + 1) / 2

    # per-cube helpers
    let halves: ptr<i64> = malloc((NC as i64) * 8)
    let invf: ptr<i64> = malloc((NC as i64) * 8)
    let par: ptr<i32> = malloc((NC as i64) * 4)
    let mut i3: i32 = 0
    while i3 < NC {
        halves[i3] = cubes[i3] >> 1
        invf[i3] = invfact[cubes[i3]]
        par[i3] = i3 % 2
        i3 = i3 + 1
    }

    let mut total_sum: i64 = 0

    let mut ai: i32 = 0
    while ai < NC {
        let X: i64 = cubes[ai]
        let hx: i64 = halves[ai]
        let invX: i64 = invf[ai]
        let px: i32 = par[ai]
        let mut bj: i32 = 0
        while bj < NC {
            let Y: i64 = cubes[bj]
            let hy: i64 = halves[bj]
            let invY: i64 = invf[bj]
            let py: i32 = par[bj]
            if px != py {
                bj = bj + 1
            } else {
                let mut ck: i32 = 0
                while ck < NC {
                    if py != par[ck] {
                        ck = ck + 1
                    } else {
                        let Z: i64 = cubes[ck]
                        let hz: i64 = halves[ck]
                        let invZ: i64 = invf[ck]

                        let n: i64 = X + Y + Z

                        # T = multinomial(n; X,Y,Z) mod MOD
                        let mut T: i64 = fact[n]
                        T = T * invX % MOD
                        T = T * invY % MOD
                        T = T * invZ % MOD

                        # D = (E - O) = q-multinomial at q=-1
                        let mut D: i64 = 0
                        if n % 2 == 0 && X % 2 == 1 {
                            D = 0
                        } else {
                            let d1n: i64 = n >> 1
                            let mut D1: i64 = 0
                            if hx < 0 || hx > d1n {
                                D1 = 0
                            } else {
                                D1 = fact[d1n] * invfact[hx] % MOD * invfact[d1n - hx] % MOD
                            }
                            let n2: i64 = n - X
                            if n2 % 2 == 0 && Y % 2 == 1 {
                                D = 0
                            } else {
                                let d2n: i64 = n2 >> 1
                                let mut D2: i64 = 0
                                if hy < 0 || hy > d2n {
                                    D2 = 0
                                } else {
                                    D2 = fact[d2n] * invfact[hy] % MOD * invfact[d2n - hy] % MOD
                                }
                                D = D1 * D2 % MOD
                            }
                        }

                        # sign: +1 if (hx+hy+hz) even else -1
                        let mut Nmod: i64 = 0
                        if (hx + hy + hz) % 2 == 0 {
                            Nmod = (T + D) % MOD
                        } else {
                            Nmod = (T - D) % MOD
                            if Nmod < 0 {
                                Nmod = Nmod + MOD
                            }
                        }

                        Nmod = Nmod * inv2 % MOD
                        total_sum = total_sum + Nmod
                        if total_sum >= MOD {
                            total_sum = total_sum - MOD
                        }
                        ck = ck + 1
                    }
                }
                bj = bj + 1
            }
        }
        ai = ai + 1
    }

    let answer: i64 = total_sum % MOD
    printf("%lld\n", answer)

    free(cubes)
    free(fact)
    free(invfact)
    free(halves)
    free(invf)
    free(par)
    return 0
}

Generated C

#include <stdint.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

/* Flow runtime helpers */
typedef struct flow_temp_node { struct flow_temp_node* next; } flow_temp_node;
static flow_temp_node* flow_temp_head = NULL;
static int flow_temp_atexit_set = 0;
__attribute__((unused)) static void flow_temp_free_all(void) {
    while (flow_temp_head) {
        flow_temp_node* n = flow_temp_head;
        flow_temp_head = n->next;
        free(n);
    }
}
__attribute__((unused)) static void* flow_temp_alloc(size_t nbytes) {
    flow_temp_node* node = (flow_temp_node*)malloc(sizeof(flow_temp_node) + nbytes);
    if (!node) return NULL;
    node->next = flow_temp_head;
    flow_temp_head = node;
    if (!flow_temp_atexit_set) {
        flow_temp_atexit_set = 1;
        atexit(flow_temp_free_all);
    }
    return (void*)(node + 1);
}
#ifndef FLOW_DIAG
#define FLOW_DIAG(msg) fprintf(stderr, "%s", (msg))
#endif
#ifndef FLOW_LOG
#define FLOW_LOG(fmt, ...) printf(fmt, __VA_ARGS__)
#endif
#ifndef FLOW_LOG_EMPTY
#define FLOW_LOG_EMPTY(fmt) printf(fmt)
#endif
static char* flow_strcat(const char* a, const char* b) {
    size_t la = strlen(a ? a : ""), lb = strlen(b ? b : "");
    char* r = (char*)flow_temp_alloc(la + lb + 1);
    if (!r) return NULL;
    if (la) memcpy(r, a, la);
    if (lb) memcpy(r + la, b, lb);
    r[la + lb] = '\0';
    return r;
}

#define __flow_in_arr(arr, val) __extension__ ({ \
    int _found = 0; \
    size_t _n = sizeof(arr)/sizeof((arr)[0]); \
    for (size_t _i = 0; _i < _n; _i++) { \
        if ((arr)[_i] == (val)) { _found = 1; break; } \
    } _found; })

/* Unified fault handler (MISRA #279) — override with -DFLOW_FAULT_HANDLER=fn */
#ifndef FLOW_FAULT_HANDLER
__attribute__((unused)) static inline void flow_fault_handler(const char* msg) {
    fprintf(stderr, "flow: %s\n", msg ? msg : "fault");
    abort();
#if defined(__GNUC__) || defined(__clang__)
    __builtin_unreachable();
#endif
}
#else
#define flow_fault_handler FLOW_FAULT_HANDLER
#endif
#define flow_div_by_zero_handler() flow_fault_handler("division by zero")
#define flow_shift_ub_handler() flow_fault_handler("invalid shift (amount out of range or left-shift of negative)")

#ifndef FLOW_CHECKED_DIV
#define FLOW_CHECKED_DIV(L, R) (((R) != 0) ? ((L) / (R)) : (flow_div_by_zero_handler(), (L) * 0))
#endif
#ifndef FLOW_CHECKED_MOD
#define FLOW_CHECKED_MOD(L, R) (((R) != 0) ? ((L) % (R)) : (flow_div_by_zero_handler(), (L) * 0))
#endif
#ifndef FLOW_CHECKED_SHL
#define FLOW_CHECKED_SHL(L, R) ((((R) >= 0) && ((unsigned long long)(R) < (sizeof(L) * 8ull)) && ((L) >= 0)) ? ((L) << (R)) : (flow_shift_ub_handler(), (L) * 0))
#endif
#ifndef FLOW_CHECKED_SHR
#define FLOW_CHECKED_SHR(L, R) ((((R) >= 0) && ((unsigned long long)(R) < (sizeof(L) * 8ull))) ? ((L) >> (R)) : (flow_shift_ub_handler(), (L) * 0))
#endif

#include <math.h>

void* _ui_state = NULL;

static inline float i32_to_f32(int32_t v) { return (float)v; }

/* Host stub for @gpu kernels (device codegen replaces this). */
static inline int32_t gpu_thread_id(void) { return 0; }

int64_t gcd_i64_i64(int64_t a0, int64_t b0);
int64_t lcm_i64_i64(int64_t a, int64_t b);
int64_t isqrt_i64(int64_t n);
int64_t mulmod_i64_i64_i64(int64_t a0, int64_t b0, int64_t mod);
int64_t mod_pow_i64_i64_i64(int64_t base, int64_t exp, int64_t mod);
bool is_prime_i64(int64_t n);
int32_t main(void);

static const int64_t MOD = 888888883;

int64_t gcd_i64_i64(int64_t a0, int64_t b0) {
    int64_t a = a0;
    int64_t b = b0;
    while (b != 0) {
        int64_t t = FLOW_CHECKED_MOD((a), (b));
        a = b;
        b = t;
    }
    return a;
}

int64_t lcm_i64_i64(int64_t a, int64_t b) {
    if ((a == 0 || b == 0)) {
        return 0;
    }
    return (FLOW_CHECKED_DIV((a), (gcd_i64_i64(a, b))) * b);
}

int64_t isqrt_i64(int64_t n) {
    if (n < 2) {
        return n;
    }
    int64_t x = n;
    int64_t y = FLOW_CHECKED_DIV(((x + 1)), (2));
    while (y < x) {
        x = y;
        y = FLOW_CHECKED_DIV(((x + FLOW_CHECKED_DIV((n), (x)))), (2));
    }
    return x;
}

int64_t mulmod_i64_i64_i64(int64_t a0, int64_t b0, int64_t mod) {
    int64_t a = FLOW_CHECKED_MOD((a0), (mod));
    int64_t b = FLOW_CHECKED_MOD((b0), (mod));
    int64_t result = 0;
    while (b > 0) {
        if (FLOW_CHECKED_MOD((b), (2)) == 1) {
            result = FLOW_CHECKED_MOD(((result + a)), (mod));
        }
        a = FLOW_CHECKED_MOD(((a * 2)), (mod));
        b = FLOW_CHECKED_DIV((b), (2));
    }
    return result;
}

int64_t mod_pow_i64_i64_i64(int64_t base, int64_t exp, int64_t mod) {
    if (mod == 1) {
        return 0;
    }
    int64_t result = 1;
    int64_t b = FLOW_CHECKED_MOD((base), (mod));
    int64_t e = exp;
    while (e > 0) {
        if (FLOW_CHECKED_MOD((e), (2)) == 1) {
            result = mulmod_i64_i64_i64(result, b, mod);
        }
        b = mulmod_i64_i64_i64(b, b, mod);
        e = FLOW_CHECKED_DIV((e), (2));
    }
    return result;
}

bool is_prime_i64(int64_t n) {
    if (n < 2) {
        return 0;
    }
    if (n < 4) {
        return 1;
    }
    if ((FLOW_CHECKED_MOD((n), (2)) == 0 || FLOW_CHECKED_MOD((n), (3)) == 0)) {
        return 0;
    }
    int64_t i = 5;
    while ((i * i) <= n) {
        if ((FLOW_CHECKED_MOD((n), (i)) == 0 || FLOW_CHECKED_MOD((n), ((i + 2))) == 0)) {
            return 0;
        }
        i = (i + 6);
    }
    return 1;
}




int32_t main(void) {
    int32_t NC = 88;
    int64_t* cubes = (int64_t*)(malloc((((int64_t)(NC)) * 8)));
    int32_t i = 0;
    while (i < NC) {
        int64_t ii = ((int64_t)(i));
        cubes[i] = ((ii * ii) * ii);
        i = (i + 1);
    }
    int64_t max_n = (3 * cubes[(NC - 1)]);
    int64_t* fact = (int64_t*)(malloc(((max_n + 1) * 8)));
    int64_t* invfact = (int64_t*)(malloc(((max_n + 1) * 8)));
    fact[0] = FLOW_CHECKED_MOD((1), (MOD));
    int64_t i1 = 1;
    while (i1 <= max_n) {
        fact[i1] = FLOW_CHECKED_MOD(((fact[(i1 - 1)] * FLOW_CHECKED_MOD((i1), (MOD)))), (MOD));
        i1 = (i1 + 1);
    }
    invfact[max_n] = mod_pow_i64_i64_i64(fact[max_n], (MOD - 2), MOD);
    int64_t i2 = max_n;
    while (i2 >= 1) {
        invfact[(i2 - 1)] = FLOW_CHECKED_MOD(((invfact[i2] * FLOW_CHECKED_MOD((i2), (MOD)))), (MOD));
        i2 = (i2 - 1);
    }
    int64_t inv2 = FLOW_CHECKED_DIV(((MOD + 1)), (2));
    int64_t* halves = (int64_t*)(malloc((((int64_t)(NC)) * 8)));
    int64_t* invf = (int64_t*)(malloc((((int64_t)(NC)) * 8)));
    int32_t* par = (int32_t*)(malloc((((int64_t)(NC)) * 4)));
    int32_t i3 = 0;
    while (i3 < NC) {
        halves[i3] = FLOW_CHECKED_SHR((cubes[i3]), (1));
        invf[i3] = invfact[cubes[i3]];
        par[i3] = FLOW_CHECKED_MOD((i3), (2));
        i3 = (i3 + 1);
    }
    int64_t total_sum = 0;
    int32_t ai = 0;
    while (ai < NC) {
        int64_t X = cubes[ai];
        int64_t hx = halves[ai];
        int64_t invX = invf[ai];
        int32_t px = par[ai];
        int32_t bj = 0;
        while (bj < NC) {
            int64_t Y = cubes[bj];
            int64_t hy = halves[bj];
            int64_t invY = invf[bj];
            int32_t py = par[bj];
            if (px != py) {
                bj = (bj + 1);
            } else {
                int32_t ck = 0;
                while (ck < NC) {
                    if (py != par[ck]) {
                        ck = (ck + 1);
                    } else {
                        int64_t Z = cubes[ck];
                        int64_t hz = halves[ck];
                        int64_t invZ = invf[ck];
                        int64_t n = ((X + Y) + Z);
                        int64_t T = fact[n];
                        T = FLOW_CHECKED_MOD(((T * invX)), (MOD));
                        T = FLOW_CHECKED_MOD(((T * invY)), (MOD));
                        T = FLOW_CHECKED_MOD(((T * invZ)), (MOD));
                        int64_t D = 0;
                        if ((FLOW_CHECKED_MOD((n), (2)) == 0 && FLOW_CHECKED_MOD((X), (2)) == 1)) {
                            D = 0;
                        } else {
                            int64_t d1n = FLOW_CHECKED_SHR((n), (1));
                            int64_t D1 = 0;
                            if ((hx < 0 || hx > d1n)) {
                                D1 = 0;
                            } else {
                                D1 = FLOW_CHECKED_MOD(((FLOW_CHECKED_MOD(((fact[d1n] * invfact[hx])), (MOD)) * invfact[(d1n - hx)])), (MOD));
                            }
                            int64_t n2 = (n - X);
                            if ((FLOW_CHECKED_MOD((n2), (2)) == 0 && FLOW_CHECKED_MOD((Y), (2)) == 1)) {
                                D = 0;
                            } else {
                                int64_t d2n = FLOW_CHECKED_SHR((n2), (1));
                                int64_t D2 = 0;
                                if ((hy < 0 || hy > d2n)) {
                                    D2 = 0;
                                } else {
                                    D2 = FLOW_CHECKED_MOD(((FLOW_CHECKED_MOD(((fact[d2n] * invfact[hy])), (MOD)) * invfact[(d2n - hy)])), (MOD));
                                }
                                D = FLOW_CHECKED_MOD(((D1 * D2)), (MOD));
                            }
                        }
                        int64_t Nmod = 0;
                        if (FLOW_CHECKED_MOD((((hx + hy) + hz)), (2)) == 0) {
                            Nmod = FLOW_CHECKED_MOD(((T + D)), (MOD));
                        } else {
                            Nmod = FLOW_CHECKED_MOD(((T - D)), (MOD));
                            if (Nmod < 0) {
                                Nmod = (Nmod + MOD);
                            }
                        }
                        Nmod = FLOW_CHECKED_MOD(((Nmod * inv2)), (MOD));
                        total_sum = (total_sum + Nmod);
                        if (total_sum >= MOD) {
                            total_sum = (total_sum - MOD);
                        }
                        ck = (ck + 1);
                    }
                }
                bj = (bj + 1);
            }
        }
        ai = (ai + 1);
    }
    int64_t answer = FLOW_CHECKED_MOD((total_sum), (MOD));
    printf("%lld\n", answer);
    free(cubes);
    free(fact);
    free(invfact);
    free(halves);
    free(invf);
    free(par);
    return 0;
}

Generated MLIR

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