#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
typedef int /*<<< orphan*/ GLuint;
typedef int /*<<< orphan*/ GLsizei;
typedef int /*<<< orphan*/ GLint;
typedef int /*<<< orphan*/ GLenum;
typedef char GLchar;

/* Variables and functions */
int /*<<< orphan*/ GL_COMPILE_STATUS;
int /*<<< orphan*/ Init();
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ glCompileShader_func(int /*<<< orphan*/);
int /*<<< orphan*/ glCreateShader_func(int /*<<< orphan*/);
int /*<<< orphan*/ glGetShaderInfoLog_func(int /*<<< orphan*/, int,
                                           int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ glGetShaderiv_func(int /*<<< orphan*/, int /*<<< orphan*/,
                                      int /*<<< orphan*/ *);
int /*<<< orphan*/ glShaderSource_func(int /*<<< orphan*/, int, char const **,
                                       int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
GLuint CompileShaderText(GLenum shaderType, const char *text) {
  GLuint shader;
  GLint stat;
  Init();
  shader = glCreateShader_func(shaderType);
  glShaderSource_func(shader, 1, (const GLchar **)&text, NULL);
  glCompileShader_func(shader);
  glGetShaderiv_func(shader, GL_COMPILE_STATUS, &stat);
  if (!stat) {
    GLchar log[1000];
    GLsizei len;
    glGetShaderInfoLog_func(shader, 1000, &len, log);
    fprintf(stderr, "Error: problem compiling shader: %s\n", log);
    exit(1);
  } else {
  }
  return shader;
}


x86 assembly (clang, -O0):
<CompileShaderText>:
push   %rbp
mov    %rsp,%rbp
sub    $0x410,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1080 <Init@plt>
mov    -0x4(%rbp),%edi
call   1090 <glCreateShader_func@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
mov    $0x1,%esi
lea    -0x10(%rbp),%rdx
xor    %eax,%eax
mov    %eax,%ecx
call   1030 <glShaderSource_func@plt>
mov    -0x14(%rbp),%edi
call   1050 <glCompileShader_func@plt>
mov    -0x14(%rbp),%edi
mov    0x2e0d(%rip),%rax
mov    (%rax),%esi
lea    -0x18(%rbp),%rdx
call   1070 <glGetShaderiv_func@plt>
cmpl   $0x0,-0x18(%rbp)
jne    1221 <CompileShaderText+0xa1>
mov    -0x14(%rbp),%edi
lea    -0x400(%rbp),%rcx
mov    $0x3e8,%esi
lea    -0x404(%rbp),%rdx
call   1040 <glGetShaderInfoLog_func@plt>
mov    0x2dde(%rip),%rax
mov    (%rax),%edi
lea    -0x400(%rbp),%rdx
lea    0xdee(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
jmp    1226 <CompileShaderText+0xa6>
mov    -0x14(%rbp),%eax
add    $0x410,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CompileShaderText>:
push   %r14
push   %rbx
sub    $0x408,%rsp
mov    %edi,%ebx
mov    %rsi,0x10(%rsp)
xor    %eax,%eax
call   1080 <Init@plt>
mov    %ebx,%edi
call   1090 <glCreateShader_func@plt>
mov    %eax,%ebx
lea    0x10(%rsp),%rdx
mov    %eax,%edi
mov    $0x1,%esi
xor    %ecx,%ecx
call   1030 <glShaderSource_func@plt>
mov    %ebx,%edi
call   1050 <glCompileShader_func@plt>
mov    0x2e16(%rip),%rax
mov    (%rax),%esi
lea    0xc(%rsp),%rdx
mov    %ebx,%edi
call   1070 <glGetShaderiv_func@plt>
cmpl   $0x0,0xc(%rsp)
je     11e4 <CompileShaderText+0x64>
mov    %ebx,%eax
add    $0x408,%rsp
pop    %rbx
pop    %r14
ret
lea    0x1c(%rsp),%rdx
lea    0x20(%rsp),%r14
mov    %ebx,%edi
mov    $0x3e8,%esi
mov    %r14,%rcx
call   1040 <glGetShaderInfoLog_func@plt>
mov    0x2ddc(%rip),%rax
mov    (%rax),%edi
lea    0xdf3(%rip),%rsi
mov    %r14,%rdx
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@GL_COMPILE_STATUS = global i32 0
@stderr = global i32 0
@.str = [37 x i8] c"Error: problem compiling shader: %s\0A\00"
define i32 @CompileShaderText(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca [1000 x i8]
%8 = alloca i32
store i32 %0, i32* %3
store i8* %1, i8** %4
%9 = call i32 (...) @Init()
%10 = load i32, i32* %3
%11 = call i32 @glCreateShader_func(i32 %10)
store i32 %11, i32* %5
%12 = load i32, i32* %5
%13 = call i32 @glShaderSource_func(i32 %12, i32 1, i8** %4, i32* null)
%14 = load i32, i32* %5
%15 = call i32 @glCompileShader_func(i32 %14)
%16 = load i32, i32* %5
%17 = load i32, i32* @GL_COMPILE_STATUS
%18 = call i32 @glGetShaderiv_func(i32 %16, i32 %17, i32* %6)
%19 = load i32, i32* %6
%20 = icmp ne i32 %19, 0
br i1 %20, label %29, label %21
21: ; preds = %2
%22 = load i32, i32* %5
%23 = getelementptr inbounds [1000 x i8], [1000 x i8]* %7, i64 0, i64 0
%24 = call i32 @glGetShaderInfoLog_func(i32 %22, i32 1000, i32* %8, i8* %23)
%25 = load i32, i32* @stderr
%26 = getelementptr inbounds [1000 x i8], [1000 x i8]* %7, i64 0, i64 0
%27 = call i32 @fprintf(i32 %25, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i8* %26)
%28 = call i32 @exit(i32 1)
unreachable
29: ; preds = %2
br label %30
30: ; preds = %29
%31 = load i32, i32* %5
ret i32 %31
}

LLVM IR (-O2):
@GL_COMPILE_STATUS = global i32 0
@stderr = global i32 0
@.str = [37 x i8] c"Error: problem compiling shader: %s\0A\00"
define i32 @CompileShaderText(i32 %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca [1000 x i8]
%6 = alloca i32
store i8* %1, i8** %3
%7 = bitcast i32* %4 to i8*
%8 = tail call i32 (...) @Init()
%9 = tail call i32 @glCreateShader_func(i32 %0)
%10 = call i32 @glShaderSource_func(i32 %9, i32 1, i8** %3, i32* null)
%11 = call i32 @glCompileShader_func(i32 %9)
%12 = load i32, i32* @GL_COMPILE_STATUS
%13 = call i32 @glGetShaderiv_func(i32 %9, i32 %12, i32* %4)
%14 = load i32, i32* %4
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %23
16: ; preds = %2
%17 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 0
%18 = bitcast i32* %6 to i8*
%19 = call i32 @glGetShaderInfoLog_func(i32 %9, i32 1000, i32* %6, i8* %17)
%20 = load i32, i32* @stderr
%21 = call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i8* %17)
%22 = call i32 @exit(i32 1)
unreachable
23: ; preds = %2
ret i32 %9
}