Problem 1001

Connections I: connectivity number of a chord diagram, mod 1003443221. Leftist heap + DSU + Fenwick/interval DP.

Answer256899492
Output256899492
StatusPASS
Native helperno
Runtime1480 ms
Peak memory3728 KB
Time complexityO(n log n) (estimated)
Space complexityO(n^2) (estimated)

Performance comparison

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

Flow source

# Project Euler 1001
# Connections I: connectivity number of a chord diagram, mod 1003443221.
# Leftist heap + DSU + Fenwick/interval DP.

extern {
    function fopen(path: string, mode: string) -> ptr<void>
    function fclose(f: ptr<void>) -> i32
    function fseek(f: ptr<void>, off: i64, whence: i32) -> i32
    function ftell(f: ptr<void>) -> i64
    function fread(buf: ptr<void>, size: i64, nmemb: i64, f: ptr<void>) -> i64
    function calloc(n: i64, size: i64) -> ptr<void>
    function free(p: ptr<void>) -> void
}

const MOD: i64 = 1003443221

struct Cand {
    right: i32,
    node: i32,
    root: i32
}

# ---- DSU with path compression ----

function find(parent: ptr<i32>, x0: i32) -> i32 {
    let mut root: i32 = x0
    while parent[root] != root {
        root = parent[root]
    }
    let mut x: i32 = x0
    while parent[x] != root {
        let nxt: i32 = parent[x]
        parent[x] = root
        x = nxt
    }
    return root
}

# ---- leftist heap meld (recursive) ----

function meld(right_end: ptr<i32>, hl: ptr<i32>, hr: ptr<i32>, hrank: ptr<i32>,
              a0: i32, b0: i32) -> i32 {
    let a: i32 = a0
    let b: i32 = b0
    if a < 0 { return b }
    if b < 0 { return a }
    let mut aa: i32 = a
    let mut bb: i32 = b
    if right_end[aa] > right_end[bb] {
        let t: i32 = aa
        aa = bb
        bb = t
    }
    hr[aa] = meld(right_end, hl, hr, hrank, hr[aa], bb)
    let lc: i32 = hl[aa]
    let rc: i32 = hr[aa]
    let lr: i32 = if lc < 0 { 0 } else { hrank[lc] }
    let rr: i32 = if rc < 0 { 0 } else { hrank[rc] }
    if lr < rr {
        hl[aa] = rc
        hr[aa] = lc
    }
    hrank[aa] = (if lr < rr { lr } else { rr }) + 1
    return aa
}

function pop_heap(right_end: ptr<i32>, hl: ptr<i32>, hr: ptr<i32>, hrank: ptr<i32>,
                  node: i32) -> i32 {
    return meld(right_end, hl, hr, hrank, hl[node], hr[node])
}

function union_dsu(parent: ptr<i32>, sz: ptr<i32>, comp_heap: ptr<i32>,
                   hl: ptr<i32>, hr: ptr<i32>, hrank: ptr<i32>, right_end: ptr<i32>,
                   a0: i32, b0: i32) -> i32 {
    let mut a: i32 = find(parent, a0)
    let mut b: i32 = find(parent, b0)
    if a == b { return a }
    if sz[a] < sz[b] {
        let t: i32 = a
        a = b
        b = t
    }
    parent[b] = a
    sz[a] = sz[a] + sz[b]
    comp_heap[a] = meld(right_end, hl, hr, hrank, comp_heap[a], comp_heap[b])
    comp_heap[b] = -1
    return a
}

# ---- candidate min-heap (ordered by right) ----

function cand_push(h: ptr<Cand>, pn: ptr<i32>, c: Cand) -> void {
    let n: i32 = pn[0]
    let i: i32 = n
    h[i] = c
    pn[0] = n + 1
    let mut ii: i32 = i
    while ii > 0 {
        let p: i32 = (ii - 1) / 2
        if h[ii].right < h[p].right {
            let t: Cand = h[ii]
            h[ii] = h[p]
            h[p] = t
            ii = p
        } else {
            ii = 0
        }
    }
}

function cand_pop(h: ptr<Cand>, pn: ptr<i32>) -> void {
    let n: i32 = pn[0] - 1
    pn[0] = n
    h[0] = h[n]
    let mut i: i32 = 0
    let mut cont: bool = true
    while cont {
        let l: i32 = 2 * i + 1
        let r: i32 = 2 * i + 2
        let sm: i32 = i
        if l < n && h[l].right < h[sm].right { sm = l }
        if r < n && h[r].right < h[sm].right { sm = r }
        if sm == i {
            cont = false
        } else {
            let t: Cand = h[i]
            h[i] = h[sm]
            h[sm] = t
            i = sm
        }
    }
}

# ---- find crossing components (sweep) ----

function find_components(left_end: ptr<i32>, right_end: ptr<i32>,
                         parent: ptr<i32>, sz: ptr<i32>,
                         hl: ptr<i32>, hr: ptr<i32>, hrank: ptr<i32>, comp_heap: ptr<i32>,
                         chord_count: i32) -> void {
    let cand: ptr<Cand> = calloc((chord_count + 1) as i64, 12) as ptr<Cand>
    let cn: ptr<i32> = calloc(1, 4) as ptr<i32>
    cn[0] = 0

    let mut chord: i32 = 0
    while chord < chord_count {
        let le: i32 = left_end[chord]
        let re: i32 = right_end[chord]
        let mut current: i32 = chord

        let mut inner: bool = true
        while inner {
            if cn[0] == 0 {
                inner = false
            } else {
                let top: Cand = cand[0]
                let rt: i32 = find(parent, top.root)

                if rt != top.root {
                    cand_pop(cand, cn)
                } else {
                    let chr: i32 = comp_heap[rt]
                    if chr != top.node || right_end[top.node] != top.right {
                        cand_pop(cand, cn)
                    } else {
                        if rt == find(parent, current) {
                            cand_pop(cand, cn)
                        } else {
                            if top.right <= le {
                                cand_pop(cand, cn)
                                while comp_heap[rt] >= 0 && right_end[comp_heap[rt]] <= le {
                                    comp_heap[rt] = pop_heap(right_end, hl, hr, hrank, comp_heap[rt])
                                }
                                let nhr: i32 = comp_heap[rt]
                                if nhr >= 0 {
                                    cand_push(cand, cn, Cand {
                                        right: right_end[nhr],
                                        node: nhr,
                                        root: rt
                                    })
                                }
                            } else {
                                if top.right >= re {
                                    inner = false
                                } else {
                                    cand_pop(cand, cn)
                                    current = union_dsu(parent, sz, comp_heap, hl, hr, hrank, right_end, current, rt)
                                }
                            }
                        }
                    }
                }
            }
        }

        current = find(parent, current)
        let hr2: i32 = comp_heap[current]
        if hr2 >= 0 {
            cand_push(cand, cn, Cand {
                right: right_end[hr2],
                node: hr2,
                root: current
            })
        }
        chord = chord + 1
    }

    # Path compress all.
    let mut i: i32 = 0
    while i < chord_count {
        find(parent, i)
        i = i + 1
    }

    free(cand as ptr<void>)
    free(cn as ptr<void>)
}

# ---- permutation cut ----

function permutation_cut(word: ptr<i32>, wc_len: i32) -> i32 {
    let chord_count: i32 = wc_len / 2
    let freq: ptr<i32> = calloc(chord_count as i64, 4) as ptr<i32>
    let mut repeated: i32 = 0

    let mut i: i32 = 0
    while i < chord_count {
        let c: i32 = word[i]
        if freq[c] == 1 { repeated = repeated + 1 }
        freq[c] = freq[c] + 1
        i = i + 1
    }

    let mut start: i32 = 0
    while start < chord_count {
        if repeated == 0 {
            free(freq as ptr<void>)
            return start
        }
        let outgoing: i32 = word[start]
        if freq[outgoing] == 2 { repeated = repeated - 1 }
        freq[outgoing] = freq[outgoing] - 1
        let incoming: i32 = word[start + chord_count]
        if freq[incoming] == 1 { repeated = repeated + 1 }
        freq[incoming] = freq[incoming] + 1
        start = start + 1
    }

    free(freq as ptr<void>)
    return -1
}

# ---- count via Fenwick tree for permutation diagrams ----

function count_perm_diagram(word: ptr<i32>, wc_len: i32, start: i32) -> i64 {
    let cc: i32 = wc_len / 2
    let fenwick: ptr<i64> = calloc((cc + 1) as i64, 8) as ptr<i64>
    let mut sub_count: i64 = 0

    let second_pos: ptr<i32> = calloc(cc as i64, 4) as ptr<i32>
    let mut i: i32 = 0
    while i < cc {
        let chord: i32 = word[start + cc + i]
        second_pos[chord] = i
        i = i + 1
    }

    i = 0
    while i < cc {
        let chord: i32 = word[start + i]
        let pos: i32 = second_pos[chord]

        let mut prefix: i64 = 0
        let mut idx: i32 = pos + 1
        while idx > 0 {
            prefix = (prefix + fenwick[idx]) % MOD
            idx = idx - (idx & (0 - idx))
        }

        let mut ending: i64 = (1 + sub_count - prefix) % MOD
        if ending < 0 { ending = ending + MOD }
        sub_count = (sub_count + ending) % MOD

        idx = pos + 1
        while idx <= cc {
            fenwick[idx] = (fenwick[idx] + ending) % MOD
            idx = idx + (idx & (0 - idx))
        }
        i = i + 1
    }

    free(fenwick as ptr<void>)
    free(second_pos as ptr<void>)
    return (sub_count + 1) % MOD
}

# ---- count via interval DP ----

function count_interval_dp(word: ptr<i32>, wc_len: i32) -> i64 {
    let n: i32 = wc_len
    let mate: ptr<i32> = calloc(n as i64, 4) as ptr<i32>
    let mut i: i32 = 0
    while i < n {
        mate[i] = -1
        i = i + 1
    }

    let cc: i32 = n / 2
    let first_pos: ptr<i32> = calloc(cc as i64, 4) as ptr<i32>
    i = 0
    while i < cc {
        first_pos[i] = -1
        i = i + 1
    }

    let mut pos: i32 = 0
    while pos < n {
        let c: i32 = word[pos]
        if first_pos[c] < 0 {
            first_pos[c] = pos
        } else {
            mate[first_pos[c]] = pos
            mate[pos] = first_pos[c]
        }
        pos = pos + 1
    }

    let inside: ptr<i64> = calloc(n as i64, 8) as ptr<i64>
    let current: ptr<i64> = calloc((n + 1) as i64, 8) as ptr<i64>
    i = 0
    while i < n {
        inside[i] = 1
        i = i + 1
    }

    let mut boundary: i32 = 0
    while boundary < n {
        current[boundary + 1] = 1
        let mut pos2: i32 = boundary
        while pos2 >= 0 {
            let other: i32 = mate[pos2]
            let mut val: i64 = current[pos2 + 1]
            if pos2 < other && other <= boundary {
                val = (val + inside[pos2] * current[other + 1]) % MOD
            }
            current[pos2] = val
            pos2 = pos2 - 1
        }
        let next_pos: i32 = boundary + 1
        if next_pos < n && mate[next_pos] < next_pos {
            let le: i32 = mate[next_pos]
            inside[le] = current[le + 1]
        }
        boundary = boundary + 1
    }

    let result: i64 = current[0]
    free(mate as ptr<void>)
    free(first_pos as ptr<void>)
    free(inside as ptr<void>)
    free(current as ptr<void>)
    return result
}

function count_component(word: ptr<i32>, wc_len: i32) -> i64 {
    let start: i32 = permutation_cut(word, wc_len)
    if start >= 0 {
        return count_perm_diagram(word, wc_len, start)
    }
    return count_interval_dp(word, wc_len)
}

function main() -> i32 {
    let f: ptr<void> = fopen("data/p1001_input.txt", "r")
    if f == null {
        printf("failed to open data/p1001_input.txt\n")
        return 1
    }
    fseek(f, 0, 2)
    let fsz: i64 = ftell(f)
    fseek(f, 0, 0)
    let buf: ptr<i8> = calloc(fsz + 1, 1) as ptr<i8>
    fread(buf as ptr<void>, 1, fsz, f)
    buf[fsz] = 0
    fclose(f)

    # Parse comma-separated integers.
    let cap: i32 = 40001
    let values: ptr<i32> = calloc(cap as i64, 4) as ptr<i32>
    let mut n: i32 = 0
    let mut p: i64 = 0
    let mut ch: i8 = buf[p]
    while ch != 0 {
        # skip whitespace
        while ch != 0 {
            if ch != 32 && ch != 10 && ch != 13 && ch != 9 { break }
            p = p + 1
            ch = buf[p]
        }
        if ch == 0 { break }
        let mut val: i32 = 0
        while ch >= 48 && ch <= 57 {
            val = val * 10 + (ch - 48) as i32
            p = p + 1
            ch = buf[p]
        }
        values[n] = val
        n = n + 1
        # skip to next comma
        while ch != 0 && ch != 44 {
            p = p + 1
            ch = buf[p]
        }
        if ch == 44 {
            p = p + 1
            ch = buf[p]
        }
    }
    free(buf as ptr<void>)

    let chord_count: i32 = n / 2

    # Parse chords.
    let left_end: ptr<i32> = calloc(chord_count as i64, 4) as ptr<i32>
    let right_end: ptr<i32> = calloc(chord_count as i64, 4) as ptr<i32>
    let chord_at: ptr<i32> = calloc(n as i64, 4) as ptr<i32>

    let mut max_val: i32 = 0
    let mut i: i32 = 0
    while i < n {
        if values[i] > max_val { max_val = values[i] }
        i = i + 1
    }
    let open_chord: ptr<i32> = calloc((max_val + 1) as i64, 4) as ptr<i32>
    let mut j: i32 = 0
    while j <= max_val {
        open_chord[j] = -1
        j = j + 1
    }

    let mut nc: i32 = 0
    let mut pos: i32 = 0
    while pos < n {
        let v: i32 = values[pos]
        let c: i32 = open_chord[v]
        if c < 0 {
            let cn: i32 = nc
            nc = nc + 1
            open_chord[v] = cn
            left_end[cn] = pos
            right_end[cn] = -1
            chord_at[pos] = cn
        } else {
            right_end[c] = pos
            open_chord[v] = -1
            chord_at[pos] = c
        }
        pos = pos + 1
    }
    free(open_chord as ptr<void>)

    # DSU + leftist heap arrays.
    let parent: ptr<i32> = calloc(chord_count as i64, 4) as ptr<i32>
    let sz: ptr<i32> = calloc(chord_count as i64, 4) as ptr<i32>
    let hl: ptr<i32> = calloc(chord_count as i64, 4) as ptr<i32>
    let hr: ptr<i32> = calloc(chord_count as i64, 4) as ptr<i32>
    let hrank: ptr<i32> = calloc(chord_count as i64, 4) as ptr<i32>
    let comp_heap: ptr<i32> = calloc(chord_count as i64, 4) as ptr<i32>

    let mut k: i32 = 0
    while k < chord_count {
        parent[k] = k
        sz[k] = 1
        hl[k] = -1
        hr[k] = -1
        hrank[k] = 1
        comp_heap[k] = k
        k = k + 1
    }

    find_components(left_end, right_end, parent, sz, hl, hr, hrank, comp_heap, chord_count)

    # Group chords by root.
    let comp_word_count: ptr<i32> = calloc(chord_count as i64, 4) as ptr<i32>
    i = 0
    while i < n {
        let r: i32 = find(parent, chord_at[i])
        comp_word_count[r] = comp_word_count[r] + 1
        i = i + 1
    }

    let comp_words: ptr<ptr<i32> > = calloc(chord_count as i64, 8) as ptr<ptr<i32> >
    i = 0
    while i < chord_count {
        if comp_word_count[i] > 0 {
            comp_words[i] = calloc(comp_word_count[i] as i64, 4) as ptr<i32>
        }
        i = i + 1
    }
    let comp_idx: ptr<i32> = calloc(chord_count as i64, 4) as ptr<i32>
    i = 0
    while i < n {
        let r: i32 = find(parent, chord_at[i])
        comp_words[r][comp_idx[r]] = chord_at[i]
        comp_idx[r] = comp_idx[r] + 1
        i = i + 1
    }

    # Multiply component counts.
    let mut answer: i64 = 1
    i = 0
    while i < chord_count {
        if comp_word_count[i] > 0 {
            let c: i64 = count_component(comp_words[i], comp_word_count[i])
            answer = answer * c % MOD
        }
        i = i + 1
    }

    printf("%lld\n", answer)

    # Cleanup.
    i = 0
    while i < chord_count {
        if comp_words[i] != null { free(comp_words[i] as ptr<void>) }
        i = i + 1
    }
    free(comp_words as ptr<void>)
    free(comp_idx as ptr<void>)
    free(comp_word_count as ptr<void>)
    free(left_end as ptr<void>)
    free(right_end as ptr<void>)
    free(chord_at as ptr<void>)
    free(parent as ptr<void>)
    free(sz as ptr<void>)
    free(hl as ptr<void>)
    free(hr as ptr<void>)
    free(hrank as ptr<void>)
    free(comp_heap as ptr<void>)
    free(values as ptr<void>)
    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; }

typedef struct Cand Cand;

struct Cand {
    int32_t right;
    int32_t node;
    int32_t root;
};

int32_t find_ptr_i32_i32(int32_t* parent, int32_t x0);
int32_t meld_ptr_i32_ptr_i32_ptr_i32_ptr_i32_i32_i32(int32_t* right_end, int32_t* hl, int32_t* hr, int32_t* hrank, int32_t a0, int32_t b0);
int32_t pop_heap_ptr_i32_ptr_i32_ptr_i32_ptr_i32_i32(int32_t* right_end, int32_t* hl, int32_t* hr, int32_t* hrank, int32_t node);
int32_t union_dsu_ptr_i32_ptr_i32_ptr_i32_ptr_i32_ptr_i32_ptr_i32_ptr_i32_i32_i32(int32_t* parent, int32_t* sz, int32_t* comp_heap, int32_t* hl, int32_t* hr, int32_t* hrank, int32_t* right_end, int32_t a0, int32_t b0);
void cand_push_ptr_Cand_ptr_i32_Cand(Cand* h, int32_t* pn, Cand c);
void cand_pop_ptr_Cand_ptr_i32(Cand* h, int32_t* pn);
void find_components_ptr_i32_ptr_i32_ptr_i32_ptr_i32_ptr_i32_ptr_i32_ptr_i32_ptr_i32_i32(int32_t* left_end, int32_t* right_end, int32_t* parent, int32_t* sz, int32_t* hl, int32_t* hr, int32_t* hrank, int32_t* comp_heap, int32_t chord_count);
int32_t permutation_cut_ptr_i32_i32(int32_t* word, int32_t wc_len);
int64_t count_perm_diagram_ptr_i32_i32_i32(int32_t* word, int32_t wc_len, int32_t start);
int64_t count_interval_dp_ptr_i32_i32(int32_t* word, int32_t wc_len);
int64_t count_component_ptr_i32_i32(int32_t* word, int32_t wc_len);
int32_t main(void);

static const int64_t MOD = 1003443221;








int32_t find_ptr_i32_i32(int32_t* parent, int32_t x0) {
    int32_t root = x0;
    while (parent[root] != root) {
        root = parent[root];
    }
    int32_t x = x0;
    while (parent[x] != root) {
        int32_t nxt = parent[x];
        parent[x] = root;
        x = nxt;
    }
    return root;
}

int32_t meld_ptr_i32_ptr_i32_ptr_i32_ptr_i32_i32_i32(int32_t* right_end, int32_t* hl, int32_t* hr, int32_t* hrank, int32_t a0, int32_t b0) {
    int32_t a = a0;
    int32_t b = b0;
    if (a < 0) {
        return b;
    }
    if (b < 0) {
        return a;
    }
    int32_t aa = a;
    int32_t bb = b;
    if (right_end[aa] > right_end[bb]) {
        int32_t t = aa;
        aa = bb;
        bb = t;
    }
    hr[aa] = meld_ptr_i32_ptr_i32_ptr_i32_ptr_i32_i32_i32(right_end, hl, hr, hrank, hr[aa], bb);
    int32_t lc = hl[aa];
    int32_t rc = hr[aa];
    int32_t lr = ((lc < 0) ? (0) : (hrank[lc]));
    int32_t rr = ((rc < 0) ? (0) : (hrank[rc]));
    if (lr < rr) {
        hl[aa] = rc;
        hr[aa] = lc;
    }
    hrank[aa] = (((lr < rr) ? (lr) : (rr)) + 1);
    return aa;
}

int32_t pop_heap_ptr_i32_ptr_i32_ptr_i32_ptr_i32_i32(int32_t* right_end, int32_t* hl, int32_t* hr, int32_t* hrank, int32_t node) {
    return meld_ptr_i32_ptr_i32_ptr_i32_ptr_i32_i32_i32(right_end, hl, hr, hrank, hl[node], hr[node]);
}

int32_t union_dsu_ptr_i32_ptr_i32_ptr_i32_ptr_i32_ptr_i32_ptr_i32_ptr_i32_i32_i32(int32_t* parent, int32_t* sz, int32_t* comp_heap, int32_t* hl, int32_t* hr, int32_t* hrank, int32_t* right_end, int32_t a0, int32_t b0) {
    int32_t a = find_ptr_i32_i32(parent, a0);
    int32_t b = find_ptr_i32_i32(parent, b0);
    if (a == b) {
        return a;
    }
    if (sz[a] < sz[b]) {
        int32_t t = a;
        a = b;
        b = t;
    }
    parent[b] = a;
    sz[a] = (sz[a] + sz[b]);
    comp_heap[a] = meld_ptr_i32_ptr_i32_ptr_i32_ptr_i32_i32_i32(right_end, hl, hr, hrank, comp_heap[a], comp_heap[b]);
    comp_heap[b] = (-1);
    return a;
}

void cand_push_ptr_Cand_ptr_i32_Cand(Cand* h, int32_t* pn, Cand c) {
    int32_t n = pn[0];
    int32_t i = n;
    h[i] = c;
    pn[0] = (n + 1);
    int32_t ii = i;
    while (ii > 0) {
        int32_t p = FLOW_CHECKED_DIV(((ii - 1)), (2));
        if (h[ii].right < h[p].right) {
            Cand t = h[ii];
            h[ii] = h[p];
            h[p] = t;
            ii = p;
        } else {
            ii = 0;
        }
    }
}

void cand_pop_ptr_Cand_ptr_i32(Cand* h, int32_t* pn) {
    int32_t n = (pn[0] - 1);
    pn[0] = n;
    h[0] = h[n];
    int32_t i = 0;
    bool cont = 1;
    while (cont) {
        int32_t l = ((2 * i) + 1);
        int32_t r = ((2 * i) + 2);
        int32_t sm = i;
        if ((l < n && h[l].right < h[sm].right)) {
            sm = l;
        }
        if ((r < n && h[r].right < h[sm].right)) {
            sm = r;
        }
        if (sm == i) {
            cont = 0;
        } else {
            Cand t = h[i];
            h[i] = h[sm];
            h[sm] = t;
            i = sm;
        }
    }
}

void find_components_ptr_i32_ptr_i32_ptr_i32_ptr_i32_ptr_i32_ptr_i32_ptr_i32_ptr_i32_i32(int32_t* left_end, int32_t* right_end, int32_t* parent, int32_t* sz, int32_t* hl, int32_t* hr, int32_t* hrank, int32_t* comp_heap, int32_t chord_count) {
    Cand* cand = (Cand*)(((Cand*)(calloc(((int64_t)((chord_count + 1))), 12))));
    int32_t* cn = (int32_t*)(((int32_t*)(calloc(1, 4))));
    cn[0] = 0;
    int32_t chord = 0;
    while (chord < chord_count) {
        int32_t le = left_end[chord];
        int32_t re = right_end[chord];
        int32_t current = chord;
        bool inner = 1;
        while (inner) {
            if (cn[0] == 0) {
                inner = 0;
            } else {
                Cand top = cand[0];
                int32_t rt = find_ptr_i32_i32(parent, top.root);
                if (rt != top.root) {
                    cand_pop_ptr_Cand_ptr_i32(cand, cn);
                } else {
                    int32_t chr = comp_heap[rt];
                    if ((chr != top.node || right_end[top.node] != top.right)) {
                        cand_pop_ptr_Cand_ptr_i32(cand, cn);
                    } else {
                        if (rt == find_ptr_i32_i32(parent, current)) {
                            cand_pop_ptr_Cand_ptr_i32(cand, cn);
                        } else {
                            if (top.right <= le) {
                                cand_pop_ptr_Cand_ptr_i32(cand, cn);
                                while ((comp_heap[rt] >= 0 && right_end[comp_heap[rt]] <= le)) {
                                    comp_heap[rt] = pop_heap_ptr_i32_ptr_i32_ptr_i32_ptr_i32_i32(right_end, hl, hr, hrank, comp_heap[rt]);
                                }
                                int32_t nhr = comp_heap[rt];
                                if (nhr >= 0) {
                                    cand_push_ptr_Cand_ptr_i32_Cand(cand, cn, (Cand){ .right = right_end[nhr], .node = nhr, .root = rt });
                                }
                            } else {
                                if (top.right >= re) {
                                    inner = 0;
                                } else {
                                    cand_pop_ptr_Cand_ptr_i32(cand, cn);
                                    current = union_dsu_ptr_i32_ptr_i32_ptr_i32_ptr_i32_ptr_i32_ptr_i32_ptr_i32_i32_i32(parent, sz, comp_heap, hl, hr, hrank, right_end, current, rt);
                                }
                            }
                        }
                    }
                }
            }
        }
        current = find_ptr_i32_i32(parent, current);
        int32_t hr2 = comp_heap[current];
        if (hr2 >= 0) {
            cand_push_ptr_Cand_ptr_i32_Cand(cand, cn, (Cand){ .right = right_end[hr2], .node = hr2, .root = current });
        }
        chord = (chord + 1);
    }
    int32_t i = 0;
    while (i < chord_count) {
        find_ptr_i32_i32(parent, i);
        i = (i + 1);
    }
    free(((void*)(cand)));
    free(((void*)(cn)));
}

int32_t permutation_cut_ptr_i32_i32(int32_t* word, int32_t wc_len) {
    int32_t chord_count = FLOW_CHECKED_DIV((wc_len), (2));
    int32_t* freq = (int32_t*)(((int32_t*)(calloc(((int64_t)(chord_count)), 4))));
    int32_t repeated = 0;
    int32_t i = 0;
    while (i < chord_count) {
        int32_t c = word[i];
        if (freq[c] == 1) {
            repeated = (repeated + 1);
        }
        freq[c] = (freq[c] + 1);
        i = (i + 1);
    }
    int32_t start = 0;
    while (start < chord_count) {
        if (repeated == 0) {
            free(((void*)(freq)));
            return start;
        }
        int32_t outgoing = word[start];
        if (freq[outgoing] == 2) {
            repeated = (repeated - 1);
        }
        freq[outgoing] = (freq[outgoing] - 1);
        int32_t incoming = word[(start + chord_count)];
        if (freq[incoming] == 1) {
            repeated = (repeated + 1);
        }
        freq[incoming] = (freq[incoming] + 1);
        start = (start + 1);
    }
    free(((void*)(freq)));
    return (-1);
}

int64_t count_perm_diagram_ptr_i32_i32_i32(int32_t* word, int32_t wc_len, int32_t start) {
    int32_t cc = FLOW_CHECKED_DIV((wc_len), (2));
    int64_t* fenwick = (int64_t*)(((int64_t*)(calloc(((int64_t)((cc + 1))), 8))));
    int64_t sub_count = 0;
    int32_t* second_pos = (int32_t*)(((int32_t*)(calloc(((int64_t)(cc)), 4))));
    int32_t i = 0;
    while (i < cc) {
        int32_t chord = word[((start + cc) + i)];
        second_pos[chord] = i;
        i = (i + 1);
    }
    i = 0;
    while (i < cc) {
        int32_t chord = word[(start + i)];
        int32_t pos = second_pos[chord];
        int64_t prefix = 0;
        int32_t idx = (pos + 1);
        while (idx > 0) {
            prefix = FLOW_CHECKED_MOD(((prefix + fenwick[idx])), (MOD));
            idx = (idx - (idx & (0 - idx)));
        }
        int64_t ending = FLOW_CHECKED_MOD((((1 + sub_count) - prefix)), (MOD));
        if (ending < 0) {
            ending = (ending + MOD);
        }
        sub_count = FLOW_CHECKED_MOD(((sub_count + ending)), (MOD));
        idx = (pos + 1);
        while (idx <= cc) {
            fenwick[idx] = FLOW_CHECKED_MOD(((fenwick[idx] + ending)), (MOD));
            idx = (idx + (idx & (0 - idx)));
        }
        i = (i + 1);
    }
    free(((void*)(fenwick)));
    free(((void*)(second_pos)));
    return FLOW_CHECKED_MOD(((sub_count + 1)), (MOD));
}

int64_t count_interval_dp_ptr_i32_i32(int32_t* word, int32_t wc_len) {
    int32_t n = wc_len;
    int32_t* mate = (int32_t*)(((int32_t*)(calloc(((int64_t)(n)), 4))));
    int32_t i = 0;
    while (i < n) {
        mate[i] = (-1);
        i = (i + 1);
    }
    int32_t cc = FLOW_CHECKED_DIV((n), (2));
    int32_t* first_pos = (int32_t*)(((int32_t*)(calloc(((int64_t)(cc)), 4))));
    i = 0;
    while (i < cc) {
        first_pos[i] = (-1);
        i = (i + 1);
    }
    int32_t pos = 0;
    while (pos < n) {
        int32_t c = word[pos];
        if (first_pos[c] < 0) {
            first_pos[c] = pos;
        } else {
            mate[first_pos[c]] = pos;
            mate[pos] = first_pos[c];
        }
        pos = (pos + 1);
    }
    int64_t* inside = (int64_t*)(((int64_t*)(calloc(((int64_t)(n)), 8))));
    int64_t* current = (int64_t*)(((int64_t*)(calloc(((int64_t)((n + 1))), 8))));
    i = 0;
    while (i < n) {
        inside[i] = 1;
        i = (i + 1);
    }
    int32_t boundary = 0;
    while (boundary < n) {
        current[(boundary + 1)] = 1;
        int32_t pos2 = boundary;
        while (pos2 >= 0) {
            int32_t other = mate[pos2];
            int64_t val = current[(pos2 + 1)];
            if ((pos2 < other && other <= boundary)) {
                val = FLOW_CHECKED_MOD(((val + (inside[pos2] * current[(other + 1)]))), (MOD));
            }
            current[pos2] = val;
            pos2 = (pos2 - 1);
        }
        int32_t next_pos = (boundary + 1);
        if ((next_pos < n && mate[next_pos] < next_pos)) {
            int32_t le = mate[next_pos];
            inside[le] = current[(le + 1)];
        }
        boundary = (boundary + 1);
    }
    int64_t result = current[0];
    free(((void*)(mate)));
    free(((void*)(first_pos)));
    free(((void*)(inside)));
    free(((void*)(current)));
    return result;
}

int64_t count_component_ptr_i32_i32(int32_t* word, int32_t wc_len) {
    int32_t start = permutation_cut_ptr_i32_i32(word, wc_len);
    if (start >= 0) {
        return count_perm_diagram_ptr_i32_i32_i32(word, wc_len, start);
    }
    return count_interval_dp_ptr_i32_i32(word, wc_len);
}

int32_t main(void) {
    void* f = (void*)(fopen("data/p1001_input.txt", "r"));
    if (f == NULL) {
        printf("failed to open data/p1001_input.txt\n");
        return 1;
    }
    fseek(f, 0, 2);
    int64_t fsz = ftell(f);
    fseek(f, 0, 0);
    int8_t* buf = (int8_t*)(((int8_t*)(calloc((fsz + 1), 1))));
    fread(((void*)(buf)), 1, fsz, f);
    buf[fsz] = 0;
    fclose(f);
    int32_t cap = 40001;
    int32_t* values = (int32_t*)(((int32_t*)(calloc(((int64_t)(cap)), 4))));
    int32_t n = 0;
    int64_t p = 0;
    int8_t ch = buf[p];
    while (ch != 0) {
        while (ch != 0) {
            if ((((ch != 32 && ch != 10) && ch != 13) && ch != 9)) {
                break;
            }
            p = (p + 1);
            ch = buf[p];
        }
        if (ch == 0) {
            break;
        }
        int32_t val = 0;
        while ((ch >= 48 && ch <= 57)) {
            val = ((val * 10) + ((int32_t)((ch - 48))));
            p = (p + 1);
            ch = buf[p];
        }
        values[n] = val;
        n = (n + 1);
        while ((ch != 0 && ch != 44)) {
            p = (p + 1);
            ch = buf[p];
        }
        if (ch == 44) {
            p = (p + 1);
            ch = buf[p];
        }
    }
    free(((void*)(buf)));
    int32_t chord_count = FLOW_CHECKED_DIV((n), (2));
    int32_t* left_end = (int32_t*)(((int32_t*)(calloc(((int64_t)(chord_count)), 4))));
    int32_t* right_end = (int32_t*)(((int32_t*)(calloc(((int64_t)(chord_count)), 4))));
    int32_t* chord_at = (int32_t*)(((int32_t*)(calloc(((int64_t)(n)), 4))));
    int32_t max_val = 0;
    int32_t i = 0;
    while (i < n) {
        if (values[i] > max_val) {
            max_val = values[i];
        }
        i = (i + 1);
    }
    int32_t* open_chord = (int32_t*)(((int32_t*)(calloc(((int64_t)((max_val + 1))), 4))));
    int32_t j = 0;
    while (j <= max_val) {
        open_chord[j] = (-1);
        j = (j + 1);
    }
    int32_t nc = 0;
    int32_t pos = 0;
    while (pos < n) {
        int32_t v = values[pos];
        int32_t c = open_chord[v];
        if (c < 0) {
            int32_t cn = nc;
            nc = (nc + 1);
            open_chord[v] = cn;
            left_end[cn] = pos;
            right_end[cn] = (-1);
            chord_at[pos] = cn;
        } else {
            right_end[c] = pos;
            open_chord[v] = (-1);
            chord_at[pos] = c;
        }
        pos = (pos + 1);
    }
    free(((void*)(open_chord)));
    int32_t* parent = (int32_t*)(((int32_t*)(calloc(((int64_t)(chord_count)), 4))));
    int32_t* sz = (int32_t*)(((int32_t*)(calloc(((int64_t)(chord_count)), 4))));
    int32_t* hl = (int32_t*)(((int32_t*)(calloc(((int64_t)(chord_count)), 4))));
    int32_t* hr = (int32_t*)(((int32_t*)(calloc(((int64_t)(chord_count)), 4))));
    int32_t* hrank = (int32_t*)(((int32_t*)(calloc(((int64_t)(chord_count)), 4))));
    int32_t* comp_heap = (int32_t*)(((int32_t*)(calloc(((int64_t)(chord_count)), 4))));
    int32_t k = 0;
    while (k < chord_count) {
        parent[k] = k;
        sz[k] = 1;
        hl[k] = (-1);
        hr[k] = (-1);
        hrank[k] = 1;
        comp_heap[k] = k;
        k = (k + 1);
    }
    find_components_ptr_i32_ptr_i32_ptr_i32_ptr_i32_ptr_i32_ptr_i32_ptr_i32_ptr_i32_i32(left_end, right_end, parent, sz, hl, hr, hrank, comp_heap, chord_count);
    int32_t* comp_word_count = (int32_t*)(((int32_t*)(calloc(((int64_t)(chord_count)), 4))));
    i = 0;
    while (i < n) {
        int32_t r = find_ptr_i32_i32(parent, chord_at[i]);
        comp_word_count[r] = (comp_word_count[r] + 1);
        i = (i + 1);
    }
    int32_t** comp_words = (int32_t**)(((int32_t**)(calloc(((int64_t)(chord_count)), 8))));
    i = 0;
    while (i < chord_count) {
        if (comp_word_count[i] > 0) {
            comp_words[i] = ((int32_t*)(calloc(((int64_t)(comp_word_count[i])), 4)));
        }
        i = (i + 1);
    }
    int32_t* comp_idx = (int32_t*)(((int32_t*)(calloc(((int64_t)(chord_count)), 4))));
    i = 0;
    while (i < n) {
        int32_t r = find_ptr_i32_i32(parent, chord_at[i]);
        comp_words[r][comp_idx[r]] = chord_at[i];
        comp_idx[r] = (comp_idx[r] + 1);
        i = (i + 1);
    }
    int64_t answer = 1;
    i = 0;
    while (i < chord_count) {
        if (comp_word_count[i] > 0) {
            int64_t c = count_component_ptr_i32_i32(comp_words[i], comp_word_count[i]);
            answer = FLOW_CHECKED_MOD(((answer * c)), (MOD));
        }
        i = (i + 1);
    }
    printf("%lld\n", answer);
    i = 0;
    while (i < chord_count) {
        if (comp_words[i] != NULL) {
            free(((void*)(comp_words[i])));
        }
        i = (i + 1);
    }
    free(((void*)(comp_words)));
    free(((void*)(comp_idx)));
    free(((void*)(comp_word_count)));
    free(((void*)(left_end)));
    free(((void*)(right_end)));
    free(((void*)(chord_at)));
    free(((void*)(parent)));
    free(((void*)(sz)));
    free(((void*)(hl)));
    free(((void*)(hr)));
    free(((void*)(hrank)));
    free(((void*)(comp_heap)));
    free(((void*)(values)));
    return 0;
}

Generated MLIR

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