Problem 626

Counting binary matrices up to row/col perm/flip; c(20) mod 1001001011.

Answer695577663
Output695577663
StatusPASS
Native helperno
Runtime20 ms
Peak memory1456 KB
Time complexityO(n^4) (estimated)
Space complexityO(n^2) (estimated)

Performance comparison

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

Flow source

# Project Euler 626
# Counting binary matrices up to row/col perm/flip; c(20) mod 1001001011.

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

const MOD: i64 = 1001001011
const N: i32 = 20

# Global partition info (flat arrays, max 2000 partitions).
let mut ninfos: i32 = 0
let mut g_lens: ptr<i32> = null as ptr<i32>
let mut g_mults: ptr<i32> = null as ptr<i32>
let mut g_ntypes: ptr<i32> = null as ptr<i32>
let mut g_kcycles: ptr<i32> = null as ptr<i32>
let mut g_tmin: ptr<i32> = null as ptr<i32>
let mut g_prefix_lt: ptr<i32> = null as ptr<i32>
let mut g_count_mod: ptr<i64> = null as ptr<i64>
let mut g_part_buf: ptr<i32> = null as ptr<i32>
let mut g_fact: ptr<i64> = null as ptr<i64>
let mut g_invfact: ptr<i64> = null as ptr<i64>
let mut g_inv_int: ptr<i64> = null as ptr<i64>

function mod_pow(a0: i64, e0: i64) -> i64 {
    let mut r: i64 = 1 % MOD
    let mut a: i64 = a0 % MOD
    let mut e: i64 = e0
    while e > 0 {
        if (e & 1) == 1 {
            r = ((r as i128) * (a as i128) % (MOD as i128)) as i64
        }
        a = ((a as i128) * (a as i128) % (MOD as i128)) as i64
        e = e >> 1
    }
    return r
}

function gcd_i(a0: i32, b0: i32) -> i32 {
    let mut a: i32 = a0
    let mut b: i32 = b0
    while b != 0 {
        let t: i32 = a % b
        a = b
        b = t
    }
    return a
}

function v2(x0: i32) -> i32 {
    let mut x: i32 = x0
    let mut c: i32 = 0
    while (x & 1) == 0 {
        x = x >> 1
        c = c + 1
    }
    return c
}

function emit_partition(p: ptr<i32>, len: i32, tmax: i32) {
    let counts: ptr<i32> = calloc(21, 4)
    for i in 0..21 {
        counts[i] = 0
    }
    for i in 0..len {
        counts[p[i]] = counts[p[i]] + 1
    }

    let idx: i32 = ninfos
    ninfos = ninfos + 1

    g_ntypes[idx] = 0
    g_kcycles[idx] = len
    g_tmin[idx] = 100

    for L in 1..(N + 1) {
        if counts[L] != 0 {
            let nt: i32 = g_ntypes[idx]
            g_lens[idx * 20 + nt] = L
            g_mults[idx * 20 + nt] = counts[L]
            g_ntypes[idx] = nt + 1
            let t: i32 = v2(L)
            if t < g_tmin[idx] {
                g_tmin[idx] = t
            }
        }
    }

    let count_v2: ptr<i32> = calloc(8, 4)
    for i in 0..8 {
        count_v2[i] = 0
    }
    for L in 1..(N + 1) {
        if counts[L] != 0 {
            count_v2[v2(L)] = count_v2[v2(L)] + counts[L]
        }
    }

    let mut s: i32 = 0
    for t in 0..(tmax + 2) {
        g_prefix_lt[idx * 8 + t] = 0
    }
    for t in 0..(tmax + 1) {
        s = s + count_v2[t]
        g_prefix_lt[idx * 8 + t + 1] = s
    }

    let mut cm: i64 = g_fact[N]
    for L in 1..(N + 1) {
        if counts[L] != 0 {
            let mult: i32 = counts[L]
            cm = ((cm as i128) * (mod_pow(g_inv_int[L], (mult as i64)) as i128) % (MOD as i128)) as i64
            cm = ((cm as i128) * (g_invfact[mult] as i128) % (MOD as i128)) as i64
        }
    }
    g_count_mod[idx] = cm

    free(count_v2)
    free(counts)
}

function gen_partitions(rem: i32, maxp: i32, depth: i32, tmax: i32) {
    if rem == 0 {
        emit_partition(g_part_buf, depth, tmax)
        return
    }
    let mut first: i32 = maxp
    if maxp > rem {
        first = rem
    }
    while first >= 1 {
        g_part_buf[depth] = first
        gen_partitions(rem - first, first, depth + 1, tmax)
        first = first - 1
    }
}

function main() -> i32 {
    # Allocate global arrays
    g_fact = calloc(21, 8)
    g_invfact = calloc(21, 8)
    g_inv_int = calloc(21, 8)
    g_lens = calloc(2000 * 20, 4)
    g_mults = calloc(2000 * 20, 4)
    g_ntypes = calloc(2000, 4)
    g_kcycles = calloc(2000, 4)
    g_tmin = calloc(2000, 4)
    g_prefix_lt = calloc(2000 * 8, 4)
    g_count_mod = calloc(2000, 8)
    g_part_buf = calloc(20, 4)

    g_fact[0] = 1
    for i in 1..(N + 1) {
        g_fact[i] = ((g_fact[i - 1] as i128) * (i as i128) % (MOD as i128)) as i64
    }
    g_invfact[N] = mod_pow(g_fact[N], MOD - 2)
    let mut i: i32 = N
    while i > 0 {
        g_invfact[i - 1] = ((g_invfact[i] as i128) * (i as i128) % (MOD as i128)) as i64
        i = i - 1
    }
    for j in 1..(N + 1) {
        g_inv_int[j] = mod_pow((j as i64), MOD - 2)
    }

    let mut tmax: i32 = 0
    let mut pp: i32 = 1
    while pp * 2 <= N {
        tmax = tmax + 1
        pp = pp * 2
    }

    ninfos = 0
    gen_partitions(N, N, 0, tmax)

    # gcd_tab
    let gcd_tab: ptr<i32> = calloc(21 * 21, 4)
    for a in 1..(N + 1) {
        for b in 1..(N + 1) {
            gcd_tab[a * 21 + b] = gcd_i(a, b)
        }
    }

    # pow2
    let pow2: ptr<i64> = calloc(401, 8)
    pow2[0] = 1
    for j in 1..(N * N + 2) {
        pow2[j] = (pow2[j - 1] * 2) % MOD
    }

    let mut total: i64 = 0
    for ii in 0..ninfos {
        for jj in 0..ninfos {
            let mut cycles: i32 = 0
            for a in 0..g_ntypes[ii] {
                for b in 0..g_ntypes[jj] {
                    cycles = cycles + g_mults[ii * 20 + a] * g_mults[jj * 20 + b] * gcd_tab[g_lens[ii * 20 + a] * 21 + g_lens[jj * 20 + b]]
                }
            }
            let mut d: i32 = 0
            if g_tmin[ii] < g_tmin[jj] {
                d = g_prefix_lt[ii * 8 + g_tmin[jj]]
            } else {
                if g_tmin[jj] < g_tmin[ii] {
                    d = g_prefix_lt[jj * 8 + g_tmin[ii]]
                } else {
                    d = 1
                }
            }
            let e: i32 = cycles - g_kcycles[ii] - g_kcycles[jj] + d
            let mut term: i64 = ((g_count_mod[ii] as i128) * (g_count_mod[jj] as i128) % (MOD as i128)) as i64
            term = ((term as i128) * (pow2[e] as i128) % (MOD as i128)) as i64
            total = (total + term) % MOD
        }
    }

    let inv_fact_n: i64 = mod_pow(g_fact[N], MOD - 2)
    let inv_den: i64 = ((inv_fact_n as i128) * (inv_fact_n as i128) % (MOD as i128)) as i64
    let result: i64 = ((total as i128) * (inv_den as i128) % (MOD as i128)) as i64

    printf("%lld\n", result)

    free(pow2)
    free(gcd_tab)
    free(g_part_buf)
    free(g_count_mod)
    free(g_prefix_lt)
    free(g_tmin)
    free(g_kcycles)
    free(g_ntypes)
    free(g_mults)
    free(g_lens)
    free(g_inv_int)
    free(g_invfact)
    free(g_fact)
    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 mod_pow_i64_i64(int64_t a0, int64_t e0);
int32_t gcd_i_i32_i32(int32_t a0, int32_t b0);
int32_t v2_i32(int32_t x0);
void emit_partition_ptr_i32_i32_i32(int32_t* p, int32_t len, int32_t tmax);
void gen_partitions_i32_i32_i32_i32(int32_t rem, int32_t maxp, int32_t depth, int32_t tmax);
int32_t main(void);

static const int64_t MOD = 1001001011;
static const int32_t N = 20;

/* Module statics */
static int32_t ninfos = 0;
static int32_t* g_lens = ((int32_t*)(NULL));
static int32_t* g_mults = ((int32_t*)(NULL));
static int32_t* g_ntypes = ((int32_t*)(NULL));
static int32_t* g_kcycles = ((int32_t*)(NULL));
static int32_t* g_tmin = ((int32_t*)(NULL));
static int32_t* g_prefix_lt = ((int32_t*)(NULL));
static int64_t* g_count_mod = ((int64_t*)(NULL));
static int32_t* g_part_buf = ((int32_t*)(NULL));
static int64_t* g_fact = ((int64_t*)(NULL));
static int64_t* g_invfact = ((int64_t*)(NULL));
static int64_t* g_inv_int = ((int64_t*)(NULL));




int64_t mod_pow_i64_i64(int64_t a0, int64_t e0) {
    int64_t r = FLOW_CHECKED_MOD((1), (MOD));
    int64_t a = FLOW_CHECKED_MOD((a0), (MOD));
    int64_t e = e0;
    while (e > 0) {
        if ((e & 1) == 1) {
            r = ((int64_t)(FLOW_CHECKED_MOD(((((__int128)(r)) * ((__int128)(a)))), (((__int128)(MOD))))));
        }
        a = ((int64_t)(FLOW_CHECKED_MOD(((((__int128)(a)) * ((__int128)(a)))), (((__int128)(MOD))))));
        e = FLOW_CHECKED_SHR((e), (1));
    }
    return r;
}

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

int32_t v2_i32(int32_t x0) {
    int32_t x = x0;
    int32_t c = 0;
    while ((x & 1) == 0) {
        x = FLOW_CHECKED_SHR((x), (1));
        c = (c + 1);
    }
    return c;
}

void emit_partition_ptr_i32_i32_i32(int32_t* p, int32_t len, int32_t tmax) {
    int32_t* counts = (int32_t*)(calloc(21, 4));
    int32_t __flow_step_1 = 1;
    for (int32_t i = 0; (0 <= 21) ? i < 21 : i > 21; i += (0 <= 21) ? 1 : -1) {
        counts[i] = 0;
    }
    int32_t __flow_step_2 = 1;
    for (int32_t i = 0; (0 <= len) ? i < len : i > len; i += (0 <= len) ? 1 : -1) {
        counts[p[i]] = (counts[p[i]] + 1);
    }
    int32_t idx = ninfos;
    ninfos = (ninfos + 1);
    g_ntypes[idx] = 0;
    g_kcycles[idx] = len;
    g_tmin[idx] = 100;
    int32_t __flow_step_3 = 1;
    for (int32_t L = 1; (1 <= (N + 1)) ? L < (N + 1) : L > (N + 1); L += (1 <= (N + 1)) ? 1 : -1) {
        if (counts[L] != 0) {
            int32_t nt = g_ntypes[idx];
            g_lens[((idx * 20) + nt)] = L;
            g_mults[((idx * 20) + nt)] = counts[L];
            g_ntypes[idx] = (nt + 1);
            int32_t t = v2_i32(L);
            if (t < g_tmin[idx]) {
                g_tmin[idx] = t;
            }
        }
    }
    int32_t* count_v2 = (int32_t*)(calloc(8, 4));
    int32_t __flow_step_4 = 1;
    for (int32_t i = 0; (0 <= 8) ? i < 8 : i > 8; i += (0 <= 8) ? 1 : -1) {
        count_v2[i] = 0;
    }
    int32_t __flow_step_5 = 1;
    for (int32_t L = 1; (1 <= (N + 1)) ? L < (N + 1) : L > (N + 1); L += (1 <= (N + 1)) ? 1 : -1) {
        if (counts[L] != 0) {
            count_v2[v2_i32(L)] = (count_v2[v2_i32(L)] + counts[L]);
        }
    }
    int32_t s = 0;
    int32_t __flow_step_6 = 1;
    for (int32_t t = 0; (0 <= (tmax + 2)) ? t < (tmax + 2) : t > (tmax + 2); t += (0 <= (tmax + 2)) ? 1 : -1) {
        g_prefix_lt[((idx * 8) + t)] = 0;
    }
    int32_t __flow_step_7 = 1;
    for (int32_t t = 0; (0 <= (tmax + 1)) ? t < (tmax + 1) : t > (tmax + 1); t += (0 <= (tmax + 1)) ? 1 : -1) {
        s = (s + count_v2[t]);
        g_prefix_lt[(((idx * 8) + t) + 1)] = s;
    }
    int64_t cm = g_fact[N];
    int32_t __flow_step_8 = 1;
    for (int32_t L = 1; (1 <= (N + 1)) ? L < (N + 1) : L > (N + 1); L += (1 <= (N + 1)) ? 1 : -1) {
        if (counts[L] != 0) {
            int32_t mult = counts[L];
            cm = ((int64_t)(FLOW_CHECKED_MOD(((((__int128)(cm)) * ((__int128)(mod_pow_i64_i64(g_inv_int[L], ((int64_t)(mult))))))), (((__int128)(MOD))))));
            cm = ((int64_t)(FLOW_CHECKED_MOD(((((__int128)(cm)) * ((__int128)(g_invfact[mult])))), (((__int128)(MOD))))));
        }
    }
    g_count_mod[idx] = cm;
    free(count_v2);
    free(counts);
}

void gen_partitions_i32_i32_i32_i32(int32_t rem, int32_t maxp, int32_t depth, int32_t tmax) {
    if (rem == 0) {
        emit_partition_ptr_i32_i32_i32(g_part_buf, depth, tmax);
        return;
    }
    int32_t first = maxp;
    if (maxp > rem) {
        first = rem;
    }
    while (first >= 1) {
        g_part_buf[depth] = first;
        gen_partitions_i32_i32_i32_i32((rem - first), first, (depth + 1), tmax);
        first = (first - 1);
    }
}

int32_t main(void) {
    g_fact = calloc(21, 8);
    g_invfact = calloc(21, 8);
    g_inv_int = calloc(21, 8);
    g_lens = calloc((2000 * 20), 4);
    g_mults = calloc((2000 * 20), 4);
    g_ntypes = calloc(2000, 4);
    g_kcycles = calloc(2000, 4);
    g_tmin = calloc(2000, 4);
    g_prefix_lt = calloc((2000 * 8), 4);
    g_count_mod = calloc(2000, 8);
    g_part_buf = calloc(20, 4);
    g_fact[0] = 1;
    int32_t __flow_step_9 = 1;
    for (int32_t i = 1; (1 <= (N + 1)) ? i < (N + 1) : i > (N + 1); i += (1 <= (N + 1)) ? 1 : -1) {
        g_fact[i] = ((int64_t)(FLOW_CHECKED_MOD(((((__int128)(g_fact[(i - 1)])) * ((__int128)(i)))), (((__int128)(MOD))))));
    }
    g_invfact[N] = mod_pow_i64_i64(g_fact[N], (MOD - 2));
    int32_t i = N;
    while (i > 0) {
        g_invfact[(i - 1)] = ((int64_t)(FLOW_CHECKED_MOD(((((__int128)(g_invfact[i])) * ((__int128)(i)))), (((__int128)(MOD))))));
        i = (i - 1);
    }
    int32_t __flow_step_10 = 1;
    for (int32_t j = 1; (1 <= (N + 1)) ? j < (N + 1) : j > (N + 1); j += (1 <= (N + 1)) ? 1 : -1) {
        g_inv_int[j] = mod_pow_i64_i64(((int64_t)(j)), (MOD - 2));
    }
    int32_t tmax = 0;
    int32_t pp = 1;
    while ((pp * 2) <= N) {
        tmax = (tmax + 1);
        pp = (pp * 2);
    }
    ninfos = 0;
    gen_partitions_i32_i32_i32_i32(N, N, 0, tmax);
    int32_t* gcd_tab = (int32_t*)(calloc((21 * 21), 4));
    int32_t __flow_step_11 = 1;
    for (int32_t a = 1; (1 <= (N + 1)) ? a < (N + 1) : a > (N + 1); a += (1 <= (N + 1)) ? 1 : -1) {
        int32_t __flow_step_12 = 1;
        for (int32_t b = 1; (1 <= (N + 1)) ? b < (N + 1) : b > (N + 1); b += (1 <= (N + 1)) ? 1 : -1) {
            gcd_tab[((a * 21) + b)] = gcd_i_i32_i32(a, b);
        }
    }
    int64_t* pow2 = (int64_t*)(calloc(401, 8));
    pow2[0] = 1;
    int32_t __flow_step_13 = 1;
    for (int32_t j = 1; (1 <= ((N * N) + 2)) ? j < ((N * N) + 2) : j > ((N * N) + 2); j += (1 <= ((N * N) + 2)) ? 1 : -1) {
        pow2[j] = FLOW_CHECKED_MOD(((pow2[(j - 1)] * 2)), (MOD));
    }
    int64_t total = 0;
    int32_t __flow_step_14 = 1;
    for (int32_t ii = 0; (0 <= ninfos) ? ii < ninfos : ii > ninfos; ii += (0 <= ninfos) ? 1 : -1) {
        int32_t __flow_step_15 = 1;
        for (int32_t jj = 0; (0 <= ninfos) ? jj < ninfos : jj > ninfos; jj += (0 <= ninfos) ? 1 : -1) {
            int32_t cycles = 0;
            int32_t __flow_step_16 = 1;
            for (int32_t a = 0; (0 <= g_ntypes[ii]) ? a < g_ntypes[ii] : a > g_ntypes[ii]; a += (0 <= g_ntypes[ii]) ? 1 : -1) {
                int32_t __flow_step_17 = 1;
                for (int32_t b = 0; (0 <= g_ntypes[jj]) ? b < g_ntypes[jj] : b > g_ntypes[jj]; b += (0 <= g_ntypes[jj]) ? 1 : -1) {
                    cycles = (cycles + ((g_mults[((ii * 20) + a)] * g_mults[((jj * 20) + b)]) * gcd_tab[((g_lens[((ii * 20) + a)] * 21) + g_lens[((jj * 20) + b)])]));
                }
            }
            int32_t d = 0;
            if (g_tmin[ii] < g_tmin[jj]) {
                d = g_prefix_lt[((ii * 8) + g_tmin[jj])];
            } else {
                if (g_tmin[jj] < g_tmin[ii]) {
                    d = g_prefix_lt[((jj * 8) + g_tmin[ii])];
                } else {
                    d = 1;
                }
            }
            int32_t e = (((cycles - g_kcycles[ii]) - g_kcycles[jj]) + d);
            int64_t term = ((int64_t)(FLOW_CHECKED_MOD(((((__int128)(g_count_mod[ii])) * ((__int128)(g_count_mod[jj])))), (((__int128)(MOD))))));
            term = ((int64_t)(FLOW_CHECKED_MOD(((((__int128)(term)) * ((__int128)(pow2[e])))), (((__int128)(MOD))))));
            total = FLOW_CHECKED_MOD(((total + term)), (MOD));
        }
    }
    int64_t inv_fact_n = mod_pow_i64_i64(g_fact[N], (MOD - 2));
    int64_t inv_den = ((int64_t)(FLOW_CHECKED_MOD(((((__int128)(inv_fact_n)) * ((__int128)(inv_fact_n)))), (((__int128)(MOD))))));
    int64_t result = ((int64_t)(FLOW_CHECKED_MOD(((((__int128)(total)) * ((__int128)(inv_den)))), (((__int128)(MOD))))));
    printf("%lld\n", result);
    free(pow2);
    free(gcd_tab);
    free(g_part_buf);
    free(g_count_mod);
    free(g_prefix_lt);
    free(g_tmin);
    free(g_kcycles);
    free(g_ntypes);
    free(g_mults);
    free(g_lens);
    free(g_inv_int);
    free(g_invfact);
    free(g_fact);
    return 0;
}

Generated MLIR

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