// File: /workspace/github_c_makefile_star2_O0/stetre[P]moongl/src/teximage.c
// Function: GetTextureImage
static int GetTextureImage(lua_State *L)
/* get_texture_image(target|texture, lod, format, type, n)
 * -> bstring or nil
 */
    {
    intptr_t data = 0;
    GLsizei bufsz = 0;
    int arg = 1;
    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++);
    intptr_t n = luaL_checkinteger(L, arg++);
    GLint64 bound_buffer = getUint(L, GL_PIXEL_PACK_BUFFER_BINDING);
    if(bound_buffer == 0)
        {
        /* no buffer is bound to GL_PIXEL_PACK_BUFFER, so treat n as the data size */
        bufsz = (GLsizei)n;
        data = (intptr_t)Malloc(L, bufsz *sizeof(char));
        if(texture==0)
            glGetTexImage(target, level, format, type, (void*)data);
        else
            glGetTextureImage(texture, level, format, type, bufsz, (void*)data);
        CheckErrorFree(L, (void*)data);
        lua_pushlstring(L, (char*)data, bufsz);
        Free(L, (void*)data);
        return 1;
        }
    else /* a buffer is bound to GL_PIXEL_PACK_BUFFER, so treat n as an offset */
        {
        if(texture==0)
            glGetTexImage(target, level, format, type, (void*)n);
        else
            glGetTextureImage(texture, level, format, type, 0, (void*)n);
        CheckError(L);
        }
    return 0;
    }

// Assembly:
subq $0x48, %rsp
movq %rdi, 0x38(%rsp)
movq $0x0, 0x30(%rsp)
movl $0x0, 0x2c(%rsp)
movl $0x1, 0x28(%rsp)
movq 0x38(%rsp), %rdi
movl 0x28(%rsp), %esi
movl %esi, %eax
addl $0x1, %eax
movl %eax, 0x28(%rsp)
leaq 0x24(%rsp), %rdx
movl $0x13, %ecx
callq 0x11430
movl %eax, 0x20(%rsp)
movq 0x38(%rsp), %rdi
movl 0x28(%rsp), %esi
movl %esi, %eax
addl $0x1, %eax
movl %eax, 0x28(%rsp)
callq 0x11af0
movl %eax, 0x1c(%rsp)
movq 0x38(%rsp), %rdi
movl 0x28(%rsp), %edx
movl %edx, %eax
addl $0x1, %eax
movl %eax, 0x28(%rsp)
movl $0x12, %esi
callq 0x11160
movl %eax, 0x18(%rsp)
movq 0x38(%rsp), %rdi
movl 0x28(%rsp), %edx
movl %edx, %eax
addl $0x1, %eax
movl %eax, 0x28(%rsp)
movl $0x7, %esi
callq 0x11160
movl %eax, 0x14(%rsp)
movq 0x38(%rsp), %rdi
movl 0x28(%rsp), %esi
movl %esi, %eax
addl $0x1, %eax
movl %eax, 0x28(%rsp)
callq 0x11af0
movq %rax, 0x8(%rsp)
movq 0x38(%rsp), %rdi
movl $0x88ed, %esi           # imm = 0x88ED
callq 0x11a70
movl %eax, %eax
movq %rax, (%rsp)
cmpq $0x0, (%rsp)
jne 0x47914
movq 0x8(%rsp), %rax
movl %eax, 0x2c(%rsp)
movq 0x38(%rsp), %rdi
movslq 0x2c(%rsp), %rsi
shlq $0x0, %rsi
callq 0x11200
movq %rax, 0x30(%rsp)
cmpl $0x0, 0x20(%rsp)
jne 0x478b2
movl 0x24(%rsp), %edi
movl 0x1c(%rsp), %esi
movl 0x18(%rsp), %edx
movl 0x14(%rsp), %ecx
movq 0x30(%rsp), %r8
callq 0x11500
jmp 0x478d8
movq 0x1fa2f(%rip), %rax     # 0x672e8
movq (%rax), %rax
movl 0x20(%rsp), %edi
movl 0x1c(%rsp), %esi
movl 0x18(%rsp), %edx
movl 0x14(%rsp), %ecx
movl 0x2c(%rsp), %r8d
movq 0x30(%rsp), %r9
callq *%rax
movq 0x38(%rsp), %rdi
movq 0x30(%rsp), %rsi
callq 0x11550
movq 0x38(%rsp), %rdi
movq 0x30(%rsp), %rsi
movslq 0x2c(%rsp), %rdx
callq 0x11ab0
movq 0x38(%rsp), %rdi
movq 0x30(%rsp), %rsi
callq 0x11370
movl $0x1, 0x44(%rsp)
jmp 0x4796d
cmpl $0x0, 0x20(%rsp)
jne 0x47937
movl 0x24(%rsp), %edi
movl 0x1c(%rsp), %esi
movl 0x18(%rsp), %edx
movl 0x14(%rsp), %ecx
movq 0x8(%rsp), %r8
callq 0x11500
jmp 0x4795b
movq 0x1f9aa(%rip), %rax     # 0x672e8
movq (%rax), %rax
movl 0x20(%rsp), %edi
movl 0x1c(%rsp), %esi
movl 0x18(%rsp), %edx
movl 0x14(%rsp), %ecx
movq 0x8(%rsp), %r9
xorl %r8d, %r8d
callq *%rax
movq 0x38(%rsp), %rdi
callq 0x11880
movl $0x0, 0x44(%rsp)
movl 0x44(%rsp), %eax
addq $0x48, %rsp
retq
nopw %cs:(%rax,%rax)