#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_10__ TYPE_4__;
typedef struct TYPE_9__ TYPE_3__;
typedef struct TYPE_8__ TYPE_2__;
typedef struct TYPE_7__ TYPE_1__;

/* Type definitions */
struct TYPE_7__ {
  int /*<<< orphan*/ cursor;
};
typedef TYPE_1__ XSetWindowAttributes;
struct TYPE_8__ {
  int /*<<< orphan*/ window;
};
typedef TYPE_2__ XMapRequestEvent;
struct TYPE_9__ {
  int keycode;
};
typedef TYPE_3__ XKeyEvent;
struct TYPE_10__ {
  scalar_t__ type;
  TYPE_3__ xkey;
  TYPE_2__ xmaprequest;
};
typedef TYPE_4__ XEvent;
typedef int /*<<< orphan*/ Window;
typedef int /*<<< orphan*/ Display;

/* Variables and functions */
int /*<<< orphan*/ CWCursor;
int /*<<< orphan*/ CurrentTime;
int /*<<< orphan*/ DefaultRootWindow(int /*<<< orphan*/ *);
int /*<<< orphan*/ GrabModeAsync;
scalar_t__ KeyRelease;
scalar_t__ MapRequest;
int /*<<< orphan*/ Mod4Mask;
int /*<<< orphan*/ RevertToPointerRoot;
int SubstructureNotifyMask;
int SubstructureRedirectMask;
int /*<<< orphan*/ True;
int /*<<< orphan*/ XC_left_ptr;
int /*<<< orphan*/ XChangeWindowAttributes(int /*<<< orphan*/ *,
                                           int /*<<< orphan*/,
                                           int /*<<< orphan*/, TYPE_1__ *);
int /*<<< orphan*/ XCreateFontCursor(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ XDestroyWindow(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ XGetInputFocus(int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                                  int *);
int /*<<< orphan*/ XGrabKey(int /*<<< orphan*/ *, int, int /*<<< orphan*/,
                            int /*<<< orphan*/, int /*<<< orphan*/,
                            int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ XMapWindow(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ XMoveResizeWindow(int /*<<< orphan*/ *, int /*<<< orphan*/,
                                     int /*<<< orphan*/, int /*<<< orphan*/,
                                     int, int);
int /*<<< orphan*/ XNextEvent(int /*<<< orphan*/ *, TYPE_4__ *);
int /*<<< orphan*/ *XOpenDisplay(int /*<<< orphan*/ *);
int /*<<< orphan*/ XSelectInput(int /*<<< orphan*/ *, int /*<<< orphan*/, int);
int /*<<< orphan*/ XSetInputFocus(int /*<<< orphan*/ *, int /*<<< orphan*/,
                                  int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ system(char *);
int main() {
  Display *dpy;
  XEvent event;
  if (!(dpy = XOpenDisplay(NULL)))
    return 1;
  Window root = DefaultRootWindow(dpy);
  XSetWindowAttributes wa;
  wa.cursor = XCreateFontCursor(dpy, XC_left_ptr);
  XChangeWindowAttributes(dpy, root, CWCursor, &wa);
  XSelectInput(dpy, root, SubstructureNotifyMask | SubstructureRedirectMask);
  XGrabKey(dpy, 53, Mod4Mask, root, True, GrabModeAsync, GrabModeAsync);
  XGrabKey(dpy, 45, Mod4Mask, root, True, GrabModeAsync, GrabModeAsync);
  for (;;) {
    XNextEvent(dpy, &event);
    if (event.type == MapRequest) {
      XMapRequestEvent mapreq = event.xmaprequest;
      XMapWindow(dpy, mapreq.window);
      XSetInputFocus(dpy, mapreq.window, RevertToPointerRoot, CurrentTime);
      XMoveResizeWindow(dpy, mapreq.window, 0, 0, 1920, 1080);
    } else if (event.type == KeyRelease) {
      XKeyEvent keyev = event.xkey;
      if (keyev.keycode == 45) {
        Window focus;
        int revert;
        XGetInputFocus(dpy, &focus, &revert);
        XDestroyWindow(dpy, focus);
      } else {
        system("dmenu_run");
      }
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1090 <XOpenDisplay@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    1201 <main+0x31>
mov    $0x1,%eax
add    $0x50,%rsp
pop    %rbp
ret
mov    -0x10(%rbp),%rdi
call   1040 <DefaultRootWindow@plt>
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rdi
mov    0x2d78(%rip),%rax
mov    (%rax),%esi
call   1030 <XCreateFontCursor@plt>
mov    %eax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    0x2d80(%rip),%rax
mov    (%rax),%edx
lea    -0x28(%rbp),%rcx
call   1070 <XChangeWindowAttributes@plt>
mov    -0x10(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    0x2d4f(%rip),%rax
mov    (%rax),%edx
mov    0x2d4e(%rip),%rax
or     (%rax),%edx
call   10c0 <XSelectInput@plt>
mov    -0x10(%rbp),%rdi
mov    0x2d8c(%rip),%rax
mov    (%rax),%edx
mov    -0x24(%rbp),%ecx
mov    0x2d60(%rip),%rax
mov    (%rax),%r8d
mov    0x2d3e(%rip),%rax
mov    (%rax),%r9d
mov    0x2d34(%rip),%rax
mov    (%rax),%eax
mov    $0x35,%esi
mov    %eax,(%rsp)
call   10a0 <XGrabKey@plt>
mov    -0x10(%rbp),%rdi
mov    0x2d52(%rip),%rax
mov    (%rax),%edx
mov    -0x24(%rbp),%ecx
mov    0x2d26(%rip),%rax
mov    (%rax),%r8d
mov    0x2d04(%rip),%rax
mov    (%rax),%r9d
mov    0x2cfa(%rip),%rax
mov    (%rax),%eax
mov    $0x2d,%esi
mov    %eax,(%rsp)
call   10a0 <XGrabKey@plt>
mov    -0x10(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   10b0 <XNextEvent@plt>
mov    -0x20(%rbp),%rax
mov    0x2ce3(%rip),%rcx
cmp    (%rcx),%rax
jne    133f <main+0x16f>
mov    -0x14(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x30(%rbp),%esi
call   10d0 <XMapWindow@plt>
mov    -0x10(%rbp),%rdi
mov    -0x30(%rbp),%esi
mov    0x2cd2(%rip),%rax
mov    (%rax),%edx
mov    0x2cc1(%rip),%rax
mov    (%rax),%ecx
call   10e0 <XSetInputFocus@plt>
mov    -0x10(%rbp),%rdi
mov    -0x30(%rbp),%esi
xor    %ecx,%ecx
mov    $0x780,%r8d
mov    $0x438,%r9d
mov    %ecx,%edx
call   1060 <XMoveResizeWindow@plt>
jmp    139b <main+0x1cb>
mov    -0x20(%rbp),%rax
mov    0x2c5e(%rip),%rcx
cmp    (%rcx),%rax
jne    1396 <main+0x1c6>
mov    -0x18(%rbp),%eax
mov    %eax,-0x38(%rbp)
cmpl   $0x2d,-0x38(%rbp)
jne    1385 <main+0x1b5>
mov    -0x10(%rbp),%rdi
lea    -0x3c(%rbp),%rsi
lea    -0x40(%rbp),%rdx
call   10f0 <XGetInputFocus@plt>
mov    -0x10(%rbp),%rdi
mov    -0x3c(%rbp),%esi
call   1080 <XDestroyWindow@plt>
jmp    1391 <main+0x1c1>
lea    0xc74(%rip),%rdi
call   1050 <system@plt>
jmp    1396 <main+0x1c6>
jmp    139b <main+0x1cb>
jmp    12cd <main+0xfd>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
xor    %edi,%edi
call   1090 <XOpenDisplay@plt>
test   %rax,%rax
je     133f <main+0x16f>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <DefaultRootWindow@plt>
mov    %eax,%ebp
mov    0x2d8e(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1030 <XCreateFontCursor@plt>
mov    %eax,0x8(%rsp)
mov    0x2d99(%rip),%rax
mov    (%rax),%edx
lea    0x8(%rsp),%rcx
mov    %rbx,%rdi
mov    %ebp,%esi
call   1070 <XChangeWindowAttributes@plt>
mov    0x2d69(%rip),%rax
mov    0x2d6a(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
mov    %rbx,%rdi
mov    %ebp,%esi
call   10c0 <XSelectInput@plt>
mov    0x2da5(%rip),%r14
mov    (%r14),%edx
mov    0x2d7b(%rip),%r15
mov    (%r15),%r8d
mov    0x2d59(%rip),%r12
mov    (%r12),%r9d
mov    %r9d,(%rsp)
mov    %rbx,%rdi
mov    $0x35,%esi
mov    %ebp,%ecx
call   10a0 <XGrabKey@plt>
mov    (%r14),%edx
mov    (%r15),%r8d
mov    (%r12),%r9d
mov    %r9d,(%rsp)
mov    %rbx,%rdi
mov    $0x2d,%esi
mov    %ebp,%ecx
call   10a0 <XGrabKey@plt>
lea    0x10(%rsp),%r14
mov    0x2d29(%rip),%r15
mov    0x2d32(%rip),%r13
mov    0x2cfb(%rip),%r12
jmp    12ef <main+0x11f>
nop
mov    0x1c(%rsp),%ebp
mov    %rbx,%rdi
mov    %ebp,%esi
call   10d0 <XMapWindow@plt>
mov    0x2d1b(%rip),%rax
mov    (%rax),%edx
mov    0x0(%r13),%ecx
mov    %rbx,%rdi
mov    %ebp,%esi
call   10e0 <XSetInputFocus@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
xor    %edx,%edx
xor    %ecx,%ecx
mov    $0x780,%r8d
mov    $0x438,%r9d
call   1060 <XMoveResizeWindow@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   10b0 <XNextEvent@plt>
mov    0x10(%rsp),%rax
cmp    (%r15),%rax
je     12b0 <main+0xe0>
cmp    (%r12),%rax
jne    12ef <main+0x11f>
cmpl   $0x2d,0x18(%rsp)
jne    1331 <main+0x161>
mov    %rbx,%rdi
lea    0xc(%rsp),%rsi
lea    0x24(%rsp),%rdx
call   10f0 <XGetInputFocus@plt>
mov    0xc(%rsp),%esi
mov    %rbx,%rdi
call   1080 <XDestroyWindow@plt>
jmp    12ef <main+0x11f>
lea    0xcc8(%rip),%rdi
call   1050 <system@plt>
jmp    12ef <main+0x11f>
mov    $0x1,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.TYPE_10__ = type { i64, %struct.TYPE_9__, %struct.TYPE_8__ }
%struct.TYPE_9__ = type { i32 }
%struct.TYPE_8__ = type { i32 }
%struct.TYPE_7__ = type { i32 }
@XC_left_ptr = global i32 0
@CWCursor = global i32 0
@SubstructureNotifyMask = global i32 0
@SubstructureRedirectMask = global i32 0
@Mod4Mask = global i32 0
@True = global i32 0
@GrabModeAsync = global i32 0
@MapRequest = global i64 0
@RevertToPointerRoot = global i32 0
@CurrentTime = global i32 0
@KeyRelease = global i64 0
@.str = [10 x i8] c"dmenu_run\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca %struct.TYPE_10__
%4 = alloca i32
%5 = alloca %struct.TYPE_7__
%6 = alloca %struct.TYPE_8__
%7 = alloca %struct.TYPE_9__
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %1
%10 = call i32* @XOpenDisplay(i32* null)
store i32* %10, i32** %2
%11 = icmp ne i32* %10, null
br i1 %11, label %13, label %12
12: ; preds = %0
ret i32 1
13: ; preds = %0
%14 = load i32*, i32** %2
%15 = call i32 @DefaultRootWindow(i32* %14)
store i32 %15, i32* %4
%16 = load i32*, i32** %2
%17 = load i32, i32* @XC_left_ptr
%18 = call i32 @XCreateFontCursor(i32* %16, i32 %17)
%19 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %5, i32 0, i32 0
store i32 %18, i32* %19
%20 = load i32*, i32** %2
%21 = load i32, i32* %4
%22 = load i32, i32* @CWCursor
%23 = call i32 @XChangeWindowAttributes(i32* %20, i32 %21, i32 %22, %struct.TYPE_7__* %5)
%24 = load i32*, i32** %2
%25 = load i32, i32* %4
%26 = load i32, i32* @SubstructureNotifyMask
%27 = load i32, i32* @SubstructureRedirectMask
%28 = or i32 %26, %27
%29 = call i32 @XSelectInput(i32* %24, i32 %25, i32 %28)
%30 = load i32*, i32** %2
%31 = load i32, i32* @Mod4Mask
%32 = load i32, i32* %4
%33 = load i32, i32* @True
%34 = load i32, i32* @GrabModeAsync
%35 = load i32, i32* @GrabModeAsync
%36 = call i32 @XGrabKey(i32* %30, i32 53, i32 %31, i32 %32, i32 %33, i32 %34, i32 %35)
%37 = load i32*, i32** %2
%38 = load i32, i32* @Mod4Mask
%39 = load i32, i32* %4
%40 = load i32, i32* @True
%41 = load i32, i32* @GrabModeAsync
%42 = load i32, i32* @GrabModeAsync
%43 = call i32 @XGrabKey(i32* %37, i32 45, i32 %38, i32 %39, i32 %40, i32 %41, i32 %42)
br label %44
44: ; preds = %91, %13
%45 = load i32*, i32** %2
%46 = call i32 @XNextEvent(i32* %45, %struct.TYPE_10__* %3)
%47 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %3, i32 0, i32 0
%48 = load i64, i64* %47
%49 = load i64, i64* @MapRequest
%50 = icmp eq i64 %48, %49
br i1 %50, label %51, label %69
51: ; preds = %44
%52 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %3, i32 0, i32 2
%53 = bitcast %struct.TYPE_8__* %6 to i8*
%54 = bitcast %struct.TYPE_8__* %52 to i8*
%55 = load i32*, i32** %2
%56 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %6, i32 0, i32 0
%57 = load i32, i32* %56
%58 = call i32 @XMapWindow(i32* %55, i32 %57)
%59 = load i32*, i32** %2
%60 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %6, i32 0, i32 0
%61 = load i32, i32* %60
%62 = load i32, i32* @RevertToPointerRoot
%63 = load i32, i32* @CurrentTime
%64 = call i32 @XSetInputFocus(i32* %59, i32 %61, i32 %62, i32 %63)
%65 = load i32*, i32** %2
%66 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %6, i32 0, i32 0
%67 = load i32, i32* %66
%68 = call i32 @XMoveResizeWindow(i32* %65, i32 %67, i32 0, i32 0, i32 1920, i32 1080)
br label %91
69: ; preds = %44
%70 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %3, i32 0, i32 0
%71 = load i64, i64* %70
%72 = load i64, i64* @KeyRelease
%73 = icmp eq i64 %71, %72
br i1 %73, label %74, label %90
74: ; preds = %69
%75 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %3, i32 0, i32 1
%76 = bitcast %struct.TYPE_9__* %7 to i8*
%77 = bitcast %struct.TYPE_9__* %75 to i8*
%78 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %7, i32 0, i32 0
%79 = load i32, i32* %78
%80 = icmp eq i32 %79, 45
br i1 %80, label %81, label %87
81: ; preds = %74
%82 = load i32*, i32** %2
%83 = call i32 @XGetInputFocus(i32* %82, i32* %8, i32* %9)
%84 = load i32*, i32** %2
%85 = load i32, i32* %8
%86 = call i32 @XDestroyWindow(i32* %84, i32 %85)
br label %89
87: ; preds = %74
%88 = call i32 @system(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
br label %89
89: ; preds = %87, %81
br label %90
90: ; preds = %89, %69
br label %91
91: ; preds = %90, %51
br label %44
}

LLVM IR (-O2):
%struct.TYPE_10__ = type { i64, %struct.TYPE_9__, %struct.TYPE_8__ }
%struct.TYPE_9__ = type { i32 }
%struct.TYPE_8__ = type { i32 }
%struct.TYPE_7__ = type { i32 }
@XC_left_ptr = global i32 0
@CWCursor = global i32 0
@SubstructureNotifyMask = global i32 0
@SubstructureRedirectMask = global i32 0
@Mod4Mask = global i32 0
@True = global i32 0
@GrabModeAsync = global i32 0
@MapRequest = global i64 0
@RevertToPointerRoot = global i32 0
@CurrentTime = global i32 0
@KeyRelease = global i64 0
@.str = [10 x i8] c"dmenu_run\00"
define i32 @main() {
%1 = alloca %struct.TYPE_10__
%2 = alloca %struct.TYPE_7__
%3 = alloca i32
%4 = alloca i32
%5 = bitcast %struct.TYPE_10__* %1 to i8*
%6 = tail call i32* @XOpenDisplay(i32* null)
%7 = icmp eq i32* %6, null
br i1 %7, label %8, label %9
8: ; preds = %0
ret i32 1
9: ; preds = %0
%10 = tail call i32 @DefaultRootWindow(i32* %6)
%11 = bitcast %struct.TYPE_7__* %2 to i8*
%12 = load i32, i32* @XC_left_ptr
%13 = tail call i32 @XCreateFontCursor(i32* %6, i32 %12)
%14 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %2, i64 0, i32 0
store i32 %13, i32* %14
%15 = load i32, i32* @CWCursor
%16 = call i32 @XChangeWindowAttributes(i32* %6, i32 %10, i32 %15, %struct.TYPE_7__* %2)
%17 = load i32, i32* @SubstructureNotifyMask
%18 = load i32, i32* @SubstructureRedirectMask
%19 = or i32 %18, %17
%20 = call i32 @XSelectInput(i32* %6, i32 %10, i32 %19)
%21 = load i32, i32* @Mod4Mask
%22 = load i32, i32* @True
%23 = load i32, i32* @GrabModeAsync
%24 = call i32 @XGrabKey(i32* %6, i32 53, i32 %21, i32 %10, i32 %22, i32 %23, i32 %23)
%25 = load i32, i32* @Mod4Mask
%26 = load i32, i32* @True
%27 = load i32, i32* @GrabModeAsync
%28 = call i32 @XGrabKey(i32* %6, i32 45, i32 %25, i32 %10, i32 %26, i32 %27, i32 %27)
%29 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %1, i64 0, i32 0
%30 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %1, i64 0, i32 1, i32 0
%31 = bitcast i32* %3 to i8*
%32 = bitcast i32* %4 to i8*
%33 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %1, i64 0, i32 2, i32 0
br label %34
34: ; preds = %56, %9
%35 = call i32 @XNextEvent(i32* %6, %struct.TYPE_10__* %1)
%36 = load i64, i64* %29
%37 = load i64, i64* @MapRequest
%38 = icmp eq i64 %36, %37
br i1 %38, label %39, label %46
39: ; preds = %34
%40 = load i32, i32* %33
%41 = call i32 @XMapWindow(i32* %6, i32 %40)
%42 = load i32, i32* @RevertToPointerRoot
%43 = load i32, i32* @CurrentTime
%44 = call i32 @XSetInputFocus(i32* %6, i32 %40, i32 %42, i32 %43)
%45 = call i32 @XMoveResizeWindow(i32* %6, i32 %40, i32 0, i32 0, i32 1920, i32 1080)
br label %56
46: ; preds = %34
%47 = load i64, i64* @KeyRelease
%48 = icmp eq i64 %36, %47
br i1 %48, label %49, label %56
49: ; preds = %46
%50 = load i32, i32* %30
%51 = icmp eq i32 %50, 45
br i1 %51, label %52, label %57
52: ; preds = %49
%53 = call i32 @XGetInputFocus(i32* %6, i32* %3, i32* %4)
%54 = load i32, i32* %3
%55 = call i32 @XDestroyWindow(i32* %6, i32 %54)
br label %56
56: ; preds = %52, %57, %46, %39
br label %34
57: ; preds = %49
%58 = call i32 @system(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
br label %56
}