// File: /workspace/github_c_makefile_star2_O0/kieselsteini[P]PiXL-old/pixl.c
// Function: px_render_screen
static void px_render_screen(lua_State *L) {
  const SDL_Color *color;
  Uint8 *pixels, *p;
  int x, y, pitch;

  // check if we really have a texture
  if (texture == NULL) {
    if (SDL_SetRenderDrawColor(renderer, 64, 16, 16, 255)) luaL_error(L, "SDL_SetRenderDrawColor() failed: %s", SDL_GetError());
    if (SDL_RenderClear(renderer)) luaL_error(L, "SDL_RenderClear() failed: %s", SDL_GetError());
    return;
  }

  // update texture
  if (SDL_LockTexture(texture, NULL, (void**)&pixels, &pitch)) luaL_error(L, "SDL_LockTexture() failed: %s", SDL_GetError());
  for (y = 0; y < screen_height; ++y) {
    p = pixels + pitch * y;
    for (x = 0; x < screen_width; ++x) {
      color = &colors[screen[x][y] & 15];
      *p++ = 255; *p++ = color->b; *p++ = color->g; *p++ = color->r;
    }
  }
  SDL_UnlockTexture(texture);

  // render everything
  if (SDL_SetRenderDrawColor(renderer, 16, 16, 16, 255)) luaL_error(L, "SDL_SetRenderDrawColor() failed: %s", SDL_GetError());
  if (SDL_RenderClear(renderer)) luaL_error(L, "SDL_RenderClear() failed: %s", SDL_GetError());
  if (SDL_RenderCopy(renderer, texture, NULL, NULL)) luaL_error(L, "SDL_RenderCopy() failed: %s", SDL_GetError());
  SDL_RenderPresent(renderer);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
cmpq $0x0, 0x1147c(%rip)     # 0x644f0
jne 0x530f3
movq 0x1146b(%rip), %rdi     # 0x644e8
movl $0x40, %esi
movl $0x10, %ecx
movl $0xff, %r8d
movl %ecx, %edx
callq 0x6690
cmpl $0x0, %eax
je 0x530bb
movq -0x8(%rbp), %rax
movq %rax, -0x38(%rbp)
callq 0x6390
movq -0x38(%rbp), %rdi
movq %rax, %rdx
leaq 0x51ff(%rip), %rsi      # 0x582b3
movb $0x0, %al
callq 0xe880
movq 0x11426(%rip), %rdi     # 0x644e8
callq 0x64a0
cmpl $0x0, %eax
je 0x530ee
movq -0x8(%rbp), %rax
movq %rax, -0x40(%rbp)
callq 0x6390
movq -0x40(%rbp), %rdi
movq %rax, %rdx
leaq 0x51f0(%rip), %rsi      # 0x582d7
movb $0x0, %al
callq 0xe880
jmp 0x532ea
movq 0x113f6(%rip), %rdi     # 0x644f0
xorl %eax, %eax
movl %eax, %esi
leaq -0x18(%rbp), %rdx
leaq -0x2c(%rbp), %rcx
callq 0x65d0
cmpl $0x0, %eax
je 0x53132
movq -0x8(%rbp), %rax
movq %rax, -0x48(%rbp)
callq 0x6390
movq -0x48(%rbp), %rdi
movq %rax, %rdx
leaq 0x51c9(%rip), %rsi      # 0x582f4
movb $0x0, %al
callq 0xe880
movl $0x0, -0x28(%rbp)
movl -0x28(%rbp), %eax
cmpl 0x1113da(%rip), %eax    # 0x16451c
jge 0x5321c
movq -0x18(%rbp), %rax
movl -0x2c(%rbp), %ecx
imull -0x28(%rbp), %ecx
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x20(%rbp)
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl 0x1113ab(%rip), %eax    # 0x164518
jge 0x5320c
movslq -0x24(%rbp), %rcx
leaq 0x11392(%rip), %rax     # 0x64510
shlq $0xa, %rcx
addq %rcx, %rax
movslq -0x28(%rbp), %rcx
movzbl (%rax,%rcx), %eax
andl $0xf, %eax
movslq %eax, %rcx
leaq 0x4d36(%rip), %rax      # 0x57ed0
shlq $0x2, %rcx
addq %rcx, %rax
movq %rax, -0x10(%rbp)
movq -0x20(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x20(%rbp)
movb $-0x1, (%rax)
movq -0x10(%rbp), %rax
movb 0x2(%rax), %cl
movq -0x20(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x20(%rbp)
movb %cl, (%rax)
movq -0x10(%rbp), %rax
movb 0x1(%rax), %cl
movq -0x20(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x20(%rbp)
movb %cl, (%rax)
movq -0x10(%rbp), %rax
movb (%rax), %cl
movq -0x20(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x20(%rbp)
movb %cl, (%rax)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x53164
jmp 0x5320e
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x53139
movq 0x112cd(%rip), %rdi     # 0x644f0
callq 0x6660
movq 0x112b9(%rip), %rdi     # 0x644e8
movl $0x10, %ecx
movl $0xff, %r8d
movl %ecx, %esi
movl %ecx, %edx
callq 0x6690
cmpl $0x0, %eax
je 0x5326a
movq -0x8(%rbp), %rax
movq %rax, -0x50(%rbp)
callq 0x6390
movq -0x50(%rbp), %rdi
movq %rax, %rdx
leaq 0x5050(%rip), %rsi      # 0x582b3
movb $0x0, %al
callq 0xe880
movq 0x11277(%rip), %rdi     # 0x644e8
callq 0x64a0
cmpl $0x0, %eax
je 0x5329d
movq -0x8(%rbp), %rax
movq %rax, -0x58(%rbp)
callq 0x6390
movq -0x58(%rbp), %rdi
movq %rax, %rdx
leaq 0x5041(%rip), %rsi      # 0x582d7
movb $0x0, %al
callq 0xe880
movq 0x11244(%rip), %rdi     # 0x644e8
movq 0x11245(%rip), %rsi     # 0x644f0
xorl %eax, %eax
movl %eax, %ecx
movq %rcx, %rdx
callq 0x6530
cmpl $0x0, %eax
je 0x532de
movq -0x8(%rbp), %rax
movq %rax, -0x60(%rbp)
callq 0x6390
movq -0x60(%rbp), %rdi
movq %rax, %rdx
leaq 0x503a(%rip), %rsi      # 0x58311
movb $0x0, %al
callq 0xe880
movq 0x11203(%rip), %rdi     # 0x644e8
callq 0x60e0
addq $0x60, %rsp
popq %rbp
retq