// File: /workspace/github_c_makefile_star2_O3/stetre[P]moongl/src/teximage.c
// Function: TextureImage
static int TextureImage(lua_State *L)
    {
    intptr_t data;
    size_t len;
    GLsizei width, height, depth;
    int arg = 1;
    GLenum target = checktexturetarget(L, arg++);
    GLint level = luaL_checkinteger(L, arg++);
    GLenum intfmt = checkinternalformat(L, arg++);
    GLenum format = checkformat(L, arg++);
    GLenum type = checktype(L, arg++);
    GLint64 bound_buffer = getUint(L, GL_PIXEL_UNPACK_BUFFER_BINDING);
    if(bound_buffer == 0) /* no buffer is bound to GL_PIXEL_UNPACK_BUFFER */
        {
        if(lua_isnil(L, arg)) /* no pixel transfer */
            { data = 0; arg++; }
        else if(lua_isstring(L, arg))
            data = (intptr_t)luaL_checkstring(L, arg++);
        else if(lua_istable(L, arg))
            data = (intptr_t)checkdataptr(L, arg++, &len);
        else
            return luaL_argerror(L, arg, "invalid type");
        }
    else /* a buffer is bound to GL_PIXEL_UNPACK_BUFFER, so data must be an offset */
        data = luaL_checkinteger(L, arg++);
    width = luaL_checkinteger(L, arg++);
    if(lua_isnoneornil(L, arg))
        {
        glTexImage1D(target,level,intfmt,width,border,format,type,(void*)data);
        CheckError(L);
        return 0;
        }
    height = luaL_checkinteger(L, arg++);
    if(lua_isnoneornil(L, arg))
        {
        glTexImage2D(target,level,intfmt,width,height,border,format,type,(void*)data);
        CheckError(L);
        return 0;
        }
    depth = luaL_checkinteger(L, arg++);
    glTexImage3D(target,level,intfmt,width,height,depth,border,format,type,(void*)data);
    CheckError(L);
    return 0;
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %rbx
movl $0x13, %esi
movl $0x1, %edx
callq 0x11150
movl %eax, %r12d
movq %rbx, %rdi
movl $0x2, %esi
callq 0x11af0
movq %rax, %r14
movq %rbx, %rdi
movl $0x11, %esi
movl $0x3, %edx
callq 0x11150
movl %eax, %r15d
movq %rbx, %rdi
movl $0x12, %esi
movl $0x4, %edx
callq 0x11150
movl %eax, %ebp
movq %rbx, %rdi
movl $0x7, %esi
movl $0x5, %edx
callq 0x11150
movl %eax, %r13d
movq %rbx, %rdi
movl $0x88ef, %esi           # imm = 0x88EF
callq 0x11a70
testl %eax, %eax
movq %r14, 0x10(%rsp)
movl %r15d, 0xc(%rsp)
movq %rbx, %rdi
movl $0x6, %esi
je 0x373ad
callq 0x11af0
movq %rax, %r14
movq %rbx, %rdi
movl $0x7, %esi
callq 0x11af0
movq %rax, %r15
movq %rbx, %rdi
movl $0x8, %esi
callq 0x11850
testl %eax, %eax
jle 0x373df
movq %rbp, 0x18(%rsp)
movq %rbx, %rdi
movl $0x8, %esi
callq 0x11af0
movq %rax, %rbp
movq %rbx, %rdi
movl $0x9, %esi
callq 0x11850
testl %eax, %eax
jle 0x37403
movq %rbx, %rdi
movl $0x9, %esi
callq 0x11af0
movq 0x1f777(%rip), %r10     # 0x56b00
movl %r12d, %edi
movq 0x10(%rsp), %rsi
movl 0xc(%rsp), %edx
movl %r15d, %ecx
movl %ebp, %r8d
movl %eax, %r9d
pushq %r14
pushq %r13
pushq 0x28(%rsp)
pushq $0x0
callq *(%r10)
jmp 0x37429
callq 0x11850
testl %eax, %eax
je 0x37446
movq %rbx, %rdi
movl $0x6, %esi
callq 0x110b0
movq %rbx, %rdi
movl $0x6, %esi
testl %eax, %eax
je 0x3744e
xorl %edx, %edx
callq 0x11440
jmp 0x37323
movl %r12d, %edi
movq 0x10(%rsp), %rsi
movl 0xc(%rsp), %edx
movl %r15d, %ecx
xorl %r8d, %r8d
movl %ebp, %r9d
pushq %r14
pushq %r13
callq 0x11a30
addq $0x10, %rsp
jmp 0x3742d
subq $0x8, %rsp
movl %r12d, %edi
movq 0x18(%rsp), %rsi
movl 0x14(%rsp), %edx
movl %r15d, %ecx
movl %ebp, %r8d
xorl %r9d, %r9d
pushq %r14
pushq %r13
pushq 0x30(%rsp)
callq 0x11830
addq $0x20, %rsp
movq %rbx, %rdi
callq 0x11870
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %r14d, %r14d
jmp 0x37326
callq 0x11850
cmpl $0x5, %eax
jne 0x3746f
leaq 0x20(%rsp), %rdx
movq %rbx, %rdi
movl $0x6, %esi
callq 0x11b20
jmp 0x37323
leaq 0x7d82(%rip), %rdx      # 0x3f1f8
movq %rbx, %rdi
movl $0x6, %esi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x11930