Problem 448

S(99999999019) mod 999999017 via Du Jiao sieve.

Answer106467648
Output106467648
StatusPASS
Native helperno
Runtime1680 ms
Peak memory115520 KB
Time complexityO(n) (estimated)
Space complexityO(n^2) (estimated)

Performance comparison

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

Flow source

# Project Euler 448
# S(99999999019) mod 999999017 via Du Jiao sieve.

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

function modpow(base0: i64, exp0: i64, mod: i64) -> i64 {
    let mut r: i64 = 1
    let mut b: i64 = base0 % mod
    let mut e: i64 = exp0
    while e > 0 {
        if e % 2 == 1 {
            r = ((r as i128) * (b as i128) % (mod as i128)) as i64
        }
        b = ((b as i128) * (b as i128) % (mod as i128)) as i64
        e = e / 2
    }
    return r
}

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

function hput(keys: ptr<i64>, vals: ptr<i64>, used: ptr<i8>, cap: i64, key: i64, val: i64) -> void {
    let mut h: i64 = key % cap
    while used[h] != 0 {
        if keys[h] == key {
            vals[h] = val
            return
        }
        h = h + 1
        if h >= cap { h = 0 }
    }
    used[h] = 1
    keys[h] = key
    vals[h] = val
}

function sumF(
    n: i64, LIMIT: i64, MOD: i64, inv2: i64, inv6: i64,
    prefF: ptr<i32>,
    keys: ptr<i64>, vals: ptr<i64>, used: ptr<i8>, HCAP: i64
) -> i64 {
    if n <= LIMIT {
        return prefF[n] as i64
    }
    let cached: i64 = hget(keys, vals, used, HCAP, n)
    if cached >= 0 { return cached }

    let a: i64 = n % MOD
    let mut res: i64 = (a * ((n + 1) % MOD) % MOD) * ((2 * n + 1) % MOD) % MOD
    res = (res * inv6) % MOD

    let mut i: i64 = 2
    while i <= n {
        let q: i64 = n / i
        let j: i64 = n / q
        let sum_ij: i64 = ((i + j) % MOD) * ((j - i + 1) % MOD) % MOD
        sum_ij = (sum_ij * inv2) % MOD
        let fq: i64 = sumF(q, LIMIT, MOD, inv2, inv6, prefF, keys, vals, used, HCAP)
        res = (res - sum_ij * fq) % MOD
        if res < 0 { res = res + MOD }
        i = j + 1
    }
    hput(keys, vals, used, HCAP, n, res)
    return res
}

function prefixJ(
    n: i64, LIMIT: i64, MOD: i64, inv2: i64, inv6: i64,
    prefF: ptr<i32>,
    keys: ptr<i64>, vals: ptr<i64>, used: ptr<i8>, HCAP: i64
) -> i64 {
    return ((sumF(n, LIMIT, MOD, inv2, inv6, prefF, keys, vals, used, HCAP) + 1) % MOD) * inv2 % MOD
}

function main() -> i32 {
    let MOD: i64 = 999999017
    let N: i64 = 99999999019
    let LIMIT: i64 = 5000000
    let inv2: i64 = modpow(2, MOD - 2, MOD)
    let inv6: i64 = modpow(6, MOD - 2, MOD)

    let phi: ptr<i32> = calloc(LIMIT + 1, 4)
    let sieve: ptr<i8> = calloc(LIMIT + 1, 1)
    let primes: ptr<i32> = calloc(LIMIT / 5, 4)
    let prefF: ptr<i32> = calloc(LIMIT + 1, 4)
    if phi == null || sieve == null || primes == null || prefF == null { return 1 }

    phi[1] = 1
    let mut pc: i64 = 0
    let mut i: i64 = 2
    while i <= LIMIT {
        if sieve[i] == 0 {
            primes[pc] = i as i32
            pc = pc + 1
            phi[i] = (i - 1) as i32
        }
        let mut j: i64 = 0
        while j < pc {
            let p: i64 = primes[j] as i64
            let ip: i64 = i * p
            if ip > LIMIT { break }
            sieve[ip] = 1
            if i % p == 0 {
                phi[ip] = ((phi[i] as i64) * p) as i32
                break
            } else {
                phi[ip] = ((phi[i] as i64) * (p - 1)) as i32
            }
            j = j + 1
        }
        i = i + 1
    }
    let mut s: i64 = 0
    i = 1
    while i <= LIMIT {
        s = (s + ((i % MOD) * ((phi[i] as i64) % MOD)) % MOD) % MOD
        prefF[i] = s as i32
        i = i + 1
    }

    let HCAP: i64 = 4000003
    let keys: ptr<i64> = calloc(HCAP, 8)
    let vals: ptr<i64> = calloc(HCAP, 8)
    let used: ptr<i8> = calloc(HCAP, 1)
    if keys == null || vals == null || used == null { return 1 }

    let mut ans: i64 = 0
    let mut k: i64 = 1
    while k <= N {
        let q: i64 = N / k
        let r: i64 = N / q
        let cnt: i64 = (r - k + 1) % MOD
        let pj: i64 = prefixJ(q, LIMIT, MOD, inv2, inv6, prefF, keys, vals, used, HCAP)
        ans = (ans + cnt * pj) % MOD
        k = r + 1
    }
    printf("%lld\n", ans)

    free(used)
    free(vals)
    free(keys)
    free(prefF)
    free(primes)
    free(sieve)
    free(phi)
    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 modpow_i64_i64_i64(int64_t base0, int64_t exp0, int64_t mod);
int64_t hget_ptr_i64_ptr_i64_ptr_i8_i64_i64(int64_t* keys, int64_t* vals, int8_t* used, int64_t cap, int64_t key);
void hput_ptr_i64_ptr_i64_ptr_i8_i64_i64_i64(int64_t* keys, int64_t* vals, int8_t* used, int64_t cap, int64_t key, int64_t val);
int64_t sumF_i64_i64_i64_i64_i64_ptr_i32_ptr_i64_ptr_i64_ptr_i8_i64(int64_t n, int64_t LIMIT, int64_t MOD, int64_t inv2, int64_t inv6, int32_t* prefF, int64_t* keys, int64_t* vals, int8_t* used, int64_t HCAP);
int64_t prefixJ_i64_i64_i64_i64_i64_ptr_i32_ptr_i64_ptr_i64_ptr_i8_i64(int64_t n, int64_t LIMIT, int64_t MOD, int64_t inv2, int64_t inv6, int32_t* prefF, int64_t* keys, int64_t* vals, int8_t* used, int64_t HCAP);
int32_t main(void);



int64_t modpow_i64_i64_i64(int64_t base0, int64_t exp0, int64_t mod) {
    int64_t r = 1;
    int64_t b = FLOW_CHECKED_MOD((base0), (mod));
    int64_t e = exp0;
    while (e > 0) {
        if (FLOW_CHECKED_MOD((e), (2)) == 1) {
            r = ((int64_t)(FLOW_CHECKED_MOD(((((__int128)(r)) * ((__int128)(b)))), (((__int128)(mod))))));
        }
        b = ((int64_t)(FLOW_CHECKED_MOD(((((__int128)(b)) * ((__int128)(b)))), (((__int128)(mod))))));
        e = FLOW_CHECKED_DIV((e), (2));
    }
    return r;
}

int64_t hget_ptr_i64_ptr_i64_ptr_i8_i64_i64(int64_t* keys, int64_t* vals, int8_t* used, int64_t cap, int64_t key) {
    int64_t h = FLOW_CHECKED_MOD((key), (cap));
    while (used[h] != 0) {
        if (keys[h] == key) {
            return vals[h];
        }
        h = (h + 1);
        if (h >= cap) {
            h = 0;
        }
    }
    return (-1);
}

void hput_ptr_i64_ptr_i64_ptr_i8_i64_i64_i64(int64_t* keys, int64_t* vals, int8_t* used, int64_t cap, int64_t key, int64_t val) {
    int64_t h = FLOW_CHECKED_MOD((key), (cap));
    while (used[h] != 0) {
        if (keys[h] == key) {
            vals[h] = val;
            return;
        }
        h = (h + 1);
        if (h >= cap) {
            h = 0;
        }
    }
    used[h] = 1;
    keys[h] = key;
    vals[h] = val;
}

int64_t sumF_i64_i64_i64_i64_i64_ptr_i32_ptr_i64_ptr_i64_ptr_i8_i64(int64_t n, int64_t LIMIT, int64_t MOD, int64_t inv2, int64_t inv6, int32_t* prefF, int64_t* keys, int64_t* vals, int8_t* used, int64_t HCAP) {
    if (n <= LIMIT) {
        return ((int64_t)(prefF[n]));
    }
    int64_t cached = hget_ptr_i64_ptr_i64_ptr_i8_i64_i64(keys, vals, used, HCAP, n);
    if (cached >= 0) {
        return cached;
    }
    int64_t a = FLOW_CHECKED_MOD((n), (MOD));
    int64_t res = FLOW_CHECKED_MOD(((FLOW_CHECKED_MOD(((a * FLOW_CHECKED_MOD(((n + 1)), (MOD)))), (MOD)) * FLOW_CHECKED_MOD((((2 * n) + 1)), (MOD)))), (MOD));
    res = FLOW_CHECKED_MOD(((res * inv6)), (MOD));
    int64_t i = 2;
    while (i <= n) {
        int64_t q = FLOW_CHECKED_DIV((n), (i));
        int64_t j = FLOW_CHECKED_DIV((n), (q));
        int64_t sum_ij = FLOW_CHECKED_MOD(((FLOW_CHECKED_MOD(((i + j)), (MOD)) * FLOW_CHECKED_MOD((((j - i) + 1)), (MOD)))), (MOD));
        sum_ij = FLOW_CHECKED_MOD(((sum_ij * inv2)), (MOD));
        int64_t fq = sumF_i64_i64_i64_i64_i64_ptr_i32_ptr_i64_ptr_i64_ptr_i8_i64(q, LIMIT, MOD, inv2, inv6, prefF, keys, vals, used, HCAP);
        res = FLOW_CHECKED_MOD(((res - (sum_ij * fq))), (MOD));
        if (res < 0) {
            res = (res + MOD);
        }
        i = (j + 1);
    }
    hput_ptr_i64_ptr_i64_ptr_i8_i64_i64_i64(keys, vals, used, HCAP, n, res);
    return res;
}

int64_t prefixJ_i64_i64_i64_i64_i64_ptr_i32_ptr_i64_ptr_i64_ptr_i8_i64(int64_t n, int64_t LIMIT, int64_t MOD, int64_t inv2, int64_t inv6, int32_t* prefF, int64_t* keys, int64_t* vals, int8_t* used, int64_t HCAP) {
    return FLOW_CHECKED_MOD(((FLOW_CHECKED_MOD(((sumF_i64_i64_i64_i64_i64_ptr_i32_ptr_i64_ptr_i64_ptr_i8_i64(n, LIMIT, MOD, inv2, inv6, prefF, keys, vals, used, HCAP) + 1)), (MOD)) * inv2)), (MOD));
}

int32_t main(void) {
    int64_t MOD = 999999017;
    int64_t N = 99999999019;
    int64_t LIMIT = 5000000;
    int64_t inv2 = modpow_i64_i64_i64(2, (MOD - 2), MOD);
    int64_t inv6 = modpow_i64_i64_i64(6, (MOD - 2), MOD);
    int32_t* phi = (int32_t*)(calloc((LIMIT + 1), 4));
    int8_t* sieve = (int8_t*)(calloc((LIMIT + 1), 1));
    int32_t* primes = (int32_t*)(calloc(FLOW_CHECKED_DIV((LIMIT), (5)), 4));
    int32_t* prefF = (int32_t*)(calloc((LIMIT + 1), 4));
    if ((((phi == NULL || sieve == NULL) || primes == NULL) || prefF == NULL)) {
        return 1;
    }
    phi[1] = 1;
    int64_t pc = 0;
    int64_t i = 2;
    while (i <= LIMIT) {
        if (sieve[i] == 0) {
            primes[pc] = ((int32_t)(i));
            pc = (pc + 1);
            phi[i] = ((int32_t)((i - 1)));
        }
        int64_t j = 0;
        while (j < pc) {
            int64_t p = ((int64_t)(primes[j]));
            int64_t ip = (i * p);
            if (ip > LIMIT) {
                break;
            }
            sieve[ip] = 1;
            if (FLOW_CHECKED_MOD((i), (p)) == 0) {
                phi[ip] = ((int32_t)((((int64_t)(phi[i])) * p)));
                break;
            } else {
                phi[ip] = ((int32_t)((((int64_t)(phi[i])) * (p - 1))));
            }
            j = (j + 1);
        }
        i = (i + 1);
    }
    int64_t s = 0;
    i = 1;
    while (i <= LIMIT) {
        s = FLOW_CHECKED_MOD(((s + FLOW_CHECKED_MOD(((FLOW_CHECKED_MOD((i), (MOD)) * FLOW_CHECKED_MOD((((int64_t)(phi[i]))), (MOD)))), (MOD)))), (MOD));
        prefF[i] = ((int32_t)(s));
        i = (i + 1);
    }
    int64_t HCAP = 4000003;
    int64_t* keys = (int64_t*)(calloc(HCAP, 8));
    int64_t* vals = (int64_t*)(calloc(HCAP, 8));
    int8_t* used = (int8_t*)(calloc(HCAP, 1));
    if (((keys == NULL || vals == NULL) || used == NULL)) {
        return 1;
    }
    int64_t ans = 0;
    int64_t k = 1;
    while (k <= N) {
        int64_t q = FLOW_CHECKED_DIV((N), (k));
        int64_t r = FLOW_CHECKED_DIV((N), (q));
        int64_t cnt = FLOW_CHECKED_MOD((((r - k) + 1)), (MOD));
        int64_t pj = prefixJ_i64_i64_i64_i64_i64_ptr_i32_ptr_i64_ptr_i64_ptr_i8_i64(q, LIMIT, MOD, inv2, inv6, prefF, keys, vals, used, HCAP);
        ans = FLOW_CHECKED_MOD(((ans + (cnt * pj))), (MOD));
        k = (r + 1);
    }
    printf("%lld\n", ans);
    free(used);
    free(vals);
    free(keys);
    free(prefF);
    free(primes);
    free(sieve);
    free(phi);
    return 0;
}

Generated MLIR

module {
  llvm.func @printf(!llvm.ptr, ...) -> i32
  llvm.mlir.global internal constant @str_0("%lld\n\00") {addr_space = 0 : i32} : !llvm.array<6 x i8>
  func.func private @calloc(i64, i64) -> !llvm.ptr
  func.func private @free(!llvm.ptr) -> ()
  func.func @modpow(%arg0: i64, %arg1: i64, %arg2: 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 = arith.remsi %arg0, %arg2 : i64
    %5 = llvm.mlir.constant(1 : i64) : i64
    %6 = llvm.alloca %5 x i64 : (i64) -> !llvm.ptr
    llvm.store %4, %6 : i64, !llvm.ptr
    %7 = llvm.mlir.constant(1 : i64) : i64
    %8 = llvm.alloca %7 x i64 : (i64) -> !llvm.ptr
    llvm.store %arg1, %8 : i64, !llvm.ptr
    cf.br ^bb0
    ^bb0:
    %9 = llvm.load %8 : !llvm.ptr -> i64
    %10 = arith.constant 0 : i32
    %12 = arith.extsi %10 : i32 to i64
    %11 = arith.cmpi sgt, %9, %12 : i64
    cf.cond_br %11, ^bb1, ^bb2
    ^bb1:
      %13 = llvm.load %8 : !llvm.ptr -> i64
      %14 = arith.constant 2 : i32
      %16 = arith.extsi %14 : i32 to i64
      %15 = arith.remsi %13, %16 : i64
      %17 = arith.constant 1 : i32
      %19 = arith.extsi %17 : i32 to i64
      %18 = arith.cmpi eq, %15, %19 : i64
      cf.cond_br %18, ^bb3, ^bb4
      ^bb3:
        %20 = llvm.load %3 : !llvm.ptr -> i64
        %21 = arith.extsi %20 : i64 to i128
        %22 = llvm.load %6 : !llvm.ptr -> i64
        %23 = arith.extsi %22 : i64 to i128
        %25 = arith.trunci %21 : i128 to i64
        %26 = arith.trunci %23 : i128 to i64
        %24 = arith.muli %25, %26 : i64
        %27 = arith.extsi %arg2 : i64 to i128
        %29 = arith.trunci %27 : i128 to i64
        %28 = arith.remsi %24, %29 : i64
        llvm.store %28, %3 : i64, !llvm.ptr
        cf.br ^bb5
      ^bb4:
        cf.br ^bb5
      ^bb5:
      %30 = llvm.load %6 : !llvm.ptr -> i64
      %31 = arith.extsi %30 : i64 to i128
      %32 = llvm.load %6 : !llvm.ptr -> i64
      %33 = arith.extsi %32 : i64 to i128
      %35 = arith.trunci %31 : i128 to i64
      %36 = arith.trunci %33 : i128 to i64
      %34 = arith.muli %35, %36 : i64
      %37 = arith.extsi %arg2 : i64 to i128
      %39 = arith.trunci %37 : i128 to i64
      %38 = arith.remsi %34, %39 : i64
      llvm.store %38, %6 : i64, !llvm.ptr
      %40 = llvm.load %8 : !llvm.ptr -> i64
      %41 = arith.constant 2 : i32
      %43 = arith.extsi %41 : i32 to i64
      %42 = arith.divsi %40, %43 : i64
      llvm.store %42, %8 : i64, !llvm.ptr
      cf.br ^bb0
    ^bb2:
    %44 = llvm.load %3 : !llvm.ptr -> i64
    func.return %44 : i64
  }
  func.func @hget(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: !llvm.ptr, %arg3: i64, %arg4: i64) -> i64 {
    %45 = arith.remsi %arg4, %arg3 : i64
    %46 = llvm.mlir.constant(1 : i64) : i64
    %47 = llvm.alloca %46 x i64 : (i64) -> !llvm.ptr
    llvm.store %45, %47 : i64, !llvm.ptr
    cf.br ^bb6
    ^bb6:
    %49 = llvm.load %47 : !llvm.ptr -> i64
    %50 = llvm.getelementptr %arg2[%49] : (!llvm.ptr, i64) -> !llvm.ptr, i8
    %48 = llvm.load %50 : !llvm.ptr -> i8
    %51 = arith.constant 0 : i32
    %53 = arith.extsi %48 : i8 to i32
    %52 = arith.cmpi ne, %53, %51 : i32
    cf.cond_br %52, ^bb7, ^bb8
    ^bb7:
      %55 = llvm.load %47 : !llvm.ptr -> i64
      %56 = llvm.getelementptr %arg0[%55] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %54 = llvm.load %56 : !llvm.ptr -> i64
      %57 = arith.cmpi eq, %54, %arg4 : i64
      cf.cond_br %57, ^bb9, ^bb10
      ^bb9:
        %59 = llvm.load %47 : !llvm.ptr -> i64
        %60 = llvm.getelementptr %arg1[%59] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %58 = llvm.load %60 : !llvm.ptr -> i64
        func.return %58 : i64
      ^bb10:
        cf.br ^bb11
      ^bb11:
      %61 = llvm.load %47 : !llvm.ptr -> i64
      %62 = arith.constant 1 : i32
      %64 = arith.extsi %62 : i32 to i64
      %63 = arith.addi %61, %64 : i64
      llvm.store %63, %47 : i64, !llvm.ptr
      %65 = llvm.load %47 : !llvm.ptr -> i64
      %66 = arith.cmpi sge, %65, %arg3 : i64
      cf.cond_br %66, ^bb12, ^bb13
      ^bb12:
        %67 = arith.constant 0 : i32
        %68 = arith.extsi %67 : i32 to i64
        llvm.store %68, %47 : i64, !llvm.ptr
        cf.br ^bb14
      ^bb13:
        cf.br ^bb14
      ^bb14:
      cf.br ^bb6
    ^bb8:
    %69 = arith.constant 1 : i32
    %71 = arith.constant 0 : i32
    %70 = arith.subi %71, %69 : i32
    %72 = arith.extsi %70 : i32 to i64
    func.return %72 : i64
  }
  func.func @hput(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: !llvm.ptr, %arg3: i64, %arg4: i64, %arg5: i64) -> () {
    %73 = arith.remsi %arg4, %arg3 : 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 ^bb15
    ^bb15:
    %77 = llvm.load %75 : !llvm.ptr -> i64
    %78 = llvm.getelementptr %arg2[%77] : (!llvm.ptr, i64) -> !llvm.ptr, i8
    %76 = llvm.load %78 : !llvm.ptr -> i8
    %79 = arith.constant 0 : i32
    %81 = arith.extsi %76 : i8 to i32
    %80 = arith.cmpi ne, %81, %79 : i32
    cf.cond_br %80, ^bb16, ^bb17
    ^bb16:
      %83 = llvm.load %75 : !llvm.ptr -> i64
      %84 = llvm.getelementptr %arg0[%83] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %82 = llvm.load %84 : !llvm.ptr -> i64
      %85 = arith.cmpi eq, %82, %arg4 : i64
      cf.cond_br %85, ^bb18, ^bb19
      ^bb18:
        %86 = llvm.load %75 : !llvm.ptr -> i64
        %87 = llvm.getelementptr %arg1[%86] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        llvm.store %arg5, %87 : i64, !llvm.ptr
        func.return
      ^bb19:
        cf.br ^bb20
      ^bb20:
      %88 = llvm.load %75 : !llvm.ptr -> i64
      %89 = arith.constant 1 : i32
      %91 = arith.extsi %89 : i32 to i64
      %90 = arith.addi %88, %91 : i64
      llvm.store %90, %75 : i64, !llvm.ptr
      %92 = llvm.load %75 : !llvm.ptr -> i64
      %93 = arith.cmpi sge, %92, %arg3 : i64
      cf.cond_br %93, ^bb21, ^bb22
      ^bb21:
        %94 = arith.constant 0 : i32
        %95 = arith.extsi %94 : i32 to i64
        llvm.store %95, %75 : i64, !llvm.ptr
        cf.br ^bb23
      ^bb22:
        cf.br ^bb23
      ^bb23:
      cf.br ^bb15
    ^bb17:
    %96 = arith.constant 1 : i32
    %97 = llvm.load %75 : !llvm.ptr -> i64
    %98 = arith.trunci %96 : i32 to i8
    %99 = llvm.getelementptr %arg2[%97] : (!llvm.ptr, i64) -> !llvm.ptr, i8
    llvm.store %98, %99 : i8, !llvm.ptr
    %100 = llvm.load %75 : !llvm.ptr -> i64
    %101 = llvm.getelementptr %arg0[%100] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    llvm.store %arg4, %101 : i64, !llvm.ptr
    %102 = llvm.load %75 : !llvm.ptr -> i64
    %103 = llvm.getelementptr %arg1[%102] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    llvm.store %arg5, %103 : i64, !llvm.ptr
    func.return
  }
  func.func @sumF(%arg0: i64, %arg1: i64, %arg2: i64, %arg3: i64, %arg4: i64, %arg5: !llvm.ptr, %arg6: !llvm.ptr, %arg7: !llvm.ptr, %arg8: !llvm.ptr, %arg9: i64) -> i64 {
    %104 = arith.cmpi sle, %arg0, %arg1 : i64
    cf.cond_br %104, ^bb24, ^bb25
    ^bb24:
      %106 = llvm.getelementptr %arg5[%arg0] : (!llvm.ptr, i64) -> !llvm.ptr, i32
      %105 = llvm.load %106 : !llvm.ptr -> i32
      %107 = arith.extsi %105 : i32 to i64
      func.return %107 : i64
    ^bb25:
      cf.br ^bb26
    ^bb26:
    %108 = func.call @hget(%arg6, %arg7, %arg8, %arg9, %arg0) : (!llvm.ptr, !llvm.ptr, !llvm.ptr, i64, i64) -> i64
    %109 = arith.constant 0 : i32
    %111 = arith.extsi %109 : i32 to i64
    %110 = arith.cmpi sge, %108, %111 : i64
    cf.cond_br %110, ^bb27, ^bb28
    ^bb27:
      func.return %108 : i64
    ^bb28:
      cf.br ^bb29
    ^bb29:
    %112 = arith.remsi %arg0, %arg2 : i64
    %113 = arith.constant 1 : i32
    %115 = arith.extsi %113 : i32 to i64
    %114 = arith.addi %arg0, %115 : i64
    %116 = arith.remsi %114, %arg2 : i64
    %117 = arith.muli %112, %116 : i64
    %118 = arith.remsi %117, %arg2 : i64
    %119 = arith.constant 2 : i32
    %121 = arith.extsi %119 : i32 to i64
    %120 = arith.muli %121, %arg0 : i64
    %122 = arith.constant 1 : i32
    %124 = arith.extsi %122 : i32 to i64
    %123 = arith.addi %120, %124 : i64
    %125 = arith.remsi %123, %arg2 : i64
    %126 = arith.muli %118, %125 : i64
    %127 = arith.remsi %126, %arg2 : i64
    %128 = llvm.mlir.constant(1 : i64) : i64
    %129 = llvm.alloca %128 x i64 : (i64) -> !llvm.ptr
    llvm.store %127, %129 : i64, !llvm.ptr
    %130 = llvm.load %129 : !llvm.ptr -> i64
    %131 = arith.muli %130, %arg4 : i64
    %132 = arith.remsi %131, %arg2 : i64
    llvm.store %132, %129 : i64, !llvm.ptr
    %133 = arith.constant 2 : i32
    %134 = arith.extsi %133 : i32 to i64
    %135 = llvm.mlir.constant(1 : i64) : i64
    %136 = llvm.alloca %135 x i64 : (i64) -> !llvm.ptr
    llvm.store %134, %136 : i64, !llvm.ptr
    cf.br ^bb30
    ^bb30:
    %137 = llvm.load %136 : !llvm.ptr -> i64
    %138 = arith.cmpi sle, %137, %arg0 : i64
    cf.cond_br %138, ^bb31, ^bb32
    ^bb31:
      %139 = llvm.load %136 : !llvm.ptr -> i64
      %140 = arith.divsi %arg0, %139 : i64
      %141 = arith.divsi %arg0, %140 : i64
      %142 = llvm.load %136 : !llvm.ptr -> i64
      %143 = arith.addi %142, %141 : i64
      %144 = arith.remsi %143, %arg2 : i64
      %145 = llvm.load %136 : !llvm.ptr -> i64
      %146 = arith.subi %141, %145 : i64
      %147 = arith.constant 1 : i32
      %149 = arith.extsi %147 : i32 to i64
      %148 = arith.addi %146, %149 : i64
      %150 = arith.remsi %148, %arg2 : i64
      %151 = arith.muli %144, %150 : i64
      %152 = arith.remsi %151, %arg2 : i64
      %153 = arith.muli %152, %arg3 : i64
      %154 = arith.remsi %153, %arg2 : i64
      %155 = func.call @sumF(%140, %arg1, %arg2, %arg3, %arg4, %arg5, %arg6, %arg7, %arg8, %arg9) : (i64, i64, i64, i64, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64) -> i64
      %156 = llvm.load %129 : !llvm.ptr -> i64
      %157 = arith.muli %154, %155 : i64
      %158 = arith.subi %156, %157 : i64
      %159 = arith.remsi %158, %arg2 : i64
      llvm.store %159, %129 : i64, !llvm.ptr
      %160 = llvm.load %129 : !llvm.ptr -> i64
      %161 = arith.constant 0 : i32
      %163 = arith.extsi %161 : i32 to i64
      %162 = arith.cmpi slt, %160, %163 : i64
      cf.cond_br %162, ^bb33, ^bb34
      ^bb33:
        %164 = llvm.load %129 : !llvm.ptr -> i64
        %165 = arith.addi %164, %arg2 : i64
        llvm.store %165, %129 : i64, !llvm.ptr
        cf.br ^bb35
      ^bb34:
        cf.br ^bb35
      ^bb35:
      %166 = arith.constant 1 : i32
      %168 = arith.extsi %166 : i32 to i64
      %167 = arith.addi %141, %168 : i64
      llvm.store %167, %136 : i64, !llvm.ptr
      cf.br ^bb30
    ^bb32:
    %170 = llvm.load %129 : !llvm.ptr -> i64
    func.call @hput(%arg6, %arg7, %arg8, %arg9, %arg0, %170) : (!llvm.ptr, !llvm.ptr, !llvm.ptr, i64, i64, i64) -> ()
    %171 = llvm.load %129 : !llvm.ptr -> i64
    func.return %171 : i64
  }
  func.func @prefixJ(%arg0: i64, %arg1: i64, %arg2: i64, %arg3: i64, %arg4: i64, %arg5: !llvm.ptr, %arg6: !llvm.ptr, %arg7: !llvm.ptr, %arg8: !llvm.ptr, %arg9: i64) -> i64 {
    %172 = func.call @sumF(%arg0, %arg1, %arg2, %arg3, %arg4, %arg5, %arg6, %arg7, %arg8, %arg9) : (i64, i64, i64, i64, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64) -> i64
    %173 = arith.constant 1 : i32
    %175 = arith.extsi %173 : i32 to i64
    %174 = arith.addi %172, %175 : i64
    %176 = arith.remsi %174, %arg2 : i64
    %177 = arith.muli %176, %arg3 : i64
    %178 = arith.remsi %177, %arg2 : i64
    func.return %178 : i64
  }
  func.func @main() -> i32 {
    %179 = arith.constant 999999017 : i32
    %180 = arith.extsi %179 : i32 to i64
    %181 = arith.constant 95705031723 : i32
    %182 = arith.extsi %181 : i32 to i64
    %183 = arith.constant 5000000 : i32
    %184 = arith.extsi %183 : i32 to i64
    %186 = arith.constant 2 : i32
    %187 = arith.constant 2 : i32
    %189 = arith.extsi %187 : i32 to i64
    %188 = arith.subi %180, %189 : i64
    %190 = arith.extsi %186 : i32 to i64
    %185 = func.call @modpow(%190, %188, %180) : (i64, i64, i64) -> i64
    %192 = arith.constant 6 : i32
    %193 = arith.constant 2 : i32
    %195 = arith.extsi %193 : i32 to i64
    %194 = arith.subi %180, %195 : i64
    %196 = arith.extsi %192 : i32 to i64
    %191 = func.call @modpow(%196, %194, %180) : (i64, i64, i64) -> i64
    %198 = arith.constant 1 : i32
    %200 = arith.extsi %198 : i32 to i64
    %199 = arith.addi %184, %200 : i64
    %201 = arith.constant 4 : i32
    %202 = arith.extsi %201 : i32 to i64
    %197 = func.call @calloc(%199, %202) : (i64, i64) -> !llvm.ptr
    %204 = arith.constant 1 : i32
    %206 = arith.extsi %204 : i32 to i64
    %205 = arith.addi %184, %206 : i64
    %207 = arith.constant 1 : i32
    %208 = arith.extsi %207 : i32 to i64
    %203 = func.call @calloc(%205, %208) : (i64, i64) -> !llvm.ptr
    %210 = arith.constant 5 : i32
    %212 = arith.extsi %210 : i32 to i64
    %211 = arith.divsi %184, %212 : i64
    %213 = arith.constant 4 : i32
    %214 = arith.extsi %213 : i32 to i64
    %209 = func.call @calloc(%211, %214) : (i64, i64) -> !llvm.ptr
    %216 = arith.constant 1 : i32
    %218 = arith.extsi %216 : i32 to i64
    %217 = arith.addi %184, %218 : i64
    %219 = arith.constant 4 : i32
    %220 = arith.extsi %219 : i32 to i64
    %215 = func.call @calloc(%217, %220) : (i64, i64) -> !llvm.ptr
    %221 = llvm.mlir.zero : !llvm.ptr
    %222 = llvm.icmp "eq" %197, %221 : !llvm.ptr
    %223 = scf.if %222 -> (i1) {
      %224 = arith.constant true
      scf.yield %224 : i1
    } else {
      %225 = llvm.mlir.zero : !llvm.ptr
      %226 = llvm.icmp "eq" %203, %225 : !llvm.ptr
      scf.yield %226 : i1
    }
    %227 = scf.if %223 -> (i1) {
      %228 = arith.constant true
      scf.yield %228 : i1
    } else {
      %229 = llvm.mlir.zero : !llvm.ptr
      %230 = llvm.icmp "eq" %209, %229 : !llvm.ptr
      scf.yield %230 : i1
    }
    %231 = scf.if %227 -> (i1) {
      %232 = arith.constant true
      scf.yield %232 : i1
    } else {
      %233 = llvm.mlir.zero : !llvm.ptr
      %234 = llvm.icmp "eq" %215, %233 : !llvm.ptr
      scf.yield %234 : i1
    }
    cf.cond_br %231, ^bb36, ^bb37
    ^bb36:
      %235 = arith.constant 1 : i32
      func.return %235 : i32
    ^bb37:
      cf.br ^bb38
    ^bb38:
    %236 = arith.constant 1 : i32
    %237 = arith.constant 1 : i32
    %238 = arith.extsi %237 : i32 to i64
    %239 = llvm.getelementptr %197[%238] : (!llvm.ptr, i64) -> !llvm.ptr, i32
    llvm.store %236, %239 : i32, !llvm.ptr
    %240 = arith.constant 0 : i32
    %241 = arith.extsi %240 : i32 to i64
    %242 = llvm.mlir.constant(1 : i64) : i64
    %243 = llvm.alloca %242 x i64 : (i64) -> !llvm.ptr
    llvm.store %241, %243 : i64, !llvm.ptr
    %244 = arith.constant 2 : i32
    %245 = arith.extsi %244 : i32 to i64
    %246 = llvm.mlir.constant(1 : i64) : i64
    %247 = llvm.alloca %246 x i64 : (i64) -> !llvm.ptr
    llvm.store %245, %247 : i64, !llvm.ptr
    cf.br ^bb39
    ^bb39:
    %248 = llvm.load %247 : !llvm.ptr -> i64
    %249 = arith.cmpi sle, %248, %184 : i64
    cf.cond_br %249, ^bb40, ^bb41
    ^bb40:
      %251 = llvm.load %247 : !llvm.ptr -> i64
      %252 = llvm.getelementptr %203[%251] : (!llvm.ptr, i64) -> !llvm.ptr, i8
      %250 = llvm.load %252 : !llvm.ptr -> i8
      %253 = arith.constant 0 : i32
      %255 = arith.extsi %250 : i8 to i32
      %254 = arith.cmpi eq, %255, %253 : i32
      cf.cond_br %254, ^bb42, ^bb43
      ^bb42:
        %256 = llvm.load %247 : !llvm.ptr -> i64
        %257 = arith.trunci %256 : i64 to i32
        %258 = llvm.load %243 : !llvm.ptr -> i64
        %259 = llvm.getelementptr %209[%258] : (!llvm.ptr, i64) -> !llvm.ptr, i32
        llvm.store %257, %259 : i32, !llvm.ptr
        %260 = llvm.load %243 : !llvm.ptr -> i64
        %261 = arith.constant 1 : i32
        %263 = arith.extsi %261 : i32 to i64
        %262 = arith.addi %260, %263 : i64
        llvm.store %262, %243 : i64, !llvm.ptr
        %264 = llvm.load %247 : !llvm.ptr -> i64
        %265 = arith.constant 1 : i32
        %267 = arith.extsi %265 : i32 to i64
        %266 = arith.subi %264, %267 : i64
        %268 = arith.trunci %266 : i64 to i32
        %269 = llvm.load %247 : !llvm.ptr -> i64
        %270 = llvm.getelementptr %197[%269] : (!llvm.ptr, i64) -> !llvm.ptr, i32
        llvm.store %268, %270 : i32, !llvm.ptr
        cf.br ^bb44
      ^bb43:
        cf.br ^bb44
      ^bb44:
      %271 = arith.constant 0 : i32
      %272 = arith.extsi %271 : i32 to i64
      %273 = llvm.mlir.constant(1 : i64) : i64
      %274 = llvm.alloca %273 x i64 : (i64) -> !llvm.ptr
      llvm.store %272, %274 : i64, !llvm.ptr
      cf.br ^bb45
      ^bb45:
      %275 = llvm.load %274 : !llvm.ptr -> i64
      %276 = llvm.load %243 : !llvm.ptr -> i64
      %277 = arith.cmpi slt, %275, %276 : i64
      cf.cond_br %277, ^bb46, ^bb47
      ^bb46:
        %279 = llvm.load %274 : !llvm.ptr -> i64
        %280 = llvm.getelementptr %209[%279] : (!llvm.ptr, i64) -> !llvm.ptr, i32
        %278 = llvm.load %280 : !llvm.ptr -> i32
        %281 = arith.extsi %278 : i32 to i64
        %282 = llvm.load %247 : !llvm.ptr -> i64
        %283 = arith.muli %282, %281 : i64
        %284 = arith.cmpi sgt, %283, %184 : i64
        cf.cond_br %284, ^bb48, ^bb49
        ^bb48:
          cf.br ^bb47
        ^bb49:
          cf.br ^bb50
        ^bb50:
        %285 = arith.constant 1 : i32
        %286 = arith.trunci %285 : i32 to i8
        %287 = llvm.getelementptr %203[%283] : (!llvm.ptr, i64) -> !llvm.ptr, i8
        llvm.store %286, %287 : i8, !llvm.ptr
        %288 = llvm.load %247 : !llvm.ptr -> i64
        %289 = arith.remsi %288, %281 : i64
        %290 = arith.constant 0 : i32
        %292 = arith.extsi %290 : i32 to i64
        %291 = arith.cmpi eq, %289, %292 : i64
        cf.cond_br %291, ^bb51, ^bb52
        ^bb51:
          %294 = llvm.load %247 : !llvm.ptr -> i64
          %295 = llvm.getelementptr %197[%294] : (!llvm.ptr, i64) -> !llvm.ptr, i32
          %293 = llvm.load %295 : !llvm.ptr -> i32
          %296 = arith.extsi %293 : i32 to i64
          %297 = arith.muli %296, %281 : i64
          %298 = arith.trunci %297 : i64 to i32
          %299 = llvm.getelementptr %197[%283] : (!llvm.ptr, i64) -> !llvm.ptr, i32
          llvm.store %298, %299 : i32, !llvm.ptr
          cf.br ^bb47
        ^bb52:
          %301 = llvm.load %247 : !llvm.ptr -> i64
          %302 = llvm.getelementptr %197[%301] : (!llvm.ptr, i64) -> !llvm.ptr, i32
          %300 = llvm.load %302 : !llvm.ptr -> i32
          %303 = arith.extsi %300 : i32 to i64
          %304 = arith.constant 1 : i32
          %306 = arith.extsi %304 : i32 to i64
          %305 = arith.subi %281, %306 : i64
          %307 = arith.muli %303, %305 : i64
          %308 = arith.trunci %307 : i64 to i32
          %309 = llvm.getelementptr %197[%283] : (!llvm.ptr, i64) -> !llvm.ptr, i32
          llvm.store %308, %309 : i32, !llvm.ptr
          cf.br ^bb53
        ^bb53:
        %310 = llvm.load %274 : !llvm.ptr -> i64
        %311 = arith.constant 1 : i32
        %313 = arith.extsi %311 : i32 to i64
        %312 = arith.addi %310, %313 : i64
        llvm.store %312, %274 : i64, !llvm.ptr
        cf.br ^bb45
      ^bb47:
      %314 = llvm.load %247 : !llvm.ptr -> i64
      %315 = arith.constant 1 : i32
      %317 = arith.extsi %315 : i32 to i64
      %316 = arith.addi %314, %317 : i64
      llvm.store %316, %247 : i64, !llvm.ptr
      cf.br ^bb39
    ^bb41:
    %318 = arith.constant 0 : i32
    %319 = arith.extsi %318 : i32 to i64
    %320 = llvm.mlir.constant(1 : i64) : i64
    %321 = llvm.alloca %320 x i64 : (i64) -> !llvm.ptr
    llvm.store %319, %321 : i64, !llvm.ptr
    %322 = arith.constant 1 : i32
    %323 = arith.extsi %322 : i32 to i64
    llvm.store %323, %247 : i64, !llvm.ptr
    cf.br ^bb54
    ^bb54:
    %324 = llvm.load %247 : !llvm.ptr -> i64
    %325 = arith.cmpi sle, %324, %184 : i64
    cf.cond_br %325, ^bb55, ^bb56
    ^bb55:
      %326 = llvm.load %321 : !llvm.ptr -> i64
      %327 = llvm.load %247 : !llvm.ptr -> i64
      %328 = arith.remsi %327, %180 : i64
      %330 = llvm.load %247 : !llvm.ptr -> i64
      %331 = llvm.getelementptr %197[%330] : (!llvm.ptr, i64) -> !llvm.ptr, i32
      %329 = llvm.load %331 : !llvm.ptr -> i32
      %332 = arith.extsi %329 : i32 to i64
      %333 = arith.remsi %332, %180 : i64
      %334 = arith.muli %328, %333 : i64
      %335 = arith.remsi %334, %180 : i64
      %336 = arith.addi %326, %335 : i64
      %337 = arith.remsi %336, %180 : i64
      llvm.store %337, %321 : i64, !llvm.ptr
      %338 = llvm.load %321 : !llvm.ptr -> i64
      %339 = arith.trunci %338 : i64 to i32
      %340 = llvm.load %247 : !llvm.ptr -> i64
      %341 = llvm.getelementptr %215[%340] : (!llvm.ptr, i64) -> !llvm.ptr, i32
      llvm.store %339, %341 : i32, !llvm.ptr
      %342 = llvm.load %247 : !llvm.ptr -> i64
      %343 = arith.constant 1 : i32
      %345 = arith.extsi %343 : i32 to i64
      %344 = arith.addi %342, %345 : i64
      llvm.store %344, %247 : i64, !llvm.ptr
      cf.br ^bb54
    ^bb56:
    %346 = arith.constant 4000003 : i32
    %347 = arith.extsi %346 : i32 to i64
    %349 = arith.constant 8 : i32
    %350 = arith.extsi %349 : i32 to i64
    %348 = func.call @calloc(%347, %350) : (i64, i64) -> !llvm.ptr
    %352 = arith.constant 8 : i32
    %353 = arith.extsi %352 : i32 to i64
    %351 = func.call @calloc(%347, %353) : (i64, i64) -> !llvm.ptr
    %355 = arith.constant 1 : i32
    %356 = arith.extsi %355 : i32 to i64
    %354 = func.call @calloc(%347, %356) : (i64, i64) -> !llvm.ptr
    %357 = llvm.mlir.zero : !llvm.ptr
    %358 = llvm.icmp "eq" %348, %357 : !llvm.ptr
    %359 = scf.if %358 -> (i1) {
      %360 = arith.constant true
      scf.yield %360 : i1
    } else {
      %361 = llvm.mlir.zero : !llvm.ptr
      %362 = llvm.icmp "eq" %351, %361 : !llvm.ptr
      scf.yield %362 : i1
    }
    %363 = scf.if %359 -> (i1) {
      %364 = arith.constant true
      scf.yield %364 : i1
    } else {
      %365 = llvm.mlir.zero : !llvm.ptr
      %366 = llvm.icmp "eq" %354, %365 : !llvm.ptr
      scf.yield %366 : i1
    }
    cf.cond_br %363, ^bb57, ^bb58
    ^bb57:
      %367 = arith.constant 1 : i32
      func.return %367 : i32
    ^bb58:
      cf.br ^bb59
    ^bb59:
    %368 = arith.constant 0 : i32
    %369 = arith.extsi %368 : i32 to i64
    %370 = llvm.mlir.constant(1 : i64) : i64
    %371 = llvm.alloca %370 x i64 : (i64) -> !llvm.ptr
    llvm.store %369, %371 : i64, !llvm.ptr
    %372 = arith.constant 1 : i32
    %373 = arith.extsi %372 : i32 to i64
    %374 = llvm.mlir.constant(1 : i64) : i64
    %375 = llvm.alloca %374 x i64 : (i64) -> !llvm.ptr
    llvm.store %373, %375 : i64, !llvm.ptr
    cf.br ^bb60
    ^bb60:
    %376 = llvm.load %375 : !llvm.ptr -> i64
    %377 = arith.cmpi sle, %376, %182 : i64
    cf.cond_br %377, ^bb61, ^bb62
    ^bb61:
      %378 = llvm.load %375 : !llvm.ptr -> i64
      %379 = arith.divsi %182, %378 : i64
      %380 = arith.divsi %182, %379 : i64
      %381 = llvm.load %375 : !llvm.ptr -> i64
      %382 = arith.subi %380, %381 : i64
      %383 = arith.constant 1 : i32
      %385 = arith.extsi %383 : i32 to i64
      %384 = arith.addi %382, %385 : i64
      %386 = arith.remsi %384, %180 : i64
      %387 = func.call @prefixJ(%379, %184, %180, %185, %191, %215, %348, %351, %354, %347) : (i64, i64, i64, i64, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr, i64) -> i64
      %388 = llvm.load %371 : !llvm.ptr -> i64
      %389 = arith.muli %386, %387 : i64
      %390 = arith.addi %388, %389 : i64
      %391 = arith.remsi %390, %180 : i64
      llvm.store %391, %371 : i64, !llvm.ptr
      %392 = arith.constant 1 : i32
      %394 = arith.extsi %392 : i32 to i64
      %393 = arith.addi %380, %394 : i64
      llvm.store %393, %375 : i64, !llvm.ptr
      cf.br ^bb60
    ^bb62:
    %395 = llvm.mlir.addressof @str_0 : !llvm.ptr
    %396 = llvm.load %371 : !llvm.ptr -> i64
    %397 = llvm.call @printf(%395, %396) vararg(!llvm.func<i32 (ptr, ...)>) : (!llvm.ptr, i64) -> i32
    func.call @free(%354) : (!llvm.ptr) -> ()
    func.call @free(%351) : (!llvm.ptr) -> ()
    func.call @free(%348) : (!llvm.ptr) -> ()
    func.call @free(%215) : (!llvm.ptr) -> ()
    func.call @free(%209) : (!llvm.ptr) -> ()
    func.call @free(%203) : (!llvm.ptr) -> ()
    func.call @free(%197) : (!llvm.ptr) -> ()
    %405 = arith.constant 0 : i32
    func.return %405 : i32
  }
}