// File: /workspace/github_c_makefile_star2_O2/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
subq $0x18, %rsp
movq %rdx, %r15
movl %esi, %r14d
movq %rdi, %rbx
callq 0x5630
cmpl $0x5, %eax
jne 0xfc96
leal 0x1(%r14), %r13d
movq %rbx, %rdi
movl %r13d, %esi
callq 0x5630
cmpl $0x5, %eax
jne 0xfca5
leal 0x2(%r14), %ebp
movq %rbx, %rdi
movl %ebp, %esi
callq 0x5630
cmpl $0x5, %eax
jne 0xfcb4
movq %rbx, %rdi
movl %r14d, %esi
callq 0x5650
movl %eax, 0x18(%r15)
testl %eax, %eax
je 0xfcdc
movl %ebp, 0x8(%rsp)
movq %rbx, %rdi
movl %r13d, %esi
callq 0x5650
movl 0x18(%r15), %ecx
cmpq %rcx, %rax
jne 0xfcd3
movq %rbx, %rdi
movl 0x8(%rsp), %esi
callq 0x5650
movl 0x18(%r15), %ebp
cmpq %rbp, %rax
jne 0xfcd3
movq %rax, %r12
movl %r13d, 0xc(%rsp)
addq %rax, %r12
movq %r12, %rdi
callq 0x54b0
movq %rax, (%r15)
movq %r12, %rdi
callq 0x54b0
movq %rax, 0x8(%r15)
movq %r12, %rdi
callq 0x54b0
movq %rax, 0x10(%r15)
xorl %r13d, %r13d
movq %r14, 0x10(%rsp)
movzwl %r13w, %r12d
cmpl %r12d, %ebp
jbe 0xfce5
leal 0x1(%r12), %r13d
movq %rbx, %rdi
movl %r14d, %esi
movq %r13, %rdx
callq 0x56d0
movq %rbx, %rdi
pushq $-0x1
popq %rsi
callq 0x53e0
movq (%r15), %rcx
addl %r12d, %r12d
movw %ax, (%rcx,%r12)
movq %rbx, %rdi
pushq $-0x2
popq %rsi
movl %esi, %r14d
callq 0x50d0
movq %rbx, %rdi
movl 0xc(%rsp), %esi
movq %r13, %rdx
callq 0x56d0
movq %rbx, %rdi
pushq $-0x1
popq %rbp
movl %ebp, %esi
callq 0x53e0
movq 0x8(%r15), %rcx
movw %ax, (%rcx,%r12)
movq %rbx, %rdi
movl %r14d, %esi
callq 0x50d0
movq %rbx, %rdi
movl 0x8(%rsp), %esi
movq %r13, %rdx
callq 0x56d0
movq %rbx, %rdi
movl %ebp, %esi
callq 0x53e0
movq 0x10(%r15), %rcx
movw %ax, (%rcx,%r12)
movq %rbx, %rdi
movl %r14d, %esi
movq 0x10(%rsp), %r14
callq 0x50d0
movl 0x18(%r15), %ebp
jmp 0xfbe7
leaq 0x51b9(%rip), %rdx      # 0x14e56
movq %rbx, %rdi
movl %r14d, %esi
jmp 0xfcc0
leaq 0x51aa(%rip), %rdx      # 0x14e56
movq %rbx, %rdi
movl %r13d, %esi
jmp 0xfcc0
leaq 0x519b(%rip), %rdx      # 0x14e56
movq %rbx, %rdi
movl %ebp, %esi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x5150
leaq 0x5197(%rip), %rdx      # 0x14e71
jmp 0xfc9d
leaq 0x5182(%rip), %rdx      # 0x14e65
jmp 0xfc9d
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq