Problem 846

Magic Bracelets - F(10^6) using Gaussian integer vectors and path merging.

Answer9851175623
Output9851175623
StatusPASS
Native helperno
Runtime30 ms
Peak memory88224 KB
Time complexityO(n^2) (estimated)
Space complexityO(n^2) (estimated)

Performance comparison

MetricOur solutionBest known
Time complexityO(n^2)?
Space complexityO(n^2)?
ApproachFlow solutionNot curated
VerdictUnknown

Flow source

# Project Euler 846
# Magic Bracelets - F(10^6) using Gaussian integer vectors and path merging.

import euler.nt { gcd }

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

const LIMIT: i64 = 1000000
const EDGE_HT_SIZE: i64 = 2097152
const EDGE_HT_MASK: i64 = 2097151

# Extended GCD for modular inverse (recursive)
function ext_gcd(a: i64, b: i64, x: ptr<i64>, y: ptr<i64>) -> i64 {
    if b == 0 {
        x[0] = 1
        y[0] = 0
        return a
    }
    let x1: i64 = 0
    let y1: i64 = 0
    # Use stack-allocated temps via pointers
    let g: i64 = ext_gcd(b, a % b, &x1, &y1)
    x[0] = y1
    y[0] = x1 - (a / b) * y1
    return g
}

function mod_inverse(a0: i64, m: i64) -> i64 {
    let a: i64 = ((a0 % m) + m) % m
    let x: i64 = 0
    let y: i64 = 0
    let g: i64 = ext_gcd(a, m, &x, &y)
    if g != 1 { return -1 }
    return ((x % m) + m) % m
}

# canonical: make (x,y) into (|x|,|y|) with |x| >= |y|
function canonical(x: ptr<i64>, y: ptr<i64>) -> void {
    let mut a: i64 = x[0]
    let mut b: i64 = y[0]
    if a < 0 { a = -a }
    if b < 0 { b = -b }
    if b > a {
        let t: i64 = a
        a = b
        b = t
    }
    x[0] = a
    y[0] = b
}

function encode_edge(a0: i64, b0: i64) -> i64 {
    let mut a: i64 = a0
    let mut b: i64 = b0
    if a < b {
        let t: i64 = a
        a = b
        b = t
    }
    return a * (LIMIT + 1) + b
}

function hash_key(key: i64) -> i64 {
    let mut h: i64 = (key * 11400714819323198485) as i64
    if h < 0 { h = -h }
    return h & EDGE_HT_MASK
}

struct EdgeEntry {
    key: i64,
    count: i64,
    sum: i64,
    used: i8
}

function edge_find(edge_ht: ptr<EdgeEntry>, key: i64) -> i64 {
    let mut h: i64 = hash_key(key)
    while edge_ht[h].used != 0 {
        if edge_ht[h].key == key { return h }
        h = (h + 1) & EDGE_HT_MASK
    }
    return h
}

function edge_lookup(edge_ht: ptr<EdgeEntry>, key: i64) -> i64 {
    let mut h: i64 = hash_key(key)
    while edge_ht[h].used != 0 {
        if edge_ht[h].key == key { return h }
        h = (h + 1) & EDGE_HT_MASK
    }
    return -1
}

# parent_labels: find parent labels for a Gaussian integer vector
function parent_labels(label: i64, x: i64, y: i64,
                       vec_x: ptr<i64>, vec_y: ptr<i64>, vec_valid: ptr<i8>,
                       parents: ptr<i64>, np: ptr<i32>) -> void {
    np[0] = 0
    if label == 2 {
        parents[0] = 1
        np[0] = 1
        return
    }
    if y == 0 { return }

    let beta: i64 = mod_inverse(y, x)
    if beta < 0 { return }
    let alpha: i64 = (1 - beta * y) / x

    let q1x: i64 = if beta < 0 { -beta } else { beta }
    let q1y: i64 = if alpha < 0 { -alpha } else { alpha }
    let q2x: i64 = x - q1x
    let q2y: i64 = y - q1y

    let n1: i64 = q1x * q1x + q1y * q1y
    let n2: i64 = q2x * q2x + q2y * q2y

    if n1 <= LIMIT && vec_valid[n1] != 0 {
        parents[np[0]] = n1
        np[0] = np[0] + 1
    }
    if n2 <= LIMIT && vec_valid[n2] != 0 && n2 != n1 {
        parents[np[0]] = n2
        np[0] = np[0] + 1
    }
    # Sort descending
    if np[0] == 2 && parents[0] < parents[1] {
        let t: i64 = parents[0]
        parents[0] = parents[1]
        parents[1] = t
    }
}

function main() -> i32 {
    # Vector storage as parallel arrays
    let vec_x: ptr<i64> = calloc(LIMIT + 1, 8) as ptr<i64>
    let vec_y: ptr<i64> = calloc(LIMIT + 1, 8) as ptr<i64>
    let vec_valid: ptr<i8> = calloc(LIMIT + 1, 1) as ptr<i8>

    # Square root lookup
    let sq_root: ptr<i32> = calloc(LIMIT + 1, 4) as ptr<i32>

    # Sieve
    let is_prime: ptr<i8> = calloc(LIMIT + 1, 1) as ptr<i8>
    memset(is_prime as ptr<void>, 1, LIMIT + 1)
    is_prime[0] = 0
    is_prime[1] = 0

    vec_x[1] = 1; vec_y[1] = 0; vec_valid[1] = 1
    vec_x[2] = 1; vec_y[2] = 1; vec_valid[2] = 1

    # Build square root lookup
    let mut i: i64 = 0
    while i * i <= LIMIT {
        sq_root[i * i] = i as i32
        i = i + 1
    }

    # Sieve
    let mut p: i64 = 2
    while p * p <= LIMIT {
        if is_prime[p] != 0 {
            let mut m: i64 = p * p
            while m <= LIMIT {
                is_prime[m] = 0
                m = m + p
            }
        }
        p = p + 1
    }

    # For each prime p = 1 (mod 4), find base representation
    p = 5
    while p <= LIMIT {
        if is_prime[p] == 0 || p % 4 != 1 {
            p = p + 1
            continue
        }

        let mut bx: i64 = 0
        let mut by: i64 = 0
        let mut x: i64 = 1
        while x * x <= p {
            let rem: i32 = (p - x * x) as i32
            if rem >= 0 && (rem as i64) <= LIMIT && sq_root[rem as i64] != 0 {
                bx = x
                by = sq_root[rem as i64] as i64
                canonical(&bx, &by)
                break
            }
            x = x + 1
        }
        if bx == 0 {
            p = p + 1
            continue
        }

        let mut value: i64 = p
        let mut cx: i64 = bx
        let mut cy: i64 = by
        while value <= LIMIT {
            let ccx: i64 = cx
            let ccy: i64 = cy
            canonical(&ccx, &ccy)
            vec_x[value] = ccx
            vec_y[value] = ccy
            vec_valid[value] = 1

            let doubled: i64 = 2 * value
            if doubled <= LIMIT {
                let mut dx: i64 = ccx - ccy
                let mut dy: i64 = ccx + ccy
                canonical(&dx, &dy)
                vec_x[doubled] = dx
                vec_y[doubled] = dy
                vec_valid[doubled] = 1
            }

            let nx: i64 = cx * bx - cy * by
            let ny: i64 = cx * by + cy * bx
            cx = nx
            cy = ny
            value = value * p
        }
        p = p + 1
    }

    # Edge hash map (EdgeEntry = 32 bytes with padding)
    let edge_ht: ptr<EdgeEntry> = calloc(EDGE_HT_SIZE, 32) as ptr<EdgeEntry>

    let mut total: i64 = 0

    # Process labels in decreasing order
    let mut label: i64 = LIMIT
    while label >= 2 {
        if vec_valid[label] == 0 {
            label = label - 1
            continue
        }

        let x: i64 = vec_x[label]
        let y: i64 = vec_y[label]
        let parents: ptr<i64> = calloc(2, 8) as ptr<i64>
        let np_ptr: ptr<i32> = calloc(1, 4) as ptr<i32>

        parent_labels(label, x, y, vec_x, vec_y, vec_valid, parents, np_ptr)
        let np: i32 = np_ptr[0]

        if np == 0 {
            free(parents as ptr<void>)
            free(np_ptr as ptr<void>)
            label = label - 1
            continue
        }

        let mut pi: i32 = 0
        while pi < np {
            let parent: i64 = parents[pi]
            let key: i64 = encode_edge(label, parent)
            let ei: i64 = edge_find(edge_ht, key)
            let mut count: i64 = 0
            let mut isum: i64 = 0
            if edge_ht[ei].used != 0 {
                count = edge_ht[ei].count
                isum = edge_ht[ei].sum
            }

            total = total + count * (label + parent) + isum

            if edge_ht[ei].used == 0 {
                edge_ht[ei].used = 1
                edge_ht[ei].key = key
            }
            edge_ht[ei].count = count + 1
            edge_ht[ei].sum = isum
            pi = pi + 1
        }

        if np == 2 {
            let a: i64 = parents[0]
            let b: i64 = parents[1]
            let key_a: i64 = encode_edge(label, a)
            let key_b: i64 = encode_edge(label, b)
            let ea_i: i64 = edge_lookup(edge_ht, key_a)
            let eb_i: i64 = edge_lookup(edge_ht, key_b)

            if ea_i < 0 || eb_i < 0 {
                free(parents as ptr<void>)
                free(np_ptr as ptr<void>)
                label = label - 1
                continue
            }

            let count_a: i64 = edge_ht[ea_i].count
            let sum_a: i64 = edge_ht[ea_i].sum
            let count_b: i64 = edge_ht[eb_i].count
            let sum_b: i64 = edge_ht[eb_i].sum

            let merged_count: i64 = count_a * count_b
            let merged_sum: i64 = merged_count * label + count_a * sum_b + count_b * sum_a

            let lower_key: i64 = encode_edge(a, b)
            let le_i: i64 = edge_find(edge_ht, lower_key)
            let mut old_count: i64 = 0
            let mut old_sum: i64 = 0
            if edge_ht[le_i].used != 0 {
                old_count = edge_ht[le_i].count
                old_sum = edge_ht[le_i].sum
            }
            if edge_ht[le_i].used == 0 {
                edge_ht[le_i].used = 1
                edge_ht[le_i].key = lower_key
            }
            edge_ht[le_i].count = old_count + merged_count
            edge_ht[le_i].sum = old_sum + merged_sum
        }

        free(parents as ptr<void>)
        free(np_ptr as ptr<void>)
        label = label - 1
    }

    printf("%lld\n", total)

    free(vec_x as ptr<void>)
    free(vec_y as ptr<void>)
    free(vec_valid as ptr<void>)
    free(sq_root as ptr<void>)
    free(is_prime as ptr<void>)
    free(edge_ht 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; }

typedef struct EdgeEntry EdgeEntry;

struct EdgeEntry {
    int64_t key;
    int64_t count;
    int64_t sum;
    int8_t used;
};

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 ext_gcd_i64_i64_ptr_i64_ptr_i64(int64_t a, int64_t b, int64_t* x, int64_t* y);
int64_t mod_inverse_i64_i64(int64_t a0, int64_t m);
void canonical_ptr_i64_ptr_i64(int64_t* x, int64_t* y);
int64_t encode_edge_i64_i64(int64_t a0, int64_t b0);
int64_t hash_key_i64(int64_t key);
int64_t edge_find_ptr_EdgeEntry_i64(EdgeEntry* edge_ht, int64_t key);
int64_t edge_lookup_ptr_EdgeEntry_i64(EdgeEntry* edge_ht, int64_t key);
void parent_labels_i64_i64_i64_ptr_i64_ptr_i64_ptr_i8_ptr_i64_ptr_i32(int64_t label, int64_t x, int64_t y, int64_t* vec_x, int64_t* vec_y, int8_t* vec_valid, int64_t* parents, int32_t* np);
int32_t main(void);

static const int64_t LIMIT = 1000000;
static const int64_t EDGE_HT_SIZE = 2097152;
static const int64_t EDGE_HT_MASK = 2097151;

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 ext_gcd_i64_i64_ptr_i64_ptr_i64(int64_t a, int64_t b, int64_t* x, int64_t* y) {
    if (b == 0) {
        x[0] = 1;
        y[0] = 0;
        return a;
    }
    int64_t x1 = 0;
    int64_t y1 = 0;
    int64_t g = ext_gcd_i64_i64_ptr_i64_ptr_i64(b, FLOW_CHECKED_MOD((a), (b)), (&(x1)), (&(y1)));
    x[0] = y1;
    y[0] = (x1 - (FLOW_CHECKED_DIV((a), (b)) * y1));
    return g;
}

int64_t mod_inverse_i64_i64(int64_t a0, int64_t m) {
    int64_t a = FLOW_CHECKED_MOD(((FLOW_CHECKED_MOD((a0), (m)) + m)), (m));
    int64_t x = 0;
    int64_t y = 0;
    int64_t g = ext_gcd_i64_i64_ptr_i64_ptr_i64(a, m, (&(x)), (&(y)));
    if (g != 1) {
        return (-1);
    }
    return FLOW_CHECKED_MOD(((FLOW_CHECKED_MOD((x), (m)) + m)), (m));
}

void canonical_ptr_i64_ptr_i64(int64_t* x, int64_t* y) {
    int64_t a = x[0];
    int64_t b = y[0];
    if (a < 0) {
        a = (-a);
    }
    if (b < 0) {
        b = (-b);
    }
    if (b > a) {
        int64_t t = a;
        a = b;
        b = t;
    }
    x[0] = a;
    y[0] = b;
}

int64_t encode_edge_i64_i64(int64_t a0, int64_t b0) {
    int64_t a = a0;
    int64_t b = b0;
    if (a < b) {
        int64_t t = a;
        a = b;
        b = t;
    }
    return ((a * (LIMIT + 1)) + b);
}

int64_t hash_key_i64(int64_t key) {
    int64_t h = ((int64_t)((key * ((__int128)0x9E3779B97F4A7C15ULL))));
    if (h < 0) {
        h = (-h);
    }
    return (h & EDGE_HT_MASK);
}

int64_t edge_find_ptr_EdgeEntry_i64(EdgeEntry* edge_ht, int64_t key) {
    int64_t h = hash_key_i64(key);
    while (edge_ht[h].used != 0) {
        if (edge_ht[h].key == key) {
            return h;
        }
        h = ((h + 1) & EDGE_HT_MASK);
    }
    return h;
}

int64_t edge_lookup_ptr_EdgeEntry_i64(EdgeEntry* edge_ht, int64_t key) {
    int64_t h = hash_key_i64(key);
    while (edge_ht[h].used != 0) {
        if (edge_ht[h].key == key) {
            return h;
        }
        h = ((h + 1) & EDGE_HT_MASK);
    }
    return (-1);
}

void parent_labels_i64_i64_i64_ptr_i64_ptr_i64_ptr_i8_ptr_i64_ptr_i32(int64_t label, int64_t x, int64_t y, int64_t* vec_x, int64_t* vec_y, int8_t* vec_valid, int64_t* parents, int32_t* np) {
    np[0] = 0;
    if (label == 2) {
        parents[0] = 1;
        np[0] = 1;
        return;
    }
    if (y == 0) {
        return;
    }
    int64_t beta = mod_inverse_i64_i64(y, x);
    if (beta < 0) {
        return;
    }
    int64_t alpha = FLOW_CHECKED_DIV(((1 - (beta * y))), (x));
    int64_t q1x = ((beta < 0) ? ((-beta)) : (beta));
    int64_t q1y = ((alpha < 0) ? ((-alpha)) : (alpha));
    int64_t q2x = (x - q1x);
    int64_t q2y = (y - q1y);
    int64_t n1 = ((q1x * q1x) + (q1y * q1y));
    int64_t n2 = ((q2x * q2x) + (q2y * q2y));
    if ((n1 <= LIMIT && vec_valid[n1] != 0)) {
        parents[np[0]] = n1;
        np[0] = (np[0] + 1);
    }
    if (((n2 <= LIMIT && vec_valid[n2] != 0) && n2 != n1)) {
        parents[np[0]] = n2;
        np[0] = (np[0] + 1);
    }
    if ((np[0] == 2 && parents[0] < parents[1])) {
        int64_t t = parents[0];
        parents[0] = parents[1];
        parents[1] = t;
    }
}

int32_t main(void) {
    int64_t* vec_x = (int64_t*)(((int64_t*)(calloc((LIMIT + 1), 8))));
    int64_t* vec_y = (int64_t*)(((int64_t*)(calloc((LIMIT + 1), 8))));
    int8_t* vec_valid = (int8_t*)(((int8_t*)(calloc((LIMIT + 1), 1))));
    int32_t* sq_root = (int32_t*)(((int32_t*)(calloc((LIMIT + 1), 4))));
    int8_t* is_prime = (int8_t*)(((int8_t*)(calloc((LIMIT + 1), 1))));
    memset(((void*)(is_prime)), 1, (LIMIT + 1));
    is_prime[0] = 0;
    is_prime[1] = 0;
    vec_x[1] = 1;
    vec_y[1] = 0;
    vec_valid[1] = 1;
    vec_x[2] = 1;
    vec_y[2] = 1;
    vec_valid[2] = 1;
    int64_t i = 0;
    while ((i * i) <= LIMIT) {
        sq_root[(i * i)] = ((int32_t)(i));
        i = (i + 1);
    }
    int64_t p = 2;
    while ((p * p) <= LIMIT) {
        if (is_prime[p] != 0) {
            int64_t m = (p * p);
            while (m <= LIMIT) {
                is_prime[m] = 0;
                m = (m + p);
            }
        }
        p = (p + 1);
    }
    p = 5;
    while (p <= LIMIT) {
        if ((is_prime[p] == 0 || FLOW_CHECKED_MOD((p), (4)) != 1)) {
            p = (p + 1);
            continue;
        }
        int64_t bx = 0;
        int64_t by = 0;
        int64_t x = 1;
        while ((x * x) <= p) {
            int32_t rem = ((int32_t)((p - (x * x))));
            if (((rem >= 0 && ((int64_t)(rem)) <= LIMIT) && sq_root[((int64_t)(rem))] != 0)) {
                bx = x;
                by = ((int64_t)(sq_root[((int64_t)(rem))]));
                canonical_ptr_i64_ptr_i64((&(bx)), (&(by)));
                break;
            }
            x = (x + 1);
        }
        if (bx == 0) {
            p = (p + 1);
            continue;
        }
        int64_t value = p;
        int64_t cx = bx;
        int64_t cy = by;
        while (value <= LIMIT) {
            int64_t ccx = cx;
            int64_t ccy = cy;
            canonical_ptr_i64_ptr_i64((&(ccx)), (&(ccy)));
            vec_x[value] = ccx;
            vec_y[value] = ccy;
            vec_valid[value] = 1;
            int64_t doubled = (2 * value);
            if (doubled <= LIMIT) {
                int64_t dx = (ccx - ccy);
                int64_t dy = (ccx + ccy);
                canonical_ptr_i64_ptr_i64((&(dx)), (&(dy)));
                vec_x[doubled] = dx;
                vec_y[doubled] = dy;
                vec_valid[doubled] = 1;
            }
            int64_t nx = ((cx * bx) - (cy * by));
            int64_t ny = ((cx * by) + (cy * bx));
            cx = nx;
            cy = ny;
            value = (value * p);
        }
        p = (p + 1);
    }
    EdgeEntry* edge_ht = (EdgeEntry*)(((EdgeEntry*)(calloc(EDGE_HT_SIZE, 32))));
    int64_t total = 0;
    int64_t label = LIMIT;
    while (label >= 2) {
        if (vec_valid[label] == 0) {
            label = (label - 1);
            continue;
        }
        int64_t x = vec_x[label];
        int64_t y = vec_y[label];
        int64_t* parents = (int64_t*)(((int64_t*)(calloc(2, 8))));
        int32_t* np_ptr = (int32_t*)(((int32_t*)(calloc(1, 4))));
        parent_labels_i64_i64_i64_ptr_i64_ptr_i64_ptr_i8_ptr_i64_ptr_i32(label, x, y, vec_x, vec_y, vec_valid, parents, np_ptr);
        int32_t np = np_ptr[0];
        if (np == 0) {
            free(((void*)(parents)));
            free(((void*)(np_ptr)));
            label = (label - 1);
            continue;
        }
        int32_t pi = 0;
        while (pi < np) {
            int64_t parent = parents[pi];
            int64_t key = encode_edge_i64_i64(label, parent);
            int64_t ei = edge_find_ptr_EdgeEntry_i64(edge_ht, key);
            int64_t count = 0;
            int64_t isum = 0;
            if (edge_ht[ei].used != 0) {
                count = edge_ht[ei].count;
                isum = edge_ht[ei].sum;
            }
            total = ((total + (count * (label + parent))) + isum);
            if (edge_ht[ei].used == 0) {
                edge_ht[ei].used = 1;
                edge_ht[ei].key = key;
            }
            edge_ht[ei].count = (count + 1);
            edge_ht[ei].sum = isum;
            pi = (pi + 1);
        }
        if (np == 2) {
            int64_t a = parents[0];
            int64_t b = parents[1];
            int64_t key_a = encode_edge_i64_i64(label, a);
            int64_t key_b = encode_edge_i64_i64(label, b);
            int64_t ea_i = edge_lookup_ptr_EdgeEntry_i64(edge_ht, key_a);
            int64_t eb_i = edge_lookup_ptr_EdgeEntry_i64(edge_ht, key_b);
            if ((ea_i < 0 || eb_i < 0)) {
                free(((void*)(parents)));
                free(((void*)(np_ptr)));
                label = (label - 1);
                continue;
            }
            int64_t count_a = edge_ht[ea_i].count;
            int64_t sum_a = edge_ht[ea_i].sum;
            int64_t count_b = edge_ht[eb_i].count;
            int64_t sum_b = edge_ht[eb_i].sum;
            int64_t merged_count = (count_a * count_b);
            int64_t merged_sum = (((merged_count * label) + (count_a * sum_b)) + (count_b * sum_a));
            int64_t lower_key = encode_edge_i64_i64(a, b);
            int64_t le_i = edge_find_ptr_EdgeEntry_i64(edge_ht, lower_key);
            int64_t old_count = 0;
            int64_t old_sum = 0;
            if (edge_ht[le_i].used != 0) {
                old_count = edge_ht[le_i].count;
                old_sum = edge_ht[le_i].sum;
            }
            if (edge_ht[le_i].used == 0) {
                edge_ht[le_i].used = 1;
                edge_ht[le_i].key = lower_key;
            }
            edge_ht[le_i].count = (old_count + merged_count);
            edge_ht[le_i].sum = (old_sum + merged_sum);
        }
        free(((void*)(parents)));
        free(((void*)(np_ptr)));
        label = (label - 1);
    }
    printf("%lld\n", total);
    free(((void*)(vec_x)));
    free(((void*)(vec_y)));
    free(((void*)(vec_valid)));
    free(((void*)(sq_root)));
    free(((void*)(is_prime)));
    free(((void*)(edge_ht)));
    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 @malloc(i64) -> !llvm.ptr
  func.func private @free(!llvm.ptr) -> ()
  func.func private @memset(!llvm.ptr, i64, i64) -> !llvm.ptr
  // Constant: LIMIT
  llvm.mlir.global internal constant @LIMIT(1000000 : i64) : i64
  // Constant: EDGE_HT_SIZE
  llvm.mlir.global internal constant @EDGE_HT_SIZE(2097152 : i64) : i64
  // Constant: EDGE_HT_MASK
  llvm.mlir.global internal constant @EDGE_HT_MASK(2097151 : i64) : i64
  func.func @ext_gcd(%arg0: i64, %arg1: i64, %arg2: !llvm.ptr, %arg3: !llvm.ptr) -> i64 {
    %175 = arith.constant 0 : i32
    %177 = arith.extsi %175 : i32 to i64
    %176 = arith.cmpi eq, %arg1, %177 : i64
    cf.cond_br %176, ^bb42, ^bb43
    ^bb42:
      %178 = arith.constant 1 : i32
      %179 = arith.constant 0 : i32
      %180 = arith.extsi %178 : i32 to i64
      %181 = arith.extsi %179 : i32 to i64
      %182 = llvm.getelementptr %arg2[%181] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %180, %182 : i64, !llvm.ptr
      %183 = arith.constant 0 : i32
      %184 = arith.constant 0 : i32
      %185 = arith.extsi %183 : i32 to i64
      %186 = arith.extsi %184 : i32 to i64
      %187 = llvm.getelementptr %arg3[%186] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %185, %187 : i64, !llvm.ptr
      func.return %arg0 : i64
    ^bb43:
      cf.br ^bb44
    ^bb44:
    %188 = arith.constant 0 : i32
    %189 = arith.extsi %188 : i32 to i64
    %190 = arith.constant 0 : i32
    %191 = arith.extsi %190 : i32 to i64
    %193 = arith.remsi %arg0, %arg1 : i64
    %194 = llvm.mlir.constant(1 : i64) : i64
    %195 = llvm.alloca %194 x i64 : (i64) -> !llvm.ptr
    llvm.store %189, %195 : i64, !llvm.ptr
    %196 = llvm.mlir.constant(1 : i64) : i64
    %197 = llvm.alloca %196 x i64 : (i64) -> !llvm.ptr
    llvm.store %191, %197 : i64, !llvm.ptr
    %192 = func.call @ext_gcd(%arg1, %193, %195, %197) : (i64, i64, !llvm.ptr, !llvm.ptr) -> i64
    %198 = llvm.load %197 : !llvm.ptr -> i64
    %199 = arith.constant 0 : i32
    %200 = arith.extsi %199 : i32 to i64
    %201 = llvm.getelementptr %arg2[%200] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    llvm.store %198, %201 : i64, !llvm.ptr
    %202 = llvm.load %195 : !llvm.ptr -> i64
    %203 = arith.divsi %arg0, %arg1 : i64
    %204 = llvm.load %197 : !llvm.ptr -> i64
    %205 = arith.muli %203, %204 : i64
    %206 = arith.subi %202, %205 : i64
    %207 = arith.constant 0 : i32
    %208 = arith.extsi %207 : i32 to i64
    %209 = llvm.getelementptr %arg3[%208] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    llvm.store %206, %209 : i64, !llvm.ptr
    func.return %192 : i64
  }
  func.func @mod_inverse(%arg0: i64, %arg1: i64) -> i64 {
    %210 = arith.remsi %arg0, %arg1 : i64
    %211 = arith.addi %210, %arg1 : i64
    %212 = arith.remsi %211, %arg1 : i64
    %213 = arith.constant 0 : i32
    %214 = arith.extsi %213 : i32 to i64
    %215 = arith.constant 0 : i32
    %216 = arith.extsi %215 : i32 to i64
    %218 = llvm.mlir.constant(1 : i64) : i64
    %219 = llvm.alloca %218 x i64 : (i64) -> !llvm.ptr
    llvm.store %214, %219 : i64, !llvm.ptr
    %220 = llvm.mlir.constant(1 : i64) : i64
    %221 = llvm.alloca %220 x i64 : (i64) -> !llvm.ptr
    llvm.store %216, %221 : i64, !llvm.ptr
    %217 = func.call @ext_gcd(%212, %arg1, %219, %221) : (i64, i64, !llvm.ptr, !llvm.ptr) -> i64
    %222 = arith.constant 1 : i32
    %224 = arith.extsi %222 : i32 to i64
    %223 = arith.cmpi ne, %217, %224 : i64
    cf.cond_br %223, ^bb45, ^bb46
    ^bb45:
      %225 = arith.constant 1 : i32
      %227 = arith.constant 0 : i32
      %226 = arith.subi %227, %225 : i32
      %228 = arith.extsi %226 : i32 to i64
      func.return %228 : i64
    ^bb46:
      cf.br ^bb47
    ^bb47:
    %229 = llvm.load %219 : !llvm.ptr -> i64
    %230 = arith.remsi %229, %arg1 : i64
    %231 = arith.addi %230, %arg1 : i64
    %232 = arith.remsi %231, %arg1 : i64
    func.return %232 : i64
  }
  func.func @canonical(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> () {
    %234 = arith.constant 0 : i32
    %235 = arith.extsi %234 : i32 to i64
    %236 = llvm.getelementptr %arg0[%235] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    %233 = llvm.load %236 : !llvm.ptr -> i64
    %237 = llvm.mlir.constant(1 : i64) : i64
    %238 = llvm.alloca %237 x i64 : (i64) -> !llvm.ptr
    llvm.store %233, %238 : i64, !llvm.ptr
    %240 = arith.constant 0 : i32
    %241 = arith.extsi %240 : i32 to i64
    %242 = llvm.getelementptr %arg1[%241] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    %239 = llvm.load %242 : !llvm.ptr -> i64
    %243 = llvm.mlir.constant(1 : i64) : i64
    %244 = llvm.alloca %243 x i64 : (i64) -> !llvm.ptr
    llvm.store %239, %244 : i64, !llvm.ptr
    %245 = llvm.load %238 : !llvm.ptr -> i64
    %246 = arith.constant 0 : i32
    %248 = arith.extsi %246 : i32 to i64
    %247 = arith.cmpi slt, %245, %248 : i64
    cf.cond_br %247, ^bb48, ^bb49
    ^bb48:
      %249 = llvm.load %238 : !llvm.ptr -> i64
      %251 = arith.constant 0 : i64
      %250 = arith.subi %251, %249 : i64
      llvm.store %250, %238 : i64, !llvm.ptr
      cf.br ^bb50
    ^bb49:
      cf.br ^bb50
    ^bb50:
    %252 = llvm.load %244 : !llvm.ptr -> i64
    %253 = arith.constant 0 : i32
    %255 = arith.extsi %253 : i32 to i64
    %254 = arith.cmpi slt, %252, %255 : i64
    cf.cond_br %254, ^bb51, ^bb52
    ^bb51:
      %256 = llvm.load %244 : !llvm.ptr -> i64
      %258 = arith.constant 0 : i64
      %257 = arith.subi %258, %256 : i64
      llvm.store %257, %244 : i64, !llvm.ptr
      cf.br ^bb53
    ^bb52:
      cf.br ^bb53
    ^bb53:
    %259 = llvm.load %244 : !llvm.ptr -> i64
    %260 = llvm.load %238 : !llvm.ptr -> i64
    %261 = arith.cmpi sgt, %259, %260 : i64
    cf.cond_br %261, ^bb54, ^bb55
    ^bb54:
      %262 = llvm.load %238 : !llvm.ptr -> i64
      %263 = llvm.load %244 : !llvm.ptr -> i64
      llvm.store %263, %238 : i64, !llvm.ptr
      llvm.store %262, %244 : i64, !llvm.ptr
      cf.br ^bb56
    ^bb55:
      cf.br ^bb56
    ^bb56:
    %264 = llvm.load %238 : !llvm.ptr -> i64
    %265 = arith.constant 0 : i32
    %266 = arith.extsi %265 : i32 to i64
    %267 = llvm.getelementptr %arg0[%266] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    llvm.store %264, %267 : i64, !llvm.ptr
    %268 = llvm.load %244 : !llvm.ptr -> i64
    %269 = arith.constant 0 : i32
    %270 = arith.extsi %269 : i32 to i64
    %271 = llvm.getelementptr %arg1[%270] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    llvm.store %268, %271 : i64, !llvm.ptr
    func.return
  }
  func.func @encode_edge(%arg0: i64, %arg1: i64) -> i64 {
    %272 = llvm.mlir.constant(1 : i64) : i64
    %273 = llvm.alloca %272 x i64 : (i64) -> !llvm.ptr
    llvm.store %arg0, %273 : i64, !llvm.ptr
    %274 = llvm.mlir.constant(1 : i64) : i64
    %275 = llvm.alloca %274 x i64 : (i64) -> !llvm.ptr
    llvm.store %arg1, %275 : i64, !llvm.ptr
    %276 = llvm.load %273 : !llvm.ptr -> i64
    %277 = llvm.load %275 : !llvm.ptr -> i64
    %278 = arith.cmpi slt, %276, %277 : i64
    cf.cond_br %278, ^bb57, ^bb58
    ^bb57:
      %279 = llvm.load %273 : !llvm.ptr -> i64
      %280 = llvm.load %275 : !llvm.ptr -> i64
      llvm.store %280, %273 : i64, !llvm.ptr
      llvm.store %279, %275 : i64, !llvm.ptr
      cf.br ^bb59
    ^bb58:
      cf.br ^bb59
    ^bb59:
    %281 = llvm.load %273 : !llvm.ptr -> i64
    %282 = llvm.mlir.addressof @LIMIT : !llvm.ptr
    %283 = llvm.load %282 : !llvm.ptr -> i64
    %284 = arith.constant 1 : i32
    %286 = arith.extsi %284 : i32 to i64
    %285 = arith.addi %283, %286 : i64
    %287 = arith.muli %281, %285 : i64
    %288 = llvm.load %275 : !llvm.ptr -> i64
    %289 = arith.addi %287, %288 : i64
    func.return %289 : i64
  }
  func.func @hash_key(%arg0: i64) -> i64 {
    %290 = arith.constant 11400714815028231189 : i32
    %292 = arith.extsi %290 : i32 to i64
    %291 = arith.muli %arg0, %292 : i64
    %293 = llvm.mlir.constant(1 : i64) : i64
    %294 = llvm.alloca %293 x i64 : (i64) -> !llvm.ptr
    llvm.store %291, %294 : i64, !llvm.ptr
    %295 = llvm.load %294 : !llvm.ptr -> i64
    %296 = arith.constant 0 : i32
    %298 = arith.extsi %296 : i32 to i64
    %297 = arith.cmpi slt, %295, %298 : i64
    cf.cond_br %297, ^bb60, ^bb61
    ^bb60:
      %299 = llvm.load %294 : !llvm.ptr -> i64
      %301 = arith.constant 0 : i64
      %300 = arith.subi %301, %299 : i64
      llvm.store %300, %294 : i64, !llvm.ptr
      cf.br ^bb62
    ^bb61:
      cf.br ^bb62
    ^bb62:
    %302 = llvm.load %294 : !llvm.ptr -> i64
    %303 = llvm.mlir.addressof @EDGE_HT_MASK : !llvm.ptr
    %304 = llvm.load %303 : !llvm.ptr -> i64
    %305 = arith.andi %302, %304 : i64
    func.return %305 : i64
  }
  // Struct: EdgeEntry
  // Fields:
  //   key: i64
  //   count: i64
  //   sum: i64
  //   used: i8
  func.func @edge_find(%arg0: !llvm.ptr, %arg1: i64) -> i64 {
    %306 = func.call @hash_key(%arg1) : (i64) -> i64
    %307 = llvm.mlir.constant(1 : i64) : i64
    %308 = llvm.alloca %307 x i64 : (i64) -> !llvm.ptr
    llvm.store %306, %308 : i64, !llvm.ptr
    cf.br ^bb63
    ^bb63:
    %310 = llvm.load %308 : !llvm.ptr -> i64
    %311 = llvm.getelementptr %arg0[%310] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64, i64, i64, i8)>
    %309 = llvm.load %311 : !llvm.ptr -> !llvm.struct<(i64, i64, i64, i8)>
    %312 = llvm.load %308 : !llvm.ptr -> i64
    %313 = llvm.getelementptr %arg0[%312] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64, i64, i64, i8)>
    %314 = llvm.getelementptr %313[0, 3] : (!llvm.ptr) -> !llvm.ptr, !llvm.struct<(i64, i64, i64, i8)>
    %315 = llvm.load %314 : !llvm.ptr -> i8
    %316 = arith.constant 0 : i32
    %318 = arith.extsi %315 : i8 to i32
    %317 = arith.cmpi ne, %318, %316 : i32
    cf.cond_br %317, ^bb64, ^bb65
    ^bb64:
      %320 = llvm.load %308 : !llvm.ptr -> i64
      %321 = llvm.getelementptr %arg0[%320] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64, i64, i64, i8)>
      %319 = llvm.load %321 : !llvm.ptr -> !llvm.struct<(i64, i64, i64, i8)>
      %322 = llvm.load %308 : !llvm.ptr -> i64
      %323 = llvm.getelementptr %arg0[%322] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64, i64, i64, i8)>
      %324 = llvm.getelementptr %323[0, 0] : (!llvm.ptr) -> !llvm.ptr, !llvm.struct<(i64, i64, i64, i8)>
      %325 = llvm.load %324 : !llvm.ptr -> i64
      %326 = arith.cmpi eq, %325, %arg1 : i64
      cf.cond_br %326, ^bb66, ^bb67
      ^bb66:
        %327 = llvm.load %308 : !llvm.ptr -> i64
        func.return %327 : i64
      ^bb67:
        cf.br ^bb68
      ^bb68:
      %328 = llvm.load %308 : !llvm.ptr -> i64
      %329 = arith.constant 1 : i32
      %331 = arith.extsi %329 : i32 to i64
      %330 = arith.addi %328, %331 : i64
      %332 = llvm.mlir.addressof @EDGE_HT_MASK : !llvm.ptr
      %333 = llvm.load %332 : !llvm.ptr -> i64
      %334 = arith.andi %330, %333 : i64
      llvm.store %334, %308 : i64, !llvm.ptr
      cf.br ^bb63
    ^bb65:
    %335 = llvm.load %308 : !llvm.ptr -> i64
    func.return %335 : i64
  }
  func.func @edge_lookup(%arg0: !llvm.ptr, %arg1: i64) -> i64 {
    %336 = func.call @hash_key(%arg1) : (i64) -> i64
    %337 = llvm.mlir.constant(1 : i64) : i64
    %338 = llvm.alloca %337 x i64 : (i64) -> !llvm.ptr
    llvm.store %336, %338 : i64, !llvm.ptr
    cf.br ^bb69
    ^bb69:
    %340 = llvm.load %338 : !llvm.ptr -> i64
    %341 = llvm.getelementptr %arg0[%340] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64, i64, i64, i8)>
    %339 = llvm.load %341 : !llvm.ptr -> !llvm.struct<(i64, i64, i64, i8)>
    %342 = llvm.load %338 : !llvm.ptr -> i64
    %343 = llvm.getelementptr %arg0[%342] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64, i64, i64, i8)>
    %344 = llvm.getelementptr %343[0, 3] : (!llvm.ptr) -> !llvm.ptr, !llvm.struct<(i64, i64, i64, i8)>
    %345 = llvm.load %344 : !llvm.ptr -> i8
    %346 = arith.constant 0 : i32
    %348 = arith.extsi %345 : i8 to i32
    %347 = arith.cmpi ne, %348, %346 : i32
    cf.cond_br %347, ^bb70, ^bb71
    ^bb70:
      %350 = llvm.load %338 : !llvm.ptr -> i64
      %351 = llvm.getelementptr %arg0[%350] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64, i64, i64, i8)>
      %349 = llvm.load %351 : !llvm.ptr -> !llvm.struct<(i64, i64, i64, i8)>
      %352 = llvm.load %338 : !llvm.ptr -> i64
      %353 = llvm.getelementptr %arg0[%352] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64, i64, i64, i8)>
      %354 = llvm.getelementptr %353[0, 0] : (!llvm.ptr) -> !llvm.ptr, !llvm.struct<(i64, i64, i64, i8)>
      %355 = llvm.load %354 : !llvm.ptr -> i64
      %356 = arith.cmpi eq, %355, %arg1 : i64
      cf.cond_br %356, ^bb72, ^bb73
      ^bb72:
        %357 = llvm.load %338 : !llvm.ptr -> i64
        func.return %357 : i64
      ^bb73:
        cf.br ^bb74
      ^bb74:
      %358 = llvm.load %338 : !llvm.ptr -> i64
      %359 = arith.constant 1 : i32
      %361 = arith.extsi %359 : i32 to i64
      %360 = arith.addi %358, %361 : i64
      %362 = llvm.mlir.addressof @EDGE_HT_MASK : !llvm.ptr
      %363 = llvm.load %362 : !llvm.ptr -> i64
      %364 = arith.andi %360, %363 : i64
      llvm.store %364, %338 : i64, !llvm.ptr
      cf.br ^bb69
    ^bb71:
    %365 = arith.constant 1 : i32
    %367 = arith.constant 0 : i32
    %366 = arith.subi %367, %365 : i32
    %368 = arith.extsi %366 : i32 to i64
    func.return %368 : i64
  }
  func.func @parent_labels(%arg0: i64, %arg1: i64, %arg2: i64, %arg3: !llvm.ptr, %arg4: !llvm.ptr, %arg5: !llvm.ptr, %arg6: !llvm.ptr, %arg7: !llvm.ptr) -> () {
    %369 = arith.constant 0 : i32
    %370 = arith.constant 0 : i32
    %371 = arith.extsi %370 : i32 to i64
    %372 = llvm.getelementptr %arg7[%371] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    llvm.store %369, %372 : i32, !llvm.ptr
    %373 = arith.constant 2 : i32
    %375 = arith.extsi %373 : i32 to i64
    %374 = arith.cmpi eq, %arg0, %375 : i64
    cf.cond_br %374, ^bb75, ^bb76
    ^bb75:
      %376 = arith.constant 1 : i32
      %377 = arith.constant 0 : i32
      %378 = arith.extsi %376 : i32 to i64
      %379 = arith.extsi %377 : i32 to i64
      %380 = llvm.getelementptr %arg6[%379] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %378, %380 : i64, !llvm.ptr
      %381 = arith.constant 1 : i32
      %382 = arith.constant 0 : i32
      %383 = arith.extsi %382 : i32 to i64
      %384 = llvm.getelementptr %arg7[%383] : (!llvm.ptr, i64) -> !llvm.ptr, i32
      llvm.store %381, %384 : i32, !llvm.ptr
      func.return
    ^bb76:
      cf.br ^bb77
    ^bb77:
    %385 = arith.constant 0 : i32
    %387 = arith.extsi %385 : i32 to i64
    %386 = arith.cmpi eq, %arg2, %387 : i64
    cf.cond_br %386, ^bb78, ^bb79
    ^bb78:
      func.return
    ^bb79:
      cf.br ^bb80
    ^bb80:
    %388 = func.call @mod_inverse(%arg2, %arg1) : (i64, i64) -> i64
    %389 = arith.constant 0 : i32
    %391 = arith.extsi %389 : i32 to i64
    %390 = arith.cmpi slt, %388, %391 : i64
    cf.cond_br %390, ^bb81, ^bb82
    ^bb81:
      func.return
    ^bb82:
      cf.br ^bb83
    ^bb83:
    %392 = arith.constant 1 : i32
    %393 = arith.muli %388, %arg2 : i64
    %395 = arith.extsi %392 : i32 to i64
    %394 = arith.subi %395, %393 : i64
    %396 = arith.divsi %394, %arg1 : i64
    %397 = arith.constant 0 : i32
    %399 = arith.extsi %397 : i32 to i64
    %398 = arith.cmpi slt, %388, %399 : i64
    %400 = scf.if %398 -> (i64) {
      %402 = arith.constant 0 : i64
      %401 = arith.subi %402, %388 : i64
      scf.yield %401 : i64
    } else {
      scf.yield %388 : i64
    }
    %403 = arith.constant 0 : i32
    %405 = arith.extsi %403 : i32 to i64
    %404 = arith.cmpi slt, %396, %405 : i64
    %406 = scf.if %404 -> (i64) {
      %408 = arith.constant 0 : i64
      %407 = arith.subi %408, %396 : i64
      scf.yield %407 : i64
    } else {
      scf.yield %396 : i64
    }
    %409 = arith.subi %arg1, %400 : i64
    %410 = arith.subi %arg2, %406 : i64
    %411 = arith.muli %400, %400 : i64
    %412 = arith.muli %406, %406 : i64
    %413 = arith.addi %411, %412 : i64
    %414 = arith.muli %409, %409 : i64
    %415 = arith.muli %410, %410 : i64
    %416 = arith.addi %414, %415 : i64
    %417 = llvm.mlir.addressof @LIMIT : !llvm.ptr
    %418 = llvm.load %417 : !llvm.ptr -> i64
    %419 = arith.cmpi sle, %413, %418 : i64
    %420 = scf.if %419 -> (i1) {
      %422 = llvm.getelementptr %arg5[%413] : (!llvm.ptr, i64) -> !llvm.ptr, i8
      %421 = llvm.load %422 : !llvm.ptr -> i8
      %423 = arith.constant 0 : i32
      %425 = arith.extsi %421 : i8 to i32
      %424 = arith.cmpi ne, %425, %423 : i32
      scf.yield %424 : i1
    } else {
      %426 = arith.constant false
      scf.yield %426 : i1
    }
    cf.cond_br %420, ^bb84, ^bb85
    ^bb84:
      %428 = arith.constant 0 : i32
      %429 = arith.extsi %428 : i32 to i64
      %430 = llvm.getelementptr %arg7[%429] : (!llvm.ptr, i64) -> !llvm.ptr, i32
      %427 = llvm.load %430 : !llvm.ptr -> i32
      %431 = arith.extsi %427 : i32 to i64
      %432 = llvm.getelementptr %arg6[%431] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %413, %432 : i64, !llvm.ptr
      %434 = arith.constant 0 : i32
      %435 = arith.extsi %434 : i32 to i64
      %436 = llvm.getelementptr %arg7[%435] : (!llvm.ptr, i64) -> !llvm.ptr, i32
      %433 = llvm.load %436 : !llvm.ptr -> i32
      %437 = arith.constant 1 : i32
      %438 = arith.addi %433, %437 : i32
      %439 = arith.constant 0 : i32
      %440 = arith.extsi %439 : i32 to i64
      %441 = llvm.getelementptr %arg7[%440] : (!llvm.ptr, i64) -> !llvm.ptr, i32
      llvm.store %438, %441 : i32, !llvm.ptr
      cf.br ^bb86
    ^bb85:
      cf.br ^bb86
    ^bb86:
    %442 = llvm.mlir.addressof @LIMIT : !llvm.ptr
    %443 = llvm.load %442 : !llvm.ptr -> i64
    %444 = arith.cmpi sle, %416, %443 : i64
    %445 = scf.if %444 -> (i1) {
      %447 = llvm.getelementptr %arg5[%416] : (!llvm.ptr, i64) -> !llvm.ptr, i8
      %446 = llvm.load %447 : !llvm.ptr -> i8
      %448 = arith.constant 0 : i32
      %450 = arith.extsi %446 : i8 to i32
      %449 = arith.cmpi ne, %450, %448 : i32
      scf.yield %449 : i1
    } else {
      %451 = arith.constant false
      scf.yield %451 : i1
    }
    %452 = scf.if %445 -> (i1) {
      %453 = arith.cmpi ne, %416, %413 : i64
      scf.yield %453 : i1
    } else {
      %454 = arith.constant false
      scf.yield %454 : i1
    }
    cf.cond_br %452, ^bb87, ^bb88
    ^bb87:
      %456 = arith.constant 0 : i32
      %457 = arith.extsi %456 : i32 to i64
      %458 = llvm.getelementptr %arg7[%457] : (!llvm.ptr, i64) -> !llvm.ptr, i32
      %455 = llvm.load %458 : !llvm.ptr -> i32
      %459 = arith.extsi %455 : i32 to i64
      %460 = llvm.getelementptr %arg6[%459] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %416, %460 : i64, !llvm.ptr
      %462 = arith.constant 0 : i32
      %463 = arith.extsi %462 : i32 to i64
      %464 = llvm.getelementptr %arg7[%463] : (!llvm.ptr, i64) -> !llvm.ptr, i32
      %461 = llvm.load %464 : !llvm.ptr -> i32
      %465 = arith.constant 1 : i32
      %466 = arith.addi %461, %465 : i32
      %467 = arith.constant 0 : i32
      %468 = arith.extsi %467 : i32 to i64
      %469 = llvm.getelementptr %arg7[%468] : (!llvm.ptr, i64) -> !llvm.ptr, i32
      llvm.store %466, %469 : i32, !llvm.ptr
      cf.br ^bb89
    ^bb88:
      cf.br ^bb89
    ^bb89:
    %471 = arith.constant 0 : i32
    %472 = arith.extsi %471 : i32 to i64
    %473 = llvm.getelementptr %arg7[%472] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    %470 = llvm.load %473 : !llvm.ptr -> i32
    %474 = arith.constant 2 : i32
    %475 = arith.cmpi eq, %470, %474 : i32
    %476 = scf.if %475 -> (i1) {
      %478 = arith.constant 0 : i32
      %479 = arith.extsi %478 : i32 to i64
      %480 = llvm.getelementptr %arg6[%479] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %477 = llvm.load %480 : !llvm.ptr -> i64
      %482 = arith.constant 1 : i32
      %483 = arith.extsi %482 : i32 to i64
      %484 = llvm.getelementptr %arg6[%483] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %481 = llvm.load %484 : !llvm.ptr -> i64
      %485 = arith.cmpi slt, %477, %481 : i64
      scf.yield %485 : i1
    } else {
      %486 = arith.constant false
      scf.yield %486 : i1
    }
    cf.cond_br %476, ^bb90, ^bb91
    ^bb90:
      %488 = arith.constant 0 : i32
      %489 = arith.extsi %488 : i32 to i64
      %490 = llvm.getelementptr %arg6[%489] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %487 = llvm.load %490 : !llvm.ptr -> i64
      %492 = arith.constant 1 : i32
      %493 = arith.extsi %492 : i32 to i64
      %494 = llvm.getelementptr %arg6[%493] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %491 = llvm.load %494 : !llvm.ptr -> i64
      %495 = arith.constant 0 : i32
      %496 = arith.extsi %495 : i32 to i64
      %497 = llvm.getelementptr %arg6[%496] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %491, %497 : i64, !llvm.ptr
      %498 = arith.constant 1 : i32
      %499 = arith.extsi %498 : i32 to i64
      %500 = llvm.getelementptr %arg6[%499] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %487, %500 : i64, !llvm.ptr
      cf.br ^bb92
    ^bb91:
      cf.br ^bb92
    ^bb92:
    func.return
  }
  func.func @main() -> i32 {
    %502 = llvm.mlir.addressof @LIMIT : !llvm.ptr
    %503 = llvm.load %502 : !llvm.ptr -> i64
    %504 = arith.constant 1 : i32
    %506 = arith.extsi %504 : i32 to i64
    %505 = arith.addi %503, %506 : i64
    %507 = arith.constant 8 : i32
    %508 = arith.extsi %507 : i32 to i64
    %501 = func.call @calloc(%505, %508) : (i64, i64) -> !llvm.ptr
    %510 = llvm.mlir.addressof @LIMIT : !llvm.ptr
    %511 = llvm.load %510 : !llvm.ptr -> i64
    %512 = arith.constant 1 : i32
    %514 = arith.extsi %512 : i32 to i64
    %513 = arith.addi %511, %514 : i64
    %515 = arith.constant 8 : i32
    %516 = arith.extsi %515 : i32 to i64
    %509 = func.call @calloc(%513, %516) : (i64, i64) -> !llvm.ptr
    %518 = llvm.mlir.addressof @LIMIT : !llvm.ptr
    %519 = llvm.load %518 : !llvm.ptr -> i64
    %520 = arith.constant 1 : i32
    %522 = arith.extsi %520 : i32 to i64
    %521 = arith.addi %519, %522 : i64
    %523 = arith.constant 1 : i32
    %524 = arith.extsi %523 : i32 to i64
    %517 = func.call @calloc(%521, %524) : (i64, i64) -> !llvm.ptr
    %526 = llvm.mlir.addressof @LIMIT : !llvm.ptr
    %527 = llvm.load %526 : !llvm.ptr -> i64
    %528 = arith.constant 1 : i32
    %530 = arith.extsi %528 : i32 to i64
    %529 = arith.addi %527, %530 : i64
    %531 = arith.constant 4 : i32
    %532 = arith.extsi %531 : i32 to i64
    %525 = func.call @calloc(%529, %532) : (i64, i64) -> !llvm.ptr
    %534 = llvm.mlir.addressof @LIMIT : !llvm.ptr
    %535 = llvm.load %534 : !llvm.ptr -> i64
    %536 = arith.constant 1 : i32
    %538 = arith.extsi %536 : i32 to i64
    %537 = arith.addi %535, %538 : i64
    %539 = arith.constant 1 : i32
    %540 = arith.extsi %539 : i32 to i64
    %533 = func.call @calloc(%537, %540) : (i64, i64) -> !llvm.ptr
    %542 = arith.constant 1 : i32
    %543 = llvm.mlir.addressof @LIMIT : !llvm.ptr
    %544 = llvm.load %543 : !llvm.ptr -> i64
    %545 = arith.constant 1 : i32
    %547 = arith.extsi %545 : i32 to i64
    %546 = arith.addi %544, %547 : i64
    %548 = arith.extsi %542 : i32 to i64
    %541 = func.call @memset(%533, %548, %546) : (!llvm.ptr, i64, i64) -> !llvm.ptr
    %549 = arith.constant 0 : i32
    %550 = arith.constant 0 : i32
    %551 = arith.trunci %549 : i32 to i8
    %552 = arith.extsi %550 : i32 to i64
    %553 = llvm.getelementptr %533[%552] : (!llvm.ptr, i64) -> !llvm.ptr, i8
    llvm.store %551, %553 : i8, !llvm.ptr
    %554 = arith.constant 0 : i32
    %555 = arith.constant 1 : i32
    %556 = arith.trunci %554 : i32 to i8
    %557 = arith.extsi %555 : i32 to i64
    %558 = llvm.getelementptr %533[%557] : (!llvm.ptr, i64) -> !llvm.ptr, i8
    llvm.store %556, %558 : i8, !llvm.ptr
    %559 = arith.constant 1 : i32
    %560 = arith.constant 1 : i32
    %561 = arith.extsi %559 : i32 to i64
    %562 = arith.extsi %560 : i32 to i64
    %563 = llvm.getelementptr %501[%562] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    llvm.store %561, %563 : i64, !llvm.ptr
    %564 = arith.constant 0 : i32
    %565 = arith.constant 1 : i32
    %566 = arith.extsi %564 : i32 to i64
    %567 = arith.extsi %565 : i32 to i64
    %568 = llvm.getelementptr %509[%567] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    llvm.store %566, %568 : i64, !llvm.ptr
    %569 = arith.constant 1 : i32
    %570 = arith.constant 1 : i32
    %571 = arith.trunci %569 : i32 to i8
    %572 = arith.extsi %570 : i32 to i64
    %573 = llvm.getelementptr %517[%572] : (!llvm.ptr, i64) -> !llvm.ptr, i8
    llvm.store %571, %573 : i8, !llvm.ptr
    %574 = arith.constant 1 : i32
    %575 = arith.constant 2 : i32
    %576 = arith.extsi %574 : i32 to i64
    %577 = arith.extsi %575 : i32 to i64
    %578 = llvm.getelementptr %501[%577] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    llvm.store %576, %578 : i64, !llvm.ptr
    %579 = arith.constant 1 : i32
    %580 = arith.constant 2 : i32
    %581 = arith.extsi %579 : i32 to i64
    %582 = arith.extsi %580 : i32 to i64
    %583 = llvm.getelementptr %509[%582] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    llvm.store %581, %583 : i64, !llvm.ptr
    %584 = arith.constant 1 : i32
    %585 = arith.constant 2 : i32
    %586 = arith.trunci %584 : i32 to i8
    %587 = arith.extsi %585 : i32 to i64
    %588 = llvm.getelementptr %517[%587] : (!llvm.ptr, i64) -> !llvm.ptr, i8
    llvm.store %586, %588 : i8, !llvm.ptr
    %589 = arith.constant 0 : i32
    %590 = arith.extsi %589 : i32 to i64
    %591 = llvm.mlir.constant(1 : i64) : i64
    %592 = llvm.alloca %591 x i64 : (i64) -> !llvm.ptr
    llvm.store %590, %592 : i64, !llvm.ptr
    cf.br ^bb93
    ^bb93:
    %593 = llvm.load %592 : !llvm.ptr -> i64
    %594 = llvm.load %592 : !llvm.ptr -> i64
    %595 = arith.muli %593, %594 : i64
    %596 = llvm.mlir.addressof @LIMIT : !llvm.ptr
    %597 = llvm.load %596 : !llvm.ptr -> i64
    %598 = arith.cmpi sle, %595, %597 : i64
    cf.cond_br %598, ^bb94, ^bb95
    ^bb94:
      %599 = llvm.load %592 : !llvm.ptr -> i64
      %600 = arith.trunci %599 : i64 to i32
      %601 = llvm.load %592 : !llvm.ptr -> i64
      %602 = llvm.load %592 : !llvm.ptr -> i64
      %603 = arith.muli %601, %602 : i64
      %604 = llvm.getelementptr %525[%603] : (!llvm.ptr, i64) -> !llvm.ptr, i32
      llvm.store %600, %604 : i32, !llvm.ptr
      %605 = llvm.load %592 : !llvm.ptr -> i64
      %606 = arith.constant 1 : i32
      %608 = arith.extsi %606 : i32 to i64
      %607 = arith.addi %605, %608 : i64
      llvm.store %607, %592 : i64, !llvm.ptr
      cf.br ^bb93
    ^bb95:
    %609 = arith.constant 2 : i32
    %610 = arith.extsi %609 : i32 to i64
    %611 = llvm.mlir.constant(1 : i64) : i64
    %612 = llvm.alloca %611 x i64 : (i64) -> !llvm.ptr
    llvm.store %610, %612 : i64, !llvm.ptr
    cf.br ^bb96
    ^bb96:
    %613 = llvm.load %612 : !llvm.ptr -> i64
    %614 = llvm.load %612 : !llvm.ptr -> i64
    %615 = arith.muli %613, %614 : i64
    %616 = llvm.mlir.addressof @LIMIT : !llvm.ptr
    %617 = llvm.load %616 : !llvm.ptr -> i64
    %618 = arith.cmpi sle, %615, %617 : i64
    cf.cond_br %618, ^bb97, ^bb98
    ^bb97:
      %620 = llvm.load %612 : !llvm.ptr -> i64
      %621 = llvm.getelementptr %533[%620] : (!llvm.ptr, i64) -> !llvm.ptr, i8
      %619 = llvm.load %621 : !llvm.ptr -> i8
      %622 = arith.constant 0 : i32
      %624 = arith.extsi %619 : i8 to i32
      %623 = arith.cmpi ne, %624, %622 : i32
      cf.cond_br %623, ^bb99, ^bb100
      ^bb99:
        %625 = llvm.load %612 : !llvm.ptr -> i64
        %626 = llvm.load %612 : !llvm.ptr -> i64
        %627 = arith.muli %625, %626 : i64
        %628 = llvm.mlir.constant(1 : i64) : i64
        %629 = llvm.alloca %628 x i64 : (i64) -> !llvm.ptr
        llvm.store %627, %629 : i64, !llvm.ptr
        cf.br ^bb102
        ^bb102:
        %630 = llvm.load %629 : !llvm.ptr -> i64
        %631 = llvm.mlir.addressof @LIMIT : !llvm.ptr
        %632 = llvm.load %631 : !llvm.ptr -> i64
        %633 = arith.cmpi sle, %630, %632 : i64
        cf.cond_br %633, ^bb103, ^bb104
        ^bb103:
          %634 = arith.constant 0 : i32
          %635 = llvm.load %629 : !llvm.ptr -> i64
          %636 = arith.trunci %634 : i32 to i8
          %637 = llvm.getelementptr %533[%635] : (!llvm.ptr, i64) -> !llvm.ptr, i8
          llvm.store %636, %637 : i8, !llvm.ptr
          %638 = llvm.load %629 : !llvm.ptr -> i64
          %639 = llvm.load %612 : !llvm.ptr -> i64
          %640 = arith.addi %638, %639 : i64
          llvm.store %640, %629 : i64, !llvm.ptr
          cf.br ^bb102
        ^bb104:
        cf.br ^bb101
      ^bb100:
        cf.br ^bb101
      ^bb101:
      %641 = llvm.load %612 : !llvm.ptr -> i64
      %642 = arith.constant 1 : i32
      %644 = arith.extsi %642 : i32 to i64
      %643 = arith.addi %641, %644 : i64
      llvm.store %643, %612 : i64, !llvm.ptr
      cf.br ^bb96
    ^bb98:
    %645 = arith.constant 5 : i32
    %646 = arith.extsi %645 : i32 to i64
    llvm.store %646, %612 : i64, !llvm.ptr
    cf.br ^bb105
    ^bb105:
    %647 = llvm.load %612 : !llvm.ptr -> i64
    %648 = llvm.mlir.addressof @LIMIT : !llvm.ptr
    %649 = llvm.load %648 : !llvm.ptr -> i64
    %650 = arith.cmpi sle, %647, %649 : i64
    cf.cond_br %650, ^bb106, ^bb107
    ^bb106:
      %652 = llvm.load %612 : !llvm.ptr -> i64
      %653 = llvm.getelementptr %533[%652] : (!llvm.ptr, i64) -> !llvm.ptr, i8
      %651 = llvm.load %653 : !llvm.ptr -> i8
      %654 = arith.constant 0 : i32
      %656 = arith.extsi %651 : i8 to i32
      %655 = arith.cmpi eq, %656, %654 : i32
      %657 = scf.if %655 -> (i1) {
        %658 = arith.constant true
        scf.yield %658 : i1
      } else {
        %659 = llvm.load %612 : !llvm.ptr -> i64
        %660 = arith.constant 4 : i32
        %662 = arith.extsi %660 : i32 to i64
        %661 = arith.remsi %659, %662 : i64
        %663 = arith.constant 1 : i32
        %665 = arith.extsi %663 : i32 to i64
        %664 = arith.cmpi ne, %661, %665 : i64
        scf.yield %664 : i1
      }
      cf.cond_br %657, ^bb108, ^bb109
      ^bb108:
        %666 = llvm.load %612 : !llvm.ptr -> i64
        %667 = arith.constant 1 : i32
        %669 = arith.extsi %667 : i32 to i64
        %668 = arith.addi %666, %669 : i64
        llvm.store %668, %612 : i64, !llvm.ptr
        cf.br ^bb105
      ^bb109:
        cf.br ^bb110
      ^bb110:
      %670 = arith.constant 0 : i32
      %671 = arith.extsi %670 : i32 to i64
      %672 = llvm.mlir.constant(1 : i64) : i64
      %673 = llvm.alloca %672 x i64 : (i64) -> !llvm.ptr
      llvm.store %671, %673 : i64, !llvm.ptr
      %674 = arith.constant 0 : i32
      %675 = arith.extsi %674 : i32 to i64
      %676 = llvm.mlir.constant(1 : i64) : i64
      %677 = llvm.alloca %676 x i64 : (i64) -> !llvm.ptr
      llvm.store %675, %677 : i64, !llvm.ptr
      %678 = arith.constant 1 : i32
      %679 = arith.extsi %678 : i32 to i64
      %680 = llvm.mlir.constant(1 : i64) : i64
      %681 = llvm.alloca %680 x i64 : (i64) -> !llvm.ptr
      llvm.store %679, %681 : i64, !llvm.ptr
      cf.br ^bb111
      ^bb111:
      %682 = llvm.load %681 : !llvm.ptr -> i64
      %683 = llvm.load %681 : !llvm.ptr -> i64
      %684 = arith.muli %682, %683 : i64
      %685 = llvm.load %612 : !llvm.ptr -> i64
      %686 = arith.cmpi sle, %684, %685 : i64
      cf.cond_br %686, ^bb112, ^bb113
      ^bb112:
        %687 = llvm.load %612 : !llvm.ptr -> i64
        %688 = llvm.load %681 : !llvm.ptr -> i64
        %689 = llvm.load %681 : !llvm.ptr -> i64
        %690 = arith.muli %688, %689 : i64
        %691 = arith.subi %687, %690 : i64
        %692 = arith.trunci %691 : i64 to i32
        %693 = arith.constant 0 : i32
        %694 = arith.cmpi sge, %692, %693 : i32
        %695 = scf.if %694 -> (i1) {
          %696 = arith.extsi %692 : i32 to i64
          %697 = llvm.mlir.addressof @LIMIT : !llvm.ptr
          %698 = llvm.load %697 : !llvm.ptr -> i64
          %699 = arith.cmpi sle, %696, %698 : i64
          scf.yield %699 : i1
        } else {
          %700 = arith.constant false
          scf.yield %700 : i1
        }
        %701 = scf.if %695 -> (i1) {
          %703 = arith.extsi %692 : i32 to i64
          %704 = llvm.getelementptr %525[%703] : (!llvm.ptr, i64) -> !llvm.ptr, i32
          %702 = llvm.load %704 : !llvm.ptr -> i32
          %705 = arith.constant 0 : i32
          %706 = arith.cmpi ne, %702, %705 : i32
          scf.yield %706 : i1
        } else {
          %707 = arith.constant false
          scf.yield %707 : i1
        }
        cf.cond_br %701, ^bb114, ^bb115
        ^bb114:
          %708 = llvm.load %681 : !llvm.ptr -> i64
          llvm.store %708, %673 : i64, !llvm.ptr
          %710 = arith.extsi %692 : i32 to i64
          %711 = llvm.getelementptr %525[%710] : (!llvm.ptr, i64) -> !llvm.ptr, i32
          %709 = llvm.load %711 : !llvm.ptr -> i32
          %712 = arith.extsi %709 : i32 to i64
          llvm.store %712, %677 : i64, !llvm.ptr
          func.call @canonical(%673, %677) : (!llvm.ptr, !llvm.ptr) -> ()
          cf.br ^bb113
        ^bb115:
          cf.br ^bb116
        ^bb116:
        %714 = llvm.load %681 : !llvm.ptr -> i64
        %715 = arith.constant 1 : i32
        %717 = arith.extsi %715 : i32 to i64
        %716 = arith.addi %714, %717 : i64
        llvm.store %716, %681 : i64, !llvm.ptr
        cf.br ^bb111
      ^bb113:
      %718 = llvm.load %673 : !llvm.ptr -> i64
      %719 = arith.constant 0 : i32
      %721 = arith.extsi %719 : i32 to i64
      %720 = arith.cmpi eq, %718, %721 : i64
      cf.cond_br %720, ^bb117, ^bb118
      ^bb117:
        %722 = llvm.load %612 : !llvm.ptr -> i64
        %723 = arith.constant 1 : i32
        %725 = arith.extsi %723 : i32 to i64
        %724 = arith.addi %722, %725 : i64
        llvm.store %724, %612 : i64, !llvm.ptr
        cf.br ^bb105
      ^bb118:
        cf.br ^bb119
      ^bb119:
      %726 = llvm.load %612 : !llvm.ptr -> i64
      %727 = llvm.mlir.constant(1 : i64) : i64
      %728 = llvm.alloca %727 x i64 : (i64) -> !llvm.ptr
      llvm.store %726, %728 : i64, !llvm.ptr
      %729 = llvm.load %673 : !llvm.ptr -> i64
      %730 = llvm.mlir.constant(1 : i64) : i64
      %731 = llvm.alloca %730 x i64 : (i64) -> !llvm.ptr
      llvm.store %729, %731 : i64, !llvm.ptr
      %732 = llvm.load %677 : !llvm.ptr -> i64
      %733 = llvm.mlir.constant(1 : i64) : i64
      %734 = llvm.alloca %733 x i64 : (i64) -> !llvm.ptr
      llvm.store %732, %734 : i64, !llvm.ptr
      cf.br ^bb120
      ^bb120:
      %735 = llvm.load %728 : !llvm.ptr -> i64
      %736 = llvm.mlir.addressof @LIMIT : !llvm.ptr
      %737 = llvm.load %736 : !llvm.ptr -> i64
      %738 = arith.cmpi sle, %735, %737 : i64
      cf.cond_br %738, ^bb121, ^bb122
      ^bb121:
        %739 = llvm.load %731 : !llvm.ptr -> i64
        %740 = llvm.load %734 : !llvm.ptr -> i64
        %742 = llvm.mlir.constant(1 : i64) : i64
        %743 = llvm.alloca %742 x i64 : (i64) -> !llvm.ptr
        llvm.store %739, %743 : i64, !llvm.ptr
        %744 = llvm.mlir.constant(1 : i64) : i64
        %745 = llvm.alloca %744 x i64 : (i64) -> !llvm.ptr
        llvm.store %740, %745 : i64, !llvm.ptr
        func.call @canonical(%743, %745) : (!llvm.ptr, !llvm.ptr) -> ()
        %746 = llvm.load %743 : !llvm.ptr -> i64
        %747 = llvm.load %728 : !llvm.ptr -> i64
        %748 = llvm.getelementptr %501[%747] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        llvm.store %746, %748 : i64, !llvm.ptr
        %749 = llvm.load %745 : !llvm.ptr -> i64
        %750 = llvm.load %728 : !llvm.ptr -> i64
        %751 = llvm.getelementptr %509[%750] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        llvm.store %749, %751 : i64, !llvm.ptr
        %752 = arith.constant 1 : i32
        %753 = llvm.load %728 : !llvm.ptr -> i64
        %754 = arith.trunci %752 : i32 to i8
        %755 = llvm.getelementptr %517[%753] : (!llvm.ptr, i64) -> !llvm.ptr, i8
        llvm.store %754, %755 : i8, !llvm.ptr
        %756 = arith.constant 2 : i32
        %757 = llvm.load %728 : !llvm.ptr -> i64
        %759 = arith.extsi %756 : i32 to i64
        %758 = arith.muli %759, %757 : i64
        %760 = llvm.mlir.addressof @LIMIT : !llvm.ptr
        %761 = llvm.load %760 : !llvm.ptr -> i64
        %762 = arith.cmpi sle, %758, %761 : i64
        cf.cond_br %762, ^bb123, ^bb124
        ^bb123:
          %763 = llvm.load %743 : !llvm.ptr -> i64
          %764 = llvm.load %745 : !llvm.ptr -> i64
          %765 = arith.subi %763, %764 : i64
          %766 = llvm.mlir.constant(1 : i64) : i64
          %767 = llvm.alloca %766 x i64 : (i64) -> !llvm.ptr
          llvm.store %765, %767 : i64, !llvm.ptr
          %768 = llvm.load %743 : !llvm.ptr -> i64
          %769 = llvm.load %745 : !llvm.ptr -> i64
          %770 = arith.addi %768, %769 : i64
          %771 = llvm.mlir.constant(1 : i64) : i64
          %772 = llvm.alloca %771 x i64 : (i64) -> !llvm.ptr
          llvm.store %770, %772 : i64, !llvm.ptr
          func.call @canonical(%767, %772) : (!llvm.ptr, !llvm.ptr) -> ()
          %774 = llvm.load %767 : !llvm.ptr -> i64
          %775 = llvm.getelementptr %501[%758] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          llvm.store %774, %775 : i64, !llvm.ptr
          %776 = llvm.load %772 : !llvm.ptr -> i64
          %777 = llvm.getelementptr %509[%758] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          llvm.store %776, %777 : i64, !llvm.ptr
          %778 = arith.constant 1 : i32
          %779 = arith.trunci %778 : i32 to i8
          %780 = llvm.getelementptr %517[%758] : (!llvm.ptr, i64) -> !llvm.ptr, i8
          llvm.store %779, %780 : i8, !llvm.ptr
          cf.br ^bb125
        ^bb124:
          cf.br ^bb125
        ^bb125:
        %781 = llvm.load %731 : !llvm.ptr -> i64
        %782 = llvm.load %673 : !llvm.ptr -> i64
        %783 = arith.muli %781, %782 : i64
        %784 = llvm.load %734 : !llvm.ptr -> i64
        %785 = llvm.load %677 : !llvm.ptr -> i64
        %786 = arith.muli %784, %785 : i64
        %787 = arith.subi %783, %786 : i64
        %788 = llvm.load %731 : !llvm.ptr -> i64
        %789 = llvm.load %677 : !llvm.ptr -> i64
        %790 = arith.muli %788, %789 : i64
        %791 = llvm.load %734 : !llvm.ptr -> i64
        %792 = llvm.load %673 : !llvm.ptr -> i64
        %793 = arith.muli %791, %792 : i64
        %794 = arith.addi %790, %793 : i64
        llvm.store %787, %731 : i64, !llvm.ptr
        llvm.store %794, %734 : i64, !llvm.ptr
        %795 = llvm.load %728 : !llvm.ptr -> i64
        %796 = llvm.load %612 : !llvm.ptr -> i64
        %797 = arith.muli %795, %796 : i64
        llvm.store %797, %728 : i64, !llvm.ptr
        cf.br ^bb120
      ^bb122:
      %798 = llvm.load %612 : !llvm.ptr -> i64
      %799 = arith.constant 1 : i32
      %801 = arith.extsi %799 : i32 to i64
      %800 = arith.addi %798, %801 : i64
      llvm.store %800, %612 : i64, !llvm.ptr
      cf.br ^bb105
    ^bb107:
    %803 = llvm.mlir.addressof @EDGE_HT_SIZE : !llvm.ptr
    %804 = llvm.load %803 : !llvm.ptr -> i64
    %805 = arith.constant 32 : i32
    %806 = arith.extsi %805 : i32 to i64
    %802 = func.call @calloc(%804, %806) : (i64, i64) -> !llvm.ptr
    %807 = arith.constant 0 : i32
    %808 = arith.extsi %807 : i32 to i64
    %809 = llvm.mlir.constant(1 : i64) : i64
    %810 = llvm.alloca %809 x i64 : (i64) -> !llvm.ptr
    llvm.store %808, %810 : i64, !llvm.ptr
    %811 = llvm.mlir.addressof @LIMIT : !llvm.ptr
    %812 = llvm.load %811 : !llvm.ptr -> i64
    %813 = llvm.mlir.constant(1 : i64) : i64
    %814 = llvm.alloca %813 x i64 : (i64) -> !llvm.ptr
    llvm.store %812, %814 : i64, !llvm.ptr
    cf.br ^bb126
    ^bb126:
    %815 = llvm.load %814 : !llvm.ptr -> i64
    %816 = arith.constant 2 : i32
    %818 = arith.extsi %816 : i32 to i64
    %817 = arith.cmpi sge, %815, %818 : i64
    cf.cond_br %817, ^bb127, ^bb128
    ^bb127:
      %820 = llvm.load %814 : !llvm.ptr -> i64
      %821 = llvm.getelementptr %517[%820] : (!llvm.ptr, i64) -> !llvm.ptr, i8
      %819 = llvm.load %821 : !llvm.ptr -> i8
      %822 = arith.constant 0 : i32
      %824 = arith.extsi %819 : i8 to i32
      %823 = arith.cmpi eq, %824, %822 : i32
      cf.cond_br %823, ^bb129, ^bb130
      ^bb129:
        %825 = llvm.load %814 : !llvm.ptr -> i64
        %826 = arith.constant 1 : i32
        %828 = arith.extsi %826 : i32 to i64
        %827 = arith.subi %825, %828 : i64
        llvm.store %827, %814 : i64, !llvm.ptr
        cf.br ^bb126
      ^bb130:
        cf.br ^bb131
      ^bb131:
      %830 = llvm.load %814 : !llvm.ptr -> i64
      %831 = llvm.getelementptr %501[%830] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %829 = llvm.load %831 : !llvm.ptr -> i64
      %833 = llvm.load %814 : !llvm.ptr -> i64
      %834 = llvm.getelementptr %509[%833] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %832 = llvm.load %834 : !llvm.ptr -> i64
      %836 = arith.constant 2 : i32
      %837 = arith.constant 8 : i32
      %838 = arith.extsi %836 : i32 to i64
      %839 = arith.extsi %837 : i32 to i64
      %835 = func.call @calloc(%838, %839) : (i64, i64) -> !llvm.ptr
      %841 = arith.constant 1 : i32
      %842 = arith.constant 4 : i32
      %843 = arith.extsi %841 : i32 to i64
      %844 = arith.extsi %842 : i32 to i64
      %840 = func.call @calloc(%843, %844) : (i64, i64) -> !llvm.ptr
      %846 = llvm.load %814 : !llvm.ptr -> i64
      func.call @parent_labels(%846, %829, %832, %501, %509, %517, %835, %840) : (i64, i64, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr) -> ()
      %848 = arith.constant 0 : i32
      %849 = arith.extsi %848 : i32 to i64
      %850 = llvm.getelementptr %840[%849] : (!llvm.ptr, i64) -> !llvm.ptr, i32
      %847 = llvm.load %850 : !llvm.ptr -> i32
      %851 = arith.constant 0 : i32
      %852 = arith.cmpi eq, %847, %851 : i32
      cf.cond_br %852, ^bb132, ^bb133
      ^bb132:
        func.call @free(%835) : (!llvm.ptr) -> ()
        func.call @free(%840) : (!llvm.ptr) -> ()
        %855 = llvm.load %814 : !llvm.ptr -> i64
        %856 = arith.constant 1 : i32
        %858 = arith.extsi %856 : i32 to i64
        %857 = arith.subi %855, %858 : i64
        llvm.store %857, %814 : i64, !llvm.ptr
        cf.br ^bb126
      ^bb133:
        cf.br ^bb134
      ^bb134:
      %859 = arith.constant 0 : i32
      %860 = llvm.mlir.constant(1 : i64) : i64
      %861 = llvm.alloca %860 x i32 : (i64) -> !llvm.ptr
      llvm.store %859, %861 : i32, !llvm.ptr
      cf.br ^bb135
      ^bb135:
      %862 = llvm.load %861 : !llvm.ptr -> i32
      %863 = arith.cmpi slt, %862, %847 : i32
      cf.cond_br %863, ^bb136, ^bb137
      ^bb136:
        %865 = llvm.load %861 : !llvm.ptr -> i32
        %866 = arith.extsi %865 : i32 to i64
        %867 = llvm.getelementptr %835[%866] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %864 = llvm.load %867 : !llvm.ptr -> i64
        %869 = llvm.load %814 : !llvm.ptr -> i64
        %868 = func.call @encode_edge(%869, %864) : (i64, i64) -> i64
        %870 = func.call @edge_find(%802, %868) : (!llvm.ptr, i64) -> i64
        %871 = arith.constant 0 : i32
        %872 = arith.extsi %871 : i32 to i64
        %873 = llvm.mlir.constant(1 : i64) : i64
        %874 = llvm.alloca %873 x i64 : (i64) -> !llvm.ptr
        llvm.store %872, %874 : i64, !llvm.ptr
        %875 = arith.constant 0 : i32
        %876 = arith.extsi %875 : i32 to i64
        %877 = llvm.mlir.constant(1 : i64) : i64
        %878 = llvm.alloca %877 x i64 : (i64) -> !llvm.ptr
        llvm.store %876, %878 : i64, !llvm.ptr
        %880 = llvm.getelementptr %802[%870] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64, i64, i64, i8)>
        %879 = llvm.load %880 : !llvm.ptr -> !llvm.struct<(i64, i64, i64, i8)>
        %881 = llvm.getelementptr %802[%870] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64, i64, i64, i8)>
        %882 = llvm.getelementptr %881[0, 3] : (!llvm.ptr) -> !llvm.ptr, !llvm.struct<(i64, i64, i64, i8)>
        %883 = llvm.load %882 : !llvm.ptr -> i8
        %884 = arith.constant 0 : i32
        %886 = arith.extsi %883 : i8 to i32
        %885 = arith.cmpi ne, %886, %884 : i32
        cf.cond_br %885, ^bb138, ^bb139
        ^bb138:
          %888 = llvm.getelementptr %802[%870] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64, i64, i64, i8)>
          %887 = llvm.load %888 : !llvm.ptr -> !llvm.struct<(i64, i64, i64, i8)>
          %889 = llvm.getelementptr %802[%870] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64, i64, i64, i8)>
          %890 = llvm.getelementptr %889[0, 1] : (!llvm.ptr) -> !llvm.ptr, !llvm.struct<(i64, i64, i64, i8)>
          %891 = llvm.load %890 : !llvm.ptr -> i64
          llvm.store %891, %874 : i64, !llvm.ptr
          %893 = llvm.getelementptr %802[%870] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64, i64, i64, i8)>
          %892 = llvm.load %893 : !llvm.ptr -> !llvm.struct<(i64, i64, i64, i8)>
          %894 = llvm.getelementptr %802[%870] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64, i64, i64, i8)>
          %895 = llvm.getelementptr %894[0, 2] : (!llvm.ptr) -> !llvm.ptr, !llvm.struct<(i64, i64, i64, i8)>
          %896 = llvm.load %895 : !llvm.ptr -> i64
          llvm.store %896, %878 : i64, !llvm.ptr
          cf.br ^bb140
        ^bb139:
          cf.br ^bb140
        ^bb140:
        %897 = llvm.load %810 : !llvm.ptr -> i64
        %898 = llvm.load %874 : !llvm.ptr -> i64
        %899 = llvm.load %814 : !llvm.ptr -> i64
        %900 = arith.addi %899, %864 : i64
        %901 = arith.muli %898, %900 : i64
        %902 = arith.addi %897, %901 : i64
        %903 = llvm.load %878 : !llvm.ptr -> i64
        %904 = arith.addi %902, %903 : i64
        llvm.store %904, %810 : i64, !llvm.ptr
        %906 = llvm.getelementptr %802[%870] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64, i64, i64, i8)>
        %905 = llvm.load %906 : !llvm.ptr -> !llvm.struct<(i64, i64, i64, i8)>
        %907 = llvm.getelementptr %802[%870] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64, i64, i64, i8)>
        %908 = llvm.getelementptr %907[0, 3] : (!llvm.ptr) -> !llvm.ptr, !llvm.struct<(i64, i64, i64, i8)>
        %909 = llvm.load %908 : !llvm.ptr -> i8
        %910 = arith.constant 0 : i32
        %912 = arith.extsi %909 : i8 to i32
        %911 = arith.cmpi eq, %912, %910 : i32
        cf.cond_br %911, ^bb141, ^bb142
        ^bb141:
          %913 = arith.constant 1 : i32
          %914 = llvm.getelementptr %802[%870] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64, i64, i64, i8)>
          %915 = arith.trunci %913 : i32 to i8
          %916 = llvm.getelementptr %914[0, 3] : (!llvm.ptr) -> !llvm.ptr, !llvm.struct<(i64, i64, i64, i8)>
          llvm.store %915, %916 : i8, !llvm.ptr
          %917 = llvm.getelementptr %802[%870] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64, i64, i64, i8)>
          %918 = llvm.getelementptr %917[0, 0] : (!llvm.ptr) -> !llvm.ptr, !llvm.struct<(i64, i64, i64, i8)>
          llvm.store %868, %918 : i64, !llvm.ptr
          cf.br ^bb143
        ^bb142:
          cf.br ^bb143
        ^bb143:
        %919 = llvm.load %874 : !llvm.ptr -> i64
        %920 = arith.constant 1 : i32
        %922 = arith.extsi %920 : i32 to i64
        %921 = arith.addi %919, %922 : i64
        %923 = llvm.getelementptr %802[%870] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64, i64, i64, i8)>
        %924 = llvm.getelementptr %923[0, 1] : (!llvm.ptr) -> !llvm.ptr, !llvm.struct<(i64, i64, i64, i8)>
        llvm.store %921, %924 : i64, !llvm.ptr
        %925 = llvm.load %878 : !llvm.ptr -> i64
        %926 = llvm.getelementptr %802[%870] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64, i64, i64, i8)>
        %927 = llvm.getelementptr %926[0, 2] : (!llvm.ptr) -> !llvm.ptr, !llvm.struct<(i64, i64, i64, i8)>
        llvm.store %925, %927 : i64, !llvm.ptr
        %928 = llvm.load %861 : !llvm.ptr -> i32
        %929 = arith.constant 1 : i32
        %930 = arith.addi %928, %929 : i32
        llvm.store %930, %861 : i32, !llvm.ptr
        cf.br ^bb135
      ^bb137:
      %931 = arith.constant 2 : i32
      %932 = arith.cmpi eq, %847, %931 : i32
      cf.cond_br %932, ^bb144, ^bb145
      ^bb144:
        %934 = arith.constant 0 : i32
        %935 = arith.extsi %934 : i32 to i64
        %936 = llvm.getelementptr %835[%935] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %933 = llvm.load %936 : !llvm.ptr -> i64
        %938 = arith.constant 1 : i32
        %939 = arith.extsi %938 : i32 to i64
        %940 = llvm.getelementptr %835[%939] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %937 = llvm.load %940 : !llvm.ptr -> i64
        %942 = llvm.load %814 : !llvm.ptr -> i64
        %941 = func.call @encode_edge(%942, %933) : (i64, i64) -> i64
        %944 = llvm.load %814 : !llvm.ptr -> i64
        %943 = func.call @encode_edge(%944, %937) : (i64, i64) -> i64
        %945 = func.call @edge_lookup(%802, %941) : (!llvm.ptr, i64) -> i64
        %946 = func.call @edge_lookup(%802, %943) : (!llvm.ptr, i64) -> i64
        %947 = arith.constant 0 : i32
        %949 = arith.extsi %947 : i32 to i64
        %948 = arith.cmpi slt, %945, %949 : i64
        %950 = scf.if %948 -> (i1) {
          %951 = arith.constant true
          scf.yield %951 : i1
        } else {
          %952 = arith.constant 0 : i32
          %954 = arith.extsi %952 : i32 to i64
          %953 = arith.cmpi slt, %946, %954 : i64
          scf.yield %953 : i1
        }
        cf.cond_br %950, ^bb147, ^bb148
        ^bb147:
          func.call @free(%835) : (!llvm.ptr) -> ()
          func.call @free(%840) : (!llvm.ptr) -> ()
          %957 = llvm.load %814 : !llvm.ptr -> i64
          %958 = arith.constant 1 : i32
          %960 = arith.extsi %958 : i32 to i64
          %959 = arith.subi %957, %960 : i64
          llvm.store %959, %814 : i64, !llvm.ptr
          cf.br ^bb126
        ^bb148:
          cf.br ^bb149
        ^bb149:
        %962 = llvm.getelementptr %802[%945] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64, i64, i64, i8)>
        %961 = llvm.load %962 : !llvm.ptr -> !llvm.struct<(i64, i64, i64, i8)>
        %963 = llvm.getelementptr %802[%945] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64, i64, i64, i8)>
        %964 = llvm.getelementptr %963[0, 1] : (!llvm.ptr) -> !llvm.ptr, !llvm.struct<(i64, i64, i64, i8)>
        %965 = llvm.load %964 : !llvm.ptr -> i64
        %967 = llvm.getelementptr %802[%945] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64, i64, i64, i8)>
        %966 = llvm.load %967 : !llvm.ptr -> !llvm.struct<(i64, i64, i64, i8)>
        %968 = llvm.getelementptr %802[%945] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64, i64, i64, i8)>
        %969 = llvm.getelementptr %968[0, 2] : (!llvm.ptr) -> !llvm.ptr, !llvm.struct<(i64, i64, i64, i8)>
        %970 = llvm.load %969 : !llvm.ptr -> i64
        %972 = llvm.getelementptr %802[%946] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64, i64, i64, i8)>
        %971 = llvm.load %972 : !llvm.ptr -> !llvm.struct<(i64, i64, i64, i8)>
        %973 = llvm.getelementptr %802[%946] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64, i64, i64, i8)>
        %974 = llvm.getelementptr %973[0, 1] : (!llvm.ptr) -> !llvm.ptr, !llvm.struct<(i64, i64, i64, i8)>
        %975 = llvm.load %974 : !llvm.ptr -> i64
        %977 = llvm.getelementptr %802[%946] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64, i64, i64, i8)>
        %976 = llvm.load %977 : !llvm.ptr -> !llvm.struct<(i64, i64, i64, i8)>
        %978 = llvm.getelementptr %802[%946] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64, i64, i64, i8)>
        %979 = llvm.getelementptr %978[0, 2] : (!llvm.ptr) -> !llvm.ptr, !llvm.struct<(i64, i64, i64, i8)>
        %980 = llvm.load %979 : !llvm.ptr -> i64
        %981 = arith.muli %965, %975 : i64
        %982 = llvm.load %814 : !llvm.ptr -> i64
        %983 = arith.muli %981, %982 : i64
        %984 = arith.muli %965, %980 : i64
        %985 = arith.addi %983, %984 : i64
        %986 = arith.muli %975, %970 : i64
        %987 = arith.addi %985, %986 : i64
        %988 = func.call @encode_edge(%933, %937) : (i64, i64) -> i64
        %989 = func.call @edge_find(%802, %988) : (!llvm.ptr, i64) -> i64
        %990 = arith.constant 0 : i32
        %991 = arith.extsi %990 : i32 to i64
        %992 = llvm.mlir.constant(1 : i64) : i64
        %993 = llvm.alloca %992 x i64 : (i64) -> !llvm.ptr
        llvm.store %991, %993 : i64, !llvm.ptr
        %994 = arith.constant 0 : i32
        %995 = arith.extsi %994 : i32 to i64
        %996 = llvm.mlir.constant(1 : i64) : i64
        %997 = llvm.alloca %996 x i64 : (i64) -> !llvm.ptr
        llvm.store %995, %997 : i64, !llvm.ptr
        %999 = llvm.getelementptr %802[%989] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64, i64, i64, i8)>
        %998 = llvm.load %999 : !llvm.ptr -> !llvm.struct<(i64, i64, i64, i8)>
        %1000 = llvm.getelementptr %802[%989] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64, i64, i64, i8)>
        %1001 = llvm.getelementptr %1000[0, 3] : (!llvm.ptr) -> !llvm.ptr, !llvm.struct<(i64, i64, i64, i8)>
        %1002 = llvm.load %1001 : !llvm.ptr -> i8
        %1003 = arith.constant 0 : i32
        %1005 = arith.extsi %1002 : i8 to i32
        %1004 = arith.cmpi ne, %1005, %1003 : i32
        cf.cond_br %1004, ^bb150, ^bb151
        ^bb150:
          %1007 = llvm.getelementptr %802[%989] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64, i64, i64, i8)>
          %1006 = llvm.load %1007 : !llvm.ptr -> !llvm.struct<(i64, i64, i64, i8)>
          %1008 = llvm.getelementptr %802[%989] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64, i64, i64, i8)>
          %1009 = llvm.getelementptr %1008[0, 1] : (!llvm.ptr) -> !llvm.ptr, !llvm.struct<(i64, i64, i64, i8)>
          %1010 = llvm.load %1009 : !llvm.ptr -> i64
          llvm.store %1010, %993 : i64, !llvm.ptr
          %1012 = llvm.getelementptr %802[%989] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64, i64, i64, i8)>
          %1011 = llvm.load %1012 : !llvm.ptr -> !llvm.struct<(i64, i64, i64, i8)>
          %1013 = llvm.getelementptr %802[%989] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64, i64, i64, i8)>
          %1014 = llvm.getelementptr %1013[0, 2] : (!llvm.ptr) -> !llvm.ptr, !llvm.struct<(i64, i64, i64, i8)>
          %1015 = llvm.load %1014 : !llvm.ptr -> i64
          llvm.store %1015, %997 : i64, !llvm.ptr
          cf.br ^bb152
        ^bb151:
          cf.br ^bb152
        ^bb152:
        %1017 = llvm.getelementptr %802[%989] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64, i64, i64, i8)>
        %1016 = llvm.load %1017 : !llvm.ptr -> !llvm.struct<(i64, i64, i64, i8)>
        %1018 = llvm.getelementptr %802[%989] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64, i64, i64, i8)>
        %1019 = llvm.getelementptr %1018[0, 3] : (!llvm.ptr) -> !llvm.ptr, !llvm.struct<(i64, i64, i64, i8)>
        %1020 = llvm.load %1019 : !llvm.ptr -> i8
        %1021 = arith.constant 0 : i32
        %1023 = arith.extsi %1020 : i8 to i32
        %1022 = arith.cmpi eq, %1023, %1021 : i32
        cf.cond_br %1022, ^bb153, ^bb154
        ^bb153:
          %1024 = arith.constant 1 : i32
          %1025 = llvm.getelementptr %802[%989] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64, i64, i64, i8)>
          %1026 = arith.trunci %1024 : i32 to i8
          %1027 = llvm.getelementptr %1025[0, 3] : (!llvm.ptr) -> !llvm.ptr, !llvm.struct<(i64, i64, i64, i8)>
          llvm.store %1026, %1027 : i8, !llvm.ptr
          %1028 = llvm.getelementptr %802[%989] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64, i64, i64, i8)>
          %1029 = llvm.getelementptr %1028[0, 0] : (!llvm.ptr) -> !llvm.ptr, !llvm.struct<(i64, i64, i64, i8)>
          llvm.store %988, %1029 : i64, !llvm.ptr
          cf.br ^bb155
        ^bb154:
          cf.br ^bb155
        ^bb155:
        %1030 = llvm.load %993 : !llvm.ptr -> i64
        %1031 = arith.addi %1030, %981 : i64
        %1032 = llvm.getelementptr %802[%989] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64, i64, i64, i8)>
        %1033 = llvm.getelementptr %1032[0, 1] : (!llvm.ptr) -> !llvm.ptr, !llvm.struct<(i64, i64, i64, i8)>
        llvm.store %1031, %1033 : i64, !llvm.ptr
        %1034 = llvm.load %997 : !llvm.ptr -> i64
        %1035 = arith.addi %1034, %987 : i64
        %1036 = llvm.getelementptr %802[%989] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i64, i64, i64, i8)>
        %1037 = llvm.getelementptr %1036[0, 2] : (!llvm.ptr) -> !llvm.ptr, !llvm.struct<(i64, i64, i64, i8)>
        llvm.store %1035, %1037 : i64, !llvm.ptr
        cf.br ^bb146
      ^bb145:
        cf.br ^bb146
      ^bb146:
      func.call @free(%835) : (!llvm.ptr) -> ()
      func.call @free(%840) : (!llvm.ptr) -> ()
      %1040 = llvm.load %814 : !llvm.ptr -> i64
      %1041 = arith.constant 1 : i32
      %1043 = arith.extsi %1041 : i32 to i64
      %1042 = arith.subi %1040, %1043 : i64
      llvm.store %1042, %814 : i64, !llvm.ptr
      cf.br ^bb126
    ^bb128:
    %1044 = llvm.mlir.addressof @str_0 : !llvm.ptr
    %1045 = llvm.load %810 : !llvm.ptr -> i64
    %1046 = llvm.call @printf(%1044, %1045) vararg(!llvm.func<i32 (ptr, ...)>) : (!llvm.ptr, i64) -> i32
    func.call @free(%501) : (!llvm.ptr) -> ()
    func.call @free(%509) : (!llvm.ptr) -> ()
    func.call @free(%517) : (!llvm.ptr) -> ()
    func.call @free(%525) : (!llvm.ptr) -> ()
    func.call @free(%533) : (!llvm.ptr) -> ()
    func.call @free(%802) : (!llvm.ptr) -> ()
    %1053 = arith.constant 0 : i32
    func.return %1053 : i32
  }
}