← All problems
Problem 680
Yarra Gnisrever: R(10^18, 10^6) mod 10^9. A stays a union of arithmetic runs, so represent it as an implicit treap whose nodes are segments (start value, length, direction) keyed by position, with a lazy reverse flag. Each of the 10^6 reversals is two position-splits, a flag toggle, and two merges; at most two new nodes per operation. The final sum uses sum(i) and sum(i^2) closed forms with the exact divisions by 2 and 6 done before reducing mod 10^9 (composite modulus, so no inverses). In the R(5,4) example the fourth operation has s > t; matching the given value 27 requires treating that as reversing [t, s].
View problem on Project Euler
Performance comparison
Metric Our solution Best known
Time complexity O(n)O(n log n)
Space complexity O(n)O(n)
Approach Flow solution Modular DP or matrix exponentiation
Verdict Optimal
Flow source
# Project Euler 680
# Yarra Gnisrever: R(10^18, 10^6) mod 10^9.
#
# A stays a union of arithmetic runs, so represent it as an implicit treap
# whose nodes are segments (start value, length, direction) keyed by
# position, with a lazy reverse flag. Each of the 10^6 reversals is two
# position-splits, a flag toggle, and two merges; at most two new nodes per
# operation. The final sum uses sum(i) and sum(i^2) closed forms with the
# exact divisions by 2 and 6 done before reducing mod 10^9 (composite
# modulus, so no inverses).
#
# In the R(5,4) example the fourth operation has s > t; matching the given
# value 27 requires treating that as reversing [t, s].
extern {
function calloc(n: i64, size: i64) -> ptr<void>
function free(p: ptr<void>) -> void
}
const MODM: i64 = 1000000000
const BIGN: i64 = 1000000000000000000
const K: i64 = 1000000
const CAP: i64 = 2100000
# node pool: 8 slots per node
# 0 pri, 1 left, 2 right, 3 len, 4 val, 5 dir, 6 sz, 7 flip
# misc: [0] node count, [1] rng state, [2] split second-result
function nn_new(P: ptr<i64>, misc: ptr<i64>, val: i64, ln: i64, dr: i64) -> i64 {
let x: i64 = misc[0] + 1
misc[0] = x
let mut st: i64 = misc[1]
st = (st * 1103515245 + 12345) % 2147483648
misc[1] = st
let b: i64 = x * 8
P[b + 0] = st
P[b + 1] = 0
P[b + 2] = 0
P[b + 3] = ln
P[b + 4] = val
P[b + 5] = dr
P[b + 6] = ln
P[b + 7] = 0
return x
}
function nn_push(P: ptr<i64>, x: i64) -> void {
let b: i64 = x * 8
if P[b + 7] == 1 {
let l: i64 = P[b + 1]
P[b + 1] = P[b + 2]
P[b + 2] = l
if P[b + 5] == 0 {
P[b + 4] = P[b + 4] + P[b + 3] - 1
P[b + 5] = 1
} else {
P[b + 4] = P[b + 4] - P[b + 3] + 1
P[b + 5] = 0
}
if P[b + 1] != 0 {
P[P[b + 1] * 8 + 7] = 1 - P[P[b + 1] * 8 + 7]
}
if P[b + 2] != 0 {
P[P[b + 2] * 8 + 7] = 1 - P[P[b + 2] * 8 + 7]
}
P[b + 7] = 0
}
}
function nn_upd(P: ptr<i64>, x: i64) -> void {
let b: i64 = x * 8
P[b + 6] = P[b + 3] + P[P[b + 1] * 8 + 6] + P[P[b + 2] * 8 + 6]
}
function tr_merge(P: ptr<i64>, a: i64, b: i64) -> i64 {
if a == 0 {
return b
}
if b == 0 {
return a
}
if P[a * 8 + 0] > P[b * 8 + 0] {
nn_push(P, a)
P[a * 8 + 2] = tr_merge(P, P[a * 8 + 2], b)
nn_upd(P, a)
return a
}
nn_push(P, b)
P[b * 8 + 1] = tr_merge(P, a, P[b * 8 + 1])
nn_upd(P, b)
return b
}
# split first k elements off; returns left root, stores right root in misc[2]
function tr_split(P: ptr<i64>, misc: ptr<i64>, x: i64, k: i64) -> i64 {
if x == 0 {
misc[2] = 0
return 0
}
nn_push(P, x)
let b: i64 = x * 8
let lsz: i64 = P[P[b + 1] * 8 + 6]
if k <= lsz {
let a: i64 = tr_split(P, misc, P[b + 1], k)
P[b + 1] = misc[2]
nn_upd(P, x)
misc[2] = x
return a
}
let k2: i64 = k - lsz
if k2 >= P[b + 3] {
let a2: i64 = tr_split(P, misc, P[b + 2], k2 - P[b + 3])
P[b + 2] = a2
nn_upd(P, x)
# misc[2] already holds the right part
return x
}
# split inside this node's segment at offset k2
let mut nv: i64 = 0
if P[b + 5] == 0 {
nv = P[b + 4] + k2
} else {
nv = P[b + 4] - k2
}
let nn: i64 = nn_new(P, misc, nv, P[b + 3] - k2, P[b + 5])
P[b + 3] = k2
let xr: i64 = P[b + 2]
P[b + 2] = 0
nn_upd(P, x)
misc[2] = tr_merge(P, nn, xr)
return x
}
# accumulate sum of i*A[i] mod MODM; acc: [0] position, [1] total
function tr_visit(P: ptr<i64>, x: i64, acc: ptr<i64>) -> void {
if x == 0 {
return
}
nn_push(P, x)
let b: i64 = x * 8
tr_visit(P, P[b + 1], acc)
let L: i64 = P[b + 3]
let a0: i64 = P[b + 4]
let dr: i64 = P[b + 5]
let p: i64 = acc[0]
# S1 = L(L-1)/2 mod, S2 = (L-1)L(2L-1)/6 mod, exact divisions first
let mut u: i64 = L - 1
let mut v: i64 = L
if u % 2 == 0 {
u = u / 2
} else {
v = v / 2
}
let S1: i64 = (u % MODM) * (v % MODM) % MODM
u = L - 1
v = L
let mut w: i64 = 2 * L - 1
if u % 2 == 0 {
u = u / 2
} else {
v = v / 2
}
if u % 3 == 0 {
u = u / 3
} else {
if v % 3 == 0 {
v = v / 3
} else {
w = w / 3
}
}
let S2: i64 = (u % MODM) * (v % MODM) % MODM * (w % MODM) % MODM
let pm: i64 = p % MODM
let am: i64 = a0 % MODM
let lm: i64 = L % MODM
let base: i64 = lm * pm % MODM * am % MODM
let mut contrib: i64 = 0
if dr == 0 {
contrib = (base + (pm + am) % MODM * S1 + S2) % MODM
} else {
contrib = (base + ((am - pm + MODM) % MODM) * S1 % MODM + MODM - S2) % MODM
}
acc[1] = (acc[1] + contrib) % MODM
acc[0] = p + L
tr_visit(P, P[b + 2], acc)
}
function main() -> i32 {
let P: ptr<i64> = calloc(CAP * 8, 8)
let misc: ptr<i64> = calloc(4, 8)
misc[1] = 987654321
let mut root: i64 = nn_new(P, misc, 0, BIGN, 0)
let mut fa: i64 = 1 # F(2j-1) mod N
let mut fb: i64 = 1 # F(2j) mod N
let mut j: i64 = 0
while j < K {
let mut s: i64 = fa
let mut t: i64 = fb
if s > t {
let tmp: i64 = s
s = t
t = tmp
}
let nfa: i64 = (fa + fb) % BIGN
let nfb: i64 = (fb + nfa) % BIGN
fa = nfa
fb = nfb
let ab: i64 = tr_split(P, misc, root, t + 1)
let c: i64 = misc[2]
let a: i64 = tr_split(P, misc, ab, s)
let bnode: i64 = misc[2]
if bnode != 0 {
P[bnode * 8 + 7] = 1 - P[bnode * 8 + 7]
}
root = tr_merge(P, tr_merge(P, a, bnode), c)
j = j + 1
}
let acc: ptr<i64> = calloc(2, 8)
tr_visit(P, root, acc)
printf("%lld\n", acc[1])
free(P)
free(misc)
free(acc)
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 nn_new_ptr_i64_ptr_i64_i64_i64_i64(int64_t* P, int64_t* misc, int64_t val, int64_t ln, int64_t dr);
void nn_push_ptr_i64_i64(int64_t* P, int64_t x);
void nn_upd_ptr_i64_i64(int64_t* P, int64_t x);
int64_t tr_merge_ptr_i64_i64_i64(int64_t* P, int64_t a, int64_t b);
int64_t tr_split_ptr_i64_ptr_i64_i64_i64(int64_t* P, int64_t* misc, int64_t x, int64_t k);
void tr_visit_ptr_i64_i64_ptr_i64(int64_t* P, int64_t x, int64_t* acc);
int32_t main(void);
static const int64_t MODM = 1000000000;
static const int64_t BIGN = 1000000000000000000;
static const int64_t K = 1000000;
static const int64_t CAP = 2100000;
int64_t nn_new_ptr_i64_ptr_i64_i64_i64_i64(int64_t* P, int64_t* misc, int64_t val, int64_t ln, int64_t dr) {
int64_t x = (misc[0] + 1);
misc[0] = x;
int64_t st = misc[1];
st = FLOW_CHECKED_MOD((((st * 1103515245) + 12345)), (2147483648));
misc[1] = st;
int64_t b = (x * 8);
P[(b + 0)] = st;
P[(b + 1)] = 0;
P[(b + 2)] = 0;
P[(b + 3)] = ln;
P[(b + 4)] = val;
P[(b + 5)] = dr;
P[(b + 6)] = ln;
P[(b + 7)] = 0;
return x;
}
void nn_push_ptr_i64_i64(int64_t* P, int64_t x) {
int64_t b = (x * 8);
if (P[(b + 7)] == 1) {
int64_t l = P[(b + 1)];
P[(b + 1)] = P[(b + 2)];
P[(b + 2)] = l;
if (P[(b + 5)] == 0) {
P[(b + 4)] = ((P[(b + 4)] + P[(b + 3)]) - 1);
P[(b + 5)] = 1;
} else {
P[(b + 4)] = ((P[(b + 4)] - P[(b + 3)]) + 1);
P[(b + 5)] = 0;
}
if (P[(b + 1)] != 0) {
P[((P[(b + 1)] * 8) + 7)] = (1 - P[((P[(b + 1)] * 8) + 7)]);
}
if (P[(b + 2)] != 0) {
P[((P[(b + 2)] * 8) + 7)] = (1 - P[((P[(b + 2)] * 8) + 7)]);
}
P[(b + 7)] = 0;
}
}
void nn_upd_ptr_i64_i64(int64_t* P, int64_t x) {
int64_t b = (x * 8);
P[(b + 6)] = ((P[(b + 3)] + P[((P[(b + 1)] * 8) + 6)]) + P[((P[(b + 2)] * 8) + 6)]);
}
int64_t tr_merge_ptr_i64_i64_i64(int64_t* P, int64_t a, int64_t b) {
if (a == 0) {
return b;
}
if (b == 0) {
return a;
}
if (P[((a * 8) + 0)] > P[((b * 8) + 0)]) {
nn_push_ptr_i64_i64(P, a);
P[((a * 8) + 2)] = tr_merge_ptr_i64_i64_i64(P, P[((a * 8) + 2)], b);
nn_upd_ptr_i64_i64(P, a);
return a;
}
nn_push_ptr_i64_i64(P, b);
P[((b * 8) + 1)] = tr_merge_ptr_i64_i64_i64(P, a, P[((b * 8) + 1)]);
nn_upd_ptr_i64_i64(P, b);
return b;
}
int64_t tr_split_ptr_i64_ptr_i64_i64_i64(int64_t* P, int64_t* misc, int64_t x, int64_t k) {
if (x == 0) {
misc[2] = 0;
return 0;
}
nn_push_ptr_i64_i64(P, x);
int64_t b = (x * 8);
int64_t lsz = P[((P[(b + 1)] * 8) + 6)];
if (k <= lsz) {
int64_t a = tr_split_ptr_i64_ptr_i64_i64_i64(P, misc, P[(b + 1)], k);
P[(b + 1)] = misc[2];
nn_upd_ptr_i64_i64(P, x);
misc[2] = x;
return a;
}
int64_t k2 = (k - lsz);
if (k2 >= P[(b + 3)]) {
int64_t a2 = tr_split_ptr_i64_ptr_i64_i64_i64(P, misc, P[(b + 2)], (k2 - P[(b + 3)]));
P[(b + 2)] = a2;
nn_upd_ptr_i64_i64(P, x);
return x;
}
int64_t nv = 0;
if (P[(b + 5)] == 0) {
nv = (P[(b + 4)] + k2);
} else {
nv = (P[(b + 4)] - k2);
}
int64_t nn = nn_new_ptr_i64_ptr_i64_i64_i64_i64(P, misc, nv, (P[(b + 3)] - k2), P[(b + 5)]);
P[(b + 3)] = k2;
int64_t xr = P[(b + 2)];
P[(b + 2)] = 0;
nn_upd_ptr_i64_i64(P, x);
misc[2] = tr_merge_ptr_i64_i64_i64(P, nn, xr);
return x;
}
void tr_visit_ptr_i64_i64_ptr_i64(int64_t* P, int64_t x, int64_t* acc) {
if (x == 0) {
return;
}
nn_push_ptr_i64_i64(P, x);
int64_t b = (x * 8);
tr_visit_ptr_i64_i64_ptr_i64(P, P[(b + 1)], acc);
int64_t L = P[(b + 3)];
int64_t a0 = P[(b + 4)];
int64_t dr = P[(b + 5)];
int64_t p = acc[0];
int64_t u = (L - 1);
int64_t v = L;
if (FLOW_CHECKED_MOD((u), (2)) == 0) {
u = FLOW_CHECKED_DIV((u), (2));
} else {
v = FLOW_CHECKED_DIV((v), (2));
}
int64_t S1 = FLOW_CHECKED_MOD(((FLOW_CHECKED_MOD((u), (MODM)) * FLOW_CHECKED_MOD((v), (MODM)))), (MODM));
u = (L - 1);
v = L;
int64_t w = ((2 * L) - 1);
if (FLOW_CHECKED_MOD((u), (2)) == 0) {
u = FLOW_CHECKED_DIV((u), (2));
} else {
v = FLOW_CHECKED_DIV((v), (2));
}
if (FLOW_CHECKED_MOD((u), (3)) == 0) {
u = FLOW_CHECKED_DIV((u), (3));
} else {
if (FLOW_CHECKED_MOD((v), (3)) == 0) {
v = FLOW_CHECKED_DIV((v), (3));
} else {
w = FLOW_CHECKED_DIV((w), (3));
}
}
int64_t S2 = FLOW_CHECKED_MOD(((FLOW_CHECKED_MOD(((FLOW_CHECKED_MOD((u), (MODM)) * FLOW_CHECKED_MOD((v), (MODM)))), (MODM)) * FLOW_CHECKED_MOD((w), (MODM)))), (MODM));
int64_t pm = FLOW_CHECKED_MOD((p), (MODM));
int64_t am = FLOW_CHECKED_MOD((a0), (MODM));
int64_t lm = FLOW_CHECKED_MOD((L), (MODM));
int64_t base = FLOW_CHECKED_MOD(((FLOW_CHECKED_MOD(((lm * pm)), (MODM)) * am)), (MODM));
int64_t contrib = 0;
if (dr == 0) {
contrib = FLOW_CHECKED_MOD((((base + (FLOW_CHECKED_MOD(((pm + am)), (MODM)) * S1)) + S2)), (MODM));
} else {
contrib = FLOW_CHECKED_MOD(((((base + FLOW_CHECKED_MOD(((FLOW_CHECKED_MOD((((am - pm) + MODM)), (MODM)) * S1)), (MODM))) + MODM) - S2)), (MODM));
}
acc[1] = FLOW_CHECKED_MOD(((acc[1] + contrib)), (MODM));
acc[0] = (p + L);
tr_visit_ptr_i64_i64_ptr_i64(P, P[(b + 2)], acc);
}
int32_t main(void) {
int64_t* P = (int64_t*)(calloc((CAP * 8), 8));
int64_t* misc = (int64_t*)(calloc(4, 8));
misc[1] = 987654321;
int64_t root = nn_new_ptr_i64_ptr_i64_i64_i64_i64(P, misc, 0, BIGN, 0);
int64_t fa = 1;
int64_t fb = 1;
int64_t j = 0;
while (j < K) {
int64_t s = fa;
int64_t t = fb;
if (s > t) {
int64_t tmp = s;
s = t;
t = tmp;
}
int64_t nfa = FLOW_CHECKED_MOD(((fa + fb)), (BIGN));
int64_t nfb = FLOW_CHECKED_MOD(((fb + nfa)), (BIGN));
fa = nfa;
fb = nfb;
int64_t ab = tr_split_ptr_i64_ptr_i64_i64_i64(P, misc, root, (t + 1));
int64_t c = misc[2];
int64_t a = tr_split_ptr_i64_ptr_i64_i64_i64(P, misc, ab, s);
int64_t bnode = misc[2];
if (bnode != 0) {
P[((bnode * 8) + 7)] = (1 - P[((bnode * 8) + 7)]);
}
root = tr_merge_ptr_i64_i64_i64(P, tr_merge_ptr_i64_i64_i64(P, a, bnode), c);
j = (j + 1);
}
int64_t* acc = (int64_t*)(calloc(2, 8));
tr_visit_ptr_i64_i64_ptr_i64(P, root, acc);
printf("%lld\n", acc[1]);
free(P);
free(misc);
free(acc);
return 0;
}
Generated MLIR
module {
llvm.func @printf(!llvm.ptr, ...) -> i32
llvm.mlir.global internal constant @str_0("%lld\n\00") {addr_space = 0 : i32} : !llvm.array<6 x i8>
func.func private @calloc(i64, i64) -> !llvm.ptr
func.func private @free(!llvm.ptr) -> ()
// Constant: MODM
llvm.mlir.global internal constant @MODM(1000000000 : i64) : i64
// Constant: BIGN
llvm.mlir.global internal constant @BIGN(1000000000000000000 : i64) : i64
// Constant: K
llvm.mlir.global internal constant @K(1000000 : i64) : i64
// Constant: CAP
llvm.mlir.global internal constant @CAP(2100000 : i64) : i64
func.func @nn_new(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: i64, %arg3: i64, %arg4: i64) -> i64 {
%1 = arith.constant 0 : i32
%2 = arith.extsi %1 : i32 to i64
%3 = llvm.getelementptr %arg1[%2] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%0 = llvm.load %3 : !llvm.ptr -> i64
%4 = arith.constant 1 : i32
%6 = arith.extsi %4 : i32 to i64
%5 = arith.addi %0, %6 : i64
%7 = arith.constant 0 : i32
%8 = arith.extsi %7 : i32 to i64
%9 = llvm.getelementptr %arg1[%8] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %5, %9 : i64, !llvm.ptr
%11 = arith.constant 1 : i32
%12 = arith.extsi %11 : i32 to i64
%13 = llvm.getelementptr %arg1[%12] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%10 = llvm.load %13 : !llvm.ptr -> i64
%14 = llvm.mlir.constant(1 : i64) : i64
%15 = llvm.alloca %14 x i64 : (i64) -> !llvm.ptr
llvm.store %10, %15 : i64, !llvm.ptr
%16 = llvm.load %15 : !llvm.ptr -> i64
%17 = arith.constant 1103515245 : i32
%19 = arith.extsi %17 : i32 to i64
%18 = arith.muli %16, %19 : i64
%20 = arith.constant 12345 : i32
%22 = arith.extsi %20 : i32 to i64
%21 = arith.addi %18, %22 : i64
%23 = arith.constant -2147483648 : i32
%25 = arith.extsi %23 : i32 to i64
%24 = arith.remsi %21, %25 : i64
llvm.store %24, %15 : i64, !llvm.ptr
%26 = llvm.load %15 : !llvm.ptr -> i64
%27 = arith.constant 1 : i32
%28 = arith.extsi %27 : i32 to i64
%29 = llvm.getelementptr %arg1[%28] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %26, %29 : i64, !llvm.ptr
%30 = arith.constant 8 : i32
%32 = arith.extsi %30 : i32 to i64
%31 = arith.muli %5, %32 : i64
%33 = llvm.load %15 : !llvm.ptr -> i64
%34 = arith.constant 0 : i32
%36 = arith.extsi %34 : i32 to i64
%35 = arith.addi %31, %36 : i64
%37 = llvm.getelementptr %arg0[%35] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %33, %37 : i64, !llvm.ptr
%38 = arith.constant 0 : i32
%39 = arith.constant 1 : i32
%41 = arith.extsi %39 : i32 to i64
%40 = arith.addi %31, %41 : i64
%42 = arith.extsi %38 : i32 to i64
%43 = llvm.getelementptr %arg0[%40] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %42, %43 : i64, !llvm.ptr
%44 = arith.constant 0 : i32
%45 = arith.constant 2 : i32
%47 = arith.extsi %45 : i32 to i64
%46 = arith.addi %31, %47 : i64
%48 = arith.extsi %44 : i32 to i64
%49 = llvm.getelementptr %arg0[%46] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %48, %49 : i64, !llvm.ptr
%50 = arith.constant 3 : i32
%52 = arith.extsi %50 : i32 to i64
%51 = arith.addi %31, %52 : i64
%53 = llvm.getelementptr %arg0[%51] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %arg3, %53 : i64, !llvm.ptr
%54 = arith.constant 4 : i32
%56 = arith.extsi %54 : i32 to i64
%55 = arith.addi %31, %56 : i64
%57 = llvm.getelementptr %arg0[%55] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %arg2, %57 : i64, !llvm.ptr
%58 = arith.constant 5 : i32
%60 = arith.extsi %58 : i32 to i64
%59 = arith.addi %31, %60 : i64
%61 = llvm.getelementptr %arg0[%59] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %arg4, %61 : i64, !llvm.ptr
%62 = arith.constant 6 : i32
%64 = arith.extsi %62 : i32 to i64
%63 = arith.addi %31, %64 : i64
%65 = llvm.getelementptr %arg0[%63] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %arg3, %65 : i64, !llvm.ptr
%66 = arith.constant 0 : i32
%67 = arith.constant 7 : i32
%69 = arith.extsi %67 : i32 to i64
%68 = arith.addi %31, %69 : i64
%70 = arith.extsi %66 : i32 to i64
%71 = llvm.getelementptr %arg0[%68] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %70, %71 : i64, !llvm.ptr
func.return %5 : i64
}
func.func @nn_push(%arg0: !llvm.ptr, %arg1: i64) -> () {
%72 = arith.constant 8 : i32
%74 = arith.extsi %72 : i32 to i64
%73 = arith.muli %arg1, %74 : i64
%76 = arith.constant 7 : i32
%78 = arith.extsi %76 : i32 to i64
%77 = arith.addi %73, %78 : i64
%79 = llvm.getelementptr %arg0[%77] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%75 = llvm.load %79 : !llvm.ptr -> i64
%80 = arith.constant 1 : i32
%82 = arith.extsi %80 : i32 to i64
%81 = arith.cmpi eq, %75, %82 : i64
cf.cond_br %81, ^bb0, ^bb1
^bb0:
%84 = arith.constant 1 : i32
%86 = arith.extsi %84 : i32 to i64
%85 = arith.addi %73, %86 : i64
%87 = llvm.getelementptr %arg0[%85] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%83 = llvm.load %87 : !llvm.ptr -> i64
%89 = arith.constant 2 : i32
%91 = arith.extsi %89 : i32 to i64
%90 = arith.addi %73, %91 : i64
%92 = llvm.getelementptr %arg0[%90] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%88 = llvm.load %92 : !llvm.ptr -> i64
%93 = arith.constant 1 : i32
%95 = arith.extsi %93 : i32 to i64
%94 = arith.addi %73, %95 : i64
%96 = llvm.getelementptr %arg0[%94] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %88, %96 : i64, !llvm.ptr
%97 = arith.constant 2 : i32
%99 = arith.extsi %97 : i32 to i64
%98 = arith.addi %73, %99 : i64
%100 = llvm.getelementptr %arg0[%98] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %83, %100 : i64, !llvm.ptr
%102 = arith.constant 5 : i32
%104 = arith.extsi %102 : i32 to i64
%103 = arith.addi %73, %104 : i64
%105 = llvm.getelementptr %arg0[%103] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%101 = llvm.load %105 : !llvm.ptr -> i64
%106 = arith.constant 0 : i32
%108 = arith.extsi %106 : i32 to i64
%107 = arith.cmpi eq, %101, %108 : i64
cf.cond_br %107, ^bb3, ^bb4
^bb3:
%110 = arith.constant 4 : i32
%112 = arith.extsi %110 : i32 to i64
%111 = arith.addi %73, %112 : i64
%113 = llvm.getelementptr %arg0[%111] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%109 = llvm.load %113 : !llvm.ptr -> i64
%115 = arith.constant 3 : i32
%117 = arith.extsi %115 : i32 to i64
%116 = arith.addi %73, %117 : i64
%118 = llvm.getelementptr %arg0[%116] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%114 = llvm.load %118 : !llvm.ptr -> i64
%119 = arith.addi %109, %114 : i64
%120 = arith.constant 1 : i32
%122 = arith.extsi %120 : i32 to i64
%121 = arith.subi %119, %122 : i64
%123 = arith.constant 4 : i32
%125 = arith.extsi %123 : i32 to i64
%124 = arith.addi %73, %125 : i64
%126 = llvm.getelementptr %arg0[%124] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %121, %126 : i64, !llvm.ptr
%127 = arith.constant 1 : i32
%128 = arith.constant 5 : i32
%130 = arith.extsi %128 : i32 to i64
%129 = arith.addi %73, %130 : i64
%131 = arith.extsi %127 : i32 to i64
%132 = llvm.getelementptr %arg0[%129] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %131, %132 : i64, !llvm.ptr
cf.br ^bb5
^bb4:
%134 = arith.constant 4 : i32
%136 = arith.extsi %134 : i32 to i64
%135 = arith.addi %73, %136 : i64
%137 = llvm.getelementptr %arg0[%135] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%133 = llvm.load %137 : !llvm.ptr -> i64
%139 = arith.constant 3 : i32
%141 = arith.extsi %139 : i32 to i64
%140 = arith.addi %73, %141 : i64
%142 = llvm.getelementptr %arg0[%140] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%138 = llvm.load %142 : !llvm.ptr -> i64
%143 = arith.subi %133, %138 : i64
%144 = arith.constant 1 : i32
%146 = arith.extsi %144 : i32 to i64
%145 = arith.addi %143, %146 : i64
%147 = arith.constant 4 : i32
%149 = arith.extsi %147 : i32 to i64
%148 = arith.addi %73, %149 : i64
%150 = llvm.getelementptr %arg0[%148] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %145, %150 : i64, !llvm.ptr
%151 = arith.constant 0 : i32
%152 = arith.constant 5 : i32
%154 = arith.extsi %152 : i32 to i64
%153 = arith.addi %73, %154 : i64
%155 = arith.extsi %151 : i32 to i64
%156 = llvm.getelementptr %arg0[%153] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %155, %156 : i64, !llvm.ptr
cf.br ^bb5
^bb5:
%158 = arith.constant 1 : i32
%160 = arith.extsi %158 : i32 to i64
%159 = arith.addi %73, %160 : i64
%161 = llvm.getelementptr %arg0[%159] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%157 = llvm.load %161 : !llvm.ptr -> i64
%162 = arith.constant 0 : i32
%164 = arith.extsi %162 : i32 to i64
%163 = arith.cmpi ne, %157, %164 : i64
cf.cond_br %163, ^bb6, ^bb7
^bb6:
%165 = arith.constant 1 : i32
%168 = arith.constant 1 : i32
%170 = arith.extsi %168 : i32 to i64
%169 = arith.addi %73, %170 : i64
%171 = llvm.getelementptr %arg0[%169] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%167 = llvm.load %171 : !llvm.ptr -> i64
%172 = arith.constant 8 : i32
%174 = arith.extsi %172 : i32 to i64
%173 = arith.muli %167, %174 : i64
%175 = arith.constant 7 : i32
%177 = arith.extsi %175 : i32 to i64
%176 = arith.addi %173, %177 : i64
%178 = llvm.getelementptr %arg0[%176] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%166 = llvm.load %178 : !llvm.ptr -> i64
%180 = arith.extsi %165 : i32 to i64
%179 = arith.subi %180, %166 : i64
%182 = arith.constant 1 : i32
%184 = arith.extsi %182 : i32 to i64
%183 = arith.addi %73, %184 : i64
%185 = llvm.getelementptr %arg0[%183] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%181 = llvm.load %185 : !llvm.ptr -> i64
%186 = arith.constant 8 : i32
%188 = arith.extsi %186 : i32 to i64
%187 = arith.muli %181, %188 : i64
%189 = arith.constant 7 : i32
%191 = arith.extsi %189 : i32 to i64
%190 = arith.addi %187, %191 : i64
%192 = llvm.getelementptr %arg0[%190] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %179, %192 : i64, !llvm.ptr
cf.br ^bb8
^bb7:
cf.br ^bb8
^bb8:
%194 = arith.constant 2 : i32
%196 = arith.extsi %194 : i32 to i64
%195 = arith.addi %73, %196 : i64
%197 = llvm.getelementptr %arg0[%195] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%193 = llvm.load %197 : !llvm.ptr -> i64
%198 = arith.constant 0 : i32
%200 = arith.extsi %198 : i32 to i64
%199 = arith.cmpi ne, %193, %200 : i64
cf.cond_br %199, ^bb9, ^bb10
^bb9:
%201 = arith.constant 1 : i32
%204 = arith.constant 2 : i32
%206 = arith.extsi %204 : i32 to i64
%205 = arith.addi %73, %206 : i64
%207 = llvm.getelementptr %arg0[%205] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%203 = llvm.load %207 : !llvm.ptr -> i64
%208 = arith.constant 8 : i32
%210 = arith.extsi %208 : i32 to i64
%209 = arith.muli %203, %210 : i64
%211 = arith.constant 7 : i32
%213 = arith.extsi %211 : i32 to i64
%212 = arith.addi %209, %213 : i64
%214 = llvm.getelementptr %arg0[%212] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%202 = llvm.load %214 : !llvm.ptr -> i64
%216 = arith.extsi %201 : i32 to i64
%215 = arith.subi %216, %202 : i64
%218 = arith.constant 2 : i32
%220 = arith.extsi %218 : i32 to i64
%219 = arith.addi %73, %220 : i64
%221 = llvm.getelementptr %arg0[%219] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%217 = llvm.load %221 : !llvm.ptr -> i64
%222 = arith.constant 8 : i32
%224 = arith.extsi %222 : i32 to i64
%223 = arith.muli %217, %224 : i64
%225 = arith.constant 7 : i32
%227 = arith.extsi %225 : i32 to i64
%226 = arith.addi %223, %227 : i64
%228 = llvm.getelementptr %arg0[%226] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %215, %228 : i64, !llvm.ptr
cf.br ^bb11
^bb10:
cf.br ^bb11
^bb11:
%229 = arith.constant 0 : i32
%230 = arith.constant 7 : i32
%232 = arith.extsi %230 : i32 to i64
%231 = arith.addi %73, %232 : i64
%233 = arith.extsi %229 : i32 to i64
%234 = llvm.getelementptr %arg0[%231] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %233, %234 : i64, !llvm.ptr
cf.br ^bb2
^bb1:
cf.br ^bb2
^bb2:
func.return
}
func.func @nn_upd(%arg0: !llvm.ptr, %arg1: i64) -> () {
%235 = arith.constant 8 : i32
%237 = arith.extsi %235 : i32 to i64
%236 = arith.muli %arg1, %237 : i64
%239 = arith.constant 3 : i32
%241 = arith.extsi %239 : i32 to i64
%240 = arith.addi %236, %241 : i64
%242 = llvm.getelementptr %arg0[%240] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%238 = llvm.load %242 : !llvm.ptr -> i64
%245 = arith.constant 1 : i32
%247 = arith.extsi %245 : i32 to i64
%246 = arith.addi %236, %247 : i64
%248 = llvm.getelementptr %arg0[%246] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%244 = llvm.load %248 : !llvm.ptr -> i64
%249 = arith.constant 8 : i32
%251 = arith.extsi %249 : i32 to i64
%250 = arith.muli %244, %251 : i64
%252 = arith.constant 6 : i32
%254 = arith.extsi %252 : i32 to i64
%253 = arith.addi %250, %254 : i64
%255 = llvm.getelementptr %arg0[%253] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%243 = llvm.load %255 : !llvm.ptr -> i64
%256 = arith.addi %238, %243 : i64
%259 = arith.constant 2 : i32
%261 = arith.extsi %259 : i32 to i64
%260 = arith.addi %236, %261 : i64
%262 = llvm.getelementptr %arg0[%260] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%258 = llvm.load %262 : !llvm.ptr -> i64
%263 = arith.constant 8 : i32
%265 = arith.extsi %263 : i32 to i64
%264 = arith.muli %258, %265 : i64
%266 = arith.constant 6 : i32
%268 = arith.extsi %266 : i32 to i64
%267 = arith.addi %264, %268 : i64
%269 = llvm.getelementptr %arg0[%267] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%257 = llvm.load %269 : !llvm.ptr -> i64
%270 = arith.addi %256, %257 : i64
%271 = arith.constant 6 : i32
%273 = arith.extsi %271 : i32 to i64
%272 = arith.addi %236, %273 : i64
%274 = llvm.getelementptr %arg0[%272] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %270, %274 : i64, !llvm.ptr
func.return
}
func.func @tr_merge(%arg0: !llvm.ptr, %arg1: i64, %arg2: i64) -> i64 {
%275 = arith.constant 0 : i32
%277 = arith.extsi %275 : i32 to i64
%276 = arith.cmpi eq, %arg1, %277 : i64
cf.cond_br %276, ^bb12, ^bb13
^bb12:
func.return %arg2 : i64
^bb13:
cf.br ^bb14
^bb14:
%278 = arith.constant 0 : i32
%280 = arith.extsi %278 : i32 to i64
%279 = arith.cmpi eq, %arg2, %280 : i64
cf.cond_br %279, ^bb15, ^bb16
^bb15:
func.return %arg1 : i64
^bb16:
cf.br ^bb17
^bb17:
%282 = arith.constant 8 : i32
%284 = arith.extsi %282 : i32 to i64
%283 = arith.muli %arg1, %284 : i64
%285 = arith.constant 0 : i32
%287 = arith.extsi %285 : i32 to i64
%286 = arith.addi %283, %287 : i64
%288 = llvm.getelementptr %arg0[%286] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%281 = llvm.load %288 : !llvm.ptr -> i64
%290 = arith.constant 8 : i32
%292 = arith.extsi %290 : i32 to i64
%291 = arith.muli %arg2, %292 : i64
%293 = arith.constant 0 : i32
%295 = arith.extsi %293 : i32 to i64
%294 = arith.addi %291, %295 : i64
%296 = llvm.getelementptr %arg0[%294] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%289 = llvm.load %296 : !llvm.ptr -> i64
%297 = arith.cmpi sgt, %281, %289 : i64
cf.cond_br %297, ^bb18, ^bb19
^bb18:
func.call @nn_push(%arg0, %arg1) : (!llvm.ptr, i64) -> ()
%301 = arith.constant 8 : i32
%303 = arith.extsi %301 : i32 to i64
%302 = arith.muli %arg1, %303 : i64
%304 = arith.constant 2 : i32
%306 = arith.extsi %304 : i32 to i64
%305 = arith.addi %302, %306 : i64
%307 = llvm.getelementptr %arg0[%305] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%300 = llvm.load %307 : !llvm.ptr -> i64
%299 = func.call @tr_merge(%arg0, %300, %arg2) : (!llvm.ptr, i64, i64) -> i64
%308 = arith.constant 8 : i32
%310 = arith.extsi %308 : i32 to i64
%309 = arith.muli %arg1, %310 : i64
%311 = arith.constant 2 : i32
%313 = arith.extsi %311 : i32 to i64
%312 = arith.addi %309, %313 : i64
%314 = llvm.getelementptr %arg0[%312] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %299, %314 : i64, !llvm.ptr
func.call @nn_upd(%arg0, %arg1) : (!llvm.ptr, i64) -> ()
func.return %arg1 : i64
^bb19:
cf.br ^bb20
^bb20:
func.call @nn_push(%arg0, %arg2) : (!llvm.ptr, i64) -> ()
%319 = arith.constant 8 : i32
%321 = arith.extsi %319 : i32 to i64
%320 = arith.muli %arg2, %321 : i64
%322 = arith.constant 1 : i32
%324 = arith.extsi %322 : i32 to i64
%323 = arith.addi %320, %324 : i64
%325 = llvm.getelementptr %arg0[%323] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%318 = llvm.load %325 : !llvm.ptr -> i64
%317 = func.call @tr_merge(%arg0, %arg1, %318) : (!llvm.ptr, i64, i64) -> i64
%326 = arith.constant 8 : i32
%328 = arith.extsi %326 : i32 to i64
%327 = arith.muli %arg2, %328 : i64
%329 = arith.constant 1 : i32
%331 = arith.extsi %329 : i32 to i64
%330 = arith.addi %327, %331 : i64
%332 = llvm.getelementptr %arg0[%330] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %317, %332 : i64, !llvm.ptr
func.call @nn_upd(%arg0, %arg2) : (!llvm.ptr, i64) -> ()
func.return %arg2 : i64
}
func.func @tr_split(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: i64, %arg3: i64) -> i64 {
%334 = arith.constant 0 : i32
%336 = arith.extsi %334 : i32 to i64
%335 = arith.cmpi eq, %arg2, %336 : i64
cf.cond_br %335, ^bb21, ^bb22
^bb21:
%337 = arith.constant 0 : i32
%338 = arith.constant 2 : i32
%339 = arith.extsi %337 : i32 to i64
%340 = arith.extsi %338 : i32 to i64
%341 = llvm.getelementptr %arg1[%340] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %339, %341 : i64, !llvm.ptr
%342 = arith.constant 0 : i32
%343 = arith.extsi %342 : i32 to i64
func.return %343 : i64
^bb22:
cf.br ^bb23
^bb23:
func.call @nn_push(%arg0, %arg2) : (!llvm.ptr, i64) -> ()
%345 = arith.constant 8 : i32
%347 = arith.extsi %345 : i32 to i64
%346 = arith.muli %arg2, %347 : i64
%350 = arith.constant 1 : i32
%352 = arith.extsi %350 : i32 to i64
%351 = arith.addi %346, %352 : i64
%353 = llvm.getelementptr %arg0[%351] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%349 = llvm.load %353 : !llvm.ptr -> i64
%354 = arith.constant 8 : i32
%356 = arith.extsi %354 : i32 to i64
%355 = arith.muli %349, %356 : i64
%357 = arith.constant 6 : i32
%359 = arith.extsi %357 : i32 to i64
%358 = arith.addi %355, %359 : i64
%360 = llvm.getelementptr %arg0[%358] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%348 = llvm.load %360 : !llvm.ptr -> i64
%361 = arith.cmpi sle, %arg3, %348 : i64
cf.cond_br %361, ^bb24, ^bb25
^bb24:
%364 = arith.constant 1 : i32
%366 = arith.extsi %364 : i32 to i64
%365 = arith.addi %346, %366 : i64
%367 = llvm.getelementptr %arg0[%365] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%363 = llvm.load %367 : !llvm.ptr -> i64
%362 = func.call @tr_split(%arg0, %arg1, %363, %arg3) : (!llvm.ptr, !llvm.ptr, i64, i64) -> i64
%369 = arith.constant 2 : i32
%370 = arith.extsi %369 : i32 to i64
%371 = llvm.getelementptr %arg1[%370] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%368 = llvm.load %371 : !llvm.ptr -> i64
%372 = arith.constant 1 : i32
%374 = arith.extsi %372 : i32 to i64
%373 = arith.addi %346, %374 : i64
%375 = llvm.getelementptr %arg0[%373] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %368, %375 : i64, !llvm.ptr
func.call @nn_upd(%arg0, %arg2) : (!llvm.ptr, i64) -> ()
%377 = arith.constant 2 : i32
%378 = arith.extsi %377 : i32 to i64
%379 = llvm.getelementptr %arg1[%378] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %arg2, %379 : i64, !llvm.ptr
func.return %362 : i64
^bb25:
cf.br ^bb26
^bb26:
%380 = arith.subi %arg3, %348 : i64
%382 = arith.constant 3 : i32
%384 = arith.extsi %382 : i32 to i64
%383 = arith.addi %346, %384 : i64
%385 = llvm.getelementptr %arg0[%383] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%381 = llvm.load %385 : !llvm.ptr -> i64
%386 = arith.cmpi sge, %380, %381 : i64
cf.cond_br %386, ^bb27, ^bb28
^bb27:
%389 = arith.constant 2 : i32
%391 = arith.extsi %389 : i32 to i64
%390 = arith.addi %346, %391 : i64
%392 = llvm.getelementptr %arg0[%390] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%388 = llvm.load %392 : !llvm.ptr -> i64
%394 = arith.constant 3 : i32
%396 = arith.extsi %394 : i32 to i64
%395 = arith.addi %346, %396 : i64
%397 = llvm.getelementptr %arg0[%395] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%393 = llvm.load %397 : !llvm.ptr -> i64
%398 = arith.subi %380, %393 : i64
%387 = func.call @tr_split(%arg0, %arg1, %388, %398) : (!llvm.ptr, !llvm.ptr, i64, i64) -> i64
%399 = arith.constant 2 : i32
%401 = arith.extsi %399 : i32 to i64
%400 = arith.addi %346, %401 : i64
%402 = llvm.getelementptr %arg0[%400] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %387, %402 : i64, !llvm.ptr
func.call @nn_upd(%arg0, %arg2) : (!llvm.ptr, i64) -> ()
func.return %arg2 : i64
^bb28:
cf.br ^bb29
^bb29:
%404 = arith.constant 0 : 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
%409 = arith.constant 5 : i32
%411 = arith.extsi %409 : i32 to i64
%410 = arith.addi %346, %411 : i64
%412 = llvm.getelementptr %arg0[%410] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%408 = llvm.load %412 : !llvm.ptr -> i64
%413 = arith.constant 0 : i32
%415 = arith.extsi %413 : i32 to i64
%414 = arith.cmpi eq, %408, %415 : i64
cf.cond_br %414, ^bb30, ^bb31
^bb30:
%417 = arith.constant 4 : i32
%419 = arith.extsi %417 : i32 to i64
%418 = arith.addi %346, %419 : i64
%420 = llvm.getelementptr %arg0[%418] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%416 = llvm.load %420 : !llvm.ptr -> i64
%421 = arith.addi %416, %380 : i64
llvm.store %421, %407 : i64, !llvm.ptr
cf.br ^bb32
^bb31:
%423 = arith.constant 4 : i32
%425 = arith.extsi %423 : i32 to i64
%424 = arith.addi %346, %425 : i64
%426 = llvm.getelementptr %arg0[%424] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%422 = llvm.load %426 : !llvm.ptr -> i64
%427 = arith.subi %422, %380 : i64
llvm.store %427, %407 : i64, !llvm.ptr
cf.br ^bb32
^bb32:
%429 = llvm.load %407 : !llvm.ptr -> i64
%431 = arith.constant 3 : i32
%433 = arith.extsi %431 : i32 to i64
%432 = arith.addi %346, %433 : i64
%434 = llvm.getelementptr %arg0[%432] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%430 = llvm.load %434 : !llvm.ptr -> i64
%435 = arith.subi %430, %380 : i64
%437 = arith.constant 5 : i32
%439 = arith.extsi %437 : i32 to i64
%438 = arith.addi %346, %439 : i64
%440 = llvm.getelementptr %arg0[%438] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%436 = llvm.load %440 : !llvm.ptr -> i64
%428 = func.call @nn_new(%arg0, %arg1, %429, %435, %436) : (!llvm.ptr, !llvm.ptr, i64, i64, i64) -> i64
%441 = arith.constant 3 : i32
%443 = arith.extsi %441 : i32 to i64
%442 = arith.addi %346, %443 : i64
%444 = llvm.getelementptr %arg0[%442] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %380, %444 : i64, !llvm.ptr
%446 = arith.constant 2 : i32
%448 = arith.extsi %446 : i32 to i64
%447 = arith.addi %346, %448 : i64
%449 = llvm.getelementptr %arg0[%447] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%445 = llvm.load %449 : !llvm.ptr -> i64
%450 = arith.constant 0 : i32
%451 = arith.constant 2 : i32
%453 = arith.extsi %451 : i32 to i64
%452 = arith.addi %346, %453 : i64
%454 = arith.extsi %450 : i32 to i64
%455 = llvm.getelementptr %arg0[%452] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %454, %455 : i64, !llvm.ptr
func.call @nn_upd(%arg0, %arg2) : (!llvm.ptr, i64) -> ()
%457 = func.call @tr_merge(%arg0, %428, %445) : (!llvm.ptr, i64, i64) -> i64
%458 = arith.constant 2 : i32
%459 = arith.extsi %458 : i32 to i64
%460 = llvm.getelementptr %arg1[%459] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %457, %460 : i64, !llvm.ptr
func.return %arg2 : i64
}
func.func @tr_visit(%arg0: !llvm.ptr, %arg1: i64, %arg2: !llvm.ptr) -> () {
%461 = arith.constant 0 : i32
%463 = arith.extsi %461 : i32 to i64
%462 = arith.cmpi eq, %arg1, %463 : i64
cf.cond_br %462, ^bb33, ^bb34
^bb33:
func.return
^bb34:
cf.br ^bb35
^bb35:
func.call @nn_push(%arg0, %arg1) : (!llvm.ptr, i64) -> ()
%465 = arith.constant 8 : i32
%467 = arith.extsi %465 : i32 to i64
%466 = arith.muli %arg1, %467 : i64
%470 = arith.constant 1 : i32
%472 = arith.extsi %470 : i32 to i64
%471 = arith.addi %466, %472 : i64
%473 = llvm.getelementptr %arg0[%471] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%469 = llvm.load %473 : !llvm.ptr -> i64
func.call @tr_visit(%arg0, %469, %arg2) : (!llvm.ptr, i64, !llvm.ptr) -> ()
%475 = arith.constant 3 : i32
%477 = arith.extsi %475 : i32 to i64
%476 = arith.addi %466, %477 : i64
%478 = llvm.getelementptr %arg0[%476] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%474 = llvm.load %478 : !llvm.ptr -> i64
%480 = arith.constant 4 : i32
%482 = arith.extsi %480 : i32 to i64
%481 = arith.addi %466, %482 : i64
%483 = llvm.getelementptr %arg0[%481] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%479 = llvm.load %483 : !llvm.ptr -> i64
%485 = arith.constant 5 : i32
%487 = arith.extsi %485 : i32 to i64
%486 = arith.addi %466, %487 : i64
%488 = llvm.getelementptr %arg0[%486] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%484 = llvm.load %488 : !llvm.ptr -> i64
%490 = arith.constant 0 : i32
%491 = arith.extsi %490 : i32 to i64
%492 = llvm.getelementptr %arg2[%491] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%489 = llvm.load %492 : !llvm.ptr -> i64
%493 = arith.constant 1 : i32
%495 = arith.extsi %493 : i32 to i64
%494 = arith.subi %474, %495 : i64
%496 = llvm.mlir.constant(1 : i64) : i64
%497 = llvm.alloca %496 x i64 : (i64) -> !llvm.ptr
llvm.store %494, %497 : i64, !llvm.ptr
%498 = llvm.mlir.constant(1 : i64) : i64
%499 = llvm.alloca %498 x i64 : (i64) -> !llvm.ptr
llvm.store %474, %499 : i64, !llvm.ptr
%500 = llvm.load %497 : !llvm.ptr -> i64
%501 = arith.constant 2 : i32
%503 = arith.extsi %501 : i32 to i64
%502 = arith.remsi %500, %503 : i64
%504 = arith.constant 0 : i32
%506 = arith.extsi %504 : i32 to i64
%505 = arith.cmpi eq, %502, %506 : i64
cf.cond_br %505, ^bb36, ^bb37
^bb36:
%507 = llvm.load %497 : !llvm.ptr -> i64
%508 = arith.constant 2 : i32
%510 = arith.extsi %508 : i32 to i64
%509 = arith.divsi %507, %510 : i64
llvm.store %509, %497 : i64, !llvm.ptr
cf.br ^bb38
^bb37:
%511 = llvm.load %499 : !llvm.ptr -> i64
%512 = arith.constant 2 : i32
%514 = arith.extsi %512 : i32 to i64
%513 = arith.divsi %511, %514 : i64
llvm.store %513, %499 : i64, !llvm.ptr
cf.br ^bb38
^bb38:
%515 = llvm.load %497 : !llvm.ptr -> i64
%516 = llvm.mlir.addressof @MODM : !llvm.ptr
%517 = llvm.load %516 : !llvm.ptr -> i64
%518 = arith.remsi %515, %517 : i64
%519 = llvm.load %499 : !llvm.ptr -> i64
%520 = llvm.mlir.addressof @MODM : !llvm.ptr
%521 = llvm.load %520 : !llvm.ptr -> i64
%522 = arith.remsi %519, %521 : i64
%523 = arith.muli %518, %522 : i64
%524 = llvm.mlir.addressof @MODM : !llvm.ptr
%525 = llvm.load %524 : !llvm.ptr -> i64
%526 = arith.remsi %523, %525 : i64
%527 = arith.constant 1 : i32
%529 = arith.extsi %527 : i32 to i64
%528 = arith.subi %474, %529 : i64
llvm.store %528, %497 : i64, !llvm.ptr
llvm.store %474, %499 : i64, !llvm.ptr
%530 = arith.constant 2 : i32
%532 = arith.extsi %530 : i32 to i64
%531 = arith.muli %532, %474 : i64
%533 = arith.constant 1 : i32
%535 = arith.extsi %533 : i32 to i64
%534 = arith.subi %531, %535 : i64
%536 = llvm.mlir.constant(1 : i64) : i64
%537 = llvm.alloca %536 x i64 : (i64) -> !llvm.ptr
llvm.store %534, %537 : i64, !llvm.ptr
%538 = llvm.load %497 : !llvm.ptr -> i64
%539 = arith.constant 2 : i32
%541 = arith.extsi %539 : i32 to i64
%540 = arith.remsi %538, %541 : i64
%542 = arith.constant 0 : i32
%544 = arith.extsi %542 : i32 to i64
%543 = arith.cmpi eq, %540, %544 : i64
cf.cond_br %543, ^bb39, ^bb40
^bb39:
%545 = llvm.load %497 : !llvm.ptr -> i64
%546 = arith.constant 2 : i32
%548 = arith.extsi %546 : i32 to i64
%547 = arith.divsi %545, %548 : i64
llvm.store %547, %497 : i64, !llvm.ptr
cf.br ^bb41
^bb40:
%549 = llvm.load %499 : !llvm.ptr -> i64
%550 = arith.constant 2 : i32
%552 = arith.extsi %550 : i32 to i64
%551 = arith.divsi %549, %552 : i64
llvm.store %551, %499 : i64, !llvm.ptr
cf.br ^bb41
^bb41:
%553 = llvm.load %497 : !llvm.ptr -> i64
%554 = arith.constant 3 : i32
%556 = arith.extsi %554 : i32 to i64
%555 = arith.remsi %553, %556 : i64
%557 = arith.constant 0 : i32
%559 = arith.extsi %557 : i32 to i64
%558 = arith.cmpi eq, %555, %559 : i64
cf.cond_br %558, ^bb42, ^bb43
^bb42:
%560 = llvm.load %497 : !llvm.ptr -> i64
%561 = arith.constant 3 : i32
%563 = arith.extsi %561 : i32 to i64
%562 = arith.divsi %560, %563 : i64
llvm.store %562, %497 : i64, !llvm.ptr
cf.br ^bb44
^bb43:
%564 = llvm.load %499 : !llvm.ptr -> i64
%565 = arith.constant 3 : i32
%567 = arith.extsi %565 : i32 to i64
%566 = arith.remsi %564, %567 : i64
%568 = arith.constant 0 : i32
%570 = arith.extsi %568 : i32 to i64
%569 = arith.cmpi eq, %566, %570 : i64
cf.cond_br %569, ^bb45, ^bb46
^bb45:
%571 = llvm.load %499 : !llvm.ptr -> i64
%572 = arith.constant 3 : i32
%574 = arith.extsi %572 : i32 to i64
%573 = arith.divsi %571, %574 : i64
llvm.store %573, %499 : i64, !llvm.ptr
cf.br ^bb47
^bb46:
%575 = llvm.load %537 : !llvm.ptr -> i64
%576 = arith.constant 3 : i32
%578 = arith.extsi %576 : i32 to i64
%577 = arith.divsi %575, %578 : i64
llvm.store %577, %537 : i64, !llvm.ptr
cf.br ^bb47
^bb47:
cf.br ^bb44
^bb44:
%579 = llvm.load %497 : !llvm.ptr -> i64
%580 = llvm.mlir.addressof @MODM : !llvm.ptr
%581 = llvm.load %580 : !llvm.ptr -> i64
%582 = arith.remsi %579, %581 : i64
%583 = llvm.load %499 : !llvm.ptr -> i64
%584 = llvm.mlir.addressof @MODM : !llvm.ptr
%585 = llvm.load %584 : !llvm.ptr -> i64
%586 = arith.remsi %583, %585 : i64
%587 = arith.muli %582, %586 : i64
%588 = llvm.mlir.addressof @MODM : !llvm.ptr
%589 = llvm.load %588 : !llvm.ptr -> i64
%590 = arith.remsi %587, %589 : i64
%591 = llvm.load %537 : !llvm.ptr -> i64
%592 = llvm.mlir.addressof @MODM : !llvm.ptr
%593 = llvm.load %592 : !llvm.ptr -> i64
%594 = arith.remsi %591, %593 : i64
%595 = arith.muli %590, %594 : i64
%596 = llvm.mlir.addressof @MODM : !llvm.ptr
%597 = llvm.load %596 : !llvm.ptr -> i64
%598 = arith.remsi %595, %597 : i64
%599 = llvm.mlir.addressof @MODM : !llvm.ptr
%600 = llvm.load %599 : !llvm.ptr -> i64
%601 = arith.remsi %489, %600 : i64
%602 = llvm.mlir.addressof @MODM : !llvm.ptr
%603 = llvm.load %602 : !llvm.ptr -> i64
%604 = arith.remsi %479, %603 : i64
%605 = llvm.mlir.addressof @MODM : !llvm.ptr
%606 = llvm.load %605 : !llvm.ptr -> i64
%607 = arith.remsi %474, %606 : i64
%608 = arith.muli %607, %601 : i64
%609 = llvm.mlir.addressof @MODM : !llvm.ptr
%610 = llvm.load %609 : !llvm.ptr -> i64
%611 = arith.remsi %608, %610 : i64
%612 = arith.muli %611, %604 : i64
%613 = llvm.mlir.addressof @MODM : !llvm.ptr
%614 = llvm.load %613 : !llvm.ptr -> i64
%615 = arith.remsi %612, %614 : i64
%616 = arith.constant 0 : i32
%617 = arith.extsi %616 : i32 to i64
%618 = llvm.mlir.constant(1 : i64) : i64
%619 = llvm.alloca %618 x i64 : (i64) -> !llvm.ptr
llvm.store %617, %619 : i64, !llvm.ptr
%620 = arith.constant 0 : i32
%622 = arith.extsi %620 : i32 to i64
%621 = arith.cmpi eq, %484, %622 : i64
cf.cond_br %621, ^bb48, ^bb49
^bb48:
%623 = arith.addi %601, %604 : i64
%624 = llvm.mlir.addressof @MODM : !llvm.ptr
%625 = llvm.load %624 : !llvm.ptr -> i64
%626 = arith.remsi %623, %625 : i64
%627 = arith.muli %626, %526 : i64
%628 = arith.addi %615, %627 : i64
%629 = arith.addi %628, %598 : i64
%630 = llvm.mlir.addressof @MODM : !llvm.ptr
%631 = llvm.load %630 : !llvm.ptr -> i64
%632 = arith.remsi %629, %631 : i64
llvm.store %632, %619 : i64, !llvm.ptr
cf.br ^bb50
^bb49:
%633 = arith.subi %604, %601 : i64
%634 = llvm.mlir.addressof @MODM : !llvm.ptr
%635 = llvm.load %634 : !llvm.ptr -> i64
%636 = arith.addi %633, %635 : i64
%637 = llvm.mlir.addressof @MODM : !llvm.ptr
%638 = llvm.load %637 : !llvm.ptr -> i64
%639 = arith.remsi %636, %638 : i64
%640 = arith.muli %639, %526 : i64
%641 = llvm.mlir.addressof @MODM : !llvm.ptr
%642 = llvm.load %641 : !llvm.ptr -> i64
%643 = arith.remsi %640, %642 : i64
%644 = arith.addi %615, %643 : i64
%645 = llvm.mlir.addressof @MODM : !llvm.ptr
%646 = llvm.load %645 : !llvm.ptr -> i64
%647 = arith.addi %644, %646 : i64
%648 = arith.subi %647, %598 : i64
%649 = llvm.mlir.addressof @MODM : !llvm.ptr
%650 = llvm.load %649 : !llvm.ptr -> i64
%651 = arith.remsi %648, %650 : i64
llvm.store %651, %619 : i64, !llvm.ptr
cf.br ^bb50
^bb50:
%653 = arith.constant 1 : i32
%654 = arith.extsi %653 : i32 to i64
%655 = llvm.getelementptr %arg2[%654] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%652 = llvm.load %655 : !llvm.ptr -> i64
%656 = llvm.load %619 : !llvm.ptr -> i64
%657 = arith.addi %652, %656 : i64
%658 = llvm.mlir.addressof @MODM : !llvm.ptr
%659 = llvm.load %658 : !llvm.ptr -> i64
%660 = arith.remsi %657, %659 : i64
%661 = arith.constant 1 : i32
%662 = arith.extsi %661 : i32 to i64
%663 = llvm.getelementptr %arg2[%662] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %660, %663 : i64, !llvm.ptr
%664 = arith.addi %489, %474 : i64
%665 = arith.constant 0 : i32
%666 = arith.extsi %665 : i32 to i64
%667 = llvm.getelementptr %arg2[%666] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %664, %667 : i64, !llvm.ptr
%670 = arith.constant 2 : i32
%672 = arith.extsi %670 : i32 to i64
%671 = arith.addi %466, %672 : i64
%673 = llvm.getelementptr %arg0[%671] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%669 = llvm.load %673 : !llvm.ptr -> i64
func.call @tr_visit(%arg0, %669, %arg2) : (!llvm.ptr, i64, !llvm.ptr) -> ()
func.return
}
func.func @main() -> i32 {
%675 = llvm.mlir.addressof @CAP : !llvm.ptr
%676 = llvm.load %675 : !llvm.ptr -> i64
%677 = arith.constant 8 : i32
%679 = arith.extsi %677 : i32 to i64
%678 = arith.muli %676, %679 : i64
%680 = arith.constant 8 : i32
%681 = arith.extsi %680 : i32 to i64
%674 = func.call @calloc(%678, %681) : (i64, i64) -> !llvm.ptr
%683 = arith.constant 4 : i32
%684 = arith.constant 8 : i32
%685 = arith.extsi %683 : i32 to i64
%686 = arith.extsi %684 : i32 to i64
%682 = func.call @calloc(%685, %686) : (i64, i64) -> !llvm.ptr
%687 = arith.constant 987654321 : i32
%688 = arith.constant 1 : i32
%689 = arith.extsi %687 : i32 to i64
%690 = arith.extsi %688 : i32 to i64
%691 = llvm.getelementptr %682[%690] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %689, %691 : i64, !llvm.ptr
%693 = arith.constant 0 : i32
%694 = llvm.mlir.addressof @BIGN : !llvm.ptr
%695 = llvm.load %694 : !llvm.ptr -> i64
%696 = arith.constant 0 : i32
%697 = arith.extsi %693 : i32 to i64
%698 = arith.extsi %696 : i32 to i64
%692 = func.call @nn_new(%674, %682, %697, %695, %698) : (!llvm.ptr, !llvm.ptr, i64, i64, i64) -> i64
%699 = llvm.mlir.constant(1 : i64) : i64
%700 = llvm.alloca %699 x i64 : (i64) -> !llvm.ptr
llvm.store %692, %700 : i64, !llvm.ptr
%701 = arith.constant 1 : i32
%702 = arith.extsi %701 : i32 to i64
%703 = llvm.mlir.constant(1 : i64) : i64
%704 = llvm.alloca %703 x i64 : (i64) -> !llvm.ptr
llvm.store %702, %704 : i64, !llvm.ptr
%705 = arith.constant 1 : i32
%706 = arith.extsi %705 : i32 to i64
%707 = llvm.mlir.constant(1 : i64) : i64
%708 = llvm.alloca %707 x i64 : (i64) -> !llvm.ptr
llvm.store %706, %708 : i64, !llvm.ptr
%709 = arith.constant 0 : i32
%710 = arith.extsi %709 : i32 to i64
%711 = llvm.mlir.constant(1 : i64) : i64
%712 = llvm.alloca %711 x i64 : (i64) -> !llvm.ptr
llvm.store %710, %712 : i64, !llvm.ptr
cf.br ^bb51
^bb51:
%713 = llvm.load %712 : !llvm.ptr -> i64
%714 = llvm.mlir.addressof @K : !llvm.ptr
%715 = llvm.load %714 : !llvm.ptr -> i64
%716 = arith.cmpi slt, %713, %715 : i64
cf.cond_br %716, ^bb52, ^bb53
^bb52:
%717 = llvm.load %704 : !llvm.ptr -> i64
%718 = llvm.mlir.constant(1 : i64) : i64
%719 = llvm.alloca %718 x i64 : (i64) -> !llvm.ptr
llvm.store %717, %719 : i64, !llvm.ptr
%720 = llvm.load %708 : !llvm.ptr -> i64
%721 = llvm.mlir.constant(1 : i64) : i64
%722 = llvm.alloca %721 x i64 : (i64) -> !llvm.ptr
llvm.store %720, %722 : i64, !llvm.ptr
%723 = llvm.load %719 : !llvm.ptr -> i64
%724 = llvm.load %722 : !llvm.ptr -> i64
%725 = arith.cmpi sgt, %723, %724 : i64
cf.cond_br %725, ^bb54, ^bb55
^bb54:
%726 = llvm.load %719 : !llvm.ptr -> i64
%727 = llvm.load %722 : !llvm.ptr -> i64
llvm.store %727, %719 : i64, !llvm.ptr
llvm.store %726, %722 : i64, !llvm.ptr
cf.br ^bb56
^bb55:
cf.br ^bb56
^bb56:
%728 = llvm.load %704 : !llvm.ptr -> i64
%729 = llvm.load %708 : !llvm.ptr -> i64
%730 = arith.addi %728, %729 : i64
%731 = llvm.mlir.addressof @BIGN : !llvm.ptr
%732 = llvm.load %731 : !llvm.ptr -> i64
%733 = arith.remsi %730, %732 : i64
%734 = llvm.load %708 : !llvm.ptr -> i64
%735 = arith.addi %734, %733 : i64
%736 = llvm.mlir.addressof @BIGN : !llvm.ptr
%737 = llvm.load %736 : !llvm.ptr -> i64
%738 = arith.remsi %735, %737 : i64
llvm.store %733, %704 : i64, !llvm.ptr
llvm.store %738, %708 : i64, !llvm.ptr
%740 = llvm.load %700 : !llvm.ptr -> i64
%741 = llvm.load %722 : !llvm.ptr -> i64
%742 = arith.constant 1 : i32
%744 = arith.extsi %742 : i32 to i64
%743 = arith.addi %741, %744 : i64
%739 = func.call @tr_split(%674, %682, %740, %743) : (!llvm.ptr, !llvm.ptr, i64, i64) -> i64
%746 = arith.constant 2 : i32
%747 = arith.extsi %746 : i32 to i64
%748 = llvm.getelementptr %682[%747] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%745 = llvm.load %748 : !llvm.ptr -> i64
%750 = llvm.load %719 : !llvm.ptr -> i64
%749 = func.call @tr_split(%674, %682, %739, %750) : (!llvm.ptr, !llvm.ptr, i64, i64) -> i64
%752 = arith.constant 2 : i32
%753 = arith.extsi %752 : i32 to i64
%754 = llvm.getelementptr %682[%753] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%751 = llvm.load %754 : !llvm.ptr -> i64
%755 = arith.constant 0 : i32
%757 = arith.extsi %755 : i32 to i64
%756 = arith.cmpi ne, %751, %757 : i64
cf.cond_br %756, ^bb57, ^bb58
^bb57:
%758 = arith.constant 1 : i32
%760 = arith.constant 8 : i32
%762 = arith.extsi %760 : i32 to i64
%761 = arith.muli %751, %762 : i64
%763 = arith.constant 7 : i32
%765 = arith.extsi %763 : i32 to i64
%764 = arith.addi %761, %765 : i64
%766 = llvm.getelementptr %674[%764] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%759 = llvm.load %766 : !llvm.ptr -> i64
%768 = arith.extsi %758 : i32 to i64
%767 = arith.subi %768, %759 : i64
%769 = arith.constant 8 : i32
%771 = arith.extsi %769 : i32 to i64
%770 = arith.muli %751, %771 : i64
%772 = arith.constant 7 : i32
%774 = arith.extsi %772 : i32 to i64
%773 = arith.addi %770, %774 : i64
%775 = llvm.getelementptr %674[%773] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %767, %775 : i64, !llvm.ptr
cf.br ^bb59
^bb58:
cf.br ^bb59
^bb59:
%777 = func.call @tr_merge(%674, %749, %751) : (!llvm.ptr, i64, i64) -> i64
%776 = func.call @tr_merge(%674, %777, %745) : (!llvm.ptr, i64, i64) -> i64
llvm.store %776, %700 : i64, !llvm.ptr
%778 = llvm.load %712 : !llvm.ptr -> i64
%779 = arith.constant 1 : i32
%781 = arith.extsi %779 : i32 to i64
%780 = arith.addi %778, %781 : i64
llvm.store %780, %712 : i64, !llvm.ptr
cf.br ^bb51
^bb53:
%783 = arith.constant 2 : i32
%784 = arith.constant 8 : i32
%785 = arith.extsi %783 : i32 to i64
%786 = arith.extsi %784 : i32 to i64
%782 = func.call @calloc(%785, %786) : (i64, i64) -> !llvm.ptr
%788 = llvm.load %700 : !llvm.ptr -> i64
func.call @tr_visit(%674, %788, %782) : (!llvm.ptr, i64, !llvm.ptr) -> ()
%789 = llvm.mlir.addressof @str_0 : !llvm.ptr
%791 = arith.constant 1 : i32
%792 = arith.extsi %791 : i32 to i64
%793 = llvm.getelementptr %782[%792] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%790 = llvm.load %793 : !llvm.ptr -> i64
%794 = llvm.call @printf(%789, %790) vararg(!llvm.func<i32 (ptr, ...)>) : (!llvm.ptr, i64) -> i32
func.call @free(%674) : (!llvm.ptr) -> ()
func.call @free(%682) : (!llvm.ptr) -> ()
func.call @free(%782) : (!llvm.ptr) -> ()
%798 = arith.constant 0 : i32
func.return %798 : i32
}
}