#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*/ Window;
typedef int /*<<< orphan*/ Display;

/* Variables and functions */
int DefaultScreen(int /*<<< orphan*/ *);
int /*<<< orphan*/ RootWindow(int /*<<< orphan*/ *, int);
int /*<<< orphan*/ XCloseDisplay(int /*<<< orphan*/ *);
int /*<<< orphan*/ XCreateSimpleWindow(int /*<<< orphan*/ *, int /*<<< orphan*/,
                                       int /*<<< orphan*/, int /*<<< orphan*/,
                                       int, int, int, int /*<<< orphan*/,
                                       int /*<<< orphan*/);
int /*<<< orphan*/ XFlush(int /*<<< orphan*/ *);
int /*<<< orphan*/ XMapWindow(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ *XOpenDisplay(int /*<<< orphan*/ *);
int /*<<< orphan*/ sleep(int);
int main(void) {
  Display *display;
  Window window, rootwindow;
  int screen;
  display = XOpenDisplay(NULL);
  screen = DefaultScreen(display);
  rootwindow = RootWindow(display, screen);
  window = XCreateSimpleWindow(display, rootwindow, 0, 0, 100, 100, 1, 0, 0);
  XMapWindow(display, window);
  XFlush(display);
  sleep(10);
  XCloseDisplay(display);
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1030 <XOpenDisplay@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1080 <DefaultScreen@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1040 <RootWindow@plt>
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%esi
xor    %ecx,%ecx
mov    $0x64,%r9d
mov    %ecx,%edx
mov    %r9d,%r8d
movl   $0x1,(%rsp)
movl   $0x0,0x8(%rsp)
movl   $0x0,0x10(%rsp)
call   1050 <XCreateSimpleWindow@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1070 <XMapWindow@plt>
mov    -0x10(%rbp),%rdi
call   1060 <XFlush@plt>
mov    $0xa,%edi
call   10a0 <sleep@plt>
mov    -0x10(%rbp),%rdi
call   1090 <XCloseDisplay@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %edi,%edi
call   1030 <XOpenDisplay@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1080 <DefaultScreen@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1040 <RootWindow@plt>
sub    $0x8,%rsp
mov    %rbx,%rdi
mov    %eax,%esi
xor    %edx,%edx
xor    %ecx,%ecx
mov    $0x64,%r8d
mov    $0x64,%r9d
push   $0x0
push   $0x0
push   $0x1
call   1050 <XCreateSimpleWindow@plt>
add    $0x20,%rsp
mov    %rbx,%rdi
mov    %eax,%esi
call   1070 <XMapWindow@plt>
mov    %rbx,%rdi
call   1060 <XFlush@plt>
mov    $0xa,%edi
call   10a0 <sleep@plt>
mov    %rbx,%rdi
call   1090 <XCloseDisplay@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
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 = call i32 @DefaultScreen(i32* %7)
store i32 %8, i32* %5
%9 = load i32*, i32** %2
%10 = load i32, i32* %5
%11 = call i32 @RootWindow(i32* %9, i32 %10)
store i32 %11, i32* %4
%12 = load i32*, i32** %2
%13 = load i32, i32* %4
%14 = call i32 @XCreateSimpleWindow(i32* %12, i32 %13, i32 0, i32 0, i32 100, i32 100, i32 1, i32 0, i32 0)
store i32 %14, i32* %3
%15 = load i32*, i32** %2
%16 = load i32, i32* %3
%17 = call i32 @XMapWindow(i32* %15, i32 %16)
%18 = load i32*, i32** %2
%19 = call i32 @XFlush(i32* %18)
%20 = call i32 @sleep(i32 10)
%21 = load i32*, i32** %2
%22 = call i32 @XCloseDisplay(i32* %21)
ret i32 0
}

LLVM IR (-O2):
define i32 @main() {
%1 = tail call i32* @XOpenDisplay(i32* null)
%2 = tail call i32 @DefaultScreen(i32* %1)
%3 = tail call i32 @RootWindow(i32* %1, i32 %2)
%4 = tail call i32 @XCreateSimpleWindow(i32* %1, i32 %3, i32 0, i32 0, i32 100, i32 100, i32 1, i32 0, i32 0)
%5 = tail call i32 @XMapWindow(i32* %1, i32 %4)
%6 = tail call i32 @XFlush(i32* %1)
%7 = tail call i32 @sleep(i32 10)
%8 = tail call i32 @XCloseDisplay(i32* %1)
ret i32 0
}