← All problems
Problem 777
Lissajous curves x = cos(a t), y = cos(b (t - pi/10)): s(10^6) in scientific notation, 10 significant digits. Self-crossings pair parameters t1 != t2 with equal x and equal y. cos(a t1) = cos(a t2) forces t1 - t2 = 2 pi k / a (shift) or t1 + t2 = 2 pi k / a (reflect); likewise for y around the phase pi/10. Shift-shift gives t1 = t2 (a, b coprime). The two mixed families give lattice-indexed crossing points whose cos^2 values sum over full residue systems, so the pair sums telescope: family sums 2ab - 3a and 2ab - 3b in total, d(a,b) = (4ab - 3a - 3b)/2. Reflect-reflect needs t1 + t2 = s with s = 0 mod 2pi/a and s = pi/5 mod 2pi/b, solvable exactly when 10 | ab. Then gamma(s - t) = gamma(t): the curve doubles onto itself, each image crossing is covered by 4 parameter pairs (2 per family), and the pairs lying on the fold (cos^2 = 1 there) are not crossings. Removing 3b - 4 and 3a - 4 and dividing by 4 gives d(a,b) = (2ab - 3a - 3b + 4)/4 when 10 | ab. Both forms verified against a numerical crossing finder for all coprime pairs 2 <= a, b <= 12 plus larger spot checks, and against the given d values, s(10) = 1602.5 and s(100) = 24256505 exactly. Sum over coprime ordered pairs 2 <= a, b <= M in exact quarter units: 4 s = sum_all (8ab - 6(a+b)) - sum_{10 | ab} (6ab - 3(a+b) - 4) with [10 | ab] = 1 - [both odd] - [both not div 5] + [both odd, not div 5] since a, b are coprime. Each class sum uses Mobius over d <= M with closed-form inner sums of multiples of d in the class. Accumulate in i128, then print 25 * (4 s) = 100 s rounded to 10 significant digits.
View problem on Project Euler
Performance comparison
Metric Our solution Best known
Time complexity O(n^2)O(1)
Space complexity O(n^2)O(1)
Approach Flow solution Closed-form formula
Verdict Suboptimal
Flow source
# Project Euler 777
# Lissajous curves x = cos(a t), y = cos(b (t - pi/10)): s(10^6) in
# scientific notation, 10 significant digits.
#
# Self-crossings pair parameters t1 != t2 with equal x and equal y.
# cos(a t1) = cos(a t2) forces t1 - t2 = 2 pi k / a (shift) or
# t1 + t2 = 2 pi k / a (reflect); likewise for y around the phase pi/10.
# Shift-shift gives t1 = t2 (a, b coprime). The two mixed families give
# lattice-indexed crossing points whose cos^2 values sum over full
# residue systems, so the pair sums telescope:
# family sums 2ab - 3a and 2ab - 3b in total, d(a,b) = (4ab - 3a - 3b)/2.
# Reflect-reflect needs t1 + t2 = s with s = 0 mod 2pi/a and
# s = pi/5 mod 2pi/b, solvable exactly when 10 | ab. Then gamma(s - t) =
# gamma(t): the curve doubles onto itself, each image crossing is covered
# by 4 parameter pairs (2 per family), and the pairs lying on the fold
# (cos^2 = 1 there) are not crossings. Removing 3b - 4 and 3a - 4 and
# dividing by 4 gives d(a,b) = (2ab - 3a - 3b + 4)/4 when 10 | ab.
# Both forms verified against a numerical crossing finder for all coprime
# pairs 2 <= a, b <= 12 plus larger spot checks, and against the given
# d values, s(10) = 1602.5 and s(100) = 24256505 exactly.
#
# Sum over coprime ordered pairs 2 <= a, b <= M in exact quarter units:
# 4 s = sum_all (8ab - 6(a+b)) - sum_{10 | ab} (6ab - 3(a+b) - 4)
# with [10 | ab] = 1 - [both odd] - [both not div 5] + [both odd, not div 5]
# since a, b are coprime. Each class sum uses Mobius over d <= M with
# closed-form inner sums of multiples of d in the class. Accumulate in
# i128, then print 25 * (4 s) = 100 s rounded to 10 significant digits.
extern {
function calloc(n: i64, size: i64) -> ptr<void>
function free(p: ptr<void>) -> void
}
const M: i64 = 1000000
function tri(n: i64) -> i64 {
if n <= 0 { return 0 }
return n * (n + 1) / 2
}
function sum_odd(n: i64) -> i64 {
if n <= 0 { return 0 }
let k: i64 = (n + 1) / 2
return k * k
}
function cnt_odd(n: i64) -> i64 {
if n <= 0 { return 0 }
return (n + 1) / 2
}
function main() -> i32 {
# Mobius sieve via smallest prime factor
let spf: ptr<i64> = calloc(M + 1, 8)
let mu: ptr<i64> = calloc(M + 1, 8)
let mut i: i64 = 2
while i <= M {
if spf[i] == 0 {
let mut j: i64 = i
while j <= M {
if spf[j] == 0 {
spf[j] = i
}
j = j + i
}
}
i = i + 1
}
mu[1] = 1
i = 2
while i <= M {
let p: i64 = spf[i]
let r: i64 = i / p
if r % p == 0 {
mu[i] = 0
} else {
mu[i] = 0 - mu[r]
}
i = i + 1
}
# per class accumulators: A = sum ab, B = sum (a+b), C = count,
# over coprime pairs with both members in the class
# class 0: all, 1: odd, 2: not div by 5, 3: odd and not div by 5
let mut a0: i128 = 0
let mut a1: i128 = 0
let mut a2: i128 = 0
let mut a3: i128 = 0
let mut b0: i128 = 0
let mut b1: i128 = 0
let mut b2: i128 = 0
let mut b3: i128 = 0
let mut c0: i128 = 0
let mut c1: i128 = 0
let mut c2: i128 = 0
let mut c3: i128 = 0
let mut d: i64 = 1
while d <= M {
let mv: i64 = mu[d]
if mv != 0 {
let q: i64 = M / d
let k5: i64 = q / 5
let m128: i128 = mv as i128
# class 0: all a in [2, M] with d | a
let mut f: i64 = d * tri(q)
let mut c: i64 = q
if d == 1 {
f = f - 1
c = c - 1
}
a0 = a0 + m128 * (f as i128) * (f as i128)
b0 = b0 + m128 * ((2 * f) as i128) * (c as i128)
c0 = c0 + m128 * ((c * c) as i128)
# class 1: odd multiples of d
if d % 2 == 1 {
f = d * sum_odd(q)
c = cnt_odd(q)
if d == 1 {
f = f - 1
c = c - 1
}
a1 = a1 + m128 * (f as i128) * (f as i128)
b1 = b1 + m128 * ((2 * f) as i128) * (c as i128)
c1 = c1 + m128 * ((c * c) as i128)
}
# class 2: multiples of d not divisible by 5
if d % 5 != 0 {
f = d * (tri(q) - 5 * tri(k5))
c = q - k5
if d == 1 {
f = f - 1
c = c - 1
}
a2 = a2 + m128 * (f as i128) * (f as i128)
b2 = b2 + m128 * ((2 * f) as i128) * (c as i128)
c2 = c2 + m128 * ((c * c) as i128)
}
# class 3: odd multiples of d not divisible by 5
if d % 2 == 1 && d % 5 != 0 {
f = d * (sum_odd(q) - 5 * sum_odd(k5))
c = cnt_odd(q) - cnt_odd(k5)
if d == 1 {
f = f - 1
c = c - 1
}
a3 = a3 + m128 * (f as i128) * (f as i128)
b3 = b3 + m128 * ((2 * f) as i128) * (c as i128)
c3 = c3 + m128 * ((c * c) as i128)
}
}
d = d + 1
}
# G = sum over class pairs of (6ab - 3(a+b) - 4)
let g0: i128 = (6 as i128) * a0 - (3 as i128) * b0 - (4 as i128) * c0
let g1: i128 = (6 as i128) * a1 - (3 as i128) * b1 - (4 as i128) * c1
let g2: i128 = (6 as i128) * a2 - (3 as i128) * b2 - (4 as i128) * c2
let g3: i128 = (6 as i128) * a3 - (3 as i128) * b3 - (4 as i128) * c3
let s4: i128 = (8 as i128) * a0 - (6 as i128) * b0 - (g0 - g1 - g2 + g3)
let s100: i128 = s4 * (25 as i128)
# decimal digits of 100 s, least significant first
let dig: ptr<i64> = calloc(64, 8)
let mut nd: i64 = 0
let mut t: i128 = s100
while t > (0 as i128) {
dig[nd] = (t % (10 as i128)) as i64
t = t / (10 as i128)
nd = nd + 1
}
# 10 significant digits with rounding; s = s100 / 100
let mant: ptr<i64> = calloc(10, 8)
i = 0
while i < 10 {
if i < nd {
mant[i] = dig[nd - 1 - i]
} else {
mant[i] = 0
}
i = i + 1
}
let mut ex: i64 = nd - 1 - 2
if nd > 10 && dig[nd - 11] >= 5 {
let mut j: i64 = 9
let mut carry: i64 = 1
while j >= 0 && carry == 1 {
mant[j] = mant[j] + 1
if mant[j] == 10 {
mant[j] = 0
} else {
carry = 0
}
j = j - 1
}
if carry == 1 {
mant[0] = 1
let mut j2: i64 = 1
while j2 < 10 {
mant[j2] = 0
j2 = j2 + 1
}
ex = ex + 1
}
}
printf("%lld.", mant[0])
i = 1
while i < 10 {
printf("%lld", mant[i])
i = i + 1
}
printf("e%lld\n", ex)
free(spf)
free(mu)
free(dig)
free(mant)
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 tri_i64(int64_t n);
int64_t sum_odd_i64(int64_t n);
int64_t cnt_odd_i64(int64_t n);
int32_t main(void);
static const int64_t M = 1000000;
int64_t tri_i64(int64_t n) {
if (n <= 0) {
return 0;
}
return FLOW_CHECKED_DIV(((n * (n + 1))), (2));
}
int64_t sum_odd_i64(int64_t n) {
if (n <= 0) {
return 0;
}
int64_t k = FLOW_CHECKED_DIV(((n + 1)), (2));
return (k * k);
}
int64_t cnt_odd_i64(int64_t n) {
if (n <= 0) {
return 0;
}
return FLOW_CHECKED_DIV(((n + 1)), (2));
}
int32_t main(void) {
int64_t* spf = (int64_t*)(calloc((M + 1), 8));
int64_t* mu = (int64_t*)(calloc((M + 1), 8));
int64_t i = 2;
while (i <= M) {
if (spf[i] == 0) {
int64_t j = i;
while (j <= M) {
if (spf[j] == 0) {
spf[j] = i;
}
j = (j + i);
}
}
i = (i + 1);
}
mu[1] = 1;
i = 2;
while (i <= M) {
int64_t p = spf[i];
int64_t r = FLOW_CHECKED_DIV((i), (p));
if (FLOW_CHECKED_MOD((r), (p)) == 0) {
mu[i] = 0;
} else {
mu[i] = (0 - mu[r]);
}
i = (i + 1);
}
__int128 a0 = 0;
__int128 a1 = 0;
__int128 a2 = 0;
__int128 a3 = 0;
__int128 b0 = 0;
__int128 b1 = 0;
__int128 b2 = 0;
__int128 b3 = 0;
__int128 c0 = 0;
__int128 c1 = 0;
__int128 c2 = 0;
__int128 c3 = 0;
int64_t d = 1;
while (d <= M) {
int64_t mv = mu[d];
if (mv != 0) {
int64_t q = FLOW_CHECKED_DIV((M), (d));
int64_t k5 = FLOW_CHECKED_DIV((q), (5));
__int128 m128 = ((__int128)(mv));
int64_t f = (d * tri_i64(q));
int64_t c = q;
if (d == 1) {
f = (f - 1);
c = (c - 1);
}
a0 = (a0 + ((m128 * ((__int128)(f))) * ((__int128)(f))));
b0 = (b0 + ((m128 * ((__int128)((2 * f)))) * ((__int128)(c))));
c0 = (c0 + (m128 * ((__int128)((c * c)))));
if (FLOW_CHECKED_MOD((d), (2)) == 1) {
f = (d * sum_odd_i64(q));
c = cnt_odd_i64(q);
if (d == 1) {
f = (f - 1);
c = (c - 1);
}
a1 = (a1 + ((m128 * ((__int128)(f))) * ((__int128)(f))));
b1 = (b1 + ((m128 * ((__int128)((2 * f)))) * ((__int128)(c))));
c1 = (c1 + (m128 * ((__int128)((c * c)))));
}
if (FLOW_CHECKED_MOD((d), (5)) != 0) {
f = (d * (tri_i64(q) - (5 * tri_i64(k5))));
c = (q - k5);
if (d == 1) {
f = (f - 1);
c = (c - 1);
}
a2 = (a2 + ((m128 * ((__int128)(f))) * ((__int128)(f))));
b2 = (b2 + ((m128 * ((__int128)((2 * f)))) * ((__int128)(c))));
c2 = (c2 + (m128 * ((__int128)((c * c)))));
}
if ((FLOW_CHECKED_MOD((d), (2)) == 1 && FLOW_CHECKED_MOD((d), (5)) != 0)) {
f = (d * (sum_odd_i64(q) - (5 * sum_odd_i64(k5))));
c = (cnt_odd_i64(q) - cnt_odd_i64(k5));
if (d == 1) {
f = (f - 1);
c = (c - 1);
}
a3 = (a3 + ((m128 * ((__int128)(f))) * ((__int128)(f))));
b3 = (b3 + ((m128 * ((__int128)((2 * f)))) * ((__int128)(c))));
c3 = (c3 + (m128 * ((__int128)((c * c)))));
}
}
d = (d + 1);
}
__int128 g0 = (((((__int128)(6)) * a0) - (((__int128)(3)) * b0)) - (((__int128)(4)) * c0));
__int128 g1 = (((((__int128)(6)) * a1) - (((__int128)(3)) * b1)) - (((__int128)(4)) * c1));
__int128 g2 = (((((__int128)(6)) * a2) - (((__int128)(3)) * b2)) - (((__int128)(4)) * c2));
__int128 g3 = (((((__int128)(6)) * a3) - (((__int128)(3)) * b3)) - (((__int128)(4)) * c3));
__int128 s4 = (((((__int128)(8)) * a0) - (((__int128)(6)) * b0)) - (((g0 - g1) - g2) + g3));
__int128 s100 = (s4 * ((__int128)(25)));
int64_t* dig = (int64_t*)(calloc(64, 8));
int64_t nd = 0;
__int128 t = s100;
while (t > ((__int128)(0))) {
dig[nd] = ((int64_t)(FLOW_CHECKED_MOD((t), (((__int128)(10))))));
t = FLOW_CHECKED_DIV((t), (((__int128)(10))));
nd = (nd + 1);
}
int64_t* mant = (int64_t*)(calloc(10, 8));
i = 0;
while (i < 10) {
if (i < nd) {
mant[i] = dig[((nd - 1) - i)];
} else {
mant[i] = 0;
}
i = (i + 1);
}
int64_t ex = ((nd - 1) - 2);
if ((nd > 10 && dig[(nd - 11)] >= 5)) {
int64_t j = 9;
int64_t carry = 1;
while ((j >= 0 && carry == 1)) {
mant[j] = (mant[j] + 1);
if (mant[j] == 10) {
mant[j] = 0;
} else {
carry = 0;
}
j = (j - 1);
}
if (carry == 1) {
mant[0] = 1;
int64_t j2 = 1;
while (j2 < 10) {
mant[j2] = 0;
j2 = (j2 + 1);
}
ex = (ex + 1);
}
}
printf("%lld.", mant[0]);
i = 1;
while (i < 10) {
printf("%lld", mant[i]);
i = (i + 1);
}
printf("e%lld\n", ex);
free(spf);
free(mu);
free(dig);
free(mant);
return 0;
}
Generated MLIR
module {
llvm.func @printf(!llvm.ptr, ...) -> i32
llvm.mlir.global internal constant @str_0("%lld.\00") {addr_space = 0 : i32} : !llvm.array<6 x i8>
llvm.mlir.global internal constant @str_1("%lld\00") {addr_space = 0 : i32} : !llvm.array<5 x i8>
llvm.mlir.global internal constant @str_2("e%lld\n\00") {addr_space = 0 : i32} : !llvm.array<7 x i8>
func.func private @calloc(i64, i64) -> !llvm.ptr
func.func private @free(!llvm.ptr) -> ()
// Constant: M
llvm.mlir.global internal constant @M(1000000 : i64) : i64
func.func @tri(%arg0: i64) -> i64 {
%0 = arith.constant 0 : i32
%2 = arith.extsi %0 : i32 to i64
%1 = arith.cmpi sle, %arg0, %2 : i64
cf.cond_br %1, ^bb0, ^bb1
^bb0:
%3 = arith.constant 0 : i32
%4 = arith.extsi %3 : i32 to i64
func.return %4 : i64
^bb1:
cf.br ^bb2
^bb2:
%5 = arith.constant 1 : i32
%7 = arith.extsi %5 : i32 to i64
%6 = arith.addi %arg0, %7 : i64
%8 = arith.muli %arg0, %6 : i64
%9 = arith.constant 2 : i32
%11 = arith.extsi %9 : i32 to i64
%10 = arith.divsi %8, %11 : i64
func.return %10 : i64
}
func.func @sum_odd(%arg0: i64) -> i64 {
%12 = arith.constant 0 : i32
%14 = arith.extsi %12 : i32 to i64
%13 = arith.cmpi sle, %arg0, %14 : i64
cf.cond_br %13, ^bb3, ^bb4
^bb3:
%15 = arith.constant 0 : i32
%16 = arith.extsi %15 : i32 to i64
func.return %16 : i64
^bb4:
cf.br ^bb5
^bb5:
%17 = arith.constant 1 : i32
%19 = arith.extsi %17 : i32 to i64
%18 = arith.addi %arg0, %19 : i64
%20 = arith.constant 2 : i32
%22 = arith.extsi %20 : i32 to i64
%21 = arith.divsi %18, %22 : i64
%23 = arith.muli %21, %21 : i64
func.return %23 : i64
}
func.func @cnt_odd(%arg0: i64) -> i64 {
%24 = arith.constant 0 : i32
%26 = arith.extsi %24 : i32 to i64
%25 = arith.cmpi sle, %arg0, %26 : i64
cf.cond_br %25, ^bb6, ^bb7
^bb6:
%27 = arith.constant 0 : i32
%28 = arith.extsi %27 : i32 to i64
func.return %28 : i64
^bb7:
cf.br ^bb8
^bb8:
%29 = arith.constant 1 : i32
%31 = arith.extsi %29 : i32 to i64
%30 = arith.addi %arg0, %31 : i64
%32 = arith.constant 2 : i32
%34 = arith.extsi %32 : i32 to i64
%33 = arith.divsi %30, %34 : i64
func.return %33 : i64
}
func.func @main() -> i32 {
%36 = llvm.mlir.addressof @M : !llvm.ptr
%37 = llvm.load %36 : !llvm.ptr -> i64
%38 = arith.constant 1 : i32
%40 = arith.extsi %38 : i32 to i64
%39 = arith.addi %37, %40 : i64
%41 = arith.constant 8 : i32
%42 = arith.extsi %41 : i32 to i64
%35 = func.call @calloc(%39, %42) : (i64, i64) -> !llvm.ptr
%44 = llvm.mlir.addressof @M : !llvm.ptr
%45 = llvm.load %44 : !llvm.ptr -> i64
%46 = arith.constant 1 : i32
%48 = arith.extsi %46 : i32 to i64
%47 = arith.addi %45, %48 : i64
%49 = arith.constant 8 : i32
%50 = arith.extsi %49 : i32 to i64
%43 = func.call @calloc(%47, %50) : (i64, i64) -> !llvm.ptr
%51 = arith.constant 2 : i32
%52 = arith.extsi %51 : i32 to i64
%53 = llvm.mlir.constant(1 : i64) : i64
%54 = llvm.alloca %53 x i64 : (i64) -> !llvm.ptr
llvm.store %52, %54 : i64, !llvm.ptr
cf.br ^bb9
^bb9:
%55 = llvm.load %54 : !llvm.ptr -> i64
%56 = llvm.mlir.addressof @M : !llvm.ptr
%57 = llvm.load %56 : !llvm.ptr -> i64
%58 = arith.cmpi sle, %55, %57 : i64
cf.cond_br %58, ^bb10, ^bb11
^bb10:
%60 = llvm.load %54 : !llvm.ptr -> i64
%61 = llvm.getelementptr %35[%60] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%59 = llvm.load %61 : !llvm.ptr -> i64
%62 = arith.constant 0 : i32
%64 = arith.extsi %62 : i32 to i64
%63 = arith.cmpi eq, %59, %64 : i64
cf.cond_br %63, ^bb12, ^bb13
^bb12:
%65 = llvm.load %54 : !llvm.ptr -> i64
%66 = llvm.mlir.constant(1 : i64) : i64
%67 = llvm.alloca %66 x i64 : (i64) -> !llvm.ptr
llvm.store %65, %67 : i64, !llvm.ptr
cf.br ^bb15
^bb15:
%68 = llvm.load %67 : !llvm.ptr -> i64
%69 = llvm.mlir.addressof @M : !llvm.ptr
%70 = llvm.load %69 : !llvm.ptr -> i64
%71 = arith.cmpi sle, %68, %70 : i64
cf.cond_br %71, ^bb16, ^bb17
^bb16:
%73 = llvm.load %67 : !llvm.ptr -> i64
%74 = llvm.getelementptr %35[%73] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%72 = llvm.load %74 : !llvm.ptr -> i64
%75 = arith.constant 0 : i32
%77 = arith.extsi %75 : i32 to i64
%76 = arith.cmpi eq, %72, %77 : i64
cf.cond_br %76, ^bb18, ^bb19
^bb18:
%78 = llvm.load %54 : !llvm.ptr -> i64
%79 = llvm.load %67 : !llvm.ptr -> i64
%80 = llvm.getelementptr %35[%79] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %78, %80 : i64, !llvm.ptr
cf.br ^bb20
^bb19:
cf.br ^bb20
^bb20:
%81 = llvm.load %67 : !llvm.ptr -> i64
%82 = llvm.load %54 : !llvm.ptr -> i64
%83 = arith.addi %81, %82 : i64
llvm.store %83, %67 : i64, !llvm.ptr
cf.br ^bb15
^bb17:
cf.br ^bb14
^bb13:
cf.br ^bb14
^bb14:
%84 = llvm.load %54 : !llvm.ptr -> i64
%85 = arith.constant 1 : i32
%87 = arith.extsi %85 : i32 to i64
%86 = arith.addi %84, %87 : i64
llvm.store %86, %54 : i64, !llvm.ptr
cf.br ^bb9
^bb11:
%88 = arith.constant 1 : i32
%89 = arith.constant 1 : i32
%90 = arith.extsi %88 : i32 to i64
%91 = arith.extsi %89 : i32 to i64
%92 = llvm.getelementptr %43[%91] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %90, %92 : i64, !llvm.ptr
%93 = arith.constant 2 : i32
%94 = arith.extsi %93 : i32 to i64
llvm.store %94, %54 : i64, !llvm.ptr
cf.br ^bb21
^bb21:
%95 = llvm.load %54 : !llvm.ptr -> i64
%96 = llvm.mlir.addressof @M : !llvm.ptr
%97 = llvm.load %96 : !llvm.ptr -> i64
%98 = arith.cmpi sle, %95, %97 : i64
cf.cond_br %98, ^bb22, ^bb23
^bb22:
%100 = llvm.load %54 : !llvm.ptr -> i64
%101 = llvm.getelementptr %35[%100] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%99 = llvm.load %101 : !llvm.ptr -> i64
%102 = llvm.load %54 : !llvm.ptr -> i64
%103 = arith.divsi %102, %99 : i64
%104 = arith.remsi %103, %99 : i64
%105 = arith.constant 0 : i32
%107 = arith.extsi %105 : i32 to i64
%106 = arith.cmpi eq, %104, %107 : i64
cf.cond_br %106, ^bb24, ^bb25
^bb24:
%108 = arith.constant 0 : i32
%109 = llvm.load %54 : !llvm.ptr -> i64
%110 = arith.extsi %108 : i32 to i64
%111 = llvm.getelementptr %43[%109] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %110, %111 : i64, !llvm.ptr
cf.br ^bb26
^bb25:
%112 = arith.constant 0 : i32
%114 = llvm.getelementptr %43[%103] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%113 = llvm.load %114 : !llvm.ptr -> i64
%116 = arith.extsi %112 : i32 to i64
%115 = arith.subi %116, %113 : i64
%117 = llvm.load %54 : !llvm.ptr -> i64
%118 = llvm.getelementptr %43[%117] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %115, %118 : i64, !llvm.ptr
cf.br ^bb26
^bb26:
%119 = llvm.load %54 : !llvm.ptr -> i64
%120 = arith.constant 1 : i32
%122 = arith.extsi %120 : i32 to i64
%121 = arith.addi %119, %122 : i64
llvm.store %121, %54 : i64, !llvm.ptr
cf.br ^bb21
^bb23:
%123 = arith.constant 0 : i32
%124 = arith.extsi %123 : i32 to i128
%125 = llvm.mlir.constant(1 : i64) : i64
%126 = llvm.alloca %125 x i128 : (i64) -> !llvm.ptr
llvm.store %124, %126 : i128, !llvm.ptr
%127 = arith.constant 0 : i32
%128 = arith.extsi %127 : i32 to i128
%129 = llvm.mlir.constant(1 : i64) : i64
%130 = llvm.alloca %129 x i128 : (i64) -> !llvm.ptr
llvm.store %128, %130 : i128, !llvm.ptr
%131 = arith.constant 0 : i32
%132 = arith.extsi %131 : i32 to i128
%133 = llvm.mlir.constant(1 : i64) : i64
%134 = llvm.alloca %133 x i128 : (i64) -> !llvm.ptr
llvm.store %132, %134 : i128, !llvm.ptr
%135 = arith.constant 0 : i32
%136 = arith.extsi %135 : i32 to i128
%137 = llvm.mlir.constant(1 : i64) : i64
%138 = llvm.alloca %137 x i128 : (i64) -> !llvm.ptr
llvm.store %136, %138 : i128, !llvm.ptr
%139 = arith.constant 0 : i32
%140 = arith.extsi %139 : i32 to i128
%141 = llvm.mlir.constant(1 : i64) : i64
%142 = llvm.alloca %141 x i128 : (i64) -> !llvm.ptr
llvm.store %140, %142 : i128, !llvm.ptr
%143 = arith.constant 0 : i32
%144 = arith.extsi %143 : i32 to i128
%145 = llvm.mlir.constant(1 : i64) : i64
%146 = llvm.alloca %145 x i128 : (i64) -> !llvm.ptr
llvm.store %144, %146 : i128, !llvm.ptr
%147 = arith.constant 0 : i32
%148 = arith.extsi %147 : i32 to i128
%149 = llvm.mlir.constant(1 : i64) : i64
%150 = llvm.alloca %149 x i128 : (i64) -> !llvm.ptr
llvm.store %148, %150 : i128, !llvm.ptr
%151 = arith.constant 0 : i32
%152 = arith.extsi %151 : i32 to i128
%153 = llvm.mlir.constant(1 : i64) : i64
%154 = llvm.alloca %153 x i128 : (i64) -> !llvm.ptr
llvm.store %152, %154 : i128, !llvm.ptr
%155 = arith.constant 0 : i32
%156 = arith.extsi %155 : i32 to i128
%157 = llvm.mlir.constant(1 : i64) : i64
%158 = llvm.alloca %157 x i128 : (i64) -> !llvm.ptr
llvm.store %156, %158 : i128, !llvm.ptr
%159 = arith.constant 0 : i32
%160 = arith.extsi %159 : i32 to i128
%161 = llvm.mlir.constant(1 : i64) : i64
%162 = llvm.alloca %161 x i128 : (i64) -> !llvm.ptr
llvm.store %160, %162 : i128, !llvm.ptr
%163 = arith.constant 0 : i32
%164 = arith.extsi %163 : i32 to i128
%165 = llvm.mlir.constant(1 : i64) : i64
%166 = llvm.alloca %165 x i128 : (i64) -> !llvm.ptr
llvm.store %164, %166 : i128, !llvm.ptr
%167 = arith.constant 0 : i32
%168 = arith.extsi %167 : i32 to i128
%169 = llvm.mlir.constant(1 : i64) : i64
%170 = llvm.alloca %169 x i128 : (i64) -> !llvm.ptr
llvm.store %168, %170 : i128, !llvm.ptr
%171 = arith.constant 1 : i32
%172 = arith.extsi %171 : i32 to i64
%173 = llvm.mlir.constant(1 : i64) : i64
%174 = llvm.alloca %173 x i64 : (i64) -> !llvm.ptr
llvm.store %172, %174 : i64, !llvm.ptr
cf.br ^bb27
^bb27:
%175 = llvm.load %174 : !llvm.ptr -> i64
%176 = llvm.mlir.addressof @M : !llvm.ptr
%177 = llvm.load %176 : !llvm.ptr -> i64
%178 = arith.cmpi sle, %175, %177 : i64
cf.cond_br %178, ^bb28, ^bb29
^bb28:
%180 = llvm.load %174 : !llvm.ptr -> i64
%181 = llvm.getelementptr %43[%180] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%179 = llvm.load %181 : !llvm.ptr -> i64
%182 = arith.constant 0 : i32
%184 = arith.extsi %182 : i32 to i64
%183 = arith.cmpi ne, %179, %184 : i64
cf.cond_br %183, ^bb30, ^bb31
^bb30:
%185 = llvm.mlir.addressof @M : !llvm.ptr
%186 = llvm.load %185 : !llvm.ptr -> i64
%187 = llvm.load %174 : !llvm.ptr -> i64
%188 = arith.divsi %186, %187 : i64
%189 = arith.constant 5 : i32
%191 = arith.extsi %189 : i32 to i64
%190 = arith.divsi %188, %191 : i64
%192 = arith.extsi %179 : i64 to i128
%193 = llvm.load %174 : !llvm.ptr -> i64
%194 = func.call @tri(%188) : (i64) -> i64
%195 = arith.muli %193, %194 : i64
%196 = llvm.mlir.constant(1 : i64) : i64
%197 = llvm.alloca %196 x i64 : (i64) -> !llvm.ptr
llvm.store %195, %197 : i64, !llvm.ptr
%198 = llvm.mlir.constant(1 : i64) : i64
%199 = llvm.alloca %198 x i64 : (i64) -> !llvm.ptr
llvm.store %188, %199 : i64, !llvm.ptr
%200 = llvm.load %174 : !llvm.ptr -> i64
%201 = arith.constant 1 : i32
%203 = arith.extsi %201 : i32 to i64
%202 = arith.cmpi eq, %200, %203 : i64
cf.cond_br %202, ^bb33, ^bb34
^bb33:
%204 = llvm.load %197 : !llvm.ptr -> i64
%205 = arith.constant 1 : i32
%207 = arith.extsi %205 : i32 to i64
%206 = arith.subi %204, %207 : i64
llvm.store %206, %197 : i64, !llvm.ptr
%208 = llvm.load %199 : !llvm.ptr -> i64
%209 = arith.constant 1 : i32
%211 = arith.extsi %209 : i32 to i64
%210 = arith.subi %208, %211 : i64
llvm.store %210, %199 : i64, !llvm.ptr
cf.br ^bb35
^bb34:
cf.br ^bb35
^bb35:
%212 = llvm.load %126 : !llvm.ptr -> i128
%213 = llvm.load %197 : !llvm.ptr -> i64
%214 = arith.extsi %213 : i64 to i128
%216 = arith.trunci %192 : i128 to i64
%217 = arith.trunci %214 : i128 to i64
%215 = arith.muli %216, %217 : i64
%218 = llvm.load %197 : !llvm.ptr -> i64
%219 = arith.extsi %218 : i64 to i128
%221 = arith.trunci %219 : i128 to i64
%220 = arith.muli %215, %221 : i64
%223 = arith.trunci %212 : i128 to i64
%222 = arith.addi %223, %220 : i64
%224 = arith.extsi %222 : i64 to i128
llvm.store %224, %126 : i128, !llvm.ptr
%225 = llvm.load %142 : !llvm.ptr -> i128
%226 = arith.constant 2 : i32
%227 = llvm.load %197 : !llvm.ptr -> i64
%229 = arith.extsi %226 : i32 to i64
%228 = arith.muli %229, %227 : i64
%230 = arith.extsi %228 : i64 to i128
%232 = arith.trunci %192 : i128 to i64
%233 = arith.trunci %230 : i128 to i64
%231 = arith.muli %232, %233 : i64
%234 = llvm.load %199 : !llvm.ptr -> i64
%235 = arith.extsi %234 : i64 to i128
%237 = arith.trunci %235 : i128 to i64
%236 = arith.muli %231, %237 : i64
%239 = arith.trunci %225 : i128 to i64
%238 = arith.addi %239, %236 : i64
%240 = arith.extsi %238 : i64 to i128
llvm.store %240, %142 : i128, !llvm.ptr
%241 = llvm.load %158 : !llvm.ptr -> i128
%242 = llvm.load %199 : !llvm.ptr -> i64
%243 = llvm.load %199 : !llvm.ptr -> i64
%244 = arith.muli %242, %243 : i64
%245 = arith.extsi %244 : i64 to i128
%247 = arith.trunci %192 : i128 to i64
%248 = arith.trunci %245 : i128 to i64
%246 = arith.muli %247, %248 : i64
%250 = arith.trunci %241 : i128 to i64
%249 = arith.addi %250, %246 : i64
%251 = arith.extsi %249 : i64 to i128
llvm.store %251, %158 : i128, !llvm.ptr
%252 = llvm.load %174 : !llvm.ptr -> i64
%253 = arith.constant 2 : i32
%255 = arith.extsi %253 : i32 to i64
%254 = arith.remsi %252, %255 : i64
%256 = arith.constant 1 : i32
%258 = arith.extsi %256 : i32 to i64
%257 = arith.cmpi eq, %254, %258 : i64
cf.cond_br %257, ^bb36, ^bb37
^bb36:
%259 = llvm.load %174 : !llvm.ptr -> i64
%260 = func.call @sum_odd(%188) : (i64) -> i64
%261 = arith.muli %259, %260 : i64
llvm.store %261, %197 : i64, !llvm.ptr
%262 = func.call @cnt_odd(%188) : (i64) -> i64
llvm.store %262, %199 : i64, !llvm.ptr
%263 = llvm.load %174 : !llvm.ptr -> i64
%264 = arith.constant 1 : i32
%266 = arith.extsi %264 : i32 to i64
%265 = arith.cmpi eq, %263, %266 : i64
cf.cond_br %265, ^bb39, ^bb40
^bb39:
%267 = llvm.load %197 : !llvm.ptr -> i64
%268 = arith.constant 1 : i32
%270 = arith.extsi %268 : i32 to i64
%269 = arith.subi %267, %270 : i64
llvm.store %269, %197 : i64, !llvm.ptr
%271 = llvm.load %199 : !llvm.ptr -> i64
%272 = arith.constant 1 : i32
%274 = arith.extsi %272 : i32 to i64
%273 = arith.subi %271, %274 : i64
llvm.store %273, %199 : i64, !llvm.ptr
cf.br ^bb41
^bb40:
cf.br ^bb41
^bb41:
%275 = llvm.load %130 : !llvm.ptr -> i128
%276 = llvm.load %197 : !llvm.ptr -> i64
%277 = arith.extsi %276 : i64 to i128
%279 = arith.trunci %192 : i128 to i64
%280 = arith.trunci %277 : i128 to i64
%278 = arith.muli %279, %280 : i64
%281 = llvm.load %197 : !llvm.ptr -> i64
%282 = arith.extsi %281 : i64 to i128
%284 = arith.trunci %282 : i128 to i64
%283 = arith.muli %278, %284 : i64
%286 = arith.trunci %275 : i128 to i64
%285 = arith.addi %286, %283 : i64
%287 = arith.extsi %285 : i64 to i128
llvm.store %287, %130 : i128, !llvm.ptr
%288 = llvm.load %146 : !llvm.ptr -> i128
%289 = arith.constant 2 : i32
%290 = llvm.load %197 : !llvm.ptr -> i64
%292 = arith.extsi %289 : i32 to i64
%291 = arith.muli %292, %290 : i64
%293 = arith.extsi %291 : i64 to i128
%295 = arith.trunci %192 : i128 to i64
%296 = arith.trunci %293 : i128 to i64
%294 = arith.muli %295, %296 : i64
%297 = llvm.load %199 : !llvm.ptr -> i64
%298 = arith.extsi %297 : i64 to i128
%300 = arith.trunci %298 : i128 to i64
%299 = arith.muli %294, %300 : i64
%302 = arith.trunci %288 : i128 to i64
%301 = arith.addi %302, %299 : i64
%303 = arith.extsi %301 : i64 to i128
llvm.store %303, %146 : i128, !llvm.ptr
%304 = llvm.load %162 : !llvm.ptr -> i128
%305 = llvm.load %199 : !llvm.ptr -> i64
%306 = llvm.load %199 : !llvm.ptr -> i64
%307 = arith.muli %305, %306 : i64
%308 = arith.extsi %307 : i64 to i128
%310 = arith.trunci %192 : i128 to i64
%311 = arith.trunci %308 : i128 to i64
%309 = arith.muli %310, %311 : i64
%313 = arith.trunci %304 : i128 to i64
%312 = arith.addi %313, %309 : i64
%314 = arith.extsi %312 : i64 to i128
llvm.store %314, %162 : i128, !llvm.ptr
cf.br ^bb38
^bb37:
cf.br ^bb38
^bb38:
%315 = llvm.load %174 : !llvm.ptr -> i64
%316 = arith.constant 5 : i32
%318 = arith.extsi %316 : i32 to i64
%317 = arith.remsi %315, %318 : i64
%319 = arith.constant 0 : i32
%321 = arith.extsi %319 : i32 to i64
%320 = arith.cmpi ne, %317, %321 : i64
cf.cond_br %320, ^bb42, ^bb43
^bb42:
%322 = llvm.load %174 : !llvm.ptr -> i64
%323 = func.call @tri(%188) : (i64) -> i64
%324 = arith.constant 5 : i32
%325 = func.call @tri(%190) : (i64) -> i64
%327 = arith.extsi %324 : i32 to i64
%326 = arith.muli %327, %325 : i64
%328 = arith.subi %323, %326 : i64
%329 = arith.muli %322, %328 : i64
llvm.store %329, %197 : i64, !llvm.ptr
%330 = arith.subi %188, %190 : i64
llvm.store %330, %199 : i64, !llvm.ptr
%331 = llvm.load %174 : !llvm.ptr -> i64
%332 = arith.constant 1 : i32
%334 = arith.extsi %332 : i32 to i64
%333 = arith.cmpi eq, %331, %334 : i64
cf.cond_br %333, ^bb45, ^bb46
^bb45:
%335 = llvm.load %197 : !llvm.ptr -> i64
%336 = arith.constant 1 : i32
%338 = arith.extsi %336 : i32 to i64
%337 = arith.subi %335, %338 : i64
llvm.store %337, %197 : i64, !llvm.ptr
%339 = llvm.load %199 : !llvm.ptr -> i64
%340 = arith.constant 1 : i32
%342 = arith.extsi %340 : i32 to i64
%341 = arith.subi %339, %342 : i64
llvm.store %341, %199 : i64, !llvm.ptr
cf.br ^bb47
^bb46:
cf.br ^bb47
^bb47:
%343 = llvm.load %134 : !llvm.ptr -> i128
%344 = llvm.load %197 : !llvm.ptr -> i64
%345 = arith.extsi %344 : i64 to i128
%347 = arith.trunci %192 : i128 to i64
%348 = arith.trunci %345 : i128 to i64
%346 = arith.muli %347, %348 : i64
%349 = llvm.load %197 : !llvm.ptr -> i64
%350 = arith.extsi %349 : i64 to i128
%352 = arith.trunci %350 : i128 to i64
%351 = arith.muli %346, %352 : i64
%354 = arith.trunci %343 : i128 to i64
%353 = arith.addi %354, %351 : i64
%355 = arith.extsi %353 : i64 to i128
llvm.store %355, %134 : i128, !llvm.ptr
%356 = llvm.load %150 : !llvm.ptr -> i128
%357 = arith.constant 2 : i32
%358 = llvm.load %197 : !llvm.ptr -> i64
%360 = arith.extsi %357 : i32 to i64
%359 = arith.muli %360, %358 : i64
%361 = arith.extsi %359 : i64 to i128
%363 = arith.trunci %192 : i128 to i64
%364 = arith.trunci %361 : i128 to i64
%362 = arith.muli %363, %364 : i64
%365 = llvm.load %199 : !llvm.ptr -> i64
%366 = arith.extsi %365 : i64 to i128
%368 = arith.trunci %366 : i128 to i64
%367 = arith.muli %362, %368 : i64
%370 = arith.trunci %356 : i128 to i64
%369 = arith.addi %370, %367 : i64
%371 = arith.extsi %369 : i64 to i128
llvm.store %371, %150 : i128, !llvm.ptr
%372 = llvm.load %166 : !llvm.ptr -> i128
%373 = llvm.load %199 : !llvm.ptr -> i64
%374 = llvm.load %199 : !llvm.ptr -> i64
%375 = arith.muli %373, %374 : i64
%376 = arith.extsi %375 : i64 to i128
%378 = arith.trunci %192 : i128 to i64
%379 = arith.trunci %376 : i128 to i64
%377 = arith.muli %378, %379 : i64
%381 = arith.trunci %372 : i128 to i64
%380 = arith.addi %381, %377 : i64
%382 = arith.extsi %380 : i64 to i128
llvm.store %382, %166 : i128, !llvm.ptr
cf.br ^bb44
^bb43:
cf.br ^bb44
^bb44:
%383 = llvm.load %174 : !llvm.ptr -> i64
%384 = arith.constant 2 : i32
%386 = arith.extsi %384 : i32 to i64
%385 = arith.remsi %383, %386 : i64
%387 = arith.constant 1 : i32
%389 = arith.extsi %387 : i32 to i64
%388 = arith.cmpi eq, %385, %389 : i64
%390 = scf.if %388 -> (i1) {
%391 = llvm.load %174 : !llvm.ptr -> i64
%392 = arith.constant 5 : i32
%394 = arith.extsi %392 : i32 to i64
%393 = arith.remsi %391, %394 : i64
%395 = arith.constant 0 : i32
%397 = arith.extsi %395 : i32 to i64
%396 = arith.cmpi ne, %393, %397 : i64
scf.yield %396 : i1
} else {
%398 = arith.constant false
scf.yield %398 : i1
}
cf.cond_br %390, ^bb48, ^bb49
^bb48:
%399 = llvm.load %174 : !llvm.ptr -> i64
%400 = func.call @sum_odd(%188) : (i64) -> i64
%401 = arith.constant 5 : i32
%402 = func.call @sum_odd(%190) : (i64) -> i64
%404 = arith.extsi %401 : i32 to i64
%403 = arith.muli %404, %402 : i64
%405 = arith.subi %400, %403 : i64
%406 = arith.muli %399, %405 : i64
llvm.store %406, %197 : i64, !llvm.ptr
%407 = func.call @cnt_odd(%188) : (i64) -> i64
%408 = func.call @cnt_odd(%190) : (i64) -> i64
%409 = arith.subi %407, %408 : i64
llvm.store %409, %199 : i64, !llvm.ptr
%410 = llvm.load %174 : !llvm.ptr -> i64
%411 = arith.constant 1 : i32
%413 = arith.extsi %411 : i32 to i64
%412 = arith.cmpi eq, %410, %413 : i64
cf.cond_br %412, ^bb51, ^bb52
^bb51:
%414 = llvm.load %197 : !llvm.ptr -> i64
%415 = arith.constant 1 : i32
%417 = arith.extsi %415 : i32 to i64
%416 = arith.subi %414, %417 : i64
llvm.store %416, %197 : i64, !llvm.ptr
%418 = llvm.load %199 : !llvm.ptr -> i64
%419 = arith.constant 1 : i32
%421 = arith.extsi %419 : i32 to i64
%420 = arith.subi %418, %421 : i64
llvm.store %420, %199 : i64, !llvm.ptr
cf.br ^bb53
^bb52:
cf.br ^bb53
^bb53:
%422 = llvm.load %138 : !llvm.ptr -> i128
%423 = llvm.load %197 : !llvm.ptr -> i64
%424 = arith.extsi %423 : i64 to i128
%426 = arith.trunci %192 : i128 to i64
%427 = arith.trunci %424 : i128 to i64
%425 = arith.muli %426, %427 : i64
%428 = llvm.load %197 : !llvm.ptr -> i64
%429 = arith.extsi %428 : i64 to i128
%431 = arith.trunci %429 : i128 to i64
%430 = arith.muli %425, %431 : i64
%433 = arith.trunci %422 : i128 to i64
%432 = arith.addi %433, %430 : i64
%434 = arith.extsi %432 : i64 to i128
llvm.store %434, %138 : i128, !llvm.ptr
%435 = llvm.load %154 : !llvm.ptr -> i128
%436 = arith.constant 2 : i32
%437 = llvm.load %197 : !llvm.ptr -> i64
%439 = arith.extsi %436 : i32 to i64
%438 = arith.muli %439, %437 : i64
%440 = arith.extsi %438 : i64 to i128
%442 = arith.trunci %192 : i128 to i64
%443 = arith.trunci %440 : i128 to i64
%441 = arith.muli %442, %443 : i64
%444 = llvm.load %199 : !llvm.ptr -> i64
%445 = arith.extsi %444 : i64 to i128
%447 = arith.trunci %445 : i128 to i64
%446 = arith.muli %441, %447 : i64
%449 = arith.trunci %435 : i128 to i64
%448 = arith.addi %449, %446 : i64
%450 = arith.extsi %448 : i64 to i128
llvm.store %450, %154 : i128, !llvm.ptr
%451 = llvm.load %170 : !llvm.ptr -> i128
%452 = llvm.load %199 : !llvm.ptr -> i64
%453 = llvm.load %199 : !llvm.ptr -> i64
%454 = arith.muli %452, %453 : i64
%455 = arith.extsi %454 : i64 to i128
%457 = arith.trunci %192 : i128 to i64
%458 = arith.trunci %455 : i128 to i64
%456 = arith.muli %457, %458 : i64
%460 = arith.trunci %451 : i128 to i64
%459 = arith.addi %460, %456 : i64
%461 = arith.extsi %459 : i64 to i128
llvm.store %461, %170 : i128, !llvm.ptr
cf.br ^bb50
^bb49:
cf.br ^bb50
^bb50:
cf.br ^bb32
^bb31:
cf.br ^bb32
^bb32:
%462 = llvm.load %174 : !llvm.ptr -> i64
%463 = arith.constant 1 : i32
%465 = arith.extsi %463 : i32 to i64
%464 = arith.addi %462, %465 : i64
llvm.store %464, %174 : i64, !llvm.ptr
cf.br ^bb27
^bb29:
%466 = arith.constant 6 : i32
%467 = arith.extsi %466 : i32 to i128
%468 = llvm.load %126 : !llvm.ptr -> i128
%470 = arith.trunci %467 : i128 to i64
%471 = arith.trunci %468 : i128 to i64
%469 = arith.muli %470, %471 : i64
%472 = arith.constant 3 : i32
%473 = arith.extsi %472 : i32 to i128
%474 = llvm.load %142 : !llvm.ptr -> i128
%476 = arith.trunci %473 : i128 to i64
%477 = arith.trunci %474 : i128 to i64
%475 = arith.muli %476, %477 : i64
%478 = arith.subi %469, %475 : i64
%479 = arith.constant 4 : i32
%480 = arith.extsi %479 : i32 to i128
%481 = llvm.load %158 : !llvm.ptr -> i128
%483 = arith.trunci %480 : i128 to i64
%484 = arith.trunci %481 : i128 to i64
%482 = arith.muli %483, %484 : i64
%485 = arith.subi %478, %482 : i64
%486 = arith.extsi %485 : i64 to i128
%487 = arith.constant 6 : i32
%488 = arith.extsi %487 : i32 to i128
%489 = llvm.load %130 : !llvm.ptr -> i128
%491 = arith.trunci %488 : i128 to i64
%492 = arith.trunci %489 : i128 to i64
%490 = arith.muli %491, %492 : i64
%493 = arith.constant 3 : i32
%494 = arith.extsi %493 : i32 to i128
%495 = llvm.load %146 : !llvm.ptr -> i128
%497 = arith.trunci %494 : i128 to i64
%498 = arith.trunci %495 : i128 to i64
%496 = arith.muli %497, %498 : i64
%499 = arith.subi %490, %496 : i64
%500 = arith.constant 4 : i32
%501 = arith.extsi %500 : i32 to i128
%502 = llvm.load %162 : !llvm.ptr -> i128
%504 = arith.trunci %501 : i128 to i64
%505 = arith.trunci %502 : i128 to i64
%503 = arith.muli %504, %505 : i64
%506 = arith.subi %499, %503 : i64
%507 = arith.extsi %506 : i64 to i128
%508 = arith.constant 6 : i32
%509 = arith.extsi %508 : i32 to i128
%510 = llvm.load %134 : !llvm.ptr -> i128
%512 = arith.trunci %509 : i128 to i64
%513 = arith.trunci %510 : i128 to i64
%511 = arith.muli %512, %513 : i64
%514 = arith.constant 3 : i32
%515 = arith.extsi %514 : i32 to i128
%516 = llvm.load %150 : !llvm.ptr -> i128
%518 = arith.trunci %515 : i128 to i64
%519 = arith.trunci %516 : i128 to i64
%517 = arith.muli %518, %519 : i64
%520 = arith.subi %511, %517 : i64
%521 = arith.constant 4 : i32
%522 = arith.extsi %521 : i32 to i128
%523 = llvm.load %166 : !llvm.ptr -> i128
%525 = arith.trunci %522 : i128 to i64
%526 = arith.trunci %523 : i128 to i64
%524 = arith.muli %525, %526 : i64
%527 = arith.subi %520, %524 : i64
%528 = arith.extsi %527 : i64 to i128
%529 = arith.constant 6 : i32
%530 = arith.extsi %529 : i32 to i128
%531 = llvm.load %138 : !llvm.ptr -> i128
%533 = arith.trunci %530 : i128 to i64
%534 = arith.trunci %531 : i128 to i64
%532 = arith.muli %533, %534 : i64
%535 = arith.constant 3 : i32
%536 = arith.extsi %535 : i32 to i128
%537 = llvm.load %154 : !llvm.ptr -> i128
%539 = arith.trunci %536 : i128 to i64
%540 = arith.trunci %537 : i128 to i64
%538 = arith.muli %539, %540 : i64
%541 = arith.subi %532, %538 : i64
%542 = arith.constant 4 : i32
%543 = arith.extsi %542 : i32 to i128
%544 = llvm.load %170 : !llvm.ptr -> i128
%546 = arith.trunci %543 : i128 to i64
%547 = arith.trunci %544 : i128 to i64
%545 = arith.muli %546, %547 : i64
%548 = arith.subi %541, %545 : i64
%549 = arith.extsi %548 : i64 to i128
%550 = arith.constant 8 : i32
%551 = arith.extsi %550 : i32 to i128
%552 = llvm.load %126 : !llvm.ptr -> i128
%554 = arith.trunci %551 : i128 to i64
%555 = arith.trunci %552 : i128 to i64
%553 = arith.muli %554, %555 : i64
%556 = arith.constant 6 : i32
%557 = arith.extsi %556 : i32 to i128
%558 = llvm.load %142 : !llvm.ptr -> i128
%560 = arith.trunci %557 : i128 to i64
%561 = arith.trunci %558 : i128 to i64
%559 = arith.muli %560, %561 : i64
%562 = arith.subi %553, %559 : i64
%564 = arith.trunci %486 : i128 to i64
%565 = arith.trunci %507 : i128 to i64
%563 = arith.subi %564, %565 : i64
%567 = arith.trunci %528 : i128 to i64
%566 = arith.subi %563, %567 : i64
%569 = arith.trunci %549 : i128 to i64
%568 = arith.addi %566, %569 : i64
%570 = arith.subi %562, %568 : i64
%571 = arith.extsi %570 : i64 to i128
%572 = arith.constant 25 : i32
%573 = arith.extsi %572 : i32 to i128
%575 = arith.trunci %571 : i128 to i64
%576 = arith.trunci %573 : i128 to i64
%574 = arith.muli %575, %576 : i64
%577 = arith.extsi %574 : i64 to i128
%579 = arith.constant 64 : i32
%580 = arith.constant 8 : i32
%581 = arith.extsi %579 : i32 to i64
%582 = arith.extsi %580 : i32 to i64
%578 = func.call @calloc(%581, %582) : (i64, i64) -> !llvm.ptr
%583 = arith.constant 0 : i32
%584 = arith.extsi %583 : i32 to i64
%585 = llvm.mlir.constant(1 : i64) : i64
%586 = llvm.alloca %585 x i64 : (i64) -> !llvm.ptr
llvm.store %584, %586 : i64, !llvm.ptr
%587 = llvm.mlir.constant(1 : i64) : i64
%588 = llvm.alloca %587 x i128 : (i64) -> !llvm.ptr
llvm.store %577, %588 : i128, !llvm.ptr
cf.br ^bb54
^bb54:
%589 = llvm.load %588 : !llvm.ptr -> i128
%590 = arith.constant 0 : i32
%591 = arith.extsi %590 : i32 to i128
%593 = arith.trunci %589 : i128 to i64
%594 = arith.trunci %591 : i128 to i64
%592 = arith.cmpi sgt, %593, %594 : i64
cf.cond_br %592, ^bb55, ^bb56
^bb55:
%595 = llvm.load %588 : !llvm.ptr -> i128
%596 = arith.constant 10 : i32
%597 = arith.extsi %596 : i32 to i128
%599 = arith.trunci %595 : i128 to i64
%600 = arith.trunci %597 : i128 to i64
%598 = arith.remsi %599, %600 : i64
%601 = llvm.load %586 : !llvm.ptr -> i64
%602 = llvm.getelementptr %578[%601] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %598, %602 : i64, !llvm.ptr
%603 = llvm.load %588 : !llvm.ptr -> i128
%604 = arith.constant 10 : i32
%605 = arith.extsi %604 : i32 to i128
%607 = arith.trunci %603 : i128 to i64
%608 = arith.trunci %605 : i128 to i64
%606 = arith.divsi %607, %608 : i64
%609 = arith.extsi %606 : i64 to i128
llvm.store %609, %588 : i128, !llvm.ptr
%610 = llvm.load %586 : !llvm.ptr -> i64
%611 = arith.constant 1 : i32
%613 = arith.extsi %611 : i32 to i64
%612 = arith.addi %610, %613 : i64
llvm.store %612, %586 : i64, !llvm.ptr
cf.br ^bb54
^bb56:
%615 = arith.constant 10 : i32
%616 = arith.constant 8 : i32
%617 = arith.extsi %615 : i32 to i64
%618 = arith.extsi %616 : i32 to i64
%614 = func.call @calloc(%617, %618) : (i64, i64) -> !llvm.ptr
%619 = arith.constant 0 : i32
%620 = arith.extsi %619 : i32 to i64
llvm.store %620, %54 : i64, !llvm.ptr
cf.br ^bb57
^bb57:
%621 = llvm.load %54 : !llvm.ptr -> i64
%622 = arith.constant 10 : i32
%624 = arith.extsi %622 : i32 to i64
%623 = arith.cmpi slt, %621, %624 : i64
cf.cond_br %623, ^bb58, ^bb59
^bb58:
%625 = llvm.load %54 : !llvm.ptr -> i64
%626 = llvm.load %586 : !llvm.ptr -> i64
%627 = arith.cmpi slt, %625, %626 : i64
cf.cond_br %627, ^bb60, ^bb61
^bb60:
%629 = llvm.load %586 : !llvm.ptr -> i64
%630 = arith.constant 1 : i32
%632 = arith.extsi %630 : i32 to i64
%631 = arith.subi %629, %632 : i64
%633 = llvm.load %54 : !llvm.ptr -> i64
%634 = arith.subi %631, %633 : i64
%635 = llvm.getelementptr %578[%634] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%628 = llvm.load %635 : !llvm.ptr -> i64
%636 = llvm.load %54 : !llvm.ptr -> i64
%637 = llvm.getelementptr %614[%636] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %628, %637 : i64, !llvm.ptr
cf.br ^bb62
^bb61:
%638 = arith.constant 0 : i32
%639 = llvm.load %54 : !llvm.ptr -> i64
%640 = arith.extsi %638 : i32 to i64
%641 = llvm.getelementptr %614[%639] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %640, %641 : i64, !llvm.ptr
cf.br ^bb62
^bb62:
%642 = llvm.load %54 : !llvm.ptr -> i64
%643 = arith.constant 1 : i32
%645 = arith.extsi %643 : i32 to i64
%644 = arith.addi %642, %645 : i64
llvm.store %644, %54 : i64, !llvm.ptr
cf.br ^bb57
^bb59:
%646 = llvm.load %586 : !llvm.ptr -> i64
%647 = arith.constant 1 : i32
%649 = arith.extsi %647 : i32 to i64
%648 = arith.subi %646, %649 : i64
%650 = arith.constant 2 : i32
%652 = arith.extsi %650 : i32 to i64
%651 = arith.subi %648, %652 : i64
%653 = llvm.mlir.constant(1 : i64) : i64
%654 = llvm.alloca %653 x i64 : (i64) -> !llvm.ptr
llvm.store %651, %654 : i64, !llvm.ptr
%655 = llvm.load %586 : !llvm.ptr -> i64
%656 = arith.constant 10 : i32
%658 = arith.extsi %656 : i32 to i64
%657 = arith.cmpi sgt, %655, %658 : i64
%659 = scf.if %657 -> (i1) {
%661 = llvm.load %586 : !llvm.ptr -> i64
%662 = arith.constant 11 : i32
%664 = arith.extsi %662 : i32 to i64
%663 = arith.subi %661, %664 : i64
%665 = llvm.getelementptr %578[%663] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%660 = llvm.load %665 : !llvm.ptr -> i64
%666 = arith.constant 5 : i32
%668 = arith.extsi %666 : i32 to i64
%667 = arith.cmpi sge, %660, %668 : i64
scf.yield %667 : i1
} else {
%669 = arith.constant false
scf.yield %669 : i1
}
cf.cond_br %659, ^bb63, ^bb64
^bb63:
%670 = arith.constant 9 : i32
%671 = arith.extsi %670 : i32 to i64
%672 = llvm.mlir.constant(1 : i64) : i64
%673 = llvm.alloca %672 x i64 : (i64) -> !llvm.ptr
llvm.store %671, %673 : i64, !llvm.ptr
%674 = arith.constant 1 : i32
%675 = arith.extsi %674 : i32 to i64
%676 = llvm.mlir.constant(1 : i64) : i64
%677 = llvm.alloca %676 x i64 : (i64) -> !llvm.ptr
llvm.store %675, %677 : i64, !llvm.ptr
cf.br ^bb66
^bb66:
%678 = llvm.load %673 : !llvm.ptr -> i64
%679 = arith.constant 0 : i32
%681 = arith.extsi %679 : i32 to i64
%680 = arith.cmpi sge, %678, %681 : i64
%682 = scf.if %680 -> (i1) {
%683 = llvm.load %677 : !llvm.ptr -> i64
%684 = arith.constant 1 : i32
%686 = arith.extsi %684 : i32 to i64
%685 = arith.cmpi eq, %683, %686 : i64
scf.yield %685 : i1
} else {
%687 = arith.constant false
scf.yield %687 : i1
}
cf.cond_br %682, ^bb67, ^bb68
^bb67:
%689 = llvm.load %673 : !llvm.ptr -> i64
%690 = llvm.getelementptr %614[%689] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%688 = llvm.load %690 : !llvm.ptr -> i64
%691 = arith.constant 1 : i32
%693 = arith.extsi %691 : i32 to i64
%692 = arith.addi %688, %693 : i64
%694 = llvm.load %673 : !llvm.ptr -> i64
%695 = llvm.getelementptr %614[%694] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %692, %695 : i64, !llvm.ptr
%697 = llvm.load %673 : !llvm.ptr -> i64
%698 = llvm.getelementptr %614[%697] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%696 = llvm.load %698 : !llvm.ptr -> i64
%699 = arith.constant 10 : i32
%701 = arith.extsi %699 : i32 to i64
%700 = arith.cmpi eq, %696, %701 : i64
cf.cond_br %700, ^bb69, ^bb70
^bb69:
%702 = arith.constant 0 : i32
%703 = llvm.load %673 : !llvm.ptr -> i64
%704 = arith.extsi %702 : i32 to i64
%705 = llvm.getelementptr %614[%703] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %704, %705 : i64, !llvm.ptr
cf.br ^bb71
^bb70:
%706 = arith.constant 0 : i32
%707 = arith.extsi %706 : i32 to i64
llvm.store %707, %677 : i64, !llvm.ptr
cf.br ^bb71
^bb71:
%708 = llvm.load %673 : !llvm.ptr -> i64
%709 = arith.constant 1 : i32
%711 = arith.extsi %709 : i32 to i64
%710 = arith.subi %708, %711 : i64
llvm.store %710, %673 : i64, !llvm.ptr
cf.br ^bb66
^bb68:
%712 = llvm.load %677 : !llvm.ptr -> i64
%713 = arith.constant 1 : i32
%715 = arith.extsi %713 : i32 to i64
%714 = arith.cmpi eq, %712, %715 : i64
cf.cond_br %714, ^bb72, ^bb73
^bb72:
%716 = arith.constant 1 : i32
%717 = arith.constant 0 : i32
%718 = arith.extsi %716 : i32 to i64
%719 = arith.extsi %717 : i32 to i64
%720 = llvm.getelementptr %614[%719] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %718, %720 : i64, !llvm.ptr
%721 = arith.constant 1 : i32
%722 = arith.extsi %721 : i32 to i64
%723 = llvm.mlir.constant(1 : i64) : i64
%724 = llvm.alloca %723 x i64 : (i64) -> !llvm.ptr
llvm.store %722, %724 : i64, !llvm.ptr
cf.br ^bb75
^bb75:
%725 = llvm.load %724 : !llvm.ptr -> i64
%726 = arith.constant 10 : i32
%728 = arith.extsi %726 : i32 to i64
%727 = arith.cmpi slt, %725, %728 : i64
cf.cond_br %727, ^bb76, ^bb77
^bb76:
%729 = arith.constant 0 : i32
%730 = llvm.load %724 : !llvm.ptr -> i64
%731 = arith.extsi %729 : i32 to i64
%732 = llvm.getelementptr %614[%730] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %731, %732 : i64, !llvm.ptr
%733 = llvm.load %724 : !llvm.ptr -> i64
%734 = arith.constant 1 : i32
%736 = arith.extsi %734 : i32 to i64
%735 = arith.addi %733, %736 : i64
llvm.store %735, %724 : i64, !llvm.ptr
cf.br ^bb75
^bb77:
%737 = llvm.load %654 : !llvm.ptr -> i64
%738 = arith.constant 1 : i32
%740 = arith.extsi %738 : i32 to i64
%739 = arith.addi %737, %740 : i64
llvm.store %739, %654 : i64, !llvm.ptr
cf.br ^bb74
^bb73:
cf.br ^bb74
^bb74:
cf.br ^bb65
^bb64:
cf.br ^bb65
^bb65:
%741 = llvm.mlir.addressof @str_0 : !llvm.ptr
%743 = arith.constant 0 : i32
%744 = arith.extsi %743 : i32 to i64
%745 = llvm.getelementptr %614[%744] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%742 = llvm.load %745 : !llvm.ptr -> i64
%746 = llvm.call @printf(%741, %742) vararg(!llvm.func<i32 (ptr, ...)>) : (!llvm.ptr, i64) -> i32
%747 = arith.constant 1 : i32
%748 = arith.extsi %747 : i32 to i64
llvm.store %748, %54 : i64, !llvm.ptr
cf.br ^bb78
^bb78:
%749 = llvm.load %54 : !llvm.ptr -> i64
%750 = arith.constant 10 : i32
%752 = arith.extsi %750 : i32 to i64
%751 = arith.cmpi slt, %749, %752 : i64
cf.cond_br %751, ^bb79, ^bb80
^bb79:
%753 = llvm.mlir.addressof @str_1 : !llvm.ptr
%755 = llvm.load %54 : !llvm.ptr -> i64
%756 = llvm.getelementptr %614[%755] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%754 = llvm.load %756 : !llvm.ptr -> i64
%757 = llvm.call @printf(%753, %754) vararg(!llvm.func<i32 (ptr, ...)>) : (!llvm.ptr, i64) -> i32
%758 = llvm.load %54 : !llvm.ptr -> i64
%759 = arith.constant 1 : i32
%761 = arith.extsi %759 : i32 to i64
%760 = arith.addi %758, %761 : i64
llvm.store %760, %54 : i64, !llvm.ptr
cf.br ^bb78
^bb80:
%762 = llvm.mlir.addressof @str_2 : !llvm.ptr
%763 = llvm.load %654 : !llvm.ptr -> i64
%764 = llvm.call @printf(%762, %763) vararg(!llvm.func<i32 (ptr, ...)>) : (!llvm.ptr, i64) -> i32
func.call @free(%35) : (!llvm.ptr) -> ()
func.call @free(%43) : (!llvm.ptr) -> ()
func.call @free(%578) : (!llvm.ptr) -> ()
func.call @free(%614) : (!llvm.ptr) -> ()
%769 = arith.constant 0 : i32
func.return %769 : i32
}
}