#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 char GLchar;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ glad_glGetShaderInfoLog(int /*<<< orphan*/, scalar_t__,
                                           int /*<<< orphan*/, char *);
int /*<<< orphan*/ glad_glGetShaderiv(int /*<<< orphan*/, int, scalar_t__ *);
char *malloc(scalar_t__);
int /*<<< orphan*/ stderr;
void check_last_compile_error(GLuint id) {
  GLint compileStatus;
  glad_glGetShaderiv(id, 0x8B81, &compileStatus);
  if (compileStatus == 0) {
    GLint logLength;
    glad_glGetShaderiv(id, 0x8B84, &logLength);
    if (logLength != 0) {
      GLchar *buf = malloc(logLength * sizeof(GLchar));
      glad_glGetShaderInfoLog(id, logLength, 0, buf);
      fprintf(stderr, "Shader error: %s", buf);
      free(buf);
    }
  }
}


x86 assembly (clang, -O0):
<check_last_compile_error>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
mov    $0x8b81,%esi
lea    -0x10(%rbp),%rdx
call   1060 <glad_glGetShaderiv@plt>
cmpq   $0x0,-0x10(%rbp)
jne    11dd <check_last_compile_error+0x8d>
mov    -0x4(%rbp),%edi
mov    $0x8b84,%esi
lea    -0x18(%rbp),%rdx
call   1060 <glad_glGetShaderiv@plt>
cmpq   $0x0,-0x18(%rbp)
je     11d8 <check_last_compile_error+0x88>
mov    -0x18(%rbp),%rdi
shl    $0x0,%rdi
call   1050 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rcx
xor    %edx,%edx
call   1070 <glad_glGetShaderInfoLog@plt>
mov    0x2e23(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rdx
lea    0xe36(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
jmp    11dd <check_last_compile_error+0x8d>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_last_compile_error>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %edi,%ebx
lea    0x8(%rsp),%rdx
mov    $0x8b81,%esi
call   1060 <glad_glGetShaderiv@plt>
cmpq   $0x0,0x8(%rsp)
jne    11c4 <check_last_compile_error+0x74>
mov    %rsp,%rdx
mov    %ebx,%edi
mov    $0x8b84,%esi
call   1060 <glad_glGetShaderiv@plt>
mov    (%rsp),%r14
test   %r14,%r14
je     11c4 <check_last_compile_error+0x74>
mov    %r14,%rdi
call   1050 <malloc@plt>
mov    %rax,%r15
mov    %ebx,%edi
mov    %r14,%rsi
xor    %edx,%edx
mov    %rax,%rcx
call   1070 <glad_glGetShaderInfoLog@plt>
mov    0x2e35(%rip),%rax
mov    (%rax),%edi
lea    0xe4c(%rip),%rsi
mov    %r15,%rdx
call   1040 <fprintf@plt>
mov    %r15,%rdi
call   1030 <free@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [17 x i8] c"Shader error: %s\00"
define void @check_last_compile_error(i32 %0) {
%2 = alloca i32
%3 = alloca i64
%4 = alloca i64
%5 = alloca i8*
store i32 %0, i32* %2
%6 = load i32, i32* %2
%7 = call i32 @glad_glGetShaderiv(i32 %6, i32 35713, i64* %3)
%8 = load i64, i64* %3
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %29
10: ; preds = %1
%11 = load i32, i32* %2
%12 = call i32 @glad_glGetShaderiv(i32 %11, i32 35716, i64* %4)
%13 = load i64, i64* %4
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %28
15: ; preds = %10
%16 = load i64, i64* %4
%17 = mul i64 %16, 1
%18 = call i8* @malloc(i64 %17)
store i8* %18, i8** %5
%19 = load i32, i32* %2
%20 = load i64, i64* %4
%21 = load i8*, i8** %5
%22 = call i32 @glad_glGetShaderInfoLog(i32 %19, i64 %20, i32 0, i8* %21)
%23 = load i32, i32* @stderr
%24 = load i8*, i8** %5
%25 = call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %24)
%26 = load i8*, i8** %5
%27 = call i32 @free(i8* %26)
br label %28
28: ; preds = %15, %10
br label %29
29: ; preds = %28, %1
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [17 x i8] c"Shader error: %s\00"
define void @check_last_compile_error(i32 %0) {
%2 = alloca i64
%3 = alloca i64
%4 = bitcast i64* %2 to i8*
%5 = call i32 @glad_glGetShaderiv(i32 %0, i32 35713, i64* %2)
%6 = load i64, i64* %2
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %20
8: ; preds = %1
%9 = bitcast i64* %3 to i8*
%10 = call i32 @glad_glGetShaderiv(i32 %0, i32 35716, i64* %3)
%11 = load i64, i64* %3
%12 = icmp eq i64 %11, 0
br i1 %12, label %19, label %13
13: ; preds = %8
%14 = call i8* @malloc(i64 %11)
%15 = call i32 @glad_glGetShaderInfoLog(i32 %0, i64 %11, i32 0, i8* %14)
%16 = load i32, i32* @stderr
%17 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %14)
%18 = call i32 @free(i8* %14)
br label %19
19: ; preds = %13, %8
br label %20
20: ; preds = %19, %1
ret void
}