Problem 146

Sum of n < 150e6 such that n^2+1,3,7,9,13,27 are consecutive primes.

Answer676333270
Output676333270
StatusPASS
Native helperno
Runtime570 ms
Peak memory1200 KB
Time complexityO(n^3) (estimated)
Space complexityO(1) (estimated)

Performance comparison

MetricOur solutionBest known
Time complexityO(n^3)O(n log log n)
Space complexityO(1)O(n)
ApproachFlow solutionSieve of Eratosthenes
VerdictSuboptimal

Flow source

# Project Euler 146
# Sum of n < 150e6 such that n^2+1,3,7,9,13,27 are consecutive primes.

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

function mod_mul(a: i64, b: i64, mod: i64) -> i64 {
    let mut res: i64 = 0
    let mut x: i64 = a % mod
    let mut y: i64 = b
    if x < 0 { x = x + mod }
    while y > 0 {
        if y % 2 == 1 {
            res = res + x
            if res >= mod || res < 0 { res = res - mod }
            if res < 0 { res = res + mod }
        }
        x = x + x
        if x >= mod || x < 0 { x = x - mod }
        if x < 0 { x = x + mod }
        y = y / 2
    }
    return res
}

function mod_pow(base: i64, exp: i64, mod: i64) -> i64 {
    let mut r: i64 = 1
    let mut b: i64 = base % mod
    let mut e: i64 = exp
    while e > 0 {
        if e % 2 == 1 { r = mod_mul(r, b, mod) }
        b = mod_mul(b, b, mod)
        e = e / 2
    }
    return r
}

function miller_rabin(n: i64) -> bool {
    if n < 2 { return false }
    if n % 2 == 0 { return n == 2 }
    if n == 3 || n == 5 || n == 7 || n == 11 || n == 13 || n == 17 || n == 19 || n == 23 { return true }
    if n % 3 == 0 || n % 5 == 0 || n % 7 == 0 || n % 11 == 0 || n % 13 == 0 || n % 17 == 0 || n % 19 == 0 || n % 23 == 0 {
        return false
    }

    let mut d: i64 = n - 1
    let mut s: i32 = 0
    while d % 2 == 0 {
        d = d / 2
        s = s + 1
    }

    # deterministic for n < 3.825e18
    let mut bi: i32 = 0
    while bi < 7 {
        let mut a: i64 = 2
        if bi == 1 { a = 325 }
        if bi == 2 { a = 9375 }
        if bi == 3 { a = 28178 }
        if bi == 4 { a = 450775 }
        if bi == 5 { a = 9780504 }
        if bi == 6 { a = 1795265022 }
        if a % n == 0 {
            bi = bi + 1
            continue
        }
        let mut x: i64 = mod_pow(a, d, n)
        let mut ok: bool = (x == 1 || x == n - 1)
        if !ok {
            let mut r: i32 = 1
            while r < s {
                x = mod_mul(x, x, n)
                if x == n - 1 { ok = true; break }
                if x == 1 { return false }
                r = r + 1
            }
        }
        if !ok { return false }
        bi = bi + 1
    }
    return true
}

function main() -> i32 {
    let limit: i64 = 150000000

    # small primes < 500 for sieving the pattern
    let primes: ptr<i64> = calloc(200, 8)
    if primes == null { return 1 }
    primes[0] = 2
    let mut pc: i32 = 1
    let mut i: i64 = 3
    while i < 500 {
        let mut ok: bool = true
        let mut j: i32 = 0
        while j < pc {
            let p: i64 = primes[j]
            if p * p > i { break }
            if i % p == 0 { ok = false; break }
            j = j + 1
        }
        if ok {
            primes[pc] = i
            pc = pc + 1
        }
        i = i + 2
    }

    let good: ptr<i64> = calloc(6, 8)
    good[0] = 1
    good[1] = 3
    good[2] = 7
    good[3] = 9
    good[4] = 13
    good[5] = 27

    let mut total: i64 = 0
    let mut n: i64 = 10
    while n < limit {
        let sq: i64 = n * n
        if sq % 3 != 0 && sq % 7 != 0 && sq % 13 != 0 {
            let mut ok: bool = true
            let mut pi: i32 = 0
            while pi < pc && ok {
                let p: i64 = primes[pi]
                let mut g: i32 = 0
                while g < 6 {
                    let current: i64 = sq + good[g]
                    if current != p && current % p == 0 {
                        ok = false
                        break
                    }
                    g = g + 1
                }
                pi = pi + 1
            }
            if ok {
                if miller_rabin(sq + 1) && miller_rabin(sq + 3) && miller_rabin(sq + 7) && miller_rabin(sq + 9) && miller_rabin(sq + 13) && miller_rabin(sq + 27) {
                    if !miller_rabin(sq + 5) && !miller_rabin(sq + 11) && !miller_rabin(sq + 15) && !miller_rabin(sq + 17) && !miller_rabin(sq + 19) && !miller_rabin(sq + 21) && !miller_rabin(sq + 23) && !miller_rabin(sq + 25) {
                        total = total + n
                    }
                }
            }
        }
        n = n + 10
    }

    printf("%lld\n", total)
    free(good)
    free(primes)
    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 mod_mul_i64_i64_i64(int64_t a, int64_t b, int64_t mod);
int64_t mod_pow_i64_i64_i64(int64_t base, int64_t exp, int64_t mod);
bool miller_rabin_i64(int64_t n);
int32_t main(void);



int64_t mod_mul_i64_i64_i64(int64_t a, int64_t b, int64_t mod) {
    int64_t res = 0;
    int64_t x = FLOW_CHECKED_MOD((a), (mod));
    int64_t y = b;
    if (x < 0) {
        x = (x + mod);
    }
    while (y > 0) {
        if (FLOW_CHECKED_MOD((y), (2)) == 1) {
            res = (res + x);
            if ((res >= mod || res < 0)) {
                res = (res - mod);
            }
            if (res < 0) {
                res = (res + mod);
            }
        }
        x = (x + x);
        if ((x >= mod || x < 0)) {
            x = (x - mod);
        }
        if (x < 0) {
            x = (x + mod);
        }
        y = FLOW_CHECKED_DIV((y), (2));
    }
    return res;
}

int64_t mod_pow_i64_i64_i64(int64_t base, int64_t exp, int64_t mod) {
    int64_t r = 1;
    int64_t b = FLOW_CHECKED_MOD((base), (mod));
    int64_t e = exp;
    while (e > 0) {
        if (FLOW_CHECKED_MOD((e), (2)) == 1) {
            r = mod_mul_i64_i64_i64(r, b, mod);
        }
        b = mod_mul_i64_i64_i64(b, b, mod);
        e = FLOW_CHECKED_DIV((e), (2));
    }
    return r;
}

bool miller_rabin_i64(int64_t n) {
    if (n < 2) {
        return 0;
    }
    if (FLOW_CHECKED_MOD((n), (2)) == 0) {
        return n == 2;
    }
    if ((((((((n == 3 || n == 5) || n == 7) || n == 11) || n == 13) || n == 17) || n == 19) || n == 23)) {
        return 1;
    }
    if ((((((((FLOW_CHECKED_MOD((n), (3)) == 0 || FLOW_CHECKED_MOD((n), (5)) == 0) || FLOW_CHECKED_MOD((n), (7)) == 0) || FLOW_CHECKED_MOD((n), (11)) == 0) || FLOW_CHECKED_MOD((n), (13)) == 0) || FLOW_CHECKED_MOD((n), (17)) == 0) || FLOW_CHECKED_MOD((n), (19)) == 0) || FLOW_CHECKED_MOD((n), (23)) == 0)) {
        return 0;
    }
    int64_t d = (n - 1);
    int32_t s = 0;
    while (FLOW_CHECKED_MOD((d), (2)) == 0) {
        d = FLOW_CHECKED_DIV((d), (2));
        s = (s + 1);
    }
    int32_t bi = 0;
    while (bi < 7) {
        int64_t a = 2;
        if (bi == 1) {
            a = 325;
        }
        if (bi == 2) {
            a = 9375;
        }
        if (bi == 3) {
            a = 28178;
        }
        if (bi == 4) {
            a = 450775;
        }
        if (bi == 5) {
            a = 9780504;
        }
        if (bi == 6) {
            a = 1795265022;
        }
        if (FLOW_CHECKED_MOD((a), (n)) == 0) {
            bi = (bi + 1);
            continue;
        }
        int64_t x = mod_pow_i64_i64_i64(a, d, n);
        bool ok = (x == 1 || x == (n - 1));
        if ((!(ok))) {
            int32_t r = 1;
            while (r < s) {
                x = mod_mul_i64_i64_i64(x, x, n);
                if (x == (n - 1)) {
                    ok = 1;
                    break;
                }
                if (x == 1) {
                    return 0;
                }
                r = (r + 1);
            }
        }
        if ((!(ok))) {
            return 0;
        }
        bi = (bi + 1);
    }
    return 1;
}

int32_t main(void) {
    int64_t limit = 150000000;
    int64_t* primes = (int64_t*)(calloc(200, 8));
    if (primes == NULL) {
        return 1;
    }
    primes[0] = 2;
    int32_t pc = 1;
    int64_t i = 3;
    while (i < 500) {
        bool ok = 1;
        int32_t j = 0;
        while (j < pc) {
            int64_t p = primes[j];
            if ((p * p) > i) {
                break;
            }
            if (FLOW_CHECKED_MOD((i), (p)) == 0) {
                ok = 0;
                break;
            }
            j = (j + 1);
        }
        if (ok) {
            primes[pc] = i;
            pc = (pc + 1);
        }
        i = (i + 2);
    }
    int64_t* good = (int64_t*)(calloc(6, 8));
    good[0] = 1;
    good[1] = 3;
    good[2] = 7;
    good[3] = 9;
    good[4] = 13;
    good[5] = 27;
    int64_t total = 0;
    int64_t n = 10;
    while (n < limit) {
        int64_t sq = (n * n);
        if (((FLOW_CHECKED_MOD((sq), (3)) != 0 && FLOW_CHECKED_MOD((sq), (7)) != 0) && FLOW_CHECKED_MOD((sq), (13)) != 0)) {
            bool ok = 1;
            int32_t pi = 0;
            while ((pi < pc && ok)) {
                int64_t p = primes[pi];
                int32_t g = 0;
                while (g < 6) {
                    int64_t current = (sq + good[g]);
                    if ((current != p && FLOW_CHECKED_MOD((current), (p)) == 0)) {
                        ok = 0;
                        break;
                    }
                    g = (g + 1);
                }
                pi = (pi + 1);
            }
            if (ok) {
                if ((((((miller_rabin_i64((sq + 1)) && miller_rabin_i64((sq + 3))) && miller_rabin_i64((sq + 7))) && miller_rabin_i64((sq + 9))) && miller_rabin_i64((sq + 13))) && miller_rabin_i64((sq + 27)))) {
                    if (((((((((!(miller_rabin_i64((sq + 5)))) && (!(miller_rabin_i64((sq + 11))))) && (!(miller_rabin_i64((sq + 15))))) && (!(miller_rabin_i64((sq + 17))))) && (!(miller_rabin_i64((sq + 19))))) && (!(miller_rabin_i64((sq + 21))))) && (!(miller_rabin_i64((sq + 23))))) && (!(miller_rabin_i64((sq + 25)))))) {
                        total = (total + n);
                    }
                }
            }
        }
        n = (n + 10);
    }
    printf("%lld\n", total);
    free(good);
    free(primes);
    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 @mod_mul(%arg0: i64, %arg1: i64, %arg2: i64) -> i64 {
    %0 = arith.constant 0 : 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
    %9 = llvm.load %6 : !llvm.ptr -> i64
    %10 = arith.constant 0 : i32
    %12 = arith.extsi %10 : i32 to i64
    %11 = arith.cmpi slt, %9, %12 : i64
    cf.cond_br %11, ^bb0, ^bb1
    ^bb0:
      %13 = llvm.load %6 : !llvm.ptr -> i64
      %14 = arith.addi %13, %arg2 : i64
      llvm.store %14, %6 : i64, !llvm.ptr
      cf.br ^bb2
    ^bb1:
      cf.br ^bb2
    ^bb2:
    cf.br ^bb3
    ^bb3:
    %15 = llvm.load %8 : !llvm.ptr -> i64
    %16 = arith.constant 0 : i32
    %18 = arith.extsi %16 : i32 to i64
    %17 = arith.cmpi sgt, %15, %18 : i64
    cf.cond_br %17, ^bb4, ^bb5
    ^bb4:
      %19 = llvm.load %8 : !llvm.ptr -> i64
      %20 = arith.constant 2 : i32
      %22 = arith.extsi %20 : i32 to i64
      %21 = arith.remsi %19, %22 : i64
      %23 = arith.constant 1 : i32
      %25 = arith.extsi %23 : i32 to i64
      %24 = arith.cmpi eq, %21, %25 : i64
      cf.cond_br %24, ^bb6, ^bb7
      ^bb6:
        %26 = llvm.load %3 : !llvm.ptr -> i64
        %27 = llvm.load %6 : !llvm.ptr -> i64
        %28 = arith.addi %26, %27 : i64
        llvm.store %28, %3 : i64, !llvm.ptr
        %29 = llvm.load %3 : !llvm.ptr -> i64
        %30 = arith.cmpi sge, %29, %arg2 : i64
        %31 = scf.if %30 -> (i1) {
          %32 = arith.constant true
          scf.yield %32 : i1
        } else {
          %33 = llvm.load %3 : !llvm.ptr -> i64
          %34 = arith.constant 0 : i32
          %36 = arith.extsi %34 : i32 to i64
          %35 = arith.cmpi slt, %33, %36 : i64
          scf.yield %35 : i1
        }
        cf.cond_br %31, ^bb9, ^bb10
        ^bb9:
          %37 = llvm.load %3 : !llvm.ptr -> i64
          %38 = arith.subi %37, %arg2 : i64
          llvm.store %38, %3 : i64, !llvm.ptr
          cf.br ^bb11
        ^bb10:
          cf.br ^bb11
        ^bb11:
        %39 = llvm.load %3 : !llvm.ptr -> i64
        %40 = arith.constant 0 : i32
        %42 = arith.extsi %40 : i32 to i64
        %41 = arith.cmpi slt, %39, %42 : i64
        cf.cond_br %41, ^bb12, ^bb13
        ^bb12:
          %43 = llvm.load %3 : !llvm.ptr -> i64
          %44 = arith.addi %43, %arg2 : i64
          llvm.store %44, %3 : i64, !llvm.ptr
          cf.br ^bb14
        ^bb13:
          cf.br ^bb14
        ^bb14:
        cf.br ^bb8
      ^bb7:
        cf.br ^bb8
      ^bb8:
      %45 = llvm.load %6 : !llvm.ptr -> i64
      %46 = llvm.load %6 : !llvm.ptr -> i64
      %47 = arith.addi %45, %46 : i64
      llvm.store %47, %6 : i64, !llvm.ptr
      %48 = llvm.load %6 : !llvm.ptr -> i64
      %49 = arith.cmpi sge, %48, %arg2 : i64
      %50 = scf.if %49 -> (i1) {
        %51 = arith.constant true
        scf.yield %51 : i1
      } else {
        %52 = llvm.load %6 : !llvm.ptr -> i64
        %53 = arith.constant 0 : i32
        %55 = arith.extsi %53 : i32 to i64
        %54 = arith.cmpi slt, %52, %55 : i64
        scf.yield %54 : i1
      }
      cf.cond_br %50, ^bb15, ^bb16
      ^bb15:
        %56 = llvm.load %6 : !llvm.ptr -> i64
        %57 = arith.subi %56, %arg2 : i64
        llvm.store %57, %6 : i64, !llvm.ptr
        cf.br ^bb17
      ^bb16:
        cf.br ^bb17
      ^bb17:
      %58 = llvm.load %6 : !llvm.ptr -> i64
      %59 = arith.constant 0 : i32
      %61 = arith.extsi %59 : i32 to i64
      %60 = arith.cmpi slt, %58, %61 : i64
      cf.cond_br %60, ^bb18, ^bb19
      ^bb18:
        %62 = llvm.load %6 : !llvm.ptr -> i64
        %63 = arith.addi %62, %arg2 : i64
        llvm.store %63, %6 : i64, !llvm.ptr
        cf.br ^bb20
      ^bb19:
        cf.br ^bb20
      ^bb20:
      %64 = llvm.load %8 : !llvm.ptr -> i64
      %65 = arith.constant 2 : i32
      %67 = arith.extsi %65 : i32 to i64
      %66 = arith.divsi %64, %67 : i64
      llvm.store %66, %8 : i64, !llvm.ptr
      cf.br ^bb3
    ^bb5:
    %68 = llvm.load %3 : !llvm.ptr -> i64
    func.return %68 : i64
  }
  func.func @mod_pow(%arg0: i64, %arg1: i64, %arg2: i64) -> i64 {
    %69 = arith.constant 1 : i32
    %70 = arith.extsi %69 : i32 to i64
    %71 = llvm.mlir.constant(1 : i64) : i64
    %72 = llvm.alloca %71 x i64 : (i64) -> !llvm.ptr
    llvm.store %70, %72 : i64, !llvm.ptr
    %73 = arith.remsi %arg0, %arg2 : 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.mlir.constant(1 : i64) : i64
    %77 = llvm.alloca %76 x i64 : (i64) -> !llvm.ptr
    llvm.store %arg1, %77 : i64, !llvm.ptr
    cf.br ^bb21
    ^bb21:
    %78 = llvm.load %77 : !llvm.ptr -> i64
    %79 = arith.constant 0 : i32
    %81 = arith.extsi %79 : i32 to i64
    %80 = arith.cmpi sgt, %78, %81 : i64
    cf.cond_br %80, ^bb22, ^bb23
    ^bb22:
      %82 = llvm.load %77 : !llvm.ptr -> i64
      %83 = arith.constant 2 : i32
      %85 = arith.extsi %83 : i32 to i64
      %84 = arith.remsi %82, %85 : i64
      %86 = arith.constant 1 : i32
      %88 = arith.extsi %86 : i32 to i64
      %87 = arith.cmpi eq, %84, %88 : i64
      cf.cond_br %87, ^bb24, ^bb25
      ^bb24:
        %90 = llvm.load %72 : !llvm.ptr -> i64
        %91 = llvm.load %75 : !llvm.ptr -> i64
        %89 = func.call @mod_mul(%90, %91, %arg2) : (i64, i64, i64) -> i64
        llvm.store %89, %72 : i64, !llvm.ptr
        cf.br ^bb26
      ^bb25:
        cf.br ^bb26
      ^bb26:
      %93 = llvm.load %75 : !llvm.ptr -> i64
      %94 = llvm.load %75 : !llvm.ptr -> i64
      %92 = func.call @mod_mul(%93, %94, %arg2) : (i64, i64, i64) -> i64
      llvm.store %92, %75 : i64, !llvm.ptr
      %95 = llvm.load %77 : !llvm.ptr -> i64
      %96 = arith.constant 2 : i32
      %98 = arith.extsi %96 : i32 to i64
      %97 = arith.divsi %95, %98 : i64
      llvm.store %97, %77 : i64, !llvm.ptr
      cf.br ^bb21
    ^bb23:
    %99 = llvm.load %72 : !llvm.ptr -> i64
    func.return %99 : i64
  }
  func.func @miller_rabin(%arg0: i64) -> i1 {
    %100 = arith.constant 2 : i32
    %102 = arith.extsi %100 : i32 to i64
    %101 = arith.cmpi slt, %arg0, %102 : i64
    cf.cond_br %101, ^bb27, ^bb28
    ^bb27:
      %103 = arith.constant 0 : i1
      func.return %103 : i1
    ^bb28:
      cf.br ^bb29
    ^bb29:
    %104 = arith.constant 2 : i32
    %106 = arith.extsi %104 : i32 to i64
    %105 = arith.remsi %arg0, %106 : i64
    %107 = arith.constant 0 : i32
    %109 = arith.extsi %107 : i32 to i64
    %108 = arith.cmpi eq, %105, %109 : i64
    cf.cond_br %108, ^bb30, ^bb31
    ^bb30:
      %110 = arith.constant 2 : i32
      %112 = arith.extsi %110 : i32 to i64
      %111 = arith.cmpi eq, %arg0, %112 : i64
      func.return %111 : i1
    ^bb31:
      cf.br ^bb32
    ^bb32:
    %113 = arith.constant 3 : i32
    %115 = arith.extsi %113 : i32 to i64
    %114 = arith.cmpi eq, %arg0, %115 : i64
    %116 = scf.if %114 -> (i1) {
      %117 = arith.constant true
      scf.yield %117 : i1
    } else {
      %118 = arith.constant 5 : i32
      %120 = arith.extsi %118 : i32 to i64
      %119 = arith.cmpi eq, %arg0, %120 : i64
      scf.yield %119 : i1
    }
    %121 = scf.if %116 -> (i1) {
      %122 = arith.constant true
      scf.yield %122 : i1
    } else {
      %123 = arith.constant 7 : i32
      %125 = arith.extsi %123 : i32 to i64
      %124 = arith.cmpi eq, %arg0, %125 : i64
      scf.yield %124 : i1
    }
    %126 = scf.if %121 -> (i1) {
      %127 = arith.constant true
      scf.yield %127 : i1
    } else {
      %128 = arith.constant 11 : i32
      %130 = arith.extsi %128 : i32 to i64
      %129 = arith.cmpi eq, %arg0, %130 : i64
      scf.yield %129 : i1
    }
    %131 = scf.if %126 -> (i1) {
      %132 = arith.constant true
      scf.yield %132 : i1
    } else {
      %133 = arith.constant 13 : i32
      %135 = arith.extsi %133 : i32 to i64
      %134 = arith.cmpi eq, %arg0, %135 : i64
      scf.yield %134 : i1
    }
    %136 = scf.if %131 -> (i1) {
      %137 = arith.constant true
      scf.yield %137 : i1
    } else {
      %138 = arith.constant 17 : i32
      %140 = arith.extsi %138 : i32 to i64
      %139 = arith.cmpi eq, %arg0, %140 : i64
      scf.yield %139 : i1
    }
    %141 = scf.if %136 -> (i1) {
      %142 = arith.constant true
      scf.yield %142 : i1
    } else {
      %143 = arith.constant 19 : i32
      %145 = arith.extsi %143 : i32 to i64
      %144 = arith.cmpi eq, %arg0, %145 : i64
      scf.yield %144 : i1
    }
    %146 = scf.if %141 -> (i1) {
      %147 = arith.constant true
      scf.yield %147 : i1
    } else {
      %148 = arith.constant 23 : i32
      %150 = arith.extsi %148 : i32 to i64
      %149 = arith.cmpi eq, %arg0, %150 : i64
      scf.yield %149 : i1
    }
    cf.cond_br %146, ^bb33, ^bb34
    ^bb33:
      %151 = arith.constant 1 : i1
      func.return %151 : i1
    ^bb34:
      cf.br ^bb35
    ^bb35:
    %152 = arith.constant 3 : i32
    %154 = arith.extsi %152 : i32 to i64
    %153 = arith.remsi %arg0, %154 : i64
    %155 = arith.constant 0 : i32
    %157 = arith.extsi %155 : i32 to i64
    %156 = arith.cmpi eq, %153, %157 : i64
    %158 = scf.if %156 -> (i1) {
      %159 = arith.constant true
      scf.yield %159 : i1
    } else {
      %160 = arith.constant 5 : i32
      %162 = arith.extsi %160 : i32 to i64
      %161 = arith.remsi %arg0, %162 : i64
      %163 = arith.constant 0 : i32
      %165 = arith.extsi %163 : i32 to i64
      %164 = arith.cmpi eq, %161, %165 : i64
      scf.yield %164 : i1
    }
    %166 = scf.if %158 -> (i1) {
      %167 = arith.constant true
      scf.yield %167 : i1
    } else {
      %168 = arith.constant 7 : i32
      %170 = arith.extsi %168 : i32 to i64
      %169 = arith.remsi %arg0, %170 : i64
      %171 = arith.constant 0 : i32
      %173 = arith.extsi %171 : i32 to i64
      %172 = arith.cmpi eq, %169, %173 : i64
      scf.yield %172 : i1
    }
    %174 = scf.if %166 -> (i1) {
      %175 = arith.constant true
      scf.yield %175 : i1
    } else {
      %176 = arith.constant 11 : i32
      %178 = arith.extsi %176 : i32 to i64
      %177 = arith.remsi %arg0, %178 : i64
      %179 = arith.constant 0 : i32
      %181 = arith.extsi %179 : i32 to i64
      %180 = arith.cmpi eq, %177, %181 : i64
      scf.yield %180 : i1
    }
    %182 = scf.if %174 -> (i1) {
      %183 = arith.constant true
      scf.yield %183 : i1
    } else {
      %184 = arith.constant 13 : i32
      %186 = arith.extsi %184 : i32 to i64
      %185 = arith.remsi %arg0, %186 : i64
      %187 = arith.constant 0 : i32
      %189 = arith.extsi %187 : i32 to i64
      %188 = arith.cmpi eq, %185, %189 : i64
      scf.yield %188 : i1
    }
    %190 = scf.if %182 -> (i1) {
      %191 = arith.constant true
      scf.yield %191 : i1
    } else {
      %192 = arith.constant 17 : i32
      %194 = arith.extsi %192 : i32 to i64
      %193 = arith.remsi %arg0, %194 : i64
      %195 = arith.constant 0 : i32
      %197 = arith.extsi %195 : i32 to i64
      %196 = arith.cmpi eq, %193, %197 : i64
      scf.yield %196 : i1
    }
    %198 = scf.if %190 -> (i1) {
      %199 = arith.constant true
      scf.yield %199 : i1
    } else {
      %200 = arith.constant 19 : i32
      %202 = arith.extsi %200 : i32 to i64
      %201 = arith.remsi %arg0, %202 : i64
      %203 = arith.constant 0 : i32
      %205 = arith.extsi %203 : i32 to i64
      %204 = arith.cmpi eq, %201, %205 : i64
      scf.yield %204 : i1
    }
    %206 = scf.if %198 -> (i1) {
      %207 = arith.constant true
      scf.yield %207 : i1
    } else {
      %208 = arith.constant 23 : i32
      %210 = arith.extsi %208 : i32 to i64
      %209 = arith.remsi %arg0, %210 : i64
      %211 = arith.constant 0 : i32
      %213 = arith.extsi %211 : i32 to i64
      %212 = arith.cmpi eq, %209, %213 : i64
      scf.yield %212 : i1
    }
    cf.cond_br %206, ^bb36, ^bb37
    ^bb36:
      %214 = arith.constant 0 : i1
      func.return %214 : i1
    ^bb37:
      cf.br ^bb38
    ^bb38:
    %215 = arith.constant 1 : i32
    %217 = arith.extsi %215 : i32 to i64
    %216 = arith.subi %arg0, %217 : i64
    %218 = llvm.mlir.constant(1 : i64) : i64
    %219 = llvm.alloca %218 x i64 : (i64) -> !llvm.ptr
    llvm.store %216, %219 : i64, !llvm.ptr
    %220 = arith.constant 0 : i32
    %221 = llvm.mlir.constant(1 : i64) : i64
    %222 = llvm.alloca %221 x i32 : (i64) -> !llvm.ptr
    llvm.store %220, %222 : i32, !llvm.ptr
    cf.br ^bb39
    ^bb39:
    %223 = llvm.load %219 : !llvm.ptr -> i64
    %224 = arith.constant 2 : i32
    %226 = arith.extsi %224 : i32 to i64
    %225 = arith.remsi %223, %226 : i64
    %227 = arith.constant 0 : i32
    %229 = arith.extsi %227 : i32 to i64
    %228 = arith.cmpi eq, %225, %229 : i64
    cf.cond_br %228, ^bb40, ^bb41
    ^bb40:
      %230 = llvm.load %219 : !llvm.ptr -> i64
      %231 = arith.constant 2 : i32
      %233 = arith.extsi %231 : i32 to i64
      %232 = arith.divsi %230, %233 : i64
      llvm.store %232, %219 : i64, !llvm.ptr
      %234 = llvm.load %222 : !llvm.ptr -> i32
      %235 = arith.constant 1 : i32
      %236 = arith.addi %234, %235 : i32
      llvm.store %236, %222 : i32, !llvm.ptr
      cf.br ^bb39
    ^bb41:
    %237 = arith.constant 0 : i32
    %238 = llvm.mlir.constant(1 : i64) : i64
    %239 = llvm.alloca %238 x i32 : (i64) -> !llvm.ptr
    llvm.store %237, %239 : i32, !llvm.ptr
    cf.br ^bb42
    ^bb42:
    %240 = llvm.load %239 : !llvm.ptr -> i32
    %241 = arith.constant 7 : i32
    %242 = arith.cmpi slt, %240, %241 : i32
    cf.cond_br %242, ^bb43, ^bb44
    ^bb43:
      %243 = arith.constant 2 : 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
      %247 = llvm.load %239 : !llvm.ptr -> i32
      %248 = arith.constant 1 : i32
      %249 = arith.cmpi eq, %247, %248 : i32
      cf.cond_br %249, ^bb45, ^bb46
      ^bb45:
        %250 = arith.constant 325 : i32
        %251 = arith.extsi %250 : i32 to i64
        llvm.store %251, %246 : i64, !llvm.ptr
        cf.br ^bb47
      ^bb46:
        cf.br ^bb47
      ^bb47:
      %252 = llvm.load %239 : !llvm.ptr -> i32
      %253 = arith.constant 2 : i32
      %254 = arith.cmpi eq, %252, %253 : i32
      cf.cond_br %254, ^bb48, ^bb49
      ^bb48:
        %255 = arith.constant 9375 : i32
        %256 = arith.extsi %255 : i32 to i64
        llvm.store %256, %246 : i64, !llvm.ptr
        cf.br ^bb50
      ^bb49:
        cf.br ^bb50
      ^bb50:
      %257 = llvm.load %239 : !llvm.ptr -> i32
      %258 = arith.constant 3 : i32
      %259 = arith.cmpi eq, %257, %258 : i32
      cf.cond_br %259, ^bb51, ^bb52
      ^bb51:
        %260 = arith.constant 28178 : i32
        %261 = arith.extsi %260 : i32 to i64
        llvm.store %261, %246 : i64, !llvm.ptr
        cf.br ^bb53
      ^bb52:
        cf.br ^bb53
      ^bb53:
      %262 = llvm.load %239 : !llvm.ptr -> i32
      %263 = arith.constant 4 : i32
      %264 = arith.cmpi eq, %262, %263 : i32
      cf.cond_br %264, ^bb54, ^bb55
      ^bb54:
        %265 = arith.constant 450775 : i32
        %266 = arith.extsi %265 : i32 to i64
        llvm.store %266, %246 : i64, !llvm.ptr
        cf.br ^bb56
      ^bb55:
        cf.br ^bb56
      ^bb56:
      %267 = llvm.load %239 : !llvm.ptr -> i32
      %268 = arith.constant 5 : i32
      %269 = arith.cmpi eq, %267, %268 : i32
      cf.cond_br %269, ^bb57, ^bb58
      ^bb57:
        %270 = arith.constant 9780504 : i32
        %271 = arith.extsi %270 : i32 to i64
        llvm.store %271, %246 : i64, !llvm.ptr
        cf.br ^bb59
      ^bb58:
        cf.br ^bb59
      ^bb59:
      %272 = llvm.load %239 : !llvm.ptr -> i32
      %273 = arith.constant 6 : i32
      %274 = arith.cmpi eq, %272, %273 : i32
      cf.cond_br %274, ^bb60, ^bb61
      ^bb60:
        %275 = arith.constant 1795265022 : i32
        %276 = arith.extsi %275 : i32 to i64
        llvm.store %276, %246 : i64, !llvm.ptr
        cf.br ^bb62
      ^bb61:
        cf.br ^bb62
      ^bb62:
      %277 = llvm.load %246 : !llvm.ptr -> i64
      %278 = arith.remsi %277, %arg0 : i64
      %279 = arith.constant 0 : i32
      %281 = arith.extsi %279 : i32 to i64
      %280 = arith.cmpi eq, %278, %281 : i64
      cf.cond_br %280, ^bb63, ^bb64
      ^bb63:
        %282 = llvm.load %239 : !llvm.ptr -> i32
        %283 = arith.constant 1 : i32
        %284 = arith.addi %282, %283 : i32
        llvm.store %284, %239 : i32, !llvm.ptr
        cf.br ^bb42
      ^bb64:
        cf.br ^bb65
      ^bb65:
      %286 = llvm.load %246 : !llvm.ptr -> i64
      %287 = llvm.load %219 : !llvm.ptr -> i64
      %285 = func.call @mod_pow(%286, %287, %arg0) : (i64, i64, i64) -> i64
      %288 = llvm.mlir.constant(1 : i64) : i64
      %289 = llvm.alloca %288 x i64 : (i64) -> !llvm.ptr
      llvm.store %285, %289 : i64, !llvm.ptr
      %290 = llvm.load %289 : !llvm.ptr -> i64
      %291 = arith.constant 1 : i32
      %293 = arith.extsi %291 : i32 to i64
      %292 = arith.cmpi eq, %290, %293 : i64
      %294 = scf.if %292 -> (i1) {
        %295 = arith.constant true
        scf.yield %295 : i1
      } else {
        %296 = llvm.load %289 : !llvm.ptr -> i64
        %297 = arith.constant 1 : i32
        %299 = arith.extsi %297 : i32 to i64
        %298 = arith.subi %arg0, %299 : i64
        %300 = arith.cmpi eq, %296, %298 : i64
        scf.yield %300 : i1
      }
      %301 = llvm.mlir.constant(1 : i64) : i64
      %302 = llvm.alloca %301 x i1 : (i64) -> !llvm.ptr
      llvm.store %294, %302 : i1, !llvm.ptr
      %303 = llvm.load %302 : !llvm.ptr -> i1
      %305 = arith.constant 1 : i1
      %304 = arith.xori %303, %305 : i1
      cf.cond_br %304, ^bb66, ^bb67
      ^bb66:
        %307 = arith.constant 1 : i32
        %308 = llvm.mlir.constant(1 : i64) : i64
        %309 = llvm.alloca %308 x i32 : (i64) -> !llvm.ptr
        llvm.store %307, %309 : i32, !llvm.ptr
        cf.br ^bb69
        ^bb69:
        %310 = llvm.load %309 : !llvm.ptr -> i32
        %311 = llvm.load %222 : !llvm.ptr -> i32
        %312 = arith.cmpi slt, %310, %311 : i32
        cf.cond_br %312, ^bb70, ^bb71
        ^bb70:
          %314 = llvm.load %289 : !llvm.ptr -> i64
          %315 = llvm.load %289 : !llvm.ptr -> i64
          %313 = func.call @mod_mul(%314, %315, %arg0) : (i64, i64, i64) -> i64
          llvm.store %313, %289 : i64, !llvm.ptr
          %316 = llvm.load %289 : !llvm.ptr -> i64
          %317 = arith.constant 1 : i32
          %319 = arith.extsi %317 : i32 to i64
          %318 = arith.subi %arg0, %319 : i64
          %320 = arith.cmpi eq, %316, %318 : i64
          cf.cond_br %320, ^bb72, ^bb73
          ^bb72:
            %321 = arith.constant 1 : i1
            llvm.store %321, %302 : i1, !llvm.ptr
            cf.br ^bb71
          ^bb73:
            cf.br ^bb74
          ^bb74:
          %322 = llvm.load %289 : !llvm.ptr -> i64
          %323 = arith.constant 1 : i32
          %325 = arith.extsi %323 : i32 to i64
          %324 = arith.cmpi eq, %322, %325 : i64
          cf.cond_br %324, ^bb75, ^bb76
          ^bb75:
            %326 = arith.constant 0 : i1
            func.return %326 : i1
          ^bb76:
            cf.br ^bb77
          ^bb77:
          %327 = llvm.load %309 : !llvm.ptr -> i32
          %328 = arith.constant 1 : i32
          %329 = arith.addi %327, %328 : i32
          llvm.store %329, %309 : i32, !llvm.ptr
          cf.br ^bb69
        ^bb71:
        cf.br ^bb68
      ^bb67:
        cf.br ^bb68
      ^bb68:
      %330 = llvm.load %302 : !llvm.ptr -> i1
      %332 = arith.constant 1 : i1
      %331 = arith.xori %330, %332 : i1
      cf.cond_br %331, ^bb78, ^bb79
      ^bb78:
        %334 = arith.constant 0 : i1
        func.return %334 : i1
      ^bb79:
        cf.br ^bb80
      ^bb80:
      %335 = llvm.load %239 : !llvm.ptr -> i32
      %336 = arith.constant 1 : i32
      %337 = arith.addi %335, %336 : i32
      llvm.store %337, %239 : i32, !llvm.ptr
      cf.br ^bb42
    ^bb44:
    %338 = arith.constant 1 : i1
    func.return %338 : i1
  }
  func.func @main() -> i32 {
    %339 = arith.constant 150000000 : i32
    %340 = arith.extsi %339 : i32 to i64
    %342 = arith.constant 200 : i32
    %343 = arith.constant 8 : i32
    %344 = arith.extsi %342 : i32 to i64
    %345 = arith.extsi %343 : i32 to i64
    %341 = func.call @calloc(%344, %345) : (i64, i64) -> !llvm.ptr
    %346 = llvm.mlir.zero : !llvm.ptr
    %347 = llvm.icmp "eq" %341, %346 : !llvm.ptr
    cf.cond_br %347, ^bb81, ^bb82
    ^bb81:
      %348 = arith.constant 1 : i32
      func.return %348 : i32
    ^bb82:
      cf.br ^bb83
    ^bb83:
    %349 = arith.constant 2 : i32
    %350 = arith.constant 0 : i32
    %351 = arith.extsi %349 : i32 to i64
    %352 = arith.extsi %350 : i32 to i64
    %353 = llvm.getelementptr %341[%352] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    llvm.store %351, %353 : i64, !llvm.ptr
    %354 = arith.constant 1 : i32
    %355 = llvm.mlir.constant(1 : i64) : i64
    %356 = llvm.alloca %355 x i32 : (i64) -> !llvm.ptr
    llvm.store %354, %356 : i32, !llvm.ptr
    %357 = arith.constant 3 : i32
    %358 = arith.extsi %357 : i32 to i64
    %359 = llvm.mlir.constant(1 : i64) : i64
    %360 = llvm.alloca %359 x i64 : (i64) -> !llvm.ptr
    llvm.store %358, %360 : i64, !llvm.ptr
    cf.br ^bb84
    ^bb84:
    %361 = llvm.load %360 : !llvm.ptr -> i64
    %362 = arith.constant 500 : i32
    %364 = arith.extsi %362 : i32 to i64
    %363 = arith.cmpi slt, %361, %364 : i64
    cf.cond_br %363, ^bb85, ^bb86
    ^bb85:
      %365 = arith.constant 1 : i1
      %366 = llvm.mlir.constant(1 : i64) : i64
      %367 = llvm.alloca %366 x i1 : (i64) -> !llvm.ptr
      llvm.store %365, %367 : i1, !llvm.ptr
      %368 = arith.constant 0 : i32
      %369 = llvm.mlir.constant(1 : i64) : i64
      %370 = llvm.alloca %369 x i32 : (i64) -> !llvm.ptr
      llvm.store %368, %370 : i32, !llvm.ptr
      cf.br ^bb87
      ^bb87:
      %371 = llvm.load %370 : !llvm.ptr -> i32
      %372 = llvm.load %356 : !llvm.ptr -> i32
      %373 = arith.cmpi slt, %371, %372 : i32
      cf.cond_br %373, ^bb88, ^bb89
      ^bb88:
        %375 = llvm.load %370 : !llvm.ptr -> i32
        %376 = arith.extsi %375 : i32 to i64
        %377 = llvm.getelementptr %341[%376] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %374 = llvm.load %377 : !llvm.ptr -> i64
        %378 = arith.muli %374, %374 : i64
        %379 = llvm.load %360 : !llvm.ptr -> i64
        %380 = arith.cmpi sgt, %378, %379 : i64
        cf.cond_br %380, ^bb90, ^bb91
        ^bb90:
          cf.br ^bb89
        ^bb91:
          cf.br ^bb92
        ^bb92:
        %381 = llvm.load %360 : !llvm.ptr -> i64
        %382 = arith.remsi %381, %374 : i64
        %383 = arith.constant 0 : i32
        %385 = arith.extsi %383 : i32 to i64
        %384 = arith.cmpi eq, %382, %385 : i64
        cf.cond_br %384, ^bb93, ^bb94
        ^bb93:
          %386 = arith.constant 0 : i1
          llvm.store %386, %367 : i1, !llvm.ptr
          cf.br ^bb89
        ^bb94:
          cf.br ^bb95
        ^bb95:
        %387 = llvm.load %370 : !llvm.ptr -> i32
        %388 = arith.constant 1 : i32
        %389 = arith.addi %387, %388 : i32
        llvm.store %389, %370 : i32, !llvm.ptr
        cf.br ^bb87
      ^bb89:
      %390 = llvm.load %367 : !llvm.ptr -> i1
      cf.cond_br %390, ^bb96, ^bb97
      ^bb96:
        %391 = llvm.load %360 : !llvm.ptr -> i64
        %392 = llvm.load %356 : !llvm.ptr -> i32
        %393 = arith.extsi %392 : i32 to i64
        %394 = llvm.getelementptr %341[%393] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        llvm.store %391, %394 : i64, !llvm.ptr
        %395 = llvm.load %356 : !llvm.ptr -> i32
        %396 = arith.constant 1 : i32
        %397 = arith.addi %395, %396 : i32
        llvm.store %397, %356 : i32, !llvm.ptr
        cf.br ^bb98
      ^bb97:
        cf.br ^bb98
      ^bb98:
      %398 = llvm.load %360 : !llvm.ptr -> i64
      %399 = arith.constant 2 : i32
      %401 = arith.extsi %399 : i32 to i64
      %400 = arith.addi %398, %401 : i64
      llvm.store %400, %360 : i64, !llvm.ptr
      cf.br ^bb84
    ^bb86:
    %403 = arith.constant 6 : i32
    %404 = arith.constant 8 : i32
    %405 = arith.extsi %403 : i32 to i64
    %406 = arith.extsi %404 : i32 to i64
    %402 = func.call @calloc(%405, %406) : (i64, i64) -> !llvm.ptr
    %407 = arith.constant 1 : i32
    %408 = arith.constant 0 : i32
    %409 = arith.extsi %407 : i32 to i64
    %410 = arith.extsi %408 : i32 to i64
    %411 = llvm.getelementptr %402[%410] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    llvm.store %409, %411 : i64, !llvm.ptr
    %412 = arith.constant 3 : i32
    %413 = arith.constant 1 : i32
    %414 = arith.extsi %412 : i32 to i64
    %415 = arith.extsi %413 : i32 to i64
    %416 = llvm.getelementptr %402[%415] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    llvm.store %414, %416 : i64, !llvm.ptr
    %417 = arith.constant 7 : i32
    %418 = arith.constant 2 : i32
    %419 = arith.extsi %417 : i32 to i64
    %420 = arith.extsi %418 : i32 to i64
    %421 = llvm.getelementptr %402[%420] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    llvm.store %419, %421 : i64, !llvm.ptr
    %422 = arith.constant 9 : i32
    %423 = arith.constant 3 : i32
    %424 = arith.extsi %422 : i32 to i64
    %425 = arith.extsi %423 : i32 to i64
    %426 = llvm.getelementptr %402[%425] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    llvm.store %424, %426 : i64, !llvm.ptr
    %427 = arith.constant 13 : i32
    %428 = arith.constant 4 : i32
    %429 = arith.extsi %427 : i32 to i64
    %430 = arith.extsi %428 : i32 to i64
    %431 = llvm.getelementptr %402[%430] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    llvm.store %429, %431 : i64, !llvm.ptr
    %432 = arith.constant 27 : i32
    %433 = arith.constant 5 : i32
    %434 = arith.extsi %432 : i32 to i64
    %435 = arith.extsi %433 : i32 to i64
    %436 = llvm.getelementptr %402[%435] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    llvm.store %434, %436 : i64, !llvm.ptr
    %437 = arith.constant 0 : i32
    %438 = arith.extsi %437 : i32 to i64
    %439 = llvm.mlir.constant(1 : i64) : i64
    %440 = llvm.alloca %439 x i64 : (i64) -> !llvm.ptr
    llvm.store %438, %440 : i64, !llvm.ptr
    %441 = arith.constant 10 : i32
    %442 = arith.extsi %441 : i32 to i64
    %443 = llvm.mlir.constant(1 : i64) : i64
    %444 = llvm.alloca %443 x i64 : (i64) -> !llvm.ptr
    llvm.store %442, %444 : i64, !llvm.ptr
    cf.br ^bb99
    ^bb99:
    %445 = llvm.load %444 : !llvm.ptr -> i64
    %446 = arith.cmpi slt, %445, %340 : i64
    cf.cond_br %446, ^bb100, ^bb101
    ^bb100:
      %447 = llvm.load %444 : !llvm.ptr -> i64
      %448 = llvm.load %444 : !llvm.ptr -> i64
      %449 = arith.muli %447, %448 : i64
      %450 = arith.constant 3 : i32
      %452 = arith.extsi %450 : i32 to i64
      %451 = arith.remsi %449, %452 : i64
      %453 = arith.constant 0 : i32
      %455 = arith.extsi %453 : i32 to i64
      %454 = arith.cmpi ne, %451, %455 : i64
      %456 = scf.if %454 -> (i1) {
        %457 = arith.constant 7 : i32
        %459 = arith.extsi %457 : i32 to i64
        %458 = arith.remsi %449, %459 : i64
        %460 = arith.constant 0 : i32
        %462 = arith.extsi %460 : i32 to i64
        %461 = arith.cmpi ne, %458, %462 : i64
        scf.yield %461 : i1
      } else {
        %463 = arith.constant false
        scf.yield %463 : i1
      }
      %464 = scf.if %456 -> (i1) {
        %465 = arith.constant 13 : i32
        %467 = arith.extsi %465 : i32 to i64
        %466 = arith.remsi %449, %467 : i64
        %468 = arith.constant 0 : i32
        %470 = arith.extsi %468 : i32 to i64
        %469 = arith.cmpi ne, %466, %470 : i64
        scf.yield %469 : i1
      } else {
        %471 = arith.constant false
        scf.yield %471 : i1
      }
      cf.cond_br %464, ^bb102, ^bb103
      ^bb102:
        %472 = arith.constant 1 : i1
        %473 = llvm.mlir.constant(1 : i64) : i64
        %474 = llvm.alloca %473 x i1 : (i64) -> !llvm.ptr
        llvm.store %472, %474 : i1, !llvm.ptr
        %475 = arith.constant 0 : i32
        %476 = llvm.mlir.constant(1 : i64) : i64
        %477 = llvm.alloca %476 x i32 : (i64) -> !llvm.ptr
        llvm.store %475, %477 : i32, !llvm.ptr
        cf.br ^bb105
        ^bb105:
        %478 = llvm.load %477 : !llvm.ptr -> i32
        %479 = llvm.load %356 : !llvm.ptr -> i32
        %480 = arith.cmpi slt, %478, %479 : i32
        %481 = scf.if %480 -> (i1) {
          %482 = llvm.load %474 : !llvm.ptr -> i1
          scf.yield %482 : i1
        } else {
          %483 = arith.constant false
          scf.yield %483 : i1
        }
        cf.cond_br %481, ^bb106, ^bb107
        ^bb106:
          %485 = llvm.load %477 : !llvm.ptr -> i32
          %486 = arith.extsi %485 : i32 to i64
          %487 = llvm.getelementptr %341[%486] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          %484 = llvm.load %487 : !llvm.ptr -> i64
          %488 = arith.constant 0 : i32
          %489 = llvm.mlir.constant(1 : i64) : i64
          %490 = llvm.alloca %489 x i32 : (i64) -> !llvm.ptr
          llvm.store %488, %490 : i32, !llvm.ptr
          cf.br ^bb108
          ^bb108:
          %491 = llvm.load %490 : !llvm.ptr -> i32
          %492 = arith.constant 6 : i32
          %493 = arith.cmpi slt, %491, %492 : i32
          cf.cond_br %493, ^bb109, ^bb110
          ^bb109:
            %495 = llvm.load %490 : !llvm.ptr -> i32
            %496 = arith.extsi %495 : i32 to i64
            %497 = llvm.getelementptr %402[%496] : (!llvm.ptr, i64) -> !llvm.ptr, i64
            %494 = llvm.load %497 : !llvm.ptr -> i64
            %498 = arith.addi %449, %494 : i64
            %499 = arith.cmpi ne, %498, %484 : i64
            %500 = scf.if %499 -> (i1) {
              %501 = arith.remsi %498, %484 : i64
              %502 = arith.constant 0 : i32
              %504 = arith.extsi %502 : i32 to i64
              %503 = arith.cmpi eq, %501, %504 : i64
              scf.yield %503 : i1
            } else {
              %505 = arith.constant false
              scf.yield %505 : i1
            }
            cf.cond_br %500, ^bb111, ^bb112
            ^bb111:
              %506 = arith.constant 0 : i1
              llvm.store %506, %474 : i1, !llvm.ptr
              cf.br ^bb110
            ^bb112:
              cf.br ^bb113
            ^bb113:
            %507 = llvm.load %490 : !llvm.ptr -> i32
            %508 = arith.constant 1 : i32
            %509 = arith.addi %507, %508 : i32
            llvm.store %509, %490 : i32, !llvm.ptr
            cf.br ^bb108
          ^bb110:
          %510 = llvm.load %477 : !llvm.ptr -> i32
          %511 = arith.constant 1 : i32
          %512 = arith.addi %510, %511 : i32
          llvm.store %512, %477 : i32, !llvm.ptr
          cf.br ^bb105
        ^bb107:
        %513 = llvm.load %474 : !llvm.ptr -> i1
        cf.cond_br %513, ^bb114, ^bb115
        ^bb114:
          %515 = arith.constant 1 : i32
          %517 = arith.extsi %515 : i32 to i64
          %516 = arith.addi %449, %517 : i64
          %514 = func.call @miller_rabin(%516) : (i64) -> i1
          %518 = scf.if %514 -> (i1) {
            %520 = arith.constant 3 : i32
            %522 = arith.extsi %520 : i32 to i64
            %521 = arith.addi %449, %522 : i64
            %519 = func.call @miller_rabin(%521) : (i64) -> i1
            scf.yield %519 : i1
          } else {
            %523 = arith.constant false
            scf.yield %523 : i1
          }
          %524 = scf.if %518 -> (i1) {
            %526 = arith.constant 7 : i32
            %528 = arith.extsi %526 : i32 to i64
            %527 = arith.addi %449, %528 : i64
            %525 = func.call @miller_rabin(%527) : (i64) -> i1
            scf.yield %525 : i1
          } else {
            %529 = arith.constant false
            scf.yield %529 : i1
          }
          %530 = scf.if %524 -> (i1) {
            %532 = arith.constant 9 : i32
            %534 = arith.extsi %532 : i32 to i64
            %533 = arith.addi %449, %534 : i64
            %531 = func.call @miller_rabin(%533) : (i64) -> i1
            scf.yield %531 : i1
          } else {
            %535 = arith.constant false
            scf.yield %535 : i1
          }
          %536 = scf.if %530 -> (i1) {
            %538 = arith.constant 13 : i32
            %540 = arith.extsi %538 : i32 to i64
            %539 = arith.addi %449, %540 : i64
            %537 = func.call @miller_rabin(%539) : (i64) -> i1
            scf.yield %537 : i1
          } else {
            %541 = arith.constant false
            scf.yield %541 : i1
          }
          %542 = scf.if %536 -> (i1) {
            %544 = arith.constant 27 : i32
            %546 = arith.extsi %544 : i32 to i64
            %545 = arith.addi %449, %546 : i64
            %543 = func.call @miller_rabin(%545) : (i64) -> i1
            scf.yield %543 : i1
          } else {
            %547 = arith.constant false
            scf.yield %547 : i1
          }
          cf.cond_br %542, ^bb117, ^bb118
          ^bb117:
            %549 = arith.constant 5 : i32
            %551 = arith.extsi %549 : i32 to i64
            %550 = arith.addi %449, %551 : i64
            %548 = func.call @miller_rabin(%550) : (i64) -> i1
            %553 = arith.constant 1 : i1
            %552 = arith.xori %548, %553 : i1
            %555 = scf.if %552 -> (i1) {
              %557 = arith.constant 11 : i32
              %559 = arith.extsi %557 : i32 to i64
              %558 = arith.addi %449, %559 : i64
              %556 = func.call @miller_rabin(%558) : (i64) -> i1
              %561 = arith.constant 1 : i1
              %560 = arith.xori %556, %561 : i1
              scf.yield %560 : i1
            } else {
              %563 = arith.constant false
              scf.yield %563 : i1
            }
            %564 = scf.if %555 -> (i1) {
              %566 = arith.constant 15 : i32
              %568 = arith.extsi %566 : i32 to i64
              %567 = arith.addi %449, %568 : i64
              %565 = func.call @miller_rabin(%567) : (i64) -> i1
              %570 = arith.constant 1 : i1
              %569 = arith.xori %565, %570 : i1
              scf.yield %569 : i1
            } else {
              %572 = arith.constant false
              scf.yield %572 : i1
            }
            %573 = scf.if %564 -> (i1) {
              %575 = arith.constant 17 : i32
              %577 = arith.extsi %575 : i32 to i64
              %576 = arith.addi %449, %577 : i64
              %574 = func.call @miller_rabin(%576) : (i64) -> i1
              %579 = arith.constant 1 : i1
              %578 = arith.xori %574, %579 : i1
              scf.yield %578 : i1
            } else {
              %581 = arith.constant false
              scf.yield %581 : i1
            }
            %582 = scf.if %573 -> (i1) {
              %584 = arith.constant 19 : i32
              %586 = arith.extsi %584 : i32 to i64
              %585 = arith.addi %449, %586 : i64
              %583 = func.call @miller_rabin(%585) : (i64) -> i1
              %588 = arith.constant 1 : i1
              %587 = arith.xori %583, %588 : i1
              scf.yield %587 : i1
            } else {
              %590 = arith.constant false
              scf.yield %590 : i1
            }
            %591 = scf.if %582 -> (i1) {
              %593 = arith.constant 21 : i32
              %595 = arith.extsi %593 : i32 to i64
              %594 = arith.addi %449, %595 : i64
              %592 = func.call @miller_rabin(%594) : (i64) -> i1
              %597 = arith.constant 1 : i1
              %596 = arith.xori %592, %597 : i1
              scf.yield %596 : i1
            } else {
              %599 = arith.constant false
              scf.yield %599 : i1
            }
            %600 = scf.if %591 -> (i1) {
              %602 = arith.constant 23 : i32
              %604 = arith.extsi %602 : i32 to i64
              %603 = arith.addi %449, %604 : i64
              %601 = func.call @miller_rabin(%603) : (i64) -> i1
              %606 = arith.constant 1 : i1
              %605 = arith.xori %601, %606 : i1
              scf.yield %605 : i1
            } else {
              %608 = arith.constant false
              scf.yield %608 : i1
            }
            %609 = scf.if %600 -> (i1) {
              %611 = arith.constant 25 : i32
              %613 = arith.extsi %611 : i32 to i64
              %612 = arith.addi %449, %613 : i64
              %610 = func.call @miller_rabin(%612) : (i64) -> i1
              %615 = arith.constant 1 : i1
              %614 = arith.xori %610, %615 : i1
              scf.yield %614 : i1
            } else {
              %617 = arith.constant false
              scf.yield %617 : i1
            }
            cf.cond_br %609, ^bb120, ^bb121
            ^bb120:
              %618 = llvm.load %440 : !llvm.ptr -> i64
              %619 = llvm.load %444 : !llvm.ptr -> i64
              %620 = arith.addi %618, %619 : i64
              llvm.store %620, %440 : i64, !llvm.ptr
              cf.br ^bb122
            ^bb121:
              cf.br ^bb122
            ^bb122:
            cf.br ^bb119
          ^bb118:
            cf.br ^bb119
          ^bb119:
          cf.br ^bb116
        ^bb115:
          cf.br ^bb116
        ^bb116:
        cf.br ^bb104
      ^bb103:
        cf.br ^bb104
      ^bb104:
      %621 = llvm.load %444 : !llvm.ptr -> i64
      %622 = arith.constant 10 : i32
      %624 = arith.extsi %622 : i32 to i64
      %623 = arith.addi %621, %624 : i64
      llvm.store %623, %444 : i64, !llvm.ptr
      cf.br ^bb99
    ^bb101:
    %625 = llvm.mlir.addressof @str_0 : !llvm.ptr
    %626 = llvm.load %440 : !llvm.ptr -> i64
    %627 = llvm.call @printf(%625, %626) vararg(!llvm.func<i32 (ptr, ...)>) : (!llvm.ptr, i64) -> i32
    func.call @free(%402) : (!llvm.ptr) -> ()
    func.call @free(%341) : (!llvm.ptr) -> ()
    %630 = arith.constant 0 : i32
    func.return %630 : i32
  }
}