// File: /workspace/github_cpp_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdi, 0x20(%rsp)
movq 0x10(%rsi), %r8
movq 0xa8(%rsi), %rax
cmpq $0x0, 0x50(%rax)
je 0xe0d52
movl %ecx, %ebx
movl %edx, %ebp
addq $0xa8, %rsi
movq (%rsi), %r12
shrl %ebp
shrl %ebx
xorl %edx, %edx
xorl %ecx, %ecx
movq %r8, 0x18(%rsp)
movq %rsi, 0x10(%rsp)
movq %rcx, 0x30(%rsp)
movq 0x60(%rax), %rax
movq %rdx, 0x28(%rsp)
movl (%rax,%rdx,4), %r14d
movq $0x0, 0xa0(%r12)
cmpq $0x0, 0xa8(%r12)
jne 0xe0b60
movq $0x2, 0xa8(%r12)
movq 0xb0(%r12), %rdi
movl $0x8, %esi
callq 0x2370
movq 0x18(%rsp), %r8
movq %rax, 0xb0(%r12)
movq 0xa0(%r12), %rcx
movq 0xb0(%r12), %rdx
movq %rcx, %rax
incq %rax
movq %rax, 0xa0(%r12)
movl %r14d, 0xc(%rsp)
movl %r14d, (%rdx,%rcx,4)
je 0xe0d1d
shrl 0xc(%rsp)
leaq -0x1(%rax), %rcx
movq %rcx, 0xa0(%r12)
movq 0xb0(%r12), %rcx
movl -0x4(%rcx,%rax,4), %eax
movq 0x20(%rsp), %rcx
movq 0x28(%rcx), %rcx
movq (%rcx,%rax,8), %rax
testl %eax, %eax
je 0xe0d0c
movq 0x20(%rsp), %rcx
movq 0x8(%rcx), %rcx
movq %rax, %rdx
shrq $0x20, %rdx
movl %eax, %eax
leaq (%rdx,%rdx,2), %rdx
leaq (%rcx,%rdx,8), %r15
addq $0x8, %r15
shlq $0x3, %rax
leaq (%rax,%rax,2), %r14
xorl %r13d, %r13d
cmpl $0x0, 0x4(%r15,%r13)
js 0xe0c7f
movl (%r15,%r13), %eax
shrl %eax
cmpl %ebp, %eax
sete %cl
cmpl %ebx, %eax
sete %al
orb %cl, %al
jne 0xe0c7f
movq 0xa8(%r12), %rax
cmpq %rax, 0xa0(%r12)
jne 0xe0c4f
leaq (%rax,%rax), %rsi
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %rsi
movq %rsi, 0xa8(%r12)
movq 0xb0(%r12), %rdi
shlq $0x2, %rsi
callq 0x2370
movq 0x18(%rsp), %r8
movq %rax, 0xb0(%r12)
movl (%r15,%r13), %eax
movq 0xa0(%r12), %rcx
movq 0xb0(%r12), %rdx
leaq 0x1(%rcx), %rsi
movq %rsi, 0xa0(%r12)
movl %eax, (%rdx,%rcx,4)
movl (%r15,%r13), %eax
shrl %eax
cmpq $0x0, (%r8,%rax,8)
je 0xe0c8e
addq $0x18, %r13
cmpq %r13, %r14
jne 0xe0be7
jmp 0xe0d0c
movq 0x1a934b(%rip), %rax    # 0x289fe0
movq (%rax), %rcx
movl $0x9, %esi
movl $0x1, %edx
leaq 0x14afcd(%rip), %rdi    # 0x22bc76
callq 0x2410
movq 0x1a932b(%rip), %rax    # 0x289fe0
movq (%rax), %rdi
movq 0x10(%rsp), %rax
movq (%rax), %rax
movl 0x50(%rax), %r8d
movl (%r15,%r13), %eax
shrl %eax
movl %eax, (%rsp)
leaq 0x14afac(%rip), %rsi    # 0x22bc80
movl %ebp, %edx
movl %ebx, %ecx
movl 0xc(%rsp), %r9d
xorl %eax, %eax
callq 0x22b0
movq 0x18(%rsp), %r8
movq 0x10(%rsp), %rax
movq (%rax), %rdi
cmpq $0x0, 0x50(%rdi)
je 0xe0c7f
movq 0x10(%rsp), %rsi
callq 0x11444
movq 0x18(%rsp), %r8
jmp 0xe0c7f
movq 0xa0(%r12), %rax
testq %rax, %rax
jne 0xe0b91
movq 0x10(%rsp), %rsi
movq (%rsi), %rax
movq 0x60(%rax), %rax
movq 0x28(%rsp), %rcx
movl (%rax,%rcx,4), %eax
shrl %eax
movq $0x0, (%r8,%rax,8)
movq 0x30(%rsp), %rcx
incl %ecx
movq (%rsi), %rax
movq %rcx, %rdx
cmpq %rcx, 0x50(%rax)
ja 0xe0b0c
cmpq $0x0, 0x50(%rax)
je 0xe0d7b
movq 0x60(%rax), %rcx
movl $0x1, %edx
xorl %esi, %esi
movl (%rcx,%rsi,4), %esi
shrl %esi
movq $-0x1, (%r8,%rsi,8)
movl %edx, %esi
incl %edx
cmpq %rsi, 0x50(%rax)
ja 0xe0d64
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq