Problem 825
Computes T(10^14) rounded to 8 decimal places. Pure Flow port of native/p825.c.
View problem on Project Euler
Performance comparison
| Metric | Our solution | Best known |
| Time complexity | O(n^2) | ? |
| Space complexity | O(1) | ? |
| Approach | Flow solution | Not curated |
| Verdict | Unknown |
Flow source
# Project Euler 825 - Chasing Game
# Computes T(10^14) rounded to 8 decimal places.
# Pure Flow port of native/p825.c.
extern {
function sqrt(x: f64) -> f64
function log(x: f64) -> f64
function fabs(x: f64) -> f64
function malloc(n: i64) -> ptr<void>
function free(p: ptr<void>) -> void
}
function dpow(base: f64, exp: i64) -> f64 {
let mut result: f64 = 1.0
let mut b: f64 = base
let mut e: i64 = exp
while e > 0 {
if e % 2 == 1 {
result = result * b
}
b = b * b
e = e / 2
}
return result
}
function digamma(x0: f64) -> f64 {
let mut x: f64 = x0
let mut res: f64 = 0.0
while x < 8.0 {
res = res - 1.0 / x
x = x + 1.0
}
let inv: f64 = 1.0 / x
let inv2: f64 = inv * inv
res = res + log(x) - 0.5 * inv
let mut t: f64 = inv2
res = res - t / 12.0
t = t * inv2
res = res + t / 120.0
t = t * inv2
res = res - t / 252.0
t = t * inv2
res = res + t / 240.0
t = t * inv2
res = res - t / 132.0
t = t * inv2
res = res + t * (691.0 / 32760.0)
return res
}
# Gauss elimination on 4x4 augmented matrix (4 rows, 5 cols).
# mat is a flat array of 20 doubles (row-major, 4 cols + 1 RHS).
function gauss_solve_4x4(mat: ptr<f64>, sol: ptr<f64>) -> void {
let mut c: i64 = 0
while c < 4 {
let mut piv: i64 = c
let mut r: i64 = c + 1
while r < 4 {
if fabs(mat[r * 5 + c]) > fabs(mat[piv * 5 + c]) {
piv = r
}
r = r + 1
}
if piv != c {
let mut j: i64 = 0
while j < 5 {
let tmp: f64 = mat[c * 5 + j]
mat[c * 5 + j] = mat[piv * 5 + j]
mat[piv * 5 + j] = tmp
j = j + 1
}
}
let pv: f64 = mat[c * 5 + c]
let mut j: i64 = c
while j < 5 {
mat[c * 5 + j] = mat[c * 5 + j] / pv
j = j + 1
}
let mut r2: i64 = 0
while r2 < 4 {
if r2 == c {
r2 = r2 + 1
continue
}
let f: f64 = mat[r2 * 5 + c]
if f == 0.0 {
r2 = r2 + 1
continue
}
let mut j2: i64 = c
while j2 < 5 {
mat[r2 * 5 + j2] = mat[r2 * 5 + j2] - f * mat[c * 5 + j2]
j2 = j2 + 1
}
r2 = r2 + 1
}
c = c + 1
}
let mut i: i64 = 0
while i < 4 {
sol[i] = mat[i * 5 + 4]
i = i + 1
}
}
function S_fast_float(n: i64) -> f64 {
if n < 2 { return 0.0 }
if n == 2 {
return 7.0 / 11.0
}
let L: i64 = 2 * n
let q: f64 = -2.0 + sqrt(3.0)
# row(y) = [1, y, q^y, q^(L-y)]
# for y = 2,3,4,5,L-2,L-1
let row: ptr<f64> = malloc(24 * 8)
let ys: ptr<i64> = malloc(6 * 8)
ys[0] = 2
ys[1] = 3
ys[2] = 4
ys[3] = 5
ys[4] = L - 2
ys[5] = L - 1
let mut i: i64 = 0
while i < 6 {
let y: i64 = ys[i]
row[i * 4 + 0] = 1.0
row[i * 4 + 1] = y as f64
row[i * 4 + 2] = dpow(q, y)
row[i * 4 + 3] = dpow(q, L - y)
i = i + 1
}
# indices: row(2)=0, row(3)=1, row(4)=2, row(5)=3, row(L-2)=4, row(L-1)=5
let mat: ptr<f64> = malloc(20 * 8)
# Eq1: g(2) + (1/3) g(L-1) = 1
let mut j: i64 = 0
while j < 4 {
mat[0 * 5 + j] = row[0 * 4 + j] + (1.0 / 3.0) * row[5 * 4 + j]
j = j + 1
}
mat[0 * 5 + 4] = 1.0
# Eq2: g(3) + (1/3) g(L-2) + (1/3) g(L-1) = 1
j = 0
while j < 4 {
mat[1 * 5 + j] = row[1 * 4 + j] + (1.0 / 3.0) * row[4 * 4 + j] + (1.0 / 3.0) * row[5 * 4 + j]
j = j + 1
}
mat[1 * 5 + 4] = 1.0
# Eq3: g(L-1) + (1/3)g(2) + (1/3)g(3) + (1/3)g(4) = 1
j = 0
while j < 4 {
mat[2 * 5 + j] = row[5 * 4 + j] + (1.0 / 3.0) * row[0 * 4 + j] + (1.0 / 3.0) * row[1 * 4 + j] + (1.0 / 3.0) * row[2 * 4 + j]
j = j + 1
}
mat[2 * 5 + 4] = 1.0
# Eq4: g(L-2) + (1/3)g(3) + (1/3)g(4) + (1/3)g(5) = 1
j = 0
while j < 4 {
mat[3 * 5 + j] = row[4 * 4 + j] + (1.0 / 3.0) * row[1 * 4 + j] + (1.0 / 3.0) * row[2 * 4 + j] + (1.0 / 3.0) * row[3 * 4 + j]
j = j + 1
}
mat[3 * 5 + 4] = 1.0
let sol: ptr<f64> = malloc(4 * 8)
gauss_solve_4x4(mat, sol)
let A: f64 = sol[0]
let B: f64 = sol[1]
let C: f64 = sol[2]
let E: f64 = sol[3]
let gn: f64 = A + B * (n as f64) + C * dpow(q, n) + E * dpow(q, L - n)
free(row)
free(ys)
free(mat)
free(sol)
return 2.0 * gn - 1.0
}
function correction_constant() -> f64 {
let c: f64 = (3.0 - sqrt(3.0)) / 6.0
let mut acc: f64 = 0.0
let mut n: i64 = 2
while n <= 60 {
acc = acc + S_fast_float(n) - 1.0 / ((n - 1) as f64 + c)
n = n + 1
}
return acc
}
function main() -> i32 {
let c: f64 = (3.0 - sqrt(3.0)) / 6.0
let K: f64 = correction_constant()
let N: f64 = 1e14
let shs: f64 = digamma(N + c) - digamma(1.0 + c)
let ans: f64 = shs + K
printf("%.8f\n", ans)
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 dpow_f64_i64(double base, int64_t exp);
double digamma_f64(double x0);
void gauss_solve_4x4_ptr_f64_ptr_f64(double* mat, double* sol);
double S_fast_float_i64(int64_t n);
double correction_constant(void);
int32_t main(void);
double dpow_f64_i64(double base, int64_t exp) {
double result = 1.0;
double b = base;
int64_t e = exp;
while (e > 0) {
if (FLOW_CHECKED_MOD((e), (2)) == 1) {
result = (result * b);
}
b = (b * b);
e = FLOW_CHECKED_DIV((e), (2));
}
return result;
}
double digamma_f64(double x0) {
double x = x0;
double res = 0.0;
while (x < 8.0) {
res = (res - (1.0 / x));
x = (x + 1.0);
}
double inv = (1.0 / x);
double inv2 = (inv * inv);
res = ((res + log(x)) - (0.5 * inv));
double t = inv2;
res = (res - (t / 12.0));
t = (t * inv2);
res = (res + (t / 120.0));
t = (t * inv2);
res = (res - (t / 252.0));
t = (t * inv2);
res = (res + (t / 240.0));
t = (t * inv2);
res = (res - (t / 132.0));
t = (t * inv2);
res = (res + (t * (691.0 / 32760.0)));
return res;
}
void gauss_solve_4x4_ptr_f64_ptr_f64(double* mat, double* sol) {
int64_t c = 0;
while (c < 4) {
int64_t piv = c;
int64_t r = (c + 1);
while (r < 4) {
if (fabs(mat[((r * 5) + c)]) > fabs(mat[((piv * 5) + c)])) {
piv = r;
}
r = (r + 1);
}
if (piv != c) {
int64_t j = 0;
while (j < 5) {
double tmp = mat[((c * 5) + j)];
mat[((c * 5) + j)] = mat[((piv * 5) + j)];
mat[((piv * 5) + j)] = tmp;
j = (j + 1);
}
}
double pv = mat[((c * 5) + c)];
int64_t j = c;
while (j < 5) {
mat[((c * 5) + j)] = (mat[((c * 5) + j)] / pv);
j = (j + 1);
}
int64_t r2 = 0;
while (r2 < 4) {
if (r2 == c) {
r2 = (r2 + 1);
continue;
}
double f = mat[((r2 * 5) + c)];
if (f == 0.0) {
r2 = (r2 + 1);
continue;
}
int64_t j2 = c;
while (j2 < 5) {
mat[((r2 * 5) + j2)] = (mat[((r2 * 5) + j2)] - (f * mat[((c * 5) + j2)]));
j2 = (j2 + 1);
}
r2 = (r2 + 1);
}
c = (c + 1);
}
int64_t i = 0;
while (i < 4) {
sol[i] = mat[((i * 5) + 4)];
i = (i + 1);
}
}
double S_fast_float_i64(int64_t n) {
if (n < 2) {
return 0.0;
}
if (n == 2) {
return (7.0 / 11.0);
}
int64_t L = (2 * n);
double q = ((-2.0) + sqrt(3.0));
double* row = (double*)(malloc((24 * 8)));
int64_t* ys = (int64_t*)(malloc((6 * 8)));
ys[0] = 2;
ys[1] = 3;
ys[2] = 4;
ys[3] = 5;
ys[4] = (L - 2);
ys[5] = (L - 1);
int64_t i = 0;
while (i < 6) {
int64_t y = ys[i];
row[((i * 4) + 0)] = 1.0;
row[((i * 4) + 1)] = ((double)(y));
row[((i * 4) + 2)] = dpow_f64_i64(q, y);
row[((i * 4) + 3)] = dpow_f64_i64(q, (L - y));
i = (i + 1);
}
double* mat = (double*)(malloc((20 * 8)));
int64_t j = 0;
while (j < 4) {
mat[((0 * 5) + j)] = (row[((0 * 4) + j)] + ((1.0 / 3.0) * row[((5 * 4) + j)]));
j = (j + 1);
}
mat[((0 * 5) + 4)] = 1.0;
j = 0;
while (j < 4) {
mat[((1 * 5) + j)] = ((row[((1 * 4) + j)] + ((1.0 / 3.0) * row[((4 * 4) + j)])) + ((1.0 / 3.0) * row[((5 * 4) + j)]));
j = (j + 1);
}
mat[((1 * 5) + 4)] = 1.0;
j = 0;
while (j < 4) {
mat[((2 * 5) + j)] = (((row[((5 * 4) + j)] + ((1.0 / 3.0) * row[((0 * 4) + j)])) + ((1.0 / 3.0) * row[((1 * 4) + j)])) + ((1.0 / 3.0) * row[((2 * 4) + j)]));
j = (j + 1);
}
mat[((2 * 5) + 4)] = 1.0;
j = 0;
while (j < 4) {
mat[((3 * 5) + j)] = (((row[((4 * 4) + j)] + ((1.0 / 3.0) * row[((1 * 4) + j)])) + ((1.0 / 3.0) * row[((2 * 4) + j)])) + ((1.0 / 3.0) * row[((3 * 4) + j)]));
j = (j + 1);
}
mat[((3 * 5) + 4)] = 1.0;
double* sol = (double*)(malloc((4 * 8)));
gauss_solve_4x4_ptr_f64_ptr_f64(mat, sol);
double A = sol[0];
double B = sol[1];
double C = sol[2];
double E = sol[3];
double gn = (((A + (B * ((double)(n)))) + (C * dpow_f64_i64(q, n))) + (E * dpow_f64_i64(q, (L - n))));
free(row);
free(ys);
free(mat);
free(sol);
return ((2.0 * gn) - 1.0);
}
double correction_constant(void) {
double c = ((3.0 - sqrt(3.0)) / 6.0);
double acc = 0.0;
int64_t n = 2;
while (n <= 60) {
acc = ((acc + S_fast_float_i64(n)) - (1.0 / (((double)((n - 1))) + c)));
n = (n + 1);
}
return acc;
}
int32_t main(void) {
double c = ((3.0 - sqrt(3.0)) / 6.0);
double K = correction_constant();
double N = 1e14;
double shs = (digamma_f64((N + c)) - digamma_f64((1.0 + c)));
double ans = (shs + K);
printf("%.8f\n", ans);
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 @sqrt(f64) -> f64
func.func private @log(f64) -> f64
func.func private @fabs(f64) -> f64
func.func private @malloc(i64) -> !llvm.ptr
func.func private @free(!llvm.ptr) -> ()
func.func @dpow(%arg0: f64, %arg1: i64) -> f64 {
%0 = arith.constant 1.0 : f32
%1 = arith.extf %0 : f32 to f64
%2 = llvm.mlir.constant(1 : i64) : i64
%3 = llvm.alloca %2 x f64 : (i64) -> !llvm.ptr
llvm.store %1, %3 : f64, !llvm.ptr
%4 = llvm.mlir.constant(1 : i64) : i64
%5 = llvm.alloca %4 x f64 : (i64) -> !llvm.ptr
llvm.store %arg0, %5 : f64, !llvm.ptr
%6 = llvm.mlir.constant(1 : i64) : i64
%7 = llvm.alloca %6 x i64 : (i64) -> !llvm.ptr
llvm.store %arg1, %7 : i64, !llvm.ptr
cf.br ^bb0
^bb0:
%8 = llvm.load %7 : !llvm.ptr -> i64
%9 = arith.constant 0 : i32
%11 = arith.extsi %9 : i32 to i64
%10 = arith.cmpi sgt, %8, %11 : i64
cf.cond_br %10, ^bb1, ^bb2
^bb1:
%12 = llvm.load %7 : !llvm.ptr -> i64
%13 = arith.constant 2 : i32
%15 = arith.extsi %13 : i32 to i64
%14 = arith.remsi %12, %15 : i64
%16 = arith.constant 1 : i32
%18 = arith.extsi %16 : i32 to i64
%17 = arith.cmpi eq, %14, %18 : i64
cf.cond_br %17, ^bb3, ^bb4
^bb3:
%19 = llvm.load %3 : !llvm.ptr -> f64
%20 = llvm.load %5 : !llvm.ptr -> f64
%21 = arith.mulf %19, %20 : f64
llvm.store %21, %3 : f64, !llvm.ptr
cf.br ^bb5
^bb4:
cf.br ^bb5
^bb5:
%22 = llvm.load %5 : !llvm.ptr -> f64
%23 = llvm.load %5 : !llvm.ptr -> f64
%24 = arith.mulf %22, %23 : f64
llvm.store %24, %5 : f64, !llvm.ptr
%25 = llvm.load %7 : !llvm.ptr -> i64
%26 = arith.constant 2 : i32
%28 = arith.extsi %26 : i32 to i64
%27 = arith.divsi %25, %28 : i64
llvm.store %27, %7 : i64, !llvm.ptr
cf.br ^bb0
^bb2:
%29 = llvm.load %3 : !llvm.ptr -> f64
func.return %29 : f64
}
func.func @digamma(%arg0: f64) -> f64 {
%30 = llvm.mlir.constant(1 : i64) : i64
%31 = llvm.alloca %30 x f64 : (i64) -> !llvm.ptr
llvm.store %arg0, %31 : f64, !llvm.ptr
%32 = arith.constant 0.0 : f32
%33 = arith.extf %32 : f32 to f64
%34 = llvm.mlir.constant(1 : i64) : i64
%35 = llvm.alloca %34 x f64 : (i64) -> !llvm.ptr
llvm.store %33, %35 : f64, !llvm.ptr
cf.br ^bb6
^bb6:
%36 = llvm.load %31 : !llvm.ptr -> f64
%37 = arith.constant 8.0 : f32
%39 = arith.extf %37 : f32 to f64
%38 = arith.cmpf olt, %36, %39 : f64
cf.cond_br %38, ^bb7, ^bb8
^bb7:
%40 = llvm.load %35 : !llvm.ptr -> f64
%41 = arith.constant 1.0 : f32
%42 = llvm.load %31 : !llvm.ptr -> f64
%44 = arith.extf %41 : f32 to f64
%43 = arith.divf %44, %42 : f64
%45 = arith.subf %40, %43 : f64
llvm.store %45, %35 : f64, !llvm.ptr
%46 = llvm.load %31 : !llvm.ptr -> f64
%47 = arith.constant 1.0 : f32
%49 = arith.extf %47 : f32 to f64
%48 = arith.addf %46, %49 : f64
llvm.store %48, %31 : f64, !llvm.ptr
cf.br ^bb6
^bb8:
%50 = arith.constant 1.0 : f32
%51 = llvm.load %31 : !llvm.ptr -> f64
%53 = arith.extf %50 : f32 to f64
%52 = arith.divf %53, %51 : f64
%54 = arith.mulf %52, %52 : f64
%55 = llvm.load %35 : !llvm.ptr -> f64
%56 = llvm.load %31 : !llvm.ptr -> f64
%57 = math.log %56 : f64
%58 = arith.addf %55, %57 : f64
%59 = arith.constant 0.5 : f32
%61 = arith.extf %59 : f32 to f64
%60 = arith.mulf %61, %52 : f64
%62 = arith.subf %58, %60 : f64
llvm.store %62, %35 : f64, !llvm.ptr
%63 = llvm.mlir.constant(1 : i64) : i64
%64 = llvm.alloca %63 x f64 : (i64) -> !llvm.ptr
llvm.store %54, %64 : f64, !llvm.ptr
%65 = llvm.load %35 : !llvm.ptr -> f64
%66 = llvm.load %64 : !llvm.ptr -> f64
%67 = arith.constant 12.0 : f32
%69 = arith.extf %67 : f32 to f64
%68 = arith.divf %66, %69 : f64
%70 = arith.subf %65, %68 : f64
llvm.store %70, %35 : f64, !llvm.ptr
%71 = llvm.load %64 : !llvm.ptr -> f64
%72 = arith.mulf %71, %54 : f64
llvm.store %72, %64 : f64, !llvm.ptr
%73 = llvm.load %35 : !llvm.ptr -> f64
%74 = llvm.load %64 : !llvm.ptr -> f64
%75 = arith.constant 120.0 : f32
%77 = arith.extf %75 : f32 to f64
%76 = arith.divf %74, %77 : f64
%78 = arith.addf %73, %76 : f64
llvm.store %78, %35 : f64, !llvm.ptr
%79 = llvm.load %64 : !llvm.ptr -> f64
%80 = arith.mulf %79, %54 : f64
llvm.store %80, %64 : f64, !llvm.ptr
%81 = llvm.load %35 : !llvm.ptr -> f64
%82 = llvm.load %64 : !llvm.ptr -> f64
%83 = arith.constant 252.0 : f32
%85 = arith.extf %83 : f32 to f64
%84 = arith.divf %82, %85 : f64
%86 = arith.subf %81, %84 : f64
llvm.store %86, %35 : f64, !llvm.ptr
%87 = llvm.load %64 : !llvm.ptr -> f64
%88 = arith.mulf %87, %54 : f64
llvm.store %88, %64 : f64, !llvm.ptr
%89 = llvm.load %35 : !llvm.ptr -> f64
%90 = llvm.load %64 : !llvm.ptr -> f64
%91 = arith.constant 240.0 : f32
%93 = arith.extf %91 : f32 to f64
%92 = arith.divf %90, %93 : f64
%94 = arith.addf %89, %92 : f64
llvm.store %94, %35 : f64, !llvm.ptr
%95 = llvm.load %64 : !llvm.ptr -> f64
%96 = arith.mulf %95, %54 : f64
llvm.store %96, %64 : f64, !llvm.ptr
%97 = llvm.load %35 : !llvm.ptr -> f64
%98 = llvm.load %64 : !llvm.ptr -> f64
%99 = arith.constant 132.0 : f32
%101 = arith.extf %99 : f32 to f64
%100 = arith.divf %98, %101 : f64
%102 = arith.subf %97, %100 : f64
llvm.store %102, %35 : f64, !llvm.ptr
%103 = llvm.load %64 : !llvm.ptr -> f64
%104 = arith.mulf %103, %54 : f64
llvm.store %104, %64 : f64, !llvm.ptr
%105 = llvm.load %35 : !llvm.ptr -> f64
%106 = llvm.load %64 : !llvm.ptr -> f64
%107 = arith.constant 691.0 : f32
%108 = arith.constant 32760.0 : f32
%109 = arith.divf %107, %108 : f32
%111 = arith.extf %109 : f32 to f64
%110 = arith.mulf %106, %111 : f64
%112 = arith.addf %105, %110 : f64
llvm.store %112, %35 : f64, !llvm.ptr
%113 = llvm.load %35 : !llvm.ptr -> f64
func.return %113 : f64
}
func.func @gauss_solve_4x4(%arg0: !llvm.ptr, %arg1: !llvm.ptr) -> () {
%114 = arith.constant 0 : i32
%115 = arith.extsi %114 : i32 to i64
%116 = llvm.mlir.constant(1 : i64) : i64
%117 = llvm.alloca %116 x i64 : (i64) -> !llvm.ptr
llvm.store %115, %117 : i64, !llvm.ptr
cf.br ^bb9
^bb9:
%118 = llvm.load %117 : !llvm.ptr -> i64
%119 = arith.constant 4 : i32
%121 = arith.extsi %119 : i32 to i64
%120 = arith.cmpi slt, %118, %121 : i64
cf.cond_br %120, ^bb10, ^bb11
^bb10:
%122 = llvm.load %117 : !llvm.ptr -> i64
%123 = llvm.mlir.constant(1 : i64) : i64
%124 = llvm.alloca %123 x i64 : (i64) -> !llvm.ptr
llvm.store %122, %124 : i64, !llvm.ptr
%125 = llvm.load %117 : !llvm.ptr -> i64
%126 = arith.constant 1 : i32
%128 = arith.extsi %126 : i32 to i64
%127 = arith.addi %125, %128 : i64
%129 = llvm.mlir.constant(1 : i64) : i64
%130 = llvm.alloca %129 x i64 : (i64) -> !llvm.ptr
llvm.store %127, %130 : i64, !llvm.ptr
cf.br ^bb12
^bb12:
%131 = llvm.load %130 : !llvm.ptr -> i64
%132 = arith.constant 4 : i32
%134 = arith.extsi %132 : i32 to i64
%133 = arith.cmpi slt, %131, %134 : i64
cf.cond_br %133, ^bb13, ^bb14
^bb13:
%136 = llvm.load %130 : !llvm.ptr -> i64
%137 = arith.constant 5 : i32
%139 = arith.extsi %137 : i32 to i64
%138 = arith.muli %136, %139 : i64
%140 = llvm.load %117 : !llvm.ptr -> i64
%141 = arith.addi %138, %140 : i64
%142 = llvm.getelementptr %arg0[%141] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%135 = llvm.load %142 : !llvm.ptr -> f64
%143 = math.absf %135 : f64
%145 = llvm.load %124 : !llvm.ptr -> i64
%146 = arith.constant 5 : i32
%148 = arith.extsi %146 : i32 to i64
%147 = arith.muli %145, %148 : i64
%149 = llvm.load %117 : !llvm.ptr -> i64
%150 = arith.addi %147, %149 : i64
%151 = llvm.getelementptr %arg0[%150] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%144 = llvm.load %151 : !llvm.ptr -> f64
%152 = math.absf %144 : f64
%153 = arith.cmpf ogt, %143, %152 : f64
cf.cond_br %153, ^bb15, ^bb16
^bb15:
%154 = llvm.load %130 : !llvm.ptr -> i64
llvm.store %154, %124 : i64, !llvm.ptr
cf.br ^bb17
^bb16:
cf.br ^bb17
^bb17:
%155 = llvm.load %130 : !llvm.ptr -> i64
%156 = arith.constant 1 : i32
%158 = arith.extsi %156 : i32 to i64
%157 = arith.addi %155, %158 : i64
llvm.store %157, %130 : i64, !llvm.ptr
cf.br ^bb12
^bb14:
%159 = llvm.load %124 : !llvm.ptr -> i64
%160 = llvm.load %117 : !llvm.ptr -> i64
%161 = arith.cmpi ne, %159, %160 : i64
cf.cond_br %161, ^bb18, ^bb19
^bb18:
%162 = arith.constant 0 : i32
%163 = arith.extsi %162 : i32 to i64
%164 = llvm.mlir.constant(1 : i64) : i64
%165 = llvm.alloca %164 x i64 : (i64) -> !llvm.ptr
llvm.store %163, %165 : i64, !llvm.ptr
cf.br ^bb21
^bb21:
%166 = llvm.load %165 : !llvm.ptr -> i64
%167 = arith.constant 5 : i32
%169 = arith.extsi %167 : i32 to i64
%168 = arith.cmpi slt, %166, %169 : i64
cf.cond_br %168, ^bb22, ^bb23
^bb22:
%171 = llvm.load %117 : !llvm.ptr -> i64
%172 = arith.constant 5 : i32
%174 = arith.extsi %172 : i32 to i64
%173 = arith.muli %171, %174 : i64
%175 = llvm.load %165 : !llvm.ptr -> i64
%176 = arith.addi %173, %175 : i64
%177 = llvm.getelementptr %arg0[%176] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%170 = llvm.load %177 : !llvm.ptr -> f64
%179 = llvm.load %124 : !llvm.ptr -> i64
%180 = arith.constant 5 : i32
%182 = arith.extsi %180 : i32 to i64
%181 = arith.muli %179, %182 : i64
%183 = llvm.load %165 : !llvm.ptr -> i64
%184 = arith.addi %181, %183 : i64
%185 = llvm.getelementptr %arg0[%184] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%178 = llvm.load %185 : !llvm.ptr -> f64
%186 = llvm.load %117 : !llvm.ptr -> i64
%187 = arith.constant 5 : i32
%189 = arith.extsi %187 : i32 to i64
%188 = arith.muli %186, %189 : i64
%190 = llvm.load %165 : !llvm.ptr -> i64
%191 = arith.addi %188, %190 : i64
%192 = llvm.getelementptr %arg0[%191] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %178, %192 : f64, !llvm.ptr
%193 = llvm.load %124 : !llvm.ptr -> i64
%194 = arith.constant 5 : i32
%196 = arith.extsi %194 : i32 to i64
%195 = arith.muli %193, %196 : i64
%197 = llvm.load %165 : !llvm.ptr -> i64
%198 = arith.addi %195, %197 : i64
%199 = llvm.getelementptr %arg0[%198] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %170, %199 : f64, !llvm.ptr
%200 = llvm.load %165 : !llvm.ptr -> i64
%201 = arith.constant 1 : i32
%203 = arith.extsi %201 : i32 to i64
%202 = arith.addi %200, %203 : i64
llvm.store %202, %165 : i64, !llvm.ptr
cf.br ^bb21
^bb23:
cf.br ^bb20
^bb19:
cf.br ^bb20
^bb20:
%205 = llvm.load %117 : !llvm.ptr -> i64
%206 = arith.constant 5 : i32
%208 = arith.extsi %206 : i32 to i64
%207 = arith.muli %205, %208 : i64
%209 = llvm.load %117 : !llvm.ptr -> i64
%210 = arith.addi %207, %209 : i64
%211 = llvm.getelementptr %arg0[%210] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%204 = llvm.load %211 : !llvm.ptr -> f64
%212 = llvm.load %117 : !llvm.ptr -> i64
%213 = llvm.mlir.constant(1 : i64) : i64
%214 = llvm.alloca %213 x i64 : (i64) -> !llvm.ptr
llvm.store %212, %214 : i64, !llvm.ptr
cf.br ^bb24
^bb24:
%215 = llvm.load %214 : !llvm.ptr -> i64
%216 = arith.constant 5 : i32
%218 = arith.extsi %216 : i32 to i64
%217 = arith.cmpi slt, %215, %218 : i64
cf.cond_br %217, ^bb25, ^bb26
^bb25:
%220 = llvm.load %117 : !llvm.ptr -> i64
%221 = arith.constant 5 : i32
%223 = arith.extsi %221 : i32 to i64
%222 = arith.muli %220, %223 : i64
%224 = llvm.load %214 : !llvm.ptr -> i64
%225 = arith.addi %222, %224 : i64
%226 = llvm.getelementptr %arg0[%225] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%219 = llvm.load %226 : !llvm.ptr -> f64
%227 = arith.divf %219, %204 : f64
%228 = llvm.load %117 : !llvm.ptr -> i64
%229 = arith.constant 5 : i32
%231 = arith.extsi %229 : i32 to i64
%230 = arith.muli %228, %231 : i64
%232 = llvm.load %214 : !llvm.ptr -> i64
%233 = arith.addi %230, %232 : i64
%234 = llvm.getelementptr %arg0[%233] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %227, %234 : f64, !llvm.ptr
%235 = llvm.load %214 : !llvm.ptr -> i64
%236 = arith.constant 1 : i32
%238 = arith.extsi %236 : i32 to i64
%237 = arith.addi %235, %238 : i64
llvm.store %237, %214 : i64, !llvm.ptr
cf.br ^bb24
^bb26:
%239 = arith.constant 0 : i32
%240 = arith.extsi %239 : i32 to i64
%241 = llvm.mlir.constant(1 : i64) : i64
%242 = llvm.alloca %241 x i64 : (i64) -> !llvm.ptr
llvm.store %240, %242 : i64, !llvm.ptr
cf.br ^bb27
^bb27:
%243 = llvm.load %242 : !llvm.ptr -> i64
%244 = arith.constant 4 : i32
%246 = arith.extsi %244 : i32 to i64
%245 = arith.cmpi slt, %243, %246 : i64
cf.cond_br %245, ^bb28, ^bb29
^bb28:
%247 = llvm.load %242 : !llvm.ptr -> i64
%248 = llvm.load %117 : !llvm.ptr -> i64
%249 = arith.cmpi eq, %247, %248 : i64
cf.cond_br %249, ^bb30, ^bb31
^bb30:
%250 = llvm.load %242 : !llvm.ptr -> i64
%251 = arith.constant 1 : i32
%253 = arith.extsi %251 : i32 to i64
%252 = arith.addi %250, %253 : i64
llvm.store %252, %242 : i64, !llvm.ptr
cf.br ^bb27
^bb31:
cf.br ^bb32
^bb32:
%255 = llvm.load %242 : !llvm.ptr -> i64
%256 = arith.constant 5 : i32
%258 = arith.extsi %256 : i32 to i64
%257 = arith.muli %255, %258 : i64
%259 = llvm.load %117 : !llvm.ptr -> i64
%260 = arith.addi %257, %259 : i64
%261 = llvm.getelementptr %arg0[%260] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%254 = llvm.load %261 : !llvm.ptr -> f64
%262 = arith.constant 0.0 : f32
%264 = arith.extf %262 : f32 to f64
%263 = arith.cmpf oeq, %254, %264 : f64
cf.cond_br %263, ^bb33, ^bb34
^bb33:
%265 = llvm.load %242 : !llvm.ptr -> i64
%266 = arith.constant 1 : i32
%268 = arith.extsi %266 : i32 to i64
%267 = arith.addi %265, %268 : i64
llvm.store %267, %242 : i64, !llvm.ptr
cf.br ^bb27
^bb34:
cf.br ^bb35
^bb35:
%269 = llvm.load %117 : !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
cf.br ^bb36
^bb36:
%272 = llvm.load %271 : !llvm.ptr -> i64
%273 = arith.constant 5 : i32
%275 = arith.extsi %273 : i32 to i64
%274 = arith.cmpi slt, %272, %275 : i64
cf.cond_br %274, ^bb37, ^bb38
^bb37:
%277 = llvm.load %242 : !llvm.ptr -> i64
%278 = arith.constant 5 : i32
%280 = arith.extsi %278 : i32 to i64
%279 = arith.muli %277, %280 : i64
%281 = llvm.load %271 : !llvm.ptr -> i64
%282 = arith.addi %279, %281 : i64
%283 = llvm.getelementptr %arg0[%282] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%276 = llvm.load %283 : !llvm.ptr -> f64
%285 = llvm.load %117 : !llvm.ptr -> i64
%286 = arith.constant 5 : i32
%288 = arith.extsi %286 : i32 to i64
%287 = arith.muli %285, %288 : i64
%289 = llvm.load %271 : !llvm.ptr -> i64
%290 = arith.addi %287, %289 : i64
%291 = llvm.getelementptr %arg0[%290] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%284 = llvm.load %291 : !llvm.ptr -> f64
%292 = arith.mulf %254, %284 : f64
%293 = arith.subf %276, %292 : f64
%294 = llvm.load %242 : !llvm.ptr -> i64
%295 = arith.constant 5 : i32
%297 = arith.extsi %295 : i32 to i64
%296 = arith.muli %294, %297 : i64
%298 = llvm.load %271 : !llvm.ptr -> i64
%299 = arith.addi %296, %298 : i64
%300 = llvm.getelementptr %arg0[%299] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %293, %300 : f64, !llvm.ptr
%301 = llvm.load %271 : !llvm.ptr -> i64
%302 = arith.constant 1 : i32
%304 = arith.extsi %302 : i32 to i64
%303 = arith.addi %301, %304 : i64
llvm.store %303, %271 : i64, !llvm.ptr
cf.br ^bb36
^bb38:
%305 = llvm.load %242 : !llvm.ptr -> i64
%306 = arith.constant 1 : i32
%308 = arith.extsi %306 : i32 to i64
%307 = arith.addi %305, %308 : i64
llvm.store %307, %242 : i64, !llvm.ptr
cf.br ^bb27
^bb29:
%309 = llvm.load %117 : !llvm.ptr -> i64
%310 = arith.constant 1 : i32
%312 = arith.extsi %310 : i32 to i64
%311 = arith.addi %309, %312 : i64
llvm.store %311, %117 : i64, !llvm.ptr
cf.br ^bb9
^bb11:
%313 = arith.constant 0 : i32
%314 = arith.extsi %313 : i32 to i64
%315 = llvm.mlir.constant(1 : i64) : i64
%316 = llvm.alloca %315 x i64 : (i64) -> !llvm.ptr
llvm.store %314, %316 : i64, !llvm.ptr
cf.br ^bb39
^bb39:
%317 = llvm.load %316 : !llvm.ptr -> i64
%318 = arith.constant 4 : i32
%320 = arith.extsi %318 : i32 to i64
%319 = arith.cmpi slt, %317, %320 : i64
cf.cond_br %319, ^bb40, ^bb41
^bb40:
%322 = llvm.load %316 : !llvm.ptr -> i64
%323 = arith.constant 5 : i32
%325 = arith.extsi %323 : i32 to i64
%324 = arith.muli %322, %325 : i64
%326 = arith.constant 4 : i32
%328 = arith.extsi %326 : i32 to i64
%327 = arith.addi %324, %328 : i64
%329 = llvm.getelementptr %arg0[%327] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%321 = llvm.load %329 : !llvm.ptr -> f64
%330 = llvm.load %316 : !llvm.ptr -> i64
%331 = llvm.getelementptr %arg1[%330] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %321, %331 : f64, !llvm.ptr
%332 = llvm.load %316 : !llvm.ptr -> i64
%333 = arith.constant 1 : i32
%335 = arith.extsi %333 : i32 to i64
%334 = arith.addi %332, %335 : i64
llvm.store %334, %316 : i64, !llvm.ptr
cf.br ^bb39
^bb41:
func.return
}
func.func @S_fast_float(%arg0: i64) -> f64 {
%336 = arith.constant 2 : i32
%338 = arith.extsi %336 : i32 to i64
%337 = arith.cmpi slt, %arg0, %338 : i64
cf.cond_br %337, ^bb42, ^bb43
^bb42:
%339 = arith.constant 0.0 : f32
%340 = arith.extf %339 : f32 to f64
func.return %340 : f64
^bb43:
cf.br ^bb44
^bb44:
%341 = arith.constant 2 : i32
%343 = arith.extsi %341 : i32 to i64
%342 = arith.cmpi eq, %arg0, %343 : i64
cf.cond_br %342, ^bb45, ^bb46
^bb45:
%344 = arith.constant 7.0 : f32
%345 = arith.constant 11.0 : f32
%346 = arith.divf %344, %345 : f32
%347 = arith.extf %346 : f32 to f64
func.return %347 : f64
^bb46:
cf.br ^bb47
^bb47:
%348 = arith.constant 2 : i32
%350 = arith.extsi %348 : i32 to i64
%349 = arith.muli %350, %arg0 : i64
%351 = arith.constant 2.0 : f32
%352 = arith.negf %351 : f32
%353 = arith.constant 3.0 : f32
%354 = math.sqrt %353 : f32
%356 = arith.extf %352 : f32 to f64
%355 = arith.addf %356, %354 : f64
%358 = arith.constant 24 : i32
%359 = arith.constant 8 : i32
%360 = arith.muli %358, %359 : i32
%361 = arith.extsi %360 : i32 to i64
%357 = func.call @malloc(%361) : (i64) -> !llvm.ptr
%363 = arith.constant 6 : i32
%364 = arith.constant 8 : i32
%365 = arith.muli %363, %364 : i32
%366 = arith.extsi %365 : i32 to i64
%362 = func.call @malloc(%366) : (i64) -> !llvm.ptr
%367 = arith.constant 2 : i32
%368 = arith.constant 0 : i32
%369 = arith.extsi %367 : i32 to i64
%370 = arith.extsi %368 : i32 to i64
%371 = llvm.getelementptr %362[%370] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %369, %371 : i64, !llvm.ptr
%372 = arith.constant 3 : i32
%373 = arith.constant 1 : i32
%374 = arith.extsi %372 : i32 to i64
%375 = arith.extsi %373 : i32 to i64
%376 = llvm.getelementptr %362[%375] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %374, %376 : i64, !llvm.ptr
%377 = arith.constant 4 : i32
%378 = arith.constant 2 : i32
%379 = arith.extsi %377 : i32 to i64
%380 = arith.extsi %378 : i32 to i64
%381 = llvm.getelementptr %362[%380] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %379, %381 : i64, !llvm.ptr
%382 = arith.constant 5 : i32
%383 = arith.constant 3 : i32
%384 = arith.extsi %382 : i32 to i64
%385 = arith.extsi %383 : i32 to i64
%386 = llvm.getelementptr %362[%385] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %384, %386 : i64, !llvm.ptr
%387 = arith.constant 2 : i32
%389 = arith.extsi %387 : i32 to i64
%388 = arith.subi %349, %389 : i64
%390 = arith.constant 4 : i32
%391 = arith.extsi %390 : i32 to i64
%392 = llvm.getelementptr %362[%391] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %388, %392 : i64, !llvm.ptr
%393 = arith.constant 1 : i32
%395 = arith.extsi %393 : i32 to i64
%394 = arith.subi %349, %395 : i64
%396 = arith.constant 5 : i32
%397 = arith.extsi %396 : i32 to i64
%398 = llvm.getelementptr %362[%397] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %394, %398 : i64, !llvm.ptr
%399 = arith.constant 0 : i32
%400 = arith.extsi %399 : i32 to i64
%401 = llvm.mlir.constant(1 : i64) : i64
%402 = llvm.alloca %401 x i64 : (i64) -> !llvm.ptr
llvm.store %400, %402 : i64, !llvm.ptr
cf.br ^bb48
^bb48:
%403 = llvm.load %402 : !llvm.ptr -> i64
%404 = arith.constant 6 : i32
%406 = arith.extsi %404 : i32 to i64
%405 = arith.cmpi slt, %403, %406 : i64
cf.cond_br %405, ^bb49, ^bb50
^bb49:
%408 = llvm.load %402 : !llvm.ptr -> i64
%409 = llvm.getelementptr %362[%408] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%407 = llvm.load %409 : !llvm.ptr -> i64
%410 = arith.constant 1.0 : f32
%411 = llvm.load %402 : !llvm.ptr -> i64
%412 = arith.constant 4 : i32
%414 = arith.extsi %412 : i32 to i64
%413 = arith.muli %411, %414 : i64
%415 = arith.constant 0 : i32
%417 = arith.extsi %415 : i32 to i64
%416 = arith.addi %413, %417 : i64
%418 = arith.extf %410 : f32 to f64
%419 = llvm.getelementptr %357[%416] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %418, %419 : f64, !llvm.ptr
%420 = arith.sitofp %407 : i64 to f64
%421 = llvm.load %402 : !llvm.ptr -> i64
%422 = arith.constant 4 : i32
%424 = arith.extsi %422 : i32 to i64
%423 = arith.muli %421, %424 : i64
%425 = arith.constant 1 : i32
%427 = arith.extsi %425 : i32 to i64
%426 = arith.addi %423, %427 : i64
%428 = llvm.getelementptr %357[%426] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %420, %428 : f64, !llvm.ptr
%429 = func.call @dpow(%355, %407) : (f64, i64) -> f64
%430 = llvm.load %402 : !llvm.ptr -> i64
%431 = arith.constant 4 : i32
%433 = arith.extsi %431 : i32 to i64
%432 = arith.muli %430, %433 : i64
%434 = arith.constant 2 : i32
%436 = arith.extsi %434 : i32 to i64
%435 = arith.addi %432, %436 : i64
%437 = llvm.getelementptr %357[%435] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %429, %437 : f64, !llvm.ptr
%439 = arith.subi %349, %407 : i64
%438 = func.call @dpow(%355, %439) : (f64, i64) -> f64
%440 = llvm.load %402 : !llvm.ptr -> i64
%441 = arith.constant 4 : i32
%443 = arith.extsi %441 : i32 to i64
%442 = arith.muli %440, %443 : i64
%444 = arith.constant 3 : i32
%446 = arith.extsi %444 : i32 to i64
%445 = arith.addi %442, %446 : i64
%447 = llvm.getelementptr %357[%445] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %438, %447 : f64, !llvm.ptr
%448 = llvm.load %402 : !llvm.ptr -> i64
%449 = arith.constant 1 : i32
%451 = arith.extsi %449 : i32 to i64
%450 = arith.addi %448, %451 : i64
llvm.store %450, %402 : i64, !llvm.ptr
cf.br ^bb48
^bb50:
%453 = arith.constant 20 : i32
%454 = arith.constant 8 : i32
%455 = arith.muli %453, %454 : i32
%456 = arith.extsi %455 : i32 to i64
%452 = func.call @malloc(%456) : (i64) -> !llvm.ptr
%457 = arith.constant 0 : i32
%458 = arith.extsi %457 : i32 to i64
%459 = llvm.mlir.constant(1 : i64) : i64
%460 = llvm.alloca %459 x i64 : (i64) -> !llvm.ptr
llvm.store %458, %460 : i64, !llvm.ptr
cf.br ^bb51
^bb51:
%461 = llvm.load %460 : !llvm.ptr -> i64
%462 = arith.constant 4 : i32
%464 = arith.extsi %462 : i32 to i64
%463 = arith.cmpi slt, %461, %464 : i64
cf.cond_br %463, ^bb52, ^bb53
^bb52:
%466 = arith.constant 0 : i32
%467 = arith.constant 4 : i32
%468 = arith.muli %466, %467 : i32
%469 = llvm.load %460 : !llvm.ptr -> i64
%471 = arith.extsi %468 : i32 to i64
%470 = arith.addi %471, %469 : i64
%472 = llvm.getelementptr %357[%470] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%465 = llvm.load %472 : !llvm.ptr -> f64
%473 = arith.constant 1.0 : f32
%474 = arith.constant 3.0 : f32
%475 = arith.divf %473, %474 : f32
%477 = arith.constant 5 : i32
%478 = arith.constant 4 : i32
%479 = arith.muli %477, %478 : i32
%480 = llvm.load %460 : !llvm.ptr -> i64
%482 = arith.extsi %479 : i32 to i64
%481 = arith.addi %482, %480 : i64
%483 = llvm.getelementptr %357[%481] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%476 = llvm.load %483 : !llvm.ptr -> f64
%485 = arith.extf %475 : f32 to f64
%484 = arith.mulf %485, %476 : f64
%486 = arith.addf %465, %484 : f64
%487 = arith.constant 0 : i32
%488 = arith.constant 5 : i32
%489 = arith.muli %487, %488 : i32
%490 = llvm.load %460 : !llvm.ptr -> i64
%492 = arith.extsi %489 : i32 to i64
%491 = arith.addi %492, %490 : i64
%493 = llvm.getelementptr %452[%491] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %486, %493 : f64, !llvm.ptr
%494 = llvm.load %460 : !llvm.ptr -> i64
%495 = arith.constant 1 : i32
%497 = arith.extsi %495 : i32 to i64
%496 = arith.addi %494, %497 : i64
llvm.store %496, %460 : i64, !llvm.ptr
cf.br ^bb51
^bb53:
%498 = arith.constant 1.0 : f32
%499 = arith.constant 0 : i32
%500 = arith.constant 5 : i32
%501 = arith.muli %499, %500 : i32
%502 = arith.constant 4 : i32
%503 = arith.addi %501, %502 : i32
%504 = arith.extf %498 : f32 to f64
%505 = arith.extsi %503 : i32 to i64
%506 = llvm.getelementptr %452[%505] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %504, %506 : f64, !llvm.ptr
%507 = arith.constant 0 : i32
%508 = arith.extsi %507 : i32 to i64
llvm.store %508, %460 : i64, !llvm.ptr
cf.br ^bb54
^bb54:
%509 = llvm.load %460 : !llvm.ptr -> i64
%510 = arith.constant 4 : i32
%512 = arith.extsi %510 : i32 to i64
%511 = arith.cmpi slt, %509, %512 : i64
cf.cond_br %511, ^bb55, ^bb56
^bb55:
%514 = arith.constant 1 : i32
%515 = arith.constant 4 : i32
%516 = arith.muli %514, %515 : i32
%517 = llvm.load %460 : !llvm.ptr -> i64
%519 = arith.extsi %516 : i32 to i64
%518 = arith.addi %519, %517 : i64
%520 = llvm.getelementptr %357[%518] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%513 = llvm.load %520 : !llvm.ptr -> f64
%521 = arith.constant 1.0 : f32
%522 = arith.constant 3.0 : f32
%523 = arith.divf %521, %522 : f32
%525 = arith.constant 4 : i32
%526 = arith.constant 4 : i32
%527 = arith.muli %525, %526 : i32
%528 = llvm.load %460 : !llvm.ptr -> i64
%530 = arith.extsi %527 : i32 to i64
%529 = arith.addi %530, %528 : i64
%531 = llvm.getelementptr %357[%529] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%524 = llvm.load %531 : !llvm.ptr -> f64
%533 = arith.extf %523 : f32 to f64
%532 = arith.mulf %533, %524 : f64
%534 = arith.addf %513, %532 : f64
%535 = arith.constant 1.0 : f32
%536 = arith.constant 3.0 : f32
%537 = arith.divf %535, %536 : f32
%539 = arith.constant 5 : i32
%540 = arith.constant 4 : i32
%541 = arith.muli %539, %540 : i32
%542 = llvm.load %460 : !llvm.ptr -> i64
%544 = arith.extsi %541 : i32 to i64
%543 = arith.addi %544, %542 : i64
%545 = llvm.getelementptr %357[%543] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%538 = llvm.load %545 : !llvm.ptr -> f64
%547 = arith.extf %537 : f32 to f64
%546 = arith.mulf %547, %538 : f64
%548 = arith.addf %534, %546 : f64
%549 = arith.constant 1 : i32
%550 = arith.constant 5 : i32
%551 = arith.muli %549, %550 : i32
%552 = llvm.load %460 : !llvm.ptr -> i64
%554 = arith.extsi %551 : i32 to i64
%553 = arith.addi %554, %552 : i64
%555 = llvm.getelementptr %452[%553] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %548, %555 : f64, !llvm.ptr
%556 = llvm.load %460 : !llvm.ptr -> i64
%557 = arith.constant 1 : i32
%559 = arith.extsi %557 : i32 to i64
%558 = arith.addi %556, %559 : i64
llvm.store %558, %460 : i64, !llvm.ptr
cf.br ^bb54
^bb56:
%560 = arith.constant 1.0 : f32
%561 = arith.constant 1 : i32
%562 = arith.constant 5 : i32
%563 = arith.muli %561, %562 : i32
%564 = arith.constant 4 : i32
%565 = arith.addi %563, %564 : i32
%566 = arith.extf %560 : f32 to f64
%567 = arith.extsi %565 : i32 to i64
%568 = llvm.getelementptr %452[%567] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %566, %568 : f64, !llvm.ptr
%569 = arith.constant 0 : i32
%570 = arith.extsi %569 : i32 to i64
llvm.store %570, %460 : i64, !llvm.ptr
cf.br ^bb57
^bb57:
%571 = llvm.load %460 : !llvm.ptr -> i64
%572 = arith.constant 4 : i32
%574 = arith.extsi %572 : i32 to i64
%573 = arith.cmpi slt, %571, %574 : i64
cf.cond_br %573, ^bb58, ^bb59
^bb58:
%576 = arith.constant 5 : i32
%577 = arith.constant 4 : i32
%578 = arith.muli %576, %577 : i32
%579 = llvm.load %460 : !llvm.ptr -> i64
%581 = arith.extsi %578 : i32 to i64
%580 = arith.addi %581, %579 : i64
%582 = llvm.getelementptr %357[%580] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%575 = llvm.load %582 : !llvm.ptr -> f64
%583 = arith.constant 1.0 : f32
%584 = arith.constant 3.0 : f32
%585 = arith.divf %583, %584 : f32
%587 = arith.constant 0 : i32
%588 = arith.constant 4 : i32
%589 = arith.muli %587, %588 : i32
%590 = llvm.load %460 : !llvm.ptr -> i64
%592 = arith.extsi %589 : i32 to i64
%591 = arith.addi %592, %590 : i64
%593 = llvm.getelementptr %357[%591] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%586 = llvm.load %593 : !llvm.ptr -> f64
%595 = arith.extf %585 : f32 to f64
%594 = arith.mulf %595, %586 : f64
%596 = arith.addf %575, %594 : f64
%597 = arith.constant 1.0 : f32
%598 = arith.constant 3.0 : f32
%599 = arith.divf %597, %598 : f32
%601 = arith.constant 1 : i32
%602 = arith.constant 4 : i32
%603 = arith.muli %601, %602 : i32
%604 = llvm.load %460 : !llvm.ptr -> i64
%606 = arith.extsi %603 : i32 to i64
%605 = arith.addi %606, %604 : i64
%607 = llvm.getelementptr %357[%605] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%600 = llvm.load %607 : !llvm.ptr -> f64
%609 = arith.extf %599 : f32 to f64
%608 = arith.mulf %609, %600 : f64
%610 = arith.addf %596, %608 : f64
%611 = arith.constant 1.0 : f32
%612 = arith.constant 3.0 : f32
%613 = arith.divf %611, %612 : f32
%615 = arith.constant 2 : i32
%616 = arith.constant 4 : i32
%617 = arith.muli %615, %616 : i32
%618 = llvm.load %460 : !llvm.ptr -> i64
%620 = arith.extsi %617 : i32 to i64
%619 = arith.addi %620, %618 : i64
%621 = llvm.getelementptr %357[%619] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%614 = llvm.load %621 : !llvm.ptr -> f64
%623 = arith.extf %613 : f32 to f64
%622 = arith.mulf %623, %614 : f64
%624 = arith.addf %610, %622 : f64
%625 = arith.constant 2 : i32
%626 = arith.constant 5 : i32
%627 = arith.muli %625, %626 : i32
%628 = llvm.load %460 : !llvm.ptr -> i64
%630 = arith.extsi %627 : i32 to i64
%629 = arith.addi %630, %628 : i64
%631 = llvm.getelementptr %452[%629] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %624, %631 : f64, !llvm.ptr
%632 = llvm.load %460 : !llvm.ptr -> i64
%633 = arith.constant 1 : i32
%635 = arith.extsi %633 : i32 to i64
%634 = arith.addi %632, %635 : i64
llvm.store %634, %460 : i64, !llvm.ptr
cf.br ^bb57
^bb59:
%636 = arith.constant 1.0 : f32
%637 = arith.constant 2 : i32
%638 = arith.constant 5 : i32
%639 = arith.muli %637, %638 : i32
%640 = arith.constant 4 : i32
%641 = arith.addi %639, %640 : i32
%642 = arith.extf %636 : f32 to f64
%643 = arith.extsi %641 : i32 to i64
%644 = llvm.getelementptr %452[%643] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %642, %644 : f64, !llvm.ptr
%645 = arith.constant 0 : i32
%646 = arith.extsi %645 : i32 to i64
llvm.store %646, %460 : i64, !llvm.ptr
cf.br ^bb60
^bb60:
%647 = llvm.load %460 : !llvm.ptr -> i64
%648 = arith.constant 4 : i32
%650 = arith.extsi %648 : i32 to i64
%649 = arith.cmpi slt, %647, %650 : i64
cf.cond_br %649, ^bb61, ^bb62
^bb61:
%652 = arith.constant 4 : i32
%653 = arith.constant 4 : i32
%654 = arith.muli %652, %653 : i32
%655 = llvm.load %460 : !llvm.ptr -> i64
%657 = arith.extsi %654 : i32 to i64
%656 = arith.addi %657, %655 : i64
%658 = llvm.getelementptr %357[%656] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%651 = llvm.load %658 : !llvm.ptr -> f64
%659 = arith.constant 1.0 : f32
%660 = arith.constant 3.0 : f32
%661 = arith.divf %659, %660 : f32
%663 = arith.constant 1 : i32
%664 = arith.constant 4 : i32
%665 = arith.muli %663, %664 : i32
%666 = llvm.load %460 : !llvm.ptr -> i64
%668 = arith.extsi %665 : i32 to i64
%667 = arith.addi %668, %666 : i64
%669 = llvm.getelementptr %357[%667] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%662 = llvm.load %669 : !llvm.ptr -> f64
%671 = arith.extf %661 : f32 to f64
%670 = arith.mulf %671, %662 : f64
%672 = arith.addf %651, %670 : f64
%673 = arith.constant 1.0 : f32
%674 = arith.constant 3.0 : f32
%675 = arith.divf %673, %674 : f32
%677 = arith.constant 2 : i32
%678 = arith.constant 4 : i32
%679 = arith.muli %677, %678 : i32
%680 = llvm.load %460 : !llvm.ptr -> i64
%682 = arith.extsi %679 : i32 to i64
%681 = arith.addi %682, %680 : i64
%683 = llvm.getelementptr %357[%681] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%676 = llvm.load %683 : !llvm.ptr -> f64
%685 = arith.extf %675 : f32 to f64
%684 = arith.mulf %685, %676 : f64
%686 = arith.addf %672, %684 : f64
%687 = arith.constant 1.0 : f32
%688 = arith.constant 3.0 : f32
%689 = arith.divf %687, %688 : f32
%691 = arith.constant 3 : i32
%692 = arith.constant 4 : i32
%693 = arith.muli %691, %692 : i32
%694 = llvm.load %460 : !llvm.ptr -> i64
%696 = arith.extsi %693 : i32 to i64
%695 = arith.addi %696, %694 : i64
%697 = llvm.getelementptr %357[%695] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%690 = llvm.load %697 : !llvm.ptr -> f64
%699 = arith.extf %689 : f32 to f64
%698 = arith.mulf %699, %690 : f64
%700 = arith.addf %686, %698 : f64
%701 = arith.constant 3 : i32
%702 = arith.constant 5 : i32
%703 = arith.muli %701, %702 : i32
%704 = llvm.load %460 : !llvm.ptr -> i64
%706 = arith.extsi %703 : i32 to i64
%705 = arith.addi %706, %704 : i64
%707 = llvm.getelementptr %452[%705] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %700, %707 : f64, !llvm.ptr
%708 = llvm.load %460 : !llvm.ptr -> i64
%709 = arith.constant 1 : i32
%711 = arith.extsi %709 : i32 to i64
%710 = arith.addi %708, %711 : i64
llvm.store %710, %460 : i64, !llvm.ptr
cf.br ^bb60
^bb62:
%712 = arith.constant 1.0 : f32
%713 = arith.constant 3 : i32
%714 = arith.constant 5 : i32
%715 = arith.muli %713, %714 : i32
%716 = arith.constant 4 : i32
%717 = arith.addi %715, %716 : i32
%718 = arith.extf %712 : f32 to f64
%719 = arith.extsi %717 : i32 to i64
%720 = llvm.getelementptr %452[%719] : (!llvm.ptr, i64) -> !llvm.ptr, f64
llvm.store %718, %720 : f64, !llvm.ptr
%722 = arith.constant 4 : i32
%723 = arith.constant 8 : i32
%724 = arith.muli %722, %723 : i32
%725 = arith.extsi %724 : i32 to i64
%721 = func.call @malloc(%725) : (i64) -> !llvm.ptr
func.call @gauss_solve_4x4(%452, %721) : (!llvm.ptr, !llvm.ptr) -> ()
%728 = arith.constant 0 : i32
%729 = arith.extsi %728 : i32 to i64
%730 = llvm.getelementptr %721[%729] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%727 = llvm.load %730 : !llvm.ptr -> f64
%732 = arith.constant 1 : i32
%733 = arith.extsi %732 : i32 to i64
%734 = llvm.getelementptr %721[%733] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%731 = llvm.load %734 : !llvm.ptr -> f64
%736 = arith.constant 2 : i32
%737 = arith.extsi %736 : i32 to i64
%738 = llvm.getelementptr %721[%737] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%735 = llvm.load %738 : !llvm.ptr -> f64
%740 = arith.constant 3 : i32
%741 = arith.extsi %740 : i32 to i64
%742 = llvm.getelementptr %721[%741] : (!llvm.ptr, i64) -> !llvm.ptr, f64
%739 = llvm.load %742 : !llvm.ptr -> f64
%743 = arith.sitofp %arg0 : i64 to f64
%744 = arith.mulf %731, %743 : f64
%745 = arith.addf %727, %744 : f64
%746 = func.call @dpow(%355, %arg0) : (f64, i64) -> f64
%747 = arith.mulf %735, %746 : f64
%748 = arith.addf %745, %747 : f64
%750 = arith.subi %349, %arg0 : i64
%749 = func.call @dpow(%355, %750) : (f64, i64) -> f64
%751 = arith.mulf %739, %749 : f64
%752 = arith.addf %748, %751 : f64
func.call @free(%357) : (!llvm.ptr) -> ()
func.call @free(%362) : (!llvm.ptr) -> ()
func.call @free(%452) : (!llvm.ptr) -> ()
func.call @free(%721) : (!llvm.ptr) -> ()
%757 = arith.constant 2.0 : f32
%759 = arith.extf %757 : f32 to f64
%758 = arith.mulf %759, %752 : f64
%760 = arith.constant 1.0 : f32
%762 = arith.extf %760 : f32 to f64
%761 = arith.subf %758, %762 : f64
func.return %761 : f64
}
func.func @correction_constant() -> f64 {
%763 = arith.constant 3.0 : f32
%764 = arith.constant 3.0 : f32
%765 = math.sqrt %764 : f32
%767 = arith.extf %763 : f32 to f64
%766 = arith.subf %767, %765 : f64
%768 = arith.constant 6.0 : f32
%770 = arith.extf %768 : f32 to f64
%769 = arith.divf %766, %770 : f64
%771 = arith.constant 0.0 : f32
%772 = arith.extf %771 : f32 to f64
%773 = llvm.mlir.constant(1 : i64) : i64
%774 = llvm.alloca %773 x f64 : (i64) -> !llvm.ptr
llvm.store %772, %774 : f64, !llvm.ptr
%775 = arith.constant 2 : i32
%776 = arith.extsi %775 : i32 to i64
%777 = llvm.mlir.constant(1 : i64) : i64
%778 = llvm.alloca %777 x i64 : (i64) -> !llvm.ptr
llvm.store %776, %778 : i64, !llvm.ptr
cf.br ^bb63
^bb63:
%779 = llvm.load %778 : !llvm.ptr -> i64
%780 = arith.constant 60 : i32
%782 = arith.extsi %780 : i32 to i64
%781 = arith.cmpi sle, %779, %782 : i64
cf.cond_br %781, ^bb64, ^bb65
^bb64:
%783 = llvm.load %774 : !llvm.ptr -> f64
%785 = llvm.load %778 : !llvm.ptr -> i64
%784 = func.call @S_fast_float(%785) : (i64) -> f64
%786 = arith.addf %783, %784 : f64
%787 = arith.constant 1.0 : f32
%788 = llvm.load %778 : !llvm.ptr -> i64
%789 = arith.constant 1 : i32
%791 = arith.extsi %789 : i32 to i64
%790 = arith.subi %788, %791 : i64
%792 = arith.sitofp %790 : i64 to f64
%793 = arith.addf %792, %769 : f64
%795 = arith.extf %787 : f32 to f64
%794 = arith.divf %795, %793 : f64
%796 = arith.subf %786, %794 : f64
llvm.store %796, %774 : f64, !llvm.ptr
%797 = llvm.load %778 : !llvm.ptr -> i64
%798 = arith.constant 1 : i32
%800 = arith.extsi %798 : i32 to i64
%799 = arith.addi %797, %800 : i64
llvm.store %799, %778 : i64, !llvm.ptr
cf.br ^bb63
^bb65:
%801 = llvm.load %774 : !llvm.ptr -> f64
func.return %801 : f64
}
func.func @main() -> i32 {
%802 = arith.constant 3.0 : f32
%803 = arith.constant 3.0 : f32
%804 = math.sqrt %803 : f32
%806 = arith.extf %802 : f32 to f64
%805 = arith.subf %806, %804 : f64
%807 = arith.constant 6.0 : f32
%809 = arith.extf %807 : f32 to f64
%808 = arith.divf %805, %809 : f64
%810 = func.call @correction_constant() : () -> f64
%811 = arith.constant 100000000000000 : f32
%812 = arith.extf %811 : f32 to f64
%814 = arith.addf %812, %808 : f64
%813 = func.call @digamma(%814) : (f64) -> f64
%816 = arith.constant 1.0 : f32
%818 = arith.extf %816 : f32 to f64
%817 = arith.addf %818, %808 : f64
%815 = func.call @digamma(%817) : (f64) -> f64
%819 = arith.subf %813, %815 : f64
%820 = arith.addf %819, %810 : f64
%821 = llvm.mlir.addressof @str_0 : !llvm.ptr
%822 = llvm.call @printf(%821, %820) vararg(!llvm.func<i32 (ptr, ...)>) : (!llvm.ptr, f64) -> i32
%823 = arith.constant 0 : i32
func.return %823 : i32
}
}