#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 scalar_t__ GLenum;

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
scalar_t__ GL_NO_ERROR;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int, char *);
scalar_t__ glGetError();
char *gluErrorString(scalar_t__);
int /*<<< orphan*/ stderr;
void trap_opengl_errors(void) {
  GLenum gl_error_code = glGetError();
  if (gl_error_code != GL_NO_ERROR) {
    fprintf(stderr,
            "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
            "2022-01-22/02-19-57/repos/asfadmin/ASF_MapReady/refs/heads/devel/"
            "src/ssv/test_mesa_glut.c"
            " line %d: OpenGL error detected: %s",
            42, gluErrorString(gl_error_code));
    exit(EXIT_FAILURE);
  }
}


x86 assembly (clang, -O0):
<trap_opengl_errors>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1040 <glGetError@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    0x2e8a(%rip),%rcx
cmp    (%rcx),%rax
je     11a1 <trap_opengl_errors+0x61>
mov    0x2e6a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <gluErrorString@plt>
mov    -0xc(%rbp),%edi
mov    %rax,%rcx
lea    0xe77(%rip),%rsi
mov    $0x2a,%edx
call   1030 <fprintf@plt>
mov    0x2e36(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<trap_opengl_errors>:
push   %rbx
xor    %eax,%eax
call   1040 <glGetError@plt>
mov    0x2e99(%rip),%rcx
cmp    (%rcx),%rax
jne    1156 <trap_opengl_errors+0x16>
pop    %rbx
ret
mov    0x2e7b(%rip),%rcx
mov    (%rcx),%ebx
mov    %rax,%rdi
call   1050 <gluErrorString@plt>
lea    0xe92(%rip),%rsi
mov    %ebx,%edi
mov    $0x2a,%edx
mov    %rax,%rcx
call   1030 <fprintf@plt>
mov    0x2e4c(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@GL_NO_ERROR = global i64 0
@stderr = global i32 0
@.str = [189 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/asfadmin/ASF_MapReady/refs/heads/devel/src/ssv/test_mesa_glut.c line %d: OpenGL error detected: %s\00"
@EXIT_FAILURE = global i32 0
define void @trap_opengl_errors() {
%1 = alloca i64
%2 = call i64 (...) @glGetError()
store i64 %2, i64* %1
%3 = load i64, i64* %1
%4 = load i64, i64* @GL_NO_ERROR
%5 = icmp ne i64 %3, %4
br i1 %5, label %6, label %13
6: ; preds = %0
%7 = load i32, i32* @stderr
%8 = load i64, i64* %1
%9 = call i8* @gluErrorString(i64 %8)
%10 = call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([189 x i8], [189 x i8]* @.str, i64 0, i64 0), i32 42, i8* %9)
%11 = load i32, i32* @EXIT_FAILURE
%12 = call i32 @exit(i32 %11)
unreachable
13: ; preds = %0
ret void
}

LLVM IR (-O2):
@GL_NO_ERROR = global i64 0
@stderr = global i32 0
@.str = [189 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/asfadmin/ASF_MapReady/refs/heads/devel/src/ssv/test_mesa_glut.c line %d: OpenGL error detected: %s\00"
@EXIT_FAILURE = global i32 0
define void @trap_opengl_errors() {
%1 = tail call i64 (...) @glGetError()
%2 = load i64, i64* @GL_NO_ERROR
%3 = icmp eq i64 %1, %2
br i1 %3, label %10, label %4
4: ; preds = %0
%5 = load i32, i32* @stderr
%6 = tail call i8* @gluErrorString(i64 %1)
%7 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([189 x i8], [189 x i8]* @.str, i64 0, i64 0), i32 42, i8* %6)
%8 = load i32, i32* @EXIT_FAILURE
%9 = tail call i32 @exit(i32 %8)
unreachable
10: ; preds = %0
ret void
}