// File: /workspace/github_cpp_makefile_star2_O1/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 0x69987(%rip), %rcx     # 0x8f99a
movl $0x1, %ebp
leaq 0x10(%rsp), %r14
movl $0x1, %esi
movq %r14, %rdx
callq 0x1a520
movq %rax, %r12
movq (%r14), %r14
movq 0x20(%r14), %r13
movq 0x50(%r14), %rax
cmpq $0x0, 0x4b8(%rax)
je 0x260cf
movq %r13, %rbp
movq %rbx, %rdi
movl $0x2, %esi
callq 0x1a130
leaq 0xc(%rsp), %r13
cmpl $0x5, %eax
jne 0x26181
movq %rbx, %rdi
movl $0x2, %esi
movq %r13, %rdx
callq 0x18780
movq %rax, %r15
cmpl $0x0, (%r13)
je 0x261c0
movq %rbx, %rdi
movq %r15, %rsi
movl $0x1, %edx
callq 0x19170
movl 0x8(%rsp), %ecx
movl $0x40, %edx
movq %rbx, %rdi
xorl %esi, %esi
movl $0x1, %r8d
callq 0x19800
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
xorl %edx, %edx
callq 0x18690
movq %rbx, %rdi
movl $0x2, %esi
movq %rax, %rdx
callq 0x18420
jmp 0x2623e
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x187e0
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 0x262ec
shlq $0x4, %rax
leaq (%rax,%rax,2), %rsi
movq %rbx, %rdi
callq 0x19210
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 0x26171
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 0x19140
movl 0xc(%rsp), %eax
addq $0x30, %r12
cmpq %rax, %r14
jb 0x26146
movq %rbx, %rdi
movq %r15, %rsi
callq 0x182e0
jmp 0x262ec
movl $0x18, %edx
movq %rbx, %rdi
movl $0x3b9d0452, %esi       # imm = 0x3B9D0452
movq %r13, %rcx
callq 0x19de0
movq %rax, %r15
cmpl $0x0, (%r13)
je 0x261c0
movq %rbx, %rdi
movq %r15, %rsi
movl $0x1, %edx
callq 0x19170
movl 0x8(%rsp), %ecx
movl $0x40, %edx
movq %rbx, %rdi
xorl %esi, %esi
jmp 0x2622b
movq %r12, 0x10(%r15)
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x187e0
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 0x26245
leaq 0xc(%rsp), %r13
movq %rbx, %rdi
movq %r13, %rdx
callq 0x19c10
movq %rax, %r12
cmpl $0x0, (%r13)
je 0x2626a
movq %rbx, %rdi
movq %r15, %rsi
movl $0x1, %edx
callq 0x19170
movl 0x8(%rsp), %ecx
movl $0x40, %edx
movq %rbx, %rdi
movq %r12, %rsi
movl $0x1, %r8d
callq 0x19800
movq %rbx, %rdi
callq 0x199e0
movl %eax, %ebp
jmp 0x262ec
movl $0x1, %ebp
movq %rbx, %rdi
movq %r15, %rsi
movl $0x1, %edx
callq 0x19170
movl 0x8(%rsp), %ecx
movl $0x40, %edx
movq %rbx, %rdi
xorl %esi, %esi
jmp 0x262e1
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 0x262bd
xorl %r14d, %r14d
movq %r12, %r13
movq %rbx, %rdi
movq %r13, %rsi
callq 0x1a0b0
incq %r14
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
movq %r14, %rdx
callq 0x19140
movl 0x8(%rsp), %eax
addq $0x40, %r13
cmpq %rax, %r14
jb 0x26292
movl $0x1, %ebp
movq %rbx, %rdi
movq %r15, %rsi
movl $0x1, %edx
callq 0x19170
movl 0x8(%rsp), %ecx
movl $0x40, %edx
movq %rbx, %rdi
movq %r12, %rsi
movl $0x1, %r8d
callq 0x19800
movl %ebp, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq