// File: /workspace/github_cpp_makefile_star2_O3/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 0x206df8
movq %rcx, %rdi
movq %rdx, %r9
movl %esi, %r14d
movl %esi, %eax
movq %rax, 0x20(%rsp)
movl $0x24, %r12d
xorl %r11d, %r11d
movl %esi, 0xc(%rsp)
movq %rcx, 0x10(%rsp)
movq %r11, 0x18(%rsp)
movq 0x30(%rdi), %rbx
movq (%r9), %r15
movl -0x24(%r15,%r12), %ebp
cmpl $-0x1, (%rbx,%rbp,4)
je 0x206e07
movq %r9, %r13
movq 0x18(%rdi), %rax
xorl %edx, %edx
cmpq %rbp, %rax
seta %dl
movl %eax, %ecx
movl $0x0, %r9d
cmoval %r9d, %ecx
movl %ebp, %esi
subl %ecx, %esi
xorl %r8d, %r8d
cmpq 0x20(%rsp), %rax
cmoval %r9d, %eax
seta %r8b
movl %r14d, %ecx
subl %eax, %ecx
callq 0x2064dd
testq %rax, %rax
je 0x206c81
cmpl %r14d, %ebp
movq 0x10(%rsp), %rdi
movq %r13, %r9
movq 0x18(%rsp), %r11
jb 0x206de7
movl -0x1c(%r15,%r12), %esi
subl -0x20(%r15,%r12), %esi
movl 0xc(%rax), %edx
movl 0x10(%rax), %ecx
movl %ecx, %r8d
subl %edx, %r8d
cmpl %r8d, %esi
jae 0x206d88
movl %edx, -0x20(%r15,%r12)
movl %ecx, -0x1c(%r15,%r12)
movsd 0x1c(%rax), %xmm0
movsd 0x4(%rax), %xmm1
movlhps %xmm0, %xmm1            # xmm1 = xmm1[0],xmm0[0]
movups %xmm1, -0x18(%r15,%r12)
movq 0x14(%rax), %rcx
movq %rcx, -0x8(%r15,%r12)
movb 0x24(%rax), %cl
andb $0x3f, %cl
movb (%r15,%r12), %dl
andb $-0x40, %dl
orb %cl, %dl
movb %dl, (%r15,%r12)
movb 0x24(%rax), %cl
andb $0x40, %cl
movq (%r9), %rdx
movb (%rdx,%r12), %sil
andb $-0x41, %sil
orb %cl, %sil
movb %sil, (%rdx,%r12)
movb 0x24(%rax), %al
andb $-0x80, %al
movq (%r9), %rcx
movb (%rcx,%r12), %dl
andb $0x7f, %dl
orb %al, %dl
movb %dl, (%rcx,%r12)
jmp 0x206de7
movl (%rbx,%rbp,4), %eax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmpq %rcx, %rax
movq 0x10(%rsp), %rdi
je 0x206e26
movq (%rdi), %rbp
testq %rbp, %rbp
je 0x206e26
shlq $0x5, %rax
addq %rax, %rbp
movq (%rbp), %rax
movq 0x8(%rbp), %rcx
cmpq 0x10(%rbp), %rcx
jne 0x206cf2
leaq (%rcx,%rcx), %rdx
testq %rcx, %rcx
movl $0x2, %ecx
cmoveq %rcx, %rdx
movq %rdx, 0x10(%rbp)
shlq $0x3, %rdx
leaq (%rdx,%rdx,4), %rsi
movq %rax, %rdi
callq 0x2370
movq 0x10(%rsp), %rdi
movq %rax, (%rbp)
movq 0x8(%rbp), %rcx
movq %r13, %r9
movq (%r13), %r15
jmp 0x206cf5
movq %r13, %r9
movl 0xc(%rsp), %r14d
movq 0x18(%rsp), %r11
leaq 0x1(%rcx), %rdx
movq %rdx, 0x8(%rbp)
leaq (%rcx,%rcx,4), %rcx
movl %r14d, (%rax,%rcx,8)
movq -0x18(%r15,%r12), %rdx
movq %rdx, 0x4(%rax,%rcx,8)
movsd -0x8(%r15,%r12), %xmm0
movsd -0x20(%r15,%r12), %xmm1
movlhps %xmm0, %xmm1            # xmm1 = xmm1[0],xmm0[0]
movups %xmm1, 0xc(%rax,%rcx,8)
movq -0x10(%r15,%r12), %rdx
movq %rdx, 0x1c(%rax,%rcx,8)
movb (%r15,%r12), %dl
andb $0x3f, %dl
movb 0x24(%rax,%rcx,8), %sil
andb $-0x40, %sil
orb %dl, %sil
movb %sil, 0x24(%rax,%rcx,8)
movq (%r9), %r8
movb (%r8,%r12), %r8b
andb $0x40, %r8b
andb $-0x41, %sil
orb %r8b, %sil
movb %sil, 0x24(%rax,%rcx,8)
movq (%r9), %rsi
movb (%rsi,%r12), %sil
andb $-0x80, %sil
orb %dl, %sil
orb %r8b, %sil
movb %sil, 0x24(%rax,%rcx,8)
testb %r8b, %r8b
jne 0x206de7
incl 0x1c(%rbp)
jmp 0x206de7
movq -0x18(%r15,%r12), %rcx
movq %rcx, 0x4(%rax)
movsd -0x8(%r15,%r12), %xmm0
movsd -0x20(%r15,%r12), %xmm1
movlhps %xmm0, %xmm1            # xmm1 = xmm1[0],xmm0[0]
movups %xmm1, 0xc(%rax)
movq -0x10(%r15,%r12), %rcx
movq %rcx, 0x1c(%rax)
movb (%r15,%r12), %cl
andb $0x3f, %cl
movb 0x24(%rax), %dl
andb $-0x40, %dl
orb %cl, %dl
movb %dl, 0x24(%rax)
movq (%r9), %rsi
movb (%rsi,%r12), %sil
andb $0x40, %sil
andb $-0x41, %dl
orb %sil, %dl
movb %dl, 0x24(%rax)
movq (%r9), %rdx
movb (%rdx,%r12), %dl
andb $-0x80, %dl
orb %cl, %dl
orb %sil, %dl
movb %dl, 0x24(%rax)
incq %r11
addq $0x28, %r12
cmpq 0x8(%r9), %r11
jb 0x206b84
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x407e4(%rip), %rdi     # 0x2475f2
leaq 0x3e7f4(%rip), %rsi     # 0x245609
leaq 0x40801(%rip), %rcx     # 0x24761d
movl $0x1a2d, %edx           # imm = 0x1A2D
callq 0x2110
leaq 0x2f143(%rip), %rdi     # 0x235f70
leaq 0x3e7d5(%rip), %rsi     # 0x245609
leaq 0x407e2(%rip), %rcx     # 0x24761d
movl $0x1a3f, %edx           # imm = 0x1A3F
callq 0x2110