← All problems
Problem 390
Sum of integer areas ≤ 10^10 for triangles sqrt(1+b²), sqrt(1+c²), sqrt(b²+c²).
View problem on Project Euler
Performance comparison
Metric Our solution Best known
Time complexity O(n)O(n^2)
Space complexity O(n)O(n^2)
Approach Flow solution Bottom-up DP
Verdict Optimal
Flow source
# Project Euler 390
# Sum of integer areas ≤ 10^10 for triangles sqrt(1+b²), sqrt(1+c²), sqrt(b²+c²).
extern {
function calloc(n: i64, size: i64) -> ptr<void>
function free(p: ptr<void>) -> void
}
function p_bound(N: i64) -> i64 {
let mut lo: i64 = 0
let mut hi: i64 = 1
while 8 * hi * hi * hi + hi <= N {
hi = hi * 2
}
while lo + 1 < hi {
let mid: i64 = (lo + hi) / 2
if 8 * mid * mid * mid + mid <= N {
lo = mid
} else {
hi = mid
}
}
return lo
}
function abs64(x: i64) -> i64 {
if x < 0 { return 0 - x }
return x
}
# Try to compute x*y if |x*y| fits in i64 and product >= 0 when needed.
function mul_nonneg(x: i64, y: i64) -> i64 {
# returns x*y if both >=0 and no overflow, else -1
if x < 0 || y < 0 { return -1 }
if x == 0 || y == 0 { return 0 }
let LIM: i64 = 9223372036854775807
if y > LIM / x { return -1 }
return x * y
}
function add_cap(sum0: i64, term: i64, N: i64) -> i64 {
# returns sum0+term if both >=0 and result <= N, else -1
if sum0 < 0 || term < 0 { return -1 }
if term > N - sum0 { return -1 }
return sum0 + term
}
function area_new(p: i64, q: i64, A: i64, N: i64) -> i64 {
# A' = 16 p^3 q + 4 p q + 8 p^2 A + A (for p>0)
# Handles q possibly negative by separating cases.
if p <= 0 { return -1 }
if A < 0 { return -1 }
if q >= 0 {
let mut sum: i64 = 0
# + A
sum = add_cap(sum, A, N)
if sum < 0 { return -1 }
# + 8 p^2 A
let p2: i64 = mul_nonneg(p, p)
if p2 < 0 { return -1 }
let eight_p2: i64 = mul_nonneg(8, p2)
if eight_p2 < 0 { return -1 }
let t2: i64 = mul_nonneg(eight_p2, A)
if t2 < 0 { return -1 }
sum = add_cap(sum, t2, N)
if sum < 0 { return -1 }
# + 4 p q
let four_p: i64 = mul_nonneg(4, p)
if four_p < 0 { return -1 }
let t3: i64 = mul_nonneg(four_p, q)
if t3 < 0 { return -1 }
sum = add_cap(sum, t3, N)
if sum < 0 { return -1 }
# + 16 p^3 q = 16 p * p2 * q
let sixteen_p: i64 = mul_nonneg(16, p)
if sixteen_p < 0 { return -1 }
let t4a: i64 = mul_nonneg(sixteen_p, p2)
if t4a < 0 {
# 16*p^3 may overflow i64; do (N-sum)/q comparison style
if q == 0 {
return sum
}
# t4 = 16*p^3*q = (16*p*q)*p2
let t16pq: i64 = mul_nonneg(sixteen_p, q)
if t16pq < 0 { return -1 }
let t4: i64 = mul_nonneg(t16pq, p2)
if t4 < 0 { return -1 }
sum = add_cap(sum, t4, N)
if sum < 0 { return -1 }
return sum
}
let t4: i64 = mul_nonneg(t4a, q)
if t4 < 0 { return -1 }
sum = add_cap(sum, t4, N)
if sum < 0 { return -1 }
return sum
}
# q < 0: A' = 8p^2 A + A - 16 p^3 mq - 4 p mq
# Positive partial sums may exceed N before subtraction, so do not cap at N yet.
let mq: i64 = 0 - q
let p2: i64 = mul_nonneg(p, p)
if p2 < 0 { return -1 }
let eight_p2: i64 = mul_nonneg(8, p2)
if eight_p2 < 0 { return -1 }
let mut pos: i64 = mul_nonneg(eight_p2, A)
if pos < 0 { return -1 }
let LIM: i64 = 9223372036854775807
if A > LIM - pos { return -1 }
pos = pos + A
let four_p: i64 = mul_nonneg(4, p)
if four_p < 0 { return -1 }
let sub1: i64 = mul_nonneg(four_p, mq)
if sub1 < 0 { return -1 }
if sub1 > pos { return -1 }
pos = pos - sub1
let sixteen_p: i64 = mul_nonneg(16, p)
if sixteen_p < 0 { return -1 }
let t16pq: i64 = mul_nonneg(sixteen_p, mq)
if t16pq < 0 { return -1 }
let sub2: i64 = mul_nonneg(t16pq, p2)
if sub2 < 0 { return -1 }
if sub2 > pos { return -1 }
pos = pos - sub2
if pos < 1 || pos > N { return -1 }
return pos
}
function q_new_val(p: i64, q: i64, A: i64) -> i64 {
# q' = (8p^2+1)q + 4p A = 8 p^2 q + q + 4 p A
# May be large; must fit in i64 for stack storage.
let p2: i64 = p * p # |p| <= 2.5e9 fits
# Use i64 carefully; values observed up to ~2.4e9 fit.
return (8 * p2 + 1) * q + 4 * p * A
}
function main() -> i32 {
let N: i64 = 10000000000
let bound: i64 = p_bound(N)
let CAP: i64 = 100000
let sp: ptr<i64> = calloc(CAP, 8)
let sq: ptr<i64> = calloc(CAP, 8)
let sA: ptr<i64> = calloc(CAP, 8)
if sp == null || sq == null || sA == null { return 1 }
let mut top: i64 = 0
let mut p0: i64 = 1
while p0 <= bound {
sp[top] = p0
sq[top] = 0
sA[top] = p0
top = top + 1
p0 = p0 + 1
}
let mut total: i64 = 0
while top > 0 {
top = top - 1
let mut pp: i64 = sp[top]
let mut qq: i64 = sq[top]
let AA: i64 = sA[top]
# Normalize to p > 0 (sign flip of p and q leaves A' invariant).
if pp < 0 {
pp = 0 - pp
qq = 0 - qq
}
if pp == 0 { continue }
let A_new: i64 = area_new(pp, qq, AA, N)
if A_new > 0 {
# q_new may overflow for huge values; only needed when A_new valid
# For valid branches, |q_new| stayed <= ~2.4e9 in reference runs.
let q_new: i64 = (8 * pp * pp + 1) * qq + 4 * pp * AA
total = total + A_new
if top + 3 > CAP {
printf("stack overflow\n")
return 1
}
sp[top] = pp; sq[top] = q_new; sA[top] = A_new; top = top + 1
sp[top] = q_new; sq[top] = pp; sA[top] = A_new; top = top + 1
sp[top] = q_new; sq[top] = 0 - pp; sA[top] = A_new; top = top + 1
}
}
printf("%lld\n", total)
free(sA)
free(sq)
free(sp)
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 p_bound_i64(int64_t N);
int64_t abs64_i64(int64_t x);
int64_t mul_nonneg_i64_i64(int64_t x, int64_t y);
int64_t add_cap_i64_i64_i64(int64_t sum0, int64_t term, int64_t N);
int64_t area_new_i64_i64_i64_i64(int64_t p, int64_t q, int64_t A, int64_t N);
int64_t q_new_val_i64_i64_i64(int64_t p, int64_t q, int64_t A);
int32_t main(void);
int64_t p_bound_i64(int64_t N) {
int64_t lo = 0;
int64_t hi = 1;
while (((((8 * hi) * hi) * hi) + hi) <= N) {
hi = (hi * 2);
}
while ((lo + 1) < hi) {
int64_t mid = FLOW_CHECKED_DIV(((lo + hi)), (2));
if (((((8 * mid) * mid) * mid) + mid) <= N) {
lo = mid;
} else {
hi = mid;
}
}
return lo;
}
int64_t abs64_i64(int64_t x) {
if (x < 0) {
return (0 - x);
}
return x;
}
int64_t mul_nonneg_i64_i64(int64_t x, int64_t y) {
if ((x < 0 || y < 0)) {
return (-1);
}
if ((x == 0 || y == 0)) {
return 0;
}
int64_t LIM = 9223372036854775807;
if (y > FLOW_CHECKED_DIV((LIM), (x))) {
return (-1);
}
return (x * y);
}
int64_t add_cap_i64_i64_i64(int64_t sum0, int64_t term, int64_t N) {
if ((sum0 < 0 || term < 0)) {
return (-1);
}
if (term > (N - sum0)) {
return (-1);
}
return (sum0 + term);
}
int64_t area_new_i64_i64_i64_i64(int64_t p, int64_t q, int64_t A, int64_t N) {
if (p <= 0) {
return (-1);
}
if (A < 0) {
return (-1);
}
if (q >= 0) {
int64_t sum = 0;
sum = add_cap_i64_i64_i64(sum, A, N);
if (sum < 0) {
return (-1);
}
int64_t p2 = mul_nonneg_i64_i64(p, p);
if (p2 < 0) {
return (-1);
}
int64_t eight_p2 = mul_nonneg_i64_i64(8, p2);
if (eight_p2 < 0) {
return (-1);
}
int64_t t2 = mul_nonneg_i64_i64(eight_p2, A);
if (t2 < 0) {
return (-1);
}
sum = add_cap_i64_i64_i64(sum, t2, N);
if (sum < 0) {
return (-1);
}
int64_t four_p = mul_nonneg_i64_i64(4, p);
if (four_p < 0) {
return (-1);
}
int64_t t3 = mul_nonneg_i64_i64(four_p, q);
if (t3 < 0) {
return (-1);
}
sum = add_cap_i64_i64_i64(sum, t3, N);
if (sum < 0) {
return (-1);
}
int64_t sixteen_p = mul_nonneg_i64_i64(16, p);
if (sixteen_p < 0) {
return (-1);
}
int64_t t4a = mul_nonneg_i64_i64(sixteen_p, p2);
if (t4a < 0) {
if (q == 0) {
return sum;
}
int64_t t16pq = mul_nonneg_i64_i64(sixteen_p, q);
if (t16pq < 0) {
return (-1);
}
int64_t t4 = mul_nonneg_i64_i64(t16pq, p2);
if (t4 < 0) {
return (-1);
}
sum = add_cap_i64_i64_i64(sum, t4, N);
if (sum < 0) {
return (-1);
}
return sum;
}
int64_t t4 = mul_nonneg_i64_i64(t4a, q);
if (t4 < 0) {
return (-1);
}
sum = add_cap_i64_i64_i64(sum, t4, N);
if (sum < 0) {
return (-1);
}
return sum;
}
int64_t mq = (0 - q);
int64_t p2 = mul_nonneg_i64_i64(p, p);
if (p2 < 0) {
return (-1);
}
int64_t eight_p2 = mul_nonneg_i64_i64(8, p2);
if (eight_p2 < 0) {
return (-1);
}
int64_t pos = mul_nonneg_i64_i64(eight_p2, A);
if (pos < 0) {
return (-1);
}
int64_t LIM = 9223372036854775807;
if (A > (LIM - pos)) {
return (-1);
}
pos = (pos + A);
int64_t four_p = mul_nonneg_i64_i64(4, p);
if (four_p < 0) {
return (-1);
}
int64_t sub1 = mul_nonneg_i64_i64(four_p, mq);
if (sub1 < 0) {
return (-1);
}
if (sub1 > pos) {
return (-1);
}
pos = (pos - sub1);
int64_t sixteen_p = mul_nonneg_i64_i64(16, p);
if (sixteen_p < 0) {
return (-1);
}
int64_t t16pq = mul_nonneg_i64_i64(sixteen_p, mq);
if (t16pq < 0) {
return (-1);
}
int64_t sub2 = mul_nonneg_i64_i64(t16pq, p2);
if (sub2 < 0) {
return (-1);
}
if (sub2 > pos) {
return (-1);
}
pos = (pos - sub2);
if ((pos < 1 || pos > N)) {
return (-1);
}
return pos;
}
int64_t q_new_val_i64_i64_i64(int64_t p, int64_t q, int64_t A) {
int64_t p2 = (p * p);
return ((((8 * p2) + 1) * q) + ((4 * p) * A));
}
int32_t main(void) {
int64_t N = 10000000000;
int64_t bound = p_bound_i64(N);
int64_t CAP = 100000;
int64_t* sp = (int64_t*)(calloc(CAP, 8));
int64_t* sq = (int64_t*)(calloc(CAP, 8));
int64_t* sA = (int64_t*)(calloc(CAP, 8));
if (((sp == NULL || sq == NULL) || sA == NULL)) {
return 1;
}
int64_t top = 0;
int64_t p0 = 1;
while (p0 <= bound) {
sp[top] = p0;
sq[top] = 0;
sA[top] = p0;
top = (top + 1);
p0 = (p0 + 1);
}
int64_t total = 0;
while (top > 0) {
top = (top - 1);
int64_t pp = sp[top];
int64_t qq = sq[top];
int64_t AA = sA[top];
if (pp < 0) {
pp = (0 - pp);
qq = (0 - qq);
}
if (pp == 0) {
continue;
}
int64_t A_new = area_new_i64_i64_i64_i64(pp, qq, AA, N);
if (A_new > 0) {
int64_t q_new = (((((8 * pp) * pp) + 1) * qq) + ((4 * pp) * AA));
total = (total + A_new);
if ((top + 3) > CAP) {
printf("stack overflow\n");
return 1;
}
sp[top] = pp;
sq[top] = q_new;
sA[top] = A_new;
top = (top + 1);
sp[top] = q_new;
sq[top] = pp;
sA[top] = A_new;
top = (top + 1);
sp[top] = q_new;
sq[top] = (0 - pp);
sA[top] = A_new;
top = (top + 1);
}
}
printf("%lld\n", total);
free(sA);
free(sq);
free(sp);
return 0;
}
Generated MLIR
module {
llvm.func @printf(!llvm.ptr, ...) -> i32
llvm.mlir.global internal constant @str_0("stack overflow\n\00") {addr_space = 0 : i32} : !llvm.array<16 x i8>
llvm.mlir.global internal constant @str_1("%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 @p_bound(%arg0: i64) -> i64 {
%0 = arith.constant 0 : i32
%1 = arith.extsi %0 : i32 to i64
%2 = llvm.mlir.constant(1 : i64) : i64
%3 = llvm.alloca %2 x i64 : (i64) -> !llvm.ptr
llvm.store %1, %3 : i64, !llvm.ptr
%4 = arith.constant 1 : i32
%5 = arith.extsi %4 : i32 to i64
%6 = llvm.mlir.constant(1 : i64) : i64
%7 = llvm.alloca %6 x i64 : (i64) -> !llvm.ptr
llvm.store %5, %7 : i64, !llvm.ptr
cf.br ^bb0
^bb0:
%8 = arith.constant 8 : i32
%9 = llvm.load %7 : !llvm.ptr -> i64
%11 = arith.extsi %8 : i32 to i64
%10 = arith.muli %11, %9 : i64
%12 = llvm.load %7 : !llvm.ptr -> i64
%13 = arith.muli %10, %12 : i64
%14 = llvm.load %7 : !llvm.ptr -> i64
%15 = arith.muli %13, %14 : i64
%16 = llvm.load %7 : !llvm.ptr -> i64
%17 = arith.addi %15, %16 : i64
%18 = arith.cmpi sle, %17, %arg0 : i64
cf.cond_br %18, ^bb1, ^bb2
^bb1:
%19 = llvm.load %7 : !llvm.ptr -> i64
%20 = arith.constant 2 : i32
%22 = arith.extsi %20 : i32 to i64
%21 = arith.muli %19, %22 : i64
llvm.store %21, %7 : i64, !llvm.ptr
cf.br ^bb0
^bb2:
cf.br ^bb3
^bb3:
%23 = llvm.load %3 : !llvm.ptr -> i64
%24 = arith.constant 1 : i32
%26 = arith.extsi %24 : i32 to i64
%25 = arith.addi %23, %26 : i64
%27 = llvm.load %7 : !llvm.ptr -> i64
%28 = arith.cmpi slt, %25, %27 : i64
cf.cond_br %28, ^bb4, ^bb5
^bb4:
%29 = llvm.load %3 : !llvm.ptr -> i64
%30 = llvm.load %7 : !llvm.ptr -> i64
%31 = arith.addi %29, %30 : i64
%32 = arith.constant 2 : i32
%34 = arith.extsi %32 : i32 to i64
%33 = arith.divsi %31, %34 : i64
%35 = arith.constant 8 : i32
%37 = arith.extsi %35 : i32 to i64
%36 = arith.muli %37, %33 : i64
%38 = arith.muli %36, %33 : i64
%39 = arith.muli %38, %33 : i64
%40 = arith.addi %39, %33 : i64
%41 = arith.cmpi sle, %40, %arg0 : i64
cf.cond_br %41, ^bb6, ^bb7
^bb6:
llvm.store %33, %3 : i64, !llvm.ptr
cf.br ^bb8
^bb7:
llvm.store %33, %7 : i64, !llvm.ptr
cf.br ^bb8
^bb8:
cf.br ^bb3
^bb5:
%42 = llvm.load %3 : !llvm.ptr -> i64
func.return %42 : i64
}
func.func @abs64(%arg0: i64) -> i64 {
%43 = arith.constant 0 : i32
%45 = arith.extsi %43 : i32 to i64
%44 = arith.cmpi slt, %arg0, %45 : i64
cf.cond_br %44, ^bb9, ^bb10
^bb9:
%46 = arith.constant 0 : i32
%48 = arith.extsi %46 : i32 to i64
%47 = arith.subi %48, %arg0 : i64
func.return %47 : i64
^bb10:
cf.br ^bb11
^bb11:
func.return %arg0 : i64
}
func.func @mul_nonneg(%arg0: i64, %arg1: i64) -> i64 {
%49 = arith.constant 0 : i32
%51 = arith.extsi %49 : i32 to i64
%50 = arith.cmpi slt, %arg0, %51 : i64
%52 = scf.if %50 -> (i1) {
%53 = arith.constant true
scf.yield %53 : i1
} else {
%54 = arith.constant 0 : i32
%56 = arith.extsi %54 : i32 to i64
%55 = arith.cmpi slt, %arg1, %56 : i64
scf.yield %55 : i1
}
cf.cond_br %52, ^bb12, ^bb13
^bb12:
%57 = arith.constant 1 : i32
%59 = arith.constant 0 : i32
%58 = arith.subi %59, %57 : i32
%60 = arith.extsi %58 : i32 to i64
func.return %60 : i64
^bb13:
cf.br ^bb14
^bb14:
%61 = arith.constant 0 : i32
%63 = arith.extsi %61 : i32 to i64
%62 = arith.cmpi eq, %arg0, %63 : i64
%64 = scf.if %62 -> (i1) {
%65 = arith.constant true
scf.yield %65 : i1
} else {
%66 = arith.constant 0 : i32
%68 = arith.extsi %66 : i32 to i64
%67 = arith.cmpi eq, %arg1, %68 : i64
scf.yield %67 : i1
}
cf.cond_br %64, ^bb15, ^bb16
^bb15:
%69 = arith.constant 0 : i32
%70 = arith.extsi %69 : i32 to i64
func.return %70 : i64
^bb16:
cf.br ^bb17
^bb17:
%71 = arith.constant 9223372032559808511 : i32
%72 = arith.extsi %71 : i32 to i64
%73 = arith.divsi %72, %arg0 : i64
%74 = arith.cmpi sgt, %arg1, %73 : i64
cf.cond_br %74, ^bb18, ^bb19
^bb18:
%75 = arith.constant 1 : i32
%77 = arith.constant 0 : i32
%76 = arith.subi %77, %75 : i32
%78 = arith.extsi %76 : i32 to i64
func.return %78 : i64
^bb19:
cf.br ^bb20
^bb20:
%79 = arith.muli %arg0, %arg1 : i64
func.return %79 : i64
}
func.func @add_cap(%arg0: i64, %arg1: i64, %arg2: i64) -> i64 {
%80 = arith.constant 0 : i32
%82 = arith.extsi %80 : i32 to i64
%81 = arith.cmpi slt, %arg0, %82 : i64
%83 = scf.if %81 -> (i1) {
%84 = arith.constant true
scf.yield %84 : i1
} else {
%85 = arith.constant 0 : i32
%87 = arith.extsi %85 : i32 to i64
%86 = arith.cmpi slt, %arg1, %87 : i64
scf.yield %86 : i1
}
cf.cond_br %83, ^bb21, ^bb22
^bb21:
%88 = arith.constant 1 : i32
%90 = arith.constant 0 : i32
%89 = arith.subi %90, %88 : i32
%91 = arith.extsi %89 : i32 to i64
func.return %91 : i64
^bb22:
cf.br ^bb23
^bb23:
%92 = arith.subi %arg2, %arg0 : i64
%93 = arith.cmpi sgt, %arg1, %92 : i64
cf.cond_br %93, ^bb24, ^bb25
^bb24:
%94 = arith.constant 1 : i32
%96 = arith.constant 0 : i32
%95 = arith.subi %96, %94 : i32
%97 = arith.extsi %95 : i32 to i64
func.return %97 : i64
^bb25:
cf.br ^bb26
^bb26:
%98 = arith.addi %arg0, %arg1 : i64
func.return %98 : i64
}
func.func @area_new(%arg0: i64, %arg1: i64, %arg2: i64, %arg3: i64) -> i64 {
%99 = arith.constant 0 : i32
%101 = arith.extsi %99 : i32 to i64
%100 = arith.cmpi sle, %arg0, %101 : i64
cf.cond_br %100, ^bb27, ^bb28
^bb27:
%102 = arith.constant 1 : i32
%104 = arith.constant 0 : i32
%103 = arith.subi %104, %102 : i32
%105 = arith.extsi %103 : i32 to i64
func.return %105 : i64
^bb28:
cf.br ^bb29
^bb29:
%106 = arith.constant 0 : i32
%108 = arith.extsi %106 : i32 to i64
%107 = arith.cmpi slt, %arg2, %108 : i64
cf.cond_br %107, ^bb30, ^bb31
^bb30:
%109 = arith.constant 1 : i32
%111 = arith.constant 0 : i32
%110 = arith.subi %111, %109 : i32
%112 = arith.extsi %110 : i32 to i64
func.return %112 : i64
^bb31:
cf.br ^bb32
^bb32:
%113 = arith.constant 0 : i32
%115 = arith.extsi %113 : i32 to i64
%114 = arith.cmpi sge, %arg1, %115 : i64
cf.cond_br %114, ^bb33, ^bb34
^bb33:
%116 = arith.constant 0 : i32
%117 = arith.extsi %116 : i32 to i64
%118 = llvm.mlir.constant(1 : i64) : i64
%119 = llvm.alloca %118 x i64 : (i64) -> !llvm.ptr
llvm.store %117, %119 : i64, !llvm.ptr
%121 = llvm.load %119 : !llvm.ptr -> i64
%120 = func.call @add_cap(%121, %arg2, %arg3) : (i64, i64, i64) -> i64
llvm.store %120, %119 : i64, !llvm.ptr
%122 = llvm.load %119 : !llvm.ptr -> i64
%123 = arith.constant 0 : i32
%125 = arith.extsi %123 : i32 to i64
%124 = arith.cmpi slt, %122, %125 : i64
cf.cond_br %124, ^bb36, ^bb37
^bb36:
%126 = arith.constant 1 : i32
%128 = arith.constant 0 : i32
%127 = arith.subi %128, %126 : i32
%129 = arith.extsi %127 : i32 to i64
func.return %129 : i64
^bb37:
cf.br ^bb38
^bb38:
%130 = func.call @mul_nonneg(%arg0, %arg0) : (i64, i64) -> i64
%131 = arith.constant 0 : i32
%133 = arith.extsi %131 : i32 to i64
%132 = arith.cmpi slt, %130, %133 : i64
cf.cond_br %132, ^bb39, ^bb40
^bb39:
%134 = arith.constant 1 : i32
%136 = arith.constant 0 : i32
%135 = arith.subi %136, %134 : i32
%137 = arith.extsi %135 : i32 to i64
func.return %137 : i64
^bb40:
cf.br ^bb41
^bb41:
%139 = arith.constant 8 : i32
%140 = arith.extsi %139 : i32 to i64
%138 = func.call @mul_nonneg(%140, %130) : (i64, i64) -> i64
%141 = arith.constant 0 : i32
%143 = arith.extsi %141 : i32 to i64
%142 = arith.cmpi slt, %138, %143 : i64
cf.cond_br %142, ^bb42, ^bb43
^bb42:
%144 = arith.constant 1 : i32
%146 = arith.constant 0 : i32
%145 = arith.subi %146, %144 : i32
%147 = arith.extsi %145 : i32 to i64
func.return %147 : i64
^bb43:
cf.br ^bb44
^bb44:
%148 = func.call @mul_nonneg(%138, %arg2) : (i64, i64) -> i64
%149 = arith.constant 0 : i32
%151 = arith.extsi %149 : i32 to i64
%150 = arith.cmpi slt, %148, %151 : i64
cf.cond_br %150, ^bb45, ^bb46
^bb45:
%152 = arith.constant 1 : i32
%154 = arith.constant 0 : i32
%153 = arith.subi %154, %152 : i32
%155 = arith.extsi %153 : i32 to i64
func.return %155 : i64
^bb46:
cf.br ^bb47
^bb47:
%157 = llvm.load %119 : !llvm.ptr -> i64
%156 = func.call @add_cap(%157, %148, %arg3) : (i64, i64, i64) -> i64
llvm.store %156, %119 : i64, !llvm.ptr
%158 = llvm.load %119 : !llvm.ptr -> i64
%159 = arith.constant 0 : i32
%161 = arith.extsi %159 : i32 to i64
%160 = arith.cmpi slt, %158, %161 : i64
cf.cond_br %160, ^bb48, ^bb49
^bb48:
%162 = arith.constant 1 : i32
%164 = arith.constant 0 : i32
%163 = arith.subi %164, %162 : i32
%165 = arith.extsi %163 : i32 to i64
func.return %165 : i64
^bb49:
cf.br ^bb50
^bb50:
%167 = arith.constant 4 : i32
%168 = arith.extsi %167 : i32 to i64
%166 = func.call @mul_nonneg(%168, %arg0) : (i64, i64) -> i64
%169 = arith.constant 0 : i32
%171 = arith.extsi %169 : i32 to i64
%170 = arith.cmpi slt, %166, %171 : i64
cf.cond_br %170, ^bb51, ^bb52
^bb51:
%172 = arith.constant 1 : i32
%174 = arith.constant 0 : i32
%173 = arith.subi %174, %172 : i32
%175 = arith.extsi %173 : i32 to i64
func.return %175 : i64
^bb52:
cf.br ^bb53
^bb53:
%176 = func.call @mul_nonneg(%166, %arg1) : (i64, i64) -> i64
%177 = arith.constant 0 : i32
%179 = arith.extsi %177 : i32 to i64
%178 = arith.cmpi slt, %176, %179 : i64
cf.cond_br %178, ^bb54, ^bb55
^bb54:
%180 = arith.constant 1 : i32
%182 = arith.constant 0 : i32
%181 = arith.subi %182, %180 : i32
%183 = arith.extsi %181 : i32 to i64
func.return %183 : i64
^bb55:
cf.br ^bb56
^bb56:
%185 = llvm.load %119 : !llvm.ptr -> i64
%184 = func.call @add_cap(%185, %176, %arg3) : (i64, i64, i64) -> i64
llvm.store %184, %119 : i64, !llvm.ptr
%186 = llvm.load %119 : !llvm.ptr -> i64
%187 = arith.constant 0 : i32
%189 = arith.extsi %187 : i32 to i64
%188 = arith.cmpi slt, %186, %189 : i64
cf.cond_br %188, ^bb57, ^bb58
^bb57:
%190 = arith.constant 1 : i32
%192 = arith.constant 0 : i32
%191 = arith.subi %192, %190 : i32
%193 = arith.extsi %191 : i32 to i64
func.return %193 : i64
^bb58:
cf.br ^bb59
^bb59:
%195 = arith.constant 16 : i32
%196 = arith.extsi %195 : i32 to i64
%194 = func.call @mul_nonneg(%196, %arg0) : (i64, i64) -> i64
%197 = arith.constant 0 : i32
%199 = arith.extsi %197 : i32 to i64
%198 = arith.cmpi slt, %194, %199 : i64
cf.cond_br %198, ^bb60, ^bb61
^bb60:
%200 = arith.constant 1 : i32
%202 = arith.constant 0 : i32
%201 = arith.subi %202, %200 : i32
%203 = arith.extsi %201 : i32 to i64
func.return %203 : i64
^bb61:
cf.br ^bb62
^bb62:
%204 = func.call @mul_nonneg(%194, %130) : (i64, i64) -> i64
%205 = arith.constant 0 : i32
%207 = arith.extsi %205 : i32 to i64
%206 = arith.cmpi slt, %204, %207 : i64
cf.cond_br %206, ^bb63, ^bb64
^bb63:
%208 = arith.constant 0 : i32
%210 = arith.extsi %208 : i32 to i64
%209 = arith.cmpi eq, %arg1, %210 : i64
cf.cond_br %209, ^bb66, ^bb67
^bb66:
%211 = llvm.load %119 : !llvm.ptr -> i64
func.return %211 : i64
^bb67:
cf.br ^bb68
^bb68:
%212 = func.call @mul_nonneg(%194, %arg1) : (i64, i64) -> i64
%213 = arith.constant 0 : i32
%215 = arith.extsi %213 : i32 to i64
%214 = arith.cmpi slt, %212, %215 : i64
cf.cond_br %214, ^bb69, ^bb70
^bb69:
%216 = arith.constant 1 : i32
%218 = arith.constant 0 : i32
%217 = arith.subi %218, %216 : i32
%219 = arith.extsi %217 : i32 to i64
func.return %219 : i64
^bb70:
cf.br ^bb71
^bb71:
%220 = func.call @mul_nonneg(%212, %130) : (i64, i64) -> i64
%221 = arith.constant 0 : i32
%223 = arith.extsi %221 : i32 to i64
%222 = arith.cmpi slt, %220, %223 : i64
cf.cond_br %222, ^bb72, ^bb73
^bb72:
%224 = arith.constant 1 : i32
%226 = arith.constant 0 : i32
%225 = arith.subi %226, %224 : i32
%227 = arith.extsi %225 : i32 to i64
func.return %227 : i64
^bb73:
cf.br ^bb74
^bb74:
%229 = llvm.load %119 : !llvm.ptr -> i64
%228 = func.call @add_cap(%229, %220, %arg3) : (i64, i64, i64) -> i64
llvm.store %228, %119 : i64, !llvm.ptr
%230 = llvm.load %119 : !llvm.ptr -> i64
%231 = arith.constant 0 : i32
%233 = arith.extsi %231 : i32 to i64
%232 = arith.cmpi slt, %230, %233 : i64
cf.cond_br %232, ^bb75, ^bb76
^bb75:
%234 = arith.constant 1 : i32
%236 = arith.constant 0 : i32
%235 = arith.subi %236, %234 : i32
%237 = arith.extsi %235 : i32 to i64
func.return %237 : i64
^bb76:
cf.br ^bb77
^bb77:
%238 = llvm.load %119 : !llvm.ptr -> i64
func.return %238 : i64
^bb64:
cf.br ^bb65
^bb65:
%239 = func.call @mul_nonneg(%204, %arg1) : (i64, i64) -> i64
%240 = arith.constant 0 : i32
%242 = arith.extsi %240 : i32 to i64
%241 = arith.cmpi slt, %239, %242 : i64
cf.cond_br %241, ^bb78, ^bb79
^bb78:
%243 = arith.constant 1 : i32
%245 = arith.constant 0 : i32
%244 = arith.subi %245, %243 : i32
%246 = arith.extsi %244 : i32 to i64
func.return %246 : i64
^bb79:
cf.br ^bb80
^bb80:
%248 = llvm.load %119 : !llvm.ptr -> i64
%247 = func.call @add_cap(%248, %239, %arg3) : (i64, i64, i64) -> i64
llvm.store %247, %119 : i64, !llvm.ptr
%249 = llvm.load %119 : !llvm.ptr -> i64
%250 = arith.constant 0 : i32
%252 = arith.extsi %250 : i32 to i64
%251 = arith.cmpi slt, %249, %252 : i64
cf.cond_br %251, ^bb81, ^bb82
^bb81:
%253 = arith.constant 1 : i32
%255 = arith.constant 0 : i32
%254 = arith.subi %255, %253 : i32
%256 = arith.extsi %254 : i32 to i64
func.return %256 : i64
^bb82:
cf.br ^bb83
^bb83:
%257 = llvm.load %119 : !llvm.ptr -> i64
func.return %257 : i64
^bb34:
cf.br ^bb35
^bb35:
%258 = arith.constant 0 : i32
%260 = arith.extsi %258 : i32 to i64
%259 = arith.subi %260, %arg1 : i64
%261 = func.call @mul_nonneg(%arg0, %arg0) : (i64, i64) -> i64
%262 = arith.constant 0 : i32
%264 = arith.extsi %262 : i32 to i64
%263 = arith.cmpi slt, %261, %264 : i64
cf.cond_br %263, ^bb84, ^bb85
^bb84:
%265 = arith.constant 1 : i32
%267 = arith.constant 0 : i32
%266 = arith.subi %267, %265 : i32
%268 = arith.extsi %266 : i32 to i64
func.return %268 : i64
^bb85:
cf.br ^bb86
^bb86:
%270 = arith.constant 8 : i32
%271 = arith.extsi %270 : i32 to i64
%269 = func.call @mul_nonneg(%271, %261) : (i64, i64) -> i64
%272 = arith.constant 0 : i32
%274 = arith.extsi %272 : i32 to i64
%273 = arith.cmpi slt, %269, %274 : i64
cf.cond_br %273, ^bb87, ^bb88
^bb87:
%275 = arith.constant 1 : i32
%277 = arith.constant 0 : i32
%276 = arith.subi %277, %275 : i32
%278 = arith.extsi %276 : i32 to i64
func.return %278 : i64
^bb88:
cf.br ^bb89
^bb89:
%279 = func.call @mul_nonneg(%269, %arg2) : (i64, i64) -> i64
%280 = llvm.mlir.constant(1 : i64) : i64
%281 = llvm.alloca %280 x i64 : (i64) -> !llvm.ptr
llvm.store %279, %281 : i64, !llvm.ptr
%282 = llvm.load %281 : !llvm.ptr -> i64
%283 = arith.constant 0 : i32
%285 = arith.extsi %283 : i32 to i64
%284 = arith.cmpi slt, %282, %285 : i64
cf.cond_br %284, ^bb90, ^bb91
^bb90:
%286 = arith.constant 1 : i32
%288 = arith.constant 0 : i32
%287 = arith.subi %288, %286 : i32
%289 = arith.extsi %287 : i32 to i64
func.return %289 : i64
^bb91:
cf.br ^bb92
^bb92:
%290 = arith.constant 9223372032559808511 : i32
%291 = arith.extsi %290 : i32 to i64
%292 = llvm.load %281 : !llvm.ptr -> i64
%293 = arith.subi %291, %292 : i64
%294 = arith.cmpi sgt, %arg2, %293 : i64
cf.cond_br %294, ^bb93, ^bb94
^bb93:
%295 = arith.constant 1 : i32
%297 = arith.constant 0 : i32
%296 = arith.subi %297, %295 : i32
%298 = arith.extsi %296 : i32 to i64
func.return %298 : i64
^bb94:
cf.br ^bb95
^bb95:
%299 = llvm.load %281 : !llvm.ptr -> i64
%300 = arith.addi %299, %arg2 : i64
llvm.store %300, %281 : i64, !llvm.ptr
%302 = arith.constant 4 : i32
%303 = arith.extsi %302 : i32 to i64
%301 = func.call @mul_nonneg(%303, %arg0) : (i64, i64) -> i64
%304 = arith.constant 0 : i32
%306 = arith.extsi %304 : i32 to i64
%305 = arith.cmpi slt, %301, %306 : i64
cf.cond_br %305, ^bb96, ^bb97
^bb96:
%307 = arith.constant 1 : i32
%309 = arith.constant 0 : i32
%308 = arith.subi %309, %307 : i32
%310 = arith.extsi %308 : i32 to i64
func.return %310 : i64
^bb97:
cf.br ^bb98
^bb98:
%311 = func.call @mul_nonneg(%301, %259) : (i64, i64) -> i64
%312 = arith.constant 0 : i32
%314 = arith.extsi %312 : i32 to i64
%313 = arith.cmpi slt, %311, %314 : i64
cf.cond_br %313, ^bb99, ^bb100
^bb99:
%315 = arith.constant 1 : i32
%317 = arith.constant 0 : i32
%316 = arith.subi %317, %315 : i32
%318 = arith.extsi %316 : i32 to i64
func.return %318 : i64
^bb100:
cf.br ^bb101
^bb101:
%319 = llvm.load %281 : !llvm.ptr -> i64
%320 = arith.cmpi sgt, %311, %319 : i64
cf.cond_br %320, ^bb102, ^bb103
^bb102:
%321 = arith.constant 1 : i32
%323 = arith.constant 0 : i32
%322 = arith.subi %323, %321 : i32
%324 = arith.extsi %322 : i32 to i64
func.return %324 : i64
^bb103:
cf.br ^bb104
^bb104:
%325 = llvm.load %281 : !llvm.ptr -> i64
%326 = arith.subi %325, %311 : i64
llvm.store %326, %281 : i64, !llvm.ptr
%328 = arith.constant 16 : i32
%329 = arith.extsi %328 : i32 to i64
%327 = func.call @mul_nonneg(%329, %arg0) : (i64, i64) -> i64
%330 = arith.constant 0 : i32
%332 = arith.extsi %330 : i32 to i64
%331 = arith.cmpi slt, %327, %332 : i64
cf.cond_br %331, ^bb105, ^bb106
^bb105:
%333 = arith.constant 1 : i32
%335 = arith.constant 0 : i32
%334 = arith.subi %335, %333 : i32
%336 = arith.extsi %334 : i32 to i64
func.return %336 : i64
^bb106:
cf.br ^bb107
^bb107:
%337 = func.call @mul_nonneg(%327, %259) : (i64, i64) -> i64
%338 = arith.constant 0 : i32
%340 = arith.extsi %338 : i32 to i64
%339 = arith.cmpi slt, %337, %340 : i64
cf.cond_br %339, ^bb108, ^bb109
^bb108:
%341 = arith.constant 1 : i32
%343 = arith.constant 0 : i32
%342 = arith.subi %343, %341 : i32
%344 = arith.extsi %342 : i32 to i64
func.return %344 : i64
^bb109:
cf.br ^bb110
^bb110:
%345 = func.call @mul_nonneg(%337, %261) : (i64, i64) -> i64
%346 = arith.constant 0 : i32
%348 = arith.extsi %346 : i32 to i64
%347 = arith.cmpi slt, %345, %348 : i64
cf.cond_br %347, ^bb111, ^bb112
^bb111:
%349 = arith.constant 1 : i32
%351 = arith.constant 0 : i32
%350 = arith.subi %351, %349 : i32
%352 = arith.extsi %350 : i32 to i64
func.return %352 : i64
^bb112:
cf.br ^bb113
^bb113:
%353 = llvm.load %281 : !llvm.ptr -> i64
%354 = arith.cmpi sgt, %345, %353 : i64
cf.cond_br %354, ^bb114, ^bb115
^bb114:
%355 = arith.constant 1 : i32
%357 = arith.constant 0 : i32
%356 = arith.subi %357, %355 : i32
%358 = arith.extsi %356 : i32 to i64
func.return %358 : i64
^bb115:
cf.br ^bb116
^bb116:
%359 = llvm.load %281 : !llvm.ptr -> i64
%360 = arith.subi %359, %345 : i64
llvm.store %360, %281 : i64, !llvm.ptr
%361 = llvm.load %281 : !llvm.ptr -> i64
%362 = arith.constant 1 : i32
%364 = arith.extsi %362 : i32 to i64
%363 = arith.cmpi slt, %361, %364 : i64
%365 = scf.if %363 -> (i1) {
%366 = arith.constant true
scf.yield %366 : i1
} else {
%367 = llvm.load %281 : !llvm.ptr -> i64
%368 = arith.cmpi sgt, %367, %arg3 : i64
scf.yield %368 : i1
}
cf.cond_br %365, ^bb117, ^bb118
^bb117:
%369 = arith.constant 1 : i32
%371 = arith.constant 0 : i32
%370 = arith.subi %371, %369 : i32
%372 = arith.extsi %370 : i32 to i64
func.return %372 : i64
^bb118:
cf.br ^bb119
^bb119:
%373 = llvm.load %281 : !llvm.ptr -> i64
func.return %373 : i64
}
func.func @q_new_val(%arg0: i64, %arg1: i64, %arg2: i64) -> i64 {
%374 = arith.muli %arg0, %arg0 : i64
%375 = arith.constant 8 : i32
%377 = arith.extsi %375 : i32 to i64
%376 = arith.muli %377, %374 : i64
%378 = arith.constant 1 : i32
%380 = arith.extsi %378 : i32 to i64
%379 = arith.addi %376, %380 : i64
%381 = arith.muli %379, %arg1 : i64
%382 = arith.constant 4 : i32
%384 = arith.extsi %382 : i32 to i64
%383 = arith.muli %384, %arg0 : i64
%385 = arith.muli %383, %arg2 : i64
%386 = arith.addi %381, %385 : i64
func.return %386 : i64
}
func.func @main() -> i32 {
%387 = arith.constant 5705032704 : i32
%388 = arith.extsi %387 : i32 to i64
%389 = func.call @p_bound(%388) : (i64) -> i64
%390 = arith.constant 100000 : i32
%391 = arith.extsi %390 : i32 to i64
%393 = arith.constant 8 : i32
%394 = arith.extsi %393 : i32 to i64
%392 = func.call @calloc(%391, %394) : (i64, i64) -> !llvm.ptr
%396 = arith.constant 8 : i32
%397 = arith.extsi %396 : i32 to i64
%395 = func.call @calloc(%391, %397) : (i64, i64) -> !llvm.ptr
%399 = arith.constant 8 : i32
%400 = arith.extsi %399 : i32 to i64
%398 = func.call @calloc(%391, %400) : (i64, i64) -> !llvm.ptr
%401 = llvm.mlir.zero : !llvm.ptr
%402 = llvm.icmp "eq" %392, %401 : !llvm.ptr
%403 = scf.if %402 -> (i1) {
%404 = arith.constant true
scf.yield %404 : i1
} else {
%405 = llvm.mlir.zero : !llvm.ptr
%406 = llvm.icmp "eq" %395, %405 : !llvm.ptr
scf.yield %406 : i1
}
%407 = scf.if %403 -> (i1) {
%408 = arith.constant true
scf.yield %408 : i1
} else {
%409 = llvm.mlir.zero : !llvm.ptr
%410 = llvm.icmp "eq" %398, %409 : !llvm.ptr
scf.yield %410 : i1
}
cf.cond_br %407, ^bb120, ^bb121
^bb120:
%411 = arith.constant 1 : i32
func.return %411 : i32
^bb121:
cf.br ^bb122
^bb122:
%412 = arith.constant 0 : i32
%413 = arith.extsi %412 : i32 to i64
%414 = llvm.mlir.constant(1 : i64) : i64
%415 = llvm.alloca %414 x i64 : (i64) -> !llvm.ptr
llvm.store %413, %415 : i64, !llvm.ptr
%416 = arith.constant 1 : i32
%417 = arith.extsi %416 : i32 to i64
%418 = llvm.mlir.constant(1 : i64) : i64
%419 = llvm.alloca %418 x i64 : (i64) -> !llvm.ptr
llvm.store %417, %419 : i64, !llvm.ptr
cf.br ^bb123
^bb123:
%420 = llvm.load %419 : !llvm.ptr -> i64
%421 = arith.cmpi sle, %420, %389 : i64
cf.cond_br %421, ^bb124, ^bb125
^bb124:
%422 = llvm.load %419 : !llvm.ptr -> i64
%423 = llvm.load %415 : !llvm.ptr -> i64
%424 = llvm.getelementptr %392[%423] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %422, %424 : i64, !llvm.ptr
%425 = arith.constant 0 : i32
%426 = llvm.load %415 : !llvm.ptr -> i64
%427 = arith.extsi %425 : i32 to i64
%428 = llvm.getelementptr %395[%426] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %427, %428 : i64, !llvm.ptr
%429 = llvm.load %419 : !llvm.ptr -> i64
%430 = llvm.load %415 : !llvm.ptr -> i64
%431 = llvm.getelementptr %398[%430] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %429, %431 : i64, !llvm.ptr
%432 = llvm.load %415 : !llvm.ptr -> i64
%433 = arith.constant 1 : i32
%435 = arith.extsi %433 : i32 to i64
%434 = arith.addi %432, %435 : i64
llvm.store %434, %415 : i64, !llvm.ptr
%436 = llvm.load %419 : !llvm.ptr -> i64
%437 = arith.constant 1 : i32
%439 = arith.extsi %437 : i32 to i64
%438 = arith.addi %436, %439 : i64
llvm.store %438, %419 : i64, !llvm.ptr
cf.br ^bb123
^bb125:
%440 = arith.constant 0 : i32
%441 = arith.extsi %440 : i32 to i64
%442 = llvm.mlir.constant(1 : i64) : i64
%443 = llvm.alloca %442 x i64 : (i64) -> !llvm.ptr
llvm.store %441, %443 : i64, !llvm.ptr
cf.br ^bb126
^bb126:
%444 = llvm.load %415 : !llvm.ptr -> i64
%445 = arith.constant 0 : i32
%447 = arith.extsi %445 : i32 to i64
%446 = arith.cmpi sgt, %444, %447 : i64
cf.cond_br %446, ^bb127, ^bb128
^bb127:
%448 = llvm.load %415 : !llvm.ptr -> i64
%449 = arith.constant 1 : i32
%451 = arith.extsi %449 : i32 to i64
%450 = arith.subi %448, %451 : i64
llvm.store %450, %415 : i64, !llvm.ptr
%453 = llvm.load %415 : !llvm.ptr -> i64
%454 = llvm.getelementptr %392[%453] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%452 = llvm.load %454 : !llvm.ptr -> i64
%455 = llvm.mlir.constant(1 : i64) : i64
%456 = llvm.alloca %455 x i64 : (i64) -> !llvm.ptr
llvm.store %452, %456 : i64, !llvm.ptr
%458 = llvm.load %415 : !llvm.ptr -> i64
%459 = llvm.getelementptr %395[%458] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%457 = llvm.load %459 : !llvm.ptr -> i64
%460 = llvm.mlir.constant(1 : i64) : i64
%461 = llvm.alloca %460 x i64 : (i64) -> !llvm.ptr
llvm.store %457, %461 : i64, !llvm.ptr
%463 = llvm.load %415 : !llvm.ptr -> i64
%464 = llvm.getelementptr %398[%463] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%462 = llvm.load %464 : !llvm.ptr -> i64
%465 = llvm.load %456 : !llvm.ptr -> i64
%466 = arith.constant 0 : i32
%468 = arith.extsi %466 : i32 to i64
%467 = arith.cmpi slt, %465, %468 : i64
cf.cond_br %467, ^bb129, ^bb130
^bb129:
%469 = arith.constant 0 : i32
%470 = llvm.load %456 : !llvm.ptr -> i64
%472 = arith.extsi %469 : i32 to i64
%471 = arith.subi %472, %470 : i64
llvm.store %471, %456 : i64, !llvm.ptr
%473 = arith.constant 0 : i32
%474 = llvm.load %461 : !llvm.ptr -> i64
%476 = arith.extsi %473 : i32 to i64
%475 = arith.subi %476, %474 : i64
llvm.store %475, %461 : i64, !llvm.ptr
cf.br ^bb131
^bb130:
cf.br ^bb131
^bb131:
%477 = llvm.load %456 : !llvm.ptr -> i64
%478 = arith.constant 0 : i32
%480 = arith.extsi %478 : i32 to i64
%479 = arith.cmpi eq, %477, %480 : i64
cf.cond_br %479, ^bb132, ^bb133
^bb132:
cf.br ^bb126
^bb133:
cf.br ^bb134
^bb134:
%482 = llvm.load %456 : !llvm.ptr -> i64
%483 = llvm.load %461 : !llvm.ptr -> i64
%481 = func.call @area_new(%482, %483, %462, %388) : (i64, i64, i64, i64) -> i64
%484 = arith.constant 0 : i32
%486 = arith.extsi %484 : i32 to i64
%485 = arith.cmpi sgt, %481, %486 : i64
cf.cond_br %485, ^bb135, ^bb136
^bb135:
%487 = arith.constant 8 : i32
%488 = llvm.load %456 : !llvm.ptr -> i64
%490 = arith.extsi %487 : i32 to i64
%489 = arith.muli %490, %488 : i64
%491 = llvm.load %456 : !llvm.ptr -> i64
%492 = arith.muli %489, %491 : i64
%493 = arith.constant 1 : i32
%495 = arith.extsi %493 : i32 to i64
%494 = arith.addi %492, %495 : i64
%496 = llvm.load %461 : !llvm.ptr -> i64
%497 = arith.muli %494, %496 : i64
%498 = arith.constant 4 : i32
%499 = llvm.load %456 : !llvm.ptr -> i64
%501 = arith.extsi %498 : i32 to i64
%500 = arith.muli %501, %499 : i64
%502 = arith.muli %500, %462 : i64
%503 = arith.addi %497, %502 : i64
%504 = llvm.load %443 : !llvm.ptr -> i64
%505 = arith.addi %504, %481 : i64
llvm.store %505, %443 : i64, !llvm.ptr
%506 = llvm.load %415 : !llvm.ptr -> i64
%507 = arith.constant 3 : i32
%509 = arith.extsi %507 : i32 to i64
%508 = arith.addi %506, %509 : i64
%510 = arith.cmpi sgt, %508, %391 : i64
cf.cond_br %510, ^bb138, ^bb139
^bb138:
%511 = llvm.mlir.addressof @str_0 : !llvm.ptr
%512 = llvm.call @printf(%511) vararg(!llvm.func<i32 (ptr, ...)>) : (!llvm.ptr) -> i32
%513 = arith.constant 1 : i32
func.return %513 : i32
^bb139:
cf.br ^bb140
^bb140:
%514 = llvm.load %456 : !llvm.ptr -> i64
%515 = llvm.load %415 : !llvm.ptr -> i64
%516 = llvm.getelementptr %392[%515] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %514, %516 : i64, !llvm.ptr
%517 = llvm.load %415 : !llvm.ptr -> i64
%518 = llvm.getelementptr %395[%517] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %503, %518 : i64, !llvm.ptr
%519 = llvm.load %415 : !llvm.ptr -> i64
%520 = llvm.getelementptr %398[%519] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %481, %520 : i64, !llvm.ptr
%521 = llvm.load %415 : !llvm.ptr -> i64
%522 = arith.constant 1 : i32
%524 = arith.extsi %522 : i32 to i64
%523 = arith.addi %521, %524 : i64
llvm.store %523, %415 : i64, !llvm.ptr
%525 = llvm.load %415 : !llvm.ptr -> i64
%526 = llvm.getelementptr %392[%525] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %503, %526 : i64, !llvm.ptr
%527 = llvm.load %456 : !llvm.ptr -> i64
%528 = llvm.load %415 : !llvm.ptr -> i64
%529 = llvm.getelementptr %395[%528] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %527, %529 : i64, !llvm.ptr
%530 = llvm.load %415 : !llvm.ptr -> i64
%531 = llvm.getelementptr %398[%530] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %481, %531 : i64, !llvm.ptr
%532 = llvm.load %415 : !llvm.ptr -> i64
%533 = arith.constant 1 : i32
%535 = arith.extsi %533 : i32 to i64
%534 = arith.addi %532, %535 : i64
llvm.store %534, %415 : i64, !llvm.ptr
%536 = llvm.load %415 : !llvm.ptr -> i64
%537 = llvm.getelementptr %392[%536] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %503, %537 : i64, !llvm.ptr
%538 = arith.constant 0 : i32
%539 = llvm.load %456 : !llvm.ptr -> i64
%541 = arith.extsi %538 : i32 to i64
%540 = arith.subi %541, %539 : i64
%542 = llvm.load %415 : !llvm.ptr -> i64
%543 = llvm.getelementptr %395[%542] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %540, %543 : i64, !llvm.ptr
%544 = llvm.load %415 : !llvm.ptr -> i64
%545 = llvm.getelementptr %398[%544] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %481, %545 : i64, !llvm.ptr
%546 = llvm.load %415 : !llvm.ptr -> i64
%547 = arith.constant 1 : i32
%549 = arith.extsi %547 : i32 to i64
%548 = arith.addi %546, %549 : i64
llvm.store %548, %415 : i64, !llvm.ptr
cf.br ^bb137
^bb136:
cf.br ^bb137
^bb137:
cf.br ^bb126
^bb128:
%550 = llvm.mlir.addressof @str_1 : !llvm.ptr
%551 = llvm.load %443 : !llvm.ptr -> i64
%552 = llvm.call @printf(%550, %551) vararg(!llvm.func<i32 (ptr, ...)>) : (!llvm.ptr, i64) -> i32
func.call @free(%398) : (!llvm.ptr) -> ()
func.call @free(%395) : (!llvm.ptr) -> ()
func.call @free(%392) : (!llvm.ptr) -> ()
%556 = arith.constant 0 : i32
func.return %556 : i32
}
}