// File: /workspace/github_cpp_makefile_star2_O2/chhylp123[P]hifiasm/hic.cpp
// Function: dfs_bubble_broken(asg_t*, kvec_t_u32_warp*, kvec_t_u32_warp*, unsigned char*, unsigned int, unsigned int, unsigned int, unsigned int)
void dfs_bubble_broken(asg_t *g, kvec_t_u32_warp* stack, kvec_t_u32_warp* result, uint8_t* vis_flag, 
uint32_t vis_flag_n, uint32_t v_d, uint32_t beg_d, uint32_t sink_d)
{
    memset(vis_flag, 0, vis_flag_n);
    asg_arc_t *acur = NULL;
    uint32_t cur, ncur, i, p_beg = (uint32_t)-1, p_sink = (uint32_t)-1, v;
    stack->a.n = result->a.n = 0;
    v = v_d;
    if(v != (beg_d^1) && v != (sink_d^1)) kv_push(uint32_t, stack->a, v);
    while (stack->a.n > 0)
    {
        stack->a.n--;
        cur = stack->a.a[stack->a.n];
        vis_flag[cur] = 1;
        if((v>>1) != (cur>>1)) kv_push(uint32_t, result->a, cur>>1);
        ncur = asg_arc_n(g, cur);
        acur = asg_arc_a(g, cur);
        for (i = 0; i < ncur; i++)
        {
            if(acur[i].del) continue;
            if(vis_flag[acur[i].v]) continue;
            if((acur[i].v>>1) == (beg_d>>1) || (acur[i].v>>1) == (sink_d>>1))
            {
                if((acur[i].v>>1) == (beg_d>>1)) p_beg = acur[i].v;
                if((acur[i].v>>1) == (sink_d>>1)) p_sink = acur[i].v;
                continue;
            } 
            kv_push(uint32_t, stack->a, acur[i].v);
        }
    }
    
    memset(vis_flag, 0, vis_flag_n);
    v ^= 1;
    if(v != (beg_d^1) && v != (sink_d^1)) kv_push(uint32_t, stack->a, v);
    while (stack->a.n > 0)
    {
        stack->a.n--;
        cur = stack->a.a[stack->a.n];
        vis_flag[cur] = 1;
        if((v>>1) != (cur>>1)) kv_push(uint32_t, result->a, cur>>1);
        ncur = asg_arc_n(g, cur);
        acur = asg_arc_a(g, cur);
        for (i = 0; i < ncur; i++)
        {
            if(acur[i].del) continue;
            if(vis_flag[acur[i].v]) continue;
            if((acur[i].v>>1) == (beg_d>>1) || (acur[i].v>>1) == (sink_d>>1))
            {
                if((acur[i].v>>1) == (beg_d>>1)) p_beg = acur[i].v;
                if((acur[i].v>>1) == (sink_d>>1)) p_sink = acur[i].v;
                continue;
            } 
            kv_push(uint32_t, stack->a, acur[i].v);
        }
    }

    if(p_beg != (uint32_t)-1) kv_push(uint32_t, result->a, beg_d>>1);
    if(p_sink != (uint32_t)-1) kv_push(uint32_t, result->a, sink_d>>1);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movl %r9d, %r12d
movq %rcx, %r14
movq %rdx, %r13
movq %rsi, %r15
movq %rdi, 0x20(%rsp)
movl 0x70(%rsp), %ebp
movl %r8d, %edx
xorl %ebx, %ebx
movq %rcx, %rdi
xorl %esi, %esi
movq %rdx, 0x30(%rsp)
callq 0x20e0
andq $0x0, (%r13)
andq $0x0, (%r15)
xorl %r12d, %ebp
cmpl $0x1, %ebp
sete %al
movl 0x78(%rsp), %ecx
xorl %r12d, %ecx
cmpl $0x1, %ecx
sete %cl
orb %al, %cl
jne 0xf6bc0
cmpq $0x0, 0x8(%r15)
je 0xf6b9a
movq 0x10(%r15), %rax
xorl %ecx, %ecx
jmp 0xf6bb5
movq $0x2, 0x8(%r15)
movq 0x10(%r15), %rdi
pushq $0x8
popq %rsi
callq 0x2370
movq %rax, 0x10(%r15)
movq (%r15), %rcx
leaq 0x1(%rcx), %rbx
movq %rbx, (%r15)
movl %r12d, (%rax,%rcx,4)
movl %r12d, 0x4(%rsp)
shrl %r12d
movl %r12d, 0xc(%rsp)
movl 0x70(%rsp), %ebp
shrl %ebp
movl 0x78(%rsp), %edi
shrl %edi
pushq $-0x1
popq %r9
movl %r9d, %r8d
movq %r13, 0x28(%rsp)
movl %edi, (%rsp)
movl %ebp, 0x8(%rsp)
movq %r14, 0x10(%rsp)
testq %rbx, %rbx
je 0xf6d57
leaq -0x1(%rbx), %rax
movq %rax, (%r15)
movq 0x10(%r15), %rax
movl -0x4(%rax,%rbx,4), %ebx
movb $0x1, (%r14,%rbx)
movl %ebx, %r12d
shrl %r12d
cmpl %r12d, 0xc(%rsp)
je 0xf6c72
movq (%r13), %rcx
movq 0x10(%r13), %rax
cmpq 0x8(%r13), %rcx
jne 0xf6c66
leaq (%rcx,%rcx), %rsi
testq %rcx, %rcx
pushq $0x2
popq %rcx
cmoveq %rcx, %rsi
movq %rsi, 0x8(%r13)
shlq $0x2, %rsi
movq %rax, %rdi
movl %r8d, 0x1c(%rsp)
movl %r9d, 0x18(%rsp)
callq 0x2370
movl 0x18(%rsp), %r9d
movl 0x1c(%rsp), %r8d
movl (%rsp), %edi
movq %rax, 0x10(%r13)
movq (%r13), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, (%r13)
movl %r12d, (%rax,%rcx,4)
movq 0x20(%rsp), %rcx
movq 0x8(%rcx), %rax
movq 0x28(%rcx), %rcx
movq (%rcx,%rbx,8), %rcx
movl %ecx, %edx
shrq $0x20, %rcx
imulq $0x18, %rdx, %r13
imulq $0x18, %rcx, %rcx
leaq (%rax,%rcx), %rbx
addq $0x8, %rbx
xorl %r12d, %r12d
cmpq %r12, %r13
je 0xf6d4a
cmpl $0x0, 0x4(%rbx,%r12)
js 0xf6d41
movl (%rbx,%r12), %ecx
cmpb $0x0, (%r14,%rcx)
jne 0xf6d41
movl %ecx, %eax
shrl %eax
cmpl %ebp, %eax
setne %dl
cmpl %edi, %eax
setne %sil
testb %sil, %dl
jne 0xf6ce9
cmpl %ebp, %eax
cmovel %ecx, %r9d
movl %ecx, %eax
xorl 0x78(%rsp), %eax
cmpl $0x2, %eax
cmovbl %ecx, %r8d
jmp 0xf6d41
movq (%r15), %rdx
movq 0x10(%r15), %rax
cmpq 0x8(%r15), %rdx
jne 0xf6d37
leaq (%rdx,%rdx), %rsi
testq %rdx, %rdx
pushq $0x2
popq %rcx
cmoveq %rcx, %rsi
movq %rsi, 0x8(%r15)
shlq $0x2, %rsi
movq %rax, %rdi
movl %r8d, %ebp
movl %r9d, %r14d
callq 0x2370
movl %r14d, %r9d
movq 0x10(%rsp), %r14
movl %ebp, %r8d
movl 0x8(%rsp), %ebp
movl (%rsp), %edi
movq %rax, 0x10(%r15)
movl (%rbx,%r12), %ecx
movq (%r15), %rdx
leaq 0x1(%rdx), %rsi
movq %rsi, (%r15)
movl %ecx, (%rax,%rdx,4)
addq $0x18, %r12
jmp 0xf6c9c
movq (%r15), %rbx
movq 0x28(%rsp), %r13
jmp 0xf6bf1
movl %r9d, %r12d
movl %r8d, %ebx
movq %r14, %rdi
xorl %esi, %esi
movq 0x30(%rsp), %rdx
callq 0x20e0
movl 0x4(%rsp), %r8d
cmpl 0x70(%rsp), %r8d
sete %al
cmpl 0x78(%rsp), %r8d
sete %cl
orb %al, %cl
jne 0xf6dd0
xorl $0x1, %r8d
movq (%r15), %rcx
movq 0x10(%r15), %rax
cmpq 0x8(%r15), %rcx
jne 0xf6dc5
leaq (%rcx,%rcx), %rsi
testq %rcx, %rcx
pushq $0x2
popq %rcx
cmoveq %rcx, %rsi
movq %rsi, 0x8(%r15)
shlq $0x2, %rsi
movq %rax, %rdi
movl %r8d, 0x4(%rsp)
callq 0x2370
movl 0x4(%rsp), %r8d
movq %rax, 0x10(%r15)
movq (%r15), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, (%r15)
movl %r8d, (%rax,%rcx,4)
movl (%rsp), %edi
movl %ebx, %r8d
movl %r12d, %r9d
movq (%r15), %rax
testq %rax, %rax
je 0xf6f40
leaq -0x1(%rax), %rcx
movq %rcx, (%r15)
movq 0x10(%r15), %rcx
movl -0x4(%rcx,%rax,4), %ebx
movb $0x1, (%r14,%rbx)
movl %ebx, %r12d
shrl %r12d
cmpl %r12d, 0xc(%rsp)
je 0xf6e5e
movq (%r13), %rcx
movq 0x10(%r13), %rax
cmpq 0x8(%r13), %rcx
jne 0xf6e52
leaq (%rcx,%rcx), %rsi
testq %rcx, %rcx
pushq $0x2
popq %rcx
cmoveq %rcx, %rsi
movq %rsi, 0x8(%r13)
shlq $0x2, %rsi
movq %rax, %rdi
movl %r8d, %ebp
movl %r9d, %r14d
callq 0x2370
movl %r14d, %r9d
movq 0x10(%rsp), %r14
movl %ebp, %r8d
movl 0x8(%rsp), %ebp
movl (%rsp), %edi
movq %rax, 0x10(%r13)
movq (%r13), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, (%r13)
movl %r12d, (%rax,%rcx,4)
movq 0x20(%rsp), %rcx
movq 0x8(%rcx), %rax
movq 0x28(%rcx), %rcx
movq (%rcx,%rbx,8), %rcx
movl %ecx, %edx
shrq $0x20, %rcx
imulq $0x18, %rdx, %r13
imulq $0x18, %rcx, %rcx
leaq (%rax,%rcx), %rbx
addq $0x8, %rbx
xorl %r12d, %r12d
cmpq %r12, %r13
je 0xf6f36
cmpl $0x0, 0x4(%rbx,%r12)
js 0xf6f2d
movl (%rbx,%r12), %ecx
cmpb $0x0, (%r14,%rcx)
jne 0xf6f2d
movl %ecx, %eax
shrl %eax
cmpl %ebp, %eax
setne %dl
cmpl %edi, %eax
setne %sil
testb %sil, %dl
jne 0xf6ed5
cmpl %ebp, %eax
cmovel %ecx, %r9d
movl %ecx, %eax
xorl 0x78(%rsp), %eax
cmpl $0x2, %eax
cmovbl %ecx, %r8d
jmp 0xf6f2d
movq (%r15), %rdx
movq 0x10(%r15), %rax
cmpq 0x8(%r15), %rdx
jne 0xf6f23
leaq (%rdx,%rdx), %rsi
testq %rdx, %rdx
pushq $0x2
popq %rcx
cmoveq %rcx, %rsi
movq %rsi, 0x8(%r15)
shlq $0x2, %rsi
movq %rax, %rdi
movl %r8d, %ebp
movl %r9d, %r14d
callq 0x2370
movl %r14d, %r9d
movq 0x10(%rsp), %r14
movl %ebp, %r8d
movl 0x8(%rsp), %ebp
movl (%rsp), %edi
movq %rax, 0x10(%r15)
movl (%rbx,%r12), %ecx
movq (%r15), %rdx
leaq 0x1(%rdx), %rsi
movq %rsi, (%r15)
movl %ecx, (%rax,%rdx,4)
addq $0x18, %r12
jmp 0xf6e88
movq 0x28(%rsp), %r13
jmp 0xf6dd9
cmpl $-0x1, %r9d
je 0xf6f8e
movq (%r13), %rcx
movq 0x10(%r13), %rax
cmpq 0x8(%r13), %rcx
jne 0xf6f83
leaq (%rcx,%rcx), %rsi
testq %rcx, %rcx
pushq $0x2
popq %rcx
cmoveq %rcx, %rsi
movq %rsi, 0x8(%r13)
shlq $0x2, %rsi
movq %rax, %rdi
movl %r8d, %ebx
callq 0x2370
movl %ebx, %r8d
movl (%rsp), %edi
movq %rax, 0x10(%r13)
movq (%r13), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, (%r13)
movl %ebp, (%rax,%rcx,4)
cmpl $-0x1, %r8d
je 0xf6fd6
movq (%r13), %rcx
movq 0x10(%r13), %rax
cmpq 0x8(%r13), %rcx
jne 0xf6fcb
leaq (%rcx,%rcx), %rsi
testq %rcx, %rcx
pushq $0x2
popq %rcx
cmoveq %rcx, %rsi
movq %rsi, 0x8(%r13)
shlq $0x2, %rsi
movq %rax, %rdi
callq 0x2370
movl (%rsp), %edi
movq %rax, 0x10(%r13)
movq (%r13), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, (%r13)
movl %edi, (%rax,%rcx,4)
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq