// File: /workspace/github_cpp_makefile_star2_O3/chhylp123[P]hifiasm/hic.cpp
// Function: determine_bub_idx(bubble_type*, ma_utg_t*, asg_t*, unsigned long, unsigned long, unsigned long, int, int, unsigned int)
void determine_bub_idx(bubble_type* bub, ma_utg_t *bu, asg_t *untig_sg, uint64_t pLen, 
uint64_t rLEN, uint64_t r_hetLen, int beg_idx, int end_idx, uint32_t check_het)
{
    if(beg_idx > end_idx) return;

    uint64_t r_homLen = rLEN - r_hetLen;
    ///pLen: total length, rLEN: beg/sink length
    if(pLen > 0 && rLEN > 0 && r_hetLen > 0 && rLEN < pLen*0.5 && r_hetLen < rLEN * 0.2) ///set het to hom
    {
        set_bub_idx(bub, bu, untig_sg, beg_idx, end_idx, 1, bub->check_het);
    }
    else if(pLen > 0 && rLEN > 0 && r_homLen > 0 && rLEN > pLen*0.9 && r_homLen < rLEN * 0.1) ///set hom to het
    {
        set_bub_idx(bub, bu, untig_sg, beg_idx, end_idx, 0, bub->check_het);
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdi, 0x8(%rsp)
movl 0x78(%rsp), %edi
movl 0x70(%rsp), %eax
cmpl %edi, %eax
jg 0x14b49d
movq %rdi, %rbx
testq %rcx, %rcx
setne %dil
testq %r8, %r8
setne %r10b
andb %dil, %r10b
xorb $0x1, %r10b
testq %r9, %r9
sete %dil
orb %r10b, %dil
jne 0x14b335
movq %r8, %xmm1
movq 0xe60ea(%rip), %xmm2    # 0x231280
punpckldq %xmm2, %xmm1    # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
movapd 0xe60ee(%rip), %xmm3    # 0x231290
subpd %xmm3, %xmm1
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
movq %rcx, %xmm1
punpckldq %xmm2, %xmm1    # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
subpd %xmm3, %xmm1
movapd %xmm1, %xmm2
unpckhpd %xmm1, %xmm2            # xmm2 = xmm2[1],xmm1[1]
addsd %xmm1, %xmm2
mulsd 0xe641d(%rip), %xmm2    # 0x2315f0
ucomisd %xmm0, %xmm2
jbe 0x14b335
movq %r9, %xmm1
punpckldq 0xe6096(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0xe609e(%rip), %xmm1    # 0x231290
movapd %xmm1, %xmm2
unpckhpd %xmm1, %xmm2            # xmm2 = xmm2[1],xmm1[1]
addsd %xmm1, %xmm2
mulsd 0xe637a(%rip), %xmm0    # 0x231580
ucomisd %xmm2, %xmm0
jbe 0x14b335
movq %rdx, 0x10(%rsp)
movabsq $0x100000000, %rdi      # imm = 0x100000000
movq 0x8(%rsp), %rcx
movl 0xb0(%rcx), %edx
movl %edx, 0x4(%rsp)
movslq %eax, %r12
movq (%rcx), %r10
movq 0x28(%rcx), %r8
movq 0x40(%rcx), %rbp
movq 0x80(%rcx), %r14
incq %r14
subl %eax, %ebx
shlq $0x3, %r12
addq 0x18(%rsi), %r12
incl %ebx
movq %rbx, %r15
xorl %ebx, %ebx
movq %r15, 0x20(%rsp)
movq %r14, 0x18(%rsp)
movq (%r12,%rbx,8), %rax
movq %rax, %rcx
andq %rdi, %rcx
shrq $0x21, %rax
movl (%rbp,%rax,4), %eax
cmpq $0x1, %rcx
adcl $0x0, %eax
movl (%r8,%rax,4), %r13d
shrl %r13d
movl (%r10,%r13,4), %eax
cmpq %rax, %r14
jb 0x14b324
movq 0x8(%rsp), %rdi
movl %r13d, %esi
leaq 0x30(%rsp), %rdx
leaq 0x28(%rsp), %rcx
movq %r8, %r14
movl 0x4(%rsp), %r8d
movq %r10, %r15
callq 0x14ac07
movq %r15, %r10
movq 0x20(%rsp), %r15
movq %r14, %r8
movq 0x18(%rsp), %r14
movabsq $0x100000000, %rdi      # imm = 0x100000000
movq 0x30(%rsp), %rax
cmpq $-0x1, %rax
sete %dl
movq 0x28(%rsp), %rcx
cmpq $-0x1, %rcx
sete %sil
orb %dl, %sil
jne 0x14b324
movq 0x8(%rsp), %rdx
movq 0x58(%rdx), %rdx
movq (%rdx,%rcx,8), %rcx
movq (%rdx,%rax,8), %rax
movq 0x10(%rsp), %rdx
movq 0x20(%rdx), %rdx
movl (%rdx,%r13,8), %edx
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
cmpq %rcx, %rax
cmovbq %rax, %rcx
leaq (%rcx,%rcx,2), %rax
cmpq %rdx, %rax
jb 0x14b324
movl $0xffffffff, (%r10,%r13,4) # imm = 0xFFFFFFFF
incq %rbx
cmpl %ebx, %r15d
jne 0x14b261
jmp 0x14b49d
cmpq %r9, %r8
sete %dil
orb %dil, %r10b
jne 0x14b49d
movq %r8, %xmm1
movq 0xe5f2e(%rip), %xmm2    # 0x231280
punpckldq %xmm2, %xmm1    # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
movapd 0xe5f32(%rip), %xmm3    # 0x231290
subpd %xmm3, %xmm1
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
movq %rcx, %xmm1
punpckldq %xmm2, %xmm1    # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
subpd %xmm3, %xmm1
movapd %xmm1, %xmm2
unpckhpd %xmm1, %xmm2            # xmm2 = xmm2[1],xmm1[1]
addsd %xmm1, %xmm2
mulsd 0xe6269(%rip), %xmm2    # 0x2315f8
ucomisd %xmm2, %xmm0
jbe 0x14b49d
subq %r9, %r8
movq %r8, %xmm1
punpckldq 0xe5ed7(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0xe5edf(%rip), %xmm1    # 0x231290
movapd %xmm1, %xmm2
unpckhpd %xmm1, %xmm2            # xmm2 = xmm2[1],xmm1[1]
addsd %xmm1, %xmm2
mulsd 0xe584b(%rip), %xmm0    # 0x230c10
ucomisd %xmm2, %xmm0
jbe 0x14b49d
movabsq $0x100000000, %rdx      # imm = 0x100000000
movq 0x8(%rsp), %rcx
movl 0xb0(%rcx), %edi
movl %edi, 0x4(%rsp)
movslq %eax, %r13
movq (%rcx), %r15
movq 0x28(%rcx), %rdi
movq 0x40(%rcx), %r14
movq 0x80(%rcx), %rcx
leaq 0x1(%rcx), %r11
incl %ecx
movq %rcx, 0x10(%rsp)
subl %eax, %ebx
shlq $0x3, %r13
addq 0x18(%rsi), %r13
incl %ebx
movq %rbx, 0x20(%rsp)
xorl %ebp, %ebp
movq %rdi, 0x18(%rsp)
movq (%r13,%rbp,8), %rax
movq %rax, %rcx
andq %rdx, %rcx
shrq $0x21, %rax
movl (%r14,%rax,4), %eax
cmpq $0x1, %rcx
adcl $0x0, %eax
movl (%rdi,%rax,4), %r12d
shrl %r12d
movl (%r15,%r12,4), %eax
cmpq %rax, %r11
je 0x14b494
movq 0x8(%rsp), %rdi
movl %r12d, %esi
leaq 0x30(%rsp), %rdx
leaq 0x28(%rsp), %rcx
movl 0x4(%rsp), %r8d
movq %r11, %rbx
callq 0x14ac07
movq %rbx, %r11
movq 0x18(%rsp), %rdi
movabsq $0x100000000, %rdx      # imm = 0x100000000
cmpq $-0x1, 0x30(%rsp)
je 0x14b494
cmpq $-0x1, 0x28(%rsp)
je 0x14b494
movq 0x10(%rsp), %rax
movl %eax, (%r15,%r12,4)
incq %rbp
cmpl %ebp, 0x20(%rsp)
jne 0x14b420
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq