// File: /workspace/github_cpp_makefile_star2_O3/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 0xa8(%rsi), %r12
cmpq $0x0, 0x50(%r12)
je 0xe20ad
movl %ecx, %ebx
movl %edx, %ebp
movq %rdi, %r14
movq 0x10(%rsi), %r8
addq $0xa8, %rsi
movq %rsi, 0x10(%rsp)
shrl %ebp
shrl %ebx
movq 0x60(%r12), %rcx
xorl %r15d, %r15d
movq $0x0, 0x20(%rsp)
movq %r8, 0x18(%rsp)
movq %rdi, 0x28(%rsp)
movl (%rcx,%r15,4), %eax
movq $0x0, 0xa0(%r12)
cmpq $0x0, 0xa8(%r12)
movq 0xb0(%r12), %rdi
movl %eax, 0xc(%rsp)
je 0xe1e75
movl %eax, (%rdi)
movl $0x1, %ecx
jmp 0xe1ebb
movq $0x2, 0xa8(%r12)
movl $0x8, %esi
movl %eax, %r13d
callq 0x2370
movq 0x18(%rsp), %r8
movq %rax, 0xb0(%r12)
movq 0xa0(%r12), %rdx
movq %rdx, %rcx
incq %rcx
movq %rcx, 0xa0(%r12)
movl %r13d, (%rax,%rdx,4)
je 0xe2050
shrl 0xc(%rsp)
movq %r15, 0x30(%rsp)
leaq -0x1(%rcx), %rdx
movq %rdx, 0xa0(%r12)
movq 0xb0(%r12), %rax
movl -0x4(%rax,%rcx,4), %eax
movq 0x28(%r14), %rcx
movq (%rcx,%rax,8), %rax
movq %rdx, %rcx
testl %eax, %eax
je 0xe2047
movq 0x8(%r14), %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 0xe1fa8
movl (%r15,%r13), %ecx
movl %ecx, %eax
shrl %eax
cmpl %ebp, %eax
sete %dl
cmpl %ebx, %eax
sete %al
orb %dl, %al
jne 0xe1fa8
movq 0xa0(%r12), %rdx
movq 0xb0(%r12), %rax
cmpq 0xa8(%r12), %rdx
jne 0xe1f8c
leaq (%rdx,%rdx), %rsi
testq %rdx, %rdx
movl $0x2, %ecx
cmoveq %rcx, %rsi
movq %rsi, 0xa8(%r12)
shlq $0x2, %rsi
movq %rax, %rdi
callq 0x2370
movq 0x18(%rsp), %r8
movq %rax, 0xb0(%r12)
movl (%r15,%r13), %ecx
movq 0xa0(%r12), %rdx
leaq 0x1(%rdx), %rsi
movq %rsi, 0xa0(%r12)
movl %ecx, (%rax,%rdx,4)
movl (%r15,%r13), %eax
shrl %eax
cmpq $0x0, (%r8,%rax,8)
je 0xe1fb7
addq $0x18, %r13
cmpq %r13, %r14
jne 0xe1f13
jmp 0xe2035
movq 0x1b3022(%rip), %rax    # 0x294fe0
movq (%rax), %rcx
movl $0x9, %esi
movl $0x1, %edx
leaq 0x155e94(%rip), %rdi    # 0x237e66
callq 0x2410
movq 0x1b3002(%rip), %rax    # 0x294fe0
movq (%rax), %rdi
movq 0x10(%rsp), %rax
movq (%rax), %rax
movl 0x50(%rax), %r8d
movl (%r15,%r13), %eax
shrl %eax
movl %eax, (%rsp)
leaq 0x155e73(%rip), %rsi    # 0x237e70
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 0xe1fa8
movq 0x10(%rsp), %rsi
callq 0x11293
movq 0x18(%rsp), %r8
jmp 0xe1fa8
movq 0xa0(%r12), %rcx
movq 0x28(%rsp), %r14
movq 0x30(%rsp), %r15
testq %rcx, %rcx
jne 0xe1ec4
movq 0x10(%rsp), %rax
movq (%rax), %rax
movq 0x60(%rax), %rcx
movl (%rcx,%r15,4), %edx
shrl %edx
movq $0x0, (%r8,%rdx,8)
movq 0x20(%rsp), %rsi
incl %esi
movq 0x50(%rax), %rdx
movq %rsi, %r15
movq %rsi, 0x20(%rsp)
cmpq %rsi, %rdx
ja 0xe1e45
testq %rdx, %rdx
je 0xe20ad
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 0xe2096
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq