// File: stetre[P]moonvulkan/src/physical_device.c
// Function: GetPhysicalDeviceToolProperties
static int GetPhysicalDeviceToolProperties(lua_State *L)
    {
    int err;
    VkResult ec;
    uint32_t i, count = 0;
    ud_t *ud;
    VkPhysicalDeviceToolPropertiesEXT *props = NULL;
    VkPhysicalDevice physical_device = checkphysical_device(L, 1, &ud);
    CheckInstancePfn(L, ud, GetPhysicalDeviceToolPropertiesEXT);
    ec = ud->idt->GetPhysicalDeviceToolPropertiesEXT(physical_device, &count, NULL);
    if(ec) { CheckError(L, ec); return 0; }
    lua_newtable(L);
    if(count == 0) return 1;
#define CLEANUP zfreearrayVkPhysicalDeviceToolPropertiesEXT(L, props, count, 1)
    props = znewchainarrayVkPhysicalDeviceToolPropertiesEXT(L, count, &err);
    if(err) { CLEANUP; return lua_error(L); }
    ec = ud->idt->GetPhysicalDeviceToolPropertiesEXT(physical_device, &count, props);
    if(ec) { CLEANUP; CheckError(L, ec); return 0; }
    for(i=0; i<count; i++)
        {
        zpushVkPhysicalDeviceToolPropertiesEXT(L, &props[i]);
        lua_rawseti(L, -2, i+1);
        }
    CLEANUP;
#undef CLEANUP
    return 1;
    }

// Assembly:
subq $0x38, %rsp
movq %rdi, 0x28(%rsp)
movl $0x0, 0x18(%rsp)
movq $0x0, 0x8(%rsp)
movq 0x28(%rsp), %rdi
movl $0x1, %esi
leaq 0x10(%rsp), %rdx
leaq 0x744ac(%rip), %rcx     # 0xd0eac
callq 0x1a640
movq %rax, (%rsp)
movq 0x10(%rsp), %rax
movq 0x48(%rax), %rax
cmpq $0x0, 0x1f0(%rax)
jne 0x5ca38
movq 0x28(%rsp), %rdi
leaq 0x86034(%rip), %rsi     # 0xe2a5c
movb $0x0, %al
callq 0x19ce0
movl %eax, 0x34(%rsp)
jmp 0x5cc0c
jmp 0x5ca3a
movq 0x10(%rsp), %rax
movq 0x48(%rax), %rax
movq 0x1f0(%rax), %rax
movq (%rsp), %rdi
leaq 0x18(%rsp), %rsi
xorl %ecx, %ecx
movl %ecx, %edx
callq *%rax
movl %eax, 0x20(%rsp)
cmpl $0x0, 0x20(%rsp)
je 0x5ca9f
jmp 0x5ca66
cmpl $0x0, 0x20(%rsp)
je 0x5ca90
movq 0x28(%rsp), %rdi
movl 0x20(%rsp), %edx
xorl %esi, %esi
callq 0x18a00
movq 0x28(%rsp), %rdi
callq 0x19ad0
movl %eax, 0x34(%rsp)
jmp 0x5cc0c
jmp 0x5ca92
movl $0x0, 0x34(%rsp)
jmp 0x5cc0c
movq 0x28(%rsp), %rdi
xorl %edx, %edx
movl %edx, %esi
callq 0x18830
cmpl $0x0, 0x18(%rsp)
jne 0x5cac1
movl $0x1, 0x34(%rsp)
jmp 0x5cc0c
movq 0x28(%rsp), %rdi
movl 0x18(%rsp), %esi
leaq 0x24(%rsp), %rdx
callq 0x184e0
movq %rax, 0x8(%rsp)
cmpl $0x0, 0x24(%rsp)
je 0x5cb11
movq 0x28(%rsp), %rdi
movq 0x8(%rsp), %rsi
movl 0x18(%rsp), %ecx
movl $0x418, %edx            # imm = 0x418
movl $0x1, %r8d
callq 0x198d0
movq 0x28(%rsp), %rdi
callq 0x19ad0
movl %eax, 0x34(%rsp)
jmp 0x5cc0c
movq 0x10(%rsp), %rax
movq 0x48(%rax), %rax
movq 0x1f0(%rax), %rax
movq (%rsp), %rdi
movq 0x8(%rsp), %rdx
leaq 0x18(%rsp), %rsi
callq *%rax
movl %eax, 0x20(%rsp)
cmpl $0x0, 0x20(%rsp)
je 0x5cb90
movq 0x28(%rsp), %rdi
movq 0x8(%rsp), %rsi
movl 0x18(%rsp), %ecx
movl $0x418, %edx            # imm = 0x418
movl $0x1, %r8d
callq 0x198d0
cmpl $0x0, 0x20(%rsp)
je 0x5cb84
movq 0x28(%rsp), %rdi
movl 0x20(%rsp), %edx
xorl %esi, %esi
callq 0x18a00
movq 0x28(%rsp), %rdi
callq 0x19ad0
movl %eax, 0x34(%rsp)
jmp 0x5cc0c
jmp 0x5cb86
movl $0x0, 0x34(%rsp)
jmp 0x5cc0c
movl $0x0, 0x1c(%rsp)
movl 0x1c(%rsp), %eax
cmpl 0x18(%rsp), %eax
jae 0x5cbe6
movq 0x28(%rsp), %rdi
movq 0x8(%rsp), %rsi
movl 0x1c(%rsp), %eax
imulq $0x418, %rax, %rax      # imm = 0x418
addq %rax, %rsi
callq 0x197d0
movq 0x28(%rsp), %rdi
movl 0x1c(%rsp), %eax
addl $0x1, %eax
movl %eax, %eax
movl %eax, %edx
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x191e0
movl 0x1c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1c(%rsp)
jmp 0x5cb98
movq 0x28(%rsp), %rdi
movq 0x8(%rsp), %rsi
movl 0x18(%rsp), %ecx
movl $0x418, %edx            # imm = 0x418
movl $0x1, %r8d
callq 0x198d0
movl $0x1, 0x34(%rsp)
movl 0x34(%rsp), %eax
addq $0x38, %rsp
retq
nopw %cs:(%rax,%rax)