// File: /workspace/github_c_makefile_star2_O1/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 0x5ab142(%rip), %r12    # 0x5f9740
movl 0x5ab3dc(%rip), %edi    # 0x5f99e0
callq *0x1f0(%r12)
movl 0x5ab3d6(%rip), %edi    # 0x5f99e8
callq *0x128(%r12)
movl 0x5ab3cc(%rip), %edi    # 0x5f99ec
callq *0x128(%r12)
movl 0x48(%r14), %esi
movq 0xf8(%r12), %rax
testl %esi, %esi
je 0x4e641
movl $0x8892, %edi           # imm = 0x8892
callq *%rax
jmp 0x4e670
movl 0x5ab39d(%rip), %esi    # 0x5f99e4
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 0x4e68c
movl $0x8893, %edi           # imm = 0x8893
callq *%rax
jmp 0x4e6a2
movl 0x5ab342(%rip), %esi    # 0x5f99d4
movl $0x8893, %edi           # imm = 0x8893
callq *%rax
movl 0x44(%r14), %edi
callq 0x4e833
movl 0x5ab340(%rip), %edi    # 0x5f99e8
movl $0x3, %esi
movl $0x1406, %edx           # imm = 0x1406
xorl %ecx, %ecx
movl $0x14, %r8d
xorl %r9d, %r9d
callq *0x138(%r15)
movl 0x5ab322(%rip), %edi    # 0x5f99ec
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 0x4e71e
movl 0x5ab32a(%rip), %esi    # 0x5f9a48
movl $0xde1, %edi            # imm = 0xDE1
callq *0xc8(%r15)
movl 0x5ab2d0(%rip), %edi    # 0x5f9a00
movss 0x8(%r14), %xmm0
callq *0x1c8(%r15)
movl 0x5ab2c1(%rip), %edi    # 0x5f9a04
movss 0xc(%r14), %xmm0
movss 0x10(%r14), %xmm1
movss 0x14(%r14), %xmm2
movss 0x18(%r14), %xmm3
callq *0x1e0(%r15)
movl 0x5ab2a0(%rip), %edi    # 0x5f9a08
movss 0x1c(%r14), %xmm0
movss 0x20(%r14), %xmm1
movss 0x24(%r14), %xmm2
movss 0x28(%r14), %xmm3
callq *0x1e0(%r15)
movl 0x5ab27f(%rip), %edi    # 0x5f9a0c
movss 0x2c(%r14), %xmm0
callq *0x1c8(%r15)
movl 0x5ab250(%rip), %edi    # 0x5f99f0
movq 0x30(%r14), %rcx
movl $0x1, %esi
xorl %edx, %edx
callq *0x1e8(%r15)
movl 0x5ab23c(%rip), %edi    # 0x5f99f4
movq 0x38(%r14), %rcx
movl $0x1, %esi
xorl %edx, %edx
callq *0x1e8(%r15)
movl 0x5ab240(%rip), %edi    # 0x5f9a10
leaq 0x54fb5(%rip), %rax     # 0xa378c
cmpl $0x1, (%rax)
je 0x4e7e6
movss 0x277b0(%rip), %xmm0    # 0x75f94
jmp 0x4e7f1
leaq 0x54fa7(%rip), %rax     # 0xa3794
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 0x5ab1d6(%rip), %edi    # 0x5f99e8
callq *0x130(%r15)
movl 0x5ab1cd(%rip), %edi    # 0x5f99ec
movq %r15, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmpq *0x130(%rax)