// File: /workspace/github_cpp_makefile_star2_O3/chhylp123[P]hifiasm/Overlaps.cpp
// Function: rd_hamming_symm(void*, long, int)
void rd_hamming_symm(void *data, long i, int tid) // callback for kt_for()
{
    rd_hamming_t *s = (rd_hamming_t *)data; buf_t *b = &(s->a[tid]);
    uint32_t st = s->rr->a[i]>>32, ed = (uint32_t)(s->rr->a[i]), p, k, ncut;
    double step = 0.2, cuttoff; uint64_t max_dist = s->max_dist;
    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;
    }

    ///drop inexact edges first
    cuttoff = -1;
    ncut = rd_hm_drop(s->g, s->ref, st, ed^1, cuttoff, 1, b);
    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
movq %rdi, %r14
movslq %edx, %rax
imulq $0x68, %rax, %rbx
addq (%rdi), %rbx
movq 0x28(%rdi), %rax
movq 0x10(%rax), %rax
movq (%rax,%rsi,8), %r13
movq %r13, %r15
shrq $0x20, %r15
movq 0x20(%rdi), %r12
movq 0x8(%rdi), %rsi
movq 0x10(%rdi), %rdi
movl %r15d, %edx
movq %r12, %rcx
movq %rbx, %r8
callq 0xe46e8
testq %rax, %rax
je 0xe561e
movq 0x18(%rbx), %rax
movl (%rax), %eax
xorl %r13d, %eax
cmpl $0x1, %eax
je 0xe5845
leaq 0x1528d1(%rip), %rdi    # 0x237ed7
leaq 0x150884(%rip), %rsi    # 0x235e91
leaq 0x1528d7(%rip), %rcx    # 0x237eeb
movl $0x62e8, %edx           # imm = 0x62E8
callq 0x2110
movq 0x8(%r14), %rdi
xorl %esi, %esi
movl %r15d, %edx
movq %r12, %rcx
movq %rbx, %r8
callq 0xe46e8
testq %rax, %rax
je 0xe5854
movq 0x18(%rbx), %rax
movl (%rax), %r12d
movl %r12d, %eax
xorl %r13d, %eax
cmpl $0x1, %eax
jne 0xe585d
movq 0x38(%rbx), %rcx
testq %rcx, %rcx
je 0xe5692
movq 0x48(%rbx), %rdx
xorl %esi, %esi
xorl %eax, %eax
movl (%rdx,%rsi,4), %edi
cmpl %r15d, %edi
je 0xe5686
cmpl %r12d, %edi
je 0xe5686
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 0xe5662
jmp 0xe5694
xorl %eax, %eax
movq 0x8(%r14), %rsi
movq 0x10(%r14), %rdi
movq 0x20(%rsi), %rcx
shrq $0x21, %r13
movl (%rcx,%r13,8), %edx
movl $0x7fffffff, %r8d       # imm = 0x7FFFFFFF
andq %r8, %rdx
addq %rax, %rdx
movl %r12d, %eax
shrl %eax
movl (%rcx,%rax,8), %r13d
andq %r8, %r13
addq %rdx, %r13
movl %r15d, %edx
movq %r13, %rcx
movq %rbx, %r8
callq 0xe46e8
testq %rax, %rax
je 0xe5702
movq 0x18(%rbx), %rax
cmpl %r12d, (%rax)
je 0xe5845
leaq 0x1527ed(%rip), %rdi    # 0x237ed7
leaq 0x1507a0(%rip), %rsi    # 0x235e91
leaq 0x1527f3(%rip), %rcx    # 0x237eeb
movl $0x62fa, %edx           # imm = 0x62FA
callq 0x2110
movq 0x8(%r14), %rsi
movq 0x10(%r14), %rdi
movsd 0x14bf26(%rip), %xmm0   # 0x231638
movl %r15d, %edx
movl %r12d, %ecx
movl $0x1, %r8d
movq %rbx, %r9
callq 0xe52c7
movq 0x8(%r14), %rsi
movq 0x10(%r14), %rdi
movl %r15d, %edx
movq %r13, %rcx
movq %rbx, %r8
callq 0xe46e8
testq %rax, %rax
je 0xe576d
movq 0x18(%rbx), %rax
cmpl %r12d, (%rax)
je 0xe5845
leaq 0x152782(%rip), %rdi    # 0x237ed7
leaq 0x150735(%rip), %rsi    # 0x235e91
leaq 0x152788(%rip), %rcx    # 0x237eeb
movl $0x6303, %edx           # imm = 0x6303
callq 0x2110
movsd 0x14be0b(%rip), %xmm1   # 0x231580
movq 0x8(%r14), %rsi
movq 0x10(%r14), %rdi
movl %r15d, %edx
movl %r12d, %ecx
movsd %xmm1, (%rsp)
movapd %xmm1, %xmm0
xorl %r8d, %r8d
movq %rbx, %r9
callq 0xe52c7
movq %rax, %rbp
movq 0x8(%r14), %rsi
movq 0x10(%r14), %rdi
movl %r15d, %edx
movq %r13, %rcx
movq %rbx, %r8
callq 0xe46e8
testq %rax, %rax
jne 0xe583c
movsd (%rsp), %xmm1
addsd 0x14bdba(%rip), %xmm1   # 0x231580
testl %ebp, %ebp
je 0xe57d8
movsd 0x14bb3e(%rip), %xmm0   # 0x231310
ucomisd %xmm1, %xmm0
ja 0xe5775
movq 0x8(%r14), %rsi
movq 0x10(%r14), %rdi
movsd 0x1505a8(%rip), %xmm0   # 0x235d90
movl %r15d, %edx
movl %r12d, %ecx
xorl %r8d, %r8d
movq %rbx, %r9
callq 0xe52c7
movq 0x8(%r14), %rsi
movq 0x10(%r14), %rdi
movl %r15d, %edx
movq %r13, %rcx
movq %rbx, %r8
callq 0xe46e8
testq %rax, %rax
je 0xe5845
movq 0x18(%rbx), %rax
cmpl %r12d, (%rax)
je 0xe5845
leaq 0x1526b3(%rip), %rdi    # 0x237ed7
leaq 0x150666(%rip), %rsi    # 0x235e91
leaq 0x1526b9(%rip), %rcx    # 0x237eeb
movl $0x6313, %edx           # imm = 0x6313
callq 0x2110
movq 0x18(%rbx), %rax
cmpl %r12d, (%rax)
jne 0xe587c
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x14ad5d(%rip), %rdi    # 0x2305b8
jmp 0xe5864
leaq 0x152673(%rip), %rdi    # 0x237ed7
leaq 0x150626(%rip), %rsi    # 0x235e91
leaq 0x152679(%rip), %rcx    # 0x237eeb
movl $0x62f1, %edx           # imm = 0x62F1
callq 0x2110
leaq 0x152654(%rip), %rdi    # 0x237ed7
leaq 0x150607(%rip), %rsi    # 0x235e91
leaq 0x15265a(%rip), %rcx    # 0x237eeb
movl $0x630b, %edx           # imm = 0x630B
callq 0x2110