// File: /workspace/github_cpp_makefile_star2_O3/stetre[P]moonvulkan/src/device_memory.c
// Function: GetImageSparseMemoryRequirements
static int GetImageSparseMemoryRequirements(lua_State *L)
    {
    uint32_t count, i;
    VkSparseImageMemoryRequirements *req;
    ud_t *ud;
    VkImage image = checkimage(L, 1, &ud);
    VkDevice device = ud->device;
    if(ud->ddt->GetImageSparseMemoryRequirements2)
        return GetImageSparseMemoryRequirements2(L, image, ud);
    lua_newtable(L);
    ud->ddt->GetImageSparseMemoryRequirements(device, image, &count, NULL);
    if(count == 0)
        return 1;
    req = (VkSparseImageMemoryRequirements*)Malloc(L, sizeof(VkSparseImageMemoryRequirements)*count);
    ud->ddt->GetImageSparseMemoryRequirements(device, image, &count, req);
    for(i = 0; i <count; i++)
        {
        zpushVkSparseImageMemoryRequirements(L, &req[i]);
        lua_rawseti(L, -2, i+1);
        }
    Free(L, req);
    return 1;
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
leaq 0x66a73(%rip), %rcx     # 0x8c99a
movl $0x1, %ebp
leaq 0x10(%rsp), %r14
movl $0x1, %esi
movq %r14, %rdx
callq 0x1a4e0
movq %rax, %r12
movq (%r14), %r14
movq 0x20(%r14), %r13
movq 0x50(%r14), %rax
cmpq $0x0, 0x4b8(%rax)
je 0x25fdf
movq %r13, %rbp
movq %rbx, %rdi
movl $0x2, %esi
callq 0x1a0f0
leaq 0xc(%rsp), %r13
cmpl $0x5, %eax
jne 0x26091
movq %rbx, %rdi
movl $0x2, %esi
movq %r13, %rdx
callq 0x18770
movq %rax, %r15
cmpl $0x0, (%r13)
je 0x260cc
movq %rbx, %rdi
movq %r15, %rsi
movl $0x1, %edx
callq 0x19160
movl $0x40, %edx
movq %rbx, %rdi
xorl %esi, %esi
movl $0x1, %r8d
callq 0x197d0
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
xorl %edx, %edx
callq 0x18680
movq %rbx, %rdi
movl $0x2, %esi
movq %rax, %rdx
callq 0x18410
jmp 0x2614a
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x187d0
movq 0x10(%rsp), %rax
movq 0x50(%rax), %rax
leaq 0xc(%rsp), %r15
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
xorl %ecx, %ecx
callq *0x80(%rax)
movl (%r15), %eax
testq %rax, %rax
je 0x261f8
shlq $0x4, %rax
leaq (%rax,%rax,2), %rsi
movq %rbx, %rdi
callq 0x19200
movq %rax, %r15
movq 0x10(%rsp), %rax
movq 0x50(%rax), %rax
movq %r13, %rdi
leaq 0xc(%rsp), %r13
movq %r12, %rsi
movq %r13, %rdx
movq %r15, %rcx
callq *0x80(%rax)
cmpl $0x0, (%r13)
je 0x26081
xorl %r14d, %r14d
movq %r15, %r12
movq %rbx, %rdi
movq %r12, %rsi
callq 0x18140
incq %r14
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
movq %r14, %rdx
callq 0x19130
movl 0xc(%rsp), %eax
addq $0x30, %r12
cmpq %rax, %r14
jb 0x26056
movq %rbx, %rdi
movq %r15, %rsi
callq 0x182d0
jmp 0x261f8
movl $0x18, %edx
movq %rbx, %rdi
movl $0x3b9d0452, %esi       # imm = 0x3B9D0452
movq %r13, %rcx
callq 0x19da0
movq %rax, %r15
cmpl $0x0, (%r13)
je 0x260cc
movq %rbx, %rdi
movq %r15, %rsi
movl $0x1, %edx
callq 0x19160
movl $0x40, %edx
movq %rbx, %rdi
xorl %esi, %esi
jmp 0x26137
movq %r12, 0x10(%r15)
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x187d0
movq 0x50(%r14), %rax
leaq 0x8(%rsp), %r12
movq %rbp, %rdi
movq %r15, %rsi
movq %r12, %rdx
xorl %ecx, %ecx
callq *0x4b8(%rax)
movl (%r12), %esi
testl %esi, %esi
je 0x26151
leaq 0xc(%rsp), %r13
movq %rbx, %rdi
movq %r13, %rdx
callq 0x19bd0
movq %rax, %r12
cmpl $0x0, (%r13)
je 0x26176
movq %rbx, %rdi
movq %r15, %rsi
movl $0x1, %edx
callq 0x19160
movl 0x8(%rsp), %ecx
movl $0x40, %edx
movq %rbx, %rdi
movq %r12, %rsi
movl $0x1, %r8d
callq 0x197d0
movq %rbx, %rdi
callq 0x199a0
movl %eax, %ebp
jmp 0x261f8
movl $0x1, %ebp
movq %rbx, %rdi
movq %r15, %rsi
movl $0x1, %edx
callq 0x19160
movl 0x8(%rsp), %ecx
movl $0x40, %edx
movq %rbx, %rdi
xorl %esi, %esi
jmp 0x261ed
movq 0x50(%r14), %rax
leaq 0x8(%rsp), %r13
movq %rbp, %rdi
movq %r15, %rsi
movq %r13, %rdx
movq %r12, %rcx
callq *0x4b8(%rax)
cmpl $0x0, (%r13)
je 0x261c9
xorl %r14d, %r14d
movq %r12, %r13
movq %rbx, %rdi
movq %r13, %rsi
callq 0x1a070
incq %r14
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
movq %r14, %rdx
callq 0x19130
movl 0x8(%rsp), %eax
addq $0x40, %r13
cmpq %rax, %r14
jb 0x2619e
movl $0x1, %ebp
movq %rbx, %rdi
movq %r15, %rsi
movl $0x1, %edx
callq 0x19160
movl 0x8(%rsp), %ecx
movl $0x40, %edx
movq %rbx, %rdi
movq %r12, %rsi
movl $0x1, %r8d
callq 0x197d0
movl %ebp, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq