// File: chhylp123[P]hifiasm/Overlaps.cpp
// Function: debug_topo_sorting(asg_t*, hap_cov_t*, unsigned int, unsigned int)
void debug_topo_sorting(asg_t *g, hap_cov_t *cov, uint32_t beg, uint32_t sink)
{
    buf_t *b = &(cov->t_ch->b_buf_0);
    uint64_t *flag = cov->pos_idx;
    asg_arc_t *acur = NULL;
    uint32_t cur, ncur, i, k, k_i, v;

    for (k = 0; k < cov->t_ch->topo_res.n; k++)
    {
        v = cov->t_ch->topo_res.a[k];

        b->b.n = 0;
        kv_push(uint32_t, b->b, v);
        while (b->b.n > 0)
        {
            b->b.n--;
            cur = b->b.a[b->b.n];

            ncur = asg_arc_n(g, cur);
            acur = asg_arc_a(g, cur);
            for (i = 0; i < ncur; i++)
            {
                if(acur[i].del) continue;
                if((acur[i].v>>1) == (beg>>1) || (acur[i].v>>1) == (sink>>1)) continue;
                kv_push(uint32_t, b->b, acur[i].v);
                if(flag[acur[i].v>>1] == 0)
                {
                    fprintf(stderr, "\nERROR-1\n");
                    fprintf(stderr, "beg>>1: %u, sink>>1: %u, topo_res.n: %u, v>>1: %u, w>>1: %u\n", 
                                            beg>>1, sink>>1, (uint32_t)cov->t_ch->topo_res.n, v>>1, acur[i].v>>1);
                    for (k_i = 0; k_i < cov->t_ch->topo_res.n; k_i++)
                    {
                        fprintf(stderr, "k_i: %u, topo_res>>1: %u\n", k_i, cov->t_ch->topo_res.a[k_i]>>1);
                    }
                } 
                
            }
        }

        flag[cov->t_ch->topo_res.a[k]>>1] = 0;
    }

    for (k = 0; k < cov->t_ch->topo_res.n; k++)
    {
        flag[cov->t_ch->topo_res.a[k]>>1] = (uint64_t)-1;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl %ecx, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq 0xa8(%rax), %rax
addq $0x68, %rax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x28(%rbp)
movq $0x0, -0x30(%rbp)
movl $0x0, -0x40(%rbp)
movl -0x40(%rbp), %eax
movq -0x10(%rbp), %rcx
movq 0xa8(%rcx), %rcx
cmpq 0x50(%rcx), %rax
jae 0x1346a0
movq -0x10(%rbp), %rax
movq 0xa8(%rax), %rax
movq 0x60(%rax), %rax
movl -0x40(%rbp), %ecx
movl (%rax,%rcx,4), %eax
movl %eax, -0x48(%rbp)
movq -0x20(%rbp), %rax
movq $0x0, 0x38(%rax)
movq -0x20(%rbp), %rax
movq 0x38(%rax), %rax
movq -0x20(%rbp), %rcx
cmpq 0x40(%rcx), %rax
jne 0x1343d9
movq -0x20(%rbp), %rax
cmpq $0x0, 0x40(%rax)
je 0x13439e
movq -0x20(%rbp), %rax
movq 0x40(%rax), %rax
shlq %rax
movq %rax, -0x50(%rbp)
jmp 0x1343a9
movl $0x2, %eax
movq %rax, -0x50(%rbp)
jmp 0x1343a9
movq -0x50(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x40(%rax)
movq -0x20(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x20(%rbp), %rax
movq 0x40(%rax), %rsi
shlq $0x2, %rsi
callq 0x2360
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x48(%rax)
movl -0x48(%rbp), %edx
movq -0x20(%rbp), %rax
movq 0x48(%rax), %rax
movq -0x20(%rbp), %rsi
movq 0x38(%rsi), %rcx
movq %rcx, %rdi
addq $0x1, %rdi
movq %rdi, 0x38(%rsi)
movl %edx, (%rax,%rcx,4)
jmp 0x1343fc
movq -0x20(%rbp), %rax
cmpq $0x0, 0x38(%rax)
jbe 0x13466d
movq -0x20(%rbp), %rax
movq 0x38(%rax), %rcx
addq $-0x1, %rcx
movq %rcx, 0x38(%rax)
movq -0x20(%rbp), %rax
movq 0x48(%rax), %rax
movq -0x20(%rbp), %rcx
movq 0x38(%rcx), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x34(%rbp)
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rax
movl -0x34(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movl %eax, -0x38(%rbp)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x8(%rbp), %rcx
movq 0x28(%rcx), %rcx
movl -0x34(%rbp), %edx
movq (%rcx,%rdx,8), %rcx
shrq $0x20, %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x38(%rbp), %eax
jae 0x134668
movq -0x30(%rbp), %rax
movl -0x3c(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0xc(%rax), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
je 0x13449a
jmp 0x13465a
movq -0x30(%rbp), %rax
movl -0x3c(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
shrl %eax
movl -0x14(%rbp), %ecx
shrl %ecx
cmpl %ecx, %eax
je 0x1344d2
movq -0x30(%rbp), %rax
movl -0x3c(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
shrl %eax
movl -0x18(%rbp), %ecx
shrl %ecx
cmpl %ecx, %eax
jne 0x1344d7
jmp 0x13465a
jmp 0x1344d9
movq -0x20(%rbp), %rax
movq 0x38(%rax), %rax
movq -0x20(%rbp), %rcx
cmpq 0x40(%rcx), %rax
jne 0x134542
movq -0x20(%rbp), %rax
cmpq $0x0, 0x40(%rax)
je 0x134507
movq -0x20(%rbp), %rax
movq 0x40(%rax), %rax
shlq %rax
movq %rax, -0x58(%rbp)
jmp 0x134512
movl $0x2, %eax
movq %rax, -0x58(%rbp)
jmp 0x134512
movq -0x58(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x40(%rax)
movq -0x20(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x20(%rbp), %rax
movq 0x40(%rax), %rsi
shlq $0x2, %rsi
callq 0x2360
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x48(%rax)
movq -0x30(%rbp), %rax
movl -0x3c(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0x8(%rax), %edx
movq -0x20(%rbp), %rax
movq 0x48(%rax), %rax
movq -0x20(%rbp), %rsi
movq 0x38(%rsi), %rcx
movq %rcx, %rdi
addq $0x1, %rdi
movq %rdi, 0x38(%rsi)
movl %edx, (%rax,%rcx,4)
movq -0x28(%rbp), %rax
movq -0x30(%rbp), %rcx
movl -0x3c(%rbp), %edx
imulq $0x18, %rdx, %rdx
addq %rdx, %rcx
movl 0x8(%rcx), %ecx
shrl %ecx
movl %ecx, %ecx
cmpq $0x0, (%rax,%rcx,8)
jne 0x134658
movq 0x28fa44(%rip), %rax    # 0x3c3fe0
movq (%rax), %rdi
leaq 0x2544ab(%rip), %rsi    # 0x388a51
movb $0x0, %al
callq 0x22a0
movq 0x28fa2c(%rip), %rax    # 0x3c3fe0
movq (%rax), %rdi
movl -0x14(%rbp), %edx
shrl %edx
movl -0x18(%rbp), %ecx
shrl %ecx
movq -0x10(%rbp), %rax
movq 0xa8(%rax), %rax
movq 0x50(%rax), %rax
movl %eax, %r8d
movl -0x48(%rbp), %r9d
shrl %r9d
movq -0x30(%rbp), %rax
movl -0x3c(%rbp), %esi
imulq $0x18, %rsi, %rsi
addq %rsi, %rax
movl 0x8(%rax), %eax
shrl %eax
leaq 0x254467(%rip), %rsi    # 0x388a5b
movl %eax, (%rsp)
movb $0x0, %al
callq 0x22a0
movl $0x0, -0x44(%rbp)
movl -0x44(%rbp), %eax
movq -0x10(%rbp), %rcx
movq 0xa8(%rcx), %rcx
cmpq 0x50(%rcx), %rax
jae 0x134656
movq 0x28f9c0(%rip), %rax    # 0x3c3fe0
movq (%rax), %rdi
movl -0x44(%rbp), %edx
movq -0x10(%rbp), %rax
movq 0xa8(%rax), %rax
movq 0x60(%rax), %rax
movl -0x44(%rbp), %ecx
movl (%rax,%rcx,4), %ecx
shrl %ecx
leaq 0x254454(%rip), %rsi    # 0x388a98
movb $0x0, %al
callq 0x22a0
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x134605
jmp 0x134658
jmp 0x13465a
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x134470
jmp 0x1343fc
movq -0x28(%rbp), %rax
movq -0x10(%rbp), %rcx
movq 0xa8(%rcx), %rcx
movq 0x60(%rcx), %rcx
movl -0x40(%rbp), %edx
movl (%rcx,%rdx,4), %ecx
shrl %ecx
movl %ecx, %ecx
movq $0x0, (%rax,%rcx,8)
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x134334
movl $0x0, -0x40(%rbp)
movl -0x40(%rbp), %eax
movq -0x10(%rbp), %rcx
movq 0xa8(%rcx), %rcx
cmpq 0x50(%rcx), %rax
jae 0x1346eb
movq -0x28(%rbp), %rax
movq -0x10(%rbp), %rcx
movq 0xa8(%rcx), %rcx
movq 0x60(%rcx), %rcx
movl -0x40(%rbp), %edx
movl (%rcx,%rdx,4), %ecx
shrl %ecx
movl %ecx, %ecx
movq $-0x1, (%rax,%rcx,8)
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x1346a7
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)