#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*/ 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,
                                 int, 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*/ XSetWindowBackground(int /*<<< orphan*/ *,
                                        int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ XSync(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ usleep(int);
int main() {
  Display *display;
  Window win;
  XEvent report;
  XEvent msg;
  int x = 50, y = 50, h = 100, w = 400;
  display = XOpenDisplay(NULL);
  if (display == NULL) {
    fprintf(stderr, "couldn't connect to X server :0\n");
    return 0;
  }
  while (1) {
    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);
    usleep(1000);
    XDestroyWindow(display, win);
    XSync(display, False);
    break;
    sleep(2);
  }
  return 1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
sub    $0x78,%rsp
movl   $0x0,-0xc(%rbp)
movl   $0x32,-0x28(%rbp)
movl   $0x32,-0x2c(%rbp)
movl   $0x64,-0x30(%rbp)
movl   $0x190,-0x34(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1050 <XOpenDisplay@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1215 <main+0x65>
mov    0x2ddd(%rip),%rax
mov    (%rax),%edi
lea    0xdfc(%rip),%rsi
call   1060 <fprintf@plt>
movl   $0x0,-0xc(%rbp)
jmp    12fb <main+0x14b>
jmp    121a <main+0x6a>
mov    -0x18(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x18(%rbp),%rdi
xor    %esi,%esi
call   1090 <RootWindow@plt>
mov    -0x48(%rbp),%rdi
mov    %eax,%esi
mov    -0x28(%rbp),%edx
mov    -0x2c(%rbp),%ecx
mov    -0x34(%rbp),%r8d
mov    -0x30(%rbp),%r9d
mov    0x2d88(%rip),%rax
mov    (%rax),%r11d
mov    0x2d7e(%rip),%rax
mov    (%rax),%r10d
mov    0x2d74(%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)
mov    -0x18(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    -0x18(%rbp),%rdi
xor    %esi,%esi
call   1030 <WhitePixel@plt>
mov    -0x40(%rbp),%rdi
mov    -0x38(%rbp),%esi
mov    %eax,%edx
call   10c0 <XSetWindowBackground@plt>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   10b0 <XMapWindow@plt>
mov    -0x18(%rbp),%rdi
call   10a0 <XFlush@plt>
mov    $0x3e8,%edi
call   10d0 <usleep@plt>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1040 <XDestroyWindow@plt>
mov    -0x18(%rbp),%rdi
mov    0x2cfb(%rip),%rax
mov    (%rax),%esi
call   1080 <XSync@plt>
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0x78,%rsp
pop    %rbx
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
xor    %r14d,%r14d
xor    %edi,%edi
call   1050 <XOpenDisplay@plt>
test   %rax,%rax
je     1261 <main+0xb1>
mov    %rax,%rbx
mov    %rax,%rdi
xor    %esi,%esi
call   1090 <RootWindow@plt>
mov    0x2df5(%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   1070 <XCreateWindow@plt>
add    $0x30,%rsp
mov    %eax,%ebp
mov    %rbx,%rdi
xor    %esi,%esi
call   1030 <WhitePixel@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %eax,%edx
call   10c0 <XSetWindowBackground@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
call   10b0 <XMapWindow@plt>
mov    %rbx,%rdi
call   10a0 <XFlush@plt>
mov    $0x3e8,%edi
call   10d0 <usleep@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
call   1040 <XDestroyWindow@plt>
mov    0x2d99(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1080 <XSync@plt>
mov    $0x1,%r14d
jmp    1276 <main+0xc6>
mov    0x2d70(%rip),%rax
mov    (%rax),%edi
lea    0xd8f(%rip),%rsi
call   1060 <fprintf@plt>
mov    %r14d,%eax
pop    %rbx
pop    %r14
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
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
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
%10 = call i32* @XOpenDisplay(i32* null)
store i32* %10, i32** %2
%11 = load i32*, i32** %2
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %16
13: ; preds = %0
%14 = load i32, i32* @stderr
%15 = call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %1
br label %47
16: ; preds = %0
br label %17
17: ; preds = %16
%18 = load i32*, i32** %2
%19 = load i32*, i32** %2
%20 = call i32 @RootWindow(i32* %19, i32 0)
%21 = load i32, i32* %6
%22 = load i32, i32* %7
%23 = load i32, i32* %9
%24 = load i32, i32* %8
%25 = load i32, i32* @CopyFromParent
%26 = load i32, i32* @CopyFromParent
%27 = load i32, i32* @CopyFromParent
%28 = call i32 @XCreateWindow(i32* %18, i32 %20, i32 %21, i32 %22, i32 %23, i32 %24, i32 10, i32 %25, i32 %26, i32 %27, i32 0, i32* null)
store i32 %28, i32* %3
%29 = load i32*, i32** %2
%30 = load i32, i32* %3
%31 = load i32*, i32** %2
%32 = call i32 @WhitePixel(i32* %31, i32 0)
%33 = call i32 @XSetWindowBackground(i32* %29, i32 %30, i32 %32)
%34 = load i32*, i32** %2
%35 = load i32, i32* %3
%36 = call i32 @XMapWindow(i32* %34, i32 %35)
%37 = load i32*, i32** %2
%38 = call i32 @XFlush(i32* %37)
%39 = call i32 @usleep(i32 1000)
%40 = load i32*, i32** %2
%41 = load i32, i32* %3
%42 = call i32 @XDestroyWindow(i32* %40, i32 %41)
%43 = load i32*, i32** %2
%44 = load i32, i32* @False
%45 = call i32 @XSync(i32* %43, i32 %44)
br label %46
46: ; preds = %17
store i32 1, i32* %1
br label %47
47: ; preds = %46, %13
%48 = load i32, i32* %1
ret i32 %48
}

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 %18
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 50, i32 50, i32 400, i32 100, i32 10, i32 %8, i32 %8, i32 %8, i32 0, i32* null)
%10 = tail call i32 @WhitePixel(i32* %1, i32 0)
%11 = tail call i32 @XSetWindowBackground(i32* %1, i32 %9, i32 %10)
%12 = tail call i32 @XMapWindow(i32* %1, i32 %9)
%13 = tail call i32 @XFlush(i32* %1)
%14 = tail call i32 @usleep(i32 1000)
%15 = tail call i32 @XDestroyWindow(i32* %1, i32 %9)
%16 = load i32, i32* @False
%17 = tail call i32 @XSync(i32* %1, i32 %16)
br label %18
18: ; preds = %6, %3
%19 = phi i32 [ 0, %3 ], [ 1, %6 ]
ret i32 %19
}