// File: /workspace/github_cpp_makefile_star2_O3/chhylp123[P]hifiasm/Overlaps.cpp
// Function: asg_cut_internal(asg_t*, int)
int asg_cut_internal(asg_t *g, int max_ext)
{
	asg64_v a = {0,0,0};
	uint32_t n_vtx = g->n_seq * 2, v, i, cnt = 0;
	for (v = 0; v < n_vtx; ++v) {
		if (g->seq[v>>1].del) continue;
		if (asg_is_utg_end(g, v, 0) != ASG_ET_MULTI_NEI) continue;
		if (asg_extend(g, v, max_ext, &a) != ASG_ET_MULTI_NEI) continue;
		/**
		 * so combining the last two lines, they are designed to reomve(n(1), n(2))?
							   ----->              <-------
							  |                		      |
							 n(0)--->n(1)---->n(2)---->n(3)
							  |                           |
							   ------>             <-------       
		**/
		for (i = 0; i < a.n; ++i)
			asg_seq_del(g, (uint32_t)a.a[i]>>1);
		++cnt;
	}
	free(a.a);
	if (cnt > 0) asg_cleanup(g);
	fprintf(stderr, "[M::%s] cut %d internal sequences\n", __func__, cnt);
	return cnt;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl %esi, %r13d
andq $0x0, 0x20(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movl 0x14(%rdi), %esi
addl %esi, %esi
je 0x7bb3
movq %rdi, %r14
xorl %r15d, %r15d
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
pushq $0x1
popq %rbx
xorl %r12d, %r12d
movl %r13d, 0xc(%rsp)
movl %esi, 0x8(%rsp)
movq 0x20(%r14), %rax
movl %r12d, %ecx
shrl %ecx
cmpl $0x0, (%rax,%rcx,8)
js 0x7b98
movq 0x28(%r14), %rcx
movl %r12d, %eax
xorl $0x1, %eax
movq (%rcx,%rax,8), %rdx
testl %edx, %edx
jle 0x7b98
movq 0x8(%r14), %rax
movq %rdx, %rsi
shrq $0x20, %rsi
imulq $0x18, %rsi, %rdi
leaq (%rax,%rdi), %rsi
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
addq %rax, %rdi
addq $0xc, %rdi
xorl %r8d, %r8d
xorl %r10d, %r10d
pushq $-0x1
popq %r9
xorl %r11d, %r11d
cmpl $0x0, (%rdi)
setns %r11b
cmovnsl %r8d, %r9d
addl %r11d, %r10d
incq %r8
addq $0x18, %rdi
cmpq %r8, %rdx
jne 0x7a0f
cmpl $0x1, %r10d
jne 0x7b94
movslq %r9d, %rdx
imulq $0x18, %rdx, %rdx
movl 0x8(%rsi,%rdx), %edx
xorq $0x1, %rdx
movq (%rcx,%rdx,8), %rcx
testl %ecx, %ecx
jle 0x7a82
movq %rcx, %rdx
shrq $0x20, %rdx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
imulq $0x18, %rdx, %rdx
addq %rax, %rdx
addq $0xc, %rdx
xorl %eax, %eax
movl (%rdx), %esi
notl %esi
shrl $0x1f, %esi
addl %esi, %eax
addq $0x18, %rdx
decq %rcx
jne 0x7a67
cmpl $0x1, %eax
je 0x7b94
movq %r14, %rdi
movl %r12d, %esi
movl %r13d, %edx
leaq 0x10(%rsp), %rcx
callq 0xa3ac7
cmpl $0x3, %eax
jne 0x7b94
movq %r15, 0x30(%rsp)
movq 0x10(%rsp), %rax
movq %rax, 0x40(%rsp)
testq %rax, %rax
je 0x7b87
movq 0x20(%rsp), %rax
movq %rax, 0x38(%rsp)
xorl %edx, %edx
movq 0x38(%rsp), %rax
movq (%rax,%rdx,8), %rsi
movl %esi, %ecx
shrl %ecx
movq 0x20(%r14), %rdi
orl $0x80000000, (%rdi,%rcx,8) # imm = 0x80000000
andl $-0x2, %esi
movb $0x1, %dil
xorl %r8d, %r8d
orq %rsi, %r8
movq 0x28(%r14), %rcx
movq (%rcx,%r8,8), %rcx
movq %rcx, %r9
andq %rbp, %r9
je 0x7b65
shrq $0x20, %rcx
imulq $0x18, %rcx, %r10
addq 0x8(%r14), %r10
xorl %r11d, %r11d
imulq $0x18, %r11, %rcx
orb $-0x80, 0xf(%r10,%rcx)
movl 0x8(%r10,%rcx), %ecx
xorq $0x1, %rcx
movq 0x28(%r14), %r15
movq (%r15,%rcx,8), %rcx
movq %rcx, %r15
andq %rbp, %r15
je 0x7b5d
movq 0x8(%r14), %r13
shrq $0x20, %rcx
imulq $0x18, %r15, %r15
imulq $0x18, %rcx, %rcx
addq %rcx, %r13
addq $0xc, %r13
xorl %ecx, %ecx
movl -0x4(%r13,%rcx), %eax
xorl %r8d, %eax
cmpl $0x1, %eax
jne 0x7b54
orb $-0x80, 0x3(%r13,%rcx)
addq $0x18, %rcx
cmpq %rcx, %r15
jne 0x7b41
incq %r11
cmpq %r9, %r11
jne 0x7b05
movq %rbx, %r8
testb $0x1, %dil
movl $0x0, %edi
jne 0x7ae3
incq %rdx
movl %edx, %eax
cmpq %rax, 0x40(%rsp)
ja 0x7ac2
movq 0x30(%rsp), %r15
incl %r15d
movl 0xc(%rsp), %r13d
movl 0x8(%rsp), %esi
incl %r12d
cmpl %esi, %r12d
jne 0x79bc
movq 0x20(%rsp), %rdi
callq 0x2220
testl %r15d, %r15d
jne 0x7bb8
xorl %r15d, %r15d
jmp 0x7bc0
movq %r14, %rdi
callq 0xa0a7d
movq 0x28d419(%rip), %rax    # 0x294fe0
movq (%rax), %rdi
leaq 0x22ea52(%rip), %rsi    # 0x236623
leaq 0x22ea6e(%rip), %rdx    # 0x236646
movl %r15d, %ecx
xorl %eax, %eax
callq 0x22b0
movl %r15d, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq