// File: /workspace/github_cpp_makefile_star2_O2/chhylp123[P]hifiasm/hic.cpp
// Function: get_max_block_multi_thread(H_partition*, G_partition*, bubble_type*, mul_block_phase_type*, long long*, long long*, long long*, long long*, long long*, double*)
int get_max_block_multi_thread(H_partition* h, G_partition* g_p, bubble_type* bub, mul_block_phase_type* x,
long long* min_u, long long* min_f_bid, long long* min_f_uid, long long* min_l_bid, long long* min_l_uid, 
double* min_w)
{
    uint32_t i;
    (*min_w) = 1;
    (*min_u) = (*min_f_bid) = (*min_f_uid) = (*min_l_bid) = (*min_l_uid) = -1;
    for (i = 0; i < x->n_thread; i++)
    {
        x->res[i].min_chain_id = x->res[i].min_f_bid = x->res[i].min_f_uid = -1;
        x->res[i].min_l_bid = x->res[i].min_l_uid = x->res[i].min_idx = -1; 
        x->res[i].min_w = 1;
    }
    x->g_p = g_p;
    x->h = h;
    kt_for(x->n_thread, worker_for_max_block, x, x->chain_ele_occ);
    ///kt_for(x->n_thread, worker_for_max_block_by_chain, x, x->chain_idx_n);

    long long min_idx = -1;
    for (i = 0; i < x->n_thread; i++)
    {
        if(x->res[i].min_chain_id == -1) continue;
        if(x->res[i].min_f_bid == -1 || x->res[i].min_f_uid == -1) continue;
        if(x->res[i].min_l_bid == -1 || x->res[i].min_l_uid == -1) continue;
        if(((*min_w) > x->res[i].min_w) || ((*min_w) == x->res[i].min_w && x->res[i].min_idx < min_idx))
        {
            (*min_w) = x->res[i].min_w;
            (*min_u) = x->res[i].min_chain_id;
            (*min_f_bid) = x->res[i].min_f_bid;
            (*min_f_uid) = x->res[i].min_f_uid;
            (*min_l_bid) = x->res[i].min_l_bid;
            (*min_l_uid) = x->res[i].min_l_uid;
            min_idx = x->res[i].min_idx;
        }
    }

    if((*min_u) != -1 && (*min_f_bid) != -1 && (*min_f_uid) != -1 && (*min_l_bid) != -1 && (*min_l_uid) != -1)
    {
        return 1;
    }

    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %r9, %rbx
movq %r8, %r14
movq %rcx, %r15
movq 0x58(%rsp), %r12
movq 0x50(%rsp), %rax
movabsq $0x3ff0000000000000, %rcx # imm = 0x3FF0000000000000
movq %rcx, (%r12)
orq $-0x1, (%rax)
movq 0x48(%rsp), %rax
movq %rax, %r13
orq $-0x1, (%rax)
movq 0x40(%rsp), %rbp
orq $-0x1, (%rbp)
orq $-0x1, (%r9)
movq %rdi, %rax
orq $-0x1, (%r8)
movl 0x8(%r15), %edi
imulq $0x38, %rdi, %rdx
xorl %r8d, %r8d
pcmpeqd %xmm0, %xmm0
cmpq %r8, %rdx
je 0x10f013
movq 0x30(%r15), %r9
movdqu %xmm0, 0x20(%r9,%r8)
movdqu %xmm0, 0x10(%r9,%r8)
movdqu %xmm0, (%r9,%r8)
movq %rcx, 0x30(%r9,%r8)
addq $0x38, %r8
jmp 0x10efeb
movq %rsi, 0x40(%r15)
movq %rax, 0x38(%r15)
movq 0x28(%r15), %rcx
leaq 0xdd(%rip), %rsi        # 0x10f103
movq %r15, %rdx
callq 0xc67c0
movl 0x8(%r15), %eax
imulq $0x38, %rax, %rax
pushq $-0x1
popq %rdx
xorl %ecx, %ecx
movq 0x50(%rsp), %r8
cmpq %rcx, %rax
je 0x10f0cd
movq 0x30(%r15), %rsi
movq (%rsi,%rcx), %rdi
cmpq $-0x1, %rdi
je 0x10f0c4
cmpq $-0x1, 0x8(%rsi,%rcx)
je 0x10f0c4
cmpq $-0x1, 0x10(%rsi,%rcx)
je 0x10f0c4
cmpq $-0x1, 0x18(%rsi,%rcx)
je 0x10f0c4
cmpq $-0x1, 0x20(%rsi,%rcx)
je 0x10f0c4
movsd (%r12), %xmm1
movsd 0x30(%rsi,%rcx), %xmm0
ucomisd %xmm0, %xmm1
ja 0x10f094
jne 0x10f0c4
jp 0x10f0c4
cmpq %rdx, 0x28(%rsi,%rcx)
jge 0x10f0c4
movsd %xmm0, (%r12)
movq %rdi, (%r14)
movq 0x8(%rsi,%rcx), %rdx
movq %rdx, (%rbx)
movq 0x10(%rsi,%rcx), %rdx
movq %rdx, (%rbp)
movq 0x18(%rsi,%rcx), %rdx
movq %rdx, (%r13)
movq 0x20(%rsi,%rcx), %rdx
movq %rdx, (%r8)
movq 0x28(%rsi,%rcx), %rdx
addq $0x38, %rcx
jmp 0x10f040
cmpq $-0x1, (%r14)
je 0x10f0f2
cmpq $-0x1, (%rbx)
je 0x10f0f2
cmpq $-0x1, (%rbp)
je 0x10f0f2
cmpq $-0x1, (%r13)
je 0x10f0f2
cmpq $-0x1, (%r8)
je 0x10f0f2
pushq $0x1
popq %rax
jmp 0x10f0f4
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq