// File: /workspace/github_cpp_makefile_star2_O3/chhylp123[P]hifiasm/Correct.cpp
// Function: push_consist_ul_ovlps(ma_ug_t*, kv_ul_ov_t*, unsigned long, unsigned long, double, ul_ov_t*, idx_emask_t*, kv_ul_ov_t*, unsigned long, unsigned long*)
void push_consist_ul_ovlps(ma_ug_t *ug, kv_ul_ov_t *ov_db, uint64_t s, uint64_t e, double len_diff, ul_ov_t *ref, idx_emask_t *mm, kv_ul_ov_t *out, uint64_t flip_res, uint64_t *is_exact)
{
    (*is_exact) = 0;
    if(s >= e) return;
    uint64_t k, z, ql = ug->g->seq[ref->qn].len, tl = ug->g->seq[ref->tn].len; ul_ov_t *p;
    for (k = s; k < e && ov_db->a[k].tn < ref->tn; k++);
    for (; k < e && ov_db->a[k].tn == ref->tn; k++) {
        if((!check_ul_ov_t_consist(ref, &(ov_db->a[k]), ql, tl, len_diff))) continue;
        z = k;
        if(is_ul_ov_pe(ov_db->a, ov_db->n, k, (*mm))) {
            k++; if((!check_ul_ov_t_consist(ref, &(ov_db->a[k]), ql, tl, len_diff))) continue;
        }
        if(is_exact_ov(ov_db->a[k], (*mm))) {
            (*is_exact) = 1; return;
        }

        for (; z <= k; z++) {
            kv_pushp(ul_ov_t, *out, &p);
            *p = ov_db->a[k];
            if(flip_res) {
                p->qn = ov_db->a[k].tn; p->tn = ov_db->a[k].qn;
                p->qs = ov_db->a[k].ts; p->qe = ov_db->a[k].te;
                p->ts = ov_db->a[k].qs; p->te = ov_db->a[k].qe;
            }
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %r9, 0x8(%rsp)
movsd %xmm0, 0x20(%rsp)
movq 0x70(%rsp), %rax
movq $0x0, (%rax)
cmpq %rcx, %rdx
jae 0x74c92
movq %r8, %rbp
movq %rcx, %r15
movq %rdx, %r13
movq %rsi, %r12
movq 0x60(%rsp), %rbx
movq 0x18(%rdi), %rax
movq 0x20(%rax), %rcx
movl (%r8), %edx
movl 0xc(%r8), %eax
movl (%rcx,%rdx,8), %esi
movl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
andq %rdx, %rsi
movq %rsi, 0x18(%rsp)
movl (%rcx,%rax,8), %ecx
andq %rdx, %rcx
movq %rcx, 0x10(%rsp)
movq (%r12), %rcx
leaq (,%r13,8), %rdx
addq %r13, %rdx
leaq (%rdx,%rdx,2), %rdx
addq %r13, %rdx
addq %rdx, %rcx
addq $0xc, %rcx
cmpl %eax, (%rcx)
jae 0x74a40
incq %r13
addq $0x1c, %rcx
cmpq %r13, %r15
jne 0x74a2b
jmp 0x74c92
cmpq %r15, %r13
jae 0x74c92
movq %rbp, (%rsp)
movq (%r12), %rsi
leaq (,%r13,8), %rax
addq %r13, %rax
leaq (%rax,%rax,2), %r14
addq %r13, %r14
movl 0xc(%rsi,%r14), %eax
cmpl 0xc(%rbp), %eax
jne 0x74c92
addq %r14, %rsi
movq %rbp, %rdi
movq 0x18(%rsp), %rdx
movq 0x10(%rsp), %rcx
movsd 0x20(%rsp), %xmm0
callq 0x1ca9e4
testq %rax, %rax
je 0x74c28
leaq 0x1(%r13), %rbp
movq (%r12), %rax
cmpq 0x8(%r12), %rbp
jae 0x74b2b
leaq (,%rbp,8), %rcx
addq %rbp, %rcx
leaq (%rcx,%rcx,2), %rsi
addq %rbp, %rsi
movl (%rax,%rsi), %edx
cmpl (%rax,%r14), %edx
jne 0x74b2b
addq %rax, %rsi
addq %rax, %r14
movl 0xc(%rsi), %ecx
cmpl 0xc(%r14), %ecx
jne 0x74b2b
movl 0x18(%rsi), %ecx
movl 0x18(%r14), %edi
movl %edi, %r8d
xorl %ecx, %r8d
js 0x74b2b
movl $0x3fffffff, %r8d       # imm = 0x3FFFFFFF
andq %r8, %rcx
andq %r8, %rdi
leal 0x1(%rdi), %r8d
cmpl %r8d, %ecx
jne 0x74b2b
movq 0x8(%rsp), %r8
movq (%r8), %r8
leaq (%rdx,%rdx,2), %rdx
movq 0x8(%r8,%rdx,8), %r9
cmpq %rdi, %r9
jbe 0x74b2b
cmpq %rcx, %r9
jbe 0x74b2b
leaq (%r8,%rdx,8), %rdx
movq (%rdx), %rdx
shlq $0x5, %rdi
movb 0x1c(%rdx,%rdi), %dil
testb $0x20, %dil
jne 0x74c36
movq %r13, %r14
leaq (%r14,%r14,8), %rcx
leaq (%rcx,%rcx,2), %rbp
addq %r14, %rbp
movl (%rax,%rbp), %edx
movl 0x18(%rax,%rbp), %eax
andl $0x3fffffff, %eax       # imm = 0x3FFFFFFF
movq 0x8(%rsp), %rcx
movq (%rcx), %rcx
leaq (%rdx,%rdx,2), %rdx
cmpq %rax, 0x8(%rcx,%rdx,8)
jbe 0x74c18
leaq (%rcx,%rdx,8), %rcx
movq (%rcx), %rcx
shlq $0x5, %rax
testb $0x20, 0x1c(%rcx,%rax)
jne 0x74c18
addq %rax, %rcx
cmpl $-0x1, 0x8(%rcx)
jne 0x74c18
jmp 0x74c86
movq (%rbx), %rax
movq 0x8(%rbx), %rcx
cmpq 0x10(%rbx), %rcx
jne 0x74bbf
leaq (%rcx,%rcx), %rdx
testq %rcx, %rcx
movl $0x2, %ecx
cmoveq %rcx, %rdx
movq %rdx, 0x10(%rbx)
leaq (%rdx,%rdx,8), %rcx
leaq (%rcx,%rcx,2), %rsi
addq %rdx, %rsi
movq %rax, %rdi
callq 0x2370
movq %rax, (%rbx)
movq 0x8(%rbx), %rcx
leaq 0x1(%rcx), %rsi
leaq (%rcx,%rcx,8), %rdx
leaq (%rdx,%rdx,2), %rdx
addq %rcx, %rdx
movq %rsi, 0x8(%rbx)
movq (%r12), %rcx
movups (%rcx,%rbp), %xmm0
movups 0xc(%rcx,%rbp), %xmm1
movups %xmm1, 0xc(%rax,%rdx)
movups %xmm0, (%rax,%rdx)
cmpq $0x0, 0x68(%rsp)
je 0x74c15
addq %rdx, %rax
movq (%r12), %rcx
movq 0xc(%rcx,%rbp), %rdx
movq %rdx, (%rax)
movl 0x14(%rcx,%rbp), %edx
movl %edx, 0x8(%rax)
movq (%rcx,%rbp), %rdx
movq %rdx, 0xc(%rax)
movl 0x8(%rcx,%rbp), %ecx
movl %ecx, 0x14(%rax)
incq %r13
cmpq %r14, %r13
jbe 0x74b84
movq %r14, %r13
movq (%rsp), %rbp
incq %r13
cmpq %r15, %r13
jb 0x74a4d
jmp 0x74c92
testb $0x1f, %dil
jne 0x74b2b
shlq $0x5, %rcx
movb 0x1c(%rdx,%rcx), %cl
andb $0x3f, %cl
movq %r13, %r14
cmpb $0x21, %cl
jne 0x74b2e
movq (%rsp), %rdi
movq 0x18(%rsp), %rdx
movq 0x10(%rsp), %rcx
movsd 0x20(%rsp), %xmm0
callq 0x1ca9e4
testq %rax, %rax
je 0x74c81
movq (%r12), %rax
movq %rbp, %r14
jmp 0x74b2e
movq %rbp, %r13
jmp 0x74c24
movq 0x70(%rsp), %rax
movq $0x1, (%rax)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq