#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_7__ TYPE_3__;
typedef struct TYPE_6__ TYPE_2__;
typedef struct TYPE_5__ TYPE_1__;

/* Type definitions */
struct TYPE_5__ {
  scalar_t__ *l;
};
struct TYPE_6__ {
  TYPE_1__ data;
};
struct TYPE_7__ {
  TYPE_2__ xclient;
};
typedef TYPE_3__ XEvent;
typedef int /*<<< orphan*/ Display;
typedef scalar_t__ Atom;

/* Variables and functions */
int /*<<< orphan*/ XCloseDisplay(int /*<<< orphan*/ *);
int /*<<< orphan*/ XNextEvent(int /*<<< orphan*/ *, TYPE_3__ *);
int /*<<< orphan*/ *XOpenDisplay(int /*<<< orphan*/ *);
int /*<<< orphan*/ create_window(int /*<<< orphan*/ *, scalar_t__ *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
int /*<<< orphan*/ sched_yield();
int /*<<< orphan*/ stderr;
int main(void) {
  Display *dis;
  Atom wm_delete_msg;
  XEvent evt;
  dis = XOpenDisplay(NULL);
  ;
  if (!dis) {
    fputs("Unable to open X display.\n", stderr);
    exit(1);
  }
  create_window(dis, &wm_delete_msg);
  for (;;) {
    sched_yield();
    XNextEvent(dis, &evt);
    if ((Atom)evt.xclient.data.l[0] == wm_delete_msg) {
      break;
    }
  }
  XCloseDisplay(dis);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1050 <XOpenDisplay@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11b6 <main+0x46>
mov    0x2e42(%rip),%rax
mov    (%rax),%esi
lea    0xe59(%rip),%rdi
call   1030 <fputs@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    -0x10(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1070 <create_window@plt>
mov    $0x0,%al
call   1040 <sched_yield@plt>
mov    -0x10(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1060 <XNextEvent@plt>
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
cmp    -0x18(%rbp),%rax
jne    11ed <main+0x7d>
jmp    11f2 <main+0x82>
jmp    11c3 <main+0x53>
mov    -0x10(%rbp),%rdi
call   1090 <XCloseDisplay@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
xor    %edi,%edi
call   1050 <XOpenDisplay@plt>
test   %rax,%rax
je     11d3 <main+0x63>
mov    %rax,%rbx
lea    0x10(%rsp),%rsi
mov    %rax,%rdi
call   1070 <create_window@plt>
lea    0x8(%rsp),%r14
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1040 <sched_yield@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1060 <XNextEvent@plt>
mov    0x8(%rsp),%rax
mov    (%rax),%rax
cmp    0x10(%rsp),%rax
jne    11a0 <main+0x30>
mov    %rbx,%rdi
call   1090 <XCloseDisplay@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret
mov    0x2e06(%rip),%rax
mov    (%rax),%esi
lea    0xe1d(%rip),%rdi
call   1030 <fputs@plt>
mov    $0x1,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
%struct.TYPE_7__ = type { %struct.TYPE_6__ }
%struct.TYPE_6__ = type { %struct.TYPE_5__ }
%struct.TYPE_5__ = type { i64* }
@.str = [27 x i8] c"Unable to open X display.\0A\00"
@stderr = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i64
%4 = alloca %struct.TYPE_7__
store i32 0, i32* %1
%5 = call i32* @XOpenDisplay(i32* null)
store i32* %5, i32** %2
%6 = load i32*, i32** %2
%7 = icmp ne i32* %6, null
br i1 %7, label %12, label %8
8: ; preds = %0
%9 = load i32, i32* @stderr
%10 = call i32 @fputs(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = call i32 @exit(i32 1)
unreachable
12: ; preds = %0
%13 = load i32*, i32** %2
%14 = call i32 @create_window(i32* %13, i64* %3)
br label %15
15: ; preds = %28, %12
%16 = call i32 (...) @sched_yield()
%17 = load i32*, i32** %2
%18 = call i32 @XNextEvent(i32* %17, %struct.TYPE_7__* %4)
%19 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %4, i32 0, i32 0
%20 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %19, i32 0, i32 0
%21 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %20, i32 0, i32 0
%22 = load i64*, i64** %21
%23 = getelementptr inbounds i64, i64* %22, i64 0
%24 = load i64, i64* %23
%25 = load i64, i64* %3
%26 = icmp eq i64 %24, %25
br i1 %26, label %27, label %28
27: ; preds = %15
br label %29
28: ; preds = %15
br label %15
29: ; preds = %27
%30 = load i32*, i32** %2
%31 = call i32 @XCloseDisplay(i32* %30)
ret i32 0
}

LLVM IR (-O2):
%struct.TYPE_7__ = type { %struct.TYPE_6__ }
%struct.TYPE_6__ = type { %struct.TYPE_5__ }
%struct.TYPE_5__ = type { i64* }
@.str = [27 x i8] c"Unable to open X display.\0A\00"
@stderr = global i32 0
define i32 @main() {
%1 = alloca i64
%2 = alloca %struct.TYPE_7__
%3 = bitcast i64* %1 to i8*
%4 = bitcast %struct.TYPE_7__* %2 to i8*
%5 = tail call i32* @XOpenDisplay(i32* null)
%6 = icmp eq i32* %5, null
br i1 %6, label %7, label %11
7: ; preds = %0
%8 = load i32, i32* @stderr
%9 = tail call i32 @fputs(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 %8)
%10 = tail call i32 @exit(i32 1)
unreachable
11: ; preds = %0
%12 = call i32 @create_window(i32* %5, i64* %1)
%13 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %2, i64 0, i32 0, i32 0, i32 0
br label %14
14: ; preds = %14, %11
%15 = call i32 (...) @sched_yield()
%16 = call i32 @XNextEvent(i32* %5, %struct.TYPE_7__* %2)
%17 = load i64*, i64** %13
%18 = load i64, i64* %17
%19 = load i64, i64* %1
%20 = icmp eq i64 %18, %19
br i1 %20, label %21, label %14
21: ; preds = %14
%22 = call i32 @XCloseDisplay(i32* %5)
ret i32 0
}