Problem 506

Clock Sequence — S(10^14) mod 123454321.

Answer18934502
Output18934502
StatusPASS
Native helperno
Runtime0 ms
Peak memory1072 KB
Time complexityO(n^3) (estimated)
Space complexityO(n^2) (estimated)

Performance comparison

MetricOur solutionBest known
Time complexityO(n^3)?
Space complexityO(n^2)?
ApproachFlow solutionNot curated
VerdictUnknown

Flow source

# Project Euler 506
# Clock Sequence — S(10^14) mod 123454321.

const MOD: i64 = 123454321
const L: i64 = 6
const N: i64 = 100000000000000

function modpow10(e: i64) -> i64 {
    let mut r: i64 = 1
    let mut b: i64 = 10
    let mut exp: i64 = e
    while exp > 0 {
        if (exp & 1) != 0 {
            r = ((r as i128) * (b as i128) % (MOD as i128)) as i64
        }
        b = ((b as i128) * (b as i128) % (MOD as i128)) as i64
        exp = exp >> 1
    }
    return r
}

function pow_sum(base: i64, n: i64, p_out: ptr<i64>, s_out: ptr<i64>) -> void {
    if n == 0 {
        p_out[0] = 1 % MOD
        s_out[0] = 0
        return
    }
    if n == 1 {
        p_out[0] = base % MOD
        s_out[0] = 1
        return
    }
    if (n & 1) == 0 {
        pow_sum(base, n / 2, p_out, s_out)
        let p: i64 = p_out[0]
        let s: i64 = s_out[0]
        let p2: i64 = ((p as i128) * (p as i128) % (MOD as i128)) as i64
        let s2: i64 = ((s as i128) * ((1 + p) % MOD) % (MOD as i128)) as i64
        p_out[0] = p2
        s_out[0] = s2
        return
    }
    pow_sum(base, n - 1, p_out, s_out)
    let p3: i64 = p_out[0]
    let s3: i64 = s_out[0]
    p_out[0] = ((p3 as i128) * (base as i128) % (MOD as i128)) as i64
    s_out[0] = (s3 + p3) % MOD
}

function pow_sum_idx(base: i64, n: i64, p_out: ptr<i64>, s_out: ptr<i64>, t_out: ptr<i64>) -> void {
    if n == 0 {
        p_out[0] = 1 % MOD
        s_out[0] = 0
        t_out[0] = 0
        return
    }
    if n == 1 {
        p_out[0] = base % MOD
        s_out[0] = 1
        t_out[0] = 0
        return
    }
    if (n & 1) == 0 {
        let m: i64 = n / 2
        pow_sum_idx(base, m, p_out, s_out, t_out)
        let p: i64 = p_out[0]
        let s: i64 = s_out[0]
        let t: i64 = t_out[0]
        let p2: i64 = ((p as i128) * (p as i128) % (MOD as i128)) as i64
        let s2: i64 = ((s as i128) * ((1 + p) % MOD) % (MOD as i128)) as i64
        let t2: i64 = ((t as i128) * ((1 + p) % MOD) % (MOD as i128)
            + ((p as i128) * ((m % MOD) as i128) % (MOD as i128) * (s as i128) % (MOD as i128)) % (MOD as i128)) as i64
        p_out[0] = p2
        s_out[0] = s2
        t_out[0] = t2 % MOD
        return
    }
    pow_sum_idx(base, n - 1, p_out, s_out, t_out)
    let p3: i64 = p_out[0]
    let s3: i64 = s_out[0]
    let t3: i64 = t_out[0]
    p_out[0] = ((p3 as i128) * (base as i128) % (MOD as i128)) as i64
    s_out[0] = (s3 + p3) % MOD
    t_out[0] = (t3 + ((n - 1) % MOD) * p3) % MOD
}

function digit_at(pos: i64) -> i64 {
    let r: i64 = pos % L
    if r == 0 { return 1 }
    if r == 1 { return 2 }
    if r == 2 { return 3 }
    if r == 3 { return 4 }
    if r == 4 { return 3 }
    return 2
}

function brute_prefix(n_max: i64, pos_out: ptr<i64>) -> i64 {
    let mut pos: i64 = 0
    let mut total: i64 = 0
    let mut n: i64 = 1
    while n <= n_max {
        let mut s: i64 = 0
        let mut val: i64 = 0
        while s < n {
            let d: i64 = digit_at(pos)
            pos = (pos + 1) % L
            s = s + d
            val = (val * 10 + d) % MOD
        }
        total = (total + val) % MOD
        n = n + 1
    }
    pos_out[0] = pos
    return total
}

function main() -> i32 {
    let n0: i64 = 15
    let small: i64 = N
    if small > n0 - 1 { small = n0 - 1 }
    let pos_buf: ptr<i64> = calloc(1, 8)
    if pos_buf == null { return 1 }
    let mut ans: i64 = brute_prefix(small, pos_buf)
    if N <= n0 - 1 {
        printf("%lld\n", ans)
        free(pos_buf)
        return 0
    }
    let pos: i64 = pos_buf[0]

    let block: ptr<i64> = calloc(L, 8)
    let prefix_sum: ptr<i64> = calloc(L * 7, 8)
    let prefix_int: ptr<i64> = calloc(L * 7, 8)
    let best_i: ptr<i64> = calloc(L * 15, 8)
    let best_p: ptr<i64> = calloc(L * 15, 8)
    if block == null || prefix_sum == null || prefix_int == null
        || best_i == null || best_p == null { return 1 }

    let mut ppos: i64 = 0
    while ppos < L {
        let mut b: i64 = 0
        let mut s: i64 = 0
        let mut v: i64 = 0
        prefix_sum[ppos * 7 + 0] = 0
        prefix_int[ppos * 7 + 0] = 0
        let mut i: i64 = 1
        while i <= L {
            let d: i64 = digit_at(ppos + i - 1)
            b = b * 10 + d
            s = s + d
            v = (v * 10 + d) % MOD
            prefix_sum[ppos * 7 + i] = s
            prefix_int[ppos * 7 + i] = v
            i = i + 1
        }
        block[ppos] = b
        ppos = ppos + 1
    }

    ppos = 0
    while ppos < L {
        let mut r: i64 = 0
        while r < 15 {
            let mut best_len: i64 = -1
            let mut best_key: i64 = 999999999
            let mut best_ii: i64 = 0
            let mut best_pp: i64 = 0
            let mut ii: i64 = 1
            while ii <= L {
                if prefix_sum[ppos * 7 + ii] % 15 == r {
                    let pp: i64 = prefix_sum[ppos * 7 + ii]
                    let key: i64 = 5 * ii - 2 * pp
                    if best_len < 0 || key < best_key || (key == best_key && ii < best_ii) {
                        best_key = key
                        best_ii = ii
                        best_pp = pp
                        best_len = 1
                    }
                }
                ii = ii + 1
            }
            best_i[ppos * 15 + r] = best_ii
            best_p[ppos * 15 + r] = best_pp
            r = r + 1
        }
        ppos = ppos + 1
    }

    let seq_n: ptr<i64> = calloc(15, 8)
    let seq_pos: ptr<i64> = calloc(15, 8)
    let seq_i: ptr<i64> = calloc(15, 8)
    let seq_p: ptr<i64> = calloc(15, 8)
    let seq_b: ptr<i64> = calloc(15, 8)
    let seq_pre: ptr<i64> = calloc(15, 8)
    if seq_n == null || seq_pos == null || seq_i == null || seq_p == null
        || seq_b == null || seq_pre == null { return 1 }

    let mut cur_pos: i64 = pos
    let mut j: i64 = 0
    while j < 15 {
        let n: i64 = n0 + j
        let rr: i64 = n % 15
        let ii: i64 = best_i[cur_pos * 15 + rr]
        let pp: i64 = best_p[cur_pos * 15 + rr]
        seq_n[j] = n
        seq_pos[j] = cur_pos
        seq_i[j] = ii
        seq_p[j] = pp
        seq_b[j] = block[cur_pos]
        seq_pre[j] = prefix_int[cur_pos * 7 + ii]
        cur_pos = (cur_pos + ii) % L
        j = j + 1
    }

    let total_terms: i64 = N - (n0 - 1)
    let K: i64 = total_terms / 15
    let rem: i64 = total_terms % 15

    let pow10: ptr<i64> = calloc(7, 8)
    if pow10 == null { return 1 }
    pow10[0] = 1
    let mut pi: i64 = 1
    while pi <= 6 {
        pow10[pi] = modpow10(pi)
        pi = pi + 1
    }

    let a: i64 = modpow10(6)
    let tmp: ptr<i64> = calloc(3, 8)
    if tmp == null { return 1 }
    let mut H: i64 = 0
    if K > 1 {
        pow_sum_idx(a, K - 1, tmp, tmp + 1, tmp + 2)
        let nn: i64 = K - 1
        H = (((nn % MOD) * tmp[1] % MOD - tmp[2]) % MOD + MOD) % MOD
    }
    pow_sum_idx(a, K, tmp, tmp + 1, tmp + 2)
    let sum_aK: i64 = tmp[1]
    let K_mod: i64 = K % MOD

    if K > 0 {
        j = 0
        while j < 15 {
            let nn: i64 = seq_n[j]
            let ii: i64 = seq_i[j]
            let pp: i64 = seq_p[j]
            let bb: i64 = seq_b[j]
            let pre: i64 = seq_pre[j]
            let t0: i64 = (nn - pp) / 15
            pow_sum(a, t0, tmp, tmp + 1)
            let at0: i64 = tmp[0]
            let G0: i64 = tmp[1]
            let sumG: i64 = (K_mod * G0 % MOD + ((at0 as i128) * (H as i128) % (MOD as i128)) as i64) % MOD
            let mut term_sum: i64 = (((bb * pow10[ii]) % MOD) * sumG) % MOD
            term_sum = (term_sum + pre * K_mod) % MOD
            ans = (ans + term_sum) % MOD
            j = j + 1
        }
    }

    if rem > 0 {
        j = 0
        while j < rem {
            let nn2: i64 = seq_n[j]
            let ii2: i64 = seq_i[j]
            let pp2: i64 = seq_p[j]
            let bb2: i64 = seq_b[j]
            let pre2: i64 = seq_pre[j]
            let t02: i64 = (nn2 - pp2) / 15
            pow_sum(a, t02, tmp, tmp + 1)
            let at02: i64 = tmp[0]
            let G02: i64 = tmp[1]
            let G: i64 = (G02 + ((at02 as i128) * (sum_aK as i128) % (MOD as i128)) as i64) % MOD
            let mut v: i64 = (((bb2 * pow10[ii2]) % MOD) * G) % MOD
            v = (v + pre2) % MOD
            ans = (ans + v) % MOD
            j = j + 1
        }
    }

    printf("%lld\n", ans)
    free(pos_buf); free(block); free(prefix_sum); free(prefix_int)
    free(best_i); free(best_p)
    free(seq_n); free(seq_pos); free(seq_i); free(seq_p); free(seq_b); free(seq_pre)
    free(pow10); free(tmp)
    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 modpow10_i64(int64_t e);
void pow_sum_i64_i64_ptr_i64_ptr_i64(int64_t base, int64_t n, int64_t* p_out, int64_t* s_out);
void pow_sum_idx_i64_i64_ptr_i64_ptr_i64_ptr_i64(int64_t base, int64_t n, int64_t* p_out, int64_t* s_out, int64_t* t_out);
int64_t digit_at_i64(int64_t pos);
int64_t brute_prefix_i64_ptr_i64(int64_t n_max, int64_t* pos_out);
int32_t main(void);

static const int64_t MOD = 123454321;
static const int64_t L = 6;
static const int64_t N = 100000000000000;

int64_t modpow10_i64(int64_t e) {
    int64_t r = 1;
    int64_t b = 10;
    int64_t exp = e;
    while (exp > 0) {
        if ((exp & 1) != 0) {
            r = ((int64_t)(FLOW_CHECKED_MOD(((((__int128)(r)) * ((__int128)(b)))), (((__int128)(MOD))))));
        }
        b = ((int64_t)(FLOW_CHECKED_MOD(((((__int128)(b)) * ((__int128)(b)))), (((__int128)(MOD))))));
        exp = FLOW_CHECKED_SHR((exp), (1));
    }
    return r;
}

void pow_sum_i64_i64_ptr_i64_ptr_i64(int64_t base, int64_t n, int64_t* p_out, int64_t* s_out) {
    if (n == 0) {
        p_out[0] = FLOW_CHECKED_MOD((1), (MOD));
        s_out[0] = 0;
        return;
    }
    if (n == 1) {
        p_out[0] = FLOW_CHECKED_MOD((base), (MOD));
        s_out[0] = 1;
        return;
    }
    if ((n & 1) == 0) {
        pow_sum_i64_i64_ptr_i64_ptr_i64(base, FLOW_CHECKED_DIV((n), (2)), p_out, s_out);
        int64_t p = p_out[0];
        int64_t s = s_out[0];
        int64_t p2 = ((int64_t)(FLOW_CHECKED_MOD(((((__int128)(p)) * ((__int128)(p)))), (((__int128)(MOD))))));
        int64_t s2 = ((int64_t)(FLOW_CHECKED_MOD(((((__int128)(s)) * FLOW_CHECKED_MOD(((1 + p)), (MOD)))), (((__int128)(MOD))))));
        p_out[0] = p2;
        s_out[0] = s2;
        return;
    }
    pow_sum_i64_i64_ptr_i64_ptr_i64(base, (n - 1), p_out, s_out);
    int64_t p3 = p_out[0];
    int64_t s3 = s_out[0];
    p_out[0] = ((int64_t)(FLOW_CHECKED_MOD(((((__int128)(p3)) * ((__int128)(base)))), (((__int128)(MOD))))));
    s_out[0] = FLOW_CHECKED_MOD(((s3 + p3)), (MOD));
}

void pow_sum_idx_i64_i64_ptr_i64_ptr_i64_ptr_i64(int64_t base, int64_t n, int64_t* p_out, int64_t* s_out, int64_t* t_out) {
    if (n == 0) {
        p_out[0] = FLOW_CHECKED_MOD((1), (MOD));
        s_out[0] = 0;
        t_out[0] = 0;
        return;
    }
    if (n == 1) {
        p_out[0] = FLOW_CHECKED_MOD((base), (MOD));
        s_out[0] = 1;
        t_out[0] = 0;
        return;
    }
    if ((n & 1) == 0) {
        int64_t m = FLOW_CHECKED_DIV((n), (2));
        pow_sum_idx_i64_i64_ptr_i64_ptr_i64_ptr_i64(base, m, p_out, s_out, t_out);
        int64_t p = p_out[0];
        int64_t s = s_out[0];
        int64_t t = t_out[0];
        int64_t p2 = ((int64_t)(FLOW_CHECKED_MOD(((((__int128)(p)) * ((__int128)(p)))), (((__int128)(MOD))))));
        int64_t s2 = ((int64_t)(FLOW_CHECKED_MOD(((((__int128)(s)) * FLOW_CHECKED_MOD(((1 + p)), (MOD)))), (((__int128)(MOD))))));
        int64_t t2 = ((int64_t)((FLOW_CHECKED_MOD(((((__int128)(t)) * FLOW_CHECKED_MOD(((1 + p)), (MOD)))), (((__int128)(MOD)))) + FLOW_CHECKED_MOD((FLOW_CHECKED_MOD(((FLOW_CHECKED_MOD(((((__int128)(p)) * ((__int128)(FLOW_CHECKED_MOD((m), (MOD)))))), (((__int128)(MOD)))) * ((__int128)(s)))), (((__int128)(MOD))))), (((__int128)(MOD)))))));
        p_out[0] = p2;
        s_out[0] = s2;
        t_out[0] = FLOW_CHECKED_MOD((t2), (MOD));
        return;
    }
    pow_sum_idx_i64_i64_ptr_i64_ptr_i64_ptr_i64(base, (n - 1), p_out, s_out, t_out);
    int64_t p3 = p_out[0];
    int64_t s3 = s_out[0];
    int64_t t3 = t_out[0];
    p_out[0] = ((int64_t)(FLOW_CHECKED_MOD(((((__int128)(p3)) * ((__int128)(base)))), (((__int128)(MOD))))));
    s_out[0] = FLOW_CHECKED_MOD(((s3 + p3)), (MOD));
    t_out[0] = FLOW_CHECKED_MOD(((t3 + (FLOW_CHECKED_MOD(((n - 1)), (MOD)) * p3))), (MOD));
}

int64_t digit_at_i64(int64_t pos) {
    int64_t r = FLOW_CHECKED_MOD((pos), (L));
    if (r == 0) {
        return 1;
    }
    if (r == 1) {
        return 2;
    }
    if (r == 2) {
        return 3;
    }
    if (r == 3) {
        return 4;
    }
    if (r == 4) {
        return 3;
    }
    return 2;
}

int64_t brute_prefix_i64_ptr_i64(int64_t n_max, int64_t* pos_out) {
    int64_t pos = 0;
    int64_t total = 0;
    int64_t n = 1;
    while (n <= n_max) {
        int64_t s = 0;
        int64_t val = 0;
        while (s < n) {
            int64_t d = digit_at_i64(pos);
            pos = FLOW_CHECKED_MOD(((pos + 1)), (L));
            s = (s + d);
            val = FLOW_CHECKED_MOD((((val * 10) + d)), (MOD));
        }
        total = FLOW_CHECKED_MOD(((total + val)), (MOD));
        n = (n + 1);
    }
    pos_out[0] = pos;
    return total;
}

int32_t main(void) {
    int64_t n0 = 15;
    int64_t small = N;
    if (small > (n0 - 1)) {
        small = (n0 - 1);
    }
    int64_t* pos_buf = (int64_t*)(calloc(1, 8));
    if (pos_buf == NULL) {
        return 1;
    }
    int64_t ans = brute_prefix_i64_ptr_i64(small, pos_buf);
    if (N <= (n0 - 1)) {
        printf("%lld\n", ans);
        free(pos_buf);
        return 0;
    }
    int64_t pos = pos_buf[0];
    int64_t* block = (int64_t*)(calloc(L, 8));
    int64_t* prefix_sum = (int64_t*)(calloc((L * 7), 8));
    int64_t* prefix_int = (int64_t*)(calloc((L * 7), 8));
    int64_t* best_i = (int64_t*)(calloc((L * 15), 8));
    int64_t* best_p = (int64_t*)(calloc((L * 15), 8));
    if (((((block == NULL || prefix_sum == NULL) || prefix_int == NULL) || best_i == NULL) || best_p == NULL)) {
        return 1;
    }
    int64_t ppos = 0;
    while (ppos < L) {
        int64_t b = 0;
        int64_t s = 0;
        int64_t v = 0;
        prefix_sum[((ppos * 7) + 0)] = 0;
        prefix_int[((ppos * 7) + 0)] = 0;
        int64_t i = 1;
        while (i <= L) {
            int64_t d = digit_at_i64(((ppos + i) - 1));
            b = ((b * 10) + d);
            s = (s + d);
            v = FLOW_CHECKED_MOD((((v * 10) + d)), (MOD));
            prefix_sum[((ppos * 7) + i)] = s;
            prefix_int[((ppos * 7) + i)] = v;
            i = (i + 1);
        }
        block[ppos] = b;
        ppos = (ppos + 1);
    }
    ppos = 0;
    while (ppos < L) {
        int64_t r = 0;
        while (r < 15) {
            int64_t best_len = (-1);
            int64_t best_key = 999999999;
            int64_t best_ii = 0;
            int64_t best_pp = 0;
            int64_t ii = 1;
            while (ii <= L) {
                if (FLOW_CHECKED_MOD((prefix_sum[((ppos * 7) + ii)]), (15)) == r) {
                    int64_t pp = prefix_sum[((ppos * 7) + ii)];
                    int64_t key = ((5 * ii) - (2 * pp));
                    if (((best_len < 0 || key < best_key) || (key == best_key && ii < best_ii))) {
                        best_key = key;
                        best_ii = ii;
                        best_pp = pp;
                        best_len = 1;
                    }
                }
                ii = (ii + 1);
            }
            best_i[((ppos * 15) + r)] = best_ii;
            best_p[((ppos * 15) + r)] = best_pp;
            r = (r + 1);
        }
        ppos = (ppos + 1);
    }
    int64_t* seq_n = (int64_t*)(calloc(15, 8));
    int64_t* seq_pos = (int64_t*)(calloc(15, 8));
    int64_t* seq_i = (int64_t*)(calloc(15, 8));
    int64_t* seq_p = (int64_t*)(calloc(15, 8));
    int64_t* seq_b = (int64_t*)(calloc(15, 8));
    int64_t* seq_pre = (int64_t*)(calloc(15, 8));
    if ((((((seq_n == NULL || seq_pos == NULL) || seq_i == NULL) || seq_p == NULL) || seq_b == NULL) || seq_pre == NULL)) {
        return 1;
    }
    int64_t cur_pos = pos;
    int64_t j = 0;
    while (j < 15) {
        int64_t n = (n0 + j);
        int64_t rr = FLOW_CHECKED_MOD((n), (15));
        int64_t ii = best_i[((cur_pos * 15) + rr)];
        int64_t pp = best_p[((cur_pos * 15) + rr)];
        seq_n[j] = n;
        seq_pos[j] = cur_pos;
        seq_i[j] = ii;
        seq_p[j] = pp;
        seq_b[j] = block[cur_pos];
        seq_pre[j] = prefix_int[((cur_pos * 7) + ii)];
        cur_pos = FLOW_CHECKED_MOD(((cur_pos + ii)), (L));
        j = (j + 1);
    }
    int64_t total_terms = (N - (n0 - 1));
    int64_t K = FLOW_CHECKED_DIV((total_terms), (15));
    int64_t rem = FLOW_CHECKED_MOD((total_terms), (15));
    int64_t* pow10 = (int64_t*)(calloc(7, 8));
    if (pow10 == NULL) {
        return 1;
    }
    pow10[0] = 1;
    int64_t pi = 1;
    while (pi <= 6) {
        pow10[pi] = modpow10_i64(pi);
        pi = (pi + 1);
    }
    int64_t a = modpow10_i64(6);
    int64_t* tmp = (int64_t*)(calloc(3, 8));
    if (tmp == NULL) {
        return 1;
    }
    int64_t H = 0;
    if (K > 1) {
        pow_sum_idx_i64_i64_ptr_i64_ptr_i64_ptr_i64(a, (K - 1), tmp, (tmp + 1), (tmp + 2));
        int64_t nn = (K - 1);
        H = FLOW_CHECKED_MOD(((FLOW_CHECKED_MOD(((FLOW_CHECKED_MOD(((FLOW_CHECKED_MOD((nn), (MOD)) * tmp[1])), (MOD)) - tmp[2])), (MOD)) + MOD)), (MOD));
    }
    pow_sum_idx_i64_i64_ptr_i64_ptr_i64_ptr_i64(a, K, tmp, (tmp + 1), (tmp + 2));
    int64_t sum_aK = tmp[1];
    int64_t K_mod = FLOW_CHECKED_MOD((K), (MOD));
    if (K > 0) {
        j = 0;
        while (j < 15) {
            int64_t nn = seq_n[j];
            int64_t ii = seq_i[j];
            int64_t pp = seq_p[j];
            int64_t bb = seq_b[j];
            int64_t pre = seq_pre[j];
            int64_t t0 = FLOW_CHECKED_DIV(((nn - pp)), (15));
            pow_sum_i64_i64_ptr_i64_ptr_i64(a, t0, tmp, (tmp + 1));
            int64_t at0 = tmp[0];
            int64_t G0 = tmp[1];
            int64_t sumG = FLOW_CHECKED_MOD(((FLOW_CHECKED_MOD(((K_mod * G0)), (MOD)) + ((int64_t)(FLOW_CHECKED_MOD(((((__int128)(at0)) * ((__int128)(H)))), (((__int128)(MOD)))))))), (MOD));
            int64_t term_sum = FLOW_CHECKED_MOD(((FLOW_CHECKED_MOD(((bb * pow10[ii])), (MOD)) * sumG)), (MOD));
            term_sum = FLOW_CHECKED_MOD(((term_sum + (pre * K_mod))), (MOD));
            ans = FLOW_CHECKED_MOD(((ans + term_sum)), (MOD));
            j = (j + 1);
        }
    }
    if (rem > 0) {
        j = 0;
        while (j < rem) {
            int64_t nn2 = seq_n[j];
            int64_t ii2 = seq_i[j];
            int64_t pp2 = seq_p[j];
            int64_t bb2 = seq_b[j];
            int64_t pre2 = seq_pre[j];
            int64_t t02 = FLOW_CHECKED_DIV(((nn2 - pp2)), (15));
            pow_sum_i64_i64_ptr_i64_ptr_i64(a, t02, tmp, (tmp + 1));
            int64_t at02 = tmp[0];
            int64_t G02 = tmp[1];
            int64_t G = FLOW_CHECKED_MOD(((G02 + ((int64_t)(FLOW_CHECKED_MOD(((((__int128)(at02)) * ((__int128)(sum_aK)))), (((__int128)(MOD)))))))), (MOD));
            int64_t v = FLOW_CHECKED_MOD(((FLOW_CHECKED_MOD(((bb2 * pow10[ii2])), (MOD)) * G)), (MOD));
            v = FLOW_CHECKED_MOD(((v + pre2)), (MOD));
            ans = FLOW_CHECKED_MOD(((ans + v)), (MOD));
            j = (j + 1);
        }
    }
    printf("%lld\n", ans);
    free(pos_buf);
    free(block);
    free(prefix_sum);
    free(prefix_int);
    free(best_i);
    free(best_p);
    free(seq_n);
    free(seq_pos);
    free(seq_i);
    free(seq_p);
    free(seq_b);
    free(seq_pre);
    free(pow10);
    free(tmp);
    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>
  // Constant: MOD
  llvm.mlir.global internal constant @MOD(123454321 : i64) : i64
  // Constant: L
  llvm.mlir.global internal constant @L(6 : i64) : i64
  // Constant: N
  llvm.mlir.global internal constant @N(100000000000000 : i64) : i64
  func.func @modpow10(%arg0: i64) -> i64 {
    %0 = arith.constant 1 : i32
    %1 = arith.extsi %0 : i32 to i64
    %2 = llvm.mlir.constant(1 : i64) : i64
    %3 = llvm.alloca %2 x i64 : (i64) -> !llvm.ptr
    llvm.store %1, %3 : i64, !llvm.ptr
    %4 = arith.constant 10 : i32
    %5 = arith.extsi %4 : i32 to i64
    %6 = llvm.mlir.constant(1 : i64) : i64
    %7 = llvm.alloca %6 x i64 : (i64) -> !llvm.ptr
    llvm.store %5, %7 : i64, !llvm.ptr
    %8 = llvm.mlir.constant(1 : i64) : i64
    %9 = llvm.alloca %8 x i64 : (i64) -> !llvm.ptr
    llvm.store %arg0, %9 : i64, !llvm.ptr
    cf.br ^bb0
    ^bb0:
    %10 = llvm.load %9 : !llvm.ptr -> i64
    %11 = arith.constant 0 : i32
    %13 = arith.extsi %11 : i32 to i64
    %12 = arith.cmpi sgt, %10, %13 : i64
    cf.cond_br %12, ^bb1, ^bb2
    ^bb1:
      %14 = llvm.load %9 : !llvm.ptr -> i64
      %15 = arith.constant 1 : i32
      %17 = arith.extsi %15 : i32 to i64
      %16 = arith.andi %14, %17 : i64
      %18 = arith.constant 0 : i32
      %20 = arith.extsi %18 : i32 to i64
      %19 = arith.cmpi ne, %16, %20 : i64
      cf.cond_br %19, ^bb3, ^bb4
      ^bb3:
        %21 = llvm.load %3 : !llvm.ptr -> i64
        %22 = arith.extsi %21 : i64 to i128
        %23 = llvm.load %7 : !llvm.ptr -> i64
        %24 = arith.extsi %23 : i64 to i128
        %26 = arith.trunci %22 : i128 to i64
        %27 = arith.trunci %24 : i128 to i64
        %25 = arith.muli %26, %27 : i64
        %28 = llvm.mlir.addressof @MOD : !llvm.ptr
        %29 = llvm.load %28 : !llvm.ptr -> i64
        %30 = arith.extsi %29 : i64 to i128
        %32 = arith.trunci %30 : i128 to i64
        %31 = arith.remsi %25, %32 : i64
        llvm.store %31, %3 : i64, !llvm.ptr
        cf.br ^bb5
      ^bb4:
        cf.br ^bb5
      ^bb5:
      %33 = llvm.load %7 : !llvm.ptr -> i64
      %34 = arith.extsi %33 : i64 to i128
      %35 = llvm.load %7 : !llvm.ptr -> i64
      %36 = arith.extsi %35 : i64 to i128
      %38 = arith.trunci %34 : i128 to i64
      %39 = arith.trunci %36 : i128 to i64
      %37 = arith.muli %38, %39 : i64
      %40 = llvm.mlir.addressof @MOD : !llvm.ptr
      %41 = llvm.load %40 : !llvm.ptr -> i64
      %42 = arith.extsi %41 : i64 to i128
      %44 = arith.trunci %42 : i128 to i64
      %43 = arith.remsi %37, %44 : i64
      llvm.store %43, %7 : i64, !llvm.ptr
      %45 = llvm.load %9 : !llvm.ptr -> i64
      %46 = arith.constant 1 : i32
      %48 = arith.extsi %46 : i32 to i64
      %47 = arith.shrsi %45, %48 : i64
      llvm.store %47, %9 : i64, !llvm.ptr
      cf.br ^bb0
    ^bb2:
    %49 = llvm.load %3 : !llvm.ptr -> i64
    func.return %49 : i64
  }
  func.func @pow_sum(%arg0: i64, %arg1: i64, %arg2: !llvm.ptr, %arg3: !llvm.ptr) -> () {
    %50 = arith.constant 0 : i32
    %52 = arith.extsi %50 : i32 to i64
    %51 = arith.cmpi eq, %arg1, %52 : i64
    cf.cond_br %51, ^bb6, ^bb7
    ^bb6:
      %53 = arith.constant 1 : i32
      %54 = llvm.mlir.addressof @MOD : !llvm.ptr
      %55 = llvm.load %54 : !llvm.ptr -> i64
      %57 = arith.extsi %53 : i32 to i64
      %56 = arith.remsi %57, %55 : i64
      %58 = arith.constant 0 : i32
      %59 = arith.extsi %58 : i32 to i64
      %60 = llvm.getelementptr %arg2[%59] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %56, %60 : i64, !llvm.ptr
      %61 = arith.constant 0 : i32
      %62 = arith.constant 0 : i32
      %63 = arith.extsi %61 : i32 to i64
      %64 = arith.extsi %62 : i32 to i64
      %65 = llvm.getelementptr %arg3[%64] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %63, %65 : i64, !llvm.ptr
      func.return
    ^bb7:
      cf.br ^bb8
    ^bb8:
    %66 = arith.constant 1 : i32
    %68 = arith.extsi %66 : i32 to i64
    %67 = arith.cmpi eq, %arg1, %68 : i64
    cf.cond_br %67, ^bb9, ^bb10
    ^bb9:
      %69 = llvm.mlir.addressof @MOD : !llvm.ptr
      %70 = llvm.load %69 : !llvm.ptr -> i64
      %71 = arith.remsi %arg0, %70 : i64
      %72 = arith.constant 0 : i32
      %73 = arith.extsi %72 : i32 to i64
      %74 = llvm.getelementptr %arg2[%73] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %71, %74 : i64, !llvm.ptr
      %75 = arith.constant 1 : i32
      %76 = arith.constant 0 : i32
      %77 = arith.extsi %75 : i32 to i64
      %78 = arith.extsi %76 : i32 to i64
      %79 = llvm.getelementptr %arg3[%78] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %77, %79 : i64, !llvm.ptr
      func.return
    ^bb10:
      cf.br ^bb11
    ^bb11:
    %80 = arith.constant 1 : i32
    %82 = arith.extsi %80 : i32 to i64
    %81 = arith.andi %arg1, %82 : i64
    %83 = arith.constant 0 : i32
    %85 = arith.extsi %83 : i32 to i64
    %84 = arith.cmpi eq, %81, %85 : i64
    cf.cond_br %84, ^bb12, ^bb13
    ^bb12:
      %87 = arith.constant 2 : i32
      %89 = arith.extsi %87 : i32 to i64
      %88 = arith.divsi %arg1, %89 : i64
      func.call @pow_sum(%arg0, %88, %arg2, %arg3) : (i64, i64, !llvm.ptr, !llvm.ptr) -> ()
      %91 = arith.constant 0 : i32
      %92 = arith.extsi %91 : i32 to i64
      %93 = llvm.getelementptr %arg2[%92] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %90 = llvm.load %93 : !llvm.ptr -> i64
      %95 = arith.constant 0 : i32
      %96 = arith.extsi %95 : i32 to i64
      %97 = llvm.getelementptr %arg3[%96] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %94 = llvm.load %97 : !llvm.ptr -> i64
      %98 = arith.extsi %90 : i64 to i128
      %99 = arith.extsi %90 : i64 to i128
      %101 = arith.trunci %98 : i128 to i64
      %102 = arith.trunci %99 : i128 to i64
      %100 = arith.muli %101, %102 : i64
      %103 = llvm.mlir.addressof @MOD : !llvm.ptr
      %104 = llvm.load %103 : !llvm.ptr -> i64
      %105 = arith.extsi %104 : i64 to i128
      %107 = arith.trunci %105 : i128 to i64
      %106 = arith.remsi %100, %107 : i64
      %108 = arith.extsi %94 : i64 to i128
      %109 = arith.constant 1 : i32
      %111 = arith.extsi %109 : i32 to i64
      %110 = arith.addi %111, %90 : i64
      %112 = llvm.mlir.addressof @MOD : !llvm.ptr
      %113 = llvm.load %112 : !llvm.ptr -> i64
      %114 = arith.remsi %110, %113 : i64
      %116 = arith.trunci %108 : i128 to i64
      %115 = arith.muli %116, %114 : i64
      %117 = llvm.mlir.addressof @MOD : !llvm.ptr
      %118 = llvm.load %117 : !llvm.ptr -> i64
      %119 = arith.extsi %118 : i64 to i128
      %121 = arith.trunci %119 : i128 to i64
      %120 = arith.remsi %115, %121 : i64
      %122 = arith.constant 0 : i32
      %123 = arith.extsi %122 : i32 to i64
      %124 = llvm.getelementptr %arg2[%123] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %106, %124 : i64, !llvm.ptr
      %125 = arith.constant 0 : i32
      %126 = arith.extsi %125 : i32 to i64
      %127 = llvm.getelementptr %arg3[%126] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %120, %127 : i64, !llvm.ptr
      func.return
    ^bb13:
      cf.br ^bb14
    ^bb14:
    %129 = arith.constant 1 : i32
    %131 = arith.extsi %129 : i32 to i64
    %130 = arith.subi %arg1, %131 : i64
    func.call @pow_sum(%arg0, %130, %arg2, %arg3) : (i64, i64, !llvm.ptr, !llvm.ptr) -> ()
    %133 = arith.constant 0 : i32
    %134 = arith.extsi %133 : i32 to i64
    %135 = llvm.getelementptr %arg2[%134] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    %132 = llvm.load %135 : !llvm.ptr -> i64
    %137 = arith.constant 0 : i32
    %138 = arith.extsi %137 : i32 to i64
    %139 = llvm.getelementptr %arg3[%138] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    %136 = llvm.load %139 : !llvm.ptr -> i64
    %140 = arith.extsi %132 : i64 to i128
    %141 = arith.extsi %arg0 : i64 to i128
    %143 = arith.trunci %140 : i128 to i64
    %144 = arith.trunci %141 : i128 to i64
    %142 = arith.muli %143, %144 : i64
    %145 = llvm.mlir.addressof @MOD : !llvm.ptr
    %146 = llvm.load %145 : !llvm.ptr -> i64
    %147 = arith.extsi %146 : i64 to i128
    %149 = arith.trunci %147 : i128 to i64
    %148 = arith.remsi %142, %149 : i64
    %150 = arith.constant 0 : i32
    %151 = arith.extsi %150 : i32 to i64
    %152 = llvm.getelementptr %arg2[%151] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    llvm.store %148, %152 : i64, !llvm.ptr
    %153 = arith.addi %136, %132 : i64
    %154 = llvm.mlir.addressof @MOD : !llvm.ptr
    %155 = llvm.load %154 : !llvm.ptr -> i64
    %156 = arith.remsi %153, %155 : i64
    %157 = arith.constant 0 : i32
    %158 = arith.extsi %157 : i32 to i64
    %159 = llvm.getelementptr %arg3[%158] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    llvm.store %156, %159 : i64, !llvm.ptr
    func.return
  }
  func.func @pow_sum_idx(%arg0: i64, %arg1: i64, %arg2: !llvm.ptr, %arg3: !llvm.ptr, %arg4: !llvm.ptr) -> () {
    %160 = arith.constant 0 : i32
    %162 = arith.extsi %160 : i32 to i64
    %161 = arith.cmpi eq, %arg1, %162 : i64
    cf.cond_br %161, ^bb15, ^bb16
    ^bb15:
      %163 = arith.constant 1 : i32
      %164 = llvm.mlir.addressof @MOD : !llvm.ptr
      %165 = llvm.load %164 : !llvm.ptr -> i64
      %167 = arith.extsi %163 : i32 to i64
      %166 = arith.remsi %167, %165 : i64
      %168 = arith.constant 0 : i32
      %169 = arith.extsi %168 : i32 to i64
      %170 = llvm.getelementptr %arg2[%169] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %166, %170 : i64, !llvm.ptr
      %171 = arith.constant 0 : i32
      %172 = arith.constant 0 : i32
      %173 = arith.extsi %171 : i32 to i64
      %174 = arith.extsi %172 : i32 to i64
      %175 = llvm.getelementptr %arg3[%174] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %173, %175 : i64, !llvm.ptr
      %176 = arith.constant 0 : i32
      %177 = arith.constant 0 : i32
      %178 = arith.extsi %176 : i32 to i64
      %179 = arith.extsi %177 : i32 to i64
      %180 = llvm.getelementptr %arg4[%179] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %178, %180 : i64, !llvm.ptr
      func.return
    ^bb16:
      cf.br ^bb17
    ^bb17:
    %181 = arith.constant 1 : i32
    %183 = arith.extsi %181 : i32 to i64
    %182 = arith.cmpi eq, %arg1, %183 : i64
    cf.cond_br %182, ^bb18, ^bb19
    ^bb18:
      %184 = llvm.mlir.addressof @MOD : !llvm.ptr
      %185 = llvm.load %184 : !llvm.ptr -> i64
      %186 = arith.remsi %arg0, %185 : i64
      %187 = arith.constant 0 : i32
      %188 = arith.extsi %187 : i32 to i64
      %189 = llvm.getelementptr %arg2[%188] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %186, %189 : i64, !llvm.ptr
      %190 = arith.constant 1 : i32
      %191 = arith.constant 0 : i32
      %192 = arith.extsi %190 : i32 to i64
      %193 = arith.extsi %191 : i32 to i64
      %194 = llvm.getelementptr %arg3[%193] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %192, %194 : i64, !llvm.ptr
      %195 = arith.constant 0 : i32
      %196 = arith.constant 0 : i32
      %197 = arith.extsi %195 : i32 to i64
      %198 = arith.extsi %196 : i32 to i64
      %199 = llvm.getelementptr %arg4[%198] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %197, %199 : i64, !llvm.ptr
      func.return
    ^bb19:
      cf.br ^bb20
    ^bb20:
    %200 = arith.constant 1 : i32
    %202 = arith.extsi %200 : i32 to i64
    %201 = arith.andi %arg1, %202 : i64
    %203 = arith.constant 0 : i32
    %205 = arith.extsi %203 : i32 to i64
    %204 = arith.cmpi eq, %201, %205 : i64
    cf.cond_br %204, ^bb21, ^bb22
    ^bb21:
      %206 = arith.constant 2 : i32
      %208 = arith.extsi %206 : i32 to i64
      %207 = arith.divsi %arg1, %208 : i64
      func.call @pow_sum_idx(%arg0, %207, %arg2, %arg3, %arg4) : (i64, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr) -> ()
      %211 = arith.constant 0 : i32
      %212 = arith.extsi %211 : i32 to i64
      %213 = llvm.getelementptr %arg2[%212] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %210 = llvm.load %213 : !llvm.ptr -> i64
      %215 = arith.constant 0 : i32
      %216 = arith.extsi %215 : i32 to i64
      %217 = llvm.getelementptr %arg3[%216] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %214 = llvm.load %217 : !llvm.ptr -> i64
      %219 = arith.constant 0 : i32
      %220 = arith.extsi %219 : i32 to i64
      %221 = llvm.getelementptr %arg4[%220] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %218 = llvm.load %221 : !llvm.ptr -> i64
      %222 = arith.extsi %210 : i64 to i128
      %223 = arith.extsi %210 : i64 to i128
      %225 = arith.trunci %222 : i128 to i64
      %226 = arith.trunci %223 : i128 to i64
      %224 = arith.muli %225, %226 : i64
      %227 = llvm.mlir.addressof @MOD : !llvm.ptr
      %228 = llvm.load %227 : !llvm.ptr -> i64
      %229 = arith.extsi %228 : i64 to i128
      %231 = arith.trunci %229 : i128 to i64
      %230 = arith.remsi %224, %231 : i64
      %232 = arith.extsi %214 : i64 to i128
      %233 = arith.constant 1 : i32
      %235 = arith.extsi %233 : i32 to i64
      %234 = arith.addi %235, %210 : i64
      %236 = llvm.mlir.addressof @MOD : !llvm.ptr
      %237 = llvm.load %236 : !llvm.ptr -> i64
      %238 = arith.remsi %234, %237 : i64
      %240 = arith.trunci %232 : i128 to i64
      %239 = arith.muli %240, %238 : i64
      %241 = llvm.mlir.addressof @MOD : !llvm.ptr
      %242 = llvm.load %241 : !llvm.ptr -> i64
      %243 = arith.extsi %242 : i64 to i128
      %245 = arith.trunci %243 : i128 to i64
      %244 = arith.remsi %239, %245 : i64
      %246 = arith.extsi %218 : i64 to i128
      %247 = arith.constant 1 : i32
      %249 = arith.extsi %247 : i32 to i64
      %248 = arith.addi %249, %210 : i64
      %250 = llvm.mlir.addressof @MOD : !llvm.ptr
      %251 = llvm.load %250 : !llvm.ptr -> i64
      %252 = arith.remsi %248, %251 : i64
      %254 = arith.trunci %246 : i128 to i64
      %253 = arith.muli %254, %252 : i64
      %255 = llvm.mlir.addressof @MOD : !llvm.ptr
      %256 = llvm.load %255 : !llvm.ptr -> i64
      %257 = arith.extsi %256 : i64 to i128
      %259 = arith.trunci %257 : i128 to i64
      %258 = arith.remsi %253, %259 : i64
      %260 = arith.extsi %210 : i64 to i128
      %261 = llvm.mlir.addressof @MOD : !llvm.ptr
      %262 = llvm.load %261 : !llvm.ptr -> i64
      %263 = arith.remsi %207, %262 : i64
      %264 = arith.extsi %263 : i64 to i128
      %266 = arith.trunci %260 : i128 to i64
      %267 = arith.trunci %264 : i128 to i64
      %265 = arith.muli %266, %267 : i64
      %268 = llvm.mlir.addressof @MOD : !llvm.ptr
      %269 = llvm.load %268 : !llvm.ptr -> i64
      %270 = arith.extsi %269 : i64 to i128
      %272 = arith.trunci %270 : i128 to i64
      %271 = arith.remsi %265, %272 : i64
      %273 = arith.extsi %214 : i64 to i128
      %275 = arith.trunci %273 : i128 to i64
      %274 = arith.muli %271, %275 : i64
      %276 = llvm.mlir.addressof @MOD : !llvm.ptr
      %277 = llvm.load %276 : !llvm.ptr -> i64
      %278 = arith.extsi %277 : i64 to i128
      %280 = arith.trunci %278 : i128 to i64
      %279 = arith.remsi %274, %280 : i64
      %281 = llvm.mlir.addressof @MOD : !llvm.ptr
      %282 = llvm.load %281 : !llvm.ptr -> i64
      %283 = arith.extsi %282 : i64 to i128
      %285 = arith.trunci %283 : i128 to i64
      %284 = arith.remsi %279, %285 : i64
      %286 = arith.addi %258, %284 : i64
      %287 = arith.constant 0 : i32
      %288 = arith.extsi %287 : i32 to i64
      %289 = llvm.getelementptr %arg2[%288] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %230, %289 : i64, !llvm.ptr
      %290 = arith.constant 0 : i32
      %291 = arith.extsi %290 : i32 to i64
      %292 = llvm.getelementptr %arg3[%291] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %244, %292 : i64, !llvm.ptr
      %293 = llvm.mlir.addressof @MOD : !llvm.ptr
      %294 = llvm.load %293 : !llvm.ptr -> i64
      %295 = arith.remsi %286, %294 : i64
      %296 = arith.constant 0 : i32
      %297 = arith.extsi %296 : i32 to i64
      %298 = llvm.getelementptr %arg4[%297] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %295, %298 : i64, !llvm.ptr
      func.return
    ^bb22:
      cf.br ^bb23
    ^bb23:
    %300 = arith.constant 1 : i32
    %302 = arith.extsi %300 : i32 to i64
    %301 = arith.subi %arg1, %302 : i64
    func.call @pow_sum_idx(%arg0, %301, %arg2, %arg3, %arg4) : (i64, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr) -> ()
    %304 = arith.constant 0 : i32
    %305 = arith.extsi %304 : i32 to i64
    %306 = llvm.getelementptr %arg2[%305] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    %303 = llvm.load %306 : !llvm.ptr -> i64
    %308 = arith.constant 0 : i32
    %309 = arith.extsi %308 : i32 to i64
    %310 = llvm.getelementptr %arg3[%309] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    %307 = llvm.load %310 : !llvm.ptr -> i64
    %312 = arith.constant 0 : i32
    %313 = arith.extsi %312 : i32 to i64
    %314 = llvm.getelementptr %arg4[%313] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    %311 = llvm.load %314 : !llvm.ptr -> i64
    %315 = arith.extsi %303 : i64 to i128
    %316 = arith.extsi %arg0 : i64 to i128
    %318 = arith.trunci %315 : i128 to i64
    %319 = arith.trunci %316 : i128 to i64
    %317 = arith.muli %318, %319 : i64
    %320 = llvm.mlir.addressof @MOD : !llvm.ptr
    %321 = llvm.load %320 : !llvm.ptr -> i64
    %322 = arith.extsi %321 : i64 to i128
    %324 = arith.trunci %322 : i128 to i64
    %323 = arith.remsi %317, %324 : i64
    %325 = arith.constant 0 : i32
    %326 = arith.extsi %325 : i32 to i64
    %327 = llvm.getelementptr %arg2[%326] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    llvm.store %323, %327 : i64, !llvm.ptr
    %328 = arith.addi %307, %303 : i64
    %329 = llvm.mlir.addressof @MOD : !llvm.ptr
    %330 = llvm.load %329 : !llvm.ptr -> i64
    %331 = arith.remsi %328, %330 : i64
    %332 = arith.constant 0 : i32
    %333 = arith.extsi %332 : i32 to i64
    %334 = llvm.getelementptr %arg3[%333] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    llvm.store %331, %334 : i64, !llvm.ptr
    %335 = arith.constant 1 : i32
    %337 = arith.extsi %335 : i32 to i64
    %336 = arith.subi %arg1, %337 : i64
    %338 = llvm.mlir.addressof @MOD : !llvm.ptr
    %339 = llvm.load %338 : !llvm.ptr -> i64
    %340 = arith.remsi %336, %339 : i64
    %341 = arith.muli %340, %303 : i64
    %342 = arith.addi %311, %341 : i64
    %343 = llvm.mlir.addressof @MOD : !llvm.ptr
    %344 = llvm.load %343 : !llvm.ptr -> i64
    %345 = arith.remsi %342, %344 : i64
    %346 = arith.constant 0 : i32
    %347 = arith.extsi %346 : i32 to i64
    %348 = llvm.getelementptr %arg4[%347] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    llvm.store %345, %348 : i64, !llvm.ptr
    func.return
  }
  func.func @digit_at(%arg0: i64) -> i64 {
    %349 = llvm.mlir.addressof @L : !llvm.ptr
    %350 = llvm.load %349 : !llvm.ptr -> i64
    %351 = arith.remsi %arg0, %350 : i64
    %352 = arith.constant 0 : i32
    %354 = arith.extsi %352 : i32 to i64
    %353 = arith.cmpi eq, %351, %354 : i64
    cf.cond_br %353, ^bb24, ^bb25
    ^bb24:
      %355 = arith.constant 1 : i32
      %356 = arith.extsi %355 : i32 to i64
      func.return %356 : i64
    ^bb25:
      cf.br ^bb26
    ^bb26:
    %357 = arith.constant 1 : i32
    %359 = arith.extsi %357 : i32 to i64
    %358 = arith.cmpi eq, %351, %359 : i64
    cf.cond_br %358, ^bb27, ^bb28
    ^bb27:
      %360 = arith.constant 2 : i32
      %361 = arith.extsi %360 : i32 to i64
      func.return %361 : i64
    ^bb28:
      cf.br ^bb29
    ^bb29:
    %362 = arith.constant 2 : i32
    %364 = arith.extsi %362 : i32 to i64
    %363 = arith.cmpi eq, %351, %364 : i64
    cf.cond_br %363, ^bb30, ^bb31
    ^bb30:
      %365 = arith.constant 3 : i32
      %366 = arith.extsi %365 : i32 to i64
      func.return %366 : i64
    ^bb31:
      cf.br ^bb32
    ^bb32:
    %367 = arith.constant 3 : i32
    %369 = arith.extsi %367 : i32 to i64
    %368 = arith.cmpi eq, %351, %369 : i64
    cf.cond_br %368, ^bb33, ^bb34
    ^bb33:
      %370 = arith.constant 4 : i32
      %371 = arith.extsi %370 : i32 to i64
      func.return %371 : i64
    ^bb34:
      cf.br ^bb35
    ^bb35:
    %372 = arith.constant 4 : i32
    %374 = arith.extsi %372 : i32 to i64
    %373 = arith.cmpi eq, %351, %374 : i64
    cf.cond_br %373, ^bb36, ^bb37
    ^bb36:
      %375 = arith.constant 3 : i32
      %376 = arith.extsi %375 : i32 to i64
      func.return %376 : i64
    ^bb37:
      cf.br ^bb38
    ^bb38:
    %377 = arith.constant 2 : i32
    %378 = arith.extsi %377 : i32 to i64
    func.return %378 : i64
  }
  func.func @brute_prefix(%arg0: i64, %arg1: !llvm.ptr) -> i64 {
    %379 = arith.constant 0 : i32
    %380 = arith.extsi %379 : i32 to i64
    %381 = llvm.mlir.constant(1 : i64) : i64
    %382 = llvm.alloca %381 x i64 : (i64) -> !llvm.ptr
    llvm.store %380, %382 : i64, !llvm.ptr
    %383 = arith.constant 0 : i32
    %384 = arith.extsi %383 : i32 to i64
    %385 = llvm.mlir.constant(1 : i64) : i64
    %386 = llvm.alloca %385 x i64 : (i64) -> !llvm.ptr
    llvm.store %384, %386 : i64, !llvm.ptr
    %387 = arith.constant 1 : i32
    %388 = arith.extsi %387 : i32 to i64
    %389 = llvm.mlir.constant(1 : i64) : i64
    %390 = llvm.alloca %389 x i64 : (i64) -> !llvm.ptr
    llvm.store %388, %390 : i64, !llvm.ptr
    cf.br ^bb39
    ^bb39:
    %391 = llvm.load %390 : !llvm.ptr -> i64
    %392 = arith.cmpi sle, %391, %arg0 : i64
    cf.cond_br %392, ^bb40, ^bb41
    ^bb40:
      %393 = arith.constant 0 : i32
      %394 = arith.extsi %393 : i32 to i64
      %395 = llvm.mlir.constant(1 : i64) : i64
      %396 = llvm.alloca %395 x i64 : (i64) -> !llvm.ptr
      llvm.store %394, %396 : i64, !llvm.ptr
      %397 = arith.constant 0 : i32
      %398 = arith.extsi %397 : i32 to i64
      %399 = llvm.mlir.constant(1 : i64) : i64
      %400 = llvm.alloca %399 x i64 : (i64) -> !llvm.ptr
      llvm.store %398, %400 : i64, !llvm.ptr
      cf.br ^bb42
      ^bb42:
      %401 = llvm.load %396 : !llvm.ptr -> i64
      %402 = llvm.load %390 : !llvm.ptr -> i64
      %403 = arith.cmpi slt, %401, %402 : i64
      cf.cond_br %403, ^bb43, ^bb44
      ^bb43:
        %405 = llvm.load %382 : !llvm.ptr -> i64
        %404 = func.call @digit_at(%405) : (i64) -> i64
        %406 = llvm.load %382 : !llvm.ptr -> i64
        %407 = arith.constant 1 : i32
        %409 = arith.extsi %407 : i32 to i64
        %408 = arith.addi %406, %409 : i64
        %410 = llvm.mlir.addressof @L : !llvm.ptr
        %411 = llvm.load %410 : !llvm.ptr -> i64
        %412 = arith.remsi %408, %411 : i64
        llvm.store %412, %382 : i64, !llvm.ptr
        %413 = llvm.load %396 : !llvm.ptr -> i64
        %414 = arith.addi %413, %404 : i64
        llvm.store %414, %396 : i64, !llvm.ptr
        %415 = llvm.load %400 : !llvm.ptr -> i64
        %416 = arith.constant 10 : i32
        %418 = arith.extsi %416 : i32 to i64
        %417 = arith.muli %415, %418 : i64
        %419 = arith.addi %417, %404 : i64
        %420 = llvm.mlir.addressof @MOD : !llvm.ptr
        %421 = llvm.load %420 : !llvm.ptr -> i64
        %422 = arith.remsi %419, %421 : i64
        llvm.store %422, %400 : i64, !llvm.ptr
        cf.br ^bb42
      ^bb44:
      %423 = llvm.load %386 : !llvm.ptr -> i64
      %424 = llvm.load %400 : !llvm.ptr -> i64
      %425 = arith.addi %423, %424 : i64
      %426 = llvm.mlir.addressof @MOD : !llvm.ptr
      %427 = llvm.load %426 : !llvm.ptr -> i64
      %428 = arith.remsi %425, %427 : i64
      llvm.store %428, %386 : i64, !llvm.ptr
      %429 = llvm.load %390 : !llvm.ptr -> i64
      %430 = arith.constant 1 : i32
      %432 = arith.extsi %430 : i32 to i64
      %431 = arith.addi %429, %432 : i64
      llvm.store %431, %390 : i64, !llvm.ptr
      cf.br ^bb39
    ^bb41:
    %433 = llvm.load %382 : !llvm.ptr -> i64
    %434 = arith.constant 0 : i32
    %435 = arith.extsi %434 : i32 to i64
    %436 = llvm.getelementptr %arg1[%435] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    llvm.store %433, %436 : i64, !llvm.ptr
    %437 = llvm.load %386 : !llvm.ptr -> i64
    func.return %437 : i64
  }
  func.func @main() -> i32 {
    %438 = arith.constant 15 : i32
    %439 = arith.extsi %438 : i32 to i64
    %440 = llvm.mlir.addressof @N : !llvm.ptr
    %441 = llvm.load %440 : !llvm.ptr -> i64
    %442 = arith.constant 1 : i32
    %444 = arith.extsi %442 : i32 to i64
    %443 = arith.subi %439, %444 : i64
    %445 = arith.cmpi sgt, %441, %443 : i64
    %446 = scf.if %445 -> (i64) {
      %447 = arith.constant 1 : i32
      %449 = arith.extsi %447 : i32 to i64
      %448 = arith.subi %439, %449 : i64
      scf.yield %448 : i64
    } else {
      scf.yield %441 : i64
    }
    %451 = arith.constant 1 : i32
    %452 = arith.constant 8 : i32
    %450 = func.call @calloc(%451, %452) : (i32, i32) -> i32
    %453 = llvm.inttoptr %450 : i32 to !llvm.ptr
    %454 = llvm.mlir.zero : !llvm.ptr
    %455 = llvm.icmp "eq" %453, %454 : !llvm.ptr
    cf.cond_br %455, ^bb45, ^bb46
    ^bb45:
      %456 = arith.constant 1 : i32
      func.return %456 : i32
    ^bb46:
      cf.br ^bb47
    ^bb47:
    %457 = func.call @brute_prefix(%446, %453) : (i64, !llvm.ptr) -> i64
    %458 = llvm.mlir.constant(1 : i64) : i64
    %459 = llvm.alloca %458 x i64 : (i64) -> !llvm.ptr
    llvm.store %457, %459 : i64, !llvm.ptr
    %460 = llvm.mlir.addressof @N : !llvm.ptr
    %461 = llvm.load %460 : !llvm.ptr -> i64
    %462 = arith.constant 1 : i32
    %464 = arith.extsi %462 : i32 to i64
    %463 = arith.subi %439, %464 : i64
    %465 = arith.cmpi sle, %461, %463 : i64
    cf.cond_br %465, ^bb48, ^bb49
    ^bb48:
      %466 = llvm.mlir.addressof @str_0 : !llvm.ptr
      %467 = llvm.load %459 : !llvm.ptr -> i64
      %468 = llvm.call @printf(%466, %467) vararg(!llvm.func<i32 (ptr, ...)>) : (!llvm.ptr, i64) -> i32
      %469 = func.call @free(%453) : (!llvm.ptr) -> i32
      %470 = arith.constant 0 : i32
      func.return %470 : i32
    ^bb49:
      cf.br ^bb50
    ^bb50:
    %472 = arith.constant 0 : i32
    %473 = arith.extsi %472 : i32 to i64
    %474 = llvm.getelementptr %453[%473] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    %471 = llvm.load %474 : !llvm.ptr -> i64
    %476 = llvm.mlir.addressof @L : !llvm.ptr
    %477 = llvm.load %476 : !llvm.ptr -> i64
    %478 = arith.constant 8 : i32
    %475 = func.call @calloc(%477, %478) : (i64, i32) -> i32
    %479 = llvm.inttoptr %475 : i32 to !llvm.ptr
    %481 = llvm.mlir.addressof @L : !llvm.ptr
    %482 = llvm.load %481 : !llvm.ptr -> i64
    %483 = arith.constant 7 : i32
    %485 = arith.extsi %483 : i32 to i64
    %484 = arith.muli %482, %485 : i64
    %486 = arith.constant 8 : i32
    %480 = func.call @calloc(%484, %486) : (i64, i32) -> i32
    %487 = llvm.inttoptr %480 : i32 to !llvm.ptr
    %489 = llvm.mlir.addressof @L : !llvm.ptr
    %490 = llvm.load %489 : !llvm.ptr -> i64
    %491 = arith.constant 7 : i32
    %493 = arith.extsi %491 : i32 to i64
    %492 = arith.muli %490, %493 : i64
    %494 = arith.constant 8 : i32
    %488 = func.call @calloc(%492, %494) : (i64, i32) -> i32
    %495 = llvm.inttoptr %488 : i32 to !llvm.ptr
    %497 = llvm.mlir.addressof @L : !llvm.ptr
    %498 = llvm.load %497 : !llvm.ptr -> i64
    %499 = arith.constant 15 : i32
    %501 = arith.extsi %499 : i32 to i64
    %500 = arith.muli %498, %501 : i64
    %502 = arith.constant 8 : i32
    %496 = func.call @calloc(%500, %502) : (i64, i32) -> i32
    %503 = llvm.inttoptr %496 : i32 to !llvm.ptr
    %505 = llvm.mlir.addressof @L : !llvm.ptr
    %506 = llvm.load %505 : !llvm.ptr -> i64
    %507 = arith.constant 15 : i32
    %509 = arith.extsi %507 : i32 to i64
    %508 = arith.muli %506, %509 : i64
    %510 = arith.constant 8 : i32
    %504 = func.call @calloc(%508, %510) : (i64, i32) -> i32
    %511 = llvm.inttoptr %504 : i32 to !llvm.ptr
    %512 = llvm.mlir.zero : !llvm.ptr
    %513 = llvm.icmp "eq" %479, %512 : !llvm.ptr
    %514 = scf.if %513 -> (i1) {
      %515 = arith.constant true
      scf.yield %515 : i1
    } else {
      %516 = llvm.mlir.zero : !llvm.ptr
      %517 = llvm.icmp "eq" %487, %516 : !llvm.ptr
      scf.yield %517 : i1
    }
    %518 = scf.if %514 -> (i1) {
      %519 = arith.constant true
      scf.yield %519 : i1
    } else {
      %520 = llvm.mlir.zero : !llvm.ptr
      %521 = llvm.icmp "eq" %495, %520 : !llvm.ptr
      scf.yield %521 : i1
    }
    %522 = scf.if %518 -> (i1) {
      %523 = arith.constant true
      scf.yield %523 : i1
    } else {
      %524 = llvm.mlir.zero : !llvm.ptr
      %525 = llvm.icmp "eq" %503, %524 : !llvm.ptr
      scf.yield %525 : i1
    }
    %526 = scf.if %522 -> (i1) {
      %527 = arith.constant true
      scf.yield %527 : i1
    } else {
      %528 = llvm.mlir.zero : !llvm.ptr
      %529 = llvm.icmp "eq" %511, %528 : !llvm.ptr
      scf.yield %529 : i1
    }
    cf.cond_br %526, ^bb51, ^bb52
    ^bb51:
      %530 = arith.constant 1 : i32
      func.return %530 : i32
    ^bb52:
      cf.br ^bb53
    ^bb53:
    %531 = arith.constant 0 : i32
    %532 = arith.extsi %531 : i32 to i64
    %533 = llvm.mlir.constant(1 : i64) : i64
    %534 = llvm.alloca %533 x i64 : (i64) -> !llvm.ptr
    llvm.store %532, %534 : i64, !llvm.ptr
    cf.br ^bb54
    ^bb54:
    %535 = llvm.load %534 : !llvm.ptr -> i64
    %536 = llvm.mlir.addressof @L : !llvm.ptr
    %537 = llvm.load %536 : !llvm.ptr -> i64
    %538 = arith.cmpi slt, %535, %537 : i64
    cf.cond_br %538, ^bb55, ^bb56
    ^bb55:
      %539 = arith.constant 0 : i32
      %540 = arith.extsi %539 : 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 = llvm.load %534 : !llvm.ptr -> i64
      %553 = arith.constant 7 : i32
      %555 = arith.extsi %553 : i32 to i64
      %554 = arith.muli %552, %555 : i64
      %556 = arith.constant 0 : i32
      %558 = arith.extsi %556 : i32 to i64
      %557 = arith.addi %554, %558 : i64
      %559 = arith.extsi %551 : i32 to i64
      %560 = llvm.getelementptr %487[%557] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %559, %560 : i64, !llvm.ptr
      %561 = arith.constant 0 : i32
      %562 = llvm.load %534 : !llvm.ptr -> i64
      %563 = arith.constant 7 : i32
      %565 = arith.extsi %563 : i32 to i64
      %564 = arith.muli %562, %565 : i64
      %566 = arith.constant 0 : i32
      %568 = arith.extsi %566 : i32 to i64
      %567 = arith.addi %564, %568 : i64
      %569 = arith.extsi %561 : i32 to i64
      %570 = llvm.getelementptr %495[%567] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %569, %570 : i64, !llvm.ptr
      %571 = arith.constant 1 : 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
      cf.br ^bb57
      ^bb57:
      %575 = llvm.load %574 : !llvm.ptr -> i64
      %576 = llvm.mlir.addressof @L : !llvm.ptr
      %577 = llvm.load %576 : !llvm.ptr -> i64
      %578 = arith.cmpi sle, %575, %577 : i64
      cf.cond_br %578, ^bb58, ^bb59
      ^bb58:
        %580 = llvm.load %534 : !llvm.ptr -> i64
        %581 = llvm.load %574 : !llvm.ptr -> i64
        %582 = arith.addi %580, %581 : i64
        %583 = arith.constant 1 : i32
        %585 = arith.extsi %583 : i32 to i64
        %584 = arith.subi %582, %585 : i64
        %579 = func.call @digit_at(%584) : (i64) -> i64
        %586 = llvm.load %542 : !llvm.ptr -> i64
        %587 = arith.constant 10 : i32
        %589 = arith.extsi %587 : i32 to i64
        %588 = arith.muli %586, %589 : i64
        %590 = arith.addi %588, %579 : i64
        llvm.store %590, %542 : i64, !llvm.ptr
        %591 = llvm.load %546 : !llvm.ptr -> i64
        %592 = arith.addi %591, %579 : i64
        llvm.store %592, %546 : i64, !llvm.ptr
        %593 = llvm.load %550 : !llvm.ptr -> i64
        %594 = arith.constant 10 : i32
        %596 = arith.extsi %594 : i32 to i64
        %595 = arith.muli %593, %596 : i64
        %597 = arith.addi %595, %579 : i64
        %598 = llvm.mlir.addressof @MOD : !llvm.ptr
        %599 = llvm.load %598 : !llvm.ptr -> i64
        %600 = arith.remsi %597, %599 : i64
        llvm.store %600, %550 : i64, !llvm.ptr
        %601 = llvm.load %546 : !llvm.ptr -> i64
        %602 = llvm.load %534 : !llvm.ptr -> i64
        %603 = arith.constant 7 : i32
        %605 = arith.extsi %603 : i32 to i64
        %604 = arith.muli %602, %605 : i64
        %606 = llvm.load %574 : !llvm.ptr -> i64
        %607 = arith.addi %604, %606 : i64
        %608 = llvm.getelementptr %487[%607] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        llvm.store %601, %608 : i64, !llvm.ptr
        %609 = llvm.load %550 : !llvm.ptr -> i64
        %610 = llvm.load %534 : !llvm.ptr -> i64
        %611 = arith.constant 7 : i32
        %613 = arith.extsi %611 : i32 to i64
        %612 = arith.muli %610, %613 : i64
        %614 = llvm.load %574 : !llvm.ptr -> i64
        %615 = arith.addi %612, %614 : i64
        %616 = llvm.getelementptr %495[%615] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        llvm.store %609, %616 : i64, !llvm.ptr
        %617 = llvm.load %574 : !llvm.ptr -> i64
        %618 = arith.constant 1 : i32
        %620 = arith.extsi %618 : i32 to i64
        %619 = arith.addi %617, %620 : i64
        llvm.store %619, %574 : i64, !llvm.ptr
        cf.br ^bb57
      ^bb59:
      %621 = llvm.load %542 : !llvm.ptr -> i64
      %622 = llvm.load %534 : !llvm.ptr -> i64
      %623 = llvm.getelementptr %479[%622] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %621, %623 : i64, !llvm.ptr
      %624 = llvm.load %534 : !llvm.ptr -> i64
      %625 = arith.constant 1 : i32
      %627 = arith.extsi %625 : i32 to i64
      %626 = arith.addi %624, %627 : i64
      llvm.store %626, %534 : i64, !llvm.ptr
      cf.br ^bb54
    ^bb56:
    %628 = arith.constant 0 : i32
    %629 = arith.extsi %628 : i32 to i64
    llvm.store %629, %534 : i64, !llvm.ptr
    cf.br ^bb60
    ^bb60:
    %630 = llvm.load %534 : !llvm.ptr -> i64
    %631 = llvm.mlir.addressof @L : !llvm.ptr
    %632 = llvm.load %631 : !llvm.ptr -> i64
    %633 = arith.cmpi slt, %630, %632 : i64
    cf.cond_br %633, ^bb61, ^bb62
    ^bb61:
      %634 = arith.constant 0 : i32
      %635 = arith.extsi %634 : i32 to i64
      %636 = llvm.mlir.constant(1 : i64) : i64
      %637 = llvm.alloca %636 x i64 : (i64) -> !llvm.ptr
      llvm.store %635, %637 : i64, !llvm.ptr
      cf.br ^bb63
      ^bb63:
      %638 = llvm.load %637 : !llvm.ptr -> i64
      %639 = arith.constant 15 : i32
      %641 = arith.extsi %639 : i32 to i64
      %640 = arith.cmpi slt, %638, %641 : i64
      cf.cond_br %640, ^bb64, ^bb65
      ^bb64:
        %642 = arith.constant 1 : i32
        %644 = arith.constant 0 : i32
        %643 = arith.subi %644, %642 : i32
        %645 = arith.extsi %643 : i32 to i64
        %646 = llvm.mlir.constant(1 : i64) : i64
        %647 = llvm.alloca %646 x i64 : (i64) -> !llvm.ptr
        llvm.store %645, %647 : i64, !llvm.ptr
        %648 = arith.constant 999999999 : i32
        %649 = arith.extsi %648 : i32 to i64
        %650 = llvm.mlir.constant(1 : i64) : i64
        %651 = llvm.alloca %650 x i64 : (i64) -> !llvm.ptr
        llvm.store %649, %651 : i64, !llvm.ptr
        %652 = arith.constant 0 : i32
        %653 = arith.extsi %652 : i32 to i64
        %654 = llvm.mlir.constant(1 : i64) : i64
        %655 = llvm.alloca %654 x i64 : (i64) -> !llvm.ptr
        llvm.store %653, %655 : i64, !llvm.ptr
        %656 = arith.constant 0 : i32
        %657 = arith.extsi %656 : i32 to i64
        %658 = llvm.mlir.constant(1 : i64) : i64
        %659 = llvm.alloca %658 x i64 : (i64) -> !llvm.ptr
        llvm.store %657, %659 : i64, !llvm.ptr
        %660 = arith.constant 1 : i32
        %661 = arith.extsi %660 : i32 to i64
        %662 = llvm.mlir.constant(1 : i64) : i64
        %663 = llvm.alloca %662 x i64 : (i64) -> !llvm.ptr
        llvm.store %661, %663 : i64, !llvm.ptr
        cf.br ^bb66
        ^bb66:
        %664 = llvm.load %663 : !llvm.ptr -> i64
        %665 = llvm.mlir.addressof @L : !llvm.ptr
        %666 = llvm.load %665 : !llvm.ptr -> i64
        %667 = arith.cmpi sle, %664, %666 : i64
        cf.cond_br %667, ^bb67, ^bb68
        ^bb67:
          %669 = llvm.load %534 : !llvm.ptr -> i64
          %670 = arith.constant 7 : i32
          %672 = arith.extsi %670 : i32 to i64
          %671 = arith.muli %669, %672 : i64
          %673 = llvm.load %663 : !llvm.ptr -> i64
          %674 = arith.addi %671, %673 : i64
          %675 = llvm.getelementptr %487[%674] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          %668 = llvm.load %675 : !llvm.ptr -> i64
          %676 = arith.constant 15 : i32
          %678 = arith.extsi %676 : i32 to i64
          %677 = arith.remsi %668, %678 : i64
          %679 = llvm.load %637 : !llvm.ptr -> i64
          %680 = arith.cmpi eq, %677, %679 : i64
          cf.cond_br %680, ^bb69, ^bb70
          ^bb69:
            %682 = llvm.load %534 : !llvm.ptr -> i64
            %683 = arith.constant 7 : i32
            %685 = arith.extsi %683 : i32 to i64
            %684 = arith.muli %682, %685 : i64
            %686 = llvm.load %663 : !llvm.ptr -> i64
            %687 = arith.addi %684, %686 : i64
            %688 = llvm.getelementptr %487[%687] : (!llvm.ptr, i64) -> !llvm.ptr, i64
            %681 = llvm.load %688 : !llvm.ptr -> i64
            %689 = arith.constant 5 : i32
            %690 = llvm.load %663 : !llvm.ptr -> i64
            %692 = arith.extsi %689 : i32 to i64
            %691 = arith.muli %692, %690 : i64
            %693 = arith.constant 2 : i32
            %695 = arith.extsi %693 : i32 to i64
            %694 = arith.muli %695, %681 : i64
            %696 = arith.subi %691, %694 : i64
            %697 = llvm.load %647 : !llvm.ptr -> i64
            %698 = arith.constant 0 : i32
            %700 = arith.extsi %698 : i32 to i64
            %699 = arith.cmpi slt, %697, %700 : i64
            %701 = scf.if %699 -> (i1) {
              %702 = arith.constant true
              scf.yield %702 : i1
            } else {
              %703 = llvm.load %651 : !llvm.ptr -> i64
              %704 = arith.cmpi slt, %696, %703 : i64
              scf.yield %704 : i1
            }
            %705 = scf.if %701 -> (i1) {
              %706 = arith.constant true
              scf.yield %706 : i1
            } else {
              %707 = llvm.load %651 : !llvm.ptr -> i64
              %708 = arith.cmpi eq, %696, %707 : i64
              %709 = scf.if %708 -> (i1) {
                %710 = llvm.load %663 : !llvm.ptr -> i64
                %711 = llvm.load %655 : !llvm.ptr -> i64
                %712 = arith.cmpi slt, %710, %711 : i64
                scf.yield %712 : i1
              } else {
                %713 = arith.constant false
                scf.yield %713 : i1
              }
              scf.yield %709 : i1
            }
            cf.cond_br %705, ^bb72, ^bb73
            ^bb72:
              llvm.store %696, %651 : i64, !llvm.ptr
              %714 = llvm.load %663 : !llvm.ptr -> i64
              llvm.store %714, %655 : i64, !llvm.ptr
              llvm.store %681, %659 : i64, !llvm.ptr
              %715 = arith.constant 1 : i32
              %716 = arith.extsi %715 : i32 to i64
              llvm.store %716, %647 : i64, !llvm.ptr
              cf.br ^bb74
            ^bb73:
              cf.br ^bb74
            ^bb74:
            cf.br ^bb71
          ^bb70:
            cf.br ^bb71
          ^bb71:
          %717 = llvm.load %663 : !llvm.ptr -> i64
          %718 = arith.constant 1 : i32
          %720 = arith.extsi %718 : i32 to i64
          %719 = arith.addi %717, %720 : i64
          llvm.store %719, %663 : i64, !llvm.ptr
          cf.br ^bb66
        ^bb68:
        %721 = llvm.load %655 : !llvm.ptr -> i64
        %722 = llvm.load %534 : !llvm.ptr -> i64
        %723 = arith.constant 15 : i32
        %725 = arith.extsi %723 : i32 to i64
        %724 = arith.muli %722, %725 : i64
        %726 = llvm.load %637 : !llvm.ptr -> i64
        %727 = arith.addi %724, %726 : i64
        %728 = llvm.getelementptr %503[%727] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        llvm.store %721, %728 : i64, !llvm.ptr
        %729 = llvm.load %659 : !llvm.ptr -> i64
        %730 = llvm.load %534 : !llvm.ptr -> i64
        %731 = arith.constant 15 : i32
        %733 = arith.extsi %731 : i32 to i64
        %732 = arith.muli %730, %733 : i64
        %734 = llvm.load %637 : !llvm.ptr -> i64
        %735 = arith.addi %732, %734 : i64
        %736 = llvm.getelementptr %511[%735] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        llvm.store %729, %736 : i64, !llvm.ptr
        %737 = llvm.load %637 : !llvm.ptr -> i64
        %738 = arith.constant 1 : i32
        %740 = arith.extsi %738 : i32 to i64
        %739 = arith.addi %737, %740 : i64
        llvm.store %739, %637 : i64, !llvm.ptr
        cf.br ^bb63
      ^bb65:
      %741 = llvm.load %534 : !llvm.ptr -> i64
      %742 = arith.constant 1 : i32
      %744 = arith.extsi %742 : i32 to i64
      %743 = arith.addi %741, %744 : i64
      llvm.store %743, %534 : i64, !llvm.ptr
      cf.br ^bb60
    ^bb62:
    %746 = arith.constant 15 : i32
    %747 = arith.constant 8 : i32
    %745 = func.call @calloc(%746, %747) : (i32, i32) -> i32
    %748 = llvm.inttoptr %745 : i32 to !llvm.ptr
    %750 = arith.constant 15 : i32
    %751 = arith.constant 8 : i32
    %749 = func.call @calloc(%750, %751) : (i32, i32) -> i32
    %752 = llvm.inttoptr %749 : i32 to !llvm.ptr
    %754 = arith.constant 15 : i32
    %755 = arith.constant 8 : i32
    %753 = func.call @calloc(%754, %755) : (i32, i32) -> i32
    %756 = llvm.inttoptr %753 : i32 to !llvm.ptr
    %758 = arith.constant 15 : i32
    %759 = arith.constant 8 : i32
    %757 = func.call @calloc(%758, %759) : (i32, i32) -> i32
    %760 = llvm.inttoptr %757 : i32 to !llvm.ptr
    %762 = arith.constant 15 : i32
    %763 = arith.constant 8 : i32
    %761 = func.call @calloc(%762, %763) : (i32, i32) -> i32
    %764 = llvm.inttoptr %761 : i32 to !llvm.ptr
    %766 = arith.constant 15 : i32
    %767 = arith.constant 8 : i32
    %765 = func.call @calloc(%766, %767) : (i32, i32) -> i32
    %768 = llvm.inttoptr %765 : i32 to !llvm.ptr
    %769 = llvm.mlir.zero : !llvm.ptr
    %770 = llvm.icmp "eq" %748, %769 : !llvm.ptr
    %771 = scf.if %770 -> (i1) {
      %772 = arith.constant true
      scf.yield %772 : i1
    } else {
      %773 = llvm.mlir.zero : !llvm.ptr
      %774 = llvm.icmp "eq" %752, %773 : !llvm.ptr
      scf.yield %774 : i1
    }
    %775 = scf.if %771 -> (i1) {
      %776 = arith.constant true
      scf.yield %776 : i1
    } else {
      %777 = llvm.mlir.zero : !llvm.ptr
      %778 = llvm.icmp "eq" %756, %777 : !llvm.ptr
      scf.yield %778 : i1
    }
    %779 = scf.if %775 -> (i1) {
      %780 = arith.constant true
      scf.yield %780 : i1
    } else {
      %781 = llvm.mlir.zero : !llvm.ptr
      %782 = llvm.icmp "eq" %760, %781 : !llvm.ptr
      scf.yield %782 : i1
    }
    %783 = scf.if %779 -> (i1) {
      %784 = arith.constant true
      scf.yield %784 : i1
    } else {
      %785 = llvm.mlir.zero : !llvm.ptr
      %786 = llvm.icmp "eq" %764, %785 : !llvm.ptr
      scf.yield %786 : i1
    }
    %787 = scf.if %783 -> (i1) {
      %788 = arith.constant true
      scf.yield %788 : i1
    } else {
      %789 = llvm.mlir.zero : !llvm.ptr
      %790 = llvm.icmp "eq" %768, %789 : !llvm.ptr
      scf.yield %790 : i1
    }
    cf.cond_br %787, ^bb75, ^bb76
    ^bb75:
      %791 = arith.constant 1 : i32
      func.return %791 : i32
    ^bb76:
      cf.br ^bb77
    ^bb77:
    %792 = llvm.mlir.constant(1 : i64) : i64
    %793 = llvm.alloca %792 x i64 : (i64) -> !llvm.ptr
    llvm.store %471, %793 : i64, !llvm.ptr
    %794 = arith.constant 0 : i32
    %795 = arith.extsi %794 : i32 to i64
    %796 = llvm.mlir.constant(1 : i64) : i64
    %797 = llvm.alloca %796 x i64 : (i64) -> !llvm.ptr
    llvm.store %795, %797 : i64, !llvm.ptr
    cf.br ^bb78
    ^bb78:
    %798 = llvm.load %797 : !llvm.ptr -> i64
    %799 = arith.constant 15 : i32
    %801 = arith.extsi %799 : i32 to i64
    %800 = arith.cmpi slt, %798, %801 : i64
    cf.cond_br %800, ^bb79, ^bb80
    ^bb79:
      %802 = llvm.load %797 : !llvm.ptr -> i64
      %803 = arith.addi %439, %802 : i64
      %804 = arith.constant 15 : i32
      %806 = arith.extsi %804 : i32 to i64
      %805 = arith.remsi %803, %806 : i64
      %808 = llvm.load %793 : !llvm.ptr -> i64
      %809 = arith.constant 15 : i32
      %811 = arith.extsi %809 : i32 to i64
      %810 = arith.muli %808, %811 : i64
      %812 = arith.addi %810, %805 : i64
      %813 = llvm.getelementptr %503[%812] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %807 = llvm.load %813 : !llvm.ptr -> i64
      %815 = llvm.load %793 : !llvm.ptr -> i64
      %816 = arith.constant 15 : i32
      %818 = arith.extsi %816 : i32 to i64
      %817 = arith.muli %815, %818 : i64
      %819 = arith.addi %817, %805 : i64
      %820 = llvm.getelementptr %511[%819] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %814 = llvm.load %820 : !llvm.ptr -> i64
      %821 = llvm.load %797 : !llvm.ptr -> i64
      %822 = llvm.getelementptr %748[%821] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %803, %822 : i64, !llvm.ptr
      %823 = llvm.load %793 : !llvm.ptr -> i64
      %824 = llvm.load %797 : !llvm.ptr -> i64
      %825 = llvm.getelementptr %752[%824] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %823, %825 : i64, !llvm.ptr
      %826 = llvm.load %797 : !llvm.ptr -> i64
      %827 = llvm.getelementptr %756[%826] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %807, %827 : i64, !llvm.ptr
      %828 = llvm.load %797 : !llvm.ptr -> i64
      %829 = llvm.getelementptr %760[%828] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %814, %829 : i64, !llvm.ptr
      %831 = llvm.load %793 : !llvm.ptr -> i64
      %832 = llvm.getelementptr %479[%831] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %830 = llvm.load %832 : !llvm.ptr -> i64
      %833 = llvm.load %797 : !llvm.ptr -> i64
      %834 = llvm.getelementptr %764[%833] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %830, %834 : i64, !llvm.ptr
      %836 = llvm.load %793 : !llvm.ptr -> i64
      %837 = arith.constant 7 : i32
      %839 = arith.extsi %837 : i32 to i64
      %838 = arith.muli %836, %839 : i64
      %840 = arith.addi %838, %807 : i64
      %841 = llvm.getelementptr %495[%840] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %835 = llvm.load %841 : !llvm.ptr -> i64
      %842 = llvm.load %797 : !llvm.ptr -> i64
      %843 = llvm.getelementptr %768[%842] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %835, %843 : i64, !llvm.ptr
      %844 = llvm.load %793 : !llvm.ptr -> i64
      %845 = arith.addi %844, %807 : i64
      %846 = llvm.mlir.addressof @L : !llvm.ptr
      %847 = llvm.load %846 : !llvm.ptr -> i64
      %848 = arith.remsi %845, %847 : i64
      llvm.store %848, %793 : i64, !llvm.ptr
      %849 = llvm.load %797 : !llvm.ptr -> i64
      %850 = arith.constant 1 : i32
      %852 = arith.extsi %850 : i32 to i64
      %851 = arith.addi %849, %852 : i64
      llvm.store %851, %797 : i64, !llvm.ptr
      cf.br ^bb78
    ^bb80:
    %853 = llvm.mlir.addressof @N : !llvm.ptr
    %854 = llvm.load %853 : !llvm.ptr -> i64
    %855 = arith.constant 1 : i32
    %857 = arith.extsi %855 : i32 to i64
    %856 = arith.subi %439, %857 : i64
    %858 = arith.subi %854, %856 : i64
    %859 = arith.constant 15 : i32
    %861 = arith.extsi %859 : i32 to i64
    %860 = arith.divsi %858, %861 : i64
    %862 = arith.constant 15 : i32
    %864 = arith.extsi %862 : i32 to i64
    %863 = arith.remsi %858, %864 : i64
    %866 = arith.constant 7 : i32
    %867 = arith.constant 8 : i32
    %865 = func.call @calloc(%866, %867) : (i32, i32) -> i32
    %868 = llvm.inttoptr %865 : i32 to !llvm.ptr
    %869 = llvm.mlir.zero : !llvm.ptr
    %870 = llvm.icmp "eq" %868, %869 : !llvm.ptr
    cf.cond_br %870, ^bb81, ^bb82
    ^bb81:
      %871 = arith.constant 1 : i32
      func.return %871 : i32
    ^bb82:
      cf.br ^bb83
    ^bb83:
    %872 = arith.constant 1 : i32
    %873 = arith.constant 0 : i32
    %874 = arith.extsi %872 : i32 to i64
    %875 = arith.extsi %873 : i32 to i64
    %876 = llvm.getelementptr %868[%875] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    llvm.store %874, %876 : i64, !llvm.ptr
    %877 = arith.constant 1 : i32
    %878 = arith.extsi %877 : i32 to i64
    %879 = llvm.mlir.constant(1 : i64) : i64
    %880 = llvm.alloca %879 x i64 : (i64) -> !llvm.ptr
    llvm.store %878, %880 : i64, !llvm.ptr
    cf.br ^bb84
    ^bb84:
    %881 = llvm.load %880 : !llvm.ptr -> i64
    %882 = arith.constant 6 : i32
    %884 = arith.extsi %882 : i32 to i64
    %883 = arith.cmpi sle, %881, %884 : i64
    cf.cond_br %883, ^bb85, ^bb86
    ^bb85:
      %886 = llvm.load %880 : !llvm.ptr -> i64
      %885 = func.call @modpow10(%886) : (i64) -> i64
      %887 = llvm.load %880 : !llvm.ptr -> i64
      %888 = llvm.getelementptr %868[%887] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %885, %888 : i64, !llvm.ptr
      %889 = llvm.load %880 : !llvm.ptr -> i64
      %890 = arith.constant 1 : i32
      %892 = arith.extsi %890 : i32 to i64
      %891 = arith.addi %889, %892 : i64
      llvm.store %891, %880 : i64, !llvm.ptr
      cf.br ^bb84
    ^bb86:
    %894 = arith.constant 6 : i32
    %895 = arith.extsi %894 : i32 to i64
    %893 = func.call @modpow10(%895) : (i64) -> i64
    %897 = arith.constant 3 : i32
    %898 = arith.constant 8 : i32
    %896 = func.call @calloc(%897, %898) : (i32, i32) -> i32
    %899 = llvm.inttoptr %896 : i32 to !llvm.ptr
    %900 = llvm.mlir.zero : !llvm.ptr
    %901 = llvm.icmp "eq" %899, %900 : !llvm.ptr
    cf.cond_br %901, ^bb87, ^bb88
    ^bb87:
      %902 = arith.constant 1 : i32
      func.return %902 : i32
    ^bb88:
      cf.br ^bb89
    ^bb89:
    %903 = arith.constant 0 : i32
    %904 = arith.extsi %903 : i32 to i64
    %905 = llvm.mlir.constant(1 : i64) : i64
    %906 = llvm.alloca %905 x i64 : (i64) -> !llvm.ptr
    llvm.store %904, %906 : i64, !llvm.ptr
    %907 = arith.constant 1 : i32
    %909 = arith.extsi %907 : i32 to i64
    %908 = arith.cmpi sgt, %860, %909 : i64
    cf.cond_br %908, ^bb90, ^bb91
    ^bb90:
      %911 = arith.constant 1 : i32
      %913 = arith.extsi %911 : i32 to i64
      %912 = arith.subi %860, %913 : i64
      # String concatenation: !llvm.ptr + i32
      # String concatenation: !llvm.ptr + i32
      func.call @pow_sum_idx(%893, %912, %899, %914, %915) : (i64, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr) -> ()
      %916 = arith.constant 1 : i32
      %918 = arith.extsi %916 : i32 to i64
      %917 = arith.subi %860, %918 : i64
      %919 = llvm.mlir.addressof @MOD : !llvm.ptr
      %920 = llvm.load %919 : !llvm.ptr -> i64
      %921 = arith.remsi %917, %920 : i64
      %923 = arith.constant 1 : i32
      %924 = arith.extsi %923 : i32 to i64
      %925 = llvm.getelementptr %899[%924] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %922 = llvm.load %925 : !llvm.ptr -> i64
      %926 = arith.muli %921, %922 : i64
      %927 = llvm.mlir.addressof @MOD : !llvm.ptr
      %928 = llvm.load %927 : !llvm.ptr -> i64
      %929 = arith.remsi %926, %928 : i64
      %931 = arith.constant 2 : i32
      %932 = arith.extsi %931 : i32 to i64
      %933 = llvm.getelementptr %899[%932] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %930 = llvm.load %933 : !llvm.ptr -> i64
      %934 = arith.subi %929, %930 : i64
      %935 = llvm.mlir.addressof @MOD : !llvm.ptr
      %936 = llvm.load %935 : !llvm.ptr -> i64
      %937 = arith.remsi %934, %936 : i64
      %938 = llvm.mlir.addressof @MOD : !llvm.ptr
      %939 = llvm.load %938 : !llvm.ptr -> i64
      %940 = arith.addi %937, %939 : i64
      %941 = llvm.mlir.addressof @MOD : !llvm.ptr
      %942 = llvm.load %941 : !llvm.ptr -> i64
      %943 = arith.remsi %940, %942 : i64
      llvm.store %943, %906 : i64, !llvm.ptr
      cf.br ^bb92
    ^bb91:
      cf.br ^bb92
    ^bb92:
    # String concatenation: !llvm.ptr + i32
    # String concatenation: !llvm.ptr + i32
    func.call @pow_sum_idx(%893, %860, %899, %945, %946) : (i64, i64, !llvm.ptr, !llvm.ptr, !llvm.ptr) -> ()
    %948 = arith.constant 1 : i32
    %949 = arith.extsi %948 : i32 to i64
    %950 = llvm.getelementptr %899[%949] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    %947 = llvm.load %950 : !llvm.ptr -> i64
    %951 = llvm.mlir.addressof @MOD : !llvm.ptr
    %952 = llvm.load %951 : !llvm.ptr -> i64
    %953 = arith.remsi %860, %952 : i64
    %954 = arith.constant 0 : i32
    %956 = arith.extsi %954 : i32 to i64
    %955 = arith.cmpi sgt, %860, %956 : i64
    cf.cond_br %955, ^bb93, ^bb94
    ^bb93:
      %957 = arith.constant 0 : i32
      %958 = arith.extsi %957 : i32 to i64
      llvm.store %958, %797 : i64, !llvm.ptr
      cf.br ^bb96
      ^bb96:
      %959 = llvm.load %797 : !llvm.ptr -> i64
      %960 = arith.constant 15 : i32
      %962 = arith.extsi %960 : i32 to i64
      %961 = arith.cmpi slt, %959, %962 : i64
      cf.cond_br %961, ^bb97, ^bb98
      ^bb97:
        %964 = llvm.load %797 : !llvm.ptr -> i64
        %965 = llvm.getelementptr %748[%964] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %963 = llvm.load %965 : !llvm.ptr -> i64
        %967 = llvm.load %797 : !llvm.ptr -> i64
        %968 = llvm.getelementptr %756[%967] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %966 = llvm.load %968 : !llvm.ptr -> i64
        %970 = llvm.load %797 : !llvm.ptr -> i64
        %971 = llvm.getelementptr %760[%970] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %969 = llvm.load %971 : !llvm.ptr -> i64
        %973 = llvm.load %797 : !llvm.ptr -> i64
        %974 = llvm.getelementptr %764[%973] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %972 = llvm.load %974 : !llvm.ptr -> i64
        %976 = llvm.load %797 : !llvm.ptr -> i64
        %977 = llvm.getelementptr %768[%976] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %975 = llvm.load %977 : !llvm.ptr -> i64
        %978 = arith.subi %963, %969 : i64
        %979 = arith.constant 15 : i32
        %981 = arith.extsi %979 : i32 to i64
        %980 = arith.divsi %978, %981 : i64
        # String concatenation: !llvm.ptr + i32
        func.call @pow_sum(%893, %980, %899, %983) : (i64, i64, !llvm.ptr, !llvm.ptr) -> ()
        %985 = arith.constant 0 : i32
        %986 = arith.extsi %985 : i32 to i64
        %987 = llvm.getelementptr %899[%986] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %984 = llvm.load %987 : !llvm.ptr -> i64
        %989 = arith.constant 1 : i32
        %990 = arith.extsi %989 : i32 to i64
        %991 = llvm.getelementptr %899[%990] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %988 = llvm.load %991 : !llvm.ptr -> i64
        %992 = arith.muli %953, %988 : i64
        %993 = llvm.mlir.addressof @MOD : !llvm.ptr
        %994 = llvm.load %993 : !llvm.ptr -> i64
        %995 = arith.remsi %992, %994 : i64
        %996 = arith.extsi %984 : i64 to i128
        %997 = llvm.load %906 : !llvm.ptr -> i64
        %998 = arith.extsi %997 : i64 to i128
        %1000 = arith.trunci %996 : i128 to i64
        %1001 = arith.trunci %998 : i128 to i64
        %999 = arith.muli %1000, %1001 : i64
        %1002 = llvm.mlir.addressof @MOD : !llvm.ptr
        %1003 = llvm.load %1002 : !llvm.ptr -> i64
        %1004 = arith.extsi %1003 : i64 to i128
        %1006 = arith.trunci %1004 : i128 to i64
        %1005 = arith.remsi %999, %1006 : i64
        %1007 = arith.addi %995, %1005 : i64
        %1008 = llvm.mlir.addressof @MOD : !llvm.ptr
        %1009 = llvm.load %1008 : !llvm.ptr -> i64
        %1010 = arith.remsi %1007, %1009 : i64
        %1012 = llvm.getelementptr %868[%966] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %1011 = llvm.load %1012 : !llvm.ptr -> i64
        %1013 = arith.muli %972, %1011 : i64
        %1014 = llvm.mlir.addressof @MOD : !llvm.ptr
        %1015 = llvm.load %1014 : !llvm.ptr -> i64
        %1016 = arith.remsi %1013, %1015 : i64
        %1017 = arith.muli %1016, %1010 : i64
        %1018 = llvm.mlir.addressof @MOD : !llvm.ptr
        %1019 = llvm.load %1018 : !llvm.ptr -> i64
        %1020 = arith.remsi %1017, %1019 : i64
        %1021 = llvm.mlir.constant(1 : i64) : i64
        %1022 = llvm.alloca %1021 x i64 : (i64) -> !llvm.ptr
        llvm.store %1020, %1022 : i64, !llvm.ptr
        %1023 = llvm.load %1022 : !llvm.ptr -> i64
        %1024 = arith.muli %975, %953 : i64
        %1025 = arith.addi %1023, %1024 : i64
        %1026 = llvm.mlir.addressof @MOD : !llvm.ptr
        %1027 = llvm.load %1026 : !llvm.ptr -> i64
        %1028 = arith.remsi %1025, %1027 : i64
        llvm.store %1028, %1022 : i64, !llvm.ptr
        %1029 = llvm.load %459 : !llvm.ptr -> i64
        %1030 = llvm.load %1022 : !llvm.ptr -> i64
        %1031 = arith.addi %1029, %1030 : i64
        %1032 = llvm.mlir.addressof @MOD : !llvm.ptr
        %1033 = llvm.load %1032 : !llvm.ptr -> i64
        %1034 = arith.remsi %1031, %1033 : i64
        llvm.store %1034, %459 : i64, !llvm.ptr
        %1035 = llvm.load %797 : !llvm.ptr -> i64
        %1036 = arith.constant 1 : i32
        %1038 = arith.extsi %1036 : i32 to i64
        %1037 = arith.addi %1035, %1038 : i64
        llvm.store %1037, %797 : i64, !llvm.ptr
        cf.br ^bb96
      ^bb98:
      cf.br ^bb95
    ^bb94:
      cf.br ^bb95
    ^bb95:
    %1039 = arith.constant 0 : i32
    %1041 = arith.extsi %1039 : i32 to i64
    %1040 = arith.cmpi sgt, %863, %1041 : i64
    cf.cond_br %1040, ^bb99, ^bb100
    ^bb99:
      %1042 = arith.constant 0 : i32
      %1043 = arith.extsi %1042 : i32 to i64
      llvm.store %1043, %797 : i64, !llvm.ptr
      cf.br ^bb102
      ^bb102:
      %1044 = llvm.load %797 : !llvm.ptr -> i64
      %1045 = arith.cmpi slt, %1044, %863 : i64
      cf.cond_br %1045, ^bb103, ^bb104
      ^bb103:
        %1047 = llvm.load %797 : !llvm.ptr -> i64
        %1048 = llvm.getelementptr %748[%1047] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %1046 = llvm.load %1048 : !llvm.ptr -> i64
        %1050 = llvm.load %797 : !llvm.ptr -> i64
        %1051 = llvm.getelementptr %756[%1050] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %1049 = llvm.load %1051 : !llvm.ptr -> i64
        %1053 = llvm.load %797 : !llvm.ptr -> i64
        %1054 = llvm.getelementptr %760[%1053] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %1052 = llvm.load %1054 : !llvm.ptr -> i64
        %1056 = llvm.load %797 : !llvm.ptr -> i64
        %1057 = llvm.getelementptr %764[%1056] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %1055 = llvm.load %1057 : !llvm.ptr -> i64
        %1059 = llvm.load %797 : !llvm.ptr -> i64
        %1060 = llvm.getelementptr %768[%1059] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %1058 = llvm.load %1060 : !llvm.ptr -> i64
        %1061 = arith.subi %1046, %1052 : i64
        %1062 = arith.constant 15 : i32
        %1064 = arith.extsi %1062 : i32 to i64
        %1063 = arith.divsi %1061, %1064 : i64
        # String concatenation: !llvm.ptr + i32
        func.call @pow_sum(%893, %1063, %899, %1066) : (i64, i64, !llvm.ptr, !llvm.ptr) -> ()
        %1068 = arith.constant 0 : i32
        %1069 = arith.extsi %1068 : i32 to i64
        %1070 = llvm.getelementptr %899[%1069] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %1067 = llvm.load %1070 : !llvm.ptr -> i64
        %1072 = arith.constant 1 : i32
        %1073 = arith.extsi %1072 : i32 to i64
        %1074 = llvm.getelementptr %899[%1073] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %1071 = llvm.load %1074 : !llvm.ptr -> i64
        %1075 = arith.extsi %1067 : i64 to i128
        %1076 = arith.extsi %947 : i64 to i128
        %1078 = arith.trunci %1075 : i128 to i64
        %1079 = arith.trunci %1076 : i128 to i64
        %1077 = arith.muli %1078, %1079 : i64
        %1080 = llvm.mlir.addressof @MOD : !llvm.ptr
        %1081 = llvm.load %1080 : !llvm.ptr -> i64
        %1082 = arith.extsi %1081 : i64 to i128
        %1084 = arith.trunci %1082 : i128 to i64
        %1083 = arith.remsi %1077, %1084 : i64
        %1085 = arith.addi %1071, %1083 : i64
        %1086 = llvm.mlir.addressof @MOD : !llvm.ptr
        %1087 = llvm.load %1086 : !llvm.ptr -> i64
        %1088 = arith.remsi %1085, %1087 : i64
        %1090 = llvm.getelementptr %868[%1049] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %1089 = llvm.load %1090 : !llvm.ptr -> i64
        %1091 = arith.muli %1055, %1089 : i64
        %1092 = llvm.mlir.addressof @MOD : !llvm.ptr
        %1093 = llvm.load %1092 : !llvm.ptr -> i64
        %1094 = arith.remsi %1091, %1093 : i64
        %1095 = arith.muli %1094, %1088 : i64
        %1096 = llvm.mlir.addressof @MOD : !llvm.ptr
        %1097 = llvm.load %1096 : !llvm.ptr -> i64
        %1098 = arith.remsi %1095, %1097 : i64
        %1099 = llvm.mlir.constant(1 : i64) : i64
        %1100 = llvm.alloca %1099 x i64 : (i64) -> !llvm.ptr
        llvm.store %1098, %1100 : i64, !llvm.ptr
        %1101 = llvm.load %1100 : !llvm.ptr -> i64
        %1102 = arith.addi %1101, %1058 : i64
        %1103 = llvm.mlir.addressof @MOD : !llvm.ptr
        %1104 = llvm.load %1103 : !llvm.ptr -> i64
        %1105 = arith.remsi %1102, %1104 : i64
        llvm.store %1105, %1100 : i64, !llvm.ptr
        %1106 = llvm.load %459 : !llvm.ptr -> i64
        %1107 = llvm.load %1100 : !llvm.ptr -> i64
        %1108 = arith.addi %1106, %1107 : i64
        %1109 = llvm.mlir.addressof @MOD : !llvm.ptr
        %1110 = llvm.load %1109 : !llvm.ptr -> i64
        %1111 = arith.remsi %1108, %1110 : i64
        llvm.store %1111, %459 : i64, !llvm.ptr
        %1112 = llvm.load %797 : !llvm.ptr -> i64
        %1113 = arith.constant 1 : i32
        %1115 = arith.extsi %1113 : i32 to i64
        %1114 = arith.addi %1112, %1115 : i64
        llvm.store %1114, %797 : i64, !llvm.ptr
        cf.br ^bb102
      ^bb104:
      cf.br ^bb101
    ^bb100:
      cf.br ^bb101
    ^bb101:
    %1116 = llvm.mlir.addressof @str_0 : !llvm.ptr
    %1117 = llvm.load %459 : !llvm.ptr -> i64
    %1118 = llvm.call @printf(%1116, %1117) vararg(!llvm.func<i32 (ptr, ...)>) : (!llvm.ptr, i64) -> i32
    %1119 = func.call @free(%453) : (!llvm.ptr) -> i32
    %1120 = func.call @free(%479) : (!llvm.ptr) -> i32
    %1121 = func.call @free(%487) : (!llvm.ptr) -> i32
    %1122 = func.call @free(%495) : (!llvm.ptr) -> i32
    %1123 = func.call @free(%503) : (!llvm.ptr) -> i32
    %1124 = func.call @free(%511) : (!llvm.ptr) -> i32
    %1125 = func.call @free(%748) : (!llvm.ptr) -> i32
    %1126 = func.call @free(%752) : (!llvm.ptr) -> i32
    %1127 = func.call @free(%756) : (!llvm.ptr) -> i32
    %1128 = func.call @free(%760) : (!llvm.ptr) -> i32
    %1129 = func.call @free(%764) : (!llvm.ptr) -> i32
    %1130 = func.call @free(%768) : (!llvm.ptr) -> i32
    %1131 = func.call @free(%868) : (!llvm.ptr) -> i32
    %1132 = func.call @free(%899) : (!llvm.ptr) -> i32
    %1133 = arith.constant 0 : i32
    func.return %1133 : i32
  }
}