// File: /workspace/github_cpp_makefile_star2_O1/chhylp123[P]hifiasm/gfa_ut.cpp
// Function: ulg_bub_pop_backtrack(ma_ug_t*, unsigned int, buf_t*)
uint32_t ulg_bub_pop_backtrack(ma_ug_t *ug, uint32_t v0, buf_t *b)
{
	uint32_t i, v, u, cnt = b->e.n; asg_t *g = ug->g;

    ///b->S.a[0] is the sink of this bubble
	for (i = 0; i < b->b.n; ++i) g->seq[b->b.a[i]>>1].del = 1;

    ///remove all edges (self/reverse for each edge) in this bubble
	for (i = 0; i < b->e.n; ++i) {
        g->arc[b->e.a[i]].del = 1;
        asg_arc_del(g, g->arc[b->e.a[i]].v^1, (g->arc[b->e.a[i]].ul>>32)^1, 1);
	}

    ///v is the sink of this bubble
	v = b->S.a[0];
	do {
		u = b->a[v].p; // u->v
		g->seq[v>>1].del = 0;
		asg_arc_del(g, u, v, 0);
		asg_arc_del(g, v^1, u^1, 0);
        cnt--;
		v = u;
	} while (v != v0);

    for (i = 0; i < b->b.n; ++i) {
        if(!g->seq[b->b.a[i]>>1].del) continue;
        ulg_seq_del(ug, (b->b.a[i]>>1));
    }

    return cnt;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdx, %r11
movq %rdi, %r14
movl 0x50(%rdx), %ebx
movq 0x18(%rdi), %r15
cmpq $0x0, 0x38(%rdx)
je 0x205ce8
movl $0x1, %eax
xorl %ecx, %ecx
movq 0x20(%r15), %rdx
movq 0x48(%r11), %rdi
movl (%rdi,%rcx,4), %ecx
shrl %ecx
orl $0x80000000, (%rdx,%rcx,8) # imm = 0x80000000
movl %eax, %ecx
incl %eax
cmpq %rcx, 0x38(%r11)
ja 0x205cca
cmpq $0x0, 0x50(%r11)
je 0x205d81
xorl %eax, %eax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
movq 0x8(%r15), %rdx
movq 0x60(%r11), %rdi
movl (%rdi,%rax,4), %edi
leaq (%rdi,%rdi,2), %rdi
orl $0x80000000, 0xc(%rdx,%rdi,8) # imm = 0x80000000
movq 0x8(%r15), %rdi
movq 0x28(%r15), %r8
movq 0x60(%r11), %rdx
movl (%rdx,%rax,4), %edx
leaq (%rdx,%rdx,2), %rdx
movl 0x8(%rdi,%rdx,8), %r9d
xorq $0x1, %r9
movq (%r8,%r9,8), %r9
movq %r9, %r8
andq %rcx, %r8
je 0x205d75
movl 0x4(%rdi,%rdx,8), %edx
shrq $0x20, %r9
shlq $0x3, %r8
leaq (%r8,%r8,2), %r8
leaq (%r9,%r9,2), %r9
leaq (%rdi,%r9,8), %rdi
addq $0xc, %rdi
xorl %r9d, %r9d
movl -0x4(%rdi,%r9), %r10d
xorl %edx, %r10d
cmpl $0x1, %r10d
jne 0x205d6c
orb $-0x80, 0x3(%rdi,%r9)
addq $0x18, %r9
cmpq %r9, %r8
jne 0x205d58
incl %eax
cmpq %rax, 0x50(%r11)
ja 0x205cfa
movq 0x18(%r11), %rax
movl (%rax), %edx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movq (%r11), %rcx
movl %edx, %edi
leaq (%rdi,%rdi,8), %r8
leaq (%r8,%r8,2), %r8
addq %rdi, %r8
movl (%rcx,%r8), %ecx
movq 0x20(%r15), %rdi
movl %edx, %r8d
shrl %r8d
andl $0x7fffffff, (%rdi,%r8,8) # imm = 0x7FFFFFFF
movq 0x28(%r15), %rdi
movq (%rdi,%rcx,8), %r8
movq %r8, %rdi
andq %rax, %rdi
je 0x205df7
movq 0x8(%r15), %r9
shrq $0x20, %r8
shlq $0x3, %rdi
leaq (%rdi,%rdi,2), %rdi
leaq (%r8,%r8,2), %r8
leaq (%r9,%r8,8), %r8
addq $0xc, %r8
xorl %r9d, %r9d
cmpl %edx, -0x4(%r8,%r9)
jne 0x205dee
andb $0x7f, 0x3(%r8,%r9)
addq $0x18, %r9
cmpq %r9, %rdi
jne 0x205de1
xorl $0x1, %edx
movq 0x28(%r15), %rdi
movq (%rdi,%rdx,8), %rdi
movq %rdi, %rdx
andq %rax, %rdx
je 0x205e46
movq 0x8(%r15), %r8
shrq $0x20, %rdi
shlq $0x3, %rdx
leaq (%rdx,%rdx,2), %rdx
leaq (%rdi,%rdi,2), %rdi
leaq (%r8,%rdi,8), %rdi
addq $0xc, %rdi
xorl %r8d, %r8d
movl -0x4(%rdi,%r8), %r9d
xorl %ecx, %r9d
cmpl $0x1, %r9d
jne 0x205e3d
andb $0x7f, 0x3(%rdi,%r8)
addq $0x18, %r8
cmpq %r8, %rdx
jne 0x205e29
decl %ebx
movl %ecx, %edx
cmpl %esi, %ecx
jne 0x205d8c
movl %ebx, 0x4(%rsp)
cmpq $0x0, 0x38(%r11)
je 0x205f83
xorl %r12d, %r12d
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
movq %r11, 0x10(%rsp)
movq %r14, 0x8(%rsp)
movq 0x20(%r15), %rdx
movq 0x48(%r11), %rax
movl (%rax,%r12,4), %ecx
movl %ecx, %eax
shrl %eax
cmpl $0x0, (%rdx,%rax,8)
jns 0x205f76
movq 0x18(%r14), %rdx
movq 0x20(%rdx), %rsi
orl $0x80000000, (%rsi,%rax,8) # imm = 0x80000000
andl $-0x2, %ecx
xorl %esi, %esi
leaq (%rsi,%rcx), %rdi
movq 0x28(%rdx), %r8
movq (%r8,%rdi,8), %r9
movq %r9, %r8
andq %r13, %r8
je 0x205f2d
shrq $0x20, %r9
leaq (%r9,%r9,2), %r9
shlq $0x3, %r9
addq 0x8(%rdx), %r9
xorl %r10d, %r10d
leaq (%r10,%r10,2), %r11
orb $-0x80, 0xf(%r9,%r11,8)
movl 0x8(%r9,%r11,8), %r11d
xorq $0x1, %r11
movq 0x28(%rdx), %rbx
movq (%rbx,%r11,8), %rbx
movq %rbx, %r11
andq %r13, %r11
je 0x205f25
movq 0x8(%rdx), %r14
shrq $0x20, %rbx
shlq $0x3, %r11
leaq (%r11,%r11,2), %r11
leaq (%rbx,%rbx,2), %rbx
leaq (%r14,%rbx,8), %r14
addq $0xc, %r14
xorl %ebx, %ebx
movl -0x4(%r14,%rbx), %ebp
xorl %edi, %ebp
cmpl $0x1, %ebp
jne 0x205f1c
orb $-0x80, 0x3(%r14,%rbx)
addq $0x18, %rbx
cmpq %rbx, %r11
jne 0x205f0a
incq %r10
cmpq %r8, %r10
jne 0x205ec9
leaq 0x1(%rsi), %rdi
testq %rsi, %rsi
movq %rdi, %rsi
je 0x205ea2
movq 0x8(%rsp), %r14
movq 0x10(%r14), %rcx
shlq $0x3, %rax
leaq (%rax,%rax,4), %rbx
movq 0x18(%rcx,%rbx), %rdi
callq 0x2220
movq 0x10(%r14), %rax
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rax,%rbx)
movups %xmm0, (%rax,%rbx)
movq $0x0, 0x20(%rax,%rbx)
movq 0x10(%rsp), %r11
incl %r12d
cmpq %r12, 0x38(%r11)
ja 0x205e74
movl 0x4(%rsp), %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq