// File: /workspace/github_cpp_makefile_star2_O2/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 0xa6c6c
testq %rax, %rax
je 0xa779a
movq 0x18(%rbx), %rax
movl (%rax), %eax
xorl %r13d, %eax
cmpl $0x1, %eax
je 0xa79b4
leaq 0x142655(%rip), %rdi    # 0x1e9dd7
leaq 0x140608(%rip), %rsi    # 0x1e7d91
leaq 0x14265b(%rip), %rcx    # 0x1e9deb
movl $0x62e8, %edx           # imm = 0x62E8
callq 0x2110
movq 0x8(%r14), %rdi
xorl %esi, %esi
movl %r15d, %edx
movq %r12, %rcx
movq %rbx, %r8
callq 0xa6c6c
testq %rax, %rax
je 0xa79c3
movq 0x18(%rbx), %rax
movl (%rax), %r12d
movl %r12d, %eax
xorl %r13d, %eax
cmpl $0x1, %eax
jne 0xa79cc
movq 0x38(%rbx), %rcx
xorl %edx, %edx
xorl %eax, %eax
movl %edx, %edx
cmpq %rdx, %rcx
jbe 0xa7807
movq 0x48(%rbx), %rsi
movl (%rsi,%rdx,4), %esi
cmpl %r15d, %esi
je 0xa7803
cmpl %r12d, %esi
je 0xa7803
movq 0x8(%r14), %rdi
movq 0x20(%rdi), %rdi
shrl %esi
movl (%rdi,%rsi,8), %esi
andl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
addq %rsi, %rax
incl %edx
jmp 0xa77d5
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 %rdx, %rax
movl %r12d, %edx
shrl %edx
movl (%rcx,%rdx,8), %r13d
andq %r8, %r13
addq %rax, %r13
movl %r15d, %edx
movq %r13, %rcx
movq %rbx, %r8
callq 0xa6c6c
testq %rax, %rax
je 0xa7875
movq 0x18(%rbx), %rax
cmpl %r12d, (%rax)
je 0xa79b4
leaq 0x14257a(%rip), %rdi    # 0x1e9dd7
leaq 0x14052d(%rip), %rsi    # 0x1e7d91
leaq 0x142580(%rip), %rcx    # 0x1e9deb
movl $0x62fa, %edx           # imm = 0x62FA
callq 0x2110
movq 0x8(%r14), %rsi
movq 0x10(%r14), %rdi
movsd 0x13bcfb(%rip), %xmm0   # 0x1e3580
pushq $0x1
popq %r8
movl %r15d, %edx
movl %r12d, %ecx
movq %rbx, %r9
callq 0xa74b1
movq 0x8(%r14), %rsi
movq 0x10(%r14), %rdi
movl %r15d, %edx
movq %r13, %rcx
movq %rbx, %r8
callq 0xa6c6c
testq %rax, %rax
je 0xa78de
movq 0x18(%rbx), %rax
cmpl %r12d, (%rax)
je 0xa79b4
leaq 0x142511(%rip), %rdi    # 0x1e9dd7
leaq 0x1404c4(%rip), %rsi    # 0x1e7d91
leaq 0x142517(%rip), %rcx    # 0x1e9deb
movl $0x6303, %edx           # imm = 0x6303
callq 0x2110
movsd 0x13bbea(%rip), %xmm1   # 0x1e34d0
movsd 0x13b9b2(%rip), %xmm0   # 0x1e32a0
ucomisd %xmm1, %xmm0
jbe 0xa7947
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 0xa74b1
movq %rax, %rbp
movq 0x8(%r14), %rsi
movq 0x10(%r14), %rdi
movl %r15d, %edx
movq %r13, %rcx
movq %rbx, %r8
callq 0xa6c6c
testq %rax, %rax
jne 0xa79ab
testl %ebp, %ebp
movsd (%rsp), %xmm1
je 0xa7947
addsd 0x13bb8b(%rip), %xmm1   # 0x1e34d0
jmp 0xa78e6
movq 0x8(%r14), %rsi
movq 0x10(%r14), %rdi
movsd 0x140339(%rip), %xmm0   # 0x1e7c90
movl %r15d, %edx
movl %r12d, %ecx
xorl %r8d, %r8d
movq %rbx, %r9
callq 0xa74b1
movq 0x8(%r14), %rsi
movq 0x10(%r14), %rdi
movl %r15d, %edx
movq %r13, %rcx
movq %rbx, %r8
callq 0xa6c6c
testq %rax, %rax
je 0xa79b4
movq 0x18(%rbx), %rax
cmpl %r12d, (%rax)
je 0xa79b4
leaq 0x142444(%rip), %rdi    # 0x1e9dd7
leaq 0x1403f7(%rip), %rsi    # 0x1e7d91
leaq 0x14244a(%rip), %rcx    # 0x1e9deb
movl $0x6313, %edx           # imm = 0x6313
callq 0x2110
movq 0x18(%rbx), %rax
cmpl %r12d, (%rax)
jne 0xa79eb
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x13abee(%rip), %rdi    # 0x1e25b8
jmp 0xa79d3
leaq 0x142404(%rip), %rdi    # 0x1e9dd7
leaq 0x1403b7(%rip), %rsi    # 0x1e7d91
leaq 0x14240a(%rip), %rcx    # 0x1e9deb
movl $0x62f1, %edx           # imm = 0x62F1
callq 0x2110
leaq 0x1423e5(%rip), %rdi    # 0x1e9dd7
leaq 0x140398(%rip), %rsi    # 0x1e7d91
leaq 0x1423eb(%rip), %rcx    # 0x1e9deb
movl $0x630b, %edx           # imm = 0x630B
callq 0x2110