// File: /workspace/github_c_makefile_star2_O2/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
pushq $0x1
popq %rsi
leaq 0xc(%rsp), %rdx
pushq $0x13
popq %rcx
callq 0x11420
movl %eax, %ebp
pushq $0x2
popq %rsi
movq %rbx, %rdi
callq 0x11af0
movq %rax, %r14
pushq $0x12
popq %rsi
pushq $0x3
popq %rdx
movq %rbx, %rdi
callq 0x11150
movl %eax, %r12d
pushq $0x7
popq %rsi
pushq $0x4
popq %rdx
movq %rbx, %rdi
callq 0x11150
movl %eax, %r13d
movq %rbx, %rdi
movl $0x88ef, %esi           # imm = 0x88EF
callq 0x11a70
testl %eax, %eax
movq %r14, 0x10(%rsp)
pushq $0x5
popq %rsi
movq %rbx, %rdi
je 0x34716
callq 0x11af0
movq %rax, (%rsp)
pushq $0x6
popq %rsi
movq %rbx, %rdi
callq 0x11af0
movq %rax, %r14
pushq $0x7
popq %rsi
movq %rbx, %rdi
callq 0x11af0
movq %rax, %r15
pushq $0x8
popq %rsi
movq %rbx, %rdi
callq 0x11850
testl %eax, %eax
jle 0x34748
movq %r13, 0x18(%rsp)
movq %r12, 0x20(%rsp)
pushq $0x8
popq %rsi
movq %rbx, %rdi
callq 0x11af0
movq %rax, %r12
pushq $0x9
popq %rsi
movq %rbx, %rdi
callq 0x11af0
movq %rax, %r13
pushq $0xa
popq %rsi
movq %rbx, %rdi
callq 0x11850
testl %eax, %eax
jle 0x3477d
pushq $0xa
popq %rsi
movq %rbx, %rdi
callq 0x11af0
movq %rax, 0x28(%rsp)
pushq $0xb
popq %rsi
movq %rbx, %rdi
callq 0x11af0
testl %ebp, %ebp
je 0x347c3
movq 0x215cd(%rip), %r10     # 0x55cd8
subq $0x8, %rsp
movl %ebp, %edi
jmp 0x347d2
callq 0x11850
testl %eax, %eax
je 0x347b6
pushq $0x5
popq %rsi
movq %rbx, %rdi
callq 0x110b0
pushq $0x5
popq %rsi
movq %rbx, %rdi
testl %eax, %eax
je 0x34823
xorl %edx, %edx
callq 0x11440
jmp 0x34675
testl %ebp, %ebp
je 0x347fd
movq 0x213b1(%rip), %rax     # 0x55b08
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)
addq $0x10, %rsp
jmp 0x34870
testl %ebp, %ebp
je 0x34842
movq 0x21184(%rip), %rax     # 0x55910
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 0x3486c
movq $0x0, (%rsp)
jmp 0x34679
movq 0x217de(%rip), %r10     # 0x55fa8
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 0x34870
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
popq %rax
popq %rcx
jmp 0x34870
callq 0x11850
cmpl $0x5, %eax
jne 0x34889
pushq $0x5
popq %rsi
leaq 0x30(%rsp), %rdx
movq %rbx, %rdi
callq 0x11b20
jmp 0x34675
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 0x6968(%rip), %rdx      # 0x3b1f8
pushq $0x5
popq %rsi
movq %rbx, %rdi
callq 0x11930
jmp 0x3487a