Problem 217
Sum of balanced numbers < 10^47, mod 3^15.
View problem on Project Euler
Performance comparison
| Metric | Our solution | Best known |
| Time complexity | O(n^3) | O(n * d * s) |
| Space complexity | O(n^2) | O(d * s) |
| Approach | Flow solution | Digit DP |
| Verdict | Unknown |
Flow source
# Project Euler 217
# Sum of balanced numbers < 10^47, mod 3^15.
extern {
function calloc(n: i64, size: i64) -> ptr<void>
function free(p: ptr<void>) -> void
}
const MOD: i64 = 14348907
function main() -> i32 {
let n: i32 = 47
let maxL: i32 = n / 2
let pow10: ptr<i64> = calloc((n + 2) as i64, 8)
if pow10 == null { return 1 }
pow10[0] = 1
for i in 1..(n + 2) {
pow10[i] = (pow10[i - 1] * 10) % MOD
}
let max_sum_all: i64 = (9 * maxL + 1) as i64
let un_c: ptr<i64> = calloc(((maxL + 1) as i64) * max_sum_all, 8)
let un_s: ptr<i64> = calloc(((maxL + 1) as i64) * max_sum_all, 8)
let un_len: ptr<i32> = calloc((maxL + 1) as i64, 4)
if un_c == null || un_s == null { return 1 }
un_c[0] = 1
un_s[0] = 0
un_len[0] = 1
for L in 1..(maxL + 1) {
let max_sum: i32 = 9 * L
un_len[L] = max_sum + 1
let prev_len: i32 = un_len[L - 1]
let base: i64 = (L as i64) * max_sum_all
let pbase: i64 = ((L - 1) as i64) * max_sum_all
for sp in 0..prev_len {
let cp: i64 = un_c[pbase + (sp as i64)]
let spv: i64 = un_s[pbase + (sp as i64)]
if cp != 0 || spv != 0 {
for d in 0..10 {
let idx: i64 = base + ((sp + d) as i64)
un_c[idx] = (un_c[idx] + cp) % MOD
un_s[idx] = (un_s[idx] + (spv * 10 + cp * (d as i64)) % MOD) % MOD
}
}
}
}
let left_c: ptr<i64> = calloc(((maxL + 1) as i64) * max_sum_all, 8)
let left_s: ptr<i64> = calloc(((maxL + 1) as i64) * max_sum_all, 8)
let left_len: ptr<i32> = calloc((maxL + 1) as i64, 4)
left_c[0] = 1
left_s[0] = 0
left_len[0] = 1
for L in 1..(maxL + 1) {
let max_sum: i32 = 9 * L
left_len[L] = max_sum + 1
let base: i64 = (L as i64) * max_sum_all
let tbase: i64 = ((L - 1) as i64) * max_sum_all
let tlen: i32 = un_len[L - 1]
for fd in 1..10 {
for ts in 0..tlen {
let cnt: i64 = un_c[tbase + (ts as i64)]
let tsv: i64 = un_s[tbase + (ts as i64)]
if cnt != 0 || tsv != 0 {
let ssum: i32 = ts + fd
let idx: i64 = base + (ssum as i64)
left_c[idx] = (left_c[idx] + cnt) % MOD
let add: i64 = ((fd as i64) * pow10[L - 1] % MOD) * cnt % MOD
left_s[idx] = (left_s[idx] + add + tsv) % MOD
}
}
}
}
let mut total: i64 = 0
if n >= 1 {
total = 45 % MOD
}
for k in 2..(n + 1) {
let L: i32 = k / 2
let even: bool = (k % 2 == 0)
let max_sum: i32 = 9 * L
let base: i64 = (L as i64) * max_sum_all
let mut sum_k: i64 = 0
if even {
let mult_left: i64 = pow10[L]
for s in 0..(max_sum + 1) {
let cl: i64 = left_c[base + (s as i64)]
let cr: i64 = un_c[base + (s as i64)]
let ls: i64 = left_s[base + (s as i64)]
let rs: i64 = un_s[base + (s as i64)]
if cl != 0 || cr != 0 {
sum_k = (sum_k + ((ls * mult_left) % MOD) * cr % MOD) % MOD
sum_k = (sum_k + cl * rs % MOD) % MOD
}
}
} else {
let mult_left: i64 = pow10[L + 1]
let mult_mid: i64 = pow10[L]
for s in 0..(max_sum + 1) {
let cl: i64 = left_c[base + (s as i64)]
let cr: i64 = un_c[base + (s as i64)]
let ls: i64 = left_s[base + (s as i64)]
let rs: i64 = un_s[base + (s as i64)]
if cl != 0 || cr != 0 {
sum_k = (sum_k + ((ls * mult_left) % MOD) * cr % MOD * 10) % MOD
sum_k = (sum_k + ((45 * mult_mid) % MOD) * cl % MOD * cr % MOD) % MOD
sum_k = (sum_k + cl * rs % MOD * 10) % MOD
}
}
}
total = (total + sum_k) % MOD
}
printf("%lld\n", total)
free(pow10); free(un_c); free(un_s); free(un_len); free(left_c); free(left_s); free(left_len)
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; }
int32_t main(void);
static const int64_t MOD = 14348907;
int32_t main(void) {
int32_t n = 47;
int32_t maxL = FLOW_CHECKED_DIV((n), (2));
int64_t* pow10 = (int64_t*)(calloc(((int64_t)((n + 2))), 8));
if (pow10 == NULL) {
return 1;
}
pow10[0] = 1;
int32_t __flow_step_1 = 1;
for (int32_t i = 1; (1 <= (n + 2)) ? i < (n + 2) : i > (n + 2); i += (1 <= (n + 2)) ? 1 : -1) {
pow10[i] = FLOW_CHECKED_MOD(((pow10[(i - 1)] * 10)), (MOD));
}
int64_t max_sum_all = ((int64_t)(((9 * maxL) + 1)));
int64_t* un_c = (int64_t*)(calloc((((int64_t)((maxL + 1))) * max_sum_all), 8));
int64_t* un_s = (int64_t*)(calloc((((int64_t)((maxL + 1))) * max_sum_all), 8));
int32_t* un_len = (int32_t*)(calloc(((int64_t)((maxL + 1))), 4));
if ((un_c == NULL || un_s == NULL)) {
return 1;
}
un_c[0] = 1;
un_s[0] = 0;
un_len[0] = 1;
int32_t __flow_step_2 = 1;
for (int32_t L = 1; (1 <= (maxL + 1)) ? L < (maxL + 1) : L > (maxL + 1); L += (1 <= (maxL + 1)) ? 1 : -1) {
int32_t max_sum = (9 * L);
un_len[L] = (max_sum + 1);
int32_t prev_len = un_len[(L - 1)];
int64_t base = (((int64_t)(L)) * max_sum_all);
int64_t pbase = (((int64_t)((L - 1))) * max_sum_all);
int32_t __flow_step_3 = 1;
for (int32_t sp = 0; (0 <= prev_len) ? sp < prev_len : sp > prev_len; sp += (0 <= prev_len) ? 1 : -1) {
int64_t cp = un_c[(pbase + ((int64_t)(sp)))];
int64_t spv = un_s[(pbase + ((int64_t)(sp)))];
if ((cp != 0 || spv != 0)) {
int32_t __flow_step_4 = 1;
for (int32_t d = 0; (0 <= 10) ? d < 10 : d > 10; d += (0 <= 10) ? 1 : -1) {
int64_t idx = (base + ((int64_t)((sp + d))));
un_c[idx] = FLOW_CHECKED_MOD(((un_c[idx] + cp)), (MOD));
un_s[idx] = FLOW_CHECKED_MOD(((un_s[idx] + FLOW_CHECKED_MOD((((spv * 10) + (cp * ((int64_t)(d))))), (MOD)))), (MOD));
}
}
}
}
int64_t* left_c = (int64_t*)(calloc((((int64_t)((maxL + 1))) * max_sum_all), 8));
int64_t* left_s = (int64_t*)(calloc((((int64_t)((maxL + 1))) * max_sum_all), 8));
int32_t* left_len = (int32_t*)(calloc(((int64_t)((maxL + 1))), 4));
left_c[0] = 1;
left_s[0] = 0;
left_len[0] = 1;
int32_t __flow_step_5 = 1;
for (int32_t L = 1; (1 <= (maxL + 1)) ? L < (maxL + 1) : L > (maxL + 1); L += (1 <= (maxL + 1)) ? 1 : -1) {
int32_t max_sum = (9 * L);
left_len[L] = (max_sum + 1);
int64_t base = (((int64_t)(L)) * max_sum_all);
int64_t tbase = (((int64_t)((L - 1))) * max_sum_all);
int32_t tlen = un_len[(L - 1)];
int32_t __flow_step_6 = 1;
for (int32_t fd = 1; (1 <= 10) ? fd < 10 : fd > 10; fd += (1 <= 10) ? 1 : -1) {
int32_t __flow_step_7 = 1;
for (int32_t ts = 0; (0 <= tlen) ? ts < tlen : ts > tlen; ts += (0 <= tlen) ? 1 : -1) {
int64_t cnt = un_c[(tbase + ((int64_t)(ts)))];
int64_t tsv = un_s[(tbase + ((int64_t)(ts)))];
if ((cnt != 0 || tsv != 0)) {
int32_t ssum = (ts + fd);
int64_t idx = (base + ((int64_t)(ssum)));
left_c[idx] = FLOW_CHECKED_MOD(((left_c[idx] + cnt)), (MOD));
int64_t add = FLOW_CHECKED_MOD(((FLOW_CHECKED_MOD(((((int64_t)(fd)) * pow10[(L - 1)])), (MOD)) * cnt)), (MOD));
left_s[idx] = FLOW_CHECKED_MOD((((left_s[idx] + add) + tsv)), (MOD));
}
}
}
}
int64_t total = 0;
if (n >= 1) {
total = FLOW_CHECKED_MOD((45), (MOD));
}
int32_t __flow_step_8 = 1;
for (int32_t k = 2; (2 <= (n + 1)) ? k < (n + 1) : k > (n + 1); k += (2 <= (n + 1)) ? 1 : -1) {
int32_t L = FLOW_CHECKED_DIV((k), (2));
bool even = FLOW_CHECKED_MOD((k), (2)) == 0;
int32_t max_sum = (9 * L);
int64_t base = (((int64_t)(L)) * max_sum_all);
int64_t sum_k = 0;
if (even) {
int64_t mult_left = pow10[L];
int32_t __flow_step_9 = 1;
for (int32_t s = 0; (0 <= (max_sum + 1)) ? s < (max_sum + 1) : s > (max_sum + 1); s += (0 <= (max_sum + 1)) ? 1 : -1) {
int64_t cl = left_c[(base + ((int64_t)(s)))];
int64_t cr = un_c[(base + ((int64_t)(s)))];
int64_t ls = left_s[(base + ((int64_t)(s)))];
int64_t rs = un_s[(base + ((int64_t)(s)))];
if ((cl != 0 || cr != 0)) {
sum_k = FLOW_CHECKED_MOD(((sum_k + FLOW_CHECKED_MOD(((FLOW_CHECKED_MOD(((ls * mult_left)), (MOD)) * cr)), (MOD)))), (MOD));
sum_k = FLOW_CHECKED_MOD(((sum_k + FLOW_CHECKED_MOD(((cl * rs)), (MOD)))), (MOD));
}
}
} else {
int64_t mult_left = pow10[(L + 1)];
int64_t mult_mid = pow10[L];
int32_t __flow_step_10 = 1;
for (int32_t s = 0; (0 <= (max_sum + 1)) ? s < (max_sum + 1) : s > (max_sum + 1); s += (0 <= (max_sum + 1)) ? 1 : -1) {
int64_t cl = left_c[(base + ((int64_t)(s)))];
int64_t cr = un_c[(base + ((int64_t)(s)))];
int64_t ls = left_s[(base + ((int64_t)(s)))];
int64_t rs = un_s[(base + ((int64_t)(s)))];
if ((cl != 0 || cr != 0)) {
sum_k = FLOW_CHECKED_MOD(((sum_k + (FLOW_CHECKED_MOD(((FLOW_CHECKED_MOD(((ls * mult_left)), (MOD)) * cr)), (MOD)) * 10))), (MOD));
sum_k = FLOW_CHECKED_MOD(((sum_k + FLOW_CHECKED_MOD(((FLOW_CHECKED_MOD(((FLOW_CHECKED_MOD(((45 * mult_mid)), (MOD)) * cl)), (MOD)) * cr)), (MOD)))), (MOD));
sum_k = FLOW_CHECKED_MOD(((sum_k + (FLOW_CHECKED_MOD(((cl * rs)), (MOD)) * 10))), (MOD));
}
}
}
total = FLOW_CHECKED_MOD(((total + sum_k)), (MOD));
}
printf("%lld\n", total);
free(pow10);
free(un_c);
free(un_s);
free(un_len);
free(left_c);
free(left_s);
free(left_len);
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(14348907 : i64) : i64
func.func @main() -> i32 {
%0 = arith.constant 47 : i32
%1 = arith.constant 2 : i32
%2 = arith.divsi %0, %1 : i32
%4 = arith.constant 2 : i32
%5 = arith.addi %0, %4 : i32
%6 = arith.extsi %5 : i32 to i64
%7 = arith.constant 8 : i32
%8 = arith.extsi %7 : i32 to i64
%3 = func.call @calloc(%6, %8) : (i64, i64) -> !llvm.ptr
%9 = llvm.mlir.zero : !llvm.ptr
%10 = llvm.icmp "eq" %3, %9 : !llvm.ptr
cf.cond_br %10, ^bb0, ^bb1
^bb0:
%11 = arith.constant 1 : i32
func.return %11 : i32
^bb1:
cf.br ^bb2
^bb2:
%12 = arith.constant 1 : i32
%13 = arith.constant 0 : i32
%14 = arith.extsi %12 : i32 to i64
%15 = arith.extsi %13 : i32 to i64
%16 = llvm.getelementptr %3[%15] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %14, %16 : i64, !llvm.ptr
%17 = arith.constant 1 : i32
%18 = arith.constant 2 : i32
%19 = arith.addi %0, %18 : i32
%20 = arith.index_cast %17 : i32 to index
%21 = arith.index_cast %19 : i32 to index
%23 = arith.constant 1 : index
%24 = arith.constant -1 : index
%25 = arith.cmpi sle, %20, %21 : index
%22 = arith.select %25, %23, %24 : index
cf.br ^bb3(%20 : index)
^bb3(%26: index):
%27 = arith.cmpi slt, %26, %21 : index
%28 = arith.cmpi sgt, %26, %21 : index
%29 = arith.select %25, %27, %28 : i1
cf.cond_br %29, ^bb4(%26 : index), ^bb5(%26 : index)
^bb4(%30: index):
%32 = arith.constant 1 : i32
%34 = arith.index_cast %30 : index to i32
%33 = arith.subi %34, %32 : i32
%35 = arith.extsi %33 : i32 to i64
%36 = llvm.getelementptr %3[%35] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%31 = llvm.load %36 : !llvm.ptr -> i64
%37 = arith.constant 10 : i32
%39 = arith.extsi %37 : i32 to i64
%38 = arith.muli %31, %39 : i64
%40 = llvm.mlir.addressof @MOD : !llvm.ptr
%41 = llvm.load %40 : !llvm.ptr -> i64
%42 = arith.remsi %38, %41 : i64
%43 = arith.index_cast %30 : index to i64
%44 = llvm.getelementptr %3[%43] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %42, %44 : i64, !llvm.ptr
%45 = arith.addi %30, %22 : index
cf.br ^bb3(%45 : index)
^bb5(%46: index):
%47 = arith.constant 9 : i32
%48 = arith.muli %47, %2 : i32
%49 = arith.constant 1 : i32
%50 = arith.addi %48, %49 : i32
%51 = arith.extsi %50 : i32 to i64
%53 = arith.constant 1 : i32
%54 = arith.addi %2, %53 : i32
%55 = arith.extsi %54 : i32 to i64
%56 = arith.muli %55, %51 : i64
%57 = arith.constant 8 : i32
%58 = arith.extsi %57 : i32 to i64
%52 = func.call @calloc(%56, %58) : (i64, i64) -> !llvm.ptr
%60 = arith.constant 1 : i32
%61 = arith.addi %2, %60 : i32
%62 = arith.extsi %61 : i32 to i64
%63 = arith.muli %62, %51 : i64
%64 = arith.constant 8 : i32
%65 = arith.extsi %64 : i32 to i64
%59 = func.call @calloc(%63, %65) : (i64, i64) -> !llvm.ptr
%67 = arith.constant 1 : i32
%68 = arith.addi %2, %67 : i32
%69 = arith.extsi %68 : i32 to i64
%70 = arith.constant 4 : i32
%71 = arith.extsi %70 : i32 to i64
%66 = func.call @calloc(%69, %71) : (i64, i64) -> !llvm.ptr
%72 = llvm.mlir.zero : !llvm.ptr
%73 = llvm.icmp "eq" %52, %72 : !llvm.ptr
%74 = scf.if %73 -> (i1) {
%75 = arith.constant true
scf.yield %75 : i1
} else {
%76 = llvm.mlir.zero : !llvm.ptr
%77 = llvm.icmp "eq" %59, %76 : !llvm.ptr
scf.yield %77 : i1
}
cf.cond_br %74, ^bb6, ^bb7
^bb6:
%78 = arith.constant 1 : i32
func.return %78 : i32
^bb7:
cf.br ^bb8
^bb8:
%79 = arith.constant 1 : i32
%80 = arith.constant 0 : i32
%81 = arith.extsi %79 : i32 to i64
%82 = arith.extsi %80 : i32 to i64
%83 = llvm.getelementptr %52[%82] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %81, %83 : i64, !llvm.ptr
%84 = arith.constant 0 : i32
%85 = arith.constant 0 : i32
%86 = arith.extsi %84 : i32 to i64
%87 = arith.extsi %85 : i32 to i64
%88 = llvm.getelementptr %59[%87] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %86, %88 : i64, !llvm.ptr
%89 = arith.constant 1 : i32
%90 = arith.constant 0 : i32
%91 = arith.extsi %90 : i32 to i64
%92 = llvm.getelementptr %66[%91] : (!llvm.ptr, i64) -> !llvm.ptr, i32
llvm.store %89, %92 : i32, !llvm.ptr
%93 = arith.constant 1 : i32
%94 = arith.constant 1 : i32
%95 = arith.addi %2, %94 : i32
%96 = arith.index_cast %93 : i32 to index
%97 = arith.index_cast %95 : i32 to index
%99 = arith.constant 1 : index
%100 = arith.constant -1 : index
%101 = arith.cmpi sle, %96, %97 : index
%98 = arith.select %101, %99, %100 : index
cf.br ^bb9(%96 : index)
^bb9(%102: index):
%103 = arith.cmpi slt, %102, %97 : index
%104 = arith.cmpi sgt, %102, %97 : index
%105 = arith.select %101, %103, %104 : i1
cf.cond_br %105, ^bb10(%102 : index), ^bb11(%102 : index)
^bb10(%106: index):
%107 = arith.constant 9 : i32
%109 = arith.index_cast %106 : index to i32
%108 = arith.muli %107, %109 : i32
%110 = arith.constant 1 : i32
%111 = arith.addi %108, %110 : i32
%112 = arith.index_cast %106 : index to i64
%113 = llvm.getelementptr %66[%112] : (!llvm.ptr, i64) -> !llvm.ptr, i32
llvm.store %111, %113 : i32, !llvm.ptr
%115 = arith.constant 1 : i32
%117 = arith.index_cast %106 : index to i32
%116 = arith.subi %117, %115 : i32
%118 = arith.extsi %116 : i32 to i64
%119 = llvm.getelementptr %66[%118] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%114 = llvm.load %119 : !llvm.ptr -> i32
%120 = arith.index_cast %106 : index to i64
%121 = arith.muli %120, %51 : i64
%122 = arith.constant 1 : i32
%124 = arith.index_cast %106 : index to i32
%123 = arith.subi %124, %122 : i32
%125 = arith.extsi %123 : i32 to i64
%126 = arith.muli %125, %51 : i64
%127 = arith.constant 0 : i32
%128 = arith.index_cast %127 : i32 to index
%129 = arith.index_cast %114 : i32 to index
%131 = arith.constant 1 : index
%132 = arith.constant -1 : index
%133 = arith.cmpi sle, %128, %129 : index
%130 = arith.select %133, %131, %132 : index
cf.br ^bb12(%128 : index)
^bb12(%134: index):
%135 = arith.cmpi slt, %134, %129 : index
%136 = arith.cmpi sgt, %134, %129 : index
%137 = arith.select %133, %135, %136 : i1
cf.cond_br %137, ^bb13(%134 : index), ^bb14(%134 : index)
^bb13(%138: index):
%140 = arith.index_cast %138 : index to i64
%141 = arith.addi %126, %140 : i64
%142 = llvm.getelementptr %52[%141] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%139 = llvm.load %142 : !llvm.ptr -> i64
%144 = arith.index_cast %138 : index to i64
%145 = arith.addi %126, %144 : i64
%146 = llvm.getelementptr %59[%145] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%143 = llvm.load %146 : !llvm.ptr -> i64
%147 = arith.constant 0 : i32
%149 = arith.extsi %147 : i32 to i64
%148 = arith.cmpi ne, %139, %149 : i64
%150 = scf.if %148 -> (i1) {
%151 = arith.constant true
scf.yield %151 : i1
} else {
%152 = arith.constant 0 : i32
%154 = arith.extsi %152 : i32 to i64
%153 = arith.cmpi ne, %143, %154 : i64
scf.yield %153 : i1
}
cf.cond_br %150, ^bb15, ^bb16
^bb15:
%155 = arith.constant 0 : i32
%156 = arith.constant 10 : i32
%157 = arith.index_cast %155 : i32 to index
%158 = arith.index_cast %156 : i32 to index
%160 = arith.constant 1 : index
%161 = arith.constant -1 : index
%162 = arith.cmpi sle, %157, %158 : index
%159 = arith.select %162, %160, %161 : index
cf.br ^bb18(%157 : index)
^bb18(%163: index):
%164 = arith.cmpi slt, %163, %158 : index
%165 = arith.cmpi sgt, %163, %158 : index
%166 = arith.select %162, %164, %165 : i1
cf.cond_br %166, ^bb19(%163 : index), ^bb20(%163 : index)
^bb19(%167: index):
%168 = arith.addi %138, %167 : index
%169 = arith.index_cast %168 : index to i64
%170 = arith.addi %121, %169 : i64
%172 = llvm.getelementptr %52[%170] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%171 = llvm.load %172 : !llvm.ptr -> i64
%173 = arith.addi %171, %139 : i64
%174 = llvm.mlir.addressof @MOD : !llvm.ptr
%175 = llvm.load %174 : !llvm.ptr -> i64
%176 = arith.remsi %173, %175 : i64
%177 = llvm.getelementptr %52[%170] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %176, %177 : i64, !llvm.ptr
%179 = llvm.getelementptr %59[%170] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%178 = llvm.load %179 : !llvm.ptr -> i64
%180 = arith.constant 10 : i32
%182 = arith.extsi %180 : i32 to i64
%181 = arith.muli %143, %182 : i64
%183 = arith.index_cast %167 : index to i64
%184 = arith.muli %139, %183 : i64
%185 = arith.addi %181, %184 : i64
%186 = llvm.mlir.addressof @MOD : !llvm.ptr
%187 = llvm.load %186 : !llvm.ptr -> i64
%188 = arith.remsi %185, %187 : i64
%189 = arith.addi %178, %188 : i64
%190 = llvm.mlir.addressof @MOD : !llvm.ptr
%191 = llvm.load %190 : !llvm.ptr -> i64
%192 = arith.remsi %189, %191 : i64
%193 = llvm.getelementptr %59[%170] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %192, %193 : i64, !llvm.ptr
%194 = arith.addi %167, %159 : index
cf.br ^bb18(%194 : index)
^bb20(%195: index):
cf.br ^bb17
^bb16:
cf.br ^bb17
^bb17:
%196 = arith.addi %138, %130 : index
cf.br ^bb12(%196 : index)
^bb14(%197: index):
%198 = arith.addi %106, %98 : index
cf.br ^bb9(%198 : index)
^bb11(%199: index):
%201 = arith.constant 1 : i32
%202 = arith.addi %2, %201 : i32
%203 = arith.extsi %202 : i32 to i64
%204 = arith.muli %203, %51 : i64
%205 = arith.constant 8 : i32
%206 = arith.extsi %205 : i32 to i64
%200 = func.call @calloc(%204, %206) : (i64, i64) -> !llvm.ptr
%208 = arith.constant 1 : i32
%209 = arith.addi %2, %208 : i32
%210 = arith.extsi %209 : i32 to i64
%211 = arith.muli %210, %51 : i64
%212 = arith.constant 8 : i32
%213 = arith.extsi %212 : i32 to i64
%207 = func.call @calloc(%211, %213) : (i64, i64) -> !llvm.ptr
%215 = arith.constant 1 : i32
%216 = arith.addi %2, %215 : i32
%217 = arith.extsi %216 : i32 to i64
%218 = arith.constant 4 : i32
%219 = arith.extsi %218 : i32 to i64
%214 = func.call @calloc(%217, %219) : (i64, i64) -> !llvm.ptr
%220 = arith.constant 1 : i32
%221 = arith.constant 0 : i32
%222 = arith.extsi %220 : i32 to i64
%223 = arith.extsi %221 : i32 to i64
%224 = llvm.getelementptr %200[%223] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %222, %224 : i64, !llvm.ptr
%225 = arith.constant 0 : i32
%226 = arith.constant 0 : i32
%227 = arith.extsi %225 : i32 to i64
%228 = arith.extsi %226 : i32 to i64
%229 = llvm.getelementptr %207[%228] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %227, %229 : i64, !llvm.ptr
%230 = arith.constant 1 : i32
%231 = arith.constant 0 : i32
%232 = arith.extsi %231 : i32 to i64
%233 = llvm.getelementptr %214[%232] : (!llvm.ptr, i64) -> !llvm.ptr, i32
llvm.store %230, %233 : i32, !llvm.ptr
%234 = arith.constant 1 : i32
%235 = arith.constant 1 : i32
%236 = arith.addi %2, %235 : i32
%237 = arith.index_cast %234 : i32 to index
%238 = arith.index_cast %236 : i32 to index
%240 = arith.constant 1 : index
%241 = arith.constant -1 : index
%242 = arith.cmpi sle, %237, %238 : index
%239 = arith.select %242, %240, %241 : index
cf.br ^bb21(%237 : index)
^bb21(%243: index):
%244 = arith.cmpi slt, %243, %238 : index
%245 = arith.cmpi sgt, %243, %238 : index
%246 = arith.select %242, %244, %245 : i1
cf.cond_br %246, ^bb22(%243 : index), ^bb23(%243 : index)
^bb22(%247: index):
%248 = arith.constant 9 : i32
%250 = arith.index_cast %247 : index to i32
%249 = arith.muli %248, %250 : i32
%251 = arith.constant 1 : i32
%252 = arith.addi %249, %251 : i32
%253 = arith.index_cast %247 : index to i64
%254 = llvm.getelementptr %214[%253] : (!llvm.ptr, i64) -> !llvm.ptr, i32
llvm.store %252, %254 : i32, !llvm.ptr
%255 = arith.index_cast %247 : index to i64
%256 = arith.muli %255, %51 : i64
%257 = arith.constant 1 : i32
%259 = arith.index_cast %247 : index to i32
%258 = arith.subi %259, %257 : i32
%260 = arith.extsi %258 : i32 to i64
%261 = arith.muli %260, %51 : i64
%263 = arith.constant 1 : i32
%265 = arith.index_cast %247 : index to i32
%264 = arith.subi %265, %263 : i32
%266 = arith.extsi %264 : i32 to i64
%267 = llvm.getelementptr %66[%266] : (!llvm.ptr, i64) -> !llvm.ptr, i32
%262 = llvm.load %267 : !llvm.ptr -> i32
%268 = arith.constant 1 : i32
%269 = arith.constant 10 : i32
%270 = arith.index_cast %268 : i32 to index
%271 = arith.index_cast %269 : i32 to index
%273 = arith.constant 1 : index
%274 = arith.constant -1 : index
%275 = arith.cmpi sle, %270, %271 : index
%272 = arith.select %275, %273, %274 : index
cf.br ^bb24(%270 : index)
^bb24(%276: index):
%277 = arith.cmpi slt, %276, %271 : index
%278 = arith.cmpi sgt, %276, %271 : index
%279 = arith.select %275, %277, %278 : i1
cf.cond_br %279, ^bb25(%276 : index), ^bb26(%276 : index)
^bb25(%280: index):
%281 = arith.constant 0 : i32
%282 = arith.index_cast %281 : i32 to index
%283 = arith.index_cast %262 : i32 to index
%285 = arith.constant 1 : index
%286 = arith.constant -1 : index
%287 = arith.cmpi sle, %282, %283 : index
%284 = arith.select %287, %285, %286 : index
cf.br ^bb27(%282 : index)
^bb27(%288: index):
%289 = arith.cmpi slt, %288, %283 : index
%290 = arith.cmpi sgt, %288, %283 : index
%291 = arith.select %287, %289, %290 : i1
cf.cond_br %291, ^bb28(%288 : index), ^bb29(%288 : index)
^bb28(%292: index):
%294 = arith.index_cast %292 : index to i64
%295 = arith.addi %261, %294 : i64
%296 = llvm.getelementptr %52[%295] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%293 = llvm.load %296 : !llvm.ptr -> i64
%298 = arith.index_cast %292 : index to i64
%299 = arith.addi %261, %298 : i64
%300 = llvm.getelementptr %59[%299] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%297 = llvm.load %300 : !llvm.ptr -> i64
%301 = arith.constant 0 : i32
%303 = arith.extsi %301 : i32 to i64
%302 = arith.cmpi ne, %293, %303 : i64
%304 = scf.if %302 -> (i1) {
%305 = arith.constant true
scf.yield %305 : i1
} else {
%306 = arith.constant 0 : i32
%308 = arith.extsi %306 : i32 to i64
%307 = arith.cmpi ne, %297, %308 : i64
scf.yield %307 : i1
}
cf.cond_br %304, ^bb30, ^bb31
^bb30:
%309 = arith.addi %292, %280 : index
%310 = arith.index_cast %309 : index to i32
%311 = arith.extsi %310 : i32 to i64
%312 = arith.addi %256, %311 : i64
%314 = llvm.getelementptr %200[%312] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%313 = llvm.load %314 : !llvm.ptr -> i64
%315 = arith.addi %313, %293 : i64
%316 = llvm.mlir.addressof @MOD : !llvm.ptr
%317 = llvm.load %316 : !llvm.ptr -> i64
%318 = arith.remsi %315, %317 : i64
%319 = llvm.getelementptr %200[%312] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %318, %319 : i64, !llvm.ptr
%320 = arith.index_cast %280 : index to i64
%322 = arith.constant 1 : i32
%324 = arith.index_cast %247 : index to i32
%323 = arith.subi %324, %322 : i32
%325 = arith.extsi %323 : i32 to i64
%326 = llvm.getelementptr %3[%325] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%321 = llvm.load %326 : !llvm.ptr -> i64
%327 = arith.muli %320, %321 : i64
%328 = llvm.mlir.addressof @MOD : !llvm.ptr
%329 = llvm.load %328 : !llvm.ptr -> i64
%330 = arith.remsi %327, %329 : i64
%331 = arith.muli %330, %293 : i64
%332 = llvm.mlir.addressof @MOD : !llvm.ptr
%333 = llvm.load %332 : !llvm.ptr -> i64
%334 = arith.remsi %331, %333 : i64
%336 = llvm.getelementptr %207[%312] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%335 = llvm.load %336 : !llvm.ptr -> i64
%337 = arith.addi %335, %334 : i64
%338 = arith.addi %337, %297 : i64
%339 = llvm.mlir.addressof @MOD : !llvm.ptr
%340 = llvm.load %339 : !llvm.ptr -> i64
%341 = arith.remsi %338, %340 : i64
%342 = llvm.getelementptr %207[%312] : (!llvm.ptr, i64) -> !llvm.ptr, i64
llvm.store %341, %342 : i64, !llvm.ptr
cf.br ^bb32
^bb31:
cf.br ^bb32
^bb32:
%343 = arith.addi %292, %284 : index
cf.br ^bb27(%343 : index)
^bb29(%344: index):
%345 = arith.addi %280, %272 : index
cf.br ^bb24(%345 : index)
^bb26(%346: index):
%347 = arith.addi %247, %239 : index
cf.br ^bb21(%347 : index)
^bb23(%348: index):
%349 = arith.constant 0 : i32
%350 = arith.extsi %349 : i32 to i64
%351 = llvm.mlir.constant(1 : i64) : i64
%352 = llvm.alloca %351 x i64 : (i64) -> !llvm.ptr
llvm.store %350, %352 : i64, !llvm.ptr
%353 = arith.constant 1 : i32
%354 = arith.cmpi sge, %0, %353 : i32
cf.cond_br %354, ^bb33, ^bb34
^bb33:
%355 = arith.constant 45 : i32
%356 = llvm.mlir.addressof @MOD : !llvm.ptr
%357 = llvm.load %356 : !llvm.ptr -> i64
%359 = arith.extsi %355 : i32 to i64
%358 = arith.remsi %359, %357 : i64
llvm.store %358, %352 : i64, !llvm.ptr
cf.br ^bb35
^bb34:
cf.br ^bb35
^bb35:
%360 = arith.constant 2 : i32
%361 = arith.constant 1 : i32
%362 = arith.addi %0, %361 : i32
%363 = arith.index_cast %360 : i32 to index
%364 = arith.index_cast %362 : i32 to index
%366 = arith.constant 1 : index
%367 = arith.constant -1 : index
%368 = arith.cmpi sle, %363, %364 : index
%365 = arith.select %368, %366, %367 : index
cf.br ^bb36(%363 : index)
^bb36(%369: index):
%370 = arith.cmpi slt, %369, %364 : index
%371 = arith.cmpi sgt, %369, %364 : index
%372 = arith.select %368, %370, %371 : i1
cf.cond_br %372, ^bb37(%369 : index), ^bb38(%369 : index)
^bb37(%373: index):
%374 = arith.constant 2 : i32
%376 = arith.index_cast %373 : index to i32
%375 = arith.divsi %376, %374 : i32
%377 = arith.constant 2 : i32
%379 = arith.index_cast %373 : index to i32
%378 = arith.remsi %379, %377 : i32
%380 = arith.constant 0 : i32
%381 = arith.cmpi eq, %378, %380 : i32
%382 = arith.constant 9 : i32
%383 = arith.muli %382, %375 : i32
%384 = arith.extsi %375 : i32 to i64
%385 = arith.muli %384, %51 : i64
%386 = arith.constant 0 : i32
%387 = arith.extsi %386 : i32 to i64
%388 = llvm.mlir.constant(1 : i64) : i64
%389 = llvm.alloca %388 x i64 : (i64) -> !llvm.ptr
llvm.store %387, %389 : i64, !llvm.ptr
cf.cond_br %381, ^bb39, ^bb40
^bb39:
%391 = arith.extsi %375 : i32 to i64
%392 = llvm.getelementptr %3[%391] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%390 = llvm.load %392 : !llvm.ptr -> i64
%393 = arith.constant 0 : i32
%394 = arith.constant 1 : i32
%395 = arith.addi %383, %394 : i32
%396 = arith.index_cast %393 : i32 to index
%397 = arith.index_cast %395 : i32 to index
%399 = arith.constant 1 : index
%400 = arith.constant -1 : index
%401 = arith.cmpi sle, %396, %397 : index
%398 = arith.select %401, %399, %400 : index
cf.br ^bb42(%396 : index)
^bb42(%402: index):
%403 = arith.cmpi slt, %402, %397 : index
%404 = arith.cmpi sgt, %402, %397 : index
%405 = arith.select %401, %403, %404 : i1
cf.cond_br %405, ^bb43(%402 : index), ^bb44(%402 : index)
^bb43(%406: index):
%408 = arith.index_cast %406 : index to i64
%409 = arith.addi %385, %408 : i64
%410 = llvm.getelementptr %200[%409] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%407 = llvm.load %410 : !llvm.ptr -> i64
%412 = arith.index_cast %406 : index to i64
%413 = arith.addi %385, %412 : i64
%414 = llvm.getelementptr %52[%413] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%411 = llvm.load %414 : !llvm.ptr -> i64
%416 = arith.index_cast %406 : index to i64
%417 = arith.addi %385, %416 : i64
%418 = llvm.getelementptr %207[%417] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%415 = llvm.load %418 : !llvm.ptr -> i64
%420 = arith.index_cast %406 : index to i64
%421 = arith.addi %385, %420 : i64
%422 = llvm.getelementptr %59[%421] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%419 = llvm.load %422 : !llvm.ptr -> i64
%423 = arith.constant 0 : i32
%425 = arith.extsi %423 : i32 to i64
%424 = arith.cmpi ne, %407, %425 : i64
%426 = scf.if %424 -> (i1) {
%427 = arith.constant true
scf.yield %427 : i1
} else {
%428 = arith.constant 0 : i32
%430 = arith.extsi %428 : i32 to i64
%429 = arith.cmpi ne, %411, %430 : i64
scf.yield %429 : i1
}
cf.cond_br %426, ^bb45, ^bb46
^bb45:
%431 = llvm.load %389 : !llvm.ptr -> i64
%432 = arith.muli %415, %390 : i64
%433 = llvm.mlir.addressof @MOD : !llvm.ptr
%434 = llvm.load %433 : !llvm.ptr -> i64
%435 = arith.remsi %432, %434 : i64
%436 = arith.muli %435, %411 : i64
%437 = llvm.mlir.addressof @MOD : !llvm.ptr
%438 = llvm.load %437 : !llvm.ptr -> i64
%439 = arith.remsi %436, %438 : i64
%440 = arith.addi %431, %439 : i64
%441 = llvm.mlir.addressof @MOD : !llvm.ptr
%442 = llvm.load %441 : !llvm.ptr -> i64
%443 = arith.remsi %440, %442 : i64
llvm.store %443, %389 : i64, !llvm.ptr
%444 = llvm.load %389 : !llvm.ptr -> i64
%445 = arith.muli %407, %419 : i64
%446 = llvm.mlir.addressof @MOD : !llvm.ptr
%447 = llvm.load %446 : !llvm.ptr -> i64
%448 = arith.remsi %445, %447 : i64
%449 = arith.addi %444, %448 : i64
%450 = llvm.mlir.addressof @MOD : !llvm.ptr
%451 = llvm.load %450 : !llvm.ptr -> i64
%452 = arith.remsi %449, %451 : i64
llvm.store %452, %389 : i64, !llvm.ptr
cf.br ^bb47
^bb46:
cf.br ^bb47
^bb47:
%453 = arith.addi %406, %398 : index
cf.br ^bb42(%453 : index)
^bb44(%454: index):
cf.br ^bb41
^bb40:
%456 = arith.constant 1 : i32
%457 = arith.addi %375, %456 : i32
%458 = arith.extsi %457 : i32 to i64
%459 = llvm.getelementptr %3[%458] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%455 = llvm.load %459 : !llvm.ptr -> i64
%461 = arith.extsi %375 : i32 to i64
%462 = llvm.getelementptr %3[%461] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%460 = llvm.load %462 : !llvm.ptr -> i64
%463 = arith.constant 0 : i32
%464 = arith.constant 1 : i32
%465 = arith.addi %383, %464 : i32
%466 = arith.index_cast %463 : i32 to index
%467 = arith.index_cast %465 : i32 to index
%469 = arith.constant 1 : index
%470 = arith.constant -1 : index
%471 = arith.cmpi sle, %466, %467 : index
%468 = arith.select %471, %469, %470 : index
cf.br ^bb48(%466 : index)
^bb48(%472: index):
%473 = arith.cmpi slt, %472, %467 : index
%474 = arith.cmpi sgt, %472, %467 : index
%475 = arith.select %471, %473, %474 : i1
cf.cond_br %475, ^bb49(%472 : index), ^bb50(%472 : index)
^bb49(%476: index):
%478 = arith.index_cast %476 : index to i64
%479 = arith.addi %385, %478 : i64
%480 = llvm.getelementptr %200[%479] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%477 = llvm.load %480 : !llvm.ptr -> i64
%482 = arith.index_cast %476 : index to i64
%483 = arith.addi %385, %482 : i64
%484 = llvm.getelementptr %52[%483] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%481 = llvm.load %484 : !llvm.ptr -> i64
%486 = arith.index_cast %476 : index to i64
%487 = arith.addi %385, %486 : i64
%488 = llvm.getelementptr %207[%487] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%485 = llvm.load %488 : !llvm.ptr -> i64
%490 = arith.index_cast %476 : index to i64
%491 = arith.addi %385, %490 : i64
%492 = llvm.getelementptr %59[%491] : (!llvm.ptr, i64) -> !llvm.ptr, i64
%489 = llvm.load %492 : !llvm.ptr -> i64
%493 = arith.constant 0 : i32
%495 = arith.extsi %493 : i32 to i64
%494 = arith.cmpi ne, %477, %495 : i64
%496 = scf.if %494 -> (i1) {
%497 = arith.constant true
scf.yield %497 : i1
} else {
%498 = arith.constant 0 : i32
%500 = arith.extsi %498 : i32 to i64
%499 = arith.cmpi ne, %481, %500 : i64
scf.yield %499 : i1
}
cf.cond_br %496, ^bb51, ^bb52
^bb51:
%501 = llvm.load %389 : !llvm.ptr -> i64
%502 = arith.muli %485, %455 : i64
%503 = llvm.mlir.addressof @MOD : !llvm.ptr
%504 = llvm.load %503 : !llvm.ptr -> i64
%505 = arith.remsi %502, %504 : i64
%506 = arith.muli %505, %481 : i64
%507 = llvm.mlir.addressof @MOD : !llvm.ptr
%508 = llvm.load %507 : !llvm.ptr -> i64
%509 = arith.remsi %506, %508 : i64
%510 = arith.constant 10 : i32
%512 = arith.extsi %510 : i32 to i64
%511 = arith.muli %509, %512 : i64
%513 = arith.addi %501, %511 : i64
%514 = llvm.mlir.addressof @MOD : !llvm.ptr
%515 = llvm.load %514 : !llvm.ptr -> i64
%516 = arith.remsi %513, %515 : i64
llvm.store %516, %389 : i64, !llvm.ptr
%517 = llvm.load %389 : !llvm.ptr -> i64
%518 = arith.constant 45 : i32
%520 = arith.extsi %518 : i32 to i64
%519 = arith.muli %520, %460 : i64
%521 = llvm.mlir.addressof @MOD : !llvm.ptr
%522 = llvm.load %521 : !llvm.ptr -> i64
%523 = arith.remsi %519, %522 : i64
%524 = arith.muli %523, %477 : i64
%525 = llvm.mlir.addressof @MOD : !llvm.ptr
%526 = llvm.load %525 : !llvm.ptr -> i64
%527 = arith.remsi %524, %526 : i64
%528 = arith.muli %527, %481 : i64
%529 = llvm.mlir.addressof @MOD : !llvm.ptr
%530 = llvm.load %529 : !llvm.ptr -> i64
%531 = arith.remsi %528, %530 : i64
%532 = arith.addi %517, %531 : i64
%533 = llvm.mlir.addressof @MOD : !llvm.ptr
%534 = llvm.load %533 : !llvm.ptr -> i64
%535 = arith.remsi %532, %534 : i64
llvm.store %535, %389 : i64, !llvm.ptr
%536 = llvm.load %389 : !llvm.ptr -> i64
%537 = arith.muli %477, %489 : i64
%538 = llvm.mlir.addressof @MOD : !llvm.ptr
%539 = llvm.load %538 : !llvm.ptr -> i64
%540 = arith.remsi %537, %539 : i64
%541 = arith.constant 10 : i32
%543 = arith.extsi %541 : i32 to i64
%542 = arith.muli %540, %543 : i64
%544 = arith.addi %536, %542 : i64
%545 = llvm.mlir.addressof @MOD : !llvm.ptr
%546 = llvm.load %545 : !llvm.ptr -> i64
%547 = arith.remsi %544, %546 : i64
llvm.store %547, %389 : i64, !llvm.ptr
cf.br ^bb53
^bb52:
cf.br ^bb53
^bb53:
%548 = arith.addi %476, %468 : index
cf.br ^bb48(%548 : index)
^bb50(%549: index):
cf.br ^bb41
^bb41:
%550 = llvm.load %352 : !llvm.ptr -> i64
%551 = llvm.load %389 : !llvm.ptr -> i64
%552 = arith.addi %550, %551 : i64
%553 = llvm.mlir.addressof @MOD : !llvm.ptr
%554 = llvm.load %553 : !llvm.ptr -> i64
%555 = arith.remsi %552, %554 : i64
llvm.store %555, %352 : i64, !llvm.ptr
%556 = arith.addi %373, %365 : index
cf.br ^bb36(%556 : index)
^bb38(%557: index):
%558 = llvm.mlir.addressof @str_0 : !llvm.ptr
%559 = llvm.load %352 : !llvm.ptr -> i64
%560 = llvm.call @printf(%558, %559) vararg(!llvm.func<i32 (ptr, ...)>) : (!llvm.ptr, i64) -> i32
func.call @free(%3) : (!llvm.ptr) -> ()
func.call @free(%52) : (!llvm.ptr) -> ()
func.call @free(%59) : (!llvm.ptr) -> ()
func.call @free(%66) : (!llvm.ptr) -> ()
func.call @free(%200) : (!llvm.ptr) -> ()
func.call @free(%207) : (!llvm.ptr) -> ()
func.call @free(%214) : (!llvm.ptr) -> ()
%568 = arith.constant 0 : i32
func.return %568 : i32
}
}