// File: chhylp123[P]hifiasm/hic.cpp
// Function: get_max_unitig(H_partition*, G_partition*, hc_links*, bubble_type*)
uint32_t get_max_unitig(H_partition* h, G_partition* g_p, hc_links* link, bubble_type* bub)
{
    double min, weight;
    uint32_t i, min_i;
     
    for (i = 0, min = 1, min_i = (uint32_t)-1; i < g_p->n; i++)
    {
        if(h->lock[i]) continue;
        weight = 0;
        if(g_p->a[i].h[0] > 0 && (g_p->a[i].status[0] == 1 || g_p->a[i].status[0] == -1))
        {
            weight += (g_p->a[i].weight[0] * g_p->a[i].status[0]);
        }

        if(g_p->a[i].h[1] > 0 && (g_p->a[i].status[1] == 1 || g_p->a[i].status[1] == -1))
        {
            weight += (g_p->a[i].weight[1] * g_p->a[i].status[1]);
        }
        weight += g_p->a[i].weight_convex*2;

        if(weight >= 0) continue;
        if(weight < min)
        {
            min = weight;
            min_i = i;
        }
    }
    ///fprintf(stderr, "*****************min: %f\n", min);
    return min_i;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movl $0x0, -0x34(%rbp)
movsd 0x18f0dd(%rip), %xmm0   # 0x382000
movsd %xmm0, -0x28(%rbp)
movl $0xffffffff, -0x38(%rbp) # imm = 0xFFFFFFFF
movl -0x34(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpq (%rcx), %rax
jae 0x1f30d6
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movl -0x34(%rbp), %ecx
cmpb $0x0, (%rax,%rcx)
je 0x1f2f55
jmp 0x1f30c8
xorps %xmm0, %xmm0
movsd %xmm0, -0x30(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x34(%rbp), %ecx
imulq $0x48, %rcx, %rcx
addq %rcx, %rax
cmpl $0x0, 0x18(%rax)
jbe 0x1f2fe5
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x34(%rbp), %ecx
imulq $0x48, %rcx, %rcx
addq %rcx, %rax
cmpl $0x1, 0x24(%rax)
je 0x1f2fa5
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x34(%rbp), %ecx
imulq $0x48, %rcx, %rcx
addq %rcx, %rax
cmpl $-0x1, 0x24(%rax)
jne 0x1f2fe5
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x34(%rbp), %ecx
imulq $0x48, %rcx, %rcx
addq %rcx, %rax
movsd 0x30(%rax), %xmm0
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x34(%rbp), %ecx
imulq $0x48, %rcx, %rcx
addq %rcx, %rax
cvtsi2sdl 0x24(%rax), %xmm2
movsd -0x30(%rbp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x30(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x34(%rbp), %ecx
imulq $0x48, %rcx, %rcx
addq %rcx, %rax
cmpl $0x0, 0x1c(%rax)
jbe 0x1f306d
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x34(%rbp), %ecx
imulq $0x48, %rcx, %rcx
addq %rcx, %rax
cmpl $0x1, 0x28(%rax)
je 0x1f302d
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x34(%rbp), %ecx
imulq $0x48, %rcx, %rcx
addq %rcx, %rax
cmpl $-0x1, 0x28(%rax)
jne 0x1f306d
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x34(%rbp), %ecx
imulq $0x48, %rcx, %rcx
addq %rcx, %rax
movsd 0x38(%rax), %xmm0
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x34(%rbp), %ecx
imulq $0x48, %rcx, %rcx
addq %rcx, %rax
cvtsi2sdl 0x28(%rax), %xmm2
movsd -0x30(%rbp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x30(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x34(%rbp), %ecx
imulq $0x48, %rcx, %rcx
addq %rcx, %rax
movsd 0x40(%rax), %xmm0
movsd -0x30(%rbp), %xmm1
addsd %xmm0, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x30(%rbp)
movsd -0x30(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x1f30a6
jmp 0x1f30c8
movsd -0x30(%rbp), %xmm1
movsd -0x28(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x1f30c6
movsd -0x30(%rbp), %xmm0
movsd %xmm0, -0x28(%rbp)
movl -0x34(%rbp), %eax
movl %eax, -0x38(%rbp)
jmp 0x1f30c8
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x1f2f2f
movl -0x38(%rbp), %eax
popq %rbp
retq
nopl (%rax,%rax)