#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_5__ TYPE_2__;
typedef struct TYPE_4__ TYPE_1__;

/* Type definitions */
struct TYPE_4__ {
  int x;
  int y;
  int width;
  int height;
};
struct TYPE_5__ {
  int type;
  TYPE_1__ xconfigure;
};
typedef TYPE_2__ XEvent;
typedef int /*<<< orphan*/ Window;
typedef int /*<<< orphan*/ Display;

/* Variables and functions */
#define ConfigureNotify 129
int /*<<< orphan*/ CopyFromParent;
#define Expose 128
int ExposureMask;
int /*<<< orphan*/ RootWindow(int /*<<< orphan*/ *, int /*<<< orphan*/);
int StructureNotifyMask;
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*/,
                                 int /*<<< orphan*/, int /*<<< orphan*/ *);
int /*<<< orphan*/ XFlush(int /*<<< orphan*/ *);
int /*<<< orphan*/ XMapWindow(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ XNextEvent(int /*<<< orphan*/ *, TYPE_2__ *);
int /*<<< orphan*/ *XOpenDisplay(int /*<<< orphan*/ *);
int /*<<< orphan*/ XResizeWindow(int /*<<< orphan*/ *, int /*<<< orphan*/, int,
                                 int);
int /*<<< orphan*/ XSelectInput(int /*<<< orphan*/ *, int /*<<< orphan*/, int);
int /*<<< orphan*/ XSetWindowBackground(int /*<<< orphan*/ *,
                                        int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ stderr;
int main() {
  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;
  }
  win = XCreateWindow(display, RootWindow(display, 0), x, y, w, h, 10,
                      CopyFromParent, CopyFromParent, CopyFromParent, 0, NULL);
  XSetWindowBackground(display, win, WhitePixel(display, 0));
  XMapWindow(display, win);
  XFlush(display);
  sleep(5);
  XResizeWindow(display, win, 600, 150);
  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   %rbx
sub    $0x88,%rsp
movl   $0x0,-0xc(%rbp)
movl   $0xa,-0x34(%rbp)
movl   $0xa,-0x38(%rbp)
movl   $0x64,-0x3c(%rbp)
movl   $0x190,-0x40(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1060 <XOpenDisplay@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1238 <main+0x68>
mov    0x2dba(%rip),%rax
mov    (%rax),%edi
lea    0xdd9(%rip),%rsi
call   1070 <fprintf@plt>
xor    %eax,%eax
add    $0x88,%rsp
pop    %rbx
pop    %rbp
ret
mov    -0x18(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x18(%rbp),%rdi
xor    %esi,%esi
call   10a0 <RootWindow@plt>
mov    -0x58(%rbp),%rdi
mov    %eax,%esi
mov    -0x34(%rbp),%edx
mov    -0x38(%rbp),%ecx
mov    -0x40(%rbp),%r8d
mov    -0x3c(%rbp),%r9d
mov    0x2d62(%rip),%rax
mov    (%rax),%r11d
mov    0x2d58(%rip),%rax
mov    (%rax),%r10d
mov    0x2d4e(%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   1090 <XCreateWindow@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x44(%rbp)
mov    -0x18(%rbp),%rdi
xor    %esi,%esi
call   1050 <WhitePixel@plt>
mov    -0x50(%rbp),%rdi
mov    -0x44(%rbp),%esi
mov    %eax,%edx
call   10e0 <XSetWindowBackground@plt>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   10d0 <XMapWindow@plt>
mov    -0x18(%rbp),%rdi
call   10c0 <XFlush@plt>
mov    $0x5,%edi
call   10f0 <sleep@plt>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    $0x258,%edx
mov    $0x96,%ecx
call   1030 <XResizeWindow@plt>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    0x2cb8(%rip),%rax
mov    (%rax),%edx
mov    0x2cbf(%rip),%rax
or     (%rax),%edx
call   10b0 <XSelectInput@plt>
mov    -0x18(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1080 <XNextEvent@plt>
mov    -0x30(%rbp),%eax
mov    %eax,-0x5c(%rbp)
sub    $0x80,%eax
je     135e <main+0x18e>
jmp    134b <main+0x17b>
mov    -0x5c(%rbp),%eax
sub    $0x81,%eax
je     1371 <main+0x1a1>
jmp    13a4 <main+0x1d4>
lea    0xcbc(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    13a4 <main+0x1d4>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x28(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x40(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x34(%rbp),%esi
mov    -0x38(%rbp),%edx
mov    -0x40(%rbp),%ecx
mov    -0x3c(%rbp),%r8d
lea    0xc8d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1328 <main+0x158>

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     1301 <main+0x121>
mov    %rax,%rbx
mov    %rax,%rdi
xor    %esi,%esi
call   10b0 <RootWindow@plt>
mov    0x2dba(%rip),%rcx
mov    (%rcx),%ebp
mov    %rbx,%rdi
mov    %eax,%esi
mov    $0xa,%edx
mov    $0xa,%ecx
mov    $0x190,%r8d
mov    $0x64,%r9d
push   $0x0
push   $0x0
push   %rbp
push   %rbp
push   %rbp
push   $0xa
call   10a0 <XCreateWindow@plt>
add    $0x30,%rsp
mov    %eax,%ebp
mov    %rbx,%rdi
xor    %esi,%esi
call   1060 <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    $0x5,%edi
call   1100 <sleep@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    $0x258,%edx
mov    $0x96,%ecx
call   1030 <XResizeWindow@plt>
mov    0x2d44(%rip),%rax
mov    0x2d4d(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
mov    %rbx,%rdi
mov    %ebp,%esi
call   10c0 <XSelectInput@plt>
mov    %rsp,%rbp
lea    0xd76(%rip),%r14
lea    0xd89(%rip),%r15
jmp    12db <main+0xfb>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0x4(%rsp),%esi
mov    0x8(%rsp),%edx
mov    0xc(%rsp),%ecx
mov    0x10(%rsp),%r8d
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1090 <XNextEvent@plt>
mov    (%rsp),%eax
cmp    $0x81,%eax
je     12c0 <main+0xe0>
cmp    $0x80,%eax
jne    12db <main+0xfb>
mov    %r15,%rdi
call   1040 <puts@plt>
jmp    12db <main+0xfb>
mov    0x2cd0(%rip),%rax
mov    (%rax),%edi
lea    0xcef(%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_5__ = type { i32, %struct.TYPE_4__ }
%struct.TYPE_4__ = type { i32, i32, i32, i32 }
@stderr = global i32 0
@.str = [33 x i8] c"couldn't connect to X server :0\0A\00"
@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 i32*
%3 = alloca i32
%4 = alloca %struct.TYPE_5__
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %1
store i32 10, i32* %5
store i32 10, i32* %6
store i32 100, i32* %7
store i32 400, i32* %8
%9 = call i32* @XOpenDisplay(i32* null)
store i32* %9, i32** %2
%10 = load i32*, i32** %2
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %15
12: ; preds = %0
%13 = load i32, i32* @stderr
%14 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
ret i32 0
15: ; preds = %0
%16 = load i32*, i32** %2
%17 = load i32*, i32** %2
%18 = call i32 @RootWindow(i32* %17, i32 0)
%19 = load i32, i32* %5
%20 = load i32, i32* %6
%21 = load i32, i32* %8
%22 = load i32, i32* %7
%23 = load i32, i32* @CopyFromParent
%24 = load i32, i32* @CopyFromParent
%25 = load i32, i32* @CopyFromParent
%26 = call i32 @XCreateWindow(i32* %16, i32 %18, i32 %19, i32 %20, i32 %21, i32 %22, i32 10, i32 %23, i32 %24, i32 %25, i32 0, i32* null)
store i32 %26, i32* %3
%27 = load i32*, i32** %2
%28 = load i32, i32* %3
%29 = load i32*, i32** %2
%30 = call i32 @WhitePixel(i32* %29, i32 0)
%31 = call i32 @XSetWindowBackground(i32* %27, i32 %28, i32 %30)
%32 = load i32*, i32** %2
%33 = load i32, i32* %3
%34 = call i32 @XMapWindow(i32* %32, i32 %33)
%35 = load i32*, i32** %2
%36 = call i32 @XFlush(i32* %35)
%37 = call i32 @sleep(i32 5)
%38 = load i32*, i32** %2
%39 = load i32, i32* %3
%40 = call i32 @XResizeWindow(i32* %38, i32 %39, i32 600, i32 150)
%41 = load i32*, i32** %2
%42 = load i32, i32* %3
%43 = load i32, i32* @ExposureMask
%44 = load i32, i32* @StructureNotifyMask
%45 = or i32 %43, %44
%46 = call i32 @XSelectInput(i32* %41, i32 %42, i32 %45)
br label %47
47: ; preds = %15, %72
%48 = load i32*, i32** %2
%49 = call i32 @XNextEvent(i32* %48, %struct.TYPE_5__* %4)
%50 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %4, i32 0, i32 0
%51 = load i32, i32* %50
switch i32 %51, label %72 [
i32 128, label %52
i32 129, label %54
]
52: ; preds = %47
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
br label %72
54: ; preds = %47
%55 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %4, i32 0, i32 1
%56 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %55, i32 0, i32 0
%57 = load i32, i32* %56
store i32 %57, i32* %5
%58 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %4, i32 0, i32 1
%59 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %58, i32 0, i32 1
%60 = load i32, i32* %59
store i32 %60, i32* %6
%61 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %4, i32 0, i32 1
%62 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %61, i32 0, i32 2
%63 = load i32, i32* %62
store i32 %63, i32* %8
%64 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %4, i32 0, i32 1
%65 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %64, i32 0, i32 3
%66 = load i32, i32* %65
store i32 %66, i32* %7
%67 = load i32, i32* %5
%68 = load i32, i32* %6
%69 = load i32, i32* %8
%70 = load i32, i32* %7
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i32 %67, i32 %68, i32 %69, i32 %70)
br label %72
72: ; preds = %47, %54, %52
br label %47
}

LLVM IR (-O2):
%struct.TYPE_5__ = type { i32, %struct.TYPE_4__ }
%struct.TYPE_4__ = type { i32, i32, i32, i32 }
@stderr = global i32 0
@.str = [33 x i8] c"couldn't connect to X server :0\0A\00"
@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_5__
%2 = bitcast %struct.TYPE_5__* %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 = tail call i32 @RootWindow(i32* %3, i32 0)
%10 = load i32, i32* @CopyFromParent
%11 = tail call i32 @XCreateWindow(i32* %3, i32 %9, i32 10, i32 10, i32 400, i32 100, i32 10, i32 %10, i32 %10, i32 %10, i32 0, i32* null)
%12 = tail call i32 @WhitePixel(i32* %3, i32 0)
%13 = tail call i32 @XSetWindowBackground(i32* %3, i32 %11, i32 %12)
%14 = tail call i32 @XMapWindow(i32* %3, i32 %11)
%15 = tail call i32 @XFlush(i32* %3)
%16 = tail call i32 @sleep(i32 5)
%17 = tail call i32 @XResizeWindow(i32* %3, i32 %11, i32 600, i32 150)
%18 = load i32, i32* @ExposureMask
%19 = load i32, i32* @StructureNotifyMask
%20 = or i32 %19, %18
%21 = tail call i32 @XSelectInput(i32* %3, i32 %11, i32 %20)
%22 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %1, i64 0, i32 0
%23 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %1, i64 0, i32 1, i32 0
%24 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %1, i64 0, i32 1, i32 1
%25 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %1, i64 0, i32 1, i32 2
%26 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %1, i64 0, i32 1, i32 3
br label %27
27: ; preds = %30, %8
%28 = call i32 @XNextEvent(i32* %3, %struct.TYPE_5__* %1)
%29 = load i32, i32* %22
switch i32 %29, label %30 [
i32 128, label %31
i32 129, label %33
]
30: ; preds = %27, %33, %31
br label %27
31: ; preds = %27
%32 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str, i64 0, i64 0))
br label %30
33: ; preds = %27
%34 = load i32, i32* %23
%35 = load i32, i32* %24
%36 = load i32, i32* %25
%37 = load i32, i32* %26
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i32 %34, i32 %35, i32 %36, i32 %37)
br label %30
}