// File: /workspace/github_c_makefile_star2_O2/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 $0x68, %rsp
movslq 0x205c49(%rip), %rax    # 0x20c28c
pushq $0x1
popq %rcx
leaq 0x21cceb(%rip), %rdx    # 0x223338
xorl %ebx, %ebx
cmpq %rax, %rcx
jge 0x6666
movslq (%rdx), %rsi
addq %rsi, %rbx
incq %rcx
addq $0xc088, %rdx           # imm = 0xC088
jmp 0x664f
testq %rbx, %rbx
je 0x6863
movq %rdi, -0x58(%rbp)
cmpl $0x3, 0x5b9e(%rip)      # 0xc218
jge 0x6874
movq %rsp, -0x50(%rbp)
movq %rsp, %rcx
movq %rbx, -0x38(%rbp)
leaq 0xf(,%rbx,8), %rax
andq $-0x10, %rax
subq %rax, %rcx
movq %rcx, -0x48(%rbp)
movq %rcx, %rsp
pushq $0x1
popq %r14
leaq 0x211c8c(%rip), %rax    # 0x218338
movq %rax, -0x40(%rbp)
xorl %ecx, %ecx
movslq 0x205bd3(%rip), %rax    # 0x20c28c
cmpq %rax, %r14
jge 0x6786
movq %r14, -0x68(%rbp)
imulq $0xc088, %r14, %r12     # imm = 0xC088
leaq 0x205bcc(%rip), %rax    # 0x20c2a0
addq %rax, %r12
movslq %ecx, %rcx
movq -0x48(%rbp), %rax
movq %rcx, -0x60(%rbp)
leaq (%rax,%rcx,8), %rbx
movq -0x40(%rbp), %r14
xorl %r15d, %r15d
movq %r12, -0x70(%rbp)
movslq 0xb010(%r12), %rax
cmpq %rax, %r15
jge 0x676b
leaq 0xe103c3(%rip), %r13    # 0xe16ac8
movq %r13, %rdi
callq 0x2360
movl 0xb018(%r12), %ecx
subq $0x8, %rsp
movq %r14, %rdi
movl $0xb0, %esi
movq 0x58c8(%rip), %rdx      # 0xbff0
movl %r15d, %r8d
movq 0x589e(%rip), %r9       # 0xbfd0
pushq %rbx
callq 0x20e0
popq %rcx
popq %rdx
movl %eax, %r12d
movq %r13, %rdi
callq 0x23a0
testl %r12d, %r12d
je 0x6757
cmpl $0x0, 0x5ac7(%rip)      # 0xc218
jns 0x68b3
incq %r15
addq $0xb0, %r14
addq $0x8, %rbx
movq -0x70(%rbp), %r12
jmp 0x66f1
movq -0x68(%rbp), %r14
incq %r14
addq $0xc088, -0x40(%rbp)    # imm = 0xC088
movq -0x60(%rbp), %rcx
addq %r15, %rcx
jmp 0x66b2
leaq 0xe1033b(%rip), %r12    # 0xe16ac8
leaq -0x88(%rbp), %r13
movq -0x38(%rbp), %r15
testl %r15d, %r15d
je 0x6859
testb $0x1, 0xe113a0(%rip)    # 0xe17b48
jne 0x6859
movq %r12, %rdi
callq 0x2360
movq -0x38(%rbp), %rdi
movq -0x48(%rbp), %rsi
leaq -0x30(%rbp), %rdx
leaq -0x2c(%rbp), %rcx
movq %r13, %r8
callq 0x2170
movl %eax, %ebx
movq %r12, %rdi
callq 0x23a0
testl %ebx, %ebx
setne %cl
movl 0x5a35(%rip), %eax      # 0xc218
testl %eax, %eax
setns %dl
andb %cl, %dl
cmpb $0x1, %dl
je 0x68f6
cmpl $0xffff8002, -0x30(%rbp) # imm = 0xFFFF8002
je 0x6809
decl %r15d
cmpl $0x3, %eax
jge 0x6815
callq 0x6d7e
movl $0x2710, %edi           # imm = 0x2710
callq 0x21e0
jmp 0x6798
movq 0x57c4(%rip), %rax      # 0xbfe0
movq (%rax), %rdi
movl 0x5a42(%rip), %r8d      # 0xc268
movl -0x2c(%rbp), %r10d
leaq 0x2afe(%rip), %rsi      # 0x932f
leaq 0x1977(%rip), %rdx      # 0x81af
leaq 0x2a8f(%rip), %rcx      # 0x92ce
movl $0xb09, %r9d            # imm = 0xB09
xorl %eax, %eax
pushq %r15
pushq %r10
pushq %rbx
pushq %r14
callq 0x2380
addq $0x20, %rsp
jmp 0x6804
movq -0x50(%rbp), %rsp
movq -0x58(%rbp), %rax
jmp 0x6865
xorl %eax, %eax
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x5765(%rip), %rax      # 0xbfe0
movq (%rax), %rdi
movl 0x59e3(%rip), %r8d      # 0xc268
subq $0x8, %rsp
leaq 0x2a12(%rip), %rsi      # 0x92a2
leaq 0x1918(%rip), %rdx      # 0x81af
leaq 0x2a30(%rip), %rcx      # 0x92ce
movl $0xae0, %r9d            # imm = 0xAE0
xorl %eax, %eax
pushq %rbx
callq 0x2380
popq %rcx
popq %rdx
jmp 0x6680
movq 0x5726(%rip), %rax      # 0xbfe0
movq (%rax), %rdi
movl 0x59a4(%rip), %r8d      # 0xc268
subq $0x8, %rsp
leaq 0x2a16(%rip), %rsi      # 0x92e5
leaq 0x18c2(%rip), %rdx      # 0x8198
leaq 0x29f1(%rip), %rcx      # 0x92ce
movl $0xaf2, %r9d            # imm = 0xAF2
xorl %eax, %eax
pushq %r12
callq 0x2380
popq %rcx
popq %rdx
pushq $0x1
popq %rdi
callq 0x5874
movq 0x56e3(%rip), %rax      # 0xbfe0
movq (%rax), %rdi
movl 0x5961(%rip), %r8d      # 0xc268
subq $0x8, %rsp
leaq 0x29f7(%rip), %rsi      # 0x9309
leaq 0x187f(%rip), %rdx      # 0x8198
leaq 0x29ae(%rip), %rcx      # 0x92ce
movl $0xb02, %r9d            # imm = 0xB02
xorl %eax, %eax
pushq %rbx
jmp 0x68e7