Problem 608

Divisor Sums: D(200!, 10^12) mod 1e9+7. With tau(kd) = sum over a|k, b|d, gcd(a,b)=1, swapping orders gives D(m, n) = sum_{b|m} tau(m/b) * sum_{a<=n, gcd(a,b)=1} floor(n/a) = sum_{u squarefree, u | m, u <= n} mu(u) V(u) U(n/u), where U(x) = sum_{a<=x} floor(x/a) and V(u) = prod_{p|u} e_p(e_p+1)/2 * prod_{p !| u} (e_p+1)(e_p+2)/2 from the exponents e_p of m = 200!. The 4.45*10^7 squarefree 200-smooth u <= 10^12 are enumerated by DFS; U(n/u) is a prefix-sum table of divisor counts when n/u <= 10^6 and a direct hyperbola sum otherwise. Verified exactly against brute force for D(3!,100), D(4!,10^4), D(5!,3000), D(6!,2000) and the given D(4!,10^6).

Answer439689828
Output439689828
StatusPASS
Native helperno
Runtime670 ms
Peak memory12896 KB
Time complexityO(n log n) (estimated)
Space complexityO(n^2) (estimated)

Performance comparison

MetricOur solutionBest known
Time complexityO(n log n)O(n log log n)
Space complexityO(n^2)O(n)
ApproachFlow solutionMobius sieve
VerdictSuboptimal

Flow source

# Project Euler 608
# Divisor Sums: D(200!, 10^12) mod 1e9+7.
#
# With tau(kd) = sum over a|k, b|d, gcd(a,b)=1, swapping orders gives
#   D(m, n) = sum_{b|m} tau(m/b) * sum_{a<=n, gcd(a,b)=1} floor(n/a)
#           = sum_{u squarefree, u | m, u <= n} mu(u) V(u) U(n/u),
# where U(x) = sum_{a<=x} floor(x/a) and
#   V(u) = prod_{p|u} e_p(e_p+1)/2 * prod_{p !| u} (e_p+1)(e_p+2)/2
# from the exponents e_p of m = 200!.  The 4.45*10^7 squarefree 200-smooth
# u <= 10^12 are enumerated by DFS; U(n/u) is a prefix-sum table of
# divisor counts when n/u <= 10^6 and a direct hyperbola sum otherwise.
# Verified exactly against brute force for D(3!,100), D(4!,10^4),
# D(5!,3000), D(6!,2000) and the given D(4!,10^6).

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

const MOD: i64 = 1000000007
const FACT: i64 = 200
const N: i64 = 1000000000000
const K: i64 = 1000000          # isqrt(N)

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

function isqrt64(n: i64) -> i64 {
    if n <= 0 {
        return 0
    }
    let mut x: i64 = n
    let mut y: i64 = (x + 1) / 2
    while y < x {
        x = y
        y = (x + n / x) / 2
    }
    return x
}

# U(x) = sum_{a<=x} floor(x/a) mod MOD via the hyperbola identity
function U_big(x: i64) -> i64 {
    let s: i64 = isqrt64(x)
    let mut acc: i64 = 0
    let mut j: i64 = 1
    while j <= s {
        acc = acc + x / j
        j = j + 1
    }
    return ((2 * (acc % MOD) - s % MOD * (s % MOD)) % MOD + MOD) % MOD
}

# DFS over squarefree 200-smooth u; adds mu(u) * gprod * U(n/u)
function dfs(idx: i64, u: i64, sign: i64, gprod: i64,
             primes: ptr<i64>, np: i64, g: ptr<i64>,
             usmall: ptr<i64>, acc: ptr<i64>) -> void {
    let w: i64 = N / u
    let mut uv: i64 = 0
    if w <= K {
        uv = usmall[w]
    } else {
        uv = U_big(w)
    }
    let term: i64 = gprod * uv % MOD
    if sign == 1 {
        acc[0] = (acc[0] + term) % MOD
    } else {
        acc[0] = (acc[0] - term + MOD) % MOD
    }
    let mut j: i64 = idx
    while j < np {
        if u > N / primes[j] {
            j = np
        } else {
            dfs(j + 1, u * primes[j], 0 - sign, gprod * g[j] % MOD,
                primes, np, g, usmall, acc)
            j = j + 1
        }
    }
}

function main() -> i32 {
    # primes up to FACT and exponents in FACT!
    let primes: ptr<i64> = calloc(64, 8)
    let g: ptr<i64> = calloc(64, 8)
    let mut np: i64 = 0
    let mut C: i64 = 1
    let mut cand: i64 = 2
    while cand <= FACT {
        let mut isp: i64 = 1
        let mut q: i64 = 2
        while q * q <= cand {
            if cand % q == 0 {
                isp = 0
            }
            q = q + 1
        }
        if isp == 1 {
            let mut e: i64 = 0
            let mut pw: i64 = cand
            while pw <= FACT {
                e = e + FACT / pw
                if pw > FACT / cand {
                    pw = FACT + 1
                } else {
                    pw = pw * cand
                }
            }
            let half_in: i64 = e % MOD * ((e + 1) % MOD) % MOD * powmod(2, MOD - 2) % MOD
            let half_out: i64 = (e + 1) % MOD * ((e + 2) % MOD) % MOD * powmod(2, MOD - 2) % MOD
            primes[np] = cand
            g[np] = half_in * powmod(half_out, MOD - 2) % MOD
            C = C * half_out % MOD
            np = np + 1
        }
        cand = cand + 1
    }

    # U table for arguments <= K: prefix sums of divisor counts
    let dcnt: ptr<i32> = calloc(K + 1, 4)
    let mut i: i64 = 1
    while i <= K {
        let mut j: i64 = i
        while j <= K {
            dcnt[j] = dcnt[j] + 1
            j = j + i
        }
        i = i + 1
    }
    let usmall: ptr<i64> = calloc(K + 1, 8)
    let mut run: i64 = 0
    i = 1
    while i <= K {
        run = (run + (dcnt[i] as i64)) % MOD
        usmall[i] = run
        i = i + 1
    }
    free(dcnt)

    let acc: ptr<i64> = calloc(1, 8)
    dfs(0, 1, 1, 1, primes, np, g, usmall, acc)
    printf("%lld\n", C * acc[0] % MOD)

    free(primes)
    free(g)
    free(usmall)
    free(acc)
    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 powmod_i64_i64(int64_t base, int64_t exp);
int64_t isqrt64_i64(int64_t n);
int64_t U_big_i64(int64_t x);
void dfs_i64_i64_i64_i64_ptr_i64_i64_ptr_i64_ptr_i64_ptr_i64(int64_t idx, int64_t u, int64_t sign, int64_t gprod, int64_t* primes, int64_t np, int64_t* g, int64_t* usmall, int64_t* acc);
int32_t main(void);

static const int64_t MOD = 1000000007;
static const int64_t FACT = 200;
static const int64_t N = 1000000000000;
static const int64_t K = 1000000;



int64_t powmod_i64_i64(int64_t base, int64_t exp) {
    int64_t result = 1;
    int64_t b = FLOW_CHECKED_MOD((base), (MOD));
    int64_t e = exp;
    while (e > 0) {
        if ((e & 1) == 1) {
            result = FLOW_CHECKED_MOD(((result * b)), (MOD));
        }
        b = FLOW_CHECKED_MOD(((b * b)), (MOD));
        e = FLOW_CHECKED_SHR((e), (1));
    }
    return result;
}

int64_t isqrt64_i64(int64_t n) {
    if (n <= 0) {
        return 0;
    }
    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 U_big_i64(int64_t x) {
    int64_t s = isqrt64_i64(x);
    int64_t acc = 0;
    int64_t j = 1;
    while (j <= s) {
        acc = (acc + FLOW_CHECKED_DIV((x), (j)));
        j = (j + 1);
    }
    return FLOW_CHECKED_MOD(((FLOW_CHECKED_MOD((((2 * FLOW_CHECKED_MOD((acc), (MOD))) - (FLOW_CHECKED_MOD((s), (MOD)) * FLOW_CHECKED_MOD((s), (MOD))))), (MOD)) + MOD)), (MOD));
}

void dfs_i64_i64_i64_i64_ptr_i64_i64_ptr_i64_ptr_i64_ptr_i64(int64_t idx, int64_t u, int64_t sign, int64_t gprod, int64_t* primes, int64_t np, int64_t* g, int64_t* usmall, int64_t* acc) {
    int64_t w = FLOW_CHECKED_DIV((N), (u));
    int64_t uv = 0;
    if (w <= K) {
        uv = usmall[w];
    } else {
        uv = U_big_i64(w);
    }
    int64_t term = FLOW_CHECKED_MOD(((gprod * uv)), (MOD));
    if (sign == 1) {
        acc[0] = FLOW_CHECKED_MOD(((acc[0] + term)), (MOD));
    } else {
        acc[0] = FLOW_CHECKED_MOD((((acc[0] - term) + MOD)), (MOD));
    }
    int64_t j = idx;
    while (j < np) {
        if (u > FLOW_CHECKED_DIV((N), (primes[j]))) {
            j = np;
        } else {
            dfs_i64_i64_i64_i64_ptr_i64_i64_ptr_i64_ptr_i64_ptr_i64((j + 1), (u * primes[j]), (0 - sign), FLOW_CHECKED_MOD(((gprod * g[j])), (MOD)), primes, np, g, usmall, acc);
            j = (j + 1);
        }
    }
}

int32_t main(void) {
    int64_t* primes = (int64_t*)(calloc(64, 8));
    int64_t* g = (int64_t*)(calloc(64, 8));
    int64_t np = 0;
    int64_t C = 1;
    int64_t cand = 2;
    while (cand <= FACT) {
        int64_t isp = 1;
        int64_t q = 2;
        while ((q * q) <= cand) {
            if (FLOW_CHECKED_MOD((cand), (q)) == 0) {
                isp = 0;
            }
            q = (q + 1);
        }
        if (isp == 1) {
            int64_t e = 0;
            int64_t pw = cand;
            while (pw <= FACT) {
                e = (e + FLOW_CHECKED_DIV((FACT), (pw)));
                if (pw > FLOW_CHECKED_DIV((FACT), (cand))) {
                    pw = (FACT + 1);
                } else {
                    pw = (pw * cand);
                }
            }
            int64_t half_in = FLOW_CHECKED_MOD(((FLOW_CHECKED_MOD(((FLOW_CHECKED_MOD((e), (MOD)) * FLOW_CHECKED_MOD(((e + 1)), (MOD)))), (MOD)) * powmod_i64_i64(2, (MOD - 2)))), (MOD));
            int64_t half_out = FLOW_CHECKED_MOD(((FLOW_CHECKED_MOD(((FLOW_CHECKED_MOD(((e + 1)), (MOD)) * FLOW_CHECKED_MOD(((e + 2)), (MOD)))), (MOD)) * powmod_i64_i64(2, (MOD - 2)))), (MOD));
            primes[np] = cand;
            g[np] = FLOW_CHECKED_MOD(((half_in * powmod_i64_i64(half_out, (MOD - 2)))), (MOD));
            C = FLOW_CHECKED_MOD(((C * half_out)), (MOD));
            np = (np + 1);
        }
        cand = (cand + 1);
    }
    int32_t* dcnt = (int32_t*)(calloc((K + 1), 4));
    int64_t i = 1;
    while (i <= K) {
        int64_t j = i;
        while (j <= K) {
            dcnt[j] = (dcnt[j] + 1);
            j = (j + i);
        }
        i = (i + 1);
    }
    int64_t* usmall = (int64_t*)(calloc((K + 1), 8));
    int64_t run = 0;
    i = 1;
    while (i <= K) {
        run = FLOW_CHECKED_MOD(((run + ((int64_t)(dcnt[i])))), (MOD));
        usmall[i] = run;
        i = (i + 1);
    }
    free(dcnt);
    int64_t* acc = (int64_t*)(calloc(1, 8));
    dfs_i64_i64_i64_i64_ptr_i64_i64_ptr_i64_ptr_i64_ptr_i64(0, 1, 1, 1, primes, np, g, usmall, acc);
    printf("%lld\n", FLOW_CHECKED_MOD(((C * acc[0])), (MOD)));
    free(primes);
    free(g);
    free(usmall);
    free(acc);
    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) -> ()
  // Constant: MOD
  llvm.mlir.global internal constant @MOD(1000000007 : i64) : i64
  // Constant: FACT
  llvm.mlir.global internal constant @FACT(200 : i64) : i64
  // Constant: N
  llvm.mlir.global internal constant @N(1000000000000 : i64) : i64
  // Constant: K
  llvm.mlir.global internal constant @K(1000000 : i64) : i64
  func.func @powmod(%arg0: i64, %arg1: i64) -> i64 {
    %0 = arith.constant 1 : i32
    %1 = arith.extsi %0 : i32 to i64
    %2 = llvm.mlir.constant(1 : i64) : i64
    %3 = llvm.alloca %2 x i64 : (i64) -> !llvm.ptr
    llvm.store %1, %3 : i64, !llvm.ptr
    %4 = llvm.mlir.addressof @MOD : !llvm.ptr
    %5 = llvm.load %4 : !llvm.ptr -> i64
    %6 = arith.remsi %arg0, %5 : i64
    %7 = llvm.mlir.constant(1 : i64) : i64
    %8 = llvm.alloca %7 x i64 : (i64) -> !llvm.ptr
    llvm.store %6, %8 : i64, !llvm.ptr
    %9 = llvm.mlir.constant(1 : i64) : i64
    %10 = llvm.alloca %9 x i64 : (i64) -> !llvm.ptr
    llvm.store %arg1, %10 : i64, !llvm.ptr
    cf.br ^bb0
    ^bb0:
    %11 = llvm.load %10 : !llvm.ptr -> i64
    %12 = arith.constant 0 : i32
    %14 = arith.extsi %12 : i32 to i64
    %13 = arith.cmpi sgt, %11, %14 : i64
    cf.cond_br %13, ^bb1, ^bb2
    ^bb1:
      %15 = llvm.load %10 : !llvm.ptr -> i64
      %16 = arith.constant 1 : i32
      %18 = arith.extsi %16 : i32 to i64
      %17 = arith.andi %15, %18 : i64
      %19 = arith.constant 1 : i32
      %21 = arith.extsi %19 : i32 to i64
      %20 = arith.cmpi eq, %17, %21 : i64
      cf.cond_br %20, ^bb3, ^bb4
      ^bb3:
        %22 = llvm.load %3 : !llvm.ptr -> i64
        %23 = llvm.load %8 : !llvm.ptr -> i64
        %24 = arith.muli %22, %23 : i64
        %25 = llvm.mlir.addressof @MOD : !llvm.ptr
        %26 = llvm.load %25 : !llvm.ptr -> i64
        %27 = arith.remsi %24, %26 : i64
        llvm.store %27, %3 : i64, !llvm.ptr
        cf.br ^bb5
      ^bb4:
        cf.br ^bb5
      ^bb5:
      %28 = llvm.load %8 : !llvm.ptr -> i64
      %29 = llvm.load %8 : !llvm.ptr -> i64
      %30 = arith.muli %28, %29 : i64
      %31 = llvm.mlir.addressof @MOD : !llvm.ptr
      %32 = llvm.load %31 : !llvm.ptr -> i64
      %33 = arith.remsi %30, %32 : i64
      llvm.store %33, %8 : i64, !llvm.ptr
      %34 = llvm.load %10 : !llvm.ptr -> i64
      %35 = arith.constant 1 : i32
      %37 = arith.extsi %35 : i32 to i64
      %36 = arith.shrsi %34, %37 : i64
      llvm.store %36, %10 : i64, !llvm.ptr
      cf.br ^bb0
    ^bb2:
    %38 = llvm.load %3 : !llvm.ptr -> i64
    func.return %38 : i64
  }
  func.func @isqrt64(%arg0: i64) -> i64 {
    %39 = arith.constant 0 : i32
    %41 = arith.extsi %39 : i32 to i64
    %40 = arith.cmpi sle, %arg0, %41 : i64
    cf.cond_br %40, ^bb6, ^bb7
    ^bb6:
      %42 = arith.constant 0 : i32
      %43 = arith.extsi %42 : i32 to i64
      func.return %43 : i64
    ^bb7:
      cf.br ^bb8
    ^bb8:
    %44 = llvm.mlir.constant(1 : i64) : i64
    %45 = llvm.alloca %44 x i64 : (i64) -> !llvm.ptr
    llvm.store %arg0, %45 : i64, !llvm.ptr
    %46 = llvm.load %45 : !llvm.ptr -> i64
    %47 = arith.constant 1 : i32
    %49 = arith.extsi %47 : i32 to i64
    %48 = arith.addi %46, %49 : i64
    %50 = arith.constant 2 : i32
    %52 = arith.extsi %50 : i32 to i64
    %51 = arith.divsi %48, %52 : i64
    %53 = llvm.mlir.constant(1 : i64) : i64
    %54 = llvm.alloca %53 x i64 : (i64) -> !llvm.ptr
    llvm.store %51, %54 : i64, !llvm.ptr
    cf.br ^bb9
    ^bb9:
    %55 = llvm.load %54 : !llvm.ptr -> i64
    %56 = llvm.load %45 : !llvm.ptr -> i64
    %57 = arith.cmpi slt, %55, %56 : i64
    cf.cond_br %57, ^bb10, ^bb11
    ^bb10:
      %58 = llvm.load %54 : !llvm.ptr -> i64
      llvm.store %58, %45 : i64, !llvm.ptr
      %59 = llvm.load %45 : !llvm.ptr -> i64
      %60 = llvm.load %45 : !llvm.ptr -> i64
      %61 = arith.divsi %arg0, %60 : i64
      %62 = arith.addi %59, %61 : i64
      %63 = arith.constant 2 : i32
      %65 = arith.extsi %63 : i32 to i64
      %64 = arith.divsi %62, %65 : i64
      llvm.store %64, %54 : i64, !llvm.ptr
      cf.br ^bb9
    ^bb11:
    %66 = llvm.load %45 : !llvm.ptr -> i64
    func.return %66 : i64
  }
  func.func @U_big(%arg0: i64) -> i64 {
    %67 = func.call @isqrt64(%arg0) : (i64) -> i64
    %68 = arith.constant 0 : i32
    %69 = arith.extsi %68 : i32 to i64
    %70 = llvm.mlir.constant(1 : i64) : i64
    %71 = llvm.alloca %70 x i64 : (i64) -> !llvm.ptr
    llvm.store %69, %71 : i64, !llvm.ptr
    %72 = arith.constant 1 : i32
    %73 = arith.extsi %72 : i32 to i64
    %74 = llvm.mlir.constant(1 : i64) : i64
    %75 = llvm.alloca %74 x i64 : (i64) -> !llvm.ptr
    llvm.store %73, %75 : i64, !llvm.ptr
    cf.br ^bb12
    ^bb12:
    %76 = llvm.load %75 : !llvm.ptr -> i64
    %77 = arith.cmpi sle, %76, %67 : i64
    cf.cond_br %77, ^bb13, ^bb14
    ^bb13:
      %78 = llvm.load %71 : !llvm.ptr -> i64
      %79 = llvm.load %75 : !llvm.ptr -> i64
      %80 = arith.divsi %arg0, %79 : i64
      %81 = arith.addi %78, %80 : i64
      llvm.store %81, %71 : i64, !llvm.ptr
      %82 = llvm.load %75 : !llvm.ptr -> i64
      %83 = arith.constant 1 : i32
      %85 = arith.extsi %83 : i32 to i64
      %84 = arith.addi %82, %85 : i64
      llvm.store %84, %75 : i64, !llvm.ptr
      cf.br ^bb12
    ^bb14:
    %86 = arith.constant 2 : i32
    %87 = llvm.load %71 : !llvm.ptr -> i64
    %88 = llvm.mlir.addressof @MOD : !llvm.ptr
    %89 = llvm.load %88 : !llvm.ptr -> i64
    %90 = arith.remsi %87, %89 : i64
    %92 = arith.extsi %86 : i32 to i64
    %91 = arith.muli %92, %90 : i64
    %93 = llvm.mlir.addressof @MOD : !llvm.ptr
    %94 = llvm.load %93 : !llvm.ptr -> i64
    %95 = arith.remsi %67, %94 : i64
    %96 = llvm.mlir.addressof @MOD : !llvm.ptr
    %97 = llvm.load %96 : !llvm.ptr -> i64
    %98 = arith.remsi %67, %97 : i64
    %99 = arith.muli %95, %98 : i64
    %100 = arith.subi %91, %99 : i64
    %101 = llvm.mlir.addressof @MOD : !llvm.ptr
    %102 = llvm.load %101 : !llvm.ptr -> i64
    %103 = arith.remsi %100, %102 : i64
    %104 = llvm.mlir.addressof @MOD : !llvm.ptr
    %105 = llvm.load %104 : !llvm.ptr -> i64
    %106 = arith.addi %103, %105 : i64
    %107 = llvm.mlir.addressof @MOD : !llvm.ptr
    %108 = llvm.load %107 : !llvm.ptr -> i64
    %109 = arith.remsi %106, %108 : i64
    func.return %109 : i64
  }
  func.func @dfs(%arg0: i64, %arg1: i64, %arg2: i64, %arg3: i64, %arg4: !llvm.ptr, %arg5: i64, %arg6: !llvm.ptr, %arg7: !llvm.ptr, %arg8: !llvm.ptr) -> () {
    %110 = llvm.mlir.addressof @N : !llvm.ptr
    %111 = llvm.load %110 : !llvm.ptr -> i64
    %112 = arith.divsi %111, %arg1 : i64
    %113 = arith.constant 0 : i32
    %114 = arith.extsi %113 : i32 to i64
    %115 = llvm.mlir.constant(1 : i64) : i64
    %116 = llvm.alloca %115 x i64 : (i64) -> !llvm.ptr
    llvm.store %114, %116 : i64, !llvm.ptr
    %117 = llvm.mlir.addressof @K : !llvm.ptr
    %118 = llvm.load %117 : !llvm.ptr -> i64
    %119 = arith.cmpi sle, %112, %118 : i64
    cf.cond_br %119, ^bb15, ^bb16
    ^bb15:
      %121 = llvm.getelementptr %arg7[%112] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %120 = llvm.load %121 : !llvm.ptr -> i64
      llvm.store %120, %116 : i64, !llvm.ptr
      cf.br ^bb17
    ^bb16:
      %122 = func.call @U_big(%112) : (i64) -> i64
      llvm.store %122, %116 : i64, !llvm.ptr
      cf.br ^bb17
    ^bb17:
    %123 = llvm.load %116 : !llvm.ptr -> i64
    %124 = arith.muli %arg3, %123 : i64
    %125 = llvm.mlir.addressof @MOD : !llvm.ptr
    %126 = llvm.load %125 : !llvm.ptr -> i64
    %127 = arith.remsi %124, %126 : i64
    %128 = arith.constant 1 : i32
    %130 = arith.extsi %128 : i32 to i64
    %129 = arith.cmpi eq, %arg2, %130 : i64
    cf.cond_br %129, ^bb18, ^bb19
    ^bb18:
      %132 = arith.constant 0 : i32
      %133 = arith.extsi %132 : i32 to i64
      %134 = llvm.getelementptr %arg8[%133] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %131 = llvm.load %134 : !llvm.ptr -> i64
      %135 = arith.addi %131, %127 : i64
      %136 = llvm.mlir.addressof @MOD : !llvm.ptr
      %137 = llvm.load %136 : !llvm.ptr -> i64
      %138 = arith.remsi %135, %137 : i64
      %139 = arith.constant 0 : i32
      %140 = arith.extsi %139 : i32 to i64
      %141 = llvm.getelementptr %arg8[%140] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %138, %141 : i64, !llvm.ptr
      cf.br ^bb20
    ^bb19:
      %143 = arith.constant 0 : i32
      %144 = arith.extsi %143 : i32 to i64
      %145 = llvm.getelementptr %arg8[%144] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %142 = llvm.load %145 : !llvm.ptr -> i64
      %146 = arith.subi %142, %127 : i64
      %147 = llvm.mlir.addressof @MOD : !llvm.ptr
      %148 = llvm.load %147 : !llvm.ptr -> i64
      %149 = arith.addi %146, %148 : i64
      %150 = llvm.mlir.addressof @MOD : !llvm.ptr
      %151 = llvm.load %150 : !llvm.ptr -> i64
      %152 = arith.remsi %149, %151 : i64
      %153 = arith.constant 0 : i32
      %154 = arith.extsi %153 : i32 to i64
      %155 = llvm.getelementptr %arg8[%154] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %152, %155 : i64, !llvm.ptr
      cf.br ^bb20
    ^bb20:
    %156 = llvm.mlir.constant(1 : i64) : i64
    %157 = llvm.alloca %156 x i64 : (i64) -> !llvm.ptr
    llvm.store %arg0, %157 : i64, !llvm.ptr
    cf.br ^bb21
    ^bb21:
    %158 = llvm.load %157 : !llvm.ptr -> i64
    %159 = arith.cmpi slt, %158, %arg5 : i64
    cf.cond_br %159, ^bb22, ^bb23
    ^bb22:
      %160 = llvm.mlir.addressof @N : !llvm.ptr
      %161 = llvm.load %160 : !llvm.ptr -> i64
      %163 = llvm.load %157 : !llvm.ptr -> i64
      %164 = llvm.getelementptr %arg4[%163] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %162 = llvm.load %164 : !llvm.ptr -> i64
      %165 = arith.divsi %161, %162 : i64
      %166 = arith.cmpi sgt, %arg1, %165 : i64
      cf.cond_br %166, ^bb24, ^bb25
      ^bb24:
        llvm.store %arg5, %157 : i64, !llvm.ptr
        cf.br ^bb26
      ^bb25:
        %168 = llvm.load %157 : !llvm.ptr -> i64
        %169 = arith.constant 1 : i32
        %171 = arith.extsi %169 : i32 to i64
        %170 = arith.addi %168, %171 : i64
        %173 = llvm.load %157 : !llvm.ptr -> i64
        %174 = llvm.getelementptr %arg4[%173] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %172 = llvm.load %174 : !llvm.ptr -> i64
        %175 = arith.muli %arg1, %172 : i64
        %176 = arith.constant 0 : i32
        %178 = arith.extsi %176 : i32 to i64
        %177 = arith.subi %178, %arg2 : i64
        %180 = llvm.load %157 : !llvm.ptr -> i64
        %181 = llvm.getelementptr %arg6[%180] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %179 = llvm.load %181 : !llvm.ptr -> i64
        %182 = arith.muli %arg3, %179 : i64
        %183 = llvm.mlir.addressof @MOD : !llvm.ptr
        %184 = llvm.load %183 : !llvm.ptr -> i64
        %185 = arith.remsi %182, %184 : i64
        func.call @dfs(%170, %175, %177, %185, %arg4, %arg5, %arg6, %arg7, %arg8) : (i64, i64, i64, i64, !llvm.ptr, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr) -> ()
        %186 = llvm.load %157 : !llvm.ptr -> i64
        %187 = arith.constant 1 : i32
        %189 = arith.extsi %187 : i32 to i64
        %188 = arith.addi %186, %189 : i64
        llvm.store %188, %157 : i64, !llvm.ptr
        cf.br ^bb26
      ^bb26:
      cf.br ^bb21
    ^bb23:
    func.return
  }
  func.func @main() -> i32 {
    %191 = arith.constant 64 : i32
    %192 = arith.constant 8 : i32
    %193 = arith.extsi %191 : i32 to i64
    %194 = arith.extsi %192 : i32 to i64
    %190 = func.call @calloc(%193, %194) : (i64, i64) -> !llvm.ptr
    %196 = arith.constant 64 : i32
    %197 = arith.constant 8 : i32
    %198 = arith.extsi %196 : i32 to i64
    %199 = arith.extsi %197 : i32 to i64
    %195 = func.call @calloc(%198, %199) : (i64, i64) -> !llvm.ptr
    %200 = arith.constant 0 : i32
    %201 = arith.extsi %200 : i32 to i64
    %202 = llvm.mlir.constant(1 : i64) : i64
    %203 = llvm.alloca %202 x i64 : (i64) -> !llvm.ptr
    llvm.store %201, %203 : i64, !llvm.ptr
    %204 = arith.constant 1 : i32
    %205 = arith.extsi %204 : i32 to i64
    %206 = llvm.mlir.constant(1 : i64) : i64
    %207 = llvm.alloca %206 x i64 : (i64) -> !llvm.ptr
    llvm.store %205, %207 : i64, !llvm.ptr
    %208 = arith.constant 2 : i32
    %209 = arith.extsi %208 : i32 to i64
    %210 = llvm.mlir.constant(1 : i64) : i64
    %211 = llvm.alloca %210 x i64 : (i64) -> !llvm.ptr
    llvm.store %209, %211 : i64, !llvm.ptr
    cf.br ^bb27
    ^bb27:
    %212 = llvm.load %211 : !llvm.ptr -> i64
    %213 = llvm.mlir.addressof @FACT : !llvm.ptr
    %214 = llvm.load %213 : !llvm.ptr -> i64
    %215 = arith.cmpi sle, %212, %214 : i64
    cf.cond_br %215, ^bb28, ^bb29
    ^bb28:
      %216 = arith.constant 1 : i32
      %217 = arith.extsi %216 : i32 to i64
      %218 = llvm.mlir.constant(1 : i64) : i64
      %219 = llvm.alloca %218 x i64 : (i64) -> !llvm.ptr
      llvm.store %217, %219 : i64, !llvm.ptr
      %220 = arith.constant 2 : i32
      %221 = arith.extsi %220 : i32 to i64
      %222 = llvm.mlir.constant(1 : i64) : i64
      %223 = llvm.alloca %222 x i64 : (i64) -> !llvm.ptr
      llvm.store %221, %223 : i64, !llvm.ptr
      cf.br ^bb30
      ^bb30:
      %224 = llvm.load %223 : !llvm.ptr -> i64
      %225 = llvm.load %223 : !llvm.ptr -> i64
      %226 = arith.muli %224, %225 : i64
      %227 = llvm.load %211 : !llvm.ptr -> i64
      %228 = arith.cmpi sle, %226, %227 : i64
      cf.cond_br %228, ^bb31, ^bb32
      ^bb31:
        %229 = llvm.load %211 : !llvm.ptr -> i64
        %230 = llvm.load %223 : !llvm.ptr -> i64
        %231 = arith.remsi %229, %230 : i64
        %232 = arith.constant 0 : i32
        %234 = arith.extsi %232 : i32 to i64
        %233 = arith.cmpi eq, %231, %234 : i64
        cf.cond_br %233, ^bb33, ^bb34
        ^bb33:
          %235 = arith.constant 0 : i32
          %236 = arith.extsi %235 : i32 to i64
          llvm.store %236, %219 : i64, !llvm.ptr
          cf.br ^bb35
        ^bb34:
          cf.br ^bb35
        ^bb35:
        %237 = llvm.load %223 : !llvm.ptr -> i64
        %238 = arith.constant 1 : i32
        %240 = arith.extsi %238 : i32 to i64
        %239 = arith.addi %237, %240 : i64
        llvm.store %239, %223 : i64, !llvm.ptr
        cf.br ^bb30
      ^bb32:
      %241 = llvm.load %219 : !llvm.ptr -> i64
      %242 = arith.constant 1 : i32
      %244 = arith.extsi %242 : i32 to i64
      %243 = arith.cmpi eq, %241, %244 : i64
      cf.cond_br %243, ^bb36, ^bb37
      ^bb36:
        %245 = arith.constant 0 : i32
        %246 = arith.extsi %245 : i32 to i64
        %247 = llvm.mlir.constant(1 : i64) : i64
        %248 = llvm.alloca %247 x i64 : (i64) -> !llvm.ptr
        llvm.store %246, %248 : i64, !llvm.ptr
        %249 = llvm.load %211 : !llvm.ptr -> i64
        %250 = llvm.mlir.constant(1 : i64) : i64
        %251 = llvm.alloca %250 x i64 : (i64) -> !llvm.ptr
        llvm.store %249, %251 : i64, !llvm.ptr
        cf.br ^bb39
        ^bb39:
        %252 = llvm.load %251 : !llvm.ptr -> i64
        %253 = llvm.mlir.addressof @FACT : !llvm.ptr
        %254 = llvm.load %253 : !llvm.ptr -> i64
        %255 = arith.cmpi sle, %252, %254 : i64
        cf.cond_br %255, ^bb40, ^bb41
        ^bb40:
          %256 = llvm.load %248 : !llvm.ptr -> i64
          %257 = llvm.mlir.addressof @FACT : !llvm.ptr
          %258 = llvm.load %257 : !llvm.ptr -> i64
          %259 = llvm.load %251 : !llvm.ptr -> i64
          %260 = arith.divsi %258, %259 : i64
          %261 = arith.addi %256, %260 : i64
          llvm.store %261, %248 : i64, !llvm.ptr
          %262 = llvm.load %251 : !llvm.ptr -> i64
          %263 = llvm.mlir.addressof @FACT : !llvm.ptr
          %264 = llvm.load %263 : !llvm.ptr -> i64
          %265 = llvm.load %211 : !llvm.ptr -> i64
          %266 = arith.divsi %264, %265 : i64
          %267 = arith.cmpi sgt, %262, %266 : i64
          cf.cond_br %267, ^bb42, ^bb43
          ^bb42:
            %268 = llvm.mlir.addressof @FACT : !llvm.ptr
            %269 = llvm.load %268 : !llvm.ptr -> i64
            %270 = arith.constant 1 : i32
            %272 = arith.extsi %270 : i32 to i64
            %271 = arith.addi %269, %272 : i64
            llvm.store %271, %251 : i64, !llvm.ptr
            cf.br ^bb44
          ^bb43:
            %273 = llvm.load %251 : !llvm.ptr -> i64
            %274 = llvm.load %211 : !llvm.ptr -> i64
            %275 = arith.muli %273, %274 : i64
            llvm.store %275, %251 : i64, !llvm.ptr
            cf.br ^bb44
          ^bb44:
          cf.br ^bb39
        ^bb41:
        %276 = llvm.load %248 : !llvm.ptr -> i64
        %277 = llvm.mlir.addressof @MOD : !llvm.ptr
        %278 = llvm.load %277 : !llvm.ptr -> i64
        %279 = arith.remsi %276, %278 : i64
        %280 = llvm.load %248 : !llvm.ptr -> i64
        %281 = arith.constant 1 : i32
        %283 = arith.extsi %281 : i32 to i64
        %282 = arith.addi %280, %283 : i64
        %284 = llvm.mlir.addressof @MOD : !llvm.ptr
        %285 = llvm.load %284 : !llvm.ptr -> i64
        %286 = arith.remsi %282, %285 : i64
        %287 = arith.muli %279, %286 : i64
        %288 = llvm.mlir.addressof @MOD : !llvm.ptr
        %289 = llvm.load %288 : !llvm.ptr -> i64
        %290 = arith.remsi %287, %289 : i64
        %292 = arith.constant 2 : i32
        %293 = llvm.mlir.addressof @MOD : !llvm.ptr
        %294 = llvm.load %293 : !llvm.ptr -> i64
        %295 = arith.constant 2 : i32
        %297 = arith.extsi %295 : i32 to i64
        %296 = arith.subi %294, %297 : i64
        %298 = arith.extsi %292 : i32 to i64
        %291 = func.call @powmod(%298, %296) : (i64, i64) -> i64
        %299 = arith.muli %290, %291 : i64
        %300 = llvm.mlir.addressof @MOD : !llvm.ptr
        %301 = llvm.load %300 : !llvm.ptr -> i64
        %302 = arith.remsi %299, %301 : i64
        %303 = llvm.load %248 : !llvm.ptr -> i64
        %304 = arith.constant 1 : i32
        %306 = arith.extsi %304 : i32 to i64
        %305 = arith.addi %303, %306 : i64
        %307 = llvm.mlir.addressof @MOD : !llvm.ptr
        %308 = llvm.load %307 : !llvm.ptr -> i64
        %309 = arith.remsi %305, %308 : i64
        %310 = llvm.load %248 : !llvm.ptr -> i64
        %311 = arith.constant 2 : i32
        %313 = arith.extsi %311 : i32 to i64
        %312 = arith.addi %310, %313 : i64
        %314 = llvm.mlir.addressof @MOD : !llvm.ptr
        %315 = llvm.load %314 : !llvm.ptr -> i64
        %316 = arith.remsi %312, %315 : i64
        %317 = arith.muli %309, %316 : i64
        %318 = llvm.mlir.addressof @MOD : !llvm.ptr
        %319 = llvm.load %318 : !llvm.ptr -> i64
        %320 = arith.remsi %317, %319 : i64
        %322 = arith.constant 2 : i32
        %323 = llvm.mlir.addressof @MOD : !llvm.ptr
        %324 = llvm.load %323 : !llvm.ptr -> i64
        %325 = arith.constant 2 : i32
        %327 = arith.extsi %325 : i32 to i64
        %326 = arith.subi %324, %327 : i64
        %328 = arith.extsi %322 : i32 to i64
        %321 = func.call @powmod(%328, %326) : (i64, i64) -> i64
        %329 = arith.muli %320, %321 : i64
        %330 = llvm.mlir.addressof @MOD : !llvm.ptr
        %331 = llvm.load %330 : !llvm.ptr -> i64
        %332 = arith.remsi %329, %331 : i64
        %333 = llvm.load %211 : !llvm.ptr -> i64
        %334 = llvm.load %203 : !llvm.ptr -> i64
        %335 = llvm.getelementptr %190[%334] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        llvm.store %333, %335 : i64, !llvm.ptr
        %337 = llvm.mlir.addressof @MOD : !llvm.ptr
        %338 = llvm.load %337 : !llvm.ptr -> i64
        %339 = arith.constant 2 : i32
        %341 = arith.extsi %339 : i32 to i64
        %340 = arith.subi %338, %341 : i64
        %336 = func.call @powmod(%332, %340) : (i64, i64) -> i64
        %342 = arith.muli %302, %336 : i64
        %343 = llvm.mlir.addressof @MOD : !llvm.ptr
        %344 = llvm.load %343 : !llvm.ptr -> i64
        %345 = arith.remsi %342, %344 : i64
        %346 = llvm.load %203 : !llvm.ptr -> i64
        %347 = llvm.getelementptr %195[%346] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        llvm.store %345, %347 : i64, !llvm.ptr
        %348 = llvm.load %207 : !llvm.ptr -> i64
        %349 = arith.muli %348, %332 : i64
        %350 = llvm.mlir.addressof @MOD : !llvm.ptr
        %351 = llvm.load %350 : !llvm.ptr -> i64
        %352 = arith.remsi %349, %351 : i64
        llvm.store %352, %207 : i64, !llvm.ptr
        %353 = llvm.load %203 : !llvm.ptr -> i64
        %354 = arith.constant 1 : i32
        %356 = arith.extsi %354 : i32 to i64
        %355 = arith.addi %353, %356 : i64
        llvm.store %355, %203 : i64, !llvm.ptr
        cf.br ^bb38
      ^bb37:
        cf.br ^bb38
      ^bb38:
      %357 = llvm.load %211 : !llvm.ptr -> i64
      %358 = arith.constant 1 : i32
      %360 = arith.extsi %358 : i32 to i64
      %359 = arith.addi %357, %360 : i64
      llvm.store %359, %211 : i64, !llvm.ptr
      cf.br ^bb27
    ^bb29:
    %362 = llvm.mlir.addressof @K : !llvm.ptr
    %363 = llvm.load %362 : !llvm.ptr -> i64
    %364 = arith.constant 1 : i32
    %366 = arith.extsi %364 : i32 to i64
    %365 = arith.addi %363, %366 : i64
    %367 = arith.constant 4 : i32
    %368 = arith.extsi %367 : i32 to i64
    %361 = func.call @calloc(%365, %368) : (i64, i64) -> !llvm.ptr
    %369 = arith.constant 1 : i32
    %370 = arith.extsi %369 : i32 to i64
    %371 = llvm.mlir.constant(1 : i64) : i64
    %372 = llvm.alloca %371 x i64 : (i64) -> !llvm.ptr
    llvm.store %370, %372 : i64, !llvm.ptr
    cf.br ^bb45
    ^bb45:
    %373 = llvm.load %372 : !llvm.ptr -> i64
    %374 = llvm.mlir.addressof @K : !llvm.ptr
    %375 = llvm.load %374 : !llvm.ptr -> i64
    %376 = arith.cmpi sle, %373, %375 : i64
    cf.cond_br %376, ^bb46, ^bb47
    ^bb46:
      %377 = llvm.load %372 : !llvm.ptr -> i64
      %378 = llvm.mlir.constant(1 : i64) : i64
      %379 = llvm.alloca %378 x i64 : (i64) -> !llvm.ptr
      llvm.store %377, %379 : i64, !llvm.ptr
      cf.br ^bb48
      ^bb48:
      %380 = llvm.load %379 : !llvm.ptr -> i64
      %381 = llvm.mlir.addressof @K : !llvm.ptr
      %382 = llvm.load %381 : !llvm.ptr -> i64
      %383 = arith.cmpi sle, %380, %382 : i64
      cf.cond_br %383, ^bb49, ^bb50
      ^bb49:
        %385 = llvm.load %379 : !llvm.ptr -> i64
        %386 = llvm.getelementptr %361[%385] : (!llvm.ptr, i64) -> !llvm.ptr, i32
        %384 = llvm.load %386 : !llvm.ptr -> i32
        %387 = arith.constant 1 : i32
        %388 = arith.addi %384, %387 : i32
        %389 = llvm.load %379 : !llvm.ptr -> i64
        %390 = llvm.getelementptr %361[%389] : (!llvm.ptr, i64) -> !llvm.ptr, i32
        llvm.store %388, %390 : i32, !llvm.ptr
        %391 = llvm.load %379 : !llvm.ptr -> i64
        %392 = llvm.load %372 : !llvm.ptr -> i64
        %393 = arith.addi %391, %392 : i64
        llvm.store %393, %379 : i64, !llvm.ptr
        cf.br ^bb48
      ^bb50:
      %394 = llvm.load %372 : !llvm.ptr -> i64
      %395 = arith.constant 1 : i32
      %397 = arith.extsi %395 : i32 to i64
      %396 = arith.addi %394, %397 : i64
      llvm.store %396, %372 : i64, !llvm.ptr
      cf.br ^bb45
    ^bb47:
    %399 = llvm.mlir.addressof @K : !llvm.ptr
    %400 = llvm.load %399 : !llvm.ptr -> i64
    %401 = arith.constant 1 : i32
    %403 = arith.extsi %401 : i32 to i64
    %402 = arith.addi %400, %403 : i64
    %404 = arith.constant 8 : i32
    %405 = arith.extsi %404 : i32 to i64
    %398 = func.call @calloc(%402, %405) : (i64, i64) -> !llvm.ptr
    %406 = arith.constant 0 : i32
    %407 = arith.extsi %406 : i32 to i64
    %408 = llvm.mlir.constant(1 : i64) : i64
    %409 = llvm.alloca %408 x i64 : (i64) -> !llvm.ptr
    llvm.store %407, %409 : i64, !llvm.ptr
    %410 = arith.constant 1 : i32
    %411 = arith.extsi %410 : i32 to i64
    llvm.store %411, %372 : i64, !llvm.ptr
    cf.br ^bb51
    ^bb51:
    %412 = llvm.load %372 : !llvm.ptr -> i64
    %413 = llvm.mlir.addressof @K : !llvm.ptr
    %414 = llvm.load %413 : !llvm.ptr -> i64
    %415 = arith.cmpi sle, %412, %414 : i64
    cf.cond_br %415, ^bb52, ^bb53
    ^bb52:
      %416 = llvm.load %409 : !llvm.ptr -> i64
      %418 = llvm.load %372 : !llvm.ptr -> i64
      %419 = llvm.getelementptr %361[%418] : (!llvm.ptr, i64) -> !llvm.ptr, i32
      %417 = llvm.load %419 : !llvm.ptr -> i32
      %420 = arith.extsi %417 : i32 to i64
      %421 = arith.addi %416, %420 : i64
      %422 = llvm.mlir.addressof @MOD : !llvm.ptr
      %423 = llvm.load %422 : !llvm.ptr -> i64
      %424 = arith.remsi %421, %423 : i64
      llvm.store %424, %409 : i64, !llvm.ptr
      %425 = llvm.load %409 : !llvm.ptr -> i64
      %426 = llvm.load %372 : !llvm.ptr -> i64
      %427 = llvm.getelementptr %398[%426] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %425, %427 : i64, !llvm.ptr
      %428 = llvm.load %372 : !llvm.ptr -> i64
      %429 = arith.constant 1 : i32
      %431 = arith.extsi %429 : i32 to i64
      %430 = arith.addi %428, %431 : i64
      llvm.store %430, %372 : i64, !llvm.ptr
      cf.br ^bb51
    ^bb53:
    func.call @free(%361) : (!llvm.ptr) -> ()
    %434 = arith.constant 1 : i32
    %435 = arith.constant 8 : i32
    %436 = arith.extsi %434 : i32 to i64
    %437 = arith.extsi %435 : i32 to i64
    %433 = func.call @calloc(%436, %437) : (i64, i64) -> !llvm.ptr
    %439 = arith.constant 0 : i32
    %440 = arith.constant 1 : i32
    %441 = arith.constant 1 : i32
    %442 = arith.constant 1 : i32
    %443 = llvm.load %203 : !llvm.ptr -> i64
    %444 = arith.extsi %439 : i32 to i64
    %445 = arith.extsi %440 : i32 to i64
    %446 = arith.extsi %441 : i32 to i64
    %447 = arith.extsi %442 : i32 to i64
    func.call @dfs(%444, %445, %446, %447, %190, %443, %195, %398, %433) : (i64, i64, i64, i64, !llvm.ptr, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr) -> ()
    %448 = llvm.mlir.addressof @str_0 : !llvm.ptr
    %449 = llvm.load %207 : !llvm.ptr -> i64
    %451 = arith.constant 0 : i32
    %452 = arith.extsi %451 : i32 to i64
    %453 = llvm.getelementptr %433[%452] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    %450 = llvm.load %453 : !llvm.ptr -> i64
    %454 = arith.muli %449, %450 : i64
    %455 = llvm.mlir.addressof @MOD : !llvm.ptr
    %456 = llvm.load %455 : !llvm.ptr -> i64
    %457 = arith.remsi %454, %456 : i64
    %458 = llvm.call @printf(%448, %457) vararg(!llvm.func<i32 (ptr, ...)>) : (!llvm.ptr, i64) -> i32
    func.call @free(%190) : (!llvm.ptr) -> ()
    func.call @free(%195) : (!llvm.ptr) -> ()
    func.call @free(%398) : (!llvm.ptr) -> ()
    func.call @free(%433) : (!llvm.ptr) -> ()
    %463 = arith.constant 0 : i32
    func.return %463 : i32
  }
}