// File: /workspace/github_cpp_makefile_star2_O1/stetre[P]moonvulkan/src/display_mode.c
// Function: Create
static int Create(lua_State *L)
    {
    int err;
    ud_t *display_ud;
    VkResult ec;
    VkDisplayModeKHR display_mode;
    VkDisplayModeCreateInfoKHR* info = NULL;
    VkDisplayKHR display = checkdisplay(L, 1, &display_ud);
    VkPhysicalDevice physical_device = (VkPhysicalDevice)(uintptr_t)display_ud->parent_ud->handle;
    const VkAllocationCallbacks *allocator = NULL;
    CheckInstancePfn(L, display_ud, CreateDisplayModeKHR);

#define CLEANUP zfreeVkDisplayModeCreateInfoKHR(L, info, 1)
    if(lua_istable(L, 2))
        {
        info = zcheckVkDisplayModeCreateInfoKHR(L, 2, &err);
        if(err) { CLEANUP; return argerror(L, 2); }
        allocator = optallocator(L, 3);
        }
    else
        {
#define CLEANUP1 zfreeVkDisplayModeParametersKHR(L, parameters, 1)
        VkDisplayModeCreateFlagsKHR flags = checkflags(L, 2);
        VkDisplayModeParametersKHR* parameters = zcheckVkDisplayModeParametersKHR(L, 3, &err);
        if(err) { CLEANUP1; return argerror(L, 3); }
        info = znewVkDisplayModeCreateInfoKHR(L, &err);
        if(err) { CLEANUP; CLEANUP1; return lua_error(L); }
#undef CLEANUP1
        info->flags = flags;
        memcpy(&info->parameters, parameters, sizeof(VkDisplayModeParametersKHR));
        Free(L, parameters); /* no zfree here */
        allocator = optallocator(L, 4);
        }
    ec = display_ud->idt->CreateDisplayModeKHR(physical_device, display, info, allocator, &display_mode);
    CLEANUP;
#undef CLEANUP
    CheckError(L, ec);
    pushdisplaymode(L, display_mode, display_ud, allocator);
    return 1;
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %rbx
leaq 0x696e3(%rip), %rcx     # 0x9164e
leaq 0x18(%rsp), %r15
movl $0x1, %esi
movq %r15, %rdx
callq 0x1a520
movq %rax, %r14
movq (%r15), %rax
movq 0x48(%rax), %rcx
cmpq $0x0, 0xb8(%rcx)
je 0x28001
movq 0x10(%rax), %rax
movq (%rax), %r15
movq %rbx, %rdi
movl $0x2, %esi
callq 0x1a130
cmpl $0x5, %eax
jne 0x28017
leaq 0xc(%rsp), %r13
movq %rbx, %rdi
movl $0x2, %esi
movq %r13, %rdx
callq 0x1a150
movq %rax, %r12
cmpl $0x0, (%r13)
je 0x28086
movq %rbx, %rdi
movq %r12, %rsi
movl $0x1, %edx
callq 0x19170
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
xorl %edx, %edx
callq 0x18690
movq %rbx, %rdi
movl $0x2, %esi
movq %rax, %rdx
callq 0x18420
jmp 0x28184
leaq 0x69913(%rip), %rsi     # 0x9191b
movq %rbx, %rdi
xorl %eax, %eax
callq 0x19be0
jmp 0x28184
movq %rbx, %rdi
movl $0x2, %esi
callq 0x18f70
movq %rax, %r13
leaq 0xc(%rsp), %r12
movq %rbx, %rdi
movl $0x3, %esi
movq %r12, %rdx
callq 0x1a1b0
movq %rax, %rbp
cmpl $0x0, (%r12)
je 0x2809b
xorl %r13d, %r13d
movq %rbx, %rdi
movq %rbp, %rsi
movl $0x1, %edx
xorl %ecx, %ecx
callq 0x19640
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
xorl %edx, %edx
callq 0x18690
movq %rbx, %rdi
movl $0x3, %esi
movq %rax, %rdx
callq 0x18420
movl %eax, %ebp
xorl %eax, %eax
xorl %r12d, %r12d
jmp 0x2812e
movq %rbx, %rdi
movl $0x3, %esi
callq 0x191c0
movq %rax, %r13
jmp 0x28132
movq %r15, 0x10(%rsp)
leaq 0xc(%rsp), %r15
movl $0x20, %edx
movq %rbx, %rdi
movl $0x3b9ad1d0, %esi       # imm = 0x3B9AD1D0
movq %r15, %rcx
callq 0x19de0
movq %rax, %r12
cmpl $0x0, (%r15)
je 0x280f6
movq %rbx, %rdi
movq %r12, %rsi
movl $0x1, %edx
callq 0x19170
xorl %r13d, %r13d
movq %rbx, %rdi
movq %rbp, %rsi
movl $0x1, %edx
xorl %ecx, %ecx
callq 0x19640
movq %rbx, %rdi
callq 0x199e0
movl %eax, %ebp
xorl %eax, %eax
jmp 0x28129
movl %r13d, 0x10(%r12)
movq (%rbp), %rax
movq %rax, 0x14(%r12)
movl 0x8(%rbp), %eax
movl %eax, 0x1c(%r12)
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x182e0
movq %rbx, %rdi
movl $0x4, %esi
callq 0x191c0
movq %rax, %r13
movb $0x1, %al
movq 0x10(%rsp), %r15
testb %al, %al
je 0x28186
movq 0x18(%rsp), %rax
movq 0x48(%rax), %rax
leaq 0x20(%rsp), %r8
movq %r15, %rdi
movq %r14, %rsi
movq %r12, %rdx
movq %r13, %rcx
callq *0xb8(%rax)
movl %eax, %r14d
movl $0x1, %ebp
movq %rbx, %rdi
movq %r12, %rsi
movl $0x1, %edx
callq 0x19170
testl %r14d, %r14d
je 0x28197
movq %rbx, %rdi
xorl %esi, %esi
movl %r14d, %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
movq 0x20(%rsp), %rsi
movq 0x18(%rsp), %rdx
movq %rbx, %rdi
movq %r13, %rcx
callq 0x28948
jmp 0x28186