// File: stetre[P]moonvulkan/src/objects.c
// Function: moonvulkan_checkxxxlist_nondispatchable
uint64_t* checkxxxlist_nondispatchable(lua_State *L, int arg, uint32_t *count, int *err, ud_t ***ud, const char *mt)
/* if ud != NULL, at return it will point to the array of ud_t* for the elements
 * i.e. ud[i] = the ud for element i  (also this array must be Free'd by the caller).
 */
    {
    uint64_t* list;
    uint32_t i;

    *count = 0;
    *err = 0;
    if(ud) *ud = NULL;
    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 = (uint64_t*)MallocNoErr(L, sizeof(uint64_t) * (*count));
    if(!list)
        { *count = 0; *err = ERR_MEMORY; return NULL; }
    if(ud)
        {
        *ud = (ud_t**)MallocNoErr(L, sizeof(ud_t*) *(*count));
        if(!*ud)
            { Free(L, list); *count = 0; *err = ERR_MEMORY; return NULL; }
        }
    
    if(ud)
        {
        for(i=0; i<*count; i++)
            {
            lua_rawgeti(L, arg, i+1);
            (void)testxxx(L, -1, ud[i], mt);
            if(!*ud[i])
                {  Free(L, list); Free(L, *ud); *count = 0; *err = ERR_TYPE; return NULL; }
            list[i] = (*ud[i])->handle;
            lua_pop(L, 1);
            }
        }
    else
        {
        for(i=0; i<*count; i++)
            {
            lua_rawgeti(L, arg, i+1);
            list[i] = (uint64_t)testxxx(L, -1, NULL, mt);
            if(!list[i])
                { Free(L, list); *count = 0; *err = ERR_TYPE; return NULL; }
            lua_pop(L, 1);
            }
        }
    return list;
    }

// Assembly:
subq $0x48, %rsp
movq %rdi, 0x38(%rsp)
movl %esi, 0x34(%rsp)
movq %rdx, 0x28(%rsp)
movq %rcx, 0x20(%rsp)
movq %r8, 0x18(%rsp)
movq %r9, 0x10(%rsp)
movq 0x28(%rsp), %rax
movl $0x0, (%rax)
movq 0x20(%rsp), %rax
movl $0x0, (%rax)
cmpq $0x0, 0x18(%rsp)
je 0x5b0cb
movq 0x18(%rsp), %rax
movq $0x0, (%rax)
movq 0x38(%rsp), %rdi
movl 0x34(%rsp), %esi
callq 0x1a240
cmpl $0x0, %eax
jg 0x5b0f7
movq 0x20(%rsp), %rax
movl $0x1, (%rax)
movq $0x0, 0x40(%rsp)
jmp 0x5b3cf
movq 0x38(%rsp), %rdi
movl 0x34(%rsp), %esi
callq 0x1a240
cmpl $0x5, %eax
je 0x5b123
movq 0x20(%rsp), %rax
movl $0xfffffffc, (%rax)     # imm = 0xFFFFFFFC
movq $0x0, 0x40(%rsp)
jmp 0x5b3cf
movq 0x38(%rsp), %rdi
movl 0x34(%rsp), %esi
callq 0x1a270
movl %eax, %ecx
movq 0x28(%rsp), %rax
movl %ecx, (%rax)
movq 0x28(%rsp), %rax
cmpl $0x0, (%rax)
jne 0x5b15d
movq 0x20(%rsp), %rax
movl $0xfffffffb, (%rax)     # imm = 0xFFFFFFFB
movq $0x0, 0x40(%rsp)
jmp 0x5b3cf
movq 0x38(%rsp), %rdi
movq 0x28(%rsp), %rax
movl (%rax), %eax
movl %eax, %esi
shlq $0x3, %rsi
callq 0x18050
movq %rax, 0x8(%rsp)
cmpq $0x0, 0x8(%rsp)
jne 0x5b1a5
movq 0x28(%rsp), %rax
movl $0x0, (%rax)
movq 0x20(%rsp), %rax
movl $0xfffffffa, (%rax)     # imm = 0xFFFFFFFA
movq $0x0, 0x40(%rsp)
jmp 0x5b3cf
cmpq $0x0, 0x18(%rsp)
je 0x5b20f
movq 0x38(%rsp), %rdi
movq 0x28(%rsp), %rax
movl (%rax), %eax
movl %eax, %esi
shlq $0x3, %rsi
callq 0x18050
movq %rax, %rcx
movq 0x18(%rsp), %rax
movq %rcx, (%rax)
movq 0x18(%rsp), %rax
cmpq $0x0, (%rax)
jne 0x5b20d
movq 0x38(%rsp), %rdi
movq 0x8(%rsp), %rsi
callq 0x18300
movq 0x28(%rsp), %rax
movl $0x0, (%rax)
movq 0x20(%rsp), %rax
movl $0xfffffffa, (%rax)     # imm = 0xFFFFFFFA
movq $0x0, 0x40(%rsp)
jmp 0x5b3cf
jmp 0x5b20f
cmpq $0x0, 0x18(%rsp)
je 0x5b30a
movl $0x0, 0x4(%rsp)
movl 0x4(%rsp), %eax
movq 0x28(%rsp), %rcx
cmpl (%rcx), %eax
jae 0x5b305
movq 0x38(%rsp), %rdi
movl 0x34(%rsp), %esi
movl 0x4(%rsp), %eax
addl $0x1, %eax
movl %eax, %eax
movl %eax, %edx
callq 0x189e0
movq 0x38(%rsp), %rdi
movq 0x18(%rsp), %rax
movl 0x4(%rsp), %ecx
movq (%rax,%rcx,8), %rdx
movq 0x10(%rsp), %rcx
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x1a5f0
movq 0x18(%rsp), %rax
movl 0x4(%rsp), %ecx
movq (%rax,%rcx,8), %rax
cmpq $0x0, (%rax)
jne 0x5b2c6
movq 0x38(%rsp), %rdi
movq 0x8(%rsp), %rsi
callq 0x18300
movq 0x38(%rsp), %rdi
movq 0x18(%rsp), %rax
movq (%rax), %rsi
callq 0x18300
movq 0x28(%rsp), %rax
movl $0x0, (%rax)
movq 0x20(%rsp), %rax
movl $0xfffffffe, (%rax)     # imm = 0xFFFFFFFE
movq $0x0, 0x40(%rsp)
jmp 0x5b3cf
movq 0x18(%rsp), %rax
movl 0x4(%rsp), %ecx
movq (%rax,%rcx,8), %rax
movq (%rax), %rax
movq (%rax), %rdx
movq 0x8(%rsp), %rax
movl 0x4(%rsp), %ecx
movq %rdx, (%rax,%rcx,8)
movq 0x38(%rsp), %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x18170
movl 0x4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x4(%rsp)
jmp 0x5b223
jmp 0x5b3c5
movl $0x0, 0x4(%rsp)
movl 0x4(%rsp), %eax
movq 0x28(%rsp), %rcx
cmpl (%rcx), %eax
jae 0x5b3c3
movq 0x38(%rsp), %rdi
movl 0x34(%rsp), %esi
movl 0x4(%rsp), %eax
addl $0x1, %eax
movl %eax, %eax
movl %eax, %edx
callq 0x189e0
movq 0x38(%rsp), %rdi
movq 0x10(%rsp), %rcx
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
xorl %eax, %eax
movl %eax, %edx
callq 0x1a5f0
movq %rax, %rdx
movq 0x8(%rsp), %rax
movl 0x4(%rsp), %ecx
movq %rdx, (%rax,%rcx,8)
movq 0x8(%rsp), %rax
movl 0x4(%rsp), %ecx
cmpq $0x0, (%rax,%rcx,8)
jne 0x5b3a4
movq 0x38(%rsp), %rdi
movq 0x8(%rsp), %rsi
callq 0x18300
movq 0x28(%rsp), %rax
movl $0x0, (%rax)
movq 0x20(%rsp), %rax
movl $0xfffffffe, (%rax)     # imm = 0xFFFFFFFE
movq $0x0, 0x40(%rsp)
jmp 0x5b3cf
movq 0x38(%rsp), %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x18170
movl 0x4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x4(%rsp)
jmp 0x5b312
jmp 0x5b3c5
movq 0x8(%rsp), %rax
movq %rax, 0x40(%rsp)
movq 0x40(%rsp), %rax
addq $0x48, %rsp
retq
nopl (%rax)