#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_3__ TYPE_1__;

/* Type definitions */
struct TYPE_3__ {
  scalar_t__ type;
};
typedef TYPE_1__ XEvent;
typedef int /*<<< orphan*/ Window;
typedef int /*<<< orphan*/ GC;
typedef int /*<<< orphan*/ Display;

/* Variables and functions */
int BlackPixel(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ DefaultRootWindow(int /*<<< orphan*/ *);
int /*<<< orphan*/ DefaultScreen(int /*<<< orphan*/ *);
scalar_t__ MapNotify;
int /*<<< orphan*/ StructureNotifyMask;
int WhitePixel(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ XCreateGC(int /*<<< orphan*/ *, int /*<<< orphan*/,
                             int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ XCreateSimpleWindow(int /*<<< orphan*/ *, int /*<<< orphan*/,
                                       int /*<<< orphan*/, int /*<<< orphan*/,
                                       int, int, int /*<<< orphan*/, int, int);
int /*<<< orphan*/ XDrawLine(int /*<<< orphan*/ *, int /*<<< orphan*/,
                             int /*<<< orphan*/, int, int, int, int);
int /*<<< orphan*/ XFlush(int /*<<< orphan*/ *);
int /*<<< orphan*/ XMapWindow(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ XNextEvent(int /*<<< orphan*/ *, TYPE_1__ *);
int /*<<< orphan*/ *XOpenDisplay(int /*<<< orphan*/);
int /*<<< orphan*/ XSelectInput(int /*<<< orphan*/ *, int /*<<< orphan*/,
                                int /*<<< orphan*/);
int /*<<< orphan*/ XSetForeground(int /*<<< orphan*/ *, int /*<<< orphan*/,
                                  int);
int /*<<< orphan*/ assert(int /*<<< orphan*/ *);
int /*<<< orphan*/ sleep(int);
main() {
  Display *dpy = XOpenDisplay((0));
  assert(dpy);
  int blackColor = BlackPixel(dpy, DefaultScreen(dpy));
  int whiteColor = WhitePixel(dpy, DefaultScreen(dpy));
  Window w = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy), 0, 0, 200, 100, 0,
                                 whiteColor, blackColor);
  XSelectInput(dpy, w, StructureNotifyMask);
  XMapWindow(dpy, w);
  GC gc = XCreateGC(dpy, w, 0, (0));
  XSetForeground(dpy, gc, whiteColor);
  for (;;) {
    XEvent e;
    XNextEvent(dpy, &e);
    if (e.type == MapNotify)
      break;
  }
  XDrawLine(dpy, w, gc, 10, 60, 180, 20);
  XFlush(dpy);
  sleep(10);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
xor    %edi,%edi
call   1050 <XOpenDisplay@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <assert@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x10(%rbp),%rdi
call   10f0 <DefaultScreen@plt>
mov    -0x40(%rbp),%rdi
mov    %eax,%esi
call   10b0 <BlackPixel@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
call   10f0 <DefaultScreen@plt>
mov    -0x38(%rbp),%rdi
mov    %eax,%esi
call   1040 <WhitePixel@plt>
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <DefaultRootWindow@plt>
mov    -0x30(%rbp),%rdi
mov    %eax,%esi
mov    -0x18(%rbp),%r10d
mov    -0x14(%rbp),%eax
xor    %ecx,%ecx
mov    $0xc8,%r8d
mov    $0x64,%r9d
mov    %ecx,%edx
movl   $0x0,(%rsp)
mov    %r10d,0x8(%rsp)
mov    %eax,0x10(%rsp)
call   10a0 <XCreateSimpleWindow@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    0x2d33(%rip),%rax
mov    (%rax),%edx
call   1080 <XSelectInput@plt>
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   10e0 <XMapWindow@plt>
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%esi
xor    %ecx,%ecx
mov    %ecx,%edx
call   1090 <XCreateGC@plt>
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%esi
mov    -0x18(%rbp),%edx
call   10c0 <XSetForeground@plt>
mov    -0x10(%rbp),%rdi
lea    -0x28(%rbp),%rsi
call   1070 <XNextEvent@plt>
mov    -0x28(%rbp),%rax
mov    0x2cf6(%rip),%rcx
cmp    (%rcx),%rax
jne    1300 <main+0x110>
jmp    1305 <main+0x115>
jmp    12da <main+0xea>
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
mov    $0xa,%ecx
mov    $0x3c,%r8d
mov    $0xb4,%r9d
movl   $0x14,(%rsp)
call   1110 <XDrawLine@plt>
mov    -0x10(%rbp),%rdi
call   10d0 <XFlush@plt>
mov    $0xa,%edi
call   1100 <sleep@plt>
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %edi,%edi
call   1050 <XOpenDisplay@plt>
mov    %rax,%r13
mov    %rax,%rdi
call   1060 <assert@plt>
mov    %r13,%rdi
call   10f0 <DefaultScreen@plt>
mov    %r13,%rdi
mov    %eax,%esi
call   10b0 <BlackPixel@plt>
mov    %eax,%ebp
mov    %r13,%rdi
call   10f0 <DefaultScreen@plt>
mov    %r13,%rdi
mov    %eax,%esi
call   1040 <WhitePixel@plt>
mov    %eax,%r14d
mov    %r13,%rdi
call   1030 <DefaultRootWindow@plt>
sub    $0x8,%rsp
mov    %r13,%rdi
mov    %eax,%esi
xor    %edx,%edx
xor    %ecx,%ecx
mov    $0xc8,%r8d
mov    $0x64,%r9d
push   %rbp
push   %r14
push   $0x0
call   10a0 <XCreateSimpleWindow@plt>
add    $0x20,%rsp
mov    %eax,%r12d
mov    0x2d69(%rip),%rax
mov    (%rax),%edx
mov    %r13,%rdi
mov    %r12d,%esi
call   1080 <XSelectInput@plt>
mov    %r13,%rdi
mov    %r12d,%esi
call   10e0 <XMapWindow@plt>
mov    %r13,%rdi
mov    %r12d,%esi
xor    %edx,%edx
xor    %ecx,%ecx
call   1090 <XCreateGC@plt>
mov    %eax,%r15d
mov    %r13,%rdi
mov    %eax,%esi
mov    %r14d,%edx
call   10c0 <XSetForeground@plt>
mov    %rsp,%rbp
mov    0x2d38(%rip),%rbx
mov    %r13,%rdi
mov    %rbp,%rsi
call   1070 <XNextEvent@plt>
mov    (%rsp),%rax
cmp    (%rbx),%rax
jne    12b0 <main+0xc0>
sub    $0x8,%rsp
mov    %r13,%rdi
mov    %r12d,%esi
mov    %r15d,%edx
mov    $0xa,%ecx
mov    $0x3c,%r8d
mov    $0xb4,%r9d
push   $0x14
call   1110 <XDrawLine@plt>
add    $0x10,%rsp
mov    %r13,%rdi
call   10d0 <XFlush@plt>
mov    $0xa,%edi
call   1100 <sleep@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.TYPE_3__ = type { i64 }
@StructureNotifyMask = global i32 0
@MapNotify = global i64 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca %struct.TYPE_3__
store i32 0, i32* %1
%8 = call i32* @XOpenDisplay(i32 0)
store i32* %8, i32** %2
%9 = load i32*, i32** %2
%10 = call i32 @assert(i32* %9)
%11 = load i32*, i32** %2
%12 = load i32*, i32** %2
%13 = call i32 @DefaultScreen(i32* %12)
%14 = call i32 @BlackPixel(i32* %11, i32 %13)
store i32 %14, i32* %3
%15 = load i32*, i32** %2
%16 = load i32*, i32** %2
%17 = call i32 @DefaultScreen(i32* %16)
%18 = call i32 @WhitePixel(i32* %15, i32 %17)
store i32 %18, i32* %4
%19 = load i32*, i32** %2
%20 = load i32*, i32** %2
%21 = call i32 @DefaultRootWindow(i32* %20)
%22 = load i32, i32* %4
%23 = load i32, i32* %3
%24 = call i32 @XCreateSimpleWindow(i32* %19, i32 %21, i32 0, i32 0, i32 200, i32 100, i32 0, i32 %22, i32 %23)
store i32 %24, i32* %5
%25 = load i32*, i32** %2
%26 = load i32, i32* %5
%27 = load i32, i32* @StructureNotifyMask
%28 = call i32 @XSelectInput(i32* %25, i32 %26, i32 %27)
%29 = load i32*, i32** %2
%30 = load i32, i32* %5
%31 = call i32 @XMapWindow(i32* %29, i32 %30)
%32 = load i32*, i32** %2
%33 = load i32, i32* %5
%34 = call i32 @XCreateGC(i32* %32, i32 %33, i32 0, i32 0)
store i32 %34, i32* %6
%35 = load i32*, i32** %2
%36 = load i32, i32* %6
%37 = load i32, i32* %4
%38 = call i32 @XSetForeground(i32* %35, i32 %36, i32 %37)
br label %39
39: ; preds = %47, %0
%40 = load i32*, i32** %2
%41 = call i32 @XNextEvent(i32* %40, %struct.TYPE_3__* %7)
%42 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %7, i32 0, i32 0
%43 = load i64, i64* %42
%44 = load i64, i64* @MapNotify
%45 = icmp eq i64 %43, %44
br i1 %45, label %46, label %47
46: ; preds = %39
br label %48
47: ; preds = %39
br label %39
48: ; preds = %46
%49 = load i32*, i32** %2
%50 = load i32, i32* %5
%51 = load i32, i32* %6
%52 = call i32 @XDrawLine(i32* %49, i32 %50, i32 %51, i32 10, i32 60, i32 180, i32 20)
%53 = load i32*, i32** %2
%54 = call i32 @XFlush(i32* %53)
%55 = call i32 @sleep(i32 10)
%56 = load i32, i32* %1
ret i32 %56
}

LLVM IR (-O2):
%struct.TYPE_3__ = type { i64 }
@StructureNotifyMask = global i32 0
@MapNotify = global i64 0
define i32 @main() {
%1 = alloca %struct.TYPE_3__
%2 = tail call i32* @XOpenDisplay(i32 0)
%3 = tail call i32 @assert(i32* %2)
%4 = tail call i32 @DefaultScreen(i32* %2)
%5 = tail call i32 @BlackPixel(i32* %2, i32 %4)
%6 = tail call i32 @DefaultScreen(i32* %2)
%7 = tail call i32 @WhitePixel(i32* %2, i32 %6)
%8 = tail call i32 @DefaultRootWindow(i32* %2)
%9 = tail call i32 @XCreateSimpleWindow(i32* %2, i32 %8, i32 0, i32 0, i32 200, i32 100, i32 0, i32 %7, i32 %5)
%10 = load i32, i32* @StructureNotifyMask
%11 = tail call i32 @XSelectInput(i32* %2, i32 %9, i32 %10)
%12 = tail call i32 @XMapWindow(i32* %2, i32 %9)
%13 = tail call i32 @XCreateGC(i32* %2, i32 %9, i32 0, i32 0)
%14 = tail call i32 @XSetForeground(i32* %2, i32 %13, i32 %7)
%15 = bitcast %struct.TYPE_3__* %1 to i8*
%16 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %1, i64 0, i32 0
br label %17
17: ; preds = %17, %0
%18 = call i32 @XNextEvent(i32* %2, %struct.TYPE_3__* %1)
%19 = load i64, i64* %16
%20 = load i64, i64* @MapNotify
%21 = icmp eq i64 %19, %20
br i1 %21, label %22, label %17
22: ; preds = %17
%23 = call i32 @XDrawLine(i32* %2, i32 %9, i32 %13, i32 10, i32 60, i32 180, i32 20)
%24 = call i32 @XFlush(i32* %2)
%25 = call i32 @sleep(i32 10)
ret i32 0
}