// File: /workspace/github_c_makefile_star2_O3/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 0x10530
leal 0x1(%r14), %ebp
movq %rbx, %rdi
movl %ebp, %esi
callq 0x5630
cmpl $0x5, %eax
jne 0x1053f
leal 0x2(%r14), %r12d
movq %rbx, %rdi
movl %r12d, %esi
callq 0x5630
cmpl $0x5, %eax
jne 0x1054d
movq %rbx, %rdi
movl %r14d, %esi
callq 0x5650
movl %eax, 0x18(%r15)
testl %eax, %eax
je 0x10576
movq %rbx, %rdi
movl %ebp, %esi
callq 0x5650
movl 0x18(%r15), %ecx
cmpq %rcx, %rax
jne 0x1056d
movq %rbx, %rdi
movl %r12d, %esi
callq 0x5650
movq %rax, %r13
movl 0x18(%r15), %eax
cmpq %rax, %r13
jne 0x1056d
addq %r13, %r13
movq %r13, %rdi
movq %rax, 0x8(%rsp)
callq 0x54b0
movq %rax, (%r15)
movq %r13, %rdi
callq 0x54b0
movq %rax, 0x8(%r15)
movq %r13, %rdi
callq 0x54b0
movq %rax, 0x10(%r15)
cmpl $0x0, 0x8(%rsp)
movl %ebp, 0x8(%rsp)
movl %r12d, 0x14(%rsp)
je 0x1051f
xorl %r13d, %r13d
xorl %r12d, %r12d
incl %r13d
movq %rbx, %rdi
movl %r14d, %esi
movq %r13, %rdx
callq 0x56d0
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x53e0
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 0x8(%rsp), %esi
movq %r13, %rdx
callq 0x56d0
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x53e0
movq 0x8(%r15), %rcx
movw %ax, (%rcx,%rbp)
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x50d0
movq %rbx, %rdi
movl 0x14(%rsp), %esi
movq %r13, %rdx
callq 0x56d0
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x53e0
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 0x10474
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x591f(%rip), %rdx      # 0x15e56
movq %rbx, %rdi
movl %r14d, %esi
jmp 0x1055a
leaq 0x5910(%rip), %rdx      # 0x15e56
movq %rbx, %rdi
movl %ebp, %esi
jmp 0x1055a
leaq 0x5902(%rip), %rdx      # 0x15e56
movq %rbx, %rdi
movl %r12d, %esi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x5150
leaq 0x58fd(%rip), %rdx      # 0x15e71
jmp 0x10537
leaq 0x58e8(%rip), %rdx      # 0x15e65
jmp 0x10537