// File: stetre[P]moonvulkan/src/surface.c
// Function: GetPhysicalDevicePresentRectangles
static int GetPhysicalDevicePresentRectangles(lua_State *L)
    {
    int err;
    VkResult ec;
    ud_t *ud;
    uint32_t i, count = 0;
    VkRect2D* rects = NULL;
    VkPhysicalDevice physdev = checkphysical_device(L, 1, &ud);
    VkSurfaceKHR surface = checksurface(L, 2, NULL);
    CheckDevicePfn(L, ud, GetPhysicalDevicePresentRectanglesKHR);
    ec = ud->ddt->GetPhysicalDevicePresentRectanglesKHR(physdev, surface, &count, NULL);
    CheckError(L, ec);
#define CLEANUP zfreearrayVkRect2D(L, rects, count, 1)
    rects = znewarrayVkRect2D(L, count, &err);
    if(err) { CLEANUP; return lua_error(L); }
    ec = ud->ddt->GetPhysicalDevicePresentRectanglesKHR(physdev, surface, &count, rects);
    if(ec) { CLEANUP; CheckError(L, ec); return 0; }
    lua_newtable(L);
    for(i = 0; i < count; i++)
        {
        zpushVkRect2D(L, &rects[i]);
        lua_rawseti(L, -2, i+1);
        }
    CLEANUP;
#undef CLEANUP
    return 1;
    }

// Assembly:
subq $0x48, %rsp
movq %rdi, 0x38(%rsp)
movl $0x0, 0x20(%rsp)
movq $0x0, 0x18(%rsp)
movq 0x38(%rsp), %rdi
movl $0x1, %esi
leaq 0x28(%rsp), %rdx
leaq 0x6d0dc(%rip), %rcx     # 0xd0eac
callq 0x1a640
movq %rax, 0x10(%rsp)
movq 0x38(%rsp), %rdi
movl $0x2, %esi
xorl %eax, %eax
movl %eax, %edx
leaq 0x7e6b1(%rip), %rcx     # 0xe24a0
callq 0x1a640
movq %rax, 0x8(%rsp)
movq 0x28(%rsp), %rax
movq 0x50(%rax), %rax
cmpq $0x0, 0x558(%rax)
jne 0x63e28
movq 0x38(%rsp), %rdi
leaq 0x7f8ee(%rip), %rsi     # 0xe3706
movb $0x0, %al
callq 0x19ce0
movl %eax, 0x44(%rsp)
jmp 0x63ff5
jmp 0x63e2a
movq 0x28(%rsp), %rax
movq 0x50(%rax), %rax
movq 0x558(%rax), %rax
movq 0x10(%rsp), %rdi
movq 0x8(%rsp), %rsi
leaq 0x20(%rsp), %rdx
xorl %ecx, %ecx
callq *%rax
movl %eax, 0x30(%rsp)
cmpl $0x0, 0x30(%rsp)
je 0x63e7b
movq 0x38(%rsp), %rdi
movl 0x30(%rsp), %edx
xorl %esi, %esi
callq 0x18a00
movq 0x38(%rsp), %rdi
callq 0x19ad0
movl %eax, 0x44(%rsp)
jmp 0x63ff5
jmp 0x63e7d
movq 0x38(%rsp), %rdi
movl 0x20(%rsp), %ecx
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl $0x10, %edx
leaq 0x34(%rsp), %r8
callq 0x19920
movq %rax, 0x18(%rsp)
cmpl $0x0, 0x34(%rsp)
je 0x63edc
movq 0x38(%rsp), %rdi
movq 0x18(%rsp), %rsi
movl 0x20(%rsp), %ecx
movl $0x10, %edx
movl $0x1, %r8d
xorl %eax, %eax
movl %eax, %r9d
callq 0x18dd0
movq 0x38(%rsp), %rdi
callq 0x19ad0
movl %eax, 0x44(%rsp)
jmp 0x63ff5
movq 0x28(%rsp), %rax
movq 0x50(%rax), %rax
movq 0x558(%rax), %rax
movq 0x10(%rsp), %rdi
movq 0x8(%rsp), %rsi
movq 0x18(%rsp), %rcx
leaq 0x20(%rsp), %rdx
callq *%rax
movl %eax, 0x30(%rsp)
cmpl $0x0, 0x30(%rsp)
je 0x63f69
movq 0x38(%rsp), %rdi
movq 0x18(%rsp), %rsi
movl 0x20(%rsp), %ecx
movl $0x10, %edx
movl $0x1, %r8d
xorl %eax, %eax
movl %eax, %r9d
callq 0x18dd0
cmpl $0x0, 0x30(%rsp)
je 0x63f5a
movq 0x38(%rsp), %rdi
movl 0x30(%rsp), %edx
xorl %esi, %esi
callq 0x18a00
movq 0x38(%rsp), %rdi
callq 0x19ad0
movl %eax, 0x44(%rsp)
jmp 0x63ff5
jmp 0x63f5c
movl $0x0, 0x44(%rsp)
jmp 0x63ff5
movq 0x38(%rsp), %rdi
xorl %edx, %edx
movl %edx, %esi
callq 0x18830
movl $0x0, 0x24(%rsp)
movl 0x24(%rsp), %eax
cmpl 0x20(%rsp), %eax
jae 0x63fca
movq 0x38(%rsp), %rdi
movq 0x18(%rsp), %rsi
movl 0x24(%rsp), %eax
shlq $0x4, %rax
addq %rax, %rsi
callq 0x1a510
movq 0x38(%rsp), %rdi
movl 0x24(%rsp), %eax
addl $0x1, %eax
movl %eax, %eax
movl %eax, %edx
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x191e0
movl 0x24(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x24(%rsp)
jmp 0x63f7f
movq 0x38(%rsp), %rdi
movq 0x18(%rsp), %rsi
movl 0x20(%rsp), %ecx
movl $0x10, %edx
movl $0x1, %r8d
xorl %eax, %eax
movl %eax, %r9d
callq 0x18dd0
movl $0x1, 0x44(%rsp)
movl 0x44(%rsp), %eax
addq $0x48, %rsp
retq
nop