// File: /workspace/github_cpp_makefile_star2_O1/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, %r13d
movq %rcx, %r14
movq %rdx, %r12
movq %rsi, %r15
movq %rdi, 0x18(%rsp)
movl 0x78(%rsp), %ebp
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 0x70(%rsp), %ebx
movl %ebx, %eax
xorl %r13d, %eax
cmpl $0x1, %eax
sete %al
movl %ebp, %ecx
movl %r13d, 0x4(%rsp)
xorl %r13d, %ecx
cmpl $0x1, %ecx
sete %cl
orb %al, %cl
jne 0x138241
cmpq $0x0, 0x8(%r15)
jne 0x13822c
movq $0x2, 0x8(%r15)
movq 0x10(%r15), %rdi
movl $0x8, %esi
callq 0x2370
movq %rax, 0x10(%r15)
movq (%r15), %rax
movq 0x10(%r15), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, (%r15)
movl 0x4(%rsp), %edx
movl %edx, (%rcx,%rax,4)
movq (%r15), %rax
testq %rax, %rax
movq %r12, 0x20(%rsp)
movq %r14, 0x28(%rsp)
je 0x1383f6
movl 0x4(%rsp), %ecx
shrl %ecx
movl %ecx, 0x10(%rsp)
movl %ebx, %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(%rax), %rcx
movq %rcx, (%r15)
movq 0x10(%r15), %rcx
movl -0x4(%rcx,%rax,4), %ebx
movb $0x1, (%r14,%rbx)
movl %ebx, %ebp
shrl %ebp
cmpl %ebp, 0x10(%rsp)
je 0x1382fb
movq 0x8(%r12), %rax
cmpq %rax, (%r12)
jne 0x1382e7
leaq (%rax,%rax), %rsi
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %rsi
movq %rsi, 0x8(%r12)
movl %edi, 0x14(%rsp)
movq 0x10(%r12), %rdi
shlq $0x2, %rsi
callq 0x2370
movl 0x8(%rsp), %r9d
movl 0xc(%rsp), %r8d
movl 0x14(%rsp), %edi
movq %rax, 0x10(%r12)
movq (%r12), %rax
movq 0x10(%r12), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, (%r12)
movl %ebp, (%rcx,%rax,4)
movq 0x18(%rsp), %rcx
movq 0x28(%rcx), %rax
movq (%rax,%rbx,8), %rax
testl %eax, %eax
je 0x1383e3
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 0x1383d6
movl (%rbp,%rbx), %eax
cmpb $0x0, (%r14,%rax)
jne 0x1383d6
movl %eax, %ecx
shrl %ecx
cmpl %r8d, %ecx
setne %dl
cmpl %r9d, %ecx
setne %sil
testb %sil, %dl
jne 0x138378
cmpl %r8d, %ecx
cmovel %eax, %r13d
movl %eax, %ecx
xorl 0x78(%rsp), %ecx
cmpl $0x2, %ecx
cmovbl %eax, %edi
jmp 0x1383d6
movq 0x8(%r15), %rax
cmpq %rax, (%r15)
jne 0x1383c1
leaq (%rax,%rax), %rsi
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %rsi
movq %rsi, 0x8(%r15)
movl %r13d, %r14d
movl %edi, %r13d
movq 0x10(%r15), %rdi
shlq $0x2, %rsi
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), %eax
movq (%r15), %rcx
movq 0x10(%r15), %rdx
leaq 0x1(%rcx), %rsi
movq %rsi, (%r15)
movl %eax, (%rdx,%rcx,4)
addq $0x18, %rbx
cmpq %rbx, %r12
jne 0x138333
movq (%r15), %rax
testq %rax, %rax
movq 0x20(%rsp), %r12
jne 0x138284
jmp 0x138401
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
movl %r13d, 0x10(%rsp)
movl %edi, %ebp
movq %r14, %rdi
xorl %esi, %esi
movq 0x30(%rsp), %rdx
callq 0x20e0
movl 0x70(%rsp), %r13d
movl 0x4(%rsp), %ecx
cmpl %r13d, %ecx
sete %al
cmpl 0x78(%rsp), %ecx
sete %cl
orb %al, %cl
jne 0x138477
movl 0x4(%rsp), %ebx
xorl $0x1, %ebx
movq 0x8(%r15), %rax
cmpq %rax, (%r15)
jne 0x138466
leaq (%rax,%rax), %rcx
testq %rax, %rax
movl $0x2, %esi
cmovneq %rcx, %rsi
movq %rsi, 0x8(%r15)
movq 0x10(%r15), %rdi
shlq $0x2, %rsi
callq 0x2370
movq %rax, 0x10(%r15)
movq (%r15), %rax
movq 0x10(%r15), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, (%r15)
movl %ebx, (%rcx,%rax,4)
movq (%r15), %rax
testq %rax, %rax
je 0x138618
shrl 0x4(%rsp)
movl %r13d, %r8d
shrl %r8d
movl 0x78(%rsp), %r9d
shrl %r9d
movl %ebp, %edi
movl 0x10(%rsp), %r13d
movl %r8d, 0xc(%rsp)
movl %r9d, 0x8(%rsp)
leaq -0x1(%rax), %rcx
movq %rcx, (%r15)
movq 0x10(%r15), %rcx
movl -0x4(%rcx,%rax,4), %ebx
movb $0x1, (%r14,%rbx)
movl %ebx, %ebp
shrl %ebp
cmpl %ebp, 0x4(%rsp)
je 0x13851d
movq 0x8(%r12), %rax
cmpq %rax, (%r12)
jne 0x138509
leaq (%rax,%rax), %rsi
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %rsi
movq %rsi, 0x8(%r12)
movl %edi, 0x14(%rsp)
movq 0x10(%r12), %rdi
shlq $0x2, %rsi
callq 0x2370
movl 0x8(%rsp), %r9d
movl 0xc(%rsp), %r8d
movl 0x14(%rsp), %edi
movq %rax, 0x10(%r12)
movq (%r12), %rax
movq 0x10(%r12), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, (%r12)
movl %ebp, (%rcx,%rax,4)
movq 0x18(%rsp), %rcx
movq 0x28(%rcx), %rax
movq (%rax,%rbx,8), %rax
testl %eax, %eax
je 0x138605
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 0x1385f8
movl (%rbp,%rbx), %eax
cmpb $0x0, (%r14,%rax)
jne 0x1385f8
movl %eax, %ecx
shrl %ecx
cmpl %r8d, %ecx
setne %dl
cmpl %r9d, %ecx
setne %sil
testb %sil, %dl
jne 0x13859a
cmpl %r8d, %ecx
cmovel %eax, %r13d
movl %eax, %ecx
xorl 0x78(%rsp), %ecx
cmpl $0x2, %ecx
cmovbl %eax, %edi
jmp 0x1385f8
movq 0x8(%r15), %rax
cmpq %rax, (%r15)
jne 0x1385e3
leaq (%rax,%rax), %rsi
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %rsi
movq %rsi, 0x8(%r15)
movl %r13d, %r14d
movl %edi, %r13d
movq 0x10(%r15), %rdi
shlq $0x2, %rsi
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), %eax
movq (%r15), %rcx
movq 0x10(%r15), %rdx
leaq 0x1(%rcx), %rsi
movq %rsi, (%r15)
movl %eax, (%rdx,%rcx,4)
addq $0x18, %rbx
cmpq %rbx, %r12
jne 0x138555
movq (%r15), %rax
testq %rax, %rax
movq 0x20(%rsp), %r12
jne 0x1384a6
jmp 0x13861f
movl %ebp, %edi
movl 0x10(%rsp), %r13d
cmpl $-0x1, %r13d
je 0x138676
movq 0x8(%r12), %rax
cmpq %rax, (%r12)
jne 0x13865c
leaq (%rax,%rax), %rcx
testq %rax, %rax
movl $0x2, %esi
cmovneq %rcx, %rsi
movq %rsi, 0x8(%r12)
movl %edi, %ebx
movq 0x10(%r12), %rdi
shlq $0x2, %rsi
callq 0x2370
movl %ebx, %edi
movq %rax, 0x10(%r12)
movl 0x70(%rsp), %esi
shrl %esi
movq (%r12), %rax
movq 0x10(%r12), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, (%r12)
movl %esi, (%rcx,%rax,4)
cmpl $-0x1, %edi
je 0x1386c8
movq 0x8(%r12), %rax
cmpq %rax, (%r12)
jne 0x1386ae
leaq (%rax,%rax), %rcx
testq %rax, %rax
movl $0x2, %esi
cmovneq %rcx, %rsi
movq %rsi, 0x8(%r12)
movq 0x10(%r12), %rdi
shlq $0x2, %rsi
callq 0x2370
movq %rax, 0x10(%r12)
movl 0x78(%rsp), %esi
shrl %esi
movq (%r12), %rax
movq 0x10(%r12), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, (%r12)
movl %esi, (%rcx,%rax,4)
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq