// File: 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:
subq $0x58, %rsp
movq %rdi, 0x48(%rsp)
movl $0x0, 0x30(%rsp)
movq 0x48(%rsp), %rdi
movl $0x1, %esi
leaq 0x38(%rsp), %rdx
leaq 0x75135(%rip), %rcx     # 0xd0eac
callq 0x1a640
movq %rax, 0x18(%rsp)
movq 0x38(%rsp), %rax
movq 0x48(%rax), %rax
cmpq $0x0, 0x118(%rax)
je 0x5bdb1
movq 0x48(%rsp), %rdi
movq 0x18(%rsp), %rsi
movq 0x38(%rsp), %rdx
callq 0x5d7f0
movl %eax, 0x54(%rsp)
jmp 0x5bf8c
movq 0x48(%rsp), %rdi
movl $0x2, %esi
leaq 0x44(%rsp), %rdx
callq 0x19690
movq %rax, 0x28(%rsp)
cmpl $0x0, 0x44(%rsp)
je 0x5be1d
movq 0x48(%rsp), %rdi
movq 0x28(%rsp), %rsi
movl $0x1, %edx
callq 0x19210
movq 0x48(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0x48(%rsp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
xorl %eax, %eax
movl %eax, %edx
callq 0x186d0
movq 0x10(%rsp), %rdi
movq %rax, %rdx
movl $0x2, %esi
callq 0x18460
movl %eax, 0x54(%rsp)
jmp 0x5bf8c
movq 0x48(%rsp), %rdi
xorl %edx, %edx
movl %edx, %esi
callq 0x18830
movq 0x38(%rsp), %rax
movq 0x48(%rax), %rax
movq 0x58(%rax), %rax
movq 0x18(%rsp), %rdi
movq 0x28(%rsp), %rcx
movl 0x10(%rcx), %esi
movq 0x28(%rsp), %rcx
movl 0x14(%rcx), %edx
movq 0x28(%rsp), %rcx
movl 0x18(%rcx), %ecx
movq 0x28(%rsp), %r8
movl 0x1c(%r8), %r8d
movq 0x28(%rsp), %r9
movl 0x20(%r9), %r9d
leaq 0x30(%rsp), %r10
xorl %r11d, %r11d
movq %r10, (%rsp)
movq $0x0, 0x8(%rsp)
callq *%rax
cmpl $0x0, 0x30(%rsp)
jne 0x5bea6
movq 0x48(%rsp), %rdi
movq 0x28(%rsp), %rsi
movl $0x1, %edx
callq 0x19210
movl $0x1, 0x54(%rsp)
jmp 0x5bf8c
movq 0x48(%rsp), %rdi
movl 0x30(%rsp), %eax
imulq $0x14, %rax, %rsi
callq 0x192c0
movq %rax, 0x20(%rsp)
movq 0x38(%rsp), %rax
movq 0x48(%rax), %rax
movq 0x58(%rax), %rax
movq 0x18(%rsp), %rdi
movq 0x28(%rsp), %rcx
movl 0x10(%rcx), %esi
movq 0x28(%rsp), %rcx
movl 0x14(%rcx), %edx
movq 0x28(%rsp), %rcx
movl 0x18(%rcx), %ecx
movq 0x28(%rsp), %r8
movl 0x1c(%r8), %r8d
movq 0x28(%rsp), %r9
movl 0x20(%r9), %r9d
movq 0x20(%rsp), %r10
leaq 0x30(%rsp), %r11
movq %r11, (%rsp)
movq %r10, 0x8(%rsp)
callq *%rax
movl $0x0, 0x34(%rsp)
movl 0x34(%rsp), %eax
cmpl 0x30(%rsp), %eax
jae 0x5bf61
movq 0x48(%rsp), %rdi
movq 0x20(%rsp), %rsi
movl 0x34(%rsp), %eax
imulq $0x14, %rax, %rax
addq %rax, %rsi
callq 0x18d50
movq 0x48(%rsp), %rdi
movl 0x34(%rsp), %eax
addl $0x1, %eax
movl %eax, %eax
movl %eax, %edx
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x191e0
movl 0x34(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x34(%rsp)
jmp 0x5bf16
movq 0x48(%rsp), %rdi
movq 0x28(%rsp), %rsi
movl $0x1, %edx
callq 0x19210
movq 0x48(%rsp), %rdi
movq 0x20(%rsp), %rsi
callq 0x18300
movl $0x1, 0x54(%rsp)
movl 0x54(%rsp), %eax
addq $0x58, %rsp
retq
nopw %cs:(%rax,%rax)