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