#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 scalar_t__ GLint;

/* Variables and functions */
scalar_t__ GL_FALSE;
int GL_INFO_LOG_LENGTH;
int GL_LINK_STATUS;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int, int, char *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ glAttachShader(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ glCreateProgram();
int /*<<< orphan*/ glGetProgramInfoLog(int /*<<< orphan*/, scalar_t__,
                                       int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ glGetProgramiv(int /*<<< orphan*/, int, scalar_t__ *);
int /*<<< orphan*/ glLinkProgram(int /*<<< orphan*/);
char *malloc(scalar_t__);
int /*<<< orphan*/ stderr;
GLuint CreateProgram(GLuint vertexShader, GLuint fragmentShader) {
  GLuint program = glCreateProgram();
  glAttachShader(program, vertexShader);
  glAttachShader(program, fragmentShader);
  glLinkProgram(program);
  {
    GLint status;
    glGetProgramiv(program, GL_LINK_STATUS, &status);
    if (GL_FALSE == status) {
      GLint logLength;
      glGetProgramiv(program, GL_INFO_LOG_LENGTH, &logLength);
      char *infoLog = malloc(logLength * sizeof(char));
      glGetProgramInfoLog(program, logLength, NULL, infoLog);
      fprintf(stderr, "%d: %d, %s\n", 68, GL_LINK_STATUS, infoLog);
      free(infoLog);
    }
  };
  return program;
}


x86 assembly (clang, -O0):
<CreateProgram>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    $0x0,%al
call   1050 <glCreateProgram@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x4(%rbp),%esi
call   1090 <glAttachShader@plt>
mov    -0xc(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1090 <glAttachShader@plt>
mov    -0xc(%rbp),%edi
call   10a0 <glLinkProgram@plt>
mov    -0xc(%rbp),%edi
mov    0x2e18(%rip),%rax
mov    (%rax),%esi
lea    -0x18(%rbp),%rdx
call   1060 <glGetProgramiv@plt>
mov    0x2e0e(%rip),%rax
mov    (%rax),%rax
cmp    -0x18(%rbp),%rax
jne    1249 <CreateProgram+0xc9>
mov    -0xc(%rbp),%edi
mov    0x2e07(%rip),%rax
mov    (%rax),%esi
lea    -0x20(%rbp),%rdx
call   1060 <glGetProgramiv@plt>
mov    -0x20(%rbp),%rdi
shl    $0x0,%rdi
call   1080 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rcx
xor    %eax,%eax
mov    %eax,%edx
call   1040 <glGetProgramInfoLog@plt>
mov    0x2da8(%rip),%rax
mov    (%rax),%edi
mov    0x2daf(%rip),%rax
mov    (%rax),%ecx
mov    -0x28(%rbp),%r8
lea    0xdca(%rip),%rsi
mov    $0x44,%edx
call   1070 <fprintf@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0xc(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CreateProgram>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %esi,%r14d
mov    %edi,%ebp
xor    %eax,%eax
call   1050 <glCreateProgram@plt>
mov    %eax,%ebx
mov    %eax,%edi
mov    %ebp,%esi
call   1090 <glAttachShader@plt>
mov    %ebx,%edi
mov    %r14d,%esi
call   1090 <glAttachShader@plt>
mov    %ebx,%edi
call   10a0 <glLinkProgram@plt>
mov    0x2e1f(%rip),%r15
mov    (%r15),%esi
lea    0x10(%rsp),%rdx
mov    %ebx,%edi
call   1060 <glGetProgramiv@plt>
mov    0x2e11(%rip),%rax
mov    (%rax),%rax
cmp    0x10(%rsp),%rax
jne    1235 <CreateProgram+0xb5>
mov    0x2e10(%rip),%rax
mov    (%rax),%esi
lea    0x8(%rsp),%rdx
mov    %ebx,%edi
call   1060 <glGetProgramiv@plt>
mov    0x8(%rsp),%rbp
mov    %rbp,%rdi
call   1080 <malloc@plt>
mov    %rax,%r14
mov    %ebx,%edi
mov    %rbp,%rsi
xor    %edx,%edx
mov    %rax,%rcx
call   1040 <glGetProgramInfoLog@plt>
mov    0x2db4(%rip),%rax
mov    (%rax),%edi
mov    (%r15),%ecx
lea    0xde0(%rip),%rsi
mov    $0x44,%edx
mov    %r14,%r8
call   1070 <fprintf@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %ebx,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@GL_LINK_STATUS = global i32 0
@GL_FALSE = global i64 0
@GL_INFO_LOG_LENGTH = global i32 0
@stderr = global i32 0
@.str = [12 x i8] c"%d: %d, %s\0A\00"
define i32 @CreateProgram(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i64
%7 = alloca i64
%8 = alloca i8*
store i32 %0, i32* %3
store i32 %1, i32* %4
%9 = call i32 (...) @glCreateProgram()
store i32 %9, i32* %5
%10 = load i32, i32* %5
%11 = load i32, i32* %3
%12 = call i32 @glAttachShader(i32 %10, i32 %11)
%13 = load i32, i32* %5
%14 = load i32, i32* %4
%15 = call i32 @glAttachShader(i32 %13, i32 %14)
%16 = load i32, i32* %5
%17 = call i32 @glLinkProgram(i32 %16)
%18 = load i32, i32* %5
%19 = load i32, i32* @GL_LINK_STATUS
%20 = call i32 @glGetProgramiv(i32 %18, i32 %19, i64* %6)
%21 = load i64, i64* @GL_FALSE
%22 = load i64, i64* %6
%23 = icmp eq i64 %21, %22
br i1 %23, label %24, label %41
24: ; preds = %2
%25 = load i32, i32* %5
%26 = load i32, i32* @GL_INFO_LOG_LENGTH
%27 = call i32 @glGetProgramiv(i32 %25, i32 %26, i64* %7)
%28 = load i64, i64* %7
%29 = mul i64 %28, 1
%30 = call i8* @malloc(i64 %29)
store i8* %30, i8** %8
%31 = load i32, i32* %5
%32 = load i64, i64* %7
%33 = load i8*, i8** %8
%34 = call i32 @glGetProgramInfoLog(i32 %31, i64 %32, i32* null, i8* %33)
%35 = load i32, i32* @stderr
%36 = load i32, i32* @GL_LINK_STATUS
%37 = load i8*, i8** %8
%38 = call i32 @fprintf(i32 %35, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 68, i32 %36, i8* %37)
%39 = load i8*, i8** %8
%40 = call i32 @free(i8* %39)
br label %41
41: ; preds = %24, %2
%42 = load i32, i32* %5
ret i32 %42
}

LLVM IR (-O2):
@GL_LINK_STATUS = global i32 0
@GL_FALSE = global i64 0
@GL_INFO_LOG_LENGTH = global i32 0
@stderr = global i32 0
@.str = [12 x i8] c"%d: %d, %s\0A\00"
define i32 @CreateProgram(i32 %0, i32 %1) {
%3 = alloca i64
%4 = alloca i64
%5 = tail call i32 (...) @glCreateProgram()
%6 = tail call i32 @glAttachShader(i32 %5, i32 %0)
%7 = tail call i32 @glAttachShader(i32 %5, i32 %1)
%8 = tail call i32 @glLinkProgram(i32 %5)
%9 = bitcast i64* %3 to i8*
%10 = load i32, i32* @GL_LINK_STATUS
%11 = call i32 @glGetProgramiv(i32 %5, i32 %10, i64* %3)
%12 = load i64, i64* @GL_FALSE
%13 = load i64, i64* %3
%14 = icmp eq i64 %12, %13
br i1 %14, label %15, label %26
15: ; preds = %2
%16 = bitcast i64* %4 to i8*
%17 = load i32, i32* @GL_INFO_LOG_LENGTH
%18 = call i32 @glGetProgramiv(i32 %5, i32 %17, i64* %4)
%19 = load i64, i64* %4
%20 = call i8* @malloc(i64 %19)
%21 = call i32 @glGetProgramInfoLog(i32 %5, i64 %19, i32* null, i8* %20)
%22 = load i32, i32* @stderr
%23 = load i32, i32* @GL_LINK_STATUS
%24 = call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 68, i32 %23, i8* %20)
%25 = call i32 @free(i8* %20)
br label %26
26: ; preds = %15, %2
ret i32 %5
}