// File: /workspace/github_cpp_makefile_star2_O3/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
movq 0x50(%rdx), %rbx
movq 0x18(%rdi), %r12
cmpq $0x0, 0x38(%rdx)
movq %rbx, %rax
je 0x2111fc
movl $0x1, %eax
xorl %ecx, %ecx
movq 0x20(%r12), %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 0x2111d9
movq 0x50(%r11), %rax
testq %rax, %rax
je 0x211296
xorl %eax, %eax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
movq 0x8(%r12), %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(%r12), %rdi
movq 0x28(%r12), %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 0x21128a
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 0x211281
orb $-0x80, 0x3(%rdi,%r9)
addq $0x18, %r9
cmpq %r9, %r8
jne 0x21126d
incl %eax
cmpq %rax, 0x50(%r11)
ja 0x21120c
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(%r12), %rdi
movl %edx, %r8d
shrl %r8d
andl $0x7fffffff, (%rdi,%r8,8) # imm = 0x7FFFFFFF
movq 0x8(%r12), %rdi
movq 0x28(%r12), %r8
movq (%r8,%rcx,8), %r9
movq %r9, %r10
andq %rax, %r10
je 0x211319
shrq $0x20, %r9
shlq $0x3, %r10
leaq (%r10,%r10,2), %r8
leaq (%r9,%r9,2), %r9
leaq (%rdi,%r9,8), %rdi
addq $0xc, %rdi
xorl %r9d, %r9d
cmpl %edx, -0x4(%rdi,%r9)
jne 0x211306
andb $0x7f, 0x3(%rdi,%r9)
addq $0x18, %r9
cmpq %r9, %r8
jne 0x2112f9
movq 0x8(%r12), %rdi
movq 0x28(%r12), %r8
xorl $0x1, %edx
movq (%r8,%rdx,8), %r8
movq %r8, %rdx
andq %rax, %rdx
je 0x211360
shrq $0x20, %r8
shlq $0x3, %rdx
leaq (%rdx,%rdx,2), %rdx
leaq (%r8,%r8,2), %r8
leaq (%rdi,%r8,8), %rdi
addq $0xc, %rdi
xorl %r8d, %r8d
movl -0x4(%rdi,%r8), %r9d
xorl %ecx, %r9d
cmpl $0x1, %r9d
jne 0x211357
andb $0x7f, 0x3(%rdi,%r8)
addq $0x18, %r8
cmpq %r8, %rdx
jne 0x211343
decl %ebx
movl %ecx, %edx
cmpl %esi, %ecx
jne 0x2112a1
movq %rbx, (%rsp)
movq 0x38(%r11), %rdx
testq %rdx, %rdx
je 0x2114aa
xorl %r13d, %r13d
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movq %r11, 0x10(%rsp)
movq %r14, 0x8(%rsp)
movq 0x20(%r12), %rsi
movq 0x48(%r11), %rax
movl (%rax,%r13,4), %ecx
movl %ecx, %eax
shrl %eax
cmpl $0x0, (%rsi,%rax,8)
jns 0x21149e
movq 0x18(%r14), %rdx
movq 0x20(%rdx), %rsi
orl $0x80000000, (%rsi,%rax,8) # imm = 0x80000000
andl $-0x2, %ecx
movb $0x1, %sil
xorl %edi, %edi
orq %rcx, %rdi
movq 0x28(%rdx), %r8
movq (%r8,%rdi,8), %r9
movq %r9, %r8
andq %rbp, %r8
je 0x21144d
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 %rbp, %r11
je 0x211445
movq 0x8(%rdx), %r15
shrq $0x20, %rbx
shlq $0x3, %r11
leaq (%r11,%r11,2), %r11
leaq (%rbx,%rbx,2), %rbx
leaq (%r15,%rbx,8), %r15
addq $0xc, %r15
xorl %ebx, %ebx
movl -0x4(%r15,%rbx), %r14d
xorl %edi, %r14d
cmpl $0x1, %r14d
jne 0x21143c
orb $-0x80, 0x3(%r15,%rbx)
addq $0x18, %rbx
cmpq %rbx, %r11
jne 0x211428
incq %r10
cmpq %r8, %r10
jne 0x2113e7
movl $0x1, %edi
testb $0x1, %sil
movl $0x0, %esi
jne 0x2113c1
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
movq 0x38(%r11), %rdx
incl %r13d
cmpq %r13, %rdx
ja 0x21138f
movq (%rsp), %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq