// File: /workspace/github_c_makefile_star2_O1/jonof[P]jftekwar/jfbuild/src/glbuild.c
// Function: glbuild_compile_shader
GLuint glbuild_compile_shader(GLuint type, const GLchar *source)
{
	GLuint shader;
	GLint status;
	GLchar *cookedsource;

	shader = glfunc.glCreateShader(type);
	if (!shader) {
		return 0;
	}

#if (USE_OPENGL == USE_GLES2)
	cookedsource = glbuild_cook_source(source, "ES2");
#elif (USE_OPENGL == USE_GL3)
	cookedsource = glbuild_cook_source(source, "3");
#else
	cookedsource = glbuild_cook_source(source, "2");
#endif
	if (!cookedsource) {
		glfunc.glDeleteShader(shader);
		return 0;
	}

	glfunc.glShaderSource(shader, 1, (const GLchar**)&cookedsource, NULL);
	glfunc.glCompileShader(shader);
	free(cookedsource);

	glfunc.glGetShaderiv(shader, GL_COMPILE_STATUS, &status);
	if (status == GL_FALSE) {
		GLint loglen = 0;
		GLchar *logtext = NULL;

		glfunc.glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &loglen);

		logtext = (GLchar *)malloc(loglen);
		glfunc.glGetShaderInfoLog(shader, loglen, &loglen, logtext);
		buildprintf("GL shader compile error: %s\n", logtext);
		free(logtext);

		glfunc.glDeleteShader(shader);
		return 0;
	}

	return shader;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %rbx
callq *0x5acbf2(%rip)         # 0x5f98a0
xorl %r12d, %r12d
testl %eax, %eax
je 0x4ce37
movl %eax, %ebp
movq %rbx, %rdi
callq 0x6060
testq %rax, %rax
je 0x4cd72
movq %rax, %r14
leaq 0x2bf51(%rip), %rsi     # 0x78c27
movq %rax, %rdi
callq 0x64b0
testq %rax, %rax
je 0x4cd83
movq %rax, %r13
movl %ebp, 0x4(%rsp)
leaq 0x306f1(%rip), %r15     # 0x7d3e6
leaq 0x2bf2b(%rip), %r12     # 0x78c27
movl $0x2401, %ebp           # imm = 0x2401
movq %r13, %rdi
movl $0x29, %esi
callq 0x6530
testq %rax, %rax
je 0x4cd69
movq %rax, %rbx
leaq 0x9(%r13), %rdi
movq %rax, %rdx
subq %r13, %rdx
addq $-0x9, %rdx
movq %r15, %rsi
callq 0x6250
testl %eax, %eax
je 0x4cd51
movzbl (%r13), %eax
cmpl $0xd, %eax
ja 0x4cd3f
btl %eax, %ebp
jb 0x4cd56
movb $0x20, (%r13)
incq %r13
jmp 0x4cd30
movb $0x20, (%r13)
incq %r13
cmpq %rbx, %r13
jbe 0x4cd49
movq %rbx, %rdi
movq %r12, %rsi
callq 0x64b0
movq %rax, %r13
testq %rax, %rax
jne 0x4cd01
xorl %r12d, %r12d
movl 0x4(%rsp), %ebp
jmp 0x4cd83
leaq 0x2beb8(%rip), %rdi     # 0x78c31
xorl %r14d, %r14d
xorl %eax, %eax
callq 0x6c31f
movq %r14, 0x8(%rsp)
testq %r14, %r14
je 0x4ce2f
xorl %r12d, %r12d
leaq 0x8(%rsp), %rbx
movl %ebp, %edi
movl $0x1, %esi
movq %rbx, %rdx
xorl %ecx, %ecx
callq *0x5acb4d(%rip)         # 0x5f98f8
movl %ebp, %edi
callq *0x5acadd(%rip)         # 0x5f9890
movq (%rbx), %rdi
callq 0x61c0
leaq 0x14(%rsp), %rbx
movl %ebp, %edi
movl $0x8b81, %esi           # imm = 0x8B81
movq %rbx, %rdx
callq *0x5acb08(%rip)         # 0x5f98d8
cmpl $0x0, (%rbx)
je 0x4cdda
movl %ebp, %r12d
jmp 0x4ce37
leaq 0x10(%rsp), %rbx
movl $0x0, (%rbx)
movl %ebp, %edi
movl $0x8b84, %esi           # imm = 0x8B84
movq %rbx, %rdx
callq *0x5acae3(%rip)         # 0x5f98d8
movl (%rbx), %eax
movslq %eax, %r14
movq %r14, %rdi
callq 0x69a0
movq %rax, %r15
movl %ebp, %edi
movl %r14d, %esi
movq %rbx, %rdx
movq %rax, %rcx
callq *0x5acaca(%rip)         # 0x5f98e0
leaq 0x2bbd1(%rip), %rdi     # 0x789ee
movq %r15, %rsi
xorl %eax, %eax
callq 0x24cb4
movq %r15, %rdi
callq 0x61c0
movl %ebp, %edi
callq *0x5aca79(%rip)         # 0x5f98b0
movl %r12d, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq