// File: /workspace/github_cpp_makefile_star2_O2/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 0x583f0(%rip), %rcx     # 0x7d99a
pushq $0x1
popq %rbp
leaq 0x10(%rsp), %r14
movl %ebp, %esi
movq %r14, %rdx
callq 0x1a500
movq %rax, %r12
movq (%r14), %r14
movq 0x20(%r14), %r13
movq 0x50(%r14), %rax
cmpq $0x0, 0x4b8(%rax)
je 0x2564c
movq %r13, %rbp
pushq $0x2
popq %rsi
movq %rbx, %rdi
callq 0x1a110
cmpl $0x5, %eax
jne 0x256e4
pushq $0x2
popq %rsi
leaq 0xc(%rsp), %r13
movq %rbx, %rdi
movq %r13, %rdx
callq 0x18770
movq %rax, %r15
cmpl $0x0, (%r13)
je 0x25730
pushq $0x1
popq %rbp
movq %rbx, %rdi
movq %r15, %rsi
movl %ebp, %edx
callq 0x19150
pushq $0x40
popq %rdx
movq %rbx, %rdi
xorl %esi, %esi
movl %ebp, %r8d
callq 0x197e0
pushq $-0x1
popq %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0x18680
pushq $0x2
popq %rsi
movq %rbx, %rdi
movq %rax, %rdx
callq 0x18420
jmp 0x257a9
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 0x25843
imulq $0x30, %rax, %rsi
movq %rbx, %rdi
callq 0x191f0
movq %rax, %r15
movq 0x10(%rsp), %rax
movq 0x50(%rax), %rax
leaq 0xc(%rsp), %rdx
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rcx
callq *0x80(%rax)
xorl %r14d, %r14d
pushq $-0x2
popq %r12
movq %r15, %r13
movl 0xc(%rsp), %eax
cmpq %rax, %r14
jae 0x25720
movq %rbx, %rdi
movq %r13, %rsi
callq 0x18140
incq %r14
movq %rbx, %rdi
movl %r12d, %esi
movq %r14, %rdx
callq 0x19120
addq $0x30, %r13
jmp 0x256b9
pushq $0x18
popq %rdx
leaq 0xc(%rsp), %r13
movq %rbx, %rdi
movl $0x3b9d0452, %esi       # imm = 0x3B9D0452
movq %r13, %rcx
callq 0x19dc0
movq %rax, %r15
cmpl $0x0, (%r13)
je 0x25730
pushq $0x1
popq %rbp
movq %rbx, %rdi
movq %r15, %rsi
movl %ebp, %edx
callq 0x19150
pushq $0x40
popq %rdx
movq %rbx, %rdi
xorl %esi, %esi
jmp 0x25799
movq %rbx, %rdi
movq %r15, %rsi
callq 0x182e0
jmp 0x25843
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 0x257b0
leaq 0xc(%rsp), %r13
movq %rbx, %rdi
movq %r13, %rdx
callq 0x19bf0
movq %rax, %r12
cmpl $0x0, (%r13)
je 0x257ce
pushq $0x1
popq %rbp
movq %rbx, %rdi
movq %r15, %rsi
movl %ebp, %edx
callq 0x19150
movl 0x8(%rsp), %ecx
pushq $0x40
popq %rdx
movq %rbx, %rdi
movq %r12, %rsi
movl %ebp, %r8d
callq 0x197e0
movq %rbx, %rdi
callq 0x199c0
movl %eax, %ebp
jmp 0x25843
pushq $0x1
popq %rbp
movq %rbx, %rdi
movq %r15, %rsi
movl %ebp, %edx
callq 0x19150
movl 0x8(%rsp), %ecx
pushq $0x40
popq %rdx
movq %rbx, %rdi
xorl %esi, %esi
jmp 0x2583b
movq 0x50(%r14), %rax
leaq 0x8(%rsp), %rdx
movq %rbp, %rdi
movq %r15, %rsi
movq %r12, %rcx
callq *0x4b8(%rax)
pushq $0x1
popq %r14
pushq $-0x2
popq %rbp
movq %r12, %r13
leaq -0x1(%r14), %rax
movl 0x8(%rsp), %ecx
cmpq %rcx, %rax
jae 0x2581e
movq %rbx, %rdi
movq %r13, %rsi
callq 0x1a090
movq %rbx, %rdi
movl %ebp, %esi
movq %r14, %rdx
callq 0x19120
incq %r14
addq $0x40, %r13
jmp 0x257f0
pushq $0x1
popq %rbp
movq %rbx, %rdi
movq %r15, %rsi
movl %ebp, %edx
callq 0x19150
movl 0x8(%rsp), %ecx
pushq $0x40
popq %rdx
movq %rbx, %rdi
movq %r12, %rsi
movl %ebp, %r8d
callq 0x197e0
movl %ebp, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq