// File: /workspace/github_cpp_makefile_star2_O2/chhylp123[P]hifiasm/gfa_ut.cpp
// Function: integer_containment_purge(ul_resolve_t*, unsigned int, ul2ul_item_t*, ul2ul_idx_t*, unsigned int)
void integer_containment_purge(ul_resolve_t *uidx, uint32_t qid, ul2ul_item_t *q, ul2ul_idx_t *ul2, uint32_t keep_raw_utg)
{
    if(q->is_del) return;
    uint64_t k; int32_t r; ul2ul_item_t *t; ul2ul_t *z; assert(qid == q->id);
    for (k = 0; k < q->cn; k++) {
        if(q->a[k].is_del || q->a[k].is_ct) continue;
        t = get_ul_ovlp(ul2, ulg_id(*ul2, q->a[k].hid), ulg_type(*ul2, q->a[k].hid));
        assert(t);
        if(t->is_del) continue;
        r = integer_hit2arc(&(q->a[k]), ulg_len(*uidx, qid), ulg_len(*uidx, q->a[k].hid), 
        ulg_occ(*uidx, qid), ulg_occ(*uidx, q->a[k].hid), qid, q->a[k].hid, 0, NULL);
        // assert(r != MA_HT_INT);
        if (r == MA_HT_QCONT) {
            q->a[k].is_ct = 1;
            z = get_ul_o(ul2, ulg_id(*ul2, q->a[k].hid), ulg_type(*ul2, q->a[k].hid), ulg_id(*ul2, qid), ulg_type(*ul2, qid));
            assert(z && (!z->is_del) && (!z->is_ct)); z->is_ct = 1;
            if((!keep_raw_utg) || ulg_type(*ul2, qid)) integer_node_del(ul2, qid, 1);
        } else if (r == MA_HT_TCONT) {
            q->a[k].is_ct = 1;
            z = get_ul_o(ul2, ulg_id(*ul2, q->a[k].hid), ulg_type(*ul2, q->a[k].hid), ulg_id(*ul2, qid), ulg_type(*ul2, qid));
            assert(z && (!z->is_del) && (!z->is_ct)); z->is_ct = 1;
            if((!keep_raw_utg) || ulg_type(*ul2, q->a[k].hid)) integer_node_del(ul2, q->a[k].hid, 1);
        }
    }

    // if(ulg_type(*ul2, k)) {
    //     for (k = 0; k < q->cn; k++) {
    //         if((!(q->a[k].is_del)) && (!(q->a[k].is_ct))) break;
    //     }
    //     if(k >= q->cn) q->is_del = 1;
    // }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movl %r8d, 0x3c(%rsp)
movq %rcx, 0x28(%rsp)
movl %esi, 0x24(%rsp)
movl 0x18(%rdx), %eax
testl %eax, %eax
js 0x1bb6a7
movl 0x24(%rsp), %ecx
cmpl %ecx, %eax
jne 0x1bb713
movl %ecx, %eax
imulq $0x58, %rax, %rcx
movq %rcx, 0x48(%rsp)
movq %rax, 0x18(%rsp)
shlq $0x5, %rax
movq %rax, 0x40(%rsp)
xorl %ebx, %ebx
xorl %r12d, %r12d
movq %rdx, 0x30(%rsp)
movq %rdi, 0x50(%rsp)
movl 0x1c(%rdx), %eax
cmpq %rax, %r12
jae 0x1bb6a7
movq (%rdx), %r13
movb 0x24(%r13,%rbx), %r14b
cmpb $0x3f, %r14b
ja 0x1bb69b
leaq (%rbx,%r13), %rbp
movl (%rbp), %r15d
movq 0x28(%rsp), %rdi
movq 0x18(%rdi), %rax
xorl %edx, %edx
cmpq %r15, %rax
movl $0x0, %ecx
cmovbeq %rax, %rcx
seta %dl
movq %r15, %rsi
subq %rcx, %rsi
callq 0x1ba426
testq %rax, %rax
je 0x1bb6b6
cmpl $0x0, 0x18(%rax)
movq 0x30(%rsp), %rdx
movq 0x50(%rsp), %rdi
js 0x1bb69b
movq 0x208(%rdi), %rdx
movq 0x18(%rsp), %rax
subq %rdx, %rax
jae 0x1bb4ad
movq 0x30(%rdi), %rax
movq 0x48(%rax), %rax
movq 0x48(%rsp), %rcx
movl 0x18(%rax,%rcx), %eax
jmp 0x1bb4c3
movq 0x18(%rdi), %rcx
movq 0x10(%rcx), %rcx
imulq $0x28, %rax, %rax
movl (%rcx,%rax), %eax
movl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
andl %ecx, %eax
movq %r15, %rcx
subq %rdx, %rcx
jae 0x1bb4de
movq 0x30(%rdi), %rcx
movq 0x48(%rcx), %rcx
imulq $0x58, %r15, %rsi
movl 0x18(%rcx,%rsi), %r9d
jmp 0x1bb4f6
movq 0x18(%rdi), %rsi
movq 0x10(%rsi), %rsi
imulq $0x28, %rcx, %rcx
movl (%rsi,%rcx), %r9d
movl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
andl %ecx, %r9d
pushq $0x1
popq %rcx
cmpq %rdx, 0x18(%rsp)
jae 0x1bb516
movq 0x1d0(%rdi), %rcx
movq 0x40(%rsp), %rsi
movl 0x18(%rcx,%rsi), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
pushq $0x1
popq %r8
cmpq %rdx, %r15
jae 0x1bb539
movq 0x1d0(%rdi), %rdx
movq %r15, %rsi
shlq $0x5, %rsi
movl 0x18(%rdx,%rsi), %r8d
andl $0x7fffffff, %r8d       # imm = 0x7FFFFFFF
movl %eax, %esi
movl %r9d, %edx
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rsp)
movq %r15, (%rsp)
movq %rbp, %rdi
movq 0x18(%rsp), %r9
callq 0x1bb0f9
cmpl $-0x3, %eax
je 0x1bb603
cmpl $-0x2, %eax
movq 0x30(%rsp), %rdx
jne 0x1bb69b
orb $-0x80, %r14b
movb %r14b, 0x24(%r13,%rbx)
movq (%rdx), %rax
movl (%rax,%rbx), %esi
movq 0x28(%rsp), %rdi
movq 0x18(%rdi), %rax
xorl %edx, %edx
cmpq %rsi, %rax
movl %eax, %ecx
movl $0x0, %r9d
cmoval %r9d, %ecx
seta %dl
subl %ecx, %esi
xorl %r8d, %r8d
cmpq 0x18(%rsp), %rax
cmoval %r9d, %eax
seta %r8b
movl 0x24(%rsp), %ecx
subl %eax, %ecx
callq 0x1ba44b
testq %rax, %rax
je 0x1bb6d5
movb 0x24(%rax), %cl
cmpb $0x40, %cl
jae 0x1bb6d5
orb $-0x80, %cl
movb %cl, 0x24(%rax)
movq 0x18(%rsp), %rsi
cmpl $0x0, 0x3c(%rsp)
movq 0x30(%rsp), %rdx
je 0x1bb689
movq 0x18(%rsp), %rcx
movq %rcx, %rsi
movq 0x28(%rsp), %rax
cmpq %rcx, 0x18(%rax)
ja 0x1bb689
jmp 0x1bb69b
orb $-0x80, %r14b
movb %r14b, 0x24(%r13,%rbx)
movq 0x30(%rsp), %rax
movq (%rax), %rax
movl (%rax,%rbx), %esi
movq 0x28(%rsp), %rdi
movq 0x18(%rdi), %rax
xorl %edx, %edx
cmpq %rsi, %rax
movl %eax, %ecx
movl $0x0, %r9d
cmoval %r9d, %ecx
seta %dl
subl %ecx, %esi
xorl %r8d, %r8d
cmpq 0x18(%rsp), %rax
cmoval %r9d, %eax
seta %r8b
movl 0x24(%rsp), %ecx
subl %eax, %ecx
callq 0x1ba44b
testq %rax, %rax
je 0x1bb6f4
movb 0x24(%rax), %cl
cmpb $0x40, %cl
jae 0x1bb6f4
orb $-0x80, %cl
movb %cl, 0x24(%rax)
movq 0x30(%rsp), %rdx
movq (%rdx), %rax
movl (%rax,%rbx), %esi
cmpl $0x0, 0x3c(%rsp)
je 0x1bb689
movq 0x28(%rsp), %rax
cmpq %rsi, 0x18(%rax)
jbe 0x1bb69b
movq 0x28(%rsp), %rdi
pushq $0x1
popq %rdx
callq 0x1bb30f
movq 0x30(%rsp), %rdx
incq %r12
addq $0x28, %rbx
jmp 0x1bb421
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2c7b3(%rip), %rdi     # 0x1e7e70
leaq 0x3be15(%rip), %rsi     # 0x1f74d9
leaq 0x3dfc8(%rip), %rcx     # 0x1f9693
movl $0x1b07, %edx           # imm = 0x1B07
callq 0x2110
leaq 0x3e019(%rip), %rdi     # 0x1f96f5
leaq 0x3bdf6(%rip), %rsi     # 0x1f74d9
leaq 0x3dfa9(%rip), %rcx     # 0x1f9693
movl $0x1b0f, %edx           # imm = 0x1B0F
callq 0x2110
leaq 0x3dffa(%rip), %rdi     # 0x1f96f5
leaq 0x3bdd7(%rip), %rsi     # 0x1f74d9
leaq 0x3df8a(%rip), %rcx     # 0x1f9693
movl $0x1b14, %edx           # imm = 0x1B14
callq 0x2110
leaq 0x3df6c(%rip), %rdi     # 0x1f9686
leaq 0x3bdb8(%rip), %rsi     # 0x1f74d9
leaq 0x3df6b(%rip), %rcx     # 0x1f9693
movl $0x1b03, %edx           # imm = 0x1B03
callq 0x2110