Problem 611

Count n <= N where #representations n = a^2+b^2 (0<a<b) is odd. Uses Lucy sieve for pi(x) and chi_sum(x).

Answer49283233900
Output49283233900
StatusPASS
Native helperno
Runtime1190 ms
Peak memory71536 KB
Time complexityO(n^2) (estimated)
Space complexityO(n^2) (estimated)

Performance comparison

MetricOur solutionBest known
Time complexityO(n^2)O(n log log n)
Space complexityO(n^2)O(n)
ApproachFlow solutionSieve-based representation count
VerdictSuboptimal

Flow source

# Project Euler 611: Hallway of Square Steps
# Count n <= N where #representations n = a^2+b^2 (0<a<b) is odd.
# Uses Lucy sieve for pi(x) and chi_sum(x).

import euler.nt { isqrt }

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

const N: i64 = 1000000000000  # 10^12

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

    # Build SPF sieve up to root
    let spf: ptr<i64> = calloc(root + 1, 8)
    for i in 0..(root + 1) { spf[i] = i }
    for i in 2..(isqrt(root) + 1) {
        if spf[i] == i {
            let mut j: i64 = (i as i64) * (i as i64)
            while j <= root {
                if spf[j] == j { spf[j] = i }
                j = j + i
            }
        }
    }

    # Build pi1_small prefix: pi1[x] = count of primes <= x with p ≡ 1 (mod 4)
    let pi1_small: ptr<i64> = calloc(root + 1, 8)
    let mut c: i64 = 0
    for x in 2..(root + 1) {
        if spf[x] == x && (x & 3) == 1 { c = c + 1 }
        pi1_small[x] = c
    }

    # Build Lucy sieve tables
    # vals: descending distinct floor(N/i)
    let vals: ptr<i64> = calloc(2 * root + 10, 8)
    let mut m: i64 = 0
    let mut i_val: i64 = 1
    while i_val <= N {
        let q: i64 = N / i_val
        vals[m] = q
        m = m + 1
        i_val = N / q + 1
    }

    # idx_big: for v > root, idx_big[N/v] = index in vals
    let idx_big: ptr<i64> = calloc(root + 1, 8)
    for idx in 0..m {
        let v: i64 = vals[idx]
        if v > root {
            idx_big[N / v] = idx
        }
    }

    # Initialize pi and schi
    let pi_tab: ptr<i64> = calloc(m, 8)
    let schi_tab: ptr<i64> = calloc(m, 8)
    for j in 0..m {
        let v: i64 = vals[j]
        if v >= 2 { pi_tab[j] = v - 1 } else { pi_tab[j] = 0 }
        # S_int(v) = count(1 mod4) - count(3 mod4) for n=1..v
        # = ((v+3)/4) - ((v+1)/4)
        let s_int: i64 = (v + 3) / 4 - (v + 1) / 4
        schi_tab[j] = s_int - 1  # exclude n=1
    }

    # Lucy sieve: for each prime p up to sqrt(N)
    for p in 2..(root + 1) {
        if spf[p] != p { continue }
        let p2: i64 = (p as i64) * (p as i64)
        if p2 > N { break }

        # k = upper_bound(p2) = number of vals >= p2
        # vals is descending, find first index where vals[idx] < p2
        let mut k: i64 = 0
        let mut lo_k: i64 = 0
        let mut hi_k: i64 = m
        while lo_k < hi_k {
            let mid: i64 = (lo_k + hi_k) / 2
            if vals[mid] >= p2 { lo_k = mid + 1 } else { hi_k = mid }
        }
        k = lo_k
        if k == 0 { continue }

        # base values at p-1
        let base_idx: i64 = m - (p - 1)
        let base_pi: i64 = pi_tab[base_idx]
        let base_s: i64 = schi_tab[base_idx]

        # chi(p)
        let chi_p: i64
        if p == 2 { chi_p = 0 } else {
            if (p & 3) == 1 { chi_p = 1 } else { chi_p = -1 }
        }

        for j in 0..k {
            let v: i64 = vals[j]
            let vp: i64 = v / p
            let idx_vp: i64
            if vp <= root {
                idx_vp = m - vp
            } else {
                idx_vp = idx_big[N / vp]
            }

            pi_tab[j] = pi_tab[j] - (pi_tab[idx_vp] - base_pi)
            if chi_p != 0 {
                schi_tab[j] = schi_tab[j] - chi_p * (schi_tab[idx_vp] - base_s)
            }
        }
    }

    # pi1_query function (inline)
    # For x <= root: pi1_small[x]
    # For x > root: (pi_tab[idx] - 1 + schi_tab[idx]) / 2

    # Enumerate odd u from 1 to root
    let mut total: i64 = 0

    # Temp buffer for excluded primes
    let excluded: ptr<i64> = calloc(20, 8)

    let mut u: i64 = 1
    while u <= root {
        if u % 2 == 0 {
            u = u + 1
            continue
        }

        let u2: i64 = u * u
        let max2: i64 = N / u2

        # Factor u using SPF, compute parity and excluded primes
        let mut parity: i64 = 0
        let mut n_excl: i64 = 0
        let mut x: i64 = u
        while x > 1 {
            let p: i64 = spf[x]
            let mut odd_exp: i64 = 0
            while x % p == 0 {
                x = x / p
                odd_exp = odd_exp ^ 1
            }
            if odd_exp == 1 && (p & 3) == 1 {
                parity = parity ^ 1
                excluded[n_excl] = p
                n_excl = n_excl + 1
            }
        }

        # Case A: parity is odd -> add bit_length(max2)
        if parity == 1 {
            # Count k >= 0 with 2^k <= max2
            let mut bl: i64 = 0
            let mut tmp2: i64 = max2
            while tmp2 > 0 { bl = bl + 1; tmp2 = tmp2 >> 1 }
            total = total + bl
        }

        # Case B: n = 2^k * p * u^2, p ≡ 1 (mod4), p not in excluded
        let mut xv: i64 = max2
        while xv >= 5 {
            # pi1_query(xv)
            let cnt: i64
            if xv <= root {
                cnt = pi1_small[xv]
            } else {
                let idx: i64 = idx_big[N / xv]
                let pi_x: i64 = pi_tab[idx]
                let s_x: i64 = schi_tab[idx]
                cnt = (pi_x - 1 + s_x) / 2
            }

            # Subtract excluded primes <= xv
            let mut ex: i64 = 0
            for ei in 0..n_excl {
                if excluded[ei] <= xv { ex = ex + 1 }
            }

            total = total + cnt - ex
            xv = xv / 2
        }
        u = u + 1
    }

    printf("%lld\n", total)

    free(excluded)
    free(schi_tab)
    free(pi_tab)
    free(idx_big)
    free(vals)
    free(pi1_small)
    free(spf)
    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 N = 1000000000000;

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) {
    int64_t root = isqrt_i64(N);
    int64_t* spf = (int64_t*)(calloc((root + 1), 8));
    int32_t __flow_step_1 = 1;
    for (int32_t i = 0; (0 <= (root + 1)) ? i < (root + 1) : i > (root + 1); i += (0 <= (root + 1)) ? 1 : -1) {
        spf[i] = i;
    }
    int32_t __flow_step_2 = 1;
    for (int32_t i = 2; (2 <= (isqrt_i64(root) + 1)) ? i < (isqrt_i64(root) + 1) : i > (isqrt_i64(root) + 1); i += (2 <= (isqrt_i64(root) + 1)) ? 1 : -1) {
        if (spf[i] == i) {
            int64_t j = (((int64_t)(i)) * ((int64_t)(i)));
            while (j <= root) {
                if (spf[j] == j) {
                    spf[j] = i;
                }
                j = (j + i);
            }
        }
    }
    int64_t* pi1_small = (int64_t*)(calloc((root + 1), 8));
    int64_t c = 0;
    int32_t __flow_step_3 = 1;
    for (int32_t x = 2; (2 <= (root + 1)) ? x < (root + 1) : x > (root + 1); x += (2 <= (root + 1)) ? 1 : -1) {
        if ((spf[x] == x && (x & 3) == 1)) {
            c = (c + 1);
        }
        pi1_small[x] = c;
    }
    int64_t* vals = (int64_t*)(calloc(((2 * root) + 10), 8));
    int64_t m = 0;
    int64_t i_val = 1;
    while (i_val <= N) {
        int64_t q = FLOW_CHECKED_DIV((N), (i_val));
        vals[m] = q;
        m = (m + 1);
        i_val = (FLOW_CHECKED_DIV((N), (q)) + 1);
    }
    int64_t* idx_big = (int64_t*)(calloc((root + 1), 8));
    int32_t __flow_step_4 = 1;
    for (int32_t idx = 0; (0 <= m) ? idx < m : idx > m; idx += (0 <= m) ? 1 : -1) {
        int64_t v = vals[idx];
        if (v > root) {
            idx_big[FLOW_CHECKED_DIV((N), (v))] = idx;
        }
    }
    int64_t* pi_tab = (int64_t*)(calloc(m, 8));
    int64_t* schi_tab = (int64_t*)(calloc(m, 8));
    int32_t __flow_step_5 = 1;
    for (int32_t j = 0; (0 <= m) ? j < m : j > m; j += (0 <= m) ? 1 : -1) {
        int64_t v = vals[j];
        if (v >= 2) {
            pi_tab[j] = (v - 1);
        } else {
            pi_tab[j] = 0;
        }
        int64_t s_int = (FLOW_CHECKED_DIV(((v + 3)), (4)) - FLOW_CHECKED_DIV(((v + 1)), (4)));
        schi_tab[j] = (s_int - 1);
    }
    int32_t __flow_step_6 = 1;
    for (int32_t p = 2; (2 <= (root + 1)) ? p < (root + 1) : p > (root + 1); p += (2 <= (root + 1)) ? 1 : -1) {
        if (spf[p] != p) {
            continue;
        }
        int64_t p2 = (((int64_t)(p)) * ((int64_t)(p)));
        if (p2 > N) {
            break;
        }
        int64_t k = 0;
        int64_t lo_k = 0;
        int64_t hi_k = m;
        while (lo_k < hi_k) {
            int64_t mid = FLOW_CHECKED_DIV(((lo_k + hi_k)), (2));
            if (vals[mid] >= p2) {
                lo_k = (mid + 1);
            } else {
                hi_k = mid;
            }
        }
        k = lo_k;
        if (k == 0) {
            continue;
        }
        int64_t base_idx = (m - (p - 1));
        int64_t base_pi = pi_tab[base_idx];
        int64_t base_s = schi_tab[base_idx];
        int64_t chi_p;
        if (p == 2) {
            chi_p = 0;
        } else {
            if ((p & 3) == 1) {
                chi_p = 1;
            } else {
                chi_p = (-1);
            }
        }
        int32_t __flow_step_7 = 1;
        for (int32_t j = 0; (0 <= k) ? j < k : j > k; j += (0 <= k) ? 1 : -1) {
            int64_t v = vals[j];
            int64_t vp = FLOW_CHECKED_DIV((v), (p));
            int64_t idx_vp;
            if (vp <= root) {
                idx_vp = (m - vp);
            } else {
                idx_vp = idx_big[FLOW_CHECKED_DIV((N), (vp))];
            }
            pi_tab[j] = (pi_tab[j] - (pi_tab[idx_vp] - base_pi));
            if (chi_p != 0) {
                schi_tab[j] = (schi_tab[j] - (chi_p * (schi_tab[idx_vp] - base_s)));
            }
        }
    }
    int64_t total = 0;
    int64_t* excluded = (int64_t*)(calloc(20, 8));
    int64_t u = 1;
    while (u <= root) {
        if (FLOW_CHECKED_MOD((u), (2)) == 0) {
            u = (u + 1);
            continue;
        }
        int64_t u2 = (u * u);
        int64_t max2 = FLOW_CHECKED_DIV((N), (u2));
        int64_t parity = 0;
        int64_t n_excl = 0;
        int64_t x = u;
        while (x > 1) {
            int64_t p = spf[x];
            int64_t odd_exp = 0;
            while (FLOW_CHECKED_MOD((x), (p)) == 0) {
                x = FLOW_CHECKED_DIV((x), (p));
                odd_exp = (odd_exp ^ 1);
            }
            if ((odd_exp == 1 && (p & 3) == 1)) {
                parity = (parity ^ 1);
                excluded[n_excl] = p;
                n_excl = (n_excl + 1);
            }
        }
        if (parity == 1) {
            int64_t bl = 0;
            int64_t tmp2 = max2;
            while (tmp2 > 0) {
                bl = (bl + 1);
                tmp2 = FLOW_CHECKED_SHR((tmp2), (1));
            }
            total = (total + bl);
        }
        int64_t xv = max2;
        while (xv >= 5) {
            int64_t cnt;
            if (xv <= root) {
                cnt = pi1_small[xv];
            } else {
                int64_t idx = idx_big[FLOW_CHECKED_DIV((N), (xv))];
                int64_t pi_x = pi_tab[idx];
                int64_t s_x = schi_tab[idx];
                cnt = FLOW_CHECKED_DIV((((pi_x - 1) + s_x)), (2));
            }
            int64_t ex = 0;
            int32_t __flow_step_8 = 1;
            for (int32_t ei = 0; (0 <= n_excl) ? ei < n_excl : ei > n_excl; ei += (0 <= n_excl) ? 1 : -1) {
                if (excluded[ei] <= xv) {
                    ex = (ex + 1);
                }
            }
            total = ((total + cnt) - ex);
            xv = FLOW_CHECKED_DIV((xv), (2));
        }
        u = (u + 1);
    }
    printf("%lld\n", total);
    free(excluded);
    free(schi_tab);
    free(pi_tab);
    free(idx_big);
    free(vals);
    free(pi1_small);
    free(spf);
    return 0;
}

Generated MLIR

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