#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_5__ TYPE_2__;
typedef struct TYPE_4__ TYPE_1__;

/* Type definitions */
struct TYPE_4__ {
  int /*<<< orphan*/ time;
};
struct TYPE_5__ {
  scalar_t__ type;
  TYPE_1__ xproperty;
};
typedef TYPE_2__ XEvent;
typedef int /*<<< orphan*/ Window;
typedef int /*<<< orphan*/ Time;
typedef int /*<<< orphan*/ Display;

/* Variables and functions */
int /*<<< orphan*/ PropertyChangeMask;
scalar_t__ PropertyNotify;
int /*<<< orphan*/ XNextEvent(int /*<<< orphan*/ *, TYPE_2__ *);
int /*<<< orphan*/ XSelectInput(int /*<<< orphan*/ *, int /*<<< orphan*/,
                                int /*<<< orphan*/);
int /*<<< orphan*/ XStoreName(int /*<<< orphan*/ *, int /*<<< orphan*/, char *);
Time getTimestamp(Display *dpy, Window win) {
  XEvent ev;
  XSelectInput(dpy, win, PropertyChangeMask);
  XStoreName(dpy, win, "shit");
  while (1) {
    XNextEvent(dpy, &ev);
    if (ev.type == PropertyNotify)
      break;
  }
  return ev.xproperty.time;
}


x86 assembly (clang, -O0):
<getTimestamp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    0x2e9b(%rip),%rax
mov    (%rax),%edx
call   1050 <XSelectInput@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
lea    0xe9e(%rip),%rdx
call   1030 <XStoreName@plt>
mov    -0x8(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1040 <XNextEvent@plt>
mov    -0x20(%rbp),%rax
mov    0x2e59(%rip),%rcx
cmp    (%rcx),%rax
jne    118d <getTimestamp+0x5d>
jmp    1192 <getTimestamp+0x62>
jmp    1167 <getTimestamp+0x37>
mov    -0x18(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getTimestamp>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %esi,%ebp
mov    %rdi,%rbx
mov    0x2ea4(%rip),%rax
mov    (%rax),%edx
call   1050 <XSelectInput@plt>
lea    0xeae(%rip),%rdx
mov    %rbx,%rdi
mov    %ebp,%esi
call   1030 <XStoreName@plt>
mov    %rsp,%r14
mov    0x2e72(%rip),%rbp
cs nopw 0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <XNextEvent@plt>
mov    (%rsp),%rax
cmp    0x0(%rbp),%rax
jne    1170 <getTimestamp+0x40>
mov    0x8(%rsp),%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.TYPE_5__ = type { i64, %struct.TYPE_4__ }
%struct.TYPE_4__ = type { i32 }
@PropertyChangeMask = global i32 0
@.str = [5 x i8] c"shit\00"
@PropertyNotify = global i64 0
define i32 @getTimestamp(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca %struct.TYPE_5__
store i32* %0, i32** %3
store i32 %1, i32* %4
%6 = load i32*, i32** %3
%7 = load i32, i32* %4
%8 = load i32, i32* @PropertyChangeMask
%9 = call i32 @XSelectInput(i32* %6, i32 %7, i32 %8)
%10 = load i32*, i32** %3
%11 = load i32, i32* %4
%12 = call i32 @XStoreName(i32* %10, i32 %11, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %13
13: ; preds = %2, %21
%14 = load i32*, i32** %3
%15 = call i32 @XNextEvent(i32* %14, %struct.TYPE_5__* %5)
%16 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %5, i32 0, i32 0
%17 = load i64, i64* %16
%18 = load i64, i64* @PropertyNotify
%19 = icmp eq i64 %17, %18
br i1 %19, label %20, label %21
20: ; preds = %13
br label %22
21: ; preds = %13
br label %13
22: ; preds = %20
%23 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %5, i32 0, i32 1
%24 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %23, i32 0, i32 0
%25 = load i32, i32* %24
ret i32 %25
}

LLVM IR (-O2):
%struct.TYPE_5__ = type { i64, %struct.TYPE_4__ }
%struct.TYPE_4__ = type { i32 }
@PropertyChangeMask = global i32 0
@.str = [5 x i8] c"shit\00"
@PropertyNotify = global i64 0
define i32 @getTimestamp(i32* %0, i32 %1) {
%3 = alloca %struct.TYPE_5__
%4 = bitcast %struct.TYPE_5__* %3 to i8*
%5 = load i32, i32* @PropertyChangeMask
%6 = tail call i32 @XSelectInput(i32* %0, i32 %1, i32 %5)
%7 = tail call i32 @XStoreName(i32* %0, i32 %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%8 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %3, i64 0, i32 0
br label %9
9: ; preds = %9, %2
%10 = call i32 @XNextEvent(i32* %0, %struct.TYPE_5__* %3)
%11 = load i64, i64* %8
%12 = load i64, i64* @PropertyNotify
%13 = icmp eq i64 %11, %12
br i1 %13, label %14, label %9
14: ; preds = %9
%15 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %3, i64 0, i32 1, i32 0
%16 = load i32, i32* %15
ret i32 %16
}