// File: /workspace/github_c_makefile_star2_O2/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 $0x28, %rsp
movq %rsi, %r14
callq *0x5adc15(%rip)         # 0x5f38a0
testl %eax, %eax
je 0x45d83
movl %eax, %ebx
movq %r14, %rdi
callq 0x6060
testq %rax, %rax
je 0x45d88
movl %ebx, 0xc(%rsp)
leaq 0x28fd6(%rip), %r15     # 0x6ec87
pushq $0x29
popq %rbp
leaq 0x2da2b(%rip), %r12     # 0x736e6
movl $0x2401, %ebx           # imm = 0x2401
movq %rax, 0x10(%rsp)
movq %rax, %r13
movq %r13, %rdi
movq %r15, %rsi
callq 0x64b0
testq %rax, %rax
je 0x45d2f
movq %rax, %r14
movq %rax, %rdi
movl %ebp, %esi
callq 0x6530
testq %rax, %rax
je 0x45d2f
movq %rax, %r13
movq %rax, %rdx
subq %r14, %rdx
movq %r14, %rdi
addq $0x9, %rdi
addq $-0x9, %rdx
movq %r12, %rsi
callq 0x6250
testl %eax, %eax
je 0x45d28
movzbl (%r14), %eax
cmpl $0xd, %eax
ja 0x45d18
btl %eax, %ebx
jb 0x45cc8
movb $0x20, (%r14)
incq %r14
jmp 0x45d0a
movb $0x20, (%r14)
incq %r14
cmpq %r13, %r14
jbe 0x45d21
jmp 0x45cc8
leaq 0x20(%rsp), %r15
movq 0x10(%rsp), %rax
movq %rax, (%r15)
xorl %r14d, %r14d
pushq $0x1
popq %rsi
movl 0xc(%rsp), %ebx
movl %ebx, %edi
movq %r15, %rdx
xorl %ecx, %ecx
callq *0x5adba5(%rip)         # 0x5f38f8
movl %ebx, %edi
callq *0x5adb35(%rip)         # 0x5f3890
movq (%r15), %rdi
callq 0x61c0
leaq 0x1c(%rsp), %r15
movl %ebx, %edi
movl $0x8b81, %esi           # imm = 0x8B81
movq %r15, %rdx
callq *0x5adb60(%rip)         # 0x5f38d8
cmpl $0x0, (%r15)
je 0x45d9b
movl %ebx, %r14d
jmp 0x45df7
xorl %r14d, %r14d
jmp 0x45df7
leaq 0x28f02(%rip), %rdi     # 0x6ec91
xorl %r14d, %r14d
xorl %eax, %eax
callq 0x62903
jmp 0x45def
leaq 0x18(%rsp), %r15
andl $0x0, (%r15)
movl %ebx, %edi
movl $0x8b84, %esi           # imm = 0x8B84
movq %r15, %rdx
callq *0x5adb24(%rip)         # 0x5f38d8
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 *0x5adb0a(%rip)         # 0x5f38e0
leaq 0x28c71(%rip), %rdi     # 0x6ea4e
movq %r13, %rsi
xorl %eax, %eax
callq 0x22427
movq %r13, %rdi
callq 0x61c0
movl %ebx, %edi
callq *0x5adab9(%rip)         # 0x5f38b0
movl %r14d, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq