// File: /workspace/github_c_makefile_star2_O1/stetre[P]moonglfw/src/utils.c
// Function: moonglfw_checkgammaramp
int checkgammaramp(lua_State *L, int arg, GLFWgammaramp *ramp)
    {
    unsigned short i;
#define R arg
#define G arg+1
#define B arg+2
    if(!lua_istable(L,R))
        return luaL_argerror(L, R, "table expected");
    if(!lua_istable(L,G))
        return luaL_argerror(L, G, "table expected");
    if(!lua_istable(L,B))
        return luaL_argerror(L, B, "table expected");
    ramp->size = luaL_len(L, R);
    if(ramp->size == 0)
        return luaL_argerror(L, R, "empty array");
    if( (luaL_len(L, G) != ramp->size) || (luaL_len(L, B) != ramp->size))
        return luaL_argerror(L, R, "red, green and blue arrays do not have the same length");
    ramp->red = (unsigned short*)malloc(ramp->size * sizeof(unsigned short));
    ramp->green = (unsigned short*)malloc(ramp->size * sizeof(unsigned short));
    ramp->blue = (unsigned short*)malloc(ramp->size * sizeof(unsigned short));
    for(i=0; i < ramp->size; i++)
        {
        lua_geti(L, R, i+1); ramp->red[i] = luaL_checkinteger(L, -1); lua_pop(L, 1);
        lua_geti(L, G, i+1); ramp->green[i] = luaL_checkinteger(L, -1); lua_pop(L, 1);
        lua_geti(L, B, i+1); ramp->blue[i] = luaL_checkinteger(L, -1); lua_pop(L, 1);
        }
    return 0;
#undef R
#undef G
#undef B
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %r15
movl %esi, %r14d
movq %rdi, %rbx
callq 0x5620
cmpl $0x5, %eax
jne 0x10407
leal 0x1(%r14), %ebp
movq %rbx, %rdi
movl %ebp, %esi
callq 0x5620
cmpl $0x5, %eax
jne 0x10416
leal 0x2(%r14), %r12d
movq %rbx, %rdi
movl %r12d, %esi
callq 0x5620
cmpl $0x5, %eax
jne 0x10424
movq %rbx, %rdi
movl %r14d, %esi
callq 0x5640
movl %eax, 0x18(%r15)
testl %eax, %eax
je 0x1044d
movq %rbx, %rdi
movl %ebp, %esi
callq 0x5640
movl 0x18(%r15), %ecx
cmpq %rcx, %rax
jne 0x10444
movq %rbx, %rdi
movl %r12d, %esi
callq 0x5640
movl 0x18(%r15), %r13d
cmpq %r13, %rax
jne 0x10444
addq %r13, %r13
movq %r13, %rdi
callq 0x54a0
movq %rax, (%r15)
movq %r13, %rdi
callq 0x54a0
movq %rax, 0x8(%r15)
movq %r13, %rdi
callq 0x54a0
movq %rax, 0x10(%r15)
cmpl $0x0, 0x18(%r15)
movl %ebp, 0x4(%rsp)
movl %r12d, (%rsp)
je 0x103f6
xorl %r13d, %r13d
xorl %r12d, %r12d
incl %r13d
movq %rbx, %rdi
movl %r14d, %esi
movq %r13, %rdx
callq 0x56c0
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x53d0
movq (%r15), %rcx
movzwl %r12w, %ebp
addl %ebp, %ebp
movw %ax, (%rcx,%rbp)
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x50d0
movq %rbx, %rdi
movl 0x4(%rsp), %esi
movq %r13, %rdx
callq 0x56c0
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x53d0
movq 0x8(%r15), %rcx
movw %ax, (%rcx,%rbp)
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x50d0
movq %rbx, %rdi
movl (%rsp), %esi
movq %r13, %rdx
callq 0x56c0
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x53d0
movq 0x10(%r15), %rcx
movw %ax, (%rcx,%rbp)
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x50d0
incl %r12d
movzwl %r12w, %r13d
cmpl %r13d, 0x18(%r15)
ja 0x1034c
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x5a48(%rip), %rdx      # 0x15e56
movq %rbx, %rdi
movl %r14d, %esi
jmp 0x10431
leaq 0x5a39(%rip), %rdx      # 0x15e56
movq %rbx, %rdi
movl %ebp, %esi
jmp 0x10431
leaq 0x5a2b(%rip), %rdx      # 0x15e56
movq %rbx, %rdi
movl %r12d, %esi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x5150
leaq 0x5a26(%rip), %rdx      # 0x15e71
jmp 0x1040e
leaq 0x5a11(%rip), %rdx      # 0x15e65
jmp 0x1040e