// File: /workspace/github_cpp_makefile_star2_O2/chhylp123[P]hifiasm/hic.cpp
// Function: check_trans_relation_by_path(unsigned int, unsigned int, pdq*, unsigned int*, buf_t*, pdq*, unsigned int*, buf_t*, asg_t*, unsigned char*, unsigned char, unsigned int, double, long long*)
uint32_t check_trans_relation_by_path(uint32_t v, uint32_t w, pdq* pqv, uint32_t* path_v, buf_t *resv,
pdq* pqw, uint32_t* path_w, buf_t *resw, asg_t *sg, uint8_t *dest, uint8_t df, uint32_t df_occ, 
double rate, long long *dis)
{
    uint64_t r1, r2, d1, d2;
    pdq_spec p1, p2, *p = NULL;
    p1.v = (uint64_t)-1; p1.src = v; p1.pq = pqv; p1.sg = sg; p1.df_occ = df_occ;
    p1.occ = df_occ; p1.flag = df; p1.dest = dest; p1.pre = path_v; if(resv) resv->b.n = 0;
    reset_pdq(p1.pq);

    p2.v = (uint64_t)-1; p2.src = w; p2.pq = pqw; p2.sg = sg; p2.df_occ = df_occ;
    p2.occ = df_occ; p2.flag = df; p2.dest = dest; p2.pre = path_w; if(resw) resw->b.n = 0;
    reset_pdq(p2.pq);

    if(dis) (*dis) = 0;

    while (1)
    {
        p = &p1;
        r1 = get_specific_shortest_path(p);
        if(r1 && p1.pq->vis.a[p->v] && p2.pq->vis.a[p->v])
        {
            d1 = p1.pq->dis.a[p->v]; d2 = p2.pq->dis.a[p->v];
            if(d1 != (uint64_t)-1 && d2 != (uint64_t)-1)
            {
                if(d2 <= d1*(1+rate) && d2 >= d1*(1-rate))
                {
                    if(resv) get_utg_path(p1.src, p->v, p1.pre, resv);
                    if(resw) get_utg_path(p2.src, p->v, p2.pre, resw);
                    if(dis)
                    {
                        (*dis) = d1 + d2;
                        (*dis) -= (sg->seq[p1.src>>1].len + sg->seq[p2.src>>1].len);
                    }
                    
                    // fprintf(stderr, "p-utg%.6ul(d1-%lu), a-utg%.6ul(d2-%lu), conver-utg%.6lul\n", 
                    // (v>>1) + 1, d1, (w>>1) + 1, d2, (p->v>>1) + 1);


                    return 1;
                }
            }
        }
        p = &p2;
        r2 = get_specific_shortest_path(p);
        if(r2 && p1.pq->vis.a[p->v] && p2.pq->vis.a[p->v])
        {
            d1 = p1.pq->dis.a[p->v]; d2 = p2.pq->dis.a[p->v];
            if(d1 != (uint64_t)-1 && d2 != (uint64_t)-1)
            {
                if(d2 <= d1*(1+rate) && d2 >= d1*(1-rate))
                {
                    if(resv) get_utg_path(p1.src, p->v, p1.pre, resv);
                    if(resw) get_utg_path(p2.src, p->v, p2.pre, resw);
                    if(dis)
                    {
                        (*dis) = d1 + d2;
                        (*dis) -= (sg->seq[p1.src>>1].len + sg->seq[p2.src>>1].len);
                    }
                    // fprintf(stderr, "p-utg%.6ul(d1-%lu), a-utg%.6ul(d2-%lu), conver-utg%.6lul\n", 
                    // (v>>1) + 1, d1, (w>>1) + 1, d2, (p->v>>1) + 1);
                    return 1;
                }
            }
        }
        if(!r1 && !r2) return 0;
    }
    
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movsd %xmm0, (%rsp)
movq %r9, %rbx
movl %esi, %ebp
movl 0x108(%rsp), %r14d
movb 0x100(%rsp), %r12b
movq 0xf8(%rsp), %r15
movq 0xf0(%rsp), %rax
movq 0xe0(%rsp), %r13
orq $-0x1, 0x98(%rsp)
movl %edi, 0x68(%rsp)
movq %rdx, 0x60(%rsp)
movq %rax, 0x70(%rsp)
movq %r14, 0x90(%rsp)
movq %r14, 0x88(%rsp)
movb %r12b, 0x80(%rsp)
movq %r15, 0x78(%rsp)
movq %rcx, 0xa0(%rsp)
testq %r8, %r8
je 0xfad9a
andq $0x0, 0x38(%r8)
movq %r8, 0x8(%rsp)
movq %rdx, %rdi
callq 0xfa62b
orq $-0x1, 0x50(%rsp)
movl %ebp, 0x20(%rsp)
movq %rbx, 0x18(%rsp)
movq 0xf0(%rsp), %rax
movq %rax, 0x28(%rsp)
movq %r14, 0x48(%rsp)
movq %r14, 0x40(%rsp)
movb %r12b, 0x38(%rsp)
movq %r15, 0x30(%rsp)
movq %r13, 0x58(%rsp)
movq 0xe8(%rsp), %rax
testq %rax, %rax
je 0xfadee
andq $0x0, 0x38(%rax)
movq %rbx, %rdi
callq 0xfa62b
movq 0x110(%rsp), %rax
testq %rax, %rax
je 0xfae07
andq $0x0, (%rax)
movsd 0xe8491(%rip), %xmm0    # 0x1e32a0
movsd (%rsp), %xmm2
movapd %xmm2, %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, 0x10(%rsp)
subsd %xmm2, %xmm0
movsd %xmm0, (%rsp)
leaq 0x18(%rsp), %r12
pushq $0x1
popq %rbp
leaq 0x60(%rsp), %rdi
callq 0xfaa7d
movl %eax, %r13d
testl %eax, %eax
je 0xfaeef
movq 0x60(%rsp), %rax
movq 0x98(%rsp), %rbx
movq 0x10(%rax), %rcx
cmpb $0x0, (%rcx,%rbx)
je 0xfaeef
movq 0x18(%rsp), %rcx
movq 0x10(%rcx), %rdx
cmpb $0x0, (%rdx,%rbx)
je 0xfaeef
movq 0x40(%rax), %rax
movq (%rax,%rbx,8), %r15
cmpq $-0x1, %r15
je 0xfaeef
movq 0x40(%rcx), %rax
movq (%rax,%rbx,8), %r14
cmpq $-0x1, %r14
je 0xfaeef
movq %r14, %xmm1
movq 0xe83d5(%rip), %xmm3    # 0x1e3270
punpckldq %xmm3, %xmm1    # xmm1 = xmm1[0],xmm3[0],xmm1[1],xmm3[1]
movapd 0xe83d9(%rip), %xmm4    # 0x1e3280
subpd %xmm4, %xmm1
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
movq %r15, %xmm2
punpckldq %xmm3, %xmm2    # xmm2 = xmm2[0],xmm3[0],xmm2[1],xmm3[1]
subpd %xmm4, %xmm2
movapd %xmm2, %xmm1
unpckhpd %xmm2, %xmm1            # xmm1 = xmm1[1],xmm2[1]
addsd %xmm2, %xmm1
movsd 0x10(%rsp), %xmm2
mulsd %xmm1, %xmm2
ucomisd %xmm0, %xmm2
jb 0xfaeef
mulsd (%rsp), %xmm1
ucomisd %xmm1, %xmm0
jae 0xfafbe
movq %r12, %rdi
callq 0xfaa7d
testl %eax, %eax
je 0xfaf9f
movq 0x60(%rsp), %rcx
movq 0x10(%rcx), %rdx
movq 0x50(%rsp), %rbx
cmpb $0x0, (%rdx,%rbx)
je 0xfaf9f
movq 0x18(%rsp), %rdx
movq 0x10(%rdx), %rsi
cmpb $0x0, (%rsi,%rbx)
je 0xfaf9f
movq 0x40(%rcx), %rcx
movq (%rcx,%rbx,8), %r15
cmpq $-0x1, %r15
je 0xfaf9f
movq 0x40(%rdx), %rcx
movq (%rcx,%rbx,8), %r14
cmpq $-0x1, %r14
je 0xfaf9f
movq %r14, %xmm1
movq 0xe8321(%rip), %xmm3    # 0x1e3270
punpckldq %xmm3, %xmm1    # xmm1 = xmm1[0],xmm3[0],xmm1[1],xmm3[1]
movapd 0xe8325(%rip), %xmm4    # 0x1e3280
subpd %xmm4, %xmm1
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
movq %r15, %xmm2
punpckldq %xmm3, %xmm2    # xmm2 = xmm2[0],xmm3[0],xmm2[1],xmm3[1]
subpd %xmm4, %xmm2
movapd %xmm2, %xmm1
unpckhpd %xmm2, %xmm1            # xmm1 = xmm1[1],xmm2[1]
addsd %xmm2, %xmm1
movsd 0x10(%rsp), %xmm2
mulsd %xmm1, %xmm2
ucomisd %xmm0, %xmm2
jb 0xfaf9f
mulsd (%rsp), %xmm1
ucomisd %xmm1, %xmm0
jae 0xfafbe
orl %r13d, %eax
jne 0xfae33
xorl %ebp, %ebp
movl %ebp, %eax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x8(%rsp), %rcx
testq %rcx, %rcx
je 0xfafdc
movl 0x68(%rsp), %edi
movq 0xa0(%rsp), %rdx
movq %rbx, %rsi
callq 0xfac08
movq 0xe8(%rsp), %rcx
testq %rcx, %rcx
je 0xfaffa
movl 0x20(%rsp), %edi
movq 0x58(%rsp), %rdx
movq %rbx, %rsi
callq 0xfac08
movq 0x110(%rsp), %rdi
testq %rdi, %rdi
je 0xfafaa
addq %r15, %r14
movq %r14, (%rdi)
movq 0xf0(%rsp), %rax
movq 0x20(%rax), %rax
movl 0x68(%rsp), %ecx
shrl %ecx
movl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
movl (%rax,%rcx,8), %ecx
andl %edx, %ecx
movl 0x20(%rsp), %esi
shrl %esi
andl (%rax,%rsi,8), %edx
addl %ecx, %edx
subq %rdx, %r14
movq %r14, (%rdi)
jmp 0xfafaa