// File: /workspace/github_c_makefile_star2_O0/00pauln00[P]yapio/yapio.c
// Function: yapio_test_groups_setup_nranks
static int
yapio_test_groups_setup_nranks(void)
{
    int i;
    int num_test_groups_without_nranks = 0;
    int num_ranks_counted = 0;

    for (i = 0; i < yapioNumTestGroups; i++)
    {
        yapio_test_group_t *ytg = &yapioTestGroups[i];

        if (!ytg->ytg_num_ranks)
            num_test_groups_without_nranks++;
        else
            num_ranks_counted += ytg->ytg_num_ranks;
    }

    /* If the user specified num_ranks for each test group then the tally
     * must match the num_ranks value reported by MPI.
     */
    if (!num_test_groups_without_nranks && num_ranks_counted != yapioNumRanks)
    {
        log_msg_r0(YAPIO_LL_ERROR,
                   "Test group rank tally (%d) does not match mpi nranks (%d)",
                   num_ranks_counted, yapioNumRanks);
        return -EINVAL;
    }

    bool slack_assigned = false;
    int num_ranks_recounted = 0;

    for (i = 0; i < yapioNumTestGroups; i++)
    {
        yapio_test_group_t *ytg = &yapioTestGroups[i];

        if (!ytg->ytg_num_ranks)
        {
            /* Divvy the remaining unassigned ranks amongst the test groups
             * which were not explicitly assigned rank counts.
             */
            ytg->ytg_num_ranks = ((yapioNumRanks - num_ranks_counted) /
                                  num_test_groups_without_nranks);
            if (!slack_assigned)
            {
                ytg->ytg_num_ranks += ((yapioNumRanks - num_ranks_counted) %
                                       num_test_groups_without_nranks);
                slack_assigned = true;
            }

            /* Ensure there are enough ranks to cover all test groups.
             */
            if (!ytg->ytg_num_ranks)
            {
                log_msg(YAPIO_LL_ERROR,
                        "No available ranks for test group %d", i);

                return -EINVAL;
            }
        }

        int rc = yapio_test_group_mpi_group_init(num_ranks_recounted, ytg);
        if (rc)
            return rc;

        num_ranks_recounted += ytg->ytg_num_ranks;
    }

    /* Sanity check.
     */
    if (num_ranks_recounted != yapioNumRanks)
        log_msg(YAPIO_LL_FATAL,
                "num_ranks_recounted (%d) != yapioNumRanks (%d)",
                num_ranks_recounted, yapioNumRanks);

    return 0;
}

// Assembly:
subq $0x58, %rsp
movl $0x0, 0x4c(%rsp)
movl $0x0, 0x48(%rsp)
movl $0x0, 0x50(%rsp)
movl 0x50(%rsp), %eax
cmpl 0x209e86(%rip), %eax    # 0x20f2bc
jge 0x5490
movslq 0x50(%rsp), %rcx
leaq 0x209e8c(%rip), %rax    # 0x20f2d0
imulq $0xc088, %rcx, %rcx     # imm = 0xC088
addq %rcx, %rax
movq %rax, 0x40(%rsp)
movq 0x40(%rsp), %rax
cmpl $0x0, 0xb01c(%rax)
jne 0x546e
movl 0x4c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x4c(%rsp)
jmp 0x5481
movq 0x40(%rsp), %rax
movl 0xb01c(%rax), %eax
addl 0x48(%rsp), %eax
movl %eax, 0x48(%rsp)
jmp 0x5483
movl 0x50(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x50(%rsp)
jmp 0x542c
cmpl $0x0, 0x4c(%rsp)
jne 0x5524
movl 0x48(%rsp), %eax
cmpl 0x209dfb(%rip), %eax    # 0x20f2a0
je 0x5524
callq 0x5910
testb $0x1, %al
jne 0x54b2
jmp 0x5517
movl $0x1, %eax
cmpl 0x9d53(%rip), %eax      # 0xf210
jg 0x5515
movq 0x9b1a(%rip), %rax      # 0xefe0
movq (%rax), %rax
movq %rax, 0x20(%rsp)
movl $0x1, %edi
callq 0x4890
movq 0x20(%rsp), %rdi
movq %rax, %rdx
movl 0x9da9(%rip), %r8d      # 0xf290
movl 0x48(%rsp), %r10d
movl 0x209dae(%rip), %eax    # 0x20f2a0
leaq 0x683a(%rip), %rsi      # 0xbd33
leaq 0x687c(%rip), %rcx      # 0xbd7c
movl $0x3b4, %r9d            # imm = 0x3B4
movl %r10d, (%rsp)
movl %eax, 0x8(%rsp)
movb $0x0, %al
callq 0x2370
jmp 0x5517
movl $0xffffffea, 0x54(%rsp) # imm = 0xFFFFFFEA
jmp 0x56f8
movb $0x0, 0x3f(%rsp)
movl $0x0, 0x38(%rsp)
movl $0x0, 0x50(%rsp)
movl 0x50(%rsp), %eax
cmpl 0x209d79(%rip), %eax    # 0x20f2bc
jge 0x567b
movslq 0x50(%rsp), %rcx
leaq 0x209d7b(%rip), %rax    # 0x20f2d0
imulq $0xc088, %rcx, %rcx     # imm = 0xC088
addq %rcx, %rax
movq %rax, 0x30(%rsp)
movq 0x30(%rsp), %rax
cmpl $0x0, 0xb01c(%rax)
jne 0x5632
movl 0x209d24(%rip), %eax    # 0x20f2a0
subl 0x48(%rsp), %eax
cltd
idivl 0x4c(%rsp)
movl %eax, %ecx
movq 0x30(%rsp), %rax
movl %ecx, 0xb01c(%rax)
testb $0x1, 0x3f(%rsp)
jne 0x55be
movl 0x209d01(%rip), %eax    # 0x20f2a0
subl 0x48(%rsp), %eax
cltd
idivl 0x4c(%rsp)
movq 0x30(%rsp), %rax
addl 0xb01c(%rax), %edx
movl %edx, 0xb01c(%rax)
movb $0x1, 0x3f(%rsp)
movq 0x30(%rsp), %rax
cmpl $0x0, 0xb01c(%rax)
jne 0x5630
movl $0x1, %eax
cmpl 0x9c39(%rip), %eax      # 0xf210
jg 0x5623
movq 0x9a00(%rip), %rax      # 0xefe0
movq (%rax), %rax
movq %rax, 0x18(%rsp)
movl $0x1, %edi
callq 0x4890
movq 0x18(%rsp), %rdi
movq %rax, %rdx
movl 0x9c8f(%rip), %r8d      # 0xf290
movl 0x50(%rsp), %eax
leaq 0x678f(%rip), %rsi      # 0xbd9b
leaq 0x6769(%rip), %rcx      # 0xbd7c
movl $0x3d2, %r9d            # imm = 0x3D2
movl %eax, (%rsp)
movb $0x0, %al
callq 0x2370
movl $0xffffffea, 0x54(%rsp) # imm = 0xFFFFFFEA
jmp 0x56f8
jmp 0x5632
movl 0x38(%rsp), %edi
movq 0x30(%rsp), %rsi
callq 0x5a60
movl %eax, 0x2c(%rsp)
cmpl $0x0, 0x2c(%rsp)
je 0x5658
movl 0x2c(%rsp), %eax
movl %eax, 0x54(%rsp)
jmp 0x56f8
movq 0x30(%rsp), %rax
movl 0xb01c(%rax), %eax
addl 0x38(%rsp), %eax
movl %eax, 0x38(%rsp)
movl 0x50(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x50(%rsp)
jmp 0x5539
movl 0x38(%rsp), %eax
cmpl 0x209c1b(%rip), %eax    # 0x20f2a0
je 0x56f0
xorl %eax, %eax
cmpl 0x9b81(%rip), %eax      # 0xf210
jg 0x56ee
movq 0x9948(%rip), %rax      # 0xefe0
movq (%rax), %rax
movq %rax, 0x10(%rsp)
xorl %edi, %edi
callq 0x4890
movq 0x10(%rsp), %rdi
movq %rax, %rdx
movl 0x9bda(%rip), %r8d      # 0xf290
movl 0x38(%rsp), %r10d
movl 0x209bdf(%rip), %eax    # 0x20f2a0
leaq 0x6707(%rip), %rsi      # 0xbdcf
leaq 0x66ad(%rip), %rcx      # 0xbd7c
movl $0x3e4, %r9d            # imm = 0x3E4
movl %r10d, (%rsp)
movl %eax, 0x8(%rsp)
movb $0x0, %al
callq 0x2370
movl $0x1, %edi
callq 0x40f0
jmp 0x56f0
movl $0x0, 0x54(%rsp)
movl 0x54(%rsp), %eax
addq $0x58, %rsp
retq
nopw %cs:(%rax,%rax)