Problem 143

Sum of distinct p+q+r ≤ 120000 for Torricelli triangles.

Answer30758397
Output30758397
StatusPASS
Native helperno
Runtime70 ms
Peak memory14528 KB
Time complexityO(n^4) (estimated)
Space complexityO(n^2) (estimated)

Performance comparison

MetricOur solutionBest known
Time complexityO(n^4)O(n^2)
Space complexityO(n^2)O(n^2)
ApproachFlow solutionBottom-up DP
VerdictSuboptimal

Flow source

# Project Euler 143
# Sum of distinct p+q+r ≤ 120000 for Torricelli triangles.

import euler.nt { gcd, isqrt }

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

function main() -> i32 {
    let limit: i64 = 120000
    let emax: i64 = 500000
    let eu: ptr<i64> = calloc(emax, 8)
    let ev: ptr<i64> = calloc(emax, 8)
    if eu == null || ev == null { return 1 }
    let mut ec: i64 = 0

    let M: i64 = isqrt(limit) + 2
    let mut m: i64 = 2
    while m <= M {
        let mm: i64 = m * m
        let mut n: i64 = 1
        while n < m {
            if gcd(m, n) == 1 && (m - n) % 3 != 0 {
                let nn: i64 = n * n
                let x0: i64 = mm - nn
                let y0: i64 = 2 * m * n + nn
                let mut max0: i64 = x0
                if y0 > max0 { max0 = y0 }
                if max0 > 0 {
                    let kmax: i64 = limit / max0
                    let mut k: i64 = 1
                    while k <= kmax {
                        let a: i64 = x0 * k
                        let b: i64 = y0 * k
                        if a != b && ec + 2 < emax {
                            eu[ec] = a
                            ev[ec] = b
                            ec = ec + 1
                            eu[ec] = b
                            ev[ec] = a
                            ec = ec + 1
                        }
                        k = k + 1
                    }
                }
            }
            n = n + 1
        }
        m = m + 1
    }

    # sort edges by (u,v) - shell sort
    let mut gap: i64 = ec / 2
    while gap > 0 {
        let mut i: i64 = gap
        while i < ec {
            let ku: i64 = eu[i]
            let kv: i64 = ev[i]
            let mut j: i64 = i
            while j >= gap && (eu[j - gap] > ku || (eu[j - gap] == ku && ev[j - gap] > kv)) {
                eu[j] = eu[j - gap]
                ev[j] = ev[j - gap]
                j = j - gap
            }
            eu[j] = ku
            ev[j] = kv
            i = i + 1
        }
        gap = gap / 2
    }

    # unique edges
    let mut wri: i64 = 0
    let mut i: i64 = 0
    while i < ec {
        if wri == 0 || eu[i] != eu[wri - 1] || ev[i] != ev[wri - 1] {
            eu[wri] = eu[i]
            ev[wri] = ev[i]
            wri = wri + 1
        }
        i = i + 1
    }
    ec = wri

    # CSR: nodes are values 1..limit; degree then offsets
    let deg: ptr<i32> = calloc(limit + 1, 4)
    if deg == null { return 1 }
    i = 0
    while i < ec {
        deg[eu[i]] = deg[eu[i]] + 1
        i = i + 1
    }
    let off: ptr<i64> = calloc(limit + 2, 8)
    if off == null { return 1 }
    off[0] = 0
    let mut u: i64 = 0
    while u <= limit {
        off[u + 1] = off[u] + (deg[u] as i64)
        u = u + 1
    }
    let adj: ptr<i64> = calloc(ec + 1, 8)
    let fill: ptr<i64> = calloc(limit + 1, 8)
    if adj == null || fill == null { return 1 }
    i = 0
    while i <= limit {
        fill[i] = off[i]
        i = i + 1
    }
    i = 0
    while i < ec {
        let uu: i64 = eu[i]
        let pos: i64 = fill[uu]
        adj[pos] = ev[i]
        fill[uu] = pos + 1
        i = i + 1
    }
    # sort each adjacency list
    u = 1
    while u <= limit {
        let lo: i64 = off[u]
        let hi: i64 = off[u + 1]
        let len: i64 = hi - lo
        if len > 1 {
            let mut g: i64 = len / 2
            while g > 0 {
                let mut ii: i64 = g
                while ii < len {
                    let v: i64 = adj[lo + ii]
                    let mut jj: i64 = ii
                    while jj >= g && adj[lo + jj - g] > v {
                        adj[lo + jj] = adj[lo + jj - g]
                        jj = jj - g
                    }
                    adj[lo + jj] = v
                    ii = ii + 1
                }
                g = g / 2
            }
        }
        u = u + 1
    }

    # mark sums with a byte array
    let seen: ptr<i8> = calloc(limit + 1, 1)
    if seen == null { return 1 }
    let mut total: i64 = 0

    u = 1
    while u <= limit {
        let lo: i64 = off[u]
        let hi: i64 = off[u + 1]
        let mut a: i64 = lo
        while a < hi {
            let q: i64 = adj[a]
            if q > u {
                let pq: i64 = u + q
                if pq < limit {
                    # intersect neighbors of u (from a+1) with neighbors of q
                    let qlo: i64 = off[q]
                    let qhi: i64 = off[q + 1]
                    let mut i1: i64 = a + 1
                    let mut i2: i64 = qlo
                    while i1 < hi && i2 < qhi {
                        let r1: i64 = adj[i1]
                        let r2: i64 = adj[i2]
                        if r1 == r2 {
                            let s: i64 = pq + r1
                            if s <= limit && r1 > q {
                                if seen[s] == 0 {
                                    seen[s] = 1
                                    total = total + s
                                }
                            }
                            i1 = i1 + 1
                            i2 = i2 + 1
                        } elif r1 < r2 {
                            i1 = i1 + 1
                        } else {
                            i2 = i2 + 1
                        }
                    }
                }
            }
            a = a + 1
        }
        u = u + 1
    }

    printf("%lld\n", total)
    free(seen)
    free(fill)
    free(adj)
    free(off)
    free(deg)
    free(ev)
    free(eu)
    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);

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 limit = 120000;
    int64_t emax = 500000;
    int64_t* eu = (int64_t*)(calloc(emax, 8));
    int64_t* ev = (int64_t*)(calloc(emax, 8));
    if ((eu == NULL || ev == NULL)) {
        return 1;
    }
    int64_t ec = 0;
    int64_t M = (isqrt_i64(limit) + 2);
    int64_t m = 2;
    while (m <= M) {
        int64_t mm = (m * m);
        int64_t n = 1;
        while (n < m) {
            if ((gcd_i64_i64(m, n) == 1 && FLOW_CHECKED_MOD(((m - n)), (3)) != 0)) {
                int64_t nn = (n * n);
                int64_t x0 = (mm - nn);
                int64_t y0 = (((2 * m) * n) + nn);
                int64_t max0 = x0;
                if (y0 > max0) {
                    max0 = y0;
                }
                if (max0 > 0) {
                    int64_t kmax = FLOW_CHECKED_DIV((limit), (max0));
                    int64_t k = 1;
                    while (k <= kmax) {
                        int64_t a = (x0 * k);
                        int64_t b = (y0 * k);
                        if ((a != b && (ec + 2) < emax)) {
                            eu[ec] = a;
                            ev[ec] = b;
                            ec = (ec + 1);
                            eu[ec] = b;
                            ev[ec] = a;
                            ec = (ec + 1);
                        }
                        k = (k + 1);
                    }
                }
            }
            n = (n + 1);
        }
        m = (m + 1);
    }
    int64_t gap = FLOW_CHECKED_DIV((ec), (2));
    while (gap > 0) {
        int64_t i = gap;
        while (i < ec) {
            int64_t ku = eu[i];
            int64_t kv = ev[i];
            int64_t j = i;
            while ((j >= gap && (eu[(j - gap)] > ku || (eu[(j - gap)] == ku && ev[(j - gap)] > kv)))) {
                eu[j] = eu[(j - gap)];
                ev[j] = ev[(j - gap)];
                j = (j - gap);
            }
            eu[j] = ku;
            ev[j] = kv;
            i = (i + 1);
        }
        gap = FLOW_CHECKED_DIV((gap), (2));
    }
    int64_t wri = 0;
    int64_t i = 0;
    while (i < ec) {
        if (((wri == 0 || eu[i] != eu[(wri - 1)]) || ev[i] != ev[(wri - 1)])) {
            eu[wri] = eu[i];
            ev[wri] = ev[i];
            wri = (wri + 1);
        }
        i = (i + 1);
    }
    ec = wri;
    int32_t* deg = (int32_t*)(calloc((limit + 1), 4));
    if (deg == NULL) {
        return 1;
    }
    i = 0;
    while (i < ec) {
        deg[eu[i]] = (deg[eu[i]] + 1);
        i = (i + 1);
    }
    int64_t* off = (int64_t*)(calloc((limit + 2), 8));
    if (off == NULL) {
        return 1;
    }
    off[0] = 0;
    int64_t u = 0;
    while (u <= limit) {
        off[(u + 1)] = (off[u] + ((int64_t)(deg[u])));
        u = (u + 1);
    }
    int64_t* adj = (int64_t*)(calloc((ec + 1), 8));
    int64_t* fill = (int64_t*)(calloc((limit + 1), 8));
    if ((adj == NULL || fill == NULL)) {
        return 1;
    }
    i = 0;
    while (i <= limit) {
        fill[i] = off[i];
        i = (i + 1);
    }
    i = 0;
    while (i < ec) {
        int64_t uu = eu[i];
        int64_t pos = fill[uu];
        adj[pos] = ev[i];
        fill[uu] = (pos + 1);
        i = (i + 1);
    }
    u = 1;
    while (u <= limit) {
        int64_t lo = off[u];
        int64_t hi = off[(u + 1)];
        int64_t len = (hi - lo);
        if (len > 1) {
            int64_t g = FLOW_CHECKED_DIV((len), (2));
            while (g > 0) {
                int64_t ii = g;
                while (ii < len) {
                    int64_t v = adj[(lo + ii)];
                    int64_t jj = ii;
                    while ((jj >= g && adj[((lo + jj) - g)] > v)) {
                        adj[(lo + jj)] = adj[((lo + jj) - g)];
                        jj = (jj - g);
                    }
                    adj[(lo + jj)] = v;
                    ii = (ii + 1);
                }
                g = FLOW_CHECKED_DIV((g), (2));
            }
        }
        u = (u + 1);
    }
    int8_t* seen = (int8_t*)(calloc((limit + 1), 1));
    if (seen == NULL) {
        return 1;
    }
    int64_t total = 0;
    u = 1;
    while (u <= limit) {
        int64_t lo = off[u];
        int64_t hi = off[(u + 1)];
        int64_t a = lo;
        while (a < hi) {
            int64_t q = adj[a];
            if (q > u) {
                int64_t pq = (u + q);
                if (pq < limit) {
                    int64_t qlo = off[q];
                    int64_t qhi = off[(q + 1)];
                    int64_t i1 = (a + 1);
                    int64_t i2 = qlo;
                    while ((i1 < hi && i2 < qhi)) {
                        int64_t r1 = adj[i1];
                        int64_t r2 = adj[i2];
                        if (r1 == r2) {
                            int64_t s = (pq + r1);
                            if ((s <= limit && r1 > q)) {
                                if (seen[s] == 0) {
                                    seen[s] = 1;
                                    total = (total + s);
                                }
                            }
                            i1 = (i1 + 1);
                            i2 = (i2 + 1);
                        } else if (r1 < r2) {
                            i1 = (i1 + 1);
                        } else {
                            i2 = (i2 + 1);
                        }
                    }
                }
            }
            a = (a + 1);
        }
        u = (u + 1);
    }
    printf("%lld\n", total);
    free(seen);
    free(fill);
    free(adj);
    free(off);
    free(deg);
    free(ev);
    free(eu);
    return 0;
}

Generated MLIR

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