Problem 273

Sum of a for squarefree n<=150 = product of distinct 4k+1 primes.

Answer2032447591196869022
Output2032447591196869022
StatusPASS
Native helperno
Runtime40 ms
Peak memory5264 KB
Time complexityO(n^2) (estimated)
Space complexityO(n^2) (estimated)

Performance comparison

MetricOur solutionBest known
Time complexityO(n^2)O(n log log n)
Space complexityO(n^2)O(n)
ApproachFlow solutionMobius sieve
VerdictSuboptimal

Flow source

# Project Euler 273
# Sum of a for squarefree n<=150 = product of distinct 4k+1 primes.

import euler.nt { is_prime }

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

function abs64(a: i64) -> i64 {
    if a < 0 { return -a }
    return a
}

function find_ab(prime: i64, a_out: ptr<i64>, b_out: ptr<i64>) -> void {
    let mut b: i64 = 1
    while b * b < prime {
        let mut a: i64 = 1
        while a < b {
            if a * a + b * b == prime {
                a_out[0] = a
                b_out[0] = b
                return
            }
            a = a + 1
        }
        b = b + 1
    }
}

function search(sols_a: ptr<i64>, sols_b: ptr<i64>, sc: i64, primes_a: ptr<i64>, primes_b: ptr<i64>, pc: i64, index: i64) -> i64 {
    if index == pc {
        let mut sum: i64 = 0
        let mut i: i64 = 0
        while i < sc {
            # skip seed (0,1)
            if !(sols_a[i] == 0 && sols_b[i] == 1) {
                sum = sum + sols_a[i]
            }
            i = i + 1
        }
        return sum
    }
    let ca: i64 = primes_a[index]
    let cb: i64 = primes_b[index]
    let next_a: ptr<i64> = calloc(sc * 2 + 2, 8)
    let next_b: ptr<i64> = calloc(sc * 2 + 2, 8)
    let mut nc: i64 = 0
    let mut i: i64 = 0
    while i < sc {
        let sa: i64 = sols_a[i]
        let sb: i64 = sols_b[i]
        let mut x: i64 = sa * ca + sb * cb
        let mut y: i64 = abs64(sa * cb - sb * ca)
        if x > y {
            let t: i64 = x
            x = y
            y = t
        }
        next_a[nc] = x
        next_b[nc] = y
        nc = nc + 1
        if !(sa == 0 && sb == 1) {
            x = abs64(sa * ca - sb * cb)
            y = sa * cb + sb * ca
            if x > y {
                let t2: i64 = x
                x = y
                y = t2
            }
            next_a[nc] = x
            next_b[nc] = y
            nc = nc + 1
        }
        i = i + 1
    }
    let without: i64 = search(sols_a, sols_b, sc, primes_a, primes_b, pc, index + 1)
    let withv: i64 = search(next_a, next_b, nc, primes_a, primes_b, pc, index + 1)
    free(next_a)
    free(next_b)
    return withv + without
}

function main() -> i32 {
    let limit: i64 = 150
    let primes_a: ptr<i64> = calloc(40, 8)
    let primes_b: ptr<i64> = calloc(40, 8)
    let mut pc: i64 = 0
    let mut i: i64 = 5
    while i <= limit {
        if i % 4 == 1 && is_prime(i) {
            let a: ptr<i64> = calloc(1, 8)
            let b: ptr<i64> = calloc(1, 8)
            find_ab(i, a, b)
            primes_a[pc] = a[0]
            primes_b[pc] = b[0]
            pc = pc + 1
            free(a); free(b)
        }
        i = i + 4
    }
    let sols_a: ptr<i64> = calloc(1, 8)
    let sols_b: ptr<i64> = calloc(1, 8)
    sols_a[0] = 0
    sols_b[0] = 1
    printf("%lld\n", search(sols_a, sols_b, 1, primes_a, primes_b, pc, 0))
    free(sols_a); free(sols_b); free(primes_a); free(primes_b)
    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 gcd_i64_i64(int64_t a0, int64_t b0);
int64_t lcm_i64_i64(int64_t a, int64_t b);
int64_t isqrt_i64(int64_t n);
int64_t mulmod_i64_i64_i64(int64_t a0, int64_t b0, int64_t mod);
int64_t mod_pow_i64_i64_i64(int64_t base, int64_t exp, int64_t mod);
bool is_prime_i64(int64_t n);
int64_t abs64_i64(int64_t a);
void find_ab_i64_ptr_i64_ptr_i64(int64_t prime, int64_t* a_out, int64_t* b_out);
int64_t search_ptr_i64_ptr_i64_i64_ptr_i64_ptr_i64_i64_i64(int64_t* sols_a, int64_t* sols_b, int64_t sc, int64_t* primes_a, int64_t* primes_b, int64_t pc, int64_t index);
int32_t main(void);

int64_t gcd_i64_i64(int64_t a0, int64_t b0) {
    int64_t a = a0;
    int64_t b = b0;
    while (b != 0) {
        int64_t t = FLOW_CHECKED_MOD((a), (b));
        a = b;
        b = t;
    }
    return a;
}

int64_t lcm_i64_i64(int64_t a, int64_t b) {
    if ((a == 0 || b == 0)) {
        return 0;
    }
    return (FLOW_CHECKED_DIV((a), (gcd_i64_i64(a, b))) * b);
}

int64_t isqrt_i64(int64_t n) {
    if (n < 2) {
        return n;
    }
    int64_t x = n;
    int64_t y = FLOW_CHECKED_DIV(((x + 1)), (2));
    while (y < x) {
        x = y;
        y = FLOW_CHECKED_DIV(((x + FLOW_CHECKED_DIV((n), (x)))), (2));
    }
    return x;
}

int64_t mulmod_i64_i64_i64(int64_t a0, int64_t b0, int64_t mod) {
    int64_t a = FLOW_CHECKED_MOD((a0), (mod));
    int64_t b = FLOW_CHECKED_MOD((b0), (mod));
    int64_t result = 0;
    while (b > 0) {
        if (FLOW_CHECKED_MOD((b), (2)) == 1) {
            result = FLOW_CHECKED_MOD(((result + a)), (mod));
        }
        a = FLOW_CHECKED_MOD(((a * 2)), (mod));
        b = FLOW_CHECKED_DIV((b), (2));
    }
    return result;
}

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

bool is_prime_i64(int64_t n) {
    if (n < 2) {
        return 0;
    }
    if (n < 4) {
        return 1;
    }
    if ((FLOW_CHECKED_MOD((n), (2)) == 0 || FLOW_CHECKED_MOD((n), (3)) == 0)) {
        return 0;
    }
    int64_t i = 5;
    while ((i * i) <= n) {
        if ((FLOW_CHECKED_MOD((n), (i)) == 0 || FLOW_CHECKED_MOD((n), ((i + 2))) == 0)) {
            return 0;
        }
        i = (i + 6);
    }
    return 1;
}



int64_t abs64_i64(int64_t a) {
    if (a < 0) {
        return (-a);
    }
    return a;
}

void find_ab_i64_ptr_i64_ptr_i64(int64_t prime, int64_t* a_out, int64_t* b_out) {
    int64_t b = 1;
    while ((b * b) < prime) {
        int64_t a = 1;
        while (a < b) {
            if (((a * a) + (b * b)) == prime) {
                a_out[0] = a;
                b_out[0] = b;
                return;
            }
            a = (a + 1);
        }
        b = (b + 1);
    }
}

int64_t search_ptr_i64_ptr_i64_i64_ptr_i64_ptr_i64_i64_i64(int64_t* sols_a, int64_t* sols_b, int64_t sc, int64_t* primes_a, int64_t* primes_b, int64_t pc, int64_t index) {
    if (index == pc) {
        int64_t sum = 0;
        int64_t i = 0;
        while (i < sc) {
            if ((!((sols_a[i] == 0 && sols_b[i] == 1)))) {
                sum = (sum + sols_a[i]);
            }
            i = (i + 1);
        }
        return sum;
    }
    int64_t ca = primes_a[index];
    int64_t cb = primes_b[index];
    int64_t* next_a = (int64_t*)(calloc(((sc * 2) + 2), 8));
    int64_t* next_b = (int64_t*)(calloc(((sc * 2) + 2), 8));
    int64_t nc = 0;
    int64_t i = 0;
    while (i < sc) {
        int64_t sa = sols_a[i];
        int64_t sb = sols_b[i];
        int64_t x = ((sa * ca) + (sb * cb));
        int64_t y = abs64_i64(((sa * cb) - (sb * ca)));
        if (x > y) {
            int64_t t = x;
            x = y;
            y = t;
        }
        next_a[nc] = x;
        next_b[nc] = y;
        nc = (nc + 1);
        if ((!((sa == 0 && sb == 1)))) {
            x = abs64_i64(((sa * ca) - (sb * cb)));
            y = ((sa * cb) + (sb * ca));
            if (x > y) {
                int64_t t2 = x;
                x = y;
                y = t2;
            }
            next_a[nc] = x;
            next_b[nc] = y;
            nc = (nc + 1);
        }
        i = (i + 1);
    }
    int64_t without = search_ptr_i64_ptr_i64_i64_ptr_i64_ptr_i64_i64_i64(sols_a, sols_b, sc, primes_a, primes_b, pc, (index + 1));
    int64_t withv = search_ptr_i64_ptr_i64_i64_ptr_i64_ptr_i64_i64_i64(next_a, next_b, nc, primes_a, primes_b, pc, (index + 1));
    free(next_a);
    free(next_b);
    return (withv + without);
}

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