// File: /workspace/github_c_makefile_star2_O2/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 %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rsi, %r14
movl %edi, %ebx
leaq 0x5ac4b1(%rip), %r12    # 0x5f3740
movl 0x5ac74b(%rip), %edi    # 0x5f39e0
callq *0x1f0(%r12)
movl 0x5ac745(%rip), %edi    # 0x5f39e8
callq *0x128(%r12)
movl 0x5ac73b(%rip), %edi    # 0x5f39ec
callq *0x128(%r12)
movl 0x48(%r14), %esi
movq 0xf8(%r12), %rax
testl %esi, %esi
je 0x472d2
movl $0x8892, %edi           # imm = 0x8892
callq *%rax
jmp 0x472fd
movl 0x5ac70c(%rip), %esi    # 0x5f39e4
movl $0x8892, %edi           # imm = 0x8892
callq *%rax
movl 0x4c(%r14), %eax
imulq $0x14, %rax, %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 0x47319
movl $0x8893, %edi           # imm = 0x8893
callq *%rax
jmp 0x4732f
movl 0x5ac6b5(%rip), %esi    # 0x5f39d4
movl $0x8893, %edi           # imm = 0x8893
callq *%rax
movl 0x44(%r14), %edi
callq 0x474b1
movl 0x5ac6b3(%rip), %edi    # 0x5f39e8
pushq $0x3
popq %rsi
pushq $0x14
popq %rbp
movl $0x1406, %edx           # imm = 0x1406
xorl %ecx, %ecx
movl %ebp, %r8d
xorl %r9d, %r9d
callq *0x138(%r15)
movl 0x5ac697(%rip), %edi    # 0x5f39ec
pushq $0x2
popq %rsi
pushq $0xc
popq %r9
movl $0x1406, %edx           # imm = 0x1406
xorl %ecx, %ecx
movl %ebp, %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 0x473a2
movl 0x5ac6a6(%rip), %esi    # 0x5f3a48
movl $0xde1, %edi            # imm = 0xDE1
callq *0xc8(%r15)
movl 0x5ac64c(%rip), %edi    # 0x5f3a00
movss 0x8(%r14), %xmm0
callq *0x1c8(%r15)
movl 0x5ac63d(%rip), %edi    # 0x5f3a04
movss 0xc(%r14), %xmm0
movss 0x10(%r14), %xmm1
movss 0x14(%r14), %xmm2
movss 0x18(%r14), %xmm3
callq *0x1e0(%r15)
movl 0x5ac61c(%rip), %edi    # 0x5f3a08
movss 0x1c(%r14), %xmm0
movss 0x20(%r14), %xmm1
movss 0x24(%r14), %xmm2
movss 0x28(%r14), %xmm3
callq *0x1e0(%r15)
movl 0x5ac5fb(%rip), %edi    # 0x5f3a0c
movss 0x2c(%r14), %xmm0
callq *0x1c8(%r15)
movl 0x5ac5cc(%rip), %edi    # 0x5f39f0
movq 0x30(%r14), %rcx
pushq $0x1
popq %rbp
movl %ebp, %esi
xorl %edx, %edx
callq *0x1e8(%r15)
movl 0x5ac5b8(%rip), %edi    # 0x5f39f4
movq 0x38(%r14), %rcx
movl %ebp, %esi
xorl %edx, %edx
callq *0x1e8(%r15)
movl 0x5ac5bf(%rip), %edi    # 0x5f3a10
leaq 0x56334(%rip), %rax     # 0x9d78c
cmpl $0x1, (%rax)
je 0x47467
movss 0x24b6f(%rip), %xmm0    # 0x6bfd4
jmp 0x47472
leaq 0x56326(%rip), %rax     # 0x9d794
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 0x5ac555(%rip), %edi    # 0x5f39e8
callq *0x130(%r15)
movl 0x5ac54c(%rip), %edi    # 0x5f39ec
movq %r15, %rax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmpq *0x130(%rax)