// File: /workspace/github_cpp_makefile_star2_O1/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 0x495a4(%rip), %rcx     # 0x90ef4
leaq 0x10(%rsp), %r15
movl $0x1, %esi
movq %r15, %rdx
callq 0x1a520
movq %rax, %r14
movq (%r15), %rbp
movq 0x48(%rbp), %rax
cmpq $0x0, 0x118(%rax)
je 0x479cc
movl $0x0, 0x4(%rsp)
leaq 0xc(%rsp), %r12
movq %rbx, %rdi
movl $0x2, %esi
movq %r12, %rdx
callq 0x195c0
movq %rax, %r15
cmpl $0x0, (%r12)
je 0x47a31
movq %rbx, %rdi
movq %r15, %rsi
movl $0x1, %edx
callq 0x19170
movl 0x4(%rsp), %ecx
movl $0x28, %edx
movq %rbx, %rdi
xorl %esi, %esi
movl $0x1, %r8d
callq 0x19800
jmp 0x479ff
leaq 0xc(%rsp), %r12
movq %rbx, %rdi
movl $0x2, %esi
movq %r12, %rdx
callq 0x195c0
movq %rax, %r15
cmpl $0x0, (%r12)
je 0x47ab8
movq %rbx, %rdi
movq %r15, %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
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 0x187e0
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 0x47b9c
leaq 0xc(%rsp), %r13
movq %rbx, %rdi
movq %r13, %rdx
callq 0x199a0
movq %rax, %r12
cmpl $0x0, (%r13)
je 0x47bc1
movq %rbx, %rdi
movq %r15, %rsi
movl $0x1, %edx
callq 0x19170
movl 0x4(%rsp), %ecx
movl $0x28, %edx
movq %rbx, %rdi
movq %r12, %rsi
movl $0x1, %r8d
callq 0x19800
movq %rbx, %rdi
callq 0x199e0
jmp 0x47a1e
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x187e0
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 0x47c48
shlq $0x2, %rax
leaq (%rax,%rax,4), %rsi
movq %rbx, %rdi
callq 0x19210
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 0x47b77
xorl %r14d, %r14d
movq %r12, %r13
movq %rbx, %rdi
movq %r13, %rsi
callq 0x18cd0
incq %r14
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
movq %r14, %rdx
callq 0x19140
movl 0x8(%rsp), %eax
addq $0x14, %r13
cmpq %rax, %r14
jb 0x47b4c
movl $0x1, %ebp
movq %rbx, %rdi
movq %r15, %rsi
movl $0x1, %edx
callq 0x19170
movq %rbx, %rdi
movq %r12, %rsi
callq 0x182e0
jmp 0x47a20
movl $0x1, %ebp
movq %rbx, %rdi
movq %r15, %rsi
movl $0x1, %edx
callq 0x19170
movl 0x4(%rsp), %ecx
movl $0x28, %edx
movq %rbx, %rdi
xorl %esi, %esi
jmp 0x47c38
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 0x47c14
xorl %r14d, %r14d
movq %r12, %r13
movq %rbx, %rdi
movq %r13, %rsi
callq 0x18440
incq %r14
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
movq %r14, %rdx
callq 0x19140
movl 0x4(%rsp), %eax
addq $0x28, %r13
cmpq %rax, %r14
jb 0x47be9
movl $0x1, %ebp
movq %rbx, %rdi
movq %r15, %rsi
movl $0x1, %edx
callq 0x19170
movl 0x4(%rsp), %ecx
movl $0x28, %edx
movq %rbx, %rdi
movq %r12, %rsi
movl $0x1, %r8d
callq 0x19800
jmp 0x47a20
movl $0x1, %ebp
movq %rbx, %rdi
movq %r15, %rsi
movl $0x1, %edx
callq 0x19170
jmp 0x47a20