// File: /workspace/github_cpp_makefile_star2_O1/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 0x144e5b
movq %rdi, %r14
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 0x144cf1
movq %r8, %xmm1
movq 0xe06f5(%rip), %xmm2    # 0x225240
punpckldq %xmm2, %xmm1    # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
movapd 0xe06f9(%rip), %xmm3    # 0x225250
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 0xe0968(%rip), %xmm2    # 0x2254f0
ucomisd %xmm0, %xmm2
jbe 0x144cf1
movq %r9, %xmm1
punpckldq 0xe06a1(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0xe06a9(%rip), %xmm1    # 0x225250
movapd %xmm1, %xmm2
unpckhpd %xmm1, %xmm2            # xmm2 = xmm2[1],xmm1[1]
addsd %xmm1, %xmm2
mulsd 0xe08c5(%rip), %xmm0    # 0x225480
ucomisd %xmm2, %xmm0
jbe 0x144cf1
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 0x80(%rcx), %r11
incq %r11
movq 0x40(%rcx), %rbx
subl %eax, %r14d
shlq $0x3, %r12
addq 0x18(%rsi), %r12
incl %r14d
movq %r14, %r15
xorl %ebp, %ebp
movq %r14, 0x20(%rsp)
movq %rbx, 0x18(%rsp)
movq (%r12,%rbp,8), %rax
movq %rax, %rcx
andq %rdi, %rcx
shrq $0x21, %rax
movl (%rbx,%rax,4), %eax
cmpq $0x1, %rcx
adcl $0x0, %eax
movl (%r8,%rax,4), %r13d
shrl %r13d
movl (%r10,%r13,4), %eax
cmpq %rax, %r11
jb 0x144ce0
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
movq %r11, %rbx
callq 0x1445e7
movq %rbx, %r11
movq 0x18(%rsp), %rbx
movq %r15, %r10
movq 0x20(%rsp), %r15
movq %r14, %r8
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 0x144ce0
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 0x144ce0
movl $0xffffffff, (%r10,%r13,4) # imm = 0xFFFFFFFF
incq %rbp
cmpl %ebp, %r15d
jne 0x144c18
jmp 0x144e5b
cmpq %r9, %r8
sete %dil
orb %dil, %r10b
jne 0x144e5b
movq %r8, %xmm1
movq 0xe0532(%rip), %xmm2    # 0x225240
punpckldq %xmm2, %xmm1    # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
movapd 0xe0536(%rip), %xmm3    # 0x225250
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 0xe07ad(%rip), %xmm2    # 0x2254f8
ucomisd %xmm2, %xmm0
jbe 0x144e5b
subq %r9, %r8
movq %r8, %xmm1
punpckldq 0xe04db(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0xe04e3(%rip), %xmm1    # 0x225250
movapd %xmm1, %xmm2
unpckhpd %xmm1, %xmm2            # xmm2 = xmm2[1],xmm1[1]
addsd %xmm1, %xmm2
mulsd 0xdfe4f(%rip), %xmm0    # 0x224bd0
ucomisd %xmm2, %xmm0
jbe 0x144e5b
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 0x80(%rcx), %r10
leaq 0x1(%r10), %r11
incl %r10d
movq %r10, 0x10(%rsp)
movq 0x40(%rcx), %rbx
subl %eax, %r14d
shlq $0x3, %r13
addq 0x18(%rsi), %r13
incl %r14d
movq %r14, 0x20(%rsp)
xorl %ebp, %ebp
movq %rdi, 0x18(%rsp)
movq (%r13,%rbp,8), %rax
movq %rax, %rcx
andq %rdx, %rcx
shrq $0x21, %rax
movl (%rbx,%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 0x144e52
movq 0x8(%rsp), %rdi
movl %r12d, %esi
leaq 0x30(%rsp), %rdx
leaq 0x28(%rsp), %rcx
movl 0x4(%rsp), %r8d
movq %r11, %r14
callq 0x1445e7
movq %r14, %r11
movq 0x18(%rsp), %rdi
movabsq $0x100000000, %rdx      # imm = 0x100000000
cmpq $-0x1, 0x30(%rsp)
je 0x144e52
cmpq $-0x1, 0x28(%rsp)
je 0x144e52
movq 0x10(%rsp), %rax
movl %eax, (%r15,%r12,4)
incq %rbp
cmpl %ebp, 0x20(%rsp)
jne 0x144ddf
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq