// File: 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
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x20(%rax), %rax
movq -0x18(%rbp), %rcx
movl 0x10(%rcx), %ecx
movl (%rax,%rcx,8), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, -0x64(%rbp)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x20(%rax), %rax
movq -0x20(%rbp), %rcx
movl 0x10(%rcx), %ecx
movl (%rax,%rcx,8), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, -0x68(%rbp)
movq -0x18(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x44(%rbp)
movq -0x18(%rbp), %rax
movl 0x10(%rax), %eax
movl %eax, -0x38(%rbp)
movq -0x18(%rbp), %rax
movl 0x1c(%rax), %ecx
movl -0x2c(%rbp), %eax
andl $0x1, %ecx
shll $0x1f, %ecx
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
orl %ecx, %eax
movl %eax, -0x2c(%rbp)
movq -0x18(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, -0x40(%rbp)
movq -0x18(%rbp), %rax
movl 0x8(%rax), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x0, 0x1c(%rax)
je 0x7c584
movl -0x64(%rbp), %eax
movq -0x18(%rbp), %rcx
subl 0x18(%rcx), %eax
subl $0x1, %eax
movl %eax, -0x34(%rbp)
movl -0x64(%rbp), %eax
movq -0x18(%rbp), %rcx
subl 0x14(%rcx), %eax
movl %eax, -0x30(%rbp)
jmp 0x7c59b
movq -0x18(%rbp), %rax
movl 0x14(%rax), %eax
movl %eax, -0x34(%rbp)
movq -0x18(%rbp), %rax
movl 0x18(%rax), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
movq -0x20(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x60(%rbp)
movq -0x20(%rbp), %rax
movl 0x10(%rax), %eax
movl %eax, -0x54(%rbp)
movq -0x20(%rbp), %rax
movl 0x1c(%rax), %ecx
movl -0x48(%rbp), %eax
andl $0x1, %ecx
shll $0x1f, %ecx
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
orl %ecx, %eax
movl %eax, -0x48(%rbp)
movq -0x20(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, -0x5c(%rbp)
movq -0x20(%rbp), %rax
movl 0x8(%rax), %eax
addl $0x1, %eax
movl %eax, -0x58(%rbp)
movq -0x20(%rbp), %rax
cmpl $0x0, 0x1c(%rax)
je 0x7c608
movl -0x68(%rbp), %eax
movq -0x20(%rbp), %rcx
subl 0x18(%rcx), %eax
subl $0x1, %eax
movl %eax, -0x50(%rbp)
movl -0x68(%rbp), %eax
movq -0x20(%rbp), %rcx
subl 0x14(%rcx), %eax
movl %eax, -0x4c(%rbp)
jmp 0x7c61f
movq -0x20(%rbp), %rax
movl 0x14(%rax), %eax
movl %eax, -0x50(%rbp)
movq -0x20(%rbp), %rax
movl 0x18(%rax), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
movq -0x28(%rbp), %rdi
xorl %esi, %esi
movl $0x1c, %edx
callq 0x2100
movl -0x40(%rbp), %eax
cmpl -0x5c(%rbp), %eax
jb 0x7c642
movl -0x40(%rbp), %eax
movl %eax, -0x84(%rbp)
jmp 0x7c64b
movl -0x5c(%rbp), %eax
movl %eax, -0x84(%rbp)
movl -0x84(%rbp), %eax
movl %eax, -0x6c(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x58(%rbp), %eax
ja 0x7c667
movl -0x3c(%rbp), %eax
movl %eax, -0x88(%rbp)
jmp 0x7c670
movl -0x58(%rbp), %eax
movl %eax, -0x88(%rbp)
movl -0x88(%rbp), %eax
movl %eax, -0x70(%rbp)
movl -0x70(%rbp), %eax
cmpl -0x6c(%rbp), %eax
ja 0x7c68e
movq $0x0, -0x8(%rbp)
jmp 0x7c79d
movl -0x40(%rbp), %edi
movl -0x3c(%rbp), %esi
movl -0x34(%rbp), %edx
movl -0x30(%rbp), %ecx
movl -0x2c(%rbp), %r8d
shrl $0x1f, %r8d
movl -0x6c(%rbp), %r9d
movl -0x70(%rbp), %r11d
leaq -0x74(%rbp), %r10
leaq -0x78(%rbp), %rax
movl %r11d, (%rsp)
movq %r10, 0x8(%rsp)
movq %rax, 0x10(%rsp)
callq 0x2c4c30
cmpl $0x0, %eax
je 0x7c795
movl -0x5c(%rbp), %edi
movl -0x58(%rbp), %esi
movl -0x50(%rbp), %edx
movl -0x4c(%rbp), %ecx
movl -0x48(%rbp), %r8d
shrl $0x1f, %r8d
movl -0x6c(%rbp), %r9d
movl -0x70(%rbp), %r11d
leaq -0x7c(%rbp), %r10
leaq -0x80(%rbp), %rax
movl %r11d, (%rsp)
movq %r10, 0x8(%rsp)
movq %rax, 0x10(%rsp)
callq 0x2c4c30
cmpl $0x0, %eax
je 0x7c795
movl -0x78(%rbp), %eax
cmpl -0x74(%rbp), %eax
jbe 0x7c793
movl -0x80(%rbp), %eax
cmpl -0x7c(%rbp), %eax
jbe 0x7c793
movl -0x38(%rbp), %ecx
movq -0x28(%rbp), %rax
movl %ecx, (%rax)
movl -0x54(%rbp), %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0xc(%rax)
movl -0x2c(%rbp), %ecx
shrl $0x1f, %ecx
movl -0x48(%rbp), %esi
shrl $0x1f, %esi
movl $0x1, %edx
xorl %eax, %eax
cmpl %esi, %ecx
cmovel %eax, %edx
movq -0x28(%rbp), %rax
movl 0x18(%rax), %ecx
andl $0x1, %edx
shll $0x1f, %edx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
orl %edx, %ecx
movl %ecx, 0x18(%rax)
movl -0x74(%rbp), %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x4(%rax)
movl -0x78(%rbp), %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x8(%rax)
movl -0x7c(%rbp), %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x10(%rax)
movl -0x80(%rbp), %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x14(%rax)
movq $0x1, -0x8(%rbp)
jmp 0x7c79d
jmp 0x7c795
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0xa0, %rsp
popq %rbp
retq
nopw (%rax,%rax)