// File: /workspace/github_cpp_makefile_star2_O3/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %edx, %r12d
movl %esi, %ebp
movq %rdi, %r14
movq (%rdi), %rbx
movq 0x8(%rdi), %rsi
movq 0x20(%rdi), %r15
movq 0x10(%rdi), %rdi
movl %ebp, %edx
movq %r15, %rcx
movq %rbx, %r8
callq 0xe46e8
testq %rax, %rax
je 0xe58ff
movq 0x18(%rbx), %rax
xorl (%rax), %r12d
cmpl $0x1, %r12d
je 0xe5ab2
leaq 0x1525f0(%rip), %rdi    # 0x237ed7
leaq 0x1505a3(%rip), %rsi    # 0x235e91
leaq 0x15261e(%rip), %rcx    # 0x237f13
movl $0x631f, %edx           # imm = 0x631F
callq 0x2110
movq 0x8(%r14), %rdi
xorl %esi, %esi
movl %ebp, %edx
movq %r15, %rcx
movq %rbx, %r8
callq 0xe46e8
testq %rax, %rax
je 0xe5ac1
movq 0x18(%rbx), %rax
movl (%rax), %r15d
xorl %r15d, %r12d
cmpl $0x1, %r12d
jne 0xe5aca
movq 0x38(%rbx), %rcx
testq %rcx, %rcx
je 0xe596f
movq 0x48(%rbx), %rdx
xorl %esi, %esi
xorl %eax, %eax
movl (%rdx,%rsi,4), %edi
cmpl %ebp, %edi
je 0xe5963
cmpl %r15d, %edi
je 0xe5963
movq 0x8(%r14), %r8
movq 0x20(%r8), %r8
shrl %edi
movl (%r8,%rdi,8), %edi
andl $0x7fffffff, %edi       # imm = 0x7FFFFFFF
addq %rdi, %rax
incq %rsi
movl %esi, %edi
cmpq %rdi, %rcx
ja 0xe5940
jmp 0xe5971
xorl %eax, %eax
movq 0x8(%r14), %rsi
movq 0x10(%r14), %rdi
movq 0x20(%rsi), %rcx
movl %ebp, %edx
shrl %edx
movl (%rcx,%rdx,8), %edx
movl $0x7fffffff, %r8d       # imm = 0x7FFFFFFF
andq %r8, %rdx
addq %rax, %rdx
movl %r15d, %eax
shrl %eax
movl (%rcx,%rax,8), %r12d
andq %r8, %r12
addq %rdx, %r12
movl %ebp, %edx
movq %r12, %rcx
movq %rbx, %r8
callq 0xe46e8
testq %rax, %rax
je 0xe59dd
movq 0x18(%rbx), %rax
cmpl %r15d, (%rax)
je 0xe5ab2
leaq 0x152512(%rip), %rdi    # 0x237ed7
leaq 0x1504c5(%rip), %rsi    # 0x235e91
leaq 0x152540(%rip), %rcx    # 0x237f13
movl $0x6331, %edx           # imm = 0x6331
callq 0x2110
movsd 0x14bb9b(%rip), %xmm1   # 0x231580
movq 0x8(%r14), %rsi
movq 0x10(%r14), %rdi
movl %ebp, %edx
movl %r15d, %ecx
movsd %xmm1, (%rsp)
movapd %xmm1, %xmm0
xorl %r8d, %r8d
movq %rbx, %r9
callq 0xe52c7
movq %rax, %r13
movq 0x8(%r14), %rsi
movq 0x10(%r14), %rdi
movl %ebp, %edx
movq %r12, %rcx
movq %rbx, %r8
callq 0xe46e8
testq %rax, %rax
jne 0xe5aa9
movsd (%rsp), %xmm1
addsd 0x14bb4c(%rip), %xmm1   # 0x231580
testl %r13d, %r13d
je 0xe5a47
movsd 0x14b8cf(%rip), %xmm0   # 0x231310
ucomisd %xmm1, %xmm0
ja 0xe59e5
movq 0x8(%r14), %rsi
movq 0x10(%r14), %rdi
movsd 0x150339(%rip), %xmm0   # 0x235d90
movl %ebp, %edx
movl %r15d, %ecx
xorl %r8d, %r8d
movq %rbx, %r9
callq 0xe52c7
movq 0x8(%r14), %rsi
movq 0x10(%r14), %rdi
movl %ebp, %edx
movq %r12, %rcx
movq %rbx, %r8
callq 0xe46e8
testq %rax, %rax
je 0xe5ab2
movq 0x18(%rbx), %rax
cmpl %r15d, (%rax)
je 0xe5ab2
leaq 0x152446(%rip), %rdi    # 0x237ed7
leaq 0x1503f9(%rip), %rsi    # 0x235e91
leaq 0x152474(%rip), %rcx    # 0x237f13
movl $0x6341, %edx           # imm = 0x6341
callq 0x2110
movq 0x18(%rbx), %rax
cmpl %r15d, (%rax)
jne 0xe5ae9
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x14aaf0(%rip), %rdi    # 0x2305b8
jmp 0xe5ad1
leaq 0x152406(%rip), %rdi    # 0x237ed7
leaq 0x1503b9(%rip), %rsi    # 0x235e91
leaq 0x152434(%rip), %rcx    # 0x237f13
movl $0x6328, %edx           # imm = 0x6328
callq 0x2110
leaq 0x1523e7(%rip), %rdi    # 0x237ed7
leaq 0x15039a(%rip), %rsi    # 0x235e91
leaq 0x152415(%rip), %rcx    # 0x237f13
movl $0x6339, %edx           # imm = 0x6339
callq 0x2110