Problem 934

U(N) = sum_{n=1..N} u(n) where u(n) is the smallest prime p such that (n mod p) is NOT a multiple of 7. Compute U(10^17) using CRT residue construction + explicit enumeration. Pure Flow port of the native C solver.

Answer292137809490441370
Output292137809490441370
StatusPASS
Native helperno
Runtime10 ms
Peak memory17520 KB
Time complexityO(n^2) (estimated)
Space complexityO(1) (estimated)

Performance comparison

MetricOur solutionBest known
Time complexityO(n^2)O(n log n)
Space complexityO(1)O(n)
ApproachFlow solutionChinese Remainder Theorem
VerdictSuboptimal

Flow source

# Project Euler 934: Unlucky Primes
# U(N) = sum_{n=1..N} u(n) where u(n) is the smallest prime p
# such that (n mod p) is NOT a multiple of 7.
# Compute U(10^17) using CRT residue construction + explicit enumeration.
# Pure Flow port of the native C solver.

extern {
    function calloc(n: i64, size: i64) -> ptr<void>
    function free(p: ptr<void>) -> void
    function malloc(n: i64) -> ptr<void>
    function realloc(p: ptr<void>, n: i64) -> ptr<void>
    function printf(fmt: ptr<i8>, ...) -> i32
}

# Extended Euclid for modular inverse
function inv_mod(a0: i64, m: i64) -> i64 {
    let mut a: i64 = a0 % m
    if a < 0 { a = a + m }
    let mut t0: i64 = 0
    let mut t1: i64 = 1
    let mut r0: i64 = m
    let mut r1: i64 = a
    while r1 != 0 {
        let q: i64 = r0 / r1
        let tmp: i64 = t0 - q * t1
        t0 = t1
        t1 = tmp
        let tmp2: i64 = r0 - q * r1
        r0 = r1
        r1 = tmp2
    }
    if r0 != 1 { return -1 }
    let mut res: i64 = t0 % m
    if res < 0 { res = res + m }
    return res
}

function is_prime(x: i32) -> bool {
    if x < 2 { return false }
    if x == 2 { return true }
    if x % 2 == 0 { return false }
    let mut i: i32 = 3
    while (i as i64) * (i as i64) <= (x as i64) {
        if x % i == 0 { return false }
        i = i + 2
    }
    return true
}

function main() -> i32 {
    let mut N: i64 = 1
    let mut i: i32 = 0
    while i < 17 {
        N = N * 10
        i = i + 1
    }

    let mut ans: i64 = 0
    let mut c_prev: i64 = N

    # Phase 1: CRT mode
    let mut M: i64 = 1
    let mut residues: ptr<i64> = (malloc(8)) as ptr<i64>
    residues[0] = 0
    let mut num_residues: i32 = 1

    # Phase 2: explicit survivors
    let mut survivors: ptr<i64> = null as ptr<i64>
    let mut num_survivors: i32 = 0

    let mut p: i32 = 2
    while true {
        if !is_prime(p) {
            p = p + 1
            continue
        }

        # Allowed residues mod p: multiples of 7 in [0, p-1]
        let num_allowed: i32 = (p + 6) / 7

        let c: i64 = 0

        if survivors == (null as ptr<i64>) {
            # CRT mode
            let M_new: i128 = (M as i128) * (p as i128)

            if M_new <= (N as i128) {
                # Extend residues using CRT
                let inv: i64 = inv_mod(M, (p as i64))
                let M_old: i64 = M

                let new_cap: i32 = num_residues * num_allowed
                let new_residues: ptr<i64> = (malloc((new_cap as i64) * 8)) as ptr<i64>
                let mut nr: i32 = 0

                let mut ii: i32 = 0
                while ii < num_residues {
                    let r: i64 = residues[ii]
                    let mut s: i32 = 0
                    while s < p {
                        let diff: i64 = (s as i64) - r
                        let mut t: i64 = ((diff % (p as i64)) * inv) % (p as i64)
                        if t < 0 { t = t + (p as i64) }
                        let new_r: i64 = r + M_old * t
                        new_residues[nr] = new_r
                        nr = nr + 1
                        s = s + 7
                    }
                    ii = ii + 1
                }

                free(residues as ptr<void>)
                residues = new_residues
                num_residues = nr
                M = (M_new as i64)

                # Count numbers <= N matching these residues (period M)
                let q: i64 = N / M
                let rem: i64 = N % M
                let mut extra: i64 = 0
                let mut iii: i32 = 0
                while iii < num_residues {
                    if residues[iii] > 0 && residues[iii] <= rem {
                        extra = extra + 1
                    }
                    iii = iii + 1
                }
                let cc: i64 = q * (num_residues as i64) + extra

                # Numbers that stop at prime p have u(n) = p
                ans = ans + (p as i64) * (c_prev - cc)
                c_prev = cc
            } else {
                # Switch to explicit enumeration
                let inv: i64 = inv_mod(M, (p as i64))
                let M_old: i64 = M

                survivors = (malloc((num_residues * num_allowed) as i64 * 8)) as ptr<i64>
                num_survivors = 0

                let mut ii2: i32 = 0
                while ii2 < num_residues {
                    let r: i64 = residues[ii2]
                    let mut s: i32 = 0
                    while s < p {
                        let diff: i64 = (s as i64) - r
                        let mut t: i64 = ((diff % (p as i64)) * inv) % (p as i64)
                        if t < 0 { t = t + (p as i64) }
                        let x: i64 = r + M_old * t
                        if x > 0 && x <= N {
                            survivors[num_survivors] = x
                            num_survivors = num_survivors + 1
                        }
                        s = s + 7
                    }
                    ii2 = ii2 + 1
                }

                free(residues as ptr<void>)
                residues = null as ptr<i64>
                M = (M_new as i64)

                let cc2: i64 = num_survivors as i64
                ans = ans + (p as i64) * (c_prev - cc2)
                c_prev = cc2
            }
        } else {
            # Explicit enumeration mode: filter survivors
            let mut j: i32 = 0
            let mut jj3: i32 = 0
            while jj3 < num_survivors {
                let n: i64 = survivors[jj3]
                if (n % (p as i64)) % 7 == 0 {
                    survivors[j] = n
                    j = j + 1
                }
                jj3 = jj3 + 1
            }
            num_survivors = j

            let cc3: i64 = num_survivors as i64
            ans = ans + (p as i64) * (c_prev - cc3)
            c_prev = cc3
        }

        if c_prev == 0 { break }
        p = p + 1
    }

    if residues != (null as ptr<i64>) {
        free(residues as ptr<void>)
    }
    if survivors != (null as ptr<i64>) {
        free(survivors as ptr<void>)
    }

    printf("%lld\n", ans)
    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 inv_mod_i64_i64(int64_t a0, int64_t m);
bool is_prime_i32(int32_t x);
int32_t main(void);






int64_t inv_mod_i64_i64(int64_t a0, int64_t m) {
    int64_t a = FLOW_CHECKED_MOD((a0), (m));
    if (a < 0) {
        a = (a + m);
    }
    int64_t t0 = 0;
    int64_t t1 = 1;
    int64_t r0 = m;
    int64_t r1 = a;
    while (r1 != 0) {
        int64_t q = FLOW_CHECKED_DIV((r0), (r1));
        int64_t tmp = (t0 - (q * t1));
        t0 = t1;
        t1 = tmp;
        int64_t tmp2 = (r0 - (q * r1));
        r0 = r1;
        r1 = tmp2;
    }
    if (r0 != 1) {
        return (-1);
    }
    int64_t res = FLOW_CHECKED_MOD((t0), (m));
    if (res < 0) {
        res = (res + m);
    }
    return res;
}

bool is_prime_i32(int32_t x) {
    if (x < 2) {
        return 0;
    }
    if (x == 2) {
        return 1;
    }
    if (FLOW_CHECKED_MOD((x), (2)) == 0) {
        return 0;
    }
    int32_t i = 3;
    while ((((int64_t)(i)) * ((int64_t)(i))) <= ((int64_t)(x))) {
        if (FLOW_CHECKED_MOD((x), (i)) == 0) {
            return 0;
        }
        i = (i + 2);
    }
    return 1;
}

int32_t main(void) {
    int64_t N = 1;
    int32_t i = 0;
    while (i < 17) {
        N = (N * 10);
        i = (i + 1);
    }
    int64_t ans = 0;
    int64_t c_prev = N;
    int64_t M = 1;
    int64_t* residues = (int64_t*)(((int64_t*)(malloc(8))));
    residues[0] = 0;
    int32_t num_residues = 1;
    int64_t* survivors = (int64_t*)(((int64_t*)(NULL)));
    int32_t num_survivors = 0;
    int32_t p = 2;
    while (1) {
        if ((!(is_prime_i32(p)))) {
            p = (p + 1);
            continue;
        }
        int32_t num_allowed = FLOW_CHECKED_DIV(((p + 6)), (7));
        int64_t c = 0;
        if (survivors == ((int64_t*)(NULL))) {
            __int128 M_new = (((__int128)(M)) * ((__int128)(p)));
            if (M_new <= ((__int128)(N))) {
                int64_t inv = inv_mod_i64_i64(M, ((int64_t)(p)));
                int64_t M_old = M;
                int32_t new_cap = (num_residues * num_allowed);
                int64_t* new_residues = (int64_t*)(((int64_t*)(malloc((((int64_t)(new_cap)) * 8)))));
                int32_t nr = 0;
                int32_t ii = 0;
                while (ii < num_residues) {
                    int64_t r = residues[ii];
                    int32_t s = 0;
                    while (s < p) {
                        int64_t diff = (((int64_t)(s)) - r);
                        int64_t t = FLOW_CHECKED_MOD(((FLOW_CHECKED_MOD((diff), (((int64_t)(p)))) * inv)), (((int64_t)(p))));
                        if (t < 0) {
                            t = (t + ((int64_t)(p)));
                        }
                        int64_t new_r = (r + (M_old * t));
                        new_residues[nr] = new_r;
                        nr = (nr + 1);
                        s = (s + 7);
                    }
                    ii = (ii + 1);
                }
                free(((void*)(residues)));
                residues = new_residues;
                num_residues = nr;
                M = ((int64_t)(M_new));
                int64_t q = FLOW_CHECKED_DIV((N), (M));
                int64_t rem = FLOW_CHECKED_MOD((N), (M));
                int64_t extra = 0;
                int32_t iii = 0;
                while (iii < num_residues) {
                    if ((residues[iii] > 0 && residues[iii] <= rem)) {
                        extra = (extra + 1);
                    }
                    iii = (iii + 1);
                }
                int64_t cc = ((q * ((int64_t)(num_residues))) + extra);
                ans = (ans + (((int64_t)(p)) * (c_prev - cc)));
                c_prev = cc;
            } else {
                int64_t inv = inv_mod_i64_i64(M, ((int64_t)(p)));
                int64_t M_old = M;
                survivors = ((int64_t*)(malloc((((int64_t)((num_residues * num_allowed))) * 8))));
                num_survivors = 0;
                int32_t ii2 = 0;
                while (ii2 < num_residues) {
                    int64_t r = residues[ii2];
                    int32_t s = 0;
                    while (s < p) {
                        int64_t diff = (((int64_t)(s)) - r);
                        int64_t t = FLOW_CHECKED_MOD(((FLOW_CHECKED_MOD((diff), (((int64_t)(p)))) * inv)), (((int64_t)(p))));
                        if (t < 0) {
                            t = (t + ((int64_t)(p)));
                        }
                        int64_t x = (r + (M_old * t));
                        if ((x > 0 && x <= N)) {
                            survivors[num_survivors] = x;
                            num_survivors = (num_survivors + 1);
                        }
                        s = (s + 7);
                    }
                    ii2 = (ii2 + 1);
                }
                free(((void*)(residues)));
                residues = ((int64_t*)(NULL));
                M = ((int64_t)(M_new));
                int64_t cc2 = ((int64_t)(num_survivors));
                ans = (ans + (((int64_t)(p)) * (c_prev - cc2)));
                c_prev = cc2;
            }
        } else {
            int32_t j = 0;
            int32_t jj3 = 0;
            while (jj3 < num_survivors) {
                int64_t n = survivors[jj3];
                if (FLOW_CHECKED_MOD((FLOW_CHECKED_MOD((n), (((int64_t)(p))))), (7)) == 0) {
                    survivors[j] = n;
                    j = (j + 1);
                }
                jj3 = (jj3 + 1);
            }
            num_survivors = j;
            int64_t cc3 = ((int64_t)(num_survivors));
            ans = (ans + (((int64_t)(p)) * (c_prev - cc3)));
            c_prev = cc3;
        }
        if (c_prev == 0) {
            break;
        }
        p = (p + 1);
    }
    if (residues != ((int64_t*)(NULL))) {
        free(((void*)(residues)));
    }
    if (survivors != ((int64_t*)(NULL))) {
        free(((void*)(survivors)));
    }
    printf("%lld\n", ans);
    return 0;
}

Generated MLIR

module {
  llvm.func @printf(!llvm.ptr, ...) -> i32
  llvm.mlir.global internal constant @str_0("%lld\n\00") {addr_space = 0 : i32} : !llvm.array<6 x i8>
  func.func private @calloc(i64, i64) -> !llvm.ptr
  func.func private @free(!llvm.ptr) -> ()
  func.func private @malloc(i64) -> !llvm.ptr
  func.func private @realloc(!llvm.ptr, i64) -> !llvm.ptr

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