// File: 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
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq (%rax), %rax
movslq -0x14(%rbp), %rcx
imulq $0x68, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rax
movq 0x28(%rax), %rax
movq 0x10(%rax), %rax
movq -0x10(%rbp), %rcx
movq (%rax,%rcx,8), %rax
shrq $0x20, %rax
movl %eax, -0x2c(%rbp)
movq -0x20(%rbp), %rax
movq 0x28(%rax), %rax
movq 0x10(%rax), %rax
movq -0x10(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl %eax, -0x30(%rbp)
movsd 0x245e35(%rip), %xmm0   # 0x37f010
movsd %xmm0, -0x48(%rbp)
movq -0x20(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x58(%rbp)
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rsi
movl -0x2c(%rbp), %edx
movq -0x58(%rbp), %rcx
movq -0x28(%rbp), %r8
callq 0x137ce0
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
je 0x13924f
movq -0x28(%rbp), %rax
movq 0x18(%rax), %rax
movl (%rax), %eax
movl -0x30(%rbp), %ecx
xorl $0x1, %ecx
cmpl %ecx, %eax
jne 0x13922b
jmp 0x13924a
leaq 0x24f8d0(%rip), %rdi    # 0x388b02
leaq 0x24d684(%rip), %rsi    # 0x3868bd
movl $0x62e8, %edx           # imm = 0x62E8
leaq 0x24f8d1(%rip), %rcx    # 0x388b16
callq 0x2130
jmp 0x1395fc
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rdi
movl -0x2c(%rbp), %edx
movq -0x58(%rbp), %rcx
movq -0x28(%rbp), %r8
xorl %eax, %eax
movl %eax, %esi
callq 0x137ce0
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
je 0x139276
jmp 0x139295
leaq 0x248147(%rip), %rdi    # 0x3813c4
leaq 0x24d639(%rip), %rsi    # 0x3868bd
movl $0x62f1, %edx           # imm = 0x62F1
leaq 0x24f886(%rip), %rcx    # 0x388b16
callq 0x2130
movq -0x28(%rbp), %rax
movq 0x18(%rax), %rax
movl (%rax), %eax
movl -0x30(%rbp), %ecx
xorl $0x1, %ecx
cmpl %ecx, %eax
jne 0x1392ab
jmp 0x1392ca
leaq 0x24f850(%rip), %rdi    # 0x388b02
leaq 0x24d604(%rip), %rsi    # 0x3868bd
movl $0x62f1, %edx           # imm = 0x62F1
leaq 0x24f851(%rip), %rcx    # 0x388b16
callq 0x2130
movq $0x0, -0x58(%rbp)
movl $0x0, -0x38(%rbp)
movl -0x38(%rbp), %eax
movq -0x28(%rbp), %rcx
cmpq 0x38(%rcx), %rax
jae 0x139350
movq -0x28(%rbp), %rax
movq 0x48(%rax), %rax
movl -0x38(%rbp), %ecx
movl (%rax,%rcx,4), %eax
cmpl -0x2c(%rbp), %eax
je 0x139313
movq -0x28(%rbp), %rax
movq 0x48(%rax), %rax
movl -0x38(%rbp), %ecx
movl (%rax,%rcx,4), %eax
movq -0x28(%rbp), %rcx
movq 0x18(%rcx), %rcx
cmpl (%rcx), %eax
jne 0x139315
jmp 0x139345
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x20(%rax), %rax
movq -0x28(%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 -0x58(%rbp), %rax
movq %rax, -0x58(%rbp)
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x1392d9
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x20(%rax), %rax
movl -0x2c(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
movl (%rax,%rcx,8), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, %eax
addq -0x58(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x20(%rax), %rax
movq -0x28(%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 -0x58(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rsi
movl -0x2c(%rbp), %edx
movq -0x58(%rbp), %rcx
movq -0x28(%rbp), %r8
callq 0x137ce0
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
je 0x139404
movq -0x28(%rbp), %rax
movq 0x18(%rax), %rax
movl (%rax), %eax
movl -0x30(%rbp), %ecx
xorl $0x1, %ecx
cmpl %ecx, %eax
jne 0x1393e0
jmp 0x1393ff
leaq 0x24f71b(%rip), %rdi    # 0x388b02
leaq 0x24d4cf(%rip), %rsi    # 0x3868bd
movl $0x62fa, %edx           # imm = 0x62FA
leaq 0x24f71c(%rip), %rcx    # 0x388b16
callq 0x2130
jmp 0x1395fc
movsd 0x248e6c(%rip), %xmm0   # 0x382278
movsd %xmm0, -0x50(%rbp)
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rsi
movl -0x2c(%rbp), %edx
movl -0x30(%rbp), %ecx
xorl $0x1, %ecx
movsd -0x50(%rbp), %xmm0
movq -0x28(%rbp), %r9
movl $0x1, %r8d
callq 0x138d20
movl %eax, -0x3c(%rbp)
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rsi
movl -0x2c(%rbp), %edx
movq -0x58(%rbp), %rcx
movq -0x28(%rbp), %r8
callq 0x137ce0
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
je 0x1394a4
movq -0x28(%rbp), %rax
movq 0x18(%rax), %rax
movl (%rax), %eax
movl -0x30(%rbp), %ecx
xorl $0x1, %ecx
cmpl %ecx, %eax
jne 0x139480
jmp 0x13949f
leaq 0x24f67b(%rip), %rdi    # 0x388b02
leaq 0x24d42f(%rip), %rsi    # 0x3868bd
movl $0x6303, %edx           # imm = 0x6303
leaq 0x24f67c(%rip), %rcx    # 0x388b16
callq 0x2130
jmp 0x1395fc
movsd -0x48(%rbp), %xmm0
movsd %xmm0, -0x50(%rbp)
movsd 0x248b4a(%rip), %xmm0   # 0x382000
ucomisd -0x50(%rbp), %xmm0
jbe 0x13956f
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rsi
movl -0x2c(%rbp), %edx
movl -0x30(%rbp), %ecx
xorl $0x1, %ecx
movsd -0x50(%rbp), %xmm0
movq -0x28(%rbp), %r9
xorl %r8d, %r8d
callq 0x138d20
movl %eax, -0x3c(%rbp)
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rsi
movl -0x2c(%rbp), %edx
movq -0x58(%rbp), %rcx
movq -0x28(%rbp), %r8
callq 0x137ce0
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
je 0x139551
movq -0x28(%rbp), %rax
movq 0x18(%rax), %rax
movl (%rax), %eax
movl -0x30(%rbp), %ecx
xorl $0x1, %ecx
cmpl %ecx, %eax
jne 0x13952d
jmp 0x13954c
leaq 0x24f5ce(%rip), %rdi    # 0x388b02
leaq 0x24d382(%rip), %rsi    # 0x3868bd
movl $0x630b, %edx           # imm = 0x630B
leaq 0x24f5cf(%rip), %rcx    # 0x388b16
callq 0x2130
jmp 0x1395fc
cmpl $0x0, -0x3c(%rbp)
jne 0x139559
jmp 0x13956f
jmp 0x13955b
movsd -0x48(%rbp), %xmm0
addsd -0x50(%rbp), %xmm0
movsd %xmm0, -0x50(%rbp)
jmp 0x1394ae
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rsi
movl -0x2c(%rbp), %edx
movl -0x30(%rbp), %ecx
xorl $0x1, %ecx
movq -0x28(%rbp), %r9
movsd 0x24d2e4(%rip), %xmm0   # 0x386878
xorl %r8d, %r8d
callq 0x138d20
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rsi
movl -0x2c(%rbp), %edx
movq -0x58(%rbp), %rcx
movq -0x28(%rbp), %r8
callq 0x137ce0
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
je 0x1395fc
movq -0x28(%rbp), %rax
movq 0x18(%rax), %rax
movl (%rax), %eax
movl -0x30(%rbp), %ecx
xorl $0x1, %ecx
cmpl %ecx, %eax
jne 0x1395db
jmp 0x1395fa
leaq 0x24f520(%rip), %rdi    # 0x388b02
leaq 0x24d2d4(%rip), %rsi    # 0x3868bd
movl $0x6313, %edx           # imm = 0x6313
leaq 0x24f521(%rip), %rcx    # 0x388b16
callq 0x2130
jmp 0x1395fc
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)