// File: /workspace/github_c_makefile_star2_O3/jonof[P]jftekwar/jfbuild/src/polymost.c
// Function: polymost_loadshaders
static void polymost_loadshaders(void)
{
	extern const char default_polymost_fs_glsl[];
	extern const char default_polymost_vs_glsl[];

	extern const char default_polymostaux_fs_glsl[];
	extern const char default_polymostaux_vs_glsl[];

	GLuint shader[2] = {0,0};

	// General texture rendering shader.
	if (polymostglsl.program) {
		glfunc.glDeleteProgram(polymostglsl.program);
		polymostglsl.program = 0;
	}

	shader[0] = polymost_load_shader(GL_VERTEX_SHADER, default_polymost_vs_glsl, "polymost_vs.glsl");
	shader[1] = polymost_load_shader(GL_FRAGMENT_SHADER, default_polymost_fs_glsl, "polymost_fs.glsl");
	if (shader[0] && shader[1]) {
		polymostglsl.program = glbuild_link_program(2, shader);
	}
	if (shader[0]) glfunc.glDeleteShader(shader[0]);
	if (shader[1]) glfunc.glDeleteShader(shader[1]);

	if (polymostglsl.program) {
		polymostglsl.attrib_vertex       = polymost_get_attrib(polymostglsl.program, "a_vertex");
		polymostglsl.attrib_texcoord     = polymost_get_attrib(polymostglsl.program, "a_texcoord");
		polymostglsl.uniform_modelview   = polymost_get_uniform(polymostglsl.program, "u_modelview");
		polymostglsl.uniform_projection  = polymost_get_uniform(polymostglsl.program, "u_projection");
		polymostglsl.uniform_texture     = polymost_get_uniform(polymostglsl.program, "u_texture");
		polymostglsl.uniform_glowtexture = polymost_get_uniform(polymostglsl.program, "u_glowtexture");
		polymostglsl.uniform_alphacut    = polymost_get_uniform(polymostglsl.program, "u_alphacut");
		polymostglsl.uniform_colour      = polymost_get_uniform(polymostglsl.program, "u_colour");
		polymostglsl.uniform_fogcolour   = polymost_get_uniform(polymostglsl.program, "u_fogcolour");
		polymostglsl.uniform_fogdensity  = polymost_get_uniform(polymostglsl.program, "u_fogdensity");
		polymostglsl.uniform_gamma       = polymost_get_uniform(polymostglsl.program, "u_gamma");

#if (USE_OPENGL == USE_GL3)
		glfunc.glGenVertexArrays(1, &polymostglsl.vao);
        glfunc.glBindVertexArray(polymostglsl.vao);
        glfunc.glEnableVertexAttribArray(polymostglsl.attrib_vertex);
        glfunc.glEnableVertexAttribArray(polymostglsl.attrib_texcoord);
#endif

		glfunc.glUseProgram(polymostglsl.program);
		glfunc.glUniform1i(polymostglsl.uniform_texture, 0);		//GL_TEXTURE0
		glfunc.glUniform1i(polymostglsl.uniform_glowtexture, 1);	//GL_TEXTURE1

		// Generate a buffer object for vertex/colour elements.
		glfunc.glGenBuffers(1, &polymostglsl.elementbuffer);
	}

	// A fully transparent texture for the case when a glow texture is not needed.
	if (!nulltexture) {
		const char pix[4] = {0,0,0,0};
		glfunc.glGenTextures(1, &nulltexture);
		glfunc.glBindTexture(GL_TEXTURE_2D, nulltexture);
		glfunc.glTexImage2D(GL_TEXTURE_2D,0,GL_RGBA,1,1,0,GL_RGBA,GL_UNSIGNED_BYTE,(GLvoid*)&pix);
		glfunc.glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST);
		glfunc.glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST);
	}

	// Engine auxiliary shader.
	if (polymostauxglsl.program) {
		glfunc.glDeleteProgram(polymostauxglsl.program);
		polymostauxglsl.program = 0;
	}

	shader[0] = polymost_load_shader(GL_VERTEX_SHADER, default_polymostaux_vs_glsl, "polymostaux_vs.glsl");
	shader[1] = polymost_load_shader(GL_FRAGMENT_SHADER, default_polymostaux_fs_glsl, "polymostaux_fs.glsl");
	if (shader[0] && shader[1]) {
		polymostauxglsl.program = glbuild_link_program(2, shader);
	}
	if (shader[0]) glfunc.glDeleteShader(shader[0]);
	if (shader[1]) glfunc.glDeleteShader(shader[1]);

	if (polymostauxglsl.program) {
		polymostauxglsl.attrib_vertex    = polymost_get_attrib(polymostauxglsl.program, "a_vertex");
		polymostauxglsl.attrib_texcoord  = polymost_get_attrib(polymostauxglsl.program, "a_texcoord");
		polymostauxglsl.uniform_projection = polymost_get_uniform(polymostauxglsl.program, "u_projection");
		polymostauxglsl.uniform_texture  = polymost_get_uniform(polymostauxglsl.program, "u_texture");
		polymostauxglsl.uniform_colour   = polymost_get_uniform(polymostauxglsl.program, "u_colour");
		polymostauxglsl.uniform_bgcolour = polymost_get_uniform(polymostauxglsl.program, "u_bgcolour");
		polymostauxglsl.uniform_mode     = polymost_get_uniform(polymostauxglsl.program, "u_mode");
		polymostauxglsl.uniform_gamma    = polymost_get_uniform(polymostauxglsl.program, "u_gamma");

#if (USE_OPENGL == USE_GL3)
		glfunc.glGenVertexArrays(1, &polymostauxglsl.vao);
        glfunc.glBindVertexArray(polymostauxglsl.vao);
        glfunc.glEnableVertexAttribArray(polymostauxglsl.attrib_vertex);
        glfunc.glEnableVertexAttribArray(polymostauxglsl.attrib_texcoord);
#endif

		glfunc.glUseProgram(polymostauxglsl.program);
		glfunc.glUniform1i(polymostauxglsl.uniform_texture, 0);	//GL_TEXTURE0

		// Generate a buffer object for vertex/colour elements and pre-allocate its memory.
		glfunc.glGenBuffers(1, &polymostauxglsl.elementbuffer);

		// Generate a buffer object for ad-hoc indexes.
		glfunc.glGenBuffers(1, &polymostauxglsl.indexbuffer);
	}

	// Generate a buffer object for element indexes and populate it with an
	// initial set of ascending indices, the way drawpoly() will generate points.
	glfunc.glGenBuffers(1, &elementindexbuffer);
	checkindexbuffer(MINVBOINDEXES);
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x18, %rsp
movl 0x5aa61b(%rip), %edi    # 0x5fa9e0
testl %edi, %edi
je 0x503e0
leaq 0x5aa370(%rip), %rax    # 0x5fa740
callq *0x168(%rax)
movl $0x0, 0x5aa600(%rip)    # 0x5fa9e0
leaq 0x2b679(%rip), %rsi     # 0x7ba60
leaq 0x2ac8f(%rip), %rdx     # 0x7b07d
movl $0x8b31, %edi           # imm = 0x8B31
callq 0x5ecd9
movl %eax, %ebx
movl %eax, 0xc(%rsp)
leaq 0x2b17b(%rip), %rsi     # 0x7b580
leaq 0x2ac82(%rip), %rdx     # 0x7b08e
movl $0x8b30, %edi           # imm = 0x8B30
callq 0x5ecd9
movl %eax, 0x10(%rsp)
testl %ebx, %ebx
setne %cl
testl %eax, %eax
setne %al
andb %cl, %al
cmpb $0x1, %al
jne 0x50444
leaq 0xc(%rsp), %rbx
movl $0x2, %edi
movq %rbx, %rsi
callq 0x4f5c7
movl %eax, 0x5aa59e(%rip)    # 0x5fa9e0
movl (%rbx), %ebx
testl %ebx, %ebx
je 0x50457
leaq 0x5aa2f1(%rip), %rax    # 0x5fa740
movl %ebx, %edi
callq *0x170(%rax)
movl 0x10(%rsp), %edi
testl %edi, %edi
je 0x5046c
leaq 0x5aa2da(%rip), %rax    # 0x5fa740
callq *0x170(%rax)
movl 0x5aa56e(%rip), %edi    # 0x5fa9e0
testl %edi, %edi
je 0x50703
leaq 0x5aa2bf(%rip), %r14    # 0x5fa740
leaq 0x2989b(%rip), %rsi     # 0x79d23
callq *0x180(%r14)
movl %eax, %ebx
testl %eax, %eax
jns 0x504aa
leaq 0x2acc8(%rip), %rdi     # 0x7b164
leaq 0x29880(%rip), %rsi     # 0x79d23
xorl %eax, %eax
callq 0x25221
movl %ebx, 0x5aa538(%rip)    # 0x5fa9e8
movl 0x5aa52a(%rip), %edi    # 0x5fa9e0
leaq 0x2986f(%rip), %rsi     # 0x79d2c
callq *0x180(%r14)
movl %eax, %ebx
testl %eax, %eax
jns 0x504df
leaq 0x2ac93(%rip), %rdi     # 0x7b164
leaq 0x29854(%rip), %rsi     # 0x79d2c
xorl %eax, %eax
callq 0x25221
movl %ebx, 0x5aa507(%rip)    # 0x5fa9ec
movl 0x5aa4f5(%rip), %edi    # 0x5fa9e0
leaq 0x2abad(%rip), %rsi     # 0x7b09f
callq *0x1a8(%r14)
movl %eax, %ebx
testl %eax, %eax
jns 0x50514
leaq 0x2ac9d(%rip), %rdi     # 0x7b1a3
leaq 0x2ab92(%rip), %rsi     # 0x7b09f
xorl %eax, %eax
callq 0x25221
movl %ebx, 0x5aa4d6(%rip)    # 0x5fa9f0
movl 0x5aa4c0(%rip), %edi    # 0x5fa9e0
leaq 0x2ab84(%rip), %rsi     # 0x7b0ab
callq *0x1a8(%r14)
movl %eax, %ebx
testl %eax, %eax
jns 0x50549
leaq 0x2ac68(%rip), %rdi     # 0x7b1a3
leaq 0x2ab69(%rip), %rsi     # 0x7b0ab
xorl %eax, %eax
callq 0x25221
movl %ebx, 0x5aa4a5(%rip)    # 0x5fa9f4
movl 0x5aa48b(%rip), %edi    # 0x5fa9e0
leaq 0x2ab5c(%rip), %rsi     # 0x7b0b8
callq *0x1a8(%r14)
movl %eax, %ebx
testl %eax, %eax
jns 0x5057e
leaq 0x2ac33(%rip), %rdi     # 0x7b1a3
leaq 0x2ab41(%rip), %rsi     # 0x7b0b8
xorl %eax, %eax
callq 0x25221
movl %ebx, 0x5aa474(%rip)    # 0x5fa9f8
movl 0x5aa456(%rip), %edi    # 0x5fa9e0
leaq 0x2ab31(%rip), %rsi     # 0x7b0c2
callq *0x1a8(%r14)
movl %eax, %ebx
testl %eax, %eax
jns 0x505b3
leaq 0x2abfe(%rip), %rdi     # 0x7b1a3
leaq 0x2ab16(%rip), %rsi     # 0x7b0c2
xorl %eax, %eax
callq 0x25221
movl %ebx, 0x5aa443(%rip)    # 0x5fa9fc
movl 0x5aa421(%rip), %edi    # 0x5fa9e0
leaq 0x2ab0a(%rip), %rsi     # 0x7b0d0
callq *0x1a8(%r14)
movl %eax, %ebx
testl %eax, %eax
jns 0x505e8
leaq 0x2abc9(%rip), %rdi     # 0x7b1a3
leaq 0x2aaef(%rip), %rsi     # 0x7b0d0
xorl %eax, %eax
callq 0x25221
movl %ebx, 0x5aa412(%rip)    # 0x5faa00
movl 0x5aa3ec(%rip), %edi    # 0x5fa9e0
leaq 0x2aae0(%rip), %rsi     # 0x7b0db
callq *0x1a8(%r14)
movl %eax, %ebx
testl %eax, %eax
jns 0x5061d
leaq 0x2ab94(%rip), %rdi     # 0x7b1a3
leaq 0x2aac5(%rip), %rsi     # 0x7b0db
xorl %eax, %eax
callq 0x25221
movl %ebx, 0x5aa3e1(%rip)    # 0x5faa04
movl 0x5aa3b7(%rip), %edi    # 0x5fa9e0
leaq 0x2aab4(%rip), %rsi     # 0x7b0e4
callq *0x1a8(%r14)
movl %eax, %ebx
testl %eax, %eax
jns 0x50652
leaq 0x2ab5f(%rip), %rdi     # 0x7b1a3
leaq 0x2aa99(%rip), %rsi     # 0x7b0e4
xorl %eax, %eax
callq 0x25221
movl %ebx, 0x5aa3b0(%rip)    # 0x5faa08
movl 0x5aa382(%rip), %edi    # 0x5fa9e0
leaq 0x2aa8b(%rip), %rsi     # 0x7b0f0
callq *0x1a8(%r14)
movl %eax, %ebx
testl %eax, %eax
jns 0x50687
leaq 0x2ab2a(%rip), %rdi     # 0x7b1a3
leaq 0x2aa70(%rip), %rsi     # 0x7b0f0
xorl %eax, %eax
callq 0x25221
movl %ebx, 0x5aa37f(%rip)    # 0x5faa0c
movl 0x5aa34d(%rip), %edi    # 0x5fa9e0
leaq 0x2969d(%rip), %rsi     # 0x79d37
callq *0x1a8(%r14)
movl %eax, %ebx
testl %eax, %eax
jns 0x506bc
leaq 0x2aaf5(%rip), %rdi     # 0x7b1a3
leaq 0x29682(%rip), %rsi     # 0x79d37
xorl %eax, %eax
callq 0x25221
movl %ebx, 0x5aa34e(%rip)    # 0x5faa10
movl 0x5aa318(%rip), %edi    # 0x5fa9e0
callq *0x1f0(%r14)
movl 0x5aa323(%rip), %edi    # 0x5fa9f8
xorl %esi, %esi
callq *0x1c0(%r14)
movl 0x5aa318(%rip), %edi    # 0x5fa9fc
movl $0x1, %esi
callq *0x1c0(%r14)
leaq 0x5aa2ed(%rip), %rsi    # 0x5fa9e4
movl $0x1, %edi
callq *0x118(%r14)
cmpl $0x0, 0x5aa33e(%rip)    # 0x5faa48
jne 0x507a4
leaq 0x14(%rsp), %r14
movl $0x0, (%r14)
leaq 0x5aa01d(%rip), %rbx    # 0x5fa740
leaq 0x5aa31e(%rip), %rsi    # 0x5faa48
movl $0x1, %edi
callq *0xb8(%rbx)
movl 0x5aa30d(%rip), %esi    # 0x5faa48
movl $0xde1, %edi            # imm = 0xDE1
callq *0xc8(%rbx)
subq $0x8, %rsp
movl $0xde1, %edi            # imm = 0xDE1
xorl %esi, %esi
movl $0x1908, %edx           # imm = 0x1908
movl $0x1, %ecx
movl $0x1, %r8d
xorl %r9d, %r9d
pushq %r14
pushq $0x1401                 # imm = 0x1401
pushq $0x1908                 # imm = 0x1908
callq *0xd0(%rbx)
addq $0x20, %rsp
movl $0xde1, %edi            # imm = 0xDE1
movl $0x2800, %esi           # imm = 0x2800
movl $0x2600, %edx           # imm = 0x2600
callq *0xe8(%rbx)
movl $0xde1, %edi            # imm = 0xDE1
movl $0x2801, %esi           # imm = 0x2801
movl $0x2600, %edx           # imm = 0x2600
callq *0xe8(%rbx)
movl 0x5aa26e(%rip), %edi    # 0x5faa18
testl %edi, %edi
je 0x507c5
leaq 0x5a9f8b(%rip), %rax    # 0x5fa740
callq *0x168(%rax)
movl $0x0, 0x5aa253(%rip)    # 0x5faa18
leaq 0x2b864(%rip), %rsi     # 0x7c030
leaq 0x2a92a(%rip), %rdx     # 0x7b0fd
movl $0x8b31, %edi           # imm = 0x8B31
callq 0x5ecd9
movl %eax, 0xc(%rsp)
leaq 0x2b458(%rip), %rsi     # 0x7bc40
leaq 0x2a922(%rip), %rdx     # 0x7b111
movl $0x8b30, %edi           # imm = 0x8B30
callq 0x5ecd9
movl %eax, 0x10(%rsp)
movl 0xc(%rsp), %edi
testl %edi, %edi
setne %cl
testl %eax, %eax
setne %al
andb %cl, %al
cmpb $0x1, %al
jne 0x5082b
leaq 0xc(%rsp), %rbx
movl $0x2, %edi
movq %rbx, %rsi
callq 0x4f5c7
movl %eax, 0x5aa1ef(%rip)    # 0x5faa18
movl (%rbx), %edi
testl %edi, %edi
je 0x5083c
leaq 0x5a9f0a(%rip), %rax    # 0x5fa740
callq *0x170(%rax)
movl 0x10(%rsp), %edi
testl %edi, %edi
je 0x50851
leaq 0x5a9ef5(%rip), %rax    # 0x5fa740
callq *0x170(%rax)
movl 0x5aa1c1(%rip), %edi    # 0x5faa18
testl %edi, %edi
je 0x50a4a
leaq 0x5a9eda(%rip), %r14    # 0x5fa740
leaq 0x294b6(%rip), %rsi     # 0x79d23
callq *0x180(%r14)
movl %eax, %ebx
testl %eax, %eax
jns 0x5088f
leaq 0x2a8e3(%rip), %rdi     # 0x7b164
leaq 0x2949b(%rip), %rsi     # 0x79d23
xorl %eax, %eax
callq 0x25221
movl %ebx, 0x5aa18f(%rip)    # 0x5faa24
movl 0x5aa17d(%rip), %edi    # 0x5faa18
leaq 0x2948a(%rip), %rsi     # 0x79d2c
callq *0x180(%r14)
movl %eax, %ebx
testl %eax, %eax
jns 0x508c4
leaq 0x2a8ae(%rip), %rdi     # 0x7b164
leaq 0x2946f(%rip), %rsi     # 0x79d2c
xorl %eax, %eax
callq 0x25221
movl %ebx, 0x5aa15e(%rip)    # 0x5faa28
movl 0x5aa148(%rip), %edi    # 0x5faa18
leaq 0x2a7d4(%rip), %rsi     # 0x7b0ab
callq *0x1a8(%r14)
movl %eax, %ebx
testl %eax, %eax
jns 0x508f9
leaq 0x2a8b8(%rip), %rdi     # 0x7b1a3
leaq 0x2a7b9(%rip), %rsi     # 0x7b0ab
xorl %eax, %eax
callq 0x25221
movl %ebx, 0x5aa12d(%rip)    # 0x5faa2c
movl 0x5aa113(%rip), %edi    # 0x5faa18
leaq 0x2a7ac(%rip), %rsi     # 0x7b0b8
callq *0x1a8(%r14)
movl %eax, %ebx
testl %eax, %eax
jns 0x5092e
leaq 0x2a883(%rip), %rdi     # 0x7b1a3
leaq 0x2a791(%rip), %rsi     # 0x7b0b8
xorl %eax, %eax
callq 0x25221
movl %ebx, 0x5aa0fc(%rip)    # 0x5faa30
movl 0x5aa0de(%rip), %edi    # 0x5faa18
leaq 0x2a79a(%rip), %rsi     # 0x7b0db
callq *0x1a8(%r14)
movl %eax, %ebx
testl %eax, %eax
jns 0x50963
leaq 0x2a84e(%rip), %rdi     # 0x7b1a3
leaq 0x2a77f(%rip), %rsi     # 0x7b0db
xorl %eax, %eax
callq 0x25221
movl %ebx, 0x5aa0cb(%rip)    # 0x5faa34
movl 0x5aa0a9(%rip), %edi    # 0x5faa18
leaq 0x2a7af(%rip), %rsi     # 0x7b125
callq *0x1a8(%r14)
movl %eax, %ebx
testl %eax, %eax
jns 0x50998
leaq 0x2a819(%rip), %rdi     # 0x7b1a3
leaq 0x2a794(%rip), %rsi     # 0x7b125
xorl %eax, %eax
callq 0x25221
movl %ebx, 0x5aa09a(%rip)    # 0x5faa38
movl 0x5aa074(%rip), %edi    # 0x5faa18
leaq 0x2a785(%rip), %rsi     # 0x7b130
callq *0x1a8(%r14)
movl %eax, %ebx
testl %eax, %eax
jns 0x509cd
leaq 0x2a7e4(%rip), %rdi     # 0x7b1a3
leaq 0x2a76a(%rip), %rsi     # 0x7b130
xorl %eax, %eax
callq 0x25221
movl %ebx, 0x5aa069(%rip)    # 0x5faa3c
movl 0x5aa03f(%rip), %edi    # 0x5faa18
leaq 0x29357(%rip), %rsi     # 0x79d37
callq *0x1a8(%r14)
movl %eax, %ebx
testl %eax, %eax
jns 0x50a02
leaq 0x2a7af(%rip), %rdi     # 0x7b1a3
leaq 0x2933c(%rip), %rsi     # 0x79d37
xorl %eax, %eax
callq 0x25221
movl %ebx, 0x5aa038(%rip)    # 0x5faa40
movl 0x5aa00a(%rip), %edi    # 0x5faa18
callq *0x1f0(%r14)
movl 0x5aa015(%rip), %edi    # 0x5faa30
xorl %esi, %esi
callq *0x1c0(%r14)
leaq 0x5a9ff1(%rip), %rsi    # 0x5faa1c
movl $0x1, %edi
callq *0x118(%r14)
leaq 0x5a9fe2(%rip), %rsi    # 0x5faa20
movl $0x1, %edi
callq *0x118(%r14)
leaq 0x5a9cef(%rip), %rax    # 0x5fa740
leaq 0x5a9f7c(%rip), %rsi    # 0x5fa9d4
movl $0x1, %edi
callq *0x118(%rax)
movl $0x10, %edi
callq 0x50f94
addq $0x18, %rsp
popq %rbx
popq %r14
retq