// File: /workspace/github_c_makefile_star2_O1/jonof[P]jftekwar/jfbuild/src/polymost.c
// Function: polymost_drawaux_glcall
static void polymost_drawaux_glcall(GLenum mode, struct polymostdrawauxcall *draw)
{
#ifdef DEBUGGINGAIDS
	polymostcallcounts.drawaux_glcall++;
#endif

	glfunc.glUseProgram(polymostauxglsl.program);

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

	glfunc.glBindBuffer(GL_ARRAY_BUFFER, polymostauxglsl.elementbuffer);
	glfunc.glBufferData(GL_ARRAY_BUFFER, draw->elementcount * sizeof(struct polymostvboitem), draw->elementvbo, GL_STREAM_DRAW);

	if (draw->indexes) {
		glfunc.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, polymostauxglsl.indexbuffer);
		glfunc.glBufferData(GL_ELEMENT_ARRAY_BUFFER, draw->indexcount * sizeof(GLushort), draw->indexes, GL_STREAM_DRAW);
	} else {
		glfunc.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, elementindexbuffer);
		checkindexbuffer(draw->indexcount);
	}

	glfunc.glVertexAttribPointer(polymostauxglsl.attrib_vertex, 3, GL_FLOAT, GL_FALSE,
		sizeof(struct polymostvboitem), (const GLvoid *)offsetof(struct polymostvboitem, v));
	glfunc.glVertexAttribPointer(polymostauxglsl.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.glUniform4f(
		polymostauxglsl.uniform_colour,
		draw->colour.r, draw->colour.g, draw->colour.b, draw->colour.a
	);
	glfunc.glUniform4f(
		polymostauxglsl.uniform_bgcolour,
		draw->bgcolour.r, draw->bgcolour.g, draw->bgcolour.b, draw->bgcolour.a
	);
	glfunc.glUniform1i(polymostauxglsl.uniform_mode, draw->mode);

	glfunc.glUniformMatrix4fv(polymostauxglsl.uniform_projection, 1, GL_FALSE, &gorthoprojmat[0][0]);

	glfunc.glUniform1f(polymostauxglsl.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(polymostauxglsl.attrib_vertex);
	glfunc.glDisableVertexAttribArray(polymostauxglsl.attrib_texcoord);
#endif
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r14
movl %edi, %ebx
leaq 0x59dff7(%rip), %r15    # 0x5f9740
movl 0x59e2c9(%rip), %edi    # 0x5f9a18
callq *0x1f0(%r15)
movl 0x59e2c8(%rip), %edi    # 0x5f9a24
callq *0x128(%r15)
movl 0x59e2bf(%rip), %edi    # 0x5f9a28
callq *0x128(%r15)
movl 0x59e2a6(%rip), %esi    # 0x5f9a1c
movl $0x8892, %edi           # imm = 0x8892
callq *0xf8(%r15)
movslq 0x38(%r14), %rax
shlq $0x2, %rax
leaq (%rax,%rax,4), %rsi
movq 0x40(%r14), %rdx
movl $0x8892, %edi           # imm = 0x8892
movl $0x88e0, %ecx           # imm = 0x88E0
callq *0x100(%r15)
cmpq $0x0, 0x30(%r14)
movq 0xf8(%r15), %rax
je 0x5b7dc
movl 0x59e269(%rip), %esi    # 0x5f9a20
movl $0x8893, %edi           # imm = 0x8893
callq *%rax
movl 0x28(%r14), %esi
addq %rsi, %rsi
movq 0x30(%r14), %rdx
movl $0x8893, %edi           # imm = 0x8893
movl $0x88e0, %ecx           # imm = 0x88E0
callq *0x100(%r15)
jmp 0x5b7f2
movl 0x59e1f2(%rip), %esi    # 0x5f99d4
movl $0x8893, %edi           # imm = 0x8893
callq *%rax
movl 0x28(%r14), %edi
callq 0x4e833
movl 0x59e22c(%rip), %edi    # 0x5f9a24
movl $0x3, %esi
movl $0x1406, %edx           # imm = 0x1406
xorl %ecx, %ecx
movl $0x14, %r8d
xorl %r9d, %r9d
callq *0x138(%r15)
movl 0x59e20e(%rip), %edi    # 0x5f9a28
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 0x59e1da(%rip), %edi    # 0x5f9a34
movss 0x4(%r14), %xmm0
movss 0x8(%r14), %xmm1
movss 0xc(%r14), %xmm2
movss 0x10(%r14), %xmm3
callq *0x1e0(%r15)
movl 0x59e1b9(%rip), %edi    # 0x5f9a38
movss 0x14(%r14), %xmm0
movss 0x18(%r14), %xmm1
movss 0x1c(%r14), %xmm2
movss 0x20(%r14), %xmm3
callq *0x1e0(%r15)
movl 0x59e198(%rip), %edi    # 0x5f9a3c
movl 0x24(%r14), %esi
callq *0x1c0(%r15)
movl 0x59e177(%rip), %edi    # 0x5f9a2c
leaq 0x59e224(%rip), %rcx    # 0x5f9ae0
movl $0x1, %esi
xorl %edx, %edx
movq %r15, %r12
callq *0x1e8(%r15)
movl 0x59e16d(%rip), %edi    # 0x5f9a40
leaq 0x47eb2(%rip), %rax     # 0xa378c
cmpl $0x1, (%rax)
je 0x5b8e9
movss 0x1a6ad(%rip), %xmm0    # 0x75f94
jmp 0x5b8f4
leaq 0x47ea4(%rip), %rax     # 0xa3794
movss (%rax), %xmm0
callq *0x1c8(%r12)
movl 0x28(%r14), %esi
movl %ebx, %edi
movl $0x1403, %edx           # imm = 0x1403
xorl %ecx, %ecx
callq *0x120(%r12)
movl 0x59e10d(%rip), %edi    # 0x5f9a24
callq *0x130(%r12)
movl 0x59e103(%rip), %edi    # 0x5f9a28
movq %r12, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmpq *0x130(%rax)