Problem 513

Integral Median — F(100000) via floor-sum trapezoid queries.

Answer2925619196
Output2925619196
StatusPASS
Native helperno
Runtime20 ms
Peak memory1856 KB
Time complexityO(n) (estimated)
Space complexityO(n) (estimated)

Performance comparison

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

Flow source

# Project Euler 513
# Integral Median — F(100000) via floor-sum trapezoid queries.

import euler.nt { isqrt }

const CAP: i64 = 65536

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

function abs64(x: i64) -> i64 {
    if x < 0 { return -x }
    return x
}

function floordiv(n: i64, d: i64) -> i64 {
    if n >= 0 { return n / d }
    return (n - d + 1) / d
}

function modfloor(n: i64, d: i64) -> i64 {
    return n - floordiv(n, d) * d
}

function trapezoid_floor_sum(
    slope0: i64, intercept0: i64, denom0: i64,
    lower_x0: i64, upper_x0: i64, include_boundary0: i32
) -> i64 {
    let mut slope: i64 = slope0
    let mut intercept: i64 = intercept0
    let mut denom: i64 = denom0
    let mut lower_x: i64 = lower_x0
    let mut upper_x: i64 = upper_x0
    let mut include_boundary: i32 = include_boundary0
    let mut total: i64 = 0

    while true {
        if abs64(upper_x - lower_x) <= 8 {
            let mut adjustment: i64 = 0
            if include_boundary == 0 { adjustment = 1 }
            if upper_x > lower_x {
                let mut x: i64 = lower_x + 1
                while x <= upper_x {
                    total = total + floordiv(slope * x + intercept - adjustment, denom)
                    x = x + 1
                }
            } else {
                let mut sub: i64 = 0
                let mut x2: i64 = upper_x + 1
                while x2 <= lower_x {
                    sub = sub + floordiv(slope * x2 + intercept - adjustment, denom)
                    x2 = x2 + 1
                }
                total = total - sub
            }
            return total
        }

        let whole_intercept: i64 = floordiv(intercept, denom)
        if whole_intercept != 0 {
            total = total + (upper_x - lower_x) * whole_intercept
            intercept = modfloor(intercept, denom)
        }
        let whole_slope: i64 = floordiv(slope, denom)
        if whole_slope != 0 {
            total = total + (upper_x - lower_x) * (upper_x + lower_x + 1) / 2 * whole_slope
            slope = modfloor(slope, denom)
        }
        if slope == 0 {
            if intercept == 0 && include_boundary == 0 {
                total = total - (upper_x - lower_x)
            }
            return total
        }

        let upper_y: i64 = floordiv(slope * upper_x + intercept, denom)
        let lower_y: i64 = floordiv(slope * lower_x + intercept, denom)
        total = total + upper_x * upper_y - lower_x * lower_y

        let nx: i64 = upper_y
        upper_x = lower_y
        lower_x = nx
        let ns: i64 = denom
        denom = slope
        slope = ns
        intercept = -intercept
        if include_boundary == 1 { include_boundary = 0 } else { include_boundary = 1 }
    }
    return total
}

function trapezoid_floor_sum_mod2(
    slope0: i64, intercept0: i64, denom0: i64,
    lower_x0: i64, upper_x0: i64, include_boundary0: i32,
    x_residue: i64, y_residue: i64
) -> i64 {
    let mut intercept: i64 = intercept0
    let mut lower_x: i64 = lower_x0
    let mut upper_x: i64 = upper_x0
    if (y_residue & 1) != 0 { intercept = intercept + denom0 }
    if (x_residue & 1) != 0 {
        intercept = intercept - slope0
        lower_x = lower_x + 1
        upper_x = upper_x + 1
    }
    return trapezoid_floor_sum(2 * slope0, intercept, 2 * denom0, lower_x / 2, upper_x / 2, include_boundary0)
}

function primitive_count(n: i64) -> i64 {
    let mut total: i64 = 0
    let three_halves_n: i64 = n + n / 2
    let root: i64 = isqrt(three_halves_n)

    let mut ir: i64 = 0
    while ir <= 2 {
        let mut i_residue: i64 = 0
        let mut j_residue: i64 = 0
        if ir == 0 { i_residue = 0; j_residue = 1 }
        elif ir == 1 { i_residue = 1; j_residue = 0 }
        else { i_residue = 1; j_residue = 1 }

        let mut max_t: i64 = 1
        let mut s: i64 = 2
        while s < root {
            if 3 * (max_t + 1) * (max_t + 1) <= s * s { max_t = max_t + 1 }
            if i_residue == j_residue || (s & 1) == 0 {
                let start_t: i64 = ((s - 1) & 1) + 1
                let mut t: i64 = start_t
                while t <= max_t {
                    let v_mid: i64 = t * n / ((s - t) * (s + t))
                    let v_max: i64 = n * (s + t) / (s * s + 2 * s * t - t * t)
                    total = total + trapezoid_floor_sum_mod2(s, 0, t, 0, v_mid, 1, j_residue, i_residue)
                    total = total + trapezoid_floor_sum_mod2(t, n, s, v_mid, v_max, 1, j_residue, i_residue)
                    total = total - trapezoid_floor_sum_mod2(s + 3 * t, 0, s + t, 0, v_max, 0, j_residue, i_residue)
                    t = t + 2
                }
            }
            s = s + 1
        }

        let max_u: i64 = three_halves_n / root
        let start_u: i64 = 1 + ((i_residue + 1) & 1)
        let mut u: i64 = start_u
        while u <= max_u {
            let mut max_v_outer: i64 = u - 1
            if n / 2 < u - 1 { max_v_outer = n / 2 }
            let start_v: i64 = 1 + ((j_residue + 1) & 1)
            let mut v: i64 = start_v
            while v <= max_v_outer {
                let split_s: i64 = (v + n) / u
                let mut residue_count: i64 = 1
                if i_residue == j_residue { residue_count = 2 }

                let mut sr: i64 = 0
                while sr < residue_count {
                    let mut s_residue: i64 = sr
                    if i_residue != j_residue { s_residue = 0 }

                    let mut min_s: i64 = root
                    let mut max_s: i64 = 0
                    let mut slope0: i64 = 0
                    let mut slope1: i64 = 0
                    if u * u < 3 * v * v {
                        min_s = root
                        max_s = n * (3 * v - u) / (2 * u * v + v * v - u * u)
                        slope0 = u - v
                        slope1 = 3 * v - u
                    } else {
                        let ms: i64 = (u + v - 1) / v
                        if ms > root { min_s = ms } else { min_s = root }
                        max_s = n * u / ((u - v) * (u + v))
                        slope0 = v
                        slope1 = u
                    }

                    if max_s >= min_s {
                        total = total + trapezoid_floor_sum_mod2(slope0, 0, slope1, min_s - 1, max_s, 1, s_residue, s_residue)
                        if split_s < max_s {
                            let mut lo: i64 = min_s - 1
                            if split_s > lo { lo = split_s }
                            total = total - trapezoid_floor_sum_mod2(u, -n, v, lo, max_s, 0, s_residue, s_residue)
                        }
                    }
                    sr = sr + 1
                }
                v = v + 2
            }
            u = u + 2
        }
        ir = ir + 1
    }
    return total
}

function hslot(key: i64, keys: ptr<i64>, used: ptr<i8>) -> i64 {
    let mut h: i64 = key % CAP
    if h < 0 { h = h + CAP }
    while used[h] == 1 && keys[h] != key {
        h = h + 1
        if h == CAP { h = 0 }
    }
    return h
}

function F(n: i64, keys: ptr<i64>, vals: ptr<i64>, used: ptr<i8>) -> i64 {
    if n <= 0 { return 0 }
    let s: i64 = hslot(n, keys, used)
    if used[s] == 1 { return vals[s] }

    let mut result: i64 = primitive_count(n)

    let mut k: i64 = 3
    let mut quotient: i64 = n / k
    while k <= quotient {
        result = result - F(quotient, keys, vals, used)
        k = k + 2
        quotient = n / k
    }

    let mut min_k: i64 = n
    if quotient + 1 > 0 { min_k = n / (quotient + 1) }
    while quotient > 0 {
        let max_k: i64 = n / quotient
        let left: i64 = (min_k + 1) + (min_k & 1)
        let right: i64 = max_k - ((max_k + 1) & 1)
        if right >= left {
            result = result - F(quotient, keys, vals, used) * ((right - left) / 2 + 1)
        }
        quotient = quotient - 1
        min_k = max_k
    }

    used[s] = 1
    keys[s] = n
    vals[s] = result
    return result
}

function main() -> i32 {
    let keys: ptr<i64> = calloc(CAP, 8)
    let vals: ptr<i64> = calloc(CAP, 8)
    let used: ptr<i8> = calloc(CAP, 1)
    if keys == null || vals == null || used == null { return 1 }
    let ans: i64 = F(100000, keys, vals, used)
    printf("%lld\n", ans)
    free(keys); free(vals); free(used)
    return 0
}

Generated C

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

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

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

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

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

#include <math.h>

void* _ui_state = NULL;

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

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

int64_t gcd_i64_i64(int64_t a0, int64_t b0);
int64_t lcm_i64_i64(int64_t a, int64_t b);
int64_t isqrt_i64(int64_t n);
int64_t mulmod_i64_i64_i64(int64_t a0, int64_t b0, int64_t mod);
int64_t mod_pow_i64_i64_i64(int64_t base, int64_t exp, int64_t mod);
bool is_prime_i64(int64_t n);
int64_t abs64_i64(int64_t x);
int64_t floordiv_i64_i64(int64_t n, int64_t d);
int64_t modfloor_i64_i64(int64_t n, int64_t d);
int64_t trapezoid_floor_sum_i64_i64_i64_i64_i64_i32(int64_t slope0, int64_t intercept0, int64_t denom0, int64_t lower_x0, int64_t upper_x0, int32_t include_boundary0);
int64_t trapezoid_floor_sum_mod2_i64_i64_i64_i64_i64_i32_i64_i64(int64_t slope0, int64_t intercept0, int64_t denom0, int64_t lower_x0, int64_t upper_x0, int32_t include_boundary0, int64_t x_residue, int64_t y_residue);
int64_t primitive_count_i64(int64_t n);
int64_t hslot_i64_ptr_i64_ptr_i8(int64_t key, int64_t* keys, int8_t* used);
int64_t F_i64_ptr_i64_ptr_i64_ptr_i8(int64_t n, int64_t* keys, int64_t* vals, int8_t* used);
int32_t main(void);

static const int64_t CAP = 65536;

int64_t gcd_i64_i64(int64_t a0, int64_t b0) {
    int64_t a = a0;
    int64_t b = b0;
    while (b != 0) {
        int64_t t = FLOW_CHECKED_MOD((a), (b));
        a = b;
        b = t;
    }
    return a;
}

int64_t lcm_i64_i64(int64_t a, int64_t b) {
    if ((a == 0 || b == 0)) {
        return 0;
    }
    return (FLOW_CHECKED_DIV((a), (gcd_i64_i64(a, b))) * b);
}

int64_t isqrt_i64(int64_t n) {
    if (n < 2) {
        return n;
    }
    int64_t x = n;
    int64_t y = FLOW_CHECKED_DIV(((x + 1)), (2));
    while (y < x) {
        x = y;
        y = FLOW_CHECKED_DIV(((x + FLOW_CHECKED_DIV((n), (x)))), (2));
    }
    return x;
}

int64_t mulmod_i64_i64_i64(int64_t a0, int64_t b0, int64_t mod) {
    int64_t a = FLOW_CHECKED_MOD((a0), (mod));
    int64_t b = FLOW_CHECKED_MOD((b0), (mod));
    int64_t result = 0;
    while (b > 0) {
        if (FLOW_CHECKED_MOD((b), (2)) == 1) {
            result = FLOW_CHECKED_MOD(((result + a)), (mod));
        }
        a = FLOW_CHECKED_MOD(((a * 2)), (mod));
        b = FLOW_CHECKED_DIV((b), (2));
    }
    return result;
}

int64_t mod_pow_i64_i64_i64(int64_t base, int64_t exp, int64_t mod) {
    if (mod == 1) {
        return 0;
    }
    int64_t result = 1;
    int64_t b = FLOW_CHECKED_MOD((base), (mod));
    int64_t e = exp;
    while (e > 0) {
        if (FLOW_CHECKED_MOD((e), (2)) == 1) {
            result = mulmod_i64_i64_i64(result, b, mod);
        }
        b = mulmod_i64_i64_i64(b, b, mod);
        e = FLOW_CHECKED_DIV((e), (2));
    }
    return result;
}

bool is_prime_i64(int64_t n) {
    if (n < 2) {
        return 0;
    }
    if (n < 4) {
        return 1;
    }
    if ((FLOW_CHECKED_MOD((n), (2)) == 0 || FLOW_CHECKED_MOD((n), (3)) == 0)) {
        return 0;
    }
    int64_t i = 5;
    while ((i * i) <= n) {
        if ((FLOW_CHECKED_MOD((n), (i)) == 0 || FLOW_CHECKED_MOD((n), ((i + 2))) == 0)) {
            return 0;
        }
        i = (i + 6);
    }
    return 1;
}



int64_t abs64_i64(int64_t x) {
    if (x < 0) {
        return (-x);
    }
    return x;
}

int64_t floordiv_i64_i64(int64_t n, int64_t d) {
    if (n >= 0) {
        return FLOW_CHECKED_DIV((n), (d));
    }
    return FLOW_CHECKED_DIV((((n - d) + 1)), (d));
}

int64_t modfloor_i64_i64(int64_t n, int64_t d) {
    return (n - (floordiv_i64_i64(n, d) * d));
}

int64_t trapezoid_floor_sum_i64_i64_i64_i64_i64_i32(int64_t slope0, int64_t intercept0, int64_t denom0, int64_t lower_x0, int64_t upper_x0, int32_t include_boundary0) {
    int64_t slope = slope0;
    int64_t intercept = intercept0;
    int64_t denom = denom0;
    int64_t lower_x = lower_x0;
    int64_t upper_x = upper_x0;
    int32_t include_boundary = include_boundary0;
    int64_t total = 0;
    while (1) {
        if (abs64_i64((upper_x - lower_x)) <= 8) {
            int64_t adjustment = 0;
            if (include_boundary == 0) {
                adjustment = 1;
            }
            if (upper_x > lower_x) {
                int64_t x = (lower_x + 1);
                while (x <= upper_x) {
                    total = (total + floordiv_i64_i64((((slope * x) + intercept) - adjustment), denom));
                    x = (x + 1);
                }
            } else {
                int64_t sub = 0;
                int64_t x2 = (upper_x + 1);
                while (x2 <= lower_x) {
                    sub = (sub + floordiv_i64_i64((((slope * x2) + intercept) - adjustment), denom));
                    x2 = (x2 + 1);
                }
                total = (total - sub);
            }
            return total;
        }
        int64_t whole_intercept = floordiv_i64_i64(intercept, denom);
        if (whole_intercept != 0) {
            total = (total + ((upper_x - lower_x) * whole_intercept));
            intercept = modfloor_i64_i64(intercept, denom);
        }
        int64_t whole_slope = floordiv_i64_i64(slope, denom);
        if (whole_slope != 0) {
            total = (total + (FLOW_CHECKED_DIV((((upper_x - lower_x) * ((upper_x + lower_x) + 1))), (2)) * whole_slope));
            slope = modfloor_i64_i64(slope, denom);
        }
        if (slope == 0) {
            if ((intercept == 0 && include_boundary == 0)) {
                total = (total - (upper_x - lower_x));
            }
            return total;
        }
        int64_t upper_y = floordiv_i64_i64(((slope * upper_x) + intercept), denom);
        int64_t lower_y = floordiv_i64_i64(((slope * lower_x) + intercept), denom);
        total = ((total + (upper_x * upper_y)) - (lower_x * lower_y));
        int64_t nx = upper_y;
        upper_x = lower_y;
        lower_x = nx;
        int64_t ns = denom;
        denom = slope;
        slope = ns;
        intercept = (-intercept);
        if (include_boundary == 1) {
            include_boundary = 0;
        } else {
            include_boundary = 1;
        }
    }
    return total;
}

int64_t trapezoid_floor_sum_mod2_i64_i64_i64_i64_i64_i32_i64_i64(int64_t slope0, int64_t intercept0, int64_t denom0, int64_t lower_x0, int64_t upper_x0, int32_t include_boundary0, int64_t x_residue, int64_t y_residue) {
    int64_t intercept = intercept0;
    int64_t lower_x = lower_x0;
    int64_t upper_x = upper_x0;
    if ((y_residue & 1) != 0) {
        intercept = (intercept + denom0);
    }
    if ((x_residue & 1) != 0) {
        intercept = (intercept - slope0);
        lower_x = (lower_x + 1);
        upper_x = (upper_x + 1);
    }
    return trapezoid_floor_sum_i64_i64_i64_i64_i64_i32((2 * slope0), intercept, (2 * denom0), FLOW_CHECKED_DIV((lower_x), (2)), FLOW_CHECKED_DIV((upper_x), (2)), include_boundary0);
}

int64_t primitive_count_i64(int64_t n) {
    int64_t total = 0;
    int64_t three_halves_n = (n + FLOW_CHECKED_DIV((n), (2)));
    int64_t root = isqrt_i64(three_halves_n);
    int64_t ir = 0;
    while (ir <= 2) {
        int64_t i_residue = 0;
        int64_t j_residue = 0;
        if (ir == 0) {
            i_residue = 0;
            j_residue = 1;
        } else if (ir == 1) {
            i_residue = 1;
            j_residue = 0;
        } else {
            i_residue = 1;
            j_residue = 1;
        }
        int64_t max_t = 1;
        int64_t s = 2;
        while (s < root) {
            if (((3 * (max_t + 1)) * (max_t + 1)) <= (s * s)) {
                max_t = (max_t + 1);
            }
            if ((i_residue == j_residue || (s & 1) == 0)) {
                int64_t start_t = (((s - 1) & 1) + 1);
                int64_t t = start_t;
                while (t <= max_t) {
                    int64_t v_mid = FLOW_CHECKED_DIV(((t * n)), (((s - t) * (s + t))));
                    int64_t v_max = FLOW_CHECKED_DIV(((n * (s + t))), ((((s * s) + ((2 * s) * t)) - (t * t))));
                    total = (total + trapezoid_floor_sum_mod2_i64_i64_i64_i64_i64_i32_i64_i64(s, 0, t, 0, v_mid, 1, j_residue, i_residue));
                    total = (total + trapezoid_floor_sum_mod2_i64_i64_i64_i64_i64_i32_i64_i64(t, n, s, v_mid, v_max, 1, j_residue, i_residue));
                    total = (total - trapezoid_floor_sum_mod2_i64_i64_i64_i64_i64_i32_i64_i64((s + (3 * t)), 0, (s + t), 0, v_max, 0, j_residue, i_residue));
                    t = (t + 2);
                }
            }
            s = (s + 1);
        }
        int64_t max_u = FLOW_CHECKED_DIV((three_halves_n), (root));
        int64_t start_u = (1 + ((i_residue + 1) & 1));
        int64_t u = start_u;
        while (u <= max_u) {
            int64_t max_v_outer = (u - 1);
            if (FLOW_CHECKED_DIV((n), (2)) < (u - 1)) {
                max_v_outer = FLOW_CHECKED_DIV((n), (2));
            }
            int64_t start_v = (1 + ((j_residue + 1) & 1));
            int64_t v = start_v;
            while (v <= max_v_outer) {
                int64_t split_s = FLOW_CHECKED_DIV(((v + n)), (u));
                int64_t residue_count = 1;
                if (i_residue == j_residue) {
                    residue_count = 2;
                }
                int64_t sr = 0;
                while (sr < residue_count) {
                    int64_t s_residue = sr;
                    if (i_residue != j_residue) {
                        s_residue = 0;
                    }
                    int64_t min_s = root;
                    int64_t max_s = 0;
                    int64_t slope0 = 0;
                    int64_t slope1 = 0;
                    if ((u * u) < ((3 * v) * v)) {
                        min_s = root;
                        max_s = FLOW_CHECKED_DIV(((n * ((3 * v) - u))), (((((2 * u) * v) + (v * v)) - (u * u))));
                        slope0 = (u - v);
                        slope1 = ((3 * v) - u);
                    } else {
                        int64_t ms = FLOW_CHECKED_DIV((((u + v) - 1)), (v));
                        if (ms > root) {
                            min_s = ms;
                        } else {
                            min_s = root;
                        }
                        max_s = FLOW_CHECKED_DIV(((n * u)), (((u - v) * (u + v))));
                        slope0 = v;
                        slope1 = u;
                    }
                    if (max_s >= min_s) {
                        total = (total + trapezoid_floor_sum_mod2_i64_i64_i64_i64_i64_i32_i64_i64(slope0, 0, slope1, (min_s - 1), max_s, 1, s_residue, s_residue));
                        if (split_s < max_s) {
                            int64_t lo = (min_s - 1);
                            if (split_s > lo) {
                                lo = split_s;
                            }
                            total = (total - trapezoid_floor_sum_mod2_i64_i64_i64_i64_i64_i32_i64_i64(u, (-n), v, lo, max_s, 0, s_residue, s_residue));
                        }
                    }
                    sr = (sr + 1);
                }
                v = (v + 2);
            }
            u = (u + 2);
        }
        ir = (ir + 1);
    }
    return total;
}

int64_t hslot_i64_ptr_i64_ptr_i8(int64_t key, int64_t* keys, int8_t* used) {
    int64_t h = FLOW_CHECKED_MOD((key), (CAP));
    if (h < 0) {
        h = (h + CAP);
    }
    while ((used[h] == 1 && keys[h] != key)) {
        h = (h + 1);
        if (h == CAP) {
            h = 0;
        }
    }
    return h;
}

int64_t F_i64_ptr_i64_ptr_i64_ptr_i8(int64_t n, int64_t* keys, int64_t* vals, int8_t* used) {
    if (n <= 0) {
        return 0;
    }
    int64_t s = hslot_i64_ptr_i64_ptr_i8(n, keys, used);
    if (used[s] == 1) {
        return vals[s];
    }
    int64_t result = primitive_count_i64(n);
    int64_t k = 3;
    int64_t quotient = FLOW_CHECKED_DIV((n), (k));
    while (k <= quotient) {
        result = (result - F_i64_ptr_i64_ptr_i64_ptr_i8(quotient, keys, vals, used));
        k = (k + 2);
        quotient = FLOW_CHECKED_DIV((n), (k));
    }
    int64_t min_k = n;
    if ((quotient + 1) > 0) {
        min_k = FLOW_CHECKED_DIV((n), ((quotient + 1)));
    }
    while (quotient > 0) {
        int64_t max_k = FLOW_CHECKED_DIV((n), (quotient));
        int64_t left = ((min_k + 1) + (min_k & 1));
        int64_t right = (max_k - ((max_k + 1) & 1));
        if (right >= left) {
            result = (result - (F_i64_ptr_i64_ptr_i64_ptr_i8(quotient, keys, vals, used) * (FLOW_CHECKED_DIV(((right - left)), (2)) + 1)));
        }
        quotient = (quotient - 1);
        min_k = max_k;
    }
    used[s] = 1;
    keys[s] = n;
    vals[s] = result;
    return result;
}

int32_t main(void) {
    int64_t* keys = (int64_t*)(calloc(CAP, 8));
    int64_t* vals = (int64_t*)(calloc(CAP, 8));
    int8_t* used = (int8_t*)(calloc(CAP, 1));
    if (((keys == NULL || vals == NULL) || used == NULL)) {
        return 1;
    }
    int64_t ans = F_i64_ptr_i64_ptr_i64_ptr_i8(100000, keys, vals, used);
    printf("%lld\n", ans);
    free(keys);
    free(vals);
    free(used);
    return 0;
}

Generated MLIR

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