Problem 241

Sum of n <= 10^18 with sigma(n)/n a half-integer.

Answer482316491800641154
Output482316491800641154
StatusPASS
Native helperno
Runtime10 ms
Peak memory3520 KB
Time complexityO(n) (estimated)
Space complexityO(n^2) (estimated)

Performance comparison

MetricOur solutionBest known
Time complexityO(n)O(n log log n)
Space complexityO(n^2)O(n)
ApproachFlow solutionSieve-based divisor sums
VerdictOptimal

Flow source

# Project Euler 241
# Sum of n <= 10^18 with sigma(n)/n a half-integer.

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

function gcd(a0: i64, b0: i64) -> i64 {
    let mut a: i64 = a0
    let mut b: i64 = b0
    while b != 0 {
        let t: i64 = a % b
        a = b
        b = t
    }
    return a
}

function addmod(a: i64, b: i64, mod: i64) -> i64 {
    let s: i64 = a + b
    if s >= mod || s < a { return s - mod }
    return s
}

function mulmod(a0: i64, b0: i64, mod: i64) -> i64 {
    let mut a: i64 = a0 % mod
    let mut b: i64 = b0 % mod
    if a < 0 { a = a + mod }
    if b < 0 { b = b + mod }
    let mut result: i64 = 0
    while b > 0 {
        if b % 2 == 1 { result = addmod(result, a, mod) }
        a = addmod(a, a, mod)
        b = b / 2
    }
    return result
}

function modpow(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 = mulmod(r, b, mod) }
        b = mulmod(b, b, mod)
        e = e / 2
    }
    return r
}

function is_prime(value: i64) -> bool {
    if value < 2 { return false }
    if value % 2 == 0 { return value == 2 }
    if value % 3 == 0 { return value == 3 }
    if value % 5 == 0 { return value == 5 }
    if value % 7 == 0 { return value == 7 }
    if value % 11 == 0 { return value == 11 }
    if value % 13 == 0 { return value == 13 }
    if value % 17 == 0 { return value == 17 }
    if value % 19 == 0 { return value == 19 }
    if value % 23 == 0 { return value == 23 }
    if value % 29 == 0 { return value == 29 }
    let mut d: i64 = value - 1
    let mut shifts: i32 = 0
    while d % 2 == 0 { d = d / 2; shifts = shifts + 1 }
    let bases: ptr<i64> = calloc(7, 8)
    bases[0] = 2; bases[1] = 325; bases[2] = 9375; bases[3] = 28178
    bases[4] = 450775; bases[5] = 9780504; bases[6] = 1795265022
    for bi in 0..7 {
        let base: i64 = bases[bi] % value
        if base != 0 {
            let mut x: i64 = modpow(base, d, value)
            if !(x == 1 || x == value - 1) {
                let mut ok: bool = false
                let mut r: i32 = 0
                while r < shifts - 1 {
                    x = mulmod(x, x, value)
                    if x == value - 1 { ok = true; break }
                    r = r + 1
                }
                if !ok { free(bases); return false }
            }
        }
    }
    free(bases)
    return true
}

function pollard_rho(n: i64) -> i64 {
    if n % 2 == 0 { return 2 }
    let mut c: i64 = 1
    while true {
        let mut x: i64 = 2
        let mut y: i64 = 2
        let mut d: i64 = 1
        while d == 1 {
            x = addmod(mulmod(x, x, n), c, n)
            y = addmod(mulmod(y, y, n), c, n)
            y = addmod(mulmod(y, y, n), c, n)
            let mut diff: i64 = x - y
            if diff < 0 { diff = 0 - diff }
            d = gcd(diff, n)
        }
        if d != n { return d }
        c = c + 1
    }
    return n
}

# Factor into primes array (with multiplicity), then group
function factor_smallest(n0: i64) -> i64 {
    # return smallest prime factor
    let mut n: i64 = n0
    if n % 2 == 0 { return 2 }
    if is_prime(n) { return n }
    let f: i64 = pollard_rho(n)
    while !is_prime(f) {
        f = pollard_rho(f)
    }
    # also check n/f factors - we need smallest prime factor of n0
    let mut spf: i64 = f
    let mut rem: i64 = n0
    # fully factor via trial + pollard
    let mut p: i64 = 2
    while p * p <= rem && p <= 1000000 {
        if rem % p == 0 { return p }
        if p == 2 { p = 3 } else { p = p + 2 }
    }
    if rem > 1 && is_prime(rem) { return rem }
    # pollard tree
    let mut stack: ptr<i64> = calloc(64, 8)
    let mut sp: i32 = 0
    stack[0] = n0; sp = 1
    let mut best: i64 = n0
    while sp > 0 {
        sp = sp - 1
        let cur: i64 = stack[sp]
        if cur < best && is_prime(cur) { best = cur; continue }
        if is_prime(cur) {
            if cur < best { best = cur }
            continue
        }
        let g: i64 = pollard_rho(cur)
        stack[sp] = g; sp = sp + 1
        stack[sp] = cur / g; sp = sp + 1
    }
    free(stack)
    return best
}

let mut TOTAL: i64 = 0
const LIMIT: i64 = 1000000000000000000

function search_target(target_num: i64) -> void {
    # stack of (n, numerator, denominator) - ignore used_primes by checking factor of denom
    let CAP: i64 = 100000
    let sn: ptr<i64> = calloc(CAP, 8)
    let snum: ptr<i64> = calloc(CAP, 8)
    let sden: ptr<i64> = calloc(CAP, 8)
    let mut sp: i64 = 0
    sn[0] = 1; snum[0] = target_num; sden[0] = 2; sp = 1
    while sp > 0 {
        sp = sp - 1
        let n: i64 = sn[sp]
        let numerator: i64 = snum[sp]
        let denominator: i64 = sden[sp]
        if numerator == denominator {
            TOTAL = TOTAL + n
            continue
        }
        if numerator < denominator { continue }
        if n > LIMIT / denominator { continue }
        if denominator == 1 { continue }
        let p: i64 = factor_smallest(denominator)
        # min exponent: how many times p divides denominator? for the forced min, use valuation of denom
        # From python: p, min_exponent = factor_items_tuple(denominator)[0]
        # factor_items_tuple returns sorted unique primes with exponents of the full factorization
        # So we need the smallest prime and its exponent in denominator
        let mut min_exp: i32 = 0
        let mut tmp: i64 = denominator
        while tmp % p == 0 {
            tmp = tmp / p
            min_exp = min_exp + 1
        }
        # check p not already used: if n % p == 0 then used
        if n % p == 0 { continue }
        let mut prime_power: i64 = 1
        let mut sigma_power: i64 = 1
        for e in 0..min_exp {
            prime_power = prime_power * p
            sigma_power = sigma_power + prime_power
        }
        while n <= LIMIT / prime_power {
            let mut new_num: i64 = numerator * prime_power
            let mut new_den: i64 = denominator * sigma_power
            let g: i64 = gcd(new_num, new_den)
            new_num = new_num / g
            new_den = new_den / g
            if new_num < new_den { break }
            sn[sp] = n * prime_power
            snum[sp] = new_num
            sden[sp] = new_den
            sp = sp + 1
            if prime_power > LIMIT / p { break }
            prime_power = prime_power * p
            sigma_power = sigma_power + prime_power
        }
    }
    free(sn); free(snum); free(sden)
}

function main() -> i32 {
    let targets: ptr<i64> = calloc(6, 8)
    targets[0] = 3; targets[1] = 5; targets[2] = 7
    targets[3] = 9; targets[4] = 11; targets[5] = 13
    for i in 0..6 {
        search_target(targets[i])
    }
    printf("%lld\n", TOTAL)
    free(targets)
    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 addmod_i64_i64_i64(int64_t a, int64_t b, int64_t mod);
int64_t mulmod_i64_i64_i64(int64_t a0, int64_t b0, int64_t mod);
int64_t modpow_i64_i64_i64(int64_t base, int64_t exp, int64_t mod);
bool is_prime_i64(int64_t value);
int64_t pollard_rho_i64(int64_t n);
int64_t factor_smallest_i64(int64_t n0);
void search_target_i64(int64_t target_num);
int32_t main(void);

static const int64_t LIMIT = 1000000000000000000;

/* Module statics */
static int64_t TOTAL = 0;



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 addmod_i64_i64_i64(int64_t a, int64_t b, int64_t mod) {
    int64_t s = (a + b);
    if ((s >= mod || s < a)) {
        return (s - mod);
    }
    return s;
}

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));
    if (a < 0) {
        a = (a + mod);
    }
    if (b < 0) {
        b = (b + mod);
    }
    int64_t result = 0;
    while (b > 0) {
        if (FLOW_CHECKED_MOD((b), (2)) == 1) {
            result = addmod_i64_i64_i64(result, a, mod);
        }
        a = addmod_i64_i64_i64(a, a, mod);
        b = FLOW_CHECKED_DIV((b), (2));
    }
    return result;
}

int64_t modpow_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 = mulmod_i64_i64_i64(r, b, mod);
        }
        b = mulmod_i64_i64_i64(b, b, mod);
        e = FLOW_CHECKED_DIV((e), (2));
    }
    return r;
}

bool is_prime_i64(int64_t value) {
    if (value < 2) {
        return 0;
    }
    if (FLOW_CHECKED_MOD((value), (2)) == 0) {
        return value == 2;
    }
    if (FLOW_CHECKED_MOD((value), (3)) == 0) {
        return value == 3;
    }
    if (FLOW_CHECKED_MOD((value), (5)) == 0) {
        return value == 5;
    }
    if (FLOW_CHECKED_MOD((value), (7)) == 0) {
        return value == 7;
    }
    if (FLOW_CHECKED_MOD((value), (11)) == 0) {
        return value == 11;
    }
    if (FLOW_CHECKED_MOD((value), (13)) == 0) {
        return value == 13;
    }
    if (FLOW_CHECKED_MOD((value), (17)) == 0) {
        return value == 17;
    }
    if (FLOW_CHECKED_MOD((value), (19)) == 0) {
        return value == 19;
    }
    if (FLOW_CHECKED_MOD((value), (23)) == 0) {
        return value == 23;
    }
    if (FLOW_CHECKED_MOD((value), (29)) == 0) {
        return value == 29;
    }
    int64_t d = (value - 1);
    int32_t shifts = 0;
    while (FLOW_CHECKED_MOD((d), (2)) == 0) {
        d = FLOW_CHECKED_DIV((d), (2));
        shifts = (shifts + 1);
    }
    int64_t* bases = (int64_t*)(calloc(7, 8));
    bases[0] = 2;
    bases[1] = 325;
    bases[2] = 9375;
    bases[3] = 28178;
    bases[4] = 450775;
    bases[5] = 9780504;
    bases[6] = 1795265022;
    int32_t __flow_step_1 = 1;
    for (int32_t bi = 0; (0 <= 7) ? bi < 7 : bi > 7; bi += (0 <= 7) ? 1 : -1) {
        int64_t base = FLOW_CHECKED_MOD((bases[bi]), (value));
        if (base != 0) {
            int64_t x = modpow_i64_i64_i64(base, d, value);
            if ((!((x == 1 || x == (value - 1))))) {
                bool ok = 0;
                int32_t r = 0;
                while (r < (shifts - 1)) {
                    x = mulmod_i64_i64_i64(x, x, value);
                    if (x == (value - 1)) {
                        ok = 1;
                        break;
                    }
                    r = (r + 1);
                }
                if ((!(ok))) {
                    free(bases);
                    return 0;
                }
            }
        }
    }
    free(bases);
    return 1;
}

int64_t pollard_rho_i64(int64_t n) {
    if (FLOW_CHECKED_MOD((n), (2)) == 0) {
        return 2;
    }
    int64_t c = 1;
    while (1) {
        int64_t x = 2;
        int64_t y = 2;
        int64_t d = 1;
        while (d == 1) {
            x = addmod_i64_i64_i64(mulmod_i64_i64_i64(x, x, n), c, n);
            y = addmod_i64_i64_i64(mulmod_i64_i64_i64(y, y, n), c, n);
            y = addmod_i64_i64_i64(mulmod_i64_i64_i64(y, y, n), c, n);
            int64_t diff = (x - y);
            if (diff < 0) {
                diff = (0 - diff);
            }
            d = gcd_i64_i64(diff, n);
        }
        if (d != n) {
            return d;
        }
        c = (c + 1);
    }
    return n;
}

int64_t factor_smallest_i64(int64_t n0) {
    int64_t n = n0;
    if (FLOW_CHECKED_MOD((n), (2)) == 0) {
        return 2;
    }
    if (is_prime_i64(n)) {
        return n;
    }
    int64_t f = pollard_rho_i64(n);
    while ((!(is_prime_i64(f)))) {
        f = pollard_rho_i64(f);
    }
    int64_t spf = f;
    int64_t rem = n0;
    int64_t p = 2;
    while (((p * p) <= rem && p <= 1000000)) {
        if (FLOW_CHECKED_MOD((rem), (p)) == 0) {
            return p;
        }
        if (p == 2) {
            p = 3;
        } else {
            p = (p + 2);
        }
    }
    if ((rem > 1 && is_prime_i64(rem))) {
        return rem;
    }
    int64_t* stack = (int64_t*)(calloc(64, 8));
    int32_t sp = 0;
    stack[0] = n0;
    sp = 1;
    int64_t best = n0;
    while (sp > 0) {
        sp = (sp - 1);
        int64_t cur = stack[sp];
        if ((cur < best && is_prime_i64(cur))) {
            best = cur;
            continue;
        }
        if (is_prime_i64(cur)) {
            if (cur < best) {
                best = cur;
            }
            continue;
        }
        int64_t g = pollard_rho_i64(cur);
        stack[sp] = g;
        sp = (sp + 1);
        stack[sp] = FLOW_CHECKED_DIV((cur), (g));
        sp = (sp + 1);
    }
    free(stack);
    return best;
}

void search_target_i64(int64_t target_num) {
    int64_t CAP = 100000;
    int64_t* sn = (int64_t*)(calloc(CAP, 8));
    int64_t* snum = (int64_t*)(calloc(CAP, 8));
    int64_t* sden = (int64_t*)(calloc(CAP, 8));
    int64_t sp = 0;
    sn[0] = 1;
    snum[0] = target_num;
    sden[0] = 2;
    sp = 1;
    while (sp > 0) {
        sp = (sp - 1);
        int64_t n = sn[sp];
        int64_t numerator = snum[sp];
        int64_t denominator = sden[sp];
        if (numerator == denominator) {
            TOTAL = (TOTAL + n);
            continue;
        }
        if (numerator < denominator) {
            continue;
        }
        if (n > FLOW_CHECKED_DIV((LIMIT), (denominator))) {
            continue;
        }
        if (denominator == 1) {
            continue;
        }
        int64_t p = factor_smallest_i64(denominator);
        int32_t min_exp = 0;
        int64_t tmp = denominator;
        while (FLOW_CHECKED_MOD((tmp), (p)) == 0) {
            tmp = FLOW_CHECKED_DIV((tmp), (p));
            min_exp = (min_exp + 1);
        }
        if (FLOW_CHECKED_MOD((n), (p)) == 0) {
            continue;
        }
        int64_t prime_power = 1;
        int64_t sigma_power = 1;
        int32_t __flow_step_2 = 1;
        for (int32_t e = 0; (0 <= min_exp) ? e < min_exp : e > min_exp; e += (0 <= min_exp) ? 1 : -1) {
            prime_power = (prime_power * p);
            sigma_power = (sigma_power + prime_power);
        }
        while (n <= FLOW_CHECKED_DIV((LIMIT), (prime_power))) {
            int64_t new_num = (numerator * prime_power);
            int64_t new_den = (denominator * sigma_power);
            int64_t g = gcd_i64_i64(new_num, new_den);
            new_num = FLOW_CHECKED_DIV((new_num), (g));
            new_den = FLOW_CHECKED_DIV((new_den), (g));
            if (new_num < new_den) {
                break;
            }
            sn[sp] = (n * prime_power);
            snum[sp] = new_num;
            sden[sp] = new_den;
            sp = (sp + 1);
            if (prime_power > FLOW_CHECKED_DIV((LIMIT), (p))) {
                break;
            }
            prime_power = (prime_power * p);
            sigma_power = (sigma_power + prime_power);
        }
    }
    free(sn);
    free(snum);
    free(sden);
}

int32_t main(void) {
    int64_t* targets = (int64_t*)(calloc(6, 8));
    targets[0] = 3;
    targets[1] = 5;
    targets[2] = 7;
    targets[3] = 9;
    targets[4] = 11;
    targets[5] = 13;
    int32_t __flow_step_3 = 1;
    for (int32_t i = 0; (0 <= 6) ? i < 6 : i > 6; i += (0 <= 6) ? 1 : -1) {
        search_target_i64(targets[i]);
    }
    printf("%lld\n", TOTAL);
    free(targets);
    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 @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 @addmod(%arg0: i64, %arg1: i64, %arg2: i64) -> i64 {
    %13 = arith.addi %arg0, %arg1 : i64
    %14 = arith.cmpi sge, %13, %arg2 : i64
    %15 = scf.if %14 -> (i1) {
      %16 = arith.constant true
      scf.yield %16 : i1
    } else {
      %17 = arith.cmpi slt, %13, %arg0 : i64
      scf.yield %17 : i1
    }
    cf.cond_br %15, ^bb3, ^bb4
    ^bb3:
      %18 = arith.subi %13, %arg2 : i64
      func.return %18 : i64
    ^bb4:
      cf.br ^bb5
    ^bb5:
    func.return %13 : i64
  }
  func.func @mulmod(%arg0: i64, %arg1: i64, %arg2: i64) -> i64 {
    %19 = arith.remsi %arg0, %arg2 : i64
    %20 = llvm.mlir.constant(1 : i64) : i64
    %21 = llvm.alloca %20 x i64 : (i64) -> !llvm.ptr
    llvm.store %19, %21 : i64, !llvm.ptr
    %22 = arith.remsi %arg1, %arg2 : i64
    %23 = llvm.mlir.constant(1 : i64) : i64
    %24 = llvm.alloca %23 x i64 : (i64) -> !llvm.ptr
    llvm.store %22, %24 : i64, !llvm.ptr
    %25 = llvm.load %21 : !llvm.ptr -> i64
    %26 = arith.constant 0 : i32
    %28 = arith.extsi %26 : i32 to i64
    %27 = arith.cmpi slt, %25, %28 : i64
    cf.cond_br %27, ^bb6, ^bb7
    ^bb6:
      %29 = llvm.load %21 : !llvm.ptr -> i64
      %30 = arith.addi %29, %arg2 : i64
      llvm.store %30, %21 : i64, !llvm.ptr
      cf.br ^bb8
    ^bb7:
      cf.br ^bb8
    ^bb8:
    %31 = llvm.load %24 : !llvm.ptr -> i64
    %32 = arith.constant 0 : i32
    %34 = arith.extsi %32 : i32 to i64
    %33 = arith.cmpi slt, %31, %34 : i64
    cf.cond_br %33, ^bb9, ^bb10
    ^bb9:
      %35 = llvm.load %24 : !llvm.ptr -> i64
      %36 = arith.addi %35, %arg2 : i64
      llvm.store %36, %24 : i64, !llvm.ptr
      cf.br ^bb11
    ^bb10:
      cf.br ^bb11
    ^bb11:
    %37 = arith.constant 0 : i32
    %38 = arith.extsi %37 : i32 to i64
    %39 = llvm.mlir.constant(1 : i64) : i64
    %40 = llvm.alloca %39 x i64 : (i64) -> !llvm.ptr
    llvm.store %38, %40 : i64, !llvm.ptr
    cf.br ^bb12
    ^bb12:
    %41 = llvm.load %24 : !llvm.ptr -> i64
    %42 = arith.constant 0 : i32
    %44 = arith.extsi %42 : i32 to i64
    %43 = arith.cmpi sgt, %41, %44 : i64
    cf.cond_br %43, ^bb13, ^bb14
    ^bb13:
      %45 = llvm.load %24 : !llvm.ptr -> i64
      %46 = arith.constant 2 : i32
      %48 = arith.extsi %46 : i32 to i64
      %47 = arith.remsi %45, %48 : i64
      %49 = arith.constant 1 : i32
      %51 = arith.extsi %49 : i32 to i64
      %50 = arith.cmpi eq, %47, %51 : i64
      cf.cond_br %50, ^bb15, ^bb16
      ^bb15:
        %53 = llvm.load %40 : !llvm.ptr -> i64
        %54 = llvm.load %21 : !llvm.ptr -> i64
        %52 = func.call @addmod(%53, %54, %arg2) : (i64, i64, i64) -> i64
        llvm.store %52, %40 : i64, !llvm.ptr
        cf.br ^bb17
      ^bb16:
        cf.br ^bb17
      ^bb17:
      %56 = llvm.load %21 : !llvm.ptr -> i64
      %57 = llvm.load %21 : !llvm.ptr -> i64
      %55 = func.call @addmod(%56, %57, %arg2) : (i64, i64, i64) -> i64
      llvm.store %55, %21 : i64, !llvm.ptr
      %58 = llvm.load %24 : !llvm.ptr -> i64
      %59 = arith.constant 2 : i32
      %61 = arith.extsi %59 : i32 to i64
      %60 = arith.divsi %58, %61 : i64
      llvm.store %60, %24 : i64, !llvm.ptr
      cf.br ^bb12
    ^bb14:
    %62 = llvm.load %40 : !llvm.ptr -> i64
    func.return %62 : i64
  }
  func.func @modpow(%arg0: i64, %arg1: i64, %arg2: i64) -> i64 {
    %63 = arith.constant 1 : i32
    %64 = arith.extsi %63 : i32 to i64
    %65 = llvm.mlir.constant(1 : i64) : i64
    %66 = llvm.alloca %65 x i64 : (i64) -> !llvm.ptr
    llvm.store %64, %66 : i64, !llvm.ptr
    %67 = arith.remsi %arg0, %arg2 : i64
    %68 = llvm.mlir.constant(1 : i64) : i64
    %69 = llvm.alloca %68 x i64 : (i64) -> !llvm.ptr
    llvm.store %67, %69 : i64, !llvm.ptr
    %70 = llvm.mlir.constant(1 : i64) : i64
    %71 = llvm.alloca %70 x i64 : (i64) -> !llvm.ptr
    llvm.store %arg1, %71 : i64, !llvm.ptr
    cf.br ^bb18
    ^bb18:
    %72 = llvm.load %71 : !llvm.ptr -> i64
    %73 = arith.constant 0 : i32
    %75 = arith.extsi %73 : i32 to i64
    %74 = arith.cmpi sgt, %72, %75 : i64
    cf.cond_br %74, ^bb19, ^bb20
    ^bb19:
      %76 = llvm.load %71 : !llvm.ptr -> i64
      %77 = arith.constant 2 : i32
      %79 = arith.extsi %77 : i32 to i64
      %78 = arith.remsi %76, %79 : i64
      %80 = arith.constant 1 : i32
      %82 = arith.extsi %80 : i32 to i64
      %81 = arith.cmpi eq, %78, %82 : i64
      cf.cond_br %81, ^bb21, ^bb22
      ^bb21:
        %84 = llvm.load %66 : !llvm.ptr -> i64
        %85 = llvm.load %69 : !llvm.ptr -> i64
        %83 = func.call @mulmod(%84, %85, %arg2) : (i64, i64, i64) -> i64
        llvm.store %83, %66 : i64, !llvm.ptr
        cf.br ^bb23
      ^bb22:
        cf.br ^bb23
      ^bb23:
      %87 = llvm.load %69 : !llvm.ptr -> i64
      %88 = llvm.load %69 : !llvm.ptr -> i64
      %86 = func.call @mulmod(%87, %88, %arg2) : (i64, i64, i64) -> i64
      llvm.store %86, %69 : i64, !llvm.ptr
      %89 = llvm.load %71 : !llvm.ptr -> i64
      %90 = arith.constant 2 : i32
      %92 = arith.extsi %90 : i32 to i64
      %91 = arith.divsi %89, %92 : i64
      llvm.store %91, %71 : i64, !llvm.ptr
      cf.br ^bb18
    ^bb20:
    %93 = llvm.load %66 : !llvm.ptr -> i64
    func.return %93 : i64
  }
  func.func @is_prime(%arg0: i64) -> i1 {
    %94 = arith.constant 2 : i32
    %96 = arith.extsi %94 : i32 to i64
    %95 = arith.cmpi slt, %arg0, %96 : i64
    cf.cond_br %95, ^bb24, ^bb25
    ^bb24:
      %97 = arith.constant 0 : i1
      func.return %97 : i1
    ^bb25:
      cf.br ^bb26
    ^bb26:
    %98 = arith.constant 2 : i32
    %100 = arith.extsi %98 : i32 to i64
    %99 = arith.remsi %arg0, %100 : i64
    %101 = arith.constant 0 : i32
    %103 = arith.extsi %101 : i32 to i64
    %102 = arith.cmpi eq, %99, %103 : i64
    cf.cond_br %102, ^bb27, ^bb28
    ^bb27:
      %104 = arith.constant 2 : i32
      %106 = arith.extsi %104 : i32 to i64
      %105 = arith.cmpi eq, %arg0, %106 : i64
      func.return %105 : i1
    ^bb28:
      cf.br ^bb29
    ^bb29:
    %107 = arith.constant 3 : i32
    %109 = arith.extsi %107 : i32 to i64
    %108 = arith.remsi %arg0, %109 : i64
    %110 = arith.constant 0 : i32
    %112 = arith.extsi %110 : i32 to i64
    %111 = arith.cmpi eq, %108, %112 : i64
    cf.cond_br %111, ^bb30, ^bb31
    ^bb30:
      %113 = arith.constant 3 : i32
      %115 = arith.extsi %113 : i32 to i64
      %114 = arith.cmpi eq, %arg0, %115 : i64
      func.return %114 : i1
    ^bb31:
      cf.br ^bb32
    ^bb32:
    %116 = arith.constant 5 : i32
    %118 = arith.extsi %116 : i32 to i64
    %117 = arith.remsi %arg0, %118 : i64
    %119 = arith.constant 0 : i32
    %121 = arith.extsi %119 : i32 to i64
    %120 = arith.cmpi eq, %117, %121 : i64
    cf.cond_br %120, ^bb33, ^bb34
    ^bb33:
      %122 = arith.constant 5 : i32
      %124 = arith.extsi %122 : i32 to i64
      %123 = arith.cmpi eq, %arg0, %124 : i64
      func.return %123 : i1
    ^bb34:
      cf.br ^bb35
    ^bb35:
    %125 = arith.constant 7 : i32
    %127 = arith.extsi %125 : i32 to i64
    %126 = arith.remsi %arg0, %127 : i64
    %128 = arith.constant 0 : i32
    %130 = arith.extsi %128 : i32 to i64
    %129 = arith.cmpi eq, %126, %130 : i64
    cf.cond_br %129, ^bb36, ^bb37
    ^bb36:
      %131 = arith.constant 7 : i32
      %133 = arith.extsi %131 : i32 to i64
      %132 = arith.cmpi eq, %arg0, %133 : i64
      func.return %132 : i1
    ^bb37:
      cf.br ^bb38
    ^bb38:
    %134 = arith.constant 11 : i32
    %136 = arith.extsi %134 : i32 to i64
    %135 = arith.remsi %arg0, %136 : i64
    %137 = arith.constant 0 : i32
    %139 = arith.extsi %137 : i32 to i64
    %138 = arith.cmpi eq, %135, %139 : i64
    cf.cond_br %138, ^bb39, ^bb40
    ^bb39:
      %140 = arith.constant 11 : i32
      %142 = arith.extsi %140 : i32 to i64
      %141 = arith.cmpi eq, %arg0, %142 : i64
      func.return %141 : i1
    ^bb40:
      cf.br ^bb41
    ^bb41:
    %143 = arith.constant 13 : i32
    %145 = arith.extsi %143 : i32 to i64
    %144 = arith.remsi %arg0, %145 : i64
    %146 = arith.constant 0 : i32
    %148 = arith.extsi %146 : i32 to i64
    %147 = arith.cmpi eq, %144, %148 : i64
    cf.cond_br %147, ^bb42, ^bb43
    ^bb42:
      %149 = arith.constant 13 : i32
      %151 = arith.extsi %149 : i32 to i64
      %150 = arith.cmpi eq, %arg0, %151 : i64
      func.return %150 : i1
    ^bb43:
      cf.br ^bb44
    ^bb44:
    %152 = arith.constant 17 : 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
    cf.cond_br %156, ^bb45, ^bb46
    ^bb45:
      %158 = arith.constant 17 : i32
      %160 = arith.extsi %158 : i32 to i64
      %159 = arith.cmpi eq, %arg0, %160 : i64
      func.return %159 : i1
    ^bb46:
      cf.br ^bb47
    ^bb47:
    %161 = arith.constant 19 : i32
    %163 = arith.extsi %161 : i32 to i64
    %162 = arith.remsi %arg0, %163 : i64
    %164 = arith.constant 0 : i32
    %166 = arith.extsi %164 : i32 to i64
    %165 = arith.cmpi eq, %162, %166 : i64
    cf.cond_br %165, ^bb48, ^bb49
    ^bb48:
      %167 = arith.constant 19 : i32
      %169 = arith.extsi %167 : i32 to i64
      %168 = arith.cmpi eq, %arg0, %169 : i64
      func.return %168 : i1
    ^bb49:
      cf.br ^bb50
    ^bb50:
    %170 = arith.constant 23 : i32
    %172 = arith.extsi %170 : i32 to i64
    %171 = arith.remsi %arg0, %172 : i64
    %173 = arith.constant 0 : i32
    %175 = arith.extsi %173 : i32 to i64
    %174 = arith.cmpi eq, %171, %175 : i64
    cf.cond_br %174, ^bb51, ^bb52
    ^bb51:
      %176 = arith.constant 23 : i32
      %178 = arith.extsi %176 : i32 to i64
      %177 = arith.cmpi eq, %arg0, %178 : i64
      func.return %177 : i1
    ^bb52:
      cf.br ^bb53
    ^bb53:
    %179 = arith.constant 29 : i32
    %181 = arith.extsi %179 : i32 to i64
    %180 = arith.remsi %arg0, %181 : i64
    %182 = arith.constant 0 : i32
    %184 = arith.extsi %182 : i32 to i64
    %183 = arith.cmpi eq, %180, %184 : i64
    cf.cond_br %183, ^bb54, ^bb55
    ^bb54:
      %185 = arith.constant 29 : i32
      %187 = arith.extsi %185 : i32 to i64
      %186 = arith.cmpi eq, %arg0, %187 : i64
      func.return %186 : i1
    ^bb55:
      cf.br ^bb56
    ^bb56:
    %188 = arith.constant 1 : i32
    %190 = arith.extsi %188 : i32 to i64
    %189 = arith.subi %arg0, %190 : i64
    %191 = llvm.mlir.constant(1 : i64) : i64
    %192 = llvm.alloca %191 x i64 : (i64) -> !llvm.ptr
    llvm.store %189, %192 : i64, !llvm.ptr
    %193 = arith.constant 0 : i32
    %194 = llvm.mlir.constant(1 : i64) : i64
    %195 = llvm.alloca %194 x i32 : (i64) -> !llvm.ptr
    llvm.store %193, %195 : i32, !llvm.ptr
    cf.br ^bb57
    ^bb57:
    %196 = llvm.load %192 : !llvm.ptr -> i64
    %197 = arith.constant 2 : i32
    %199 = arith.extsi %197 : i32 to i64
    %198 = arith.remsi %196, %199 : i64
    %200 = arith.constant 0 : i32
    %202 = arith.extsi %200 : i32 to i64
    %201 = arith.cmpi eq, %198, %202 : i64
    cf.cond_br %201, ^bb58, ^bb59
    ^bb58:
      %203 = llvm.load %192 : !llvm.ptr -> i64
      %204 = arith.constant 2 : i32
      %206 = arith.extsi %204 : i32 to i64
      %205 = arith.divsi %203, %206 : i64
      llvm.store %205, %192 : i64, !llvm.ptr
      %207 = llvm.load %195 : !llvm.ptr -> i32
      %208 = arith.constant 1 : i32
      %209 = arith.addi %207, %208 : i32
      llvm.store %209, %195 : i32, !llvm.ptr
      cf.br ^bb57
    ^bb59:
    %211 = arith.constant 7 : i32
    %212 = arith.constant 8 : i32
    %213 = arith.extsi %211 : i32 to i64
    %214 = arith.extsi %212 : i32 to i64
    %210 = func.call @calloc(%213, %214) : (i64, i64) -> !llvm.ptr
    %215 = arith.constant 2 : i32
    %216 = arith.constant 0 : i32
    %217 = arith.extsi %215 : i32 to i64
    %218 = arith.extsi %216 : i32 to i64
    %219 = llvm.getelementptr %210[%218] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    llvm.store %217, %219 : i64, !llvm.ptr
    %220 = arith.constant 325 : i32
    %221 = arith.constant 1 : i32
    %222 = arith.extsi %220 : i32 to i64
    %223 = arith.extsi %221 : i32 to i64
    %224 = llvm.getelementptr %210[%223] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    llvm.store %222, %224 : i64, !llvm.ptr
    %225 = arith.constant 9375 : i32
    %226 = arith.constant 2 : i32
    %227 = arith.extsi %225 : i32 to i64
    %228 = arith.extsi %226 : i32 to i64
    %229 = llvm.getelementptr %210[%228] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    llvm.store %227, %229 : i64, !llvm.ptr
    %230 = arith.constant 28178 : i32
    %231 = arith.constant 3 : i32
    %232 = arith.extsi %230 : i32 to i64
    %233 = arith.extsi %231 : i32 to i64
    %234 = llvm.getelementptr %210[%233] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    llvm.store %232, %234 : i64, !llvm.ptr
    %235 = arith.constant 450775 : i32
    %236 = arith.constant 4 : i32
    %237 = arith.extsi %235 : i32 to i64
    %238 = arith.extsi %236 : i32 to i64
    %239 = llvm.getelementptr %210[%238] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    llvm.store %237, %239 : i64, !llvm.ptr
    %240 = arith.constant 9780504 : i32
    %241 = arith.constant 5 : i32
    %242 = arith.extsi %240 : i32 to i64
    %243 = arith.extsi %241 : i32 to i64
    %244 = llvm.getelementptr %210[%243] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    llvm.store %242, %244 : i64, !llvm.ptr
    %245 = arith.constant 1795265022 : i32
    %246 = arith.constant 6 : i32
    %247 = arith.extsi %245 : i32 to i64
    %248 = arith.extsi %246 : i32 to i64
    %249 = llvm.getelementptr %210[%248] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    llvm.store %247, %249 : i64, !llvm.ptr
    %250 = arith.constant 0 : i32
    %251 = arith.constant 7 : i32
    %252 = arith.index_cast %250 : i32 to index
    %253 = arith.index_cast %251 : i32 to index
    %255 = arith.constant 1 : index
    %256 = arith.constant -1 : index
    %257 = arith.cmpi sle, %252, %253 : index
    %254 = arith.select %257, %255, %256 : index
    cf.br ^bb60(%252 : index)
    ^bb60(%258: index):
    %259 = arith.cmpi slt, %258, %253 : index
    %260 = arith.cmpi sgt, %258, %253 : index
    %261 = arith.select %257, %259, %260 : i1
    cf.cond_br %261, ^bb61(%258 : index), ^bb62(%258 : index)
    ^bb61(%262: index):
      %264 = arith.index_cast %262 : index to i64
      %265 = llvm.getelementptr %210[%264] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %263 = llvm.load %265 : !llvm.ptr -> i64
      %266 = arith.remsi %263, %arg0 : i64
      %267 = arith.constant 0 : i32
      %269 = arith.extsi %267 : i32 to i64
      %268 = arith.cmpi ne, %266, %269 : i64
      cf.cond_br %268, ^bb63, ^bb64
      ^bb63:
        %271 = llvm.load %192 : !llvm.ptr -> i64
        %270 = func.call @modpow(%266, %271, %arg0) : (i64, i64, i64) -> i64
        %272 = llvm.mlir.constant(1 : i64) : i64
        %273 = llvm.alloca %272 x i64 : (i64) -> !llvm.ptr
        llvm.store %270, %273 : i64, !llvm.ptr
        %274 = llvm.load %273 : !llvm.ptr -> i64
        %275 = arith.constant 1 : i32
        %277 = arith.extsi %275 : i32 to i64
        %276 = arith.cmpi eq, %274, %277 : i64
        %278 = scf.if %276 -> (i1) {
          %279 = arith.constant true
          scf.yield %279 : i1
        } else {
          %280 = llvm.load %273 : !llvm.ptr -> i64
          %281 = arith.constant 1 : i32
          %283 = arith.extsi %281 : i32 to i64
          %282 = arith.subi %arg0, %283 : i64
          %284 = arith.cmpi eq, %280, %282 : i64
          scf.yield %284 : i1
        }
        %286 = arith.constant 1 : i1
        %285 = arith.xori %278, %286 : i1
        cf.cond_br %285, ^bb66, ^bb67
        ^bb66:
          %288 = arith.constant 0 : i1
          %289 = llvm.mlir.constant(1 : i64) : i64
          %290 = llvm.alloca %289 x i1 : (i64) -> !llvm.ptr
          llvm.store %288, %290 : i1, !llvm.ptr
          %291 = arith.constant 0 : i32
          %292 = llvm.mlir.constant(1 : i64) : i64
          %293 = llvm.alloca %292 x i32 : (i64) -> !llvm.ptr
          llvm.store %291, %293 : i32, !llvm.ptr
          cf.br ^bb69
          ^bb69:
          %294 = llvm.load %293 : !llvm.ptr -> i32
          %295 = llvm.load %195 : !llvm.ptr -> i32
          %296 = arith.constant 1 : i32
          %297 = arith.subi %295, %296 : i32
          %298 = arith.cmpi slt, %294, %297 : i32
          cf.cond_br %298, ^bb70, ^bb71
          ^bb70:
            %300 = llvm.load %273 : !llvm.ptr -> i64
            %301 = llvm.load %273 : !llvm.ptr -> i64
            %299 = func.call @mulmod(%300, %301, %arg0) : (i64, i64, i64) -> i64
            llvm.store %299, %273 : i64, !llvm.ptr
            %302 = llvm.load %273 : !llvm.ptr -> i64
            %303 = arith.constant 1 : i32
            %305 = arith.extsi %303 : i32 to i64
            %304 = arith.subi %arg0, %305 : i64
            %306 = arith.cmpi eq, %302, %304 : i64
            cf.cond_br %306, ^bb72, ^bb73
            ^bb72:
              %307 = arith.constant 1 : i1
              llvm.store %307, %290 : i1, !llvm.ptr
              cf.br ^bb71
            ^bb73:
              cf.br ^bb74
            ^bb74:
            %308 = llvm.load %293 : !llvm.ptr -> i32
            %309 = arith.constant 1 : i32
            %310 = arith.addi %308, %309 : i32
            llvm.store %310, %293 : i32, !llvm.ptr
            cf.br ^bb69
          ^bb71:
          %311 = llvm.load %290 : !llvm.ptr -> i1
          %313 = arith.constant 1 : i1
          %312 = arith.xori %311, %313 : i1
          cf.cond_br %312, ^bb75, ^bb76
          ^bb75:
            func.call @free(%210) : (!llvm.ptr) -> ()
            %316 = arith.constant 0 : i1
            func.return %316 : i1
          ^bb76:
            cf.br ^bb77
          ^bb77:
          cf.br ^bb68
        ^bb67:
          cf.br ^bb68
        ^bb68:
        cf.br ^bb65
      ^bb64:
        cf.br ^bb65
      ^bb65:
      %317 = arith.addi %262, %254 : index
      cf.br ^bb60(%317 : index)
    ^bb62(%318: index):
    func.call @free(%210) : (!llvm.ptr) -> ()
    %320 = arith.constant 1 : i1
    func.return %320 : i1
  }
  func.func @pollard_rho(%arg0: i64) -> i64 {
    %321 = arith.constant 2 : i32
    %323 = arith.extsi %321 : i32 to i64
    %322 = arith.remsi %arg0, %323 : i64
    %324 = arith.constant 0 : i32
    %326 = arith.extsi %324 : i32 to i64
    %325 = arith.cmpi eq, %322, %326 : i64
    cf.cond_br %325, ^bb78, ^bb79
    ^bb78:
      %327 = arith.constant 2 : i32
      %328 = arith.extsi %327 : i32 to i64
      func.return %328 : i64
    ^bb79:
      cf.br ^bb80
    ^bb80:
    %329 = arith.constant 1 : i32
    %330 = arith.extsi %329 : i32 to i64
    %331 = llvm.mlir.constant(1 : i64) : i64
    %332 = llvm.alloca %331 x i64 : (i64) -> !llvm.ptr
    llvm.store %330, %332 : i64, !llvm.ptr
    cf.br ^bb81
    ^bb81:
    %333 = arith.constant 1 : i1
    cf.cond_br %333, ^bb82, ^bb83
    ^bb82:
      %334 = arith.constant 2 : i32
      %335 = arith.extsi %334 : i32 to i64
      %336 = llvm.mlir.constant(1 : i64) : i64
      %337 = llvm.alloca %336 x i64 : (i64) -> !llvm.ptr
      llvm.store %335, %337 : i64, !llvm.ptr
      %338 = arith.constant 2 : i32
      %339 = arith.extsi %338 : i32 to i64
      %340 = llvm.mlir.constant(1 : i64) : i64
      %341 = llvm.alloca %340 x i64 : (i64) -> !llvm.ptr
      llvm.store %339, %341 : i64, !llvm.ptr
      %342 = arith.constant 1 : i32
      %343 = arith.extsi %342 : i32 to i64
      %344 = llvm.mlir.constant(1 : i64) : i64
      %345 = llvm.alloca %344 x i64 : (i64) -> !llvm.ptr
      llvm.store %343, %345 : i64, !llvm.ptr
      cf.br ^bb84
      ^bb84:
      %346 = llvm.load %345 : !llvm.ptr -> i64
      %347 = arith.constant 1 : i32
      %349 = arith.extsi %347 : i32 to i64
      %348 = arith.cmpi eq, %346, %349 : i64
      cf.cond_br %348, ^bb85, ^bb86
      ^bb85:
        %352 = llvm.load %337 : !llvm.ptr -> i64
        %353 = llvm.load %337 : !llvm.ptr -> i64
        %351 = func.call @mulmod(%352, %353, %arg0) : (i64, i64, i64) -> i64
        %354 = llvm.load %332 : !llvm.ptr -> i64
        %350 = func.call @addmod(%351, %354, %arg0) : (i64, i64, i64) -> i64
        llvm.store %350, %337 : i64, !llvm.ptr
        %357 = llvm.load %341 : !llvm.ptr -> i64
        %358 = llvm.load %341 : !llvm.ptr -> i64
        %356 = func.call @mulmod(%357, %358, %arg0) : (i64, i64, i64) -> i64
        %359 = llvm.load %332 : !llvm.ptr -> i64
        %355 = func.call @addmod(%356, %359, %arg0) : (i64, i64, i64) -> i64
        llvm.store %355, %341 : i64, !llvm.ptr
        %362 = llvm.load %341 : !llvm.ptr -> i64
        %363 = llvm.load %341 : !llvm.ptr -> i64
        %361 = func.call @mulmod(%362, %363, %arg0) : (i64, i64, i64) -> i64
        %364 = llvm.load %332 : !llvm.ptr -> i64
        %360 = func.call @addmod(%361, %364, %arg0) : (i64, i64, i64) -> i64
        llvm.store %360, %341 : i64, !llvm.ptr
        %365 = llvm.load %337 : !llvm.ptr -> i64
        %366 = llvm.load %341 : !llvm.ptr -> i64
        %367 = arith.subi %365, %366 : i64
        %368 = llvm.mlir.constant(1 : i64) : i64
        %369 = llvm.alloca %368 x i64 : (i64) -> !llvm.ptr
        llvm.store %367, %369 : i64, !llvm.ptr
        %370 = llvm.load %369 : !llvm.ptr -> i64
        %371 = arith.constant 0 : i32
        %373 = arith.extsi %371 : i32 to i64
        %372 = arith.cmpi slt, %370, %373 : i64
        cf.cond_br %372, ^bb87, ^bb88
        ^bb87:
          %374 = arith.constant 0 : i32
          %375 = llvm.load %369 : !llvm.ptr -> i64
          %377 = arith.extsi %374 : i32 to i64
          %376 = arith.subi %377, %375 : i64
          llvm.store %376, %369 : i64, !llvm.ptr
          cf.br ^bb89
        ^bb88:
          cf.br ^bb89
        ^bb89:
        %379 = llvm.load %369 : !llvm.ptr -> i64
        %378 = func.call @gcd(%379, %arg0) : (i64, i64) -> i64
        llvm.store %378, %345 : i64, !llvm.ptr
        cf.br ^bb84
      ^bb86:
      %380 = llvm.load %345 : !llvm.ptr -> i64
      %381 = arith.cmpi ne, %380, %arg0 : i64
      cf.cond_br %381, ^bb90, ^bb91
      ^bb90:
        %382 = llvm.load %345 : !llvm.ptr -> i64
        func.return %382 : i64
      ^bb91:
        cf.br ^bb92
      ^bb92:
      %383 = llvm.load %332 : !llvm.ptr -> i64
      %384 = arith.constant 1 : i32
      %386 = arith.extsi %384 : i32 to i64
      %385 = arith.addi %383, %386 : i64
      llvm.store %385, %332 : i64, !llvm.ptr
      cf.br ^bb81
    ^bb83:
    func.return %arg0 : i64
  }
  func.func @factor_smallest(%arg0: i64) -> i64 {
    %387 = llvm.mlir.constant(1 : i64) : i64
    %388 = llvm.alloca %387 x i64 : (i64) -> !llvm.ptr
    llvm.store %arg0, %388 : i64, !llvm.ptr
    %389 = llvm.load %388 : !llvm.ptr -> i64
    %390 = arith.constant 2 : i32
    %392 = arith.extsi %390 : i32 to i64
    %391 = arith.remsi %389, %392 : i64
    %393 = arith.constant 0 : i32
    %395 = arith.extsi %393 : i32 to i64
    %394 = arith.cmpi eq, %391, %395 : i64
    cf.cond_br %394, ^bb93, ^bb94
    ^bb93:
      %396 = arith.constant 2 : i32
      %397 = arith.extsi %396 : i32 to i64
      func.return %397 : i64
    ^bb94:
      cf.br ^bb95
    ^bb95:
    %399 = llvm.load %388 : !llvm.ptr -> i64
    %398 = func.call @is_prime(%399) : (i64) -> i1
    cf.cond_br %398, ^bb96, ^bb97
    ^bb96:
      %400 = llvm.load %388 : !llvm.ptr -> i64
      func.return %400 : i64
    ^bb97:
      cf.br ^bb98
    ^bb98:
    %402 = llvm.load %388 : !llvm.ptr -> i64
    %401 = func.call @pollard_rho(%402) : (i64) -> i64
    cf.br ^bb99(%401 : i64)
    ^bb99(%403: i64):
    %404 = func.call @is_prime(%403) : (i64) -> i1
    %406 = arith.constant 1 : i1
    %405 = arith.xori %404, %406 : i1
    cf.cond_br %405, ^bb100(%403 : i64), ^bb101(%403 : i64)
    ^bb100(%408: i64):
      %409 = func.call @pollard_rho(%408) : (i64) -> i64
      cf.br ^bb99(%409 : i64)
    ^bb101(%410: i64):
    %411 = llvm.mlir.constant(1 : i64) : i64
    %412 = llvm.alloca %411 x i64 : (i64) -> !llvm.ptr
    llvm.store %410, %412 : i64, !llvm.ptr
    %413 = llvm.mlir.constant(1 : i64) : i64
    %414 = llvm.alloca %413 x i64 : (i64) -> !llvm.ptr
    llvm.store %arg0, %414 : i64, !llvm.ptr
    %415 = arith.constant 2 : i32
    %416 = arith.extsi %415 : i32 to i64
    %417 = llvm.mlir.constant(1 : i64) : i64
    %418 = llvm.alloca %417 x i64 : (i64) -> !llvm.ptr
    llvm.store %416, %418 : i64, !llvm.ptr
    cf.br ^bb102
    ^bb102:
    %419 = llvm.load %418 : !llvm.ptr -> i64
    %420 = llvm.load %418 : !llvm.ptr -> i64
    %421 = arith.muli %419, %420 : i64
    %422 = llvm.load %414 : !llvm.ptr -> i64
    %423 = arith.cmpi sle, %421, %422 : i64
    %424 = scf.if %423 -> (i1) {
      %425 = llvm.load %418 : !llvm.ptr -> i64
      %426 = arith.constant 1000000 : i32
      %428 = arith.extsi %426 : i32 to i64
      %427 = arith.cmpi sle, %425, %428 : i64
      scf.yield %427 : i1
    } else {
      %429 = arith.constant false
      scf.yield %429 : i1
    }
    cf.cond_br %424, ^bb103, ^bb104
    ^bb103:
      %430 = llvm.load %414 : !llvm.ptr -> i64
      %431 = llvm.load %418 : !llvm.ptr -> i64
      %432 = arith.remsi %430, %431 : i64
      %433 = arith.constant 0 : i32
      %435 = arith.extsi %433 : i32 to i64
      %434 = arith.cmpi eq, %432, %435 : i64
      cf.cond_br %434, ^bb105, ^bb106
      ^bb105:
        %436 = llvm.load %418 : !llvm.ptr -> i64
        func.return %436 : i64
      ^bb106:
        cf.br ^bb107
      ^bb107:
      %437 = llvm.load %418 : !llvm.ptr -> i64
      %438 = arith.constant 2 : i32
      %440 = arith.extsi %438 : i32 to i64
      %439 = arith.cmpi eq, %437, %440 : i64
      cf.cond_br %439, ^bb108, ^bb109
      ^bb108:
        %441 = arith.constant 3 : i32
        %442 = arith.extsi %441 : i32 to i64
        llvm.store %442, %418 : i64, !llvm.ptr
        cf.br ^bb110
      ^bb109:
        %443 = llvm.load %418 : !llvm.ptr -> i64
        %444 = arith.constant 2 : i32
        %446 = arith.extsi %444 : i32 to i64
        %445 = arith.addi %443, %446 : i64
        llvm.store %445, %418 : i64, !llvm.ptr
        cf.br ^bb110
      ^bb110:
      cf.br ^bb102
    ^bb104:
    %447 = llvm.load %414 : !llvm.ptr -> i64
    %448 = arith.constant 1 : i32
    %450 = arith.extsi %448 : i32 to i64
    %449 = arith.cmpi sgt, %447, %450 : i64
    %451 = scf.if %449 -> (i1) {
      %453 = llvm.load %414 : !llvm.ptr -> i64
      %452 = func.call @is_prime(%453) : (i64) -> i1
      scf.yield %452 : i1
    } else {
      %454 = arith.constant false
      scf.yield %454 : i1
    }
    cf.cond_br %451, ^bb111, ^bb112
    ^bb111:
      %455 = llvm.load %414 : !llvm.ptr -> i64
      func.return %455 : i64
    ^bb112:
      cf.br ^bb113
    ^bb113:
    %457 = arith.constant 64 : i32
    %458 = arith.constant 8 : i32
    %459 = arith.extsi %457 : i32 to i64
    %460 = arith.extsi %458 : i32 to i64
    %456 = func.call @calloc(%459, %460) : (i64, i64) -> !llvm.ptr
    %461 = llvm.mlir.constant(1 : i64) : i64
    %462 = llvm.alloca %461 x !llvm.ptr : (i64) -> !llvm.ptr
    llvm.store %456, %462 : !llvm.ptr, !llvm.ptr
    %463 = arith.constant 0 : i32
    %464 = llvm.mlir.constant(1 : i64) : i64
    %465 = llvm.alloca %464 x i32 : (i64) -> !llvm.ptr
    llvm.store %463, %465 : i32, !llvm.ptr
    %466 = llvm.load %462 : !llvm.ptr -> !llvm.ptr
    %467 = arith.constant 0 : i32
    %468 = arith.extsi %467 : i32 to i64
    %469 = llvm.getelementptr %466[%468] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    llvm.store %arg0, %469 : i64, !llvm.ptr
    %470 = arith.constant 1 : i32
    llvm.store %470, %465 : i32, !llvm.ptr
    %471 = llvm.mlir.constant(1 : i64) : i64
    %472 = llvm.alloca %471 x i64 : (i64) -> !llvm.ptr
    llvm.store %arg0, %472 : i64, !llvm.ptr
    cf.br ^bb114
    ^bb114:
    %473 = llvm.load %465 : !llvm.ptr -> i32
    %474 = arith.constant 0 : i32
    %475 = arith.cmpi sgt, %473, %474 : i32
    cf.cond_br %475, ^bb115, ^bb116
    ^bb115:
      %476 = llvm.load %465 : !llvm.ptr -> i32
      %477 = arith.constant 1 : i32
      %478 = arith.subi %476, %477 : i32
      llvm.store %478, %465 : i32, !llvm.ptr
      %480 = llvm.load %462 : !llvm.ptr -> !llvm.ptr
      %481 = llvm.load %465 : !llvm.ptr -> i32
      %482 = arith.extsi %481 : i32 to i64
      %483 = llvm.getelementptr %480[%482] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %479 = llvm.load %483 : !llvm.ptr -> i64
      %484 = llvm.load %472 : !llvm.ptr -> i64
      %485 = arith.cmpi slt, %479, %484 : i64
      %486 = scf.if %485 -> (i1) {
        %487 = func.call @is_prime(%479) : (i64) -> i1
        scf.yield %487 : i1
      } else {
        %488 = arith.constant false
        scf.yield %488 : i1
      }
      cf.cond_br %486, ^bb117, ^bb118
      ^bb117:
        llvm.store %479, %472 : i64, !llvm.ptr
        cf.br ^bb114
      ^bb118:
        cf.br ^bb119
      ^bb119:
      %489 = func.call @is_prime(%479) : (i64) -> i1
      cf.cond_br %489, ^bb120, ^bb121
      ^bb120:
        %490 = llvm.load %472 : !llvm.ptr -> i64
        %491 = arith.cmpi slt, %479, %490 : i64
        cf.cond_br %491, ^bb123, ^bb124
        ^bb123:
          llvm.store %479, %472 : i64, !llvm.ptr
          cf.br ^bb125
        ^bb124:
          cf.br ^bb125
        ^bb125:
        cf.br ^bb114
      ^bb121:
        cf.br ^bb122
      ^bb122:
      %492 = func.call @pollard_rho(%479) : (i64) -> i64
      %493 = llvm.load %462 : !llvm.ptr -> !llvm.ptr
      %494 = llvm.load %465 : !llvm.ptr -> i32
      %495 = arith.extsi %494 : i32 to i64
      %496 = llvm.getelementptr %493[%495] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %492, %496 : i64, !llvm.ptr
      %497 = llvm.load %465 : !llvm.ptr -> i32
      %498 = arith.constant 1 : i32
      %499 = arith.addi %497, %498 : i32
      llvm.store %499, %465 : i32, !llvm.ptr
      %500 = arith.divsi %479, %492 : i64
      %501 = llvm.load %462 : !llvm.ptr -> !llvm.ptr
      %502 = llvm.load %465 : !llvm.ptr -> i32
      %503 = arith.extsi %502 : i32 to i64
      %504 = llvm.getelementptr %501[%503] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %500, %504 : i64, !llvm.ptr
      %505 = llvm.load %465 : !llvm.ptr -> i32
      %506 = arith.constant 1 : i32
      %507 = arith.addi %505, %506 : i32
      llvm.store %507, %465 : i32, !llvm.ptr
      cf.br ^bb114
    ^bb116:
    %509 = llvm.load %462 : !llvm.ptr -> !llvm.ptr
    func.call @free(%509) : (!llvm.ptr) -> ()
    %510 = llvm.load %472 : !llvm.ptr -> i64
    func.return %510 : i64
  }
  // Module static: TOTAL
  llvm.mlir.global internal @TOTAL(0 : i64) : i64
  // Constant: LIMIT
  llvm.mlir.global internal constant @LIMIT(1000000000000000000 : i64) : i64
  func.func @search_target(%arg0: i64) -> () {
    %511 = arith.constant 100000 : i32
    %512 = arith.extsi %511 : i32 to i64
    %514 = arith.constant 8 : i32
    %515 = arith.extsi %514 : i32 to i64
    %513 = func.call @calloc(%512, %515) : (i64, i64) -> !llvm.ptr
    %517 = arith.constant 8 : i32
    %518 = arith.extsi %517 : i32 to i64
    %516 = func.call @calloc(%512, %518) : (i64, i64) -> !llvm.ptr
    %520 = arith.constant 8 : i32
    %521 = arith.extsi %520 : i32 to i64
    %519 = func.call @calloc(%512, %521) : (i64, i64) -> !llvm.ptr
    %522 = arith.constant 0 : i32
    %523 = arith.extsi %522 : i32 to i64
    %524 = llvm.mlir.constant(1 : i64) : i64
    %525 = llvm.alloca %524 x i64 : (i64) -> !llvm.ptr
    llvm.store %523, %525 : i64, !llvm.ptr
    %526 = arith.constant 1 : i32
    %527 = arith.constant 0 : i32
    %528 = arith.extsi %526 : i32 to i64
    %529 = arith.extsi %527 : i32 to i64
    %530 = llvm.getelementptr %513[%529] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    llvm.store %528, %530 : i64, !llvm.ptr
    %531 = arith.constant 0 : i32
    %532 = arith.extsi %531 : i32 to i64
    %533 = llvm.getelementptr %516[%532] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    llvm.store %arg0, %533 : i64, !llvm.ptr
    %534 = arith.constant 2 : i32
    %535 = arith.constant 0 : i32
    %536 = arith.extsi %534 : i32 to i64
    %537 = arith.extsi %535 : i32 to i64
    %538 = llvm.getelementptr %519[%537] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    llvm.store %536, %538 : i64, !llvm.ptr
    %539 = arith.constant 1 : i32
    %540 = arith.extsi %539 : i32 to i64
    llvm.store %540, %525 : i64, !llvm.ptr
    cf.br ^bb126
    ^bb126:
    %541 = llvm.load %525 : !llvm.ptr -> i64
    %542 = arith.constant 0 : i32
    %544 = arith.extsi %542 : i32 to i64
    %543 = arith.cmpi sgt, %541, %544 : i64
    cf.cond_br %543, ^bb127, ^bb128
    ^bb127:
      %545 = llvm.load %525 : !llvm.ptr -> i64
      %546 = arith.constant 1 : i32
      %548 = arith.extsi %546 : i32 to i64
      %547 = arith.subi %545, %548 : i64
      llvm.store %547, %525 : i64, !llvm.ptr
      %550 = llvm.load %525 : !llvm.ptr -> i64
      %551 = llvm.getelementptr %513[%550] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %549 = llvm.load %551 : !llvm.ptr -> i64
      %553 = llvm.load %525 : !llvm.ptr -> i64
      %554 = llvm.getelementptr %516[%553] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %552 = llvm.load %554 : !llvm.ptr -> i64
      %556 = llvm.load %525 : !llvm.ptr -> i64
      %557 = llvm.getelementptr %519[%556] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %555 = llvm.load %557 : !llvm.ptr -> i64
      %558 = arith.cmpi eq, %552, %555 : i64
      cf.cond_br %558, ^bb129, ^bb130
      ^bb129:
        %559 = llvm.mlir.addressof @TOTAL : !llvm.ptr
        %560 = llvm.load %559 : !llvm.ptr -> i64
        %561 = arith.addi %560, %549 : i64
        %562 = llvm.mlir.addressof @TOTAL : !llvm.ptr
        llvm.store %561, %562 : i64, !llvm.ptr
        cf.br ^bb126
      ^bb130:
        cf.br ^bb131
      ^bb131:
      %563 = arith.cmpi slt, %552, %555 : i64
      cf.cond_br %563, ^bb132, ^bb133
      ^bb132:
        cf.br ^bb126
      ^bb133:
        cf.br ^bb134
      ^bb134:
      %564 = llvm.mlir.addressof @LIMIT : !llvm.ptr
      %565 = llvm.load %564 : !llvm.ptr -> i64
      %566 = arith.divsi %565, %555 : i64
      %567 = arith.cmpi sgt, %549, %566 : i64
      cf.cond_br %567, ^bb135, ^bb136
      ^bb135:
        cf.br ^bb126
      ^bb136:
        cf.br ^bb137
      ^bb137:
      %568 = arith.constant 1 : i32
      %570 = arith.extsi %568 : i32 to i64
      %569 = arith.cmpi eq, %555, %570 : i64
      cf.cond_br %569, ^bb138, ^bb139
      ^bb138:
        cf.br ^bb126
      ^bb139:
        cf.br ^bb140
      ^bb140:
      %571 = func.call @factor_smallest(%555) : (i64) -> i64
      %572 = arith.constant 0 : i32
      %573 = llvm.mlir.constant(1 : i64) : i64
      %574 = llvm.alloca %573 x i32 : (i64) -> !llvm.ptr
      llvm.store %572, %574 : i32, !llvm.ptr
      %575 = llvm.mlir.constant(1 : i64) : i64
      %576 = llvm.alloca %575 x i64 : (i64) -> !llvm.ptr
      llvm.store %555, %576 : i64, !llvm.ptr
      cf.br ^bb141
      ^bb141:
      %577 = llvm.load %576 : !llvm.ptr -> i64
      %578 = arith.remsi %577, %571 : i64
      %579 = arith.constant 0 : i32
      %581 = arith.extsi %579 : i32 to i64
      %580 = arith.cmpi eq, %578, %581 : i64
      cf.cond_br %580, ^bb142, ^bb143
      ^bb142:
        %582 = llvm.load %576 : !llvm.ptr -> i64
        %583 = arith.divsi %582, %571 : i64
        llvm.store %583, %576 : i64, !llvm.ptr
        %584 = llvm.load %574 : !llvm.ptr -> i32
        %585 = arith.constant 1 : i32
        %586 = arith.addi %584, %585 : i32
        llvm.store %586, %574 : i32, !llvm.ptr
        cf.br ^bb141
      ^bb143:
      %587 = arith.remsi %549, %571 : i64
      %588 = arith.constant 0 : i32
      %590 = arith.extsi %588 : i32 to i64
      %589 = arith.cmpi eq, %587, %590 : i64
      cf.cond_br %589, ^bb144, ^bb145
      ^bb144:
        cf.br ^bb126
      ^bb145:
        cf.br ^bb146
      ^bb146:
      %591 = arith.constant 1 : i32
      %592 = arith.extsi %591 : i32 to i64
      %593 = llvm.mlir.constant(1 : i64) : i64
      %594 = llvm.alloca %593 x i64 : (i64) -> !llvm.ptr
      llvm.store %592, %594 : i64, !llvm.ptr
      %595 = arith.constant 1 : i32
      %596 = arith.extsi %595 : i32 to i64
      %597 = llvm.mlir.constant(1 : i64) : i64
      %598 = llvm.alloca %597 x i64 : (i64) -> !llvm.ptr
      llvm.store %596, %598 : i64, !llvm.ptr
      %599 = arith.constant 0 : i32
      %600 = llvm.load %574 : !llvm.ptr -> i32
      %601 = arith.index_cast %599 : i32 to index
      %602 = arith.index_cast %600 : i32 to index
      %604 = arith.constant 1 : index
      %605 = arith.constant -1 : index
      %606 = arith.cmpi sle, %601, %602 : index
      %603 = arith.select %606, %604, %605 : index
      cf.br ^bb147(%601 : index)
      ^bb147(%607: index):
      %608 = arith.cmpi slt, %607, %602 : index
      %609 = arith.cmpi sgt, %607, %602 : index
      %610 = arith.select %606, %608, %609 : i1
      cf.cond_br %610, ^bb148(%607 : index), ^bb149(%607 : index)
      ^bb148(%611: index):
        %612 = llvm.load %594 : !llvm.ptr -> i64
        %613 = arith.muli %612, %571 : i64
        llvm.store %613, %594 : i64, !llvm.ptr
        %614 = llvm.load %598 : !llvm.ptr -> i64
        %615 = llvm.load %594 : !llvm.ptr -> i64
        %616 = arith.addi %614, %615 : i64
        llvm.store %616, %598 : i64, !llvm.ptr
        %617 = arith.addi %611, %603 : index
        cf.br ^bb147(%617 : index)
      ^bb149(%618: index):
      cf.br ^bb150
      ^bb150:
      %619 = llvm.mlir.addressof @LIMIT : !llvm.ptr
      %620 = llvm.load %619 : !llvm.ptr -> i64
      %621 = llvm.load %594 : !llvm.ptr -> i64
      %622 = arith.divsi %620, %621 : i64
      %623 = arith.cmpi sle, %549, %622 : i64
      cf.cond_br %623, ^bb151, ^bb152
      ^bb151:
        %624 = llvm.load %594 : !llvm.ptr -> i64
        %625 = arith.muli %552, %624 : i64
        %626 = llvm.mlir.constant(1 : i64) : i64
        %627 = llvm.alloca %626 x i64 : (i64) -> !llvm.ptr
        llvm.store %625, %627 : i64, !llvm.ptr
        %628 = llvm.load %598 : !llvm.ptr -> i64
        %629 = arith.muli %555, %628 : i64
        %630 = llvm.mlir.constant(1 : i64) : i64
        %631 = llvm.alloca %630 x i64 : (i64) -> !llvm.ptr
        llvm.store %629, %631 : i64, !llvm.ptr
        %633 = llvm.load %627 : !llvm.ptr -> i64
        %634 = llvm.load %631 : !llvm.ptr -> i64
        %632 = func.call @gcd(%633, %634) : (i64, i64) -> i64
        %635 = llvm.load %627 : !llvm.ptr -> i64
        %636 = arith.divsi %635, %632 : i64
        llvm.store %636, %627 : i64, !llvm.ptr
        %637 = llvm.load %631 : !llvm.ptr -> i64
        %638 = arith.divsi %637, %632 : i64
        llvm.store %638, %631 : i64, !llvm.ptr
        %639 = llvm.load %627 : !llvm.ptr -> i64
        %640 = llvm.load %631 : !llvm.ptr -> i64
        %641 = arith.cmpi slt, %639, %640 : i64
        cf.cond_br %641, ^bb153, ^bb154
        ^bb153:
          cf.br ^bb152
        ^bb154:
          cf.br ^bb155
        ^bb155:
        %642 = llvm.load %594 : !llvm.ptr -> i64
        %643 = arith.muli %549, %642 : i64
        %644 = llvm.load %525 : !llvm.ptr -> i64
        %645 = llvm.getelementptr %513[%644] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        llvm.store %643, %645 : i64, !llvm.ptr
        %646 = llvm.load %627 : !llvm.ptr -> i64
        %647 = llvm.load %525 : !llvm.ptr -> i64
        %648 = llvm.getelementptr %516[%647] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        llvm.store %646, %648 : i64, !llvm.ptr
        %649 = llvm.load %631 : !llvm.ptr -> i64
        %650 = llvm.load %525 : !llvm.ptr -> i64
        %651 = llvm.getelementptr %519[%650] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        llvm.store %649, %651 : i64, !llvm.ptr
        %652 = llvm.load %525 : !llvm.ptr -> i64
        %653 = arith.constant 1 : i32
        %655 = arith.extsi %653 : i32 to i64
        %654 = arith.addi %652, %655 : i64
        llvm.store %654, %525 : i64, !llvm.ptr
        %656 = llvm.load %594 : !llvm.ptr -> i64
        %657 = llvm.mlir.addressof @LIMIT : !llvm.ptr
        %658 = llvm.load %657 : !llvm.ptr -> i64
        %659 = arith.divsi %658, %571 : i64
        %660 = arith.cmpi sgt, %656, %659 : i64
        cf.cond_br %660, ^bb156, ^bb157
        ^bb156:
          cf.br ^bb152
        ^bb157:
          cf.br ^bb158
        ^bb158:
        %661 = llvm.load %594 : !llvm.ptr -> i64
        %662 = arith.muli %661, %571 : i64
        llvm.store %662, %594 : i64, !llvm.ptr
        %663 = llvm.load %598 : !llvm.ptr -> i64
        %664 = llvm.load %594 : !llvm.ptr -> i64
        %665 = arith.addi %663, %664 : i64
        llvm.store %665, %598 : i64, !llvm.ptr
        cf.br ^bb150
      ^bb152:
      cf.br ^bb126
    ^bb128:
    func.call @free(%513) : (!llvm.ptr) -> ()
    func.call @free(%516) : (!llvm.ptr) -> ()
    func.call @free(%519) : (!llvm.ptr) -> ()
    func.return
  }
  func.func @main() -> i32 {
    %670 = arith.constant 6 : i32
    %671 = arith.constant 8 : i32
    %672 = arith.extsi %670 : i32 to i64
    %673 = arith.extsi %671 : i32 to i64
    %669 = func.call @calloc(%672, %673) : (i64, i64) -> !llvm.ptr
    %674 = arith.constant 3 : i32
    %675 = arith.constant 0 : i32
    %676 = arith.extsi %674 : i32 to i64
    %677 = arith.extsi %675 : i32 to i64
    %678 = llvm.getelementptr %669[%677] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    llvm.store %676, %678 : i64, !llvm.ptr
    %679 = arith.constant 5 : i32
    %680 = arith.constant 1 : i32
    %681 = arith.extsi %679 : i32 to i64
    %682 = arith.extsi %680 : i32 to i64
    %683 = llvm.getelementptr %669[%682] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    llvm.store %681, %683 : i64, !llvm.ptr
    %684 = arith.constant 7 : i32
    %685 = arith.constant 2 : i32
    %686 = arith.extsi %684 : i32 to i64
    %687 = arith.extsi %685 : i32 to i64
    %688 = llvm.getelementptr %669[%687] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    llvm.store %686, %688 : i64, !llvm.ptr
    %689 = arith.constant 9 : i32
    %690 = arith.constant 3 : i32
    %691 = arith.extsi %689 : i32 to i64
    %692 = arith.extsi %690 : i32 to i64
    %693 = llvm.getelementptr %669[%692] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    llvm.store %691, %693 : i64, !llvm.ptr
    %694 = arith.constant 11 : i32
    %695 = arith.constant 4 : i32
    %696 = arith.extsi %694 : i32 to i64
    %697 = arith.extsi %695 : i32 to i64
    %698 = llvm.getelementptr %669[%697] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    llvm.store %696, %698 : i64, !llvm.ptr
    %699 = arith.constant 13 : i32
    %700 = arith.constant 5 : i32
    %701 = arith.extsi %699 : i32 to i64
    %702 = arith.extsi %700 : i32 to i64
    %703 = llvm.getelementptr %669[%702] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    llvm.store %701, %703 : i64, !llvm.ptr
    %704 = arith.constant 0 : i32
    %705 = arith.constant 6 : i32
    %706 = arith.index_cast %704 : i32 to index
    %707 = arith.index_cast %705 : i32 to index
    %709 = arith.constant 1 : index
    %710 = arith.constant -1 : index
    %711 = arith.cmpi sle, %706, %707 : index
    %708 = arith.select %711, %709, %710 : index
    cf.br ^bb159(%706 : index)
    ^bb159(%712: index):
    %713 = arith.cmpi slt, %712, %707 : index
    %714 = arith.cmpi sgt, %712, %707 : index
    %715 = arith.select %711, %713, %714 : i1
    cf.cond_br %715, ^bb160(%712 : index), ^bb161(%712 : index)
    ^bb160(%716: index):
      %719 = arith.index_cast %716 : index to i64
      %720 = llvm.getelementptr %669[%719] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %718 = llvm.load %720 : !llvm.ptr -> i64
      func.call @search_target(%718) : (i64) -> ()
      %721 = arith.addi %716, %708 : index
      cf.br ^bb159(%721 : index)
    ^bb161(%722: index):
    %723 = llvm.mlir.addressof @str_0 : !llvm.ptr
    %724 = llvm.mlir.addressof @TOTAL : !llvm.ptr
    %725 = llvm.load %724 : !llvm.ptr -> i64
    %726 = llvm.call @printf(%723, %725) vararg(!llvm.func<i32 (ptr, ...)>) : (!llvm.ptr, i64) -> i32
    func.call @free(%669) : (!llvm.ptr) -> ()
    %728 = arith.constant 0 : i32
    func.return %728 : i32
  }
}