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

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ glutExit();
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ vfprintf(int /*<<< orphan*/, char const *,
                            int /*<<< orphan*/);
void myError(const char *fmt, va_list ap) {
  fprintf(stderr, "myError: Entering user defined error handler\n");
  fprintf(stderr, "myError:");
  vfprintf(stderr, fmt, ap);
  fprintf(stderr, "\n");
  fprintf(stderr, "myError: Calling glutExit()\n");
  glutExit();
  fprintf(stderr, "myError: Exit-ing handler routine\n");
  exit(1);
}


x86 assembly (clang, -O0):
<myError>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    0x2e8a(%rip),%rax
mov    (%rax),%edi
lea    0xea1(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2e75(%rip),%rax
mov    (%rax),%edi
lea    0xeba(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2e60(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rsi
mov    -0xc(%rbp),%edx
call   1050 <vfprintf@plt>
mov    0x2e4b(%rip),%rax
mov    (%rax),%edi
lea    0xeb4(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2e36(%rip),%rax
mov    (%rax),%edi
lea    0xe84(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x0,%al
call   1040 <glutExit@plt>
mov    0x2e1a(%rip),%rax
mov    (%rax),%edi
lea    0xe85(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<myError>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%r14d
mov    %rdi,%rbx
mov    0x2e8f(%rip),%rbp
mov    0x0(%rbp),%edi
lea    0xea5(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0xec4(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x0(%rbp),%edi
mov    %rbx,%rsi
mov    %r14d,%edx
call   1050 <vfprintf@plt>
mov    0x0(%rbp),%edi
lea    0xecb(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0xea1(%rip),%rsi
call   1030 <fprintf@plt>
xor    %eax,%eax
call   1040 <glutExit@plt>
mov    0x0(%rbp),%edi
lea    0xea8(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [46 x i8] c"myError: Entering user defined error handler\0A\00"
@.str.1 = [9 x i8] c"myError:\00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [29 x i8] c"myError: Calling glutExit()\0A\00"
@.str.4 = [35 x i8] c"myError: Exit-ing handler routine\0A\00"
define void @myError(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%5 = load i32, i32* @stderr
%6 = call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0))
%7 = load i32, i32* @stderr
%8 = call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%9 = load i32, i32* @stderr
%10 = load i8*, i8** %3
%11 = load i32, i32* %4
%12 = call i32 @vfprintf(i32 %9, i8* %10, i32 %11)
%13 = load i32, i32* @stderr
%14 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%15 = load i32, i32* @stderr
%16 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0))
%17 = call i32 (...) @glutExit()
%18 = load i32, i32* @stderr
%19 = call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.4, i64 0, i64 0))
%20 = call i32 @exit(i32 1)
unreachable
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [46 x i8] c"myError: Entering user defined error handler\0A\00"
@.str.1 = [9 x i8] c"myError:\00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [29 x i8] c"myError: Calling glutExit()\0A\00"
@.str.4 = [35 x i8] c"myError: Exit-ing handler routine\0A\00"
define void @myError(i8* %0, i32 %1) {
%3 = load i32, i32* @stderr
%4 = tail call i32 @fprintf(i32 %3, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0))
%5 = load i32, i32* @stderr
%6 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%7 = load i32, i32* @stderr
%8 = tail call i32 @vfprintf(i32 %7, i8* %0, i32 %1)
%9 = load i32, i32* @stderr
%10 = tail call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%11 = load i32, i32* @stderr
%12 = tail call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0))
%13 = tail call i32 (...) @glutExit()
%14 = load i32, i32* @stderr
%15 = tail call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.4, i64 0, i64 0))
%16 = tail call i32 @exit(i32 1)
unreachable
}