// File: /workspace/github_cpp_makefile_star2_O3/chhylp123[P]hifiasm/Overlaps.cpp
// Function: drop_tips_at_tangle(asg_t*, unsigned long*, unsigned long, unsigned int, unsigned int, buf_t*)
int drop_tips_at_tangle(asg_t* nsg, uint64_t* nodes, uint64_t n, uint32_t beg, uint32_t end, 
buf_t* bb)
{
    uint32_t i, v, k, m, convex, return_flag, next_tips = 1, reduce = 0;
    long long ll, tmp, max_stop_nodeLen, max_stop_baseLen;
    
    while(next_tips > 0)
    {
        next_tips = 0;

        for (i = 0; i < n; i++)
        {
            v = (uint32_t)nodes[i];
            if(nsg->seq[v].del) continue;
            if(nsg->seq[v].c == ALTER_LABLE) continue;
            v = v<<1;

            for (k = 0; k < 2; k++)
            {
                v = v|k;
                if(get_real_length(nsg, v^1, NULL) != 0) continue;

                bb->b.n = 0;
                return_flag = get_unitig(nsg, NULL, v, &convex, &ll, &tmp, &max_stop_nodeLen, 
                        &max_stop_baseLen, 1, bb);
                if(return_flag == LOOP) continue;
                if(return_flag == MUL_OUTPUT) next_tips++;

                for(m = 0; m < bb->b.n; m++)
                {
                    if(((bb->b.a[m]>>1)==(beg>>1)) || ((bb->b.a[m]>>1)==(end>>1))) break;
                }
                ///means this unitig consists of beg or end 
                if(m != bb->b.n) continue;

                for(m = 0; m < bb->b.n; m++)
                {
                    nsg->seq[(bb->b.a[m]>>1)].c = ALTER_LABLE;
                }

                for(m = 0; m < bb->b.n; m++)
                {
                    asg_seq_drop(nsg, (bb->b.a[m]>>1));
                }
                
                reduce++;
            }
        }
    }
    
    return reduce;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %r9, %r14
movl %r8d, %ebp
movl %ecx, %ebx
movq %rdx, 0x28(%rsp)
movq %rsi, 0x30(%rsp)
movq %rdi, %r12
shrl %ebx
shrl %ebp
movq $0x0, 0x10(%rsp)
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
movl %ebp, 0x24(%rsp)
movl %ebx, 0x20(%rsp)
cmpq $0x0, 0x28(%rsp)
je 0xee407
xorl %edx, %edx
movl $0x0, 0xc(%rsp)
movq 0x30(%rsp), %rax
movq (%rax,%rdx,8), %rax
movq %rax, %rsi
movl %eax, %eax
movq 0x20(%r12), %rcx
cmpl $0x0, (%rcx,%rax,8)
movq %rdx, 0x38(%rsp)
js 0xee3ea
cmpb $0x1, 0x4(%rcx,%rax,8)
je 0xee3ea
movq %rsi, %rdx
addl %edx, %edx
xorl %eax, %eax
movb $0x1, %cl
movl %ecx, 0x8(%rsp)
movl %edx, %ecx
movl %eax, %edx
orl %ecx, %edx
movl %edx, %eax
xorl $0x1, %eax
movq 0x28(%r12), %rcx
movq (%rcx,%rax,8), %rax
movq %rax, %rcx
andq %r13, %rcx
je 0xee210
movq %rdx, %r8
movq 0x8(%r12), %rdx
shrq $0x20, %rax
leaq (%rax,%rax,2), %rax
leaq (%rdx,%rax,8), %rax
addq $0xc, %rax
shlq $0x3, %rcx
leaq (%rcx,%rcx,2), %rcx
xorl %edx, %edx
xorl %esi, %esi
movl (%rax,%rdx), %edi
notl %edi
shrl $0x1f, %edi
addl %edi, %esi
addq $0x18, %rdx
cmpq %rdx, %rcx
jne 0xee1f2
testl %esi, %esi
movq %r8, %rdx
jne 0xee3d3
movq $0x0, 0x38(%r14)
movq %r12, %rdi
xorl %esi, %esi
movq %rdx, 0x18(%rsp)
leaq 0x44(%rsp), %rcx
leaq 0x60(%rsp), %r8
leaq 0x58(%rsp), %r9
pushq %r14
pushq $0x1
leaq 0x58(%rsp), %rax
pushq %rax
leaq 0x68(%rsp), %rax
pushq %rax
callq 0x1053a7
addq $0x20, %rsp
cmpl $0x7, %eax
je 0xee3ce
cmpl $0x4, %eax
jne 0xee25c
incl 0xc(%rsp)
movq 0x38(%r14), %rdx
testq %rdx, %rdx
je 0xee3c2
movq 0x48(%r14), %rax
movl $0x1, %esi
xorl %ecx, %ecx
movl (%rax,%rcx,4), %edi
shrl %edi
cmpl %ebx, %edi
je 0xee28a
cmpl %ebp, %edi
je 0xee28a
movl %esi, %ecx
incl %esi
cmpq %rcx, %rdx
ja 0xee274
cmpq %rcx, %rdx
jne 0xee3ce
movq 0x20(%r12), %rax
movq 0x48(%r14), %rcx
xorl %esi, %esi
movl (%rcx,%rsi,4), %edi
shrl %edi
movb $0x1, 0x4(%rax,%rdi,8)
incq %rsi
movl %esi, %edi
cmpq %rdi, %rdx
ja 0xee29e
xorl %eax, %eax
movq 0x48(%r14), %rcx
movl (%rcx,%rax,4), %ecx
movl %ecx, %esi
shrl %esi
movq 0x20(%r12), %rdi
cmpb $0x1, 0x4(%rdi,%rsi,8)
jne 0xee3b7
movq %r14, %rbx
andl $-0x2, %ecx
movb $0x1, %dl
xorl %esi, %esi
orq %rcx, %rsi
movq 0x28(%r12), %rdi
movq (%rdi,%rsi,8), %r8
movq %r8, %rdi
andq %r13, %rdi
je 0xee395
shrq $0x20, %r8
leaq (%r8,%r8,2), %r8
shlq $0x3, %r8
addq 0x8(%r12), %r8
xorl %r9d, %r9d
leaq (%r9,%r9,2), %r11
movl 0xc(%r8,%r11,8), %r10d
testl %r10d, %r10d
js 0xee389
leaq (%r8,%r11,8), %r14
movq 0x20(%r12), %rbp
movl 0x8(%r14), %r15d
movl %r15d, %r11d
shrl %r11d
cmpb $0x1, 0x4(%rbp,%r11,8)
je 0xee389
orl $0x80000000, %r10d      # imm = 0x80000000
movl %r10d, 0xc(%r14)
xorq $0x1, %r15
movq 0x28(%r12), %r10
movq (%r10,%r15,8), %r11
movq %r11, %r10
andq %r13, %r10
je 0xee389
movq 0x8(%r12), %r14
shrq $0x20, %r11
shlq $0x3, %r10
leaq (%r10,%r10,2), %r10
leaq (%r11,%r11,2), %r11
leaq (%r14,%r11,8), %r11
addq $0xc, %r11
xorl %r14d, %r14d
movl -0x4(%r11,%r14), %ebp
xorl %esi, %ebp
cmpl $0x1, %ebp
jne 0xee380
orb $-0x80, 0x3(%r11,%r14)
addq $0x18, %r14
cmpq %r14, %r10
jne 0xee36e
incq %r9
cmpq %rdi, %r9
jne 0xee305
movl $0x1, %esi
testb $0x1, %dl
movl $0x0, %edx
jne 0xee2d9
movq %rbx, %r14
movq 0x38(%rbx), %rdx
movl 0x24(%rsp), %ebp
movl 0x20(%rsp), %ebx
incl %eax
cmpq %rax, %rdx
ja 0xee2b4
movq 0x10(%rsp), %rax
incl %eax
movq %rax, 0x10(%rsp)
movq 0x18(%rsp), %rdx
movl 0x8(%rsp), %ecx
movl $0x1, %eax
testb $0x1, %cl
movl $0x0, %ecx
jne 0xee1ae
movq 0x38(%rsp), %rdx
incl %edx
cmpq 0x28(%rsp), %rdx
jb 0xee178
cmpl $0x0, 0xc(%rsp)
jne 0xee162
movq 0x10(%rsp), %rax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq