// File: /workspace/github_c_makefile_star2_O3/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 0x59ce9b(%rip), %r15    # 0x5fa740
movl 0x59d16d(%rip), %edi    # 0x5faa18
callq *0x1f0(%r15)
movl 0x59d16c(%rip), %edi    # 0x5faa24
callq *0x128(%r15)
movl 0x59d163(%rip), %edi    # 0x5faa28
callq *0x128(%r15)
movl 0x59d14a(%rip), %esi    # 0x5faa1c
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 0x5d938
movl 0x59d10d(%rip), %esi    # 0x5faa20
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 0x5d94e
movl 0x59d096(%rip), %esi    # 0x5fa9d4
movl $0x8893, %edi           # imm = 0x8893
callq *%rax
movl 0x28(%r14), %edi
callq 0x50f94
movl 0x59d0d0(%rip), %edi    # 0x5faa24
movl $0x3, %esi
movl $0x1406, %edx           # imm = 0x1406
xorl %ecx, %ecx
movl $0x14, %r8d
xorl %r9d, %r9d
callq *0x138(%r15)
movl 0x59d0b2(%rip), %edi    # 0x5faa28
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 0x59d07e(%rip), %edi    # 0x5faa34
movss 0x4(%r14), %xmm0
movss 0x8(%r14), %xmm1
movss 0xc(%r14), %xmm2
movss 0x10(%r14), %xmm3
callq *0x1e0(%r15)
movl 0x59d05d(%rip), %edi    # 0x5faa38
movss 0x14(%r14), %xmm0
movss 0x18(%r14), %xmm1
movss 0x1c(%r14), %xmm2
movss 0x20(%r14), %xmm3
callq *0x1e0(%r15)
movl 0x59d03c(%rip), %edi    # 0x5faa3c
movl 0x24(%r14), %esi
callq *0x1c0(%r15)
movl 0x59d01b(%rip), %edi    # 0x5faa2c
leaq 0x59d0c8(%rip), %rcx    # 0x5faae0
movl $0x1, %esi
xorl %edx, %edx
movq %r15, %r12
callq *0x1e8(%r15)
movl 0x59d011(%rip), %edi    # 0x5faa40
leaq 0x46d56(%rip), %rax     # 0xa478c
cmpl $0x1, (%rax)
je 0x5da45
movss 0x196d1(%rip), %xmm0    # 0x77114
jmp 0x5da50
leaq 0x46d48(%rip), %rax     # 0xa4794
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 0x59cfb1(%rip), %edi    # 0x5faa24
callq *0x130(%r12)
movl 0x59cfa7(%rip), %edi    # 0x5faa28
movq %r12, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmpq *0x130(%rax)