Problem 314
Maximize Area/Perimeter of wall on 500x500 posts (symmetry n=250).
View problem on Project Euler
Performance comparison
| Metric | Our solution | Best known |
| Time complexity | O(n^4) | O(n^2) |
| Space complexity | O(n^2) | O(n^2) |
| Approach | Flow solution | Combinatorial or DP counting |
| Verdict | Suboptimal |
Flow source
# Project Euler 314
# Maximize Area/Perimeter of wall on 500x500 posts (symmetry n=250).
extern {
function calloc(n: i64, size: i64) -> ptr<void>
function free(p: ptr<void>) -> void
function sqrt(x: f64) -> f64
function fabs(x: f64) -> f64
}
function main() -> i32 {
let n: i64 = 250
let dist: ptr<f64> = calloc((n + 1) * (n + 1), 8)
let mut dx: i64 = 0
while dx <= n {
let mut dy: i64 = 0
while dy <= n {
dist[dx * (n + 1) + dy] = sqrt((dx * dx + dy * dy) as f64)
dy = dy + 1
}
dx = dx + 1
}
let NEG: f64 = -1.0e300
let dp: ptr<f64> = calloc((n + 1) * (n + 1), 8)
let parx: ptr<i16> = calloc((n + 1) * (n + 1), 2)
let pary: ptr<i16> = calloc((n + 1) * (n + 1), 2)
let best: ptr<f64> = calloc(n + 1, 8)
let best_px: ptr<i16> = calloc(n + 1, 2)
let best_py: ptr<i16> = calloc(n + 1, 2)
let sites: ptr<i32> = calloc(n + 1, 4)
let vals: ptr<f64> = calloc(n + 1, 8)
let starts: ptr<i32> = calloc(n + 1, 4)
# initial r from triangle cut example
let mut r: f64 = 238750.0 / (1400.0 + 300.0 * sqrt(2.0))
let mut iter: i64 = 0
while iter < 20 {
let mut y: i64 = 0
while y <= n {
dp[0 * (n + 1) + y] = -r * (y as f64)
y = y + 1
}
let mut i: i64 = 1
while i <= n {
y = 0
while y <= n {
best[y] = NEG
best_px[y] = -1
best_py[y] = -1
y = y + 1
}
let mut x: i64 = 0
while x < i {
let dxi: i64 = i - x
let halfdx: f64 = 0.5 * (dxi as f64)
let mut sc: i64 = 0
y = 0
while y <= n {
let v: f64 = dp[x * (n + 1) + y]
if v > NEG / 2.0 {
let Sy: f64 = v + halfdx * (y as f64)
if sc == 0 {
sites[0] = y as i32; vals[0] = Sy; starts[0] = y as i32; sc = 1
} else {
while sc > 0 {
let y_last: i64 = sites[sc - 1] as i64
let S_last: f64 = vals[sc - 1]
# intersect
let k: i64 = y - y_last
let dS: f64 = Sy - S_last
let mut j0: i64 = y
if dS < 0.0 {
if dS + r * (k as f64) <= 0.0 {
j0 = n + 1
} else {
let C: f64 = (S_last - Sy) / r
let A: f64 = (k * k) as f64 - C * C
let u: f64 = (-(k as f64) + C * sqrt(1.0 + 4.0 * (dxi * dxi) as f64 / A)) * 0.5
j0 = y + (u as i64)
if j0 < y { j0 = y }
while j0 <= n {
let fb: f64 = Sy - r * dist[dxi * (n + 1) + (j0 - y)]
let fa: f64 = S_last - r * dist[dxi * (n + 1) + (j0 - y_last)]
if fb >= fa - 1e-13 { break }
j0 = j0 + 1
}
if j0 > n { j0 = n + 1 }
}
}
if j0 <= (starts[sc - 1] as i64) { sc = sc - 1 }
else {
sites[sc] = y as i32; vals[sc] = Sy; starts[sc] = j0 as i32; sc = sc + 1
break
}
}
if sc == 0 {
sites[0] = y as i32; vals[0] = Sy; starts[0] = y as i32; sc = 1
}
}
}
y = y + 1
}
let mut idx: i64 = 0
let mut j: i64 = 0
while j <= n {
while idx + 1 < sc && j >= (starts[idx + 1] as i64) { idx = idx + 1 }
let yb: i64 = sites[idx] as i64
if yb <= j {
let score: f64 = vals[idx] - r * dist[dxi * (n + 1) + (j - yb)] + halfdx * (j as f64)
if score > best[j] {
best[j] = score
best_px[j] = x as i16
best_py[j] = yb as i16
}
}
j = j + 1
}
x = x + 1
}
y = 0
while y <= n {
dp[i * (n + 1) + y] = best[y]
parx[i * (n + 1) + y] = best_px[y]
pary[i * (n + 1) + y] = best_py[y]
y = y + 1
}
i = i + 1
}
# reconstruct
let pathx: ptr<i32> = calloc(n + 2, 4)
let pathy: ptr<i32> = calloc(n + 2, 4)
let mut k: i64 = 0
let mut cx: i64 = n
let mut cy: i64 = n
while cx != 0 {
pathx[k] = cx as i32
pathy[k] = cy as i32
let px: i64 = parx[cx * (n + 1) + cy] as i64
let py: i64 = pary[cx * (n + 1) + cy] as i64
cx = px
cy = py
k = k + 1
}
pathx[k] = 0
pathy[k] = cy as i32
k = k + 1
# reverse
let mut t: i64 = 0
while t < k / 2 {
let tx: i32 = pathx[t]; let ty: i32 = pathy[t]
pathx[t] = pathx[k - 1 - t]; pathy[t] = pathy[k - 1 - t]
pathx[k - 1 - t] = tx; pathy[k - 1 - t] = ty
t = t + 1
}
let mut area: f64 = 0.0
let mut peri: f64 = pathy[0] as f64
t = 0
while t < k - 1 {
let x1: i64 = pathx[t] as i64
let y1: i64 = pathy[t] as i64
let x2: i64 = pathx[t + 1] as i64
let y2: i64 = pathy[t + 1] as i64
let ddx: i64 = x2 - x1
let mut ddy: i64 = y2 - y1
if ddy < 0 { ddy = -ddy }
area = area + ((y1 + y2) as f64) * (ddx as f64) * 0.5
peri = peri + dist[ddx * (n + 1) + ddy]
t = t + 1
}
let new_r: f64 = area / peri
if fabs(new_r - r) < 5e-13 {
r = new_r
free(pathx); free(pathy)
break
}
r = new_r
free(pathx); free(pathy)
iter = iter + 1
}
# full figure is 4x quadrant area/peri ratio same
printf("%.8f\n", r)
free(dist); free(dp); free(parx); free(pary); free(best); free(best_px); free(best_py)
free(sites); free(vals); free(starts)
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; }
int32_t main(void);
int32_t main(void) {
int64_t n = 250;
double* dist = (double*)(calloc(((n + 1) * (n + 1)), 8));
int64_t dx = 0;
while (dx <= n) {
int64_t dy = 0;
while (dy <= n) {
dist[((dx * (n + 1)) + dy)] = sqrt(((double)(((dx * dx) + (dy * dy)))));
dy = (dy + 1);
}
dx = (dx + 1);
}
double NEG = (-1.0e300);
double* dp = (double*)(calloc(((n + 1) * (n + 1)), 8));
int16_t* parx = (int16_t*)(calloc(((n + 1) * (n + 1)), 2));
int16_t* pary = (int16_t*)(calloc(((n + 1) * (n + 1)), 2));
double* best = (double*)(calloc((n + 1), 8));
int16_t* best_px = (int16_t*)(calloc((n + 1), 2));
int16_t* best_py = (int16_t*)(calloc((n + 1), 2));
int32_t* sites = (int32_t*)(calloc((n + 1), 4));
double* vals = (double*)(calloc((n + 1), 8));
int32_t* starts = (int32_t*)(calloc((n + 1), 4));
double r = (238750.0 / (1400.0 + (300.0 * sqrt(2.0))));
int64_t iter = 0;
while (iter < 20) {
int64_t y = 0;
while (y <= n) {
dp[((0 * (n + 1)) + y)] = ((-r) * ((double)(y)));
y = (y + 1);
}
int64_t i = 1;
while (i <= n) {
y = 0;
while (y <= n) {
best[y] = NEG;
best_px[y] = (-1);
best_py[y] = (-1);
y = (y + 1);
}
int64_t x = 0;
while (x < i) {
int64_t dxi = (i - x);
double halfdx = (0.5 * ((double)(dxi)));
int64_t sc = 0;
y = 0;
while (y <= n) {
double v = dp[((x * (n + 1)) + y)];
if (v > (NEG / 2.0)) {
double Sy = (v + (halfdx * ((double)(y))));
if (sc == 0) {
sites[0] = ((int32_t)(y));
vals[0] = Sy;
starts[0] = ((int32_t)(y));
sc = 1;
} else {
while (sc > 0) {
int64_t y_last = ((int64_t)(sites[(sc - 1)]));
double S_last = vals[(sc - 1)];
int64_t k = (y - y_last);
double dS = (Sy - S_last);
int64_t j0 = y;
if (dS < 0.0) {
if ((dS + (r * ((double)(k)))) <= 0.0) {
j0 = (n + 1);
} else {
double C = ((S_last - Sy) / r);
double A = (((double)((k * k))) - (C * C));
double u = (((-((double)(k))) + (C * sqrt((1.0 + ((4.0 * ((double)((dxi * dxi)))) / A))))) * 0.5);
j0 = (y + ((int64_t)(u)));
if (j0 < y) {
j0 = y;
}
while (j0 <= n) {
double fb = (Sy - (r * dist[((dxi * (n + 1)) + (j0 - y))]));
double fa = (S_last - (r * dist[((dxi * (n + 1)) + (j0 - y_last))]));
if (fb >= (fa - 1e-13)) {
break;
}
j0 = (j0 + 1);
}
if (j0 > n) {
j0 = (n + 1);
}
}
}
if (j0 <= ((int64_t)(starts[(sc - 1)]))) {
sc = (sc - 1);
} else {
sites[sc] = ((int32_t)(y));
vals[sc] = Sy;
starts[sc] = ((int32_t)(j0));
sc = (sc + 1);
break;
}
}
if (sc == 0) {
sites[0] = ((int32_t)(y));
vals[0] = Sy;
starts[0] = ((int32_t)(y));
sc = 1;
}
}
}
y = (y + 1);
}
int64_t idx = 0;
int64_t j = 0;
while (j <= n) {
while (((idx + 1) < sc && j >= ((int64_t)(starts[(idx + 1)])))) {
idx = (idx + 1);
}
int64_t yb = ((int64_t)(sites[idx]));
if (yb <= j) {
double score = ((vals[idx] - (r * dist[((dxi * (n + 1)) + (j - yb))])) + (halfdx * ((double)(j))));
if (score > best[j]) {
best[j] = score;
best_px[j] = ((int16_t)(x));
best_py[j] = ((int16_t)(yb));
}
}
j = (j + 1);
}
x = (x + 1);
}
y = 0;
while (y <= n) {
dp[((i * (n + 1)) + y)] = best[y];
parx[((i * (n + 1)) + y)] = best_px[y];
pary[((i * (n + 1)) + y)] = best_py[y];
y = (y + 1);
}
i = (i + 1);
}
int32_t* pathx = (int32_t*)(calloc((n + 2), 4));
int32_t* pathy = (int32_t*)(calloc((n + 2), 4));
int64_t k = 0;
int64_t cx = n;
int64_t cy = n;
while (cx != 0) {
pathx[k] = ((int32_t)(cx));
pathy[k] = ((int32_t)(cy));
int64_t px = ((int64_t)(parx[((cx * (n + 1)) + cy)]));
int64_t py = ((int64_t)(pary[((cx * (n + 1)) + cy)]));
cx = px;
cy = py;
k = (k + 1);
}
pathx[k] = 0;
pathy[k] = ((int32_t)(cy));
k = (k + 1);
int64_t t = 0;
while (t < FLOW_CHECKED_DIV((k), (2))) {
int32_t tx = pathx[t];
int32_t ty = pathy[t];
pathx[t] = pathx[((k - 1) - t)];
pathy[t] = pathy[((k - 1) - t)];
pathx[((k - 1) - t)] = tx;
pathy[((k - 1) - t)] = ty;
t = (t + 1);
}
double area = 0.0;
double peri = ((double)(pathy[0]));
t = 0;
while (t < (k - 1)) {
int64_t x1 = ((int64_t)(pathx[t]));
int64_t y1 = ((int64_t)(pathy[t]));
int64_t x2 = ((int64_t)(pathx[(t + 1)]));
int64_t y2 = ((int64_t)(pathy[(t + 1)]));
int64_t ddx = (x2 - x1);
int64_t ddy = (y2 - y1);
if (ddy < 0) {
ddy = (-ddy);
}
area = (area + ((((double)((y1 + y2))) * ((double)(ddx))) * 0.5));
peri = (peri + dist[((ddx * (n + 1)) + ddy)]);
t = (t + 1);
}
double new_r = (area / peri);
if (fabs((new_r - r)) < 5e-13) {
r = new_r;
free(pathx);
free(pathy);
break;
}
r = new_r;
free(pathx);
free(pathy);
iter = (iter + 1);
}
printf("%.8f\n", r);
free(dist);
free(dp);
free(parx);
free(pary);
free(best);
free(best_px);
free(best_py);
free(sites);
free(vals);
free(starts);
return 0;
}
Generated MLIR
module {
llvm.func @printf(!llvm.ptr, ...) -> i32
llvm.mlir.global internal constant @str_0("%.8f\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 private @sqrt(f64) -> f64
func.func private @fabs(f64) -> f64
func.func @main() -> i32 {
%0 = arith.constant 250 : i32
%1 = arith.extsi %0 : i32 to i64
%3 = arith.constant 1 : i32
%5 = arith.extsi %3 : i32 to i64
%4 = arith.addi %1, %5 : i64
%6 = arith.constant 1 : i32
%8 = arith.extsi %6 : i32 to i64
%7 = arith.addi %1, %8 : i64
%9 = arith.muli %4, %7 : i64
%10 = arith.constant 8 : i32
%11 = arith.extsi %10 : i32 to i64
%2 = func.call @calloc(%9, %11) : (i64, i64) -> !llvm.ptr
%12 = arith.constant 0 : i32
%13 = arith.extsi %12 : i32 to i64
%14 = llvm.mlir.constant(1 : i64) : i64
%15 = llvm.alloca %14 x i64 : (i64) -> !llvm.ptr
llvm.store %13, %15 : i64, !llvm.ptr
cf.br ^bb0
^bb0:
%16 = llvm.load %15 : !llvm.ptr -> i64
%17 = arith.cmpi sle, %16, %1 : i64
cf.cond_br %17, ^bb1, ^bb2
^bb1:
%18 = arith.constant 0 : i32
%19 = arith.extsi %18 : i32 to i64
%20 = llvm.mlir.constant(1 : i64) : i64
%21 = llvm.alloca %20 x i64 : (i64) -> !llvm.ptr
llvm.store %19, %21 : i64, !llvm.ptr
cf.br ^bb3
^bb3:
%22 = llvm.load %21 : !llvm.ptr -> i64
%23 = arith.cmpi sle, %22, %1 : i64
cf.cond_br %23, ^bb4, ^bb5
^bb4:
%24 = llvm.load %15 : !llvm.ptr -> i64
%25 = llvm.load %15 : !llvm.ptr -> i64
%26 = arith.muli %24, %25 : i64
%27 = llvm.load %21 : !llvm.ptr -> i64
%28 = llvm.load %21 : !llvm.ptr -> i64
%29 = arith.muli %27, %28 : i64
%30 = arith.addi %26, %29 : i64
%31 = arith.sitofp %30 : i64 to f64
%32 = math.sqrt %31 : f64
%33 = llvm.load %15 : !llvm.ptr -> i64
%34 = arith.constant 1 : i32
%36 = arith.extsi %34 : i32 to i64
%35 = arith.addi %1, %36 : i64
%37 = arith.muli %33, %35 : i64
%38 = llvm.load %21 : !llvm.ptr -> i64
%39 = arith.addi %37, %38 : i64
%40 = llvm.getelementptr %2[%39] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %32, %40 : f64, !llvm.ptr
%41 = llvm.load %21 : !llvm.ptr -> i64
%42 = arith.constant 1 : i32
%44 = arith.extsi %42 : i32 to i64
%43 = arith.addi %41, %44 : i64
llvm.store %43, %21 : i64, !llvm.ptr
cf.br ^bb3
^bb5:
%45 = llvm.load %15 : !llvm.ptr -> i64
%46 = arith.constant 1 : i32
%48 = arith.extsi %46 : i32 to i64
%47 = arith.addi %45, %48 : i64
llvm.store %47, %15 : i64, !llvm.ptr
cf.br ^bb0
^bb2:
%49 = arith.constant 1000000000000000052504760255204420248704468581108159154915854115511802457988908195786371375080447864043704443832883878176942523235360430575644792184786706982848387200926575803737830233794788090059368953234970799945081119038967640880074652742780142494579258788820056842838115669472196386865459400540160 : f32
%50 = arith.negf %49 : f32
%51 = arith.extf %50 : f32 to f64
%53 = arith.constant 1 : i32
%55 = arith.extsi %53 : i32 to i64
%54 = arith.addi %1, %55 : i64
%56 = arith.constant 1 : i32
%58 = arith.extsi %56 : i32 to i64
%57 = arith.addi %1, %58 : i64
%59 = arith.muli %54, %57 : i64
%60 = arith.constant 8 : i32
%61 = arith.extsi %60 : i32 to i64
%52 = func.call @calloc(%59, %61) : (i64, i64) -> !llvm.ptr
%63 = arith.constant 1 : i32
%65 = arith.extsi %63 : i32 to i64
%64 = arith.addi %1, %65 : i64
%66 = arith.constant 1 : i32
%68 = arith.extsi %66 : i32 to i64
%67 = arith.addi %1, %68 : i64
%69 = arith.muli %64, %67 : i64
%70 = arith.constant 2 : i32
%71 = arith.extsi %70 : i32 to i64
%62 = func.call @calloc(%69, %71) : (i64, i64) -> !llvm.ptr
%73 = arith.constant 1 : i32
%75 = arith.extsi %73 : i32 to i64
%74 = arith.addi %1, %75 : i64
%76 = arith.constant 1 : i32
%78 = arith.extsi %76 : i32 to i64
%77 = arith.addi %1, %78 : i64
%79 = arith.muli %74, %77 : i64
%80 = arith.constant 2 : i32
%81 = arith.extsi %80 : i32 to i64
%72 = func.call @calloc(%79, %81) : (i64, i64) -> !llvm.ptr
%83 = arith.constant 1 : i32
%85 = arith.extsi %83 : i32 to i64
%84 = arith.addi %1, %85 : i64
%86 = arith.constant 8 : i32
%87 = arith.extsi %86 : i32 to i64
%82 = func.call @calloc(%84, %87) : (i64, i64) -> !llvm.ptr
%89 = arith.constant 1 : i32
%91 = arith.extsi %89 : i32 to i64
%90 = arith.addi %1, %91 : i64
%92 = arith.constant 2 : i32
%93 = arith.extsi %92 : i32 to i64
%88 = func.call @calloc(%90, %93) : (i64, i64) -> !llvm.ptr
%95 = arith.constant 1 : i32
%97 = arith.extsi %95 : i32 to i64
%96 = arith.addi %1, %97 : i64
%98 = arith.constant 2 : i32
%99 = arith.extsi %98 : i32 to i64
%94 = func.call @calloc(%96, %99) : (i64, i64) -> !llvm.ptr
%101 = arith.constant 1 : i32
%103 = arith.extsi %101 : i32 to i64
%102 = arith.addi %1, %103 : i64
%104 = arith.constant 4 : i32
%105 = arith.extsi %104 : i32 to i64
%100 = func.call @calloc(%102, %105) : (i64, i64) -> !llvm.ptr
%107 = arith.constant 1 : i32
%109 = arith.extsi %107 : i32 to i64
%108 = arith.addi %1, %109 : i64
%110 = arith.constant 8 : i32
%111 = arith.extsi %110 : i32 to i64
%106 = func.call @calloc(%108, %111) : (i64, i64) -> !llvm.ptr
%113 = arith.constant 1 : i32
%115 = arith.extsi %113 : i32 to i64
%114 = arith.addi %1, %115 : i64
%116 = arith.constant 4 : i32
%117 = arith.extsi %116 : i32 to i64
%112 = func.call @calloc(%114, %117) : (i64, i64) -> !llvm.ptr
%118 = arith.constant 238750.0 : f32
%119 = arith.constant 1400.0 : f32
%120 = arith.constant 300.0 : f32
%121 = arith.constant 2.0 : f32
%122 = math.sqrt %121 : f32
%124 = arith.extf %120 : f32 to f64
%123 = arith.mulf %124, %122 : f64
%126 = arith.extf %119 : f32 to f64
%125 = arith.addf %126, %123 : f64
%128 = arith.extf %118 : f32 to f64
%127 = arith.divf %128, %125 : f64
%129 = llvm.mlir.constant(1 : i64) : i64
%130 = llvm.alloca %129 x f64 : (i64) -> !llvm.ptr
llvm.store %127, %130 : f64, !llvm.ptr
%131 = arith.constant 0 : i32
%132 = arith.extsi %131 : i32 to i64
%133 = llvm.mlir.constant(1 : i64) : i64
%134 = llvm.alloca %133 x i64 : (i64) -> !llvm.ptr
llvm.store %132, %134 : i64, !llvm.ptr
cf.br ^bb6
^bb6:
%135 = llvm.load %134 : !llvm.ptr -> i64
%136 = arith.constant 20 : i32
%138 = arith.extsi %136 : i32 to i64
%137 = arith.cmpi slt, %135, %138 : i64
cf.cond_br %137, ^bb7, ^bb8
^bb7:
%139 = arith.constant 0 : i32
%140 = arith.extsi %139 : i32 to i64
%141 = llvm.mlir.constant(1 : i64) : i64
%142 = llvm.alloca %141 x i64 : (i64) -> !llvm.ptr
llvm.store %140, %142 : i64, !llvm.ptr
cf.br ^bb9
^bb9:
%143 = llvm.load %142 : !llvm.ptr -> i64
%144 = arith.cmpi sle, %143, %1 : i64
cf.cond_br %144, ^bb10, ^bb11
^bb10:
%145 = llvm.load %130 : !llvm.ptr -> f64
%146 = arith.negf %145 : f64
%147 = llvm.load %142 : !llvm.ptr -> i64
%148 = arith.sitofp %147 : i64 to f64
%149 = arith.mulf %146, %148 : f64
%150 = arith.constant 0 : i32
%151 = arith.constant 1 : i32
%153 = arith.extsi %151 : i32 to i64
%152 = arith.addi %1, %153 : i64
%155 = arith.extsi %150 : i32 to i64
%154 = arith.muli %155, %152 : i64
%156 = llvm.load %142 : !llvm.ptr -> i64
%157 = arith.addi %154, %156 : i64
%158 = llvm.getelementptr %52[%157] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %149, %158 : f64, !llvm.ptr
%159 = llvm.load %142 : !llvm.ptr -> i64
%160 = arith.constant 1 : i32
%162 = arith.extsi %160 : i32 to i64
%161 = arith.addi %159, %162 : i64
llvm.store %161, %142 : i64, !llvm.ptr
cf.br ^bb9
^bb11:
%163 = arith.constant 1 : i32
%164 = arith.extsi %163 : i32 to i64
%165 = llvm.mlir.constant(1 : i64) : i64
%166 = llvm.alloca %165 x i64 : (i64) -> !llvm.ptr
llvm.store %164, %166 : i64, !llvm.ptr
cf.br ^bb12
^bb12:
%167 = llvm.load %166 : !llvm.ptr -> i64
%168 = arith.cmpi sle, %167, %1 : i64
cf.cond_br %168, ^bb13, ^bb14
^bb13:
%169 = arith.constant 0 : i32
%170 = arith.extsi %169 : i32 to i64
llvm.store %170, %142 : i64, !llvm.ptr
cf.br ^bb15
^bb15:
%171 = llvm.load %142 : !llvm.ptr -> i64
%172 = arith.cmpi sle, %171, %1 : i64
cf.cond_br %172, ^bb16, ^bb17
^bb16:
%173 = llvm.load %142 : !llvm.ptr -> i64
%174 = llvm.getelementptr %82[%173] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %51, %174 : f64, !llvm.ptr
%175 = arith.constant 1 : i32
%177 = arith.constant 0 : i32
%176 = arith.subi %177, %175 : i32
%178 = llvm.load %142 : !llvm.ptr -> i64
%179 = arith.trunci %176 : i32 to i16
%180 = llvm.getelementptr %88[%178] : (!llvm.ptr, i64) -> !llvm.ptr, i16
llvm.store %179, %180 : i16, !llvm.ptr
%181 = arith.constant 1 : i32
%183 = arith.constant 0 : i32
%182 = arith.subi %183, %181 : i32
%184 = llvm.load %142 : !llvm.ptr -> i64
%185 = arith.trunci %182 : i32 to i16
%186 = llvm.getelementptr %94[%184] : (!llvm.ptr, i64) -> !llvm.ptr, i16
llvm.store %185, %186 : i16, !llvm.ptr
%187 = llvm.load %142 : !llvm.ptr -> i64
%188 = arith.constant 1 : i32
%190 = arith.extsi %188 : i32 to i64
%189 = arith.addi %187, %190 : i64
llvm.store %189, %142 : i64, !llvm.ptr
cf.br ^bb15
^bb17:
%191 = arith.constant 0 : i32
%192 = arith.extsi %191 : i32 to i64
%193 = llvm.mlir.constant(1 : i64) : i64
%194 = llvm.alloca %193 x i64 : (i64) -> !llvm.ptr
llvm.store %192, %194 : i64, !llvm.ptr
cf.br ^bb18
^bb18:
%195 = llvm.load %194 : !llvm.ptr -> i64
%196 = llvm.load %166 : !llvm.ptr -> i64
%197 = arith.cmpi slt, %195, %196 : i64
cf.cond_br %197, ^bb19, ^bb20
^bb19:
%198 = llvm.load %166 : !llvm.ptr -> i64
%199 = llvm.load %194 : !llvm.ptr -> i64
%200 = arith.subi %198, %199 : i64
%201 = arith.constant 0.5 : f32
%202 = arith.sitofp %200 : i64 to f64
%204 = arith.extf %201 : f32 to f64
%203 = arith.mulf %204, %202 : f64
%205 = arith.constant 0 : i32
%206 = arith.extsi %205 : i32 to i64
%207 = llvm.mlir.constant(1 : i64) : i64
%208 = llvm.alloca %207 x i64 : (i64) -> !llvm.ptr
llvm.store %206, %208 : i64, !llvm.ptr
%209 = arith.constant 0 : i32
%210 = arith.extsi %209 : i32 to i64
llvm.store %210, %142 : i64, !llvm.ptr
cf.br ^bb21
^bb21:
%211 = llvm.load %142 : !llvm.ptr -> i64
%212 = arith.cmpi sle, %211, %1 : i64
cf.cond_br %212, ^bb22, ^bb23
^bb22:
%214 = llvm.load %194 : !llvm.ptr -> i64
%215 = arith.constant 1 : i32
%217 = arith.extsi %215 : i32 to i64
%216 = arith.addi %1, %217 : i64
%218 = arith.muli %214, %216 : i64
%219 = llvm.load %142 : !llvm.ptr -> i64
%220 = arith.addi %218, %219 : i64
%221 = llvm.getelementptr %52[%220] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%213 = llvm.load %221 : !llvm.ptr -> f64
%222 = arith.constant 2.0 : f32
%224 = arith.extf %222 : f32 to f64
%223 = arith.divf %51, %224 : f64
%225 = arith.cmpf ogt, %213, %223 : f64
cf.cond_br %225, ^bb24, ^bb25
^bb24:
%226 = llvm.load %142 : !llvm.ptr -> i64
%227 = arith.sitofp %226 : i64 to f64
%228 = arith.mulf %203, %227 : f64
%229 = arith.addf %213, %228 : f64
%230 = llvm.load %208 : !llvm.ptr -> i64
%231 = arith.constant 0 : i32
%233 = arith.extsi %231 : i32 to i64
%232 = arith.cmpi eq, %230, %233 : i64
cf.cond_br %232, ^bb27, ^bb28
^bb27:
%234 = llvm.load %142 : !llvm.ptr -> i64
%235 = arith.trunci %234 : i64 to i32
%236 = arith.constant 0 : i32
%237 = arith.extsi %236 : i32 to i64
%238 = llvm.getelementptr %100[%237] : (!llvm.ptr, i64) -> !llvm.ptr, i32
llvm.store %235, %238 : i32, !llvm.ptr
%239 = arith.constant 0 : i32
%240 = arith.extsi %239 : i32 to i64
%241 = llvm.getelementptr %106[%240] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %229, %241 : f64, !llvm.ptr
%242 = llvm.load %142 : !llvm.ptr -> i64
%243 = arith.trunci %242 : i64 to i32
%244 = arith.constant 0 : i32
%245 = arith.extsi %244 : i32 to i64
%246 = llvm.getelementptr %112[%245] : (!llvm.ptr, i64) -> !llvm.ptr, i32
llvm.store %243, %246 : i32, !llvm.ptr
%247 = arith.constant 1 : i32
%248 = arith.extsi %247 : i32 to i64
llvm.store %248, %208 : i64, !llvm.ptr
cf.br ^bb29
^bb28:
cf.br ^bb30
^bb30:
%249 = llvm.load %208 : !llvm.ptr -> i64
%250 = arith.constant 0 : i32
%252 = arith.extsi %250 : i32 to i64
%251 = arith.cmpi sgt, %249, %252 : i64
cf.cond_br %251, ^bb31, ^bb32
^bb31:
%254 = llvm.load %208 : !llvm.ptr -> i64
%255 = arith.constant 1 : i32
%257 = arith.extsi %255 : i32 to i64
%256 = arith.subi %254, %257 : i64
%258 = llvm.getelementptr %100[%256] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%253 = llvm.load %258 : !llvm.ptr -> i32
%259 = arith.extsi %253 : i32 to i64
%261 = llvm.load %208 : !llvm.ptr -> i64
%262 = arith.constant 1 : i32
%264 = arith.extsi %262 : i32 to i64
%263 = arith.subi %261, %264 : i64
%265 = llvm.getelementptr %106[%263] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%260 = llvm.load %265 : !llvm.ptr -> f64
%266 = llvm.load %142 : !llvm.ptr -> i64
%267 = arith.subi %266, %259 : i64
%268 = arith.subf %229, %260 : f64
%269 = llvm.load %142 : !llvm.ptr -> i64
%270 = llvm.mlir.constant(1 : i64) : i64
%271 = llvm.alloca %270 x i64 : (i64) -> !llvm.ptr
llvm.store %269, %271 : i64, !llvm.ptr
%272 = arith.constant 0.0 : f32
%274 = arith.extf %272 : f32 to f64
%273 = arith.cmpf olt, %268, %274 : f64
cf.cond_br %273, ^bb33, ^bb34
^bb33:
%275 = llvm.load %130 : !llvm.ptr -> f64
%276 = arith.sitofp %267 : i64 to f64
%277 = arith.mulf %275, %276 : f64
%278 = arith.addf %268, %277 : f64
%279 = arith.constant 0.0 : f32
%281 = arith.extf %279 : f32 to f64
%280 = arith.cmpf ole, %278, %281 : f64
cf.cond_br %280, ^bb36, ^bb37
^bb36:
%282 = arith.constant 1 : i32
%284 = arith.extsi %282 : i32 to i64
%283 = arith.addi %1, %284 : i64
llvm.store %283, %271 : i64, !llvm.ptr
cf.br ^bb38
^bb37:
%285 = arith.subf %260, %229 : f64
%286 = llvm.load %130 : !llvm.ptr -> f64
%287 = arith.divf %285, %286 : f64
%288 = arith.muli %267, %267 : i64
%289 = arith.sitofp %288 : i64 to f64
%290 = arith.mulf %287, %287 : f64
%291 = arith.subf %289, %290 : f64
%292 = arith.sitofp %267 : i64 to f64
%293 = arith.negf %292 : f64
%294 = arith.constant 1.0 : f32
%295 = arith.constant 4.0 : f32
%296 = arith.muli %200, %200 : i64
%297 = arith.sitofp %296 : i64 to f64
%299 = arith.extf %295 : f32 to f64
%298 = arith.mulf %299, %297 : f64
%300 = arith.divf %298, %291 : f64
%302 = arith.extf %294 : f32 to f64
%301 = arith.addf %302, %300 : f64
%303 = math.sqrt %301 : f64
%304 = arith.mulf %287, %303 : f64
%305 = arith.addf %293, %304 : f64
%306 = arith.constant 0.5 : f32
%308 = arith.extf %306 : f32 to f64
%307 = arith.mulf %305, %308 : f64
%309 = llvm.load %142 : !llvm.ptr -> i64
%310 = arith.fptosi %307 : f64 to i64
%311 = arith.addi %309, %310 : i64
llvm.store %311, %271 : i64, !llvm.ptr
%312 = llvm.load %271 : !llvm.ptr -> i64
%313 = llvm.load %142 : !llvm.ptr -> i64
%314 = arith.cmpi slt, %312, %313 : i64
cf.cond_br %314, ^bb39, ^bb40
^bb39:
%315 = llvm.load %142 : !llvm.ptr -> i64
llvm.store %315, %271 : i64, !llvm.ptr
cf.br ^bb41
^bb40:
cf.br ^bb41
^bb41:
cf.br ^bb42
^bb42:
%316 = llvm.load %271 : !llvm.ptr -> i64
%317 = arith.cmpi sle, %316, %1 : i64
cf.cond_br %317, ^bb43, ^bb44
^bb43:
%318 = llvm.load %130 : !llvm.ptr -> f64
%320 = arith.constant 1 : i32
%322 = arith.extsi %320 : i32 to i64
%321 = arith.addi %1, %322 : i64
%323 = arith.muli %200, %321 : i64
%324 = llvm.load %271 : !llvm.ptr -> i64
%325 = llvm.load %142 : !llvm.ptr -> i64
%326 = arith.subi %324, %325 : i64
%327 = arith.addi %323, %326 : i64
%328 = llvm.getelementptr %2[%327] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%319 = llvm.load %328 : !llvm.ptr -> f64
%329 = arith.mulf %318, %319 : f64
%330 = arith.subf %229, %329 : f64
%331 = llvm.load %130 : !llvm.ptr -> f64
%333 = arith.constant 1 : i32
%335 = arith.extsi %333 : i32 to i64
%334 = arith.addi %1, %335 : i64
%336 = arith.muli %200, %334 : i64
%337 = llvm.load %271 : !llvm.ptr -> i64
%338 = arith.subi %337, %259 : i64
%339 = arith.addi %336, %338 : i64
%340 = llvm.getelementptr %2[%339] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%332 = llvm.load %340 : !llvm.ptr -> f64
%341 = arith.mulf %331, %332 : f64
%342 = arith.subf %260, %341 : f64
%343 = arith.constant 0 : f32
%345 = arith.extf %343 : f32 to f64
%344 = arith.subf %342, %345 : f64
%346 = arith.cmpf oge, %330, %344 : f64
cf.cond_br %346, ^bb45, ^bb46
^bb45:
cf.br ^bb44
^bb46:
cf.br ^bb47
^bb47:
%347 = llvm.load %271 : !llvm.ptr -> i64
%348 = arith.constant 1 : i32
%350 = arith.extsi %348 : i32 to i64
%349 = arith.addi %347, %350 : i64
llvm.store %349, %271 : i64, !llvm.ptr
cf.br ^bb42
^bb44:
%351 = llvm.load %271 : !llvm.ptr -> i64
%352 = arith.cmpi sgt, %351, %1 : i64
cf.cond_br %352, ^bb48, ^bb49
^bb48:
%353 = arith.constant 1 : i32
%355 = arith.extsi %353 : i32 to i64
%354 = arith.addi %1, %355 : i64
llvm.store %354, %271 : i64, !llvm.ptr
cf.br ^bb50
^bb49:
cf.br ^bb50
^bb50:
cf.br ^bb38
^bb38:
cf.br ^bb35
^bb34:
cf.br ^bb35
^bb35:
%356 = llvm.load %271 : !llvm.ptr -> i64
%358 = llvm.load %208 : !llvm.ptr -> i64
%359 = arith.constant 1 : i32
%361 = arith.extsi %359 : i32 to i64
%360 = arith.subi %358, %361 : i64
%362 = llvm.getelementptr %112[%360] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%357 = llvm.load %362 : !llvm.ptr -> i32
%363 = arith.extsi %357 : i32 to i64
%364 = arith.cmpi sle, %356, %363 : i64
cf.cond_br %364, ^bb51, ^bb52
^bb51:
%365 = llvm.load %208 : !llvm.ptr -> i64
%366 = arith.constant 1 : i32
%368 = arith.extsi %366 : i32 to i64
%367 = arith.subi %365, %368 : i64
llvm.store %367, %208 : i64, !llvm.ptr
cf.br ^bb53
^bb52:
%369 = llvm.load %142 : !llvm.ptr -> i64
%370 = arith.trunci %369 : i64 to i32
%371 = llvm.load %208 : !llvm.ptr -> i64
%372 = llvm.getelementptr %100[%371] : (!llvm.ptr, i64) -> !llvm.ptr, i32
llvm.store %370, %372 : i32, !llvm.ptr
%373 = llvm.load %208 : !llvm.ptr -> i64
%374 = llvm.getelementptr %106[%373] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %229, %374 : f64, !llvm.ptr
%375 = llvm.load %271 : !llvm.ptr -> i64
%376 = arith.trunci %375 : i64 to i32
%377 = llvm.load %208 : !llvm.ptr -> i64
%378 = llvm.getelementptr %112[%377] : (!llvm.ptr, i64) -> !llvm.ptr, i32
llvm.store %376, %378 : i32, !llvm.ptr
%379 = llvm.load %208 : !llvm.ptr -> i64
%380 = arith.constant 1 : i32
%382 = arith.extsi %380 : i32 to i64
%381 = arith.addi %379, %382 : i64
llvm.store %381, %208 : i64, !llvm.ptr
cf.br ^bb32
^bb53:
cf.br ^bb30
^bb32:
%383 = llvm.load %208 : !llvm.ptr -> i64
%384 = arith.constant 0 : i32
%386 = arith.extsi %384 : i32 to i64
%385 = arith.cmpi eq, %383, %386 : i64
cf.cond_br %385, ^bb54, ^bb55
^bb54:
%387 = llvm.load %142 : !llvm.ptr -> i64
%388 = arith.trunci %387 : i64 to i32
%389 = arith.constant 0 : i32
%390 = arith.extsi %389 : i32 to i64
%391 = llvm.getelementptr %100[%390] : (!llvm.ptr, i64) -> !llvm.ptr, i32
llvm.store %388, %391 : i32, !llvm.ptr
%392 = arith.constant 0 : i32
%393 = arith.extsi %392 : i32 to i64
%394 = llvm.getelementptr %106[%393] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %229, %394 : f64, !llvm.ptr
%395 = llvm.load %142 : !llvm.ptr -> i64
%396 = arith.trunci %395 : i64 to i32
%397 = arith.constant 0 : i32
%398 = arith.extsi %397 : i32 to i64
%399 = llvm.getelementptr %112[%398] : (!llvm.ptr, i64) -> !llvm.ptr, i32
llvm.store %396, %399 : i32, !llvm.ptr
%400 = arith.constant 1 : i32
%401 = arith.extsi %400 : i32 to i64
llvm.store %401, %208 : i64, !llvm.ptr
cf.br ^bb56
^bb55:
cf.br ^bb56
^bb56:
cf.br ^bb29
^bb29:
cf.br ^bb26
^bb25:
cf.br ^bb26
^bb26:
%402 = llvm.load %142 : !llvm.ptr -> i64
%403 = arith.constant 1 : i32
%405 = arith.extsi %403 : i32 to i64
%404 = arith.addi %402, %405 : i64
llvm.store %404, %142 : i64, !llvm.ptr
cf.br ^bb21
^bb23:
%406 = arith.constant 0 : i32
%407 = arith.extsi %406 : i32 to i64
%408 = llvm.mlir.constant(1 : i64) : i64
%409 = llvm.alloca %408 x i64 : (i64) -> !llvm.ptr
llvm.store %407, %409 : i64, !llvm.ptr
%410 = arith.constant 0 : i32
%411 = arith.extsi %410 : i32 to i64
%412 = llvm.mlir.constant(1 : i64) : i64
%413 = llvm.alloca %412 x i64 : (i64) -> !llvm.ptr
llvm.store %411, %413 : i64, !llvm.ptr
cf.br ^bb57
^bb57:
%414 = llvm.load %413 : !llvm.ptr -> i64
%415 = arith.cmpi sle, %414, %1 : i64
cf.cond_br %415, ^bb58, ^bb59
^bb58:
cf.br ^bb60
^bb60:
%416 = llvm.load %409 : !llvm.ptr -> i64
%417 = arith.constant 1 : i32
%419 = arith.extsi %417 : i32 to i64
%418 = arith.addi %416, %419 : i64
%420 = llvm.load %208 : !llvm.ptr -> i64
%421 = arith.cmpi slt, %418, %420 : i64
%422 = scf.if %421 -> (i1) {
%423 = llvm.load %413 : !llvm.ptr -> i64
%425 = llvm.load %409 : !llvm.ptr -> i64
%426 = arith.constant 1 : i32
%428 = arith.extsi %426 : i32 to i64
%427 = arith.addi %425, %428 : i64
%429 = llvm.getelementptr %112[%427] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%424 = llvm.load %429 : !llvm.ptr -> i32
%430 = arith.extsi %424 : i32 to i64
%431 = arith.cmpi sge, %423, %430 : i64
scf.yield %431 : i1
} else {
%432 = arith.constant false
scf.yield %432 : i1
}
cf.cond_br %422, ^bb61, ^bb62
^bb61:
%433 = llvm.load %409 : !llvm.ptr -> i64
%434 = arith.constant 1 : i32
%436 = arith.extsi %434 : i32 to i64
%435 = arith.addi %433, %436 : i64
llvm.store %435, %409 : i64, !llvm.ptr
cf.br ^bb60
^bb62:
%438 = llvm.load %409 : !llvm.ptr -> i64
%439 = llvm.getelementptr %100[%438] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%437 = llvm.load %439 : !llvm.ptr -> i32
%440 = arith.extsi %437 : i32 to i64
%441 = llvm.load %413 : !llvm.ptr -> i64
%442 = arith.cmpi sle, %440, %441 : i64
cf.cond_br %442, ^bb63, ^bb64
^bb63:
%444 = llvm.load %409 : !llvm.ptr -> i64
%445 = llvm.getelementptr %106[%444] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%443 = llvm.load %445 : !llvm.ptr -> f64
%446 = llvm.load %130 : !llvm.ptr -> f64
%448 = arith.constant 1 : i32
%450 = arith.extsi %448 : i32 to i64
%449 = arith.addi %1, %450 : i64
%451 = arith.muli %200, %449 : i64
%452 = llvm.load %413 : !llvm.ptr -> i64
%453 = arith.subi %452, %440 : i64
%454 = arith.addi %451, %453 : i64
%455 = llvm.getelementptr %2[%454] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%447 = llvm.load %455 : !llvm.ptr -> f64
%456 = arith.mulf %446, %447 : f64
%457 = arith.subf %443, %456 : f64
%458 = llvm.load %413 : !llvm.ptr -> i64
%459 = arith.sitofp %458 : i64 to f64
%460 = arith.mulf %203, %459 : f64
%461 = arith.addf %457, %460 : f64
%463 = llvm.load %413 : !llvm.ptr -> i64
%464 = llvm.getelementptr %82[%463] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%462 = llvm.load %464 : !llvm.ptr -> f64
%465 = arith.cmpf ogt, %461, %462 : f64
cf.cond_br %465, ^bb66, ^bb67
^bb66:
%466 = llvm.load %413 : !llvm.ptr -> i64
%467 = llvm.getelementptr %82[%466] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %461, %467 : f64, !llvm.ptr
%468 = llvm.load %194 : !llvm.ptr -> i64
%469 = arith.trunci %468 : i64 to i16
%470 = llvm.load %413 : !llvm.ptr -> i64
%471 = llvm.getelementptr %88[%470] : (!llvm.ptr, i64) -> !llvm.ptr, i16
llvm.store %469, %471 : i16, !llvm.ptr
%472 = arith.trunci %440 : i64 to i16
%473 = llvm.load %413 : !llvm.ptr -> i64
%474 = llvm.getelementptr %94[%473] : (!llvm.ptr, i64) -> !llvm.ptr, i16
llvm.store %472, %474 : i16, !llvm.ptr
cf.br ^bb68
^bb67:
cf.br ^bb68
^bb68:
cf.br ^bb65
^bb64:
cf.br ^bb65
^bb65:
%475 = llvm.load %413 : !llvm.ptr -> i64
%476 = arith.constant 1 : i32
%478 = arith.extsi %476 : i32 to i64
%477 = arith.addi %475, %478 : i64
llvm.store %477, %413 : i64, !llvm.ptr
cf.br ^bb57
^bb59:
%479 = llvm.load %194 : !llvm.ptr -> i64
%480 = arith.constant 1 : i32
%482 = arith.extsi %480 : i32 to i64
%481 = arith.addi %479, %482 : i64
llvm.store %481, %194 : i64, !llvm.ptr
cf.br ^bb18
^bb20:
%483 = arith.constant 0 : i32
%484 = arith.extsi %483 : i32 to i64
llvm.store %484, %142 : i64, !llvm.ptr
cf.br ^bb69
^bb69:
%485 = llvm.load %142 : !llvm.ptr -> i64
%486 = arith.cmpi sle, %485, %1 : i64
cf.cond_br %486, ^bb70, ^bb71
^bb70:
%488 = llvm.load %142 : !llvm.ptr -> i64
%489 = llvm.getelementptr %82[%488] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%487 = llvm.load %489 : !llvm.ptr -> f64
%490 = llvm.load %166 : !llvm.ptr -> i64
%491 = arith.constant 1 : i32
%493 = arith.extsi %491 : i32 to i64
%492 = arith.addi %1, %493 : i64
%494 = arith.muli %490, %492 : i64
%495 = llvm.load %142 : !llvm.ptr -> i64
%496 = arith.addi %494, %495 : i64
%497 = llvm.getelementptr %52[%496] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %487, %497 : f64, !llvm.ptr
%499 = llvm.load %142 : !llvm.ptr -> i64
%500 = llvm.getelementptr %88[%499] : (!llvm.ptr, i64) -> !llvm.ptr, i16
%498 = llvm.load %500 : !llvm.ptr -> i16
%501 = llvm.load %166 : !llvm.ptr -> i64
%502 = arith.constant 1 : i32
%504 = arith.extsi %502 : i32 to i64
%503 = arith.addi %1, %504 : i64
%505 = arith.muli %501, %503 : i64
%506 = llvm.load %142 : !llvm.ptr -> i64
%507 = arith.addi %505, %506 : i64
%508 = llvm.getelementptr %62[%507] : (!llvm.ptr, i64) -> !llvm.ptr, i16
llvm.store %498, %508 : i16, !llvm.ptr
%510 = llvm.load %142 : !llvm.ptr -> i64
%511 = llvm.getelementptr %94[%510] : (!llvm.ptr, i64) -> !llvm.ptr, i16
%509 = llvm.load %511 : !llvm.ptr -> i16
%512 = llvm.load %166 : !llvm.ptr -> i64
%513 = arith.constant 1 : i32
%515 = arith.extsi %513 : i32 to i64
%514 = arith.addi %1, %515 : i64
%516 = arith.muli %512, %514 : i64
%517 = llvm.load %142 : !llvm.ptr -> i64
%518 = arith.addi %516, %517 : i64
%519 = llvm.getelementptr %72[%518] : (!llvm.ptr, i64) -> !llvm.ptr, i16
llvm.store %509, %519 : i16, !llvm.ptr
%520 = llvm.load %142 : !llvm.ptr -> i64
%521 = arith.constant 1 : i32
%523 = arith.extsi %521 : i32 to i64
%522 = arith.addi %520, %523 : i64
llvm.store %522, %142 : i64, !llvm.ptr
cf.br ^bb69
^bb71:
%524 = llvm.load %166 : !llvm.ptr -> i64
%525 = arith.constant 1 : i32
%527 = arith.extsi %525 : i32 to i64
%526 = arith.addi %524, %527 : i64
llvm.store %526, %166 : i64, !llvm.ptr
cf.br ^bb12
^bb14:
%529 = arith.constant 2 : i32
%531 = arith.extsi %529 : i32 to i64
%530 = arith.addi %1, %531 : i64
%532 = arith.constant 4 : i32
%533 = arith.extsi %532 : i32 to i64
%528 = func.call @calloc(%530, %533) : (i64, i64) -> !llvm.ptr
%535 = arith.constant 2 : i32
%537 = arith.extsi %535 : i32 to i64
%536 = arith.addi %1, %537 : i64
%538 = arith.constant 4 : i32
%539 = arith.extsi %538 : i32 to i64
%534 = func.call @calloc(%536, %539) : (i64, 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
%544 = llvm.mlir.constant(1 : i64) : i64
%545 = llvm.alloca %544 x i64 : (i64) -> !llvm.ptr
llvm.store %1, %545 : i64, !llvm.ptr
%546 = llvm.mlir.constant(1 : i64) : i64
%547 = llvm.alloca %546 x i64 : (i64) -> !llvm.ptr
llvm.store %1, %547 : i64, !llvm.ptr
cf.br ^bb72
^bb72:
%548 = llvm.load %545 : !llvm.ptr -> i64
%549 = arith.constant 0 : i32
%551 = arith.extsi %549 : i32 to i64
%550 = arith.cmpi ne, %548, %551 : i64
cf.cond_br %550, ^bb73, ^bb74
^bb73:
%552 = llvm.load %545 : !llvm.ptr -> i64
%553 = arith.trunci %552 : i64 to i32
%554 = llvm.load %543 : !llvm.ptr -> i64
%555 = llvm.getelementptr %528[%554] : (!llvm.ptr, i64) -> !llvm.ptr, i32
llvm.store %553, %555 : i32, !llvm.ptr
%556 = llvm.load %547 : !llvm.ptr -> i64
%557 = arith.trunci %556 : i64 to i32
%558 = llvm.load %543 : !llvm.ptr -> i64
%559 = llvm.getelementptr %534[%558] : (!llvm.ptr, i64) -> !llvm.ptr, i32
llvm.store %557, %559 : i32, !llvm.ptr
%561 = llvm.load %545 : !llvm.ptr -> i64
%562 = arith.constant 1 : i32
%564 = arith.extsi %562 : i32 to i64
%563 = arith.addi %1, %564 : i64
%565 = arith.muli %561, %563 : i64
%566 = llvm.load %547 : !llvm.ptr -> i64
%567 = arith.addi %565, %566 : i64
%568 = llvm.getelementptr %62[%567] : (!llvm.ptr, i64) -> !llvm.ptr, i16
%560 = llvm.load %568 : !llvm.ptr -> i16
%569 = arith.extsi %560 : i16 to i64
%571 = llvm.load %545 : !llvm.ptr -> i64
%572 = arith.constant 1 : i32
%574 = arith.extsi %572 : i32 to i64
%573 = arith.addi %1, %574 : i64
%575 = arith.muli %571, %573 : i64
%576 = llvm.load %547 : !llvm.ptr -> i64
%577 = arith.addi %575, %576 : i64
%578 = llvm.getelementptr %72[%577] : (!llvm.ptr, i64) -> !llvm.ptr, i16
%570 = llvm.load %578 : !llvm.ptr -> i16
%579 = arith.extsi %570 : i16 to i64
llvm.store %569, %545 : i64, !llvm.ptr
llvm.store %579, %547 : i64, !llvm.ptr
%580 = llvm.load %543 : !llvm.ptr -> i64
%581 = arith.constant 1 : i32
%583 = arith.extsi %581 : i32 to i64
%582 = arith.addi %580, %583 : i64
llvm.store %582, %543 : i64, !llvm.ptr
cf.br ^bb72
^bb74:
%584 = arith.constant 0 : i32
%585 = llvm.load %543 : !llvm.ptr -> i64
%586 = llvm.getelementptr %528[%585] : (!llvm.ptr, i64) -> !llvm.ptr, i32
llvm.store %584, %586 : i32, !llvm.ptr
%587 = llvm.load %547 : !llvm.ptr -> i64
%588 = arith.trunci %587 : i64 to i32
%589 = llvm.load %543 : !llvm.ptr -> i64
%590 = llvm.getelementptr %534[%589] : (!llvm.ptr, i64) -> !llvm.ptr, i32
llvm.store %588, %590 : i32, !llvm.ptr
%591 = llvm.load %543 : !llvm.ptr -> i64
%592 = arith.constant 1 : i32
%594 = arith.extsi %592 : i32 to i64
%593 = arith.addi %591, %594 : i64
llvm.store %593, %543 : i64, !llvm.ptr
%595 = arith.constant 0 : i32
%596 = arith.extsi %595 : i32 to i64
%597 = llvm.mlir.constant(1 : i64) : i64
%598 = llvm.alloca %597 x i64 : (i64) -> !llvm.ptr
llvm.store %596, %598 : i64, !llvm.ptr
cf.br ^bb75
^bb75:
%599 = llvm.load %598 : !llvm.ptr -> i64
%600 = llvm.load %543 : !llvm.ptr -> i64
%601 = arith.constant 2 : i32
%603 = arith.extsi %601 : i32 to i64
%602 = arith.divsi %600, %603 : i64
%604 = arith.cmpi slt, %599, %602 : i64
cf.cond_br %604, ^bb76, ^bb77
^bb76:
%606 = llvm.load %598 : !llvm.ptr -> i64
%607 = llvm.getelementptr %528[%606] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%605 = llvm.load %607 : !llvm.ptr -> i32
%609 = llvm.load %598 : !llvm.ptr -> i64
%610 = llvm.getelementptr %534[%609] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%608 = llvm.load %610 : !llvm.ptr -> i32
%612 = llvm.load %543 : !llvm.ptr -> i64
%613 = arith.constant 1 : i32
%615 = arith.extsi %613 : i32 to i64
%614 = arith.subi %612, %615 : i64
%616 = llvm.load %598 : !llvm.ptr -> i64
%617 = arith.subi %614, %616 : i64
%618 = llvm.getelementptr %528[%617] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%611 = llvm.load %618 : !llvm.ptr -> i32
%619 = llvm.load %598 : !llvm.ptr -> i64
%620 = llvm.getelementptr %528[%619] : (!llvm.ptr, i64) -> !llvm.ptr, i32
llvm.store %611, %620 : i32, !llvm.ptr
%622 = llvm.load %543 : !llvm.ptr -> i64
%623 = arith.constant 1 : i32
%625 = arith.extsi %623 : i32 to i64
%624 = arith.subi %622, %625 : i64
%626 = llvm.load %598 : !llvm.ptr -> i64
%627 = arith.subi %624, %626 : i64
%628 = llvm.getelementptr %534[%627] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%621 = llvm.load %628 : !llvm.ptr -> i32
%629 = llvm.load %598 : !llvm.ptr -> i64
%630 = llvm.getelementptr %534[%629] : (!llvm.ptr, i64) -> !llvm.ptr, i32
llvm.store %621, %630 : i32, !llvm.ptr
%631 = llvm.load %543 : !llvm.ptr -> i64
%632 = arith.constant 1 : i32
%634 = arith.extsi %632 : i32 to i64
%633 = arith.subi %631, %634 : i64
%635 = llvm.load %598 : !llvm.ptr -> i64
%636 = arith.subi %633, %635 : i64
%637 = llvm.getelementptr %528[%636] : (!llvm.ptr, i64) -> !llvm.ptr, i32
llvm.store %605, %637 : i32, !llvm.ptr
%638 = llvm.load %543 : !llvm.ptr -> i64
%639 = arith.constant 1 : i32
%641 = arith.extsi %639 : i32 to i64
%640 = arith.subi %638, %641 : i64
%642 = llvm.load %598 : !llvm.ptr -> i64
%643 = arith.subi %640, %642 : i64
%644 = llvm.getelementptr %534[%643] : (!llvm.ptr, i64) -> !llvm.ptr, i32
llvm.store %608, %644 : i32, !llvm.ptr
%645 = llvm.load %598 : !llvm.ptr -> i64
%646 = arith.constant 1 : i32
%648 = arith.extsi %646 : i32 to i64
%647 = arith.addi %645, %648 : i64
llvm.store %647, %598 : i64, !llvm.ptr
cf.br ^bb75
^bb77:
%649 = arith.constant 0.0 : f32
%650 = arith.extf %649 : f32 to f64
%651 = llvm.mlir.constant(1 : i64) : i64
%652 = llvm.alloca %651 x f64 : (i64) -> !llvm.ptr
llvm.store %650, %652 : f64, !llvm.ptr
%654 = arith.constant 0 : i32
%655 = arith.extsi %654 : i32 to i64
%656 = llvm.getelementptr %534[%655] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%653 = llvm.load %656 : !llvm.ptr -> i32
%657 = arith.sitofp %653 : i32 to f64
%658 = llvm.mlir.constant(1 : i64) : i64
%659 = llvm.alloca %658 x f64 : (i64) -> !llvm.ptr
llvm.store %657, %659 : f64, !llvm.ptr
%660 = arith.constant 0 : i32
%661 = arith.extsi %660 : i32 to i64
llvm.store %661, %598 : i64, !llvm.ptr
cf.br ^bb78
^bb78:
%662 = llvm.load %598 : !llvm.ptr -> i64
%663 = llvm.load %543 : !llvm.ptr -> i64
%664 = arith.constant 1 : i32
%666 = arith.extsi %664 : i32 to i64
%665 = arith.subi %663, %666 : i64
%667 = arith.cmpi slt, %662, %665 : i64
cf.cond_br %667, ^bb79, ^bb80
^bb79:
%669 = llvm.load %598 : !llvm.ptr -> i64
%670 = llvm.getelementptr %528[%669] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%668 = llvm.load %670 : !llvm.ptr -> i32
%671 = arith.extsi %668 : i32 to i64
%673 = llvm.load %598 : !llvm.ptr -> i64
%674 = llvm.getelementptr %534[%673] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%672 = llvm.load %674 : !llvm.ptr -> i32
%675 = arith.extsi %672 : i32 to i64
%677 = llvm.load %598 : !llvm.ptr -> i64
%678 = arith.constant 1 : i32
%680 = arith.extsi %678 : i32 to i64
%679 = arith.addi %677, %680 : i64
%681 = llvm.getelementptr %528[%679] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%676 = llvm.load %681 : !llvm.ptr -> i32
%682 = arith.extsi %676 : i32 to i64
%684 = llvm.load %598 : !llvm.ptr -> i64
%685 = arith.constant 1 : i32
%687 = arith.extsi %685 : i32 to i64
%686 = arith.addi %684, %687 : i64
%688 = llvm.getelementptr %534[%686] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%683 = llvm.load %688 : !llvm.ptr -> i32
%689 = arith.extsi %683 : i32 to i64
%690 = arith.subi %682, %671 : i64
%691 = arith.subi %689, %675 : i64
%692 = llvm.mlir.constant(1 : i64) : i64
%693 = llvm.alloca %692 x i64 : (i64) -> !llvm.ptr
llvm.store %691, %693 : i64, !llvm.ptr
%694 = llvm.load %693 : !llvm.ptr -> i64
%695 = arith.constant 0 : i32
%697 = arith.extsi %695 : i32 to i64
%696 = arith.cmpi slt, %694, %697 : i64
cf.cond_br %696, ^bb81, ^bb82
^bb81:
%698 = llvm.load %693 : !llvm.ptr -> i64
%700 = arith.constant 0 : i64
%699 = arith.subi %700, %698 : i64
llvm.store %699, %693 : i64, !llvm.ptr
cf.br ^bb83
^bb82:
cf.br ^bb83
^bb83:
%701 = llvm.load %652 : !llvm.ptr -> f64
%702 = arith.addi %675, %689 : i64
%703 = arith.sitofp %702 : i64 to f64
%704 = arith.sitofp %690 : i64 to f64
%705 = arith.mulf %703, %704 : f64
%706 = arith.constant 0.5 : f32
%708 = arith.extf %706 : f32 to f64
%707 = arith.mulf %705, %708 : f64
%709 = arith.addf %701, %707 : f64
llvm.store %709, %652 : f64, !llvm.ptr
%710 = llvm.load %659 : !llvm.ptr -> f64
%712 = arith.constant 1 : i32
%714 = arith.extsi %712 : i32 to i64
%713 = arith.addi %1, %714 : i64
%715 = arith.muli %690, %713 : i64
%716 = llvm.load %693 : !llvm.ptr -> i64
%717 = arith.addi %715, %716 : i64
%718 = llvm.getelementptr %2[%717] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%711 = llvm.load %718 : !llvm.ptr -> f64
%719 = arith.addf %710, %711 : f64
llvm.store %719, %659 : f64, !llvm.ptr
%720 = llvm.load %598 : !llvm.ptr -> i64
%721 = arith.constant 1 : i32
%723 = arith.extsi %721 : i32 to i64
%722 = arith.addi %720, %723 : i64
llvm.store %722, %598 : i64, !llvm.ptr
cf.br ^bb78
^bb80:
%724 = llvm.load %652 : !llvm.ptr -> f64
%725 = llvm.load %659 : !llvm.ptr -> f64
%726 = arith.divf %724, %725 : f64
%727 = llvm.load %130 : !llvm.ptr -> f64
%728 = arith.subf %726, %727 : f64
%729 = math.absf %728 : f64
%730 = arith.constant 0 : f32
%732 = arith.extf %730 : f32 to f64
%731 = arith.cmpf olt, %729, %732 : f64
cf.cond_br %731, ^bb84, ^bb85
^bb84:
llvm.store %726, %130 : f64, !llvm.ptr
func.call @free(%528) : (!llvm.ptr) -> ()
func.call @free(%534) : (!llvm.ptr) -> ()
cf.br ^bb8
^bb85:
cf.br ^bb86
^bb86:
llvm.store %726, %130 : f64, !llvm.ptr
func.call @free(%528) : (!llvm.ptr) -> ()
func.call @free(%534) : (!llvm.ptr) -> ()
%737 = llvm.load %134 : !llvm.ptr -> i64
%738 = arith.constant 1 : i32
%740 = arith.extsi %738 : i32 to i64
%739 = arith.addi %737, %740 : i64
llvm.store %739, %134 : i64, !llvm.ptr
cf.br ^bb6
^bb8:
%741 = llvm.mlir.addressof @str_0 : !llvm.ptr
%742 = llvm.load %130 : !llvm.ptr -> f64
%743 = llvm.call @printf(%741, %742) vararg(!llvm.func<i32 (ptr, ...)>) : (!llvm.ptr, f64) -> i32
func.call @free(%2) : (!llvm.ptr) -> ()
func.call @free(%52) : (!llvm.ptr) -> ()
func.call @free(%62) : (!llvm.ptr) -> ()
func.call @free(%72) : (!llvm.ptr) -> ()
func.call @free(%82) : (!llvm.ptr) -> ()
func.call @free(%88) : (!llvm.ptr) -> ()
func.call @free(%94) : (!llvm.ptr) -> ()
func.call @free(%100) : (!llvm.ptr) -> ()
func.call @free(%106) : (!llvm.ptr) -> ()
func.call @free(%112) : (!llvm.ptr) -> ()
%754 = arith.constant 0 : i32
func.return %754 : i32
}
}