Problem 998

Minimum bounding square of triangles with Pythagorean partners.

Answer4439835458570
Output4439835458570
StatusPASS
Native helperno
Runtime1670 ms
Peak memory183696 KB
Time complexityO(n^3) (estimated)
Space complexityO(n^2) (estimated)

Performance comparison

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

Flow source

# Project Euler 998
# Minimum bounding square of triangles with Pythagorean partners.

import euler.nt { gcd, isqrt }

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

const LIMIT: i64 = 1000000
const HT_SIZE: i64 = 16777216
const HT_MASK: i64 = 16777215

function encode_sides(a: i64, b: i64, c: i64) -> i64 {
    let key: i128 = ((a as i128) << 42) | ((b as i128) << 21) | (c as i128)
    return key as i64
}

function hash_key(key: i64) -> i64 {
    let mut h: i128 = key as i128
    if h < 0 { h = 0 - h }
    h = (h * 2654435761) % (HT_SIZE as i128)
    return h as i64
}

function seen_insert(ht_keys: ptr<i64>, ht_used: ptr<i8>, key: i64) -> i32 {
    let mut h: i64 = hash_key(key)
    while ht_used[h] != 0 {
        if ht_keys[h] == key { return 0 }
        h = h + 1
        if h == HT_SIZE { h = 0 }
    }
    ht_used[h] = 1
    ht_keys[h] = key
    return 1
}

# Pass 1: count partners per m.
function count_partners(pcount: ptr<i32>) -> void {
    let mut r: i64 = 2
    while r * r <= 2 * LIMIT {
        let rr: i64 = r * r
        let mut s: i64 = 1
        while s < r {
            if ((r - s) & 1) == 0 {
                s = s + 1
                continue
            }
            if gcd(r, s) != 1 {
                s = s + 1
                continue
            }
            let a: i64 = rr - s * s
            let b: i64 = 2 * r * s
            let m: i64 = if a > b { a } else { b }
            let x: i64 = if a > b { b } else { a }
            if m > LIMIT {
                s = s + 1
                continue
            }
            let mut km: i64 = m
            while km <= LIMIT {
                pcount[km] = pcount[km] + 1
                km = km + m
            }
            s = s + 1
        }
        r = r + 1
    }
}

# Pass 2: fill partners per m.
function fill_partners(pptr: ptr<ptr<i64> >, pcount: ptr<i32>) -> void {
    let mut r: i64 = 2
    while r * r <= 2 * LIMIT {
        let rr: i64 = r * r
        let mut s: i64 = 1
        while s < r {
            if ((r - s) & 1) == 0 {
                s = s + 1
                continue
            }
            if gcd(r, s) != 1 {
                s = s + 1
                continue
            }
            let a: i64 = rr - s * s
            let b: i64 = 2 * r * s
            let m: i64 = if a > b { a } else { b }
            let x: i64 = if a > b { b } else { a }
            if m > LIMIT {
                s = s + 1
                continue
            }
            let mut km: i64 = m
            while km <= LIMIT {
                let idx: i32 = pcount[km]
                pptr[km][idx] = (km / m) * x
                pcount[km] = idx + 1
                km = km + m
            }
            s = s + 1
        }
        r = r + 1
    }
}

function insertion_sort(arr: ptr<i64>, n: i32) -> void {
    let mut i: i32 = 1
    while i < n {
        let key: i64 = arr[i]
        let mut j: i32 = i - 1
        while j >= 0 && arr[j] > key {
            arr[j + 1] = arr[j]
            j = j - 1
        }
        arr[j + 1] = key
        i = i + 1
    }
}

function sort3(s: ptr<i64>) -> void {
    if s[0] > s[1] {
        let t: i64 = s[0]
        s[0] = s[1]
        s[1] = t
    }
    if s[1] > s[2] {
        let t: i64 = s[1]
        s[1] = s[2]
        s[2] = t
    }
    if s[0] > s[1] {
        let t: i64 = s[0]
        s[0] = s[1]
        s[1] = t
    }
}

function is_minimum_square(sides: ptr<i64>, twice_area: i64, square_side: i64) -> i32 {
    let m: i64 = square_side
    let m2: i64 = m * m
    let d_area: i64 = twice_area
    let mut has_equal: i32 = 0

    # Candidate 1: square side parallel to a triangle side.
    let mut i: i32 = 0
    while i < 3 {
        let d: i64 = sides[i]
        let e: i64 = sides[(i + 1) % 3]
        let f: i64 = sides[(i + 2) % 3]
        let den: i64 = 2 * d
        let t_num: i64 = d * d + e * e - f * f
        let d_num: i64 = d * den
        let mut mx: i64 = d_num
        let mut mn: i64 = d_num
        if t_num > mx { mx = t_num }
        if t_num < mn { mn = t_num }
        if 0 > mx { mx = 0 }
        if 0 < mn { mn = 0 }
        let width_num: i64 = mx - mn

        let width_cmp: i64 = width_num - m * den
        let height_cmp: i64 = d_area - m * d
        if width_cmp < 0 && height_cmp < 0 {
            return 0
        }
        if width_cmp <= 0 && height_cmp <= 0 && (width_cmp == 0 || height_cmp == 0) {
            has_equal = 1
        }
        i = i + 1
    }

    # Candidate 2: all four sides of the square are touched.
    i = 0
    while i < 3 {
        let r: i64 = sides[i]
        let p: i64 = sides[(i + 1) % 3]
        let q: i64 = sides[(i + 2) % 3]
        let k_num: i64 = p * p + q * q - r * r
        if k_num <= 0 {
            i = i + 1
            continue
        }
        let r_den_part: i64 = p * p + q * q - 2 * d_area
        if r_den_part <= 0 {
            i = i + 1
            continue
        }

        let num: i128 = (k_num as i128) * (k_num as i128)
        let den: i128 = (4 as i128) * (r_den_part as i128)

        let p2: i64 = p * p
        let q2: i64 = q * q

        if num < (d_area as i128) * den {
            i = i + 1
            continue
        }
        if num > (p2 as i128) * den || num > (q2 as i128) * den {
            i = i + 1
            continue
        }
        if (p2 as i128) * den > (2 as i128) * num || (q2 as i128) * den > (2 as i128) * num {
            i = i + 1
            continue
        }

        let target: i128 = (m2 as i128) * den
        if num < target {
            return 0
        }
        if num == target {
            has_equal = 1
        }
        i = i + 1
    }

    return has_equal
}

function main() -> i32 {
    let pcount: ptr<i32> = calloc((LIMIT + 1) as i64, 4) as ptr<i32>
    count_partners(pcount)

    let pptr: ptr<ptr<i64> > = calloc((LIMIT + 1) as i64, 8) as ptr<ptr<i64> >
    let mut m: i64 = 1
    while m <= LIMIT {
        let c: i32 = pcount[m]
        if c > 0 {
            pptr[m] = calloc((c + 1) as i64, 8) as ptr<i64>
        }
        pcount[m] = 0
        m = m + 1
    }
    fill_partners(pptr, pcount)

    # Sort each partner list.
    m = 1
    while m <= LIMIT {
        let c: i32 = pcount[m]
        if c > 1 {
            insertion_sort(pptr[m], c)
        }
        m = m + 1
    }

    # Hash set.
    let ht_keys: ptr<i64> = calloc(HT_SIZE, 8) as ptr<i64>
    let ht_used: ptr<i8> = calloc(HT_SIZE, 1) as ptr<i8>

    # Find max row length for buffer allocation.
    let mut max_np: i32 = 0
    m = 1
    while m <= LIMIT {
        if pcount[m] > max_np { max_np = pcount[m] }
        m = m + 1
    }
    let row_len_max: i64 = (max_np + 1) as i64
    let row_x: ptr<i64> = malloc(row_len_max * 8) as ptr<i64>
    let row_h: ptr<i64> = malloc(row_len_max * 8) as ptr<i64>
    let s: ptr<i64> = malloc(3 * 8) as ptr<i64>

    let mut total: i64 = 0

    m = 1
    while m <= LIMIT {
        let mm: i64 = m * m
        let np: i32 = pcount[m]
        let plist: ptr<i64> = pptr[m]

        let row_len: i32 = np + 1
        row_x[0] = 0
        row_h[0] = m
        let mut i: i32 = 0
        while i < np {
            row_x[i + 1] = plist[i]
            row_h[i + 1] = isqrt(mm + plist[i] * plist[i])
            i = i + 1
        }

        # Edge-aligned minima.
        i = 0
        while i < row_len {
            let mut j: i32 = i
            while j < row_len {
                let x: i64 = row_x[i]
                let hx: i64 = row_h[i]
                let y: i64 = row_x[j]
                let hy: i64 = row_h[j]
                let base: i64 = x + y
                if base == 0 {
                    j = j + 1
                    continue
                }
                if base > m { break }
                if x * y < m * (m - base) {
                    j = j + 1
                    continue
                }

                s[0] = base
                s[1] = hx
                s[2] = hy
                sort3(s)

                let key: i64 = encode_sides(s[0], s[1], s[2])
                if seen_insert(ht_keys, ht_used, key) != 0 {
                    total = total + s[0] + s[1] + s[2]
                }
                j = j + 1
            }
            i = i + 1
        }

        # Four-sided, balanced minima.
        i = 0
        while i < row_len {
            let mut j: i32 = i
            while j < row_len {
                let u: i64 = row_x[i]
                let hu: i64 = row_h[i]
                let v: i64 = row_x[j]
                let hv: i64 = row_h[j]
                let twice_area: i64 = mm - u * v
                if twice_area <= 0 {
                    j = j + 1
                    continue
                }
                let p: i64 = m - u
                let q: i64 = m - v
                let third2: i64 = p * p + q * q
                let third: i64 = isqrt(third2)
                if third * third != third2 || third == 0 {
                    j = j + 1
                    continue
                }

                s[0] = third
                s[1] = hu
                s[2] = hv
                sort3(s)

                let key: i64 = encode_sides(s[0], s[1], s[2])
                if seen_insert(ht_keys, ht_used, key) == 0 {
                    j = j + 1
                    continue
                }

                if is_minimum_square(s, twice_area, m) != 0 {
                    total = total + s[0] + s[1] + s[2]
                }
                j = j + 1
            }
            i = i + 1
        }

        m = m + 1
    }

    printf("%lld\n", total)

    # Cleanup.
    m = 0
    while m <= LIMIT {
        if pptr[m] != null { free(pptr[m] as ptr<void>) }
        m = m + 1
    }
    free(pptr as ptr<void>)
    free(pcount as ptr<void>)
    free(ht_keys as ptr<void>)
    free(ht_used as ptr<void>)
    free(row_x as ptr<void>)
    free(row_h as ptr<void>)
    free(s as ptr<void>)
    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 encode_sides_i64_i64_i64(int64_t a, int64_t b, int64_t c);
int64_t hash_key_i64(int64_t key);
int32_t seen_insert_ptr_i64_ptr_i8_i64(int64_t* ht_keys, int8_t* ht_used, int64_t key);
void count_partners_ptr_i32(int32_t* pcount);
void fill_partners_ptr_ptr_i64_ptr_i32(int64_t** pptr, int32_t* pcount);
void insertion_sort_ptr_i64_i32(int64_t* arr, int32_t n);
void sort3_ptr_i64(int64_t* s);
int32_t is_minimum_square_ptr_i64_i64_i64(int64_t* sides, int64_t twice_area, int64_t square_side);
int32_t main(void);

static const int64_t LIMIT = 1000000;
static const int64_t HT_SIZE = 16777216;
static const int64_t HT_MASK = 16777215;

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 encode_sides_i64_i64_i64(int64_t a, int64_t b, int64_t c) {
    __int128 key = ((FLOW_CHECKED_SHL((((__int128)(a))), (42)) | FLOW_CHECKED_SHL((((__int128)(b))), (21))) | ((__int128)(c)));
    return ((int64_t)(key));
}

int64_t hash_key_i64(int64_t key) {
    __int128 h = ((__int128)(key));
    if (h < 0) {
        h = (0 - h);
    }
    h = FLOW_CHECKED_MOD(((h * 2654435761)), (((__int128)(HT_SIZE))));
    return ((int64_t)(h));
}

int32_t seen_insert_ptr_i64_ptr_i8_i64(int64_t* ht_keys, int8_t* ht_used, int64_t key) {
    int64_t h = hash_key_i64(key);
    while (ht_used[h] != 0) {
        if (ht_keys[h] == key) {
            return 0;
        }
        h = (h + 1);
        if (h == HT_SIZE) {
            h = 0;
        }
    }
    ht_used[h] = 1;
    ht_keys[h] = key;
    return 1;
}

void count_partners_ptr_i32(int32_t* pcount) {
    int64_t r = 2;
    while ((r * r) <= (2 * LIMIT)) {
        int64_t rr = (r * r);
        int64_t s = 1;
        while (s < r) {
            if (((r - s) & 1) == 0) {
                s = (s + 1);
                continue;
            }
            if (gcd_i64_i64(r, s) != 1) {
                s = (s + 1);
                continue;
            }
            int64_t a = (rr - (s * s));
            int64_t b = ((2 * r) * s);
            int64_t m = ((a > b) ? (a) : (b));
            int64_t x = ((a > b) ? (b) : (a));
            if (m > LIMIT) {
                s = (s + 1);
                continue;
            }
            int64_t km = m;
            while (km <= LIMIT) {
                pcount[km] = (pcount[km] + 1);
                km = (km + m);
            }
            s = (s + 1);
        }
        r = (r + 1);
    }
}

void fill_partners_ptr_ptr_i64_ptr_i32(int64_t** pptr, int32_t* pcount) {
    int64_t r = 2;
    while ((r * r) <= (2 * LIMIT)) {
        int64_t rr = (r * r);
        int64_t s = 1;
        while (s < r) {
            if (((r - s) & 1) == 0) {
                s = (s + 1);
                continue;
            }
            if (gcd_i64_i64(r, s) != 1) {
                s = (s + 1);
                continue;
            }
            int64_t a = (rr - (s * s));
            int64_t b = ((2 * r) * s);
            int64_t m = ((a > b) ? (a) : (b));
            int64_t x = ((a > b) ? (b) : (a));
            if (m > LIMIT) {
                s = (s + 1);
                continue;
            }
            int64_t km = m;
            while (km <= LIMIT) {
                int32_t idx = pcount[km];
                pptr[km][idx] = (FLOW_CHECKED_DIV((km), (m)) * x);
                pcount[km] = (idx + 1);
                km = (km + m);
            }
            s = (s + 1);
        }
        r = (r + 1);
    }
}

void insertion_sort_ptr_i64_i32(int64_t* arr, int32_t n) {
    int32_t i = 1;
    while (i < n) {
        int64_t key = arr[i];
        int32_t j = (i - 1);
        while ((j >= 0 && arr[j] > key)) {
            arr[(j + 1)] = arr[j];
            j = (j - 1);
        }
        arr[(j + 1)] = key;
        i = (i + 1);
    }
}

void sort3_ptr_i64(int64_t* s) {
    if (s[0] > s[1]) {
        int64_t t = s[0];
        s[0] = s[1];
        s[1] = t;
    }
    if (s[1] > s[2]) {
        int64_t t = s[1];
        s[1] = s[2];
        s[2] = t;
    }
    if (s[0] > s[1]) {
        int64_t t = s[0];
        s[0] = s[1];
        s[1] = t;
    }
}

int32_t is_minimum_square_ptr_i64_i64_i64(int64_t* sides, int64_t twice_area, int64_t square_side) {
    int64_t m = square_side;
    int64_t m2 = (m * m);
    int64_t d_area = twice_area;
    int32_t has_equal = 0;
    int32_t i = 0;
    while (i < 3) {
        int64_t d = sides[i];
        int64_t e = sides[FLOW_CHECKED_MOD(((i + 1)), (3))];
        int64_t f = sides[FLOW_CHECKED_MOD(((i + 2)), (3))];
        int64_t den = (2 * d);
        int64_t t_num = (((d * d) + (e * e)) - (f * f));
        int64_t d_num = (d * den);
        int64_t mx = d_num;
        int64_t mn = d_num;
        if (t_num > mx) {
            mx = t_num;
        }
        if (t_num < mn) {
            mn = t_num;
        }
        if (0 > mx) {
            mx = 0;
        }
        if (0 < mn) {
            mn = 0;
        }
        int64_t width_num = (mx - mn);
        int64_t width_cmp = (width_num - (m * den));
        int64_t height_cmp = (d_area - (m * d));
        if ((width_cmp < 0 && height_cmp < 0)) {
            return 0;
        }
        if (((width_cmp <= 0 && height_cmp <= 0) && (width_cmp == 0 || height_cmp == 0))) {
            has_equal = 1;
        }
        i = (i + 1);
    }
    i = 0;
    while (i < 3) {
        int64_t r = sides[i];
        int64_t p = sides[FLOW_CHECKED_MOD(((i + 1)), (3))];
        int64_t q = sides[FLOW_CHECKED_MOD(((i + 2)), (3))];
        int64_t k_num = (((p * p) + (q * q)) - (r * r));
        if (k_num <= 0) {
            i = (i + 1);
            continue;
        }
        int64_t r_den_part = (((p * p) + (q * q)) - (2 * d_area));
        if (r_den_part <= 0) {
            i = (i + 1);
            continue;
        }
        __int128 num = (((__int128)(k_num)) * ((__int128)(k_num)));
        __int128 den = (((__int128)(4)) * ((__int128)(r_den_part)));
        int64_t p2 = (p * p);
        int64_t q2 = (q * q);
        if (num < (((__int128)(d_area)) * den)) {
            i = (i + 1);
            continue;
        }
        if ((num > (((__int128)(p2)) * den) || num > (((__int128)(q2)) * den))) {
            i = (i + 1);
            continue;
        }
        if (((((__int128)(p2)) * den) > (((__int128)(2)) * num) || (((__int128)(q2)) * den) > (((__int128)(2)) * num))) {
            i = (i + 1);
            continue;
        }
        __int128 target = (((__int128)(m2)) * den);
        if (num < target) {
            return 0;
        }
        if (num == target) {
            has_equal = 1;
        }
        i = (i + 1);
    }
    return has_equal;
}

int32_t main(void) {
    int32_t* pcount = (int32_t*)(((int32_t*)(calloc(((int64_t)((LIMIT + 1))), 4))));
    count_partners_ptr_i32(pcount);
    int64_t** pptr = (int64_t**)(((int64_t**)(calloc(((int64_t)((LIMIT + 1))), 8))));
    int64_t m = 1;
    while (m <= LIMIT) {
        int32_t c = pcount[m];
        if (c > 0) {
            pptr[m] = ((int64_t*)(calloc(((int64_t)((c + 1))), 8)));
        }
        pcount[m] = 0;
        m = (m + 1);
    }
    fill_partners_ptr_ptr_i64_ptr_i32(pptr, pcount);
    m = 1;
    while (m <= LIMIT) {
        int32_t c = pcount[m];
        if (c > 1) {
            insertion_sort_ptr_i64_i32(pptr[m], c);
        }
        m = (m + 1);
    }
    int64_t* ht_keys = (int64_t*)(((int64_t*)(calloc(HT_SIZE, 8))));
    int8_t* ht_used = (int8_t*)(((int8_t*)(calloc(HT_SIZE, 1))));
    int32_t max_np = 0;
    m = 1;
    while (m <= LIMIT) {
        if (pcount[m] > max_np) {
            max_np = pcount[m];
        }
        m = (m + 1);
    }
    int64_t row_len_max = ((int64_t)((max_np + 1)));
    int64_t* row_x = (int64_t*)(((int64_t*)(malloc((row_len_max * 8)))));
    int64_t* row_h = (int64_t*)(((int64_t*)(malloc((row_len_max * 8)))));
    int64_t* s = (int64_t*)(((int64_t*)(malloc((3 * 8)))));
    int64_t total = 0;
    m = 1;
    while (m <= LIMIT) {
        int64_t mm = (m * m);
        int32_t np = pcount[m];
        int64_t* plist = (int64_t*)(pptr[m]);
        int32_t row_len = (np + 1);
        row_x[0] = 0;
        row_h[0] = m;
        int32_t i = 0;
        while (i < np) {
            row_x[(i + 1)] = plist[i];
            row_h[(i + 1)] = isqrt_i64((mm + (plist[i] * plist[i])));
            i = (i + 1);
        }
        i = 0;
        while (i < row_len) {
            int32_t j = i;
            while (j < row_len) {
                int64_t x = row_x[i];
                int64_t hx = row_h[i];
                int64_t y = row_x[j];
                int64_t hy = row_h[j];
                int64_t base = (x + y);
                if (base == 0) {
                    j = (j + 1);
                    continue;
                }
                if (base > m) {
                    break;
                }
                if ((x * y) < (m * (m - base))) {
                    j = (j + 1);
                    continue;
                }
                s[0] = base;
                s[1] = hx;
                s[2] = hy;
                sort3_ptr_i64(s);
                int64_t key = encode_sides_i64_i64_i64(s[0], s[1], s[2]);
                if (seen_insert_ptr_i64_ptr_i8_i64(ht_keys, ht_used, key) != 0) {
                    total = (((total + s[0]) + s[1]) + s[2]);
                }
                j = (j + 1);
            }
            i = (i + 1);
        }
        i = 0;
        while (i < row_len) {
            int32_t j = i;
            while (j < row_len) {
                int64_t u = row_x[i];
                int64_t hu = row_h[i];
                int64_t v = row_x[j];
                int64_t hv = row_h[j];
                int64_t twice_area = (mm - (u * v));
                if (twice_area <= 0) {
                    j = (j + 1);
                    continue;
                }
                int64_t p = (m - u);
                int64_t q = (m - v);
                int64_t third2 = ((p * p) + (q * q));
                int64_t third = isqrt_i64(third2);
                if (((third * third) != third2 || third == 0)) {
                    j = (j + 1);
                    continue;
                }
                s[0] = third;
                s[1] = hu;
                s[2] = hv;
                sort3_ptr_i64(s);
                int64_t key = encode_sides_i64_i64_i64(s[0], s[1], s[2]);
                if (seen_insert_ptr_i64_ptr_i8_i64(ht_keys, ht_used, key) == 0) {
                    j = (j + 1);
                    continue;
                }
                if (is_minimum_square_ptr_i64_i64_i64(s, twice_area, m) != 0) {
                    total = (((total + s[0]) + s[1]) + s[2]);
                }
                j = (j + 1);
            }
            i = (i + 1);
        }
        m = (m + 1);
    }
    printf("%lld\n", total);
    m = 0;
    while (m <= LIMIT) {
        if (pptr[m] != NULL) {
            free(((void*)(pptr[m])));
        }
        m = (m + 1);
    }
    free(((void*)(pptr)));
    free(((void*)(pcount)));
    free(((void*)(ht_keys)));
    free(((void*)(ht_used)));
    free(((void*)(row_x)));
    free(((void*)(row_h)));
    free(((void*)(s)));
    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 @malloc(i64) -> !llvm.ptr
  // Constant: LIMIT
  llvm.mlir.global internal constant @LIMIT(1000000 : i64) : i64
  // Constant: HT_SIZE
  llvm.mlir.global internal constant @HT_SIZE(16777216 : i64) : i64
  // Constant: HT_MASK
  llvm.mlir.global internal constant @HT_MASK(16777215 : i64) : i64
  func.func @encode_sides(%arg0: i64, %arg1: i64, %arg2: i64) -> i64 {
    %175 = arith.extsi %arg0 : i64 to i128
    %176 = arith.constant 42 : i32
    %178 = arith.trunci %175 : i128 to i64
    %179 = arith.extsi %176 : i32 to i64
    %177 = arith.shli %178, %179 : i64
    %180 = arith.extsi %arg1 : i64 to i128
    %181 = arith.constant 21 : i32
    %183 = arith.trunci %180 : i128 to i64
    %184 = arith.extsi %181 : i32 to i64
    %182 = arith.shli %183, %184 : i64
    %185 = arith.ori %177, %182 : i64
    %186 = arith.extsi %arg2 : i64 to i128
    %188 = arith.trunci %186 : i128 to i64
    %187 = arith.ori %185, %188 : i64
    %189 = arith.extsi %187 : i64 to i128
    %190 = arith.trunci %189 : i128 to i64
    func.return %190 : i64
  }
  func.func @hash_key(%arg0: i64) -> i64 {
    %191 = arith.extsi %arg0 : i64 to i128
    %192 = llvm.mlir.constant(1 : i64) : i64
    %193 = llvm.alloca %192 x i128 : (i64) -> !llvm.ptr
    llvm.store %191, %193 : i128, !llvm.ptr
    %194 = llvm.load %193 : !llvm.ptr -> i128
    %195 = arith.constant 0 : i32
    %197 = arith.trunci %194 : i128 to i64
    %198 = arith.extsi %195 : i32 to i64
    %196 = arith.cmpi slt, %197, %198 : i64
    cf.cond_br %196, ^bb42, ^bb43
    ^bb42:
      %199 = arith.constant 0 : i32
      %200 = llvm.load %193 : !llvm.ptr -> i128
      %202 = arith.extsi %199 : i32 to i64
      %203 = arith.trunci %200 : i128 to i64
      %201 = arith.subi %202, %203 : i64
      %204 = arith.extsi %201 : i64 to i128
      llvm.store %204, %193 : i128, !llvm.ptr
      cf.br ^bb44
    ^bb43:
      cf.br ^bb44
    ^bb44:
    %205 = llvm.load %193 : !llvm.ptr -> i128
    %206 = arith.constant -1640531535 : i32
    %208 = arith.trunci %205 : i128 to i64
    %209 = arith.extsi %206 : i32 to i64
    %207 = arith.muli %208, %209 : i64
    %210 = llvm.mlir.addressof @HT_SIZE : !llvm.ptr
    %211 = llvm.load %210 : !llvm.ptr -> i64
    %212 = arith.extsi %211 : i64 to i128
    %214 = arith.trunci %212 : i128 to i64
    %213 = arith.remsi %207, %214 : i64
    %215 = arith.extsi %213 : i64 to i128
    llvm.store %215, %193 : i128, !llvm.ptr
    %216 = llvm.load %193 : !llvm.ptr -> i128
    %217 = arith.trunci %216 : i128 to i64
    func.return %217 : i64
  }
  func.func @seen_insert(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: i64) -> i32 {
    %218 = func.call @hash_key(%arg2) : (i64) -> i64
    %219 = llvm.mlir.constant(1 : i64) : i64
    %220 = llvm.alloca %219 x i64 : (i64) -> !llvm.ptr
    llvm.store %218, %220 : i64, !llvm.ptr
    cf.br ^bb45
    ^bb45:
    %222 = llvm.load %220 : !llvm.ptr -> i64
    %223 = llvm.getelementptr %arg1[%222] : (!llvm.ptr, i64) -> !llvm.ptr, i8
    %221 = llvm.load %223 : !llvm.ptr -> i8
    %224 = arith.constant 0 : i32
    %226 = arith.extsi %221 : i8 to i32
    %225 = arith.cmpi ne, %226, %224 : i32
    cf.cond_br %225, ^bb46, ^bb47
    ^bb46:
      %228 = llvm.load %220 : !llvm.ptr -> i64
      %229 = llvm.getelementptr %arg0[%228] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %227 = llvm.load %229 : !llvm.ptr -> i64
      %230 = arith.cmpi eq, %227, %arg2 : i64
      cf.cond_br %230, ^bb48, ^bb49
      ^bb48:
        %231 = arith.constant 0 : i32
        func.return %231 : i32
      ^bb49:
        cf.br ^bb50
      ^bb50:
      %232 = llvm.load %220 : !llvm.ptr -> i64
      %233 = arith.constant 1 : i32
      %235 = arith.extsi %233 : i32 to i64
      %234 = arith.addi %232, %235 : i64
      llvm.store %234, %220 : i64, !llvm.ptr
      %236 = llvm.load %220 : !llvm.ptr -> i64
      %237 = llvm.mlir.addressof @HT_SIZE : !llvm.ptr
      %238 = llvm.load %237 : !llvm.ptr -> i64
      %239 = arith.cmpi eq, %236, %238 : i64
      cf.cond_br %239, ^bb51, ^bb52
      ^bb51:
        %240 = arith.constant 0 : i32
        %241 = arith.extsi %240 : i32 to i64
        llvm.store %241, %220 : i64, !llvm.ptr
        cf.br ^bb53
      ^bb52:
        cf.br ^bb53
      ^bb53:
      cf.br ^bb45
    ^bb47:
    %242 = arith.constant 1 : i32
    %243 = llvm.load %220 : !llvm.ptr -> i64
    %244 = arith.trunci %242 : i32 to i8
    %245 = llvm.getelementptr %arg1[%243] : (!llvm.ptr, i64) -> !llvm.ptr, i8
    llvm.store %244, %245 : i8, !llvm.ptr
    %246 = llvm.load %220 : !llvm.ptr -> i64
    %247 = llvm.getelementptr %arg0[%246] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    llvm.store %arg2, %247 : i64, !llvm.ptr
    %248 = arith.constant 1 : i32
    func.return %248 : i32
  }
  func.func @count_partners(%arg0: !llvm.ptr) -> () {
    %249 = arith.constant 2 : i32
    %250 = arith.extsi %249 : i32 to i64
    %251 = llvm.mlir.constant(1 : i64) : i64
    %252 = llvm.alloca %251 x i64 : (i64) -> !llvm.ptr
    llvm.store %250, %252 : i64, !llvm.ptr
    cf.br ^bb54
    ^bb54:
    %253 = llvm.load %252 : !llvm.ptr -> i64
    %254 = llvm.load %252 : !llvm.ptr -> i64
    %255 = arith.muli %253, %254 : i64
    %256 = arith.constant 2 : i32
    %257 = llvm.mlir.addressof @LIMIT : !llvm.ptr
    %258 = llvm.load %257 : !llvm.ptr -> i64
    %260 = arith.extsi %256 : i32 to i64
    %259 = arith.muli %260, %258 : i64
    %261 = arith.cmpi sle, %255, %259 : i64
    cf.cond_br %261, ^bb55, ^bb56
    ^bb55:
      %262 = llvm.load %252 : !llvm.ptr -> i64
      %263 = llvm.load %252 : !llvm.ptr -> i64
      %264 = arith.muli %262, %263 : i64
      %265 = arith.constant 1 : i32
      %266 = arith.extsi %265 : i32 to i64
      %267 = llvm.mlir.constant(1 : i64) : i64
      %268 = llvm.alloca %267 x i64 : (i64) -> !llvm.ptr
      llvm.store %266, %268 : i64, !llvm.ptr
      cf.br ^bb57
      ^bb57:
      %269 = llvm.load %268 : !llvm.ptr -> i64
      %270 = llvm.load %252 : !llvm.ptr -> i64
      %271 = arith.cmpi slt, %269, %270 : i64
      cf.cond_br %271, ^bb58, ^bb59
      ^bb58:
        %272 = llvm.load %252 : !llvm.ptr -> i64
        %273 = llvm.load %268 : !llvm.ptr -> i64
        %274 = arith.subi %272, %273 : i64
        %275 = arith.constant 1 : i32
        %277 = arith.extsi %275 : i32 to i64
        %276 = arith.andi %274, %277 : i64
        %278 = arith.constant 0 : i32
        %280 = arith.extsi %278 : i32 to i64
        %279 = arith.cmpi eq, %276, %280 : i64
        cf.cond_br %279, ^bb60, ^bb61
        ^bb60:
          %281 = llvm.load %268 : !llvm.ptr -> i64
          %282 = arith.constant 1 : i32
          %284 = arith.extsi %282 : i32 to i64
          %283 = arith.addi %281, %284 : i64
          llvm.store %283, %268 : i64, !llvm.ptr
          cf.br ^bb57
        ^bb61:
          cf.br ^bb62
        ^bb62:
        %286 = llvm.load %252 : !llvm.ptr -> i64
        %287 = llvm.load %268 : !llvm.ptr -> i64
        %285 = func.call @gcd(%286, %287) : (i64, i64) -> i64
        %288 = arith.constant 1 : i32
        %290 = arith.extsi %288 : i32 to i64
        %289 = arith.cmpi ne, %285, %290 : i64
        cf.cond_br %289, ^bb63, ^bb64
        ^bb63:
          %291 = llvm.load %268 : !llvm.ptr -> i64
          %292 = arith.constant 1 : i32
          %294 = arith.extsi %292 : i32 to i64
          %293 = arith.addi %291, %294 : i64
          llvm.store %293, %268 : i64, !llvm.ptr
          cf.br ^bb57
        ^bb64:
          cf.br ^bb65
        ^bb65:
        %295 = llvm.load %268 : !llvm.ptr -> i64
        %296 = llvm.load %268 : !llvm.ptr -> i64
        %297 = arith.muli %295, %296 : i64
        %298 = arith.subi %264, %297 : i64
        %299 = arith.constant 2 : i32
        %300 = llvm.load %252 : !llvm.ptr -> i64
        %302 = arith.extsi %299 : i32 to i64
        %301 = arith.muli %302, %300 : i64
        %303 = llvm.load %268 : !llvm.ptr -> i64
        %304 = arith.muli %301, %303 : i64
        %305 = arith.cmpi sgt, %298, %304 : i64
        %306 = scf.if %305 -> (i64) {
          scf.yield %298 : i64
        } else {
          scf.yield %304 : i64
        }
        %307 = arith.cmpi sgt, %298, %304 : i64
        %308 = scf.if %307 -> (i64) {
          scf.yield %304 : i64
        } else {
          scf.yield %298 : i64
        }
        %309 = llvm.mlir.addressof @LIMIT : !llvm.ptr
        %310 = llvm.load %309 : !llvm.ptr -> i64
        %311 = arith.cmpi sgt, %306, %310 : i64
        cf.cond_br %311, ^bb66, ^bb67
        ^bb66:
          %312 = llvm.load %268 : !llvm.ptr -> i64
          %313 = arith.constant 1 : i32
          %315 = arith.extsi %313 : i32 to i64
          %314 = arith.addi %312, %315 : i64
          llvm.store %314, %268 : i64, !llvm.ptr
          cf.br ^bb57
        ^bb67:
          cf.br ^bb68
        ^bb68:
        %316 = llvm.mlir.constant(1 : i64) : i64
        %317 = llvm.alloca %316 x i64 : (i64) -> !llvm.ptr
        llvm.store %306, %317 : i64, !llvm.ptr
        cf.br ^bb69
        ^bb69:
        %318 = llvm.load %317 : !llvm.ptr -> i64
        %319 = llvm.mlir.addressof @LIMIT : !llvm.ptr
        %320 = llvm.load %319 : !llvm.ptr -> i64
        %321 = arith.cmpi sle, %318, %320 : i64
        cf.cond_br %321, ^bb70, ^bb71
        ^bb70:
          %323 = llvm.load %317 : !llvm.ptr -> i64
          %324 = llvm.getelementptr %arg0[%323] : (!llvm.ptr, i64) -> !llvm.ptr, i32
          %322 = llvm.load %324 : !llvm.ptr -> i32
          %325 = arith.constant 1 : i32
          %326 = arith.addi %322, %325 : i32
          %327 = llvm.load %317 : !llvm.ptr -> i64
          %328 = llvm.getelementptr %arg0[%327] : (!llvm.ptr, i64) -> !llvm.ptr, i32
          llvm.store %326, %328 : i32, !llvm.ptr
          %329 = llvm.load %317 : !llvm.ptr -> i64
          %330 = arith.addi %329, %306 : i64
          llvm.store %330, %317 : i64, !llvm.ptr
          cf.br ^bb69
        ^bb71:
        %331 = llvm.load %268 : !llvm.ptr -> i64
        %332 = arith.constant 1 : i32
        %334 = arith.extsi %332 : i32 to i64
        %333 = arith.addi %331, %334 : i64
        llvm.store %333, %268 : i64, !llvm.ptr
        cf.br ^bb57
      ^bb59:
      %335 = llvm.load %252 : !llvm.ptr -> i64
      %336 = arith.constant 1 : i32
      %338 = arith.extsi %336 : i32 to i64
      %337 = arith.addi %335, %338 : i64
      llvm.store %337, %252 : i64, !llvm.ptr
      cf.br ^bb54
    ^bb56:
    func.return
  }
  func.func @fill_partners(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> () {
    %339 = arith.constant 2 : i32
    %340 = arith.extsi %339 : i32 to i64
    %341 = llvm.mlir.constant(1 : i64) : i64
    %342 = llvm.alloca %341 x i64 : (i64) -> !llvm.ptr
    llvm.store %340, %342 : i64, !llvm.ptr
    cf.br ^bb72
    ^bb72:
    %343 = llvm.load %342 : !llvm.ptr -> i64
    %344 = llvm.load %342 : !llvm.ptr -> i64
    %345 = arith.muli %343, %344 : i64
    %346 = arith.constant 2 : i32
    %347 = llvm.mlir.addressof @LIMIT : !llvm.ptr
    %348 = llvm.load %347 : !llvm.ptr -> i64
    %350 = arith.extsi %346 : i32 to i64
    %349 = arith.muli %350, %348 : i64
    %351 = arith.cmpi sle, %345, %349 : i64
    cf.cond_br %351, ^bb73, ^bb74
    ^bb73:
      %352 = llvm.load %342 : !llvm.ptr -> i64
      %353 = llvm.load %342 : !llvm.ptr -> i64
      %354 = arith.muli %352, %353 : i64
      %355 = arith.constant 1 : i32
      %356 = arith.extsi %355 : i32 to i64
      %357 = llvm.mlir.constant(1 : i64) : i64
      %358 = llvm.alloca %357 x i64 : (i64) -> !llvm.ptr
      llvm.store %356, %358 : i64, !llvm.ptr
      cf.br ^bb75
      ^bb75:
      %359 = llvm.load %358 : !llvm.ptr -> i64
      %360 = llvm.load %342 : !llvm.ptr -> i64
      %361 = arith.cmpi slt, %359, %360 : i64
      cf.cond_br %361, ^bb76, ^bb77
      ^bb76:
        %362 = llvm.load %342 : !llvm.ptr -> i64
        %363 = llvm.load %358 : !llvm.ptr -> i64
        %364 = arith.subi %362, %363 : i64
        %365 = arith.constant 1 : i32
        %367 = arith.extsi %365 : i32 to i64
        %366 = arith.andi %364, %367 : i64
        %368 = arith.constant 0 : i32
        %370 = arith.extsi %368 : i32 to i64
        %369 = arith.cmpi eq, %366, %370 : i64
        cf.cond_br %369, ^bb78, ^bb79
        ^bb78:
          %371 = llvm.load %358 : !llvm.ptr -> i64
          %372 = arith.constant 1 : i32
          %374 = arith.extsi %372 : i32 to i64
          %373 = arith.addi %371, %374 : i64
          llvm.store %373, %358 : i64, !llvm.ptr
          cf.br ^bb75
        ^bb79:
          cf.br ^bb80
        ^bb80:
        %376 = llvm.load %342 : !llvm.ptr -> i64
        %377 = llvm.load %358 : !llvm.ptr -> i64
        %375 = func.call @gcd(%376, %377) : (i64, i64) -> i64
        %378 = arith.constant 1 : i32
        %380 = arith.extsi %378 : i32 to i64
        %379 = arith.cmpi ne, %375, %380 : i64
        cf.cond_br %379, ^bb81, ^bb82
        ^bb81:
          %381 = llvm.load %358 : !llvm.ptr -> i64
          %382 = arith.constant 1 : i32
          %384 = arith.extsi %382 : i32 to i64
          %383 = arith.addi %381, %384 : i64
          llvm.store %383, %358 : i64, !llvm.ptr
          cf.br ^bb75
        ^bb82:
          cf.br ^bb83
        ^bb83:
        %385 = llvm.load %358 : !llvm.ptr -> i64
        %386 = llvm.load %358 : !llvm.ptr -> i64
        %387 = arith.muli %385, %386 : i64
        %388 = arith.subi %354, %387 : i64
        %389 = arith.constant 2 : i32
        %390 = llvm.load %342 : !llvm.ptr -> i64
        %392 = arith.extsi %389 : i32 to i64
        %391 = arith.muli %392, %390 : i64
        %393 = llvm.load %358 : !llvm.ptr -> i64
        %394 = arith.muli %391, %393 : i64
        %395 = arith.cmpi sgt, %388, %394 : i64
        %396 = scf.if %395 -> (i64) {
          scf.yield %388 : i64
        } else {
          scf.yield %394 : i64
        }
        %397 = arith.cmpi sgt, %388, %394 : i64
        %398 = scf.if %397 -> (i64) {
          scf.yield %394 : i64
        } else {
          scf.yield %388 : i64
        }
        %399 = llvm.mlir.addressof @LIMIT : !llvm.ptr
        %400 = llvm.load %399 : !llvm.ptr -> i64
        %401 = arith.cmpi sgt, %396, %400 : i64
        cf.cond_br %401, ^bb84, ^bb85
        ^bb84:
          %402 = llvm.load %358 : !llvm.ptr -> i64
          %403 = arith.constant 1 : i32
          %405 = arith.extsi %403 : i32 to i64
          %404 = arith.addi %402, %405 : i64
          llvm.store %404, %358 : i64, !llvm.ptr
          cf.br ^bb75
        ^bb85:
          cf.br ^bb86
        ^bb86:
        %406 = llvm.mlir.constant(1 : i64) : i64
        %407 = llvm.alloca %406 x i64 : (i64) -> !llvm.ptr
        llvm.store %396, %407 : i64, !llvm.ptr
        cf.br ^bb87
        ^bb87:
        %408 = llvm.load %407 : !llvm.ptr -> i64
        %409 = llvm.mlir.addressof @LIMIT : !llvm.ptr
        %410 = llvm.load %409 : !llvm.ptr -> i64
        %411 = arith.cmpi sle, %408, %410 : i64
        cf.cond_br %411, ^bb88, ^bb89
        ^bb88:
          %413 = llvm.load %407 : !llvm.ptr -> i64
          %414 = llvm.getelementptr %arg1[%413] : (!llvm.ptr, i64) -> !llvm.ptr, i32
          %412 = llvm.load %414 : !llvm.ptr -> i32
          %415 = llvm.load %407 : !llvm.ptr -> i64
          %416 = arith.divsi %415, %396 : i64
          %417 = arith.muli %416, %398 : i64
          %419 = llvm.load %407 : !llvm.ptr -> i64
          %420 = llvm.getelementptr %arg0[%419] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.ptr
          %418 = llvm.load %420 : !llvm.ptr -> !llvm.ptr
          %421 = arith.extsi %412 : i32 to i64
          %422 = llvm.getelementptr %418[%421] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          llvm.store %417, %422 : i64, !llvm.ptr
          %423 = arith.constant 1 : i32
          %424 = arith.addi %412, %423 : i32
          %425 = llvm.load %407 : !llvm.ptr -> i64
          %426 = llvm.getelementptr %arg1[%425] : (!llvm.ptr, i64) -> !llvm.ptr, i32
          llvm.store %424, %426 : i32, !llvm.ptr
          %427 = llvm.load %407 : !llvm.ptr -> i64
          %428 = arith.addi %427, %396 : i64
          llvm.store %428, %407 : i64, !llvm.ptr
          cf.br ^bb87
        ^bb89:
        %429 = llvm.load %358 : !llvm.ptr -> i64
        %430 = arith.constant 1 : i32
        %432 = arith.extsi %430 : i32 to i64
        %431 = arith.addi %429, %432 : i64
        llvm.store %431, %358 : i64, !llvm.ptr
        cf.br ^bb75
      ^bb77:
      %433 = llvm.load %342 : !llvm.ptr -> i64
      %434 = arith.constant 1 : i32
      %436 = arith.extsi %434 : i32 to i64
      %435 = arith.addi %433, %436 : i64
      llvm.store %435, %342 : i64, !llvm.ptr
      cf.br ^bb72
    ^bb74:
    func.return
  }
  func.func @insertion_sort(%arg0: !llvm.ptr, %arg1: i32) -> () {
    %437 = arith.constant 1 : i32
    %438 = llvm.mlir.constant(1 : i64) : i64
    %439 = llvm.alloca %438 x i32 : (i64) -> !llvm.ptr
    llvm.store %437, %439 : i32, !llvm.ptr
    cf.br ^bb90
    ^bb90:
    %440 = llvm.load %439 : !llvm.ptr -> i32
    %441 = arith.cmpi slt, %440, %arg1 : i32
    cf.cond_br %441, ^bb91, ^bb92
    ^bb91:
      %443 = llvm.load %439 : !llvm.ptr -> i32
      %444 = arith.extsi %443 : i32 to i64
      %445 = llvm.getelementptr %arg0[%444] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %442 = llvm.load %445 : !llvm.ptr -> i64
      %446 = llvm.load %439 : !llvm.ptr -> i32
      %447 = arith.constant 1 : i32
      %448 = arith.subi %446, %447 : i32
      %449 = llvm.mlir.constant(1 : i64) : i64
      %450 = llvm.alloca %449 x i32 : (i64) -> !llvm.ptr
      llvm.store %448, %450 : i32, !llvm.ptr
      cf.br ^bb93
      ^bb93:
      %451 = llvm.load %450 : !llvm.ptr -> i32
      %452 = arith.constant 0 : i32
      %453 = arith.cmpi sge, %451, %452 : i32
      %454 = scf.if %453 -> (i1) {
        %456 = llvm.load %450 : !llvm.ptr -> i32
        %457 = arith.extsi %456 : i32 to i64
        %458 = llvm.getelementptr %arg0[%457] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %455 = llvm.load %458 : !llvm.ptr -> i64
        %459 = arith.cmpi sgt, %455, %442 : i64
        scf.yield %459 : i1
      } else {
        %460 = arith.constant false
        scf.yield %460 : i1
      }
      cf.cond_br %454, ^bb94, ^bb95
      ^bb94:
        %462 = llvm.load %450 : !llvm.ptr -> i32
        %463 = arith.extsi %462 : i32 to i64
        %464 = llvm.getelementptr %arg0[%463] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %461 = llvm.load %464 : !llvm.ptr -> i64
        %465 = llvm.load %450 : !llvm.ptr -> i32
        %466 = arith.constant 1 : i32
        %467 = arith.addi %465, %466 : i32
        %468 = arith.extsi %467 : i32 to i64
        %469 = llvm.getelementptr %arg0[%468] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        llvm.store %461, %469 : i64, !llvm.ptr
        %470 = llvm.load %450 : !llvm.ptr -> i32
        %471 = arith.constant 1 : i32
        %472 = arith.subi %470, %471 : i32
        llvm.store %472, %450 : i32, !llvm.ptr
        cf.br ^bb93
      ^bb95:
      %473 = llvm.load %450 : !llvm.ptr -> i32
      %474 = arith.constant 1 : i32
      %475 = arith.addi %473, %474 : i32
      %476 = arith.extsi %475 : i32 to i64
      %477 = llvm.getelementptr %arg0[%476] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %442, %477 : i64, !llvm.ptr
      %478 = llvm.load %439 : !llvm.ptr -> i32
      %479 = arith.constant 1 : i32
      %480 = arith.addi %478, %479 : i32
      llvm.store %480, %439 : i32, !llvm.ptr
      cf.br ^bb90
    ^bb92:
    func.return
  }
  func.func @sort3(%arg0: !llvm.ptr) -> () {
    %482 = arith.constant 0 : i32
    %483 = arith.extsi %482 : i32 to i64
    %484 = llvm.getelementptr %arg0[%483] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    %481 = llvm.load %484 : !llvm.ptr -> i64
    %486 = arith.constant 1 : i32
    %487 = arith.extsi %486 : i32 to i64
    %488 = llvm.getelementptr %arg0[%487] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    %485 = llvm.load %488 : !llvm.ptr -> i64
    %489 = arith.cmpi sgt, %481, %485 : i64
    cf.cond_br %489, ^bb96, ^bb97
    ^bb96:
      %491 = arith.constant 0 : i32
      %492 = arith.extsi %491 : i32 to i64
      %493 = llvm.getelementptr %arg0[%492] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %490 = llvm.load %493 : !llvm.ptr -> i64
      %495 = arith.constant 1 : i32
      %496 = arith.extsi %495 : i32 to i64
      %497 = llvm.getelementptr %arg0[%496] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %494 = llvm.load %497 : !llvm.ptr -> i64
      %498 = arith.constant 0 : i32
      %499 = arith.extsi %498 : i32 to i64
      %500 = llvm.getelementptr %arg0[%499] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %494, %500 : i64, !llvm.ptr
      %501 = arith.constant 1 : i32
      %502 = arith.extsi %501 : i32 to i64
      %503 = llvm.getelementptr %arg0[%502] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %490, %503 : i64, !llvm.ptr
      cf.br ^bb98
    ^bb97:
      cf.br ^bb98
    ^bb98:
    %505 = arith.constant 1 : i32
    %506 = arith.extsi %505 : i32 to i64
    %507 = llvm.getelementptr %arg0[%506] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    %504 = llvm.load %507 : !llvm.ptr -> i64
    %509 = arith.constant 2 : i32
    %510 = arith.extsi %509 : i32 to i64
    %511 = llvm.getelementptr %arg0[%510] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    %508 = llvm.load %511 : !llvm.ptr -> i64
    %512 = arith.cmpi sgt, %504, %508 : i64
    cf.cond_br %512, ^bb99, ^bb100
    ^bb99:
      %514 = arith.constant 1 : i32
      %515 = arith.extsi %514 : i32 to i64
      %516 = llvm.getelementptr %arg0[%515] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %513 = llvm.load %516 : !llvm.ptr -> i64
      %518 = arith.constant 2 : i32
      %519 = arith.extsi %518 : i32 to i64
      %520 = llvm.getelementptr %arg0[%519] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %517 = llvm.load %520 : !llvm.ptr -> i64
      %521 = arith.constant 1 : i32
      %522 = arith.extsi %521 : i32 to i64
      %523 = llvm.getelementptr %arg0[%522] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %517, %523 : i64, !llvm.ptr
      %524 = arith.constant 2 : i32
      %525 = arith.extsi %524 : i32 to i64
      %526 = llvm.getelementptr %arg0[%525] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %513, %526 : i64, !llvm.ptr
      cf.br ^bb101
    ^bb100:
      cf.br ^bb101
    ^bb101:
    %528 = arith.constant 0 : i32
    %529 = arith.extsi %528 : i32 to i64
    %530 = llvm.getelementptr %arg0[%529] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    %527 = llvm.load %530 : !llvm.ptr -> i64
    %532 = arith.constant 1 : i32
    %533 = arith.extsi %532 : i32 to i64
    %534 = llvm.getelementptr %arg0[%533] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    %531 = llvm.load %534 : !llvm.ptr -> i64
    %535 = arith.cmpi sgt, %527, %531 : i64
    cf.cond_br %535, ^bb102, ^bb103
    ^bb102:
      %537 = arith.constant 0 : i32
      %538 = arith.extsi %537 : i32 to i64
      %539 = llvm.getelementptr %arg0[%538] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %536 = llvm.load %539 : !llvm.ptr -> i64
      %541 = arith.constant 1 : i32
      %542 = arith.extsi %541 : i32 to i64
      %543 = llvm.getelementptr %arg0[%542] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %540 = llvm.load %543 : !llvm.ptr -> i64
      %544 = arith.constant 0 : i32
      %545 = arith.extsi %544 : i32 to i64
      %546 = llvm.getelementptr %arg0[%545] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %540, %546 : i64, !llvm.ptr
      %547 = arith.constant 1 : i32
      %548 = arith.extsi %547 : i32 to i64
      %549 = llvm.getelementptr %arg0[%548] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %536, %549 : i64, !llvm.ptr
      cf.br ^bb104
    ^bb103:
      cf.br ^bb104
    ^bb104:
    func.return
  }
  func.func @is_minimum_square(%arg0: !llvm.ptr, %arg1: i64, %arg2: i64) -> i32 {
    %550 = arith.muli %arg2, %arg2 : i64
    %551 = arith.constant 0 : i32
    %552 = llvm.mlir.constant(1 : i64) : i64
    %553 = llvm.alloca %552 x i32 : (i64) -> !llvm.ptr
    llvm.store %551, %553 : i32, !llvm.ptr
    %554 = arith.constant 0 : i32
    %555 = llvm.mlir.constant(1 : i64) : i64
    %556 = llvm.alloca %555 x i32 : (i64) -> !llvm.ptr
    llvm.store %554, %556 : i32, !llvm.ptr
    cf.br ^bb105
    ^bb105:
    %557 = llvm.load %556 : !llvm.ptr -> i32
    %558 = arith.constant 3 : i32
    %559 = arith.cmpi slt, %557, %558 : i32
    cf.cond_br %559, ^bb106, ^bb107
    ^bb106:
      %561 = llvm.load %556 : !llvm.ptr -> i32
      %562 = arith.extsi %561 : i32 to i64
      %563 = llvm.getelementptr %arg0[%562] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %560 = llvm.load %563 : !llvm.ptr -> i64
      %565 = llvm.load %556 : !llvm.ptr -> i32
      %566 = arith.constant 1 : i32
      %567 = arith.addi %565, %566 : i32
      %568 = arith.constant 3 : i32
      %569 = arith.remsi %567, %568 : i32
      %570 = arith.extsi %569 : i32 to i64
      %571 = llvm.getelementptr %arg0[%570] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %564 = llvm.load %571 : !llvm.ptr -> i64
      %573 = llvm.load %556 : !llvm.ptr -> i32
      %574 = arith.constant 2 : i32
      %575 = arith.addi %573, %574 : i32
      %576 = arith.constant 3 : i32
      %577 = arith.remsi %575, %576 : i32
      %578 = arith.extsi %577 : i32 to i64
      %579 = llvm.getelementptr %arg0[%578] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %572 = llvm.load %579 : !llvm.ptr -> i64
      %580 = arith.constant 2 : i32
      %582 = arith.extsi %580 : i32 to i64
      %581 = arith.muli %582, %560 : i64
      %583 = arith.muli %560, %560 : i64
      %584 = arith.muli %564, %564 : i64
      %585 = arith.addi %583, %584 : i64
      %586 = arith.muli %572, %572 : i64
      %587 = arith.subi %585, %586 : i64
      %588 = arith.muli %560, %581 : i64
      %589 = llvm.mlir.constant(1 : i64) : i64
      %590 = llvm.alloca %589 x i64 : (i64) -> !llvm.ptr
      llvm.store %588, %590 : i64, !llvm.ptr
      %591 = llvm.mlir.constant(1 : i64) : i64
      %592 = llvm.alloca %591 x i64 : (i64) -> !llvm.ptr
      llvm.store %588, %592 : i64, !llvm.ptr
      %593 = llvm.load %590 : !llvm.ptr -> i64
      %594 = arith.cmpi sgt, %587, %593 : i64
      cf.cond_br %594, ^bb108, ^bb109
      ^bb108:
        llvm.store %587, %590 : i64, !llvm.ptr
        cf.br ^bb110
      ^bb109:
        cf.br ^bb110
      ^bb110:
      %595 = llvm.load %592 : !llvm.ptr -> i64
      %596 = arith.cmpi slt, %587, %595 : i64
      cf.cond_br %596, ^bb111, ^bb112
      ^bb111:
        llvm.store %587, %592 : i64, !llvm.ptr
        cf.br ^bb113
      ^bb112:
        cf.br ^bb113
      ^bb113:
      %597 = arith.constant 0 : i32
      %598 = llvm.load %590 : !llvm.ptr -> i64
      %600 = arith.extsi %597 : i32 to i64
      %599 = arith.cmpi sgt, %600, %598 : i64
      cf.cond_br %599, ^bb114, ^bb115
      ^bb114:
        %601 = arith.constant 0 : i32
        %602 = arith.extsi %601 : i32 to i64
        llvm.store %602, %590 : i64, !llvm.ptr
        cf.br ^bb116
      ^bb115:
        cf.br ^bb116
      ^bb116:
      %603 = arith.constant 0 : i32
      %604 = llvm.load %592 : !llvm.ptr -> i64
      %606 = arith.extsi %603 : i32 to i64
      %605 = arith.cmpi slt, %606, %604 : i64
      cf.cond_br %605, ^bb117, ^bb118
      ^bb117:
        %607 = arith.constant 0 : i32
        %608 = arith.extsi %607 : i32 to i64
        llvm.store %608, %592 : i64, !llvm.ptr
        cf.br ^bb119
      ^bb118:
        cf.br ^bb119
      ^bb119:
      %609 = llvm.load %590 : !llvm.ptr -> i64
      %610 = llvm.load %592 : !llvm.ptr -> i64
      %611 = arith.subi %609, %610 : i64
      %612 = arith.muli %arg2, %581 : i64
      %613 = arith.subi %611, %612 : i64
      %614 = arith.muli %arg2, %560 : i64
      %615 = arith.subi %arg1, %614 : i64
      %616 = arith.constant 0 : i32
      %618 = arith.extsi %616 : i32 to i64
      %617 = arith.cmpi slt, %613, %618 : i64
      %619 = scf.if %617 -> (i1) {
        %620 = arith.constant 0 : i32
        %622 = arith.extsi %620 : i32 to i64
        %621 = arith.cmpi slt, %615, %622 : i64
        scf.yield %621 : i1
      } else {
        %623 = arith.constant false
        scf.yield %623 : i1
      }
      cf.cond_br %619, ^bb120, ^bb121
      ^bb120:
        %624 = arith.constant 0 : i32
        func.return %624 : i32
      ^bb121:
        cf.br ^bb122
      ^bb122:
      %625 = arith.constant 0 : i32
      %627 = arith.extsi %625 : i32 to i64
      %626 = arith.cmpi sle, %613, %627 : i64
      %628 = scf.if %626 -> (i1) {
        %629 = arith.constant 0 : i32
        %631 = arith.extsi %629 : i32 to i64
        %630 = arith.cmpi sle, %615, %631 : i64
        scf.yield %630 : i1
      } else {
        %632 = arith.constant false
        scf.yield %632 : i1
      }
      %633 = scf.if %628 -> (i1) {
        %634 = arith.constant 0 : i32
        %636 = arith.extsi %634 : i32 to i64
        %635 = arith.cmpi eq, %613, %636 : i64
        %637 = scf.if %635 -> (i1) {
          %638 = arith.constant true
          scf.yield %638 : i1
        } else {
          %639 = arith.constant 0 : i32
          %641 = arith.extsi %639 : i32 to i64
          %640 = arith.cmpi eq, %615, %641 : i64
          scf.yield %640 : i1
        }
        scf.yield %637 : i1
      } else {
        %642 = arith.constant false
        scf.yield %642 : i1
      }
      cf.cond_br %633, ^bb123, ^bb124
      ^bb123:
        %643 = arith.constant 1 : i32
        llvm.store %643, %553 : i32, !llvm.ptr
        cf.br ^bb125
      ^bb124:
        cf.br ^bb125
      ^bb125:
      %644 = llvm.load %556 : !llvm.ptr -> i32
      %645 = arith.constant 1 : i32
      %646 = arith.addi %644, %645 : i32
      llvm.store %646, %556 : i32, !llvm.ptr
      cf.br ^bb105
    ^bb107:
    %647 = arith.constant 0 : i32
    llvm.store %647, %556 : i32, !llvm.ptr
    cf.br ^bb126
    ^bb126:
    %648 = llvm.load %556 : !llvm.ptr -> i32
    %649 = arith.constant 3 : i32
    %650 = arith.cmpi slt, %648, %649 : i32
    cf.cond_br %650, ^bb127, ^bb128
    ^bb127:
      %652 = llvm.load %556 : !llvm.ptr -> i32
      %653 = arith.extsi %652 : i32 to i64
      %654 = llvm.getelementptr %arg0[%653] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %651 = llvm.load %654 : !llvm.ptr -> i64
      %656 = llvm.load %556 : !llvm.ptr -> i32
      %657 = arith.constant 1 : i32
      %658 = arith.addi %656, %657 : i32
      %659 = arith.constant 3 : i32
      %660 = arith.remsi %658, %659 : i32
      %661 = arith.extsi %660 : i32 to i64
      %662 = llvm.getelementptr %arg0[%661] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %655 = llvm.load %662 : !llvm.ptr -> i64
      %664 = llvm.load %556 : !llvm.ptr -> i32
      %665 = arith.constant 2 : i32
      %666 = arith.addi %664, %665 : i32
      %667 = arith.constant 3 : i32
      %668 = arith.remsi %666, %667 : i32
      %669 = arith.extsi %668 : i32 to i64
      %670 = llvm.getelementptr %arg0[%669] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %663 = llvm.load %670 : !llvm.ptr -> i64
      %671 = arith.muli %655, %655 : i64
      %672 = arith.muli %663, %663 : i64
      %673 = arith.addi %671, %672 : i64
      %674 = arith.muli %651, %651 : i64
      %675 = arith.subi %673, %674 : i64
      %676 = arith.constant 0 : i32
      %678 = arith.extsi %676 : i32 to i64
      %677 = arith.cmpi sle, %675, %678 : i64
      cf.cond_br %677, ^bb129, ^bb130
      ^bb129:
        %679 = llvm.load %556 : !llvm.ptr -> i32
        %680 = arith.constant 1 : i32
        %681 = arith.addi %679, %680 : i32
        llvm.store %681, %556 : i32, !llvm.ptr
        cf.br ^bb126
      ^bb130:
        cf.br ^bb131
      ^bb131:
      %682 = arith.muli %655, %655 : i64
      %683 = arith.muli %663, %663 : i64
      %684 = arith.addi %682, %683 : i64
      %685 = arith.constant 2 : i32
      %687 = arith.extsi %685 : i32 to i64
      %686 = arith.muli %687, %arg1 : i64
      %688 = arith.subi %684, %686 : i64
      %689 = arith.constant 0 : i32
      %691 = arith.extsi %689 : i32 to i64
      %690 = arith.cmpi sle, %688, %691 : i64
      cf.cond_br %690, ^bb132, ^bb133
      ^bb132:
        %692 = llvm.load %556 : !llvm.ptr -> i32
        %693 = arith.constant 1 : i32
        %694 = arith.addi %692, %693 : i32
        llvm.store %694, %556 : i32, !llvm.ptr
        cf.br ^bb126
      ^bb133:
        cf.br ^bb134
      ^bb134:
      %695 = arith.extsi %675 : i64 to i128
      %696 = arith.extsi %675 : i64 to i128
      %698 = arith.trunci %695 : i128 to i64
      %699 = arith.trunci %696 : i128 to i64
      %697 = arith.muli %698, %699 : i64
      %700 = arith.extsi %697 : i64 to i128
      %701 = arith.constant 4 : i32
      %702 = arith.extsi %701 : i32 to i128
      %703 = arith.extsi %688 : i64 to i128
      %705 = arith.trunci %702 : i128 to i64
      %706 = arith.trunci %703 : i128 to i64
      %704 = arith.muli %705, %706 : i64
      %707 = arith.extsi %704 : i64 to i128
      %708 = arith.muli %655, %655 : i64
      %709 = arith.muli %663, %663 : i64
      %710 = arith.extsi %arg1 : i64 to i128
      %712 = arith.trunci %710 : i128 to i64
      %713 = arith.trunci %707 : i128 to i64
      %711 = arith.muli %712, %713 : i64
      %715 = arith.trunci %700 : i128 to i64
      %714 = arith.cmpi slt, %715, %711 : i64
      cf.cond_br %714, ^bb135, ^bb136
      ^bb135:
        %716 = llvm.load %556 : !llvm.ptr -> i32
        %717 = arith.constant 1 : i32
        %718 = arith.addi %716, %717 : i32
        llvm.store %718, %556 : i32, !llvm.ptr
        cf.br ^bb126
      ^bb136:
        cf.br ^bb137
      ^bb137:
      %719 = arith.extsi %708 : i64 to i128
      %721 = arith.trunci %719 : i128 to i64
      %722 = arith.trunci %707 : i128 to i64
      %720 = arith.muli %721, %722 : i64
      %724 = arith.trunci %700 : i128 to i64
      %723 = arith.cmpi sgt, %724, %720 : i64
      %725 = scf.if %723 -> (i1) {
        %726 = arith.constant true
        scf.yield %726 : i1
      } else {
        %727 = arith.extsi %709 : i64 to i128
        %729 = arith.trunci %727 : i128 to i64
        %730 = arith.trunci %707 : i128 to i64
        %728 = arith.muli %729, %730 : i64
        %732 = arith.trunci %700 : i128 to i64
        %731 = arith.cmpi sgt, %732, %728 : i64
        scf.yield %731 : i1
      }
      cf.cond_br %725, ^bb138, ^bb139
      ^bb138:
        %733 = llvm.load %556 : !llvm.ptr -> i32
        %734 = arith.constant 1 : i32
        %735 = arith.addi %733, %734 : i32
        llvm.store %735, %556 : i32, !llvm.ptr
        cf.br ^bb126
      ^bb139:
        cf.br ^bb140
      ^bb140:
      %736 = arith.extsi %708 : i64 to i128
      %738 = arith.trunci %736 : i128 to i64
      %739 = arith.trunci %707 : i128 to i64
      %737 = arith.muli %738, %739 : i64
      %740 = arith.constant 2 : i32
      %741 = arith.extsi %740 : i32 to i128
      %743 = arith.trunci %741 : i128 to i64
      %744 = arith.trunci %700 : i128 to i64
      %742 = arith.muli %743, %744 : i64
      %745 = arith.cmpi sgt, %737, %742 : i64
      %746 = scf.if %745 -> (i1) {
        %747 = arith.constant true
        scf.yield %747 : i1
      } else {
        %748 = arith.extsi %709 : i64 to i128
        %750 = arith.trunci %748 : i128 to i64
        %751 = arith.trunci %707 : i128 to i64
        %749 = arith.muli %750, %751 : i64
        %752 = arith.constant 2 : i32
        %753 = arith.extsi %752 : i32 to i128
        %755 = arith.trunci %753 : i128 to i64
        %756 = arith.trunci %700 : i128 to i64
        %754 = arith.muli %755, %756 : i64
        %757 = arith.cmpi sgt, %749, %754 : i64
        scf.yield %757 : i1
      }
      cf.cond_br %746, ^bb141, ^bb142
      ^bb141:
        %758 = llvm.load %556 : !llvm.ptr -> i32
        %759 = arith.constant 1 : i32
        %760 = arith.addi %758, %759 : i32
        llvm.store %760, %556 : i32, !llvm.ptr
        cf.br ^bb126
      ^bb142:
        cf.br ^bb143
      ^bb143:
      %761 = arith.extsi %550 : i64 to i128
      %763 = arith.trunci %761 : i128 to i64
      %764 = arith.trunci %707 : i128 to i64
      %762 = arith.muli %763, %764 : i64
      %765 = arith.extsi %762 : i64 to i128
      %767 = arith.trunci %700 : i128 to i64
      %768 = arith.trunci %765 : i128 to i64
      %766 = arith.cmpi slt, %767, %768 : i64
      cf.cond_br %766, ^bb144, ^bb145
      ^bb144:
        %769 = arith.constant 0 : i32
        func.return %769 : i32
      ^bb145:
        cf.br ^bb146
      ^bb146:
      %771 = arith.trunci %700 : i128 to i64
      %772 = arith.trunci %765 : i128 to i64
      %770 = arith.cmpi eq, %771, %772 : i64
      cf.cond_br %770, ^bb147, ^bb148
      ^bb147:
        %773 = arith.constant 1 : i32
        llvm.store %773, %553 : i32, !llvm.ptr
        cf.br ^bb149
      ^bb148:
        cf.br ^bb149
      ^bb149:
      %774 = llvm.load %556 : !llvm.ptr -> i32
      %775 = arith.constant 1 : i32
      %776 = arith.addi %774, %775 : i32
      llvm.store %776, %556 : i32, !llvm.ptr
      cf.br ^bb126
    ^bb128:
    %777 = llvm.load %553 : !llvm.ptr -> i32
    func.return %777 : i32
  }
  func.func @main() -> i32 {
    %779 = llvm.mlir.addressof @LIMIT : !llvm.ptr
    %780 = llvm.load %779 : !llvm.ptr -> i64
    %781 = arith.constant 1 : i32
    %783 = arith.extsi %781 : i32 to i64
    %782 = arith.addi %780, %783 : i64
    %784 = arith.constant 4 : i32
    %785 = arith.extsi %784 : i32 to i64
    %778 = func.call @calloc(%782, %785) : (i64, i64) -> !llvm.ptr
    func.call @count_partners(%778) : (!llvm.ptr) -> ()
    %788 = llvm.mlir.addressof @LIMIT : !llvm.ptr
    %789 = llvm.load %788 : !llvm.ptr -> i64
    %790 = arith.constant 1 : i32
    %792 = arith.extsi %790 : i32 to i64
    %791 = arith.addi %789, %792 : i64
    %793 = arith.constant 8 : i32
    %794 = arith.extsi %793 : i32 to i64
    %787 = func.call @calloc(%791, %794) : (i64, i64) -> !llvm.ptr
    %795 = arith.constant 1 : i32
    %796 = arith.extsi %795 : i32 to i64
    %797 = llvm.mlir.constant(1 : i64) : i64
    %798 = llvm.alloca %797 x i64 : (i64) -> !llvm.ptr
    llvm.store %796, %798 : i64, !llvm.ptr
    cf.br ^bb150
    ^bb150:
    %799 = llvm.load %798 : !llvm.ptr -> i64
    %800 = llvm.mlir.addressof @LIMIT : !llvm.ptr
    %801 = llvm.load %800 : !llvm.ptr -> i64
    %802 = arith.cmpi sle, %799, %801 : i64
    cf.cond_br %802, ^bb151, ^bb152
    ^bb151:
      %804 = llvm.load %798 : !llvm.ptr -> i64
      %805 = llvm.getelementptr %778[%804] : (!llvm.ptr, i64) -> !llvm.ptr, i32
      %803 = llvm.load %805 : !llvm.ptr -> i32
      %806 = arith.constant 0 : i32
      %807 = arith.cmpi sgt, %803, %806 : i32
      cf.cond_br %807, ^bb153, ^bb154
      ^bb153:
        %809 = arith.constant 1 : i32
        %810 = arith.addi %803, %809 : i32
        %811 = arith.extsi %810 : i32 to i64
        %812 = arith.constant 8 : i32
        %813 = arith.extsi %812 : i32 to i64
        %808 = func.call @calloc(%811, %813) : (i64, i64) -> !llvm.ptr
        %814 = llvm.load %798 : !llvm.ptr -> i64
        %815 = llvm.getelementptr %787[%814] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.ptr
        llvm.store %808, %815 : !llvm.ptr, !llvm.ptr
        cf.br ^bb155
      ^bb154:
        cf.br ^bb155
      ^bb155:
      %816 = arith.constant 0 : i32
      %817 = llvm.load %798 : !llvm.ptr -> i64
      %818 = llvm.getelementptr %778[%817] : (!llvm.ptr, i64) -> !llvm.ptr, i32
      llvm.store %816, %818 : i32, !llvm.ptr
      %819 = llvm.load %798 : !llvm.ptr -> i64
      %820 = arith.constant 1 : i32
      %822 = arith.extsi %820 : i32 to i64
      %821 = arith.addi %819, %822 : i64
      llvm.store %821, %798 : i64, !llvm.ptr
      cf.br ^bb150
    ^bb152:
    func.call @fill_partners(%787, %778) : (!llvm.ptr, !llvm.ptr) -> ()
    %824 = arith.constant 1 : i32
    %825 = arith.extsi %824 : i32 to i64
    llvm.store %825, %798 : i64, !llvm.ptr
    cf.br ^bb156
    ^bb156:
    %826 = llvm.load %798 : !llvm.ptr -> i64
    %827 = llvm.mlir.addressof @LIMIT : !llvm.ptr
    %828 = llvm.load %827 : !llvm.ptr -> i64
    %829 = arith.cmpi sle, %826, %828 : i64
    cf.cond_br %829, ^bb157, ^bb158
    ^bb157:
      %831 = llvm.load %798 : !llvm.ptr -> i64
      %832 = llvm.getelementptr %778[%831] : (!llvm.ptr, i64) -> !llvm.ptr, i32
      %830 = llvm.load %832 : !llvm.ptr -> i32
      %833 = arith.constant 1 : i32
      %834 = arith.cmpi sgt, %830, %833 : i32
      cf.cond_br %834, ^bb159, ^bb160
      ^bb159:
        %837 = llvm.load %798 : !llvm.ptr -> i64
        %838 = llvm.getelementptr %787[%837] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.ptr
        %836 = llvm.load %838 : !llvm.ptr -> !llvm.ptr
        func.call @insertion_sort(%836, %830) : (!llvm.ptr, i32) -> ()
        cf.br ^bb161
      ^bb160:
        cf.br ^bb161
      ^bb161:
      %839 = llvm.load %798 : !llvm.ptr -> i64
      %840 = arith.constant 1 : i32
      %842 = arith.extsi %840 : i32 to i64
      %841 = arith.addi %839, %842 : i64
      llvm.store %841, %798 : i64, !llvm.ptr
      cf.br ^bb156
    ^bb158:
    %844 = llvm.mlir.addressof @HT_SIZE : !llvm.ptr
    %845 = llvm.load %844 : !llvm.ptr -> i64
    %846 = arith.constant 8 : i32
    %847 = arith.extsi %846 : i32 to i64
    %843 = func.call @calloc(%845, %847) : (i64, i64) -> !llvm.ptr
    %849 = llvm.mlir.addressof @HT_SIZE : !llvm.ptr
    %850 = llvm.load %849 : !llvm.ptr -> i64
    %851 = arith.constant 1 : i32
    %852 = arith.extsi %851 : i32 to i64
    %848 = func.call @calloc(%850, %852) : (i64, i64) -> !llvm.ptr
    %853 = arith.constant 0 : i32
    %854 = llvm.mlir.constant(1 : i64) : i64
    %855 = llvm.alloca %854 x i32 : (i64) -> !llvm.ptr
    llvm.store %853, %855 : i32, !llvm.ptr
    %856 = arith.constant 1 : i32
    %857 = arith.extsi %856 : i32 to i64
    llvm.store %857, %798 : i64, !llvm.ptr
    cf.br ^bb162
    ^bb162:
    %858 = llvm.load %798 : !llvm.ptr -> i64
    %859 = llvm.mlir.addressof @LIMIT : !llvm.ptr
    %860 = llvm.load %859 : !llvm.ptr -> i64
    %861 = arith.cmpi sle, %858, %860 : i64
    cf.cond_br %861, ^bb163, ^bb164
    ^bb163:
      %863 = llvm.load %798 : !llvm.ptr -> i64
      %864 = llvm.getelementptr %778[%863] : (!llvm.ptr, i64) -> !llvm.ptr, i32
      %862 = llvm.load %864 : !llvm.ptr -> i32
      %865 = llvm.load %855 : !llvm.ptr -> i32
      %866 = arith.cmpi sgt, %862, %865 : i32
      cf.cond_br %866, ^bb165, ^bb166
      ^bb165:
        %868 = llvm.load %798 : !llvm.ptr -> i64
        %869 = llvm.getelementptr %778[%868] : (!llvm.ptr, i64) -> !llvm.ptr, i32
        %867 = llvm.load %869 : !llvm.ptr -> i32
        llvm.store %867, %855 : i32, !llvm.ptr
        cf.br ^bb167
      ^bb166:
        cf.br ^bb167
      ^bb167:
      %870 = llvm.load %798 : !llvm.ptr -> i64
      %871 = arith.constant 1 : i32
      %873 = arith.extsi %871 : i32 to i64
      %872 = arith.addi %870, %873 : i64
      llvm.store %872, %798 : i64, !llvm.ptr
      cf.br ^bb162
    ^bb164:
    %874 = llvm.load %855 : !llvm.ptr -> i32
    %875 = arith.constant 1 : i32
    %876 = arith.addi %874, %875 : i32
    %877 = arith.extsi %876 : i32 to i64
    %879 = arith.constant 8 : i32
    %881 = arith.extsi %879 : i32 to i64
    %880 = arith.muli %877, %881 : i64
    %878 = func.call @malloc(%880) : (i64) -> !llvm.ptr
    %883 = arith.constant 8 : i32
    %885 = arith.extsi %883 : i32 to i64
    %884 = arith.muli %877, %885 : i64
    %882 = func.call @malloc(%884) : (i64) -> !llvm.ptr
    %887 = arith.constant 3 : i32
    %888 = arith.constant 8 : i32
    %889 = arith.muli %887, %888 : i32
    %890 = arith.extsi %889 : i32 to i64
    %886 = func.call @malloc(%890) : (i64) -> !llvm.ptr
    %891 = arith.constant 0 : i32
    %892 = arith.extsi %891 : i32 to i64
    %893 = llvm.mlir.constant(1 : i64) : i64
    %894 = llvm.alloca %893 x i64 : (i64) -> !llvm.ptr
    llvm.store %892, %894 : i64, !llvm.ptr
    %895 = arith.constant 1 : i32
    %896 = arith.extsi %895 : i32 to i64
    llvm.store %896, %798 : i64, !llvm.ptr
    cf.br ^bb168
    ^bb168:
    %897 = llvm.load %798 : !llvm.ptr -> i64
    %898 = llvm.mlir.addressof @LIMIT : !llvm.ptr
    %899 = llvm.load %898 : !llvm.ptr -> i64
    %900 = arith.cmpi sle, %897, %899 : i64
    cf.cond_br %900, ^bb169, ^bb170
    ^bb169:
      %901 = llvm.load %798 : !llvm.ptr -> i64
      %902 = llvm.load %798 : !llvm.ptr -> i64
      %903 = arith.muli %901, %902 : i64
      %905 = llvm.load %798 : !llvm.ptr -> i64
      %906 = llvm.getelementptr %778[%905] : (!llvm.ptr, i64) -> !llvm.ptr, i32
      %904 = llvm.load %906 : !llvm.ptr -> i32
      %908 = llvm.load %798 : !llvm.ptr -> i64
      %909 = llvm.getelementptr %787[%908] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.ptr
      %907 = llvm.load %909 : !llvm.ptr -> !llvm.ptr
      %910 = arith.constant 1 : i32
      %911 = arith.addi %904, %910 : i32
      %912 = arith.constant 0 : i32
      %913 = arith.constant 0 : i32
      %914 = arith.extsi %912 : i32 to i64
      %915 = arith.extsi %913 : i32 to i64
      %916 = llvm.getelementptr %878[%915] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %914, %916 : i64, !llvm.ptr
      %917 = llvm.load %798 : !llvm.ptr -> i64
      %918 = arith.constant 0 : i32
      %919 = arith.extsi %918 : i32 to i64
      %920 = llvm.getelementptr %882[%919] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %917, %920 : i64, !llvm.ptr
      %921 = arith.constant 0 : i32
      %922 = llvm.mlir.constant(1 : i64) : i64
      %923 = llvm.alloca %922 x i32 : (i64) -> !llvm.ptr
      llvm.store %921, %923 : i32, !llvm.ptr
      cf.br ^bb171
      ^bb171:
      %924 = llvm.load %923 : !llvm.ptr -> i32
      %925 = arith.cmpi slt, %924, %904 : i32
      cf.cond_br %925, ^bb172, ^bb173
      ^bb172:
        %927 = llvm.load %923 : !llvm.ptr -> i32
        %928 = arith.extsi %927 : i32 to i64
        %929 = llvm.getelementptr %907[%928] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %926 = llvm.load %929 : !llvm.ptr -> i64
        %930 = llvm.load %923 : !llvm.ptr -> i32
        %931 = arith.constant 1 : i32
        %932 = arith.addi %930, %931 : i32
        %933 = arith.extsi %932 : i32 to i64
        %934 = llvm.getelementptr %878[%933] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        llvm.store %926, %934 : i64, !llvm.ptr
        %937 = llvm.load %923 : !llvm.ptr -> i32
        %938 = arith.extsi %937 : i32 to i64
        %939 = llvm.getelementptr %907[%938] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %936 = llvm.load %939 : !llvm.ptr -> i64
        %941 = llvm.load %923 : !llvm.ptr -> i32
        %942 = arith.extsi %941 : i32 to i64
        %943 = llvm.getelementptr %907[%942] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %940 = llvm.load %943 : !llvm.ptr -> i64
        %944 = arith.muli %936, %940 : i64
        %945 = arith.addi %903, %944 : i64
        %935 = func.call @isqrt(%945) : (i64) -> i64
        %946 = llvm.load %923 : !llvm.ptr -> i32
        %947 = arith.constant 1 : i32
        %948 = arith.addi %946, %947 : i32
        %949 = arith.extsi %948 : i32 to i64
        %950 = llvm.getelementptr %882[%949] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        llvm.store %935, %950 : i64, !llvm.ptr
        %951 = llvm.load %923 : !llvm.ptr -> i32
        %952 = arith.constant 1 : i32
        %953 = arith.addi %951, %952 : i32
        llvm.store %953, %923 : i32, !llvm.ptr
        cf.br ^bb171
      ^bb173:
      %954 = arith.constant 0 : i32
      llvm.store %954, %923 : i32, !llvm.ptr
      cf.br ^bb174
      ^bb174:
      %955 = llvm.load %923 : !llvm.ptr -> i32
      %956 = arith.cmpi slt, %955, %911 : i32
      cf.cond_br %956, ^bb175, ^bb176
      ^bb175:
        %957 = llvm.load %923 : !llvm.ptr -> i32
        %958 = llvm.mlir.constant(1 : i64) : i64
        %959 = llvm.alloca %958 x i32 : (i64) -> !llvm.ptr
        llvm.store %957, %959 : i32, !llvm.ptr
        cf.br ^bb177
        ^bb177:
        %960 = llvm.load %959 : !llvm.ptr -> i32
        %961 = arith.cmpi slt, %960, %911 : i32
        cf.cond_br %961, ^bb178, ^bb179
        ^bb178:
          %963 = llvm.load %923 : !llvm.ptr -> i32
          %964 = arith.extsi %963 : i32 to i64
          %965 = llvm.getelementptr %878[%964] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          %962 = llvm.load %965 : !llvm.ptr -> i64
          %967 = llvm.load %923 : !llvm.ptr -> i32
          %968 = arith.extsi %967 : i32 to i64
          %969 = llvm.getelementptr %882[%968] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          %966 = llvm.load %969 : !llvm.ptr -> i64
          %971 = llvm.load %959 : !llvm.ptr -> i32
          %972 = arith.extsi %971 : i32 to i64
          %973 = llvm.getelementptr %878[%972] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          %970 = llvm.load %973 : !llvm.ptr -> i64
          %975 = llvm.load %959 : !llvm.ptr -> i32
          %976 = arith.extsi %975 : i32 to i64
          %977 = llvm.getelementptr %882[%976] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          %974 = llvm.load %977 : !llvm.ptr -> i64
          %978 = arith.addi %962, %970 : i64
          %979 = arith.constant 0 : i32
          %981 = arith.extsi %979 : i32 to i64
          %980 = arith.cmpi eq, %978, %981 : i64
          cf.cond_br %980, ^bb180, ^bb181
          ^bb180:
            %982 = llvm.load %959 : !llvm.ptr -> i32
            %983 = arith.constant 1 : i32
            %984 = arith.addi %982, %983 : i32
            llvm.store %984, %959 : i32, !llvm.ptr
            cf.br ^bb177
          ^bb181:
            cf.br ^bb182
          ^bb182:
          %985 = llvm.load %798 : !llvm.ptr -> i64
          %986 = arith.cmpi sgt, %978, %985 : i64
          cf.cond_br %986, ^bb183, ^bb184
          ^bb183:
            cf.br ^bb179
          ^bb184:
            cf.br ^bb185
          ^bb185:
          %987 = arith.muli %962, %970 : i64
          %988 = llvm.load %798 : !llvm.ptr -> i64
          %989 = llvm.load %798 : !llvm.ptr -> i64
          %990 = arith.subi %989, %978 : i64
          %991 = arith.muli %988, %990 : i64
          %992 = arith.cmpi slt, %987, %991 : i64
          cf.cond_br %992, ^bb186, ^bb187
          ^bb186:
            %993 = llvm.load %959 : !llvm.ptr -> i32
            %994 = arith.constant 1 : i32
            %995 = arith.addi %993, %994 : i32
            llvm.store %995, %959 : i32, !llvm.ptr
            cf.br ^bb177
          ^bb187:
            cf.br ^bb188
          ^bb188:
          %996 = arith.constant 0 : i32
          %997 = arith.extsi %996 : i32 to i64
          %998 = llvm.getelementptr %886[%997] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          llvm.store %978, %998 : i64, !llvm.ptr
          %999 = arith.constant 1 : i32
          %1000 = arith.extsi %999 : i32 to i64
          %1001 = llvm.getelementptr %886[%1000] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          llvm.store %966, %1001 : i64, !llvm.ptr
          %1002 = arith.constant 2 : i32
          %1003 = arith.extsi %1002 : i32 to i64
          %1004 = llvm.getelementptr %886[%1003] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          llvm.store %974, %1004 : i64, !llvm.ptr
          func.call @sort3(%886) : (!llvm.ptr) -> ()
          %1008 = arith.constant 0 : i32
          %1009 = arith.extsi %1008 : i32 to i64
          %1010 = llvm.getelementptr %886[%1009] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          %1007 = llvm.load %1010 : !llvm.ptr -> i64
          %1012 = arith.constant 1 : i32
          %1013 = arith.extsi %1012 : i32 to i64
          %1014 = llvm.getelementptr %886[%1013] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          %1011 = llvm.load %1014 : !llvm.ptr -> i64
          %1016 = arith.constant 2 : i32
          %1017 = arith.extsi %1016 : i32 to i64
          %1018 = llvm.getelementptr %886[%1017] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          %1015 = llvm.load %1018 : !llvm.ptr -> i64
          %1006 = func.call @encode_sides(%1007, %1011, %1015) : (i64, i64, i64) -> i64
          %1019 = func.call @seen_insert(%843, %848, %1006) : (!llvm.ptr, !llvm.ptr, i64) -> i32
          %1020 = arith.constant 0 : i32
          %1021 = arith.cmpi ne, %1019, %1020 : i32
          cf.cond_br %1021, ^bb189, ^bb190
          ^bb189:
            %1022 = llvm.load %894 : !llvm.ptr -> i64
            %1024 = arith.constant 0 : i32
            %1025 = arith.extsi %1024 : i32 to i64
            %1026 = llvm.getelementptr %886[%1025] : (!llvm.ptr, i64) -> !llvm.ptr, i64
            %1023 = llvm.load %1026 : !llvm.ptr -> i64
            %1027 = arith.addi %1022, %1023 : i64
            %1029 = arith.constant 1 : i32
            %1030 = arith.extsi %1029 : i32 to i64
            %1031 = llvm.getelementptr %886[%1030] : (!llvm.ptr, i64) -> !llvm.ptr, i64
            %1028 = llvm.load %1031 : !llvm.ptr -> i64
            %1032 = arith.addi %1027, %1028 : i64
            %1034 = arith.constant 2 : i32
            %1035 = arith.extsi %1034 : i32 to i64
            %1036 = llvm.getelementptr %886[%1035] : (!llvm.ptr, i64) -> !llvm.ptr, i64
            %1033 = llvm.load %1036 : !llvm.ptr -> i64
            %1037 = arith.addi %1032, %1033 : i64
            llvm.store %1037, %894 : i64, !llvm.ptr
            cf.br ^bb191
          ^bb190:
            cf.br ^bb191
          ^bb191:
          %1038 = llvm.load %959 : !llvm.ptr -> i32
          %1039 = arith.constant 1 : i32
          %1040 = arith.addi %1038, %1039 : i32
          llvm.store %1040, %959 : i32, !llvm.ptr
          cf.br ^bb177
        ^bb179:
        %1041 = llvm.load %923 : !llvm.ptr -> i32
        %1042 = arith.constant 1 : i32
        %1043 = arith.addi %1041, %1042 : i32
        llvm.store %1043, %923 : i32, !llvm.ptr
        cf.br ^bb174
      ^bb176:
      %1044 = arith.constant 0 : i32
      llvm.store %1044, %923 : i32, !llvm.ptr
      cf.br ^bb192
      ^bb192:
      %1045 = llvm.load %923 : !llvm.ptr -> i32
      %1046 = arith.cmpi slt, %1045, %911 : i32
      cf.cond_br %1046, ^bb193, ^bb194
      ^bb193:
        %1047 = llvm.load %923 : !llvm.ptr -> i32
        %1048 = llvm.mlir.constant(1 : i64) : i64
        %1049 = llvm.alloca %1048 x i32 : (i64) -> !llvm.ptr
        llvm.store %1047, %1049 : i32, !llvm.ptr
        cf.br ^bb195
        ^bb195:
        %1050 = llvm.load %1049 : !llvm.ptr -> i32
        %1051 = arith.cmpi slt, %1050, %911 : i32
        cf.cond_br %1051, ^bb196, ^bb197
        ^bb196:
          %1053 = llvm.load %923 : !llvm.ptr -> i32
          %1054 = arith.extsi %1053 : i32 to i64
          %1055 = llvm.getelementptr %878[%1054] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          %1052 = llvm.load %1055 : !llvm.ptr -> i64
          %1057 = llvm.load %923 : !llvm.ptr -> i32
          %1058 = arith.extsi %1057 : i32 to i64
          %1059 = llvm.getelementptr %882[%1058] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          %1056 = llvm.load %1059 : !llvm.ptr -> i64
          %1061 = llvm.load %1049 : !llvm.ptr -> i32
          %1062 = arith.extsi %1061 : i32 to i64
          %1063 = llvm.getelementptr %878[%1062] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          %1060 = llvm.load %1063 : !llvm.ptr -> i64
          %1065 = llvm.load %1049 : !llvm.ptr -> i32
          %1066 = arith.extsi %1065 : i32 to i64
          %1067 = llvm.getelementptr %882[%1066] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          %1064 = llvm.load %1067 : !llvm.ptr -> i64
          %1068 = arith.muli %1052, %1060 : i64
          %1069 = arith.subi %903, %1068 : i64
          %1070 = arith.constant 0 : i32
          %1072 = arith.extsi %1070 : i32 to i64
          %1071 = arith.cmpi sle, %1069, %1072 : i64
          cf.cond_br %1071, ^bb198, ^bb199
          ^bb198:
            %1073 = llvm.load %1049 : !llvm.ptr -> i32
            %1074 = arith.constant 1 : i32
            %1075 = arith.addi %1073, %1074 : i32
            llvm.store %1075, %1049 : i32, !llvm.ptr
            cf.br ^bb195
          ^bb199:
            cf.br ^bb200
          ^bb200:
          %1076 = llvm.load %798 : !llvm.ptr -> i64
          %1077 = arith.subi %1076, %1052 : i64
          %1078 = llvm.load %798 : !llvm.ptr -> i64
          %1079 = arith.subi %1078, %1060 : i64
          %1080 = arith.muli %1077, %1077 : i64
          %1081 = arith.muli %1079, %1079 : i64
          %1082 = arith.addi %1080, %1081 : i64
          %1083 = func.call @isqrt(%1082) : (i64) -> i64
          %1084 = arith.muli %1083, %1083 : i64
          %1085 = arith.cmpi ne, %1084, %1082 : i64
          %1086 = scf.if %1085 -> (i1) {
            %1087 = arith.constant true
            scf.yield %1087 : i1
          } else {
            %1088 = arith.constant 0 : i32
            %1090 = arith.extsi %1088 : i32 to i64
            %1089 = arith.cmpi eq, %1083, %1090 : i64
            scf.yield %1089 : i1
          }
          cf.cond_br %1086, ^bb201, ^bb202
          ^bb201:
            %1091 = llvm.load %1049 : !llvm.ptr -> i32
            %1092 = arith.constant 1 : i32
            %1093 = arith.addi %1091, %1092 : i32
            llvm.store %1093, %1049 : i32, !llvm.ptr
            cf.br ^bb195
          ^bb202:
            cf.br ^bb203
          ^bb203:
          %1094 = arith.constant 0 : i32
          %1095 = arith.extsi %1094 : i32 to i64
          %1096 = llvm.getelementptr %886[%1095] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          llvm.store %1083, %1096 : i64, !llvm.ptr
          %1097 = arith.constant 1 : i32
          %1098 = arith.extsi %1097 : i32 to i64
          %1099 = llvm.getelementptr %886[%1098] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          llvm.store %1056, %1099 : i64, !llvm.ptr
          %1100 = arith.constant 2 : i32
          %1101 = arith.extsi %1100 : i32 to i64
          %1102 = llvm.getelementptr %886[%1101] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          llvm.store %1064, %1102 : i64, !llvm.ptr
          func.call @sort3(%886) : (!llvm.ptr) -> ()
          %1106 = arith.constant 0 : i32
          %1107 = arith.extsi %1106 : i32 to i64
          %1108 = llvm.getelementptr %886[%1107] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          %1105 = llvm.load %1108 : !llvm.ptr -> i64
          %1110 = arith.constant 1 : i32
          %1111 = arith.extsi %1110 : i32 to i64
          %1112 = llvm.getelementptr %886[%1111] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          %1109 = llvm.load %1112 : !llvm.ptr -> i64
          %1114 = arith.constant 2 : i32
          %1115 = arith.extsi %1114 : i32 to i64
          %1116 = llvm.getelementptr %886[%1115] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          %1113 = llvm.load %1116 : !llvm.ptr -> i64
          %1104 = func.call @encode_sides(%1105, %1109, %1113) : (i64, i64, i64) -> i64
          %1117 = func.call @seen_insert(%843, %848, %1104) : (!llvm.ptr, !llvm.ptr, i64) -> i32
          %1118 = arith.constant 0 : i32
          %1119 = arith.cmpi eq, %1117, %1118 : i32
          cf.cond_br %1119, ^bb204, ^bb205
          ^bb204:
            %1120 = llvm.load %1049 : !llvm.ptr -> i32
            %1121 = arith.constant 1 : i32
            %1122 = arith.addi %1120, %1121 : i32
            llvm.store %1122, %1049 : i32, !llvm.ptr
            cf.br ^bb195
          ^bb205:
            cf.br ^bb206
          ^bb206:
          %1124 = llvm.load %798 : !llvm.ptr -> i64
          %1123 = func.call @is_minimum_square(%886, %1069, %1124) : (!llvm.ptr, i64, i64) -> i32
          %1125 = arith.constant 0 : i32
          %1126 = arith.cmpi ne, %1123, %1125 : i32
          cf.cond_br %1126, ^bb207, ^bb208
          ^bb207:
            %1127 = llvm.load %894 : !llvm.ptr -> i64
            %1129 = arith.constant 0 : i32
            %1130 = arith.extsi %1129 : i32 to i64
            %1131 = llvm.getelementptr %886[%1130] : (!llvm.ptr, i64) -> !llvm.ptr, i64
            %1128 = llvm.load %1131 : !llvm.ptr -> i64
            %1132 = arith.addi %1127, %1128 : i64
            %1134 = arith.constant 1 : i32
            %1135 = arith.extsi %1134 : i32 to i64
            %1136 = llvm.getelementptr %886[%1135] : (!llvm.ptr, i64) -> !llvm.ptr, i64
            %1133 = llvm.load %1136 : !llvm.ptr -> i64
            %1137 = arith.addi %1132, %1133 : i64
            %1139 = arith.constant 2 : i32
            %1140 = arith.extsi %1139 : i32 to i64
            %1141 = llvm.getelementptr %886[%1140] : (!llvm.ptr, i64) -> !llvm.ptr, i64
            %1138 = llvm.load %1141 : !llvm.ptr -> i64
            %1142 = arith.addi %1137, %1138 : i64
            llvm.store %1142, %894 : i64, !llvm.ptr
            cf.br ^bb209
          ^bb208:
            cf.br ^bb209
          ^bb209:
          %1143 = llvm.load %1049 : !llvm.ptr -> i32
          %1144 = arith.constant 1 : i32
          %1145 = arith.addi %1143, %1144 : i32
          llvm.store %1145, %1049 : i32, !llvm.ptr
          cf.br ^bb195
        ^bb197:
        %1146 = llvm.load %923 : !llvm.ptr -> i32
        %1147 = arith.constant 1 : i32
        %1148 = arith.addi %1146, %1147 : i32
        llvm.store %1148, %923 : i32, !llvm.ptr
        cf.br ^bb192
      ^bb194:
      %1149 = llvm.load %798 : !llvm.ptr -> i64
      %1150 = arith.constant 1 : i32
      %1152 = arith.extsi %1150 : i32 to i64
      %1151 = arith.addi %1149, %1152 : i64
      llvm.store %1151, %798 : i64, !llvm.ptr
      cf.br ^bb168
    ^bb170:
    %1153 = llvm.mlir.addressof @str_0 : !llvm.ptr
    %1154 = llvm.load %894 : !llvm.ptr -> i64
    %1155 = llvm.call @printf(%1153, %1154) vararg(!llvm.func<i32 (ptr, ...)>) : (!llvm.ptr, i64) -> i32
    %1156 = arith.constant 0 : i32
    %1157 = arith.extsi %1156 : i32 to i64
    llvm.store %1157, %798 : i64, !llvm.ptr
    cf.br ^bb210
    ^bb210:
    %1158 = llvm.load %798 : !llvm.ptr -> i64
    %1159 = llvm.mlir.addressof @LIMIT : !llvm.ptr
    %1160 = llvm.load %1159 : !llvm.ptr -> i64
    %1161 = arith.cmpi sle, %1158, %1160 : i64
    cf.cond_br %1161, ^bb211, ^bb212
    ^bb211:
      %1163 = llvm.load %798 : !llvm.ptr -> i64
      %1164 = llvm.getelementptr %787[%1163] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.ptr
      %1162 = llvm.load %1164 : !llvm.ptr -> !llvm.ptr
      %1165 = llvm.mlir.zero : !llvm.ptr
      %1166 = llvm.icmp "ne" %1162, %1165 : !llvm.ptr
      cf.cond_br %1166, ^bb213, ^bb214
      ^bb213:
        %1169 = llvm.load %798 : !llvm.ptr -> i64
        %1170 = llvm.getelementptr %787[%1169] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.ptr
        %1168 = llvm.load %1170 : !llvm.ptr -> !llvm.ptr
        func.call @free(%1168) : (!llvm.ptr) -> ()
        cf.br ^bb215
      ^bb214:
        cf.br ^bb215
      ^bb215:
      %1171 = llvm.load %798 : !llvm.ptr -> i64
      %1172 = arith.constant 1 : i32
      %1174 = arith.extsi %1172 : i32 to i64
      %1173 = arith.addi %1171, %1174 : i64
      llvm.store %1173, %798 : i64, !llvm.ptr
      cf.br ^bb210
    ^bb212:
    func.call @free(%787) : (!llvm.ptr) -> ()
    func.call @free(%778) : (!llvm.ptr) -> ()
    func.call @free(%843) : (!llvm.ptr) -> ()
    func.call @free(%848) : (!llvm.ptr) -> ()
    func.call @free(%878) : (!llvm.ptr) -> ()
    func.call @free(%882) : (!llvm.ptr) -> ()
    func.call @free(%886) : (!llvm.ptr) -> ()
    %1182 = arith.constant 0 : i32
    func.return %1182 : i32
  }
}