Problem 261

Sum of pivots k <= 10^10 for pivoted square sums.

Answer238890850232021
Output238890850232021
StatusPASS
Native helperno
Runtime10 ms
Peak memory7664 KB
Time complexityO(n^3) (estimated)
Space complexityO(n^2) (estimated)

Performance comparison

MetricOur solutionBest known
Time complexityO(n^3)O(n log n)
Space complexityO(n^2)O(n)
ApproachFlow solutionSearch with pruning
VerdictSuboptimal

Flow source

# Project Euler 261
# Sum of pivots k <= 10^10 for pivoted square sums.

import euler.nt { isqrt }

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

# Multiply two non-neg i64 into hi:lo (unsigned interpretation of bits)
function mul128(a: i64, b: i64, hi: ptr<i64>, lo: ptr<i64>) -> void {
    let mask: i64 = 4294967295
    let a0: i64 = a & mask
    let a1: i64 = (a >> 32) & mask
    let b0: i64 = b & mask
    let b1: i64 = (b >> 32) & mask
    let p0: i64 = a0 * b0
    let p1: i64 = a0 * b1
    let p2: i64 = a1 * b0
    let p3: i64 = a1 * b1
    let mut mid: i64 = (p0 >> 32) + (p1 & mask) + (p2 & mask)
    lo[0] = (p0 & mask) | ((mid & mask) << 32)
    hi[0] = p3 + (p1 >> 32) + (p2 >> 32) + (mid >> 32)
}

function add128(ahi: i64, alo: i64, bhi: i64, blo: i64, hi: ptr<i64>, lo: ptr<i64>) -> void {
    let mask: i64 = 4294967295
    # add low as unsigned - use careful
    let mut lo_sum: i64 = alo + blo
    let mut carry: i64 = 0
    # detect unsigned overflow: if both nonneg and sum < either, or mixed signs hard
    # Since pell numbers stay positive and < 2^63 for final x,y we only need intermediates
    # that may exceed 2^63. Use unsigned compare via bits.
    let alo_u_hi: i64 = (alo >> 32) & mask
    let alo_u_lo: i64 = alo & mask
    let blo_u_hi: i64 = (blo >> 32) & mask
    let blo_u_lo: i64 = blo & mask
    let s_lo: i64 = alo_u_lo + blo_u_lo
    let c1: i64 = s_lo >> 32
    let s_hi: i64 = alo_u_hi + blo_u_hi + c1
    carry = s_hi >> 32
    lo[0] = (s_lo & mask) | ((s_hi & mask) << 32)
    hi[0] = ahi + bhi + carry
}

function set_add(keys: ptr<i64>, used: ptr<i8>, cap: i64, key: i64) -> bool {
    let mut h: i64 = key % cap
    if h < 0 { h = -h }
    while used[h] != 0 {
        if keys[h] == key { return false }
        h = h + 1
        if h == cap { h = 0 }
    }
    used[h] = 1
    keys[h] = key
    return true
}

function main() -> i32 {
    let LIMIT: i64 = 10000000000
    let mmax: i64 = (isqrt(1 + 2 * LIMIT) - 1) / 2
    let spf: ptr<i32> = calloc(mmax + 3, 4)
    let mut i: i64 = 0
    while i <= mmax + 2 {
        spf[i] = i as i32
        i = i + 1
    }
    i = 2
    while i * i <= mmax + 2 {
        if (spf[i] as i64) == i {
            let mut j: i64 = i * i
            while j <= mmax + 2 {
                if (spf[j] as i64) == j {
                    spf[j] = i as i32
                }
                j = j + i
            }
        }
        i = i + 1
    }

    # pell cache as parallel arrays keyed by D via hashmap
    let PCAP: i64 = 200003
    let p_used: ptr<i8> = calloc(PCAP, 1)
    let p_D: ptr<i64> = calloc(PCAP, 8)
    let p_x: ptr<i64> = calloc(PCAP, 8)
    let p_y: ptr<i64> = calloc(PCAP, 8)

    let SCAP: i64 = 150001
    let s_used: ptr<i8> = calloc(SCAP, 1)
    let s_keys: ptr<i64> = calloc(SCAP, 8)
    let mut sum: i64 = 0

    let hi1: ptr<i64> = calloc(1, 8)
    let lo1: ptr<i64> = calloc(1, 8)
    let hi2: ptr<i64> = calloc(1, 8)
    let lo2: ptr<i64> = calloc(1, 8)
    let hi3: ptr<i64> = calloc(1, 8)
    let lo3: ptr<i64> = calloc(1, 8)

    let mut m: i64 = 1
    while m <= mmax {
        # squarefree_and_sqrt(m)
        let mut n: i64 = m
        let mut s: i64 = 1
        let mut p: i64 = 1
        while n > 1 {
            let pr: i64 = spf[n] as i64
            let mut e: i64 = 0
            while n % pr == 0 {
                n = n / pr
                e = e + 1
            }
            if e % 2 == 1 { s = s * pr }
            let mut ee: i64 = e / 2
            let mut pp: i64 = 1
            let mut t: i64 = 0
            while t < ee {
                pp = pp * pr
                t = t + 1
            }
            p = p * pp
        }
        n = m + 1
        let mut g: i64 = 1
        let mut r: i64 = 1
        while n > 1 {
            let pr: i64 = spf[n] as i64
            let mut e: i64 = 0
            while n % pr == 0 {
                n = n / pr
                e = e + 1
            }
            if e % 2 == 1 { g = g * pr }
            let mut ee: i64 = e / 2
            let mut pp: i64 = 1
            let mut t: i64 = 0
            while t < ee {
                pp = pp * pr
                t = t + 1
            }
            r = r * pp
        }
        let D: i64 = s * g

        # get or compute pell fundamental
        let mut h: i64 = D % PCAP
        if h < 0 { h = -h }
        while p_used[h] != 0 && p_D[h] != D {
            h = h + 1
            if h == PCAP { h = 0 }
        }
        let mut x1: i64 = 0
        let mut y1: i64 = 0
        if p_used[h] != 0 {
            x1 = p_x[h]
            y1 = p_y[h]
        } else {
            let a0: i64 = isqrt(D)
            let mut mm: i64 = 0
            let mut dd: i64 = 1
            let mut a: i64 = a0
            let mut num1: i64 = 1
            let mut num: i64 = a
            let mut den1: i64 = 0
            let mut den: i64 = 1
            while num * num - D * den * den != 1 {
                mm = dd * a - mm
                dd = (D - mm * mm) / dd
                a = (a0 + mm) / dd
                let num2: i64 = num1
                num1 = num
                let den2: i64 = den1
                den1 = den
                num = a * num1 + num2
                den = a * den1 + den2
            }
            x1 = num
            y1 = den
            p_used[h] = 1
            p_D[h] = D
            p_x[h] = x1
            p_y[h] = y1
        }

        let mut x: i64 = g * r
        let mut y: i64 = p
        while true {
            let q: i64 = y
            let numerator: i64 = s * p * (p + q)
            let k_floor: i64 = numerator / 2
            if k_floor > LIMIT && q > p { break }
            if numerator % 2 == 0 {
                let k: i64 = numerator / 2
                if k <= LIMIT && k >= 2 * m * (m + 1) {
                    let u: i64 = x / g
                    let tt: i64 = g * r * u
                    if (tt - m - 1) % 2 == 0 {
                        let nn: i64 = (tt - m - 1) / 2
                        if nn >= k {
                            if set_add(s_keys, s_used, SCAP, k) {
                                sum = sum + k
                            }
                        }
                    }
                }
            }
            # x,y = x*x1 + y*y1*D, x*y1 + y*x1
            # use 128-bit for safety then take low if fits
            mul128(x, x1, hi1, lo1)
            mul128(y, y1, hi2, lo2)
            mul128(lo2[0], D, hi3, lo3)
            # add lo1+lo3 -> newx, need hi
            add128(hi1[0], lo1[0], hi3[0], lo3[0], hi1, lo1)
            let newx: i64 = lo1[0]
            mul128(x, y1, hi1, lo1)
            mul128(y, x1, hi2, lo2)
            add128(hi1[0], lo1[0], hi2[0], lo2[0], hi1, lo1)
            let newy: i64 = lo1[0]
            x = newx
            y = newy
            if x < 0 || y < 0 { break }
        }
        m = m + 1
    }
    printf("%lld\n", sum)
    free(spf); free(p_used); free(p_D); free(p_x); free(p_y); free(s_used); free(s_keys)
    free(hi1); free(lo1); free(hi2); free(lo2); free(hi3); free(lo3)
    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);
void mul128_i64_i64_ptr_i64_ptr_i64(int64_t a, int64_t b, int64_t* hi, int64_t* lo);
void add128_i64_i64_i64_i64_ptr_i64_ptr_i64(int64_t ahi, int64_t alo, int64_t bhi, int64_t blo, int64_t* hi, int64_t* lo);
bool set_add_ptr_i64_ptr_i8_i64_i64(int64_t* keys, int8_t* used, int64_t cap, int64_t key);
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;
}



void mul128_i64_i64_ptr_i64_ptr_i64(int64_t a, int64_t b, int64_t* hi, int64_t* lo) {
    int64_t mask = 4294967295;
    int64_t a0 = (a & mask);
    int64_t a1 = (FLOW_CHECKED_SHR((a), (32)) & mask);
    int64_t b0 = (b & mask);
    int64_t b1 = (FLOW_CHECKED_SHR((b), (32)) & mask);
    int64_t p0 = (a0 * b0);
    int64_t p1 = (a0 * b1);
    int64_t p2 = (a1 * b0);
    int64_t p3 = (a1 * b1);
    int64_t mid = ((FLOW_CHECKED_SHR((p0), (32)) + (p1 & mask)) + (p2 & mask));
    lo[0] = ((p0 & mask) | FLOW_CHECKED_SHL(((mid & mask)), (32)));
    hi[0] = (((p3 + FLOW_CHECKED_SHR((p1), (32))) + FLOW_CHECKED_SHR((p2), (32))) + FLOW_CHECKED_SHR((mid), (32)));
}

void add128_i64_i64_i64_i64_ptr_i64_ptr_i64(int64_t ahi, int64_t alo, int64_t bhi, int64_t blo, int64_t* hi, int64_t* lo) {
    int64_t mask = 4294967295;
    int64_t lo_sum = (alo + blo);
    int64_t carry = 0;
    int64_t alo_u_hi = (FLOW_CHECKED_SHR((alo), (32)) & mask);
    int64_t alo_u_lo = (alo & mask);
    int64_t blo_u_hi = (FLOW_CHECKED_SHR((blo), (32)) & mask);
    int64_t blo_u_lo = (blo & mask);
    int64_t s_lo = (alo_u_lo + blo_u_lo);
    int64_t c1 = FLOW_CHECKED_SHR((s_lo), (32));
    int64_t s_hi = ((alo_u_hi + blo_u_hi) + c1);
    carry = FLOW_CHECKED_SHR((s_hi), (32));
    lo[0] = ((s_lo & mask) | FLOW_CHECKED_SHL(((s_hi & mask)), (32)));
    hi[0] = ((ahi + bhi) + carry);
}

bool set_add_ptr_i64_ptr_i8_i64_i64(int64_t* keys, int8_t* used, int64_t cap, int64_t key) {
    int64_t h = FLOW_CHECKED_MOD((key), (cap));
    if (h < 0) {
        h = (-h);
    }
    while (used[h] != 0) {
        if (keys[h] == key) {
            return 0;
        }
        h = (h + 1);
        if (h == cap) {
            h = 0;
        }
    }
    used[h] = 1;
    keys[h] = key;
    return 1;
}

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