Problem 904
F(N, L) = sum_{n=1..N} f(cuberoot(n), L) N = 45000, L = 10^10
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 904: Pythagorean Angle
# F(N, L) = sum_{n=1..N} f(cuberoot(n), L)
# N = 45000, L = 10^10
extern {
function calloc(n: i64, size: i64) -> ptr<void>
function free(p: ptr<void>) -> void
function sqrt(x: f64) -> f64
function fabs(x: f64) -> f64
function atan(x: f64) -> f64
function tan(x: f64) -> f64
function cbrt(x: f64) -> f64
}
const PI: f64 = 3.14159265358979323846
const DEG2RAD: f64 = 0.01745329251994329576
const T0_F: f64 = 0.41421356237309504880
function g_of_t(t: f64) -> f64 {
let tt: f64 = t * t
let denom: f64 = 1.0 + tt
return 3.0 * t * (1.0 - tt) / (denom * denom)
}
function root_left(y: f64) -> f64 {
let mut lo: f64 = 0.0
let mut hi: f64 = T0_F
for i in 0..35 {
let mid: f64 = (lo + hi) * 0.5
if g_of_t(mid) < y { lo = mid } else { hi = mid }
}
return (lo + hi) * 0.5
}
function root_right(y: f64) -> f64 {
let mut lo: f64 = T0_F
let mut hi: f64 = 1.0
for i in 0..35 {
let mid: f64 = (lo + hi) * 0.5
if g_of_t(mid) > y { lo = mid } else { hi = mid }
}
return (lo + hi) * 0.5
}
# cf_candidates_circle: continued fraction candidates
# Fills out_p[0..count-1] and out_q[0..count-1]
# Returns count
function cf_candidates_circle(x: f64, L: i64, out_p: ptr<i64>, out_q: ptr<i64>, max_out: i32) -> i32 {
let mut count: i32 = 0
let mut p0: i64 = 0
let mut q0: i64 = 1
let mut p1: i64 = 1
let mut q1: i64 = 0
let mut frac: f64 = x
let sqrtL: i64 = sqrt(L as f64) as i64 + 1
let mut iter: i32 = 0
while iter < 80 {
let a: i64 = frac as i64
# Check for potential overflow
if a > 2 * sqrtL || (p1 > 0 && a > sqrtL / p1 + 1) {
# Semiconvergent branch (overflow case)
let A: i64 = p1 * p1 + q1 * q1
let B: i64 = 2 * (p0 * p1 + q0 * q1)
let C: i64 = p0 * p0 + q0 * q0 - L
let mut kmax: i64 = 0
if A > 0 {
let disc: i128 = (B as i128) * (B as i128) - (4 as i128) * (A as i128) * (C as i128)
if disc > 0 {
let mut s_val: i64 = sqrt(disc as f64) as i64
while (s_val as i128) * (s_val as i128) > disc { s_val = s_val - 1 }
while ((s_val + 1) as i128) * ((s_val + 1) as i128) <= disc { s_val = s_val + 1 }
kmax = (-B + s_val) / (2 * A)
}
}
if kmax > a - 1 { kmax = a - 1 }
if kmax < 0 { kmax = 0 }
let mut lo: i64 = kmax - 3
if lo < 1 { lo = 1 }
let mut hi: i64 = kmax + 3
if hi > a - 1 { hi = a - 1 }
if hi < lo { hi = lo }
let mut k: i64 = lo
while k <= hi {
let ps: i64 = k * p1 + p0
let qs: i64 = k * q1 + q0
if ps > 0 && qs > 0 && (ps as i128) * (ps as i128) + (qs as i128) * (qs as i128) <= (L as i128) {
if count < max_out {
out_p[count] = ps
out_q[count] = qs
count = count + 1
}
}
k = k + 1
}
break
}
let p2: i64 = a * p1 + p0
let q2: i64 = a * q1 + q0
if (p2 as i128) * (p2 as i128) + (q2 as i128) * (q2 as i128) > (L as i128) {
# Find largest k <= a-1 with (p0+k*p1)^2 + (q0+k*q1)^2 <= L
let A2: i64 = p1 * p1 + q1 * q1
let B2: i64 = 2 * (p0 * p1 + q0 * q1)
let C2: i64 = p0 * p0 + q0 * q0 - L
let mut kmax2: i64 = 0
if A2 > 0 {
let disc2: i128 = (B2 as i128) * (B2 as i128) - (4 as i128) * (A2 as i128) * (C2 as i128)
if disc2 > 0 {
let mut s_val2: i64 = sqrt(disc2 as f64) as i64
while (s_val2 as i128) * (s_val2 as i128) > disc2 { s_val2 = s_val2 - 1 }
while ((s_val2 + 1) as i128) * ((s_val2 + 1) as i128) <= disc2 { s_val2 = s_val2 + 1 }
kmax2 = (-B2 + s_val2) / (2 * A2)
}
}
if kmax2 > a - 1 { kmax2 = a - 1 }
if kmax2 < 0 { kmax2 = 0 }
let mut lo2: i64 = kmax2 - 3
if lo2 < 1 { lo2 = 1 }
let mut hi2: i64 = kmax2 + 3
if hi2 > a - 1 { hi2 = a - 1 }
let mut k2: i64 = lo2
while k2 <= hi2 {
let ps2: i64 = k2 * p1 + p0
let qs2: i64 = k2 * q1 + q0
if ps2 > 0 && qs2 > 0 && (ps2 as i128) * (ps2 as i128) + (qs2 as i128) * (qs2 as i128) <= (L as i128) {
if count < max_out {
out_p[count] = ps2
out_q[count] = qs2
count = count + 1
}
}
k2 = k2 + 1
}
break
}
if p2 > 0 && q2 > 0 {
if count < max_out {
out_p[count] = p2
out_q[count] = q2
count = count + 1
}
}
if frac == (a as f64) { break }
frac = 1.0 / (frac - (a as f64))
p0 = p1
q0 = q1
p1 = p2
q1 = q2
iter = iter + 1
}
# Also include last convergent if admissible
if p1 > 0 && q1 > 0 && (p1 as i128) * (p1 as i128) + (q1 as i128) * (q1 as i128) <= (L as i128) {
let mut found: i32 = 0
let mut i: i32 = 0
while i < count {
if out_p[i] == p1 && out_q[i] == q1 {
found = 1
break
}
i = i + 1
}
if found == 0 && count < max_out {
out_p[count] = p1
out_q[count] = q1
count = count + 1
}
}
return count
}
# triangle_from_mn outputs
let mut g_tri_a: i64 = 0
let mut g_tri_b: i64 = 0
let mut g_tri_c: i64 = 0
function triangle_from_mn(m: i64, n: i64) -> void {
let aa: i64 = m * m - n * n
let bb: i64 = 2 * m * n
let cc: i64 = m * m + n * n
if ((m + n) % 2) == 0 {
g_tri_a = aa / 2
g_tri_b = bb / 2
g_tri_c = cc / 2
} else {
g_tri_a = aa
g_tri_b = bb
g_tri_c = cc
}
}
function tan_theta_from_legs(a: i64, b: i64) -> f64 {
let aa: f64 = (a as f64) * (a as f64)
let bb: f64 = (b as f64) * (b as f64)
return (3.0 * (a as f64) * (b as f64)) / (2.0 * (aa + bb))
}
function f_val(alpha_deg: f64, L: i64) -> i64 {
let alpha_rad: f64 = alpha_deg * DEG2RAD
let y: f64 = tan(alpha_rad)
let r1: f64 = root_left(y)
let r2: f64 = root_right(y)
let mut best_diff: f64 = 1e300
let mut best_area_key: f64 = -1.0
let mut best_perim: i64 = 0
let cands_p: ptr<i64> = calloc(200, 8)
let cands_q: ptr<i64> = calloc(200, 8)
for ri in 0..2 {
let root: f64 = if ri == 0 { r1 } else { r2 }
let ncands: i32 = cf_candidates_circle(root, L, cands_p, cands_q, 200)
for ci in 0..ncands {
let n_val: i64 = cands_p[ci]
let m_val: i64 = cands_q[ci]
if n_val > 0 && n_val < m_val {
triangle_from_mn(m_val, n_val)
let a: i64 = g_tri_a
let b: i64 = g_tri_b
let c: i64 = g_tri_c
if a > 0 && b > 0 {
if c <= L {
let k: i64 = L / c
if k > 0 {
let theta: f64 = atan(tan_theta_from_legs(a, b))
let diff: f64 = fabs(theta - alpha_rad)
let area_key: f64 = (k as f64) * (k as f64) * (a as f64) * (b as f64)
let perim: i64 = k * (a + b + c)
if diff + 1e-16 < best_diff {
best_diff = diff
best_area_key = area_key
best_perim = perim
} else {
if fabs(diff - best_diff) <= 1e-16 {
if area_key > best_area_key {
best_area_key = area_key
best_perim = perim
}
}
}
}
}
}
}
}
}
free(cands_p)
free(cands_q)
return best_perim
}
function main() -> i32 {
let N: i64 = 45000
let L: i64 = 10000000000
let mut total: i64 = 0
let mut n: i64 = 1
while n <= N {
let alpha: f64 = cbrt(n as f64)
total = total + f_val(alpha, L)
n = n + 1
}
printf("%lld\n", total)
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 atan(double x);
double cbrt(double x);
double g_of_t_f64(double t);
double root_left_f64(double y);
double root_right_f64(double y);
int32_t cf_candidates_circle_f64_i64_ptr_i64_ptr_i64_i32(double x, int64_t L, int64_t* out_p, int64_t* out_q, int32_t max_out);
void triangle_from_mn_i64_i64(int64_t m, int64_t n);
double tan_theta_from_legs_i64_i64(int64_t a, int64_t b);
int64_t f_val_f64_i64(double alpha_deg, int64_t L);
int32_t main(void);
static const double PI = 3.14159265358979323846;
static const double DEG2RAD = 0.01745329251994329576;
static const double T0_F = 0.41421356237309504880;
/* Module statics */
static int64_t g_tri_a = 0;
static int64_t g_tri_b = 0;
static int64_t g_tri_c = 0;
double g_of_t_f64(double t) {
double tt = (t * t);
double denom = (1.0 + tt);
return (((3.0 * t) * (1.0 - tt)) / (denom * denom));
}
double root_left_f64(double y) {
double lo = 0.0;
double hi = T0_F;
int32_t __flow_step_1 = 1;
for (int32_t i = 0; (0 <= 35) ? i < 35 : i > 35; i += (0 <= 35) ? 1 : -1) {
double mid = ((lo + hi) * 0.5);
if (g_of_t_f64(mid) < y) {
lo = mid;
} else {
hi = mid;
}
}
return ((lo + hi) * 0.5);
}
double root_right_f64(double y) {
double lo = T0_F;
double hi = 1.0;
int32_t __flow_step_2 = 1;
for (int32_t i = 0; (0 <= 35) ? i < 35 : i > 35; i += (0 <= 35) ? 1 : -1) {
double mid = ((lo + hi) * 0.5);
if (g_of_t_f64(mid) > y) {
lo = mid;
} else {
hi = mid;
}
}
return ((lo + hi) * 0.5);
}
int32_t cf_candidates_circle_f64_i64_ptr_i64_ptr_i64_i32(double x, int64_t L, int64_t* out_p, int64_t* out_q, int32_t max_out) {
int32_t count = 0;
int64_t p0 = 0;
int64_t q0 = 1;
int64_t p1 = 1;
int64_t q1 = 0;
double frac = x;
int64_t sqrtL = (((int64_t)(sqrt(((double)(L))))) + 1);
int32_t iter = 0;
while (iter < 80) {
int64_t a = ((int64_t)(frac));
if ((a > (2 * sqrtL) || (p1 > 0 && a > (FLOW_CHECKED_DIV((sqrtL), (p1)) + 1)))) {
int64_t A = ((p1 * p1) + (q1 * q1));
int64_t B = (2 * ((p0 * p1) + (q0 * q1)));
int64_t C = (((p0 * p0) + (q0 * q0)) - L);
int64_t kmax = 0;
if (A > 0) {
__int128 disc = ((((__int128)(B)) * ((__int128)(B))) - ((((__int128)(4)) * ((__int128)(A))) * ((__int128)(C))));
if (disc > 0) {
int64_t s_val = ((int64_t)(sqrt(((double)(disc)))));
while ((((__int128)(s_val)) * ((__int128)(s_val))) > disc) {
s_val = (s_val - 1);
}
while ((((__int128)((s_val + 1))) * ((__int128)((s_val + 1)))) <= disc) {
s_val = (s_val + 1);
}
kmax = FLOW_CHECKED_DIV((((-B) + s_val)), ((2 * A)));
}
}
if (kmax > (a - 1)) {
kmax = (a - 1);
}
if (kmax < 0) {
kmax = 0;
}
int64_t lo = (kmax - 3);
if (lo < 1) {
lo = 1;
}
int64_t hi = (kmax + 3);
if (hi > (a - 1)) {
hi = (a - 1);
}
if (hi < lo) {
hi = lo;
}
int64_t k = lo;
while (k <= hi) {
int64_t ps = ((k * p1) + p0);
int64_t qs = ((k * q1) + q0);
if (((ps > 0 && qs > 0) && ((((__int128)(ps)) * ((__int128)(ps))) + (((__int128)(qs)) * ((__int128)(qs)))) <= ((__int128)(L)))) {
if (count < max_out) {
out_p[count] = ps;
out_q[count] = qs;
count = (count + 1);
}
}
k = (k + 1);
}
break;
}
int64_t p2 = ((a * p1) + p0);
int64_t q2 = ((a * q1) + q0);
if (((((__int128)(p2)) * ((__int128)(p2))) + (((__int128)(q2)) * ((__int128)(q2)))) > ((__int128)(L))) {
int64_t A2 = ((p1 * p1) + (q1 * q1));
int64_t B2 = (2 * ((p0 * p1) + (q0 * q1)));
int64_t C2 = (((p0 * p0) + (q0 * q0)) - L);
int64_t kmax2 = 0;
if (A2 > 0) {
__int128 disc2 = ((((__int128)(B2)) * ((__int128)(B2))) - ((((__int128)(4)) * ((__int128)(A2))) * ((__int128)(C2))));
if (disc2 > 0) {
int64_t s_val2 = ((int64_t)(sqrt(((double)(disc2)))));
while ((((__int128)(s_val2)) * ((__int128)(s_val2))) > disc2) {
s_val2 = (s_val2 - 1);
}
while ((((__int128)((s_val2 + 1))) * ((__int128)((s_val2 + 1)))) <= disc2) {
s_val2 = (s_val2 + 1);
}
kmax2 = FLOW_CHECKED_DIV((((-B2) + s_val2)), ((2 * A2)));
}
}
if (kmax2 > (a - 1)) {
kmax2 = (a - 1);
}
if (kmax2 < 0) {
kmax2 = 0;
}
int64_t lo2 = (kmax2 - 3);
if (lo2 < 1) {
lo2 = 1;
}
int64_t hi2 = (kmax2 + 3);
if (hi2 > (a - 1)) {
hi2 = (a - 1);
}
int64_t k2 = lo2;
while (k2 <= hi2) {
int64_t ps2 = ((k2 * p1) + p0);
int64_t qs2 = ((k2 * q1) + q0);
if (((ps2 > 0 && qs2 > 0) && ((((__int128)(ps2)) * ((__int128)(ps2))) + (((__int128)(qs2)) * ((__int128)(qs2)))) <= ((__int128)(L)))) {
if (count < max_out) {
out_p[count] = ps2;
out_q[count] = qs2;
count = (count + 1);
}
}
k2 = (k2 + 1);
}
break;
}
if ((p2 > 0 && q2 > 0)) {
if (count < max_out) {
out_p[count] = p2;
out_q[count] = q2;
count = (count + 1);
}
}
if (frac == ((double)(a))) {
break;
}
frac = (1.0 / (frac - ((double)(a))));
p0 = p1;
q0 = q1;
p1 = p2;
q1 = q2;
iter = (iter + 1);
}
if (((p1 > 0 && q1 > 0) && ((((__int128)(p1)) * ((__int128)(p1))) + (((__int128)(q1)) * ((__int128)(q1)))) <= ((__int128)(L)))) {
int32_t found = 0;
int32_t i = 0;
while (i < count) {
if ((out_p[i] == p1 && out_q[i] == q1)) {
found = 1;
break;
}
i = (i + 1);
}
if ((found == 0 && count < max_out)) {
out_p[count] = p1;
out_q[count] = q1;
count = (count + 1);
}
}
return count;
}
void triangle_from_mn_i64_i64(int64_t m, int64_t n) {
int64_t aa = ((m * m) - (n * n));
int64_t bb = ((2 * m) * n);
int64_t cc = ((m * m) + (n * n));
if (FLOW_CHECKED_MOD(((m + n)), (2)) == 0) {
g_tri_a = FLOW_CHECKED_DIV((aa), (2));
g_tri_b = FLOW_CHECKED_DIV((bb), (2));
g_tri_c = FLOW_CHECKED_DIV((cc), (2));
} else {
g_tri_a = aa;
g_tri_b = bb;
g_tri_c = cc;
}
}
double tan_theta_from_legs_i64_i64(int64_t a, int64_t b) {
double aa = (((double)(a)) * ((double)(a)));
double bb = (((double)(b)) * ((double)(b)));
return (((3.0 * ((double)(a))) * ((double)(b))) / (2.0 * (aa + bb)));
}
int64_t f_val_f64_i64(double alpha_deg, int64_t L) {
double alpha_rad = (alpha_deg * DEG2RAD);
double y = tan(alpha_rad);
double r1 = root_left_f64(y);
double r2 = root_right_f64(y);
double best_diff = 1e300;
double best_area_key = (-1.0);
int64_t best_perim = 0;
int64_t* cands_p = (int64_t*)(calloc(200, 8));
int64_t* cands_q = (int64_t*)(calloc(200, 8));
int32_t __flow_step_3 = 1;
for (int32_t ri = 0; (0 <= 2) ? ri < 2 : ri > 2; ri += (0 <= 2) ? 1 : -1) {
double root = ((ri == 0) ? (r1) : (r2));
int32_t ncands = cf_candidates_circle_f64_i64_ptr_i64_ptr_i64_i32(root, L, cands_p, cands_q, 200);
int32_t __flow_step_4 = 1;
for (int32_t ci = 0; (0 <= ncands) ? ci < ncands : ci > ncands; ci += (0 <= ncands) ? 1 : -1) {
int64_t n_val = cands_p[ci];
int64_t m_val = cands_q[ci];
if ((n_val > 0 && n_val < m_val)) {
triangle_from_mn_i64_i64(m_val, n_val);
int64_t a = g_tri_a;
int64_t b = g_tri_b;
int64_t c = g_tri_c;
if ((a > 0 && b > 0)) {
if (c <= L) {
int64_t k = FLOW_CHECKED_DIV((L), (c));
if (k > 0) {
double theta = atan(tan_theta_from_legs_i64_i64(a, b));
double diff = fabs((theta - alpha_rad));
double area_key = (((((double)(k)) * ((double)(k))) * ((double)(a))) * ((double)(b)));
int64_t perim = (k * ((a + b) + c));
if ((diff + 1e-16) < best_diff) {
best_diff = diff;
best_area_key = area_key;
best_perim = perim;
} else {
if (fabs((diff - best_diff)) <= 1e-16) {
if (area_key > best_area_key) {
best_area_key = area_key;
best_perim = perim;
}
}
}
}
}
}
}
}
}
free(cands_p);
free(cands_q);
return best_perim;
}
int32_t main(void) {
int64_t N = 45000;
int64_t L = 10000000000;
int64_t total = 0;
int64_t n = 1;
while (n <= N) {
double alpha = cbrt(((double)(n)));
total = (total + f_val_f64_i64(alpha, L));
n = (n + 1);
}
printf("%lld\n", total);
return 0;
}
Generated MLIR
module {
llvm.func @printf(!llvm.ptr, ...) -> i32
llvm.mlir.global internal constant @str_0("%lld\n\00") {addr_space = 0 : i32} : !llvm.array<6 x i8>
func.func private @calloc(i64, i64) -> !llvm.ptr
func.func private @free(!llvm.ptr) -> ()
func.func private @sqrt(f64) -> f64
func.func private @fabs(f64) -> f64
func.func private @atan(f64) -> f64
func.func private @tan(f64) -> f64
func.func private @cbrt(f64) -> f64
// Constant: PI
llvm.mlir.global internal constant @PI(3.14159265358979323846 : f64) : f64
// Constant: DEG2RAD
llvm.mlir.global internal constant @DEG2RAD(0.01745329251994329576 : f64) : f64
// Constant: T0_F
llvm.mlir.global internal constant @T0_F(0.41421356237309504880 : f64) : f64
func.func @g_of_t(%arg0: f64) -> f64 {
%0 = arith.mulf %arg0, %arg0 : f64
%1 = arith.constant 1.0 : f32
%3 = arith.extf %1 : f32 to f64
%2 = arith.addf %3, %0 : f64
%4 = arith.constant 3.0 : f32
%6 = arith.extf %4 : f32 to f64
%5 = arith.mulf %6, %arg0 : f64
%7 = arith.constant 1.0 : f32
%9 = arith.extf %7 : f32 to f64
%8 = arith.subf %9, %0 : f64
%10 = arith.mulf %5, %8 : f64
%11 = arith.mulf %2, %2 : f64
%12 = arith.divf %10, %11 : f64
func.return %12 : f64
}
func.func @root_left(%arg0: f64) -> f64 {
%13 = arith.constant 0.0 : f32
%14 = arith.extf %13 : f32 to f64
%15 = llvm.mlir.constant(1 : i64) : i64
%16 = llvm.alloca %15 x f64 : (i64) -> !llvm.ptr
llvm.store %14, %16 : f64, !llvm.ptr
%17 = llvm.mlir.addressof @T0_F : !llvm.ptr
%18 = llvm.load %17 : !llvm.ptr -> f64
%19 = llvm.mlir.constant(1 : i64) : i64
%20 = llvm.alloca %19 x f64 : (i64) -> !llvm.ptr
llvm.store %18, %20 : f64, !llvm.ptr
%21 = arith.constant 0 : i32
%22 = arith.constant 35 : i32
%23 = arith.index_cast %21 : i32 to index
%24 = arith.index_cast %22 : i32 to index
%26 = arith.constant 1 : index
%27 = arith.constant -1 : index
%28 = arith.cmpi sle, %23, %24 : index
%25 = arith.select %28, %26, %27 : index
cf.br ^bb0(%23 : index)
^bb0(%29: index):
%30 = arith.cmpi slt, %29, %24 : index
%31 = arith.cmpi sgt, %29, %24 : index
%32 = arith.select %28, %30, %31 : i1
cf.cond_br %32, ^bb1(%29 : index), ^bb2(%29 : index)
^bb1(%33: index):
%34 = llvm.load %16 : !llvm.ptr -> f64
%35 = llvm.load %20 : !llvm.ptr -> f64
%36 = arith.addf %34, %35 : f64
%37 = arith.constant 0.5 : f32
%39 = arith.extf %37 : f32 to f64
%38 = arith.mulf %36, %39 : f64
%40 = func.call @g_of_t(%38) : (f64) -> f64
%41 = arith.cmpf olt, %40, %arg0 : f64
cf.cond_br %41, ^bb3, ^bb4
^bb3:
llvm.store %38, %16 : f64, !llvm.ptr
cf.br ^bb5
^bb4:
llvm.store %38, %20 : f64, !llvm.ptr
cf.br ^bb5
^bb5:
%42 = arith.addi %33, %25 : index
cf.br ^bb0(%42 : index)
^bb2(%43: index):
%44 = llvm.load %16 : !llvm.ptr -> f64
%45 = llvm.load %20 : !llvm.ptr -> f64
%46 = arith.addf %44, %45 : f64
%47 = arith.constant 0.5 : f32
%49 = arith.extf %47 : f32 to f64
%48 = arith.mulf %46, %49 : f64
func.return %48 : f64
}
func.func @root_right(%arg0: f64) -> f64 {
%50 = llvm.mlir.addressof @T0_F : !llvm.ptr
%51 = llvm.load %50 : !llvm.ptr -> f64
%52 = llvm.mlir.constant(1 : i64) : i64
%53 = llvm.alloca %52 x f64 : (i64) -> !llvm.ptr
llvm.store %51, %53 : f64, !llvm.ptr
%54 = arith.constant 1.0 : f32
%55 = arith.extf %54 : f32 to f64
%56 = llvm.mlir.constant(1 : i64) : i64
%57 = llvm.alloca %56 x f64 : (i64) -> !llvm.ptr
llvm.store %55, %57 : f64, !llvm.ptr
%58 = arith.constant 0 : i32
%59 = arith.constant 35 : i32
%60 = arith.index_cast %58 : i32 to index
%61 = arith.index_cast %59 : i32 to index
%63 = arith.constant 1 : index
%64 = arith.constant -1 : index
%65 = arith.cmpi sle, %60, %61 : index
%62 = arith.select %65, %63, %64 : index
cf.br ^bb6(%60 : index)
^bb6(%66: index):
%67 = arith.cmpi slt, %66, %61 : index
%68 = arith.cmpi sgt, %66, %61 : index
%69 = arith.select %65, %67, %68 : i1
cf.cond_br %69, ^bb7(%66 : index), ^bb8(%66 : index)
^bb7(%70: index):
%71 = llvm.load %53 : !llvm.ptr -> f64
%72 = llvm.load %57 : !llvm.ptr -> f64
%73 = arith.addf %71, %72 : f64
%74 = arith.constant 0.5 : f32
%76 = arith.extf %74 : f32 to f64
%75 = arith.mulf %73, %76 : f64
%77 = func.call @g_of_t(%75) : (f64) -> f64
%78 = arith.cmpf ogt, %77, %arg0 : f64
cf.cond_br %78, ^bb9, ^bb10
^bb9:
llvm.store %75, %53 : f64, !llvm.ptr
cf.br ^bb11
^bb10:
llvm.store %75, %57 : f64, !llvm.ptr
cf.br ^bb11
^bb11:
%79 = arith.addi %70, %62 : index
cf.br ^bb6(%79 : index)
^bb8(%80: index):
%81 = llvm.load %53 : !llvm.ptr -> f64
%82 = llvm.load %57 : !llvm.ptr -> f64
%83 = arith.addf %81, %82 : f64
%84 = arith.constant 0.5 : f32
%86 = arith.extf %84 : f32 to f64
%85 = arith.mulf %83, %86 : f64
func.return %85 : f64
}
func.func @cf_candidates_circle(%arg0: f64, %arg1: i64, %arg2: !llvm.ptr, %arg3: !llvm.ptr, %arg4: i32) -> i32 {
%87 = arith.constant 0 : i32
%88 = llvm.mlir.constant(1 : i64) : i64
%89 = llvm.alloca %88 x i32 : (i64) -> !llvm.ptr
llvm.store %87, %89 : i32, !llvm.ptr
%90 = arith.constant 0 : i32
%91 = arith.extsi %90 : i32 to i64
%92 = llvm.mlir.constant(1 : i64) : i64
%93 = llvm.alloca %92 x i64 : (i64) -> !llvm.ptr
llvm.store %91, %93 : i64, !llvm.ptr
%94 = arith.constant 1 : i32
%95 = arith.extsi %94 : i32 to i64
%96 = llvm.mlir.constant(1 : i64) : i64
%97 = llvm.alloca %96 x i64 : (i64) -> !llvm.ptr
llvm.store %95, %97 : i64, !llvm.ptr
%98 = arith.constant 1 : i32
%99 = arith.extsi %98 : i32 to i64
%100 = llvm.mlir.constant(1 : i64) : i64
%101 = llvm.alloca %100 x i64 : (i64) -> !llvm.ptr
llvm.store %99, %101 : i64, !llvm.ptr
%102 = arith.constant 0 : i32
%103 = arith.extsi %102 : i32 to i64
%104 = llvm.mlir.constant(1 : i64) : i64
%105 = llvm.alloca %104 x i64 : (i64) -> !llvm.ptr
llvm.store %103, %105 : i64, !llvm.ptr
%106 = llvm.mlir.constant(1 : i64) : i64
%107 = llvm.alloca %106 x f64 : (i64) -> !llvm.ptr
llvm.store %arg0, %107 : f64, !llvm.ptr
%108 = arith.sitofp %arg1 : i64 to f64
%109 = math.sqrt %108 : f64
%110 = arith.fptosi %109 : f64 to i64
%111 = arith.constant 1 : i32
%113 = arith.extsi %111 : i32 to i64
%112 = arith.addi %110, %113 : i64
%114 = arith.constant 0 : i32
%115 = llvm.mlir.constant(1 : i64) : i64
%116 = llvm.alloca %115 x i32 : (i64) -> !llvm.ptr
llvm.store %114, %116 : i32, !llvm.ptr
cf.br ^bb12
^bb12:
%117 = llvm.load %116 : !llvm.ptr -> i32
%118 = arith.constant 80 : i32
%119 = arith.cmpi slt, %117, %118 : i32
cf.cond_br %119, ^bb13, ^bb14
^bb13:
%120 = llvm.load %107 : !llvm.ptr -> f64
%121 = arith.fptosi %120 : f64 to i64
%122 = arith.constant 2 : i32
%124 = arith.extsi %122 : i32 to i64
%123 = arith.muli %124, %112 : i64
%125 = arith.cmpi sgt, %121, %123 : i64
%126 = scf.if %125 -> (i1) {
%127 = arith.constant true
scf.yield %127 : i1
} else {
%128 = llvm.load %101 : !llvm.ptr -> i64
%129 = arith.constant 0 : i32
%131 = arith.extsi %129 : i32 to i64
%130 = arith.cmpi sgt, %128, %131 : i64
%132 = scf.if %130 -> (i1) {
%133 = llvm.load %101 : !llvm.ptr -> i64
%134 = arith.divsi %112, %133 : i64
%135 = arith.constant 1 : i32
%137 = arith.extsi %135 : i32 to i64
%136 = arith.addi %134, %137 : i64
%138 = arith.cmpi sgt, %121, %136 : i64
scf.yield %138 : i1
} else {
%139 = arith.constant false
scf.yield %139 : i1
}
scf.yield %132 : i1
}
cf.cond_br %126, ^bb15, ^bb16
^bb15:
%140 = llvm.load %101 : !llvm.ptr -> i64
%141 = llvm.load %101 : !llvm.ptr -> i64
%142 = arith.muli %140, %141 : i64
%143 = llvm.load %105 : !llvm.ptr -> i64
%144 = llvm.load %105 : !llvm.ptr -> i64
%145 = arith.muli %143, %144 : i64
%146 = arith.addi %142, %145 : i64
%147 = arith.constant 2 : i32
%148 = llvm.load %93 : !llvm.ptr -> i64
%149 = llvm.load %101 : !llvm.ptr -> i64
%150 = arith.muli %148, %149 : i64
%151 = llvm.load %97 : !llvm.ptr -> i64
%152 = llvm.load %105 : !llvm.ptr -> i64
%153 = arith.muli %151, %152 : i64
%154 = arith.addi %150, %153 : i64
%156 = arith.extsi %147 : i32 to i64
%155 = arith.muli %156, %154 : i64
%157 = llvm.load %93 : !llvm.ptr -> i64
%158 = llvm.load %93 : !llvm.ptr -> i64
%159 = arith.muli %157, %158 : i64
%160 = llvm.load %97 : !llvm.ptr -> i64
%161 = llvm.load %97 : !llvm.ptr -> i64
%162 = arith.muli %160, %161 : i64
%163 = arith.addi %159, %162 : i64
%164 = arith.subi %163, %arg1 : i64
%165 = arith.constant 0 : i32
%166 = arith.extsi %165 : i32 to i64
%167 = llvm.mlir.constant(1 : i64) : i64
%168 = llvm.alloca %167 x i64 : (i64) -> !llvm.ptr
llvm.store %166, %168 : i64, !llvm.ptr
%169 = arith.constant 0 : i32
%171 = arith.extsi %169 : i32 to i64
%170 = arith.cmpi sgt, %146, %171 : i64
cf.cond_br %170, ^bb18, ^bb19
^bb18:
%172 = arith.extsi %155 : i64 to i128
%173 = arith.extsi %155 : i64 to i128
%175 = arith.trunci %172 : i128 to i64
%176 = arith.trunci %173 : i128 to i64
%174 = arith.muli %175, %176 : i64
%177 = arith.constant 4 : i32
%178 = arith.extsi %177 : i32 to i128
%179 = arith.extsi %146 : i64 to i128
%181 = arith.trunci %178 : i128 to i64
%182 = arith.trunci %179 : i128 to i64
%180 = arith.muli %181, %182 : i64
%183 = arith.extsi %164 : i64 to i128
%185 = arith.trunci %183 : i128 to i64
%184 = arith.muli %180, %185 : i64
%186 = arith.subi %174, %184 : i64
%187 = arith.extsi %186 : i64 to i128
%188 = arith.constant 0 : i32
%190 = arith.trunci %187 : i128 to i64
%191 = arith.extsi %188 : i32 to i64
%189 = arith.cmpi sgt, %190, %191 : i64
cf.cond_br %189, ^bb21, ^bb22
^bb21:
%192 = arith.sitofp %187 : i128 to f64
%193 = math.sqrt %192 : f64
%194 = arith.fptosi %193 : f64 to i64
%195 = llvm.mlir.constant(1 : i64) : i64
%196 = llvm.alloca %195 x i64 : (i64) -> !llvm.ptr
llvm.store %194, %196 : i64, !llvm.ptr
cf.br ^bb24
^bb24:
%197 = llvm.load %196 : !llvm.ptr -> i64
%198 = arith.extsi %197 : i64 to i128
%199 = llvm.load %196 : !llvm.ptr -> i64
%200 = arith.extsi %199 : i64 to i128
%202 = arith.trunci %198 : i128 to i64
%203 = arith.trunci %200 : i128 to i64
%201 = arith.muli %202, %203 : i64
%205 = arith.trunci %187 : i128 to i64
%204 = arith.cmpi sgt, %201, %205 : i64
cf.cond_br %204, ^bb25, ^bb26
^bb25:
%206 = llvm.load %196 : !llvm.ptr -> i64
%207 = arith.constant 1 : i32
%209 = arith.extsi %207 : i32 to i64
%208 = arith.subi %206, %209 : i64
llvm.store %208, %196 : i64, !llvm.ptr
cf.br ^bb24
^bb26:
cf.br ^bb27
^bb27:
%210 = llvm.load %196 : !llvm.ptr -> i64
%211 = arith.constant 1 : i32
%213 = arith.extsi %211 : i32 to i64
%212 = arith.addi %210, %213 : i64
%214 = arith.extsi %212 : i64 to i128
%215 = llvm.load %196 : !llvm.ptr -> i64
%216 = arith.constant 1 : i32
%218 = arith.extsi %216 : i32 to i64
%217 = arith.addi %215, %218 : i64
%219 = arith.extsi %217 : i64 to i128
%221 = arith.trunci %214 : i128 to i64
%222 = arith.trunci %219 : i128 to i64
%220 = arith.muli %221, %222 : i64
%224 = arith.trunci %187 : i128 to i64
%223 = arith.cmpi sle, %220, %224 : i64
cf.cond_br %223, ^bb28, ^bb29
^bb28:
%225 = llvm.load %196 : !llvm.ptr -> i64
%226 = arith.constant 1 : i32
%228 = arith.extsi %226 : i32 to i64
%227 = arith.addi %225, %228 : i64
llvm.store %227, %196 : i64, !llvm.ptr
cf.br ^bb27
^bb29:
%230 = arith.constant 0 : i64
%229 = arith.subi %230, %155 : i64
%231 = llvm.load %196 : !llvm.ptr -> i64
%232 = arith.addi %229, %231 : i64
%233 = arith.constant 2 : i32
%235 = arith.extsi %233 : i32 to i64
%234 = arith.muli %235, %146 : i64
%236 = arith.divsi %232, %234 : i64
llvm.store %236, %168 : i64, !llvm.ptr
cf.br ^bb23
^bb22:
cf.br ^bb23
^bb23:
cf.br ^bb20
^bb19:
cf.br ^bb20
^bb20:
%237 = llvm.load %168 : !llvm.ptr -> i64
%238 = arith.constant 1 : i32
%240 = arith.extsi %238 : i32 to i64
%239 = arith.subi %121, %240 : i64
%241 = arith.cmpi sgt, %237, %239 : i64
cf.cond_br %241, ^bb30, ^bb31
^bb30:
%242 = arith.constant 1 : i32
%244 = arith.extsi %242 : i32 to i64
%243 = arith.subi %121, %244 : i64
llvm.store %243, %168 : i64, !llvm.ptr
cf.br ^bb32
^bb31:
cf.br ^bb32
^bb32:
%245 = llvm.load %168 : !llvm.ptr -> i64
%246 = arith.constant 0 : i32
%248 = arith.extsi %246 : i32 to i64
%247 = arith.cmpi slt, %245, %248 : i64
cf.cond_br %247, ^bb33, ^bb34
^bb33:
%249 = arith.constant 0 : i32
%250 = arith.extsi %249 : i32 to i64
llvm.store %250, %168 : i64, !llvm.ptr
cf.br ^bb35
^bb34:
cf.br ^bb35
^bb35:
%251 = llvm.load %168 : !llvm.ptr -> i64
%252 = arith.constant 3 : i32
%254 = arith.extsi %252 : i32 to i64
%253 = arith.subi %251, %254 : i64
%255 = llvm.mlir.constant(1 : i64) : i64
%256 = llvm.alloca %255 x i64 : (i64) -> !llvm.ptr
llvm.store %253, %256 : i64, !llvm.ptr
%257 = llvm.load %256 : !llvm.ptr -> i64
%258 = arith.constant 1 : i32
%260 = arith.extsi %258 : i32 to i64
%259 = arith.cmpi slt, %257, %260 : i64
cf.cond_br %259, ^bb36, ^bb37
^bb36:
%261 = arith.constant 1 : i32
%262 = arith.extsi %261 : i32 to i64
llvm.store %262, %256 : i64, !llvm.ptr
cf.br ^bb38
^bb37:
cf.br ^bb38
^bb38:
%263 = llvm.load %168 : !llvm.ptr -> i64
%264 = arith.constant 3 : i32
%266 = arith.extsi %264 : i32 to i64
%265 = arith.addi %263, %266 : i64
%267 = llvm.mlir.constant(1 : i64) : i64
%268 = llvm.alloca %267 x i64 : (i64) -> !llvm.ptr
llvm.store %265, %268 : i64, !llvm.ptr
%269 = llvm.load %268 : !llvm.ptr -> i64
%270 = arith.constant 1 : i32
%272 = arith.extsi %270 : i32 to i64
%271 = arith.subi %121, %272 : i64
%273 = arith.cmpi sgt, %269, %271 : i64
cf.cond_br %273, ^bb39, ^bb40
^bb39:
%274 = arith.constant 1 : i32
%276 = arith.extsi %274 : i32 to i64
%275 = arith.subi %121, %276 : i64
llvm.store %275, %268 : i64, !llvm.ptr
cf.br ^bb41
^bb40:
cf.br ^bb41
^bb41:
%277 = llvm.load %268 : !llvm.ptr -> i64
%278 = llvm.load %256 : !llvm.ptr -> i64
%279 = arith.cmpi slt, %277, %278 : i64
cf.cond_br %279, ^bb42, ^bb43
^bb42:
%280 = llvm.load %256 : !llvm.ptr -> i64
llvm.store %280, %268 : i64, !llvm.ptr
cf.br ^bb44
^bb43:
cf.br ^bb44
^bb44:
%281 = llvm.load %256 : !llvm.ptr -> i64
%282 = llvm.mlir.constant(1 : i64) : i64
%283 = llvm.alloca %282 x i64 : (i64) -> !llvm.ptr
llvm.store %281, %283 : i64, !llvm.ptr
cf.br ^bb45
^bb45:
%284 = llvm.load %283 : !llvm.ptr -> i64
%285 = llvm.load %268 : !llvm.ptr -> i64
%286 = arith.cmpi sle, %284, %285 : i64
cf.cond_br %286, ^bb46, ^bb47
^bb46:
%287 = llvm.load %283 : !llvm.ptr -> i64
%288 = llvm.load %101 : !llvm.ptr -> i64
%289 = arith.muli %287, %288 : i64
%290 = llvm.load %93 : !llvm.ptr -> i64
%291 = arith.addi %289, %290 : i64
%292 = llvm.load %283 : !llvm.ptr -> i64
%293 = llvm.load %105 : !llvm.ptr -> i64
%294 = arith.muli %292, %293 : i64
%295 = llvm.load %97 : !llvm.ptr -> i64
%296 = arith.addi %294, %295 : i64
%297 = arith.constant 0 : i32
%299 = arith.extsi %297 : i32 to i64
%298 = arith.cmpi sgt, %291, %299 : i64
%300 = scf.if %298 -> (i1) {
%301 = arith.constant 0 : i32
%303 = arith.extsi %301 : i32 to i64
%302 = arith.cmpi sgt, %296, %303 : i64
scf.yield %302 : i1
} else {
%304 = arith.constant false
scf.yield %304 : i1
}
%305 = scf.if %300 -> (i1) {
%306 = arith.extsi %291 : i64 to i128
%307 = arith.extsi %291 : i64 to i128
%309 = arith.trunci %306 : i128 to i64
%310 = arith.trunci %307 : i128 to i64
%308 = arith.muli %309, %310 : i64
%311 = arith.extsi %296 : i64 to i128
%312 = arith.extsi %296 : i64 to i128
%314 = arith.trunci %311 : i128 to i64
%315 = arith.trunci %312 : i128 to i64
%313 = arith.muli %314, %315 : i64
%316 = arith.addi %308, %313 : i64
%317 = arith.extsi %arg1 : i64 to i128
%319 = arith.trunci %317 : i128 to i64
%318 = arith.cmpi sle, %316, %319 : i64
scf.yield %318 : i1
} else {
%320 = arith.constant false
scf.yield %320 : i1
}
cf.cond_br %305, ^bb48, ^bb49
^bb48:
%321 = llvm.load %89 : !llvm.ptr -> i32
%322 = arith.cmpi slt, %321, %arg4 : i32
cf.cond_br %322, ^bb51, ^bb52
^bb51:
%323 = llvm.load %89 : !llvm.ptr -> i32
%324 = arith.extsi %323 : i32 to i64
%325 = llvm.getelementptr %arg2[%324] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %291, %325 : i64, !llvm.ptr
%326 = llvm.load %89 : !llvm.ptr -> i32
%327 = arith.extsi %326 : i32 to i64
%328 = llvm.getelementptr %arg3[%327] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %296, %328 : i64, !llvm.ptr
%329 = llvm.load %89 : !llvm.ptr -> i32
%330 = arith.constant 1 : i32
%331 = arith.addi %329, %330 : i32
llvm.store %331, %89 : i32, !llvm.ptr
cf.br ^bb53
^bb52:
cf.br ^bb53
^bb53:
cf.br ^bb50
^bb49:
cf.br ^bb50
^bb50:
%332 = llvm.load %283 : !llvm.ptr -> i64
%333 = arith.constant 1 : i32
%335 = arith.extsi %333 : i32 to i64
%334 = arith.addi %332, %335 : i64
llvm.store %334, %283 : i64, !llvm.ptr
cf.br ^bb45
^bb47:
cf.br ^bb14
^bb16:
cf.br ^bb17
^bb17:
%336 = llvm.load %101 : !llvm.ptr -> i64
%337 = arith.muli %121, %336 : i64
%338 = llvm.load %93 : !llvm.ptr -> i64
%339 = arith.addi %337, %338 : i64
%340 = llvm.load %105 : !llvm.ptr -> i64
%341 = arith.muli %121, %340 : i64
%342 = llvm.load %97 : !llvm.ptr -> i64
%343 = arith.addi %341, %342 : i64
%344 = arith.extsi %339 : i64 to i128
%345 = arith.extsi %339 : i64 to i128
%347 = arith.trunci %344 : i128 to i64
%348 = arith.trunci %345 : i128 to i64
%346 = arith.muli %347, %348 : i64
%349 = arith.extsi %343 : i64 to i128
%350 = arith.extsi %343 : i64 to i128
%352 = arith.trunci %349 : i128 to i64
%353 = arith.trunci %350 : i128 to i64
%351 = arith.muli %352, %353 : i64
%354 = arith.addi %346, %351 : i64
%355 = arith.extsi %arg1 : i64 to i128
%357 = arith.trunci %355 : i128 to i64
%356 = arith.cmpi sgt, %354, %357 : i64
cf.cond_br %356, ^bb54, ^bb55
^bb54:
%358 = llvm.load %101 : !llvm.ptr -> i64
%359 = llvm.load %101 : !llvm.ptr -> i64
%360 = arith.muli %358, %359 : i64
%361 = llvm.load %105 : !llvm.ptr -> i64
%362 = llvm.load %105 : !llvm.ptr -> i64
%363 = arith.muli %361, %362 : i64
%364 = arith.addi %360, %363 : i64
%365 = arith.constant 2 : i32
%366 = llvm.load %93 : !llvm.ptr -> i64
%367 = llvm.load %101 : !llvm.ptr -> i64
%368 = arith.muli %366, %367 : i64
%369 = llvm.load %97 : !llvm.ptr -> i64
%370 = llvm.load %105 : !llvm.ptr -> i64
%371 = arith.muli %369, %370 : i64
%372 = arith.addi %368, %371 : i64
%374 = arith.extsi %365 : i32 to i64
%373 = arith.muli %374, %372 : i64
%375 = llvm.load %93 : !llvm.ptr -> i64
%376 = llvm.load %93 : !llvm.ptr -> i64
%377 = arith.muli %375, %376 : i64
%378 = llvm.load %97 : !llvm.ptr -> i64
%379 = llvm.load %97 : !llvm.ptr -> i64
%380 = arith.muli %378, %379 : i64
%381 = arith.addi %377, %380 : i64
%382 = arith.subi %381, %arg1 : i64
%383 = arith.constant 0 : i32
%384 = arith.extsi %383 : i32 to i64
%385 = llvm.mlir.constant(1 : i64) : i64
%386 = llvm.alloca %385 x i64 : (i64) -> !llvm.ptr
llvm.store %384, %386 : i64, !llvm.ptr
%387 = arith.constant 0 : i32
%389 = arith.extsi %387 : i32 to i64
%388 = arith.cmpi sgt, %364, %389 : i64
cf.cond_br %388, ^bb57, ^bb58
^bb57:
%390 = arith.extsi %373 : i64 to i128
%391 = arith.extsi %373 : i64 to i128
%393 = arith.trunci %390 : i128 to i64
%394 = arith.trunci %391 : i128 to i64
%392 = arith.muli %393, %394 : i64
%395 = arith.constant 4 : i32
%396 = arith.extsi %395 : i32 to i128
%397 = arith.extsi %364 : i64 to i128
%399 = arith.trunci %396 : i128 to i64
%400 = arith.trunci %397 : i128 to i64
%398 = arith.muli %399, %400 : i64
%401 = arith.extsi %382 : i64 to i128
%403 = arith.trunci %401 : i128 to i64
%402 = arith.muli %398, %403 : i64
%404 = arith.subi %392, %402 : i64
%405 = arith.extsi %404 : i64 to i128
%406 = arith.constant 0 : i32
%408 = arith.trunci %405 : i128 to i64
%409 = arith.extsi %406 : i32 to i64
%407 = arith.cmpi sgt, %408, %409 : i64
cf.cond_br %407, ^bb60, ^bb61
^bb60:
%410 = arith.sitofp %405 : i128 to f64
%411 = math.sqrt %410 : f64
%412 = arith.fptosi %411 : f64 to i64
%413 = llvm.mlir.constant(1 : i64) : i64
%414 = llvm.alloca %413 x i64 : (i64) -> !llvm.ptr
llvm.store %412, %414 : i64, !llvm.ptr
cf.br ^bb63
^bb63:
%415 = llvm.load %414 : !llvm.ptr -> i64
%416 = arith.extsi %415 : i64 to i128
%417 = llvm.load %414 : !llvm.ptr -> i64
%418 = arith.extsi %417 : i64 to i128
%420 = arith.trunci %416 : i128 to i64
%421 = arith.trunci %418 : i128 to i64
%419 = arith.muli %420, %421 : i64
%423 = arith.trunci %405 : i128 to i64
%422 = arith.cmpi sgt, %419, %423 : i64
cf.cond_br %422, ^bb64, ^bb65
^bb64:
%424 = llvm.load %414 : !llvm.ptr -> i64
%425 = arith.constant 1 : i32
%427 = arith.extsi %425 : i32 to i64
%426 = arith.subi %424, %427 : i64
llvm.store %426, %414 : i64, !llvm.ptr
cf.br ^bb63
^bb65:
cf.br ^bb66
^bb66:
%428 = llvm.load %414 : !llvm.ptr -> i64
%429 = arith.constant 1 : i32
%431 = arith.extsi %429 : i32 to i64
%430 = arith.addi %428, %431 : i64
%432 = arith.extsi %430 : i64 to i128
%433 = llvm.load %414 : !llvm.ptr -> i64
%434 = arith.constant 1 : i32
%436 = arith.extsi %434 : i32 to i64
%435 = arith.addi %433, %436 : i64
%437 = arith.extsi %435 : i64 to i128
%439 = arith.trunci %432 : i128 to i64
%440 = arith.trunci %437 : i128 to i64
%438 = arith.muli %439, %440 : i64
%442 = arith.trunci %405 : i128 to i64
%441 = arith.cmpi sle, %438, %442 : i64
cf.cond_br %441, ^bb67, ^bb68
^bb67:
%443 = llvm.load %414 : !llvm.ptr -> i64
%444 = arith.constant 1 : i32
%446 = arith.extsi %444 : i32 to i64
%445 = arith.addi %443, %446 : i64
llvm.store %445, %414 : i64, !llvm.ptr
cf.br ^bb66
^bb68:
%448 = arith.constant 0 : i64
%447 = arith.subi %448, %373 : i64
%449 = llvm.load %414 : !llvm.ptr -> i64
%450 = arith.addi %447, %449 : i64
%451 = arith.constant 2 : i32
%453 = arith.extsi %451 : i32 to i64
%452 = arith.muli %453, %364 : i64
%454 = arith.divsi %450, %452 : i64
llvm.store %454, %386 : i64, !llvm.ptr
cf.br ^bb62
^bb61:
cf.br ^bb62
^bb62:
cf.br ^bb59
^bb58:
cf.br ^bb59
^bb59:
%455 = llvm.load %386 : !llvm.ptr -> i64
%456 = arith.constant 1 : i32
%458 = arith.extsi %456 : i32 to i64
%457 = arith.subi %121, %458 : i64
%459 = arith.cmpi sgt, %455, %457 : i64
cf.cond_br %459, ^bb69, ^bb70
^bb69:
%460 = arith.constant 1 : i32
%462 = arith.extsi %460 : i32 to i64
%461 = arith.subi %121, %462 : i64
llvm.store %461, %386 : i64, !llvm.ptr
cf.br ^bb71
^bb70:
cf.br ^bb71
^bb71:
%463 = llvm.load %386 : !llvm.ptr -> i64
%464 = arith.constant 0 : i32
%466 = arith.extsi %464 : i32 to i64
%465 = arith.cmpi slt, %463, %466 : i64
cf.cond_br %465, ^bb72, ^bb73
^bb72:
%467 = arith.constant 0 : i32
%468 = arith.extsi %467 : i32 to i64
llvm.store %468, %386 : i64, !llvm.ptr
cf.br ^bb74
^bb73:
cf.br ^bb74
^bb74:
%469 = llvm.load %386 : !llvm.ptr -> i64
%470 = arith.constant 3 : i32
%472 = arith.extsi %470 : i32 to i64
%471 = arith.subi %469, %472 : i64
%473 = llvm.mlir.constant(1 : i64) : i64
%474 = llvm.alloca %473 x i64 : (i64) -> !llvm.ptr
llvm.store %471, %474 : i64, !llvm.ptr
%475 = llvm.load %474 : !llvm.ptr -> i64
%476 = arith.constant 1 : i32
%478 = arith.extsi %476 : i32 to i64
%477 = arith.cmpi slt, %475, %478 : i64
cf.cond_br %477, ^bb75, ^bb76
^bb75:
%479 = arith.constant 1 : i32
%480 = arith.extsi %479 : i32 to i64
llvm.store %480, %474 : i64, !llvm.ptr
cf.br ^bb77
^bb76:
cf.br ^bb77
^bb77:
%481 = llvm.load %386 : !llvm.ptr -> i64
%482 = arith.constant 3 : i32
%484 = arith.extsi %482 : i32 to i64
%483 = arith.addi %481, %484 : i64
%485 = llvm.mlir.constant(1 : i64) : i64
%486 = llvm.alloca %485 x i64 : (i64) -> !llvm.ptr
llvm.store %483, %486 : i64, !llvm.ptr
%487 = llvm.load %486 : !llvm.ptr -> i64
%488 = arith.constant 1 : i32
%490 = arith.extsi %488 : i32 to i64
%489 = arith.subi %121, %490 : i64
%491 = arith.cmpi sgt, %487, %489 : i64
cf.cond_br %491, ^bb78, ^bb79
^bb78:
%492 = arith.constant 1 : i32
%494 = arith.extsi %492 : i32 to i64
%493 = arith.subi %121, %494 : i64
llvm.store %493, %486 : i64, !llvm.ptr
cf.br ^bb80
^bb79:
cf.br ^bb80
^bb80:
%495 = llvm.load %474 : !llvm.ptr -> i64
%496 = llvm.mlir.constant(1 : i64) : i64
%497 = llvm.alloca %496 x i64 : (i64) -> !llvm.ptr
llvm.store %495, %497 : i64, !llvm.ptr
cf.br ^bb81
^bb81:
%498 = llvm.load %497 : !llvm.ptr -> i64
%499 = llvm.load %486 : !llvm.ptr -> i64
%500 = arith.cmpi sle, %498, %499 : i64
cf.cond_br %500, ^bb82, ^bb83
^bb82:
%501 = llvm.load %497 : !llvm.ptr -> i64
%502 = llvm.load %101 : !llvm.ptr -> i64
%503 = arith.muli %501, %502 : i64
%504 = llvm.load %93 : !llvm.ptr -> i64
%505 = arith.addi %503, %504 : i64
%506 = llvm.load %497 : !llvm.ptr -> i64
%507 = llvm.load %105 : !llvm.ptr -> i64
%508 = arith.muli %506, %507 : i64
%509 = llvm.load %97 : !llvm.ptr -> i64
%510 = arith.addi %508, %509 : i64
%511 = arith.constant 0 : i32
%513 = arith.extsi %511 : i32 to i64
%512 = arith.cmpi sgt, %505, %513 : i64
%514 = scf.if %512 -> (i1) {
%515 = arith.constant 0 : i32
%517 = arith.extsi %515 : i32 to i64
%516 = arith.cmpi sgt, %510, %517 : i64
scf.yield %516 : i1
} else {
%518 = arith.constant false
scf.yield %518 : i1
}
%519 = scf.if %514 -> (i1) {
%520 = arith.extsi %505 : i64 to i128
%521 = arith.extsi %505 : i64 to i128
%523 = arith.trunci %520 : i128 to i64
%524 = arith.trunci %521 : i128 to i64
%522 = arith.muli %523, %524 : i64
%525 = arith.extsi %510 : i64 to i128
%526 = arith.extsi %510 : i64 to i128
%528 = arith.trunci %525 : i128 to i64
%529 = arith.trunci %526 : i128 to i64
%527 = arith.muli %528, %529 : i64
%530 = arith.addi %522, %527 : i64
%531 = arith.extsi %arg1 : i64 to i128
%533 = arith.trunci %531 : i128 to i64
%532 = arith.cmpi sle, %530, %533 : i64
scf.yield %532 : i1
} else {
%534 = arith.constant false
scf.yield %534 : i1
}
cf.cond_br %519, ^bb84, ^bb85
^bb84:
%535 = llvm.load %89 : !llvm.ptr -> i32
%536 = arith.cmpi slt, %535, %arg4 : i32
cf.cond_br %536, ^bb87, ^bb88
^bb87:
%537 = llvm.load %89 : !llvm.ptr -> i32
%538 = arith.extsi %537 : i32 to i64
%539 = llvm.getelementptr %arg2[%538] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %505, %539 : i64, !llvm.ptr
%540 = llvm.load %89 : !llvm.ptr -> i32
%541 = arith.extsi %540 : i32 to i64
%542 = llvm.getelementptr %arg3[%541] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %510, %542 : i64, !llvm.ptr
%543 = llvm.load %89 : !llvm.ptr -> i32
%544 = arith.constant 1 : i32
%545 = arith.addi %543, %544 : i32
llvm.store %545, %89 : i32, !llvm.ptr
cf.br ^bb89
^bb88:
cf.br ^bb89
^bb89:
cf.br ^bb86
^bb85:
cf.br ^bb86
^bb86:
%546 = llvm.load %497 : !llvm.ptr -> i64
%547 = arith.constant 1 : i32
%549 = arith.extsi %547 : i32 to i64
%548 = arith.addi %546, %549 : i64
llvm.store %548, %497 : i64, !llvm.ptr
cf.br ^bb81
^bb83:
cf.br ^bb14
^bb55:
cf.br ^bb56
^bb56:
%550 = arith.constant 0 : i32
%552 = arith.extsi %550 : i32 to i64
%551 = arith.cmpi sgt, %339, %552 : i64
%553 = scf.if %551 -> (i1) {
%554 = arith.constant 0 : i32
%556 = arith.extsi %554 : i32 to i64
%555 = arith.cmpi sgt, %343, %556 : i64
scf.yield %555 : i1
} else {
%557 = arith.constant false
scf.yield %557 : i1
}
cf.cond_br %553, ^bb90, ^bb91
^bb90:
%558 = llvm.load %89 : !llvm.ptr -> i32
%559 = arith.cmpi slt, %558, %arg4 : i32
cf.cond_br %559, ^bb93, ^bb94
^bb93:
%560 = llvm.load %89 : !llvm.ptr -> i32
%561 = arith.extsi %560 : i32 to i64
%562 = llvm.getelementptr %arg2[%561] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %339, %562 : i64, !llvm.ptr
%563 = llvm.load %89 : !llvm.ptr -> i32
%564 = arith.extsi %563 : i32 to i64
%565 = llvm.getelementptr %arg3[%564] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %343, %565 : i64, !llvm.ptr
%566 = llvm.load %89 : !llvm.ptr -> i32
%567 = arith.constant 1 : i32
%568 = arith.addi %566, %567 : i32
llvm.store %568, %89 : i32, !llvm.ptr
cf.br ^bb95
^bb94:
cf.br ^bb95
^bb95:
cf.br ^bb92
^bb91:
cf.br ^bb92
^bb92:
%569 = llvm.load %107 : !llvm.ptr -> f64
%570 = arith.sitofp %121 : i64 to f64
%571 = arith.cmpf oeq, %569, %570 : f64
cf.cond_br %571, ^bb96, ^bb97
^bb96:
cf.br ^bb14
^bb97:
cf.br ^bb98
^bb98:
%572 = arith.constant 1.0 : f32
%573 = llvm.load %107 : !llvm.ptr -> f64
%574 = arith.sitofp %121 : i64 to f64
%575 = arith.subf %573, %574 : f64
%577 = arith.extf %572 : f32 to f64
%576 = arith.divf %577, %575 : f64
llvm.store %576, %107 : f64, !llvm.ptr
%578 = llvm.load %101 : !llvm.ptr -> i64
llvm.store %578, %93 : i64, !llvm.ptr
%579 = llvm.load %105 : !llvm.ptr -> i64
llvm.store %579, %97 : i64, !llvm.ptr
llvm.store %339, %101 : i64, !llvm.ptr
llvm.store %343, %105 : i64, !llvm.ptr
%580 = llvm.load %116 : !llvm.ptr -> i32
%581 = arith.constant 1 : i32
%582 = arith.addi %580, %581 : i32
llvm.store %582, %116 : i32, !llvm.ptr
cf.br ^bb12
^bb14:
%583 = llvm.load %101 : !llvm.ptr -> i64
%584 = arith.constant 0 : i32
%586 = arith.extsi %584 : i32 to i64
%585 = arith.cmpi sgt, %583, %586 : i64
%587 = scf.if %585 -> (i1) {
%588 = llvm.load %105 : !llvm.ptr -> i64
%589 = arith.constant 0 : i32
%591 = arith.extsi %589 : i32 to i64
%590 = arith.cmpi sgt, %588, %591 : i64
scf.yield %590 : i1
} else {
%592 = arith.constant false
scf.yield %592 : i1
}
%593 = scf.if %587 -> (i1) {
%594 = llvm.load %101 : !llvm.ptr -> i64
%595 = arith.extsi %594 : i64 to i128
%596 = llvm.load %101 : !llvm.ptr -> i64
%597 = arith.extsi %596 : i64 to i128
%599 = arith.trunci %595 : i128 to i64
%600 = arith.trunci %597 : i128 to i64
%598 = arith.muli %599, %600 : i64
%601 = llvm.load %105 : !llvm.ptr -> i64
%602 = arith.extsi %601 : i64 to i128
%603 = llvm.load %105 : !llvm.ptr -> i64
%604 = arith.extsi %603 : i64 to i128
%606 = arith.trunci %602 : i128 to i64
%607 = arith.trunci %604 : i128 to i64
%605 = arith.muli %606, %607 : i64
%608 = arith.addi %598, %605 : i64
%609 = arith.extsi %arg1 : i64 to i128
%611 = arith.trunci %609 : i128 to i64
%610 = arith.cmpi sle, %608, %611 : i64
scf.yield %610 : i1
} else {
%612 = arith.constant false
scf.yield %612 : i1
}
cf.cond_br %593, ^bb99, ^bb100
^bb99:
%613 = arith.constant 0 : i32
%614 = llvm.mlir.constant(1 : i64) : i64
%615 = llvm.alloca %614 x i32 : (i64) -> !llvm.ptr
llvm.store %613, %615 : i32, !llvm.ptr
%616 = arith.constant 0 : i32
%617 = llvm.mlir.constant(1 : i64) : i64
%618 = llvm.alloca %617 x i32 : (i64) -> !llvm.ptr
llvm.store %616, %618 : i32, !llvm.ptr
cf.br ^bb102
^bb102:
%619 = llvm.load %618 : !llvm.ptr -> i32
%620 = llvm.load %89 : !llvm.ptr -> i32
%621 = arith.cmpi slt, %619, %620 : i32
cf.cond_br %621, ^bb103, ^bb104
^bb103:
%623 = llvm.load %618 : !llvm.ptr -> i32
%624 = arith.extsi %623 : i32 to i64
%625 = llvm.getelementptr %arg2[%624] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%622 = llvm.load %625 : !llvm.ptr -> i64
%626 = llvm.load %101 : !llvm.ptr -> i64
%627 = arith.cmpi eq, %622, %626 : i64
%628 = scf.if %627 -> (i1) {
%630 = llvm.load %618 : !llvm.ptr -> i32
%631 = arith.extsi %630 : i32 to i64
%632 = llvm.getelementptr %arg3[%631] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%629 = llvm.load %632 : !llvm.ptr -> i64
%633 = llvm.load %105 : !llvm.ptr -> i64
%634 = arith.cmpi eq, %629, %633 : i64
scf.yield %634 : i1
} else {
%635 = arith.constant false
scf.yield %635 : i1
}
cf.cond_br %628, ^bb105, ^bb106
^bb105:
%636 = arith.constant 1 : i32
llvm.store %636, %615 : i32, !llvm.ptr
cf.br ^bb104
^bb106:
cf.br ^bb107
^bb107:
%637 = llvm.load %618 : !llvm.ptr -> i32
%638 = arith.constant 1 : i32
%639 = arith.addi %637, %638 : i32
llvm.store %639, %618 : i32, !llvm.ptr
cf.br ^bb102
^bb104:
%640 = llvm.load %615 : !llvm.ptr -> i32
%641 = arith.constant 0 : i32
%642 = arith.cmpi eq, %640, %641 : i32
%643 = scf.if %642 -> (i1) {
%644 = llvm.load %89 : !llvm.ptr -> i32
%645 = arith.cmpi slt, %644, %arg4 : i32
scf.yield %645 : i1
} else {
%646 = arith.constant false
scf.yield %646 : i1
}
cf.cond_br %643, ^bb108, ^bb109
^bb108:
%647 = llvm.load %101 : !llvm.ptr -> i64
%648 = llvm.load %89 : !llvm.ptr -> i32
%649 = arith.extsi %648 : i32 to i64
%650 = llvm.getelementptr %arg2[%649] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %647, %650 : i64, !llvm.ptr
%651 = llvm.load %105 : !llvm.ptr -> i64
%652 = llvm.load %89 : !llvm.ptr -> i32
%653 = arith.extsi %652 : i32 to i64
%654 = llvm.getelementptr %arg3[%653] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %651, %654 : i64, !llvm.ptr
%655 = llvm.load %89 : !llvm.ptr -> i32
%656 = arith.constant 1 : i32
%657 = arith.addi %655, %656 : i32
llvm.store %657, %89 : i32, !llvm.ptr
cf.br ^bb110
^bb109:
cf.br ^bb110
^bb110:
cf.br ^bb101
^bb100:
cf.br ^bb101
^bb101:
%658 = llvm.load %89 : !llvm.ptr -> i32
func.return %658 : i32
}
// Module static: g_tri_a
llvm.mlir.global internal @g_tri_a(0 : i64) : i64
// Module static: g_tri_b
llvm.mlir.global internal @g_tri_b(0 : i64) : i64
// Module static: g_tri_c
llvm.mlir.global internal @g_tri_c(0 : i64) : i64
func.func @triangle_from_mn(%arg0: i64, %arg1: i64) -> () {
%659 = arith.muli %arg0, %arg0 : i64
%660 = arith.muli %arg1, %arg1 : i64
%661 = arith.subi %659, %660 : i64
%662 = arith.constant 2 : i32
%664 = arith.extsi %662 : i32 to i64
%663 = arith.muli %664, %arg0 : i64
%665 = arith.muli %663, %arg1 : i64
%666 = arith.muli %arg0, %arg0 : i64
%667 = arith.muli %arg1, %arg1 : i64
%668 = arith.addi %666, %667 : i64
%669 = arith.addi %arg0, %arg1 : i64
%670 = arith.constant 2 : i32
%672 = arith.extsi %670 : i32 to i64
%671 = arith.remsi %669, %672 : i64
%673 = arith.constant 0 : i32
%675 = arith.extsi %673 : i32 to i64
%674 = arith.cmpi eq, %671, %675 : i64
cf.cond_br %674, ^bb111, ^bb112
^bb111:
%676 = arith.constant 2 : i32
%678 = arith.extsi %676 : i32 to i64
%677 = arith.divsi %661, %678 : i64
%679 = llvm.mlir.addressof @g_tri_a : !llvm.ptr
llvm.store %677, %679 : i64, !llvm.ptr
%680 = arith.constant 2 : i32
%682 = arith.extsi %680 : i32 to i64
%681 = arith.divsi %665, %682 : i64
%683 = llvm.mlir.addressof @g_tri_b : !llvm.ptr
llvm.store %681, %683 : i64, !llvm.ptr
%684 = arith.constant 2 : i32
%686 = arith.extsi %684 : i32 to i64
%685 = arith.divsi %668, %686 : i64
%687 = llvm.mlir.addressof @g_tri_c : !llvm.ptr
llvm.store %685, %687 : i64, !llvm.ptr
cf.br ^bb113
^bb112:
%688 = llvm.mlir.addressof @g_tri_a : !llvm.ptr
llvm.store %661, %688 : i64, !llvm.ptr
%689 = llvm.mlir.addressof @g_tri_b : !llvm.ptr
llvm.store %665, %689 : i64, !llvm.ptr
%690 = llvm.mlir.addressof @g_tri_c : !llvm.ptr
llvm.store %668, %690 : i64, !llvm.ptr
cf.br ^bb113
^bb113:
func.return
}
func.func @tan_theta_from_legs(%arg0: i64, %arg1: i64) -> f64 {
%691 = arith.sitofp %arg0 : i64 to f64
%692 = arith.sitofp %arg0 : i64 to f64
%693 = arith.mulf %691, %692 : f64
%694 = arith.sitofp %arg1 : i64 to f64
%695 = arith.sitofp %arg1 : i64 to f64
%696 = arith.mulf %694, %695 : f64
%697 = arith.constant 3.0 : f32
%698 = arith.sitofp %arg0 : i64 to f64
%700 = arith.extf %697 : f32 to f64
%699 = arith.mulf %700, %698 : f64
%701 = arith.sitofp %arg1 : i64 to f64
%702 = arith.mulf %699, %701 : f64
%703 = arith.constant 2.0 : f32
%704 = arith.addf %693, %696 : f64
%706 = arith.extf %703 : f32 to f64
%705 = arith.mulf %706, %704 : f64
%707 = arith.divf %702, %705 : f64
func.return %707 : f64
}
func.func @f_val(%arg0: f64, %arg1: i64) -> i64 {
%708 = llvm.mlir.addressof @DEG2RAD : !llvm.ptr
%709 = llvm.load %708 : !llvm.ptr -> f64
%710 = arith.mulf %arg0, %709 : f64
%711 = math.tan %710 : f64
%712 = func.call @root_left(%711) : (f64) -> f64
%713 = func.call @root_right(%711) : (f64) -> f64
%714 = arith.constant 1000000000000000052504760255204420248704468581108159154915854115511802457988908195786371375080447864043704443832883878176942523235360430575644792184786706982848387200926575803737830233794788090059368953234970799945081119038967640880074652742780142494579258788820056842838115669472196386865459400540160 : f32
%715 = arith.extf %714 : f32 to f64
%716 = llvm.mlir.constant(1 : i64) : i64
%717 = llvm.alloca %716 x f64 : (i64) -> !llvm.ptr
llvm.store %715, %717 : f64, !llvm.ptr
%718 = arith.constant 1.0 : f32
%719 = arith.negf %718 : f32
%720 = arith.extf %719 : f32 to f64
%721 = llvm.mlir.constant(1 : i64) : i64
%722 = llvm.alloca %721 x f64 : (i64) -> !llvm.ptr
llvm.store %720, %722 : f64, !llvm.ptr
%723 = arith.constant 0 : i32
%724 = arith.extsi %723 : i32 to i64
%725 = llvm.mlir.constant(1 : i64) : i64
%726 = llvm.alloca %725 x i64 : (i64) -> !llvm.ptr
llvm.store %724, %726 : i64, !llvm.ptr
%728 = arith.constant 200 : i32
%729 = arith.constant 8 : i32
%730 = arith.extsi %728 : i32 to i64
%731 = arith.extsi %729 : i32 to i64
%727 = func.call @calloc(%730, %731) : (i64, i64) -> !llvm.ptr
%733 = arith.constant 200 : i32
%734 = arith.constant 8 : i32
%735 = arith.extsi %733 : i32 to i64
%736 = arith.extsi %734 : i32 to i64
%732 = func.call @calloc(%735, %736) : (i64, i64) -> !llvm.ptr
%737 = arith.constant 0 : i32
%738 = arith.constant 2 : i32
%739 = arith.index_cast %737 : i32 to index
%740 = arith.index_cast %738 : i32 to index
%742 = arith.constant 1 : index
%743 = arith.constant -1 : index
%744 = arith.cmpi sle, %739, %740 : index
%741 = arith.select %744, %742, %743 : index
cf.br ^bb114(%739 : index)
^bb114(%745: index):
%746 = arith.cmpi slt, %745, %740 : index
%747 = arith.cmpi sgt, %745, %740 : index
%748 = arith.select %744, %746, %747 : i1
cf.cond_br %748, ^bb115(%745 : index), ^bb116(%745 : index)
^bb115(%749: index):
%750 = arith.constant 0 : i32
%752 = arith.index_cast %749 : index to i32
%751 = arith.cmpi eq, %752, %750 : i32
%753 = scf.if %751 -> (f64) {
scf.yield %712 : f64
} else {
scf.yield %713 : f64
}
%755 = arith.constant 200 : i32
%754 = func.call @cf_candidates_circle(%753, %arg1, %727, %732, %755) : (f64, i64, !llvm.ptr, !llvm.ptr, i32) -> i32
%756 = arith.constant 0 : i32
%757 = arith.index_cast %756 : i32 to index
%758 = arith.index_cast %754 : i32 to index
%760 = arith.constant 1 : index
%761 = arith.constant -1 : index
%762 = arith.cmpi sle, %757, %758 : index
%759 = arith.select %762, %760, %761 : index
cf.br ^bb117(%757 : index)
^bb117(%763: index):
%764 = arith.cmpi slt, %763, %758 : index
%765 = arith.cmpi sgt, %763, %758 : index
%766 = arith.select %762, %764, %765 : i1
cf.cond_br %766, ^bb118(%763 : index), ^bb119(%763 : index)
^bb118(%767: index):
%769 = arith.index_cast %767 : index to i64
%770 = llvm.getelementptr %727[%769] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%768 = llvm.load %770 : !llvm.ptr -> i64
%772 = arith.index_cast %767 : index to i64
%773 = llvm.getelementptr %732[%772] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%771 = llvm.load %773 : !llvm.ptr -> i64
%774 = arith.constant 0 : i32
%776 = arith.extsi %774 : i32 to i64
%775 = arith.cmpi sgt, %768, %776 : i64
%777 = scf.if %775 -> (i1) {
%778 = arith.cmpi slt, %768, %771 : i64
scf.yield %778 : i1
} else {
%779 = arith.constant false
scf.yield %779 : i1
}
cf.cond_br %777, ^bb120, ^bb121
^bb120:
func.call @triangle_from_mn(%771, %768) : (i64, i64) -> ()
%781 = llvm.mlir.addressof @g_tri_a : !llvm.ptr
%782 = llvm.load %781 : !llvm.ptr -> i64
%783 = llvm.mlir.addressof @g_tri_b : !llvm.ptr
%784 = llvm.load %783 : !llvm.ptr -> i64
%785 = llvm.mlir.addressof @g_tri_c : !llvm.ptr
%786 = llvm.load %785 : !llvm.ptr -> i64
%787 = arith.constant 0 : i32
%789 = arith.extsi %787 : i32 to i64
%788 = arith.cmpi sgt, %782, %789 : i64
%790 = scf.if %788 -> (i1) {
%791 = arith.constant 0 : i32
%793 = arith.extsi %791 : i32 to i64
%792 = arith.cmpi sgt, %784, %793 : i64
scf.yield %792 : i1
} else {
%794 = arith.constant false
scf.yield %794 : i1
}
cf.cond_br %790, ^bb123, ^bb124
^bb123:
%795 = arith.cmpi sle, %786, %arg1 : i64
cf.cond_br %795, ^bb126, ^bb127
^bb126:
%796 = arith.divsi %arg1, %786 : i64
%797 = arith.constant 0 : i32
%799 = arith.extsi %797 : i32 to i64
%798 = arith.cmpi sgt, %796, %799 : i64
cf.cond_br %798, ^bb129, ^bb130
^bb129:
%801 = func.call @tan_theta_from_legs(%782, %784) : (i64, i64) -> f64
%800 = func.call @atan(%801) : (f64) -> f64
%802 = arith.subf %800, %710 : f64
%803 = math.absf %802 : f64
%804 = arith.sitofp %796 : i64 to f64
%805 = arith.sitofp %796 : i64 to f64
%806 = arith.mulf %804, %805 : f64
%807 = arith.sitofp %782 : i64 to f64
%808 = arith.mulf %806, %807 : f64
%809 = arith.sitofp %784 : i64 to f64
%810 = arith.mulf %808, %809 : f64
%811 = arith.addi %782, %784 : i64
%812 = arith.addi %811, %786 : i64
%813 = arith.muli %796, %812 : i64
%814 = arith.constant 0 : f32
%816 = arith.extf %814 : f32 to f64
%815 = arith.addf %803, %816 : f64
%817 = llvm.load %717 : !llvm.ptr -> f64
%818 = arith.cmpf olt, %815, %817 : f64
cf.cond_br %818, ^bb132, ^bb133
^bb132:
llvm.store %803, %717 : f64, !llvm.ptr
llvm.store %810, %722 : f64, !llvm.ptr
llvm.store %813, %726 : i64, !llvm.ptr
cf.br ^bb134
^bb133:
%819 = llvm.load %717 : !llvm.ptr -> f64
%820 = arith.subf %803, %819 : f64
%821 = math.absf %820 : f64
%822 = arith.constant 0 : f32
%824 = arith.extf %822 : f32 to f64
%823 = arith.cmpf ole, %821, %824 : f64
cf.cond_br %823, ^bb135, ^bb136
^bb135:
%825 = llvm.load %722 : !llvm.ptr -> f64
%826 = arith.cmpf ogt, %810, %825 : f64
cf.cond_br %826, ^bb138, ^bb139
^bb138:
llvm.store %810, %722 : f64, !llvm.ptr
llvm.store %813, %726 : i64, !llvm.ptr
cf.br ^bb140
^bb139:
cf.br ^bb140
^bb140:
cf.br ^bb137
^bb136:
cf.br ^bb137
^bb137:
cf.br ^bb134
^bb134:
cf.br ^bb131
^bb130:
cf.br ^bb131
^bb131:
cf.br ^bb128
^bb127:
cf.br ^bb128
^bb128:
cf.br ^bb125
^bb124:
cf.br ^bb125
^bb125:
cf.br ^bb122
^bb121:
cf.br ^bb122
^bb122:
%827 = arith.addi %767, %759 : index
cf.br ^bb117(%827 : index)
^bb119(%828: index):
%829 = arith.addi %749, %741 : index
cf.br ^bb114(%829 : index)
^bb116(%830: index):
func.call @free(%727) : (!llvm.ptr) -> ()
func.call @free(%732) : (!llvm.ptr) -> ()
%833 = llvm.load %726 : !llvm.ptr -> i64
func.return %833 : i64
}
func.func @main() -> i32 {
%834 = arith.constant 45000 : i32
%835 = arith.extsi %834 : i32 to i64
%836 = arith.constant 5705032704 : i32
%837 = arith.extsi %836 : i32 to i64
%838 = arith.constant 0 : i32
%839 = arith.extsi %838 : i32 to i64
%840 = llvm.mlir.constant(1 : i64) : i64
%841 = llvm.alloca %840 x i64 : (i64) -> !llvm.ptr
llvm.store %839, %841 : i64, !llvm.ptr
%842 = arith.constant 1 : i32
%843 = arith.extsi %842 : i32 to i64
%844 = llvm.mlir.constant(1 : i64) : i64
%845 = llvm.alloca %844 x i64 : (i64) -> !llvm.ptr
llvm.store %843, %845 : i64, !llvm.ptr
cf.br ^bb141
^bb141:
%846 = llvm.load %845 : !llvm.ptr -> i64
%847 = arith.cmpi sle, %846, %835 : i64
cf.cond_br %847, ^bb142, ^bb143
^bb142:
%849 = llvm.load %845 : !llvm.ptr -> i64
%850 = arith.sitofp %849 : i64 to f64
%848 = func.call @cbrt(%850) : (f64) -> f64
%851 = llvm.load %841 : !llvm.ptr -> i64
%852 = func.call @f_val(%848, %837) : (f64, i64) -> i64
%853 = arith.addi %851, %852 : i64
llvm.store %853, %841 : i64, !llvm.ptr
%854 = llvm.load %845 : !llvm.ptr -> i64
%855 = arith.constant 1 : i32
%857 = arith.extsi %855 : i32 to i64
%856 = arith.addi %854, %857 : i64
llvm.store %856, %845 : i64, !llvm.ptr
cf.br ^bb141
^bb143:
%858 = llvm.mlir.addressof @str_0 : !llvm.ptr
%859 = llvm.load %841 : !llvm.ptr -> i64
%860 = llvm.call @printf(%858, %859) vararg(!llvm.func<i32 (ptr, ...)>) : (!llvm.ptr, i64) -> i32
%861 = arith.constant 0 : i32
func.return %861 : i32
}
}