Problem 926

Total Roundness — R(10^7!) mod 10^9+7.

Answer40410219
Output40410219
StatusPASS
Native helperno
Runtime440 ms
Peak memory89408 KB
Time complexityO(n^2) (estimated)
Space complexityO(n^2) (estimated)

Performance comparison

MetricOur solutionBest known
Time complexityO(n^2)O(n log n)
Space complexityO(n^2)O(n)
ApproachFlow solutionModular DP or matrix exponentiation
VerdictSuboptimal

Flow source

# Project Euler 926
# Total Roundness — R(10^7!) mod 10^9+7.

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

const MOD: i64 = 1000000007

function primes_upto(n: i64, out_count: ptr<i64>) -> ptr<i64> {
    if n < 2 {
        out_count[0] = 0
        return null
    }
    let size: i64 = n / 2 + 1
    let mut sieve: ptr<i8> = calloc(size, 1)
    for i in 0..size {
        sieve[i] = 1
    }
    sieve[0] = 0
    let limit: i64 = (sqrt(n as f64)) as i64
    for i in 1..(limit / 2 + 1) {
        if sieve[i] != 0 {
            let p: i64 = 2 * i + 1
            let mut j: i64 = (p * p) / 2
            while j < size {
                sieve[j] = 0
                j = j + p
            }
        }
    }
    let mut cnt: i64 = 1
    for i in 1..size {
        if sieve[i] != 0 { cnt = cnt + 1 }
    }
    let mut primes: ptr<i64> = calloc(cnt, 8)
    primes[0] = 2
    let mut k: i64 = 1
    for i in 1..size {
        if sieve[i] != 0 {
            primes[k] = 2 * i + 1
            k = k + 1
        }
    }
    if primes[k - 1] > n { k = k - 1 }
    free(sieve)
    out_count[0] = k
    return primes
}

function v_p_factorial(n: i64, p: i64) -> i64 {
    let mut e: i64 = 0
    let mut pp: i64 = p
    while pp <= n {
        e = e + n / pp
        if pp > n / p { break }
        pp = pp * p
    }
    return e
}

function apply_exp(D: ptr<i64>, e: i64, c: i64) -> void {
    for k in 1..(e + 1) {
        let mult: i64 = (e / k) + 1
        let mut m: i64 = 1
        for i in 0..c {
            m = ((m as i128) * (mult as i128) % (MOD as i128)) as i64
        }
        D[k] = ((D[k] as i128) * (m as i128) % (MOD as i128)) as i64
    }
}

function total_roundness_factorial(n: i64) -> i64 {
    if n <= 1 { return 0 }
    let emax: i64 = v_p_factorial(n, 2)
    let mut D: ptr<i64> = calloc(emax + 1, 8)
    for i in 0..(emax + 1) {
        D[i] = 1
    }
    let mut pc: i64 = 0
    let mut primes: ptr<i64> = primes_upto(n, &pc)
    let mut sq: i64 = (sqrt(n as f64)) as i64
    while (sq + 1) * (sq + 1) <= n { sq = sq + 1 }
    while sq * sq > n { sq = sq - 1 }
    let mut split: i64 = 0
    while split < pc && primes[split] <= sq { split = split + 1 }
    for i in 0..split {
        let e: i64 = v_p_factorial(n, primes[i])
        apply_exp(D, e, 1)
    }
    let mut counts: ptr<i64> = calloc(sq + 1, 8)
    for i in split..pc {
        counts[n / primes[i]] = counts[n / primes[i]] + 1
    }
    for e in 1..(sq + 1) {
        if counts[e] != 0 { apply_exp(D, e, counts[e]) }
    }
    let mut total: i64 = 0
    for k in 1..(emax + 1) {
        total = (total + D[k]) % MOD
    }
    free(D)
    free(primes)
    free(counts)
    return (total - emax % MOD + MOD) % MOD
}

function main() -> i32 {
    printf("%lld\n", total_roundness_factorial(10000000))
    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* primes_upto_i64_ptr_i64(int64_t n, int64_t* out_count);
int64_t v_p_factorial_i64_i64(int64_t n, int64_t p);
void apply_exp_ptr_i64_i64_i64(int64_t* D, int64_t e, int64_t c);
int64_t total_roundness_factorial_i64(int64_t n);
int32_t main(void);

static const int64_t MOD = 1000000007;




int64_t* primes_upto_i64_ptr_i64(int64_t n, int64_t* out_count) {
    if (n < 2) {
        out_count[0] = 0;
        return NULL;
    }
    int64_t size = (FLOW_CHECKED_DIV((n), (2)) + 1);
    int8_t* sieve = (int8_t*)(calloc(size, 1));
    int32_t __flow_step_1 = 1;
    for (int32_t i = 0; (0 <= size) ? i < size : i > size; i += (0 <= size) ? 1 : -1) {
        sieve[i] = 1;
    }
    sieve[0] = 0;
    int64_t limit = ((int64_t)(sqrt(((double)(n)))));
    int32_t __flow_step_2 = 1;
    for (int32_t i = 1; (1 <= (FLOW_CHECKED_DIV((limit), (2)) + 1)) ? i < (FLOW_CHECKED_DIV((limit), (2)) + 1) : i > (FLOW_CHECKED_DIV((limit), (2)) + 1); i += (1 <= (FLOW_CHECKED_DIV((limit), (2)) + 1)) ? 1 : -1) {
        if (sieve[i] != 0) {
            int64_t p = ((2 * i) + 1);
            int64_t j = FLOW_CHECKED_DIV(((p * p)), (2));
            while (j < size) {
                sieve[j] = 0;
                j = (j + p);
            }
        }
    }
    int64_t cnt = 1;
    int32_t __flow_step_3 = 1;
    for (int32_t i = 1; (1 <= size) ? i < size : i > size; i += (1 <= size) ? 1 : -1) {
        if (sieve[i] != 0) {
            cnt = (cnt + 1);
        }
    }
    int64_t* primes = (int64_t*)(calloc(cnt, 8));
    primes[0] = 2;
    int64_t k = 1;
    int32_t __flow_step_4 = 1;
    for (int32_t i = 1; (1 <= size) ? i < size : i > size; i += (1 <= size) ? 1 : -1) {
        if (sieve[i] != 0) {
            primes[k] = ((2 * i) + 1);
            k = (k + 1);
        }
    }
    if (primes[(k - 1)] > n) {
        k = (k - 1);
    }
    free(sieve);
    out_count[0] = k;
    return primes;
}

int64_t v_p_factorial_i64_i64(int64_t n, int64_t p) {
    int64_t e = 0;
    int64_t pp = p;
    while (pp <= n) {
        e = (e + FLOW_CHECKED_DIV((n), (pp)));
        if (pp > FLOW_CHECKED_DIV((n), (p))) {
            break;
        }
        pp = (pp * p);
    }
    return e;
}

void apply_exp_ptr_i64_i64_i64(int64_t* D, int64_t e, int64_t c) {
    int32_t __flow_step_5 = 1;
    for (int32_t k = 1; (1 <= (e + 1)) ? k < (e + 1) : k > (e + 1); k += (1 <= (e + 1)) ? 1 : -1) {
        int64_t mult = (FLOW_CHECKED_DIV((e), (k)) + 1);
        int64_t m = 1;
        int32_t __flow_step_6 = 1;
        for (int32_t i = 0; (0 <= c) ? i < c : i > c; i += (0 <= c) ? 1 : -1) {
            m = ((int64_t)(FLOW_CHECKED_MOD(((((__int128)(m)) * ((__int128)(mult)))), (((__int128)(MOD))))));
        }
        D[k] = ((int64_t)(FLOW_CHECKED_MOD(((((__int128)(D[k])) * ((__int128)(m)))), (((__int128)(MOD))))));
    }
}

int64_t total_roundness_factorial_i64(int64_t n) {
    if (n <= 1) {
        return 0;
    }
    int64_t emax = v_p_factorial_i64_i64(n, 2);
    int64_t* D = (int64_t*)(calloc((emax + 1), 8));
    int32_t __flow_step_7 = 1;
    for (int32_t i = 0; (0 <= (emax + 1)) ? i < (emax + 1) : i > (emax + 1); i += (0 <= (emax + 1)) ? 1 : -1) {
        D[i] = 1;
    }
    int64_t pc = 0;
    int64_t* primes = (int64_t*)(primes_upto_i64_ptr_i64(n, (&(pc))));
    int64_t sq = ((int64_t)(sqrt(((double)(n)))));
    while (((sq + 1) * (sq + 1)) <= n) {
        sq = (sq + 1);
    }
    while ((sq * sq) > n) {
        sq = (sq - 1);
    }
    int64_t split = 0;
    while ((split < pc && primes[split] <= sq)) {
        split = (split + 1);
    }
    int32_t __flow_step_8 = 1;
    for (int32_t i = 0; (0 <= split) ? i < split : i > split; i += (0 <= split) ? 1 : -1) {
        int64_t e = v_p_factorial_i64_i64(n, primes[i]);
        apply_exp_ptr_i64_i64_i64(D, e, 1);
    }
    int64_t* counts = (int64_t*)(calloc((sq + 1), 8));
    int32_t __flow_step_9 = 1;
    for (int32_t i = split; (split <= pc) ? i < pc : i > pc; i += (split <= pc) ? 1 : -1) {
        counts[FLOW_CHECKED_DIV((n), (primes[i]))] = (counts[FLOW_CHECKED_DIV((n), (primes[i]))] + 1);
    }
    int32_t __flow_step_10 = 1;
    for (int32_t e = 1; (1 <= (sq + 1)) ? e < (sq + 1) : e > (sq + 1); e += (1 <= (sq + 1)) ? 1 : -1) {
        if (counts[e] != 0) {
            apply_exp_ptr_i64_i64_i64(D, e, counts[e]);
        }
    }
    int64_t total = 0;
    int32_t __flow_step_11 = 1;
    for (int32_t k = 1; (1 <= (emax + 1)) ? k < (emax + 1) : k > (emax + 1); k += (1 <= (emax + 1)) ? 1 : -1) {
        total = FLOW_CHECKED_MOD(((total + D[k])), (MOD));
    }
    free(D);
    free(primes);
    free(counts);
    return FLOW_CHECKED_MOD((((total - FLOW_CHECKED_MOD((emax), (MOD))) + MOD)), (MOD));
}

int32_t main(void) {
    printf("%lld\n", total_roundness_factorial_i64(10000000));
    return 0;
}

Generated MLIR

module {
  llvm.func @printf(!llvm.ptr, ...) -> i32
  llvm.mlir.global internal constant @str_0("%lld\n\00") {addr_space = 0 : i32} : !llvm.array<6 x i8>
  func.func private @calloc(i64, i64) -> !llvm.ptr
  func.func private @free(!llvm.ptr) -> ()
  func.func private @sqrt(f64) -> f64
  // Constant: MOD
  llvm.mlir.global internal constant @MOD(1000000007 : i64) : i64
  func.func @primes_upto(%arg0: i64, %arg1: !llvm.ptr) -> !llvm.ptr {
    %0 = arith.constant 2 : i32
    %2 = arith.extsi %0 : i32 to i64
    %1 = arith.cmpi slt, %arg0, %2 : i64
    cf.cond_br %1, ^bb0, ^bb1
    ^bb0:
      %3 = arith.constant 0 : i32
      %4 = arith.constant 0 : i32
      %5 = arith.extsi %3 : i32 to i64
      %6 = arith.extsi %4 : i32 to i64
      %7 = llvm.getelementptr %arg1[%6] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %5, %7 : i64, !llvm.ptr
      %8 = llvm.mlir.zero : !llvm.ptr
      func.return %8 : !llvm.ptr
    ^bb1:
      cf.br ^bb2
    ^bb2:
    %9 = arith.constant 2 : i32
    %11 = arith.extsi %9 : i32 to i64
    %10 = arith.divsi %arg0, %11 : i64
    %12 = arith.constant 1 : i32
    %14 = arith.extsi %12 : i32 to i64
    %13 = arith.addi %10, %14 : i64
    %16 = arith.constant 1 : i32
    %17 = arith.extsi %16 : i32 to i64
    %15 = func.call @calloc(%13, %17) : (i64, i64) -> !llvm.ptr
    %18 = llvm.mlir.constant(1 : i64) : i64
    %19 = llvm.alloca %18 x !llvm.ptr : (i64) -> !llvm.ptr
    llvm.store %15, %19 : !llvm.ptr, !llvm.ptr
    %20 = arith.constant 0 : i32
    %21 = arith.index_cast %20 : i32 to index
    %22 = arith.index_cast %13 : i32 to index
    %24 = arith.constant 1 : index
    %25 = arith.constant -1 : index
    %26 = arith.cmpi sle, %21, %22 : index
    %23 = arith.select %26, %24, %25 : index
    cf.br ^bb3(%21 : index)
    ^bb3(%27: index):
    %28 = arith.cmpi slt, %27, %22 : index
    %29 = arith.cmpi sgt, %27, %22 : index
    %30 = arith.select %26, %28, %29 : i1
    cf.cond_br %30, ^bb4(%27 : index), ^bb5(%27 : index)
    ^bb4(%31: index):
      %32 = arith.constant 1 : i32
      %33 = llvm.load %19 : !llvm.ptr -> !llvm.ptr
      %34 = arith.trunci %32 : i32 to i8
      %35 = arith.index_cast %31 : index to i64
      %36 = llvm.getelementptr %33[%35] : (!llvm.ptr, i64) -> !llvm.ptr, i8
      llvm.store %34, %36 : i8, !llvm.ptr
      %37 = arith.addi %31, %23 : index
      cf.br ^bb3(%37 : index)
    ^bb5(%38: index):
    %39 = arith.constant 0 : i32
    %40 = llvm.load %19 : !llvm.ptr -> !llvm.ptr
    %41 = arith.constant 0 : i32
    %42 = arith.trunci %39 : i32 to i8
    %43 = arith.extsi %41 : i32 to i64
    %44 = llvm.getelementptr %40[%43] : (!llvm.ptr, i64) -> !llvm.ptr, i8
    llvm.store %42, %44 : i8, !llvm.ptr
    %45 = arith.sitofp %arg0 : i64 to f64
    %46 = math.sqrt %45 : f64
    %47 = arith.fptosi %46 : f64 to i64
    %48 = arith.constant 1 : i32
    %49 = arith.constant 2 : i32
    %51 = arith.extsi %49 : i32 to i64
    %50 = arith.divsi %47, %51 : i64
    %52 = arith.constant 1 : i32
    %54 = arith.extsi %52 : i32 to i64
    %53 = arith.addi %50, %54 : i64
    %55 = arith.index_cast %48 : i32 to index
    %56 = arith.index_cast %53 : i32 to index
    %58 = arith.constant 1 : index
    %59 = arith.constant -1 : index
    %60 = arith.cmpi sle, %55, %56 : index
    %57 = arith.select %60, %58, %59 : index
    cf.br ^bb6(%55 : index)
    ^bb6(%61: index):
    %62 = arith.cmpi slt, %61, %56 : index
    %63 = arith.cmpi sgt, %61, %56 : index
    %64 = arith.select %60, %62, %63 : i1
    cf.cond_br %64, ^bb7(%61 : index), ^bb8(%61 : index)
    ^bb7(%65: index):
      %67 = llvm.load %19 : !llvm.ptr -> !llvm.ptr
      %68 = arith.index_cast %65 : index to i64
      %69 = llvm.getelementptr %67[%68] : (!llvm.ptr, i64) -> !llvm.ptr, i8
      %66 = llvm.load %69 : !llvm.ptr -> i8
      %70 = arith.constant 0 : i32
      %72 = arith.extsi %66 : i8 to i32
      %71 = arith.cmpi ne, %72, %70 : i32
      cf.cond_br %71, ^bb9, ^bb10
      ^bb9:
        %73 = arith.constant 2 : i32
        %75 = arith.index_cast %65 : index to i32
        %74 = arith.muli %73, %75 : i32
        %76 = arith.constant 1 : i32
        %77 = arith.addi %74, %76 : i32
        %78 = arith.extsi %77 : i32 to i64
        %79 = arith.muli %78, %78 : i64
        %80 = arith.constant 2 : i32
        %82 = arith.extsi %80 : i32 to i64
        %81 = arith.divsi %79, %82 : i64
        %83 = llvm.mlir.constant(1 : i64) : i64
        %84 = llvm.alloca %83 x i64 : (i64) -> !llvm.ptr
        llvm.store %81, %84 : i64, !llvm.ptr
        cf.br ^bb12
        ^bb12:
        %85 = llvm.load %84 : !llvm.ptr -> i64
        %86 = arith.cmpi slt, %85, %13 : i64
        cf.cond_br %86, ^bb13, ^bb14
        ^bb13:
          %87 = arith.constant 0 : i32
          %88 = llvm.load %19 : !llvm.ptr -> !llvm.ptr
          %89 = llvm.load %84 : !llvm.ptr -> i64
          %90 = arith.trunci %87 : i32 to i8
          %91 = llvm.getelementptr %88[%89] : (!llvm.ptr, i64) -> !llvm.ptr, i8
          llvm.store %90, %91 : i8, !llvm.ptr
          %92 = llvm.load %84 : !llvm.ptr -> i64
          %93 = arith.addi %92, %78 : i64
          llvm.store %93, %84 : i64, !llvm.ptr
          cf.br ^bb12
        ^bb14:
        cf.br ^bb11
      ^bb10:
        cf.br ^bb11
      ^bb11:
      %94 = arith.addi %65, %57 : index
      cf.br ^bb6(%94 : index)
    ^bb8(%95: index):
    %96 = arith.constant 1 : i32
    %97 = arith.extsi %96 : i32 to i64
    %98 = llvm.mlir.constant(1 : i64) : i64
    %99 = llvm.alloca %98 x i64 : (i64) -> !llvm.ptr
    llvm.store %97, %99 : i64, !llvm.ptr
    %100 = arith.constant 1 : i32
    %101 = arith.index_cast %100 : i32 to index
    %102 = arith.index_cast %13 : i32 to index
    %104 = arith.constant 1 : index
    %105 = arith.constant -1 : index
    %106 = arith.cmpi sle, %101, %102 : index
    %103 = arith.select %106, %104, %105 : index
    cf.br ^bb15(%101 : index)
    ^bb15(%107: index):
    %108 = arith.cmpi slt, %107, %102 : index
    %109 = arith.cmpi sgt, %107, %102 : index
    %110 = arith.select %106, %108, %109 : i1
    cf.cond_br %110, ^bb16(%107 : index), ^bb17(%107 : index)
    ^bb16(%111: index):
      %113 = llvm.load %19 : !llvm.ptr -> !llvm.ptr
      %114 = arith.index_cast %111 : index to i64
      %115 = llvm.getelementptr %113[%114] : (!llvm.ptr, i64) -> !llvm.ptr, i8
      %112 = llvm.load %115 : !llvm.ptr -> i8
      %116 = arith.constant 0 : i32
      %118 = arith.extsi %112 : i8 to i32
      %117 = arith.cmpi ne, %118, %116 : i32
      cf.cond_br %117, ^bb18, ^bb19
      ^bb18:
        %119 = llvm.load %99 : !llvm.ptr -> i64
        %120 = arith.constant 1 : i32
        %122 = arith.extsi %120 : i32 to i64
        %121 = arith.addi %119, %122 : i64
        llvm.store %121, %99 : i64, !llvm.ptr
        cf.br ^bb20
      ^bb19:
        cf.br ^bb20
      ^bb20:
      %123 = arith.addi %111, %103 : index
      cf.br ^bb15(%123 : index)
    ^bb17(%124: index):
    %126 = llvm.load %99 : !llvm.ptr -> i64
    %127 = arith.constant 8 : i32
    %128 = arith.extsi %127 : i32 to i64
    %125 = func.call @calloc(%126, %128) : (i64, i64) -> !llvm.ptr
    %129 = llvm.mlir.constant(1 : i64) : i64
    %130 = llvm.alloca %129 x !llvm.ptr : (i64) -> !llvm.ptr
    llvm.store %125, %130 : !llvm.ptr, !llvm.ptr
    %131 = arith.constant 2 : i32
    %132 = llvm.load %130 : !llvm.ptr -> !llvm.ptr
    %133 = arith.constant 0 : i32
    %134 = arith.extsi %131 : i32 to i64
    %135 = arith.extsi %133 : i32 to i64
    %136 = llvm.getelementptr %132[%135] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    llvm.store %134, %136 : i64, !llvm.ptr
    %137 = arith.constant 1 : i32
    %138 = arith.extsi %137 : i32 to i64
    %139 = llvm.mlir.constant(1 : i64) : i64
    %140 = llvm.alloca %139 x i64 : (i64) -> !llvm.ptr
    llvm.store %138, %140 : i64, !llvm.ptr
    %141 = arith.constant 1 : i32
    %142 = arith.index_cast %141 : i32 to index
    %143 = arith.index_cast %13 : i32 to index
    %145 = arith.constant 1 : index
    %146 = arith.constant -1 : index
    %147 = arith.cmpi sle, %142, %143 : index
    %144 = arith.select %147, %145, %146 : index
    cf.br ^bb21(%142 : index)
    ^bb21(%148: index):
    %149 = arith.cmpi slt, %148, %143 : index
    %150 = arith.cmpi sgt, %148, %143 : index
    %151 = arith.select %147, %149, %150 : i1
    cf.cond_br %151, ^bb22(%148 : index), ^bb23(%148 : index)
    ^bb22(%152: index):
      %154 = llvm.load %19 : !llvm.ptr -> !llvm.ptr
      %155 = arith.index_cast %152 : index to i64
      %156 = llvm.getelementptr %154[%155] : (!llvm.ptr, i64) -> !llvm.ptr, i8
      %153 = llvm.load %156 : !llvm.ptr -> i8
      %157 = arith.constant 0 : i32
      %159 = arith.extsi %153 : i8 to i32
      %158 = arith.cmpi ne, %159, %157 : i32
      cf.cond_br %158, ^bb24, ^bb25
      ^bb24:
        %160 = arith.constant 2 : i32
        %162 = arith.index_cast %152 : index to i32
        %161 = arith.muli %160, %162 : i32
        %163 = arith.constant 1 : i32
        %164 = arith.addi %161, %163 : i32
        %165 = llvm.load %130 : !llvm.ptr -> !llvm.ptr
        %166 = llvm.load %140 : !llvm.ptr -> i64
        %167 = arith.extsi %164 : i32 to i64
        %168 = llvm.getelementptr %165[%166] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        llvm.store %167, %168 : i64, !llvm.ptr
        %169 = llvm.load %140 : !llvm.ptr -> i64
        %170 = arith.constant 1 : i32
        %172 = arith.extsi %170 : i32 to i64
        %171 = arith.addi %169, %172 : i64
        llvm.store %171, %140 : i64, !llvm.ptr
        cf.br ^bb26
      ^bb25:
        cf.br ^bb26
      ^bb26:
      %173 = arith.addi %152, %144 : index
      cf.br ^bb21(%173 : index)
    ^bb23(%174: index):
    %176 = llvm.load %130 : !llvm.ptr -> !llvm.ptr
    %177 = llvm.load %140 : !llvm.ptr -> i64
    %178 = arith.constant 1 : i32
    %180 = arith.extsi %178 : i32 to i64
    %179 = arith.subi %177, %180 : i64
    %181 = llvm.getelementptr %176[%179] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    %175 = llvm.load %181 : !llvm.ptr -> i64
    %182 = arith.cmpi sgt, %175, %arg0 : i64
    cf.cond_br %182, ^bb27, ^bb28
    ^bb27:
      %183 = llvm.load %140 : !llvm.ptr -> i64
      %184 = arith.constant 1 : i32
      %186 = arith.extsi %184 : i32 to i64
      %185 = arith.subi %183, %186 : i64
      llvm.store %185, %140 : i64, !llvm.ptr
      cf.br ^bb29
    ^bb28:
      cf.br ^bb29
    ^bb29:
    %188 = llvm.load %19 : !llvm.ptr -> !llvm.ptr
    func.call @free(%188) : (!llvm.ptr) -> ()
    %189 = llvm.load %140 : !llvm.ptr -> i64
    %190 = arith.constant 0 : i32
    %191 = arith.extsi %190 : i32 to i64
    %192 = llvm.getelementptr %arg1[%191] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    llvm.store %189, %192 : i64, !llvm.ptr
    %193 = llvm.load %130 : !llvm.ptr -> !llvm.ptr
    func.return %193 : !llvm.ptr
  }
  func.func @v_p_factorial(%arg0: i64, %arg1: i64) -> i64 {
    %194 = arith.constant 0 : i32
    %195 = arith.extsi %194 : i32 to i64
    %196 = llvm.mlir.constant(1 : i64) : i64
    %197 = llvm.alloca %196 x i64 : (i64) -> !llvm.ptr
    llvm.store %195, %197 : i64, !llvm.ptr
    %198 = llvm.mlir.constant(1 : i64) : i64
    %199 = llvm.alloca %198 x i64 : (i64) -> !llvm.ptr
    llvm.store %arg1, %199 : i64, !llvm.ptr
    cf.br ^bb30
    ^bb30:
    %200 = llvm.load %199 : !llvm.ptr -> i64
    %201 = arith.cmpi sle, %200, %arg0 : i64
    cf.cond_br %201, ^bb31, ^bb32
    ^bb31:
      %202 = llvm.load %197 : !llvm.ptr -> i64
      %203 = llvm.load %199 : !llvm.ptr -> i64
      %204 = arith.divsi %arg0, %203 : i64
      %205 = arith.addi %202, %204 : i64
      llvm.store %205, %197 : i64, !llvm.ptr
      %206 = llvm.load %199 : !llvm.ptr -> i64
      %207 = arith.divsi %arg0, %arg1 : i64
      %208 = arith.cmpi sgt, %206, %207 : i64
      cf.cond_br %208, ^bb33, ^bb34
      ^bb33:
        cf.br ^bb32
      ^bb34:
        cf.br ^bb35
      ^bb35:
      %209 = llvm.load %199 : !llvm.ptr -> i64
      %210 = arith.muli %209, %arg1 : i64
      llvm.store %210, %199 : i64, !llvm.ptr
      cf.br ^bb30
    ^bb32:
    %211 = llvm.load %197 : !llvm.ptr -> i64
    func.return %211 : i64
  }
  func.func @apply_exp(%arg0: !llvm.ptr, %arg1: i64, %arg2: i64) -> () {
    %212 = arith.constant 1 : i32
    %213 = arith.constant 1 : i32
    %215 = arith.extsi %213 : i32 to i64
    %214 = arith.addi %arg1, %215 : i64
    %216 = arith.index_cast %212 : i32 to index
    %217 = arith.index_cast %214 : i32 to index
    %219 = arith.constant 1 : index
    %220 = arith.constant -1 : index
    %221 = arith.cmpi sle, %216, %217 : index
    %218 = arith.select %221, %219, %220 : index
    cf.br ^bb36(%216 : index)
    ^bb36(%222: index):
    %223 = arith.cmpi slt, %222, %217 : index
    %224 = arith.cmpi sgt, %222, %217 : index
    %225 = arith.select %221, %223, %224 : i1
    cf.cond_br %225, ^bb37(%222 : index), ^bb38(%222 : index)
    ^bb37(%226: index):
      %228 = arith.trunci %arg1 : i64 to i32
      %229 = arith.index_cast %226 : index to i32
      %227 = arith.divsi %228, %229 : i32
      %230 = arith.constant 1 : i32
      %231 = arith.addi %227, %230 : i32
      %232 = arith.extsi %231 : i32 to i64
      %233 = arith.constant 1 : i32
      %234 = arith.extsi %233 : i32 to i64
      %235 = llvm.mlir.constant(1 : i64) : i64
      %236 = llvm.alloca %235 x i64 : (i64) -> !llvm.ptr
      llvm.store %234, %236 : i64, !llvm.ptr
      %237 = arith.constant 0 : i32
      %238 = arith.index_cast %237 : i32 to index
      %239 = arith.index_cast %arg2 : i32 to index
      %241 = arith.constant 1 : index
      %242 = arith.constant -1 : index
      %243 = arith.cmpi sle, %238, %239 : index
      %240 = arith.select %243, %241, %242 : index
      cf.br ^bb39(%238 : index)
      ^bb39(%244: index):
      %245 = arith.cmpi slt, %244, %239 : index
      %246 = arith.cmpi sgt, %244, %239 : index
      %247 = arith.select %243, %245, %246 : i1
      cf.cond_br %247, ^bb40(%244 : index), ^bb41(%244 : index)
      ^bb40(%248: index):
        %249 = llvm.load %236 : !llvm.ptr -> i64
        %250 = arith.extsi %249 : i64 to i128
        %251 = arith.extsi %232 : i64 to i128
        %253 = arith.trunci %250 : i128 to i64
        %254 = arith.trunci %251 : i128 to i64
        %252 = arith.muli %253, %254 : i64
        %255 = llvm.mlir.addressof @MOD : !llvm.ptr
        %256 = llvm.load %255 : !llvm.ptr -> i64
        %257 = arith.extsi %256 : i64 to i128
        %259 = arith.trunci %257 : i128 to i64
        %258 = arith.remsi %252, %259 : i64
        llvm.store %258, %236 : i64, !llvm.ptr
        %260 = arith.addi %248, %240 : index
        cf.br ^bb39(%260 : index)
      ^bb41(%261: index):
      %263 = arith.index_cast %226 : index to i64
      %264 = llvm.getelementptr %arg0[%263] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %262 = llvm.load %264 : !llvm.ptr -> i64
      %265 = arith.extsi %262 : i64 to i128
      %266 = llvm.load %236 : !llvm.ptr -> i64
      %267 = arith.extsi %266 : i64 to i128
      %269 = arith.trunci %265 : i128 to i64
      %270 = arith.trunci %267 : i128 to i64
      %268 = arith.muli %269, %270 : i64
      %271 = llvm.mlir.addressof @MOD : !llvm.ptr
      %272 = llvm.load %271 : !llvm.ptr -> i64
      %273 = arith.extsi %272 : i64 to i128
      %275 = arith.trunci %273 : i128 to i64
      %274 = arith.remsi %268, %275 : i64
      %276 = arith.index_cast %226 : index to i64
      %277 = llvm.getelementptr %arg0[%276] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %274, %277 : i64, !llvm.ptr
      %278 = arith.addi %226, %218 : index
      cf.br ^bb36(%278 : index)
    ^bb38(%279: index):
    func.return
  }
  func.func @total_roundness_factorial(%arg0: i64) -> i64 {
    %280 = arith.constant 1 : i32
    %282 = arith.extsi %280 : i32 to i64
    %281 = arith.cmpi sle, %arg0, %282 : i64
    cf.cond_br %281, ^bb42, ^bb43
    ^bb42:
      %283 = arith.constant 0 : i32
      %284 = arith.extsi %283 : i32 to i64
      func.return %284 : i64
    ^bb43:
      cf.br ^bb44
    ^bb44:
    %286 = arith.constant 2 : i32
    %287 = arith.extsi %286 : i32 to i64
    %285 = func.call @v_p_factorial(%arg0, %287) : (i64, i64) -> i64
    %289 = arith.constant 1 : i32
    %291 = arith.extsi %289 : i32 to i64
    %290 = arith.addi %285, %291 : i64
    %292 = arith.constant 8 : i32
    %293 = arith.extsi %292 : i32 to i64
    %288 = func.call @calloc(%290, %293) : (i64, i64) -> !llvm.ptr
    %294 = llvm.mlir.constant(1 : i64) : i64
    %295 = llvm.alloca %294 x !llvm.ptr : (i64) -> !llvm.ptr
    llvm.store %288, %295 : !llvm.ptr, !llvm.ptr
    %296 = arith.constant 0 : i32
    %297 = arith.constant 1 : i32
    %299 = arith.extsi %297 : i32 to i64
    %298 = arith.addi %285, %299 : i64
    %300 = arith.index_cast %296 : i32 to index
    %301 = arith.index_cast %298 : i32 to index
    %303 = arith.constant 1 : index
    %304 = arith.constant -1 : index
    %305 = arith.cmpi sle, %300, %301 : index
    %302 = arith.select %305, %303, %304 : index
    cf.br ^bb45(%300 : index)
    ^bb45(%306: index):
    %307 = arith.cmpi slt, %306, %301 : index
    %308 = arith.cmpi sgt, %306, %301 : index
    %309 = arith.select %305, %307, %308 : i1
    cf.cond_br %309, ^bb46(%306 : index), ^bb47(%306 : index)
    ^bb46(%310: index):
      %311 = arith.constant 1 : i32
      %312 = llvm.load %295 : !llvm.ptr -> !llvm.ptr
      %313 = arith.extsi %311 : i32 to i64
      %314 = arith.index_cast %310 : index to i64
      %315 = llvm.getelementptr %312[%314] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %313, %315 : i64, !llvm.ptr
      %316 = arith.addi %310, %302 : index
      cf.br ^bb45(%316 : index)
    ^bb47(%317: index):
    %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 = func.call @primes_upto(%arg0, %321) : (i64, !llvm.ptr) -> !llvm.ptr
    %323 = llvm.mlir.constant(1 : i64) : i64
    %324 = llvm.alloca %323 x !llvm.ptr : (i64) -> !llvm.ptr
    llvm.store %322, %324 : !llvm.ptr, !llvm.ptr
    %325 = arith.sitofp %arg0 : i64 to f64
    %326 = math.sqrt %325 : f64
    %327 = arith.fptosi %326 : f64 to i64
    %328 = llvm.mlir.constant(1 : i64) : i64
    %329 = llvm.alloca %328 x i64 : (i64) -> !llvm.ptr
    llvm.store %327, %329 : i64, !llvm.ptr
    cf.br ^bb48
    ^bb48:
    %330 = llvm.load %329 : !llvm.ptr -> i64
    %331 = arith.constant 1 : i32
    %333 = arith.extsi %331 : i32 to i64
    %332 = arith.addi %330, %333 : i64
    %334 = llvm.load %329 : !llvm.ptr -> i64
    %335 = arith.constant 1 : i32
    %337 = arith.extsi %335 : i32 to i64
    %336 = arith.addi %334, %337 : i64
    %338 = arith.muli %332, %336 : i64
    %339 = arith.cmpi sle, %338, %arg0 : i64
    cf.cond_br %339, ^bb49, ^bb50
    ^bb49:
      %340 = llvm.load %329 : !llvm.ptr -> i64
      %341 = arith.constant 1 : i32
      %343 = arith.extsi %341 : i32 to i64
      %342 = arith.addi %340, %343 : i64
      llvm.store %342, %329 : i64, !llvm.ptr
      cf.br ^bb48
    ^bb50:
    cf.br ^bb51
    ^bb51:
    %344 = llvm.load %329 : !llvm.ptr -> i64
    %345 = llvm.load %329 : !llvm.ptr -> i64
    %346 = arith.muli %344, %345 : i64
    %347 = arith.cmpi sgt, %346, %arg0 : i64
    cf.cond_br %347, ^bb52, ^bb53
    ^bb52:
      %348 = llvm.load %329 : !llvm.ptr -> i64
      %349 = arith.constant 1 : i32
      %351 = arith.extsi %349 : i32 to i64
      %350 = arith.subi %348, %351 : i64
      llvm.store %350, %329 : i64, !llvm.ptr
      cf.br ^bb51
    ^bb53:
    %352 = arith.constant 0 : i32
    %353 = arith.extsi %352 : i32 to i64
    %354 = llvm.mlir.constant(1 : i64) : i64
    %355 = llvm.alloca %354 x i64 : (i64) -> !llvm.ptr
    llvm.store %353, %355 : i64, !llvm.ptr
    cf.br ^bb54
    ^bb54:
    %356 = llvm.load %355 : !llvm.ptr -> i64
    %357 = llvm.load %321 : !llvm.ptr -> i64
    %358 = arith.cmpi slt, %356, %357 : i64
    %359 = scf.if %358 -> (i1) {
      %361 = llvm.load %324 : !llvm.ptr -> !llvm.ptr
      %362 = llvm.load %355 : !llvm.ptr -> i64
      %363 = llvm.getelementptr %361[%362] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %360 = llvm.load %363 : !llvm.ptr -> i64
      %364 = llvm.load %329 : !llvm.ptr -> i64
      %365 = arith.cmpi sle, %360, %364 : i64
      scf.yield %365 : i1
    } else {
      %366 = arith.constant false
      scf.yield %366 : i1
    }
    cf.cond_br %359, ^bb55, ^bb56
    ^bb55:
      %367 = llvm.load %355 : !llvm.ptr -> i64
      %368 = arith.constant 1 : i32
      %370 = arith.extsi %368 : i32 to i64
      %369 = arith.addi %367, %370 : i64
      llvm.store %369, %355 : i64, !llvm.ptr
      cf.br ^bb54
    ^bb56:
    %371 = arith.constant 0 : i32
    %372 = llvm.load %355 : !llvm.ptr -> i64
    %373 = arith.index_cast %371 : i32 to index
    %374 = arith.index_cast %372 : i32 to index
    %376 = arith.constant 1 : index
    %377 = arith.constant -1 : index
    %378 = arith.cmpi sle, %373, %374 : index
    %375 = arith.select %378, %376, %377 : index
    cf.br ^bb57(%373 : index)
    ^bb57(%379: index):
    %380 = arith.cmpi slt, %379, %374 : index
    %381 = arith.cmpi sgt, %379, %374 : index
    %382 = arith.select %378, %380, %381 : i1
    cf.cond_br %382, ^bb58(%379 : index), ^bb59(%379 : index)
    ^bb58(%383: index):
      %386 = llvm.load %324 : !llvm.ptr -> !llvm.ptr
      %387 = arith.index_cast %383 : index to i64
      %388 = llvm.getelementptr %386[%387] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %385 = llvm.load %388 : !llvm.ptr -> i64
      %384 = func.call @v_p_factorial(%arg0, %385) : (i64, i64) -> i64
      %390 = llvm.load %295 : !llvm.ptr -> !llvm.ptr
      %391 = arith.constant 1 : i32
      %392 = arith.extsi %391 : i32 to i64
      func.call @apply_exp(%390, %384, %392) : (!llvm.ptr, i64, i64) -> ()
      %393 = arith.addi %383, %375 : index
      cf.br ^bb57(%393 : index)
    ^bb59(%394: index):
    %396 = llvm.load %329 : !llvm.ptr -> i64
    %397 = arith.constant 1 : i32
    %399 = arith.extsi %397 : i32 to i64
    %398 = arith.addi %396, %399 : i64
    %400 = arith.constant 8 : i32
    %401 = arith.extsi %400 : i32 to i64
    %395 = func.call @calloc(%398, %401) : (i64, i64) -> !llvm.ptr
    %402 = llvm.mlir.constant(1 : i64) : i64
    %403 = llvm.alloca %402 x !llvm.ptr : (i64) -> !llvm.ptr
    llvm.store %395, %403 : !llvm.ptr, !llvm.ptr
    %404 = llvm.load %355 : !llvm.ptr -> i64
    %405 = llvm.load %321 : !llvm.ptr -> i64
    %406 = arith.index_cast %404 : i32 to index
    %407 = arith.index_cast %405 : i32 to index
    %409 = arith.constant 1 : index
    %410 = arith.constant -1 : index
    %411 = arith.cmpi sle, %406, %407 : index
    %408 = arith.select %411, %409, %410 : index
    cf.br ^bb60(%406 : index)
    ^bb60(%412: index):
    %413 = arith.cmpi slt, %412, %407 : index
    %414 = arith.cmpi sgt, %412, %407 : index
    %415 = arith.select %411, %413, %414 : i1
    cf.cond_br %415, ^bb61(%412 : index), ^bb62(%412 : index)
    ^bb61(%416: index):
      %418 = llvm.load %403 : !llvm.ptr -> !llvm.ptr
      %420 = llvm.load %324 : !llvm.ptr -> !llvm.ptr
      %421 = arith.index_cast %416 : index to i64
      %422 = llvm.getelementptr %420[%421] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %419 = llvm.load %422 : !llvm.ptr -> i64
      %423 = arith.divsi %arg0, %419 : i64
      %424 = llvm.getelementptr %418[%423] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %417 = llvm.load %424 : !llvm.ptr -> i64
      %425 = arith.constant 1 : i32
      %427 = arith.extsi %425 : i32 to i64
      %426 = arith.addi %417, %427 : i64
      %428 = llvm.load %403 : !llvm.ptr -> !llvm.ptr
      %430 = llvm.load %324 : !llvm.ptr -> !llvm.ptr
      %431 = arith.index_cast %416 : index to i64
      %432 = llvm.getelementptr %430[%431] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %429 = llvm.load %432 : !llvm.ptr -> i64
      %433 = arith.divsi %arg0, %429 : i64
      %434 = llvm.getelementptr %428[%433] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %426, %434 : i64, !llvm.ptr
      %435 = arith.addi %416, %408 : index
      cf.br ^bb60(%435 : index)
    ^bb62(%436: index):
    %437 = arith.constant 1 : i32
    %438 = llvm.load %329 : !llvm.ptr -> i64
    %439 = arith.constant 1 : i32
    %441 = arith.extsi %439 : i32 to i64
    %440 = arith.addi %438, %441 : i64
    %442 = arith.index_cast %437 : i32 to index
    %443 = arith.index_cast %440 : i32 to index
    %445 = arith.constant 1 : index
    %446 = arith.constant -1 : index
    %447 = arith.cmpi sle, %442, %443 : index
    %444 = arith.select %447, %445, %446 : index
    cf.br ^bb63(%442 : index)
    ^bb63(%448: index):
    %449 = arith.cmpi slt, %448, %443 : index
    %450 = arith.cmpi sgt, %448, %443 : index
    %451 = arith.select %447, %449, %450 : i1
    cf.cond_br %451, ^bb64(%448 : index), ^bb65(%448 : index)
    ^bb64(%452: index):
      %454 = llvm.load %403 : !llvm.ptr -> !llvm.ptr
      %455 = arith.index_cast %452 : index to i64
      %456 = llvm.getelementptr %454[%455] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %453 = llvm.load %456 : !llvm.ptr -> i64
      %457 = arith.constant 0 : i32
      %459 = arith.extsi %457 : i32 to i64
      %458 = arith.cmpi ne, %453, %459 : i64
      cf.cond_br %458, ^bb66, ^bb67
      ^bb66:
        %461 = llvm.load %295 : !llvm.ptr -> !llvm.ptr
        %463 = llvm.load %403 : !llvm.ptr -> !llvm.ptr
        %464 = arith.index_cast %452 : index to i64
        %465 = llvm.getelementptr %463[%464] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %462 = llvm.load %465 : !llvm.ptr -> i64
        %466 = arith.index_cast %452 : index to i64
        func.call @apply_exp(%461, %466, %462) : (!llvm.ptr, i64, i64) -> ()
        cf.br ^bb68
      ^bb67:
        cf.br ^bb68
      ^bb68:
      %467 = arith.addi %452, %444 : index
      cf.br ^bb63(%467 : index)
    ^bb65(%468: index):
    %469 = arith.constant 0 : i32
    %470 = arith.extsi %469 : i32 to i64
    %471 = llvm.mlir.constant(1 : i64) : i64
    %472 = llvm.alloca %471 x i64 : (i64) -> !llvm.ptr
    llvm.store %470, %472 : i64, !llvm.ptr
    %473 = arith.constant 1 : i32
    %474 = arith.constant 1 : i32
    %476 = arith.extsi %474 : i32 to i64
    %475 = arith.addi %285, %476 : i64
    %477 = arith.index_cast %473 : i32 to index
    %478 = arith.index_cast %475 : i32 to index
    %480 = arith.constant 1 : index
    %481 = arith.constant -1 : index
    %482 = arith.cmpi sle, %477, %478 : index
    %479 = arith.select %482, %480, %481 : index
    cf.br ^bb69(%477 : index)
    ^bb69(%483: index):
    %484 = arith.cmpi slt, %483, %478 : index
    %485 = arith.cmpi sgt, %483, %478 : index
    %486 = arith.select %482, %484, %485 : i1
    cf.cond_br %486, ^bb70(%483 : index), ^bb71(%483 : index)
    ^bb70(%487: index):
      %488 = llvm.load %472 : !llvm.ptr -> i64
      %490 = llvm.load %295 : !llvm.ptr -> !llvm.ptr
      %491 = arith.index_cast %487 : index to i64
      %492 = llvm.getelementptr %490[%491] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %489 = llvm.load %492 : !llvm.ptr -> i64
      %493 = arith.addi %488, %489 : i64
      %494 = llvm.mlir.addressof @MOD : !llvm.ptr
      %495 = llvm.load %494 : !llvm.ptr -> i64
      %496 = arith.remsi %493, %495 : i64
      llvm.store %496, %472 : i64, !llvm.ptr
      %497 = arith.addi %487, %479 : index
      cf.br ^bb69(%497 : index)
    ^bb71(%498: index):
    %500 = llvm.load %295 : !llvm.ptr -> !llvm.ptr
    func.call @free(%500) : (!llvm.ptr) -> ()
    %502 = llvm.load %324 : !llvm.ptr -> !llvm.ptr
    func.call @free(%502) : (!llvm.ptr) -> ()
    %504 = llvm.load %403 : !llvm.ptr -> !llvm.ptr
    func.call @free(%504) : (!llvm.ptr) -> ()
    %505 = llvm.load %472 : !llvm.ptr -> i64
    %506 = llvm.mlir.addressof @MOD : !llvm.ptr
    %507 = llvm.load %506 : !llvm.ptr -> i64
    %508 = arith.remsi %285, %507 : i64
    %509 = arith.subi %505, %508 : i64
    %510 = llvm.mlir.addressof @MOD : !llvm.ptr
    %511 = llvm.load %510 : !llvm.ptr -> i64
    %512 = arith.addi %509, %511 : i64
    %513 = llvm.mlir.addressof @MOD : !llvm.ptr
    %514 = llvm.load %513 : !llvm.ptr -> i64
    %515 = arith.remsi %512, %514 : i64
    func.return %515 : i64
  }
  func.func @main() -> i32 {
    %516 = llvm.mlir.addressof @str_0 : !llvm.ptr
    %518 = arith.constant 10000000 : i32
    %519 = arith.extsi %518 : i32 to i64
    %517 = func.call @total_roundness_factorial(%519) : (i64) -> i64
    %520 = llvm.call @printf(%516, %517) vararg(!llvm.func<i32 (ptr, ...)>) : (!llvm.ptr, i64) -> i32
    %521 = arith.constant 0 : i32
    func.return %521 : i32
  }
}