// File: /workspace/github_cpp_makefile_star2_O2/stetre[P]moonvulkan/src/instance.c
// Function: EnumeratePhysicalDeviceGroups
static int EnumeratePhysicalDeviceGroups(lua_State *L)
    {
    int err;
    ud_t *ud;
    uint32_t count, remaining, tot, i;
    VkResult ec;
    VkPhysicalDeviceGroupPropertiesKHR* props;
    VkInstance instance = checkinstance(L, 1, &ud);
    CheckInstancePfn(L, ud, EnumeratePhysicalDeviceGroups);
#define CLEANUP zfreearrayVkPhysicalDeviceGroupPropertiesKHR(L, props, N, 1)
    props = znewchainarrayVkPhysicalDeviceGroupPropertiesKHR(L, N, &err);
    if(err) { CLEANUP; return lua_error(L); }
    lua_newtable(L);
    ec = ud->idt->EnumeratePhysicalDeviceGroups(instance, &remaining, NULL);
    if(ec) { CLEANUP; CheckError(L, ec); }
    if(remaining == 0) { CLEANUP; return 1; }

    tot = 0;
    do {
        if(remaining > N)
            { count = N; remaining -= N; }
        else
            { count = remaining; remaining = 0; }
        ec = ud->idt->EnumeratePhysicalDeviceGroups(instance, &count, props);
        if(ec && ec != VK_INCOMPLETE) { CLEANUP; CheckError(L, ec); }

        for(i=0; i<count; i++)
            {
            zpushVkPhysicalDeviceGroupPropertiesKHR(L, &props[i], instance);
            lua_rawseti(L, -2, ++tot);
            }
    } while(remaining > 0);

    CLEANUP;
#undef CLEANUP
    return 1;
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %rbx
leaq 0x3b9a4(%rip), %rcx     # 0x7e711
pushq $0x1
popq %rsi
leaq 0x10(%rsp), %r14
movq %r14, %rdx
callq 0x1a500
movq %rax, %r15
movq (%r14), %rax
movq 0x48(%rax), %rax
cmpq $0x0, 0x1c0(%rax)
je 0x42dca
pushq $0x20
popq %r12
leaq 0x24(%rsp), %r14
movq %rbx, %rdi
movl %r12d, %esi
movq %r14, %rdx
callq 0x19a90
movq %rax, %rbp
cmpl $0x0, (%r14)
je 0x42ddd
pushq $0x20
popq %rcx
pushq $0x1
popq %r8
movl $0x120, %edx            # imm = 0x120
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x197e0
jmp 0x42e2d
leaq 0x4d735(%rip), %rsi     # 0x90506
movq %rbx, %rdi
xorl %eax, %eax
callq 0x19bc0
jmp 0x42e35
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x187d0
movq 0x10(%rsp), %rax
movq 0x48(%rax), %rax
leaq 0x4(%rsp), %rsi
movq %r15, %rdi
xorl %edx, %edx
callq *0x1c0(%rax)
testl %eax, %eax
je 0x42e48
movl %eax, %r14d
pushq $0x20
popq %rcx
pushq $0x1
popq %r8
movl $0x120, %edx            # imm = 0x120
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x197e0
movq %rbx, %rdi
xorl %esi, %esi
movl %r14d, %edx
callq 0x18980
movq %rbx, %rdi
callq 0x199c0
movl %eax, %ebp
movl %ebp, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl 0x4(%rsp), %eax
testl %eax, %eax
je 0x42f12
pushq $-0x2
popq %r13
movl $0x0, 0x8(%rsp)
movq %rbp, 0x18(%rsp)
movl %eax, %ecx
subl $0x20, %ecx
cmovael %r12d, %eax
movl $0x0, %edx
cmovbl %edx, %ecx
movl %eax, 0xc(%rsp)
movl %ecx, 0x4(%rsp)
movq 0x10(%rsp), %rax
movq 0x48(%rax), %rax
movq %r15, %rdi
leaq 0xc(%rsp), %rsi
movq %rbp, %rdx
callq *0x1c0(%rax)
cmpl $0x5, %eax
je 0x42ea8
movl %eax, %r14d
testl %eax, %eax
jne 0x42e09
movl 0x8(%rsp), %r12d
movq %rbp, %r14
xorl %ebp, %ebp
movl 0xc(%rsp), %eax
cmpq %rax, %rbp
jae 0x42ee6
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x18110
leal (%r12,%rbp), %edx
incl %edx
movq %rbx, %rdi
movl %r13d, %esi
callq 0x19120
incq %rbp
addq $0x120, %r14            # imm = 0x120
jmp 0x42eb2
movl 0x4(%rsp), %eax
addl %ebp, 0x8(%rsp)
testl %eax, %eax
movq 0x18(%rsp), %rbp
pushq $0x20
popq %r12
jne 0x42e65
pushq $0x20
popq %rcx
movl $0x120, %edx            # imm = 0x120
movq %rbx, %rdi
movq %rbp, %rsi
pushq $0x1
popq %rbp
jmp 0x42f23
pushq $0x20
popq %rcx
movq %rbp, %rsi
pushq $0x1
popq %rbp
movl $0x120, %edx            # imm = 0x120
movq %rbx, %rdi
movl %ebp, %r8d
callq 0x197e0
jmp 0x42e37