#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*/ error;
struct TYPE_3__ {
  scalar_t__ error_code;
  int request_code;
};
typedef TYPE_1__ XErrorEvent;
typedef int /*<<< orphan*/ Display;

/* Variables and functions */
scalar_t__ BadAccess;
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ XGetErrorText(int /*<<< orphan*/ *, scalar_t__, char *, int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ stderr;
int xc_handle_error(Display *display, XErrorEvent *event) {
  char error[1024];
  XGetErrorText(display, event->error_code, error, sizeof(error));
  fprintf(stderr, "error: (X) %s\n", error);
  if (event->error_code == BadAccess && event->request_code == 33) {
    fprintf(stderr, "A key is already grabbed by another application "
                    "(most likely your wm/DE).\n");
  }
  fflush(stderr);
  exit(EXIT_FAILURE);
}


x86 assembly (clang, -O0):
<xc_handle_error>:
push   %rbp
mov    %rsp,%rbp
sub    $0x410,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    -0x410(%rbp),%rdx
mov    $0x400,%ecx
call   1050 <XGetErrorText@plt>
mov    0x2e6a(%rip),%rax
mov    (%rax),%edi
lea    -0x410(%rbp),%rdx
lea    0xe7a(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    0x2e3d(%rip),%rcx
cmp    (%rcx),%rax
jne    11c9 <xc_handle_error+0x89>
mov    -0x10(%rbp),%rax
cmpl   $0x21,0x8(%rax)
jne    11c9 <xc_handle_error+0x89>
mov    0x2e27(%rip),%rax
mov    (%rax),%edi
lea    0xe4d(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    0x2e10(%rip),%rax
mov    (%rax),%edi
call   1040 <fflush@plt>
mov    0x2df2(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<xc_handle_error>:
push   %r15
push   %r14
push   %rbx
sub    $0x400,%rsp
mov    %rsi,%rbx
mov    (%rsi),%rsi
mov    %rsp,%r14
mov    %r14,%rdx
mov    $0x400,%ecx
call   1050 <XGetErrorText@plt>
mov    0x2e77(%rip),%r15
mov    (%r15),%edi
lea    0xe8d(%rip),%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    (%rbx),%rax
mov    0x2e51(%rip),%rcx
cmp    (%rcx),%rax
jne    11a3 <xc_handle_error+0x63>
cmpl   $0x21,0x8(%rbx)
jne    11a3 <xc_handle_error+0x63>
mov    (%r15),%edi
lea    0xe73(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    (%r15),%edi
call   1040 <fflush@plt>
mov    0x2e1e(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

LLVM IR (-O0):
%struct.TYPE_3__ = type { i64, i32 }
@stderr = global i32 0
@.str = [15 x i8] c"error: (X) %s\0A\00"
@BadAccess = global i64 0
@.str.1 = [75 x i8] c"A key is already grabbed by another application (most likely your wm/DE).\0A\00"
@EXIT_FAILURE = global i32 0
define i32 @xc_handle_error(i32* %0, %struct.TYPE_3__* %1) {
%3 = alloca i32*
%4 = alloca %struct.TYPE_3__*
%5 = alloca [1024 x i8]
store i32* %0, i32** %3
store %struct.TYPE_3__* %1, %struct.TYPE_3__** %4
%6 = load i32*, i32** %3
%7 = load %struct.TYPE_3__*, %struct.TYPE_3__** %4
%8 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %7, i32 0, i32 0
%9 = load i64, i64* %8
%10 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%11 = call i32 @XGetErrorText(i32* %6, i64 %9, i8* %10, i32 1024)
%12 = load i32, i32* @stderr
%13 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%14 = call i32 (i32, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %13)
%15 = load %struct.TYPE_3__*, %struct.TYPE_3__** %4
%16 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %15, i32 0, i32 0
%17 = load i64, i64* %16
%18 = load i64, i64* @BadAccess
%19 = icmp eq i64 %17, %18
br i1 %19, label %20, label %28
20: ; preds = %2
%21 = load %struct.TYPE_3__*, %struct.TYPE_3__** %4
%22 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %21, i32 0, i32 1
%23 = load i32, i32* %22
%24 = icmp eq i32 %23, 33
br i1 %24, label %25, label %28
25: ; preds = %20
%26 = load i32, i32* @stderr
%27 = call i32 (i32, i8*, ...) @fprintf(i32 %26, i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str.1, i64 0, i64 0))
br label %28
28: ; preds = %25, %20, %2
%29 = load i32, i32* @stderr
%30 = call i32 @fflush(i32 %29)
%31 = load i32, i32* @EXIT_FAILURE
%32 = call i32 @exit(i32 %31)
unreachable
}

LLVM IR (-O2):
%struct.TYPE_3__ = type { i64, i32 }
@stderr = global i32 0
@.str = [15 x i8] c"error: (X) %s\0A\00"
@BadAccess = global i64 0
@.str.1 = [75 x i8] c"A key is already grabbed by another application (most likely your wm/DE).\0A\00"
@EXIT_FAILURE = global i32 0
define i32 @xc_handle_error(i32* %0, %struct.TYPE_3__* nocapture %1) {
%3 = alloca [1024 x i8]
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%5 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %1, i64 0, i32 0
%6 = load i64, i64* %5
%7 = call i32 @XGetErrorText(i32* %0, i64 %6, i8* %4, i32 1024)
%8 = load i32, i32* @stderr
%9 = call i32 (i32, i8*, ...) @fprintf(i32 %8, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %4)
%10 = load i64, i64* %5
%11 = load i64, i64* @BadAccess
%12 = icmp eq i64 %10, %11
br i1 %12, label %13, label %20
13: ; preds = %2
%14 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %1, i64 0, i32 1
%15 = load i32, i32* %14
%16 = icmp eq i32 %15, 33
br i1 %16, label %17, label %20
17: ; preds = %13
%18 = load i32, i32* @stderr
%19 = call i32 (i32, i8*, ...) @fprintf(i32 %18, i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str.1, i64 0, i64 0))
br label %20
20: ; preds = %17, %13, %2
%21 = load i32, i32* @stderr
%22 = call i32 @fflush(i32 %21)
%23 = load i32, i32* @EXIT_FAILURE
%24 = call i32 @exit(i32 %23)
unreachable
}