// File: /workspace/github_cpp_makefile_star2_O3/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, %ebp
movq %rcx, %r14
movq %rdx, %r12
movq %rsi, %r15
movq %rdi, 0x18(%rsp)
movl 0x70(%rsp), %r13d
movl %r8d, %edx
xorl %ebx, %ebx
movq %rcx, %rdi
xorl %esi, %esi
movq %rdx, 0x30(%rsp)
callq 0x20e0
movq %rbx, (%r12)
movq %rbx, (%r15)
movl %r13d, %eax
xorl %ebp, %eax
cmpl $0x1, %eax
sete %al
movl 0x78(%rsp), %ecx
xorl %ebp, %ecx
cmpl $0x1, %ecx
sete %cl
orb %al, %cl
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
movq %r12, 0x20(%rsp)
movq %r14, 0x28(%rsp)
movl %ebp, 0x10(%rsp)
je 0x13dff5
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
jmp 0x13e1db
cmpq $0x0, 0x8(%r15)
je 0x13e009
movq 0x10(%r15), %rax
movl %ebp, (%rax)
movl $0x1, %ecx
jmp 0x13e03d
movq $0x2, 0x8(%r15)
movq 0x10(%r15), %rdi
movl $0x8, %esi
callq 0x2370
movq %rax, 0x10(%r15)
movq (%r15), %rdx
movq %rdx, %rcx
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
incq %rcx
movq %rcx, (%r15)
movl %ebp, (%rax,%rdx,4)
je 0x13e1db
movl 0x10(%rsp), %eax
shrl %eax
movl %eax, 0x14(%rsp)
movl 0x70(%rsp), %r8d
shrl %r8d
movl 0x78(%rsp), %r9d
shrl %r9d
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
movl %r8d, 0xc(%rsp)
movl %r9d, 0x8(%rsp)
leaq -0x1(%rcx), %rax
movq %rax, (%r15)
movq 0x10(%r15), %rax
movl -0x4(%rax,%rcx,4), %ebx
movb $0x1, (%r14,%rbx)
movl %ebx, %ebp
shrl %ebp
cmpl %ebp, 0x14(%rsp)
je 0x13e0e1
movq (%r12), %rcx
movq 0x10(%r12), %rax
cmpq 0x8(%r12), %rcx
jne 0x13e0d6
leaq (%rcx,%rcx), %rsi
testq %rcx, %rcx
movl $0x2, %ecx
cmoveq %rcx, %rsi
movq %rsi, 0x8(%r12)
shlq $0x2, %rsi
movl %edi, 0x4(%rsp)
movq %rax, %rdi
callq 0x2370
movl 0x8(%rsp), %r9d
movl 0xc(%rsp), %r8d
movl 0x4(%rsp), %edi
movq %rax, 0x10(%r12)
movq (%r12), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, (%r12)
movl %ebp, (%rax,%rcx,4)
movq 0x18(%rsp), %rcx
movq 0x28(%rcx), %rax
movq (%rax,%rbx,8), %rax
testl %eax, %eax
je 0x13e1ca
movq 0x8(%rcx), %rcx
movq %rax, %rdx
shrq $0x20, %rdx
movl %eax, %eax
leaq (%rdx,%rdx,2), %rdx
leaq (%rcx,%rdx,8), %rbx
addq $0x8, %rbx
shlq $0x3, %rax
leaq (%rax,%rax,2), %rbp
xorl %r12d, %r12d
cmpl $0x0, 0x4(%rbx,%r12)
js 0x13e1bd
movl (%rbx,%r12), %ecx
cmpb $0x0, (%r14,%rcx)
jne 0x13e1bd
movl %ecx, %eax
shrl %eax
cmpl %r8d, %eax
setne %dl
cmpl %r9d, %eax
setne %sil
testb %sil, %dl
jne 0x13e160
cmpl %r8d, %eax
cmovel %ecx, %r13d
movl %ecx, %eax
xorl 0x78(%rsp), %eax
cmpl $0x2, %eax
cmovbl %ecx, %edi
jmp 0x13e1bd
movq (%r15), %rdx
movq 0x10(%r15), %rax
cmpq 0x8(%r15), %rdx
jne 0x13e1b3
leaq (%rdx,%rdx), %rsi
testq %rdx, %rdx
movl $0x2, %ecx
cmoveq %rcx, %rsi
movq %rsi, 0x8(%r15)
shlq $0x2, %rsi
movl %r13d, %r14d
movl %edi, %r13d
movq %rax, %rdi
callq 0x2370
movl 0x8(%rsp), %r9d
movl 0xc(%rsp), %r8d
movl %r13d, %edi
movl %r14d, %r13d
movq 0x28(%rsp), %r14
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
cmpq %r12, %rbp
jne 0x13e11a
movq (%r15), %rcx
testq %rcx, %rcx
movq 0x20(%rsp), %r12
jne 0x13e06c
movl %r13d, 0x4(%rsp)
movl %edi, %r13d
movq %r14, %rdi
xorl %esi, %esi
movq 0x30(%rsp), %rdx
callq 0x20e0
movl 0x10(%rsp), %ebp
cmpl 0x70(%rsp), %ebp
sete %al
cmpl 0x78(%rsp), %ebp
sete %cl
orb %al, %cl
movq (%r15), %rcx
je 0x13e210
movl %r13d, %edi
jmp 0x13e259
movl %ebp, %ebx
xorl $0x1, %ebx
cmpq 0x8(%r15), %rcx
jne 0x13e245
leaq (%rcx,%rcx), %rax
testq %rcx, %rcx
movl $0x2, %esi
cmovneq %rax, %rsi
movq %rsi, 0x8(%r15)
movq 0x10(%r15), %rdi
shlq $0x2, %rsi
callq 0x2370
movq %rax, 0x10(%r15)
movq (%r15), %rcx
jmp 0x13e249
movq 0x10(%r15), %rax
movl %r13d, %edi
leaq 0x1(%rcx), %rdx
movq %rdx, (%r15)
movl %ebx, (%rax,%rcx,4)
movq %rdx, %rcx
testq %rcx, %rcx
je 0x13e3f6
shrl %ebp
movl %ebp, 0x10(%rsp)
movl 0x70(%rsp), %r8d
shrl %r8d
movl 0x78(%rsp), %r9d
shrl %r9d
movl 0x4(%rsp), %r13d
movl %r8d, 0xc(%rsp)
movl %r9d, 0x8(%rsp)
leaq -0x1(%rcx), %rax
movq %rax, (%r15)
movq 0x10(%r15), %rax
movl -0x4(%rax,%rcx,4), %ebx
movb $0x1, (%r14,%rbx)
movl %ebx, %ebp
shrl %ebp
cmpl %ebp, 0x10(%rsp)
je 0x13e2fc
movq (%r12), %rcx
movq 0x10(%r12), %rax
cmpq 0x8(%r12), %rcx
jne 0x13e2f1
leaq (%rcx,%rcx), %rsi
testq %rcx, %rcx
movl $0x2, %ecx
cmoveq %rcx, %rsi
movq %rsi, 0x8(%r12)
shlq $0x2, %rsi
movl %edi, 0x4(%rsp)
movq %rax, %rdi
callq 0x2370
movl 0x8(%rsp), %r9d
movl 0xc(%rsp), %r8d
movl 0x4(%rsp), %edi
movq %rax, 0x10(%r12)
movq (%r12), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, (%r12)
movl %ebp, (%rax,%rcx,4)
movq 0x18(%rsp), %rcx
movq 0x28(%rcx), %rax
movq (%rax,%rbx,8), %rax
testl %eax, %eax
je 0x13e3e3
movq 0x8(%rcx), %rcx
movq %rax, %rdx
shrq $0x20, %rdx
movl %eax, %eax
leaq (%rdx,%rdx,2), %rdx
leaq (%rcx,%rdx,8), %rbp
addq $0x8, %rbp
shlq $0x3, %rax
leaq (%rax,%rax,2), %r12
xorl %ebx, %ebx
cmpl $0x0, 0x4(%rbp,%rbx)
js 0x13e3d6
movl (%rbp,%rbx), %ecx
cmpb $0x0, (%r14,%rcx)
jne 0x13e3d6
movl %ecx, %eax
shrl %eax
cmpl %r8d, %eax
setne %dl
cmpl %r9d, %eax
setne %sil
testb %sil, %dl
jne 0x13e379
cmpl %r8d, %eax
cmovel %ecx, %r13d
movl %ecx, %eax
xorl 0x78(%rsp), %eax
cmpl $0x2, %eax
cmovbl %ecx, %edi
jmp 0x13e3d6
movq (%r15), %rdx
movq 0x10(%r15), %rax
cmpq 0x8(%r15), %rdx
jne 0x13e3cc
leaq (%rdx,%rdx), %rsi
testq %rdx, %rdx
movl $0x2, %ecx
cmoveq %rcx, %rsi
movq %rsi, 0x8(%r15)
shlq $0x2, %rsi
movl %r13d, %r14d
movl %edi, %r13d
movq %rax, %rdi
callq 0x2370
movl 0x8(%rsp), %r9d
movl 0xc(%rsp), %r8d
movl %r13d, %edi
movl %r14d, %r13d
movq 0x28(%rsp), %r14
movq %rax, 0x10(%r15)
movl (%rbp,%rbx), %ecx
movq (%r15), %rdx
leaq 0x1(%rdx), %rsi
movq %rsi, (%r15)
movl %ecx, (%rax,%rdx,4)
addq $0x18, %rbx
cmpq %rbx, %r12
jne 0x13e334
movq (%r15), %rcx
testq %rcx, %rcx
movq 0x20(%rsp), %r12
jne 0x13e287
jmp 0x13e3fb
movl 0x4(%rsp), %r13d
cmpl $-0x1, %r13d
je 0x13e454
movq (%r12), %rcx
cmpq 0x8(%r12), %rcx
jne 0x13e43e
leaq (%rcx,%rcx), %rax
testq %rcx, %rcx
movl $0x2, %esi
cmovneq %rax, %rsi
movq %rsi, 0x8(%r12)
movl %edi, %ebx
movq 0x10(%r12), %rdi
shlq $0x2, %rsi
callq 0x2370
movl %ebx, %edi
movq %rax, 0x10(%r12)
movq (%r12), %rcx
jmp 0x13e443
movq 0x10(%r12), %rax
movl 0x70(%rsp), %esi
shrl %esi
leaq 0x1(%rcx), %rdx
movq %rdx, (%r12)
movl %esi, (%rax,%rcx,4)
cmpl $-0x1, %edi
je 0x13e4a8
movq (%r12), %rcx
cmpq 0x8(%r12), %rcx
jne 0x13e492
leaq (%rcx,%rcx), %rax
testq %rcx, %rcx
movl $0x2, %esi
cmovneq %rax, %rsi
movq %rsi, 0x8(%r12)
movq 0x10(%r12), %rdi
shlq $0x2, %rsi
callq 0x2370
movq %rax, 0x10(%r12)
movq (%r12), %rcx
jmp 0x13e497
movq 0x10(%r12), %rax
movl 0x78(%rsp), %esi
shrl %esi
leaq 0x1(%rcx), %rdx
movq %rdx, (%r12)
movl %esi, (%rax,%rcx,4)
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq