// File: stetre[P]moonvulkan/src/display.c
// Function: GetDisplayPlaneSupportedDisplays
static int GetDisplayPlaneSupportedDisplays(lua_State *L)
    {
    VkResult ec;
    uint32_t count, remaining, tot, i;
    VkDisplayKHR display[32];
    ud_t *ud;
    VkPhysicalDevice physdev = checkphysical_device(L, 1, &ud);
    uint32_t planeIndex = luaL_checkinteger(L, 2);

    CheckInstancePfn(L, ud, GetDisplayPlaneSupportedDisplaysKHR);

    lua_newtable(L);
    ec = ud->idt->GetDisplayPlaneSupportedDisplaysKHR(physdev, planeIndex, &remaining, NULL);
    CheckError(L, ec);
    if(remaining==0) return 1;
    tot = 0;
    do {
        if(remaining > 32)
            { count = 32; remaining -= 32; }
        else
            { count = remaining; remaining = 0; }

        ec = ud->idt->GetDisplayPlaneSupportedDisplaysKHR(physdev, planeIndex, &count, display);
        if(ec != VK_INCOMPLETE)
            CheckError(L, ec);
    
        for(i = 0; i < count; i++)
            {
            pushdisplay(L, display[i], ud);
            lua_rawseti(L, -2, ++tot);
            }
        } while (remaining > 0);

    return 1;
    }

// Assembly:
subq $0x148, %rsp            # imm = 0x148
movq %rdi, 0x138(%rsp)
movq 0x138(%rsp), %rdi
movl $0x1, %esi
leaq 0x18(%rsp), %rdx
leaq 0xa41f4(%rip), %rcx     # 0xd0eac
callq 0x1a640
movq %rax, 0x10(%rsp)
movq 0x138(%rsp), %rdi
movl $0x2, %esi
callq 0x19190
movl %eax, 0xc(%rsp)
movq 0x18(%rsp), %rax
movq 0x48(%rax), %rax
cmpq $0x0, 0xa8(%rax)
jne 0x2cd0d
movq 0x138(%rsp), %rdi
leaq 0xa4ad1(%rip), %rsi     # 0xd17cb
movb $0x0, %al
callq 0x19ce0
movl %eax, 0x144(%rsp)
jmp 0x2cef3
jmp 0x2cd0f
movq 0x138(%rsp), %rdi
xorl %edx, %edx
movl %edx, %esi
callq 0x18830
movq 0x18(%rsp), %rax
movq 0x48(%rax), %rax
movq 0xa8(%rax), %rax
movq 0x10(%rsp), %rdi
movl 0xc(%rsp), %esi
leaq 0x12c(%rsp), %rdx
xorl %ecx, %ecx
callq *%rax
movl %eax, 0x134(%rsp)
cmpl $0x0, 0x134(%rsp)
je 0x2cd85
movq 0x138(%rsp), %rdi
movl 0x134(%rsp), %edx
xorl %esi, %esi
callq 0x18a00
movq 0x138(%rsp), %rdi
callq 0x19ad0
movl %eax, 0x144(%rsp)
jmp 0x2cef3
jmp 0x2cd87
cmpl $0x0, 0x12c(%rsp)
jne 0x2cda1
movl $0x1, 0x144(%rsp)
jmp 0x2cef3
movl $0x0, 0x128(%rsp)
cmpl $0x20, 0x12c(%rsp)
jbe 0x2cdd4
movl $0x20, 0x130(%rsp)
movl 0x12c(%rsp), %eax
subl $0x20, %eax
movl %eax, 0x12c(%rsp)
jmp 0x2cded
movl 0x12c(%rsp), %eax
movl %eax, 0x130(%rsp)
movl $0x0, 0x12c(%rsp)
movq 0x18(%rsp), %rax
movq 0x48(%rax), %rax
movq 0xa8(%rax), %rax
movq 0x10(%rsp), %rdi
movl 0xc(%rsp), %esi
leaq 0x20(%rsp), %rcx
leaq 0x130(%rsp), %rdx
callq *%rax
movl %eax, 0x134(%rsp)
cmpl $0x5, 0x134(%rsp)
je 0x2ce65
jmp 0x2ce28
cmpl $0x0, 0x134(%rsp)
je 0x2ce61
movq 0x138(%rsp), %rdi
movl 0x134(%rsp), %edx
xorl %esi, %esi
callq 0x18a00
movq 0x138(%rsp), %rdi
callq 0x19ad0
movl %eax, 0x144(%rsp)
jmp 0x2cef3
jmp 0x2ce63
jmp 0x2ce65
movl $0x0, 0x124(%rsp)
movl 0x124(%rsp), %eax
cmpl 0x130(%rsp), %eax
jae 0x2ced8
movq 0x138(%rsp), %rdi
movl 0x124(%rsp), %eax
movq 0x20(%rsp,%rax,8), %rsi
movq 0x18(%rsp), %rdx
callq 0x2d720
movq 0x138(%rsp), %rdi
movl 0x128(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x128(%rsp)
movl %eax, %eax
movl %eax, %edx
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x191e0
movl 0x124(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x124(%rsp)
jmp 0x2ce70
jmp 0x2ceda
cmpl $0x0, 0x12c(%rsp)
ja 0x2cdac
movl $0x1, 0x144(%rsp)
movl 0x144(%rsp), %eax
addq $0x148, %rsp            # imm = 0x148
retq
nopw %cs:(%rax,%rax)