#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 */
typedef struct TYPE_3__ TYPE_1__;

/* Type definitions */
typedef int /*<<< orphan*/ mess;
struct TYPE_3__ {
  int error_code;
};
typedef TYPE_1__ XErrorEvent;
typedef int /*<<< orphan*/ Display;

/* Variables and functions */
int /*<<< orphan*/ XGetErrorText(int /*<<< orphan*/ *, int, char *, int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, int);
int /*<<< orphan*/ stderr;
int error_handler(Display *dpy, XErrorEvent *ev) {
  if (ev->error_code == 3) {
    return 0;
  }
  char mess[128];
  XGetErrorText(dpy, ev->error_code, mess, sizeof(mess));
  fprintf(stderr, "X11 Error: %s (error code: %d).\n", mess, ev->error_code);
  exit(ev->error_code);
  return ev->error_code;
}


x86 assembly (clang, -O0):
<error_handler>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmpl   $0x3,(%rax)
jne    115b <error_handler+0x2b>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbp
ret
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%esi
lea    -0x90(%rbp),%rdx
mov    $0x80,%ecx
call   1040 <XGetErrorText@plt>
mov    0x2e63(%rip),%rax
mov    (%rax),%edi
lea    -0x90(%rbp),%rdx
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
lea    0xe6d(%rip),%rsi
call   1030 <fprintf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%edi
call   1050 <exit@plt>

x86 assembly (clang, -O2):
<error_handler>:
push   %r14
push   %rbx
sub    $0x88,%rsp
mov    %rsi,%rbx
mov    (%rsi),%esi
cmp    $0x3,%esi
jne    1151 <error_handler+0x21>
xor    %eax,%eax
add    $0x88,%rsp
pop    %rbx
pop    %r14
ret
mov    %rsp,%r14
mov    %r14,%rdx
mov    $0x80,%ecx
call   1040 <XGetErrorText@plt>
mov    0x2e78(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%ecx
lea    0xe8d(%rip),%rsi
mov    %r14,%rdx
call   1030 <fprintf@plt>
mov    (%rbx),%edi
call   1050 <exit@plt>

LLVM IR (-O0):
%struct.TYPE_3__ = type { i32 }
@stderr = global i32 0
@.str = [33 x i8] c"X11 Error: %s (error code: %d).\0A\00"
define i32 @error_handler(i32* %0, %struct.TYPE_3__* %1) {
%3 = alloca i32*
%4 = alloca %struct.TYPE_3__*
%5 = alloca [128 x i8]
store i32* %0, i32** %3
store %struct.TYPE_3__* %1, %struct.TYPE_3__** %4
%6 = load %struct.TYPE_3__*, %struct.TYPE_3__** %4
%7 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %6, i32 0, i32 0
%8 = load i32, i32* %7
%9 = icmp eq i32 %8, 3
br i1 %9, label %10, label %11
10: ; preds = %2
ret i32 0
11: ; preds = %2
%12 = load i32*, i32** %3
%13 = load %struct.TYPE_3__*, %struct.TYPE_3__** %4
%14 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %13, i32 0, i32 0
%15 = load i32, i32* %14
%16 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%17 = call i32 @XGetErrorText(i32* %12, i32 %15, i8* %16, i32 128)
%18 = load i32, i32* @stderr
%19 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%20 = load %struct.TYPE_3__*, %struct.TYPE_3__** %4
%21 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %20, i32 0, i32 0
%22 = load i32, i32* %21
%23 = call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* %19, i32 %22)
%24 = load %struct.TYPE_3__*, %struct.TYPE_3__** %4
%25 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %24, i32 0, i32 0
%26 = load i32, i32* %25
%27 = call i32 @exit(i32 %26)
unreachable
}

LLVM IR (-O2):
%struct.TYPE_3__ = type { i32 }
@stderr = global i32 0
@.str = [33 x i8] c"X11 Error: %s (error code: %d).\0A\00"
define i32 @error_handler(i32* %0, %struct.TYPE_3__* nocapture %1) {
%3 = alloca [128 x i8]
%4 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %1, i64 0, i32 0
%5 = load i32, i32* %4
%6 = icmp eq i32 %5, 3
br i1 %6, label %7, label %8
7: ; preds = %2
ret i32 0
8: ; preds = %2
%9 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%10 = call i32 @XGetErrorText(i32* %0, i32 %5, i8* %9, i32 128)
%11 = load i32, i32* @stderr
%12 = load i32, i32* %4
%13 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* %9, i32 %12)
%14 = load i32, i32* %4
%15 = call i32 @exit(i32 %14)
unreachable
}