// File: chhylp123[P]hifiasm/Overlaps.cpp
// Function: rd_hamming_symm_simple(rd_hamming_t*, unsigned int, unsigned int)
void rd_hamming_symm_simple(rd_hamming_t *s, uint32_t st, uint32_t ed) // callback for kt_for()
{
    buf_t *b = &(s->a[0]); double step = 0.2, cuttoff; uint64_t max_dist = s->max_dist;
    // uint32_t st = s->rr->a[i]>>32, ed = (uint32_t)(s->rr->a[i]);
    uint32_t p, k, ncut;
    p = rd_hm_bub(s->g, s->ref, st, max_dist, b);
    if(p) {
        assert(b->S.a[0] == (ed^1));
        return;
    }
    ///recalculate max_dist
    p = rd_hm_bub(s->ref, NULL, st, max_dist, b);
    // if(!p) {
    //     fprintf(stderr, "[M::%s] st>>1::%u(st&1::%u), ed>>1::%u(ed&1::%u), max_dist::%lu\n", 
    //     __func__, st>>1, st&1, ed>>1, ed&1, max_dist);
    // }
    assert(p); assert(b->S.a[0] == (ed^1));
    for (k = max_dist = 0; k < b->b.n; ++k) {
        if(b->b.a[k]==st || b->b.a[k]==b->S.a[0]) continue;
        max_dist += s->ref->seq[b->b.a[k]>>1].len;
    }
    max_dist += s->ref->seq[st>>1].len;
    max_dist += s->ref->seq[b->S.a[0]>>1].len;
    p = rd_hm_bub(s->g, s->ref, st, max_dist, b);
    if(p) {
        assert(b->S.a[0] == (ed^1));
        return;
    }

    for (cuttoff = step; cuttoff < 1.0; cuttoff += step) {
        ncut = rd_hm_drop(s->g, s->ref, st, ed^1, cuttoff, 0, b);
        p = rd_hm_bub(s->g, s->ref, st, max_dist, b);
        if(p) {
            assert(b->S.a[0] == (ed^1));
            return;
        }
        if(!ncut) break;
    }
    rd_hm_drop(s->g, s->ref, st, ed^1, 1024, 0, b);   
    p = rd_hm_bub(s->g, s->ref, st, max_dist, b); 
    if(p) {
        assert(b->S.a[0] == (ed^1));
        return;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x18(%rbp)
movsd 0x2459db(%rip), %xmm0   # 0x37f010
movsd %xmm0, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rsi
movl -0xc(%rbp), %edx
movq -0x30(%rbp), %rcx
movq -0x18(%rbp), %r8
callq 0x137ce0
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
je 0x1396a9
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
movl (%rax), %eax
movl -0x10(%rbp), %ecx
xorl $0x1, %ecx
cmpl %ecx, %eax
jne 0x139685
jmp 0x1396a4
leaq 0x24f476(%rip), %rdi    # 0x388b02
leaq 0x24d22a(%rip), %rsi    # 0x3868bd
movl $0x631f, %edx           # imm = 0x631F
leaq 0x24f49f(%rip), %rcx    # 0x388b3e
callq 0x2130
jmp 0x1399b6
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rdi
movl -0xc(%rbp), %edx
movq -0x30(%rbp), %rcx
movq -0x18(%rbp), %r8
xorl %eax, %eax
movl %eax, %esi
callq 0x137ce0
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
je 0x1396d0
jmp 0x1396ef
leaq 0x247ced(%rip), %rdi    # 0x3813c4
leaq 0x24d1df(%rip), %rsi    # 0x3868bd
movl $0x6328, %edx           # imm = 0x6328
leaq 0x24f454(%rip), %rcx    # 0x388b3e
callq 0x2130
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
movl (%rax), %eax
movl -0x10(%rbp), %ecx
xorl $0x1, %ecx
cmpl %ecx, %eax
jne 0x139705
jmp 0x139724
leaq 0x24f3f6(%rip), %rdi    # 0x388b02
leaq 0x24d1aa(%rip), %rsi    # 0x3868bd
movl $0x6328, %edx           # imm = 0x6328
leaq 0x24f41f(%rip), %rcx    # 0x388b3e
callq 0x2130
movq $0x0, -0x30(%rbp)
movl $0x0, -0x38(%rbp)
movl -0x38(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpq 0x38(%rcx), %rax
jae 0x1397aa
movq -0x18(%rbp), %rax
movq 0x48(%rax), %rax
movl -0x38(%rbp), %ecx
movl (%rax,%rcx,4), %eax
cmpl -0xc(%rbp), %eax
je 0x13976d
movq -0x18(%rbp), %rax
movq 0x48(%rax), %rax
movl -0x38(%rbp), %ecx
movl (%rax,%rcx,4), %eax
movq -0x18(%rbp), %rcx
movq 0x18(%rcx), %rcx
cmpl (%rcx), %eax
jne 0x13976f
jmp 0x13979f
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x20(%rax), %rax
movq -0x18(%rbp), %rcx
movq 0x48(%rcx), %rcx
movl -0x38(%rbp), %edx
movl (%rcx,%rdx,4), %ecx
shrl %ecx
movl %ecx, %ecx
movl (%rax,%rcx,8), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, %eax
addq -0x30(%rbp), %rax
movq %rax, -0x30(%rbp)
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x139733
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x20(%rax), %rax
movl -0xc(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
movl (%rax,%rcx,8), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, %eax
addq -0x30(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x20(%rax), %rax
movq -0x18(%rbp), %rcx
movq 0x18(%rcx), %rcx
movl (%rcx), %ecx
shrl %ecx
movl %ecx, %ecx
movl (%rax,%rcx,8), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, %eax
addq -0x30(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rsi
movl -0xc(%rbp), %edx
movq -0x30(%rbp), %rcx
movq -0x18(%rbp), %r8
callq 0x137ce0
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
je 0x13985e
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
movl (%rax), %eax
movl -0x10(%rbp), %ecx
xorl $0x1, %ecx
cmpl %ecx, %eax
jne 0x13983a
jmp 0x139859
leaq 0x24f2c1(%rip), %rdi    # 0x388b02
leaq 0x24d075(%rip), %rsi    # 0x3868bd
movl $0x6331, %edx           # imm = 0x6331
leaq 0x24f2ea(%rip), %rcx    # 0x388b3e
callq 0x2130
jmp 0x1399b6
movsd -0x20(%rbp), %xmm0
movsd %xmm0, -0x28(%rbp)
movsd 0x248790(%rip), %xmm0   # 0x382000
ucomisd -0x28(%rbp), %xmm0
jbe 0x139929
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rsi
movl -0xc(%rbp), %edx
movl -0x10(%rbp), %ecx
xorl $0x1, %ecx
movsd -0x28(%rbp), %xmm0
movq -0x18(%rbp), %r9
xorl %r8d, %r8d
callq 0x138d20
movl %eax, -0x3c(%rbp)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rsi
movl -0xc(%rbp), %edx
movq -0x30(%rbp), %rcx
movq -0x18(%rbp), %r8
callq 0x137ce0
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
je 0x13990b
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
movl (%rax), %eax
movl -0x10(%rbp), %ecx
xorl $0x1, %ecx
cmpl %ecx, %eax
jne 0x1398e7
jmp 0x139906
leaq 0x24f214(%rip), %rdi    # 0x388b02
leaq 0x24cfc8(%rip), %rsi    # 0x3868bd
movl $0x6339, %edx           # imm = 0x6339
leaq 0x24f23d(%rip), %rcx    # 0x388b3e
callq 0x2130
jmp 0x1399b6
cmpl $0x0, -0x3c(%rbp)
jne 0x139913
jmp 0x139929
jmp 0x139915
movsd -0x20(%rbp), %xmm0
addsd -0x28(%rbp), %xmm0
movsd %xmm0, -0x28(%rbp)
jmp 0x139868
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rsi
movl -0xc(%rbp), %edx
movl -0x10(%rbp), %ecx
xorl $0x1, %ecx
movq -0x18(%rbp), %r9
movsd 0x24cf2a(%rip), %xmm0   # 0x386878
xorl %r8d, %r8d
callq 0x138d20
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rsi
movl -0xc(%rbp), %edx
movq -0x30(%rbp), %rcx
movq -0x18(%rbp), %r8
callq 0x137ce0
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
je 0x1399b6
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
movl (%rax), %eax
movl -0x10(%rbp), %ecx
xorl $0x1, %ecx
cmpl %ecx, %eax
jne 0x139995
jmp 0x1399b4
leaq 0x24f166(%rip), %rdi    # 0x388b02
leaq 0x24cf1a(%rip), %rsi    # 0x3868bd
movl $0x6341, %edx           # imm = 0x6341
leaq 0x24f18f(%rip), %rcx    # 0x388b3e
callq 0x2130
jmp 0x1399b6
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax)