// File: /workspace/github_cpp_makefile_star2_O3/stetre[P]moonvulkan/src/physical_device.c
// Function: GetPhysicalDeviceSparseImageFormatProperties
static int GetPhysicalDeviceSparseImageFormatProperties(lua_State *L)
    {
    int err;
    ud_t *ud;
    uint32_t i, count = 0;
    VkPhysicalDeviceSparseImageFormatInfo2* info;
    VkSparseImageFormatProperties* props;
    VkPhysicalDevice physical_device = checkphysical_device(L, 1, &ud);
    if(ud->idt->GetPhysicalDeviceSparseImageFormatProperties2)
        return GetPhysicalDeviceSparseImageFormatProperties2(L, physical_device, ud);
#define CLEANUP zfreeVkPhysicalDeviceSparseImageFormatInfo2(L, info, 1)
    info = zcheckVkPhysicalDeviceSparseImageFormatInfo2(L, 2, &err);
    if(err) { CLEANUP; return argerror(L, 2); }

    lua_newtable(L);
    ud->idt->GetPhysicalDeviceSparseImageFormatProperties(physical_device, 
        info->format, info->type, info->samples, info->usage, info->tiling, &count, NULL);
    if(count == 0) { CLEANUP; return 1; }
    props = (VkSparseImageFormatProperties*)Malloc(L, sizeof(VkSparseImageFormatProperties)*count);
    ud->idt->GetPhysicalDeviceSparseImageFormatProperties(physical_device, 
        info->format, info->type, info->samples, info->usage, info->tiling, &count, props);
    for(i=0; i<count; i++)
        {
        zpushVkSparseImageFormatProperties(L, &props[i]);
        lua_rawseti(L, -2, i+1);
        }
    CLEANUP;
    Free(L, props);
#undef CLEANUP
    return 1;
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
movl $0x0, 0x8(%rsp)
leaq 0x46849(%rip), %rcx     # 0x8def4
leaq 0x10(%rsp), %r15
movl $0x1, %esi
movq %r15, %rdx
callq 0x1a4e0
movq %rax, %r14
movq (%r15), %rbp
movq 0x48(%rbp), %rax
cmpq $0x0, 0x118(%rax)
je 0x47725
movl $0x0, 0x4(%rsp)
leaq 0xc(%rsp), %r12
movq %rbx, %rdi
movl $0x2, %esi
movq %r12, %rdx
callq 0x19590
movq %rax, %r15
cmpl $0x0, (%r12)
je 0x4778a
movq %rbx, %rdi
movq %r15, %rsi
movl $0x1, %edx
callq 0x19160
movl $0x28, %edx
movq %rbx, %rdi
xorl %esi, %esi
xorl %ecx, %ecx
movl $0x1, %r8d
callq 0x197d0
jmp 0x47758
leaq 0xc(%rsp), %r12
movq %rbx, %rdi
movl $0x2, %esi
movq %r12, %rdx
callq 0x19590
movq %rax, %r15
cmpl $0x0, (%r12)
je 0x47811
movq %rbx, %rdi
movq %r15, %rsi
movl $0x1, %edx
callq 0x19160
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
xorl %edx, %edx
callq 0x18680
movq %rbx, %rdi
movl $0x2, %esi
movq %rax, %rdx
callq 0x18410
movl %eax, %ebp
movl %ebp, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x187d0
movq 0x48(%rbp), %rax
leaq 0x4(%rsp), %r12
movq %r14, %rdi
movq %r15, %rsi
movq %r12, %rdx
xorl %ecx, %ecx
callq *0x118(%rax)
movl (%r12), %esi
testl %esi, %esi
je 0x478f5
leaq 0xc(%rsp), %r13
movq %rbx, %rdi
movq %r13, %rdx
callq 0x19960
movq %rax, %r12
cmpl $0x0, (%r13)
je 0x4791a
movq %rbx, %rdi
movq %r15, %rsi
movl $0x1, %edx
callq 0x19160
movl 0x4(%rsp), %ecx
movl $0x28, %edx
movq %rbx, %rdi
movq %r12, %rsi
movl $0x1, %r8d
callq 0x197d0
movq %rbx, %rdi
callq 0x199a0
jmp 0x47777
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x187d0
movq 0x10(%rsp), %rax
movq 0x48(%rax), %rax
movl 0x10(%r15), %esi
movl 0x14(%r15), %edx
movl 0x18(%r15), %ecx
movl 0x1c(%r15), %r8d
movl 0x20(%r15), %r9d
leaq 0x8(%rsp), %r13
movq %r14, %rdi
pushq $0x0
pushq %r13
callq *0x58(%rax)
addq $0x10, %rsp
movl (%r13), %eax
testq %rax, %rax
je 0x479a1
shlq $0x2, %rax
leaq (%rax,%rax,4), %rsi
movq %rbx, %rdi
callq 0x19200
movq %rax, %r12
movq 0x10(%rsp), %rax
movq 0x48(%rax), %rax
movl 0x10(%r15), %esi
movl 0x14(%r15), %edx
movl 0x18(%r15), %ecx
movl 0x1c(%r15), %r8d
movl 0x20(%r15), %r9d
movq %r14, %rdi
pushq %r12
pushq %r13
callq *0x58(%rax)
addq $0x10, %rsp
cmpl $0x0, 0x8(%rsp)
je 0x478d0
xorl %r14d, %r14d
movq %r12, %r13
movq %rbx, %rdi
movq %r13, %rsi
callq 0x18cc0
incq %r14
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
movq %r14, %rdx
callq 0x19130
movl 0x8(%rsp), %eax
addq $0x14, %r13
cmpq %rax, %r14
jb 0x478a5
movl $0x1, %ebp
movq %rbx, %rdi
movq %r15, %rsi
movl $0x1, %edx
callq 0x19160
movq %rbx, %rdi
movq %r12, %rsi
callq 0x182d0
jmp 0x47779
movl $0x1, %ebp
movq %rbx, %rdi
movq %r15, %rsi
movl $0x1, %edx
callq 0x19160
movl 0x4(%rsp), %ecx
movl $0x28, %edx
movq %rbx, %rdi
xorl %esi, %esi
jmp 0x47991
movq 0x48(%rbp), %rax
leaq 0x4(%rsp), %r13
movq %r14, %rdi
movq %r15, %rsi
movq %r13, %rdx
movq %r12, %rcx
callq *0x118(%rax)
cmpl $0x0, (%r13)
je 0x4796d
xorl %r14d, %r14d
movq %r12, %r13
movq %rbx, %rdi
movq %r13, %rsi
callq 0x18430
incq %r14
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
movq %r14, %rdx
callq 0x19130
movl 0x4(%rsp), %eax
addq $0x28, %r13
cmpq %rax, %r14
jb 0x47942
movl $0x1, %ebp
movq %rbx, %rdi
movq %r15, %rsi
movl $0x1, %edx
callq 0x19160
movl 0x4(%rsp), %ecx
movl $0x28, %edx
movq %rbx, %rdi
movq %r12, %rsi
movl $0x1, %r8d
callq 0x197d0
jmp 0x47779
movl $0x1, %ebp
movq %rbx, %rdi
movq %r15, %rsi
movl $0x1, %edx
callq 0x19160
jmp 0x47779