// File: chhylp123[P]hifiasm/gfa_ut.cpp
// Function: integer_hit2arc_idx_contain(ul2ul_t const*, long, long, unsigned long*)
static inline int64_t integer_hit2arc_idx_contain(const ul2ul_t *z, int64_t qn, int64_t tn, uint64_t *dir)
{
    int64_t tn5, tn3, extn5, extn3, qsn = z->qs_k, qen = qn - ((int64_t)z->qe_k);
    if (z->is_rev) tn5 = tn - z->te_k, tn3 = z->ts_k;
    else tn5 = z->ts_k, tn3 = tn - z->te_k;
    (*dir) = (uint64_t)-1;

    extn5 = ((qsn<tn5)?qsn:tn5);
    extn3 = ((qen<tn3)?qen:tn3);
    if(extn5 > 0 || extn3 > 0) return MA_HT_INT;///overhang
    if (qsn < tn5 && qen < tn3) { // query contained in target
        return MA_HT_QCONT; 
    } else if (qsn > tn5 && qen > tn3) { // target contained in query
        return MA_HT_TCONT;  
    } else if(qsn == tn5 && qen == tn3) {
        (*dir) = (uint64_t)-1;
    } else if (qsn > tn5) { ///query-to-target overlap
        (*dir) = 0;
    } else if(qsn < tn5) { ///target-to-query overlaps
        (*dir) = 1;
    } else if(qen > tn3) { ///target-to-query overlaps
        (*dir) = 1;
    } else if(qen < tn3) { ///query-to-target overlap
        (*dir) = 0;
    }
    return MA_HT_DOUBLE;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq -0x10(%rbp), %rax
movl 0x14(%rax), %eax
movq %rax, -0x50(%rbp)
movq -0x18(%rbp), %rax
movq -0x10(%rbp), %rcx
movl 0x18(%rcx), %ecx
subq %rcx, %rax
movq %rax, -0x58(%rbp)
movq -0x10(%rbp), %rax
movb 0x24(%rax), %al
andb $0x3f, %al
cmpb $0x0, %al
je 0x37b89d
movq -0x20(%rbp), %rax
movq -0x10(%rbp), %rcx
movl 0x20(%rcx), %ecx
subq %rcx, %rax
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rax
movl 0x1c(%rax), %eax
movq %rax, -0x38(%rbp)
jmp 0x37b8ba
movq -0x10(%rbp), %rax
movl 0x1c(%rax), %eax
movq %rax, -0x30(%rbp)
movq -0x20(%rbp), %rax
movq -0x10(%rbp), %rcx
movl 0x20(%rcx), %ecx
subq %rcx, %rax
movq %rax, -0x38(%rbp)
movq -0x28(%rbp), %rax
movq $-0x1, (%rax)
movq -0x50(%rbp), %rax
cmpq -0x30(%rbp), %rax
jge 0x37b8d9
movq -0x50(%rbp), %rax
movq %rax, -0x60(%rbp)
jmp 0x37b8e1
movq -0x30(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x58(%rbp), %rax
cmpq -0x38(%rbp), %rax
jge 0x37b8fd
movq -0x58(%rbp), %rax
movq %rax, -0x68(%rbp)
jmp 0x37b905
movq -0x38(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rax
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x40(%rbp)
jg 0x37b91b
cmpq $0x0, -0x48(%rbp)
jle 0x37b928
movq $-0x1, -0x8(%rbp)
jmp 0x37b9f9
movq -0x50(%rbp), %rax
cmpq -0x30(%rbp), %rax
jge 0x37b949
movq -0x58(%rbp), %rax
cmpq -0x38(%rbp), %rax
jge 0x37b949
movq $-0x2, -0x8(%rbp)
jmp 0x37b9f9
movq -0x50(%rbp), %rax
cmpq -0x30(%rbp), %rax
jle 0x37b96a
movq -0x58(%rbp), %rax
cmpq -0x38(%rbp), %rax
jle 0x37b96a
movq $-0x3, -0x8(%rbp)
jmp 0x37b9f9
movq -0x50(%rbp), %rax
cmpq -0x30(%rbp), %rax
jne 0x37b98b
movq -0x58(%rbp), %rax
cmpq -0x38(%rbp), %rax
jne 0x37b98b
movq -0x28(%rbp), %rax
movq $-0x1, (%rax)
jmp 0x37b9ed
movq -0x50(%rbp), %rax
cmpq -0x30(%rbp), %rax
jle 0x37b9a2
movq -0x28(%rbp), %rax
movq $0x0, (%rax)
jmp 0x37b9eb
movq -0x50(%rbp), %rax
cmpq -0x30(%rbp), %rax
jge 0x37b9b9
movq -0x28(%rbp), %rax
movq $0x1, (%rax)
jmp 0x37b9e9
movq -0x58(%rbp), %rax
cmpq -0x38(%rbp), %rax
jle 0x37b9d0
movq -0x28(%rbp), %rax
movq $0x1, (%rax)
jmp 0x37b9e7
movq -0x58(%rbp), %rax
cmpq -0x38(%rbp), %rax
jge 0x37b9e5
movq -0x28(%rbp), %rax
movq $0x0, (%rax)
jmp 0x37b9e7
jmp 0x37b9e9
jmp 0x37b9eb
jmp 0x37b9ed
jmp 0x37b9ef
jmp 0x37b9f1
movq $-0x400, -0x8(%rbp)     # imm = 0xFC00
movq -0x8(%rbp), %rax
popq %rbp
retq
nop