Problem 478

Mixtures E(10^7) mod 11^8 via Möbius / Mertens direction counts.

Answer59510340
Output59510340
StatusPASS
Native helperno
Runtime2450 ms
Peak memory160080 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 478
# Mixtures
# E(10^7) mod 11^8 via Möbius / Mertens direction counts.

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

const MOD: i64 = 214358881
const PHI_MOD: i64 = 389743420
const N: i64 = 10000000

let mut MERTENS: ptr<i32> = null

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

function F(s: i64, n: i64) -> i64 {
    let mut ret: i64 = 0
    let mut i: i64 = 1
    while i * s <= n {
        let j: i64 = n / (n / i) + 1
        let t: i64 = n / i
        let d: i64 = t / s
        let mut expr: i64 = (2 * (t % PHI_MOD) % PHI_MOD + 2 - s * (1 + d)) % PHI_MOD
        if expr < 0 { expr = expr + PHI_MOD }
        let g: i64 = expr * d % PHI_MOD / 2
        let dm: i64 = (MERTENS[j - 1] as i64) - (MERTENS[i - 1] as i64)
        ret = ret + g * dm % PHI_MOD
        i = j
    }
    ret = ret % PHI_MOD
    if ret < 0 { ret = ret + PHI_MOD }
    return ret
}

function main() -> i32 {
    let lp: ptr<i32> = calloc(N + 1, 4)
    let mu: ptr<i32> = calloc(N + 1, 4)
    let phi: ptr<i32> = calloc(N + 1, 4)
    MERTENS = calloc(N + 1, 4)
    let primes: ptr<i32> = calloc(N / 5 + 10, 4)
    if lp == null || mu == null || phi == null || MERTENS == null || primes == null { return 1 }

    mu[1] = 1
    phi[1] = 1
    let mut pc: i64 = 0
    let mut i: i64 = 2
    while i <= N {
        if lp[i] == 0 {
            lp[i] = i as i32
            primes[pc] = i as i32
            pc = pc + 1
            mu[i] = -1
            phi[i] = (i - 1) as i32
        }
        let mut j: i64 = 0
        while j < pc {
            let p: i64 = primes[j] as i64
            if p > (lp[i] as i64) { break }
            if i * p > N { break }
            lp[i * p] = p as i32
            if p == (lp[i] as i64) {
                mu[i * p] = 0
                phi[i * p] = (phi[i] as i64 * p) as i32
                break
            } else {
                mu[i * p] = (0 - (mu[i] as i64)) as i32
                phi[i * p] = (phi[i] as i64 * (p - 1)) as i32
            }
            j = j + 1
        }
        i = i + 1
    }

    i = 1
    while i <= N {
        MERTENS[i] = (MERTENS[i - 1] as i64 + mu[i] as i64) as i32
        i = i + 1
    }

    let mut total: i64 = 0
    i = 1
    while i <= N {
        let x: i64 = N / i + 1
        let cube: i64 = x * x % PHI_MOD * x % PHI_MOD
        let mut term: i64 = (cube - 1) % PHI_MOD
        if term < 0 { term = term + PHI_MOD }
        total = total + (mu[i] as i64) * term % PHI_MOD
        i = i + 1
    }
    total = total % PHI_MOD
    if total < 0 { total = total + PHI_MOD }

    let mut ans: i64 = modpow(2, total, MOD)
    let e1: i64 = (total - 1) / 2
    let pow_e1: i64 = modpow(2, e1, MOD)
    let mut b: i64 = 1
    while b <= N {
        let M: i64 = 6 * (phi[b] as i64)
        let f: i64 = F(b, N)
        let e2: i64 = e1 - f + PHI_MOD
        let mut term2: i64 = (pow_e1 - modpow(2, e2, MOD)) % MOD
        if term2 < 0 { term2 = term2 + MOD }
        ans = ans - (M % MOD) * term2 % MOD
        ans = ans % MOD
        if ans < 0 { ans = ans + MOD }
        b = b + 1
    }
    ans = ans - 1
    ans = ans % MOD
    if ans < 0 { ans = ans + MOD }
    printf("%lld\n", ans)

    free(primes)
    free(MERTENS)
    MERTENS = null
    free(phi)
    free(mu)
    free(lp)
    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 m);
int64_t F_i64_i64(int64_t s, int64_t n);
int32_t main(void);

static const int64_t MOD = 214358881;
static const int64_t PHI_MOD = 389743420;
static const int64_t N = 10000000;

/* Module statics */
static int32_t* MERTENS = NULL;



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

int64_t F_i64_i64(int64_t s, int64_t n) {
    int64_t ret = 0;
    int64_t i = 1;
    while ((i * s) <= n) {
        int64_t j = (FLOW_CHECKED_DIV((n), (FLOW_CHECKED_DIV((n), (i)))) + 1);
        int64_t t = FLOW_CHECKED_DIV((n), (i));
        int64_t d = FLOW_CHECKED_DIV((t), (s));
        int64_t expr = FLOW_CHECKED_MOD((((FLOW_CHECKED_MOD(((2 * FLOW_CHECKED_MOD((t), (PHI_MOD)))), (PHI_MOD)) + 2) - (s * (1 + d)))), (PHI_MOD));
        if (expr < 0) {
            expr = (expr + PHI_MOD);
        }
        int64_t g = FLOW_CHECKED_DIV((FLOW_CHECKED_MOD(((expr * d)), (PHI_MOD))), (2));
        int64_t dm = (((int64_t)(MERTENS[(j - 1)])) - ((int64_t)(MERTENS[(i - 1)])));
        ret = (ret + FLOW_CHECKED_MOD(((g * dm)), (PHI_MOD)));
        i = j;
    }
    ret = FLOW_CHECKED_MOD((ret), (PHI_MOD));
    if (ret < 0) {
        ret = (ret + PHI_MOD);
    }
    return ret;
}

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