← All problems
Problem 562
Maximal Perimeter — empty lattice triangles maximizing T(r) for r=10^7.
View problem on Project Euler
Performance comparison
Metric Our solution Best known
Time complexity O(n^2)O(n^2)
Space complexity O(n^2)O(n^2)
Approach Flow solution Combinatorial or DP counting
Verdict Optimal
Flow source
# Project Euler 562
# Maximal Perimeter — empty lattice triangles maximizing T(r) for r=10^7.
import euler.nt { isqrt }
extern {
function calloc(n: i64, size: i64) -> ptr<void>
function free(p: ptr<void>) -> void
function sqrt(x: f64) -> f64
function llround(x: f64) -> i64
}
function igcd(a0: i64, b0: i64) -> i64 {
let mut a: i64 = a0
let mut b: i64 = b0
if a < 0 { a = -a }
if b < 0 { b = -b }
while b != 0 {
let t: i64 = a % b
a = b
b = t
}
return a
}
function iabs(x: i64) -> i64 {
if x < 0 { return -x }
return x
}
function egcd(a0: i64, b0: i64, outx: ptr<i64>, outy: ptr<i64>) -> i64 {
let mut a: i64 = a0
let mut b: i64 = b0
let mut x0: i64 = 1
let mut y0: i64 = 0
let mut x1: i64 = 0
let mut y1: i64 = 1
while b != 0 {
let q: i64 = a / b
let na: i64 = b
b = a - q * b
a = na
let nx: i64 = x1
x1 = x0 - q * x1
x0 = nx
let ny: i64 = y1
y1 = y0 - q * y1
y0 = ny
}
outx[0] = x0
outy[0] = y0
return a
}
function ceil_div(a: i64, b: i64) -> i64 {
# Python: -((-a)//b) for b>0
return 0 - ((0 - a) / b)
}
function compute_T(r: i64) -> i64 {
let deficit_limit: i64 = 8000
let r2: i64 = r * r
let cap: i64 = 200000
let xs: ptr<i64> = calloc(cap, 8)
let ys: ptr<i64> = calloc(cap, 8)
let mut m: i64 = 0
let mut x: i64 = r
let mut x2: i64 = x * x
let mut y2: i64 = 0
let mut y: i64 = 0
while y <= r {
while x2 + y2 > r2 {
x = x - 1
x2 = x * x
}
let deficit: i64 = r2 - x2 - y2
if deficit <= deficit_limit {
xs[m] = x
ys[m] = y
m = m + 1
}
y2 = y2 + 2 * y + 1
y = y + 1
}
let mut best_u2: i64 = -1
let cand_cap: i64 = 10000
let ci: ptr<i64> = calloc(cand_cap, 8)
let cj: ptr<i64> = calloc(cand_cap, 8)
let cux: ptr<i64> = calloc(cand_cap, 8)
let cuy: ptr<i64> = calloc(cand_cap, 8)
let mut nc: i64 = 0
let mut i: i64 = 0
while i < m {
let xi: i64 = xs[i]
let yi: i64 = ys[i]
let mut j: i64 = i + 1
while j < m {
let ux: i64 = xi + xs[j]
let uy: i64 = yi + ys[j]
let u2: i64 = ux * ux + uy * uy
if u2 >= best_u2 {
if ((ux | uy) & 1) != 0 {
if igcd(ux, uy) == 1 {
if u2 > best_u2 {
best_u2 = u2
nc = 0
}
ci[nc] = i
cj[nc] = j
cux[nc] = ux
cuy[nc] = uy
nc = nc + 1
}
}
}
j = j + 1
}
i = i + 1
}
let mut best_s1: i64 = 0
let mut best_s2: i64 = 0
let mut best_s3: i64 = 0
let mut best_per: f64 = -1.0
let eg: ptr<i64> = calloc(2, 8)
let mut c: i64 = 0
while c < nc {
let ux: i64 = cux[c]
let uy: i64 = cuy[c]
let ii: i64 = ci[c]
let jj: i64 = cj[c]
let mut pass: i64 = 0
while pass < 2 {
let mut ax: i64 = -xs[ii]
let mut ay: i64 = -ys[ii]
if pass == 1 {
ax = -xs[jj]
ay = -ys[jj]
}
let bx: i64 = ax + ux
let by: i64 = ay + uy
if ax * ax + ay * ay <= r2 && bx * bx + by * by <= r2 {
let s1: i64 = ux * ux + uy * uy
egcd(iabs(ux), iabs(uy), eg, eg + 1)
let mut s: i64 = eg[0]
let mut t: i64 = eg[1]
if ux < 0 { s = -s }
if uy < 0 { t = -t }
let v0x: i64 = -t
let v0y: i64 = s
let mut sign: i64 = 1
let mut si: i64 = 0
while si < 2 {
let bvx: i64 = sign * v0x
let bvy: i64 = sign * v0y
let p0x: i64 = ax + bvx
let p0y: i64 = ay + bvy
let pu: i128 = (p0x as i128) * (ux as i128) + (p0y as i128) * (uy as i128)
let pp: i128 = (p0x as i128) * (p0x as i128) + (p0y as i128) * (p0y as i128)
let uu: i128 = s1 as i128
let disc: i128 = pu * pu - uu * (pp - (r2 as i128))
if disc >= 0 {
# isqrt for i128
let mut rx: i128 = disc
let mut ry: i128 = (rx + 1) / 2
while ry < rx {
rx = ry
ry = (rx + disc / rx) / 2
}
let root: i128 = rx
# k_lo = ceil((-pu-root)/uu), k_hi = floor((-pu+root)/uu)
let mut num_lo: i128 = 0 - pu - root
let mut k_lo: i64 = 0
if num_lo >= 0 {
k_lo = ((num_lo + uu - 1) / uu) as i64
} else {
k_lo = (num_lo / uu) as i64
}
let k_hi: i64 = ((0 - pu + root) / uu) as i64
let mut k: i64 = k_lo
while k <= k_hi {
let vx: i64 = bvx + k * ux
let vy: i64 = bvy + k * uy
let cx: i128 = (ax as i128) + (vx as i128)
let cy: i128 = (ay as i128) + (vy as i128)
if cx * cx + cy * cy <= (r2 as i128) {
let s2: i64 = vx * vx + vy * vy
let wx: i64 = ux - vx
let wy: i64 = uy - vy
let s3: i64 = wx * wx + wy * wy
let per: f64 = sqrt(s1 as f64) + sqrt(s2 as f64) + sqrt(s3 as f64)
if per > best_per {
best_per = per
best_s1 = s1
best_s2 = s2
best_s3 = s3
}
}
k = k + 1
}
}
sign = -1
si = si + 1
}
}
pass = pass + 1
}
c = c + 1
}
let tv: f64 = sqrt(best_s1 as f64) * sqrt(best_s2 as f64) * sqrt(best_s3 as f64) / (2.0 * (r as f64))
let ans: i64 = llround(tv)
free(xs); free(ys); free(ci); free(cj); free(cux); free(cuy); free(eg)
return ans
}
function main() -> i32 {
printf("%lld\n", compute_T(10000000))
return 0
}
Generated C
#include <stdint.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/* Flow runtime helpers */
typedef struct flow_temp_node { struct flow_temp_node* next; } flow_temp_node;
static flow_temp_node* flow_temp_head = NULL;
static int flow_temp_atexit_set = 0;
__attribute__((unused)) static void flow_temp_free_all(void) {
while (flow_temp_head) {
flow_temp_node* n = flow_temp_head;
flow_temp_head = n->next;
free(n);
}
}
__attribute__((unused)) static void* flow_temp_alloc(size_t nbytes) {
flow_temp_node* node = (flow_temp_node*)malloc(sizeof(flow_temp_node) + nbytes);
if (!node) return NULL;
node->next = flow_temp_head;
flow_temp_head = node;
if (!flow_temp_atexit_set) {
flow_temp_atexit_set = 1;
atexit(flow_temp_free_all);
}
return (void*)(node + 1);
}
#ifndef FLOW_DIAG
#define FLOW_DIAG(msg) fprintf(stderr, "%s", (msg))
#endif
#ifndef FLOW_LOG
#define FLOW_LOG(fmt, ...) printf(fmt, __VA_ARGS__)
#endif
#ifndef FLOW_LOG_EMPTY
#define FLOW_LOG_EMPTY(fmt) printf(fmt)
#endif
static char* flow_strcat(const char* a, const char* b) {
size_t la = strlen(a ? a : ""), lb = strlen(b ? b : "");
char* r = (char*)flow_temp_alloc(la + lb + 1);
if (!r) return NULL;
if (la) memcpy(r, a, la);
if (lb) memcpy(r + la, b, lb);
r[la + lb] = '\0';
return r;
}
#define __flow_in_arr(arr, val) __extension__ ({ \
int _found = 0; \
size_t _n = sizeof(arr)/sizeof((arr)[0]); \
for (size_t _i = 0; _i < _n; _i++) { \
if ((arr)[_i] == (val)) { _found = 1; break; } \
} _found; })
/* Unified fault handler (MISRA #279) — override with -DFLOW_FAULT_HANDLER=fn */
#ifndef FLOW_FAULT_HANDLER
__attribute__((unused)) static inline void flow_fault_handler(const char* msg) {
fprintf(stderr, "flow: %s\n", msg ? msg : "fault");
abort();
#if defined(__GNUC__) || defined(__clang__)
__builtin_unreachable();
#endif
}
#else
#define flow_fault_handler FLOW_FAULT_HANDLER
#endif
#define flow_div_by_zero_handler() flow_fault_handler("division by zero")
#define flow_shift_ub_handler() flow_fault_handler("invalid shift (amount out of range or left-shift of negative)")
#ifndef FLOW_CHECKED_DIV
#define FLOW_CHECKED_DIV(L, R) (((R) != 0) ? ((L) / (R)) : (flow_div_by_zero_handler(), (L) * 0))
#endif
#ifndef FLOW_CHECKED_MOD
#define FLOW_CHECKED_MOD(L, R) (((R) != 0) ? ((L) % (R)) : (flow_div_by_zero_handler(), (L) * 0))
#endif
#ifndef FLOW_CHECKED_SHL
#define FLOW_CHECKED_SHL(L, R) ((((R) >= 0) && ((unsigned long long)(R) < (sizeof(L) * 8ull)) && ((L) >= 0)) ? ((L) << (R)) : (flow_shift_ub_handler(), (L) * 0))
#endif
#ifndef FLOW_CHECKED_SHR
#define FLOW_CHECKED_SHR(L, R) ((((R) >= 0) && ((unsigned long long)(R) < (sizeof(L) * 8ull))) ? ((L) >> (R)) : (flow_shift_ub_handler(), (L) * 0))
#endif
#include <math.h>
void* _ui_state = NULL;
static inline float i32_to_f32(int32_t v) { return (float)v; }
/* Host stub for @gpu kernels (device codegen replaces this). */
static inline int32_t gpu_thread_id(void) { return 0; }
int64_t gcd_i64_i64(int64_t a0, int64_t b0);
int64_t lcm_i64_i64(int64_t a, int64_t b);
int64_t isqrt_i64(int64_t n);
int64_t mulmod_i64_i64_i64(int64_t a0, int64_t b0, int64_t mod);
int64_t mod_pow_i64_i64_i64(int64_t base, int64_t exp, int64_t mod);
bool is_prime_i64(int64_t n);
int64_t llround(double x);
int64_t igcd_i64_i64(int64_t a0, int64_t b0);
int64_t iabs_i64(int64_t x);
int64_t egcd_i64_i64_ptr_i64_ptr_i64(int64_t a0, int64_t b0, int64_t* outx, int64_t* outy);
int64_t ceil_div_i64_i64(int64_t a, int64_t b);
int64_t compute_T_i64(int64_t r);
int32_t main(void);
int64_t gcd_i64_i64(int64_t a0, int64_t b0) {
int64_t a = a0;
int64_t b = b0;
while (b != 0) {
int64_t t = FLOW_CHECKED_MOD((a), (b));
a = b;
b = t;
}
return a;
}
int64_t lcm_i64_i64(int64_t a, int64_t b) {
if ((a == 0 || b == 0)) {
return 0;
}
return (FLOW_CHECKED_DIV((a), (gcd_i64_i64(a, b))) * b);
}
int64_t isqrt_i64(int64_t n) {
if (n < 2) {
return n;
}
int64_t x = n;
int64_t y = FLOW_CHECKED_DIV(((x + 1)), (2));
while (y < x) {
x = y;
y = FLOW_CHECKED_DIV(((x + FLOW_CHECKED_DIV((n), (x)))), (2));
}
return x;
}
int64_t mulmod_i64_i64_i64(int64_t a0, int64_t b0, int64_t mod) {
int64_t a = FLOW_CHECKED_MOD((a0), (mod));
int64_t b = FLOW_CHECKED_MOD((b0), (mod));
int64_t result = 0;
while (b > 0) {
if (FLOW_CHECKED_MOD((b), (2)) == 1) {
result = FLOW_CHECKED_MOD(((result + a)), (mod));
}
a = FLOW_CHECKED_MOD(((a * 2)), (mod));
b = FLOW_CHECKED_DIV((b), (2));
}
return result;
}
int64_t mod_pow_i64_i64_i64(int64_t base, int64_t exp, int64_t mod) {
if (mod == 1) {
return 0;
}
int64_t result = 1;
int64_t b = FLOW_CHECKED_MOD((base), (mod));
int64_t e = exp;
while (e > 0) {
if (FLOW_CHECKED_MOD((e), (2)) == 1) {
result = mulmod_i64_i64_i64(result, b, mod);
}
b = mulmod_i64_i64_i64(b, b, mod);
e = FLOW_CHECKED_DIV((e), (2));
}
return result;
}
bool is_prime_i64(int64_t n) {
if (n < 2) {
return 0;
}
if (n < 4) {
return 1;
}
if ((FLOW_CHECKED_MOD((n), (2)) == 0 || FLOW_CHECKED_MOD((n), (3)) == 0)) {
return 0;
}
int64_t i = 5;
while ((i * i) <= n) {
if ((FLOW_CHECKED_MOD((n), (i)) == 0 || FLOW_CHECKED_MOD((n), ((i + 2))) == 0)) {
return 0;
}
i = (i + 6);
}
return 1;
}
int64_t igcd_i64_i64(int64_t a0, int64_t b0) {
int64_t a = a0;
int64_t b = b0;
if (a < 0) {
a = (-a);
}
if (b < 0) {
b = (-b);
}
while (b != 0) {
int64_t t = FLOW_CHECKED_MOD((a), (b));
a = b;
b = t;
}
return a;
}
int64_t iabs_i64(int64_t x) {
if (x < 0) {
return (-x);
}
return x;
}
int64_t egcd_i64_i64_ptr_i64_ptr_i64(int64_t a0, int64_t b0, int64_t* outx, int64_t* outy) {
int64_t a = a0;
int64_t b = b0;
int64_t x0 = 1;
int64_t y0 = 0;
int64_t x1 = 0;
int64_t y1 = 1;
while (b != 0) {
int64_t q = FLOW_CHECKED_DIV((a), (b));
int64_t na = b;
b = (a - (q * b));
a = na;
int64_t nx = x1;
x1 = (x0 - (q * x1));
x0 = nx;
int64_t ny = y1;
y1 = (y0 - (q * y1));
y0 = ny;
}
outx[0] = x0;
outy[0] = y0;
return a;
}
int64_t ceil_div_i64_i64(int64_t a, int64_t b) {
return (0 - FLOW_CHECKED_DIV(((0 - a)), (b)));
}
int64_t compute_T_i64(int64_t r) {
int64_t deficit_limit = 8000;
int64_t r2 = (r * r);
int64_t cap = 200000;
int64_t* xs = (int64_t*)(calloc(cap, 8));
int64_t* ys = (int64_t*)(calloc(cap, 8));
int64_t m = 0;
int64_t x = r;
int64_t x2 = (x * x);
int64_t y2 = 0;
int64_t y = 0;
while (y <= r) {
while ((x2 + y2) > r2) {
x = (x - 1);
x2 = (x * x);
}
int64_t deficit = ((r2 - x2) - y2);
if (deficit <= deficit_limit) {
xs[m] = x;
ys[m] = y;
m = (m + 1);
}
y2 = ((y2 + (2 * y)) + 1);
y = (y + 1);
}
int64_t best_u2 = (-1);
int64_t cand_cap = 10000;
int64_t* ci = (int64_t*)(calloc(cand_cap, 8));
int64_t* cj = (int64_t*)(calloc(cand_cap, 8));
int64_t* cux = (int64_t*)(calloc(cand_cap, 8));
int64_t* cuy = (int64_t*)(calloc(cand_cap, 8));
int64_t nc = 0;
int64_t i = 0;
while (i < m) {
int64_t xi = xs[i];
int64_t yi = ys[i];
int64_t j = (i + 1);
while (j < m) {
int64_t ux = (xi + xs[j]);
int64_t uy = (yi + ys[j]);
int64_t u2 = ((ux * ux) + (uy * uy));
if (u2 >= best_u2) {
if (((ux | uy) & 1) != 0) {
if (igcd_i64_i64(ux, uy) == 1) {
if (u2 > best_u2) {
best_u2 = u2;
nc = 0;
}
ci[nc] = i;
cj[nc] = j;
cux[nc] = ux;
cuy[nc] = uy;
nc = (nc + 1);
}
}
}
j = (j + 1);
}
i = (i + 1);
}
int64_t best_s1 = 0;
int64_t best_s2 = 0;
int64_t best_s3 = 0;
double best_per = (-1.0);
int64_t* eg = (int64_t*)(calloc(2, 8));
int64_t c = 0;
while (c < nc) {
int64_t ux = cux[c];
int64_t uy = cuy[c];
int64_t ii = ci[c];
int64_t jj = cj[c];
int64_t pass = 0;
while (pass < 2) {
int64_t ax = (-xs[ii]);
int64_t ay = (-ys[ii]);
if (pass == 1) {
ax = (-xs[jj]);
ay = (-ys[jj]);
}
int64_t bx = (ax + ux);
int64_t by = (ay + uy);
if ((((ax * ax) + (ay * ay)) <= r2 && ((bx * bx) + (by * by)) <= r2)) {
int64_t s1 = ((ux * ux) + (uy * uy));
egcd_i64_i64_ptr_i64_ptr_i64(iabs_i64(ux), iabs_i64(uy), eg, (eg + 1));
int64_t s = eg[0];
int64_t t = eg[1];
if (ux < 0) {
s = (-s);
}
if (uy < 0) {
t = (-t);
}
int64_t v0x = (-t);
int64_t v0y = s;
int64_t sign = 1;
int64_t si = 0;
while (si < 2) {
int64_t bvx = (sign * v0x);
int64_t bvy = (sign * v0y);
int64_t p0x = (ax + bvx);
int64_t p0y = (ay + bvy);
__int128 pu = ((((__int128)(p0x)) * ((__int128)(ux))) + (((__int128)(p0y)) * ((__int128)(uy))));
__int128 pp = ((((__int128)(p0x)) * ((__int128)(p0x))) + (((__int128)(p0y)) * ((__int128)(p0y))));
__int128 uu = ((__int128)(s1));
__int128 disc = ((pu * pu) - (uu * (pp - ((__int128)(r2)))));
if (disc >= 0) {
__int128 rx = disc;
__int128 ry = FLOW_CHECKED_DIV(((rx + 1)), (2));
while (ry < rx) {
rx = ry;
ry = FLOW_CHECKED_DIV(((rx + FLOW_CHECKED_DIV((disc), (rx)))), (2));
}
__int128 root = rx;
__int128 num_lo = ((0 - pu) - root);
int64_t k_lo = 0;
if (num_lo >= 0) {
k_lo = ((int64_t)(FLOW_CHECKED_DIV((((num_lo + uu) - 1)), (uu))));
} else {
k_lo = ((int64_t)(FLOW_CHECKED_DIV((num_lo), (uu))));
}
int64_t k_hi = ((int64_t)(FLOW_CHECKED_DIV((((0 - pu) + root)), (uu))));
int64_t k = k_lo;
while (k <= k_hi) {
int64_t vx = (bvx + (k * ux));
int64_t vy = (bvy + (k * uy));
__int128 cx = (((__int128)(ax)) + ((__int128)(vx)));
__int128 cy = (((__int128)(ay)) + ((__int128)(vy)));
if (((cx * cx) + (cy * cy)) <= ((__int128)(r2))) {
int64_t s2 = ((vx * vx) + (vy * vy));
int64_t wx = (ux - vx);
int64_t wy = (uy - vy);
int64_t s3 = ((wx * wx) + (wy * wy));
double per = ((sqrt(((double)(s1))) + sqrt(((double)(s2)))) + sqrt(((double)(s3))));
if (per > best_per) {
best_per = per;
best_s1 = s1;
best_s2 = s2;
best_s3 = s3;
}
}
k = (k + 1);
}
}
sign = (-1);
si = (si + 1);
}
}
pass = (pass + 1);
}
c = (c + 1);
}
double tv = (((sqrt(((double)(best_s1))) * sqrt(((double)(best_s2)))) * sqrt(((double)(best_s3)))) / (2.0 * ((double)(r))));
int64_t ans = llround(tv);
free(xs);
free(ys);
free(ci);
free(cj);
free(cux);
free(cuy);
free(eg);
return ans;
}
int32_t main(void) {
printf("%lld\n", compute_T_i64(10000000));
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 @gcd(%arg0: i64, %arg1: i64) -> i64 {
%0 = llvm.mlir.constant(1 : i64) : i64
%1 = llvm.alloca %0 x i64 : (i64) -> !llvm.ptr
llvm.store %arg0, %1 : i64, !llvm.ptr
%2 = llvm.mlir.constant(1 : i64) : i64
%3 = llvm.alloca %2 x i64 : (i64) -> !llvm.ptr
llvm.store %arg1, %3 : i64, !llvm.ptr
cf.br ^bb0
^bb0:
%4 = llvm.load %3 : !llvm.ptr -> i64
%5 = arith.constant 0 : i32
%7 = arith.extsi %5 : i32 to i64
%6 = arith.cmpi ne, %4, %7 : i64
cf.cond_br %6, ^bb1, ^bb2
^bb1:
%8 = llvm.load %1 : !llvm.ptr -> i64
%9 = llvm.load %3 : !llvm.ptr -> i64
%10 = arith.remsi %8, %9 : i64
%11 = llvm.load %3 : !llvm.ptr -> i64
llvm.store %11, %1 : i64, !llvm.ptr
llvm.store %10, %3 : i64, !llvm.ptr
cf.br ^bb0
^bb2:
%12 = llvm.load %1 : !llvm.ptr -> i64
func.return %12 : i64
}
func.func @lcm(%arg0: i64, %arg1: i64) -> i64 {
%13 = arith.constant 0 : i32
%15 = arith.extsi %13 : i32 to i64
%14 = arith.cmpi eq, %arg0, %15 : i64
%16 = scf.if %14 -> (i1) {
%17 = arith.constant true
scf.yield %17 : i1
} else {
%18 = arith.constant 0 : i32
%20 = arith.extsi %18 : i32 to i64
%19 = arith.cmpi eq, %arg1, %20 : i64
scf.yield %19 : i1
}
cf.cond_br %16, ^bb3, ^bb4
^bb3:
%21 = arith.constant 0 : i32
%22 = arith.extsi %21 : i32 to i64
func.return %22 : i64
^bb4:
cf.br ^bb5
^bb5:
%23 = func.call @gcd(%arg0, %arg1) : (i64, i64) -> i64
%24 = arith.divsi %arg0, %23 : i64
%25 = arith.muli %24, %arg1 : i64
func.return %25 : i64
}
func.func @isqrt(%arg0: i64) -> i64 {
%26 = arith.constant 2 : i32
%28 = arith.extsi %26 : i32 to i64
%27 = arith.cmpi slt, %arg0, %28 : i64
cf.cond_br %27, ^bb6, ^bb7
^bb6:
func.return %arg0 : i64
^bb7:
cf.br ^bb8
^bb8:
%29 = llvm.mlir.constant(1 : i64) : i64
%30 = llvm.alloca %29 x i64 : (i64) -> !llvm.ptr
llvm.store %arg0, %30 : i64, !llvm.ptr
%31 = llvm.load %30 : !llvm.ptr -> i64
%32 = arith.constant 1 : i32
%34 = arith.extsi %32 : i32 to i64
%33 = arith.addi %31, %34 : i64
%35 = arith.constant 2 : i32
%37 = arith.extsi %35 : i32 to i64
%36 = arith.divsi %33, %37 : i64
%38 = llvm.mlir.constant(1 : i64) : i64
%39 = llvm.alloca %38 x i64 : (i64) -> !llvm.ptr
llvm.store %36, %39 : i64, !llvm.ptr
cf.br ^bb9
^bb9:
%40 = llvm.load %39 : !llvm.ptr -> i64
%41 = llvm.load %30 : !llvm.ptr -> i64
%42 = arith.cmpi slt, %40, %41 : i64
cf.cond_br %42, ^bb10, ^bb11
^bb10:
%43 = llvm.load %39 : !llvm.ptr -> i64
llvm.store %43, %30 : i64, !llvm.ptr
%44 = llvm.load %30 : !llvm.ptr -> i64
%45 = llvm.load %30 : !llvm.ptr -> i64
%46 = arith.divsi %arg0, %45 : i64
%47 = arith.addi %44, %46 : i64
%48 = arith.constant 2 : i32
%50 = arith.extsi %48 : i32 to i64
%49 = arith.divsi %47, %50 : i64
llvm.store %49, %39 : i64, !llvm.ptr
cf.br ^bb9
^bb11:
%51 = llvm.load %30 : !llvm.ptr -> i64
func.return %51 : i64
}
func.func @mulmod(%arg0: i64, %arg1: i64, %arg2: i64) -> i64 {
%52 = arith.remsi %arg0, %arg2 : i64
%53 = llvm.mlir.constant(1 : i64) : i64
%54 = llvm.alloca %53 x i64 : (i64) -> !llvm.ptr
llvm.store %52, %54 : i64, !llvm.ptr
%55 = arith.remsi %arg1, %arg2 : i64
%56 = llvm.mlir.constant(1 : i64) : i64
%57 = llvm.alloca %56 x i64 : (i64) -> !llvm.ptr
llvm.store %55, %57 : i64, !llvm.ptr
%58 = arith.constant 0 : i32
%59 = arith.extsi %58 : i32 to i64
%60 = llvm.mlir.constant(1 : i64) : i64
%61 = llvm.alloca %60 x i64 : (i64) -> !llvm.ptr
llvm.store %59, %61 : i64, !llvm.ptr
cf.br ^bb12
^bb12:
%62 = llvm.load %57 : !llvm.ptr -> i64
%63 = arith.constant 0 : i32
%65 = arith.extsi %63 : i32 to i64
%64 = arith.cmpi sgt, %62, %65 : i64
cf.cond_br %64, ^bb13, ^bb14
^bb13:
%66 = llvm.load %57 : !llvm.ptr -> i64
%67 = arith.constant 2 : i32
%69 = arith.extsi %67 : i32 to i64
%68 = arith.remsi %66, %69 : i64
%70 = arith.constant 1 : i32
%72 = arith.extsi %70 : i32 to i64
%71 = arith.cmpi eq, %68, %72 : i64
cf.cond_br %71, ^bb15, ^bb16
^bb15:
%73 = llvm.load %61 : !llvm.ptr -> i64
%74 = llvm.load %54 : !llvm.ptr -> i64
%75 = arith.addi %73, %74 : i64
%76 = arith.remsi %75, %arg2 : i64
llvm.store %76, %61 : i64, !llvm.ptr
cf.br ^bb17
^bb16:
cf.br ^bb17
^bb17:
%77 = llvm.load %54 : !llvm.ptr -> i64
%78 = arith.constant 2 : i32
%80 = arith.extsi %78 : i32 to i64
%79 = arith.muli %77, %80 : i64
%81 = arith.remsi %79, %arg2 : i64
llvm.store %81, %54 : i64, !llvm.ptr
%82 = llvm.load %57 : !llvm.ptr -> i64
%83 = arith.constant 2 : i32
%85 = arith.extsi %83 : i32 to i64
%84 = arith.divsi %82, %85 : i64
llvm.store %84, %57 : i64, !llvm.ptr
cf.br ^bb12
^bb14:
%86 = llvm.load %61 : !llvm.ptr -> i64
func.return %86 : i64
}
func.func @mod_pow(%arg0: i64, %arg1: i64, %arg2: i64) -> i64 {
%87 = arith.constant 1 : i32
%89 = arith.extsi %87 : i32 to i64
%88 = arith.cmpi eq, %arg2, %89 : i64
cf.cond_br %88, ^bb18, ^bb19
^bb18:
%90 = arith.constant 0 : i32
%91 = arith.extsi %90 : i32 to i64
func.return %91 : i64
^bb19:
cf.br ^bb20
^bb20:
%92 = arith.constant 1 : i32
%93 = arith.extsi %92 : i32 to i64
%94 = llvm.mlir.constant(1 : i64) : i64
%95 = llvm.alloca %94 x i64 : (i64) -> !llvm.ptr
llvm.store %93, %95 : i64, !llvm.ptr
%96 = arith.remsi %arg0, %arg2 : i64
%97 = llvm.mlir.constant(1 : i64) : i64
%98 = llvm.alloca %97 x i64 : (i64) -> !llvm.ptr
llvm.store %96, %98 : i64, !llvm.ptr
%99 = llvm.mlir.constant(1 : i64) : i64
%100 = llvm.alloca %99 x i64 : (i64) -> !llvm.ptr
llvm.store %arg1, %100 : i64, !llvm.ptr
cf.br ^bb21
^bb21:
%101 = llvm.load %100 : !llvm.ptr -> i64
%102 = arith.constant 0 : i32
%104 = arith.extsi %102 : i32 to i64
%103 = arith.cmpi sgt, %101, %104 : i64
cf.cond_br %103, ^bb22, ^bb23
^bb22:
%105 = llvm.load %100 : !llvm.ptr -> i64
%106 = arith.constant 2 : i32
%108 = arith.extsi %106 : i32 to i64
%107 = arith.remsi %105, %108 : i64
%109 = arith.constant 1 : i32
%111 = arith.extsi %109 : i32 to i64
%110 = arith.cmpi eq, %107, %111 : i64
cf.cond_br %110, ^bb24, ^bb25
^bb24:
%113 = llvm.load %95 : !llvm.ptr -> i64
%114 = llvm.load %98 : !llvm.ptr -> i64
%112 = func.call @mulmod(%113, %114, %arg2) : (i64, i64, i64) -> i64
llvm.store %112, %95 : i64, !llvm.ptr
cf.br ^bb26
^bb25:
cf.br ^bb26
^bb26:
%116 = llvm.load %98 : !llvm.ptr -> i64
%117 = llvm.load %98 : !llvm.ptr -> i64
%115 = func.call @mulmod(%116, %117, %arg2) : (i64, i64, i64) -> i64
llvm.store %115, %98 : i64, !llvm.ptr
%118 = llvm.load %100 : !llvm.ptr -> i64
%119 = arith.constant 2 : i32
%121 = arith.extsi %119 : i32 to i64
%120 = arith.divsi %118, %121 : i64
llvm.store %120, %100 : i64, !llvm.ptr
cf.br ^bb21
^bb23:
%122 = llvm.load %95 : !llvm.ptr -> i64
func.return %122 : i64
}
func.func @is_prime(%arg0: i64) -> i1 {
%123 = arith.constant 2 : i32
%125 = arith.extsi %123 : i32 to i64
%124 = arith.cmpi slt, %arg0, %125 : i64
cf.cond_br %124, ^bb27, ^bb28
^bb27:
%126 = arith.constant 0 : i1
func.return %126 : i1
^bb28:
cf.br ^bb29
^bb29:
%127 = arith.constant 4 : i32
%129 = arith.extsi %127 : i32 to i64
%128 = arith.cmpi slt, %arg0, %129 : i64
cf.cond_br %128, ^bb30, ^bb31
^bb30:
%130 = arith.constant 1 : i1
func.return %130 : i1
^bb31:
cf.br ^bb32
^bb32:
%131 = arith.constant 2 : i32
%133 = arith.extsi %131 : i32 to i64
%132 = arith.remsi %arg0, %133 : i64
%134 = arith.constant 0 : i32
%136 = arith.extsi %134 : i32 to i64
%135 = arith.cmpi eq, %132, %136 : i64
%137 = scf.if %135 -> (i1) {
%138 = arith.constant true
scf.yield %138 : i1
} else {
%139 = arith.constant 3 : i32
%141 = arith.extsi %139 : i32 to i64
%140 = arith.remsi %arg0, %141 : i64
%142 = arith.constant 0 : i32
%144 = arith.extsi %142 : i32 to i64
%143 = arith.cmpi eq, %140, %144 : i64
scf.yield %143 : i1
}
cf.cond_br %137, ^bb33, ^bb34
^bb33:
%145 = arith.constant 0 : i1
func.return %145 : i1
^bb34:
cf.br ^bb35
^bb35:
%146 = arith.constant 5 : i32
%147 = arith.extsi %146 : i32 to i64
%148 = llvm.mlir.constant(1 : i64) : i64
%149 = llvm.alloca %148 x i64 : (i64) -> !llvm.ptr
llvm.store %147, %149 : i64, !llvm.ptr
cf.br ^bb36
^bb36:
%150 = llvm.load %149 : !llvm.ptr -> i64
%151 = llvm.load %149 : !llvm.ptr -> i64
%152 = arith.muli %150, %151 : i64
%153 = arith.cmpi sle, %152, %arg0 : i64
cf.cond_br %153, ^bb37, ^bb38
^bb37:
%154 = llvm.load %149 : !llvm.ptr -> i64
%155 = arith.remsi %arg0, %154 : i64
%156 = arith.constant 0 : i32
%158 = arith.extsi %156 : i32 to i64
%157 = arith.cmpi eq, %155, %158 : i64
%159 = scf.if %157 -> (i1) {
%160 = arith.constant true
scf.yield %160 : i1
} else {
%161 = llvm.load %149 : !llvm.ptr -> i64
%162 = arith.constant 2 : i32
%164 = arith.extsi %162 : i32 to i64
%163 = arith.addi %161, %164 : i64
%165 = arith.remsi %arg0, %163 : i64
%166 = arith.constant 0 : i32
%168 = arith.extsi %166 : i32 to i64
%167 = arith.cmpi eq, %165, %168 : i64
scf.yield %167 : i1
}
cf.cond_br %159, ^bb39, ^bb40
^bb39:
%169 = arith.constant 0 : i1
func.return %169 : i1
^bb40:
cf.br ^bb41
^bb41:
%170 = llvm.load %149 : !llvm.ptr -> i64
%171 = arith.constant 6 : i32
%173 = arith.extsi %171 : i32 to i64
%172 = arith.addi %170, %173 : i64
llvm.store %172, %149 : i64, !llvm.ptr
cf.br ^bb36
^bb38:
%174 = arith.constant 1 : i1
func.return %174 : i1
}
func.func private @calloc(i64, i64) -> !llvm.ptr
func.func private @free(!llvm.ptr) -> ()
func.func private @sqrt(f64) -> f64
func.func private @llround(f64) -> i64
func.func @igcd(%arg0: i64, %arg1: i64) -> i64 {
%175 = llvm.mlir.constant(1 : i64) : i64
%176 = llvm.alloca %175 x i64 : (i64) -> !llvm.ptr
llvm.store %arg0, %176 : i64, !llvm.ptr
%177 = llvm.mlir.constant(1 : i64) : i64
%178 = llvm.alloca %177 x i64 : (i64) -> !llvm.ptr
llvm.store %arg1, %178 : i64, !llvm.ptr
%179 = llvm.load %176 : !llvm.ptr -> i64
%180 = arith.constant 0 : i32
%182 = arith.extsi %180 : i32 to i64
%181 = arith.cmpi slt, %179, %182 : i64
cf.cond_br %181, ^bb42, ^bb43
^bb42:
%183 = llvm.load %176 : !llvm.ptr -> i64
%185 = arith.constant 0 : i64
%184 = arith.subi %185, %183 : i64
llvm.store %184, %176 : i64, !llvm.ptr
cf.br ^bb44
^bb43:
cf.br ^bb44
^bb44:
%186 = llvm.load %178 : !llvm.ptr -> i64
%187 = arith.constant 0 : i32
%189 = arith.extsi %187 : i32 to i64
%188 = arith.cmpi slt, %186, %189 : i64
cf.cond_br %188, ^bb45, ^bb46
^bb45:
%190 = llvm.load %178 : !llvm.ptr -> i64
%192 = arith.constant 0 : i64
%191 = arith.subi %192, %190 : i64
llvm.store %191, %178 : i64, !llvm.ptr
cf.br ^bb47
^bb46:
cf.br ^bb47
^bb47:
cf.br ^bb48
^bb48:
%193 = llvm.load %178 : !llvm.ptr -> i64
%194 = arith.constant 0 : i32
%196 = arith.extsi %194 : i32 to i64
%195 = arith.cmpi ne, %193, %196 : i64
cf.cond_br %195, ^bb49, ^bb50
^bb49:
%197 = llvm.load %176 : !llvm.ptr -> i64
%198 = llvm.load %178 : !llvm.ptr -> i64
%199 = arith.remsi %197, %198 : i64
%200 = llvm.load %178 : !llvm.ptr -> i64
llvm.store %200, %176 : i64, !llvm.ptr
llvm.store %199, %178 : i64, !llvm.ptr
cf.br ^bb48
^bb50:
%201 = llvm.load %176 : !llvm.ptr -> i64
func.return %201 : i64
}
func.func @iabs(%arg0: i64) -> i64 {
%202 = arith.constant 0 : i32
%204 = arith.extsi %202 : i32 to i64
%203 = arith.cmpi slt, %arg0, %204 : i64
cf.cond_br %203, ^bb51, ^bb52
^bb51:
%206 = arith.constant 0 : i64
%205 = arith.subi %206, %arg0 : i64
func.return %205 : i64
^bb52:
cf.br ^bb53
^bb53:
func.return %arg0 : i64
}
func.func @egcd(%arg0: i64, %arg1: i64, %arg2: !llvm.ptr, %arg3: !llvm.ptr) -> i64 {
%207 = llvm.mlir.constant(1 : i64) : i64
%208 = llvm.alloca %207 x i64 : (i64) -> !llvm.ptr
llvm.store %arg0, %208 : i64, !llvm.ptr
%209 = llvm.mlir.constant(1 : i64) : i64
%210 = llvm.alloca %209 x i64 : (i64) -> !llvm.ptr
llvm.store %arg1, %210 : i64, !llvm.ptr
%211 = arith.constant 1 : i32
%212 = arith.extsi %211 : i32 to i64
%213 = llvm.mlir.constant(1 : i64) : i64
%214 = llvm.alloca %213 x i64 : (i64) -> !llvm.ptr
llvm.store %212, %214 : i64, !llvm.ptr
%215 = arith.constant 0 : i32
%216 = arith.extsi %215 : i32 to i64
%217 = llvm.mlir.constant(1 : i64) : i64
%218 = llvm.alloca %217 x i64 : (i64) -> !llvm.ptr
llvm.store %216, %218 : i64, !llvm.ptr
%219 = arith.constant 0 : i32
%220 = arith.extsi %219 : i32 to i64
%221 = llvm.mlir.constant(1 : i64) : i64
%222 = llvm.alloca %221 x i64 : (i64) -> !llvm.ptr
llvm.store %220, %222 : i64, !llvm.ptr
%223 = arith.constant 1 : i32
%224 = arith.extsi %223 : i32 to i64
%225 = llvm.mlir.constant(1 : i64) : i64
%226 = llvm.alloca %225 x i64 : (i64) -> !llvm.ptr
llvm.store %224, %226 : i64, !llvm.ptr
cf.br ^bb54
^bb54:
%227 = llvm.load %210 : !llvm.ptr -> i64
%228 = arith.constant 0 : i32
%230 = arith.extsi %228 : i32 to i64
%229 = arith.cmpi ne, %227, %230 : i64
cf.cond_br %229, ^bb55, ^bb56
^bb55:
%231 = llvm.load %208 : !llvm.ptr -> i64
%232 = llvm.load %210 : !llvm.ptr -> i64
%233 = arith.divsi %231, %232 : i64
%234 = llvm.load %210 : !llvm.ptr -> i64
%235 = llvm.load %208 : !llvm.ptr -> i64
%236 = llvm.load %210 : !llvm.ptr -> i64
%237 = arith.muli %233, %236 : i64
%238 = arith.subi %235, %237 : i64
llvm.store %238, %210 : i64, !llvm.ptr
llvm.store %234, %208 : i64, !llvm.ptr
%239 = llvm.load %222 : !llvm.ptr -> i64
%240 = llvm.load %214 : !llvm.ptr -> i64
%241 = llvm.load %222 : !llvm.ptr -> i64
%242 = arith.muli %233, %241 : i64
%243 = arith.subi %240, %242 : i64
llvm.store %243, %222 : i64, !llvm.ptr
llvm.store %239, %214 : i64, !llvm.ptr
%244 = llvm.load %226 : !llvm.ptr -> i64
%245 = llvm.load %218 : !llvm.ptr -> i64
%246 = llvm.load %226 : !llvm.ptr -> i64
%247 = arith.muli %233, %246 : i64
%248 = arith.subi %245, %247 : i64
llvm.store %248, %226 : i64, !llvm.ptr
llvm.store %244, %218 : i64, !llvm.ptr
cf.br ^bb54
^bb56:
%249 = llvm.load %214 : !llvm.ptr -> i64
%250 = arith.constant 0 : i32
%251 = arith.extsi %250 : i32 to i64
%252 = llvm.getelementptr %arg2[%251] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %249, %252 : i64, !llvm.ptr
%253 = llvm.load %218 : !llvm.ptr -> i64
%254 = arith.constant 0 : i32
%255 = arith.extsi %254 : i32 to i64
%256 = llvm.getelementptr %arg3[%255] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %253, %256 : i64, !llvm.ptr
%257 = llvm.load %208 : !llvm.ptr -> i64
func.return %257 : i64
}
func.func @ceil_div(%arg0: i64, %arg1: i64) -> i64 {
%258 = arith.constant 0 : i32
%259 = arith.constant 0 : i32
%261 = arith.extsi %259 : i32 to i64
%260 = arith.subi %261, %arg0 : i64
%262 = arith.divsi %260, %arg1 : i64
%264 = arith.extsi %258 : i32 to i64
%263 = arith.subi %264, %262 : i64
func.return %263 : i64
}
func.func @compute_T(%arg0: i64) -> i64 {
%265 = arith.constant 8000 : i32
%266 = arith.extsi %265 : i32 to i64
%267 = arith.muli %arg0, %arg0 : i64
%268 = arith.constant 200000 : i32
%269 = arith.extsi %268 : i32 to i64
%271 = arith.constant 8 : i32
%272 = arith.extsi %271 : i32 to i64
%270 = func.call @calloc(%269, %272) : (i64, i64) -> !llvm.ptr
%274 = arith.constant 8 : i32
%275 = arith.extsi %274 : i32 to i64
%273 = func.call @calloc(%269, %275) : (i64, i64) -> !llvm.ptr
%276 = arith.constant 0 : i32
%277 = arith.extsi %276 : i32 to i64
%278 = llvm.mlir.constant(1 : i64) : i64
%279 = llvm.alloca %278 x i64 : (i64) -> !llvm.ptr
llvm.store %277, %279 : i64, !llvm.ptr
%280 = llvm.mlir.constant(1 : i64) : i64
%281 = llvm.alloca %280 x i64 : (i64) -> !llvm.ptr
llvm.store %arg0, %281 : i64, !llvm.ptr
%282 = llvm.load %281 : !llvm.ptr -> i64
%283 = llvm.load %281 : !llvm.ptr -> i64
%284 = arith.muli %282, %283 : i64
%285 = llvm.mlir.constant(1 : i64) : i64
%286 = llvm.alloca %285 x i64 : (i64) -> !llvm.ptr
llvm.store %284, %286 : i64, !llvm.ptr
%287 = arith.constant 0 : i32
%288 = arith.extsi %287 : i32 to i64
%289 = llvm.mlir.constant(1 : i64) : i64
%290 = llvm.alloca %289 x i64 : (i64) -> !llvm.ptr
llvm.store %288, %290 : i64, !llvm.ptr
%291 = arith.constant 0 : i32
%292 = arith.extsi %291 : i32 to i64
%293 = llvm.mlir.constant(1 : i64) : i64
%294 = llvm.alloca %293 x i64 : (i64) -> !llvm.ptr
llvm.store %292, %294 : i64, !llvm.ptr
cf.br ^bb57
^bb57:
%295 = llvm.load %294 : !llvm.ptr -> i64
%296 = arith.cmpi sle, %295, %arg0 : i64
cf.cond_br %296, ^bb58, ^bb59
^bb58:
cf.br ^bb60
^bb60:
%297 = llvm.load %286 : !llvm.ptr -> i64
%298 = llvm.load %290 : !llvm.ptr -> i64
%299 = arith.addi %297, %298 : i64
%300 = arith.cmpi sgt, %299, %267 : i64
cf.cond_br %300, ^bb61, ^bb62
^bb61:
%301 = llvm.load %281 : !llvm.ptr -> i64
%302 = arith.constant 1 : i32
%304 = arith.extsi %302 : i32 to i64
%303 = arith.subi %301, %304 : i64
llvm.store %303, %281 : i64, !llvm.ptr
%305 = llvm.load %281 : !llvm.ptr -> i64
%306 = llvm.load %281 : !llvm.ptr -> i64
%307 = arith.muli %305, %306 : i64
llvm.store %307, %286 : i64, !llvm.ptr
cf.br ^bb60
^bb62:
%308 = llvm.load %286 : !llvm.ptr -> i64
%309 = arith.subi %267, %308 : i64
%310 = llvm.load %290 : !llvm.ptr -> i64
%311 = arith.subi %309, %310 : i64
%312 = arith.cmpi sle, %311, %266 : i64
cf.cond_br %312, ^bb63, ^bb64
^bb63:
%313 = llvm.load %281 : !llvm.ptr -> i64
%314 = llvm.load %279 : !llvm.ptr -> i64
%315 = llvm.getelementptr %270[%314] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %313, %315 : i64, !llvm.ptr
%316 = llvm.load %294 : !llvm.ptr -> i64
%317 = llvm.load %279 : !llvm.ptr -> i64
%318 = llvm.getelementptr %273[%317] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %316, %318 : i64, !llvm.ptr
%319 = llvm.load %279 : !llvm.ptr -> i64
%320 = arith.constant 1 : i32
%322 = arith.extsi %320 : i32 to i64
%321 = arith.addi %319, %322 : i64
llvm.store %321, %279 : i64, !llvm.ptr
cf.br ^bb65
^bb64:
cf.br ^bb65
^bb65:
%323 = llvm.load %290 : !llvm.ptr -> i64
%324 = arith.constant 2 : i32
%325 = llvm.load %294 : !llvm.ptr -> i64
%327 = arith.extsi %324 : i32 to i64
%326 = arith.muli %327, %325 : i64
%328 = arith.addi %323, %326 : i64
%329 = arith.constant 1 : i32
%331 = arith.extsi %329 : i32 to i64
%330 = arith.addi %328, %331 : i64
llvm.store %330, %290 : i64, !llvm.ptr
%332 = llvm.load %294 : !llvm.ptr -> i64
%333 = arith.constant 1 : i32
%335 = arith.extsi %333 : i32 to i64
%334 = arith.addi %332, %335 : i64
llvm.store %334, %294 : i64, !llvm.ptr
cf.br ^bb57
^bb59:
%336 = arith.constant 1 : i32
%338 = arith.constant 0 : i32
%337 = arith.subi %338, %336 : i32
%339 = arith.extsi %337 : i32 to i64
%340 = llvm.mlir.constant(1 : i64) : i64
%341 = llvm.alloca %340 x i64 : (i64) -> !llvm.ptr
llvm.store %339, %341 : i64, !llvm.ptr
%342 = arith.constant 10000 : i32
%343 = arith.extsi %342 : i32 to i64
%345 = arith.constant 8 : i32
%346 = arith.extsi %345 : i32 to i64
%344 = func.call @calloc(%343, %346) : (i64, i64) -> !llvm.ptr
%348 = arith.constant 8 : i32
%349 = arith.extsi %348 : i32 to i64
%347 = func.call @calloc(%343, %349) : (i64, i64) -> !llvm.ptr
%351 = arith.constant 8 : i32
%352 = arith.extsi %351 : i32 to i64
%350 = func.call @calloc(%343, %352) : (i64, i64) -> !llvm.ptr
%354 = arith.constant 8 : i32
%355 = arith.extsi %354 : i32 to i64
%353 = func.call @calloc(%343, %355) : (i64, i64) -> !llvm.ptr
%356 = arith.constant 0 : i32
%357 = arith.extsi %356 : i32 to i64
%358 = llvm.mlir.constant(1 : i64) : i64
%359 = llvm.alloca %358 x i64 : (i64) -> !llvm.ptr
llvm.store %357, %359 : i64, !llvm.ptr
%360 = arith.constant 0 : i32
%361 = arith.extsi %360 : i32 to i64
%362 = llvm.mlir.constant(1 : i64) : i64
%363 = llvm.alloca %362 x i64 : (i64) -> !llvm.ptr
llvm.store %361, %363 : i64, !llvm.ptr
cf.br ^bb66
^bb66:
%364 = llvm.load %363 : !llvm.ptr -> i64
%365 = llvm.load %279 : !llvm.ptr -> i64
%366 = arith.cmpi slt, %364, %365 : i64
cf.cond_br %366, ^bb67, ^bb68
^bb67:
%368 = llvm.load %363 : !llvm.ptr -> i64
%369 = llvm.getelementptr %270[%368] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%367 = llvm.load %369 : !llvm.ptr -> i64
%371 = llvm.load %363 : !llvm.ptr -> i64
%372 = llvm.getelementptr %273[%371] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%370 = llvm.load %372 : !llvm.ptr -> i64
%373 = llvm.load %363 : !llvm.ptr -> i64
%374 = arith.constant 1 : i32
%376 = arith.extsi %374 : i32 to i64
%375 = arith.addi %373, %376 : i64
%377 = llvm.mlir.constant(1 : i64) : i64
%378 = llvm.alloca %377 x i64 : (i64) -> !llvm.ptr
llvm.store %375, %378 : i64, !llvm.ptr
cf.br ^bb69
^bb69:
%379 = llvm.load %378 : !llvm.ptr -> i64
%380 = llvm.load %279 : !llvm.ptr -> i64
%381 = arith.cmpi slt, %379, %380 : i64
cf.cond_br %381, ^bb70, ^bb71
^bb70:
%383 = llvm.load %378 : !llvm.ptr -> i64
%384 = llvm.getelementptr %270[%383] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%382 = llvm.load %384 : !llvm.ptr -> i64
%385 = arith.addi %367, %382 : i64
%387 = llvm.load %378 : !llvm.ptr -> i64
%388 = llvm.getelementptr %273[%387] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%386 = llvm.load %388 : !llvm.ptr -> i64
%389 = arith.addi %370, %386 : i64
%390 = arith.muli %385, %385 : i64
%391 = arith.muli %389, %389 : i64
%392 = arith.addi %390, %391 : i64
%393 = llvm.load %341 : !llvm.ptr -> i64
%394 = arith.cmpi sge, %392, %393 : i64
cf.cond_br %394, ^bb72, ^bb73
^bb72:
%395 = arith.ori %385, %389 : i64
%396 = arith.constant 1 : i32
%398 = arith.extsi %396 : i32 to i64
%397 = arith.andi %395, %398 : i64
%399 = arith.constant 0 : i32
%401 = arith.extsi %399 : i32 to i64
%400 = arith.cmpi ne, %397, %401 : i64
cf.cond_br %400, ^bb75, ^bb76
^bb75:
%402 = func.call @igcd(%385, %389) : (i64, i64) -> i64
%403 = arith.constant 1 : i32
%405 = arith.extsi %403 : i32 to i64
%404 = arith.cmpi eq, %402, %405 : i64
cf.cond_br %404, ^bb78, ^bb79
^bb78:
%406 = llvm.load %341 : !llvm.ptr -> i64
%407 = arith.cmpi sgt, %392, %406 : i64
cf.cond_br %407, ^bb81, ^bb82
^bb81:
llvm.store %392, %341 : i64, !llvm.ptr
%408 = arith.constant 0 : i32
%409 = arith.extsi %408 : i32 to i64
llvm.store %409, %359 : i64, !llvm.ptr
cf.br ^bb83
^bb82:
cf.br ^bb83
^bb83:
%410 = llvm.load %363 : !llvm.ptr -> i64
%411 = llvm.load %359 : !llvm.ptr -> i64
%412 = llvm.getelementptr %344[%411] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %410, %412 : i64, !llvm.ptr
%413 = llvm.load %378 : !llvm.ptr -> i64
%414 = llvm.load %359 : !llvm.ptr -> i64
%415 = llvm.getelementptr %347[%414] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %413, %415 : i64, !llvm.ptr
%416 = llvm.load %359 : !llvm.ptr -> i64
%417 = llvm.getelementptr %350[%416] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %385, %417 : i64, !llvm.ptr
%418 = llvm.load %359 : !llvm.ptr -> i64
%419 = llvm.getelementptr %353[%418] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %389, %419 : i64, !llvm.ptr
%420 = llvm.load %359 : !llvm.ptr -> i64
%421 = arith.constant 1 : i32
%423 = arith.extsi %421 : i32 to i64
%422 = arith.addi %420, %423 : i64
llvm.store %422, %359 : i64, !llvm.ptr
cf.br ^bb80
^bb79:
cf.br ^bb80
^bb80:
cf.br ^bb77
^bb76:
cf.br ^bb77
^bb77:
cf.br ^bb74
^bb73:
cf.br ^bb74
^bb74:
%424 = llvm.load %378 : !llvm.ptr -> i64
%425 = arith.constant 1 : i32
%427 = arith.extsi %425 : i32 to i64
%426 = arith.addi %424, %427 : i64
llvm.store %426, %378 : i64, !llvm.ptr
cf.br ^bb69
^bb71:
%428 = llvm.load %363 : !llvm.ptr -> i64
%429 = arith.constant 1 : i32
%431 = arith.extsi %429 : i32 to i64
%430 = arith.addi %428, %431 : i64
llvm.store %430, %363 : i64, !llvm.ptr
cf.br ^bb66
^bb68:
%432 = arith.constant 0 : i32
%433 = arith.extsi %432 : i32 to i64
%434 = llvm.mlir.constant(1 : i64) : i64
%435 = llvm.alloca %434 x i64 : (i64) -> !llvm.ptr
llvm.store %433, %435 : i64, !llvm.ptr
%436 = arith.constant 0 : i32
%437 = arith.extsi %436 : i32 to i64
%438 = llvm.mlir.constant(1 : i64) : i64
%439 = llvm.alloca %438 x i64 : (i64) -> !llvm.ptr
llvm.store %437, %439 : i64, !llvm.ptr
%440 = arith.constant 0 : i32
%441 = arith.extsi %440 : i32 to i64
%442 = llvm.mlir.constant(1 : i64) : i64
%443 = llvm.alloca %442 x i64 : (i64) -> !llvm.ptr
llvm.store %441, %443 : i64, !llvm.ptr
%444 = arith.constant 1.0 : f32
%445 = arith.negf %444 : f32
%446 = arith.extf %445 : f32 to f64
%447 = llvm.mlir.constant(1 : i64) : i64
%448 = llvm.alloca %447 x f64 : (i64) -> !llvm.ptr
llvm.store %446, %448 : f64, !llvm.ptr
%450 = arith.constant 2 : i32
%451 = arith.constant 8 : i32
%452 = arith.extsi %450 : i32 to i64
%453 = arith.extsi %451 : i32 to i64
%449 = func.call @calloc(%452, %453) : (i64, i64) -> !llvm.ptr
%454 = arith.constant 0 : i32
%455 = arith.extsi %454 : i32 to i64
%456 = llvm.mlir.constant(1 : i64) : i64
%457 = llvm.alloca %456 x i64 : (i64) -> !llvm.ptr
llvm.store %455, %457 : i64, !llvm.ptr
cf.br ^bb84
^bb84:
%458 = llvm.load %457 : !llvm.ptr -> i64
%459 = llvm.load %359 : !llvm.ptr -> i64
%460 = arith.cmpi slt, %458, %459 : i64
cf.cond_br %460, ^bb85, ^bb86
^bb85:
%462 = llvm.load %457 : !llvm.ptr -> i64
%463 = llvm.getelementptr %350[%462] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%461 = llvm.load %463 : !llvm.ptr -> i64
%465 = llvm.load %457 : !llvm.ptr -> i64
%466 = llvm.getelementptr %353[%465] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%464 = llvm.load %466 : !llvm.ptr -> i64
%468 = llvm.load %457 : !llvm.ptr -> i64
%469 = llvm.getelementptr %344[%468] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%467 = llvm.load %469 : !llvm.ptr -> i64
%471 = llvm.load %457 : !llvm.ptr -> i64
%472 = llvm.getelementptr %347[%471] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%470 = llvm.load %472 : !llvm.ptr -> i64
%473 = arith.constant 0 : i32
%474 = arith.extsi %473 : i32 to i64
%475 = llvm.mlir.constant(1 : i64) : i64
%476 = llvm.alloca %475 x i64 : (i64) -> !llvm.ptr
llvm.store %474, %476 : i64, !llvm.ptr
cf.br ^bb87
^bb87:
%477 = llvm.load %476 : !llvm.ptr -> i64
%478 = arith.constant 2 : i32
%480 = arith.extsi %478 : i32 to i64
%479 = arith.cmpi slt, %477, %480 : i64
cf.cond_br %479, ^bb88, ^bb89
^bb88:
%482 = llvm.getelementptr %270[%467] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%481 = llvm.load %482 : !llvm.ptr -> i64
%484 = arith.constant 0 : i64
%483 = arith.subi %484, %481 : i64
%485 = llvm.mlir.constant(1 : i64) : i64
%486 = llvm.alloca %485 x i64 : (i64) -> !llvm.ptr
llvm.store %483, %486 : i64, !llvm.ptr
%488 = llvm.getelementptr %273[%467] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%487 = llvm.load %488 : !llvm.ptr -> i64
%490 = arith.constant 0 : i64
%489 = arith.subi %490, %487 : i64
%491 = llvm.mlir.constant(1 : i64) : i64
%492 = llvm.alloca %491 x i64 : (i64) -> !llvm.ptr
llvm.store %489, %492 : i64, !llvm.ptr
%493 = llvm.load %476 : !llvm.ptr -> i64
%494 = arith.constant 1 : i32
%496 = arith.extsi %494 : i32 to i64
%495 = arith.cmpi eq, %493, %496 : i64
cf.cond_br %495, ^bb90, ^bb91
^bb90:
%498 = llvm.getelementptr %270[%470] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%497 = llvm.load %498 : !llvm.ptr -> i64
%500 = arith.constant 0 : i64
%499 = arith.subi %500, %497 : i64
llvm.store %499, %486 : i64, !llvm.ptr
%502 = llvm.getelementptr %273[%470] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%501 = llvm.load %502 : !llvm.ptr -> i64
%504 = arith.constant 0 : i64
%503 = arith.subi %504, %501 : i64
llvm.store %503, %492 : i64, !llvm.ptr
cf.br ^bb92
^bb91:
cf.br ^bb92
^bb92:
%505 = llvm.load %486 : !llvm.ptr -> i64
%506 = arith.addi %505, %461 : i64
%507 = llvm.load %492 : !llvm.ptr -> i64
%508 = arith.addi %507, %464 : i64
%509 = llvm.load %486 : !llvm.ptr -> i64
%510 = llvm.load %486 : !llvm.ptr -> i64
%511 = arith.muli %509, %510 : i64
%512 = llvm.load %492 : !llvm.ptr -> i64
%513 = llvm.load %492 : !llvm.ptr -> i64
%514 = arith.muli %512, %513 : i64
%515 = arith.addi %511, %514 : i64
%516 = arith.cmpi sle, %515, %267 : i64
%517 = scf.if %516 -> (i1) {
%518 = arith.muli %506, %506 : i64
%519 = arith.muli %508, %508 : i64
%520 = arith.addi %518, %519 : i64
%521 = arith.cmpi sle, %520, %267 : i64
scf.yield %521 : i1
} else {
%522 = arith.constant false
scf.yield %522 : i1
}
cf.cond_br %517, ^bb93, ^bb94
^bb93:
%523 = arith.muli %461, %461 : i64
%524 = arith.muli %464, %464 : i64
%525 = arith.addi %523, %524 : i64
%527 = func.call @iabs(%461) : (i64) -> i64
%528 = func.call @iabs(%464) : (i64) -> i64
# String concatenation: !llvm.ptr + i32
%526 = func.call @egcd(%527, %528, %449, %529) : (i64, i64, !llvm.ptr, !llvm.ptr) -> i64
%531 = arith.constant 0 : i32
%532 = arith.extsi %531 : i32 to i64
%533 = llvm.getelementptr %449[%532] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%530 = llvm.load %533 : !llvm.ptr -> i64
%534 = llvm.mlir.constant(1 : i64) : i64
%535 = llvm.alloca %534 x i64 : (i64) -> !llvm.ptr
llvm.store %530, %535 : i64, !llvm.ptr
%537 = arith.constant 1 : i32
%538 = arith.extsi %537 : i32 to i64
%539 = llvm.getelementptr %449[%538] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%536 = llvm.load %539 : !llvm.ptr -> i64
%540 = llvm.mlir.constant(1 : i64) : i64
%541 = llvm.alloca %540 x i64 : (i64) -> !llvm.ptr
llvm.store %536, %541 : i64, !llvm.ptr
%542 = arith.constant 0 : i32
%544 = arith.extsi %542 : i32 to i64
%543 = arith.cmpi slt, %461, %544 : i64
cf.cond_br %543, ^bb96, ^bb97
^bb96:
%545 = llvm.load %535 : !llvm.ptr -> i64
%547 = arith.constant 0 : i64
%546 = arith.subi %547, %545 : i64
llvm.store %546, %535 : i64, !llvm.ptr
cf.br ^bb98
^bb97:
cf.br ^bb98
^bb98:
%548 = arith.constant 0 : i32
%550 = arith.extsi %548 : i32 to i64
%549 = arith.cmpi slt, %464, %550 : i64
cf.cond_br %549, ^bb99, ^bb100
^bb99:
%551 = llvm.load %541 : !llvm.ptr -> i64
%553 = arith.constant 0 : i64
%552 = arith.subi %553, %551 : i64
llvm.store %552, %541 : i64, !llvm.ptr
cf.br ^bb101
^bb100:
cf.br ^bb101
^bb101:
%554 = llvm.load %541 : !llvm.ptr -> i64
%556 = arith.constant 0 : i64
%555 = arith.subi %556, %554 : i64
%557 = llvm.load %535 : !llvm.ptr -> i64
%558 = arith.constant 1 : i32
%559 = arith.extsi %558 : i32 to i64
%560 = llvm.mlir.constant(1 : i64) : i64
%561 = llvm.alloca %560 x i64 : (i64) -> !llvm.ptr
llvm.store %559, %561 : i64, !llvm.ptr
%562 = arith.constant 0 : i32
%563 = arith.extsi %562 : i32 to i64
%564 = llvm.mlir.constant(1 : i64) : i64
%565 = llvm.alloca %564 x i64 : (i64) -> !llvm.ptr
llvm.store %563, %565 : i64, !llvm.ptr
cf.br ^bb102
^bb102:
%566 = llvm.load %565 : !llvm.ptr -> i64
%567 = arith.constant 2 : i32
%569 = arith.extsi %567 : i32 to i64
%568 = arith.cmpi slt, %566, %569 : i64
cf.cond_br %568, ^bb103, ^bb104
^bb103:
%570 = llvm.load %561 : !llvm.ptr -> i64
%571 = arith.muli %570, %555 : i64
%572 = llvm.load %561 : !llvm.ptr -> i64
%573 = arith.muli %572, %557 : i64
%574 = llvm.load %486 : !llvm.ptr -> i64
%575 = arith.addi %574, %571 : i64
%576 = llvm.load %492 : !llvm.ptr -> i64
%577 = arith.addi %576, %573 : i64
%578 = arith.extsi %575 : i64 to i128
%579 = arith.extsi %461 : i64 to i128
%581 = arith.trunci %578 : i128 to i64
%582 = arith.trunci %579 : i128 to i64
%580 = arith.muli %581, %582 : i64
%583 = arith.extsi %577 : i64 to i128
%584 = arith.extsi %464 : i64 to i128
%586 = arith.trunci %583 : i128 to i64
%587 = arith.trunci %584 : i128 to i64
%585 = arith.muli %586, %587 : i64
%588 = arith.addi %580, %585 : i64
%589 = arith.extsi %588 : i64 to i128
%590 = arith.extsi %575 : i64 to i128
%591 = arith.extsi %575 : i64 to i128
%593 = arith.trunci %590 : i128 to i64
%594 = arith.trunci %591 : i128 to i64
%592 = arith.muli %593, %594 : i64
%595 = arith.extsi %577 : i64 to i128
%596 = arith.extsi %577 : i64 to i128
%598 = arith.trunci %595 : i128 to i64
%599 = arith.trunci %596 : i128 to i64
%597 = arith.muli %598, %599 : i64
%600 = arith.addi %592, %597 : i64
%601 = arith.extsi %600 : i64 to i128
%602 = arith.extsi %525 : i64 to i128
%604 = arith.trunci %589 : i128 to i64
%605 = arith.trunci %589 : i128 to i64
%603 = arith.muli %604, %605 : i64
%606 = arith.extsi %267 : i64 to i128
%608 = arith.trunci %601 : i128 to i64
%609 = arith.trunci %606 : i128 to i64
%607 = arith.subi %608, %609 : i64
%611 = arith.trunci %602 : i128 to i64
%610 = arith.muli %611, %607 : i64
%612 = arith.subi %603, %610 : i64
%613 = arith.extsi %612 : i64 to i128
%614 = arith.constant 0 : i32
%616 = arith.trunci %613 : i128 to i64
%617 = arith.extsi %614 : i32 to i64
%615 = arith.cmpi sge, %616, %617 : i64
cf.cond_br %615, ^bb105, ^bb106
^bb105:
%618 = llvm.mlir.constant(1 : i64) : i64
%619 = llvm.alloca %618 x i128 : (i64) -> !llvm.ptr
llvm.store %613, %619 : i128, !llvm.ptr
%620 = llvm.load %619 : !llvm.ptr -> i128
%621 = arith.constant 1 : i32
%623 = arith.trunci %620 : i128 to i64
%624 = arith.extsi %621 : i32 to i64
%622 = arith.addi %623, %624 : i64
%625 = arith.constant 2 : i32
%627 = arith.extsi %625 : i32 to i64
%626 = arith.divsi %622, %627 : i64
%628 = arith.extsi %626 : i64 to i128
%629 = llvm.mlir.constant(1 : i64) : i64
%630 = llvm.alloca %629 x i128 : (i64) -> !llvm.ptr
llvm.store %628, %630 : i128, !llvm.ptr
cf.br ^bb108
^bb108:
%631 = llvm.load %630 : !llvm.ptr -> i128
%632 = llvm.load %619 : !llvm.ptr -> i128
%634 = arith.trunci %631 : i128 to i64
%635 = arith.trunci %632 : i128 to i64
%633 = arith.cmpi slt, %634, %635 : i64
cf.cond_br %633, ^bb109, ^bb110
^bb109:
%636 = llvm.load %630 : !llvm.ptr -> i128
llvm.store %636, %619 : i128, !llvm.ptr
%637 = llvm.load %619 : !llvm.ptr -> i128
%638 = llvm.load %619 : !llvm.ptr -> i128
%640 = arith.trunci %613 : i128 to i64
%641 = arith.trunci %638 : i128 to i64
%639 = arith.divsi %640, %641 : i64
%643 = arith.trunci %637 : i128 to i64
%642 = arith.addi %643, %639 : i64
%644 = arith.constant 2 : i32
%646 = arith.extsi %644 : i32 to i64
%645 = arith.divsi %642, %646 : i64
%647 = arith.extsi %645 : i64 to i128
llvm.store %647, %630 : i128, !llvm.ptr
cf.br ^bb108
^bb110:
%648 = llvm.load %619 : !llvm.ptr -> i128
%649 = arith.constant 0 : i32
%651 = arith.extsi %649 : i32 to i64
%652 = arith.trunci %589 : i128 to i64
%650 = arith.subi %651, %652 : i64
%654 = arith.trunci %648 : i128 to i64
%653 = arith.subi %650, %654 : i64
%655 = arith.extsi %653 : i64 to i128
%656 = llvm.mlir.constant(1 : i64) : i64
%657 = llvm.alloca %656 x i128 : (i64) -> !llvm.ptr
llvm.store %655, %657 : i128, !llvm.ptr
%658 = arith.constant 0 : i32
%659 = arith.extsi %658 : i32 to i64
%660 = llvm.mlir.constant(1 : i64) : i64
%661 = llvm.alloca %660 x i64 : (i64) -> !llvm.ptr
llvm.store %659, %661 : i64, !llvm.ptr
%662 = llvm.load %657 : !llvm.ptr -> i128
%663 = arith.constant 0 : i32
%665 = arith.trunci %662 : i128 to i64
%666 = arith.extsi %663 : i32 to i64
%664 = arith.cmpi sge, %665, %666 : i64
cf.cond_br %664, ^bb111, ^bb112
^bb111:
%667 = llvm.load %657 : !llvm.ptr -> i128
%669 = arith.trunci %667 : i128 to i64
%670 = arith.trunci %602 : i128 to i64
%668 = arith.addi %669, %670 : i64
%671 = arith.constant 1 : i32
%673 = arith.extsi %671 : i32 to i64
%672 = arith.subi %668, %673 : i64
%675 = arith.trunci %602 : i128 to i64
%674 = arith.divsi %672, %675 : i64
llvm.store %674, %661 : i64, !llvm.ptr
cf.br ^bb113
^bb112:
%676 = llvm.load %657 : !llvm.ptr -> i128
%678 = arith.trunci %676 : i128 to i64
%679 = arith.trunci %602 : i128 to i64
%677 = arith.divsi %678, %679 : i64
llvm.store %677, %661 : i64, !llvm.ptr
cf.br ^bb113
^bb113:
%680 = arith.constant 0 : i32
%682 = arith.extsi %680 : i32 to i64
%683 = arith.trunci %589 : i128 to i64
%681 = arith.subi %682, %683 : i64
%685 = arith.trunci %648 : i128 to i64
%684 = arith.addi %681, %685 : i64
%687 = arith.trunci %602 : i128 to i64
%686 = arith.divsi %684, %687 : i64
%688 = llvm.load %661 : !llvm.ptr -> i64
%689 = llvm.mlir.constant(1 : i64) : i64
%690 = llvm.alloca %689 x i64 : (i64) -> !llvm.ptr
llvm.store %688, %690 : i64, !llvm.ptr
cf.br ^bb114
^bb114:
%691 = llvm.load %690 : !llvm.ptr -> i64
%692 = arith.cmpi sle, %691, %686 : i64
cf.cond_br %692, ^bb115, ^bb116
^bb115:
%693 = llvm.load %690 : !llvm.ptr -> i64
%694 = arith.muli %693, %461 : i64
%695 = arith.addi %571, %694 : i64
%696 = llvm.load %690 : !llvm.ptr -> i64
%697 = arith.muli %696, %464 : i64
%698 = arith.addi %573, %697 : i64
%699 = llvm.load %486 : !llvm.ptr -> i64
%700 = arith.extsi %699 : i64 to i128
%701 = arith.extsi %695 : i64 to i128
%703 = arith.trunci %700 : i128 to i64
%704 = arith.trunci %701 : i128 to i64
%702 = arith.addi %703, %704 : i64
%705 = arith.extsi %702 : i64 to i128
%706 = llvm.load %492 : !llvm.ptr -> i64
%707 = arith.extsi %706 : i64 to i128
%708 = arith.extsi %698 : i64 to i128
%710 = arith.trunci %707 : i128 to i64
%711 = arith.trunci %708 : i128 to i64
%709 = arith.addi %710, %711 : i64
%712 = arith.extsi %709 : i64 to i128
%714 = arith.trunci %705 : i128 to i64
%715 = arith.trunci %705 : i128 to i64
%713 = arith.muli %714, %715 : i64
%717 = arith.trunci %712 : i128 to i64
%718 = arith.trunci %712 : i128 to i64
%716 = arith.muli %717, %718 : i64
%719 = arith.addi %713, %716 : i64
%720 = arith.extsi %267 : i64 to i128
%722 = arith.trunci %720 : i128 to i64
%721 = arith.cmpi sle, %719, %722 : i64
cf.cond_br %721, ^bb117, ^bb118
^bb117:
%723 = arith.muli %695, %695 : i64
%724 = arith.muli %698, %698 : i64
%725 = arith.addi %723, %724 : i64
%726 = arith.subi %461, %695 : i64
%727 = arith.subi %464, %698 : i64
%728 = arith.muli %726, %726 : i64
%729 = arith.muli %727, %727 : i64
%730 = arith.addi %728, %729 : i64
%731 = arith.sitofp %525 : i64 to f64
%732 = math.sqrt %731 : f64
%733 = arith.sitofp %725 : i64 to f64
%734 = math.sqrt %733 : f64
%735 = arith.addf %732, %734 : f64
%736 = arith.sitofp %730 : i64 to f64
%737 = math.sqrt %736 : f64
%738 = arith.addf %735, %737 : f64
%739 = llvm.load %448 : !llvm.ptr -> f64
%740 = arith.cmpf ogt, %738, %739 : f64
cf.cond_br %740, ^bb120, ^bb121
^bb120:
llvm.store %738, %448 : f64, !llvm.ptr
llvm.store %525, %435 : i64, !llvm.ptr
llvm.store %725, %439 : i64, !llvm.ptr
llvm.store %730, %443 : i64, !llvm.ptr
cf.br ^bb122
^bb121:
cf.br ^bb122
^bb122:
cf.br ^bb119
^bb118:
cf.br ^bb119
^bb119:
%741 = llvm.load %690 : !llvm.ptr -> i64
%742 = arith.constant 1 : i32
%744 = arith.extsi %742 : i32 to i64
%743 = arith.addi %741, %744 : i64
llvm.store %743, %690 : i64, !llvm.ptr
cf.br ^bb114
^bb116:
cf.br ^bb107
^bb106:
cf.br ^bb107
^bb107:
%745 = arith.constant 1 : i32
%747 = arith.constant 0 : i32
%746 = arith.subi %747, %745 : i32
%748 = arith.extsi %746 : i32 to i64
llvm.store %748, %561 : i64, !llvm.ptr
%749 = llvm.load %565 : !llvm.ptr -> i64
%750 = arith.constant 1 : i32
%752 = arith.extsi %750 : i32 to i64
%751 = arith.addi %749, %752 : i64
llvm.store %751, %565 : i64, !llvm.ptr
cf.br ^bb102
^bb104:
cf.br ^bb95
^bb94:
cf.br ^bb95
^bb95:
%753 = llvm.load %476 : !llvm.ptr -> i64
%754 = arith.constant 1 : i32
%756 = arith.extsi %754 : i32 to i64
%755 = arith.addi %753, %756 : i64
llvm.store %755, %476 : i64, !llvm.ptr
cf.br ^bb87
^bb89:
%757 = llvm.load %457 : !llvm.ptr -> i64
%758 = arith.constant 1 : i32
%760 = arith.extsi %758 : i32 to i64
%759 = arith.addi %757, %760 : i64
llvm.store %759, %457 : i64, !llvm.ptr
cf.br ^bb84
^bb86:
%761 = llvm.load %435 : !llvm.ptr -> i64
%762 = arith.sitofp %761 : i64 to f64
%763 = math.sqrt %762 : f64
%764 = llvm.load %439 : !llvm.ptr -> i64
%765 = arith.sitofp %764 : i64 to f64
%766 = math.sqrt %765 : f64
%767 = arith.mulf %763, %766 : f64
%768 = llvm.load %443 : !llvm.ptr -> i64
%769 = arith.sitofp %768 : i64 to f64
%770 = math.sqrt %769 : f64
%771 = arith.mulf %767, %770 : f64
%772 = arith.constant 2.0 : f32
%773 = arith.sitofp %arg0 : i64 to f64
%775 = arith.extf %772 : f32 to f64
%774 = arith.mulf %775, %773 : f64
%776 = arith.divf %771, %774 : f64
%777 = func.call @llround(%776) : (f64) -> i64
func.call @free(%270) : (!llvm.ptr) -> ()
func.call @free(%273) : (!llvm.ptr) -> ()
func.call @free(%344) : (!llvm.ptr) -> ()
func.call @free(%347) : (!llvm.ptr) -> ()
func.call @free(%350) : (!llvm.ptr) -> ()
func.call @free(%353) : (!llvm.ptr) -> ()
func.call @free(%449) : (!llvm.ptr) -> ()
func.return %777 : i64
}
func.func @main() -> i32 {
%785 = llvm.mlir.addressof @str_0 : !llvm.ptr
%787 = arith.constant 10000000 : i32
%788 = arith.extsi %787 : i32 to i64
%786 = func.call @compute_T(%788) : (i64) -> i64
%789 = llvm.call @printf(%785, %786) vararg(!llvm.func<i32 (ptr, ...)>) : (!llvm.ptr, i64) -> i32
%790 = arith.constant 0 : i32
func.return %790 : i32
}
}