Problem 749

Near Power Sums: sum of all near power sum numbers with at most 16 digits. Pure Flow port of the native C solver.

Answer13459471903176422
Output13459471903176422
StatusPASS
Native helperno
Runtime190 ms
Peak memory2144 KB
Time complexityO(n^4) (estimated)
Space complexityO(n^2) (estimated)

Performance comparison

MetricOur solutionBest known
Time complexityO(n^4)O(n log log n)
Space complexityO(n^2)O(n)
ApproachFlow solutionSieve or enumeration
VerdictSuboptimal

Flow source

# Project Euler 749
# Near Power Sums: sum of all near power sum numbers with at most 16 digits.
# Pure Flow port of the native C solver.

extern {
    function calloc(n: i64, size: i64) -> ptr<void>
    function free(p: ptr<void>) -> void
    function memset(s: ptr<void>, c: i64, n: i64) -> ptr<void>
}

const MAX_DIGITS: i32 = 16
const SET_CAP: i64 = 65536

# 1D arrays replacing C's multi-dimensional arrays:
#   pow_table: 640 i128, index k*10+d
#   k_low: 170 i32, index L*10+m
#   k_high: 2890 i32, index (L*10+m)*17+c
#   pack_exact: 50000 i64, index len*10000+x
let mut p10: ptr<i64> = null
let mut max_k: i32 = 0
let mut pow_table: ptr<i128> = null
let mut k_low: ptr<i32> = null
let mut k_high: ptr<i32> = null
let mut pack4: ptr<i64> = null
let mut pack_exact: ptr<i64> = null
let mut set_tbl: ptr<i64> = null

let mut g_Ks: ptr<i32> = null
let mut g_nks: i32 = 0
let mut g_base_t: ptr<i128> = null
let mut g_counts: ptr<i32> = null
let mut g_sig_m: i64 = 0
let mut g_L_lo: i64 = 0
let mut g_L_hi: i64 = 0
let mut g_L: i32 = 0

function set_init() -> void {
    set_tbl = calloc(SET_CAP, 8) as ptr<i64>
}

function set_insert(v: i64) -> i32 {
    let mut idx: i64 = (v ^ (v >> 16) ^ (v >> 32)) & (SET_CAP - 1)
    while true {
        if set_tbl[idx] == 0 {
            set_tbl[idx] = v
            return 1
        }
        if set_tbl[idx] == v {
            return 0
        }
        idx = (idx + 1) & (SET_CAP - 1)
    }
    return 0
}

function build_pow10() -> void {
    p10 = calloc(17, 8) as ptr<i64>
    p10[0] = 1
    let mut i: i32 = 1
    while i <= MAX_DIGITS {
        p10[i] = p10[i - 1] * 10
        i = i + 1
    }
}

function compute_max_k() -> void {
    let limit: i64 = p10[MAX_DIGITS]
    let mut k: i32 = 0
    let mut p: i64 = 1
    while p <= limit {
        k = k + 1
        p = p * 2
    }
    max_k = k
}

function build_pow_table() -> void {
    pow_table = calloc(640, 16) as ptr<i128>
    let mut d: i32 = 0
    while d < 10 {
        pow_table[1 * 10 + d] = d as i128
        d = d + 1
    }
    let mut k: i32 = 2
    while k <= max_k {
        let mut d2: i32 = 0
        while d2 < 10 {
            let val: i128 = pow_table[(k - 1) * 10 + d2] * (d2 as i128)
            if val > (1000000000000000000 as i128) {
                pow_table[k * 10 + d2] = 1000000000000000000 as i128
            } else {
                pow_table[k * 10 + d2] = val
            }
            d2 = d2 + 1
        }
        k = k + 1
    }
}

function build_k_bounds() -> void {
    k_low = calloc(170, 4) as ptr<i32>
    k_high = calloc(2890, 4) as ptr<i32>
    let mut L: i32 = 1
    while L <= MAX_DIGITS {
        let lt: i64 = p10[L - 1] - 1
        let ht: i64 = p10[L]
        let mut m: i32 = 0
        while m < 10 {
            k_low[L * 10 + m] = max_k + 1
            let mut c: i32 = 0
            while c <= MAX_DIGITS {
                k_high[(L * 10 + m) * 17 + c] = 0
                c = c + 1
            }
            m = m + 1
        }
        let mut m2: i32 = 2
        while m2 < 10 {
            let mut p: i128 = m2 as i128
            let mut k: i32 = 1
            while k <= max_k && (L as i128) * p < (lt as i128) {
                p = p * (m2 as i128)
                k = k + 1
            }
            k_low[L * 10 + m2] = k

            let mut c2: i32 = 1
            while c2 <= L {
                let mut p2: i128 = m2 as i128
                let mut best: i32 = 0
                let mut kk: i32 = 1
                while kk <= max_k {
                    if (c2 as i128) * p2 <= (ht as i128) {
                        best = kk
                        p2 = p2 * (m2 as i128)
                    } else {
                        break
                    }
                    kk = kk + 1
                }
                k_high[(L * 10 + m2) * 17 + c2] = best
                c2 = c2 + 1
            }
            m2 = m2 + 1
        }
        L = L + 1
    }
}

function build_pack_tables() -> void {
    pack4 = calloc(10000, 8) as ptr<i64>
    pack_exact = calloc(50000, 8) as ptr<i64>
    let mut x: i32 = 0
    while x < 10000 {
        let mut code: i64 = 0
        let mut y: i32 = x
        let mut i: i32 = 0
        while i < 4 {
            let d: i32 = y % 10
            code = code + ((1 as i64) << (5 * d))
            y = y / 10
            i = i + 1
        }
        pack4[x] = code
        x = x + 1
    }
    let mut x2: i32 = 0
    while x2 < 10 {
        pack_exact[1 * 10000 + x2] = (1 as i64) << (5 * x2)
        x2 = x2 + 1
    }
    let mut x3: i32 = 0
    while x3 < 100 {
        let mut code: i64 = 0
        let mut y: i32 = x3
        let mut i: i32 = 0
        while i < 2 {
            let d: i32 = y % 10
            code = code + ((1 as i64) << (5 * d))
            y = y / 10
            i = i + 1
        }
        pack_exact[2 * 10000 + x3] = code
        x3 = x3 + 1
    }
    let mut x4: i32 = 0
    while x4 < 1000 {
        let mut code: i64 = 0
        let mut y: i32 = x4
        let mut i: i32 = 0
        while i < 3 {
            let d: i32 = y % 10
            code = code + ((1 as i64) << (5 * d))
            y = y / 10
            i = i + 1
        }
        pack_exact[3 * 10000 + x4] = code
        x4 = x4 + 1
    }
    let mut x5: i32 = 0
    while x5 < 10000 {
        pack_exact[4 * 10000 + x5] = pack4[x5]
        x5 = x5 + 1
    }
}

function pack_digits_len(n0: i64, L: i32) -> i64 {
    let mut n: i64 = n0
    if L <= 4 { return pack_exact[L * 10000 + n] }
    if L <= 8 {
        let a: i64 = n % 10000
        let b: i64 = n / 10000
        return pack4[a] + pack_exact[(L - 4) * 10000 + b]
    }
    if L <= 12 {
        let a: i64 = n % 10000
        n = n / 10000
        let b: i64 = n % 10000
        let c: i64 = n / 10000
        return pack4[a] + pack4[b] + pack_exact[(L - 8) * 10000 + c]
    }
    let a: i64 = n % 10000
    n = n / 10000
    let b: i64 = n % 10000
    n = n / 10000
    let c: i64 = n % 10000
    let d: i64 = n / 10000
    return pack4[a] + pack4[b] + pack4[c] + pack_exact[(L - 12) * 10000 + d]
}

function leaf(packed_part: i64) -> void {
    let sig: i64 = packed_part | g_sig_m
    let mut idx: i32 = 0
    while idx < g_nks {
        let mut t: i128 = g_base_t[idx]
        let k: i32 = g_Ks[idx]
        let mut d: i32 = 0
        while d < 10 {
            let c: i32 = g_counts[d]
            if c != 0 {
                t = t + (c as i128) * pow_table[k * 10 + d]
            }
            d = d + 1
        }
        if t > 0 {
            let n: i64 = (t - 1) as i64
            if g_L_lo <= n && n < g_L_hi {
                if pack_digits_len(n, g_L) == sig {
                    set_insert(n)
                }
            }
        }
        let n2: i64 = (t + 1) as i64
        if g_L_lo <= n2 && n2 < g_L_hi {
            if pack_digits_len(n2, g_L) == sig {
                set_insert(n2)
            }
        }
        idx = idx + 1
    }
}

function rec(d: i32, remaining: i32, packed_part: i64, m: i32) -> void {
    if d == m - 1 {
        g_counts[d] = remaining
        leaf(packed_part | ((remaining as i64) << (5 * d)))
        return
    }
    let shift: i32 = 5 * d
    let mut c: i32 = 0
    while c <= remaining {
        g_counts[d] = c
        rec(d + 1, remaining - c, packed_part | ((c as i64) << shift), m)
        c = c + 1
    }
}

function main() -> i32 {
    g_Ks = calloc(64, 4) as ptr<i32>
    g_base_t = calloc(64, 16) as ptr<i128>
    g_counts = calloc(10, 4) as ptr<i32>

    build_pow10()
    compute_max_k()
    build_pow_table()
    build_k_bounds()
    build_pack_tables()
    set_init()

    let mut L: i32 = 1
    while L <= MAX_DIGITS {
        g_L = L
        g_L_lo = p10[L - 1]
        g_L_hi = p10[L]

        let mut m: i32 = 2
        while m < 10 {
            let shift_m: i32 = 5 * m
            let km_base: i32 = k_low[L * 10 + m]

            let mut c_m: i32 = 1
            while c_m <= L {
                let k1: i32 = km_base
                let k2: i32 = k_high[(L * 10 + m) * 17 + c_m]
                if k1 > k2 {
                    c_m = c_m + 1
                    continue
                }

                g_nks = 0
                let mut k: i32 = k1
                while k <= k2 {
                    g_Ks[g_nks] = k
                    g_base_t[g_nks] = (c_m as i128) * pow_table[k * 10 + m]
                    g_nks = g_nks + 1
                    k = k + 1
                }
                let rem: i32 = L - c_m
                let mut i: i32 = 0
                while i < m {
                    g_counts[i] = 0
                    i = i + 1
                }
                g_sig_m = (c_m as i64) << shift_m

                if m == 2 {
                    let mut c0: i32 = 0
                    while c0 <= rem {
                        let c1: i32 = rem - c0
                        g_counts[0] = c0
                        g_counts[1] = c1
                        leaf((c0 as i64) | ((c1 as i64) << 5))
                        c0 = c0 + 1
                    }
                } else {
                    rec(0, rem, 0, m)
                }
                c_m = c_m + 1
            }
            m = m + 1
        }
        L = L + 1
    }

    let mut total: i128 = 0
    let mut i: i64 = 0
    while i < SET_CAP {
        if set_tbl[i] != 0 {
            total = total + (set_tbl[i] as i128)
        }
        i = i + 1
    }
    printf("%lld\n", total as i64)
    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; }

void set_init(void);
int32_t set_insert_i64(int64_t v);
void build_pow10(void);
void compute_max_k(void);
void build_pow_table(void);
void build_k_bounds(void);
void build_pack_tables(void);
int64_t pack_digits_len_i64_i32(int64_t n0, int32_t L);
void leaf_i64(int64_t packed_part);
void rec_i32_i32_i64_i32(int32_t d, int32_t remaining, int64_t packed_part, int32_t m);
int32_t main(void);

static const int32_t MAX_DIGITS = 16;
static const int64_t SET_CAP = 65536;

/* Module statics */
static int64_t* p10 = NULL;
static int32_t max_k = 0;
static __int128* pow_table = NULL;
static int32_t* k_low = NULL;
static int32_t* k_high = NULL;
static int64_t* pack4 = NULL;
static int64_t* pack_exact = NULL;
static int64_t* set_tbl = NULL;
static int32_t* g_Ks = NULL;
static int32_t g_nks = 0;
static __int128* g_base_t = NULL;
static int32_t* g_counts = NULL;
static int64_t g_sig_m = 0;
static int64_t g_L_lo = 0;
static int64_t g_L_hi = 0;
static int32_t g_L = 0;




void set_init(void) {
    set_tbl = ((int64_t*)(calloc(SET_CAP, 8)));
}

int32_t set_insert_i64(int64_t v) {
    int64_t idx = (((v ^ FLOW_CHECKED_SHR((v), (16))) ^ FLOW_CHECKED_SHR((v), (32))) & (SET_CAP - 1));
    while (1) {
        if (set_tbl[idx] == 0) {
            set_tbl[idx] = v;
            return 1;
        }
        if (set_tbl[idx] == v) {
            return 0;
        }
        idx = ((idx + 1) & (SET_CAP - 1));
    }
    return 0;
}

void build_pow10(void) {
    p10 = ((int64_t*)(calloc(17, 8)));
    p10[0] = 1;
    int32_t i = 1;
    while (i <= MAX_DIGITS) {
        p10[i] = (p10[(i - 1)] * 10);
        i = (i + 1);
    }
}

void compute_max_k(void) {
    int64_t limit = p10[MAX_DIGITS];
    int32_t k = 0;
    int64_t p = 1;
    while (p <= limit) {
        k = (k + 1);
        p = (p * 2);
    }
    max_k = k;
}

void build_pow_table(void) {
    pow_table = ((__int128*)(calloc(640, 16)));
    int32_t d = 0;
    while (d < 10) {
        pow_table[((1 * 10) + d)] = ((__int128)(d));
        d = (d + 1);
    }
    int32_t k = 2;
    while (k <= max_k) {
        int32_t d2 = 0;
        while (d2 < 10) {
            __int128 val = (pow_table[(((k - 1) * 10) + d2)] * ((__int128)(d2)));
            if (val > ((__int128)(1000000000000000000))) {
                pow_table[((k * 10) + d2)] = ((__int128)(1000000000000000000));
            } else {
                pow_table[((k * 10) + d2)] = val;
            }
            d2 = (d2 + 1);
        }
        k = (k + 1);
    }
}

void build_k_bounds(void) {
    k_low = ((int32_t*)(calloc(170, 4)));
    k_high = ((int32_t*)(calloc(2890, 4)));
    int32_t L = 1;
    while (L <= MAX_DIGITS) {
        int64_t lt = (p10[(L - 1)] - 1);
        int64_t ht = p10[L];
        int32_t m = 0;
        while (m < 10) {
            k_low[((L * 10) + m)] = (max_k + 1);
            int32_t c = 0;
            while (c <= MAX_DIGITS) {
                k_high[((((L * 10) + m) * 17) + c)] = 0;
                c = (c + 1);
            }
            m = (m + 1);
        }
        int32_t m2 = 2;
        while (m2 < 10) {
            __int128 p = ((__int128)(m2));
            int32_t k = 1;
            while ((k <= max_k && (((__int128)(L)) * p) < ((__int128)(lt)))) {
                p = (p * ((__int128)(m2)));
                k = (k + 1);
            }
            k_low[((L * 10) + m2)] = k;
            int32_t c2 = 1;
            while (c2 <= L) {
                __int128 p2 = ((__int128)(m2));
                int32_t best = 0;
                int32_t kk = 1;
                while (kk <= max_k) {
                    if ((((__int128)(c2)) * p2) <= ((__int128)(ht))) {
                        best = kk;
                        p2 = (p2 * ((__int128)(m2)));
                    } else {
                        break;
                    }
                    kk = (kk + 1);
                }
                k_high[((((L * 10) + m2) * 17) + c2)] = best;
                c2 = (c2 + 1);
            }
            m2 = (m2 + 1);
        }
        L = (L + 1);
    }
}

void build_pack_tables(void) {
    pack4 = ((int64_t*)(calloc(10000, 8)));
    pack_exact = ((int64_t*)(calloc(50000, 8)));
    int32_t x = 0;
    while (x < 10000) {
        int64_t code = 0;
        int32_t y = x;
        int32_t i = 0;
        while (i < 4) {
            int32_t d = FLOW_CHECKED_MOD((y), (10));
            code = (code + FLOW_CHECKED_SHL((((int64_t)(1))), ((5 * d))));
            y = FLOW_CHECKED_DIV((y), (10));
            i = (i + 1);
        }
        pack4[x] = code;
        x = (x + 1);
    }
    int32_t x2 = 0;
    while (x2 < 10) {
        pack_exact[((1 * 10000) + x2)] = FLOW_CHECKED_SHL((((int64_t)(1))), ((5 * x2)));
        x2 = (x2 + 1);
    }
    int32_t x3 = 0;
    while (x3 < 100) {
        int64_t code = 0;
        int32_t y = x3;
        int32_t i = 0;
        while (i < 2) {
            int32_t d = FLOW_CHECKED_MOD((y), (10));
            code = (code + FLOW_CHECKED_SHL((((int64_t)(1))), ((5 * d))));
            y = FLOW_CHECKED_DIV((y), (10));
            i = (i + 1);
        }
        pack_exact[((2 * 10000) + x3)] = code;
        x3 = (x3 + 1);
    }
    int32_t x4 = 0;
    while (x4 < 1000) {
        int64_t code = 0;
        int32_t y = x4;
        int32_t i = 0;
        while (i < 3) {
            int32_t d = FLOW_CHECKED_MOD((y), (10));
            code = (code + FLOW_CHECKED_SHL((((int64_t)(1))), ((5 * d))));
            y = FLOW_CHECKED_DIV((y), (10));
            i = (i + 1);
        }
        pack_exact[((3 * 10000) + x4)] = code;
        x4 = (x4 + 1);
    }
    int32_t x5 = 0;
    while (x5 < 10000) {
        pack_exact[((4 * 10000) + x5)] = pack4[x5];
        x5 = (x5 + 1);
    }
}

int64_t pack_digits_len_i64_i32(int64_t n0, int32_t L) {
    int64_t n = n0;
    if (L <= 4) {
        return pack_exact[((L * 10000) + n)];
    }
    if (L <= 8) {
        int64_t a = FLOW_CHECKED_MOD((n), (10000));
        int64_t b = FLOW_CHECKED_DIV((n), (10000));
        return (pack4[a] + pack_exact[(((L - 4) * 10000) + b)]);
    }
    if (L <= 12) {
        int64_t a = FLOW_CHECKED_MOD((n), (10000));
        n = FLOW_CHECKED_DIV((n), (10000));
        int64_t b = FLOW_CHECKED_MOD((n), (10000));
        int64_t c = FLOW_CHECKED_DIV((n), (10000));
        return ((pack4[a] + pack4[b]) + pack_exact[(((L - 8) * 10000) + c)]);
    }
    int64_t a = FLOW_CHECKED_MOD((n), (10000));
    n = FLOW_CHECKED_DIV((n), (10000));
    int64_t b = FLOW_CHECKED_MOD((n), (10000));
    n = FLOW_CHECKED_DIV((n), (10000));
    int64_t c = FLOW_CHECKED_MOD((n), (10000));
    int64_t d = FLOW_CHECKED_DIV((n), (10000));
    return (((pack4[a] + pack4[b]) + pack4[c]) + pack_exact[(((L - 12) * 10000) + d)]);
}

void leaf_i64(int64_t packed_part) {
    int64_t sig = (packed_part | g_sig_m);
    int32_t idx = 0;
    while (idx < g_nks) {
        __int128 t = g_base_t[idx];
        int32_t k = g_Ks[idx];
        int32_t d = 0;
        while (d < 10) {
            int32_t c = g_counts[d];
            if (c != 0) {
                t = (t + (((__int128)(c)) * pow_table[((k * 10) + d)]));
            }
            d = (d + 1);
        }
        if (t > 0) {
            int64_t n = ((int64_t)((t - 1)));
            if ((g_L_lo <= n && n < g_L_hi)) {
                if (pack_digits_len_i64_i32(n, g_L) == sig) {
                    set_insert_i64(n);
                }
            }
        }
        int64_t n2 = ((int64_t)((t + 1)));
        if ((g_L_lo <= n2 && n2 < g_L_hi)) {
            if (pack_digits_len_i64_i32(n2, g_L) == sig) {
                set_insert_i64(n2);
            }
        }
        idx = (idx + 1);
    }
}

void rec_i32_i32_i64_i32(int32_t d, int32_t remaining, int64_t packed_part, int32_t m) {
    if (d == (m - 1)) {
        g_counts[d] = remaining;
        leaf_i64((packed_part | FLOW_CHECKED_SHL((((int64_t)(remaining))), ((5 * d)))));
        return;
    }
    int32_t shift = (5 * d);
    int32_t c = 0;
    while (c <= remaining) {
        g_counts[d] = c;
        rec_i32_i32_i64_i32((d + 1), (remaining - c), (packed_part | FLOW_CHECKED_SHL((((int64_t)(c))), (shift))), m);
        c = (c + 1);
    }
}

int32_t main(void) {
    g_Ks = ((int32_t*)(calloc(64, 4)));
    g_base_t = ((__int128*)(calloc(64, 16)));
    g_counts = ((int32_t*)(calloc(10, 4)));
    build_pow10();
    compute_max_k();
    build_pow_table();
    build_k_bounds();
    build_pack_tables();
    set_init();
    int32_t L = 1;
    while (L <= MAX_DIGITS) {
        g_L = L;
        g_L_lo = p10[(L - 1)];
        g_L_hi = p10[L];
        int32_t m = 2;
        while (m < 10) {
            int32_t shift_m = (5 * m);
            int32_t km_base = k_low[((L * 10) + m)];
            int32_t c_m = 1;
            while (c_m <= L) {
                int32_t k1 = km_base;
                int32_t k2 = k_high[((((L * 10) + m) * 17) + c_m)];
                if (k1 > k2) {
                    c_m = (c_m + 1);
                    continue;
                }
                g_nks = 0;
                int32_t k = k1;
                while (k <= k2) {
                    g_Ks[g_nks] = k;
                    g_base_t[g_nks] = (((__int128)(c_m)) * pow_table[((k * 10) + m)]);
                    g_nks = (g_nks + 1);
                    k = (k + 1);
                }
                int32_t rem = (L - c_m);
                int32_t i = 0;
                while (i < m) {
                    g_counts[i] = 0;
                    i = (i + 1);
                }
                g_sig_m = FLOW_CHECKED_SHL((((int64_t)(c_m))), (shift_m));
                if (m == 2) {
                    int32_t c0 = 0;
                    while (c0 <= rem) {
                        int32_t c1 = (rem - c0);
                        g_counts[0] = c0;
                        g_counts[1] = c1;
                        leaf_i64((((int64_t)(c0)) | FLOW_CHECKED_SHL((((int64_t)(c1))), (5))));
                        c0 = (c0 + 1);
                    }
                } else {
                    rec_i32_i32_i64_i32(0, rem, 0, m);
                }
                c_m = (c_m + 1);
            }
            m = (m + 1);
        }
        L = (L + 1);
    }
    __int128 total = 0;
    int64_t i = 0;
    while (i < SET_CAP) {
        if (set_tbl[i] != 0) {
            total = (total + ((__int128)(set_tbl[i])));
        }
        i = (i + 1);
    }
    printf("%lld\n", ((int64_t)(total)));
    return 0;
}

Generated MLIR

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