// File: chhylp123[P]hifiasm/Overlaps.cpp
// Function: debug_contig_end(ma_ug_t*, asg_t*, kvec_asg_arc_t_warp*)
void debug_contig_end(ma_ug_t *ug, asg_t* read_g, kvec_asg_arc_t_warp* edge)
{
    asg_t* nsg = ug->g;
    uint32_t n_vtx = nsg->n_seq<<1, v, w, nv, v_occ, rv, rw, i;
    asg_arc_t *av = NULL;
    ma_utg_t* u = NULL;

    for (v = 0; v < n_vtx; v++)
    {
        if(ug->g->seq[v>>1].del) continue;
        u = &(ug->u.a[v>>1]);
        if(u->n == 0) continue;
        av = asg_arc_a(ug->g, v);
        nv = asg_arc_n(ug->g, v);
        if(nv == 0) continue;

        if(v&1) rv = ug->u.a[v>>1].start^1;
        else rv = ug->u.a[v>>1].end^1;

        for (i = v_occ = 0; i < nv; i++)
        {
            if(av[i].del) continue;
            v_occ++;
        }
        if(v_occ == 0) continue;

        for (i = 0; i < nv; i++)
        {
            if(av[i].del) continue;
            w = av[i].v;
            if(w&1) rw = ug->u.a[w>>1].end;
            else rw = ug->u.a[w>>1].start;

            fprintf(stderr, "utg: (v>>1: %u)[v&1: %u]->(w>>1: %u)[w&1: %u]\n", v>>1, v&1, w>>1, w&1);
            fprintf(stderr, "rtg: (r_v>>1: %u)[r_v&1: %u]->(r_w>>1: %u)[r_w&1: %u]\n\n", 
                                    rv>>1, rv&1, rw>>1, rw&1);
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movl 0x14(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
shll %eax
movl %eax, -0x24(%rbp)
movq $0x0, -0x48(%rbp)
movq $0x0, -0x50(%rbp)
movl $0x0, -0x28(%rbp)
movl -0x28(%rbp), %eax
cmpl -0x24(%rbp), %eax
jae 0xf5426
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x20(%rax), %rax
movl -0x28(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
movl (%rax,%rcx,8), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
je 0xf5207
jmp 0xf5418
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x28(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
cmpl $0x0, 0x10(%rax)
jne 0xf5230
jmp 0xf5418
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x8(%rax), %rax
movq -0x8(%rbp), %rcx
movq 0x18(%rcx), %rcx
movq 0x28(%rcx), %rcx
movl -0x28(%rbp), %edx
movq (%rcx,%rdx,8), %rcx
shrq $0x20, %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x48(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x28(%rax), %rax
movl -0x28(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movl %eax, -0x30(%rbp)
cmpl $0x0, -0x30(%rbp)
jne 0xf527f
jmp 0xf5418
movl -0x28(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0xf52ab
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x28(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
xorl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0xf52ca
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x28(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
xorl $0x1, %eax
movl %eax, -0x38(%rbp)
movl $0x0, -0x34(%rbp)
movl $0x0, -0x40(%rbp)
movl -0x40(%rbp), %eax
cmpl -0x30(%rbp), %eax
jae 0xf530f
movq -0x48(%rbp), %rax
movl -0x40(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0xc(%rax), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
je 0xf52fb
jmp 0xf5304
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0xf52d8
cmpl $0x0, -0x34(%rbp)
jne 0xf531a
jmp 0xf5418
movl $0x0, -0x40(%rbp)
movl -0x40(%rbp), %eax
cmpl -0x30(%rbp), %eax
jae 0xf5416
movq -0x48(%rbp), %rax
movl -0x40(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0xc(%rax), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
je 0xf534b
jmp 0xf5408
movq -0x48(%rbp), %rax
movl -0x40(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0xf5388
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x2c(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movl %eax, -0x3c(%rbp)
jmp 0xf53a4
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x2c(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
movl %eax, -0x3c(%rbp)
movq 0x2cec35(%rip), %rax    # 0x3c3fe0
movq (%rax), %rdi
movl -0x28(%rbp), %edx
shrl %edx
movl -0x28(%rbp), %ecx
andl $0x1, %ecx
movl -0x2c(%rbp), %r8d
shrl %r8d
movl -0x2c(%rbp), %r9d
andl $0x1, %r9d
leaq 0x291e9b(%rip), %rsi    # 0x38726a
movb $0x0, %al
callq 0x22a0
movq 0x2cec03(%rip), %rax    # 0x3c3fe0
movq (%rax), %rdi
movl -0x38(%rbp), %edx
shrl %edx
movl -0x38(%rbp), %ecx
andl $0x1, %ecx
movl -0x3c(%rbp), %r8d
shrl %r8d
movl -0x3c(%rbp), %r9d
andl $0x1, %r9d
leaq 0x291e98(%rip), %rsi    # 0x387299
movb $0x0, %al
callq 0x22a0
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0xf5321
jmp 0xf5418
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0xf51d8
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax)