#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_4__ TYPE_1__;

/* Type definitions */
struct TYPE_4__ {
  scalar_t__ error_code;
  scalar_t__ request_code;
};
typedef TYPE_1__ XErrorEvent;
typedef int /*<<< orphan*/ Display;

/* Variables and functions */
scalar_t__ BadAccess;
scalar_t__ BadDrawable;
scalar_t__ BadMatch;
scalar_t__ BadWindow;
scalar_t__ X_ConfigureWindow;
scalar_t__ X_CopyArea;
scalar_t__ X_GrabKey;
scalar_t__ X_PolyFillRectangle;
scalar_t__ X_PolySegment;
scalar_t__ X_PolyText8;
scalar_t__ X_SetInputFocus;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ logger(char *);
int xerrorxlib(int /*<<< orphan*/ *, TYPE_1__ *);
int xerror(Display *dis, XErrorEvent *ee) {
  if (ee->error_code == BadWindow ||
      (ee->request_code == X_SetInputFocus && ee->error_code == BadMatch) ||
      (ee->request_code == X_PolyText8 && ee->error_code == BadDrawable) ||
      (ee->request_code == X_PolyFillRectangle &&
       ee->error_code == BadDrawable) ||
      (ee->request_code == X_PolySegment && ee->error_code == BadDrawable) ||
      (ee->request_code == X_ConfigureWindow && ee->error_code == BadMatch) ||
      (ee->request_code == X_GrabKey && ee->error_code == BadAccess) ||
      (ee->request_code == X_CopyArea && ee->error_code == BadDrawable))
    return 0;
  if (ee->error_code == BadAccess) {
    logger("\033[0;31mIs Another Window Manager Running? Exiting!");
    exit(1);
  } else
    logger("\033[0;31mBad Window Error!");
  return xerrorxlib(dis, ee);
}


x86 assembly (clang, -O0):
<xerror>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    0x2e8a(%rip),%rcx
cmp    (%rcx),%rax
je     12a0 <xerror+0x170>
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rax
mov    0x2e3a(%rip),%rcx
cmp    (%rcx),%rax
jne    1186 <xerror+0x56>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    0x2e0b(%rip),%rcx
cmp    (%rcx),%rax
je     12a0 <xerror+0x170>
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rax
mov    0x2e23(%rip),%rcx
cmp    (%rcx),%rax
jne    11b5 <xerror+0x85>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    0x2e24(%rip),%rcx
cmp    (%rcx),%rax
je     12a0 <xerror+0x170>
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rax
mov    0x2e04(%rip),%rcx
cmp    (%rcx),%rax
jne    11e4 <xerror+0xb4>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    0x2df5(%rip),%rcx
cmp    (%rcx),%rax
je     12a0 <xerror+0x170>
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rax
mov    0x2df5(%rip),%rcx
cmp    (%rcx),%rax
jne    1213 <xerror+0xe3>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    0x2dc6(%rip),%rcx
cmp    (%rcx),%rax
je     12a0 <xerror+0x170>
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rax
mov    0x2d8e(%rip),%rcx
cmp    (%rcx),%rax
jne    1242 <xerror+0x112>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    0x2d4f(%rip),%rcx
cmp    (%rcx),%rax
je     12a0 <xerror+0x170>
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rax
mov    0x2d47(%rip),%rcx
cmp    (%rcx),%rax
jne    1271 <xerror+0x141>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    0x2d40(%rip),%rcx
cmp    (%rcx),%rax
je     12a0 <xerror+0x170>
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rax
mov    0x2d60(%rip),%rcx
cmp    (%rcx),%rax
jne    12ac <xerror+0x17c>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    0x2d39(%rip),%rcx
cmp    (%rcx),%rax
jne    12ac <xerror+0x17c>
movl   $0x0,-0x4(%rbp)
jmp    12f5 <xerror+0x1c5>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    0x2cee(%rip),%rcx
cmp    (%rcx),%rax
jne    12d9 <xerror+0x1a9>
lea    0xd36(%rip),%rdi
call   1040 <logger@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
lea    0xd53(%rip),%rdi
call   1040 <logger@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <xerrorxlib@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xerror>:
push   %r14
push   %rbx
push   %rax
mov    (%rsi),%rax
mov    0x2e9a(%rip),%rcx
cmp    (%rcx),%rax
je     11e6 <xerror+0xb6>
mov    %rsi,%rbx
mov    %rdi,%r14
mov    0x8(%rsi),%rcx
mov    0x2e48(%rip),%rdx
mov    0x2e29(%rip),%rsi
mov    (%rsi),%rsi
cmp    (%rdx),%rcx
jne    116c <xerror+0x3c>
cmp    %rsi,%rax
je     11e6 <xerror+0xb6>
mov    0x2e45(%rip),%rdi
mov    0x2e56(%rip),%rdx
mov    (%rdx),%rdx
cmp    (%rdi),%rcx
jne    1187 <xerror+0x57>
cmp    %rdx,%rax
je     11e6 <xerror+0xb6>
mov    0x2e3a(%rip),%rdi
cmp    (%rdi),%rcx
jne    1198 <xerror+0x68>
cmp    %rdx,%rax
je     11e6 <xerror+0xb6>
mov    0x2e49(%rip),%rdi
cmp    (%rdi),%rcx
jne    11a9 <xerror+0x79>
cmp    %rdx,%rax
je     11e6 <xerror+0xb6>
mov    0x2e00(%rip),%rdi
cmp    (%rdi),%rcx
jne    11ba <xerror+0x8a>
cmp    %rsi,%rax
je     11e6 <xerror+0xb6>
mov    0x2dd7(%rip),%rdi
mov    0x2de0(%rip),%rsi
mov    (%rsi),%rsi
cmp    (%rdi),%rcx
jne    11d5 <xerror+0xa5>
cmp    %rsi,%rax
je     11e6 <xerror+0xb6>
mov    0x2e04(%rip),%rdi
cmp    (%rdi),%rcx
jne    11f0 <xerror+0xc0>
cmp    %rdx,%rax
jne    11f0 <xerror+0xc0>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
cmp    %rsi,%rax
je     1213 <xerror+0xe3>
lea    0xe37(%rip),%rdi
call   1040 <logger@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <xerrorxlib@plt>
lea    0xde6(%rip),%rdi
call   1040 <logger@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
%struct.TYPE_4__ = type { i64, i64 }
@BadWindow = global i64 0
@X_SetInputFocus = global i64 0
@BadMatch = global i64 0
@X_PolyText8 = global i64 0
@BadDrawable = global i64 0
@X_PolyFillRectangle = global i64 0
@X_PolySegment = global i64 0
@X_ConfigureWindow = global i64 0
@X_GrabKey = global i64 0
@BadAccess = global i64 0
@X_CopyArea = global i64 0
@.str = [51 x i8] c"\1B[0;31mIs Another Window Manager Running? Exiting!\00"
@.str.1 = [25 x i8] c"\1B[0;31mBad Window Error!\00"
define i32 @xerror(i32* %0, %struct.TYPE_4__* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca %struct.TYPE_4__*
store i32* %0, i32** %4
store %struct.TYPE_4__* %1, %struct.TYPE_4__** %5
%6 = load %struct.TYPE_4__*, %struct.TYPE_4__** %5
%7 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %6, i32 0, i32 0
%8 = load i64, i64* %7
%9 = load i64, i64* @BadWindow
%10 = icmp eq i64 %8, %9
br i1 %10, label %95, label %11
11: ; preds = %2
%12 = load %struct.TYPE_4__*, %struct.TYPE_4__** %5
%13 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %12, i32 0, i32 1
%14 = load i64, i64* %13
%15 = load i64, i64* @X_SetInputFocus
%16 = icmp eq i64 %14, %15
br i1 %16, label %17, label %23
17: ; preds = %11
%18 = load %struct.TYPE_4__*, %struct.TYPE_4__** %5
%19 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %18, i32 0, i32 0
%20 = load i64, i64* %19
%21 = load i64, i64* @BadMatch
%22 = icmp eq i64 %20, %21
br i1 %22, label %95, label %23
23: ; preds = %17, %11
%24 = load %struct.TYPE_4__*, %struct.TYPE_4__** %5
%25 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %24, i32 0, i32 1
%26 = load i64, i64* %25
%27 = load i64, i64* @X_PolyText8
%28 = icmp eq i64 %26, %27
br i1 %28, label %29, label %35
29: ; preds = %23
%30 = load %struct.TYPE_4__*, %struct.TYPE_4__** %5
%31 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %30, i32 0, i32 0
%32 = load i64, i64* %31
%33 = load i64, i64* @BadDrawable
%34 = icmp eq i64 %32, %33
br i1 %34, label %95, label %35
35: ; preds = %29, %23
%36 = load %struct.TYPE_4__*, %struct.TYPE_4__** %5
%37 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %36, i32 0, i32 1
%38 = load i64, i64* %37
%39 = load i64, i64* @X_PolyFillRectangle
%40 = icmp eq i64 %38, %39
br i1 %40, label %41, label %47
41: ; preds = %35
%42 = load %struct.TYPE_4__*, %struct.TYPE_4__** %5
%43 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %42, i32 0, i32 0
%44 = load i64, i64* %43
%45 = load i64, i64* @BadDrawable
%46 = icmp eq i64 %44, %45
br i1 %46, label %95, label %47
47: ; preds = %41, %35
%48 = load %struct.TYPE_4__*, %struct.TYPE_4__** %5
%49 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %48, i32 0, i32 1
%50 = load i64, i64* %49
%51 = load i64, i64* @X_PolySegment
%52 = icmp eq i64 %50, %51
br i1 %52, label %53, label %59
53: ; preds = %47
%54 = load %struct.TYPE_4__*, %struct.TYPE_4__** %5
%55 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %54, i32 0, i32 0
%56 = load i64, i64* %55
%57 = load i64, i64* @BadDrawable
%58 = icmp eq i64 %56, %57
br i1 %58, label %95, label %59
59: ; preds = %53, %47
%60 = load %struct.TYPE_4__*, %struct.TYPE_4__** %5
%61 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %60, i32 0, i32 1
%62 = load i64, i64* %61
%63 = load i64, i64* @X_ConfigureWindow
%64 = icmp eq i64 %62, %63
br i1 %64, label %65, label %71
65: ; preds = %59
%66 = load %struct.TYPE_4__*, %struct.TYPE_4__** %5
%67 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %66, i32 0, i32 0
%68 = load i64, i64* %67
%69 = load i64, i64* @BadMatch
%70 = icmp eq i64 %68, %69
br i1 %70, label %95, label %71
71: ; preds = %65, %59
%72 = load %struct.TYPE_4__*, %struct.TYPE_4__** %5
%73 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %72, i32 0, i32 1
%74 = load i64, i64* %73
%75 = load i64, i64* @X_GrabKey
%76 = icmp eq i64 %74, %75
br i1 %76, label %77, label %83
77: ; preds = %71
%78 = load %struct.TYPE_4__*, %struct.TYPE_4__** %5
%79 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %78, i32 0, i32 0
%80 = load i64, i64* %79
%81 = load i64, i64* @BadAccess
%82 = icmp eq i64 %80, %81
br i1 %82, label %95, label %83
83: ; preds = %77, %71
%84 = load %struct.TYPE_4__*, %struct.TYPE_4__** %5
%85 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %84, i32 0, i32 1
%86 = load i64, i64* %85
%87 = load i64, i64* @X_CopyArea
%88 = icmp eq i64 %86, %87
br i1 %88, label %89, label %96
89: ; preds = %83
%90 = load %struct.TYPE_4__*, %struct.TYPE_4__** %5
%91 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %90, i32 0, i32 0
%92 = load i64, i64* %91
%93 = load i64, i64* @BadDrawable
%94 = icmp eq i64 %92, %93
br i1 %94, label %95, label %96
95: ; preds = %89, %77, %65, %53, %41, %29, %17, %2
store i32 0, i32* %3
br label %111
96: ; preds = %89, %83
%97 = load %struct.TYPE_4__*, %struct.TYPE_4__** %5
%98 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %97, i32 0, i32 0
%99 = load i64, i64* %98
%100 = load i64, i64* @BadAccess
%101 = icmp eq i64 %99, %100
br i1 %101, label %102, label %105
102: ; preds = %96
%103 = call i32 @logger(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0))
%104 = call i32 @exit(i32 1)
unreachable
105: ; preds = %96
%106 = call i32 @logger(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
br label %107
107: ; preds = %105
%108 = load i32*, i32** %4
%109 = load %struct.TYPE_4__*, %struct.TYPE_4__** %5
%110 = call i32 @xerrorxlib(i32* %108, %struct.TYPE_4__* %109)
store i32 %110, i32* %3
br label %111
111: ; preds = %107, %95
%112 = load i32, i32* %3
ret i32 %112
}

LLVM IR (-O2):
%struct.TYPE_4__ = type { i64, i64 }
@BadWindow = global i64 0
@X_SetInputFocus = global i64 0
@BadMatch = global i64 0
@X_PolyText8 = global i64 0
@BadDrawable = global i64 0
@X_PolyFillRectangle = global i64 0
@X_PolySegment = global i64 0
@X_ConfigureWindow = global i64 0
@X_GrabKey = global i64 0
@BadAccess = global i64 0
@X_CopyArea = global i64 0
@.str = [51 x i8] c"\1B[0;31mIs Another Window Manager Running? Exiting!\00"
@.str.1 = [25 x i8] c"\1B[0;31mBad Window Error!\00"
define i32 @xerror(i32* %0, %struct.TYPE_4__* %1) {
%3 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %1, i64 0, i32 0
%4 = load i64, i64* %3
%5 = load i64, i64* @BadWindow
%6 = icmp eq i64 %4, %5
br i1 %6, label %51, label %7
7: ; preds = %2
%8 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %1, i64 0, i32 1
%9 = load i64, i64* %8
%10 = load i64, i64* @X_SetInputFocus
%11 = icmp eq i64 %9, %10
%12 = load i64, i64* @BadMatch
%13 = icmp eq i64 %4, %12
%14 = select i1 %11, i1 %13, i1 false
br i1 %14, label %51, label %15
15: ; preds = %7
%16 = load i64, i64* @X_PolyText8
%17 = icmp eq i64 %9, %16
%18 = load i64, i64* @BadDrawable
%19 = icmp eq i64 %4, %18
%20 = select i1 %17, i1 %19, i1 false
br i1 %20, label %51, label %21
21: ; preds = %15
%22 = load i64, i64* @X_PolyFillRectangle
%23 = icmp eq i64 %9, %22
%24 = select i1 %23, i1 %19, i1 false
br i1 %24, label %51, label %25
25: ; preds = %21
%26 = load i64, i64* @X_PolySegment
%27 = icmp eq i64 %9, %26
%28 = select i1 %27, i1 %19, i1 false
br i1 %28, label %51, label %29
29: ; preds = %25
%30 = load i64, i64* @X_ConfigureWindow
%31 = icmp ne i64 %9, %30
%32 = xor i1 %13, true
%33 = select i1 %31, i1 true, i1 %32
br i1 %33, label %34, label %51
34: ; preds = %29
%35 = load i64, i64* @X_GrabKey
%36 = icmp eq i64 %9, %35
%37 = load i64, i64* @BadAccess
%38 = icmp eq i64 %4, %37
%39 = select i1 %36, i1 %38, i1 false
br i1 %39, label %51, label %40
40: ; preds = %34
%41 = load i64, i64* @X_CopyArea
%42 = icmp eq i64 %9, %41
%43 = select i1 %42, i1 %19, i1 false
br i1 %43, label %51, label %44
44: ; preds = %40
br i1 %38, label %45, label %48
45: ; preds = %44
%46 = tail call i32 @logger(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0))
%47 = tail call i32 @exit(i32 1)
unreachable
48: ; preds = %44
%49 = tail call i32 @logger(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
%50 = tail call i32 @xerrorxlib(i32* %0, %struct.TYPE_4__* %1)
br label %51
51: ; preds = %40, %34, %29, %25, %21, %15, %2, %7, %48
%52 = phi i32 [ %50, %48 ], [ 0, %7 ], [ 0, %2 ], [ 0, %15 ], [ 0, %21 ], [ 0, %25 ], [ 0, %29 ], [ 0, %34 ], [ 0, %40 ]
ret i32 %52
}