// File: /workspace/github_cpp_makefile_star2_O3/chhylp123[P]hifiasm/tovlp.cpp
// Function: is_pop_unitig(unsigned int, asg_t*, ma_ug_t*, kvec_t_u32_warp*, kvec_t_u32_warp*, unsigned char*, pdq*, pdq*, unsigned char, unsigned char, long long*)
int is_pop_unitig(uint32_t v, asg_t *g, ma_ug_t *ug, kvec_t_u32_warp *tt, kvec_t_u32_warp *stack, uint8_t *vis,
pdq *pq_p, pdq *pq_a, uint8_t fp, uint8_t fa, long long *d)
{
    asg_arc_t *as = NULL;
    uint32_t s, sv, return_flag, convex, ns, i, k, nc, p_n, found, *a_a = NULL, a_n;
    long long ll, tmp, max_stop_nodeLen, max_stop_baseLen;
    if(g->seq[v>>1].del || g->seq[v>>1].c == ALTER_LABLE) return 0;
    if(asg_arc_n(g, v) == 0 || get_real_length(g, v, NULL) != 1) return 0;
    get_real_length(g, v, &s);
    if(get_real_length(g, s^1, NULL) < 2) return 0;
    return_flag = get_unitig(g, ug, v^1, &convex, &ll, &tmp, &max_stop_nodeLen,&max_stop_baseLen, 1, NULL);
    if(return_flag == LOOP) return 0;

    as = asg_arc_a(g, convex); ns = asg_arc_n(g, convex);
    for (i = nc = 0; i < ns; i++)
    {
        if(as[i].del) continue;
        if(get_real_length(g, as[i].v^1, NULL) < 2) break;
        nc++;
    }
    if(nc == 0 || i < ns) return 0;

    tt->a.n = 0; s^=1; sv = v^1;
    dfs_set(g, sv, s>>1, stack, tt, vis, fp);
    p_n = tt->a.n;
    as = asg_arc_a(g, s); ns = asg_arc_n(g, s); found = 0;
    for (i = 0; i < ns; i++)
    {
        if(as[i].del || as[i].v == sv) continue;
        nc = dfs_set(g, as[i].v, s>>1, stack, tt, vis, fa);///nc > 0 means as[i].v and sv have common suffix
        if(nc && check_trans_relation_by_path(sv, as[i].v, pq_p, NULL, NULL, pq_a, NULL, NULL, g, 
        vis, fp+fa, nc, 0.45, d))
        {
            found = 1;
        }
        a_a = tt->a.a + p_n; a_n = tt->a.n - p_n;
        for (k = 0; k < a_n; k++)
        {
            if(vis[a_a[k]]&fa) vis[a_a[k]] -= fa;
        }
        tt->a.n = p_n;
        if(found) break;
    }
    a_a = tt->a.a; a_n = p_n;
    for (k = 0; k < a_n; k++) vis[a_a[k]] = 0;
    return found;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %rcx, %r14
movq 0x20(%rsi), %rax
movl %edi, %ecx
shrl %ecx
xorl %r15d, %r15d
cmpl $0x0, (%rax,%rcx,8)
js 0x199ae3
cmpb $0x1, 0x4(%rax,%rcx,8)
je 0x199ae3
movq %rsi, %r12
movl %edi, %ebp
movq 0x28(%rsi), %rax
movl %edi, %ecx
movq (%rax,%rcx,8), %rsi
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
andq %rsi, %rdi
je 0x199ae3
movq %r9, %rbx
movq 0x8(%r12), %rcx
shrq $0x20, %rsi
leaq (%rsi,%rsi,2), %rsi
leaq (%rcx,%rsi,8), %rsi
addq $0xc, %rsi
shlq $0x3, %rdi
leaq (%rdi,%rdi,2), %rdi
xorl %r11d, %r11d
xorl %r9d, %r9d
movl (%rsi,%r11), %r10d
notl %r10d
shrl $0x1f, %r10d
addl %r10d, %r9d
addq $0x18, %r11
cmpq %r11, %rdi
jne 0x19991e
cmpl $0x1, %r9d
jne 0x199ae0
xorl %r9d, %r9d
cmpl $0x0, (%rsi,%r9)
js 0x19994e
movl -0x4(%rsi,%r9), %r13d
addq $0x18, %r9
cmpq %r9, %rdi
jne 0x199942
movl %r13d, %r10d
xorl $0x1, %r10d
movq (%rax,%r10,8), %rax
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
andq %rax, %rsi
je 0x199ae0
shrq $0x20, %rax
leaq (%rax,%rax,2), %rax
leaq (%rcx,%rax,8), %rax
addq $0xc, %rax
shlq $0x3, %rsi
leaq (%rsi,%rsi,2), %rcx
xorl %esi, %esi
xorl %edi, %edi
movl (%rax,%rsi), %r9d
notl %r9d
shrl $0x1f, %r9d
addl %r9d, %edi
addq $0x18, %rsi
cmpq %rsi, %rcx
jne 0x19998c
xorl %r15d, %r15d
cmpl $0x2, %edi
jl 0x199ae3
movq %r10, 0x50(%rsp)
movq %r8, 0x48(%rsp)
xorl $0x1, %ebp
leaq 0x88(%rsp), %rax
movq %rax, 0x8(%rsp)
leaq 0x90(%rsp), %rax
movq %rax, (%rsp)
movq $0x0, 0x18(%rsp)
movl $0x1, 0x10(%rsp)
leaq 0x6c(%rsp), %rcx
leaq 0xa0(%rsp), %r8
leaq 0x98(%rsp), %r9
movq %r12, %rdi
movq %rdx, %rsi
movl %ebp, %edx
callq 0x1053a7
cmpl $0x7, %eax
je 0x199ae3
movq 0x28(%r12), %rcx
movl 0x6c(%rsp), %eax
movq %rcx, 0x60(%rsp)
movq (%rcx,%rax,8), %rax
testl %eax, %eax
movq 0x48(%rsp), %rcx
je 0x199ae3
movq 0x8(%r12), %rdi
movq %rax, %rdx
shrq $0x20, %rdx
leaq (%rdx,%rdx,2), %rdx
leaq (%rdi,%rdx,8), %rdx
movl %eax, %esi
addq $0xc, %rdi
movq %rdi, 0x58(%rsp)
xorl %r8d, %r8d
movb $0x1, %r9b
xorl %edi, %edi
leaq (%r8,%r8,2), %rax
cmpl $0x0, 0xc(%rdx,%rax,8)
js 0x199ac1
leaq (%rdx,%rax,8), %rax
movl 0x8(%rax), %eax
xorq $0x1, %rax
movq 0x60(%rsp), %rcx
movq (%rcx,%rax,8), %r10
movq %r10, %rax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
andq %rcx, %rax
je 0x199ae0
shrq $0x20, %r10
leaq (%r10,%r10,2), %r10
movq 0x58(%rsp), %rcx
leaq (%rcx,%r10,8), %r11
shlq $0x3, %rax
leaq (%rax,%rax,2), %r15
xorl %r10d, %r10d
xorl %eax, %eax
movl (%r11,%r10), %ecx
notl %ecx
shrl $0x1f, %ecx
addl %ecx, %eax
addq $0x18, %r10
cmpq %r10, %r15
jne 0x199aa1
cmpl $0x2, %eax
jl 0x199acf
incl %edi
movq 0x48(%rsp), %rcx
incq %r8
cmpq %rsi, %r8
setb %r9b
jne 0x199a57
jmp 0x199ad4
movq 0x48(%rsp), %rcx
testl %edi, %edi
sete %al
orb %r9b, %al
testb $0x1, %al
je 0x199af8
xorl %r15d, %r15d
movl %r15d, %eax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq $0x0, (%r14)
shrl %r13d
movb 0xf0(%rsp), %r15b
movzbl %r15b, %eax
movl %eax, (%rsp)
movq %r12, %rdi
movl %ebp, %esi
movl %r13d, %edx
movq %r14, %r8
movq %rbx, %r9
callq 0x1991bb
movq (%r14), %r11
movq 0x28(%r12), %rax
movq 0x50(%rsp), %rcx
movq (%rax,%rcx,8), %rax
testl %eax, %eax
je 0x199ca1
movq %rax, %rcx
shrq $0x20, %rcx
leaq (%rcx,%rcx,2), %rdx
shlq $0x3, %rdx
addq 0x8(%r12), %rdx
movb 0xf8(%rsp), %cl
addb %cl, %r15b
movb %r15b, 0x47(%rsp)
movl %r11d, %esi
movl %eax, %edi
xorl %r15d, %r15d
movzbl %cl, %eax
movl %eax, 0x68(%rsp)
movq %rsi, 0x80(%rsp)
leaq (,%rsi,4), %rax
movq %rax, 0x70(%rsp)
movq 0x48(%rsp), %rcx
movq %r11, 0x58(%rsp)
movq %rdx, 0x50(%rsp)
movq %rdi, 0x78(%rsp)
leaq (%r15,%r15,2), %rax
cmpl $0x0, 0xc(%rdx,%rax,8)
js 0x199c95
leaq (%rdx,%rax,8), %rax
movl 0x8(%rax), %esi
cmpl %ebp, %esi
je 0x199c95
movq %rax, 0x60(%rsp)
movl 0x68(%rsp), %eax
movl %eax, (%rsp)
movq %r12, %rdi
movl %r13d, %edx
movq %r14, %r8
movq %rbx, %r9
callq 0x1991bb
testl %eax, %eax
je 0x199c35
movq 0x60(%rsp), %rcx
movl 0x8(%rcx), %esi
movq 0x100(%rsp), %rcx
movq %rcx, 0x30(%rsp)
movl %eax, 0x28(%rsp)
movzbl 0x47(%rsp), %eax
movl %eax, 0x20(%rsp)
movq %rbx, 0x18(%rsp)
movq %r12, 0x10(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, (%rsp)
movl %ebp, %edi
movq 0xe0(%rsp), %rdx
xorl %ecx, %ecx
xorl %r8d, %r8d
movq 0xe8(%rsp), %r9
movsd 0xa5d27(%rip), %xmm0    # 0x23f950
callq 0x1421f4
testl %eax, %eax
sete %al
jmp 0x199c37
movb $0x1, %al
movb 0xf8(%rsp), %r10b
movq (%r14), %rdx
movq 0x58(%rsp), %r11
subq %r11, %rdx
testl %edx, %edx
movq 0x48(%rsp), %rcx
je 0x199c7c
movq 0x10(%r14), %r9
addq 0x70(%rsp), %r9
movl %edx, %edx
xorl %esi, %esi
movl (%r9,%rsi,4), %edi
movb (%rbx,%rdi), %r8b
testb %r10b, %r8b
je 0x199c74
subb %r10b, %r8b
movb %r8b, (%rbx,%rdi)
incq %rsi
cmpq %rsi, %rdx
jne 0x199c60
movq 0x80(%rsp), %rdx
movq %rdx, (%r14)
testb %al, %al
movq 0x50(%rsp), %rdx
movq 0x78(%rsp), %rdi
je 0x199cca
incq %r15
cmpq %rdi, %r15
jne 0x199b98
xorl %r15d, %r15d
testl %r11d, %r11d
je 0x199ae3
movq 0x10(%r14), %rax
movl %r11d, %ecx
xorl %edx, %edx
movl (%rax,%rdx,4), %esi
movb $0x0, (%rbx,%rsi)
incq %rdx
cmpq %rdx, %rcx
jne 0x199cb6
jmp 0x199ae3
movl $0x1, %r15d
jmp 0x199ca4