// File: /workspace/github_cpp_makefile_star2_O1/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
movl %r13d, %ebp
movq 0x20(%rdi), %r12
movq 0x8(%rdi), %rsi
movq 0x10(%rdi), %rdi
movl %r15d, %edx
movq %r12, %rcx
movq %rbx, %r8
callq 0xe2f48
testq %rax, %rax
je 0xe3eb7
movq 0x18(%rbx), %rax
movl (%rax), %eax
xorl %ebp, %eax
cmpl $0x1, %eax
je 0xe40d4
leaq 0x147e48(%rip), %rdi    # 0x22bce7
leaq 0x145dfb(%rip), %rsi    # 0x229ca1
leaq 0x147e4e(%rip), %rcx    # 0x22bcfb
movl $0x62e8, %edx           # imm = 0x62E8
callq 0x2110
movq 0x8(%r14), %rdi
xorl %esi, %esi
movl %r15d, %edx
movq %r12, %rcx
movq %rbx, %r8
callq 0xe2f48
testq %rax, %rax
je 0xe40e3
movq 0x18(%rbx), %rax
movl (%rax), %eax
xorl $0x1, %ebp
cmpl %ebp, %eax
jne 0xe40ec
movq 0x38(%rbx), %rdx
testq %rdx, %rdx
je 0xe3f2a
movq 0x48(%rbx), %rsi
xorl %edi, %edi
xorl %ecx, %ecx
movl (%rsi,%rdi,4), %r8d
cmpl %r15d, %r8d
je 0xe3f1d
cmpl %eax, %r8d
je 0xe3f1d
movq 0x8(%r14), %r9
movq 0x20(%r9), %r9
shrl %r8d
movl (%r9,%r8,8), %r8d
andl $0x7fffffff, %r8d       # imm = 0x7FFFFFFF
addq %r8, %rcx
incq %rdi
movl %edi, %r8d
cmpq %r8, %rdx
ja 0xe3ef6
jmp 0xe3f2c
xorl %ecx, %ecx
movq 0x8(%r14), %rsi
movq 0x10(%r14), %rdi
movq 0x20(%rsi), %rdx
shrq $0x21, %r13
movl (%rdx,%r13,8), %r8d
movl $0x7fffffff, %r9d       # imm = 0x7FFFFFFF
andq %r9, %r8
addq %rcx, %r8
shrl %eax
movl (%rdx,%rax,8), %r12d
andq %r9, %r12
addq %r8, %r12
movl %r15d, %edx
movq %r12, %rcx
movq %rbx, %r8
callq 0xe2f48
testq %rax, %rax
je 0xe3f96
movq 0x18(%rbx), %rax
cmpl %ebp, (%rax)
je 0xe40d4
leaq 0x147d69(%rip), %rdi    # 0x22bce7
leaq 0x145d1c(%rip), %rsi    # 0x229ca1
leaq 0x147d6f(%rip), %rcx    # 0x22bcfb
movl $0x62fa, %edx           # imm = 0x62FA
callq 0x2110
movq 0x8(%r14), %rsi
movq 0x10(%r14), %rdi
movsd 0x141592(%rip), %xmm0   # 0x225538
movl %r15d, %edx
movl %ebp, %ecx
movl $0x1, %r8d
movq %rbx, %r9
callq 0xe3b74
movq 0x8(%r14), %rsi
movq 0x10(%r14), %rdi
movl %r15d, %edx
movq %r12, %rcx
movq %rbx, %r8
callq 0xe2f48
testq %rax, %rax
je 0xe3fff
movq 0x18(%rbx), %rax
cmpl %ebp, (%rax)
je 0xe40d4
leaq 0x147d00(%rip), %rdi    # 0x22bce7
leaq 0x145cb3(%rip), %rsi    # 0x229ca1
leaq 0x147d06(%rip), %rcx    # 0x22bcfb
movl $0x6303, %edx           # imm = 0x6303
callq 0x2110
movsd 0x141479(%rip), %xmm1   # 0x225480
movq 0x8(%r14), %rsi
movq 0x10(%r14), %rdi
movl %r15d, %edx
movl %ebp, %ecx
movsd %xmm1, (%rsp)
movapd %xmm1, %xmm0
xorl %r8d, %r8d
movq %rbx, %r9
callq 0xe3b74
movq %rax, %r13
movq 0x8(%r14), %rsi
movq 0x10(%r14), %rdi
movl %r15d, %edx
movq %r12, %rcx
movq %rbx, %r8
callq 0xe2f48
testq %rax, %rax
jne 0xe40cc
movsd (%rsp), %xmm1
addsd 0x141429(%rip), %xmm1   # 0x225480
testl %r13d, %r13d
je 0xe406a
movsd 0x14120c(%rip), %xmm0   # 0x225270
ucomisd %xmm1, %xmm0
ja 0xe4007
movq 0x8(%r14), %rsi
movq 0x10(%r14), %rdi
movsd 0x145b1e(%rip), %xmm0   # 0x229b98
movl %r15d, %edx
movl %ebp, %ecx
xorl %r8d, %r8d
movq %rbx, %r9
callq 0xe3b74
movq 0x8(%r14), %rsi
movq 0x10(%r14), %rdi
movl %r15d, %edx
movq %r12, %rcx
movq %rbx, %r8
callq 0xe2f48
testq %rax, %rax
je 0xe40d4
movq 0x18(%rbx), %rax
cmpl %ebp, (%rax)
je 0xe40d4
leaq 0x147c33(%rip), %rdi    # 0x22bce7
leaq 0x145be6(%rip), %rsi    # 0x229ca1
leaq 0x147c39(%rip), %rcx    # 0x22bcfb
movl $0x6313, %edx           # imm = 0x6313
callq 0x2110
movq 0x18(%rbx), %rax
cmpl %ebp, (%rax)
jne 0xe410b
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1404be(%rip), %rdi    # 0x2245a8
jmp 0xe40f3
leaq 0x147bf4(%rip), %rdi    # 0x22bce7
leaq 0x145ba7(%rip), %rsi    # 0x229ca1
leaq 0x147bfa(%rip), %rcx    # 0x22bcfb
movl $0x62f1, %edx           # imm = 0x62F1
callq 0x2110
leaq 0x147bd5(%rip), %rdi    # 0x22bce7
leaq 0x145b88(%rip), %rsi    # 0x229ca1
leaq 0x147bdb(%rip), %rcx    # 0x22bcfb
movl $0x630b, %edx           # imm = 0x630B
callq 0x2110