// File: /workspace/github_cpp_makefile_star2_O1/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
movl %esi, %ebp
movq %rdi, %r15
xorl %eax, %eax
movq %rdx, (%rsp)
movl %eax, (%rdx)
movl %eax, (%rcx)
callq 0x1a130
testl %eax, %eax
jle 0x4fee6
movq %r15, %rdi
movl %ebp, %esi
callq 0x1a130
cmpl $0x5, %eax
jne 0x4fef2
movq %r15, %rdi
movl %ebp, %esi
callq 0x1a160
movq (%rsp), %rcx
movl %eax, (%rcx)
testl %eax, %eax
je 0x4fefe
movl %eax, %r13d
shlq $0x3, %r13
movq 0x744f4(%rip), %rax     # 0xc43c0
testq %rax, %rax
je 0x4ff0a
movq 0x744f0(%rip), %rdi     # 0xc43c8
xorl %esi, %esi
xorl %edx, %edx
movq %r13, %rcx
callq *%rax
movq %rax, %r12
jmp 0x4ff0d
movl $0x1, (%r14)
jmp 0x5000d
movl $0xfffffffc, (%r14)     # imm = 0xFFFFFFFC
jmp 0x5000d
movl $0xfffffffb, (%r14)     # imm = 0xFFFFFFFB
jmp 0x5000d
xorl %r12d, %r12d
testq %r12, %r12
je 0x4ff21
movq %r12, %rdi
xorl %esi, %esi
movq %r13, %rdx
callq 0x18b50
jmp 0x4ff24
xorl %r12d, %r12d
testq %r12, %r12
je 0x4fffc
xorl %ebx, %ebx
movq (%rsp), %rax
movl (%rax), %eax
cmpq %rax, %rbx
jae 0x50010
movq %rbx, %r13
incq %rbx
movq %r15, %rdi
movl %ebp, %esi
movq %rbx, %rdx
callq 0x18980
movq %r15, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x1a130
movq %r15, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
cmpl $0x4, %eax
jne 0x4ff8e
xorl %edx, %edx
callq 0x18690
movq %rax, %rdi
leaq 0x53bc9(%rip), %rsi     # 0xa3b45
callq 0x19000
testl %eax, %eax
je 0x4ffac
movl $0xfffffffd, (%r14)     # imm = 0xFFFFFFFD
jmp 0x4ffbd
callq 0x1a600
testl %eax, %eax
je 0x4ffb6
movq %r15, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
xorl %edx, %edx
callq 0x18640
movq %rax, (%r12,%r13,8)
jmp 0x4ffbd
movq $-0x1, (%r12,%r13,8)
jmp 0x4ffbd
movl $0xfffffffe, (%r14)     # imm = 0xFFFFFFFE
movq %r15, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x18150
cmpl $0x0, (%r14)
je 0x4ff2f
movq 0x743e5(%rip), %rax     # 0xc43c0
testq %rax, %rax
je 0x4fff0
movq 0x743e1(%rip), %rdi     # 0xc43c8
movq %r12, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
callq *%rax
movq (%rsp), %rax
movl $0x0, (%rax)
jmp 0x5000d
movq (%rsp), %rax
movl $0x0, (%rax)
movl $0xfffffffa, (%r14)     # imm = 0xFFFFFFFA
xorl %r12d, %r12d
movq %r12, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq