// File: stetre[P]moonvulkan/src/surface.c
// Function: GetPhysicalDeviceSurfaceFormats2
static int GetPhysicalDeviceSurfaceFormats2(lua_State *L, VkPhysicalDevice physdev, ud_t *ud)
    {
    int err;
    VkResult ec;
    uint32_t i, count=0;
    VkSurfaceFormat2KHR* formats=NULL;
    VkPhysicalDeviceSurfaceInfo2KHR* info=NULL;
    VkSurfaceKHR surface = checksurface(L, 2, NULL);
#define CLEANUP do {                                        \
    zfreearrayVkSurfaceFormat2KHR(L, formats, count, 1);    \
    zfreeVkPhysicalDeviceSurfaceInfo2KHR(L, info, 1);       \
} while(0)
    info = znewVkPhysicalDeviceSurfaceInfo2KHR(L, &err);
    if(err) { CLEANUP; return lua_error(L); }
    info->surface = surface;
    lua_newtable(L);
    ec = ud->idt->GetPhysicalDeviceSurfaceFormats2KHR(physdev, info, &count, NULL);
    if(ec) { CLEANUP; CheckError(L, ec); return 0; }
    if(count == 0) { CLEANUP; return 1; }
    formats = znewchainarrayVkSurfaceFormat2KHR(L, count, &err);
    if(err) { CLEANUP; return lua_error(L); }
    ec = ud->idt->GetPhysicalDeviceSurfaceFormats2KHR(physdev, info, &count, formats);
    if(ec) { CLEANUP; CheckError(L, ec); return 0; }
    for(i = 0; i < count; i++)
        {
        zpushVkSurfaceFormat2KHR(L, &formats[i]);
        lua_rawseti(L, -2, i+1);
        }
    CLEANUP;
#undef CLEANUP
    return 1;
    }

// Assembly:
subq $0x48, %rsp
movq %rdi, 0x38(%rsp)
movq %rsi, 0x30(%rsp)
movq %rdx, 0x28(%rsp)
movl $0x0, 0x18(%rsp)
movq $0x0, 0x10(%rsp)
movq $0x0, 0x8(%rsp)
movq 0x38(%rsp), %rdi
movl $0x2, %esi
xorl %eax, %eax
movl %eax, %edx
leaq 0x7e05e(%rip), %rcx     # 0xe24a0
callq 0x1a640
movq %rax, (%rsp)
movq 0x38(%rsp), %rdi
movl $0x3b9c9ad8, %esi       # imm = 0x3B9C9AD8
movl $0x18, %edx
leaq 0x24(%rsp), %rcx
callq 0x19ee0
movq %rax, 0x8(%rsp)
cmpl $0x0, 0x24(%rsp)
je 0x644b7
jmp 0x64472
movq 0x38(%rsp), %rdi
movq 0x10(%rsp), %rsi
movl 0x18(%rsp), %ecx
movl $0x18, %edx
movl $0x1, %r8d
callq 0x198d0
movq 0x38(%rsp), %rdi
movq 0x8(%rsp), %rsi
movl $0x1, %edx
callq 0x19210
movq 0x38(%rsp), %rdi
callq 0x19ad0
movl %eax, 0x44(%rsp)
jmp 0x6474c
movq (%rsp), %rcx
movq 0x8(%rsp), %rax
movq %rcx, 0x10(%rax)
movq 0x38(%rsp), %rdi
xorl %edx, %edx
movl %edx, %esi
callq 0x18830
movq 0x28(%rsp), %rax
movq 0x48(%rax), %rax
movq 0x88(%rax), %rax
movq 0x30(%rsp), %rdi
movq 0x8(%rsp), %rsi
leaq 0x18(%rsp), %rdx
xorl %ecx, %ecx
callq *%rax
movl %eax, 0x20(%rsp)
cmpl $0x0, 0x20(%rsp)
je 0x6456f
jmp 0x64502
movq 0x38(%rsp), %rdi
movq 0x10(%rsp), %rsi
movl 0x18(%rsp), %ecx
movl $0x18, %edx
movl $0x1, %r8d
callq 0x198d0
movq 0x38(%rsp), %rdi
movq 0x8(%rsp), %rsi
movl $0x1, %edx
callq 0x19210
jmp 0x64536
cmpl $0x0, 0x20(%rsp)
je 0x64560
movq 0x38(%rsp), %rdi
movl 0x20(%rsp), %edx
xorl %esi, %esi
callq 0x18a00
movq 0x38(%rsp), %rdi
callq 0x19ad0
movl %eax, 0x44(%rsp)
jmp 0x6474c
jmp 0x64562
movl $0x0, 0x44(%rsp)
jmp 0x6474c
cmpl $0x0, 0x18(%rsp)
jne 0x645b7
jmp 0x64578
movq 0x38(%rsp), %rdi
movq 0x10(%rsp), %rsi
movl 0x18(%rsp), %ecx
movl $0x18, %edx
movl $0x1, %r8d
callq 0x198d0
movq 0x38(%rsp), %rdi
movq 0x8(%rsp), %rsi
movl $0x1, %edx
callq 0x19210
movl $0x1, 0x44(%rsp)
jmp 0x6474c
movq 0x38(%rsp), %rdi
movl 0x18(%rsp), %esi
leaq 0x24(%rsp), %rdx
callq 0x19f00
movq %rax, 0x10(%rsp)
cmpl $0x0, 0x24(%rsp)
je 0x6461d
jmp 0x645d8
movq 0x38(%rsp), %rdi
movq 0x10(%rsp), %rsi
movl 0x18(%rsp), %ecx
movl $0x18, %edx
movl $0x1, %r8d
callq 0x198d0
movq 0x38(%rsp), %rdi
movq 0x8(%rsp), %rsi
movl $0x1, %edx
callq 0x19210
movq 0x38(%rsp), %rdi
callq 0x19ad0
movl %eax, 0x44(%rsp)
jmp 0x6474c
movq 0x28(%rsp), %rax
movq 0x48(%rax), %rax
movq 0x88(%rax), %rax
movq 0x30(%rsp), %rdi
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rcx
leaq 0x18(%rsp), %rdx
callq *%rax
movl %eax, 0x20(%rsp)
cmpl $0x0, 0x20(%rsp)
je 0x646bd
jmp 0x64650
movq 0x38(%rsp), %rdi
movq 0x10(%rsp), %rsi
movl 0x18(%rsp), %ecx
movl $0x18, %edx
movl $0x1, %r8d
callq 0x198d0
movq 0x38(%rsp), %rdi
movq 0x8(%rsp), %rsi
movl $0x1, %edx
callq 0x19210
jmp 0x64684
cmpl $0x0, 0x20(%rsp)
je 0x646ae
movq 0x38(%rsp), %rdi
movl 0x20(%rsp), %edx
xorl %esi, %esi
callq 0x18a00
movq 0x38(%rsp), %rdi
callq 0x19ad0
movl %eax, 0x44(%rsp)
jmp 0x6474c
jmp 0x646b0
movl $0x0, 0x44(%rsp)
jmp 0x6474c
movl $0x0, 0x1c(%rsp)
movl 0x1c(%rsp), %eax
cmpl 0x18(%rsp), %eax
jae 0x64710
movq 0x38(%rsp), %rdi
movq 0x10(%rsp), %rsi
movl 0x1c(%rsp), %eax
imulq $0x18, %rax, %rax
addq %rax, %rsi
callq 0x182b0
movq 0x38(%rsp), %rdi
movl 0x1c(%rsp), %eax
addl $0x1, %eax
movl %eax, %eax
movl %eax, %edx
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x191e0
movl 0x1c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1c(%rsp)
jmp 0x646c5
jmp 0x64712
movq 0x38(%rsp), %rdi
movq 0x10(%rsp), %rsi
movl 0x18(%rsp), %ecx
movl $0x18, %edx
movl $0x1, %r8d
callq 0x198d0
movq 0x38(%rsp), %rdi
movq 0x8(%rsp), %rsi
movl $0x1, %edx
callq 0x19210
movl $0x1, 0x44(%rsp)
movl 0x44(%rsp), %eax
addq $0x48, %rsp
retq
nopw %cs:(%rax,%rax)