Problem 714

Duodigits. d(n) is the smallest positive multiple of n whose decimal form uses at most two distinct digits; D(k) = sum of d(n) for n <= k. For n not divisible by 10 we run ONE level-synchronous BFS across all 45 digit pairs {a,b} at once: every pair's frontier advances one level per round, so the first round that produces remainder 0 gives the shortest duodigit length, and no pair ever explores past that level. This avoids the blow-up where a pair whose smallest multiple is long would otherwise scan the whole remainder space before a better pair gets a chance. All hits at the winning level are reconstructed and the minimum value taken, which is d(n) (shorter duodigits are always smaller numbers). Numbers divisible by 10 must end in 0, so their duodigit multiple uses digits {0,d}. Writing it as 10*V, V is the smallest {0,d} duodigit divisible by m = n/10, so we BFS mod m (<= 5000) over only the 9 pairs {0,d}. The answer is 10*V. The sum is kept exactly in i128 and printed with 13 significant digits.

Answer2.452767775565e20
Output2.452767775565e20
StatusPASS
Native helperno
Runtime24730 ms
Peak memory39488 KB
Time complexityO(n^3) (estimated)
Space complexityO(n^2) (estimated)

Performance comparison

MetricOur solutionBest known
Time complexityO(n^3)O(n log n)
Space complexityO(n^2)O(n)
ApproachFlow solutionSearch with pruning or sieve
VerdictSuboptimal

Flow source

# Project Euler 714
# Duodigits.  d(n) is the smallest positive multiple of n whose decimal
# form uses at most two distinct digits; D(k) = sum of d(n) for n <= k.
#
# For n not divisible by 10 we run ONE level-synchronous BFS across all 45
# digit pairs {a,b} at once: every pair's frontier advances one level per
# round, so the first round that produces remainder 0 gives the shortest
# duodigit length, and no pair ever explores past that level.  This avoids
# the blow-up where a pair whose smallest multiple is long would otherwise
# scan the whole remainder space before a better pair gets a chance.
# All hits at the winning level are reconstructed and the minimum value
# taken, which is d(n) (shorter duodigits are always smaller numbers).
#
# Numbers divisible by 10 must end in 0, so their duodigit multiple uses
# digits {0,d}.  Writing it as 10*V, V is the smallest {0,d} duodigit
# divisible by m = n/10, so we BFS mod m (<= 5000) over only the 9 pairs
# {0,d}.  The answer is 10*V.
# The sum is kept exactly in i128 and printed with 13 significant digits.

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

const N: i64 = 50000

# For n divisible by 10: search (up to cap_len levels) for the smallest
# {a,b}-duodigit divisible by mod.  Returns its digit length, or 0 if none
# found within cap_len.  Writes the exact value to out_val[0] when the
# length is <= 25, otherwise writes -1.
function bfs_ab(mod: i64, a: i64, b: i64, cap_len: i64,
                seen: ptr<i64>, prv: ptr<i64>, dg: ptr<i64>, qq: ptr<i64>,
                buf: ptr<i64>, ptoken: ptr<i64>, out_val: ptr<i128>) -> i64 {
    let token: i64 = ptoken[0] + 1
    ptoken[0] = token
    let mut hit: i64 = 0
    let mut hitpar: i64 = 0
    let mut hitdig: i64 = 0
    let mut hitlen: i64 = 0
    let mut cnt: i64 = 0
    let mut s: i64 = 0
    while s < 2 {
        let mut d: i64 = a
        if s == 1 { d = b }
        if d > 0 && hit == 0 {
            let r: i64 = d % mod
            if r == 0 {
                hit = 1
                hitpar = 0 - 1
                hitdig = d
                hitlen = 1
            } else {
                if seen[r] != token {
                    seen[r] = token
                    prv[r] = 0 - 1
                    dg[r] = d
                    qq[cnt] = r
                    cnt = cnt + 1
                }
            }
        }
        s = s + 1
    }
    let mut ls: i64 = 0
    let mut le: i64 = cnt
    let mut level: i64 = 1
    while hit == 0 && ls < le && level < cap_len {
        let mut ne: i64 = le
        let mut i: i64 = ls
        while i < le && hit == 0 {
            let r: i64 = qq[i]
            let mut t: i64 = 0
            while t < 2 && hit == 0 {
                let mut d: i64 = a
                if t == 1 { d = b }
                let nr: i64 = (r * 10 + d) % mod
                if nr == 0 {
                    hit = 1
                    hitpar = r
                    hitdig = d
                    hitlen = level + 1
                } else {
                    if seen[nr] != token {
                        seen[nr] = token
                        prv[nr] = r
                        dg[nr] = d
                        qq[ne] = nr
                        ne = ne + 1
                    }
                }
                t = t + 1
            }
            i = i + 1
        }
        ls = le
        le = ne
        level = level + 1
    }
    if hit == 0 {
        out_val[0] = 0 as i128 - (1 as i128)
        return 0
    }
    if hitlen > 25 {
        out_val[0] = 0 as i128 - (1 as i128)
        return hitlen
    }
    let mut k: i64 = 0
    buf[k] = hitdig
    k = k + 1
    let mut c: i64 = hitpar
    while c != 0 - 1 {
        buf[k] = dg[c]
        k = k + 1
        c = prv[c]
    }
    let mut val: i128 = 0 as i128
    let mut j: i64 = k - 1
    while j >= 0 {
        val = val * (10 as i128) + (buf[j] as i128)
        j = j - 1
    }
    out_val[0] = val
    return hitlen
}

# Level-synchronous BFS over all 45 digit pairs for n not divisible by 10.
# Returns d(n)'s digit length, or 0 if none found within 25 digits.
# Writes the value to out_val[0].
function bfs_all(mod: i64, pa: ptr<i64>, pb: ptr<i64>,
                 seen: ptr<i64>, q_pair: ptr<i8>, q_rem: ptr<i64>,
                 q_prv: ptr<i64>, q_dig: ptr<i8>, buf: ptr<i64>,
                 ptoken: ptr<i64>, out_val: ptr<i128>) -> i64 {
    # single-digit duodigits (handles mod <= 9)
    let mut sd: i64 = 1
    while sd <= 9 {
        if sd % mod == 0 {
            out_val[0] = sd as i128
            return 1
        }
        sd = sd + 1
    }
    let token: i64 = ptoken[0] + 1
    ptoken[0] = token
    let mut cnt: i64 = 0
    let mut p: i64 = 0
    while p < 45 {
        let a: i64 = pa[p]
        let b: i64 = pb[p]
        let mut s: i64 = 0
        while s < 2 {
            let mut d: i64 = a
            if s == 1 { d = b }
            if d > 0 {
                let r: i64 = d % mod
                if r != 0 {
                    let key: i64 = p * mod + r
                    if seen[key] != token {
                        seen[key] = token
                        q_pair[cnt] = p as i8
                        q_rem[cnt] = r
                        q_prv[cnt] = 0 - 1
                        q_dig[cnt] = d as i8
                        cnt = cnt + 1
                    }
                }
            }
            s = s + 1
        }
        p = p + 1
    }
    let mut ls: i64 = 0
    let mut le: i64 = cnt
    let mut level: i64 = 1
    while ls < le && level < 25 {
        let mut ne: i64 = le
        let mut found: i64 = 0
        let mut bestv: i128 = 0 as i128 - (1 as i128)
        let mut i: i64 = ls
        while i < le {
            let pp: i64 = (q_pair[i] as i64)
            let rem: i64 = q_rem[i]
            let a: i64 = pa[pp]
            let b: i64 = pb[pp]
            let mut t: i64 = 0
            while t < 2 {
                let mut d: i64 = a
                if t == 1 { d = b }
                let nr: i64 = (rem * 10 + d) % mod
                if nr == 0 {
                    let mut k: i64 = 0
                    buf[k] = d
                    k = k + 1
                    let mut c: i64 = i
                    while c != 0 - 1 {
                        buf[k] = (q_dig[c] as i64)
                        k = k + 1
                        c = q_prv[c]
                    }
                    let mut val: i128 = 0 as i128
                    let mut j: i64 = k - 1
                    while j >= 0 {
                        val = val * (10 as i128) + (buf[j] as i128)
                        j = j - 1
                    }
                    if found == 0 {
                        found = 1
                        bestv = val
                    } else {
                        if val < bestv { bestv = val }
                    }
                } else {
                    let key: i64 = pp * mod + nr
                    if seen[key] != token {
                        seen[key] = token
                        q_pair[ne] = pp as i8
                        q_rem[ne] = nr
                        q_prv[ne] = i
                        q_dig[ne] = d as i8
                        ne = ne + 1
                    }
                }
                t = t + 1
            }
            i = i + 1
        }
        if found == 1 {
            out_val[0] = bestv
            return level + 1
        }
        ls = le
        le = ne
        level = level + 1
    }
    out_val[0] = 0 as i128 - (1 as i128)
    return 0
}

function main() -> i32 {
    let seen: ptr<i64> = calloc(N + 2, 8)
    let prv: ptr<i64> = calloc(N + 2, 8)
    let dg: ptr<i64> = calloc(N + 2, 8)
    let qq: ptr<i64> = calloc(N + 2, 8)
    let buf: ptr<i64> = calloc(64, 8)
    let pa: ptr<i64> = calloc(45, 8)
    let pb: ptr<i64> = calloc(45, 8)
    let out_val: ptr<i128> = calloc(2, 16)
    let ptoken: ptr<i64> = calloc(1, 8)
    if seen == null || prv == null || dg == null || qq == null || buf == null || pa == null || pb == null || out_val == null || ptoken == null { return 1 }

    # interleaved-BFS scratch (sized for 45 pairs * max mod)
    let SEEN_SZ: i64 = 45 * (N + 2)
    let i_seen: ptr<i64> = calloc(SEEN_SZ, 8)
    let i_qrem: ptr<i64> = calloc(SEEN_SZ, 8)
    let i_qprv: ptr<i64> = calloc(SEEN_SZ, 8)
    let i_qpair: ptr<i8> = calloc(SEEN_SZ, 1)
    let i_qdig: ptr<i8> = calloc(SEEN_SZ, 1)
    if i_seen == null || i_qrem == null || i_qprv == null || i_qpair == null || i_qdig == null { return 1 }

    let mut np: i64 = 0
    let mut aa: i64 = 0
    while aa < 10 {
        let mut bb: i64 = aa + 1
        while bb < 10 {
            pa[np] = aa
            pb[np] = bb
            np = np + 1
            bb = bb + 1
        }
        aa = aa + 1
    }

    let mut total: i128 = 0 as i128

    let mut n: i64 = 1
    while n <= N {
        if n % 10 == 0 {
            # n = 10*m: only pairs {0,d} can work; BFS mod m, answer is 10*V.
            let m: i64 = n / 10
            let mut bestlen: i64 = 1000000
            let mut bestval: i128 = 0 as i128 - (1 as i128)
            let mut d: i64 = 1
            while d <= 9 {
                let hl: i64 = bfs_ab(m, 0, d, bestlen, seen, prv, dg, qq, buf, ptoken, out_val)
                if hl > 0 {
                    if hl <= 25 {
                        if hl < bestlen {
                            bestlen = hl
                            bestval = out_val[0]
                        } else {
                            if hl == bestlen {
                                if bestval < 0 || out_val[0] < bestval {
                                    bestval = out_val[0]
                                }
                            }
                        }
                    } else {
                        if hl < bestlen {
                            bestlen = hl
                            bestval = 0 as i128 - (1 as i128)
                        }
                    }
                }
                d = d + 1
            }
            total = total + (10 as i128) * bestval
        } else {
            let hl: i64 = bfs_all(n, pa, pb, i_seen, i_qpair, i_qrem, i_qprv, i_qdig, buf, ptoken, out_val)
            total = total + out_val[0]
        }
        n = n + 1
    }

    # scientific notation, 13 significant digits (12 after the point)
    let mut tmp: i128 = total
    let mut nd: i64 = 0
    while tmp > (0 as i128) {
        tmp = tmp / (10 as i128)
        nd = nd + 1
    }
    let mut ex: i64 = nd - 1
    let mut mant: i128 = total
    if nd > 13 {
        let mut shift: i64 = nd - 13
        let mut pw: i128 = 1 as i128
        let mut u: i64 = 0
        while u < shift {
            pw = pw * (10 as i128)
            u = u + 1
        }
        mant = (total + pw / (2 as i128)) / pw
        # rounding may carry into a 14th digit
        let mut cap: i128 = 1 as i128
        u = 0
        while u < 13 {
            cap = cap * (10 as i128)
            u = u + 1
        }
        if mant >= cap {
            mant = mant / (10 as i128)
            ex = ex + 1
        }
    } else {
        let mut u: i64 = nd
        while u < 13 {
            mant = mant * (10 as i128)
            u = u + 1
        }
    }
    let m64: i64 = mant as i64
    printf("%lld.%012llde%lld\n", m64 / 1000000000000, m64 % 1000000000000, ex)

    free(i_qdig)
    free(i_qpair)
    free(i_qprv)
    free(i_qrem)
    free(i_seen)
    free(ptoken)
    free(out_val)
    free(pb)
    free(pa)
    free(buf)
    free(qq)
    free(dg)
    free(prv)
    free(seen)
    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 bfs_ab_i64_i64_i64_i64_ptr_i64_ptr_i64_ptr_i64_ptr_i64_ptr_i64_ptr_i64_ptr_i128(int64_t mod, int64_t a, int64_t b, int64_t cap_len, int64_t* seen, int64_t* prv, int64_t* dg, int64_t* qq, int64_t* buf, int64_t* ptoken, __int128* out_val);
int64_t bfs_all_i64_ptr_i64_ptr_i64_ptr_i64_ptr_i8_ptr_i64_ptr_i64_ptr_i8_ptr_i64_ptr_i64_ptr_i128(int64_t mod, int64_t* pa, int64_t* pb, int64_t* seen, int8_t* q_pair, int64_t* q_rem, int64_t* q_prv, int8_t* q_dig, int64_t* buf, int64_t* ptoken, __int128* out_val);
int32_t main(void);

static const int64_t N = 50000;



int64_t bfs_ab_i64_i64_i64_i64_ptr_i64_ptr_i64_ptr_i64_ptr_i64_ptr_i64_ptr_i64_ptr_i128(int64_t mod, int64_t a, int64_t b, int64_t cap_len, int64_t* seen, int64_t* prv, int64_t* dg, int64_t* qq, int64_t* buf, int64_t* ptoken, __int128* out_val) {
    int64_t token = (ptoken[0] + 1);
    ptoken[0] = token;
    int64_t hit = 0;
    int64_t hitpar = 0;
    int64_t hitdig = 0;
    int64_t hitlen = 0;
    int64_t cnt = 0;
    int64_t s = 0;
    while (s < 2) {
        int64_t d = a;
        if (s == 1) {
            d = b;
        }
        if ((d > 0 && hit == 0)) {
            int64_t r = FLOW_CHECKED_MOD((d), (mod));
            if (r == 0) {
                hit = 1;
                hitpar = (0 - 1);
                hitdig = d;
                hitlen = 1;
            } else {
                if (seen[r] != token) {
                    seen[r] = token;
                    prv[r] = (0 - 1);
                    dg[r] = d;
                    qq[cnt] = r;
                    cnt = (cnt + 1);
                }
            }
        }
        s = (s + 1);
    }
    int64_t ls = 0;
    int64_t le = cnt;
    int64_t level = 1;
    while (((hit == 0 && ls < le) && level < cap_len)) {
        int64_t ne = le;
        int64_t i = ls;
        while ((i < le && hit == 0)) {
            int64_t r = qq[i];
            int64_t t = 0;
            while ((t < 2 && hit == 0)) {
                int64_t d = a;
                if (t == 1) {
                    d = b;
                }
                int64_t nr = FLOW_CHECKED_MOD((((r * 10) + d)), (mod));
                if (nr == 0) {
                    hit = 1;
                    hitpar = r;
                    hitdig = d;
                    hitlen = (level + 1);
                } else {
                    if (seen[nr] != token) {
                        seen[nr] = token;
                        prv[nr] = r;
                        dg[nr] = d;
                        qq[ne] = nr;
                        ne = (ne + 1);
                    }
                }
                t = (t + 1);
            }
            i = (i + 1);
        }
        ls = le;
        le = ne;
        level = (level + 1);
    }
    if (hit == 0) {
        out_val[0] = (((__int128)(0)) - ((__int128)(1)));
        return 0;
    }
    if (hitlen > 25) {
        out_val[0] = (((__int128)(0)) - ((__int128)(1)));
        return hitlen;
    }
    int64_t k = 0;
    buf[k] = hitdig;
    k = (k + 1);
    int64_t c = hitpar;
    while (c != (0 - 1)) {
        buf[k] = dg[c];
        k = (k + 1);
        c = prv[c];
    }
    __int128 val = ((__int128)(0));
    int64_t j = (k - 1);
    while (j >= 0) {
        val = ((val * ((__int128)(10))) + ((__int128)(buf[j])));
        j = (j - 1);
    }
    out_val[0] = val;
    return hitlen;
}

int64_t bfs_all_i64_ptr_i64_ptr_i64_ptr_i64_ptr_i8_ptr_i64_ptr_i64_ptr_i8_ptr_i64_ptr_i64_ptr_i128(int64_t mod, int64_t* pa, int64_t* pb, int64_t* seen, int8_t* q_pair, int64_t* q_rem, int64_t* q_prv, int8_t* q_dig, int64_t* buf, int64_t* ptoken, __int128* out_val) {
    int64_t sd = 1;
    while (sd <= 9) {
        if (FLOW_CHECKED_MOD((sd), (mod)) == 0) {
            out_val[0] = ((__int128)(sd));
            return 1;
        }
        sd = (sd + 1);
    }
    int64_t token = (ptoken[0] + 1);
    ptoken[0] = token;
    int64_t cnt = 0;
    int64_t p = 0;
    while (p < 45) {
        int64_t a = pa[p];
        int64_t b = pb[p];
        int64_t s = 0;
        while (s < 2) {
            int64_t d = a;
            if (s == 1) {
                d = b;
            }
            if (d > 0) {
                int64_t r = FLOW_CHECKED_MOD((d), (mod));
                if (r != 0) {
                    int64_t key = ((p * mod) + r);
                    if (seen[key] != token) {
                        seen[key] = token;
                        q_pair[cnt] = ((int8_t)(p));
                        q_rem[cnt] = r;
                        q_prv[cnt] = (0 - 1);
                        q_dig[cnt] = ((int8_t)(d));
                        cnt = (cnt + 1);
                    }
                }
            }
            s = (s + 1);
        }
        p = (p + 1);
    }
    int64_t ls = 0;
    int64_t le = cnt;
    int64_t level = 1;
    while ((ls < le && level < 25)) {
        int64_t ne = le;
        int64_t found = 0;
        __int128 bestv = (((__int128)(0)) - ((__int128)(1)));
        int64_t i = ls;
        while (i < le) {
            int64_t pp = ((int64_t)(q_pair[i]));
            int64_t rem = q_rem[i];
            int64_t a = pa[pp];
            int64_t b = pb[pp];
            int64_t t = 0;
            while (t < 2) {
                int64_t d = a;
                if (t == 1) {
                    d = b;
                }
                int64_t nr = FLOW_CHECKED_MOD((((rem * 10) + d)), (mod));
                if (nr == 0) {
                    int64_t k = 0;
                    buf[k] = d;
                    k = (k + 1);
                    int64_t c = i;
                    while (c != (0 - 1)) {
                        buf[k] = ((int64_t)(q_dig[c]));
                        k = (k + 1);
                        c = q_prv[c];
                    }
                    __int128 val = ((__int128)(0));
                    int64_t j = (k - 1);
                    while (j >= 0) {
                        val = ((val * ((__int128)(10))) + ((__int128)(buf[j])));
                        j = (j - 1);
                    }
                    if (found == 0) {
                        found = 1;
                        bestv = val;
                    } else {
                        if (val < bestv) {
                            bestv = val;
                        }
                    }
                } else {
                    int64_t key = ((pp * mod) + nr);
                    if (seen[key] != token) {
                        seen[key] = token;
                        q_pair[ne] = ((int8_t)(pp));
                        q_rem[ne] = nr;
                        q_prv[ne] = i;
                        q_dig[ne] = ((int8_t)(d));
                        ne = (ne + 1);
                    }
                }
                t = (t + 1);
            }
            i = (i + 1);
        }
        if (found == 1) {
            out_val[0] = bestv;
            return (level + 1);
        }
        ls = le;
        le = ne;
        level = (level + 1);
    }
    out_val[0] = (((__int128)(0)) - ((__int128)(1)));
    return 0;
}

int32_t main(void) {
    int64_t* seen = (int64_t*)(calloc((N + 2), 8));
    int64_t* prv = (int64_t*)(calloc((N + 2), 8));
    int64_t* dg = (int64_t*)(calloc((N + 2), 8));
    int64_t* qq = (int64_t*)(calloc((N + 2), 8));
    int64_t* buf = (int64_t*)(calloc(64, 8));
    int64_t* pa = (int64_t*)(calloc(45, 8));
    int64_t* pb = (int64_t*)(calloc(45, 8));
    __int128* out_val = (__int128*)(calloc(2, 16));
    int64_t* ptoken = (int64_t*)(calloc(1, 8));
    if (((((((((seen == NULL || prv == NULL) || dg == NULL) || qq == NULL) || buf == NULL) || pa == NULL) || pb == NULL) || out_val == NULL) || ptoken == NULL)) {
        return 1;
    }
    int64_t SEEN_SZ = (45 * (N + 2));
    int64_t* i_seen = (int64_t*)(calloc(SEEN_SZ, 8));
    int64_t* i_qrem = (int64_t*)(calloc(SEEN_SZ, 8));
    int64_t* i_qprv = (int64_t*)(calloc(SEEN_SZ, 8));
    int8_t* i_qpair = (int8_t*)(calloc(SEEN_SZ, 1));
    int8_t* i_qdig = (int8_t*)(calloc(SEEN_SZ, 1));
    if (((((i_seen == NULL || i_qrem == NULL) || i_qprv == NULL) || i_qpair == NULL) || i_qdig == NULL)) {
        return 1;
    }
    int64_t np = 0;
    int64_t aa = 0;
    while (aa < 10) {
        int64_t bb = (aa + 1);
        while (bb < 10) {
            pa[np] = aa;
            pb[np] = bb;
            np = (np + 1);
            bb = (bb + 1);
        }
        aa = (aa + 1);
    }
    __int128 total = ((__int128)(0));
    int64_t n = 1;
    while (n <= N) {
        if (FLOW_CHECKED_MOD((n), (10)) == 0) {
            int64_t m = FLOW_CHECKED_DIV((n), (10));
            int64_t bestlen = 1000000;
            __int128 bestval = (((__int128)(0)) - ((__int128)(1)));
            int64_t d = 1;
            while (d <= 9) {
                int64_t hl = bfs_ab_i64_i64_i64_i64_ptr_i64_ptr_i64_ptr_i64_ptr_i64_ptr_i64_ptr_i64_ptr_i128(m, 0, d, bestlen, seen, prv, dg, qq, buf, ptoken, out_val);
                if (hl > 0) {
                    if (hl <= 25) {
                        if (hl < bestlen) {
                            bestlen = hl;
                            bestval = out_val[0];
                        } else {
                            if (hl == bestlen) {
                                if ((bestval < 0 || out_val[0] < bestval)) {
                                    bestval = out_val[0];
                                }
                            }
                        }
                    } else {
                        if (hl < bestlen) {
                            bestlen = hl;
                            bestval = (((__int128)(0)) - ((__int128)(1)));
                        }
                    }
                }
                d = (d + 1);
            }
            total = (total + (((__int128)(10)) * bestval));
        } else {
            int64_t hl = bfs_all_i64_ptr_i64_ptr_i64_ptr_i64_ptr_i8_ptr_i64_ptr_i64_ptr_i8_ptr_i64_ptr_i64_ptr_i128(n, pa, pb, i_seen, i_qpair, i_qrem, i_qprv, i_qdig, buf, ptoken, out_val);
            total = (total + out_val[0]);
        }
        n = (n + 1);
    }
    __int128 tmp = total;
    int64_t nd = 0;
    while (tmp > ((__int128)(0))) {
        tmp = FLOW_CHECKED_DIV((tmp), (((__int128)(10))));
        nd = (nd + 1);
    }
    int64_t ex = (nd - 1);
    __int128 mant = total;
    if (nd > 13) {
        int64_t shift = (nd - 13);
        __int128 pw = ((__int128)(1));
        int64_t u = 0;
        while (u < shift) {
            pw = (pw * ((__int128)(10)));
            u = (u + 1);
        }
        mant = FLOW_CHECKED_DIV(((total + FLOW_CHECKED_DIV((pw), (((__int128)(2)))))), (pw));
        __int128 cap = ((__int128)(1));
        u = 0;
        while (u < 13) {
            cap = (cap * ((__int128)(10)));
            u = (u + 1);
        }
        if (mant >= cap) {
            mant = FLOW_CHECKED_DIV((mant), (((__int128)(10))));
            ex = (ex + 1);
        }
    } else {
        int64_t u = nd;
        while (u < 13) {
            mant = (mant * ((__int128)(10)));
            u = (u + 1);
        }
    }
    int64_t m64 = ((int64_t)(mant));
    printf("%lld.%012llde%lld\n", FLOW_CHECKED_DIV((m64), (1000000000000)), FLOW_CHECKED_MOD((m64), (1000000000000)), ex);
    free(i_qdig);
    free(i_qpair);
    free(i_qprv);
    free(i_qrem);
    free(i_seen);
    free(ptoken);
    free(out_val);
    free(pb);
    free(pa);
    free(buf);
    free(qq);
    free(dg);
    free(prv);
    free(seen);
    return 0;
}

Generated MLIR

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