← All problems
Problem 453
Lattice Quadrilaterals — Q(12345,6789) via coprime power sums + closed form.
View problem on Project Euler
Performance comparison
Metric Our solution Best known
Time complexity O(n)O(n log log n)
Space complexity O(n^2)O(n)
Approach Flow solution Sieve of Eratosthenes
Verdict Optimal
Flow source
# Project Euler 453
# Lattice Quadrilaterals — Q(12345,6789) via coprime power sums + closed form.
import euler.nt { isqrt }
extern {
function calloc(n: i64, size: i64) -> ptr<void>
function free(p: ptr<void>) -> void
}
const MOD: i64 = 135707531
const CAP: i64 = 2097152
let mut G_m: i64 = 0
let mut G_n: i64 = 0
let mut G_k1: ptr<i64> = null
let mut G_k2: ptr<i64> = null
let mut G_v: ptr<i128> = null
let mut G_u: ptr<i8> = null
function ipow(base: i64, e: i64) -> i128 {
let mut r: i128 = 1
let mut b: i128 = base as i128
let mut ee: i64 = e
while ee > 0 {
if (ee & 1) == 1 { r = r * b }
b = b * b
ee = ee / 2
}
return r
}
function sum_pows(t0: i64, k: i64) -> i128 {
if t0 <= 0 { return 0 as i128 }
let t: i128 = t0 as i128
if k == 0 { return t }
if k == 1 { return t * (t + 1) / 2 }
if k == 2 { return t * (t + 1) * (2 * t + 1) / 6 }
if k == 3 {
let s: i128 = t * (t + 1) / 2
return s * s
}
if k == 4 {
return t * (t + 1) * (2 * t + 1) * (3 * t * t + 3 * t - 1) / 30
}
# k==5 used? not in need list; keep general fallback unused
return 0 as i128
}
function max64(a: i64, b: i64) -> i64 {
if a > b { return a }
return b
}
function min64(a: i64, b: i64) -> i64 {
if a < b { return a }
return b
}
function G_fn(u: i64, v: i64, a: i64, b: i64) -> i128 {
if u <= 0 || v <= 0 { return 0 as i128 }
let key1: i64 = (u << 32) ^ v
let key2: i64 = (a << 8) ^ b
let mut h: i64 = (key1 * 1315423911 + key2) % CAP
if h < 0 { h = h + CAP }
while G_u[h] != 0 {
if G_k1[h] == key1 && G_k2[h] == key2 {
return G_v[h]
}
h = h + 1
if h == CAP { h = 0 }
}
let q: i64 = isqrt(u)
let mut upper: i64 = v
if u / q < upper { upper = u / q }
let mut res: i128 = sum_pows(u, a) * sum_pows(v, b)
let ab: i64 = a + b
let mut k: i64 = 2
while k <= upper {
res = res - G_fn(u / k, v / k, a, b) * ipow(k, ab)
k = k + 1
}
k = 1
while k < q {
let x: i64 = v / (u / (k + 1) + 1)
let y: i64 = v / (u / k)
if x == y {
res = res - G_fn(k, x, a, b) * (sum_pows(u / k, ab) - sum_pows(u / (k + 1), ab))
} else {
let lo: i64 = max64(u / (k + 1), v / (x + 1))
let hi: i64 = min64(u / k, v / x)
if hi > lo {
res = res - G_fn(k, x, a, b) * (sum_pows(hi, ab) - sum_pows(lo, ab))
}
if y != 0 {
let lo2: i64 = max64(u / (k + 1), v / (y + 1))
let hi2: i64 = min64(u / k, v / y)
if hi2 > lo2 {
res = res - G_fn(k, y, a, b) * (sum_pows(hi2, ab) - sum_pows(lo2, ab))
}
}
}
k = k + 1
}
G_u[h] = 1
G_k1[h] = key1
G_k2[h] = key2
G_v[h] = res
return res
}
function H_fn(a: i64, b: i64, c: i64) -> i128 {
if c == 0 {
return sum_pows(G_m, a) * sum_pows(G_n, b)
}
let q: i64 = isqrt(G_m)
let mut upper: i64 = G_n
if G_m / q < upper { upper = G_m / q }
let mut res: i128 = 0
let abc: i64 = a + b + c
let mut k: i64 = 1
while k <= upper {
res = res + G_fn(G_m / k, G_n / k, a, b) * ipow(k, abc)
k = k + 1
}
k = 1
while k < q {
let x: i64 = G_n / (G_m / (k + 1) + 1)
let y: i64 = G_n / (G_m / k)
if x == y {
res = res + G_fn(k, x, a, b) * (sum_pows(G_m / k, abc) - sum_pows(G_m / (k + 1), abc))
} else {
let lo: i64 = max64(G_m / (k + 1), G_n / (x + 1))
let hi: i64 = min64(G_m / k, G_n / x)
if hi > lo {
res = res + G_fn(k, x, a, b) * (sum_pows(hi, abc) - sum_pows(lo, abc))
}
if y != 0 {
let lo2: i64 = max64(G_m / (k + 1), G_n / (y + 1))
let hi2: i64 = min64(G_m / k, G_n / y)
if hi2 > lo2 {
res = res + G_fn(k, y, a, b) * (sum_pows(hi2, abc) - sum_pows(lo2, abc))
}
}
}
k = k + 1
}
return res
}
function f_fn(a: i64, b: i64, c: i64) -> i128 {
let mut res: i128 = H_fn(a, b, c)
if a == 0 {
res = res + sum_pows(G_n, b + c)
}
if b == 0 {
res = res + sum_pows(G_m, a + c)
}
if a + b + c == 0 {
res = res + 1
}
return res
}
function comb(n0: i128, k: i64) -> i128 {
if k < 0 { return 0 as i128 }
let mut r: i128 = 1
let mut i: i64 = 1
while i <= k {
r = r * (n0 - (i as i128) + 1) / (i as i128)
i = i + 1
}
return r
}
function Q_mod(m: i64, n: i64) -> i64 {
G_m = m
G_n = n
# clear memo
let mut i: i64 = 0
while i < CAP {
G_u[i] = 0
i = i + 1
}
let s001: i128 = f_fn(0, 0, 1)
let s011: i128 = f_fn(0, 1, 1)
let s101: i128 = f_fn(1, 0, 1)
let s111: i128 = f_fn(1, 1, 1)
let s002: i128 = f_fn(0, 0, 2)
let s012: i128 = f_fn(0, 1, 2)
let s102: i128 = f_fn(1, 0, 2)
let s112: i128 = f_fn(1, 1, 2)
let s000: i128 = f_fn(0, 0, 0)
let s010: i128 = f_fn(0, 1, 0)
let s100: i128 = f_fn(1, 0, 0)
let s110: i128 = f_fn(1, 1, 0)
let s330: i128 = f_fn(3, 3, 0)
let s320: i128 = f_fn(3, 2, 0)
let s230: i128 = f_fn(2, 3, 0)
let s220: i128 = f_fn(2, 2, 0)
let s310: i128 = f_fn(3, 1, 0)
let s210: i128 = f_fn(2, 1, 0)
let s300: i128 = f_fn(3, 0, 0)
let s200: i128 = f_fn(2, 0, 0)
let s130: i128 = f_fn(1, 3, 0)
let s120: i128 = f_fn(1, 2, 0)
let s030: i128 = f_fn(0, 3, 0)
let s020: i128 = f_fn(0, 2, 0)
let mp1: i128 = (m + 1) as i128
let np1: i128 = (n + 1) as i128
let P: i128 = mp1 * np1
let s: i128 = (s012 - 11 * s230 - s210 - s030) * mp1
+ (s102 - 11 * s320 - s300 - s120) * np1
- (s112 - 11 * s330 - s310 - s130)
- (s002 - 11 * s220 - s200 - s020) * mp1 * np1
let c3: i128 = 2 * (
(s010 - s011) * mp1
+ (s100 - s101) * np1
- (s000 - s001) * mp1 * np1
- (s110 - s111)
)
+ s020
- ((n + 2) as i128) * s010
+ np1 * s000
+ s200
- ((m + 2) as i128) * s100
+ mp1 * s000
let c4: i128 = (s000 * 4 - s001 * 6 + s002 * 2) * mp1 * np1
+ (s110 * 4 - s111 * 6 + s112 * 2)
- (s100 * 4 - s101 * 6 + s102 * 2) * np1
- (s010 * 4 - s011 * 6 + s012 * 2) * mp1
+ s030
- ((n + 4) as i128) * s020
+ ((3 * n + 5) as i128) * s010
- 2 * np1 * s000
+ s300
- ((m + 4) as i128) * s200
+ ((3 * m + 5) as i128) * s100
- 2 * mp1 * s000
let Qv: i128 = comb(P, 4) - comb(P, 3) + s / 3 + (7 - 2 * P) * c3 + 7 * (c4 / 2)
let mm: i128 = MOD as i128
let mut r: i128 = Qv % mm
if r < 0 { r = r + mm }
return r as i64
}
function main() -> i32 {
G_k1 = calloc(CAP, 8)
G_k2 = calloc(CAP, 8)
G_v = calloc(CAP, 16)
G_u = calloc(CAP, 1)
if G_k1 == null || G_k2 == null || G_v == null || G_u == null { return 1 }
printf("%lld\n", Q_mod(12345, 6789))
free(G_u)
free(G_v)
free(G_k2)
free(G_k1)
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);
__int128 ipow_i64_i64(int64_t base, int64_t e);
__int128 sum_pows_i64_i64(int64_t t0, int64_t k);
int64_t max64_i64_i64(int64_t a, int64_t b);
int64_t min64_i64_i64(int64_t a, int64_t b);
__int128 G_fn_i64_i64_i64_i64(int64_t u, int64_t v, int64_t a, int64_t b);
__int128 H_fn_i64_i64_i64(int64_t a, int64_t b, int64_t c);
__int128 f_fn_i64_i64_i64(int64_t a, int64_t b, int64_t c);
__int128 comb_i128_i64(__int128 n0, int64_t k);
int64_t Q_mod_i64_i64(int64_t m, int64_t n);
int32_t main(void);
static const int64_t MOD = 135707531;
static const int64_t CAP = 2097152;
/* Module statics */
static int64_t G_m = 0;
static int64_t G_n = 0;
static int64_t* G_k1 = NULL;
static int64_t* G_k2 = NULL;
static __int128* G_v = NULL;
static int8_t* G_u = NULL;
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;
}
__int128 ipow_i64_i64(int64_t base, int64_t e) {
__int128 r = 1;
__int128 b = ((__int128)(base));
int64_t ee = e;
while (ee > 0) {
if ((ee & 1) == 1) {
r = (r * b);
}
b = (b * b);
ee = FLOW_CHECKED_DIV((ee), (2));
}
return r;
}
__int128 sum_pows_i64_i64(int64_t t0, int64_t k) {
if (t0 <= 0) {
return ((__int128)(0));
}
__int128 t = ((__int128)(t0));
if (k == 0) {
return t;
}
if (k == 1) {
return FLOW_CHECKED_DIV(((t * (t + 1))), (2));
}
if (k == 2) {
return FLOW_CHECKED_DIV((((t * (t + 1)) * ((2 * t) + 1))), (6));
}
if (k == 3) {
__int128 s = FLOW_CHECKED_DIV(((t * (t + 1))), (2));
return (s * s);
}
if (k == 4) {
return FLOW_CHECKED_DIV(((((t * (t + 1)) * ((2 * t) + 1)) * ((((3 * t) * t) + (3 * t)) - 1))), (30));
}
return ((__int128)(0));
}
int64_t max64_i64_i64(int64_t a, int64_t b) {
if (a > b) {
return a;
}
return b;
}
int64_t min64_i64_i64(int64_t a, int64_t b) {
if (a < b) {
return a;
}
return b;
}
__int128 G_fn_i64_i64_i64_i64(int64_t u, int64_t v, int64_t a, int64_t b) {
if ((u <= 0 || v <= 0)) {
return ((__int128)(0));
}
int64_t key1 = (FLOW_CHECKED_SHL((u), (32)) ^ v);
int64_t key2 = (FLOW_CHECKED_SHL((a), (8)) ^ b);
int64_t h = FLOW_CHECKED_MOD((((key1 * 1315423911) + key2)), (CAP));
if (h < 0) {
h = (h + CAP);
}
while (G_u[h] != 0) {
if ((G_k1[h] == key1 && G_k2[h] == key2)) {
return G_v[h];
}
h = (h + 1);
if (h == CAP) {
h = 0;
}
}
int64_t q = isqrt_i64(u);
int64_t upper = v;
if (FLOW_CHECKED_DIV((u), (q)) < upper) {
upper = FLOW_CHECKED_DIV((u), (q));
}
__int128 res = (sum_pows_i64_i64(u, a) * sum_pows_i64_i64(v, b));
int64_t ab = (a + b);
int64_t k = 2;
while (k <= upper) {
res = (res - (G_fn_i64_i64_i64_i64(FLOW_CHECKED_DIV((u), (k)), FLOW_CHECKED_DIV((v), (k)), a, b) * ipow_i64_i64(k, ab)));
k = (k + 1);
}
k = 1;
while (k < q) {
int64_t x = FLOW_CHECKED_DIV((v), ((FLOW_CHECKED_DIV((u), ((k + 1))) + 1)));
int64_t y = FLOW_CHECKED_DIV((v), (FLOW_CHECKED_DIV((u), (k))));
if (x == y) {
res = (res - (G_fn_i64_i64_i64_i64(k, x, a, b) * (sum_pows_i64_i64(FLOW_CHECKED_DIV((u), (k)), ab) - sum_pows_i64_i64(FLOW_CHECKED_DIV((u), ((k + 1))), ab))));
} else {
int64_t lo = max64_i64_i64(FLOW_CHECKED_DIV((u), ((k + 1))), FLOW_CHECKED_DIV((v), ((x + 1))));
int64_t hi = min64_i64_i64(FLOW_CHECKED_DIV((u), (k)), FLOW_CHECKED_DIV((v), (x)));
if (hi > lo) {
res = (res - (G_fn_i64_i64_i64_i64(k, x, a, b) * (sum_pows_i64_i64(hi, ab) - sum_pows_i64_i64(lo, ab))));
}
if (y != 0) {
int64_t lo2 = max64_i64_i64(FLOW_CHECKED_DIV((u), ((k + 1))), FLOW_CHECKED_DIV((v), ((y + 1))));
int64_t hi2 = min64_i64_i64(FLOW_CHECKED_DIV((u), (k)), FLOW_CHECKED_DIV((v), (y)));
if (hi2 > lo2) {
res = (res - (G_fn_i64_i64_i64_i64(k, y, a, b) * (sum_pows_i64_i64(hi2, ab) - sum_pows_i64_i64(lo2, ab))));
}
}
}
k = (k + 1);
}
G_u[h] = 1;
G_k1[h] = key1;
G_k2[h] = key2;
G_v[h] = res;
return res;
}
__int128 H_fn_i64_i64_i64(int64_t a, int64_t b, int64_t c) {
if (c == 0) {
return (sum_pows_i64_i64(G_m, a) * sum_pows_i64_i64(G_n, b));
}
int64_t q = isqrt_i64(G_m);
int64_t upper = G_n;
if (FLOW_CHECKED_DIV((G_m), (q)) < upper) {
upper = FLOW_CHECKED_DIV((G_m), (q));
}
__int128 res = 0;
int64_t abc = ((a + b) + c);
int64_t k = 1;
while (k <= upper) {
res = (res + (G_fn_i64_i64_i64_i64(FLOW_CHECKED_DIV((G_m), (k)), FLOW_CHECKED_DIV((G_n), (k)), a, b) * ipow_i64_i64(k, abc)));
k = (k + 1);
}
k = 1;
while (k < q) {
int64_t x = FLOW_CHECKED_DIV((G_n), ((FLOW_CHECKED_DIV((G_m), ((k + 1))) + 1)));
int64_t y = FLOW_CHECKED_DIV((G_n), (FLOW_CHECKED_DIV((G_m), (k))));
if (x == y) {
res = (res + (G_fn_i64_i64_i64_i64(k, x, a, b) * (sum_pows_i64_i64(FLOW_CHECKED_DIV((G_m), (k)), abc) - sum_pows_i64_i64(FLOW_CHECKED_DIV((G_m), ((k + 1))), abc))));
} else {
int64_t lo = max64_i64_i64(FLOW_CHECKED_DIV((G_m), ((k + 1))), FLOW_CHECKED_DIV((G_n), ((x + 1))));
int64_t hi = min64_i64_i64(FLOW_CHECKED_DIV((G_m), (k)), FLOW_CHECKED_DIV((G_n), (x)));
if (hi > lo) {
res = (res + (G_fn_i64_i64_i64_i64(k, x, a, b) * (sum_pows_i64_i64(hi, abc) - sum_pows_i64_i64(lo, abc))));
}
if (y != 0) {
int64_t lo2 = max64_i64_i64(FLOW_CHECKED_DIV((G_m), ((k + 1))), FLOW_CHECKED_DIV((G_n), ((y + 1))));
int64_t hi2 = min64_i64_i64(FLOW_CHECKED_DIV((G_m), (k)), FLOW_CHECKED_DIV((G_n), (y)));
if (hi2 > lo2) {
res = (res + (G_fn_i64_i64_i64_i64(k, y, a, b) * (sum_pows_i64_i64(hi2, abc) - sum_pows_i64_i64(lo2, abc))));
}
}
}
k = (k + 1);
}
return res;
}
__int128 f_fn_i64_i64_i64(int64_t a, int64_t b, int64_t c) {
__int128 res = H_fn_i64_i64_i64(a, b, c);
if (a == 0) {
res = (res + sum_pows_i64_i64(G_n, (b + c)));
}
if (b == 0) {
res = (res + sum_pows_i64_i64(G_m, (a + c)));
}
if (((a + b) + c) == 0) {
res = (res + 1);
}
return res;
}
__int128 comb_i128_i64(__int128 n0, int64_t k) {
if (k < 0) {
return ((__int128)(0));
}
__int128 r = 1;
int64_t i = 1;
while (i <= k) {
r = FLOW_CHECKED_DIV(((r * ((n0 - ((__int128)(i))) + 1))), (((__int128)(i))));
i = (i + 1);
}
return r;
}
int64_t Q_mod_i64_i64(int64_t m, int64_t n) {
G_m = m;
G_n = n;
int64_t i = 0;
while (i < CAP) {
G_u[i] = 0;
i = (i + 1);
}
__int128 s001 = f_fn_i64_i64_i64(0, 0, 1);
__int128 s011 = f_fn_i64_i64_i64(0, 1, 1);
__int128 s101 = f_fn_i64_i64_i64(1, 0, 1);
__int128 s111 = f_fn_i64_i64_i64(1, 1, 1);
__int128 s002 = f_fn_i64_i64_i64(0, 0, 2);
__int128 s012 = f_fn_i64_i64_i64(0, 1, 2);
__int128 s102 = f_fn_i64_i64_i64(1, 0, 2);
__int128 s112 = f_fn_i64_i64_i64(1, 1, 2);
__int128 s000 = f_fn_i64_i64_i64(0, 0, 0);
__int128 s010 = f_fn_i64_i64_i64(0, 1, 0);
__int128 s100 = f_fn_i64_i64_i64(1, 0, 0);
__int128 s110 = f_fn_i64_i64_i64(1, 1, 0);
__int128 s330 = f_fn_i64_i64_i64(3, 3, 0);
__int128 s320 = f_fn_i64_i64_i64(3, 2, 0);
__int128 s230 = f_fn_i64_i64_i64(2, 3, 0);
__int128 s220 = f_fn_i64_i64_i64(2, 2, 0);
__int128 s310 = f_fn_i64_i64_i64(3, 1, 0);
__int128 s210 = f_fn_i64_i64_i64(2, 1, 0);
__int128 s300 = f_fn_i64_i64_i64(3, 0, 0);
__int128 s200 = f_fn_i64_i64_i64(2, 0, 0);
__int128 s130 = f_fn_i64_i64_i64(1, 3, 0);
__int128 s120 = f_fn_i64_i64_i64(1, 2, 0);
__int128 s030 = f_fn_i64_i64_i64(0, 3, 0);
__int128 s020 = f_fn_i64_i64_i64(0, 2, 0);
__int128 mp1 = ((__int128)((m + 1)));
__int128 np1 = ((__int128)((n + 1)));
__int128 P = (mp1 * np1);
__int128 s = (((((((s012 - (11 * s230)) - s210) - s030) * mp1) + ((((s102 - (11 * s320)) - s300) - s120) * np1)) - (((s112 - (11 * s330)) - s310) - s130)) - (((((s002 - (11 * s220)) - s200) - s020) * mp1) * np1));
__int128 c3 = (((((((2 * (((((s010 - s011) * mp1) + ((s100 - s101) * np1)) - (((s000 - s001) * mp1) * np1)) - (s110 - s111))) + s020) - (((__int128)((n + 2))) * s010)) + (np1 * s000)) + s200) - (((__int128)((m + 2))) * s100)) + (mp1 * s000));
__int128 c4 = ((((((((((((((((s000 * 4) - (s001 * 6)) + (s002 * 2)) * mp1) * np1) + (((s110 * 4) - (s111 * 6)) + (s112 * 2))) - ((((s100 * 4) - (s101 * 6)) + (s102 * 2)) * np1)) - ((((s010 * 4) - (s011 * 6)) + (s012 * 2)) * mp1)) + s030) - (((__int128)((n + 4))) * s020)) + (((__int128)(((3 * n) + 5))) * s010)) - ((2 * np1) * s000)) + s300) - (((__int128)((m + 4))) * s200)) + (((__int128)(((3 * m) + 5))) * s100)) - ((2 * mp1) * s000));
__int128 Qv = ((((comb_i128_i64(P, 4) - comb_i128_i64(P, 3)) + FLOW_CHECKED_DIV((s), (3))) + ((7 - (2 * P)) * c3)) + (7 * FLOW_CHECKED_DIV((c4), (2))));
__int128 mm = ((__int128)(MOD));
__int128 r = FLOW_CHECKED_MOD((Qv), (mm));
if (r < 0) {
r = (r + mm);
}
return ((int64_t)(r));
}
int32_t main(void) {
G_k1 = calloc(CAP, 8);
G_k2 = calloc(CAP, 8);
G_v = calloc(CAP, 16);
G_u = calloc(CAP, 1);
if ((((G_k1 == NULL || G_k2 == NULL) || G_v == NULL) || G_u == NULL)) {
return 1;
}
printf("%lld\n", Q_mod_i64_i64(12345, 6789));
free(G_u);
free(G_v);
free(G_k2);
free(G_k1);
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) -> ()
// Constant: MOD
llvm.mlir.global internal constant @MOD(135707531 : i64) : i64
// Constant: CAP
llvm.mlir.global internal constant @CAP(2097152 : i64) : i64
// Module static: G_m
llvm.mlir.global internal @G_m(0 : i64) : i64
// Module static: G_n
llvm.mlir.global internal @G_n(0 : i64) : i64
// Module static: G_k1
llvm.mlir.global internal @G_k1() {addr_space = 0 : i32} : !llvm.ptr {
%175 = llvm.mlir.zero : !llvm.ptr
llvm.return %175 : !llvm.ptr
}
// Module static: G_k2
llvm.mlir.global internal @G_k2() {addr_space = 0 : i32} : !llvm.ptr {
%176 = llvm.mlir.zero : !llvm.ptr
llvm.return %176 : !llvm.ptr
}
// Module static: G_v
llvm.mlir.global internal @G_v() {addr_space = 0 : i32} : !llvm.ptr {
%177 = llvm.mlir.zero : !llvm.ptr
llvm.return %177 : !llvm.ptr
}
// Module static: G_u
llvm.mlir.global internal @G_u() {addr_space = 0 : i32} : !llvm.ptr {
%178 = llvm.mlir.zero : !llvm.ptr
llvm.return %178 : !llvm.ptr
}
func.func @ipow(%arg0: i64, %arg1: i64) -> i128 {
%179 = arith.constant 1 : i32
%180 = arith.extsi %179 : i32 to i128
%181 = llvm.mlir.constant(1 : i64) : i64
%182 = llvm.alloca %181 x i128 : (i64) -> !llvm.ptr
llvm.store %180, %182 : i128, !llvm.ptr
%183 = arith.extsi %arg0 : i64 to i128
%184 = llvm.mlir.constant(1 : i64) : i64
%185 = llvm.alloca %184 x i128 : (i64) -> !llvm.ptr
llvm.store %183, %185 : i128, !llvm.ptr
%186 = llvm.mlir.constant(1 : i64) : i64
%187 = llvm.alloca %186 x i64 : (i64) -> !llvm.ptr
llvm.store %arg1, %187 : i64, !llvm.ptr
cf.br ^bb42
^bb42:
%188 = llvm.load %187 : !llvm.ptr -> i64
%189 = arith.constant 0 : i32
%191 = arith.extsi %189 : i32 to i64
%190 = arith.cmpi sgt, %188, %191 : i64
cf.cond_br %190, ^bb43, ^bb44
^bb43:
%192 = llvm.load %187 : !llvm.ptr -> i64
%193 = arith.constant 1 : i32
%195 = arith.extsi %193 : i32 to i64
%194 = arith.andi %192, %195 : i64
%196 = arith.constant 1 : i32
%198 = arith.extsi %196 : i32 to i64
%197 = arith.cmpi eq, %194, %198 : i64
cf.cond_br %197, ^bb45, ^bb46
^bb45:
%199 = llvm.load %182 : !llvm.ptr -> i128
%200 = llvm.load %185 : !llvm.ptr -> i128
%202 = arith.trunci %199 : i128 to i64
%203 = arith.trunci %200 : i128 to i64
%201 = arith.muli %202, %203 : i64
%204 = arith.extsi %201 : i64 to i128
llvm.store %204, %182 : i128, !llvm.ptr
cf.br ^bb47
^bb46:
cf.br ^bb47
^bb47:
%205 = llvm.load %185 : !llvm.ptr -> i128
%206 = llvm.load %185 : !llvm.ptr -> i128
%208 = arith.trunci %205 : i128 to i64
%209 = arith.trunci %206 : i128 to i64
%207 = arith.muli %208, %209 : i64
%210 = arith.extsi %207 : i64 to i128
llvm.store %210, %185 : i128, !llvm.ptr
%211 = llvm.load %187 : !llvm.ptr -> i64
%212 = arith.constant 2 : i32
%214 = arith.extsi %212 : i32 to i64
%213 = arith.divsi %211, %214 : i64
llvm.store %213, %187 : i64, !llvm.ptr
cf.br ^bb42
^bb44:
%215 = llvm.load %182 : !llvm.ptr -> i128
func.return %215 : i128
}
func.func @sum_pows(%arg0: i64, %arg1: i64) -> i128 {
%216 = arith.constant 0 : i32
%218 = arith.extsi %216 : i32 to i64
%217 = arith.cmpi sle, %arg0, %218 : i64
cf.cond_br %217, ^bb48, ^bb49
^bb48:
%219 = arith.constant 0 : i32
%220 = arith.extsi %219 : i32 to i128
func.return %220 : i128
^bb49:
cf.br ^bb50
^bb50:
%221 = arith.extsi %arg0 : i64 to i128
%222 = arith.constant 0 : i32
%224 = arith.extsi %222 : i32 to i64
%223 = arith.cmpi eq, %arg1, %224 : i64
cf.cond_br %223, ^bb51, ^bb52
^bb51:
func.return %221 : i128
^bb52:
cf.br ^bb53
^bb53:
%225 = arith.constant 1 : i32
%227 = arith.extsi %225 : i32 to i64
%226 = arith.cmpi eq, %arg1, %227 : i64
cf.cond_br %226, ^bb54, ^bb55
^bb54:
%228 = arith.constant 1 : i32
%230 = arith.trunci %221 : i128 to i64
%231 = arith.extsi %228 : i32 to i64
%229 = arith.addi %230, %231 : i64
%233 = arith.trunci %221 : i128 to i64
%232 = arith.muli %233, %229 : i64
%234 = arith.constant 2 : i32
%236 = arith.extsi %234 : i32 to i64
%235 = arith.divsi %232, %236 : i64
%237 = arith.extsi %235 : i64 to i128
func.return %237 : i128
^bb55:
cf.br ^bb56
^bb56:
%238 = arith.constant 2 : i32
%240 = arith.extsi %238 : i32 to i64
%239 = arith.cmpi eq, %arg1, %240 : i64
cf.cond_br %239, ^bb57, ^bb58
^bb57:
%241 = arith.constant 1 : i32
%243 = arith.trunci %221 : i128 to i64
%244 = arith.extsi %241 : i32 to i64
%242 = arith.addi %243, %244 : i64
%246 = arith.trunci %221 : i128 to i64
%245 = arith.muli %246, %242 : i64
%247 = arith.constant 2 : i32
%249 = arith.extsi %247 : i32 to i64
%250 = arith.trunci %221 : i128 to i64
%248 = arith.muli %249, %250 : i64
%251 = arith.constant 1 : i32
%253 = arith.extsi %251 : i32 to i64
%252 = arith.addi %248, %253 : i64
%254 = arith.muli %245, %252 : i64
%255 = arith.constant 6 : i32
%257 = arith.extsi %255 : i32 to i64
%256 = arith.divsi %254, %257 : i64
%258 = arith.extsi %256 : i64 to i128
func.return %258 : i128
^bb58:
cf.br ^bb59
^bb59:
%259 = arith.constant 3 : i32
%261 = arith.extsi %259 : i32 to i64
%260 = arith.cmpi eq, %arg1, %261 : i64
cf.cond_br %260, ^bb60, ^bb61
^bb60:
%262 = arith.constant 1 : i32
%264 = arith.trunci %221 : i128 to i64
%265 = arith.extsi %262 : i32 to i64
%263 = arith.addi %264, %265 : i64
%267 = arith.trunci %221 : i128 to i64
%266 = arith.muli %267, %263 : i64
%268 = arith.constant 2 : i32
%270 = arith.extsi %268 : i32 to i64
%269 = arith.divsi %266, %270 : i64
%271 = arith.extsi %269 : i64 to i128
%273 = arith.trunci %271 : i128 to i64
%274 = arith.trunci %271 : i128 to i64
%272 = arith.muli %273, %274 : i64
%275 = arith.extsi %272 : i64 to i128
func.return %275 : i128
^bb61:
cf.br ^bb62
^bb62:
%276 = arith.constant 4 : i32
%278 = arith.extsi %276 : i32 to i64
%277 = arith.cmpi eq, %arg1, %278 : i64
cf.cond_br %277, ^bb63, ^bb64
^bb63:
%279 = arith.constant 1 : i32
%281 = arith.trunci %221 : i128 to i64
%282 = arith.extsi %279 : i32 to i64
%280 = arith.addi %281, %282 : i64
%284 = arith.trunci %221 : i128 to i64
%283 = arith.muli %284, %280 : i64
%285 = arith.constant 2 : i32
%287 = arith.extsi %285 : i32 to i64
%288 = arith.trunci %221 : i128 to i64
%286 = arith.muli %287, %288 : i64
%289 = arith.constant 1 : i32
%291 = arith.extsi %289 : i32 to i64
%290 = arith.addi %286, %291 : i64
%292 = arith.muli %283, %290 : i64
%293 = arith.constant 3 : i32
%295 = arith.extsi %293 : i32 to i64
%296 = arith.trunci %221 : i128 to i64
%294 = arith.muli %295, %296 : i64
%298 = arith.trunci %221 : i128 to i64
%297 = arith.muli %294, %298 : i64
%299 = arith.constant 3 : i32
%301 = arith.extsi %299 : i32 to i64
%302 = arith.trunci %221 : i128 to i64
%300 = arith.muli %301, %302 : i64
%303 = arith.addi %297, %300 : i64
%304 = arith.constant 1 : i32
%306 = arith.extsi %304 : i32 to i64
%305 = arith.subi %303, %306 : i64
%307 = arith.muli %292, %305 : i64
%308 = arith.constant 30 : i32
%310 = arith.extsi %308 : i32 to i64
%309 = arith.divsi %307, %310 : i64
%311 = arith.extsi %309 : i64 to i128
func.return %311 : i128
^bb64:
cf.br ^bb65
^bb65:
%312 = arith.constant 0 : i32
%313 = arith.extsi %312 : i32 to i128
func.return %313 : i128
}
func.func @max64(%arg0: i64, %arg1: i64) -> i64 {
%314 = arith.cmpi sgt, %arg0, %arg1 : i64
cf.cond_br %314, ^bb66, ^bb67
^bb66:
func.return %arg0 : i64
^bb67:
cf.br ^bb68
^bb68:
func.return %arg1 : i64
}
func.func @min64(%arg0: i64, %arg1: i64) -> i64 {
%315 = arith.cmpi slt, %arg0, %arg1 : i64
cf.cond_br %315, ^bb69, ^bb70
^bb69:
func.return %arg0 : i64
^bb70:
cf.br ^bb71
^bb71:
func.return %arg1 : i64
}
func.func @G_fn(%arg0: i64, %arg1: i64, %arg2: i64, %arg3: i64) -> i128 {
%316 = arith.constant 0 : i32
%318 = arith.extsi %316 : i32 to i64
%317 = arith.cmpi sle, %arg0, %318 : i64
%319 = scf.if %317 -> (i1) {
%320 = arith.constant true
scf.yield %320 : i1
} else {
%321 = arith.constant 0 : i32
%323 = arith.extsi %321 : i32 to i64
%322 = arith.cmpi sle, %arg1, %323 : i64
scf.yield %322 : i1
}
cf.cond_br %319, ^bb72, ^bb73
^bb72:
%324 = arith.constant 0 : i32
%325 = arith.extsi %324 : i32 to i128
func.return %325 : i128
^bb73:
cf.br ^bb74
^bb74:
%326 = arith.constant 32 : i32
%328 = arith.extsi %326 : i32 to i64
%327 = arith.shli %arg0, %328 : i64
%329 = arith.xori %327, %arg1 : i64
%330 = arith.constant 8 : i32
%332 = arith.extsi %330 : i32 to i64
%331 = arith.shli %arg2, %332 : i64
%333 = arith.xori %331, %arg3 : i64
%334 = arith.constant 1315423911 : i32
%336 = arith.extsi %334 : i32 to i64
%335 = arith.muli %329, %336 : i64
%337 = arith.addi %335, %333 : i64
%338 = llvm.mlir.addressof @CAP : !llvm.ptr
%339 = llvm.load %338 : !llvm.ptr -> i64
%340 = arith.remsi %337, %339 : i64
%341 = llvm.mlir.constant(1 : i64) : i64
%342 = llvm.alloca %341 x i64 : (i64) -> !llvm.ptr
llvm.store %340, %342 : i64, !llvm.ptr
%343 = llvm.load %342 : !llvm.ptr -> i64
%344 = arith.constant 0 : i32
%346 = arith.extsi %344 : i32 to i64
%345 = arith.cmpi slt, %343, %346 : i64
cf.cond_br %345, ^bb75, ^bb76
^bb75:
%347 = llvm.load %342 : !llvm.ptr -> i64
%348 = llvm.mlir.addressof @CAP : !llvm.ptr
%349 = llvm.load %348 : !llvm.ptr -> i64
%350 = arith.addi %347, %349 : i64
llvm.store %350, %342 : i64, !llvm.ptr
cf.br ^bb77
^bb76:
cf.br ^bb77
^bb77:
cf.br ^bb78
^bb78:
%352 = llvm.mlir.addressof @G_u : !llvm.ptr
%353 = llvm.load %352 : !llvm.ptr -> !llvm.ptr
%354 = llvm.load %342 : !llvm.ptr -> i64
%355 = llvm.getelementptr %353[%354] : (!llvm.ptr, i64) -> !llvm.ptr, i8
%351 = llvm.load %355 : !llvm.ptr -> i8
%356 = arith.constant 0 : i32
%358 = arith.extsi %351 : i8 to i32
%357 = arith.cmpi ne, %358, %356 : i32
cf.cond_br %357, ^bb79, ^bb80
^bb79:
%360 = llvm.mlir.addressof @G_k1 : !llvm.ptr
%361 = llvm.load %360 : !llvm.ptr -> !llvm.ptr
%362 = llvm.load %342 : !llvm.ptr -> i64
%363 = llvm.getelementptr %361[%362] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%359 = llvm.load %363 : !llvm.ptr -> i64
%364 = arith.cmpi eq, %359, %329 : i64
%365 = scf.if %364 -> (i1) {
%367 = llvm.mlir.addressof @G_k2 : !llvm.ptr
%368 = llvm.load %367 : !llvm.ptr -> !llvm.ptr
%369 = llvm.load %342 : !llvm.ptr -> i64
%370 = llvm.getelementptr %368[%369] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%366 = llvm.load %370 : !llvm.ptr -> i64
%371 = arith.cmpi eq, %366, %333 : i64
scf.yield %371 : i1
} else {
%372 = arith.constant false
scf.yield %372 : i1
}
cf.cond_br %365, ^bb81, ^bb82
^bb81:
%374 = llvm.mlir.addressof @G_v : !llvm.ptr
%375 = llvm.load %374 : !llvm.ptr -> !llvm.ptr
%376 = llvm.load %342 : !llvm.ptr -> i64
%377 = llvm.getelementptr %375[%376] : (!llvm.ptr, i64) -> !llvm.ptr, i128
%373 = llvm.load %377 : !llvm.ptr -> i128
func.return %373 : i128
^bb82:
cf.br ^bb83
^bb83:
%378 = llvm.load %342 : !llvm.ptr -> i64
%379 = arith.constant 1 : i32
%381 = arith.extsi %379 : i32 to i64
%380 = arith.addi %378, %381 : i64
llvm.store %380, %342 : i64, !llvm.ptr
%382 = llvm.load %342 : !llvm.ptr -> i64
%383 = llvm.mlir.addressof @CAP : !llvm.ptr
%384 = llvm.load %383 : !llvm.ptr -> i64
%385 = arith.cmpi eq, %382, %384 : i64
cf.cond_br %385, ^bb84, ^bb85
^bb84:
%386 = arith.constant 0 : i32
%387 = arith.extsi %386 : i32 to i64
llvm.store %387, %342 : i64, !llvm.ptr
cf.br ^bb86
^bb85:
cf.br ^bb86
^bb86:
cf.br ^bb78
^bb80:
%388 = func.call @isqrt(%arg0) : (i64) -> i64
%389 = llvm.mlir.constant(1 : i64) : i64
%390 = llvm.alloca %389 x i64 : (i64) -> !llvm.ptr
llvm.store %arg1, %390 : i64, !llvm.ptr
%391 = arith.divsi %arg0, %388 : i64
%392 = llvm.load %390 : !llvm.ptr -> i64
%393 = arith.cmpi slt, %391, %392 : i64
cf.cond_br %393, ^bb87, ^bb88
^bb87:
%394 = arith.divsi %arg0, %388 : i64
llvm.store %394, %390 : i64, !llvm.ptr
cf.br ^bb89
^bb88:
cf.br ^bb89
^bb89:
%395 = func.call @sum_pows(%arg0, %arg2) : (i64, i64) -> i128
%396 = func.call @sum_pows(%arg1, %arg3) : (i64, i64) -> i128
%398 = arith.trunci %395 : i128 to i64
%399 = arith.trunci %396 : i128 to i64
%397 = arith.muli %398, %399 : i64
%400 = arith.extsi %397 : i64 to i128
%401 = llvm.mlir.constant(1 : i64) : i64
%402 = llvm.alloca %401 x i128 : (i64) -> !llvm.ptr
llvm.store %400, %402 : i128, !llvm.ptr
%403 = arith.addi %arg2, %arg3 : i64
%404 = arith.constant 2 : i32
%405 = arith.extsi %404 : i32 to i64
%406 = llvm.mlir.constant(1 : i64) : i64
%407 = llvm.alloca %406 x i64 : (i64) -> !llvm.ptr
llvm.store %405, %407 : i64, !llvm.ptr
cf.br ^bb90
^bb90:
%408 = llvm.load %407 : !llvm.ptr -> i64
%409 = llvm.load %390 : !llvm.ptr -> i64
%410 = arith.cmpi sle, %408, %409 : i64
cf.cond_br %410, ^bb91, ^bb92
^bb91:
%411 = llvm.load %402 : !llvm.ptr -> i128
%413 = llvm.load %407 : !llvm.ptr -> i64
%414 = arith.divsi %arg0, %413 : i64
%415 = llvm.load %407 : !llvm.ptr -> i64
%416 = arith.divsi %arg1, %415 : i64
%412 = func.call @G_fn(%414, %416, %arg2, %arg3) : (i64, i64, i64, i64) -> i128
%418 = llvm.load %407 : !llvm.ptr -> i64
%417 = func.call @ipow(%418, %403) : (i64, i64) -> i128
%420 = arith.trunci %412 : i128 to i64
%421 = arith.trunci %417 : i128 to i64
%419 = arith.muli %420, %421 : i64
%423 = arith.trunci %411 : i128 to i64
%422 = arith.subi %423, %419 : i64
%424 = arith.extsi %422 : i64 to i128
llvm.store %424, %402 : i128, !llvm.ptr
%425 = llvm.load %407 : !llvm.ptr -> i64
%426 = arith.constant 1 : i32
%428 = arith.extsi %426 : i32 to i64
%427 = arith.addi %425, %428 : i64
llvm.store %427, %407 : i64, !llvm.ptr
cf.br ^bb90
^bb92:
%429 = arith.constant 1 : i32
%430 = arith.extsi %429 : i32 to i64
llvm.store %430, %407 : i64, !llvm.ptr
cf.br ^bb93
^bb93:
%431 = llvm.load %407 : !llvm.ptr -> i64
%432 = arith.cmpi slt, %431, %388 : i64
cf.cond_br %432, ^bb94, ^bb95
^bb94:
%433 = llvm.load %407 : !llvm.ptr -> i64
%434 = arith.constant 1 : i32
%436 = arith.extsi %434 : i32 to i64
%435 = arith.addi %433, %436 : i64
%437 = arith.divsi %arg0, %435 : i64
%438 = arith.constant 1 : i32
%440 = arith.extsi %438 : i32 to i64
%439 = arith.addi %437, %440 : i64
%441 = arith.divsi %arg1, %439 : i64
%442 = llvm.load %407 : !llvm.ptr -> i64
%443 = arith.divsi %arg0, %442 : i64
%444 = arith.divsi %arg1, %443 : i64
%445 = arith.cmpi eq, %441, %444 : i64
cf.cond_br %445, ^bb96, ^bb97
^bb96:
%446 = llvm.load %402 : !llvm.ptr -> i128
%448 = llvm.load %407 : !llvm.ptr -> i64
%447 = func.call @G_fn(%448, %441, %arg2, %arg3) : (i64, i64, i64, i64) -> i128
%450 = llvm.load %407 : !llvm.ptr -> i64
%451 = arith.divsi %arg0, %450 : i64
%449 = func.call @sum_pows(%451, %403) : (i64, i64) -> i128
%453 = llvm.load %407 : !llvm.ptr -> i64
%454 = arith.constant 1 : i32
%456 = arith.extsi %454 : i32 to i64
%455 = arith.addi %453, %456 : i64
%457 = arith.divsi %arg0, %455 : i64
%452 = func.call @sum_pows(%457, %403) : (i64, i64) -> i128
%459 = arith.trunci %449 : i128 to i64
%460 = arith.trunci %452 : i128 to i64
%458 = arith.subi %459, %460 : i64
%462 = arith.trunci %447 : i128 to i64
%461 = arith.muli %462, %458 : i64
%464 = arith.trunci %446 : i128 to i64
%463 = arith.subi %464, %461 : i64
%465 = arith.extsi %463 : i64 to i128
llvm.store %465, %402 : i128, !llvm.ptr
cf.br ^bb98
^bb97:
%467 = llvm.load %407 : !llvm.ptr -> i64
%468 = arith.constant 1 : i32
%470 = arith.extsi %468 : i32 to i64
%469 = arith.addi %467, %470 : i64
%471 = arith.divsi %arg0, %469 : i64
%472 = arith.constant 1 : i32
%474 = arith.extsi %472 : i32 to i64
%473 = arith.addi %441, %474 : i64
%475 = arith.divsi %arg1, %473 : i64
%466 = func.call @max64(%471, %475) : (i64, i64) -> i64
%477 = llvm.load %407 : !llvm.ptr -> i64
%478 = arith.divsi %arg0, %477 : i64
%479 = arith.divsi %arg1, %441 : i64
%476 = func.call @min64(%478, %479) : (i64, i64) -> i64
%480 = arith.cmpi sgt, %476, %466 : i64
cf.cond_br %480, ^bb99, ^bb100
^bb99:
%481 = llvm.load %402 : !llvm.ptr -> i128
%483 = llvm.load %407 : !llvm.ptr -> i64
%482 = func.call @G_fn(%483, %441, %arg2, %arg3) : (i64, i64, i64, i64) -> i128
%484 = func.call @sum_pows(%476, %403) : (i64, i64) -> i128
%485 = func.call @sum_pows(%466, %403) : (i64, i64) -> i128
%487 = arith.trunci %484 : i128 to i64
%488 = arith.trunci %485 : i128 to i64
%486 = arith.subi %487, %488 : i64
%490 = arith.trunci %482 : i128 to i64
%489 = arith.muli %490, %486 : i64
%492 = arith.trunci %481 : i128 to i64
%491 = arith.subi %492, %489 : i64
%493 = arith.extsi %491 : i64 to i128
llvm.store %493, %402 : i128, !llvm.ptr
cf.br ^bb101
^bb100:
cf.br ^bb101
^bb101:
%494 = arith.constant 0 : i32
%496 = arith.extsi %494 : i32 to i64
%495 = arith.cmpi ne, %444, %496 : i64
cf.cond_br %495, ^bb102, ^bb103
^bb102:
%498 = llvm.load %407 : !llvm.ptr -> i64
%499 = arith.constant 1 : i32
%501 = arith.extsi %499 : i32 to i64
%500 = arith.addi %498, %501 : i64
%502 = arith.divsi %arg0, %500 : i64
%503 = arith.constant 1 : i32
%505 = arith.extsi %503 : i32 to i64
%504 = arith.addi %444, %505 : i64
%506 = arith.divsi %arg1, %504 : i64
%497 = func.call @max64(%502, %506) : (i64, i64) -> i64
%508 = llvm.load %407 : !llvm.ptr -> i64
%509 = arith.divsi %arg0, %508 : i64
%510 = arith.divsi %arg1, %444 : i64
%507 = func.call @min64(%509, %510) : (i64, i64) -> i64
%511 = arith.cmpi sgt, %507, %497 : i64
cf.cond_br %511, ^bb105, ^bb106
^bb105:
%512 = llvm.load %402 : !llvm.ptr -> i128
%514 = llvm.load %407 : !llvm.ptr -> i64
%513 = func.call @G_fn(%514, %444, %arg2, %arg3) : (i64, i64, i64, i64) -> i128
%515 = func.call @sum_pows(%507, %403) : (i64, i64) -> i128
%516 = func.call @sum_pows(%497, %403) : (i64, i64) -> i128
%518 = arith.trunci %515 : i128 to i64
%519 = arith.trunci %516 : i128 to i64
%517 = arith.subi %518, %519 : i64
%521 = arith.trunci %513 : i128 to i64
%520 = arith.muli %521, %517 : i64
%523 = arith.trunci %512 : i128 to i64
%522 = arith.subi %523, %520 : i64
%524 = arith.extsi %522 : i64 to i128
llvm.store %524, %402 : i128, !llvm.ptr
cf.br ^bb107
^bb106:
cf.br ^bb107
^bb107:
cf.br ^bb104
^bb103:
cf.br ^bb104
^bb104:
cf.br ^bb98
^bb98:
%525 = llvm.load %407 : !llvm.ptr -> i64
%526 = arith.constant 1 : i32
%528 = arith.extsi %526 : i32 to i64
%527 = arith.addi %525, %528 : i64
llvm.store %527, %407 : i64, !llvm.ptr
cf.br ^bb93
^bb95:
%529 = arith.constant 1 : i32
%530 = llvm.mlir.addressof @G_u : !llvm.ptr
%531 = llvm.load %530 : !llvm.ptr -> !llvm.ptr
%532 = llvm.load %342 : !llvm.ptr -> i64
%533 = arith.trunci %529 : i32 to i8
%534 = llvm.getelementptr %531[%532] : (!llvm.ptr, i64) -> !llvm.ptr, i8
llvm.store %533, %534 : i8, !llvm.ptr
%535 = llvm.mlir.addressof @G_k1 : !llvm.ptr
%536 = llvm.load %535 : !llvm.ptr -> !llvm.ptr
%537 = llvm.load %342 : !llvm.ptr -> i64
%538 = llvm.getelementptr %536[%537] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %329, %538 : i64, !llvm.ptr
%539 = llvm.mlir.addressof @G_k2 : !llvm.ptr
%540 = llvm.load %539 : !llvm.ptr -> !llvm.ptr
%541 = llvm.load %342 : !llvm.ptr -> i64
%542 = llvm.getelementptr %540[%541] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %333, %542 : i64, !llvm.ptr
%543 = llvm.load %402 : !llvm.ptr -> i128
%544 = llvm.mlir.addressof @G_v : !llvm.ptr
%545 = llvm.load %544 : !llvm.ptr -> !llvm.ptr
%546 = llvm.load %342 : !llvm.ptr -> i64
%547 = llvm.getelementptr %545[%546] : (!llvm.ptr, i64) -> !llvm.ptr, i128
llvm.store %543, %547 : i128, !llvm.ptr
%548 = llvm.load %402 : !llvm.ptr -> i128
func.return %548 : i128
}
func.func @H_fn(%arg0: i64, %arg1: i64, %arg2: i64) -> i128 {
%549 = arith.constant 0 : i32
%551 = arith.extsi %549 : i32 to i64
%550 = arith.cmpi eq, %arg2, %551 : i64
cf.cond_br %550, ^bb108, ^bb109
^bb108:
%553 = llvm.mlir.addressof @G_m : !llvm.ptr
%554 = llvm.load %553 : !llvm.ptr -> i64
%552 = func.call @sum_pows(%554, %arg0) : (i64, i64) -> i128
%556 = llvm.mlir.addressof @G_n : !llvm.ptr
%557 = llvm.load %556 : !llvm.ptr -> i64
%555 = func.call @sum_pows(%557, %arg1) : (i64, i64) -> i128
%559 = arith.trunci %552 : i128 to i64
%560 = arith.trunci %555 : i128 to i64
%558 = arith.muli %559, %560 : i64
%561 = arith.extsi %558 : i64 to i128
func.return %561 : i128
^bb109:
cf.br ^bb110
^bb110:
%563 = llvm.mlir.addressof @G_m : !llvm.ptr
%564 = llvm.load %563 : !llvm.ptr -> i64
%562 = func.call @isqrt(%564) : (i64) -> i64
%565 = llvm.mlir.addressof @G_n : !llvm.ptr
%566 = llvm.load %565 : !llvm.ptr -> i64
%567 = llvm.mlir.constant(1 : i64) : i64
%568 = llvm.alloca %567 x i64 : (i64) -> !llvm.ptr
llvm.store %566, %568 : i64, !llvm.ptr
%569 = llvm.mlir.addressof @G_m : !llvm.ptr
%570 = llvm.load %569 : !llvm.ptr -> i64
%571 = arith.divsi %570, %562 : i64
%572 = llvm.load %568 : !llvm.ptr -> i64
%573 = arith.cmpi slt, %571, %572 : i64
cf.cond_br %573, ^bb111, ^bb112
^bb111:
%574 = llvm.mlir.addressof @G_m : !llvm.ptr
%575 = llvm.load %574 : !llvm.ptr -> i64
%576 = arith.divsi %575, %562 : i64
llvm.store %576, %568 : i64, !llvm.ptr
cf.br ^bb113
^bb112:
cf.br ^bb113
^bb113:
%577 = arith.constant 0 : i32
%578 = arith.extsi %577 : i32 to i128
%579 = llvm.mlir.constant(1 : i64) : i64
%580 = llvm.alloca %579 x i128 : (i64) -> !llvm.ptr
llvm.store %578, %580 : i128, !llvm.ptr
%581 = arith.addi %arg0, %arg1 : i64
%582 = arith.addi %581, %arg2 : i64
%583 = arith.constant 1 : 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
cf.br ^bb114
^bb114:
%587 = llvm.load %586 : !llvm.ptr -> i64
%588 = llvm.load %568 : !llvm.ptr -> i64
%589 = arith.cmpi sle, %587, %588 : i64
cf.cond_br %589, ^bb115, ^bb116
^bb115:
%590 = llvm.load %580 : !llvm.ptr -> i128
%592 = llvm.mlir.addressof @G_m : !llvm.ptr
%593 = llvm.load %592 : !llvm.ptr -> i64
%594 = llvm.load %586 : !llvm.ptr -> i64
%595 = arith.divsi %593, %594 : i64
%596 = llvm.mlir.addressof @G_n : !llvm.ptr
%597 = llvm.load %596 : !llvm.ptr -> i64
%598 = llvm.load %586 : !llvm.ptr -> i64
%599 = arith.divsi %597, %598 : i64
%591 = func.call @G_fn(%595, %599, %arg0, %arg1) : (i64, i64, i64, i64) -> i128
%601 = llvm.load %586 : !llvm.ptr -> i64
%600 = func.call @ipow(%601, %582) : (i64, i64) -> i128
%603 = arith.trunci %591 : i128 to i64
%604 = arith.trunci %600 : i128 to i64
%602 = arith.muli %603, %604 : i64
%606 = arith.trunci %590 : i128 to i64
%605 = arith.addi %606, %602 : i64
%607 = arith.extsi %605 : i64 to i128
llvm.store %607, %580 : i128, !llvm.ptr
%608 = llvm.load %586 : !llvm.ptr -> i64
%609 = arith.constant 1 : i32
%611 = arith.extsi %609 : i32 to i64
%610 = arith.addi %608, %611 : i64
llvm.store %610, %586 : i64, !llvm.ptr
cf.br ^bb114
^bb116:
%612 = arith.constant 1 : i32
%613 = arith.extsi %612 : i32 to i64
llvm.store %613, %586 : i64, !llvm.ptr
cf.br ^bb117
^bb117:
%614 = llvm.load %586 : !llvm.ptr -> i64
%615 = arith.cmpi slt, %614, %562 : i64
cf.cond_br %615, ^bb118, ^bb119
^bb118:
%616 = llvm.mlir.addressof @G_n : !llvm.ptr
%617 = llvm.load %616 : !llvm.ptr -> i64
%618 = llvm.mlir.addressof @G_m : !llvm.ptr
%619 = llvm.load %618 : !llvm.ptr -> i64
%620 = llvm.load %586 : !llvm.ptr -> i64
%621 = arith.constant 1 : i32
%623 = arith.extsi %621 : i32 to i64
%622 = arith.addi %620, %623 : i64
%624 = arith.divsi %619, %622 : i64
%625 = arith.constant 1 : i32
%627 = arith.extsi %625 : i32 to i64
%626 = arith.addi %624, %627 : i64
%628 = arith.divsi %617, %626 : i64
%629 = llvm.mlir.addressof @G_n : !llvm.ptr
%630 = llvm.load %629 : !llvm.ptr -> i64
%631 = llvm.mlir.addressof @G_m : !llvm.ptr
%632 = llvm.load %631 : !llvm.ptr -> i64
%633 = llvm.load %586 : !llvm.ptr -> i64
%634 = arith.divsi %632, %633 : i64
%635 = arith.divsi %630, %634 : i64
%636 = arith.cmpi eq, %628, %635 : i64
cf.cond_br %636, ^bb120, ^bb121
^bb120:
%637 = llvm.load %580 : !llvm.ptr -> i128
%639 = llvm.load %586 : !llvm.ptr -> i64
%638 = func.call @G_fn(%639, %628, %arg0, %arg1) : (i64, i64, i64, i64) -> i128
%641 = llvm.mlir.addressof @G_m : !llvm.ptr
%642 = llvm.load %641 : !llvm.ptr -> i64
%643 = llvm.load %586 : !llvm.ptr -> i64
%644 = arith.divsi %642, %643 : i64
%640 = func.call @sum_pows(%644, %582) : (i64, i64) -> i128
%646 = llvm.mlir.addressof @G_m : !llvm.ptr
%647 = llvm.load %646 : !llvm.ptr -> i64
%648 = llvm.load %586 : !llvm.ptr -> i64
%649 = arith.constant 1 : i32
%651 = arith.extsi %649 : i32 to i64
%650 = arith.addi %648, %651 : i64
%652 = arith.divsi %647, %650 : i64
%645 = func.call @sum_pows(%652, %582) : (i64, i64) -> i128
%654 = arith.trunci %640 : i128 to i64
%655 = arith.trunci %645 : i128 to i64
%653 = arith.subi %654, %655 : i64
%657 = arith.trunci %638 : i128 to i64
%656 = arith.muli %657, %653 : i64
%659 = arith.trunci %637 : i128 to i64
%658 = arith.addi %659, %656 : i64
%660 = arith.extsi %658 : i64 to i128
llvm.store %660, %580 : i128, !llvm.ptr
cf.br ^bb122
^bb121:
%662 = llvm.mlir.addressof @G_m : !llvm.ptr
%663 = llvm.load %662 : !llvm.ptr -> i64
%664 = llvm.load %586 : !llvm.ptr -> i64
%665 = arith.constant 1 : i32
%667 = arith.extsi %665 : i32 to i64
%666 = arith.addi %664, %667 : i64
%668 = arith.divsi %663, %666 : i64
%669 = llvm.mlir.addressof @G_n : !llvm.ptr
%670 = llvm.load %669 : !llvm.ptr -> i64
%671 = arith.constant 1 : i32
%673 = arith.extsi %671 : i32 to i64
%672 = arith.addi %628, %673 : i64
%674 = arith.divsi %670, %672 : i64
%661 = func.call @max64(%668, %674) : (i64, i64) -> i64
%676 = llvm.mlir.addressof @G_m : !llvm.ptr
%677 = llvm.load %676 : !llvm.ptr -> i64
%678 = llvm.load %586 : !llvm.ptr -> i64
%679 = arith.divsi %677, %678 : i64
%680 = llvm.mlir.addressof @G_n : !llvm.ptr
%681 = llvm.load %680 : !llvm.ptr -> i64
%682 = arith.divsi %681, %628 : i64
%675 = func.call @min64(%679, %682) : (i64, i64) -> i64
%683 = arith.cmpi sgt, %675, %661 : i64
cf.cond_br %683, ^bb123, ^bb124
^bb123:
%684 = llvm.load %580 : !llvm.ptr -> i128
%686 = llvm.load %586 : !llvm.ptr -> i64
%685 = func.call @G_fn(%686, %628, %arg0, %arg1) : (i64, i64, i64, i64) -> i128
%687 = func.call @sum_pows(%675, %582) : (i64, i64) -> i128
%688 = func.call @sum_pows(%661, %582) : (i64, i64) -> i128
%690 = arith.trunci %687 : i128 to i64
%691 = arith.trunci %688 : i128 to i64
%689 = arith.subi %690, %691 : i64
%693 = arith.trunci %685 : i128 to i64
%692 = arith.muli %693, %689 : i64
%695 = arith.trunci %684 : i128 to i64
%694 = arith.addi %695, %692 : i64
%696 = arith.extsi %694 : i64 to i128
llvm.store %696, %580 : i128, !llvm.ptr
cf.br ^bb125
^bb124:
cf.br ^bb125
^bb125:
%697 = arith.constant 0 : i32
%699 = arith.extsi %697 : i32 to i64
%698 = arith.cmpi ne, %635, %699 : i64
cf.cond_br %698, ^bb126, ^bb127
^bb126:
%701 = llvm.mlir.addressof @G_m : !llvm.ptr
%702 = llvm.load %701 : !llvm.ptr -> i64
%703 = llvm.load %586 : !llvm.ptr -> i64
%704 = arith.constant 1 : i32
%706 = arith.extsi %704 : i32 to i64
%705 = arith.addi %703, %706 : i64
%707 = arith.divsi %702, %705 : i64
%708 = llvm.mlir.addressof @G_n : !llvm.ptr
%709 = llvm.load %708 : !llvm.ptr -> i64
%710 = arith.constant 1 : i32
%712 = arith.extsi %710 : i32 to i64
%711 = arith.addi %635, %712 : i64
%713 = arith.divsi %709, %711 : i64
%700 = func.call @max64(%707, %713) : (i64, i64) -> i64
%715 = llvm.mlir.addressof @G_m : !llvm.ptr
%716 = llvm.load %715 : !llvm.ptr -> i64
%717 = llvm.load %586 : !llvm.ptr -> i64
%718 = arith.divsi %716, %717 : i64
%719 = llvm.mlir.addressof @G_n : !llvm.ptr
%720 = llvm.load %719 : !llvm.ptr -> i64
%721 = arith.divsi %720, %635 : i64
%714 = func.call @min64(%718, %721) : (i64, i64) -> i64
%722 = arith.cmpi sgt, %714, %700 : i64
cf.cond_br %722, ^bb129, ^bb130
^bb129:
%723 = llvm.load %580 : !llvm.ptr -> i128
%725 = llvm.load %586 : !llvm.ptr -> i64
%724 = func.call @G_fn(%725, %635, %arg0, %arg1) : (i64, i64, i64, i64) -> i128
%726 = func.call @sum_pows(%714, %582) : (i64, i64) -> i128
%727 = func.call @sum_pows(%700, %582) : (i64, i64) -> i128
%729 = arith.trunci %726 : i128 to i64
%730 = arith.trunci %727 : i128 to i64
%728 = arith.subi %729, %730 : i64
%732 = arith.trunci %724 : i128 to i64
%731 = arith.muli %732, %728 : i64
%734 = arith.trunci %723 : i128 to i64
%733 = arith.addi %734, %731 : i64
%735 = arith.extsi %733 : i64 to i128
llvm.store %735, %580 : i128, !llvm.ptr
cf.br ^bb131
^bb130:
cf.br ^bb131
^bb131:
cf.br ^bb128
^bb127:
cf.br ^bb128
^bb128:
cf.br ^bb122
^bb122:
%736 = llvm.load %586 : !llvm.ptr -> i64
%737 = arith.constant 1 : i32
%739 = arith.extsi %737 : i32 to i64
%738 = arith.addi %736, %739 : i64
llvm.store %738, %586 : i64, !llvm.ptr
cf.br ^bb117
^bb119:
%740 = llvm.load %580 : !llvm.ptr -> i128
func.return %740 : i128
}
func.func @f_fn(%arg0: i64, %arg1: i64, %arg2: i64) -> i128 {
%741 = func.call @H_fn(%arg0, %arg1, %arg2) : (i64, i64, i64) -> i128
%742 = llvm.mlir.constant(1 : i64) : i64
%743 = llvm.alloca %742 x i128 : (i64) -> !llvm.ptr
llvm.store %741, %743 : i128, !llvm.ptr
%744 = arith.constant 0 : i32
%746 = arith.extsi %744 : i32 to i64
%745 = arith.cmpi eq, %arg0, %746 : i64
cf.cond_br %745, ^bb132, ^bb133
^bb132:
%747 = llvm.load %743 : !llvm.ptr -> i128
%749 = llvm.mlir.addressof @G_n : !llvm.ptr
%750 = llvm.load %749 : !llvm.ptr -> i64
%751 = arith.addi %arg1, %arg2 : i64
%748 = func.call @sum_pows(%750, %751) : (i64, i64) -> i128
%753 = arith.trunci %747 : i128 to i64
%754 = arith.trunci %748 : i128 to i64
%752 = arith.addi %753, %754 : i64
%755 = arith.extsi %752 : i64 to i128
llvm.store %755, %743 : i128, !llvm.ptr
cf.br ^bb134
^bb133:
cf.br ^bb134
^bb134:
%756 = arith.constant 0 : i32
%758 = arith.extsi %756 : i32 to i64
%757 = arith.cmpi eq, %arg1, %758 : i64
cf.cond_br %757, ^bb135, ^bb136
^bb135:
%759 = llvm.load %743 : !llvm.ptr -> i128
%761 = llvm.mlir.addressof @G_m : !llvm.ptr
%762 = llvm.load %761 : !llvm.ptr -> i64
%763 = arith.addi %arg0, %arg2 : i64
%760 = func.call @sum_pows(%762, %763) : (i64, i64) -> i128
%765 = arith.trunci %759 : i128 to i64
%766 = arith.trunci %760 : i128 to i64
%764 = arith.addi %765, %766 : i64
%767 = arith.extsi %764 : i64 to i128
llvm.store %767, %743 : i128, !llvm.ptr
cf.br ^bb137
^bb136:
cf.br ^bb137
^bb137:
%768 = arith.addi %arg0, %arg1 : i64
%769 = arith.addi %768, %arg2 : i64
%770 = arith.constant 0 : i32
%772 = arith.extsi %770 : i32 to i64
%771 = arith.cmpi eq, %769, %772 : i64
cf.cond_br %771, ^bb138, ^bb139
^bb138:
%773 = llvm.load %743 : !llvm.ptr -> i128
%774 = arith.constant 1 : i32
%776 = arith.trunci %773 : i128 to i64
%777 = arith.extsi %774 : i32 to i64
%775 = arith.addi %776, %777 : i64
%778 = arith.extsi %775 : i64 to i128
llvm.store %778, %743 : i128, !llvm.ptr
cf.br ^bb140
^bb139:
cf.br ^bb140
^bb140:
%779 = llvm.load %743 : !llvm.ptr -> i128
func.return %779 : i128
}
func.func @comb(%arg0: i128, %arg1: i64) -> i128 {
%780 = arith.constant 0 : i32
%782 = arith.extsi %780 : i32 to i64
%781 = arith.cmpi slt, %arg1, %782 : i64
cf.cond_br %781, ^bb141, ^bb142
^bb141:
%783 = arith.constant 0 : i32
%784 = arith.extsi %783 : i32 to i128
func.return %784 : i128
^bb142:
cf.br ^bb143
^bb143:
%785 = arith.constant 1 : i32
%786 = arith.extsi %785 : i32 to i128
%787 = llvm.mlir.constant(1 : i64) : i64
%788 = llvm.alloca %787 x i128 : (i64) -> !llvm.ptr
llvm.store %786, %788 : i128, !llvm.ptr
%789 = arith.constant 1 : i32
%790 = arith.extsi %789 : i32 to i64
%791 = llvm.mlir.constant(1 : i64) : i64
%792 = llvm.alloca %791 x i64 : (i64) -> !llvm.ptr
llvm.store %790, %792 : i64, !llvm.ptr
cf.br ^bb144
^bb144:
%793 = llvm.load %792 : !llvm.ptr -> i64
%794 = arith.cmpi sle, %793, %arg1 : i64
cf.cond_br %794, ^bb145, ^bb146
^bb145:
%795 = llvm.load %788 : !llvm.ptr -> i128
%796 = llvm.load %792 : !llvm.ptr -> i64
%797 = arith.extsi %796 : i64 to i128
%799 = arith.trunci %arg0 : i128 to i64
%800 = arith.trunci %797 : i128 to i64
%798 = arith.subi %799, %800 : i64
%801 = arith.constant 1 : i32
%803 = arith.extsi %801 : i32 to i64
%802 = arith.addi %798, %803 : i64
%805 = arith.trunci %795 : i128 to i64
%804 = arith.muli %805, %802 : i64
%806 = llvm.load %792 : !llvm.ptr -> i64
%807 = arith.extsi %806 : i64 to i128
%809 = arith.trunci %807 : i128 to i64
%808 = arith.divsi %804, %809 : i64
%810 = arith.extsi %808 : i64 to i128
llvm.store %810, %788 : i128, !llvm.ptr
%811 = llvm.load %792 : !llvm.ptr -> i64
%812 = arith.constant 1 : i32
%814 = arith.extsi %812 : i32 to i64
%813 = arith.addi %811, %814 : i64
llvm.store %813, %792 : i64, !llvm.ptr
cf.br ^bb144
^bb146:
%815 = llvm.load %788 : !llvm.ptr -> i128
func.return %815 : i128
}
func.func @Q_mod(%arg0: i64, %arg1: i64) -> i64 {
%816 = llvm.mlir.addressof @G_m : !llvm.ptr
llvm.store %arg0, %816 : i64, !llvm.ptr
%817 = llvm.mlir.addressof @G_n : !llvm.ptr
llvm.store %arg1, %817 : i64, !llvm.ptr
%818 = arith.constant 0 : i32
%819 = arith.extsi %818 : i32 to i64
%820 = llvm.mlir.constant(1 : i64) : i64
%821 = llvm.alloca %820 x i64 : (i64) -> !llvm.ptr
llvm.store %819, %821 : i64, !llvm.ptr
cf.br ^bb147
^bb147:
%822 = llvm.load %821 : !llvm.ptr -> i64
%823 = llvm.mlir.addressof @CAP : !llvm.ptr
%824 = llvm.load %823 : !llvm.ptr -> i64
%825 = arith.cmpi slt, %822, %824 : i64
cf.cond_br %825, ^bb148, ^bb149
^bb148:
%826 = arith.constant 0 : i32
%827 = llvm.mlir.addressof @G_u : !llvm.ptr
%828 = llvm.load %827 : !llvm.ptr -> !llvm.ptr
%829 = llvm.load %821 : !llvm.ptr -> i64
%830 = arith.trunci %826 : i32 to i8
%831 = llvm.getelementptr %828[%829] : (!llvm.ptr, i64) -> !llvm.ptr, i8
llvm.store %830, %831 : i8, !llvm.ptr
%832 = llvm.load %821 : !llvm.ptr -> i64
%833 = arith.constant 1 : i32
%835 = arith.extsi %833 : i32 to i64
%834 = arith.addi %832, %835 : i64
llvm.store %834, %821 : i64, !llvm.ptr
cf.br ^bb147
^bb149:
%837 = arith.constant 0 : i32
%838 = arith.constant 0 : i32
%839 = arith.constant 1 : i32
%840 = arith.extsi %837 : i32 to i64
%841 = arith.extsi %838 : i32 to i64
%842 = arith.extsi %839 : i32 to i64
%836 = func.call @f_fn(%840, %841, %842) : (i64, i64, i64) -> i128
%844 = arith.constant 0 : i32
%845 = arith.constant 1 : i32
%846 = arith.constant 1 : i32
%847 = arith.extsi %844 : i32 to i64
%848 = arith.extsi %845 : i32 to i64
%849 = arith.extsi %846 : i32 to i64
%843 = func.call @f_fn(%847, %848, %849) : (i64, i64, i64) -> i128
%851 = arith.constant 1 : i32
%852 = arith.constant 0 : i32
%853 = arith.constant 1 : i32
%854 = arith.extsi %851 : i32 to i64
%855 = arith.extsi %852 : i32 to i64
%856 = arith.extsi %853 : i32 to i64
%850 = func.call @f_fn(%854, %855, %856) : (i64, i64, i64) -> i128
%858 = arith.constant 1 : i32
%859 = arith.constant 1 : i32
%860 = arith.constant 1 : i32
%861 = arith.extsi %858 : i32 to i64
%862 = arith.extsi %859 : i32 to i64
%863 = arith.extsi %860 : i32 to i64
%857 = func.call @f_fn(%861, %862, %863) : (i64, i64, i64) -> i128
%865 = arith.constant 0 : i32
%866 = arith.constant 0 : i32
%867 = arith.constant 2 : i32
%868 = arith.extsi %865 : i32 to i64
%869 = arith.extsi %866 : i32 to i64
%870 = arith.extsi %867 : i32 to i64
%864 = func.call @f_fn(%868, %869, %870) : (i64, i64, i64) -> i128
%872 = arith.constant 0 : i32
%873 = arith.constant 1 : i32
%874 = arith.constant 2 : i32
%875 = arith.extsi %872 : i32 to i64
%876 = arith.extsi %873 : i32 to i64
%877 = arith.extsi %874 : i32 to i64
%871 = func.call @f_fn(%875, %876, %877) : (i64, i64, i64) -> i128
%879 = arith.constant 1 : i32
%880 = arith.constant 0 : i32
%881 = arith.constant 2 : i32
%882 = arith.extsi %879 : i32 to i64
%883 = arith.extsi %880 : i32 to i64
%884 = arith.extsi %881 : i32 to i64
%878 = func.call @f_fn(%882, %883, %884) : (i64, i64, i64) -> i128
%886 = arith.constant 1 : i32
%887 = arith.constant 1 : i32
%888 = arith.constant 2 : i32
%889 = arith.extsi %886 : i32 to i64
%890 = arith.extsi %887 : i32 to i64
%891 = arith.extsi %888 : i32 to i64
%885 = func.call @f_fn(%889, %890, %891) : (i64, i64, i64) -> i128
%893 = arith.constant 0 : i32
%894 = arith.constant 0 : i32
%895 = arith.constant 0 : i32
%896 = arith.extsi %893 : i32 to i64
%897 = arith.extsi %894 : i32 to i64
%898 = arith.extsi %895 : i32 to i64
%892 = func.call @f_fn(%896, %897, %898) : (i64, i64, i64) -> i128
%900 = arith.constant 0 : i32
%901 = arith.constant 1 : i32
%902 = arith.constant 0 : i32
%903 = arith.extsi %900 : i32 to i64
%904 = arith.extsi %901 : i32 to i64
%905 = arith.extsi %902 : i32 to i64
%899 = func.call @f_fn(%903, %904, %905) : (i64, i64, i64) -> i128
%907 = arith.constant 1 : i32
%908 = arith.constant 0 : i32
%909 = arith.constant 0 : i32
%910 = arith.extsi %907 : i32 to i64
%911 = arith.extsi %908 : i32 to i64
%912 = arith.extsi %909 : i32 to i64
%906 = func.call @f_fn(%910, %911, %912) : (i64, i64, i64) -> i128
%914 = arith.constant 1 : i32
%915 = arith.constant 1 : i32
%916 = arith.constant 0 : i32
%917 = arith.extsi %914 : i32 to i64
%918 = arith.extsi %915 : i32 to i64
%919 = arith.extsi %916 : i32 to i64
%913 = func.call @f_fn(%917, %918, %919) : (i64, i64, i64) -> i128
%921 = arith.constant 3 : i32
%922 = arith.constant 3 : i32
%923 = arith.constant 0 : i32
%924 = arith.extsi %921 : i32 to i64
%925 = arith.extsi %922 : i32 to i64
%926 = arith.extsi %923 : i32 to i64
%920 = func.call @f_fn(%924, %925, %926) : (i64, i64, i64) -> i128
%928 = arith.constant 3 : i32
%929 = arith.constant 2 : i32
%930 = arith.constant 0 : i32
%931 = arith.extsi %928 : i32 to i64
%932 = arith.extsi %929 : i32 to i64
%933 = arith.extsi %930 : i32 to i64
%927 = func.call @f_fn(%931, %932, %933) : (i64, i64, i64) -> i128
%935 = arith.constant 2 : i32
%936 = arith.constant 3 : i32
%937 = arith.constant 0 : i32
%938 = arith.extsi %935 : i32 to i64
%939 = arith.extsi %936 : i32 to i64
%940 = arith.extsi %937 : i32 to i64
%934 = func.call @f_fn(%938, %939, %940) : (i64, i64, i64) -> i128
%942 = arith.constant 2 : i32
%943 = arith.constant 2 : i32
%944 = arith.constant 0 : i32
%945 = arith.extsi %942 : i32 to i64
%946 = arith.extsi %943 : i32 to i64
%947 = arith.extsi %944 : i32 to i64
%941 = func.call @f_fn(%945, %946, %947) : (i64, i64, i64) -> i128
%949 = arith.constant 3 : i32
%950 = arith.constant 1 : i32
%951 = arith.constant 0 : i32
%952 = arith.extsi %949 : i32 to i64
%953 = arith.extsi %950 : i32 to i64
%954 = arith.extsi %951 : i32 to i64
%948 = func.call @f_fn(%952, %953, %954) : (i64, i64, i64) -> i128
%956 = arith.constant 2 : i32
%957 = arith.constant 1 : i32
%958 = arith.constant 0 : i32
%959 = arith.extsi %956 : i32 to i64
%960 = arith.extsi %957 : i32 to i64
%961 = arith.extsi %958 : i32 to i64
%955 = func.call @f_fn(%959, %960, %961) : (i64, i64, i64) -> i128
%963 = arith.constant 3 : i32
%964 = arith.constant 0 : i32
%965 = arith.constant 0 : i32
%966 = arith.extsi %963 : i32 to i64
%967 = arith.extsi %964 : i32 to i64
%968 = arith.extsi %965 : i32 to i64
%962 = func.call @f_fn(%966, %967, %968) : (i64, i64, i64) -> i128
%970 = arith.constant 2 : i32
%971 = arith.constant 0 : i32
%972 = arith.constant 0 : i32
%973 = arith.extsi %970 : i32 to i64
%974 = arith.extsi %971 : i32 to i64
%975 = arith.extsi %972 : i32 to i64
%969 = func.call @f_fn(%973, %974, %975) : (i64, i64, i64) -> i128
%977 = arith.constant 1 : i32
%978 = arith.constant 3 : i32
%979 = arith.constant 0 : i32
%980 = arith.extsi %977 : i32 to i64
%981 = arith.extsi %978 : i32 to i64
%982 = arith.extsi %979 : i32 to i64
%976 = func.call @f_fn(%980, %981, %982) : (i64, i64, i64) -> i128
%984 = arith.constant 1 : i32
%985 = arith.constant 2 : i32
%986 = arith.constant 0 : i32
%987 = arith.extsi %984 : i32 to i64
%988 = arith.extsi %985 : i32 to i64
%989 = arith.extsi %986 : i32 to i64
%983 = func.call @f_fn(%987, %988, %989) : (i64, i64, i64) -> i128
%991 = arith.constant 0 : i32
%992 = arith.constant 3 : i32
%993 = arith.constant 0 : i32
%994 = arith.extsi %991 : i32 to i64
%995 = arith.extsi %992 : i32 to i64
%996 = arith.extsi %993 : i32 to i64
%990 = func.call @f_fn(%994, %995, %996) : (i64, i64, i64) -> i128
%998 = arith.constant 0 : i32
%999 = arith.constant 2 : i32
%1000 = arith.constant 0 : i32
%1001 = arith.extsi %998 : i32 to i64
%1002 = arith.extsi %999 : i32 to i64
%1003 = arith.extsi %1000 : i32 to i64
%997 = func.call @f_fn(%1001, %1002, %1003) : (i64, i64, i64) -> i128
%1004 = arith.constant 1 : i32
%1006 = arith.extsi %1004 : i32 to i64
%1005 = arith.addi %arg0, %1006 : i64
%1007 = arith.extsi %1005 : i64 to i128
%1008 = arith.constant 1 : i32
%1010 = arith.extsi %1008 : i32 to i64
%1009 = arith.addi %arg1, %1010 : i64
%1011 = arith.extsi %1009 : i64 to i128
%1013 = arith.trunci %1007 : i128 to i64
%1014 = arith.trunci %1011 : i128 to i64
%1012 = arith.muli %1013, %1014 : i64
%1015 = arith.extsi %1012 : i64 to i128
%1016 = arith.constant 11 : i32
%1018 = arith.extsi %1016 : i32 to i64
%1019 = arith.trunci %934 : i128 to i64
%1017 = arith.muli %1018, %1019 : i64
%1021 = arith.trunci %871 : i128 to i64
%1020 = arith.subi %1021, %1017 : i64
%1023 = arith.trunci %955 : i128 to i64
%1022 = arith.subi %1020, %1023 : i64
%1025 = arith.trunci %990 : i128 to i64
%1024 = arith.subi %1022, %1025 : i64
%1027 = arith.trunci %1007 : i128 to i64
%1026 = arith.muli %1024, %1027 : i64
%1028 = arith.constant 11 : i32
%1030 = arith.extsi %1028 : i32 to i64
%1031 = arith.trunci %927 : i128 to i64
%1029 = arith.muli %1030, %1031 : i64
%1033 = arith.trunci %878 : i128 to i64
%1032 = arith.subi %1033, %1029 : i64
%1035 = arith.trunci %962 : i128 to i64
%1034 = arith.subi %1032, %1035 : i64
%1037 = arith.trunci %983 : i128 to i64
%1036 = arith.subi %1034, %1037 : i64
%1039 = arith.trunci %1011 : i128 to i64
%1038 = arith.muli %1036, %1039 : i64
%1040 = arith.addi %1026, %1038 : i64
%1041 = arith.constant 11 : i32
%1043 = arith.extsi %1041 : i32 to i64
%1044 = arith.trunci %920 : i128 to i64
%1042 = arith.muli %1043, %1044 : i64
%1046 = arith.trunci %885 : i128 to i64
%1045 = arith.subi %1046, %1042 : i64
%1048 = arith.trunci %948 : i128 to i64
%1047 = arith.subi %1045, %1048 : i64
%1050 = arith.trunci %976 : i128 to i64
%1049 = arith.subi %1047, %1050 : i64
%1051 = arith.subi %1040, %1049 : i64
%1052 = arith.constant 11 : i32
%1054 = arith.extsi %1052 : i32 to i64
%1055 = arith.trunci %941 : i128 to i64
%1053 = arith.muli %1054, %1055 : i64
%1057 = arith.trunci %864 : i128 to i64
%1056 = arith.subi %1057, %1053 : i64
%1059 = arith.trunci %969 : i128 to i64
%1058 = arith.subi %1056, %1059 : i64
%1061 = arith.trunci %997 : i128 to i64
%1060 = arith.subi %1058, %1061 : i64
%1063 = arith.trunci %1007 : i128 to i64
%1062 = arith.muli %1060, %1063 : i64
%1065 = arith.trunci %1011 : i128 to i64
%1064 = arith.muli %1062, %1065 : i64
%1066 = arith.subi %1051, %1064 : i64
%1067 = arith.extsi %1066 : i64 to i128
%1068 = arith.constant 2 : i32
%1070 = arith.trunci %899 : i128 to i64
%1071 = arith.trunci %843 : i128 to i64
%1069 = arith.subi %1070, %1071 : i64
%1073 = arith.trunci %1007 : i128 to i64
%1072 = arith.muli %1069, %1073 : i64
%1075 = arith.trunci %906 : i128 to i64
%1076 = arith.trunci %850 : i128 to i64
%1074 = arith.subi %1075, %1076 : i64
%1078 = arith.trunci %1011 : i128 to i64
%1077 = arith.muli %1074, %1078 : i64
%1079 = arith.addi %1072, %1077 : i64
%1081 = arith.trunci %892 : i128 to i64
%1082 = arith.trunci %836 : i128 to i64
%1080 = arith.subi %1081, %1082 : i64
%1084 = arith.trunci %1007 : i128 to i64
%1083 = arith.muli %1080, %1084 : i64
%1086 = arith.trunci %1011 : i128 to i64
%1085 = arith.muli %1083, %1086 : i64
%1087 = arith.subi %1079, %1085 : i64
%1089 = arith.trunci %913 : i128 to i64
%1090 = arith.trunci %857 : i128 to i64
%1088 = arith.subi %1089, %1090 : i64
%1091 = arith.subi %1087, %1088 : i64
%1093 = arith.extsi %1068 : i32 to i64
%1092 = arith.muli %1093, %1091 : i64
%1095 = arith.trunci %997 : i128 to i64
%1094 = arith.addi %1092, %1095 : i64
%1096 = arith.constant 2 : i32
%1098 = arith.extsi %1096 : i32 to i64
%1097 = arith.addi %arg1, %1098 : i64
%1099 = arith.extsi %1097 : i64 to i128
%1101 = arith.trunci %1099 : i128 to i64
%1102 = arith.trunci %899 : i128 to i64
%1100 = arith.muli %1101, %1102 : i64
%1103 = arith.subi %1094, %1100 : i64
%1105 = arith.trunci %1011 : i128 to i64
%1106 = arith.trunci %892 : i128 to i64
%1104 = arith.muli %1105, %1106 : i64
%1107 = arith.addi %1103, %1104 : i64
%1109 = arith.trunci %969 : i128 to i64
%1108 = arith.addi %1107, %1109 : i64
%1110 = arith.constant 2 : i32
%1112 = arith.extsi %1110 : i32 to i64
%1111 = arith.addi %arg0, %1112 : i64
%1113 = arith.extsi %1111 : i64 to i128
%1115 = arith.trunci %1113 : i128 to i64
%1116 = arith.trunci %906 : i128 to i64
%1114 = arith.muli %1115, %1116 : i64
%1117 = arith.subi %1108, %1114 : i64
%1119 = arith.trunci %1007 : i128 to i64
%1120 = arith.trunci %892 : i128 to i64
%1118 = arith.muli %1119, %1120 : i64
%1121 = arith.addi %1117, %1118 : i64
%1122 = arith.extsi %1121 : i64 to i128
%1123 = arith.constant 4 : i32
%1125 = arith.trunci %892 : i128 to i64
%1126 = arith.extsi %1123 : i32 to i64
%1124 = arith.muli %1125, %1126 : i64
%1127 = arith.constant 6 : i32
%1129 = arith.trunci %836 : i128 to i64
%1130 = arith.extsi %1127 : i32 to i64
%1128 = arith.muli %1129, %1130 : i64
%1131 = arith.subi %1124, %1128 : i64
%1132 = arith.constant 2 : i32
%1134 = arith.trunci %864 : i128 to i64
%1135 = arith.extsi %1132 : i32 to i64
%1133 = arith.muli %1134, %1135 : i64
%1136 = arith.addi %1131, %1133 : i64
%1138 = arith.trunci %1007 : i128 to i64
%1137 = arith.muli %1136, %1138 : i64
%1140 = arith.trunci %1011 : i128 to i64
%1139 = arith.muli %1137, %1140 : i64
%1141 = arith.constant 4 : i32
%1143 = arith.trunci %913 : i128 to i64
%1144 = arith.extsi %1141 : i32 to i64
%1142 = arith.muli %1143, %1144 : i64
%1145 = arith.constant 6 : i32
%1147 = arith.trunci %857 : i128 to i64
%1148 = arith.extsi %1145 : i32 to i64
%1146 = arith.muli %1147, %1148 : i64
%1149 = arith.subi %1142, %1146 : i64
%1150 = arith.constant 2 : i32
%1152 = arith.trunci %885 : i128 to i64
%1153 = arith.extsi %1150 : i32 to i64
%1151 = arith.muli %1152, %1153 : i64
%1154 = arith.addi %1149, %1151 : i64
%1155 = arith.addi %1139, %1154 : i64
%1156 = arith.constant 4 : i32
%1158 = arith.trunci %906 : i128 to i64
%1159 = arith.extsi %1156 : i32 to i64
%1157 = arith.muli %1158, %1159 : i64
%1160 = arith.constant 6 : i32
%1162 = arith.trunci %850 : i128 to i64
%1163 = arith.extsi %1160 : i32 to i64
%1161 = arith.muli %1162, %1163 : i64
%1164 = arith.subi %1157, %1161 : i64
%1165 = arith.constant 2 : i32
%1167 = arith.trunci %878 : i128 to i64
%1168 = arith.extsi %1165 : i32 to i64
%1166 = arith.muli %1167, %1168 : i64
%1169 = arith.addi %1164, %1166 : i64
%1171 = arith.trunci %1011 : i128 to i64
%1170 = arith.muli %1169, %1171 : i64
%1172 = arith.subi %1155, %1170 : i64
%1173 = arith.constant 4 : i32
%1175 = arith.trunci %899 : i128 to i64
%1176 = arith.extsi %1173 : i32 to i64
%1174 = arith.muli %1175, %1176 : i64
%1177 = arith.constant 6 : i32
%1179 = arith.trunci %843 : i128 to i64
%1180 = arith.extsi %1177 : i32 to i64
%1178 = arith.muli %1179, %1180 : i64
%1181 = arith.subi %1174, %1178 : i64
%1182 = arith.constant 2 : i32
%1184 = arith.trunci %871 : i128 to i64
%1185 = arith.extsi %1182 : i32 to i64
%1183 = arith.muli %1184, %1185 : i64
%1186 = arith.addi %1181, %1183 : i64
%1188 = arith.trunci %1007 : i128 to i64
%1187 = arith.muli %1186, %1188 : i64
%1189 = arith.subi %1172, %1187 : i64
%1191 = arith.trunci %990 : i128 to i64
%1190 = arith.addi %1189, %1191 : i64
%1192 = arith.constant 4 : i32
%1194 = arith.extsi %1192 : i32 to i64
%1193 = arith.addi %arg1, %1194 : i64
%1195 = arith.extsi %1193 : i64 to i128
%1197 = arith.trunci %1195 : i128 to i64
%1198 = arith.trunci %997 : i128 to i64
%1196 = arith.muli %1197, %1198 : i64
%1199 = arith.subi %1190, %1196 : i64
%1200 = arith.constant 3 : i32
%1202 = arith.extsi %1200 : i32 to i64
%1201 = arith.muli %1202, %arg1 : i64
%1203 = arith.constant 5 : i32
%1205 = arith.extsi %1203 : i32 to i64
%1204 = arith.addi %1201, %1205 : i64
%1206 = arith.extsi %1204 : i64 to i128
%1208 = arith.trunci %1206 : i128 to i64
%1209 = arith.trunci %899 : i128 to i64
%1207 = arith.muli %1208, %1209 : i64
%1210 = arith.addi %1199, %1207 : i64
%1211 = arith.constant 2 : i32
%1213 = arith.extsi %1211 : i32 to i64
%1214 = arith.trunci %1011 : i128 to i64
%1212 = arith.muli %1213, %1214 : i64
%1216 = arith.trunci %892 : i128 to i64
%1215 = arith.muli %1212, %1216 : i64
%1217 = arith.subi %1210, %1215 : i64
%1219 = arith.trunci %962 : i128 to i64
%1218 = arith.addi %1217, %1219 : i64
%1220 = arith.constant 4 : i32
%1222 = arith.extsi %1220 : i32 to i64
%1221 = arith.addi %arg0, %1222 : i64
%1223 = arith.extsi %1221 : i64 to i128
%1225 = arith.trunci %1223 : i128 to i64
%1226 = arith.trunci %969 : i128 to i64
%1224 = arith.muli %1225, %1226 : i64
%1227 = arith.subi %1218, %1224 : i64
%1228 = arith.constant 3 : i32
%1230 = arith.extsi %1228 : i32 to i64
%1229 = arith.muli %1230, %arg0 : i64
%1231 = arith.constant 5 : i32
%1233 = arith.extsi %1231 : i32 to i64
%1232 = arith.addi %1229, %1233 : i64
%1234 = arith.extsi %1232 : i64 to i128
%1236 = arith.trunci %1234 : i128 to i64
%1237 = arith.trunci %906 : i128 to i64
%1235 = arith.muli %1236, %1237 : i64
%1238 = arith.addi %1227, %1235 : i64
%1239 = arith.constant 2 : i32
%1241 = arith.extsi %1239 : i32 to i64
%1242 = arith.trunci %1007 : i128 to i64
%1240 = arith.muli %1241, %1242 : i64
%1244 = arith.trunci %892 : i128 to i64
%1243 = arith.muli %1240, %1244 : i64
%1245 = arith.subi %1238, %1243 : i64
%1246 = arith.extsi %1245 : i64 to i128
%1248 = arith.constant 4 : i32
%1249 = arith.extsi %1248 : i32 to i64
%1247 = func.call @comb(%1015, %1249) : (i128, i64) -> i128
%1251 = arith.constant 3 : i32
%1252 = arith.extsi %1251 : i32 to i64
%1250 = func.call @comb(%1015, %1252) : (i128, i64) -> i128
%1254 = arith.trunci %1247 : i128 to i64
%1255 = arith.trunci %1250 : i128 to i64
%1253 = arith.subi %1254, %1255 : i64
%1256 = arith.constant 3 : i32
%1258 = arith.trunci %1067 : i128 to i64
%1259 = arith.extsi %1256 : i32 to i64
%1257 = arith.divsi %1258, %1259 : i64
%1260 = arith.addi %1253, %1257 : i64
%1261 = arith.constant 7 : i32
%1262 = arith.constant 2 : i32
%1264 = arith.extsi %1262 : i32 to i64
%1265 = arith.trunci %1015 : i128 to i64
%1263 = arith.muli %1264, %1265 : i64
%1267 = arith.extsi %1261 : i32 to i64
%1266 = arith.subi %1267, %1263 : i64
%1269 = arith.trunci %1122 : i128 to i64
%1268 = arith.muli %1266, %1269 : i64
%1270 = arith.addi %1260, %1268 : i64
%1271 = arith.constant 7 : i32
%1272 = arith.constant 2 : i32
%1274 = arith.trunci %1246 : i128 to i64
%1275 = arith.extsi %1272 : i32 to i64
%1273 = arith.divsi %1274, %1275 : i64
%1277 = arith.extsi %1271 : i32 to i64
%1276 = arith.muli %1277, %1273 : i64
%1278 = arith.addi %1270, %1276 : i64
%1279 = arith.extsi %1278 : i64 to i128
%1280 = llvm.mlir.addressof @MOD : !llvm.ptr
%1281 = llvm.load %1280 : !llvm.ptr -> i64
%1282 = arith.extsi %1281 : i64 to i128
%1284 = arith.trunci %1279 : i128 to i64
%1285 = arith.trunci %1282 : i128 to i64
%1283 = arith.remsi %1284, %1285 : i64
%1286 = arith.extsi %1283 : i64 to i128
%1287 = llvm.mlir.constant(1 : i64) : i64
%1288 = llvm.alloca %1287 x i128 : (i64) -> !llvm.ptr
llvm.store %1286, %1288 : i128, !llvm.ptr
%1289 = llvm.load %1288 : !llvm.ptr -> i128
%1290 = arith.constant 0 : i32
%1292 = arith.trunci %1289 : i128 to i64
%1293 = arith.extsi %1290 : i32 to i64
%1291 = arith.cmpi slt, %1292, %1293 : i64
cf.cond_br %1291, ^bb150, ^bb151
^bb150:
%1294 = llvm.load %1288 : !llvm.ptr -> i128
%1296 = arith.trunci %1294 : i128 to i64
%1297 = arith.trunci %1282 : i128 to i64
%1295 = arith.addi %1296, %1297 : i64
%1298 = arith.extsi %1295 : i64 to i128
llvm.store %1298, %1288 : i128, !llvm.ptr
cf.br ^bb152
^bb151:
cf.br ^bb152
^bb152:
%1299 = llvm.load %1288 : !llvm.ptr -> i128
%1300 = arith.trunci %1299 : i128 to i64
func.return %1300 : i64
}
func.func @main() -> i32 {
%1302 = llvm.mlir.addressof @CAP : !llvm.ptr
%1303 = llvm.load %1302 : !llvm.ptr -> i64
%1304 = arith.constant 8 : i32
%1305 = arith.extsi %1304 : i32 to i64
%1301 = func.call @calloc(%1303, %1305) : (i64, i64) -> !llvm.ptr
%1306 = llvm.mlir.addressof @G_k1 : !llvm.ptr
llvm.store %1301, %1306 : !llvm.ptr, !llvm.ptr
%1308 = llvm.mlir.addressof @CAP : !llvm.ptr
%1309 = llvm.load %1308 : !llvm.ptr -> i64
%1310 = arith.constant 8 : i32
%1311 = arith.extsi %1310 : i32 to i64
%1307 = func.call @calloc(%1309, %1311) : (i64, i64) -> !llvm.ptr
%1312 = llvm.mlir.addressof @G_k2 : !llvm.ptr
llvm.store %1307, %1312 : !llvm.ptr, !llvm.ptr
%1314 = llvm.mlir.addressof @CAP : !llvm.ptr
%1315 = llvm.load %1314 : !llvm.ptr -> i64
%1316 = arith.constant 16 : i32
%1317 = arith.extsi %1316 : i32 to i64
%1313 = func.call @calloc(%1315, %1317) : (i64, i64) -> !llvm.ptr
%1318 = llvm.mlir.addressof @G_v : !llvm.ptr
llvm.store %1313, %1318 : !llvm.ptr, !llvm.ptr
%1320 = llvm.mlir.addressof @CAP : !llvm.ptr
%1321 = llvm.load %1320 : !llvm.ptr -> i64
%1322 = arith.constant 1 : i32
%1323 = arith.extsi %1322 : i32 to i64
%1319 = func.call @calloc(%1321, %1323) : (i64, i64) -> !llvm.ptr
%1324 = llvm.mlir.addressof @G_u : !llvm.ptr
llvm.store %1319, %1324 : !llvm.ptr, !llvm.ptr
%1325 = llvm.mlir.addressof @G_k1 : !llvm.ptr
%1326 = llvm.load %1325 : !llvm.ptr -> !llvm.ptr
%1327 = llvm.mlir.zero : !llvm.ptr
%1328 = llvm.icmp "eq" %1326, %1327 : !llvm.ptr
%1329 = scf.if %1328 -> (i1) {
%1330 = arith.constant true
scf.yield %1330 : i1
} else {
%1331 = llvm.mlir.addressof @G_k2 : !llvm.ptr
%1332 = llvm.load %1331 : !llvm.ptr -> !llvm.ptr
%1333 = llvm.mlir.zero : !llvm.ptr
%1334 = llvm.icmp "eq" %1332, %1333 : !llvm.ptr
scf.yield %1334 : i1
}
%1335 = scf.if %1329 -> (i1) {
%1336 = arith.constant true
scf.yield %1336 : i1
} else {
%1337 = llvm.mlir.addressof @G_v : !llvm.ptr
%1338 = llvm.load %1337 : !llvm.ptr -> !llvm.ptr
%1339 = llvm.mlir.zero : !llvm.ptr
%1340 = llvm.icmp "eq" %1338, %1339 : !llvm.ptr
scf.yield %1340 : i1
}
%1341 = scf.if %1335 -> (i1) {
%1342 = arith.constant true
scf.yield %1342 : i1
} else {
%1343 = llvm.mlir.addressof @G_u : !llvm.ptr
%1344 = llvm.load %1343 : !llvm.ptr -> !llvm.ptr
%1345 = llvm.mlir.zero : !llvm.ptr
%1346 = llvm.icmp "eq" %1344, %1345 : !llvm.ptr
scf.yield %1346 : i1
}
cf.cond_br %1341, ^bb153, ^bb154
^bb153:
%1347 = arith.constant 1 : i32
func.return %1347 : i32
^bb154:
cf.br ^bb155
^bb155:
%1348 = llvm.mlir.addressof @str_0 : !llvm.ptr
%1350 = arith.constant 12345 : i32
%1351 = arith.constant 6789 : i32
%1352 = arith.extsi %1350 : i32 to i64
%1353 = arith.extsi %1351 : i32 to i64
%1349 = func.call @Q_mod(%1352, %1353) : (i64, i64) -> i64
%1354 = llvm.call @printf(%1348, %1349) vararg(!llvm.func<i32 (ptr, ...)>) : (!llvm.ptr, i64) -> i32
%1356 = llvm.mlir.addressof @G_u : !llvm.ptr
%1357 = llvm.load %1356 : !llvm.ptr -> !llvm.ptr
func.call @free(%1357) : (!llvm.ptr) -> ()
%1359 = llvm.mlir.addressof @G_v : !llvm.ptr
%1360 = llvm.load %1359 : !llvm.ptr -> !llvm.ptr
func.call @free(%1360) : (!llvm.ptr) -> ()
%1362 = llvm.mlir.addressof @G_k2 : !llvm.ptr
%1363 = llvm.load %1362 : !llvm.ptr -> !llvm.ptr
func.call @free(%1363) : (!llvm.ptr) -> ()
%1365 = llvm.mlir.addressof @G_k1 : !llvm.ptr
%1366 = llvm.load %1365 : !llvm.ptr -> !llvm.ptr
func.call @free(%1366) : (!llvm.ptr) -> ()
%1367 = arith.constant 0 : i32
func.return %1367 : i32
}
}