// File: /workspace/github_c_makefile_star2_O0/stetre[P]moonglmath/src/mat.c
// Function: moonglmath_testmat
int testmat(lua_State *L, int arg, mat_t m, size_t *nr, size_t *nc)
    {
    int row;
    size_t i, j, nr_, nc_;
    if(!testmetatable(L, arg, MAT_MT))
        return 0;

    lua_getfield(L, arg, "rows");   
    nr_ = luaL_checkinteger(L, -1);
    lua_pop(L, 1);
    lua_getfield(L, arg, "columns");    
    nc_ = luaL_checkinteger(L, -1);
    lua_pop(L, 1);
    checkmatsize(L, nr_, nc_);

    if(nr) *nr = nr_;
    if(nc) *nc = nc_;
    if(m)
        {
        for(i=0; i < nr_; i++)
            {
            if(lua_geti(L, arg, i+1) != LUA_TTABLE)
                return luaL_error(L, "malformed matrix");
            row = lua_gettop(L);
            for(j=0; j < nc_; j++)
                {
                lua_geti(L, row, j+1);
                m[i][j] = luaL_checknumber(L, -1);
                lua_pop(L, 1);
                }
            lua_pop(L, 1);
            }
        }
    return 1;
    }

// Assembly:
subq $0x58, %rsp
movq %rdi, 0x48(%rsp)
movl %esi, 0x44(%rsp)
movq %rdx, 0x38(%rsp)
movq %rcx, 0x30(%rsp)
movq %r8, 0x28(%rsp)
movq 0x48(%rsp), %rdi
movl 0x44(%rsp), %esi
leaq 0x11559(%rip), %rdx     # 0x23355
callq 0x8180
cmpl $0x0, %eax
jne 0x11e13
movl $0x0, 0x54(%rsp)
jmp 0x11ff2
movq 0x48(%rsp), %rdi
movl 0x44(%rsp), %esi
leaq 0x11720(%rip), %rdx     # 0x23543
callq 0x8e80
movq 0x48(%rsp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x8740
movq %rax, 0x8(%rsp)
movq 0x48(%rsp), %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x80c0
movq 0x48(%rsp), %rdi
movl 0x44(%rsp), %esi
leaq 0x116ed(%rip), %rdx     # 0x23548
callq 0x8e80
movq 0x48(%rsp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x8740
movq %rax, (%rsp)
movq 0x48(%rsp), %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x80c0
cmpq $0x1, 0x8(%rsp)
jb 0x11ea0
cmpq $0x4, 0x8(%rsp)
ja 0x11ea0
cmpq $0x1, (%rsp)
jb 0x11ea0
cmpq $0x4, (%rsp)
jbe 0x11ebc
movq 0x48(%rsp), %rdi
leaq 0x116a4(%rip), %rsi     # 0x23550
movb $0x0, %al
callq 0x8b30
movl %eax, 0x54(%rsp)
jmp 0x11ff2
jmp 0x11ebe
cmpq $0x0, 0x30(%rsp)
je 0x11ed3
movq 0x8(%rsp), %rcx
movq 0x30(%rsp), %rax
movq %rcx, (%rax)
cmpq $0x0, 0x28(%rsp)
je 0x11ee7
movq (%rsp), %rcx
movq 0x28(%rsp), %rax
movq %rcx, (%rax)
cmpq $0x0, 0x38(%rsp)
je 0x11fea
movq $0x0, 0x18(%rsp)
movq 0x18(%rsp), %rax
cmpq 0x8(%rsp), %rax
jae 0x11fe8
movq 0x48(%rsp), %rdi
movl 0x44(%rsp), %esi
movq 0x18(%rsp), %rdx
addq $0x1, %rdx
callq 0x8e10
cmpl $0x5, %eax
je 0x11f44
movq 0x48(%rsp), %rdi
leaq 0x11630(%rip), %rsi     # 0x23564
movb $0x0, %al
callq 0x8b30
movl %eax, 0x54(%rsp)
jmp 0x11ff2
movq 0x48(%rsp), %rdi
callq 0x8060
movl %eax, 0x24(%rsp)
movq $0x0, 0x10(%rsp)
movq 0x10(%rsp), %rax
cmpq (%rsp), %rax
jae 0x11fc6
movq 0x48(%rsp), %rdi
movl 0x24(%rsp), %esi
movq 0x10(%rsp), %rdx
addq $0x1, %rdx
callq 0x8e10
movq 0x48(%rsp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x8350
movq 0x38(%rsp), %rax
movq 0x18(%rsp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq 0x10(%rsp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movq 0x48(%rsp), %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x80c0
movq 0x10(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x10(%rsp)
jmp 0x11f5b
movq 0x48(%rsp), %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x80c0
movq 0x18(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x18(%rsp)
jmp 0x11efc
jmp 0x11fea
movl $0x1, 0x54(%rsp)
movl 0x54(%rsp), %eax
addq $0x58, %rsp
retq
nopl (%rax,%rax)