// File: /workspace/github_c_makefile_star2_O3/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 0x20522a(%rip), %rax    # 0x20c28c
cmpq $0x2, %rax
jl 0x72c1
imulq $0xc088, %rax, %rcx     # imm = 0xC088
addq $-0xc088, %rcx          # imm = 0xFFFF3F78
xorl %edx, %edx
leaq 0x20521d(%rip), %r14    # 0x20c2a0
xorl %ebx, %ebx
movslq 0x17098(%rdx,%r14), %rsi
addq %rsi, %rbx
addq $0xc088, %rdx           # imm = 0xC088
cmpq %rdx, %rcx
jne 0x7085
testq %rbx, %rbx
je 0x72c1
movq %rdi, -0x58(%rbp)
cmpl $0x3, 0x5170(%rip)      # 0xc220
jge 0x72dc
movq %rsp, -0x50(%rbp)
movq %rsp, %rdx
leaq 0xf(,%rbx,8), %rcx
andq $-0x10, %rcx
subq %rcx, %rdx
movq %rdx, -0x40(%rbp)
movq %rdx, %rsp
movl $0x1, %edx
cmpl $0x2, %eax
jl 0x71db
movq %rbx, -0x48(%rbp)
xorl %esi, %esi
movl $0x1, %edx
leaq 0x211245(%rip), %rdi    # 0x218338
imulq $0xc088, %rdx, %r13     # imm = 0xC088
cmpl $0x0, 0xb010(%r13,%r14)
jle 0x71c1
movq %rdx, -0x30(%rbp)
addq %r14, %r13
movq %rsi, -0x68(%rbp)
movslq %esi, %rax
movq -0x40(%rbp), %rcx
leaq (%rcx,%rax,8), %r12
movq %rdi, -0x60(%rbp)
movq %rdi, %r14
xorl %r15d, %r15d
leaq 0xe0f998(%rip), %rdi    # 0xe16ac8
callq 0x2370
movq %r13, %rbx
movl 0xb018(%r13), %ecx
subq $0x8, %rsp
movq %r14, %rdi
movl $0xb0, %esi
movq 0x4e9e(%rip), %rdx      # 0xbff0
movl %r15d, %r8d
movq 0x4e74(%rip), %r9       # 0xbfd0
pushq %r12
callq 0x20f0
addq $0x10, %rsp
movl %eax, %r13d
leaq 0xe0f957(%rip), %rdi    # 0xe16ac8
callq 0x23b0
testl %r13d, %r13d
je 0x7188
cmpl $0x0, 0x509e(%rip)      # 0xc220
jns 0x7323
incq %r15
movq %rbx, %r13
movslq 0xb010(%rbx), %rax
addq $0x8, %r12
addq $0xb0, %r14
cmpq %rax, %r15
jl 0x7129
movq -0x68(%rbp), %rsi
addl %r15d, %esi
movl 0x2050da(%rip), %eax    # 0x20c28c
movq -0x30(%rbp), %rdx
leaq 0x2050e3(%rip), %r14    # 0x20c2a0
movq -0x60(%rbp), %rdi
incq %rdx
movslq %eax, %rcx
addq $0xc088, %rdi           # imm = 0xC088
cmpq %rcx, %rdx
jl 0x70f3
movq -0x48(%rbp), %rbx
movq %rdx, -0x30(%rbp)
testl %ebx, %ebx
je 0x72c5
testb $0x1, 0xe1095a(%rip)    # 0xe17b48
jne 0x72c5
movq %rbx, %r13
leaq 0xe0f8ca(%rip), %r12    # 0xe16ac8
leaq -0x80(%rbp), %rbx
movl %r13d, %r15d
movq %r12, %rdi
callq 0x2370
movl %r13d, %edi
movq -0x40(%rbp), %rsi
leaq -0x38(%rbp), %rdx
leaq -0x34(%rbp), %rcx
movq %rbx, %r8
callq 0x2180
movl %eax, %r14d
movq %r12, %rdi
callq 0x23b0
testl %r14d, %r14d
setne %cl
movl 0x4fe5(%rip), %eax      # 0xc220
testl %eax, %eax
setns %dl
andb %cl, %dl
cmpb $0x1, %dl
je 0x732b
cmpl $0xffff8002, -0x38(%rbp) # imm = 0xFFFF8002
je 0x7261
decl %r15d
cmpl $0x3, %eax
jge 0x727b
callq 0x777c
movl $0x2710, %edi           # imm = 0x2710
callq 0x21f0
testl %r15d, %r15d
je 0x72c5
testb $0x1, 0xe108d1(%rip)    # 0xe17b48
je 0x7205
jmp 0x72c5
movq 0x4d5e(%rip), %rax      # 0xbfe0
movq (%rax), %rdi
movl 0x4fdc(%rip), %r8d      # 0xc268
movl -0x34(%rbp), %r10d
leaq 0x20d4(%rip), %rsi      # 0x936b
leaq 0xf4d(%rip), %rdx       # 0x81eb
leaq 0x2065(%rip), %rcx      # 0x930a
movl $0xb09, %r9d            # imm = 0xB09
xorl %eax, %eax
pushq %r15
pushq %r10
pushq %r14
pushq -0x30(%rbp)
callq 0x2390
addq $0x20, %rsp
jmp 0x725c
xorl %eax, %eax
jmp 0x72cd
movq -0x50(%rbp), %rsp
movq -0x58(%rbp), %rax
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x4cfd(%rip), %rax      # 0xbfe0
movq (%rax), %rdi
movl 0x4f7b(%rip), %r8d      # 0xc268
subq $0x8, %rsp
leaq 0x1fe6(%rip), %rsi      # 0x92de
leaq 0xeec(%rip), %rdx       # 0x81eb
leaq 0x2004(%rip), %rcx      # 0x930a
movl $0xae0, %r9d            # imm = 0xAE0
xorl %eax, %eax
pushq %rbx
callq 0x2390
addq $0x10, %rsp
movl 0x204f6e(%rip), %eax    # 0x20c28c
jmp 0x70b6
movl %r13d, %edi
callq 0x2951
movl %r14d, %edi
callq 0x290f