#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 */
typedef int /*<<< orphan*/ XWMHints;
struct TYPE_7__ {
  int x;
  int y;
  int width;
  int height;
};
typedef TYPE_2__ XRectangle;
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 */
int /*<<< orphan*/ BlackPixel(int /*<<< orphan*/ *, int /*<<< orphan*/);
#define ConfigureNotify 129
int /*<<< orphan*/ CopyFromParent;
#define Expose 128
int /*<<< orphan*/ RootWindow(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ ShapeBounding;
int /*<<< orphan*/ ShapeSet;
int /*<<< orphan*/ Unsorted;
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_3__ *);
int /*<<< orphan*/ *XOpenDisplay(int /*<<< orphan*/ *);
int /*<<< orphan*/ XSetWindowBackground(int /*<<< orphan*/ *,
                                        int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/
XShapeCombineRectangles(int /*<<< orphan*/ *, int /*<<< orphan*/,
                        int /*<<< orphan*/, int /*<<< orphan*/,
                        int /*<<< orphan*/, TYPE_2__ *, int, 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;
  XEvent msg;
  int x = 50, y = 50, h = 100, w = 400;
  XWMHints hint;
  XRectangle xrect;
  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);
  xrect.x = 10;
  xrect.y = 10;
  xrect.width = w - 20;
  xrect.height = h - 20;
  XShapeCombineRectangles(display, win, ShapeBounding, 0, 0, &xrect, 1,
                          ShapeSet, Unsorted);
  XSetWindowBackground(display, win, BlackPixel(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    $0xb8,%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   1040 <XOpenDisplay@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1218 <main+0x68>
mov    0x2dca(%rip),%rax
mov    (%rax),%edi
lea    0xdf9(%rip),%rsi
call   1050 <fprintf@plt>
xor    %eax,%eax
add    $0xb8,%rsp
pop    %rbx
pop    %rbp
ret
mov    -0x18(%rbp),%rax
mov    %rax,-0x88(%rbp)
mov    -0x18(%rbp),%rdi
xor    %esi,%esi
call   1080 <RootWindow@plt>
mov    -0x88(%rbp),%rdi
mov    %eax,%esi
mov    -0x4c(%rbp),%edx
mov    -0x50(%rbp),%ecx
mov    -0x58(%rbp),%r8d
mov    -0x54(%rbp),%r9d
mov    0x2d74(%rip),%rax
mov    (%rax),%r11d
mov    0x2d6a(%rip),%rax
mov    (%rax),%r10d
mov    0x2d60(%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   1070 <XCreateWindow@plt>
mov    %eax,-0x1c(%rbp)
movl   $0xa,-0x70(%rbp)
movl   $0xa,-0x6c(%rbp)
mov    -0x58(%rbp),%eax
sub    $0x14,%eax
mov    %eax,-0x68(%rbp)
mov    -0x54(%rbp),%eax
sub    $0x14,%eax
mov    %eax,-0x64(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    0x2d1e(%rip),%rax
mov    (%rax),%edx
mov    0x2d1d(%rip),%rax
mov    (%rax),%r10d
mov    0x2d03(%rip),%rax
mov    (%rax),%eax
xor    %r8d,%r8d
lea    -0x70(%rbp),%r9
mov    %r8d,%ecx
movl   $0x1,(%rsp)
mov    %r10d,0x8(%rsp)
mov    %eax,0x10(%rsp)
call   1090 <XShapeCombineRectangles@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x80(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x74(%rbp)
mov    -0x18(%rbp),%rdi
xor    %esi,%esi
call   10a0 <BlackPixel@plt>
mov    -0x80(%rbp),%rdi
mov    -0x74(%rbp),%esi
mov    %eax,%edx
call   10d0 <XSetWindowBackground@plt>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   10c0 <XMapWindow@plt>
mov    -0x18(%rbp),%rdi
call   10b0 <XFlush@plt>
mov    -0x18(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1060 <XNextEvent@plt>
mov    -0x30(%rbp),%eax
mov    %eax,-0x8c(%rbp)
sub    $0x80,%eax
je     136e <main+0x1be>
jmp    1358 <main+0x1a8>
mov    -0x8c(%rbp),%eax
sub    $0x81,%eax
je     1381 <main+0x1d1>
jmp    13b4 <main+0x204>
lea    0xcac(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    13b4 <main+0x204>
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    0xc7d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1332 <main+0x182>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x38,%rsp
xor    %edi,%edi
call   1050 <XOpenDisplay@plt>
test   %rax,%rax
je     12f2 <main+0x132>
mov    %rax,%rbx
mov    %rax,%rdi
xor    %esi,%esi
call   1090 <RootWindow@plt>
mov    0x2dd2(%rip),%rcx
mov    (%rcx),%ebp
mov    %rbx,%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   1080 <XCreateWindow@plt>
add    $0x30,%rsp
mov    %eax,%ebp
movaps 0xdda(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
mov    0x2dae(%rip),%rax
mov    (%rax),%edx
mov    0x2dad(%rip),%rax
mov    (%rax),%r10d
mov    0x2d93(%rip),%rcx
mov    (%rcx),%eax
sub    $0x8,%rsp
lea    0x28(%rsp),%r9
mov    %rbx,%rdi
mov    %ebp,%esi
xor    %ecx,%ecx
xor    %r8d,%r8d
push   %rax
push   %r10
push   $0x1
call   10a0 <XShapeCombineRectangles@plt>
add    $0x20,%rsp
mov    %rbx,%rdi
xor    %esi,%esi
call   10b0 <BlackPixel@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %eax,%edx
call   10e0 <XSetWindowBackground@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
call   10d0 <XMapWindow@plt>
mov    %rbx,%rdi
call   10c0 <XFlush@plt>
lea    0x8(%rsp),%rbp
lea    0xd95(%rip),%r14
lea    0xda8(%rip),%r15
jmp    12cb <main+0x10b>
cs nopw 0x0(%rax,%rax,1)
nop
mov    0xc(%rsp),%esi
mov    0x10(%rsp),%edx
mov    0x14(%rsp),%ecx
mov    0x18(%rsp),%r8d
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1070 <XNextEvent@plt>
mov    0x8(%rsp),%eax
cmp    $0x81,%eax
je     12b0 <main+0xf0>
cmp    $0x80,%eax
jne    12cb <main+0x10b>
mov    %r15,%rdi
call   1030 <puts@plt>
jmp    12cb <main+0x10b>
mov    0x2ccf(%rip),%rax
mov    (%rax),%edi
lea    0xd0e(%rip),%rsi
call   1060 <fprintf@plt>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.TYPE_8__ = type { i32, %struct.TYPE_6__ }
%struct.TYPE_6__ = type { i32, i32, i32, i32 }
%struct.TYPE_7__ = 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
@ShapeBounding = global i32 0
@ShapeSet = global i32 0
@Unsorted = 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_8__
%5 = alloca %struct.TYPE_8__
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca %struct.TYPE_7__
store i32 0, i32* %1
store i32 50, i32* %6
store i32 50, i32* %7
store i32 100, i32* %8
store i32 400, i32* %9
%12 = call i32* @XOpenDisplay(i32* null)
store i32* %12, i32** %2
%13 = load i32*, i32** %2
%14 = icmp eq i32* %13, null
br i1 %14, label %15, label %18
15: ; preds = %0
%16 = load i32, i32* @stderr
%17 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
ret i32 0
18: ; preds = %0
%19 = load i32*, i32** %2
%20 = load i32*, i32** %2
%21 = call i32 @RootWindow(i32* %20, i32 0)
%22 = load i32, i32* %6
%23 = load i32, i32* %7
%24 = load i32, i32* %9
%25 = load i32, i32* %8
%26 = load i32, i32* @CopyFromParent
%27 = load i32, i32* @CopyFromParent
%28 = load i32, i32* @CopyFromParent
%29 = call i32 @XCreateWindow(i32* %19, i32 %21, i32 %22, i32 %23, i32 %24, i32 %25, i32 10, i32 %26, i32 %27, i32 %28, i32 0, i32* null)
store i32 %29, i32* %3
%30 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %11, i32 0, i32 0
store i32 10, i32* %30
%31 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %11, i32 0, i32 1
store i32 10, i32* %31
%32 = load i32, i32* %9
%33 = sub nsw i32 %32, 20
%34 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %11, i32 0, i32 2
store i32 %33, i32* %34
%35 = load i32, i32* %8
%36 = sub nsw i32 %35, 20
%37 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %11, i32 0, i32 3
store i32 %36, i32* %37
%38 = load i32*, i32** %2
%39 = load i32, i32* %3
%40 = load i32, i32* @ShapeBounding
%41 = load i32, i32* @ShapeSet
%42 = load i32, i32* @Unsorted
%43 = call i32 @XShapeCombineRectangles(i32* %38, i32 %39, i32 %40, i32 0, i32 0, %struct.TYPE_7__* %11, i32 1, i32 %41, i32 %42)
%44 = load i32*, i32** %2
%45 = load i32, i32* %3
%46 = load i32*, i32** %2
%47 = call i32 @BlackPixel(i32* %46, i32 0)
%48 = call i32 @XSetWindowBackground(i32* %44, i32 %45, i32 %47)
%49 = load i32*, i32** %2
%50 = load i32, i32* %3
%51 = call i32 @XMapWindow(i32* %49, i32 %50)
%52 = load i32*, i32** %2
%53 = call i32 @XFlush(i32* %52)
br label %54
54: ; preds = %18, %79
%55 = load i32*, i32** %2
%56 = call i32 @XNextEvent(i32* %55, %struct.TYPE_8__* %4)
%57 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %4, i32 0, i32 0
%58 = load i32, i32* %57
switch i32 %58, label %79 [
i32 128, label %59
i32 129, label %61
]
59: ; preds = %54
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
br label %79
61: ; preds = %54
%62 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %4, i32 0, i32 1
%63 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %62, i32 0, i32 0
%64 = load i32, i32* %63
store i32 %64, i32* %6
%65 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %4, i32 0, i32 1
%66 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %65, i32 0, i32 1
%67 = load i32, i32* %66
store i32 %67, i32* %7
%68 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %4, i32 0, i32 1
%69 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %68, i32 0, i32 2
%70 = load i32, i32* %69
store i32 %70, i32* %9
%71 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %4, i32 0, i32 1
%72 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %71, i32 0, i32 3
%73 = load i32, i32* %72
store i32 %73, i32* %8
%74 = load i32, i32* %6
%75 = load i32, i32* %7
%76 = load i32, i32* %9
%77 = load i32, i32* %8
%78 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i32 %74, i32 %75, i32 %76, i32 %77)
br label %79
79: ; preds = %54, %61, %59
br label %54
}

LLVM IR (-O2):
%struct.TYPE_8__ = type { i32, %struct.TYPE_6__ }
%struct.TYPE_6__ = type { i32, i32, i32, i32 }
%struct.TYPE_7__ = 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
@ShapeBounding = global i32 0
@ShapeSet = global i32 0
@Unsorted = 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_8__
%2 = alloca <4 x i32>
%3 = bitcast %struct.TYPE_8__* %1 to i8*
%4 = bitcast <4 x i32>* %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 = bitcast <4 x i32>* %2 to %struct.TYPE_7__*
%12 = tail call i32 @RootWindow(i32* %5, i32 0)
%13 = load i32, i32* @CopyFromParent
%14 = tail call i32 @XCreateWindow(i32* %5, i32 %12, i32 50, i32 50, i32 400, i32 100, i32 10, i32 %13, i32 %13, i32 %13, i32 0, i32* null)
store <4 x i32> <i32 10, i32 10, i32 380, i32 80>, <4 x i32>* %2
%15 = load i32, i32* @ShapeBounding
%16 = load i32, i32* @ShapeSet
%17 = load i32, i32* @Unsorted
%18 = call i32 @XShapeCombineRectangles(i32* %5, i32 %14, i32 %15, i32 0, i32 0, %struct.TYPE_7__* %11, i32 1, i32 %16, i32 %17)
%19 = call i32 @BlackPixel(i32* %5, i32 0)
%20 = call i32 @XSetWindowBackground(i32* %5, i32 %14, i32 %19)
%21 = call i32 @XMapWindow(i32* %5, i32 %14)
%22 = call i32 @XFlush(i32* %5)
%23 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %1, i64 0, i32 0
%24 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %1, i64 0, i32 1, i32 0
%25 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %1, i64 0, i32 1, i32 1
%26 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %1, i64 0, i32 1, i32 2
%27 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %1, i64 0, i32 1, i32 3
br label %28
28: ; preds = %31, %10
%29 = call i32 @XNextEvent(i32* %5, %struct.TYPE_8__* %1)
%30 = load i32, i32* %23
switch i32 %30, label %31 [
i32 128, label %32
i32 129, label %34
]
31: ; preds = %28, %34, %32
br label %28
32: ; preds = %28
%33 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str, i64 0, i64 0))
br label %31
34: ; preds = %28
%35 = load i32, i32* %24
%36 = load i32, i32* %25
%37 = load i32, i32* %26
%38 = load i32, i32* %27
%39 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i32 %35, i32 %36, i32 %37, i32 %38)
br label %31
}