Problem 681

Uses Brahmagupta's formula. SP(n) = sum of perimeters of cyclic quadrilaterals with integer area k <= n.

Answer2611227421428
Output2611227421428
StatusPASS
Native helperno
Runtime14480 ms
Peak memory9056 KB
Time complexityO(n^4) (estimated)
Space complexityO(n^2) (estimated)

Performance comparison

MetricOur solutionBest known
Time complexityO(n^4)O(n * m)
Space complexityO(n^2)O(n)
ApproachFlow solutionDynamic programming or generating function
VerdictUnknown

Flow source

# Project Euler 681: Maximal Area
# Uses Brahmagupta's formula. SP(n) = sum of perimeters of cyclic quadrilaterals
# with integer area k <= n.

import euler.nt { isqrt }

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

# Hardware-sqrt integer square root (faster than Newton iteration).
function isq(n: i64) -> i64 {
    if n <= 0 { return 0 }
    let r: i64 = sqrt(n as f64) as i64
    while r > 0 && r * r > n { r = r - 1 }
    while (r + 1) * (r + 1) <= n { r = r + 1 }
    return r
}

function sift_down(a: ptr<i64>, start: i64, end: i64) -> void {
    let mut root: i64 = start
    while 2 * root + 1 <= end {
        let mut child: i64 = 2 * root + 1
        if child + 1 <= end {
            if a[child] < a[child + 1] { child = child + 1 }
        }
        if a[root] < a[child] {
            let t: i64 = a[root]
            a[root] = a[child]
            a[child] = t
            root = child
        } else {
            return
        }
    }
}

function heapsort_i64(a: ptr<i64>, n: i64) -> void {
    if n < 2 { return }
    let mut start: i64 = n / 2 - 1
    while start >= 0 {
        sift_down(a, start, n - 1)
        start = start - 1
    }
    let mut end: i64 = n - 1
    while end > 0 {
        let t: i64 = a[0]
        a[0] = a[end]
        a[end] = t
        end = end - 1
        sift_down(a, 0, end)
    }
}

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

    # Build SPF sieve up to n
    let spf: ptr<i64> = calloc(n + 1, 8)
    if spf == null { return 1 }
    for i in 0..(n + 1) { spf[i] = i }

    let root: i64 = isqrt(n)
    for i in 2..(root + 1) {
        if spf[i] == i {
            let start: i64 = i * i
            let mut j: i64 = start
            while j <= n {
                if spf[j] == j { spf[j] = i }
                j = j + i
            }
        }
    }

    # Divisor buffer (max divisors of k^2 is small, ~240 for k<=10^6)
    let max_divs: i64 = 2000
    let divs: ptr<i64> = calloc(max_divs, 8)
    if divs == null { return 1 }

    # Temp factorization buffer
    let max_primes: i64 = 20
    let fac_p: ptr<i64> = calloc(max_primes, 8)
    let fac_e: ptr<i64> = calloc(max_primes, 8)

    let mut total: i64 = 0

    let mut k: i64 = 1
    while k <= n {
        let k2: i64 = k * k

        # Factorize k
        let mut nfac: i64 = 0
        let mut x: i64 = k
        while x > 1 {
            let p: i64 = spf[x]
            let mut e: i64 = 0
            while x % p == 0 {
                x = x / p
                e = e + 1
            }
            fac_p[nfac] = p
            fac_e[nfac] = e
            nfac = nfac + 1
        }

        # Generate all divisors of k^2 that are <= k
        # k^2 has exponents 2*e for each prime
        divs[0] = 1
        let mut ndivs: i64 = 1

        for fi in 0..nfac {
            let p: i64 = fac_p[fi]
            let e2: i64 = 2 * fac_e[fi]
            let old_count: i64 = ndivs

            # Generate powers p^1, p^2, ..., p^(2e)
            let mut pe: i64 = 1
            for _ in 0..e2 {
                pe = pe * p
                for di in 0..old_count {
                    let v: i64 = divs[di] * pe
                    if v <= k {
                        divs[ndivs] = v
                        ndivs = ndivs + 1
                        if ndivs >= max_divs { return 1 }
                    }
                }
            }
        }

        # Sort divs (heapsort — O(d log d) vs O(d^2) insertion sort).
        heapsort_i64(divs, ndivs)

        let dlen: i64 = ndivs

        # Iterate over T, W, V
        for ti in 0..dlen {
            let T: i64 = divs[ti]
            if T * T > k { break }

            let k2_div_T: i64 = k2 / T

            for wi in ti..dlen {
                let W: i64 = divs[wi]
                if W * W * W > k2_div_T { break }

                if k2_div_T % W != 0 { continue }

                let R: i64 = k2_div_T / W
                let mut vmax: i64 = isq(R)
                if vmax < W { break }
                if vmax > k { vmax = k }

                let S: i64 = W + T
                # disc = S^2 + 4*R
                let disc: i64 = S * S + 4 * R
                let rt: i64 = isq(disc)
                let mut vmin: i64 = (rt - S) / 2 + 1
                if vmin < W { vmin = W }
                if vmin > vmax { continue }

                # Binary search for first divs[vi] >= vmin
                let mut lo: i64 = wi
                let mut hi: i64 = dlen
                while lo < hi {
                    let mid: i64 = (lo + hi) / 2
                    if divs[mid] < vmin { lo = mid + 1 }
                    else { hi = mid }
                }

                for vi in lo..dlen {
                    let V: i64 = divs[vi]
                    if V > vmax { break }
                    if R % V != 0 { continue }

                    let U: i64 = R / V
                    if U < V { continue }
                    if U >= V + S { continue }

                    let p: i64 = U + V + S
                    if p % 2 != 0 { continue }

                    total = total + p
                }
            }
        }
        k = k + 1
    }

    printf("%lld\n", total)

    free(fac_e)
    free(fac_p)
    free(divs)
    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);
int64_t isq_i64(int64_t n);
void sift_down_ptr_i64_i64_i64(int64_t* a, int64_t start, int64_t end);
void heapsort_i64_ptr_i64_i64(int64_t* a, 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;
}




int64_t isq_i64(int64_t n) {
    if (n <= 0) {
        return 0;
    }
    int64_t r = ((int64_t)(sqrt(((double)(n)))));
    while ((r > 0 && (r * r) > n)) {
        r = (r - 1);
    }
    while (((r + 1) * (r + 1)) <= n) {
        r = (r + 1);
    }
    return r;
}

void sift_down_ptr_i64_i64_i64(int64_t* a, int64_t start, int64_t end) {
    int64_t root = start;
    while (((2 * root) + 1) <= end) {
        int64_t child = ((2 * root) + 1);
        if ((child + 1) <= end) {
            if (a[child] < a[(child + 1)]) {
                child = (child + 1);
            }
        }
        if (a[root] < a[child]) {
            int64_t t = a[root];
            a[root] = a[child];
            a[child] = t;
            root = child;
        } else {
            return;
        }
    }
}

void heapsort_i64_ptr_i64_i64(int64_t* a, int64_t n) {
    if (n < 2) {
        return;
    }
    int64_t start = (FLOW_CHECKED_DIV((n), (2)) - 1);
    while (start >= 0) {
        sift_down_ptr_i64_i64_i64(a, start, (n - 1));
        start = (start - 1);
    }
    int64_t end = (n - 1);
    while (end > 0) {
        int64_t t = a[0];
        a[0] = a[end];
        a[end] = t;
        end = (end - 1);
        sift_down_ptr_i64_i64_i64(a, 0, end);
    }
}

int32_t main(void) {
    int64_t n = 1000000;
    int64_t* spf = (int64_t*)(calloc((n + 1), 8));
    if (spf == NULL) {
        return 1;
    }
    int32_t __flow_step_1 = 1;
    for (int32_t i = 0; (0 <= (n + 1)) ? i < (n + 1) : i > (n + 1); i += (0 <= (n + 1)) ? 1 : -1) {
        spf[i] = i;
    }
    int64_t root = isqrt_i64(n);
    int32_t __flow_step_2 = 1;
    for (int32_t i = 2; (2 <= (root + 1)) ? i < (root + 1) : i > (root + 1); i += (2 <= (root + 1)) ? 1 : -1) {
        if (spf[i] == i) {
            int64_t start = (i * i);
            int64_t j = start;
            while (j <= n) {
                if (spf[j] == j) {
                    spf[j] = i;
                }
                j = (j + i);
            }
        }
    }
    int64_t max_divs = 2000;
    int64_t* divs = (int64_t*)(calloc(max_divs, 8));
    if (divs == NULL) {
        return 1;
    }
    int64_t max_primes = 20;
    int64_t* fac_p = (int64_t*)(calloc(max_primes, 8));
    int64_t* fac_e = (int64_t*)(calloc(max_primes, 8));
    int64_t total = 0;
    int64_t k = 1;
    while (k <= n) {
        int64_t k2 = (k * k);
        int64_t nfac = 0;
        int64_t x = k;
        while (x > 1) {
            int64_t p = spf[x];
            int64_t e = 0;
            while (FLOW_CHECKED_MOD((x), (p)) == 0) {
                x = FLOW_CHECKED_DIV((x), (p));
                e = (e + 1);
            }
            fac_p[nfac] = p;
            fac_e[nfac] = e;
            nfac = (nfac + 1);
        }
        divs[0] = 1;
        int64_t ndivs = 1;
        int32_t __flow_step_3 = 1;
        for (int32_t fi = 0; (0 <= nfac) ? fi < nfac : fi > nfac; fi += (0 <= nfac) ? 1 : -1) {
            int64_t p = fac_p[fi];
            int64_t e2 = (2 * fac_e[fi]);
            int64_t old_count = ndivs;
            int64_t pe = 1;
            int32_t __flow_step_4 = 1;
            for (int32_t _ = 0; (0 <= e2) ? _ < e2 : _ > e2; _ += (0 <= e2) ? 1 : -1) {
                pe = (pe * p);
                int32_t __flow_step_5 = 1;
                for (int32_t di = 0; (0 <= old_count) ? di < old_count : di > old_count; di += (0 <= old_count) ? 1 : -1) {
                    int64_t v = (divs[di] * pe);
                    if (v <= k) {
                        divs[ndivs] = v;
                        ndivs = (ndivs + 1);
                        if (ndivs >= max_divs) {
                            return 1;
                        }
                    }
                }
            }
        }
        heapsort_i64_ptr_i64_i64(divs, ndivs);
        int64_t dlen = ndivs;
        int32_t __flow_step_6 = 1;
        for (int32_t ti = 0; (0 <= dlen) ? ti < dlen : ti > dlen; ti += (0 <= dlen) ? 1 : -1) {
            int64_t T = divs[ti];
            if ((T * T) > k) {
                break;
            }
            int64_t k2_div_T = FLOW_CHECKED_DIV((k2), (T));
            int32_t __flow_step_7 = 1;
            for (int32_t wi = ti; (ti <= dlen) ? wi < dlen : wi > dlen; wi += (ti <= dlen) ? 1 : -1) {
                int64_t W = divs[wi];
                if (((W * W) * W) > k2_div_T) {
                    break;
                }
                if (FLOW_CHECKED_MOD((k2_div_T), (W)) != 0) {
                    continue;
                }
                int64_t R = FLOW_CHECKED_DIV((k2_div_T), (W));
                int64_t vmax = isq_i64(R);
                if (vmax < W) {
                    break;
                }
                if (vmax > k) {
                    vmax = k;
                }
                int64_t S = (W + T);
                int64_t disc = ((S * S) + (4 * R));
                int64_t rt = isq_i64(disc);
                int64_t vmin = (FLOW_CHECKED_DIV(((rt - S)), (2)) + 1);
                if (vmin < W) {
                    vmin = W;
                }
                if (vmin > vmax) {
                    continue;
                }
                int64_t lo = wi;
                int64_t hi = dlen;
                while (lo < hi) {
                    int64_t mid = FLOW_CHECKED_DIV(((lo + hi)), (2));
                    if (divs[mid] < vmin) {
                        lo = (mid + 1);
                    } else {
                        hi = mid;
                    }
                }
                int32_t __flow_step_8 = 1;
                for (int32_t vi = lo; (lo <= dlen) ? vi < dlen : vi > dlen; vi += (lo <= dlen) ? 1 : -1) {
                    int64_t V = divs[vi];
                    if (V > vmax) {
                        break;
                    }
                    if (FLOW_CHECKED_MOD((R), (V)) != 0) {
                        continue;
                    }
                    int64_t U = FLOW_CHECKED_DIV((R), (V));
                    if (U < V) {
                        continue;
                    }
                    if (U >= (V + S)) {
                        continue;
                    }
                    int64_t p = ((U + V) + S);
                    if (FLOW_CHECKED_MOD((p), (2)) != 0) {
                        continue;
                    }
                    total = (total + p);
                }
            }
        }
        k = (k + 1);
    }
    printf("%lld\n", total);
    free(fac_e);
    free(fac_p);
    free(divs);
    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) -> ()
  func.func private @sqrt(f64) -> f64
  func.func @isq(%arg0: i64) -> i64 {
    %175 = arith.constant 0 : i32
    %177 = arith.extsi %175 : i32 to i64
    %176 = arith.cmpi sle, %arg0, %177 : i64
    cf.cond_br %176, ^bb42, ^bb43
    ^bb42:
      %178 = arith.constant 0 : i32
      %179 = arith.extsi %178 : i32 to i64
      func.return %179 : i64
    ^bb43:
      cf.br ^bb44
    ^bb44:
    %180 = arith.sitofp %arg0 : i64 to f64
    %181 = math.sqrt %180 : f64
    %182 = arith.fptosi %181 : f64 to i64
    cf.br ^bb45(%182 : i64)
    ^bb45(%183: i64):
    %184 = arith.constant 0 : i32
    %186 = arith.extsi %184 : i32 to i64
    %185 = arith.cmpi sgt, %183, %186 : i64
    %187 = scf.if %185 -> (i1) {
      %188 = arith.muli %183, %183 : i64
      %189 = arith.cmpi sgt, %188, %arg0 : i64
      scf.yield %189 : i1
    } else {
      %190 = arith.constant false
      scf.yield %190 : i1
    }
    cf.cond_br %187, ^bb46(%183 : i64), ^bb47(%183 : i64)
    ^bb46(%191: i64):
      %192 = arith.constant 1 : i32
      %194 = arith.extsi %192 : i32 to i64
      %193 = arith.subi %191, %194 : i64
      cf.br ^bb45(%193 : i64)
    ^bb47(%195: i64):
    cf.br ^bb48(%195 : i64)
    ^bb48(%196: i64):
    %197 = arith.constant 1 : i32
    %199 = arith.extsi %197 : i32 to i64
    %198 = arith.addi %196, %199 : i64
    %200 = arith.constant 1 : i32
    %202 = arith.extsi %200 : i32 to i64
    %201 = arith.addi %196, %202 : i64
    %203 = arith.muli %198, %201 : i64
    %204 = arith.cmpi sle, %203, %arg0 : i64
    cf.cond_br %204, ^bb49(%196 : i64), ^bb50(%196 : i64)
    ^bb49(%205: i64):
      %206 = arith.constant 1 : i32
      %208 = arith.extsi %206 : i32 to i64
      %207 = arith.addi %205, %208 : i64
      cf.br ^bb48(%207 : i64)
    ^bb50(%209: i64):
    func.return %209 : i64
  }
  func.func @sift_down(%arg0: !llvm.ptr, %arg1: i64, %arg2: i64) -> () {
    %210 = llvm.mlir.constant(1 : i64) : i64
    %211 = llvm.alloca %210 x i64 : (i64) -> !llvm.ptr
    llvm.store %arg1, %211 : i64, !llvm.ptr
    cf.br ^bb51
    ^bb51:
    %212 = arith.constant 2 : i32
    %213 = llvm.load %211 : !llvm.ptr -> i64
    %215 = arith.extsi %212 : i32 to i64
    %214 = arith.muli %215, %213 : i64
    %216 = arith.constant 1 : i32
    %218 = arith.extsi %216 : i32 to i64
    %217 = arith.addi %214, %218 : i64
    %219 = arith.cmpi sle, %217, %arg2 : i64
    cf.cond_br %219, ^bb52, ^bb53
    ^bb52:
      %220 = arith.constant 2 : i32
      %221 = llvm.load %211 : !llvm.ptr -> i64
      %223 = arith.extsi %220 : i32 to i64
      %222 = arith.muli %223, %221 : i64
      %224 = arith.constant 1 : i32
      %226 = arith.extsi %224 : i32 to i64
      %225 = arith.addi %222, %226 : i64
      %227 = llvm.mlir.constant(1 : i64) : i64
      %228 = llvm.alloca %227 x i64 : (i64) -> !llvm.ptr
      llvm.store %225, %228 : i64, !llvm.ptr
      %229 = llvm.load %228 : !llvm.ptr -> i64
      %230 = arith.constant 1 : i32
      %232 = arith.extsi %230 : i32 to i64
      %231 = arith.addi %229, %232 : i64
      %233 = arith.cmpi sle, %231, %arg2 : i64
      cf.cond_br %233, ^bb54, ^bb55
      ^bb54:
        %235 = llvm.load %228 : !llvm.ptr -> i64
        %236 = llvm.getelementptr %arg0[%235] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %234 = llvm.load %236 : !llvm.ptr -> i64
        %238 = llvm.load %228 : !llvm.ptr -> i64
        %239 = arith.constant 1 : i32
        %241 = arith.extsi %239 : i32 to i64
        %240 = arith.addi %238, %241 : i64
        %242 = llvm.getelementptr %arg0[%240] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %237 = llvm.load %242 : !llvm.ptr -> i64
        %243 = arith.cmpi slt, %234, %237 : i64
        cf.cond_br %243, ^bb57, ^bb58
        ^bb57:
          %244 = llvm.load %228 : !llvm.ptr -> i64
          %245 = arith.constant 1 : i32
          %247 = arith.extsi %245 : i32 to i64
          %246 = arith.addi %244, %247 : i64
          llvm.store %246, %228 : i64, !llvm.ptr
          cf.br ^bb59
        ^bb58:
          cf.br ^bb59
        ^bb59:
        cf.br ^bb56
      ^bb55:
        cf.br ^bb56
      ^bb56:
      %249 = llvm.load %211 : !llvm.ptr -> i64
      %250 = llvm.getelementptr %arg0[%249] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %248 = llvm.load %250 : !llvm.ptr -> i64
      %252 = llvm.load %228 : !llvm.ptr -> i64
      %253 = llvm.getelementptr %arg0[%252] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %251 = llvm.load %253 : !llvm.ptr -> i64
      %254 = arith.cmpi slt, %248, %251 : i64
      cf.cond_br %254, ^bb60, ^bb61
      ^bb60:
        %256 = llvm.load %211 : !llvm.ptr -> i64
        %257 = llvm.getelementptr %arg0[%256] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %255 = llvm.load %257 : !llvm.ptr -> i64
        %259 = llvm.load %228 : !llvm.ptr -> i64
        %260 = llvm.getelementptr %arg0[%259] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %258 = llvm.load %260 : !llvm.ptr -> i64
        %261 = llvm.load %211 : !llvm.ptr -> i64
        %262 = llvm.getelementptr %arg0[%261] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        llvm.store %258, %262 : i64, !llvm.ptr
        %263 = llvm.load %228 : !llvm.ptr -> i64
        %264 = llvm.getelementptr %arg0[%263] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        llvm.store %255, %264 : i64, !llvm.ptr
        %265 = llvm.load %228 : !llvm.ptr -> i64
        llvm.store %265, %211 : i64, !llvm.ptr
        cf.br ^bb62
      ^bb61:
        func.return
      ^bb62:
      cf.br ^bb51
    ^bb53:
    func.return
  }
  func.func @heapsort_i64(%arg0: !llvm.ptr, %arg1: i64) -> () {
    %266 = arith.constant 2 : i32
    %268 = arith.extsi %266 : i32 to i64
    %267 = arith.cmpi slt, %arg1, %268 : i64
    cf.cond_br %267, ^bb63, ^bb64
    ^bb63:
      func.return
    ^bb64:
      cf.br ^bb65
    ^bb65:
    %269 = arith.constant 2 : i32
    %271 = arith.extsi %269 : i32 to i64
    %270 = arith.divsi %arg1, %271 : i64
    %272 = arith.constant 1 : i32
    %274 = arith.extsi %272 : i32 to i64
    %273 = arith.subi %270, %274 : i64
    %275 = llvm.mlir.constant(1 : i64) : i64
    %276 = llvm.alloca %275 x i64 : (i64) -> !llvm.ptr
    llvm.store %273, %276 : i64, !llvm.ptr
    cf.br ^bb66
    ^bb66:
    %277 = llvm.load %276 : !llvm.ptr -> i64
    %278 = arith.constant 0 : i32
    %280 = arith.extsi %278 : i32 to i64
    %279 = arith.cmpi sge, %277, %280 : i64
    cf.cond_br %279, ^bb67, ^bb68
    ^bb67:
      %282 = llvm.load %276 : !llvm.ptr -> i64
      %283 = arith.constant 1 : i32
      %285 = arith.extsi %283 : i32 to i64
      %284 = arith.subi %arg1, %285 : i64
      func.call @sift_down(%arg0, %282, %284) : (!llvm.ptr, i64, i64) -> ()
      %286 = llvm.load %276 : !llvm.ptr -> i64
      %287 = arith.constant 1 : i32
      %289 = arith.extsi %287 : i32 to i64
      %288 = arith.subi %286, %289 : i64
      llvm.store %288, %276 : i64, !llvm.ptr
      cf.br ^bb66
    ^bb68:
    %290 = arith.constant 1 : i32
    %292 = arith.extsi %290 : i32 to i64
    %291 = arith.subi %arg1, %292 : i64
    %293 = llvm.mlir.constant(1 : i64) : i64
    %294 = llvm.alloca %293 x i64 : (i64) -> !llvm.ptr
    llvm.store %291, %294 : i64, !llvm.ptr
    cf.br ^bb69
    ^bb69:
    %295 = llvm.load %294 : !llvm.ptr -> i64
    %296 = arith.constant 0 : i32
    %298 = arith.extsi %296 : i32 to i64
    %297 = arith.cmpi sgt, %295, %298 : i64
    cf.cond_br %297, ^bb70, ^bb71
    ^bb70:
      %300 = arith.constant 0 : i32
      %301 = arith.extsi %300 : i32 to i64
      %302 = llvm.getelementptr %arg0[%301] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %299 = llvm.load %302 : !llvm.ptr -> i64
      %304 = llvm.load %294 : !llvm.ptr -> i64
      %305 = llvm.getelementptr %arg0[%304] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %303 = llvm.load %305 : !llvm.ptr -> i64
      %306 = arith.constant 0 : i32
      %307 = arith.extsi %306 : i32 to i64
      %308 = llvm.getelementptr %arg0[%307] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %303, %308 : i64, !llvm.ptr
      %309 = llvm.load %294 : !llvm.ptr -> i64
      %310 = llvm.getelementptr %arg0[%309] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %299, %310 : i64, !llvm.ptr
      %311 = llvm.load %294 : !llvm.ptr -> i64
      %312 = arith.constant 1 : i32
      %314 = arith.extsi %312 : i32 to i64
      %313 = arith.subi %311, %314 : i64
      llvm.store %313, %294 : i64, !llvm.ptr
      %316 = arith.constant 0 : i32
      %317 = llvm.load %294 : !llvm.ptr -> i64
      %318 = arith.extsi %316 : i32 to i64
      func.call @sift_down(%arg0, %318, %317) : (!llvm.ptr, i64, i64) -> ()
      cf.br ^bb69
    ^bb71:
    func.return
  }
  func.func @main() -> i32 {
    %319 = arith.constant 1000000 : i32
    %320 = arith.extsi %319 : i32 to i64
    %322 = arith.constant 1 : i32
    %324 = arith.extsi %322 : i32 to i64
    %323 = arith.addi %320, %324 : i64
    %325 = arith.constant 8 : i32
    %326 = arith.extsi %325 : i32 to i64
    %321 = func.call @calloc(%323, %326) : (i64, i64) -> !llvm.ptr
    %327 = llvm.mlir.zero : !llvm.ptr
    %328 = llvm.icmp "eq" %321, %327 : !llvm.ptr
    cf.cond_br %328, ^bb72, ^bb73
    ^bb72:
      %329 = arith.constant 1 : i32
      func.return %329 : i32
    ^bb73:
      cf.br ^bb74
    ^bb74:
    %330 = arith.constant 0 : i32
    %331 = arith.constant 1 : i32
    %333 = arith.extsi %331 : i32 to i64
    %332 = arith.addi %320, %333 : i64
    %334 = arith.index_cast %330 : i32 to index
    %335 = arith.index_cast %332 : i32 to index
    %337 = arith.constant 1 : index
    %338 = arith.constant -1 : index
    %339 = arith.cmpi sle, %334, %335 : index
    %336 = arith.select %339, %337, %338 : index
    cf.br ^bb75(%334 : index)
    ^bb75(%340: index):
    %341 = arith.cmpi slt, %340, %335 : index
    %342 = arith.cmpi sgt, %340, %335 : index
    %343 = arith.select %339, %341, %342 : i1
    cf.cond_br %343, ^bb76(%340 : index), ^bb77(%340 : index)
    ^bb76(%344: index):
      %345 = arith.index_cast %344 : index to i64
      %346 = arith.index_cast %344 : index to i64
      %347 = llvm.getelementptr %321[%346] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %345, %347 : i64, !llvm.ptr
      %348 = arith.addi %344, %336 : index
      cf.br ^bb75(%348 : index)
    ^bb77(%349: index):
    %350 = func.call @isqrt(%320) : (i64) -> i64
    %351 = arith.constant 2 : i32
    %352 = arith.constant 1 : i32
    %354 = arith.extsi %352 : i32 to i64
    %353 = arith.addi %350, %354 : i64
    %355 = arith.index_cast %351 : i32 to index
    %356 = arith.index_cast %353 : i32 to index
    %358 = arith.constant 1 : index
    %359 = arith.constant -1 : index
    %360 = arith.cmpi sle, %355, %356 : index
    %357 = arith.select %360, %358, %359 : index
    cf.br ^bb78(%355 : index)
    ^bb78(%361: index):
    %362 = arith.cmpi slt, %361, %356 : index
    %363 = arith.cmpi sgt, %361, %356 : index
    %364 = arith.select %360, %362, %363 : i1
    cf.cond_br %364, ^bb79(%361 : index), ^bb80(%361 : index)
    ^bb79(%365: index):
      %367 = arith.index_cast %365 : index to i64
      %368 = llvm.getelementptr %321[%367] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %366 = llvm.load %368 : !llvm.ptr -> i64
      %370 = arith.trunci %366 : i64 to i32
      %371 = arith.index_cast %365 : index to i32
      %369 = arith.cmpi eq, %370, %371 : i32
      cf.cond_br %369, ^bb81, ^bb82
      ^bb81:
        %372 = arith.muli %365, %365 : index
        %373 = arith.index_cast %372 : index to i64
        %374 = llvm.mlir.constant(1 : i64) : i64
        %375 = llvm.alloca %374 x i64 : (i64) -> !llvm.ptr
        llvm.store %373, %375 : i64, !llvm.ptr
        cf.br ^bb84
        ^bb84:
        %376 = llvm.load %375 : !llvm.ptr -> i64
        %377 = arith.cmpi sle, %376, %320 : i64
        cf.cond_br %377, ^bb85, ^bb86
        ^bb85:
          %379 = llvm.load %375 : !llvm.ptr -> i64
          %380 = llvm.getelementptr %321[%379] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          %378 = llvm.load %380 : !llvm.ptr -> i64
          %381 = llvm.load %375 : !llvm.ptr -> i64
          %382 = arith.cmpi eq, %378, %381 : i64
          cf.cond_br %382, ^bb87, ^bb88
          ^bb87:
            %383 = llvm.load %375 : !llvm.ptr -> i64
            %384 = arith.index_cast %365 : index to i64
            %385 = llvm.getelementptr %321[%383] : (!llvm.ptr, i64) -> !llvm.ptr, i64
            llvm.store %384, %385 : i64, !llvm.ptr
            cf.br ^bb89
          ^bb88:
            cf.br ^bb89
          ^bb89:
          %386 = llvm.load %375 : !llvm.ptr -> i64
          %388 = arith.trunci %386 : i64 to i32
          %389 = arith.index_cast %365 : index to i32
          %387 = arith.addi %388, %389 : i32
          %390 = arith.extsi %387 : i32 to i64
          llvm.store %390, %375 : i64, !llvm.ptr
          cf.br ^bb84
        ^bb86:
        cf.br ^bb83
      ^bb82:
        cf.br ^bb83
      ^bb83:
      %391 = arith.addi %365, %357 : index
      cf.br ^bb78(%391 : index)
    ^bb80(%392: index):
    %393 = arith.constant 2000 : i32
    %394 = arith.extsi %393 : i32 to i64
    %396 = arith.constant 8 : i32
    %397 = arith.extsi %396 : i32 to i64
    %395 = func.call @calloc(%394, %397) : (i64, i64) -> !llvm.ptr
    %398 = llvm.mlir.zero : !llvm.ptr
    %399 = llvm.icmp "eq" %395, %398 : !llvm.ptr
    cf.cond_br %399, ^bb90, ^bb91
    ^bb90:
      %400 = arith.constant 1 : i32
      func.return %400 : i32
    ^bb91:
      cf.br ^bb92
    ^bb92:
    %401 = arith.constant 20 : i32
    %402 = arith.extsi %401 : i32 to i64
    %404 = arith.constant 8 : i32
    %405 = arith.extsi %404 : i32 to i64
    %403 = func.call @calloc(%402, %405) : (i64, i64) -> !llvm.ptr
    %407 = arith.constant 8 : i32
    %408 = arith.extsi %407 : i32 to i64
    %406 = func.call @calloc(%402, %408) : (i64, i64) -> !llvm.ptr
    %409 = arith.constant 0 : i32
    %410 = arith.extsi %409 : i32 to i64
    %411 = llvm.mlir.constant(1 : i64) : i64
    %412 = llvm.alloca %411 x i64 : (i64) -> !llvm.ptr
    llvm.store %410, %412 : i64, !llvm.ptr
    %413 = arith.constant 1 : i32
    %414 = arith.extsi %413 : i32 to i64
    %415 = llvm.mlir.constant(1 : i64) : i64
    %416 = llvm.alloca %415 x i64 : (i64) -> !llvm.ptr
    llvm.store %414, %416 : i64, !llvm.ptr
    cf.br ^bb93
    ^bb93:
    %417 = llvm.load %416 : !llvm.ptr -> i64
    %418 = arith.cmpi sle, %417, %320 : i64
    cf.cond_br %418, ^bb94, ^bb95
    ^bb94:
      %419 = llvm.load %416 : !llvm.ptr -> i64
      %420 = llvm.load %416 : !llvm.ptr -> i64
      %421 = arith.muli %419, %420 : i64
      %422 = arith.constant 0 : i32
      %423 = arith.extsi %422 : i32 to i64
      %424 = llvm.mlir.constant(1 : i64) : i64
      %425 = llvm.alloca %424 x i64 : (i64) -> !llvm.ptr
      llvm.store %423, %425 : i64, !llvm.ptr
      %426 = llvm.load %416 : !llvm.ptr -> i64
      %427 = llvm.mlir.constant(1 : i64) : i64
      %428 = llvm.alloca %427 x i64 : (i64) -> !llvm.ptr
      llvm.store %426, %428 : i64, !llvm.ptr
      cf.br ^bb96
      ^bb96:
      %429 = llvm.load %428 : !llvm.ptr -> i64
      %430 = arith.constant 1 : i32
      %432 = arith.extsi %430 : i32 to i64
      %431 = arith.cmpi sgt, %429, %432 : i64
      cf.cond_br %431, ^bb97, ^bb98
      ^bb97:
        %434 = llvm.load %428 : !llvm.ptr -> i64
        %435 = llvm.getelementptr %321[%434] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %433 = llvm.load %435 : !llvm.ptr -> i64
        %436 = arith.constant 0 : i32
        %437 = arith.extsi %436 : i32 to i64
        %438 = llvm.mlir.constant(1 : i64) : i64
        %439 = llvm.alloca %438 x i64 : (i64) -> !llvm.ptr
        llvm.store %437, %439 : i64, !llvm.ptr
        cf.br ^bb99
        ^bb99:
        %440 = llvm.load %428 : !llvm.ptr -> i64
        %441 = arith.remsi %440, %433 : i64
        %442 = arith.constant 0 : i32
        %444 = arith.extsi %442 : i32 to i64
        %443 = arith.cmpi eq, %441, %444 : i64
        cf.cond_br %443, ^bb100, ^bb101
        ^bb100:
          %445 = llvm.load %428 : !llvm.ptr -> i64
          %446 = arith.divsi %445, %433 : i64
          llvm.store %446, %428 : i64, !llvm.ptr
          %447 = llvm.load %439 : !llvm.ptr -> i64
          %448 = arith.constant 1 : i32
          %450 = arith.extsi %448 : i32 to i64
          %449 = arith.addi %447, %450 : i64
          llvm.store %449, %439 : i64, !llvm.ptr
          cf.br ^bb99
        ^bb101:
        %451 = llvm.load %425 : !llvm.ptr -> i64
        %452 = llvm.getelementptr %403[%451] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        llvm.store %433, %452 : i64, !llvm.ptr
        %453 = llvm.load %439 : !llvm.ptr -> i64
        %454 = llvm.load %425 : !llvm.ptr -> i64
        %455 = llvm.getelementptr %406[%454] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        llvm.store %453, %455 : i64, !llvm.ptr
        %456 = llvm.load %425 : !llvm.ptr -> i64
        %457 = arith.constant 1 : i32
        %459 = arith.extsi %457 : i32 to i64
        %458 = arith.addi %456, %459 : i64
        llvm.store %458, %425 : i64, !llvm.ptr
        cf.br ^bb96
      ^bb98:
      %460 = arith.constant 1 : i32
      %461 = arith.constant 0 : i32
      %462 = arith.extsi %460 : i32 to i64
      %463 = arith.extsi %461 : i32 to i64
      %464 = llvm.getelementptr %395[%463] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %462, %464 : i64, !llvm.ptr
      %465 = arith.constant 1 : i32
      %466 = arith.extsi %465 : i32 to i64
      %467 = llvm.mlir.constant(1 : i64) : i64
      %468 = llvm.alloca %467 x i64 : (i64) -> !llvm.ptr
      llvm.store %466, %468 : i64, !llvm.ptr
      %469 = arith.constant 0 : i32
      %470 = llvm.load %425 : !llvm.ptr -> i64
      %471 = arith.index_cast %469 : i32 to index
      %472 = arith.index_cast %470 : i32 to index
      %474 = arith.constant 1 : index
      %475 = arith.constant -1 : index
      %476 = arith.cmpi sle, %471, %472 : index
      %473 = arith.select %476, %474, %475 : index
      cf.br ^bb102(%471 : index)
      ^bb102(%477: index):
      %478 = arith.cmpi slt, %477, %472 : index
      %479 = arith.cmpi sgt, %477, %472 : index
      %480 = arith.select %476, %478, %479 : i1
      cf.cond_br %480, ^bb103(%477 : index), ^bb104(%477 : index)
      ^bb103(%481: index):
        %483 = arith.index_cast %481 : index to i64
        %484 = llvm.getelementptr %403[%483] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %482 = llvm.load %484 : !llvm.ptr -> i64
        %485 = arith.constant 2 : i32
        %487 = arith.index_cast %481 : index to i64
        %488 = llvm.getelementptr %406[%487] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %486 = llvm.load %488 : !llvm.ptr -> i64
        %490 = arith.extsi %485 : i32 to i64
        %489 = arith.muli %490, %486 : i64
        %491 = llvm.load %468 : !llvm.ptr -> i64
        %492 = arith.constant 1 : i32
        %493 = arith.extsi %492 : i32 to i64
        %494 = llvm.mlir.constant(1 : i64) : i64
        %495 = llvm.alloca %494 x i64 : (i64) -> !llvm.ptr
        llvm.store %493, %495 : i64, !llvm.ptr
        %496 = arith.constant 0 : i32
        %497 = arith.index_cast %496 : i32 to index
        %498 = arith.index_cast %489 : i32 to index
        %500 = arith.constant 1 : index
        %501 = arith.constant -1 : index
        %502 = arith.cmpi sle, %497, %498 : index
        %499 = arith.select %502, %500, %501 : index
        cf.br ^bb105(%497 : index)
        ^bb105(%503: index):
        %504 = arith.cmpi slt, %503, %498 : index
        %505 = arith.cmpi sgt, %503, %498 : index
        %506 = arith.select %502, %504, %505 : i1
        cf.cond_br %506, ^bb106(%503 : index), ^bb107(%503 : index)
        ^bb106(%507: index):
          %508 = llvm.load %495 : !llvm.ptr -> i64
          %509 = arith.muli %508, %482 : i64
          llvm.store %509, %495 : i64, !llvm.ptr
          %510 = arith.constant 0 : i32
          %511 = arith.index_cast %510 : i32 to index
          %512 = arith.index_cast %491 : i32 to index
          %514 = arith.constant 1 : index
          %515 = arith.constant -1 : index
          %516 = arith.cmpi sle, %511, %512 : index
          %513 = arith.select %516, %514, %515 : index
          cf.br ^bb108(%511 : index)
          ^bb108(%517: index):
          %518 = arith.cmpi slt, %517, %512 : index
          %519 = arith.cmpi sgt, %517, %512 : index
          %520 = arith.select %516, %518, %519 : i1
          cf.cond_br %520, ^bb109(%517 : index), ^bb110(%517 : index)
          ^bb109(%521: index):
            %523 = arith.index_cast %521 : index to i64
            %524 = llvm.getelementptr %395[%523] : (!llvm.ptr, i64) -> !llvm.ptr, i64
            %522 = llvm.load %524 : !llvm.ptr -> i64
            %525 = llvm.load %495 : !llvm.ptr -> i64
            %526 = arith.muli %522, %525 : i64
            %527 = llvm.load %416 : !llvm.ptr -> i64
            %528 = arith.cmpi sle, %526, %527 : i64
            cf.cond_br %528, ^bb111, ^bb112
            ^bb111:
              %529 = llvm.load %468 : !llvm.ptr -> i64
              %530 = llvm.getelementptr %395[%529] : (!llvm.ptr, i64) -> !llvm.ptr, i64
              llvm.store %526, %530 : i64, !llvm.ptr
              %531 = llvm.load %468 : !llvm.ptr -> i64
              %532 = arith.constant 1 : i32
              %534 = arith.extsi %532 : i32 to i64
              %533 = arith.addi %531, %534 : i64
              llvm.store %533, %468 : i64, !llvm.ptr
              %535 = llvm.load %468 : !llvm.ptr -> i64
              %536 = arith.cmpi sge, %535, %394 : i64
              cf.cond_br %536, ^bb114, ^bb115
              ^bb114:
                %537 = arith.constant 1 : i32
                func.return %537 : i32
              ^bb115:
                cf.br ^bb116
              ^bb116:
              cf.br ^bb113
            ^bb112:
              cf.br ^bb113
            ^bb113:
            %538 = arith.addi %521, %513 : index
            cf.br ^bb108(%538 : index)
          ^bb110(%539: index):
          %540 = arith.addi %507, %499 : index
          cf.br ^bb105(%540 : index)
        ^bb107(%541: index):
        %542 = arith.addi %481, %473 : index
        cf.br ^bb102(%542 : index)
      ^bb104(%543: index):
      %545 = llvm.load %468 : !llvm.ptr -> i64
      func.call @heapsort_i64(%395, %545) : (!llvm.ptr, i64) -> ()
      %546 = llvm.load %468 : !llvm.ptr -> i64
      %547 = arith.constant 0 : i32
      %548 = arith.index_cast %547 : i32 to index
      %549 = arith.index_cast %546 : i32 to index
      %551 = arith.constant 1 : index
      %552 = arith.constant -1 : index
      %553 = arith.cmpi sle, %548, %549 : index
      %550 = arith.select %553, %551, %552 : index
      cf.br ^bb117(%548 : index)
      ^bb117(%554: index):
      %555 = arith.cmpi slt, %554, %549 : index
      %556 = arith.cmpi sgt, %554, %549 : index
      %557 = arith.select %553, %555, %556 : i1
      cf.cond_br %557, ^bb118(%554 : index), ^bb119(%554 : index)
      ^bb118(%558: index):
        %560 = arith.index_cast %558 : index to i64
        %561 = llvm.getelementptr %395[%560] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %559 = llvm.load %561 : !llvm.ptr -> i64
        %562 = arith.muli %559, %559 : i64
        %563 = llvm.load %416 : !llvm.ptr -> i64
        %564 = arith.cmpi sgt, %562, %563 : i64
        cf.cond_br %564, ^bb120, ^bb121
        ^bb120:
          cf.br ^bb119(%558 : index)
        ^bb121:
          cf.br ^bb122
        ^bb122:
        %565 = arith.divsi %421, %559 : i64
        %566 = arith.index_cast %558 : i32 to index
        %567 = arith.index_cast %546 : i32 to index
        %569 = arith.constant 1 : index
        %570 = arith.constant -1 : index
        %571 = arith.cmpi sle, %566, %567 : index
        %568 = arith.select %571, %569, %570 : index
        cf.br ^bb123(%566 : index)
        ^bb123(%572: index):
        %573 = arith.cmpi slt, %572, %567 : index
        %574 = arith.cmpi sgt, %572, %567 : index
        %575 = arith.select %571, %573, %574 : i1
        cf.cond_br %575, ^bb124(%572 : index), ^bb125(%572 : index)
        ^bb124(%576: index):
          %578 = arith.index_cast %576 : index to i64
          %579 = llvm.getelementptr %395[%578] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          %577 = llvm.load %579 : !llvm.ptr -> i64
          %580 = arith.muli %577, %577 : i64
          %581 = arith.muli %580, %577 : i64
          %582 = arith.cmpi sgt, %581, %565 : i64
          cf.cond_br %582, ^bb126, ^bb127
          ^bb126:
            cf.br ^bb125(%576 : index)
          ^bb127:
            cf.br ^bb128
          ^bb128:
          %583 = arith.remsi %565, %577 : i64
          %584 = arith.constant 0 : i32
          %586 = arith.extsi %584 : i32 to i64
          %585 = arith.cmpi ne, %583, %586 : i64
          cf.cond_br %585, ^bb129, ^bb130
          ^bb129:
            %587 = arith.addi %576, %568 : index
            cf.br ^bb123(%587 : index)
          ^bb130:
            cf.br ^bb131
          ^bb131:
          %588 = arith.divsi %565, %577 : i64
          %589 = func.call @isq(%588) : (i64) -> i64
          %590 = llvm.mlir.constant(1 : i64) : i64
          %591 = llvm.alloca %590 x i64 : (i64) -> !llvm.ptr
          llvm.store %589, %591 : i64, !llvm.ptr
          %592 = llvm.load %591 : !llvm.ptr -> i64
          %593 = arith.cmpi slt, %592, %577 : i64
          cf.cond_br %593, ^bb132, ^bb133
          ^bb132:
            cf.br ^bb125(%576 : index)
          ^bb133:
            cf.br ^bb134
          ^bb134:
          %594 = llvm.load %591 : !llvm.ptr -> i64
          %595 = llvm.load %416 : !llvm.ptr -> i64
          %596 = arith.cmpi sgt, %594, %595 : i64
          cf.cond_br %596, ^bb135, ^bb136
          ^bb135:
            %597 = llvm.load %416 : !llvm.ptr -> i64
            llvm.store %597, %591 : i64, !llvm.ptr
            cf.br ^bb137
          ^bb136:
            cf.br ^bb137
          ^bb137:
          %598 = arith.addi %577, %559 : i64
          %599 = arith.muli %598, %598 : i64
          %600 = arith.constant 4 : i32
          %602 = arith.extsi %600 : i32 to i64
          %601 = arith.muli %602, %588 : i64
          %603 = arith.addi %599, %601 : i64
          %604 = func.call @isq(%603) : (i64) -> i64
          %605 = arith.subi %604, %598 : i64
          %606 = arith.constant 2 : i32
          %608 = arith.extsi %606 : i32 to i64
          %607 = arith.divsi %605, %608 : i64
          %609 = arith.constant 1 : i32
          %611 = arith.extsi %609 : i32 to i64
          %610 = arith.addi %607, %611 : i64
          %612 = llvm.mlir.constant(1 : i64) : i64
          %613 = llvm.alloca %612 x i64 : (i64) -> !llvm.ptr
          llvm.store %610, %613 : i64, !llvm.ptr
          %614 = llvm.load %613 : !llvm.ptr -> i64
          %615 = arith.cmpi slt, %614, %577 : i64
          cf.cond_br %615, ^bb138, ^bb139
          ^bb138:
            llvm.store %577, %613 : i64, !llvm.ptr
            cf.br ^bb140
          ^bb139:
            cf.br ^bb140
          ^bb140:
          %616 = llvm.load %613 : !llvm.ptr -> i64
          %617 = llvm.load %591 : !llvm.ptr -> i64
          %618 = arith.cmpi sgt, %616, %617 : i64
          cf.cond_br %618, ^bb141, ^bb142
          ^bb141:
            %619 = arith.addi %576, %568 : index
            cf.br ^bb123(%619 : index)
          ^bb142:
            cf.br ^bb143
          ^bb143:
          %620 = arith.index_cast %576 : index to i64
          %621 = llvm.mlir.constant(1 : i64) : i64
          %622 = llvm.alloca %621 x i64 : (i64) -> !llvm.ptr
          llvm.store %620, %622 : i64, !llvm.ptr
          %623 = llvm.mlir.constant(1 : i64) : i64
          %624 = llvm.alloca %623 x i64 : (i64) -> !llvm.ptr
          llvm.store %546, %624 : i64, !llvm.ptr
          cf.br ^bb144
          ^bb144:
          %625 = llvm.load %622 : !llvm.ptr -> i64
          %626 = llvm.load %624 : !llvm.ptr -> i64
          %627 = arith.cmpi slt, %625, %626 : i64
          cf.cond_br %627, ^bb145, ^bb146
          ^bb145:
            %628 = llvm.load %622 : !llvm.ptr -> i64
            %629 = llvm.load %624 : !llvm.ptr -> i64
            %630 = arith.addi %628, %629 : i64
            %631 = arith.constant 2 : i32
            %633 = arith.extsi %631 : i32 to i64
            %632 = arith.divsi %630, %633 : i64
            %635 = llvm.getelementptr %395[%632] : (!llvm.ptr, i64) -> !llvm.ptr, i64
            %634 = llvm.load %635 : !llvm.ptr -> i64
            %636 = llvm.load %613 : !llvm.ptr -> i64
            %637 = arith.cmpi slt, %634, %636 : i64
            cf.cond_br %637, ^bb147, ^bb148
            ^bb147:
              %638 = arith.constant 1 : i32
              %640 = arith.extsi %638 : i32 to i64
              %639 = arith.addi %632, %640 : i64
              llvm.store %639, %622 : i64, !llvm.ptr
              cf.br ^bb149
            ^bb148:
              llvm.store %632, %624 : i64, !llvm.ptr
              cf.br ^bb149
            ^bb149:
            cf.br ^bb144
          ^bb146:
          %641 = llvm.load %622 : !llvm.ptr -> i64
          %642 = arith.index_cast %641 : i32 to index
          %643 = arith.index_cast %546 : i32 to index
          %645 = arith.constant 1 : index
          %646 = arith.constant -1 : index
          %647 = arith.cmpi sle, %642, %643 : index
          %644 = arith.select %647, %645, %646 : index
          cf.br ^bb150(%642 : index)
          ^bb150(%648: index):
          %649 = arith.cmpi slt, %648, %643 : index
          %650 = arith.cmpi sgt, %648, %643 : index
          %651 = arith.select %647, %649, %650 : i1
          cf.cond_br %651, ^bb151(%648 : index), ^bb152(%648 : index)
          ^bb151(%652: index):
            %654 = arith.index_cast %652 : index to i64
            %655 = llvm.getelementptr %395[%654] : (!llvm.ptr, i64) -> !llvm.ptr, i64
            %653 = llvm.load %655 : !llvm.ptr -> i64
            %656 = llvm.load %591 : !llvm.ptr -> i64
            %657 = arith.cmpi sgt, %653, %656 : i64
            cf.cond_br %657, ^bb153, ^bb154
            ^bb153:
              cf.br ^bb152(%652 : index)
            ^bb154:
              cf.br ^bb155
            ^bb155:
            %658 = arith.remsi %588, %653 : i64
            %659 = arith.constant 0 : i32
            %661 = arith.extsi %659 : i32 to i64
            %660 = arith.cmpi ne, %658, %661 : i64
            cf.cond_br %660, ^bb156, ^bb157
            ^bb156:
              %662 = arith.addi %652, %644 : index
              cf.br ^bb150(%662 : index)
            ^bb157:
              cf.br ^bb158
            ^bb158:
            %663 = arith.divsi %588, %653 : i64
            %664 = arith.cmpi slt, %663, %653 : i64
            cf.cond_br %664, ^bb159, ^bb160
            ^bb159:
              %665 = arith.addi %652, %644 : index
              cf.br ^bb150(%665 : index)
            ^bb160:
              cf.br ^bb161
            ^bb161:
            %666 = arith.addi %653, %598 : i64
            %667 = arith.cmpi sge, %663, %666 : i64
            cf.cond_br %667, ^bb162, ^bb163
            ^bb162:
              %668 = arith.addi %652, %644 : index
              cf.br ^bb150(%668 : index)
            ^bb163:
              cf.br ^bb164
            ^bb164:
            %669 = arith.addi %663, %653 : i64
            %670 = arith.addi %669, %598 : i64
            %671 = arith.constant 2 : i32
            %673 = arith.extsi %671 : i32 to i64
            %672 = arith.remsi %670, %673 : i64
            %674 = arith.constant 0 : i32
            %676 = arith.extsi %674 : i32 to i64
            %675 = arith.cmpi ne, %672, %676 : i64
            cf.cond_br %675, ^bb165, ^bb166
            ^bb165:
              %677 = arith.addi %652, %644 : index
              cf.br ^bb150(%677 : index)
            ^bb166:
              cf.br ^bb167
            ^bb167:
            %678 = llvm.load %412 : !llvm.ptr -> i64
            %679 = arith.addi %678, %670 : i64
            llvm.store %679, %412 : i64, !llvm.ptr
            %680 = arith.addi %652, %644 : index
            cf.br ^bb150(%680 : index)
          ^bb152(%681: index):
          %682 = arith.addi %576, %568 : index
          cf.br ^bb123(%682 : index)
        ^bb125(%683: index):
        %684 = arith.addi %558, %550 : index
        cf.br ^bb117(%684 : index)
      ^bb119(%685: index):
      %686 = llvm.load %416 : !llvm.ptr -> i64
      %687 = arith.constant 1 : i32
      %689 = arith.extsi %687 : i32 to i64
      %688 = arith.addi %686, %689 : i64
      llvm.store %688, %416 : i64, !llvm.ptr
      cf.br ^bb93
    ^bb95:
    %690 = llvm.mlir.addressof @str_0 : !llvm.ptr
    %691 = llvm.load %412 : !llvm.ptr -> i64
    %692 = llvm.call @printf(%690, %691) vararg(!llvm.func<i32 (ptr, ...)>) : (!llvm.ptr, i64) -> i32
    func.call @free(%406) : (!llvm.ptr) -> ()
    func.call @free(%403) : (!llvm.ptr) -> ()
    func.call @free(%395) : (!llvm.ptr) -> ()
    func.call @free(%321) : (!llvm.ptr) -> ()
    %697 = arith.constant 0 : i32
    func.return %697 : i32
  }
}