#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_6__ {
  scalar_t__ type;
};
typedef TYPE_2__ XEvent;
struct TYPE_5__ {
  int *l;
};
struct TYPE_7__ {
  TYPE_1__ data;
};
typedef TYPE_3__ XClientMessageEvent;
typedef int Window;
typedef int /*<<< orphan*/ Display;

/* Variables and functions */
int /*<<< orphan*/ BlackPixel(int /*<<< orphan*/ *, int /*<<< orphan*/);
scalar_t__ ClientMessage;
int /*<<< orphan*/ DefaultRootWindow(int /*<<< orphan*/ *);
int /*<<< orphan*/ DefaultScreen(int /*<<< orphan*/ *);
int /*<<< orphan*/ XCloseDisplay(int /*<<< orphan*/ *);
int XCreateSimpleWindow(int /*<<< orphan*/ *, int /*<<< orphan*/,
                        int /*<<< orphan*/, int /*<<< orphan*/, int, int,
                        int /*<<< orphan*/, int /*<<< orphan*/,
                        int /*<<< orphan*/);
int /*<<< orphan*/ XFlush(int /*<<< orphan*/ *);
int /*<<< orphan*/ XNextEvent(int /*<<< orphan*/ *, TYPE_2__ *);
int /*<<< orphan*/ *XOpenDisplay(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, int, ...);
int /*<<< orphan*/ sprintf(char *, char *, int);
int /*<<< orphan*/ system(char *);
int main(int argc, char **argv) {
  Display *display;
  XEvent message;
  Window window;
  int lokke;
  char temp[500];
  display = XOpenDisplay(NULL);
  window =
      XCreateSimpleWindow(display, DefaultRootWindow(display), 0, 0, 100, 100,
                          0, BlackPixel(display, DefaultScreen(display)),
                          BlackPixel(display, DefaultScreen(display)));
  printf("Window: %d\n", window);
  XFlush(display);
  sprintf(temp, "../bin/X11_XSendEvent %d 1 2 3 4 5", window);
  system(temp);
  for (;;) {
    XEvent event;
    XNextEvent(display, &event);
    if (event.type == ClientMessage) {
      XClientMessageEvent *x = (XClientMessageEvent *)(&event);
      printf("Got it %d %d %d %d %d\n", x->data.l[0], x->data.l[1],
             x->data.l[2], x->data.l[3], x->data.l[4]);
      break;
    }
  }
  XCloseDisplay(display);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x270,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1060 <XOpenDisplay@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x240(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <DefaultRootWindow@plt>
mov    %eax,-0x238(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x250(%rbp)
mov    -0x18(%rbp),%rdi
call   10c0 <DefaultScreen@plt>
mov    -0x250(%rbp),%rdi
mov    %eax,%esi
call   1090 <BlackPixel@plt>
mov    %eax,-0x234(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x248(%rbp)
mov    -0x18(%rbp),%rdi
call   10c0 <DefaultScreen@plt>
mov    -0x248(%rbp),%rdi
mov    %eax,%esi
call   1090 <BlackPixel@plt>
mov    -0x240(%rbp),%rdi
mov    -0x238(%rbp),%esi
mov    -0x234(%rbp),%r10d
xor    %ecx,%ecx
mov    $0x64,%r9d
mov    %ecx,%edx
mov    %r9d,%r8d
movl   $0x0,(%rsp)
mov    %r10d,0x8(%rsp)
mov    %eax,0x10(%rsp)
call   1080 <XCreateSimpleWindow@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%esi
lea    0xd83(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x18(%rbp),%rdi
call   10a0 <XFlush@plt>
lea    -0x220(%rbp),%rdi
mov    -0x24(%rbp),%edx
lea    0xd6e(%rip),%rsi
call   10b0 <sprintf@plt>
lea    -0x220(%rbp),%rdi
call   1040 <system@plt>
mov    -0x18(%rbp),%rdi
lea    -0x228(%rbp),%rsi
call   1070 <XNextEvent@plt>
mov    -0x228(%rbp),%rax
mov    0x2d1b(%rip),%rcx
cmp    (%rcx),%rax
jne    1339 <main+0x189>
lea    -0x228(%rbp),%rax
mov    %rax,-0x230(%rbp)
mov    -0x230(%rbp),%rax
mov    (%rax),%rax
mov    (%rax),%esi
mov    -0x230(%rbp),%rax
mov    (%rax),%rax
mov    0x4(%rax),%edx
mov    -0x230(%rbp),%rax
mov    (%rax),%rax
mov    0x8(%rax),%ecx
mov    -0x230(%rbp),%rax
mov    (%rax),%rax
mov    0xc(%rax),%r8d
mov    -0x230(%rbp),%rax
mov    (%rax),%rax
mov    0x10(%rax),%r9d
lea    0xd02(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    133e <main+0x18e>
jmp    12af <main+0xff>
mov    -0x18(%rbp),%rdi
call   10d0 <XCloseDisplay@plt>
xor    %eax,%eax
add    $0x270,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x210,%rsp
xor    %edi,%edi
call   1060 <XOpenDisplay@plt>
mov    %rax,%r14
mov    %rax,%rdi
call   1030 <DefaultRootWindow@plt>
mov    %eax,%ebp
mov    %r14,%rdi
call   10c0 <DefaultScreen@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   1090 <BlackPixel@plt>
mov    %eax,%ebx
mov    %r14,%rdi
call   10c0 <DefaultScreen@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   1090 <BlackPixel@plt>
sub    $0x8,%rsp
mov    %r14,%rdi
mov    %ebp,%esi
xor    %edx,%edx
xor    %ecx,%ecx
mov    $0x64,%r8d
mov    $0x64,%r9d
push   %rax
push   %rbx
push   $0x0
call   1080 <XCreateSimpleWindow@plt>
add    $0x20,%rsp
mov    %eax,%ebx
lea    0xddc(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
call   10a0 <XFlush@plt>
lea    0xdd0(%rip),%rsi
lea    0x10(%rsp),%rbp
mov    %rbp,%rdi
mov    %ebx,%edx
call   10b0 <sprintf@plt>
mov    %rbp,%rdi
call   1040 <system@plt>
lea    0x8(%rsp),%rsi
mov    %r14,%rdi
call   1070 <XNextEvent@plt>
mov    0x8(%rsp),%rax
mov    0x2d7c(%rip),%rbp
cmp    0x0(%rbp),%rax
je     1296 <main+0xe6>
lea    0x8(%rsp),%rbx
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1070 <XNextEvent@plt>
mov    0x8(%rsp),%rax
cmp    0x0(%rbp),%rax
jne    1280 <main+0xd0>
mov    (%rax),%esi
mov    0x4(%rax),%edx
mov    0x8(%rax),%ecx
mov    0xc(%rax),%r8d
mov    0x10(%rax),%r9d
lea    0xd82(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
call   10d0 <XCloseDisplay@plt>
xor    %eax,%eax
add    $0x210,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.TYPE_6__ = type { i64 }
%struct.TYPE_7__ = type { %struct.TYPE_5__ }
%struct.TYPE_5__ = type { i32* }
@.str = [12 x i8] c"Window: %d\0A\00"
@.str.1 = [35 x i8] c"../bin/X11_XSendEvent %d 1 2 3 4 5\00"
@ClientMessage = global i64 0
@.str.2 = [23 x i8] c"Got it %d %d %d %d %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca %struct.TYPE_6__
%8 = alloca i32
%9 = alloca i32
%10 = alloca [500 x i8]
%11 = alloca %struct.TYPE_6__
%12 = alloca %struct.TYPE_7__*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = call i32* @XOpenDisplay(i32* null)
store i32* %13, i32** %6
%14 = load i32*, i32** %6
%15 = load i32*, i32** %6
%16 = call i32 @DefaultRootWindow(i32* %15)
%17 = load i32*, i32** %6
%18 = load i32*, i32** %6
%19 = call i32 @DefaultScreen(i32* %18)
%20 = call i32 @BlackPixel(i32* %17, i32 %19)
%21 = load i32*, i32** %6
%22 = load i32*, i32** %6
%23 = call i32 @DefaultScreen(i32* %22)
%24 = call i32 @BlackPixel(i32* %21, i32 %23)
%25 = call i32 @XCreateSimpleWindow(i32* %14, i32 %16, i32 0, i32 0, i32 100, i32 100, i32 0, i32 %20, i32 %24)
store i32 %25, i32* %8
%26 = load i32, i32* %8
%27 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %26)
%28 = load i32*, i32** %6
%29 = call i32 @XFlush(i32* %28)
%30 = getelementptr inbounds [500 x i8], [500 x i8]* %10, i64 0, i64 0
%31 = load i32, i32* %8
%32 = call i32 @sprintf(i8* %30, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i32 %31)
%33 = getelementptr inbounds [500 x i8], [500 x i8]* %10, i64 0, i64 0
%34 = call i32 @system(i8* %33)
br label %35
35: ; preds = %75, %2
%36 = load i32*, i32** %6
%37 = call i32 @XNextEvent(i32* %36, %struct.TYPE_6__* %11)
%38 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %11, i32 0, i32 0
%39 = load i64, i64* %38
%40 = load i64, i64* @ClientMessage
%41 = icmp eq i64 %39, %40
br i1 %41, label %42, label %75
42: ; preds = %35
%43 = bitcast %struct.TYPE_6__* %11 to %struct.TYPE_7__*
store %struct.TYPE_7__* %43, %struct.TYPE_7__** %12
%44 = load %struct.TYPE_7__*, %struct.TYPE_7__** %12
%45 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %44, i32 0, i32 0
%46 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %45, i32 0, i32 0
%47 = load i32*, i32** %46
%48 = getelementptr inbounds i32, i32* %47, i64 0
%49 = load i32, i32* %48
%50 = load %struct.TYPE_7__*, %struct.TYPE_7__** %12
%51 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %50, i32 0, i32 0
%52 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %51, i32 0, i32 0
%53 = load i32*, i32** %52
%54 = getelementptr inbounds i32, i32* %53, i64 1
%55 = load i32, i32* %54
%56 = load %struct.TYPE_7__*, %struct.TYPE_7__** %12
%57 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %56, i32 0, i32 0
%58 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %57, i32 0, i32 0
%59 = load i32*, i32** %58
%60 = getelementptr inbounds i32, i32* %59, i64 2
%61 = load i32, i32* %60
%62 = load %struct.TYPE_7__*, %struct.TYPE_7__** %12
%63 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %62, i32 0, i32 0
%64 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %63, i32 0, i32 0
%65 = load i32*, i32** %64
%66 = getelementptr inbounds i32, i32* %65, i64 3
%67 = load i32, i32* %66
%68 = load %struct.TYPE_7__*, %struct.TYPE_7__** %12
%69 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %68, i32 0, i32 0
%70 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %69, i32 0, i32 0
%71 = load i32*, i32** %70
%72 = getelementptr inbounds i32, i32* %71, i64 4
%73 = load i32, i32* %72
%74 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i32 %49, i32 %55, i32 %61, i32 %67, i32 %73)
br label %76
75: ; preds = %35
br label %35
76: ; preds = %42
%77 = load i32*, i32** %6
%78 = call i32 @XCloseDisplay(i32* %77)
ret i32 0
}

LLVM IR (-O2):
%struct.TYPE_6__ = type { i64 }
@.str = [12 x i8] c"Window: %d\0A\00"
@.str.1 = [35 x i8] c"../bin/X11_XSendEvent %d 1 2 3 4 5\00"
@ClientMessage = global i64 0
@.str.2 = [23 x i8] c"Got it %d %d %d %d %d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [500 x i8]
%4 = alloca %struct.TYPE_6__
%5 = getelementptr inbounds [500 x i8], [500 x i8]* %3, i64 0, i64 0
%6 = tail call i32* @XOpenDisplay(i32* null)
%7 = tail call i32 @DefaultRootWindow(i32* %6)
%8 = tail call i32 @DefaultScreen(i32* %6)
%9 = tail call i32 @BlackPixel(i32* %6, i32 %8)
%10 = tail call i32 @DefaultScreen(i32* %6)
%11 = tail call i32 @BlackPixel(i32* %6, i32 %10)
%12 = tail call i32 @XCreateSimpleWindow(i32* %6, i32 %7, i32 0, i32 0, i32 100, i32 100, i32 0, i32 %9, i32 %11)
%13 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %12)
%14 = tail call i32 @XFlush(i32* %6)
%15 = call i32 @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i32 %12)
%16 = call i32 @system(i8* %5)
%17 = bitcast %struct.TYPE_6__* %4 to i8*
%18 = call i32 @XNextEvent(i32* %6, %struct.TYPE_6__* %4)
%19 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %4, i64 0, i32 0
%20 = load i64, i64* %19
%21 = load i64, i64* @ClientMessage
%22 = icmp eq i64 %20, %21
br i1 %22, label %28, label %23
23: ; preds = %2, %23
%24 = call i32 @XNextEvent(i32* %6, %struct.TYPE_6__* %4)
%25 = load i64, i64* %19
%26 = load i64, i64* @ClientMessage
%27 = icmp eq i64 %25, %26
br i1 %27, label %28, label %23
28: ; preds = %23, %2
%29 = phi i64 [ %20, %2 ], [ %25, %23 ]
%30 = inttoptr i64 %29 to i32*
%31 = load i32, i32* %30
%32 = getelementptr inbounds i32, i32* %30, i64 1
%33 = load i32, i32* %32
%34 = getelementptr inbounds i32, i32* %30, i64 2
%35 = load i32, i32* %34
%36 = getelementptr inbounds i32, i32* %30, i64 3
%37 = load i32, i32* %36
%38 = getelementptr inbounds i32, i32* %30, i64 4
%39 = load i32, i32* %38
%40 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i32 %31, i32 %33, i32 %35, i32 %37, i32 %39)
%41 = call i32 @XCloseDisplay(i32* %6)
ret i32 0
}