#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__ {
  int /*<<< orphan*/ cursor;
};
typedef TYPE_1__ XSetWindowAttributes;
typedef int /*<<< orphan*/ XEvent;
typedef int /*<<< orphan*/ Window;
typedef int /*<<< orphan*/ Display;

/* Variables and functions */
int /*<<< orphan*/ CWCursor;
int /*<<< orphan*/ CopyFromParent;
int /*<<< orphan*/ InputOnly;
int /*<<< orphan*/ RootWindow(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ XC_watch;
int /*<<< orphan*/ XCreateFontCursor(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ XCreateWindow(int /*<<< orphan*/ *, int /*<<< orphan*/, int,
                                 int, int, int, int, int /*<<< orphan*/,
                                 int /*<<< orphan*/, int /*<<< orphan*/,
                                 int /*<<< orphan*/, TYPE_1__ *);
int /*<<< orphan*/ XFlush(int /*<<< orphan*/ *);
int /*<<< orphan*/ XMapWindow(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ XNextEvent(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ *XOpenDisplay(int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
int main() {
  Display *display;
  Window win, child;
  XEvent report;
  int x = 10, y = 10, h = 100, w = 400, b = 10;
  XSetWindowAttributes a;
  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, b,
                      CopyFromParent, CopyFromParent, CopyFromParent, 0, NULL);
  a.cursor = XCreateFontCursor(display, XC_watch);
  child =
      XCreateWindow(display, win, x + w / 8, y + h / 8, 3 * w / 4, 3 * h / 4, 0,
                    CopyFromParent, InputOnly, CopyFromParent, CWCursor, &a);
  XMapWindow(display, child);
  XMapWindow(display, win);
  XFlush(display);
  while (1) {
    XNextEvent(display, &report);
  }
  return 1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r14
push   %rbx
sub    $0x80,%rsp
movl   $0x0,-0x14(%rbp)
movl   $0xa,-0x30(%rbp)
movl   $0xa,-0x34(%rbp)
movl   $0x64,-0x38(%rbp)
movl   $0x190,-0x3c(%rbp)
movl   $0xa,-0x40(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1040 <XOpenDisplay@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11f3 <main+0x73>
mov    0x2df9(%rip),%rax
mov    (%rax),%edi
lea    0xe20(%rip),%rsi
call   1050 <fprintf@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    -0x20(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x20(%rbp),%rdi
xor    %esi,%esi
call   1080 <RootWindow@plt>
mov    -0x58(%rbp),%rdi
mov    %eax,%esi
mov    -0x30(%rbp),%edx
mov    -0x34(%rbp),%ecx
mov    -0x3c(%rbp),%r8d
mov    -0x38(%rbp),%r9d
mov    -0x40(%rbp),%ebx
mov    0x2d9c(%rip),%rax
mov    (%rax),%r11d
mov    0x2d92(%rip),%rax
mov    (%rax),%r10d
mov    0x2d88(%rip),%rax
mov    (%rax),%eax
xor    %r14d,%r14d
xor    %r14d,%r14d
mov    %ebx,(%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,-0x24(%rbp)
mov    -0x20(%rbp),%rdi
mov    0x2d73(%rip),%rax
mov    (%rax),%esi
call   1030 <XCreateFontCursor@plt>
mov    %eax,-0x48(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    -0x30(%rbp),%eax
mov    %eax,-0x50(%rbp)
mov    -0x3c(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x50(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x4c(%rbp)
mov    -0x34(%rbp),%ecx
mov    -0x38(%rbp),%eax
mov    $0x8,%r8d
cltd
idiv   %r8d
add    %eax,%ecx
imul   $0x3,-0x3c(%rbp),%eax
mov    $0x4,%r8d
cltd
idiv   %r8d
mov    %eax,%r8d
imul   $0x3,-0x38(%rbp),%eax
mov    $0x4,%r9d
cltd
idiv   %r9d
mov    -0x4c(%rbp),%edx
mov    %eax,%r9d
mov    0x2ce1(%rip),%rax
mov    (%rax),%r14d
mov    0x2cdf(%rip),%rax
mov    (%rax),%ebx
mov    0x2cce(%rip),%rax
mov    (%rax),%r11d
mov    0x2cdc(%rip),%rax
mov    (%rax),%r10d
xor    %eax,%eax
lea    -0x48(%rbp),%rax
movl   $0x0,(%rsp)
mov    %r14d,0x8(%rsp)
mov    %ebx,0x10(%rsp)
mov    %r11d,0x18(%rsp)
mov    %r10d,0x20(%rsp)
mov    %rax,0x28(%rsp)
call   1070 <XCreateWindow@plt>
mov    %eax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%esi
call   10a0 <XMapWindow@plt>
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%esi
call   10a0 <XMapWindow@plt>
mov    -0x20(%rbp),%rdi
call   1090 <XFlush@plt>
mov    -0x20(%rbp),%rdi
lea    -0x2c(%rbp),%rsi
call   1060 <XNextEvent@plt>
jmp    134d <main+0x1cd>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
xor    %edi,%edi
call   1040 <XOpenDisplay@plt>
test   %rax,%rax
je     126d <main+0xed>
mov    %rax,%rbx
mov    %rax,%rdi
xor    %esi,%esi
call   1080 <RootWindow@plt>
mov    0x2e15(%rip),%r14
mov    (%r14),%ebp
mov    %rbx,%rdi
mov    %eax,%esi
mov    $0xa,%edx
mov    $0xa,%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,%r15d
mov    0x2e03(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1030 <XCreateFontCursor@plt>
mov    %eax,(%rsp)
mov    (%r14),%eax
mov    0x2dcc(%rip),%rcx
mov    (%rcx),%r10d
mov    0x2dd2(%rip),%rcx
mov    (%rcx),%ebp
mov    %rsp,%r11
mov    %rbx,%rdi
mov    %r15d,%esi
mov    $0x3c,%edx
mov    $0x16,%ecx
mov    $0x12c,%r8d
mov    $0x4b,%r9d
push   %r11
push   %rbp
push   %rax
push   %r10
push   %rax
push   $0x0
call   1070 <XCreateWindow@plt>
add    $0x30,%rsp
mov    %rbx,%rdi
mov    %eax,%esi
call   10a0 <XMapWindow@plt>
mov    %rbx,%rdi
mov    %r15d,%esi
call   10a0 <XMapWindow@plt>
mov    %rbx,%rdi
call   1090 <XFlush@plt>
lea    0x4(%rsp),%rbp
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1060 <XNextEvent@plt>
jmp    1260 <main+0xe0>
mov    0x2d5c(%rip),%rax
mov    (%rax),%edi
lea    0xd83(%rip),%rsi
call   1050 <fprintf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.TYPE_3__ = type { i32 }
@stderr = global i32 0
@.str = [33 x i8] c"couldn't connect to X server :0\0A\00"
@CopyFromParent = global i32 0
@XC_watch = global i32 0
@InputOnly = global i32 0
@CWCursor = 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
%10 = alloca i32
%11 = alloca %struct.TYPE_3__
store i32 0, i32* %1
store i32 10, i32* %6
store i32 10, i32* %7
store i32 100, i32* %8
store i32 400, i32* %9
store i32 10, i32* %10
%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* %10
%27 = load i32, i32* @CopyFromParent
%28 = load i32, i32* @CopyFromParent
%29 = load i32, i32* @CopyFromParent
%30 = call i32 @XCreateWindow(i32* %19, i32 %21, i32 %22, i32 %23, i32 %24, i32 %25, i32 %26, i32 %27, i32 %28, i32 %29, i32 0, %struct.TYPE_3__* null)
store i32 %30, i32* %3
%31 = load i32*, i32** %2
%32 = load i32, i32* @XC_watch
%33 = call i32 @XCreateFontCursor(i32* %31, i32 %32)
%34 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %11, i32 0, i32 0
store i32 %33, i32* %34
%35 = load i32*, i32** %2
%36 = load i32, i32* %3
%37 = load i32, i32* %6
%38 = load i32, i32* %9
%39 = sdiv i32 %38, 8
%40 = add nsw i32 %37, %39
%41 = load i32, i32* %7
%42 = load i32, i32* %8
%43 = sdiv i32 %42, 8
%44 = add nsw i32 %41, %43
%45 = load i32, i32* %9
%46 = mul nsw i32 3, %45
%47 = sdiv i32 %46, 4
%48 = load i32, i32* %8
%49 = mul nsw i32 3, %48
%50 = sdiv i32 %49, 4
%51 = load i32, i32* @CopyFromParent
%52 = load i32, i32* @InputOnly
%53 = load i32, i32* @CopyFromParent
%54 = load i32, i32* @CWCursor
%55 = call i32 @XCreateWindow(i32* %35, i32 %36, i32 %40, i32 %44, i32 %47, i32 %50, i32 0, i32 %51, i32 %52, i32 %53, i32 %54, %struct.TYPE_3__* %11)
store i32 %55, i32* %4
%56 = load i32*, i32** %2
%57 = load i32, i32* %4
%58 = call i32 @XMapWindow(i32* %56, i32 %57)
%59 = load i32*, i32** %2
%60 = load i32, i32* %3
%61 = call i32 @XMapWindow(i32* %59, i32 %60)
%62 = load i32*, i32** %2
%63 = call i32 @XFlush(i32* %62)
br label %64
64: ; preds = %18, %64
%65 = load i32*, i32** %2
%66 = call i32 @XNextEvent(i32* %65, i32* %5)
br label %64
}

LLVM IR (-O2):
%struct.TYPE_3__ = type { i32 }
@stderr = global i32 0
@.str = [33 x i8] c"couldn't connect to X server :0\0A\00"
@CopyFromParent = global i32 0
@XC_watch = global i32 0
@InputOnly = global i32 0
@CWCursor = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.TYPE_3__
%3 = bitcast i32* %1 to i8*
%4 = bitcast %struct.TYPE_3__* %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 = tail call i32 @RootWindow(i32* %5, i32 0)
%12 = load i32, i32* @CopyFromParent
%13 = tail call i32 @XCreateWindow(i32* %5, i32 %11, i32 10, i32 10, i32 400, i32 100, i32 10, i32 %12, i32 %12, i32 %12, i32 0, %struct.TYPE_3__* null)
%14 = load i32, i32* @XC_watch
%15 = tail call i32 @XCreateFontCursor(i32* %5, i32 %14)
%16 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %2, i64 0, i32 0
store i32 %15, i32* %16
%17 = load i32, i32* @CopyFromParent
%18 = load i32, i32* @InputOnly
%19 = load i32, i32* @CWCursor
%20 = call i32 @XCreateWindow(i32* %5, i32 %13, i32 60, i32 22, i32 300, i32 75, i32 0, i32 %17, i32 %18, i32 %17, i32 %19, %struct.TYPE_3__* %2)
%21 = call i32 @XMapWindow(i32* %5, i32 %20)
%22 = call i32 @XMapWindow(i32* %5, i32 %13)
%23 = call i32 @XFlush(i32* %5)
br label %24
24: ; preds = %24, %10
%25 = call i32 @XNextEvent(i32* %5, i32* %1)
br label %24
}