// File: /workspace/github_c_makefile_star2_O3/stetre[P]moongl/src/teximage.c
// Function: TextureSubImage
static int TextureSubImage(lua_State *L)
    {
    intptr_t data;
    size_t len;
    int arg = 1;
    GLint v1, v2, v3, v4, v5, v6;
    GLenum target;
    GLuint texture = checktargetorname(L, arg++, &target, DOMAIN_TEXTURE_TARGET);
    GLint level = luaL_checkinteger(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++);
    v1 = luaL_checkinteger(L, arg++);
    v2 = luaL_checkinteger(L, arg++);
    if(lua_isnoneornil(L, arg))
        {
        if(texture==0)
            glTexSubImage1D(target, level, v1, v2, format, type, (void*)data);
        else
            glTextureSubImage1D(texture, level, v1, v2, format, type, (void*)data);
        CheckError(L);
        return 0;
        }
    v3 = luaL_checkinteger(L, arg++);
    v4 = luaL_checkinteger(L, arg++);
    if(lua_isnoneornil(L, arg))
        {
        if(texture==0)
            glTexSubImage2D(target, level, v1, v2, v3, v4, format, type, (void*)data);
        else
            glTextureSubImage2D(texture, level, v1, v2, v3, v4, format, type, (void*)data);
        CheckError(L);
        return 0;
        }
    v5 = luaL_checkinteger(L, arg++);
    v6 = luaL_checkinteger(L, arg++);
    if(texture==0)
        glTexSubImage3D(target,level, v1, v2, v3, v4, v5, v6,format,type,(void*)data);
    else
        glTextureSubImage3D(texture,level,v1, v2, v3, v4, v5, v6,format,type,(void*)data); 
    CheckError(L);
    return 0;
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdi, %rbx
leaq 0xc(%rsp), %rdx
movl $0x1, %esi
movl $0x13, %ecx
callq 0x11420
movl %eax, %ebp
movq %rbx, %rdi
movl $0x2, %esi
callq 0x11af0
movq %rax, %r14
movq %rbx, %rdi
movl $0x12, %esi
movl $0x3, %edx
callq 0x11150
movl %eax, %r12d
movq %rbx, %rdi
movl $0x7, %esi
movl $0x4, %edx
callq 0x11150
movl %eax, %r13d
movq %rbx, %rdi
movl $0x88ef, %esi           # imm = 0x88EF
callq 0x11a70
testl %eax, %eax
movq %r14, 0x10(%rsp)
movq %rbx, %rdi
movl $0x5, %esi
je 0x375ca
callq 0x11af0
movq %rax, (%rsp)
movq %rbx, %rdi
movl $0x6, %esi
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 0x37600
movq %r13, 0x18(%rsp)
movq %r12, 0x20(%rsp)
movq %rbx, %rdi
movl $0x8, %esi
callq 0x11af0
movq %rax, %r12
movq %rbx, %rdi
movl $0x9, %esi
callq 0x11af0
movq %rax, %r13
movq %rbx, %rdi
movl $0xa, %esi
callq 0x11850
testl %eax, %eax
jle 0x37631
movq %rbx, %rdi
movl $0xa, %esi
callq 0x11af0
movq %rax, 0x28(%rsp)
movq %rbx, %rdi
movl $0xb, %esi
callq 0x11af0
testl %ebp, %ebp
je 0x37677
movq 0x1f719(%rip), %r10     # 0x56cd8
subq $0x8, %rsp
movl %ebp, %edi
jmp 0x37686
callq 0x11850
testl %eax, %eax
je 0x3766a
movq %rbx, %rdi
movl $0x5, %esi
callq 0x110b0
movq %rbx, %rdi
movl $0x5, %esi
testl %eax, %eax
je 0x376d9
xorl %edx, %edx
callq 0x11440
jmp 0x37519
testl %ebp, %ebp
je 0x376b1
movq 0x1f4f9(%rip), %rax     # 0x56b08
subq $0x8, %rsp
movl %ebp, %edi
movq 0x18(%rsp), %rsi
movl %r14d, %edx
movl %r15d, %ecx
movl %r12d, %r8d
movl %r13d, %r9d
pushq 0x8(%rsp)
callq *(%rax)
jmp 0x376d3
testl %ebp, %ebp
je 0x376fa
movq 0x1f2d0(%rip), %rax     # 0x56910
subq $0x8, %rsp
movl %ebp, %edi
movq 0x18(%rsp), %rsi
movl %r14d, %edx
movl %r15d, %ecx
movl %r12d, %r8d
movl %r13d, %r9d
pushq 0x8(%rsp)
pushq 0x28(%rsp)
pushq 0x38(%rsp)
callq *(%rax)
jmp 0x37724
movq $0x0, (%rsp)
jmp 0x3751d
movq 0x1f92a(%rip), %r10     # 0x56fa8
movl 0xc(%rsp), %edi
subq $0x8, %rsp
movq 0x18(%rsp), %rsi
movl %r14d, %edx
movl %r15d, %ecx
movl %r12d, %r8d
movl %r13d, %r9d
pushq 0x8(%rsp)
pushq 0x28(%rsp)
pushq 0x38(%rsp)
pushq %rax
pushq 0x50(%rsp)
callq *(%r10)
addq $0x30, %rsp
jmp 0x37728
movl 0xc(%rsp), %edi
subq $0x8, %rsp
movq 0x18(%rsp), %rsi
movl %r14d, %edx
movl %r15d, %ecx
movl %r12d, %r8d
movl %r13d, %r9d
pushq 0x8(%rsp)
callq 0x11230
addq $0x10, %rsp
jmp 0x37728
callq 0x11850
cmpl $0x5, %eax
jne 0x37741
leaq 0x30(%rsp), %rdx
movq %rbx, %rdi
movl $0x5, %esi
callq 0x11b20
jmp 0x37519
movl 0xc(%rsp), %edi
subq $0x8, %rsp
movq 0x18(%rsp), %rsi
movl %r14d, %edx
movl %r15d, %ecx
movl %r12d, %r8d
movl %r13d, %r9d
pushq 0x8(%rsp)
pushq 0x28(%rsp)
pushq 0x38(%rsp)
callq 0x11950
addq $0x20, %rsp
movq %rbx, %rdi
callq 0x11870
xorl %eax, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x7ab0(%rip), %rdx      # 0x3f1f8
movq %rbx, %rdi
movl $0x5, %esi
callq 0x11930
jmp 0x37732