// File: /workspace/github_c_makefile_star2_O1/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
movq $0x0, 0x8(%rsp)
movl 0x5abd86(%rip), %edi    # 0x5f99e0
testl %edi, %edi
je 0x4dc75
leaq 0x5abadb(%rip), %rax    # 0x5f9740
callq *0x168(%rax)
movl $0x0, 0x5abd6b(%rip)    # 0x5f99e0
leaq 0x2c924(%rip), %rsi     # 0x7a5a0
leaq 0x2bf7a(%rip), %rdx     # 0x79bfd
movl $0x8b31, %edi           # imm = 0x8B31
callq 0x5ca80
movl %eax, 0x8(%rsp)
leaq 0x2c428(%rip), %rsi     # 0x7a0c0
leaq 0x2bf6f(%rip), %rdx     # 0x79c0e
movl $0x8b30, %edi           # imm = 0x8B30
callq 0x5ca80
movl %eax, 0xc(%rsp)
cmpl $0x0, 0x8(%rsp)
setne %cl
testl %eax, %eax
setne %al
andb %cl, %al
cmpb $0x1, %al
jne 0x4dcd5
leaq 0x8(%rsp), %rsi
movl $0x2, %edi
callq 0x4ce49
movl %eax, 0x5abd0b(%rip)    # 0x5f99e0
movl 0x8(%rsp), %edi
testl %edi, %edi
je 0x4dcea
leaq 0x5aba5c(%rip), %rax    # 0x5f9740
callq *0x170(%rax)
movl 0xc(%rsp), %edi
testl %edi, %edi
je 0x4dcff
leaq 0x5aba47(%rip), %rax    # 0x5f9740
callq *0x170(%rax)
movl 0x5abcdb(%rip), %edi    # 0x5f99e0
testl %edi, %edi
je 0x4df96
leaq 0x5aba2c(%rip), %r14    # 0x5f9740
leaq 0x2ad28(%rip), %rsi     # 0x78a43
callq *0x180(%r14)
movl %eax, %ebx
testl %eax, %eax
jns 0x4dd3d
leaq 0x2bfb5(%rip), %rdi     # 0x79ce4
leaq 0x2ad0d(%rip), %rsi     # 0x78a43
xorl %eax, %eax
callq 0x24cb4
movl %ebx, 0x5abca5(%rip)    # 0x5f99e8
movl 0x5abc97(%rip), %edi    # 0x5f99e0
leaq 0x2acfc(%rip), %rsi     # 0x78a4c
callq *0x180(%r14)
movl %eax, %ebx
testl %eax, %eax
jns 0x4dd72
leaq 0x2bf80(%rip), %rdi     # 0x79ce4
leaq 0x2ace1(%rip), %rsi     # 0x78a4c
xorl %eax, %eax
callq 0x24cb4
movl %ebx, 0x5abc74(%rip)    # 0x5f99ec
movl 0x5abc62(%rip), %edi    # 0x5f99e0
leaq 0x2be9a(%rip), %rsi     # 0x79c1f
callq *0x1a8(%r14)
movl %eax, %ebx
testl %eax, %eax
jns 0x4dda7
leaq 0x2bf8a(%rip), %rdi     # 0x79d23
leaq 0x2be7f(%rip), %rsi     # 0x79c1f
xorl %eax, %eax
callq 0x24cb4
movl %ebx, 0x5abc43(%rip)    # 0x5f99f0
movl 0x5abc2d(%rip), %edi    # 0x5f99e0
leaq 0x2be71(%rip), %rsi     # 0x79c2b
callq *0x1a8(%r14)
movl %eax, %ebx
testl %eax, %eax
jns 0x4dddc
leaq 0x2bf55(%rip), %rdi     # 0x79d23
leaq 0x2be56(%rip), %rsi     # 0x79c2b
xorl %eax, %eax
callq 0x24cb4
movl %ebx, 0x5abc12(%rip)    # 0x5f99f4
movl 0x5abbf8(%rip), %edi    # 0x5f99e0
leaq 0x2be49(%rip), %rsi     # 0x79c38
callq *0x1a8(%r14)
movl %eax, %ebx
testl %eax, %eax
jns 0x4de11
leaq 0x2bf20(%rip), %rdi     # 0x79d23
leaq 0x2be2e(%rip), %rsi     # 0x79c38
xorl %eax, %eax
callq 0x24cb4
movl %ebx, 0x5abbe1(%rip)    # 0x5f99f8
movl 0x5abbc3(%rip), %edi    # 0x5f99e0
leaq 0x2be1e(%rip), %rsi     # 0x79c42
callq *0x1a8(%r14)
movl %eax, %ebx
testl %eax, %eax
jns 0x4de46
leaq 0x2beeb(%rip), %rdi     # 0x79d23
leaq 0x2be03(%rip), %rsi     # 0x79c42
xorl %eax, %eax
callq 0x24cb4
movl %ebx, 0x5abbb0(%rip)    # 0x5f99fc
movl 0x5abb8e(%rip), %edi    # 0x5f99e0
leaq 0x2bdf7(%rip), %rsi     # 0x79c50
callq *0x1a8(%r14)
movl %eax, %ebx
testl %eax, %eax
jns 0x4de7b
leaq 0x2beb6(%rip), %rdi     # 0x79d23
leaq 0x2bddc(%rip), %rsi     # 0x79c50
xorl %eax, %eax
callq 0x24cb4
movl %ebx, 0x5abb7f(%rip)    # 0x5f9a00
movl 0x5abb59(%rip), %edi    # 0x5f99e0
leaq 0x2bdcd(%rip), %rsi     # 0x79c5b
callq *0x1a8(%r14)
movl %eax, %ebx
testl %eax, %eax
jns 0x4deb0
leaq 0x2be81(%rip), %rdi     # 0x79d23
leaq 0x2bdb2(%rip), %rsi     # 0x79c5b
xorl %eax, %eax
callq 0x24cb4
movl %ebx, 0x5abb4e(%rip)    # 0x5f9a04
movl 0x5abb24(%rip), %edi    # 0x5f99e0
leaq 0x2bda1(%rip), %rsi     # 0x79c64
callq *0x1a8(%r14)
movl %eax, %ebx
testl %eax, %eax
jns 0x4dee5
leaq 0x2be4c(%rip), %rdi     # 0x79d23
leaq 0x2bd86(%rip), %rsi     # 0x79c64
xorl %eax, %eax
callq 0x24cb4
movl %ebx, 0x5abb1d(%rip)    # 0x5f9a08
movl 0x5abaef(%rip), %edi    # 0x5f99e0
leaq 0x2bd78(%rip), %rsi     # 0x79c70
callq *0x1a8(%r14)
movl %eax, %ebx
testl %eax, %eax
jns 0x4df1a
leaq 0x2be17(%rip), %rdi     # 0x79d23
leaq 0x2bd5d(%rip), %rsi     # 0x79c70
xorl %eax, %eax
callq 0x24cb4
movl %ebx, 0x5abaec(%rip)    # 0x5f9a0c
movl 0x5ababa(%rip), %edi    # 0x5f99e0
leaq 0x2ab2a(%rip), %rsi     # 0x78a57
callq *0x1a8(%r14)
movl %eax, %ebx
testl %eax, %eax
jns 0x4df4f
leaq 0x2bde2(%rip), %rdi     # 0x79d23
leaq 0x2ab0f(%rip), %rsi     # 0x78a57
xorl %eax, %eax
callq 0x24cb4
movl %ebx, 0x5ababb(%rip)    # 0x5f9a10
movl 0x5aba85(%rip), %edi    # 0x5f99e0
callq *0x1f0(%r14)
movl 0x5aba90(%rip), %edi    # 0x5f99f8
xorl %esi, %esi
callq *0x1c0(%r14)
movl 0x5aba85(%rip), %edi    # 0x5f99fc
movl $0x1, %esi
callq *0x1c0(%r14)
leaq 0x5aba5a(%rip), %rsi    # 0x5f99e4
movl $0x1, %edi
callq *0x118(%r14)
cmpl $0x0, 0x5abaab(%rip)    # 0x5f9a48
jne 0x4e037
leaq 0x14(%rsp), %r14
movl $0x0, (%r14)
leaq 0x5ab78a(%rip), %rbx    # 0x5f9740
leaq 0x5aba8b(%rip), %rsi    # 0x5f9a48
movl $0x1, %edi
callq *0xb8(%rbx)
movl 0x5aba7a(%rip), %esi    # 0x5f9a48
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 0x5ab9db(%rip), %edi    # 0x5f9a18
testl %edi, %edi
je 0x4e058
leaq 0x5ab6f8(%rip), %rax    # 0x5f9740
callq *0x168(%rax)
movl $0x0, 0x5ab9c0(%rip)    # 0x5f9a18
leaq 0x2cb11(%rip), %rsi     # 0x7ab70
leaq 0x2bc17(%rip), %rdx     # 0x79c7d
movl $0x8b31, %edi           # imm = 0x8B31
callq 0x5ca80
movl %eax, 0x8(%rsp)
leaq 0x2c705(%rip), %rsi     # 0x7a780
leaq 0x2bc0f(%rip), %rdx     # 0x79c91
movl $0x8b30, %edi           # imm = 0x8B30
callq 0x5ca80
movl %eax, 0xc(%rsp)
cmpl $0x0, 0x8(%rsp)
setne %cl
testl %eax, %eax
setne %al
andb %cl, %al
cmpb $0x1, %al
jne 0x4e0b8
leaq 0x8(%rsp), %rsi
movl $0x2, %edi
callq 0x4ce49
movl %eax, 0x5ab960(%rip)    # 0x5f9a18
movl 0x8(%rsp), %edi
testl %edi, %edi
je 0x4e0cd
leaq 0x5ab679(%rip), %rax    # 0x5f9740
callq *0x170(%rax)
movl 0xc(%rsp), %edi
testl %edi, %edi
je 0x4e0e2
leaq 0x5ab664(%rip), %rax    # 0x5f9740
callq *0x170(%rax)
movl 0x5ab930(%rip), %edi    # 0x5f9a18
testl %edi, %edi
je 0x4e2db
leaq 0x5ab649(%rip), %r14    # 0x5f9740
leaq 0x2a945(%rip), %rsi     # 0x78a43
callq *0x180(%r14)
movl %eax, %ebx
testl %eax, %eax
jns 0x4e120
leaq 0x2bbd2(%rip), %rdi     # 0x79ce4
leaq 0x2a92a(%rip), %rsi     # 0x78a43
xorl %eax, %eax
callq 0x24cb4
movl %ebx, 0x5ab8fe(%rip)    # 0x5f9a24
movl 0x5ab8ec(%rip), %edi    # 0x5f9a18
leaq 0x2a919(%rip), %rsi     # 0x78a4c
callq *0x180(%r14)
movl %eax, %ebx
testl %eax, %eax
jns 0x4e155
leaq 0x2bb9d(%rip), %rdi     # 0x79ce4
leaq 0x2a8fe(%rip), %rsi     # 0x78a4c
xorl %eax, %eax
callq 0x24cb4
movl %ebx, 0x5ab8cd(%rip)    # 0x5f9a28
movl 0x5ab8b7(%rip), %edi    # 0x5f9a18
leaq 0x2bac3(%rip), %rsi     # 0x79c2b
callq *0x1a8(%r14)
movl %eax, %ebx
testl %eax, %eax
jns 0x4e18a
leaq 0x2bba7(%rip), %rdi     # 0x79d23
leaq 0x2baa8(%rip), %rsi     # 0x79c2b
xorl %eax, %eax
callq 0x24cb4
movl %ebx, 0x5ab89c(%rip)    # 0x5f9a2c
movl 0x5ab882(%rip), %edi    # 0x5f9a18
leaq 0x2ba9b(%rip), %rsi     # 0x79c38
callq *0x1a8(%r14)
movl %eax, %ebx
testl %eax, %eax
jns 0x4e1bf
leaq 0x2bb72(%rip), %rdi     # 0x79d23
leaq 0x2ba80(%rip), %rsi     # 0x79c38
xorl %eax, %eax
callq 0x24cb4
movl %ebx, 0x5ab86b(%rip)    # 0x5f9a30
movl 0x5ab84d(%rip), %edi    # 0x5f9a18
leaq 0x2ba89(%rip), %rsi     # 0x79c5b
callq *0x1a8(%r14)
movl %eax, %ebx
testl %eax, %eax
jns 0x4e1f4
leaq 0x2bb3d(%rip), %rdi     # 0x79d23
leaq 0x2ba6e(%rip), %rsi     # 0x79c5b
xorl %eax, %eax
callq 0x24cb4
movl %ebx, 0x5ab83a(%rip)    # 0x5f9a34
movl 0x5ab818(%rip), %edi    # 0x5f9a18
leaq 0x2ba9e(%rip), %rsi     # 0x79ca5
callq *0x1a8(%r14)
movl %eax, %ebx
testl %eax, %eax
jns 0x4e229
leaq 0x2bb08(%rip), %rdi     # 0x79d23
leaq 0x2ba83(%rip), %rsi     # 0x79ca5
xorl %eax, %eax
callq 0x24cb4
movl %ebx, 0x5ab809(%rip)    # 0x5f9a38
movl 0x5ab7e3(%rip), %edi    # 0x5f9a18
leaq 0x2ba74(%rip), %rsi     # 0x79cb0
callq *0x1a8(%r14)
movl %eax, %ebx
testl %eax, %eax
jns 0x4e25e
leaq 0x2bad3(%rip), %rdi     # 0x79d23
leaq 0x2ba59(%rip), %rsi     # 0x79cb0
xorl %eax, %eax
callq 0x24cb4
movl %ebx, 0x5ab7d8(%rip)    # 0x5f9a3c
movl 0x5ab7ae(%rip), %edi    # 0x5f9a18
leaq 0x2a7e6(%rip), %rsi     # 0x78a57
callq *0x1a8(%r14)
movl %eax, %ebx
testl %eax, %eax
jns 0x4e293
leaq 0x2ba9e(%rip), %rdi     # 0x79d23
leaq 0x2a7cb(%rip), %rsi     # 0x78a57
xorl %eax, %eax
callq 0x24cb4
movl %ebx, 0x5ab7a7(%rip)    # 0x5f9a40
movl 0x5ab779(%rip), %edi    # 0x5f9a18
callq *0x1f0(%r14)
movl 0x5ab784(%rip), %edi    # 0x5f9a30
xorl %esi, %esi
callq *0x1c0(%r14)
leaq 0x5ab760(%rip), %rsi    # 0x5f9a1c
movl $0x1, %edi
callq *0x118(%r14)
leaq 0x5ab751(%rip), %rsi    # 0x5f9a20
movl $0x1, %edi
callq *0x118(%r14)
leaq 0x5ab45e(%rip), %rax    # 0x5f9740
leaq 0x5ab6eb(%rip), %rsi    # 0x5f99d4
movl $0x1, %edi
callq *0x118(%rax)
movl $0x10, %edi
callq 0x4e833
addq $0x18, %rsp
popq %rbx
popq %r14
retq