#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 */
typedef int /*<<< orphan*/ event;
struct TYPE_4__ {
  int same_screen;
  int /*<<< orphan*/ state;
  int /*<<< orphan*/ y;
  int /*<<< orphan*/ x;
  int /*<<< orphan*/ y_root;
  int /*<<< orphan*/ x_root;
  scalar_t__ subwindow;
  int /*<<< orphan*/ root;
  scalar_t__ window;
  int /*<<< orphan*/ button;
};
struct TYPE_5__ {
  int /*<<< orphan*/ type;
  TYPE_1__ xbutton;
};
typedef TYPE_2__ XEvent;
typedef int /*<<< orphan*/ Window;
typedef int /*<<< orphan*/ Display;

/* Variables and functions */
int /*<<< orphan*/ Button1;
int /*<<< orphan*/ ButtonPress;
int /*<<< orphan*/ ButtonRelease;
scalar_t__ DefaultRootWindow(int /*<<< orphan*/ *);
int /*<<< orphan*/ XFlush(int /*<<< orphan*/ *);
int /*<<< orphan*/ XQueryPointer(int /*<<< orphan*/ *, scalar_t__,
                                 int /*<<< orphan*/ *, scalar_t__ *,
                                 int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                                 int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                                 int /*<<< orphan*/ *);
int /*<<< orphan*/ memset(TYPE_2__ *, int /*<<< orphan*/, int);
int /*<<< orphan*/ usleep(int);
void click(Display *display, Window root) {
  XEvent event;
  memset(&event, 0, sizeof(event));
  event.xbutton.button = Button1;
  event.xbutton.same_screen = 1;
  event.xbutton.subwindow = DefaultRootWindow(display);
  while (event.xbutton.subwindow) {
    event.xbutton.window = event.xbutton.subwindow;
    XQueryPointer(display, event.xbutton.window, &event.xbutton.root,
                  &event.xbutton.subwindow, &event.xbutton.x_root,
                  &event.xbutton.y_root, &event.xbutton.x, &event.xbutton.y,
                  &event.xbutton.state);
  }
  event.type = ButtonPress;
  XFlush(display);
  usleep(1);
  event.type = ButtonRelease;
  XFlush(display);
  usleep(1);
}


x86 assembly (clang, -O0):
<click>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
lea    -0x50(%rbp),%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1040 <memset@plt>
mov    0x2e72(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
movl   $0x1,-0x48(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <DefaultRootWindow@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     1216 <click+0xc6>
mov    -0x30(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
lea    -0x50(%rbp),%rdx
add    $0x8,%rdx
add    $0x20,%rdx
lea    -0x50(%rbp),%rcx
add    $0x8,%rcx
add    $0x18,%rcx
lea    -0x50(%rbp),%r8
add    $0x8,%r8
add    $0x14,%r8
lea    -0x50(%rbp),%r9
add    $0x8,%r9
add    $0x10,%r9
lea    -0x50(%rbp),%r11
add    $0x8,%r11
add    $0xc,%r11
lea    -0x50(%rbp),%r10
add    $0x8,%r10
add    $0x8,%r10
lea    -0x50(%rbp),%rax
add    $0x8,%rax
add    $0x4,%rax
mov    %r11,(%rsp)
mov    %r10,0x8(%rsp)
mov    %rax,0x10(%rsp)
call   1050 <XQueryPointer@plt>
jmp    118f <click+0x3f>
mov    0x2dbb(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x50(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <XFlush@plt>
mov    $0x1,%edi
call   1070 <usleep@plt>
mov    0x2d8c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x50(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <XFlush@plt>
mov    $0x1,%edi
call   1070 <usleep@plt>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<click>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %rdi,%rbx
lea    0x8(%rsp),%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1040 <memset@plt>
mov    0x2e6f(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x40(%rsp)
movl   $0x1,0x10(%rsp)
mov    %rbx,%rdi
call   1030 <DefaultRootWindow@plt>
mov    %rax,0x28(%rsp)
test   %rax,%rax
je     11f4 <click+0xa4>
mov    %rax,%rsi
lea    0x24(%rsp),%r12
lea    0x20(%rsp),%r13
lea    0x1c(%rsp),%rbp
lea    0x18(%rsp),%r14
lea    0x14(%rsp),%r15
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rsi,0x38(%rsp)
sub    $0x8,%rsp
mov    %rbx,%rdi
lea    0x38(%rsp),%rdx
lea    0x30(%rsp),%rcx
mov    %r12,%r8
mov    %r13,%r9
push   %r15
push   %r14
push   %rbp
call   1050 <XQueryPointer@plt>
add    $0x20,%rsp
mov    0x28(%rsp),%rsi
test   %rsi,%rsi
jne    11c0 <click+0x70>
mov    0x2ddd(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x8(%rsp)
mov    %rbx,%rdi
call   1060 <XFlush@plt>
mov    $0x1,%edi
call   1070 <usleep@plt>
mov    0x2dae(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x8(%rsp)
mov    %rbx,%rdi
call   1060 <XFlush@plt>
mov    $0x1,%edi
call   1070 <usleep@plt>
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.TYPE_5__ = type { i32, %struct.TYPE_4__ }
%struct.TYPE_4__ = type { i32, i32, i32, i32, i32, i32, i64, i32, i64, i32 }
@Button1 = global i32 0
@ButtonPress = global i32 0
@ButtonRelease = global i32 0
define void @click(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 = call i32 @memset(%struct.TYPE_5__* %5, i32 0, i32 64)
%7 = load i32, i32* @Button1
%8 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %5, i32 0, i32 1
%9 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %8, i32 0, i32 9
store i32 %7, i32* %9
%10 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %5, i32 0, i32 1
%11 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %10, i32 0, i32 0
store i32 1, i32* %11
%12 = load i32*, i32** %3
%13 = call i64 @DefaultRootWindow(i32* %12)
%14 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %5, i32 0, i32 1
%15 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %14, i32 0, i32 6
store i64 %13, i64* %15
br label %16
16: ; preds = %21, %2
%17 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %5, i32 0, i32 1
%18 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %17, i32 0, i32 6
%19 = load i64, i64* %18
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %46
21: ; preds = %16
%22 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %5, i32 0, i32 1
%23 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %22, i32 0, i32 6
%24 = load i64, i64* %23
%25 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %5, i32 0, i32 1
%26 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %25, i32 0, i32 8
store i64 %24, i64* %26
%27 = load i32*, i32** %3
%28 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %5, i32 0, i32 1
%29 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %28, i32 0, i32 8
%30 = load i64, i64* %29
%31 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %5, i32 0, i32 1
%32 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %31, i32 0, i32 7
%33 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %5, i32 0, i32 1
%34 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %33, i32 0, i32 6
%35 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %5, i32 0, i32 1
%36 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %35, i32 0, i32 5
%37 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %5, i32 0, i32 1
%38 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %37, i32 0, i32 4
%39 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %5, i32 0, i32 1
%40 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %39, i32 0, i32 3
%41 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %5, i32 0, i32 1
%42 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %41, i32 0, i32 2
%43 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %5, i32 0, i32 1
%44 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %43, i32 0, i32 1
%45 = call i32 @XQueryPointer(i32* %27, i64 %30, i32* %32, i64* %34, i32* %36, i32* %38, i32* %40, i32* %42, i32* %44)
br label %16
46: ; preds = %16
%47 = load i32, i32* @ButtonPress
%48 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %5, i32 0, i32 0
store i32 %47, i32* %48
%49 = load i32*, i32** %3
%50 = call i32 @XFlush(i32* %49)
%51 = call i32 @usleep(i32 1)
%52 = load i32, i32* @ButtonRelease
%53 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %5, i32 0, i32 0
store i32 %52, i32* %53
%54 = load i32*, i32** %3
%55 = call i32 @XFlush(i32* %54)
%56 = call i32 @usleep(i32 1)
ret void
}

LLVM IR (-O2):
%struct.TYPE_5__ = type { i32, %struct.TYPE_4__ }
%struct.TYPE_4__ = type { i32, i32, i32, i32, i32, i32, i64, i32, i64, i32 }
@Button1 = global i32 0
@ButtonPress = global i32 0
@ButtonRelease = global i32 0
define void @click(i32* %0, i32 %1) {
%3 = alloca %struct.TYPE_5__
%4 = bitcast %struct.TYPE_5__* %3 to i8*
%5 = call i32 @memset(%struct.TYPE_5__* %3, i32 0, i32 64)
%6 = load i32, i32* @Button1
%7 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %3, i64 0, i32 1, i32 9
store i32 %6, i32* %7
%8 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %3, i64 0, i32 1, i32 0
store i32 1, i32* %8
%9 = call i64 @DefaultRootWindow(i32* %0)
%10 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %3, i64 0, i32 1, i32 6
store i64 %9, i64* %10
%11 = icmp eq i64 %9, 0
br i1 %11, label %25, label %12
12: ; preds = %2
%13 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %3, i64 0, i32 1, i32 8
%14 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %3, i64 0, i32 1, i32 7
%15 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %3, i64 0, i32 1, i32 5
%16 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %3, i64 0, i32 1, i32 4
%17 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %3, i64 0, i32 1, i32 3
%18 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %3, i64 0, i32 1, i32 2
%19 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %3, i64 0, i32 1, i32 1
br label %20
20: ; preds = %12, %20
%21 = phi i64 [ %9, %12 ], [ %23, %20 ]
store i64 %21, i64* %13
%22 = call i32 @XQueryPointer(i32* %0, i64 %21, i32* %14, i64* %10, i32* %15, i32* %16, i32* %17, i32* %18, i32* %19)
%23 = load i64, i64* %10
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %20
25: ; preds = %20, %2
%26 = load i32, i32* @ButtonPress
%27 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %3, i64 0, i32 0
store i32 %26, i32* %27
%28 = call i32 @XFlush(i32* %0)
%29 = call i32 @usleep(i32 1)
%30 = load i32, i32* @ButtonRelease
store i32 %30, i32* %27
%31 = call i32 @XFlush(i32* %0)
%32 = call i32 @usleep(i32 1)
ret void
}