// File: /workspace/github_c_makefile_star2_O0/c-zhou[P]oatk/path.c
// Function: graph_path_extension
static llnode **graph_path_extension(asmg_t *g, llnode *root, kh_u32_t *seg_dups, int max_path, uint64_t *n_leaf, int *_exceed_limit)
{
    uint64_t i, j, v, w, nv;
    int skip, exceed_limit;
    llnode *next_node, *node;
    kdq_llnodep_t *node_q;
    void *km;
    asmg_arc_t *av;
    khint32_t k32;

    kvec_t(llnodep) leaf_node;
    kvec_t(uint32_t) dups;

    kv_init(leaf_node);
    kv_init(dups);
    km = km_init();
    node_q = kdq_init_llnodep(km);

    exceed_limit = 0;
    *kdq_pushp_llnodep(node_q) = root;

    while (kdq_size(node_q) > 0) {
        node = *kdq_shift_llnodep(node_q);
        v = node->v;
        nv = asmg_arc_n(g, v);
        av = asmg_arc_a(g, v);
        dups.n = 0;
        for (i = 0; i < nv; ++i) {
            if (av[i].del) continue;

            w = av[i].w;
            skip = 0;
            k32 = kh_u32_get(seg_dups, w >> 1);
            if (k32 < kh_end(seg_dups)) {
                // dup seg
                // check if already processed
                for (j = 0; j < dups.n; ++j) {
                    if (dups.a[j] == kh_val(seg_dups, k32)) {
                        skip = 1;
                        break;
                    }
                }
            }

            if (!skip && !path_contain_vertex(node, w)) {
                next_node = new_node(w);
                next_node->prev = node;
                add_next(node, next_node);
                *kdq_pushp_llnodep(node_q) = next_node;
                
                if (k32 < kh_end(seg_dups))
                    kv_push(uint32_t, dups, kh_val(seg_dups, k32));
            }
        }

        if (node->n_n == 0) {
            // leaf node
            kv_push(llnodep, leaf_node, node);
        }
        
        if (kdq_size(node_q) + leaf_node.n > max_path) {
            exceed_limit = 1;
            break;
        }
    }

    kdq_destroy_llnodep(node_q);
    km_destroy(km);
    kv_destroy(dups);

    if (exceed_limit) {
        *n_leaf = 0;
        *_exceed_limit = 1;
        kv_destroy(leaf_node);
        return 0;
    } else {
        *n_leaf = leaf_node.n;
        *_exceed_limit = 0;
        return leaf_node.a;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x100, %rsp            # imm = 0x100
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movl %ecx, -0x24(%rbp)
movq %r8, -0x30(%rbp)
movq %r9, -0x38(%rbp)
movq $0x0, -0xa8(%rbp)
movq $0x0, -0xb0(%rbp)
movq $0x0, -0xa0(%rbp)
movq $0x0, -0xc0(%rbp)
movq $0x0, -0xc8(%rbp)
movq $0x0, -0xb8(%rbp)
callq 0x21230
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rdi
callq 0x14690
movq %rax, -0x80(%rbp)
movl $0x0, -0x68(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0xd0(%rbp)
movq -0x80(%rbp), %rdi
callq 0x146b0
movq -0xd0(%rbp), %rcx
movq %rcx, (%rax)
movq -0x80(%rbp), %rax
cmpq $0x0, 0x8(%rax)
jbe 0x813d
movq -0x80(%rbp), %rdi
callq 0x14740
movq (%rax), %rax
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rax
movl (%rax), %eax
movq %rax, -0x50(%rbp)
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rax
movq -0x50(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x60(%rbp)
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movq -0x10(%rbp), %rcx
movq 0x30(%rcx), %rcx
movq -0x50(%rbp), %rdx
imulq $0x30, (%rcx,%rdx,8), %rcx
addq %rcx, %rax
movq %rax, -0x90(%rbp)
movq $0x0, -0xc8(%rbp)
movq $0x0, -0x40(%rbp)
movq -0x40(%rbp), %rax
cmpq -0x60(%rbp), %rax
jae 0x8079
movq -0x90(%rbp), %rax
imulq $0x30, -0x40(%rbp), %rcx
addq %rcx, %rax
movl 0x20(%rax), %eax
shrl $0x1e, %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x7e48
jmp 0x8068
movq -0x90(%rbp), %rax
imulq $0x30, -0x40(%rbp), %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movq %rax, -0x58(%rbp)
movl $0x0, -0x64(%rbp)
movq -0x20(%rbp), %rdi
movq -0x58(%rbp), %rax
shrq %rax
movl %eax, %esi
callq 0x8430
movl %eax, -0x94(%rbp)
movl -0x94(%rbp), %eax
movl %eax, -0xd4(%rbp)
movq -0x20(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x7eaa
movq -0x20(%rbp), %rax
movl (%rax), %ecx
movl $0x1, %eax
shll %cl, %eax
movl %eax, -0xd8(%rbp)
jmp 0x7eb4
xorl %eax, %eax
movl %eax, -0xd8(%rbp)
jmp 0x7eb4
movl -0xd4(%rbp), %eax
movl -0xd8(%rbp), %ecx
cmpl %ecx, %eax
jae 0x7f16
movq $0x0, -0x48(%rbp)
movq -0x48(%rbp), %rax
cmpq -0xc8(%rbp), %rax
jae 0x7f14
movq -0xb8(%rbp), %rax
movq -0x48(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movq -0x20(%rbp), %rcx
movq 0x10(%rcx), %rcx
movl -0x94(%rbp), %edx
cmpl 0x4(%rcx,%rdx,8), %eax
jne 0x7f04
movl $0x1, -0x64(%rbp)
jmp 0x7f14
jmp 0x7f06
movq -0x48(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x48(%rbp)
jmp 0x7ecc
jmp 0x7f16
cmpl $0x0, -0x64(%rbp)
jne 0x8066
movq -0x78(%rbp), %rdi
movq -0x58(%rbp), %rax
movl %eax, %esi
callq 0x14820
cmpl $0x0, %eax
jne 0x8066
movq -0x58(%rbp), %rax
movl %eax, %edi
callq 0x7c90
movq %rax, -0x70(%rbp)
movq -0x78(%rbp), %rcx
movq -0x70(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x78(%rbp), %rdi
movq -0x70(%rbp), %rsi
callq 0x81c0
movq -0x70(%rbp), %rax
movq %rax, -0xe8(%rbp)
movq -0x80(%rbp), %rdi
callq 0x146b0
movq -0xe8(%rbp), %rcx
movq %rcx, (%rax)
movl -0x94(%rbp), %eax
movl %eax, -0xdc(%rbp)
movq -0x20(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x7faa
movq -0x20(%rbp), %rax
movl (%rax), %ecx
movl $0x1, %eax
shll %cl, %eax
movl %eax, -0xec(%rbp)
jmp 0x7fb4
xorl %eax, %eax
movl %eax, -0xec(%rbp)
jmp 0x7fb4
movl -0xdc(%rbp), %eax
movl -0xec(%rbp), %ecx
cmpl %ecx, %eax
jae 0x8064
jmp 0x7fca
movq -0xc8(%rbp), %rax
cmpq -0xc0(%rbp), %rax
jne 0x8031
cmpq $0x0, -0xc0(%rbp)
je 0x7ff7
movq -0xc0(%rbp), %rax
shlq %rax
movq %rax, -0xf8(%rbp)
jmp 0x8005
movl $0x2, %eax
movq %rax, -0xf8(%rbp)
jmp 0x8005
movq -0xf8(%rbp), %rax
movq %rax, -0xc0(%rbp)
movq -0xb8(%rbp), %rdi
movq -0xc0(%rbp), %rsi
shlq $0x2, %rsi
callq 0x2330
movq %rax, -0xb8(%rbp)
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x94(%rbp), %ecx
movl 0x4(%rax,%rcx,8), %edx
movq -0xb8(%rbp), %rax
movq -0xc8(%rbp), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, -0xc8(%rbp)
movl %edx, (%rax,%rcx,4)
jmp 0x8064
jmp 0x8066
jmp 0x8068
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
jmp 0x7e18
movq -0x78(%rbp), %rax
cmpq $0x0, 0x18(%rax)
jne 0x8117
jmp 0x808a
movq -0xb0(%rbp), %rax
cmpq -0xa8(%rbp), %rax
jne 0x80f1
cmpq $0x0, -0xa8(%rbp)
je 0x80b7
movq -0xa8(%rbp), %rax
shlq %rax
movq %rax, -0x100(%rbp)
jmp 0x80c5
movl $0x2, %eax
movq %rax, -0x100(%rbp)
jmp 0x80c5
movq -0x100(%rbp), %rax
movq %rax, -0xa8(%rbp)
movq -0xa0(%rbp), %rdi
movq -0xa8(%rbp), %rsi
shlq $0x3, %rsi
callq 0x2330
movq %rax, -0xa0(%rbp)
movq -0x78(%rbp), %rdx
movq -0xa0(%rbp), %rax
movq -0xb0(%rbp), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, -0xb0(%rbp)
movq %rdx, (%rax,%rcx,8)
jmp 0x8117
movq -0x80(%rbp), %rax
movq 0x8(%rax), %rax
addq -0xb0(%rbp), %rax
movslq -0x24(%rbp), %rcx
cmpq %rcx, %rax
jbe 0x8138
movl $0x1, -0x68(%rbp)
jmp 0x813d
jmp 0x7da5
movq -0x80(%rbp), %rdi
callq 0x14870
movq -0x88(%rbp), %rdi
callq 0x21250
movq -0xb8(%rbp), %rdi
callq 0x2060
cmpl $0x0, -0x68(%rbp)
je 0x818f
movq -0x30(%rbp), %rax
movq $0x0, (%rax)
movq -0x38(%rbp), %rax
movl $0x1, (%rax)
movq -0xa0(%rbp), %rdi
callq 0x2060
movq $0x0, -0x8(%rbp)
jmp 0x81b2
movq -0xb0(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, (%rax)
movq -0x38(%rbp), %rax
movl $0x0, (%rax)
movq -0xa0(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x100, %rsp            # imm = 0x100
popq %rbp
retq
nop