Problem 842

Irregular Star Polygons - sum T(n) mod 1e9+7 for n=3..60.

Answer885226002
Output885226002
StatusPASS
Native helperno
Runtime130 ms
Peak memory36560 KB
Time complexityO(n^4) (estimated)
Space complexityO(n^2) (estimated)

Performance comparison

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

Flow source

# Project Euler 842
# Irregular Star Polygons - sum T(n) mod 1e9+7 for n=3..60.

extern {
    function calloc(n: i64, size: i64) -> ptr<void>
    function free(p: ptr<void>) -> void
    function memset(p: ptr<void>, c: i32, n: i64) -> ptr<void>
    function cos(x: f64) -> f64
    function sin(x: f64) -> f64
    function fabs(x: f64) -> f64
    function floor(x: f64) -> f64
    function llround(x: f64) -> i64
}

const MOD: i64 = 1000000007
const SCALE: i64 = 100000000000
const HASH_SIZE: i64 = 1048576
const HASH_MASK: i64 = 1048575
const MAX_POINTS: i64 = 600000
const MAX_REPS: i64 = 600000

let mut fact_mod: ptr<i64> = null
let mut inv_fact_mod: ptr<i64> = null

let mut pts_qx: ptr<i64> = null
let mut pts_qy: ptr<i64> = null
let mut pts_count: ptr<i32> = null
let mut num_points: i64 = 0
let mut hash_buckets: ptr<i32> = null
let mut hash_next: ptr<i32> = null

let mut reps_x: ptr<f64> = null
let mut reps_y: ptr<f64> = null
let mut reps_cnt: ptr<i32> = null
let mut num_reps: i64 = 0
let mut grid_buckets: ptr<i32> = null
let mut grid_next: ptr<i32> = null

function modpow(b0: i64, e0: i64, m0: i64) -> i64 {
    let mut r: i64 = 1
    let mut b: i64 = b0 % m0
    let mut e: i64 = e0
    while e > 0 {
        if (e & 1) != 0 {
            r = ((r as i128) * (b as i128) % (m0 as i128)) as i64
        }
        b = ((b as i128) * (b as i128) % (m0 as i128)) as i64
        e = e >> 1
    }
    return r
}

function modinv(a: i64, m: i64) -> i64 {
    return modpow(a, m - 2, m)
}

function init_factorials() -> void {
    fact_mod = calloc(61, 8)
    inv_fact_mod = calloc(61, 8)
    fact_mod[0] = 1
    let mut i: i64 = 1
    while i <= 60 {
        fact_mod[i] = (fact_mod[i - 1] * i) % MOD
        i = i + 1
    }
    i = 0
    while i <= 60 {
        inv_fact_mod[i] = modinv(fact_mod[i], MOD)
        i = i + 1
    }
}

function comb_mod(n: i64, k: i64) -> i64 {
    if k < 0 || k > n {
        return 0
    }
    return (fact_mod[n] * inv_fact_mod[k] % MOD * inv_fact_mod[n - k] % MOD) as i64
}

function cycles_at_least_two_edges(n: i64, m: i64) -> i64 {
    if m < 2 {
        return 0
    }
    let inv2: i64 = modinv(2, MOD)
    let total: i64 = fact_mod[n - 1] * inv2 % MOD
    let mut c0: i64 = 0
    let mut k: i64 = 0
    while k <= m {
        let ak: i64 = 0
        if k == 0 {
            ak = total
        } else {
            ak = modpow(2, k - 1, MOD) * fact_mod[n - k - 1] % MOD
        }
        let term: i64 = comb_mod(m, k) * ak % MOD
        if k % 2 == 0 {
            c0 = (c0 + term) % MOD
        } else {
            c0 = (c0 - term % MOD + MOD) % MOD
        }
        k = k + 1
    }
    let mut c1: i64 = 0
    k = 1
    while k <= m {
        let ak: i64 = modpow(2, k - 1, MOD) * fact_mod[n - k - 1] % MOD
        let term: i64 = (k * comb_mod(m, k) % MOD) * ak % MOD
        if (k - 1) % 2 == 0 {
            c1 = (c1 + term) % MOD
        } else {
            c1 = (c1 - term % MOD + MOD) % MOD
        }
        k = k + 1
    }
    return (total - c0 - c1 % MOD + 2 * MOD) % MOD
}

function isqrt_ll(n: i64) -> i64 {
    if n < 0 {
        return -1
    }
    if n == 0 {
        return 0
    }
    let mut x: i64 = 0
    # Newton's method
    let mut bit: i64 = 1
    while bit <= n {
        bit = bit << 2
    }
    bit = bit >> 2
    while bit != 0 {
        if n >= x + bit {
            n = n - (x + bit)
            x = (x >> 1) + bit
        } else {
            x = x >> 1
        }
        bit = bit >> 2
    }
    return x
}

function inv_triangular(q: i64) -> i64 {
    let disc: i64 = 1 + 8 * q
    let r: i64 = isqrt_ll(disc)
    if r * r != disc {
        return -1
    }
    if (1 + r) % 2 != 0 {
        return -1
    }
    return (1 + r) / 2
}

function hash_key(qx: i64, qy: i64) -> i64 {
    let h: i64 = qx * 1000000007 + qy
    # mix high bits down
    let hi: i64 = (h as i64) >> 32
    let lo: i64 = h & 0xFFFFFFFF
    let mixed: i64 = (lo ^ hi) & HASH_MASK
    return mixed
}

function find_point(qx: i64, qy: i64) -> i64 {
    let h: i64 = hash_key(qx, qy)
    let mut idx: i64 = hash_buckets[h] as i64
    while idx != -1 {
        if pts_qx[idx] == qx && pts_qy[idx] == qy {
            return idx
        }
        idx = hash_next[idx] as i64
    }
    return -1
}

function add_point_fast(qx: i64, qy: i64) -> void {
    let idx: i64 = find_point(qx, qy)
    if idx >= 0 {
        pts_count[idx] = pts_count[idx] + 1
        return
    }
    idx = num_points
    num_points = num_points + 1
    pts_qx[idx] = qx
    pts_qy[idx] = qy
    pts_count[idx] = 1
    let h: i64 = hash_key(qx, qy)
    hash_next[idx] = hash_buckets[h]
    hash_buckets[h] = idx as i32
}

function grid_key(x: f64, y: f64) -> i64 {
    let ix: i64 = floor(x / 0.000001) as i64
    let iy: i64 = floor(y / 0.000001) as i64
    let h: i64 = ix * 1000000007 + iy
    let hi: i64 = (h as i64) >> 32
    let lo: i64 = h & 0xFFFFFFFF
    return (lo ^ hi) & HASH_MASK
}

function add_point_slow(x: f64, y: f64) -> void {
    let ix: i64 = floor(x / 0.000001) as i64
    let iy: i64 = floor(y / 0.000001) as i64
    let mut dx: i64 = -1
    while dx <= 1 {
        let mut dy: i64 = -1
        while dy <= 1 {
            let cx: i64 = ix + dx
            let cy: i64 = iy + dy
            let h2: i64 = cx * 1000000007 + cy
            let hi: i64 = (h2 as i64) >> 32
            let lo: i64 = h2 & 0xFFFFFFFF
            let h: i64 = (lo ^ hi) & HASH_MASK
            let mut idx: i64 = grid_buckets[h] as i64
            while idx != -1 {
                let ddx: f64 = x - reps_x[idx]
                let ddy: f64 = y - reps_y[idx]
                if ddx * ddx + ddy * ddy <= 1e-18 {
                    reps_cnt[idx] = reps_cnt[idx] + 1
                    return
                }
                idx = grid_next[idx] as i64
            }
            dy = dy + 1
        }
        dx = dx + 1
    }
    let idx: i64 = num_reps
    num_reps = num_reps + 1
    reps_x[idx] = x
    reps_y[idx] = y
    reps_cnt[idx] = 1
    let h: i64 = grid_key(x, y)
    grid_next[idx] = grid_buckets[h]
    grid_buckets[h] = idx as i32
}

function compute_points_fast(n: i64, xs: ptr<f64>, ys: ptr<f64>) -> i32 {
    num_points = 0
    let mut i: i64 = 0
    while i < HASH_SIZE {
        hash_buckets[i] = -1
        i = i + 1
    }
    let mut a: i64 = 0
    while a < n - 3 {
        let x1: f64 = xs[a]
        let y1: f64 = ys[a]
        let mut b: i64 = a + 1
        while b < n - 2 {
            let x3: f64 = xs[b]
            let y3: f64 = ys[b]
            let abx: f64 = x3 - x1
            let aby: f64 = y3 - y1
            let mut c: i64 = b + 1
            while c < n - 1 {
                let x2: f64 = xs[c]
                let y2: f64 = ys[c]
                let dx12: f64 = x2 - x1
                let dy12: f64 = y2 - y1
                let mut d: i64 = c + 1
                while d < n {
                    let x4: f64 = xs[d]
                    let y4: f64 = ys[d]
                    let dx34: f64 = x4 - x3
                    let dy34: f64 = y4 - y3
                    let denom: f64 = dx12 * dy34 - dy12 * dx34
                    if fabs(denom) < 1e-18 {
                        d = d + 1
                        continue
                    }
                    let t: f64 = (abx * dy34 - aby * dx34) / denom
                    let px: f64 = x1 + t * dx12
                    let py: f64 = y1 + t * dy12
                    let qx: i64 = llround(px * (SCALE as f64))
                    let qy: i64 = llround(py * (SCALE as f64))
                    add_point_fast(qx, qy)
                    d = d + 1
                }
                c = c + 1
            }
            b = b + 1
        }
        a = a + 1
    }
    i = 0
    while i < num_points {
        if inv_triangular(pts_count[i] as i64) < 0 {
            return 0
        }
        i = i + 1
    }
    return 1
}

function compute_points_slow(n: i64, xs: ptr<f64>, ys: ptr<f64>) -> void {
    num_reps = 0
    let mut i: i64 = 0
    while i < HASH_SIZE {
        grid_buckets[i] = -1
        i = i + 1
    }
    let mut a: i64 = 0
    while a < n - 3 {
        let x1: f64 = xs[a]
        let y1: f64 = ys[a]
        let mut b: i64 = a + 1
        while b < n - 2 {
            let x3: f64 = xs[b]
            let y3: f64 = ys[b]
            let abx: f64 = x3 - x1
            let aby: f64 = y3 - y1
            let mut c: i64 = b + 1
            while c < n - 1 {
                let x2: f64 = xs[c]
                let y2: f64 = ys[c]
                let dx12: f64 = x2 - x1
                let dy12: f64 = y2 - y1
                let mut d: i64 = c + 1
                while d < n {
                    let x4: f64 = xs[d]
                    let y4: f64 = ys[d]
                    let dx34: f64 = x4 - x3
                    let dy34: f64 = y4 - y3
                    let denom: f64 = dx12 * dy34 - dy12 * dx34
                    if fabs(denom) < 1e-18 {
                        d = d + 1
                        continue
                    }
                    let t: f64 = (abx * dy34 - aby * dx34) / denom
                    let px: f64 = x1 + t * dx12
                    let py: f64 = y1 + t * dy12
                    add_point_slow(px, py)
                    d = d + 1
                }
                c = c + 1
            }
            b = b + 1
        }
        a = a + 1
    }
}

function T_mod(n: i64) -> i64 {
    if n < 4 {
        return 0
    }
    let tau: f64 = 2.0 * 3.14159265358979323846
    let xs: ptr<f64> = calloc(60, 8)
    let ys: ptr<f64> = calloc(60, 8)
    let mut k: i64 = 0
    while k < n {
        xs[k] = cos(tau * (k as f64) / (n as f64))
        ys[k] = sin(tau * (k as f64) / (n as f64))
        k = k + 1
    }
    let dist_m: ptr<i64> = calloc(100, 8)
    let dist_cnt: ptr<i64> = calloc(100, 8)
    let mut dist_size: i64 = 0
    let fast: i32 = compute_points_fast(n, xs, ys)
    if fast != 0 {
        let mut i: i64 = 0
        while i < num_points {
            let m: i64 = inv_triangular(pts_count[i] as i64)
            let mut found: i64 = -1
            let mut j: i64 = 0
            while j < dist_size {
                if dist_m[j] == m {
                    found = j
                    break
                }
                j = j + 1
            }
            if found < 0 {
                dist_m[dist_size] = m
                dist_cnt[dist_size] = 1
                dist_size = dist_size + 1
            } else {
                dist_cnt[found] = dist_cnt[found] + 1
            }
            i = i + 1
        }
    } else {
        compute_points_slow(n, xs, ys)
        let mut i: i64 = 0
        while i < num_reps {
            let m: i64 = inv_triangular(reps_cnt[i] as i64)
            if m < 0 {
                i = i + 1
                continue
            }
            let mut found: i64 = -1
            let mut j: i64 = 0
            while j < dist_size {
                if dist_m[j] == m {
                    found = j
                    break
                }
                j = j + 1
            }
            if found < 0 {
                dist_m[dist_size] = m
                dist_cnt[dist_size] = 1
                dist_size = dist_size + 1
            } else {
                dist_cnt[found] = dist_cnt[found] + 1
            }
            i = i + 1
        }
    }
    let mut total: i64 = 0
    let mut i: i64 = 0
    while i < dist_size {
        let g: i64 = cycles_at_least_two_edges(n, dist_m[i])
        total = (total + dist_cnt[i] * g) % MOD
        i = i + 1
    }
    free(xs)
    free(ys)
    free(dist_m)
    free(dist_cnt)
    return total
}

function main() -> i32 {
    init_factorials()
    pts_qx = calloc(MAX_POINTS, 8)
    pts_qy = calloc(MAX_POINTS, 8)
    pts_count = calloc(MAX_POINTS, 4)
    hash_buckets = calloc(HASH_SIZE, 4)
    hash_next = calloc(MAX_POINTS, 4)
    reps_x = calloc(MAX_REPS, 8)
    reps_y = calloc(MAX_REPS, 8)
    reps_cnt = calloc(MAX_REPS, 4)
    grid_buckets = calloc(HASH_SIZE, 4)
    grid_next = calloc(MAX_REPS, 4)
    let mut ans: i64 = 0
    let mut n: i64 = 3
    while n <= 60 {
        ans = (ans + T_mod(n)) % MOD
        n = n + 1
    }
    printf("%lld\n", ans)
    return 0
}

Generated C

#include <stdint.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

/* Flow runtime helpers */
typedef struct flow_temp_node { struct flow_temp_node* next; } flow_temp_node;
static flow_temp_node* flow_temp_head = NULL;
static int flow_temp_atexit_set = 0;
__attribute__((unused)) static void flow_temp_free_all(void) {
    while (flow_temp_head) {
        flow_temp_node* n = flow_temp_head;
        flow_temp_head = n->next;
        free(n);
    }
}
__attribute__((unused)) static void* flow_temp_alloc(size_t nbytes) {
    flow_temp_node* node = (flow_temp_node*)malloc(sizeof(flow_temp_node) + nbytes);
    if (!node) return NULL;
    node->next = flow_temp_head;
    flow_temp_head = node;
    if (!flow_temp_atexit_set) {
        flow_temp_atexit_set = 1;
        atexit(flow_temp_free_all);
    }
    return (void*)(node + 1);
}
#ifndef FLOW_DIAG
#define FLOW_DIAG(msg) fprintf(stderr, "%s", (msg))
#endif
#ifndef FLOW_LOG
#define FLOW_LOG(fmt, ...) printf(fmt, __VA_ARGS__)
#endif
#ifndef FLOW_LOG_EMPTY
#define FLOW_LOG_EMPTY(fmt) printf(fmt)
#endif
static char* flow_strcat(const char* a, const char* b) {
    size_t la = strlen(a ? a : ""), lb = strlen(b ? b : "");
    char* r = (char*)flow_temp_alloc(la + lb + 1);
    if (!r) return NULL;
    if (la) memcpy(r, a, la);
    if (lb) memcpy(r + la, b, lb);
    r[la + lb] = '\0';
    return r;
}

#define __flow_in_arr(arr, val) __extension__ ({ \
    int _found = 0; \
    size_t _n = sizeof(arr)/sizeof((arr)[0]); \
    for (size_t _i = 0; _i < _n; _i++) { \
        if ((arr)[_i] == (val)) { _found = 1; break; } \
    } _found; })

/* Unified fault handler (MISRA #279) — override with -DFLOW_FAULT_HANDLER=fn */
#ifndef FLOW_FAULT_HANDLER
__attribute__((unused)) static inline void flow_fault_handler(const char* msg) {
    fprintf(stderr, "flow: %s\n", msg ? msg : "fault");
    abort();
#if defined(__GNUC__) || defined(__clang__)
    __builtin_unreachable();
#endif
}
#else
#define flow_fault_handler FLOW_FAULT_HANDLER
#endif
#define flow_div_by_zero_handler() flow_fault_handler("division by zero")
#define flow_shift_ub_handler() flow_fault_handler("invalid shift (amount out of range or left-shift of negative)")

#ifndef FLOW_CHECKED_DIV
#define FLOW_CHECKED_DIV(L, R) (((R) != 0) ? ((L) / (R)) : (flow_div_by_zero_handler(), (L) * 0))
#endif
#ifndef FLOW_CHECKED_MOD
#define FLOW_CHECKED_MOD(L, R) (((R) != 0) ? ((L) % (R)) : (flow_div_by_zero_handler(), (L) * 0))
#endif
#ifndef FLOW_CHECKED_SHL
#define FLOW_CHECKED_SHL(L, R) ((((R) >= 0) && ((unsigned long long)(R) < (sizeof(L) * 8ull)) && ((L) >= 0)) ? ((L) << (R)) : (flow_shift_ub_handler(), (L) * 0))
#endif
#ifndef FLOW_CHECKED_SHR
#define FLOW_CHECKED_SHR(L, R) ((((R) >= 0) && ((unsigned long long)(R) < (sizeof(L) * 8ull))) ? ((L) >> (R)) : (flow_shift_ub_handler(), (L) * 0))
#endif

#include <math.h>

void* _ui_state = NULL;

static inline float i32_to_f32(int32_t v) { return (float)v; }

/* Host stub for @gpu kernels (device codegen replaces this). */
static inline int32_t gpu_thread_id(void) { return 0; }

int64_t llround(double x);
int64_t modpow_i64_i64_i64(int64_t b0, int64_t e0, int64_t m0);
int64_t modinv_i64_i64(int64_t a, int64_t m);
void init_factorials(void);
int64_t comb_mod_i64_i64(int64_t n, int64_t k);
int64_t cycles_at_least_two_edges_i64_i64(int64_t n, int64_t m);
int64_t isqrt_ll_i64(int64_t n);
int64_t inv_triangular_i64(int64_t q);
int64_t hash_key_i64_i64(int64_t qx, int64_t qy);
int64_t find_point_i64_i64(int64_t qx, int64_t qy);
void add_point_fast_i64_i64(int64_t qx, int64_t qy);
int64_t grid_key_f64_f64(double x, double y);
void add_point_slow_f64_f64(double x, double y);
int32_t compute_points_fast_i64_ptr_f64_ptr_f64(int64_t n, double* xs, double* ys);
void compute_points_slow_i64_ptr_f64_ptr_f64(int64_t n, double* xs, double* ys);
int64_t T_mod_i64(int64_t n);
int32_t main(void);

static const int64_t MOD = 1000000007;
static const int64_t SCALE = 100000000000;
static const int64_t HASH_SIZE = 1048576;
static const int64_t HASH_MASK = 1048575;
static const int64_t MAX_POINTS = 600000;
static const int64_t MAX_REPS = 600000;

/* Module statics */
static int64_t* fact_mod = NULL;
static int64_t* inv_fact_mod = NULL;
static int64_t* pts_qx = NULL;
static int64_t* pts_qy = NULL;
static int32_t* pts_count = NULL;
static int64_t num_points = 0;
static int32_t* hash_buckets = NULL;
static int32_t* hash_next = NULL;
static double* reps_x = NULL;
static double* reps_y = NULL;
static int32_t* reps_cnt = NULL;
static int64_t num_reps = 0;
static int32_t* grid_buckets = NULL;
static int32_t* grid_next = NULL;









int64_t modpow_i64_i64_i64(int64_t b0, int64_t e0, int64_t m0) {
    int64_t r = 1;
    int64_t b = FLOW_CHECKED_MOD((b0), (m0));
    int64_t e = e0;
    while (e > 0) {
        if ((e & 1) != 0) {
            r = ((int64_t)(FLOW_CHECKED_MOD(((((__int128)(r)) * ((__int128)(b)))), (((__int128)(m0))))));
        }
        b = ((int64_t)(FLOW_CHECKED_MOD(((((__int128)(b)) * ((__int128)(b)))), (((__int128)(m0))))));
        e = FLOW_CHECKED_SHR((e), (1));
    }
    return r;
}

int64_t modinv_i64_i64(int64_t a, int64_t m) {
    return modpow_i64_i64_i64(a, (m - 2), m);
}

void init_factorials(void) {
    fact_mod = calloc(61, 8);
    inv_fact_mod = calloc(61, 8);
    fact_mod[0] = 1;
    int64_t i = 1;
    while (i <= 60) {
        fact_mod[i] = FLOW_CHECKED_MOD(((fact_mod[(i - 1)] * i)), (MOD));
        i = (i + 1);
    }
    i = 0;
    while (i <= 60) {
        inv_fact_mod[i] = modinv_i64_i64(fact_mod[i], MOD);
        i = (i + 1);
    }
}

int64_t comb_mod_i64_i64(int64_t n, int64_t k) {
    if ((k < 0 || k > n)) {
        return 0;
    }
    return ((int64_t)(FLOW_CHECKED_MOD(((FLOW_CHECKED_MOD(((fact_mod[n] * inv_fact_mod[k])), (MOD)) * inv_fact_mod[(n - k)])), (MOD))));
}

int64_t cycles_at_least_two_edges_i64_i64(int64_t n, int64_t m) {
    if (m < 2) {
        return 0;
    }
    int64_t inv2 = modinv_i64_i64(2, MOD);
    int64_t total = FLOW_CHECKED_MOD(((fact_mod[(n - 1)] * inv2)), (MOD));
    int64_t c0 = 0;
    int64_t k = 0;
    while (k <= m) {
        int64_t ak = 0;
        if (k == 0) {
            ak = total;
        } else {
            ak = FLOW_CHECKED_MOD(((modpow_i64_i64_i64(2, (k - 1), MOD) * fact_mod[((n - k) - 1)])), (MOD));
        }
        int64_t term = FLOW_CHECKED_MOD(((comb_mod_i64_i64(m, k) * ak)), (MOD));
        if (FLOW_CHECKED_MOD((k), (2)) == 0) {
            c0 = FLOW_CHECKED_MOD(((c0 + term)), (MOD));
        } else {
            c0 = FLOW_CHECKED_MOD((((c0 - FLOW_CHECKED_MOD((term), (MOD))) + MOD)), (MOD));
        }
        k = (k + 1);
    }
    int64_t c1 = 0;
    k = 1;
    while (k <= m) {
        int64_t ak = FLOW_CHECKED_MOD(((modpow_i64_i64_i64(2, (k - 1), MOD) * fact_mod[((n - k) - 1)])), (MOD));
        int64_t term = FLOW_CHECKED_MOD(((FLOW_CHECKED_MOD(((k * comb_mod_i64_i64(m, k))), (MOD)) * ak)), (MOD));
        if (FLOW_CHECKED_MOD(((k - 1)), (2)) == 0) {
            c1 = FLOW_CHECKED_MOD(((c1 + term)), (MOD));
        } else {
            c1 = FLOW_CHECKED_MOD((((c1 - FLOW_CHECKED_MOD((term), (MOD))) + MOD)), (MOD));
        }
        k = (k + 1);
    }
    return FLOW_CHECKED_MOD(((((total - c0) - FLOW_CHECKED_MOD((c1), (MOD))) + (2 * MOD))), (MOD));
}

int64_t isqrt_ll_i64(int64_t n) {
    if (n < 0) {
        return (-1);
    }
    if (n == 0) {
        return 0;
    }
    int64_t x = 0;
    int64_t bit = 1;
    while (bit <= n) {
        bit = FLOW_CHECKED_SHL((bit), (2));
    }
    bit = FLOW_CHECKED_SHR((bit), (2));
    while (bit != 0) {
        if (n >= (x + bit)) {
            n = (n - (x + bit));
            x = (FLOW_CHECKED_SHR((x), (1)) + bit);
        } else {
            x = FLOW_CHECKED_SHR((x), (1));
        }
        bit = FLOW_CHECKED_SHR((bit), (2));
    }
    return x;
}

int64_t inv_triangular_i64(int64_t q) {
    int64_t disc = (1 + (8 * q));
    int64_t r = isqrt_ll_i64(disc);
    if ((r * r) != disc) {
        return (-1);
    }
    if (FLOW_CHECKED_MOD(((1 + r)), (2)) != 0) {
        return (-1);
    }
    return FLOW_CHECKED_DIV(((1 + r)), (2));
}

int64_t hash_key_i64_i64(int64_t qx, int64_t qy) {
    int64_t h = ((qx * 1000000007) + qy);
    int64_t hi = FLOW_CHECKED_SHR((((int64_t)(h))), (32));
    int64_t lo = (h & 4294967295);
    int64_t mixed = ((lo ^ hi) & HASH_MASK);
    return mixed;
}

int64_t find_point_i64_i64(int64_t qx, int64_t qy) {
    int64_t h = hash_key_i64_i64(qx, qy);
    int64_t idx = ((int64_t)(hash_buckets[h]));
    while (idx != (-1)) {
        if ((pts_qx[idx] == qx && pts_qy[idx] == qy)) {
            return idx;
        }
        idx = ((int64_t)(hash_next[idx]));
    }
    return (-1);
}

void add_point_fast_i64_i64(int64_t qx, int64_t qy) {
    int64_t idx = find_point_i64_i64(qx, qy);
    if (idx >= 0) {
        pts_count[idx] = (pts_count[idx] + 1);
        return;
    }
    idx = num_points;
    num_points = (num_points + 1);
    pts_qx[idx] = qx;
    pts_qy[idx] = qy;
    pts_count[idx] = 1;
    int64_t h = hash_key_i64_i64(qx, qy);
    hash_next[idx] = hash_buckets[h];
    hash_buckets[h] = ((int32_t)(idx));
}

int64_t grid_key_f64_f64(double x, double y) {
    int64_t ix = ((int64_t)(floor((x / 0.000001))));
    int64_t iy = ((int64_t)(floor((y / 0.000001))));
    int64_t h = ((ix * 1000000007) + iy);
    int64_t hi = FLOW_CHECKED_SHR((((int64_t)(h))), (32));
    int64_t lo = (h & 4294967295);
    return ((lo ^ hi) & HASH_MASK);
}

void add_point_slow_f64_f64(double x, double y) {
    int64_t ix = ((int64_t)(floor((x / 0.000001))));
    int64_t iy = ((int64_t)(floor((y / 0.000001))));
    int64_t dx = (-1);
    while (dx <= 1) {
        int64_t dy = (-1);
        while (dy <= 1) {
            int64_t cx = (ix + dx);
            int64_t cy = (iy + dy);
            int64_t h2 = ((cx * 1000000007) + cy);
            int64_t hi = FLOW_CHECKED_SHR((((int64_t)(h2))), (32));
            int64_t lo = (h2 & 4294967295);
            int64_t h = ((lo ^ hi) & HASH_MASK);
            int64_t idx = ((int64_t)(grid_buckets[h]));
            while (idx != (-1)) {
                double ddx = (x - reps_x[idx]);
                double ddy = (y - reps_y[idx]);
                if (((ddx * ddx) + (ddy * ddy)) <= 1e-18) {
                    reps_cnt[idx] = (reps_cnt[idx] + 1);
                    return;
                }
                idx = ((int64_t)(grid_next[idx]));
            }
            dy = (dy + 1);
        }
        dx = (dx + 1);
    }
    int64_t idx = num_reps;
    num_reps = (num_reps + 1);
    reps_x[idx] = x;
    reps_y[idx] = y;
    reps_cnt[idx] = 1;
    int64_t h = grid_key_f64_f64(x, y);
    grid_next[idx] = grid_buckets[h];
    grid_buckets[h] = ((int32_t)(idx));
}

int32_t compute_points_fast_i64_ptr_f64_ptr_f64(int64_t n, double* xs, double* ys) {
    num_points = 0;
    int64_t i = 0;
    while (i < HASH_SIZE) {
        hash_buckets[i] = (-1);
        i = (i + 1);
    }
    int64_t a = 0;
    while (a < (n - 3)) {
        double x1 = xs[a];
        double y1 = ys[a];
        int64_t b = (a + 1);
        while (b < (n - 2)) {
            double x3 = xs[b];
            double y3 = ys[b];
            double abx = (x3 - x1);
            double aby = (y3 - y1);
            int64_t c = (b + 1);
            while (c < (n - 1)) {
                double x2 = xs[c];
                double y2 = ys[c];
                double dx12 = (x2 - x1);
                double dy12 = (y2 - y1);
                int64_t d = (c + 1);
                while (d < n) {
                    double x4 = xs[d];
                    double y4 = ys[d];
                    double dx34 = (x4 - x3);
                    double dy34 = (y4 - y3);
                    double denom = ((dx12 * dy34) - (dy12 * dx34));
                    if (fabs(denom) < 1e-18) {
                        d = (d + 1);
                        continue;
                    }
                    double t = (((abx * dy34) - (aby * dx34)) / denom);
                    double px = (x1 + (t * dx12));
                    double py = (y1 + (t * dy12));
                    int64_t qx = llround((px * ((double)(SCALE))));
                    int64_t qy = llround((py * ((double)(SCALE))));
                    add_point_fast_i64_i64(qx, qy);
                    d = (d + 1);
                }
                c = (c + 1);
            }
            b = (b + 1);
        }
        a = (a + 1);
    }
    i = 0;
    while (i < num_points) {
        if (inv_triangular_i64(((int64_t)(pts_count[i]))) < 0) {
            return 0;
        }
        i = (i + 1);
    }
    return 1;
}

void compute_points_slow_i64_ptr_f64_ptr_f64(int64_t n, double* xs, double* ys) {
    num_reps = 0;
    int64_t i = 0;
    while (i < HASH_SIZE) {
        grid_buckets[i] = (-1);
        i = (i + 1);
    }
    int64_t a = 0;
    while (a < (n - 3)) {
        double x1 = xs[a];
        double y1 = ys[a];
        int64_t b = (a + 1);
        while (b < (n - 2)) {
            double x3 = xs[b];
            double y3 = ys[b];
            double abx = (x3 - x1);
            double aby = (y3 - y1);
            int64_t c = (b + 1);
            while (c < (n - 1)) {
                double x2 = xs[c];
                double y2 = ys[c];
                double dx12 = (x2 - x1);
                double dy12 = (y2 - y1);
                int64_t d = (c + 1);
                while (d < n) {
                    double x4 = xs[d];
                    double y4 = ys[d];
                    double dx34 = (x4 - x3);
                    double dy34 = (y4 - y3);
                    double denom = ((dx12 * dy34) - (dy12 * dx34));
                    if (fabs(denom) < 1e-18) {
                        d = (d + 1);
                        continue;
                    }
                    double t = (((abx * dy34) - (aby * dx34)) / denom);
                    double px = (x1 + (t * dx12));
                    double py = (y1 + (t * dy12));
                    add_point_slow_f64_f64(px, py);
                    d = (d + 1);
                }
                c = (c + 1);
            }
            b = (b + 1);
        }
        a = (a + 1);
    }
}

int64_t T_mod_i64(int64_t n) {
    if (n < 4) {
        return 0;
    }
    double tau = (2.0 * 3.14159265358979323846);
    double* xs = (double*)(calloc(60, 8));
    double* ys = (double*)(calloc(60, 8));
    int64_t k = 0;
    while (k < n) {
        xs[k] = cos(((tau * ((double)(k))) / ((double)(n))));
        ys[k] = sin(((tau * ((double)(k))) / ((double)(n))));
        k = (k + 1);
    }
    int64_t* dist_m = (int64_t*)(calloc(100, 8));
    int64_t* dist_cnt = (int64_t*)(calloc(100, 8));
    int64_t dist_size = 0;
    int32_t fast = compute_points_fast_i64_ptr_f64_ptr_f64(n, xs, ys);
    if (fast != 0) {
        int64_t i = 0;
        while (i < num_points) {
            int64_t m = inv_triangular_i64(((int64_t)(pts_count[i])));
            int64_t found = (-1);
            int64_t j = 0;
            while (j < dist_size) {
                if (dist_m[j] == m) {
                    found = j;
                    break;
                }
                j = (j + 1);
            }
            if (found < 0) {
                dist_m[dist_size] = m;
                dist_cnt[dist_size] = 1;
                dist_size = (dist_size + 1);
            } else {
                dist_cnt[found] = (dist_cnt[found] + 1);
            }
            i = (i + 1);
        }
    } else {
        compute_points_slow_i64_ptr_f64_ptr_f64(n, xs, ys);
        int64_t i = 0;
        while (i < num_reps) {
            int64_t m = inv_triangular_i64(((int64_t)(reps_cnt[i])));
            if (m < 0) {
                i = (i + 1);
                continue;
            }
            int64_t found = (-1);
            int64_t j = 0;
            while (j < dist_size) {
                if (dist_m[j] == m) {
                    found = j;
                    break;
                }
                j = (j + 1);
            }
            if (found < 0) {
                dist_m[dist_size] = m;
                dist_cnt[dist_size] = 1;
                dist_size = (dist_size + 1);
            } else {
                dist_cnt[found] = (dist_cnt[found] + 1);
            }
            i = (i + 1);
        }
    }
    int64_t total = 0;
    int64_t i = 0;
    while (i < dist_size) {
        int64_t g = cycles_at_least_two_edges_i64_i64(n, dist_m[i]);
        total = FLOW_CHECKED_MOD(((total + (dist_cnt[i] * g))), (MOD));
        i = (i + 1);
    }
    free(xs);
    free(ys);
    free(dist_m);
    free(dist_cnt);
    return total;
}

int32_t main(void) {
    init_factorials();
    pts_qx = calloc(MAX_POINTS, 8);
    pts_qy = calloc(MAX_POINTS, 8);
    pts_count = calloc(MAX_POINTS, 4);
    hash_buckets = calloc(HASH_SIZE, 4);
    hash_next = calloc(MAX_POINTS, 4);
    reps_x = calloc(MAX_REPS, 8);
    reps_y = calloc(MAX_REPS, 8);
    reps_cnt = calloc(MAX_REPS, 4);
    grid_buckets = calloc(HASH_SIZE, 4);
    grid_next = calloc(MAX_REPS, 4);
    int64_t ans = 0;
    int64_t n = 3;
    while (n <= 60) {
        ans = FLOW_CHECKED_MOD(((ans + T_mod_i64(n))), (MOD));
        n = (n + 1);
    }
    printf("%lld\n", ans);
    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 private @calloc(i64, i64) -> !llvm.ptr
  func.func private @free(!llvm.ptr) -> ()
  func.func private @memset(!llvm.ptr, i32, i64) -> !llvm.ptr
  func.func private @cos(f64) -> f64
  func.func private @sin(f64) -> f64
  func.func private @fabs(f64) -> f64
  func.func private @floor(f64) -> f64
  func.func private @llround(f64) -> i64
  // Constant: MOD
  llvm.mlir.global internal constant @MOD(1000000007 : i64) : i64
  // Constant: SCALE
  llvm.mlir.global internal constant @SCALE(100000000000 : i64) : i64
  // Constant: HASH_SIZE
  llvm.mlir.global internal constant @HASH_SIZE(1048576 : i64) : i64
  // Constant: HASH_MASK
  llvm.mlir.global internal constant @HASH_MASK(1048575 : i64) : i64
  // Constant: MAX_POINTS
  llvm.mlir.global internal constant @MAX_POINTS(600000 : i64) : i64
  // Constant: MAX_REPS
  llvm.mlir.global internal constant @MAX_REPS(600000 : i64) : i64
  // Module static: fact_mod
  llvm.mlir.global internal @fact_mod() {addr_space = 0 : i32} : !llvm.ptr {
    %0 = llvm.mlir.zero : !llvm.ptr
    llvm.return %0 : !llvm.ptr
  }
  // Module static: inv_fact_mod
  llvm.mlir.global internal @inv_fact_mod() {addr_space = 0 : i32} : !llvm.ptr {
    %1 = llvm.mlir.zero : !llvm.ptr
    llvm.return %1 : !llvm.ptr
  }
  // Module static: pts_qx
  llvm.mlir.global internal @pts_qx() {addr_space = 0 : i32} : !llvm.ptr {
    %2 = llvm.mlir.zero : !llvm.ptr
    llvm.return %2 : !llvm.ptr
  }
  // Module static: pts_qy
  llvm.mlir.global internal @pts_qy() {addr_space = 0 : i32} : !llvm.ptr {
    %3 = llvm.mlir.zero : !llvm.ptr
    llvm.return %3 : !llvm.ptr
  }
  // Module static: pts_count
  llvm.mlir.global internal @pts_count() {addr_space = 0 : i32} : !llvm.ptr {
    %4 = llvm.mlir.zero : !llvm.ptr
    llvm.return %4 : !llvm.ptr
  }
  // Module static: num_points
  llvm.mlir.global internal @num_points(0 : i64) : i64
  // Module static: hash_buckets
  llvm.mlir.global internal @hash_buckets() {addr_space = 0 : i32} : !llvm.ptr {
    %5 = llvm.mlir.zero : !llvm.ptr
    llvm.return %5 : !llvm.ptr
  }
  // Module static: hash_next
  llvm.mlir.global internal @hash_next() {addr_space = 0 : i32} : !llvm.ptr {
    %6 = llvm.mlir.zero : !llvm.ptr
    llvm.return %6 : !llvm.ptr
  }
  // Module static: reps_x
  llvm.mlir.global internal @reps_x() {addr_space = 0 : i32} : !llvm.ptr {
    %7 = llvm.mlir.zero : !llvm.ptr
    llvm.return %7 : !llvm.ptr
  }
  // Module static: reps_y
  llvm.mlir.global internal @reps_y() {addr_space = 0 : i32} : !llvm.ptr {
    %8 = llvm.mlir.zero : !llvm.ptr
    llvm.return %8 : !llvm.ptr
  }
  // Module static: reps_cnt
  llvm.mlir.global internal @reps_cnt() {addr_space = 0 : i32} : !llvm.ptr {
    %9 = llvm.mlir.zero : !llvm.ptr
    llvm.return %9 : !llvm.ptr
  }
  // Module static: num_reps
  llvm.mlir.global internal @num_reps(0 : i64) : i64
  // Module static: grid_buckets
  llvm.mlir.global internal @grid_buckets() {addr_space = 0 : i32} : !llvm.ptr {
    %10 = llvm.mlir.zero : !llvm.ptr
    llvm.return %10 : !llvm.ptr
  }
  // Module static: grid_next
  llvm.mlir.global internal @grid_next() {addr_space = 0 : i32} : !llvm.ptr {
    %11 = llvm.mlir.zero : !llvm.ptr
    llvm.return %11 : !llvm.ptr
  }
  func.func @modpow(%arg0: i64, %arg1: i64, %arg2: i64) -> i64 {
    %12 = arith.constant 1 : i32
    %13 = arith.extsi %12 : i32 to i64
    %14 = llvm.mlir.constant(1 : i64) : i64
    %15 = llvm.alloca %14 x i64 : (i64) -> !llvm.ptr
    llvm.store %13, %15 : i64, !llvm.ptr
    %16 = arith.remsi %arg0, %arg2 : i64
    %17 = llvm.mlir.constant(1 : i64) : i64
    %18 = llvm.alloca %17 x i64 : (i64) -> !llvm.ptr
    llvm.store %16, %18 : i64, !llvm.ptr
    %19 = llvm.mlir.constant(1 : i64) : i64
    %20 = llvm.alloca %19 x i64 : (i64) -> !llvm.ptr
    llvm.store %arg1, %20 : i64, !llvm.ptr
    cf.br ^bb0
    ^bb0:
    %21 = llvm.load %20 : !llvm.ptr -> i64
    %22 = arith.constant 0 : i32
    %24 = arith.extsi %22 : i32 to i64
    %23 = arith.cmpi sgt, %21, %24 : i64
    cf.cond_br %23, ^bb1, ^bb2
    ^bb1:
      %25 = llvm.load %20 : !llvm.ptr -> i64
      %26 = arith.constant 1 : i32
      %28 = arith.extsi %26 : i32 to i64
      %27 = arith.andi %25, %28 : i64
      %29 = arith.constant 0 : i32
      %31 = arith.extsi %29 : i32 to i64
      %30 = arith.cmpi ne, %27, %31 : i64
      cf.cond_br %30, ^bb3, ^bb4
      ^bb3:
        %32 = llvm.load %15 : !llvm.ptr -> i64
        %33 = arith.extsi %32 : i64 to i128
        %34 = llvm.load %18 : !llvm.ptr -> i64
        %35 = arith.extsi %34 : i64 to i128
        %37 = arith.trunci %33 : i128 to i64
        %38 = arith.trunci %35 : i128 to i64
        %36 = arith.muli %37, %38 : i64
        %39 = arith.extsi %arg2 : i64 to i128
        %41 = arith.trunci %39 : i128 to i64
        %40 = arith.remsi %36, %41 : i64
        llvm.store %40, %15 : i64, !llvm.ptr
        cf.br ^bb5
      ^bb4:
        cf.br ^bb5
      ^bb5:
      %42 = llvm.load %18 : !llvm.ptr -> i64
      %43 = arith.extsi %42 : i64 to i128
      %44 = llvm.load %18 : !llvm.ptr -> i64
      %45 = arith.extsi %44 : i64 to i128
      %47 = arith.trunci %43 : i128 to i64
      %48 = arith.trunci %45 : i128 to i64
      %46 = arith.muli %47, %48 : i64
      %49 = arith.extsi %arg2 : i64 to i128
      %51 = arith.trunci %49 : i128 to i64
      %50 = arith.remsi %46, %51 : i64
      llvm.store %50, %18 : i64, !llvm.ptr
      %52 = llvm.load %20 : !llvm.ptr -> i64
      %53 = arith.constant 1 : i32
      %55 = arith.extsi %53 : i32 to i64
      %54 = arith.shrsi %52, %55 : i64
      llvm.store %54, %20 : i64, !llvm.ptr
      cf.br ^bb0
    ^bb2:
    %56 = llvm.load %15 : !llvm.ptr -> i64
    func.return %56 : i64
  }
  func.func @modinv(%arg0: i64, %arg1: i64) -> i64 {
    %58 = arith.constant 2 : i32
    %60 = arith.extsi %58 : i32 to i64
    %59 = arith.subi %arg1, %60 : i64
    %57 = func.call @modpow(%arg0, %59, %arg1) : (i64, i64, i64) -> i64
    func.return %57 : i64
  }
  func.func @init_factorials() -> () {
    %62 = arith.constant 61 : i32
    %63 = arith.constant 8 : i32
    %64 = arith.extsi %62 : i32 to i64
    %65 = arith.extsi %63 : i32 to i64
    %61 = func.call @calloc(%64, %65) : (i64, i64) -> !llvm.ptr
    %66 = llvm.mlir.addressof @fact_mod : !llvm.ptr
    llvm.store %61, %66 : !llvm.ptr, !llvm.ptr
    %68 = arith.constant 61 : i32
    %69 = arith.constant 8 : i32
    %70 = arith.extsi %68 : i32 to i64
    %71 = arith.extsi %69 : i32 to i64
    %67 = func.call @calloc(%70, %71) : (i64, i64) -> !llvm.ptr
    %72 = llvm.mlir.addressof @inv_fact_mod : !llvm.ptr
    llvm.store %67, %72 : !llvm.ptr, !llvm.ptr
    %73 = arith.constant 1 : i32
    %74 = llvm.mlir.addressof @fact_mod : !llvm.ptr
    %75 = llvm.load %74 : !llvm.ptr -> !llvm.ptr
    %76 = arith.constant 0 : i32
    %77 = arith.extsi %73 : i32 to i64
    %78 = arith.extsi %76 : i32 to i64
    %79 = llvm.getelementptr %75[%78] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    llvm.store %77, %79 : i64, !llvm.ptr
    %80 = arith.constant 1 : i32
    %81 = arith.extsi %80 : i32 to i64
    %82 = llvm.mlir.constant(1 : i64) : i64
    %83 = llvm.alloca %82 x i64 : (i64) -> !llvm.ptr
    llvm.store %81, %83 : i64, !llvm.ptr
    cf.br ^bb6
    ^bb6:
    %84 = llvm.load %83 : !llvm.ptr -> i64
    %85 = arith.constant 60 : i32
    %87 = arith.extsi %85 : i32 to i64
    %86 = arith.cmpi sle, %84, %87 : i64
    cf.cond_br %86, ^bb7, ^bb8
    ^bb7:
      %89 = llvm.mlir.addressof @fact_mod : !llvm.ptr
      %90 = llvm.load %89 : !llvm.ptr -> !llvm.ptr
      %91 = llvm.load %83 : !llvm.ptr -> i64
      %92 = arith.constant 1 : i32
      %94 = arith.extsi %92 : i32 to i64
      %93 = arith.subi %91, %94 : i64
      %95 = llvm.getelementptr %90[%93] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %88 = llvm.load %95 : !llvm.ptr -> i64
      %96 = llvm.load %83 : !llvm.ptr -> i64
      %97 = arith.muli %88, %96 : i64
      %98 = llvm.mlir.addressof @MOD : !llvm.ptr
      %99 = llvm.load %98 : !llvm.ptr -> i64
      %100 = arith.remsi %97, %99 : i64
      %101 = llvm.mlir.addressof @fact_mod : !llvm.ptr
      %102 = llvm.load %101 : !llvm.ptr -> !llvm.ptr
      %103 = llvm.load %83 : !llvm.ptr -> i64
      %104 = llvm.getelementptr %102[%103] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %100, %104 : i64, !llvm.ptr
      %105 = llvm.load %83 : !llvm.ptr -> i64
      %106 = arith.constant 1 : i32
      %108 = arith.extsi %106 : i32 to i64
      %107 = arith.addi %105, %108 : i64
      llvm.store %107, %83 : i64, !llvm.ptr
      cf.br ^bb6
    ^bb8:
    %109 = arith.constant 0 : i32
    %110 = arith.extsi %109 : i32 to i64
    llvm.store %110, %83 : i64, !llvm.ptr
    cf.br ^bb9
    ^bb9:
    %111 = llvm.load %83 : !llvm.ptr -> i64
    %112 = arith.constant 60 : i32
    %114 = arith.extsi %112 : i32 to i64
    %113 = arith.cmpi sle, %111, %114 : i64
    cf.cond_br %113, ^bb10, ^bb11
    ^bb10:
      %117 = llvm.mlir.addressof @fact_mod : !llvm.ptr
      %118 = llvm.load %117 : !llvm.ptr -> !llvm.ptr
      %119 = llvm.load %83 : !llvm.ptr -> i64
      %120 = llvm.getelementptr %118[%119] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %116 = llvm.load %120 : !llvm.ptr -> i64
      %121 = llvm.mlir.addressof @MOD : !llvm.ptr
      %122 = llvm.load %121 : !llvm.ptr -> i64
      %115 = func.call @modinv(%116, %122) : (i64, i64) -> i64
      %123 = llvm.mlir.addressof @inv_fact_mod : !llvm.ptr
      %124 = llvm.load %123 : !llvm.ptr -> !llvm.ptr
      %125 = llvm.load %83 : !llvm.ptr -> i64
      %126 = llvm.getelementptr %124[%125] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %115, %126 : i64, !llvm.ptr
      %127 = llvm.load %83 : !llvm.ptr -> i64
      %128 = arith.constant 1 : i32
      %130 = arith.extsi %128 : i32 to i64
      %129 = arith.addi %127, %130 : i64
      llvm.store %129, %83 : i64, !llvm.ptr
      cf.br ^bb9
    ^bb11:
    func.return
  }
  func.func @comb_mod(%arg0: i64, %arg1: i64) -> i64 {
    %131 = arith.constant 0 : i32
    %133 = arith.extsi %131 : i32 to i64
    %132 = arith.cmpi slt, %arg1, %133 : i64
    %134 = scf.if %132 -> (i1) {
      %135 = arith.constant true
      scf.yield %135 : i1
    } else {
      %136 = arith.cmpi sgt, %arg1, %arg0 : i64
      scf.yield %136 : i1
    }
    cf.cond_br %134, ^bb12, ^bb13
    ^bb12:
      %137 = arith.constant 0 : i32
      %138 = arith.extsi %137 : i32 to i64
      func.return %138 : i64
    ^bb13:
      cf.br ^bb14
    ^bb14:
    %140 = llvm.mlir.addressof @fact_mod : !llvm.ptr
    %141 = llvm.load %140 : !llvm.ptr -> !llvm.ptr
    %142 = llvm.getelementptr %141[%arg0] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    %139 = llvm.load %142 : !llvm.ptr -> i64
    %144 = llvm.mlir.addressof @inv_fact_mod : !llvm.ptr
    %145 = llvm.load %144 : !llvm.ptr -> !llvm.ptr
    %146 = llvm.getelementptr %145[%arg1] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    %143 = llvm.load %146 : !llvm.ptr -> i64
    %147 = arith.muli %139, %143 : i64
    %148 = llvm.mlir.addressof @MOD : !llvm.ptr
    %149 = llvm.load %148 : !llvm.ptr -> i64
    %150 = arith.remsi %147, %149 : i64
    %152 = llvm.mlir.addressof @inv_fact_mod : !llvm.ptr
    %153 = llvm.load %152 : !llvm.ptr -> !llvm.ptr
    %154 = arith.subi %arg0, %arg1 : i64
    %155 = llvm.getelementptr %153[%154] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    %151 = llvm.load %155 : !llvm.ptr -> i64
    %156 = arith.muli %150, %151 : i64
    %157 = llvm.mlir.addressof @MOD : !llvm.ptr
    %158 = llvm.load %157 : !llvm.ptr -> i64
    %159 = arith.remsi %156, %158 : i64
    func.return %159 : i64
  }
  func.func @cycles_at_least_two_edges(%arg0: i64, %arg1: i64) -> i64 {
    %160 = arith.constant 2 : i32
    %162 = arith.extsi %160 : i32 to i64
    %161 = arith.cmpi slt, %arg1, %162 : i64
    cf.cond_br %161, ^bb15, ^bb16
    ^bb15:
      %163 = arith.constant 0 : i32
      %164 = arith.extsi %163 : i32 to i64
      func.return %164 : i64
    ^bb16:
      cf.br ^bb17
    ^bb17:
    %166 = arith.constant 2 : i32
    %167 = llvm.mlir.addressof @MOD : !llvm.ptr
    %168 = llvm.load %167 : !llvm.ptr -> i64
    %169 = arith.extsi %166 : i32 to i64
    %165 = func.call @modinv(%169, %168) : (i64, i64) -> i64
    %171 = llvm.mlir.addressof @fact_mod : !llvm.ptr
    %172 = llvm.load %171 : !llvm.ptr -> !llvm.ptr
    %173 = arith.constant 1 : i32
    %175 = arith.extsi %173 : i32 to i64
    %174 = arith.subi %arg0, %175 : i64
    %176 = llvm.getelementptr %172[%174] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    %170 = llvm.load %176 : !llvm.ptr -> i64
    %177 = arith.muli %170, %165 : i64
    %178 = llvm.mlir.addressof @MOD : !llvm.ptr
    %179 = llvm.load %178 : !llvm.ptr -> i64
    %180 = arith.remsi %177, %179 : i64
    %181 = arith.constant 0 : i32
    %182 = arith.extsi %181 : i32 to i64
    %183 = llvm.mlir.constant(1 : i64) : i64
    %184 = llvm.alloca %183 x i64 : (i64) -> !llvm.ptr
    llvm.store %182, %184 : i64, !llvm.ptr
    %185 = arith.constant 0 : i32
    %186 = arith.extsi %185 : i32 to i64
    %187 = llvm.mlir.constant(1 : i64) : i64
    %188 = llvm.alloca %187 x i64 : (i64) -> !llvm.ptr
    llvm.store %186, %188 : i64, !llvm.ptr
    cf.br ^bb18
    ^bb18:
    %189 = llvm.load %188 : !llvm.ptr -> i64
    %190 = arith.cmpi sle, %189, %arg1 : i64
    cf.cond_br %190, ^bb19, ^bb20
    ^bb19:
      %191 = arith.constant 0 : i32
      %192 = arith.extsi %191 : i32 to i64
      %193 = llvm.load %188 : !llvm.ptr -> i64
      %194 = arith.constant 0 : i32
      %196 = arith.extsi %194 : i32 to i64
      %195 = arith.cmpi eq, %193, %196 : i64
      %197 = scf.if %195 -> (i64) {
        scf.yield %180 : i64
      } else {
        %199 = arith.constant 2 : i32
        %200 = llvm.load %188 : !llvm.ptr -> i64
        %201 = arith.constant 1 : i32
        %203 = arith.extsi %201 : i32 to i64
        %202 = arith.subi %200, %203 : i64
        %204 = llvm.mlir.addressof @MOD : !llvm.ptr
        %205 = llvm.load %204 : !llvm.ptr -> i64
        %206 = arith.extsi %199 : i32 to i64
        %198 = func.call @modpow(%206, %202, %205) : (i64, i64, i64) -> i64
        %208 = llvm.mlir.addressof @fact_mod : !llvm.ptr
        %209 = llvm.load %208 : !llvm.ptr -> !llvm.ptr
        %210 = llvm.load %188 : !llvm.ptr -> i64
        %211 = arith.subi %arg0, %210 : i64
        %212 = arith.constant 1 : i32
        %214 = arith.extsi %212 : i32 to i64
        %213 = arith.subi %211, %214 : i64
        %215 = llvm.getelementptr %209[%213] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %207 = llvm.load %215 : !llvm.ptr -> i64
        %216 = arith.muli %198, %207 : i64
        %217 = llvm.mlir.addressof @MOD : !llvm.ptr
        %218 = llvm.load %217 : !llvm.ptr -> i64
        %219 = arith.remsi %216, %218 : i64
        scf.yield %219 : i64
      }
      %221 = llvm.load %188 : !llvm.ptr -> i64
      %220 = func.call @comb_mod(%arg1, %221) : (i64, i64) -> i64
      %222 = arith.muli %220, %197 : i64
      %223 = llvm.mlir.addressof @MOD : !llvm.ptr
      %224 = llvm.load %223 : !llvm.ptr -> i64
      %225 = arith.remsi %222, %224 : i64
      %226 = llvm.load %188 : !llvm.ptr -> i64
      %227 = arith.constant 2 : i32
      %229 = arith.extsi %227 : i32 to i64
      %228 = arith.remsi %226, %229 : i64
      %230 = arith.constant 0 : i32
      %232 = arith.extsi %230 : i32 to i64
      %231 = arith.cmpi eq, %228, %232 : i64
      cf.cond_br %231, ^bb21, ^bb22
      ^bb21:
        %233 = llvm.load %184 : !llvm.ptr -> i64
        %234 = arith.addi %233, %225 : i64
        %235 = llvm.mlir.addressof @MOD : !llvm.ptr
        %236 = llvm.load %235 : !llvm.ptr -> i64
        %237 = arith.remsi %234, %236 : i64
        llvm.store %237, %184 : i64, !llvm.ptr
        cf.br ^bb23
      ^bb22:
        %238 = llvm.load %184 : !llvm.ptr -> i64
        %239 = llvm.mlir.addressof @MOD : !llvm.ptr
        %240 = llvm.load %239 : !llvm.ptr -> i64
        %241 = arith.remsi %225, %240 : i64
        %242 = arith.subi %238, %241 : i64
        %243 = llvm.mlir.addressof @MOD : !llvm.ptr
        %244 = llvm.load %243 : !llvm.ptr -> i64
        %245 = arith.addi %242, %244 : i64
        %246 = llvm.mlir.addressof @MOD : !llvm.ptr
        %247 = llvm.load %246 : !llvm.ptr -> i64
        %248 = arith.remsi %245, %247 : i64
        llvm.store %248, %184 : i64, !llvm.ptr
        cf.br ^bb23
      ^bb23:
      %249 = llvm.load %188 : !llvm.ptr -> i64
      %250 = arith.constant 1 : i32
      %252 = arith.extsi %250 : i32 to i64
      %251 = arith.addi %249, %252 : i64
      llvm.store %251, %188 : i64, !llvm.ptr
      cf.br ^bb18
    ^bb20:
    %253 = arith.constant 0 : i32
    %254 = arith.extsi %253 : i32 to i64
    %255 = llvm.mlir.constant(1 : i64) : i64
    %256 = llvm.alloca %255 x i64 : (i64) -> !llvm.ptr
    llvm.store %254, %256 : i64, !llvm.ptr
    %257 = arith.constant 1 : i32
    %258 = arith.extsi %257 : i32 to i64
    llvm.store %258, %188 : i64, !llvm.ptr
    cf.br ^bb24
    ^bb24:
    %259 = llvm.load %188 : !llvm.ptr -> i64
    %260 = arith.cmpi sle, %259, %arg1 : i64
    cf.cond_br %260, ^bb25, ^bb26
    ^bb25:
      %262 = arith.constant 2 : i32
      %263 = llvm.load %188 : !llvm.ptr -> i64
      %264 = arith.constant 1 : i32
      %266 = arith.extsi %264 : i32 to i64
      %265 = arith.subi %263, %266 : i64
      %267 = llvm.mlir.addressof @MOD : !llvm.ptr
      %268 = llvm.load %267 : !llvm.ptr -> i64
      %269 = arith.extsi %262 : i32 to i64
      %261 = func.call @modpow(%269, %265, %268) : (i64, i64, i64) -> i64
      %271 = llvm.mlir.addressof @fact_mod : !llvm.ptr
      %272 = llvm.load %271 : !llvm.ptr -> !llvm.ptr
      %273 = llvm.load %188 : !llvm.ptr -> i64
      %274 = arith.subi %arg0, %273 : i64
      %275 = arith.constant 1 : i32
      %277 = arith.extsi %275 : i32 to i64
      %276 = arith.subi %274, %277 : i64
      %278 = llvm.getelementptr %272[%276] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %270 = llvm.load %278 : !llvm.ptr -> i64
      %279 = arith.muli %261, %270 : i64
      %280 = llvm.mlir.addressof @MOD : !llvm.ptr
      %281 = llvm.load %280 : !llvm.ptr -> i64
      %282 = arith.remsi %279, %281 : i64
      %283 = llvm.load %188 : !llvm.ptr -> i64
      %285 = llvm.load %188 : !llvm.ptr -> i64
      %284 = func.call @comb_mod(%arg1, %285) : (i64, i64) -> i64
      %286 = arith.muli %283, %284 : i64
      %287 = llvm.mlir.addressof @MOD : !llvm.ptr
      %288 = llvm.load %287 : !llvm.ptr -> i64
      %289 = arith.remsi %286, %288 : i64
      %290 = arith.muli %289, %282 : i64
      %291 = llvm.mlir.addressof @MOD : !llvm.ptr
      %292 = llvm.load %291 : !llvm.ptr -> i64
      %293 = arith.remsi %290, %292 : i64
      %294 = llvm.load %188 : !llvm.ptr -> i64
      %295 = arith.constant 1 : i32
      %297 = arith.extsi %295 : i32 to i64
      %296 = arith.subi %294, %297 : i64
      %298 = arith.constant 2 : i32
      %300 = arith.extsi %298 : i32 to i64
      %299 = arith.remsi %296, %300 : i64
      %301 = arith.constant 0 : i32
      %303 = arith.extsi %301 : i32 to i64
      %302 = arith.cmpi eq, %299, %303 : i64
      cf.cond_br %302, ^bb27, ^bb28
      ^bb27:
        %304 = llvm.load %256 : !llvm.ptr -> i64
        %305 = arith.addi %304, %293 : i64
        %306 = llvm.mlir.addressof @MOD : !llvm.ptr
        %307 = llvm.load %306 : !llvm.ptr -> i64
        %308 = arith.remsi %305, %307 : i64
        llvm.store %308, %256 : i64, !llvm.ptr
        cf.br ^bb29
      ^bb28:
        %309 = llvm.load %256 : !llvm.ptr -> i64
        %310 = llvm.mlir.addressof @MOD : !llvm.ptr
        %311 = llvm.load %310 : !llvm.ptr -> i64
        %312 = arith.remsi %293, %311 : i64
        %313 = arith.subi %309, %312 : i64
        %314 = llvm.mlir.addressof @MOD : !llvm.ptr
        %315 = llvm.load %314 : !llvm.ptr -> i64
        %316 = arith.addi %313, %315 : i64
        %317 = llvm.mlir.addressof @MOD : !llvm.ptr
        %318 = llvm.load %317 : !llvm.ptr -> i64
        %319 = arith.remsi %316, %318 : i64
        llvm.store %319, %256 : i64, !llvm.ptr
        cf.br ^bb29
      ^bb29:
      %320 = llvm.load %188 : !llvm.ptr -> i64
      %321 = arith.constant 1 : i32
      %323 = arith.extsi %321 : i32 to i64
      %322 = arith.addi %320, %323 : i64
      llvm.store %322, %188 : i64, !llvm.ptr
      cf.br ^bb24
    ^bb26:
    %324 = llvm.load %184 : !llvm.ptr -> i64
    %325 = arith.subi %180, %324 : i64
    %326 = llvm.load %256 : !llvm.ptr -> i64
    %327 = llvm.mlir.addressof @MOD : !llvm.ptr
    %328 = llvm.load %327 : !llvm.ptr -> i64
    %329 = arith.remsi %326, %328 : i64
    %330 = arith.subi %325, %329 : i64
    %331 = arith.constant 2 : i32
    %332 = llvm.mlir.addressof @MOD : !llvm.ptr
    %333 = llvm.load %332 : !llvm.ptr -> i64
    %335 = arith.extsi %331 : i32 to i64
    %334 = arith.muli %335, %333 : i64
    %336 = arith.addi %330, %334 : i64
    %337 = llvm.mlir.addressof @MOD : !llvm.ptr
    %338 = llvm.load %337 : !llvm.ptr -> i64
    %339 = arith.remsi %336, %338 : i64
    func.return %339 : i64
  }
  func.func @isqrt_ll(%arg0: i64) -> i64 {
    %340 = arith.constant 0 : i32
    %342 = arith.extsi %340 : i32 to i64
    %341 = arith.cmpi slt, %arg0, %342 : i64
    cf.cond_br %341, ^bb30, ^bb31
    ^bb30:
      %343 = arith.constant 1 : i32
      %345 = arith.constant 0 : i32
      %344 = arith.subi %345, %343 : i32
      %346 = arith.extsi %344 : i32 to i64
      func.return %346 : i64
    ^bb31:
      cf.br ^bb32
    ^bb32:
    %347 = arith.constant 0 : i32
    %349 = arith.extsi %347 : i32 to i64
    %348 = arith.cmpi eq, %arg0, %349 : i64
    cf.cond_br %348, ^bb33, ^bb34
    ^bb33:
      %350 = arith.constant 0 : i32
      %351 = arith.extsi %350 : i32 to i64
      func.return %351 : i64
    ^bb34:
      cf.br ^bb35
    ^bb35:
    %352 = arith.constant 0 : i32
    %353 = arith.extsi %352 : i32 to i64
    %354 = llvm.mlir.constant(1 : i64) : i64
    %355 = llvm.alloca %354 x i64 : (i64) -> !llvm.ptr
    llvm.store %353, %355 : i64, !llvm.ptr
    %356 = arith.constant 1 : i32
    %357 = arith.extsi %356 : i32 to i64
    %358 = llvm.mlir.constant(1 : i64) : i64
    %359 = llvm.alloca %358 x i64 : (i64) -> !llvm.ptr
    llvm.store %357, %359 : i64, !llvm.ptr
    cf.br ^bb36
    ^bb36:
    %360 = llvm.load %359 : !llvm.ptr -> i64
    %361 = arith.cmpi sle, %360, %arg0 : i64
    cf.cond_br %361, ^bb37, ^bb38
    ^bb37:
      %362 = llvm.load %359 : !llvm.ptr -> i64
      %363 = arith.constant 2 : i32
      %365 = arith.extsi %363 : i32 to i64
      %364 = arith.shli %362, %365 : i64
      llvm.store %364, %359 : i64, !llvm.ptr
      cf.br ^bb36
    ^bb38:
    %366 = llvm.load %359 : !llvm.ptr -> i64
    %367 = arith.constant 2 : i32
    %369 = arith.extsi %367 : i32 to i64
    %368 = arith.shrsi %366, %369 : i64
    llvm.store %368, %359 : i64, !llvm.ptr
    cf.br ^bb39(%arg0 : i64)
    ^bb39(%370: i64):
    %371 = llvm.load %359 : !llvm.ptr -> i64
    %372 = arith.constant 0 : i32
    %374 = arith.extsi %372 : i32 to i64
    %373 = arith.cmpi ne, %371, %374 : i64
    cf.cond_br %373, ^bb40(%370 : i64), ^bb41(%370 : i64)
    ^bb40(%375: i64):
      %376 = llvm.load %355 : !llvm.ptr -> i64
      %377 = llvm.load %359 : !llvm.ptr -> i64
      %378 = arith.addi %376, %377 : i64
      %379 = arith.cmpi sge, %375, %378 : i64
      %380 = scf.if %379 -> (i64) {
        %381 = llvm.load %355 : !llvm.ptr -> i64
        %382 = llvm.load %359 : !llvm.ptr -> i64
        %383 = arith.addi %381, %382 : i64
        %384 = arith.subi %375, %383 : i64
        %385 = llvm.load %355 : !llvm.ptr -> i64
        %386 = arith.constant 1 : i32
        %388 = arith.extsi %386 : i32 to i64
        %387 = arith.shrsi %385, %388 : i64
        %389 = llvm.load %359 : !llvm.ptr -> i64
        %390 = arith.addi %387, %389 : i64
        llvm.store %390, %355 : i64, !llvm.ptr
        scf.yield %384 : i64
      } else {
        %391 = llvm.load %355 : !llvm.ptr -> i64
        %392 = arith.constant 1 : i32
        %394 = arith.extsi %392 : i32 to i64
        %393 = arith.shrsi %391, %394 : i64
        llvm.store %393, %355 : i64, !llvm.ptr
        scf.yield %375 : i64
      }
      %395 = llvm.load %359 : !llvm.ptr -> i64
      %396 = arith.constant 2 : i32
      %398 = arith.extsi %396 : i32 to i64
      %397 = arith.shrsi %395, %398 : i64
      llvm.store %397, %359 : i64, !llvm.ptr
      cf.br ^bb39(%380 : i64)
    ^bb41(%399: i64):
    %400 = llvm.load %355 : !llvm.ptr -> i64
    func.return %400 : i64
  }
  func.func @inv_triangular(%arg0: i64) -> i64 {
    %401 = arith.constant 1 : i32
    %402 = arith.constant 8 : i32
    %404 = arith.extsi %402 : i32 to i64
    %403 = arith.muli %404, %arg0 : i64
    %406 = arith.extsi %401 : i32 to i64
    %405 = arith.addi %406, %403 : i64
    %407 = func.call @isqrt_ll(%405) : (i64) -> i64
    %408 = arith.muli %407, %407 : i64
    %409 = arith.cmpi ne, %408, %405 : i64
    cf.cond_br %409, ^bb42, ^bb43
    ^bb42:
      %410 = arith.constant 1 : i32
      %412 = arith.constant 0 : i32
      %411 = arith.subi %412, %410 : i32
      %413 = arith.extsi %411 : i32 to i64
      func.return %413 : i64
    ^bb43:
      cf.br ^bb44
    ^bb44:
    %414 = arith.constant 1 : i32
    %416 = arith.extsi %414 : i32 to i64
    %415 = arith.addi %416, %407 : i64
    %417 = arith.constant 2 : i32
    %419 = arith.extsi %417 : i32 to i64
    %418 = arith.remsi %415, %419 : i64
    %420 = arith.constant 0 : i32
    %422 = arith.extsi %420 : i32 to i64
    %421 = arith.cmpi ne, %418, %422 : i64
    cf.cond_br %421, ^bb45, ^bb46
    ^bb45:
      %423 = arith.constant 1 : i32
      %425 = arith.constant 0 : i32
      %424 = arith.subi %425, %423 : i32
      %426 = arith.extsi %424 : i32 to i64
      func.return %426 : i64
    ^bb46:
      cf.br ^bb47
    ^bb47:
    %427 = arith.constant 1 : i32
    %429 = arith.extsi %427 : i32 to i64
    %428 = arith.addi %429, %407 : i64
    %430 = arith.constant 2 : i32
    %432 = arith.extsi %430 : i32 to i64
    %431 = arith.divsi %428, %432 : i64
    func.return %431 : i64
  }
  func.func @hash_key(%arg0: i64, %arg1: i64) -> i64 {
    %433 = arith.constant 1000000007 : i32
    %435 = arith.extsi %433 : i32 to i64
    %434 = arith.muli %arg0, %435 : i64
    %436 = arith.addi %434, %arg1 : i64
    %437 = arith.constant 32 : i32
    %439 = arith.extsi %437 : i32 to i64
    %438 = arith.shrsi %436, %439 : i64
    %440 = arith.constant -1 : i32
    %442 = arith.extsi %440 : i32 to i64
    %441 = arith.andi %436, %442 : i64
    %443 = arith.xori %441, %438 : i64
    %444 = llvm.mlir.addressof @HASH_MASK : !llvm.ptr
    %445 = llvm.load %444 : !llvm.ptr -> i64
    %446 = arith.andi %443, %445 : i64
    func.return %446 : i64
  }
  func.func @find_point(%arg0: i64, %arg1: i64) -> i64 {
    %447 = func.call @hash_key(%arg0, %arg1) : (i64, i64) -> i64
    %449 = llvm.mlir.addressof @hash_buckets : !llvm.ptr
    %450 = llvm.load %449 : !llvm.ptr -> !llvm.ptr
    %451 = llvm.getelementptr %450[%447] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    %448 = llvm.load %451 : !llvm.ptr -> i32
    %452 = arith.extsi %448 : i32 to i64
    %453 = llvm.mlir.constant(1 : i64) : i64
    %454 = llvm.alloca %453 x i64 : (i64) -> !llvm.ptr
    llvm.store %452, %454 : i64, !llvm.ptr
    cf.br ^bb48
    ^bb48:
    %455 = llvm.load %454 : !llvm.ptr -> i64
    %456 = arith.constant 1 : i32
    %458 = arith.constant 0 : i32
    %457 = arith.subi %458, %456 : i32
    %460 = arith.extsi %457 : i32 to i64
    %459 = arith.cmpi ne, %455, %460 : i64
    cf.cond_br %459, ^bb49, ^bb50
    ^bb49:
      %462 = llvm.mlir.addressof @pts_qx : !llvm.ptr
      %463 = llvm.load %462 : !llvm.ptr -> !llvm.ptr
      %464 = llvm.load %454 : !llvm.ptr -> i64
      %465 = llvm.getelementptr %463[%464] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %461 = llvm.load %465 : !llvm.ptr -> i64
      %466 = arith.cmpi eq, %461, %arg0 : i64
      %467 = scf.if %466 -> (i1) {
        %469 = llvm.mlir.addressof @pts_qy : !llvm.ptr
        %470 = llvm.load %469 : !llvm.ptr -> !llvm.ptr
        %471 = llvm.load %454 : !llvm.ptr -> i64
        %472 = llvm.getelementptr %470[%471] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %468 = llvm.load %472 : !llvm.ptr -> i64
        %473 = arith.cmpi eq, %468, %arg1 : i64
        scf.yield %473 : i1
      } else {
        %474 = arith.constant false
        scf.yield %474 : i1
      }
      cf.cond_br %467, ^bb51, ^bb52
      ^bb51:
        %475 = llvm.load %454 : !llvm.ptr -> i64
        func.return %475 : i64
      ^bb52:
        cf.br ^bb53
      ^bb53:
      %477 = llvm.mlir.addressof @hash_next : !llvm.ptr
      %478 = llvm.load %477 : !llvm.ptr -> !llvm.ptr
      %479 = llvm.load %454 : !llvm.ptr -> i64
      %480 = llvm.getelementptr %478[%479] : (!llvm.ptr, i64) -> !llvm.ptr, i32
      %476 = llvm.load %480 : !llvm.ptr -> i32
      %481 = arith.extsi %476 : i32 to i64
      llvm.store %481, %454 : i64, !llvm.ptr
      cf.br ^bb48
    ^bb50:
    %482 = arith.constant 1 : i32
    %484 = arith.constant 0 : i32
    %483 = arith.subi %484, %482 : i32
    %485 = arith.extsi %483 : i32 to i64
    func.return %485 : i64
  }
  func.func @add_point_fast(%arg0: i64, %arg1: i64) -> () {
    %486 = func.call @find_point(%arg0, %arg1) : (i64, i64) -> i64
    %487 = arith.constant 0 : i32
    %489 = arith.extsi %487 : i32 to i64
    %488 = arith.cmpi sge, %486, %489 : i64
    cf.cond_br %488, ^bb54, ^bb55
    ^bb54:
      %491 = llvm.mlir.addressof @pts_count : !llvm.ptr
      %492 = llvm.load %491 : !llvm.ptr -> !llvm.ptr
      %493 = llvm.getelementptr %492[%486] : (!llvm.ptr, i64) -> !llvm.ptr, i32
      %490 = llvm.load %493 : !llvm.ptr -> i32
      %494 = arith.constant 1 : i32
      %495 = arith.addi %490, %494 : i32
      %496 = llvm.mlir.addressof @pts_count : !llvm.ptr
      %497 = llvm.load %496 : !llvm.ptr -> !llvm.ptr
      %498 = llvm.getelementptr %497[%486] : (!llvm.ptr, i64) -> !llvm.ptr, i32
      llvm.store %495, %498 : i32, !llvm.ptr
      func.return
    ^bb55:
      cf.br ^bb56
    ^bb56:
    %499 = llvm.mlir.addressof @num_points : !llvm.ptr
    %500 = llvm.load %499 : !llvm.ptr -> i64
    %501 = llvm.mlir.addressof @num_points : !llvm.ptr
    %502 = llvm.load %501 : !llvm.ptr -> i64
    %503 = arith.constant 1 : i32
    %505 = arith.extsi %503 : i32 to i64
    %504 = arith.addi %502, %505 : i64
    %506 = llvm.mlir.addressof @num_points : !llvm.ptr
    llvm.store %504, %506 : i64, !llvm.ptr
    %507 = llvm.mlir.addressof @pts_qx : !llvm.ptr
    %508 = llvm.load %507 : !llvm.ptr -> !llvm.ptr
    %509 = llvm.getelementptr %508[%500] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    llvm.store %arg0, %509 : i64, !llvm.ptr
    %510 = llvm.mlir.addressof @pts_qy : !llvm.ptr
    %511 = llvm.load %510 : !llvm.ptr -> !llvm.ptr
    %512 = llvm.getelementptr %511[%500] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    llvm.store %arg1, %512 : i64, !llvm.ptr
    %513 = arith.constant 1 : i32
    %514 = llvm.mlir.addressof @pts_count : !llvm.ptr
    %515 = llvm.load %514 : !llvm.ptr -> !llvm.ptr
    %516 = llvm.getelementptr %515[%500] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    llvm.store %513, %516 : i32, !llvm.ptr
    %517 = func.call @hash_key(%arg0, %arg1) : (i64, i64) -> i64
    %519 = llvm.mlir.addressof @hash_buckets : !llvm.ptr
    %520 = llvm.load %519 : !llvm.ptr -> !llvm.ptr
    %521 = llvm.getelementptr %520[%517] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    %518 = llvm.load %521 : !llvm.ptr -> i32
    %522 = llvm.mlir.addressof @hash_next : !llvm.ptr
    %523 = llvm.load %522 : !llvm.ptr -> !llvm.ptr
    %524 = llvm.getelementptr %523[%500] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    llvm.store %518, %524 : i32, !llvm.ptr
    %525 = arith.trunci %500 : i64 to i32
    %526 = llvm.mlir.addressof @hash_buckets : !llvm.ptr
    %527 = llvm.load %526 : !llvm.ptr -> !llvm.ptr
    %528 = llvm.getelementptr %527[%517] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    llvm.store %525, %528 : i32, !llvm.ptr
    func.return
  }
  func.func @grid_key(%arg0: f64, %arg1: f64) -> i64 {
    %530 = arith.constant 0.000001 : f32
    %532 = arith.extf %530 : f32 to f64
    %531 = arith.divf %arg0, %532 : f64
    %529 = func.call @floor(%531) : (f64) -> f64
    %533 = arith.fptosi %529 : f64 to i64
    %535 = arith.constant 0.000001 : f32
    %537 = arith.extf %535 : f32 to f64
    %536 = arith.divf %arg1, %537 : f64
    %534 = func.call @floor(%536) : (f64) -> f64
    %538 = arith.fptosi %534 : f64 to i64
    %539 = arith.constant 1000000007 : i32
    %541 = arith.extsi %539 : i32 to i64
    %540 = arith.muli %533, %541 : i64
    %542 = arith.addi %540, %538 : i64
    %543 = arith.constant 32 : i32
    %545 = arith.extsi %543 : i32 to i64
    %544 = arith.shrsi %542, %545 : i64
    %546 = arith.constant -1 : i32
    %548 = arith.extsi %546 : i32 to i64
    %547 = arith.andi %542, %548 : i64
    %549 = arith.xori %547, %544 : i64
    %550 = llvm.mlir.addressof @HASH_MASK : !llvm.ptr
    %551 = llvm.load %550 : !llvm.ptr -> i64
    %552 = arith.andi %549, %551 : i64
    func.return %552 : i64
  }
  func.func @add_point_slow(%arg0: f64, %arg1: f64) -> () {
    %554 = arith.constant 0.000001 : f32
    %556 = arith.extf %554 : f32 to f64
    %555 = arith.divf %arg0, %556 : f64
    %553 = func.call @floor(%555) : (f64) -> f64
    %557 = arith.fptosi %553 : f64 to i64
    %559 = arith.constant 0.000001 : f32
    %561 = arith.extf %559 : f32 to f64
    %560 = arith.divf %arg1, %561 : f64
    %558 = func.call @floor(%560) : (f64) -> f64
    %562 = arith.fptosi %558 : f64 to i64
    %563 = arith.constant 1 : i32
    %565 = arith.constant 0 : i32
    %564 = arith.subi %565, %563 : i32
    %566 = arith.extsi %564 : i32 to i64
    %567 = llvm.mlir.constant(1 : i64) : i64
    %568 = llvm.alloca %567 x i64 : (i64) -> !llvm.ptr
    llvm.store %566, %568 : i64, !llvm.ptr
    cf.br ^bb57
    ^bb57:
    %569 = llvm.load %568 : !llvm.ptr -> i64
    %570 = arith.constant 1 : i32
    %572 = arith.extsi %570 : i32 to i64
    %571 = arith.cmpi sle, %569, %572 : i64
    cf.cond_br %571, ^bb58, ^bb59
    ^bb58:
      %573 = arith.constant 1 : i32
      %575 = arith.constant 0 : i32
      %574 = arith.subi %575, %573 : i32
      %576 = arith.extsi %574 : i32 to i64
      %577 = llvm.mlir.constant(1 : i64) : i64
      %578 = llvm.alloca %577 x i64 : (i64) -> !llvm.ptr
      llvm.store %576, %578 : i64, !llvm.ptr
      cf.br ^bb60
      ^bb60:
      %579 = llvm.load %578 : !llvm.ptr -> i64
      %580 = arith.constant 1 : i32
      %582 = arith.extsi %580 : i32 to i64
      %581 = arith.cmpi sle, %579, %582 : i64
      cf.cond_br %581, ^bb61, ^bb62
      ^bb61:
        %583 = llvm.load %568 : !llvm.ptr -> i64
        %584 = arith.addi %557, %583 : i64
        %585 = llvm.load %578 : !llvm.ptr -> i64
        %586 = arith.addi %562, %585 : i64
        %587 = arith.constant 1000000007 : i32
        %589 = arith.extsi %587 : i32 to i64
        %588 = arith.muli %584, %589 : i64
        %590 = arith.addi %588, %586 : i64
        %591 = arith.constant 32 : i32
        %593 = arith.extsi %591 : i32 to i64
        %592 = arith.shrsi %590, %593 : i64
        %594 = arith.constant -1 : i32
        %596 = arith.extsi %594 : i32 to i64
        %595 = arith.andi %590, %596 : i64
        %597 = arith.xori %595, %592 : i64
        %598 = llvm.mlir.addressof @HASH_MASK : !llvm.ptr
        %599 = llvm.load %598 : !llvm.ptr -> i64
        %600 = arith.andi %597, %599 : i64
        %602 = llvm.mlir.addressof @grid_buckets : !llvm.ptr
        %603 = llvm.load %602 : !llvm.ptr -> !llvm.ptr
        %604 = llvm.getelementptr %603[%600] : (!llvm.ptr, i64) -> !llvm.ptr, i32
        %601 = llvm.load %604 : !llvm.ptr -> i32
        %605 = arith.extsi %601 : i32 to i64
        %606 = llvm.mlir.constant(1 : i64) : i64
        %607 = llvm.alloca %606 x i64 : (i64) -> !llvm.ptr
        llvm.store %605, %607 : i64, !llvm.ptr
        cf.br ^bb63
        ^bb63:
        %608 = llvm.load %607 : !llvm.ptr -> i64
        %609 = arith.constant 1 : i32
        %611 = arith.constant 0 : i32
        %610 = arith.subi %611, %609 : i32
        %613 = arith.extsi %610 : i32 to i64
        %612 = arith.cmpi ne, %608, %613 : i64
        cf.cond_br %612, ^bb64, ^bb65
        ^bb64:
          %615 = llvm.mlir.addressof @reps_x : !llvm.ptr
          %616 = llvm.load %615 : !llvm.ptr -> !llvm.ptr
          %617 = llvm.load %607 : !llvm.ptr -> i64
          %618 = llvm.getelementptr %616[%617] : (!llvm.ptr, i64) -> !llvm.ptr, f64
          %614 = llvm.load %618 : !llvm.ptr -> f64
          %619 = arith.subf %arg0, %614 : f64
          %621 = llvm.mlir.addressof @reps_y : !llvm.ptr
          %622 = llvm.load %621 : !llvm.ptr -> !llvm.ptr
          %623 = llvm.load %607 : !llvm.ptr -> i64
          %624 = llvm.getelementptr %622[%623] : (!llvm.ptr, i64) -> !llvm.ptr, f64
          %620 = llvm.load %624 : !llvm.ptr -> f64
          %625 = arith.subf %arg1, %620 : f64
          %626 = arith.mulf %619, %619 : f64
          %627 = arith.mulf %625, %625 : f64
          %628 = arith.addf %626, %627 : f64
          %629 = arith.constant 0 : f32
          %631 = arith.extf %629 : f32 to f64
          %630 = arith.cmpf ole, %628, %631 : f64
          cf.cond_br %630, ^bb66, ^bb67
          ^bb66:
            %633 = llvm.mlir.addressof @reps_cnt : !llvm.ptr
            %634 = llvm.load %633 : !llvm.ptr -> !llvm.ptr
            %635 = llvm.load %607 : !llvm.ptr -> i64
            %636 = llvm.getelementptr %634[%635] : (!llvm.ptr, i64) -> !llvm.ptr, i32
            %632 = llvm.load %636 : !llvm.ptr -> i32
            %637 = arith.constant 1 : i32
            %638 = arith.addi %632, %637 : i32
            %639 = llvm.mlir.addressof @reps_cnt : !llvm.ptr
            %640 = llvm.load %639 : !llvm.ptr -> !llvm.ptr
            %641 = llvm.load %607 : !llvm.ptr -> i64
            %642 = llvm.getelementptr %640[%641] : (!llvm.ptr, i64) -> !llvm.ptr, i32
            llvm.store %638, %642 : i32, !llvm.ptr
            func.return
          ^bb67:
            cf.br ^bb68
          ^bb68:
          %644 = llvm.mlir.addressof @grid_next : !llvm.ptr
          %645 = llvm.load %644 : !llvm.ptr -> !llvm.ptr
          %646 = llvm.load %607 : !llvm.ptr -> i64
          %647 = llvm.getelementptr %645[%646] : (!llvm.ptr, i64) -> !llvm.ptr, i32
          %643 = llvm.load %647 : !llvm.ptr -> i32
          %648 = arith.extsi %643 : i32 to i64
          llvm.store %648, %607 : i64, !llvm.ptr
          cf.br ^bb63
        ^bb65:
        %649 = llvm.load %578 : !llvm.ptr -> i64
        %650 = arith.constant 1 : i32
        %652 = arith.extsi %650 : i32 to i64
        %651 = arith.addi %649, %652 : i64
        llvm.store %651, %578 : i64, !llvm.ptr
        cf.br ^bb60
      ^bb62:
      %653 = llvm.load %568 : !llvm.ptr -> i64
      %654 = arith.constant 1 : i32
      %656 = arith.extsi %654 : i32 to i64
      %655 = arith.addi %653, %656 : i64
      llvm.store %655, %568 : i64, !llvm.ptr
      cf.br ^bb57
    ^bb59:
    %657 = llvm.mlir.addressof @num_reps : !llvm.ptr
    %658 = llvm.load %657 : !llvm.ptr -> i64
    %659 = llvm.mlir.addressof @num_reps : !llvm.ptr
    %660 = llvm.load %659 : !llvm.ptr -> i64
    %661 = arith.constant 1 : i32
    %663 = arith.extsi %661 : i32 to i64
    %662 = arith.addi %660, %663 : i64
    %664 = llvm.mlir.addressof @num_reps : !llvm.ptr
    llvm.store %662, %664 : i64, !llvm.ptr
    %665 = llvm.mlir.addressof @reps_x : !llvm.ptr
    %666 = llvm.load %665 : !llvm.ptr -> !llvm.ptr
    %667 = llvm.getelementptr %666[%658] : (!llvm.ptr, i64) -> !llvm.ptr, f64
    llvm.store %arg0, %667 : f64, !llvm.ptr
    %668 = llvm.mlir.addressof @reps_y : !llvm.ptr
    %669 = llvm.load %668 : !llvm.ptr -> !llvm.ptr
    %670 = llvm.getelementptr %669[%658] : (!llvm.ptr, i64) -> !llvm.ptr, f64
    llvm.store %arg1, %670 : f64, !llvm.ptr
    %671 = arith.constant 1 : i32
    %672 = llvm.mlir.addressof @reps_cnt : !llvm.ptr
    %673 = llvm.load %672 : !llvm.ptr -> !llvm.ptr
    %674 = llvm.getelementptr %673[%658] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    llvm.store %671, %674 : i32, !llvm.ptr
    %675 = func.call @grid_key(%arg0, %arg1) : (f64, f64) -> i64
    %677 = llvm.mlir.addressof @grid_buckets : !llvm.ptr
    %678 = llvm.load %677 : !llvm.ptr -> !llvm.ptr
    %679 = llvm.getelementptr %678[%675] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    %676 = llvm.load %679 : !llvm.ptr -> i32
    %680 = llvm.mlir.addressof @grid_next : !llvm.ptr
    %681 = llvm.load %680 : !llvm.ptr -> !llvm.ptr
    %682 = llvm.getelementptr %681[%658] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    llvm.store %676, %682 : i32, !llvm.ptr
    %683 = arith.trunci %658 : i64 to i32
    %684 = llvm.mlir.addressof @grid_buckets : !llvm.ptr
    %685 = llvm.load %684 : !llvm.ptr -> !llvm.ptr
    %686 = llvm.getelementptr %685[%675] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    llvm.store %683, %686 : i32, !llvm.ptr
    func.return
  }
  func.func @compute_points_fast(%arg0: i64, %arg1: !llvm.ptr, %arg2: !llvm.ptr) -> i32 {
    %687 = arith.constant 0 : i32
    %688 = arith.extsi %687 : i32 to i64
    %689 = llvm.mlir.addressof @num_points : !llvm.ptr
    llvm.store %688, %689 : i64, !llvm.ptr
    %690 = arith.constant 0 : i32
    %691 = arith.extsi %690 : i32 to i64
    %692 = llvm.mlir.constant(1 : i64) : i64
    %693 = llvm.alloca %692 x i64 : (i64) -> !llvm.ptr
    llvm.store %691, %693 : i64, !llvm.ptr
    cf.br ^bb69
    ^bb69:
    %694 = llvm.load %693 : !llvm.ptr -> i64
    %695 = llvm.mlir.addressof @HASH_SIZE : !llvm.ptr
    %696 = llvm.load %695 : !llvm.ptr -> i64
    %697 = arith.cmpi slt, %694, %696 : i64
    cf.cond_br %697, ^bb70, ^bb71
    ^bb70:
      %698 = arith.constant 1 : i32
      %700 = arith.constant 0 : i32
      %699 = arith.subi %700, %698 : i32
      %701 = llvm.mlir.addressof @hash_buckets : !llvm.ptr
      %702 = llvm.load %701 : !llvm.ptr -> !llvm.ptr
      %703 = llvm.load %693 : !llvm.ptr -> i64
      %704 = llvm.getelementptr %702[%703] : (!llvm.ptr, i64) -> !llvm.ptr, i32
      llvm.store %699, %704 : i32, !llvm.ptr
      %705 = llvm.load %693 : !llvm.ptr -> i64
      %706 = arith.constant 1 : i32
      %708 = arith.extsi %706 : i32 to i64
      %707 = arith.addi %705, %708 : i64
      llvm.store %707, %693 : i64, !llvm.ptr
      cf.br ^bb69
    ^bb71:
    %709 = arith.constant 0 : i32
    %710 = arith.extsi %709 : i32 to i64
    %711 = llvm.mlir.constant(1 : i64) : i64
    %712 = llvm.alloca %711 x i64 : (i64) -> !llvm.ptr
    llvm.store %710, %712 : i64, !llvm.ptr
    cf.br ^bb72
    ^bb72:
    %713 = llvm.load %712 : !llvm.ptr -> i64
    %714 = arith.constant 3 : i32
    %716 = arith.extsi %714 : i32 to i64
    %715 = arith.subi %arg0, %716 : i64
    %717 = arith.cmpi slt, %713, %715 : i64
    cf.cond_br %717, ^bb73, ^bb74
    ^bb73:
      %719 = llvm.load %712 : !llvm.ptr -> i64
      %720 = llvm.getelementptr %arg1[%719] : (!llvm.ptr, i64) -> !llvm.ptr, f64
      %718 = llvm.load %720 : !llvm.ptr -> f64
      %722 = llvm.load %712 : !llvm.ptr -> i64
      %723 = llvm.getelementptr %arg2[%722] : (!llvm.ptr, i64) -> !llvm.ptr, f64
      %721 = llvm.load %723 : !llvm.ptr -> f64
      %724 = llvm.load %712 : !llvm.ptr -> i64
      %725 = arith.constant 1 : i32
      %727 = arith.extsi %725 : i32 to i64
      %726 = arith.addi %724, %727 : i64
      %728 = llvm.mlir.constant(1 : i64) : i64
      %729 = llvm.alloca %728 x i64 : (i64) -> !llvm.ptr
      llvm.store %726, %729 : i64, !llvm.ptr
      cf.br ^bb75
      ^bb75:
      %730 = llvm.load %729 : !llvm.ptr -> i64
      %731 = arith.constant 2 : i32
      %733 = arith.extsi %731 : i32 to i64
      %732 = arith.subi %arg0, %733 : i64
      %734 = arith.cmpi slt, %730, %732 : i64
      cf.cond_br %734, ^bb76, ^bb77
      ^bb76:
        %736 = llvm.load %729 : !llvm.ptr -> i64
        %737 = llvm.getelementptr %arg1[%736] : (!llvm.ptr, i64) -> !llvm.ptr, f64
        %735 = llvm.load %737 : !llvm.ptr -> f64
        %739 = llvm.load %729 : !llvm.ptr -> i64
        %740 = llvm.getelementptr %arg2[%739] : (!llvm.ptr, i64) -> !llvm.ptr, f64
        %738 = llvm.load %740 : !llvm.ptr -> f64
        %741 = arith.subf %735, %718 : f64
        %742 = arith.subf %738, %721 : f64
        %743 = llvm.load %729 : !llvm.ptr -> i64
        %744 = arith.constant 1 : i32
        %746 = arith.extsi %744 : i32 to i64
        %745 = arith.addi %743, %746 : i64
        %747 = llvm.mlir.constant(1 : i64) : i64
        %748 = llvm.alloca %747 x i64 : (i64) -> !llvm.ptr
        llvm.store %745, %748 : i64, !llvm.ptr
        cf.br ^bb78
        ^bb78:
        %749 = llvm.load %748 : !llvm.ptr -> i64
        %750 = arith.constant 1 : i32
        %752 = arith.extsi %750 : i32 to i64
        %751 = arith.subi %arg0, %752 : i64
        %753 = arith.cmpi slt, %749, %751 : i64
        cf.cond_br %753, ^bb79, ^bb80
        ^bb79:
          %755 = llvm.load %748 : !llvm.ptr -> i64
          %756 = llvm.getelementptr %arg1[%755] : (!llvm.ptr, i64) -> !llvm.ptr, f64
          %754 = llvm.load %756 : !llvm.ptr -> f64
          %758 = llvm.load %748 : !llvm.ptr -> i64
          %759 = llvm.getelementptr %arg2[%758] : (!llvm.ptr, i64) -> !llvm.ptr, f64
          %757 = llvm.load %759 : !llvm.ptr -> f64
          %760 = arith.subf %754, %718 : f64
          %761 = arith.subf %757, %721 : f64
          %762 = llvm.load %748 : !llvm.ptr -> i64
          %763 = arith.constant 1 : i32
          %765 = arith.extsi %763 : i32 to i64
          %764 = arith.addi %762, %765 : i64
          %766 = llvm.mlir.constant(1 : i64) : i64
          %767 = llvm.alloca %766 x i64 : (i64) -> !llvm.ptr
          llvm.store %764, %767 : i64, !llvm.ptr
          cf.br ^bb81
          ^bb81:
          %768 = llvm.load %767 : !llvm.ptr -> i64
          %769 = arith.cmpi slt, %768, %arg0 : i64
          cf.cond_br %769, ^bb82, ^bb83
          ^bb82:
            %771 = llvm.load %767 : !llvm.ptr -> i64
            %772 = llvm.getelementptr %arg1[%771] : (!llvm.ptr, i64) -> !llvm.ptr, f64
            %770 = llvm.load %772 : !llvm.ptr -> f64
            %774 = llvm.load %767 : !llvm.ptr -> i64
            %775 = llvm.getelementptr %arg2[%774] : (!llvm.ptr, i64) -> !llvm.ptr, f64
            %773 = llvm.load %775 : !llvm.ptr -> f64
            %776 = arith.subf %770, %735 : f64
            %777 = arith.subf %773, %738 : f64
            %778 = arith.mulf %760, %777 : f64
            %779 = arith.mulf %761, %776 : f64
            %780 = arith.subf %778, %779 : f64
            %781 = math.absf %780 : f64
            %782 = arith.constant 0 : f32
            %784 = arith.extf %782 : f32 to f64
            %783 = arith.cmpf olt, %781, %784 : f64
            cf.cond_br %783, ^bb84, ^bb85
            ^bb84:
              %785 = llvm.load %767 : !llvm.ptr -> i64
              %786 = arith.constant 1 : i32
              %788 = arith.extsi %786 : i32 to i64
              %787 = arith.addi %785, %788 : i64
              llvm.store %787, %767 : i64, !llvm.ptr
              cf.br ^bb81
            ^bb85:
              cf.br ^bb86
            ^bb86:
            %789 = arith.mulf %741, %777 : f64
            %790 = arith.mulf %742, %776 : f64
            %791 = arith.subf %789, %790 : f64
            %792 = arith.divf %791, %780 : f64
            %793 = arith.mulf %792, %760 : f64
            %794 = arith.addf %718, %793 : f64
            %795 = arith.mulf %792, %761 : f64
            %796 = arith.addf %721, %795 : f64
            %798 = llvm.mlir.addressof @SCALE : !llvm.ptr
            %799 = llvm.load %798 : !llvm.ptr -> i64
            %800 = arith.sitofp %799 : i64 to f64
            %801 = arith.mulf %794, %800 : f64
            %797 = func.call @llround(%801) : (f64) -> i64
            %803 = llvm.mlir.addressof @SCALE : !llvm.ptr
            %804 = llvm.load %803 : !llvm.ptr -> i64
            %805 = arith.sitofp %804 : i64 to f64
            %806 = arith.mulf %796, %805 : f64
            %802 = func.call @llround(%806) : (f64) -> i64
            func.call @add_point_fast(%797, %802) : (i64, i64) -> ()
            %808 = llvm.load %767 : !llvm.ptr -> i64
            %809 = arith.constant 1 : i32
            %811 = arith.extsi %809 : i32 to i64
            %810 = arith.addi %808, %811 : i64
            llvm.store %810, %767 : i64, !llvm.ptr
            cf.br ^bb81
          ^bb83:
          %812 = llvm.load %748 : !llvm.ptr -> i64
          %813 = arith.constant 1 : i32
          %815 = arith.extsi %813 : i32 to i64
          %814 = arith.addi %812, %815 : i64
          llvm.store %814, %748 : i64, !llvm.ptr
          cf.br ^bb78
        ^bb80:
        %816 = llvm.load %729 : !llvm.ptr -> i64
        %817 = arith.constant 1 : i32
        %819 = arith.extsi %817 : i32 to i64
        %818 = arith.addi %816, %819 : i64
        llvm.store %818, %729 : i64, !llvm.ptr
        cf.br ^bb75
      ^bb77:
      %820 = llvm.load %712 : !llvm.ptr -> i64
      %821 = arith.constant 1 : i32
      %823 = arith.extsi %821 : i32 to i64
      %822 = arith.addi %820, %823 : i64
      llvm.store %822, %712 : i64, !llvm.ptr
      cf.br ^bb72
    ^bb74:
    %824 = arith.constant 0 : i32
    %825 = arith.extsi %824 : i32 to i64
    llvm.store %825, %693 : i64, !llvm.ptr
    cf.br ^bb87
    ^bb87:
    %826 = llvm.load %693 : !llvm.ptr -> i64
    %827 = llvm.mlir.addressof @num_points : !llvm.ptr
    %828 = llvm.load %827 : !llvm.ptr -> i64
    %829 = arith.cmpi slt, %826, %828 : i64
    cf.cond_br %829, ^bb88, ^bb89
    ^bb88:
      %832 = llvm.mlir.addressof @pts_count : !llvm.ptr
      %833 = llvm.load %832 : !llvm.ptr -> !llvm.ptr
      %834 = llvm.load %693 : !llvm.ptr -> i64
      %835 = llvm.getelementptr %833[%834] : (!llvm.ptr, i64) -> !llvm.ptr, i32
      %831 = llvm.load %835 : !llvm.ptr -> i32
      %836 = arith.extsi %831 : i32 to i64
      %830 = func.call @inv_triangular(%836) : (i64) -> i64
      %837 = arith.constant 0 : i32
      %839 = arith.extsi %837 : i32 to i64
      %838 = arith.cmpi slt, %830, %839 : i64
      cf.cond_br %838, ^bb90, ^bb91
      ^bb90:
        %840 = arith.constant 0 : i32
        func.return %840 : i32
      ^bb91:
        cf.br ^bb92
      ^bb92:
      %841 = llvm.load %693 : !llvm.ptr -> i64
      %842 = arith.constant 1 : i32
      %844 = arith.extsi %842 : i32 to i64
      %843 = arith.addi %841, %844 : i64
      llvm.store %843, %693 : i64, !llvm.ptr
      cf.br ^bb87
    ^bb89:
    %845 = arith.constant 1 : i32
    func.return %845 : i32
  }
  func.func @compute_points_slow(%arg0: i64, %arg1: !llvm.ptr, %arg2: !llvm.ptr) -> () {
    %846 = arith.constant 0 : i32
    %847 = arith.extsi %846 : i32 to i64
    %848 = llvm.mlir.addressof @num_reps : !llvm.ptr
    llvm.store %847, %848 : i64, !llvm.ptr
    %849 = arith.constant 0 : i32
    %850 = arith.extsi %849 : i32 to i64
    %851 = llvm.mlir.constant(1 : i64) : i64
    %852 = llvm.alloca %851 x i64 : (i64) -> !llvm.ptr
    llvm.store %850, %852 : i64, !llvm.ptr
    cf.br ^bb93
    ^bb93:
    %853 = llvm.load %852 : !llvm.ptr -> i64
    %854 = llvm.mlir.addressof @HASH_SIZE : !llvm.ptr
    %855 = llvm.load %854 : !llvm.ptr -> i64
    %856 = arith.cmpi slt, %853, %855 : i64
    cf.cond_br %856, ^bb94, ^bb95
    ^bb94:
      %857 = arith.constant 1 : i32
      %859 = arith.constant 0 : i32
      %858 = arith.subi %859, %857 : i32
      %860 = llvm.mlir.addressof @grid_buckets : !llvm.ptr
      %861 = llvm.load %860 : !llvm.ptr -> !llvm.ptr
      %862 = llvm.load %852 : !llvm.ptr -> i64
      %863 = llvm.getelementptr %861[%862] : (!llvm.ptr, i64) -> !llvm.ptr, i32
      llvm.store %858, %863 : i32, !llvm.ptr
      %864 = llvm.load %852 : !llvm.ptr -> i64
      %865 = arith.constant 1 : i32
      %867 = arith.extsi %865 : i32 to i64
      %866 = arith.addi %864, %867 : i64
      llvm.store %866, %852 : i64, !llvm.ptr
      cf.br ^bb93
    ^bb95:
    %868 = arith.constant 0 : i32
    %869 = arith.extsi %868 : i32 to i64
    %870 = llvm.mlir.constant(1 : i64) : i64
    %871 = llvm.alloca %870 x i64 : (i64) -> !llvm.ptr
    llvm.store %869, %871 : i64, !llvm.ptr
    cf.br ^bb96
    ^bb96:
    %872 = llvm.load %871 : !llvm.ptr -> i64
    %873 = arith.constant 3 : i32
    %875 = arith.extsi %873 : i32 to i64
    %874 = arith.subi %arg0, %875 : i64
    %876 = arith.cmpi slt, %872, %874 : i64
    cf.cond_br %876, ^bb97, ^bb98
    ^bb97:
      %878 = llvm.load %871 : !llvm.ptr -> i64
      %879 = llvm.getelementptr %arg1[%878] : (!llvm.ptr, i64) -> !llvm.ptr, f64
      %877 = llvm.load %879 : !llvm.ptr -> f64
      %881 = llvm.load %871 : !llvm.ptr -> i64
      %882 = llvm.getelementptr %arg2[%881] : (!llvm.ptr, i64) -> !llvm.ptr, f64
      %880 = llvm.load %882 : !llvm.ptr -> f64
      %883 = llvm.load %871 : !llvm.ptr -> i64
      %884 = arith.constant 1 : i32
      %886 = arith.extsi %884 : i32 to i64
      %885 = arith.addi %883, %886 : i64
      %887 = llvm.mlir.constant(1 : i64) : i64
      %888 = llvm.alloca %887 x i64 : (i64) -> !llvm.ptr
      llvm.store %885, %888 : i64, !llvm.ptr
      cf.br ^bb99
      ^bb99:
      %889 = llvm.load %888 : !llvm.ptr -> i64
      %890 = arith.constant 2 : i32
      %892 = arith.extsi %890 : i32 to i64
      %891 = arith.subi %arg0, %892 : i64
      %893 = arith.cmpi slt, %889, %891 : i64
      cf.cond_br %893, ^bb100, ^bb101
      ^bb100:
        %895 = llvm.load %888 : !llvm.ptr -> i64
        %896 = llvm.getelementptr %arg1[%895] : (!llvm.ptr, i64) -> !llvm.ptr, f64
        %894 = llvm.load %896 : !llvm.ptr -> f64
        %898 = llvm.load %888 : !llvm.ptr -> i64
        %899 = llvm.getelementptr %arg2[%898] : (!llvm.ptr, i64) -> !llvm.ptr, f64
        %897 = llvm.load %899 : !llvm.ptr -> f64
        %900 = arith.subf %894, %877 : f64
        %901 = arith.subf %897, %880 : f64
        %902 = llvm.load %888 : !llvm.ptr -> i64
        %903 = arith.constant 1 : i32
        %905 = arith.extsi %903 : i32 to i64
        %904 = arith.addi %902, %905 : i64
        %906 = llvm.mlir.constant(1 : i64) : i64
        %907 = llvm.alloca %906 x i64 : (i64) -> !llvm.ptr
        llvm.store %904, %907 : i64, !llvm.ptr
        cf.br ^bb102
        ^bb102:
        %908 = llvm.load %907 : !llvm.ptr -> i64
        %909 = arith.constant 1 : i32
        %911 = arith.extsi %909 : i32 to i64
        %910 = arith.subi %arg0, %911 : i64
        %912 = arith.cmpi slt, %908, %910 : i64
        cf.cond_br %912, ^bb103, ^bb104
        ^bb103:
          %914 = llvm.load %907 : !llvm.ptr -> i64
          %915 = llvm.getelementptr %arg1[%914] : (!llvm.ptr, i64) -> !llvm.ptr, f64
          %913 = llvm.load %915 : !llvm.ptr -> f64
          %917 = llvm.load %907 : !llvm.ptr -> i64
          %918 = llvm.getelementptr %arg2[%917] : (!llvm.ptr, i64) -> !llvm.ptr, f64
          %916 = llvm.load %918 : !llvm.ptr -> f64
          %919 = arith.subf %913, %877 : f64
          %920 = arith.subf %916, %880 : f64
          %921 = llvm.load %907 : !llvm.ptr -> i64
          %922 = arith.constant 1 : i32
          %924 = arith.extsi %922 : i32 to i64
          %923 = arith.addi %921, %924 : i64
          %925 = llvm.mlir.constant(1 : i64) : i64
          %926 = llvm.alloca %925 x i64 : (i64) -> !llvm.ptr
          llvm.store %923, %926 : i64, !llvm.ptr
          cf.br ^bb105
          ^bb105:
          %927 = llvm.load %926 : !llvm.ptr -> i64
          %928 = arith.cmpi slt, %927, %arg0 : i64
          cf.cond_br %928, ^bb106, ^bb107
          ^bb106:
            %930 = llvm.load %926 : !llvm.ptr -> i64
            %931 = llvm.getelementptr %arg1[%930] : (!llvm.ptr, i64) -> !llvm.ptr, f64
            %929 = llvm.load %931 : !llvm.ptr -> f64
            %933 = llvm.load %926 : !llvm.ptr -> i64
            %934 = llvm.getelementptr %arg2[%933] : (!llvm.ptr, i64) -> !llvm.ptr, f64
            %932 = llvm.load %934 : !llvm.ptr -> f64
            %935 = arith.subf %929, %894 : f64
            %936 = arith.subf %932, %897 : f64
            %937 = arith.mulf %919, %936 : f64
            %938 = arith.mulf %920, %935 : f64
            %939 = arith.subf %937, %938 : f64
            %940 = math.absf %939 : f64
            %941 = arith.constant 0 : f32
            %943 = arith.extf %941 : f32 to f64
            %942 = arith.cmpf olt, %940, %943 : f64
            cf.cond_br %942, ^bb108, ^bb109
            ^bb108:
              %944 = llvm.load %926 : !llvm.ptr -> i64
              %945 = arith.constant 1 : i32
              %947 = arith.extsi %945 : i32 to i64
              %946 = arith.addi %944, %947 : i64
              llvm.store %946, %926 : i64, !llvm.ptr
              cf.br ^bb105
            ^bb109:
              cf.br ^bb110
            ^bb110:
            %948 = arith.mulf %900, %936 : f64
            %949 = arith.mulf %901, %935 : f64
            %950 = arith.subf %948, %949 : f64
            %951 = arith.divf %950, %939 : f64
            %952 = arith.mulf %951, %919 : f64
            %953 = arith.addf %877, %952 : f64
            %954 = arith.mulf %951, %920 : f64
            %955 = arith.addf %880, %954 : f64
            func.call @add_point_slow(%953, %955) : (f64, f64) -> ()
            %957 = llvm.load %926 : !llvm.ptr -> i64
            %958 = arith.constant 1 : i32
            %960 = arith.extsi %958 : i32 to i64
            %959 = arith.addi %957, %960 : i64
            llvm.store %959, %926 : i64, !llvm.ptr
            cf.br ^bb105
          ^bb107:
          %961 = llvm.load %907 : !llvm.ptr -> i64
          %962 = arith.constant 1 : i32
          %964 = arith.extsi %962 : i32 to i64
          %963 = arith.addi %961, %964 : i64
          llvm.store %963, %907 : i64, !llvm.ptr
          cf.br ^bb102
        ^bb104:
        %965 = llvm.load %888 : !llvm.ptr -> i64
        %966 = arith.constant 1 : i32
        %968 = arith.extsi %966 : i32 to i64
        %967 = arith.addi %965, %968 : i64
        llvm.store %967, %888 : i64, !llvm.ptr
        cf.br ^bb99
      ^bb101:
      %969 = llvm.load %871 : !llvm.ptr -> i64
      %970 = arith.constant 1 : i32
      %972 = arith.extsi %970 : i32 to i64
      %971 = arith.addi %969, %972 : i64
      llvm.store %971, %871 : i64, !llvm.ptr
      cf.br ^bb96
    ^bb98:
    func.return
  }
  func.func @T_mod(%arg0: i64) -> i64 {
    %973 = arith.constant 4 : i32
    %975 = arith.extsi %973 : i32 to i64
    %974 = arith.cmpi slt, %arg0, %975 : i64
    cf.cond_br %974, ^bb111, ^bb112
    ^bb111:
      %976 = arith.constant 0 : i32
      %977 = arith.extsi %976 : i32 to i64
      func.return %977 : i64
    ^bb112:
      cf.br ^bb113
    ^bb113:
    %978 = arith.constant 2.0 : f32
    %979 = arith.constant 3.14159265358979323846 : f32
    %980 = arith.mulf %978, %979 : f32
    %981 = arith.extf %980 : f32 to f64
    %983 = arith.constant 60 : i32
    %984 = arith.constant 8 : i32
    %985 = arith.extsi %983 : i32 to i64
    %986 = arith.extsi %984 : i32 to i64
    %982 = func.call @calloc(%985, %986) : (i64, i64) -> !llvm.ptr
    %988 = arith.constant 60 : i32
    %989 = arith.constant 8 : i32
    %990 = arith.extsi %988 : i32 to i64
    %991 = arith.extsi %989 : i32 to i64
    %987 = func.call @calloc(%990, %991) : (i64, i64) -> !llvm.ptr
    %992 = arith.constant 0 : i32
    %993 = arith.extsi %992 : i32 to i64
    %994 = llvm.mlir.constant(1 : i64) : i64
    %995 = llvm.alloca %994 x i64 : (i64) -> !llvm.ptr
    llvm.store %993, %995 : i64, !llvm.ptr
    cf.br ^bb114
    ^bb114:
    %996 = llvm.load %995 : !llvm.ptr -> i64
    %997 = arith.cmpi slt, %996, %arg0 : i64
    cf.cond_br %997, ^bb115, ^bb116
    ^bb115:
      %998 = llvm.load %995 : !llvm.ptr -> i64
      %999 = arith.sitofp %998 : i64 to f64
      %1000 = arith.mulf %981, %999 : f64
      %1001 = arith.sitofp %arg0 : i64 to f64
      %1002 = arith.divf %1000, %1001 : f64
      %1003 = math.cos %1002 : f64
      %1004 = llvm.load %995 : !llvm.ptr -> i64
      %1005 = llvm.getelementptr %982[%1004] : (!llvm.ptr, i64) -> !llvm.ptr, f64
      llvm.store %1003, %1005 : f64, !llvm.ptr
      %1006 = llvm.load %995 : !llvm.ptr -> i64
      %1007 = arith.sitofp %1006 : i64 to f64
      %1008 = arith.mulf %981, %1007 : f64
      %1009 = arith.sitofp %arg0 : i64 to f64
      %1010 = arith.divf %1008, %1009 : f64
      %1011 = math.sin %1010 : f64
      %1012 = llvm.load %995 : !llvm.ptr -> i64
      %1013 = llvm.getelementptr %987[%1012] : (!llvm.ptr, i64) -> !llvm.ptr, f64
      llvm.store %1011, %1013 : f64, !llvm.ptr
      %1014 = llvm.load %995 : !llvm.ptr -> i64
      %1015 = arith.constant 1 : i32
      %1017 = arith.extsi %1015 : i32 to i64
      %1016 = arith.addi %1014, %1017 : i64
      llvm.store %1016, %995 : i64, !llvm.ptr
      cf.br ^bb114
    ^bb116:
    %1019 = arith.constant 100 : i32
    %1020 = arith.constant 8 : i32
    %1021 = arith.extsi %1019 : i32 to i64
    %1022 = arith.extsi %1020 : i32 to i64
    %1018 = func.call @calloc(%1021, %1022) : (i64, i64) -> !llvm.ptr
    %1024 = arith.constant 100 : i32
    %1025 = arith.constant 8 : i32
    %1026 = arith.extsi %1024 : i32 to i64
    %1027 = arith.extsi %1025 : i32 to i64
    %1023 = func.call @calloc(%1026, %1027) : (i64, i64) -> !llvm.ptr
    %1028 = arith.constant 0 : i32
    %1029 = arith.extsi %1028 : i32 to i64
    %1030 = llvm.mlir.constant(1 : i64) : i64
    %1031 = llvm.alloca %1030 x i64 : (i64) -> !llvm.ptr
    llvm.store %1029, %1031 : i64, !llvm.ptr
    %1032 = func.call @compute_points_fast(%arg0, %982, %987) : (i64, !llvm.ptr, !llvm.ptr) -> i32
    %1033 = arith.constant 0 : i32
    %1034 = arith.cmpi ne, %1032, %1033 : i32
    cf.cond_br %1034, ^bb117, ^bb118
    ^bb117:
      %1035 = arith.constant 0 : i32
      %1036 = arith.extsi %1035 : i32 to i64
      %1037 = llvm.mlir.constant(1 : i64) : i64
      %1038 = llvm.alloca %1037 x i64 : (i64) -> !llvm.ptr
      llvm.store %1036, %1038 : i64, !llvm.ptr
      cf.br ^bb120
      ^bb120:
      %1039 = llvm.load %1038 : !llvm.ptr -> i64
      %1040 = llvm.mlir.addressof @num_points : !llvm.ptr
      %1041 = llvm.load %1040 : !llvm.ptr -> i64
      %1042 = arith.cmpi slt, %1039, %1041 : i64
      cf.cond_br %1042, ^bb121, ^bb122
      ^bb121:
        %1045 = llvm.mlir.addressof @pts_count : !llvm.ptr
        %1046 = llvm.load %1045 : !llvm.ptr -> !llvm.ptr
        %1047 = llvm.load %1038 : !llvm.ptr -> i64
        %1048 = llvm.getelementptr %1046[%1047] : (!llvm.ptr, i64) -> !llvm.ptr, i32
        %1044 = llvm.load %1048 : !llvm.ptr -> i32
        %1049 = arith.extsi %1044 : i32 to i64
        %1043 = func.call @inv_triangular(%1049) : (i64) -> i64
        %1050 = arith.constant 1 : i32
        %1052 = arith.constant 0 : i32
        %1051 = arith.subi %1052, %1050 : i32
        %1053 = arith.extsi %1051 : i32 to i64
        %1054 = llvm.mlir.constant(1 : i64) : i64
        %1055 = llvm.alloca %1054 x i64 : (i64) -> !llvm.ptr
        llvm.store %1053, %1055 : i64, !llvm.ptr
        %1056 = arith.constant 0 : i32
        %1057 = arith.extsi %1056 : i32 to i64
        %1058 = llvm.mlir.constant(1 : i64) : i64
        %1059 = llvm.alloca %1058 x i64 : (i64) -> !llvm.ptr
        llvm.store %1057, %1059 : i64, !llvm.ptr
        cf.br ^bb123
        ^bb123:
        %1060 = llvm.load %1059 : !llvm.ptr -> i64
        %1061 = llvm.load %1031 : !llvm.ptr -> i64
        %1062 = arith.cmpi slt, %1060, %1061 : i64
        cf.cond_br %1062, ^bb124, ^bb125
        ^bb124:
          %1064 = llvm.load %1059 : !llvm.ptr -> i64
          %1065 = llvm.getelementptr %1018[%1064] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          %1063 = llvm.load %1065 : !llvm.ptr -> i64
          %1066 = arith.cmpi eq, %1063, %1043 : i64
          cf.cond_br %1066, ^bb126, ^bb127
          ^bb126:
            %1067 = llvm.load %1059 : !llvm.ptr -> i64
            llvm.store %1067, %1055 : i64, !llvm.ptr
            cf.br ^bb125
          ^bb127:
            cf.br ^bb128
          ^bb128:
          %1068 = llvm.load %1059 : !llvm.ptr -> i64
          %1069 = arith.constant 1 : i32
          %1071 = arith.extsi %1069 : i32 to i64
          %1070 = arith.addi %1068, %1071 : i64
          llvm.store %1070, %1059 : i64, !llvm.ptr
          cf.br ^bb123
        ^bb125:
        %1072 = llvm.load %1055 : !llvm.ptr -> i64
        %1073 = arith.constant 0 : i32
        %1075 = arith.extsi %1073 : i32 to i64
        %1074 = arith.cmpi slt, %1072, %1075 : i64
        cf.cond_br %1074, ^bb129, ^bb130
        ^bb129:
          %1076 = llvm.load %1031 : !llvm.ptr -> i64
          %1077 = llvm.getelementptr %1018[%1076] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          llvm.store %1043, %1077 : i64, !llvm.ptr
          %1078 = arith.constant 1 : i32
          %1079 = llvm.load %1031 : !llvm.ptr -> i64
          %1080 = arith.extsi %1078 : i32 to i64
          %1081 = llvm.getelementptr %1023[%1079] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          llvm.store %1080, %1081 : i64, !llvm.ptr
          %1082 = llvm.load %1031 : !llvm.ptr -> i64
          %1083 = arith.constant 1 : i32
          %1085 = arith.extsi %1083 : i32 to i64
          %1084 = arith.addi %1082, %1085 : i64
          llvm.store %1084, %1031 : i64, !llvm.ptr
          cf.br ^bb131
        ^bb130:
          %1087 = llvm.load %1055 : !llvm.ptr -> i64
          %1088 = llvm.getelementptr %1023[%1087] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          %1086 = llvm.load %1088 : !llvm.ptr -> i64
          %1089 = arith.constant 1 : i32
          %1091 = arith.extsi %1089 : i32 to i64
          %1090 = arith.addi %1086, %1091 : i64
          %1092 = llvm.load %1055 : !llvm.ptr -> i64
          %1093 = llvm.getelementptr %1023[%1092] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          llvm.store %1090, %1093 : i64, !llvm.ptr
          cf.br ^bb131
        ^bb131:
        %1094 = llvm.load %1038 : !llvm.ptr -> i64
        %1095 = arith.constant 1 : i32
        %1097 = arith.extsi %1095 : i32 to i64
        %1096 = arith.addi %1094, %1097 : i64
        llvm.store %1096, %1038 : i64, !llvm.ptr
        cf.br ^bb120
      ^bb122:
      cf.br ^bb119
    ^bb118:
      func.call @compute_points_slow(%arg0, %982, %987) : (i64, !llvm.ptr, !llvm.ptr) -> ()
      %1099 = arith.constant 0 : i32
      %1100 = arith.extsi %1099 : i32 to i64
      %1101 = llvm.mlir.constant(1 : i64) : i64
      %1102 = llvm.alloca %1101 x i64 : (i64) -> !llvm.ptr
      llvm.store %1100, %1102 : i64, !llvm.ptr
      cf.br ^bb132
      ^bb132:
      %1103 = llvm.load %1102 : !llvm.ptr -> i64
      %1104 = llvm.mlir.addressof @num_reps : !llvm.ptr
      %1105 = llvm.load %1104 : !llvm.ptr -> i64
      %1106 = arith.cmpi slt, %1103, %1105 : i64
      cf.cond_br %1106, ^bb133, ^bb134
      ^bb133:
        %1109 = llvm.mlir.addressof @reps_cnt : !llvm.ptr
        %1110 = llvm.load %1109 : !llvm.ptr -> !llvm.ptr
        %1111 = llvm.load %1102 : !llvm.ptr -> i64
        %1112 = llvm.getelementptr %1110[%1111] : (!llvm.ptr, i64) -> !llvm.ptr, i32
        %1108 = llvm.load %1112 : !llvm.ptr -> i32
        %1113 = arith.extsi %1108 : i32 to i64
        %1107 = func.call @inv_triangular(%1113) : (i64) -> i64
        %1114 = arith.constant 0 : i32
        %1116 = arith.extsi %1114 : i32 to i64
        %1115 = arith.cmpi slt, %1107, %1116 : i64
        cf.cond_br %1115, ^bb135, ^bb136
        ^bb135:
          %1117 = llvm.load %1102 : !llvm.ptr -> i64
          %1118 = arith.constant 1 : i32
          %1120 = arith.extsi %1118 : i32 to i64
          %1119 = arith.addi %1117, %1120 : i64
          llvm.store %1119, %1102 : i64, !llvm.ptr
          cf.br ^bb132
        ^bb136:
          cf.br ^bb137
        ^bb137:
        %1121 = arith.constant 1 : i32
        %1123 = arith.constant 0 : i32
        %1122 = arith.subi %1123, %1121 : i32
        %1124 = arith.extsi %1122 : i32 to i64
        %1125 = llvm.mlir.constant(1 : i64) : i64
        %1126 = llvm.alloca %1125 x i64 : (i64) -> !llvm.ptr
        llvm.store %1124, %1126 : i64, !llvm.ptr
        %1127 = arith.constant 0 : i32
        %1128 = arith.extsi %1127 : i32 to i64
        %1129 = llvm.mlir.constant(1 : i64) : i64
        %1130 = llvm.alloca %1129 x i64 : (i64) -> !llvm.ptr
        llvm.store %1128, %1130 : i64, !llvm.ptr
        cf.br ^bb138
        ^bb138:
        %1131 = llvm.load %1130 : !llvm.ptr -> i64
        %1132 = llvm.load %1031 : !llvm.ptr -> i64
        %1133 = arith.cmpi slt, %1131, %1132 : i64
        cf.cond_br %1133, ^bb139, ^bb140
        ^bb139:
          %1135 = llvm.load %1130 : !llvm.ptr -> i64
          %1136 = llvm.getelementptr %1018[%1135] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          %1134 = llvm.load %1136 : !llvm.ptr -> i64
          %1137 = arith.cmpi eq, %1134, %1107 : i64
          cf.cond_br %1137, ^bb141, ^bb142
          ^bb141:
            %1138 = llvm.load %1130 : !llvm.ptr -> i64
            llvm.store %1138, %1126 : i64, !llvm.ptr
            cf.br ^bb140
          ^bb142:
            cf.br ^bb143
          ^bb143:
          %1139 = llvm.load %1130 : !llvm.ptr -> i64
          %1140 = arith.constant 1 : i32
          %1142 = arith.extsi %1140 : i32 to i64
          %1141 = arith.addi %1139, %1142 : i64
          llvm.store %1141, %1130 : i64, !llvm.ptr
          cf.br ^bb138
        ^bb140:
        %1143 = llvm.load %1126 : !llvm.ptr -> i64
        %1144 = arith.constant 0 : i32
        %1146 = arith.extsi %1144 : i32 to i64
        %1145 = arith.cmpi slt, %1143, %1146 : i64
        cf.cond_br %1145, ^bb144, ^bb145
        ^bb144:
          %1147 = llvm.load %1031 : !llvm.ptr -> i64
          %1148 = llvm.getelementptr %1018[%1147] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          llvm.store %1107, %1148 : i64, !llvm.ptr
          %1149 = arith.constant 1 : i32
          %1150 = llvm.load %1031 : !llvm.ptr -> i64
          %1151 = arith.extsi %1149 : i32 to i64
          %1152 = llvm.getelementptr %1023[%1150] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          llvm.store %1151, %1152 : i64, !llvm.ptr
          %1153 = llvm.load %1031 : !llvm.ptr -> i64
          %1154 = arith.constant 1 : i32
          %1156 = arith.extsi %1154 : i32 to i64
          %1155 = arith.addi %1153, %1156 : i64
          llvm.store %1155, %1031 : i64, !llvm.ptr
          cf.br ^bb146
        ^bb145:
          %1158 = llvm.load %1126 : !llvm.ptr -> i64
          %1159 = llvm.getelementptr %1023[%1158] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          %1157 = llvm.load %1159 : !llvm.ptr -> i64
          %1160 = arith.constant 1 : i32
          %1162 = arith.extsi %1160 : i32 to i64
          %1161 = arith.addi %1157, %1162 : i64
          %1163 = llvm.load %1126 : !llvm.ptr -> i64
          %1164 = llvm.getelementptr %1023[%1163] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          llvm.store %1161, %1164 : i64, !llvm.ptr
          cf.br ^bb146
        ^bb146:
        %1165 = llvm.load %1102 : !llvm.ptr -> i64
        %1166 = arith.constant 1 : i32
        %1168 = arith.extsi %1166 : i32 to i64
        %1167 = arith.addi %1165, %1168 : i64
        llvm.store %1167, %1102 : i64, !llvm.ptr
        cf.br ^bb132
      ^bb134:
      cf.br ^bb119
    ^bb119:
    %1169 = arith.constant 0 : i32
    %1170 = arith.extsi %1169 : i32 to i64
    %1171 = llvm.mlir.constant(1 : i64) : i64
    %1172 = llvm.alloca %1171 x i64 : (i64) -> !llvm.ptr
    llvm.store %1170, %1172 : i64, !llvm.ptr
    %1173 = arith.constant 0 : i32
    %1174 = arith.extsi %1173 : i32 to i64
    %1175 = llvm.mlir.constant(1 : i64) : i64
    %1176 = llvm.alloca %1175 x i64 : (i64) -> !llvm.ptr
    llvm.store %1174, %1176 : i64, !llvm.ptr
    cf.br ^bb147
    ^bb147:
    %1177 = llvm.load %1176 : !llvm.ptr -> i64
    %1178 = llvm.load %1031 : !llvm.ptr -> i64
    %1179 = arith.cmpi slt, %1177, %1178 : i64
    cf.cond_br %1179, ^bb148, ^bb149
    ^bb148:
      %1182 = llvm.load %1176 : !llvm.ptr -> i64
      %1183 = llvm.getelementptr %1018[%1182] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %1181 = llvm.load %1183 : !llvm.ptr -> i64
      %1180 = func.call @cycles_at_least_two_edges(%arg0, %1181) : (i64, i64) -> i64
      %1184 = llvm.load %1172 : !llvm.ptr -> i64
      %1186 = llvm.load %1176 : !llvm.ptr -> i64
      %1187 = llvm.getelementptr %1023[%1186] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %1185 = llvm.load %1187 : !llvm.ptr -> i64
      %1188 = arith.muli %1185, %1180 : i64
      %1189 = arith.addi %1184, %1188 : i64
      %1190 = llvm.mlir.addressof @MOD : !llvm.ptr
      %1191 = llvm.load %1190 : !llvm.ptr -> i64
      %1192 = arith.remsi %1189, %1191 : i64
      llvm.store %1192, %1172 : i64, !llvm.ptr
      %1193 = llvm.load %1176 : !llvm.ptr -> i64
      %1194 = arith.constant 1 : i32
      %1196 = arith.extsi %1194 : i32 to i64
      %1195 = arith.addi %1193, %1196 : i64
      llvm.store %1195, %1176 : i64, !llvm.ptr
      cf.br ^bb147
    ^bb149:
    func.call @free(%982) : (!llvm.ptr) -> ()
    func.call @free(%987) : (!llvm.ptr) -> ()
    func.call @free(%1018) : (!llvm.ptr) -> ()
    func.call @free(%1023) : (!llvm.ptr) -> ()
    %1201 = llvm.load %1172 : !llvm.ptr -> i64
    func.return %1201 : i64
  }
  func.func @main() -> i32 {
    func.call @init_factorials() : () -> ()
    %1204 = llvm.mlir.addressof @MAX_POINTS : !llvm.ptr
    %1205 = llvm.load %1204 : !llvm.ptr -> i64
    %1206 = arith.constant 8 : i32
    %1207 = arith.extsi %1206 : i32 to i64
    %1203 = func.call @calloc(%1205, %1207) : (i64, i64) -> !llvm.ptr
    %1208 = llvm.mlir.addressof @pts_qx : !llvm.ptr
    llvm.store %1203, %1208 : !llvm.ptr, !llvm.ptr
    %1210 = llvm.mlir.addressof @MAX_POINTS : !llvm.ptr
    %1211 = llvm.load %1210 : !llvm.ptr -> i64
    %1212 = arith.constant 8 : i32
    %1213 = arith.extsi %1212 : i32 to i64
    %1209 = func.call @calloc(%1211, %1213) : (i64, i64) -> !llvm.ptr
    %1214 = llvm.mlir.addressof @pts_qy : !llvm.ptr
    llvm.store %1209, %1214 : !llvm.ptr, !llvm.ptr
    %1216 = llvm.mlir.addressof @MAX_POINTS : !llvm.ptr
    %1217 = llvm.load %1216 : !llvm.ptr -> i64
    %1218 = arith.constant 4 : i32
    %1219 = arith.extsi %1218 : i32 to i64
    %1215 = func.call @calloc(%1217, %1219) : (i64, i64) -> !llvm.ptr
    %1220 = llvm.mlir.addressof @pts_count : !llvm.ptr
    llvm.store %1215, %1220 : !llvm.ptr, !llvm.ptr
    %1222 = llvm.mlir.addressof @HASH_SIZE : !llvm.ptr
    %1223 = llvm.load %1222 : !llvm.ptr -> i64
    %1224 = arith.constant 4 : i32
    %1225 = arith.extsi %1224 : i32 to i64
    %1221 = func.call @calloc(%1223, %1225) : (i64, i64) -> !llvm.ptr
    %1226 = llvm.mlir.addressof @hash_buckets : !llvm.ptr
    llvm.store %1221, %1226 : !llvm.ptr, !llvm.ptr
    %1228 = llvm.mlir.addressof @MAX_POINTS : !llvm.ptr
    %1229 = llvm.load %1228 : !llvm.ptr -> i64
    %1230 = arith.constant 4 : i32
    %1231 = arith.extsi %1230 : i32 to i64
    %1227 = func.call @calloc(%1229, %1231) : (i64, i64) -> !llvm.ptr
    %1232 = llvm.mlir.addressof @hash_next : !llvm.ptr
    llvm.store %1227, %1232 : !llvm.ptr, !llvm.ptr
    %1234 = llvm.mlir.addressof @MAX_REPS : !llvm.ptr
    %1235 = llvm.load %1234 : !llvm.ptr -> i64
    %1236 = arith.constant 8 : i32
    %1237 = arith.extsi %1236 : i32 to i64
    %1233 = func.call @calloc(%1235, %1237) : (i64, i64) -> !llvm.ptr
    %1238 = llvm.mlir.addressof @reps_x : !llvm.ptr
    llvm.store %1233, %1238 : !llvm.ptr, !llvm.ptr
    %1240 = llvm.mlir.addressof @MAX_REPS : !llvm.ptr
    %1241 = llvm.load %1240 : !llvm.ptr -> i64
    %1242 = arith.constant 8 : i32
    %1243 = arith.extsi %1242 : i32 to i64
    %1239 = func.call @calloc(%1241, %1243) : (i64, i64) -> !llvm.ptr
    %1244 = llvm.mlir.addressof @reps_y : !llvm.ptr
    llvm.store %1239, %1244 : !llvm.ptr, !llvm.ptr
    %1246 = llvm.mlir.addressof @MAX_REPS : !llvm.ptr
    %1247 = llvm.load %1246 : !llvm.ptr -> i64
    %1248 = arith.constant 4 : i32
    %1249 = arith.extsi %1248 : i32 to i64
    %1245 = func.call @calloc(%1247, %1249) : (i64, i64) -> !llvm.ptr
    %1250 = llvm.mlir.addressof @reps_cnt : !llvm.ptr
    llvm.store %1245, %1250 : !llvm.ptr, !llvm.ptr
    %1252 = llvm.mlir.addressof @HASH_SIZE : !llvm.ptr
    %1253 = llvm.load %1252 : !llvm.ptr -> i64
    %1254 = arith.constant 4 : i32
    %1255 = arith.extsi %1254 : i32 to i64
    %1251 = func.call @calloc(%1253, %1255) : (i64, i64) -> !llvm.ptr
    %1256 = llvm.mlir.addressof @grid_buckets : !llvm.ptr
    llvm.store %1251, %1256 : !llvm.ptr, !llvm.ptr
    %1258 = llvm.mlir.addressof @MAX_REPS : !llvm.ptr
    %1259 = llvm.load %1258 : !llvm.ptr -> i64
    %1260 = arith.constant 4 : i32
    %1261 = arith.extsi %1260 : i32 to i64
    %1257 = func.call @calloc(%1259, %1261) : (i64, i64) -> !llvm.ptr
    %1262 = llvm.mlir.addressof @grid_next : !llvm.ptr
    llvm.store %1257, %1262 : !llvm.ptr, !llvm.ptr
    %1263 = arith.constant 0 : i32
    %1264 = arith.extsi %1263 : i32 to i64
    %1265 = llvm.mlir.constant(1 : i64) : i64
    %1266 = llvm.alloca %1265 x i64 : (i64) -> !llvm.ptr
    llvm.store %1264, %1266 : i64, !llvm.ptr
    %1267 = arith.constant 3 : i32
    %1268 = arith.extsi %1267 : i32 to i64
    %1269 = llvm.mlir.constant(1 : i64) : i64
    %1270 = llvm.alloca %1269 x i64 : (i64) -> !llvm.ptr
    llvm.store %1268, %1270 : i64, !llvm.ptr
    cf.br ^bb150
    ^bb150:
    %1271 = llvm.load %1270 : !llvm.ptr -> i64
    %1272 = arith.constant 60 : i32
    %1274 = arith.extsi %1272 : i32 to i64
    %1273 = arith.cmpi sle, %1271, %1274 : i64
    cf.cond_br %1273, ^bb151, ^bb152
    ^bb151:
      %1275 = llvm.load %1266 : !llvm.ptr -> i64
      %1277 = llvm.load %1270 : !llvm.ptr -> i64
      %1276 = func.call @T_mod(%1277) : (i64) -> i64
      %1278 = arith.addi %1275, %1276 : i64
      %1279 = llvm.mlir.addressof @MOD : !llvm.ptr
      %1280 = llvm.load %1279 : !llvm.ptr -> i64
      %1281 = arith.remsi %1278, %1280 : i64
      llvm.store %1281, %1266 : i64, !llvm.ptr
      %1282 = llvm.load %1270 : !llvm.ptr -> i64
      %1283 = arith.constant 1 : i32
      %1285 = arith.extsi %1283 : i32 to i64
      %1284 = arith.addi %1282, %1285 : i64
      llvm.store %1284, %1270 : i64, !llvm.ptr
      cf.br ^bb150
    ^bb152:
    %1286 = llvm.mlir.addressof @str_0 : !llvm.ptr
    %1287 = llvm.load %1266 : !llvm.ptr -> i64
    %1288 = llvm.call @printf(%1286, %1287) vararg(!llvm.func<i32 (ptr, ...)>) : (!llvm.ptr, i64) -> i32
    %1289 = arith.constant 0 : i32
    func.return %1289 : i32
  }
}