#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 */
int /*<<< orphan*/ GL_NO_ERROR;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ glGetError();
scalar_t__ gluErrorString(int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
void checkErrors(void) {
  GLenum error;
  while ((error = glGetError()) != GL_NO_ERROR) {
    fprintf(stderr, "Error: %s\n", (char *)gluErrorString(error));
  }
}


x86 assembly (clang, -O0):
<checkErrors>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1040 <glGetError@plt>
mov    %eax,-0x4(%rbp)
mov    0x2e9f(%rip),%rcx
cmp    (%rcx),%eax
je     117c <checkErrors+0x4c>
mov    0x2e80(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%edi
call   1050 <gluErrorString@plt>
mov    -0x8(%rbp),%edi
mov    %rax,%rdx
lea    0xe8e(%rip),%rsi
call   1030 <fprintf@plt>
jmp    1138 <checkErrors+0x8>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<checkErrors>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1040 <glGetError@plt>
mov    0x2ea3(%rip),%r14
cmp    (%r14),%eax
je     1183 <checkErrors+0x53>
mov    0x2e87(%rip),%r15
lea    0xea8(%rip),%rbx
nopl   0x0(%rax,%rax,1)
mov    (%r15),%ebp
mov    %eax,%edi
call   1050 <gluErrorString@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %rax,%rdx
call   1030 <fprintf@plt>
xor    %eax,%eax
call   1040 <glGetError@plt>
cmp    (%r14),%eax
jne    1160 <checkErrors+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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