Problem 837

Amidakuji: count 3-line identity permutations with m,n rungs. a(123456789, 987654321) mod 1234567891. Pure Flow port of the native C helper (modular arithmetic with batch inversion). MOD^2 < 9.2e18 so i64 products are safe.

Answer428074856
Output428074856
StatusPASS
Native helperno
Runtime3470 ms
Peak memory14192 KB
Time complexityO(n) (estimated)
Space complexityO(1) (estimated)

Performance comparison

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

Flow source

# Project Euler 837
# Amidakuji: count 3-line identity permutations with m,n rungs.
# a(123456789, 987654321) mod 1234567891.
# Pure Flow port of the native C helper (modular arithmetic with batch
# inversion). MOD^2 < 9.2e18 so i64 products are safe.

import euler.nt { mod_pow }

const MOD: i64 = 1234567891

function mulmod(a0: i64, b0: i64) -> i64 {
    let a: i64 = a0 % MOD
    let b: i64 = b0 % MOD
    return a * b % MOD
}

# Batch-invert consecutive integers start, start+1, ..., start+length-1 mod p.
function invert_consecutive(start: i64, length: i64, out: ptr<i64>) {
    if length <= 0 {
        return
    }
    let pref: ptr<i64> = malloc(length * 8)
    let mut acc: i64 = 1
    for i in 0..length {
        acc = acc * ((start + i) % MOD) % MOD
        pref[i] = acc
    }
    let mut inv_acc: i64 = mod_pow(pref[length - 1], MOD - 2, MOD)
    let mut i: i64 = length - 1
    while i >= 0 {
        let prev: i64 = 1
        if i != 0 {
            prev = pref[i - 1]
        }
        out[i] = inv_acc * prev % MOD
        inv_acc = inv_acc * ((start + i) % MOD) % MOD
        i = i - 1
    }
    free(pref)
}

# Batch-invert a list of values mod p.
function invert_list(vals: ptr<i64>, n: i64, out: ptr<i64>) {
    if n == 0 {
        return
    }
    let pref: ptr<i64> = malloc(n * 8)
    let mut acc: i64 = 1
    for i in 0..n {
        acc = acc * vals[i] % MOD
        pref[i] = acc
    }
    let mut inv_acc: i64 = mod_pow(pref[n - 1], MOD - 2, MOD)
    let mut i: i64 = n - 1
    while i >= 0 {
        let prev: i64 = 1
        if i != 0 {
            prev = pref[i - 1]
        }
        out[i] = inv_acc * prev % MOD
        inv_acc = inv_acc * vals[i] % MOD
        i = i - 1
    }
    free(pref)
}

# C(n,k) mod prime, product formula with batch inversion.
function binom_mod(n: i64, k: i64) -> i64 {
    if k < 0 || k > n {
        return 0
    }
    let mut kk: i64 = k
    if kk > n - kk {
        kk = n - kk
    }
    if kk == 0 {
        return 1
    }
    let base: i64 = n - kk
    let mut res: i64 = 1
    let mut start: i64 = 1
    let block: i64 = 200000
    let invs: ptr<i64> = malloc(block * 8)
    while start <= kk {
        let mut length: i64 = block
        if length > kk - start + 1 {
            length = kk - start + 1
        }
        invert_consecutive(start, length, invs)
        let b: i64 = base + start
        for i in 0..length {
            res = res * ((b + i) % MOD) % MOD
            res = res * invs[i] % MOD
        }
        start = start + length
    }
    free(invs)
    return res
}

function amidakuji_count_mod(m: i64, n: i64) -> i64 {
    let L: i64 = m + n
    if L % 2 == 1 {
        return 0
    }

    let t: i64 = L / 2
    let mut k: i64 = m % 2
    let limit: i64 = m
    if n < m {
        limit = n
    }

    let mut layout: i64 = 0
    if k == 0 {
        layout = binom_mod(t, m / 2)
    } else {
        layout = (t % MOD) * binom_mod(t - 1, (m - 1) / 2) % MOD
    }

    let inv3: i64 = mod_pow(3, MOD - 2, MOD)
    let mut pow2: i64 = 1
    if k != 0 {
        pow2 = 2
    }
    let mut sign: i64 = 1
    if k != 0 {
        sign = MOD - 1
    }

    let mut total: i64 = 0
    let block: i64 = 200000
    let nums: ptr<i64> = malloc(block * 8)
    let dens: ptr<i64> = malloc(block * 8)
    let inv_dens: ptr<i64> = malloc(block * 8)

    while k <= limit {
        let mut steps: i64 = block
        let avail: i64 = ((limit - k) / 2) + 1
        if steps > avail {
            steps = avail
        }

        let mut kk: i64 = k
        for i in 0..steps {
            nums[i] = ((m - kk) % MOD) * ((n - kk) % MOD) % MOD
            dens[i] = ((4 * (kk + 1)) % MOD) * ((kk + 2) % MOD) % MOD
            kk = kk + 2
        }

        invert_list(dens, steps, inv_dens)

        for i in 0..steps {
            let orientations: i64 = ((pow2 + 2 * sign) % MOD) * inv3 % MOD
            total = (total + layout * orientations % MOD) % MOD
            layout = layout * nums[i] % MOD * inv_dens[i] % MOD
            pow2 = pow2 * 4 % MOD
        }

        k = k + 2 * steps
    }

    free(nums)
    free(dens)
    free(inv_dens)
    return total
}

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

function main() -> i32 {
    printf("%lld\n", amidakuji_count_mod(123456789, 987654321))
    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 mulmod_i64_i64(int64_t a0, int64_t b0);
void invert_consecutive_i64_i64_ptr_i64(int64_t start, int64_t length, int64_t* out);
void invert_list_ptr_i64_i64_ptr_i64(int64_t* vals, int64_t n, int64_t* out);
int64_t binom_mod_i64_i64(int64_t n, int64_t k);
int64_t amidakuji_count_mod_i64_i64(int64_t m, int64_t n);
int32_t main(void);

static const int64_t MOD = 1234567891;

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 mulmod_i64_i64(int64_t a0, int64_t b0) {
    int64_t a = FLOW_CHECKED_MOD((a0), (MOD));
    int64_t b = FLOW_CHECKED_MOD((b0), (MOD));
    return FLOW_CHECKED_MOD(((a * b)), (MOD));
}

void invert_consecutive_i64_i64_ptr_i64(int64_t start, int64_t length, int64_t* out) {
    if (length <= 0) {
        return;
    }
    int64_t* pref = (int64_t*)(malloc((length * 8)));
    int64_t acc = 1;
    int32_t __flow_step_1 = 1;
    for (int32_t i = 0; (0 <= length) ? i < length : i > length; i += (0 <= length) ? 1 : -1) {
        acc = FLOW_CHECKED_MOD(((acc * FLOW_CHECKED_MOD(((start + i)), (MOD)))), (MOD));
        pref[i] = acc;
    }
    int64_t inv_acc = mod_pow_i64_i64_i64(pref[(length - 1)], (MOD - 2), MOD);
    int64_t i = (length - 1);
    while (i >= 0) {
        int64_t prev = 1;
        if (i != 0) {
            prev = pref[(i - 1)];
        }
        out[i] = FLOW_CHECKED_MOD(((inv_acc * prev)), (MOD));
        inv_acc = FLOW_CHECKED_MOD(((inv_acc * FLOW_CHECKED_MOD(((start + i)), (MOD)))), (MOD));
        i = (i - 1);
    }
    free(pref);
}

void invert_list_ptr_i64_i64_ptr_i64(int64_t* vals, int64_t n, int64_t* out) {
    if (n == 0) {
        return;
    }
    int64_t* pref = (int64_t*)(malloc((n * 8)));
    int64_t acc = 1;
    int32_t __flow_step_2 = 1;
    for (int32_t i = 0; (0 <= n) ? i < n : i > n; i += (0 <= n) ? 1 : -1) {
        acc = FLOW_CHECKED_MOD(((acc * vals[i])), (MOD));
        pref[i] = acc;
    }
    int64_t inv_acc = mod_pow_i64_i64_i64(pref[(n - 1)], (MOD - 2), MOD);
    int64_t i = (n - 1);
    while (i >= 0) {
        int64_t prev = 1;
        if (i != 0) {
            prev = pref[(i - 1)];
        }
        out[i] = FLOW_CHECKED_MOD(((inv_acc * prev)), (MOD));
        inv_acc = FLOW_CHECKED_MOD(((inv_acc * vals[i])), (MOD));
        i = (i - 1);
    }
    free(pref);
}

int64_t binom_mod_i64_i64(int64_t n, int64_t k) {
    if ((k < 0 || k > n)) {
        return 0;
    }
    int64_t kk = k;
    if (kk > (n - kk)) {
        kk = (n - kk);
    }
    if (kk == 0) {
        return 1;
    }
    int64_t base = (n - kk);
    int64_t res = 1;
    int64_t start = 1;
    int64_t block = 200000;
    int64_t* invs = (int64_t*)(malloc((block * 8)));
    while (start <= kk) {
        int64_t length = block;
        if (length > ((kk - start) + 1)) {
            length = ((kk - start) + 1);
        }
        invert_consecutive_i64_i64_ptr_i64(start, length, invs);
        int64_t b = (base + start);
        int32_t __flow_step_3 = 1;
        for (int32_t i = 0; (0 <= length) ? i < length : i > length; i += (0 <= length) ? 1 : -1) {
            res = FLOW_CHECKED_MOD(((res * FLOW_CHECKED_MOD(((b + i)), (MOD)))), (MOD));
            res = FLOW_CHECKED_MOD(((res * invs[i])), (MOD));
        }
        start = (start + length);
    }
    free(invs);
    return res;
}

int64_t amidakuji_count_mod_i64_i64(int64_t m, int64_t n) {
    int64_t L = (m + n);
    if (FLOW_CHECKED_MOD((L), (2)) == 1) {
        return 0;
    }
    int64_t t = FLOW_CHECKED_DIV((L), (2));
    int64_t k = FLOW_CHECKED_MOD((m), (2));
    int64_t limit = m;
    if (n < m) {
        limit = n;
    }
    int64_t layout = 0;
    if (k == 0) {
        layout = binom_mod_i64_i64(t, FLOW_CHECKED_DIV((m), (2)));
    } else {
        layout = FLOW_CHECKED_MOD(((FLOW_CHECKED_MOD((t), (MOD)) * binom_mod_i64_i64((t - 1), FLOW_CHECKED_DIV(((m - 1)), (2))))), (MOD));
    }
    int64_t inv3 = mod_pow_i64_i64_i64(3, (MOD - 2), MOD);
    int64_t pow2 = 1;
    if (k != 0) {
        pow2 = 2;
    }
    int64_t sign = 1;
    if (k != 0) {
        sign = (MOD - 1);
    }
    int64_t total = 0;
    int64_t block = 200000;
    int64_t* nums = (int64_t*)(malloc((block * 8)));
    int64_t* dens = (int64_t*)(malloc((block * 8)));
    int64_t* inv_dens = (int64_t*)(malloc((block * 8)));
    while (k <= limit) {
        int64_t steps = block;
        int64_t avail = (FLOW_CHECKED_DIV(((limit - k)), (2)) + 1);
        if (steps > avail) {
            steps = avail;
        }
        int64_t kk = k;
        int32_t __flow_step_4 = 1;
        for (int32_t i = 0; (0 <= steps) ? i < steps : i > steps; i += (0 <= steps) ? 1 : -1) {
            nums[i] = FLOW_CHECKED_MOD(((FLOW_CHECKED_MOD(((m - kk)), (MOD)) * FLOW_CHECKED_MOD(((n - kk)), (MOD)))), (MOD));
            dens[i] = FLOW_CHECKED_MOD(((FLOW_CHECKED_MOD(((4 * (kk + 1))), (MOD)) * FLOW_CHECKED_MOD(((kk + 2)), (MOD)))), (MOD));
            kk = (kk + 2);
        }
        invert_list_ptr_i64_i64_ptr_i64(dens, steps, inv_dens);
        int32_t __flow_step_5 = 1;
        for (int32_t i = 0; (0 <= steps) ? i < steps : i > steps; i += (0 <= steps) ? 1 : -1) {
            int64_t orientations = FLOW_CHECKED_MOD(((FLOW_CHECKED_MOD(((pow2 + (2 * sign))), (MOD)) * inv3)), (MOD));
            total = FLOW_CHECKED_MOD(((total + FLOW_CHECKED_MOD(((layout * orientations)), (MOD)))), (MOD));
            layout = FLOW_CHECKED_MOD(((FLOW_CHECKED_MOD(((layout * nums[i])), (MOD)) * inv_dens[i])), (MOD));
            pow2 = FLOW_CHECKED_MOD(((pow2 * 4)), (MOD));
        }
        k = (k + (2 * steps));
    }
    free(nums);
    free(dens);
    free(inv_dens);
    return total;
}




int32_t main(void) {
    printf("%lld\n", amidakuji_count_mod_i64_i64(123456789, 987654321));
    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) : (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) : (i64, i64) -> i64
      llvm.store %115, %98 : i64, !llvm.ptr
      %118 = llvm.load %100 : !llvm.ptr -> i64
      %119 = arith.constant 2 : i32
      %121 = arith.extsi %119 : i32 to i64
      %120 = arith.divsi %118, %121 : i64
      llvm.store %120, %100 : i64, !llvm.ptr
      cf.br ^bb21
    ^bb23:
    %122 = llvm.load %95 : !llvm.ptr -> i64
    func.return %122 : i64
  }
  func.func @is_prime(%arg0: i64) -> i1 {
    %123 = arith.constant 2 : i32
    %125 = arith.extsi %123 : i32 to i64
    %124 = arith.cmpi slt, %arg0, %125 : i64
    cf.cond_br %124, ^bb27, ^bb28
    ^bb27:
      %126 = arith.constant 0 : i1
      func.return %126 : i1
    ^bb28:
      cf.br ^bb29
    ^bb29:
    %127 = arith.constant 4 : i32
    %129 = arith.extsi %127 : i32 to i64
    %128 = arith.cmpi slt, %arg0, %129 : i64
    cf.cond_br %128, ^bb30, ^bb31
    ^bb30:
      %130 = arith.constant 1 : i1
      func.return %130 : i1
    ^bb31:
      cf.br ^bb32
    ^bb32:
    %131 = arith.constant 2 : i32
    %133 = arith.extsi %131 : i32 to i64
    %132 = arith.remsi %arg0, %133 : i64
    %134 = arith.constant 0 : i32
    %136 = arith.extsi %134 : i32 to i64
    %135 = arith.cmpi eq, %132, %136 : i64
    %137 = scf.if %135 -> (i1) {
      %138 = arith.constant true
      scf.yield %138 : i1
    } else {
      %139 = arith.constant 3 : i32
      %141 = arith.extsi %139 : i32 to i64
      %140 = arith.remsi %arg0, %141 : i64
      %142 = arith.constant 0 : i32
      %144 = arith.extsi %142 : i32 to i64
      %143 = arith.cmpi eq, %140, %144 : i64
      scf.yield %143 : i1
    }
    cf.cond_br %137, ^bb33, ^bb34
    ^bb33:
      %145 = arith.constant 0 : i1
      func.return %145 : i1
    ^bb34:
      cf.br ^bb35
    ^bb35:
    %146 = arith.constant 5 : i32
    %147 = arith.extsi %146 : i32 to i64
    %148 = llvm.mlir.constant(1 : i64) : i64
    %149 = llvm.alloca %148 x i64 : (i64) -> !llvm.ptr
    llvm.store %147, %149 : i64, !llvm.ptr
    cf.br ^bb36
    ^bb36:
    %150 = llvm.load %149 : !llvm.ptr -> i64
    %151 = llvm.load %149 : !llvm.ptr -> i64
    %152 = arith.muli %150, %151 : i64
    %153 = arith.cmpi sle, %152, %arg0 : i64
    cf.cond_br %153, ^bb37, ^bb38
    ^bb37:
      %154 = llvm.load %149 : !llvm.ptr -> i64
      %155 = arith.remsi %arg0, %154 : i64
      %156 = arith.constant 0 : i32
      %158 = arith.extsi %156 : i32 to i64
      %157 = arith.cmpi eq, %155, %158 : i64
      %159 = scf.if %157 -> (i1) {
        %160 = arith.constant true
        scf.yield %160 : i1
      } else {
        %161 = llvm.load %149 : !llvm.ptr -> i64
        %162 = arith.constant 2 : i32
        %164 = arith.extsi %162 : i32 to i64
        %163 = arith.addi %161, %164 : i64
        %165 = arith.remsi %arg0, %163 : i64
        %166 = arith.constant 0 : i32
        %168 = arith.extsi %166 : i32 to i64
        %167 = arith.cmpi eq, %165, %168 : i64
        scf.yield %167 : i1
      }
      cf.cond_br %159, ^bb39, ^bb40
      ^bb39:
        %169 = arith.constant 0 : i1
        func.return %169 : i1
      ^bb40:
        cf.br ^bb41
      ^bb41:
      %170 = llvm.load %149 : !llvm.ptr -> i64
      %171 = arith.constant 6 : i32
      %173 = arith.extsi %171 : i32 to i64
      %172 = arith.addi %170, %173 : i64
      llvm.store %172, %149 : i64, !llvm.ptr
      cf.br ^bb36
    ^bb38:
    %174 = arith.constant 1 : i1
    func.return %174 : i1
  }
  // Constant: MOD
  llvm.mlir.global internal constant @MOD(1234567891 : i64) : i64
  func.func @mulmod(%arg0: i64, %arg1: i64) -> i64 {
    %175 = llvm.mlir.addressof @MOD : !llvm.ptr
    %176 = llvm.load %175 : !llvm.ptr -> i64
    %177 = arith.remsi %arg0, %176 : i64
    %178 = llvm.mlir.addressof @MOD : !llvm.ptr
    %179 = llvm.load %178 : !llvm.ptr -> i64
    %180 = arith.remsi %arg1, %179 : i64
    %181 = arith.muli %177, %180 : i64
    %182 = llvm.mlir.addressof @MOD : !llvm.ptr
    %183 = llvm.load %182 : !llvm.ptr -> i64
    %184 = arith.remsi %181, %183 : i64
    func.return %184 : i64
  }
  func.func @invert_consecutive(%arg0: i64, %arg1: i64, %arg2: !llvm.ptr) -> () {
    %185 = arith.constant 0 : i32
    %187 = arith.extsi %185 : i32 to i64
    %186 = arith.cmpi sle, %arg1, %187 : i64
    cf.cond_br %186, ^bb42, ^bb43
    ^bb42:
      func.return
    ^bb43:
      cf.br ^bb44
    ^bb44:
    %189 = arith.constant 8 : i32
    %191 = arith.extsi %189 : i32 to i64
    %190 = arith.muli %arg1, %191 : i64
    %188 = func.call @malloc(%190) : (i64) -> !llvm.ptr
    %192 = arith.constant 1 : i32
    %193 = arith.extsi %192 : i32 to i64
    %194 = llvm.mlir.constant(1 : i64) : i64
    %195 = llvm.alloca %194 x i64 : (i64) -> !llvm.ptr
    llvm.store %193, %195 : i64, !llvm.ptr
    %196 = arith.constant 0 : i32
    %197 = arith.index_cast %196 : i32 to index
    %198 = arith.index_cast %arg1 : i32 to index
    %200 = arith.constant 1 : index
    %201 = arith.constant -1 : index
    %202 = arith.cmpi sle, %197, %198 : index
    %199 = arith.select %202, %200, %201 : index
    cf.br ^bb45(%197 : index)
    ^bb45(%203: index):
    %204 = arith.cmpi slt, %203, %198 : index
    %205 = arith.cmpi sgt, %203, %198 : index
    %206 = arith.select %202, %204, %205 : i1
    cf.cond_br %206, ^bb46(%203 : index), ^bb47(%203 : index)
    ^bb46(%207: index):
      %208 = llvm.load %195 : !llvm.ptr -> i64
      %210 = arith.trunci %arg0 : i64 to i32
      %211 = arith.index_cast %207 : index to i32
      %209 = arith.addi %210, %211 : i32
      %212 = llvm.mlir.addressof @MOD : !llvm.ptr
      %213 = llvm.load %212 : !llvm.ptr -> i64
      %215 = arith.extsi %209 : i32 to i64
      %214 = arith.remsi %215, %213 : i64
      %216 = arith.muli %208, %214 : i64
      %217 = llvm.mlir.addressof @MOD : !llvm.ptr
      %218 = llvm.load %217 : !llvm.ptr -> i64
      %219 = arith.remsi %216, %218 : i64
      llvm.store %219, %195 : i64, !llvm.ptr
      %220 = llvm.load %195 : !llvm.ptr -> i64
      %221 = arith.index_cast %207 : index to i64
      %222 = llvm.getelementptr %188[%221] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %220, %222 : i64, !llvm.ptr
      %223 = arith.addi %207, %199 : index
      cf.br ^bb45(%223 : index)
    ^bb47(%224: index):
    %227 = arith.constant 1 : i32
    %229 = arith.extsi %227 : i32 to i64
    %228 = arith.subi %arg1, %229 : i64
    %230 = llvm.getelementptr %188[%228] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    %226 = llvm.load %230 : !llvm.ptr -> i64
    %231 = llvm.mlir.addressof @MOD : !llvm.ptr
    %232 = llvm.load %231 : !llvm.ptr -> i64
    %233 = arith.constant 2 : i32
    %235 = arith.extsi %233 : i32 to i64
    %234 = arith.subi %232, %235 : i64
    %236 = llvm.mlir.addressof @MOD : !llvm.ptr
    %237 = llvm.load %236 : !llvm.ptr -> i64
    %225 = func.call @mod_pow(%226, %234, %237) : (i64, i64, i64) -> i64
    %238 = llvm.mlir.constant(1 : i64) : i64
    %239 = llvm.alloca %238 x i64 : (i64) -> !llvm.ptr
    llvm.store %225, %239 : i64, !llvm.ptr
    %240 = arith.constant 1 : i32
    %242 = arith.extsi %240 : i32 to i64
    %241 = arith.subi %arg1, %242 : i64
    %243 = llvm.mlir.constant(1 : i64) : i64
    %244 = llvm.alloca %243 x i64 : (i64) -> !llvm.ptr
    llvm.store %241, %244 : i64, !llvm.ptr
    cf.br ^bb48
    ^bb48:
    %245 = llvm.load %244 : !llvm.ptr -> i64
    %246 = arith.constant 0 : i32
    %248 = arith.extsi %246 : i32 to i64
    %247 = arith.cmpi sge, %245, %248 : i64
    cf.cond_br %247, ^bb49, ^bb50
    ^bb49:
      %249 = arith.constant 1 : i32
      %250 = arith.extsi %249 : i32 to i64
      %251 = llvm.load %244 : !llvm.ptr -> i64
      %252 = arith.constant 0 : i32
      %254 = arith.extsi %252 : i32 to i64
      %253 = arith.cmpi ne, %251, %254 : i64
      %255 = scf.if %253 -> (i64) {
        %257 = llvm.load %244 : !llvm.ptr -> i64
        %258 = arith.constant 1 : i32
        %260 = arith.extsi %258 : i32 to i64
        %259 = arith.subi %257, %260 : i64
        %261 = llvm.getelementptr %188[%259] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %256 = llvm.load %261 : !llvm.ptr -> i64
        scf.yield %256 : i64
      } else {
        scf.yield %250 : i64
      }
      %262 = llvm.load %239 : !llvm.ptr -> i64
      %263 = arith.muli %262, %255 : i64
      %264 = llvm.mlir.addressof @MOD : !llvm.ptr
      %265 = llvm.load %264 : !llvm.ptr -> i64
      %266 = arith.remsi %263, %265 : i64
      %267 = llvm.load %244 : !llvm.ptr -> i64
      %268 = llvm.getelementptr %arg2[%267] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %266, %268 : i64, !llvm.ptr
      %269 = llvm.load %239 : !llvm.ptr -> i64
      %270 = llvm.load %244 : !llvm.ptr -> i64
      %271 = arith.addi %arg0, %270 : i64
      %272 = llvm.mlir.addressof @MOD : !llvm.ptr
      %273 = llvm.load %272 : !llvm.ptr -> i64
      %274 = arith.remsi %271, %273 : i64
      %275 = arith.muli %269, %274 : i64
      %276 = llvm.mlir.addressof @MOD : !llvm.ptr
      %277 = llvm.load %276 : !llvm.ptr -> i64
      %278 = arith.remsi %275, %277 : i64
      llvm.store %278, %239 : i64, !llvm.ptr
      %279 = llvm.load %244 : !llvm.ptr -> i64
      %280 = arith.constant 1 : i32
      %282 = arith.extsi %280 : i32 to i64
      %281 = arith.subi %279, %282 : i64
      llvm.store %281, %244 : i64, !llvm.ptr
      cf.br ^bb48
    ^bb50:
    func.call @free(%188) : (!llvm.ptr) -> ()
    func.return
  }
  func.func @invert_list(%arg0: !llvm.ptr, %arg1: i64, %arg2: !llvm.ptr) -> () {
    %284 = arith.constant 0 : i32
    %286 = arith.extsi %284 : i32 to i64
    %285 = arith.cmpi eq, %arg1, %286 : i64
    cf.cond_br %285, ^bb51, ^bb52
    ^bb51:
      func.return
    ^bb52:
      cf.br ^bb53
    ^bb53:
    %288 = arith.constant 8 : i32
    %290 = arith.extsi %288 : i32 to i64
    %289 = arith.muli %arg1, %290 : i64
    %287 = func.call @malloc(%289) : (i64) -> !llvm.ptr
    %291 = arith.constant 1 : i32
    %292 = arith.extsi %291 : i32 to i64
    %293 = llvm.mlir.constant(1 : i64) : i64
    %294 = llvm.alloca %293 x i64 : (i64) -> !llvm.ptr
    llvm.store %292, %294 : i64, !llvm.ptr
    %295 = arith.constant 0 : i32
    %296 = arith.index_cast %295 : i32 to index
    %297 = arith.index_cast %arg1 : i32 to index
    %299 = arith.constant 1 : index
    %300 = arith.constant -1 : index
    %301 = arith.cmpi sle, %296, %297 : index
    %298 = arith.select %301, %299, %300 : index
    cf.br ^bb54(%296 : index)
    ^bb54(%302: index):
    %303 = arith.cmpi slt, %302, %297 : index
    %304 = arith.cmpi sgt, %302, %297 : index
    %305 = arith.select %301, %303, %304 : i1
    cf.cond_br %305, ^bb55(%302 : index), ^bb56(%302 : index)
    ^bb55(%306: index):
      %307 = llvm.load %294 : !llvm.ptr -> i64
      %309 = arith.index_cast %306 : index to i64
      %310 = llvm.getelementptr %arg0[%309] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %308 = llvm.load %310 : !llvm.ptr -> i64
      %311 = arith.muli %307, %308 : i64
      %312 = llvm.mlir.addressof @MOD : !llvm.ptr
      %313 = llvm.load %312 : !llvm.ptr -> i64
      %314 = arith.remsi %311, %313 : i64
      llvm.store %314, %294 : i64, !llvm.ptr
      %315 = llvm.load %294 : !llvm.ptr -> i64
      %316 = arith.index_cast %306 : index to i64
      %317 = llvm.getelementptr %287[%316] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %315, %317 : i64, !llvm.ptr
      %318 = arith.addi %306, %298 : index
      cf.br ^bb54(%318 : index)
    ^bb56(%319: index):
    %322 = arith.constant 1 : i32
    %324 = arith.extsi %322 : i32 to i64
    %323 = arith.subi %arg1, %324 : i64
    %325 = llvm.getelementptr %287[%323] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    %321 = llvm.load %325 : !llvm.ptr -> i64
    %326 = llvm.mlir.addressof @MOD : !llvm.ptr
    %327 = llvm.load %326 : !llvm.ptr -> i64
    %328 = arith.constant 2 : i32
    %330 = arith.extsi %328 : i32 to i64
    %329 = arith.subi %327, %330 : i64
    %331 = llvm.mlir.addressof @MOD : !llvm.ptr
    %332 = llvm.load %331 : !llvm.ptr -> i64
    %320 = func.call @mod_pow(%321, %329, %332) : (i64, i64, i64) -> i64
    %333 = llvm.mlir.constant(1 : i64) : i64
    %334 = llvm.alloca %333 x i64 : (i64) -> !llvm.ptr
    llvm.store %320, %334 : i64, !llvm.ptr
    %335 = arith.constant 1 : i32
    %337 = arith.extsi %335 : i32 to i64
    %336 = arith.subi %arg1, %337 : i64
    %338 = llvm.mlir.constant(1 : i64) : i64
    %339 = llvm.alloca %338 x i64 : (i64) -> !llvm.ptr
    llvm.store %336, %339 : i64, !llvm.ptr
    cf.br ^bb57
    ^bb57:
    %340 = llvm.load %339 : !llvm.ptr -> i64
    %341 = arith.constant 0 : i32
    %343 = arith.extsi %341 : i32 to i64
    %342 = arith.cmpi sge, %340, %343 : i64
    cf.cond_br %342, ^bb58, ^bb59
    ^bb58:
      %344 = arith.constant 1 : i32
      %345 = arith.extsi %344 : i32 to i64
      %346 = llvm.load %339 : !llvm.ptr -> i64
      %347 = arith.constant 0 : i32
      %349 = arith.extsi %347 : i32 to i64
      %348 = arith.cmpi ne, %346, %349 : i64
      %350 = scf.if %348 -> (i64) {
        %352 = llvm.load %339 : !llvm.ptr -> i64
        %353 = arith.constant 1 : i32
        %355 = arith.extsi %353 : i32 to i64
        %354 = arith.subi %352, %355 : i64
        %356 = llvm.getelementptr %287[%354] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %351 = llvm.load %356 : !llvm.ptr -> i64
        scf.yield %351 : i64
      } else {
        scf.yield %345 : i64
      }
      %357 = llvm.load %334 : !llvm.ptr -> i64
      %358 = arith.muli %357, %350 : i64
      %359 = llvm.mlir.addressof @MOD : !llvm.ptr
      %360 = llvm.load %359 : !llvm.ptr -> i64
      %361 = arith.remsi %358, %360 : i64
      %362 = llvm.load %339 : !llvm.ptr -> i64
      %363 = llvm.getelementptr %arg2[%362] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %361, %363 : i64, !llvm.ptr
      %364 = llvm.load %334 : !llvm.ptr -> i64
      %366 = llvm.load %339 : !llvm.ptr -> i64
      %367 = llvm.getelementptr %arg0[%366] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %365 = llvm.load %367 : !llvm.ptr -> i64
      %368 = arith.muli %364, %365 : i64
      %369 = llvm.mlir.addressof @MOD : !llvm.ptr
      %370 = llvm.load %369 : !llvm.ptr -> i64
      %371 = arith.remsi %368, %370 : i64
      llvm.store %371, %334 : i64, !llvm.ptr
      %372 = llvm.load %339 : !llvm.ptr -> i64
      %373 = arith.constant 1 : i32
      %375 = arith.extsi %373 : i32 to i64
      %374 = arith.subi %372, %375 : i64
      llvm.store %374, %339 : i64, !llvm.ptr
      cf.br ^bb57
    ^bb59:
    func.call @free(%287) : (!llvm.ptr) -> ()
    func.return
  }
  func.func @binom_mod(%arg0: i64, %arg1: i64) -> i64 {
    %377 = arith.constant 0 : i32
    %379 = arith.extsi %377 : i32 to i64
    %378 = arith.cmpi slt, %arg1, %379 : i64
    %380 = scf.if %378 -> (i1) {
      %381 = arith.constant true
      scf.yield %381 : i1
    } else {
      %382 = arith.cmpi sgt, %arg1, %arg0 : i64
      scf.yield %382 : i1
    }
    cf.cond_br %380, ^bb60, ^bb61
    ^bb60:
      %383 = arith.constant 0 : i32
      %384 = arith.extsi %383 : i32 to i64
      func.return %384 : i64
    ^bb61:
      cf.br ^bb62
    ^bb62:
    %385 = llvm.mlir.constant(1 : i64) : i64
    %386 = llvm.alloca %385 x i64 : (i64) -> !llvm.ptr
    llvm.store %arg1, %386 : i64, !llvm.ptr
    %387 = llvm.load %386 : !llvm.ptr -> i64
    %388 = llvm.load %386 : !llvm.ptr -> i64
    %389 = arith.subi %arg0, %388 : i64
    %390 = arith.cmpi sgt, %387, %389 : i64
    cf.cond_br %390, ^bb63, ^bb64
    ^bb63:
      %391 = llvm.load %386 : !llvm.ptr -> i64
      %392 = arith.subi %arg0, %391 : i64
      llvm.store %392, %386 : i64, !llvm.ptr
      cf.br ^bb65
    ^bb64:
      cf.br ^bb65
    ^bb65:
    %393 = llvm.load %386 : !llvm.ptr -> i64
    %394 = arith.constant 0 : i32
    %396 = arith.extsi %394 : i32 to i64
    %395 = arith.cmpi eq, %393, %396 : i64
    cf.cond_br %395, ^bb66, ^bb67
    ^bb66:
      %397 = arith.constant 1 : i32
      %398 = arith.extsi %397 : i32 to i64
      func.return %398 : i64
    ^bb67:
      cf.br ^bb68
    ^bb68:
    %399 = llvm.load %386 : !llvm.ptr -> i64
    %400 = arith.subi %arg0, %399 : i64
    %401 = arith.constant 1 : i32
    %402 = arith.extsi %401 : i32 to i64
    %403 = llvm.mlir.constant(1 : i64) : i64
    %404 = llvm.alloca %403 x i64 : (i64) -> !llvm.ptr
    llvm.store %402, %404 : i64, !llvm.ptr
    %405 = arith.constant 1 : i32
    %406 = arith.extsi %405 : i32 to i64
    %407 = llvm.mlir.constant(1 : i64) : i64
    %408 = llvm.alloca %407 x i64 : (i64) -> !llvm.ptr
    llvm.store %406, %408 : i64, !llvm.ptr
    %409 = arith.constant 200000 : i32
    %410 = arith.extsi %409 : i32 to i64
    %412 = arith.constant 8 : i32
    %414 = arith.extsi %412 : i32 to i64
    %413 = arith.muli %410, %414 : i64
    %411 = func.call @malloc(%413) : (i64) -> !llvm.ptr
    cf.br ^bb69
    ^bb69:
    %415 = llvm.load %408 : !llvm.ptr -> i64
    %416 = llvm.load %386 : !llvm.ptr -> i64
    %417 = arith.cmpi sle, %415, %416 : i64
    cf.cond_br %417, ^bb70, ^bb71
    ^bb70:
      %418 = llvm.mlir.constant(1 : i64) : i64
      %419 = llvm.alloca %418 x i64 : (i64) -> !llvm.ptr
      llvm.store %410, %419 : i64, !llvm.ptr
      %420 = llvm.load %419 : !llvm.ptr -> i64
      %421 = llvm.load %386 : !llvm.ptr -> i64
      %422 = llvm.load %408 : !llvm.ptr -> i64
      %423 = arith.subi %421, %422 : i64
      %424 = arith.constant 1 : i32
      %426 = arith.extsi %424 : i32 to i64
      %425 = arith.addi %423, %426 : i64
      %427 = arith.cmpi sgt, %420, %425 : i64
      cf.cond_br %427, ^bb72, ^bb73
      ^bb72:
        %428 = llvm.load %386 : !llvm.ptr -> i64
        %429 = llvm.load %408 : !llvm.ptr -> i64
        %430 = arith.subi %428, %429 : i64
        %431 = arith.constant 1 : i32
        %433 = arith.extsi %431 : i32 to i64
        %432 = arith.addi %430, %433 : i64
        llvm.store %432, %419 : i64, !llvm.ptr
        cf.br ^bb74
      ^bb73:
        cf.br ^bb74
      ^bb74:
      %435 = llvm.load %408 : !llvm.ptr -> i64
      %436 = llvm.load %419 : !llvm.ptr -> i64
      func.call @invert_consecutive(%435, %436, %411) : (i64, i64, !llvm.ptr) -> ()
      %437 = llvm.load %408 : !llvm.ptr -> i64
      %438 = arith.addi %400, %437 : i64
      %439 = arith.constant 0 : i32
      %440 = llvm.load %419 : !llvm.ptr -> i64
      %441 = arith.index_cast %439 : i32 to index
      %442 = arith.index_cast %440 : i32 to index
      %444 = arith.constant 1 : index
      %445 = arith.constant -1 : index
      %446 = arith.cmpi sle, %441, %442 : index
      %443 = arith.select %446, %444, %445 : index
      cf.br ^bb75(%441 : index)
      ^bb75(%447: index):
      %448 = arith.cmpi slt, %447, %442 : index
      %449 = arith.cmpi sgt, %447, %442 : index
      %450 = arith.select %446, %448, %449 : i1
      cf.cond_br %450, ^bb76(%447 : index), ^bb77(%447 : index)
      ^bb76(%451: index):
        %452 = llvm.load %404 : !llvm.ptr -> i64
        %454 = arith.trunci %438 : i64 to i32
        %455 = arith.index_cast %451 : index to i32
        %453 = arith.addi %454, %455 : i32
        %456 = llvm.mlir.addressof @MOD : !llvm.ptr
        %457 = llvm.load %456 : !llvm.ptr -> i64
        %459 = arith.extsi %453 : i32 to i64
        %458 = arith.remsi %459, %457 : i64
        %460 = arith.muli %452, %458 : i64
        %461 = llvm.mlir.addressof @MOD : !llvm.ptr
        %462 = llvm.load %461 : !llvm.ptr -> i64
        %463 = arith.remsi %460, %462 : i64
        llvm.store %463, %404 : i64, !llvm.ptr
        %464 = llvm.load %404 : !llvm.ptr -> i64
        %466 = arith.index_cast %451 : index to i64
        %467 = llvm.getelementptr %411[%466] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %465 = llvm.load %467 : !llvm.ptr -> i64
        %468 = arith.muli %464, %465 : i64
        %469 = llvm.mlir.addressof @MOD : !llvm.ptr
        %470 = llvm.load %469 : !llvm.ptr -> i64
        %471 = arith.remsi %468, %470 : i64
        llvm.store %471, %404 : i64, !llvm.ptr
        %472 = arith.addi %451, %443 : index
        cf.br ^bb75(%472 : index)
      ^bb77(%473: index):
      %474 = llvm.load %408 : !llvm.ptr -> i64
      %475 = llvm.load %419 : !llvm.ptr -> i64
      %476 = arith.addi %474, %475 : i64
      llvm.store %476, %408 : i64, !llvm.ptr
      cf.br ^bb69
    ^bb71:
    func.call @free(%411) : (!llvm.ptr) -> ()
    %478 = llvm.load %404 : !llvm.ptr -> i64
    func.return %478 : i64
  }
  func.func @amidakuji_count_mod(%arg0: i64, %arg1: i64) -> i64 {
    %479 = arith.addi %arg0, %arg1 : i64
    %480 = arith.constant 2 : i32
    %482 = arith.extsi %480 : i32 to i64
    %481 = arith.remsi %479, %482 : i64
    %483 = arith.constant 1 : i32
    %485 = arith.extsi %483 : i32 to i64
    %484 = arith.cmpi eq, %481, %485 : i64
    cf.cond_br %484, ^bb78, ^bb79
    ^bb78:
      %486 = arith.constant 0 : i32
      %487 = arith.extsi %486 : i32 to i64
      func.return %487 : i64
    ^bb79:
      cf.br ^bb80
    ^bb80:
    %488 = arith.constant 2 : i32
    %490 = arith.extsi %488 : i32 to i64
    %489 = arith.divsi %479, %490 : i64
    %491 = arith.constant 2 : i32
    %493 = arith.extsi %491 : i32 to i64
    %492 = arith.remsi %arg0, %493 : i64
    %494 = llvm.mlir.constant(1 : i64) : i64
    %495 = llvm.alloca %494 x i64 : (i64) -> !llvm.ptr
    llvm.store %492, %495 : i64, !llvm.ptr
    %496 = arith.cmpi slt, %arg1, %arg0 : i64
    %497 = scf.if %496 -> (i64) {
      scf.yield %arg1 : i64
    } else {
      scf.yield %arg0 : i64
    }
    %498 = arith.constant 0 : i32
    %499 = arith.extsi %498 : i32 to i64
    %500 = llvm.mlir.constant(1 : i64) : i64
    %501 = llvm.alloca %500 x i64 : (i64) -> !llvm.ptr
    llvm.store %499, %501 : i64, !llvm.ptr
    %502 = llvm.load %495 : !llvm.ptr -> i64
    %503 = arith.constant 0 : i32
    %505 = arith.extsi %503 : i32 to i64
    %504 = arith.cmpi eq, %502, %505 : i64
    cf.cond_br %504, ^bb81, ^bb82
    ^bb81:
      %507 = arith.constant 2 : i32
      %509 = arith.extsi %507 : i32 to i64
      %508 = arith.divsi %arg0, %509 : i64
      %506 = func.call @binom_mod(%489, %508) : (i64, i64) -> i64
      llvm.store %506, %501 : i64, !llvm.ptr
      cf.br ^bb83
    ^bb82:
      %510 = llvm.mlir.addressof @MOD : !llvm.ptr
      %511 = llvm.load %510 : !llvm.ptr -> i64
      %512 = arith.remsi %489, %511 : i64
      %514 = arith.constant 1 : i32
      %516 = arith.extsi %514 : i32 to i64
      %515 = arith.subi %489, %516 : i64
      %517 = arith.constant 1 : i32
      %519 = arith.extsi %517 : i32 to i64
      %518 = arith.subi %arg0, %519 : i64
      %520 = arith.constant 2 : i32
      %522 = arith.extsi %520 : i32 to i64
      %521 = arith.divsi %518, %522 : i64
      %513 = func.call @binom_mod(%515, %521) : (i64, i64) -> i64
      %523 = arith.muli %512, %513 : i64
      %524 = llvm.mlir.addressof @MOD : !llvm.ptr
      %525 = llvm.load %524 : !llvm.ptr -> i64
      %526 = arith.remsi %523, %525 : i64
      llvm.store %526, %501 : i64, !llvm.ptr
      cf.br ^bb83
    ^bb83:
    %528 = arith.constant 3 : i32
    %529 = llvm.mlir.addressof @MOD : !llvm.ptr
    %530 = llvm.load %529 : !llvm.ptr -> i64
    %531 = arith.constant 2 : i32
    %533 = arith.extsi %531 : i32 to i64
    %532 = arith.subi %530, %533 : i64
    %534 = llvm.mlir.addressof @MOD : !llvm.ptr
    %535 = llvm.load %534 : !llvm.ptr -> i64
    %536 = arith.extsi %528 : i32 to i64
    %527 = func.call @mod_pow(%536, %532, %535) : (i64, i64, i64) -> i64
    %537 = arith.constant 1 : i32
    %538 = arith.extsi %537 : i32 to i64
    %539 = llvm.mlir.constant(1 : i64) : i64
    %540 = llvm.alloca %539 x i64 : (i64) -> !llvm.ptr
    llvm.store %538, %540 : i64, !llvm.ptr
    %541 = llvm.load %495 : !llvm.ptr -> i64
    %542 = arith.constant 0 : i32
    %544 = arith.extsi %542 : i32 to i64
    %543 = arith.cmpi ne, %541, %544 : i64
    cf.cond_br %543, ^bb84, ^bb85
    ^bb84:
      %545 = arith.constant 2 : i32
      %546 = arith.extsi %545 : i32 to i64
      llvm.store %546, %540 : i64, !llvm.ptr
      cf.br ^bb86
    ^bb85:
      cf.br ^bb86
    ^bb86:
    %547 = arith.constant 1 : i32
    %548 = arith.extsi %547 : i32 to i64
    %549 = llvm.mlir.constant(1 : i64) : i64
    %550 = llvm.alloca %549 x i64 : (i64) -> !llvm.ptr
    llvm.store %548, %550 : i64, !llvm.ptr
    %551 = llvm.load %495 : !llvm.ptr -> i64
    %552 = arith.constant 0 : i32
    %554 = arith.extsi %552 : i32 to i64
    %553 = arith.cmpi ne, %551, %554 : i64
    cf.cond_br %553, ^bb87, ^bb88
    ^bb87:
      %555 = llvm.mlir.addressof @MOD : !llvm.ptr
      %556 = llvm.load %555 : !llvm.ptr -> i64
      %557 = arith.constant 1 : i32
      %559 = arith.extsi %557 : i32 to i64
      %558 = arith.subi %556, %559 : i64
      llvm.store %558, %550 : i64, !llvm.ptr
      cf.br ^bb89
    ^bb88:
      cf.br ^bb89
    ^bb89:
    %560 = arith.constant 0 : i32
    %561 = arith.extsi %560 : i32 to i64
    %562 = llvm.mlir.constant(1 : i64) : i64
    %563 = llvm.alloca %562 x i64 : (i64) -> !llvm.ptr
    llvm.store %561, %563 : i64, !llvm.ptr
    %564 = arith.constant 200000 : i32
    %565 = arith.extsi %564 : i32 to i64
    %567 = arith.constant 8 : i32
    %569 = arith.extsi %567 : i32 to i64
    %568 = arith.muli %565, %569 : i64
    %566 = func.call @malloc(%568) : (i64) -> !llvm.ptr
    %571 = arith.constant 8 : i32
    %573 = arith.extsi %571 : i32 to i64
    %572 = arith.muli %565, %573 : i64
    %570 = func.call @malloc(%572) : (i64) -> !llvm.ptr
    %575 = arith.constant 8 : i32
    %577 = arith.extsi %575 : i32 to i64
    %576 = arith.muli %565, %577 : i64
    %574 = func.call @malloc(%576) : (i64) -> !llvm.ptr
    cf.br ^bb90
    ^bb90:
    %578 = llvm.load %495 : !llvm.ptr -> i64
    %579 = arith.cmpi sle, %578, %497 : i64
    cf.cond_br %579, ^bb91, ^bb92
    ^bb91:
      %580 = llvm.mlir.constant(1 : i64) : i64
      %581 = llvm.alloca %580 x i64 : (i64) -> !llvm.ptr
      llvm.store %565, %581 : i64, !llvm.ptr
      %582 = llvm.load %495 : !llvm.ptr -> i64
      %583 = arith.subi %497, %582 : i64
      %584 = arith.constant 2 : i32
      %586 = arith.extsi %584 : i32 to i64
      %585 = arith.divsi %583, %586 : i64
      %587 = arith.constant 1 : i32
      %589 = arith.extsi %587 : i32 to i64
      %588 = arith.addi %585, %589 : i64
      %590 = llvm.load %581 : !llvm.ptr -> i64
      %591 = arith.cmpi sgt, %590, %588 : i64
      cf.cond_br %591, ^bb93, ^bb94
      ^bb93:
        llvm.store %588, %581 : i64, !llvm.ptr
        cf.br ^bb95
      ^bb94:
        cf.br ^bb95
      ^bb95:
      %592 = llvm.load %495 : !llvm.ptr -> i64
      %593 = llvm.mlir.constant(1 : i64) : i64
      %594 = llvm.alloca %593 x i64 : (i64) -> !llvm.ptr
      llvm.store %592, %594 : i64, !llvm.ptr
      %595 = arith.constant 0 : i32
      %596 = llvm.load %581 : !llvm.ptr -> i64
      %597 = arith.index_cast %595 : i32 to index
      %598 = arith.index_cast %596 : i32 to index
      %600 = arith.constant 1 : index
      %601 = arith.constant -1 : index
      %602 = arith.cmpi sle, %597, %598 : index
      %599 = arith.select %602, %600, %601 : index
      cf.br ^bb96(%597 : index)
      ^bb96(%603: index):
      %604 = arith.cmpi slt, %603, %598 : index
      %605 = arith.cmpi sgt, %603, %598 : index
      %606 = arith.select %602, %604, %605 : i1
      cf.cond_br %606, ^bb97(%603 : index), ^bb98(%603 : index)
      ^bb97(%607: index):
        %608 = llvm.load %594 : !llvm.ptr -> i64
        %609 = arith.subi %arg0, %608 : i64
        %610 = llvm.mlir.addressof @MOD : !llvm.ptr
        %611 = llvm.load %610 : !llvm.ptr -> i64
        %612 = arith.remsi %609, %611 : i64
        %613 = llvm.load %594 : !llvm.ptr -> i64
        %614 = arith.subi %arg1, %613 : i64
        %615 = llvm.mlir.addressof @MOD : !llvm.ptr
        %616 = llvm.load %615 : !llvm.ptr -> i64
        %617 = arith.remsi %614, %616 : i64
        %618 = arith.muli %612, %617 : i64
        %619 = llvm.mlir.addressof @MOD : !llvm.ptr
        %620 = llvm.load %619 : !llvm.ptr -> i64
        %621 = arith.remsi %618, %620 : i64
        %622 = arith.index_cast %607 : index to i64
        %623 = llvm.getelementptr %566[%622] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        llvm.store %621, %623 : i64, !llvm.ptr
        %624 = arith.constant 4 : i32
        %625 = llvm.load %594 : !llvm.ptr -> i64
        %626 = arith.constant 1 : i32
        %628 = arith.extsi %626 : i32 to i64
        %627 = arith.addi %625, %628 : i64
        %630 = arith.extsi %624 : i32 to i64
        %629 = arith.muli %630, %627 : i64
        %631 = llvm.mlir.addressof @MOD : !llvm.ptr
        %632 = llvm.load %631 : !llvm.ptr -> i64
        %633 = arith.remsi %629, %632 : i64
        %634 = llvm.load %594 : !llvm.ptr -> i64
        %635 = arith.constant 2 : i32
        %637 = arith.extsi %635 : i32 to i64
        %636 = arith.addi %634, %637 : i64
        %638 = llvm.mlir.addressof @MOD : !llvm.ptr
        %639 = llvm.load %638 : !llvm.ptr -> i64
        %640 = arith.remsi %636, %639 : i64
        %641 = arith.muli %633, %640 : i64
        %642 = llvm.mlir.addressof @MOD : !llvm.ptr
        %643 = llvm.load %642 : !llvm.ptr -> i64
        %644 = arith.remsi %641, %643 : i64
        %645 = arith.index_cast %607 : index to i64
        %646 = llvm.getelementptr %570[%645] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        llvm.store %644, %646 : i64, !llvm.ptr
        %647 = llvm.load %594 : !llvm.ptr -> i64
        %648 = arith.constant 2 : i32
        %650 = arith.extsi %648 : i32 to i64
        %649 = arith.addi %647, %650 : i64
        llvm.store %649, %594 : i64, !llvm.ptr
        %651 = arith.addi %607, %599 : index
        cf.br ^bb96(%651 : index)
      ^bb98(%652: index):
      %654 = llvm.load %581 : !llvm.ptr -> i64
      func.call @invert_list(%570, %654, %574) : (!llvm.ptr, i64, !llvm.ptr) -> ()
      %655 = arith.constant 0 : i32
      %656 = llvm.load %581 : !llvm.ptr -> i64
      %657 = arith.index_cast %655 : i32 to index
      %658 = arith.index_cast %656 : i32 to index
      %660 = arith.constant 1 : index
      %661 = arith.constant -1 : index
      %662 = arith.cmpi sle, %657, %658 : index
      %659 = arith.select %662, %660, %661 : index
      cf.br ^bb99(%657 : index)
      ^bb99(%663: index):
      %664 = arith.cmpi slt, %663, %658 : index
      %665 = arith.cmpi sgt, %663, %658 : index
      %666 = arith.select %662, %664, %665 : i1
      cf.cond_br %666, ^bb100(%663 : index), ^bb101(%663 : index)
      ^bb100(%667: index):
        %668 = llvm.load %540 : !llvm.ptr -> i64
        %669 = arith.constant 2 : i32
        %670 = llvm.load %550 : !llvm.ptr -> i64
        %672 = arith.extsi %669 : i32 to i64
        %671 = arith.muli %672, %670 : i64
        %673 = arith.addi %668, %671 : i64
        %674 = llvm.mlir.addressof @MOD : !llvm.ptr
        %675 = llvm.load %674 : !llvm.ptr -> i64
        %676 = arith.remsi %673, %675 : i64
        %677 = arith.muli %676, %527 : i64
        %678 = llvm.mlir.addressof @MOD : !llvm.ptr
        %679 = llvm.load %678 : !llvm.ptr -> i64
        %680 = arith.remsi %677, %679 : i64
        %681 = llvm.load %563 : !llvm.ptr -> i64
        %682 = llvm.load %501 : !llvm.ptr -> i64
        %683 = arith.muli %682, %680 : i64
        %684 = llvm.mlir.addressof @MOD : !llvm.ptr
        %685 = llvm.load %684 : !llvm.ptr -> i64
        %686 = arith.remsi %683, %685 : i64
        %687 = arith.addi %681, %686 : i64
        %688 = llvm.mlir.addressof @MOD : !llvm.ptr
        %689 = llvm.load %688 : !llvm.ptr -> i64
        %690 = arith.remsi %687, %689 : i64
        llvm.store %690, %563 : i64, !llvm.ptr
        %691 = llvm.load %501 : !llvm.ptr -> i64
        %693 = arith.index_cast %667 : index to i64
        %694 = llvm.getelementptr %566[%693] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %692 = llvm.load %694 : !llvm.ptr -> i64
        %695 = arith.muli %691, %692 : i64
        %696 = llvm.mlir.addressof @MOD : !llvm.ptr
        %697 = llvm.load %696 : !llvm.ptr -> i64
        %698 = arith.remsi %695, %697 : i64
        %700 = arith.index_cast %667 : index to i64
        %701 = llvm.getelementptr %574[%700] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %699 = llvm.load %701 : !llvm.ptr -> i64
        %702 = arith.muli %698, %699 : i64
        %703 = llvm.mlir.addressof @MOD : !llvm.ptr
        %704 = llvm.load %703 : !llvm.ptr -> i64
        %705 = arith.remsi %702, %704 : i64
        llvm.store %705, %501 : i64, !llvm.ptr
        %706 = llvm.load %540 : !llvm.ptr -> i64
        %707 = arith.constant 4 : i32
        %709 = arith.extsi %707 : i32 to i64
        %708 = arith.muli %706, %709 : i64
        %710 = llvm.mlir.addressof @MOD : !llvm.ptr
        %711 = llvm.load %710 : !llvm.ptr -> i64
        %712 = arith.remsi %708, %711 : i64
        llvm.store %712, %540 : i64, !llvm.ptr
        %713 = arith.addi %667, %659 : index
        cf.br ^bb99(%713 : index)
      ^bb101(%714: index):
      %715 = llvm.load %495 : !llvm.ptr -> i64
      %716 = arith.constant 2 : i32
      %717 = llvm.load %581 : !llvm.ptr -> i64
      %719 = arith.extsi %716 : i32 to i64
      %718 = arith.muli %719, %717 : i64
      %720 = arith.addi %715, %718 : i64
      llvm.store %720, %495 : i64, !llvm.ptr
      cf.br ^bb90
    ^bb92:
    func.call @free(%566) : (!llvm.ptr) -> ()
    func.call @free(%570) : (!llvm.ptr) -> ()
    func.call @free(%574) : (!llvm.ptr) -> ()
    %724 = llvm.load %563 : !llvm.ptr -> i64
    func.return %724 : i64
  }
  func.func private @calloc(i64, i64) -> !llvm.ptr
  func.func private @free(!llvm.ptr) -> ()
  func.func private @malloc(i64) -> !llvm.ptr
  func.func @main() -> i32 {
    %725 = llvm.mlir.addressof @str_0 : !llvm.ptr
    %727 = arith.constant 123456789 : i32
    %728 = arith.constant 987654321 : i32
    %729 = arith.extsi %727 : i32 to i64
    %730 = arith.extsi %728 : i32 to i64
    %726 = func.call @amidakuji_count_mod(%729, %730) : (i64, i64) -> i64
    %731 = llvm.call @printf(%725, %726) vararg(!llvm.func<i32 (ptr, ...)>) : (!llvm.ptr, i64) -> i32
    %732 = arith.constant 0 : i32
    func.return %732 : i32
  }
}