// File: /workspace/github_c_makefile_star2_O3/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, %r14
callq *0x5ab46a(%rip)         # 0x5fa8a0
testl %eax, %eax
je 0x4f53e
movl %eax, %ebx
movq %r14, %rdi
callq 0x6060
testq %rax, %rax
je 0x4f543
leaq 0x2aaaf(%rip), %rsi     # 0x79f07
movq %rax, (%rsp)
movq %rax, %rdi
callq 0x64b0
testq %rax, %rax
je 0x4f4ed
movq %rax, %r13
leaq 0x2f40f(%rip), %r15     # 0x7e886
leaq 0x2aa89(%rip), %r12     # 0x79f07
movl $0x2401, %r14d          # imm = 0x2401
movq %r13, %rdi
movl $0x29, %esi
callq 0x6530
testq %rax, %rax
je 0x4f4ed
movq %rax, %rbp
leaq 0x9(%r13), %rdi
movq %rax, %rdx
subq %r13, %rdx
addq $-0x9, %rdx
movq %r15, %rsi
callq 0x6250
testl %eax, %eax
je 0x4f4d5
movzbl (%r13), %eax
cmpl $0xd, %eax
ja 0x4f4c3
btl %eax, %r14d
jb 0x4f4da
movb $0x20, (%r13)
incq %r13
jmp 0x4f4b3
movb $0x20, (%r13)
incq %r13
cmpq %rbp, %r13
jbe 0x4f4cd
movq %rbp, %rdi
movq %r12, %rsi
callq 0x64b0
movq %rax, %r13
testq %rax, %rax
jne 0x4f484
leaq 0x10(%rsp), %r15
movq (%rsp), %rax
movq %rax, (%r15)
xorl %r14d, %r14d
movl %ebx, %edi
movl $0x1, %esi
movq %r15, %rdx
xorl %ecx, %ecx
callq *0x5ab3ea(%rip)         # 0x5fa8f8
movl %ebx, %edi
callq *0x5ab37a(%rip)         # 0x5fa890
movq (%r15), %rdi
callq 0x61c0
leaq 0xc(%rsp), %r15
movl %ebx, %edi
movl $0x8b81, %esi           # imm = 0x8B81
movq %r15, %rdx
callq *0x5ab3a5(%rip)         # 0x5fa8d8
cmpl $0x0, (%r15)
je 0x4f556
movl %ebx, %r14d
jmp 0x4f5b5
xorl %r14d, %r14d
jmp 0x4f5b5
leaq 0x2a9c7(%rip), %rdi     # 0x79f11
xorl %r14d, %r14d
xorl %eax, %eax
callq 0x6e05b
jmp 0x4f5ad
leaq 0x8(%rsp), %r15
movl $0x0, (%r15)
movl %ebx, %edi
movl $0x8b84, %esi           # imm = 0x8B84
movq %r15, %rdx
callq *0x5ab366(%rip)         # 0x5fa8d8
movl (%r15), %eax
movslq %eax, %r12
movq %r12, %rdi
callq 0x69a0
movq %rax, %r13
movl %ebx, %edi
movl %r12d, %esi
movq %r15, %rdx
movq %rax, %rcx
callq *0x5ab34c(%rip)         # 0x5fa8e0
leaq 0x2a733(%rip), %rdi     # 0x79cce
movq %r13, %rsi
xorl %eax, %eax
callq 0x25221
movq %r13, %rdi
callq 0x61c0
movl %ebx, %edi
callq *0x5ab2fb(%rip)         # 0x5fa8b0
movl %r14d, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq