// File: /workspace/github_cpp_makefile_star2_O3/stetre[P]moonvulkan/src/utils.c
// Function: moonvulkan_checkdevicesizelist
VkDeviceSize* checkdevicesizelist(lua_State *L, int arg, uint32_t *count, int *err)
    {
    const char *s;
    VkDeviceSize* list;
    uint32_t i;

    *count = 0;
    *err = 0;
    if(lua_isnoneornil(L, arg))
        { *err = ERR_NOTPRESENT; return NULL; }
    if(lua_type(L, arg) != LUA_TTABLE)
        { *err = ERR_TABLE; return NULL; }

    *count = luaL_len(L, arg);
    if(*count == 0)
        { *err = ERR_EMPTY; return NULL; }

    list = (VkDeviceSize*)MallocNoErr(L, sizeof(VkDeviceSize) * (*count));
    if(!list)
        { *count = 0; *err = ERR_MEMORY; return NULL; }

    for(i=0; i<*count; i++)
        {
        lua_rawgeti(L, arg, i+1);
        if(lua_type(L, -1) == LUA_TSTRING)
            {
            s = lua_tostring(L, -1);
            if(strcmp(s, "whole size") == 0)
                list[i] = VK_WHOLE_SIZE;
            else *err = ERR_VALUE;
            }
        else if(lua_isinteger(L, -1))
            list[i] = lua_tointeger(L, -1);
        else
            *err = ERR_TYPE;
        lua_pop(L, 1);
        if(*err)
            { Free(L, list); *count = 0; return NULL; }
        }
    return list;
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rcx, %r14
movq %rdx, %rbx
movl %esi, %ebp
movq %rdi, %r15
xorl %eax, %eax
movl %eax, (%rdx)
movl %eax, (%rcx)
callq 0x1a0f0
testl %eax, %eax
jle 0x4fce0
movq %r15, %rdi
movl %ebp, %esi
callq 0x1a0f0
cmpl $0x5, %eax
jne 0x4fce9
movq %r15, %rdi
movl %ebp, %esi
callq 0x1a120
movl %eax, (%rbx)
testl %eax, %eax
je 0x4fd01
movq 0x717cc(%rip), %r8      # 0xc13a0
testq %r8, %r8
je 0x4fcf2
movl %eax, %r13d
shlq $0x3, %r13
movq 0x717bd(%rip), %rdi     # 0xc13a8
xorl %esi, %esi
xorl %edx, %edx
movq %r13, %rcx
callq *%r8
testq %rax, %rax
je 0x4fcf2
xorl %r12d, %r12d
movq %rax, (%rsp)
movq %rax, %rdi
xorl %esi, %esi
movq %r13, %rdx
callq 0x18b40
movl (%rbx), %eax
cmpq %rax, %r12
jae 0x4fd19
movq %r12, %r13
incq %r12
movq %r15, %rdi
movl %ebp, %esi
movq %r12, %rdx
callq 0x18970
movq %r15, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x1a0f0
movq %r15, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
cmpl $0x4, %eax
jne 0x4fc6d
xorl %edx, %edx
callq 0x18680
movq %rax, %rdi
leaq 0x50f0a(%rip), %rsi     # 0xa0b65
callq 0x18ff0
testl %eax, %eax
je 0x4fc8f
movl $0xfffffffd, (%r14)     # imm = 0xFFFFFFFD
jmp 0x4fca4
callq 0x1a5c0
testl %eax, %eax
je 0x4fc9d
movq %r15, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
xorl %edx, %edx
callq 0x18630
movq (%rsp), %rcx
movq %rax, (%rcx,%r13,8)
jmp 0x4fca4
movq (%rsp), %rax
movq $-0x1, (%rax,%r13,8)
jmp 0x4fca4
movl $0xfffffffe, (%r14)     # imm = 0xFFFFFFFE
movq %r15, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x18150
cmpl $0x0, (%r14)
je 0x4fc12
movq 0x716de(%rip), %rax     # 0xc13a0
testq %rax, %rax
je 0x4fcd8
movq 0x716da(%rip), %rdi     # 0xc13a8
movq (%rsp), %rsi
xorl %edx, %edx
xorl %ecx, %ecx
callq *%rax
movl $0x0, (%rbx)
jmp 0x4fd08
movl $0x1, (%r14)
jmp 0x4fd08
movl $0xfffffffc, (%r14)     # imm = 0xFFFFFFFC
jmp 0x4fd08
movl $0x0, (%rbx)
movl $0xfffffffa, (%r14)     # imm = 0xFFFFFFFA
jmp 0x4fd08
movl $0xfffffffb, (%r14)     # imm = 0xFFFFFFFB
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq (%rsp), %rax
jmp 0x4fd0a