// File: 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
movq %rsp, %rbp
subq $0xf0, %rsp
movq 0x40(%rbp), %rax
movl 0x38(%rbp), %eax
movb 0x30(%rbp), %al
movq 0x28(%rbp), %rax
movq 0x20(%rbp), %rax
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movl %edi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movsd %xmm0, -0x38(%rbp)
movq $0x0, -0xf0(%rbp)
movq $-0x1, -0x68(%rbp)
movl -0x8(%rbp), %eax
movl %eax, -0x98(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq 0x20(%rbp), %rax
movq %rax, -0x90(%rbp)
movl 0x38(%rbp), %eax
movq %rax, -0x70(%rbp)
movl 0x38(%rbp), %eax
movq %rax, -0x78(%rbp)
movb 0x30(%rbp), %al
movb %al, -0x80(%rbp)
movq 0x28(%rbp), %rax
movq %rax, -0x88(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x60(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x1ccbbc
movq -0x28(%rbp), %rax
movq $0x0, 0x38(%rax)
movq -0xa0(%rbp), %rdi
callq 0x1cbba0
movq $-0x1, -0xb0(%rbp)
movl -0xc(%rbp), %eax
movl %eax, -0xe0(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0xe8(%rbp)
movq 0x20(%rbp), %rax
movq %rax, -0xd8(%rbp)
movl 0x38(%rbp), %eax
movq %rax, -0xb8(%rbp)
movl 0x38(%rbp), %eax
movq %rax, -0xc0(%rbp)
movb 0x30(%rbp), %al
movb %al, -0xc8(%rbp)
movq 0x28(%rbp), %rax
movq %rax, -0xd0(%rbp)
movq 0x10(%rbp), %rax
movq %rax, -0xa8(%rbp)
cmpq $0x0, 0x18(%rbp)
je 0x1ccc38
movq 0x18(%rbp), %rax
movq $0x0, 0x38(%rax)
movq -0xe8(%rbp), %rdi
callq 0x1cbba0
cmpq $0x0, 0x40(%rbp)
je 0x1ccc56
movq 0x40(%rbp), %rax
movq $0x0, (%rax)
jmp 0x1ccc58
leaq -0xa0(%rbp), %rax
movq %rax, -0xf0(%rbp)
movq -0xf0(%rbp), %rdi
callq 0x1cc550
movl %eax, %eax
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
je 0x1cce87
movq -0xa0(%rbp), %rax
movq 0x10(%rax), %rax
movq -0xf0(%rbp), %rcx
movq 0x38(%rcx), %rcx
cmpb $0x0, (%rax,%rcx)
je 0x1cce87
movq -0xe8(%rbp), %rax
movq 0x10(%rax), %rax
movq -0xf0(%rbp), %rcx
movq 0x38(%rcx), %rcx
cmpb $0x0, (%rax,%rcx)
je 0x1cce87
movq -0xa0(%rbp), %rax
movq 0x40(%rax), %rax
movq -0xf0(%rbp), %rcx
movq 0x38(%rcx), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x50(%rbp)
movq -0xe8(%rbp), %rax
movq 0x40(%rax), %rax
movq -0xf0(%rbp), %rcx
movq 0x38(%rcx), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x58(%rbp)
cmpq $-0x1, -0x50(%rbp)
je 0x1cce85
cmpq $-0x1, -0x58(%rbp)
je 0x1cce85
movq -0x58(%rbp), %xmm1
movaps 0x1b52ef(%rip), %xmm3   # 0x382010
punpckldq %xmm3, %xmm1    # xmm1 = xmm1[0],xmm3[0],xmm1[1],xmm3[1]
movapd 0x1b52f3(%rip), %xmm2   # 0x382020
subpd %xmm2, %xmm1
movaps %xmm1, %xmm0
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm0, %xmm1
movq -0x50(%rbp), %xmm0
punpckldq %xmm3, %xmm0    # xmm0 = xmm0[0],xmm3[0],xmm0[1],xmm3[1]
subpd %xmm2, %xmm0
movaps %xmm0, %xmm2
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm2, %xmm0
movsd 0x1b52a4(%rip), %xmm2   # 0x382000
addsd -0x38(%rbp), %xmm2
mulsd %xmm2, %xmm0
ucomisd %xmm1, %xmm0
jb 0x1cce83
movq -0x58(%rbp), %xmm0
movaps 0x1b5295(%rip), %xmm3   # 0x382010
punpckldq %xmm3, %xmm0    # xmm0 = xmm0[0],xmm3[0],xmm0[1],xmm3[1]
movapd 0x1b5299(%rip), %xmm2   # 0x382020
subpd %xmm2, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movq -0x50(%rbp), %xmm1
punpckldq %xmm3, %xmm1    # xmm1 = xmm1[0],xmm3[0],xmm1[1],xmm3[1]
subpd %xmm2, %xmm1
movaps %xmm1, %xmm2
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm2, %xmm1
movsd 0x1b524a(%rip), %xmm2   # 0x382000
subsd -0x38(%rbp), %xmm2
mulsd %xmm2, %xmm1
ucomisd %xmm1, %xmm0
jb 0x1cce83
cmpq $0x0, -0x28(%rbp)
je 0x1ccdf0
movl -0x98(%rbp), %eax
movl %eax, %edi
movq -0xf0(%rbp), %rax
movq 0x38(%rax), %rsi
movq -0x60(%rbp), %rdx
movq -0x28(%rbp), %rcx
callq 0x1cc870
cmpq $0x0, 0x18(%rbp)
je 0x1cce1a
movl -0xe0(%rbp), %eax
movl %eax, %edi
movq -0xf0(%rbp), %rax
movq 0x38(%rax), %rsi
movq -0xa8(%rbp), %rdx
movq 0x18(%rbp), %rcx
callq 0x1cc870
cmpq $0x0, 0x40(%rbp)
je 0x1cce77
movq -0x50(%rbp), %rcx
addq -0x58(%rbp), %rcx
movq 0x40(%rbp), %rax
movq %rcx, (%rax)
movq 0x20(%rbp), %rax
movq 0x20(%rax), %rax
movl -0x98(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
movl (%rax,%rcx,8), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movq 0x20(%rbp), %rcx
movq 0x20(%rcx), %rcx
movl -0xe0(%rbp), %edx
shrl %edx
movl %edx, %edx
movl (%rcx,%rdx,8), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
addl %ecx, %eax
movslq %eax, %rdx
movq 0x40(%rbp), %rax
movq (%rax), %rcx
subq %rdx, %rcx
movq %rcx, (%rax)
movl $0x1, -0x4(%rbp)
jmp 0x1cd0cf
jmp 0x1cce85
jmp 0x1cce87
leaq -0xe8(%rbp), %rax
movq %rax, -0xf0(%rbp)
movq -0xf0(%rbp), %rdi
callq 0x1cc550
movl %eax, %eax
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
je 0x1cd0b3
movq -0xa0(%rbp), %rax
movq 0x10(%rax), %rax
movq -0xf0(%rbp), %rcx
movq 0x38(%rcx), %rcx
cmpb $0x0, (%rax,%rcx)
je 0x1cd0b3
movq -0xe8(%rbp), %rax
movq 0x10(%rax), %rax
movq -0xf0(%rbp), %rcx
movq 0x38(%rcx), %rcx
cmpb $0x0, (%rax,%rcx)
je 0x1cd0b3
movq -0xa0(%rbp), %rax
movq 0x40(%rax), %rax
movq -0xf0(%rbp), %rcx
movq 0x38(%rcx), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x50(%rbp)
movq -0xe8(%rbp), %rax
movq 0x40(%rax), %rax
movq -0xf0(%rbp), %rcx
movq 0x38(%rcx), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x58(%rbp)
cmpq $-0x1, -0x50(%rbp)
je 0x1cd0b1
cmpq $-0x1, -0x58(%rbp)
je 0x1cd0b1
movq -0x58(%rbp), %xmm1
movaps 0x1b50c0(%rip), %xmm3   # 0x382010
punpckldq %xmm3, %xmm1    # xmm1 = xmm1[0],xmm3[0],xmm1[1],xmm3[1]
movapd 0x1b50c4(%rip), %xmm2   # 0x382020
subpd %xmm2, %xmm1
movaps %xmm1, %xmm0
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm0, %xmm1
movq -0x50(%rbp), %xmm0
punpckldq %xmm3, %xmm0    # xmm0 = xmm0[0],xmm3[0],xmm0[1],xmm3[1]
subpd %xmm2, %xmm0
movaps %xmm0, %xmm2
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm2, %xmm0
movsd 0x1b5075(%rip), %xmm2   # 0x382000
addsd -0x38(%rbp), %xmm2
mulsd %xmm2, %xmm0
ucomisd %xmm1, %xmm0
jb 0x1cd0af
movq -0x58(%rbp), %xmm0
movaps 0x1b5066(%rip), %xmm3   # 0x382010
punpckldq %xmm3, %xmm0    # xmm0 = xmm0[0],xmm3[0],xmm0[1],xmm3[1]
movapd 0x1b506a(%rip), %xmm2   # 0x382020
subpd %xmm2, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movq -0x50(%rbp), %xmm1
punpckldq %xmm3, %xmm1    # xmm1 = xmm1[0],xmm3[0],xmm1[1],xmm3[1]
subpd %xmm2, %xmm1
movaps %xmm1, %xmm2
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm2, %xmm1
movsd 0x1b501b(%rip), %xmm2   # 0x382000
subsd -0x38(%rbp), %xmm2
mulsd %xmm2, %xmm1
ucomisd %xmm1, %xmm0
jb 0x1cd0af
cmpq $0x0, -0x28(%rbp)
je 0x1cd01f
movl -0x98(%rbp), %eax
movl %eax, %edi
movq -0xf0(%rbp), %rax
movq 0x38(%rax), %rsi
movq -0x60(%rbp), %rdx
movq -0x28(%rbp), %rcx
callq 0x1cc870
cmpq $0x0, 0x18(%rbp)
je 0x1cd049
movl -0xe0(%rbp), %eax
movl %eax, %edi
movq -0xf0(%rbp), %rax
movq 0x38(%rax), %rsi
movq -0xa8(%rbp), %rdx
movq 0x18(%rbp), %rcx
callq 0x1cc870
cmpq $0x0, 0x40(%rbp)
je 0x1cd0a6
movq -0x50(%rbp), %rcx
addq -0x58(%rbp), %rcx
movq 0x40(%rbp), %rax
movq %rcx, (%rax)
movq 0x20(%rbp), %rax
movq 0x20(%rax), %rax
movl -0x98(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
movl (%rax,%rcx,8), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movq 0x20(%rbp), %rcx
movq 0x20(%rcx), %rcx
movl -0xe0(%rbp), %edx
shrl %edx
movl %edx, %edx
movl (%rcx,%rdx,8), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
addl %ecx, %eax
movslq %eax, %rdx
movq 0x40(%rbp), %rax
movq (%rax), %rcx
subq %rdx, %rcx
movq %rcx, (%rax)
movl $0x1, -0x4(%rbp)
jmp 0x1cd0cf
jmp 0x1cd0b1
jmp 0x1cd0b3
cmpq $0x0, -0x40(%rbp)
jne 0x1cd0ca
cmpq $0x0, -0x48(%rbp)
jne 0x1cd0ca
movl $0x0, -0x4(%rbp)
jmp 0x1cd0cf
jmp 0x1ccc58
movl -0x4(%rbp), %eax
addq $0xf0, %rsp
popq %rbp
retq
nopl (%rax,%rax)