#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_8__ TYPE_3__;
typedef struct TYPE_7__ TYPE_2__;
typedef struct TYPE_6__ TYPE_1__;

/* Type definitions */
struct TYPE_7__ {
  int /*<<< orphan*/ override_redirect;
};
typedef TYPE_2__ XSetWindowAttributes;
struct TYPE_6__ {
  int x;
  int y;
  int width;
  int height;
};
struct TYPE_8__ {
  int type;
  TYPE_1__ xconfigure;
};
typedef TYPE_3__ XEvent;
typedef int /*<<< orphan*/ Window;
typedef int /*<<< orphan*/ Display;

/* Variables and functions */
unsigned long CWOverrideRedirect;
#define ConfigureNotify 129
int /*<<< orphan*/ CopyFromParent;
#define Expose 128
int ExposureMask;
int /*<<< orphan*/ RootWindow(int /*<<< orphan*/ *, int /*<<< orphan*/);
int StructureNotifyMask;
int /*<<< orphan*/ True;
int /*<<< orphan*/ WhitePixel(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ XCreateWindow(int /*<<< orphan*/ *, int /*<<< orphan*/, int,
                                 int, int, int, int, int /*<<< orphan*/,
                                 int /*<<< orphan*/, int /*<<< orphan*/,
                                 unsigned long, TYPE_2__ *);
int /*<<< orphan*/ XFlush(int /*<<< orphan*/ *);
int /*<<< orphan*/ XMapWindow(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ XNextEvent(int /*<<< orphan*/ *, TYPE_3__ *);
int /*<<< orphan*/ *XOpenDisplay(int /*<<< orphan*/ *);
int /*<<< orphan*/ XSelectInput(int /*<<< orphan*/ *, int /*<<< orphan*/, int);
int /*<<< orphan*/ XSetWindowBackground(int /*<<< orphan*/ *,
                                        int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ XUnmapWindow(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ stderr;
int main() {
  XSetWindowAttributes xswa;
  unsigned long xswamask;
  Display *display;
  Window win;
  XEvent report;
  int x = 10, y = 10, h = 100, w = 400;
  display = XOpenDisplay(NULL);
  if (display == NULL) {
    fprintf(stderr, "couldn't connect to X server :0\n");
    return 0;
  }
  xswa.override_redirect = True;
  xswamask = CWOverrideRedirect;
  win = XCreateWindow(display, RootWindow(display, 0), x, y, w, h, 10,
                      CopyFromParent, CopyFromParent, CopyFromParent, xswamask,
                      &xswa);
  XSetWindowBackground(display, win, WhitePixel(display, 0));
  XMapWindow(display, win);
  XFlush(display);
  sleep(1);
  XUnmapWindow(display, win);
  XFlush(display);
  sleep(1);
  XMapWindow(display, win);
  XFlush(display);
  XSelectInput(display, win, ExposureMask | StructureNotifyMask);
  while (1) {
    XNextEvent(display, &report);
    switch (report.type) {
    case Expose:
      printf("exposed\n");
      break;
    case ConfigureNotify:
      x = report.xconfigure.x;
      y = report.xconfigure.y;
      w = report.xconfigure.width;
      h = report.xconfigure.height;
      printf("confignotify %i,%i-%ix%i\n", x, y, w, h);
      break;
    }
  }
  return 1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r14
push   %rbx
sub    $0x90,%rsp
movl   $0x0,-0x14(%rbp)
movl   $0xa,-0x44(%rbp)
movl   $0xa,-0x48(%rbp)
movl   $0x64,-0x4c(%rbp)
movl   $0x190,-0x50(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1050 <XOpenDisplay@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    123c <main+0x6c>
mov    0x2db0(%rip),%rax
mov    (%rax),%edi
lea    0xdd7(%rip),%rsi
call   1060 <fprintf@plt>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    0x2da5(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    0x2d61(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    -0x28(%rbp),%rdi
xor    %esi,%esi
call   1090 <RootWindow@plt>
mov    -0x68(%rbp),%rdi
mov    %eax,%esi
mov    -0x44(%rbp),%edx
mov    -0x48(%rbp),%ecx
mov    -0x50(%rbp),%r8d
mov    -0x4c(%rbp),%r9d
mov    0x2d3c(%rip),%rax
mov    (%rax),%r14d
mov    0x2d32(%rip),%rax
mov    (%rax),%ebx
mov    0x2d29(%rip),%rax
mov    (%rax),%r11d
mov    -0x20(%rbp),%r10
lea    -0x18(%rbp),%rax
movl   $0xa,(%rsp)
mov    %r14d,0x8(%rsp)
mov    %ebx,0x10(%rsp)
mov    %r11d,0x18(%rsp)
mov    %r10,0x20(%rsp)
mov    %rax,0x28(%rsp)
call   1080 <XCreateWindow@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0x2c(%rbp),%eax
mov    %eax,-0x54(%rbp)
mov    -0x28(%rbp),%rdi
xor    %esi,%esi
call   1040 <WhitePixel@plt>
mov    -0x60(%rbp),%rdi
mov    -0x54(%rbp),%esi
mov    %eax,%edx
call   10e0 <XSetWindowBackground@plt>
mov    -0x28(%rbp),%rdi
mov    -0x2c(%rbp),%esi
call   10d0 <XMapWindow@plt>
mov    -0x28(%rbp),%rdi
call   10c0 <XFlush@plt>
mov    $0x1,%edi
call   10f0 <sleep@plt>
mov    -0x28(%rbp),%rdi
mov    -0x2c(%rbp),%esi
call   10b0 <XUnmapWindow@plt>
mov    -0x28(%rbp),%rdi
call   10c0 <XFlush@plt>
mov    $0x1,%edi
call   10f0 <sleep@plt>
mov    -0x28(%rbp),%rdi
mov    -0x2c(%rbp),%esi
call   10d0 <XMapWindow@plt>
mov    -0x28(%rbp),%rdi
call   10c0 <XFlush@plt>
mov    -0x28(%rbp),%rdi
mov    -0x2c(%rbp),%esi
mov    0x2c77(%rip),%rax
mov    (%rax),%edx
mov    0x2c7e(%rip),%rax
or     (%rax),%edx
call   10a0 <XSelectInput@plt>
mov    -0x28(%rbp),%rdi
lea    -0x40(%rbp),%rsi
call   1070 <XNextEvent@plt>
mov    -0x40(%rbp),%eax
mov    %eax,-0x6c(%rbp)
sub    $0x80,%eax
je     1397 <main+0x1c7>
jmp    1384 <main+0x1b4>
mov    -0x6c(%rbp),%eax
sub    $0x81,%eax
je     13aa <main+0x1da>
jmp    13dd <main+0x20d>
lea    0xc83(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    13dd <main+0x20d>
mov    -0x3c(%rbp),%eax
mov    %eax,-0x44(%rbp)
mov    -0x38(%rbp),%eax
mov    %eax,-0x48(%rbp)
mov    -0x34(%rbp),%eax
mov    %eax,-0x50(%rbp)
mov    -0x30(%rbp),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x44(%rbp),%esi
mov    -0x48(%rbp),%edx
mov    -0x50(%rbp),%ecx
mov    -0x4c(%rbp),%r8d
lea    0xc54(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1361 <main+0x191>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x28,%rsp
xor    %edi,%edi
call   1060 <XOpenDisplay@plt>
test   %rax,%rax
je     1332 <main+0x152>
mov    %rax,%rbx
mov    0x2de4(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x8(%rsp)
mov    0x2d9f(%rip),%rax
mov    (%rax),%r14
mov    %rbx,%rdi
xor    %esi,%esi
call   10a0 <RootWindow@plt>
mov    0x2d9b(%rip),%rcx
mov    (%rcx),%ebp
lea    0x8(%rsp),%r10
mov    %rbx,%rdi
mov    %eax,%esi
mov    $0xa,%edx
mov    $0xa,%ecx
mov    $0x190,%r8d
mov    $0x64,%r9d
push   %r10
push   %r14
push   %rbp
push   %rbp
push   %rbp
push   $0xa
call   1090 <XCreateWindow@plt>
add    $0x30,%rsp
mov    %eax,%ebp
mov    %rbx,%rdi
xor    %esi,%esi
call   1050 <WhitePixel@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %eax,%edx
call   10f0 <XSetWindowBackground@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
call   10e0 <XMapWindow@plt>
mov    %rbx,%rdi
call   10d0 <XFlush@plt>
mov    $0x1,%edi
call   1100 <sleep@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
call   10c0 <XUnmapWindow@plt>
mov    %rbx,%rdi
call   10d0 <XFlush@plt>
mov    $0x1,%edi
call   1100 <sleep@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
call   10e0 <XMapWindow@plt>
mov    %rbx,%rdi
call   10d0 <XFlush@plt>
mov    0x2d06(%rip),%rax
mov    0x2d0f(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
mov    %rbx,%rdi
mov    %ebp,%esi
call   10b0 <XSelectInput@plt>
lea    0x10(%rsp),%rbp
lea    0xd3e(%rip),%r14
lea    0xd51(%rip),%r15
jmp    130b <main+0x12b>
nopl   0x0(%rax)
mov    0x14(%rsp),%esi
mov    0x18(%rsp),%edx
mov    0x1c(%rsp),%ecx
mov    0x20(%rsp),%r8d
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1080 <XNextEvent@plt>
mov    0x10(%rsp),%eax
cmp    $0x81,%eax
je     12f0 <main+0x110>
cmp    $0x80,%eax
jne    130b <main+0x12b>
mov    %r15,%rdi
call   1030 <puts@plt>
jmp    130b <main+0x12b>
mov    0x2c97(%rip),%rax
mov    (%rax),%edi
lea    0xcbe(%rip),%rsi
call   1070 <fprintf@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.TYPE_7__ = type { i32 }
%struct.TYPE_8__ = type { i32, %struct.TYPE_6__ }
%struct.TYPE_6__ = type { i32, i32, i32, i32 }
@stderr = global i32 0
@.str = [33 x i8] c"couldn't connect to X server :0\0A\00"
@True = global i32 0
@CWOverrideRedirect = global i64 0
@CopyFromParent = global i32 0
@ExposureMask = global i32 0
@StructureNotifyMask = global i32 0
@.str.1 = [9 x i8] c"exposed\0A\00"
@.str.2 = [26 x i8] c"confignotify %i,%i-%ix%i\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.TYPE_7__
%3 = alloca i64
%4 = alloca i32*
%5 = alloca i32
%6 = alloca %struct.TYPE_8__
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %1
store i32 10, i32* %7
store i32 10, i32* %8
store i32 100, i32* %9
store i32 400, i32* %10
%11 = call i32* @XOpenDisplay(i32* null)
store i32* %11, i32** %4
%12 = load i32*, i32** %4
%13 = icmp eq i32* %12, null
br i1 %13, label %14, label %17
14: ; preds = %0
%15 = load i32, i32* @stderr
%16 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
ret i32 0
17: ; preds = %0
%18 = load i32, i32* @True
%19 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %2, i32 0, i32 0
store i32 %18, i32* %19
%20 = load i64, i64* @CWOverrideRedirect
store i64 %20, i64* %3
%21 = load i32*, i32** %4
%22 = load i32*, i32** %4
%23 = call i32 @RootWindow(i32* %22, i32 0)
%24 = load i32, i32* %7
%25 = load i32, i32* %8
%26 = load i32, i32* %10
%27 = load i32, i32* %9
%28 = load i32, i32* @CopyFromParent
%29 = load i32, i32* @CopyFromParent
%30 = load i32, i32* @CopyFromParent
%31 = load i64, i64* %3
%32 = call i32 @XCreateWindow(i32* %21, i32 %23, i32 %24, i32 %25, i32 %26, i32 %27, i32 10, i32 %28, i32 %29, i32 %30, i64 %31, %struct.TYPE_7__* %2)
store i32 %32, i32* %5
%33 = load i32*, i32** %4
%34 = load i32, i32* %5
%35 = load i32*, i32** %4
%36 = call i32 @WhitePixel(i32* %35, i32 0)
%37 = call i32 @XSetWindowBackground(i32* %33, i32 %34, i32 %36)
%38 = load i32*, i32** %4
%39 = load i32, i32* %5
%40 = call i32 @XMapWindow(i32* %38, i32 %39)
%41 = load i32*, i32** %4
%42 = call i32 @XFlush(i32* %41)
%43 = call i32 @sleep(i32 1)
%44 = load i32*, i32** %4
%45 = load i32, i32* %5
%46 = call i32 @XUnmapWindow(i32* %44, i32 %45)
%47 = load i32*, i32** %4
%48 = call i32 @XFlush(i32* %47)
%49 = call i32 @sleep(i32 1)
%50 = load i32*, i32** %4
%51 = load i32, i32* %5
%52 = call i32 @XMapWindow(i32* %50, i32 %51)
%53 = load i32*, i32** %4
%54 = call i32 @XFlush(i32* %53)
%55 = load i32*, i32** %4
%56 = load i32, i32* %5
%57 = load i32, i32* @ExposureMask
%58 = load i32, i32* @StructureNotifyMask
%59 = or i32 %57, %58
%60 = call i32 @XSelectInput(i32* %55, i32 %56, i32 %59)
br label %61
61: ; preds = %17, %86
%62 = load i32*, i32** %4
%63 = call i32 @XNextEvent(i32* %62, %struct.TYPE_8__* %6)
%64 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %6, i32 0, i32 0
%65 = load i32, i32* %64
switch i32 %65, label %86 [
i32 128, label %66
i32 129, label %68
]
66: ; preds = %61
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
br label %86
68: ; preds = %61
%69 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %6, i32 0, i32 1
%70 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %69, i32 0, i32 0
%71 = load i32, i32* %70
store i32 %71, i32* %7
%72 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %6, i32 0, i32 1
%73 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %72, i32 0, i32 1
%74 = load i32, i32* %73
store i32 %74, i32* %8
%75 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %6, i32 0, i32 1
%76 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %75, i32 0, i32 2
%77 = load i32, i32* %76
store i32 %77, i32* %10
%78 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %6, i32 0, i32 1
%79 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %78, i32 0, i32 3
%80 = load i32, i32* %79
store i32 %80, i32* %9
%81 = load i32, i32* %7
%82 = load i32, i32* %8
%83 = load i32, i32* %10
%84 = load i32, i32* %9
%85 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i32 %81, i32 %82, i32 %83, i32 %84)
br label %86
86: ; preds = %61, %68, %66
br label %61
}

LLVM IR (-O2):
%struct.TYPE_7__ = type { i32 }
%struct.TYPE_8__ = type { i32, %struct.TYPE_6__ }
%struct.TYPE_6__ = type { i32, i32, i32, i32 }
@stderr = global i32 0
@.str = [33 x i8] c"couldn't connect to X server :0\0A\00"
@True = global i32 0
@CWOverrideRedirect = global i64 0
@CopyFromParent = global i32 0
@ExposureMask = global i32 0
@StructureNotifyMask = global i32 0
@.str.2 = [26 x i8] c"confignotify %i,%i-%ix%i\0A\00"
@str = [8 x i8] c"exposed\00"
define i32 @main() {
%1 = alloca %struct.TYPE_7__
%2 = alloca %struct.TYPE_8__
%3 = bitcast %struct.TYPE_7__* %1 to i8*
%4 = bitcast %struct.TYPE_8__* %2 to i8*
%5 = tail call i32* @XOpenDisplay(i32* null)
%6 = icmp eq i32* %5, null
br i1 %6, label %7, label %10
7: ; preds = %0
%8 = load i32, i32* @stderr
%9 = tail call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
ret i32 0
10: ; preds = %0
%11 = load i32, i32* @True
%12 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %1, i64 0, i32 0
store i32 %11, i32* %12
%13 = load i64, i64* @CWOverrideRedirect
%14 = tail call i32 @RootWindow(i32* %5, i32 0)
%15 = load i32, i32* @CopyFromParent
%16 = call i32 @XCreateWindow(i32* %5, i32 %14, i32 10, i32 10, i32 400, i32 100, i32 10, i32 %15, i32 %15, i32 %15, i64 %13, %struct.TYPE_7__* %1)
%17 = call i32 @WhitePixel(i32* %5, i32 0)
%18 = call i32 @XSetWindowBackground(i32* %5, i32 %16, i32 %17)
%19 = call i32 @XMapWindow(i32* %5, i32 %16)
%20 = call i32 @XFlush(i32* %5)
%21 = call i32 @sleep(i32 1)
%22 = call i32 @XUnmapWindow(i32* %5, i32 %16)
%23 = call i32 @XFlush(i32* %5)
%24 = call i32 @sleep(i32 1)
%25 = call i32 @XMapWindow(i32* %5, i32 %16)
%26 = call i32 @XFlush(i32* %5)
%27 = load i32, i32* @ExposureMask
%28 = load i32, i32* @StructureNotifyMask
%29 = or i32 %28, %27
%30 = call i32 @XSelectInput(i32* %5, i32 %16, i32 %29)
%31 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %2, i64 0, i32 0
%32 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %2, i64 0, i32 1, i32 0
%33 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %2, i64 0, i32 1, i32 1
%34 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %2, i64 0, i32 1, i32 2
%35 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %2, i64 0, i32 1, i32 3
br label %36
36: ; preds = %39, %10
%37 = call i32 @XNextEvent(i32* %5, %struct.TYPE_8__* %2)
%38 = load i32, i32* %31
switch i32 %38, label %39 [
i32 128, label %40
i32 129, label %42
]
39: ; preds = %36, %42, %40
br label %36
40: ; preds = %36
%41 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str, i64 0, i64 0))
br label %39
42: ; preds = %36
%43 = load i32, i32* %32
%44 = load i32, i32* %33
%45 = load i32, i32* %34
%46 = load i32, i32* %35
%47 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i32 %43, i32 %44, i32 %45, i32 %46)
br label %39
}