// File: /workspace/github_c_makefile_star2_O3/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 0x4faf6
cmpl %ecx, 0x30(%rbx)
je 0x4fc0a
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 0x29c1c(%rip), %xmm1    # 0x79750
cvtss2sd %xmm1, %xmm3
movss 0x275d4(%rip), %xmm1    # 0x77114
movsd 0x29c18(%rip), %xmm4    # 0x79760
ucomisd %xmm3, %xmm4
jbe 0x4fb53
movaps %xmm1, %xmm0
jmp 0x4fb68
ucomiss %xmm0, %xmm2
jbe 0x4fb5e
divss %xmm2, %xmm0
jmp 0x4fb68
divss %xmm0, %xmm2
movaps %xmm1, %xmm0
movaps %xmm2, %xmm1
xorl %eax, %eax
movq %rsp, %r14
movl %eax, (%r14)
movaps 0x24579(%rip), %xmm2    # 0x740f0
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)
movl %eax, 0x24(%r14)
movss %xmm0, 0x28(%r14)
movss %xmm1, 0x2c(%r14)
movq $0x0, 0x30(%r14)
movss %xmm3, 0x38(%r14)
movss %xmm1, 0x3c(%r14)
xorl %edi, %edi
xorl %esi, %esi
callq *0x5aabdc(%rip)         # 0x5fa7c0
movl 0x1c(%rbx), %esi
movl $0x8892, %edi           # imm = 0x8892
callq *0x5aac46(%rip)         # 0x5fa838
movl $0x40, %esi
movl $0x8892, %edi           # imm = 0x8892
movq %r14, %rdx
movl $0x88e4, %ecx           # imm = 0x88E4
callq *0x5aac36(%rip)         # 0x5fa840
addq $0x48, %rsp
popq %rbx
popq %r14
retq