// File: /workspace/github_cpp_makefile_star2_O2/chhylp123[P]hifiasm/gfa_ut.cpp
// Function: integer_normalize_ovlp(ul_resolve_t*, unsigned int, ul2ul_item_t*, ul2ul_idx_t*)
void integer_normalize_ovlp(ul_resolve_t *uidx, uint32_t qid, ul2ul_item_t *o, ul2ul_idx_t *ul2)
{
    ul2ul_t *z; uint64_t k; ul2ul_item_t *t;
    for (k = 0; k < o->n; k++) {
        assert(ul2->item_idx[o->a[k].hid] != (uint32_t)-1);
        z = get_ul_o(ul2, ulg_id(*ul2, o->a[k].hid), ulg_type(*ul2, o->a[k].hid), 
                                                            ulg_id(*ul2, qid), ulg_type(*ul2, qid));
        // assert(z && z->hid == qid);
        // if(o->a[k].is_rev == z->is_rev && (*z).qs == o->a[k].ts && (*z).qe == o->a[k].te && 
        //     (*z).ts == o->a[k].qs && (*z).te == o->a[k].qe) {
        //     fprintf(stderr, "good::[M::%s] fn::%u(%c), fqs::%u, fqe::%u, fts::%u, fte::%u, rn::%u(%c), rqs::%u, rqe::%u, rts::%u, rte::%u\n", __func__, 
        //         o->a[k].hid, "+-"[o->a[k].is_rev], o->a[k].qs, o->a[k].qe, o->a[k].ts, o->a[k].te, 
        //         z->hid, "+-"[z->is_rev], z->qs, z->qe, z->ts, z->te);
        // } else {
        //     fprintf(stderr, "bad::[M::%s] fn::%u(%c), fqs::%u, fqe::%u, fts::%u, fte::%u, rn::%u(%c), rqs::%u, rqe::%u, rts::%u, rte::%u\n", __func__, 
        //         o->a[k].hid, "+-"[o->a[k].is_rev], o->a[k].qs, o->a[k].qe, o->a[k].ts, o->a[k].te, 
        //         z->hid, "+-"[z->is_rev], z->qs, z->qe, z->ts, z->te);
        // }
        // continue;
        if(z && o->a[k].hid < qid) continue;
        if(!z) {
            t = get_ul_ovlp(ul2, ulg_id(*ul2, o->a[k].hid), ulg_type(*ul2, o->a[k].hid));
            assert(t);
            kv_pushp(ul2ul_t, *t, &z); 
            (*z).hid = qid; 
            (*z).qs = o->a[k].ts; (*z).qe = o->a[k].te; 
            (*z).ts = o->a[k].qs; (*z).te = o->a[k].qe;
            (*z).qs_k = o->a[k].ts_k; (*z).qe_k = o->a[k].te_k; 
            (*z).ts_k = o->a[k].qs_k; (*z).te_k = o->a[k].qe_k;
            (*z).is_rev = o->a[k].is_rev; (*z).is_del = o->a[k].is_del;
            (*z).is_ct = o->a[k].is_ct;
            if(!((*z).is_del)) {
                t->cn++;
            }
        } else {
            if((o->a[k].qe - o->a[k].qs) >= (z->te - z->ts)) {
                (*z).qs = o->a[k].ts; (*z).qe = o->a[k].te;
                (*z).ts = o->a[k].qs; (*z).te = o->a[k].qe;
                (*z).qs_k = o->a[k].ts_k; (*z).qe_k = o->a[k].te_k; 
                (*z).ts_k = o->a[k].qs_k; (*z).te_k = o->a[k].qe_k;
                (*z).is_rev = o->a[k].is_rev; (*z).is_del = o->a[k].is_del;
                (*z).is_ct = o->a[k].is_ct;
            } else {
                o->a[k].qs = (*z).ts; o->a[k].qe = (*z).te;
                o->a[k].ts = (*z).qs; o->a[k].te = (*z).qe;
                o->a[k].qs_k = (*z).ts_k; o->a[k].qe_k = (*z).te_k;
                o->a[k].ts_k = (*z).qs_k; o->a[k].te_k = (*z).qe_k;
                o->a[k].is_rev = (*z).is_rev; o->a[k].is_del = (*z).is_del;
                o->a[k].is_ct = (*z).is_ct;
            }
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rcx, %rdi
movq %rdx, %r12
movl %esi, %r9d
movl %esi, %eax
movq %rax, 0x8(%rsp)
pushq $0x24
popq %r13
xorl %ecx, %ecx
movq %rdi, (%rsp)
cmpq 0x8(%r12), %rcx
jae 0x1bacc2
movq 0x30(%rdi), %rax
movq (%r12), %rbp
movl -0x24(%rbp,%r13), %r15d
cmpl $-0x1, (%rax,%r15,4)
je 0x1bacd1
movq %r12, %r14
movq %rcx, 0x10(%rsp)
movq 0x18(%rdi), %r12
xorl %eax, %eax
xorl %edx, %edx
movl $0x0, %r8d
cmpq %r15, %r12
seta %cl
ja 0x1baa8a
movl %r12d, %r8d
movl %r15d, %esi
subl %r8d, %esi
movb %cl, %dl
xorl %r8d, %r8d
cmpq 0x8(%rsp), %r12
cmovbel %r12d, %eax
seta %r8b
movl %r9d, %ecx
subl %eax, %ecx
movl %r9d, %ebx
callq 0x1ba44b
testq %rax, %rax
je 0x1bab59
cmpl %ebx, %r15d
movl %ebx, %r9d
movq (%rsp), %rdi
movq %r14, %r12
jb 0x1bacb1
movl -0x1c(%rbp,%r13), %esi
subl -0x20(%rbp,%r13), %esi
movl 0xc(%rax), %edx
movl 0x10(%rax), %ecx
movl %ecx, %r8d
subl %edx, %r8d
cmpl %r8d, %esi
jae 0x1bac4f
movl %edx, -0x20(%rbp,%r13)
movl %ecx, -0x1c(%rbp,%r13)
movsd 0x1c(%rax), %xmm0
movsd 0x4(%rax), %xmm1
movlhps %xmm0, %xmm1            # xmm1 = xmm1[0],xmm0[0]
movups %xmm1, -0x18(%rbp,%r13)
movq 0x14(%rax), %rcx
movq %rcx, -0x8(%rbp,%r13)
movb 0x24(%rax), %cl
andb $0x3f, %cl
movb (%rbp,%r13), %dl
andb $-0x40, %dl
orb %cl, %dl
movb %dl, (%rbp,%r13)
movb 0x24(%rax), %cl
andb $0x40, %cl
movq (%r12), %rdx
movb (%rdx,%r13), %sil
andb $-0x41, %sil
orb %cl, %sil
movb %sil, (%rdx,%r13)
movb 0x24(%rax), %al
andb $-0x80, %al
movq (%r12), %rcx
movb (%rcx,%r13), %dl
andb $0x7f, %dl
orb %al, %dl
movb %dl, (%rcx,%r13)
jmp 0x1bacb1
xorl %edx, %edx
cmpq %r15, %r12
seta %al
jbe 0x1bab66
xorl %r12d, %r12d
movq (%rsp), %rdi
subq %r12, %r15
movb %al, %dl
movq %r15, %rsi
callq 0x1ba426
testq %rax, %rax
je 0x1bacf0
movq %rax, %r15
movq (%rax), %rax
movq 0x8(%r15), %rcx
cmpq 0x10(%r15), %rcx
movq %r14, %r12
jne 0x1babbc
pushq $0x2
popq %rdx
testq %rcx, %rcx
je 0x1baba1
addq %rcx, %rcx
movq %rcx, %rdx
movq %rdx, 0x10(%r15)
imulq $0x28, %rdx, %rsi
movq %rax, %rdi
callq 0x2370
movq %rax, (%r15)
movq 0x8(%r15), %rcx
movq (%r12), %rbp
movl %ebx, %r9d
leaq 0x1(%rcx), %rdx
movq %rdx, 0x8(%r15)
imulq $0x28, %rcx, %rcx
movl %ebx, (%rax,%rcx)
movq -0x18(%rbp,%r13), %rdx
movq %rdx, 0x4(%rax,%rcx)
movsd -0x8(%rbp,%r13), %xmm0
movsd -0x20(%rbp,%r13), %xmm1
movlhps %xmm0, %xmm1            # xmm1 = xmm1[0],xmm0[0]
movups %xmm1, 0xc(%rax,%rcx)
movq -0x10(%rbp,%r13), %rdx
movq %rdx, 0x1c(%rax,%rcx)
movb (%rbp,%r13), %dl
andb $0x3f, %dl
movb 0x24(%rax,%rcx), %sil
andb $-0x40, %sil
orb %dl, %sil
movb %sil, 0x24(%rax,%rcx)
movq (%r12), %rdi
movb (%rdi,%r13), %dil
andb $0x40, %dil
andb $-0x41, %sil
orb %dil, %sil
movb %sil, 0x24(%rax,%rcx)
movq (%r12), %rsi
movb (%rsi,%r13), %sil
andb $-0x80, %sil
orb %dl, %sil
orb %dil, %sil
movb %sil, 0x24(%rax,%rcx)
testb %dil, %dil
movq (%rsp), %rdi
jne 0x1bacb1
incl 0x1c(%r15)
jmp 0x1bacb1
movq -0x18(%rbp,%r13), %rcx
movq %rcx, 0x4(%rax)
movsd -0x8(%rbp,%r13), %xmm0
movsd -0x20(%rbp,%r13), %xmm1
movlhps %xmm0, %xmm1            # xmm1 = xmm1[0],xmm0[0]
movups %xmm1, 0xc(%rax)
movq -0x10(%rbp,%r13), %rcx
movq %rcx, 0x1c(%rax)
movb (%rbp,%r13), %cl
andb $0x3f, %cl
movb 0x24(%rax), %dl
andb $-0x40, %dl
orb %cl, %dl
movb %dl, 0x24(%rax)
movq (%r12), %rsi
movb (%rsi,%r13), %sil
andb $0x40, %sil
andb $-0x41, %dl
orb %sil, %dl
movb %dl, 0x24(%rax)
movq (%r12), %rdx
movb (%rdx,%r13), %dl
andb $-0x80, %dl
orb %cl, %dl
orb %sil, %dl
movb %dl, 0x24(%rax)
movq 0x10(%rsp), %rcx
incq %rcx
addq $0x28, %r13
jmp 0x1baa46
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x3e8d9(%rip), %rdi     # 0x1f95b1
leaq 0x3c7fa(%rip), %rsi     # 0x1f74d9
leaq 0x3e8f6(%rip), %rcx     # 0x1f95dc
movl $0x1a2d, %edx           # imm = 0x1A2D
callq 0x2110
leaq 0x2d179(%rip), %rdi     # 0x1e7e70
leaq 0x3c7db(%rip), %rsi     # 0x1f74d9
leaq 0x3e8d7(%rip), %rcx     # 0x1f95dc
movl $0x1a3f, %edx           # imm = 0x1A3F
callq 0x2110