// File: /workspace/github_c_makefile_star2_O3/rikuu[P]kermit/miniasm/asg.c
// Function: asg_cut_tip
int asg_cut_tip(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_TIP) continue; // not a tip
		if (asg_extend(g, v, max_ext, &a) == ASG_ET_MERGEABLE) continue; // not a short unitig
		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 tips\n", __func__, cnt);
	return cnt;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl %esi, 0xc(%rsp)
andq $0x0, 0x20(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movl 0x14(%rdi), %r13d
addl %r13d, %r13d
je 0x1906
movq %rdi, %r14
xorl %ebx, %ebx
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
pushq $0x1
popq %rbp
xorl %r12d, %r12d
movl %r13d, 0x8(%rsp)
movq 0x18(%r14), %rax
movl %r12d, %ecx
shrl %ecx
cmpl $0x0, (%rax,%rcx,4)
js 0x18ec
movq 0x20(%r14), %rax
movl %r12d, %ecx
xorl $0x1, %ecx
movq (%rax,%rcx,8), %rcx
movq %rcx, %rax
andq %r15, %rax
je 0x17d8
movq 0x8(%r14), %rdx
shrq $0x20, %rcx
shlq $0x4, %rax
shlq $0x4, %rcx
addq %rdx, %rcx
addq $0xc, %rcx
xorl %edx, %edx
xorl %esi, %esi
movl (%rcx,%rdx), %edi
notl %edi
shrl $0x1f, %edi
addl %edi, %esi
addq $0x10, %rdx
cmpq %rdx, %rax
jne 0x17bd
testl %esi, %esi
jne 0x18ec
movq %r14, %rdi
movl %r12d, %esi
movl 0xc(%rsp), %edx
leaq 0x10(%rsp), %rcx
callq 0x4116
testl %eax, %eax
je 0x18ec
movq %rbx, 0x30(%rsp)
movq 0x10(%rsp), %rax
movq %rax, 0x40(%rsp)
testq %rax, %rax
je 0x18e0
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 0x18(%r14), %rdi
orl $0x80000000, (%rdi,%rcx,4) # imm = 0x80000000
andl $-0x2, %esi
movb $0x1, %dil
xorl %r8d, %r8d
orq %rsi, %r8
movq 0x20(%r14), %rcx
movq (%rcx,%r8,8), %r9
movq %r9, %r10
andq %r15, %r10
je 0x18be
shrq $0x1c, %r9
andq $-0x10, %r9
addq 0x8(%r14), %r9
xorl %r11d, %r11d
movq %r11, %rcx
shlq $0x4, %rcx
orb $-0x80, 0xf(%r9,%rcx)
movl 0x8(%r9,%rcx), %ecx
xorq $0x1, %rcx
movq 0x20(%r14), %rbx
movq (%rbx,%rcx,8), %rcx
movq %rcx, %rbx
andq %r15, %rbx
je 0x18b6
movq 0x8(%r14), %r13
shrq $0x20, %rcx
shlq $0x4, %rbx
shlq $0x4, %rcx
addq %rcx, %r13
addq $0xc, %r13
xorl %ecx, %ecx
movl -0x4(%r13,%rcx), %eax
xorl %r8d, %eax
cmpl $0x1, %eax
jne 0x18ad
orb $-0x80, 0x3(%r13,%rcx)
addq $0x10, %rcx
cmpq %rcx, %rbx
jne 0x189a
incq %r11
cmpq %r10, %r11
jne 0x185b
movq %rbp, %r8
testb $0x1, %dil
movl $0x0, %edi
jne 0x1839
incq %rdx
movl %edx, %eax
cmpq %rax, 0x40(%rsp)
ja 0x1818
movq 0x30(%rsp), %rbx
incl %ebx
movl 0x8(%rsp), %r13d
incl %r12d
cmpl %r13d, %r12d
jne 0x1779
movq 0x20(%rsp), %rdi
callq 0x1040
testl %ebx, %ebx
jne 0x190a
xorl %ebx, %ebx
jmp 0x1912
movq %r14, %rdi
callq 0x40c7
movq 0xc6df(%rip), %rax      # 0xdff8
movq (%rax), %rdi
leaq 0x8819(%rip), %rsi      # 0xa13c
leaq 0x8827(%rip), %rdx      # 0xa151
movl %ebx, %ecx
xorl %eax, %eax
callq 0x1120
movl %ebx, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq