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

/* Variables and functions */
int BadAccess;
int BadMatch;
int BadWindow;
int /*<<< orphan*/ XGetErrorText(int /*<<< orphan*/ *, int, char *, int);
int X_ConfigureWindow;
int X_GrabKey;
int X_SetInputFocus;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, int, int);
int /*<<< orphan*/ stderr;
int x11_extras_xerror(Display *dpy, XErrorEvent *ee) {
  char buffer[1000];
  XGetErrorText(dpy, ee->error_code, buffer, 1000);
  if (ee->error_code == BadWindow ||
      (ee->request_code == X_SetInputFocus && ee->error_code == BadMatch) ||
      (ee->request_code == X_ConfigureWindow && ee->error_code == BadMatch) ||
      (ee->request_code == X_GrabKey && ee->error_code == BadAccess))
    return 0;
  fprintf(stderr, "xmonad: X11 error: %s, request code=%d, error code=%d\n",
          buffer, ee->request_code, ee->error_code);
  return 0;
}


x86 assembly (clang, -O0):
<x11_extras_xerror>:
push   %rbp
mov    %rsp,%rbp
sub    $0x400,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    (%rax),%esi
lea    -0x400(%rbp),%rdx
mov    $0x3e8,%ecx
call   1040 <XGetErrorText@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
mov    0x2e8d(%rip),%rcx
cmp    (%rcx),%eax
je     11e4 <x11_extras_xerror+0xc4>
mov    -0x18(%rbp),%rax
mov    0x4(%rax),%eax
mov    0x2e4f(%rip),%rcx
cmp    (%rcx),%eax
jne    118e <x11_extras_xerror+0x6e>
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
mov    0x2e22(%rip),%rcx
cmp    (%rcx),%eax
je     11e4 <x11_extras_xerror+0xc4>
mov    -0x18(%rbp),%rax
mov    0x4(%rax),%eax
mov    0x2e34(%rip),%rcx
cmp    (%rcx),%eax
jne    11b9 <x11_extras_xerror+0x99>
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
mov    0x2df7(%rip),%rcx
cmp    (%rcx),%eax
je     11e4 <x11_extras_xerror+0xc4>
mov    -0x18(%rbp),%rax
mov    0x4(%rax),%eax
mov    0x2df1(%rip),%rcx
cmp    (%rcx),%eax
jne    11f0 <x11_extras_xerror+0xd0>
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
mov    0x2dec(%rip),%rcx
cmp    (%rcx),%eax
jne    11f0 <x11_extras_xerror+0xd0>
movl   $0x0,-0x4(%rbp)
jmp    1221 <x11_extras_xerror+0x101>
mov    0x2de1(%rip),%rax
mov    (%rax),%edi
lea    -0x400(%rbp),%rdx
mov    -0x18(%rbp),%rax
mov    0x4(%rax),%ecx
mov    -0x18(%rbp),%rax
mov    (%rax),%r8d
lea    0xdeb(%rip),%rsi
call   1030 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x400,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<x11_extras_xerror>:
push   %rbx
sub    $0x3f0,%rsp
mov    %rsi,%rbx
mov    (%rsi),%esi
mov    %rsp,%rdx
mov    $0x3e8,%ecx
call   1040 <XGetErrorText@plt>
mov    (%rbx),%r8d
mov    0x2ea4(%rip),%rax
cmp    (%rax),%r8d
je     11a4 <x11_extras_xerror+0x84>
mov    0x4(%rbx),%ecx
mov    0x2e6d(%rip),%rdx
mov    0x2e4e(%rip),%rax
mov    (%rax),%eax
cmp    (%rdx),%ecx
jne    1165 <x11_extras_xerror+0x45>
cmp    %eax,%r8d
je     11a4 <x11_extras_xerror+0x84>
mov    0x2e64(%rip),%rdx
cmp    (%rdx),%ecx
jne    1175 <x11_extras_xerror+0x55>
cmp    %eax,%r8d
je     11a4 <x11_extras_xerror+0x84>
mov    0x2e3c(%rip),%rax
cmp    (%rax),%ecx
jne    118c <x11_extras_xerror+0x6c>
mov    0x2e41(%rip),%rax
cmp    (%rax),%r8d
je     11a4 <x11_extras_xerror+0x84>
mov    0x2e45(%rip),%rax
mov    (%rax),%edi
lea    0xe64(%rip),%rsi
mov    %rsp,%rdx
call   1030 <fprintf@plt>
xor    %eax,%eax
add    $0x3f0,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.TYPE_3__ = type { i32, i32 }
@BadWindow = global i32 0
@X_SetInputFocus = global i32 0
@BadMatch = global i32 0
@X_ConfigureWindow = global i32 0
@X_GrabKey = global i32 0
@BadAccess = global i32 0
@stderr = global i32 0
@.str = [55 x i8] c"xmonad: X11 error: %s, request code=%d, error code=%d\0A\00"
define i32 @x11_extras_xerror(i32* %0, %struct.TYPE_3__* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca %struct.TYPE_3__*
%6 = alloca [1000 x i8]
store i32* %0, i32** %4
store %struct.TYPE_3__* %1, %struct.TYPE_3__** %5
%7 = load i32*, i32** %4
%8 = load %struct.TYPE_3__*, %struct.TYPE_3__** %5
%9 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %8, i32 0, i32 0
%10 = load i32, i32* %9
%11 = getelementptr inbounds [1000 x i8], [1000 x i8]* %6, i64 0, i64 0
%12 = call i32 @XGetErrorText(i32* %7, i32 %10, i8* %11, i32 1000)
%13 = load %struct.TYPE_3__*, %struct.TYPE_3__** %5
%14 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %13, i32 0, i32 0
%15 = load i32, i32* %14
%16 = load i32, i32* @BadWindow
%17 = icmp eq i32 %15, %16
br i1 %17, label %54, label %18
18: ; preds = %2
%19 = load %struct.TYPE_3__*, %struct.TYPE_3__** %5
%20 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %19, i32 0, i32 1
%21 = load i32, i32* %20
%22 = load i32, i32* @X_SetInputFocus
%23 = icmp eq i32 %21, %22
br i1 %23, label %24, label %30
24: ; preds = %18
%25 = load %struct.TYPE_3__*, %struct.TYPE_3__** %5
%26 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %25, i32 0, i32 0
%27 = load i32, i32* %26
%28 = load i32, i32* @BadMatch
%29 = icmp eq i32 %27, %28
br i1 %29, label %54, label %30
30: ; preds = %24, %18
%31 = load %struct.TYPE_3__*, %struct.TYPE_3__** %5
%32 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %31, i32 0, i32 1
%33 = load i32, i32* %32
%34 = load i32, i32* @X_ConfigureWindow
%35 = icmp eq i32 %33, %34
br i1 %35, label %36, label %42
36: ; preds = %30
%37 = load %struct.TYPE_3__*, %struct.TYPE_3__** %5
%38 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %37, i32 0, i32 0
%39 = load i32, i32* %38
%40 = load i32, i32* @BadMatch
%41 = icmp eq i32 %39, %40
br i1 %41, label %54, label %42
42: ; preds = %36, %30
%43 = load %struct.TYPE_3__*, %struct.TYPE_3__** %5
%44 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %43, i32 0, i32 1
%45 = load i32, i32* %44
%46 = load i32, i32* @X_GrabKey
%47 = icmp eq i32 %45, %46
br i1 %47, label %48, label %55
48: ; preds = %42
%49 = load %struct.TYPE_3__*, %struct.TYPE_3__** %5
%50 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %49, i32 0, i32 0
%51 = load i32, i32* %50
%52 = load i32, i32* @BadAccess
%53 = icmp eq i32 %51, %52
br i1 %53, label %54, label %55
54: ; preds = %48, %36, %24, %2
store i32 0, i32* %3
br label %65
55: ; preds = %48, %42
%56 = load i32, i32* @stderr
%57 = getelementptr inbounds [1000 x i8], [1000 x i8]* %6, i64 0, i64 0
%58 = load %struct.TYPE_3__*, %struct.TYPE_3__** %5
%59 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %58, i32 0, i32 1
%60 = load i32, i32* %59
%61 = load %struct.TYPE_3__*, %struct.TYPE_3__** %5
%62 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %61, i32 0, i32 0
%63 = load i32, i32* %62
%64 = call i32 @fprintf(i32 %56, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str, i64 0, i64 0), i8* %57, i32 %60, i32 %63)
store i32 0, i32* %3
br label %65
65: ; preds = %55, %54
%66 = load i32, i32* %3
ret i32 %66
}

LLVM IR (-O2):
%struct.TYPE_3__ = type { i32, i32 }
@BadWindow = global i32 0
@X_SetInputFocus = global i32 0
@BadMatch = global i32 0
@X_ConfigureWindow = global i32 0
@X_GrabKey = global i32 0
@BadAccess = global i32 0
@stderr = global i32 0
@.str = [55 x i8] c"xmonad: X11 error: %s, request code=%d, error code=%d\0A\00"
define i32 @x11_extras_xerror(i32* %0, %struct.TYPE_3__* nocapture %1) {
%3 = alloca [1000 x i8]
%4 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%5 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %1, i64 0, i32 0
%6 = load i32, i32* %5
%7 = call i32 @XGetErrorText(i32* %0, i32 %6, i8* %4, i32 1000)
%8 = load i32, i32* %5
%9 = load i32, i32* @BadWindow
%10 = icmp eq i32 %8, %9
br i1 %10, label %33, label %11
11: ; preds = %2
%12 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %1, i64 0, i32 1
%13 = load i32, i32* %12
%14 = load i32, i32* @X_SetInputFocus
%15 = icmp eq i32 %13, %14
%16 = load i32, i32* @BadMatch
%17 = icmp eq i32 %8, %16
%18 = select i1 %15, i1 %17, i1 false
br i1 %18, label %33, label %19
19: ; preds = %11
%20 = load i32, i32* @X_ConfigureWindow
%21 = icmp ne i32 %13, %20
%22 = xor i1 %17, true
%23 = select i1 %21, i1 true, i1 %22
br i1 %23, label %24, label %33
24: ; preds = %19
%25 = load i32, i32* @X_GrabKey
%26 = icmp eq i32 %13, %25
%27 = load i32, i32* @BadAccess
%28 = icmp eq i32 %8, %27
%29 = select i1 %26, i1 %28, i1 false
br i1 %29, label %33, label %30
30: ; preds = %24
%31 = load i32, i32* @stderr
%32 = call i32 @fprintf(i32 %31, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str, i64 0, i64 0), i8* %4, i32 %13, i32 %8)
br label %33
33: ; preds = %24, %19, %2, %11, %30
ret i32 0
}