// File: stetre[P]moonvulkan/src/display.c
// Function: GetPhysicalDeviceDisplayPlaneProperties1
static int GetPhysicalDeviceDisplayPlaneProperties1(lua_State *L, VkPhysicalDevice physdev, ud_t *ud)
    {
    int err;
    VkResult ec;
    uint32_t count, remaining, tot, i;
    VkDisplayPlanePropertiesKHR* properties; //[N];
#define CLEANUP zfreearrayVkDisplayPlanePropertiesKHR(L, properties, N, 1)
    properties = znewarrayVkDisplayPlanePropertiesKHR(L, N, &err);
    if(err) { CLEANUP; lua_error(L); }
    lua_newtable(L);
    ec = ud->idt->GetPhysicalDeviceDisplayPlanePropertiesKHR(physdev, &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->GetPhysicalDeviceDisplayPlanePropertiesKHR(physdev, &count, properties);
        if(ec && ec != VK_INCOMPLETE) { CLEANUP; CheckError(L, ec); }
    
        for(i = 0; i < count; i++)
            {
            zpushVkDisplayPlanePropertiesKHR(L, &properties[i]);
            if(properties[i].currentDisplay != VK_NULL_HANDLE)
                {
                pushdisplay(L, properties[i].currentDisplay, ud);
                lua_setfield(L, -2, "current_display");
                }
            lua_rawseti(L, -2, ++tot);
            }
        } while (remaining > 0);

    CLEANUP;
#undef CLEANUP
    return 1;
    }

// Assembly:
subq $0x48, %rsp
movq %rdi, 0x38(%rsp)
movq %rsi, 0x30(%rsp)
movq %rdx, 0x28(%rsp)
movq 0x38(%rsp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl $0x10, %edx
movl $0x20, %ecx
leaq 0x24(%rsp), %r8
callq 0x19920
movq %rax, 0x8(%rsp)
cmpl $0x0, 0x24(%rsp)
je 0x2dbab
movq 0x38(%rsp), %rdi
movq 0x8(%rsp), %rsi
movl $0x10, %edx
movl $0x20, %ecx
movl $0x1, %r8d
xorl %eax, %eax
movl %eax, %r9d
callq 0x18dd0
movq 0x38(%rsp), %rdi
callq 0x19ad0
movq 0x38(%rsp), %rdi
xorl %edx, %edx
movl %edx, %esi
callq 0x18830
movq 0x28(%rsp), %rax
movq 0x48(%rax), %rax
movq 0xa0(%rax), %rax
movq 0x30(%rsp), %rdi
leaq 0x18(%rsp), %rsi
xorl %ecx, %ecx
movl %ecx, %edx
callq *%rax
movl %eax, 0x20(%rsp)
cmpl $0x0, 0x20(%rsp)
je 0x2dc36
movq 0x38(%rsp), %rdi
movq 0x8(%rsp), %rsi
movl $0x10, %edx
movl $0x20, %ecx
movl $0x1, %r8d
xorl %eax, %eax
movl %eax, %r9d
callq 0x18dd0
cmpl $0x0, 0x20(%rsp)
je 0x2dc32
movq 0x38(%rsp), %rdi
movl 0x20(%rsp), %edx
xorl %esi, %esi
callq 0x18a00
movq 0x38(%rsp), %rdi
callq 0x19ad0
movl %eax, 0x44(%rsp)
jmp 0x2de0c
jmp 0x2dc34
jmp 0x2dc36
cmpl $0x0, 0x18(%rsp)
jne 0x2dc6e
movq 0x38(%rsp), %rdi
movq 0x8(%rsp), %rsi
movl $0x10, %edx
movl $0x20, %ecx
movl $0x1, %r8d
xorl %eax, %eax
movl %eax, %r9d
callq 0x18dd0
movl $0x1, 0x44(%rsp)
jmp 0x2de0c
movl $0x0, 0x14(%rsp)
cmpl $0x20, 0x18(%rsp)
jbe 0x2dc92
movl $0x20, 0x1c(%rsp)
movl 0x18(%rsp), %eax
subl $0x20, %eax
movl %eax, 0x18(%rsp)
jmp 0x2dca2
movl 0x18(%rsp), %eax
movl %eax, 0x1c(%rsp)
movl $0x0, 0x18(%rsp)
movq 0x28(%rsp), %rax
movq 0x48(%rax), %rax
movq 0xa0(%rax), %rax
movq 0x30(%rsp), %rdi
movq 0x8(%rsp), %rdx
leaq 0x1c(%rsp), %rsi
callq *%rax
movl %eax, 0x20(%rsp)
cmpl $0x0, 0x20(%rsp)
je 0x2dd27
cmpl $0x5, 0x20(%rsp)
je 0x2dd27
movq 0x38(%rsp), %rdi
movq 0x8(%rsp), %rsi
movl $0x10, %edx
movl $0x20, %ecx
movl $0x1, %r8d
xorl %eax, %eax
movl %eax, %r9d
callq 0x18dd0
cmpl $0x0, 0x20(%rsp)
je 0x2dd23
movq 0x38(%rsp), %rdi
movl 0x20(%rsp), %edx
xorl %esi, %esi
callq 0x18a00
movq 0x38(%rsp), %rdi
callq 0x19ad0
movl %eax, 0x44(%rsp)
jmp 0x2de0c
jmp 0x2dd25
jmp 0x2dd27
movl $0x0, 0x10(%rsp)
movl 0x10(%rsp), %eax
cmpl 0x1c(%rsp), %eax
jae 0x2ddd3
movq 0x38(%rsp), %rdi
movq 0x8(%rsp), %rsi
movl 0x10(%rsp), %eax
shlq $0x4, %rax
addq %rax, %rsi
callq 0x18630
movq 0x8(%rsp), %rax
movl 0x10(%rsp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
cmpq $0x0, (%rax)
je 0x2dda5
movq 0x38(%rsp), %rdi
movq 0x8(%rsp), %rax
movl 0x10(%rsp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rsi
movq 0x28(%rsp), %rdx
callq 0x2d720
movq 0x38(%rsp), %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
leaq 0xa3a1b(%rip), %rdx     # 0xd17bb
callq 0x18b80
movq 0x38(%rsp), %rdi
movl 0x14(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x14(%rsp)
movl %eax, %eax
movl %eax, %edx
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x191e0
movl 0x10(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x10(%rsp)
jmp 0x2dd2f
jmp 0x2ddd5
cmpl $0x0, 0x18(%rsp)
ja 0x2dc76
movq 0x38(%rsp), %rdi
movq 0x8(%rsp), %rsi
movl $0x10, %edx
movl $0x20, %ecx
movl $0x1, %r8d
xorl %eax, %eax
movl %eax, %r9d
callq 0x18dd0
movl $0x1, 0x44(%rsp)
movl 0x44(%rsp), %eax
addq $0x48, %rsp
retq
nopw %cs:(%rax,%rax)
nop