// File: /workspace/github_cpp_makefile_star2_O1/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 $0x48, %rsp
movl %r8d, 0x34(%rsp)
movl %esi, 0x24(%rsp)
movl 0x18(%rdx), %eax
testl %eax, %eax
js 0x1fc25e
cmpl 0x24(%rsp), %eax
jne 0x1fc2ca
movq %rdx, %r15
cmpl $0x0, 0x1c(%rdx)
je 0x1fc25e
movq %rcx, %r11
movq %rdi, %r10
movl 0x24(%rsp), %r9d
imulq $0x58, %r9, %rax
movq %rax, 0x40(%rsp)
movq %r9, %rax
shlq $0x5, %rax
movq %rax, 0x38(%rsp)
xorl %ebx, %ebx
xorl %ebp, %ebp
movq %rcx, 0x28(%rsp)
movq (%r15), %r12
cmpb $0x3f, 0x24(%r12,%rbx)
ja 0x1fc24a
leaq (%r12,%rbx), %rdi
movl (%rdi), %eax
movq 0x30(%r11), %rcx
movl (%rcx,%rax,4), %ecx
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
cmpq %rdx, %rcx
je 0x1fc02b
shlq $0x5, %rcx
addq (%r11), %rcx
jmp 0x1fc02d
xorl %ecx, %ecx
testq %rcx, %rcx
je 0x1fc26d
cmpl $0x0, 0x18(%rcx)
js 0x1fc24a
movq 0x208(%r10), %rsi
movq %r9, %rcx
subq %rsi, %rcx
jae 0x1fc062
movq 0x30(%r10), %rcx
movq 0x48(%rcx), %rcx
movq 0x40(%rsp), %rdx
movl 0x18(%rcx,%rdx), %edx
jmp 0x1fc078
movq 0x18(%r10), %rdx
movq 0x10(%rdx), %rdx
leaq (%rcx,%rcx,4), %rcx
movl (%rdx,%rcx,8), %edx
movl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
andl %ecx, %edx
movq %rax, %rcx
subq %rsi, %rcx
jae 0x1fc093
movq 0x30(%r10), %rcx
movq 0x48(%rcx), %rcx
imulq $0x58, %rax, %r8
movl 0x18(%rcx,%r8), %r11d
jmp 0x1fc0ab
movq 0x18(%r10), %r8
movq 0x10(%r8), %r8
leaq (%rcx,%rcx,4), %rcx
movl (%r8,%rcx,8), %r11d
movl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
andl %ecx, %r11d
movl $0x1, %r8d
movl $0x1, %ecx
cmpq %rsi, %r9
jae 0x1fc0d2
movq 0x1d0(%r10), %rcx
movq 0x38(%rsp), %r14
movl 0x18(%rcx,%r14), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
cmpq %rsi, %rax
jae 0x1fc0f1
movq 0x1d0(%r10), %rsi
movq %rax, %r8
shlq $0x5, %r8
movl 0x18(%rsi,%r8), %r8d
andl $0x7fffffff, %r8d       # imm = 0x7FFFFFFF
movq %r10, %r13
movl %edx, %esi
movl %r11d, %edx
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rsp)
movq %rax, (%rsp)
movq %r9, %r14
callq 0x1fbca4
cmpl $-0x3, %eax
je 0x1fc1af
cmpl $-0x2, %eax
movq %r13, %r10
movq %r14, %r9
movq 0x28(%rsp), %r11
jne 0x1fc24a
orb $-0x80, 0x24(%r12,%rbx)
movq (%r15), %rax
movl (%rax,%rbx), %esi
movq 0x18(%r11), %rax
xorl %edx, %edx
cmpq %rsi, %rax
movl %eax, %ecx
movl $0x0, %edi
cmoval %edi, %ecx
seta %dl
subl %ecx, %esi
xorl %r8d, %r8d
cmpq %r9, %rax
cmoval %edi, %eax
seta %r8b
movl 0x24(%rsp), %ecx
subl %eax, %ecx
movq %r11, %rdi
callq 0x1faeda
testq %rax, %rax
je 0x1fc28c
movb 0x24(%rax), %cl
cmpb $0x40, %cl
jae 0x1fc28c
orb $-0x80, %cl
movb %cl, 0x24(%rax)
movq %r14, %rsi
cmpl $0x0, 0x34(%rsp)
movq 0x28(%rsp), %r11
je 0x1fc232
movq %r14, %r9
movq %r13, %r10
movq %r14, %rsi
cmpq %r14, 0x18(%r11)
ja 0x1fc232
jmp 0x1fc24a
orb $-0x80, 0x24(%r12,%rbx)
movq (%r15), %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 %r14, %rax
cmoval %r9d, %eax
seta %r8b
movl 0x24(%rsp), %ecx
subl %eax, %ecx
callq 0x1faeda
testq %rax, %rax
je 0x1fc2ab
movb 0x24(%rax), %cl
cmpb $0x40, %cl
jae 0x1fc2ab
orb $-0x80, %cl
movb %cl, 0x24(%rax)
cmpl $0x0, 0x34(%rsp)
movq 0x28(%rsp), %r11
je 0x1fc22c
movq %r13, %r10
movq %r14, %r9
movq (%r15), %rax
movl (%rax,%rbx), %eax
cmpq %rax, 0x18(%r11)
jbe 0x1fc24a
movq (%r15), %rax
movl (%rax,%rbx), %esi
movl $0x1, %edx
movq %r11, %rdi
callq 0x1fbee1
movq 0x28(%rsp), %r11
movq %r14, %r9
movq %r13, %r10
incq %rbp
movl 0x1c(%r15), %eax
addq $0x28, %rbx
cmpq %rax, %rbp
jb 0x1fbffc
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2db0c(%rip), %rdi     # 0x229d80
leaq 0x3d0aa(%rip), %rsi     # 0x239325
leaq 0x3f16e(%rip), %rcx     # 0x23b3f0
movl $0x1b07, %edx           # imm = 0x1B07
callq 0x2110
leaq 0x3f1bf(%rip), %rdi     # 0x23b452
leaq 0x3d08b(%rip), %rsi     # 0x239325
leaq 0x3f14f(%rip), %rcx     # 0x23b3f0
movl $0x1b0f, %edx           # imm = 0x1B0F
callq 0x2110
leaq 0x3f1a0(%rip), %rdi     # 0x23b452
leaq 0x3d06c(%rip), %rsi     # 0x239325
leaq 0x3f130(%rip), %rcx     # 0x23b3f0
movl $0x1b14, %edx           # imm = 0x1B14
callq 0x2110
leaq 0x3f112(%rip), %rdi     # 0x23b3e3
leaq 0x3d04d(%rip), %rsi     # 0x239325
leaq 0x3f111(%rip), %rcx     # 0x23b3f0
movl $0x1b03, %edx           # imm = 0x1B03
callq 0x2110