// File: /workspace/github_cpp_makefile_star2_O3/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, %r15
movq %rdx, %r12
movl %esi, %ebp
movl 0x108(%rsp), %ebx
movb 0x100(%rsp), %r13b
movq 0xf8(%rsp), %r14
movq 0xf0(%rsp), %rax
movq $-0x1, 0x98(%rsp)
movl %edi, 0x68(%rsp)
movq %rdx, 0x60(%rsp)
movq %rax, 0x70(%rsp)
movq %rbx, 0x90(%rsp)
movq %rbx, 0x88(%rsp)
movb %r13b, 0x80(%rsp)
movq %r14, 0x78(%rsp)
movq %rcx, 0xa0(%rsp)
testq %r8, %r8
je 0x14227d
movq $0x0, 0x38(%r8)
movq %r8, 0x8(%rsp)
movq $0x1, 0x18(%r12)
movq 0x28(%r12), %rax
movq $0x0, (%rax)
movq 0x30(%r12), %rdx
movq 0x40(%r12), %rdi
shlq $0x3, %rdx
movl $0xff, %esi
callq 0x20e0
movq (%r12), %rdx
movq 0x10(%r12), %rdi
xorl %esi, %esi
callq 0x20e0
movq $-0x1, 0x50(%rsp)
movl %ebp, 0x20(%rsp)
movq %r15, 0x18(%rsp)
movq 0xf0(%rsp), %rax
movq %rax, 0x28(%rsp)
movq %rbx, 0x48(%rsp)
movq %rbx, 0x40(%rsp)
movb %r13b, 0x38(%rsp)
movq %r14, 0x30(%rsp)
movq 0xe0(%rsp), %rax
movq %rax, 0x58(%rsp)
movq 0xe8(%rsp), %rax
testq %rax, %rax
je 0x142314
movq $0x0, 0x38(%rax)
movq $0x1, 0x18(%r15)
movq 0x28(%r15), %rax
movq $0x0, (%rax)
movq 0x30(%r15), %rdx
movq 0x40(%r15), %rdi
shlq $0x3, %rdx
movl $0xff, %esi
callq 0x20e0
movq (%r15), %rdx
movq 0x10(%r15), %rdi
xorl %esi, %esi
callq 0x20e0
movq 0x110(%rsp), %rax
testq %rax, %rax
je 0x14235f
movq $0x0, (%rax)
movsd 0xeefa9(%rip), %xmm0    # 0x231310
movsd (%rsp), %xmm2
movapd %xmm2, %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, 0x10(%rsp)
subsd %xmm2, %xmm0
movsd %xmm0, (%rsp)
leaq 0x60(%rsp), %r15
leaq 0x18(%rsp), %r12
movq %r15, %rdi
callq 0x141f2b
movl %eax, %ebp
testl %eax, %eax
je 0x142448
movq 0x60(%rsp), %rax
movq 0x98(%rsp), %r13
movq 0x10(%rax), %rcx
cmpb $0x0, (%rcx,%r13)
je 0x142448
movq 0x18(%rsp), %rcx
movq 0x10(%rcx), %rdx
cmpb $0x0, (%rdx,%r13)
je 0x142448
movq 0x40(%rax), %rax
movq (%rax,%r13,8), %r14
cmpq $-0x1, %r14
je 0x142448
movq 0x40(%rcx), %rax
movq (%rax,%r13,8), %rbx
cmpq $-0x1, %rbx
je 0x142448
movq %rbx, %xmm1
movq 0xeee8c(%rip), %xmm3    # 0x231280
punpckldq %xmm3, %xmm1    # xmm1 = xmm1[0],xmm3[0],xmm1[1],xmm3[1]
movapd 0xeee90(%rip), %xmm4    # 0x231290
subpd %xmm4, %xmm1
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
movq %r14, %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 0x142448
mulsd (%rsp), %xmm1
ucomisd %xmm1, %xmm0
jae 0x142516
movq %r12, %rdi
callq 0x141f2b
testl %eax, %eax
je 0x1424fa
movq 0x60(%rsp), %rcx
movq 0x10(%rcx), %rdx
movq 0x50(%rsp), %r13
cmpb $0x0, (%rdx,%r13)
je 0x1424fa
movq 0x18(%rsp), %rdx
movq 0x10(%rdx), %rsi
cmpb $0x0, (%rsi,%r13)
je 0x1424fa
movq 0x40(%rcx), %rcx
movq (%rcx,%r13,8), %r14
cmpq $-0x1, %r14
je 0x1424fa
movq 0x40(%rdx), %rcx
movq (%rcx,%r13,8), %rbx
cmpq $-0x1, %rbx
je 0x1424fa
movq %rbx, %xmm1
movq 0xeedd6(%rip), %xmm3    # 0x231280
punpckldq %xmm3, %xmm1    # xmm1 = xmm1[0],xmm3[0],xmm1[1],xmm3[1]
movapd 0xeedda(%rip), %xmm4    # 0x231290
subpd %xmm4, %xmm1
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
movq %r14, %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 0x1424fa
mulsd (%rsp), %xmm1
ucomisd %xmm1, %xmm0
jae 0x142516
orl %ebp, %eax
jne 0x14238d
xorl %eax, %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 0x142534
movl 0x68(%rsp), %edi
movq 0xa0(%rsp), %rdx
movq %r13, %rsi
callq 0x1420d9
movq 0xe8(%rsp), %rcx
testq %rcx, %rcx
je 0x142552
movl 0x20(%rsp), %edi
movq 0x58(%rsp), %rdx
movq %r13, %rsi
callq 0x1420d9
movq 0x110(%rsp), %rdi
testq %rdi, %rdi
je 0x142592
addq %r14, %rbx
movq %rbx, (%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, %rbx
movq %rbx, (%rdi)
movl $0x1, %eax
jmp 0x142504