Set of four distinct digits with longest consecutive positive targets from 1.
| Answer | 1258 |
|---|---|
| Output | 1258 |
| Status | PASS |
| Native helper | no |
| Runtime | 0 ms |
| Peak memory | 1072 KB |
| Time complexity | O(n^10) (estimated) |
| Space complexity | O(1) (estimated) |
| Metric | Our solution | Best known |
|---|---|---|
| Time complexity | O(n^10) | ? |
| Space complexity | O(1) | ? |
| Approach | Flow solution | Not curated |
| Verdict | Unknown | |
# Project Euler 093
# Set of four distinct digits with longest consecutive positive targets from 1.
extern {
function calloc(n: i64, size: i64) -> ptr<void>
function free(p: ptr<void>) -> void
}
function absf(x: f64) -> f64 {
if x < 0.0 { return 0.0 - x }
return x
}
function nearly_int(x: f64) -> bool {
let r: f64 = x + 0.5
let n: i64 = r as i64
# careful for negatives
if x >= 0.0 {
let nearest: f64 = (x + 0.5) as i64 as f64
return absf(x - nearest) < 1e-9
}
return false
}
function to_int(x: f64) -> i32 {
return (x + 0.5) as i32
}
function main() -> i32 {
let seen: ptr<i8> = calloc(10000, 1)
if seen == null { return 1 }
let mut best_len: i32 = 0
let mut best_key: i64 = 0
let mut a: i32 = 1
while a <= 6 {
let mut b: i32 = a + 1
while b <= 7 {
let mut c: i32 = b + 1
while c <= 8 {
let mut d: i32 = c + 1
while d <= 9 {
# clear seen for targets
let mut zi: i32 = 0
while zi < 10000 {
seen[zi] = 0
zi = zi + 1
}
let digs: array<i32, 4> = [a, b, c, d]
# all permutations of 4 digits
let mut p0: i32 = 0
while p0 < 4 {
let mut p1: i32 = 0
while p1 < 4 {
if p1 != p0 {
let mut p2: i32 = 0
while p2 < 4 {
if p2 != p0 && p2 != p1 {
let mut p3: i32 = 0
while p3 < 4 {
if p3 != p0 && p3 != p1 && p3 != p2 {
let w: f64 = digs[p0] as f64
let x: f64 = digs[p1] as f64
let y: f64 = digs[p2] as f64
let z: f64 = digs[p3] as f64
# all ((w⊕x)⊕y)⊕z and (w⊕x)⊕(y⊕z) patterns via ops 0:+ 1:- 2:* 3:/
let mut o1: i32 = 0
while o1 < 4 {
let mut o2: i32 = 0
while o2 < 4 {
let mut o3: i32 = 0
while o3 < 4 {
# pattern A: ((w o1 x) o2 y) o3 z
let mut v1: f64 = 0.0
let mut ok1: bool = true
if o1 == 0 { v1 = w + x }
elif o1 == 1 { v1 = w - x }
elif o1 == 2 { v1 = w * x }
else {
if absf(x) < 1e-12 { ok1 = false }
else { v1 = w / x }
}
if ok1 {
let mut v2: f64 = 0.0
if o2 == 0 { v2 = v1 + y }
elif o2 == 1 { v2 = v1 - y }
elif o2 == 2 { v2 = v1 * y }
else {
if absf(y) < 1e-12 { ok1 = false }
else { v2 = v1 / y }
}
if ok1 {
let mut v3: f64 = 0.0
if o3 == 0 { v3 = v2 + z }
elif o3 == 1 { v3 = v2 - z }
elif o3 == 2 { v3 = v2 * z }
else {
if absf(z) < 1e-12 { ok1 = false }
else { v3 = v2 / z }
}
if ok1 && nearly_int(v3) {
let t: i32 = to_int(v3)
if t > 0 && t < 10000 {
seen[t] = 1
}
}
}
}
# pattern B: (w o1 x) o2 (y o3 z)
ok1 = true
let mut left: f64 = 0.0
let mut right: f64 = 0.0
if o1 == 0 { left = w + x }
elif o1 == 1 { left = w - x }
elif o1 == 2 { left = w * x }
else {
if absf(x) < 1e-12 { ok1 = false }
else { left = w / x }
}
if ok1 {
if o3 == 0 { right = y + z }
elif o3 == 1 { right = y - z }
elif o3 == 2 { right = y * z }
else {
if absf(z) < 1e-12 { ok1 = false }
else { right = y / z }
}
}
if ok1 {
let mut v: f64 = 0.0
if o2 == 0 { v = left + right }
elif o2 == 1 { v = left - right }
elif o2 == 2 { v = left * right }
else {
if absf(right) < 1e-12 { ok1 = false }
else { v = left / right }
}
if ok1 && nearly_int(v) {
let t: i32 = to_int(v)
if t > 0 && t < 10000 {
seen[t] = 1
}
}
}
o3 = o3 + 1
}
o2 = o2 + 1
}
o1 = o1 + 1
}
}
p3 = p3 + 1
}
}
p2 = p2 + 1
}
}
p1 = p1 + 1
}
p0 = p0 + 1
}
let mut len: i32 = 0
while seen[len + 1] != 0 {
len = len + 1
}
if len > best_len {
best_len = len
best_key = (a as i64) * 1000 + (b as i64) * 100 + (c as i64) * 10 + (d as i64)
}
d = d + 1
}
c = c + 1
}
b = b + 1
}
a = a + 1
}
printf("%lld\n", best_key)
free(seen)
return 0
}
#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; }
double absf_f64(double x);
bool nearly_int_f64(double x);
int32_t to_int_f64(double x);
int32_t main(void);
double absf_f64(double x) {
if (x < 0.0) {
return (0.0 - x);
}
return x;
}
bool nearly_int_f64(double x) {
double r = (x + 0.5);
int64_t n = ((int64_t)(r));
if (x >= 0.0) {
double nearest = ((double)(((int64_t)((x + 0.5)))));
return absf_f64((x - nearest)) < 1e-9;
}
return 0;
}
int32_t to_int_f64(double x) {
return ((int32_t)((x + 0.5)));
}
int32_t main(void) {
int8_t* seen = (int8_t*)(calloc(10000, 1));
if (seen == NULL) {
return 1;
}
int32_t best_len = 0;
int64_t best_key = 0;
int32_t a = 1;
while (a <= 6) {
int32_t b = (a + 1);
while (b <= 7) {
int32_t c = (b + 1);
while (c <= 8) {
int32_t d = (c + 1);
while (d <= 9) {
int32_t zi = 0;
while (zi < 10000) {
seen[zi] = 0;
zi = (zi + 1);
}
int32_t digs[4] = { a, b, c, d };
int32_t p0 = 0;
while (p0 < 4) {
int32_t p1 = 0;
while (p1 < 4) {
if (p1 != p0) {
int32_t p2 = 0;
while (p2 < 4) {
if ((p2 != p0 && p2 != p1)) {
int32_t p3 = 0;
while (p3 < 4) {
if (((p3 != p0 && p3 != p1) && p3 != p2)) {
double w = ((double)((((unsigned)(p0) < 4) ? digs[p0] : (fprintf(stderr, "array index %d out of bounds (size %d)\n", (int)(p0), 4), flow_fault_handler("array index out of bounds"), digs[0]))));
double x = ((double)((((unsigned)(p1) < 4) ? digs[p1] : (fprintf(stderr, "array index %d out of bounds (size %d)\n", (int)(p1), 4), flow_fault_handler("array index out of bounds"), digs[0]))));
double y = ((double)((((unsigned)(p2) < 4) ? digs[p2] : (fprintf(stderr, "array index %d out of bounds (size %d)\n", (int)(p2), 4), flow_fault_handler("array index out of bounds"), digs[0]))));
double z = ((double)((((unsigned)(p3) < 4) ? digs[p3] : (fprintf(stderr, "array index %d out of bounds (size %d)\n", (int)(p3), 4), flow_fault_handler("array index out of bounds"), digs[0]))));
int32_t o1 = 0;
while (o1 < 4) {
int32_t o2 = 0;
while (o2 < 4) {
int32_t o3 = 0;
while (o3 < 4) {
double v1 = 0.0;
bool ok1 = 1;
if (o1 == 0) {
v1 = (w + x);
} else if (o1 == 1) {
v1 = (w - x);
} else if (o1 == 2) {
v1 = (w * x);
} else {
if (absf_f64(x) < 1e-12) {
ok1 = 0;
} else {
v1 = (w / x);
}
}
if (ok1) {
double v2 = 0.0;
if (o2 == 0) {
v2 = (v1 + y);
} else if (o2 == 1) {
v2 = (v1 - y);
} else if (o2 == 2) {
v2 = (v1 * y);
} else {
if (absf_f64(y) < 1e-12) {
ok1 = 0;
} else {
v2 = (v1 / y);
}
}
if (ok1) {
double v3 = 0.0;
if (o3 == 0) {
v3 = (v2 + z);
} else if (o3 == 1) {
v3 = (v2 - z);
} else if (o3 == 2) {
v3 = (v2 * z);
} else {
if (absf_f64(z) < 1e-12) {
ok1 = 0;
} else {
v3 = (v2 / z);
}
}
if ((ok1 && nearly_int_f64(v3))) {
int32_t t = to_int_f64(v3);
if ((t > 0 && t < 10000)) {
seen[t] = 1;
}
}
}
}
ok1 = 1;
double left = 0.0;
double right = 0.0;
if (o1 == 0) {
left = (w + x);
} else if (o1 == 1) {
left = (w - x);
} else if (o1 == 2) {
left = (w * x);
} else {
if (absf_f64(x) < 1e-12) {
ok1 = 0;
} else {
left = (w / x);
}
}
if (ok1) {
if (o3 == 0) {
right = (y + z);
} else if (o3 == 1) {
right = (y - z);
} else if (o3 == 2) {
right = (y * z);
} else {
if (absf_f64(z) < 1e-12) {
ok1 = 0;
} else {
right = (y / z);
}
}
}
if (ok1) {
double v = 0.0;
if (o2 == 0) {
v = (left + right);
} else if (o2 == 1) {
v = (left - right);
} else if (o2 == 2) {
v = (left * right);
} else {
if (absf_f64(right) < 1e-12) {
ok1 = 0;
} else {
v = (left / right);
}
}
if ((ok1 && nearly_int_f64(v))) {
int32_t t = to_int_f64(v);
if ((t > 0 && t < 10000)) {
seen[t] = 1;
}
}
}
o3 = (o3 + 1);
}
o2 = (o2 + 1);
}
o1 = (o1 + 1);
}
}
p3 = (p3 + 1);
}
}
p2 = (p2 + 1);
}
}
p1 = (p1 + 1);
}
p0 = (p0 + 1);
}
int32_t len = 0;
while (seen[(len + 1)] != 0) {
len = (len + 1);
}
if (len > best_len) {
best_len = len;
best_key = ((((((int64_t)(a)) * 1000) + (((int64_t)(b)) * 100)) + (((int64_t)(c)) * 10)) + ((int64_t)(d)));
}
d = (d + 1);
}
c = (c + 1);
}
b = (b + 1);
}
a = (a + 1);
}
printf("%lld\n", best_key);
free(seen);
return 0;
}
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 @absf(%arg0: f64) -> f64 {
%0 = arith.constant 0.0 : f32
%2 = arith.extf %0 : f32 to f64
%1 = arith.cmpf olt, %arg0, %2 : f64
cf.cond_br %1, ^bb0, ^bb1
^bb0:
%3 = arith.constant 0.0 : f32
%5 = arith.extf %3 : f32 to f64
%4 = arith.subf %5, %arg0 : f64
func.return %4 : f64
^bb1:
cf.br ^bb2
^bb2:
func.return %arg0 : f64
}
func.func @nearly_int(%arg0: f64) -> i1 {
%6 = arith.constant 0.5 : f32
%8 = arith.extf %6 : f32 to f64
%7 = arith.addf %arg0, %8 : f64
%9 = arith.fptosi %7 : f64 to i64
%10 = arith.constant 0.0 : f32
%12 = arith.extf %10 : f32 to f64
%11 = arith.cmpf oge, %arg0, %12 : f64
cf.cond_br %11, ^bb3, ^bb4
^bb3:
%13 = arith.constant 0.5 : f32
%15 = arith.extf %13 : f32 to f64
%14 = arith.addf %arg0, %15 : f64
%16 = arith.fptosi %14 : f64 to i64
%17 = arith.sitofp %16 : i64 to f64
%19 = arith.subf %arg0, %17 : f64
%18 = func.call @absf(%19) : (f64) -> f64
%20 = arith.constant 0.000000001 : f32
%22 = arith.extf %20 : f32 to f64
%21 = arith.cmpf olt, %18, %22 : f64
func.return %21 : i1
^bb4:
cf.br ^bb5
^bb5:
%23 = arith.constant 0 : i1
func.return %23 : i1
}
func.func @to_int(%arg0: f64) -> i32 {
%24 = arith.constant 0.5 : f32
%26 = arith.extf %24 : f32 to f64
%25 = arith.addf %arg0, %26 : f64
%27 = arith.fptosi %25 : f64 to i32
func.return %27 : i32
}
func.func @main() -> i32 {
%29 = arith.constant 10000 : i32
%30 = arith.constant 1 : i32
%31 = arith.extsi %29 : i32 to i64
%32 = arith.extsi %30 : i32 to i64
%28 = func.call @calloc(%31, %32) : (i64, i64) -> !llvm.ptr
%33 = llvm.mlir.zero : !llvm.ptr
%34 = llvm.icmp "eq" %28, %33 : !llvm.ptr
cf.cond_br %34, ^bb6, ^bb7
^bb6:
%35 = arith.constant 1 : i32
func.return %35 : i32
^bb7:
cf.br ^bb8
^bb8:
%36 = arith.constant 0 : i32
%37 = llvm.mlir.constant(1 : i64) : i64
%38 = llvm.alloca %37 x i32 : (i64) -> !llvm.ptr
llvm.store %36, %38 : i32, !llvm.ptr
%39 = arith.constant 0 : i32
%40 = arith.extsi %39 : i32 to i64
%41 = llvm.mlir.constant(1 : i64) : i64
%42 = llvm.alloca %41 x i64 : (i64) -> !llvm.ptr
llvm.store %40, %42 : i64, !llvm.ptr
%43 = arith.constant 1 : i32
%44 = llvm.mlir.constant(1 : i64) : i64
%45 = llvm.alloca %44 x i32 : (i64) -> !llvm.ptr
llvm.store %43, %45 : i32, !llvm.ptr
cf.br ^bb9
^bb9:
%46 = llvm.load %45 : !llvm.ptr -> i32
%47 = arith.constant 6 : i32
%48 = arith.cmpi sle, %46, %47 : i32
cf.cond_br %48, ^bb10, ^bb11
^bb10:
%49 = llvm.load %45 : !llvm.ptr -> i32
%50 = arith.constant 1 : i32
%51 = arith.addi %49, %50 : i32
%52 = llvm.mlir.constant(1 : i64) : i64
%53 = llvm.alloca %52 x i32 : (i64) -> !llvm.ptr
llvm.store %51, %53 : i32, !llvm.ptr
cf.br ^bb12
^bb12:
%54 = llvm.load %53 : !llvm.ptr -> i32
%55 = arith.constant 7 : i32
%56 = arith.cmpi sle, %54, %55 : i32
cf.cond_br %56, ^bb13, ^bb14
^bb13:
%57 = llvm.load %53 : !llvm.ptr -> i32
%58 = arith.constant 1 : i32
%59 = arith.addi %57, %58 : i32
%60 = llvm.mlir.constant(1 : i64) : i64
%61 = llvm.alloca %60 x i32 : (i64) -> !llvm.ptr
llvm.store %59, %61 : i32, !llvm.ptr
cf.br ^bb15
^bb15:
%62 = llvm.load %61 : !llvm.ptr -> i32
%63 = arith.constant 8 : i32
%64 = arith.cmpi sle, %62, %63 : i32
cf.cond_br %64, ^bb16, ^bb17
^bb16:
%65 = llvm.load %61 : !llvm.ptr -> i32
%66 = arith.constant 1 : i32
%67 = arith.addi %65, %66 : i32
%68 = llvm.mlir.constant(1 : i64) : i64
%69 = llvm.alloca %68 x i32 : (i64) -> !llvm.ptr
llvm.store %67, %69 : i32, !llvm.ptr
cf.br ^bb18
^bb18:
%70 = llvm.load %69 : !llvm.ptr -> i32
%71 = arith.constant 9 : i32
%72 = arith.cmpi sle, %70, %71 : i32
cf.cond_br %72, ^bb19, ^bb20
^bb19:
%73 = arith.constant 0 : i32
%74 = llvm.mlir.constant(1 : i64) : i64
%75 = llvm.alloca %74 x i32 : (i64) -> !llvm.ptr
llvm.store %73, %75 : i32, !llvm.ptr
cf.br ^bb21
^bb21:
%76 = llvm.load %75 : !llvm.ptr -> i32
%77 = arith.constant 10000 : i32
%78 = arith.cmpi slt, %76, %77 : i32
cf.cond_br %78, ^bb22, ^bb23
^bb22:
%79 = arith.constant 0 : i32
%80 = llvm.load %75 : !llvm.ptr -> i32
%81 = arith.trunci %79 : i32 to i8
%82 = arith.extsi %80 : i32 to i64
%83 = llvm.getelementptr %28[%82] : (!llvm.ptr, i64) -> !llvm.ptr, i8
llvm.store %81, %83 : i8, !llvm.ptr
%84 = llvm.load %75 : !llvm.ptr -> i32
%85 = arith.constant 1 : i32
%86 = arith.addi %84, %85 : i32
llvm.store %86, %75 : i32, !llvm.ptr
cf.br ^bb21
^bb23:
%88 = llvm.load %45 : !llvm.ptr -> i32
%89 = llvm.load %53 : !llvm.ptr -> i32
%90 = llvm.load %61 : !llvm.ptr -> i32
%91 = llvm.load %69 : !llvm.ptr -> i32
%92 = llvm.mlir.constant(1 : i64) : i64
%93 = llvm.alloca %92 x !llvm.array<4 x i32> : (i64) -> !llvm.ptr
%94 = llvm.mlir.zero : !llvm.array<4 x i32>
llvm.store %94, %93 : !llvm.array<4 x i32>, !llvm.ptr
%95 = llvm.mlir.constant(0 : i64) : i64
%96 = llvm.getelementptr %93[0, %95] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<4 x i32>
llvm.store %88, %96 : i32, !llvm.ptr
%97 = llvm.mlir.constant(1 : i64) : i64
%98 = llvm.getelementptr %93[0, %97] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<4 x i32>
llvm.store %89, %98 : i32, !llvm.ptr
%99 = llvm.mlir.constant(2 : i64) : i64
%100 = llvm.getelementptr %93[0, %99] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<4 x i32>
llvm.store %90, %100 : i32, !llvm.ptr
%101 = llvm.mlir.constant(3 : i64) : i64
%102 = llvm.getelementptr %93[0, %101] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<4 x i32>
llvm.store %91, %102 : i32, !llvm.ptr
%103 = arith.constant 0 : i32
%104 = llvm.mlir.constant(1 : i64) : i64
%105 = llvm.alloca %104 x i32 : (i64) -> !llvm.ptr
llvm.store %103, %105 : i32, !llvm.ptr
cf.br ^bb24
^bb24:
%106 = llvm.load %105 : !llvm.ptr -> i32
%107 = arith.constant 4 : i32
%108 = arith.cmpi slt, %106, %107 : i32
cf.cond_br %108, ^bb25, ^bb26
^bb25:
%109 = arith.constant 0 : i32
%110 = llvm.mlir.constant(1 : i64) : i64
%111 = llvm.alloca %110 x i32 : (i64) -> !llvm.ptr
llvm.store %109, %111 : i32, !llvm.ptr
cf.br ^bb27
^bb27:
%112 = llvm.load %111 : !llvm.ptr -> i32
%113 = arith.constant 4 : i32
%114 = arith.cmpi slt, %112, %113 : i32
cf.cond_br %114, ^bb28, ^bb29
^bb28:
%115 = llvm.load %111 : !llvm.ptr -> i32
%116 = llvm.load %105 : !llvm.ptr -> i32
%117 = arith.cmpi ne, %115, %116 : i32
cf.cond_br %117, ^bb30, ^bb31
^bb30:
%118 = arith.constant 0 : i32
%119 = llvm.mlir.constant(1 : i64) : i64
%120 = llvm.alloca %119 x i32 : (i64) -> !llvm.ptr
llvm.store %118, %120 : i32, !llvm.ptr
cf.br ^bb33
^bb33:
%121 = llvm.load %120 : !llvm.ptr -> i32
%122 = arith.constant 4 : i32
%123 = arith.cmpi slt, %121, %122 : i32
cf.cond_br %123, ^bb34, ^bb35
^bb34:
%124 = llvm.load %120 : !llvm.ptr -> i32
%125 = llvm.load %105 : !llvm.ptr -> i32
%126 = arith.cmpi ne, %124, %125 : i32
%127 = scf.if %126 -> (i1) {
%128 = llvm.load %120 : !llvm.ptr -> i32
%129 = llvm.load %111 : !llvm.ptr -> i32
%130 = arith.cmpi ne, %128, %129 : i32
scf.yield %130 : i1
} else {
%131 = arith.constant false
scf.yield %131 : i1
}
cf.cond_br %127, ^bb36, ^bb37
^bb36:
%132 = arith.constant 0 : i32
%133 = llvm.mlir.constant(1 : i64) : i64
%134 = llvm.alloca %133 x i32 : (i64) -> !llvm.ptr
llvm.store %132, %134 : i32, !llvm.ptr
cf.br ^bb39
^bb39:
%135 = llvm.load %134 : !llvm.ptr -> i32
%136 = arith.constant 4 : i32
%137 = arith.cmpi slt, %135, %136 : i32
cf.cond_br %137, ^bb40, ^bb41
^bb40:
%138 = llvm.load %134 : !llvm.ptr -> i32
%139 = llvm.load %105 : !llvm.ptr -> i32
%140 = arith.cmpi ne, %138, %139 : i32
%141 = scf.if %140 -> (i1) {
%142 = llvm.load %134 : !llvm.ptr -> i32
%143 = llvm.load %111 : !llvm.ptr -> i32
%144 = arith.cmpi ne, %142, %143 : i32
scf.yield %144 : i1
} else {
%145 = arith.constant false
scf.yield %145 : i1
}
%146 = scf.if %141 -> (i1) {
%147 = llvm.load %134 : !llvm.ptr -> i32
%148 = llvm.load %120 : !llvm.ptr -> i32
%149 = arith.cmpi ne, %147, %148 : i32
scf.yield %149 : i1
} else {
%150 = arith.constant false
scf.yield %150 : i1
}
cf.cond_br %146, ^bb42, ^bb43
^bb42:
%152 = llvm.load %105 : !llvm.ptr -> i32
%153 = arith.extsi %152 : i32 to i64
%154 = llvm.getelementptr %93[0, %153] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<4 x i32>
%151 = llvm.load %154 : !llvm.ptr -> i32
%155 = arith.sitofp %151 : i32 to f64
%157 = llvm.load %111 : !llvm.ptr -> i32
%158 = arith.extsi %157 : i32 to i64
%159 = llvm.getelementptr %93[0, %158] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<4 x i32>
%156 = llvm.load %159 : !llvm.ptr -> i32
%160 = arith.sitofp %156 : i32 to f64
%162 = llvm.load %120 : !llvm.ptr -> i32
%163 = arith.extsi %162 : i32 to i64
%164 = llvm.getelementptr %93[0, %163] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<4 x i32>
%161 = llvm.load %164 : !llvm.ptr -> i32
%165 = arith.sitofp %161 : i32 to f64
%167 = llvm.load %134 : !llvm.ptr -> i32
%168 = arith.extsi %167 : i32 to i64
%169 = llvm.getelementptr %93[0, %168] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<4 x i32>
%166 = llvm.load %169 : !llvm.ptr -> i32
%170 = arith.sitofp %166 : i32 to f64
%171 = arith.constant 0 : i32
%172 = llvm.mlir.constant(1 : i64) : i64
%173 = llvm.alloca %172 x i32 : (i64) -> !llvm.ptr
llvm.store %171, %173 : i32, !llvm.ptr
cf.br ^bb45
^bb45:
%174 = llvm.load %173 : !llvm.ptr -> i32
%175 = arith.constant 4 : i32
%176 = arith.cmpi slt, %174, %175 : i32
cf.cond_br %176, ^bb46, ^bb47
^bb46:
%177 = arith.constant 0 : i32
%178 = llvm.mlir.constant(1 : i64) : i64
%179 = llvm.alloca %178 x i32 : (i64) -> !llvm.ptr
llvm.store %177, %179 : i32, !llvm.ptr
cf.br ^bb48
^bb48:
%180 = llvm.load %179 : !llvm.ptr -> i32
%181 = arith.constant 4 : i32
%182 = arith.cmpi slt, %180, %181 : i32
cf.cond_br %182, ^bb49, ^bb50
^bb49:
%183 = arith.constant 0 : i32
%184 = llvm.mlir.constant(1 : i64) : i64
%185 = llvm.alloca %184 x i32 : (i64) -> !llvm.ptr
llvm.store %183, %185 : i32, !llvm.ptr
cf.br ^bb51
^bb51:
%186 = llvm.load %185 : !llvm.ptr -> i32
%187 = arith.constant 4 : i32
%188 = arith.cmpi slt, %186, %187 : i32
cf.cond_br %188, ^bb52, ^bb53
^bb52:
%189 = arith.constant 0.0 : f32
%190 = arith.extf %189 : f32 to f64
%191 = llvm.mlir.constant(1 : i64) : i64
%192 = llvm.alloca %191 x f64 : (i64) -> !llvm.ptr
llvm.store %190, %192 : f64, !llvm.ptr
%193 = arith.constant 1 : i1
%194 = llvm.mlir.constant(1 : i64) : i64
%195 = llvm.alloca %194 x i1 : (i64) -> !llvm.ptr
llvm.store %193, %195 : i1, !llvm.ptr
%196 = llvm.load %173 : !llvm.ptr -> i32
%197 = arith.constant 0 : i32
%198 = arith.cmpi eq, %196, %197 : i32
cf.cond_br %198, ^bb54, ^bb55
^bb54:
%199 = arith.addf %155, %160 : f64
llvm.store %199, %192 : f64, !llvm.ptr
cf.br ^bb56
^bb55:
%200 = llvm.load %173 : !llvm.ptr -> i32
%201 = arith.constant 1 : i32
%202 = arith.cmpi eq, %200, %201 : i32
cf.cond_br %202, ^bb58, ^bb57
^bb58:
%203 = arith.subf %155, %160 : f64
llvm.store %203, %192 : f64, !llvm.ptr
cf.br ^bb56
^bb57:
%204 = llvm.load %173 : !llvm.ptr -> i32
%205 = arith.constant 2 : i32
%206 = arith.cmpi eq, %204, %205 : i32
cf.cond_br %206, ^bb60, ^bb59
^bb60:
%207 = arith.mulf %155, %160 : f64
llvm.store %207, %192 : f64, !llvm.ptr
cf.br ^bb56
^bb59:
%208 = func.call @absf(%160) : (f64) -> f64
%209 = arith.constant 0 : f32
%211 = arith.extf %209 : f32 to f64
%210 = arith.cmpf olt, %208, %211 : f64
cf.cond_br %210, ^bb61, ^bb62
^bb61:
%212 = arith.constant 0 : i1
llvm.store %212, %195 : i1, !llvm.ptr
cf.br ^bb63
^bb62:
%213 = arith.divf %155, %160 : f64
llvm.store %213, %192 : f64, !llvm.ptr
cf.br ^bb63
^bb63:
cf.br ^bb56
^bb56:
%214 = llvm.load %195 : !llvm.ptr -> i1
cf.cond_br %214, ^bb64, ^bb65
^bb64:
%215 = arith.constant 0.0 : f32
%216 = arith.extf %215 : f32 to f64
%217 = llvm.mlir.constant(1 : i64) : i64
%218 = llvm.alloca %217 x f64 : (i64) -> !llvm.ptr
llvm.store %216, %218 : f64, !llvm.ptr
%219 = llvm.load %179 : !llvm.ptr -> i32
%220 = arith.constant 0 : i32
%221 = arith.cmpi eq, %219, %220 : i32
cf.cond_br %221, ^bb67, ^bb68
^bb67:
%222 = llvm.load %192 : !llvm.ptr -> f64
%223 = arith.addf %222, %165 : f64
llvm.store %223, %218 : f64, !llvm.ptr
cf.br ^bb69
^bb68:
%224 = llvm.load %179 : !llvm.ptr -> i32
%225 = arith.constant 1 : i32
%226 = arith.cmpi eq, %224, %225 : i32
cf.cond_br %226, ^bb71, ^bb70
^bb71:
%227 = llvm.load %192 : !llvm.ptr -> f64
%228 = arith.subf %227, %165 : f64
llvm.store %228, %218 : f64, !llvm.ptr
cf.br ^bb69
^bb70:
%229 = llvm.load %179 : !llvm.ptr -> i32
%230 = arith.constant 2 : i32
%231 = arith.cmpi eq, %229, %230 : i32
cf.cond_br %231, ^bb73, ^bb72
^bb73:
%232 = llvm.load %192 : !llvm.ptr -> f64
%233 = arith.mulf %232, %165 : f64
llvm.store %233, %218 : f64, !llvm.ptr
cf.br ^bb69
^bb72:
%234 = func.call @absf(%165) : (f64) -> f64
%235 = arith.constant 0 : f32
%237 = arith.extf %235 : f32 to f64
%236 = arith.cmpf olt, %234, %237 : f64
cf.cond_br %236, ^bb74, ^bb75
^bb74:
%238 = arith.constant 0 : i1
llvm.store %238, %195 : i1, !llvm.ptr
cf.br ^bb76
^bb75:
%239 = llvm.load %192 : !llvm.ptr -> f64
%240 = arith.divf %239, %165 : f64
llvm.store %240, %218 : f64, !llvm.ptr
cf.br ^bb76
^bb76:
cf.br ^bb69
^bb69:
%241 = llvm.load %195 : !llvm.ptr -> i1
cf.cond_br %241, ^bb77, ^bb78
^bb77:
%242 = arith.constant 0.0 : f32
%243 = arith.extf %242 : f32 to f64
%244 = llvm.mlir.constant(1 : i64) : i64
%245 = llvm.alloca %244 x f64 : (i64) -> !llvm.ptr
llvm.store %243, %245 : f64, !llvm.ptr
%246 = llvm.load %185 : !llvm.ptr -> i32
%247 = arith.constant 0 : i32
%248 = arith.cmpi eq, %246, %247 : i32
cf.cond_br %248, ^bb80, ^bb81
^bb80:
%249 = llvm.load %218 : !llvm.ptr -> f64
%250 = arith.addf %249, %170 : f64
llvm.store %250, %245 : f64, !llvm.ptr
cf.br ^bb82
^bb81:
%251 = llvm.load %185 : !llvm.ptr -> i32
%252 = arith.constant 1 : i32
%253 = arith.cmpi eq, %251, %252 : i32
cf.cond_br %253, ^bb84, ^bb83
^bb84:
%254 = llvm.load %218 : !llvm.ptr -> f64
%255 = arith.subf %254, %170 : f64
llvm.store %255, %245 : f64, !llvm.ptr
cf.br ^bb82
^bb83:
%256 = llvm.load %185 : !llvm.ptr -> i32
%257 = arith.constant 2 : i32
%258 = arith.cmpi eq, %256, %257 : i32
cf.cond_br %258, ^bb86, ^bb85
^bb86:
%259 = llvm.load %218 : !llvm.ptr -> f64
%260 = arith.mulf %259, %170 : f64
llvm.store %260, %245 : f64, !llvm.ptr
cf.br ^bb82
^bb85:
%261 = func.call @absf(%170) : (f64) -> f64
%262 = arith.constant 0 : f32
%264 = arith.extf %262 : f32 to f64
%263 = arith.cmpf olt, %261, %264 : f64
cf.cond_br %263, ^bb87, ^bb88
^bb87:
%265 = arith.constant 0 : i1
llvm.store %265, %195 : i1, !llvm.ptr
cf.br ^bb89
^bb88:
%266 = llvm.load %218 : !llvm.ptr -> f64
%267 = arith.divf %266, %170 : f64
llvm.store %267, %245 : f64, !llvm.ptr
cf.br ^bb89
^bb89:
cf.br ^bb82
^bb82:
%268 = llvm.load %195 : !llvm.ptr -> i1
%269 = scf.if %268 -> (i1) {
%271 = llvm.load %245 : !llvm.ptr -> f64
%270 = func.call @nearly_int(%271) : (f64) -> i1
scf.yield %270 : i1
} else {
%272 = arith.constant false
scf.yield %272 : i1
}
cf.cond_br %269, ^bb90, ^bb91
^bb90:
%274 = llvm.load %245 : !llvm.ptr -> f64
%273 = func.call @to_int(%274) : (f64) -> i32
%275 = arith.constant 0 : i32
%276 = arith.cmpi sgt, %273, %275 : i32
%277 = scf.if %276 -> (i1) {
%278 = arith.constant 10000 : i32
%279 = arith.cmpi slt, %273, %278 : i32
scf.yield %279 : i1
} else {
%280 = arith.constant false
scf.yield %280 : i1
}
cf.cond_br %277, ^bb93, ^bb94
^bb93:
%281 = arith.constant 1 : i32
%282 = arith.trunci %281 : i32 to i8
%283 = arith.extsi %273 : i32 to i64
%284 = llvm.getelementptr %28[%283] : (!llvm.ptr, i64) -> !llvm.ptr, i8
llvm.store %282, %284 : i8, !llvm.ptr
cf.br ^bb95
^bb94:
cf.br ^bb95
^bb95:
cf.br ^bb92
^bb91:
cf.br ^bb92
^bb92:
cf.br ^bb79
^bb78:
cf.br ^bb79
^bb79:
cf.br ^bb66
^bb65:
cf.br ^bb66
^bb66:
%285 = arith.constant 1 : i1
llvm.store %285, %195 : i1, !llvm.ptr
%286 = arith.constant 0.0 : f32
%287 = arith.extf %286 : f32 to f64
%288 = llvm.mlir.constant(1 : i64) : i64
%289 = llvm.alloca %288 x f64 : (i64) -> !llvm.ptr
llvm.store %287, %289 : f64, !llvm.ptr
%290 = arith.constant 0.0 : f32
%291 = arith.extf %290 : f32 to f64
%292 = llvm.mlir.constant(1 : i64) : i64
%293 = llvm.alloca %292 x f64 : (i64) -> !llvm.ptr
llvm.store %291, %293 : f64, !llvm.ptr
%294 = llvm.load %173 : !llvm.ptr -> i32
%295 = arith.constant 0 : i32
%296 = arith.cmpi eq, %294, %295 : i32
cf.cond_br %296, ^bb96, ^bb97
^bb96:
%297 = arith.addf %155, %160 : f64
llvm.store %297, %289 : f64, !llvm.ptr
cf.br ^bb98
^bb97:
%298 = llvm.load %173 : !llvm.ptr -> i32
%299 = arith.constant 1 : i32
%300 = arith.cmpi eq, %298, %299 : i32
cf.cond_br %300, ^bb100, ^bb99
^bb100:
%301 = arith.subf %155, %160 : f64
llvm.store %301, %289 : f64, !llvm.ptr
cf.br ^bb98
^bb99:
%302 = llvm.load %173 : !llvm.ptr -> i32
%303 = arith.constant 2 : i32
%304 = arith.cmpi eq, %302, %303 : i32
cf.cond_br %304, ^bb102, ^bb101
^bb102:
%305 = arith.mulf %155, %160 : f64
llvm.store %305, %289 : f64, !llvm.ptr
cf.br ^bb98
^bb101:
%306 = func.call @absf(%160) : (f64) -> f64
%307 = arith.constant 0 : f32
%309 = arith.extf %307 : f32 to f64
%308 = arith.cmpf olt, %306, %309 : f64
cf.cond_br %308, ^bb103, ^bb104
^bb103:
%310 = arith.constant 0 : i1
llvm.store %310, %195 : i1, !llvm.ptr
cf.br ^bb105
^bb104:
%311 = arith.divf %155, %160 : f64
llvm.store %311, %289 : f64, !llvm.ptr
cf.br ^bb105
^bb105:
cf.br ^bb98
^bb98:
%312 = llvm.load %195 : !llvm.ptr -> i1
cf.cond_br %312, ^bb106, ^bb107
^bb106:
%313 = llvm.load %185 : !llvm.ptr -> i32
%314 = arith.constant 0 : i32
%315 = arith.cmpi eq, %313, %314 : i32
cf.cond_br %315, ^bb109, ^bb110
^bb109:
%316 = arith.addf %165, %170 : f64
llvm.store %316, %293 : f64, !llvm.ptr
cf.br ^bb111
^bb110:
%317 = llvm.load %185 : !llvm.ptr -> i32
%318 = arith.constant 1 : i32
%319 = arith.cmpi eq, %317, %318 : i32
cf.cond_br %319, ^bb113, ^bb112
^bb113:
%320 = arith.subf %165, %170 : f64
llvm.store %320, %293 : f64, !llvm.ptr
cf.br ^bb111
^bb112:
%321 = llvm.load %185 : !llvm.ptr -> i32
%322 = arith.constant 2 : i32
%323 = arith.cmpi eq, %321, %322 : i32
cf.cond_br %323, ^bb115, ^bb114
^bb115:
%324 = arith.mulf %165, %170 : f64
llvm.store %324, %293 : f64, !llvm.ptr
cf.br ^bb111
^bb114:
%325 = func.call @absf(%170) : (f64) -> f64
%326 = arith.constant 0 : f32
%328 = arith.extf %326 : f32 to f64
%327 = arith.cmpf olt, %325, %328 : f64
cf.cond_br %327, ^bb116, ^bb117
^bb116:
%329 = arith.constant 0 : i1
llvm.store %329, %195 : i1, !llvm.ptr
cf.br ^bb118
^bb117:
%330 = arith.divf %165, %170 : f64
llvm.store %330, %293 : f64, !llvm.ptr
cf.br ^bb118
^bb118:
cf.br ^bb111
^bb111:
cf.br ^bb108
^bb107:
cf.br ^bb108
^bb108:
%331 = llvm.load %195 : !llvm.ptr -> i1
cf.cond_br %331, ^bb119, ^bb120
^bb119:
%332 = arith.constant 0.0 : f32
%333 = arith.extf %332 : f32 to f64
%334 = llvm.mlir.constant(1 : i64) : i64
%335 = llvm.alloca %334 x f64 : (i64) -> !llvm.ptr
llvm.store %333, %335 : f64, !llvm.ptr
%336 = llvm.load %179 : !llvm.ptr -> i32
%337 = arith.constant 0 : i32
%338 = arith.cmpi eq, %336, %337 : i32
cf.cond_br %338, ^bb122, ^bb123
^bb122:
%339 = llvm.load %289 : !llvm.ptr -> f64
%340 = llvm.load %293 : !llvm.ptr -> f64
%341 = arith.addf %339, %340 : f64
llvm.store %341, %335 : f64, !llvm.ptr
cf.br ^bb124
^bb123:
%342 = llvm.load %179 : !llvm.ptr -> i32
%343 = arith.constant 1 : i32
%344 = arith.cmpi eq, %342, %343 : i32
cf.cond_br %344, ^bb126, ^bb125
^bb126:
%345 = llvm.load %289 : !llvm.ptr -> f64
%346 = llvm.load %293 : !llvm.ptr -> f64
%347 = arith.subf %345, %346 : f64
llvm.store %347, %335 : f64, !llvm.ptr
cf.br ^bb124
^bb125:
%348 = llvm.load %179 : !llvm.ptr -> i32
%349 = arith.constant 2 : i32
%350 = arith.cmpi eq, %348, %349 : i32
cf.cond_br %350, ^bb128, ^bb127
^bb128:
%351 = llvm.load %289 : !llvm.ptr -> f64
%352 = llvm.load %293 : !llvm.ptr -> f64
%353 = arith.mulf %351, %352 : f64
llvm.store %353, %335 : f64, !llvm.ptr
cf.br ^bb124
^bb127:
%355 = llvm.load %293 : !llvm.ptr -> f64
%354 = func.call @absf(%355) : (f64) -> f64
%356 = arith.constant 0 : f32
%358 = arith.extf %356 : f32 to f64
%357 = arith.cmpf olt, %354, %358 : f64
cf.cond_br %357, ^bb129, ^bb130
^bb129:
%359 = arith.constant 0 : i1
llvm.store %359, %195 : i1, !llvm.ptr
cf.br ^bb131
^bb130:
%360 = llvm.load %289 : !llvm.ptr -> f64
%361 = llvm.load %293 : !llvm.ptr -> f64
%362 = arith.divf %360, %361 : f64
llvm.store %362, %335 : f64, !llvm.ptr
cf.br ^bb131
^bb131:
cf.br ^bb124
^bb124:
%363 = llvm.load %195 : !llvm.ptr -> i1
%364 = scf.if %363 -> (i1) {
%366 = llvm.load %335 : !llvm.ptr -> f64
%365 = func.call @nearly_int(%366) : (f64) -> i1
scf.yield %365 : i1
} else {
%367 = arith.constant false
scf.yield %367 : i1
}
cf.cond_br %364, ^bb132, ^bb133
^bb132:
%369 = llvm.load %335 : !llvm.ptr -> f64
%368 = func.call @to_int(%369) : (f64) -> i32
%370 = arith.constant 0 : i32
%371 = arith.cmpi sgt, %368, %370 : i32
%372 = scf.if %371 -> (i1) {
%373 = arith.constant 10000 : i32
%374 = arith.cmpi slt, %368, %373 : i32
scf.yield %374 : i1
} else {
%375 = arith.constant false
scf.yield %375 : i1
}
cf.cond_br %372, ^bb135, ^bb136
^bb135:
%376 = arith.constant 1 : i32
%377 = arith.trunci %376 : i32 to i8
%378 = arith.extsi %368 : i32 to i64
%379 = llvm.getelementptr %28[%378] : (!llvm.ptr, i64) -> !llvm.ptr, i8
llvm.store %377, %379 : i8, !llvm.ptr
cf.br ^bb137
^bb136:
cf.br ^bb137
^bb137:
cf.br ^bb134
^bb133:
cf.br ^bb134
^bb134:
cf.br ^bb121
^bb120:
cf.br ^bb121
^bb121:
%380 = llvm.load %185 : !llvm.ptr -> i32
%381 = arith.constant 1 : i32
%382 = arith.addi %380, %381 : i32
llvm.store %382, %185 : i32, !llvm.ptr
cf.br ^bb51
^bb53:
%383 = llvm.load %179 : !llvm.ptr -> i32
%384 = arith.constant 1 : i32
%385 = arith.addi %383, %384 : i32
llvm.store %385, %179 : i32, !llvm.ptr
cf.br ^bb48
^bb50:
%386 = llvm.load %173 : !llvm.ptr -> i32
%387 = arith.constant 1 : i32
%388 = arith.addi %386, %387 : i32
llvm.store %388, %173 : i32, !llvm.ptr
cf.br ^bb45
^bb47:
cf.br ^bb44
^bb43:
cf.br ^bb44
^bb44:
%389 = llvm.load %134 : !llvm.ptr -> i32
%390 = arith.constant 1 : i32
%391 = arith.addi %389, %390 : i32
llvm.store %391, %134 : i32, !llvm.ptr
cf.br ^bb39
^bb41:
cf.br ^bb38
^bb37:
cf.br ^bb38
^bb38:
%392 = llvm.load %120 : !llvm.ptr -> i32
%393 = arith.constant 1 : i32
%394 = arith.addi %392, %393 : i32
llvm.store %394, %120 : i32, !llvm.ptr
cf.br ^bb33
^bb35:
cf.br ^bb32
^bb31:
cf.br ^bb32
^bb32:
%395 = llvm.load %111 : !llvm.ptr -> i32
%396 = arith.constant 1 : i32
%397 = arith.addi %395, %396 : i32
llvm.store %397, %111 : i32, !llvm.ptr
cf.br ^bb27
^bb29:
%398 = llvm.load %105 : !llvm.ptr -> i32
%399 = arith.constant 1 : i32
%400 = arith.addi %398, %399 : i32
llvm.store %400, %105 : i32, !llvm.ptr
cf.br ^bb24
^bb26:
%401 = arith.constant 0 : i32
%402 = llvm.mlir.constant(1 : i64) : i64
%403 = llvm.alloca %402 x i32 : (i64) -> !llvm.ptr
llvm.store %401, %403 : i32, !llvm.ptr
cf.br ^bb138
^bb138:
%405 = llvm.load %403 : !llvm.ptr -> i32
%406 = arith.constant 1 : i32
%407 = arith.addi %405, %406 : i32
%408 = arith.extsi %407 : i32 to i64
%409 = llvm.getelementptr %28[%408] : (!llvm.ptr, i64) -> !llvm.ptr, i8
%404 = llvm.load %409 : !llvm.ptr -> i8
%410 = arith.constant 0 : i32
%412 = arith.extsi %404 : i8 to i32
%411 = arith.cmpi ne, %412, %410 : i32
cf.cond_br %411, ^bb139, ^bb140
^bb139:
%413 = llvm.load %403 : !llvm.ptr -> i32
%414 = arith.constant 1 : i32
%415 = arith.addi %413, %414 : i32
llvm.store %415, %403 : i32, !llvm.ptr
cf.br ^bb138
^bb140:
%416 = llvm.load %403 : !llvm.ptr -> i32
%417 = llvm.load %38 : !llvm.ptr -> i32
%418 = arith.cmpi sgt, %416, %417 : i32
cf.cond_br %418, ^bb141, ^bb142
^bb141:
%419 = llvm.load %403 : !llvm.ptr -> i32
llvm.store %419, %38 : i32, !llvm.ptr
%420 = llvm.load %45 : !llvm.ptr -> i32
%421 = arith.extsi %420 : i32 to i64
%422 = arith.constant 1000 : i32
%424 = arith.extsi %422 : i32 to i64
%423 = arith.muli %421, %424 : i64
%425 = llvm.load %53 : !llvm.ptr -> i32
%426 = arith.extsi %425 : i32 to i64
%427 = arith.constant 100 : i32
%429 = arith.extsi %427 : i32 to i64
%428 = arith.muli %426, %429 : i64
%430 = arith.addi %423, %428 : i64
%431 = llvm.load %61 : !llvm.ptr -> i32
%432 = arith.extsi %431 : i32 to i64
%433 = arith.constant 10 : i32
%435 = arith.extsi %433 : i32 to i64
%434 = arith.muli %432, %435 : i64
%436 = arith.addi %430, %434 : i64
%437 = llvm.load %69 : !llvm.ptr -> i32
%438 = arith.extsi %437 : i32 to i64
%439 = arith.addi %436, %438 : i64
llvm.store %439, %42 : i64, !llvm.ptr
cf.br ^bb143
^bb142:
cf.br ^bb143
^bb143:
%440 = llvm.load %69 : !llvm.ptr -> i32
%441 = arith.constant 1 : i32
%442 = arith.addi %440, %441 : i32
llvm.store %442, %69 : i32, !llvm.ptr
cf.br ^bb18
^bb20:
%443 = llvm.load %61 : !llvm.ptr -> i32
%444 = arith.constant 1 : i32
%445 = arith.addi %443, %444 : i32
llvm.store %445, %61 : i32, !llvm.ptr
cf.br ^bb15
^bb17:
%446 = llvm.load %53 : !llvm.ptr -> i32
%447 = arith.constant 1 : i32
%448 = arith.addi %446, %447 : i32
llvm.store %448, %53 : i32, !llvm.ptr
cf.br ^bb12
^bb14:
%449 = llvm.load %45 : !llvm.ptr -> i32
%450 = arith.constant 1 : i32
%451 = arith.addi %449, %450 : i32
llvm.store %451, %45 : i32, !llvm.ptr
cf.br ^bb9
^bb11:
%452 = llvm.mlir.addressof @str_0 : !llvm.ptr
%453 = llvm.load %42 : !llvm.ptr -> i64
%454 = llvm.call @printf(%452, %453) vararg(!llvm.func<i32 (ptr, ...)>) : (!llvm.ptr, i64) -> i32
func.call @free(%28) : (!llvm.ptr) -> ()
%456 = arith.constant 0 : i32
func.return %456 : i32
}
}