// File: /workspace/github_cpp_makefile_star2_O1/stetre[P]moonvulkan/src/device_memory.c
// Function: GetDeviceImageSparseMemoryRequirements
static int GetDeviceImageSparseMemoryRequirements(lua_State *L)
    {
    int err;
    uint32_t count, i;
    ud_t *ud;
    VkDeviceImageMemoryRequirementsKHR *info = NULL;
    VkSparseImageMemoryRequirements2 *req = NULL;
    VkDevice device = checkdevice(L, 1, &ud);
    CheckDevicePfn(L, ud, GetDeviceImageSparseMemoryRequirementsKHR);
#define CLEANUP do {                                                \
    zfreeVkDeviceImageMemoryRequirementsKHR(L, info, 1);            \
    zfreearrayVkSparseImageMemoryRequirements2(L, req, count, 1);   \
} while(0)
    info = zcheckVkDeviceImageMemoryRequirementsKHR(L, 2, &err);
    if(err) { CLEANUP; return argerror(L, 2); }
    lua_newtable(L);
    ud->ddt->GetDeviceImageSparseMemoryRequirementsKHR(device, info, &count, NULL);
    if(count == 0) { CLEANUP; return 1; }
    req = znewchainarrayVkSparseImageMemoryRequirements2(L, count, &err);
    if(err) { CLEANUP; return lua_error(L); }
    ud->ddt->GetDeviceImageSparseMemoryRequirementsKHR(device, info, &count, req);
    for(i = 0; i <count; i++)
        {
        zpushVkSparseImageMemoryRequirements2(L, &req[i]);
        lua_rawseti(L, -2, i+1);
        }
    CLEANUP;
#undef CLEANUP
    return 1;
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
leaq 0x68ad4(%rip), %rcx     # 0x8f03b
leaq 0x10(%rsp), %r14
movl $0x1, %esi
movq %r14, %rdx
callq 0x1a520
movq %rax, %r12
movq (%r14), %rax
movq 0x50(%rax), %rax
cmpq $0x0, 0x878(%rax)
je 0x265f5
leaq 0xc(%rsp), %r15
movq %rbx, %rdi
movl $0x2, %esi
movq %r15, %rdx
callq 0x185d0
movq %rax, %r14
cmpl $0x0, (%r15)
je 0x26619
movq %rbx, %rdi
movq %r14, %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 0x26606
leaq 0x6ae3f(%rip), %rsi     # 0x9143b
movq %rbx, %rdi
xorl %eax, %eax
callq 0x19be0
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 0x10(%rsp), %rax
movq 0x50(%rax), %rax
leaq 0x8(%rsp), %r15
movq %r12, %rdi
movq %r14, %rsi
movq %r15, %rdx
xorl %ecx, %ecx
callq *0x878(%rax)
movl (%r15), %esi
testl %esi, %esi
je 0x2669c
leaq 0xc(%rsp), %r13
movq %rbx, %rdi
movq %r13, %rdx
callq 0x19c10
movq %rax, %r15
cmpl $0x0, (%r13)
je 0x266c1
movq %rbx, %rdi
movq %r14, %rsi
movl $0x1, %edx
callq 0x19170
movl 0x8(%rsp), %ecx
movl $0x40, %edx
movq %rbx, %rdi
movq %r15, %rsi
movl $0x1, %r8d
callq 0x19800
movq %rbx, %rdi
callq 0x199e0
jmp 0x26606
movl $0x1, %ebp
movq %rbx, %rdi
movq %r14, %rsi
movl $0x1, %edx
callq 0x19170
movl 0x8(%rsp), %ecx
movl $0x40, %edx
movq %rbx, %rdi
xorl %esi, %esi
jmp 0x2673d
movq 0x10(%rsp), %rax
movq 0x50(%rax), %rax
leaq 0x8(%rsp), %r13
movq %r12, %rdi
movq %r14, %rsi
movq %r13, %rdx
movq %r15, %rcx
callq *0x878(%rax)
cmpl $0x0, (%r13)
je 0x26719
xorl %r12d, %r12d
movq %r15, %r13
movq %rbx, %rdi
movq %r13, %rsi
callq 0x1a0b0
incq %r12
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
movq %r12, %rdx
callq 0x19140
movl 0x8(%rsp), %eax
addq $0x40, %r13
cmpq %rax, %r12
jb 0x266ee
movl $0x1, %ebp
movq %rbx, %rdi
movq %r14, %rsi
movl $0x1, %edx
callq 0x19170
movl 0x8(%rsp), %ecx
movl $0x40, %edx
movq %rbx, %rdi
movq %r15, %rsi
movl $0x1, %r8d
callq 0x19800
jmp 0x26608