Problem 397

Count triangles on y=x^2/k with a 45-degree angle: F(10^6, 10^9).

Answer141630459461893728
Output141630459461893728
StatusPASS
Native helperno
Runtime1170 ms
Peak memory5136 KB
Time complexityO(n^3) (estimated)
Space complexityO(n^2) (estimated)

Performance comparison

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

Flow source

# Project Euler 397
# Count triangles on y=x^2/k with a 45-degree angle: F(10^6, 10^9).

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

# Floor division toward -inf (C/Flow truncate toward 0).
function floordiv(a: i64, b: i64) -> i64 {
    let q: i64 = a / b
    let r: i64 = a % b
    if r != 0 {
        if (a < 0 && b > 0) || (a > 0 && b < 0) {
            return q - 1
        }
    }
    return q
}

function count_left(X: i64, s: i64, t: i64) -> i64 {
    let mut L: i64 = t - X
    if L < (0 - X) { L = 0 - X }
    let mut U: i64 = s + X
    if U > X { U = X }
    let u2: i64 = floordiv(s - 1, 2)
    if u2 < U { U = u2 }
    if U < L { return 0 }
    return U - L + 1
}

function count_mid(X: i64, p: i64, q: i64) -> i64 {
    let mut L: i64 = p - X
    if L < (0 - X) { L = 0 - X }
    let qx: i64 = q - X
    if qx > L { L = qx }
    let l2: i64 = floordiv(p, 2) + 1
    if l2 > L { L = l2 }
    let mut U: i64 = p + X
    if U > X { U = X }
    let u2: i64 = floordiv(q - 1, 2)
    if u2 < U { U = u2 }
    if U < L { return 0 }
    return U - L + 1
}

function main() -> i32 {
    let K: i64 = 1000000
    let X: i64 = 1000000000
    let spf: ptr<i32> = calloc(K + 1, 4)
    let mut i: i64 = 0
    while i <= K {
        spf[i] = i as i32
        i = i + 1
    }
    i = 2
    while i * i <= K {
        if (spf[i] as i64) == i {
            let mut j: i64 = i * i
            while j <= K {
                if (spf[j] as i64) == j { spf[j] = i as i32 }
                j = j + i
            }
        }
        i = i + 1
    }

    let twoX: i64 = 2 * X
    let mut count_A: i64 = 0
    let mut count_B: i64 = 0
    let mut overlap_AB: i64 = 0
    let mut overlap_AC: i64 = 0

    let fac_p: ptr<i32> = calloc(64, 4)
    let fac_e: ptr<i32> = calloc(64, 4)
    let divs: ptr<i64> = calloc(4096, 8)
    let new_divs: ptr<i64> = calloc(4096, 8)

    let mut k: i64 = 1
    while k <= K {
        let D: i64 = 2 * k * k
        # factor 2*k^2 from spf of k
        let mut x: i64 = k
        let mut fc: i64 = 0
        let mut has2: i64 = 0
        while x > 1 {
            let p: i64 = spf[x] as i64
            let mut e: i64 = 0
            while x % p == 0 {
                x = x / p
                e = e + 1
            }
            if p == 2 {
                fac_p[fc] = 2
                fac_e[fc] = (2 * e + 1) as i32
                has2 = 1
            } else {
                fac_p[fc] = p as i32
                fac_e[fc] = (2 * e) as i32
            }
            fc = fc + 1
        }
        if has2 == 0 {
            fac_p[fc] = 2
            fac_e[fc] = 1
            fc = fc + 1
        }

        divs[0] = 1
        let mut dc: i64 = 1
        let mut fi: i64 = 0
        while fi < fc {
            let p: i64 = fac_p[fi] as i64
            let expv: i64 = fac_e[fi] as i64
            let mut pe: i64 = 1
            let mut ndc: i64 = 0
            let mut di: i64 = 0
            while di < dc {
                let base: i64 = divs[di]
                pe = 1
                let mut e: i64 = 0
                while e <= expv {
                    new_divs[ndc] = base * pe
                    ndc = ndc + 1
                    if e < expv { pe = pe * p }
                    e = e + 1
                }
                di = di + 1
            }
            di = 0
            while di < ndc {
                divs[di] = new_divs[di]
                di = di + 1
            }
            dc = ndc
            fi = fi + 1
        }

        let mut di: i64 = 0
        while di < dc {
            let d: i64 = divs[di]
            let u: i64 = D / d
            let s: i64 = k - u
            let t: i64 = d - k
            if s >= (0 - twoX) && s <= twoX && t >= (0 - twoX) && t <= twoX {
                count_A = count_A + count_left(X, s, t)
                let denom: i64 = s + k
                if denom != 0 {
                    let num: i64 = k * (s - k)
                    if num % denom == 0 {
                        let q: i64 = num / denom
                        if q >= (0 - twoX) && q <= twoX && ((s + t - q) & 1) == 0 {
                            let a: i64 = (s + t - q) / 2
                            let b: i64 = (s + q - t) / 2
                            let c: i64 = (t + q - s) / 2
                            if a >= (0 - X) && a < b && b < c && c <= X {
                                overlap_AB = overlap_AB + 1
                            }
                        }
                    }
                }
                let denom2: i64 = k - t
                if denom2 != 0 {
                    let num2: i64 = k * (k + t)
                    if num2 % denom2 == 0 {
                        let q2: i64 = num2 / denom2
                        if q2 >= (0 - twoX) && q2 <= twoX && ((s + t - q2) & 1) == 0 {
                            let a: i64 = (s + t - q2) / 2
                            let b: i64 = (s + q2 - t) / 2
                            let c: i64 = (t + q2 - s) / 2
                            if a >= (0 - X) && a < b && b < c && c <= X {
                                overlap_AC = overlap_AC + 1
                            }
                        }
                    }
                }
            }
            let p: i64 = 0 - (k + u)
            let q: i64 = k + d
            if p >= (0 - twoX) && p <= twoX && q <= twoX {
                count_B = count_B + count_mid(X, p, q)
            }
            di = di + 1
        }
        k = k + 1
    }

    let total: i64 = 2 * count_A + count_B - 2 * overlap_AB - overlap_AC
    printf("%lld\n", total)
    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 floordiv_i64_i64(int64_t a, int64_t b);
int64_t count_left_i64_i64_i64(int64_t X, int64_t s, int64_t t);
int64_t count_mid_i64_i64_i64(int64_t X, int64_t p, int64_t q);
int32_t main(void);



int64_t floordiv_i64_i64(int64_t a, int64_t b) {
    int64_t q = FLOW_CHECKED_DIV((a), (b));
    int64_t r = FLOW_CHECKED_MOD((a), (b));
    if (r != 0) {
        if (((a < 0 && b > 0) || (a > 0 && b < 0))) {
            return (q - 1);
        }
    }
    return q;
}

int64_t count_left_i64_i64_i64(int64_t X, int64_t s, int64_t t) {
    int64_t L = (t - X);
    if (L < (0 - X)) {
        L = (0 - X);
    }
    int64_t U = (s + X);
    if (U > X) {
        U = X;
    }
    int64_t u2 = floordiv_i64_i64((s - 1), 2);
    if (u2 < U) {
        U = u2;
    }
    if (U < L) {
        return 0;
    }
    return ((U - L) + 1);
}

int64_t count_mid_i64_i64_i64(int64_t X, int64_t p, int64_t q) {
    int64_t L = (p - X);
    if (L < (0 - X)) {
        L = (0 - X);
    }
    int64_t qx = (q - X);
    if (qx > L) {
        L = qx;
    }
    int64_t l2 = (floordiv_i64_i64(p, 2) + 1);
    if (l2 > L) {
        L = l2;
    }
    int64_t U = (p + X);
    if (U > X) {
        U = X;
    }
    int64_t u2 = floordiv_i64_i64((q - 1), 2);
    if (u2 < U) {
        U = u2;
    }
    if (U < L) {
        return 0;
    }
    return ((U - L) + 1);
}

int32_t main(void) {
    int64_t K = 1000000;
    int64_t X = 1000000000;
    int32_t* spf = (int32_t*)(calloc((K + 1), 4));
    int64_t i = 0;
    while (i <= K) {
        spf[i] = ((int32_t)(i));
        i = (i + 1);
    }
    i = 2;
    while ((i * i) <= K) {
        if (((int64_t)(spf[i])) == i) {
            int64_t j = (i * i);
            while (j <= K) {
                if (((int64_t)(spf[j])) == j) {
                    spf[j] = ((int32_t)(i));
                }
                j = (j + i);
            }
        }
        i = (i + 1);
    }
    int64_t twoX = (2 * X);
    int64_t count_A = 0;
    int64_t count_B = 0;
    int64_t overlap_AB = 0;
    int64_t overlap_AC = 0;
    int32_t* fac_p = (int32_t*)(calloc(64, 4));
    int32_t* fac_e = (int32_t*)(calloc(64, 4));
    int64_t* divs = (int64_t*)(calloc(4096, 8));
    int64_t* new_divs = (int64_t*)(calloc(4096, 8));
    int64_t k = 1;
    while (k <= K) {
        int64_t D = ((2 * k) * k);
        int64_t x = k;
        int64_t fc = 0;
        int64_t has2 = 0;
        while (x > 1) {
            int64_t p = ((int64_t)(spf[x]));
            int64_t e = 0;
            while (FLOW_CHECKED_MOD((x), (p)) == 0) {
                x = FLOW_CHECKED_DIV((x), (p));
                e = (e + 1);
            }
            if (p == 2) {
                fac_p[fc] = 2;
                fac_e[fc] = ((int32_t)(((2 * e) + 1)));
                has2 = 1;
            } else {
                fac_p[fc] = ((int32_t)(p));
                fac_e[fc] = ((int32_t)((2 * e)));
            }
            fc = (fc + 1);
        }
        if (has2 == 0) {
            fac_p[fc] = 2;
            fac_e[fc] = 1;
            fc = (fc + 1);
        }
        divs[0] = 1;
        int64_t dc = 1;
        int64_t fi = 0;
        while (fi < fc) {
            int64_t p = ((int64_t)(fac_p[fi]));
            int64_t expv = ((int64_t)(fac_e[fi]));
            int64_t pe = 1;
            int64_t ndc = 0;
            int64_t di = 0;
            while (di < dc) {
                int64_t base = divs[di];
                pe = 1;
                int64_t e = 0;
                while (e <= expv) {
                    new_divs[ndc] = (base * pe);
                    ndc = (ndc + 1);
                    if (e < expv) {
                        pe = (pe * p);
                    }
                    e = (e + 1);
                }
                di = (di + 1);
            }
            di = 0;
            while (di < ndc) {
                divs[di] = new_divs[di];
                di = (di + 1);
            }
            dc = ndc;
            fi = (fi + 1);
        }
        int64_t di = 0;
        while (di < dc) {
            int64_t d = divs[di];
            int64_t u = FLOW_CHECKED_DIV((D), (d));
            int64_t s = (k - u);
            int64_t t = (d - k);
            if ((((s >= (0 - twoX) && s <= twoX) && t >= (0 - twoX)) && t <= twoX)) {
                count_A = (count_A + count_left_i64_i64_i64(X, s, t));
                int64_t denom = (s + k);
                if (denom != 0) {
                    int64_t num = (k * (s - k));
                    if (FLOW_CHECKED_MOD((num), (denom)) == 0) {
                        int64_t q = FLOW_CHECKED_DIV((num), (denom));
                        if (((q >= (0 - twoX) && q <= twoX) && (((s + t) - q) & 1) == 0)) {
                            int64_t a = FLOW_CHECKED_DIV((((s + t) - q)), (2));
                            int64_t b = FLOW_CHECKED_DIV((((s + q) - t)), (2));
                            int64_t c = FLOW_CHECKED_DIV((((t + q) - s)), (2));
                            if ((((a >= (0 - X) && a < b) && b < c) && c <= X)) {
                                overlap_AB = (overlap_AB + 1);
                            }
                        }
                    }
                }
                int64_t denom2 = (k - t);
                if (denom2 != 0) {
                    int64_t num2 = (k * (k + t));
                    if (FLOW_CHECKED_MOD((num2), (denom2)) == 0) {
                        int64_t q2 = FLOW_CHECKED_DIV((num2), (denom2));
                        if (((q2 >= (0 - twoX) && q2 <= twoX) && (((s + t) - q2) & 1) == 0)) {
                            int64_t a = FLOW_CHECKED_DIV((((s + t) - q2)), (2));
                            int64_t b = FLOW_CHECKED_DIV((((s + q2) - t)), (2));
                            int64_t c = FLOW_CHECKED_DIV((((t + q2) - s)), (2));
                            if ((((a >= (0 - X) && a < b) && b < c) && c <= X)) {
                                overlap_AC = (overlap_AC + 1);
                            }
                        }
                    }
                }
            }
            int64_t p = (0 - (k + u));
            int64_t q = (k + d);
            if (((p >= (0 - twoX) && p <= twoX) && q <= twoX)) {
                count_B = (count_B + count_mid_i64_i64_i64(X, p, q));
            }
            di = (di + 1);
        }
        k = (k + 1);
    }
    int64_t total = ((((2 * count_A) + count_B) - (2 * overlap_AB)) - overlap_AC);
    printf("%lld\n", total);
    return 0;
}

Generated MLIR

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