// File: chhylp123[P]hifiasm/hic.cpp
// Function: reset_inner_bub_het_poy(asg_t*, ma_ug_t*, bubble_type*, unsigned int, unsigned long, buf_t*, unsigned long, unsigned long, unsigned char*, ma_hit_t_alloc*, R_to_U*)
void reset_inner_bub_het_poy(asg_t* sg, ma_ug_t* ug, bubble_type* bub, uint32_t bid, uint64_t tLen, buf_t *b, 
uint64_t m_het_cov, uint64_t m_hom_cov, uint8_t *r_het_flag, ma_hit_t_alloc* sources, R_to_U* ruIndex)
{
    uint32_t beg, sink, *ba, bn, m, v, z, socc;
    get_bubbles(bub, bid, &beg, &sink, &ba, &bn, NULL);
    for (m = 0; m < bn; m++) {
        v = ba[m];
        if(IF_HOM((v>>1), *bub)) continue;
        if(ug->g->seq[v>>1].del) continue;
        if(bub->index[v>>1] == (uint32_t)-1) continue;

        if(get_unitig_het_fly(ug, v>>1, sg, m_het_cov, m_hom_cov, sources, ruIndex, r_het_flag, 20, 1, 0, (uint32_t)-1) == 1) {
            continue;
        }

        if(asg_arc_n(ug->g, v) < 2) continue;
        if(get_real_length(ug->g, v, NULL) < 2) continue;
        if(asg_bub_pop1_primary_trio(ug->g, NULL, v, tLen, b, (uint32_t)-1, (uint32_t)-1, 0, NULL, NULL, NULL, 0, 0, NULL)) {
            //beg is v, end is b.S.a[0]
            //note b.b include end, does not include beg
            for (z = socc = 0; z < b->b.n; z++) {
                if(b->b.a[z]==v || b->b.a[z]==b->S.a[0]) continue;
                socc += ug->u.a[b->b.a[z]>>1].n;
            }
            if((socc > 10) && (socc > (ug->u.a[v>>1].n*3))) {
                bub->index[v>>1] = (uint32_t)-1;
            }
        }

        
        v ^= 1;
        if(bub->index[v>>1] == (uint32_t)-1) continue;
        if(asg_arc_n(ug->g, v) < 2) continue;
        if(get_real_length(ug->g, v, NULL) < 2) continue;
        if(asg_bub_pop1_primary_trio(ug->g, NULL, v, tLen, b, (uint32_t)-1, (uint32_t)-1, 0, NULL, NULL, NULL, 0, 0, NULL)) {
            //beg is v, end is b.S.a[0]
            //note b.b include end, does not include beg
            for (z = socc = 0; z < b->b.n; z++) {
                if(b->b.a[z]==v || b->b.a[z]==b->S.a[0]) continue;
                socc += ug->u.a[b->b.a[z]>>1].n;
            }
            if((socc > 10) && (socc > (ug->u.a[v>>1].n*3))) {
                bub->index[v>>1] = (uint32_t)-1;
            }
        }
    }  
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq 0x30(%rbp), %rax
movq 0x28(%rbp), %rax
movq 0x20(%rbp), %rax
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movq -0x18(%rbp), %rdi
movl -0x1c(%rbp), %eax
movl %eax, %esi
leaq -0x34(%rbp), %rdx
leaq -0x38(%rbp), %rcx
leaq -0x40(%rbp), %r8
leaq -0x44(%rbp), %r9
xorl %eax, %eax
movq $0x0, (%rsp)
callq 0x1c4b20
movl $0x0, -0x48(%rbp)
movl -0x48(%rbp), %eax
cmpl -0x44(%rbp), %eax
jae 0x1c8c64
movq -0x40(%rbp), %rax
movl -0x48(%rbp), %ecx
movl (%rax,%rcx,4), %eax
movl %eax, -0x4c(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rax
movl -0x4c(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
movl (%rax,%rcx,4), %eax
movq -0x18(%rbp), %rcx
movq 0x80(%rcx), %rcx
addq $0x1, %rcx
cmpq %rcx, %rax
jbe 0x1c88c8
jmp 0x1c8c56
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x20(%rax), %rax
movl -0x4c(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
movl (%rax,%rcx,8), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
je 0x1c88eb
jmp 0x1c8c56
movq -0x18(%rbp), %rax
movq (%rax), %rax
movl -0x4c(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
cmpl $-0x1, (%rax,%rcx,4)
jne 0x1c8904
jmp 0x1c8c56
movq -0x10(%rbp), %rdi
movl -0x4c(%rbp), %esi
shrl %esi
movq -0x8(%rbp), %rdx
movq 0x10(%rbp), %rcx
movq 0x18(%rbp), %r8
movq 0x28(%rbp), %r9
movq 0x30(%rbp), %r10
movq 0x20(%rbp), %rax
xorl %r11d, %r11d
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
movl $0x14, 0x10(%rsp)
movl $0x1, 0x18(%rsp)
movl $0x0, 0x20(%rsp)
movl $0xffffffff, 0x28(%rsp) # imm = 0xFFFFFFFF
callq 0x1c6f90
cmpl $0x1, %eax
jne 0x1c8960
jmp 0x1c8c56
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x28(%rax), %rax
movl -0x4c(%rbp), %ecx
movq (%rax,%rcx,8), %rax
cmpl $0x2, %eax
jae 0x1c897d
jmp 0x1c8c56
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
movl -0x4c(%rbp), %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x166b50
cmpl $0x2, %eax
jge 0x1c899b
jmp 0x1c8c56
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
movl -0x4c(%rbp), %edx
movq -0x28(%rbp), %rcx
movq -0x30(%rbp), %r8
xorl %eax, %eax
movl %eax, %esi
movl $0xffffffff, %r9d       # imm = 0xFFFFFFFF
xorl %eax, %eax
movl $0xffffffff, (%rsp)     # imm = 0xFFFFFFFF
movl $0x0, 0x8(%rsp)
movq $0x0, 0x10(%rsp)
movq $0x0, 0x18(%rsp)
movq $0x0, 0x20(%rsp)
movl $0x0, 0x28(%rsp)
movl $0x0, 0x30(%rsp)
movq $0x0, 0x38(%rsp)
callq 0xfe040
cmpq $0x0, %rax
je 0x1c8ac9
movl $0x0, -0x54(%rbp)
movl $0x0, -0x50(%rbp)
movl -0x50(%rbp), %eax
movq -0x30(%rbp), %rcx
cmpq 0x38(%rcx), %rax
jae 0x1c8a8b
movq -0x30(%rbp), %rax
movq 0x48(%rax), %rax
movl -0x50(%rbp), %ecx
movl (%rax,%rcx,4), %eax
cmpl -0x4c(%rbp), %eax
je 0x1c8a54
movq -0x30(%rbp), %rax
movq 0x48(%rax), %rax
movl -0x50(%rbp), %ecx
movl (%rax,%rcx,4), %eax
movq -0x30(%rbp), %rcx
movq 0x18(%rcx), %rcx
cmpl (%rcx), %eax
jne 0x1c8a56
jmp 0x1c8a80
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x30(%rbp), %rcx
movq 0x48(%rcx), %rcx
movl -0x50(%rbp), %edx
movl (%rcx,%rdx,4), %ecx
shrl %ecx
movl %ecx, %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl 0x10(%rax), %eax
addl -0x54(%rbp), %eax
movl %eax, -0x54(%rbp)
movl -0x50(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x50(%rbp)
jmp 0x1c8a1a
cmpl $0xa, -0x54(%rbp)
jbe 0x1c8ac7
movl -0x54(%rbp), %eax
movq -0x10(%rbp), %rcx
movq 0x10(%rcx), %rcx
movl -0x4c(%rbp), %edx
shrl %edx
movl %edx, %edx
imulq $0x28, %rdx, %rdx
addq %rdx, %rcx
imull $0x3, 0x10(%rcx), %ecx
cmpl %ecx, %eax
jbe 0x1c8ac7
movq -0x18(%rbp), %rax
movq (%rax), %rax
movl -0x4c(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
movl $0xffffffff, (%rax,%rcx,4) # imm = 0xFFFFFFFF
jmp 0x1c8ac9
movl -0x4c(%rbp), %eax
xorl $0x1, %eax
movl %eax, -0x4c(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rax
movl -0x4c(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
cmpl $-0x1, (%rax,%rcx,4)
jne 0x1c8aeb
jmp 0x1c8c56
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x28(%rax), %rax
movl -0x4c(%rbp), %ecx
movq (%rax,%rcx,8), %rax
cmpl $0x2, %eax
jae 0x1c8b08
jmp 0x1c8c56
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
movl -0x4c(%rbp), %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x166b50
cmpl $0x2, %eax
jge 0x1c8b26
jmp 0x1c8c56
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
movl -0x4c(%rbp), %edx
movq -0x28(%rbp), %rcx
movq -0x30(%rbp), %r8
xorl %eax, %eax
movl %eax, %esi
movl $0xffffffff, %r9d       # imm = 0xFFFFFFFF
xorl %eax, %eax
movl $0xffffffff, (%rsp)     # imm = 0xFFFFFFFF
movl $0x0, 0x8(%rsp)
movq $0x0, 0x10(%rsp)
movq $0x0, 0x18(%rsp)
movq $0x0, 0x20(%rsp)
movl $0x0, 0x28(%rsp)
movl $0x0, 0x30(%rsp)
movq $0x0, 0x38(%rsp)
callq 0xfe040
cmpq $0x0, %rax
je 0x1c8c54
movl $0x0, -0x54(%rbp)
movl $0x0, -0x50(%rbp)
movl -0x50(%rbp), %eax
movq -0x30(%rbp), %rcx
cmpq 0x38(%rcx), %rax
jae 0x1c8c16
movq -0x30(%rbp), %rax
movq 0x48(%rax), %rax
movl -0x50(%rbp), %ecx
movl (%rax,%rcx,4), %eax
cmpl -0x4c(%rbp), %eax
je 0x1c8bdf
movq -0x30(%rbp), %rax
movq 0x48(%rax), %rax
movl -0x50(%rbp), %ecx
movl (%rax,%rcx,4), %eax
movq -0x30(%rbp), %rcx
movq 0x18(%rcx), %rcx
cmpl (%rcx), %eax
jne 0x1c8be1
jmp 0x1c8c0b
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x30(%rbp), %rcx
movq 0x48(%rcx), %rcx
movl -0x50(%rbp), %edx
movl (%rcx,%rdx,4), %ecx
shrl %ecx
movl %ecx, %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl 0x10(%rax), %eax
addl -0x54(%rbp), %eax
movl %eax, -0x54(%rbp)
movl -0x50(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x50(%rbp)
jmp 0x1c8ba5
cmpl $0xa, -0x54(%rbp)
jbe 0x1c8c52
movl -0x54(%rbp), %eax
movq -0x10(%rbp), %rcx
movq 0x10(%rcx), %rcx
movl -0x4c(%rbp), %edx
shrl %edx
movl %edx, %edx
imulq $0x28, %rdx, %rdx
addq %rdx, %rcx
imull $0x3, 0x10(%rcx), %ecx
cmpl %ecx, %eax
jbe 0x1c8c52
movq -0x18(%rbp), %rax
movq (%rax), %rax
movl -0x4c(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
movl $0xffffffff, (%rax,%rcx,4) # imm = 0xFFFFFFFF
jmp 0x1c8c54
jmp 0x1c8c56
movl -0x48(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x48(%rbp)
jmp 0x1c8885
addq $0xa0, %rsp
popq %rbp
retq
nopl (%rax)