// File: chhylp123[P]hifiasm/gfa_ut.cpp
// Function: trans_path_check(unsigned int, unsigned int, asg_t*, ma_hit_t_alloc*, R_to_U*, unsigned int, asg64_v*)
uint32_t trans_path_check(uint32_t a, uint32_t b, asg_t *g, ma_hit_t_alloc *rev, R_to_U* rI, 
uint32_t minLen, asg64_v *t)
{
    if(a == b) return -1;
    uint32_t tn = t->n, m, e, l[2] = {0};
    uint64_t *x[2];
    m = follow_limit_path(g, a, &e, &(l[0]), t, (uint32_t)-1);
    if(m == LOOP || l[0] <= minLen) {
        t->n = tn; return -1;
    }

    m = follow_limit_path(g, b, &e, &(l[1]), t, (uint32_t)-1);
    if(m == LOOP || l[1] <= minLen) {
        t->n = tn; return -1;
    }

    x[0] = t->a + tn; x[1] = t->a + tn + l[0];
    if(l[0] > l[1]) {
        x[0] = t->a + tn + l[0]; x[1] = t->a + tn;
        m = l[0]; l[0] = l[1]; l[1] = m;
    }
    assert(l[0]+l[1]+tn==t->n);

    uint32_t i, k, qi, ti, isU; double max_count = 0, min_count = 0;
    for (i = 0; i < l[1]; i++) g->seq_vis[x[1][i]>>1] = 1;
    for (i = 0; i < l[0]; i++) {
        qi = x[0][i]>>1;
        for (k = 0; k < rev[qi].length; k++) {
            ti = Get_tn(rev[qi].buffer[k]);
            if(g->seq[ti].del == 1) {
                get_R_to_U(rI, ti, &ti, &isU);
                if(ti == (uint32_t)-1 || isU == 1 || g->seq[ti].del == 1) continue;
            }
            min_count++; max_count += g->seq_vis[ti];
        }
    }

    for (i = 0; i < l[1]; i++) g->seq_vis[x[1][i]>>1] = 0;
    t->n = tn;

    if(min_count == 0) return -1;
    if(max_count == 0) return 0;
    if((max_count/min_count)>0.3) return 1;
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq 0x10(%rbp), %rax
movl %edi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movl %r9d, -0x2c(%rbp)
movl -0x8(%rbp), %eax
cmpl -0xc(%rbp), %eax
jne 0x315719
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x315a61
movq 0x10(%rbp), %rax
movq (%rax), %rax
movl %eax, -0x30(%rbp)
leaq -0x40(%rbp), %rdi
xorl %esi, %esi
movl $0x8, %edx
callq 0x2100
movq -0x18(%rbp), %rdi
movl -0x8(%rbp), %esi
leaq -0x40(%rbp), %rcx
movq 0x10(%rbp), %r8
leaq -0x38(%rbp), %rdx
movl $0xffffffff, %r9d       # imm = 0xFFFFFFFF
callq 0x311da0
movl %eax, -0x34(%rbp)
cmpl $0x7, -0x34(%rbp)
je 0x315762
movl -0x40(%rbp), %eax
cmpl -0x2c(%rbp), %eax
ja 0x31577a
movl -0x30(%rbp), %eax
movl %eax, %ecx
movq 0x10(%rbp), %rax
movq %rcx, (%rax)
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x315a61
movq -0x18(%rbp), %rdi
movl -0xc(%rbp), %esi
leaq -0x40(%rbp), %rcx
addq $0x4, %rcx
movq 0x10(%rbp), %r8
leaq -0x38(%rbp), %rdx
movl $0xffffffff, %r9d       # imm = 0xFFFFFFFF
callq 0x311da0
movl %eax, -0x34(%rbp)
cmpl $0x7, -0x34(%rbp)
je 0x3157ad
movl -0x3c(%rbp), %eax
cmpl -0x2c(%rbp), %eax
ja 0x3157c5
movl -0x30(%rbp), %eax
movl %eax, %ecx
movq 0x10(%rbp), %rax
movq %rcx, (%rax)
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x315a61
movq 0x10(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x30(%rbp), %ecx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, -0x50(%rbp)
movq 0x10(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x30(%rbp), %ecx
shlq $0x3, %rcx
addq %rcx, %rax
movl -0x40(%rbp), %ecx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, -0x48(%rbp)
movl -0x40(%rbp), %eax
cmpl -0x3c(%rbp), %eax
jbe 0x31584b
movq 0x10(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x30(%rbp), %ecx
shlq $0x3, %rcx
addq %rcx, %rax
movl -0x40(%rbp), %ecx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, -0x50(%rbp)
movq 0x10(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x30(%rbp), %ecx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, -0x48(%rbp)
movl -0x40(%rbp), %eax
movl %eax, -0x34(%rbp)
movl -0x3c(%rbp), %eax
movl %eax, -0x40(%rbp)
movl -0x34(%rbp), %eax
movl %eax, -0x3c(%rbp)
movl -0x40(%rbp), %eax
addl -0x3c(%rbp), %eax
addl -0x30(%rbp), %eax
movl %eax, %eax
movq 0x10(%rbp), %rcx
cmpq (%rcx), %rax
jne 0x315861
jmp 0x315880
leaq 0x80bd9(%rip), %rdi     # 0x396441
leaq 0x8094a(%rip), %rsi     # 0x3961b9
movl $0x4e5, %edx            # imm = 0x4E5
leaq 0x80bd9(%rip), %rcx     # 0x396454
callq 0x2130
xorps %xmm0, %xmm0
movsd %xmm0, -0x70(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x78(%rbp)
movl $0x0, -0x54(%rbp)
movl -0x54(%rbp), %eax
cmpl -0x3c(%rbp), %eax
jae 0x3158c4
movq -0x18(%rbp), %rax
movq 0x30(%rax), %rax
movq -0x48(%rbp), %rcx
movl -0x54(%rbp), %edx
movq (%rcx,%rdx,8), %rcx
shrq %rcx
movb $0x1, (%rax,%rcx)
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
jmp 0x315897
movl $0x0, -0x54(%rbp)
movl -0x54(%rbp), %eax
cmpl -0x40(%rbp), %eax
jae 0x3159c7
movq -0x50(%rbp), %rax
movl -0x54(%rbp), %ecx
movq (%rax,%rcx,8), %rax
shrq %rax
movl %eax, -0x5c(%rbp)
movl $0x0, -0x58(%rbp)
movl -0x58(%rbp), %eax
movq -0x20(%rbp), %rcx
movl -0x5c(%rbp), %edx
imulq $0x18, %rdx, %rdx
addq %rdx, %rcx
cmpl 0xc(%rcx), %eax
jae 0x3159b7
movq -0x20(%rbp), %rax
movl -0x5c(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rax
movl -0x58(%rbp), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl 0xc(%rax), %eax
movl %eax, -0x60(%rbp)
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
movl -0x60(%rbp), %ecx
movl (%rax,%rcx,8), %eax
shrl $0x1f, %eax
cmpl $0x1, %eax
jne 0x31597a
movq -0x28(%rbp), %rdi
movl -0x60(%rbp), %esi
leaq -0x60(%rbp), %rdx
leaq -0x64(%rbp), %rcx
callq 0xd3d50
cmpl $-0x1, -0x60(%rbp)
je 0x315976
cmpl $0x1, -0x64(%rbp)
je 0x315976
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
movl -0x60(%rbp), %ecx
movl (%rax,%rcx,8), %eax
shrl $0x1f, %eax
cmpl $0x1, %eax
jne 0x315978
jmp 0x3159a9
jmp 0x31597a
movsd 0x6c67e(%rip), %xmm0    # 0x382000
addsd -0x78(%rbp), %xmm0
movsd %xmm0, -0x78(%rbp)
movq -0x18(%rbp), %rax
movq 0x30(%rax), %rax
movl -0x60(%rbp), %ecx
movzbl (%rax,%rcx), %eax
cvtsi2sd %eax, %xmm0
addsd -0x70(%rbp), %xmm0
movsd %xmm0, -0x70(%rbp)
movl -0x58(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x58(%rbp)
jmp 0x3158ef
jmp 0x3159b9
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
jmp 0x3158cb
movl $0x0, -0x54(%rbp)
movl -0x54(%rbp), %eax
cmpl -0x3c(%rbp), %eax
jae 0x3159fb
movq -0x18(%rbp), %rax
movq 0x30(%rax), %rax
movq -0x48(%rbp), %rcx
movl -0x54(%rbp), %edx
movq (%rcx,%rdx,8), %rcx
shrq %rcx
movb $0x0, (%rax,%rcx)
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
jmp 0x3159ce
movl -0x30(%rbp), %eax
movl %eax, %ecx
movq 0x10(%rbp), %rax
movq %rcx, (%rax)
movsd -0x78(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x315a20
jp 0x315a20
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x315a61
movsd -0x70(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x315a39
jp 0x315a39
movl $0x0, -0x4(%rbp)
jmp 0x315a61
movsd -0x70(%rbp), %xmm0
divsd -0x78(%rbp), %xmm0
movsd 0x6befd(%rip), %xmm1    # 0x381948
ucomisd %xmm1, %xmm0
jbe 0x315a5a
movl $0x1, -0x4(%rbp)
jmp 0x315a61
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x80, %rsp
popq %rbp
retq
nopl (%rax)