// File: /workspace/github_cpp_makefile_star2_O3/chhylp123[P]hifiasm/Correct.cpp
// Function: cal_x_ul_ovlp(ma_ug_t*, overlap_region*, overlap_region*, ul_ov_t*)
uint64_t cal_x_ul_ovlp(ma_ug_t *ug, overlap_region *q, overlap_region *t, ul_ov_t *res)
{
    ul_ov_t qo, to; uint32_t ql, tl, os, oe, rqs, rqe, rts, rte;
    ql = ug->g->seq[q->y_id].len; tl = ug->g->seq[t->y_id].len;
    aln2ov((*q), qo, ql); aln2ov((*t), to, tl); memset(res, 0, sizeof(*res));
    os = MAX(qo.qs, to.qs); oe = MIN(qo.qe, to.qe);
    if(oe <= os) return 0;
    if(infer_se(qo.qs, qo.qe, qo.ts, qo.te, qo.rev, os, oe, &rqs, &rqe) &&
			infer_se(to.qs, to.qe, to.ts, to.te, to.rev, os, oe, &rts, &rte)) {
        if(rqe > rqs && rte > rts) {
            res->qn = qo.tn; res->tn = to.tn; res->rev = ((qo.rev==to.rev)?0:1);
            res->qs = rqs; res->qe = rqe; res->ts = rts; res->te = rte; 
            return 1;
        }
    }
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rcx, %r10
movq %rdx, %rax
movq %rsi, %r8
movq 0x18(%rdi), %rcx
movq 0x20(%rcx), %r9
movl 0x10(%rsi), %r11d
movl 0x10(%rdx), %ebx
movl $0x7fffffff, %r14d      # imm = 0x7FFFFFFF
movl 0x1c(%rsi), %ecx
movl 0x8(%rsi), %esi
movl %ecx, 0x8(%rsp)
testl %ecx, %ecx
je 0x74333
movl (%r9,%r11,8), %ecx
andl %r14d, %ecx
movl 0x18(%r8), %edx
notl %edx
addl %ecx, %edx
subl 0x14(%r8), %ecx
jmp 0x7433d
movl 0x14(%r8), %edx
movl 0x18(%r8), %ecx
incl %ecx
movl 0x4(%r8), %edi
incl %esi
movl 0x1c(%rax), %r8d
movl 0x4(%rax), %ebp
movl 0x8(%rax), %r13d
incl %r13d
testl %r8d, %r8d
movq %rbx, 0x30(%rsp)
je 0x7436d
andl (%r9,%rbx,8), %r14d
movl 0x18(%rax), %ebx
notl %ebx
addl %r14d, %ebx
subl 0x14(%rax), %r14d
jmp 0x74377
movl 0x14(%rax), %ebx
movl 0x18(%rax), %r14d
incl %r14d
xorps %xmm0, %xmm0
movups %xmm0, 0xc(%r10)
movups %xmm0, (%r10)
cmpl %ebp, %edi
movl %ebp, %r12d
cmoval %edi, %r12d
cmpl %r13d, %esi
movl %r13d, %r15d
cmovbl %esi, %r15d
cmpl %r12d, %r15d
jbe 0x7447f
movl %r8d, 0xc(%rsp)
movq %r11, 0x20(%rsp)
movq %r10, 0x28(%rsp)
movl 0x8(%rsp), %r8d
andl $0x1, %r8d
subq $0x8, %rsp
leaq 0x20(%rsp), %rax
leaq 0x24(%rsp), %r10
movl %r8d, 0x10(%rsp)
movl %r12d, %r9d
pushq %rax
pushq %r10
pushq %r15
callq 0x1c847b
addq $0x20, %rsp
testl %eax, %eax
je 0x7447f
movl 0xc(%rsp), %r8d
andl $0x1, %r8d
subq $0x8, %rsp
leaq 0x18(%rsp), %rax
leaq 0x1c(%rsp), %r10
movl %ebp, %edi
movl %r13d, %esi
movl %ebx, %edx
movl %r14d, %ecx
movl %r8d, %ebx
movl %r12d, %r9d
pushq %rax
pushq %r10
pushq %r15
callq 0x1c847b
addq $0x20, %rsp
testl %eax, %eax
je 0x7447f
movl 0x18(%rsp), %eax
movl 0x1c(%rsp), %ecx
cmpl %ecx, %eax
jbe 0x7447f
movl 0x10(%rsp), %edx
movl 0x14(%rsp), %esi
cmpl %esi, %edx
jbe 0x7447f
movq 0x28(%rsp), %r9
movq 0x20(%rsp), %rdi
movl %edi, (%r9)
movq 0x30(%rsp), %rdi
movl %edi, 0xc(%r9)
xorl %edi, %edi
cmpl %ebx, 0x8(%rsp)
setne %dil
movl $0x7fffffff, %r8d       # imm = 0x7FFFFFFF
andl 0x18(%r9), %r8d
shll $0x1f, %edi
orl %edi, %r8d
movl %r8d, 0x18(%r9)
movl %ecx, 0x4(%r9)
movl %eax, 0x8(%r9)
movl %esi, 0x10(%r9)
movl %edx, 0x14(%r9)
movl $0x1, %eax
jmp 0x74481
xorl %eax, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq