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

/* Variables and functions */
char *ErrorString(int /*<<< orphan*/);
int /*<<< orphan*/ GL_NO_ERROR;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *, int,
                           char *);
int /*<<< orphan*/ glGetError();
int /*<<< orphan*/ stderr;
void _CheckError(const char *file, int line) {
  GLenum error = glGetError();
  do {
    fprintf(stderr, "[%s:%d] %s\n", file, line, ErrorString(error));
  } while ((error = glGetError()) != GL_NO_ERROR);
}


x86 assembly (clang, -O0):
<_CheckError>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    $0x0,%al
call   1050 <glGetError@plt>
mov    %eax,-0x10(%rbp)
mov    0x2e88(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%edi
call   1030 <ErrorString@plt>
mov    -0x24(%rbp),%edi
mov    -0x20(%rbp),%rdx
mov    -0x14(%rbp),%ecx
mov    %rax,%r8
lea    0xe81(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x0,%al
call   1050 <glGetError@plt>
mov    %eax,-0x10(%rbp)
mov    0x2e53(%rip),%rcx
cmp    (%rcx),%eax
jne    1149 <_CheckError+0x19>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_CheckError>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%r15d
mov    %rdi,%rbx
xor    %eax,%eax
call   1050 <glGetError@plt>
mov    0x2e89(%rip),%r12
lea    0xeaa(%rip),%r14
mov    0x2e8b(%rip),%r13
nopl   (%rax)
mov    (%r12),%ebp
mov    %eax,%edi
call   1030 <ErrorString@plt>
mov    %ebp,%edi
mov    %r14,%rsi
mov    %rbx,%rdx
mov    %r15d,%ecx
mov    %rax,%r8
call   1040 <fprintf@plt>
xor    %eax,%eax
call   1050 <glGetError@plt>
cmp    0x0(%r13),%eax
jne    1160 <_CheckError+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [12 x i8] c"[%s:%d] %s\0A\00"
@GL_NO_ERROR = global i32 0
define void @_CheckError(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%6 = call i32 (...) @glGetError()
store i32 %6, i32* %5
br label %7
7: ; preds = %14, %2
%8 = load i32, i32* @stderr
%9 = load i8*, i8** %3
%10 = load i32, i32* %4
%11 = load i32, i32* %5
%12 = call i8* @ErrorString(i32 %11)
%13 = call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %9, i32 %10, i8* %12)
br label %14
14: ; preds = %7
%15 = call i32 (...) @glGetError()
store i32 %15, i32* %5
%16 = load i32, i32* @GL_NO_ERROR
%17 = icmp ne i32 %15, %16
br i1 %17, label %7, label %18
18: ; preds = %14
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [12 x i8] c"[%s:%d] %s\0A\00"
@GL_NO_ERROR = global i32 0
define void @_CheckError(i8* %0, i32 %1) {
%3 = tail call i32 (...) @glGetError()
br label %4
4: ; preds = %4, %2
%5 = phi i32 [ %3, %2 ], [ %9, %4 ]
%6 = load i32, i32* @stderr
%7 = tail call i8* @ErrorString(i32 %5)
%8 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %0, i32 %1, i8* %7)
%9 = tail call i32 (...) @glGetError()
%10 = load i32, i32* @GL_NO_ERROR
%11 = icmp eq i32 %9, %10
br i1 %11, label %12, label %4
12: ; preds = %4
ret void
}