← All problems
Problem 847
Jack's Bean - H(R_19) mod 1e9+7. Ported from native C to pure Flow.
View problem on Project Euler
Performance comparison
Metric Our solution Best known
Time complexity O(n)?
Space complexity O(n)?
Approach Flow solution Not curated
Verdict Unknown
Flow source
# Project Euler 847
# Jack's Bean - H(R_19) mod 1e9+7.
# Ported from native C to pure Flow.
extern {
function calloc(n: i64, size: i64) -> ptr<void>
function free(p: ptr<void>) -> void
}
const MOD: i64 = 1000000007
const HT_CAP: i64 = 4096
let mut INV2: i64 = 0
let mut INV6: i64 = 0
let mut ht_keys: ptr<i64> = null
let mut ht_vals: ptr<i64> = null
let mut ht_used: ptr<i8> = null
function modpow(base: i64, exp: i64, mod: i64) -> i64 {
let mut r: i64 = 1
let mut b: i64 = base % mod
if b < 0 { b = b + mod }
let mut e: i64 = exp
while e > 0 {
if (e & 1) == 1 {
r = (((r as i128) * (b as i128)) % (mod as i128)) as i64
}
b = (((b as i128) * (b as i128)) % (mod as i128)) as i64
e = e >> 1
}
return r
}
function floor_log2(x: i64) -> i32 {
let mut n: i32 = 0
let mut v: i64 = x
while v > 1 {
v = v >> 1
n = n + 1
}
return n
}
function pow2k(k: i32) -> i64 {
let mut r: i64 = 1
let mut i: i32 = 0
while i < k {
r = r * 2
i = i + 1
}
return r
}
function repunit(n: i32) -> i64 {
let mut r: i64 = 0
let mut i: i32 = 0
while i < n {
r = r * 10 + 1
i = i + 1
}
return r
}
function sum_1(n: i64) -> i64 {
if n <= 0 { return 0 }
let a: i64 = n % MOD
let b: i64 = (n + 1) % MOD
let t: i128 = ((a as i128) * (b as i128)) % (MOD as i128)
return ((t * (INV2 as i128)) % (MOD as i128)) as i64
}
function sum_2(n: i64) -> i64 {
if n <= 0 { return 0 }
let a: i64 = n % MOD
let b: i64 = (n + 1) % MOD
let c: i64 = (2 * n + 1) % MOD
let t1: i128 = ((a as i128) * (b as i128)) % (MOD as i128)
let t2: i128 = (t1 * (c as i128)) % (MOD as i128)
return ((t2 * (INV6 as i128)) % (MOD as i128)) as i64
}
function range_sum_1(l: i64, r: i64) -> i64 {
if l > r { return 0 }
let s: i64 = sum_1(r) - sum_1(l - 1)
return (s % MOD + MOD) % MOD
}
function range_sum_2(l: i64, r: i64) -> i64 {
if l > r { return 0 }
let s: i64 = sum_2(r) - sum_2(l - 1)
return (s % MOD + MOD) % MOD
}
function sum_triples_count(l: i64, r: i64) -> i64 {
if l > r { return 0 }
let cnt: i64 = (r - l + 1) % MOD
let s1: i64 = range_sum_1(l, r)
let s2: i64 = range_sum_2(l, r)
let total: i64 = (s2 + (3 * s1) % MOD + (2 * cnt) % MOD) % MOD
return (((total as i128) * (INV2 as i128)) % (MOD as i128)) as i64
}
function threshold_t(k: i32) -> i64 {
if k < 3 { return 1000000000000000000 }
return 3 * pow2k(k - 2) + 2
}
function base_bad_for_block(M: i64, L: i64) -> i64 {
if L < (M >> 1) + 2 { return 0 }
let n: i64 = 2 * L - M - 1
return n * (n - 1) / 2
}
function bad_count_for_sum(s: i64) -> i64 {
if s <= 7 { return 0 }
let k: i32 = floor_log2(s - 1)
let M: i64 = pow2k(k)
let L: i64 = s - M
let res: i64 = base_bad_for_block(M, L)
if k >= 3 {
let t: i64 = threshold_t(k)
if L >= t {
res = res + 3 * bad_count_for_sum(L)
}
}
return res
}
function ht_hash(key: i64) -> i64 {
let mut h: i64 = key ^ (key >> 32)
if h < 0 { h = 0 - h }
return h % HT_CAP
}
function ht_lookup(key: i64) -> i64 {
let mut h: i64 = ht_hash(key)
while ht_used[h] != 0 {
if ht_keys[h] == key { return ht_vals[h] }
h = (h + 1) % HT_CAP
}
return -1
}
function ht_insert(key: i64, val: i64) -> void {
let mut h: i64 = ht_hash(key)
while ht_used[h] != 0 {
if ht_keys[h] == key {
ht_vals[h] = val
return
}
h = (h + 1) % HT_CAP
}
ht_used[h] = 1
ht_keys[h] = key
ht_vals[h] = val
}
function sum_base_bad_block_mod(M: i64, R: i64) -> i64 {
if R <= 0 { return 0 }
let start: i64 = (M >> 1) + 2
if R < start { return 0 }
let a: i64 = start
let b: i64 = R
let cnt: i64 = (b - a + 1) % MOD
let sumL: i64 = range_sum_1(a, b)
let sumL2: i64 = range_sum_2(a, b)
let m1: i64 = (M + 1) % MOD
let m2: i64 = (M + 2) % MOD
let cv: i128 = ((m1 as i128) * (m2 as i128)) % (MOD as i128)
let const_val: i64 = ((cv * (INV2 as i128)) % (MOD as i128)) as i64
let m3: i64 = (2 * M + 3) % MOD
let term1: i64 = (2 * sumL2) % MOD
let term2: i64 = (((m3 as i128) * (sumL as i128)) % (MOD as i128)) as i64
let term3: i64 = (((const_val as i128) * (cnt as i128)) % (MOD as i128)) as i64
let res: i64 = (term1 - term2 + term3) % MOD
return (res % MOD + MOD) % MOD
}
function block_bad_sum_mod(M: i64, R: i64) -> i64 {
if R <= 0 { return 0 }
let k: i32 = floor_log2(M)
let res: i64 = sum_base_bad_block_mod(M, R)
let t: i64 = threshold_t(k)
if t <= R {
let diff: i64 = (bad_prefix_sum_mod(R) - bad_prefix_sum_mod(t - 1)) % MOD
res = (res + (3 * diff) % MOD) % MOD
}
return (res % MOD + MOD) % MOD
}
function bad_prefix_sum_mod(N: i64) -> i64 {
if N <= 0 { return 0 }
if N <= 16 {
let mut total: i64 = 0
let mut s: i64 = 1
while s <= N {
total = total + bad_count_for_sum(s)
s = s + 1
}
return total % MOD
}
let cached: i64 = ht_lookup(N)
if cached >= 0 { return cached }
let pw: i64 = pow2k(floor_log2(N))
let result: i64 = 0
if N == pw {
if pw == 1 {
result = 0
} else {
let M: i64 = pw >> 1
result = (bad_prefix_sum_mod(M) + block_bad_sum_mod(M, M)) % MOD
}
} else {
result = (bad_prefix_sum_mod(pw) + block_bad_sum_mod(pw, N - pw)) % MOD
}
ht_insert(N, result)
return result
}
function base_part_mod(N: i64) -> i64 {
if N <= 0 { return 0 }
let mut res: i64 = 0
let mut m: i64 = 1
let mut low: i64 = 2
while low <= N {
let mut high: i64 = pow2k(m as i32)
if high > N { high = N }
let stc: i64 = sum_triples_count(low, high)
let term: i64 = (((m as i128) * (stc as i128)) % (MOD as i128)) as i64
res = (res + term) % MOD
m = m + 1
low = pow2k((m - 1) as i32) + 1
}
return res
}
function H_mod(N: i64) -> i64 {
return (base_part_mod(N) + bad_prefix_sum_mod(N)) % MOD
}
function main() -> i32 {
INV2 = (MOD + 1) / 2
INV6 = modpow(6, MOD - 2, MOD)
ht_keys = calloc(HT_CAP, 8) as ptr<i64>
ht_vals = calloc(HT_CAP, 8) as ptr<i64>
ht_used = calloc(HT_CAP, 1) as ptr<i8>
let n: i64 = repunit(19)
printf("%lld\n", H_mod(n))
free(ht_keys)
free(ht_vals)
free(ht_used)
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 modpow_i64_i64_i64(int64_t base, int64_t exp, int64_t mod);
int32_t floor_log2_i64(int64_t x);
int64_t pow2k_i32(int32_t k);
int64_t repunit_i32(int32_t n);
int64_t sum_1_i64(int64_t n);
int64_t sum_2_i64(int64_t n);
int64_t range_sum_1_i64_i64(int64_t l, int64_t r);
int64_t range_sum_2_i64_i64(int64_t l, int64_t r);
int64_t sum_triples_count_i64_i64(int64_t l, int64_t r);
int64_t threshold_t_i32(int32_t k);
int64_t base_bad_for_block_i64_i64(int64_t M, int64_t L);
int64_t bad_count_for_sum_i64(int64_t s);
int64_t ht_hash_i64(int64_t key);
int64_t ht_lookup_i64(int64_t key);
void ht_insert_i64_i64(int64_t key, int64_t val);
int64_t sum_base_bad_block_mod_i64_i64(int64_t M, int64_t R);
int64_t block_bad_sum_mod_i64_i64(int64_t M, int64_t R);
int64_t bad_prefix_sum_mod_i64(int64_t N);
int64_t base_part_mod_i64(int64_t N);
int64_t H_mod_i64(int64_t N);
int32_t main(void);
static const int64_t MOD = 1000000007;
static const int64_t HT_CAP = 4096;
/* Module statics */
static int64_t INV2 = 0;
static int64_t INV6 = 0;
static int64_t* ht_keys = NULL;
static int64_t* ht_vals = NULL;
static int8_t* ht_used = NULL;
int64_t modpow_i64_i64_i64(int64_t base, int64_t exp, int64_t mod) {
int64_t r = 1;
int64_t b = FLOW_CHECKED_MOD((base), (mod));
if (b < 0) {
b = (b + mod);
}
int64_t e = exp;
while (e > 0) {
if ((e & 1) == 1) {
r = ((int64_t)(FLOW_CHECKED_MOD(((((__int128)(r)) * ((__int128)(b)))), (((__int128)(mod))))));
}
b = ((int64_t)(FLOW_CHECKED_MOD(((((__int128)(b)) * ((__int128)(b)))), (((__int128)(mod))))));
e = FLOW_CHECKED_SHR((e), (1));
}
return r;
}
int32_t floor_log2_i64(int64_t x) {
int32_t n = 0;
int64_t v = x;
while (v > 1) {
v = FLOW_CHECKED_SHR((v), (1));
n = (n + 1);
}
return n;
}
int64_t pow2k_i32(int32_t k) {
int64_t r = 1;
int32_t i = 0;
while (i < k) {
r = (r * 2);
i = (i + 1);
}
return r;
}
int64_t repunit_i32(int32_t n) {
int64_t r = 0;
int32_t i = 0;
while (i < n) {
r = ((r * 10) + 1);
i = (i + 1);
}
return r;
}
int64_t sum_1_i64(int64_t n) {
if (n <= 0) {
return 0;
}
int64_t a = FLOW_CHECKED_MOD((n), (MOD));
int64_t b = FLOW_CHECKED_MOD(((n + 1)), (MOD));
__int128 t = FLOW_CHECKED_MOD(((((__int128)(a)) * ((__int128)(b)))), (((__int128)(MOD))));
return ((int64_t)(FLOW_CHECKED_MOD(((t * ((__int128)(INV2)))), (((__int128)(MOD))))));
}
int64_t sum_2_i64(int64_t n) {
if (n <= 0) {
return 0;
}
int64_t a = FLOW_CHECKED_MOD((n), (MOD));
int64_t b = FLOW_CHECKED_MOD(((n + 1)), (MOD));
int64_t c = FLOW_CHECKED_MOD((((2 * n) + 1)), (MOD));
__int128 t1 = FLOW_CHECKED_MOD(((((__int128)(a)) * ((__int128)(b)))), (((__int128)(MOD))));
__int128 t2 = FLOW_CHECKED_MOD(((t1 * ((__int128)(c)))), (((__int128)(MOD))));
return ((int64_t)(FLOW_CHECKED_MOD(((t2 * ((__int128)(INV6)))), (((__int128)(MOD))))));
}
int64_t range_sum_1_i64_i64(int64_t l, int64_t r) {
if (l > r) {
return 0;
}
int64_t s = (sum_1_i64(r) - sum_1_i64((l - 1)));
return FLOW_CHECKED_MOD(((FLOW_CHECKED_MOD((s), (MOD)) + MOD)), (MOD));
}
int64_t range_sum_2_i64_i64(int64_t l, int64_t r) {
if (l > r) {
return 0;
}
int64_t s = (sum_2_i64(r) - sum_2_i64((l - 1)));
return FLOW_CHECKED_MOD(((FLOW_CHECKED_MOD((s), (MOD)) + MOD)), (MOD));
}
int64_t sum_triples_count_i64_i64(int64_t l, int64_t r) {
if (l > r) {
return 0;
}
int64_t cnt = FLOW_CHECKED_MOD((((r - l) + 1)), (MOD));
int64_t s1 = range_sum_1_i64_i64(l, r);
int64_t s2 = range_sum_2_i64_i64(l, r);
int64_t total = FLOW_CHECKED_MOD((((s2 + FLOW_CHECKED_MOD(((3 * s1)), (MOD))) + FLOW_CHECKED_MOD(((2 * cnt)), (MOD)))), (MOD));
return ((int64_t)(FLOW_CHECKED_MOD(((((__int128)(total)) * ((__int128)(INV2)))), (((__int128)(MOD))))));
}
int64_t threshold_t_i32(int32_t k) {
if (k < 3) {
return 1000000000000000000;
}
return ((3 * pow2k_i32((k - 2))) + 2);
}
int64_t base_bad_for_block_i64_i64(int64_t M, int64_t L) {
if (L < (FLOW_CHECKED_SHR((M), (1)) + 2)) {
return 0;
}
int64_t n = (((2 * L) - M) - 1);
return FLOW_CHECKED_DIV(((n * (n - 1))), (2));
}
int64_t bad_count_for_sum_i64(int64_t s) {
if (s <= 7) {
return 0;
}
int32_t k = floor_log2_i64((s - 1));
int64_t M = pow2k_i32(k);
int64_t L = (s - M);
int64_t res = base_bad_for_block_i64_i64(M, L);
if (k >= 3) {
int64_t t = threshold_t_i32(k);
if (L >= t) {
res = (res + (3 * bad_count_for_sum_i64(L)));
}
}
return res;
}
int64_t ht_hash_i64(int64_t key) {
int64_t h = (key ^ FLOW_CHECKED_SHR((key), (32)));
if (h < 0) {
h = (0 - h);
}
return FLOW_CHECKED_MOD((h), (HT_CAP));
}
int64_t ht_lookup_i64(int64_t key) {
int64_t h = ht_hash_i64(key);
while (ht_used[h] != 0) {
if (ht_keys[h] == key) {
return ht_vals[h];
}
h = FLOW_CHECKED_MOD(((h + 1)), (HT_CAP));
}
return (-1);
}
void ht_insert_i64_i64(int64_t key, int64_t val) {
int64_t h = ht_hash_i64(key);
while (ht_used[h] != 0) {
if (ht_keys[h] == key) {
ht_vals[h] = val;
return;
}
h = FLOW_CHECKED_MOD(((h + 1)), (HT_CAP));
}
ht_used[h] = 1;
ht_keys[h] = key;
ht_vals[h] = val;
}
int64_t sum_base_bad_block_mod_i64_i64(int64_t M, int64_t R) {
if (R <= 0) {
return 0;
}
int64_t start = (FLOW_CHECKED_SHR((M), (1)) + 2);
if (R < start) {
return 0;
}
int64_t a = start;
int64_t b = R;
int64_t cnt = FLOW_CHECKED_MOD((((b - a) + 1)), (MOD));
int64_t sumL = range_sum_1_i64_i64(a, b);
int64_t sumL2 = range_sum_2_i64_i64(a, b);
int64_t m1 = FLOW_CHECKED_MOD(((M + 1)), (MOD));
int64_t m2 = FLOW_CHECKED_MOD(((M + 2)), (MOD));
__int128 cv = FLOW_CHECKED_MOD(((((__int128)(m1)) * ((__int128)(m2)))), (((__int128)(MOD))));
int64_t const_val = ((int64_t)(FLOW_CHECKED_MOD(((cv * ((__int128)(INV2)))), (((__int128)(MOD))))));
int64_t m3 = FLOW_CHECKED_MOD((((2 * M) + 3)), (MOD));
int64_t term1 = FLOW_CHECKED_MOD(((2 * sumL2)), (MOD));
int64_t term2 = ((int64_t)(FLOW_CHECKED_MOD(((((__int128)(m3)) * ((__int128)(sumL)))), (((__int128)(MOD))))));
int64_t term3 = ((int64_t)(FLOW_CHECKED_MOD(((((__int128)(const_val)) * ((__int128)(cnt)))), (((__int128)(MOD))))));
int64_t res = FLOW_CHECKED_MOD((((term1 - term2) + term3)), (MOD));
return FLOW_CHECKED_MOD(((FLOW_CHECKED_MOD((res), (MOD)) + MOD)), (MOD));
}
int64_t block_bad_sum_mod_i64_i64(int64_t M, int64_t R) {
if (R <= 0) {
return 0;
}
int32_t k = floor_log2_i64(M);
int64_t res = sum_base_bad_block_mod_i64_i64(M, R);
int64_t t = threshold_t_i32(k);
if (t <= R) {
int64_t diff = FLOW_CHECKED_MOD(((bad_prefix_sum_mod_i64(R) - bad_prefix_sum_mod_i64((t - 1)))), (MOD));
res = FLOW_CHECKED_MOD(((res + FLOW_CHECKED_MOD(((3 * diff)), (MOD)))), (MOD));
}
return FLOW_CHECKED_MOD(((FLOW_CHECKED_MOD((res), (MOD)) + MOD)), (MOD));
}
int64_t bad_prefix_sum_mod_i64(int64_t N) {
if (N <= 0) {
return 0;
}
if (N <= 16) {
int64_t total = 0;
int64_t s = 1;
while (s <= N) {
total = (total + bad_count_for_sum_i64(s));
s = (s + 1);
}
return FLOW_CHECKED_MOD((total), (MOD));
}
int64_t cached = ht_lookup_i64(N);
if (cached >= 0) {
return cached;
}
int64_t pw = pow2k_i32(floor_log2_i64(N));
int64_t result = 0;
if (N == pw) {
if (pw == 1) {
result = 0;
} else {
int64_t M = FLOW_CHECKED_SHR((pw), (1));
result = FLOW_CHECKED_MOD(((bad_prefix_sum_mod_i64(M) + block_bad_sum_mod_i64_i64(M, M))), (MOD));
}
} else {
result = FLOW_CHECKED_MOD(((bad_prefix_sum_mod_i64(pw) + block_bad_sum_mod_i64_i64(pw, (N - pw)))), (MOD));
}
ht_insert_i64_i64(N, result);
return result;
}
int64_t base_part_mod_i64(int64_t N) {
if (N <= 0) {
return 0;
}
int64_t res = 0;
int64_t m = 1;
int64_t low = 2;
while (low <= N) {
int64_t high = pow2k_i32(((int32_t)(m)));
if (high > N) {
high = N;
}
int64_t stc = sum_triples_count_i64_i64(low, high);
int64_t term = ((int64_t)(FLOW_CHECKED_MOD(((((__int128)(m)) * ((__int128)(stc)))), (((__int128)(MOD))))));
res = FLOW_CHECKED_MOD(((res + term)), (MOD));
m = (m + 1);
low = (pow2k_i32(((int32_t)((m - 1)))) + 1);
}
return res;
}
int64_t H_mod_i64(int64_t N) {
return FLOW_CHECKED_MOD(((base_part_mod_i64(N) + bad_prefix_sum_mod_i64(N))), (MOD));
}
int32_t main(void) {
INV2 = FLOW_CHECKED_DIV(((MOD + 1)), (2));
INV6 = modpow_i64_i64_i64(6, (MOD - 2), MOD);
ht_keys = ((int64_t*)(calloc(HT_CAP, 8)));
ht_vals = ((int64_t*)(calloc(HT_CAP, 8)));
ht_used = ((int8_t*)(calloc(HT_CAP, 1)));
int64_t n = repunit_i32(19);
printf("%lld\n", H_mod_i64(n));
free(ht_keys);
free(ht_vals);
free(ht_used);
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
// Constant: HT_CAP
llvm.mlir.global internal constant @HT_CAP(4096 : i64) : i64
// Module static: INV2
llvm.mlir.global internal @INV2(0 : i64) : i64
// Module static: INV6
llvm.mlir.global internal @INV6(0 : i64) : i64
// Module static: ht_keys
llvm.mlir.global internal @ht_keys() {addr_space = 0 : i32} : !llvm.ptr {
%0 = llvm.mlir.zero : !llvm.ptr
llvm.return %0 : !llvm.ptr
}
// Module static: ht_vals
llvm.mlir.global internal @ht_vals() {addr_space = 0 : i32} : !llvm.ptr {
%1 = llvm.mlir.zero : !llvm.ptr
llvm.return %1 : !llvm.ptr
}
// Module static: ht_used
llvm.mlir.global internal @ht_used() {addr_space = 0 : i32} : !llvm.ptr {
%2 = llvm.mlir.zero : !llvm.ptr
llvm.return %2 : !llvm.ptr
}
func.func @modpow(%arg0: i64, %arg1: i64, %arg2: i64) -> i64 {
%3 = arith.constant 1 : i32
%4 = arith.extsi %3 : i32 to i64
%5 = llvm.mlir.constant(1 : i64) : i64
%6 = llvm.alloca %5 x i64 : (i64) -> !llvm.ptr
llvm.store %4, %6 : i64, !llvm.ptr
%7 = arith.remsi %arg0, %arg2 : i64
%8 = llvm.mlir.constant(1 : i64) : i64
%9 = llvm.alloca %8 x i64 : (i64) -> !llvm.ptr
llvm.store %7, %9 : i64, !llvm.ptr
%10 = llvm.load %9 : !llvm.ptr -> i64
%11 = arith.constant 0 : i32
%13 = arith.extsi %11 : i32 to i64
%12 = arith.cmpi slt, %10, %13 : i64
cf.cond_br %12, ^bb0, ^bb1
^bb0:
%14 = llvm.load %9 : !llvm.ptr -> i64
%15 = arith.addi %14, %arg2 : i64
llvm.store %15, %9 : i64, !llvm.ptr
cf.br ^bb2
^bb1:
cf.br ^bb2
^bb2:
%16 = llvm.mlir.constant(1 : i64) : i64
%17 = llvm.alloca %16 x i64 : (i64) -> !llvm.ptr
llvm.store %arg1, %17 : i64, !llvm.ptr
cf.br ^bb3
^bb3:
%18 = llvm.load %17 : !llvm.ptr -> i64
%19 = arith.constant 0 : i32
%21 = arith.extsi %19 : i32 to i64
%20 = arith.cmpi sgt, %18, %21 : i64
cf.cond_br %20, ^bb4, ^bb5
^bb4:
%22 = llvm.load %17 : !llvm.ptr -> i64
%23 = arith.constant 1 : i32
%25 = arith.extsi %23 : i32 to i64
%24 = arith.andi %22, %25 : i64
%26 = arith.constant 1 : i32
%28 = arith.extsi %26 : i32 to i64
%27 = arith.cmpi eq, %24, %28 : i64
cf.cond_br %27, ^bb6, ^bb7
^bb6:
%29 = llvm.load %6 : !llvm.ptr -> i64
%30 = arith.extsi %29 : i64 to i128
%31 = llvm.load %9 : !llvm.ptr -> i64
%32 = arith.extsi %31 : i64 to i128
%34 = arith.trunci %30 : i128 to i64
%35 = arith.trunci %32 : i128 to i64
%33 = arith.muli %34, %35 : i64
%36 = arith.extsi %arg2 : i64 to i128
%38 = arith.trunci %36 : i128 to i64
%37 = arith.remsi %33, %38 : i64
llvm.store %37, %6 : i64, !llvm.ptr
cf.br ^bb8
^bb7:
cf.br ^bb8
^bb8:
%39 = llvm.load %9 : !llvm.ptr -> i64
%40 = arith.extsi %39 : i64 to i128
%41 = llvm.load %9 : !llvm.ptr -> i64
%42 = arith.extsi %41 : i64 to i128
%44 = arith.trunci %40 : i128 to i64
%45 = arith.trunci %42 : i128 to i64
%43 = arith.muli %44, %45 : i64
%46 = arith.extsi %arg2 : i64 to i128
%48 = arith.trunci %46 : i128 to i64
%47 = arith.remsi %43, %48 : i64
llvm.store %47, %9 : i64, !llvm.ptr
%49 = llvm.load %17 : !llvm.ptr -> i64
%50 = arith.constant 1 : i32
%52 = arith.extsi %50 : i32 to i64
%51 = arith.shrsi %49, %52 : i64
llvm.store %51, %17 : i64, !llvm.ptr
cf.br ^bb3
^bb5:
%53 = llvm.load %6 : !llvm.ptr -> i64
func.return %53 : i64
}
func.func @floor_log2(%arg0: i64) -> i32 {
%54 = arith.constant 0 : i32
%55 = llvm.mlir.constant(1 : i64) : i64
%56 = llvm.alloca %55 x i32 : (i64) -> !llvm.ptr
llvm.store %54, %56 : i32, !llvm.ptr
%57 = llvm.mlir.constant(1 : i64) : i64
%58 = llvm.alloca %57 x i64 : (i64) -> !llvm.ptr
llvm.store %arg0, %58 : i64, !llvm.ptr
cf.br ^bb9
^bb9:
%59 = llvm.load %58 : !llvm.ptr -> i64
%60 = arith.constant 1 : i32
%62 = arith.extsi %60 : i32 to i64
%61 = arith.cmpi sgt, %59, %62 : i64
cf.cond_br %61, ^bb10, ^bb11
^bb10:
%63 = llvm.load %58 : !llvm.ptr -> i64
%64 = arith.constant 1 : i32
%66 = arith.extsi %64 : i32 to i64
%65 = arith.shrsi %63, %66 : i64
llvm.store %65, %58 : i64, !llvm.ptr
%67 = llvm.load %56 : !llvm.ptr -> i32
%68 = arith.constant 1 : i32
%69 = arith.addi %67, %68 : i32
llvm.store %69, %56 : i32, !llvm.ptr
cf.br ^bb9
^bb11:
%70 = llvm.load %56 : !llvm.ptr -> i32
func.return %70 : i32
}
func.func @pow2k(%arg0: i32) -> i64 {
%71 = arith.constant 1 : i32
%72 = arith.extsi %71 : i32 to i64
%73 = llvm.mlir.constant(1 : i64) : i64
%74 = llvm.alloca %73 x i64 : (i64) -> !llvm.ptr
llvm.store %72, %74 : i64, !llvm.ptr
%75 = arith.constant 0 : i32
%76 = llvm.mlir.constant(1 : i64) : i64
%77 = llvm.alloca %76 x i32 : (i64) -> !llvm.ptr
llvm.store %75, %77 : i32, !llvm.ptr
cf.br ^bb12
^bb12:
%78 = llvm.load %77 : !llvm.ptr -> i32
%79 = arith.cmpi slt, %78, %arg0 : i32
cf.cond_br %79, ^bb13, ^bb14
^bb13:
%80 = llvm.load %74 : !llvm.ptr -> i64
%81 = arith.constant 2 : i32
%83 = arith.extsi %81 : i32 to i64
%82 = arith.muli %80, %83 : i64
llvm.store %82, %74 : i64, !llvm.ptr
%84 = llvm.load %77 : !llvm.ptr -> i32
%85 = arith.constant 1 : i32
%86 = arith.addi %84, %85 : i32
llvm.store %86, %77 : i32, !llvm.ptr
cf.br ^bb12
^bb14:
%87 = llvm.load %74 : !llvm.ptr -> i64
func.return %87 : i64
}
func.func @repunit(%arg0: i32) -> i64 {
%88 = arith.constant 0 : i32
%89 = arith.extsi %88 : i32 to i64
%90 = llvm.mlir.constant(1 : i64) : i64
%91 = llvm.alloca %90 x i64 : (i64) -> !llvm.ptr
llvm.store %89, %91 : i64, !llvm.ptr
%92 = arith.constant 0 : i32
%93 = llvm.mlir.constant(1 : i64) : i64
%94 = llvm.alloca %93 x i32 : (i64) -> !llvm.ptr
llvm.store %92, %94 : i32, !llvm.ptr
cf.br ^bb15
^bb15:
%95 = llvm.load %94 : !llvm.ptr -> i32
%96 = arith.cmpi slt, %95, %arg0 : i32
cf.cond_br %96, ^bb16, ^bb17
^bb16:
%97 = llvm.load %91 : !llvm.ptr -> i64
%98 = arith.constant 10 : i32
%100 = arith.extsi %98 : i32 to i64
%99 = arith.muli %97, %100 : i64
%101 = arith.constant 1 : i32
%103 = arith.extsi %101 : i32 to i64
%102 = arith.addi %99, %103 : i64
llvm.store %102, %91 : i64, !llvm.ptr
%104 = llvm.load %94 : !llvm.ptr -> i32
%105 = arith.constant 1 : i32
%106 = arith.addi %104, %105 : i32
llvm.store %106, %94 : i32, !llvm.ptr
cf.br ^bb15
^bb17:
%107 = llvm.load %91 : !llvm.ptr -> i64
func.return %107 : i64
}
func.func @sum_1(%arg0: i64) -> i64 {
%108 = arith.constant 0 : i32
%110 = arith.extsi %108 : i32 to i64
%109 = arith.cmpi sle, %arg0, %110 : i64
cf.cond_br %109, ^bb18, ^bb19
^bb18:
%111 = arith.constant 0 : i32
%112 = arith.extsi %111 : i32 to i64
func.return %112 : i64
^bb19:
cf.br ^bb20
^bb20:
%113 = llvm.mlir.addressof @MOD : !llvm.ptr
%114 = llvm.load %113 : !llvm.ptr -> i64
%115 = arith.remsi %arg0, %114 : i64
%116 = arith.constant 1 : i32
%118 = arith.extsi %116 : i32 to i64
%117 = arith.addi %arg0, %118 : i64
%119 = llvm.mlir.addressof @MOD : !llvm.ptr
%120 = llvm.load %119 : !llvm.ptr -> i64
%121 = arith.remsi %117, %120 : i64
%122 = arith.extsi %115 : i64 to i128
%123 = arith.extsi %121 : i64 to i128
%125 = arith.trunci %122 : i128 to i64
%126 = arith.trunci %123 : i128 to i64
%124 = arith.muli %125, %126 : i64
%127 = llvm.mlir.addressof @MOD : !llvm.ptr
%128 = llvm.load %127 : !llvm.ptr -> i64
%129 = arith.extsi %128 : i64 to i128
%131 = arith.trunci %129 : i128 to i64
%130 = arith.remsi %124, %131 : i64
%132 = arith.extsi %130 : i64 to i128
%133 = llvm.mlir.addressof @INV2 : !llvm.ptr
%134 = llvm.load %133 : !llvm.ptr -> i64
%135 = arith.extsi %134 : i64 to i128
%137 = arith.trunci %132 : i128 to i64
%138 = arith.trunci %135 : i128 to i64
%136 = arith.muli %137, %138 : i64
%139 = llvm.mlir.addressof @MOD : !llvm.ptr
%140 = llvm.load %139 : !llvm.ptr -> i64
%141 = arith.extsi %140 : i64 to i128
%143 = arith.trunci %141 : i128 to i64
%142 = arith.remsi %136, %143 : i64
func.return %142 : i64
}
func.func @sum_2(%arg0: i64) -> i64 {
%144 = arith.constant 0 : i32
%146 = arith.extsi %144 : i32 to i64
%145 = arith.cmpi sle, %arg0, %146 : i64
cf.cond_br %145, ^bb21, ^bb22
^bb21:
%147 = arith.constant 0 : i32
%148 = arith.extsi %147 : i32 to i64
func.return %148 : i64
^bb22:
cf.br ^bb23
^bb23:
%149 = llvm.mlir.addressof @MOD : !llvm.ptr
%150 = llvm.load %149 : !llvm.ptr -> i64
%151 = arith.remsi %arg0, %150 : i64
%152 = arith.constant 1 : i32
%154 = arith.extsi %152 : i32 to i64
%153 = arith.addi %arg0, %154 : i64
%155 = llvm.mlir.addressof @MOD : !llvm.ptr
%156 = llvm.load %155 : !llvm.ptr -> i64
%157 = arith.remsi %153, %156 : i64
%158 = arith.constant 2 : i32
%160 = arith.extsi %158 : i32 to i64
%159 = arith.muli %160, %arg0 : i64
%161 = arith.constant 1 : i32
%163 = arith.extsi %161 : i32 to i64
%162 = arith.addi %159, %163 : i64
%164 = llvm.mlir.addressof @MOD : !llvm.ptr
%165 = llvm.load %164 : !llvm.ptr -> i64
%166 = arith.remsi %162, %165 : i64
%167 = arith.extsi %151 : i64 to i128
%168 = arith.extsi %157 : i64 to i128
%170 = arith.trunci %167 : i128 to i64
%171 = arith.trunci %168 : i128 to i64
%169 = arith.muli %170, %171 : i64
%172 = llvm.mlir.addressof @MOD : !llvm.ptr
%173 = llvm.load %172 : !llvm.ptr -> i64
%174 = arith.extsi %173 : i64 to i128
%176 = arith.trunci %174 : i128 to i64
%175 = arith.remsi %169, %176 : i64
%177 = arith.extsi %175 : i64 to i128
%178 = arith.extsi %166 : i64 to i128
%180 = arith.trunci %177 : i128 to i64
%181 = arith.trunci %178 : i128 to i64
%179 = arith.muli %180, %181 : i64
%182 = llvm.mlir.addressof @MOD : !llvm.ptr
%183 = llvm.load %182 : !llvm.ptr -> i64
%184 = arith.extsi %183 : i64 to i128
%186 = arith.trunci %184 : i128 to i64
%185 = arith.remsi %179, %186 : i64
%187 = arith.extsi %185 : i64 to i128
%188 = llvm.mlir.addressof @INV6 : !llvm.ptr
%189 = llvm.load %188 : !llvm.ptr -> i64
%190 = arith.extsi %189 : i64 to i128
%192 = arith.trunci %187 : i128 to i64
%193 = arith.trunci %190 : i128 to i64
%191 = arith.muli %192, %193 : i64
%194 = llvm.mlir.addressof @MOD : !llvm.ptr
%195 = llvm.load %194 : !llvm.ptr -> i64
%196 = arith.extsi %195 : i64 to i128
%198 = arith.trunci %196 : i128 to i64
%197 = arith.remsi %191, %198 : i64
func.return %197 : i64
}
func.func @range_sum_1(%arg0: i64, %arg1: i64) -> i64 {
%199 = arith.cmpi sgt, %arg0, %arg1 : i64
cf.cond_br %199, ^bb24, ^bb25
^bb24:
%200 = arith.constant 0 : i32
%201 = arith.extsi %200 : i32 to i64
func.return %201 : i64
^bb25:
cf.br ^bb26
^bb26:
%202 = func.call @sum_1(%arg1) : (i64) -> i64
%204 = arith.constant 1 : i32
%206 = arith.extsi %204 : i32 to i64
%205 = arith.subi %arg0, %206 : i64
%203 = func.call @sum_1(%205) : (i64) -> i64
%207 = arith.subi %202, %203 : i64
%208 = llvm.mlir.addressof @MOD : !llvm.ptr
%209 = llvm.load %208 : !llvm.ptr -> i64
%210 = arith.remsi %207, %209 : i64
%211 = llvm.mlir.addressof @MOD : !llvm.ptr
%212 = llvm.load %211 : !llvm.ptr -> i64
%213 = arith.addi %210, %212 : i64
%214 = llvm.mlir.addressof @MOD : !llvm.ptr
%215 = llvm.load %214 : !llvm.ptr -> i64
%216 = arith.remsi %213, %215 : i64
func.return %216 : i64
}
func.func @range_sum_2(%arg0: i64, %arg1: i64) -> i64 {
%217 = arith.cmpi sgt, %arg0, %arg1 : i64
cf.cond_br %217, ^bb27, ^bb28
^bb27:
%218 = arith.constant 0 : i32
%219 = arith.extsi %218 : i32 to i64
func.return %219 : i64
^bb28:
cf.br ^bb29
^bb29:
%220 = func.call @sum_2(%arg1) : (i64) -> i64
%222 = arith.constant 1 : i32
%224 = arith.extsi %222 : i32 to i64
%223 = arith.subi %arg0, %224 : i64
%221 = func.call @sum_2(%223) : (i64) -> i64
%225 = arith.subi %220, %221 : i64
%226 = llvm.mlir.addressof @MOD : !llvm.ptr
%227 = llvm.load %226 : !llvm.ptr -> i64
%228 = arith.remsi %225, %227 : i64
%229 = llvm.mlir.addressof @MOD : !llvm.ptr
%230 = llvm.load %229 : !llvm.ptr -> i64
%231 = arith.addi %228, %230 : i64
%232 = llvm.mlir.addressof @MOD : !llvm.ptr
%233 = llvm.load %232 : !llvm.ptr -> i64
%234 = arith.remsi %231, %233 : i64
func.return %234 : i64
}
func.func @sum_triples_count(%arg0: i64, %arg1: i64) -> i64 {
%235 = arith.cmpi sgt, %arg0, %arg1 : i64
cf.cond_br %235, ^bb30, ^bb31
^bb30:
%236 = arith.constant 0 : i32
%237 = arith.extsi %236 : i32 to i64
func.return %237 : i64
^bb31:
cf.br ^bb32
^bb32:
%238 = arith.subi %arg1, %arg0 : i64
%239 = arith.constant 1 : i32
%241 = arith.extsi %239 : i32 to i64
%240 = arith.addi %238, %241 : i64
%242 = llvm.mlir.addressof @MOD : !llvm.ptr
%243 = llvm.load %242 : !llvm.ptr -> i64
%244 = arith.remsi %240, %243 : i64
%245 = func.call @range_sum_1(%arg0, %arg1) : (i64, i64) -> i64
%246 = func.call @range_sum_2(%arg0, %arg1) : (i64, i64) -> i64
%247 = arith.constant 3 : i32
%249 = arith.extsi %247 : i32 to i64
%248 = arith.muli %249, %245 : i64
%250 = llvm.mlir.addressof @MOD : !llvm.ptr
%251 = llvm.load %250 : !llvm.ptr -> i64
%252 = arith.remsi %248, %251 : i64
%253 = arith.addi %246, %252 : i64
%254 = arith.constant 2 : i32
%256 = arith.extsi %254 : i32 to i64
%255 = arith.muli %256, %244 : i64
%257 = llvm.mlir.addressof @MOD : !llvm.ptr
%258 = llvm.load %257 : !llvm.ptr -> i64
%259 = arith.remsi %255, %258 : i64
%260 = arith.addi %253, %259 : i64
%261 = llvm.mlir.addressof @MOD : !llvm.ptr
%262 = llvm.load %261 : !llvm.ptr -> i64
%263 = arith.remsi %260, %262 : i64
%264 = arith.extsi %263 : i64 to i128
%265 = llvm.mlir.addressof @INV2 : !llvm.ptr
%266 = llvm.load %265 : !llvm.ptr -> i64
%267 = arith.extsi %266 : i64 to i128
%269 = arith.trunci %264 : i128 to i64
%270 = arith.trunci %267 : i128 to i64
%268 = arith.muli %269, %270 : i64
%271 = llvm.mlir.addressof @MOD : !llvm.ptr
%272 = llvm.load %271 : !llvm.ptr -> i64
%273 = arith.extsi %272 : i64 to i128
%275 = arith.trunci %273 : i128 to i64
%274 = arith.remsi %268, %275 : i64
func.return %274 : i64
}
func.func @threshold_t(%arg0: i32) -> i64 {
%276 = arith.constant 3 : i32
%277 = arith.cmpi slt, %arg0, %276 : i32
cf.cond_br %277, ^bb33, ^bb34
^bb33:
%278 = arith.constant 999999995705032704 : i32
%279 = arith.extsi %278 : i32 to i64
func.return %279 : i64
^bb34:
cf.br ^bb35
^bb35:
%280 = arith.constant 3 : i32
%282 = arith.constant 2 : i32
%283 = arith.subi %arg0, %282 : i32
%281 = func.call @pow2k(%283) : (i32) -> i64
%285 = arith.extsi %280 : i32 to i64
%284 = arith.muli %285, %281 : i64
%286 = arith.constant 2 : i32
%288 = arith.extsi %286 : i32 to i64
%287 = arith.addi %284, %288 : i64
func.return %287 : i64
}
func.func @base_bad_for_block(%arg0: i64, %arg1: i64) -> i64 {
%289 = arith.constant 1 : i32
%291 = arith.extsi %289 : i32 to i64
%290 = arith.shrsi %arg0, %291 : i64
%292 = arith.constant 2 : i32
%294 = arith.extsi %292 : i32 to i64
%293 = arith.addi %290, %294 : i64
%295 = arith.cmpi slt, %arg1, %293 : i64
cf.cond_br %295, ^bb36, ^bb37
^bb36:
%296 = arith.constant 0 : i32
%297 = arith.extsi %296 : i32 to i64
func.return %297 : i64
^bb37:
cf.br ^bb38
^bb38:
%298 = arith.constant 2 : i32
%300 = arith.extsi %298 : i32 to i64
%299 = arith.muli %300, %arg1 : i64
%301 = arith.subi %299, %arg0 : i64
%302 = arith.constant 1 : i32
%304 = arith.extsi %302 : i32 to i64
%303 = arith.subi %301, %304 : i64
%305 = arith.constant 1 : i32
%307 = arith.extsi %305 : i32 to i64
%306 = arith.subi %303, %307 : i64
%308 = arith.muli %303, %306 : i64
%309 = arith.constant 2 : i32
%311 = arith.extsi %309 : i32 to i64
%310 = arith.divsi %308, %311 : i64
func.return %310 : i64
}
func.func @bad_count_for_sum(%arg0: i64) -> i64 {
%312 = arith.constant 7 : i32
%314 = arith.extsi %312 : i32 to i64
%313 = arith.cmpi sle, %arg0, %314 : i64
cf.cond_br %313, ^bb39, ^bb40
^bb39:
%315 = arith.constant 0 : i32
%316 = arith.extsi %315 : i32 to i64
func.return %316 : i64
^bb40:
cf.br ^bb41
^bb41:
%318 = arith.constant 1 : i32
%320 = arith.extsi %318 : i32 to i64
%319 = arith.subi %arg0, %320 : i64
%317 = func.call @floor_log2(%319) : (i64) -> i32
%321 = func.call @pow2k(%317) : (i32) -> i64
%322 = arith.subi %arg0, %321 : i64
%323 = func.call @base_bad_for_block(%321, %322) : (i64, i64) -> i64
%324 = arith.constant 3 : i32
%325 = arith.cmpi sge, %317, %324 : i32
cf.cond_br %325, ^bb42, ^bb43
^bb42:
%326 = func.call @threshold_t(%317) : (i32) -> i64
%327 = arith.cmpi sge, %322, %326 : i64
%328 = scf.if %327 -> (i64) {
%329 = arith.constant 3 : i32
%330 = func.call @bad_count_for_sum(%322) : (i64) -> i64
%332 = arith.extsi %329 : i32 to i64
%331 = arith.muli %332, %330 : i64
%333 = arith.addi %323, %331 : i64
scf.yield %333 : i64
} else {
scf.yield %323 : i64
}
cf.br ^bb44(%328 : i64)
^bb43:
cf.br ^bb44(%323 : i64)
^bb44(%334: i64):
func.return %334 : i64
}
func.func @ht_hash(%arg0: i64) -> i64 {
%335 = arith.constant 32 : i32
%337 = arith.extsi %335 : i32 to i64
%336 = arith.shrsi %arg0, %337 : i64
%338 = arith.xori %arg0, %336 : i64
%339 = llvm.mlir.constant(1 : i64) : i64
%340 = llvm.alloca %339 x i64 : (i64) -> !llvm.ptr
llvm.store %338, %340 : i64, !llvm.ptr
%341 = llvm.load %340 : !llvm.ptr -> i64
%342 = arith.constant 0 : i32
%344 = arith.extsi %342 : i32 to i64
%343 = arith.cmpi slt, %341, %344 : i64
cf.cond_br %343, ^bb45, ^bb46
^bb45:
%345 = arith.constant 0 : i32
%346 = llvm.load %340 : !llvm.ptr -> i64
%348 = arith.extsi %345 : i32 to i64
%347 = arith.subi %348, %346 : i64
llvm.store %347, %340 : i64, !llvm.ptr
cf.br ^bb47
^bb46:
cf.br ^bb47
^bb47:
%349 = llvm.load %340 : !llvm.ptr -> i64
%350 = llvm.mlir.addressof @HT_CAP : !llvm.ptr
%351 = llvm.load %350 : !llvm.ptr -> i64
%352 = arith.remsi %349, %351 : i64
func.return %352 : i64
}
func.func @ht_lookup(%arg0: i64) -> i64 {
%353 = func.call @ht_hash(%arg0) : (i64) -> i64
%354 = llvm.mlir.constant(1 : i64) : i64
%355 = llvm.alloca %354 x i64 : (i64) -> !llvm.ptr
llvm.store %353, %355 : i64, !llvm.ptr
cf.br ^bb48
^bb48:
%357 = llvm.mlir.addressof @ht_used : !llvm.ptr
%358 = llvm.load %357 : !llvm.ptr -> !llvm.ptr
%359 = llvm.load %355 : !llvm.ptr -> i64
%360 = llvm.getelementptr %358[%359] : (!llvm.ptr, i64) -> !llvm.ptr, i8
%356 = llvm.load %360 : !llvm.ptr -> i8
%361 = arith.constant 0 : i32
%363 = arith.extsi %356 : i8 to i32
%362 = arith.cmpi ne, %363, %361 : i32
cf.cond_br %362, ^bb49, ^bb50
^bb49:
%365 = llvm.mlir.addressof @ht_keys : !llvm.ptr
%366 = llvm.load %365 : !llvm.ptr -> !llvm.ptr
%367 = llvm.load %355 : !llvm.ptr -> i64
%368 = llvm.getelementptr %366[%367] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%364 = llvm.load %368 : !llvm.ptr -> i64
%369 = arith.cmpi eq, %364, %arg0 : i64
cf.cond_br %369, ^bb51, ^bb52
^bb51:
%371 = llvm.mlir.addressof @ht_vals : !llvm.ptr
%372 = llvm.load %371 : !llvm.ptr -> !llvm.ptr
%373 = llvm.load %355 : !llvm.ptr -> i64
%374 = llvm.getelementptr %372[%373] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%370 = llvm.load %374 : !llvm.ptr -> i64
func.return %370 : i64
^bb52:
cf.br ^bb53
^bb53:
%375 = llvm.load %355 : !llvm.ptr -> i64
%376 = arith.constant 1 : i32
%378 = arith.extsi %376 : i32 to i64
%377 = arith.addi %375, %378 : i64
%379 = llvm.mlir.addressof @HT_CAP : !llvm.ptr
%380 = llvm.load %379 : !llvm.ptr -> i64
%381 = arith.remsi %377, %380 : i64
llvm.store %381, %355 : i64, !llvm.ptr
cf.br ^bb48
^bb50:
%382 = arith.constant 1 : i32
%384 = arith.constant 0 : i32
%383 = arith.subi %384, %382 : i32
%385 = arith.extsi %383 : i32 to i64
func.return %385 : i64
}
func.func @ht_insert(%arg0: i64, %arg1: i64) -> () {
%386 = func.call @ht_hash(%arg0) : (i64) -> i64
%387 = llvm.mlir.constant(1 : i64) : i64
%388 = llvm.alloca %387 x i64 : (i64) -> !llvm.ptr
llvm.store %386, %388 : i64, !llvm.ptr
cf.br ^bb54
^bb54:
%390 = llvm.mlir.addressof @ht_used : !llvm.ptr
%391 = llvm.load %390 : !llvm.ptr -> !llvm.ptr
%392 = llvm.load %388 : !llvm.ptr -> i64
%393 = llvm.getelementptr %391[%392] : (!llvm.ptr, i64) -> !llvm.ptr, i8
%389 = llvm.load %393 : !llvm.ptr -> i8
%394 = arith.constant 0 : i32
%396 = arith.extsi %389 : i8 to i32
%395 = arith.cmpi ne, %396, %394 : i32
cf.cond_br %395, ^bb55, ^bb56
^bb55:
%398 = llvm.mlir.addressof @ht_keys : !llvm.ptr
%399 = llvm.load %398 : !llvm.ptr -> !llvm.ptr
%400 = llvm.load %388 : !llvm.ptr -> i64
%401 = llvm.getelementptr %399[%400] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%397 = llvm.load %401 : !llvm.ptr -> i64
%402 = arith.cmpi eq, %397, %arg0 : i64
cf.cond_br %402, ^bb57, ^bb58
^bb57:
%403 = llvm.mlir.addressof @ht_vals : !llvm.ptr
%404 = llvm.load %403 : !llvm.ptr -> !llvm.ptr
%405 = llvm.load %388 : !llvm.ptr -> i64
%406 = llvm.getelementptr %404[%405] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %arg1, %406 : i64, !llvm.ptr
func.return
^bb58:
cf.br ^bb59
^bb59:
%407 = llvm.load %388 : !llvm.ptr -> i64
%408 = arith.constant 1 : i32
%410 = arith.extsi %408 : i32 to i64
%409 = arith.addi %407, %410 : i64
%411 = llvm.mlir.addressof @HT_CAP : !llvm.ptr
%412 = llvm.load %411 : !llvm.ptr -> i64
%413 = arith.remsi %409, %412 : i64
llvm.store %413, %388 : i64, !llvm.ptr
cf.br ^bb54
^bb56:
%414 = arith.constant 1 : i32
%415 = llvm.mlir.addressof @ht_used : !llvm.ptr
%416 = llvm.load %415 : !llvm.ptr -> !llvm.ptr
%417 = llvm.load %388 : !llvm.ptr -> i64
%418 = arith.trunci %414 : i32 to i8
%419 = llvm.getelementptr %416[%417] : (!llvm.ptr, i64) -> !llvm.ptr, i8
llvm.store %418, %419 : i8, !llvm.ptr
%420 = llvm.mlir.addressof @ht_keys : !llvm.ptr
%421 = llvm.load %420 : !llvm.ptr -> !llvm.ptr
%422 = llvm.load %388 : !llvm.ptr -> i64
%423 = llvm.getelementptr %421[%422] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %arg0, %423 : i64, !llvm.ptr
%424 = llvm.mlir.addressof @ht_vals : !llvm.ptr
%425 = llvm.load %424 : !llvm.ptr -> !llvm.ptr
%426 = llvm.load %388 : !llvm.ptr -> i64
%427 = llvm.getelementptr %425[%426] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %arg1, %427 : i64, !llvm.ptr
func.return
}
func.func @sum_base_bad_block_mod(%arg0: i64, %arg1: i64) -> i64 {
%428 = arith.constant 0 : i32
%430 = arith.extsi %428 : i32 to i64
%429 = arith.cmpi sle, %arg1, %430 : i64
cf.cond_br %429, ^bb60, ^bb61
^bb60:
%431 = arith.constant 0 : i32
%432 = arith.extsi %431 : i32 to i64
func.return %432 : i64
^bb61:
cf.br ^bb62
^bb62:
%433 = arith.constant 1 : i32
%435 = arith.extsi %433 : i32 to i64
%434 = arith.shrsi %arg0, %435 : i64
%436 = arith.constant 2 : i32
%438 = arith.extsi %436 : i32 to i64
%437 = arith.addi %434, %438 : i64
%439 = arith.cmpi slt, %arg1, %437 : i64
cf.cond_br %439, ^bb63, ^bb64
^bb63:
%440 = arith.constant 0 : i32
%441 = arith.extsi %440 : i32 to i64
func.return %441 : i64
^bb64:
cf.br ^bb65
^bb65:
%442 = arith.subi %arg1, %437 : i64
%443 = arith.constant 1 : i32
%445 = arith.extsi %443 : i32 to i64
%444 = arith.addi %442, %445 : i64
%446 = llvm.mlir.addressof @MOD : !llvm.ptr
%447 = llvm.load %446 : !llvm.ptr -> i64
%448 = arith.remsi %444, %447 : i64
%449 = func.call @range_sum_1(%437, %arg1) : (i64, i64) -> i64
%450 = func.call @range_sum_2(%437, %arg1) : (i64, i64) -> i64
%451 = arith.constant 1 : i32
%453 = arith.extsi %451 : i32 to i64
%452 = arith.addi %arg0, %453 : i64
%454 = llvm.mlir.addressof @MOD : !llvm.ptr
%455 = llvm.load %454 : !llvm.ptr -> i64
%456 = arith.remsi %452, %455 : i64
%457 = arith.constant 2 : i32
%459 = arith.extsi %457 : i32 to i64
%458 = arith.addi %arg0, %459 : i64
%460 = llvm.mlir.addressof @MOD : !llvm.ptr
%461 = llvm.load %460 : !llvm.ptr -> i64
%462 = arith.remsi %458, %461 : i64
%463 = arith.extsi %456 : i64 to i128
%464 = arith.extsi %462 : i64 to i128
%466 = arith.trunci %463 : i128 to i64
%467 = arith.trunci %464 : i128 to i64
%465 = arith.muli %466, %467 : i64
%468 = llvm.mlir.addressof @MOD : !llvm.ptr
%469 = llvm.load %468 : !llvm.ptr -> i64
%470 = arith.extsi %469 : i64 to i128
%472 = arith.trunci %470 : i128 to i64
%471 = arith.remsi %465, %472 : i64
%473 = arith.extsi %471 : i64 to i128
%474 = llvm.mlir.addressof @INV2 : !llvm.ptr
%475 = llvm.load %474 : !llvm.ptr -> i64
%476 = arith.extsi %475 : i64 to i128
%478 = arith.trunci %473 : i128 to i64
%479 = arith.trunci %476 : i128 to i64
%477 = arith.muli %478, %479 : i64
%480 = llvm.mlir.addressof @MOD : !llvm.ptr
%481 = llvm.load %480 : !llvm.ptr -> i64
%482 = arith.extsi %481 : i64 to i128
%484 = arith.trunci %482 : i128 to i64
%483 = arith.remsi %477, %484 : i64
%485 = arith.constant 2 : i32
%487 = arith.extsi %485 : i32 to i64
%486 = arith.muli %487, %arg0 : i64
%488 = arith.constant 3 : i32
%490 = arith.extsi %488 : i32 to i64
%489 = arith.addi %486, %490 : i64
%491 = llvm.mlir.addressof @MOD : !llvm.ptr
%492 = llvm.load %491 : !llvm.ptr -> i64
%493 = arith.remsi %489, %492 : i64
%494 = arith.constant 2 : i32
%496 = arith.extsi %494 : i32 to i64
%495 = arith.muli %496, %450 : i64
%497 = llvm.mlir.addressof @MOD : !llvm.ptr
%498 = llvm.load %497 : !llvm.ptr -> i64
%499 = arith.remsi %495, %498 : i64
%500 = arith.extsi %493 : i64 to i128
%501 = arith.extsi %449 : i64 to i128
%503 = arith.trunci %500 : i128 to i64
%504 = arith.trunci %501 : i128 to i64
%502 = arith.muli %503, %504 : i64
%505 = llvm.mlir.addressof @MOD : !llvm.ptr
%506 = llvm.load %505 : !llvm.ptr -> i64
%507 = arith.extsi %506 : i64 to i128
%509 = arith.trunci %507 : i128 to i64
%508 = arith.remsi %502, %509 : i64
%510 = arith.extsi %483 : i64 to i128
%511 = arith.extsi %448 : i64 to i128
%513 = arith.trunci %510 : i128 to i64
%514 = arith.trunci %511 : i128 to i64
%512 = arith.muli %513, %514 : i64
%515 = llvm.mlir.addressof @MOD : !llvm.ptr
%516 = llvm.load %515 : !llvm.ptr -> i64
%517 = arith.extsi %516 : i64 to i128
%519 = arith.trunci %517 : i128 to i64
%518 = arith.remsi %512, %519 : i64
%520 = arith.subi %499, %508 : i64
%521 = arith.addi %520, %518 : i64
%522 = llvm.mlir.addressof @MOD : !llvm.ptr
%523 = llvm.load %522 : !llvm.ptr -> i64
%524 = arith.remsi %521, %523 : i64
%525 = llvm.mlir.addressof @MOD : !llvm.ptr
%526 = llvm.load %525 : !llvm.ptr -> i64
%527 = arith.remsi %524, %526 : i64
%528 = llvm.mlir.addressof @MOD : !llvm.ptr
%529 = llvm.load %528 : !llvm.ptr -> i64
%530 = arith.addi %527, %529 : i64
%531 = llvm.mlir.addressof @MOD : !llvm.ptr
%532 = llvm.load %531 : !llvm.ptr -> i64
%533 = arith.remsi %530, %532 : i64
func.return %533 : i64
}
func.func @block_bad_sum_mod(%arg0: i64, %arg1: i64) -> i64 {
%534 = arith.constant 0 : i32
%536 = arith.extsi %534 : i32 to i64
%535 = arith.cmpi sle, %arg1, %536 : i64
cf.cond_br %535, ^bb66, ^bb67
^bb66:
%537 = arith.constant 0 : i32
%538 = arith.extsi %537 : i32 to i64
func.return %538 : i64
^bb67:
cf.br ^bb68
^bb68:
%539 = func.call @floor_log2(%arg0) : (i64) -> i32
%540 = func.call @sum_base_bad_block_mod(%arg0, %arg1) : (i64, i64) -> i64
%541 = func.call @threshold_t(%539) : (i32) -> i64
%542 = arith.cmpi sle, %541, %arg1 : i64
%543 = scf.if %542 -> (i64) {
%544 = func.call @bad_prefix_sum_mod(%arg1) : (i64) -> i64
%546 = arith.constant 1 : i32
%548 = arith.extsi %546 : i32 to i64
%547 = arith.subi %541, %548 : i64
%545 = func.call @bad_prefix_sum_mod(%547) : (i64) -> i64
%549 = arith.subi %544, %545 : i64
%550 = llvm.mlir.addressof @MOD : !llvm.ptr
%551 = llvm.load %550 : !llvm.ptr -> i64
%552 = arith.remsi %549, %551 : i64
%553 = arith.constant 3 : i32
%555 = arith.extsi %553 : i32 to i64
%554 = arith.muli %555, %552 : i64
%556 = llvm.mlir.addressof @MOD : !llvm.ptr
%557 = llvm.load %556 : !llvm.ptr -> i64
%558 = arith.remsi %554, %557 : i64
%559 = arith.addi %540, %558 : i64
%560 = llvm.mlir.addressof @MOD : !llvm.ptr
%561 = llvm.load %560 : !llvm.ptr -> i64
%562 = arith.remsi %559, %561 : i64
scf.yield %562 : i64
} else {
scf.yield %540 : i64
}
%563 = llvm.mlir.addressof @MOD : !llvm.ptr
%564 = llvm.load %563 : !llvm.ptr -> i64
%565 = arith.remsi %543, %564 : i64
%566 = llvm.mlir.addressof @MOD : !llvm.ptr
%567 = llvm.load %566 : !llvm.ptr -> i64
%568 = arith.addi %565, %567 : i64
%569 = llvm.mlir.addressof @MOD : !llvm.ptr
%570 = llvm.load %569 : !llvm.ptr -> i64
%571 = arith.remsi %568, %570 : i64
func.return %571 : i64
}
func.func @bad_prefix_sum_mod(%arg0: i64) -> i64 {
%572 = arith.constant 0 : i32
%574 = arith.extsi %572 : i32 to i64
%573 = arith.cmpi sle, %arg0, %574 : i64
cf.cond_br %573, ^bb69, ^bb70
^bb69:
%575 = arith.constant 0 : i32
%576 = arith.extsi %575 : i32 to i64
func.return %576 : i64
^bb70:
cf.br ^bb71
^bb71:
%577 = arith.constant 16 : i32
%579 = arith.extsi %577 : i32 to i64
%578 = arith.cmpi sle, %arg0, %579 : i64
cf.cond_br %578, ^bb72, ^bb73
^bb72:
%580 = arith.constant 0 : i32
%581 = arith.extsi %580 : i32 to i64
%582 = llvm.mlir.constant(1 : i64) : i64
%583 = llvm.alloca %582 x i64 : (i64) -> !llvm.ptr
llvm.store %581, %583 : i64, !llvm.ptr
%584 = arith.constant 1 : i32
%585 = arith.extsi %584 : i32 to i64
%586 = llvm.mlir.constant(1 : i64) : i64
%587 = llvm.alloca %586 x i64 : (i64) -> !llvm.ptr
llvm.store %585, %587 : i64, !llvm.ptr
cf.br ^bb75
^bb75:
%588 = llvm.load %587 : !llvm.ptr -> i64
%589 = arith.cmpi sle, %588, %arg0 : i64
cf.cond_br %589, ^bb76, ^bb77
^bb76:
%590 = llvm.load %583 : !llvm.ptr -> i64
%592 = llvm.load %587 : !llvm.ptr -> i64
%591 = func.call @bad_count_for_sum(%592) : (i64) -> i64
%593 = arith.addi %590, %591 : i64
llvm.store %593, %583 : i64, !llvm.ptr
%594 = llvm.load %587 : !llvm.ptr -> i64
%595 = arith.constant 1 : i32
%597 = arith.extsi %595 : i32 to i64
%596 = arith.addi %594, %597 : i64
llvm.store %596, %587 : i64, !llvm.ptr
cf.br ^bb75
^bb77:
%598 = llvm.load %583 : !llvm.ptr -> i64
%599 = llvm.mlir.addressof @MOD : !llvm.ptr
%600 = llvm.load %599 : !llvm.ptr -> i64
%601 = arith.remsi %598, %600 : i64
func.return %601 : i64
^bb73:
cf.br ^bb74
^bb74:
%602 = func.call @ht_lookup(%arg0) : (i64) -> i64
%603 = arith.constant 0 : i32
%605 = arith.extsi %603 : i32 to i64
%604 = arith.cmpi sge, %602, %605 : i64
cf.cond_br %604, ^bb78, ^bb79
^bb78:
func.return %602 : i64
^bb79:
cf.br ^bb80
^bb80:
%607 = func.call @floor_log2(%arg0) : (i64) -> i32
%606 = func.call @pow2k(%607) : (i32) -> i64
%608 = arith.constant 0 : i32
%609 = arith.extsi %608 : i32 to i64
%610 = arith.cmpi eq, %arg0, %606 : i64
cf.cond_br %610, ^bb81, ^bb82
^bb81:
%611 = arith.constant 1 : i32
%613 = arith.extsi %611 : i32 to i64
%612 = arith.cmpi eq, %606, %613 : i64
%614 = scf.if %612 -> (i64) {
%615 = arith.constant 0 : i32
%616 = arith.extsi %615 : i32 to i64
scf.yield %616 : i64
} else {
%617 = arith.constant 1 : i32
%619 = arith.extsi %617 : i32 to i64
%618 = arith.shrsi %606, %619 : i64
%620 = func.call @bad_prefix_sum_mod(%618) : (i64) -> i64
%621 = func.call @block_bad_sum_mod(%618, %618) : (i64, i64) -> i64
%622 = arith.addi %620, %621 : i64
%623 = llvm.mlir.addressof @MOD : !llvm.ptr
%624 = llvm.load %623 : !llvm.ptr -> i64
%625 = arith.remsi %622, %624 : i64
scf.yield %625 : i64
}
cf.br ^bb83(%614 : i64)
^bb82:
%626 = func.call @bad_prefix_sum_mod(%606) : (i64) -> i64
%628 = arith.subi %arg0, %606 : i64
%627 = func.call @block_bad_sum_mod(%606, %628) : (i64, i64) -> i64
%629 = arith.addi %626, %627 : i64
%630 = llvm.mlir.addressof @MOD : !llvm.ptr
%631 = llvm.load %630 : !llvm.ptr -> i64
%632 = arith.remsi %629, %631 : i64
cf.br ^bb83(%632 : i64)
^bb83(%633: i64):
func.call @ht_insert(%arg0, %633) : (i64, i64) -> ()
func.return %633 : i64
}
func.func @base_part_mod(%arg0: i64) -> i64 {
%635 = arith.constant 0 : i32
%637 = arith.extsi %635 : i32 to i64
%636 = arith.cmpi sle, %arg0, %637 : i64
cf.cond_br %636, ^bb84, ^bb85
^bb84:
%638 = arith.constant 0 : i32
%639 = arith.extsi %638 : i32 to i64
func.return %639 : i64
^bb85:
cf.br ^bb86
^bb86:
%640 = arith.constant 0 : i32
%641 = arith.extsi %640 : i32 to i64
%642 = llvm.mlir.constant(1 : i64) : i64
%643 = llvm.alloca %642 x i64 : (i64) -> !llvm.ptr
llvm.store %641, %643 : i64, !llvm.ptr
%644 = arith.constant 1 : i32
%645 = arith.extsi %644 : i32 to i64
%646 = llvm.mlir.constant(1 : i64) : i64
%647 = llvm.alloca %646 x i64 : (i64) -> !llvm.ptr
llvm.store %645, %647 : i64, !llvm.ptr
%648 = arith.constant 2 : i32
%649 = arith.extsi %648 : i32 to i64
%650 = llvm.mlir.constant(1 : i64) : i64
%651 = llvm.alloca %650 x i64 : (i64) -> !llvm.ptr
llvm.store %649, %651 : i64, !llvm.ptr
cf.br ^bb87
^bb87:
%652 = llvm.load %651 : !llvm.ptr -> i64
%653 = arith.cmpi sle, %652, %arg0 : i64
cf.cond_br %653, ^bb88, ^bb89
^bb88:
%655 = llvm.load %647 : !llvm.ptr -> i64
%656 = arith.trunci %655 : i64 to i32
%654 = func.call @pow2k(%656) : (i32) -> i64
%657 = llvm.mlir.constant(1 : i64) : i64
%658 = llvm.alloca %657 x i64 : (i64) -> !llvm.ptr
llvm.store %654, %658 : i64, !llvm.ptr
%659 = llvm.load %658 : !llvm.ptr -> i64
%660 = arith.cmpi sgt, %659, %arg0 : i64
cf.cond_br %660, ^bb90, ^bb91
^bb90:
llvm.store %arg0, %658 : i64, !llvm.ptr
cf.br ^bb92
^bb91:
cf.br ^bb92
^bb92:
%662 = llvm.load %651 : !llvm.ptr -> i64
%663 = llvm.load %658 : !llvm.ptr -> i64
%661 = func.call @sum_triples_count(%662, %663) : (i64, i64) -> i64
%664 = llvm.load %647 : !llvm.ptr -> i64
%665 = arith.extsi %664 : i64 to i128
%666 = arith.extsi %661 : i64 to i128
%668 = arith.trunci %665 : i128 to i64
%669 = arith.trunci %666 : i128 to i64
%667 = arith.muli %668, %669 : i64
%670 = llvm.mlir.addressof @MOD : !llvm.ptr
%671 = llvm.load %670 : !llvm.ptr -> i64
%672 = arith.extsi %671 : i64 to i128
%674 = arith.trunci %672 : i128 to i64
%673 = arith.remsi %667, %674 : i64
%675 = llvm.load %643 : !llvm.ptr -> i64
%676 = arith.addi %675, %673 : i64
%677 = llvm.mlir.addressof @MOD : !llvm.ptr
%678 = llvm.load %677 : !llvm.ptr -> i64
%679 = arith.remsi %676, %678 : i64
llvm.store %679, %643 : i64, !llvm.ptr
%680 = llvm.load %647 : !llvm.ptr -> i64
%681 = arith.constant 1 : i32
%683 = arith.extsi %681 : i32 to i64
%682 = arith.addi %680, %683 : i64
llvm.store %682, %647 : i64, !llvm.ptr
%685 = llvm.load %647 : !llvm.ptr -> i64
%686 = arith.constant 1 : i32
%688 = arith.extsi %686 : i32 to i64
%687 = arith.subi %685, %688 : i64
%689 = arith.trunci %687 : i64 to i32
%684 = func.call @pow2k(%689) : (i32) -> i64
%690 = arith.constant 1 : i32
%692 = arith.extsi %690 : i32 to i64
%691 = arith.addi %684, %692 : i64
llvm.store %691, %651 : i64, !llvm.ptr
cf.br ^bb87
^bb89:
%693 = llvm.load %643 : !llvm.ptr -> i64
func.return %693 : i64
}
func.func @H_mod(%arg0: i64) -> i64 {
%694 = func.call @base_part_mod(%arg0) : (i64) -> i64
%695 = func.call @bad_prefix_sum_mod(%arg0) : (i64) -> i64
%696 = arith.addi %694, %695 : i64
%697 = llvm.mlir.addressof @MOD : !llvm.ptr
%698 = llvm.load %697 : !llvm.ptr -> i64
%699 = arith.remsi %696, %698 : i64
func.return %699 : i64
}
func.func @main() -> i32 {
%700 = llvm.mlir.addressof @MOD : !llvm.ptr
%701 = llvm.load %700 : !llvm.ptr -> i64
%702 = arith.constant 1 : i32
%704 = arith.extsi %702 : i32 to i64
%703 = arith.addi %701, %704 : i64
%705 = arith.constant 2 : i32
%707 = arith.extsi %705 : i32 to i64
%706 = arith.divsi %703, %707 : i64
%708 = llvm.mlir.addressof @INV2 : !llvm.ptr
llvm.store %706, %708 : i64, !llvm.ptr
%710 = arith.constant 6 : i32
%711 = llvm.mlir.addressof @MOD : !llvm.ptr
%712 = llvm.load %711 : !llvm.ptr -> i64
%713 = arith.constant 2 : i32
%715 = arith.extsi %713 : i32 to i64
%714 = arith.subi %712, %715 : i64
%716 = llvm.mlir.addressof @MOD : !llvm.ptr
%717 = llvm.load %716 : !llvm.ptr -> i64
%718 = arith.extsi %710 : i32 to i64
%709 = func.call @modpow(%718, %714, %717) : (i64, i64, i64) -> i64
%719 = llvm.mlir.addressof @INV6 : !llvm.ptr
llvm.store %709, %719 : i64, !llvm.ptr
%721 = llvm.mlir.addressof @HT_CAP : !llvm.ptr
%722 = llvm.load %721 : !llvm.ptr -> i64
%723 = arith.constant 8 : i32
%724 = arith.extsi %723 : i32 to i64
%720 = func.call @calloc(%722, %724) : (i64, i64) -> !llvm.ptr
%725 = llvm.mlir.addressof @ht_keys : !llvm.ptr
llvm.store %720, %725 : !llvm.ptr, !llvm.ptr
%727 = llvm.mlir.addressof @HT_CAP : !llvm.ptr
%728 = llvm.load %727 : !llvm.ptr -> i64
%729 = arith.constant 8 : i32
%730 = arith.extsi %729 : i32 to i64
%726 = func.call @calloc(%728, %730) : (i64, i64) -> !llvm.ptr
%731 = llvm.mlir.addressof @ht_vals : !llvm.ptr
llvm.store %726, %731 : !llvm.ptr, !llvm.ptr
%733 = llvm.mlir.addressof @HT_CAP : !llvm.ptr
%734 = llvm.load %733 : !llvm.ptr -> i64
%735 = arith.constant 1 : i32
%736 = arith.extsi %735 : i32 to i64
%732 = func.call @calloc(%734, %736) : (i64, i64) -> !llvm.ptr
%737 = llvm.mlir.addressof @ht_used : !llvm.ptr
llvm.store %732, %737 : !llvm.ptr, !llvm.ptr
%739 = arith.constant 19 : i32
%738 = func.call @repunit(%739) : (i32) -> i64
%740 = llvm.mlir.addressof @str_0 : !llvm.ptr
%741 = func.call @H_mod(%738) : (i64) -> i64
%742 = llvm.call @printf(%740, %741) vararg(!llvm.func<i32 (ptr, ...)>) : (!llvm.ptr, i64) -> i32
%744 = llvm.mlir.addressof @ht_keys : !llvm.ptr
%745 = llvm.load %744 : !llvm.ptr -> !llvm.ptr
func.call @free(%745) : (!llvm.ptr) -> ()
%747 = llvm.mlir.addressof @ht_vals : !llvm.ptr
%748 = llvm.load %747 : !llvm.ptr -> !llvm.ptr
func.call @free(%748) : (!llvm.ptr) -> ()
%750 = llvm.mlir.addressof @ht_used : !llvm.ptr
%751 = llvm.load %750 : !llvm.ptr -> !llvm.ptr
func.call @free(%751) : (!llvm.ptr) -> ()
%752 = arith.constant 0 : i32
func.return %752 : i32
}
}