#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;
typedef int /*<<< orphan*/ GLenum;
typedef int /*<<< orphan*/ GLchar;

/* Variables and functions */
int GL_COMPILE_STATUS;
scalar_t__ GL_FALSE;
int GL_INFO_LOG_LENGTH;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int, int, char *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ glCompileShader(int /*<<< orphan*/);
int /*<<< orphan*/ glCreateShader(int /*<<< orphan*/);
int /*<<< orphan*/ glGetShaderInfoLog(int /*<<< orphan*/, scalar_t__,
                                      int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ glGetShaderiv(int /*<<< orphan*/, int, scalar_t__ *);
int /*<<< orphan*/ glShaderSource(int /*<<< orphan*/, int,
                                  int /*<<< orphan*/ const **,
                                  int /*<<< orphan*/ *);
char *malloc(scalar_t__);
int /*<<< orphan*/ stderr;
GLuint CreateShader(GLenum shaderType, const char *shaderSource) {
  GLuint shader = glCreateShader(shaderType);
  glShaderSource(shader, 1, (const GLchar **)&shaderSource, NULL);
  glCompileShader(shader);
  {
    GLint status;
    glGetShaderiv(shader, GL_COMPILE_STATUS, &status);
    if (GL_FALSE == status) {
      GLint logLength;
      glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &logLength);
      char *infoLog = malloc(logLength * sizeof(char));
      glGetShaderInfoLog(shader, logLength, NULL, infoLog);
      fprintf(stderr, "%d: %d, %s\n", 58, GL_COMPILE_STATUS, infoLog);
      free(infoLog);
    }
  };
  return shader;
}


x86 assembly (clang, -O0):
<CreateShader>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%edi
call   1090 <glCreateShader@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x10(%rbp),%rdx
mov    $0x1,%esi
xor    %eax,%eax
mov    %eax,%ecx
call   1050 <glShaderSource@plt>
mov    -0x14(%rbp),%edi
call   1070 <glCompileShader@plt>
mov    -0x14(%rbp),%edi
mov    0x2e07(%rip),%rax
mov    (%rax),%esi
lea    -0x20(%rbp),%rdx
call   1040 <glGetShaderiv@plt>
mov    0x2e0d(%rip),%rax
mov    (%rax),%rax
cmp    -0x20(%rbp),%rax
jne    124a <CreateShader+0xca>
mov    -0x14(%rbp),%edi
mov    0x2e06(%rip),%rax
mov    (%rax),%esi
lea    -0x28(%rbp),%rdx
call   1040 <glGetShaderiv@plt>
mov    -0x28(%rbp),%rdi
shl    $0x0,%rdi
call   1080 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x28(%rbp),%rsi
mov    -0x30(%rbp),%rcx
xor    %eax,%eax
mov    %eax,%edx
call   10a0 <glGetShaderInfoLog@plt>
mov    0x2daf(%rip),%rax
mov    (%rax),%edi
mov    0x2d9e(%rip),%rax
mov    (%rax),%ecx
mov    -0x30(%rbp),%r8
lea    0xdc9(%rip),%rsi
mov    $0x3a,%edx
call   1060 <fprintf@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    -0x14(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CreateShader>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,0x10(%rsp)
call   1090 <glCreateShader@plt>
mov    %eax,%ebx
lea    0x10(%rsp),%rdx
mov    %eax,%edi
mov    $0x1,%esi
xor    %ecx,%ecx
call   1050 <glShaderSource@plt>
mov    %ebx,%edi
call   1070 <glCompileShader@plt>
mov    0x2e10(%rip),%r12
mov    (%r12),%esi
lea    0x8(%rsp),%rdx
mov    %ebx,%edi
call   1040 <glGetShaderiv@plt>
mov    0x2e11(%rip),%rax
mov    (%rax),%rax
cmp    0x8(%rsp),%rax
jne    1233 <CreateShader+0xb3>
mov    0x2e10(%rip),%rax
mov    (%rax),%esi
mov    %rsp,%rdx
mov    %ebx,%edi
call   1040 <glGetShaderiv@plt>
mov    (%rsp),%r14
mov    %r14,%rdi
call   1080 <malloc@plt>
mov    %rax,%r15
mov    %ebx,%edi
mov    %r14,%rsi
xor    %edx,%edx
mov    %rax,%rcx
call   10a0 <glGetShaderInfoLog@plt>
mov    0x2dbf(%rip),%rax
mov    (%rax),%edi
mov    (%r12),%ecx
lea    0xde2(%rip),%rsi
mov    $0x3a,%edx
mov    %r15,%r8
call   1060 <fprintf@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %ebx,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@GL_COMPILE_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 @CreateShader(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i64
%7 = alloca i64
%8 = alloca i8*
store i32 %0, i32* %3
store i8* %1, i8** %4
%9 = load i32, i32* %3
%10 = call i32 @glCreateShader(i32 %9)
store i32 %10, i32* %5
%11 = load i32, i32* %5
%12 = bitcast i8** %4 to i32**
%13 = call i32 @glShaderSource(i32 %11, i32 1, i32** %12, i32* null)
%14 = load i32, i32* %5
%15 = call i32 @glCompileShader(i32 %14)
%16 = load i32, i32* %5
%17 = load i32, i32* @GL_COMPILE_STATUS
%18 = call i32 @glGetShaderiv(i32 %16, i32 %17, i64* %6)
%19 = load i64, i64* @GL_FALSE
%20 = load i64, i64* %6
%21 = icmp eq i64 %19, %20
br i1 %21, label %22, label %39
22: ; preds = %2
%23 = load i32, i32* %5
%24 = load i32, i32* @GL_INFO_LOG_LENGTH
%25 = call i32 @glGetShaderiv(i32 %23, i32 %24, i64* %7)
%26 = load i64, i64* %7
%27 = mul i64 %26, 1
%28 = call i8* @malloc(i64 %27)
store i8* %28, i8** %8
%29 = load i32, i32* %5
%30 = load i64, i64* %7
%31 = load i8*, i8** %8
%32 = call i32 @glGetShaderInfoLog(i32 %29, i64 %30, i32* null, i8* %31)
%33 = load i32, i32* @stderr
%34 = load i32, i32* @GL_COMPILE_STATUS
%35 = load i8*, i8** %8
%36 = call i32 @fprintf(i32 %33, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 58, i32 %34, i8* %35)
%37 = load i8*, i8** %8
%38 = call i32 @free(i8* %37)
br label %39
39: ; preds = %22, %2
%40 = load i32, i32* %5
ret i32 %40
}

LLVM IR (-O2):
@GL_COMPILE_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 @CreateShader(i32 %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i64
store i8* %1, i8** %3
%6 = tail call i32 @glCreateShader(i32 %0)
%7 = bitcast i8** %3 to i32**
%8 = call i32 @glShaderSource(i32 %6, i32 1, i32** %7, i32* null)
%9 = call i32 @glCompileShader(i32 %6)
%10 = bitcast i64* %4 to i8*
%11 = load i32, i32* @GL_COMPILE_STATUS
%12 = call i32 @glGetShaderiv(i32 %6, i32 %11, i64* %4)
%13 = load i64, i64* @GL_FALSE
%14 = load i64, i64* %4
%15 = icmp eq i64 %13, %14
br i1 %15, label %16, label %27
16: ; preds = %2
%17 = bitcast i64* %5 to i8*
%18 = load i32, i32* @GL_INFO_LOG_LENGTH
%19 = call i32 @glGetShaderiv(i32 %6, i32 %18, i64* %5)
%20 = load i64, i64* %5
%21 = call i8* @malloc(i64 %20)
%22 = call i32 @glGetShaderInfoLog(i32 %6, i64 %20, i32* null, i8* %21)
%23 = load i32, i32* @stderr
%24 = load i32, i32* @GL_COMPILE_STATUS
%25 = call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 58, i32 %24, i8* %21)
%26 = call i32 @free(i8* %21)
br label %27
27: ; preds = %16, %2
ret i32 %6
}