// File: /workspace/github_c_makefile_star2_O1/00pauln00[P]yapio/yapio.c
// Function: yapio_stats_collection
static void *
yapio_stats_collection(void *unused_arg)
{
    ssize_t num_remote_test_contexts;
    int i;
    /* Skip the first group since the leader rank is 'this' rank.
     */
    for (i = 1, num_remote_test_contexts = 0; i < yapioNumTestGroups; i++)
        num_remote_test_contexts += yapioTestGroups[i].ytg_num_contexts;

    if (!num_remote_test_contexts)
        return NULL;

    log_msg(YAPIO_LL_DEBUG, "num_remote_test_contexts=%zd",
            num_remote_test_contexts);

    MPI_Request requests[num_remote_test_contexts];

    int req_num;
    for (i = 1, req_num = 0; i < yapioNumTestGroups; i++)
    {
        yapio_test_group_t *ytg = &yapioTestGroups[i];
        int j;
        for (j = 0; j < ytg->ytg_num_contexts; j++)
        {
            MPI_OP_START;
            int rc = MPI_Irecv(&ytg->ytg_contexts[j], sizeof(yapio_test_ctx_t),
                               MPI_BYTE, ytg->ytg_first_rank, j,
                               MPI_COMM_WORLD, &requests[req_num++]);
            MPI_OP_END;

            if (rc != MPI_SUCCESS)
                log_msg(YAPIO_LL_FATAL, "MPI_Irecv failed: %d", rc);
        }
    }

    int remaining_reports = num_remote_test_contexts;
    while (remaining_reports && !yapioHaltStonewallThread)
    {
        int index, flag;
        MPI_Status status;

        MPI_OP_START;
        int rc = MPI_Testany(num_remote_test_contexts, requests, &index, &flag,
                             &status);
        MPI_OP_END;

        if (rc != MPI_SUCCESS)
            log_msg(YAPIO_LL_FATAL, "MPI_Testany failed: %d", rc);

        if (index != MPI_UNDEFINED)
        {
            remaining_reports--;

            log_msg(YAPIO_LL_DEBUG, "index=%d rc=%d flag=%d rem=%d",
                    i, rc, flag, remaining_reports);

            yapio_stat_ready();
        }

        usleep(YAPIO_STATS_SLEEP_USEC);
    }

    return unused_arg;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movslq 0x2060d5(%rip), %rax    # 0x20d28c
cmpq $0x2, %rax
jl 0x71ef
imulq $0xc088, %rax, %rax     # imm = 0xC088
addq $-0xc088, %rax          # imm = 0xFFFF3F78
xorl %ecx, %ecx
leaq 0x2060cd(%rip), %rdx    # 0x20d2a0
xorl %r14d, %r14d
movslq 0x17098(%rcx,%rdx), %rsi
addq %rsi, %r14
addq $0xc088, %rcx           # imm = 0xC088
cmpq %rcx, %rax
jne 0x71d6
jmp 0x71f2
xorl %r14d, %r14d
testq %r14, %r14
je 0x7421
movq %rdi, -0x58(%rbp)
cmpl $0x3, 0x601a(%rip)      # 0xd220
jge 0x7432
movq %rsp, -0x50(%rbp)
movq %rsp, %rcx
leaq 0xf(,%r14,8), %rax
andq $-0x10, %rax
subq %rax, %rcx
movq %rcx, -0x40(%rbp)
movq %rcx, %rsp
movl $0x1, %ecx
cmpl $0x2, 0x206057(%rip)    # 0x20d28c
jl 0x7337
movq %r14, -0x48(%rbp)
xorl %edx, %edx
movl $0x1, %ecx
leaq 0x2120eb(%rip), %r14    # 0x219338
leaq 0x20604c(%rip), %rsi    # 0x20d2a0
imulq $0xc088, %rcx, %r12     # imm = 0xC088
cmpl $0x0, 0xb010(%r12,%rsi)
jle 0x7319
movq %rcx, -0x30(%rbp)
addq %rsi, %r12
movq %rdx, -0x68(%rbp)
movslq %edx, %rax
movq -0x40(%rbp), %rcx
leaq (%rcx,%rax,8), %rbx
movq %r14, -0x60(%rbp)
xorl %r15d, %r15d
leaq 0xe1083a(%rip), %rdi    # 0xe17ac8
callq 0x2370
movq %r12, %r13
movl 0xb018(%r12), %ecx
subq $0x8, %rsp
movq %r14, %rdi
movl $0xb0, %esi
movq 0x5d3f(%rip), %rdx      # 0xcff0
movl %r15d, %r8d
movq 0x5d15(%rip), %r9       # 0xcfd0
pushq %rbx
callq 0x20f0
addq $0x10, %rsp
movl %eax, %r12d
leaq 0xe107f9(%rip), %rdi    # 0xe17ac8
callq 0x23b0
testl %r12d, %r12d
je 0x72e6
cmpl $0x0, 0x5f40(%rip)      # 0xd220
jns 0x743f
incq %r15
movq %r13, %r12
movslq 0xb010(%r13), %rax
addq $0x8, %rbx
addq $0xb0, %r14
cmpq %rax, %r15
jl 0x7287
movq -0x68(%rbp), %rdx
addl %r15d, %edx
movq -0x30(%rbp), %rcx
movq -0x60(%rbp), %r14
leaq 0x205f87(%rip), %rsi    # 0x20d2a0
incq %rcx
movslq 0x205f69(%rip), %rax    # 0x20d28c
addq $0xc088, %r14           # imm = 0xC088
cmpq %rax, %rcx
jl 0x7254
movq -0x48(%rbp), %r14
movq %rcx, -0x30(%rbp)
testl %r14d, %r14d
je 0x7417
testb $0x1, 0xe117fd(%rip)    # 0xe18b48
jne 0x7417
movq %r14, %rbx
leaq 0xe1076d(%rip), %r12    # 0xe17ac8
leaq -0x80(%rbp), %r13
movl %ebx, %r15d
movq %r12, %rdi
callq 0x2370
movl %ebx, %edi
movq -0x40(%rbp), %rsi
leaq -0x38(%rbp), %rdx
leaq -0x34(%rbp), %rcx
movq %r13, %r8
callq 0x2180
movl %eax, %r14d
movq %r12, %rdi
callq 0x23b0
testl %r14d, %r14d
je 0x739d
cmpl $0x0, 0x5e89(%rip)      # 0xd220
jns 0x7447
cmpl $0xffff8002, -0x38(%rbp) # imm = 0xFFFF8002
je 0x73b7
decl %r15d
cmpl $0x3, 0x5e70(%rip)      # 0xd220
jge 0x73d1
callq 0x78c4
movl $0x2710, %edi           # imm = 0x2710
callq 0x21f0
testl %r15d, %r15d
je 0x7417
testb $0x1, 0xe1177b(%rip)    # 0xe18b48
je 0x7362
jmp 0x7417
movq 0x5c08(%rip), %rax      # 0xcfe0
movq (%rax), %rdi
movl 0x5e86(%rip), %r8d      # 0xd268
movl -0x34(%rbp), %r10d
leaq 0x1f8e(%rip), %rsi      # 0x937b
leaq 0xe07(%rip), %rdx       # 0x81fb
leaq 0x1f1f(%rip), %rcx      # 0x931a
movl $0xb09, %r9d            # imm = 0xB09
xorl %eax, %eax
pushq %r15
pushq %r10
pushq %r14
pushq -0x30(%rbp)
callq 0x2390
addq $0x20, %rsp
jmp 0x73b2
movq -0x50(%rbp), %rsp
movq -0x58(%rbp), %rax
jmp 0x7423
xorl %eax, %eax
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r14, %rdi
callq 0x2962
jmp 0x720c
movl %r12d, %edi
callq 0x29e1
movl %r14d, %edi
callq 0x299f