← All problems
Problem 276
Primitive integer triangles with perimeter <= 10^7.
View problem on Project Euler
Performance comparison
Metric Our solution Best known
Time complexity O(n^2)O(n^2)
Space complexity O(n^2)O(n^2)
Approach Flow solution Bottom-up DP
Verdict Optimal
Flow source
# Project Euler 276
# Primitive integer triangles with perimeter <= 10^7.
extern {
function calloc(n: i64, size: i64) -> ptr<void>
function free(p: ptr<void>) -> void
}
function bi_mul_small(L: ptr<i64>, n: i64, f: i64, B: i64) -> void {
let mut carry: i64 = 0
let mut i: i64 = 0
while i < n {
let cur: i64 = L[i] * f + carry
L[i] = cur % B
carry = cur / B
i = i + 1
}
}
function bi_div_small(L: ptr<i64>, n: i64, d: i64, B: i64) -> void {
let mut rem: i64 = 0
let mut i: i64 = n - 1
while i >= 0 {
let cur: i64 = rem * B + L[i]
L[i] = cur / d
rem = cur % d
i = i - 1
}
}
function bi_add_small(L: ptr<i64>, n: i64, v: i64, B: i64) -> void {
let mut cur: i64 = L[0] + v
let mut i: i64 = 0
while true {
if cur >= 0 {
L[i] = cur % B
let carry: i64 = cur / B
if carry == 0 { break }
i = i + 1
if i >= n { break }
cur = L[i] + carry
} else {
# borrow
while cur < 0 {
cur = cur + B
i = i + 1
if i >= n { break }
cur = L[i] - 1
L[i - 1] = 0
}
# simpler path unused for S
break
}
}
}
function bi_to_i64(L: ptr<i64>, n: i64, B: i64) -> i64 {
let mut ans: i64 = 0
let mut i: i64 = n - 1
while i >= 0 {
ans = ans * B + L[i]
i = i - 1
}
return ans
}
# S(m) = sum_{k=1..m} floor((k^2+6)/12) = (sum k^2 + 6m - sum_rem(m)) / 12
function S(m: i64) -> i64 {
if m <= 0 { return 0 }
let B: i64 = 1000000000
let n: i64 = 6
let L: ptr<i64> = calloc(n, 8)
L[0] = 1
bi_mul_small(L, n, m, B)
bi_mul_small(L, n, m + 1, B)
bi_mul_small(L, n, 2 * m + 1, B)
bi_div_small(L, n, 6, B)
# + 6m
let mut addv: i64 = 6 * m
let mut carry: i64 = L[0] + addv
L[0] = carry % B
carry = carry / B
let mut i: i64 = 1
while carry != 0 && i < n {
carry = L[i] + carry
L[i] = carry % B
carry = carry / B
i = i + 1
}
# - sum_rem(m)
let q: i64 = m / 6
let r: i64 = m % 6
let mut pref: i64 = 0
if r == 1 { pref = 7 }
elif r == 2 { pref = 17 }
elif r == 3 { pref = 20 }
elif r == 4 { pref = 30 }
elif r == 5 { pref = 37 }
elif r == 6 { pref = 43 }
let rem_sum: i64 = q * 43 + pref
L[0] = L[0] - rem_sum
i = 0
while i < n - 1 {
while L[i] < 0 {
L[i] = L[i] + B
L[i + 1] = L[i + 1] - 1
}
if L[i] >= B {
L[i + 1] = L[i + 1] + L[i] / B
L[i] = L[i] % B
}
i = i + 1
}
bi_div_small(L, n, 12, B)
let ans: i64 = bi_to_i64(L, n, B)
free(L)
return ans
}
function triangles_upto(n: i64) -> i64 {
return S(n / 2) + S((n + 1) / 2 + 1)
}
function main() -> i32 {
let n: i64 = 10000000
let mu: ptr<i32> = calloc(n + 1, 4)
let M: ptr<i32> = calloc(n + 1, 4)
let is_comp: ptr<i8> = calloc(n + 1, 1)
let primes: ptr<i64> = calloc(700000, 8)
if mu == null || M == null || is_comp == null || primes == null { return 1 }
mu[1] = 1
let mut pc: i64 = 0
let mut i: i64 = 2
while i <= n {
if is_comp[i] == 0 {
primes[pc] = i
pc = pc + 1
mu[i] = -1
}
let mi: i32 = mu[i]
let mut j: i64 = 0
while j < pc {
let p: i64 = primes[j]
if p > n / i { break }
let ip: i64 = i * p
is_comp[ip] = 1
if i % p == 0 {
mu[ip] = 0
break
}
mu[ip] = 0 - mi
j = j + 1
}
i = i + 1
}
let mut s: i32 = 0
i = 1
while i <= n {
s = s + mu[i]
M[i] = s
i = i + 1
}
# P(n) = sum_d mu(d) A(n/d) via Dirichlet blocks:
# need bigint for (M[r]-M[l-1]) * A(q) since product may exceed i64.
let B: i64 = 1000000000
let LN: i64 = 8
let mag: ptr<i64> = calloc(LN, 8)
let mut sign: i32 = 1
let mut l: i64 = 1
while l <= n {
let qv: i64 = n / l
let r: i64 = n / qv
let delta: i64 = (M[r] as i64) - (M[l - 1] as i64)
let a: i64 = triangles_upto(qv)
if delta != 0 && a != 0 {
# term = delta * a, may need wide mul
let mut term_sign: i32 = 1
let mut da: i64 = delta
if da < 0 {
da = -da
term_sign = -1
}
# compute da * a into tmp limbs
let tmp: ptr<i64> = calloc(LN, 8)
tmp[0] = a
# normalize a into limbs
let mut k: i64 = 0
while k < LN - 1 {
if tmp[k] >= B {
tmp[k + 1] = tmp[k + 1] + tmp[k] / B
tmp[k] = tmp[k] % B
}
k = k + 1
}
bi_mul_small(tmp, LN, da, B)
# add/sub tmp into mag with sign
if sign == term_sign {
k = 0
let mut carry: i64 = 0
while k < LN {
let cur: i64 = mag[k] + tmp[k] + carry
mag[k] = cur % B
carry = cur / B
k = k + 1
}
} else {
# compare mag vs tmp
let mut cmp: i32 = 0
k = LN - 1
while k >= 0 {
if mag[k] < tmp[k] { cmp = -1; break }
if mag[k] > tmp[k] { cmp = 1; break }
k = k - 1
}
if cmp == 0 {
k = 0
while k < LN { mag[k] = 0; k = k + 1 }
sign = 1
} elif cmp > 0 {
k = 0
while k < LN {
mag[k] = mag[k] - tmp[k]
k = k + 1
}
k = 0
while k < LN - 1 {
while mag[k] < 0 {
mag[k] = mag[k] + B
mag[k + 1] = mag[k + 1] - 1
}
k = k + 1
}
} else {
k = 0
while k < LN {
tmp[k] = tmp[k] - mag[k]
k = k + 1
}
k = 0
while k < LN - 1 {
while tmp[k] < 0 {
tmp[k] = tmp[k] + B
tmp[k + 1] = tmp[k + 1] - 1
}
k = k + 1
}
k = 0
while k < LN {
mag[k] = tmp[k]
k = k + 1
}
sign = term_sign
}
}
free(tmp)
}
l = r + 1
}
let mut ans: i64 = bi_to_i64(mag, LN, B)
if sign < 0 { ans = -ans }
printf("%lld\n", ans)
free(mu); free(M); free(is_comp); free(primes); free(mag)
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; }
void bi_mul_small_ptr_i64_i64_i64_i64(int64_t* L, int64_t n, int64_t f, int64_t B);
void bi_div_small_ptr_i64_i64_i64_i64(int64_t* L, int64_t n, int64_t d, int64_t B);
void bi_add_small_ptr_i64_i64_i64_i64(int64_t* L, int64_t n, int64_t v, int64_t B);
int64_t bi_to_i64_ptr_i64_i64_i64(int64_t* L, int64_t n, int64_t B);
int64_t S_i64(int64_t m);
int64_t triangles_upto_i64(int64_t n);
int32_t main(void);
void bi_mul_small_ptr_i64_i64_i64_i64(int64_t* L, int64_t n, int64_t f, int64_t B) {
int64_t carry = 0;
int64_t i = 0;
while (i < n) {
int64_t cur = ((L[i] * f) + carry);
L[i] = FLOW_CHECKED_MOD((cur), (B));
carry = FLOW_CHECKED_DIV((cur), (B));
i = (i + 1);
}
}
void bi_div_small_ptr_i64_i64_i64_i64(int64_t* L, int64_t n, int64_t d, int64_t B) {
int64_t rem = 0;
int64_t i = (n - 1);
while (i >= 0) {
int64_t cur = ((rem * B) + L[i]);
L[i] = FLOW_CHECKED_DIV((cur), (d));
rem = FLOW_CHECKED_MOD((cur), (d));
i = (i - 1);
}
}
void bi_add_small_ptr_i64_i64_i64_i64(int64_t* L, int64_t n, int64_t v, int64_t B) {
int64_t cur = (L[0] + v);
int64_t i = 0;
while (1) {
if (cur >= 0) {
L[i] = FLOW_CHECKED_MOD((cur), (B));
int64_t carry = FLOW_CHECKED_DIV((cur), (B));
if (carry == 0) {
break;
}
i = (i + 1);
if (i >= n) {
break;
}
cur = (L[i] + carry);
} else {
while (cur < 0) {
cur = (cur + B);
i = (i + 1);
if (i >= n) {
break;
}
cur = (L[i] - 1);
L[(i - 1)] = 0;
}
break;
}
}
}
int64_t bi_to_i64_ptr_i64_i64_i64(int64_t* L, int64_t n, int64_t B) {
int64_t ans = 0;
int64_t i = (n - 1);
while (i >= 0) {
ans = ((ans * B) + L[i]);
i = (i - 1);
}
return ans;
}
int64_t S_i64(int64_t m) {
if (m <= 0) {
return 0;
}
int64_t B = 1000000000;
int64_t n = 6;
int64_t* L = (int64_t*)(calloc(n, 8));
L[0] = 1;
bi_mul_small_ptr_i64_i64_i64_i64(L, n, m, B);
bi_mul_small_ptr_i64_i64_i64_i64(L, n, (m + 1), B);
bi_mul_small_ptr_i64_i64_i64_i64(L, n, ((2 * m) + 1), B);
bi_div_small_ptr_i64_i64_i64_i64(L, n, 6, B);
int64_t addv = (6 * m);
int64_t carry = (L[0] + addv);
L[0] = FLOW_CHECKED_MOD((carry), (B));
carry = FLOW_CHECKED_DIV((carry), (B));
int64_t i = 1;
while ((carry != 0 && i < n)) {
carry = (L[i] + carry);
L[i] = FLOW_CHECKED_MOD((carry), (B));
carry = FLOW_CHECKED_DIV((carry), (B));
i = (i + 1);
}
int64_t q = FLOW_CHECKED_DIV((m), (6));
int64_t r = FLOW_CHECKED_MOD((m), (6));
int64_t pref = 0;
if (r == 1) {
pref = 7;
} else if (r == 2) {
pref = 17;
} else if (r == 3) {
pref = 20;
} else if (r == 4) {
pref = 30;
} else if (r == 5) {
pref = 37;
} else if (r == 6) {
pref = 43;
}
int64_t rem_sum = ((q * 43) + pref);
L[0] = (L[0] - rem_sum);
i = 0;
while (i < (n - 1)) {
while (L[i] < 0) {
L[i] = (L[i] + B);
L[(i + 1)] = (L[(i + 1)] - 1);
}
if (L[i] >= B) {
L[(i + 1)] = (L[(i + 1)] + FLOW_CHECKED_DIV((L[i]), (B)));
L[i] = FLOW_CHECKED_MOD((L[i]), (B));
}
i = (i + 1);
}
bi_div_small_ptr_i64_i64_i64_i64(L, n, 12, B);
int64_t ans = bi_to_i64_ptr_i64_i64_i64(L, n, B);
free(L);
return ans;
}
int64_t triangles_upto_i64(int64_t n) {
return (S_i64(FLOW_CHECKED_DIV((n), (2))) + S_i64((FLOW_CHECKED_DIV(((n + 1)), (2)) + 1)));
}
int32_t main(void) {
int64_t n = 10000000;
int32_t* mu = (int32_t*)(calloc((n + 1), 4));
int32_t* M = (int32_t*)(calloc((n + 1), 4));
int8_t* is_comp = (int8_t*)(calloc((n + 1), 1));
int64_t* primes = (int64_t*)(calloc(700000, 8));
if ((((mu == NULL || M == NULL) || is_comp == NULL) || primes == NULL)) {
return 1;
}
mu[1] = 1;
int64_t pc = 0;
int64_t i = 2;
while (i <= n) {
if (is_comp[i] == 0) {
primes[pc] = i;
pc = (pc + 1);
mu[i] = (-1);
}
int32_t mi = mu[i];
int64_t j = 0;
while (j < pc) {
int64_t p = primes[j];
if (p > FLOW_CHECKED_DIV((n), (i))) {
break;
}
int64_t ip = (i * p);
is_comp[ip] = 1;
if (FLOW_CHECKED_MOD((i), (p)) == 0) {
mu[ip] = 0;
break;
}
mu[ip] = (0 - mi);
j = (j + 1);
}
i = (i + 1);
}
int32_t s = 0;
i = 1;
while (i <= n) {
s = (s + mu[i]);
M[i] = s;
i = (i + 1);
}
int64_t B = 1000000000;
int64_t LN = 8;
int64_t* mag = (int64_t*)(calloc(LN, 8));
int32_t sign = 1;
int64_t l = 1;
while (l <= n) {
int64_t qv = FLOW_CHECKED_DIV((n), (l));
int64_t r = FLOW_CHECKED_DIV((n), (qv));
int64_t delta = (((int64_t)(M[r])) - ((int64_t)(M[(l - 1)])));
int64_t a = triangles_upto_i64(qv);
if ((delta != 0 && a != 0)) {
int32_t term_sign = 1;
int64_t da = delta;
if (da < 0) {
da = (-da);
term_sign = (-1);
}
int64_t* tmp = (int64_t*)(calloc(LN, 8));
tmp[0] = a;
int64_t k = 0;
while (k < (LN - 1)) {
if (tmp[k] >= B) {
tmp[(k + 1)] = (tmp[(k + 1)] + FLOW_CHECKED_DIV((tmp[k]), (B)));
tmp[k] = FLOW_CHECKED_MOD((tmp[k]), (B));
}
k = (k + 1);
}
bi_mul_small_ptr_i64_i64_i64_i64(tmp, LN, da, B);
if (sign == term_sign) {
k = 0;
int64_t carry = 0;
while (k < LN) {
int64_t cur = ((mag[k] + tmp[k]) + carry);
mag[k] = FLOW_CHECKED_MOD((cur), (B));
carry = FLOW_CHECKED_DIV((cur), (B));
k = (k + 1);
}
} else {
int32_t cmp = 0;
k = (LN - 1);
while (k >= 0) {
if (mag[k] < tmp[k]) {
cmp = (-1);
break;
}
if (mag[k] > tmp[k]) {
cmp = 1;
break;
}
k = (k - 1);
}
if (cmp == 0) {
k = 0;
while (k < LN) {
mag[k] = 0;
k = (k + 1);
}
sign = 1;
} else if (cmp > 0) {
k = 0;
while (k < LN) {
mag[k] = (mag[k] - tmp[k]);
k = (k + 1);
}
k = 0;
while (k < (LN - 1)) {
while (mag[k] < 0) {
mag[k] = (mag[k] + B);
mag[(k + 1)] = (mag[(k + 1)] - 1);
}
k = (k + 1);
}
} else {
k = 0;
while (k < LN) {
tmp[k] = (tmp[k] - mag[k]);
k = (k + 1);
}
k = 0;
while (k < (LN - 1)) {
while (tmp[k] < 0) {
tmp[k] = (tmp[k] + B);
tmp[(k + 1)] = (tmp[(k + 1)] - 1);
}
k = (k + 1);
}
k = 0;
while (k < LN) {
mag[k] = tmp[k];
k = (k + 1);
}
sign = term_sign;
}
}
free(tmp);
}
l = (r + 1);
}
int64_t ans = bi_to_i64_ptr_i64_i64_i64(mag, LN, B);
if (sign < 0) {
ans = (-ans);
}
printf("%lld\n", ans);
free(mu);
free(M);
free(is_comp);
free(primes);
free(mag);
return 0;
}
Generated MLIR
module {
llvm.func @printf(!llvm.ptr, ...) -> i32
llvm.mlir.global internal constant @str_0("%lld\n\00") {addr_space = 0 : i32} : !llvm.array<6 x i8>
func.func private @calloc(i64, i64) -> !llvm.ptr
func.func private @free(!llvm.ptr) -> ()
func.func @bi_mul_small(%arg0: !llvm.ptr, %arg1: i64, %arg2: i64, %arg3: 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 0 : 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 = llvm.load %7 : !llvm.ptr -> i64
%9 = arith.cmpi slt, %8, %arg1 : i64
cf.cond_br %9, ^bb1, ^bb2
^bb1:
%11 = llvm.load %7 : !llvm.ptr -> i64
%12 = llvm.getelementptr %arg0[%11] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%10 = llvm.load %12 : !llvm.ptr -> i64
%13 = arith.muli %10, %arg2 : i64
%14 = llvm.load %3 : !llvm.ptr -> i64
%15 = arith.addi %13, %14 : i64
%16 = arith.remsi %15, %arg3 : i64
%17 = llvm.load %7 : !llvm.ptr -> i64
%18 = llvm.getelementptr %arg0[%17] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %16, %18 : i64, !llvm.ptr
%19 = arith.divsi %15, %arg3 : i64
llvm.store %19, %3 : i64, !llvm.ptr
%20 = llvm.load %7 : !llvm.ptr -> i64
%21 = arith.constant 1 : i32
%23 = arith.extsi %21 : i32 to i64
%22 = arith.addi %20, %23 : i64
llvm.store %22, %7 : i64, !llvm.ptr
cf.br ^bb0
^bb2:
func.return
}
func.func @bi_div_small(%arg0: !llvm.ptr, %arg1: i64, %arg2: i64, %arg3: i64) -> () {
%24 = arith.constant 0 : i32
%25 = arith.extsi %24 : i32 to i64
%26 = llvm.mlir.constant(1 : i64) : i64
%27 = llvm.alloca %26 x i64 : (i64) -> !llvm.ptr
llvm.store %25, %27 : i64, !llvm.ptr
%28 = arith.constant 1 : i32
%30 = arith.extsi %28 : i32 to i64
%29 = arith.subi %arg1, %30 : i64
%31 = llvm.mlir.constant(1 : i64) : i64
%32 = llvm.alloca %31 x i64 : (i64) -> !llvm.ptr
llvm.store %29, %32 : i64, !llvm.ptr
cf.br ^bb3
^bb3:
%33 = llvm.load %32 : !llvm.ptr -> i64
%34 = arith.constant 0 : i32
%36 = arith.extsi %34 : i32 to i64
%35 = arith.cmpi sge, %33, %36 : i64
cf.cond_br %35, ^bb4, ^bb5
^bb4:
%37 = llvm.load %27 : !llvm.ptr -> i64
%38 = arith.muli %37, %arg3 : i64
%40 = llvm.load %32 : !llvm.ptr -> i64
%41 = llvm.getelementptr %arg0[%40] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%39 = llvm.load %41 : !llvm.ptr -> i64
%42 = arith.addi %38, %39 : i64
%43 = arith.divsi %42, %arg2 : i64
%44 = llvm.load %32 : !llvm.ptr -> i64
%45 = llvm.getelementptr %arg0[%44] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %43, %45 : i64, !llvm.ptr
%46 = arith.remsi %42, %arg2 : i64
llvm.store %46, %27 : i64, !llvm.ptr
%47 = llvm.load %32 : !llvm.ptr -> i64
%48 = arith.constant 1 : i32
%50 = arith.extsi %48 : i32 to i64
%49 = arith.subi %47, %50 : i64
llvm.store %49, %32 : i64, !llvm.ptr
cf.br ^bb3
^bb5:
func.return
}
func.func @bi_add_small(%arg0: !llvm.ptr, %arg1: i64, %arg2: i64, %arg3: i64) -> () {
%52 = arith.constant 0 : i32
%53 = arith.extsi %52 : i32 to i64
%54 = llvm.getelementptr %arg0[%53] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%51 = llvm.load %54 : !llvm.ptr -> i64
%55 = arith.addi %51, %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 ^bb6
^bb6:
%62 = arith.constant 1 : i1
cf.cond_br %62, ^bb7, ^bb8
^bb7:
%63 = llvm.load %57 : !llvm.ptr -> i64
%64 = arith.constant 0 : i32
%66 = arith.extsi %64 : i32 to i64
%65 = arith.cmpi sge, %63, %66 : i64
cf.cond_br %65, ^bb9, ^bb10
^bb9:
%67 = llvm.load %57 : !llvm.ptr -> i64
%68 = arith.remsi %67, %arg3 : i64
%69 = llvm.load %61 : !llvm.ptr -> i64
%70 = llvm.getelementptr %arg0[%69] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %68, %70 : i64, !llvm.ptr
%71 = llvm.load %57 : !llvm.ptr -> i64
%72 = arith.divsi %71, %arg3 : i64
%73 = arith.constant 0 : i32
%75 = arith.extsi %73 : i32 to i64
%74 = arith.cmpi eq, %72, %75 : i64
cf.cond_br %74, ^bb12, ^bb13
^bb12:
cf.br ^bb8
^bb13:
cf.br ^bb14
^bb14:
%76 = llvm.load %61 : !llvm.ptr -> i64
%77 = arith.constant 1 : i32
%79 = arith.extsi %77 : i32 to i64
%78 = arith.addi %76, %79 : i64
llvm.store %78, %61 : i64, !llvm.ptr
%80 = llvm.load %61 : !llvm.ptr -> i64
%81 = arith.cmpi sge, %80, %arg1 : i64
cf.cond_br %81, ^bb15, ^bb16
^bb15:
cf.br ^bb8
^bb16:
cf.br ^bb17
^bb17:
%83 = llvm.load %61 : !llvm.ptr -> i64
%84 = llvm.getelementptr %arg0[%83] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%82 = llvm.load %84 : !llvm.ptr -> i64
%85 = arith.addi %82, %72 : i64
llvm.store %85, %57 : i64, !llvm.ptr
cf.br ^bb11
^bb10:
cf.br ^bb18
^bb18:
%86 = llvm.load %57 : !llvm.ptr -> i64
%87 = arith.constant 0 : i32
%89 = arith.extsi %87 : i32 to i64
%88 = arith.cmpi slt, %86, %89 : i64
cf.cond_br %88, ^bb19, ^bb20
^bb19:
%90 = llvm.load %57 : !llvm.ptr -> i64
%91 = arith.addi %90, %arg3 : i64
llvm.store %91, %57 : i64, !llvm.ptr
%92 = llvm.load %61 : !llvm.ptr -> i64
%93 = arith.constant 1 : i32
%95 = arith.extsi %93 : i32 to i64
%94 = arith.addi %92, %95 : i64
llvm.store %94, %61 : i64, !llvm.ptr
%96 = llvm.load %61 : !llvm.ptr -> i64
%97 = arith.cmpi sge, %96, %arg1 : i64
cf.cond_br %97, ^bb21, ^bb22
^bb21:
cf.br ^bb20
^bb22:
cf.br ^bb23
^bb23:
%99 = llvm.load %61 : !llvm.ptr -> i64
%100 = llvm.getelementptr %arg0[%99] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%98 = llvm.load %100 : !llvm.ptr -> i64
%101 = arith.constant 1 : i32
%103 = arith.extsi %101 : i32 to i64
%102 = arith.subi %98, %103 : i64
llvm.store %102, %57 : i64, !llvm.ptr
%104 = arith.constant 0 : i32
%105 = llvm.load %61 : !llvm.ptr -> i64
%106 = arith.constant 1 : i32
%108 = arith.extsi %106 : i32 to i64
%107 = arith.subi %105, %108 : i64
%109 = arith.extsi %104 : i32 to i64
%110 = llvm.getelementptr %arg0[%107] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %109, %110 : i64, !llvm.ptr
cf.br ^bb18
^bb20:
cf.br ^bb8
^bb11:
cf.br ^bb6
^bb8:
func.return
}
func.func @bi_to_i64(%arg0: !llvm.ptr, %arg1: i64, %arg2: i64) -> i64 {
%111 = arith.constant 0 : i32
%112 = arith.extsi %111 : i32 to i64
%113 = llvm.mlir.constant(1 : i64) : i64
%114 = llvm.alloca %113 x i64 : (i64) -> !llvm.ptr
llvm.store %112, %114 : i64, !llvm.ptr
%115 = arith.constant 1 : i32
%117 = arith.extsi %115 : i32 to i64
%116 = arith.subi %arg1, %117 : i64
%118 = llvm.mlir.constant(1 : i64) : i64
%119 = llvm.alloca %118 x i64 : (i64) -> !llvm.ptr
llvm.store %116, %119 : i64, !llvm.ptr
cf.br ^bb24
^bb24:
%120 = llvm.load %119 : !llvm.ptr -> i64
%121 = arith.constant 0 : i32
%123 = arith.extsi %121 : i32 to i64
%122 = arith.cmpi sge, %120, %123 : i64
cf.cond_br %122, ^bb25, ^bb26
^bb25:
%124 = llvm.load %114 : !llvm.ptr -> i64
%125 = arith.muli %124, %arg2 : i64
%127 = llvm.load %119 : !llvm.ptr -> i64
%128 = llvm.getelementptr %arg0[%127] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%126 = llvm.load %128 : !llvm.ptr -> i64
%129 = arith.addi %125, %126 : i64
llvm.store %129, %114 : i64, !llvm.ptr
%130 = llvm.load %119 : !llvm.ptr -> i64
%131 = arith.constant 1 : i32
%133 = arith.extsi %131 : i32 to i64
%132 = arith.subi %130, %133 : i64
llvm.store %132, %119 : i64, !llvm.ptr
cf.br ^bb24
^bb26:
%134 = llvm.load %114 : !llvm.ptr -> i64
func.return %134 : i64
}
func.func @S(%arg0: i64) -> i64 {
%135 = arith.constant 0 : i32
%137 = arith.extsi %135 : i32 to i64
%136 = arith.cmpi sle, %arg0, %137 : i64
cf.cond_br %136, ^bb27, ^bb28
^bb27:
%138 = arith.constant 0 : i32
%139 = arith.extsi %138 : i32 to i64
func.return %139 : i64
^bb28:
cf.br ^bb29
^bb29:
%140 = arith.constant 1000000000 : i32
%141 = arith.extsi %140 : i32 to i64
%142 = arith.constant 6 : i32
%143 = arith.extsi %142 : i32 to i64
%145 = arith.constant 8 : i32
%146 = arith.extsi %145 : i32 to i64
%144 = func.call @calloc(%143, %146) : (i64, i64) -> !llvm.ptr
%147 = arith.constant 1 : i32
%148 = arith.constant 0 : i32
%149 = arith.extsi %147 : i32 to i64
%150 = arith.extsi %148 : i32 to i64
%151 = llvm.getelementptr %144[%150] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %149, %151 : i64, !llvm.ptr
func.call @bi_mul_small(%144, %143, %arg0, %141) : (!llvm.ptr, i64, i64, i64) -> ()
%154 = arith.constant 1 : i32
%156 = arith.extsi %154 : i32 to i64
%155 = arith.addi %arg0, %156 : i64
func.call @bi_mul_small(%144, %143, %155, %141) : (!llvm.ptr, i64, i64, i64) -> ()
%158 = arith.constant 2 : i32
%160 = arith.extsi %158 : i32 to i64
%159 = arith.muli %160, %arg0 : i64
%161 = arith.constant 1 : i32
%163 = arith.extsi %161 : i32 to i64
%162 = arith.addi %159, %163 : i64
func.call @bi_mul_small(%144, %143, %162, %141) : (!llvm.ptr, i64, i64, i64) -> ()
%165 = arith.constant 6 : i32
%166 = arith.extsi %165 : i32 to i64
func.call @bi_div_small(%144, %143, %166, %141) : (!llvm.ptr, i64, i64, i64) -> ()
%167 = arith.constant 6 : i32
%169 = arith.extsi %167 : i32 to i64
%168 = arith.muli %169, %arg0 : i64
%170 = llvm.mlir.constant(1 : i64) : i64
%171 = llvm.alloca %170 x i64 : (i64) -> !llvm.ptr
llvm.store %168, %171 : i64, !llvm.ptr
%173 = arith.constant 0 : i32
%174 = arith.extsi %173 : i32 to i64
%175 = llvm.getelementptr %144[%174] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%172 = llvm.load %175 : !llvm.ptr -> i64
%176 = llvm.load %171 : !llvm.ptr -> i64
%177 = arith.addi %172, %176 : i64
%178 = llvm.mlir.constant(1 : i64) : i64
%179 = llvm.alloca %178 x i64 : (i64) -> !llvm.ptr
llvm.store %177, %179 : i64, !llvm.ptr
%180 = llvm.load %179 : !llvm.ptr -> i64
%181 = arith.remsi %180, %141 : i64
%182 = arith.constant 0 : i32
%183 = arith.extsi %182 : i32 to i64
%184 = llvm.getelementptr %144[%183] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %181, %184 : i64, !llvm.ptr
%185 = llvm.load %179 : !llvm.ptr -> i64
%186 = arith.divsi %185, %141 : i64
llvm.store %186, %179 : i64, !llvm.ptr
%187 = arith.constant 1 : i32
%188 = arith.extsi %187 : i32 to i64
%189 = llvm.mlir.constant(1 : i64) : i64
%190 = llvm.alloca %189 x i64 : (i64) -> !llvm.ptr
llvm.store %188, %190 : i64, !llvm.ptr
cf.br ^bb30
^bb30:
%191 = llvm.load %179 : !llvm.ptr -> i64
%192 = arith.constant 0 : i32
%194 = arith.extsi %192 : i32 to i64
%193 = arith.cmpi ne, %191, %194 : i64
%195 = scf.if %193 -> (i1) {
%196 = llvm.load %190 : !llvm.ptr -> i64
%197 = arith.cmpi slt, %196, %143 : i64
scf.yield %197 : i1
} else {
%198 = arith.constant false
scf.yield %198 : i1
}
cf.cond_br %195, ^bb31, ^bb32
^bb31:
%200 = llvm.load %190 : !llvm.ptr -> i64
%201 = llvm.getelementptr %144[%200] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%199 = llvm.load %201 : !llvm.ptr -> i64
%202 = llvm.load %179 : !llvm.ptr -> i64
%203 = arith.addi %199, %202 : i64
llvm.store %203, %179 : i64, !llvm.ptr
%204 = llvm.load %179 : !llvm.ptr -> i64
%205 = arith.remsi %204, %141 : i64
%206 = llvm.load %190 : !llvm.ptr -> i64
%207 = llvm.getelementptr %144[%206] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %205, %207 : i64, !llvm.ptr
%208 = llvm.load %179 : !llvm.ptr -> i64
%209 = arith.divsi %208, %141 : i64
llvm.store %209, %179 : i64, !llvm.ptr
%210 = llvm.load %190 : !llvm.ptr -> i64
%211 = arith.constant 1 : i32
%213 = arith.extsi %211 : i32 to i64
%212 = arith.addi %210, %213 : i64
llvm.store %212, %190 : i64, !llvm.ptr
cf.br ^bb30
^bb32:
%214 = arith.constant 6 : i32
%216 = arith.extsi %214 : i32 to i64
%215 = arith.divsi %arg0, %216 : i64
%217 = arith.constant 6 : i32
%219 = arith.extsi %217 : i32 to i64
%218 = arith.remsi %arg0, %219 : i64
%220 = arith.constant 0 : i32
%221 = arith.extsi %220 : i32 to i64
%222 = llvm.mlir.constant(1 : i64) : i64
%223 = llvm.alloca %222 x i64 : (i64) -> !llvm.ptr
llvm.store %221, %223 : i64, !llvm.ptr
%224 = arith.constant 1 : i32
%226 = arith.extsi %224 : i32 to i64
%225 = arith.cmpi eq, %218, %226 : i64
cf.cond_br %225, ^bb33, ^bb34
^bb33:
%227 = arith.constant 7 : i32
%228 = arith.extsi %227 : i32 to i64
llvm.store %228, %223 : i64, !llvm.ptr
cf.br ^bb35
^bb34:
%229 = arith.constant 2 : i32
%231 = arith.extsi %229 : i32 to i64
%230 = arith.cmpi eq, %218, %231 : i64
cf.cond_br %230, ^bb37, ^bb36
^bb37:
%232 = arith.constant 17 : i32
%233 = arith.extsi %232 : i32 to i64
llvm.store %233, %223 : i64, !llvm.ptr
cf.br ^bb35
^bb36:
%234 = arith.constant 3 : i32
%236 = arith.extsi %234 : i32 to i64
%235 = arith.cmpi eq, %218, %236 : i64
cf.cond_br %235, ^bb39, ^bb38
^bb39:
%237 = arith.constant 20 : i32
%238 = arith.extsi %237 : i32 to i64
llvm.store %238, %223 : i64, !llvm.ptr
cf.br ^bb35
^bb38:
%239 = arith.constant 4 : i32
%241 = arith.extsi %239 : i32 to i64
%240 = arith.cmpi eq, %218, %241 : i64
cf.cond_br %240, ^bb41, ^bb40
^bb41:
%242 = arith.constant 30 : i32
%243 = arith.extsi %242 : i32 to i64
llvm.store %243, %223 : i64, !llvm.ptr
cf.br ^bb35
^bb40:
%244 = arith.constant 5 : i32
%246 = arith.extsi %244 : i32 to i64
%245 = arith.cmpi eq, %218, %246 : i64
cf.cond_br %245, ^bb43, ^bb42
^bb43:
%247 = arith.constant 37 : i32
%248 = arith.extsi %247 : i32 to i64
llvm.store %248, %223 : i64, !llvm.ptr
cf.br ^bb35
^bb42:
%249 = arith.constant 6 : i32
%251 = arith.extsi %249 : i32 to i64
%250 = arith.cmpi eq, %218, %251 : i64
cf.cond_br %250, ^bb44, ^bb35
^bb44:
%252 = arith.constant 43 : i32
%253 = arith.extsi %252 : i32 to i64
llvm.store %253, %223 : i64, !llvm.ptr
cf.br ^bb35
^bb35:
%254 = arith.constant 43 : i32
%256 = arith.extsi %254 : i32 to i64
%255 = arith.muli %215, %256 : i64
%257 = llvm.load %223 : !llvm.ptr -> i64
%258 = arith.addi %255, %257 : i64
%260 = arith.constant 0 : i32
%261 = arith.extsi %260 : i32 to i64
%262 = llvm.getelementptr %144[%261] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%259 = llvm.load %262 : !llvm.ptr -> i64
%263 = arith.subi %259, %258 : i64
%264 = arith.constant 0 : i32
%265 = arith.extsi %264 : i32 to i64
%266 = llvm.getelementptr %144[%265] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %263, %266 : i64, !llvm.ptr
%267 = arith.constant 0 : i32
%268 = arith.extsi %267 : i32 to i64
llvm.store %268, %190 : i64, !llvm.ptr
cf.br ^bb45
^bb45:
%269 = llvm.load %190 : !llvm.ptr -> i64
%270 = arith.constant 1 : i32
%272 = arith.extsi %270 : i32 to i64
%271 = arith.subi %143, %272 : i64
%273 = arith.cmpi slt, %269, %271 : i64
cf.cond_br %273, ^bb46, ^bb47
^bb46:
cf.br ^bb48
^bb48:
%275 = llvm.load %190 : !llvm.ptr -> i64
%276 = llvm.getelementptr %144[%275] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%274 = llvm.load %276 : !llvm.ptr -> i64
%277 = arith.constant 0 : i32
%279 = arith.extsi %277 : i32 to i64
%278 = arith.cmpi slt, %274, %279 : i64
cf.cond_br %278, ^bb49, ^bb50
^bb49:
%281 = llvm.load %190 : !llvm.ptr -> i64
%282 = llvm.getelementptr %144[%281] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%280 = llvm.load %282 : !llvm.ptr -> i64
%283 = arith.addi %280, %141 : i64
%284 = llvm.load %190 : !llvm.ptr -> i64
%285 = llvm.getelementptr %144[%284] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %283, %285 : i64, !llvm.ptr
%287 = llvm.load %190 : !llvm.ptr -> i64
%288 = arith.constant 1 : i32
%290 = arith.extsi %288 : i32 to i64
%289 = arith.addi %287, %290 : i64
%291 = llvm.getelementptr %144[%289] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%286 = llvm.load %291 : !llvm.ptr -> i64
%292 = arith.constant 1 : i32
%294 = arith.extsi %292 : i32 to i64
%293 = arith.subi %286, %294 : i64
%295 = llvm.load %190 : !llvm.ptr -> i64
%296 = arith.constant 1 : i32
%298 = arith.extsi %296 : i32 to i64
%297 = arith.addi %295, %298 : i64
%299 = llvm.getelementptr %144[%297] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %293, %299 : i64, !llvm.ptr
cf.br ^bb48
^bb50:
%301 = llvm.load %190 : !llvm.ptr -> i64
%302 = llvm.getelementptr %144[%301] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%300 = llvm.load %302 : !llvm.ptr -> i64
%303 = arith.cmpi sge, %300, %141 : i64
cf.cond_br %303, ^bb51, ^bb52
^bb51:
%305 = llvm.load %190 : !llvm.ptr -> i64
%306 = arith.constant 1 : i32
%308 = arith.extsi %306 : i32 to i64
%307 = arith.addi %305, %308 : i64
%309 = llvm.getelementptr %144[%307] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%304 = llvm.load %309 : !llvm.ptr -> i64
%311 = llvm.load %190 : !llvm.ptr -> i64
%312 = llvm.getelementptr %144[%311] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%310 = llvm.load %312 : !llvm.ptr -> i64
%313 = arith.divsi %310, %141 : i64
%314 = arith.addi %304, %313 : i64
%315 = llvm.load %190 : !llvm.ptr -> i64
%316 = arith.constant 1 : i32
%318 = arith.extsi %316 : i32 to i64
%317 = arith.addi %315, %318 : i64
%319 = llvm.getelementptr %144[%317] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %314, %319 : i64, !llvm.ptr
%321 = llvm.load %190 : !llvm.ptr -> i64
%322 = llvm.getelementptr %144[%321] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%320 = llvm.load %322 : !llvm.ptr -> i64
%323 = arith.remsi %320, %141 : i64
%324 = llvm.load %190 : !llvm.ptr -> i64
%325 = llvm.getelementptr %144[%324] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %323, %325 : i64, !llvm.ptr
cf.br ^bb53
^bb52:
cf.br ^bb53
^bb53:
%326 = llvm.load %190 : !llvm.ptr -> i64
%327 = arith.constant 1 : i32
%329 = arith.extsi %327 : i32 to i64
%328 = arith.addi %326, %329 : i64
llvm.store %328, %190 : i64, !llvm.ptr
cf.br ^bb45
^bb47:
%331 = arith.constant 12 : i32
%332 = arith.extsi %331 : i32 to i64
func.call @bi_div_small(%144, %143, %332, %141) : (!llvm.ptr, i64, i64, i64) -> ()
%333 = func.call @bi_to_i64(%144, %143, %141) : (!llvm.ptr, i64, i64) -> i64
func.call @free(%144) : (!llvm.ptr) -> ()
func.return %333 : i64
}
func.func @triangles_upto(%arg0: i64) -> i64 {
%336 = arith.constant 2 : i32
%338 = arith.extsi %336 : i32 to i64
%337 = arith.divsi %arg0, %338 : i64
%335 = func.call @S(%337) : (i64) -> i64
%340 = arith.constant 1 : i32
%342 = arith.extsi %340 : i32 to i64
%341 = arith.addi %arg0, %342 : i64
%343 = arith.constant 2 : i32
%345 = arith.extsi %343 : i32 to i64
%344 = arith.divsi %341, %345 : i64
%346 = arith.constant 1 : i32
%348 = arith.extsi %346 : i32 to i64
%347 = arith.addi %344, %348 : i64
%339 = func.call @S(%347) : (i64) -> i64
%349 = arith.addi %335, %339 : i64
func.return %349 : i64
}
func.func @main() -> i32 {
%350 = arith.constant 10000000 : i32
%351 = arith.extsi %350 : i32 to i64
%353 = arith.constant 1 : i32
%355 = arith.extsi %353 : i32 to i64
%354 = arith.addi %351, %355 : i64
%356 = arith.constant 4 : i32
%357 = arith.extsi %356 : i32 to i64
%352 = func.call @calloc(%354, %357) : (i64, i64) -> !llvm.ptr
%359 = arith.constant 1 : i32
%361 = arith.extsi %359 : i32 to i64
%360 = arith.addi %351, %361 : i64
%362 = arith.constant 4 : i32
%363 = arith.extsi %362 : i32 to i64
%358 = func.call @calloc(%360, %363) : (i64, i64) -> !llvm.ptr
%365 = arith.constant 1 : i32
%367 = arith.extsi %365 : i32 to i64
%366 = arith.addi %351, %367 : i64
%368 = arith.constant 1 : i32
%369 = arith.extsi %368 : i32 to i64
%364 = func.call @calloc(%366, %369) : (i64, i64) -> !llvm.ptr
%371 = arith.constant 700000 : i32
%372 = arith.constant 8 : i32
%373 = arith.extsi %371 : i32 to i64
%374 = arith.extsi %372 : i32 to i64
%370 = func.call @calloc(%373, %374) : (i64, i64) -> !llvm.ptr
%375 = llvm.mlir.zero : !llvm.ptr
%376 = llvm.icmp "eq" %352, %375 : !llvm.ptr
%377 = scf.if %376 -> (i1) {
%378 = arith.constant true
scf.yield %378 : i1
} else {
%379 = llvm.mlir.zero : !llvm.ptr
%380 = llvm.icmp "eq" %358, %379 : !llvm.ptr
scf.yield %380 : i1
}
%381 = scf.if %377 -> (i1) {
%382 = arith.constant true
scf.yield %382 : i1
} else {
%383 = llvm.mlir.zero : !llvm.ptr
%384 = llvm.icmp "eq" %364, %383 : !llvm.ptr
scf.yield %384 : i1
}
%385 = scf.if %381 -> (i1) {
%386 = arith.constant true
scf.yield %386 : i1
} else {
%387 = llvm.mlir.zero : !llvm.ptr
%388 = llvm.icmp "eq" %370, %387 : !llvm.ptr
scf.yield %388 : i1
}
cf.cond_br %385, ^bb54, ^bb55
^bb54:
%389 = arith.constant 1 : i32
func.return %389 : i32
^bb55:
cf.br ^bb56
^bb56:
%390 = arith.constant 1 : i32
%391 = arith.constant 1 : i32
%392 = arith.extsi %391 : i32 to i64
%393 = llvm.getelementptr %352[%392] : (!llvm.ptr, i64) -> !llvm.ptr, i32
llvm.store %390, %393 : i32, !llvm.ptr
%394 = arith.constant 0 : i32
%395 = arith.extsi %394 : i32 to i64
%396 = llvm.mlir.constant(1 : i64) : i64
%397 = llvm.alloca %396 x i64 : (i64) -> !llvm.ptr
llvm.store %395, %397 : i64, !llvm.ptr
%398 = arith.constant 2 : i32
%399 = arith.extsi %398 : i32 to i64
%400 = llvm.mlir.constant(1 : i64) : i64
%401 = llvm.alloca %400 x i64 : (i64) -> !llvm.ptr
llvm.store %399, %401 : i64, !llvm.ptr
cf.br ^bb57
^bb57:
%402 = llvm.load %401 : !llvm.ptr -> i64
%403 = arith.cmpi sle, %402, %351 : i64
cf.cond_br %403, ^bb58, ^bb59
^bb58:
%405 = llvm.load %401 : !llvm.ptr -> i64
%406 = llvm.getelementptr %364[%405] : (!llvm.ptr, i64) -> !llvm.ptr, i8
%404 = llvm.load %406 : !llvm.ptr -> i8
%407 = arith.constant 0 : i32
%409 = arith.extsi %404 : i8 to i32
%408 = arith.cmpi eq, %409, %407 : i32
cf.cond_br %408, ^bb60, ^bb61
^bb60:
%410 = llvm.load %401 : !llvm.ptr -> i64
%411 = llvm.load %397 : !llvm.ptr -> i64
%412 = llvm.getelementptr %370[%411] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %410, %412 : i64, !llvm.ptr
%413 = llvm.load %397 : !llvm.ptr -> i64
%414 = arith.constant 1 : i32
%416 = arith.extsi %414 : i32 to i64
%415 = arith.addi %413, %416 : i64
llvm.store %415, %397 : i64, !llvm.ptr
%417 = arith.constant 1 : i32
%419 = arith.constant 0 : i32
%418 = arith.subi %419, %417 : i32
%420 = llvm.load %401 : !llvm.ptr -> i64
%421 = llvm.getelementptr %352[%420] : (!llvm.ptr, i64) -> !llvm.ptr, i32
llvm.store %418, %421 : i32, !llvm.ptr
cf.br ^bb62
^bb61:
cf.br ^bb62
^bb62:
%423 = llvm.load %401 : !llvm.ptr -> i64
%424 = llvm.getelementptr %352[%423] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%422 = llvm.load %424 : !llvm.ptr -> i32
%425 = arith.constant 0 : i32
%426 = arith.extsi %425 : i32 to i64
%427 = llvm.mlir.constant(1 : i64) : i64
%428 = llvm.alloca %427 x i64 : (i64) -> !llvm.ptr
llvm.store %426, %428 : i64, !llvm.ptr
cf.br ^bb63
^bb63:
%429 = llvm.load %428 : !llvm.ptr -> i64
%430 = llvm.load %397 : !llvm.ptr -> i64
%431 = arith.cmpi slt, %429, %430 : i64
cf.cond_br %431, ^bb64, ^bb65
^bb64:
%433 = llvm.load %428 : !llvm.ptr -> i64
%434 = llvm.getelementptr %370[%433] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%432 = llvm.load %434 : !llvm.ptr -> i64
%435 = llvm.load %401 : !llvm.ptr -> i64
%436 = arith.divsi %351, %435 : i64
%437 = arith.cmpi sgt, %432, %436 : i64
cf.cond_br %437, ^bb66, ^bb67
^bb66:
cf.br ^bb65
^bb67:
cf.br ^bb68
^bb68:
%438 = llvm.load %401 : !llvm.ptr -> i64
%439 = arith.muli %438, %432 : i64
%440 = arith.constant 1 : i32
%441 = arith.trunci %440 : i32 to i8
%442 = llvm.getelementptr %364[%439] : (!llvm.ptr, i64) -> !llvm.ptr, i8
llvm.store %441, %442 : i8, !llvm.ptr
%443 = llvm.load %401 : !llvm.ptr -> i64
%444 = arith.remsi %443, %432 : i64
%445 = arith.constant 0 : i32
%447 = arith.extsi %445 : i32 to i64
%446 = arith.cmpi eq, %444, %447 : i64
cf.cond_br %446, ^bb69, ^bb70
^bb69:
%448 = arith.constant 0 : i32
%449 = llvm.getelementptr %352[%439] : (!llvm.ptr, i64) -> !llvm.ptr, i32
llvm.store %448, %449 : i32, !llvm.ptr
cf.br ^bb65
^bb70:
cf.br ^bb71
^bb71:
%450 = arith.constant 0 : i32
%451 = arith.subi %450, %422 : i32
%452 = llvm.getelementptr %352[%439] : (!llvm.ptr, i64) -> !llvm.ptr, i32
llvm.store %451, %452 : i32, !llvm.ptr
%453 = llvm.load %428 : !llvm.ptr -> i64
%454 = arith.constant 1 : i32
%456 = arith.extsi %454 : i32 to i64
%455 = arith.addi %453, %456 : i64
llvm.store %455, %428 : i64, !llvm.ptr
cf.br ^bb63
^bb65:
%457 = llvm.load %401 : !llvm.ptr -> i64
%458 = arith.constant 1 : i32
%460 = arith.extsi %458 : i32 to i64
%459 = arith.addi %457, %460 : i64
llvm.store %459, %401 : i64, !llvm.ptr
cf.br ^bb57
^bb59:
%461 = arith.constant 0 : i32
%462 = llvm.mlir.constant(1 : i64) : i64
%463 = llvm.alloca %462 x i32 : (i64) -> !llvm.ptr
llvm.store %461, %463 : i32, !llvm.ptr
%464 = arith.constant 1 : i32
%465 = arith.extsi %464 : i32 to i64
llvm.store %465, %401 : i64, !llvm.ptr
cf.br ^bb72
^bb72:
%466 = llvm.load %401 : !llvm.ptr -> i64
%467 = arith.cmpi sle, %466, %351 : i64
cf.cond_br %467, ^bb73, ^bb74
^bb73:
%468 = llvm.load %463 : !llvm.ptr -> i32
%470 = llvm.load %401 : !llvm.ptr -> i64
%471 = llvm.getelementptr %352[%470] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%469 = llvm.load %471 : !llvm.ptr -> i32
%472 = arith.addi %468, %469 : i32
llvm.store %472, %463 : i32, !llvm.ptr
%473 = llvm.load %463 : !llvm.ptr -> i32
%474 = llvm.load %401 : !llvm.ptr -> i64
%475 = llvm.getelementptr %358[%474] : (!llvm.ptr, i64) -> !llvm.ptr, i32
llvm.store %473, %475 : i32, !llvm.ptr
%476 = llvm.load %401 : !llvm.ptr -> i64
%477 = arith.constant 1 : i32
%479 = arith.extsi %477 : i32 to i64
%478 = arith.addi %476, %479 : i64
llvm.store %478, %401 : i64, !llvm.ptr
cf.br ^bb72
^bb74:
%480 = arith.constant 1000000000 : i32
%481 = arith.extsi %480 : i32 to i64
%482 = arith.constant 8 : i32
%483 = arith.extsi %482 : i32 to i64
%485 = arith.constant 8 : i32
%486 = arith.extsi %485 : i32 to i64
%484 = func.call @calloc(%483, %486) : (i64, i64) -> !llvm.ptr
%487 = arith.constant 1 : i32
%488 = llvm.mlir.constant(1 : i64) : i64
%489 = llvm.alloca %488 x i32 : (i64) -> !llvm.ptr
llvm.store %487, %489 : i32, !llvm.ptr
%490 = arith.constant 1 : i32
%491 = arith.extsi %490 : i32 to i64
%492 = llvm.mlir.constant(1 : i64) : i64
%493 = llvm.alloca %492 x i64 : (i64) -> !llvm.ptr
llvm.store %491, %493 : i64, !llvm.ptr
cf.br ^bb75
^bb75:
%494 = llvm.load %493 : !llvm.ptr -> i64
%495 = arith.cmpi sle, %494, %351 : i64
cf.cond_br %495, ^bb76, ^bb77
^bb76:
%496 = llvm.load %493 : !llvm.ptr -> i64
%497 = arith.divsi %351, %496 : i64
%498 = arith.divsi %351, %497 : i64
%500 = llvm.getelementptr %358[%498] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%499 = llvm.load %500 : !llvm.ptr -> i32
%501 = arith.extsi %499 : i32 to i64
%503 = llvm.load %493 : !llvm.ptr -> i64
%504 = arith.constant 1 : i32
%506 = arith.extsi %504 : i32 to i64
%505 = arith.subi %503, %506 : i64
%507 = llvm.getelementptr %358[%505] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%502 = llvm.load %507 : !llvm.ptr -> i32
%508 = arith.extsi %502 : i32 to i64
%509 = arith.subi %501, %508 : i64
%510 = func.call @triangles_upto(%497) : (i64) -> i64
%511 = arith.constant 0 : i32
%513 = arith.extsi %511 : i32 to i64
%512 = arith.cmpi ne, %509, %513 : i64
%514 = scf.if %512 -> (i1) {
%515 = arith.constant 0 : i32
%517 = arith.extsi %515 : i32 to i64
%516 = arith.cmpi ne, %510, %517 : i64
scf.yield %516 : i1
} else {
%518 = arith.constant false
scf.yield %518 : i1
}
cf.cond_br %514, ^bb78, ^bb79
^bb78:
%519 = arith.constant 1 : i32
%520 = llvm.mlir.constant(1 : i64) : i64
%521 = llvm.alloca %520 x i32 : (i64) -> !llvm.ptr
llvm.store %519, %521 : i32, !llvm.ptr
%522 = llvm.mlir.constant(1 : i64) : i64
%523 = llvm.alloca %522 x i64 : (i64) -> !llvm.ptr
llvm.store %509, %523 : i64, !llvm.ptr
%524 = llvm.load %523 : !llvm.ptr -> i64
%525 = arith.constant 0 : i32
%527 = arith.extsi %525 : i32 to i64
%526 = arith.cmpi slt, %524, %527 : i64
cf.cond_br %526, ^bb81, ^bb82
^bb81:
%528 = llvm.load %523 : !llvm.ptr -> i64
%530 = arith.constant 0 : i64
%529 = arith.subi %530, %528 : i64
llvm.store %529, %523 : i64, !llvm.ptr
%531 = arith.constant 1 : i32
%533 = arith.constant 0 : i32
%532 = arith.subi %533, %531 : i32
llvm.store %532, %521 : i32, !llvm.ptr
cf.br ^bb83
^bb82:
cf.br ^bb83
^bb83:
%535 = arith.constant 8 : i32
%536 = arith.extsi %535 : i32 to i64
%534 = func.call @calloc(%483, %536) : (i64, i64) -> !llvm.ptr
%537 = arith.constant 0 : i32
%538 = arith.extsi %537 : i32 to i64
%539 = llvm.getelementptr %534[%538] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %510, %539 : i64, !llvm.ptr
%540 = arith.constant 0 : i32
%541 = arith.extsi %540 : i32 to i64
%542 = llvm.mlir.constant(1 : i64) : i64
%543 = llvm.alloca %542 x i64 : (i64) -> !llvm.ptr
llvm.store %541, %543 : i64, !llvm.ptr
cf.br ^bb84
^bb84:
%544 = llvm.load %543 : !llvm.ptr -> i64
%545 = arith.constant 1 : i32
%547 = arith.extsi %545 : i32 to i64
%546 = arith.subi %483, %547 : i64
%548 = arith.cmpi slt, %544, %546 : i64
cf.cond_br %548, ^bb85, ^bb86
^bb85:
%550 = llvm.load %543 : !llvm.ptr -> i64
%551 = llvm.getelementptr %534[%550] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%549 = llvm.load %551 : !llvm.ptr -> i64
%552 = arith.cmpi sge, %549, %481 : i64
cf.cond_br %552, ^bb87, ^bb88
^bb87:
%554 = llvm.load %543 : !llvm.ptr -> i64
%555 = arith.constant 1 : i32
%557 = arith.extsi %555 : i32 to i64
%556 = arith.addi %554, %557 : i64
%558 = llvm.getelementptr %534[%556] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%553 = llvm.load %558 : !llvm.ptr -> i64
%560 = llvm.load %543 : !llvm.ptr -> i64
%561 = llvm.getelementptr %534[%560] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%559 = llvm.load %561 : !llvm.ptr -> i64
%562 = arith.divsi %559, %481 : i64
%563 = arith.addi %553, %562 : i64
%564 = llvm.load %543 : !llvm.ptr -> i64
%565 = arith.constant 1 : i32
%567 = arith.extsi %565 : i32 to i64
%566 = arith.addi %564, %567 : i64
%568 = llvm.getelementptr %534[%566] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %563, %568 : i64, !llvm.ptr
%570 = llvm.load %543 : !llvm.ptr -> i64
%571 = llvm.getelementptr %534[%570] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%569 = llvm.load %571 : !llvm.ptr -> i64
%572 = arith.remsi %569, %481 : i64
%573 = llvm.load %543 : !llvm.ptr -> i64
%574 = llvm.getelementptr %534[%573] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %572, %574 : i64, !llvm.ptr
cf.br ^bb89
^bb88:
cf.br ^bb89
^bb89:
%575 = llvm.load %543 : !llvm.ptr -> i64
%576 = arith.constant 1 : i32
%578 = arith.extsi %576 : i32 to i64
%577 = arith.addi %575, %578 : i64
llvm.store %577, %543 : i64, !llvm.ptr
cf.br ^bb84
^bb86:
%580 = llvm.load %523 : !llvm.ptr -> i64
func.call @bi_mul_small(%534, %483, %580, %481) : (!llvm.ptr, i64, i64, i64) -> ()
%581 = llvm.load %489 : !llvm.ptr -> i32
%582 = llvm.load %521 : !llvm.ptr -> i32
%583 = arith.cmpi eq, %581, %582 : i32
cf.cond_br %583, ^bb90, ^bb91
^bb90:
%584 = arith.constant 0 : i32
%585 = arith.extsi %584 : i32 to i64
llvm.store %585, %543 : i64, !llvm.ptr
%586 = arith.constant 0 : i32
%587 = arith.extsi %586 : i32 to i64
%588 = llvm.mlir.constant(1 : i64) : i64
%589 = llvm.alloca %588 x i64 : (i64) -> !llvm.ptr
llvm.store %587, %589 : i64, !llvm.ptr
cf.br ^bb93
^bb93:
%590 = llvm.load %543 : !llvm.ptr -> i64
%591 = arith.cmpi slt, %590, %483 : i64
cf.cond_br %591, ^bb94, ^bb95
^bb94:
%593 = llvm.load %543 : !llvm.ptr -> i64
%594 = llvm.getelementptr %484[%593] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%592 = llvm.load %594 : !llvm.ptr -> i64
%596 = llvm.load %543 : !llvm.ptr -> i64
%597 = llvm.getelementptr %534[%596] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%595 = llvm.load %597 : !llvm.ptr -> i64
%598 = arith.addi %592, %595 : i64
%599 = llvm.load %589 : !llvm.ptr -> i64
%600 = arith.addi %598, %599 : i64
%601 = arith.remsi %600, %481 : i64
%602 = llvm.load %543 : !llvm.ptr -> i64
%603 = llvm.getelementptr %484[%602] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %601, %603 : i64, !llvm.ptr
%604 = arith.divsi %600, %481 : i64
llvm.store %604, %589 : i64, !llvm.ptr
%605 = llvm.load %543 : !llvm.ptr -> i64
%606 = arith.constant 1 : i32
%608 = arith.extsi %606 : i32 to i64
%607 = arith.addi %605, %608 : i64
llvm.store %607, %543 : i64, !llvm.ptr
cf.br ^bb93
^bb95:
cf.br ^bb92
^bb91:
%609 = arith.constant 0 : i32
%610 = llvm.mlir.constant(1 : i64) : i64
%611 = llvm.alloca %610 x i32 : (i64) -> !llvm.ptr
llvm.store %609, %611 : i32, !llvm.ptr
%612 = arith.constant 1 : i32
%614 = arith.extsi %612 : i32 to i64
%613 = arith.subi %483, %614 : i64
llvm.store %613, %543 : i64, !llvm.ptr
cf.br ^bb96
^bb96:
%615 = llvm.load %543 : !llvm.ptr -> i64
%616 = arith.constant 0 : i32
%618 = arith.extsi %616 : i32 to i64
%617 = arith.cmpi sge, %615, %618 : i64
cf.cond_br %617, ^bb97, ^bb98
^bb97:
%620 = llvm.load %543 : !llvm.ptr -> i64
%621 = llvm.getelementptr %484[%620] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%619 = llvm.load %621 : !llvm.ptr -> i64
%623 = llvm.load %543 : !llvm.ptr -> i64
%624 = llvm.getelementptr %534[%623] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%622 = llvm.load %624 : !llvm.ptr -> i64
%625 = arith.cmpi slt, %619, %622 : i64
cf.cond_br %625, ^bb99, ^bb100
^bb99:
%626 = arith.constant 1 : i32
%628 = arith.constant 0 : i32
%627 = arith.subi %628, %626 : i32
llvm.store %627, %611 : i32, !llvm.ptr
cf.br ^bb98
^bb100:
cf.br ^bb101
^bb101:
%630 = llvm.load %543 : !llvm.ptr -> i64
%631 = llvm.getelementptr %484[%630] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%629 = llvm.load %631 : !llvm.ptr -> i64
%633 = llvm.load %543 : !llvm.ptr -> i64
%634 = llvm.getelementptr %534[%633] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%632 = llvm.load %634 : !llvm.ptr -> i64
%635 = arith.cmpi sgt, %629, %632 : i64
cf.cond_br %635, ^bb102, ^bb103
^bb102:
%636 = arith.constant 1 : i32
llvm.store %636, %611 : i32, !llvm.ptr
cf.br ^bb98
^bb103:
cf.br ^bb104
^bb104:
%637 = llvm.load %543 : !llvm.ptr -> i64
%638 = arith.constant 1 : i32
%640 = arith.extsi %638 : i32 to i64
%639 = arith.subi %637, %640 : i64
llvm.store %639, %543 : i64, !llvm.ptr
cf.br ^bb96
^bb98:
%641 = llvm.load %611 : !llvm.ptr -> i32
%642 = arith.constant 0 : i32
%643 = arith.cmpi eq, %641, %642 : i32
cf.cond_br %643, ^bb105, ^bb106
^bb105:
%644 = arith.constant 0 : i32
%645 = arith.extsi %644 : i32 to i64
llvm.store %645, %543 : i64, !llvm.ptr
cf.br ^bb108
^bb108:
%646 = llvm.load %543 : !llvm.ptr -> i64
%647 = arith.cmpi slt, %646, %483 : i64
cf.cond_br %647, ^bb109, ^bb110
^bb109:
%648 = arith.constant 0 : i32
%649 = llvm.load %543 : !llvm.ptr -> i64
%650 = arith.extsi %648 : i32 to i64
%651 = llvm.getelementptr %484[%649] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %650, %651 : i64, !llvm.ptr
%652 = llvm.load %543 : !llvm.ptr -> i64
%653 = arith.constant 1 : i32
%655 = arith.extsi %653 : i32 to i64
%654 = arith.addi %652, %655 : i64
llvm.store %654, %543 : i64, !llvm.ptr
cf.br ^bb108
^bb110:
%656 = arith.constant 1 : i32
llvm.store %656, %489 : i32, !llvm.ptr
cf.br ^bb107
^bb106:
%657 = llvm.load %611 : !llvm.ptr -> i32
%658 = arith.constant 0 : i32
%659 = arith.cmpi sgt, %657, %658 : i32
cf.cond_br %659, ^bb112, ^bb111
^bb112:
%660 = arith.constant 0 : i32
%661 = arith.extsi %660 : i32 to i64
llvm.store %661, %543 : i64, !llvm.ptr
cf.br ^bb113
^bb113:
%662 = llvm.load %543 : !llvm.ptr -> i64
%663 = arith.cmpi slt, %662, %483 : i64
cf.cond_br %663, ^bb114, ^bb115
^bb114:
%665 = llvm.load %543 : !llvm.ptr -> i64
%666 = llvm.getelementptr %484[%665] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%664 = llvm.load %666 : !llvm.ptr -> i64
%668 = llvm.load %543 : !llvm.ptr -> i64
%669 = llvm.getelementptr %534[%668] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%667 = llvm.load %669 : !llvm.ptr -> i64
%670 = arith.subi %664, %667 : i64
%671 = llvm.load %543 : !llvm.ptr -> i64
%672 = llvm.getelementptr %484[%671] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %670, %672 : i64, !llvm.ptr
%673 = llvm.load %543 : !llvm.ptr -> i64
%674 = arith.constant 1 : i32
%676 = arith.extsi %674 : i32 to i64
%675 = arith.addi %673, %676 : i64
llvm.store %675, %543 : i64, !llvm.ptr
cf.br ^bb113
^bb115:
%677 = arith.constant 0 : i32
%678 = arith.extsi %677 : i32 to i64
llvm.store %678, %543 : i64, !llvm.ptr
cf.br ^bb116
^bb116:
%679 = llvm.load %543 : !llvm.ptr -> i64
%680 = arith.constant 1 : i32
%682 = arith.extsi %680 : i32 to i64
%681 = arith.subi %483, %682 : i64
%683 = arith.cmpi slt, %679, %681 : i64
cf.cond_br %683, ^bb117, ^bb118
^bb117:
cf.br ^bb119
^bb119:
%685 = llvm.load %543 : !llvm.ptr -> i64
%686 = llvm.getelementptr %484[%685] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%684 = llvm.load %686 : !llvm.ptr -> i64
%687 = arith.constant 0 : i32
%689 = arith.extsi %687 : i32 to i64
%688 = arith.cmpi slt, %684, %689 : i64
cf.cond_br %688, ^bb120, ^bb121
^bb120:
%691 = llvm.load %543 : !llvm.ptr -> i64
%692 = llvm.getelementptr %484[%691] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%690 = llvm.load %692 : !llvm.ptr -> i64
%693 = arith.addi %690, %481 : i64
%694 = llvm.load %543 : !llvm.ptr -> i64
%695 = llvm.getelementptr %484[%694] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %693, %695 : i64, !llvm.ptr
%697 = llvm.load %543 : !llvm.ptr -> i64
%698 = arith.constant 1 : i32
%700 = arith.extsi %698 : i32 to i64
%699 = arith.addi %697, %700 : i64
%701 = llvm.getelementptr %484[%699] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%696 = llvm.load %701 : !llvm.ptr -> i64
%702 = arith.constant 1 : i32
%704 = arith.extsi %702 : i32 to i64
%703 = arith.subi %696, %704 : i64
%705 = llvm.load %543 : !llvm.ptr -> i64
%706 = arith.constant 1 : i32
%708 = arith.extsi %706 : i32 to i64
%707 = arith.addi %705, %708 : i64
%709 = llvm.getelementptr %484[%707] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %703, %709 : i64, !llvm.ptr
cf.br ^bb119
^bb121:
%710 = llvm.load %543 : !llvm.ptr -> i64
%711 = arith.constant 1 : i32
%713 = arith.extsi %711 : i32 to i64
%712 = arith.addi %710, %713 : i64
llvm.store %712, %543 : i64, !llvm.ptr
cf.br ^bb116
^bb118:
cf.br ^bb107
^bb111:
%714 = arith.constant 0 : i32
%715 = arith.extsi %714 : i32 to i64
llvm.store %715, %543 : i64, !llvm.ptr
cf.br ^bb122
^bb122:
%716 = llvm.load %543 : !llvm.ptr -> i64
%717 = arith.cmpi slt, %716, %483 : i64
cf.cond_br %717, ^bb123, ^bb124
^bb123:
%719 = llvm.load %543 : !llvm.ptr -> i64
%720 = llvm.getelementptr %534[%719] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%718 = llvm.load %720 : !llvm.ptr -> i64
%722 = llvm.load %543 : !llvm.ptr -> i64
%723 = llvm.getelementptr %484[%722] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%721 = llvm.load %723 : !llvm.ptr -> i64
%724 = arith.subi %718, %721 : i64
%725 = llvm.load %543 : !llvm.ptr -> i64
%726 = llvm.getelementptr %534[%725] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %724, %726 : i64, !llvm.ptr
%727 = llvm.load %543 : !llvm.ptr -> i64
%728 = arith.constant 1 : i32
%730 = arith.extsi %728 : i32 to i64
%729 = arith.addi %727, %730 : i64
llvm.store %729, %543 : i64, !llvm.ptr
cf.br ^bb122
^bb124:
%731 = arith.constant 0 : i32
%732 = arith.extsi %731 : i32 to i64
llvm.store %732, %543 : i64, !llvm.ptr
cf.br ^bb125
^bb125:
%733 = llvm.load %543 : !llvm.ptr -> i64
%734 = arith.constant 1 : i32
%736 = arith.extsi %734 : i32 to i64
%735 = arith.subi %483, %736 : i64
%737 = arith.cmpi slt, %733, %735 : i64
cf.cond_br %737, ^bb126, ^bb127
^bb126:
cf.br ^bb128
^bb128:
%739 = llvm.load %543 : !llvm.ptr -> i64
%740 = llvm.getelementptr %534[%739] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%738 = llvm.load %740 : !llvm.ptr -> i64
%741 = arith.constant 0 : i32
%743 = arith.extsi %741 : i32 to i64
%742 = arith.cmpi slt, %738, %743 : i64
cf.cond_br %742, ^bb129, ^bb130
^bb129:
%745 = llvm.load %543 : !llvm.ptr -> i64
%746 = llvm.getelementptr %534[%745] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%744 = llvm.load %746 : !llvm.ptr -> i64
%747 = arith.addi %744, %481 : i64
%748 = llvm.load %543 : !llvm.ptr -> i64
%749 = llvm.getelementptr %534[%748] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %747, %749 : i64, !llvm.ptr
%751 = llvm.load %543 : !llvm.ptr -> i64
%752 = arith.constant 1 : i32
%754 = arith.extsi %752 : i32 to i64
%753 = arith.addi %751, %754 : i64
%755 = llvm.getelementptr %534[%753] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%750 = llvm.load %755 : !llvm.ptr -> i64
%756 = arith.constant 1 : i32
%758 = arith.extsi %756 : i32 to i64
%757 = arith.subi %750, %758 : i64
%759 = llvm.load %543 : !llvm.ptr -> i64
%760 = arith.constant 1 : i32
%762 = arith.extsi %760 : i32 to i64
%761 = arith.addi %759, %762 : i64
%763 = llvm.getelementptr %534[%761] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %757, %763 : i64, !llvm.ptr
cf.br ^bb128
^bb130:
%764 = llvm.load %543 : !llvm.ptr -> i64
%765 = arith.constant 1 : i32
%767 = arith.extsi %765 : i32 to i64
%766 = arith.addi %764, %767 : i64
llvm.store %766, %543 : i64, !llvm.ptr
cf.br ^bb125
^bb127:
%768 = arith.constant 0 : i32
%769 = arith.extsi %768 : i32 to i64
llvm.store %769, %543 : i64, !llvm.ptr
cf.br ^bb131
^bb131:
%770 = llvm.load %543 : !llvm.ptr -> i64
%771 = arith.cmpi slt, %770, %483 : i64
cf.cond_br %771, ^bb132, ^bb133
^bb132:
%773 = llvm.load %543 : !llvm.ptr -> i64
%774 = llvm.getelementptr %534[%773] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%772 = llvm.load %774 : !llvm.ptr -> i64
%775 = llvm.load %543 : !llvm.ptr -> i64
%776 = llvm.getelementptr %484[%775] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %772, %776 : i64, !llvm.ptr
%777 = llvm.load %543 : !llvm.ptr -> i64
%778 = arith.constant 1 : i32
%780 = arith.extsi %778 : i32 to i64
%779 = arith.addi %777, %780 : i64
llvm.store %779, %543 : i64, !llvm.ptr
cf.br ^bb131
^bb133:
%781 = llvm.load %521 : !llvm.ptr -> i32
llvm.store %781, %489 : i32, !llvm.ptr
cf.br ^bb107
^bb107:
cf.br ^bb92
^bb92:
func.call @free(%534) : (!llvm.ptr) -> ()
cf.br ^bb80
^bb79:
cf.br ^bb80
^bb80:
%783 = arith.constant 1 : i32
%785 = arith.extsi %783 : i32 to i64
%784 = arith.addi %498, %785 : i64
llvm.store %784, %493 : i64, !llvm.ptr
cf.br ^bb75
^bb77:
%786 = func.call @bi_to_i64(%484, %483, %481) : (!llvm.ptr, i64, i64) -> i64
%787 = llvm.mlir.constant(1 : i64) : i64
%788 = llvm.alloca %787 x i64 : (i64) -> !llvm.ptr
llvm.store %786, %788 : i64, !llvm.ptr
%789 = llvm.load %489 : !llvm.ptr -> i32
%790 = arith.constant 0 : i32
%791 = arith.cmpi slt, %789, %790 : i32
cf.cond_br %791, ^bb134, ^bb135
^bb134:
%792 = llvm.load %788 : !llvm.ptr -> i64
%794 = arith.constant 0 : i64
%793 = arith.subi %794, %792 : i64
llvm.store %793, %788 : i64, !llvm.ptr
cf.br ^bb136
^bb135:
cf.br ^bb136
^bb136:
%795 = llvm.mlir.addressof @str_0 : !llvm.ptr
%796 = llvm.load %788 : !llvm.ptr -> i64
%797 = llvm.call @printf(%795, %796) vararg(!llvm.func<i32 (ptr, ...)>) : (!llvm.ptr, i64) -> i32
func.call @free(%352) : (!llvm.ptr) -> ()
func.call @free(%358) : (!llvm.ptr) -> ()
func.call @free(%364) : (!llvm.ptr) -> ()
func.call @free(%370) : (!llvm.ptr) -> ()
func.call @free(%484) : (!llvm.ptr) -> ()
%803 = arith.constant 0 : i32
func.return %803 : i32
}
}