Problem 254
sum_{i=1..150} sg(i) for digit-factorial sf maps.
View problem on Project Euler
Performance comparison
| Metric | Our solution | Best known |
| Time complexity | O(n^3) | O(n) |
| Space complexity | O(n^2) | O(n) |
| Approach | Flow solution | Big-integer factorial |
| Verdict | Suboptimal |
Flow source
# Project Euler 254
# sum_{i=1..150} sg(i) for digit-factorial sf maps.
extern {
function calloc(n: i64, size: i64) -> ptr<void>
function free(p: ptr<void>) -> void
}
function digit_sum(n0: i64) -> i64 {
let mut n: i64 = n0
let mut s: i64 = 0
if n < 0 { n = -n }
while n > 0 {
s = s + (n % 10)
n = n / 10
}
return s
}
function min_number_digit_sum(s: i64) -> i64 {
# smallest positive int with digit sum s
let q: i64 = s / 9
let r: i64 = s % 9
let mut ans: i64 = 0
if r == 0 {
let mut i: i64 = 0
while i < q {
ans = ans * 10 + 9
i = i + 1
}
} else {
ans = r
let mut i: i64 = 0
while i < q {
ans = ans * 10 + 9
i = i + 1
}
}
return ans
}
function main() -> i32 {
let FACT9: i64 = 362880
let f1: i64 = 1
let f2: i64 = 2
let f3: i64 = 6
let f4: i64 = 24
let f5: i64 = 120
let f6: i64 = 720
let f7: i64 = 5040
let f8: i64 = 40320
let counts1: ptr<i8> = calloc(FACT9, 1)
let counts2: ptr<i8> = calloc(FACT9, 1)
let counts3: ptr<i8> = calloc(FACT9, 1)
let counts4: ptr<i8> = calloc(FACT9, 1)
let counts5: ptr<i8> = calloc(FACT9, 1)
let counts6: ptr<i8> = calloc(FACT9, 1)
let counts7: ptr<i8> = calloc(FACT9, 1)
let counts8: ptr<i8> = calloc(FACT9, 1)
let rem_len: ptr<i8> = calloc(FACT9, 1)
let rem_sg: ptr<i16> = calloc(FACT9, 2)
let bucket_sz: ptr<i32> = calloc(9, 4)
let packed: ptr<i64> = calloc(FACT9, 8)
let packed_mod: ptr<i8> = calloc(FACT9, 1)
let mut r: i64 = 0
while r < FACT9 {
let mut x: i64 = r
let a8: i64 = x / f8; x = x % f8
let a7: i64 = x / f7; x = x % f7
let a6: i64 = x / f6; x = x % f6
let a5: i64 = x / f5; x = x % f5
let a4: i64 = x / f4; x = x % f4
let a3: i64 = x / f3; x = x % f3
let a2: i64 = x / f2; x = x % f2
let a1: i64 = x / f1
counts1[r] = a1 as i8
counts2[r] = a2 as i8
counts3[r] = a3 as i8
counts4[r] = a4 as i8
counts5[r] = a5 as i8
counts6[r] = a6 as i8
counts7[r] = a7 as i8
counts8[r] = a8 as i8
let ln: i64 = a1+a2+a3+a4+a5+a6+a7+a8
rem_len[r] = ln as i8
rem_sg[r] = (1*a1+2*a2+3*a3+4*a4+5*a5+6*a6+7*a7+8*a8) as i16
let mut code: i64 = ln
code = code * 9 + (8 - a1)
code = code * 9 + (8 - a2)
code = code * 9 + (8 - a3)
code = code * 9 + (8 - a4)
code = code * 9 + (8 - a5)
code = code * 9 + (8 - a6)
code = code * 9 + (8 - a7)
code = code * 9 + (8 - a8)
packed[r] = (code << 19) | r
packed_mod[r] = (r % 9) as i8
bucket_sz[r % 9] = bucket_sz[r % 9] + 1
r = r + 1
}
# sort each bucket by packed key - insertion sort into buckets
let bucket_off: ptr<i32> = calloc(10, 4)
let mut m: i64 = 0
while m < 9 {
bucket_off[m + 1] = bucket_off[m] + bucket_sz[m]
m = m + 1
}
let buckets: ptr<i32> = calloc(FACT9, 4)
let fill: ptr<i32> = calloc(9, 4)
m = 0
while m < 9 { fill[m] = bucket_off[m]; m = m + 1 }
r = 0
while r < FACT9 {
let md: i64 = packed_mod[r] as i64
let at: i64 = fill[md] as i64
buckets[at] = r as i32
fill[md] = (at + 1) as i32
r = r + 1
}
# sort each bucket by packed[r]
m = 0
while m < 9 {
let lo: i64 = bucket_off[m] as i64
let hi: i64 = bucket_off[m + 1] as i64
let mut i: i64 = lo + 1
while i < hi {
let key: i64 = buckets[i] as i64
let pk: i64 = packed[key]
let mut j: i64 = i
while j > lo {
let prev: i64 = buckets[j - 1] as i64
if packed[prev] <= pk { break }
buckets[j] = prev as i32
j = j - 1
}
buckets[j] = key as i32
i = i + 1
}
m = m + 1
}
let low_lim: i64 = 1000000 + FACT9
let low_ds: ptr<i8> = calloc(low_lim, 1)
let mut n: i64 = 1
while n < low_lim {
low_ds[n] = (low_ds[n / 10] as i64 + (n % 10)) as i8
n = n + 1
}
let mut total: i64 = 0
let mut i: i64 = 1
while i <= 150 {
let kmin: i64 = min_number_digit_sum(i)
let qmin: i64 = kmin / FACT9
let residue: i64 = i % 9
let blo: i64 = bucket_off[residue] as i64
let bhi: i64 = bucket_off[residue + 1] as i64
let mut best_len: i64 = -1
let mut best_c1: i64 = 0
let mut best_c2: i64 = 0
let mut best_c3: i64 = 0
let mut best_c4: i64 = 0
let mut best_c5: i64 = 0
let mut best_c6: i64 = 0
let mut best_c7: i64 = 0
let mut best_c8: i64 = 0
let mut best_q: i64 = 0
let mut best_sg: i64 = -1
let mut have: bool = false
let mut delta: i64 = 0
while delta < 37 {
let q: i64 = qmin + delta
if have && q >= best_len { break }
let base: i64 = q * FACT9
let high: i64 = base / 1000000
let low: i64 = base % 1000000
let sum_high: i64 = digit_sum(high)
let sum_high1: i64 = digit_sum(high + 1)
let mut need0: i64 = i - sum_high
let mut need1: i64 = i - sum_high1
if need0 < 0 || need0 > 54 { need0 = -1 }
if need1 < 0 || need1 > 54 { need1 = -1 }
let mut found_r: i64 = -1
let mut bi: i64 = blo
while bi < bhi {
let rr: i64 = buckets[bi] as i64
let t: i64 = low + rr
if t < 1000000 {
if need0 >= 0 && (low_ds[t] as i64) == need0 {
found_r = rr
break
}
} else {
if need1 >= 0 && (low_ds[t - 1000000] as i64) == need1 {
found_r = rr
break
}
}
bi = bi + 1
}
if found_r >= 0 {
let ln: i64 = rem_len[found_r] as i64
let length_total: i64 = q + ln
let c1: i64 = counts1[found_r] as i64
let c2: i64 = counts2[found_r] as i64
let c3: i64 = counts3[found_r] as i64
let c4: i64 = counts4[found_r] as i64
let c5: i64 = counts5[found_r] as i64
let c6: i64 = counts6[found_r] as i64
let c7: i64 = counts7[found_r] as i64
let c8: i64 = counts8[found_r] as i64
let better: bool = false
if !have { better = true }
elif length_total < best_len { better = true }
elif length_total == best_len {
if c1 > best_c1 { better = true }
elif c1 == best_c1 && c2 > best_c2 { better = true }
elif c1 == best_c1 && c2 == best_c2 && c3 > best_c3 { better = true }
elif c1 == best_c1 && c2 == best_c2 && c3 == best_c3 && c4 > best_c4 { better = true }
elif c1 == best_c1 && c2 == best_c2 && c3 == best_c3 && c4 == best_c4 && c5 > best_c5 { better = true }
elif c1 == best_c1 && c2 == best_c2 && c3 == best_c3 && c4 == best_c4 && c5 == best_c5 && c6 > best_c6 { better = true }
elif c1 == best_c1 && c2 == best_c2 && c3 == best_c3 && c4 == best_c4 && c5 == best_c5 && c6 == best_c6 && c7 > best_c7 { better = true }
elif c1 == best_c1 && c2 == best_c2 && c3 == best_c3 && c4 == best_c4 && c5 == best_c5 && c6 == best_c6 && c7 == best_c7 && c8 > best_c8 { better = true }
elif c1 == best_c1 && c2 == best_c2 && c3 == best_c3 && c4 == best_c4 && c5 == best_c5 && c6 == best_c6 && c7 == best_c7 && c8 == best_c8 && q > best_q { better = true }
}
if better {
have = true
best_len = length_total
best_c1 = c1; best_c2 = c2; best_c3 = c3; best_c4 = c4
best_c5 = c5; best_c6 = c6; best_c7 = c7; best_c8 = c8
best_q = q
best_sg = (rem_sg[found_r] as i64) + 9 * q
}
}
delta = delta + 1
}
total = total + best_sg
i = i + 1
}
printf("%lld\n", total)
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 digit_sum_i64(int64_t n0);
int64_t min_number_digit_sum_i64(int64_t s);
int32_t main(void);
int64_t digit_sum_i64(int64_t n0) {
int64_t n = n0;
int64_t s = 0;
if (n < 0) {
n = (-n);
}
while (n > 0) {
s = (s + FLOW_CHECKED_MOD((n), (10)));
n = FLOW_CHECKED_DIV((n), (10));
}
return s;
}
int64_t min_number_digit_sum_i64(int64_t s) {
int64_t q = FLOW_CHECKED_DIV((s), (9));
int64_t r = FLOW_CHECKED_MOD((s), (9));
int64_t ans = 0;
if (r == 0) {
int64_t i = 0;
while (i < q) {
ans = ((ans * 10) + 9);
i = (i + 1);
}
} else {
ans = r;
int64_t i = 0;
while (i < q) {
ans = ((ans * 10) + 9);
i = (i + 1);
}
}
return ans;
}
int32_t main(void) {
int64_t FACT9 = 362880;
int64_t f1 = 1;
int64_t f2 = 2;
int64_t f3 = 6;
int64_t f4 = 24;
int64_t f5 = 120;
int64_t f6 = 720;
int64_t f7 = 5040;
int64_t f8 = 40320;
int8_t* counts1 = (int8_t*)(calloc(FACT9, 1));
int8_t* counts2 = (int8_t*)(calloc(FACT9, 1));
int8_t* counts3 = (int8_t*)(calloc(FACT9, 1));
int8_t* counts4 = (int8_t*)(calloc(FACT9, 1));
int8_t* counts5 = (int8_t*)(calloc(FACT9, 1));
int8_t* counts6 = (int8_t*)(calloc(FACT9, 1));
int8_t* counts7 = (int8_t*)(calloc(FACT9, 1));
int8_t* counts8 = (int8_t*)(calloc(FACT9, 1));
int8_t* rem_len = (int8_t*)(calloc(FACT9, 1));
int16_t* rem_sg = (int16_t*)(calloc(FACT9, 2));
int32_t* bucket_sz = (int32_t*)(calloc(9, 4));
int64_t* packed = (int64_t*)(calloc(FACT9, 8));
int8_t* packed_mod = (int8_t*)(calloc(FACT9, 1));
int64_t r = 0;
while (r < FACT9) {
int64_t x = r;
int64_t a8 = FLOW_CHECKED_DIV((x), (f8));
x = FLOW_CHECKED_MOD((x), (f8));
int64_t a7 = FLOW_CHECKED_DIV((x), (f7));
x = FLOW_CHECKED_MOD((x), (f7));
int64_t a6 = FLOW_CHECKED_DIV((x), (f6));
x = FLOW_CHECKED_MOD((x), (f6));
int64_t a5 = FLOW_CHECKED_DIV((x), (f5));
x = FLOW_CHECKED_MOD((x), (f5));
int64_t a4 = FLOW_CHECKED_DIV((x), (f4));
x = FLOW_CHECKED_MOD((x), (f4));
int64_t a3 = FLOW_CHECKED_DIV((x), (f3));
x = FLOW_CHECKED_MOD((x), (f3));
int64_t a2 = FLOW_CHECKED_DIV((x), (f2));
x = FLOW_CHECKED_MOD((x), (f2));
int64_t a1 = FLOW_CHECKED_DIV((x), (f1));
counts1[r] = ((int8_t)(a1));
counts2[r] = ((int8_t)(a2));
counts3[r] = ((int8_t)(a3));
counts4[r] = ((int8_t)(a4));
counts5[r] = ((int8_t)(a5));
counts6[r] = ((int8_t)(a6));
counts7[r] = ((int8_t)(a7));
counts8[r] = ((int8_t)(a8));
int64_t ln = (((((((a1 + a2) + a3) + a4) + a5) + a6) + a7) + a8);
rem_len[r] = ((int8_t)(ln));
rem_sg[r] = ((int16_t)(((((((((1 * a1) + (2 * a2)) + (3 * a3)) + (4 * a4)) + (5 * a5)) + (6 * a6)) + (7 * a7)) + (8 * a8))));
int64_t code = ln;
code = ((code * 9) + (8 - a1));
code = ((code * 9) + (8 - a2));
code = ((code * 9) + (8 - a3));
code = ((code * 9) + (8 - a4));
code = ((code * 9) + (8 - a5));
code = ((code * 9) + (8 - a6));
code = ((code * 9) + (8 - a7));
code = ((code * 9) + (8 - a8));
packed[r] = (FLOW_CHECKED_SHL((code), (19)) | r);
packed_mod[r] = ((int8_t)(FLOW_CHECKED_MOD((r), (9))));
bucket_sz[FLOW_CHECKED_MOD((r), (9))] = (bucket_sz[FLOW_CHECKED_MOD((r), (9))] + 1);
r = (r + 1);
}
int32_t* bucket_off = (int32_t*)(calloc(10, 4));
int64_t m = 0;
while (m < 9) {
bucket_off[(m + 1)] = (bucket_off[m] + bucket_sz[m]);
m = (m + 1);
}
int32_t* buckets = (int32_t*)(calloc(FACT9, 4));
int32_t* fill = (int32_t*)(calloc(9, 4));
m = 0;
while (m < 9) {
fill[m] = bucket_off[m];
m = (m + 1);
}
r = 0;
while (r < FACT9) {
int64_t md = ((int64_t)(packed_mod[r]));
int64_t at = ((int64_t)(fill[md]));
buckets[at] = ((int32_t)(r));
fill[md] = ((int32_t)((at + 1)));
r = (r + 1);
}
m = 0;
while (m < 9) {
int64_t lo = ((int64_t)(bucket_off[m]));
int64_t hi = ((int64_t)(bucket_off[(m + 1)]));
int64_t i = (lo + 1);
while (i < hi) {
int64_t key = ((int64_t)(buckets[i]));
int64_t pk = packed[key];
int64_t j = i;
while (j > lo) {
int64_t prev = ((int64_t)(buckets[(j - 1)]));
if (packed[prev] <= pk) {
break;
}
buckets[j] = ((int32_t)(prev));
j = (j - 1);
}
buckets[j] = ((int32_t)(key));
i = (i + 1);
}
m = (m + 1);
}
int64_t low_lim = (1000000 + FACT9);
int8_t* low_ds = (int8_t*)(calloc(low_lim, 1));
int64_t n = 1;
while (n < low_lim) {
low_ds[n] = ((int8_t)((((int64_t)(low_ds[FLOW_CHECKED_DIV((n), (10))])) + FLOW_CHECKED_MOD((n), (10)))));
n = (n + 1);
}
int64_t total = 0;
int64_t i = 1;
while (i <= 150) {
int64_t kmin = min_number_digit_sum_i64(i);
int64_t qmin = FLOW_CHECKED_DIV((kmin), (FACT9));
int64_t residue = FLOW_CHECKED_MOD((i), (9));
int64_t blo = ((int64_t)(bucket_off[residue]));
int64_t bhi = ((int64_t)(bucket_off[(residue + 1)]));
int64_t best_len = (-1);
int64_t best_c1 = 0;
int64_t best_c2 = 0;
int64_t best_c3 = 0;
int64_t best_c4 = 0;
int64_t best_c5 = 0;
int64_t best_c6 = 0;
int64_t best_c7 = 0;
int64_t best_c8 = 0;
int64_t best_q = 0;
int64_t best_sg = (-1);
bool have = 0;
int64_t delta = 0;
while (delta < 37) {
int64_t q = (qmin + delta);
if ((have && q >= best_len)) {
break;
}
int64_t base = (q * FACT9);
int64_t high = FLOW_CHECKED_DIV((base), (1000000));
int64_t low = FLOW_CHECKED_MOD((base), (1000000));
int64_t sum_high = digit_sum_i64(high);
int64_t sum_high1 = digit_sum_i64((high + 1));
int64_t need0 = (i - sum_high);
int64_t need1 = (i - sum_high1);
if ((need0 < 0 || need0 > 54)) {
need0 = (-1);
}
if ((need1 < 0 || need1 > 54)) {
need1 = (-1);
}
int64_t found_r = (-1);
int64_t bi = blo;
while (bi < bhi) {
int64_t rr = ((int64_t)(buckets[bi]));
int64_t t = (low + rr);
if (t < 1000000) {
if ((need0 >= 0 && ((int64_t)(low_ds[t])) == need0)) {
found_r = rr;
break;
}
} else {
if ((need1 >= 0 && ((int64_t)(low_ds[(t - 1000000)])) == need1)) {
found_r = rr;
break;
}
}
bi = (bi + 1);
}
if (found_r >= 0) {
int64_t ln = ((int64_t)(rem_len[found_r]));
int64_t length_total = (q + ln);
int64_t c1 = ((int64_t)(counts1[found_r]));
int64_t c2 = ((int64_t)(counts2[found_r]));
int64_t c3 = ((int64_t)(counts3[found_r]));
int64_t c4 = ((int64_t)(counts4[found_r]));
int64_t c5 = ((int64_t)(counts5[found_r]));
int64_t c6 = ((int64_t)(counts6[found_r]));
int64_t c7 = ((int64_t)(counts7[found_r]));
int64_t c8 = ((int64_t)(counts8[found_r]));
bool better = 0;
if ((!(have))) {
better = 1;
} else if (length_total < best_len) {
better = 1;
} else if (length_total == best_len) {
if (c1 > best_c1) {
better = 1;
} else if ((c1 == best_c1 && c2 > best_c2)) {
better = 1;
} else if (((c1 == best_c1 && c2 == best_c2) && c3 > best_c3)) {
better = 1;
} else if ((((c1 == best_c1 && c2 == best_c2) && c3 == best_c3) && c4 > best_c4)) {
better = 1;
} else if (((((c1 == best_c1 && c2 == best_c2) && c3 == best_c3) && c4 == best_c4) && c5 > best_c5)) {
better = 1;
} else if ((((((c1 == best_c1 && c2 == best_c2) && c3 == best_c3) && c4 == best_c4) && c5 == best_c5) && c6 > best_c6)) {
better = 1;
} else if (((((((c1 == best_c1 && c2 == best_c2) && c3 == best_c3) && c4 == best_c4) && c5 == best_c5) && c6 == best_c6) && c7 > best_c7)) {
better = 1;
} else if ((((((((c1 == best_c1 && c2 == best_c2) && c3 == best_c3) && c4 == best_c4) && c5 == best_c5) && c6 == best_c6) && c7 == best_c7) && c8 > best_c8)) {
better = 1;
} else if (((((((((c1 == best_c1 && c2 == best_c2) && c3 == best_c3) && c4 == best_c4) && c5 == best_c5) && c6 == best_c6) && c7 == best_c7) && c8 == best_c8) && q > best_q)) {
better = 1;
}
}
if (better) {
have = 1;
best_len = length_total;
best_c1 = c1;
best_c2 = c2;
best_c3 = c3;
best_c4 = c4;
best_c5 = c5;
best_c6 = c6;
best_c7 = c7;
best_c8 = c8;
best_q = q;
best_sg = (((int64_t)(rem_sg[found_r])) + (9 * q));
}
}
delta = (delta + 1);
}
total = (total + best_sg);
i = (i + 1);
}
printf("%lld\n", total);
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) -> ()
func.func @digit_sum(%arg0: i64) -> i64 {
%0 = llvm.mlir.constant(1 : i64) : i64
%1 = llvm.alloca %0 x i64 : (i64) -> !llvm.ptr
llvm.store %arg0, %1 : i64, !llvm.ptr
%2 = arith.constant 0 : i32
%3 = arith.extsi %2 : i32 to i64
%4 = llvm.mlir.constant(1 : i64) : i64
%5 = llvm.alloca %4 x i64 : (i64) -> !llvm.ptr
llvm.store %3, %5 : i64, !llvm.ptr
%6 = llvm.load %1 : !llvm.ptr -> i64
%7 = arith.constant 0 : i32
%9 = arith.extsi %7 : i32 to i64
%8 = arith.cmpi slt, %6, %9 : i64
cf.cond_br %8, ^bb0, ^bb1
^bb0:
%10 = llvm.load %1 : !llvm.ptr -> i64
%12 = arith.constant 0 : i64
%11 = arith.subi %12, %10 : i64
llvm.store %11, %1 : i64, !llvm.ptr
cf.br ^bb2
^bb1:
cf.br ^bb2
^bb2:
cf.br ^bb3
^bb3:
%13 = llvm.load %1 : !llvm.ptr -> i64
%14 = arith.constant 0 : i32
%16 = arith.extsi %14 : i32 to i64
%15 = arith.cmpi sgt, %13, %16 : i64
cf.cond_br %15, ^bb4, ^bb5
^bb4:
%17 = llvm.load %5 : !llvm.ptr -> i64
%18 = llvm.load %1 : !llvm.ptr -> i64
%19 = arith.constant 10 : i32
%21 = arith.extsi %19 : i32 to i64
%20 = arith.remsi %18, %21 : i64
%22 = arith.addi %17, %20 : i64
llvm.store %22, %5 : i64, !llvm.ptr
%23 = llvm.load %1 : !llvm.ptr -> i64
%24 = arith.constant 10 : i32
%26 = arith.extsi %24 : i32 to i64
%25 = arith.divsi %23, %26 : i64
llvm.store %25, %1 : i64, !llvm.ptr
cf.br ^bb3
^bb5:
%27 = llvm.load %5 : !llvm.ptr -> i64
func.return %27 : i64
}
func.func @min_number_digit_sum(%arg0: i64) -> i64 {
%28 = arith.constant 9 : i32
%30 = arith.extsi %28 : i32 to i64
%29 = arith.divsi %arg0, %30 : i64
%31 = arith.constant 9 : i32
%33 = arith.extsi %31 : i32 to i64
%32 = arith.remsi %arg0, %33 : i64
%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 = arith.constant 0 : i32
%40 = arith.extsi %38 : i32 to i64
%39 = arith.cmpi eq, %32, %40 : i64
cf.cond_br %39, ^bb6, ^bb7
^bb6:
%41 = arith.constant 0 : i32
%42 = arith.extsi %41 : i32 to i64
%43 = llvm.mlir.constant(1 : i64) : i64
%44 = llvm.alloca %43 x i64 : (i64) -> !llvm.ptr
llvm.store %42, %44 : i64, !llvm.ptr
cf.br ^bb9
^bb9:
%45 = llvm.load %44 : !llvm.ptr -> i64
%46 = arith.cmpi slt, %45, %29 : i64
cf.cond_br %46, ^bb10, ^bb11
^bb10:
%47 = llvm.load %37 : !llvm.ptr -> i64
%48 = arith.constant 10 : i32
%50 = arith.extsi %48 : i32 to i64
%49 = arith.muli %47, %50 : i64
%51 = arith.constant 9 : i32
%53 = arith.extsi %51 : i32 to i64
%52 = arith.addi %49, %53 : i64
llvm.store %52, %37 : i64, !llvm.ptr
%54 = llvm.load %44 : !llvm.ptr -> i64
%55 = arith.constant 1 : i32
%57 = arith.extsi %55 : i32 to i64
%56 = arith.addi %54, %57 : i64
llvm.store %56, %44 : i64, !llvm.ptr
cf.br ^bb9
^bb11:
cf.br ^bb8
^bb7:
llvm.store %32, %37 : i64, !llvm.ptr
%58 = arith.constant 0 : i32
%59 = arith.extsi %58 : i32 to i64
%60 = llvm.mlir.constant(1 : i64) : i64
%61 = llvm.alloca %60 x i64 : (i64) -> !llvm.ptr
llvm.store %59, %61 : i64, !llvm.ptr
cf.br ^bb12
^bb12:
%62 = llvm.load %61 : !llvm.ptr -> i64
%63 = arith.cmpi slt, %62, %29 : i64
cf.cond_br %63, ^bb13, ^bb14
^bb13:
%64 = llvm.load %37 : !llvm.ptr -> i64
%65 = arith.constant 10 : i32
%67 = arith.extsi %65 : i32 to i64
%66 = arith.muli %64, %67 : i64
%68 = arith.constant 9 : i32
%70 = arith.extsi %68 : i32 to i64
%69 = arith.addi %66, %70 : i64
llvm.store %69, %37 : i64, !llvm.ptr
%71 = llvm.load %61 : !llvm.ptr -> i64
%72 = arith.constant 1 : i32
%74 = arith.extsi %72 : i32 to i64
%73 = arith.addi %71, %74 : i64
llvm.store %73, %61 : i64, !llvm.ptr
cf.br ^bb12
^bb14:
cf.br ^bb8
^bb8:
%75 = llvm.load %37 : !llvm.ptr -> i64
func.return %75 : i64
}
func.func @main() -> i32 {
%76 = arith.constant 362880 : i32
%77 = arith.extsi %76 : i32 to i64
%78 = arith.constant 1 : i32
%79 = arith.extsi %78 : i32 to i64
%80 = arith.constant 2 : i32
%81 = arith.extsi %80 : i32 to i64
%82 = arith.constant 6 : i32
%83 = arith.extsi %82 : i32 to i64
%84 = arith.constant 24 : i32
%85 = arith.extsi %84 : i32 to i64
%86 = arith.constant 120 : i32
%87 = arith.extsi %86 : i32 to i64
%88 = arith.constant 720 : i32
%89 = arith.extsi %88 : i32 to i64
%90 = arith.constant 5040 : i32
%91 = arith.extsi %90 : i32 to i64
%92 = arith.constant 40320 : i32
%93 = arith.extsi %92 : i32 to i64
%95 = arith.constant 1 : i32
%96 = arith.extsi %95 : i32 to i64
%94 = func.call @calloc(%77, %96) : (i64, i64) -> !llvm.ptr
%98 = arith.constant 1 : i32
%99 = arith.extsi %98 : i32 to i64
%97 = func.call @calloc(%77, %99) : (i64, i64) -> !llvm.ptr
%101 = arith.constant 1 : i32
%102 = arith.extsi %101 : i32 to i64
%100 = func.call @calloc(%77, %102) : (i64, i64) -> !llvm.ptr
%104 = arith.constant 1 : i32
%105 = arith.extsi %104 : i32 to i64
%103 = func.call @calloc(%77, %105) : (i64, i64) -> !llvm.ptr
%107 = arith.constant 1 : i32
%108 = arith.extsi %107 : i32 to i64
%106 = func.call @calloc(%77, %108) : (i64, i64) -> !llvm.ptr
%110 = arith.constant 1 : i32
%111 = arith.extsi %110 : i32 to i64
%109 = func.call @calloc(%77, %111) : (i64, i64) -> !llvm.ptr
%113 = arith.constant 1 : i32
%114 = arith.extsi %113 : i32 to i64
%112 = func.call @calloc(%77, %114) : (i64, i64) -> !llvm.ptr
%116 = arith.constant 1 : i32
%117 = arith.extsi %116 : i32 to i64
%115 = func.call @calloc(%77, %117) : (i64, i64) -> !llvm.ptr
%119 = arith.constant 1 : i32
%120 = arith.extsi %119 : i32 to i64
%118 = func.call @calloc(%77, %120) : (i64, i64) -> !llvm.ptr
%122 = arith.constant 2 : i32
%123 = arith.extsi %122 : i32 to i64
%121 = func.call @calloc(%77, %123) : (i64, i64) -> !llvm.ptr
%125 = arith.constant 9 : i32
%126 = arith.constant 4 : i32
%127 = arith.extsi %125 : i32 to i64
%128 = arith.extsi %126 : i32 to i64
%124 = func.call @calloc(%127, %128) : (i64, i64) -> !llvm.ptr
%130 = arith.constant 8 : i32
%131 = arith.extsi %130 : i32 to i64
%129 = func.call @calloc(%77, %131) : (i64, i64) -> !llvm.ptr
%133 = arith.constant 1 : i32
%134 = arith.extsi %133 : i32 to i64
%132 = func.call @calloc(%77, %134) : (i64, i64) -> !llvm.ptr
%135 = arith.constant 0 : i32
%136 = arith.extsi %135 : i32 to i64
%137 = llvm.mlir.constant(1 : i64) : i64
%138 = llvm.alloca %137 x i64 : (i64) -> !llvm.ptr
llvm.store %136, %138 : i64, !llvm.ptr
cf.br ^bb15
^bb15:
%139 = llvm.load %138 : !llvm.ptr -> i64
%140 = arith.cmpi slt, %139, %77 : i64
cf.cond_br %140, ^bb16, ^bb17
^bb16:
%141 = llvm.load %138 : !llvm.ptr -> i64
%142 = llvm.mlir.constant(1 : i64) : i64
%143 = llvm.alloca %142 x i64 : (i64) -> !llvm.ptr
llvm.store %141, %143 : i64, !llvm.ptr
%144 = llvm.load %143 : !llvm.ptr -> i64
%145 = arith.divsi %144, %93 : i64
%146 = llvm.load %143 : !llvm.ptr -> i64
%147 = arith.remsi %146, %93 : i64
llvm.store %147, %143 : i64, !llvm.ptr
%148 = llvm.load %143 : !llvm.ptr -> i64
%149 = arith.divsi %148, %91 : i64
%150 = llvm.load %143 : !llvm.ptr -> i64
%151 = arith.remsi %150, %91 : i64
llvm.store %151, %143 : i64, !llvm.ptr
%152 = llvm.load %143 : !llvm.ptr -> i64
%153 = arith.divsi %152, %89 : i64
%154 = llvm.load %143 : !llvm.ptr -> i64
%155 = arith.remsi %154, %89 : i64
llvm.store %155, %143 : i64, !llvm.ptr
%156 = llvm.load %143 : !llvm.ptr -> i64
%157 = arith.divsi %156, %87 : i64
%158 = llvm.load %143 : !llvm.ptr -> i64
%159 = arith.remsi %158, %87 : i64
llvm.store %159, %143 : i64, !llvm.ptr
%160 = llvm.load %143 : !llvm.ptr -> i64
%161 = arith.divsi %160, %85 : i64
%162 = llvm.load %143 : !llvm.ptr -> i64
%163 = arith.remsi %162, %85 : i64
llvm.store %163, %143 : i64, !llvm.ptr
%164 = llvm.load %143 : !llvm.ptr -> i64
%165 = arith.divsi %164, %83 : i64
%166 = llvm.load %143 : !llvm.ptr -> i64
%167 = arith.remsi %166, %83 : i64
llvm.store %167, %143 : i64, !llvm.ptr
%168 = llvm.load %143 : !llvm.ptr -> i64
%169 = arith.divsi %168, %81 : i64
%170 = llvm.load %143 : !llvm.ptr -> i64
%171 = arith.remsi %170, %81 : i64
llvm.store %171, %143 : i64, !llvm.ptr
%172 = llvm.load %143 : !llvm.ptr -> i64
%173 = arith.divsi %172, %79 : i64
%174 = arith.trunci %173 : i64 to i8
%175 = llvm.load %138 : !llvm.ptr -> i64
%176 = llvm.getelementptr %94[%175] : (!llvm.ptr, i64) -> !llvm.ptr, i8
llvm.store %174, %176 : i8, !llvm.ptr
%177 = arith.trunci %169 : i64 to i8
%178 = llvm.load %138 : !llvm.ptr -> i64
%179 = llvm.getelementptr %97[%178] : (!llvm.ptr, i64) -> !llvm.ptr, i8
llvm.store %177, %179 : i8, !llvm.ptr
%180 = arith.trunci %165 : i64 to i8
%181 = llvm.load %138 : !llvm.ptr -> i64
%182 = llvm.getelementptr %100[%181] : (!llvm.ptr, i64) -> !llvm.ptr, i8
llvm.store %180, %182 : i8, !llvm.ptr
%183 = arith.trunci %161 : i64 to i8
%184 = llvm.load %138 : !llvm.ptr -> i64
%185 = llvm.getelementptr %103[%184] : (!llvm.ptr, i64) -> !llvm.ptr, i8
llvm.store %183, %185 : i8, !llvm.ptr
%186 = arith.trunci %157 : i64 to i8
%187 = llvm.load %138 : !llvm.ptr -> i64
%188 = llvm.getelementptr %106[%187] : (!llvm.ptr, i64) -> !llvm.ptr, i8
llvm.store %186, %188 : i8, !llvm.ptr
%189 = arith.trunci %153 : i64 to i8
%190 = llvm.load %138 : !llvm.ptr -> i64
%191 = llvm.getelementptr %109[%190] : (!llvm.ptr, i64) -> !llvm.ptr, i8
llvm.store %189, %191 : i8, !llvm.ptr
%192 = arith.trunci %149 : i64 to i8
%193 = llvm.load %138 : !llvm.ptr -> i64
%194 = llvm.getelementptr %112[%193] : (!llvm.ptr, i64) -> !llvm.ptr, i8
llvm.store %192, %194 : i8, !llvm.ptr
%195 = arith.trunci %145 : i64 to i8
%196 = llvm.load %138 : !llvm.ptr -> i64
%197 = llvm.getelementptr %115[%196] : (!llvm.ptr, i64) -> !llvm.ptr, i8
llvm.store %195, %197 : i8, !llvm.ptr
%198 = arith.addi %173, %169 : i64
%199 = arith.addi %198, %165 : i64
%200 = arith.addi %199, %161 : i64
%201 = arith.addi %200, %157 : i64
%202 = arith.addi %201, %153 : i64
%203 = arith.addi %202, %149 : i64
%204 = arith.addi %203, %145 : i64
%205 = arith.trunci %204 : i64 to i8
%206 = llvm.load %138 : !llvm.ptr -> i64
%207 = llvm.getelementptr %118[%206] : (!llvm.ptr, i64) -> !llvm.ptr, i8
llvm.store %205, %207 : i8, !llvm.ptr
%208 = arith.constant 1 : i32
%210 = arith.extsi %208 : i32 to i64
%209 = arith.muli %210, %173 : i64
%211 = arith.constant 2 : i32
%213 = arith.extsi %211 : i32 to i64
%212 = arith.muli %213, %169 : i64
%214 = arith.addi %209, %212 : i64
%215 = arith.constant 3 : i32
%217 = arith.extsi %215 : i32 to i64
%216 = arith.muli %217, %165 : i64
%218 = arith.addi %214, %216 : i64
%219 = arith.constant 4 : i32
%221 = arith.extsi %219 : i32 to i64
%220 = arith.muli %221, %161 : i64
%222 = arith.addi %218, %220 : i64
%223 = arith.constant 5 : i32
%225 = arith.extsi %223 : i32 to i64
%224 = arith.muli %225, %157 : i64
%226 = arith.addi %222, %224 : i64
%227 = arith.constant 6 : i32
%229 = arith.extsi %227 : i32 to i64
%228 = arith.muli %229, %153 : i64
%230 = arith.addi %226, %228 : i64
%231 = arith.constant 7 : i32
%233 = arith.extsi %231 : i32 to i64
%232 = arith.muli %233, %149 : i64
%234 = arith.addi %230, %232 : i64
%235 = arith.constant 8 : i32
%237 = arith.extsi %235 : i32 to i64
%236 = arith.muli %237, %145 : i64
%238 = arith.addi %234, %236 : i64
%239 = arith.trunci %238 : i64 to i16
%240 = llvm.load %138 : !llvm.ptr -> i64
%241 = llvm.getelementptr %121[%240] : (!llvm.ptr, i64) -> !llvm.ptr, i16
llvm.store %239, %241 : i16, !llvm.ptr
%242 = llvm.mlir.constant(1 : i64) : i64
%243 = llvm.alloca %242 x i64 : (i64) -> !llvm.ptr
llvm.store %204, %243 : i64, !llvm.ptr
%244 = llvm.load %243 : !llvm.ptr -> i64
%245 = arith.constant 9 : i32
%247 = arith.extsi %245 : i32 to i64
%246 = arith.muli %244, %247 : i64
%248 = arith.constant 8 : i32
%250 = arith.extsi %248 : i32 to i64
%249 = arith.subi %250, %173 : i64
%251 = arith.addi %246, %249 : i64
llvm.store %251, %243 : i64, !llvm.ptr
%252 = llvm.load %243 : !llvm.ptr -> i64
%253 = arith.constant 9 : i32
%255 = arith.extsi %253 : i32 to i64
%254 = arith.muli %252, %255 : i64
%256 = arith.constant 8 : i32
%258 = arith.extsi %256 : i32 to i64
%257 = arith.subi %258, %169 : i64
%259 = arith.addi %254, %257 : i64
llvm.store %259, %243 : i64, !llvm.ptr
%260 = llvm.load %243 : !llvm.ptr -> i64
%261 = arith.constant 9 : i32
%263 = arith.extsi %261 : i32 to i64
%262 = arith.muli %260, %263 : i64
%264 = arith.constant 8 : i32
%266 = arith.extsi %264 : i32 to i64
%265 = arith.subi %266, %165 : i64
%267 = arith.addi %262, %265 : i64
llvm.store %267, %243 : i64, !llvm.ptr
%268 = llvm.load %243 : !llvm.ptr -> i64
%269 = arith.constant 9 : i32
%271 = arith.extsi %269 : i32 to i64
%270 = arith.muli %268, %271 : i64
%272 = arith.constant 8 : i32
%274 = arith.extsi %272 : i32 to i64
%273 = arith.subi %274, %161 : i64
%275 = arith.addi %270, %273 : i64
llvm.store %275, %243 : i64, !llvm.ptr
%276 = llvm.load %243 : !llvm.ptr -> i64
%277 = arith.constant 9 : i32
%279 = arith.extsi %277 : i32 to i64
%278 = arith.muli %276, %279 : i64
%280 = arith.constant 8 : i32
%282 = arith.extsi %280 : i32 to i64
%281 = arith.subi %282, %157 : i64
%283 = arith.addi %278, %281 : i64
llvm.store %283, %243 : i64, !llvm.ptr
%284 = llvm.load %243 : !llvm.ptr -> i64
%285 = arith.constant 9 : i32
%287 = arith.extsi %285 : i32 to i64
%286 = arith.muli %284, %287 : i64
%288 = arith.constant 8 : i32
%290 = arith.extsi %288 : i32 to i64
%289 = arith.subi %290, %153 : i64
%291 = arith.addi %286, %289 : i64
llvm.store %291, %243 : i64, !llvm.ptr
%292 = llvm.load %243 : !llvm.ptr -> i64
%293 = arith.constant 9 : i32
%295 = arith.extsi %293 : i32 to i64
%294 = arith.muli %292, %295 : i64
%296 = arith.constant 8 : i32
%298 = arith.extsi %296 : i32 to i64
%297 = arith.subi %298, %149 : i64
%299 = arith.addi %294, %297 : i64
llvm.store %299, %243 : i64, !llvm.ptr
%300 = llvm.load %243 : !llvm.ptr -> i64
%301 = arith.constant 9 : i32
%303 = arith.extsi %301 : i32 to i64
%302 = arith.muli %300, %303 : i64
%304 = arith.constant 8 : i32
%306 = arith.extsi %304 : i32 to i64
%305 = arith.subi %306, %145 : i64
%307 = arith.addi %302, %305 : i64
llvm.store %307, %243 : i64, !llvm.ptr
%308 = llvm.load %243 : !llvm.ptr -> i64
%309 = arith.constant 19 : i32
%311 = arith.extsi %309 : i32 to i64
%310 = arith.shli %308, %311 : i64
%312 = llvm.load %138 : !llvm.ptr -> i64
%313 = arith.ori %310, %312 : i64
%314 = llvm.load %138 : !llvm.ptr -> i64
%315 = llvm.getelementptr %129[%314] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %313, %315 : i64, !llvm.ptr
%316 = llvm.load %138 : !llvm.ptr -> i64
%317 = arith.constant 9 : i32
%319 = arith.extsi %317 : i32 to i64
%318 = arith.remsi %316, %319 : i64
%320 = arith.trunci %318 : i64 to i8
%321 = llvm.load %138 : !llvm.ptr -> i64
%322 = llvm.getelementptr %132[%321] : (!llvm.ptr, i64) -> !llvm.ptr, i8
llvm.store %320, %322 : i8, !llvm.ptr
%324 = llvm.load %138 : !llvm.ptr -> i64
%325 = arith.constant 9 : i32
%327 = arith.extsi %325 : i32 to i64
%326 = arith.remsi %324, %327 : i64
%328 = llvm.getelementptr %124[%326] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%323 = llvm.load %328 : !llvm.ptr -> i32
%329 = arith.constant 1 : i32
%330 = arith.addi %323, %329 : i32
%331 = llvm.load %138 : !llvm.ptr -> i64
%332 = arith.constant 9 : i32
%334 = arith.extsi %332 : i32 to i64
%333 = arith.remsi %331, %334 : i64
%335 = llvm.getelementptr %124[%333] : (!llvm.ptr, i64) -> !llvm.ptr, i32
llvm.store %330, %335 : i32, !llvm.ptr
%336 = llvm.load %138 : !llvm.ptr -> i64
%337 = arith.constant 1 : i32
%339 = arith.extsi %337 : i32 to i64
%338 = arith.addi %336, %339 : i64
llvm.store %338, %138 : i64, !llvm.ptr
cf.br ^bb15
^bb17:
%341 = arith.constant 10 : i32
%342 = arith.constant 4 : i32
%343 = arith.extsi %341 : i32 to i64
%344 = arith.extsi %342 : i32 to i64
%340 = func.call @calloc(%343, %344) : (i64, i64) -> !llvm.ptr
%345 = arith.constant 0 : i32
%346 = arith.extsi %345 : i32 to i64
%347 = llvm.mlir.constant(1 : i64) : i64
%348 = llvm.alloca %347 x i64 : (i64) -> !llvm.ptr
llvm.store %346, %348 : i64, !llvm.ptr
cf.br ^bb18
^bb18:
%349 = llvm.load %348 : !llvm.ptr -> i64
%350 = arith.constant 9 : i32
%352 = arith.extsi %350 : i32 to i64
%351 = arith.cmpi slt, %349, %352 : i64
cf.cond_br %351, ^bb19, ^bb20
^bb19:
%354 = llvm.load %348 : !llvm.ptr -> i64
%355 = llvm.getelementptr %340[%354] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%353 = llvm.load %355 : !llvm.ptr -> i32
%357 = llvm.load %348 : !llvm.ptr -> i64
%358 = llvm.getelementptr %124[%357] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%356 = llvm.load %358 : !llvm.ptr -> i32
%359 = arith.addi %353, %356 : i32
%360 = llvm.load %348 : !llvm.ptr -> i64
%361 = arith.constant 1 : i32
%363 = arith.extsi %361 : i32 to i64
%362 = arith.addi %360, %363 : i64
%364 = llvm.getelementptr %340[%362] : (!llvm.ptr, i64) -> !llvm.ptr, i32
llvm.store %359, %364 : i32, !llvm.ptr
%365 = llvm.load %348 : !llvm.ptr -> i64
%366 = arith.constant 1 : i32
%368 = arith.extsi %366 : i32 to i64
%367 = arith.addi %365, %368 : i64
llvm.store %367, %348 : i64, !llvm.ptr
cf.br ^bb18
^bb20:
%370 = arith.constant 4 : i32
%371 = arith.extsi %370 : i32 to i64
%369 = func.call @calloc(%77, %371) : (i64, i64) -> !llvm.ptr
%373 = arith.constant 9 : i32
%374 = arith.constant 4 : i32
%375 = arith.extsi %373 : i32 to i64
%376 = arith.extsi %374 : i32 to i64
%372 = func.call @calloc(%375, %376) : (i64, i64) -> !llvm.ptr
%377 = arith.constant 0 : i32
%378 = arith.extsi %377 : i32 to i64
llvm.store %378, %348 : i64, !llvm.ptr
cf.br ^bb21
^bb21:
%379 = llvm.load %348 : !llvm.ptr -> i64
%380 = arith.constant 9 : i32
%382 = arith.extsi %380 : i32 to i64
%381 = arith.cmpi slt, %379, %382 : i64
cf.cond_br %381, ^bb22, ^bb23
^bb22:
%384 = llvm.load %348 : !llvm.ptr -> i64
%385 = llvm.getelementptr %340[%384] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%383 = llvm.load %385 : !llvm.ptr -> i32
%386 = llvm.load %348 : !llvm.ptr -> i64
%387 = llvm.getelementptr %372[%386] : (!llvm.ptr, i64) -> !llvm.ptr, i32
llvm.store %383, %387 : i32, !llvm.ptr
%388 = llvm.load %348 : !llvm.ptr -> i64
%389 = arith.constant 1 : i32
%391 = arith.extsi %389 : i32 to i64
%390 = arith.addi %388, %391 : i64
llvm.store %390, %348 : i64, !llvm.ptr
cf.br ^bb21
^bb23:
%392 = arith.constant 0 : i32
%393 = arith.extsi %392 : i32 to i64
llvm.store %393, %138 : i64, !llvm.ptr
cf.br ^bb24
^bb24:
%394 = llvm.load %138 : !llvm.ptr -> i64
%395 = arith.cmpi slt, %394, %77 : i64
cf.cond_br %395, ^bb25, ^bb26
^bb25:
%397 = llvm.load %138 : !llvm.ptr -> i64
%398 = llvm.getelementptr %132[%397] : (!llvm.ptr, i64) -> !llvm.ptr, i8
%396 = llvm.load %398 : !llvm.ptr -> i8
%399 = arith.extsi %396 : i8 to i64
%401 = llvm.getelementptr %372[%399] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%400 = llvm.load %401 : !llvm.ptr -> i32
%402 = arith.extsi %400 : i32 to i64
%403 = llvm.load %138 : !llvm.ptr -> i64
%404 = arith.trunci %403 : i64 to i32
%405 = llvm.getelementptr %369[%402] : (!llvm.ptr, i64) -> !llvm.ptr, i32
llvm.store %404, %405 : i32, !llvm.ptr
%406 = arith.constant 1 : i32
%408 = arith.extsi %406 : i32 to i64
%407 = arith.addi %402, %408 : i64
%409 = arith.trunci %407 : i64 to i32
%410 = llvm.getelementptr %372[%399] : (!llvm.ptr, i64) -> !llvm.ptr, i32
llvm.store %409, %410 : i32, !llvm.ptr
%411 = llvm.load %138 : !llvm.ptr -> i64
%412 = arith.constant 1 : i32
%414 = arith.extsi %412 : i32 to i64
%413 = arith.addi %411, %414 : i64
llvm.store %413, %138 : i64, !llvm.ptr
cf.br ^bb24
^bb26:
%415 = arith.constant 0 : i32
%416 = arith.extsi %415 : i32 to i64
llvm.store %416, %348 : i64, !llvm.ptr
cf.br ^bb27
^bb27:
%417 = llvm.load %348 : !llvm.ptr -> i64
%418 = arith.constant 9 : i32
%420 = arith.extsi %418 : i32 to i64
%419 = arith.cmpi slt, %417, %420 : i64
cf.cond_br %419, ^bb28, ^bb29
^bb28:
%422 = llvm.load %348 : !llvm.ptr -> i64
%423 = llvm.getelementptr %340[%422] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%421 = llvm.load %423 : !llvm.ptr -> i32
%424 = arith.extsi %421 : i32 to i64
%426 = llvm.load %348 : !llvm.ptr -> i64
%427 = arith.constant 1 : i32
%429 = arith.extsi %427 : i32 to i64
%428 = arith.addi %426, %429 : i64
%430 = llvm.getelementptr %340[%428] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%425 = llvm.load %430 : !llvm.ptr -> i32
%431 = arith.extsi %425 : i32 to i64
%432 = arith.constant 1 : i32
%434 = arith.extsi %432 : i32 to i64
%433 = arith.addi %424, %434 : i64
%435 = llvm.mlir.constant(1 : i64) : i64
%436 = llvm.alloca %435 x i64 : (i64) -> !llvm.ptr
llvm.store %433, %436 : i64, !llvm.ptr
cf.br ^bb30
^bb30:
%437 = llvm.load %436 : !llvm.ptr -> i64
%438 = arith.cmpi slt, %437, %431 : i64
cf.cond_br %438, ^bb31, ^bb32
^bb31:
%440 = llvm.load %436 : !llvm.ptr -> i64
%441 = llvm.getelementptr %369[%440] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%439 = llvm.load %441 : !llvm.ptr -> i32
%442 = arith.extsi %439 : i32 to i64
%444 = llvm.getelementptr %129[%442] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%443 = llvm.load %444 : !llvm.ptr -> i64
%445 = llvm.load %436 : !llvm.ptr -> i64
%446 = llvm.mlir.constant(1 : i64) : i64
%447 = llvm.alloca %446 x i64 : (i64) -> !llvm.ptr
llvm.store %445, %447 : i64, !llvm.ptr
cf.br ^bb33
^bb33:
%448 = llvm.load %447 : !llvm.ptr -> i64
%449 = arith.cmpi sgt, %448, %424 : i64
cf.cond_br %449, ^bb34, ^bb35
^bb34:
%451 = llvm.load %447 : !llvm.ptr -> i64
%452 = arith.constant 1 : i32
%454 = arith.extsi %452 : i32 to i64
%453 = arith.subi %451, %454 : i64
%455 = llvm.getelementptr %369[%453] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%450 = llvm.load %455 : !llvm.ptr -> i32
%456 = arith.extsi %450 : i32 to i64
%458 = llvm.getelementptr %129[%456] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%457 = llvm.load %458 : !llvm.ptr -> i64
%459 = arith.cmpi sle, %457, %443 : i64
cf.cond_br %459, ^bb36, ^bb37
^bb36:
cf.br ^bb35
^bb37:
cf.br ^bb38
^bb38:
%460 = arith.trunci %456 : i64 to i32
%461 = llvm.load %447 : !llvm.ptr -> i64
%462 = llvm.getelementptr %369[%461] : (!llvm.ptr, i64) -> !llvm.ptr, i32
llvm.store %460, %462 : i32, !llvm.ptr
%463 = llvm.load %447 : !llvm.ptr -> i64
%464 = arith.constant 1 : i32
%466 = arith.extsi %464 : i32 to i64
%465 = arith.subi %463, %466 : i64
llvm.store %465, %447 : i64, !llvm.ptr
cf.br ^bb33
^bb35:
%467 = arith.trunci %442 : i64 to i32
%468 = llvm.load %447 : !llvm.ptr -> i64
%469 = llvm.getelementptr %369[%468] : (!llvm.ptr, i64) -> !llvm.ptr, i32
llvm.store %467, %469 : i32, !llvm.ptr
%470 = llvm.load %436 : !llvm.ptr -> i64
%471 = arith.constant 1 : i32
%473 = arith.extsi %471 : i32 to i64
%472 = arith.addi %470, %473 : i64
llvm.store %472, %436 : i64, !llvm.ptr
cf.br ^bb30
^bb32:
%474 = llvm.load %348 : !llvm.ptr -> i64
%475 = arith.constant 1 : i32
%477 = arith.extsi %475 : i32 to i64
%476 = arith.addi %474, %477 : i64
llvm.store %476, %348 : i64, !llvm.ptr
cf.br ^bb27
^bb29:
%478 = arith.constant 1000000 : i32
%480 = arith.extsi %478 : i32 to i64
%479 = arith.addi %480, %77 : i64
%482 = arith.constant 1 : i32
%483 = arith.extsi %482 : i32 to i64
%481 = func.call @calloc(%479, %483) : (i64, i64) -> !llvm.ptr
%484 = arith.constant 1 : i32
%485 = arith.extsi %484 : i32 to i64
%486 = llvm.mlir.constant(1 : i64) : i64
%487 = llvm.alloca %486 x i64 : (i64) -> !llvm.ptr
llvm.store %485, %487 : i64, !llvm.ptr
cf.br ^bb39
^bb39:
%488 = llvm.load %487 : !llvm.ptr -> i64
%489 = arith.cmpi slt, %488, %479 : i64
cf.cond_br %489, ^bb40, ^bb41
^bb40:
%491 = llvm.load %487 : !llvm.ptr -> i64
%492 = arith.constant 10 : i32
%494 = arith.extsi %492 : i32 to i64
%493 = arith.divsi %491, %494 : i64
%495 = llvm.getelementptr %481[%493] : (!llvm.ptr, i64) -> !llvm.ptr, i8
%490 = llvm.load %495 : !llvm.ptr -> i8
%496 = arith.extsi %490 : i8 to i64
%497 = llvm.load %487 : !llvm.ptr -> i64
%498 = arith.constant 10 : i32
%500 = arith.extsi %498 : i32 to i64
%499 = arith.remsi %497, %500 : i64
%501 = arith.addi %496, %499 : i64
%502 = arith.trunci %501 : i64 to i8
%503 = llvm.load %487 : !llvm.ptr -> i64
%504 = llvm.getelementptr %481[%503] : (!llvm.ptr, i64) -> !llvm.ptr, i8
llvm.store %502, %504 : i8, !llvm.ptr
%505 = llvm.load %487 : !llvm.ptr -> i64
%506 = arith.constant 1 : i32
%508 = arith.extsi %506 : i32 to i64
%507 = arith.addi %505, %508 : i64
llvm.store %507, %487 : i64, !llvm.ptr
cf.br ^bb39
^bb41:
%509 = arith.constant 0 : i32
%510 = arith.extsi %509 : i32 to i64
%511 = llvm.mlir.constant(1 : i64) : i64
%512 = llvm.alloca %511 x i64 : (i64) -> !llvm.ptr
llvm.store %510, %512 : i64, !llvm.ptr
%513 = arith.constant 1 : i32
%514 = arith.extsi %513 : i32 to i64
%515 = llvm.mlir.constant(1 : i64) : i64
%516 = llvm.alloca %515 x i64 : (i64) -> !llvm.ptr
llvm.store %514, %516 : i64, !llvm.ptr
cf.br ^bb42
^bb42:
%517 = llvm.load %516 : !llvm.ptr -> i64
%518 = arith.constant 150 : i32
%520 = arith.extsi %518 : i32 to i64
%519 = arith.cmpi sle, %517, %520 : i64
cf.cond_br %519, ^bb43, ^bb44
^bb43:
%522 = llvm.load %516 : !llvm.ptr -> i64
%521 = func.call @min_number_digit_sum(%522) : (i64) -> i64
%523 = arith.divsi %521, %77 : i64
%524 = llvm.load %516 : !llvm.ptr -> i64
%525 = arith.constant 9 : i32
%527 = arith.extsi %525 : i32 to i64
%526 = arith.remsi %524, %527 : i64
%529 = llvm.getelementptr %340[%526] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%528 = llvm.load %529 : !llvm.ptr -> i32
%530 = arith.extsi %528 : i32 to i64
%532 = arith.constant 1 : i32
%534 = arith.extsi %532 : i32 to i64
%533 = arith.addi %526, %534 : i64
%535 = llvm.getelementptr %340[%533] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%531 = llvm.load %535 : !llvm.ptr -> i32
%536 = arith.extsi %531 : i32 to i64
%537 = arith.constant 1 : i32
%539 = arith.constant 0 : i32
%538 = arith.subi %539, %537 : i32
%540 = arith.extsi %538 : i32 to i64
%541 = llvm.mlir.constant(1 : i64) : i64
%542 = llvm.alloca %541 x i64 : (i64) -> !llvm.ptr
llvm.store %540, %542 : i64, !llvm.ptr
%543 = arith.constant 0 : i32
%544 = arith.extsi %543 : i32 to i64
%545 = llvm.mlir.constant(1 : i64) : i64
%546 = llvm.alloca %545 x i64 : (i64) -> !llvm.ptr
llvm.store %544, %546 : i64, !llvm.ptr
%547 = arith.constant 0 : i32
%548 = arith.extsi %547 : i32 to i64
%549 = llvm.mlir.constant(1 : i64) : i64
%550 = llvm.alloca %549 x i64 : (i64) -> !llvm.ptr
llvm.store %548, %550 : i64, !llvm.ptr
%551 = arith.constant 0 : i32
%552 = arith.extsi %551 : i32 to i64
%553 = llvm.mlir.constant(1 : i64) : i64
%554 = llvm.alloca %553 x i64 : (i64) -> !llvm.ptr
llvm.store %552, %554 : i64, !llvm.ptr
%555 = arith.constant 0 : i32
%556 = arith.extsi %555 : i32 to i64
%557 = llvm.mlir.constant(1 : i64) : i64
%558 = llvm.alloca %557 x i64 : (i64) -> !llvm.ptr
llvm.store %556, %558 : i64, !llvm.ptr
%559 = arith.constant 0 : i32
%560 = arith.extsi %559 : i32 to i64
%561 = llvm.mlir.constant(1 : i64) : i64
%562 = llvm.alloca %561 x i64 : (i64) -> !llvm.ptr
llvm.store %560, %562 : i64, !llvm.ptr
%563 = arith.constant 0 : i32
%564 = arith.extsi %563 : i32 to i64
%565 = llvm.mlir.constant(1 : i64) : i64
%566 = llvm.alloca %565 x i64 : (i64) -> !llvm.ptr
llvm.store %564, %566 : i64, !llvm.ptr
%567 = arith.constant 0 : i32
%568 = arith.extsi %567 : i32 to i64
%569 = llvm.mlir.constant(1 : i64) : i64
%570 = llvm.alloca %569 x i64 : (i64) -> !llvm.ptr
llvm.store %568, %570 : i64, !llvm.ptr
%571 = arith.constant 0 : i32
%572 = arith.extsi %571 : i32 to i64
%573 = llvm.mlir.constant(1 : i64) : i64
%574 = llvm.alloca %573 x i64 : (i64) -> !llvm.ptr
llvm.store %572, %574 : i64, !llvm.ptr
%575 = arith.constant 0 : i32
%576 = arith.extsi %575 : i32 to i64
%577 = llvm.mlir.constant(1 : i64) : i64
%578 = llvm.alloca %577 x i64 : (i64) -> !llvm.ptr
llvm.store %576, %578 : i64, !llvm.ptr
%579 = arith.constant 1 : i32
%581 = arith.constant 0 : i32
%580 = arith.subi %581, %579 : i32
%582 = arith.extsi %580 : i32 to i64
%583 = llvm.mlir.constant(1 : i64) : i64
%584 = llvm.alloca %583 x i64 : (i64) -> !llvm.ptr
llvm.store %582, %584 : i64, !llvm.ptr
%585 = arith.constant 0 : i1
%586 = llvm.mlir.constant(1 : i64) : i64
%587 = llvm.alloca %586 x i1 : (i64) -> !llvm.ptr
llvm.store %585, %587 : i1, !llvm.ptr
%588 = arith.constant 0 : i32
%589 = arith.extsi %588 : i32 to i64
%590 = llvm.mlir.constant(1 : i64) : i64
%591 = llvm.alloca %590 x i64 : (i64) -> !llvm.ptr
llvm.store %589, %591 : i64, !llvm.ptr
cf.br ^bb45
^bb45:
%592 = llvm.load %591 : !llvm.ptr -> i64
%593 = arith.constant 37 : i32
%595 = arith.extsi %593 : i32 to i64
%594 = arith.cmpi slt, %592, %595 : i64
cf.cond_br %594, ^bb46, ^bb47
^bb46:
%596 = llvm.load %591 : !llvm.ptr -> i64
%597 = arith.addi %523, %596 : i64
%598 = llvm.load %587 : !llvm.ptr -> i1
%599 = scf.if %598 -> (i1) {
%600 = llvm.load %542 : !llvm.ptr -> i64
%601 = arith.cmpi sge, %597, %600 : i64
scf.yield %601 : i1
} else {
%602 = arith.constant false
scf.yield %602 : i1
}
cf.cond_br %599, ^bb48, ^bb49
^bb48:
cf.br ^bb47
^bb49:
cf.br ^bb50
^bb50:
%603 = arith.muli %597, %77 : i64
%604 = arith.constant 1000000 : i32
%606 = arith.extsi %604 : i32 to i64
%605 = arith.divsi %603, %606 : i64
%607 = arith.constant 1000000 : i32
%609 = arith.extsi %607 : i32 to i64
%608 = arith.remsi %603, %609 : i64
%610 = func.call @digit_sum(%605) : (i64) -> i64
%612 = arith.constant 1 : i32
%614 = arith.extsi %612 : i32 to i64
%613 = arith.addi %605, %614 : i64
%611 = func.call @digit_sum(%613) : (i64) -> i64
%615 = llvm.load %516 : !llvm.ptr -> i64
%616 = arith.subi %615, %610 : i64
%617 = llvm.mlir.constant(1 : i64) : i64
%618 = llvm.alloca %617 x i64 : (i64) -> !llvm.ptr
llvm.store %616, %618 : i64, !llvm.ptr
%619 = llvm.load %516 : !llvm.ptr -> i64
%620 = arith.subi %619, %611 : i64
%621 = llvm.mlir.constant(1 : i64) : i64
%622 = llvm.alloca %621 x i64 : (i64) -> !llvm.ptr
llvm.store %620, %622 : i64, !llvm.ptr
%623 = llvm.load %618 : !llvm.ptr -> i64
%624 = arith.constant 0 : i32
%626 = arith.extsi %624 : i32 to i64
%625 = arith.cmpi slt, %623, %626 : i64
%627 = scf.if %625 -> (i1) {
%628 = arith.constant true
scf.yield %628 : i1
} else {
%629 = llvm.load %618 : !llvm.ptr -> i64
%630 = arith.constant 54 : i32
%632 = arith.extsi %630 : i32 to i64
%631 = arith.cmpi sgt, %629, %632 : i64
scf.yield %631 : i1
}
cf.cond_br %627, ^bb51, ^bb52
^bb51:
%633 = arith.constant 1 : i32
%635 = arith.constant 0 : i32
%634 = arith.subi %635, %633 : i32
%636 = arith.extsi %634 : i32 to i64
llvm.store %636, %618 : i64, !llvm.ptr
cf.br ^bb53
^bb52:
cf.br ^bb53
^bb53:
%637 = llvm.load %622 : !llvm.ptr -> i64
%638 = arith.constant 0 : i32
%640 = arith.extsi %638 : i32 to i64
%639 = arith.cmpi slt, %637, %640 : i64
%641 = scf.if %639 -> (i1) {
%642 = arith.constant true
scf.yield %642 : i1
} else {
%643 = llvm.load %622 : !llvm.ptr -> i64
%644 = arith.constant 54 : i32
%646 = arith.extsi %644 : i32 to i64
%645 = arith.cmpi sgt, %643, %646 : i64
scf.yield %645 : i1
}
cf.cond_br %641, ^bb54, ^bb55
^bb54:
%647 = arith.constant 1 : i32
%649 = arith.constant 0 : i32
%648 = arith.subi %649, %647 : i32
%650 = arith.extsi %648 : i32 to i64
llvm.store %650, %622 : i64, !llvm.ptr
cf.br ^bb56
^bb55:
cf.br ^bb56
^bb56:
%651 = arith.constant 1 : i32
%653 = arith.constant 0 : i32
%652 = arith.subi %653, %651 : i32
%654 = arith.extsi %652 : i32 to i64
%655 = llvm.mlir.constant(1 : i64) : i64
%656 = llvm.alloca %655 x i64 : (i64) -> !llvm.ptr
llvm.store %654, %656 : i64, !llvm.ptr
%657 = llvm.mlir.constant(1 : i64) : i64
%658 = llvm.alloca %657 x i64 : (i64) -> !llvm.ptr
llvm.store %530, %658 : i64, !llvm.ptr
cf.br ^bb57
^bb57:
%659 = llvm.load %658 : !llvm.ptr -> i64
%660 = arith.cmpi slt, %659, %536 : i64
cf.cond_br %660, ^bb58, ^bb59
^bb58:
%662 = llvm.load %658 : !llvm.ptr -> i64
%663 = llvm.getelementptr %369[%662] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%661 = llvm.load %663 : !llvm.ptr -> i32
%664 = arith.extsi %661 : i32 to i64
%665 = arith.addi %608, %664 : i64
%666 = arith.constant 1000000 : i32
%668 = arith.extsi %666 : i32 to i64
%667 = arith.cmpi slt, %665, %668 : i64
cf.cond_br %667, ^bb60, ^bb61
^bb60:
%669 = llvm.load %618 : !llvm.ptr -> i64
%670 = arith.constant 0 : i32
%672 = arith.extsi %670 : i32 to i64
%671 = arith.cmpi sge, %669, %672 : i64
%673 = scf.if %671 -> (i1) {
%675 = llvm.getelementptr %481[%665] : (!llvm.ptr, i64) -> !llvm.ptr, i8
%674 = llvm.load %675 : !llvm.ptr -> i8
%676 = arith.extsi %674 : i8 to i64
%677 = llvm.load %618 : !llvm.ptr -> i64
%678 = arith.cmpi eq, %676, %677 : i64
scf.yield %678 : i1
} else {
%679 = arith.constant false
scf.yield %679 : i1
}
cf.cond_br %673, ^bb63, ^bb64
^bb63:
llvm.store %664, %656 : i64, !llvm.ptr
cf.br ^bb59
^bb64:
cf.br ^bb65
^bb65:
cf.br ^bb62
^bb61:
%680 = llvm.load %622 : !llvm.ptr -> i64
%681 = arith.constant 0 : i32
%683 = arith.extsi %681 : i32 to i64
%682 = arith.cmpi sge, %680, %683 : i64
%684 = scf.if %682 -> (i1) {
%686 = arith.constant 1000000 : i32
%688 = arith.extsi %686 : i32 to i64
%687 = arith.subi %665, %688 : i64
%689 = llvm.getelementptr %481[%687] : (!llvm.ptr, i64) -> !llvm.ptr, i8
%685 = llvm.load %689 : !llvm.ptr -> i8
%690 = arith.extsi %685 : i8 to i64
%691 = llvm.load %622 : !llvm.ptr -> i64
%692 = arith.cmpi eq, %690, %691 : i64
scf.yield %692 : i1
} else {
%693 = arith.constant false
scf.yield %693 : i1
}
cf.cond_br %684, ^bb66, ^bb67
^bb66:
llvm.store %664, %656 : i64, !llvm.ptr
cf.br ^bb59
^bb67:
cf.br ^bb68
^bb68:
cf.br ^bb62
^bb62:
%694 = llvm.load %658 : !llvm.ptr -> i64
%695 = arith.constant 1 : i32
%697 = arith.extsi %695 : i32 to i64
%696 = arith.addi %694, %697 : i64
llvm.store %696, %658 : i64, !llvm.ptr
cf.br ^bb57
^bb59:
%698 = llvm.load %656 : !llvm.ptr -> i64
%699 = arith.constant 0 : i32
%701 = arith.extsi %699 : i32 to i64
%700 = arith.cmpi sge, %698, %701 : i64
cf.cond_br %700, ^bb69, ^bb70
^bb69:
%703 = llvm.load %656 : !llvm.ptr -> i64
%704 = llvm.getelementptr %118[%703] : (!llvm.ptr, i64) -> !llvm.ptr, i8
%702 = llvm.load %704 : !llvm.ptr -> i8
%705 = arith.extsi %702 : i8 to i64
%706 = arith.addi %597, %705 : i64
%708 = llvm.load %656 : !llvm.ptr -> i64
%709 = llvm.getelementptr %94[%708] : (!llvm.ptr, i64) -> !llvm.ptr, i8
%707 = llvm.load %709 : !llvm.ptr -> i8
%710 = arith.extsi %707 : i8 to i64
%712 = llvm.load %656 : !llvm.ptr -> i64
%713 = llvm.getelementptr %97[%712] : (!llvm.ptr, i64) -> !llvm.ptr, i8
%711 = llvm.load %713 : !llvm.ptr -> i8
%714 = arith.extsi %711 : i8 to i64
%716 = llvm.load %656 : !llvm.ptr -> i64
%717 = llvm.getelementptr %100[%716] : (!llvm.ptr, i64) -> !llvm.ptr, i8
%715 = llvm.load %717 : !llvm.ptr -> i8
%718 = arith.extsi %715 : i8 to i64
%720 = llvm.load %656 : !llvm.ptr -> i64
%721 = llvm.getelementptr %103[%720] : (!llvm.ptr, i64) -> !llvm.ptr, i8
%719 = llvm.load %721 : !llvm.ptr -> i8
%722 = arith.extsi %719 : i8 to i64
%724 = llvm.load %656 : !llvm.ptr -> i64
%725 = llvm.getelementptr %106[%724] : (!llvm.ptr, i64) -> !llvm.ptr, i8
%723 = llvm.load %725 : !llvm.ptr -> i8
%726 = arith.extsi %723 : i8 to i64
%728 = llvm.load %656 : !llvm.ptr -> i64
%729 = llvm.getelementptr %109[%728] : (!llvm.ptr, i64) -> !llvm.ptr, i8
%727 = llvm.load %729 : !llvm.ptr -> i8
%730 = arith.extsi %727 : i8 to i64
%732 = llvm.load %656 : !llvm.ptr -> i64
%733 = llvm.getelementptr %112[%732] : (!llvm.ptr, i64) -> !llvm.ptr, i8
%731 = llvm.load %733 : !llvm.ptr -> i8
%734 = arith.extsi %731 : i8 to i64
%736 = llvm.load %656 : !llvm.ptr -> i64
%737 = llvm.getelementptr %115[%736] : (!llvm.ptr, i64) -> !llvm.ptr, i8
%735 = llvm.load %737 : !llvm.ptr -> i8
%738 = arith.extsi %735 : i8 to i64
%739 = arith.constant 0 : i1
%740 = llvm.load %587 : !llvm.ptr -> i1
%742 = arith.constant 1 : i1
%741 = arith.xori %740, %742 : i1
cf.cond_br %741, ^bb72, ^bb73
^bb72:
%744 = arith.constant 1 : i1
cf.br ^bb74(%744 : i1)
^bb73:
%745 = llvm.load %542 : !llvm.ptr -> i64
%746 = arith.cmpi slt, %706, %745 : i64
cf.cond_br %746, ^bb76, ^bb75
^bb76:
%747 = arith.constant 1 : i1
cf.br ^bb74(%747 : i1)
^bb75:
%748 = llvm.load %542 : !llvm.ptr -> i64
%749 = arith.cmpi eq, %706, %748 : i64
cf.cond_br %749, ^bb77, ^bb74(%739 : i1)
^bb77:
%750 = llvm.load %546 : !llvm.ptr -> i64
%751 = arith.cmpi sgt, %710, %750 : i64
cf.cond_br %751, ^bb78, ^bb79
^bb78:
%752 = arith.constant 1 : i1
cf.br ^bb80(%752 : i1)
^bb79:
%753 = llvm.load %546 : !llvm.ptr -> i64
%754 = arith.cmpi eq, %710, %753 : i64
%755 = scf.if %754 -> (i1) {
%756 = llvm.load %550 : !llvm.ptr -> i64
%757 = arith.cmpi sgt, %714, %756 : i64
scf.yield %757 : i1
} else {
%758 = arith.constant false
scf.yield %758 : i1
}
cf.cond_br %755, ^bb82, ^bb81
^bb82:
%759 = arith.constant 1 : i1
cf.br ^bb80(%759 : i1)
^bb81:
%760 = llvm.load %546 : !llvm.ptr -> i64
%761 = arith.cmpi eq, %710, %760 : i64
%762 = scf.if %761 -> (i1) {
%763 = llvm.load %550 : !llvm.ptr -> i64
%764 = arith.cmpi eq, %714, %763 : i64
scf.yield %764 : i1
} else {
%765 = arith.constant false
scf.yield %765 : i1
}
%766 = scf.if %762 -> (i1) {
%767 = llvm.load %554 : !llvm.ptr -> i64
%768 = arith.cmpi sgt, %718, %767 : i64
scf.yield %768 : i1
} else {
%769 = arith.constant false
scf.yield %769 : i1
}
cf.cond_br %766, ^bb84, ^bb83
^bb84:
%770 = arith.constant 1 : i1
cf.br ^bb80(%770 : i1)
^bb83:
%771 = llvm.load %546 : !llvm.ptr -> i64
%772 = arith.cmpi eq, %710, %771 : i64
%773 = scf.if %772 -> (i1) {
%774 = llvm.load %550 : !llvm.ptr -> i64
%775 = arith.cmpi eq, %714, %774 : i64
scf.yield %775 : i1
} else {
%776 = arith.constant false
scf.yield %776 : i1
}
%777 = scf.if %773 -> (i1) {
%778 = llvm.load %554 : !llvm.ptr -> i64
%779 = arith.cmpi eq, %718, %778 : i64
scf.yield %779 : i1
} else {
%780 = arith.constant false
scf.yield %780 : i1
}
%781 = scf.if %777 -> (i1) {
%782 = llvm.load %558 : !llvm.ptr -> i64
%783 = arith.cmpi sgt, %722, %782 : i64
scf.yield %783 : i1
} else {
%784 = arith.constant false
scf.yield %784 : i1
}
cf.cond_br %781, ^bb86, ^bb85
^bb86:
%785 = arith.constant 1 : i1
cf.br ^bb80(%785 : i1)
^bb85:
%786 = llvm.load %546 : !llvm.ptr -> i64
%787 = arith.cmpi eq, %710, %786 : i64
%788 = scf.if %787 -> (i1) {
%789 = llvm.load %550 : !llvm.ptr -> i64
%790 = arith.cmpi eq, %714, %789 : i64
scf.yield %790 : i1
} else {
%791 = arith.constant false
scf.yield %791 : i1
}
%792 = scf.if %788 -> (i1) {
%793 = llvm.load %554 : !llvm.ptr -> i64
%794 = arith.cmpi eq, %718, %793 : i64
scf.yield %794 : i1
} else {
%795 = arith.constant false
scf.yield %795 : i1
}
%796 = scf.if %792 -> (i1) {
%797 = llvm.load %558 : !llvm.ptr -> i64
%798 = arith.cmpi eq, %722, %797 : i64
scf.yield %798 : i1
} else {
%799 = arith.constant false
scf.yield %799 : i1
}
%800 = scf.if %796 -> (i1) {
%801 = llvm.load %562 : !llvm.ptr -> i64
%802 = arith.cmpi sgt, %726, %801 : i64
scf.yield %802 : i1
} else {
%803 = arith.constant false
scf.yield %803 : i1
}
cf.cond_br %800, ^bb88, ^bb87
^bb88:
%804 = arith.constant 1 : i1
cf.br ^bb80(%804 : i1)
^bb87:
%805 = llvm.load %546 : !llvm.ptr -> i64
%806 = arith.cmpi eq, %710, %805 : i64
%807 = scf.if %806 -> (i1) {
%808 = llvm.load %550 : !llvm.ptr -> i64
%809 = arith.cmpi eq, %714, %808 : i64
scf.yield %809 : i1
} else {
%810 = arith.constant false
scf.yield %810 : i1
}
%811 = scf.if %807 -> (i1) {
%812 = llvm.load %554 : !llvm.ptr -> i64
%813 = arith.cmpi eq, %718, %812 : i64
scf.yield %813 : i1
} else {
%814 = arith.constant false
scf.yield %814 : i1
}
%815 = scf.if %811 -> (i1) {
%816 = llvm.load %558 : !llvm.ptr -> i64
%817 = arith.cmpi eq, %722, %816 : i64
scf.yield %817 : i1
} else {
%818 = arith.constant false
scf.yield %818 : i1
}
%819 = scf.if %815 -> (i1) {
%820 = llvm.load %562 : !llvm.ptr -> i64
%821 = arith.cmpi eq, %726, %820 : i64
scf.yield %821 : i1
} else {
%822 = arith.constant false
scf.yield %822 : i1
}
%823 = scf.if %819 -> (i1) {
%824 = llvm.load %566 : !llvm.ptr -> i64
%825 = arith.cmpi sgt, %730, %824 : i64
scf.yield %825 : i1
} else {
%826 = arith.constant false
scf.yield %826 : i1
}
cf.cond_br %823, ^bb90, ^bb89
^bb90:
%827 = arith.constant 1 : i1
cf.br ^bb80(%827 : i1)
^bb89:
%828 = llvm.load %546 : !llvm.ptr -> i64
%829 = arith.cmpi eq, %710, %828 : i64
%830 = scf.if %829 -> (i1) {
%831 = llvm.load %550 : !llvm.ptr -> i64
%832 = arith.cmpi eq, %714, %831 : i64
scf.yield %832 : i1
} else {
%833 = arith.constant false
scf.yield %833 : i1
}
%834 = scf.if %830 -> (i1) {
%835 = llvm.load %554 : !llvm.ptr -> i64
%836 = arith.cmpi eq, %718, %835 : i64
scf.yield %836 : i1
} else {
%837 = arith.constant false
scf.yield %837 : i1
}
%838 = scf.if %834 -> (i1) {
%839 = llvm.load %558 : !llvm.ptr -> i64
%840 = arith.cmpi eq, %722, %839 : i64
scf.yield %840 : i1
} else {
%841 = arith.constant false
scf.yield %841 : i1
}
%842 = scf.if %838 -> (i1) {
%843 = llvm.load %562 : !llvm.ptr -> i64
%844 = arith.cmpi eq, %726, %843 : i64
scf.yield %844 : i1
} else {
%845 = arith.constant false
scf.yield %845 : i1
}
%846 = scf.if %842 -> (i1) {
%847 = llvm.load %566 : !llvm.ptr -> i64
%848 = arith.cmpi eq, %730, %847 : i64
scf.yield %848 : i1
} else {
%849 = arith.constant false
scf.yield %849 : i1
}
%850 = scf.if %846 -> (i1) {
%851 = llvm.load %570 : !llvm.ptr -> i64
%852 = arith.cmpi sgt, %734, %851 : i64
scf.yield %852 : i1
} else {
%853 = arith.constant false
scf.yield %853 : i1
}
cf.cond_br %850, ^bb92, ^bb91
^bb92:
%854 = arith.constant 1 : i1
cf.br ^bb80(%854 : i1)
^bb91:
%855 = llvm.load %546 : !llvm.ptr -> i64
%856 = arith.cmpi eq, %710, %855 : i64
%857 = scf.if %856 -> (i1) {
%858 = llvm.load %550 : !llvm.ptr -> i64
%859 = arith.cmpi eq, %714, %858 : i64
scf.yield %859 : i1
} else {
%860 = arith.constant false
scf.yield %860 : i1
}
%861 = scf.if %857 -> (i1) {
%862 = llvm.load %554 : !llvm.ptr -> i64
%863 = arith.cmpi eq, %718, %862 : i64
scf.yield %863 : i1
} else {
%864 = arith.constant false
scf.yield %864 : i1
}
%865 = scf.if %861 -> (i1) {
%866 = llvm.load %558 : !llvm.ptr -> i64
%867 = arith.cmpi eq, %722, %866 : i64
scf.yield %867 : i1
} else {
%868 = arith.constant false
scf.yield %868 : i1
}
%869 = scf.if %865 -> (i1) {
%870 = llvm.load %562 : !llvm.ptr -> i64
%871 = arith.cmpi eq, %726, %870 : i64
scf.yield %871 : i1
} else {
%872 = arith.constant false
scf.yield %872 : i1
}
%873 = scf.if %869 -> (i1) {
%874 = llvm.load %566 : !llvm.ptr -> i64
%875 = arith.cmpi eq, %730, %874 : i64
scf.yield %875 : i1
} else {
%876 = arith.constant false
scf.yield %876 : i1
}
%877 = scf.if %873 -> (i1) {
%878 = llvm.load %570 : !llvm.ptr -> i64
%879 = arith.cmpi eq, %734, %878 : i64
scf.yield %879 : i1
} else {
%880 = arith.constant false
scf.yield %880 : i1
}
%881 = scf.if %877 -> (i1) {
%882 = llvm.load %574 : !llvm.ptr -> i64
%883 = arith.cmpi sgt, %738, %882 : i64
scf.yield %883 : i1
} else {
%884 = arith.constant false
scf.yield %884 : i1
}
cf.cond_br %881, ^bb94, ^bb93
^bb94:
%885 = arith.constant 1 : i1
cf.br ^bb80(%885 : i1)
^bb93:
%886 = llvm.load %546 : !llvm.ptr -> i64
%887 = arith.cmpi eq, %710, %886 : i64
%888 = scf.if %887 -> (i1) {
%889 = llvm.load %550 : !llvm.ptr -> i64
%890 = arith.cmpi eq, %714, %889 : i64
scf.yield %890 : i1
} else {
%891 = arith.constant false
scf.yield %891 : i1
}
%892 = scf.if %888 -> (i1) {
%893 = llvm.load %554 : !llvm.ptr -> i64
%894 = arith.cmpi eq, %718, %893 : i64
scf.yield %894 : i1
} else {
%895 = arith.constant false
scf.yield %895 : i1
}
%896 = scf.if %892 -> (i1) {
%897 = llvm.load %558 : !llvm.ptr -> i64
%898 = arith.cmpi eq, %722, %897 : i64
scf.yield %898 : i1
} else {
%899 = arith.constant false
scf.yield %899 : i1
}
%900 = scf.if %896 -> (i1) {
%901 = llvm.load %562 : !llvm.ptr -> i64
%902 = arith.cmpi eq, %726, %901 : i64
scf.yield %902 : i1
} else {
%903 = arith.constant false
scf.yield %903 : i1
}
%904 = scf.if %900 -> (i1) {
%905 = llvm.load %566 : !llvm.ptr -> i64
%906 = arith.cmpi eq, %730, %905 : i64
scf.yield %906 : i1
} else {
%907 = arith.constant false
scf.yield %907 : i1
}
%908 = scf.if %904 -> (i1) {
%909 = llvm.load %570 : !llvm.ptr -> i64
%910 = arith.cmpi eq, %734, %909 : i64
scf.yield %910 : i1
} else {
%911 = arith.constant false
scf.yield %911 : i1
}
%912 = scf.if %908 -> (i1) {
%913 = llvm.load %574 : !llvm.ptr -> i64
%914 = arith.cmpi eq, %738, %913 : i64
scf.yield %914 : i1
} else {
%915 = arith.constant false
scf.yield %915 : i1
}
%916 = scf.if %912 -> (i1) {
%917 = llvm.load %578 : !llvm.ptr -> i64
%918 = arith.cmpi sgt, %597, %917 : i64
scf.yield %918 : i1
} else {
%919 = arith.constant false
scf.yield %919 : i1
}
cf.cond_br %916, ^bb95, ^bb80(%739 : i1)
^bb95:
%920 = arith.constant 1 : i1
cf.br ^bb80(%920 : i1)
^bb80(%921: i1):
cf.br ^bb74(%921 : i1)
^bb74(%922: i1):
cf.cond_br %922, ^bb96, ^bb97
^bb96:
%923 = arith.constant 1 : i1
llvm.store %923, %587 : i1, !llvm.ptr
llvm.store %706, %542 : i64, !llvm.ptr
llvm.store %710, %546 : i64, !llvm.ptr
llvm.store %714, %550 : i64, !llvm.ptr
llvm.store %718, %554 : i64, !llvm.ptr
llvm.store %722, %558 : i64, !llvm.ptr
llvm.store %726, %562 : i64, !llvm.ptr
llvm.store %730, %566 : i64, !llvm.ptr
llvm.store %734, %570 : i64, !llvm.ptr
llvm.store %738, %574 : i64, !llvm.ptr
llvm.store %597, %578 : i64, !llvm.ptr
%925 = llvm.load %656 : !llvm.ptr -> i64
%926 = llvm.getelementptr %121[%925] : (!llvm.ptr, i64) -> !llvm.ptr, i16
%924 = llvm.load %926 : !llvm.ptr -> i16
%927 = arith.extsi %924 : i16 to i64
%928 = arith.constant 9 : i32
%930 = arith.extsi %928 : i32 to i64
%929 = arith.muli %930, %597 : i64
%931 = arith.addi %927, %929 : i64
llvm.store %931, %584 : i64, !llvm.ptr
cf.br ^bb98
^bb97:
cf.br ^bb98
^bb98:
cf.br ^bb71
^bb70:
cf.br ^bb71
^bb71:
%932 = llvm.load %591 : !llvm.ptr -> i64
%933 = arith.constant 1 : i32
%935 = arith.extsi %933 : i32 to i64
%934 = arith.addi %932, %935 : i64
llvm.store %934, %591 : i64, !llvm.ptr
cf.br ^bb45
^bb47:
%936 = llvm.load %512 : !llvm.ptr -> i64
%937 = llvm.load %584 : !llvm.ptr -> i64
%938 = arith.addi %936, %937 : i64
llvm.store %938, %512 : i64, !llvm.ptr
%939 = llvm.load %516 : !llvm.ptr -> i64
%940 = arith.constant 1 : i32
%942 = arith.extsi %940 : i32 to i64
%941 = arith.addi %939, %942 : i64
llvm.store %941, %516 : i64, !llvm.ptr
cf.br ^bb42
^bb44:
%943 = llvm.mlir.addressof @str_0 : !llvm.ptr
%944 = llvm.load %512 : !llvm.ptr -> i64
%945 = llvm.call @printf(%943, %944) vararg(!llvm.func<i32 (ptr, ...)>) : (!llvm.ptr, i64) -> i32
%946 = arith.constant 0 : i32
func.return %946 : i32
}
}