// File: /workspace/github_cpp_makefile_star2_O1/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), %rdx
movq 0x48(%rsp), %r8
movq 0x40(%rsp), %r9
movabsq $0x3ff0000000000000, %rcx # imm = 0x3FF0000000000000
movq %rcx, (%r12)
movq $-0x1, %rax
movq %rax, (%rdx)
movq %r8, %rbp
movq %rax, (%r8)
movq %r9, %r13
movq %rax, (%r9)
movq %rax, (%rbx)
movq %rax, (%r14)
movl 0x8(%r15), %eax
testq %rax, %rax
je 0x14fc3a
movq 0x30(%r15), %rdx
imulq $0x38, %rax, %r8
xorl %r9d, %r9d
pcmpeqd %xmm0, %xmm0
movdqu %xmm0, 0x20(%rdx,%r9)
movdqu %xmm0, 0x10(%rdx,%r9)
movdqu %xmm0, (%rdx,%r9)
movq %rcx, 0x30(%rdx,%r9)
addq $0x38, %r9
cmpq %r9, %r8
jne 0x14fc18
movq %rsi, 0x40(%r15)
movq %rdi, 0x38(%r15)
movq 0x28(%r15), %rcx
leaq 0xe9(%rip), %rsi        # 0x14fd36
movl %eax, %edi
movq %r15, %rdx
callq 0x1047b4
movl 0x8(%r15), %ecx
testq %rcx, %rcx
movq 0x50(%rsp), %r8
je 0x14fd00
movq 0x30(%r15), %rax
imulq $0x38, %rcx, %rcx
movq $-0x1, %rsi
xorl %edx, %edx
movq (%rax,%rdx), %rdi
cmpq $-0x1, %rdi
je 0x14fcf3
cmpq $-0x1, 0x8(%rax,%rdx)
je 0x14fcf3
cmpq $-0x1, 0x10(%rax,%rdx)
je 0x14fcf3
cmpq $-0x1, 0x18(%rax,%rdx)
je 0x14fcf3
cmpq $-0x1, 0x20(%rax,%rdx)
je 0x14fcf3
movsd (%r12), %xmm0
ucomisd 0x30(%rax,%rdx), %xmm0
ja 0x14fcbd
jne 0x14fcf3
jp 0x14fcf3
cmpq %rsi, 0x28(%rax,%rdx)
jge 0x14fcf3
movsd 0x30(%rax,%rdx), %xmm0
movsd %xmm0, (%r12)
movq %rdi, (%r14)
movq 0x8(%rax,%rdx), %rsi
movq %rsi, (%rbx)
movq 0x10(%rax,%rdx), %rsi
movq %rsi, (%r13)
movq 0x18(%rax,%rdx), %rsi
movq %rsi, (%rbp)
movq 0x20(%rax,%rdx), %rsi
movq %rsi, (%r8)
movq 0x28(%rax,%rdx), %rsi
addq $0x38, %rdx
cmpq %rdx, %rcx
jne 0x14fc7a
cmpq $-0x1, (%r14)
je 0x14fd25
cmpq $-0x1, (%rbx)
je 0x14fd25
cmpq $-0x1, (%r13)
je 0x14fd25
cmpq $-0x1, (%rbp)
je 0x14fd25
movl $0x1, %eax
cmpq $-0x1, (%r8)
jne 0x14fd27
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq