// File: /workspace/github_c_makefile_star2_O0/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:
subq $0x28, %rsp
movq %rdi, 0x18(%rsp)
movl %esi, 0x14(%rsp)
movq %rdx, 0x8(%rsp)
movq 0x18(%rsp), %rdi
movl 0x14(%rsp), %esi
callq 0x5610
cmpl $0x5, %eax
je 0x18603
movq 0x18(%rsp), %rdi
movl 0x14(%rsp), %esi
leaq 0x6831(%rip), %rdx      # 0x1ee26
callq 0x5140
movl %eax, 0x24(%rsp)
jmp 0x18883
movq 0x18(%rsp), %rdi
movl 0x14(%rsp), %esi
addl $0x1, %esi
callq 0x5610
cmpl $0x5, %eax
je 0x1863a
movq 0x18(%rsp), %rdi
movl 0x14(%rsp), %esi
addl $0x1, %esi
leaq 0x67fa(%rip), %rdx      # 0x1ee26
callq 0x5140
movl %eax, 0x24(%rsp)
jmp 0x18883
movq 0x18(%rsp), %rdi
movl 0x14(%rsp), %esi
addl $0x2, %esi
callq 0x5610
cmpl $0x5, %eax
je 0x18671
movq 0x18(%rsp), %rdi
movl 0x14(%rsp), %esi
addl $0x2, %esi
leaq 0x67c3(%rip), %rdx      # 0x1ee26
callq 0x5140
movl %eax, 0x24(%rsp)
jmp 0x18883
movq 0x18(%rsp), %rdi
movl 0x14(%rsp), %esi
callq 0x5630
movl %eax, %ecx
movq 0x8(%rsp), %rax
movl %ecx, 0x18(%rax)
movq 0x8(%rsp), %rax
cmpl $0x0, 0x18(%rax)
jne 0x186b2
movq 0x18(%rsp), %rdi
movl 0x14(%rsp), %esi
leaq 0x6791(%rip), %rdx      # 0x1ee35
callq 0x5140
movl %eax, 0x24(%rsp)
jmp 0x18883
movq 0x18(%rsp), %rdi
movl 0x14(%rsp), %esi
addl $0x1, %esi
callq 0x5630
movq 0x8(%rsp), %rcx
movl 0x18(%rcx), %ecx
cmpq %rcx, %rax
jne 0x186ee
movq 0x18(%rsp), %rdi
movl 0x14(%rsp), %esi
addl $0x2, %esi
callq 0x5630
movq 0x8(%rsp), %rcx
movl 0x18(%rcx), %ecx
cmpq %rcx, %rax
je 0x1870c
movq 0x18(%rsp), %rdi
movl 0x14(%rsp), %esi
leaq 0x6743(%rip), %rdx      # 0x1ee41
callq 0x5140
movl %eax, 0x24(%rsp)
jmp 0x18883
movq 0x8(%rsp), %rax
movl 0x18(%rax), %eax
movl %eax, %edi
shlq %rdi
callq 0x5490
movq %rax, %rcx
movq 0x8(%rsp), %rax
movq %rcx, (%rax)
movq 0x8(%rsp), %rax
movl 0x18(%rax), %eax
movl %eax, %edi
shlq %rdi
callq 0x5490
movq %rax, %rcx
movq 0x8(%rsp), %rax
movq %rcx, 0x8(%rax)
movq 0x8(%rsp), %rax
movl 0x18(%rax), %eax
movl %eax, %edi
shlq %rdi
callq 0x5490
movq %rax, %rcx
movq 0x8(%rsp), %rax
movq %rcx, 0x10(%rax)
movw $0x0, 0x6(%rsp)
movzwl 0x6(%rsp), %eax
movq 0x8(%rsp), %rcx
cmpl 0x18(%rcx), %eax
jae 0x1887b
movq 0x18(%rsp), %rdi
movl 0x14(%rsp), %esi
movzwl 0x6(%rsp), %eax
addl $0x1, %eax
movslq %eax, %rdx
callq 0x56b0
movq 0x18(%rsp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x53c0
movw %ax, %dx
movq 0x8(%rsp), %rax
movq (%rax), %rax
movzwl 0x6(%rsp), %ecx
movw %dx, (%rax,%rcx,2)
movq 0x18(%rsp), %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x50d0
movq 0x18(%rsp), %rdi
movl 0x14(%rsp), %esi
addl $0x1, %esi
movzwl 0x6(%rsp), %eax
addl $0x1, %eax
movslq %eax, %rdx
callq 0x56b0
movq 0x18(%rsp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x53c0
movw %ax, %dx
movq 0x8(%rsp), %rax
movq 0x8(%rax), %rax
movzwl 0x6(%rsp), %ecx
movw %dx, (%rax,%rcx,2)
movq 0x18(%rsp), %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x50d0
movq 0x18(%rsp), %rdi
movl 0x14(%rsp), %esi
addl $0x2, %esi
movzwl 0x6(%rsp), %eax
addl $0x1, %eax
movslq %eax, %rdx
callq 0x56b0
movq 0x18(%rsp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x53c0
movw %ax, %dx
movq 0x8(%rsp), %rax
movq 0x10(%rax), %rax
movzwl 0x6(%rsp), %ecx
movw %dx, (%rax,%rcx,2)
movq 0x18(%rsp), %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x50d0
movw 0x6(%rsp), %ax
addw $0x1, %ax
movw %ax, 0x6(%rsp)
jmp 0x1876c
movl $0x0, 0x24(%rsp)
movl 0x24(%rsp), %eax
addq $0x28, %rsp
retq
nopl (%rax)