// File: /workspace/github_cpp_makefile_star2_O2/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, 0x8(%rsp)
movq %rsi, (%rsp)
movl %edi, %ebp
movq 0x68(%rsp), %r12
movq %rcx, 0x10(%rsp)
movq 0x18(%rcx), %rax
movl 0x14(%rax), %edx
addl %edx, %edx
movq %r9, %rdi
xorl %esi, %esi
movq %rdx, 0x20(%rsp)
callq 0x20e0
andq $0x0, (%r12)
cmpq $0x0, 0x8(%r12)
je 0x1080e3
movq 0x10(%r12), %rax
xorl %edx, %edx
jmp 0x108102
movq $0x2, 0x8(%r12)
movq 0x10(%r12), %rdi
pushq $0x8
popq %rsi
callq 0x2370
movq %rax, 0x10(%r12)
movq (%r12), %rdx
movl 0x60(%rsp), %r9d
leaq 0x1(%rdx), %rcx
movq %rcx, (%r12)
movl %ebp, (%rax,%rdx,4)
movq 0x8(%rsp), %rdi
movq (%rsp), %r8
movq %rbx, 0x18(%rsp)
testq %rcx, %rcx
je 0x108241
leaq -0x1(%rcx), %rdx
movq %rdx, (%r12)
movq 0x10(%r12), %rax
movl -0x4(%rax,%rcx,4), %eax
cmpb $0x0, (%rbx,%rax)
movq %rdx, %rcx
jne 0x108120
movb $0x1, (%rbx,%rax)
movq 0x10(%rsp), %rcx
movq 0x18(%rcx), %rcx
movq 0x8(%rcx), %rdx
movq 0x28(%rcx), %rcx
movq (%rcx,%rax,8), %rax
movl %eax, %ecx
shrq $0x20, %rax
imulq $0x18, %rcx, %r15
imulq $0x18, %rax, %rax
leaq (%rdx,%rax), %r13
addq $0x8, %r13
xorl %ebp, %ebp
cmpq %rbp, %r15
je 0x108238
cmpl $0x0, 0x4(%r13,%rbp)
js 0x10822f
movl (%r13,%rbp), %ecx
cmpb $0x0, (%rbx,%rcx)
jne 0x10822f
movl %ecx, %eax
shrl %eax
movzbl (%r14,%rax), %edx
testl %edx, %edx
sete %sil
cmpl %r9d, %edx
sete %dl
orb %sil, %dl
je 0x10821c
movq (%r12), %rdx
movq 0x10(%r12), %rax
cmpq 0x8(%r12), %rdx
jne 0x10820f
leaq (%rdx,%rdx), %rsi
testq %rdx, %rdx
pushq $0x2
popq %rcx
cmoveq %rcx, %rsi
movq %rsi, 0x8(%r12)
shlq $0x2, %rsi
movq %rax, %rdi
movq %r12, %rbx
movq %r14, %r12
movl %r9d, %r14d
callq 0x2370
movl %r14d, %r9d
movq %r12, %r14
movq %rbx, %r12
movq 0x18(%rsp), %rbx
movq (%rsp), %r8
movq 0x8(%rsp), %rdi
movq %rax, 0x10(%r12)
movl (%r13,%rbp), %ecx
movq (%r12), %rdx
leaq 0x1(%rdx), %rsi
movq %rsi, (%r12)
movl %ecx, (%rax,%rdx,4)
jmp 0x10822f
testq %r8, %r8
je 0x108226
cmpl (%r8), %eax
je 0x10822f
testq %rdi, %rdi
je 0x108264
cmpl (%rdi), %eax
jne 0x108264
addq $0x18, %rbp
jmp 0x108174
movq (%r12), %rcx
jmp 0x108120
xorl %eax, %eax
cmpq %rax, 0x20(%rsp)
je 0x108264
cmpb $0x0, (%rbx,%rax)
je 0x10825f
movl %eax, %ecx
shrl %ecx
cmpb $0x0, (%r14,%rcx)
jne 0x10825f
movb %r9b, (%r14,%rcx)
incq %rax
jmp 0x108243
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq