// File: /workspace/github_cpp_makefile_star2_O1/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 $0x28, %rsp
cmpq $0x0, 0x8(%rdx)
je 0x1fb846
movq %rcx, %rdi
movl %esi, %r13d
movl %esi, %eax
movq %rax, 0x20(%rsp)
movl $0x24, %r12d
xorl %eax, %eax
movq %rdx, 0x18(%rsp)
movl %esi, 0x4(%rsp)
movq %rcx, 0x10(%rsp)
movq 0x30(%rdi), %rbx
movq (%rdx), %r15
movl -0x24(%r15,%r12), %ebp
cmpl $-0x1, (%rbx,%rbp,4)
je 0x1fb855
movq %rax, 0x8(%rsp)
movq 0x18(%rdi), %r14
xorl %eax, %eax
xorl %edx, %edx
movl $0x0, %r8d
cmpq %rbp, %r14
seta %cl
ja 0x1fb584
movl %r14d, %r8d
movl %ebp, %esi
subl %r8d, %esi
movb %cl, %dl
xorl %r8d, %r8d
cmpq 0x20(%rsp), %r14
cmovbel %r14d, %eax
seta %r8b
movl %r13d, %ecx
subl %eax, %ecx
callq 0x1faeda
testq %rax, %rax
je 0x1fb669
cmpl %r13d, %ebp
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rdx
movq 0x8(%rsp), %rcx
jb 0x1fb832
movl -0x1c(%r15,%r12), %esi
subl -0x20(%r15,%r12), %esi
movl 0xc(%rax), %r9d
movl 0x10(%rax), %ecx
movl %ecx, %r8d
subl %r9d, %r8d
cmpl %r8d, %esi
jae 0x1fb7ac
movl %r9d, -0x20(%r15,%r12)
movl %ecx, -0x1c(%r15,%r12)
movl 0x4(%rax), %ecx
movl %ecx, -0x18(%r15,%r12)
movl 0x8(%rax), %ecx
movl %ecx, -0x14(%r15,%r12)
movl 0x1c(%rax), %ecx
movl %ecx, -0x10(%r15,%r12)
movl 0x20(%rax), %ecx
movl %ecx, -0xc(%r15,%r12)
movl 0x14(%rax), %ecx
movl %ecx, -0x8(%r15,%r12)
movl 0x18(%rax), %ecx
movl %ecx, -0x4(%r15,%r12)
movb 0x24(%rax), %cl
andb $0x3f, %cl
movb (%r15,%r12), %sil
andb $-0x40, %sil
orb %cl, %sil
movb %sil, (%r15,%r12)
movb 0x24(%rax), %cl
andb $0x40, %cl
movq (%rdx), %r8
movb (%r8,%r12), %sil
andb $-0x41, %sil
orb %cl, %sil
movb %sil, (%r8,%r12)
movb 0x24(%rax), %al
andb $-0x80, %al
movq (%rdx), %rcx
movb (%rcx,%r12), %sil
andb $0x7f, %sil
orb %al, %sil
movb %sil, (%rcx,%r12)
jmp 0x1fb82d
movl $0x0, %r15d
movl $0x0, %eax
cmpq %rbp, %r14
ja 0x1fb67c
movq %r14, %rax
subq %rax, %rbp
leaq (%rbx,%rbp,4), %rcx
movl (%rcx,%rax,4), %eax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmpq %rcx, %rax
movq 0x10(%rsp), %rdi
movl 0x4(%rsp), %r13d
je 0x1fb6a4
shlq $0x5, %rax
addq (%rdi), %rax
movq %rax, %r15
testq %r15, %r15
je 0x1fb874
movq 0x10(%r15), %rax
cmpq %rax, 0x8(%r15)
jne 0x1fb6e8
movl $0x2, %ecx
testq %rax, %rax
je 0x1fb6c7
addq %rax, %rax
movq %rax, %rcx
movq %rcx, 0x10(%r15)
movq (%r15), %rdi
shlq $0x3, %rcx
leaq (%rcx,%rcx,4), %rsi
callq 0x2370
movq %rax, (%r15)
movq 0x10(%rsp), %rdi
movl 0x4(%rsp), %r13d
movq (%r15), %rax
movq 0x8(%r15), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x8(%r15)
leaq (%rcx,%rcx,4), %rcx
movl %r13d, (%rax,%rcx,8)
movq 0x18(%rsp), %rdx
movq (%rdx), %r8
movl -0x18(%r8,%r12), %esi
movl %esi, 0x4(%rax,%rcx,8)
movl -0x14(%r8,%r12), %esi
movl %esi, 0x8(%rax,%rcx,8)
movl -0x20(%r8,%r12), %esi
movl %esi, 0xc(%rax,%rcx,8)
movl -0x1c(%r8,%r12), %esi
movl %esi, 0x10(%rax,%rcx,8)
movl -0x8(%r8,%r12), %esi
movl %esi, 0x14(%rax,%rcx,8)
movl -0x4(%r8,%r12), %esi
movl %esi, 0x18(%rax,%rcx,8)
movl -0x10(%r8,%r12), %esi
movl %esi, 0x1c(%rax,%rcx,8)
movl -0xc(%r8,%r12), %esi
movl %esi, 0x20(%rax,%rcx,8)
movb (%r8,%r12), %r9b
andb $0x3f, %r9b
movb 0x24(%rax,%rcx,8), %sil
andb $-0x40, %sil
orb %r9b, %sil
movb %sil, 0x24(%rax,%rcx,8)
movq (%rdx), %r8
movb (%r8,%r12), %r8b
andb $0x40, %r8b
andb $-0x41, %sil
orb %r8b, %sil
movb %sil, 0x24(%rax,%rcx,8)
movq (%rdx), %rsi
movb (%rsi,%r12), %sil
andb $-0x80, %sil
orb %r9b, %sil
orb %r8b, %sil
movb %sil, 0x24(%rax,%rcx,8)
testb %r8b, %r8b
movq 0x8(%rsp), %rcx
jne 0x1fb832
incl 0x1c(%r15)
jmp 0x1fb832
movl -0x18(%r15,%r12), %ecx
movl %ecx, 0x4(%rax)
movl -0x14(%r15,%r12), %ecx
movl %ecx, 0x8(%rax)
movl -0x20(%r15,%r12), %ecx
movl %ecx, 0xc(%rax)
movl -0x1c(%r15,%r12), %ecx
movl %ecx, 0x10(%rax)
movl -0x8(%r15,%r12), %ecx
movl %ecx, 0x14(%rax)
movl -0x4(%r15,%r12), %ecx
movl %ecx, 0x18(%rax)
movl -0x10(%r15,%r12), %ecx
movl %ecx, 0x1c(%rax)
movl -0xc(%r15,%r12), %ecx
movl %ecx, 0x20(%rax)
movb (%r15,%r12), %cl
andb $0x3f, %cl
movb 0x24(%rax), %r8b
andb $-0x40, %r8b
orb %cl, %r8b
movb %r8b, 0x24(%rax)
movq (%rdx), %rsi
movb (%rsi,%r12), %sil
andb $0x40, %sil
andb $-0x41, %r8b
orb %sil, %r8b
movb %r8b, 0x24(%rax)
movq (%rdx), %r8
movb (%r8,%r12), %r8b
andb $-0x80, %r8b
orb %cl, %r8b
orb %sil, %r8b
movb %r8b, 0x24(%rax)
movq 0x8(%rsp), %rcx
incq %rcx
addq $0x28, %r12
cmpq 0x8(%rdx), %rcx
movq %rcx, %rax
jb 0x1fb550
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x3fab2(%rip), %rdi     # 0x23b30e
leaq 0x3dac2(%rip), %rsi     # 0x239325
leaq 0x3facf(%rip), %rcx     # 0x23b339
movl $0x1a2d, %edx           # imm = 0x1A2D
callq 0x2110
leaq 0x2e505(%rip), %rdi     # 0x229d80
leaq 0x3daa3(%rip), %rsi     # 0x239325
leaq 0x3fab0(%rip), %rcx     # 0x23b339
movl $0x1a3f, %edx           # imm = 0x1A3F
callq 0x2110