#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_3__;
typedef struct TYPE_9__ TYPE_2__;
typedef struct TYPE_8__ TYPE_1__;

/* Type definitions */
struct TYPE_9__ {
  int /*<<< orphan*/ flags;
};
typedef TYPE_2__ XSizeHints;
struct TYPE_8__ {
  int x;
  int y;
  int width;
  int height;
  int send_event;
};
struct TYPE_10__ {
  int type;
  TYPE_1__ xconfigure;
};
typedef TYPE_3__ XEvent;
typedef int /*<<< orphan*/ Window;
typedef int /*<<< orphan*/ Display;

/* Variables and functions */
#define ButtonPress 129
int ButtonPressMask;
#define ConfigureNotify 128
int /*<<< orphan*/ CopyFromParent;
int /*<<< orphan*/ PPosition;
int /*<<< orphan*/ RootWindow(int /*<<< orphan*/ *, int /*<<< orphan*/);
int StructureNotifyMask;
int /*<<< orphan*/ WhitePixel(int /*<<< orphan*/ *, int /*<<< orphan*/);
TYPE_2__ *XAllocSizeHints();
int /*<<< orphan*/ XCreateWindow(int /*<<< orphan*/ *, int /*<<< orphan*/, int,
                                 int, int, int, int /*<<< orphan*/,
                                 int /*<<< orphan*/, int /*<<< orphan*/,
                                 int /*<<< orphan*/, int /*<<< orphan*/,
                                 int /*<<< orphan*/ *);
int /*<<< orphan*/ XFlush(int /*<<< orphan*/ *);
int /*<<< orphan*/ XFree(TYPE_2__ *);
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*/ XSetWMNormalHints(int /*<<< orphan*/ *, int /*<<< orphan*/,
                                     TYPE_2__ *);
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, int, int, int, int);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  Display *display;
  Window win;
  XEvent report;
  int x = 200, y = 200, h = 100, w = 400, s;
  XSizeHints *size;
  display = XOpenDisplay(NULL);
  if (display == NULL) {
    fprintf(stderr, "couldn't connect to X server :0\n");
    return 0;
  }
  win = XCreateWindow(display, RootWindow(display, 0), x, y, w, h, 0,
                      CopyFromParent, CopyFromParent, CopyFromParent, 0, NULL);
  XSetWindowBackground(display, win, WhitePixel(display, 0));
  size = XAllocSizeHints();
  size->flags = PPosition;
  XSetWMNormalHints(display, win, size);
  XFree(size);
  XFlush(display);
  XMapWindow(display, win);
  XSelectInput(display, win, StructureNotifyMask | ButtonPressMask);
  while (1) {
    XNextEvent(display, &report);
    switch (report.type) {
    case ButtonPress:
      XUnmapWindow(display, win);
      break;
    case ConfigureNotify:
      x = report.xconfigure.x;
      y = report.xconfigure.y;
      w = report.xconfigure.width;
      h = report.xconfigure.height;
      s = report.xconfigure.send_event;
      printf("confignotify %i,%i-%ix%i (send: %d)\n", x, y, w, h, s);
      break;
    }
  }
  return 1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
sub    $0xa8,%rsp
movl   $0x0,-0xc(%rbp)
mov    %edi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0xc8,-0x44(%rbp)
movl   $0xc8,-0x48(%rbp)
movl   $0x64,-0x4c(%rbp)
movl   $0x190,-0x50(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1070 <XOpenDisplay@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    125f <main+0x6f>
mov    0x2d83(%rip),%rax
mov    (%rax),%edi
lea    0xdb2(%rip),%rsi
call   1080 <fprintf@plt>
xor    %eax,%eax
add    $0xa8,%rsp
pop    %rbx
pop    %rbp
ret
mov    -0x20(%rbp),%rax
mov    %rax,-0x78(%rbp)
mov    -0x20(%rbp),%rdi
xor    %esi,%esi
call   10c0 <RootWindow@plt>
mov    -0x78(%rbp),%rdi
mov    %eax,%esi
mov    -0x44(%rbp),%edx
mov    -0x48(%rbp),%ecx
mov    -0x50(%rbp),%r8d
mov    -0x4c(%rbp),%r9d
mov    0x2d33(%rip),%rax
mov    (%rax),%r11d
mov    0x2d29(%rip),%rax
mov    (%rax),%r10d
mov    0x2d1f(%rip),%rax
mov    (%rax),%eax
xor    %ebx,%ebx
xor    %ebx,%ebx
movl   $0x0,(%rsp)
mov    %r11d,0x8(%rsp)
mov    %r10d,0x10(%rsp)
mov    %eax,0x18(%rsp)
movl   $0x0,0x20(%rsp)
movq   $0x0,0x28(%rsp)
call   10b0 <XCreateWindow@plt>
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x70(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x64(%rbp)
mov    -0x20(%rbp),%rdi
xor    %esi,%esi
call   1050 <WhitePixel@plt>
mov    -0x70(%rbp),%rdi
mov    -0x64(%rbp),%esi
mov    %eax,%edx
call   1110 <XSetWindowBackground@plt>
mov    $0x0,%al
call   1090 <XAllocSizeHints@plt>
mov    %rax,-0x60(%rbp)
mov    0x2cca(%rip),%rax
mov    (%rax),%ecx
mov    -0x60(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    -0x60(%rbp),%rdx
call   1060 <XSetWMNormalHints@plt>
mov    -0x60(%rbp),%rdi
call   1040 <XFree@plt>
mov    -0x20(%rbp),%rdi
call   10f0 <XFlush@plt>
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%esi
call   1100 <XMapWindow@plt>
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    0x2c7e(%rip),%rax
mov    (%rax),%edx
mov    0x2c8d(%rip),%rax
or     (%rax),%edx
call   10d0 <XSelectInput@plt>
mov    -0x20(%rbp),%rdi
lea    -0x40(%rbp),%rsi
call   10a0 <XNextEvent@plt>
mov    -0x40(%rbp),%eax
mov    %eax,-0x7c(%rbp)
sub    $0x80,%eax
je     13a9 <main+0x1b9>
jmp    1385 <main+0x195>
mov    -0x7c(%rbp),%eax
sub    $0x81,%eax
jne    13e4 <main+0x1f4>
jmp    1398 <main+0x1a8>
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%esi
call   10e0 <XUnmapWindow@plt>
jmp    13e4 <main+0x1f4>
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    -0x2c(%rbp),%eax
mov    %eax,-0x54(%rbp)
mov    -0x44(%rbp),%esi
mov    -0x48(%rbp),%edx
mov    -0x50(%rbp),%ecx
mov    -0x4c(%rbp),%r8d
mov    -0x54(%rbp),%r9d
lea    0xc42(%rip),%rdi
call   1030 <printf@plt>
jmp    1362 <main+0x172>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
xor    %edi,%edi
call   1070 <XOpenDisplay@plt>
test   %rax,%rax
je     1317 <main+0x127>
mov    %rax,%rbx
mov    %rax,%rdi
xor    %esi,%esi
call   10c0 <RootWindow@plt>
mov    0x2da2(%rip),%rcx
mov    (%rcx),%ebp
mov    %rbx,%rdi
mov    %eax,%esi
mov    $0xc8,%edx
mov    $0xc8,%ecx
mov    $0x190,%r8d
mov    $0x64,%r9d
push   $0x0
push   $0x0
push   %rbp
push   %rbp
push   %rbp
push   $0x0
call   10b0 <XCreateWindow@plt>
add    $0x30,%rsp
mov    %eax,%r14d
mov    %rbx,%rdi
xor    %esi,%esi
call   1050 <WhitePixel@plt>
mov    %rbx,%rdi
mov    %r14d,%esi
mov    %eax,%edx
call   1110 <XSetWindowBackground@plt>
xor    %eax,%eax
call   1090 <XAllocSizeHints@plt>
mov    %rax,%rbp
mov    0x2d60(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x0(%rbp)
mov    %rbx,%rdi
mov    %r14d,%esi
mov    %rbp,%rdx
call   1060 <XSetWMNormalHints@plt>
mov    %rbp,%rdi
call   1040 <XFree@plt>
mov    %rbx,%rdi
call   10f0 <XFlush@plt>
mov    %rbx,%rdi
mov    %r14d,%esi
call   1100 <XMapWindow@plt>
mov    0x2d23(%rip),%rax
mov    0x2d34(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
mov    %rbx,%rdi
mov    %r14d,%esi
call   10d0 <XSelectInput@plt>
mov    %rsp,%rbp
lea    0xd54(%rip),%r15
jmp    12ee <main+0xfe>
nop
mov    0x4(%rsp),%esi
mov    0x8(%rsp),%edx
mov    0xc(%rsp),%ecx
mov    0x10(%rsp),%r8d
mov    0x14(%rsp),%r9d
mov    %r15,%rdi
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   10a0 <XNextEvent@plt>
mov    (%rsp),%eax
cmp    $0x80,%eax
je     12d0 <main+0xe0>
cmp    $0x81,%eax
jne    12ee <main+0xfe>
mov    %rbx,%rdi
mov    %r14d,%esi
call   10e0 <XUnmapWindow@plt>
jmp    12ee <main+0xfe>
mov    0x2caa(%rip),%rax
mov    (%rax),%edi
lea    0xcd9(%rip),%rsi
call   1080 <fprintf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
%struct.TYPE_10__ = type { i32, %struct.TYPE_8__ }
%struct.TYPE_8__ = type { i32, i32, i32, i32, i32 }
%struct.TYPE_9__ = type { i32 }
@stderr = global i32 0
@.str = [33 x i8] c"couldn't connect to X server :0\0A\00"
@CopyFromParent = global i32 0
@PPosition = global i32 0
@StructureNotifyMask = global i32 0
@ButtonPressMask = global i32 0
@.str.1 = [37 x i8] c"confignotify %i,%i-%ix%i (send: %d)\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca %struct.TYPE_10__
%4 = bitcast %struct.TYPE_10__* %3 to i8*
%5 = tail call i32* @XOpenDisplay(i32* null)
%6 = icmp eq i32* %5, null
br i1 %6, label %7, label %10
7: ; preds = %2
%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 = %2
%11 = tail call i32 @RootWindow(i32* %5, i32 0)
%12 = load i32, i32* @CopyFromParent
%13 = tail call i32 @XCreateWindow(i32* %5, i32 %11, i32 200, i32 200, i32 400, i32 100, i32 0, i32 %12, i32 %12, i32 %12, i32 0, i32* null)
%14 = tail call i32 @WhitePixel(i32* %5, i32 0)
%15 = tail call i32 @XSetWindowBackground(i32* %5, i32 %13, i32 %14)
%16 = tail call %struct.TYPE_9__* (...) @XAllocSizeHints()
%17 = load i32, i32* @PPosition
%18 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %16, i64 0, i32 0
store i32 %17, i32* %18
%19 = tail call i32 @XSetWMNormalHints(i32* %5, i32 %13, %struct.TYPE_9__* %16)
%20 = tail call i32 @XFree(%struct.TYPE_9__* %16)
%21 = tail call i32 @XFlush(i32* %5)
%22 = tail call i32 @XMapWindow(i32* %5, i32 %13)
%23 = load i32, i32* @StructureNotifyMask
%24 = load i32, i32* @ButtonPressMask
%25 = or i32 %24, %23
%26 = tail call i32 @XSelectInput(i32* %5, i32 %13, i32 %25)
%27 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %3, i64 0, i32 0
%28 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %3, i64 0, i32 1, i32 0
%29 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %3, i64 0, i32 1, i32 1
%30 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %3, i64 0, i32 1, i32 2
%31 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %3, i64 0, i32 1, i32 3
%32 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %3, i64 0, i32 1, i32 4
br label %33
33: ; preds = %36, %10
%34 = call i32 @XNextEvent(i32* %5, %struct.TYPE_10__* %3)
%35 = load i32, i32* %27
switch i32 %35, label %36 [
i32 129, label %37
i32 128, label %39
]
36: ; preds = %33, %39, %37
br label %33
37: ; preds = %33
%38 = call i32 @XUnmapWindow(i32* %5, i32 %13)
br label %36
39: ; preds = %33
%40 = load i32, i32* %28
%41 = load i32, i32* %29
%42 = load i32, i32* %30
%43 = load i32, i32* %31
%44 = load i32, i32* %32
%45 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i32 %40, i32 %41, i32 %42, i32 %43, i32 %44)
br label %36
}