// File: /workspace/github_cpp_makefile_star2_O1/chhylp123[P]hifiasm/gfa_ut.cpp
// Function: cal_bub_best(void*, long, int)
static void cal_bub_best(void *data, long i, int tid)
{
    ug_clean_t *sl = (ug_clean_t *)data;
    ma_ug_t *ug = sl->ug; uint32_t v, w;
    sl->idx[i<<1] = sl->idx[(i<<1)+1] = (uint32_t)-1;
    if(ug->g->seq[i].del) return;
    if((sl->bid[i<<1] == (uint32_t)-1) || (sl->bid[(i<<1)+1] == (uint32_t)-1)) return;///not within a bubble
    
    v = i<<1;
    if(sl->bid[v] != v) {///not the beg/sink node
        w = get_best_het_node(ug, v, sl->bid, sl->is_ou, sl->is_trio, sl->len_rat, sl->ou_rat, sl->min_ou);
        // if(v == 352) fprintf(stderr, "-v-[M::%s]\tutg%.6ul(%c)\tv::%u\tw::%u\n", __func__, (v>>1)+1, "+-"[v&1], v, w);
        if((w != (uint32_t)-1) && ((v^1) == get_best_het_node(ug, w^1, sl->bid, sl->is_ou, sl->is_trio, sl->len_rat, sl->ou_rat, sl->min_ou))) {
            sl->idx[v] = w;
        }
    }

    v = (i<<1)+1;
    if(sl->bid[v] != v) {///not the beg/sink node
        w = get_best_het_node(ug, v, sl->bid, sl->is_ou, sl->is_trio, sl->len_rat, sl->ou_rat, sl->min_ou);
        if((w != (uint32_t)-1) && ((v^1) == get_best_het_node(ug, w^1, sl->bid, sl->is_ou, sl->is_trio, sl->len_rat, sl->ou_rat, sl->min_ou))) {
            sl->idx[v] = w;
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq 0x10(%rdi), %rbx
movq 0x80(%rdi), %rbp
leaq (%rsi,%rsi), %r13
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, 0x4(%rbp,%r13,4)
movl %eax, (%rbp,%rsi,8)
movq 0x18(%rbx), %rax
movq 0x20(%rax), %rax
cmpl $0x0, (%rax,%rsi,8)
js 0x221154
movq %rdi, %r12
movq 0x88(%rdi), %r15
cmpl $-0x1, (%r15,%r13,4)
je 0x221154
leaq 0x1(,%rsi,2), %rdx
cmpl $-0x1, (%r15,%rdx,4)
je 0x221154
movl %r13d, %r14d
andl $-0x2, %r14d
cmpl %r13d, (%r15,%r14,4)
je 0x2210aa
movsd 0xb0(%r12), %xmm0
movsd 0xb8(%r12), %xmm1
movl 0xc0(%r12), %r9d
movzbl 0x98(%r12), %ecx
movzbl 0x99(%r12), %r8d
movq %rbx, %rdi
movq %rdx, 0x10(%rsp)
movl %r13d, %esi
movq %r15, %rdx
movl %ecx, (%rsp)
movl %r8d, 0x24(%rsp)
movsd %xmm0, 0x8(%rsp)
movsd %xmm1, 0x18(%rsp)
movl %r9d, 0x4(%rsp)
callq 0x21fc94
movq 0x10(%rsp), %rdx
cmpl $-0x1, %eax
je 0x2210aa
orl $0x1, %r13d
movl %eax, %esi
xorl $0x1, %esi
movq %rbx, %rdi
movq %r15, %rdx
movl (%rsp), %ecx
movl 0x24(%rsp), %r8d
movsd 0x8(%rsp), %xmm0
movsd 0x18(%rsp), %xmm1
movl 0x4(%rsp), %r9d
movl %eax, 0x8(%rsp)
callq 0x21fc94
movq 0x10(%rsp), %rdx
cmpl %eax, %r13d
movl 0x8(%rsp), %eax
jne 0x2210aa
movl %eax, (%rbp,%r14,4)
movl %edx, %r14d
cmpl %edx, (%r15,%r14,4)
je 0x221154
movsd 0xb0(%r12), %xmm0
movsd 0xb8(%r12), %xmm1
movl 0xc0(%r12), %r9d
movzbl 0x98(%r12), %r13d
movzbl 0x99(%r12), %r8d
movq %rbx, %rdi
movq %rdx, %r12
movl %r12d, %esi
movq %r15, %rdx
movl %r13d, %ecx
movl %r8d, (%rsp)
movsd %xmm0, 0x8(%rsp)
movsd %xmm1, 0x18(%rsp)
movl %r9d, 0x4(%rsp)
callq 0x21fc94
cmpl $-0x1, %eax
je 0x221154
movq %r12, %rcx
movl %eax, %r12d
andl $-0x2, %ecx
movq %rcx, 0x10(%rsp)
movl %eax, %esi
xorl $0x1, %esi
movq %rbx, %rdi
movq %r15, %rdx
movl %r13d, %ecx
movl (%rsp), %r8d
movsd 0x8(%rsp), %xmm0
movsd 0x18(%rsp), %xmm1
movl 0x4(%rsp), %r9d
callq 0x21fc94
cmpl %eax, 0x10(%rsp)
jne 0x221154
movl %r12d, (%rbp,%r14,4)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq