← All problems
Problem 229
Numbers representable as a^2+b^2, a^2+2b^2, a^2+3b^2, a^2+7b^2 below 2e9.
View problem on Project Euler
Performance comparison
Metric Our solution Best known
Time complexity O(n)O(n log log n)
Space complexity O(n^2)O(n)
Approach Flow solution Sieve-based representation count
Verdict Optimal
Flow source
# Project Euler 229
# Numbers representable as a^2+b^2, a^2+2b^2, a^2+3b^2, a^2+7b^2 below 2e9.
import euler.nt { isqrt }
extern {
function calloc(n: i64, size: i64) -> ptr<void>
function free(p: ptr<void>) -> void
}
function main() -> i32 {
let LIMIT: i64 = 2000000000
let SLICE: i64 = 1000000
let ONE: i32 = 1
let TWO: i32 = 2
let THREE: i32 = 4
let SEVEN: i32 = 8
let ALL: i32 = 15
let used: ptr<i8> = calloc(SLICE, 1)
if used == null { return 1 }
let max_a: i64 = isqrt(LIMIT)
let b1: ptr<i32> = calloc(max_a + 1, 4)
let b2: ptr<i32> = calloc(max_a + 1, 4)
let b3: ptr<i32> = calloc(max_a + 1, 4)
let b7: ptr<i32> = calloc(max_a + 1, 4)
if b1 == null || b2 == null || b3 == null || b7 == null { return 1 }
let mut a: i64 = 1
while a <= max_a {
b1[a] = 1; b2[a] = 1; b3[a] = 1; b7[a] = 1
a = a + 1
}
let mut count: i64 = 0
let mut start: i64 = 0
while start < LIMIT {
let mut end: i64 = start + SLICE
if end > LIMIT { end = LIMIT }
a = 1
while a <= max_a {
if a * a + (b1[a] as i64) * (b1[a] as i64) >= end { break }
let mut b: i64 = b1[a] as i64
while a * a + b * b < end {
used[a * a + b * b - start] = (used[a * a + b * b - start] as i32 | ONE) as i8
b = b + 1
}
b1[a] = b as i32
b = b2[a] as i64
while a * a + 2 * b * b < end {
used[a * a + 2 * b * b - start] = (used[a * a + 2 * b * b - start] as i32 | TWO) as i8
b = b + 1
}
b2[a] = b as i32
b = b3[a] as i64
while a * a + 3 * b * b < end {
used[a * a + 3 * b * b - start] = (used[a * a + 3 * b * b - start] as i32 | THREE) as i8
b = b + 1
}
b3[a] = b as i32
b = b7[a] as i64
while a * a + 7 * b * b < end {
used[a * a + 7 * b * b - start] = (used[a * a + 7 * b * b - start] as i32 | SEVEN) as i8
b = b + 1
}
b7[a] = b as i32
a = a + 1
}
let mut i: i64 = 0
while i < end - start {
if (used[i] as i32) == ALL { count = count + 1 }
used[i] = 0
i = i + 1
}
start = end
}
printf("%lld\n", count)
free(used); free(b1); free(b2); free(b3); free(b7)
return 0
}
Generated C
#include <stdint.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/* Flow runtime helpers */
typedef struct flow_temp_node { struct flow_temp_node* next; } flow_temp_node;
static flow_temp_node* flow_temp_head = NULL;
static int flow_temp_atexit_set = 0;
__attribute__((unused)) static void flow_temp_free_all(void) {
while (flow_temp_head) {
flow_temp_node* n = flow_temp_head;
flow_temp_head = n->next;
free(n);
}
}
__attribute__((unused)) static void* flow_temp_alloc(size_t nbytes) {
flow_temp_node* node = (flow_temp_node*)malloc(sizeof(flow_temp_node) + nbytes);
if (!node) return NULL;
node->next = flow_temp_head;
flow_temp_head = node;
if (!flow_temp_atexit_set) {
flow_temp_atexit_set = 1;
atexit(flow_temp_free_all);
}
return (void*)(node + 1);
}
#ifndef FLOW_DIAG
#define FLOW_DIAG(msg) fprintf(stderr, "%s", (msg))
#endif
#ifndef FLOW_LOG
#define FLOW_LOG(fmt, ...) printf(fmt, __VA_ARGS__)
#endif
#ifndef FLOW_LOG_EMPTY
#define FLOW_LOG_EMPTY(fmt) printf(fmt)
#endif
static char* flow_strcat(const char* a, const char* b) {
size_t la = strlen(a ? a : ""), lb = strlen(b ? b : "");
char* r = (char*)flow_temp_alloc(la + lb + 1);
if (!r) return NULL;
if (la) memcpy(r, a, la);
if (lb) memcpy(r + la, b, lb);
r[la + lb] = '\0';
return r;
}
#define __flow_in_arr(arr, val) __extension__ ({ \
int _found = 0; \
size_t _n = sizeof(arr)/sizeof((arr)[0]); \
for (size_t _i = 0; _i < _n; _i++) { \
if ((arr)[_i] == (val)) { _found = 1; break; } \
} _found; })
/* Unified fault handler (MISRA #279) — override with -DFLOW_FAULT_HANDLER=fn */
#ifndef FLOW_FAULT_HANDLER
__attribute__((unused)) static inline void flow_fault_handler(const char* msg) {
fprintf(stderr, "flow: %s\n", msg ? msg : "fault");
abort();
#if defined(__GNUC__) || defined(__clang__)
__builtin_unreachable();
#endif
}
#else
#define flow_fault_handler FLOW_FAULT_HANDLER
#endif
#define flow_div_by_zero_handler() flow_fault_handler("division by zero")
#define flow_shift_ub_handler() flow_fault_handler("invalid shift (amount out of range or left-shift of negative)")
#ifndef FLOW_CHECKED_DIV
#define FLOW_CHECKED_DIV(L, R) (((R) != 0) ? ((L) / (R)) : (flow_div_by_zero_handler(), (L) * 0))
#endif
#ifndef FLOW_CHECKED_MOD
#define FLOW_CHECKED_MOD(L, R) (((R) != 0) ? ((L) % (R)) : (flow_div_by_zero_handler(), (L) * 0))
#endif
#ifndef FLOW_CHECKED_SHL
#define FLOW_CHECKED_SHL(L, R) ((((R) >= 0) && ((unsigned long long)(R) < (sizeof(L) * 8ull)) && ((L) >= 0)) ? ((L) << (R)) : (flow_shift_ub_handler(), (L) * 0))
#endif
#ifndef FLOW_CHECKED_SHR
#define FLOW_CHECKED_SHR(L, R) ((((R) >= 0) && ((unsigned long long)(R) < (sizeof(L) * 8ull))) ? ((L) >> (R)) : (flow_shift_ub_handler(), (L) * 0))
#endif
#include <math.h>
void* _ui_state = NULL;
static inline float i32_to_f32(int32_t v) { return (float)v; }
/* Host stub for @gpu kernels (device codegen replaces this). */
static inline int32_t gpu_thread_id(void) { return 0; }
int64_t gcd_i64_i64(int64_t a0, int64_t b0);
int64_t lcm_i64_i64(int64_t a, int64_t b);
int64_t isqrt_i64(int64_t n);
int64_t mulmod_i64_i64_i64(int64_t a0, int64_t b0, int64_t mod);
int64_t mod_pow_i64_i64_i64(int64_t base, int64_t exp, int64_t mod);
bool is_prime_i64(int64_t n);
int32_t main(void);
int64_t gcd_i64_i64(int64_t a0, int64_t b0) {
int64_t a = a0;
int64_t b = b0;
while (b != 0) {
int64_t t = FLOW_CHECKED_MOD((a), (b));
a = b;
b = t;
}
return a;
}
int64_t lcm_i64_i64(int64_t a, int64_t b) {
if ((a == 0 || b == 0)) {
return 0;
}
return (FLOW_CHECKED_DIV((a), (gcd_i64_i64(a, b))) * b);
}
int64_t isqrt_i64(int64_t n) {
if (n < 2) {
return n;
}
int64_t x = n;
int64_t y = FLOW_CHECKED_DIV(((x + 1)), (2));
while (y < x) {
x = y;
y = FLOW_CHECKED_DIV(((x + FLOW_CHECKED_DIV((n), (x)))), (2));
}
return x;
}
int64_t mulmod_i64_i64_i64(int64_t a0, int64_t b0, int64_t mod) {
int64_t a = FLOW_CHECKED_MOD((a0), (mod));
int64_t b = FLOW_CHECKED_MOD((b0), (mod));
int64_t result = 0;
while (b > 0) {
if (FLOW_CHECKED_MOD((b), (2)) == 1) {
result = FLOW_CHECKED_MOD(((result + a)), (mod));
}
a = FLOW_CHECKED_MOD(((a * 2)), (mod));
b = FLOW_CHECKED_DIV((b), (2));
}
return result;
}
int64_t mod_pow_i64_i64_i64(int64_t base, int64_t exp, int64_t mod) {
if (mod == 1) {
return 0;
}
int64_t result = 1;
int64_t b = FLOW_CHECKED_MOD((base), (mod));
int64_t e = exp;
while (e > 0) {
if (FLOW_CHECKED_MOD((e), (2)) == 1) {
result = mulmod_i64_i64_i64(result, b, mod);
}
b = mulmod_i64_i64_i64(b, b, mod);
e = FLOW_CHECKED_DIV((e), (2));
}
return result;
}
bool is_prime_i64(int64_t n) {
if (n < 2) {
return 0;
}
if (n < 4) {
return 1;
}
if ((FLOW_CHECKED_MOD((n), (2)) == 0 || FLOW_CHECKED_MOD((n), (3)) == 0)) {
return 0;
}
int64_t i = 5;
while ((i * i) <= n) {
if ((FLOW_CHECKED_MOD((n), (i)) == 0 || FLOW_CHECKED_MOD((n), ((i + 2))) == 0)) {
return 0;
}
i = (i + 6);
}
return 1;
}
int32_t main(void) {
int64_t LIMIT = 2000000000;
int64_t SLICE = 1000000;
int32_t ONE = 1;
int32_t TWO = 2;
int32_t THREE = 4;
int32_t SEVEN = 8;
int32_t ALL = 15;
int8_t* used = (int8_t*)(calloc(SLICE, 1));
if (used == NULL) {
return 1;
}
int64_t max_a = isqrt_i64(LIMIT);
int32_t* b1 = (int32_t*)(calloc((max_a + 1), 4));
int32_t* b2 = (int32_t*)(calloc((max_a + 1), 4));
int32_t* b3 = (int32_t*)(calloc((max_a + 1), 4));
int32_t* b7 = (int32_t*)(calloc((max_a + 1), 4));
if ((((b1 == NULL || b2 == NULL) || b3 == NULL) || b7 == NULL)) {
return 1;
}
int64_t a = 1;
while (a <= max_a) {
b1[a] = 1;
b2[a] = 1;
b3[a] = 1;
b7[a] = 1;
a = (a + 1);
}
int64_t count = 0;
int64_t start = 0;
while (start < LIMIT) {
int64_t end = (start + SLICE);
if (end > LIMIT) {
end = LIMIT;
}
a = 1;
while (a <= max_a) {
if (((a * a) + (((int64_t)(b1[a])) * ((int64_t)(b1[a])))) >= end) {
break;
}
int64_t b = ((int64_t)(b1[a]));
while (((a * a) + (b * b)) < end) {
used[(((a * a) + (b * b)) - start)] = ((int8_t)((((int32_t)(used[(((a * a) + (b * b)) - start)])) | ONE)));
b = (b + 1);
}
b1[a] = ((int32_t)(b));
b = ((int64_t)(b2[a]));
while (((a * a) + ((2 * b) * b)) < end) {
used[(((a * a) + ((2 * b) * b)) - start)] = ((int8_t)((((int32_t)(used[(((a * a) + ((2 * b) * b)) - start)])) | TWO)));
b = (b + 1);
}
b2[a] = ((int32_t)(b));
b = ((int64_t)(b3[a]));
while (((a * a) + ((3 * b) * b)) < end) {
used[(((a * a) + ((3 * b) * b)) - start)] = ((int8_t)((((int32_t)(used[(((a * a) + ((3 * b) * b)) - start)])) | THREE)));
b = (b + 1);
}
b3[a] = ((int32_t)(b));
b = ((int64_t)(b7[a]));
while (((a * a) + ((7 * b) * b)) < end) {
used[(((a * a) + ((7 * b) * b)) - start)] = ((int8_t)((((int32_t)(used[(((a * a) + ((7 * b) * b)) - start)])) | SEVEN)));
b = (b + 1);
}
b7[a] = ((int32_t)(b));
a = (a + 1);
}
int64_t i = 0;
while (i < (end - start)) {
if (((int32_t)(used[i])) == ALL) {
count = (count + 1);
}
used[i] = 0;
i = (i + 1);
}
start = end;
}
printf("%lld\n", count);
free(used);
free(b1);
free(b2);
free(b3);
free(b7);
return 0;
}
Generated MLIR
module {
llvm.func @printf(!llvm.ptr, ...) -> i32
llvm.mlir.global internal constant @str_0("%lld\n\00") {addr_space = 0 : i32} : !llvm.array<6 x i8>
func.func @gcd(%arg0: i64, %arg1: i64) -> i64 {
%0 = llvm.mlir.constant(1 : i64) : i64
%1 = llvm.alloca %0 x i64 : (i64) -> !llvm.ptr
llvm.store %arg0, %1 : i64, !llvm.ptr
%2 = llvm.mlir.constant(1 : i64) : i64
%3 = llvm.alloca %2 x i64 : (i64) -> !llvm.ptr
llvm.store %arg1, %3 : i64, !llvm.ptr
cf.br ^bb0
^bb0:
%4 = llvm.load %3 : !llvm.ptr -> i64
%5 = arith.constant 0 : i32
%7 = arith.extsi %5 : i32 to i64
%6 = arith.cmpi ne, %4, %7 : i64
cf.cond_br %6, ^bb1, ^bb2
^bb1:
%8 = llvm.load %1 : !llvm.ptr -> i64
%9 = llvm.load %3 : !llvm.ptr -> i64
%10 = arith.remsi %8, %9 : i64
%11 = llvm.load %3 : !llvm.ptr -> i64
llvm.store %11, %1 : i64, !llvm.ptr
llvm.store %10, %3 : i64, !llvm.ptr
cf.br ^bb0
^bb2:
%12 = llvm.load %1 : !llvm.ptr -> i64
func.return %12 : i64
}
func.func @lcm(%arg0: i64, %arg1: i64) -> i64 {
%13 = arith.constant 0 : i32
%15 = arith.extsi %13 : i32 to i64
%14 = arith.cmpi eq, %arg0, %15 : i64
%16 = scf.if %14 -> (i1) {
%17 = arith.constant true
scf.yield %17 : i1
} else {
%18 = arith.constant 0 : i32
%20 = arith.extsi %18 : i32 to i64
%19 = arith.cmpi eq, %arg1, %20 : i64
scf.yield %19 : i1
}
cf.cond_br %16, ^bb3, ^bb4
^bb3:
%21 = arith.constant 0 : i32
%22 = arith.extsi %21 : i32 to i64
func.return %22 : i64
^bb4:
cf.br ^bb5
^bb5:
%23 = func.call @gcd(%arg0, %arg1) : (i64, i64) -> i64
%24 = arith.divsi %arg0, %23 : i64
%25 = arith.muli %24, %arg1 : i64
func.return %25 : i64
}
func.func @isqrt(%arg0: i64) -> i64 {
%26 = arith.constant 2 : i32
%28 = arith.extsi %26 : i32 to i64
%27 = arith.cmpi slt, %arg0, %28 : i64
cf.cond_br %27, ^bb6, ^bb7
^bb6:
func.return %arg0 : i64
^bb7:
cf.br ^bb8
^bb8:
%29 = llvm.mlir.constant(1 : i64) : i64
%30 = llvm.alloca %29 x i64 : (i64) -> !llvm.ptr
llvm.store %arg0, %30 : i64, !llvm.ptr
%31 = llvm.load %30 : !llvm.ptr -> i64
%32 = arith.constant 1 : i32
%34 = arith.extsi %32 : i32 to i64
%33 = arith.addi %31, %34 : i64
%35 = arith.constant 2 : i32
%37 = arith.extsi %35 : i32 to i64
%36 = arith.divsi %33, %37 : i64
%38 = llvm.mlir.constant(1 : i64) : i64
%39 = llvm.alloca %38 x i64 : (i64) -> !llvm.ptr
llvm.store %36, %39 : i64, !llvm.ptr
cf.br ^bb9
^bb9:
%40 = llvm.load %39 : !llvm.ptr -> i64
%41 = llvm.load %30 : !llvm.ptr -> i64
%42 = arith.cmpi slt, %40, %41 : i64
cf.cond_br %42, ^bb10, ^bb11
^bb10:
%43 = llvm.load %39 : !llvm.ptr -> i64
llvm.store %43, %30 : i64, !llvm.ptr
%44 = llvm.load %30 : !llvm.ptr -> i64
%45 = llvm.load %30 : !llvm.ptr -> i64
%46 = arith.divsi %arg0, %45 : i64
%47 = arith.addi %44, %46 : i64
%48 = arith.constant 2 : i32
%50 = arith.extsi %48 : i32 to i64
%49 = arith.divsi %47, %50 : i64
llvm.store %49, %39 : i64, !llvm.ptr
cf.br ^bb9
^bb11:
%51 = llvm.load %30 : !llvm.ptr -> i64
func.return %51 : i64
}
func.func @mulmod(%arg0: i64, %arg1: i64, %arg2: i64) -> i64 {
%52 = arith.remsi %arg0, %arg2 : i64
%53 = llvm.mlir.constant(1 : i64) : i64
%54 = llvm.alloca %53 x i64 : (i64) -> !llvm.ptr
llvm.store %52, %54 : i64, !llvm.ptr
%55 = arith.remsi %arg1, %arg2 : i64
%56 = llvm.mlir.constant(1 : i64) : i64
%57 = llvm.alloca %56 x i64 : (i64) -> !llvm.ptr
llvm.store %55, %57 : i64, !llvm.ptr
%58 = arith.constant 0 : i32
%59 = arith.extsi %58 : i32 to i64
%60 = llvm.mlir.constant(1 : i64) : i64
%61 = llvm.alloca %60 x i64 : (i64) -> !llvm.ptr
llvm.store %59, %61 : i64, !llvm.ptr
cf.br ^bb12
^bb12:
%62 = llvm.load %57 : !llvm.ptr -> i64
%63 = arith.constant 0 : i32
%65 = arith.extsi %63 : i32 to i64
%64 = arith.cmpi sgt, %62, %65 : i64
cf.cond_br %64, ^bb13, ^bb14
^bb13:
%66 = llvm.load %57 : !llvm.ptr -> i64
%67 = arith.constant 2 : i32
%69 = arith.extsi %67 : i32 to i64
%68 = arith.remsi %66, %69 : i64
%70 = arith.constant 1 : i32
%72 = arith.extsi %70 : i32 to i64
%71 = arith.cmpi eq, %68, %72 : i64
cf.cond_br %71, ^bb15, ^bb16
^bb15:
%73 = llvm.load %61 : !llvm.ptr -> i64
%74 = llvm.load %54 : !llvm.ptr -> i64
%75 = arith.addi %73, %74 : i64
%76 = arith.remsi %75, %arg2 : i64
llvm.store %76, %61 : i64, !llvm.ptr
cf.br ^bb17
^bb16:
cf.br ^bb17
^bb17:
%77 = llvm.load %54 : !llvm.ptr -> i64
%78 = arith.constant 2 : i32
%80 = arith.extsi %78 : i32 to i64
%79 = arith.muli %77, %80 : i64
%81 = arith.remsi %79, %arg2 : i64
llvm.store %81, %54 : i64, !llvm.ptr
%82 = llvm.load %57 : !llvm.ptr -> i64
%83 = arith.constant 2 : i32
%85 = arith.extsi %83 : i32 to i64
%84 = arith.divsi %82, %85 : i64
llvm.store %84, %57 : i64, !llvm.ptr
cf.br ^bb12
^bb14:
%86 = llvm.load %61 : !llvm.ptr -> i64
func.return %86 : i64
}
func.func @mod_pow(%arg0: i64, %arg1: i64, %arg2: i64) -> i64 {
%87 = arith.constant 1 : i32
%89 = arith.extsi %87 : i32 to i64
%88 = arith.cmpi eq, %arg2, %89 : i64
cf.cond_br %88, ^bb18, ^bb19
^bb18:
%90 = arith.constant 0 : i32
%91 = arith.extsi %90 : i32 to i64
func.return %91 : i64
^bb19:
cf.br ^bb20
^bb20:
%92 = arith.constant 1 : i32
%93 = arith.extsi %92 : i32 to i64
%94 = llvm.mlir.constant(1 : i64) : i64
%95 = llvm.alloca %94 x i64 : (i64) -> !llvm.ptr
llvm.store %93, %95 : i64, !llvm.ptr
%96 = arith.remsi %arg0, %arg2 : i64
%97 = llvm.mlir.constant(1 : i64) : i64
%98 = llvm.alloca %97 x i64 : (i64) -> !llvm.ptr
llvm.store %96, %98 : i64, !llvm.ptr
%99 = llvm.mlir.constant(1 : i64) : i64
%100 = llvm.alloca %99 x i64 : (i64) -> !llvm.ptr
llvm.store %arg1, %100 : i64, !llvm.ptr
cf.br ^bb21
^bb21:
%101 = llvm.load %100 : !llvm.ptr -> i64
%102 = arith.constant 0 : i32
%104 = arith.extsi %102 : i32 to i64
%103 = arith.cmpi sgt, %101, %104 : i64
cf.cond_br %103, ^bb22, ^bb23
^bb22:
%105 = llvm.load %100 : !llvm.ptr -> i64
%106 = arith.constant 2 : i32
%108 = arith.extsi %106 : i32 to i64
%107 = arith.remsi %105, %108 : i64
%109 = arith.constant 1 : i32
%111 = arith.extsi %109 : i32 to i64
%110 = arith.cmpi eq, %107, %111 : i64
cf.cond_br %110, ^bb24, ^bb25
^bb24:
%113 = llvm.load %95 : !llvm.ptr -> i64
%114 = llvm.load %98 : !llvm.ptr -> i64
%112 = func.call @mulmod(%113, %114, %arg2) : (i64, i64, i64) -> i64
llvm.store %112, %95 : i64, !llvm.ptr
cf.br ^bb26
^bb25:
cf.br ^bb26
^bb26:
%116 = llvm.load %98 : !llvm.ptr -> i64
%117 = llvm.load %98 : !llvm.ptr -> i64
%115 = func.call @mulmod(%116, %117, %arg2) : (i64, i64, i64) -> i64
llvm.store %115, %98 : i64, !llvm.ptr
%118 = llvm.load %100 : !llvm.ptr -> i64
%119 = arith.constant 2 : i32
%121 = arith.extsi %119 : i32 to i64
%120 = arith.divsi %118, %121 : i64
llvm.store %120, %100 : i64, !llvm.ptr
cf.br ^bb21
^bb23:
%122 = llvm.load %95 : !llvm.ptr -> i64
func.return %122 : i64
}
func.func @is_prime(%arg0: i64) -> i1 {
%123 = arith.constant 2 : i32
%125 = arith.extsi %123 : i32 to i64
%124 = arith.cmpi slt, %arg0, %125 : i64
cf.cond_br %124, ^bb27, ^bb28
^bb27:
%126 = arith.constant 0 : i1
func.return %126 : i1
^bb28:
cf.br ^bb29
^bb29:
%127 = arith.constant 4 : i32
%129 = arith.extsi %127 : i32 to i64
%128 = arith.cmpi slt, %arg0, %129 : i64
cf.cond_br %128, ^bb30, ^bb31
^bb30:
%130 = arith.constant 1 : i1
func.return %130 : i1
^bb31:
cf.br ^bb32
^bb32:
%131 = arith.constant 2 : i32
%133 = arith.extsi %131 : i32 to i64
%132 = arith.remsi %arg0, %133 : i64
%134 = arith.constant 0 : i32
%136 = arith.extsi %134 : i32 to i64
%135 = arith.cmpi eq, %132, %136 : i64
%137 = scf.if %135 -> (i1) {
%138 = arith.constant true
scf.yield %138 : i1
} else {
%139 = arith.constant 3 : i32
%141 = arith.extsi %139 : i32 to i64
%140 = arith.remsi %arg0, %141 : i64
%142 = arith.constant 0 : i32
%144 = arith.extsi %142 : i32 to i64
%143 = arith.cmpi eq, %140, %144 : i64
scf.yield %143 : i1
}
cf.cond_br %137, ^bb33, ^bb34
^bb33:
%145 = arith.constant 0 : i1
func.return %145 : i1
^bb34:
cf.br ^bb35
^bb35:
%146 = arith.constant 5 : i32
%147 = arith.extsi %146 : i32 to i64
%148 = llvm.mlir.constant(1 : i64) : i64
%149 = llvm.alloca %148 x i64 : (i64) -> !llvm.ptr
llvm.store %147, %149 : i64, !llvm.ptr
cf.br ^bb36
^bb36:
%150 = llvm.load %149 : !llvm.ptr -> i64
%151 = llvm.load %149 : !llvm.ptr -> i64
%152 = arith.muli %150, %151 : i64
%153 = arith.cmpi sle, %152, %arg0 : i64
cf.cond_br %153, ^bb37, ^bb38
^bb37:
%154 = llvm.load %149 : !llvm.ptr -> i64
%155 = arith.remsi %arg0, %154 : i64
%156 = arith.constant 0 : i32
%158 = arith.extsi %156 : i32 to i64
%157 = arith.cmpi eq, %155, %158 : i64
%159 = scf.if %157 -> (i1) {
%160 = arith.constant true
scf.yield %160 : i1
} else {
%161 = llvm.load %149 : !llvm.ptr -> i64
%162 = arith.constant 2 : i32
%164 = arith.extsi %162 : i32 to i64
%163 = arith.addi %161, %164 : i64
%165 = arith.remsi %arg0, %163 : i64
%166 = arith.constant 0 : i32
%168 = arith.extsi %166 : i32 to i64
%167 = arith.cmpi eq, %165, %168 : i64
scf.yield %167 : i1
}
cf.cond_br %159, ^bb39, ^bb40
^bb39:
%169 = arith.constant 0 : i1
func.return %169 : i1
^bb40:
cf.br ^bb41
^bb41:
%170 = llvm.load %149 : !llvm.ptr -> i64
%171 = arith.constant 6 : i32
%173 = arith.extsi %171 : i32 to i64
%172 = arith.addi %170, %173 : i64
llvm.store %172, %149 : i64, !llvm.ptr
cf.br ^bb36
^bb38:
%174 = arith.constant 1 : i1
func.return %174 : i1
}
func.func private @calloc(i64, i64) -> !llvm.ptr
func.func private @free(!llvm.ptr) -> ()
func.func @main() -> i32 {
%175 = arith.constant 2000000000 : i32
%176 = arith.extsi %175 : i32 to i64
%177 = arith.constant 1000000 : i32
%178 = arith.extsi %177 : i32 to i64
%179 = arith.constant 1 : i32
%180 = arith.constant 2 : i32
%181 = arith.constant 4 : i32
%182 = arith.constant 8 : i32
%183 = arith.constant 15 : i32
%185 = arith.constant 1 : i32
%186 = arith.extsi %185 : i32 to i64
%184 = func.call @calloc(%178, %186) : (i64, i64) -> !llvm.ptr
%187 = llvm.mlir.zero : !llvm.ptr
%188 = llvm.icmp "eq" %184, %187 : !llvm.ptr
cf.cond_br %188, ^bb42, ^bb43
^bb42:
%189 = arith.constant 1 : i32
func.return %189 : i32
^bb43:
cf.br ^bb44
^bb44:
%190 = func.call @isqrt(%176) : (i64) -> i64
%192 = arith.constant 1 : i32
%194 = arith.extsi %192 : i32 to i64
%193 = arith.addi %190, %194 : i64
%195 = arith.constant 4 : i32
%196 = arith.extsi %195 : i32 to i64
%191 = func.call @calloc(%193, %196) : (i64, i64) -> !llvm.ptr
%198 = arith.constant 1 : i32
%200 = arith.extsi %198 : i32 to i64
%199 = arith.addi %190, %200 : i64
%201 = arith.constant 4 : i32
%202 = arith.extsi %201 : i32 to i64
%197 = func.call @calloc(%199, %202) : (i64, i64) -> !llvm.ptr
%204 = arith.constant 1 : i32
%206 = arith.extsi %204 : i32 to i64
%205 = arith.addi %190, %206 : i64
%207 = arith.constant 4 : i32
%208 = arith.extsi %207 : i32 to i64
%203 = func.call @calloc(%205, %208) : (i64, i64) -> !llvm.ptr
%210 = arith.constant 1 : i32
%212 = arith.extsi %210 : i32 to i64
%211 = arith.addi %190, %212 : i64
%213 = arith.constant 4 : i32
%214 = arith.extsi %213 : i32 to i64
%209 = func.call @calloc(%211, %214) : (i64, i64) -> !llvm.ptr
%215 = llvm.mlir.zero : !llvm.ptr
%216 = llvm.icmp "eq" %191, %215 : !llvm.ptr
%217 = scf.if %216 -> (i1) {
%218 = arith.constant true
scf.yield %218 : i1
} else {
%219 = llvm.mlir.zero : !llvm.ptr
%220 = llvm.icmp "eq" %197, %219 : !llvm.ptr
scf.yield %220 : i1
}
%221 = scf.if %217 -> (i1) {
%222 = arith.constant true
scf.yield %222 : i1
} else {
%223 = llvm.mlir.zero : !llvm.ptr
%224 = llvm.icmp "eq" %203, %223 : !llvm.ptr
scf.yield %224 : i1
}
%225 = scf.if %221 -> (i1) {
%226 = arith.constant true
scf.yield %226 : i1
} else {
%227 = llvm.mlir.zero : !llvm.ptr
%228 = llvm.icmp "eq" %209, %227 : !llvm.ptr
scf.yield %228 : i1
}
cf.cond_br %225, ^bb45, ^bb46
^bb45:
%229 = arith.constant 1 : i32
func.return %229 : i32
^bb46:
cf.br ^bb47
^bb47:
%230 = arith.constant 1 : i32
%231 = arith.extsi %230 : i32 to i64
%232 = llvm.mlir.constant(1 : i64) : i64
%233 = llvm.alloca %232 x i64 : (i64) -> !llvm.ptr
llvm.store %231, %233 : i64, !llvm.ptr
cf.br ^bb48
^bb48:
%234 = llvm.load %233 : !llvm.ptr -> i64
%235 = arith.cmpi sle, %234, %190 : i64
cf.cond_br %235, ^bb49, ^bb50
^bb49:
%236 = arith.constant 1 : i32
%237 = llvm.load %233 : !llvm.ptr -> i64
%238 = llvm.getelementptr %191[%237] : (!llvm.ptr, i64) -> !llvm.ptr, i32
llvm.store %236, %238 : i32, !llvm.ptr
%239 = arith.constant 1 : i32
%240 = llvm.load %233 : !llvm.ptr -> i64
%241 = llvm.getelementptr %197[%240] : (!llvm.ptr, i64) -> !llvm.ptr, i32
llvm.store %239, %241 : i32, !llvm.ptr
%242 = arith.constant 1 : i32
%243 = llvm.load %233 : !llvm.ptr -> i64
%244 = llvm.getelementptr %203[%243] : (!llvm.ptr, i64) -> !llvm.ptr, i32
llvm.store %242, %244 : i32, !llvm.ptr
%245 = arith.constant 1 : i32
%246 = llvm.load %233 : !llvm.ptr -> i64
%247 = llvm.getelementptr %209[%246] : (!llvm.ptr, i64) -> !llvm.ptr, i32
llvm.store %245, %247 : i32, !llvm.ptr
%248 = llvm.load %233 : !llvm.ptr -> i64
%249 = arith.constant 1 : i32
%251 = arith.extsi %249 : i32 to i64
%250 = arith.addi %248, %251 : i64
llvm.store %250, %233 : i64, !llvm.ptr
cf.br ^bb48
^bb50:
%252 = arith.constant 0 : i32
%253 = arith.extsi %252 : i32 to i64
%254 = llvm.mlir.constant(1 : i64) : i64
%255 = llvm.alloca %254 x i64 : (i64) -> !llvm.ptr
llvm.store %253, %255 : i64, !llvm.ptr
%256 = arith.constant 0 : i32
%257 = arith.extsi %256 : i32 to i64
%258 = llvm.mlir.constant(1 : i64) : i64
%259 = llvm.alloca %258 x i64 : (i64) -> !llvm.ptr
llvm.store %257, %259 : i64, !llvm.ptr
cf.br ^bb51
^bb51:
%260 = llvm.load %259 : !llvm.ptr -> i64
%261 = arith.cmpi slt, %260, %176 : i64
cf.cond_br %261, ^bb52, ^bb53
^bb52:
%262 = llvm.load %259 : !llvm.ptr -> i64
%263 = arith.addi %262, %178 : i64
%264 = llvm.mlir.constant(1 : i64) : i64
%265 = llvm.alloca %264 x i64 : (i64) -> !llvm.ptr
llvm.store %263, %265 : i64, !llvm.ptr
%266 = llvm.load %265 : !llvm.ptr -> i64
%267 = arith.cmpi sgt, %266, %176 : i64
cf.cond_br %267, ^bb54, ^bb55
^bb54:
llvm.store %176, %265 : i64, !llvm.ptr
cf.br ^bb56
^bb55:
cf.br ^bb56
^bb56:
%268 = arith.constant 1 : i32
%269 = arith.extsi %268 : i32 to i64
llvm.store %269, %233 : i64, !llvm.ptr
cf.br ^bb57
^bb57:
%270 = llvm.load %233 : !llvm.ptr -> i64
%271 = arith.cmpi sle, %270, %190 : i64
cf.cond_br %271, ^bb58, ^bb59
^bb58:
%272 = llvm.load %233 : !llvm.ptr -> i64
%273 = llvm.load %233 : !llvm.ptr -> i64
%274 = arith.muli %272, %273 : i64
%276 = llvm.load %233 : !llvm.ptr -> i64
%277 = llvm.getelementptr %191[%276] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%275 = llvm.load %277 : !llvm.ptr -> i32
%278 = arith.extsi %275 : i32 to i64
%280 = llvm.load %233 : !llvm.ptr -> i64
%281 = llvm.getelementptr %191[%280] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%279 = llvm.load %281 : !llvm.ptr -> i32
%282 = arith.extsi %279 : i32 to i64
%283 = arith.muli %278, %282 : i64
%284 = arith.addi %274, %283 : i64
%285 = llvm.load %265 : !llvm.ptr -> i64
%286 = arith.cmpi sge, %284, %285 : i64
cf.cond_br %286, ^bb60, ^bb61
^bb60:
cf.br ^bb59
^bb61:
cf.br ^bb62
^bb62:
%288 = llvm.load %233 : !llvm.ptr -> i64
%289 = llvm.getelementptr %191[%288] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%287 = llvm.load %289 : !llvm.ptr -> i32
%290 = arith.extsi %287 : i32 to i64
%291 = llvm.mlir.constant(1 : i64) : i64
%292 = llvm.alloca %291 x i64 : (i64) -> !llvm.ptr
llvm.store %290, %292 : i64, !llvm.ptr
cf.br ^bb63
^bb63:
%293 = llvm.load %233 : !llvm.ptr -> i64
%294 = llvm.load %233 : !llvm.ptr -> i64
%295 = arith.muli %293, %294 : i64
%296 = llvm.load %292 : !llvm.ptr -> i64
%297 = llvm.load %292 : !llvm.ptr -> i64
%298 = arith.muli %296, %297 : i64
%299 = arith.addi %295, %298 : i64
%300 = llvm.load %265 : !llvm.ptr -> i64
%301 = arith.cmpi slt, %299, %300 : i64
cf.cond_br %301, ^bb64, ^bb65
^bb64:
%303 = llvm.load %233 : !llvm.ptr -> i64
%304 = llvm.load %233 : !llvm.ptr -> i64
%305 = arith.muli %303, %304 : i64
%306 = llvm.load %292 : !llvm.ptr -> i64
%307 = llvm.load %292 : !llvm.ptr -> i64
%308 = arith.muli %306, %307 : i64
%309 = arith.addi %305, %308 : i64
%310 = llvm.load %259 : !llvm.ptr -> i64
%311 = arith.subi %309, %310 : i64
%312 = llvm.getelementptr %184[%311] : (!llvm.ptr, i64) -> !llvm.ptr, i8
%302 = llvm.load %312 : !llvm.ptr -> i8
%313 = arith.extsi %302 : i8 to i32
%314 = arith.ori %313, %179 : i32
%315 = arith.trunci %314 : i32 to i8
%316 = llvm.load %233 : !llvm.ptr -> i64
%317 = llvm.load %233 : !llvm.ptr -> i64
%318 = arith.muli %316, %317 : i64
%319 = llvm.load %292 : !llvm.ptr -> i64
%320 = llvm.load %292 : !llvm.ptr -> i64
%321 = arith.muli %319, %320 : i64
%322 = arith.addi %318, %321 : i64
%323 = llvm.load %259 : !llvm.ptr -> i64
%324 = arith.subi %322, %323 : i64
%325 = llvm.getelementptr %184[%324] : (!llvm.ptr, i64) -> !llvm.ptr, i8
llvm.store %315, %325 : i8, !llvm.ptr
%326 = llvm.load %292 : !llvm.ptr -> i64
%327 = arith.constant 1 : i32
%329 = arith.extsi %327 : i32 to i64
%328 = arith.addi %326, %329 : i64
llvm.store %328, %292 : i64, !llvm.ptr
cf.br ^bb63
^bb65:
%330 = llvm.load %292 : !llvm.ptr -> i64
%331 = arith.trunci %330 : i64 to i32
%332 = llvm.load %233 : !llvm.ptr -> i64
%333 = llvm.getelementptr %191[%332] : (!llvm.ptr, i64) -> !llvm.ptr, i32
llvm.store %331, %333 : i32, !llvm.ptr
%335 = llvm.load %233 : !llvm.ptr -> i64
%336 = llvm.getelementptr %197[%335] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%334 = llvm.load %336 : !llvm.ptr -> i32
%337 = arith.extsi %334 : i32 to i64
llvm.store %337, %292 : i64, !llvm.ptr
cf.br ^bb66
^bb66:
%338 = llvm.load %233 : !llvm.ptr -> i64
%339 = llvm.load %233 : !llvm.ptr -> i64
%340 = arith.muli %338, %339 : i64
%341 = arith.constant 2 : i32
%342 = llvm.load %292 : !llvm.ptr -> i64
%344 = arith.extsi %341 : i32 to i64
%343 = arith.muli %344, %342 : i64
%345 = llvm.load %292 : !llvm.ptr -> i64
%346 = arith.muli %343, %345 : i64
%347 = arith.addi %340, %346 : i64
%348 = llvm.load %265 : !llvm.ptr -> i64
%349 = arith.cmpi slt, %347, %348 : i64
cf.cond_br %349, ^bb67, ^bb68
^bb67:
%351 = llvm.load %233 : !llvm.ptr -> i64
%352 = llvm.load %233 : !llvm.ptr -> i64
%353 = arith.muli %351, %352 : i64
%354 = arith.constant 2 : i32
%355 = llvm.load %292 : !llvm.ptr -> i64
%357 = arith.extsi %354 : i32 to i64
%356 = arith.muli %357, %355 : i64
%358 = llvm.load %292 : !llvm.ptr -> i64
%359 = arith.muli %356, %358 : i64
%360 = arith.addi %353, %359 : i64
%361 = llvm.load %259 : !llvm.ptr -> i64
%362 = arith.subi %360, %361 : i64
%363 = llvm.getelementptr %184[%362] : (!llvm.ptr, i64) -> !llvm.ptr, i8
%350 = llvm.load %363 : !llvm.ptr -> i8
%364 = arith.extsi %350 : i8 to i32
%365 = arith.ori %364, %180 : i32
%366 = arith.trunci %365 : i32 to i8
%367 = llvm.load %233 : !llvm.ptr -> i64
%368 = llvm.load %233 : !llvm.ptr -> i64
%369 = arith.muli %367, %368 : i64
%370 = arith.constant 2 : i32
%371 = llvm.load %292 : !llvm.ptr -> i64
%373 = arith.extsi %370 : i32 to i64
%372 = arith.muli %373, %371 : i64
%374 = llvm.load %292 : !llvm.ptr -> i64
%375 = arith.muli %372, %374 : i64
%376 = arith.addi %369, %375 : i64
%377 = llvm.load %259 : !llvm.ptr -> i64
%378 = arith.subi %376, %377 : i64
%379 = llvm.getelementptr %184[%378] : (!llvm.ptr, i64) -> !llvm.ptr, i8
llvm.store %366, %379 : i8, !llvm.ptr
%380 = llvm.load %292 : !llvm.ptr -> i64
%381 = arith.constant 1 : i32
%383 = arith.extsi %381 : i32 to i64
%382 = arith.addi %380, %383 : i64
llvm.store %382, %292 : i64, !llvm.ptr
cf.br ^bb66
^bb68:
%384 = llvm.load %292 : !llvm.ptr -> i64
%385 = arith.trunci %384 : i64 to i32
%386 = llvm.load %233 : !llvm.ptr -> i64
%387 = llvm.getelementptr %197[%386] : (!llvm.ptr, i64) -> !llvm.ptr, i32
llvm.store %385, %387 : i32, !llvm.ptr
%389 = llvm.load %233 : !llvm.ptr -> i64
%390 = llvm.getelementptr %203[%389] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%388 = llvm.load %390 : !llvm.ptr -> i32
%391 = arith.extsi %388 : i32 to i64
llvm.store %391, %292 : i64, !llvm.ptr
cf.br ^bb69
^bb69:
%392 = llvm.load %233 : !llvm.ptr -> i64
%393 = llvm.load %233 : !llvm.ptr -> i64
%394 = arith.muli %392, %393 : i64
%395 = arith.constant 3 : i32
%396 = llvm.load %292 : !llvm.ptr -> i64
%398 = arith.extsi %395 : i32 to i64
%397 = arith.muli %398, %396 : i64
%399 = llvm.load %292 : !llvm.ptr -> i64
%400 = arith.muli %397, %399 : i64
%401 = arith.addi %394, %400 : i64
%402 = llvm.load %265 : !llvm.ptr -> i64
%403 = arith.cmpi slt, %401, %402 : i64
cf.cond_br %403, ^bb70, ^bb71
^bb70:
%405 = llvm.load %233 : !llvm.ptr -> i64
%406 = llvm.load %233 : !llvm.ptr -> i64
%407 = arith.muli %405, %406 : i64
%408 = arith.constant 3 : i32
%409 = llvm.load %292 : !llvm.ptr -> i64
%411 = arith.extsi %408 : i32 to i64
%410 = arith.muli %411, %409 : i64
%412 = llvm.load %292 : !llvm.ptr -> i64
%413 = arith.muli %410, %412 : i64
%414 = arith.addi %407, %413 : i64
%415 = llvm.load %259 : !llvm.ptr -> i64
%416 = arith.subi %414, %415 : i64
%417 = llvm.getelementptr %184[%416] : (!llvm.ptr, i64) -> !llvm.ptr, i8
%404 = llvm.load %417 : !llvm.ptr -> i8
%418 = arith.extsi %404 : i8 to i32
%419 = arith.ori %418, %181 : i32
%420 = arith.trunci %419 : i32 to i8
%421 = llvm.load %233 : !llvm.ptr -> i64
%422 = llvm.load %233 : !llvm.ptr -> i64
%423 = arith.muli %421, %422 : i64
%424 = arith.constant 3 : i32
%425 = llvm.load %292 : !llvm.ptr -> i64
%427 = arith.extsi %424 : i32 to i64
%426 = arith.muli %427, %425 : i64
%428 = llvm.load %292 : !llvm.ptr -> i64
%429 = arith.muli %426, %428 : i64
%430 = arith.addi %423, %429 : i64
%431 = llvm.load %259 : !llvm.ptr -> i64
%432 = arith.subi %430, %431 : i64
%433 = llvm.getelementptr %184[%432] : (!llvm.ptr, i64) -> !llvm.ptr, i8
llvm.store %420, %433 : i8, !llvm.ptr
%434 = llvm.load %292 : !llvm.ptr -> i64
%435 = arith.constant 1 : i32
%437 = arith.extsi %435 : i32 to i64
%436 = arith.addi %434, %437 : i64
llvm.store %436, %292 : i64, !llvm.ptr
cf.br ^bb69
^bb71:
%438 = llvm.load %292 : !llvm.ptr -> i64
%439 = arith.trunci %438 : i64 to i32
%440 = llvm.load %233 : !llvm.ptr -> i64
%441 = llvm.getelementptr %203[%440] : (!llvm.ptr, i64) -> !llvm.ptr, i32
llvm.store %439, %441 : i32, !llvm.ptr
%443 = llvm.load %233 : !llvm.ptr -> i64
%444 = llvm.getelementptr %209[%443] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%442 = llvm.load %444 : !llvm.ptr -> i32
%445 = arith.extsi %442 : i32 to i64
llvm.store %445, %292 : i64, !llvm.ptr
cf.br ^bb72
^bb72:
%446 = llvm.load %233 : !llvm.ptr -> i64
%447 = llvm.load %233 : !llvm.ptr -> i64
%448 = arith.muli %446, %447 : i64
%449 = arith.constant 7 : i32
%450 = llvm.load %292 : !llvm.ptr -> i64
%452 = arith.extsi %449 : i32 to i64
%451 = arith.muli %452, %450 : i64
%453 = llvm.load %292 : !llvm.ptr -> i64
%454 = arith.muli %451, %453 : i64
%455 = arith.addi %448, %454 : i64
%456 = llvm.load %265 : !llvm.ptr -> i64
%457 = arith.cmpi slt, %455, %456 : i64
cf.cond_br %457, ^bb73, ^bb74
^bb73:
%459 = llvm.load %233 : !llvm.ptr -> i64
%460 = llvm.load %233 : !llvm.ptr -> i64
%461 = arith.muli %459, %460 : i64
%462 = arith.constant 7 : i32
%463 = llvm.load %292 : !llvm.ptr -> i64
%465 = arith.extsi %462 : i32 to i64
%464 = arith.muli %465, %463 : i64
%466 = llvm.load %292 : !llvm.ptr -> i64
%467 = arith.muli %464, %466 : i64
%468 = arith.addi %461, %467 : i64
%469 = llvm.load %259 : !llvm.ptr -> i64
%470 = arith.subi %468, %469 : i64
%471 = llvm.getelementptr %184[%470] : (!llvm.ptr, i64) -> !llvm.ptr, i8
%458 = llvm.load %471 : !llvm.ptr -> i8
%472 = arith.extsi %458 : i8 to i32
%473 = arith.ori %472, %182 : i32
%474 = arith.trunci %473 : i32 to i8
%475 = llvm.load %233 : !llvm.ptr -> i64
%476 = llvm.load %233 : !llvm.ptr -> i64
%477 = arith.muli %475, %476 : i64
%478 = arith.constant 7 : i32
%479 = llvm.load %292 : !llvm.ptr -> i64
%481 = arith.extsi %478 : i32 to i64
%480 = arith.muli %481, %479 : i64
%482 = llvm.load %292 : !llvm.ptr -> i64
%483 = arith.muli %480, %482 : i64
%484 = arith.addi %477, %483 : i64
%485 = llvm.load %259 : !llvm.ptr -> i64
%486 = arith.subi %484, %485 : i64
%487 = llvm.getelementptr %184[%486] : (!llvm.ptr, i64) -> !llvm.ptr, i8
llvm.store %474, %487 : i8, !llvm.ptr
%488 = llvm.load %292 : !llvm.ptr -> i64
%489 = arith.constant 1 : i32
%491 = arith.extsi %489 : i32 to i64
%490 = arith.addi %488, %491 : i64
llvm.store %490, %292 : i64, !llvm.ptr
cf.br ^bb72
^bb74:
%492 = llvm.load %292 : !llvm.ptr -> i64
%493 = arith.trunci %492 : i64 to i32
%494 = llvm.load %233 : !llvm.ptr -> i64
%495 = llvm.getelementptr %209[%494] : (!llvm.ptr, i64) -> !llvm.ptr, i32
llvm.store %493, %495 : i32, !llvm.ptr
%496 = llvm.load %233 : !llvm.ptr -> i64
%497 = arith.constant 1 : i32
%499 = arith.extsi %497 : i32 to i64
%498 = arith.addi %496, %499 : i64
llvm.store %498, %233 : i64, !llvm.ptr
cf.br ^bb57
^bb59:
%500 = arith.constant 0 : i32
%501 = arith.extsi %500 : i32 to i64
%502 = llvm.mlir.constant(1 : i64) : i64
%503 = llvm.alloca %502 x i64 : (i64) -> !llvm.ptr
llvm.store %501, %503 : i64, !llvm.ptr
cf.br ^bb75
^bb75:
%504 = llvm.load %503 : !llvm.ptr -> i64
%505 = llvm.load %265 : !llvm.ptr -> i64
%506 = llvm.load %259 : !llvm.ptr -> i64
%507 = arith.subi %505, %506 : i64
%508 = arith.cmpi slt, %504, %507 : i64
cf.cond_br %508, ^bb76, ^bb77
^bb76:
%510 = llvm.load %503 : !llvm.ptr -> i64
%511 = llvm.getelementptr %184[%510] : (!llvm.ptr, i64) -> !llvm.ptr, i8
%509 = llvm.load %511 : !llvm.ptr -> i8
%512 = arith.extsi %509 : i8 to i32
%513 = arith.cmpi eq, %512, %183 : i32
cf.cond_br %513, ^bb78, ^bb79
^bb78:
%514 = llvm.load %255 : !llvm.ptr -> i64
%515 = arith.constant 1 : i32
%517 = arith.extsi %515 : i32 to i64
%516 = arith.addi %514, %517 : i64
llvm.store %516, %255 : i64, !llvm.ptr
cf.br ^bb80
^bb79:
cf.br ^bb80
^bb80:
%518 = arith.constant 0 : i32
%519 = llvm.load %503 : !llvm.ptr -> i64
%520 = arith.trunci %518 : i32 to i8
%521 = llvm.getelementptr %184[%519] : (!llvm.ptr, i64) -> !llvm.ptr, i8
llvm.store %520, %521 : i8, !llvm.ptr
%522 = llvm.load %503 : !llvm.ptr -> i64
%523 = arith.constant 1 : i32
%525 = arith.extsi %523 : i32 to i64
%524 = arith.addi %522, %525 : i64
llvm.store %524, %503 : i64, !llvm.ptr
cf.br ^bb75
^bb77:
%526 = llvm.load %265 : !llvm.ptr -> i64
llvm.store %526, %259 : i64, !llvm.ptr
cf.br ^bb51
^bb53:
%527 = llvm.mlir.addressof @str_0 : !llvm.ptr
%528 = llvm.load %255 : !llvm.ptr -> i64
%529 = llvm.call @printf(%527, %528) vararg(!llvm.func<i32 (ptr, ...)>) : (!llvm.ptr, i64) -> i32
func.call @free(%184) : (!llvm.ptr) -> ()
func.call @free(%191) : (!llvm.ptr) -> ()
func.call @free(%197) : (!llvm.ptr) -> ()
func.call @free(%203) : (!llvm.ptr) -> ()
func.call @free(%209) : (!llvm.ptr) -> ()
%535 = arith.constant 0 : i32
func.return %535 : i32
}
}