Problem 651

Uses Burnside's lemma over D_a x D_b, surjections count, modular arithmetic.

Answer448233151
Output448233151
StatusPASS
Native helperno
Runtime30 ms
Peak memory3856 KB
Time complexityO(n^4) (estimated)
Space complexityO(n^2) (estimated)

Performance comparison

MetricOur solutionBest known
Time complexityO(n^4)O(log n)
Space complexityO(n^2)O(1)
ApproachFlow solutionModular exponentiation
VerdictSuboptimal

Flow source

# Project Euler 651: Patterned Cylinders
# Uses Burnside's lemma over D_a x D_b, surjections count, modular arithmetic.

import euler.nt { isqrt }

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

const MOD: i64 = 1000000007

function pow_mod(base: i64, exp: i64, m: i64) -> i64 {
    let mut r: i64 = 1
    let mut b: i64 = base % m
    let mut e: i64 = exp
    while e > 0 {
        if (e & 1) == 1 { r = (r * b) % m }
        b = (b * b) % m
        e = e >> 1
    }
    return r
}

function mygcd(a: i64, b: i64) -> i64 {
    let mut x: i64 = a
    let mut y: i64 = b
    while y > 0 {
        let t: i64 = x % y
        x = y
        y = t
    }
    return x
}

# Sieve primes up to 20000
const MAX_PRIME: i64 = 20001
let mut g_primes: ptr<i64> = null
let mut g_nprimes: i64 = 0

function sieve_primes() -> void {
    let bs: ptr<i8> = calloc(MAX_PRIME, 1)
    for i in 0..MAX_PRIME { bs[i] = 1 }
    bs[0] = 0
    bs[1] = 0
    let r: i64 = isqrt(MAX_PRIME)
    for i in 2..(r + 1) {
        if bs[i] == 1 {
            let mut j: i64 = i * i
            while j < MAX_PRIME {
                bs[j] = 0
                j = j + i
            }
        }
    }
    let mut cnt: i64 = 0
    for i in 0..MAX_PRIME {
        if bs[i] == 1 { cnt = cnt + 1 }
    }
    g_primes = calloc(cnt, 8)
    let mut idx: i64 = 0
    for i in 0..MAX_PRIME {
        if bs[i] == 1 {
            g_primes[idx] = i
            idx = idx + 1
        }
    }
    g_nprimes = cnt
    free(bs)
}

# Factorize n, store primes and exponents in arrays
# Returns number of factors
function factorize(n: i64, fps: ptr<i64>, fes: ptr<i64>) -> i64 {
    let mut x: i64 = n
    let mut nf: i64 = 0
    for i in 0..g_nprimes {
        let p: i64 = g_primes[i]
        if p * p > x { break }
        if x % p == 0 {
            let mut e: i64 = 0
            while x % p == 0 {
                x = x / p
                e = e + 1
            }
            fps[nf] = p
            fes[nf] = e
            nf = nf + 1
        }
    }
    if x > 1 {
        fps[nf] = x
        fes[nf] = 1
        nf = nf + 1
    }
    return nf
}

# Enumerate divisors with totient
# Returns count, fills divs[] and phis[]
function divisors_phi(nf: i64, fps: ptr<i64>, fes: ptr<i64>, divs: ptr<i64>, phis: ptr<i64>) -> i64 {
    divs[0] = 1
    phis[0] = 1
    let mut count: i64 = 1
    for i in 0..nf {
        let p: i64 = fps[i]
        let e: i64 = fes[i]
        let prev_count: i64 = count
        let mut pk: i64 = 1
        for k in 0..(e + 1) {
            let phi_pk: i64
            if k == 0 {
                phi_pk = 1
            } else {
                phi_pk = (pk / p) * (p - 1)
            }
            if k > 0 {
                for j in 0..prev_count {
                    divs[count] = divs[j] * pk
                    phis[count] = phis[j] * phi_pk
                    count = count + 1
                }
            }
            pk = pk * p
        }
    }
    return count
}

# Dihedral types: cycle_length_counts and multiplicity
# We store as: types_cycles[i] = cycle length, types_count[i] = number of cycles, types_mult[i] = multiplicity
# But a type can have multiple cycle lengths. Use a flat representation:
# type_data = [n_types][max_cycles_per_type][3] (cycle_len, count, multiplicity)
# Simpler: store as list of (cycle_len, count, multiplicity) triples, with a separator

# Actually, let's use a different approach. For each type, store:
# - number of distinct cycle lengths
# - for each: cycle_length and count
# - multiplicity

const MAX_TYPES: i64 = 10000
const MAX_CYCLES_PER_TYPE: i64 = 3

let mut g_type_ncyc: ptr<i64> = null  # [MAX_TYPES]
let mut g_type_mult: ptr<i64> = null  # [MAX_TYPES]
let mut g_type_clen: ptr<i64> = null  # [MAX_TYPES * MAX_CYCLES_PER_TYPE]
let mut g_type_ccnt: ptr<i64> = null  # [MAX_TYPES * MAX_CYCLES_PER_TYPE]

function init_type_arrays() -> void {
    g_type_ncyc = calloc(MAX_TYPES, 8)
    g_type_mult = calloc(MAX_TYPES, 8)
    g_type_clen = calloc(MAX_TYPES * MAX_CYCLES_PER_TYPE, 8)
    g_type_ccnt = calloc(MAX_TYPES * MAX_CYCLES_PER_TYPE, 8)
}

function dihedral_types(n: i64) -> i64 {
    # Returns number of types, fills g_type_* arrays
    let fps: ptr<i64> = calloc(20, 8)
    let fes: ptr<i64> = calloc(20, 8)
    let nf: i64 = factorize(n, fps, fes)

    let divs: ptr<i64> = calloc(10000, 8)
    let phis: ptr<i64> = calloc(10000, 8)
    let ndiv: i64 = divisors_phi(nf, fps, fes, divs, phis)

    let mut ntypes: i64 = 0

    # Rotations
    for i in 0..ndiv {
        let L: i64 = divs[i]
        let phiL: i64 = phis[i]
        g_type_ncyc[ntypes] = 1
        g_type_mult[ntypes] = phiL
        g_type_clen[ntypes * MAX_CYCLES_PER_TYPE + 0] = L
        g_type_ccnt[ntypes * MAX_CYCLES_PER_TYPE + 0] = n / L
        ntypes = ntypes + 1
    }

    # Reflections
    if n % 2 == 1 {
        g_type_ncyc[ntypes] = 2
        g_type_mult[ntypes] = n
        g_type_clen[ntypes * MAX_CYCLES_PER_TYPE + 0] = 1
        g_type_ccnt[ntypes * MAX_CYCLES_PER_TYPE + 0] = 1
        g_type_clen[ntypes * MAX_CYCLES_PER_TYPE + 1] = 2
        g_type_ccnt[ntypes * MAX_CYCLES_PER_TYPE + 1] = (n - 1) / 2
        ntypes = ntypes + 1
    } else {
        g_type_ncyc[ntypes] = 2
        g_type_mult[ntypes] = n / 2
        g_type_clen[ntypes * MAX_CYCLES_PER_TYPE + 0] = 1
        g_type_ccnt[ntypes * MAX_CYCLES_PER_TYPE + 0] = 2
        g_type_clen[ntypes * MAX_CYCLES_PER_TYPE + 1] = 2
        g_type_ccnt[ntypes * MAX_CYCLES_PER_TYPE + 1] = (n - 2) / 2
        ntypes = ntypes + 1

        g_type_ncyc[ntypes] = 1
        g_type_mult[ntypes] = n / 2
        g_type_clen[ntypes * MAX_CYCLES_PER_TYPE + 0] = 2
        g_type_ccnt[ntypes * MAX_CYCLES_PER_TYPE + 0] = n / 2
        ntypes = ntypes + 1
    }

    free(phis)
    free(divs)
    free(fes)
    free(fps)
    return ntypes
}

function cycles_on_grid(type_a_idx: i64, type_b_idx: i64) -> i64 {
    let na: i64 = g_type_ncyc[type_a_idx]
    let nb: i64 = g_type_ncyc[type_b_idx]
    let mut total: i64 = 0
    for i in 0..na {
        let la: i64 = g_type_clen[type_a_idx * MAX_CYCLES_PER_TYPE + i]
        let ca: i64 = g_type_ccnt[type_a_idx * MAX_CYCLES_PER_TYPE + i]
        for j in 0..nb {
            let lb: i64 = g_type_clen[type_b_idx * MAX_CYCLES_PER_TYPE + j]
            let cb: i64 = g_type_ccnt[type_b_idx * MAX_CYCLES_PER_TYPE + j]
            total = total + ca * cb * mygcd(la, lb)
        }
    }
    return total
}

function surjections_count(cycles: i64, m: i64, comb: ptr<i64>) -> i64 {
    let mut s: i64 = 0
    for k in 0..(m + 1) {
        let base: i64 = m - k
        let term: i64 = (comb[k] * pow_mod(base, cycles, MOD)) % MOD
        if (k & 1) == 1 {
            s = s - term
        } else {
            s = s + term
        }
    }
    s = s % MOD
    if s < 0 { s = s + MOD }
    return s
}

# Compute C(m, k) for k=0..m
function compute_comb(m: i64, comb: ptr<i64>) -> void {
    # Compute exact C(m,k) for k=0..m, then reduce mod MOD
    # C(m,k) fits in i64 for m<=40 (max C(40,20) ~ 1.38e11)
    comb[0] = 1
    for k in 1..(m + 1) {
        comb[k] = comb[k - 1] * (m - k + 1) / k
    }
    for k in 0..(m + 1) {
        comb[k] = comb[k] % MOD
    }
}

function f(m: i64, a: i64, b: i64) -> i64 {
    let ntypes_a: i64 = dihedral_types(a)
    # Save type_a data
    let saved_ncyc_a: ptr<i64> = calloc(MAX_TYPES, 8)
    let saved_mult_a: ptr<i64> = calloc(MAX_TYPES, 8)
    let saved_clen_a: ptr<i64> = calloc(MAX_TYPES * MAX_CYCLES_PER_TYPE, 8)
    let saved_ccnt_a: ptr<i64> = calloc(MAX_TYPES * MAX_CYCLES_PER_TYPE, 8)
    for i in 0..ntypes_a {
        saved_ncyc_a[i] = g_type_ncyc[i]
        saved_mult_a[i] = g_type_mult[i]
        for j in 0..MAX_CYCLES_PER_TYPE {
            saved_clen_a[i * MAX_CYCLES_PER_TYPE + j] = g_type_clen[i * MAX_CYCLES_PER_TYPE + j]
            saved_ccnt_a[i * MAX_CYCLES_PER_TYPE + j] = g_type_ccnt[i * MAX_CYCLES_PER_TYPE + j]
        }
    }

    let ntypes_b: i64 = dihedral_types(b)

    # Aggregate weights by number of cycles
    # Max cycles is a*b, use a hash map approach
    # Since a,b <= F_40 ~ 10^8, a*b can be huge. But the number of distinct cycle counts is small.
    # Use arrays: weights_cycles[0..ntypes_a*ntypes_b], weights_val[0..ntypes_a*ntypes_b]
    let max_pairs: i64 = ntypes_a * ntypes_b + 1
    let w_cycles: ptr<i64> = calloc(max_pairs, 8)
    let w_vals: ptr<i64> = calloc(max_pairs, 8)
    let mut n_weights: i64 = 0

    for ia in 0..ntypes_a {
        let mult_a: i64 = saved_mult_a[ia]
        for ib in 0..ntypes_b {
            let mult_b: i64 = g_type_mult[ib]
            # Compute cycles using saved type_a and current type_b
            let na: i64 = saved_ncyc_a[ia]
            let nb: i64 = g_type_ncyc[ib]
            let mut c: i64 = 0
            for i in 0..na {
                let la: i64 = saved_clen_a[ia * MAX_CYCLES_PER_TYPE + i]
                let ca: i64 = saved_ccnt_a[ia * MAX_CYCLES_PER_TYPE + i]
                for j in 0..nb {
                    let lb: i64 = g_type_clen[ib * MAX_CYCLES_PER_TYPE + j]
                    let cb: i64 = g_type_ccnt[ib * MAX_CYCLES_PER_TYPE + j]
                    c = c + ca * cb * mygcd(la, lb)
                }
            }

            let w: i64 = (mult_a * mult_b) % MOD

            # Find or add cycle count
            let mut found: i64 = -1
            for wi in 0..n_weights {
                if w_cycles[wi] == c { found = wi }
            }
            if found == -1 {
                w_cycles[n_weights] = c
                w_vals[n_weights] = w
                n_weights = n_weights + 1
            } else {
                w_vals[found] = (w_vals[found] + w) % MOD
            }
        }
    }

    let comb: ptr<i64> = calloc(m + 1, 8)
    compute_comb(m, comb)

    let mut num: i64 = 0
    for wi in 0..n_weights {
        let val: i64 = surjections_count(w_cycles[wi], m, comb)
        num = (num + w_vals[wi] * val) % MOD
    }

    let den: i64 = (4 * (a % MOD) * (b % MOD)) % MOD
    let result: i64 = (num * pow_mod(den, MOD - 2, MOD)) % MOD

    free(comb)
    free(w_vals)
    free(w_cycles)
    free(saved_ccnt_a)
    free(saved_clen_a)
    free(saved_mult_a)
    free(saved_ncyc_a)
    return result
}

function main() -> i32 {
    sieve_primes()
    init_type_arrays()

    # Fibonacci numbers F[0..40]
    let fib: ptr<i64> = calloc(41, 8)
    fib[0] = 0
    fib[1] = 1
    for i in 2..41 {
        fib[i] = fib[i - 1] + fib[i - 2]
    }

    let mut ans: i64 = 0
    for i in 4..41 {
        ans = (ans + f(i, fib[i - 1], fib[i])) % MOD
    }

    printf("%lld\n", ans)

    free(fib)
    free(g_type_ccnt)
    free(g_type_clen)
    free(g_type_mult)
    free(g_type_ncyc)
    free(g_primes)
    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 pow_mod_i64_i64_i64(int64_t base, int64_t exp, int64_t m);
int64_t mygcd_i64_i64(int64_t a, int64_t b);
void sieve_primes(void);
int64_t factorize_i64_ptr_i64_ptr_i64(int64_t n, int64_t* fps, int64_t* fes);
int64_t divisors_phi_i64_ptr_i64_ptr_i64_ptr_i64_ptr_i64(int64_t nf, int64_t* fps, int64_t* fes, int64_t* divs, int64_t* phis);
void init_type_arrays(void);
int64_t dihedral_types_i64(int64_t n);
int64_t cycles_on_grid_i64_i64(int64_t type_a_idx, int64_t type_b_idx);
int64_t surjections_count_i64_i64_ptr_i64(int64_t cycles, int64_t m, int64_t* comb);
void compute_comb_i64_ptr_i64(int64_t m, int64_t* comb);
int64_t f_i64_i64_i64(int64_t m, int64_t a, int64_t b);
int32_t main(void);

static const int64_t MOD = 1000000007;
static const int64_t MAX_PRIME = 20001;
static const int64_t MAX_TYPES = 10000;
static const int64_t MAX_CYCLES_PER_TYPE = 3;

/* Module statics */
static int64_t* g_primes = NULL;
static int64_t g_nprimes = 0;
static int64_t* g_type_ncyc = NULL;
static int64_t* g_type_mult = NULL;
static int64_t* g_type_clen = NULL;
static int64_t* g_type_ccnt = NULL;

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 pow_mod_i64_i64_i64(int64_t base, int64_t exp, int64_t m) {
    int64_t r = 1;
    int64_t b = FLOW_CHECKED_MOD((base), (m));
    int64_t e = exp;
    while (e > 0) {
        if ((e & 1) == 1) {
            r = FLOW_CHECKED_MOD(((r * b)), (m));
        }
        b = FLOW_CHECKED_MOD(((b * b)), (m));
        e = FLOW_CHECKED_SHR((e), (1));
    }
    return r;
}

int64_t mygcd_i64_i64(int64_t a, int64_t b) {
    int64_t x = a;
    int64_t y = b;
    while (y > 0) {
        int64_t t = FLOW_CHECKED_MOD((x), (y));
        x = y;
        y = t;
    }
    return x;
}

void sieve_primes(void) {
    int8_t* bs = (int8_t*)(calloc(MAX_PRIME, 1));
    int32_t __flow_step_1 = 1;
    for (int32_t i = 0; (0 <= MAX_PRIME) ? i < MAX_PRIME : i > MAX_PRIME; i += (0 <= MAX_PRIME) ? 1 : -1) {
        bs[i] = 1;
    }
    bs[0] = 0;
    bs[1] = 0;
    int64_t r = isqrt_i64(MAX_PRIME);
    int32_t __flow_step_2 = 1;
    for (int32_t i = 2; (2 <= (r + 1)) ? i < (r + 1) : i > (r + 1); i += (2 <= (r + 1)) ? 1 : -1) {
        if (bs[i] == 1) {
            int64_t j = (i * i);
            while (j < MAX_PRIME) {
                bs[j] = 0;
                j = (j + i);
            }
        }
    }
    int64_t cnt = 0;
    int32_t __flow_step_3 = 1;
    for (int32_t i = 0; (0 <= MAX_PRIME) ? i < MAX_PRIME : i > MAX_PRIME; i += (0 <= MAX_PRIME) ? 1 : -1) {
        if (bs[i] == 1) {
            cnt = (cnt + 1);
        }
    }
    g_primes = calloc(cnt, 8);
    int64_t idx = 0;
    int32_t __flow_step_4 = 1;
    for (int32_t i = 0; (0 <= MAX_PRIME) ? i < MAX_PRIME : i > MAX_PRIME; i += (0 <= MAX_PRIME) ? 1 : -1) {
        if (bs[i] == 1) {
            g_primes[idx] = i;
            idx = (idx + 1);
        }
    }
    g_nprimes = cnt;
    free(bs);
}

int64_t factorize_i64_ptr_i64_ptr_i64(int64_t n, int64_t* fps, int64_t* fes) {
    int64_t x = n;
    int64_t nf = 0;
    int32_t __flow_step_5 = 1;
    for (int32_t i = 0; (0 <= g_nprimes) ? i < g_nprimes : i > g_nprimes; i += (0 <= g_nprimes) ? 1 : -1) {
        int64_t p = g_primes[i];
        if ((p * p) > x) {
            break;
        }
        if (FLOW_CHECKED_MOD((x), (p)) == 0) {
            int64_t e = 0;
            while (FLOW_CHECKED_MOD((x), (p)) == 0) {
                x = FLOW_CHECKED_DIV((x), (p));
                e = (e + 1);
            }
            fps[nf] = p;
            fes[nf] = e;
            nf = (nf + 1);
        }
    }
    if (x > 1) {
        fps[nf] = x;
        fes[nf] = 1;
        nf = (nf + 1);
    }
    return nf;
}

int64_t divisors_phi_i64_ptr_i64_ptr_i64_ptr_i64_ptr_i64(int64_t nf, int64_t* fps, int64_t* fes, int64_t* divs, int64_t* phis) {
    divs[0] = 1;
    phis[0] = 1;
    int64_t count = 1;
    int32_t __flow_step_6 = 1;
    for (int32_t i = 0; (0 <= nf) ? i < nf : i > nf; i += (0 <= nf) ? 1 : -1) {
        int64_t p = fps[i];
        int64_t e = fes[i];
        int64_t prev_count = count;
        int64_t pk = 1;
        int32_t __flow_step_7 = 1;
        for (int32_t k = 0; (0 <= (e + 1)) ? k < (e + 1) : k > (e + 1); k += (0 <= (e + 1)) ? 1 : -1) {
            int64_t phi_pk;
            if (k == 0) {
                phi_pk = 1;
            } else {
                phi_pk = (FLOW_CHECKED_DIV((pk), (p)) * (p - 1));
            }
            if (k > 0) {
                int32_t __flow_step_8 = 1;
                for (int32_t j = 0; (0 <= prev_count) ? j < prev_count : j > prev_count; j += (0 <= prev_count) ? 1 : -1) {
                    divs[count] = (divs[j] * pk);
                    phis[count] = (phis[j] * phi_pk);
                    count = (count + 1);
                }
            }
            pk = (pk * p);
        }
    }
    return count;
}

void init_type_arrays(void) {
    g_type_ncyc = calloc(MAX_TYPES, 8);
    g_type_mult = calloc(MAX_TYPES, 8);
    g_type_clen = calloc((MAX_TYPES * MAX_CYCLES_PER_TYPE), 8);
    g_type_ccnt = calloc((MAX_TYPES * MAX_CYCLES_PER_TYPE), 8);
}

int64_t dihedral_types_i64(int64_t n) {
    int64_t* fps = (int64_t*)(calloc(20, 8));
    int64_t* fes = (int64_t*)(calloc(20, 8));
    int64_t nf = factorize_i64_ptr_i64_ptr_i64(n, fps, fes);
    int64_t* divs = (int64_t*)(calloc(10000, 8));
    int64_t* phis = (int64_t*)(calloc(10000, 8));
    int64_t ndiv = divisors_phi_i64_ptr_i64_ptr_i64_ptr_i64_ptr_i64(nf, fps, fes, divs, phis);
    int64_t ntypes = 0;
    int32_t __flow_step_9 = 1;
    for (int32_t i = 0; (0 <= ndiv) ? i < ndiv : i > ndiv; i += (0 <= ndiv) ? 1 : -1) {
        int64_t L = divs[i];
        int64_t phiL = phis[i];
        g_type_ncyc[ntypes] = 1;
        g_type_mult[ntypes] = phiL;
        g_type_clen[((ntypes * MAX_CYCLES_PER_TYPE) + 0)] = L;
        g_type_ccnt[((ntypes * MAX_CYCLES_PER_TYPE) + 0)] = FLOW_CHECKED_DIV((n), (L));
        ntypes = (ntypes + 1);
    }
    if (FLOW_CHECKED_MOD((n), (2)) == 1) {
        g_type_ncyc[ntypes] = 2;
        g_type_mult[ntypes] = n;
        g_type_clen[((ntypes * MAX_CYCLES_PER_TYPE) + 0)] = 1;
        g_type_ccnt[((ntypes * MAX_CYCLES_PER_TYPE) + 0)] = 1;
        g_type_clen[((ntypes * MAX_CYCLES_PER_TYPE) + 1)] = 2;
        g_type_ccnt[((ntypes * MAX_CYCLES_PER_TYPE) + 1)] = FLOW_CHECKED_DIV(((n - 1)), (2));
        ntypes = (ntypes + 1);
    } else {
        g_type_ncyc[ntypes] = 2;
        g_type_mult[ntypes] = FLOW_CHECKED_DIV((n), (2));
        g_type_clen[((ntypes * MAX_CYCLES_PER_TYPE) + 0)] = 1;
        g_type_ccnt[((ntypes * MAX_CYCLES_PER_TYPE) + 0)] = 2;
        g_type_clen[((ntypes * MAX_CYCLES_PER_TYPE) + 1)] = 2;
        g_type_ccnt[((ntypes * MAX_CYCLES_PER_TYPE) + 1)] = FLOW_CHECKED_DIV(((n - 2)), (2));
        ntypes = (ntypes + 1);
        g_type_ncyc[ntypes] = 1;
        g_type_mult[ntypes] = FLOW_CHECKED_DIV((n), (2));
        g_type_clen[((ntypes * MAX_CYCLES_PER_TYPE) + 0)] = 2;
        g_type_ccnt[((ntypes * MAX_CYCLES_PER_TYPE) + 0)] = FLOW_CHECKED_DIV((n), (2));
        ntypes = (ntypes + 1);
    }
    free(phis);
    free(divs);
    free(fes);
    free(fps);
    return ntypes;
}

int64_t cycles_on_grid_i64_i64(int64_t type_a_idx, int64_t type_b_idx) {
    int64_t na = g_type_ncyc[type_a_idx];
    int64_t nb = g_type_ncyc[type_b_idx];
    int64_t total = 0;
    int32_t __flow_step_10 = 1;
    for (int32_t i = 0; (0 <= na) ? i < na : i > na; i += (0 <= na) ? 1 : -1) {
        int64_t la = g_type_clen[((type_a_idx * MAX_CYCLES_PER_TYPE) + i)];
        int64_t ca = g_type_ccnt[((type_a_idx * MAX_CYCLES_PER_TYPE) + i)];
        int32_t __flow_step_11 = 1;
        for (int32_t j = 0; (0 <= nb) ? j < nb : j > nb; j += (0 <= nb) ? 1 : -1) {
            int64_t lb = g_type_clen[((type_b_idx * MAX_CYCLES_PER_TYPE) + j)];
            int64_t cb = g_type_ccnt[((type_b_idx * MAX_CYCLES_PER_TYPE) + j)];
            total = (total + ((ca * cb) * mygcd_i64_i64(la, lb)));
        }
    }
    return total;
}

int64_t surjections_count_i64_i64_ptr_i64(int64_t cycles, int64_t m, int64_t* comb) {
    int64_t s = 0;
    int32_t __flow_step_12 = 1;
    for (int32_t k = 0; (0 <= (m + 1)) ? k < (m + 1) : k > (m + 1); k += (0 <= (m + 1)) ? 1 : -1) {
        int64_t base = (m - k);
        int64_t term = FLOW_CHECKED_MOD(((comb[k] * pow_mod_i64_i64_i64(base, cycles, MOD))), (MOD));
        if ((k & 1) == 1) {
            s = (s - term);
        } else {
            s = (s + term);
        }
    }
    s = FLOW_CHECKED_MOD((s), (MOD));
    if (s < 0) {
        s = (s + MOD);
    }
    return s;
}

void compute_comb_i64_ptr_i64(int64_t m, int64_t* comb) {
    comb[0] = 1;
    int32_t __flow_step_13 = 1;
    for (int32_t k = 1; (1 <= (m + 1)) ? k < (m + 1) : k > (m + 1); k += (1 <= (m + 1)) ? 1 : -1) {
        comb[k] = FLOW_CHECKED_DIV(((comb[(k - 1)] * ((m - k) + 1))), (k));
    }
    int32_t __flow_step_14 = 1;
    for (int32_t k = 0; (0 <= (m + 1)) ? k < (m + 1) : k > (m + 1); k += (0 <= (m + 1)) ? 1 : -1) {
        comb[k] = FLOW_CHECKED_MOD((comb[k]), (MOD));
    }
}

int64_t f_i64_i64_i64(int64_t m, int64_t a, int64_t b) {
    int64_t ntypes_a = dihedral_types_i64(a);
    int64_t* saved_ncyc_a = (int64_t*)(calloc(MAX_TYPES, 8));
    int64_t* saved_mult_a = (int64_t*)(calloc(MAX_TYPES, 8));
    int64_t* saved_clen_a = (int64_t*)(calloc((MAX_TYPES * MAX_CYCLES_PER_TYPE), 8));
    int64_t* saved_ccnt_a = (int64_t*)(calloc((MAX_TYPES * MAX_CYCLES_PER_TYPE), 8));
    int32_t __flow_step_15 = 1;
    for (int32_t i = 0; (0 <= ntypes_a) ? i < ntypes_a : i > ntypes_a; i += (0 <= ntypes_a) ? 1 : -1) {
        saved_ncyc_a[i] = g_type_ncyc[i];
        saved_mult_a[i] = g_type_mult[i];
        int32_t __flow_step_16 = 1;
        for (int32_t j = 0; (0 <= MAX_CYCLES_PER_TYPE) ? j < MAX_CYCLES_PER_TYPE : j > MAX_CYCLES_PER_TYPE; j += (0 <= MAX_CYCLES_PER_TYPE) ? 1 : -1) {
            saved_clen_a[((i * MAX_CYCLES_PER_TYPE) + j)] = g_type_clen[((i * MAX_CYCLES_PER_TYPE) + j)];
            saved_ccnt_a[((i * MAX_CYCLES_PER_TYPE) + j)] = g_type_ccnt[((i * MAX_CYCLES_PER_TYPE) + j)];
        }
    }
    int64_t ntypes_b = dihedral_types_i64(b);
    int64_t max_pairs = ((ntypes_a * ntypes_b) + 1);
    int64_t* w_cycles = (int64_t*)(calloc(max_pairs, 8));
    int64_t* w_vals = (int64_t*)(calloc(max_pairs, 8));
    int64_t n_weights = 0;
    int32_t __flow_step_17 = 1;
    for (int32_t ia = 0; (0 <= ntypes_a) ? ia < ntypes_a : ia > ntypes_a; ia += (0 <= ntypes_a) ? 1 : -1) {
        int64_t mult_a = saved_mult_a[ia];
        int32_t __flow_step_18 = 1;
        for (int32_t ib = 0; (0 <= ntypes_b) ? ib < ntypes_b : ib > ntypes_b; ib += (0 <= ntypes_b) ? 1 : -1) {
            int64_t mult_b = g_type_mult[ib];
            int64_t na = saved_ncyc_a[ia];
            int64_t nb = g_type_ncyc[ib];
            int64_t c = 0;
            int32_t __flow_step_19 = 1;
            for (int32_t i = 0; (0 <= na) ? i < na : i > na; i += (0 <= na) ? 1 : -1) {
                int64_t la = saved_clen_a[((ia * MAX_CYCLES_PER_TYPE) + i)];
                int64_t ca = saved_ccnt_a[((ia * MAX_CYCLES_PER_TYPE) + i)];
                int32_t __flow_step_20 = 1;
                for (int32_t j = 0; (0 <= nb) ? j < nb : j > nb; j += (0 <= nb) ? 1 : -1) {
                    int64_t lb = g_type_clen[((ib * MAX_CYCLES_PER_TYPE) + j)];
                    int64_t cb = g_type_ccnt[((ib * MAX_CYCLES_PER_TYPE) + j)];
                    c = (c + ((ca * cb) * mygcd_i64_i64(la, lb)));
                }
            }
            int64_t w = FLOW_CHECKED_MOD(((mult_a * mult_b)), (MOD));
            int64_t found = (-1);
            int32_t __flow_step_21 = 1;
            for (int32_t wi = 0; (0 <= n_weights) ? wi < n_weights : wi > n_weights; wi += (0 <= n_weights) ? 1 : -1) {
                if (w_cycles[wi] == c) {
                    found = wi;
                }
            }
            if (found == (-1)) {
                w_cycles[n_weights] = c;
                w_vals[n_weights] = w;
                n_weights = (n_weights + 1);
            } else {
                w_vals[found] = FLOW_CHECKED_MOD(((w_vals[found] + w)), (MOD));
            }
        }
    }
    int64_t* comb = (int64_t*)(calloc((m + 1), 8));
    compute_comb_i64_ptr_i64(m, comb);
    int64_t num = 0;
    int32_t __flow_step_22 = 1;
    for (int32_t wi = 0; (0 <= n_weights) ? wi < n_weights : wi > n_weights; wi += (0 <= n_weights) ? 1 : -1) {
        int64_t val = surjections_count_i64_i64_ptr_i64(w_cycles[wi], m, comb);
        num = FLOW_CHECKED_MOD(((num + (w_vals[wi] * val))), (MOD));
    }
    int64_t den = FLOW_CHECKED_MOD((((4 * FLOW_CHECKED_MOD((a), (MOD))) * FLOW_CHECKED_MOD((b), (MOD)))), (MOD));
    int64_t result = FLOW_CHECKED_MOD(((num * pow_mod_i64_i64_i64(den, (MOD - 2), MOD))), (MOD));
    free(comb);
    free(w_vals);
    free(w_cycles);
    free(saved_ccnt_a);
    free(saved_clen_a);
    free(saved_mult_a);
    free(saved_ncyc_a);
    return result;
}

int32_t main(void) {
    sieve_primes();
    init_type_arrays();
    int64_t* fib = (int64_t*)(calloc(41, 8));
    fib[0] = 0;
    fib[1] = 1;
    int32_t __flow_step_23 = 1;
    for (int32_t i = 2; (2 <= 41) ? i < 41 : i > 41; i += (2 <= 41) ? 1 : -1) {
        fib[i] = (fib[(i - 1)] + fib[(i - 2)]);
    }
    int64_t ans = 0;
    int32_t __flow_step_24 = 1;
    for (int32_t i = 4; (4 <= 41) ? i < 41 : i > 41; i += (4 <= 41) ? 1 : -1) {
        ans = FLOW_CHECKED_MOD(((ans + f_i64_i64_i64(i, fib[(i - 1)], fib[i]))), (MOD));
    }
    printf("%lld\n", ans);
    free(fib);
    free(g_type_ccnt);
    free(g_type_clen);
    free(g_type_mult);
    free(g_type_ncyc);
    free(g_primes);
    return 0;
}

Generated MLIR

module {
  llvm.func @printf(!llvm.ptr, ...) -> i32
  llvm.mlir.global internal constant @str_0("%lld\n\00") {addr_space = 0 : i32} : !llvm.array<6 x i8>
  func.func @gcd(%arg0: i64, %arg1: i64) -> i64 {
    %0 = llvm.mlir.constant(1 : i64) : i64
    %1 = llvm.alloca %0 x i64 : (i64) -> !llvm.ptr
    llvm.store %arg0, %1 : i64, !llvm.ptr
    %2 = llvm.mlir.constant(1 : i64) : i64
    %3 = llvm.alloca %2 x i64 : (i64) -> !llvm.ptr
    llvm.store %arg1, %3 : i64, !llvm.ptr
    cf.br ^bb0
    ^bb0:
    %4 = llvm.load %3 : !llvm.ptr -> i64
    %5 = arith.constant 0 : i32
    %7 = arith.extsi %5 : i32 to i64
    %6 = arith.cmpi ne, %4, %7 : i64
    cf.cond_br %6, ^bb1, ^bb2
    ^bb1:
      %8 = llvm.load %1 : !llvm.ptr -> i64
      %9 = llvm.load %3 : !llvm.ptr -> i64
      %10 = arith.remsi %8, %9 : i64
      %11 = llvm.load %3 : !llvm.ptr -> i64
      llvm.store %11, %1 : i64, !llvm.ptr
      llvm.store %10, %3 : i64, !llvm.ptr
      cf.br ^bb0
    ^bb2:
    %12 = llvm.load %1 : !llvm.ptr -> i64
    func.return %12 : i64
  }
  func.func @lcm(%arg0: i64, %arg1: i64) -> i64 {
    %13 = arith.constant 0 : i32
    %15 = arith.extsi %13 : i32 to i64
    %14 = arith.cmpi eq, %arg0, %15 : i64
    %16 = scf.if %14 -> (i1) {
      %17 = arith.constant true
      scf.yield %17 : i1
    } else {
      %18 = arith.constant 0 : i32
      %20 = arith.extsi %18 : i32 to i64
      %19 = arith.cmpi eq, %arg1, %20 : i64
      scf.yield %19 : i1
    }
    cf.cond_br %16, ^bb3, ^bb4
    ^bb3:
      %21 = arith.constant 0 : i32
      %22 = arith.extsi %21 : i32 to i64
      func.return %22 : i64
    ^bb4:
      cf.br ^bb5
    ^bb5:
    %23 = func.call @gcd(%arg0, %arg1) : (i64, i64) -> i64
    %24 = arith.divsi %arg0, %23 : i64
    %25 = arith.muli %24, %arg1 : i64
    func.return %25 : i64
  }
  func.func @isqrt(%arg0: i64) -> i64 {
    %26 = arith.constant 2 : i32
    %28 = arith.extsi %26 : i32 to i64
    %27 = arith.cmpi slt, %arg0, %28 : i64
    cf.cond_br %27, ^bb6, ^bb7
    ^bb6:
      func.return %arg0 : i64
    ^bb7:
      cf.br ^bb8
    ^bb8:
    %29 = llvm.mlir.constant(1 : i64) : i64
    %30 = llvm.alloca %29 x i64 : (i64) -> !llvm.ptr
    llvm.store %arg0, %30 : i64, !llvm.ptr
    %31 = llvm.load %30 : !llvm.ptr -> i64
    %32 = arith.constant 1 : i32
    %34 = arith.extsi %32 : i32 to i64
    %33 = arith.addi %31, %34 : i64
    %35 = arith.constant 2 : i32
    %37 = arith.extsi %35 : i32 to i64
    %36 = arith.divsi %33, %37 : i64
    %38 = llvm.mlir.constant(1 : i64) : i64
    %39 = llvm.alloca %38 x i64 : (i64) -> !llvm.ptr
    llvm.store %36, %39 : i64, !llvm.ptr
    cf.br ^bb9
    ^bb9:
    %40 = llvm.load %39 : !llvm.ptr -> i64
    %41 = llvm.load %30 : !llvm.ptr -> i64
    %42 = arith.cmpi slt, %40, %41 : i64
    cf.cond_br %42, ^bb10, ^bb11
    ^bb10:
      %43 = llvm.load %39 : !llvm.ptr -> i64
      llvm.store %43, %30 : i64, !llvm.ptr
      %44 = llvm.load %30 : !llvm.ptr -> i64
      %45 = llvm.load %30 : !llvm.ptr -> i64
      %46 = arith.divsi %arg0, %45 : i64
      %47 = arith.addi %44, %46 : i64
      %48 = arith.constant 2 : i32
      %50 = arith.extsi %48 : i32 to i64
      %49 = arith.divsi %47, %50 : i64
      llvm.store %49, %39 : i64, !llvm.ptr
      cf.br ^bb9
    ^bb11:
    %51 = llvm.load %30 : !llvm.ptr -> i64
    func.return %51 : i64
  }
  func.func @mulmod(%arg0: i64, %arg1: i64, %arg2: i64) -> i64 {
    %52 = arith.remsi %arg0, %arg2 : i64
    %53 = llvm.mlir.constant(1 : i64) : i64
    %54 = llvm.alloca %53 x i64 : (i64) -> !llvm.ptr
    llvm.store %52, %54 : i64, !llvm.ptr
    %55 = arith.remsi %arg1, %arg2 : i64
    %56 = llvm.mlir.constant(1 : i64) : i64
    %57 = llvm.alloca %56 x i64 : (i64) -> !llvm.ptr
    llvm.store %55, %57 : i64, !llvm.ptr
    %58 = arith.constant 0 : i32
    %59 = arith.extsi %58 : i32 to i64
    %60 = llvm.mlir.constant(1 : i64) : i64
    %61 = llvm.alloca %60 x i64 : (i64) -> !llvm.ptr
    llvm.store %59, %61 : i64, !llvm.ptr
    cf.br ^bb12
    ^bb12:
    %62 = llvm.load %57 : !llvm.ptr -> i64
    %63 = arith.constant 0 : i32
    %65 = arith.extsi %63 : i32 to i64
    %64 = arith.cmpi sgt, %62, %65 : i64
    cf.cond_br %64, ^bb13, ^bb14
    ^bb13:
      %66 = llvm.load %57 : !llvm.ptr -> i64
      %67 = arith.constant 2 : i32
      %69 = arith.extsi %67 : i32 to i64
      %68 = arith.remsi %66, %69 : i64
      %70 = arith.constant 1 : i32
      %72 = arith.extsi %70 : i32 to i64
      %71 = arith.cmpi eq, %68, %72 : i64
      cf.cond_br %71, ^bb15, ^bb16
      ^bb15:
        %73 = llvm.load %61 : !llvm.ptr -> i64
        %74 = llvm.load %54 : !llvm.ptr -> i64
        %75 = arith.addi %73, %74 : i64
        %76 = arith.remsi %75, %arg2 : i64
        llvm.store %76, %61 : i64, !llvm.ptr
        cf.br ^bb17
      ^bb16:
        cf.br ^bb17
      ^bb17:
      %77 = llvm.load %54 : !llvm.ptr -> i64
      %78 = arith.constant 2 : i32
      %80 = arith.extsi %78 : i32 to i64
      %79 = arith.muli %77, %80 : i64
      %81 = arith.remsi %79, %arg2 : i64
      llvm.store %81, %54 : i64, !llvm.ptr
      %82 = llvm.load %57 : !llvm.ptr -> i64
      %83 = arith.constant 2 : i32
      %85 = arith.extsi %83 : i32 to i64
      %84 = arith.divsi %82, %85 : i64
      llvm.store %84, %57 : i64, !llvm.ptr
      cf.br ^bb12
    ^bb14:
    %86 = llvm.load %61 : !llvm.ptr -> i64
    func.return %86 : i64
  }
  func.func @mod_pow(%arg0: i64, %arg1: i64, %arg2: i64) -> i64 {
    %87 = arith.constant 1 : i32
    %89 = arith.extsi %87 : i32 to i64
    %88 = arith.cmpi eq, %arg2, %89 : i64
    cf.cond_br %88, ^bb18, ^bb19
    ^bb18:
      %90 = arith.constant 0 : i32
      %91 = arith.extsi %90 : i32 to i64
      func.return %91 : i64
    ^bb19:
      cf.br ^bb20
    ^bb20:
    %92 = arith.constant 1 : i32
    %93 = arith.extsi %92 : i32 to i64
    %94 = llvm.mlir.constant(1 : i64) : i64
    %95 = llvm.alloca %94 x i64 : (i64) -> !llvm.ptr
    llvm.store %93, %95 : i64, !llvm.ptr
    %96 = arith.remsi %arg0, %arg2 : i64
    %97 = llvm.mlir.constant(1 : i64) : i64
    %98 = llvm.alloca %97 x i64 : (i64) -> !llvm.ptr
    llvm.store %96, %98 : i64, !llvm.ptr
    %99 = llvm.mlir.constant(1 : i64) : i64
    %100 = llvm.alloca %99 x i64 : (i64) -> !llvm.ptr
    llvm.store %arg1, %100 : i64, !llvm.ptr
    cf.br ^bb21
    ^bb21:
    %101 = llvm.load %100 : !llvm.ptr -> i64
    %102 = arith.constant 0 : i32
    %104 = arith.extsi %102 : i32 to i64
    %103 = arith.cmpi sgt, %101, %104 : i64
    cf.cond_br %103, ^bb22, ^bb23
    ^bb22:
      %105 = llvm.load %100 : !llvm.ptr -> i64
      %106 = arith.constant 2 : i32
      %108 = arith.extsi %106 : i32 to i64
      %107 = arith.remsi %105, %108 : i64
      %109 = arith.constant 1 : i32
      %111 = arith.extsi %109 : i32 to i64
      %110 = arith.cmpi eq, %107, %111 : i64
      cf.cond_br %110, ^bb24, ^bb25
      ^bb24:
        %113 = llvm.load %95 : !llvm.ptr -> i64
        %114 = llvm.load %98 : !llvm.ptr -> i64
        %112 = func.call @mulmod(%113, %114, %arg2) : (i64, i64, i64) -> i64
        llvm.store %112, %95 : i64, !llvm.ptr
        cf.br ^bb26
      ^bb25:
        cf.br ^bb26
      ^bb26:
      %116 = llvm.load %98 : !llvm.ptr -> i64
      %117 = llvm.load %98 : !llvm.ptr -> i64
      %115 = func.call @mulmod(%116, %117, %arg2) : (i64, i64, i64) -> i64
      llvm.store %115, %98 : i64, !llvm.ptr
      %118 = llvm.load %100 : !llvm.ptr -> i64
      %119 = arith.constant 2 : i32
      %121 = arith.extsi %119 : i32 to i64
      %120 = arith.divsi %118, %121 : i64
      llvm.store %120, %100 : i64, !llvm.ptr
      cf.br ^bb21
    ^bb23:
    %122 = llvm.load %95 : !llvm.ptr -> i64
    func.return %122 : i64
  }
  func.func @is_prime(%arg0: i64) -> i1 {
    %123 = arith.constant 2 : i32
    %125 = arith.extsi %123 : i32 to i64
    %124 = arith.cmpi slt, %arg0, %125 : i64
    cf.cond_br %124, ^bb27, ^bb28
    ^bb27:
      %126 = arith.constant 0 : i1
      func.return %126 : i1
    ^bb28:
      cf.br ^bb29
    ^bb29:
    %127 = arith.constant 4 : i32
    %129 = arith.extsi %127 : i32 to i64
    %128 = arith.cmpi slt, %arg0, %129 : i64
    cf.cond_br %128, ^bb30, ^bb31
    ^bb30:
      %130 = arith.constant 1 : i1
      func.return %130 : i1
    ^bb31:
      cf.br ^bb32
    ^bb32:
    %131 = arith.constant 2 : i32
    %133 = arith.extsi %131 : i32 to i64
    %132 = arith.remsi %arg0, %133 : i64
    %134 = arith.constant 0 : i32
    %136 = arith.extsi %134 : i32 to i64
    %135 = arith.cmpi eq, %132, %136 : i64
    %137 = scf.if %135 -> (i1) {
      %138 = arith.constant true
      scf.yield %138 : i1
    } else {
      %139 = arith.constant 3 : i32
      %141 = arith.extsi %139 : i32 to i64
      %140 = arith.remsi %arg0, %141 : i64
      %142 = arith.constant 0 : i32
      %144 = arith.extsi %142 : i32 to i64
      %143 = arith.cmpi eq, %140, %144 : i64
      scf.yield %143 : i1
    }
    cf.cond_br %137, ^bb33, ^bb34
    ^bb33:
      %145 = arith.constant 0 : i1
      func.return %145 : i1
    ^bb34:
      cf.br ^bb35
    ^bb35:
    %146 = arith.constant 5 : i32
    %147 = arith.extsi %146 : i32 to i64
    %148 = llvm.mlir.constant(1 : i64) : i64
    %149 = llvm.alloca %148 x i64 : (i64) -> !llvm.ptr
    llvm.store %147, %149 : i64, !llvm.ptr
    cf.br ^bb36
    ^bb36:
    %150 = llvm.load %149 : !llvm.ptr -> i64
    %151 = llvm.load %149 : !llvm.ptr -> i64
    %152 = arith.muli %150, %151 : i64
    %153 = arith.cmpi sle, %152, %arg0 : i64
    cf.cond_br %153, ^bb37, ^bb38
    ^bb37:
      %154 = llvm.load %149 : !llvm.ptr -> i64
      %155 = arith.remsi %arg0, %154 : i64
      %156 = arith.constant 0 : i32
      %158 = arith.extsi %156 : i32 to i64
      %157 = arith.cmpi eq, %155, %158 : i64
      %159 = scf.if %157 -> (i1) {
        %160 = arith.constant true
        scf.yield %160 : i1
      } else {
        %161 = llvm.load %149 : !llvm.ptr -> i64
        %162 = arith.constant 2 : i32
        %164 = arith.extsi %162 : i32 to i64
        %163 = arith.addi %161, %164 : i64
        %165 = arith.remsi %arg0, %163 : i64
        %166 = arith.constant 0 : i32
        %168 = arith.extsi %166 : i32 to i64
        %167 = arith.cmpi eq, %165, %168 : i64
        scf.yield %167 : i1
      }
      cf.cond_br %159, ^bb39, ^bb40
      ^bb39:
        %169 = arith.constant 0 : i1
        func.return %169 : i1
      ^bb40:
        cf.br ^bb41
      ^bb41:
      %170 = llvm.load %149 : !llvm.ptr -> i64
      %171 = arith.constant 6 : i32
      %173 = arith.extsi %171 : i32 to i64
      %172 = arith.addi %170, %173 : i64
      llvm.store %172, %149 : i64, !llvm.ptr
      cf.br ^bb36
    ^bb38:
    %174 = arith.constant 1 : i1
    func.return %174 : i1
  }
  func.func private @calloc(i64, i64) -> !llvm.ptr
  func.func private @free(!llvm.ptr) -> ()
  // Constant: MOD
  llvm.mlir.global internal constant @MOD(1000000007 : i64) : i64
  func.func @pow_mod(%arg0: i64, %arg1: i64, %arg2: i64) -> i64 {
    %175 = arith.constant 1 : i32
    %176 = arith.extsi %175 : i32 to i64
    %177 = llvm.mlir.constant(1 : i64) : i64
    %178 = llvm.alloca %177 x i64 : (i64) -> !llvm.ptr
    llvm.store %176, %178 : i64, !llvm.ptr
    %179 = arith.remsi %arg0, %arg2 : i64
    %180 = llvm.mlir.constant(1 : i64) : i64
    %181 = llvm.alloca %180 x i64 : (i64) -> !llvm.ptr
    llvm.store %179, %181 : i64, !llvm.ptr
    %182 = llvm.mlir.constant(1 : i64) : i64
    %183 = llvm.alloca %182 x i64 : (i64) -> !llvm.ptr
    llvm.store %arg1, %183 : i64, !llvm.ptr
    cf.br ^bb42
    ^bb42:
    %184 = llvm.load %183 : !llvm.ptr -> i64
    %185 = arith.constant 0 : i32
    %187 = arith.extsi %185 : i32 to i64
    %186 = arith.cmpi sgt, %184, %187 : i64
    cf.cond_br %186, ^bb43, ^bb44
    ^bb43:
      %188 = llvm.load %183 : !llvm.ptr -> i64
      %189 = arith.constant 1 : i32
      %191 = arith.extsi %189 : i32 to i64
      %190 = arith.andi %188, %191 : i64
      %192 = arith.constant 1 : i32
      %194 = arith.extsi %192 : i32 to i64
      %193 = arith.cmpi eq, %190, %194 : i64
      cf.cond_br %193, ^bb45, ^bb46
      ^bb45:
        %195 = llvm.load %178 : !llvm.ptr -> i64
        %196 = llvm.load %181 : !llvm.ptr -> i64
        %197 = arith.muli %195, %196 : i64
        %198 = arith.remsi %197, %arg2 : i64
        llvm.store %198, %178 : i64, !llvm.ptr
        cf.br ^bb47
      ^bb46:
        cf.br ^bb47
      ^bb47:
      %199 = llvm.load %181 : !llvm.ptr -> i64
      %200 = llvm.load %181 : !llvm.ptr -> i64
      %201 = arith.muli %199, %200 : i64
      %202 = arith.remsi %201, %arg2 : i64
      llvm.store %202, %181 : i64, !llvm.ptr
      %203 = llvm.load %183 : !llvm.ptr -> i64
      %204 = arith.constant 1 : i32
      %206 = arith.extsi %204 : i32 to i64
      %205 = arith.shrsi %203, %206 : i64
      llvm.store %205, %183 : i64, !llvm.ptr
      cf.br ^bb42
    ^bb44:
    %207 = llvm.load %178 : !llvm.ptr -> i64
    func.return %207 : i64
  }
  func.func @mygcd(%arg0: i64, %arg1: i64) -> i64 {
    %208 = llvm.mlir.constant(1 : i64) : i64
    %209 = llvm.alloca %208 x i64 : (i64) -> !llvm.ptr
    llvm.store %arg0, %209 : i64, !llvm.ptr
    %210 = llvm.mlir.constant(1 : i64) : i64
    %211 = llvm.alloca %210 x i64 : (i64) -> !llvm.ptr
    llvm.store %arg1, %211 : i64, !llvm.ptr
    cf.br ^bb48
    ^bb48:
    %212 = llvm.load %211 : !llvm.ptr -> i64
    %213 = arith.constant 0 : i32
    %215 = arith.extsi %213 : i32 to i64
    %214 = arith.cmpi sgt, %212, %215 : i64
    cf.cond_br %214, ^bb49, ^bb50
    ^bb49:
      %216 = llvm.load %209 : !llvm.ptr -> i64
      %217 = llvm.load %211 : !llvm.ptr -> i64
      %218 = arith.remsi %216, %217 : i64
      %219 = llvm.load %211 : !llvm.ptr -> i64
      llvm.store %219, %209 : i64, !llvm.ptr
      llvm.store %218, %211 : i64, !llvm.ptr
      cf.br ^bb48
    ^bb50:
    %220 = llvm.load %209 : !llvm.ptr -> i64
    func.return %220 : i64
  }
  // Constant: MAX_PRIME
  llvm.mlir.global internal constant @MAX_PRIME(20001 : i64) : i64
  // Module static: g_primes
  llvm.mlir.global internal @g_primes() {addr_space = 0 : i32} : !llvm.ptr {
    %221 = llvm.mlir.zero : !llvm.ptr
    llvm.return %221 : !llvm.ptr
  }
  // Module static: g_nprimes
  llvm.mlir.global internal @g_nprimes(0 : i64) : i64
  func.func @sieve_primes() -> () {
    %223 = llvm.mlir.addressof @MAX_PRIME : !llvm.ptr
    %224 = llvm.load %223 : !llvm.ptr -> i64
    %225 = arith.constant 1 : i32
    %226 = arith.extsi %225 : i32 to i64
    %222 = func.call @calloc(%224, %226) : (i64, i64) -> !llvm.ptr
    %227 = arith.constant 0 : i32
    %228 = llvm.mlir.addressof @MAX_PRIME : !llvm.ptr
    %229 = llvm.load %228 : !llvm.ptr -> i64
    %230 = arith.index_cast %227 : i32 to index
    %231 = arith.index_cast %229 : i32 to index
    %233 = arith.constant 1 : index
    %234 = arith.constant -1 : index
    %235 = arith.cmpi sle, %230, %231 : index
    %232 = arith.select %235, %233, %234 : index
    cf.br ^bb51(%230 : index)
    ^bb51(%236: index):
    %237 = arith.cmpi slt, %236, %231 : index
    %238 = arith.cmpi sgt, %236, %231 : index
    %239 = arith.select %235, %237, %238 : i1
    cf.cond_br %239, ^bb52(%236 : index), ^bb53(%236 : index)
    ^bb52(%240: index):
      %241 = arith.constant 1 : i32
      %242 = arith.trunci %241 : i32 to i8
      %243 = arith.index_cast %240 : index to i64
      %244 = llvm.getelementptr %222[%243] : (!llvm.ptr, i64) -> !llvm.ptr, i8
      llvm.store %242, %244 : i8, !llvm.ptr
      %245 = arith.addi %240, %232 : index
      cf.br ^bb51(%245 : index)
    ^bb53(%246: index):
    %247 = arith.constant 0 : i32
    %248 = arith.constant 0 : i32
    %249 = arith.trunci %247 : i32 to i8
    %250 = arith.extsi %248 : i32 to i64
    %251 = llvm.getelementptr %222[%250] : (!llvm.ptr, i64) -> !llvm.ptr, i8
    llvm.store %249, %251 : i8, !llvm.ptr
    %252 = arith.constant 0 : i32
    %253 = arith.constant 1 : i32
    %254 = arith.trunci %252 : i32 to i8
    %255 = arith.extsi %253 : i32 to i64
    %256 = llvm.getelementptr %222[%255] : (!llvm.ptr, i64) -> !llvm.ptr, i8
    llvm.store %254, %256 : i8, !llvm.ptr
    %258 = llvm.mlir.addressof @MAX_PRIME : !llvm.ptr
    %259 = llvm.load %258 : !llvm.ptr -> i64
    %257 = func.call @isqrt(%259) : (i64) -> i64
    %260 = arith.constant 2 : i32
    %261 = arith.constant 1 : i32
    %263 = arith.extsi %261 : i32 to i64
    %262 = arith.addi %257, %263 : i64
    %264 = arith.index_cast %260 : i32 to index
    %265 = arith.index_cast %262 : i32 to index
    %267 = arith.constant 1 : index
    %268 = arith.constant -1 : index
    %269 = arith.cmpi sle, %264, %265 : index
    %266 = arith.select %269, %267, %268 : index
    cf.br ^bb54(%264 : index)
    ^bb54(%270: index):
    %271 = arith.cmpi slt, %270, %265 : index
    %272 = arith.cmpi sgt, %270, %265 : index
    %273 = arith.select %269, %271, %272 : i1
    cf.cond_br %273, ^bb55(%270 : index), ^bb56(%270 : index)
    ^bb55(%274: index):
      %276 = arith.index_cast %274 : index to i64
      %277 = llvm.getelementptr %222[%276] : (!llvm.ptr, i64) -> !llvm.ptr, i8
      %275 = llvm.load %277 : !llvm.ptr -> i8
      %278 = arith.constant 1 : i32
      %280 = arith.extsi %275 : i8 to i32
      %279 = arith.cmpi eq, %280, %278 : i32
      cf.cond_br %279, ^bb57, ^bb58
      ^bb57:
        %281 = arith.muli %274, %274 : index
        %282 = arith.index_cast %281 : index to i64
        %283 = llvm.mlir.constant(1 : i64) : i64
        %284 = llvm.alloca %283 x i64 : (i64) -> !llvm.ptr
        llvm.store %282, %284 : i64, !llvm.ptr
        cf.br ^bb60
        ^bb60:
        %285 = llvm.load %284 : !llvm.ptr -> i64
        %286 = llvm.mlir.addressof @MAX_PRIME : !llvm.ptr
        %287 = llvm.load %286 : !llvm.ptr -> i64
        %288 = arith.cmpi slt, %285, %287 : i64
        cf.cond_br %288, ^bb61, ^bb62
        ^bb61:
          %289 = arith.constant 0 : i32
          %290 = llvm.load %284 : !llvm.ptr -> i64
          %291 = arith.trunci %289 : i32 to i8
          %292 = llvm.getelementptr %222[%290] : (!llvm.ptr, i64) -> !llvm.ptr, i8
          llvm.store %291, %292 : i8, !llvm.ptr
          %293 = llvm.load %284 : !llvm.ptr -> i64
          %295 = arith.trunci %293 : i64 to i32
          %296 = arith.index_cast %274 : index to i32
          %294 = arith.addi %295, %296 : i32
          %297 = arith.extsi %294 : i32 to i64
          llvm.store %297, %284 : i64, !llvm.ptr
          cf.br ^bb60
        ^bb62:
        cf.br ^bb59
      ^bb58:
        cf.br ^bb59
      ^bb59:
      %298 = arith.addi %274, %266 : index
      cf.br ^bb54(%298 : index)
    ^bb56(%299: index):
    %300 = arith.constant 0 : i32
    %301 = arith.extsi %300 : i32 to i64
    %302 = llvm.mlir.constant(1 : i64) : i64
    %303 = llvm.alloca %302 x i64 : (i64) -> !llvm.ptr
    llvm.store %301, %303 : i64, !llvm.ptr
    %304 = arith.constant 0 : i32
    %305 = llvm.mlir.addressof @MAX_PRIME : !llvm.ptr
    %306 = llvm.load %305 : !llvm.ptr -> i64
    %307 = arith.index_cast %304 : i32 to index
    %308 = arith.index_cast %306 : i32 to index
    %310 = arith.constant 1 : index
    %311 = arith.constant -1 : index
    %312 = arith.cmpi sle, %307, %308 : index
    %309 = arith.select %312, %310, %311 : index
    cf.br ^bb63(%307 : index)
    ^bb63(%313: index):
    %314 = arith.cmpi slt, %313, %308 : index
    %315 = arith.cmpi sgt, %313, %308 : index
    %316 = arith.select %312, %314, %315 : i1
    cf.cond_br %316, ^bb64(%313 : index), ^bb65(%313 : index)
    ^bb64(%317: index):
      %319 = arith.index_cast %317 : index to i64
      %320 = llvm.getelementptr %222[%319] : (!llvm.ptr, i64) -> !llvm.ptr, i8
      %318 = llvm.load %320 : !llvm.ptr -> i8
      %321 = arith.constant 1 : i32
      %323 = arith.extsi %318 : i8 to i32
      %322 = arith.cmpi eq, %323, %321 : i32
      cf.cond_br %322, ^bb66, ^bb67
      ^bb66:
        %324 = llvm.load %303 : !llvm.ptr -> i64
        %325 = arith.constant 1 : i32
        %327 = arith.extsi %325 : i32 to i64
        %326 = arith.addi %324, %327 : i64
        llvm.store %326, %303 : i64, !llvm.ptr
        cf.br ^bb68
      ^bb67:
        cf.br ^bb68
      ^bb68:
      %328 = arith.addi %317, %309 : index
      cf.br ^bb63(%328 : index)
    ^bb65(%329: index):
    %331 = llvm.load %303 : !llvm.ptr -> i64
    %332 = arith.constant 8 : i32
    %333 = arith.extsi %332 : i32 to i64
    %330 = func.call @calloc(%331, %333) : (i64, i64) -> !llvm.ptr
    %334 = llvm.mlir.addressof @g_primes : !llvm.ptr
    llvm.store %330, %334 : !llvm.ptr, !llvm.ptr
    %335 = arith.constant 0 : i32
    %336 = arith.extsi %335 : i32 to i64
    %337 = llvm.mlir.constant(1 : i64) : i64
    %338 = llvm.alloca %337 x i64 : (i64) -> !llvm.ptr
    llvm.store %336, %338 : i64, !llvm.ptr
    %339 = arith.constant 0 : i32
    %340 = llvm.mlir.addressof @MAX_PRIME : !llvm.ptr
    %341 = llvm.load %340 : !llvm.ptr -> i64
    %342 = arith.index_cast %339 : i32 to index
    %343 = arith.index_cast %341 : i32 to index
    %345 = arith.constant 1 : index
    %346 = arith.constant -1 : index
    %347 = arith.cmpi sle, %342, %343 : index
    %344 = arith.select %347, %345, %346 : index
    cf.br ^bb69(%342 : index)
    ^bb69(%348: index):
    %349 = arith.cmpi slt, %348, %343 : index
    %350 = arith.cmpi sgt, %348, %343 : index
    %351 = arith.select %347, %349, %350 : i1
    cf.cond_br %351, ^bb70(%348 : index), ^bb71(%348 : index)
    ^bb70(%352: index):
      %354 = arith.index_cast %352 : index to i64
      %355 = llvm.getelementptr %222[%354] : (!llvm.ptr, i64) -> !llvm.ptr, i8
      %353 = llvm.load %355 : !llvm.ptr -> i8
      %356 = arith.constant 1 : i32
      %358 = arith.extsi %353 : i8 to i32
      %357 = arith.cmpi eq, %358, %356 : i32
      cf.cond_br %357, ^bb72, ^bb73
      ^bb72:
        %359 = llvm.mlir.addressof @g_primes : !llvm.ptr
        %360 = llvm.load %359 : !llvm.ptr -> !llvm.ptr
        %361 = llvm.load %338 : !llvm.ptr -> i64
        %362 = arith.index_cast %352 : index to i64
        %363 = llvm.getelementptr %360[%361] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        llvm.store %362, %363 : i64, !llvm.ptr
        %364 = llvm.load %338 : !llvm.ptr -> i64
        %365 = arith.constant 1 : i32
        %367 = arith.extsi %365 : i32 to i64
        %366 = arith.addi %364, %367 : i64
        llvm.store %366, %338 : i64, !llvm.ptr
        cf.br ^bb74
      ^bb73:
        cf.br ^bb74
      ^bb74:
      %368 = arith.addi %352, %344 : index
      cf.br ^bb69(%368 : index)
    ^bb71(%369: index):
    %370 = llvm.load %303 : !llvm.ptr -> i64
    %371 = llvm.mlir.addressof @g_nprimes : !llvm.ptr
    llvm.store %370, %371 : i64, !llvm.ptr
    func.call @free(%222) : (!llvm.ptr) -> ()
    func.return
  }
  func.func @factorize(%arg0: i64, %arg1: !llvm.ptr, %arg2: !llvm.ptr) -> i64 {
    %373 = llvm.mlir.constant(1 : i64) : i64
    %374 = llvm.alloca %373 x i64 : (i64) -> !llvm.ptr
    llvm.store %arg0, %374 : i64, !llvm.ptr
    %375 = arith.constant 0 : i32
    %376 = arith.extsi %375 : i32 to i64
    %377 = llvm.mlir.constant(1 : i64) : i64
    %378 = llvm.alloca %377 x i64 : (i64) -> !llvm.ptr
    llvm.store %376, %378 : i64, !llvm.ptr
    %379 = arith.constant 0 : i32
    %380 = llvm.mlir.addressof @g_nprimes : !llvm.ptr
    %381 = llvm.load %380 : !llvm.ptr -> i64
    %382 = arith.index_cast %379 : i32 to index
    %383 = arith.index_cast %381 : i32 to index
    %385 = arith.constant 1 : index
    %386 = arith.constant -1 : index
    %387 = arith.cmpi sle, %382, %383 : index
    %384 = arith.select %387, %385, %386 : index
    cf.br ^bb75(%382 : index)
    ^bb75(%388: index):
    %389 = arith.cmpi slt, %388, %383 : index
    %390 = arith.cmpi sgt, %388, %383 : index
    %391 = arith.select %387, %389, %390 : i1
    cf.cond_br %391, ^bb76(%388 : index), ^bb77(%388 : index)
    ^bb76(%392: index):
      %394 = llvm.mlir.addressof @g_primes : !llvm.ptr
      %395 = llvm.load %394 : !llvm.ptr -> !llvm.ptr
      %396 = arith.index_cast %392 : index to i64
      %397 = llvm.getelementptr %395[%396] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %393 = llvm.load %397 : !llvm.ptr -> i64
      %398 = arith.muli %393, %393 : i64
      %399 = llvm.load %374 : !llvm.ptr -> i64
      %400 = arith.cmpi sgt, %398, %399 : i64
      cf.cond_br %400, ^bb78, ^bb79
      ^bb78:
        cf.br ^bb77(%392 : index)
      ^bb79:
        cf.br ^bb80
      ^bb80:
      %401 = llvm.load %374 : !llvm.ptr -> i64
      %402 = arith.remsi %401, %393 : i64
      %403 = arith.constant 0 : i32
      %405 = arith.extsi %403 : i32 to i64
      %404 = arith.cmpi eq, %402, %405 : i64
      cf.cond_br %404, ^bb81, ^bb82
      ^bb81:
        %406 = arith.constant 0 : i32
        %407 = arith.extsi %406 : i32 to i64
        %408 = llvm.mlir.constant(1 : i64) : i64
        %409 = llvm.alloca %408 x i64 : (i64) -> !llvm.ptr
        llvm.store %407, %409 : i64, !llvm.ptr
        cf.br ^bb84
        ^bb84:
        %410 = llvm.load %374 : !llvm.ptr -> i64
        %411 = arith.remsi %410, %393 : i64
        %412 = arith.constant 0 : i32
        %414 = arith.extsi %412 : i32 to i64
        %413 = arith.cmpi eq, %411, %414 : i64
        cf.cond_br %413, ^bb85, ^bb86
        ^bb85:
          %415 = llvm.load %374 : !llvm.ptr -> i64
          %416 = arith.divsi %415, %393 : i64
          llvm.store %416, %374 : i64, !llvm.ptr
          %417 = llvm.load %409 : !llvm.ptr -> i64
          %418 = arith.constant 1 : i32
          %420 = arith.extsi %418 : i32 to i64
          %419 = arith.addi %417, %420 : i64
          llvm.store %419, %409 : i64, !llvm.ptr
          cf.br ^bb84
        ^bb86:
        %421 = llvm.load %378 : !llvm.ptr -> i64
        %422 = llvm.getelementptr %arg1[%421] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        llvm.store %393, %422 : i64, !llvm.ptr
        %423 = llvm.load %409 : !llvm.ptr -> i64
        %424 = llvm.load %378 : !llvm.ptr -> i64
        %425 = llvm.getelementptr %arg2[%424] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        llvm.store %423, %425 : i64, !llvm.ptr
        %426 = llvm.load %378 : !llvm.ptr -> i64
        %427 = arith.constant 1 : i32
        %429 = arith.extsi %427 : i32 to i64
        %428 = arith.addi %426, %429 : i64
        llvm.store %428, %378 : i64, !llvm.ptr
        cf.br ^bb83
      ^bb82:
        cf.br ^bb83
      ^bb83:
      %430 = arith.addi %392, %384 : index
      cf.br ^bb75(%430 : index)
    ^bb77(%431: index):
    %432 = llvm.load %374 : !llvm.ptr -> i64
    %433 = arith.constant 1 : i32
    %435 = arith.extsi %433 : i32 to i64
    %434 = arith.cmpi sgt, %432, %435 : i64
    cf.cond_br %434, ^bb87, ^bb88
    ^bb87:
      %436 = llvm.load %374 : !llvm.ptr -> i64
      %437 = llvm.load %378 : !llvm.ptr -> i64
      %438 = llvm.getelementptr %arg1[%437] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %436, %438 : i64, !llvm.ptr
      %439 = arith.constant 1 : i32
      %440 = llvm.load %378 : !llvm.ptr -> i64
      %441 = arith.extsi %439 : i32 to i64
      %442 = llvm.getelementptr %arg2[%440] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %441, %442 : i64, !llvm.ptr
      %443 = llvm.load %378 : !llvm.ptr -> i64
      %444 = arith.constant 1 : i32
      %446 = arith.extsi %444 : i32 to i64
      %445 = arith.addi %443, %446 : i64
      llvm.store %445, %378 : i64, !llvm.ptr
      cf.br ^bb89
    ^bb88:
      cf.br ^bb89
    ^bb89:
    %447 = llvm.load %378 : !llvm.ptr -> i64
    func.return %447 : i64
  }
  func.func @divisors_phi(%arg0: i64, %arg1: !llvm.ptr, %arg2: !llvm.ptr, %arg3: !llvm.ptr, %arg4: !llvm.ptr) -> i64 {
    %448 = arith.constant 1 : i32
    %449 = arith.constant 0 : i32
    %450 = arith.extsi %448 : i32 to i64
    %451 = arith.extsi %449 : i32 to i64
    %452 = llvm.getelementptr %arg3[%451] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    llvm.store %450, %452 : i64, !llvm.ptr
    %453 = arith.constant 1 : i32
    %454 = arith.constant 0 : i32
    %455 = arith.extsi %453 : i32 to i64
    %456 = arith.extsi %454 : i32 to i64
    %457 = llvm.getelementptr %arg4[%456] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    llvm.store %455, %457 : i64, !llvm.ptr
    %458 = arith.constant 1 : i32
    %459 = arith.extsi %458 : i32 to i64
    %460 = llvm.mlir.constant(1 : i64) : i64
    %461 = llvm.alloca %460 x i64 : (i64) -> !llvm.ptr
    llvm.store %459, %461 : i64, !llvm.ptr
    %462 = arith.constant 0 : i32
    %463 = arith.index_cast %462 : i32 to index
    %464 = arith.index_cast %arg0 : i32 to index
    %466 = arith.constant 1 : index
    %467 = arith.constant -1 : index
    %468 = arith.cmpi sle, %463, %464 : index
    %465 = arith.select %468, %466, %467 : index
    cf.br ^bb90(%463 : index)
    ^bb90(%469: index):
    %470 = arith.cmpi slt, %469, %464 : index
    %471 = arith.cmpi sgt, %469, %464 : index
    %472 = arith.select %468, %470, %471 : i1
    cf.cond_br %472, ^bb91(%469 : index), ^bb92(%469 : index)
    ^bb91(%473: index):
      %475 = arith.index_cast %473 : index to i64
      %476 = llvm.getelementptr %arg1[%475] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %474 = llvm.load %476 : !llvm.ptr -> i64
      %478 = arith.index_cast %473 : index to i64
      %479 = llvm.getelementptr %arg2[%478] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %477 = llvm.load %479 : !llvm.ptr -> i64
      %480 = llvm.load %461 : !llvm.ptr -> i64
      %481 = arith.constant 1 : i32
      %482 = arith.extsi %481 : i32 to i64
      %483 = llvm.mlir.constant(1 : i64) : i64
      %484 = llvm.alloca %483 x i64 : (i64) -> !llvm.ptr
      llvm.store %482, %484 : i64, !llvm.ptr
      %485 = arith.constant 0 : i32
      %486 = arith.constant 1 : i32
      %488 = arith.extsi %486 : i32 to i64
      %487 = arith.addi %477, %488 : i64
      %489 = arith.index_cast %485 : i32 to index
      %490 = arith.index_cast %487 : i32 to index
      %492 = arith.constant 1 : index
      %493 = arith.constant -1 : index
      %494 = arith.cmpi sle, %489, %490 : index
      %491 = arith.select %494, %492, %493 : index
      cf.br ^bb93(%489 : index)
      ^bb93(%495: index):
      %496 = arith.cmpi slt, %495, %490 : index
      %497 = arith.cmpi sgt, %495, %490 : index
      %498 = arith.select %494, %496, %497 : i1
      cf.cond_br %498, ^bb94(%495 : index), ^bb95(%495 : index)
      ^bb94(%499: index):
        %500 = llvm.mlir.undef : i64
        %501 = arith.constant 0 : i32
        %503 = arith.index_cast %499 : index to i32
        %502 = arith.cmpi eq, %503, %501 : i32
        %504 = scf.if %502 -> (i64) {
          %505 = arith.constant 1 : i32
          %506 = arith.extsi %505 : i32 to i64
          scf.yield %506 : i64
        } else {
          %507 = llvm.load %484 : !llvm.ptr -> i64
          %508 = arith.divsi %507, %474 : i64
          %509 = arith.constant 1 : i32
          %511 = arith.extsi %509 : i32 to i64
          %510 = arith.subi %474, %511 : i64
          %512 = arith.muli %508, %510 : i64
          scf.yield %512 : i64
        }
        %513 = arith.constant 0 : i32
        %515 = arith.index_cast %499 : index to i32
        %514 = arith.cmpi sgt, %515, %513 : i32
        cf.cond_br %514, ^bb96, ^bb97
        ^bb96:
          %516 = arith.constant 0 : i32
          %517 = arith.index_cast %516 : i32 to index
          %518 = arith.index_cast %480 : i32 to index
          %520 = arith.constant 1 : index
          %521 = arith.constant -1 : index
          %522 = arith.cmpi sle, %517, %518 : index
          %519 = arith.select %522, %520, %521 : index
          cf.br ^bb99(%517 : index)
          ^bb99(%523: index):
          %524 = arith.cmpi slt, %523, %518 : index
          %525 = arith.cmpi sgt, %523, %518 : index
          %526 = arith.select %522, %524, %525 : i1
          cf.cond_br %526, ^bb100(%523 : index), ^bb101(%523 : index)
          ^bb100(%527: index):
            %529 = arith.index_cast %527 : index to i64
            %530 = llvm.getelementptr %arg3[%529] : (!llvm.ptr, i64) -> !llvm.ptr, i64
            %528 = llvm.load %530 : !llvm.ptr -> i64
            %531 = llvm.load %484 : !llvm.ptr -> i64
            %532 = arith.muli %528, %531 : i64
            %533 = llvm.load %461 : !llvm.ptr -> i64
            %534 = llvm.getelementptr %arg3[%533] : (!llvm.ptr, i64) -> !llvm.ptr, i64
            llvm.store %532, %534 : i64, !llvm.ptr
            %536 = arith.index_cast %527 : index to i64
            %537 = llvm.getelementptr %arg4[%536] : (!llvm.ptr, i64) -> !llvm.ptr, i64
            %535 = llvm.load %537 : !llvm.ptr -> i64
            %538 = arith.muli %535, %504 : i64
            %539 = llvm.load %461 : !llvm.ptr -> i64
            %540 = llvm.getelementptr %arg4[%539] : (!llvm.ptr, i64) -> !llvm.ptr, i64
            llvm.store %538, %540 : i64, !llvm.ptr
            %541 = llvm.load %461 : !llvm.ptr -> i64
            %542 = arith.constant 1 : i32
            %544 = arith.extsi %542 : i32 to i64
            %543 = arith.addi %541, %544 : i64
            llvm.store %543, %461 : i64, !llvm.ptr
            %545 = arith.addi %527, %519 : index
            cf.br ^bb99(%545 : index)
          ^bb101(%546: index):
          cf.br ^bb98
        ^bb97:
          cf.br ^bb98
        ^bb98:
        %547 = llvm.load %484 : !llvm.ptr -> i64
        %548 = arith.muli %547, %474 : i64
        llvm.store %548, %484 : i64, !llvm.ptr
        %549 = arith.addi %499, %491 : index
        cf.br ^bb93(%549 : index)
      ^bb95(%550: index):
      %551 = arith.addi %473, %465 : index
      cf.br ^bb90(%551 : index)
    ^bb92(%552: index):
    %553 = llvm.load %461 : !llvm.ptr -> i64
    func.return %553 : i64
  }
  // Constant: MAX_TYPES
  llvm.mlir.global internal constant @MAX_TYPES(10000 : i64) : i64
  // Constant: MAX_CYCLES_PER_TYPE
  llvm.mlir.global internal constant @MAX_CYCLES_PER_TYPE(3 : i64) : i64
  // Module static: g_type_ncyc
  llvm.mlir.global internal @g_type_ncyc() {addr_space = 0 : i32} : !llvm.ptr {
    %554 = llvm.mlir.zero : !llvm.ptr
    llvm.return %554 : !llvm.ptr
  }
  // Module static: g_type_mult
  llvm.mlir.global internal @g_type_mult() {addr_space = 0 : i32} : !llvm.ptr {
    %555 = llvm.mlir.zero : !llvm.ptr
    llvm.return %555 : !llvm.ptr
  }
  // Module static: g_type_clen
  llvm.mlir.global internal @g_type_clen() {addr_space = 0 : i32} : !llvm.ptr {
    %556 = llvm.mlir.zero : !llvm.ptr
    llvm.return %556 : !llvm.ptr
  }
  // Module static: g_type_ccnt
  llvm.mlir.global internal @g_type_ccnt() {addr_space = 0 : i32} : !llvm.ptr {
    %557 = llvm.mlir.zero : !llvm.ptr
    llvm.return %557 : !llvm.ptr
  }
  func.func @init_type_arrays() -> () {
    %559 = llvm.mlir.addressof @MAX_TYPES : !llvm.ptr
    %560 = llvm.load %559 : !llvm.ptr -> i64
    %561 = arith.constant 8 : i32
    %562 = arith.extsi %561 : i32 to i64
    %558 = func.call @calloc(%560, %562) : (i64, i64) -> !llvm.ptr
    %563 = llvm.mlir.addressof @g_type_ncyc : !llvm.ptr
    llvm.store %558, %563 : !llvm.ptr, !llvm.ptr
    %565 = llvm.mlir.addressof @MAX_TYPES : !llvm.ptr
    %566 = llvm.load %565 : !llvm.ptr -> i64
    %567 = arith.constant 8 : i32
    %568 = arith.extsi %567 : i32 to i64
    %564 = func.call @calloc(%566, %568) : (i64, i64) -> !llvm.ptr
    %569 = llvm.mlir.addressof @g_type_mult : !llvm.ptr
    llvm.store %564, %569 : !llvm.ptr, !llvm.ptr
    %571 = llvm.mlir.addressof @MAX_TYPES : !llvm.ptr
    %572 = llvm.load %571 : !llvm.ptr -> i64
    %573 = llvm.mlir.addressof @MAX_CYCLES_PER_TYPE : !llvm.ptr
    %574 = llvm.load %573 : !llvm.ptr -> i64
    %575 = arith.muli %572, %574 : i64
    %576 = arith.constant 8 : i32
    %577 = arith.extsi %576 : i32 to i64
    %570 = func.call @calloc(%575, %577) : (i64, i64) -> !llvm.ptr
    %578 = llvm.mlir.addressof @g_type_clen : !llvm.ptr
    llvm.store %570, %578 : !llvm.ptr, !llvm.ptr
    %580 = llvm.mlir.addressof @MAX_TYPES : !llvm.ptr
    %581 = llvm.load %580 : !llvm.ptr -> i64
    %582 = llvm.mlir.addressof @MAX_CYCLES_PER_TYPE : !llvm.ptr
    %583 = llvm.load %582 : !llvm.ptr -> i64
    %584 = arith.muli %581, %583 : i64
    %585 = arith.constant 8 : i32
    %586 = arith.extsi %585 : i32 to i64
    %579 = func.call @calloc(%584, %586) : (i64, i64) -> !llvm.ptr
    %587 = llvm.mlir.addressof @g_type_ccnt : !llvm.ptr
    llvm.store %579, %587 : !llvm.ptr, !llvm.ptr
    func.return
  }
  func.func @dihedral_types(%arg0: i64) -> i64 {
    %589 = arith.constant 20 : i32
    %590 = arith.constant 8 : i32
    %591 = arith.extsi %589 : i32 to i64
    %592 = arith.extsi %590 : i32 to i64
    %588 = func.call @calloc(%591, %592) : (i64, i64) -> !llvm.ptr
    %594 = arith.constant 20 : i32
    %595 = arith.constant 8 : i32
    %596 = arith.extsi %594 : i32 to i64
    %597 = arith.extsi %595 : i32 to i64
    %593 = func.call @calloc(%596, %597) : (i64, i64) -> !llvm.ptr
    %598 = func.call @factorize(%arg0, %588, %593) : (i64, !llvm.ptr, !llvm.ptr) -> i64
    %600 = arith.constant 10000 : i32
    %601 = arith.constant 8 : i32
    %602 = arith.extsi %600 : i32 to i64
    %603 = arith.extsi %601 : i32 to i64
    %599 = func.call @calloc(%602, %603) : (i64, i64) -> !llvm.ptr
    %605 = arith.constant 10000 : i32
    %606 = arith.constant 8 : i32
    %607 = arith.extsi %605 : i32 to i64
    %608 = arith.extsi %606 : i32 to i64
    %604 = func.call @calloc(%607, %608) : (i64, i64) -> !llvm.ptr
    %609 = func.call @divisors_phi(%598, %588, %593, %599, %604) : (i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr) -> i64
    %610 = arith.constant 0 : i32
    %611 = arith.extsi %610 : i32 to i64
    %612 = llvm.mlir.constant(1 : i64) : i64
    %613 = llvm.alloca %612 x i64 : (i64) -> !llvm.ptr
    llvm.store %611, %613 : i64, !llvm.ptr
    %614 = arith.constant 0 : i32
    %615 = arith.index_cast %614 : i32 to index
    %616 = arith.index_cast %609 : i32 to index
    %618 = arith.constant 1 : index
    %619 = arith.constant -1 : index
    %620 = arith.cmpi sle, %615, %616 : index
    %617 = arith.select %620, %618, %619 : index
    cf.br ^bb102(%615 : index)
    ^bb102(%621: index):
    %622 = arith.cmpi slt, %621, %616 : index
    %623 = arith.cmpi sgt, %621, %616 : index
    %624 = arith.select %620, %622, %623 : i1
    cf.cond_br %624, ^bb103(%621 : index), ^bb104(%621 : index)
    ^bb103(%625: index):
      %627 = arith.index_cast %625 : index to i64
      %628 = llvm.getelementptr %599[%627] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %626 = llvm.load %628 : !llvm.ptr -> i64
      %630 = arith.index_cast %625 : index to i64
      %631 = llvm.getelementptr %604[%630] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %629 = llvm.load %631 : !llvm.ptr -> i64
      %632 = arith.constant 1 : i32
      %633 = llvm.mlir.addressof @g_type_ncyc : !llvm.ptr
      %634 = llvm.load %633 : !llvm.ptr -> !llvm.ptr
      %635 = llvm.load %613 : !llvm.ptr -> i64
      %636 = arith.extsi %632 : i32 to i64
      %637 = llvm.getelementptr %634[%635] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %636, %637 : i64, !llvm.ptr
      %638 = llvm.mlir.addressof @g_type_mult : !llvm.ptr
      %639 = llvm.load %638 : !llvm.ptr -> !llvm.ptr
      %640 = llvm.load %613 : !llvm.ptr -> i64
      %641 = llvm.getelementptr %639[%640] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %629, %641 : i64, !llvm.ptr
      %642 = llvm.mlir.addressof @g_type_clen : !llvm.ptr
      %643 = llvm.load %642 : !llvm.ptr -> !llvm.ptr
      %644 = llvm.load %613 : !llvm.ptr -> i64
      %645 = llvm.mlir.addressof @MAX_CYCLES_PER_TYPE : !llvm.ptr
      %646 = llvm.load %645 : !llvm.ptr -> i64
      %647 = arith.muli %644, %646 : i64
      %648 = arith.constant 0 : i32
      %650 = arith.extsi %648 : i32 to i64
      %649 = arith.addi %647, %650 : i64
      %651 = llvm.getelementptr %643[%649] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %626, %651 : i64, !llvm.ptr
      %652 = arith.divsi %arg0, %626 : i64
      %653 = llvm.mlir.addressof @g_type_ccnt : !llvm.ptr
      %654 = llvm.load %653 : !llvm.ptr -> !llvm.ptr
      %655 = llvm.load %613 : !llvm.ptr -> i64
      %656 = llvm.mlir.addressof @MAX_CYCLES_PER_TYPE : !llvm.ptr
      %657 = llvm.load %656 : !llvm.ptr -> i64
      %658 = arith.muli %655, %657 : i64
      %659 = arith.constant 0 : i32
      %661 = arith.extsi %659 : i32 to i64
      %660 = arith.addi %658, %661 : i64
      %662 = llvm.getelementptr %654[%660] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %652, %662 : i64, !llvm.ptr
      %663 = llvm.load %613 : !llvm.ptr -> i64
      %664 = arith.constant 1 : i32
      %666 = arith.extsi %664 : i32 to i64
      %665 = arith.addi %663, %666 : i64
      llvm.store %665, %613 : i64, !llvm.ptr
      %667 = arith.addi %625, %617 : index
      cf.br ^bb102(%667 : index)
    ^bb104(%668: index):
    %669 = arith.constant 2 : i32
    %671 = arith.extsi %669 : i32 to i64
    %670 = arith.remsi %arg0, %671 : i64
    %672 = arith.constant 1 : i32
    %674 = arith.extsi %672 : i32 to i64
    %673 = arith.cmpi eq, %670, %674 : i64
    cf.cond_br %673, ^bb105, ^bb106
    ^bb105:
      %675 = arith.constant 2 : i32
      %676 = llvm.mlir.addressof @g_type_ncyc : !llvm.ptr
      %677 = llvm.load %676 : !llvm.ptr -> !llvm.ptr
      %678 = llvm.load %613 : !llvm.ptr -> i64
      %679 = arith.extsi %675 : i32 to i64
      %680 = llvm.getelementptr %677[%678] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %679, %680 : i64, !llvm.ptr
      %681 = llvm.mlir.addressof @g_type_mult : !llvm.ptr
      %682 = llvm.load %681 : !llvm.ptr -> !llvm.ptr
      %683 = llvm.load %613 : !llvm.ptr -> i64
      %684 = llvm.getelementptr %682[%683] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %arg0, %684 : i64, !llvm.ptr
      %685 = arith.constant 1 : i32
      %686 = llvm.mlir.addressof @g_type_clen : !llvm.ptr
      %687 = llvm.load %686 : !llvm.ptr -> !llvm.ptr
      %688 = llvm.load %613 : !llvm.ptr -> i64
      %689 = llvm.mlir.addressof @MAX_CYCLES_PER_TYPE : !llvm.ptr
      %690 = llvm.load %689 : !llvm.ptr -> i64
      %691 = arith.muli %688, %690 : i64
      %692 = arith.constant 0 : i32
      %694 = arith.extsi %692 : i32 to i64
      %693 = arith.addi %691, %694 : i64
      %695 = arith.extsi %685 : i32 to i64
      %696 = llvm.getelementptr %687[%693] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %695, %696 : i64, !llvm.ptr
      %697 = arith.constant 1 : i32
      %698 = llvm.mlir.addressof @g_type_ccnt : !llvm.ptr
      %699 = llvm.load %698 : !llvm.ptr -> !llvm.ptr
      %700 = llvm.load %613 : !llvm.ptr -> i64
      %701 = llvm.mlir.addressof @MAX_CYCLES_PER_TYPE : !llvm.ptr
      %702 = llvm.load %701 : !llvm.ptr -> i64
      %703 = arith.muli %700, %702 : i64
      %704 = arith.constant 0 : i32
      %706 = arith.extsi %704 : i32 to i64
      %705 = arith.addi %703, %706 : i64
      %707 = arith.extsi %697 : i32 to i64
      %708 = llvm.getelementptr %699[%705] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %707, %708 : i64, !llvm.ptr
      %709 = arith.constant 2 : i32
      %710 = llvm.mlir.addressof @g_type_clen : !llvm.ptr
      %711 = llvm.load %710 : !llvm.ptr -> !llvm.ptr
      %712 = llvm.load %613 : !llvm.ptr -> i64
      %713 = llvm.mlir.addressof @MAX_CYCLES_PER_TYPE : !llvm.ptr
      %714 = llvm.load %713 : !llvm.ptr -> i64
      %715 = arith.muli %712, %714 : i64
      %716 = arith.constant 1 : i32
      %718 = arith.extsi %716 : i32 to i64
      %717 = arith.addi %715, %718 : i64
      %719 = arith.extsi %709 : i32 to i64
      %720 = llvm.getelementptr %711[%717] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %719, %720 : i64, !llvm.ptr
      %721 = arith.constant 1 : i32
      %723 = arith.extsi %721 : i32 to i64
      %722 = arith.subi %arg0, %723 : i64
      %724 = arith.constant 2 : i32
      %726 = arith.extsi %724 : i32 to i64
      %725 = arith.divsi %722, %726 : i64
      %727 = llvm.mlir.addressof @g_type_ccnt : !llvm.ptr
      %728 = llvm.load %727 : !llvm.ptr -> !llvm.ptr
      %729 = llvm.load %613 : !llvm.ptr -> i64
      %730 = llvm.mlir.addressof @MAX_CYCLES_PER_TYPE : !llvm.ptr
      %731 = llvm.load %730 : !llvm.ptr -> i64
      %732 = arith.muli %729, %731 : i64
      %733 = arith.constant 1 : i32
      %735 = arith.extsi %733 : i32 to i64
      %734 = arith.addi %732, %735 : i64
      %736 = llvm.getelementptr %728[%734] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %725, %736 : i64, !llvm.ptr
      %737 = llvm.load %613 : !llvm.ptr -> i64
      %738 = arith.constant 1 : i32
      %740 = arith.extsi %738 : i32 to i64
      %739 = arith.addi %737, %740 : i64
      llvm.store %739, %613 : i64, !llvm.ptr
      cf.br ^bb107
    ^bb106:
      %741 = arith.constant 2 : i32
      %742 = llvm.mlir.addressof @g_type_ncyc : !llvm.ptr
      %743 = llvm.load %742 : !llvm.ptr -> !llvm.ptr
      %744 = llvm.load %613 : !llvm.ptr -> i64
      %745 = arith.extsi %741 : i32 to i64
      %746 = llvm.getelementptr %743[%744] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %745, %746 : i64, !llvm.ptr
      %747 = arith.constant 2 : i32
      %749 = arith.extsi %747 : i32 to i64
      %748 = arith.divsi %arg0, %749 : i64
      %750 = llvm.mlir.addressof @g_type_mult : !llvm.ptr
      %751 = llvm.load %750 : !llvm.ptr -> !llvm.ptr
      %752 = llvm.load %613 : !llvm.ptr -> i64
      %753 = llvm.getelementptr %751[%752] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %748, %753 : i64, !llvm.ptr
      %754 = arith.constant 1 : i32
      %755 = llvm.mlir.addressof @g_type_clen : !llvm.ptr
      %756 = llvm.load %755 : !llvm.ptr -> !llvm.ptr
      %757 = llvm.load %613 : !llvm.ptr -> i64
      %758 = llvm.mlir.addressof @MAX_CYCLES_PER_TYPE : !llvm.ptr
      %759 = llvm.load %758 : !llvm.ptr -> i64
      %760 = arith.muli %757, %759 : i64
      %761 = arith.constant 0 : i32
      %763 = arith.extsi %761 : i32 to i64
      %762 = arith.addi %760, %763 : i64
      %764 = arith.extsi %754 : i32 to i64
      %765 = llvm.getelementptr %756[%762] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %764, %765 : i64, !llvm.ptr
      %766 = arith.constant 2 : i32
      %767 = llvm.mlir.addressof @g_type_ccnt : !llvm.ptr
      %768 = llvm.load %767 : !llvm.ptr -> !llvm.ptr
      %769 = llvm.load %613 : !llvm.ptr -> i64
      %770 = llvm.mlir.addressof @MAX_CYCLES_PER_TYPE : !llvm.ptr
      %771 = llvm.load %770 : !llvm.ptr -> i64
      %772 = arith.muli %769, %771 : i64
      %773 = arith.constant 0 : i32
      %775 = arith.extsi %773 : i32 to i64
      %774 = arith.addi %772, %775 : i64
      %776 = arith.extsi %766 : i32 to i64
      %777 = llvm.getelementptr %768[%774] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %776, %777 : i64, !llvm.ptr
      %778 = arith.constant 2 : i32
      %779 = llvm.mlir.addressof @g_type_clen : !llvm.ptr
      %780 = llvm.load %779 : !llvm.ptr -> !llvm.ptr
      %781 = llvm.load %613 : !llvm.ptr -> i64
      %782 = llvm.mlir.addressof @MAX_CYCLES_PER_TYPE : !llvm.ptr
      %783 = llvm.load %782 : !llvm.ptr -> i64
      %784 = arith.muli %781, %783 : i64
      %785 = arith.constant 1 : i32
      %787 = arith.extsi %785 : i32 to i64
      %786 = arith.addi %784, %787 : i64
      %788 = arith.extsi %778 : i32 to i64
      %789 = llvm.getelementptr %780[%786] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %788, %789 : i64, !llvm.ptr
      %790 = arith.constant 2 : i32
      %792 = arith.extsi %790 : i32 to i64
      %791 = arith.subi %arg0, %792 : i64
      %793 = arith.constant 2 : i32
      %795 = arith.extsi %793 : i32 to i64
      %794 = arith.divsi %791, %795 : i64
      %796 = llvm.mlir.addressof @g_type_ccnt : !llvm.ptr
      %797 = llvm.load %796 : !llvm.ptr -> !llvm.ptr
      %798 = llvm.load %613 : !llvm.ptr -> i64
      %799 = llvm.mlir.addressof @MAX_CYCLES_PER_TYPE : !llvm.ptr
      %800 = llvm.load %799 : !llvm.ptr -> i64
      %801 = arith.muli %798, %800 : i64
      %802 = arith.constant 1 : i32
      %804 = arith.extsi %802 : i32 to i64
      %803 = arith.addi %801, %804 : i64
      %805 = llvm.getelementptr %797[%803] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %794, %805 : i64, !llvm.ptr
      %806 = llvm.load %613 : !llvm.ptr -> i64
      %807 = arith.constant 1 : i32
      %809 = arith.extsi %807 : i32 to i64
      %808 = arith.addi %806, %809 : i64
      llvm.store %808, %613 : i64, !llvm.ptr
      %810 = arith.constant 1 : i32
      %811 = llvm.mlir.addressof @g_type_ncyc : !llvm.ptr
      %812 = llvm.load %811 : !llvm.ptr -> !llvm.ptr
      %813 = llvm.load %613 : !llvm.ptr -> i64
      %814 = arith.extsi %810 : i32 to i64
      %815 = llvm.getelementptr %812[%813] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %814, %815 : i64, !llvm.ptr
      %816 = arith.constant 2 : i32
      %818 = arith.extsi %816 : i32 to i64
      %817 = arith.divsi %arg0, %818 : i64
      %819 = llvm.mlir.addressof @g_type_mult : !llvm.ptr
      %820 = llvm.load %819 : !llvm.ptr -> !llvm.ptr
      %821 = llvm.load %613 : !llvm.ptr -> i64
      %822 = llvm.getelementptr %820[%821] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %817, %822 : i64, !llvm.ptr
      %823 = arith.constant 2 : i32
      %824 = llvm.mlir.addressof @g_type_clen : !llvm.ptr
      %825 = llvm.load %824 : !llvm.ptr -> !llvm.ptr
      %826 = llvm.load %613 : !llvm.ptr -> i64
      %827 = llvm.mlir.addressof @MAX_CYCLES_PER_TYPE : !llvm.ptr
      %828 = llvm.load %827 : !llvm.ptr -> i64
      %829 = arith.muli %826, %828 : i64
      %830 = arith.constant 0 : i32
      %832 = arith.extsi %830 : i32 to i64
      %831 = arith.addi %829, %832 : i64
      %833 = arith.extsi %823 : i32 to i64
      %834 = llvm.getelementptr %825[%831] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %833, %834 : i64, !llvm.ptr
      %835 = arith.constant 2 : i32
      %837 = arith.extsi %835 : i32 to i64
      %836 = arith.divsi %arg0, %837 : i64
      %838 = llvm.mlir.addressof @g_type_ccnt : !llvm.ptr
      %839 = llvm.load %838 : !llvm.ptr -> !llvm.ptr
      %840 = llvm.load %613 : !llvm.ptr -> i64
      %841 = llvm.mlir.addressof @MAX_CYCLES_PER_TYPE : !llvm.ptr
      %842 = llvm.load %841 : !llvm.ptr -> i64
      %843 = arith.muli %840, %842 : i64
      %844 = arith.constant 0 : i32
      %846 = arith.extsi %844 : i32 to i64
      %845 = arith.addi %843, %846 : i64
      %847 = llvm.getelementptr %839[%845] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %836, %847 : i64, !llvm.ptr
      %848 = llvm.load %613 : !llvm.ptr -> i64
      %849 = arith.constant 1 : i32
      %851 = arith.extsi %849 : i32 to i64
      %850 = arith.addi %848, %851 : i64
      llvm.store %850, %613 : i64, !llvm.ptr
      cf.br ^bb107
    ^bb107:
    func.call @free(%604) : (!llvm.ptr) -> ()
    func.call @free(%599) : (!llvm.ptr) -> ()
    func.call @free(%593) : (!llvm.ptr) -> ()
    func.call @free(%588) : (!llvm.ptr) -> ()
    %856 = llvm.load %613 : !llvm.ptr -> i64
    func.return %856 : i64
  }
  func.func @cycles_on_grid(%arg0: i64, %arg1: i64) -> i64 {
    %858 = llvm.mlir.addressof @g_type_ncyc : !llvm.ptr
    %859 = llvm.load %858 : !llvm.ptr -> !llvm.ptr
    %860 = llvm.getelementptr %859[%arg0] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    %857 = llvm.load %860 : !llvm.ptr -> i64
    %862 = llvm.mlir.addressof @g_type_ncyc : !llvm.ptr
    %863 = llvm.load %862 : !llvm.ptr -> !llvm.ptr
    %864 = llvm.getelementptr %863[%arg1] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    %861 = llvm.load %864 : !llvm.ptr -> i64
    %865 = arith.constant 0 : i32
    %866 = arith.extsi %865 : i32 to i64
    %867 = llvm.mlir.constant(1 : i64) : i64
    %868 = llvm.alloca %867 x i64 : (i64) -> !llvm.ptr
    llvm.store %866, %868 : i64, !llvm.ptr
    %869 = arith.constant 0 : i32
    %870 = arith.index_cast %869 : i32 to index
    %871 = arith.index_cast %857 : i32 to index
    %873 = arith.constant 1 : index
    %874 = arith.constant -1 : index
    %875 = arith.cmpi sle, %870, %871 : index
    %872 = arith.select %875, %873, %874 : index
    cf.br ^bb108(%870 : index)
    ^bb108(%876: index):
    %877 = arith.cmpi slt, %876, %871 : index
    %878 = arith.cmpi sgt, %876, %871 : index
    %879 = arith.select %875, %877, %878 : i1
    cf.cond_br %879, ^bb109(%876 : index), ^bb110(%876 : index)
    ^bb109(%880: index):
      %882 = llvm.mlir.addressof @g_type_clen : !llvm.ptr
      %883 = llvm.load %882 : !llvm.ptr -> !llvm.ptr
      %884 = llvm.mlir.addressof @MAX_CYCLES_PER_TYPE : !llvm.ptr
      %885 = llvm.load %884 : !llvm.ptr -> i64
      %886 = arith.muli %arg0, %885 : i64
      %888 = arith.trunci %886 : i64 to i32
      %889 = arith.index_cast %880 : index to i32
      %887 = arith.addi %888, %889 : i32
      %890 = arith.extsi %887 : i32 to i64
      %891 = llvm.getelementptr %883[%890] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %881 = llvm.load %891 : !llvm.ptr -> i64
      %893 = llvm.mlir.addressof @g_type_ccnt : !llvm.ptr
      %894 = llvm.load %893 : !llvm.ptr -> !llvm.ptr
      %895 = llvm.mlir.addressof @MAX_CYCLES_PER_TYPE : !llvm.ptr
      %896 = llvm.load %895 : !llvm.ptr -> i64
      %897 = arith.muli %arg0, %896 : i64
      %899 = arith.trunci %897 : i64 to i32
      %900 = arith.index_cast %880 : index to i32
      %898 = arith.addi %899, %900 : i32
      %901 = arith.extsi %898 : i32 to i64
      %902 = llvm.getelementptr %894[%901] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %892 = llvm.load %902 : !llvm.ptr -> i64
      %903 = arith.constant 0 : i32
      %904 = arith.index_cast %903 : i32 to index
      %905 = arith.index_cast %861 : i32 to index
      %907 = arith.constant 1 : index
      %908 = arith.constant -1 : index
      %909 = arith.cmpi sle, %904, %905 : index
      %906 = arith.select %909, %907, %908 : index
      cf.br ^bb111(%904 : index)
      ^bb111(%910: index):
      %911 = arith.cmpi slt, %910, %905 : index
      %912 = arith.cmpi sgt, %910, %905 : index
      %913 = arith.select %909, %911, %912 : i1
      cf.cond_br %913, ^bb112(%910 : index), ^bb113(%910 : index)
      ^bb112(%914: index):
        %916 = llvm.mlir.addressof @g_type_clen : !llvm.ptr
        %917 = llvm.load %916 : !llvm.ptr -> !llvm.ptr
        %918 = llvm.mlir.addressof @MAX_CYCLES_PER_TYPE : !llvm.ptr
        %919 = llvm.load %918 : !llvm.ptr -> i64
        %920 = arith.muli %arg1, %919 : i64
        %922 = arith.trunci %920 : i64 to i32
        %923 = arith.index_cast %914 : index to i32
        %921 = arith.addi %922, %923 : i32
        %924 = arith.extsi %921 : i32 to i64
        %925 = llvm.getelementptr %917[%924] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %915 = llvm.load %925 : !llvm.ptr -> i64
        %927 = llvm.mlir.addressof @g_type_ccnt : !llvm.ptr
        %928 = llvm.load %927 : !llvm.ptr -> !llvm.ptr
        %929 = llvm.mlir.addressof @MAX_CYCLES_PER_TYPE : !llvm.ptr
        %930 = llvm.load %929 : !llvm.ptr -> i64
        %931 = arith.muli %arg1, %930 : i64
        %933 = arith.trunci %931 : i64 to i32
        %934 = arith.index_cast %914 : index to i32
        %932 = arith.addi %933, %934 : i32
        %935 = arith.extsi %932 : i32 to i64
        %936 = llvm.getelementptr %928[%935] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %926 = llvm.load %936 : !llvm.ptr -> i64
        %937 = llvm.load %868 : !llvm.ptr -> i64
        %938 = arith.muli %892, %926 : i64
        %939 = func.call @mygcd(%881, %915) : (i64, i64) -> i64
        %940 = arith.muli %938, %939 : i64
        %941 = arith.addi %937, %940 : i64
        llvm.store %941, %868 : i64, !llvm.ptr
        %942 = arith.addi %914, %906 : index
        cf.br ^bb111(%942 : index)
      ^bb113(%943: index):
      %944 = arith.addi %880, %872 : index
      cf.br ^bb108(%944 : index)
    ^bb110(%945: index):
    %946 = llvm.load %868 : !llvm.ptr -> i64
    func.return %946 : i64
  }
  func.func @surjections_count(%arg0: i64, %arg1: i64, %arg2: !llvm.ptr) -> i64 {
    %947 = arith.constant 0 : i32
    %948 = arith.extsi %947 : i32 to i64
    %949 = llvm.mlir.constant(1 : i64) : i64
    %950 = llvm.alloca %949 x i64 : (i64) -> !llvm.ptr
    llvm.store %948, %950 : i64, !llvm.ptr
    %951 = arith.constant 0 : i32
    %952 = arith.constant 1 : i32
    %954 = arith.extsi %952 : i32 to i64
    %953 = arith.addi %arg1, %954 : i64
    %955 = arith.index_cast %951 : i32 to index
    %956 = arith.index_cast %953 : i32 to index
    %958 = arith.constant 1 : index
    %959 = arith.constant -1 : index
    %960 = arith.cmpi sle, %955, %956 : index
    %957 = arith.select %960, %958, %959 : index
    cf.br ^bb114(%955 : index)
    ^bb114(%961: index):
    %962 = arith.cmpi slt, %961, %956 : index
    %963 = arith.cmpi sgt, %961, %956 : index
    %964 = arith.select %960, %962, %963 : i1
    cf.cond_br %964, ^bb115(%961 : index), ^bb116(%961 : index)
    ^bb115(%965: index):
      %967 = arith.trunci %arg1 : i64 to i32
      %968 = arith.index_cast %965 : index to i32
      %966 = arith.subi %967, %968 : i32
      %969 = arith.extsi %966 : i32 to i64
      %971 = arith.index_cast %965 : index to i64
      %972 = llvm.getelementptr %arg2[%971] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %970 = llvm.load %972 : !llvm.ptr -> i64
      %974 = llvm.mlir.addressof @MOD : !llvm.ptr
      %975 = llvm.load %974 : !llvm.ptr -> i64
      %973 = func.call @pow_mod(%969, %arg0, %975) : (i64, i64, i64) -> i64
      %976 = arith.muli %970, %973 : i64
      %977 = llvm.mlir.addressof @MOD : !llvm.ptr
      %978 = llvm.load %977 : !llvm.ptr -> i64
      %979 = arith.remsi %976, %978 : i64
      %980 = arith.constant 1 : i32
      %982 = arith.index_cast %965 : index to i32
      %981 = arith.andi %982, %980 : i32
      %983 = arith.constant 1 : i32
      %984 = arith.cmpi eq, %981, %983 : i32
      cf.cond_br %984, ^bb117, ^bb118
      ^bb117:
        %985 = llvm.load %950 : !llvm.ptr -> i64
        %986 = arith.subi %985, %979 : i64
        llvm.store %986, %950 : i64, !llvm.ptr
        cf.br ^bb119
      ^bb118:
        %987 = llvm.load %950 : !llvm.ptr -> i64
        %988 = arith.addi %987, %979 : i64
        llvm.store %988, %950 : i64, !llvm.ptr
        cf.br ^bb119
      ^bb119:
      %989 = arith.addi %965, %957 : index
      cf.br ^bb114(%989 : index)
    ^bb116(%990: index):
    %991 = llvm.load %950 : !llvm.ptr -> i64
    %992 = llvm.mlir.addressof @MOD : !llvm.ptr
    %993 = llvm.load %992 : !llvm.ptr -> i64
    %994 = arith.remsi %991, %993 : i64
    llvm.store %994, %950 : i64, !llvm.ptr
    %995 = llvm.load %950 : !llvm.ptr -> i64
    %996 = arith.constant 0 : i32
    %998 = arith.extsi %996 : i32 to i64
    %997 = arith.cmpi slt, %995, %998 : i64
    cf.cond_br %997, ^bb120, ^bb121
    ^bb120:
      %999 = llvm.load %950 : !llvm.ptr -> i64
      %1000 = llvm.mlir.addressof @MOD : !llvm.ptr
      %1001 = llvm.load %1000 : !llvm.ptr -> i64
      %1002 = arith.addi %999, %1001 : i64
      llvm.store %1002, %950 : i64, !llvm.ptr
      cf.br ^bb122
    ^bb121:
      cf.br ^bb122
    ^bb122:
    %1003 = llvm.load %950 : !llvm.ptr -> i64
    func.return %1003 : i64
  }
  func.func @compute_comb(%arg0: i64, %arg1: !llvm.ptr) -> () {
    %1004 = arith.constant 1 : i32
    %1005 = arith.constant 0 : i32
    %1006 = arith.extsi %1004 : i32 to i64
    %1007 = arith.extsi %1005 : i32 to i64
    %1008 = llvm.getelementptr %arg1[%1007] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    llvm.store %1006, %1008 : i64, !llvm.ptr
    %1009 = arith.constant 1 : i32
    %1010 = arith.constant 1 : i32
    %1012 = arith.extsi %1010 : i32 to i64
    %1011 = arith.addi %arg0, %1012 : i64
    %1013 = arith.index_cast %1009 : i32 to index
    %1014 = arith.index_cast %1011 : i32 to index
    %1016 = arith.constant 1 : index
    %1017 = arith.constant -1 : index
    %1018 = arith.cmpi sle, %1013, %1014 : index
    %1015 = arith.select %1018, %1016, %1017 : index
    cf.br ^bb123(%1013 : index)
    ^bb123(%1019: index):
    %1020 = arith.cmpi slt, %1019, %1014 : index
    %1021 = arith.cmpi sgt, %1019, %1014 : index
    %1022 = arith.select %1018, %1020, %1021 : i1
    cf.cond_br %1022, ^bb124(%1019 : index), ^bb125(%1019 : index)
    ^bb124(%1023: index):
      %1025 = arith.constant 1 : i32
      %1027 = arith.index_cast %1023 : index to i32
      %1026 = arith.subi %1027, %1025 : i32
      %1028 = arith.extsi %1026 : i32 to i64
      %1029 = llvm.getelementptr %arg1[%1028] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %1024 = llvm.load %1029 : !llvm.ptr -> i64
      %1031 = arith.trunci %arg0 : i64 to i32
      %1032 = arith.index_cast %1023 : index to i32
      %1030 = arith.subi %1031, %1032 : i32
      %1033 = arith.constant 1 : i32
      %1034 = arith.addi %1030, %1033 : i32
      %1036 = arith.extsi %1034 : i32 to i64
      %1035 = arith.muli %1024, %1036 : i64
      %1038 = arith.trunci %1035 : i64 to i32
      %1039 = arith.index_cast %1023 : index to i32
      %1037 = arith.divsi %1038, %1039 : i32
      %1040 = arith.extsi %1037 : i32 to i64
      %1041 = arith.index_cast %1023 : index to i64
      %1042 = llvm.getelementptr %arg1[%1041] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %1040, %1042 : i64, !llvm.ptr
      %1043 = arith.addi %1023, %1015 : index
      cf.br ^bb123(%1043 : index)
    ^bb125(%1044: index):
    %1045 = arith.constant 0 : i32
    %1046 = arith.constant 1 : i32
    %1048 = arith.extsi %1046 : i32 to i64
    %1047 = arith.addi %arg0, %1048 : i64
    %1049 = arith.index_cast %1045 : i32 to index
    %1050 = arith.index_cast %1047 : i32 to index
    %1052 = arith.constant 1 : index
    %1053 = arith.constant -1 : index
    %1054 = arith.cmpi sle, %1049, %1050 : index
    %1051 = arith.select %1054, %1052, %1053 : index
    cf.br ^bb126(%1049 : index)
    ^bb126(%1055: index):
    %1056 = arith.cmpi slt, %1055, %1050 : index
    %1057 = arith.cmpi sgt, %1055, %1050 : index
    %1058 = arith.select %1054, %1056, %1057 : i1
    cf.cond_br %1058, ^bb127(%1055 : index), ^bb128(%1055 : index)
    ^bb127(%1059: index):
      %1061 = arith.index_cast %1059 : index to i64
      %1062 = llvm.getelementptr %arg1[%1061] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %1060 = llvm.load %1062 : !llvm.ptr -> i64
      %1063 = llvm.mlir.addressof @MOD : !llvm.ptr
      %1064 = llvm.load %1063 : !llvm.ptr -> i64
      %1065 = arith.remsi %1060, %1064 : i64
      %1066 = arith.index_cast %1059 : index to i64
      %1067 = llvm.getelementptr %arg1[%1066] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %1065, %1067 : i64, !llvm.ptr
      %1068 = arith.addi %1059, %1051 : index
      cf.br ^bb126(%1068 : index)
    ^bb128(%1069: index):
    func.return
  }
  func.func @f(%arg0: i64, %arg1: i64, %arg2: i64) -> i64 {
    %1070 = func.call @dihedral_types(%arg1) : (i64) -> i64
    %1072 = llvm.mlir.addressof @MAX_TYPES : !llvm.ptr
    %1073 = llvm.load %1072 : !llvm.ptr -> i64
    %1074 = arith.constant 8 : i32
    %1075 = arith.extsi %1074 : i32 to i64
    %1071 = func.call @calloc(%1073, %1075) : (i64, i64) -> !llvm.ptr
    %1077 = llvm.mlir.addressof @MAX_TYPES : !llvm.ptr
    %1078 = llvm.load %1077 : !llvm.ptr -> i64
    %1079 = arith.constant 8 : i32
    %1080 = arith.extsi %1079 : i32 to i64
    %1076 = func.call @calloc(%1078, %1080) : (i64, i64) -> !llvm.ptr
    %1082 = llvm.mlir.addressof @MAX_TYPES : !llvm.ptr
    %1083 = llvm.load %1082 : !llvm.ptr -> i64
    %1084 = llvm.mlir.addressof @MAX_CYCLES_PER_TYPE : !llvm.ptr
    %1085 = llvm.load %1084 : !llvm.ptr -> i64
    %1086 = arith.muli %1083, %1085 : i64
    %1087 = arith.constant 8 : i32
    %1088 = arith.extsi %1087 : i32 to i64
    %1081 = func.call @calloc(%1086, %1088) : (i64, i64) -> !llvm.ptr
    %1090 = llvm.mlir.addressof @MAX_TYPES : !llvm.ptr
    %1091 = llvm.load %1090 : !llvm.ptr -> i64
    %1092 = llvm.mlir.addressof @MAX_CYCLES_PER_TYPE : !llvm.ptr
    %1093 = llvm.load %1092 : !llvm.ptr -> i64
    %1094 = arith.muli %1091, %1093 : i64
    %1095 = arith.constant 8 : i32
    %1096 = arith.extsi %1095 : i32 to i64
    %1089 = func.call @calloc(%1094, %1096) : (i64, i64) -> !llvm.ptr
    %1097 = arith.constant 0 : i32
    %1098 = arith.index_cast %1097 : i32 to index
    %1099 = arith.index_cast %1070 : i32 to index
    %1101 = arith.constant 1 : index
    %1102 = arith.constant -1 : index
    %1103 = arith.cmpi sle, %1098, %1099 : index
    %1100 = arith.select %1103, %1101, %1102 : index
    cf.br ^bb129(%1098 : index)
    ^bb129(%1104: index):
    %1105 = arith.cmpi slt, %1104, %1099 : index
    %1106 = arith.cmpi sgt, %1104, %1099 : index
    %1107 = arith.select %1103, %1105, %1106 : i1
    cf.cond_br %1107, ^bb130(%1104 : index), ^bb131(%1104 : index)
    ^bb130(%1108: index):
      %1110 = llvm.mlir.addressof @g_type_ncyc : !llvm.ptr
      %1111 = llvm.load %1110 : !llvm.ptr -> !llvm.ptr
      %1112 = arith.index_cast %1108 : index to i64
      %1113 = llvm.getelementptr %1111[%1112] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %1109 = llvm.load %1113 : !llvm.ptr -> i64
      %1114 = arith.index_cast %1108 : index to i64
      %1115 = llvm.getelementptr %1071[%1114] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %1109, %1115 : i64, !llvm.ptr
      %1117 = llvm.mlir.addressof @g_type_mult : !llvm.ptr
      %1118 = llvm.load %1117 : !llvm.ptr -> !llvm.ptr
      %1119 = arith.index_cast %1108 : index to i64
      %1120 = llvm.getelementptr %1118[%1119] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %1116 = llvm.load %1120 : !llvm.ptr -> i64
      %1121 = arith.index_cast %1108 : index to i64
      %1122 = llvm.getelementptr %1076[%1121] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %1116, %1122 : i64, !llvm.ptr
      %1123 = arith.constant 0 : i32
      %1124 = llvm.mlir.addressof @MAX_CYCLES_PER_TYPE : !llvm.ptr
      %1125 = llvm.load %1124 : !llvm.ptr -> i64
      %1126 = arith.index_cast %1123 : i32 to index
      %1127 = arith.index_cast %1125 : i32 to index
      %1129 = arith.constant 1 : index
      %1130 = arith.constant -1 : index
      %1131 = arith.cmpi sle, %1126, %1127 : index
      %1128 = arith.select %1131, %1129, %1130 : index
      cf.br ^bb132(%1126 : index)
      ^bb132(%1132: index):
      %1133 = arith.cmpi slt, %1132, %1127 : index
      %1134 = arith.cmpi sgt, %1132, %1127 : index
      %1135 = arith.select %1131, %1133, %1134 : i1
      cf.cond_br %1135, ^bb133(%1132 : index), ^bb134(%1132 : index)
      ^bb133(%1136: index):
        %1138 = llvm.mlir.addressof @g_type_clen : !llvm.ptr
        %1139 = llvm.load %1138 : !llvm.ptr -> !llvm.ptr
        %1140 = llvm.mlir.addressof @MAX_CYCLES_PER_TYPE : !llvm.ptr
        %1141 = llvm.load %1140 : !llvm.ptr -> i64
        %1143 = arith.index_cast %1108 : index to i32
        %1144 = arith.trunci %1141 : i64 to i32
        %1142 = arith.muli %1143, %1144 : i32
        %1146 = arith.index_cast %1136 : index to i32
        %1145 = arith.addi %1142, %1146 : i32
        %1147 = arith.extsi %1145 : i32 to i64
        %1148 = llvm.getelementptr %1139[%1147] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %1137 = llvm.load %1148 : !llvm.ptr -> i64
        %1149 = llvm.mlir.addressof @MAX_CYCLES_PER_TYPE : !llvm.ptr
        %1150 = llvm.load %1149 : !llvm.ptr -> i64
        %1152 = arith.index_cast %1108 : index to i32
        %1153 = arith.trunci %1150 : i64 to i32
        %1151 = arith.muli %1152, %1153 : i32
        %1155 = arith.index_cast %1136 : index to i32
        %1154 = arith.addi %1151, %1155 : i32
        %1156 = arith.extsi %1154 : i32 to i64
        %1157 = llvm.getelementptr %1081[%1156] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        llvm.store %1137, %1157 : i64, !llvm.ptr
        %1159 = llvm.mlir.addressof @g_type_ccnt : !llvm.ptr
        %1160 = llvm.load %1159 : !llvm.ptr -> !llvm.ptr
        %1161 = llvm.mlir.addressof @MAX_CYCLES_PER_TYPE : !llvm.ptr
        %1162 = llvm.load %1161 : !llvm.ptr -> i64
        %1164 = arith.index_cast %1108 : index to i32
        %1165 = arith.trunci %1162 : i64 to i32
        %1163 = arith.muli %1164, %1165 : i32
        %1167 = arith.index_cast %1136 : index to i32
        %1166 = arith.addi %1163, %1167 : i32
        %1168 = arith.extsi %1166 : i32 to i64
        %1169 = llvm.getelementptr %1160[%1168] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %1158 = llvm.load %1169 : !llvm.ptr -> i64
        %1170 = llvm.mlir.addressof @MAX_CYCLES_PER_TYPE : !llvm.ptr
        %1171 = llvm.load %1170 : !llvm.ptr -> i64
        %1173 = arith.index_cast %1108 : index to i32
        %1174 = arith.trunci %1171 : i64 to i32
        %1172 = arith.muli %1173, %1174 : i32
        %1176 = arith.index_cast %1136 : index to i32
        %1175 = arith.addi %1172, %1176 : i32
        %1177 = arith.extsi %1175 : i32 to i64
        %1178 = llvm.getelementptr %1089[%1177] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        llvm.store %1158, %1178 : i64, !llvm.ptr
        %1179 = arith.addi %1136, %1128 : index
        cf.br ^bb132(%1179 : index)
      ^bb134(%1180: index):
      %1181 = arith.addi %1108, %1100 : index
      cf.br ^bb129(%1181 : index)
    ^bb131(%1182: index):
    %1183 = func.call @dihedral_types(%arg2) : (i64) -> i64
    %1184 = arith.muli %1070, %1183 : i64
    %1185 = arith.constant 1 : i32
    %1187 = arith.extsi %1185 : i32 to i64
    %1186 = arith.addi %1184, %1187 : i64
    %1189 = arith.constant 8 : i32
    %1190 = arith.extsi %1189 : i32 to i64
    %1188 = func.call @calloc(%1186, %1190) : (i64, i64) -> !llvm.ptr
    %1192 = arith.constant 8 : i32
    %1193 = arith.extsi %1192 : i32 to i64
    %1191 = func.call @calloc(%1186, %1193) : (i64, i64) -> !llvm.ptr
    %1194 = arith.constant 0 : i32
    %1195 = arith.extsi %1194 : i32 to i64
    %1196 = llvm.mlir.constant(1 : i64) : i64
    %1197 = llvm.alloca %1196 x i64 : (i64) -> !llvm.ptr
    llvm.store %1195, %1197 : i64, !llvm.ptr
    %1198 = arith.constant 0 : i32
    %1199 = arith.index_cast %1198 : i32 to index
    %1200 = arith.index_cast %1070 : i32 to index
    %1202 = arith.constant 1 : index
    %1203 = arith.constant -1 : index
    %1204 = arith.cmpi sle, %1199, %1200 : index
    %1201 = arith.select %1204, %1202, %1203 : index
    cf.br ^bb135(%1199 : index)
    ^bb135(%1205: index):
    %1206 = arith.cmpi slt, %1205, %1200 : index
    %1207 = arith.cmpi sgt, %1205, %1200 : index
    %1208 = arith.select %1204, %1206, %1207 : i1
    cf.cond_br %1208, ^bb136(%1205 : index), ^bb137(%1205 : index)
    ^bb136(%1209: index):
      %1211 = arith.index_cast %1209 : index to i64
      %1212 = llvm.getelementptr %1076[%1211] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %1210 = llvm.load %1212 : !llvm.ptr -> i64
      %1213 = arith.constant 0 : i32
      %1214 = arith.index_cast %1213 : i32 to index
      %1215 = arith.index_cast %1183 : i32 to index
      %1217 = arith.constant 1 : index
      %1218 = arith.constant -1 : index
      %1219 = arith.cmpi sle, %1214, %1215 : index
      %1216 = arith.select %1219, %1217, %1218 : index
      cf.br ^bb138(%1214 : index)
      ^bb138(%1220: index):
      %1221 = arith.cmpi slt, %1220, %1215 : index
      %1222 = arith.cmpi sgt, %1220, %1215 : index
      %1223 = arith.select %1219, %1221, %1222 : i1
      cf.cond_br %1223, ^bb139(%1220 : index), ^bb140(%1220 : index)
      ^bb139(%1224: index):
        %1226 = llvm.mlir.addressof @g_type_mult : !llvm.ptr
        %1227 = llvm.load %1226 : !llvm.ptr -> !llvm.ptr
        %1228 = arith.index_cast %1224 : index to i64
        %1229 = llvm.getelementptr %1227[%1228] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %1225 = llvm.load %1229 : !llvm.ptr -> i64
        %1231 = arith.index_cast %1209 : index to i64
        %1232 = llvm.getelementptr %1071[%1231] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %1230 = llvm.load %1232 : !llvm.ptr -> i64
        %1234 = llvm.mlir.addressof @g_type_ncyc : !llvm.ptr
        %1235 = llvm.load %1234 : !llvm.ptr -> !llvm.ptr
        %1236 = arith.index_cast %1224 : index to i64
        %1237 = llvm.getelementptr %1235[%1236] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %1233 = llvm.load %1237 : !llvm.ptr -> i64
        %1238 = arith.constant 0 : i32
        %1239 = arith.extsi %1238 : i32 to i64
        %1240 = llvm.mlir.constant(1 : i64) : i64
        %1241 = llvm.alloca %1240 x i64 : (i64) -> !llvm.ptr
        llvm.store %1239, %1241 : i64, !llvm.ptr
        %1242 = arith.constant 0 : i32
        %1243 = arith.index_cast %1242 : i32 to index
        %1244 = arith.index_cast %1230 : i32 to index
        %1246 = arith.constant 1 : index
        %1247 = arith.constant -1 : index
        %1248 = arith.cmpi sle, %1243, %1244 : index
        %1245 = arith.select %1248, %1246, %1247 : index
        cf.br ^bb141(%1243 : index)
        ^bb141(%1249: index):
        %1250 = arith.cmpi slt, %1249, %1244 : index
        %1251 = arith.cmpi sgt, %1249, %1244 : index
        %1252 = arith.select %1248, %1250, %1251 : i1
        cf.cond_br %1252, ^bb142(%1249 : index), ^bb143(%1249 : index)
        ^bb142(%1253: index):
          %1255 = llvm.mlir.addressof @MAX_CYCLES_PER_TYPE : !llvm.ptr
          %1256 = llvm.load %1255 : !llvm.ptr -> i64
          %1258 = arith.index_cast %1209 : index to i32
          %1259 = arith.trunci %1256 : i64 to i32
          %1257 = arith.muli %1258, %1259 : i32
          %1261 = arith.index_cast %1253 : index to i32
          %1260 = arith.addi %1257, %1261 : i32
          %1262 = arith.extsi %1260 : i32 to i64
          %1263 = llvm.getelementptr %1081[%1262] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          %1254 = llvm.load %1263 : !llvm.ptr -> i64
          %1265 = llvm.mlir.addressof @MAX_CYCLES_PER_TYPE : !llvm.ptr
          %1266 = llvm.load %1265 : !llvm.ptr -> i64
          %1268 = arith.index_cast %1209 : index to i32
          %1269 = arith.trunci %1266 : i64 to i32
          %1267 = arith.muli %1268, %1269 : i32
          %1271 = arith.index_cast %1253 : index to i32
          %1270 = arith.addi %1267, %1271 : i32
          %1272 = arith.extsi %1270 : i32 to i64
          %1273 = llvm.getelementptr %1089[%1272] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          %1264 = llvm.load %1273 : !llvm.ptr -> i64
          %1274 = arith.constant 0 : i32
          %1275 = arith.index_cast %1274 : i32 to index
          %1276 = arith.index_cast %1233 : i32 to index
          %1278 = arith.constant 1 : index
          %1279 = arith.constant -1 : index
          %1280 = arith.cmpi sle, %1275, %1276 : index
          %1277 = arith.select %1280, %1278, %1279 : index
          cf.br ^bb144(%1275 : index)
          ^bb144(%1281: index):
          %1282 = arith.cmpi slt, %1281, %1276 : index
          %1283 = arith.cmpi sgt, %1281, %1276 : index
          %1284 = arith.select %1280, %1282, %1283 : i1
          cf.cond_br %1284, ^bb145(%1281 : index), ^bb146(%1281 : index)
          ^bb145(%1285: index):
            %1287 = llvm.mlir.addressof @g_type_clen : !llvm.ptr
            %1288 = llvm.load %1287 : !llvm.ptr -> !llvm.ptr
            %1289 = llvm.mlir.addressof @MAX_CYCLES_PER_TYPE : !llvm.ptr
            %1290 = llvm.load %1289 : !llvm.ptr -> i64
            %1292 = arith.index_cast %1224 : index to i32
            %1293 = arith.trunci %1290 : i64 to i32
            %1291 = arith.muli %1292, %1293 : i32
            %1295 = arith.index_cast %1285 : index to i32
            %1294 = arith.addi %1291, %1295 : i32
            %1296 = arith.extsi %1294 : i32 to i64
            %1297 = llvm.getelementptr %1288[%1296] : (!llvm.ptr, i64) -> !llvm.ptr, i64
            %1286 = llvm.load %1297 : !llvm.ptr -> i64
            %1299 = llvm.mlir.addressof @g_type_ccnt : !llvm.ptr
            %1300 = llvm.load %1299 : !llvm.ptr -> !llvm.ptr
            %1301 = llvm.mlir.addressof @MAX_CYCLES_PER_TYPE : !llvm.ptr
            %1302 = llvm.load %1301 : !llvm.ptr -> i64
            %1304 = arith.index_cast %1224 : index to i32
            %1305 = arith.trunci %1302 : i64 to i32
            %1303 = arith.muli %1304, %1305 : i32
            %1307 = arith.index_cast %1285 : index to i32
            %1306 = arith.addi %1303, %1307 : i32
            %1308 = arith.extsi %1306 : i32 to i64
            %1309 = llvm.getelementptr %1300[%1308] : (!llvm.ptr, i64) -> !llvm.ptr, i64
            %1298 = llvm.load %1309 : !llvm.ptr -> i64
            %1310 = llvm.load %1241 : !llvm.ptr -> i64
            %1311 = arith.muli %1264, %1298 : i64
            %1312 = func.call @mygcd(%1254, %1286) : (i64, i64) -> i64
            %1313 = arith.muli %1311, %1312 : i64
            %1314 = arith.addi %1310, %1313 : i64
            llvm.store %1314, %1241 : i64, !llvm.ptr
            %1315 = arith.addi %1285, %1277 : index
            cf.br ^bb144(%1315 : index)
          ^bb146(%1316: index):
          %1317 = arith.addi %1253, %1245 : index
          cf.br ^bb141(%1317 : index)
        ^bb143(%1318: index):
        %1319 = arith.muli %1210, %1225 : i64
        %1320 = llvm.mlir.addressof @MOD : !llvm.ptr
        %1321 = llvm.load %1320 : !llvm.ptr -> i64
        %1322 = arith.remsi %1319, %1321 : i64
        %1323 = arith.constant 1 : i32
        %1325 = arith.constant 0 : i32
        %1324 = arith.subi %1325, %1323 : i32
        %1326 = arith.extsi %1324 : i32 to i64
        %1327 = llvm.mlir.constant(1 : i64) : i64
        %1328 = llvm.alloca %1327 x i64 : (i64) -> !llvm.ptr
        llvm.store %1326, %1328 : i64, !llvm.ptr
        %1329 = arith.constant 0 : i32
        %1330 = llvm.load %1197 : !llvm.ptr -> i64
        %1331 = arith.index_cast %1329 : i32 to index
        %1332 = arith.index_cast %1330 : i32 to index
        %1334 = arith.constant 1 : index
        %1335 = arith.constant -1 : index
        %1336 = arith.cmpi sle, %1331, %1332 : index
        %1333 = arith.select %1336, %1334, %1335 : index
        cf.br ^bb147(%1331 : index)
        ^bb147(%1337: index):
        %1338 = arith.cmpi slt, %1337, %1332 : index
        %1339 = arith.cmpi sgt, %1337, %1332 : index
        %1340 = arith.select %1336, %1338, %1339 : i1
        cf.cond_br %1340, ^bb148(%1337 : index), ^bb149(%1337 : index)
        ^bb148(%1341: index):
          %1343 = arith.index_cast %1341 : index to i64
          %1344 = llvm.getelementptr %1188[%1343] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          %1342 = llvm.load %1344 : !llvm.ptr -> i64
          %1345 = llvm.load %1241 : !llvm.ptr -> i64
          %1346 = arith.cmpi eq, %1342, %1345 : i64
          cf.cond_br %1346, ^bb150, ^bb151
          ^bb150:
            %1347 = arith.index_cast %1341 : index to i64
            llvm.store %1347, %1328 : i64, !llvm.ptr
            cf.br ^bb152
          ^bb151:
            cf.br ^bb152
          ^bb152:
          %1348 = arith.addi %1341, %1333 : index
          cf.br ^bb147(%1348 : index)
        ^bb149(%1349: index):
        %1350 = llvm.load %1328 : !llvm.ptr -> i64
        %1351 = arith.constant 1 : i32
        %1353 = arith.constant 0 : i32
        %1352 = arith.subi %1353, %1351 : i32
        %1355 = arith.extsi %1352 : i32 to i64
        %1354 = arith.cmpi eq, %1350, %1355 : i64
        cf.cond_br %1354, ^bb153, ^bb154
        ^bb153:
          %1356 = llvm.load %1241 : !llvm.ptr -> i64
          %1357 = llvm.load %1197 : !llvm.ptr -> i64
          %1358 = llvm.getelementptr %1188[%1357] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          llvm.store %1356, %1358 : i64, !llvm.ptr
          %1359 = llvm.load %1197 : !llvm.ptr -> i64
          %1360 = llvm.getelementptr %1191[%1359] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          llvm.store %1322, %1360 : i64, !llvm.ptr
          %1361 = llvm.load %1197 : !llvm.ptr -> i64
          %1362 = arith.constant 1 : i32
          %1364 = arith.extsi %1362 : i32 to i64
          %1363 = arith.addi %1361, %1364 : i64
          llvm.store %1363, %1197 : i64, !llvm.ptr
          cf.br ^bb155
        ^bb154:
          %1366 = llvm.load %1328 : !llvm.ptr -> i64
          %1367 = llvm.getelementptr %1191[%1366] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          %1365 = llvm.load %1367 : !llvm.ptr -> i64
          %1368 = arith.addi %1365, %1322 : i64
          %1369 = llvm.mlir.addressof @MOD : !llvm.ptr
          %1370 = llvm.load %1369 : !llvm.ptr -> i64
          %1371 = arith.remsi %1368, %1370 : i64
          %1372 = llvm.load %1328 : !llvm.ptr -> i64
          %1373 = llvm.getelementptr %1191[%1372] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          llvm.store %1371, %1373 : i64, !llvm.ptr
          cf.br ^bb155
        ^bb155:
        %1374 = arith.addi %1224, %1216 : index
        cf.br ^bb138(%1374 : index)
      ^bb140(%1375: index):
      %1376 = arith.addi %1209, %1201 : index
      cf.br ^bb135(%1376 : index)
    ^bb137(%1377: index):
    %1379 = arith.constant 1 : i32
    %1381 = arith.extsi %1379 : i32 to i64
    %1380 = arith.addi %arg0, %1381 : i64
    %1382 = arith.constant 8 : i32
    %1383 = arith.extsi %1382 : i32 to i64
    %1378 = func.call @calloc(%1380, %1383) : (i64, i64) -> !llvm.ptr
    func.call @compute_comb(%arg0, %1378) : (i64, !llvm.ptr) -> ()
    %1385 = arith.constant 0 : i32
    %1386 = arith.extsi %1385 : i32 to i64
    %1387 = llvm.mlir.constant(1 : i64) : i64
    %1388 = llvm.alloca %1387 x i64 : (i64) -> !llvm.ptr
    llvm.store %1386, %1388 : i64, !llvm.ptr
    %1389 = arith.constant 0 : i32
    %1390 = llvm.load %1197 : !llvm.ptr -> i64
    %1391 = arith.index_cast %1389 : i32 to index
    %1392 = arith.index_cast %1390 : i32 to index
    %1394 = arith.constant 1 : index
    %1395 = arith.constant -1 : index
    %1396 = arith.cmpi sle, %1391, %1392 : index
    %1393 = arith.select %1396, %1394, %1395 : index
    cf.br ^bb156(%1391 : index)
    ^bb156(%1397: index):
    %1398 = arith.cmpi slt, %1397, %1392 : index
    %1399 = arith.cmpi sgt, %1397, %1392 : index
    %1400 = arith.select %1396, %1398, %1399 : i1
    cf.cond_br %1400, ^bb157(%1397 : index), ^bb158(%1397 : index)
    ^bb157(%1401: index):
      %1404 = arith.index_cast %1401 : index to i64
      %1405 = llvm.getelementptr %1188[%1404] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %1403 = llvm.load %1405 : !llvm.ptr -> i64
      %1402 = func.call @surjections_count(%1403, %arg0, %1378) : (i64, i64, !llvm.ptr) -> i64
      %1406 = llvm.load %1388 : !llvm.ptr -> i64
      %1408 = arith.index_cast %1401 : index to i64
      %1409 = llvm.getelementptr %1191[%1408] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %1407 = llvm.load %1409 : !llvm.ptr -> i64
      %1410 = arith.muli %1407, %1402 : i64
      %1411 = arith.addi %1406, %1410 : i64
      %1412 = llvm.mlir.addressof @MOD : !llvm.ptr
      %1413 = llvm.load %1412 : !llvm.ptr -> i64
      %1414 = arith.remsi %1411, %1413 : i64
      llvm.store %1414, %1388 : i64, !llvm.ptr
      %1415 = arith.addi %1401, %1393 : index
      cf.br ^bb156(%1415 : index)
    ^bb158(%1416: index):
    %1417 = arith.constant 4 : i32
    %1418 = llvm.mlir.addressof @MOD : !llvm.ptr
    %1419 = llvm.load %1418 : !llvm.ptr -> i64
    %1420 = arith.remsi %arg1, %1419 : i64
    %1422 = arith.extsi %1417 : i32 to i64
    %1421 = arith.muli %1422, %1420 : i64
    %1423 = llvm.mlir.addressof @MOD : !llvm.ptr
    %1424 = llvm.load %1423 : !llvm.ptr -> i64
    %1425 = arith.remsi %arg2, %1424 : i64
    %1426 = arith.muli %1421, %1425 : i64
    %1427 = llvm.mlir.addressof @MOD : !llvm.ptr
    %1428 = llvm.load %1427 : !llvm.ptr -> i64
    %1429 = arith.remsi %1426, %1428 : i64
    %1430 = llvm.load %1388 : !llvm.ptr -> i64
    %1432 = llvm.mlir.addressof @MOD : !llvm.ptr
    %1433 = llvm.load %1432 : !llvm.ptr -> i64
    %1434 = arith.constant 2 : i32
    %1436 = arith.extsi %1434 : i32 to i64
    %1435 = arith.subi %1433, %1436 : i64
    %1437 = llvm.mlir.addressof @MOD : !llvm.ptr
    %1438 = llvm.load %1437 : !llvm.ptr -> i64
    %1431 = func.call @pow_mod(%1429, %1435, %1438) : (i64, i64, i64) -> i64
    %1439 = arith.muli %1430, %1431 : i64
    %1440 = llvm.mlir.addressof @MOD : !llvm.ptr
    %1441 = llvm.load %1440 : !llvm.ptr -> i64
    %1442 = arith.remsi %1439, %1441 : i64
    func.call @free(%1378) : (!llvm.ptr) -> ()
    func.call @free(%1191) : (!llvm.ptr) -> ()
    func.call @free(%1188) : (!llvm.ptr) -> ()
    func.call @free(%1089) : (!llvm.ptr) -> ()
    func.call @free(%1081) : (!llvm.ptr) -> ()
    func.call @free(%1076) : (!llvm.ptr) -> ()
    func.call @free(%1071) : (!llvm.ptr) -> ()
    func.return %1442 : i64
  }
  func.func @main() -> i32 {
    func.call @sieve_primes() : () -> ()
    func.call @init_type_arrays() : () -> ()
    %1453 = arith.constant 41 : i32
    %1454 = arith.constant 8 : i32
    %1455 = arith.extsi %1453 : i32 to i64
    %1456 = arith.extsi %1454 : i32 to i64
    %1452 = func.call @calloc(%1455, %1456) : (i64, i64) -> !llvm.ptr
    %1457 = arith.constant 0 : i32
    %1458 = arith.constant 0 : i32
    %1459 = arith.extsi %1457 : i32 to i64
    %1460 = arith.extsi %1458 : i32 to i64
    %1461 = llvm.getelementptr %1452[%1460] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    llvm.store %1459, %1461 : i64, !llvm.ptr
    %1462 = arith.constant 1 : i32
    %1463 = arith.constant 1 : i32
    %1464 = arith.extsi %1462 : i32 to i64
    %1465 = arith.extsi %1463 : i32 to i64
    %1466 = llvm.getelementptr %1452[%1465] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    llvm.store %1464, %1466 : i64, !llvm.ptr
    %1467 = arith.constant 2 : i32
    %1468 = arith.constant 41 : i32
    %1469 = arith.index_cast %1467 : i32 to index
    %1470 = arith.index_cast %1468 : i32 to index
    %1472 = arith.constant 1 : index
    %1473 = arith.constant -1 : index
    %1474 = arith.cmpi sle, %1469, %1470 : index
    %1471 = arith.select %1474, %1472, %1473 : index
    cf.br ^bb159(%1469 : index)
    ^bb159(%1475: index):
    %1476 = arith.cmpi slt, %1475, %1470 : index
    %1477 = arith.cmpi sgt, %1475, %1470 : index
    %1478 = arith.select %1474, %1476, %1477 : i1
    cf.cond_br %1478, ^bb160(%1475 : index), ^bb161(%1475 : index)
    ^bb160(%1479: index):
      %1481 = arith.constant 1 : i32
      %1483 = arith.index_cast %1479 : index to i32
      %1482 = arith.subi %1483, %1481 : i32
      %1484 = arith.extsi %1482 : i32 to i64
      %1485 = llvm.getelementptr %1452[%1484] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %1480 = llvm.load %1485 : !llvm.ptr -> i64
      %1487 = arith.constant 2 : i32
      %1489 = arith.index_cast %1479 : index to i32
      %1488 = arith.subi %1489, %1487 : i32
      %1490 = arith.extsi %1488 : i32 to i64
      %1491 = llvm.getelementptr %1452[%1490] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %1486 = llvm.load %1491 : !llvm.ptr -> i64
      %1492 = arith.addi %1480, %1486 : i64
      %1493 = arith.index_cast %1479 : index to i64
      %1494 = llvm.getelementptr %1452[%1493] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %1492, %1494 : i64, !llvm.ptr
      %1495 = arith.addi %1479, %1471 : index
      cf.br ^bb159(%1495 : index)
    ^bb161(%1496: index):
    %1497 = arith.constant 0 : i32
    %1498 = arith.extsi %1497 : i32 to i64
    %1499 = llvm.mlir.constant(1 : i64) : i64
    %1500 = llvm.alloca %1499 x i64 : (i64) -> !llvm.ptr
    llvm.store %1498, %1500 : i64, !llvm.ptr
    %1501 = arith.constant 4 : i32
    %1502 = arith.constant 41 : i32
    %1503 = arith.index_cast %1501 : i32 to index
    %1504 = arith.index_cast %1502 : i32 to index
    %1506 = arith.constant 1 : index
    %1507 = arith.constant -1 : index
    %1508 = arith.cmpi sle, %1503, %1504 : index
    %1505 = arith.select %1508, %1506, %1507 : index
    cf.br ^bb162(%1503 : index)
    ^bb162(%1509: index):
    %1510 = arith.cmpi slt, %1509, %1504 : index
    %1511 = arith.cmpi sgt, %1509, %1504 : index
    %1512 = arith.select %1508, %1510, %1511 : i1
    cf.cond_br %1512, ^bb163(%1509 : index), ^bb164(%1509 : index)
    ^bb163(%1513: index):
      %1514 = llvm.load %1500 : !llvm.ptr -> i64
      %1517 = arith.constant 1 : i32
      %1519 = arith.index_cast %1513 : index to i32
      %1518 = arith.subi %1519, %1517 : i32
      %1520 = arith.extsi %1518 : i32 to i64
      %1521 = llvm.getelementptr %1452[%1520] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %1516 = llvm.load %1521 : !llvm.ptr -> i64
      %1523 = arith.index_cast %1513 : index to i64
      %1524 = llvm.getelementptr %1452[%1523] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %1522 = llvm.load %1524 : !llvm.ptr -> i64
      %1525 = arith.index_cast %1513 : index to i64
      %1515 = func.call @f(%1525, %1516, %1522) : (i64, i64, i64) -> i64
      %1526 = arith.addi %1514, %1515 : i64
      %1527 = llvm.mlir.addressof @MOD : !llvm.ptr
      %1528 = llvm.load %1527 : !llvm.ptr -> i64
      %1529 = arith.remsi %1526, %1528 : i64
      llvm.store %1529, %1500 : i64, !llvm.ptr
      %1530 = arith.addi %1513, %1505 : index
      cf.br ^bb162(%1530 : index)
    ^bb164(%1531: index):
    %1532 = llvm.mlir.addressof @str_0 : !llvm.ptr
    %1533 = llvm.load %1500 : !llvm.ptr -> i64
    %1534 = llvm.call @printf(%1532, %1533) vararg(!llvm.func<i32 (ptr, ...)>) : (!llvm.ptr, i64) -> i32
    func.call @free(%1452) : (!llvm.ptr) -> ()
    %1537 = llvm.mlir.addressof @g_type_ccnt : !llvm.ptr
    %1538 = llvm.load %1537 : !llvm.ptr -> !llvm.ptr
    func.call @free(%1538) : (!llvm.ptr) -> ()
    %1540 = llvm.mlir.addressof @g_type_clen : !llvm.ptr
    %1541 = llvm.load %1540 : !llvm.ptr -> !llvm.ptr
    func.call @free(%1541) : (!llvm.ptr) -> ()
    %1543 = llvm.mlir.addressof @g_type_mult : !llvm.ptr
    %1544 = llvm.load %1543 : !llvm.ptr -> !llvm.ptr
    func.call @free(%1544) : (!llvm.ptr) -> ()
    %1546 = llvm.mlir.addressof @g_type_ncyc : !llvm.ptr
    %1547 = llvm.load %1546 : !llvm.ptr -> !llvm.ptr
    func.call @free(%1547) : (!llvm.ptr) -> ()
    %1549 = llvm.mlir.addressof @g_primes : !llvm.ptr
    %1550 = llvm.load %1549 : !llvm.ptr -> !llvm.ptr
    func.call @free(%1550) : (!llvm.ptr) -> ()
    %1551 = arith.constant 0 : i32
    func.return %1551 : i32
  }
}