#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*/ GLint;

/* Variables and functions */
int /*<<< orphan*/ GL_INFO_LOG_LENGTH;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ glGetProgramInfoLog(int /*<<< orphan*/, int /*<<< orphan*/,
                                       int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ glGetProgramiv(int /*<<< orphan*/, int /*<<< orphan*/,
                                  int /*<<< orphan*/ *);
int /*<<< orphan*/ glGetShaderInfoLog(int /*<<< orphan*/, int /*<<< orphan*/,
                                      int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ glGetShaderiv(int /*<<< orphan*/, int /*<<< orphan*/,
                                 int /*<<< orphan*/ *);
scalar_t__ glIsProgram(int /*<<< orphan*/);
scalar_t__ glIsShader(int /*<<< orphan*/);
char *malloc(int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
void printlog(GLuint object) {
  GLint len = 0;
  char *log;
  if (glIsShader(object)) {
    glGetShaderiv(object, GL_INFO_LOG_LENGTH, &len);
  } else if (glIsProgram(object)) {
    glGetProgramiv(object, GL_INFO_LOG_LENGTH, &len);
  } else {
    fprintf(stderr, "error: not a shader or a program\n");
    return;
  }
  log = malloc(len);
  if (glIsShader(object))
    glGetShaderInfoLog(object, len, NULL, log);
  else if (glIsProgram(object))
    glGetProgramInfoLog(object, len, NULL, log);
  fprintf(stderr, "%s", log);
  free(log);
}


x86 assembly (clang, -O0):
<printlog>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x4(%rbp),%edi
call   10a0 <glIsShader@plt>
cmp    $0x0,%rax
je     11ce <printlog+0x3e>
mov    -0x4(%rbp),%edi
mov    0x2e32(%rip),%rax
mov    (%rax),%esi
lea    -0x8(%rbp),%rdx
call   1050 <glGetShaderiv@plt>
jmp    121b <printlog+0x8b>
mov    -0x4(%rbp),%edi
call   1090 <glIsProgram@plt>
cmp    $0x0,%rax
je     11fa <printlog+0x6a>
mov    -0x4(%rbp),%edi
mov    0x2e06(%rip),%rax
mov    (%rax),%esi
lea    -0x8(%rbp),%rdx
call   1060 <glGetProgramiv@plt>
jmp    1216 <printlog+0x86>
mov    0x2dd7(%rip),%rax
mov    (%rax),%edi
lea    0xdf6(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
jmp    129f <printlog+0x10f>
jmp    121b <printlog+0x8b>
mov    -0x8(%rbp),%edi
call   1080 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x4(%rbp),%edi
call   10a0 <glIsShader@plt>
cmp    $0x0,%rax
je     1251 <printlog+0xc1>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%rcx
xor    %eax,%eax
mov    %eax,%edx
call   10b0 <glGetShaderInfoLog@plt>
jmp    127b <printlog+0xeb>
mov    -0x4(%rbp),%edi
call   1090 <glIsProgram@plt>
cmp    $0x0,%rax
je     1276 <printlog+0xe6>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%rcx
xor    %eax,%eax
mov    %eax,%edx
call   1040 <glGetProgramInfoLog@plt>
jmp    127b <printlog+0xeb>
mov    0x2d56(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xd93(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printlog>:
push   %r14
push   %rbx
push   %rax
mov    %edi,%ebx
movl   $0x0,0x4(%rsp)
call   10a0 <glIsShader@plt>
test   %rax,%rax
je     11bf <printlog+0x2f>
mov    0x2e41(%rip),%rax
mov    (%rax),%esi
lea    0x4(%rsp),%rdx
mov    %ebx,%edi
call   1050 <glGetShaderiv@plt>
jmp    11e4 <printlog+0x54>
mov    %ebx,%edi
call   1090 <glIsProgram@plt>
test   %rax,%rax
je     1254 <printlog+0xc4>
mov    0x2e1a(%rip),%rax
mov    (%rax),%esi
lea    0x4(%rsp),%rdx
mov    %ebx,%edi
call   1060 <glGetProgramiv@plt>
mov    0x4(%rsp),%edi
call   1080 <malloc@plt>
mov    %rax,%r14
mov    %ebx,%edi
call   10a0 <glIsShader@plt>
test   %rax,%rax
je     120e <printlog+0x7e>
mov    0x4(%rsp),%esi
mov    %ebx,%edi
xor    %edx,%edx
mov    %r14,%rcx
call   10b0 <glGetShaderInfoLog@plt>
jmp    122a <printlog+0x9a>
mov    %ebx,%edi
call   1090 <glIsProgram@plt>
test   %rax,%rax
je     122a <printlog+0x9a>
mov    0x4(%rsp),%esi
mov    %ebx,%edi
xor    %edx,%edx
mov    %r14,%rcx
call   1040 <glGetProgramInfoLog@plt>
mov    0x2da7(%rip),%rax
mov    (%rax),%edi
lea    0xde8(%rip),%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    %r14,%rdi
call   1030 <free@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    0x2d7d(%rip),%rax
mov    (%rax),%edi
lea    0xd9c(%rip),%rsi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1070 <fprintf@plt>

LLVM IR (-O0):
@GL_INFO_LOG_LENGTH = global i32 0
@stderr = global i32 0
@.str = [34 x i8] c"error: not a shader or a program\0A\00"
@.str.1 = [3 x i8] c"%s\00"
define void @printlog(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8*
store i32 %0, i32* %2
store i32 0, i32* %3
%5 = load i32, i32* %2
%6 = call i64 @glIsShader(i32 %5)
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %12
8: ; preds = %1
%9 = load i32, i32* %2
%10 = load i32, i32* @GL_INFO_LOG_LENGTH
%11 = call i32 @glGetShaderiv(i32 %9, i32 %10, i32* %3)
br label %24
12: ; preds = %1
%13 = load i32, i32* %2
%14 = call i64 @glIsProgram(i32 %13)
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %20
16: ; preds = %12
%17 = load i32, i32* %2
%18 = load i32, i32* @GL_INFO_LOG_LENGTH
%19 = call i32 @glGetProgramiv(i32 %17, i32 %18, i32* %3)
br label %23
20: ; preds = %12
%21 = load i32, i32* @stderr
%22 = call i32 (i32, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
br label %51
23: ; preds = %16
br label %24
24: ; preds = %23, %8
%25 = load i32, i32* %3
%26 = call i8* @malloc(i32 %25)
store i8* %26, i8** %4
%27 = load i32, i32* %2
%28 = call i64 @glIsShader(i32 %27)
%29 = icmp ne i64 %28, 0
br i1 %29, label %30, label %35
30: ; preds = %24
%31 = load i32, i32* %2
%32 = load i32, i32* %3
%33 = load i8*, i8** %4
%34 = call i32 @glGetShaderInfoLog(i32 %31, i32 %32, i32* null, i8* %33)
br label %45
35: ; preds = %24
%36 = load i32, i32* %2
%37 = call i64 @glIsProgram(i32 %36)
%38 = icmp ne i64 %37, 0
br i1 %38, label %39, label %44
39: ; preds = %35
%40 = load i32, i32* %2
%41 = load i32, i32* %3
%42 = load i8*, i8** %4
%43 = call i32 @glGetProgramInfoLog(i32 %40, i32 %41, i32* null, i8* %42)
br label %44
44: ; preds = %39, %35
br label %45
45: ; preds = %44, %30
%46 = load i32, i32* @stderr
%47 = load i8*, i8** %4
%48 = call i32 (i32, i8*, ...) @fprintf(i32 %46, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %47)
%49 = load i8*, i8** %4
%50 = call i32 @free(i8* %49)
br label %51
51: ; preds = %45, %20
ret void
}

LLVM IR (-O2):
@GL_INFO_LOG_LENGTH = global i32 0
@stderr = global i32 0
@.str = [34 x i8] c"error: not a shader or a program\0A\00"
@.str.1 = [3 x i8] c"%s\00"
define void @printlog(i32 %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
store i32 0, i32* %2
%4 = tail call i64 @glIsShader(i32 %0)
%5 = icmp eq i64 %4, 0
br i1 %5, label %9, label %6
6: ; preds = %1
%7 = load i32, i32* @GL_INFO_LOG_LENGTH
%8 = call i32 @glGetShaderiv(i32 %0, i32 %7, i32* %2)
br label %18
9: ; preds = %1
%10 = tail call i64 @glIsProgram(i32 %0)
%11 = icmp eq i64 %10, 0
br i1 %11, label %15, label %12
12: ; preds = %9
%13 = load i32, i32* @GL_INFO_LOG_LENGTH
%14 = call i32 @glGetProgramiv(i32 %0, i32 %13, i32* %2)
br label %18
15: ; preds = %9
%16 = load i32, i32* @stderr
%17 = tail call i32 (i32, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
br label %36
18: ; preds = %12, %6
%19 = load i32, i32* %2
%20 = call i8* @malloc(i32 %19)
%21 = call i64 @glIsShader(i32 %0)
%22 = icmp eq i64 %21, 0
br i1 %22, label %26, label %23
23: ; preds = %18
%24 = load i32, i32* %2
%25 = call i32 @glGetShaderInfoLog(i32 %0, i32 %24, i32* null, i8* %20)
br label %32
26: ; preds = %18
%27 = call i64 @glIsProgram(i32 %0)
%28 = icmp eq i64 %27, 0
br i1 %28, label %32, label %29
29: ; preds = %26
%30 = load i32, i32* %2
%31 = call i32 @glGetProgramInfoLog(i32 %0, i32 %30, i32* null, i8* %20)
br label %32
32: ; preds = %26, %29, %23
%33 = load i32, i32* @stderr
%34 = call i32 (i32, i8*, ...) @fprintf(i32 %33, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %20)
%35 = call i32 @free(i8* %20)
br label %36
36: ; preds = %32, %15
ret void
}