// File: /workspace/github_cpp_makefile_star2_O1/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 0x4ab39(%rip), %rcx     # 0x90711
leaq 0x10(%rsp), %r14
movl $0x1, %esi
movq %r14, %rdx
callq 0x1a520
movq %rax, %r15
movq (%r14), %rax
movq 0x48(%rax), %rax
cmpq $0x0, 0x1c0(%rax)
je 0x45c3a
leaq 0x24(%rsp), %r12
movq %rbx, %rdi
movl $0x20, %esi
movq %r12, %rdx
callq 0x19ab0
movq %rax, %r14
cmpl $0x0, (%r12)
je 0x45c4d
movl $0x120, %edx            # imm = 0x120
movq %rbx, %rdi
movq %r14, %rsi
movl $0x20, %ecx
movl $0x1, %r8d
callq 0x19800
jmp 0x45c9f
leaq 0x5c8a2(%rip), %rsi     # 0xa24e3
movq %rbx, %rdi
xorl %eax, %eax
callq 0x19be0
jmp 0x45ca7
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x187e0
movq 0x10(%rsp), %rax
movq 0x48(%rax), %rax
leaq 0x8(%rsp), %rsi
movq %r15, %rdi
xorl %edx, %edx
callq *0x1c0(%rax)
testl %eax, %eax
je 0x45cba
movl %eax, %ebp
movl $0x120, %edx            # imm = 0x120
movq %rbx, %rdi
movq %r14, %rsi
movl $0x20, %ecx
movl $0x1, %r8d
callq 0x19800
movq %rbx, %rdi
xorl %esi, %esi
movl %ebp, %edx
callq 0x18990
movq %rbx, %rdi
callq 0x199e0
movl %eax, %ebp
movl %ebp, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x0, 0x8(%rsp)
je 0x45d73
xorl %r13d, %r13d
movq %r14, 0x18(%rsp)
movl 0x8(%rsp), %eax
cmpl $0x21, %eax
jb 0x45ce3
movl $0x20, 0xc(%rsp)
addl $-0x20, %eax
jmp 0x45ce9
movl %eax, 0xc(%rsp)
xorl %eax, %eax
movl %eax, 0x8(%rsp)
movq 0x10(%rsp), %rax
movq 0x48(%rax), %rax
movq %r15, %rdi
leaq 0xc(%rsp), %rsi
movq %r14, %rdx
callq *0x1c0(%rax)
testl %eax, %eax
je 0x45d16
movl %eax, %ebp
cmpl $0x5, %eax
jne 0x45c78
cmpl $0x0, 0xc(%rsp)
je 0x45d68
movq %r13, %r12
movl %r13d, %ebp
movq %r14, %r13
xorl %r14d, %r14d
movq %rbx, %rdi
movq %r13, %rsi
movq %r15, %rdx
callq 0x18110
leal (%r14,%rbp), %edx
incl %edx
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x19140
incq %r14
movl 0xc(%rsp), %eax
addq $0x120, %r13            # imm = 0x120
cmpq %rax, %r14
jb 0x45d29
movq %r12, %r13
addl %r14d, %r13d
movq 0x18(%rsp), %r14
cmpl $0x0, 0x8(%rsp)
jne 0x45ccd
movl $0x1, %ebp
movl $0x120, %edx            # imm = 0x120
movq %rbx, %rdi
movq %r14, %rsi
movl $0x20, %ecx
movl $0x1, %r8d
callq 0x19800
jmp 0x45ca9