Problem 1000
Meta-problem: M from I(1000), X(1000), C(1000) triple product recurrence.
View problem on Project Euler
Performance comparison
| Metric | Our solution | Best known |
| Time complexity | O(n^3) | ? |
| Space complexity | O(n^2) | ? |
| Approach | Flow solution | Not curated |
| Verdict | Unknown |
Flow source
# Project Euler 1000
# Meta-problem: M from I(1000), X(1000), C(1000) triple product recurrence.
extern {
function calloc(n: i64, size: i64) -> ptr<void>
function free(p: ptr<void>) -> void
}
const MOD: i64 = 1000000007
function ones_in_bit(n: i64, bit: i64) -> i64 {
if n < 0 { return 0 }
let half: i64 = 1 << bit
let period: i64 = half << 1
let value_count: i64 = n + 1
let full: i64 = value_count / period
let rem: i64 = value_count % period
let extra: i64 = rem - half
if extra < 0 { extra = 0 }
return full * half + extra
}
function max_and(n: i64) -> i64 {
if n <= 0 { return 0 }
let mut total: i64 = 0
let mut bit: i64 = 0
let mut v: i64 = n
while v > 0 {
let count: i64 = ones_in_bit(n, bit)
let smaller: i64 = count / 2
let larger: i64 = count - smaller
total = total + (1 << bit) * smaller * larger
v = v / 2
bit = bit + 1
}
return total
}
function max_xor_sum(n: i64) -> i64 {
if n <= 1 { return 0 }
let mut vb: i64 = 1
let mut t: i64 = n
while t > 1 {
t = t / 2
vb = vb + 1
}
let payload: i64 = 2 * vb
let vmask: i64 = (1 << vb) - 1
let squares: ptr<i64> = calloc(n + 1, 8)
let mut i: i64 = 0
while i <= n {
squares[i] = i * i
i = i + 1
}
let ec: i64 = n * (n - 1) / 2
let edges: ptr<i64> = calloc(ec, 8)
let mut e: i64 = 0
let mut left: i64 = 1
while left <= n {
let ls: i64 = squares[left]
let mut right: i64 = left + 1
while right <= n {
let weight: i64 = ls ^ squares[right]
edges[e] = (weight << payload) | (left << vb) | right
e = e + 1
right = right + 1
}
left = left + 1
}
# sort edges (heap sort)
let mut hs: i64 = ec / 2 - 1
while hs >= 0 {
let mut root: i64 = hs
while 1 == 1 {
let mut largest: i64 = root
let lch: i64 = 2 * root + 1
let rch: i64 = lch + 1
if lch < ec && edges[lch] > edges[largest] { largest = lch }
if rch < ec && edges[rch] > edges[largest] { largest = rch }
if largest == root { break }
let tmp: i64 = edges[root]
edges[root] = edges[largest]
edges[largest] = tmp
root = largest
}
hs = hs - 1
}
let mut end: i64 = ec - 1
while end > 0 {
let tmp2: i64 = edges[0]
edges[0] = edges[end]
edges[end] = tmp2
let mut root2: i64 = 0
let lim: i64 = end
while 1 == 1 {
let mut largest2: i64 = root2
let l2: i64 = 2 * root2 + 1
let r2: i64 = l2 + 1
if l2 < lim && edges[l2] > edges[largest2] { largest2 = l2 }
if r2 < lim && edges[r2] > edges[largest2] { largest2 = r2 }
if largest2 == root2 { break }
let t3: i64 = edges[root2]
edges[root2] = edges[largest2]
edges[largest2] = t3
root2 = largest2
}
end = end - 1
}
let best: ptr<i64> = calloc(n + 1, 8)
let pending: ptr<i64> = calloc(n + 1, 8)
let mut pi: i64 = 0
while pi <= n {
pending[pi] = -1
pi = pi + 1
}
let touched: ptr<i64> = calloc(n + 1, 8)
let mut index: i64 = 0
while index < ec {
let weight: i64 = edges[index] >> payload
let mut tc: i64 = 0
let mut next_index: i64 = index
while next_index < ec && (edges[next_index] >> payload) == weight {
let packed: i64 = edges[next_index]
let L: i64 = (packed >> vb) & vmask
let R: i64 = packed & vmask
let candL: i64 = best[R] + weight
if candL > pending[L] {
if pending[L] < 0 {
touched[tc] = L
tc = tc + 1
}
pending[L] = candL
}
let candR: i64 = best[L] + weight
if candR > pending[R] {
if pending[R] < 0 {
touched[tc] = R
tc = tc + 1
}
pending[R] = candR
}
next_index = next_index + 1
}
let mut ti: i64 = 0
while ti < tc {
let v2: i64 = touched[ti]
if pending[v2] > best[v2] { best[v2] = pending[v2] }
pending[v2] = -1
ti = ti + 1
}
index = next_index
}
let mut ans: i64 = 0
let mut v3: i64 = 0
while v3 <= n {
if best[v3] > ans { ans = best[v3] }
v3 = v3 + 1
}
free(squares)
free(edges)
free(best)
free(pending)
free(touched)
return ans
}
function count_unreachable_pivot(limit: i64, pivot: i64) -> i64 {
let mut bit_count: i64 = 1
let mut tmp: i64 = limit
while tmp > 1 {
tmp = tmp / 2
bit_count = bit_count + 1
}
let counts: ptr<i64> = calloc(8, 8)
let nextc: ptr<i64> = calloc(8, 8)
counts[7] = 1
let mut bit: i64 = bit_count - 1
while bit >= 0 {
let mut mi: i64 = 0
while mi < 8 {
nextc[mi] = 0
mi = mi + 1
}
let limit_bit: i64 = (limit >> bit) & 1
let mut tight: i64 = 0
while tight < 8 {
let ways: i64 = counts[tight]
if ways > 0 {
let mut pat: i64 = 0
while pat < 8 {
let mut use: i32 = 0
if bit > pivot {
if pat == 0 || pat == 3 || pat == 5 || pat == 6 { use = 1 }
} else {
if bit == pivot {
if pat == 7 { use = 1 }
} else {
use = 1
}
}
if use == 1 {
let mut next_tight: i64 = 0
let mut valid: i32 = 1
let mut pile: i64 = 0
while pile < 3 {
let pile_mask: i64 = 1 << pile
if (tight & pile_mask) != 0 {
let chosen: i64 = (pat >> pile) & 1
if chosen > limit_bit {
valid = 0
break
}
if chosen == limit_bit {
next_tight = next_tight | pile_mask
}
}
pile = pile + 1
}
if valid == 1 {
nextc[next_tight] = nextc[next_tight] + ways
}
}
pat = pat + 1
}
}
tight = tight + 1
}
mi = 0
while mi < 8 {
counts[mi] = nextc[mi]
mi = mi + 1
}
bit = bit - 1
}
let mut s: i64 = 0
let mut j: i64 = 0
while j < 8 {
s = s + counts[j]
j = j + 1
}
free(counts)
free(nextc)
return s
}
function count_unreachable_nim(n: i64) -> i64 {
if n <= 0 { return 0 }
let limit: i64 = n - 1
let mut bit_count: i64 = 1
let mut tmp: i64 = limit
while tmp > 1 {
tmp = tmp / 2
bit_count = bit_count + 1
}
let mut total: i64 = 0
let mut pivot: i64 = 0
while pivot < bit_count {
total = total + count_unreachable_pivot(limit, pivot)
pivot = pivot + 1
}
return total
}
function main() -> i32 {
let I: i64 = max_and(1000) % MOD
let X: i64 = max_xor_sum(1000) % MOD
let C: i64 = count_unreachable_nim(1000) % MOD
let mut m0: i64 = I
let mut m1: i64 = X
let mut m2: i64 = C
let mut k: i64 = 3
while k <= 1000 {
let nxt: i64 = m2 * m1 % MOD * m0 % MOD
m0 = m1
m1 = m2
m2 = nxt
k = k + 1
}
printf("%lld\n", m2)
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 ones_in_bit_i64_i64(int64_t n, int64_t bit);
int64_t max_and_i64(int64_t n);
int64_t max_xor_sum_i64(int64_t n);
int64_t count_unreachable_pivot_i64_i64(int64_t limit, int64_t pivot);
int64_t count_unreachable_nim_i64(int64_t n);
int32_t main(void);
static const int64_t MOD = 1000000007;
int64_t ones_in_bit_i64_i64(int64_t n, int64_t bit) {
if (n < 0) {
return 0;
}
int64_t half = FLOW_CHECKED_SHL((1), (bit));
int64_t period = FLOW_CHECKED_SHL((half), (1));
int64_t value_count = (n + 1);
int64_t full = FLOW_CHECKED_DIV((value_count), (period));
int64_t rem = FLOW_CHECKED_MOD((value_count), (period));
int64_t extra = (rem - half);
if (extra < 0) {
extra = 0;
}
return ((full * half) + extra);
}
int64_t max_and_i64(int64_t n) {
if (n <= 0) {
return 0;
}
int64_t total = 0;
int64_t bit = 0;
int64_t v = n;
while (v > 0) {
int64_t count = ones_in_bit_i64_i64(n, bit);
int64_t smaller = FLOW_CHECKED_DIV((count), (2));
int64_t larger = (count - smaller);
total = (total + ((FLOW_CHECKED_SHL((1), (bit)) * smaller) * larger));
v = FLOW_CHECKED_DIV((v), (2));
bit = (bit + 1);
}
return total;
}
int64_t max_xor_sum_i64(int64_t n) {
if (n <= 1) {
return 0;
}
int64_t vb = 1;
int64_t t = n;
while (t > 1) {
t = FLOW_CHECKED_DIV((t), (2));
vb = (vb + 1);
}
int64_t payload = (2 * vb);
int64_t vmask = (FLOW_CHECKED_SHL((1), (vb)) - 1);
int64_t* squares = (int64_t*)(calloc((n + 1), 8));
int64_t i = 0;
while (i <= n) {
squares[i] = (i * i);
i = (i + 1);
}
int64_t ec = FLOW_CHECKED_DIV(((n * (n - 1))), (2));
int64_t* edges = (int64_t*)(calloc(ec, 8));
int64_t e = 0;
int64_t left = 1;
while (left <= n) {
int64_t ls = squares[left];
int64_t right = (left + 1);
while (right <= n) {
int64_t weight = (ls ^ squares[right]);
edges[e] = ((FLOW_CHECKED_SHL((weight), (payload)) | FLOW_CHECKED_SHL((left), (vb))) | right);
e = (e + 1);
right = (right + 1);
}
left = (left + 1);
}
int64_t hs = (FLOW_CHECKED_DIV((ec), (2)) - 1);
while (hs >= 0) {
int64_t root = hs;
while (1 == 1) {
int64_t largest = root;
int64_t lch = ((2 * root) + 1);
int64_t rch = (lch + 1);
if ((lch < ec && edges[lch] > edges[largest])) {
largest = lch;
}
if ((rch < ec && edges[rch] > edges[largest])) {
largest = rch;
}
if (largest == root) {
break;
}
int64_t tmp = edges[root];
edges[root] = edges[largest];
edges[largest] = tmp;
root = largest;
}
hs = (hs - 1);
}
int64_t end = (ec - 1);
while (end > 0) {
int64_t tmp2 = edges[0];
edges[0] = edges[end];
edges[end] = tmp2;
int64_t root2 = 0;
int64_t lim = end;
while (1 == 1) {
int64_t largest2 = root2;
int64_t l2 = ((2 * root2) + 1);
int64_t r2 = (l2 + 1);
if ((l2 < lim && edges[l2] > edges[largest2])) {
largest2 = l2;
}
if ((r2 < lim && edges[r2] > edges[largest2])) {
largest2 = r2;
}
if (largest2 == root2) {
break;
}
int64_t t3 = edges[root2];
edges[root2] = edges[largest2];
edges[largest2] = t3;
root2 = largest2;
}
end = (end - 1);
}
int64_t* best = (int64_t*)(calloc((n + 1), 8));
int64_t* pending = (int64_t*)(calloc((n + 1), 8));
int64_t pi = 0;
while (pi <= n) {
pending[pi] = (-1);
pi = (pi + 1);
}
int64_t* touched = (int64_t*)(calloc((n + 1), 8));
int64_t index = 0;
while (index < ec) {
int64_t weight = FLOW_CHECKED_SHR((edges[index]), (payload));
int64_t tc = 0;
int64_t next_index = index;
while ((next_index < ec && FLOW_CHECKED_SHR((edges[next_index]), (payload)) == weight)) {
int64_t packed = edges[next_index];
int64_t L = (FLOW_CHECKED_SHR((packed), (vb)) & vmask);
int64_t R = (packed & vmask);
int64_t candL = (best[R] + weight);
if (candL > pending[L]) {
if (pending[L] < 0) {
touched[tc] = L;
tc = (tc + 1);
}
pending[L] = candL;
}
int64_t candR = (best[L] + weight);
if (candR > pending[R]) {
if (pending[R] < 0) {
touched[tc] = R;
tc = (tc + 1);
}
pending[R] = candR;
}
next_index = (next_index + 1);
}
int64_t ti = 0;
while (ti < tc) {
int64_t v2 = touched[ti];
if (pending[v2] > best[v2]) {
best[v2] = pending[v2];
}
pending[v2] = (-1);
ti = (ti + 1);
}
index = next_index;
}
int64_t ans = 0;
int64_t v3 = 0;
while (v3 <= n) {
if (best[v3] > ans) {
ans = best[v3];
}
v3 = (v3 + 1);
}
free(squares);
free(edges);
free(best);
free(pending);
free(touched);
return ans;
}
int64_t count_unreachable_pivot_i64_i64(int64_t limit, int64_t pivot) {
int64_t bit_count = 1;
int64_t tmp = limit;
while (tmp > 1) {
tmp = FLOW_CHECKED_DIV((tmp), (2));
bit_count = (bit_count + 1);
}
int64_t* counts = (int64_t*)(calloc(8, 8));
int64_t* nextc = (int64_t*)(calloc(8, 8));
counts[7] = 1;
int64_t bit = (bit_count - 1);
while (bit >= 0) {
int64_t mi = 0;
while (mi < 8) {
nextc[mi] = 0;
mi = (mi + 1);
}
int64_t limit_bit = (FLOW_CHECKED_SHR((limit), (bit)) & 1);
int64_t tight = 0;
while (tight < 8) {
int64_t ways = counts[tight];
if (ways > 0) {
int64_t pat = 0;
while (pat < 8) {
int32_t use = 0;
if (bit > pivot) {
if ((((pat == 0 || pat == 3) || pat == 5) || pat == 6)) {
use = 1;
}
} else {
if (bit == pivot) {
if (pat == 7) {
use = 1;
}
} else {
use = 1;
}
}
if (use == 1) {
int64_t next_tight = 0;
int32_t valid = 1;
int64_t pile = 0;
while (pile < 3) {
int64_t pile_mask = FLOW_CHECKED_SHL((1), (pile));
if ((tight & pile_mask) != 0) {
int64_t chosen = (FLOW_CHECKED_SHR((pat), (pile)) & 1);
if (chosen > limit_bit) {
valid = 0;
break;
}
if (chosen == limit_bit) {
next_tight = (next_tight | pile_mask);
}
}
pile = (pile + 1);
}
if (valid == 1) {
nextc[next_tight] = (nextc[next_tight] + ways);
}
}
pat = (pat + 1);
}
}
tight = (tight + 1);
}
mi = 0;
while (mi < 8) {
counts[mi] = nextc[mi];
mi = (mi + 1);
}
bit = (bit - 1);
}
int64_t s = 0;
int64_t j = 0;
while (j < 8) {
s = (s + counts[j]);
j = (j + 1);
}
free(counts);
free(nextc);
return s;
}
int64_t count_unreachable_nim_i64(int64_t n) {
if (n <= 0) {
return 0;
}
int64_t limit = (n - 1);
int64_t bit_count = 1;
int64_t tmp = limit;
while (tmp > 1) {
tmp = FLOW_CHECKED_DIV((tmp), (2));
bit_count = (bit_count + 1);
}
int64_t total = 0;
int64_t pivot = 0;
while (pivot < bit_count) {
total = (total + count_unreachable_pivot_i64_i64(limit, pivot));
pivot = (pivot + 1);
}
return total;
}
int32_t main(void) {
int64_t I = FLOW_CHECKED_MOD((max_and_i64(1000)), (MOD));
int64_t X = FLOW_CHECKED_MOD((max_xor_sum_i64(1000)), (MOD));
int64_t C = FLOW_CHECKED_MOD((count_unreachable_nim_i64(1000)), (MOD));
int64_t m0 = I;
int64_t m1 = X;
int64_t m2 = C;
int64_t k = 3;
while (k <= 1000) {
int64_t nxt = FLOW_CHECKED_MOD(((FLOW_CHECKED_MOD(((m2 * m1)), (MOD)) * m0)), (MOD));
m0 = m1;
m1 = m2;
m2 = nxt;
k = (k + 1);
}
printf("%lld\n", m2);
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: MOD
llvm.mlir.global internal constant @MOD(1000000007 : i64) : i64
func.func @ones_in_bit(%arg0: i64, %arg1: i64) -> i64 {
%0 = arith.constant 0 : i32
%2 = arith.extsi %0 : i32 to i64
%1 = arith.cmpi slt, %arg0, %2 : i64
cf.cond_br %1, ^bb0, ^bb1
^bb0:
%3 = arith.constant 0 : i32
%4 = arith.extsi %3 : i32 to i64
func.return %4 : i64
^bb1:
cf.br ^bb2
^bb2:
%5 = arith.constant 1 : i32
%7 = arith.extsi %5 : i32 to i64
%6 = arith.shli %7, %arg1 : i64
%8 = arith.constant 1 : i32
%10 = arith.extsi %8 : i32 to i64
%9 = arith.shli %6, %10 : i64
%11 = arith.constant 1 : i32
%13 = arith.extsi %11 : i32 to i64
%12 = arith.addi %arg0, %13 : i64
%14 = arith.divsi %12, %9 : i64
%15 = arith.remsi %12, %9 : i64
%16 = arith.subi %15, %6 : i64
%17 = arith.constant 0 : i32
%19 = arith.extsi %17 : i32 to i64
%18 = arith.cmpi slt, %16, %19 : i64
%20 = scf.if %18 -> (i64) {
%21 = arith.constant 0 : i32
%22 = arith.extsi %21 : i32 to i64
scf.yield %22 : i64
} else {
scf.yield %16 : i64
}
%23 = arith.muli %14, %6 : i64
%24 = arith.addi %23, %20 : i64
func.return %24 : i64
}
func.func @max_and(%arg0: i64) -> i64 {
%25 = arith.constant 0 : i32
%27 = arith.extsi %25 : i32 to i64
%26 = arith.cmpi sle, %arg0, %27 : i64
cf.cond_br %26, ^bb3, ^bb4
^bb3:
%28 = arith.constant 0 : i32
%29 = arith.extsi %28 : i32 to i64
func.return %29 : i64
^bb4:
cf.br ^bb5
^bb5:
%30 = arith.constant 0 : i32
%31 = arith.extsi %30 : i32 to i64
%32 = llvm.mlir.constant(1 : i64) : i64
%33 = llvm.alloca %32 x i64 : (i64) -> !llvm.ptr
llvm.store %31, %33 : i64, !llvm.ptr
%34 = arith.constant 0 : i32
%35 = arith.extsi %34 : i32 to i64
%36 = llvm.mlir.constant(1 : i64) : i64
%37 = llvm.alloca %36 x i64 : (i64) -> !llvm.ptr
llvm.store %35, %37 : i64, !llvm.ptr
%38 = llvm.mlir.constant(1 : i64) : i64
%39 = llvm.alloca %38 x i64 : (i64) -> !llvm.ptr
llvm.store %arg0, %39 : i64, !llvm.ptr
cf.br ^bb6
^bb6:
%40 = llvm.load %39 : !llvm.ptr -> i64
%41 = arith.constant 0 : i32
%43 = arith.extsi %41 : i32 to i64
%42 = arith.cmpi sgt, %40, %43 : i64
cf.cond_br %42, ^bb7, ^bb8
^bb7:
%45 = llvm.load %37 : !llvm.ptr -> i64
%44 = func.call @ones_in_bit(%arg0, %45) : (i64, i64) -> i64
%46 = arith.constant 2 : i32
%48 = arith.extsi %46 : i32 to i64
%47 = arith.divsi %44, %48 : i64
%49 = arith.subi %44, %47 : i64
%50 = llvm.load %33 : !llvm.ptr -> i64
%51 = arith.constant 1 : i32
%52 = llvm.load %37 : !llvm.ptr -> i64
%54 = arith.extsi %51 : i32 to i64
%53 = arith.shli %54, %52 : i64
%55 = arith.muli %53, %47 : i64
%56 = arith.muli %55, %49 : i64
%57 = arith.addi %50, %56 : i64
llvm.store %57, %33 : i64, !llvm.ptr
%58 = llvm.load %39 : !llvm.ptr -> i64
%59 = arith.constant 2 : i32
%61 = arith.extsi %59 : i32 to i64
%60 = arith.divsi %58, %61 : i64
llvm.store %60, %39 : i64, !llvm.ptr
%62 = llvm.load %37 : !llvm.ptr -> i64
%63 = arith.constant 1 : i32
%65 = arith.extsi %63 : i32 to i64
%64 = arith.addi %62, %65 : i64
llvm.store %64, %37 : i64, !llvm.ptr
cf.br ^bb6
^bb8:
%66 = llvm.load %33 : !llvm.ptr -> i64
func.return %66 : i64
}
func.func @max_xor_sum(%arg0: i64) -> i64 {
%67 = arith.constant 1 : i32
%69 = arith.extsi %67 : i32 to i64
%68 = arith.cmpi sle, %arg0, %69 : i64
cf.cond_br %68, ^bb9, ^bb10
^bb9:
%70 = arith.constant 0 : i32
%71 = arith.extsi %70 : i32 to i64
func.return %71 : i64
^bb10:
cf.br ^bb11
^bb11:
%72 = arith.constant 1 : i32
%73 = arith.extsi %72 : i32 to i64
%74 = llvm.mlir.constant(1 : i64) : i64
%75 = llvm.alloca %74 x i64 : (i64) -> !llvm.ptr
llvm.store %73, %75 : i64, !llvm.ptr
%76 = llvm.mlir.constant(1 : i64) : i64
%77 = llvm.alloca %76 x i64 : (i64) -> !llvm.ptr
llvm.store %arg0, %77 : i64, !llvm.ptr
cf.br ^bb12
^bb12:
%78 = llvm.load %77 : !llvm.ptr -> i64
%79 = arith.constant 1 : i32
%81 = arith.extsi %79 : i32 to i64
%80 = arith.cmpi sgt, %78, %81 : i64
cf.cond_br %80, ^bb13, ^bb14
^bb13:
%82 = llvm.load %77 : !llvm.ptr -> i64
%83 = arith.constant 2 : i32
%85 = arith.extsi %83 : i32 to i64
%84 = arith.divsi %82, %85 : i64
llvm.store %84, %77 : i64, !llvm.ptr
%86 = llvm.load %75 : !llvm.ptr -> i64
%87 = arith.constant 1 : i32
%89 = arith.extsi %87 : i32 to i64
%88 = arith.addi %86, %89 : i64
llvm.store %88, %75 : i64, !llvm.ptr
cf.br ^bb12
^bb14:
%90 = arith.constant 2 : i32
%91 = llvm.load %75 : !llvm.ptr -> i64
%93 = arith.extsi %90 : i32 to i64
%92 = arith.muli %93, %91 : i64
%94 = arith.constant 1 : i32
%95 = llvm.load %75 : !llvm.ptr -> i64
%97 = arith.extsi %94 : i32 to i64
%96 = arith.shli %97, %95 : i64
%98 = arith.constant 1 : i32
%100 = arith.extsi %98 : i32 to i64
%99 = arith.subi %96, %100 : i64
%102 = arith.constant 1 : i32
%104 = arith.extsi %102 : i32 to i64
%103 = arith.addi %arg0, %104 : i64
%105 = arith.constant 8 : i32
%106 = arith.extsi %105 : i32 to i64
%101 = func.call @calloc(%103, %106) : (i64, i64) -> !llvm.ptr
%107 = arith.constant 0 : i32
%108 = arith.extsi %107 : i32 to i64
%109 = llvm.mlir.constant(1 : i64) : i64
%110 = llvm.alloca %109 x i64 : (i64) -> !llvm.ptr
llvm.store %108, %110 : i64, !llvm.ptr
cf.br ^bb15
^bb15:
%111 = llvm.load %110 : !llvm.ptr -> i64
%112 = arith.cmpi sle, %111, %arg0 : i64
cf.cond_br %112, ^bb16, ^bb17
^bb16:
%113 = llvm.load %110 : !llvm.ptr -> i64
%114 = llvm.load %110 : !llvm.ptr -> i64
%115 = arith.muli %113, %114 : i64
%116 = llvm.load %110 : !llvm.ptr -> i64
%117 = llvm.getelementptr %101[%116] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %115, %117 : i64, !llvm.ptr
%118 = llvm.load %110 : !llvm.ptr -> i64
%119 = arith.constant 1 : i32
%121 = arith.extsi %119 : i32 to i64
%120 = arith.addi %118, %121 : i64
llvm.store %120, %110 : i64, !llvm.ptr
cf.br ^bb15
^bb17:
%122 = arith.constant 1 : i32
%124 = arith.extsi %122 : i32 to i64
%123 = arith.subi %arg0, %124 : i64
%125 = arith.muli %arg0, %123 : i64
%126 = arith.constant 2 : i32
%128 = arith.extsi %126 : i32 to i64
%127 = arith.divsi %125, %128 : i64
%130 = arith.constant 8 : i32
%131 = arith.extsi %130 : i32 to i64
%129 = func.call @calloc(%127, %131) : (i64, i64) -> !llvm.ptr
%132 = arith.constant 0 : i32
%133 = arith.extsi %132 : i32 to i64
%134 = llvm.mlir.constant(1 : i64) : i64
%135 = llvm.alloca %134 x i64 : (i64) -> !llvm.ptr
llvm.store %133, %135 : i64, !llvm.ptr
%136 = arith.constant 1 : i32
%137 = arith.extsi %136 : i32 to i64
%138 = llvm.mlir.constant(1 : i64) : i64
%139 = llvm.alloca %138 x i64 : (i64) -> !llvm.ptr
llvm.store %137, %139 : i64, !llvm.ptr
cf.br ^bb18
^bb18:
%140 = llvm.load %139 : !llvm.ptr -> i64
%141 = arith.cmpi sle, %140, %arg0 : i64
cf.cond_br %141, ^bb19, ^bb20
^bb19:
%143 = llvm.load %139 : !llvm.ptr -> i64
%144 = llvm.getelementptr %101[%143] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%142 = llvm.load %144 : !llvm.ptr -> i64
%145 = llvm.load %139 : !llvm.ptr -> i64
%146 = arith.constant 1 : i32
%148 = arith.extsi %146 : i32 to i64
%147 = arith.addi %145, %148 : i64
%149 = llvm.mlir.constant(1 : i64) : i64
%150 = llvm.alloca %149 x i64 : (i64) -> !llvm.ptr
llvm.store %147, %150 : i64, !llvm.ptr
cf.br ^bb21
^bb21:
%151 = llvm.load %150 : !llvm.ptr -> i64
%152 = arith.cmpi sle, %151, %arg0 : i64
cf.cond_br %152, ^bb22, ^bb23
^bb22:
%154 = llvm.load %150 : !llvm.ptr -> i64
%155 = llvm.getelementptr %101[%154] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%153 = llvm.load %155 : !llvm.ptr -> i64
%156 = arith.xori %142, %153 : i64
%157 = arith.shli %156, %92 : i64
%158 = llvm.load %139 : !llvm.ptr -> i64
%159 = llvm.load %75 : !llvm.ptr -> i64
%160 = arith.shli %158, %159 : i64
%161 = arith.ori %157, %160 : i64
%162 = llvm.load %150 : !llvm.ptr -> i64
%163 = arith.ori %161, %162 : i64
%164 = llvm.load %135 : !llvm.ptr -> i64
%165 = llvm.getelementptr %129[%164] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %163, %165 : i64, !llvm.ptr
%166 = llvm.load %135 : !llvm.ptr -> i64
%167 = arith.constant 1 : i32
%169 = arith.extsi %167 : i32 to i64
%168 = arith.addi %166, %169 : i64
llvm.store %168, %135 : i64, !llvm.ptr
%170 = llvm.load %150 : !llvm.ptr -> i64
%171 = arith.constant 1 : i32
%173 = arith.extsi %171 : i32 to i64
%172 = arith.addi %170, %173 : i64
llvm.store %172, %150 : i64, !llvm.ptr
cf.br ^bb21
^bb23:
%174 = llvm.load %139 : !llvm.ptr -> i64
%175 = arith.constant 1 : i32
%177 = arith.extsi %175 : i32 to i64
%176 = arith.addi %174, %177 : i64
llvm.store %176, %139 : i64, !llvm.ptr
cf.br ^bb18
^bb20:
%178 = arith.constant 2 : i32
%180 = arith.extsi %178 : i32 to i64
%179 = arith.divsi %127, %180 : i64
%181 = arith.constant 1 : i32
%183 = arith.extsi %181 : i32 to i64
%182 = arith.subi %179, %183 : i64
%184 = llvm.mlir.constant(1 : i64) : i64
%185 = llvm.alloca %184 x i64 : (i64) -> !llvm.ptr
llvm.store %182, %185 : i64, !llvm.ptr
cf.br ^bb24
^bb24:
%186 = llvm.load %185 : !llvm.ptr -> i64
%187 = arith.constant 0 : i32
%189 = arith.extsi %187 : i32 to i64
%188 = arith.cmpi sge, %186, %189 : i64
cf.cond_br %188, ^bb25, ^bb26
^bb25:
%190 = llvm.load %185 : !llvm.ptr -> i64
%191 = llvm.mlir.constant(1 : i64) : i64
%192 = llvm.alloca %191 x i64 : (i64) -> !llvm.ptr
llvm.store %190, %192 : i64, !llvm.ptr
cf.br ^bb27
^bb27:
%193 = arith.constant 1 : i32
%194 = arith.constant 1 : i32
%195 = arith.cmpi eq, %193, %194 : i32
cf.cond_br %195, ^bb28, ^bb29
^bb28:
%196 = llvm.load %192 : !llvm.ptr -> i64
%197 = llvm.mlir.constant(1 : i64) : i64
%198 = llvm.alloca %197 x i64 : (i64) -> !llvm.ptr
llvm.store %196, %198 : i64, !llvm.ptr
%199 = arith.constant 2 : i32
%200 = llvm.load %192 : !llvm.ptr -> i64
%202 = arith.extsi %199 : i32 to i64
%201 = arith.muli %202, %200 : i64
%203 = arith.constant 1 : i32
%205 = arith.extsi %203 : i32 to i64
%204 = arith.addi %201, %205 : i64
%206 = arith.constant 1 : i32
%208 = arith.extsi %206 : i32 to i64
%207 = arith.addi %204, %208 : i64
%209 = arith.cmpi slt, %204, %127 : i64
%210 = scf.if %209 -> (i1) {
%212 = llvm.getelementptr %129[%204] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%211 = llvm.load %212 : !llvm.ptr -> i64
%214 = llvm.load %198 : !llvm.ptr -> i64
%215 = llvm.getelementptr %129[%214] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%213 = llvm.load %215 : !llvm.ptr -> i64
%216 = arith.cmpi sgt, %211, %213 : i64
scf.yield %216 : i1
} else {
%217 = arith.constant false
scf.yield %217 : i1
}
cf.cond_br %210, ^bb30, ^bb31
^bb30:
llvm.store %204, %198 : i64, !llvm.ptr
cf.br ^bb32
^bb31:
cf.br ^bb32
^bb32:
%218 = arith.cmpi slt, %207, %127 : i64
%219 = scf.if %218 -> (i1) {
%221 = llvm.getelementptr %129[%207] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%220 = llvm.load %221 : !llvm.ptr -> i64
%223 = llvm.load %198 : !llvm.ptr -> i64
%224 = llvm.getelementptr %129[%223] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%222 = llvm.load %224 : !llvm.ptr -> i64
%225 = arith.cmpi sgt, %220, %222 : i64
scf.yield %225 : i1
} else {
%226 = arith.constant false
scf.yield %226 : i1
}
cf.cond_br %219, ^bb33, ^bb34
^bb33:
llvm.store %207, %198 : i64, !llvm.ptr
cf.br ^bb35
^bb34:
cf.br ^bb35
^bb35:
%227 = llvm.load %198 : !llvm.ptr -> i64
%228 = llvm.load %192 : !llvm.ptr -> i64
%229 = arith.cmpi eq, %227, %228 : i64
cf.cond_br %229, ^bb36, ^bb37
^bb36:
cf.br ^bb29
^bb37:
cf.br ^bb38
^bb38:
%231 = llvm.load %192 : !llvm.ptr -> i64
%232 = llvm.getelementptr %129[%231] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%230 = llvm.load %232 : !llvm.ptr -> i64
%234 = llvm.load %198 : !llvm.ptr -> i64
%235 = llvm.getelementptr %129[%234] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%233 = llvm.load %235 : !llvm.ptr -> i64
%236 = llvm.load %192 : !llvm.ptr -> i64
%237 = llvm.getelementptr %129[%236] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %233, %237 : i64, !llvm.ptr
%238 = llvm.load %198 : !llvm.ptr -> i64
%239 = llvm.getelementptr %129[%238] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %230, %239 : i64, !llvm.ptr
%240 = llvm.load %198 : !llvm.ptr -> i64
llvm.store %240, %192 : i64, !llvm.ptr
cf.br ^bb27
^bb29:
%241 = llvm.load %185 : !llvm.ptr -> i64
%242 = arith.constant 1 : i32
%244 = arith.extsi %242 : i32 to i64
%243 = arith.subi %241, %244 : i64
llvm.store %243, %185 : i64, !llvm.ptr
cf.br ^bb24
^bb26:
%245 = arith.constant 1 : i32
%247 = arith.extsi %245 : i32 to i64
%246 = arith.subi %127, %247 : i64
%248 = llvm.mlir.constant(1 : i64) : i64
%249 = llvm.alloca %248 x i64 : (i64) -> !llvm.ptr
llvm.store %246, %249 : i64, !llvm.ptr
cf.br ^bb39
^bb39:
%250 = llvm.load %249 : !llvm.ptr -> i64
%251 = arith.constant 0 : i32
%253 = arith.extsi %251 : i32 to i64
%252 = arith.cmpi sgt, %250, %253 : i64
cf.cond_br %252, ^bb40, ^bb41
^bb40:
%255 = arith.constant 0 : i32
%256 = arith.extsi %255 : i32 to i64
%257 = llvm.getelementptr %129[%256] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%254 = llvm.load %257 : !llvm.ptr -> i64
%259 = llvm.load %249 : !llvm.ptr -> i64
%260 = llvm.getelementptr %129[%259] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%258 = llvm.load %260 : !llvm.ptr -> i64
%261 = arith.constant 0 : i32
%262 = arith.extsi %261 : i32 to i64
%263 = llvm.getelementptr %129[%262] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %258, %263 : i64, !llvm.ptr
%264 = llvm.load %249 : !llvm.ptr -> i64
%265 = llvm.getelementptr %129[%264] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %254, %265 : i64, !llvm.ptr
%266 = arith.constant 0 : i32
%267 = arith.extsi %266 : i32 to i64
%268 = llvm.mlir.constant(1 : i64) : i64
%269 = llvm.alloca %268 x i64 : (i64) -> !llvm.ptr
llvm.store %267, %269 : i64, !llvm.ptr
%270 = llvm.load %249 : !llvm.ptr -> i64
cf.br ^bb42
^bb42:
%271 = arith.constant 1 : i32
%272 = arith.constant 1 : i32
%273 = arith.cmpi eq, %271, %272 : i32
cf.cond_br %273, ^bb43, ^bb44
^bb43:
%274 = llvm.load %269 : !llvm.ptr -> i64
%275 = llvm.mlir.constant(1 : i64) : i64
%276 = llvm.alloca %275 x i64 : (i64) -> !llvm.ptr
llvm.store %274, %276 : i64, !llvm.ptr
%277 = arith.constant 2 : i32
%278 = llvm.load %269 : !llvm.ptr -> i64
%280 = arith.extsi %277 : i32 to i64
%279 = arith.muli %280, %278 : i64
%281 = arith.constant 1 : i32
%283 = arith.extsi %281 : i32 to i64
%282 = arith.addi %279, %283 : i64
%284 = arith.constant 1 : i32
%286 = arith.extsi %284 : i32 to i64
%285 = arith.addi %282, %286 : i64
%287 = arith.cmpi slt, %282, %270 : i64
%288 = scf.if %287 -> (i1) {
%290 = llvm.getelementptr %129[%282] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%289 = llvm.load %290 : !llvm.ptr -> i64
%292 = llvm.load %276 : !llvm.ptr -> i64
%293 = llvm.getelementptr %129[%292] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%291 = llvm.load %293 : !llvm.ptr -> i64
%294 = arith.cmpi sgt, %289, %291 : i64
scf.yield %294 : i1
} else {
%295 = arith.constant false
scf.yield %295 : i1
}
cf.cond_br %288, ^bb45, ^bb46
^bb45:
llvm.store %282, %276 : i64, !llvm.ptr
cf.br ^bb47
^bb46:
cf.br ^bb47
^bb47:
%296 = arith.cmpi slt, %285, %270 : i64
%297 = scf.if %296 -> (i1) {
%299 = llvm.getelementptr %129[%285] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%298 = llvm.load %299 : !llvm.ptr -> i64
%301 = llvm.load %276 : !llvm.ptr -> i64
%302 = llvm.getelementptr %129[%301] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%300 = llvm.load %302 : !llvm.ptr -> i64
%303 = arith.cmpi sgt, %298, %300 : i64
scf.yield %303 : i1
} else {
%304 = arith.constant false
scf.yield %304 : i1
}
cf.cond_br %297, ^bb48, ^bb49
^bb48:
llvm.store %285, %276 : i64, !llvm.ptr
cf.br ^bb50
^bb49:
cf.br ^bb50
^bb50:
%305 = llvm.load %276 : !llvm.ptr -> i64
%306 = llvm.load %269 : !llvm.ptr -> i64
%307 = arith.cmpi eq, %305, %306 : i64
cf.cond_br %307, ^bb51, ^bb52
^bb51:
cf.br ^bb44
^bb52:
cf.br ^bb53
^bb53:
%309 = llvm.load %269 : !llvm.ptr -> i64
%310 = llvm.getelementptr %129[%309] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%308 = llvm.load %310 : !llvm.ptr -> i64
%312 = llvm.load %276 : !llvm.ptr -> i64
%313 = llvm.getelementptr %129[%312] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%311 = llvm.load %313 : !llvm.ptr -> i64
%314 = llvm.load %269 : !llvm.ptr -> i64
%315 = llvm.getelementptr %129[%314] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %311, %315 : i64, !llvm.ptr
%316 = llvm.load %276 : !llvm.ptr -> i64
%317 = llvm.getelementptr %129[%316] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %308, %317 : i64, !llvm.ptr
%318 = llvm.load %276 : !llvm.ptr -> i64
llvm.store %318, %269 : i64, !llvm.ptr
cf.br ^bb42
^bb44:
%319 = llvm.load %249 : !llvm.ptr -> i64
%320 = arith.constant 1 : i32
%322 = arith.extsi %320 : i32 to i64
%321 = arith.subi %319, %322 : i64
llvm.store %321, %249 : i64, !llvm.ptr
cf.br ^bb39
^bb41:
%324 = arith.constant 1 : i32
%326 = arith.extsi %324 : i32 to i64
%325 = arith.addi %arg0, %326 : i64
%327 = arith.constant 8 : i32
%328 = arith.extsi %327 : i32 to i64
%323 = func.call @calloc(%325, %328) : (i64, i64) -> !llvm.ptr
%330 = arith.constant 1 : i32
%332 = arith.extsi %330 : i32 to i64
%331 = arith.addi %arg0, %332 : i64
%333 = arith.constant 8 : i32
%334 = arith.extsi %333 : i32 to i64
%329 = func.call @calloc(%331, %334) : (i64, i64) -> !llvm.ptr
%335 = arith.constant 0 : i32
%336 = arith.extsi %335 : i32 to i64
%337 = llvm.mlir.constant(1 : i64) : i64
%338 = llvm.alloca %337 x i64 : (i64) -> !llvm.ptr
llvm.store %336, %338 : i64, !llvm.ptr
cf.br ^bb54
^bb54:
%339 = llvm.load %338 : !llvm.ptr -> i64
%340 = arith.cmpi sle, %339, %arg0 : i64
cf.cond_br %340, ^bb55, ^bb56
^bb55:
%341 = arith.constant 1 : i32
%343 = arith.constant 0 : i32
%342 = arith.subi %343, %341 : i32
%344 = llvm.load %338 : !llvm.ptr -> i64
%345 = arith.extsi %342 : i32 to i64
%346 = llvm.getelementptr %329[%344] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %345, %346 : i64, !llvm.ptr
%347 = llvm.load %338 : !llvm.ptr -> i64
%348 = arith.constant 1 : i32
%350 = arith.extsi %348 : i32 to i64
%349 = arith.addi %347, %350 : i64
llvm.store %349, %338 : i64, !llvm.ptr
cf.br ^bb54
^bb56:
%352 = arith.constant 1 : i32
%354 = arith.extsi %352 : i32 to i64
%353 = arith.addi %arg0, %354 : i64
%355 = arith.constant 8 : i32
%356 = arith.extsi %355 : i32 to i64
%351 = func.call @calloc(%353, %356) : (i64, i64) -> !llvm.ptr
%357 = arith.constant 0 : i32
%358 = arith.extsi %357 : i32 to i64
%359 = llvm.mlir.constant(1 : i64) : i64
%360 = llvm.alloca %359 x i64 : (i64) -> !llvm.ptr
llvm.store %358, %360 : i64, !llvm.ptr
cf.br ^bb57
^bb57:
%361 = llvm.load %360 : !llvm.ptr -> i64
%362 = arith.cmpi slt, %361, %127 : i64
cf.cond_br %362, ^bb58, ^bb59
^bb58:
%364 = llvm.load %360 : !llvm.ptr -> i64
%365 = llvm.getelementptr %129[%364] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%363 = llvm.load %365 : !llvm.ptr -> i64
%366 = arith.shrsi %363, %92 : i64
%367 = arith.constant 0 : i32
%368 = arith.extsi %367 : i32 to i64
%369 = llvm.mlir.constant(1 : i64) : i64
%370 = llvm.alloca %369 x i64 : (i64) -> !llvm.ptr
llvm.store %368, %370 : i64, !llvm.ptr
%371 = llvm.load %360 : !llvm.ptr -> i64
%372 = llvm.mlir.constant(1 : i64) : i64
%373 = llvm.alloca %372 x i64 : (i64) -> !llvm.ptr
llvm.store %371, %373 : i64, !llvm.ptr
cf.br ^bb60
^bb60:
%374 = llvm.load %373 : !llvm.ptr -> i64
%375 = arith.cmpi slt, %374, %127 : i64
%376 = scf.if %375 -> (i1) {
%378 = llvm.load %373 : !llvm.ptr -> i64
%379 = llvm.getelementptr %129[%378] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%377 = llvm.load %379 : !llvm.ptr -> i64
%380 = arith.shrsi %377, %92 : i64
%381 = arith.cmpi eq, %380, %366 : i64
scf.yield %381 : i1
} else {
%382 = arith.constant false
scf.yield %382 : i1
}
cf.cond_br %376, ^bb61, ^bb62
^bb61:
%384 = llvm.load %373 : !llvm.ptr -> i64
%385 = llvm.getelementptr %129[%384] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%383 = llvm.load %385 : !llvm.ptr -> i64
%386 = llvm.load %75 : !llvm.ptr -> i64
%387 = arith.shrsi %383, %386 : i64
%388 = arith.andi %387, %99 : i64
%389 = arith.andi %383, %99 : i64
%391 = llvm.getelementptr %323[%389] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%390 = llvm.load %391 : !llvm.ptr -> i64
%392 = arith.addi %390, %366 : i64
%394 = llvm.getelementptr %329[%388] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%393 = llvm.load %394 : !llvm.ptr -> i64
%395 = arith.cmpi sgt, %392, %393 : i64
cf.cond_br %395, ^bb63, ^bb64
^bb63:
%397 = llvm.getelementptr %329[%388] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%396 = llvm.load %397 : !llvm.ptr -> i64
%398 = arith.constant 0 : i32
%400 = arith.extsi %398 : i32 to i64
%399 = arith.cmpi slt, %396, %400 : i64
cf.cond_br %399, ^bb66, ^bb67
^bb66:
%401 = llvm.load %370 : !llvm.ptr -> i64
%402 = llvm.getelementptr %351[%401] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %388, %402 : i64, !llvm.ptr
%403 = llvm.load %370 : !llvm.ptr -> i64
%404 = arith.constant 1 : i32
%406 = arith.extsi %404 : i32 to i64
%405 = arith.addi %403, %406 : i64
llvm.store %405, %370 : i64, !llvm.ptr
cf.br ^bb68
^bb67:
cf.br ^bb68
^bb68:
%407 = llvm.getelementptr %329[%388] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %392, %407 : i64, !llvm.ptr
cf.br ^bb65
^bb64:
cf.br ^bb65
^bb65:
%409 = llvm.getelementptr %323[%388] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%408 = llvm.load %409 : !llvm.ptr -> i64
%410 = arith.addi %408, %366 : i64
%412 = llvm.getelementptr %329[%389] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%411 = llvm.load %412 : !llvm.ptr -> i64
%413 = arith.cmpi sgt, %410, %411 : i64
cf.cond_br %413, ^bb69, ^bb70
^bb69:
%415 = llvm.getelementptr %329[%389] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%414 = llvm.load %415 : !llvm.ptr -> i64
%416 = arith.constant 0 : i32
%418 = arith.extsi %416 : i32 to i64
%417 = arith.cmpi slt, %414, %418 : i64
cf.cond_br %417, ^bb72, ^bb73
^bb72:
%419 = llvm.load %370 : !llvm.ptr -> i64
%420 = llvm.getelementptr %351[%419] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %389, %420 : i64, !llvm.ptr
%421 = llvm.load %370 : !llvm.ptr -> i64
%422 = arith.constant 1 : i32
%424 = arith.extsi %422 : i32 to i64
%423 = arith.addi %421, %424 : i64
llvm.store %423, %370 : i64, !llvm.ptr
cf.br ^bb74
^bb73:
cf.br ^bb74
^bb74:
%425 = llvm.getelementptr %329[%389] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %410, %425 : i64, !llvm.ptr
cf.br ^bb71
^bb70:
cf.br ^bb71
^bb71:
%426 = llvm.load %373 : !llvm.ptr -> i64
%427 = arith.constant 1 : i32
%429 = arith.extsi %427 : i32 to i64
%428 = arith.addi %426, %429 : i64
llvm.store %428, %373 : i64, !llvm.ptr
cf.br ^bb60
^bb62:
%430 = arith.constant 0 : i32
%431 = arith.extsi %430 : i32 to i64
%432 = llvm.mlir.constant(1 : i64) : i64
%433 = llvm.alloca %432 x i64 : (i64) -> !llvm.ptr
llvm.store %431, %433 : i64, !llvm.ptr
cf.br ^bb75
^bb75:
%434 = llvm.load %433 : !llvm.ptr -> i64
%435 = llvm.load %370 : !llvm.ptr -> i64
%436 = arith.cmpi slt, %434, %435 : i64
cf.cond_br %436, ^bb76, ^bb77
^bb76:
%438 = llvm.load %433 : !llvm.ptr -> i64
%439 = llvm.getelementptr %351[%438] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%437 = llvm.load %439 : !llvm.ptr -> i64
%441 = llvm.getelementptr %329[%437] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%440 = llvm.load %441 : !llvm.ptr -> i64
%443 = llvm.getelementptr %323[%437] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%442 = llvm.load %443 : !llvm.ptr -> i64
%444 = arith.cmpi sgt, %440, %442 : i64
cf.cond_br %444, ^bb78, ^bb79
^bb78:
%446 = llvm.getelementptr %329[%437] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%445 = llvm.load %446 : !llvm.ptr -> i64
%447 = llvm.getelementptr %323[%437] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %445, %447 : i64, !llvm.ptr
cf.br ^bb80
^bb79:
cf.br ^bb80
^bb80:
%448 = arith.constant 1 : i32
%450 = arith.constant 0 : i32
%449 = arith.subi %450, %448 : i32
%451 = arith.extsi %449 : i32 to i64
%452 = llvm.getelementptr %329[%437] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %451, %452 : i64, !llvm.ptr
%453 = llvm.load %433 : !llvm.ptr -> i64
%454 = arith.constant 1 : i32
%456 = arith.extsi %454 : i32 to i64
%455 = arith.addi %453, %456 : i64
llvm.store %455, %433 : i64, !llvm.ptr
cf.br ^bb75
^bb77:
%457 = llvm.load %373 : !llvm.ptr -> i64
llvm.store %457, %360 : i64, !llvm.ptr
cf.br ^bb57
^bb59:
%458 = arith.constant 0 : i32
%459 = arith.extsi %458 : i32 to i64
%460 = llvm.mlir.constant(1 : i64) : i64
%461 = llvm.alloca %460 x i64 : (i64) -> !llvm.ptr
llvm.store %459, %461 : i64, !llvm.ptr
%462 = arith.constant 0 : i32
%463 = arith.extsi %462 : i32 to i64
%464 = llvm.mlir.constant(1 : i64) : i64
%465 = llvm.alloca %464 x i64 : (i64) -> !llvm.ptr
llvm.store %463, %465 : i64, !llvm.ptr
cf.br ^bb81
^bb81:
%466 = llvm.load %465 : !llvm.ptr -> i64
%467 = arith.cmpi sle, %466, %arg0 : i64
cf.cond_br %467, ^bb82, ^bb83
^bb82:
%469 = llvm.load %465 : !llvm.ptr -> i64
%470 = llvm.getelementptr %323[%469] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%468 = llvm.load %470 : !llvm.ptr -> i64
%471 = llvm.load %461 : !llvm.ptr -> i64
%472 = arith.cmpi sgt, %468, %471 : i64
cf.cond_br %472, ^bb84, ^bb85
^bb84:
%474 = llvm.load %465 : !llvm.ptr -> i64
%475 = llvm.getelementptr %323[%474] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%473 = llvm.load %475 : !llvm.ptr -> i64
llvm.store %473, %461 : i64, !llvm.ptr
cf.br ^bb86
^bb85:
cf.br ^bb86
^bb86:
%476 = llvm.load %465 : !llvm.ptr -> i64
%477 = arith.constant 1 : i32
%479 = arith.extsi %477 : i32 to i64
%478 = arith.addi %476, %479 : i64
llvm.store %478, %465 : i64, !llvm.ptr
cf.br ^bb81
^bb83:
func.call @free(%101) : (!llvm.ptr) -> ()
func.call @free(%129) : (!llvm.ptr) -> ()
func.call @free(%323) : (!llvm.ptr) -> ()
func.call @free(%329) : (!llvm.ptr) -> ()
func.call @free(%351) : (!llvm.ptr) -> ()
%485 = llvm.load %461 : !llvm.ptr -> i64
func.return %485 : i64
}
func.func @count_unreachable_pivot(%arg0: i64, %arg1: i64) -> i64 {
%486 = arith.constant 1 : i32
%487 = arith.extsi %486 : i32 to i64
%488 = llvm.mlir.constant(1 : i64) : i64
%489 = llvm.alloca %488 x i64 : (i64) -> !llvm.ptr
llvm.store %487, %489 : i64, !llvm.ptr
%490 = llvm.mlir.constant(1 : i64) : i64
%491 = llvm.alloca %490 x i64 : (i64) -> !llvm.ptr
llvm.store %arg0, %491 : i64, !llvm.ptr
cf.br ^bb87
^bb87:
%492 = llvm.load %491 : !llvm.ptr -> i64
%493 = arith.constant 1 : i32
%495 = arith.extsi %493 : i32 to i64
%494 = arith.cmpi sgt, %492, %495 : i64
cf.cond_br %494, ^bb88, ^bb89
^bb88:
%496 = llvm.load %491 : !llvm.ptr -> i64
%497 = arith.constant 2 : i32
%499 = arith.extsi %497 : i32 to i64
%498 = arith.divsi %496, %499 : i64
llvm.store %498, %491 : i64, !llvm.ptr
%500 = llvm.load %489 : !llvm.ptr -> i64
%501 = arith.constant 1 : i32
%503 = arith.extsi %501 : i32 to i64
%502 = arith.addi %500, %503 : i64
llvm.store %502, %489 : i64, !llvm.ptr
cf.br ^bb87
^bb89:
%505 = arith.constant 8 : i32
%506 = arith.constant 8 : i32
%507 = arith.extsi %505 : i32 to i64
%508 = arith.extsi %506 : i32 to i64
%504 = func.call @calloc(%507, %508) : (i64, i64) -> !llvm.ptr
%510 = arith.constant 8 : i32
%511 = arith.constant 8 : i32
%512 = arith.extsi %510 : i32 to i64
%513 = arith.extsi %511 : i32 to i64
%509 = func.call @calloc(%512, %513) : (i64, i64) -> !llvm.ptr
%514 = arith.constant 1 : i32
%515 = arith.constant 7 : i32
%516 = arith.extsi %514 : i32 to i64
%517 = arith.extsi %515 : i32 to i64
%518 = llvm.getelementptr %504[%517] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %516, %518 : i64, !llvm.ptr
%519 = llvm.load %489 : !llvm.ptr -> i64
%520 = arith.constant 1 : i32
%522 = arith.extsi %520 : i32 to i64
%521 = arith.subi %519, %522 : i64
%523 = llvm.mlir.constant(1 : i64) : i64
%524 = llvm.alloca %523 x i64 : (i64) -> !llvm.ptr
llvm.store %521, %524 : i64, !llvm.ptr
cf.br ^bb90
^bb90:
%525 = llvm.load %524 : !llvm.ptr -> i64
%526 = arith.constant 0 : i32
%528 = arith.extsi %526 : i32 to i64
%527 = arith.cmpi sge, %525, %528 : i64
cf.cond_br %527, ^bb91, ^bb92
^bb91:
%529 = arith.constant 0 : i32
%530 = arith.extsi %529 : i32 to i64
%531 = llvm.mlir.constant(1 : i64) : i64
%532 = llvm.alloca %531 x i64 : (i64) -> !llvm.ptr
llvm.store %530, %532 : i64, !llvm.ptr
cf.br ^bb93
^bb93:
%533 = llvm.load %532 : !llvm.ptr -> i64
%534 = arith.constant 8 : i32
%536 = arith.extsi %534 : i32 to i64
%535 = arith.cmpi slt, %533, %536 : i64
cf.cond_br %535, ^bb94, ^bb95
^bb94:
%537 = arith.constant 0 : i32
%538 = llvm.load %532 : !llvm.ptr -> i64
%539 = arith.extsi %537 : i32 to i64
%540 = llvm.getelementptr %509[%538] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %539, %540 : i64, !llvm.ptr
%541 = llvm.load %532 : !llvm.ptr -> i64
%542 = arith.constant 1 : i32
%544 = arith.extsi %542 : i32 to i64
%543 = arith.addi %541, %544 : i64
llvm.store %543, %532 : i64, !llvm.ptr
cf.br ^bb93
^bb95:
%545 = llvm.load %524 : !llvm.ptr -> i64
%546 = arith.shrsi %arg0, %545 : i64
%547 = arith.constant 1 : i32
%549 = arith.extsi %547 : i32 to i64
%548 = arith.andi %546, %549 : i64
%550 = arith.constant 0 : i32
%551 = arith.extsi %550 : i32 to i64
%552 = llvm.mlir.constant(1 : i64) : i64
%553 = llvm.alloca %552 x i64 : (i64) -> !llvm.ptr
llvm.store %551, %553 : i64, !llvm.ptr
cf.br ^bb96
^bb96:
%554 = llvm.load %553 : !llvm.ptr -> i64
%555 = arith.constant 8 : i32
%557 = arith.extsi %555 : i32 to i64
%556 = arith.cmpi slt, %554, %557 : i64
cf.cond_br %556, ^bb97, ^bb98
^bb97:
%559 = llvm.load %553 : !llvm.ptr -> i64
%560 = llvm.getelementptr %504[%559] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%558 = llvm.load %560 : !llvm.ptr -> i64
%561 = arith.constant 0 : i32
%563 = arith.extsi %561 : i32 to i64
%562 = arith.cmpi sgt, %558, %563 : i64
cf.cond_br %562, ^bb99, ^bb100
^bb99:
%564 = arith.constant 0 : i32
%565 = arith.extsi %564 : i32 to i64
%566 = llvm.mlir.constant(1 : i64) : i64
%567 = llvm.alloca %566 x i64 : (i64) -> !llvm.ptr
llvm.store %565, %567 : i64, !llvm.ptr
cf.br ^bb102
^bb102:
%568 = llvm.load %567 : !llvm.ptr -> i64
%569 = arith.constant 8 : i32
%571 = arith.extsi %569 : i32 to i64
%570 = arith.cmpi slt, %568, %571 : i64
cf.cond_br %570, ^bb103, ^bb104
^bb103:
%572 = arith.constant 0 : i32
%573 = llvm.mlir.constant(1 : i64) : i64
%574 = llvm.alloca %573 x i32 : (i64) -> !llvm.ptr
llvm.store %572, %574 : i32, !llvm.ptr
%575 = llvm.load %524 : !llvm.ptr -> i64
%576 = arith.cmpi sgt, %575, %arg1 : i64
cf.cond_br %576, ^bb105, ^bb106
^bb105:
%577 = llvm.load %567 : !llvm.ptr -> i64
%578 = arith.constant 0 : i32
%580 = arith.extsi %578 : i32 to i64
%579 = arith.cmpi eq, %577, %580 : i64
%581 = scf.if %579 -> (i1) {
%582 = arith.constant true
scf.yield %582 : i1
} else {
%583 = llvm.load %567 : !llvm.ptr -> i64
%584 = arith.constant 3 : i32
%586 = arith.extsi %584 : i32 to i64
%585 = arith.cmpi eq, %583, %586 : i64
scf.yield %585 : i1
}
%587 = scf.if %581 -> (i1) {
%588 = arith.constant true
scf.yield %588 : i1
} else {
%589 = llvm.load %567 : !llvm.ptr -> i64
%590 = arith.constant 5 : i32
%592 = arith.extsi %590 : i32 to i64
%591 = arith.cmpi eq, %589, %592 : i64
scf.yield %591 : i1
}
%593 = scf.if %587 -> (i1) {
%594 = arith.constant true
scf.yield %594 : i1
} else {
%595 = llvm.load %567 : !llvm.ptr -> i64
%596 = arith.constant 6 : i32
%598 = arith.extsi %596 : i32 to i64
%597 = arith.cmpi eq, %595, %598 : i64
scf.yield %597 : i1
}
cf.cond_br %593, ^bb108, ^bb109
^bb108:
%599 = arith.constant 1 : i32
llvm.store %599, %574 : i32, !llvm.ptr
cf.br ^bb110
^bb109:
cf.br ^bb110
^bb110:
cf.br ^bb107
^bb106:
%600 = llvm.load %524 : !llvm.ptr -> i64
%601 = arith.cmpi eq, %600, %arg1 : i64
cf.cond_br %601, ^bb111, ^bb112
^bb111:
%602 = llvm.load %567 : !llvm.ptr -> i64
%603 = arith.constant 7 : i32
%605 = arith.extsi %603 : i32 to i64
%604 = arith.cmpi eq, %602, %605 : i64
cf.cond_br %604, ^bb114, ^bb115
^bb114:
%606 = arith.constant 1 : i32
llvm.store %606, %574 : i32, !llvm.ptr
cf.br ^bb116
^bb115:
cf.br ^bb116
^bb116:
cf.br ^bb113
^bb112:
%607 = arith.constant 1 : i32
llvm.store %607, %574 : i32, !llvm.ptr
cf.br ^bb113
^bb113:
cf.br ^bb107
^bb107:
%608 = llvm.load %574 : !llvm.ptr -> i32
%609 = arith.constant 1 : i32
%610 = arith.cmpi eq, %608, %609 : i32
cf.cond_br %610, ^bb117, ^bb118
^bb117:
%611 = arith.constant 0 : i32
%612 = arith.extsi %611 : i32 to i64
%613 = llvm.mlir.constant(1 : i64) : i64
%614 = llvm.alloca %613 x i64 : (i64) -> !llvm.ptr
llvm.store %612, %614 : i64, !llvm.ptr
%615 = arith.constant 1 : i32
%616 = llvm.mlir.constant(1 : i64) : i64
%617 = llvm.alloca %616 x i32 : (i64) -> !llvm.ptr
llvm.store %615, %617 : i32, !llvm.ptr
%618 = arith.constant 0 : i32
%619 = arith.extsi %618 : i32 to i64
%620 = llvm.mlir.constant(1 : i64) : i64
%621 = llvm.alloca %620 x i64 : (i64) -> !llvm.ptr
llvm.store %619, %621 : i64, !llvm.ptr
cf.br ^bb120
^bb120:
%622 = llvm.load %621 : !llvm.ptr -> i64
%623 = arith.constant 3 : i32
%625 = arith.extsi %623 : i32 to i64
%624 = arith.cmpi slt, %622, %625 : i64
cf.cond_br %624, ^bb121, ^bb122
^bb121:
%626 = arith.constant 1 : i32
%627 = llvm.load %621 : !llvm.ptr -> i64
%629 = arith.extsi %626 : i32 to i64
%628 = arith.shli %629, %627 : i64
%630 = llvm.load %553 : !llvm.ptr -> i64
%631 = arith.andi %630, %628 : i64
%632 = arith.constant 0 : i32
%634 = arith.extsi %632 : i32 to i64
%633 = arith.cmpi ne, %631, %634 : i64
cf.cond_br %633, ^bb123, ^bb124
^bb123:
%635 = llvm.load %567 : !llvm.ptr -> i64
%636 = llvm.load %621 : !llvm.ptr -> i64
%637 = arith.shrsi %635, %636 : i64
%638 = arith.constant 1 : i32
%640 = arith.extsi %638 : i32 to i64
%639 = arith.andi %637, %640 : i64
%641 = arith.cmpi sgt, %639, %548 : i64
cf.cond_br %641, ^bb126, ^bb127
^bb126:
%642 = arith.constant 0 : i32
llvm.store %642, %617 : i32, !llvm.ptr
cf.br ^bb122
^bb127:
cf.br ^bb128
^bb128:
%643 = arith.cmpi eq, %639, %548 : i64
cf.cond_br %643, ^bb129, ^bb130
^bb129:
%644 = llvm.load %614 : !llvm.ptr -> i64
%645 = arith.ori %644, %628 : i64
llvm.store %645, %614 : i64, !llvm.ptr
cf.br ^bb131
^bb130:
cf.br ^bb131
^bb131:
cf.br ^bb125
^bb124:
cf.br ^bb125
^bb125:
%646 = llvm.load %621 : !llvm.ptr -> i64
%647 = arith.constant 1 : i32
%649 = arith.extsi %647 : i32 to i64
%648 = arith.addi %646, %649 : i64
llvm.store %648, %621 : i64, !llvm.ptr
cf.br ^bb120
^bb122:
%650 = llvm.load %617 : !llvm.ptr -> i32
%651 = arith.constant 1 : i32
%652 = arith.cmpi eq, %650, %651 : i32
cf.cond_br %652, ^bb132, ^bb133
^bb132:
%654 = llvm.load %614 : !llvm.ptr -> i64
%655 = llvm.getelementptr %509[%654] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%653 = llvm.load %655 : !llvm.ptr -> i64
%656 = arith.addi %653, %558 : i64
%657 = llvm.load %614 : !llvm.ptr -> i64
%658 = llvm.getelementptr %509[%657] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %656, %658 : i64, !llvm.ptr
cf.br ^bb134
^bb133:
cf.br ^bb134
^bb134:
cf.br ^bb119
^bb118:
cf.br ^bb119
^bb119:
%659 = llvm.load %567 : !llvm.ptr -> i64
%660 = arith.constant 1 : i32
%662 = arith.extsi %660 : i32 to i64
%661 = arith.addi %659, %662 : i64
llvm.store %661, %567 : i64, !llvm.ptr
cf.br ^bb102
^bb104:
cf.br ^bb101
^bb100:
cf.br ^bb101
^bb101:
%663 = llvm.load %553 : !llvm.ptr -> i64
%664 = arith.constant 1 : i32
%666 = arith.extsi %664 : i32 to i64
%665 = arith.addi %663, %666 : i64
llvm.store %665, %553 : i64, !llvm.ptr
cf.br ^bb96
^bb98:
%667 = arith.constant 0 : i32
%668 = arith.extsi %667 : i32 to i64
llvm.store %668, %532 : i64, !llvm.ptr
cf.br ^bb135
^bb135:
%669 = llvm.load %532 : !llvm.ptr -> i64
%670 = arith.constant 8 : i32
%672 = arith.extsi %670 : i32 to i64
%671 = arith.cmpi slt, %669, %672 : i64
cf.cond_br %671, ^bb136, ^bb137
^bb136:
%674 = llvm.load %532 : !llvm.ptr -> i64
%675 = llvm.getelementptr %509[%674] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%673 = llvm.load %675 : !llvm.ptr -> i64
%676 = llvm.load %532 : !llvm.ptr -> i64
%677 = llvm.getelementptr %504[%676] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %673, %677 : i64, !llvm.ptr
%678 = llvm.load %532 : !llvm.ptr -> i64
%679 = arith.constant 1 : i32
%681 = arith.extsi %679 : i32 to i64
%680 = arith.addi %678, %681 : i64
llvm.store %680, %532 : i64, !llvm.ptr
cf.br ^bb135
^bb137:
%682 = llvm.load %524 : !llvm.ptr -> i64
%683 = arith.constant 1 : i32
%685 = arith.extsi %683 : i32 to i64
%684 = arith.subi %682, %685 : i64
llvm.store %684, %524 : i64, !llvm.ptr
cf.br ^bb90
^bb92:
%686 = arith.constant 0 : i32
%687 = arith.extsi %686 : i32 to i64
%688 = llvm.mlir.constant(1 : i64) : i64
%689 = llvm.alloca %688 x i64 : (i64) -> !llvm.ptr
llvm.store %687, %689 : i64, !llvm.ptr
%690 = arith.constant 0 : i32
%691 = arith.extsi %690 : i32 to i64
%692 = llvm.mlir.constant(1 : i64) : i64
%693 = llvm.alloca %692 x i64 : (i64) -> !llvm.ptr
llvm.store %691, %693 : i64, !llvm.ptr
cf.br ^bb138
^bb138:
%694 = llvm.load %693 : !llvm.ptr -> i64
%695 = arith.constant 8 : i32
%697 = arith.extsi %695 : i32 to i64
%696 = arith.cmpi slt, %694, %697 : i64
cf.cond_br %696, ^bb139, ^bb140
^bb139:
%698 = llvm.load %689 : !llvm.ptr -> i64
%700 = llvm.load %693 : !llvm.ptr -> i64
%701 = llvm.getelementptr %504[%700] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%699 = llvm.load %701 : !llvm.ptr -> i64
%702 = arith.addi %698, %699 : i64
llvm.store %702, %689 : i64, !llvm.ptr
%703 = llvm.load %693 : !llvm.ptr -> i64
%704 = arith.constant 1 : i32
%706 = arith.extsi %704 : i32 to i64
%705 = arith.addi %703, %706 : i64
llvm.store %705, %693 : i64, !llvm.ptr
cf.br ^bb138
^bb140:
func.call @free(%504) : (!llvm.ptr) -> ()
func.call @free(%509) : (!llvm.ptr) -> ()
%709 = llvm.load %689 : !llvm.ptr -> i64
func.return %709 : i64
}
func.func @count_unreachable_nim(%arg0: i64) -> i64 {
%710 = arith.constant 0 : i32
%712 = arith.extsi %710 : i32 to i64
%711 = arith.cmpi sle, %arg0, %712 : i64
cf.cond_br %711, ^bb141, ^bb142
^bb141:
%713 = arith.constant 0 : i32
%714 = arith.extsi %713 : i32 to i64
func.return %714 : i64
^bb142:
cf.br ^bb143
^bb143:
%715 = arith.constant 1 : i32
%717 = arith.extsi %715 : i32 to i64
%716 = arith.subi %arg0, %717 : i64
%718 = arith.constant 1 : i32
%719 = arith.extsi %718 : i32 to i64
%720 = llvm.mlir.constant(1 : i64) : i64
%721 = llvm.alloca %720 x i64 : (i64) -> !llvm.ptr
llvm.store %719, %721 : i64, !llvm.ptr
%722 = llvm.mlir.constant(1 : i64) : i64
%723 = llvm.alloca %722 x i64 : (i64) -> !llvm.ptr
llvm.store %716, %723 : i64, !llvm.ptr
cf.br ^bb144
^bb144:
%724 = llvm.load %723 : !llvm.ptr -> i64
%725 = arith.constant 1 : i32
%727 = arith.extsi %725 : i32 to i64
%726 = arith.cmpi sgt, %724, %727 : i64
cf.cond_br %726, ^bb145, ^bb146
^bb145:
%728 = llvm.load %723 : !llvm.ptr -> i64
%729 = arith.constant 2 : i32
%731 = arith.extsi %729 : i32 to i64
%730 = arith.divsi %728, %731 : i64
llvm.store %730, %723 : i64, !llvm.ptr
%732 = llvm.load %721 : !llvm.ptr -> i64
%733 = arith.constant 1 : i32
%735 = arith.extsi %733 : i32 to i64
%734 = arith.addi %732, %735 : i64
llvm.store %734, %721 : i64, !llvm.ptr
cf.br ^bb144
^bb146:
%736 = arith.constant 0 : i32
%737 = arith.extsi %736 : i32 to i64
%738 = llvm.mlir.constant(1 : i64) : i64
%739 = llvm.alloca %738 x i64 : (i64) -> !llvm.ptr
llvm.store %737, %739 : i64, !llvm.ptr
%740 = arith.constant 0 : i32
%741 = arith.extsi %740 : i32 to i64
%742 = llvm.mlir.constant(1 : i64) : i64
%743 = llvm.alloca %742 x i64 : (i64) -> !llvm.ptr
llvm.store %741, %743 : i64, !llvm.ptr
cf.br ^bb147
^bb147:
%744 = llvm.load %743 : !llvm.ptr -> i64
%745 = llvm.load %721 : !llvm.ptr -> i64
%746 = arith.cmpi slt, %744, %745 : i64
cf.cond_br %746, ^bb148, ^bb149
^bb148:
%747 = llvm.load %739 : !llvm.ptr -> i64
%749 = llvm.load %743 : !llvm.ptr -> i64
%748 = func.call @count_unreachable_pivot(%716, %749) : (i64, i64) -> i64
%750 = arith.addi %747, %748 : i64
llvm.store %750, %739 : i64, !llvm.ptr
%751 = llvm.load %743 : !llvm.ptr -> i64
%752 = arith.constant 1 : i32
%754 = arith.extsi %752 : i32 to i64
%753 = arith.addi %751, %754 : i64
llvm.store %753, %743 : i64, !llvm.ptr
cf.br ^bb147
^bb149:
%755 = llvm.load %739 : !llvm.ptr -> i64
func.return %755 : i64
}
func.func @main() -> i32 {
%757 = arith.constant 1000 : i32
%758 = arith.extsi %757 : i32 to i64
%756 = func.call @max_and(%758) : (i64) -> i64
%759 = llvm.mlir.addressof @MOD : !llvm.ptr
%760 = llvm.load %759 : !llvm.ptr -> i64
%761 = arith.remsi %756, %760 : i64
%763 = arith.constant 1000 : i32
%764 = arith.extsi %763 : i32 to i64
%762 = func.call @max_xor_sum(%764) : (i64) -> i64
%765 = llvm.mlir.addressof @MOD : !llvm.ptr
%766 = llvm.load %765 : !llvm.ptr -> i64
%767 = arith.remsi %762, %766 : i64
%769 = arith.constant 1000 : i32
%770 = arith.extsi %769 : i32 to i64
%768 = func.call @count_unreachable_nim(%770) : (i64) -> i64
%771 = llvm.mlir.addressof @MOD : !llvm.ptr
%772 = llvm.load %771 : !llvm.ptr -> i64
%773 = arith.remsi %768, %772 : i64
%774 = llvm.mlir.constant(1 : i64) : i64
%775 = llvm.alloca %774 x i64 : (i64) -> !llvm.ptr
llvm.store %761, %775 : i64, !llvm.ptr
%776 = llvm.mlir.constant(1 : i64) : i64
%777 = llvm.alloca %776 x i64 : (i64) -> !llvm.ptr
llvm.store %767, %777 : i64, !llvm.ptr
%778 = llvm.mlir.constant(1 : i64) : i64
%779 = llvm.alloca %778 x i64 : (i64) -> !llvm.ptr
llvm.store %773, %779 : i64, !llvm.ptr
%780 = arith.constant 3 : i32
%781 = arith.extsi %780 : i32 to i64
%782 = llvm.mlir.constant(1 : i64) : i64
%783 = llvm.alloca %782 x i64 : (i64) -> !llvm.ptr
llvm.store %781, %783 : i64, !llvm.ptr
cf.br ^bb150
^bb150:
%784 = llvm.load %783 : !llvm.ptr -> i64
%785 = arith.constant 1000 : i32
%787 = arith.extsi %785 : i32 to i64
%786 = arith.cmpi sle, %784, %787 : i64
cf.cond_br %786, ^bb151, ^bb152
^bb151:
%788 = llvm.load %779 : !llvm.ptr -> i64
%789 = llvm.load %777 : !llvm.ptr -> i64
%790 = arith.muli %788, %789 : i64
%791 = llvm.mlir.addressof @MOD : !llvm.ptr
%792 = llvm.load %791 : !llvm.ptr -> i64
%793 = arith.remsi %790, %792 : i64
%794 = llvm.load %775 : !llvm.ptr -> i64
%795 = arith.muli %793, %794 : i64
%796 = llvm.mlir.addressof @MOD : !llvm.ptr
%797 = llvm.load %796 : !llvm.ptr -> i64
%798 = arith.remsi %795, %797 : i64
%799 = llvm.load %777 : !llvm.ptr -> i64
llvm.store %799, %775 : i64, !llvm.ptr
%800 = llvm.load %779 : !llvm.ptr -> i64
llvm.store %800, %777 : i64, !llvm.ptr
llvm.store %798, %779 : i64, !llvm.ptr
%801 = llvm.load %783 : !llvm.ptr -> i64
%802 = arith.constant 1 : i32
%804 = arith.extsi %802 : i32 to i64
%803 = arith.addi %801, %804 : i64
llvm.store %803, %783 : i64, !llvm.ptr
cf.br ^bb150
^bb152:
%805 = llvm.mlir.addressof @str_0 : !llvm.ptr
%806 = llvm.load %779 : !llvm.ptr -> i64
%807 = llvm.call @printf(%805, %806) vararg(!llvm.func<i32 (ptr, ...)>) : (!llvm.ptr, i64) -> i32
%808 = arith.constant 0 : i32
func.return %808 : i32
}
}