// File: /workspace/github_c_makefile_star2_O2/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
pushq $0x13
popq %rsi
pushq $0x1
popq %rdx
callq 0x11150
movl %eax, %r12d
pushq $0x2
popq %rsi
movq %rbx, %rdi
callq 0x11af0
movq %rax, %r13
pushq $0x11
popq %rsi
pushq $0x3
popq %rdx
movq %rbx, %rdi
callq 0x11150
movl %eax, %ebp
pushq $0x12
popq %rsi
pushq $0x4
popq %rdx
movq %rbx, %rdi
callq 0x11150
movl %eax, %r15d
pushq $0x7
popq %rsi
pushq $0x5
popq %rdx
movq %rbx, %rdi
callq 0x11150
movl %eax, %r14d
movq %rbx, %rdi
movl $0x88ef, %esi           # imm = 0x88EF
callq 0x11a70
testl %eax, %eax
movq %r14, 0x10(%rsp)
movl %ebp, 0xc(%rsp)
pushq $0x6
popq %rsi
movq %rbx, %rdi
je 0x34525
callq 0x11af0
movq %rax, %r14
pushq $0x7
popq %rsi
movq %rbx, %rdi
callq 0x11af0
movq %rax, %rbp
pushq $0x8
popq %rsi
movq %rbx, %rdi
callq 0x11850
testl %eax, %eax
jle 0x34553
movq %r15, 0x18(%rsp)
pushq $0x8
popq %rsi
movq %rbx, %rdi
callq 0x11af0
movq %rax, %r15
pushq $0x9
popq %rsi
movq %rbx, %rdi
callq 0x11850
testl %eax, %eax
jle 0x34574
pushq $0x9
popq %rsi
movq %rbx, %rdi
callq 0x11af0
movq 0x215fe(%rip), %r10     # 0x55b00
movl %r12d, %edi
movl %r13d, %esi
movl 0xc(%rsp), %edx
movl %ebp, %ecx
movl %r15d, %r8d
movl %eax, %r9d
pushq %r14
pushq 0x18(%rsp)
pushq 0x28(%rsp)
pushq $0x0
callq *(%r10)
jmp 0x34599
callq 0x11850
testl %eax, %eax
je 0x345b6
pushq $0x6
popq %rsi
movq %rbx, %rdi
callq 0x110b0
pushq $0x6
popq %rsi
movq %rbx, %rdi
testl %eax, %eax
je 0x345be
xorl %edx, %edx
callq 0x11440
jmp 0x344a6
movl %r12d, %edi
movl %r13d, %esi
movl 0xc(%rsp), %edx
movl %ebp, %ecx
xorl %r8d, %r8d
movl %r15d, %r9d
pushq %r14
pushq 0x18(%rsp)
callq 0x11a30
popq %rax
popq %rcx
jmp 0x3459d
subq $0x8, %rsp
movl %r12d, %edi
movl %r13d, %esi
movl 0x14(%rsp), %edx
movl %ebp, %ecx
movl %r15d, %r8d
xorl %r9d, %r9d
pushq %r14
pushq 0x20(%rsp)
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 0x344a9
callq 0x11850
cmpl $0x5, %eax
jne 0x345dd
pushq $0x6
popq %rsi
leaq 0x20(%rsp), %rdx
movq %rbx, %rdi
callq 0x11b20
jmp 0x344a6
leaq 0x6c14(%rip), %rdx      # 0x3b1f8
pushq $0x6
popq %rsi
movq %rbx, %rdi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x11930