// File: chhylp123[P]hifiasm/hic.cpp
// Function: is_hom_map(unsigned long, unsigned int, mc_interval_t*, unsigned int*, ha_ug_index*)
uint32_t is_hom_map(uint64_t x, uint32_t len, mc_interval_t *p, uint32_t *p_idx, ha_ug_index* idx)
{
    mc_interval_t *a = NULL;
    uint32_t uid, qs, qe, as, ae, occ, k;
    uint64_t oLen;
    interpr_hit(idx, x, len, &uid, &qs, &qe);

    a = p + p_idx[uid]; 
    occ = p_idx[uid+1] - p_idx[uid];
    for (k = 0; k < occ; k++)
    {
        as = a[k].bS;
        ae = a[k].bE;
        oLen = ((MIN(qe, ae) >= MAX(qs, as))? MIN(qe, ae) - MAX(qs, as) + 1 : 0);
        if(oLen == 0) continue;
        if(oLen > len*0.2) return 1;
    }
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
movq -0x30(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl -0x14(%rbp), %edx
leaq -0x3c(%rbp), %rcx
leaq -0x40(%rbp), %r8
leaq -0x44(%rbp), %r9
callq 0x201880
movq -0x20(%rbp), %rax
movq -0x28(%rbp), %rcx
movl -0x3c(%rbp), %edx
movl (%rcx,%rdx,4), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x38(%rbp)
movq -0x28(%rbp), %rax
movl -0x3c(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, %ecx
movl (%rax,%rcx,4), %eax
movq -0x28(%rbp), %rcx
movl -0x3c(%rbp), %edx
subl (%rcx,%rdx,4), %eax
movl %eax, -0x50(%rbp)
movl $0x0, -0x54(%rbp)
movl -0x54(%rbp), %eax
cmpl -0x50(%rbp), %eax
jae 0x204ac2
movq -0x38(%rbp), %rax
movl -0x54(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %eax
movl %eax, -0x48(%rbp)
movq -0x38(%rbp), %rax
movl -0x54(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
movl %eax, -0x4c(%rbp)
movl -0x44(%rbp), %eax
cmpl -0x4c(%rbp), %eax
ja 0x2049e1
movl -0x44(%rbp), %eax
movl %eax, -0x64(%rbp)
jmp 0x2049e7
movl -0x4c(%rbp), %eax
movl %eax, -0x64(%rbp)
movl -0x64(%rbp), %eax
movl %eax, -0x68(%rbp)
movl -0x40(%rbp), %eax
cmpl -0x48(%rbp), %eax
jb 0x2049fd
movl -0x40(%rbp), %eax
movl %eax, -0x6c(%rbp)
jmp 0x204a03
movl -0x48(%rbp), %eax
movl %eax, -0x6c(%rbp)
movl -0x68(%rbp), %eax
movl -0x6c(%rbp), %ecx
cmpl %ecx, %eax
jb 0x204a4f
movl -0x44(%rbp), %eax
cmpl -0x4c(%rbp), %eax
ja 0x204a1d
movl -0x44(%rbp), %eax
movl %eax, -0x70(%rbp)
jmp 0x204a23
movl -0x4c(%rbp), %eax
movl %eax, -0x70(%rbp)
movl -0x70(%rbp), %eax
movl %eax, -0x74(%rbp)
movl -0x40(%rbp), %eax
cmpl -0x48(%rbp), %eax
jb 0x204a39
movl -0x40(%rbp), %eax
movl %eax, -0x78(%rbp)
jmp 0x204a3f
movl -0x48(%rbp), %eax
movl %eax, -0x78(%rbp)
movl -0x74(%rbp), %eax
movl -0x78(%rbp), %ecx
subl %ecx, %eax
addl $0x1, %eax
movl %eax, -0x7c(%rbp)
jmp 0x204a56
xorl %eax, %eax
movl %eax, -0x7c(%rbp)
jmp 0x204a56
movl -0x7c(%rbp), %eax
movl %eax, %eax
movq %rax, -0x60(%rbp)
cmpq $0x0, -0x60(%rbp)
jne 0x204a68
jmp 0x204ab4
movaps 0x17d5a1(%rip), %xmm1   # 0x382010
movq -0x60(%rbp), %xmm0
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0x17d5a0(%rip), %xmm1   # 0x382020
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movl -0x14(%rbp), %eax
cvtsi2sd %rax, %xmm1
movsd 0x17a571(%rip), %xmm2   # 0x37f010
mulsd %xmm2, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x204ab2
movl $0x1, -0x4(%rbp)
jmp 0x204ac9
jmp 0x204ab4
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
jmp 0x20499e
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x80, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)