← All problems
Problem 296
Count triangles with BE = ac/(a+b) integer, perimeter <= 100000.
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 296
# Count triangles with BE = ac/(a+b) integer, perimeter <= 100000.
extern {
function calloc(n: i64, size: i64) -> ptr<void>
function free(p: ptr<void>) -> void
}
function floor_sum(n0: i64, m0: i64, a0: i64, b0: i64) -> i64 {
let mut total: i64 = 0
let mut n: i64 = n0
let mut m: i64 = m0
let mut a: i64 = a0
let mut b: i64 = b0
while true {
if a >= m {
total = total + (n - 1) * n * (a / m) / 2
a = a % m
}
if b >= m {
total = total + n * (b / m)
b = b % m
}
let y: i64 = a * n + b
if y < m {
return total
}
n = y / m
b = y % m
let tmp: i64 = m
m = a
a = tmp
}
return total
}
function main() -> i32 {
let limit: i64 = 100000
let max_q: i64 = limit / 3
let mu: ptr<i32> = calloc(max_q + 1, 4)
let is_comp: ptr<i8> = calloc(max_q + 1, 1)
let primes: ptr<i64> = calloc(max_q / 5 + 10, 8)
mu[1] = 1
let mut pc: i64 = 0
for n in 2..(max_q + 1) {
if is_comp[n] == 0 {
primes[pc] = n
pc = pc + 1
mu[n] = -1
}
let mi: i32 = mu[n]
let mut j: i64 = 0
while j < pc {
let p: i64 = primes[j]
if p > max_q / n { break }
let ip: i64 = n * p
is_comp[ip] = 1
if n % p == 0 {
mu[ip] = 0
break
}
mu[ip] = 0 - mi
j = j + 1
}
}
# divisors[q] stored as flat: first count, then pairs (d, mu) in separate arrays via CSR
let offs: ptr<i64> = calloc(max_q + 2, 8)
for d in 1..(max_q + 1) {
if mu[d] != 0 {
for mult in d..(max_q + 1) step d {
offs[mult + 1] = offs[mult + 1] + 1
}
}
}
for i in 1..(max_q + 2) {
offs[i] = offs[i] + offs[i - 1]
}
let total_pairs: i64 = offs[max_q + 1]
let ds: ptr<i64> = calloc(total_pairs, 8)
let ms: ptr<i32> = calloc(total_pairs, 4)
let cur: ptr<i64> = calloc(max_q + 1, 8)
for i in 0..(max_q + 1) {
cur[i] = offs[i]
}
for d in 1..(max_q + 1) {
if mu[d] != 0 {
for mult in d..(max_q + 1) step d {
let at: i64 = cur[mult]
ds[at] = d
ms[at] = mu[d]
cur[mult] = at + 1
}
}
}
let mut count: i64 = 0
for q in 2..(max_q + 1) {
let max_g_plus_k: i64 = limit / q
let half_q: i64 = q / 2
let start: i64 = offs[q]
let end: i64 = offs[q + 1]
# reduced_up_to_half = sum mu*(half_q//d)
let mut reduced_up_to_half: i64 = 0
for t in start..end {
reduced_up_to_half = reduced_up_to_half + (ms[t] as i64) * (half_q / ds[t])
}
for g in 2..max_g_plus_k {
let mut min_h: i64 = 1
let alt: i64 = 2 * g - max_g_plus_k
if alt > min_h { min_h = alt }
let before: i64 = (min_h * q + g - 1) / g - 1
if before < half_q {
let mut coprime_before: i64 = 0
let mut floor_half: i64 = 0
let mut floor_before: i64 = 0
for t in start..end {
let dd: i64 = ds[t]
let mmu: i64 = ms[t] as i64
coprime_before = coprime_before + mmu * (before / dd)
let n1: i64 = half_q / dd
if n1 > 0 {
floor_half = floor_half + mmu * floor_sum(n1 + 1, q / dd, g, 0)
}
let n2: i64 = before / dd
if n2 > 0 {
floor_before = floor_before + mmu * floor_sum(n2 + 1, q / dd, g, 0)
}
}
let reduced_count: i64 = reduced_up_to_half - coprime_before
let floor_part: i64 = floor_half - floor_before
count = count + floor_part - (min_h - 1) * reduced_count
}
}
}
printf("%lld\n", count)
free(mu); free(is_comp); free(primes); free(offs); free(ds); free(ms); free(cur)
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 floor_sum_i64_i64_i64_i64(int64_t n0, int64_t m0, int64_t a0, int64_t b0);
int32_t main(void);
int64_t floor_sum_i64_i64_i64_i64(int64_t n0, int64_t m0, int64_t a0, int64_t b0) {
int64_t total = 0;
int64_t n = n0;
int64_t m = m0;
int64_t a = a0;
int64_t b = b0;
while (1) {
if (a >= m) {
total = (total + FLOW_CHECKED_DIV(((((n - 1) * n) * FLOW_CHECKED_DIV((a), (m)))), (2)));
a = FLOW_CHECKED_MOD((a), (m));
}
if (b >= m) {
total = (total + (n * FLOW_CHECKED_DIV((b), (m))));
b = FLOW_CHECKED_MOD((b), (m));
}
int64_t y = ((a * n) + b);
if (y < m) {
return total;
}
n = FLOW_CHECKED_DIV((y), (m));
b = FLOW_CHECKED_MOD((y), (m));
int64_t tmp = m;
m = a;
a = tmp;
}
return total;
}
int32_t main(void) {
int64_t limit = 100000;
int64_t max_q = FLOW_CHECKED_DIV((limit), (3));
int32_t* mu = (int32_t*)(calloc((max_q + 1), 4));
int8_t* is_comp = (int8_t*)(calloc((max_q + 1), 1));
int64_t* primes = (int64_t*)(calloc((FLOW_CHECKED_DIV((max_q), (5)) + 10), 8));
mu[1] = 1;
int64_t pc = 0;
int32_t __flow_step_1 = 1;
for (int32_t n = 2; (2 <= (max_q + 1)) ? n < (max_q + 1) : n > (max_q + 1); n += (2 <= (max_q + 1)) ? 1 : -1) {
if (is_comp[n] == 0) {
primes[pc] = n;
pc = (pc + 1);
mu[n] = (-1);
}
int32_t mi = mu[n];
int64_t j = 0;
while (j < pc) {
int64_t p = primes[j];
if (p > FLOW_CHECKED_DIV((max_q), (n))) {
break;
}
int64_t ip = (n * p);
is_comp[ip] = 1;
if (FLOW_CHECKED_MOD((n), (p)) == 0) {
mu[ip] = 0;
break;
}
mu[ip] = (0 - mi);
j = (j + 1);
}
}
int64_t* offs = (int64_t*)(calloc((max_q + 2), 8));
int32_t __flow_step_2 = 1;
for (int32_t d = 1; (1 <= (max_q + 1)) ? d < (max_q + 1) : d > (max_q + 1); d += (1 <= (max_q + 1)) ? 1 : -1) {
if (mu[d] != 0) {
int32_t __flow_step_3 = d;
#pragma clang loop vectorize(enable) interleave(enable)
#pragma GCC ivdep
for (int32_t mult = d; (__flow_step_3 > 0) ? mult < (max_q + 1) : mult > (max_q + 1); mult += __flow_step_3) {
offs[(mult + 1)] = (offs[(mult + 1)] + 1);
}
}
}
int32_t __flow_step_4 = 1;
for (int32_t i = 1; (1 <= (max_q + 2)) ? i < (max_q + 2) : i > (max_q + 2); i += (1 <= (max_q + 2)) ? 1 : -1) {
offs[i] = (offs[i] + offs[(i - 1)]);
}
int64_t total_pairs = offs[(max_q + 1)];
int64_t* ds = (int64_t*)(calloc(total_pairs, 8));
int32_t* ms = (int32_t*)(calloc(total_pairs, 4));
int64_t* cur = (int64_t*)(calloc((max_q + 1), 8));
int32_t __flow_step_5 = 1;
for (int32_t i = 0; (0 <= (max_q + 1)) ? i < (max_q + 1) : i > (max_q + 1); i += (0 <= (max_q + 1)) ? 1 : -1) {
cur[i] = offs[i];
}
int32_t __flow_step_6 = 1;
for (int32_t d = 1; (1 <= (max_q + 1)) ? d < (max_q + 1) : d > (max_q + 1); d += (1 <= (max_q + 1)) ? 1 : -1) {
if (mu[d] != 0) {
int32_t __flow_step_7 = d;
#pragma clang loop vectorize(enable) interleave(enable)
#pragma GCC ivdep
for (int32_t mult = d; (__flow_step_7 > 0) ? mult < (max_q + 1) : mult > (max_q + 1); mult += __flow_step_7) {
int64_t at = cur[mult];
ds[at] = d;
ms[at] = mu[d];
cur[mult] = (at + 1);
}
}
}
int64_t count = 0;
int32_t __flow_step_8 = 1;
for (int32_t q = 2; (2 <= (max_q + 1)) ? q < (max_q + 1) : q > (max_q + 1); q += (2 <= (max_q + 1)) ? 1 : -1) {
int64_t max_g_plus_k = FLOW_CHECKED_DIV((limit), (q));
int64_t half_q = FLOW_CHECKED_DIV((q), (2));
int64_t start = offs[q];
int64_t end = offs[(q + 1)];
int64_t reduced_up_to_half = 0;
int32_t __flow_step_9 = 1;
for (int32_t t = start; (start <= end) ? t < end : t > end; t += (start <= end) ? 1 : -1) {
reduced_up_to_half = (reduced_up_to_half + (((int64_t)(ms[t])) * FLOW_CHECKED_DIV((half_q), (ds[t]))));
}
int32_t __flow_step_10 = 1;
for (int32_t g = 2; (2 <= max_g_plus_k) ? g < max_g_plus_k : g > max_g_plus_k; g += (2 <= max_g_plus_k) ? 1 : -1) {
int64_t min_h = 1;
int64_t alt = ((2 * g) - max_g_plus_k);
if (alt > min_h) {
min_h = alt;
}
int64_t before = (FLOW_CHECKED_DIV(((((min_h * q) + g) - 1)), (g)) - 1);
if (before < half_q) {
int64_t coprime_before = 0;
int64_t floor_half = 0;
int64_t floor_before = 0;
int32_t __flow_step_11 = 1;
for (int32_t t = start; (start <= end) ? t < end : t > end; t += (start <= end) ? 1 : -1) {
int64_t dd = ds[t];
int64_t mmu = ((int64_t)(ms[t]));
coprime_before = (coprime_before + (mmu * FLOW_CHECKED_DIV((before), (dd))));
int64_t n1 = FLOW_CHECKED_DIV((half_q), (dd));
if (n1 > 0) {
floor_half = (floor_half + (mmu * floor_sum_i64_i64_i64_i64((n1 + 1), FLOW_CHECKED_DIV((q), (dd)), g, 0)));
}
int64_t n2 = FLOW_CHECKED_DIV((before), (dd));
if (n2 > 0) {
floor_before = (floor_before + (mmu * floor_sum_i64_i64_i64_i64((n2 + 1), FLOW_CHECKED_DIV((q), (dd)), g, 0)));
}
}
int64_t reduced_count = (reduced_up_to_half - coprime_before);
int64_t floor_part = (floor_half - floor_before);
count = ((count + floor_part) - ((min_h - 1) * reduced_count));
}
}
}
printf("%lld\n", count);
free(mu);
free(is_comp);
free(primes);
free(offs);
free(ds);
free(ms);
free(cur);
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 @floor_sum(%arg0: i64, %arg1: i64, %arg2: i64, %arg3: 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 = llvm.mlir.constant(1 : i64) : i64
%5 = llvm.alloca %4 x i64 : (i64) -> !llvm.ptr
llvm.store %arg0, %5 : i64, !llvm.ptr
%6 = llvm.mlir.constant(1 : i64) : i64
%7 = llvm.alloca %6 x i64 : (i64) -> !llvm.ptr
llvm.store %arg1, %7 : i64, !llvm.ptr
%8 = llvm.mlir.constant(1 : i64) : i64
%9 = llvm.alloca %8 x i64 : (i64) -> !llvm.ptr
llvm.store %arg2, %9 : i64, !llvm.ptr
%10 = llvm.mlir.constant(1 : i64) : i64
%11 = llvm.alloca %10 x i64 : (i64) -> !llvm.ptr
llvm.store %arg3, %11 : i64, !llvm.ptr
cf.br ^bb0
^bb0:
%12 = arith.constant 1 : i1
cf.cond_br %12, ^bb1, ^bb2
^bb1:
%13 = llvm.load %9 : !llvm.ptr -> i64
%14 = llvm.load %7 : !llvm.ptr -> i64
%15 = arith.cmpi sge, %13, %14 : i64
cf.cond_br %15, ^bb3, ^bb4
^bb3:
%16 = llvm.load %3 : !llvm.ptr -> i64
%17 = llvm.load %5 : !llvm.ptr -> i64
%18 = arith.constant 1 : i32
%20 = arith.extsi %18 : i32 to i64
%19 = arith.subi %17, %20 : i64
%21 = llvm.load %5 : !llvm.ptr -> i64
%22 = arith.muli %19, %21 : i64
%23 = llvm.load %9 : !llvm.ptr -> i64
%24 = llvm.load %7 : !llvm.ptr -> i64
%25 = arith.divsi %23, %24 : i64
%26 = arith.muli %22, %25 : i64
%27 = arith.constant 2 : i32
%29 = arith.extsi %27 : i32 to i64
%28 = arith.divsi %26, %29 : i64
%30 = arith.addi %16, %28 : i64
llvm.store %30, %3 : i64, !llvm.ptr
%31 = llvm.load %9 : !llvm.ptr -> i64
%32 = llvm.load %7 : !llvm.ptr -> i64
%33 = arith.remsi %31, %32 : i64
llvm.store %33, %9 : i64, !llvm.ptr
cf.br ^bb5
^bb4:
cf.br ^bb5
^bb5:
%34 = llvm.load %11 : !llvm.ptr -> i64
%35 = llvm.load %7 : !llvm.ptr -> i64
%36 = arith.cmpi sge, %34, %35 : i64
cf.cond_br %36, ^bb6, ^bb7
^bb6:
%37 = llvm.load %3 : !llvm.ptr -> i64
%38 = llvm.load %5 : !llvm.ptr -> i64
%39 = llvm.load %11 : !llvm.ptr -> i64
%40 = llvm.load %7 : !llvm.ptr -> i64
%41 = arith.divsi %39, %40 : i64
%42 = arith.muli %38, %41 : i64
%43 = arith.addi %37, %42 : i64
llvm.store %43, %3 : i64, !llvm.ptr
%44 = llvm.load %11 : !llvm.ptr -> i64
%45 = llvm.load %7 : !llvm.ptr -> i64
%46 = arith.remsi %44, %45 : i64
llvm.store %46, %11 : i64, !llvm.ptr
cf.br ^bb8
^bb7:
cf.br ^bb8
^bb8:
%47 = llvm.load %9 : !llvm.ptr -> i64
%48 = llvm.load %5 : !llvm.ptr -> i64
%49 = arith.muli %47, %48 : i64
%50 = llvm.load %11 : !llvm.ptr -> i64
%51 = arith.addi %49, %50 : i64
%52 = llvm.load %7 : !llvm.ptr -> i64
%53 = arith.cmpi slt, %51, %52 : i64
cf.cond_br %53, ^bb9, ^bb10
^bb9:
%54 = llvm.load %3 : !llvm.ptr -> i64
func.return %54 : i64
^bb10:
cf.br ^bb11
^bb11:
%55 = llvm.load %7 : !llvm.ptr -> i64
%56 = arith.divsi %51, %55 : i64
llvm.store %56, %5 : i64, !llvm.ptr
%57 = llvm.load %7 : !llvm.ptr -> i64
%58 = arith.remsi %51, %57 : i64
llvm.store %58, %11 : i64, !llvm.ptr
%59 = llvm.load %7 : !llvm.ptr -> i64
%60 = llvm.load %9 : !llvm.ptr -> i64
llvm.store %60, %7 : i64, !llvm.ptr
llvm.store %59, %9 : i64, !llvm.ptr
cf.br ^bb0
^bb2:
%61 = llvm.load %3 : !llvm.ptr -> i64
func.return %61 : i64
}
func.func @main() -> i32 {
%62 = arith.constant 100000 : i32
%63 = arith.extsi %62 : i32 to i64
%64 = arith.constant 3 : i32
%66 = arith.extsi %64 : i32 to i64
%65 = arith.divsi %63, %66 : i64
%68 = arith.constant 1 : i32
%70 = arith.extsi %68 : i32 to i64
%69 = arith.addi %65, %70 : i64
%71 = arith.constant 4 : i32
%72 = arith.extsi %71 : i32 to i64
%67 = func.call @calloc(%69, %72) : (i64, i64) -> !llvm.ptr
%74 = arith.constant 1 : i32
%76 = arith.extsi %74 : i32 to i64
%75 = arith.addi %65, %76 : i64
%77 = arith.constant 1 : i32
%78 = arith.extsi %77 : i32 to i64
%73 = func.call @calloc(%75, %78) : (i64, i64) -> !llvm.ptr
%80 = arith.constant 5 : i32
%82 = arith.extsi %80 : i32 to i64
%81 = arith.divsi %65, %82 : i64
%83 = arith.constant 10 : i32
%85 = arith.extsi %83 : i32 to i64
%84 = arith.addi %81, %85 : i64
%86 = arith.constant 8 : i32
%87 = arith.extsi %86 : i32 to i64
%79 = func.call @calloc(%84, %87) : (i64, i64) -> !llvm.ptr
%88 = arith.constant 1 : i32
%89 = arith.constant 1 : i32
%90 = arith.extsi %89 : i32 to i64
%91 = llvm.getelementptr %67[%90] : (!llvm.ptr, i64) -> !llvm.ptr, i32
llvm.store %88, %91 : i32, !llvm.ptr
%92 = arith.constant 0 : i32
%93 = arith.extsi %92 : i32 to i64
%94 = llvm.mlir.constant(1 : i64) : i64
%95 = llvm.alloca %94 x i64 : (i64) -> !llvm.ptr
llvm.store %93, %95 : i64, !llvm.ptr
%96 = arith.constant 2 : i32
%97 = arith.constant 1 : i32
%99 = arith.extsi %97 : i32 to i64
%98 = arith.addi %65, %99 : i64
%100 = arith.index_cast %96 : i32 to index
%101 = arith.index_cast %98 : i32 to index
%103 = arith.constant 1 : index
%104 = arith.constant -1 : index
%105 = arith.cmpi sle, %100, %101 : index
%102 = arith.select %105, %103, %104 : index
cf.br ^bb12(%100 : index)
^bb12(%106: index):
%107 = arith.cmpi slt, %106, %101 : index
%108 = arith.cmpi sgt, %106, %101 : index
%109 = arith.select %105, %107, %108 : i1
cf.cond_br %109, ^bb13(%106 : index), ^bb14(%106 : index)
^bb13(%110: index):
%112 = arith.index_cast %110 : index to i64
%113 = llvm.getelementptr %73[%112] : (!llvm.ptr, i64) -> !llvm.ptr, i8
%111 = llvm.load %113 : !llvm.ptr -> i8
%114 = arith.constant 0 : i32
%116 = arith.extsi %111 : i8 to i32
%115 = arith.cmpi eq, %116, %114 : i32
cf.cond_br %115, ^bb15, ^bb16
^bb15:
%117 = llvm.load %95 : !llvm.ptr -> i64
%118 = arith.index_cast %110 : index to i64
%119 = llvm.getelementptr %79[%117] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %118, %119 : i64, !llvm.ptr
%120 = llvm.load %95 : !llvm.ptr -> i64
%121 = arith.constant 1 : i32
%123 = arith.extsi %121 : i32 to i64
%122 = arith.addi %120, %123 : i64
llvm.store %122, %95 : i64, !llvm.ptr
%124 = arith.constant 1 : i32
%126 = arith.constant 0 : i32
%125 = arith.subi %126, %124 : i32
%127 = arith.index_cast %110 : index to i64
%128 = llvm.getelementptr %67[%127] : (!llvm.ptr, i64) -> !llvm.ptr, i32
llvm.store %125, %128 : i32, !llvm.ptr
cf.br ^bb17
^bb16:
cf.br ^bb17
^bb17:
%130 = arith.index_cast %110 : index to i64
%131 = llvm.getelementptr %67[%130] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%129 = llvm.load %131 : !llvm.ptr -> i32
%132 = arith.constant 0 : i32
%133 = arith.extsi %132 : i32 to i64
%134 = llvm.mlir.constant(1 : i64) : i64
%135 = llvm.alloca %134 x i64 : (i64) -> !llvm.ptr
llvm.store %133, %135 : i64, !llvm.ptr
cf.br ^bb18
^bb18:
%136 = llvm.load %135 : !llvm.ptr -> i64
%137 = llvm.load %95 : !llvm.ptr -> i64
%138 = arith.cmpi slt, %136, %137 : i64
cf.cond_br %138, ^bb19, ^bb20
^bb19:
%140 = llvm.load %135 : !llvm.ptr -> i64
%141 = llvm.getelementptr %79[%140] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%139 = llvm.load %141 : !llvm.ptr -> i64
%143 = arith.trunci %65 : i64 to i32
%144 = arith.index_cast %110 : index to i32
%142 = arith.divsi %143, %144 : i32
%146 = arith.extsi %142 : i32 to i64
%145 = arith.cmpi sgt, %139, %146 : i64
cf.cond_br %145, ^bb21, ^bb22
^bb21:
cf.br ^bb20
^bb22:
cf.br ^bb23
^bb23:
%148 = arith.index_cast %110 : index to i32
%149 = arith.trunci %139 : i64 to i32
%147 = arith.muli %148, %149 : i32
%150 = arith.extsi %147 : i32 to i64
%151 = arith.constant 1 : i32
%152 = arith.trunci %151 : i32 to i8
%153 = llvm.getelementptr %73[%150] : (!llvm.ptr, i64) -> !llvm.ptr, i8
llvm.store %152, %153 : i8, !llvm.ptr
%155 = arith.index_cast %110 : index to i32
%156 = arith.trunci %139 : i64 to i32
%154 = arith.remsi %155, %156 : i32
%157 = arith.constant 0 : i32
%158 = arith.cmpi eq, %154, %157 : i32
cf.cond_br %158, ^bb24, ^bb25
^bb24:
%159 = arith.constant 0 : i32
%160 = llvm.getelementptr %67[%150] : (!llvm.ptr, i64) -> !llvm.ptr, i32
llvm.store %159, %160 : i32, !llvm.ptr
cf.br ^bb20
^bb25:
cf.br ^bb26
^bb26:
%161 = arith.constant 0 : i32
%162 = arith.subi %161, %129 : i32
%163 = llvm.getelementptr %67[%150] : (!llvm.ptr, i64) -> !llvm.ptr, i32
llvm.store %162, %163 : i32, !llvm.ptr
%164 = llvm.load %135 : !llvm.ptr -> i64
%165 = arith.constant 1 : i32
%167 = arith.extsi %165 : i32 to i64
%166 = arith.addi %164, %167 : i64
llvm.store %166, %135 : i64, !llvm.ptr
cf.br ^bb18
^bb20:
%168 = arith.addi %110, %102 : index
cf.br ^bb12(%168 : index)
^bb14(%169: index):
%171 = arith.constant 2 : i32
%173 = arith.extsi %171 : i32 to i64
%172 = arith.addi %65, %173 : i64
%174 = arith.constant 8 : i32
%175 = arith.extsi %174 : i32 to i64
%170 = func.call @calloc(%172, %175) : (i64, i64) -> !llvm.ptr
%176 = arith.constant 1 : i32
%177 = arith.constant 1 : i32
%179 = arith.extsi %177 : i32 to i64
%178 = arith.addi %65, %179 : i64
%180 = arith.index_cast %176 : i32 to index
%181 = arith.index_cast %178 : i32 to index
%183 = arith.constant 1 : index
%184 = arith.constant -1 : index
%185 = arith.cmpi sle, %180, %181 : index
%182 = arith.select %185, %183, %184 : index
cf.br ^bb27(%180 : index)
^bb27(%186: index):
%187 = arith.cmpi slt, %186, %181 : index
%188 = arith.cmpi sgt, %186, %181 : index
%189 = arith.select %185, %187, %188 : i1
cf.cond_br %189, ^bb28(%186 : index), ^bb29(%186 : index)
^bb28(%190: index):
%192 = arith.index_cast %190 : index to i64
%193 = llvm.getelementptr %67[%192] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%191 = llvm.load %193 : !llvm.ptr -> i32
%194 = arith.constant 0 : i32
%195 = arith.cmpi ne, %191, %194 : i32
cf.cond_br %195, ^bb30, ^bb31
^bb30:
%196 = arith.constant 1 : i32
%198 = arith.extsi %196 : i32 to i64
%197 = arith.addi %65, %198 : i64
%199 = arith.index_cast %190 : i32 to index
%200 = arith.index_cast %197 : i32 to index
%201 = arith.index_cast %190 : i32 to index
%202 = arith.constant 0 : index
%203 = arith.cmpi sgt, %201, %202 : index
cf.br ^bb33(%199 : index)
^bb33(%204: index):
%205 = arith.cmpi slt, %204, %200 : index
%206 = arith.cmpi sgt, %204, %200 : index
%207 = arith.select %203, %205, %206 : i1
cf.cond_br %207, ^bb34(%204 : index), ^bb35(%204 : index)
^bb34(%208: index):
%210 = arith.constant 1 : i32
%212 = arith.index_cast %208 : index to i32
%211 = arith.addi %212, %210 : i32
%213 = arith.extsi %211 : i32 to i64
%214 = llvm.getelementptr %170[%213] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%209 = llvm.load %214 : !llvm.ptr -> i64
%215 = arith.constant 1 : i32
%217 = arith.extsi %215 : i32 to i64
%216 = arith.addi %209, %217 : i64
%218 = arith.constant 1 : i32
%220 = arith.index_cast %208 : index to i32
%219 = arith.addi %220, %218 : i32
%221 = arith.extsi %219 : i32 to i64
%222 = llvm.getelementptr %170[%221] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %216, %222 : i64, !llvm.ptr
%223 = arith.addi %208, %201 : index
cf.br ^bb33(%223 : index)
^bb35(%224: index):
cf.br ^bb32
^bb31:
cf.br ^bb32
^bb32:
%225 = arith.addi %190, %182 : index
cf.br ^bb27(%225 : index)
^bb29(%226: index):
%227 = arith.constant 1 : i32
%228 = arith.constant 2 : i32
%230 = arith.extsi %228 : i32 to i64
%229 = arith.addi %65, %230 : i64
%231 = arith.index_cast %227 : i32 to index
%232 = arith.index_cast %229 : i32 to index
%234 = arith.constant 1 : index
%235 = arith.constant -1 : index
%236 = arith.cmpi sle, %231, %232 : index
%233 = arith.select %236, %234, %235 : index
cf.br ^bb36(%231 : index)
^bb36(%237: index):
%238 = arith.cmpi slt, %237, %232 : index
%239 = arith.cmpi sgt, %237, %232 : index
%240 = arith.select %236, %238, %239 : i1
cf.cond_br %240, ^bb37(%237 : index), ^bb38(%237 : index)
^bb37(%241: index):
%243 = arith.index_cast %241 : index to i64
%244 = llvm.getelementptr %170[%243] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%242 = llvm.load %244 : !llvm.ptr -> i64
%246 = arith.constant 1 : i32
%248 = arith.index_cast %241 : index to i32
%247 = arith.subi %248, %246 : i32
%249 = arith.extsi %247 : i32 to i64
%250 = llvm.getelementptr %170[%249] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%245 = llvm.load %250 : !llvm.ptr -> i64
%251 = arith.addi %242, %245 : i64
%252 = arith.index_cast %241 : index to i64
%253 = llvm.getelementptr %170[%252] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %251, %253 : i64, !llvm.ptr
%254 = arith.addi %241, %233 : index
cf.br ^bb36(%254 : index)
^bb38(%255: index):
%257 = arith.constant 1 : i32
%259 = arith.extsi %257 : i32 to i64
%258 = arith.addi %65, %259 : i64
%260 = llvm.getelementptr %170[%258] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%256 = llvm.load %260 : !llvm.ptr -> i64
%262 = arith.constant 8 : i32
%263 = arith.extsi %262 : i32 to i64
%261 = func.call @calloc(%256, %263) : (i64, i64) -> !llvm.ptr
%265 = arith.constant 4 : i32
%266 = arith.extsi %265 : i32 to i64
%264 = func.call @calloc(%256, %266) : (i64, i64) -> !llvm.ptr
%268 = arith.constant 1 : i32
%270 = arith.extsi %268 : i32 to i64
%269 = arith.addi %65, %270 : i64
%271 = arith.constant 8 : i32
%272 = arith.extsi %271 : i32 to i64
%267 = func.call @calloc(%269, %272) : (i64, i64) -> !llvm.ptr
%273 = arith.constant 0 : i32
%274 = arith.constant 1 : i32
%276 = arith.extsi %274 : i32 to i64
%275 = arith.addi %65, %276 : i64
%277 = arith.index_cast %273 : i32 to index
%278 = arith.index_cast %275 : i32 to index
%280 = arith.constant 1 : index
%281 = arith.constant -1 : index
%282 = arith.cmpi sle, %277, %278 : index
%279 = arith.select %282, %280, %281 : index
cf.br ^bb39(%277 : index)
^bb39(%283: index):
%284 = arith.cmpi slt, %283, %278 : index
%285 = arith.cmpi sgt, %283, %278 : index
%286 = arith.select %282, %284, %285 : i1
cf.cond_br %286, ^bb40(%283 : index), ^bb41(%283 : index)
^bb40(%287: index):
%289 = arith.index_cast %287 : index to i64
%290 = llvm.getelementptr %170[%289] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%288 = llvm.load %290 : !llvm.ptr -> i64
%291 = arith.index_cast %287 : index to i64
%292 = llvm.getelementptr %267[%291] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %288, %292 : i64, !llvm.ptr
%293 = arith.addi %287, %279 : index
cf.br ^bb39(%293 : index)
^bb41(%294: index):
%295 = arith.constant 1 : i32
%296 = arith.constant 1 : i32
%298 = arith.extsi %296 : i32 to i64
%297 = arith.addi %65, %298 : i64
%299 = arith.index_cast %295 : i32 to index
%300 = arith.index_cast %297 : i32 to index
%302 = arith.constant 1 : index
%303 = arith.constant -1 : index
%304 = arith.cmpi sle, %299, %300 : index
%301 = arith.select %304, %302, %303 : index
cf.br ^bb42(%299 : index)
^bb42(%305: index):
%306 = arith.cmpi slt, %305, %300 : index
%307 = arith.cmpi sgt, %305, %300 : index
%308 = arith.select %304, %306, %307 : i1
cf.cond_br %308, ^bb43(%305 : index), ^bb44(%305 : index)
^bb43(%309: index):
%311 = arith.index_cast %309 : index to i64
%312 = llvm.getelementptr %67[%311] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%310 = llvm.load %312 : !llvm.ptr -> i32
%313 = arith.constant 0 : i32
%314 = arith.cmpi ne, %310, %313 : i32
cf.cond_br %314, ^bb45, ^bb46
^bb45:
%315 = arith.constant 1 : i32
%317 = arith.extsi %315 : i32 to i64
%316 = arith.addi %65, %317 : i64
%318 = arith.index_cast %309 : i32 to index
%319 = arith.index_cast %316 : i32 to index
%320 = arith.index_cast %309 : i32 to index
%321 = arith.constant 0 : index
%322 = arith.cmpi sgt, %320, %321 : index
cf.br ^bb48(%318 : index)
^bb48(%323: index):
%324 = arith.cmpi slt, %323, %319 : index
%325 = arith.cmpi sgt, %323, %319 : index
%326 = arith.select %322, %324, %325 : i1
cf.cond_br %326, ^bb49(%323 : index), ^bb50(%323 : index)
^bb49(%327: index):
%329 = arith.index_cast %327 : index to i64
%330 = llvm.getelementptr %267[%329] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%328 = llvm.load %330 : !llvm.ptr -> i64
%331 = arith.index_cast %309 : index to i64
%332 = llvm.getelementptr %261[%328] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %331, %332 : i64, !llvm.ptr
%334 = arith.index_cast %309 : index to i64
%335 = llvm.getelementptr %67[%334] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%333 = llvm.load %335 : !llvm.ptr -> i32
%336 = llvm.getelementptr %264[%328] : (!llvm.ptr, i64) -> !llvm.ptr, i32
llvm.store %333, %336 : i32, !llvm.ptr
%337 = arith.constant 1 : i32
%339 = arith.extsi %337 : i32 to i64
%338 = arith.addi %328, %339 : i64
%340 = arith.index_cast %327 : index to i64
%341 = llvm.getelementptr %267[%340] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %338, %341 : i64, !llvm.ptr
%342 = arith.addi %327, %320 : index
cf.br ^bb48(%342 : index)
^bb50(%343: index):
cf.br ^bb47
^bb46:
cf.br ^bb47
^bb47:
%344 = arith.addi %309, %301 : index
cf.br ^bb42(%344 : index)
^bb44(%345: index):
%346 = arith.constant 0 : i32
%347 = arith.extsi %346 : i32 to i64
%348 = llvm.mlir.constant(1 : i64) : i64
%349 = llvm.alloca %348 x i64 : (i64) -> !llvm.ptr
llvm.store %347, %349 : i64, !llvm.ptr
%350 = arith.constant 2 : i32
%351 = arith.constant 1 : i32
%353 = arith.extsi %351 : i32 to i64
%352 = arith.addi %65, %353 : i64
%354 = arith.index_cast %350 : i32 to index
%355 = arith.index_cast %352 : i32 to index
%357 = arith.constant 1 : index
%358 = arith.constant -1 : index
%359 = arith.cmpi sle, %354, %355 : index
%356 = arith.select %359, %357, %358 : index
cf.br ^bb51(%354 : index)
^bb51(%360: index):
%361 = arith.cmpi slt, %360, %355 : index
%362 = arith.cmpi sgt, %360, %355 : index
%363 = arith.select %359, %361, %362 : i1
cf.cond_br %363, ^bb52(%360 : index), ^bb53(%360 : index)
^bb52(%364: index):
%366 = arith.trunci %63 : i64 to i32
%367 = arith.index_cast %364 : index to i32
%365 = arith.divsi %366, %367 : i32
%368 = arith.extsi %365 : i32 to i64
%369 = arith.constant 2 : i32
%371 = arith.index_cast %364 : index to i32
%370 = arith.divsi %371, %369 : i32
%372 = arith.extsi %370 : i32 to i64
%374 = arith.index_cast %364 : index to i64
%375 = llvm.getelementptr %170[%374] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%373 = llvm.load %375 : !llvm.ptr -> i64
%377 = arith.constant 1 : i32
%379 = arith.index_cast %364 : index to i32
%378 = arith.addi %379, %377 : i32
%380 = arith.extsi %378 : i32 to i64
%381 = llvm.getelementptr %170[%380] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%376 = llvm.load %381 : !llvm.ptr -> i64
%382 = arith.constant 0 : i32
%383 = arith.extsi %382 : i32 to i64
%384 = llvm.mlir.constant(1 : i64) : i64
%385 = llvm.alloca %384 x i64 : (i64) -> !llvm.ptr
llvm.store %383, %385 : i64, !llvm.ptr
%386 = arith.index_cast %373 : i32 to index
%387 = arith.index_cast %376 : i32 to index
%389 = arith.constant 1 : index
%390 = arith.constant -1 : index
%391 = arith.cmpi sle, %386, %387 : index
%388 = arith.select %391, %389, %390 : index
cf.br ^bb54(%386 : index)
^bb54(%392: index):
%393 = arith.cmpi slt, %392, %387 : index
%394 = arith.cmpi sgt, %392, %387 : index
%395 = arith.select %391, %393, %394 : i1
cf.cond_br %395, ^bb55(%392 : index), ^bb56(%392 : index)
^bb55(%396: index):
%397 = llvm.load %385 : !llvm.ptr -> i64
%399 = arith.index_cast %396 : index to i64
%400 = llvm.getelementptr %264[%399] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%398 = llvm.load %400 : !llvm.ptr -> i32
%401 = arith.extsi %398 : i32 to i64
%403 = arith.index_cast %396 : index to i64
%404 = llvm.getelementptr %261[%403] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%402 = llvm.load %404 : !llvm.ptr -> i64
%405 = arith.divsi %372, %402 : i64
%406 = arith.muli %401, %405 : i64
%407 = arith.addi %397, %406 : i64
llvm.store %407, %385 : i64, !llvm.ptr
%408 = arith.addi %396, %388 : index
cf.br ^bb54(%408 : index)
^bb56(%409: index):
%410 = arith.constant 2 : i32
%411 = arith.index_cast %410 : i32 to index
%412 = arith.index_cast %368 : i32 to index
%414 = arith.constant 1 : index
%415 = arith.constant -1 : index
%416 = arith.cmpi sle, %411, %412 : index
%413 = arith.select %416, %414, %415 : index
cf.br ^bb57(%411 : index)
^bb57(%417: index):
%418 = arith.cmpi slt, %417, %412 : index
%419 = arith.cmpi sgt, %417, %412 : index
%420 = arith.select %416, %418, %419 : i1
cf.cond_br %420, ^bb58(%417 : index), ^bb59(%417 : index)
^bb58(%421: index):
%422 = arith.constant 1 : i32
%423 = arith.extsi %422 : i32 to i64
%424 = llvm.mlir.constant(1 : i64) : i64
%425 = llvm.alloca %424 x i64 : (i64) -> !llvm.ptr
llvm.store %423, %425 : i64, !llvm.ptr
%426 = arith.constant 2 : i32
%428 = arith.index_cast %421 : index to i32
%427 = arith.muli %426, %428 : i32
%430 = arith.extsi %427 : i32 to i64
%429 = arith.subi %430, %368 : i64
%431 = llvm.load %425 : !llvm.ptr -> i64
%432 = arith.cmpi sgt, %429, %431 : i64
cf.cond_br %432, ^bb60, ^bb61
^bb60:
llvm.store %429, %425 : i64, !llvm.ptr
cf.br ^bb62
^bb61:
cf.br ^bb62
^bb62:
%433 = llvm.load %425 : !llvm.ptr -> i64
%435 = arith.trunci %433 : i64 to i32
%436 = arith.index_cast %364 : index to i32
%434 = arith.muli %435, %436 : i32
%438 = arith.index_cast %421 : index to i32
%437 = arith.addi %434, %438 : i32
%439 = arith.constant 1 : i32
%440 = arith.subi %437, %439 : i32
%442 = arith.index_cast %421 : index to i32
%441 = arith.divsi %440, %442 : i32
%443 = arith.constant 1 : i32
%444 = arith.subi %441, %443 : i32
%445 = arith.extsi %444 : i32 to i64
%446 = arith.cmpi slt, %445, %372 : i64
cf.cond_br %446, ^bb63, ^bb64
^bb63:
%447 = arith.constant 0 : i32
%448 = arith.extsi %447 : i32 to i64
%449 = llvm.mlir.constant(1 : i64) : i64
%450 = llvm.alloca %449 x i64 : (i64) -> !llvm.ptr
llvm.store %448, %450 : i64, !llvm.ptr
%451 = arith.constant 0 : i32
%452 = arith.extsi %451 : i32 to i64
%453 = llvm.mlir.constant(1 : i64) : i64
%454 = llvm.alloca %453 x i64 : (i64) -> !llvm.ptr
llvm.store %452, %454 : i64, !llvm.ptr
%455 = arith.constant 0 : i32
%456 = arith.extsi %455 : i32 to i64
%457 = llvm.mlir.constant(1 : i64) : i64
%458 = llvm.alloca %457 x i64 : (i64) -> !llvm.ptr
llvm.store %456, %458 : i64, !llvm.ptr
%459 = arith.index_cast %373 : i32 to index
%460 = arith.index_cast %376 : i32 to index
%462 = arith.constant 1 : index
%463 = arith.constant -1 : index
%464 = arith.cmpi sle, %459, %460 : index
%461 = arith.select %464, %462, %463 : index
cf.br ^bb66(%459 : index)
^bb66(%465: index):
%466 = arith.cmpi slt, %465, %460 : index
%467 = arith.cmpi sgt, %465, %460 : index
%468 = arith.select %464, %466, %467 : i1
cf.cond_br %468, ^bb67(%465 : index), ^bb68(%465 : index)
^bb67(%469: index):
%471 = arith.index_cast %469 : index to i64
%472 = llvm.getelementptr %261[%471] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%470 = llvm.load %472 : !llvm.ptr -> i64
%474 = arith.index_cast %469 : index to i64
%475 = llvm.getelementptr %264[%474] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%473 = llvm.load %475 : !llvm.ptr -> i32
%476 = arith.extsi %473 : i32 to i64
%477 = llvm.load %450 : !llvm.ptr -> i64
%478 = arith.divsi %445, %470 : i64
%479 = arith.muli %476, %478 : i64
%480 = arith.addi %477, %479 : i64
llvm.store %480, %450 : i64, !llvm.ptr
%481 = arith.divsi %372, %470 : i64
%482 = arith.constant 0 : i32
%484 = arith.extsi %482 : i32 to i64
%483 = arith.cmpi sgt, %481, %484 : i64
cf.cond_br %483, ^bb69, ^bb70
^bb69:
%485 = llvm.load %454 : !llvm.ptr -> i64
%487 = arith.constant 1 : i32
%489 = arith.extsi %487 : i32 to i64
%488 = arith.addi %481, %489 : i64
%491 = arith.index_cast %364 : index to i32
%492 = arith.trunci %470 : i64 to i32
%490 = arith.divsi %491, %492 : i32
%493 = arith.constant 0 : i32
%494 = arith.extsi %490 : i32 to i64
%495 = arith.index_cast %421 : index to i64
%496 = arith.extsi %493 : i32 to i64
%486 = func.call @floor_sum(%488, %494, %495, %496) : (i64, i64, i64, i64) -> i64
%497 = arith.muli %476, %486 : i64
%498 = arith.addi %485, %497 : i64
llvm.store %498, %454 : i64, !llvm.ptr
cf.br ^bb71
^bb70:
cf.br ^bb71
^bb71:
%499 = arith.divsi %445, %470 : i64
%500 = arith.constant 0 : i32
%502 = arith.extsi %500 : i32 to i64
%501 = arith.cmpi sgt, %499, %502 : i64
cf.cond_br %501, ^bb72, ^bb73
^bb72:
%503 = llvm.load %458 : !llvm.ptr -> i64
%505 = arith.constant 1 : i32
%507 = arith.extsi %505 : i32 to i64
%506 = arith.addi %499, %507 : i64
%509 = arith.index_cast %364 : index to i32
%510 = arith.trunci %470 : i64 to i32
%508 = arith.divsi %509, %510 : i32
%511 = arith.constant 0 : i32
%512 = arith.extsi %508 : i32 to i64
%513 = arith.index_cast %421 : index to i64
%514 = arith.extsi %511 : i32 to i64
%504 = func.call @floor_sum(%506, %512, %513, %514) : (i64, i64, i64, i64) -> i64
%515 = arith.muli %476, %504 : i64
%516 = arith.addi %503, %515 : i64
llvm.store %516, %458 : i64, !llvm.ptr
cf.br ^bb74
^bb73:
cf.br ^bb74
^bb74:
%517 = arith.addi %469, %461 : index
cf.br ^bb66(%517 : index)
^bb68(%518: index):
%519 = llvm.load %385 : !llvm.ptr -> i64
%520 = llvm.load %450 : !llvm.ptr -> i64
%521 = arith.subi %519, %520 : i64
%522 = llvm.load %454 : !llvm.ptr -> i64
%523 = llvm.load %458 : !llvm.ptr -> i64
%524 = arith.subi %522, %523 : i64
%525 = llvm.load %349 : !llvm.ptr -> i64
%526 = arith.addi %525, %524 : i64
%527 = llvm.load %425 : !llvm.ptr -> i64
%528 = arith.constant 1 : i32
%530 = arith.extsi %528 : i32 to i64
%529 = arith.subi %527, %530 : i64
%531 = arith.muli %529, %521 : i64
%532 = arith.subi %526, %531 : i64
llvm.store %532, %349 : i64, !llvm.ptr
cf.br ^bb65
^bb64:
cf.br ^bb65
^bb65:
%533 = arith.addi %421, %413 : index
cf.br ^bb57(%533 : index)
^bb59(%534: index):
%535 = arith.addi %364, %356 : index
cf.br ^bb51(%535 : index)
^bb53(%536: index):
%537 = llvm.mlir.addressof @str_0 : !llvm.ptr
%538 = llvm.load %349 : !llvm.ptr -> i64
%539 = llvm.call @printf(%537, %538) vararg(!llvm.func<i32 (ptr, ...)>) : (!llvm.ptr, i64) -> i32
func.call @free(%67) : (!llvm.ptr) -> ()
func.call @free(%73) : (!llvm.ptr) -> ()
func.call @free(%79) : (!llvm.ptr) -> ()
func.call @free(%170) : (!llvm.ptr) -> ()
func.call @free(%261) : (!llvm.ptr) -> ()
func.call @free(%264) : (!llvm.ptr) -> ()
func.call @free(%267) : (!llvm.ptr) -> ()
%547 = arith.constant 0 : i32
func.return %547 : i32
}
}