// File: stetre[P]moonvulkan/src/display_mode.c
// Function: GetDisplayPlaneCapabilities2
static int GetDisplayPlaneCapabilities2(lua_State *L, VkDisplayModeKHR display_mode, ud_t *ud)
    {
    int err;
    VkResult ec;
    VkDisplayPlaneInfo2KHR* info = NULL;
    VkDisplayPlaneCapabilities2KHR* capabilities = NULL;
    VkPhysicalDevice physical_device = (VkPhysicalDevice)(uintptr_t)ud->parent_ud->parent_ud->handle;
#define CLEANUP do {                                            \
    zfreeVkDisplayPlaneInfo2KHR(L, info, 1);                    \
    zfreeVkDisplayPlaneCapabilities2KHR(L, capabilities, 1);    \
} while(0)
    if(lua_istable(L, 2))
        {
        info = zcheckVkDisplayPlaneInfo2KHR(L, 2, &err);
        if(err) { CLEANUP; return argerror(L, 2); }
        }
    else
        {
        uint32_t index = luaL_checkinteger(L, 2);
        info = znewVkDisplayPlaneInfo2KHR(L, &err);
        if(err) { CLEANUP; return lua_error(L); }
        info->planeIndex = index;
        }
    info->mode = display_mode;
    capabilities = znewchainVkDisplayPlaneCapabilities2KHR(L, &err);
    if(err) { CLEANUP; return lua_error(L); }
    ec = ud->idt->GetDisplayPlaneCapabilities2KHR(physical_device, info, capabilities);
    if(ec) { CLEANUP; CheckError(L, ec); }
    zpushVkDisplayPlaneCapabilities2KHR(L, capabilities);
    CLEANUP;
#undef CLEANUP
    return 1;
    }

// Assembly:
subq $0x58, %rsp
movq %rdi, 0x48(%rsp)
movq %rsi, 0x40(%rsp)
movq %rdx, 0x38(%rsp)
movq $0x0, 0x28(%rsp)
movq $0x0, 0x20(%rsp)
movq 0x38(%rsp), %rax
movq 0x10(%rax), %rax
movq 0x10(%rax), %rax
movq (%rax), %rax
movq %rax, 0x18(%rsp)
movq 0x48(%rsp), %rdi
movl $0x2, %esi
callq 0x1a240
cmpl $0x5, %eax
jne 0x2ed29
movq 0x48(%rsp), %rdi
movl $0x2, %esi
leaq 0x34(%rsp), %rdx
callq 0x19880
movq %rax, 0x28(%rsp)
cmpl $0x0, 0x34(%rsp)
je 0x2ed24
jmp 0x2ecc4
movq 0x48(%rsp), %rdi
movq 0x28(%rsp), %rsi
movl $0x1, %edx
callq 0x19210
movq 0x48(%rsp), %rdi
movq 0x20(%rsp), %rsi
movl $0x1, %edx
callq 0x19210
movq 0x48(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x48(%rsp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
xorl %eax, %eax
movl %eax, %edx
callq 0x186d0
movq 0x8(%rsp), %rdi
movq %rax, %rdx
movl $0x2, %esi
callq 0x18460
movl %eax, 0x54(%rsp)
jmp 0x2eed2
jmp 0x2edaa
movq 0x48(%rsp), %rdi
movl $0x2, %esi
callq 0x19190
movl %eax, 0x14(%rsp)
movq 0x48(%rsp), %rdi
movl $0x3b9ca2ab, %esi       # imm = 0x3B9CA2AB
movl $0x20, %edx
leaq 0x34(%rsp), %rcx
callq 0x19ee0
movq %rax, 0x28(%rsp)
cmpl $0x0, 0x34(%rsp)
je 0x2ed9e
jmp 0x2ed63
movq 0x48(%rsp), %rdi
movq 0x28(%rsp), %rsi
movl $0x1, %edx
callq 0x19210
movq 0x48(%rsp), %rdi
movq 0x20(%rsp), %rsi
movl $0x1, %edx
callq 0x19210
movq 0x48(%rsp), %rdi
callq 0x19ad0
movl %eax, 0x54(%rsp)
jmp 0x2eed2
movl 0x14(%rsp), %ecx
movq 0x28(%rsp), %rax
movl %ecx, 0x18(%rax)
movq 0x40(%rsp), %rcx
movq 0x28(%rsp), %rax
movq %rcx, 0x10(%rax)
movq 0x48(%rsp), %rdi
leaq 0x34(%rsp), %rsi
callq 0x1a190
movq %rax, 0x20(%rsp)
cmpl $0x0, 0x34(%rsp)
je 0x2ee10
jmp 0x2edd5
movq 0x48(%rsp), %rdi
movq 0x28(%rsp), %rsi
movl $0x1, %edx
callq 0x19210
movq 0x48(%rsp), %rdi
movq 0x20(%rsp), %rsi
movl $0x1, %edx
callq 0x19210
movq 0x48(%rsp), %rdi
callq 0x19ad0
movl %eax, 0x54(%rsp)
jmp 0x2eed2
movq 0x38(%rsp), %rax
movq 0x48(%rax), %rax
movq 0x1b8(%rax), %rax
movq 0x18(%rsp), %rdi
movq 0x28(%rsp), %rsi
movq 0x20(%rsp), %rdx
callq *%rax
movl %eax, 0x30(%rsp)
cmpl $0x0, 0x30(%rsp)
je 0x2ee93
jmp 0x2ee3e
movq 0x48(%rsp), %rdi
movq 0x28(%rsp), %rsi
movl $0x1, %edx
callq 0x19210
movq 0x48(%rsp), %rdi
movq 0x20(%rsp), %rsi
movl $0x1, %edx
callq 0x19210
jmp 0x2ee68
cmpl $0x0, 0x30(%rsp)
je 0x2ee8f
movq 0x48(%rsp), %rdi
movl 0x30(%rsp), %edx
xorl %esi, %esi
callq 0x18a00
movq 0x48(%rsp), %rdi
callq 0x19ad0
movl %eax, 0x54(%rsp)
jmp 0x2eed2
jmp 0x2ee91
jmp 0x2ee93
movq 0x48(%rsp), %rdi
movq 0x20(%rsp), %rsi
callq 0x19460
movq 0x48(%rsp), %rdi
movq 0x28(%rsp), %rsi
movl $0x1, %edx
callq 0x19210
movq 0x48(%rsp), %rdi
movq 0x20(%rsp), %rsi
movl $0x1, %edx
callq 0x19210
movl $0x1, 0x54(%rsp)
movl 0x54(%rsp), %eax
addq $0x58, %rsp
retq
nopl (%rax,%rax)