// File: chhylp123[P]hifiasm/hic.cpp
// Function: select_max_block_by_utg_multi_thread(H_partition*, G_partition*, bubble_type*, hc_links*, block_phase_type*, unsigned long*, unsigned int, block_res_type*)
void select_max_block_by_utg_multi_thread(H_partition* h, G_partition* g_p, bubble_type* bub, 
hc_links* link, block_phase_type* i_b, uint64_t* chain_idx, uint32_t id, block_res_type* res)
{
    long long c_bid, c_uid, l_bid, l_uid;
    uint32_t gid;
    get_block_phase_type(chain_idx, g_p, bub, id, i_b);

    ma_utg_t *u = &(bub->b_ug->u.a[i_b->chainID]);
    
    gid = next_hap_label_id(i_b, g_p, bub, u, 1, &c_bid, &c_uid);

    if(gid == (uint32_t)-1) return;
    if(identify_best_interval(i_b, h->lock, g_p, bub, u, link, c_bid, c_uid, &l_bid, &l_uid)) return;
    if(l_bid == -1 || l_uid == -1) return;

    if((res->min_w > i_b->weight) || (res->min_w == i_b->weight && id < res->min_idx))
    {
        res->min_w = i_b->weight;
        res->min_f_bid = c_bid;
        res->min_f_uid = c_uid;
        res->min_l_bid = l_bid;
        res->min_l_uid = l_uid;
        res->min_chain_id = i_b->chainID;
        res->min_idx = id;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
subq $0x88, %rsp
movq 0x18(%rbp), %rax
movl 0x10(%rbp), %eax
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq %r9, -0x38(%rbp)
movq -0x38(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
movl 0x10(%rbp), %ecx
movq -0x30(%rbp), %r8
callq 0x1f1c70
movq -0x20(%rbp), %rax
movq 0xc0(%rax), %rax
movq 0x10(%rax), %rax
movq -0x30(%rbp), %rcx
imulq $0x28, 0x30(%rcx), %rcx
addq %rcx, %rax
movq %rax, -0x68(%rbp)
movq -0x30(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x68(%rbp), %rcx
movl $0x1, %r8d
leaq -0x40(%rbp), %r9
leaq -0x48(%rbp), %rax
movq %rax, (%rsp)
callq 0x1f0aa0
movl %eax, -0x5c(%rbp)
cmpl $-0x1, -0x5c(%rbp)
jne 0x1f20f7
jmp 0x1f21ed
movq -0x30(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rsi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
movq -0x68(%rbp), %r8
movq -0x28(%rbp), %r9
movq -0x40(%rbp), %rbx
movq -0x48(%rbp), %r11
leaq -0x50(%rbp), %r10
leaq -0x58(%rbp), %rax
movq %rbx, (%rsp)
movq %r11, 0x8(%rsp)
movq %r10, 0x10(%rsp)
movq %rax, 0x18(%rsp)
callq 0x1f1280
cmpl $0x0, %eax
je 0x1f2145
jmp 0x1f21ed
cmpq $-0x1, -0x50(%rbp)
je 0x1f2153
cmpq $-0x1, -0x58(%rbp)
jne 0x1f2158
jmp 0x1f21ed
movq 0x18(%rbp), %rax
movsd 0x30(%rax), %xmm0
movq -0x30(%rbp), %rax
ucomisd 0x18(%rax), %xmm0
ja 0x1f218f
movq 0x18(%rbp), %rax
movsd 0x30(%rax), %xmm0
movq -0x30(%rbp), %rax
ucomisd 0x18(%rax), %xmm0
jne 0x1f21ed
jp 0x1f21ed
movl 0x10(%rbp), %eax
movq 0x18(%rbp), %rcx
cmpq 0x28(%rcx), %rax
jge 0x1f21ed
movq -0x30(%rbp), %rax
movsd 0x18(%rax), %xmm0
movq 0x18(%rbp), %rax
movsd %xmm0, 0x30(%rax)
movq -0x40(%rbp), %rcx
movq 0x18(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x48(%rbp), %rcx
movq 0x18(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x50(%rbp), %rcx
movq 0x18(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x58(%rbp), %rcx
movq 0x18(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x30(%rbp), %rax
movq 0x30(%rax), %rcx
movq 0x18(%rbp), %rax
movq %rcx, (%rax)
movl 0x10(%rbp), %eax
movl %eax, %ecx
movq 0x18(%rbp), %rax
movq %rcx, 0x28(%rax)
addq $0x88, %rsp
popq %rbx
popq %rbp
retq
nopw (%rax,%rax)