// File: /workspace/github_c_makefile_star2_O0/jonof[P]jftekwar/jfbuild/src/sdlayer2.c
// Function: showframe
void showframe(void)
{
#if USE_OPENGL
	if (!glunavailable) {
		if (bpp == 8) {
			glbuild_update_8bit_frame(&gl8bit, frame, xres, yres, bytesperline);
			glbuild_draw_8bit_frame(&gl8bit);
		}

		SDL_GL_SwapWindow(sdl_window);
		return;
	}
#endif

	unsigned char *pixels, *in;

#ifdef SDLAYER_USE_RENDERER
	int pitch, y, x;

	if (SDL_LockTexture(sdl_texture, NULL, (void**)&pixels, &pitch)) {
		debugprintf("Could not lock texture: %s\n", SDL_GetError());
		return;
	}

	in = frame;
	for (y = yres - 1; y >= 0; y--) {
		for (x = xres - 1; x >= 0; x--) {
#if B_LITTLE_ENDIAN
			// RGBA -> BGRA, ignoring A
			/*
			pixels[(x<<2)+0] = curpalettefaded[in[x]].b;
			pixels[(x<<2)+1] = curpalettefaded[in[x]].g;
			pixels[(x<<2)+2] = curpalettefaded[in[x]].r;
			pixels[(x<<2)+3] = 0;
			*/
			((unsigned int *)pixels)[x] = B_SWAP32(*(unsigned int *)&curpalettefaded[in[x]]) >> 8;
#else
			pixels[(x<<2)+0] = 0;
			pixels[(x<<2)+1] = curpalettefaded[in[x]].r;
			pixels[(x<<2)+2] = curpalettefaded[in[x]].g;
			pixels[(x<<2)+3] = curpalettefaded[in[x]].b;
#endif
		}
		pixels += pitch;
		in += bytesperline;
	}

	SDL_UnlockTexture(sdl_texture);
	if (SDL_RenderCopy(sdl_renderer, sdl_texture, NULL, NULL)) {
		debugprintf("Could not copy render texture: %s\n", SDL_GetError());
	}
	SDL_RenderPresent(sdl_renderer);

#else //SDLAYER_USE_RENDERER
	SDL_Surface *winsurface;
	int pitch, y;

	if (SDL_LockSurface(sdl_surface)) {
		debugprintf("Could not lock surface: %s\n", SDL_GetError());
		return;
	}
	pixels = (unsigned char *)sdl_surface->pixels;
	pitch = sdl_surface->pitch;

	in = frame;
	for (y = yres - 1; y >= 0; y--) {
		memcpy(pixels, in, xres);
		pixels += pitch;
		in += bytesperline;
	}

	SDL_UnlockSurface(sdl_surface);

	winsurface = SDL_GetWindowSurface(sdl_window);
	if (!winsurface) {
		debugprintf("Could not get window surface: %s\n", SDL_GetError());
		return;
	}
	SDL_BlitSurface(sdl_surface, NULL, winsurface, NULL);
	SDL_UpdateWindowSurface(sdl_window);
#endif //SDLAYER_USE_RENDERER
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
leaq 0x114479(%rip), %rax    # 0x1bac48
cmpl $0x0, (%rax)
jne 0xa682c
leaq 0x114429(%rip), %rax    # 0x1bac04
cmpl $0x8, (%rax)
jne 0xa681b
movq 0x61b829(%rip), %rsi    # 0x6c2010
leaq 0x39c06(%rip), %rax     # 0xe03f4
movl (%rax), %edx
leaq 0x39c01(%rip), %rax     # 0xe03f8
movl (%rax), %ecx
leaq 0x1145e4(%rip), %rax    # 0x1bade4
movl (%rax), %r8d
leaq 0x61b7de(%rip), %rdi    # 0x6c1fe8
callq 0x71ea0
leaq 0x61b7d2(%rip), %rdi    # 0x6c1fe8
callq 0x71f20
movq 0x619a7e(%rip), %rdi    # 0x6c02a0
callq 0x6310
jmp 0xa693c
movq 0x61b7a5(%rip), %rdi    # 0x6c1fd8
callq 0x6500
cmpl $0x0, %eax
je 0xa6858
callq 0x6a60
movq %rax, %rsi
leaq 0x140ef(%rip), %rdi     # 0xba93b
movb $0x0, %al
callq 0xa5110
jmp 0xa693c
movq 0x61b779(%rip), %rax    # 0x6c1fd8
movq 0x20(%rax), %rax
movq %rax, -0x8(%rbp)
movq 0x61b76a(%rip), %rax    # 0x6c1fd8
movl 0x18(%rax), %eax
movl %eax, -0x1c(%rbp)
movq 0x61b795(%rip), %rax    # 0x6c2010
movq %rax, -0x10(%rbp)
leaq 0x39b72(%rip), %rax     # 0xe03f8
movl (%rax), %eax
subl $0x1, %eax
movl %eax, -0x20(%rbp)
cmpl $0x0, -0x20(%rbp)
jl 0xa68de
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
leaq 0x39b51(%rip), %rax     # 0xe03f4
movslq (%rax), %rdx
callq 0x60c0
movl -0x1c(%rbp), %ecx
movq -0x8(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x8(%rbp)
leaq 0x114521(%rip), %rax    # 0x1bade4
movl (%rax), %ecx
movq -0x10(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x10(%rbp)
movl -0x20(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0xa688e
movq 0x61b6f3(%rip), %rdi    # 0x6c1fd8
callq 0x6950
movq 0x6199af(%rip), %rdi    # 0x6c02a0
callq 0x6480
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0xa6919
callq 0x6a60
movq %rax, %rsi
leaq 0x14047(%rip), %rdi     # 0xba957
movb $0x0, %al
callq 0xa5110
jmp 0xa693c
movq 0x61b6b8(%rip), %rdi    # 0x6c1fd8
movq -0x18(%rbp), %rdx
xorl %eax, %eax
movl %eax, %ecx
movq %rcx, %rsi
callq 0x67f0
movq 0x619969(%rip), %rdi    # 0x6c02a0
callq 0x6b30
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)