// File: chhylp123[P]hifiasm/Overlaps.cpp
// Function: rd_hm_bub(asg_t*, asg_t*, unsigned int, unsigned long, buf_t*)
uint64_t rd_hm_bub(asg_t *g, asg_t *ref, uint32_t v0, uint64_t max_dist, buf_t *b)
{
    uint32_t i0, i1, n_pending = 0, is_first = 1, n_tips, tip_end; uint64_t n_pop = 0;
    uint32_t v, w, d, nv0, nv1, l, x, i; asg_arc_t *av0, *av1; binfo_t *t;
    if (g->seq[v0>>1].del) return 0; // already deleted
    nv0 = g?get_real_length(g, v0, NULL):0; 
    nv1 = ref?get_real_length(ref, v0, NULL):0;
    // if((v0 == 4386) && (!ref)) {
    //     fprintf(stderr, "[M::%s] v0>>1::%u(v0&1::%u), nv0::%u, nv1::%u\n", __func__, v0>>1, v0&1, 
    //     nv0, nv1);
    // }
    if((nv0+nv1)<2) return 0;
    // if(v0 >= (ref->n_seq<<1)) {
    //     fprintf(stderr, "[M::%s] v0::%u, ref->n_seq::%u\n", __func__, v0, ref->n_seq);
    // }
    b->S.n = b->T.n = b->b.n = b->e.n = 0;
    b->a[v0].c = b->a[v0].d = b->a[v0].m = b->a[v0].nc = b->a[v0].np = 0;
    ///b->S is the nodes with all incoming edges visited
    kv_push(uint32_t, b->S, v0);
    n_tips = 0; tip_end = (uint32_t)-1;

    do {
        ///v is a node that all incoming edges have been visited
        ///d is the distance from v0 to v
        v = kv_pop(b->S); d = b->a[v].d;
        nv0 = 0; av0 = NULL; nv1 = 0; av1 = NULL; i0 = i1 = 0;
        if(g) {
            nv0 = asg_arc_n(g, v); av0 = asg_arc_a(g, v);
        }
        if(ref) {
            nv1 = asg_arc_n(ref, v); av1 = asg_arc_a(ref, v);
        }
        // if((v0 == 4386) && (!ref)) {
        //     fprintf(stderr, "[M::%s] v0>>1::%u(v0&1::%u), v>>1::%u(v&1::%u)\n", __func__, v0>>1, v0&1, v>>1, v&1);
        // }
        ///all out-edges of v
        for (i0 = 0; i0 < nv0; ++i0) { // loop through v's neighbors
            if (av0[i0].del) continue;
            w = av0[i0].v; l = (uint32_t)av0[i0].ul; t = &b->a[w];
            // if((v0 == 4386) && (!ref)) {
            //     fprintf(stderr, "[M::%s] v0>>1::%u(v0&1::%u), w>>1::%u(w&1::%u)\n", 
            //     __func__, v0>>1, v0&1, w>>1, w&1);
            // }
            if ((w>>1) == (v0>>1)) goto pop_rd_hm_bub;
            if(is_first) l = 0;
            if (d + l > max_dist) break; // too far
            ///unvisited node
            if (t->s == 0) { // this vertex has never been visited
                kv_push(uint32_t, b->b, w); // save it for revert
                t->p = v, t->s = 1, t->d = d + l;
                t->r = (g?get_real_length(g, w^1, NULL):0)+(ref?get_real_length(ref, w^1, NULL):0);
                ++n_pending;
            } else { // visited before
                ///the shortest path
                if (d + l < t->d) t->d = d + l; // update dist
            }
            // if((v0 == 4386) && (!ref) && ((w>>1) == 2597)) {
            //     fprintf(stderr, "[M::%s] w>>1::%u(w&1::%u), t->r::%u\n", 
            //     __func__, w>>1, w&1, t->r);
            // }
            //if all incoming edges of w have visited
            //push it to b->S
            if (--(t->r) == 0) {
                x = (g?get_real_length(g, w, NULL):0)+(ref?get_real_length(ref, w, NULL):0);
                // if((v0 == 4386) && (!ref) && ((w>>1) == 2597)) {
                //     fprintf(stderr, "[M::%s] w>>1::%u(w&1::%u), t->r::%u, x::%u, b->S.n::%u\n", 
                //     __func__, w>>1, w&1, t->r, x, (uint32_t)b->S.n);
                // }
                if(x > 0) {
                    // if((v0 == 4386) && (!ref)) {
                    //     fprintf(stderr, "+[M::%s] v0>>1::%u(v0&1::%u), push_w>>1::%u(w&1::%u)\n", 
                    //     __func__, v0>>1, v0&1, w>>1, w&1);
                    //     uint32_t m;
                    //     for (m = 0; m < b->S.n; m++) {
                    //         fprintf(stderr, "+[M::%s] m>>1::%u(m&1::%u)\n", __func__, b->S.a[m]>>1, b->S.a[m]&1);
                    //     }
                    // }
                    kv_push(uint32_t, b->S, w);
                } else {
                    ///at most one tip
                    if(n_tips != 0) goto pop_rd_hm_bub;
                    n_tips++; tip_end = w;
                }
                --n_pending;
            }
        }
        if (i0 >= nv0) {
            for (i1 = 0; i1 < nv1; ++i1) { // loop through v's neighbors
                if (av1[i1].del) continue;
                w = av1[i1].v; l = (uint32_t)av1[i1].ul; t = &b->a[w];
                if ((w>>1) == (v0>>1)) goto pop_rd_hm_bub;
                if(is_first) l = 0;
                if (d + l > max_dist) break; // too far
                ///unvisited node
                if (t->s == 0) { // this vertex has never been visited
                    kv_push(uint32_t, b->b, w); // save it for revert
                    t->p = v, t->s = 1, t->d = d + l;
                    t->r = (g?get_real_length(g, w^1, NULL):0)+(ref?get_real_length(ref, w^1, NULL):0);
                    ++n_pending;
                } else { // visited before
                    ///the shortest path
                    if (d + l < t->d) t->d = d + l; // update dist
                }

                //if all incoming edges of w have visited
                //push it to b->S
                if (--(t->r) == 0) {
                    x = (g?get_real_length(g, w, NULL):0)+(ref?get_real_length(ref, w, NULL):0);
                    if(x > 0) {
                        // if((v0 == 4386) && (!ref)) {
                        //     fprintf(stderr, "-[M::%s] v0>>1::%u(v0&1::%u), push_w>>1::%u(w&1::%u)\n", 
                        //     __func__, v0>>1, v0&1, w>>1, w&1);
                        // }
                        kv_push(uint32_t, b->S, w);
                    } else {
                        ///at most one tip
                        if(n_tips != 0) goto pop_rd_hm_bub;
                        n_tips++; tip_end = w;
                    }
                    --n_pending;
                }
            }
        }

        is_first = 0;
        //if found a tip
        if(n_tips == 1) {
            if(tip_end != (uint32_t)-1 && n_pending == 0 && b->S.n == 0) {
                // if((v0 == 4386) && (!ref)) {
                //     fprintf(stderr, ">[M::%s] v0>>1::%u(v0&1::%u), push_w>>1::%u(w&1::%u)\n", 
                //     __func__, v0>>1, v0&1, tip_end>>1, tip_end&1);
                // }
                kv_push(uint32_t, b->S, tip_end);
                break;
            } else {
                goto pop_rd_hm_bub;
            }
        }
        // if((v0 == 4386) && (!ref)) {
        //     fprintf(stderr, "[M::%s] v0>>1::%u(v0&1::%u), b->S.n::%u, n_pending::%u\n", 
        //             __func__, v0>>1, v0&1, (uint32_t)b->S.n, n_pending);
        // }
        ///if i < nv, that means (d + l > max_dist)
        if (i0 < nv0 || i1 < nv1 || b->S.n == 0) goto pop_rd_hm_bub;
    } while (b->S.n > 1 || n_pending);
    n_pop = 1;
    pop_rd_hm_bub:
    for (i = 0; i < b->b.n; ++i) { // clear the states of visited vertices
        t = &b->a[b->b.a[i]];
        t->s = t->c = t->d = t->m = t->nc = t->np = 0;
    }
    return n_pop;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x100, %rsp            # imm = 0x100
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movl $0x0, -0x3c(%rbp)
movl $0x1, -0x40(%rbp)
movq $0x0, -0x50(%rbp)
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movl -0x1c(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
movl (%rax,%rcx,8), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
je 0x137d3b
movq $0x0, -0x8(%rbp)
jmp 0x138922
cmpq $0x0, -0x10(%rbp)
je 0x137d5a
movq -0x10(%rbp), %rdi
movl -0x1c(%rbp), %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x166b50
movl %eax, -0x8c(%rbp)
jmp 0x137d64
xorl %eax, %eax
movl %eax, -0x8c(%rbp)
jmp 0x137d64
movl -0x8c(%rbp), %eax
movl %eax, -0x60(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x137d8c
movq -0x18(%rbp), %rdi
movl -0x1c(%rbp), %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x166b50
movl %eax, -0x90(%rbp)
jmp 0x137d96
xorl %eax, %eax
movl %eax, -0x90(%rbp)
jmp 0x137d96
movl -0x90(%rbp), %eax
movl %eax, -0x64(%rbp)
movl -0x60(%rbp), %eax
addl -0x64(%rbp), %eax
cmpl $0x2, %eax
jae 0x137db7
movq $0x0, -0x8(%rbp)
jmp 0x138922
movq -0x30(%rbp), %rax
movq $0x0, 0x50(%rax)
movq -0x30(%rbp), %rax
movq $0x0, 0x38(%rax)
movq -0x30(%rbp), %rax
movq $0x0, 0x20(%rax)
movq -0x30(%rbp), %rax
movq $0x0, 0x8(%rax)
movq -0x30(%rbp), %rax
movq (%rax), %rax
movl -0x1c(%rbp), %ecx
imulq $0x1c, %rcx, %rcx
addq %rcx, %rax
movl $0x0, 0x10(%rax)
movq -0x30(%rbp), %rax
movq (%rax), %rax
movl -0x1c(%rbp), %ecx
imulq $0x1c, %rcx, %rcx
addq %rcx, %rax
movl $0x0, 0x14(%rax)
movq -0x30(%rbp), %rax
movq (%rax), %rax
movl -0x1c(%rbp), %ecx
imulq $0x1c, %rcx, %rcx
addq %rcx, %rax
movl $0x0, 0xc(%rax)
movq -0x30(%rbp), %rax
movq (%rax), %rax
movl -0x1c(%rbp), %ecx
imulq $0x1c, %rcx, %rcx
addq %rcx, %rax
movl $0x0, 0x4(%rax)
movq -0x30(%rbp), %rax
movq (%rax), %rax
movl -0x1c(%rbp), %ecx
imulq $0x1c, %rcx, %rcx
addq %rcx, %rax
movl $0x0, 0x8(%rax)
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x30(%rbp), %rcx
cmpq 0x10(%rcx), %rax
jne 0x137ed1
movq -0x30(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x137e90
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rax
shlq %rax
movq %rax, -0x98(%rbp)
jmp 0x137e9e
movl $0x2, %eax
movq %rax, -0x98(%rbp)
jmp 0x137e9e
movq -0x98(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rsi
shlq $0x2, %rsi
callq 0x2360
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x18(%rax)
movl -0x1c(%rbp), %edx
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x30(%rbp), %rsi
movq 0x8(%rsi), %rcx
movq %rcx, %rdi
addq $0x1, %rdi
movq %rdi, 0x8(%rsi)
movl %edx, (%rax,%rcx,4)
movl $0x0, -0x44(%rbp)
movl $0xffffffff, -0x48(%rbp) # imm = 0xFFFFFFFF
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x30(%rbp), %rdx
movq 0x8(%rdx), %rcx
movq %rcx, %rsi
addq $-0x1, %rsi
movq %rsi, 0x8(%rdx)
movl -0x4(%rax,%rcx,4), %eax
movl %eax, -0x54(%rbp)
movq -0x30(%rbp), %rax
movq (%rax), %rax
movl -0x54(%rbp), %ecx
imulq $0x1c, %rcx, %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
movl %eax, -0x5c(%rbp)
movl $0x0, -0x60(%rbp)
movq $0x0, -0x78(%rbp)
movl $0x0, -0x64(%rbp)
movq $0x0, -0x80(%rbp)
movl $0x0, -0x38(%rbp)
movl $0x0, -0x34(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x137fa4
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movl -0x54(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movl %eax, -0x60(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x10(%rbp), %rcx
movq 0x28(%rcx), %rcx
movl -0x54(%rbp), %edx
movq (%rcx,%rdx,8), %rcx
shrq $0x20, %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x78(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x137fe3
movq -0x18(%rbp), %rax
movq 0x28(%rax), %rax
movl -0x54(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movl %eax, -0x64(%rbp)
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x18(%rbp), %rcx
movq 0x28(%rcx), %rcx
movl -0x54(%rbp), %edx
movq (%rcx,%rdx,8), %rcx
shrq $0x20, %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x80(%rbp)
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x60(%rbp), %eax
jae 0x138394
movq -0x78(%rbp), %rax
movl -0x34(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0xc(%rax), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
je 0x138014
jmp 0x138386
movq -0x78(%rbp), %rax
movl -0x34(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movl %eax, -0x58(%rbp)
movq -0x78(%rbp), %rax
movl -0x34(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rax
movl %eax, -0x68(%rbp)
movq -0x30(%rbp), %rax
movq (%rax), %rax
movl -0x58(%rbp), %ecx
imulq $0x1c, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x88(%rbp)
movl -0x58(%rbp), %eax
shrl %eax
movl -0x1c(%rbp), %ecx
shrl %ecx
cmpl %ecx, %eax
jne 0x138067
jmp 0x138875
cmpl $0x0, -0x40(%rbp)
je 0x138074
movl $0x0, -0x68(%rbp)
movl -0x5c(%rbp), %eax
addl -0x68(%rbp), %eax
movl %eax, %eax
cmpq -0x28(%rbp), %rax
jbe 0x138087
jmp 0x138394
movq -0x88(%rbp), %rax
movl 0x18(%rax), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
jne 0x1381ff
jmp 0x13809f
movq -0x30(%rbp), %rax
movq 0x38(%rax), %rax
movq -0x30(%rbp), %rcx
cmpq 0x40(%rcx), %rax
jne 0x138111
movq -0x30(%rbp), %rax
cmpq $0x0, 0x40(%rax)
je 0x1380d0
movq -0x30(%rbp), %rax
movq 0x40(%rax), %rax
shlq %rax
movq %rax, -0xa0(%rbp)
jmp 0x1380de
movl $0x2, %eax
movq %rax, -0xa0(%rbp)
jmp 0x1380de
movq -0xa0(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x40(%rax)
movq -0x30(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x30(%rbp), %rax
movq 0x40(%rax), %rsi
shlq $0x2, %rsi
callq 0x2360
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x48(%rax)
movl -0x58(%rbp), %edx
movq -0x30(%rbp), %rax
movq 0x48(%rax), %rax
movq -0x30(%rbp), %rsi
movq 0x38(%rsi), %rcx
movq %rcx, %rdi
addq $0x1, %rdi
movq %rdi, 0x38(%rsi)
movl %edx, (%rax,%rcx,4)
movl -0x54(%rbp), %ecx
movq -0x88(%rbp), %rax
movl %ecx, (%rax)
movq -0x88(%rbp), %rax
movl 0x18(%rax), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
orl $0x80000000, %ecx       # imm = 0x80000000
movl %ecx, 0x18(%rax)
movl -0x5c(%rbp), %ecx
addl -0x68(%rbp), %ecx
movq -0x88(%rbp), %rax
movl %ecx, 0x4(%rax)
cmpq $0x0, -0x10(%rbp)
je 0x138189
movq -0x10(%rbp), %rdi
movl -0x58(%rbp), %esi
xorl $0x1, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x166b50
movl %eax, -0xa4(%rbp)
jmp 0x138193
xorl %eax, %eax
movl %eax, -0xa4(%rbp)
jmp 0x138193
movl -0xa4(%rbp), %eax
movl %eax, -0xa8(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x1381c1
movq -0x18(%rbp), %rdi
movl -0x58(%rbp), %esi
xorl $0x1, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x166b50
movl %eax, -0xac(%rbp)
jmp 0x1381cb
xorl %eax, %eax
movl %eax, -0xac(%rbp)
jmp 0x1381cb
movl -0xa8(%rbp), %edx
movl -0xac(%rbp), %eax
addl %eax, %edx
movq -0x88(%rbp), %rax
movl 0x18(%rax), %ecx
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
andl $0x80000000, %ecx       # imm = 0x80000000
orl %edx, %ecx
movl %ecx, 0x18(%rax)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x138223
movl -0x5c(%rbp), %eax
addl -0x68(%rbp), %eax
movq -0x88(%rbp), %rcx
cmpl 0x4(%rcx), %eax
jae 0x138221
movl -0x5c(%rbp), %ecx
addl -0x68(%rbp), %ecx
movq -0x88(%rbp), %rax
movl %ecx, 0x4(%rax)
jmp 0x138223
movq -0x88(%rbp), %rcx
movl 0x18(%rcx), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
addl $-0x1, %eax
movl 0x18(%rcx), %edx
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
andl $0x80000000, %edx       # imm = 0x80000000
orl %eax, %edx
movl %edx, 0x18(%rcx)
cmpl $0x0, %eax
jne 0x138384
cmpq $0x0, -0x10(%rbp)
je 0x138270
movq -0x10(%rbp), %rdi
movl -0x58(%rbp), %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x166b50
movl %eax, -0xb0(%rbp)
jmp 0x13827a
xorl %eax, %eax
movl %eax, -0xb0(%rbp)
jmp 0x13827a
movl -0xb0(%rbp), %eax
movl %eax, -0xb4(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x1382a5
movq -0x18(%rbp), %rdi
movl -0x58(%rbp), %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x166b50
movl %eax, -0xb8(%rbp)
jmp 0x1382af
xorl %eax, %eax
movl %eax, -0xb8(%rbp)
jmp 0x1382af
movl -0xb4(%rbp), %eax
movl -0xb8(%rbp), %ecx
addl %ecx, %eax
movl %eax, -0x6c(%rbp)
cmpl $0x0, -0x6c(%rbp)
jbe 0x138361
jmp 0x1382cc
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x30(%rbp), %rcx
cmpq 0x10(%rcx), %rax
jne 0x13833e
movq -0x30(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x1382fd
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rax
shlq %rax
movq %rax, -0xc0(%rbp)
jmp 0x13830b
movl $0x2, %eax
movq %rax, -0xc0(%rbp)
jmp 0x13830b
movq -0xc0(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rsi
shlq $0x2, %rsi
callq 0x2360
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x18(%rax)
movl -0x58(%rbp), %edx
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x30(%rbp), %rsi
movq 0x8(%rsi), %rcx
movq %rcx, %rdi
addq $0x1, %rdi
movq %rdi, 0x8(%rsi)
movl %edx, (%rax,%rcx,4)
jmp 0x13837b
cmpl $0x0, -0x44(%rbp)
je 0x13836c
jmp 0x138875
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
movl -0x58(%rbp), %eax
movl %eax, -0x48(%rbp)
movl -0x3c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x138386
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x137fea
movl -0x34(%rbp), %eax
cmpl -0x60(%rbp), %eax
jb 0x138753
movl $0x0, -0x38(%rbp)
movl -0x38(%rbp), %eax
cmpl -0x64(%rbp), %eax
jae 0x138751
movq -0x80(%rbp), %rax
movl -0x38(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0xc(%rax), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
je 0x1383d1
jmp 0x138743
movq -0x80(%rbp), %rax
movl -0x38(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movl %eax, -0x58(%rbp)
movq -0x80(%rbp), %rax
movl -0x38(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rax
movl %eax, -0x68(%rbp)
movq -0x30(%rbp), %rax
movq (%rax), %rax
movl -0x58(%rbp), %ecx
imulq $0x1c, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x88(%rbp)
movl -0x58(%rbp), %eax
shrl %eax
movl -0x1c(%rbp), %ecx
shrl %ecx
cmpl %ecx, %eax
jne 0x138424
jmp 0x138875
cmpl $0x0, -0x40(%rbp)
je 0x138431
movl $0x0, -0x68(%rbp)
movl -0x5c(%rbp), %eax
addl -0x68(%rbp), %eax
movl %eax, %eax
cmpq -0x28(%rbp), %rax
jbe 0x138444
jmp 0x138751
movq -0x88(%rbp), %rax
movl 0x18(%rax), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
jne 0x1385bc
jmp 0x13845c
movq -0x30(%rbp), %rax
movq 0x38(%rax), %rax
movq -0x30(%rbp), %rcx
cmpq 0x40(%rcx), %rax
jne 0x1384ce
movq -0x30(%rbp), %rax
cmpq $0x0, 0x40(%rax)
je 0x13848d
movq -0x30(%rbp), %rax
movq 0x40(%rax), %rax
shlq %rax
movq %rax, -0xc8(%rbp)
jmp 0x13849b
movl $0x2, %eax
movq %rax, -0xc8(%rbp)
jmp 0x13849b
movq -0xc8(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x40(%rax)
movq -0x30(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x30(%rbp), %rax
movq 0x40(%rax), %rsi
shlq $0x2, %rsi
callq 0x2360
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x48(%rax)
movl -0x58(%rbp), %edx
movq -0x30(%rbp), %rax
movq 0x48(%rax), %rax
movq -0x30(%rbp), %rsi
movq 0x38(%rsi), %rcx
movq %rcx, %rdi
addq $0x1, %rdi
movq %rdi, 0x38(%rsi)
movl %edx, (%rax,%rcx,4)
movl -0x54(%rbp), %ecx
movq -0x88(%rbp), %rax
movl %ecx, (%rax)
movq -0x88(%rbp), %rax
movl 0x18(%rax), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
orl $0x80000000, %ecx       # imm = 0x80000000
movl %ecx, 0x18(%rax)
movl -0x5c(%rbp), %ecx
addl -0x68(%rbp), %ecx
movq -0x88(%rbp), %rax
movl %ecx, 0x4(%rax)
cmpq $0x0, -0x10(%rbp)
je 0x138546
movq -0x10(%rbp), %rdi
movl -0x58(%rbp), %esi
xorl $0x1, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x166b50
movl %eax, -0xcc(%rbp)
jmp 0x138550
xorl %eax, %eax
movl %eax, -0xcc(%rbp)
jmp 0x138550
movl -0xcc(%rbp), %eax
movl %eax, -0xd0(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x13857e
movq -0x18(%rbp), %rdi
movl -0x58(%rbp), %esi
xorl $0x1, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x166b50
movl %eax, -0xd4(%rbp)
jmp 0x138588
xorl %eax, %eax
movl %eax, -0xd4(%rbp)
jmp 0x138588
movl -0xd0(%rbp), %edx
movl -0xd4(%rbp), %eax
addl %eax, %edx
movq -0x88(%rbp), %rax
movl 0x18(%rax), %ecx
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
andl $0x80000000, %ecx       # imm = 0x80000000
orl %edx, %ecx
movl %ecx, 0x18(%rax)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x1385e0
movl -0x5c(%rbp), %eax
addl -0x68(%rbp), %eax
movq -0x88(%rbp), %rcx
cmpl 0x4(%rcx), %eax
jae 0x1385de
movl -0x5c(%rbp), %ecx
addl -0x68(%rbp), %ecx
movq -0x88(%rbp), %rax
movl %ecx, 0x4(%rax)
jmp 0x1385e0
movq -0x88(%rbp), %rcx
movl 0x18(%rcx), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
addl $-0x1, %eax
movl 0x18(%rcx), %edx
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
andl $0x80000000, %edx       # imm = 0x80000000
orl %eax, %edx
movl %edx, 0x18(%rcx)
cmpl $0x0, %eax
jne 0x138741
cmpq $0x0, -0x10(%rbp)
je 0x13862d
movq -0x10(%rbp), %rdi
movl -0x58(%rbp), %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x166b50
movl %eax, -0xd8(%rbp)
jmp 0x138637
xorl %eax, %eax
movl %eax, -0xd8(%rbp)
jmp 0x138637
movl -0xd8(%rbp), %eax
movl %eax, -0xdc(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x138662
movq -0x18(%rbp), %rdi
movl -0x58(%rbp), %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x166b50
movl %eax, -0xe0(%rbp)
jmp 0x13866c
xorl %eax, %eax
movl %eax, -0xe0(%rbp)
jmp 0x13866c
movl -0xdc(%rbp), %eax
movl -0xe0(%rbp), %ecx
addl %ecx, %eax
movl %eax, -0x6c(%rbp)
cmpl $0x0, -0x6c(%rbp)
jbe 0x13871e
jmp 0x138689
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x30(%rbp), %rcx
cmpq 0x10(%rcx), %rax
jne 0x1386fb
movq -0x30(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x1386ba
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rax
shlq %rax
movq %rax, -0xe8(%rbp)
jmp 0x1386c8
movl $0x2, %eax
movq %rax, -0xe8(%rbp)
jmp 0x1386c8
movq -0xe8(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rsi
shlq $0x2, %rsi
callq 0x2360
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x18(%rax)
movl -0x58(%rbp), %edx
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x30(%rbp), %rsi
movq 0x8(%rsi), %rcx
movq %rcx, %rdi
addq $0x1, %rdi
movq %rdi, 0x8(%rsi)
movl %edx, (%rax,%rcx,4)
jmp 0x138738
cmpl $0x0, -0x44(%rbp)
je 0x138729
jmp 0x138875
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
movl -0x58(%rbp), %eax
movl %eax, -0x48(%rbp)
movl -0x3c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x138743
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x1383a7
jmp 0x138753
movl $0x0, -0x40(%rbp)
cmpl $0x1, -0x44(%rbp)
jne 0x138820
cmpl $-0x1, -0x48(%rbp)
je 0x13881e
cmpl $0x0, -0x3c(%rbp)
jne 0x13881e
movq -0x30(%rbp), %rax
cmpq $0x0, 0x8(%rax)
jne 0x13881e
jmp 0x138789
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x30(%rbp), %rcx
cmpq 0x10(%rcx), %rax
jne 0x1387fb
movq -0x30(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x1387ba
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rax
shlq %rax
movq %rax, -0xf0(%rbp)
jmp 0x1387c8
movl $0x2, %eax
movq %rax, -0xf0(%rbp)
jmp 0x1387c8
movq -0xf0(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rsi
shlq $0x2, %rsi
callq 0x2360
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x18(%rax)
movl -0x48(%rbp), %edx
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x30(%rbp), %rsi
movq 0x8(%rsi), %rcx
movq %rcx, %rdi
addq $0x1, %rdi
movq %rdi, 0x8(%rsi)
movl %edx, (%rax,%rcx,4)
jmp 0x13886d
jmp 0x138875
movl -0x34(%rbp), %eax
cmpl -0x60(%rbp), %eax
jb 0x13883b
movl -0x38(%rbp), %eax
cmpl -0x64(%rbp), %eax
jb 0x13883b
movq -0x30(%rbp), %rax
cmpq $0x0, 0x8(%rax)
jne 0x13883d
jmp 0x138875
jmp 0x13883f
movq -0x30(%rbp), %rcx
movb $0x1, %al
cmpq $0x1, 0x8(%rcx)
movb %al, -0xf1(%rbp)
ja 0x13885f
cmpl $0x0, -0x3c(%rbp)
setne %al
movb %al, -0xf1(%rbp)
movb -0xf1(%rbp), %al
testb $0x1, %al
jne 0x137f00
movq $0x1, -0x50(%rbp)
movl $0x0, -0x70(%rbp)
movl -0x70(%rbp), %eax
movq -0x30(%rbp), %rcx
cmpq 0x38(%rcx), %rax
jae 0x13891a
movq -0x30(%rbp), %rax
movq (%rax), %rax
movq -0x30(%rbp), %rcx
movq 0x48(%rcx), %rcx
movl -0x70(%rbp), %edx
movl (%rcx,%rdx,4), %ecx
imulq $0x1c, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rax
movl $0x0, 0x10(%rax)
movq -0x88(%rbp), %rax
movl $0x0, 0x14(%rax)
movq -0x88(%rbp), %rax
movl $0x0, 0xc(%rax)
movq -0x88(%rbp), %rax
movl $0x0, 0x4(%rax)
movq -0x88(%rbp), %rax
movl $0x0, 0x8(%rax)
movq -0x88(%rbp), %rax
movl 0x18(%rax), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
orl $0x0, %ecx
movl %ecx, 0x18(%rax)
movl -0x70(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x70(%rbp)
jmp 0x13887c
movq -0x50(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x100, %rsp            # imm = 0x100
popq %rbp
retq
nop