// File: /workspace/github_cpp_makefile_star2_O3/chhylp123[P]hifiasm/hic.cpp
// Function: if_conflict_utg(unsigned int, unsigned int*, unsigned int*, ma_ug_t*, unsigned char*, unsigned char*, unsigned int, kvec_t_u32_warp*)
void if_conflict_utg(uint32_t root, uint32_t* aim_0, uint32_t* aim_1, ma_ug_t* ug, uint8_t* vis_flag,
uint8_t* is_vis_2, uint32_t ava_flag, kvec_t_u32_warp* stack)
{
    uint32_t n_vx = ug->g->n_seq<<1, k, cur, ncur;
    asg_arc_t *acur = NULL;
    memset(is_vis_2, 0, n_vx);

    stack->a.n = 0;
    kv_push(uint32_t, stack->a, root);
    while (stack->a.n > 0)
    {
        stack->a.n--;
        cur = stack->a.a[stack->a.n];
        if(is_vis_2[cur]) continue;
        is_vis_2[cur] = 1;
       
        ncur = asg_arc_n(ug->g, cur);
        acur = asg_arc_a(ug->g, cur);
        for (k = 0; k < ncur; k++)
        {
            if(acur[k].del) continue;
            if(is_vis_2[acur[k].v]) continue;
            if(vis_flag[acur[k].v>>1] != 0 && vis_flag[acur[k].v>>1] != ava_flag)
            {
                if(aim_0 && (acur[k].v>>1) == (*aim_0)) continue;
                if(aim_1 && (acur[k].v>>1) == (*aim_1)) continue;
                break;
            }
            kv_push(uint32_t, stack->a, acur[k].v);
        }

        if(k < ncur) return;
    }

    for (k = 0; k < n_vx; k++)
    {
        if(is_vis_2[k] && vis_flag[k>>1] == 0)
        {
            ///fprintf(stderr, "******************k=utg%.6ul, vis_flag: %u\n", (k>>1)+1, vis_flag[k>>1]);
            vis_flag[k>>1] = ava_flag;
        } 
        
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %r9, %rbx
movq %r8, %r14
movq %rdx, 0x10(%rsp)
movq %rsi, 0x8(%rsp)
movl %edi, %ebp
movq 0x68(%rsp), %r12
movq %rcx, 0x20(%rsp)
movq 0x18(%rcx), %rax
movl 0x14(%rax), %edx
addl %edx, %edx
movq %r9, %rdi
xorl %esi, %esi
movq %rdx, 0x18(%rsp)
callq 0x20e0
movq $0x0, (%r12)
cmpq $0x0, 0x8(%r12)
je 0x15046a
movq 0x10(%r12), %rax
movl %ebp, (%rax)
movl $0x1, %ecx
movl 0x60(%rsp), %edi
movq 0x18(%rsp), %r8
movq 0x10(%rsp), %r9
movq 0x8(%rsp), %r10
jmp 0x1504b1
movq $0x2, 0x8(%r12)
movq 0x10(%r12), %rdi
movl $0x8, %esi
callq 0x2370
movq %rax, 0x10(%r12)
movq (%r12), %rdx
movq %rdx, %rcx
incq %rcx
movq %rcx, (%r12)
movl %ebp, (%rax,%rdx,4)
movl 0x60(%rsp), %edi
movq 0x18(%rsp), %r8
movq 0x10(%rsp), %r9
movq 0x8(%rsp), %r10
je 0x1505cb
leaq -0x1(%rcx), %rax
movq %rax, (%r12)
movq 0x10(%r12), %rax
movl -0x4(%rax,%rcx,4), %eax
cmpb $0x0, (%rbx,%rax)
jne 0x1505be
movb $0x1, (%rbx,%rax)
movq 0x20(%rsp), %rcx
movq 0x18(%rcx), %rcx
movq 0x28(%rcx), %rdx
movq (%rdx,%rax,8), %rax
testl %eax, %eax
je 0x1505be
movq 0x8(%rcx), %rcx
movq %rax, %rdx
shrq $0x20, %rdx
movl %eax, %eax
leaq (%rdx,%rdx,2), %rdx
leaq (%rcx,%rdx,8), %r15
addq $0x8, %r15
shlq $0x3, %rax
leaq (%rax,%rax,2), %r13
xorl %ebp, %ebp
cmpl $0x0, 0x4(%r15,%rbp)
js 0x1505b1
movl (%r15,%rbp), %ecx
cmpb $0x0, (%rbx,%rcx)
jne 0x1505b1
movl %ecx, %eax
shrl %eax
movzbl (%r14,%rax), %edx
testl %edx, %edx
sete %sil
cmpl %edi, %edx
sete %dl
orb %sil, %dl
je 0x15059d
movq (%r12), %rdx
movq 0x10(%r12), %rax
cmpq 0x8(%r12), %rdx
jne 0x150590
leaq (%rdx,%rdx), %rsi
testq %rdx, %rdx
movl $0x2, %ecx
cmoveq %rcx, %rsi
movq %rsi, 0x8(%r12)
shlq $0x2, %rsi
movq %rax, %rdi
callq 0x2370
movq 0x8(%rsp), %r10
movq 0x10(%rsp), %r9
movq 0x18(%rsp), %r8
movl 0x60(%rsp), %edi
movq %rax, 0x10(%r12)
movl (%r15,%rbp), %ecx
movq (%r12), %rdx
leaq 0x1(%rdx), %rsi
movq %rsi, (%r12)
movl %ecx, (%rax,%rdx,4)
jmp 0x1505b1
testq %r10, %r10
je 0x1505a7
cmpl (%r10), %eax
je 0x1505b1
testq %r9, %r9
je 0x1505ef
cmpl (%r9), %eax
jne 0x1505ef
addq $0x18, %rbp
cmpq %rbp, %r13
jne 0x15050c
movq (%r12), %rcx
testq %rcx, %rcx
jne 0x1504b1
testq %r8, %r8
je 0x1505ef
xorl %eax, %eax
cmpb $0x0, (%rbx,%rax)
je 0x1505e7
movl %eax, %ecx
shrl %ecx
cmpb $0x0, (%r14,%rcx)
jne 0x1505e7
movb %dil, (%r14,%rcx)
incq %rax
cmpq %rax, %r8
jne 0x1505d2
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq