Problem 184

Triangles containing the origin with vertices in I_105.

Answer1725323624056
Output1725323624056
StatusPASS
Native helperno
Runtime500 ms
Peak memory9920 KB
Time complexityO(n^2) (estimated)
Space complexityO(n^2) (estimated)

Performance comparison

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

Flow source

# Project Euler 184
# Triangles containing the origin with vertices in I_105.

import euler.nt { isqrt }

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

function gcd_abs(a: i64, b: i64) -> i64 {
    let mut x: i64 = a
    if x < 0 { x = 0 - x }
    let mut y: i64 = b
    if y < 0 { y = 0 - y }
    while y != 0 {
        let t: i64 = x % y
        x = y
        y = t
    }
    return x
}

function comb3(n: i64) -> i64 {
    if n < 3 { return 0 }
    return n * (n - 1) * (n - 2) / 6
}

function half(x: i64, y: i64) -> i32 {
    if y > 0 || (y == 0 && x > 0) { return 0 }
    return 1
}

function angle_lt_pi(ax: i64, ay: i64, bx: i64, by: i64) -> bool {
    let cross: i64 = ax * by - ay * bx
    if cross > 0 { return true }
    if cross < 0 { return false }
    let dot: i64 = ax * bx + ay * by
    return dot > 0
}

function main() -> i32 {
    let r: i64 = 105
    let r2: i64 = r * r
    # Max distinct rays ~ O(r^2)
    let MAX: i64 = 50000
    let vx: ptr<i64> = calloc(MAX, 8)
    let vy: ptr<i64> = calloc(MAX, 8)
    let vw: ptr<i64> = calloc(MAX, 8)
    if vx == null || vy == null || vw == null { return 1 }

    # hash map for rays: key = (dx+1000)*2001+(dy+1000)
    let HS: i64 = 1 << 18
    let hdx: ptr<i64> = calloc(HS, 8)
    let hdy: ptr<i64> = calloc(HS, 8)
    let hw: ptr<i64> = calloc(HS, 8)
    let hused: ptr<i8> = calloc(HS, 1)
    if hdx == null || hdy == null || hw == null || hused == null { return 1 }

    let mut total_points: i64 = 0
    let mut x: i64 = 0 - (r - 1)
    while x < r {
        let maxy2: i64 = r2 - 1 - x * x
        if maxy2 >= 0 {
            let ylim: i64 = isqrt(maxy2)
            let mut y: i64 = 0 - ylim
            while y <= ylim {
                if !(x == 0 && y == 0) {
                    let g: i64 = gcd_abs(x, y)
                    let dx: i64 = x / g
                    let dy: i64 = y / g
                    let mut h: i64 = ((dx + 200) * 401 + (dy + 200)) % HS
                    if h < 0 { h = h + HS }
                    while hused[h] == 1 && !(hdx[h] == dx && hdy[h] == dy) {
                        h = h + 1
                        if h >= HS { h = 0 }
                    }
                    if hused[h] == 0 {
                        hused[h] = 1
                        hdx[h] = dx
                        hdy[h] = dy
                        hw[h] = 1
                    } else {
                        hw[h] = hw[h] + 1
                    }
                    total_points = total_points + 1
                }
                y = y + 1
            }
        }
        x = x + 1
    }

    let mut m: i64 = 0
    let mut hi: i64 = 0
    while hi < HS {
        if hused[hi] == 1 {
            vx[m] = hdx[hi]
            vy[m] = hdy[hi]
            vw[m] = hw[hi]
            m = m + 1
        }
        hi = hi + 1
    }

    # polar sort
    let mut i: i64 = 0
    while i < m {
        let mut j: i64 = i + 1
        while j < m {
            let ha: i32 = half(vx[i], vy[i])
            let hb: i32 = half(vx[j], vy[j])
            let mut swap: bool = false
            if ha > hb { swap = true }
            elif ha == hb {
                let cross: i64 = vx[i] * vy[j] - vy[i] * vx[j]
                if cross < 0 { swap = true }
                elif cross == 0 {
                    let da: i64 = vx[i]*vx[i] + vy[i]*vy[i]
                    let db: i64 = vx[j]*vx[j] + vy[j]*vy[j]
                    if da > db { swap = true }
                }
            }
            if swap {
                let tx: i64 = vx[i]; vx[i] = vx[j]; vx[j] = tx
                let ty: i64 = vy[i]; vy[i] = vy[j]; vy[j] = ty
                let tw: i64 = vw[i]; vw[i] = vw[j]; vw[j] = tw
            }
            j = j + 1
        }
        i = i + 1
    }

    # doubled arrays
    let vx2: ptr<i64> = calloc(2 * m, 8)
    let vy2: ptr<i64> = calloc(2 * m, 8)
    let vw2: ptr<i64> = calloc(2 * m, 8)
    let pref: ptr<i64> = calloc(2 * m + 1, 8)
    i = 0
    while i < m {
        vx2[i] = vx[i]; vy2[i] = vy[i]; vw2[i] = vw[i]
        vx2[i + m] = vx[i]; vy2[i + m] = vy[i]; vw2[i + m] = vw[i]
        i = i + 1
    }
    i = 0
    while i < 2 * m {
        pref[i + 1] = pref[i] + vw2[i]
        i = i + 1
    }

    let mut bad_open: i64 = 0
    let mut jj: i64 = 0
    i = 0
    while i < m {
        if jj < i { jj = i }
        while jj < i + m && angle_lt_pi(vx[i], vy[i], vx2[jj], vy2[jj]) {
            jj = jj + 1
        }
        let W: i64 = pref[jj] - pref[i]
        let wi: i64 = vw[i]
        bad_open = bad_open + comb3(W) - comb3(W - wi)
        i = i + 1
    }

    let total: i64 = comb3(total_points)

    # boundary
    # rebuild line_pos/neg from rays
    let mut boundary: i64 = 0
    # For each ray direction in positive half, find opposite
    i = 0
    while i < m {
        let dx: i64 = vx[i]
        let dy: i64 = vy[i]
        if dx > 0 || (dx == 0 && dy > 0) {
            let P: i64 = vw[i]
            # find opposite -dx,-dy
            let mut Q: i64 = 0
            let mut k: i64 = 0
            while k < m {
                if vx[k] == 0 - dx && vy[k] == 0 - dy {
                    Q = vw[k]
                    break
                }
                k = k + 1
            }
            if P > 0 && Q > 0 {
                let S: i64 = P + Q
                boundary = boundary + P * Q * (total_points - S)
                boundary = boundary + comb3(S) - comb3(P) - comb3(Q)
            }
        }
        i = i + 1
    }

    printf("%lld\n", total - bad_open - boundary)
    free(vx); free(vy); free(vw)
    free(hdx); free(hdy); free(hw); free(hused)
    free(vx2); free(vy2); free(vw2); free(pref)
    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 gcd_abs_i64_i64(int64_t a, int64_t b);
int64_t comb3_i64(int64_t n);
int32_t half_i64_i64(int64_t x, int64_t y);
bool angle_lt_pi_i64_i64_i64_i64(int64_t ax, int64_t ay, int64_t bx, int64_t by);
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 gcd_abs_i64_i64(int64_t a, int64_t b) {
    int64_t x = a;
    if (x < 0) {
        x = (0 - x);
    }
    int64_t y = b;
    if (y < 0) {
        y = (0 - y);
    }
    while (y != 0) {
        int64_t t = FLOW_CHECKED_MOD((x), (y));
        x = y;
        y = t;
    }
    return x;
}

int64_t comb3_i64(int64_t n) {
    if (n < 3) {
        return 0;
    }
    return FLOW_CHECKED_DIV((((n * (n - 1)) * (n - 2))), (6));
}

int32_t half_i64_i64(int64_t x, int64_t y) {
    if ((y > 0 || (y == 0 && x > 0))) {
        return 0;
    }
    return 1;
}

bool angle_lt_pi_i64_i64_i64_i64(int64_t ax, int64_t ay, int64_t bx, int64_t by) {
    int64_t cross = ((ax * by) - (ay * bx));
    if (cross > 0) {
        return 1;
    }
    if (cross < 0) {
        return 0;
    }
    int64_t dot = ((ax * bx) + (ay * by));
    return dot > 0;
}

int32_t main(void) {
    int64_t r = 105;
    int64_t r2 = (r * r);
    int64_t MAX = 50000;
    int64_t* vx = (int64_t*)(calloc(MAX, 8));
    int64_t* vy = (int64_t*)(calloc(MAX, 8));
    int64_t* vw = (int64_t*)(calloc(MAX, 8));
    if (((vx == NULL || vy == NULL) || vw == NULL)) {
        return 1;
    }
    int64_t HS = FLOW_CHECKED_SHL((1), (18));
    int64_t* hdx = (int64_t*)(calloc(HS, 8));
    int64_t* hdy = (int64_t*)(calloc(HS, 8));
    int64_t* hw = (int64_t*)(calloc(HS, 8));
    int8_t* hused = (int8_t*)(calloc(HS, 1));
    if ((((hdx == NULL || hdy == NULL) || hw == NULL) || hused == NULL)) {
        return 1;
    }
    int64_t total_points = 0;
    int64_t x = (0 - (r - 1));
    while (x < r) {
        int64_t maxy2 = ((r2 - 1) - (x * x));
        if (maxy2 >= 0) {
            int64_t ylim = isqrt_i64(maxy2);
            int64_t y = (0 - ylim);
            while (y <= ylim) {
                if ((!((x == 0 && y == 0)))) {
                    int64_t g = gcd_abs_i64_i64(x, y);
                    int64_t dx = FLOW_CHECKED_DIV((x), (g));
                    int64_t dy = FLOW_CHECKED_DIV((y), (g));
                    int64_t h = FLOW_CHECKED_MOD(((((dx + 200) * 401) + (dy + 200))), (HS));
                    if (h < 0) {
                        h = (h + HS);
                    }
                    while ((hused[h] == 1 && (!((hdx[h] == dx && hdy[h] == dy))))) {
                        h = (h + 1);
                        if (h >= HS) {
                            h = 0;
                        }
                    }
                    if (hused[h] == 0) {
                        hused[h] = 1;
                        hdx[h] = dx;
                        hdy[h] = dy;
                        hw[h] = 1;
                    } else {
                        hw[h] = (hw[h] + 1);
                    }
                    total_points = (total_points + 1);
                }
                y = (y + 1);
            }
        }
        x = (x + 1);
    }
    int64_t m = 0;
    int64_t hi = 0;
    while (hi < HS) {
        if (hused[hi] == 1) {
            vx[m] = hdx[hi];
            vy[m] = hdy[hi];
            vw[m] = hw[hi];
            m = (m + 1);
        }
        hi = (hi + 1);
    }
    int64_t i = 0;
    while (i < m) {
        int64_t j = (i + 1);
        while (j < m) {
            int32_t ha = half_i64_i64(vx[i], vy[i]);
            int32_t hb = half_i64_i64(vx[j], vy[j]);
            bool swap = 0;
            if (ha > hb) {
                swap = 1;
            } else if (ha == hb) {
                int64_t cross = ((vx[i] * vy[j]) - (vy[i] * vx[j]));
                if (cross < 0) {
                    swap = 1;
                } else if (cross == 0) {
                    int64_t da = ((vx[i] * vx[i]) + (vy[i] * vy[i]));
                    int64_t db = ((vx[j] * vx[j]) + (vy[j] * vy[j]));
                    if (da > db) {
                        swap = 1;
                    }
                }
            }
            if (swap) {
                int64_t tx = vx[i];
                vx[i] = vx[j];
                vx[j] = tx;
                int64_t ty = vy[i];
                vy[i] = vy[j];
                vy[j] = ty;
                int64_t tw = vw[i];
                vw[i] = vw[j];
                vw[j] = tw;
            }
            j = (j + 1);
        }
        i = (i + 1);
    }
    int64_t* vx2 = (int64_t*)(calloc((2 * m), 8));
    int64_t* vy2 = (int64_t*)(calloc((2 * m), 8));
    int64_t* vw2 = (int64_t*)(calloc((2 * m), 8));
    int64_t* pref = (int64_t*)(calloc(((2 * m) + 1), 8));
    i = 0;
    while (i < m) {
        vx2[i] = vx[i];
        vy2[i] = vy[i];
        vw2[i] = vw[i];
        vx2[(i + m)] = vx[i];
        vy2[(i + m)] = vy[i];
        vw2[(i + m)] = vw[i];
        i = (i + 1);
    }
    i = 0;
    while (i < (2 * m)) {
        pref[(i + 1)] = (pref[i] + vw2[i]);
        i = (i + 1);
    }
    int64_t bad_open = 0;
    int64_t jj = 0;
    i = 0;
    while (i < m) {
        if (jj < i) {
            jj = i;
        }
        while ((jj < (i + m) && angle_lt_pi_i64_i64_i64_i64(vx[i], vy[i], vx2[jj], vy2[jj]))) {
            jj = (jj + 1);
        }
        int64_t W = (pref[jj] - pref[i]);
        int64_t wi = vw[i];
        bad_open = ((bad_open + comb3_i64(W)) - comb3_i64((W - wi)));
        i = (i + 1);
    }
    int64_t total = comb3_i64(total_points);
    int64_t boundary = 0;
    i = 0;
    while (i < m) {
        int64_t dx = vx[i];
        int64_t dy = vy[i];
        if ((dx > 0 || (dx == 0 && dy > 0))) {
            int64_t P = vw[i];
            int64_t Q = 0;
            int64_t k = 0;
            while (k < m) {
                if ((vx[k] == (0 - dx) && vy[k] == (0 - dy))) {
                    Q = vw[k];
                    break;
                }
                k = (k + 1);
            }
            if ((P > 0 && Q > 0)) {
                int64_t S = (P + Q);
                boundary = (boundary + ((P * Q) * (total_points - S)));
                boundary = (((boundary + comb3_i64(S)) - comb3_i64(P)) - comb3_i64(Q));
            }
        }
        i = (i + 1);
    }
    printf("%lld\n", ((total - bad_open) - boundary));
    free(vx);
    free(vy);
    free(vw);
    free(hdx);
    free(hdy);
    free(hw);
    free(hused);
    free(vx2);
    free(vy2);
    free(vw2);
    free(pref);
    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 @gcd_abs(%arg0: i64, %arg1: i64) -> i64 {
    %175 = llvm.mlir.constant(1 : i64) : i64
    %176 = llvm.alloca %175 x i64 : (i64) -> !llvm.ptr
    llvm.store %arg0, %176 : i64, !llvm.ptr
    %177 = llvm.load %176 : !llvm.ptr -> i64
    %178 = arith.constant 0 : i32
    %180 = arith.extsi %178 : i32 to i64
    %179 = arith.cmpi slt, %177, %180 : i64
    cf.cond_br %179, ^bb42, ^bb43
    ^bb42:
      %181 = arith.constant 0 : i32
      %182 = llvm.load %176 : !llvm.ptr -> i64
      %184 = arith.extsi %181 : i32 to i64
      %183 = arith.subi %184, %182 : i64
      llvm.store %183, %176 : i64, !llvm.ptr
      cf.br ^bb44
    ^bb43:
      cf.br ^bb44
    ^bb44:
    %185 = llvm.mlir.constant(1 : i64) : i64
    %186 = llvm.alloca %185 x i64 : (i64) -> !llvm.ptr
    llvm.store %arg1, %186 : i64, !llvm.ptr
    %187 = llvm.load %186 : !llvm.ptr -> i64
    %188 = arith.constant 0 : i32
    %190 = arith.extsi %188 : i32 to i64
    %189 = arith.cmpi slt, %187, %190 : i64
    cf.cond_br %189, ^bb45, ^bb46
    ^bb45:
      %191 = arith.constant 0 : i32
      %192 = llvm.load %186 : !llvm.ptr -> i64
      %194 = arith.extsi %191 : i32 to i64
      %193 = arith.subi %194, %192 : i64
      llvm.store %193, %186 : i64, !llvm.ptr
      cf.br ^bb47
    ^bb46:
      cf.br ^bb47
    ^bb47:
    cf.br ^bb48
    ^bb48:
    %195 = llvm.load %186 : !llvm.ptr -> i64
    %196 = arith.constant 0 : i32
    %198 = arith.extsi %196 : i32 to i64
    %197 = arith.cmpi ne, %195, %198 : i64
    cf.cond_br %197, ^bb49, ^bb50
    ^bb49:
      %199 = llvm.load %176 : !llvm.ptr -> i64
      %200 = llvm.load %186 : !llvm.ptr -> i64
      %201 = arith.remsi %199, %200 : i64
      %202 = llvm.load %186 : !llvm.ptr -> i64
      llvm.store %202, %176 : i64, !llvm.ptr
      llvm.store %201, %186 : i64, !llvm.ptr
      cf.br ^bb48
    ^bb50:
    %203 = llvm.load %176 : !llvm.ptr -> i64
    func.return %203 : i64
  }
  func.func @comb3(%arg0: i64) -> i64 {
    %204 = arith.constant 3 : i32
    %206 = arith.extsi %204 : i32 to i64
    %205 = arith.cmpi slt, %arg0, %206 : i64
    cf.cond_br %205, ^bb51, ^bb52
    ^bb51:
      %207 = arith.constant 0 : i32
      %208 = arith.extsi %207 : i32 to i64
      func.return %208 : i64
    ^bb52:
      cf.br ^bb53
    ^bb53:
    %209 = arith.constant 1 : i32
    %211 = arith.extsi %209 : i32 to i64
    %210 = arith.subi %arg0, %211 : i64
    %212 = arith.muli %arg0, %210 : i64
    %213 = arith.constant 2 : i32
    %215 = arith.extsi %213 : i32 to i64
    %214 = arith.subi %arg0, %215 : i64
    %216 = arith.muli %212, %214 : i64
    %217 = arith.constant 6 : i32
    %219 = arith.extsi %217 : i32 to i64
    %218 = arith.divsi %216, %219 : i64
    func.return %218 : i64
  }
  func.func @half(%arg0: i64, %arg1: i64) -> i32 {
    %220 = arith.constant 0 : i32
    %222 = arith.extsi %220 : i32 to i64
    %221 = arith.cmpi sgt, %arg1, %222 : i64
    %223 = scf.if %221 -> (i1) {
      %224 = arith.constant true
      scf.yield %224 : i1
    } else {
      %225 = arith.constant 0 : i32
      %227 = arith.extsi %225 : i32 to i64
      %226 = arith.cmpi eq, %arg1, %227 : i64
      %228 = scf.if %226 -> (i1) {
        %229 = arith.constant 0 : i32
        %231 = arith.extsi %229 : i32 to i64
        %230 = arith.cmpi sgt, %arg0, %231 : i64
        scf.yield %230 : i1
      } else {
        %232 = arith.constant false
        scf.yield %232 : i1
      }
      scf.yield %228 : i1
    }
    cf.cond_br %223, ^bb54, ^bb55
    ^bb54:
      %233 = arith.constant 0 : i32
      func.return %233 : i32
    ^bb55:
      cf.br ^bb56
    ^bb56:
    %234 = arith.constant 1 : i32
    func.return %234 : i32
  }
  func.func @angle_lt_pi(%arg0: i64, %arg1: i64, %arg2: i64, %arg3: i64) -> i1 {
    %235 = arith.muli %arg0, %arg3 : i64
    %236 = arith.muli %arg1, %arg2 : i64
    %237 = arith.subi %235, %236 : i64
    %238 = arith.constant 0 : i32
    %240 = arith.extsi %238 : i32 to i64
    %239 = arith.cmpi sgt, %237, %240 : i64
    cf.cond_br %239, ^bb57, ^bb58
    ^bb57:
      %241 = arith.constant 1 : i1
      func.return %241 : i1
    ^bb58:
      cf.br ^bb59
    ^bb59:
    %242 = arith.constant 0 : i32
    %244 = arith.extsi %242 : i32 to i64
    %243 = arith.cmpi slt, %237, %244 : i64
    cf.cond_br %243, ^bb60, ^bb61
    ^bb60:
      %245 = arith.constant 0 : i1
      func.return %245 : i1
    ^bb61:
      cf.br ^bb62
    ^bb62:
    %246 = arith.muli %arg0, %arg2 : i64
    %247 = arith.muli %arg1, %arg3 : i64
    %248 = arith.addi %246, %247 : i64
    %249 = arith.constant 0 : i32
    %251 = arith.extsi %249 : i32 to i64
    %250 = arith.cmpi sgt, %248, %251 : i64
    func.return %250 : i1
  }
  func.func @main() -> i32 {
    %252 = arith.constant 105 : i32
    %253 = arith.extsi %252 : i32 to i64
    %254 = arith.muli %253, %253 : i64
    %255 = arith.constant 50000 : i32
    %256 = arith.extsi %255 : i32 to i64
    %258 = arith.constant 8 : i32
    %259 = arith.extsi %258 : i32 to i64
    %257 = func.call @calloc(%256, %259) : (i64, i64) -> !llvm.ptr
    %261 = arith.constant 8 : i32
    %262 = arith.extsi %261 : i32 to i64
    %260 = func.call @calloc(%256, %262) : (i64, i64) -> !llvm.ptr
    %264 = arith.constant 8 : i32
    %265 = arith.extsi %264 : i32 to i64
    %263 = func.call @calloc(%256, %265) : (i64, i64) -> !llvm.ptr
    %266 = llvm.mlir.zero : !llvm.ptr
    %267 = llvm.icmp "eq" %257, %266 : !llvm.ptr
    %268 = scf.if %267 -> (i1) {
      %269 = arith.constant true
      scf.yield %269 : i1
    } else {
      %270 = llvm.mlir.zero : !llvm.ptr
      %271 = llvm.icmp "eq" %260, %270 : !llvm.ptr
      scf.yield %271 : i1
    }
    %272 = scf.if %268 -> (i1) {
      %273 = arith.constant true
      scf.yield %273 : i1
    } else {
      %274 = llvm.mlir.zero : !llvm.ptr
      %275 = llvm.icmp "eq" %263, %274 : !llvm.ptr
      scf.yield %275 : i1
    }
    cf.cond_br %272, ^bb63, ^bb64
    ^bb63:
      %276 = arith.constant 1 : i32
      func.return %276 : i32
    ^bb64:
      cf.br ^bb65
    ^bb65:
    %277 = arith.constant 1 : i32
    %278 = arith.constant 18 : i32
    %279 = arith.shli %277, %278 : i32
    %280 = arith.extsi %279 : i32 to i64
    %282 = arith.constant 8 : i32
    %283 = arith.extsi %282 : i32 to i64
    %281 = func.call @calloc(%280, %283) : (i64, i64) -> !llvm.ptr
    %285 = arith.constant 8 : i32
    %286 = arith.extsi %285 : i32 to i64
    %284 = func.call @calloc(%280, %286) : (i64, i64) -> !llvm.ptr
    %288 = arith.constant 8 : i32
    %289 = arith.extsi %288 : i32 to i64
    %287 = func.call @calloc(%280, %289) : (i64, i64) -> !llvm.ptr
    %291 = arith.constant 1 : i32
    %292 = arith.extsi %291 : i32 to i64
    %290 = func.call @calloc(%280, %292) : (i64, i64) -> !llvm.ptr
    %293 = llvm.mlir.zero : !llvm.ptr
    %294 = llvm.icmp "eq" %281, %293 : !llvm.ptr
    %295 = scf.if %294 -> (i1) {
      %296 = arith.constant true
      scf.yield %296 : i1
    } else {
      %297 = llvm.mlir.zero : !llvm.ptr
      %298 = llvm.icmp "eq" %284, %297 : !llvm.ptr
      scf.yield %298 : i1
    }
    %299 = scf.if %295 -> (i1) {
      %300 = arith.constant true
      scf.yield %300 : i1
    } else {
      %301 = llvm.mlir.zero : !llvm.ptr
      %302 = llvm.icmp "eq" %287, %301 : !llvm.ptr
      scf.yield %302 : i1
    }
    %303 = scf.if %299 -> (i1) {
      %304 = arith.constant true
      scf.yield %304 : i1
    } else {
      %305 = llvm.mlir.zero : !llvm.ptr
      %306 = llvm.icmp "eq" %290, %305 : !llvm.ptr
      scf.yield %306 : i1
    }
    cf.cond_br %303, ^bb66, ^bb67
    ^bb66:
      %307 = arith.constant 1 : i32
      func.return %307 : i32
    ^bb67:
      cf.br ^bb68
    ^bb68:
    %308 = arith.constant 0 : i32
    %309 = arith.extsi %308 : i32 to i64
    %310 = llvm.mlir.constant(1 : i64) : i64
    %311 = llvm.alloca %310 x i64 : (i64) -> !llvm.ptr
    llvm.store %309, %311 : i64, !llvm.ptr
    %312 = arith.constant 0 : i32
    %313 = arith.constant 1 : i32
    %315 = arith.extsi %313 : i32 to i64
    %314 = arith.subi %253, %315 : i64
    %317 = arith.extsi %312 : i32 to i64
    %316 = arith.subi %317, %314 : i64
    %318 = llvm.mlir.constant(1 : i64) : i64
    %319 = llvm.alloca %318 x i64 : (i64) -> !llvm.ptr
    llvm.store %316, %319 : i64, !llvm.ptr
    cf.br ^bb69
    ^bb69:
    %320 = llvm.load %319 : !llvm.ptr -> i64
    %321 = arith.cmpi slt, %320, %253 : i64
    cf.cond_br %321, ^bb70, ^bb71
    ^bb70:
      %322 = arith.constant 1 : i32
      %324 = arith.extsi %322 : i32 to i64
      %323 = arith.subi %254, %324 : i64
      %325 = llvm.load %319 : !llvm.ptr -> i64
      %326 = llvm.load %319 : !llvm.ptr -> i64
      %327 = arith.muli %325, %326 : i64
      %328 = arith.subi %323, %327 : i64
      %329 = arith.constant 0 : i32
      %331 = arith.extsi %329 : i32 to i64
      %330 = arith.cmpi sge, %328, %331 : i64
      cf.cond_br %330, ^bb72, ^bb73
      ^bb72:
        %332 = func.call @isqrt(%328) : (i64) -> i64
        %333 = arith.constant 0 : i32
        %335 = arith.extsi %333 : i32 to i64
        %334 = arith.subi %335, %332 : i64
        %336 = llvm.mlir.constant(1 : i64) : i64
        %337 = llvm.alloca %336 x i64 : (i64) -> !llvm.ptr
        llvm.store %334, %337 : i64, !llvm.ptr
        cf.br ^bb75
        ^bb75:
        %338 = llvm.load %337 : !llvm.ptr -> i64
        %339 = arith.cmpi sle, %338, %332 : i64
        cf.cond_br %339, ^bb76, ^bb77
        ^bb76:
          %340 = llvm.load %319 : !llvm.ptr -> i64
          %341 = arith.constant 0 : i32
          %343 = arith.extsi %341 : i32 to i64
          %342 = arith.cmpi eq, %340, %343 : i64
          %344 = scf.if %342 -> (i1) {
            %345 = llvm.load %337 : !llvm.ptr -> i64
            %346 = arith.constant 0 : i32
            %348 = arith.extsi %346 : i32 to i64
            %347 = arith.cmpi eq, %345, %348 : i64
            scf.yield %347 : i1
          } else {
            %349 = arith.constant false
            scf.yield %349 : i1
          }
          %351 = arith.constant 1 : i1
          %350 = arith.xori %344, %351 : i1
          cf.cond_br %350, ^bb78, ^bb79
          ^bb78:
            %354 = llvm.load %319 : !llvm.ptr -> i64
            %355 = llvm.load %337 : !llvm.ptr -> i64
            %353 = func.call @gcd_abs(%354, %355) : (i64, i64) -> i64
            %356 = llvm.load %319 : !llvm.ptr -> i64
            %357 = arith.divsi %356, %353 : i64
            %358 = llvm.load %337 : !llvm.ptr -> i64
            %359 = arith.divsi %358, %353 : i64
            %360 = arith.constant 200 : i32
            %362 = arith.extsi %360 : i32 to i64
            %361 = arith.addi %357, %362 : i64
            %363 = arith.constant 401 : i32
            %365 = arith.extsi %363 : i32 to i64
            %364 = arith.muli %361, %365 : i64
            %366 = arith.constant 200 : i32
            %368 = arith.extsi %366 : i32 to i64
            %367 = arith.addi %359, %368 : i64
            %369 = arith.addi %364, %367 : i64
            %370 = arith.remsi %369, %280 : i64
            %371 = llvm.mlir.constant(1 : i64) : i64
            %372 = llvm.alloca %371 x i64 : (i64) -> !llvm.ptr
            llvm.store %370, %372 : i64, !llvm.ptr
            %373 = llvm.load %372 : !llvm.ptr -> i64
            %374 = arith.constant 0 : i32
            %376 = arith.extsi %374 : i32 to i64
            %375 = arith.cmpi slt, %373, %376 : i64
            cf.cond_br %375, ^bb81, ^bb82
            ^bb81:
              %377 = llvm.load %372 : !llvm.ptr -> i64
              %378 = arith.addi %377, %280 : i64
              llvm.store %378, %372 : i64, !llvm.ptr
              cf.br ^bb83
            ^bb82:
              cf.br ^bb83
            ^bb83:
            cf.br ^bb84
            ^bb84:
            %380 = llvm.load %372 : !llvm.ptr -> i64
            %381 = llvm.getelementptr %290[%380] : (!llvm.ptr, i64) -> !llvm.ptr, i8
            %379 = llvm.load %381 : !llvm.ptr -> i8
            %382 = arith.constant 1 : i32
            %384 = arith.extsi %379 : i8 to i32
            %383 = arith.cmpi eq, %384, %382 : i32
            %385 = scf.if %383 -> (i1) {
              %387 = llvm.load %372 : !llvm.ptr -> i64
              %388 = llvm.getelementptr %281[%387] : (!llvm.ptr, i64) -> !llvm.ptr, i64
              %386 = llvm.load %388 : !llvm.ptr -> i64
              %389 = arith.cmpi eq, %386, %357 : i64
              %390 = scf.if %389 -> (i1) {
                %392 = llvm.load %372 : !llvm.ptr -> i64
                %393 = llvm.getelementptr %284[%392] : (!llvm.ptr, i64) -> !llvm.ptr, i64
                %391 = llvm.load %393 : !llvm.ptr -> i64
                %394 = arith.cmpi eq, %391, %359 : i64
                scf.yield %394 : i1
              } else {
                %395 = arith.constant false
                scf.yield %395 : i1
              }
              %397 = arith.constant 1 : i1
              %396 = arith.xori %390, %397 : i1
              scf.yield %396 : i1
            } else {
              %399 = arith.constant false
              scf.yield %399 : i1
            }
            cf.cond_br %385, ^bb85, ^bb86
            ^bb85:
              %400 = llvm.load %372 : !llvm.ptr -> i64
              %401 = arith.constant 1 : i32
              %403 = arith.extsi %401 : i32 to i64
              %402 = arith.addi %400, %403 : i64
              llvm.store %402, %372 : i64, !llvm.ptr
              %404 = llvm.load %372 : !llvm.ptr -> i64
              %405 = arith.cmpi sge, %404, %280 : i64
              cf.cond_br %405, ^bb87, ^bb88
              ^bb87:
                %406 = arith.constant 0 : i32
                %407 = arith.extsi %406 : i32 to i64
                llvm.store %407, %372 : i64, !llvm.ptr
                cf.br ^bb89
              ^bb88:
                cf.br ^bb89
              ^bb89:
              cf.br ^bb84
            ^bb86:
            %409 = llvm.load %372 : !llvm.ptr -> i64
            %410 = llvm.getelementptr %290[%409] : (!llvm.ptr, i64) -> !llvm.ptr, i8
            %408 = llvm.load %410 : !llvm.ptr -> i8
            %411 = arith.constant 0 : i32
            %413 = arith.extsi %408 : i8 to i32
            %412 = arith.cmpi eq, %413, %411 : i32
            cf.cond_br %412, ^bb90, ^bb91
            ^bb90:
              %414 = arith.constant 1 : i32
              %415 = llvm.load %372 : !llvm.ptr -> i64
              %416 = arith.trunci %414 : i32 to i8
              %417 = llvm.getelementptr %290[%415] : (!llvm.ptr, i64) -> !llvm.ptr, i8
              llvm.store %416, %417 : i8, !llvm.ptr
              %418 = llvm.load %372 : !llvm.ptr -> i64
              %419 = llvm.getelementptr %281[%418] : (!llvm.ptr, i64) -> !llvm.ptr, i64
              llvm.store %357, %419 : i64, !llvm.ptr
              %420 = llvm.load %372 : !llvm.ptr -> i64
              %421 = llvm.getelementptr %284[%420] : (!llvm.ptr, i64) -> !llvm.ptr, i64
              llvm.store %359, %421 : i64, !llvm.ptr
              %422 = arith.constant 1 : i32
              %423 = llvm.load %372 : !llvm.ptr -> i64
              %424 = arith.extsi %422 : i32 to i64
              %425 = llvm.getelementptr %287[%423] : (!llvm.ptr, i64) -> !llvm.ptr, i64
              llvm.store %424, %425 : i64, !llvm.ptr
              cf.br ^bb92
            ^bb91:
              %427 = llvm.load %372 : !llvm.ptr -> i64
              %428 = llvm.getelementptr %287[%427] : (!llvm.ptr, i64) -> !llvm.ptr, i64
              %426 = llvm.load %428 : !llvm.ptr -> i64
              %429 = arith.constant 1 : i32
              %431 = arith.extsi %429 : i32 to i64
              %430 = arith.addi %426, %431 : i64
              %432 = llvm.load %372 : !llvm.ptr -> i64
              %433 = llvm.getelementptr %287[%432] : (!llvm.ptr, i64) -> !llvm.ptr, i64
              llvm.store %430, %433 : i64, !llvm.ptr
              cf.br ^bb92
            ^bb92:
            %434 = llvm.load %311 : !llvm.ptr -> i64
            %435 = arith.constant 1 : i32
            %437 = arith.extsi %435 : i32 to i64
            %436 = arith.addi %434, %437 : i64
            llvm.store %436, %311 : i64, !llvm.ptr
            cf.br ^bb80
          ^bb79:
            cf.br ^bb80
          ^bb80:
          %438 = llvm.load %337 : !llvm.ptr -> i64
          %439 = arith.constant 1 : i32
          %441 = arith.extsi %439 : i32 to i64
          %440 = arith.addi %438, %441 : i64
          llvm.store %440, %337 : i64, !llvm.ptr
          cf.br ^bb75
        ^bb77:
        cf.br ^bb74
      ^bb73:
        cf.br ^bb74
      ^bb74:
      %442 = llvm.load %319 : !llvm.ptr -> i64
      %443 = arith.constant 1 : i32
      %445 = arith.extsi %443 : i32 to i64
      %444 = arith.addi %442, %445 : i64
      llvm.store %444, %319 : i64, !llvm.ptr
      cf.br ^bb69
    ^bb71:
    %446 = arith.constant 0 : i32
    %447 = arith.extsi %446 : i32 to i64
    %448 = llvm.mlir.constant(1 : i64) : i64
    %449 = llvm.alloca %448 x i64 : (i64) -> !llvm.ptr
    llvm.store %447, %449 : i64, !llvm.ptr
    %450 = arith.constant 0 : i32
    %451 = arith.extsi %450 : i32 to i64
    %452 = llvm.mlir.constant(1 : i64) : i64
    %453 = llvm.alloca %452 x i64 : (i64) -> !llvm.ptr
    llvm.store %451, %453 : i64, !llvm.ptr
    cf.br ^bb93
    ^bb93:
    %454 = llvm.load %453 : !llvm.ptr -> i64
    %455 = arith.cmpi slt, %454, %280 : i64
    cf.cond_br %455, ^bb94, ^bb95
    ^bb94:
      %457 = llvm.load %453 : !llvm.ptr -> i64
      %458 = llvm.getelementptr %290[%457] : (!llvm.ptr, i64) -> !llvm.ptr, i8
      %456 = llvm.load %458 : !llvm.ptr -> i8
      %459 = arith.constant 1 : i32
      %461 = arith.extsi %456 : i8 to i32
      %460 = arith.cmpi eq, %461, %459 : i32
      cf.cond_br %460, ^bb96, ^bb97
      ^bb96:
        %463 = llvm.load %453 : !llvm.ptr -> i64
        %464 = llvm.getelementptr %281[%463] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %462 = llvm.load %464 : !llvm.ptr -> i64
        %465 = llvm.load %449 : !llvm.ptr -> i64
        %466 = llvm.getelementptr %257[%465] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        llvm.store %462, %466 : i64, !llvm.ptr
        %468 = llvm.load %453 : !llvm.ptr -> i64
        %469 = llvm.getelementptr %284[%468] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %467 = llvm.load %469 : !llvm.ptr -> i64
        %470 = llvm.load %449 : !llvm.ptr -> i64
        %471 = llvm.getelementptr %260[%470] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        llvm.store %467, %471 : i64, !llvm.ptr
        %473 = llvm.load %453 : !llvm.ptr -> i64
        %474 = llvm.getelementptr %287[%473] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %472 = llvm.load %474 : !llvm.ptr -> i64
        %475 = llvm.load %449 : !llvm.ptr -> i64
        %476 = llvm.getelementptr %263[%475] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        llvm.store %472, %476 : i64, !llvm.ptr
        %477 = llvm.load %449 : !llvm.ptr -> i64
        %478 = arith.constant 1 : i32
        %480 = arith.extsi %478 : i32 to i64
        %479 = arith.addi %477, %480 : i64
        llvm.store %479, %449 : i64, !llvm.ptr
        cf.br ^bb98
      ^bb97:
        cf.br ^bb98
      ^bb98:
      %481 = llvm.load %453 : !llvm.ptr -> i64
      %482 = arith.constant 1 : i32
      %484 = arith.extsi %482 : i32 to i64
      %483 = arith.addi %481, %484 : i64
      llvm.store %483, %453 : i64, !llvm.ptr
      cf.br ^bb93
    ^bb95:
    %485 = arith.constant 0 : i32
    %486 = arith.extsi %485 : i32 to i64
    %487 = llvm.mlir.constant(1 : i64) : i64
    %488 = llvm.alloca %487 x i64 : (i64) -> !llvm.ptr
    llvm.store %486, %488 : i64, !llvm.ptr
    cf.br ^bb99
    ^bb99:
    %489 = llvm.load %488 : !llvm.ptr -> i64
    %490 = llvm.load %449 : !llvm.ptr -> i64
    %491 = arith.cmpi slt, %489, %490 : i64
    cf.cond_br %491, ^bb100, ^bb101
    ^bb100:
      %492 = llvm.load %488 : !llvm.ptr -> i64
      %493 = arith.constant 1 : i32
      %495 = arith.extsi %493 : i32 to i64
      %494 = arith.addi %492, %495 : i64
      %496 = llvm.mlir.constant(1 : i64) : i64
      %497 = llvm.alloca %496 x i64 : (i64) -> !llvm.ptr
      llvm.store %494, %497 : i64, !llvm.ptr
      cf.br ^bb102
      ^bb102:
      %498 = llvm.load %497 : !llvm.ptr -> i64
      %499 = llvm.load %449 : !llvm.ptr -> i64
      %500 = arith.cmpi slt, %498, %499 : i64
      cf.cond_br %500, ^bb103, ^bb104
      ^bb103:
        %503 = llvm.load %488 : !llvm.ptr -> i64
        %504 = llvm.getelementptr %257[%503] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %502 = llvm.load %504 : !llvm.ptr -> i64
        %506 = llvm.load %488 : !llvm.ptr -> i64
        %507 = llvm.getelementptr %260[%506] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %505 = llvm.load %507 : !llvm.ptr -> i64
        %501 = func.call @half(%502, %505) : (i64, i64) -> i32
        %510 = llvm.load %497 : !llvm.ptr -> i64
        %511 = llvm.getelementptr %257[%510] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %509 = llvm.load %511 : !llvm.ptr -> i64
        %513 = llvm.load %497 : !llvm.ptr -> i64
        %514 = llvm.getelementptr %260[%513] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %512 = llvm.load %514 : !llvm.ptr -> i64
        %508 = func.call @half(%509, %512) : (i64, i64) -> i32
        %515 = arith.constant 0 : i1
        %516 = llvm.mlir.constant(1 : i64) : i64
        %517 = llvm.alloca %516 x i1 : (i64) -> !llvm.ptr
        llvm.store %515, %517 : i1, !llvm.ptr
        %518 = arith.cmpi sgt, %501, %508 : i32
        cf.cond_br %518, ^bb105, ^bb106
        ^bb105:
          %519 = arith.constant 1 : i1
          llvm.store %519, %517 : i1, !llvm.ptr
          cf.br ^bb107
        ^bb106:
          %520 = arith.cmpi eq, %501, %508 : i32
          cf.cond_br %520, ^bb108, ^bb107
        ^bb108:
          %522 = llvm.load %488 : !llvm.ptr -> i64
          %523 = llvm.getelementptr %257[%522] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          %521 = llvm.load %523 : !llvm.ptr -> i64
          %525 = llvm.load %497 : !llvm.ptr -> i64
          %526 = llvm.getelementptr %260[%525] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          %524 = llvm.load %526 : !llvm.ptr -> i64
          %527 = arith.muli %521, %524 : i64
          %529 = llvm.load %488 : !llvm.ptr -> i64
          %530 = llvm.getelementptr %260[%529] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          %528 = llvm.load %530 : !llvm.ptr -> i64
          %532 = llvm.load %497 : !llvm.ptr -> i64
          %533 = llvm.getelementptr %257[%532] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          %531 = llvm.load %533 : !llvm.ptr -> i64
          %534 = arith.muli %528, %531 : i64
          %535 = arith.subi %527, %534 : i64
          %536 = arith.constant 0 : i32
          %538 = arith.extsi %536 : i32 to i64
          %537 = arith.cmpi slt, %535, %538 : i64
          cf.cond_br %537, ^bb109, ^bb110
          ^bb109:
            %539 = arith.constant 1 : i1
            llvm.store %539, %517 : i1, !llvm.ptr
            cf.br ^bb111
          ^bb110:
            %540 = arith.constant 0 : i32
            %542 = arith.extsi %540 : i32 to i64
            %541 = arith.cmpi eq, %535, %542 : i64
            cf.cond_br %541, ^bb112, ^bb111
          ^bb112:
            %544 = llvm.load %488 : !llvm.ptr -> i64
            %545 = llvm.getelementptr %257[%544] : (!llvm.ptr, i64) -> !llvm.ptr, i64
            %543 = llvm.load %545 : !llvm.ptr -> i64
            %547 = llvm.load %488 : !llvm.ptr -> i64
            %548 = llvm.getelementptr %257[%547] : (!llvm.ptr, i64) -> !llvm.ptr, i64
            %546 = llvm.load %548 : !llvm.ptr -> i64
            %549 = arith.muli %543, %546 : i64
            %551 = llvm.load %488 : !llvm.ptr -> i64
            %552 = llvm.getelementptr %260[%551] : (!llvm.ptr, i64) -> !llvm.ptr, i64
            %550 = llvm.load %552 : !llvm.ptr -> i64
            %554 = llvm.load %488 : !llvm.ptr -> i64
            %555 = llvm.getelementptr %260[%554] : (!llvm.ptr, i64) -> !llvm.ptr, i64
            %553 = llvm.load %555 : !llvm.ptr -> i64
            %556 = arith.muli %550, %553 : i64
            %557 = arith.addi %549, %556 : i64
            %559 = llvm.load %497 : !llvm.ptr -> i64
            %560 = llvm.getelementptr %257[%559] : (!llvm.ptr, i64) -> !llvm.ptr, i64
            %558 = llvm.load %560 : !llvm.ptr -> i64
            %562 = llvm.load %497 : !llvm.ptr -> i64
            %563 = llvm.getelementptr %257[%562] : (!llvm.ptr, i64) -> !llvm.ptr, i64
            %561 = llvm.load %563 : !llvm.ptr -> i64
            %564 = arith.muli %558, %561 : i64
            %566 = llvm.load %497 : !llvm.ptr -> i64
            %567 = llvm.getelementptr %260[%566] : (!llvm.ptr, i64) -> !llvm.ptr, i64
            %565 = llvm.load %567 : !llvm.ptr -> i64
            %569 = llvm.load %497 : !llvm.ptr -> i64
            %570 = llvm.getelementptr %260[%569] : (!llvm.ptr, i64) -> !llvm.ptr, i64
            %568 = llvm.load %570 : !llvm.ptr -> i64
            %571 = arith.muli %565, %568 : i64
            %572 = arith.addi %564, %571 : i64
            %573 = arith.cmpi sgt, %557, %572 : i64
            cf.cond_br %573, ^bb113, ^bb114
            ^bb113:
              %574 = arith.constant 1 : i1
              llvm.store %574, %517 : i1, !llvm.ptr
              cf.br ^bb115
            ^bb114:
              cf.br ^bb115
            ^bb115:
            cf.br ^bb111
          ^bb111:
          cf.br ^bb107
        ^bb107:
        %575 = llvm.load %517 : !llvm.ptr -> i1
        cf.cond_br %575, ^bb116, ^bb117
        ^bb116:
          %577 = llvm.load %488 : !llvm.ptr -> i64
          %578 = llvm.getelementptr %257[%577] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          %576 = llvm.load %578 : !llvm.ptr -> i64
          %580 = llvm.load %497 : !llvm.ptr -> i64
          %581 = llvm.getelementptr %257[%580] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          %579 = llvm.load %581 : !llvm.ptr -> i64
          %582 = llvm.load %488 : !llvm.ptr -> i64
          %583 = llvm.getelementptr %257[%582] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          llvm.store %579, %583 : i64, !llvm.ptr
          %584 = llvm.load %497 : !llvm.ptr -> i64
          %585 = llvm.getelementptr %257[%584] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          llvm.store %576, %585 : i64, !llvm.ptr
          %587 = llvm.load %488 : !llvm.ptr -> i64
          %588 = llvm.getelementptr %260[%587] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          %586 = llvm.load %588 : !llvm.ptr -> i64
          %590 = llvm.load %497 : !llvm.ptr -> i64
          %591 = llvm.getelementptr %260[%590] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          %589 = llvm.load %591 : !llvm.ptr -> i64
          %592 = llvm.load %488 : !llvm.ptr -> i64
          %593 = llvm.getelementptr %260[%592] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          llvm.store %589, %593 : i64, !llvm.ptr
          %594 = llvm.load %497 : !llvm.ptr -> i64
          %595 = llvm.getelementptr %260[%594] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          llvm.store %586, %595 : i64, !llvm.ptr
          %597 = llvm.load %488 : !llvm.ptr -> i64
          %598 = llvm.getelementptr %263[%597] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          %596 = llvm.load %598 : !llvm.ptr -> i64
          %600 = llvm.load %497 : !llvm.ptr -> i64
          %601 = llvm.getelementptr %263[%600] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          %599 = llvm.load %601 : !llvm.ptr -> i64
          %602 = llvm.load %488 : !llvm.ptr -> i64
          %603 = llvm.getelementptr %263[%602] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          llvm.store %599, %603 : i64, !llvm.ptr
          %604 = llvm.load %497 : !llvm.ptr -> i64
          %605 = llvm.getelementptr %263[%604] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          llvm.store %596, %605 : i64, !llvm.ptr
          cf.br ^bb118
        ^bb117:
          cf.br ^bb118
        ^bb118:
        %606 = llvm.load %497 : !llvm.ptr -> i64
        %607 = arith.constant 1 : i32
        %609 = arith.extsi %607 : i32 to i64
        %608 = arith.addi %606, %609 : i64
        llvm.store %608, %497 : i64, !llvm.ptr
        cf.br ^bb102
      ^bb104:
      %610 = llvm.load %488 : !llvm.ptr -> i64
      %611 = arith.constant 1 : i32
      %613 = arith.extsi %611 : i32 to i64
      %612 = arith.addi %610, %613 : i64
      llvm.store %612, %488 : i64, !llvm.ptr
      cf.br ^bb99
    ^bb101:
    %615 = arith.constant 2 : i32
    %616 = llvm.load %449 : !llvm.ptr -> i64
    %618 = arith.extsi %615 : i32 to i64
    %617 = arith.muli %618, %616 : i64
    %619 = arith.constant 8 : i32
    %620 = arith.extsi %619 : i32 to i64
    %614 = func.call @calloc(%617, %620) : (i64, i64) -> !llvm.ptr
    %622 = arith.constant 2 : i32
    %623 = llvm.load %449 : !llvm.ptr -> i64
    %625 = arith.extsi %622 : i32 to i64
    %624 = arith.muli %625, %623 : i64
    %626 = arith.constant 8 : i32
    %627 = arith.extsi %626 : i32 to i64
    %621 = func.call @calloc(%624, %627) : (i64, i64) -> !llvm.ptr
    %629 = arith.constant 2 : i32
    %630 = llvm.load %449 : !llvm.ptr -> i64
    %632 = arith.extsi %629 : i32 to i64
    %631 = arith.muli %632, %630 : i64
    %633 = arith.constant 8 : i32
    %634 = arith.extsi %633 : i32 to i64
    %628 = func.call @calloc(%631, %634) : (i64, i64) -> !llvm.ptr
    %636 = arith.constant 2 : i32
    %637 = llvm.load %449 : !llvm.ptr -> i64
    %639 = arith.extsi %636 : i32 to i64
    %638 = arith.muli %639, %637 : i64
    %640 = arith.constant 1 : i32
    %642 = arith.extsi %640 : i32 to i64
    %641 = arith.addi %638, %642 : i64
    %643 = arith.constant 8 : i32
    %644 = arith.extsi %643 : i32 to i64
    %635 = func.call @calloc(%641, %644) : (i64, i64) -> !llvm.ptr
    %645 = arith.constant 0 : i32
    %646 = arith.extsi %645 : i32 to i64
    llvm.store %646, %488 : i64, !llvm.ptr
    cf.br ^bb119
    ^bb119:
    %647 = llvm.load %488 : !llvm.ptr -> i64
    %648 = llvm.load %449 : !llvm.ptr -> i64
    %649 = arith.cmpi slt, %647, %648 : i64
    cf.cond_br %649, ^bb120, ^bb121
    ^bb120:
      %651 = llvm.load %488 : !llvm.ptr -> i64
      %652 = llvm.getelementptr %257[%651] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %650 = llvm.load %652 : !llvm.ptr -> i64
      %653 = llvm.load %488 : !llvm.ptr -> i64
      %654 = llvm.getelementptr %614[%653] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %650, %654 : i64, !llvm.ptr
      %656 = llvm.load %488 : !llvm.ptr -> i64
      %657 = llvm.getelementptr %260[%656] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %655 = llvm.load %657 : !llvm.ptr -> i64
      %658 = llvm.load %488 : !llvm.ptr -> i64
      %659 = llvm.getelementptr %621[%658] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %655, %659 : i64, !llvm.ptr
      %661 = llvm.load %488 : !llvm.ptr -> i64
      %662 = llvm.getelementptr %263[%661] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %660 = llvm.load %662 : !llvm.ptr -> i64
      %663 = llvm.load %488 : !llvm.ptr -> i64
      %664 = llvm.getelementptr %628[%663] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %660, %664 : i64, !llvm.ptr
      %666 = llvm.load %488 : !llvm.ptr -> i64
      %667 = llvm.getelementptr %257[%666] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %665 = llvm.load %667 : !llvm.ptr -> i64
      %668 = llvm.load %488 : !llvm.ptr -> i64
      %669 = llvm.load %449 : !llvm.ptr -> i64
      %670 = arith.addi %668, %669 : i64
      %671 = llvm.getelementptr %614[%670] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %665, %671 : i64, !llvm.ptr
      %673 = llvm.load %488 : !llvm.ptr -> i64
      %674 = llvm.getelementptr %260[%673] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %672 = llvm.load %674 : !llvm.ptr -> i64
      %675 = llvm.load %488 : !llvm.ptr -> i64
      %676 = llvm.load %449 : !llvm.ptr -> i64
      %677 = arith.addi %675, %676 : i64
      %678 = llvm.getelementptr %621[%677] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %672, %678 : i64, !llvm.ptr
      %680 = llvm.load %488 : !llvm.ptr -> i64
      %681 = llvm.getelementptr %263[%680] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %679 = llvm.load %681 : !llvm.ptr -> i64
      %682 = llvm.load %488 : !llvm.ptr -> i64
      %683 = llvm.load %449 : !llvm.ptr -> i64
      %684 = arith.addi %682, %683 : i64
      %685 = llvm.getelementptr %628[%684] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %679, %685 : i64, !llvm.ptr
      %686 = llvm.load %488 : !llvm.ptr -> i64
      %687 = arith.constant 1 : i32
      %689 = arith.extsi %687 : i32 to i64
      %688 = arith.addi %686, %689 : i64
      llvm.store %688, %488 : i64, !llvm.ptr
      cf.br ^bb119
    ^bb121:
    %690 = arith.constant 0 : i32
    %691 = arith.extsi %690 : i32 to i64
    llvm.store %691, %488 : i64, !llvm.ptr
    cf.br ^bb122
    ^bb122:
    %692 = llvm.load %488 : !llvm.ptr -> i64
    %693 = arith.constant 2 : i32
    %694 = llvm.load %449 : !llvm.ptr -> i64
    %696 = arith.extsi %693 : i32 to i64
    %695 = arith.muli %696, %694 : i64
    %697 = arith.cmpi slt, %692, %695 : i64
    cf.cond_br %697, ^bb123, ^bb124
    ^bb123:
      %699 = llvm.load %488 : !llvm.ptr -> i64
      %700 = llvm.getelementptr %635[%699] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %698 = llvm.load %700 : !llvm.ptr -> i64
      %702 = llvm.load %488 : !llvm.ptr -> i64
      %703 = llvm.getelementptr %628[%702] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %701 = llvm.load %703 : !llvm.ptr -> i64
      %704 = arith.addi %698, %701 : i64
      %705 = llvm.load %488 : !llvm.ptr -> i64
      %706 = arith.constant 1 : i32
      %708 = arith.extsi %706 : i32 to i64
      %707 = arith.addi %705, %708 : i64
      %709 = llvm.getelementptr %635[%707] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %704, %709 : i64, !llvm.ptr
      %710 = llvm.load %488 : !llvm.ptr -> i64
      %711 = arith.constant 1 : i32
      %713 = arith.extsi %711 : i32 to i64
      %712 = arith.addi %710, %713 : i64
      llvm.store %712, %488 : i64, !llvm.ptr
      cf.br ^bb122
    ^bb124:
    %714 = arith.constant 0 : i32
    %715 = arith.extsi %714 : i32 to i64
    %716 = llvm.mlir.constant(1 : i64) : i64
    %717 = llvm.alloca %716 x i64 : (i64) -> !llvm.ptr
    llvm.store %715, %717 : i64, !llvm.ptr
    %718 = arith.constant 0 : i32
    %719 = arith.extsi %718 : i32 to i64
    %720 = llvm.mlir.constant(1 : i64) : i64
    %721 = llvm.alloca %720 x i64 : (i64) -> !llvm.ptr
    llvm.store %719, %721 : i64, !llvm.ptr
    %722 = arith.constant 0 : i32
    %723 = arith.extsi %722 : i32 to i64
    llvm.store %723, %488 : i64, !llvm.ptr
    cf.br ^bb125
    ^bb125:
    %724 = llvm.load %488 : !llvm.ptr -> i64
    %725 = llvm.load %449 : !llvm.ptr -> i64
    %726 = arith.cmpi slt, %724, %725 : i64
    cf.cond_br %726, ^bb126, ^bb127
    ^bb126:
      %727 = llvm.load %721 : !llvm.ptr -> i64
      %728 = llvm.load %488 : !llvm.ptr -> i64
      %729 = arith.cmpi slt, %727, %728 : i64
      cf.cond_br %729, ^bb128, ^bb129
      ^bb128:
        %730 = llvm.load %488 : !llvm.ptr -> i64
        llvm.store %730, %721 : i64, !llvm.ptr
        cf.br ^bb130
      ^bb129:
        cf.br ^bb130
      ^bb130:
      cf.br ^bb131
      ^bb131:
      %731 = llvm.load %721 : !llvm.ptr -> i64
      %732 = llvm.load %488 : !llvm.ptr -> i64
      %733 = llvm.load %449 : !llvm.ptr -> i64
      %734 = arith.addi %732, %733 : i64
      %735 = arith.cmpi slt, %731, %734 : i64
      %736 = scf.if %735 -> (i1) {
        %739 = llvm.load %488 : !llvm.ptr -> i64
        %740 = llvm.getelementptr %257[%739] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %738 = llvm.load %740 : !llvm.ptr -> i64
        %742 = llvm.load %488 : !llvm.ptr -> i64
        %743 = llvm.getelementptr %260[%742] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %741 = llvm.load %743 : !llvm.ptr -> i64
        %745 = llvm.load %721 : !llvm.ptr -> i64
        %746 = llvm.getelementptr %614[%745] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %744 = llvm.load %746 : !llvm.ptr -> i64
        %748 = llvm.load %721 : !llvm.ptr -> i64
        %749 = llvm.getelementptr %621[%748] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %747 = llvm.load %749 : !llvm.ptr -> i64
        %737 = func.call @angle_lt_pi(%738, %741, %744, %747) : (i64, i64, i64, i64) -> i1
        scf.yield %737 : i1
      } else {
        %750 = arith.constant false
        scf.yield %750 : i1
      }
      cf.cond_br %736, ^bb132, ^bb133
      ^bb132:
        %751 = llvm.load %721 : !llvm.ptr -> i64
        %752 = arith.constant 1 : i32
        %754 = arith.extsi %752 : i32 to i64
        %753 = arith.addi %751, %754 : i64
        llvm.store %753, %721 : i64, !llvm.ptr
        cf.br ^bb131
      ^bb133:
      %756 = llvm.load %721 : !llvm.ptr -> i64
      %757 = llvm.getelementptr %635[%756] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %755 = llvm.load %757 : !llvm.ptr -> i64
      %759 = llvm.load %488 : !llvm.ptr -> i64
      %760 = llvm.getelementptr %635[%759] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %758 = llvm.load %760 : !llvm.ptr -> i64
      %761 = arith.subi %755, %758 : i64
      %763 = llvm.load %488 : !llvm.ptr -> i64
      %764 = llvm.getelementptr %263[%763] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %762 = llvm.load %764 : !llvm.ptr -> i64
      %765 = llvm.load %717 : !llvm.ptr -> i64
      %766 = func.call @comb3(%761) : (i64) -> i64
      %767 = arith.addi %765, %766 : i64
      %769 = arith.subi %761, %762 : i64
      %768 = func.call @comb3(%769) : (i64) -> i64
      %770 = arith.subi %767, %768 : i64
      llvm.store %770, %717 : i64, !llvm.ptr
      %771 = llvm.load %488 : !llvm.ptr -> i64
      %772 = arith.constant 1 : i32
      %774 = arith.extsi %772 : i32 to i64
      %773 = arith.addi %771, %774 : i64
      llvm.store %773, %488 : i64, !llvm.ptr
      cf.br ^bb125
    ^bb127:
    %776 = llvm.load %311 : !llvm.ptr -> i64
    %775 = func.call @comb3(%776) : (i64) -> i64
    %777 = arith.constant 0 : i32
    %778 = arith.extsi %777 : i32 to i64
    %779 = llvm.mlir.constant(1 : i64) : i64
    %780 = llvm.alloca %779 x i64 : (i64) -> !llvm.ptr
    llvm.store %778, %780 : i64, !llvm.ptr
    %781 = arith.constant 0 : i32
    %782 = arith.extsi %781 : i32 to i64
    llvm.store %782, %488 : i64, !llvm.ptr
    cf.br ^bb134
    ^bb134:
    %783 = llvm.load %488 : !llvm.ptr -> i64
    %784 = llvm.load %449 : !llvm.ptr -> i64
    %785 = arith.cmpi slt, %783, %784 : i64
    cf.cond_br %785, ^bb135, ^bb136
    ^bb135:
      %787 = llvm.load %488 : !llvm.ptr -> i64
      %788 = llvm.getelementptr %257[%787] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %786 = llvm.load %788 : !llvm.ptr -> i64
      %790 = llvm.load %488 : !llvm.ptr -> i64
      %791 = llvm.getelementptr %260[%790] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %789 = llvm.load %791 : !llvm.ptr -> i64
      %792 = arith.constant 0 : i32
      %794 = arith.extsi %792 : i32 to i64
      %793 = arith.cmpi sgt, %786, %794 : i64
      %795 = scf.if %793 -> (i1) {
        %796 = arith.constant true
        scf.yield %796 : i1
      } else {
        %797 = arith.constant 0 : i32
        %799 = arith.extsi %797 : i32 to i64
        %798 = arith.cmpi eq, %786, %799 : i64
        %800 = scf.if %798 -> (i1) {
          %801 = arith.constant 0 : i32
          %803 = arith.extsi %801 : i32 to i64
          %802 = arith.cmpi sgt, %789, %803 : i64
          scf.yield %802 : i1
        } else {
          %804 = arith.constant false
          scf.yield %804 : i1
        }
        scf.yield %800 : i1
      }
      cf.cond_br %795, ^bb137, ^bb138
      ^bb137:
        %806 = llvm.load %488 : !llvm.ptr -> i64
        %807 = llvm.getelementptr %263[%806] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %805 = llvm.load %807 : !llvm.ptr -> i64
        %808 = arith.constant 0 : i32
        %809 = arith.extsi %808 : i32 to i64
        %810 = llvm.mlir.constant(1 : i64) : i64
        %811 = llvm.alloca %810 x i64 : (i64) -> !llvm.ptr
        llvm.store %809, %811 : i64, !llvm.ptr
        %812 = arith.constant 0 : i32
        %813 = arith.extsi %812 : i32 to i64
        %814 = llvm.mlir.constant(1 : i64) : i64
        %815 = llvm.alloca %814 x i64 : (i64) -> !llvm.ptr
        llvm.store %813, %815 : i64, !llvm.ptr
        cf.br ^bb140
        ^bb140:
        %816 = llvm.load %815 : !llvm.ptr -> i64
        %817 = llvm.load %449 : !llvm.ptr -> i64
        %818 = arith.cmpi slt, %816, %817 : i64
        cf.cond_br %818, ^bb141, ^bb142
        ^bb141:
          %820 = llvm.load %815 : !llvm.ptr -> i64
          %821 = llvm.getelementptr %257[%820] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          %819 = llvm.load %821 : !llvm.ptr -> i64
          %822 = arith.constant 0 : i32
          %824 = arith.extsi %822 : i32 to i64
          %823 = arith.subi %824, %786 : i64
          %825 = arith.cmpi eq, %819, %823 : i64
          %826 = scf.if %825 -> (i1) {
            %828 = llvm.load %815 : !llvm.ptr -> i64
            %829 = llvm.getelementptr %260[%828] : (!llvm.ptr, i64) -> !llvm.ptr, i64
            %827 = llvm.load %829 : !llvm.ptr -> i64
            %830 = arith.constant 0 : i32
            %832 = arith.extsi %830 : i32 to i64
            %831 = arith.subi %832, %789 : i64
            %833 = arith.cmpi eq, %827, %831 : i64
            scf.yield %833 : i1
          } else {
            %834 = arith.constant false
            scf.yield %834 : i1
          }
          cf.cond_br %826, ^bb143, ^bb144
          ^bb143:
            %836 = llvm.load %815 : !llvm.ptr -> i64
            %837 = llvm.getelementptr %263[%836] : (!llvm.ptr, i64) -> !llvm.ptr, i64
            %835 = llvm.load %837 : !llvm.ptr -> i64
            llvm.store %835, %811 : i64, !llvm.ptr
            cf.br ^bb142
          ^bb144:
            cf.br ^bb145
          ^bb145:
          %838 = llvm.load %815 : !llvm.ptr -> i64
          %839 = arith.constant 1 : i32
          %841 = arith.extsi %839 : i32 to i64
          %840 = arith.addi %838, %841 : i64
          llvm.store %840, %815 : i64, !llvm.ptr
          cf.br ^bb140
        ^bb142:
        %842 = arith.constant 0 : i32
        %844 = arith.extsi %842 : i32 to i64
        %843 = arith.cmpi sgt, %805, %844 : i64
        %845 = scf.if %843 -> (i1) {
          %846 = llvm.load %811 : !llvm.ptr -> i64
          %847 = arith.constant 0 : i32
          %849 = arith.extsi %847 : i32 to i64
          %848 = arith.cmpi sgt, %846, %849 : i64
          scf.yield %848 : i1
        } else {
          %850 = arith.constant false
          scf.yield %850 : i1
        }
        cf.cond_br %845, ^bb146, ^bb147
        ^bb146:
          %851 = llvm.load %811 : !llvm.ptr -> i64
          %852 = arith.addi %805, %851 : i64
          %853 = llvm.load %780 : !llvm.ptr -> i64
          %854 = llvm.load %811 : !llvm.ptr -> i64
          %855 = arith.muli %805, %854 : i64
          %856 = llvm.load %311 : !llvm.ptr -> i64
          %857 = arith.subi %856, %852 : i64
          %858 = arith.muli %855, %857 : i64
          %859 = arith.addi %853, %858 : i64
          llvm.store %859, %780 : i64, !llvm.ptr
          %860 = llvm.load %780 : !llvm.ptr -> i64
          %861 = func.call @comb3(%852) : (i64) -> i64
          %862 = arith.addi %860, %861 : i64
          %863 = func.call @comb3(%805) : (i64) -> i64
          %864 = arith.subi %862, %863 : i64
          %866 = llvm.load %811 : !llvm.ptr -> i64
          %865 = func.call @comb3(%866) : (i64) -> i64
          %867 = arith.subi %864, %865 : i64
          llvm.store %867, %780 : i64, !llvm.ptr
          cf.br ^bb148
        ^bb147:
          cf.br ^bb148
        ^bb148:
        cf.br ^bb139
      ^bb138:
        cf.br ^bb139
      ^bb139:
      %868 = llvm.load %488 : !llvm.ptr -> i64
      %869 = arith.constant 1 : i32
      %871 = arith.extsi %869 : i32 to i64
      %870 = arith.addi %868, %871 : i64
      llvm.store %870, %488 : i64, !llvm.ptr
      cf.br ^bb134
    ^bb136:
    %872 = llvm.mlir.addressof @str_0 : !llvm.ptr
    %873 = llvm.load %717 : !llvm.ptr -> i64
    %874 = arith.subi %775, %873 : i64
    %875 = llvm.load %780 : !llvm.ptr -> i64
    %876 = arith.subi %874, %875 : i64
    %877 = llvm.call @printf(%872, %876) vararg(!llvm.func<i32 (ptr, ...)>) : (!llvm.ptr, i64) -> i32
    func.call @free(%257) : (!llvm.ptr) -> ()
    func.call @free(%260) : (!llvm.ptr) -> ()
    func.call @free(%263) : (!llvm.ptr) -> ()
    func.call @free(%281) : (!llvm.ptr) -> ()
    func.call @free(%284) : (!llvm.ptr) -> ()
    func.call @free(%287) : (!llvm.ptr) -> ()
    func.call @free(%290) : (!llvm.ptr) -> ()
    func.call @free(%614) : (!llvm.ptr) -> ()
    func.call @free(%621) : (!llvm.ptr) -> ()
    func.call @free(%628) : (!llvm.ptr) -> ()
    func.call @free(%635) : (!llvm.ptr) -> ()
    %889 = arith.constant 0 : i32
    func.return %889 : i32
  }
}