// File: /workspace/github_cpp_makefile_star2_O2/stetre[P]moonvulkan/src/surface.c
// Function: GetPhysicalDeviceSurfacePresentModes
static int GetPhysicalDeviceSurfacePresentModes(lua_State *L)
    {
    VkResult ec;
    uint32_t count, i;
    VkPresentModeKHR* modes;
    ud_t *ud;
    VkPhysicalDevice physdev = checkphysical_device(L, 1, &ud);
    VkSurfaceKHR surface = checksurface(L, 2, NULL);
    int byname = optboolean(L, 3, 0);

    CheckInstancePfn(L, ud, GetPhysicalDeviceSurfacePresentModesKHR);
    lua_newtable(L);
    ec = ud->idt->GetPhysicalDeviceSurfacePresentModesKHR(physdev, surface, &count, NULL);
    CheckError(L, ec);
    if(count == 0) return 1;

    modes = (VkPresentModeKHR*)Malloc(L, sizeof(VkPresentModeKHR)*count);
    
    ud->idt->GetPhysicalDeviceSurfacePresentModesKHR(physdev, surface, &count, modes);
    if(ec) { Free(L, modes); CheckError(L, ec); return 0; }

    if(byname)
        {
        for(i = 0; i < count; i++)
            {
            pushpresentmode(L, modes[i]);
            lua_pushboolean(L, 1);
            lua_rawset(L, -3);
            }
        }
    else
        {
        for(i = 0; i < count; i++)
            {
            pushpresentmode(L, modes[i]);
            lua_rawseti(L, -2, i+1);
            }
        }
    Free(L, modes);
    return 1;
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %r14
leaq 0x3578a(%rip), %rcx     # 0x7eef4
pushq $0x1
popq %rbx
leaq 0x10(%rsp), %r15
movl %ebx, %esi
movq %r15, %rdx
callq 0x1a500
movq %rax, %r12
leaq 0x46d53(%rip), %rcx     # 0x904d9
pushq $0x2
popq %rsi
movq %r14, %rdi
xorl %edx, %edx
callq 0x1a500
movq %rax, %r13
pushq $0x3
popq %rsi
movq %r14, %rdi
xorl %edx, %edx
callq 0x197c0
movl %eax, %ebp
movq (%r15), %rax
movq 0x48(%rax), %rax
cmpq $0x0, 0x90(%rax)
je 0x497f8
movq %r14, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x187d0
movq 0x10(%rsp), %rax
movq 0x48(%rax), %rax
leaq 0xc(%rsp), %rdx
movq %r12, %rdi
movq %r13, %rsi
xorl %ecx, %ecx
callq *0x90(%rax)
testl %eax, %eax
je 0x4981c
movq %r14, %rdi
xorl %esi, %esi
movl %eax, %edx
callq 0x18980
movq %r14, %rdi
callq 0x199c0
jmp 0x49809
leaq 0x47e4c(%rip), %rsi     # 0x9164b
movq %r14, %rdi
xorl %eax, %eax
callq 0x19bc0
movl %eax, %ebx
movl %ebx, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl 0xc(%rsp), %esi
testq %rsi, %rsi
je 0x4980b
shlq $0x2, %rsi
movq %r14, %rdi
callq 0x191f0
movq %rax, %r15
movq 0x10(%rsp), %rax
movq 0x48(%rax), %rax
leaq 0xc(%rsp), %rdx
movq %r12, %rdi
movq %r13, %rsi
movq %r15, %rcx
callq *0x90(%rax)
testl %ebp, %ebp
je 0x49894
xorl %ebx, %ebx
pushq $0x23
popq %rbp
pushq $0x1
popq %r12
pushq $-0x3
popq %r13
movl 0xc(%rsp), %eax
cmpq %rax, %rbx
jae 0x498c8
movl (%r15,%rbx,4), %edx
movq %r14, %rdi
movl %ebp, %esi
callq 0x18980
movq %r14, %rdi
movl %r12d, %esi
callq 0x193a0
movq %r14, %rdi
movl %r13d, %esi
callq 0x18800
incq %rbx
jmp 0x49862
xorl %r12d, %r12d
pushq $0x23
popq %rbp
pushq $-0x2
popq %r13
movl 0xc(%rsp), %eax
cmpq %rax, %r12
jae 0x498c8
movl (%r15,%r12,4), %edx
movq %r14, %rdi
movl %ebp, %esi
callq 0x18980
incq %r12
movq %r14, %rdi
movl %r13d, %esi
movq %r12, %rdx
callq 0x19120
jmp 0x4989e
movq %r14, %rdi
movq %r15, %rsi
callq 0x182e0
pushq $0x1
popq %rbx
jmp 0x4980b