Problem 482

The Incenter of a Triangle — S(10^7) via integer inradii + Pythagorean legs.

Answer1400824879147
Output1400824879147
StatusPASS
Native helperno
Runtime1100 ms
Peak memory85280 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 482
# The Incenter of a Triangle — S(10^7) via integer inradii + Pythagorean legs.

import euler.nt { isqrt }

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

function gcd64(a0: i64, b0: i64) -> i64 {
    let mut a: i64 = a0
    let mut b: i64 = b0
    while b != 0 {
        let t: i64 = a % b
        a = b
        b = t
    }
    if a < 0 { return 0 - a }
    return a
}

function S(P: i64) -> i64 {
    let s_max: i64 = P / 2
    if s_max < 3 { return 0 }
    let x_max: i64 = s_max - 2
    let r_max: i64 = ((s_max as f64) * sqrt(3.0) / 9.0) as i64 + 2

    let counts: ptr<i32> = calloc(r_max + 1, 4)
    let m_limit: i64 = isqrt(x_max) + 1
    let mut m: i64 = 2
    while m <= m_limit {
        let mm: i64 = m * m
        let mut n: i64 = 1
        while n < m {
            if ((m - n) & 1) != 0 {
                if gcd64(m, n) == 1 {
                    let mut a: i64 = mm - n * n
                    let mut b: i64 = 2 * m * n
                    if a > b {
                        let tmp: i64 = a
                        a = b
                        b = tmp
                    }
                    # r = k*a, x = k*b
                    let mut k_max: i64 = r_max / a
                    let kb: i64 = x_max / b
                    if kb < k_max { k_max = kb }
                    let mut k: i64 = 1
                    while k <= k_max {
                        counts[k * a] = counts[k * a] + 1
                        k = k + 1
                    }
                    # r = k*b, x = k*a
                    k_max = r_max / b
                    let ka: i64 = x_max / a
                    if ka < k_max { k_max = ka }
                    k = 1
                    while k <= k_max {
                        counts[k * b] = counts[k * b] + 1
                        k = k + 1
                    }
                }
            }
            n = n + 1
        }
        m = m + 1
    }

    let offsets: ptr<i64> = calloc(r_max + 2, 8)
    let mut total_pairs: i64 = 0
    let mut r: i64 = 1
    while r <= r_max {
        total_pairs = total_pairs + (counts[r] as i64)
        offsets[r + 1] = total_pairs
        r = r + 1
    }
    let xs: ptr<i32> = calloc(total_pairs, 4)
    let us: ptr<i32> = calloc(total_pairs, 4)
    let pos: ptr<i64> = calloc(r_max + 1, 8)
    r = 0
    while r <= r_max {
        pos[r] = offsets[r]
        r = r + 1
    }

    m = 2
    while m <= m_limit {
        let mm: i64 = m * m
        let mut n: i64 = 1
        while n < m {
            if ((m - n) & 1) != 0 {
                if gcd64(m, n) == 1 {
                    let mut a: i64 = mm - n * n
                    let mut b: i64 = 2 * m * n
                    let c: i64 = mm + n * n
                    if a > b {
                        let tmp: i64 = a
                        a = b
                        b = tmp
                    }
                    let mut k_max: i64 = r_max / a
                    let kb: i64 = x_max / b
                    if kb < k_max { k_max = kb }
                    let mut k: i64 = 1
                    while k <= k_max {
                        let rr: i64 = k * a
                        let idx: i64 = pos[rr]
                        xs[idx] = (k * b) as i32
                        us[idx] = (k * c) as i32
                        pos[rr] = idx + 1
                        k = k + 1
                    }
                    k_max = r_max / b
                    let ka: i64 = x_max / a
                    if ka < k_max { k_max = ka }
                    k = 1
                    while k <= k_max {
                        let rr: i64 = k * b
                        let idx: i64 = pos[rr]
                        xs[idx] = (k * a) as i32
                        us[idx] = (k * c) as i32
                        pos[rr] = idx + 1
                        k = k + 1
                    }
                }
            }
            n = n + 1
        }
        m = m + 1
    }

    # For each r: map x -> u via open addressing, then enumerate x<=y
    let mut ans: i64 = 0
    let HCAP: i64 = 4096
    let hkey: ptr<i32> = calloc(HCAP, 4)
    let hval: ptr<i32> = calloc(HCAP, 4)
    let hused: ptr<i8> = calloc(HCAP, 1)
    let xlist: ptr<i32> = calloc(HCAP, 4)

    r = 1
    while r <= r_max {
        let start: i64 = offsets[r]
        let end: i64 = offsets[r + 1]
        let cnt: i64 = end - start
        if cnt >= 3 {
            let mut i: i64 = 0
            while i < HCAP {
                hused[i] = 0
                i = i + 1
            }
            let mut nx: i64 = 0
            i = start
            while i < end {
                let xv: i32 = xs[i]
                let uv: i32 = us[i]
                let mut slot: i64 = (xv as i64) % HCAP
                if slot < 0 { slot = 0 - slot }
                while hused[slot] != 0 && hkey[slot] != xv {
                    slot = slot + 1
                    if slot == HCAP { slot = 0 }
                }
                if hused[slot] == 0 {
                    hused[slot] = 1
                    hkey[slot] = xv
                    hval[slot] = uv
                    xlist[nx] = xv
                    nx = nx + 1
                }
                i = i + 1
            }
            if nx >= 3 {
                # sort xlist ascending
                i = 0
                while i < nx {
                    let mut j: i64 = i + 1
                    while j < nx {
                        if xlist[j] < xlist[i] {
                            let tmp: i32 = xlist[i]
                            xlist[i] = xlist[j]
                            xlist[j] = tmp
                        }
                        j = j + 1
                    }
                    i = i + 1
                }
                let r2: i64 = r * r
                i = 0
                while i < nx {
                    let x: i64 = xlist[i] as i64
                    # lookup ux
                    let mut slot: i64 = x % HCAP
                    while hused[slot] != 0 && (hkey[slot] as i64) != x {
                        slot = slot + 1
                        if slot == HCAP { slot = 0 }
                    }
                    let ux: i64 = hval[slot] as i64
                    let mut j: i64 = i
                    while j < nx {
                        let y: i64 = xlist[j] as i64
                        let denom: i64 = x * y - r2
                        if denom > 0 {
                            let numer: i64 = r2 * (x + y)
                            if numer % denom == 0 {
                                let z: i64 = numer / denom
                                if z >= y {
                                    let s: i64 = x + y + z
                                    if s <= s_max {
                                        # lookup uz
                                        let mut slotz: i64 = z % HCAP
                                        let mut found: i64 = 0
                                        let mut uz: i64 = 0
                                        while hused[slotz] != 0 {
                                            if (hkey[slotz] as i64) == z {
                                                found = 1
                                                uz = hval[slotz] as i64
                                                break
                                            }
                                            slotz = slotz + 1
                                            if slotz == HCAP { slotz = 0 }
                                        }
                                        if found != 0 {
                                            # uy
                                            let mut sloty: i64 = y % HCAP
                                            while hused[sloty] != 0 && (hkey[sloty] as i64) != y {
                                                sloty = sloty + 1
                                                if sloty == HCAP { sloty = 0 }
                                            }
                                            let uy: i64 = hval[sloty] as i64
                                            ans = ans + 2 * s + ux + uy + uz
                                        }
                                    }
                                }
                            }
                        }
                        j = j + 1
                    }
                    i = i + 1
                }
            }
        }
        r = r + 1
    }

    free(xlist)
    free(hused)
    free(hval)
    free(hkey)
    free(pos)
    free(us)
    free(xs)
    free(offsets)
    free(counts)
    return ans
}

function main() -> i32 {
    printf("%lld\n", S(10000000))
    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 gcd64_i64_i64(int64_t a0, int64_t b0);
int64_t S_i64(int64_t P);
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 gcd64_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;
    }
    if (a < 0) {
        return (0 - a);
    }
    return a;
}

int64_t S_i64(int64_t P) {
    int64_t s_max = FLOW_CHECKED_DIV((P), (2));
    if (s_max < 3) {
        return 0;
    }
    int64_t x_max = (s_max - 2);
    int64_t r_max = (((int64_t)(((((double)(s_max)) * sqrt(3.0)) / 9.0))) + 2);
    int32_t* counts = (int32_t*)(calloc((r_max + 1), 4));
    int64_t m_limit = (isqrt_i64(x_max) + 1);
    int64_t m = 2;
    while (m <= m_limit) {
        int64_t mm = (m * m);
        int64_t n = 1;
        while (n < m) {
            if (((m - n) & 1) != 0) {
                if (gcd64_i64_i64(m, n) == 1) {
                    int64_t a = (mm - (n * n));
                    int64_t b = ((2 * m) * n);
                    if (a > b) {
                        int64_t tmp = a;
                        a = b;
                        b = tmp;
                    }
                    int64_t k_max = FLOW_CHECKED_DIV((r_max), (a));
                    int64_t kb = FLOW_CHECKED_DIV((x_max), (b));
                    if (kb < k_max) {
                        k_max = kb;
                    }
                    int64_t k = 1;
                    while (k <= k_max) {
                        counts[(k * a)] = (counts[(k * a)] + 1);
                        k = (k + 1);
                    }
                    k_max = FLOW_CHECKED_DIV((r_max), (b));
                    int64_t ka = FLOW_CHECKED_DIV((x_max), (a));
                    if (ka < k_max) {
                        k_max = ka;
                    }
                    k = 1;
                    while (k <= k_max) {
                        counts[(k * b)] = (counts[(k * b)] + 1);
                        k = (k + 1);
                    }
                }
            }
            n = (n + 1);
        }
        m = (m + 1);
    }
    int64_t* offsets = (int64_t*)(calloc((r_max + 2), 8));
    int64_t total_pairs = 0;
    int64_t r = 1;
    while (r <= r_max) {
        total_pairs = (total_pairs + ((int64_t)(counts[r])));
        offsets[(r + 1)] = total_pairs;
        r = (r + 1);
    }
    int32_t* xs = (int32_t*)(calloc(total_pairs, 4));
    int32_t* us = (int32_t*)(calloc(total_pairs, 4));
    int64_t* pos = (int64_t*)(calloc((r_max + 1), 8));
    r = 0;
    while (r <= r_max) {
        pos[r] = offsets[r];
        r = (r + 1);
    }
    m = 2;
    while (m <= m_limit) {
        int64_t mm = (m * m);
        int64_t n = 1;
        while (n < m) {
            if (((m - n) & 1) != 0) {
                if (gcd64_i64_i64(m, n) == 1) {
                    int64_t a = (mm - (n * n));
                    int64_t b = ((2 * m) * n);
                    int64_t c = (mm + (n * n));
                    if (a > b) {
                        int64_t tmp = a;
                        a = b;
                        b = tmp;
                    }
                    int64_t k_max = FLOW_CHECKED_DIV((r_max), (a));
                    int64_t kb = FLOW_CHECKED_DIV((x_max), (b));
                    if (kb < k_max) {
                        k_max = kb;
                    }
                    int64_t k = 1;
                    while (k <= k_max) {
                        int64_t rr = (k * a);
                        int64_t idx = pos[rr];
                        xs[idx] = ((int32_t)((k * b)));
                        us[idx] = ((int32_t)((k * c)));
                        pos[rr] = (idx + 1);
                        k = (k + 1);
                    }
                    k_max = FLOW_CHECKED_DIV((r_max), (b));
                    int64_t ka = FLOW_CHECKED_DIV((x_max), (a));
                    if (ka < k_max) {
                        k_max = ka;
                    }
                    k = 1;
                    while (k <= k_max) {
                        int64_t rr = (k * b);
                        int64_t idx = pos[rr];
                        xs[idx] = ((int32_t)((k * a)));
                        us[idx] = ((int32_t)((k * c)));
                        pos[rr] = (idx + 1);
                        k = (k + 1);
                    }
                }
            }
            n = (n + 1);
        }
        m = (m + 1);
    }
    int64_t ans = 0;
    int64_t HCAP = 4096;
    int32_t* hkey = (int32_t*)(calloc(HCAP, 4));
    int32_t* hval = (int32_t*)(calloc(HCAP, 4));
    int8_t* hused = (int8_t*)(calloc(HCAP, 1));
    int32_t* xlist = (int32_t*)(calloc(HCAP, 4));
    r = 1;
    while (r <= r_max) {
        int64_t start = offsets[r];
        int64_t end = offsets[(r + 1)];
        int64_t cnt = (end - start);
        if (cnt >= 3) {
            int64_t i = 0;
            while (i < HCAP) {
                hused[i] = 0;
                i = (i + 1);
            }
            int64_t nx = 0;
            i = start;
            while (i < end) {
                int32_t xv = xs[i];
                int32_t uv = us[i];
                int64_t slot = FLOW_CHECKED_MOD((((int64_t)(xv))), (HCAP));
                if (slot < 0) {
                    slot = (0 - slot);
                }
                while ((hused[slot] != 0 && hkey[slot] != xv)) {
                    slot = (slot + 1);
                    if (slot == HCAP) {
                        slot = 0;
                    }
                }
                if (hused[slot] == 0) {
                    hused[slot] = 1;
                    hkey[slot] = xv;
                    hval[slot] = uv;
                    xlist[nx] = xv;
                    nx = (nx + 1);
                }
                i = (i + 1);
            }
            if (nx >= 3) {
                i = 0;
                while (i < nx) {
                    int64_t j = (i + 1);
                    while (j < nx) {
                        if (xlist[j] < xlist[i]) {
                            int32_t tmp = xlist[i];
                            xlist[i] = xlist[j];
                            xlist[j] = tmp;
                        }
                        j = (j + 1);
                    }
                    i = (i + 1);
                }
                int64_t r2 = (r * r);
                i = 0;
                while (i < nx) {
                    int64_t x = ((int64_t)(xlist[i]));
                    int64_t slot = FLOW_CHECKED_MOD((x), (HCAP));
                    while ((hused[slot] != 0 && ((int64_t)(hkey[slot])) != x)) {
                        slot = (slot + 1);
                        if (slot == HCAP) {
                            slot = 0;
                        }
                    }
                    int64_t ux = ((int64_t)(hval[slot]));
                    int64_t j = i;
                    while (j < nx) {
                        int64_t y = ((int64_t)(xlist[j]));
                        int64_t denom = ((x * y) - r2);
                        if (denom > 0) {
                            int64_t numer = (r2 * (x + y));
                            if (FLOW_CHECKED_MOD((numer), (denom)) == 0) {
                                int64_t z = FLOW_CHECKED_DIV((numer), (denom));
                                if (z >= y) {
                                    int64_t s = ((x + y) + z);
                                    if (s <= s_max) {
                                        int64_t slotz = FLOW_CHECKED_MOD((z), (HCAP));
                                        int64_t found = 0;
                                        int64_t uz = 0;
                                        while (hused[slotz] != 0) {
                                            if (((int64_t)(hkey[slotz])) == z) {
                                                found = 1;
                                                uz = ((int64_t)(hval[slotz]));
                                                break;
                                            }
                                            slotz = (slotz + 1);
                                            if (slotz == HCAP) {
                                                slotz = 0;
                                            }
                                        }
                                        if (found != 0) {
                                            int64_t sloty = FLOW_CHECKED_MOD((y), (HCAP));
                                            while ((hused[sloty] != 0 && ((int64_t)(hkey[sloty])) != y)) {
                                                sloty = (sloty + 1);
                                                if (sloty == HCAP) {
                                                    sloty = 0;
                                                }
                                            }
                                            int64_t uy = ((int64_t)(hval[sloty]));
                                            ans = ((((ans + (2 * s)) + ux) + uy) + uz);
                                        }
                                    }
                                }
                            }
                        }
                        j = (j + 1);
                    }
                    i = (i + 1);
                }
            }
        }
        r = (r + 1);
    }
    free(xlist);
    free(hused);
    free(hval);
    free(hkey);
    free(pos);
    free(us);
    free(xs);
    free(offsets);
    free(counts);
    return ans;
}

int32_t main(void) {
    printf("%lld\n", S_i64(10000000));
    return 0;
}

Generated MLIR

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