// File: /workspace/github_c_makefile_star2_O2/jonof[P]jftekwar/jfbuild/src/glbuild.c
// Function: glbuild_update_window_size
void glbuild_update_window_size(glbuild8bit *state, int winx, int winy)
{
	if (winx == state->winx && winy == state->winy) {
		return;
	}

	float winaspect = (float)winx / (float)winy;
	float frameaspect = (float)state->resx / (float)state->resy;
	float aspectx, aspecty;

	state->winx = winx;
	state->winy = winy;

	// Correct for aspect ratio difference between the window size
	// and the logical 8-bit surface by skewing the quad we draw.
	if (fabs(winaspect - frameaspect) < 0.01) {
		aspectx = aspecty = 1.0;
	} else if (winaspect > frameaspect) {
		// Window is wider than the frame.
		aspectx = frameaspect / winaspect;
		aspecty = 1.0;
	} else {
		// Window is narrower than the frame.
		aspectx = 1.0;
		aspecty = winaspect / frameaspect;
	}

	// Texcoord/vertex elements.
	GLfloat elements[4][4] = {
		// tx, ty,  vx, vy
		{ 0.0,        state->ty,  -aspectx, -aspecty },
		{ state->tx,  state->ty,   aspectx, -aspecty },
		{ state->tx,  0.0,         aspectx,  aspecty },
		{ 0.0,        0.0,        -aspectx,  aspecty },
	};

	glfunc.glViewport(0, 0, winx, winy);

	glfunc.glBindBuffer(GL_ARRAY_BUFFER, state->buffer_elements);
	glfunc.glBufferData(GL_ARRAY_BUFFER, sizeof(elements), elements, GL_STATIC_DRAW);
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x48, %rsp
movl %edx, %ecx
movl %esi, %edx
movq %rdi, %rbx
cmpl %esi, 0x2c(%rdi)
jne 0x46303
cmpl %ecx, 0x30(%rbx)
je 0x46412
movd 0x24(%rbx), %xmm0
movd %edx, %xmm1
punpckldq %xmm0, %xmm1    # xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1]
cvtdq2ps %xmm1, %xmm2
movd 0x28(%rbx), %xmm0
movd %ecx, %xmm1
punpckldq %xmm0, %xmm1    # xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1]
cvtdq2ps %xmm1, %xmm0
divps %xmm0, %xmm2
movl %edx, 0x2c(%rbx)
movl %ecx, 0x30(%rbx)
movaps %xmm2, %xmm0
shufps $0x55, %xmm2, %xmm0     # xmm0 = xmm0[1,1],xmm2[1,1]
movaps %xmm2, %xmm1
subss %xmm0, %xmm1
andps 0x2817f(%rip), %xmm1    # 0x6e4c0
cvtss2sd %xmm1, %xmm3
movss 0x25c87(%rip), %xmm1    # 0x6bfd4
movsd 0x2818b(%rip), %xmm4    # 0x6e4e0
ucomisd %xmm3, %xmm4
jbe 0x46360
movaps %xmm1, %xmm0
jmp 0x46375
ucomiss %xmm0, %xmm2
jbe 0x4636b
divss %xmm2, %xmm0
jmp 0x46375
divss %xmm0, %xmm2
movaps %xmm1, %xmm0
movaps %xmm2, %xmm1
movq %rsp, %r14
andl $0x0, (%r14)
movaps 0x2814d(%rip), %xmm2    # 0x6e4d0
movaps %xmm0, %xmm3
xorps %xmm2, %xmm3
movss %xmm3, 0x8(%r14)
xorps %xmm1, %xmm2
movss %xmm2, 0xc(%r14)
movsd 0x34(%rbx), %xmm4
movaps %xmm4, %xmm5
shufps $0x55, %xmm4, %xmm5     # xmm5 = xmm5[1,1],xmm4[1,1]
movss %xmm5, 0x4(%r14)
movsd %xmm4, 0x10(%r14)
movss %xmm0, 0x18(%r14)
movss %xmm2, 0x1c(%r14)
movss %xmm4, 0x20(%r14)
andl $0x0, 0x24(%r14)
movss %xmm0, 0x28(%r14)
movss %xmm1, 0x2c(%r14)
andq $0x0, 0x30(%r14)
movss %xmm3, 0x38(%r14)
movss %xmm1, 0x3c(%r14)
xorl %edi, %edi
xorl %esi, %esi
callq *0x5ad3d2(%rip)         # 0x5f37c0
movl 0x1c(%rbx), %esi
movl $0x8892, %edi           # imm = 0x8892
callq *0x5ad43c(%rip)         # 0x5f3838
pushq $0x40
popq %rsi
movl $0x8892, %edi           # imm = 0x8892
movq %r14, %rdx
movl $0x88e4, %ecx           # imm = 0x88E4
callq *0x5ad42e(%rip)         # 0x5f3840
addq $0x48, %rsp
popq %rbx
popq %r14
retq