← All problems
Problem 695
Random Rectangles: expected area of the middle rectangle, to 10 dp. Sort the three points by x: adjacent gaps (a1, a2) have density 6(1-a1-a2); y-gaps (b1, b2) are independent with the same law, and the x-to-y rank permutation is uniform. Up to gap swaps only two classes remain: {a1 b1, a2 b2, (a1+a2)(b1+b2)} (weight 1/3) and {a1(b1+b2), a2 b2, (a1+a2) b1} (weight 2/3). All areas are linear in (b1, b2) and pairwise-equality loci are rays through the origin, so the b-simplex splits into sectors whose median form integrates in closed form over each sector triangle. Homogeneity in the overall scale reduces the a-integral to one dimension: T = Int_0^inf H(t) / (2 (1+t)^3) dt, t = a2 / a1, with H analytic except at t = 1 and t = phi (all three ray coincidences degenerate to a2 = phi a1). Composite 16-point Gauss-Legendre between those splits gives full double precision. Cross-checked by Monte Carlo.
View problem on Project Euler
Performance comparison
Metric Our solution Best known
Time complexity O(n^3)O(n^2)
Space complexity O(1)O(n^2)
Approach Flow solution Bottom-up DP
Verdict Suboptimal
Flow source
# Project Euler 695
# Random Rectangles: expected area of the middle rectangle, to 10 dp.
#
# Sort the three points by x: adjacent gaps (a1, a2) have density
# 6(1-a1-a2); y-gaps (b1, b2) are independent with the same law, and the
# x-to-y rank permutation is uniform. Up to gap swaps only two classes
# remain: {a1 b1, a2 b2, (a1+a2)(b1+b2)} (weight 1/3) and
# {a1(b1+b2), a2 b2, (a1+a2) b1} (weight 2/3). All areas are linear in
# (b1, b2) and pairwise-equality loci are rays through the origin, so the
# b-simplex splits into sectors whose median form integrates in closed
# form over each sector triangle. Homogeneity in the overall scale
# reduces the a-integral to one dimension:
# T = Int_0^inf H(t) / (2 (1+t)^3) dt, t = a2 / a1,
# with H analytic except at t = 1 and t = phi (all three ray coincidences
# degenerate to a2 = phi a1). Composite 16-point Gauss-Legendre between
# those splits gives full double precision. Cross-checked by Monte Carlo.
extern {
function calloc(n: i64, size: i64) -> ptr<void>
function free(p: ptr<void>) -> void
}
# H(t) for one permutation class: cls = 1 or 2, with a1 = 1, a2 = t
function H_of(cls: i64, t: f64) -> f64 {
# forms: c1[i]*b1 + c2[i]*b2
let c1: ptr<f64> = calloc(3, 8)
let c2: ptr<f64> = calloc(3, 8)
if cls == 1 {
c1[0] = 1.0
c2[0] = 0.0
c1[1] = 0.0
c2[1] = t
c1[2] = 1.0 + t
c2[2] = 1.0 + t
} else {
c1[0] = 1.0
c2[0] = 1.0
c1[1] = 0.0
c2[1] = t
c1[2] = 1.0 + t
c2[2] = 0.0
}
# rays: slopes s = -(c1_i - c1_j)/(c2_i - c2_j) when positive
let sl: ptr<f64> = calloc(4, 8)
let mut ns: i64 = 0
let mut i: i64 = 0
while i < 3 {
let mut j: i64 = i + 1
while j < 3 {
let d1: f64 = c1[i] - c1[j]
let d2: f64 = c2[i] - c2[j]
if d2 != 0.0 {
let s: f64 = (0.0 - d1) / d2
if s > 0.000000000000001 {
sl[ns] = s
ns = ns + 1
}
}
j = j + 1
}
i = i + 1
}
# sort slopes (n <= 3)
i = 0
while i < ns {
let mut j2: i64 = i + 1
while j2 < ns {
if sl[j2] < sl[i] {
let tmp: f64 = sl[i]
sl[i] = sl[j2]
sl[j2] = tmp
}
j2 = j2 + 1
}
i = i + 1
}
# boundary points on b1+b2 = 1 from (1,0) to (0,1)
let px: ptr<f64> = calloc(6, 8)
let py: ptr<f64> = calloc(6, 8)
px[0] = 1.0
py[0] = 0.0
i = 0
while i < ns {
px[i + 1] = 1.0 / (1.0 + sl[i])
py[i + 1] = sl[i] / (1.0 + sl[i])
i = i + 1
}
px[ns + 1] = 0.0
py[ns + 1] = 1.0
let mut tot: f64 = 0.0
i = 0
while i <= ns {
let ux: f64 = px[i]
let uy: f64 = py[i]
let vx: f64 = px[i + 1]
let vy: f64 = py[i + 1]
let mx: f64 = (ux + vx) / 2.0
let my: f64 = (uy + vy) / 2.0
# median of the three form values at midpoint
let v0: f64 = c1[0] * mx + c2[0] * my
let v1: f64 = c1[1] * mx + c2[1] * my
let v2: f64 = c1[2] * mx + c2[2] * my
let mut k: i64 = 0
if (v0 <= v1 && v1 <= v2) || (v2 <= v1 && v1 <= v0) {
k = 1
} else {
if (v1 <= v2 && v2 <= v0) || (v0 <= v2 && v2 <= v1) {
k = 2
} else {
k = 0
}
}
let mut det: f64 = ux * vy - uy * vx
if det < 0.0 {
det = 0.0 - det
}
let LU: f64 = c1[k] * ux + c2[k] * uy
let LV: f64 = c1[k] * vx + c2[k] * vy
tot = tot + 6.0 * det * (LU + LV) / 24.0
i = i + 1
}
free(c1)
free(c2)
free(sl)
free(px)
free(py)
return tot
}
function T_of(cls: i64, gx: ptr<f64>, gw: ptr<f64>) -> f64 {
# integrate H(t)/(2(1+t)^3) over t in (0,inf), v = t/(1+t) substitution,
# splits at t = 1/phi, 1, phi
let phi: f64 = 1.6180339887498949
let vs: ptr<f64> = calloc(5, 8)
vs[0] = 0.0
vs[1] = (1.0 / phi) / (1.0 + 1.0 / phi)
vs[2] = 0.5
vs[3] = phi / (1.0 + phi)
vs[4] = 1.0
let mut tot: f64 = 0.0
let mut seg: i64 = 0
while seg < 4 {
let a: f64 = vs[seg]
let b: f64 = vs[seg + 1]
let mut p: i64 = 0
while p < 16 {
let aa: f64 = a + (b - a) * (p as f64) / 16.0
let bb: f64 = a + (b - a) * ((p + 1) as f64) / 16.0
let mut q: i64 = 0
while q < 16 {
let vv: f64 = aa + (bb - aa) * 0.5 * (gx[q] + 1.0)
let ww: f64 = 0.5 * (bb - aa) * gw[q]
let t: f64 = vv / (1.0 - vv)
let dt: f64 = 1.0 / ((1.0 - vv) * (1.0 - vv))
let ht: f64 = H_of(cls, t)
let om: f64 = 1.0 + t
tot = tot + ww * ht / (2.0 * om * om * om) * dt
q = q + 1
}
p = p + 1
}
seg = seg + 1
}
free(vs)
return tot
}
function main() -> i32 {
let gx: ptr<f64> = calloc(16, 8)
let gw: ptr<f64> = calloc(16, 8)
gx[0] = -0.98940093499164994; gx[1] = -0.9445750230732326
gx[2] = -0.86563120238783164; gx[3] = -0.75540440835500311
gx[4] = -0.61787624440264377; gx[5] = -0.45801677765722737
gx[6] = -0.28160355077925892; gx[7] = -0.095012509837637441
gx[8] = 0.095012509837637441; gx[9] = 0.28160355077925892
gx[10] = 0.45801677765722737; gx[11] = 0.61787624440264377
gx[12] = 0.75540440835500311; gx[13] = 0.86563120238783164
gx[14] = 0.9445750230732326; gx[15] = 0.98940093499164994
gw[0] = 0.027152459411754055; gw[1] = 0.062253523938647609
gw[2] = 0.095158511682492994; gw[3] = 0.12462897125553395
gw[4] = 0.14959598881657665; gw[5] = 0.16915651939500262
gw[6] = 0.18260341504492361; gw[7] = 0.18945061045506859
gw[8] = 0.18945061045506859; gw[9] = 0.18260341504492361
gw[10] = 0.16915651939500262; gw[11] = 0.14959598881657665
gw[12] = 0.12462897125553395; gw[13] = 0.095158511682492994
gw[14] = 0.062253523938647609; gw[15] = 0.027152459411754055
let T1: f64 = T_of(1, gx, gw)
let T2: f64 = T_of(2, gx, gw)
let E: f64 = T1 / 3.0 + 2.0 * T2 / 3.0
printf("%.10f\n", E)
free(gx)
free(gw)
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; }
double H_of_i64_f64(int64_t cls, double t);
double T_of_i64_ptr_f64_ptr_f64(int64_t cls, double* gx, double* gw);
int32_t main(void);
double H_of_i64_f64(int64_t cls, double t) {
double* c1 = (double*)(calloc(3, 8));
double* c2 = (double*)(calloc(3, 8));
if (cls == 1) {
c1[0] = 1.0;
c2[0] = 0.0;
c1[1] = 0.0;
c2[1] = t;
c1[2] = (1.0 + t);
c2[2] = (1.0 + t);
} else {
c1[0] = 1.0;
c2[0] = 1.0;
c1[1] = 0.0;
c2[1] = t;
c1[2] = (1.0 + t);
c2[2] = 0.0;
}
double* sl = (double*)(calloc(4, 8));
int64_t ns = 0;
int64_t i = 0;
while (i < 3) {
int64_t j = (i + 1);
while (j < 3) {
double d1 = (c1[i] - c1[j]);
double d2 = (c2[i] - c2[j]);
if (d2 != 0.0) {
double s = ((0.0 - d1) / d2);
if (s > 0.000000000000001) {
sl[ns] = s;
ns = (ns + 1);
}
}
j = (j + 1);
}
i = (i + 1);
}
i = 0;
while (i < ns) {
int64_t j2 = (i + 1);
while (j2 < ns) {
if (sl[j2] < sl[i]) {
double tmp = sl[i];
sl[i] = sl[j2];
sl[j2] = tmp;
}
j2 = (j2 + 1);
}
i = (i + 1);
}
double* px = (double*)(calloc(6, 8));
double* py = (double*)(calloc(6, 8));
px[0] = 1.0;
py[0] = 0.0;
i = 0;
while (i < ns) {
px[(i + 1)] = (1.0 / (1.0 + sl[i]));
py[(i + 1)] = (sl[i] / (1.0 + sl[i]));
i = (i + 1);
}
px[(ns + 1)] = 0.0;
py[(ns + 1)] = 1.0;
double tot = 0.0;
i = 0;
while (i <= ns) {
double ux = px[i];
double uy = py[i];
double vx = px[(i + 1)];
double vy = py[(i + 1)];
double mx = ((ux + vx) / 2.0);
double my = ((uy + vy) / 2.0);
double v0 = ((c1[0] * mx) + (c2[0] * my));
double v1 = ((c1[1] * mx) + (c2[1] * my));
double v2 = ((c1[2] * mx) + (c2[2] * my));
int64_t k = 0;
if (((v0 <= v1 && v1 <= v2) || (v2 <= v1 && v1 <= v0))) {
k = 1;
} else {
if (((v1 <= v2 && v2 <= v0) || (v0 <= v2 && v2 <= v1))) {
k = 2;
} else {
k = 0;
}
}
double det = ((ux * vy) - (uy * vx));
if (det < 0.0) {
det = (0.0 - det);
}
double LU = ((c1[k] * ux) + (c2[k] * uy));
double LV = ((c1[k] * vx) + (c2[k] * vy));
tot = (tot + (((6.0 * det) * (LU + LV)) / 24.0));
i = (i + 1);
}
free(c1);
free(c2);
free(sl);
free(px);
free(py);
return tot;
}
double T_of_i64_ptr_f64_ptr_f64(int64_t cls, double* gx, double* gw) {
double phi = 1.6180339887498949;
double* vs = (double*)(calloc(5, 8));
vs[0] = 0.0;
vs[1] = ((1.0 / phi) / (1.0 + (1.0 / phi)));
vs[2] = 0.5;
vs[3] = (phi / (1.0 + phi));
vs[4] = 1.0;
double tot = 0.0;
int64_t seg = 0;
while (seg < 4) {
double a = vs[seg];
double b = vs[(seg + 1)];
int64_t p = 0;
while (p < 16) {
double aa = (a + (((b - a) * ((double)(p))) / 16.0));
double bb = (a + (((b - a) * ((double)((p + 1)))) / 16.0));
int64_t q = 0;
while (q < 16) {
double vv = (aa + (((bb - aa) * 0.5) * (gx[q] + 1.0)));
double ww = ((0.5 * (bb - aa)) * gw[q]);
double t = (vv / (1.0 - vv));
double dt = (1.0 / ((1.0 - vv) * (1.0 - vv)));
double ht = H_of_i64_f64(cls, t);
double om = (1.0 + t);
tot = (tot + (((ww * ht) / (((2.0 * om) * om) * om)) * dt));
q = (q + 1);
}
p = (p + 1);
}
seg = (seg + 1);
}
free(vs);
return tot;
}
int32_t main(void) {
double* gx = (double*)(calloc(16, 8));
double* gw = (double*)(calloc(16, 8));
gx[0] = (-0.98940093499164994);
gx[1] = (-0.9445750230732326);
gx[2] = (-0.86563120238783164);
gx[3] = (-0.75540440835500311);
gx[4] = (-0.61787624440264377);
gx[5] = (-0.45801677765722737);
gx[6] = (-0.28160355077925892);
gx[7] = (-0.095012509837637441);
gx[8] = 0.095012509837637441;
gx[9] = 0.28160355077925892;
gx[10] = 0.45801677765722737;
gx[11] = 0.61787624440264377;
gx[12] = 0.75540440835500311;
gx[13] = 0.86563120238783164;
gx[14] = 0.9445750230732326;
gx[15] = 0.98940093499164994;
gw[0] = 0.027152459411754055;
gw[1] = 0.062253523938647609;
gw[2] = 0.095158511682492994;
gw[3] = 0.12462897125553395;
gw[4] = 0.14959598881657665;
gw[5] = 0.16915651939500262;
gw[6] = 0.18260341504492361;
gw[7] = 0.18945061045506859;
gw[8] = 0.18945061045506859;
gw[9] = 0.18260341504492361;
gw[10] = 0.16915651939500262;
gw[11] = 0.14959598881657665;
gw[12] = 0.12462897125553395;
gw[13] = 0.095158511682492994;
gw[14] = 0.062253523938647609;
gw[15] = 0.027152459411754055;
double T1 = T_of_i64_ptr_f64_ptr_f64(1, gx, gw);
double T2 = T_of_i64_ptr_f64_ptr_f64(2, gx, gw);
double E = ((T1 / 3.0) + ((2.0 * T2) / 3.0));
printf("%.10f\n", E);
free(gx);
free(gw);
return 0;
}
Generated MLIR
module {
llvm.func @printf(!llvm.ptr, ...) -> i32
llvm.mlir.global internal constant @str_0("%.10f\n\00") {addr_space = 0 : i32} : !llvm.array<7 x i8>
func.func private @calloc(i64, i64) -> !llvm.ptr
func.func private @free(!llvm.ptr) -> ()
func.func @H_of(%arg0: i64, %arg1: f64) -> f64 {
%1 = arith.constant 3 : i32
%2 = arith.constant 8 : i32
%3 = arith.extsi %1 : i32 to i64
%4 = arith.extsi %2 : i32 to i64
%0 = func.call @calloc(%3, %4) : (i64, i64) -> !llvm.ptr
%6 = arith.constant 3 : i32
%7 = arith.constant 8 : i32
%8 = arith.extsi %6 : i32 to i64
%9 = arith.extsi %7 : i32 to i64
%5 = func.call @calloc(%8, %9) : (i64, i64) -> !llvm.ptr
%10 = arith.constant 1 : i32
%12 = arith.extsi %10 : i32 to i64
%11 = arith.cmpi eq, %arg0, %12 : i64
cf.cond_br %11, ^bb0, ^bb1
^bb0:
%13 = arith.constant 1.0 : f32
%14 = arith.constant 0 : i32
%15 = arith.extf %13 : f32 to f64
%16 = arith.extsi %14 : i32 to i64
%17 = llvm.getelementptr %0[%16] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %15, %17 : f64, !llvm.ptr
%18 = arith.constant 0.0 : f32
%19 = arith.constant 0 : i32
%20 = arith.extf %18 : f32 to f64
%21 = arith.extsi %19 : i32 to i64
%22 = llvm.getelementptr %5[%21] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %20, %22 : f64, !llvm.ptr
%23 = arith.constant 0.0 : f32
%24 = arith.constant 1 : i32
%25 = arith.extf %23 : f32 to f64
%26 = arith.extsi %24 : i32 to i64
%27 = llvm.getelementptr %0[%26] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %25, %27 : f64, !llvm.ptr
%28 = arith.constant 1 : i32
%29 = arith.extsi %28 : i32 to i64
%30 = llvm.getelementptr %5[%29] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %arg1, %30 : f64, !llvm.ptr
%31 = arith.constant 1.0 : f32
%33 = arith.extf %31 : f32 to f64
%32 = arith.addf %33, %arg1 : f64
%34 = arith.constant 2 : i32
%35 = arith.extsi %34 : i32 to i64
%36 = llvm.getelementptr %0[%35] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %32, %36 : f64, !llvm.ptr
%37 = arith.constant 1.0 : f32
%39 = arith.extf %37 : f32 to f64
%38 = arith.addf %39, %arg1 : f64
%40 = arith.constant 2 : i32
%41 = arith.extsi %40 : i32 to i64
%42 = llvm.getelementptr %5[%41] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %38, %42 : f64, !llvm.ptr
cf.br ^bb2
^bb1:
%43 = arith.constant 1.0 : f32
%44 = arith.constant 0 : i32
%45 = arith.extf %43 : f32 to f64
%46 = arith.extsi %44 : i32 to i64
%47 = llvm.getelementptr %0[%46] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %45, %47 : f64, !llvm.ptr
%48 = arith.constant 1.0 : f32
%49 = arith.constant 0 : i32
%50 = arith.extf %48 : f32 to f64
%51 = arith.extsi %49 : i32 to i64
%52 = llvm.getelementptr %5[%51] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %50, %52 : f64, !llvm.ptr
%53 = arith.constant 0.0 : f32
%54 = arith.constant 1 : i32
%55 = arith.extf %53 : f32 to f64
%56 = arith.extsi %54 : i32 to i64
%57 = llvm.getelementptr %0[%56] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %55, %57 : f64, !llvm.ptr
%58 = arith.constant 1 : i32
%59 = arith.extsi %58 : i32 to i64
%60 = llvm.getelementptr %5[%59] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %arg1, %60 : f64, !llvm.ptr
%61 = arith.constant 1.0 : f32
%63 = arith.extf %61 : f32 to f64
%62 = arith.addf %63, %arg1 : f64
%64 = arith.constant 2 : i32
%65 = arith.extsi %64 : i32 to i64
%66 = llvm.getelementptr %0[%65] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %62, %66 : f64, !llvm.ptr
%67 = arith.constant 0.0 : f32
%68 = arith.constant 2 : i32
%69 = arith.extf %67 : f32 to f64
%70 = arith.extsi %68 : i32 to i64
%71 = llvm.getelementptr %5[%70] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %69, %71 : f64, !llvm.ptr
cf.br ^bb2
^bb2:
%73 = arith.constant 4 : i32
%74 = arith.constant 8 : i32
%75 = arith.extsi %73 : i32 to i64
%76 = arith.extsi %74 : i32 to i64
%72 = func.call @calloc(%75, %76) : (i64, i64) -> !llvm.ptr
%77 = arith.constant 0 : i32
%78 = arith.extsi %77 : i32 to i64
%79 = llvm.mlir.constant(1 : i64) : i64
%80 = llvm.alloca %79 x i64 : (i64) -> !llvm.ptr
llvm.store %78, %80 : i64, !llvm.ptr
%81 = arith.constant 0 : i32
%82 = arith.extsi %81 : i32 to i64
%83 = llvm.mlir.constant(1 : i64) : i64
%84 = llvm.alloca %83 x i64 : (i64) -> !llvm.ptr
llvm.store %82, %84 : i64, !llvm.ptr
cf.br ^bb3
^bb3:
%85 = llvm.load %84 : !llvm.ptr -> i64
%86 = arith.constant 3 : i32
%88 = arith.extsi %86 : i32 to i64
%87 = arith.cmpi slt, %85, %88 : i64
cf.cond_br %87, ^bb4, ^bb5
^bb4:
%89 = llvm.load %84 : !llvm.ptr -> i64
%90 = arith.constant 1 : i32
%92 = arith.extsi %90 : i32 to i64
%91 = arith.addi %89, %92 : i64
%93 = llvm.mlir.constant(1 : i64) : i64
%94 = llvm.alloca %93 x i64 : (i64) -> !llvm.ptr
llvm.store %91, %94 : i64, !llvm.ptr
cf.br ^bb6
^bb6:
%95 = llvm.load %94 : !llvm.ptr -> i64
%96 = arith.constant 3 : i32
%98 = arith.extsi %96 : i32 to i64
%97 = arith.cmpi slt, %95, %98 : i64
cf.cond_br %97, ^bb7, ^bb8
^bb7:
%100 = llvm.load %84 : !llvm.ptr -> i64
%101 = llvm.getelementptr %0[%100] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%99 = llvm.load %101 : !llvm.ptr -> f64
%103 = llvm.load %94 : !llvm.ptr -> i64
%104 = llvm.getelementptr %0[%103] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%102 = llvm.load %104 : !llvm.ptr -> f64
%105 = arith.subf %99, %102 : f64
%107 = llvm.load %84 : !llvm.ptr -> i64
%108 = llvm.getelementptr %5[%107] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%106 = llvm.load %108 : !llvm.ptr -> f64
%110 = llvm.load %94 : !llvm.ptr -> i64
%111 = llvm.getelementptr %5[%110] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%109 = llvm.load %111 : !llvm.ptr -> f64
%112 = arith.subf %106, %109 : f64
%113 = arith.constant 0.0 : f32
%115 = arith.extf %113 : f32 to f64
%114 = arith.cmpf one, %112, %115 : f64
cf.cond_br %114, ^bb9, ^bb10
^bb9:
%116 = arith.constant 0.0 : f32
%118 = arith.extf %116 : f32 to f64
%117 = arith.subf %118, %105 : f64
%119 = arith.divf %117, %112 : f64
%120 = arith.constant 0.000000000000001 : f32
%122 = arith.extf %120 : f32 to f64
%121 = arith.cmpf ogt, %119, %122 : f64
cf.cond_br %121, ^bb12, ^bb13
^bb12:
%123 = llvm.load %80 : !llvm.ptr -> i64
%124 = llvm.getelementptr %72[%123] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %119, %124 : f64, !llvm.ptr
%125 = llvm.load %80 : !llvm.ptr -> i64
%126 = arith.constant 1 : i32
%128 = arith.extsi %126 : i32 to i64
%127 = arith.addi %125, %128 : i64
llvm.store %127, %80 : i64, !llvm.ptr
cf.br ^bb14
^bb13:
cf.br ^bb14
^bb14:
cf.br ^bb11
^bb10:
cf.br ^bb11
^bb11:
%129 = llvm.load %94 : !llvm.ptr -> i64
%130 = arith.constant 1 : i32
%132 = arith.extsi %130 : i32 to i64
%131 = arith.addi %129, %132 : i64
llvm.store %131, %94 : i64, !llvm.ptr
cf.br ^bb6
^bb8:
%133 = llvm.load %84 : !llvm.ptr -> i64
%134 = arith.constant 1 : i32
%136 = arith.extsi %134 : i32 to i64
%135 = arith.addi %133, %136 : i64
llvm.store %135, %84 : i64, !llvm.ptr
cf.br ^bb3
^bb5:
%137 = arith.constant 0 : i32
%138 = arith.extsi %137 : i32 to i64
llvm.store %138, %84 : i64, !llvm.ptr
cf.br ^bb15
^bb15:
%139 = llvm.load %84 : !llvm.ptr -> i64
%140 = llvm.load %80 : !llvm.ptr -> i64
%141 = arith.cmpi slt, %139, %140 : i64
cf.cond_br %141, ^bb16, ^bb17
^bb16:
%142 = llvm.load %84 : !llvm.ptr -> i64
%143 = arith.constant 1 : i32
%145 = arith.extsi %143 : i32 to i64
%144 = arith.addi %142, %145 : i64
%146 = llvm.mlir.constant(1 : i64) : i64
%147 = llvm.alloca %146 x i64 : (i64) -> !llvm.ptr
llvm.store %144, %147 : i64, !llvm.ptr
cf.br ^bb18
^bb18:
%148 = llvm.load %147 : !llvm.ptr -> i64
%149 = llvm.load %80 : !llvm.ptr -> i64
%150 = arith.cmpi slt, %148, %149 : i64
cf.cond_br %150, ^bb19, ^bb20
^bb19:
%152 = llvm.load %147 : !llvm.ptr -> i64
%153 = llvm.getelementptr %72[%152] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%151 = llvm.load %153 : !llvm.ptr -> f64
%155 = llvm.load %84 : !llvm.ptr -> i64
%156 = llvm.getelementptr %72[%155] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%154 = llvm.load %156 : !llvm.ptr -> f64
%157 = arith.cmpf olt, %151, %154 : f64
cf.cond_br %157, ^bb21, ^bb22
^bb21:
%159 = llvm.load %84 : !llvm.ptr -> i64
%160 = llvm.getelementptr %72[%159] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%158 = llvm.load %160 : !llvm.ptr -> f64
%162 = llvm.load %147 : !llvm.ptr -> i64
%163 = llvm.getelementptr %72[%162] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%161 = llvm.load %163 : !llvm.ptr -> f64
%164 = llvm.load %84 : !llvm.ptr -> i64
%165 = llvm.getelementptr %72[%164] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %161, %165 : f64, !llvm.ptr
%166 = llvm.load %147 : !llvm.ptr -> i64
%167 = llvm.getelementptr %72[%166] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %158, %167 : f64, !llvm.ptr
cf.br ^bb23
^bb22:
cf.br ^bb23
^bb23:
%168 = llvm.load %147 : !llvm.ptr -> i64
%169 = arith.constant 1 : i32
%171 = arith.extsi %169 : i32 to i64
%170 = arith.addi %168, %171 : i64
llvm.store %170, %147 : i64, !llvm.ptr
cf.br ^bb18
^bb20:
%172 = llvm.load %84 : !llvm.ptr -> i64
%173 = arith.constant 1 : i32
%175 = arith.extsi %173 : i32 to i64
%174 = arith.addi %172, %175 : i64
llvm.store %174, %84 : i64, !llvm.ptr
cf.br ^bb15
^bb17:
%177 = arith.constant 6 : i32
%178 = arith.constant 8 : i32
%179 = arith.extsi %177 : i32 to i64
%180 = arith.extsi %178 : i32 to i64
%176 = func.call @calloc(%179, %180) : (i64, i64) -> !llvm.ptr
%182 = arith.constant 6 : i32
%183 = arith.constant 8 : i32
%184 = arith.extsi %182 : i32 to i64
%185 = arith.extsi %183 : i32 to i64
%181 = func.call @calloc(%184, %185) : (i64, i64) -> !llvm.ptr
%186 = arith.constant 1.0 : f32
%187 = arith.constant 0 : i32
%188 = arith.extf %186 : f32 to f64
%189 = arith.extsi %187 : i32 to i64
%190 = llvm.getelementptr %176[%189] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %188, %190 : f64, !llvm.ptr
%191 = arith.constant 0.0 : f32
%192 = arith.constant 0 : i32
%193 = arith.extf %191 : f32 to f64
%194 = arith.extsi %192 : i32 to i64
%195 = llvm.getelementptr %181[%194] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %193, %195 : f64, !llvm.ptr
%196 = arith.constant 0 : i32
%197 = arith.extsi %196 : i32 to i64
llvm.store %197, %84 : i64, !llvm.ptr
cf.br ^bb24
^bb24:
%198 = llvm.load %84 : !llvm.ptr -> i64
%199 = llvm.load %80 : !llvm.ptr -> i64
%200 = arith.cmpi slt, %198, %199 : i64
cf.cond_br %200, ^bb25, ^bb26
^bb25:
%201 = arith.constant 1.0 : f32
%202 = arith.constant 1.0 : f32
%204 = llvm.load %84 : !llvm.ptr -> i64
%205 = llvm.getelementptr %72[%204] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%203 = llvm.load %205 : !llvm.ptr -> f64
%207 = arith.extf %202 : f32 to f64
%206 = arith.addf %207, %203 : f64
%209 = arith.extf %201 : f32 to f64
%208 = arith.divf %209, %206 : f64
%210 = llvm.load %84 : !llvm.ptr -> i64
%211 = arith.constant 1 : i32
%213 = arith.extsi %211 : i32 to i64
%212 = arith.addi %210, %213 : i64
%214 = llvm.getelementptr %176[%212] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %208, %214 : f64, !llvm.ptr
%216 = llvm.load %84 : !llvm.ptr -> i64
%217 = llvm.getelementptr %72[%216] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%215 = llvm.load %217 : !llvm.ptr -> f64
%218 = arith.constant 1.0 : f32
%220 = llvm.load %84 : !llvm.ptr -> i64
%221 = llvm.getelementptr %72[%220] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%219 = llvm.load %221 : !llvm.ptr -> f64
%223 = arith.extf %218 : f32 to f64
%222 = arith.addf %223, %219 : f64
%224 = arith.divf %215, %222 : f64
%225 = llvm.load %84 : !llvm.ptr -> i64
%226 = arith.constant 1 : i32
%228 = arith.extsi %226 : i32 to i64
%227 = arith.addi %225, %228 : i64
%229 = llvm.getelementptr %181[%227] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %224, %229 : f64, !llvm.ptr
%230 = llvm.load %84 : !llvm.ptr -> i64
%231 = arith.constant 1 : i32
%233 = arith.extsi %231 : i32 to i64
%232 = arith.addi %230, %233 : i64
llvm.store %232, %84 : i64, !llvm.ptr
cf.br ^bb24
^bb26:
%234 = arith.constant 0.0 : f32
%235 = llvm.load %80 : !llvm.ptr -> i64
%236 = arith.constant 1 : i32
%238 = arith.extsi %236 : i32 to i64
%237 = arith.addi %235, %238 : i64
%239 = arith.extf %234 : f32 to f64
%240 = llvm.getelementptr %176[%237] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %239, %240 : f64, !llvm.ptr
%241 = arith.constant 1.0 : f32
%242 = llvm.load %80 : !llvm.ptr -> i64
%243 = arith.constant 1 : i32
%245 = arith.extsi %243 : i32 to i64
%244 = arith.addi %242, %245 : i64
%246 = arith.extf %241 : f32 to f64
%247 = llvm.getelementptr %181[%244] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %246, %247 : f64, !llvm.ptr
%248 = arith.constant 0.0 : f32
%249 = arith.extf %248 : f32 to f64
%250 = llvm.mlir.constant(1 : i64) : i64
%251 = llvm.alloca %250 x f64 : (i64) -> !llvm.ptr
llvm.store %249, %251 : f64, !llvm.ptr
%252 = arith.constant 0 : i32
%253 = arith.extsi %252 : i32 to i64
llvm.store %253, %84 : i64, !llvm.ptr
cf.br ^bb27
^bb27:
%254 = llvm.load %84 : !llvm.ptr -> i64
%255 = llvm.load %80 : !llvm.ptr -> i64
%256 = arith.cmpi sle, %254, %255 : i64
cf.cond_br %256, ^bb28, ^bb29
^bb28:
%258 = llvm.load %84 : !llvm.ptr -> i64
%259 = llvm.getelementptr %176[%258] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%257 = llvm.load %259 : !llvm.ptr -> f64
%261 = llvm.load %84 : !llvm.ptr -> i64
%262 = llvm.getelementptr %181[%261] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%260 = llvm.load %262 : !llvm.ptr -> f64
%264 = llvm.load %84 : !llvm.ptr -> i64
%265 = arith.constant 1 : i32
%267 = arith.extsi %265 : i32 to i64
%266 = arith.addi %264, %267 : i64
%268 = llvm.getelementptr %176[%266] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%263 = llvm.load %268 : !llvm.ptr -> f64
%270 = llvm.load %84 : !llvm.ptr -> i64
%271 = arith.constant 1 : i32
%273 = arith.extsi %271 : i32 to i64
%272 = arith.addi %270, %273 : i64
%274 = llvm.getelementptr %181[%272] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%269 = llvm.load %274 : !llvm.ptr -> f64
%275 = arith.addf %257, %263 : f64
%276 = arith.constant 2.0 : f32
%278 = arith.extf %276 : f32 to f64
%277 = arith.divf %275, %278 : f64
%279 = arith.addf %260, %269 : f64
%280 = arith.constant 2.0 : f32
%282 = arith.extf %280 : f32 to f64
%281 = arith.divf %279, %282 : f64
%284 = arith.constant 0 : i32
%285 = arith.extsi %284 : i32 to i64
%286 = llvm.getelementptr %0[%285] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%283 = llvm.load %286 : !llvm.ptr -> f64
%287 = arith.mulf %283, %277 : f64
%289 = arith.constant 0 : i32
%290 = arith.extsi %289 : i32 to i64
%291 = llvm.getelementptr %5[%290] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%288 = llvm.load %291 : !llvm.ptr -> f64
%292 = arith.mulf %288, %281 : f64
%293 = arith.addf %287, %292 : f64
%295 = arith.constant 1 : i32
%296 = arith.extsi %295 : i32 to i64
%297 = llvm.getelementptr %0[%296] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%294 = llvm.load %297 : !llvm.ptr -> f64
%298 = arith.mulf %294, %277 : f64
%300 = arith.constant 1 : i32
%301 = arith.extsi %300 : i32 to i64
%302 = llvm.getelementptr %5[%301] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%299 = llvm.load %302 : !llvm.ptr -> f64
%303 = arith.mulf %299, %281 : f64
%304 = arith.addf %298, %303 : f64
%306 = arith.constant 2 : i32
%307 = arith.extsi %306 : i32 to i64
%308 = llvm.getelementptr %0[%307] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%305 = llvm.load %308 : !llvm.ptr -> f64
%309 = arith.mulf %305, %277 : f64
%311 = arith.constant 2 : i32
%312 = arith.extsi %311 : i32 to i64
%313 = llvm.getelementptr %5[%312] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%310 = llvm.load %313 : !llvm.ptr -> f64
%314 = arith.mulf %310, %281 : f64
%315 = arith.addf %309, %314 : f64
%316 = arith.constant 0 : i32
%317 = arith.extsi %316 : i32 to i64
%318 = llvm.mlir.constant(1 : i64) : i64
%319 = llvm.alloca %318 x i64 : (i64) -> !llvm.ptr
llvm.store %317, %319 : i64, !llvm.ptr
%320 = arith.cmpf ole, %293, %304 : f64
%321 = scf.if %320 -> (i1) {
%322 = arith.cmpf ole, %304, %315 : f64
scf.yield %322 : i1
} else {
%323 = arith.constant false
scf.yield %323 : i1
}
%324 = scf.if %321 -> (i1) {
%325 = arith.constant true
scf.yield %325 : i1
} else {
%326 = arith.cmpf ole, %315, %304 : f64
%327 = scf.if %326 -> (i1) {
%328 = arith.cmpf ole, %304, %293 : f64
scf.yield %328 : i1
} else {
%329 = arith.constant false
scf.yield %329 : i1
}
scf.yield %327 : i1
}
cf.cond_br %324, ^bb30, ^bb31
^bb30:
%330 = arith.constant 1 : i32
%331 = arith.extsi %330 : i32 to i64
llvm.store %331, %319 : i64, !llvm.ptr
cf.br ^bb32
^bb31:
%332 = arith.cmpf ole, %304, %315 : f64
%333 = scf.if %332 -> (i1) {
%334 = arith.cmpf ole, %315, %293 : f64
scf.yield %334 : i1
} else {
%335 = arith.constant false
scf.yield %335 : i1
}
%336 = scf.if %333 -> (i1) {
%337 = arith.constant true
scf.yield %337 : i1
} else {
%338 = arith.cmpf ole, %293, %315 : f64
%339 = scf.if %338 -> (i1) {
%340 = arith.cmpf ole, %315, %304 : f64
scf.yield %340 : i1
} else {
%341 = arith.constant false
scf.yield %341 : i1
}
scf.yield %339 : i1
}
cf.cond_br %336, ^bb33, ^bb34
^bb33:
%342 = arith.constant 2 : i32
%343 = arith.extsi %342 : i32 to i64
llvm.store %343, %319 : i64, !llvm.ptr
cf.br ^bb35
^bb34:
%344 = arith.constant 0 : i32
%345 = arith.extsi %344 : i32 to i64
llvm.store %345, %319 : i64, !llvm.ptr
cf.br ^bb35
^bb35:
cf.br ^bb32
^bb32:
%346 = arith.mulf %257, %269 : f64
%347 = arith.mulf %260, %263 : f64
%348 = arith.subf %346, %347 : f64
%349 = llvm.mlir.constant(1 : i64) : i64
%350 = llvm.alloca %349 x f64 : (i64) -> !llvm.ptr
llvm.store %348, %350 : f64, !llvm.ptr
%351 = llvm.load %350 : !llvm.ptr -> f64
%352 = arith.constant 0.0 : f32
%354 = arith.extf %352 : f32 to f64
%353 = arith.cmpf olt, %351, %354 : f64
cf.cond_br %353, ^bb36, ^bb37
^bb36:
%355 = arith.constant 0.0 : f32
%356 = llvm.load %350 : !llvm.ptr -> f64
%358 = arith.extf %355 : f32 to f64
%357 = arith.subf %358, %356 : f64
llvm.store %357, %350 : f64, !llvm.ptr
cf.br ^bb38
^bb37:
cf.br ^bb38
^bb38:
%360 = llvm.load %319 : !llvm.ptr -> i64
%361 = llvm.getelementptr %0[%360] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%359 = llvm.load %361 : !llvm.ptr -> f64
%362 = arith.mulf %359, %257 : f64
%364 = llvm.load %319 : !llvm.ptr -> i64
%365 = llvm.getelementptr %5[%364] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%363 = llvm.load %365 : !llvm.ptr -> f64
%366 = arith.mulf %363, %260 : f64
%367 = arith.addf %362, %366 : f64
%369 = llvm.load %319 : !llvm.ptr -> i64
%370 = llvm.getelementptr %0[%369] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%368 = llvm.load %370 : !llvm.ptr -> f64
%371 = arith.mulf %368, %263 : f64
%373 = llvm.load %319 : !llvm.ptr -> i64
%374 = llvm.getelementptr %5[%373] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%372 = llvm.load %374 : !llvm.ptr -> f64
%375 = arith.mulf %372, %269 : f64
%376 = arith.addf %371, %375 : f64
%377 = llvm.load %251 : !llvm.ptr -> f64
%378 = arith.constant 6.0 : f32
%379 = llvm.load %350 : !llvm.ptr -> f64
%381 = arith.extf %378 : f32 to f64
%380 = arith.mulf %381, %379 : f64
%382 = arith.addf %367, %376 : f64
%383 = arith.mulf %380, %382 : f64
%384 = arith.constant 24.0 : f32
%386 = arith.extf %384 : f32 to f64
%385 = arith.divf %383, %386 : f64
%387 = arith.addf %377, %385 : f64
llvm.store %387, %251 : f64, !llvm.ptr
%388 = llvm.load %84 : !llvm.ptr -> i64
%389 = arith.constant 1 : i32
%391 = arith.extsi %389 : i32 to i64
%390 = arith.addi %388, %391 : i64
llvm.store %390, %84 : i64, !llvm.ptr
cf.br ^bb27
^bb29:
func.call @free(%0) : (!llvm.ptr) -> ()
func.call @free(%5) : (!llvm.ptr) -> ()
func.call @free(%72) : (!llvm.ptr) -> ()
func.call @free(%176) : (!llvm.ptr) -> ()
func.call @free(%181) : (!llvm.ptr) -> ()
%397 = llvm.load %251 : !llvm.ptr -> f64
func.return %397 : f64
}
func.func @T_of(%arg0: i64, %arg1: !llvm.ptr, %arg2: !llvm.ptr) -> f64 {
%398 = arith.constant 1.6180339887498949 : f32
%399 = arith.extf %398 : f32 to f64
%401 = arith.constant 5 : i32
%402 = arith.constant 8 : i32
%403 = arith.extsi %401 : i32 to i64
%404 = arith.extsi %402 : i32 to i64
%400 = func.call @calloc(%403, %404) : (i64, i64) -> !llvm.ptr
%405 = arith.constant 0.0 : f32
%406 = arith.constant 0 : i32
%407 = arith.extf %405 : f32 to f64
%408 = arith.extsi %406 : i32 to i64
%409 = llvm.getelementptr %400[%408] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %407, %409 : f64, !llvm.ptr
%410 = arith.constant 1.0 : f32
%412 = arith.extf %410 : f32 to f64
%411 = arith.divf %412, %399 : f64
%413 = arith.constant 1.0 : f32
%414 = arith.constant 1.0 : f32
%416 = arith.extf %414 : f32 to f64
%415 = arith.divf %416, %399 : f64
%418 = arith.extf %413 : f32 to f64
%417 = arith.addf %418, %415 : f64
%419 = arith.divf %411, %417 : f64
%420 = arith.constant 1 : i32
%421 = arith.extsi %420 : i32 to i64
%422 = llvm.getelementptr %400[%421] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %419, %422 : f64, !llvm.ptr
%423 = arith.constant 0.5 : f32
%424 = arith.constant 2 : i32
%425 = arith.extf %423 : f32 to f64
%426 = arith.extsi %424 : i32 to i64
%427 = llvm.getelementptr %400[%426] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %425, %427 : f64, !llvm.ptr
%428 = arith.constant 1.0 : f32
%430 = arith.extf %428 : f32 to f64
%429 = arith.addf %430, %399 : f64
%431 = arith.divf %399, %429 : f64
%432 = arith.constant 3 : i32
%433 = arith.extsi %432 : i32 to i64
%434 = llvm.getelementptr %400[%433] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %431, %434 : f64, !llvm.ptr
%435 = arith.constant 1.0 : f32
%436 = arith.constant 4 : i32
%437 = arith.extf %435 : f32 to f64
%438 = arith.extsi %436 : i32 to i64
%439 = llvm.getelementptr %400[%438] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %437, %439 : f64, !llvm.ptr
%440 = arith.constant 0.0 : f32
%441 = arith.extf %440 : f32 to f64
%442 = llvm.mlir.constant(1 : i64) : i64
%443 = llvm.alloca %442 x f64 : (i64) -> !llvm.ptr
llvm.store %441, %443 : f64, !llvm.ptr
%444 = arith.constant 0 : i32
%445 = arith.extsi %444 : i32 to i64
%446 = llvm.mlir.constant(1 : i64) : i64
%447 = llvm.alloca %446 x i64 : (i64) -> !llvm.ptr
llvm.store %445, %447 : i64, !llvm.ptr
cf.br ^bb39
^bb39:
%448 = llvm.load %447 : !llvm.ptr -> i64
%449 = arith.constant 4 : i32
%451 = arith.extsi %449 : i32 to i64
%450 = arith.cmpi slt, %448, %451 : i64
cf.cond_br %450, ^bb40, ^bb41
^bb40:
%453 = llvm.load %447 : !llvm.ptr -> i64
%454 = llvm.getelementptr %400[%453] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%452 = llvm.load %454 : !llvm.ptr -> f64
%456 = llvm.load %447 : !llvm.ptr -> i64
%457 = arith.constant 1 : i32
%459 = arith.extsi %457 : i32 to i64
%458 = arith.addi %456, %459 : i64
%460 = llvm.getelementptr %400[%458] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%455 = llvm.load %460 : !llvm.ptr -> f64
%461 = arith.constant 0 : i32
%462 = arith.extsi %461 : i32 to i64
%463 = llvm.mlir.constant(1 : i64) : i64
%464 = llvm.alloca %463 x i64 : (i64) -> !llvm.ptr
llvm.store %462, %464 : i64, !llvm.ptr
cf.br ^bb42
^bb42:
%465 = llvm.load %464 : !llvm.ptr -> i64
%466 = arith.constant 16 : i32
%468 = arith.extsi %466 : i32 to i64
%467 = arith.cmpi slt, %465, %468 : i64
cf.cond_br %467, ^bb43, ^bb44
^bb43:
%469 = arith.subf %455, %452 : f64
%470 = llvm.load %464 : !llvm.ptr -> i64
%471 = arith.sitofp %470 : i64 to f64
%472 = arith.mulf %469, %471 : f64
%473 = arith.constant 16.0 : f32
%475 = arith.extf %473 : f32 to f64
%474 = arith.divf %472, %475 : f64
%476 = arith.addf %452, %474 : f64
%477 = arith.subf %455, %452 : f64
%478 = llvm.load %464 : !llvm.ptr -> i64
%479 = arith.constant 1 : i32
%481 = arith.extsi %479 : i32 to i64
%480 = arith.addi %478, %481 : i64
%482 = arith.sitofp %480 : i64 to f64
%483 = arith.mulf %477, %482 : f64
%484 = arith.constant 16.0 : f32
%486 = arith.extf %484 : f32 to f64
%485 = arith.divf %483, %486 : f64
%487 = arith.addf %452, %485 : f64
%488 = arith.constant 0 : i32
%489 = arith.extsi %488 : i32 to i64
%490 = llvm.mlir.constant(1 : i64) : i64
%491 = llvm.alloca %490 x i64 : (i64) -> !llvm.ptr
llvm.store %489, %491 : i64, !llvm.ptr
cf.br ^bb45
^bb45:
%492 = llvm.load %491 : !llvm.ptr -> i64
%493 = arith.constant 16 : i32
%495 = arith.extsi %493 : i32 to i64
%494 = arith.cmpi slt, %492, %495 : i64
cf.cond_br %494, ^bb46, ^bb47
^bb46:
%496 = arith.subf %487, %476 : f64
%497 = arith.constant 0.5 : f32
%499 = arith.extf %497 : f32 to f64
%498 = arith.mulf %496, %499 : f64
%501 = llvm.load %491 : !llvm.ptr -> i64
%502 = llvm.getelementptr %arg1[%501] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%500 = llvm.load %502 : !llvm.ptr -> f64
%503 = arith.constant 1.0 : f32
%505 = arith.extf %503 : f32 to f64
%504 = arith.addf %500, %505 : f64
%506 = arith.mulf %498, %504 : f64
%507 = arith.addf %476, %506 : f64
%508 = arith.constant 0.5 : f32
%509 = arith.subf %487, %476 : f64
%511 = arith.extf %508 : f32 to f64
%510 = arith.mulf %511, %509 : f64
%513 = llvm.load %491 : !llvm.ptr -> i64
%514 = llvm.getelementptr %arg2[%513] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%512 = llvm.load %514 : !llvm.ptr -> f64
%515 = arith.mulf %510, %512 : f64
%516 = arith.constant 1.0 : f32
%518 = arith.extf %516 : f32 to f64
%517 = arith.subf %518, %507 : f64
%519 = arith.divf %507, %517 : f64
%520 = arith.constant 1.0 : f32
%521 = arith.constant 1.0 : f32
%523 = arith.extf %521 : f32 to f64
%522 = arith.subf %523, %507 : f64
%524 = arith.constant 1.0 : f32
%526 = arith.extf %524 : f32 to f64
%525 = arith.subf %526, %507 : f64
%527 = arith.mulf %522, %525 : f64
%529 = arith.extf %520 : f32 to f64
%528 = arith.divf %529, %527 : f64
%530 = func.call @H_of(%arg0, %519) : (i64, f64) -> f64
%531 = arith.constant 1.0 : f32
%533 = arith.extf %531 : f32 to f64
%532 = arith.addf %533, %519 : f64
%534 = llvm.load %443 : !llvm.ptr -> f64
%535 = arith.mulf %515, %530 : f64
%536 = arith.constant 2.0 : f32
%538 = arith.extf %536 : f32 to f64
%537 = arith.mulf %538, %532 : f64
%539 = arith.mulf %537, %532 : f64
%540 = arith.mulf %539, %532 : f64
%541 = arith.divf %535, %540 : f64
%542 = arith.mulf %541, %528 : f64
%543 = arith.addf %534, %542 : f64
llvm.store %543, %443 : f64, !llvm.ptr
%544 = llvm.load %491 : !llvm.ptr -> i64
%545 = arith.constant 1 : i32
%547 = arith.extsi %545 : i32 to i64
%546 = arith.addi %544, %547 : i64
llvm.store %546, %491 : i64, !llvm.ptr
cf.br ^bb45
^bb47:
%548 = llvm.load %464 : !llvm.ptr -> i64
%549 = arith.constant 1 : i32
%551 = arith.extsi %549 : i32 to i64
%550 = arith.addi %548, %551 : i64
llvm.store %550, %464 : i64, !llvm.ptr
cf.br ^bb42
^bb44:
%552 = llvm.load %447 : !llvm.ptr -> i64
%553 = arith.constant 1 : i32
%555 = arith.extsi %553 : i32 to i64
%554 = arith.addi %552, %555 : i64
llvm.store %554, %447 : i64, !llvm.ptr
cf.br ^bb39
^bb41:
func.call @free(%400) : (!llvm.ptr) -> ()
%557 = llvm.load %443 : !llvm.ptr -> f64
func.return %557 : f64
}
func.func @main() -> i32 {
%559 = arith.constant 16 : i32
%560 = arith.constant 8 : i32
%561 = arith.extsi %559 : i32 to i64
%562 = arith.extsi %560 : i32 to i64
%558 = func.call @calloc(%561, %562) : (i64, i64) -> !llvm.ptr
%564 = arith.constant 16 : i32
%565 = arith.constant 8 : i32
%566 = arith.extsi %564 : i32 to i64
%567 = arith.extsi %565 : i32 to i64
%563 = func.call @calloc(%566, %567) : (i64, i64) -> !llvm.ptr
%568 = arith.constant 0.98940093499164994 : f32
%569 = arith.negf %568 : f32
%570 = arith.constant 0 : i32
%571 = arith.extf %569 : f32 to f64
%572 = arith.extsi %570 : i32 to i64
%573 = llvm.getelementptr %558[%572] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %571, %573 : f64, !llvm.ptr
%574 = arith.constant 0.9445750230732326 : f32
%575 = arith.negf %574 : f32
%576 = arith.constant 1 : i32
%577 = arith.extf %575 : f32 to f64
%578 = arith.extsi %576 : i32 to i64
%579 = llvm.getelementptr %558[%578] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %577, %579 : f64, !llvm.ptr
%580 = arith.constant 0.86563120238783164 : f32
%581 = arith.negf %580 : f32
%582 = arith.constant 2 : i32
%583 = arith.extf %581 : f32 to f64
%584 = arith.extsi %582 : i32 to i64
%585 = llvm.getelementptr %558[%584] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %583, %585 : f64, !llvm.ptr
%586 = arith.constant 0.75540440835500311 : f32
%587 = arith.negf %586 : f32
%588 = arith.constant 3 : i32
%589 = arith.extf %587 : f32 to f64
%590 = arith.extsi %588 : i32 to i64
%591 = llvm.getelementptr %558[%590] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %589, %591 : f64, !llvm.ptr
%592 = arith.constant 0.61787624440264377 : f32
%593 = arith.negf %592 : f32
%594 = arith.constant 4 : i32
%595 = arith.extf %593 : f32 to f64
%596 = arith.extsi %594 : i32 to i64
%597 = llvm.getelementptr %558[%596] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %595, %597 : f64, !llvm.ptr
%598 = arith.constant 0.45801677765722737 : f32
%599 = arith.negf %598 : f32
%600 = arith.constant 5 : i32
%601 = arith.extf %599 : f32 to f64
%602 = arith.extsi %600 : i32 to i64
%603 = llvm.getelementptr %558[%602] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %601, %603 : f64, !llvm.ptr
%604 = arith.constant 0.28160355077925892 : f32
%605 = arith.negf %604 : f32
%606 = arith.constant 6 : i32
%607 = arith.extf %605 : f32 to f64
%608 = arith.extsi %606 : i32 to i64
%609 = llvm.getelementptr %558[%608] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %607, %609 : f64, !llvm.ptr
%610 = arith.constant 0.095012509837637441 : f32
%611 = arith.negf %610 : f32
%612 = arith.constant 7 : i32
%613 = arith.extf %611 : f32 to f64
%614 = arith.extsi %612 : i32 to i64
%615 = llvm.getelementptr %558[%614] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %613, %615 : f64, !llvm.ptr
%616 = arith.constant 0.095012509837637441 : f32
%617 = arith.constant 8 : i32
%618 = arith.extf %616 : f32 to f64
%619 = arith.extsi %617 : i32 to i64
%620 = llvm.getelementptr %558[%619] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %618, %620 : f64, !llvm.ptr
%621 = arith.constant 0.28160355077925892 : f32
%622 = arith.constant 9 : i32
%623 = arith.extf %621 : f32 to f64
%624 = arith.extsi %622 : i32 to i64
%625 = llvm.getelementptr %558[%624] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %623, %625 : f64, !llvm.ptr
%626 = arith.constant 0.45801677765722737 : f32
%627 = arith.constant 10 : i32
%628 = arith.extf %626 : f32 to f64
%629 = arith.extsi %627 : i32 to i64
%630 = llvm.getelementptr %558[%629] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %628, %630 : f64, !llvm.ptr
%631 = arith.constant 0.61787624440264377 : f32
%632 = arith.constant 11 : i32
%633 = arith.extf %631 : f32 to f64
%634 = arith.extsi %632 : i32 to i64
%635 = llvm.getelementptr %558[%634] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %633, %635 : f64, !llvm.ptr
%636 = arith.constant 0.75540440835500311 : f32
%637 = arith.constant 12 : i32
%638 = arith.extf %636 : f32 to f64
%639 = arith.extsi %637 : i32 to i64
%640 = llvm.getelementptr %558[%639] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %638, %640 : f64, !llvm.ptr
%641 = arith.constant 0.86563120238783164 : f32
%642 = arith.constant 13 : i32
%643 = arith.extf %641 : f32 to f64
%644 = arith.extsi %642 : i32 to i64
%645 = llvm.getelementptr %558[%644] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %643, %645 : f64, !llvm.ptr
%646 = arith.constant 0.9445750230732326 : f32
%647 = arith.constant 14 : i32
%648 = arith.extf %646 : f32 to f64
%649 = arith.extsi %647 : i32 to i64
%650 = llvm.getelementptr %558[%649] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %648, %650 : f64, !llvm.ptr
%651 = arith.constant 0.98940093499164994 : f32
%652 = arith.constant 15 : i32
%653 = arith.extf %651 : f32 to f64
%654 = arith.extsi %652 : i32 to i64
%655 = llvm.getelementptr %558[%654] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %653, %655 : f64, !llvm.ptr
%656 = arith.constant 0.027152459411754055 : f32
%657 = arith.constant 0 : i32
%658 = arith.extf %656 : f32 to f64
%659 = arith.extsi %657 : i32 to i64
%660 = llvm.getelementptr %563[%659] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %658, %660 : f64, !llvm.ptr
%661 = arith.constant 0.062253523938647609 : f32
%662 = arith.constant 1 : i32
%663 = arith.extf %661 : f32 to f64
%664 = arith.extsi %662 : i32 to i64
%665 = llvm.getelementptr %563[%664] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %663, %665 : f64, !llvm.ptr
%666 = arith.constant 0.095158511682492994 : f32
%667 = arith.constant 2 : i32
%668 = arith.extf %666 : f32 to f64
%669 = arith.extsi %667 : i32 to i64
%670 = llvm.getelementptr %563[%669] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %668, %670 : f64, !llvm.ptr
%671 = arith.constant 0.12462897125553395 : f32
%672 = arith.constant 3 : i32
%673 = arith.extf %671 : f32 to f64
%674 = arith.extsi %672 : i32 to i64
%675 = llvm.getelementptr %563[%674] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %673, %675 : f64, !llvm.ptr
%676 = arith.constant 0.14959598881657665 : f32
%677 = arith.constant 4 : i32
%678 = arith.extf %676 : f32 to f64
%679 = arith.extsi %677 : i32 to i64
%680 = llvm.getelementptr %563[%679] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %678, %680 : f64, !llvm.ptr
%681 = arith.constant 0.16915651939500262 : f32
%682 = arith.constant 5 : i32
%683 = arith.extf %681 : f32 to f64
%684 = arith.extsi %682 : i32 to i64
%685 = llvm.getelementptr %563[%684] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %683, %685 : f64, !llvm.ptr
%686 = arith.constant 0.18260341504492361 : f32
%687 = arith.constant 6 : i32
%688 = arith.extf %686 : f32 to f64
%689 = arith.extsi %687 : i32 to i64
%690 = llvm.getelementptr %563[%689] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %688, %690 : f64, !llvm.ptr
%691 = arith.constant 0.18945061045506859 : f32
%692 = arith.constant 7 : i32
%693 = arith.extf %691 : f32 to f64
%694 = arith.extsi %692 : i32 to i64
%695 = llvm.getelementptr %563[%694] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %693, %695 : f64, !llvm.ptr
%696 = arith.constant 0.18945061045506859 : f32
%697 = arith.constant 8 : i32
%698 = arith.extf %696 : f32 to f64
%699 = arith.extsi %697 : i32 to i64
%700 = llvm.getelementptr %563[%699] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %698, %700 : f64, !llvm.ptr
%701 = arith.constant 0.18260341504492361 : f32
%702 = arith.constant 9 : i32
%703 = arith.extf %701 : f32 to f64
%704 = arith.extsi %702 : i32 to i64
%705 = llvm.getelementptr %563[%704] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %703, %705 : f64, !llvm.ptr
%706 = arith.constant 0.16915651939500262 : f32
%707 = arith.constant 10 : i32
%708 = arith.extf %706 : f32 to f64
%709 = arith.extsi %707 : i32 to i64
%710 = llvm.getelementptr %563[%709] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %708, %710 : f64, !llvm.ptr
%711 = arith.constant 0.14959598881657665 : f32
%712 = arith.constant 11 : i32
%713 = arith.extf %711 : f32 to f64
%714 = arith.extsi %712 : i32 to i64
%715 = llvm.getelementptr %563[%714] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %713, %715 : f64, !llvm.ptr
%716 = arith.constant 0.12462897125553395 : f32
%717 = arith.constant 12 : i32
%718 = arith.extf %716 : f32 to f64
%719 = arith.extsi %717 : i32 to i64
%720 = llvm.getelementptr %563[%719] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %718, %720 : f64, !llvm.ptr
%721 = arith.constant 0.095158511682492994 : f32
%722 = arith.constant 13 : i32
%723 = arith.extf %721 : f32 to f64
%724 = arith.extsi %722 : i32 to i64
%725 = llvm.getelementptr %563[%724] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %723, %725 : f64, !llvm.ptr
%726 = arith.constant 0.062253523938647609 : f32
%727 = arith.constant 14 : i32
%728 = arith.extf %726 : f32 to f64
%729 = arith.extsi %727 : i32 to i64
%730 = llvm.getelementptr %563[%729] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %728, %730 : f64, !llvm.ptr
%731 = arith.constant 0.027152459411754055 : f32
%732 = arith.constant 15 : i32
%733 = arith.extf %731 : f32 to f64
%734 = arith.extsi %732 : i32 to i64
%735 = llvm.getelementptr %563[%734] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %733, %735 : f64, !llvm.ptr
%737 = arith.constant 1 : i32
%738 = arith.extsi %737 : i32 to i64
%736 = func.call @T_of(%738, %558, %563) : (i64, !llvm.ptr, !llvm.ptr) -> f64
%740 = arith.constant 2 : i32
%741 = arith.extsi %740 : i32 to i64
%739 = func.call @T_of(%741, %558, %563) : (i64, !llvm.ptr, !llvm.ptr) -> f64
%742 = arith.constant 3.0 : f32
%744 = arith.extf %742 : f32 to f64
%743 = arith.divf %736, %744 : f64
%745 = arith.constant 2.0 : f32
%747 = arith.extf %745 : f32 to f64
%746 = arith.mulf %747, %739 : f64
%748 = arith.constant 3.0 : f32
%750 = arith.extf %748 : f32 to f64
%749 = arith.divf %746, %750 : f64
%751 = arith.addf %743, %749 : f64
%752 = llvm.mlir.addressof @str_0 : !llvm.ptr
%753 = llvm.call @printf(%752, %751) vararg(!llvm.func<i32 (ptr, ...)>) : (!llvm.ptr, f64) -> i32
func.call @free(%558) : (!llvm.ptr) -> ()
func.call @free(%563) : (!llvm.ptr) -> ()
%756 = arith.constant 0 : i32
func.return %756 : i32
}
}