Problem 421

sum_{n=1..10^11} s(n,10^8) where s sums prime factors of n^15+1 <= 10^8.

Answer2304215802083466198
Output2304215802083466198
StatusPASS
Native helperno
Runtime3060 ms
Peak memory50016 KB
Time complexityO(n^2) (estimated)
Space complexityO(n) (estimated)

Performance comparison

MetricOur solutionBest known
Time complexityO(n^2)O(sqrt(n))
Space complexityO(n)O(1)
ApproachFlow solutionTrial division or Pollard rho
VerdictSuboptimal

Flow source

# Project Euler 421
# sum_{n=1..10^11} s(n,10^8) where s sums prime factors of n^15+1 <= 10^8.

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

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

function is_order_15(g: i64, p: i64) -> i64 {
    if g == 1 { return 0 }
    let g2: i64 = ((g as i128) * (g as i128) % (p as i128)) as i64
    let g3: i64 = ((g2 as i128) * (g as i128) % (p as i128)) as i64
    if g3 == 1 { return 0 }
    let g5: i64 = ((g2 as i128) * (g3 as i128) % (p as i128)) as i64
    if g5 == 1 { return 0 }
    return 1
}

function find_gen(p: i64, d: i64) -> i64 {
    let exp: i64 = (p - 1) / d
    let bases: ptr<i64> = calloc(30, 8)
    let nb: i64 = 25
    bases[0]=2; bases[1]=3; bases[2]=5; bases[3]=7; bases[4]=11
    bases[5]=13; bases[6]=17; bases[7]=19; bases[8]=23; bases[9]=29
    bases[10]=31; bases[11]=37; bases[12]=41; bases[13]=43; bases[14]=47
    bases[15]=53; bases[16]=59; bases[17]=61; bases[18]=67; bases[19]=71
    bases[20]=73; bases[21]=79; bases[22]=83; bases[23]=89; bases[24]=97
    let mut i: i64 = 0
    while i < nb {
        let a: i64 = bases[i]
        if a >= p { break }
        let g: i64 = modpow(a, exp, p)
        if d == 3 || d == 5 {
            if g != 1 { free(bases); return g }
        } else {
            if is_order_15(g, p) == 1 { free(bases); return g }
        }
        i = i + 1
    }
    let mut a2: i64 = 2
    while a2 < p && a2 < 500 {
        let g2: i64 = modpow(a2, exp, p)
        if d == 3 || d == 5 {
            if g2 != 1 { free(bases); return g2 }
        } else {
            if is_order_15(g2, p) == 1 { free(bases); return g2 }
        }
        a2 = a2 + 1
    }
    free(bases)
    return 1
}

function main() -> i32 {
    let L: i64 = 100000000000
    let M: i64 = 100000000
    let size: i64 = M / 2 + 1
    let odd: ptr<i8> = calloc(size, 1)
    if odd == null { return 1 }
    let mut i: i64 = 0
    while i < size { odd[i] = 1; i = i + 1 }
    odd[0] = 0
    let mut p: i64 = 3
    while p * p <= M {
        if odd[p >> 1] != 0 {
            let mut cur: i64 = (p * p) >> 1
            while cur < size {
                odd[cur] = 0
                cur = cur + p
            }
        }
        p = p + 2
    }

    let d_table: ptr<i32> = calloc(30, 4)
    i = 0
    while i < 30 { d_table[i] = 1; i = i + 1 }
    d_table[1] = 15
    d_table[11] = 5
    d_table[7] = 3
    d_table[13] = 3
    d_table[19] = 3

    let mut ans: i64 = 2 * ((L + 1) / 2)
    p = 3
    while p <= M {
        if odd[p >> 1] != 0 {
            let d: i64 = d_table[p % 30] as i64
            let q: i64 = L / p
            let t: i64 = L % p
            if d == 1 {
                let mut cnt: i64 = q
                if t == p - 1 { cnt = cnt + 1 }
                ans = ans + p * cnt
            } else {
                let g: i64 = find_gen(p, d)
                let threshold: i64 = p - t
                let mut u: i64 = 1
                let mut extra: i64 = 0
                let mut k: i64 = 0
                while k < d {
                    if u >= threshold { extra = extra + 1 }
                    u = ((u as i128) * (g as i128) % (p as i128)) as i64
                    k = k + 1
                }
                ans = ans + p * (d * q + extra)
            }
        }
        p = p + 2
    }
    printf("%lld\n", ans)
    free(d_table)
    free(odd)
    return 0
}

Generated C

#include <stdint.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

/* Flow runtime helpers */
typedef struct flow_temp_node { struct flow_temp_node* next; } flow_temp_node;
static flow_temp_node* flow_temp_head = NULL;
static int flow_temp_atexit_set = 0;
__attribute__((unused)) static void flow_temp_free_all(void) {
    while (flow_temp_head) {
        flow_temp_node* n = flow_temp_head;
        flow_temp_head = n->next;
        free(n);
    }
}
__attribute__((unused)) static void* flow_temp_alloc(size_t nbytes) {
    flow_temp_node* node = (flow_temp_node*)malloc(sizeof(flow_temp_node) + nbytes);
    if (!node) return NULL;
    node->next = flow_temp_head;
    flow_temp_head = node;
    if (!flow_temp_atexit_set) {
        flow_temp_atexit_set = 1;
        atexit(flow_temp_free_all);
    }
    return (void*)(node + 1);
}
#ifndef FLOW_DIAG
#define FLOW_DIAG(msg) fprintf(stderr, "%s", (msg))
#endif
#ifndef FLOW_LOG
#define FLOW_LOG(fmt, ...) printf(fmt, __VA_ARGS__)
#endif
#ifndef FLOW_LOG_EMPTY
#define FLOW_LOG_EMPTY(fmt) printf(fmt)
#endif
static char* flow_strcat(const char* a, const char* b) {
    size_t la = strlen(a ? a : ""), lb = strlen(b ? b : "");
    char* r = (char*)flow_temp_alloc(la + lb + 1);
    if (!r) return NULL;
    if (la) memcpy(r, a, la);
    if (lb) memcpy(r + la, b, lb);
    r[la + lb] = '\0';
    return r;
}

#define __flow_in_arr(arr, val) __extension__ ({ \
    int _found = 0; \
    size_t _n = sizeof(arr)/sizeof((arr)[0]); \
    for (size_t _i = 0; _i < _n; _i++) { \
        if ((arr)[_i] == (val)) { _found = 1; break; } \
    } _found; })

/* Unified fault handler (MISRA #279) — override with -DFLOW_FAULT_HANDLER=fn */
#ifndef FLOW_FAULT_HANDLER
__attribute__((unused)) static inline void flow_fault_handler(const char* msg) {
    fprintf(stderr, "flow: %s\n", msg ? msg : "fault");
    abort();
#if defined(__GNUC__) || defined(__clang__)
    __builtin_unreachable();
#endif
}
#else
#define flow_fault_handler FLOW_FAULT_HANDLER
#endif
#define flow_div_by_zero_handler() flow_fault_handler("division by zero")
#define flow_shift_ub_handler() flow_fault_handler("invalid shift (amount out of range or left-shift of negative)")

#ifndef FLOW_CHECKED_DIV
#define FLOW_CHECKED_DIV(L, R) (((R) != 0) ? ((L) / (R)) : (flow_div_by_zero_handler(), (L) * 0))
#endif
#ifndef FLOW_CHECKED_MOD
#define FLOW_CHECKED_MOD(L, R) (((R) != 0) ? ((L) % (R)) : (flow_div_by_zero_handler(), (L) * 0))
#endif
#ifndef FLOW_CHECKED_SHL
#define FLOW_CHECKED_SHL(L, R) ((((R) >= 0) && ((unsigned long long)(R) < (sizeof(L) * 8ull)) && ((L) >= 0)) ? ((L) << (R)) : (flow_shift_ub_handler(), (L) * 0))
#endif
#ifndef FLOW_CHECKED_SHR
#define FLOW_CHECKED_SHR(L, R) ((((R) >= 0) && ((unsigned long long)(R) < (sizeof(L) * 8ull))) ? ((L) >> (R)) : (flow_shift_ub_handler(), (L) * 0))
#endif

#include <math.h>

void* _ui_state = NULL;

static inline float i32_to_f32(int32_t v) { return (float)v; }

/* Host stub for @gpu kernels (device codegen replaces this). */
static inline int32_t gpu_thread_id(void) { return 0; }

int64_t modpow_i64_i64_i64(int64_t base0, int64_t exp0, int64_t mod);
int64_t is_order_15_i64_i64(int64_t g, int64_t p);
int64_t find_gen_i64_i64(int64_t p, int64_t d);
int32_t main(void);



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

int64_t is_order_15_i64_i64(int64_t g, int64_t p) {
    if (g == 1) {
        return 0;
    }
    int64_t g2 = ((int64_t)(FLOW_CHECKED_MOD(((((__int128)(g)) * ((__int128)(g)))), (((__int128)(p))))));
    int64_t g3 = ((int64_t)(FLOW_CHECKED_MOD(((((__int128)(g2)) * ((__int128)(g)))), (((__int128)(p))))));
    if (g3 == 1) {
        return 0;
    }
    int64_t g5 = ((int64_t)(FLOW_CHECKED_MOD(((((__int128)(g2)) * ((__int128)(g3)))), (((__int128)(p))))));
    if (g5 == 1) {
        return 0;
    }
    return 1;
}

int64_t find_gen_i64_i64(int64_t p, int64_t d) {
    int64_t exp = FLOW_CHECKED_DIV(((p - 1)), (d));
    int64_t* bases = (int64_t*)(calloc(30, 8));
    int64_t nb = 25;
    bases[0] = 2;
    bases[1] = 3;
    bases[2] = 5;
    bases[3] = 7;
    bases[4] = 11;
    bases[5] = 13;
    bases[6] = 17;
    bases[7] = 19;
    bases[8] = 23;
    bases[9] = 29;
    bases[10] = 31;
    bases[11] = 37;
    bases[12] = 41;
    bases[13] = 43;
    bases[14] = 47;
    bases[15] = 53;
    bases[16] = 59;
    bases[17] = 61;
    bases[18] = 67;
    bases[19] = 71;
    bases[20] = 73;
    bases[21] = 79;
    bases[22] = 83;
    bases[23] = 89;
    bases[24] = 97;
    int64_t i = 0;
    while (i < nb) {
        int64_t a = bases[i];
        if (a >= p) {
            break;
        }
        int64_t g = modpow_i64_i64_i64(a, exp, p);
        if ((d == 3 || d == 5)) {
            if (g != 1) {
                free(bases);
                return g;
            }
        } else {
            if (is_order_15_i64_i64(g, p) == 1) {
                free(bases);
                return g;
            }
        }
        i = (i + 1);
    }
    int64_t a2 = 2;
    while ((a2 < p && a2 < 500)) {
        int64_t g2 = modpow_i64_i64_i64(a2, exp, p);
        if ((d == 3 || d == 5)) {
            if (g2 != 1) {
                free(bases);
                return g2;
            }
        } else {
            if (is_order_15_i64_i64(g2, p) == 1) {
                free(bases);
                return g2;
            }
        }
        a2 = (a2 + 1);
    }
    free(bases);
    return 1;
}

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