#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 */

/* Type definitions */
typedef int /*<<< orphan*/ XEvent;
typedef int /*<<< orphan*/ Window;
typedef int /*<<< orphan*/ Display;

/* Variables and functions */
int /*<<< orphan*/ BlackPixel(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ CopyFromParent;
int /*<<< orphan*/ False;
int /*<<< orphan*/ RootWindow(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ WhitePixel(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ XCreateWindow(int /*<<< orphan*/ *, int /*<<< orphan*/,
                                 int /*<<< orphan*/, int /*<<< orphan*/, int,
                                 int, int, int /*<<< orphan*/,
                                 int /*<<< orphan*/, int /*<<< orphan*/,
                                 int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ XDestroyWindow(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ XFlush(int /*<<< orphan*/ *);
int /*<<< orphan*/ XMapWindow(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ *XOpenDisplay(int /*<<< orphan*/ *);
int /*<<< orphan*/ XSetTransientForHint(int /*<<< orphan*/ *,
                                        int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ XSetWindowBackground(int /*<<< orphan*/ *,
                                        int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ XSync(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ usleep(int);
int main() {
  Display *display;
  Window one, two;
  XEvent report;
  display = XOpenDisplay(NULL);
  if (display == NULL) {
    fprintf(stderr, "couldn't connect to X server :0\n");
    return 0;
  }
  one = XCreateWindow(display, RootWindow(display, 0), 0, 0, 200, 200, 10,
                      CopyFromParent, CopyFromParent, CopyFromParent, 0, 0);
  two = XCreateWindow(display, RootWindow(display, 0), 0, 0, 150, 150, 10,
                      CopyFromParent, CopyFromParent, CopyFromParent, 0, 0);
  XSetWindowBackground(display, one, WhitePixel(display, 0));
  XSetWindowBackground(display, two, BlackPixel(display, 0));
  XSetTransientForHint(display, two, one);
  XMapWindow(display, one);
  XFlush(display);
  usleep(1000);
  XMapWindow(display, two);
  XFlush(display);
  usleep(1000);
  XDestroyWindow(display, two);
  XFlush(display);
  usleep(1000);
  XDestroyWindow(display, one);
  XSync(display, False);
  return 1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1060 <XOpenDisplay@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    121b <main+0x4b>
mov    0x2dd7(%rip),%rax
mov    (%rax),%edi
lea    0xdf6(%rip),%rsi
call   1070 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    13da <main+0x20a>
mov    -0x10(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
call   10a0 <RootWindow@plt>
mov    -0x48(%rbp),%rdi
mov    %eax,%esi
mov    0x2d95(%rip),%rax
mov    (%rax),%r11d
mov    0x2d8b(%rip),%rax
mov    (%rax),%r10d
mov    0x2d81(%rip),%rax
mov    (%rax),%eax
xor    %ecx,%ecx
mov    $0xc8,%r9d
mov    %ecx,%edx
mov    %r9d,%r8d
movl   $0xa,(%rsp)
mov    %r11d,0x8(%rsp)
mov    %r10d,0x10(%rsp)
mov    %eax,0x18(%rsp)
movl   $0x0,0x20(%rsp)
movl   $0x0,0x28(%rsp)
call   1080 <XCreateWindow@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
call   10a0 <RootWindow@plt>
mov    -0x40(%rbp),%rdi
mov    %eax,%esi
mov    0x2d25(%rip),%rax
mov    (%rax),%r11d
mov    0x2d1b(%rip),%rax
mov    (%rax),%r10d
mov    0x2d11(%rip),%rax
mov    (%rax),%eax
xor    %ecx,%ecx
mov    $0x96,%r9d
mov    %ecx,%edx
mov    %r9d,%r8d
movl   $0xa,(%rsp)
mov    %r11d,0x8(%rsp)
mov    %r10d,0x10(%rsp)
mov    %eax,0x18(%rsp)
movl   $0x0,0x20(%rsp)
movl   $0x0,0x28(%rsp)
call   1080 <XCreateWindow@plt>
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
call   1040 <WhitePixel@plt>
mov    -0x38(%rbp),%rdi
mov    -0x2c(%rbp),%esi
mov    %eax,%edx
call   10e0 <XSetWindowBackground@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
call   10b0 <BlackPixel@plt>
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%esi
mov    %eax,%edx
call   10e0 <XSetWindowBackground@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1030 <XSetTransientForHint@plt>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   10d0 <XMapWindow@plt>
mov    -0x10(%rbp),%rdi
call   10c0 <XFlush@plt>
mov    $0x3e8,%edi
call   10f0 <usleep@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%esi
call   10d0 <XMapWindow@plt>
mov    -0x10(%rbp),%rdi
call   10c0 <XFlush@plt>
mov    $0x3e8,%edi
call   10f0 <usleep@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%esi
call   1050 <XDestroyWindow@plt>
mov    -0x10(%rbp),%rdi
call   10c0 <XFlush@plt>
mov    $0x3e8,%edi
call   10f0 <usleep@plt>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1050 <XDestroyWindow@plt>
mov    -0x10(%rbp),%rdi
mov    0x2c1c(%rip),%rax
mov    (%rax),%esi
call   1090 <XSync@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
xor    %ebp,%ebp
xor    %edi,%edi
call   1060 <XOpenDisplay@plt>
test   %rax,%rax
je     1312 <main+0x142>
mov    %rax,%rbx
mov    %rax,%rdi
xor    %esi,%esi
call   10a0 <RootWindow@plt>
mov    0x2dd3(%rip),%r15
mov    (%r15),%ebp
mov    %rbx,%rdi
mov    %eax,%esi
xor    %edx,%edx
xor    %ecx,%ecx
mov    $0xc8,%r8d
mov    $0xc8,%r9d
push   $0x0
push   $0x0
push   %rbp
push   %rbp
push   %rbp
push   $0xa
call   1080 <XCreateWindow@plt>
add    $0x30,%rsp
mov    %eax,%r14d
mov    %rbx,%rdi
xor    %esi,%esi
call   10a0 <RootWindow@plt>
mov    (%r15),%ebp
mov    %rbx,%rdi
mov    %eax,%esi
xor    %edx,%edx
xor    %ecx,%ecx
mov    $0x96,%r8d
mov    $0x96,%r9d
push   $0x0
push   $0x0
push   %rbp
push   %rbp
push   %rbp
push   $0xa
call   1080 <XCreateWindow@plt>
add    $0x30,%rsp
mov    %eax,%ebp
mov    %rbx,%rdi
xor    %esi,%esi
call   1040 <WhitePixel@plt>
mov    %rbx,%rdi
mov    %r14d,%esi
mov    %eax,%edx
call   10e0 <XSetWindowBackground@plt>
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
mov    %r14d,%edx
call   1030 <XSetTransientForHint@plt>
mov    %rbx,%rdi
mov    %r14d,%esi
call   10d0 <XMapWindow@plt>
mov    %rbx,%rdi
call   10c0 <XFlush@plt>
mov    $0x3e8,%edi
call   10f0 <usleep@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
call   10d0 <XMapWindow@plt>
mov    %rbx,%rdi
call   10c0 <XFlush@plt>
mov    $0x3e8,%edi
call   10f0 <usleep@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
call   1050 <XDestroyWindow@plt>
mov    %rbx,%rdi
call   10c0 <XFlush@plt>
mov    $0x3e8,%edi
call   10f0 <usleep@plt>
mov    %rbx,%rdi
mov    %r14d,%esi
call   1050 <XDestroyWindow@plt>
mov    0x2ce7(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1090 <XSync@plt>
mov    $0x1,%ebp
jmp    1327 <main+0x157>
mov    0x2cbf(%rip),%rax
mov    (%rax),%edi
lea    0xcde(%rip),%rsi
call   1070 <fprintf@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [33 x i8] c"couldn't connect to X server :0\0A\00"
@CopyFromParent = global i32 0
@False = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = call i32* @XOpenDisplay(i32* null)
store i32* %6, i32** %2
%7 = load i32*, i32** %2
%8 = icmp eq i32* %7, null
br i1 %8, label %9, label %12
9: ; preds = %0
%10 = load i32, i32* @stderr
%11 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %1
br label %65
12: ; preds = %0
%13 = load i32*, i32** %2
%14 = load i32*, i32** %2
%15 = call i32 @RootWindow(i32* %14, i32 0)
%16 = load i32, i32* @CopyFromParent
%17 = load i32, i32* @CopyFromParent
%18 = load i32, i32* @CopyFromParent
%19 = call i32 @XCreateWindow(i32* %13, i32 %15, i32 0, i32 0, i32 200, i32 200, i32 10, i32 %16, i32 %17, i32 %18, i32 0, i32 0)
store i32 %19, i32* %3
%20 = load i32*, i32** %2
%21 = load i32*, i32** %2
%22 = call i32 @RootWindow(i32* %21, i32 0)
%23 = load i32, i32* @CopyFromParent
%24 = load i32, i32* @CopyFromParent
%25 = load i32, i32* @CopyFromParent
%26 = call i32 @XCreateWindow(i32* %20, i32 %22, i32 0, i32 0, i32 150, i32 150, i32 10, i32 %23, i32 %24, i32 %25, i32 0, i32 0)
store i32 %26, i32* %4
%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* %4
%34 = load i32*, i32** %2
%35 = call i32 @BlackPixel(i32* %34, i32 0)
%36 = call i32 @XSetWindowBackground(i32* %32, i32 %33, i32 %35)
%37 = load i32*, i32** %2
%38 = load i32, i32* %4
%39 = load i32, i32* %3
%40 = call i32 @XSetTransientForHint(i32* %37, i32 %38, i32 %39)
%41 = load i32*, i32** %2
%42 = load i32, i32* %3
%43 = call i32 @XMapWindow(i32* %41, i32 %42)
%44 = load i32*, i32** %2
%45 = call i32 @XFlush(i32* %44)
%46 = call i32 @usleep(i32 1000)
%47 = load i32*, i32** %2
%48 = load i32, i32* %4
%49 = call i32 @XMapWindow(i32* %47, i32 %48)
%50 = load i32*, i32** %2
%51 = call i32 @XFlush(i32* %50)
%52 = call i32 @usleep(i32 1000)
%53 = load i32*, i32** %2
%54 = load i32, i32* %4
%55 = call i32 @XDestroyWindow(i32* %53, i32 %54)
%56 = load i32*, i32** %2
%57 = call i32 @XFlush(i32* %56)
%58 = call i32 @usleep(i32 1000)
%59 = load i32*, i32** %2
%60 = load i32, i32* %3
%61 = call i32 @XDestroyWindow(i32* %59, i32 %60)
%62 = load i32*, i32** %2
%63 = load i32, i32* @False
%64 = call i32 @XSync(i32* %62, i32 %63)
store i32 1, i32* %1
br label %65
65: ; preds = %12, %9
%66 = load i32, i32* %1
ret i32 %66
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [33 x i8] c"couldn't connect to X server :0\0A\00"
@CopyFromParent = global i32 0
@False = global i32 0
define i32 @main() {
%1 = tail call i32* @XOpenDisplay(i32* null)
%2 = icmp eq i32* %1, null
br i1 %2, label %3, label %6
3: ; preds = %0
%4 = load i32, i32* @stderr
%5 = tail call i32 @fprintf(i32 %4, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
br label %30
6: ; preds = %0
%7 = tail call i32 @RootWindow(i32* %1, i32 0)
%8 = load i32, i32* @CopyFromParent
%9 = tail call i32 @XCreateWindow(i32* %1, i32 %7, i32 0, i32 0, i32 200, i32 200, i32 10, i32 %8, i32 %8, i32 %8, i32 0, i32 0)
%10 = tail call i32 @RootWindow(i32* %1, i32 0)
%11 = load i32, i32* @CopyFromParent
%12 = tail call i32 @XCreateWindow(i32* %1, i32 %10, i32 0, i32 0, i32 150, i32 150, i32 10, i32 %11, i32 %11, i32 %11, i32 0, i32 0)
%13 = tail call i32 @WhitePixel(i32* %1, i32 0)
%14 = tail call i32 @XSetWindowBackground(i32* %1, i32 %9, i32 %13)
%15 = tail call i32 @BlackPixel(i32* %1, i32 0)
%16 = tail call i32 @XSetWindowBackground(i32* %1, i32 %12, i32 %15)
%17 = tail call i32 @XSetTransientForHint(i32* %1, i32 %12, i32 %9)
%18 = tail call i32 @XMapWindow(i32* %1, i32 %9)
%19 = tail call i32 @XFlush(i32* %1)
%20 = tail call i32 @usleep(i32 1000)
%21 = tail call i32 @XMapWindow(i32* %1, i32 %12)
%22 = tail call i32 @XFlush(i32* %1)
%23 = tail call i32 @usleep(i32 1000)
%24 = tail call i32 @XDestroyWindow(i32* %1, i32 %12)
%25 = tail call i32 @XFlush(i32* %1)
%26 = tail call i32 @usleep(i32 1000)
%27 = tail call i32 @XDestroyWindow(i32* %1, i32 %9)
%28 = load i32, i32* @False
%29 = tail call i32 @XSync(i32* %1, i32 %28)
br label %30
30: ; preds = %6, %3
%31 = phi i32 [ 0, %3 ], [ 1, %6 ]
ret i32 %31
}