#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*/ str;
typedef scalar_t__ GLint;
typedef int /*<<< orphan*/ GLhandleARB;

/* Variables and functions */
scalar_t__ GL_FALSE;
int /*<<< orphan*/ GL_FRAGMENT_SHADER_ARB;
int /*<<< orphan*/ GL_OBJECT_COMPILE_STATUS_ARB;
int /*<<< orphan*/ GL_OBJECT_LINK_STATUS_ARB;
int /*<<< orphan*/ GL_VERTEX_SHADER_ARB;
int /*<<< orphan*/ free(void *);
int /*<<< orphan*/ glAttachObjectARB(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ glCompileShaderARB(int /*<<< orphan*/);
int /*<<< orphan*/ glCreateProgramObjectARB();
int /*<<< orphan*/ glCreateShaderObjectARB(int /*<<< orphan*/);
int /*<<< orphan*/ glGetInfoLogARB(int /*<<< orphan*/, int,
                                   int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ glGetObjectParameterivARB(int /*<<< orphan*/,
                                             int /*<<< orphan*/, scalar_t__ *);
int /*<<< orphan*/ glLinkProgramARB(int /*<<< orphan*/);
int /*<<< orphan*/ glShaderSourceARB(int /*<<< orphan*/, int, char const **,
                                     int /*<<< orphan*/ *);
int /*<<< orphan*/ printError(char *, char *);
char *readShaderFile(char const *);
GLhandleARB createShader(const char *vertfilename, const char *fragfilename) {
  GLhandleARB programObj;
  GLhandleARB fragmentShader;
  GLhandleARB vertexShader;
  const char *vertexShaderStrings[1];
  GLint vertexCompiled;
  const char *fragmentShaderStrings[1];
  GLint fragmentCompiled;
  GLint shadersLinked;
  char str[4096];
  vertexShader = glCreateShaderObjectARB(GL_VERTEX_SHADER_ARB);
  char *vertexShaderAssembly = readShaderFile(vertfilename);
  vertexShaderStrings[0] = vertexShaderAssembly;
  glShaderSourceARB(vertexShader, 1, vertexShaderStrings, NULL);
  glCompileShaderARB(vertexShader);
  free((void *)vertexShaderAssembly);
  glGetObjectParameterivARB(vertexShader, GL_OBJECT_COMPILE_STATUS_ARB,
                            &vertexCompiled);
  if (vertexCompiled == GL_FALSE) {
    glGetInfoLogARB(vertexShader, sizeof(str), NULL, str);
    printError("Vertex shader compile error", str);
  }
  fragmentShader = glCreateShaderObjectARB(GL_FRAGMENT_SHADER_ARB);
  char *fragmentShaderAssembly = readShaderFile(fragfilename);
  fragmentShaderStrings[0] = fragmentShaderAssembly;
  glShaderSourceARB(fragmentShader, 1, fragmentShaderStrings, NULL);
  glCompileShaderARB(fragmentShader);
  free((void *)fragmentShaderAssembly);
  glGetObjectParameterivARB(fragmentShader, GL_OBJECT_COMPILE_STATUS_ARB,
                            &fragmentCompiled);
  if (fragmentCompiled == GL_FALSE) {
    glGetInfoLogARB(fragmentShader, sizeof(str), NULL, str);
    printError("Fragment shader compile error", str);
  }
  programObj = glCreateProgramObjectARB();
  glAttachObjectARB(programObj, vertexShader);
  glAttachObjectARB(programObj, fragmentShader);
  glLinkProgramARB(programObj);
  glGetObjectParameterivARB(programObj, GL_OBJECT_LINK_STATUS_ARB,
                            &shadersLinked);
  if (shadersLinked == GL_FALSE) {
    glGetInfoLogARB(programObj, sizeof(str), NULL, str);
    printError("Program object linking error", str);
  }
  return programObj;
}


x86 assembly (clang, -O0):
<createShader>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1060,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2df6(%rip),%rax
mov    (%rax),%edi
call   1070 <glCreateShaderObjectARB@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <readShaderFile@plt>
mov    %rax,-0x1058(%rbp)
mov    -0x1058(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x1c(%rbp),%edi
lea    -0x28(%rbp),%rdx
mov    $0x1,%esi
xor    %eax,%eax
mov    %eax,%ecx
call   10b0 <glShaderSourceARB@plt>
mov    -0x1c(%rbp),%edi
call   10c0 <glCompileShaderARB@plt>
mov    -0x1058(%rbp),%rdi
call   1030 <free@plt>
mov    -0x1c(%rbp),%edi
mov    0x2dbe(%rip),%rax
mov    (%rax),%esi
lea    -0x30(%rbp),%rdx
call   1050 <glGetObjectParameterivARB@plt>
mov    -0x30(%rbp),%rax
mov    0x2db0(%rip),%rcx
cmp    (%rcx),%rax
jne    126c <createShader+0xbc>
mov    -0x1c(%rbp),%edi
lea    -0x1050(%rbp),%rcx
mov    $0x1000,%esi
xor    %eax,%eax
mov    %eax,%edx
call   1080 <glGetInfoLogARB@plt>
lea    -0x1050(%rbp),%rsi
lea    0xd99(%rip),%rdi
call   10a0 <printError@plt>
mov    0x2d5d(%rip),%rax
mov    (%rax),%edi
call   1070 <glCreateShaderObjectARB@plt>
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <readShaderFile@plt>
mov    %rax,-0x1060(%rbp)
mov    -0x1060(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%edi
lea    -0x38(%rbp),%rdx
mov    $0x1,%esi
xor    %eax,%eax
mov    %eax,%ecx
call   10b0 <glShaderSourceARB@plt>
mov    -0x18(%rbp),%edi
call   10c0 <glCompileShaderARB@plt>
mov    -0x1060(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%edi
mov    0x2d15(%rip),%rax
mov    (%rax),%esi
lea    -0x40(%rbp),%rdx
call   1050 <glGetObjectParameterivARB@plt>
mov    -0x40(%rbp),%rax
mov    0x2d07(%rip),%rcx
cmp    (%rcx),%rax
jne    1315 <createShader+0x165>
mov    -0x18(%rbp),%edi
lea    -0x1050(%rbp),%rcx
mov    $0x1000,%esi
xor    %eax,%eax
mov    %eax,%edx
call   1080 <glGetInfoLogARB@plt>
lea    -0x1050(%rbp),%rsi
lea    0xd0c(%rip),%rdi
call   10a0 <printError@plt>
mov    $0x0,%al
call   1060 <glCreateProgramObjectARB@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x1c(%rbp),%esi
call   10d0 <glAttachObjectARB@plt>
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
call   10d0 <glAttachObjectARB@plt>
mov    -0x14(%rbp),%edi
call   1090 <glLinkProgramARB@plt>
mov    -0x14(%rbp),%edi
mov    0x2c81(%rip),%rax
mov    (%rax),%esi
lea    -0x48(%rbp),%rdx
call   1050 <glGetObjectParameterivARB@plt>
mov    -0x48(%rbp),%rax
mov    0x2c8b(%rip),%rcx
cmp    (%rcx),%rax
jne    1391 <createShader+0x1e1>
mov    -0x14(%rbp),%edi
lea    -0x1050(%rbp),%rcx
mov    $0x1000,%esi
xor    %eax,%eax
mov    %eax,%edx
call   1080 <glGetInfoLogARB@plt>
lea    -0x1050(%rbp),%rsi
lea    0xcae(%rip),%rdi
call   10a0 <printError@plt>
mov    -0x14(%rbp),%eax
add    $0x1060,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<createShader>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1038,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
mov    0x2df2(%rip),%rax
mov    (%rax),%edi
call   1070 <glCreateShaderObjectARB@plt>
mov    %eax,%r15d
mov    %rbx,%rdi
call   1040 <readShaderFile@plt>
mov    %rax,%rbx
mov    %rax,0x28(%rsp)
lea    0x28(%rsp),%rdx
mov    %r15d,%edi
mov    $0x1,%esi
xor    %ecx,%ecx
call   10b0 <glShaderSourceARB@plt>
mov    %r15d,%edi
call   10c0 <glCompileShaderARB@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    0x2dcd(%rip),%r13
mov    0x0(%r13),%esi
lea    0x20(%rsp),%rdx
mov    %r15d,%edi
call   1050 <glGetObjectParameterivARB@plt>
mov    0x20(%rsp),%rax
mov    0x2db8(%rip),%r12
cmp    (%r12),%rax
jne    125c <createShader+0xac>
lea    0x30(%rsp),%rbx
mov    %r15d,%edi
mov    $0x1000,%esi
xor    %edx,%edx
mov    %rbx,%rcx
call   1080 <glGetInfoLogARB@plt>
lea    0xdac(%rip),%rdi
mov    %rbx,%rsi
call   10a0 <printError@plt>
mov    0x2d6d(%rip),%rax
mov    (%rax),%edi
call   1070 <glCreateShaderObjectARB@plt>
mov    %eax,%ebp
mov    %r14,%rdi
call   1040 <readShaderFile@plt>
mov    %rax,%rbx
mov    %rax,0x18(%rsp)
lea    0x18(%rsp),%rdx
mov    %ebp,%edi
mov    $0x1,%esi
xor    %ecx,%ecx
call   10b0 <glShaderSourceARB@plt>
mov    %ebp,%edi
call   10c0 <glCompileShaderARB@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    0x0(%r13),%esi
lea    0x10(%rsp),%rdx
mov    %ebp,%edi
call   1050 <glGetObjectParameterivARB@plt>
mov    0x10(%rsp),%rax
cmp    (%r12),%rax
jne    12de <createShader+0x12e>
lea    0x30(%rsp),%rbx
mov    %ebp,%edi
mov    $0x1000,%esi
xor    %edx,%edx
mov    %rbx,%rcx
call   1080 <glGetInfoLogARB@plt>
lea    0xd46(%rip),%rdi
mov    %rbx,%rsi
call   10a0 <printError@plt>
xor    %eax,%eax
call   1060 <glCreateProgramObjectARB@plt>
mov    %eax,%ebx
mov    %eax,%edi
mov    %r15d,%esi
call   10d0 <glAttachObjectARB@plt>
mov    %ebx,%edi
mov    %ebp,%esi
call   10d0 <glAttachObjectARB@plt>
mov    %ebx,%edi
call   1090 <glLinkProgramARB@plt>
mov    0x2cc0(%rip),%rax
mov    (%rax),%esi
lea    0x8(%rsp),%rdx
mov    %ebx,%edi
call   1050 <glGetObjectParameterivARB@plt>
mov    0x8(%rsp),%rax
cmp    (%r12),%rax
jne    1346 <createShader+0x196>
lea    0x30(%rsp),%rbp
mov    %ebx,%edi
mov    $0x1000,%esi
xor    %edx,%edx
mov    %rbp,%rcx
call   1080 <glGetInfoLogARB@plt>
lea    0xcfc(%rip),%rdi
mov    %rbp,%rsi
call   10a0 <printError@plt>
mov    %ebx,%eax
add    $0x1038,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@GL_VERTEX_SHADER_ARB = global i32 0
@GL_OBJECT_COMPILE_STATUS_ARB = global i32 0
@GL_FALSE = global i64 0
@.str = [28 x i8] c"Vertex shader compile error\00"
@GL_FRAGMENT_SHADER_ARB = global i32 0
@.str.1 = [30 x i8] c"Fragment shader compile error\00"
@GL_OBJECT_LINK_STATUS_ARB = global i32 0
@.str.2 = [29 x i8] c"Program object linking error\00"
define i32 @createShader(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca [1 x i8*]
%9 = alloca i64
%10 = alloca [1 x i8*]
%11 = alloca i64
%12 = alloca i64
%13 = alloca [4096 x i8]
%14 = alloca i8*
%15 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%16 = load i32, i32* @GL_VERTEX_SHADER_ARB
%17 = call i32 @glCreateShaderObjectARB(i32 %16)
store i32 %17, i32* %7
%18 = load i8*, i8** %3
%19 = call i8* @readShaderFile(i8* %18)
store i8* %19, i8** %14
%20 = load i8*, i8** %14
%21 = getelementptr inbounds [1 x i8*], [1 x i8*]* %8, i64 0, i64 0
store i8* %20, i8** %21
%22 = load i32, i32* %7
%23 = getelementptr inbounds [1 x i8*], [1 x i8*]* %8, i64 0, i64 0
%24 = call i32 @glShaderSourceARB(i32 %22, i32 1, i8** %23, i32* null)
%25 = load i32, i32* %7
%26 = call i32 @glCompileShaderARB(i32 %25)
%27 = load i8*, i8** %14
%28 = call i32 @free(i8* %27)
%29 = load i32, i32* %7
%30 = load i32, i32* @GL_OBJECT_COMPILE_STATUS_ARB
%31 = call i32 @glGetObjectParameterivARB(i32 %29, i32 %30, i64* %9)
%32 = load i64, i64* %9
%33 = load i64, i64* @GL_FALSE
%34 = icmp eq i64 %32, %33
br i1 %34, label %35, label %41
35: ; preds = %2
%36 = load i32, i32* %7
%37 = getelementptr inbounds [4096 x i8], [4096 x i8]* %13, i64 0, i64 0
%38 = call i32 @glGetInfoLogARB(i32 %36, i32 4096, i32* null, i8* %37)
%39 = getelementptr inbounds [4096 x i8], [4096 x i8]* %13, i64 0, i64 0
%40 = call i32 @printError(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* %39)
br label %41
41: ; preds = %35, %2
%42 = load i32, i32* @GL_FRAGMENT_SHADER_ARB
%43 = call i32 @glCreateShaderObjectARB(i32 %42)
store i32 %43, i32* %6
%44 = load i8*, i8** %4
%45 = call i8* @readShaderFile(i8* %44)
store i8* %45, i8** %15
%46 = load i8*, i8** %15
%47 = getelementptr inbounds [1 x i8*], [1 x i8*]* %10, i64 0, i64 0
store i8* %46, i8** %47
%48 = load i32, i32* %6
%49 = getelementptr inbounds [1 x i8*], [1 x i8*]* %10, i64 0, i64 0
%50 = call i32 @glShaderSourceARB(i32 %48, i32 1, i8** %49, i32* null)
%51 = load i32, i32* %6
%52 = call i32 @glCompileShaderARB(i32 %51)
%53 = load i8*, i8** %15
%54 = call i32 @free(i8* %53)
%55 = load i32, i32* %6
%56 = load i32, i32* @GL_OBJECT_COMPILE_STATUS_ARB
%57 = call i32 @glGetObjectParameterivARB(i32 %55, i32 %56, i64* %11)
%58 = load i64, i64* %11
%59 = load i64, i64* @GL_FALSE
%60 = icmp eq i64 %58, %59
br i1 %60, label %61, label %67
61: ; preds = %41
%62 = load i32, i32* %6
%63 = getelementptr inbounds [4096 x i8], [4096 x i8]* %13, i64 0, i64 0
%64 = call i32 @glGetInfoLogARB(i32 %62, i32 4096, i32* null, i8* %63)
%65 = getelementptr inbounds [4096 x i8], [4096 x i8]* %13, i64 0, i64 0
%66 = call i32 @printError(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* %65)
br label %67
67: ; preds = %61, %41
%68 = call i32 (...) @glCreateProgramObjectARB()
store i32 %68, i32* %5
%69 = load i32, i32* %5
%70 = load i32, i32* %7
%71 = call i32 @glAttachObjectARB(i32 %69, i32 %70)
%72 = load i32, i32* %5
%73 = load i32, i32* %6
%74 = call i32 @glAttachObjectARB(i32 %72, i32 %73)
%75 = load i32, i32* %5
%76 = call i32 @glLinkProgramARB(i32 %75)
%77 = load i32, i32* %5
%78 = load i32, i32* @GL_OBJECT_LINK_STATUS_ARB
%79 = call i32 @glGetObjectParameterivARB(i32 %77, i32 %78, i64* %12)
%80 = load i64, i64* %12
%81 = load i64, i64* @GL_FALSE
%82 = icmp eq i64 %80, %81
br i1 %82, label %83, label %89
83: ; preds = %67
%84 = load i32, i32* %5
%85 = getelementptr inbounds [4096 x i8], [4096 x i8]* %13, i64 0, i64 0
%86 = call i32 @glGetInfoLogARB(i32 %84, i32 4096, i32* null, i8* %85)
%87 = getelementptr inbounds [4096 x i8], [4096 x i8]* %13, i64 0, i64 0
%88 = call i32 @printError(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i8* %87)
br label %89
89: ; preds = %83, %67
%90 = load i32, i32* %5
ret i32 %90
}

LLVM IR (-O2):
@GL_VERTEX_SHADER_ARB = global i32 0
@GL_OBJECT_COMPILE_STATUS_ARB = global i32 0
@GL_FALSE = global i64 0
@.str = [28 x i8] c"Vertex shader compile error\00"
@GL_FRAGMENT_SHADER_ARB = global i32 0
@.str.1 = [30 x i8] c"Fragment shader compile error\00"
@GL_OBJECT_LINK_STATUS_ARB = global i32 0
@.str.2 = [29 x i8] c"Program object linking error\00"
define i32 @createShader(i8* %0, i8* %1) {
%3 = alloca [1 x i8*]
%4 = alloca i64
%5 = alloca [1 x i8*]
%6 = alloca i64
%7 = alloca i64
%8 = alloca [4096 x i8]
%9 = bitcast [1 x i8*]* %3 to i8*
%10 = bitcast i64* %4 to i8*
%11 = bitcast [1 x i8*]* %5 to i8*
%12 = bitcast i64* %6 to i8*
%13 = bitcast i64* %7 to i8*
%14 = getelementptr inbounds [4096 x i8], [4096 x i8]* %8, i64 0, i64 0
%15 = load i32, i32* @GL_VERTEX_SHADER_ARB
%16 = tail call i32 @glCreateShaderObjectARB(i32 %15)
%17 = tail call i8* @readShaderFile(i8* %0)
%18 = getelementptr inbounds [1 x i8*], [1 x i8*]* %3, i64 0, i64 0
store i8* %17, i8** %18
%19 = call i32 @glShaderSourceARB(i32 %16, i32 1, i8** %18, i32* null)
%20 = call i32 @glCompileShaderARB(i32 %16)
%21 = call i32 @free(i8* %17)
%22 = load i32, i32* @GL_OBJECT_COMPILE_STATUS_ARB
%23 = call i32 @glGetObjectParameterivARB(i32 %16, i32 %22, i64* %4)
%24 = load i64, i64* %4
%25 = load i64, i64* @GL_FALSE
%26 = icmp eq i64 %24, %25
br i1 %26, label %27, label %30
27: ; preds = %2
%28 = call i32 @glGetInfoLogARB(i32 %16, i32 4096, i32* null, i8* %14)
%29 = call i32 @printError(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* %14)
br label %30
30: ; preds = %27, %2
%31 = load i32, i32* @GL_FRAGMENT_SHADER_ARB
%32 = call i32 @glCreateShaderObjectARB(i32 %31)
%33 = call i8* @readShaderFile(i8* %1)
%34 = getelementptr inbounds [1 x i8*], [1 x i8*]* %5, i64 0, i64 0
store i8* %33, i8** %34
%35 = call i32 @glShaderSourceARB(i32 %32, i32 1, i8** %34, i32* null)
%36 = call i32 @glCompileShaderARB(i32 %32)
%37 = call i32 @free(i8* %33)
%38 = load i32, i32* @GL_OBJECT_COMPILE_STATUS_ARB
%39 = call i32 @glGetObjectParameterivARB(i32 %32, i32 %38, i64* %6)
%40 = load i64, i64* %6
%41 = load i64, i64* @GL_FALSE
%42 = icmp eq i64 %40, %41
br i1 %42, label %43, label %46
43: ; preds = %30
%44 = call i32 @glGetInfoLogARB(i32 %32, i32 4096, i32* null, i8* %14)
%45 = call i32 @printError(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* %14)
br label %46
46: ; preds = %43, %30
%47 = call i32 (...) @glCreateProgramObjectARB()
%48 = call i32 @glAttachObjectARB(i32 %47, i32 %16)
%49 = call i32 @glAttachObjectARB(i32 %47, i32 %32)
%50 = call i32 @glLinkProgramARB(i32 %47)
%51 = load i32, i32* @GL_OBJECT_LINK_STATUS_ARB
%52 = call i32 @glGetObjectParameterivARB(i32 %47, i32 %51, i64* %7)
%53 = load i64, i64* %7
%54 = load i64, i64* @GL_FALSE
%55 = icmp eq i64 %53, %54
br i1 %55, label %56, label %59
56: ; preds = %46
%57 = call i32 @glGetInfoLogARB(i32 %47, i32 4096, i32* null, i8* %14)
%58 = call i32 @printError(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i8* %14)
br label %59
59: ; preds = %56, %46
ret i32 %47
}