// File: /workspace/github_cpp_makefile_star2_O2/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 $0x38, %rsp
movq %r9, 0x10(%rsp)
movsd %xmm0, 0x28(%rsp)
movq 0x80(%rsp), %rax
andq $0x0, (%rax)
movq %rcx, 0x30(%rsp)
cmpq %rcx, %rdx
jae 0x42a9f
movq %r8, %r14
movq %rdx, %r13
movq %rsi, %r12
movq 0x78(%rsp), %rbp
movq 0x70(%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, 0x20(%rsp)
movl (%rcx,%rax,8), %ecx
andq %rdx, %rcx
movq %rcx, 0x18(%rsp)
imulq $0x1c, %r13, %rcx
addq $0xc, %rcx
movq 0x30(%rsp), %rsi
cmpq %rsi, %r13
jae 0x4287b
movq (%r12), %rdx
cmpl %eax, (%rdx,%rcx)
jae 0x4287e
incq %r13
addq $0x1c, %rcx
jmp 0x42864
movq %rsi, %r13
movq %r14, 0x8(%rsp)
cmpq %rsi, %r13
jae 0x42a9f
movq (%r12), %rsi
imulq $0x1c, %r13, %r15
movl 0xc(%rsi,%r15), %eax
cmpl 0xc(%r14), %eax
jne 0x42a9f
addq %r15, %rsi
movq %r14, %rdi
movq 0x20(%rsp), %rdx
movq 0x18(%rsp), %rcx
movsd 0x28(%rsp), %xmm0
callq 0x17eb54
testq %rax, %rax
je 0x42a32
leaq 0x1(%r13), %r14
movq (%r12), %rax
cmpq 0x8(%r12), %r14
jae 0x4294a
imulq $0x1c, %r14, %rsi
movl (%rax,%rsi), %edx
cmpl (%rax,%r15), %edx
jne 0x4294a
addq %rax, %rsi
addq %rax, %r15
movl 0xc(%rsi), %ecx
cmpl 0xc(%r15), %ecx
jne 0x4294a
movl 0x18(%rsi), %ecx
movl 0x18(%r15), %edi
movl %edi, %r8d
xorl %ecx, %r8d
js 0x4294a
movl $0x3fffffff, %r8d       # imm = 0x3FFFFFFF
andq %r8, %rcx
andq %r8, %rdi
leal 0x1(%rdi), %r8d
cmpl %r8d, %ecx
jne 0x4294a
movq 0x10(%rsp), %r8
movq (%r8), %r8
imulq $0x18, %rdx, %rdx
movq 0x8(%r8,%rdx), %r9
cmpq %rdi, %r9
jbe 0x4294a
cmpq %rcx, %r9
jbe 0x4294a
addq %rdx, %r8
movq (%r8), %rdx
shlq $0x5, %rdi
movb 0x1c(%rdx,%rdi), %dil
testb $0x20, %dil
jne 0x42a3f
movq %r13, %r15
imulq $0x1c, %r15, %r14
movl (%rax,%r14), %edx
movl 0x18(%rax,%r14), %eax
andl $0x3fffffff, %eax       # imm = 0x3FFFFFFF
movq 0x10(%rsp), %rcx
movq (%rcx), %rcx
imulq $0x18, %rdx, %rdx
cmpq %rax, 0x8(%rcx,%rdx)
jbe 0x42a21
addq %rdx, %rcx
movq (%rcx), %rcx
shlq $0x5, %rax
testb $0x20, 0x1c(%rcx,%rax)
jne 0x42a21
addq %rax, %rcx
cmpl $-0x1, 0x8(%rcx)
jne 0x42a21
jmp 0x42a90
movq (%rbx), %rax
movq 0x8(%rbx), %rcx
cmpq 0x10(%rbx), %rcx
jne 0x429cf
leaq (%rcx,%rcx), %rdx
testq %rcx, %rcx
pushq $0x2
popq %rcx
cmoveq %rcx, %rdx
movq %rdx, 0x10(%rbx)
imulq $0x1c, %rdx, %rsi
movq %rax, %rdi
callq 0x2370
movq %rax, (%rbx)
movq 0x8(%rbx), %rcx
imulq $0x1c, %rcx, %rdx
incq %rcx
movq %rcx, 0x8(%rbx)
movq (%r12), %rcx
movups (%rcx,%r14), %xmm0
movups 0xc(%rcx,%r14), %xmm1
movups %xmm1, 0xc(%rax,%rdx)
movups %xmm0, (%rax,%rdx)
testq %rbp, %rbp
je 0x42a1e
addq %rdx, %rax
movq (%r12), %rcx
movq 0xc(%rcx,%r14), %rdx
movq %rdx, (%rax)
movl 0x14(%rcx,%r14), %edx
movl %edx, 0x8(%rax)
movq (%rcx,%r14), %rdx
movq %rdx, 0xc(%rax)
movl 0x8(%rcx,%r14), %ecx
movl %ecx, 0x14(%rax)
incq %r13
cmpq %r15, %r13
jbe 0x4299d
movq %r15, %r13
movq 0x8(%rsp), %r14
incq %r13
movq 0x30(%rsp), %rsi
jmp 0x42883
testb $0x1f, %dil
jne 0x4294a
shlq $0x5, %rcx
movb 0x1c(%rdx,%rcx), %cl
andb $0x3f, %cl
movq %r13, %r15
cmpb $0x21, %cl
jne 0x4294d
movq 0x8(%rsp), %rdi
movq 0x20(%rsp), %rdx
movq 0x18(%rsp), %rcx
movsd 0x28(%rsp), %xmm0
callq 0x17eb54
testq %rax, %rax
je 0x42a8b
movq (%r12), %rax
movq %r14, %r15
jmp 0x4294d
movq %r14, %r13
jmp 0x42a2d
movq 0x80(%rsp), %rax
movq $0x1, (%rax)
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq