#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__ {
  void *initial_state;
  int /*<<< orphan*/ flags;
};
typedef TYPE_2__ XWMHints;
struct TYPE_8__ {
  int x;
  int y;
  int width;
  int height;
};
struct TYPE_10__ {
  int type;
  TYPE_1__ xconfigure;
};
typedef TYPE_3__ XEvent;
typedef int /*<<< orphan*/ Window;
typedef int /*<<< orphan*/ Display;
typedef int /*<<< orphan*/ Atom;

/* Variables and functions */
#define ConfigureNotify 129
int /*<<< orphan*/ CopyFromParent;
#define Expose 128
int /*<<< orphan*/ False;
void *IconicState;
unsigned long None;
int /*<<< orphan*/ RootWindow(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ StateHint;
int /*<<< orphan*/ WhitePixel(int /*<<< orphan*/ *, int /*<<< orphan*/);
TYPE_2__ *XAllocWMHints();
int /*<<< orphan*/ XCreateWindow(int /*<<< orphan*/ *, int /*<<< orphan*/, int,
                                 int, int, int, int, int /*<<< orphan*/,
                                 int /*<<< orphan*/, int /*<<< orphan*/,
                                 int /*<<< orphan*/, int /*<<< orphan*/ *);
int /*<<< orphan*/ XFlush(int /*<<< orphan*/ *);
int /*<<< orphan*/ XFree(TYPE_2__ *);
int /*<<< orphan*/ XInternAtom(int /*<<< orphan*/ *, char *,
                               int /*<<< orphan*/);
int /*<<< orphan*/ XMapWindow(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ XNextEvent(int /*<<< orphan*/ *, TYPE_3__ *);
int /*<<< orphan*/ *XOpenDisplay(int /*<<< orphan*/ *);
int /*<<< orphan*/ XSetWMHints(int /*<<< orphan*/ *, int /*<<< orphan*/,
                               TYPE_2__ *);
int /*<<< orphan*/ XSetWindowBackground(int /*<<< orphan*/ *,
                                        int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
int main() {
  Display *display;
  Window win;
  XEvent report;
  Atom wm_state;
  XEvent msg;
  int x = 50, y = 50, h = 100, w = 400;
  unsigned long state[2];
  XWMHints *hints;
  display = XOpenDisplay(NULL);
  if (display == NULL) {
    fprintf(stderr, "couldn't connect to X server :0\n");
    return 0;
  }
  state[0] = IconicState;
  state[1] = None;
  wm_state = XInternAtom(display, "WM_STATE", False);
  win = XCreateWindow(display, RootWindow(display, 0), x, y, w, h, 10,
                      CopyFromParent, CopyFromParent, CopyFromParent, 0, NULL);
  hints = XAllocWMHints();
  hints->flags = StateHint;
  hints->initial_state = IconicState;
  XSetWMHints(display, win, hints);
  XFree(hints);
  XSetWindowBackground(display, win, WhitePixel(display, 0));
  XMapWindow(display, win);
  XFlush(display);
  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   %rbx
sub    $0xc8,%rsp
movl   $0x0,-0xc(%rbp)
movl   $0x32,-0x4c(%rbp)
movl   $0x32,-0x50(%rbp)
movl   $0x64,-0x54(%rbp)
movl   $0x190,-0x58(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1070 <XOpenDisplay@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1248 <main+0x68>
mov    0x2d92(%rip),%rax
mov    (%rax),%edi
lea    0xdc9(%rip),%rsi
call   1080 <fprintf@plt>
xor    %eax,%eax
add    $0xc8,%rsp
pop    %rbx
pop    %rbp
ret
mov    0x2d89(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x70(%rbp)
mov    0x2d73(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x68(%rbp)
mov    -0x18(%rbp),%rdi
mov    0x2d71(%rip),%rax
mov    (%rax),%edx
lea    0xda9(%rip),%rsi
call   10b0 <XInternAtom@plt>
mov    %eax,-0x34(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x90(%rbp)
mov    -0x18(%rbp),%rdi
xor    %esi,%esi
call   10d0 <RootWindow@plt>
mov    -0x90(%rbp),%rdi
mov    %eax,%esi
mov    -0x4c(%rbp),%edx
mov    -0x50(%rbp),%ecx
mov    -0x58(%rbp),%r8d
mov    -0x54(%rbp),%r9d
mov    0x2d04(%rip),%rax
mov    (%rax),%r11d
mov    0x2cfa(%rip),%rax
mov    (%rax),%r10d
mov    0x2cf0(%rip),%rax
mov    (%rax),%eax
xor    %ebx,%ebx
xor    %ebx,%ebx
movl   $0xa,(%rsp)
mov    %r11d,0x8(%rsp)
mov    %r10d,0x10(%rsp)
mov    %eax,0x18(%rsp)
movl   $0x0,0x20(%rsp)
movq   $0x0,0x28(%rsp)
call   10c0 <XCreateWindow@plt>
mov    %eax,-0x1c(%rbp)
mov    $0x0,%al
call   1090 <XAllocWMHints@plt>
mov    %rax,-0x78(%rbp)
mov    0x2cea(%rip),%rax
mov    (%rax),%ecx
mov    -0x78(%rbp),%rax
mov    %ecx,0x8(%rax)
mov    0x2cba(%rip),%rax
mov    (%rax),%rcx
mov    -0x78(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x78(%rbp),%rdx
call   1050 <XSetWMHints@plt>
mov    -0x78(%rbp),%rdi
call   1040 <XFree@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x88(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x7c(%rbp)
mov    -0x18(%rbp),%rdi
xor    %esi,%esi
call   1060 <WhitePixel@plt>
mov    -0x88(%rbp),%rdi
mov    -0x7c(%rbp),%esi
mov    %eax,%edx
call   1100 <XSetWindowBackground@plt>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   10f0 <XMapWindow@plt>
mov    -0x18(%rbp),%rdi
call   10e0 <XFlush@plt>
mov    -0x18(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   10a0 <XNextEvent@plt>
mov    -0x30(%rbp),%eax
mov    %eax,-0x94(%rbp)
sub    $0x80,%eax
je     13bf <main+0x1df>
jmp    13a9 <main+0x1c9>
mov    -0x94(%rbp),%eax
sub    $0x81,%eax
je     13d2 <main+0x1f2>
jmp    1405 <main+0x225>
lea    0xc64(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1405 <main+0x225>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x28(%rbp),%eax
mov    %eax,-0x50(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x58(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x54(%rbp)
mov    -0x4c(%rbp),%esi
mov    -0x50(%rbp),%edx
mov    -0x58(%rbp),%ecx
mov    -0x54(%rbp),%r8d
lea    0xc35(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1383 <main+0x1a3>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x20,%rsp
xor    %edi,%edi
call   1080 <XOpenDisplay@plt>
test   %rax,%rax
je     1322 <main+0x132>
mov    %rax,%r14
mov    0x2dca(%rip),%rax
mov    (%rax),%edx
lea    0xe02(%rip),%rsi
mov    %r14,%rdi
call   10c0 <XInternAtom@plt>
mov    %r14,%rdi
xor    %esi,%esi
call   10e0 <RootWindow@plt>
mov    0x2d88(%rip),%rcx
mov    (%rcx),%ebp
mov    %r14,%rdi
mov    %eax,%esi
mov    $0x32,%edx
mov    $0x32,%ecx
mov    $0x190,%r8d
mov    $0x64,%r9d
push   $0x0
push   $0x0
push   %rbp
push   %rbp
push   %rbp
push   $0xa
call   10d0 <XCreateWindow@plt>
add    $0x30,%rsp
mov    %eax,%ebp
xor    %eax,%eax
call   10a0 <XAllocWMHints@plt>
mov    %rax,%rbx
mov    0x2d7e(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x8(%rbx)
mov    0x2d52(%rip),%rax
mov    (%rax),%rax
mov    %rax,(%rbx)
mov    %r14,%rdi
mov    %ebp,%esi
mov    %rbx,%rdx
call   1060 <XSetWMHints@plt>
mov    %rbx,%rdi
call   1050 <XFree@plt>
mov    %r14,%rdi
xor    %esi,%esi
call   1070 <WhitePixel@plt>
mov    %r14,%rdi
mov    %ebp,%esi
mov    %eax,%edx
call   1110 <XSetWindowBackground@plt>
mov    %r14,%rdi
mov    %ebp,%esi
call   1100 <XMapWindow@plt>
mov    %r14,%rdi
call   10f0 <XFlush@plt>
lea    0x8(%rsp),%rbx
lea    0xd55(%rip),%r15
lea    0xd68(%rip),%r12
jmp    12fb <main+0x10b>
xchg   %ax,%ax
mov    0xc(%rsp),%esi
mov    0x10(%rsp),%edx
mov    0x14(%rsp),%ecx
mov    0x18(%rsp),%r8d
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   10b0 <XNextEvent@plt>
mov    0x8(%rsp),%eax
cmp    $0x81,%eax
je     12e0 <main+0xf0>
cmp    $0x80,%eax
jne    12fb <main+0x10b>
mov    %r12,%rdi
call   1030 <puts@plt>
jmp    12fb <main+0x10b>
mov    0x2c9f(%rip),%rax
mov    (%rax),%edi
lea    0xcce(%rip),%rsi
call   1090 <fprintf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r12
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 }
%struct.TYPE_9__ = type { i8*, i32 }
@stderr = global i32 0
@.str = [33 x i8] c"couldn't connect to X server :0\0A\00"
@IconicState = global i8* null
@None = global i64 0
@.str.1 = [9 x i8] c"WM_STATE\00"
@False = global i32 0
@CopyFromParent = global i32 0
@StateHint = global i32 0
@.str.2 = [9 x i8] c"exposed\0A\00"
@.str.3 = [26 x i8] c"confignotify %i,%i-%ix%i\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32
%4 = alloca %struct.TYPE_10__
%5 = alloca i32
%6 = alloca %struct.TYPE_10__
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca [2 x i64]
%12 = alloca %struct.TYPE_9__*
store i32 0, i32* %1
store i32 50, i32* %7
store i32 50, i32* %8
store i32 100, i32* %9
store i32 400, i32* %10
%13 = call i32* @XOpenDisplay(i32* null)
store i32* %13, i32** %2
%14 = load i32*, i32** %2
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %19
16: ; preds = %0
%17 = load i32, i32* @stderr
%18 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
ret i32 0
19: ; preds = %0
%20 = load i8*, i8** @IconicState
%21 = ptrtoint i8* %20 to i64
%22 = getelementptr inbounds [2 x i64], [2 x i64]* %11, i64 0, i64 0
store i64 %21, i64* %22
%23 = load i64, i64* @None
%24 = getelementptr inbounds [2 x i64], [2 x i64]* %11, i64 0, i64 1
store i64 %23, i64* %24
%25 = load i32*, i32** %2
%26 = load i32, i32* @False
%27 = call i32 @XInternAtom(i32* %25, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %26)
store i32 %27, i32* %5
%28 = load i32*, i32** %2
%29 = load i32*, i32** %2
%30 = call i32 @RootWindow(i32* %29, i32 0)
%31 = load i32, i32* %7
%32 = load i32, i32* %8
%33 = load i32, i32* %10
%34 = load i32, i32* %9
%35 = load i32, i32* @CopyFromParent
%36 = load i32, i32* @CopyFromParent
%37 = load i32, i32* @CopyFromParent
%38 = call i32 @XCreateWindow(i32* %28, i32 %30, i32 %31, i32 %32, i32 %33, i32 %34, i32 10, i32 %35, i32 %36, i32 %37, i32 0, i32* null)
store i32 %38, i32* %3
%39 = call %struct.TYPE_9__* (...) @XAllocWMHints()
store %struct.TYPE_9__* %39, %struct.TYPE_9__** %12
%40 = load i32, i32* @StateHint
%41 = load %struct.TYPE_9__*, %struct.TYPE_9__** %12
%42 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %41, i32 0, i32 1
store i32 %40, i32* %42
%43 = load i8*, i8** @IconicState
%44 = load %struct.TYPE_9__*, %struct.TYPE_9__** %12
%45 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %44, i32 0, i32 0
store i8* %43, i8** %45
%46 = load i32*, i32** %2
%47 = load i32, i32* %3
%48 = load %struct.TYPE_9__*, %struct.TYPE_9__** %12
%49 = call i32 @XSetWMHints(i32* %46, i32 %47, %struct.TYPE_9__* %48)
%50 = load %struct.TYPE_9__*, %struct.TYPE_9__** %12
%51 = call i32 @XFree(%struct.TYPE_9__* %50)
%52 = load i32*, i32** %2
%53 = load i32, i32* %3
%54 = load i32*, i32** %2
%55 = call i32 @WhitePixel(i32* %54, i32 0)
%56 = call i32 @XSetWindowBackground(i32* %52, i32 %53, i32 %55)
%57 = load i32*, i32** %2
%58 = load i32, i32* %3
%59 = call i32 @XMapWindow(i32* %57, i32 %58)
%60 = load i32*, i32** %2
%61 = call i32 @XFlush(i32* %60)
br label %62
62: ; preds = %19, %87
%63 = load i32*, i32** %2
%64 = call i32 @XNextEvent(i32* %63, %struct.TYPE_10__* %4)
%65 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %4, i32 0, i32 0
%66 = load i32, i32* %65
switch i32 %66, label %87 [
i32 128, label %67
i32 129, label %69
]
67: ; preds = %62
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
br label %87
69: ; preds = %62
%70 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %4, i32 0, i32 1
%71 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %70, i32 0, i32 0
%72 = load i32, i32* %71
store i32 %72, i32* %7
%73 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %4, i32 0, i32 1
%74 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %73, i32 0, i32 1
%75 = load i32, i32* %74
store i32 %75, i32* %8
%76 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %4, i32 0, i32 1
%77 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %76, i32 0, i32 2
%78 = load i32, i32* %77
store i32 %78, i32* %10
%79 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %4, i32 0, i32 1
%80 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %79, i32 0, i32 3
%81 = load i32, i32* %80
store i32 %81, i32* %9
%82 = load i32, i32* %7
%83 = load i32, i32* %8
%84 = load i32, i32* %10
%85 = load i32, i32* %9
%86 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i32 %82, i32 %83, i32 %84, i32 %85)
br label %87
87: ; preds = %62, %69, %67
br label %62
}

LLVM IR (-O2):
%struct.TYPE_10__ = type { i32, %struct.TYPE_8__ }
%struct.TYPE_8__ = type { i32, i32, i32, i32 }
%struct.TYPE_9__ = type { i8*, i32 }
@stderr = global i32 0
@.str = [33 x i8] c"couldn't connect to X server :0\0A\00"
@IconicState = global i8* null
@None = global i64 0
@.str.1 = [9 x i8] c"WM_STATE\00"
@False = global i32 0
@CopyFromParent = global i32 0
@StateHint = global i32 0
@.str.3 = [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_10__
%2 = bitcast %struct.TYPE_10__* %1 to i8*
%3 = tail call i32* @XOpenDisplay(i32* null)
%4 = icmp eq i32* %3, null
br i1 %4, label %5, label %8
5: ; preds = %0
%6 = load i32, i32* @stderr
%7 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
ret i32 0
8: ; preds = %0
%9 = load i32, i32* @False
%10 = tail call i32 @XInternAtom(i32* %3, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %9)
%11 = tail call i32 @RootWindow(i32* %3, i32 0)
%12 = load i32, i32* @CopyFromParent
%13 = tail call i32 @XCreateWindow(i32* %3, i32 %11, i32 50, i32 50, i32 400, i32 100, i32 10, i32 %12, i32 %12, i32 %12, i32 0, i32* null)
%14 = tail call %struct.TYPE_9__* (...) @XAllocWMHints()
%15 = load i32, i32* @StateHint
%16 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %14, i64 0, i32 1
store i32 %15, i32* %16
%17 = load i8*, i8** @IconicState
%18 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %14, i64 0, i32 0
store i8* %17, i8** %18
%19 = tail call i32 @XSetWMHints(i32* %3, i32 %13, %struct.TYPE_9__* %14)
%20 = tail call i32 @XFree(%struct.TYPE_9__* %14)
%21 = tail call i32 @WhitePixel(i32* %3, i32 0)
%22 = tail call i32 @XSetWindowBackground(i32* %3, i32 %13, i32 %21)
%23 = tail call i32 @XMapWindow(i32* %3, i32 %13)
%24 = tail call i32 @XFlush(i32* %3)
%25 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %1, i64 0, i32 0
%26 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %1, i64 0, i32 1, i32 0
%27 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %1, i64 0, i32 1, i32 1
%28 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %1, i64 0, i32 1, i32 2
%29 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %1, i64 0, i32 1, i32 3
br label %30
30: ; preds = %33, %8
%31 = call i32 @XNextEvent(i32* %3, %struct.TYPE_10__* %1)
%32 = load i32, i32* %25
switch i32 %32, label %33 [
i32 128, label %34
i32 129, label %36
]
33: ; preds = %30, %36, %34
br label %30
34: ; preds = %30
%35 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str, i64 0, i64 0))
br label %33
36: ; preds = %30
%37 = load i32, i32* %26
%38 = load i32, i32* %27
%39 = load i32, i32* %28
%40 = load i32, i32* %29
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i32 %37, i32 %38, i32 %39, i32 %40)
br label %33
}