// File: /workspace/github_c_makefile_star2_O3/jonof[P]jftekwar/jfbuild/src/polymost.c
// Function: polymost_drawpoly_glcall
void polymost_drawpoly_glcall(GLenum mode, struct polymostdrawpolycall *draw)
{
#ifdef DEBUGGINGAIDS
	polymostcallcounts.drawpoly_glcall++;
#endif

	glfunc.glUseProgram(polymostglsl.program);

#if (USE_OPENGL == USE_GL3)
    glfunc.glBindVertexArray(polymostglsl.vao);
#else
    glfunc.glEnableVertexAttribArray(polymostglsl.attrib_vertex);
    glfunc.glEnableVertexAttribArray(polymostglsl.attrib_texcoord);
#endif

	if (draw->elementbuffer > 0) {
		glfunc.glBindBuffer(GL_ARRAY_BUFFER, draw->elementbuffer);
	} else {
		// Drawing from the passed elementvbo items.
		glfunc.glBindBuffer(GL_ARRAY_BUFFER, polymostglsl.elementbuffer);
		glfunc.glBufferData(GL_ARRAY_BUFFER, draw->elementcount * sizeof(struct polymostvboitem), draw->elementvbo, GL_STREAM_DRAW);
	}

	if (draw->indexbuffer > 0) {
		glfunc.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, draw->indexbuffer);
	} else {
		glfunc.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, elementindexbuffer);
		checkindexbuffer(draw->indexcount);
	}

	glfunc.glVertexAttribPointer(polymostglsl.attrib_vertex, 3, GL_FLOAT, GL_FALSE,
		sizeof(struct polymostvboitem), (const GLvoid *)offsetof(struct polymostvboitem, v));
	glfunc.glVertexAttribPointer(polymostglsl.attrib_texcoord, 2, GL_FLOAT, GL_FALSE,
		sizeof(struct polymostvboitem), (const GLvoid *)offsetof(struct polymostvboitem, t));

	glfunc.glActiveTexture(GL_TEXTURE0);
	glfunc.glBindTexture(GL_TEXTURE_2D, draw->texture0);

	glfunc.glActiveTexture(GL_TEXTURE1);
	glfunc.glBindTexture(GL_TEXTURE_2D, draw->texture1 ? draw->texture1 : nulltexture);

	glfunc.glUniform1f(polymostglsl.uniform_alphacut, draw->alphacut);

	glfunc.glUniform4f(
		polymostglsl.uniform_colour,
		draw->colour.r, draw->colour.g, draw->colour.b, draw->colour.a
	);
	glfunc.glUniform4f(
		polymostglsl.uniform_fogcolour,
		draw->fogcolour.r, draw->fogcolour.g, draw->fogcolour.b, draw->fogcolour.a
	);
	glfunc.glUniform1f(
		polymostglsl.uniform_fogdensity,
		draw->fogdensity
	);

	glfunc.glUniformMatrix4fv(polymostglsl.uniform_modelview, 1, GL_FALSE, draw->modelview);
	glfunc.glUniformMatrix4fv(polymostglsl.uniform_projection, 1, GL_FALSE, draw->projection);

	glfunc.glUniform1f(polymostglsl.uniform_gamma, usegammabrightness == 1 ? curgamma : 1.0);

	glfunc.glDrawElements(mode, draw->indexcount, GL_UNSIGNED_SHORT, 0);

#if (USE_OPENGL == USE_GL3)
    glfunc.glBindVertexArray(0);
#else
	glfunc.glDisableVertexAttribArray(polymostglsl.attrib_vertex);
	glfunc.glDisableVertexAttribArray(polymostglsl.attrib_texcoord);
#endif
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r14
movl %edi, %ebx
leaq 0x5a99e1(%rip), %r12    # 0x5fa740
movl 0x5a9c7b(%rip), %edi    # 0x5fa9e0
callq *0x1f0(%r12)
movl 0x5a9c75(%rip), %edi    # 0x5fa9e8
callq *0x128(%r12)
movl 0x5a9c6b(%rip), %edi    # 0x5fa9ec
callq *0x128(%r12)
movl 0x48(%r14), %esi
movq 0xf8(%r12), %rax
testl %esi, %esi
je 0x50da2
movl $0x8892, %edi           # imm = 0x8892
callq *%rax
jmp 0x50dd1
movl 0x5a9c3c(%rip), %esi    # 0x5fa9e4
movl $0x8892, %edi           # imm = 0x8892
callq *%rax
movl 0x4c(%r14), %eax
shlq $0x2, %rax
leaq (%rax,%rax,4), %rsi
movq 0x50(%r14), %rdx
movl $0x8892, %edi           # imm = 0x8892
movl $0x88e0, %ecx           # imm = 0x88E0
callq *0x100(%r12)
movl 0x40(%r14), %esi
movq %r12, %r15
movq 0xf8(%r12), %rax
testl %esi, %esi
je 0x50ded
movl $0x8893, %edi           # imm = 0x8893
callq *%rax
jmp 0x50e03
movl 0x5a9be1(%rip), %esi    # 0x5fa9d4
movl $0x8893, %edi           # imm = 0x8893
callq *%rax
movl 0x44(%r14), %edi
callq 0x50f94
movl 0x5a9bdf(%rip), %edi    # 0x5fa9e8
movl $0x3, %esi
movl $0x1406, %edx           # imm = 0x1406
xorl %ecx, %ecx
movl $0x14, %r8d
xorl %r9d, %r9d
callq *0x138(%r15)
movl 0x5a9bc1(%rip), %edi    # 0x5fa9ec
movl $0xc, %r9d
movl $0x2, %esi
movl $0x1406, %edx           # imm = 0x1406
xorl %ecx, %ecx
movl $0x14, %r8d
callq *0x138(%r15)
movl $0x84c0, %edi           # imm = 0x84C0
callq *0x140(%r15)
movl (%r14), %esi
movl $0xde1, %edi            # imm = 0xDE1
callq *0xc8(%r15)
movl $0x84c1, %edi           # imm = 0x84C1
callq *0x140(%r15)
movl 0x4(%r14), %esi
testl %esi, %esi
jne 0x50e7f
movl 0x5a9bc9(%rip), %esi    # 0x5faa48
movl $0xde1, %edi            # imm = 0xDE1
callq *0xc8(%r15)
movl 0x5a9b6f(%rip), %edi    # 0x5faa00
movss 0x8(%r14), %xmm0
callq *0x1c8(%r15)
movl 0x5a9b60(%rip), %edi    # 0x5faa04
movss 0xc(%r14), %xmm0
movss 0x10(%r14), %xmm1
movss 0x14(%r14), %xmm2
movss 0x18(%r14), %xmm3
callq *0x1e0(%r15)
movl 0x5a9b3f(%rip), %edi    # 0x5faa08
movss 0x1c(%r14), %xmm0
movss 0x20(%r14), %xmm1
movss 0x24(%r14), %xmm2
movss 0x28(%r14), %xmm3
callq *0x1e0(%r15)
movl 0x5a9b1e(%rip), %edi    # 0x5faa0c
movss 0x2c(%r14), %xmm0
callq *0x1c8(%r15)
movl 0x5a9aef(%rip), %edi    # 0x5fa9f0
movq 0x30(%r14), %rcx
movl $0x1, %esi
xorl %edx, %edx
callq *0x1e8(%r15)
movl 0x5a9adb(%rip), %edi    # 0x5fa9f4
movq 0x38(%r14), %rcx
movl $0x1, %esi
xorl %edx, %edx
callq *0x1e8(%r15)
movl 0x5a9adf(%rip), %edi    # 0x5faa10
leaq 0x53854(%rip), %rax     # 0xa478c
cmpl $0x1, (%rax)
je 0x50f47
movss 0x261cf(%rip), %xmm0    # 0x77114
jmp 0x50f52
leaq 0x53846(%rip), %rax     # 0xa4794
movss (%rax), %xmm0
callq *0x1c8(%r15)
movl 0x44(%r14), %esi
movl %ebx, %edi
movl $0x1403, %edx           # imm = 0x1403
xorl %ecx, %ecx
callq *0x120(%r15)
movl 0x5a9a75(%rip), %edi    # 0x5fa9e8
callq *0x130(%r15)
movl 0x5a9a6c(%rip), %edi    # 0x5fa9ec
movq %r15, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmpq *0x130(%rax)