Problem 670

Tile a 2xn rectangle with 1x1, 1x2, 1x3 horizontal and 2x1 vertical domino tiles. 4 colours, no 4 corners meeting, adjacent tiles different colours. F(10^16) mod 1000004321. Uses BFS state enumeration + matrix exponentiation.

Answer551055065
Output551055065
StatusPASS
Native helperno
Runtime100 ms
Peak memory4672 KB
Time complexityO(n^3) (estimated)
Space complexityO(n^2) (estimated)

Performance comparison

MetricOur solutionBest known
Time complexityO(n^3)O(log n)
Space complexityO(n^2)O(n^2)
ApproachFlow solutionMatrix exponentiation
VerdictSuboptimal

Flow source

# Project Euler 670: Colouring a Strip
# Tile a 2xn rectangle with 1x1, 1x2, 1x3 horizontal and 2x1 vertical domino tiles.
# 4 colours, no 4 corners meeting, adjacent tiles different colours.
# F(10^16) mod 1000004321.
# Uses BFS state enumeration + matrix exponentiation.

import euler.nt { isqrt }

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

const MOD: i64 = 1000004321
const COLORS: i64 = 4
const NONE: i64 = 4

# State: (v_prev, inT, contT, valT, inB, contB, valB)
# Packed as: v_prev*1000000 + inT*100000 + contT*10000 + valT*1000 + inB*100 + contB*10 + valB
function pack_state(v_prev: i64, inT: i64, contT: i64, valT: i64, inB: i64, contB: i64, valB: i64) -> i64 {
    return v_prev * 1000000 + inT * 100000 + contT * 10000 + valT * 1000 + inB * 100 + contB * 10 + valB
}

function unpack_v_prev(s: i64) -> i64 { return s / 1000000 }
function unpack_inT(s: i64) -> i64 { return (s / 100000) % 10 }
function unpack_contT(s: i64) -> i64 { return (s / 10000) % 10 }
function unpack_valT(s: i64) -> i64 { return (s / 1000) % 10 }
function unpack_inB(s: i64) -> i64 { return (s / 100) % 10 }
function unpack_contB(s: i64) -> i64 { return (s / 10) % 10 }
function unpack_valB(s: i64) -> i64 { return s % 10 }

# BFS state enumeration
const MAX_STATES: i64 = 2000

function build_automaton(state_arr: ptr<i64>, adj_idx: ptr<i64>, adj_val: ptr<i64>, adj_w: ptr<i64>) -> i64 {
    # Returns number of states, fills adjacency as CSR-like structure
    let init: i64 = pack_state(1, 0, 0, NONE, 0, 0, NONE)
    state_arr[0] = init
    let mut n_states: i64 = 1
    let mut head: i64 = 0
    let mut n_edges: i64 = 0

    # Temporary transition buffer per state
    let trans_states: ptr<i64> = calloc(200, 8)
    let trans_weights: ptr<i64> = calloc(200, 8)

    while head < n_states {
        let s: i64 = state_arr[head]
        let v_prev: i64 = unpack_v_prev(s)
        let inT: i64 = unpack_inT(s)
        let contT: i64 = unpack_contT(s)
        let valT: i64 = unpack_valT(s)
        let inB: i64 = unpack_inB(s)
        let contB: i64 = unpack_contB(s)
        let valB: i64 = unpack_valB(s)

        # Compute transitions
        let mut n_trans: i64 = 0

        let cT: i64 = valT  # meaningful only if inT
        let cB: i64 = valB  # meaningful only if inB

        # nextT = (in, cont, val) for top row
        let nextT_in: i64
        let nextT_cont: i64
        let nextT_val: i64
        if inT != 0 {
            if contT != 0 { nextT_in = 1; nextT_cont = 0; nextT_val = valT }
            else { nextT_in = 0; nextT_cont = 0; nextT_val = valT }
        } else {
            nextT_in = -1; nextT_cont = -1; nextT_val = -1  # unused
        }

        let nextB_in: i64
        let nextB_cont: i64
        let nextB_val: i64
        if inB != 0 {
            if contB != 0 { nextB_in = 1; nextB_cont = 0; nextB_val = valB }
            else { nextB_in = 0; nextB_cont = 0; nextB_val = valB }
        } else {
            nextB_in = -1; nextB_cont = -1; nextB_val = -1
        }

        let leftT: i64 = valT  # meaningful only if inT==0
        let leftB: i64 = valB  # meaningful only if inB==0

        # Helper: add transition
        # add(v_cur, nt_in, nt_cont, nt_val, nb_in, nb_cont, nb_val, ways)

        # Case 1: both cells occupied
        if inT != 0 && inB != 0 {
            if cT != cB {
                let ns: i64 = pack_state(0, nextT_in, nextT_cont, nextT_val, nextB_in, nextB_cont, nextB_val)
                trans_states[n_trans] = ns
                trans_weights[n_trans] = 1
                n_trans = n_trans + 1
            }
        }
        else {
        # Case 2: top occupied, bottom free
        if inT != 0 && inB == 0 {
            for L in 1..4 {
                for col in 0..COLORS {
                    if leftB != NONE && col == leftB { continue }
                    if col == cT { continue }
                    let bs_in: i64
                    let bs_cont: i64
                    if L == 1 { bs_in = 0; bs_cont = 0 }
                    else { if L == 2 { bs_in = 1; bs_cont = 0 }
                    else { bs_in = 1; bs_cont = 1 } }

                    # No-4-corners check: v_prev==0 and v_cur==0 and inT==0 and inB==0
                    # In Case 2, inT!=0 so check always passes
                    let ns: i64 = pack_state(0, nextT_in, nextT_cont, nextT_val, bs_in, bs_cont, col)
                    trans_states[n_trans] = ns
                    trans_weights[n_trans] = 1
                    n_trans = n_trans + 1
                }
            }
        }
        else {
        # Case 3: bottom occupied, top free
        if inT == 0 && inB != 0 {
            for L in 1..4 {
                for col in 0..COLORS {
                    if leftT != NONE && col == leftT { continue }
                    if col == cB { continue }
                    let ts_in: i64
                    let ts_cont: i64
                    if L == 1 { ts_in = 0; ts_cont = 0 }
                    else { if L == 2 { ts_in = 1; ts_cont = 0 }
                    else { ts_in = 1; ts_cont = 1 } }

                    # No-4-corners check: v_prev==0 and v_cur==0 and inT==0 and inB==0
                    # In Case 3, inB!=0 so check always passes
                    let ns: i64 = pack_state(0, ts_in, ts_cont, col, nextB_in, nextB_cont, nextB_val)
                    trans_states[n_trans] = ns
                    trans_weights[n_trans] = 1
                    n_trans = n_trans + 1
                }
            }
        }
        else {
            # Case 4: both cells free
            # Option A: vertical domino
            for col in 0..COLORS {
                if leftT != NONE && col == leftT { continue }
                if leftB != NONE && col == leftB { continue }
                let ns: i64 = pack_state(1, 0, 0, col, 0, 0, col)
                trans_states[n_trans] = ns
                trans_weights[n_trans] = 1
                n_trans = n_trans + 1
            }

            # Option B: two horizontal tiles
            for Lt in 1..4 {
                for Lb in 1..4 {
                    for ct in 0..COLORS {
                        if leftT != NONE && ct == leftT { continue }
                        for cb in 0..COLORS {
                            if leftB != NONE && cb == leftB { continue }
                            if ct == cb { continue }

                            let ts_in: i64
                            let ts_cont: i64
                            if Lt == 1 { ts_in = 0; ts_cont = 0 }
                            else { if Lt == 2 { ts_in = 1; ts_cont = 0 }
                            else { ts_in = 1; ts_cont = 1 } }

                            let bs_in: i64
                            let bs_cont: i64
                            if Lb == 1 { bs_in = 0; bs_cont = 0 }
                            else { if Lb == 2 { bs_in = 1; bs_cont = 0 }
                            else { bs_in = 1; bs_cont = 1 } }

                            # Check no-4-corners: v_prev==0 and v_cur==0 and inT==0 and inB==0
                            # In Case 4, inT==0 and inB==0 and v_cur=0, so check v_prev only
                            if v_prev == 0 { continue }

                            let ns: i64 = pack_state(0, ts_in, ts_cont, ct, bs_in, bs_cont, cb)
                            trans_states[n_trans] = ns
                            trans_weights[n_trans] = 1
                            n_trans = n_trans + 1
                        }
                    }
                }
            }
        }
        }
        }

        # Merge duplicate transitions
        let mut merged_n: i64 = 0
        for ti in 0..n_trans {
            let found: i64 = -1
            for mi in 0..merged_n {
                if trans_states[mi] == trans_states[ti] {
                    trans_weights[mi] = (trans_weights[mi] + trans_weights[ti]) % MOD
                    found = 1
                }
            }
            if found == -1 {
                trans_states[merged_n] = trans_states[ti]
                trans_weights[merged_n] = trans_weights[ti]
                merged_n = merged_n + 1
            }
        }

        adj_idx[head] = n_edges
        for ti in 0..merged_n {
            # Find or add state
            let ns: i64 = trans_states[ti]
            let mut found: i64 = -1
            for si in 0..n_states {
                if state_arr[si] == ns { found = si }
            }
            if found == -1 {
                state_arr[n_states] = ns
                found = n_states
                n_states = n_states + 1
            }
            adj_val[n_edges] = found
            adj_w[n_edges] = trans_weights[ti]
            n_edges = n_edges + 1
        }

        head = head + 1
    }

    adj_idx[n_states] = n_edges  # sentinel

    free(trans_weights)
    free(trans_states)
    return n_states
}

function main() -> i32 {
    # Build automaton
    let state_arr: ptr<i64> = calloc(MAX_STATES, 8)
    let adj_idx: ptr<i64> = calloc(MAX_STATES + 1, 8)
    let adj_val: ptr<i64> = calloc(MAX_STATES * 200, 8)
    let adj_w: ptr<i64> = calloc(MAX_STATES * 200, 8)

    let S: i64 = build_automaton(state_arr, adj_idx, adj_val, adj_w)

    # Build dense matrix
    let T: ptr<i64> = calloc(S * S, 8)
    for i in 0..S {
        for ei in adj_idx[i]..adj_idx[i + 1] {
            let j: i64 = adj_val[ei]
            T[i * S + j] = adj_w[ei]
        }
    }

    # Initial vector: state 0 (init state)
    let v0: ptr<i64> = calloc(S, 8)
    v0[0] = 1

    # Matrix exponentiation: v = v0 * T^n
    let n: i64 = 10000000000000000  # 10^16

    let vcur: ptr<i64> = calloc(S, 8)
    for i in 0..S { vcur[i] = v0[i] }

    let power: ptr<i64> = calloc(S * S, 8)
    for i in 0..(S * S) { power[i] = T[i] }

    let tmp_vcur: ptr<i64> = calloc(S, 8)
    let tmp_mat: ptr<i64> = calloc(S * S, 8)

    let mut e: i64 = n
    while e > 0 {
        if e & 1 == 1 {
            # vcur = vcur * power
            for i in 0..S { tmp_vcur[i] = 0 }
            for i in 0..S {
                if vcur[i] == 0 { continue }
                for j in 0..S {
                    tmp_vcur[j] = (tmp_vcur[j] + vcur[i] * power[i * S + j]) % MOD
                }
            }
            for i in 0..S { vcur[i] = tmp_vcur[i] }
        }
        e = e >> 1
        if e > 0 {
            # power = power * power
            for i in 0..(S * S) { tmp_mat[i] = 0 }
            for i in 0..S {
                for k in 0..S {
                    if power[i * S + k] == 0 { continue }
                    for j in 0..S {
                        tmp_mat[i * S + j] = (tmp_mat[i * S + j] + power[i * S + k] * power[k * S + j]) % MOD
                    }
                }
            }
            for i in 0..(S * S) { power[i] = tmp_mat[i] }
        }
    }

    # Sum over accepting states (inT==0 and inB==0)
    let mut ans: i64 = 0
    for i in 0..S {
        let inT: i64 = unpack_inT(state_arr[i])
        let inB: i64 = unpack_inB(state_arr[i])
        if inT == 0 && inB == 0 {
            ans = (ans + vcur[i]) % MOD
        }
    }

    printf("%lld\n", ans)

    free(tmp_mat)
    free(tmp_vcur)
    free(power)
    free(vcur)
    free(v0)
    free(T)
    free(adj_w)
    free(adj_val)
    free(adj_idx)
    free(state_arr)
    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 gcd_i64_i64(int64_t a0, int64_t b0);
int64_t lcm_i64_i64(int64_t a, int64_t b);
int64_t isqrt_i64(int64_t n);
int64_t mulmod_i64_i64_i64(int64_t a0, int64_t b0, int64_t mod);
int64_t mod_pow_i64_i64_i64(int64_t base, int64_t exp, int64_t mod);
bool is_prime_i64(int64_t n);
int64_t pack_state_i64_i64_i64_i64_i64_i64_i64(int64_t v_prev, int64_t inT, int64_t contT, int64_t valT, int64_t inB, int64_t contB, int64_t valB);
int64_t unpack_v_prev_i64(int64_t s);
int64_t unpack_inT_i64(int64_t s);
int64_t unpack_contT_i64(int64_t s);
int64_t unpack_valT_i64(int64_t s);
int64_t unpack_inB_i64(int64_t s);
int64_t unpack_contB_i64(int64_t s);
int64_t unpack_valB_i64(int64_t s);
int64_t build_automaton_ptr_i64_ptr_i64_ptr_i64_ptr_i64(int64_t* state_arr, int64_t* adj_idx, int64_t* adj_val, int64_t* adj_w);
int32_t main(void);

static const int64_t MOD = 1000004321;
static const int64_t COLORS = 4;
static const int64_t NONE = 4;
static const int64_t MAX_STATES = 2000;

int64_t gcd_i64_i64(int64_t a0, int64_t b0) {
    int64_t a = a0;
    int64_t b = b0;
    while (b != 0) {
        int64_t t = FLOW_CHECKED_MOD((a), (b));
        a = b;
        b = t;
    }
    return a;
}

int64_t lcm_i64_i64(int64_t a, int64_t b) {
    if ((a == 0 || b == 0)) {
        return 0;
    }
    return (FLOW_CHECKED_DIV((a), (gcd_i64_i64(a, b))) * b);
}

int64_t isqrt_i64(int64_t n) {
    if (n < 2) {
        return n;
    }
    int64_t x = n;
    int64_t y = FLOW_CHECKED_DIV(((x + 1)), (2));
    while (y < x) {
        x = y;
        y = FLOW_CHECKED_DIV(((x + FLOW_CHECKED_DIV((n), (x)))), (2));
    }
    return x;
}

int64_t mulmod_i64_i64_i64(int64_t a0, int64_t b0, int64_t mod) {
    int64_t a = FLOW_CHECKED_MOD((a0), (mod));
    int64_t b = FLOW_CHECKED_MOD((b0), (mod));
    int64_t result = 0;
    while (b > 0) {
        if (FLOW_CHECKED_MOD((b), (2)) == 1) {
            result = FLOW_CHECKED_MOD(((result + a)), (mod));
        }
        a = FLOW_CHECKED_MOD(((a * 2)), (mod));
        b = FLOW_CHECKED_DIV((b), (2));
    }
    return result;
}

int64_t mod_pow_i64_i64_i64(int64_t base, int64_t exp, int64_t mod) {
    if (mod == 1) {
        return 0;
    }
    int64_t result = 1;
    int64_t b = FLOW_CHECKED_MOD((base), (mod));
    int64_t e = exp;
    while (e > 0) {
        if (FLOW_CHECKED_MOD((e), (2)) == 1) {
            result = mulmod_i64_i64_i64(result, b, mod);
        }
        b = mulmod_i64_i64_i64(b, b, mod);
        e = FLOW_CHECKED_DIV((e), (2));
    }
    return result;
}

bool is_prime_i64(int64_t n) {
    if (n < 2) {
        return 0;
    }
    if (n < 4) {
        return 1;
    }
    if ((FLOW_CHECKED_MOD((n), (2)) == 0 || FLOW_CHECKED_MOD((n), (3)) == 0)) {
        return 0;
    }
    int64_t i = 5;
    while ((i * i) <= n) {
        if ((FLOW_CHECKED_MOD((n), (i)) == 0 || FLOW_CHECKED_MOD((n), ((i + 2))) == 0)) {
            return 0;
        }
        i = (i + 6);
    }
    return 1;
}




int64_t pack_state_i64_i64_i64_i64_i64_i64_i64(int64_t v_prev, int64_t inT, int64_t contT, int64_t valT, int64_t inB, int64_t contB, int64_t valB) {
    return (((((((v_prev * 1000000) + (inT * 100000)) + (contT * 10000)) + (valT * 1000)) + (inB * 100)) + (contB * 10)) + valB);
}

int64_t unpack_v_prev_i64(int64_t s) {
    return FLOW_CHECKED_DIV((s), (1000000));
}

int64_t unpack_inT_i64(int64_t s) {
    return FLOW_CHECKED_MOD((FLOW_CHECKED_DIV((s), (100000))), (10));
}

int64_t unpack_contT_i64(int64_t s) {
    return FLOW_CHECKED_MOD((FLOW_CHECKED_DIV((s), (10000))), (10));
}

int64_t unpack_valT_i64(int64_t s) {
    return FLOW_CHECKED_MOD((FLOW_CHECKED_DIV((s), (1000))), (10));
}

int64_t unpack_inB_i64(int64_t s) {
    return FLOW_CHECKED_MOD((FLOW_CHECKED_DIV((s), (100))), (10));
}

int64_t unpack_contB_i64(int64_t s) {
    return FLOW_CHECKED_MOD((FLOW_CHECKED_DIV((s), (10))), (10));
}

int64_t unpack_valB_i64(int64_t s) {
    return FLOW_CHECKED_MOD((s), (10));
}

int64_t build_automaton_ptr_i64_ptr_i64_ptr_i64_ptr_i64(int64_t* state_arr, int64_t* adj_idx, int64_t* adj_val, int64_t* adj_w) {
    int64_t init = pack_state_i64_i64_i64_i64_i64_i64_i64(1, 0, 0, NONE, 0, 0, NONE);
    state_arr[0] = init;
    int64_t n_states = 1;
    int64_t head = 0;
    int64_t n_edges = 0;
    int64_t* trans_states = (int64_t*)(calloc(200, 8));
    int64_t* trans_weights = (int64_t*)(calloc(200, 8));
    while (head < n_states) {
        int64_t s = state_arr[head];
        int64_t v_prev = unpack_v_prev_i64(s);
        int64_t inT = unpack_inT_i64(s);
        int64_t contT = unpack_contT_i64(s);
        int64_t valT = unpack_valT_i64(s);
        int64_t inB = unpack_inB_i64(s);
        int64_t contB = unpack_contB_i64(s);
        int64_t valB = unpack_valB_i64(s);
        int64_t n_trans = 0;
        int64_t cT = valT;
        int64_t cB = valB;
        int64_t nextT_in;
        int64_t nextT_cont;
        int64_t nextT_val;
        if (inT != 0) {
            if (contT != 0) {
                nextT_in = 1;
                nextT_cont = 0;
                nextT_val = valT;
            } else {
                nextT_in = 0;
                nextT_cont = 0;
                nextT_val = valT;
            }
        } else {
            nextT_in = (-1);
            nextT_cont = (-1);
            nextT_val = (-1);
        }
        int64_t nextB_in;
        int64_t nextB_cont;
        int64_t nextB_val;
        if (inB != 0) {
            if (contB != 0) {
                nextB_in = 1;
                nextB_cont = 0;
                nextB_val = valB;
            } else {
                nextB_in = 0;
                nextB_cont = 0;
                nextB_val = valB;
            }
        } else {
            nextB_in = (-1);
            nextB_cont = (-1);
            nextB_val = (-1);
        }
        int64_t leftT = valT;
        int64_t leftB = valB;
        if ((inT != 0 && inB != 0)) {
            if (cT != cB) {
                int64_t ns = pack_state_i64_i64_i64_i64_i64_i64_i64(0, nextT_in, nextT_cont, nextT_val, nextB_in, nextB_cont, nextB_val);
                trans_states[n_trans] = ns;
                trans_weights[n_trans] = 1;
                n_trans = (n_trans + 1);
            }
        } else {
            if ((inT != 0 && inB == 0)) {
                int32_t __flow_step_1 = 1;
                for (int32_t L = 1; (1 <= 4) ? L < 4 : L > 4; L += (1 <= 4) ? 1 : -1) {
                    int32_t __flow_step_2 = 1;
                    for (int32_t col = 0; (0 <= COLORS) ? col < COLORS : col > COLORS; col += (0 <= COLORS) ? 1 : -1) {
                        if ((leftB != NONE && col == leftB)) {
                            continue;
                        }
                        if (col == cT) {
                            continue;
                        }
                        int64_t bs_in;
                        int64_t bs_cont;
                        if (L == 1) {
                            bs_in = 0;
                            bs_cont = 0;
                        } else {
                            if (L == 2) {
                                bs_in = 1;
                                bs_cont = 0;
                            } else {
                                bs_in = 1;
                                bs_cont = 1;
                            }
                        }
                        int64_t ns = pack_state_i64_i64_i64_i64_i64_i64_i64(0, nextT_in, nextT_cont, nextT_val, bs_in, bs_cont, col);
                        trans_states[n_trans] = ns;
                        trans_weights[n_trans] = 1;
                        n_trans = (n_trans + 1);
                    }
                }
            } else {
                if ((inT == 0 && inB != 0)) {
                    int32_t __flow_step_3 = 1;
                    for (int32_t L = 1; (1 <= 4) ? L < 4 : L > 4; L += (1 <= 4) ? 1 : -1) {
                        int32_t __flow_step_4 = 1;
                        for (int32_t col = 0; (0 <= COLORS) ? col < COLORS : col > COLORS; col += (0 <= COLORS) ? 1 : -1) {
                            if ((leftT != NONE && col == leftT)) {
                                continue;
                            }
                            if (col == cB) {
                                continue;
                            }
                            int64_t ts_in;
                            int64_t ts_cont;
                            if (L == 1) {
                                ts_in = 0;
                                ts_cont = 0;
                            } else {
                                if (L == 2) {
                                    ts_in = 1;
                                    ts_cont = 0;
                                } else {
                                    ts_in = 1;
                                    ts_cont = 1;
                                }
                            }
                            int64_t ns = pack_state_i64_i64_i64_i64_i64_i64_i64(0, ts_in, ts_cont, col, nextB_in, nextB_cont, nextB_val);
                            trans_states[n_trans] = ns;
                            trans_weights[n_trans] = 1;
                            n_trans = (n_trans + 1);
                        }
                    }
                } else {
                    int32_t __flow_step_5 = 1;
                    for (int32_t col = 0; (0 <= COLORS) ? col < COLORS : col > COLORS; col += (0 <= COLORS) ? 1 : -1) {
                        if ((leftT != NONE && col == leftT)) {
                            continue;
                        }
                        if ((leftB != NONE && col == leftB)) {
                            continue;
                        }
                        int64_t ns = pack_state_i64_i64_i64_i64_i64_i64_i64(1, 0, 0, col, 0, 0, col);
                        trans_states[n_trans] = ns;
                        trans_weights[n_trans] = 1;
                        n_trans = (n_trans + 1);
                    }
                    int32_t __flow_step_6 = 1;
                    for (int32_t Lt = 1; (1 <= 4) ? Lt < 4 : Lt > 4; Lt += (1 <= 4) ? 1 : -1) {
                        int32_t __flow_step_7 = 1;
                        for (int32_t Lb = 1; (1 <= 4) ? Lb < 4 : Lb > 4; Lb += (1 <= 4) ? 1 : -1) {
                            int32_t __flow_step_8 = 1;
                            for (int32_t ct = 0; (0 <= COLORS) ? ct < COLORS : ct > COLORS; ct += (0 <= COLORS) ? 1 : -1) {
                                if ((leftT != NONE && ct == leftT)) {
                                    continue;
                                }
                                int32_t __flow_step_9 = 1;
                                for (int32_t cb = 0; (0 <= COLORS) ? cb < COLORS : cb > COLORS; cb += (0 <= COLORS) ? 1 : -1) {
                                    if ((leftB != NONE && cb == leftB)) {
                                        continue;
                                    }
                                    if (ct == cb) {
                                        continue;
                                    }
                                    int64_t ts_in;
                                    int64_t ts_cont;
                                    if (Lt == 1) {
                                        ts_in = 0;
                                        ts_cont = 0;
                                    } else {
                                        if (Lt == 2) {
                                            ts_in = 1;
                                            ts_cont = 0;
                                        } else {
                                            ts_in = 1;
                                            ts_cont = 1;
                                        }
                                    }
                                    int64_t bs_in;
                                    int64_t bs_cont;
                                    if (Lb == 1) {
                                        bs_in = 0;
                                        bs_cont = 0;
                                    } else {
                                        if (Lb == 2) {
                                            bs_in = 1;
                                            bs_cont = 0;
                                        } else {
                                            bs_in = 1;
                                            bs_cont = 1;
                                        }
                                    }
                                    if (v_prev == 0) {
                                        continue;
                                    }
                                    int64_t ns = pack_state_i64_i64_i64_i64_i64_i64_i64(0, ts_in, ts_cont, ct, bs_in, bs_cont, cb);
                                    trans_states[n_trans] = ns;
                                    trans_weights[n_trans] = 1;
                                    n_trans = (n_trans + 1);
                                }
                            }
                        }
                    }
                }
            }
        }
        int64_t merged_n = 0;
        int32_t __flow_step_10 = 1;
        for (int32_t ti = 0; (0 <= n_trans) ? ti < n_trans : ti > n_trans; ti += (0 <= n_trans) ? 1 : -1) {
            int64_t found = (-1);
            int32_t __flow_step_11 = 1;
            for (int32_t mi = 0; (0 <= merged_n) ? mi < merged_n : mi > merged_n; mi += (0 <= merged_n) ? 1 : -1) {
                if (trans_states[mi] == trans_states[ti]) {
                    trans_weights[mi] = FLOW_CHECKED_MOD(((trans_weights[mi] + trans_weights[ti])), (MOD));
                    found = 1;
                }
            }
            if (found == (-1)) {
                trans_states[merged_n] = trans_states[ti];
                trans_weights[merged_n] = trans_weights[ti];
                merged_n = (merged_n + 1);
            }
        }
        adj_idx[head] = n_edges;
        int32_t __flow_step_12 = 1;
        for (int32_t ti = 0; (0 <= merged_n) ? ti < merged_n : ti > merged_n; ti += (0 <= merged_n) ? 1 : -1) {
            int64_t ns = trans_states[ti];
            int64_t found = (-1);
            int32_t __flow_step_13 = 1;
            for (int32_t si = 0; (0 <= n_states) ? si < n_states : si > n_states; si += (0 <= n_states) ? 1 : -1) {
                if (state_arr[si] == ns) {
                    found = si;
                }
            }
            if (found == (-1)) {
                state_arr[n_states] = ns;
                found = n_states;
                n_states = (n_states + 1);
            }
            adj_val[n_edges] = found;
            adj_w[n_edges] = trans_weights[ti];
            n_edges = (n_edges + 1);
        }
        head = (head + 1);
    }
    adj_idx[n_states] = n_edges;
    free(trans_weights);
    free(trans_states);
    return n_states;
}

int32_t main(void) {
    int64_t* state_arr = (int64_t*)(calloc(MAX_STATES, 8));
    int64_t* adj_idx = (int64_t*)(calloc((MAX_STATES + 1), 8));
    int64_t* adj_val = (int64_t*)(calloc((MAX_STATES * 200), 8));
    int64_t* adj_w = (int64_t*)(calloc((MAX_STATES * 200), 8));
    int64_t S = build_automaton_ptr_i64_ptr_i64_ptr_i64_ptr_i64(state_arr, adj_idx, adj_val, adj_w);
    int64_t* T = (int64_t*)(calloc((S * S), 8));
    int32_t __flow_step_14 = 1;
    for (int32_t i = 0; (0 <= S) ? i < S : i > S; i += (0 <= S) ? 1 : -1) {
        int32_t __flow_step_15 = 1;
        for (int32_t ei = adj_idx[i]; (adj_idx[i] <= adj_idx[(i + 1)]) ? ei < adj_idx[(i + 1)] : ei > adj_idx[(i + 1)]; ei += (adj_idx[i] <= adj_idx[(i + 1)]) ? 1 : -1) {
            int64_t j = adj_val[ei];
            T[((i * S) + j)] = adj_w[ei];
        }
    }
    int64_t* v0 = (int64_t*)(calloc(S, 8));
    v0[0] = 1;
    int64_t n = 10000000000000000;
    int64_t* vcur = (int64_t*)(calloc(S, 8));
    int32_t __flow_step_16 = 1;
    for (int32_t i = 0; (0 <= S) ? i < S : i > S; i += (0 <= S) ? 1 : -1) {
        vcur[i] = v0[i];
    }
    int64_t* power = (int64_t*)(calloc((S * S), 8));
    int32_t __flow_step_17 = 1;
    for (int32_t i = 0; (0 <= (S * S)) ? i < (S * S) : i > (S * S); i += (0 <= (S * S)) ? 1 : -1) {
        power[i] = T[i];
    }
    int64_t* tmp_vcur = (int64_t*)(calloc(S, 8));
    int64_t* tmp_mat = (int64_t*)(calloc((S * S), 8));
    int64_t e = n;
    while (e > 0) {
        if ((e & 1 == 1)) {
            int32_t __flow_step_18 = 1;
            for (int32_t i = 0; (0 <= S) ? i < S : i > S; i += (0 <= S) ? 1 : -1) {
                tmp_vcur[i] = 0;
            }
            int32_t __flow_step_19 = 1;
            for (int32_t i = 0; (0 <= S) ? i < S : i > S; i += (0 <= S) ? 1 : -1) {
                if (vcur[i] == 0) {
                    continue;
                }
                int32_t __flow_step_20 = 1;
                for (int32_t j = 0; (0 <= S) ? j < S : j > S; j += (0 <= S) ? 1 : -1) {
                    tmp_vcur[j] = FLOW_CHECKED_MOD(((tmp_vcur[j] + (vcur[i] * power[((i * S) + j)]))), (MOD));
                }
            }
            int32_t __flow_step_21 = 1;
            for (int32_t i = 0; (0 <= S) ? i < S : i > S; i += (0 <= S) ? 1 : -1) {
                vcur[i] = tmp_vcur[i];
            }
        }
        e = FLOW_CHECKED_SHR((e), (1));
        if (e > 0) {
            int32_t __flow_step_22 = 1;
            for (int32_t i = 0; (0 <= (S * S)) ? i < (S * S) : i > (S * S); i += (0 <= (S * S)) ? 1 : -1) {
                tmp_mat[i] = 0;
            }
            int32_t __flow_step_23 = 1;
            for (int32_t i = 0; (0 <= S) ? i < S : i > S; i += (0 <= S) ? 1 : -1) {
                int32_t __flow_step_24 = 1;
                for (int32_t k = 0; (0 <= S) ? k < S : k > S; k += (0 <= S) ? 1 : -1) {
                    if (power[((i * S) + k)] == 0) {
                        continue;
                    }
                    int32_t __flow_step_25 = 1;
                    for (int32_t j = 0; (0 <= S) ? j < S : j > S; j += (0 <= S) ? 1 : -1) {
                        tmp_mat[((i * S) + j)] = FLOW_CHECKED_MOD(((tmp_mat[((i * S) + j)] + (power[((i * S) + k)] * power[((k * S) + j)]))), (MOD));
                    }
                }
            }
            int32_t __flow_step_26 = 1;
            for (int32_t i = 0; (0 <= (S * S)) ? i < (S * S) : i > (S * S); i += (0 <= (S * S)) ? 1 : -1) {
                power[i] = tmp_mat[i];
            }
        }
    }
    int64_t ans = 0;
    int32_t __flow_step_27 = 1;
    for (int32_t i = 0; (0 <= S) ? i < S : i > S; i += (0 <= S) ? 1 : -1) {
        int64_t inT = unpack_inT_i64(state_arr[i]);
        int64_t inB = unpack_inB_i64(state_arr[i]);
        if ((inT == 0 && inB == 0)) {
            ans = FLOW_CHECKED_MOD(((ans + vcur[i])), (MOD));
        }
    }
    printf("%lld\n", ans);
    free(tmp_mat);
    free(tmp_vcur);
    free(power);
    free(vcur);
    free(v0);
    free(T);
    free(adj_w);
    free(adj_val);
    free(adj_idx);
    free(state_arr);
    return 0;
}

Generated MLIR

module {
  llvm.func @printf(!llvm.ptr, ...) -> i32
  llvm.mlir.global internal constant @str_0("%lld\n\00") {addr_space = 0 : i32} : !llvm.array<6 x i8>
  func.func @gcd(%arg0: i64, %arg1: i64) -> i64 {
    %0 = llvm.mlir.constant(1 : i64) : i64
    %1 = llvm.alloca %0 x i64 : (i64) -> !llvm.ptr
    llvm.store %arg0, %1 : i64, !llvm.ptr
    %2 = llvm.mlir.constant(1 : i64) : i64
    %3 = llvm.alloca %2 x i64 : (i64) -> !llvm.ptr
    llvm.store %arg1, %3 : i64, !llvm.ptr
    cf.br ^bb0
    ^bb0:
    %4 = llvm.load %3 : !llvm.ptr -> i64
    %5 = arith.constant 0 : i32
    %7 = arith.extsi %5 : i32 to i64
    %6 = arith.cmpi ne, %4, %7 : i64
    cf.cond_br %6, ^bb1, ^bb2
    ^bb1:
      %8 = llvm.load %1 : !llvm.ptr -> i64
      %9 = llvm.load %3 : !llvm.ptr -> i64
      %10 = arith.remsi %8, %9 : i64
      %11 = llvm.load %3 : !llvm.ptr -> i64
      llvm.store %11, %1 : i64, !llvm.ptr
      llvm.store %10, %3 : i64, !llvm.ptr
      cf.br ^bb0
    ^bb2:
    %12 = llvm.load %1 : !llvm.ptr -> i64
    func.return %12 : i64
  }
  func.func @lcm(%arg0: i64, %arg1: i64) -> i64 {
    %13 = arith.constant 0 : i32
    %15 = arith.extsi %13 : i32 to i64
    %14 = arith.cmpi eq, %arg0, %15 : i64
    %16 = scf.if %14 -> (i1) {
      %17 = arith.constant true
      scf.yield %17 : i1
    } else {
      %18 = arith.constant 0 : i32
      %20 = arith.extsi %18 : i32 to i64
      %19 = arith.cmpi eq, %arg1, %20 : i64
      scf.yield %19 : i1
    }
    cf.cond_br %16, ^bb3, ^bb4
    ^bb3:
      %21 = arith.constant 0 : i32
      %22 = arith.extsi %21 : i32 to i64
      func.return %22 : i64
    ^bb4:
      cf.br ^bb5
    ^bb5:
    %23 = func.call @gcd(%arg0, %arg1) : (i64, i64) -> i64
    %24 = arith.divsi %arg0, %23 : i64
    %25 = arith.muli %24, %arg1 : i64
    func.return %25 : i64
  }
  func.func @isqrt(%arg0: i64) -> i64 {
    %26 = arith.constant 2 : i32
    %28 = arith.extsi %26 : i32 to i64
    %27 = arith.cmpi slt, %arg0, %28 : i64
    cf.cond_br %27, ^bb6, ^bb7
    ^bb6:
      func.return %arg0 : i64
    ^bb7:
      cf.br ^bb8
    ^bb8:
    %29 = llvm.mlir.constant(1 : i64) : i64
    %30 = llvm.alloca %29 x i64 : (i64) -> !llvm.ptr
    llvm.store %arg0, %30 : i64, !llvm.ptr
    %31 = llvm.load %30 : !llvm.ptr -> i64
    %32 = arith.constant 1 : i32
    %34 = arith.extsi %32 : i32 to i64
    %33 = arith.addi %31, %34 : i64
    %35 = arith.constant 2 : i32
    %37 = arith.extsi %35 : i32 to i64
    %36 = arith.divsi %33, %37 : i64
    %38 = llvm.mlir.constant(1 : i64) : i64
    %39 = llvm.alloca %38 x i64 : (i64) -> !llvm.ptr
    llvm.store %36, %39 : i64, !llvm.ptr
    cf.br ^bb9
    ^bb9:
    %40 = llvm.load %39 : !llvm.ptr -> i64
    %41 = llvm.load %30 : !llvm.ptr -> i64
    %42 = arith.cmpi slt, %40, %41 : i64
    cf.cond_br %42, ^bb10, ^bb11
    ^bb10:
      %43 = llvm.load %39 : !llvm.ptr -> i64
      llvm.store %43, %30 : i64, !llvm.ptr
      %44 = llvm.load %30 : !llvm.ptr -> i64
      %45 = llvm.load %30 : !llvm.ptr -> i64
      %46 = arith.divsi %arg0, %45 : i64
      %47 = arith.addi %44, %46 : i64
      %48 = arith.constant 2 : i32
      %50 = arith.extsi %48 : i32 to i64
      %49 = arith.divsi %47, %50 : i64
      llvm.store %49, %39 : i64, !llvm.ptr
      cf.br ^bb9
    ^bb11:
    %51 = llvm.load %30 : !llvm.ptr -> i64
    func.return %51 : i64
  }
  func.func @mulmod(%arg0: i64, %arg1: i64, %arg2: i64) -> i64 {
    %52 = arith.remsi %arg0, %arg2 : i64
    %53 = llvm.mlir.constant(1 : i64) : i64
    %54 = llvm.alloca %53 x i64 : (i64) -> !llvm.ptr
    llvm.store %52, %54 : i64, !llvm.ptr
    %55 = arith.remsi %arg1, %arg2 : i64
    %56 = llvm.mlir.constant(1 : i64) : i64
    %57 = llvm.alloca %56 x i64 : (i64) -> !llvm.ptr
    llvm.store %55, %57 : i64, !llvm.ptr
    %58 = arith.constant 0 : i32
    %59 = arith.extsi %58 : i32 to i64
    %60 = llvm.mlir.constant(1 : i64) : i64
    %61 = llvm.alloca %60 x i64 : (i64) -> !llvm.ptr
    llvm.store %59, %61 : i64, !llvm.ptr
    cf.br ^bb12
    ^bb12:
    %62 = llvm.load %57 : !llvm.ptr -> i64
    %63 = arith.constant 0 : i32
    %65 = arith.extsi %63 : i32 to i64
    %64 = arith.cmpi sgt, %62, %65 : i64
    cf.cond_br %64, ^bb13, ^bb14
    ^bb13:
      %66 = llvm.load %57 : !llvm.ptr -> i64
      %67 = arith.constant 2 : i32
      %69 = arith.extsi %67 : i32 to i64
      %68 = arith.remsi %66, %69 : i64
      %70 = arith.constant 1 : i32
      %72 = arith.extsi %70 : i32 to i64
      %71 = arith.cmpi eq, %68, %72 : i64
      cf.cond_br %71, ^bb15, ^bb16
      ^bb15:
        %73 = llvm.load %61 : !llvm.ptr -> i64
        %74 = llvm.load %54 : !llvm.ptr -> i64
        %75 = arith.addi %73, %74 : i64
        %76 = arith.remsi %75, %arg2 : i64
        llvm.store %76, %61 : i64, !llvm.ptr
        cf.br ^bb17
      ^bb16:
        cf.br ^bb17
      ^bb17:
      %77 = llvm.load %54 : !llvm.ptr -> i64
      %78 = arith.constant 2 : i32
      %80 = arith.extsi %78 : i32 to i64
      %79 = arith.muli %77, %80 : i64
      %81 = arith.remsi %79, %arg2 : i64
      llvm.store %81, %54 : i64, !llvm.ptr
      %82 = llvm.load %57 : !llvm.ptr -> i64
      %83 = arith.constant 2 : i32
      %85 = arith.extsi %83 : i32 to i64
      %84 = arith.divsi %82, %85 : i64
      llvm.store %84, %57 : i64, !llvm.ptr
      cf.br ^bb12
    ^bb14:
    %86 = llvm.load %61 : !llvm.ptr -> i64
    func.return %86 : i64
  }
  func.func @mod_pow(%arg0: i64, %arg1: i64, %arg2: i64) -> i64 {
    %87 = arith.constant 1 : i32
    %89 = arith.extsi %87 : i32 to i64
    %88 = arith.cmpi eq, %arg2, %89 : i64
    cf.cond_br %88, ^bb18, ^bb19
    ^bb18:
      %90 = arith.constant 0 : i32
      %91 = arith.extsi %90 : i32 to i64
      func.return %91 : i64
    ^bb19:
      cf.br ^bb20
    ^bb20:
    %92 = arith.constant 1 : i32
    %93 = arith.extsi %92 : i32 to 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.remsi %arg0, %arg2 : i64
    %97 = llvm.mlir.constant(1 : i64) : i64
    %98 = llvm.alloca %97 x i64 : (i64) -> !llvm.ptr
    llvm.store %96, %98 : i64, !llvm.ptr
    %99 = llvm.mlir.constant(1 : i64) : i64
    %100 = llvm.alloca %99 x i64 : (i64) -> !llvm.ptr
    llvm.store %arg1, %100 : i64, !llvm.ptr
    cf.br ^bb21
    ^bb21:
    %101 = llvm.load %100 : !llvm.ptr -> i64
    %102 = arith.constant 0 : i32
    %104 = arith.extsi %102 : i32 to i64
    %103 = arith.cmpi sgt, %101, %104 : i64
    cf.cond_br %103, ^bb22, ^bb23
    ^bb22:
      %105 = llvm.load %100 : !llvm.ptr -> i64
      %106 = arith.constant 2 : i32
      %108 = arith.extsi %106 : i32 to i64
      %107 = arith.remsi %105, %108 : i64
      %109 = arith.constant 1 : i32
      %111 = arith.extsi %109 : i32 to i64
      %110 = arith.cmpi eq, %107, %111 : i64
      cf.cond_br %110, ^bb24, ^bb25
      ^bb24:
        %113 = llvm.load %95 : !llvm.ptr -> i64
        %114 = llvm.load %98 : !llvm.ptr -> i64
        %112 = func.call @mulmod(%113, %114, %arg2) : (i64, i64, i64) -> i64
        llvm.store %112, %95 : i64, !llvm.ptr
        cf.br ^bb26
      ^bb25:
        cf.br ^bb26
      ^bb26:
      %116 = llvm.load %98 : !llvm.ptr -> i64
      %117 = llvm.load %98 : !llvm.ptr -> i64
      %115 = func.call @mulmod(%116, %117, %arg2) : (i64, i64, i64) -> i64
      llvm.store %115, %98 : i64, !llvm.ptr
      %118 = llvm.load %100 : !llvm.ptr -> i64
      %119 = arith.constant 2 : i32
      %121 = arith.extsi %119 : i32 to i64
      %120 = arith.divsi %118, %121 : i64
      llvm.store %120, %100 : i64, !llvm.ptr
      cf.br ^bb21
    ^bb23:
    %122 = llvm.load %95 : !llvm.ptr -> i64
    func.return %122 : i64
  }
  func.func @is_prime(%arg0: i64) -> i1 {
    %123 = arith.constant 2 : i32
    %125 = arith.extsi %123 : i32 to i64
    %124 = arith.cmpi slt, %arg0, %125 : i64
    cf.cond_br %124, ^bb27, ^bb28
    ^bb27:
      %126 = arith.constant 0 : i1
      func.return %126 : i1
    ^bb28:
      cf.br ^bb29
    ^bb29:
    %127 = arith.constant 4 : i32
    %129 = arith.extsi %127 : i32 to i64
    %128 = arith.cmpi slt, %arg0, %129 : i64
    cf.cond_br %128, ^bb30, ^bb31
    ^bb30:
      %130 = arith.constant 1 : i1
      func.return %130 : i1
    ^bb31:
      cf.br ^bb32
    ^bb32:
    %131 = arith.constant 2 : i32
    %133 = arith.extsi %131 : i32 to i64
    %132 = arith.remsi %arg0, %133 : i64
    %134 = arith.constant 0 : i32
    %136 = arith.extsi %134 : i32 to i64
    %135 = arith.cmpi eq, %132, %136 : i64
    %137 = scf.if %135 -> (i1) {
      %138 = arith.constant true
      scf.yield %138 : i1
    } else {
      %139 = arith.constant 3 : i32
      %141 = arith.extsi %139 : i32 to i64
      %140 = arith.remsi %arg0, %141 : i64
      %142 = arith.constant 0 : i32
      %144 = arith.extsi %142 : i32 to i64
      %143 = arith.cmpi eq, %140, %144 : i64
      scf.yield %143 : i1
    }
    cf.cond_br %137, ^bb33, ^bb34
    ^bb33:
      %145 = arith.constant 0 : i1
      func.return %145 : i1
    ^bb34:
      cf.br ^bb35
    ^bb35:
    %146 = arith.constant 5 : i32
    %147 = arith.extsi %146 : i32 to i64
    %148 = llvm.mlir.constant(1 : i64) : i64
    %149 = llvm.alloca %148 x i64 : (i64) -> !llvm.ptr
    llvm.store %147, %149 : i64, !llvm.ptr
    cf.br ^bb36
    ^bb36:
    %150 = llvm.load %149 : !llvm.ptr -> i64
    %151 = llvm.load %149 : !llvm.ptr -> i64
    %152 = arith.muli %150, %151 : i64
    %153 = arith.cmpi sle, %152, %arg0 : i64
    cf.cond_br %153, ^bb37, ^bb38
    ^bb37:
      %154 = llvm.load %149 : !llvm.ptr -> i64
      %155 = arith.remsi %arg0, %154 : i64
      %156 = arith.constant 0 : i32
      %158 = arith.extsi %156 : i32 to i64
      %157 = arith.cmpi eq, %155, %158 : i64
      %159 = scf.if %157 -> (i1) {
        %160 = arith.constant true
        scf.yield %160 : i1
      } else {
        %161 = llvm.load %149 : !llvm.ptr -> i64
        %162 = arith.constant 2 : i32
        %164 = arith.extsi %162 : i32 to i64
        %163 = arith.addi %161, %164 : i64
        %165 = arith.remsi %arg0, %163 : i64
        %166 = arith.constant 0 : i32
        %168 = arith.extsi %166 : i32 to i64
        %167 = arith.cmpi eq, %165, %168 : i64
        scf.yield %167 : i1
      }
      cf.cond_br %159, ^bb39, ^bb40
      ^bb39:
        %169 = arith.constant 0 : i1
        func.return %169 : i1
      ^bb40:
        cf.br ^bb41
      ^bb41:
      %170 = llvm.load %149 : !llvm.ptr -> i64
      %171 = arith.constant 6 : i32
      %173 = arith.extsi %171 : i32 to i64
      %172 = arith.addi %170, %173 : i64
      llvm.store %172, %149 : i64, !llvm.ptr
      cf.br ^bb36
    ^bb38:
    %174 = arith.constant 1 : i1
    func.return %174 : i1
  }
  func.func private @calloc(i64, i64) -> !llvm.ptr
  func.func private @free(!llvm.ptr) -> ()
  func.func private @memset(!llvm.ptr, i64, i64) -> !llvm.ptr
  // Constant: MOD
  llvm.mlir.global internal constant @MOD(1000004321 : i64) : i64
  // Constant: COLORS
  llvm.mlir.global internal constant @COLORS(4 : i64) : i64
  // Constant: NONE
  llvm.mlir.global internal constant @NONE(4 : i64) : i64
  func.func @pack_state(%arg0: i64, %arg1: i64, %arg2: i64, %arg3: i64, %arg4: i64, %arg5: i64, %arg6: i64) -> i64 {
    %175 = arith.constant 1000000 : i32
    %177 = arith.extsi %175 : i32 to i64
    %176 = arith.muli %arg0, %177 : i64
    %178 = arith.constant 100000 : i32
    %180 = arith.extsi %178 : i32 to i64
    %179 = arith.muli %arg1, %180 : i64
    %181 = arith.addi %176, %179 : i64
    %182 = arith.constant 10000 : i32
    %184 = arith.extsi %182 : i32 to i64
    %183 = arith.muli %arg2, %184 : i64
    %185 = arith.addi %181, %183 : i64
    %186 = arith.constant 1000 : i32
    %188 = arith.extsi %186 : i32 to i64
    %187 = arith.muli %arg3, %188 : i64
    %189 = arith.addi %185, %187 : i64
    %190 = arith.constant 100 : i32
    %192 = arith.extsi %190 : i32 to i64
    %191 = arith.muli %arg4, %192 : i64
    %193 = arith.addi %189, %191 : i64
    %194 = arith.constant 10 : i32
    %196 = arith.extsi %194 : i32 to i64
    %195 = arith.muli %arg5, %196 : i64
    %197 = arith.addi %193, %195 : i64
    %198 = arith.addi %197, %arg6 : i64
    func.return %198 : i64
  }
  func.func @unpack_v_prev(%arg0: i64) -> i64 {
    %199 = arith.constant 1000000 : i32
    %201 = arith.extsi %199 : i32 to i64
    %200 = arith.divsi %arg0, %201 : i64
    func.return %200 : i64
  }
  func.func @unpack_inT(%arg0: i64) -> i64 {
    %202 = arith.constant 100000 : i32
    %204 = arith.extsi %202 : i32 to i64
    %203 = arith.divsi %arg0, %204 : i64
    %205 = arith.constant 10 : i32
    %207 = arith.extsi %205 : i32 to i64
    %206 = arith.remsi %203, %207 : i64
    func.return %206 : i64
  }
  func.func @unpack_contT(%arg0: i64) -> i64 {
    %208 = arith.constant 10000 : i32
    %210 = arith.extsi %208 : i32 to i64
    %209 = arith.divsi %arg0, %210 : i64
    %211 = arith.constant 10 : i32
    %213 = arith.extsi %211 : i32 to i64
    %212 = arith.remsi %209, %213 : i64
    func.return %212 : i64
  }
  func.func @unpack_valT(%arg0: i64) -> i64 {
    %214 = arith.constant 1000 : i32
    %216 = arith.extsi %214 : i32 to i64
    %215 = arith.divsi %arg0, %216 : i64
    %217 = arith.constant 10 : i32
    %219 = arith.extsi %217 : i32 to i64
    %218 = arith.remsi %215, %219 : i64
    func.return %218 : i64
  }
  func.func @unpack_inB(%arg0: i64) -> i64 {
    %220 = arith.constant 100 : i32
    %222 = arith.extsi %220 : i32 to i64
    %221 = arith.divsi %arg0, %222 : i64
    %223 = arith.constant 10 : i32
    %225 = arith.extsi %223 : i32 to i64
    %224 = arith.remsi %221, %225 : i64
    func.return %224 : i64
  }
  func.func @unpack_contB(%arg0: i64) -> i64 {
    %226 = arith.constant 10 : i32
    %228 = arith.extsi %226 : i32 to i64
    %227 = arith.divsi %arg0, %228 : i64
    %229 = arith.constant 10 : i32
    %231 = arith.extsi %229 : i32 to i64
    %230 = arith.remsi %227, %231 : i64
    func.return %230 : i64
  }
  func.func @unpack_valB(%arg0: i64) -> i64 {
    %232 = arith.constant 10 : i32
    %234 = arith.extsi %232 : i32 to i64
    %233 = arith.remsi %arg0, %234 : i64
    func.return %233 : i64
  }
  // Constant: MAX_STATES
  llvm.mlir.global internal constant @MAX_STATES(2000 : i64) : i64
  func.func @build_automaton(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: !llvm.ptr, %arg3: !llvm.ptr) -> i64 {
    %236 = arith.constant 1 : i32
    %237 = arith.constant 0 : i32
    %238 = arith.constant 0 : i32
    %239 = llvm.mlir.addressof @NONE : !llvm.ptr
    %240 = llvm.load %239 : !llvm.ptr -> i64
    %241 = arith.constant 0 : i32
    %242 = arith.constant 0 : i32
    %243 = llvm.mlir.addressof @NONE : !llvm.ptr
    %244 = llvm.load %243 : !llvm.ptr -> i64
    %245 = arith.extsi %236 : i32 to i64
    %246 = arith.extsi %237 : i32 to i64
    %247 = arith.extsi %238 : i32 to i64
    %248 = arith.extsi %241 : i32 to i64
    %249 = arith.extsi %242 : i32 to i64
    %235 = func.call @pack_state(%245, %246, %247, %240, %248, %249, %244) : (i64, i64, i64, i64, i64, i64, i64) -> i64
    %250 = arith.constant 0 : i32
    %251 = arith.extsi %250 : i32 to i64
    %252 = llvm.getelementptr %arg0[%251] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    llvm.store %235, %252 : i64, !llvm.ptr
    %253 = arith.constant 1 : i32
    %254 = arith.extsi %253 : i32 to i64
    %255 = llvm.mlir.constant(1 : i64) : i64
    %256 = llvm.alloca %255 x i64 : (i64) -> !llvm.ptr
    llvm.store %254, %256 : i64, !llvm.ptr
    %257 = arith.constant 0 : i32
    %258 = arith.extsi %257 : i32 to i64
    %259 = llvm.mlir.constant(1 : i64) : i64
    %260 = llvm.alloca %259 x i64 : (i64) -> !llvm.ptr
    llvm.store %258, %260 : i64, !llvm.ptr
    %261 = arith.constant 0 : i32
    %262 = arith.extsi %261 : i32 to i64
    %263 = llvm.mlir.constant(1 : i64) : i64
    %264 = llvm.alloca %263 x i64 : (i64) -> !llvm.ptr
    llvm.store %262, %264 : i64, !llvm.ptr
    %266 = arith.constant 200 : i32
    %267 = arith.constant 8 : i32
    %268 = arith.extsi %266 : i32 to i64
    %269 = arith.extsi %267 : i32 to i64
    %265 = func.call @calloc(%268, %269) : (i64, i64) -> !llvm.ptr
    %271 = arith.constant 200 : i32
    %272 = arith.constant 8 : i32
    %273 = arith.extsi %271 : i32 to i64
    %274 = arith.extsi %272 : i32 to i64
    %270 = func.call @calloc(%273, %274) : (i64, i64) -> !llvm.ptr
    cf.br ^bb42
    ^bb42:
    %275 = llvm.load %260 : !llvm.ptr -> i64
    %276 = llvm.load %256 : !llvm.ptr -> i64
    %277 = arith.cmpi slt, %275, %276 : i64
    cf.cond_br %277, ^bb43, ^bb44
    ^bb43:
      %279 = llvm.load %260 : !llvm.ptr -> i64
      %280 = llvm.getelementptr %arg0[%279] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %278 = llvm.load %280 : !llvm.ptr -> i64
      %281 = func.call @unpack_v_prev(%278) : (i64) -> i64
      %282 = func.call @unpack_inT(%278) : (i64) -> i64
      %283 = func.call @unpack_contT(%278) : (i64) -> i64
      %284 = func.call @unpack_valT(%278) : (i64) -> i64
      %285 = func.call @unpack_inB(%278) : (i64) -> i64
      %286 = func.call @unpack_contB(%278) : (i64) -> i64
      %287 = func.call @unpack_valB(%278) : (i64) -> i64
      %288 = arith.constant 0 : i32
      %289 = arith.extsi %288 : i32 to i64
      %290 = llvm.mlir.constant(1 : i64) : i64
      %291 = llvm.alloca %290 x i64 : (i64) -> !llvm.ptr
      llvm.store %289, %291 : i64, !llvm.ptr
      %292 = llvm.mlir.undef : i64
      %293 = llvm.mlir.undef : i64
      %294 = llvm.mlir.undef : i64
      %295 = arith.constant 0 : i32
      %297 = arith.extsi %295 : i32 to i64
      %296 = arith.cmpi ne, %282, %297 : i64
      cf.cond_br %296, ^bb45, ^bb46
      ^bb45:
        %298 = arith.constant 0 : i32
        %300 = arith.extsi %298 : i32 to i64
        %299 = arith.cmpi ne, %283, %300 : i64
        %301, %302, %303 = scf.if %299 -> (i64, i64, i64) {
          %304 = arith.constant 1 : i32
          %305 = arith.extsi %304 : i32 to i64
          %306 = arith.constant 0 : i32
          %307 = arith.extsi %306 : i32 to i64
          scf.yield %305, %307, %284 : i64, i64, i64
        } else {
          %308 = arith.constant 0 : i32
          %309 = arith.extsi %308 : i32 to i64
          %310 = arith.constant 0 : i32
          %311 = arith.extsi %310 : i32 to i64
          scf.yield %309, %311, %284 : i64, i64, i64
        }
        cf.br ^bb47(%301, %302, %303 : i64, i64, i64)
      ^bb46:
        %312 = arith.constant 1 : i32
        %314 = arith.constant 0 : i32
        %313 = arith.subi %314, %312 : i32
        %315 = arith.extsi %313 : i32 to i64
        %316 = arith.constant 1 : i32
        %318 = arith.constant 0 : i32
        %317 = arith.subi %318, %316 : i32
        %319 = arith.extsi %317 : i32 to i64
        %320 = arith.constant 1 : i32
        %322 = arith.constant 0 : i32
        %321 = arith.subi %322, %320 : i32
        %323 = arith.extsi %321 : i32 to i64
        cf.br ^bb47(%315, %319, %323 : i64, i64, i64)
      ^bb47(%324: i64, %325: i64, %326: i64):
      %327 = llvm.mlir.undef : i64
      %328 = llvm.mlir.undef : i64
      %329 = llvm.mlir.undef : i64
      %330 = arith.constant 0 : i32
      %332 = arith.extsi %330 : i32 to i64
      %331 = arith.cmpi ne, %285, %332 : i64
      cf.cond_br %331, ^bb48, ^bb49
      ^bb48:
        %333 = arith.constant 0 : i32
        %335 = arith.extsi %333 : i32 to i64
        %334 = arith.cmpi ne, %286, %335 : i64
        %336, %337, %338 = scf.if %334 -> (i64, i64, i64) {
          %339 = arith.constant 1 : i32
          %340 = arith.extsi %339 : i32 to i64
          %341 = arith.constant 0 : i32
          %342 = arith.extsi %341 : i32 to i64
          scf.yield %340, %342, %287 : i64, i64, i64
        } else {
          %343 = arith.constant 0 : i32
          %344 = arith.extsi %343 : i32 to i64
          %345 = arith.constant 0 : i32
          %346 = arith.extsi %345 : i32 to i64
          scf.yield %344, %346, %287 : i64, i64, i64
        }
        cf.br ^bb50(%336, %337, %338 : i64, i64, i64)
      ^bb49:
        %347 = arith.constant 1 : i32
        %349 = arith.constant 0 : i32
        %348 = arith.subi %349, %347 : i32
        %350 = arith.extsi %348 : i32 to i64
        %351 = arith.constant 1 : i32
        %353 = arith.constant 0 : i32
        %352 = arith.subi %353, %351 : i32
        %354 = arith.extsi %352 : i32 to i64
        %355 = arith.constant 1 : i32
        %357 = arith.constant 0 : i32
        %356 = arith.subi %357, %355 : i32
        %358 = arith.extsi %356 : i32 to i64
        cf.br ^bb50(%350, %354, %358 : i64, i64, i64)
      ^bb50(%359: i64, %360: i64, %361: i64):
      %362 = arith.constant 0 : i32
      %364 = arith.extsi %362 : i32 to i64
      %363 = arith.cmpi ne, %282, %364 : i64
      %365 = scf.if %363 -> (i1) {
        %366 = arith.constant 0 : i32
        %368 = arith.extsi %366 : i32 to i64
        %367 = arith.cmpi ne, %285, %368 : i64
        scf.yield %367 : i1
      } else {
        %369 = arith.constant false
        scf.yield %369 : i1
      }
      cf.cond_br %365, ^bb51, ^bb52
      ^bb51:
        %370 = arith.cmpi ne, %284, %287 : i64
        cf.cond_br %370, ^bb54, ^bb55
        ^bb54:
          %372 = arith.constant 0 : i32
          %373 = arith.extsi %372 : i32 to i64
          %371 = func.call @pack_state(%373, %324, %325, %326, %359, %360, %361) : (i64, i64, i64, i64, i64, i64, i64) -> i64
          %374 = llvm.load %291 : !llvm.ptr -> i64
          %375 = llvm.getelementptr %265[%374] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          llvm.store %371, %375 : i64, !llvm.ptr
          %376 = arith.constant 1 : i32
          %377 = llvm.load %291 : !llvm.ptr -> i64
          %378 = arith.extsi %376 : i32 to i64
          %379 = llvm.getelementptr %270[%377] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          llvm.store %378, %379 : i64, !llvm.ptr
          %380 = llvm.load %291 : !llvm.ptr -> i64
          %381 = arith.constant 1 : i32
          %383 = arith.extsi %381 : i32 to i64
          %382 = arith.addi %380, %383 : i64
          llvm.store %382, %291 : i64, !llvm.ptr
          cf.br ^bb56
        ^bb55:
          cf.br ^bb56
        ^bb56:
        cf.br ^bb53
      ^bb52:
        %384 = arith.constant 0 : i32
        %386 = arith.extsi %384 : i32 to i64
        %385 = arith.cmpi ne, %282, %386 : i64
        %387 = scf.if %385 -> (i1) {
          %388 = arith.constant 0 : i32
          %390 = arith.extsi %388 : i32 to i64
          %389 = arith.cmpi eq, %285, %390 : i64
          scf.yield %389 : i1
        } else {
          %391 = arith.constant false
          scf.yield %391 : i1
        }
        cf.cond_br %387, ^bb57, ^bb58
        ^bb57:
          %392 = arith.constant 1 : i32
          %393 = arith.constant 4 : i32
          %394 = arith.index_cast %392 : i32 to index
          %395 = arith.index_cast %393 : i32 to index
          %397 = arith.constant 1 : index
          %398 = arith.constant -1 : index
          %399 = arith.cmpi sle, %394, %395 : index
          %396 = arith.select %399, %397, %398 : index
          cf.br ^bb60(%394 : index)
          ^bb60(%400: index):
          %401 = arith.cmpi slt, %400, %395 : index
          %402 = arith.cmpi sgt, %400, %395 : index
          %403 = arith.select %399, %401, %402 : i1
          cf.cond_br %403, ^bb61(%400 : index), ^bb62(%400 : index)
          ^bb61(%404: index):
            %405 = arith.constant 0 : i32
            %406 = llvm.mlir.addressof @COLORS : !llvm.ptr
            %407 = llvm.load %406 : !llvm.ptr -> i64
            %408 = arith.index_cast %405 : i32 to index
            %409 = arith.index_cast %407 : i32 to index
            %411 = arith.constant 1 : index
            %412 = arith.constant -1 : index
            %413 = arith.cmpi sle, %408, %409 : index
            %410 = arith.select %413, %411, %412 : index
            cf.br ^bb63(%408 : index)
            ^bb63(%414: index):
            %415 = arith.cmpi slt, %414, %409 : index
            %416 = arith.cmpi sgt, %414, %409 : index
            %417 = arith.select %413, %415, %416 : i1
            cf.cond_br %417, ^bb64(%414 : index), ^bb65(%414 : index)
            ^bb64(%418: index):
              %419 = llvm.mlir.addressof @NONE : !llvm.ptr
              %420 = llvm.load %419 : !llvm.ptr -> i64
              %421 = arith.cmpi ne, %287, %420 : i64
              %422 = scf.if %421 -> (i1) {
                %424 = arith.index_cast %418 : index to i32
                %425 = arith.trunci %287 : i64 to i32
                %423 = arith.cmpi eq, %424, %425 : i32
                scf.yield %423 : i1
              } else {
                %426 = arith.constant false
                scf.yield %426 : i1
              }
              cf.cond_br %422, ^bb66, ^bb67
              ^bb66:
                %427 = arith.addi %418, %410 : index
                cf.br ^bb63(%427 : index)
              ^bb67:
                cf.br ^bb68
              ^bb68:
              %429 = arith.index_cast %418 : index to i32
              %430 = arith.trunci %284 : i64 to i32
              %428 = arith.cmpi eq, %429, %430 : i32
              cf.cond_br %428, ^bb69, ^bb70
              ^bb69:
                %431 = arith.addi %418, %410 : index
                cf.br ^bb63(%431 : index)
              ^bb70:
                cf.br ^bb71
              ^bb71:
              %432 = llvm.mlir.undef : i64
              %433 = llvm.mlir.undef : i64
              %434 = arith.constant 1 : i32
              %436 = arith.index_cast %404 : index to i32
              %435 = arith.cmpi eq, %436, %434 : i32
              cf.cond_br %435, ^bb72, ^bb73
              ^bb72:
                %437 = arith.constant 0 : i32
                %438 = arith.extsi %437 : i32 to i64
                %439 = arith.constant 0 : i32
                %440 = arith.extsi %439 : i32 to i64
                cf.br ^bb74(%438, %440 : i64, i64)
              ^bb73:
                %441 = arith.constant 2 : i32
                %443 = arith.index_cast %404 : index to i32
                %442 = arith.cmpi eq, %443, %441 : i32
                %444, %445 = scf.if %442 -> (i64, i64) {
                  %446 = arith.constant 1 : i32
                  %447 = arith.extsi %446 : i32 to i64
                  %448 = arith.constant 0 : i32
                  %449 = arith.extsi %448 : i32 to i64
                  scf.yield %447, %449 : i64, i64
                } else {
                  %450 = arith.constant 1 : i32
                  %451 = arith.extsi %450 : i32 to i64
                  %452 = arith.constant 1 : i32
                  %453 = arith.extsi %452 : i32 to i64
                  scf.yield %451, %453 : i64, i64
                }
                cf.br ^bb74(%444, %445 : i64, i64)
              ^bb74(%454: i64, %455: i64):
              %457 = arith.constant 0 : i32
              %458 = arith.extsi %457 : i32 to i64
              %459 = arith.index_cast %418 : index to i64
              %456 = func.call @pack_state(%458, %324, %325, %326, %454, %455, %459) : (i64, i64, i64, i64, i64, i64, i64) -> i64
              %460 = llvm.load %291 : !llvm.ptr -> i64
              %461 = llvm.getelementptr %265[%460] : (!llvm.ptr, i64) -> !llvm.ptr, i64
              llvm.store %456, %461 : i64, !llvm.ptr
              %462 = arith.constant 1 : i32
              %463 = llvm.load %291 : !llvm.ptr -> i64
              %464 = arith.extsi %462 : i32 to i64
              %465 = llvm.getelementptr %270[%463] : (!llvm.ptr, i64) -> !llvm.ptr, i64
              llvm.store %464, %465 : i64, !llvm.ptr
              %466 = llvm.load %291 : !llvm.ptr -> i64
              %467 = arith.constant 1 : i32
              %469 = arith.extsi %467 : i32 to i64
              %468 = arith.addi %466, %469 : i64
              llvm.store %468, %291 : i64, !llvm.ptr
              %470 = arith.addi %418, %410 : index
              cf.br ^bb63(%470 : index)
            ^bb65(%471: index):
            %472 = arith.addi %404, %396 : index
            cf.br ^bb60(%472 : index)
          ^bb62(%473: index):
          cf.br ^bb59
        ^bb58:
          %474 = arith.constant 0 : i32
          %476 = arith.extsi %474 : i32 to i64
          %475 = arith.cmpi eq, %282, %476 : i64
          %477 = scf.if %475 -> (i1) {
            %478 = arith.constant 0 : i32
            %480 = arith.extsi %478 : i32 to i64
            %479 = arith.cmpi ne, %285, %480 : i64
            scf.yield %479 : i1
          } else {
            %481 = arith.constant false
            scf.yield %481 : i1
          }
          cf.cond_br %477, ^bb75, ^bb76
          ^bb75:
            %482 = arith.constant 1 : i32
            %483 = arith.constant 4 : i32
            %484 = arith.index_cast %482 : i32 to index
            %485 = arith.index_cast %483 : i32 to index
            %487 = arith.constant 1 : index
            %488 = arith.constant -1 : index
            %489 = arith.cmpi sle, %484, %485 : index
            %486 = arith.select %489, %487, %488 : index
            cf.br ^bb78(%484 : index)
            ^bb78(%490: index):
            %491 = arith.cmpi slt, %490, %485 : index
            %492 = arith.cmpi sgt, %490, %485 : index
            %493 = arith.select %489, %491, %492 : i1
            cf.cond_br %493, ^bb79(%490 : index), ^bb80(%490 : index)
            ^bb79(%494: index):
              %495 = arith.constant 0 : i32
              %496 = llvm.mlir.addressof @COLORS : !llvm.ptr
              %497 = llvm.load %496 : !llvm.ptr -> i64
              %498 = arith.index_cast %495 : i32 to index
              %499 = arith.index_cast %497 : i32 to index
              %501 = arith.constant 1 : index
              %502 = arith.constant -1 : index
              %503 = arith.cmpi sle, %498, %499 : index
              %500 = arith.select %503, %501, %502 : index
              cf.br ^bb81(%498 : index)
              ^bb81(%504: index):
              %505 = arith.cmpi slt, %504, %499 : index
              %506 = arith.cmpi sgt, %504, %499 : index
              %507 = arith.select %503, %505, %506 : i1
              cf.cond_br %507, ^bb82(%504 : index), ^bb83(%504 : index)
              ^bb82(%508: index):
                %509 = llvm.mlir.addressof @NONE : !llvm.ptr
                %510 = llvm.load %509 : !llvm.ptr -> i64
                %511 = arith.cmpi ne, %284, %510 : i64
                %512 = scf.if %511 -> (i1) {
                  %514 = arith.index_cast %508 : index to i32
                  %515 = arith.trunci %284 : i64 to i32
                  %513 = arith.cmpi eq, %514, %515 : i32
                  scf.yield %513 : i1
                } else {
                  %516 = arith.constant false
                  scf.yield %516 : i1
                }
                cf.cond_br %512, ^bb84, ^bb85
                ^bb84:
                  %517 = arith.addi %508, %500 : index
                  cf.br ^bb81(%517 : index)
                ^bb85:
                  cf.br ^bb86
                ^bb86:
                %519 = arith.index_cast %508 : index to i32
                %520 = arith.trunci %287 : i64 to i32
                %518 = arith.cmpi eq, %519, %520 : i32
                cf.cond_br %518, ^bb87, ^bb88
                ^bb87:
                  %521 = arith.addi %508, %500 : index
                  cf.br ^bb81(%521 : index)
                ^bb88:
                  cf.br ^bb89
                ^bb89:
                %522 = llvm.mlir.undef : i64
                %523 = llvm.mlir.undef : i64
                %524 = arith.constant 1 : i32
                %526 = arith.index_cast %494 : index to i32
                %525 = arith.cmpi eq, %526, %524 : i32
                cf.cond_br %525, ^bb90, ^bb91
                ^bb90:
                  %527 = arith.constant 0 : i32
                  %528 = arith.extsi %527 : i32 to i64
                  %529 = arith.constant 0 : i32
                  %530 = arith.extsi %529 : i32 to i64
                  cf.br ^bb92(%528, %530 : i64, i64)
                ^bb91:
                  %531 = arith.constant 2 : i32
                  %533 = arith.index_cast %494 : index to i32
                  %532 = arith.cmpi eq, %533, %531 : i32
                  %534, %535 = scf.if %532 -> (i64, i64) {
                    %536 = arith.constant 1 : i32
                    %537 = arith.extsi %536 : i32 to i64
                    %538 = arith.constant 0 : i32
                    %539 = arith.extsi %538 : i32 to i64
                    scf.yield %537, %539 : i64, i64
                  } else {
                    %540 = arith.constant 1 : i32
                    %541 = arith.extsi %540 : i32 to i64
                    %542 = arith.constant 1 : i32
                    %543 = arith.extsi %542 : i32 to i64
                    scf.yield %541, %543 : i64, i64
                  }
                  cf.br ^bb92(%534, %535 : i64, i64)
                ^bb92(%544: i64, %545: i64):
                %547 = arith.constant 0 : i32
                %548 = arith.extsi %547 : i32 to i64
                %549 = arith.index_cast %508 : index to i64
                %546 = func.call @pack_state(%548, %544, %545, %549, %359, %360, %361) : (i64, i64, i64, i64, i64, i64, i64) -> i64
                %550 = llvm.load %291 : !llvm.ptr -> i64
                %551 = llvm.getelementptr %265[%550] : (!llvm.ptr, i64) -> !llvm.ptr, i64
                llvm.store %546, %551 : i64, !llvm.ptr
                %552 = arith.constant 1 : i32
                %553 = llvm.load %291 : !llvm.ptr -> i64
                %554 = arith.extsi %552 : i32 to i64
                %555 = llvm.getelementptr %270[%553] : (!llvm.ptr, i64) -> !llvm.ptr, i64
                llvm.store %554, %555 : i64, !llvm.ptr
                %556 = llvm.load %291 : !llvm.ptr -> i64
                %557 = arith.constant 1 : i32
                %559 = arith.extsi %557 : i32 to i64
                %558 = arith.addi %556, %559 : i64
                llvm.store %558, %291 : i64, !llvm.ptr
                %560 = arith.addi %508, %500 : index
                cf.br ^bb81(%560 : index)
              ^bb83(%561: index):
              %562 = arith.addi %494, %486 : index
              cf.br ^bb78(%562 : index)
            ^bb80(%563: index):
            cf.br ^bb77
          ^bb76:
            %564 = arith.constant 0 : i32
            %565 = llvm.mlir.addressof @COLORS : !llvm.ptr
            %566 = llvm.load %565 : !llvm.ptr -> i64
            %567 = arith.index_cast %564 : i32 to index
            %568 = arith.index_cast %566 : i32 to index
            %570 = arith.constant 1 : index
            %571 = arith.constant -1 : index
            %572 = arith.cmpi sle, %567, %568 : index
            %569 = arith.select %572, %570, %571 : index
            cf.br ^bb93(%567 : index)
            ^bb93(%573: index):
            %574 = arith.cmpi slt, %573, %568 : index
            %575 = arith.cmpi sgt, %573, %568 : index
            %576 = arith.select %572, %574, %575 : i1
            cf.cond_br %576, ^bb94(%573 : index), ^bb95(%573 : index)
            ^bb94(%577: index):
              %578 = llvm.mlir.addressof @NONE : !llvm.ptr
              %579 = llvm.load %578 : !llvm.ptr -> i64
              %580 = arith.cmpi ne, %284, %579 : i64
              %581 = scf.if %580 -> (i1) {
                %583 = arith.index_cast %577 : index to i32
                %584 = arith.trunci %284 : i64 to i32
                %582 = arith.cmpi eq, %583, %584 : i32
                scf.yield %582 : i1
              } else {
                %585 = arith.constant false
                scf.yield %585 : i1
              }
              cf.cond_br %581, ^bb96, ^bb97
              ^bb96:
                %586 = arith.addi %577, %569 : index
                cf.br ^bb93(%586 : index)
              ^bb97:
                cf.br ^bb98
              ^bb98:
              %587 = llvm.mlir.addressof @NONE : !llvm.ptr
              %588 = llvm.load %587 : !llvm.ptr -> i64
              %589 = arith.cmpi ne, %287, %588 : i64
              %590 = scf.if %589 -> (i1) {
                %592 = arith.index_cast %577 : index to i32
                %593 = arith.trunci %287 : i64 to i32
                %591 = arith.cmpi eq, %592, %593 : i32
                scf.yield %591 : i1
              } else {
                %594 = arith.constant false
                scf.yield %594 : i1
              }
              cf.cond_br %590, ^bb99, ^bb100
              ^bb99:
                %595 = arith.addi %577, %569 : index
                cf.br ^bb93(%595 : index)
              ^bb100:
                cf.br ^bb101
              ^bb101:
              %597 = arith.constant 1 : i32
              %598 = arith.constant 0 : i32
              %599 = arith.constant 0 : i32
              %600 = arith.constant 0 : i32
              %601 = arith.constant 0 : i32
              %602 = arith.extsi %597 : i32 to i64
              %603 = arith.extsi %598 : i32 to i64
              %604 = arith.extsi %599 : i32 to i64
              %605 = arith.index_cast %577 : index to i64
              %606 = arith.extsi %600 : i32 to i64
              %607 = arith.extsi %601 : i32 to i64
              %608 = arith.index_cast %577 : index to i64
              %596 = func.call @pack_state(%602, %603, %604, %605, %606, %607, %608) : (i64, i64, i64, i64, i64, i64, i64) -> i64
              %609 = llvm.load %291 : !llvm.ptr -> i64
              %610 = llvm.getelementptr %265[%609] : (!llvm.ptr, i64) -> !llvm.ptr, i64
              llvm.store %596, %610 : i64, !llvm.ptr
              %611 = arith.constant 1 : i32
              %612 = llvm.load %291 : !llvm.ptr -> i64
              %613 = arith.extsi %611 : i32 to i64
              %614 = llvm.getelementptr %270[%612] : (!llvm.ptr, i64) -> !llvm.ptr, i64
              llvm.store %613, %614 : i64, !llvm.ptr
              %615 = llvm.load %291 : !llvm.ptr -> i64
              %616 = arith.constant 1 : i32
              %618 = arith.extsi %616 : i32 to i64
              %617 = arith.addi %615, %618 : i64
              llvm.store %617, %291 : i64, !llvm.ptr
              %619 = arith.addi %577, %569 : index
              cf.br ^bb93(%619 : index)
            ^bb95(%620: index):
            %621 = arith.constant 1 : i32
            %622 = arith.constant 4 : i32
            %623 = arith.index_cast %621 : i32 to index
            %624 = arith.index_cast %622 : i32 to index
            %626 = arith.constant 1 : index
            %627 = arith.constant -1 : index
            %628 = arith.cmpi sle, %623, %624 : index
            %625 = arith.select %628, %626, %627 : index
            cf.br ^bb102(%623 : index)
            ^bb102(%629: index):
            %630 = arith.cmpi slt, %629, %624 : index
            %631 = arith.cmpi sgt, %629, %624 : index
            %632 = arith.select %628, %630, %631 : i1
            cf.cond_br %632, ^bb103(%629 : index), ^bb104(%629 : index)
            ^bb103(%633: index):
              %634 = arith.constant 1 : i32
              %635 = arith.constant 4 : i32
              %636 = arith.index_cast %634 : i32 to index
              %637 = arith.index_cast %635 : i32 to index
              %639 = arith.constant 1 : index
              %640 = arith.constant -1 : index
              %641 = arith.cmpi sle, %636, %637 : index
              %638 = arith.select %641, %639, %640 : index
              cf.br ^bb105(%636 : index)
              ^bb105(%642: index):
              %643 = arith.cmpi slt, %642, %637 : index
              %644 = arith.cmpi sgt, %642, %637 : index
              %645 = arith.select %641, %643, %644 : i1
              cf.cond_br %645, ^bb106(%642 : index), ^bb107(%642 : index)
              ^bb106(%646: index):
                %647 = arith.constant 0 : i32
                %648 = llvm.mlir.addressof @COLORS : !llvm.ptr
                %649 = llvm.load %648 : !llvm.ptr -> i64
                %650 = arith.index_cast %647 : i32 to index
                %651 = arith.index_cast %649 : i32 to index
                %653 = arith.constant 1 : index
                %654 = arith.constant -1 : index
                %655 = arith.cmpi sle, %650, %651 : index
                %652 = arith.select %655, %653, %654 : index
                cf.br ^bb108(%650 : index)
                ^bb108(%656: index):
                %657 = arith.cmpi slt, %656, %651 : index
                %658 = arith.cmpi sgt, %656, %651 : index
                %659 = arith.select %655, %657, %658 : i1
                cf.cond_br %659, ^bb109(%656 : index), ^bb110(%656 : index)
                ^bb109(%660: index):
                  %661 = llvm.mlir.addressof @NONE : !llvm.ptr
                  %662 = llvm.load %661 : !llvm.ptr -> i64
                  %663 = arith.cmpi ne, %284, %662 : i64
                  %664 = scf.if %663 -> (i1) {
                    %666 = arith.index_cast %660 : index to i32
                    %667 = arith.trunci %284 : i64 to i32
                    %665 = arith.cmpi eq, %666, %667 : i32
                    scf.yield %665 : i1
                  } else {
                    %668 = arith.constant false
                    scf.yield %668 : i1
                  }
                  cf.cond_br %664, ^bb111, ^bb112
                  ^bb111:
                    %669 = arith.addi %660, %652 : index
                    cf.br ^bb108(%669 : index)
                  ^bb112:
                    cf.br ^bb113
                  ^bb113:
                  %670 = arith.constant 0 : i32
                  %671 = llvm.mlir.addressof @COLORS : !llvm.ptr
                  %672 = llvm.load %671 : !llvm.ptr -> i64
                  %673 = arith.index_cast %670 : i32 to index
                  %674 = arith.index_cast %672 : i32 to index
                  %676 = arith.constant 1 : index
                  %677 = arith.constant -1 : index
                  %678 = arith.cmpi sle, %673, %674 : index
                  %675 = arith.select %678, %676, %677 : index
                  cf.br ^bb114(%673 : index)
                  ^bb114(%679: index):
                  %680 = arith.cmpi slt, %679, %674 : index
                  %681 = arith.cmpi sgt, %679, %674 : index
                  %682 = arith.select %678, %680, %681 : i1
                  cf.cond_br %682, ^bb115(%679 : index), ^bb116(%679 : index)
                  ^bb115(%683: index):
                    %684 = llvm.mlir.addressof @NONE : !llvm.ptr
                    %685 = llvm.load %684 : !llvm.ptr -> i64
                    %686 = arith.cmpi ne, %287, %685 : i64
                    %687 = scf.if %686 -> (i1) {
                      %689 = arith.index_cast %683 : index to i32
                      %690 = arith.trunci %287 : i64 to i32
                      %688 = arith.cmpi eq, %689, %690 : i32
                      scf.yield %688 : i1
                    } else {
                      %691 = arith.constant false
                      scf.yield %691 : i1
                    }
                    cf.cond_br %687, ^bb117, ^bb118
                    ^bb117:
                      %692 = arith.addi %683, %675 : index
                      cf.br ^bb114(%692 : index)
                    ^bb118:
                      cf.br ^bb119
                    ^bb119:
                    %693 = arith.cmpi eq, %660, %683 : index
                    cf.cond_br %693, ^bb120, ^bb121
                    ^bb120:
                      %694 = arith.addi %683, %675 : index
                      cf.br ^bb114(%694 : index)
                    ^bb121:
                      cf.br ^bb122
                    ^bb122:
                    %695 = llvm.mlir.undef : i64
                    %696 = llvm.mlir.undef : i64
                    %697 = arith.constant 1 : i32
                    %699 = arith.index_cast %633 : index to i32
                    %698 = arith.cmpi eq, %699, %697 : i32
                    cf.cond_br %698, ^bb123, ^bb124
                    ^bb123:
                      %700 = arith.constant 0 : i32
                      %701 = arith.extsi %700 : i32 to i64
                      %702 = arith.constant 0 : i32
                      %703 = arith.extsi %702 : i32 to i64
                      cf.br ^bb125(%701, %703 : i64, i64)
                    ^bb124:
                      %704 = arith.constant 2 : i32
                      %706 = arith.index_cast %633 : index to i32
                      %705 = arith.cmpi eq, %706, %704 : i32
                      %707, %708 = scf.if %705 -> (i64, i64) {
                        %709 = arith.constant 1 : i32
                        %710 = arith.extsi %709 : i32 to i64
                        %711 = arith.constant 0 : i32
                        %712 = arith.extsi %711 : i32 to i64
                        scf.yield %710, %712 : i64, i64
                      } else {
                        %713 = arith.constant 1 : i32
                        %714 = arith.extsi %713 : i32 to i64
                        %715 = arith.constant 1 : i32
                        %716 = arith.extsi %715 : i32 to i64
                        scf.yield %714, %716 : i64, i64
                      }
                      cf.br ^bb125(%707, %708 : i64, i64)
                    ^bb125(%717: i64, %718: i64):
                    %719 = llvm.mlir.undef : i64
                    %720 = llvm.mlir.undef : i64
                    %721 = arith.constant 1 : i32
                    %723 = arith.index_cast %646 : index to i32
                    %722 = arith.cmpi eq, %723, %721 : i32
                    cf.cond_br %722, ^bb126, ^bb127
                    ^bb126:
                      %724 = arith.constant 0 : i32
                      %725 = arith.extsi %724 : i32 to i64
                      %726 = arith.constant 0 : i32
                      %727 = arith.extsi %726 : i32 to i64
                      cf.br ^bb128(%725, %727 : i64, i64)
                    ^bb127:
                      %728 = arith.constant 2 : i32
                      %730 = arith.index_cast %646 : index to i32
                      %729 = arith.cmpi eq, %730, %728 : i32
                      %731, %732 = scf.if %729 -> (i64, i64) {
                        %733 = arith.constant 1 : i32
                        %734 = arith.extsi %733 : i32 to i64
                        %735 = arith.constant 0 : i32
                        %736 = arith.extsi %735 : i32 to i64
                        scf.yield %734, %736 : i64, i64
                      } else {
                        %737 = arith.constant 1 : i32
                        %738 = arith.extsi %737 : i32 to i64
                        %739 = arith.constant 1 : i32
                        %740 = arith.extsi %739 : i32 to i64
                        scf.yield %738, %740 : i64, i64
                      }
                      cf.br ^bb128(%731, %732 : i64, i64)
                    ^bb128(%741: i64, %742: i64):
                    %743 = arith.constant 0 : i32
                    %745 = arith.extsi %743 : i32 to i64
                    %744 = arith.cmpi eq, %281, %745 : i64
                    cf.cond_br %744, ^bb129, ^bb130
                    ^bb129:
                      %746 = arith.addi %683, %675 : index
                      cf.br ^bb114(%746 : index)
                    ^bb130:
                      cf.br ^bb131
                    ^bb131:
                    %748 = arith.constant 0 : i32
                    %749 = arith.extsi %748 : i32 to i64
                    %750 = arith.index_cast %660 : index to i64
                    %751 = arith.index_cast %683 : index to i64
                    %747 = func.call @pack_state(%749, %717, %718, %750, %741, %742, %751) : (i64, i64, i64, i64, i64, i64, i64) -> i64
                    %752 = llvm.load %291 : !llvm.ptr -> i64
                    %753 = llvm.getelementptr %265[%752] : (!llvm.ptr, i64) -> !llvm.ptr, i64
                    llvm.store %747, %753 : i64, !llvm.ptr
                    %754 = arith.constant 1 : i32
                    %755 = llvm.load %291 : !llvm.ptr -> i64
                    %756 = arith.extsi %754 : i32 to i64
                    %757 = llvm.getelementptr %270[%755] : (!llvm.ptr, i64) -> !llvm.ptr, i64
                    llvm.store %756, %757 : i64, !llvm.ptr
                    %758 = llvm.load %291 : !llvm.ptr -> i64
                    %759 = arith.constant 1 : i32
                    %761 = arith.extsi %759 : i32 to i64
                    %760 = arith.addi %758, %761 : i64
                    llvm.store %760, %291 : i64, !llvm.ptr
                    %762 = arith.addi %683, %675 : index
                    cf.br ^bb114(%762 : index)
                  ^bb116(%763: index):
                  %764 = arith.addi %660, %652 : index
                  cf.br ^bb108(%764 : index)
                ^bb110(%765: index):
                %766 = arith.addi %646, %638 : index
                cf.br ^bb105(%766 : index)
              ^bb107(%767: index):
              %768 = arith.addi %633, %625 : index
              cf.br ^bb102(%768 : index)
            ^bb104(%769: index):
            cf.br ^bb77
          ^bb77:
          cf.br ^bb59
        ^bb59:
        cf.br ^bb53
      ^bb53:
      %770 = arith.constant 0 : i32
      %771 = arith.extsi %770 : i32 to i64
      %772 = llvm.mlir.constant(1 : i64) : i64
      %773 = llvm.alloca %772 x i64 : (i64) -> !llvm.ptr
      llvm.store %771, %773 : i64, !llvm.ptr
      %774 = arith.constant 0 : i32
      %775 = llvm.load %291 : !llvm.ptr -> i64
      %776 = arith.index_cast %774 : i32 to index
      %777 = arith.index_cast %775 : i32 to index
      %779 = arith.constant 1 : index
      %780 = arith.constant -1 : index
      %781 = arith.cmpi sle, %776, %777 : index
      %778 = arith.select %781, %779, %780 : index
      cf.br ^bb132(%776 : index)
      ^bb132(%782: index):
      %783 = arith.cmpi slt, %782, %777 : index
      %784 = arith.cmpi sgt, %782, %777 : index
      %785 = arith.select %781, %783, %784 : i1
      cf.cond_br %785, ^bb133(%782 : index), ^bb134(%782 : index)
      ^bb133(%786: index):
        %787 = arith.constant 1 : i32
        %789 = arith.constant 0 : i32
        %788 = arith.subi %789, %787 : i32
        %790 = arith.extsi %788 : i32 to i64
        %791 = arith.constant 0 : i32
        %792 = llvm.load %773 : !llvm.ptr -> i64
        %793 = arith.index_cast %791 : i32 to index
        %794 = arith.index_cast %792 : i32 to index
        %796 = arith.constant 1 : index
        %797 = arith.constant -1 : index
        %798 = arith.cmpi sle, %793, %794 : index
        %795 = arith.select %798, %796, %797 : index
        cf.br ^bb135(%793, %790 : index, i64)
        ^bb135(%799: index, %800: i64):
        %801 = arith.cmpi slt, %799, %794 : index
        %802 = arith.cmpi sgt, %799, %794 : index
        %803 = arith.select %798, %801, %802 : i1
        cf.cond_br %803, ^bb136(%799, %800 : index, i64), ^bb137(%799, %800 : index, i64)
        ^bb136(%804: index, %805: i64):
          %807 = arith.index_cast %804 : index to i64
          %808 = llvm.getelementptr %265[%807] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          %806 = llvm.load %808 : !llvm.ptr -> i64
          %810 = arith.index_cast %786 : index to i64
          %811 = llvm.getelementptr %265[%810] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          %809 = llvm.load %811 : !llvm.ptr -> i64
          %812 = arith.cmpi eq, %806, %809 : i64
          %813 = scf.if %812 -> (i64) {
            %815 = arith.index_cast %804 : index to i64
            %816 = llvm.getelementptr %270[%815] : (!llvm.ptr, i64) -> !llvm.ptr, i64
            %814 = llvm.load %816 : !llvm.ptr -> i64
            %818 = arith.index_cast %786 : index to i64
            %819 = llvm.getelementptr %270[%818] : (!llvm.ptr, i64) -> !llvm.ptr, i64
            %817 = llvm.load %819 : !llvm.ptr -> i64
            %820 = arith.addi %814, %817 : i64
            %821 = llvm.mlir.addressof @MOD : !llvm.ptr
            %822 = llvm.load %821 : !llvm.ptr -> i64
            %823 = arith.remsi %820, %822 : i64
            %824 = arith.index_cast %804 : index to i64
            %825 = llvm.getelementptr %270[%824] : (!llvm.ptr, i64) -> !llvm.ptr, i64
            llvm.store %823, %825 : i64, !llvm.ptr
            %826 = arith.constant 1 : i32
            %827 = arith.extsi %826 : i32 to i64
            scf.yield %827 : i64
          } else {
            scf.yield %805 : i64
          }
          %828 = arith.addi %804, %795 : index
          cf.br ^bb135(%828, %813 : index, i64)
        ^bb137(%829: index, %830: i64):
        %831 = arith.constant 1 : i32
        %833 = arith.constant 0 : i32
        %832 = arith.subi %833, %831 : i32
        %835 = arith.extsi %832 : i32 to i64
        %834 = arith.cmpi eq, %830, %835 : i64
        cf.cond_br %834, ^bb138, ^bb139
        ^bb138:
          %837 = arith.index_cast %786 : index to i64
          %838 = llvm.getelementptr %265[%837] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          %836 = llvm.load %838 : !llvm.ptr -> i64
          %839 = llvm.load %773 : !llvm.ptr -> i64
          %840 = llvm.getelementptr %265[%839] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          llvm.store %836, %840 : i64, !llvm.ptr
          %842 = arith.index_cast %786 : index to i64
          %843 = llvm.getelementptr %270[%842] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          %841 = llvm.load %843 : !llvm.ptr -> i64
          %844 = llvm.load %773 : !llvm.ptr -> i64
          %845 = llvm.getelementptr %270[%844] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          llvm.store %841, %845 : i64, !llvm.ptr
          %846 = llvm.load %773 : !llvm.ptr -> i64
          %847 = arith.constant 1 : i32
          %849 = arith.extsi %847 : i32 to i64
          %848 = arith.addi %846, %849 : i64
          llvm.store %848, %773 : i64, !llvm.ptr
          cf.br ^bb140
        ^bb139:
          cf.br ^bb140
        ^bb140:
        %850 = arith.addi %786, %778 : index
        cf.br ^bb132(%850 : index)
      ^bb134(%851: index):
      %852 = llvm.load %264 : !llvm.ptr -> i64
      %853 = llvm.load %260 : !llvm.ptr -> i64
      %854 = llvm.getelementptr %arg1[%853] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %852, %854 : i64, !llvm.ptr
      %855 = arith.constant 0 : i32
      %856 = llvm.load %773 : !llvm.ptr -> i64
      %857 = arith.index_cast %855 : i32 to index
      %858 = arith.index_cast %856 : i32 to index
      %860 = arith.constant 1 : index
      %861 = arith.constant -1 : index
      %862 = arith.cmpi sle, %857, %858 : index
      %859 = arith.select %862, %860, %861 : index
      cf.br ^bb141(%857 : index)
      ^bb141(%863: index):
      %864 = arith.cmpi slt, %863, %858 : index
      %865 = arith.cmpi sgt, %863, %858 : index
      %866 = arith.select %862, %864, %865 : i1
      cf.cond_br %866, ^bb142(%863 : index), ^bb143(%863 : index)
      ^bb142(%867: index):
        %869 = arith.index_cast %867 : index to i64
        %870 = llvm.getelementptr %265[%869] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %868 = llvm.load %870 : !llvm.ptr -> i64
        %871 = arith.constant 1 : i32
        %873 = arith.constant 0 : i32
        %872 = arith.subi %873, %871 : i32
        %874 = arith.extsi %872 : i32 to i64
        %875 = llvm.mlir.constant(1 : i64) : i64
        %876 = llvm.alloca %875 x i64 : (i64) -> !llvm.ptr
        llvm.store %874, %876 : i64, !llvm.ptr
        %877 = arith.constant 0 : i32
        %878 = llvm.load %256 : !llvm.ptr -> i64
        %879 = arith.index_cast %877 : i32 to index
        %880 = arith.index_cast %878 : i32 to index
        %882 = arith.constant 1 : index
        %883 = arith.constant -1 : index
        %884 = arith.cmpi sle, %879, %880 : index
        %881 = arith.select %884, %882, %883 : index
        cf.br ^bb144(%879 : index)
        ^bb144(%885: index):
        %886 = arith.cmpi slt, %885, %880 : index
        %887 = arith.cmpi sgt, %885, %880 : index
        %888 = arith.select %884, %886, %887 : i1
        cf.cond_br %888, ^bb145(%885 : index), ^bb146(%885 : index)
        ^bb145(%889: index):
          %891 = arith.index_cast %889 : index to i64
          %892 = llvm.getelementptr %arg0[%891] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          %890 = llvm.load %892 : !llvm.ptr -> i64
          %893 = arith.cmpi eq, %890, %868 : i64
          cf.cond_br %893, ^bb147, ^bb148
          ^bb147:
            %894 = arith.index_cast %889 : index to i64
            llvm.store %894, %876 : i64, !llvm.ptr
            cf.br ^bb149
          ^bb148:
            cf.br ^bb149
          ^bb149:
          %895 = arith.addi %889, %881 : index
          cf.br ^bb144(%895 : index)
        ^bb146(%896: index):
        %897 = llvm.load %876 : !llvm.ptr -> i64
        %898 = arith.constant 1 : i32
        %900 = arith.constant 0 : i32
        %899 = arith.subi %900, %898 : i32
        %902 = arith.extsi %899 : i32 to i64
        %901 = arith.cmpi eq, %897, %902 : i64
        cf.cond_br %901, ^bb150, ^bb151
        ^bb150:
          %903 = llvm.load %256 : !llvm.ptr -> i64
          %904 = llvm.getelementptr %arg0[%903] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          llvm.store %868, %904 : i64, !llvm.ptr
          %905 = llvm.load %256 : !llvm.ptr -> i64
          llvm.store %905, %876 : i64, !llvm.ptr
          %906 = llvm.load %256 : !llvm.ptr -> i64
          %907 = arith.constant 1 : i32
          %909 = arith.extsi %907 : i32 to i64
          %908 = arith.addi %906, %909 : i64
          llvm.store %908, %256 : i64, !llvm.ptr
          cf.br ^bb152
        ^bb151:
          cf.br ^bb152
        ^bb152:
        %910 = llvm.load %876 : !llvm.ptr -> i64
        %911 = llvm.load %264 : !llvm.ptr -> i64
        %912 = llvm.getelementptr %arg2[%911] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        llvm.store %910, %912 : i64, !llvm.ptr
        %914 = arith.index_cast %867 : index to i64
        %915 = llvm.getelementptr %270[%914] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %913 = llvm.load %915 : !llvm.ptr -> i64
        %916 = llvm.load %264 : !llvm.ptr -> i64
        %917 = llvm.getelementptr %arg3[%916] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        llvm.store %913, %917 : i64, !llvm.ptr
        %918 = llvm.load %264 : !llvm.ptr -> i64
        %919 = arith.constant 1 : i32
        %921 = arith.extsi %919 : i32 to i64
        %920 = arith.addi %918, %921 : i64
        llvm.store %920, %264 : i64, !llvm.ptr
        %922 = arith.addi %867, %859 : index
        cf.br ^bb141(%922 : index)
      ^bb143(%923: index):
      %924 = llvm.load %260 : !llvm.ptr -> i64
      %925 = arith.constant 1 : i32
      %927 = arith.extsi %925 : i32 to i64
      %926 = arith.addi %924, %927 : i64
      llvm.store %926, %260 : i64, !llvm.ptr
      cf.br ^bb42
    ^bb44:
    %928 = llvm.load %264 : !llvm.ptr -> i64
    %929 = llvm.load %256 : !llvm.ptr -> i64
    %930 = llvm.getelementptr %arg1[%929] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    llvm.store %928, %930 : i64, !llvm.ptr
    func.call @free(%270) : (!llvm.ptr) -> ()
    func.call @free(%265) : (!llvm.ptr) -> ()
    %933 = llvm.load %256 : !llvm.ptr -> i64
    func.return %933 : i64
  }
  func.func @main() -> i32 {
    %935 = llvm.mlir.addressof @MAX_STATES : !llvm.ptr
    %936 = llvm.load %935 : !llvm.ptr -> i64
    %937 = arith.constant 8 : i32
    %938 = arith.extsi %937 : i32 to i64
    %934 = func.call @calloc(%936, %938) : (i64, i64) -> !llvm.ptr
    %940 = llvm.mlir.addressof @MAX_STATES : !llvm.ptr
    %941 = llvm.load %940 : !llvm.ptr -> i64
    %942 = arith.constant 1 : i32
    %944 = arith.extsi %942 : i32 to i64
    %943 = arith.addi %941, %944 : i64
    %945 = arith.constant 8 : i32
    %946 = arith.extsi %945 : i32 to i64
    %939 = func.call @calloc(%943, %946) : (i64, i64) -> !llvm.ptr
    %948 = llvm.mlir.addressof @MAX_STATES : !llvm.ptr
    %949 = llvm.load %948 : !llvm.ptr -> i64
    %950 = arith.constant 200 : i32
    %952 = arith.extsi %950 : i32 to i64
    %951 = arith.muli %949, %952 : i64
    %953 = arith.constant 8 : i32
    %954 = arith.extsi %953 : i32 to i64
    %947 = func.call @calloc(%951, %954) : (i64, i64) -> !llvm.ptr
    %956 = llvm.mlir.addressof @MAX_STATES : !llvm.ptr
    %957 = llvm.load %956 : !llvm.ptr -> i64
    %958 = arith.constant 200 : i32
    %960 = arith.extsi %958 : i32 to i64
    %959 = arith.muli %957, %960 : i64
    %961 = arith.constant 8 : i32
    %962 = arith.extsi %961 : i32 to i64
    %955 = func.call @calloc(%959, %962) : (i64, i64) -> !llvm.ptr
    %963 = func.call @build_automaton(%934, %939, %947, %955) : (!llvm.ptr, !llvm.ptr, !llvm.ptr, !llvm.ptr) -> i64
    %965 = arith.muli %963, %963 : i64
    %966 = arith.constant 8 : i32
    %967 = arith.extsi %966 : i32 to i64
    %964 = func.call @calloc(%965, %967) : (i64, i64) -> !llvm.ptr
    %968 = arith.constant 0 : i32
    %969 = arith.index_cast %968 : i32 to index
    %970 = arith.index_cast %963 : i32 to index
    %972 = arith.constant 1 : index
    %973 = arith.constant -1 : index
    %974 = arith.cmpi sle, %969, %970 : index
    %971 = arith.select %974, %972, %973 : index
    cf.br ^bb153(%969 : index)
    ^bb153(%975: index):
    %976 = arith.cmpi slt, %975, %970 : index
    %977 = arith.cmpi sgt, %975, %970 : index
    %978 = arith.select %974, %976, %977 : i1
    cf.cond_br %978, ^bb154(%975 : index), ^bb155(%975 : index)
    ^bb154(%979: index):
      %981 = arith.index_cast %979 : index to i64
      %982 = llvm.getelementptr %939[%981] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %980 = llvm.load %982 : !llvm.ptr -> i64
      %984 = arith.constant 1 : i32
      %986 = arith.index_cast %979 : index to i32
      %985 = arith.addi %986, %984 : i32
      %987 = arith.extsi %985 : i32 to i64
      %988 = llvm.getelementptr %939[%987] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %983 = llvm.load %988 : !llvm.ptr -> i64
      %989 = arith.index_cast %980 : i32 to index
      %990 = arith.index_cast %983 : i32 to index
      %992 = arith.constant 1 : index
      %993 = arith.constant -1 : index
      %994 = arith.cmpi sle, %989, %990 : index
      %991 = arith.select %994, %992, %993 : index
      cf.br ^bb156(%989 : index)
      ^bb156(%995: index):
      %996 = arith.cmpi slt, %995, %990 : index
      %997 = arith.cmpi sgt, %995, %990 : index
      %998 = arith.select %994, %996, %997 : i1
      cf.cond_br %998, ^bb157(%995 : index), ^bb158(%995 : index)
      ^bb157(%999: index):
        %1001 = arith.index_cast %999 : index to i64
        %1002 = llvm.getelementptr %947[%1001] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %1000 = llvm.load %1002 : !llvm.ptr -> i64
        %1004 = arith.index_cast %999 : index to i64
        %1005 = llvm.getelementptr %955[%1004] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %1003 = llvm.load %1005 : !llvm.ptr -> i64
        %1007 = arith.index_cast %979 : index to i32
        %1008 = arith.trunci %963 : i64 to i32
        %1006 = arith.muli %1007, %1008 : i32
        %1010 = arith.extsi %1006 : i32 to i64
        %1009 = arith.addi %1010, %1000 : i64
        %1011 = llvm.getelementptr %964[%1009] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        llvm.store %1003, %1011 : i64, !llvm.ptr
        %1012 = arith.addi %999, %991 : index
        cf.br ^bb156(%1012 : index)
      ^bb158(%1013: index):
      %1014 = arith.addi %979, %971 : index
      cf.br ^bb153(%1014 : index)
    ^bb155(%1015: index):
    %1017 = arith.constant 8 : i32
    %1018 = arith.extsi %1017 : i32 to i64
    %1016 = func.call @calloc(%963, %1018) : (i64, i64) -> !llvm.ptr
    %1019 = arith.constant 1 : i32
    %1020 = arith.constant 0 : i32
    %1021 = arith.extsi %1019 : i32 to i64
    %1022 = arith.extsi %1020 : i32 to i64
    %1023 = llvm.getelementptr %1016[%1022] : (!llvm.ptr, i64) -> !llvm.ptr, i64
    llvm.store %1021, %1023 : i64, !llvm.ptr
    %1024 = arith.constant 9999995705032704 : i32
    %1025 = arith.extsi %1024 : i32 to i64
    %1027 = arith.constant 8 : i32
    %1028 = arith.extsi %1027 : i32 to i64
    %1026 = func.call @calloc(%963, %1028) : (i64, i64) -> !llvm.ptr
    %1029 = arith.constant 0 : i32
    %1030 = arith.index_cast %1029 : i32 to index
    %1031 = arith.index_cast %963 : i32 to index
    %1033 = arith.constant 1 : index
    %1034 = arith.constant -1 : index
    %1035 = arith.cmpi sle, %1030, %1031 : index
    %1032 = arith.select %1035, %1033, %1034 : index
    cf.br ^bb159(%1030 : index)
    ^bb159(%1036: index):
    %1037 = arith.cmpi slt, %1036, %1031 : index
    %1038 = arith.cmpi sgt, %1036, %1031 : index
    %1039 = arith.select %1035, %1037, %1038 : i1
    cf.cond_br %1039, ^bb160(%1036 : index), ^bb161(%1036 : index)
    ^bb160(%1040: index):
      %1042 = arith.index_cast %1040 : index to i64
      %1043 = llvm.getelementptr %1016[%1042] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %1041 = llvm.load %1043 : !llvm.ptr -> i64
      %1044 = arith.index_cast %1040 : index to i64
      %1045 = llvm.getelementptr %1026[%1044] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %1041, %1045 : i64, !llvm.ptr
      %1046 = arith.addi %1040, %1032 : index
      cf.br ^bb159(%1046 : index)
    ^bb161(%1047: index):
    %1049 = arith.muli %963, %963 : i64
    %1050 = arith.constant 8 : i32
    %1051 = arith.extsi %1050 : i32 to i64
    %1048 = func.call @calloc(%1049, %1051) : (i64, i64) -> !llvm.ptr
    %1052 = arith.constant 0 : i32
    %1053 = arith.muli %963, %963 : i64
    %1054 = arith.index_cast %1052 : i32 to index
    %1055 = arith.index_cast %1053 : i32 to index
    %1057 = arith.constant 1 : index
    %1058 = arith.constant -1 : index
    %1059 = arith.cmpi sle, %1054, %1055 : index
    %1056 = arith.select %1059, %1057, %1058 : index
    cf.br ^bb162(%1054 : index)
    ^bb162(%1060: index):
    %1061 = arith.cmpi slt, %1060, %1055 : index
    %1062 = arith.cmpi sgt, %1060, %1055 : index
    %1063 = arith.select %1059, %1061, %1062 : i1
    cf.cond_br %1063, ^bb163(%1060 : index), ^bb164(%1060 : index)
    ^bb163(%1064: index):
      %1066 = arith.index_cast %1064 : index to i64
      %1067 = llvm.getelementptr %964[%1066] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %1065 = llvm.load %1067 : !llvm.ptr -> i64
      %1068 = arith.index_cast %1064 : index to i64
      %1069 = llvm.getelementptr %1048[%1068] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      llvm.store %1065, %1069 : i64, !llvm.ptr
      %1070 = arith.addi %1064, %1056 : index
      cf.br ^bb162(%1070 : index)
    ^bb164(%1071: index):
    %1073 = arith.constant 8 : i32
    %1074 = arith.extsi %1073 : i32 to i64
    %1072 = func.call @calloc(%963, %1074) : (i64, i64) -> !llvm.ptr
    %1076 = arith.muli %963, %963 : i64
    %1077 = arith.constant 8 : i32
    %1078 = arith.extsi %1077 : i32 to i64
    %1075 = func.call @calloc(%1076, %1078) : (i64, i64) -> !llvm.ptr
    %1079 = llvm.mlir.constant(1 : i64) : i64
    %1080 = llvm.alloca %1079 x i64 : (i64) -> !llvm.ptr
    llvm.store %1025, %1080 : i64, !llvm.ptr
    cf.br ^bb165
    ^bb165:
    %1081 = llvm.load %1080 : !llvm.ptr -> i64
    %1082 = arith.constant 0 : i32
    %1084 = arith.extsi %1082 : i32 to i64
    %1083 = arith.cmpi sgt, %1081, %1084 : i64
    cf.cond_br %1083, ^bb166, ^bb167
    ^bb166:
      %1085 = llvm.load %1080 : !llvm.ptr -> i64
      %1086 = arith.constant 1 : i32
      %1087 = arith.constant 1 : i32
      %1088 = arith.cmpi eq, %1086, %1087 : i32
      %1090 = arith.trunci %1085 : i64 to i1
      %1089 = arith.andi %1090, %1088 : i1
      cf.cond_br %1089, ^bb168, ^bb169
      ^bb168:
        %1091 = arith.constant 0 : i32
        %1092 = arith.index_cast %1091 : i32 to index
        %1093 = arith.index_cast %963 : i32 to index
        %1095 = arith.constant 1 : index
        %1096 = arith.constant -1 : index
        %1097 = arith.cmpi sle, %1092, %1093 : index
        %1094 = arith.select %1097, %1095, %1096 : index
        cf.br ^bb171(%1092 : index)
        ^bb171(%1098: index):
        %1099 = arith.cmpi slt, %1098, %1093 : index
        %1100 = arith.cmpi sgt, %1098, %1093 : index
        %1101 = arith.select %1097, %1099, %1100 : i1
        cf.cond_br %1101, ^bb172(%1098 : index), ^bb173(%1098 : index)
        ^bb172(%1102: index):
          %1103 = arith.constant 0 : i32
          %1104 = arith.extsi %1103 : i32 to i64
          %1105 = arith.index_cast %1102 : index to i64
          %1106 = llvm.getelementptr %1072[%1105] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          llvm.store %1104, %1106 : i64, !llvm.ptr
          %1107 = arith.addi %1102, %1094 : index
          cf.br ^bb171(%1107 : index)
        ^bb173(%1108: index):
        %1109 = arith.constant 0 : i32
        %1110 = arith.index_cast %1109 : i32 to index
        %1111 = arith.index_cast %963 : i32 to index
        %1113 = arith.constant 1 : index
        %1114 = arith.constant -1 : index
        %1115 = arith.cmpi sle, %1110, %1111 : index
        %1112 = arith.select %1115, %1113, %1114 : index
        cf.br ^bb174(%1110 : index)
        ^bb174(%1116: index):
        %1117 = arith.cmpi slt, %1116, %1111 : index
        %1118 = arith.cmpi sgt, %1116, %1111 : index
        %1119 = arith.select %1115, %1117, %1118 : i1
        cf.cond_br %1119, ^bb175(%1116 : index), ^bb176(%1116 : index)
        ^bb175(%1120: index):
          %1122 = arith.index_cast %1120 : index to i64
          %1123 = llvm.getelementptr %1026[%1122] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          %1121 = llvm.load %1123 : !llvm.ptr -> i64
          %1124 = arith.constant 0 : i32
          %1126 = arith.extsi %1124 : i32 to i64
          %1125 = arith.cmpi eq, %1121, %1126 : i64
          cf.cond_br %1125, ^bb177, ^bb178
          ^bb177:
            %1127 = arith.addi %1120, %1112 : index
            cf.br ^bb174(%1127 : index)
          ^bb178:
            cf.br ^bb179
          ^bb179:
          %1128 = arith.constant 0 : i32
          %1129 = arith.index_cast %1128 : i32 to index
          %1130 = arith.index_cast %963 : i32 to index
          %1132 = arith.constant 1 : index
          %1133 = arith.constant -1 : index
          %1134 = arith.cmpi sle, %1129, %1130 : index
          %1131 = arith.select %1134, %1132, %1133 : index
          cf.br ^bb180(%1129 : index)
          ^bb180(%1135: index):
          %1136 = arith.cmpi slt, %1135, %1130 : index
          %1137 = arith.cmpi sgt, %1135, %1130 : index
          %1138 = arith.select %1134, %1136, %1137 : i1
          cf.cond_br %1138, ^bb181(%1135 : index), ^bb182(%1135 : index)
          ^bb181(%1139: index):
            %1141 = arith.index_cast %1139 : index to i64
            %1142 = llvm.getelementptr %1072[%1141] : (!llvm.ptr, i64) -> !llvm.ptr, i64
            %1140 = llvm.load %1142 : !llvm.ptr -> i64
            %1144 = arith.index_cast %1120 : index to i64
            %1145 = llvm.getelementptr %1026[%1144] : (!llvm.ptr, i64) -> !llvm.ptr, i64
            %1143 = llvm.load %1145 : !llvm.ptr -> i64
            %1148 = arith.index_cast %1120 : index to i32
            %1149 = arith.trunci %963 : i64 to i32
            %1147 = arith.muli %1148, %1149 : i32
            %1151 = arith.index_cast %1139 : index to i32
            %1150 = arith.addi %1147, %1151 : i32
            %1152 = arith.extsi %1150 : i32 to i64
            %1153 = llvm.getelementptr %1048[%1152] : (!llvm.ptr, i64) -> !llvm.ptr, i64
            %1146 = llvm.load %1153 : !llvm.ptr -> i64
            %1154 = arith.muli %1143, %1146 : i64
            %1155 = arith.addi %1140, %1154 : i64
            %1156 = llvm.mlir.addressof @MOD : !llvm.ptr
            %1157 = llvm.load %1156 : !llvm.ptr -> i64
            %1158 = arith.remsi %1155, %1157 : i64
            %1159 = arith.index_cast %1139 : index to i64
            %1160 = llvm.getelementptr %1072[%1159] : (!llvm.ptr, i64) -> !llvm.ptr, i64
            llvm.store %1158, %1160 : i64, !llvm.ptr
            %1161 = arith.addi %1139, %1131 : index
            cf.br ^bb180(%1161 : index)
          ^bb182(%1162: index):
          %1163 = arith.addi %1120, %1112 : index
          cf.br ^bb174(%1163 : index)
        ^bb176(%1164: index):
        %1165 = arith.constant 0 : i32
        %1166 = arith.index_cast %1165 : i32 to index
        %1167 = arith.index_cast %963 : i32 to index
        %1169 = arith.constant 1 : index
        %1170 = arith.constant -1 : index
        %1171 = arith.cmpi sle, %1166, %1167 : index
        %1168 = arith.select %1171, %1169, %1170 : index
        cf.br ^bb183(%1166 : index)
        ^bb183(%1172: index):
        %1173 = arith.cmpi slt, %1172, %1167 : index
        %1174 = arith.cmpi sgt, %1172, %1167 : index
        %1175 = arith.select %1171, %1173, %1174 : i1
        cf.cond_br %1175, ^bb184(%1172 : index), ^bb185(%1172 : index)
        ^bb184(%1176: index):
          %1178 = arith.index_cast %1176 : index to i64
          %1179 = llvm.getelementptr %1072[%1178] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          %1177 = llvm.load %1179 : !llvm.ptr -> i64
          %1180 = arith.index_cast %1176 : index to i64
          %1181 = llvm.getelementptr %1026[%1180] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          llvm.store %1177, %1181 : i64, !llvm.ptr
          %1182 = arith.addi %1176, %1168 : index
          cf.br ^bb183(%1182 : index)
        ^bb185(%1183: index):
        cf.br ^bb170
      ^bb169:
        cf.br ^bb170
      ^bb170:
      %1184 = llvm.load %1080 : !llvm.ptr -> i64
      %1185 = arith.constant 1 : i32
      %1187 = arith.extsi %1185 : i32 to i64
      %1186 = arith.shrsi %1184, %1187 : i64
      llvm.store %1186, %1080 : i64, !llvm.ptr
      %1188 = llvm.load %1080 : !llvm.ptr -> i64
      %1189 = arith.constant 0 : i32
      %1191 = arith.extsi %1189 : i32 to i64
      %1190 = arith.cmpi sgt, %1188, %1191 : i64
      cf.cond_br %1190, ^bb186, ^bb187
      ^bb186:
        %1192 = arith.constant 0 : i32
        %1193 = arith.muli %963, %963 : i64
        %1194 = arith.index_cast %1192 : i32 to index
        %1195 = arith.index_cast %1193 : i32 to index
        %1197 = arith.constant 1 : index
        %1198 = arith.constant -1 : index
        %1199 = arith.cmpi sle, %1194, %1195 : index
        %1196 = arith.select %1199, %1197, %1198 : index
        cf.br ^bb189(%1194 : index)
        ^bb189(%1200: index):
        %1201 = arith.cmpi slt, %1200, %1195 : index
        %1202 = arith.cmpi sgt, %1200, %1195 : index
        %1203 = arith.select %1199, %1201, %1202 : i1
        cf.cond_br %1203, ^bb190(%1200 : index), ^bb191(%1200 : index)
        ^bb190(%1204: index):
          %1205 = arith.constant 0 : i32
          %1206 = arith.extsi %1205 : i32 to i64
          %1207 = arith.index_cast %1204 : index to i64
          %1208 = llvm.getelementptr %1075[%1207] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          llvm.store %1206, %1208 : i64, !llvm.ptr
          %1209 = arith.addi %1204, %1196 : index
          cf.br ^bb189(%1209 : index)
        ^bb191(%1210: index):
        %1211 = arith.constant 0 : i32
        %1212 = arith.index_cast %1211 : i32 to index
        %1213 = arith.index_cast %963 : i32 to index
        %1215 = arith.constant 1 : index
        %1216 = arith.constant -1 : index
        %1217 = arith.cmpi sle, %1212, %1213 : index
        %1214 = arith.select %1217, %1215, %1216 : index
        cf.br ^bb192(%1212 : index)
        ^bb192(%1218: index):
        %1219 = arith.cmpi slt, %1218, %1213 : index
        %1220 = arith.cmpi sgt, %1218, %1213 : index
        %1221 = arith.select %1217, %1219, %1220 : i1
        cf.cond_br %1221, ^bb193(%1218 : index), ^bb194(%1218 : index)
        ^bb193(%1222: index):
          %1223 = arith.constant 0 : i32
          %1224 = arith.index_cast %1223 : i32 to index
          %1225 = arith.index_cast %963 : i32 to index
          %1227 = arith.constant 1 : index
          %1228 = arith.constant -1 : index
          %1229 = arith.cmpi sle, %1224, %1225 : index
          %1226 = arith.select %1229, %1227, %1228 : index
          cf.br ^bb195(%1224 : index)
          ^bb195(%1230: index):
          %1231 = arith.cmpi slt, %1230, %1225 : index
          %1232 = arith.cmpi sgt, %1230, %1225 : index
          %1233 = arith.select %1229, %1231, %1232 : i1
          cf.cond_br %1233, ^bb196(%1230 : index), ^bb197(%1230 : index)
          ^bb196(%1234: index):
            %1237 = arith.index_cast %1222 : index to i32
            %1238 = arith.trunci %963 : i64 to i32
            %1236 = arith.muli %1237, %1238 : i32
            %1240 = arith.index_cast %1234 : index to i32
            %1239 = arith.addi %1236, %1240 : i32
            %1241 = arith.extsi %1239 : i32 to i64
            %1242 = llvm.getelementptr %1048[%1241] : (!llvm.ptr, i64) -> !llvm.ptr, i64
            %1235 = llvm.load %1242 : !llvm.ptr -> i64
            %1243 = arith.constant 0 : i32
            %1245 = arith.extsi %1243 : i32 to i64
            %1244 = arith.cmpi eq, %1235, %1245 : i64
            cf.cond_br %1244, ^bb198, ^bb199
            ^bb198:
              %1246 = arith.addi %1234, %1226 : index
              cf.br ^bb195(%1246 : index)
            ^bb199:
              cf.br ^bb200
            ^bb200:
            %1247 = arith.constant 0 : i32
            %1248 = arith.index_cast %1247 : i32 to index
            %1249 = arith.index_cast %963 : i32 to index
            %1251 = arith.constant 1 : index
            %1252 = arith.constant -1 : index
            %1253 = arith.cmpi sle, %1248, %1249 : index
            %1250 = arith.select %1253, %1251, %1252 : index
            cf.br ^bb201(%1248 : index)
            ^bb201(%1254: index):
            %1255 = arith.cmpi slt, %1254, %1249 : index
            %1256 = arith.cmpi sgt, %1254, %1249 : index
            %1257 = arith.select %1253, %1255, %1256 : i1
            cf.cond_br %1257, ^bb202(%1254 : index), ^bb203(%1254 : index)
            ^bb202(%1258: index):
              %1261 = arith.index_cast %1222 : index to i32
              %1262 = arith.trunci %963 : i64 to i32
              %1260 = arith.muli %1261, %1262 : i32
              %1264 = arith.index_cast %1258 : index to i32
              %1263 = arith.addi %1260, %1264 : i32
              %1265 = arith.extsi %1263 : i32 to i64
              %1266 = llvm.getelementptr %1075[%1265] : (!llvm.ptr, i64) -> !llvm.ptr, i64
              %1259 = llvm.load %1266 : !llvm.ptr -> i64
              %1269 = arith.index_cast %1222 : index to i32
              %1270 = arith.trunci %963 : i64 to i32
              %1268 = arith.muli %1269, %1270 : i32
              %1272 = arith.index_cast %1234 : index to i32
              %1271 = arith.addi %1268, %1272 : i32
              %1273 = arith.extsi %1271 : i32 to i64
              %1274 = llvm.getelementptr %1048[%1273] : (!llvm.ptr, i64) -> !llvm.ptr, i64
              %1267 = llvm.load %1274 : !llvm.ptr -> i64
              %1277 = arith.index_cast %1234 : index to i32
              %1278 = arith.trunci %963 : i64 to i32
              %1276 = arith.muli %1277, %1278 : i32
              %1280 = arith.index_cast %1258 : index to i32
              %1279 = arith.addi %1276, %1280 : i32
              %1281 = arith.extsi %1279 : i32 to i64
              %1282 = llvm.getelementptr %1048[%1281] : (!llvm.ptr, i64) -> !llvm.ptr, i64
              %1275 = llvm.load %1282 : !llvm.ptr -> i64
              %1283 = arith.muli %1267, %1275 : i64
              %1284 = arith.addi %1259, %1283 : i64
              %1285 = llvm.mlir.addressof @MOD : !llvm.ptr
              %1286 = llvm.load %1285 : !llvm.ptr -> i64
              %1287 = arith.remsi %1284, %1286 : i64
              %1289 = arith.index_cast %1222 : index to i32
              %1290 = arith.trunci %963 : i64 to i32
              %1288 = arith.muli %1289, %1290 : i32
              %1292 = arith.index_cast %1258 : index to i32
              %1291 = arith.addi %1288, %1292 : i32
              %1293 = arith.extsi %1291 : i32 to i64
              %1294 = llvm.getelementptr %1075[%1293] : (!llvm.ptr, i64) -> !llvm.ptr, i64
              llvm.store %1287, %1294 : i64, !llvm.ptr
              %1295 = arith.addi %1258, %1250 : index
              cf.br ^bb201(%1295 : index)
            ^bb203(%1296: index):
            %1297 = arith.addi %1234, %1226 : index
            cf.br ^bb195(%1297 : index)
          ^bb197(%1298: index):
          %1299 = arith.addi %1222, %1214 : index
          cf.br ^bb192(%1299 : index)
        ^bb194(%1300: index):
        %1301 = arith.constant 0 : i32
        %1302 = arith.muli %963, %963 : i64
        %1303 = arith.index_cast %1301 : i32 to index
        %1304 = arith.index_cast %1302 : i32 to index
        %1306 = arith.constant 1 : index
        %1307 = arith.constant -1 : index
        %1308 = arith.cmpi sle, %1303, %1304 : index
        %1305 = arith.select %1308, %1306, %1307 : index
        cf.br ^bb204(%1303 : index)
        ^bb204(%1309: index):
        %1310 = arith.cmpi slt, %1309, %1304 : index
        %1311 = arith.cmpi sgt, %1309, %1304 : index
        %1312 = arith.select %1308, %1310, %1311 : i1
        cf.cond_br %1312, ^bb205(%1309 : index), ^bb206(%1309 : index)
        ^bb205(%1313: index):
          %1315 = arith.index_cast %1313 : index to i64
          %1316 = llvm.getelementptr %1075[%1315] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          %1314 = llvm.load %1316 : !llvm.ptr -> i64
          %1317 = arith.index_cast %1313 : index to i64
          %1318 = llvm.getelementptr %1048[%1317] : (!llvm.ptr, i64) -> !llvm.ptr, i64
          llvm.store %1314, %1318 : i64, !llvm.ptr
          %1319 = arith.addi %1313, %1305 : index
          cf.br ^bb204(%1319 : index)
        ^bb206(%1320: index):
        cf.br ^bb188
      ^bb187:
        cf.br ^bb188
      ^bb188:
      cf.br ^bb165
    ^bb167:
    %1321 = arith.constant 0 : i32
    %1322 = arith.extsi %1321 : i32 to i64
    %1323 = llvm.mlir.constant(1 : i64) : i64
    %1324 = llvm.alloca %1323 x i64 : (i64) -> !llvm.ptr
    llvm.store %1322, %1324 : i64, !llvm.ptr
    %1325 = arith.constant 0 : i32
    %1326 = arith.index_cast %1325 : i32 to index
    %1327 = arith.index_cast %963 : i32 to index
    %1329 = arith.constant 1 : index
    %1330 = arith.constant -1 : index
    %1331 = arith.cmpi sle, %1326, %1327 : index
    %1328 = arith.select %1331, %1329, %1330 : index
    cf.br ^bb207(%1326 : index)
    ^bb207(%1332: index):
    %1333 = arith.cmpi slt, %1332, %1327 : index
    %1334 = arith.cmpi sgt, %1332, %1327 : index
    %1335 = arith.select %1331, %1333, %1334 : i1
    cf.cond_br %1335, ^bb208(%1332 : index), ^bb209(%1332 : index)
    ^bb208(%1336: index):
      %1339 = arith.index_cast %1336 : index to i64
      %1340 = llvm.getelementptr %934[%1339] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %1338 = llvm.load %1340 : !llvm.ptr -> i64
      %1337 = func.call @unpack_inT(%1338) : (i64) -> i64
      %1343 = arith.index_cast %1336 : index to i64
      %1344 = llvm.getelementptr %934[%1343] : (!llvm.ptr, i64) -> !llvm.ptr, i64
      %1342 = llvm.load %1344 : !llvm.ptr -> i64
      %1341 = func.call @unpack_inB(%1342) : (i64) -> i64
      %1345 = arith.constant 0 : i32
      %1347 = arith.extsi %1345 : i32 to i64
      %1346 = arith.cmpi eq, %1337, %1347 : i64
      %1348 = scf.if %1346 -> (i1) {
        %1349 = arith.constant 0 : i32
        %1351 = arith.extsi %1349 : i32 to i64
        %1350 = arith.cmpi eq, %1341, %1351 : i64
        scf.yield %1350 : i1
      } else {
        %1352 = arith.constant false
        scf.yield %1352 : i1
      }
      cf.cond_br %1348, ^bb210, ^bb211
      ^bb210:
        %1353 = llvm.load %1324 : !llvm.ptr -> i64
        %1355 = arith.index_cast %1336 : index to i64
        %1356 = llvm.getelementptr %1026[%1355] : (!llvm.ptr, i64) -> !llvm.ptr, i64
        %1354 = llvm.load %1356 : !llvm.ptr -> i64
        %1357 = arith.addi %1353, %1354 : i64
        %1358 = llvm.mlir.addressof @MOD : !llvm.ptr
        %1359 = llvm.load %1358 : !llvm.ptr -> i64
        %1360 = arith.remsi %1357, %1359 : i64
        llvm.store %1360, %1324 : i64, !llvm.ptr
        cf.br ^bb212
      ^bb211:
        cf.br ^bb212
      ^bb212:
      %1361 = arith.addi %1336, %1328 : index
      cf.br ^bb207(%1361 : index)
    ^bb209(%1362: index):
    %1363 = llvm.mlir.addressof @str_0 : !llvm.ptr
    %1364 = llvm.load %1324 : !llvm.ptr -> i64
    %1365 = llvm.call @printf(%1363, %1364) vararg(!llvm.func<i32 (ptr, ...)>) : (!llvm.ptr, i64) -> i32
    func.call @free(%1075) : (!llvm.ptr) -> ()
    func.call @free(%1072) : (!llvm.ptr) -> ()
    func.call @free(%1048) : (!llvm.ptr) -> ()
    func.call @free(%1026) : (!llvm.ptr) -> ()
    func.call @free(%1016) : (!llvm.ptr) -> ()
    func.call @free(%964) : (!llvm.ptr) -> ()
    func.call @free(%955) : (!llvm.ptr) -> ()
    func.call @free(%947) : (!llvm.ptr) -> ()
    func.call @free(%939) : (!llvm.ptr) -> ()
    func.call @free(%934) : (!llvm.ptr) -> ()
    %1376 = arith.constant 0 : i32
    func.return %1376 : i32
  }
}