#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_6__ TYPE_2__;
typedef struct TYPE_5__ TYPE_1__;

/* Type definitions */
typedef int /*<<< orphan*/ event;
struct TYPE_5__ {
  int button;
  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*/ same_screen;
};
struct TYPE_6__ {
  int /*<<< orphan*/ type;
  TYPE_1__ xbutton;
};
typedef TYPE_2__ XEvent;
typedef int /*<<< orphan*/ Display;

/* Variables and functions */
int /*<<< orphan*/ ButtonPress;
int /*<<< orphan*/ ButtonPressMask;
int /*<<< orphan*/ ButtonRelease;
int /*<<< orphan*/ ButtonReleaseMask;
scalar_t__ DefaultRootWindow(int /*<<< orphan*/ *);
int /*<<< orphan*/ PointerWindow;
int /*<<< orphan*/ True;
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*/ *);
scalar_t__ XSendEvent(int /*<<< orphan*/ *, int /*<<< orphan*/,
                      int /*<<< orphan*/, int /*<<< orphan*/, TYPE_2__ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ memset(TYPE_2__ *, int /*<<< orphan*/, int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ usleep(int);
void click(Display *display, int button) {
  XEvent event;
  memset(&event, 0, sizeof(event));
  event.xbutton.button = button;
  event.xbutton.same_screen = True;
  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;
  if (XSendEvent(display, PointerWindow, True, ButtonPressMask, &event) == 0)
    fprintf(stderr, "Error to send the event!\n");
  XFlush(display);
  usleep(1);
  event.type = ButtonRelease;
  if (XSendEvent(display, PointerWindow, True, ButtonReleaseMask, &event) == 0)
    fprintf(stderr, "Error to send the event!\n");
  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   1050 <memset@plt>
mov    -0xc(%rbp),%eax
mov    %eax,-0x48(%rbp)
mov    0x2e44(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <DefaultRootWindow@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     1235 <click+0xc5>
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   1070 <XQueryPointer@plt>
jmp    11ae <click+0x3e>
mov    0x2d7c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x50(%rbp)
mov    -0x8(%rbp),%rdi
mov    0x2d74(%rip),%rax
mov    (%rax),%esi
mov    0x2d8b(%rip),%rax
mov    (%rax),%edx
mov    0x2d8a(%rip),%rax
mov    (%rax),%ecx
lea    -0x50(%rbp),%r8
call   1030 <XSendEvent@plt>
cmp    $0x0,%rax
jne    1288 <click+0x118>
mov    0x2d56(%rip),%rax
mov    (%rax),%edi
lea    0xd7d(%rip),%rsi
call   1060 <fprintf@plt>
mov    -0x8(%rbp),%rdi
call   1080 <XFlush@plt>
mov    $0x1,%edi
call   1090 <usleep@plt>
mov    0x2d06(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x50(%rbp)
mov    -0x8(%rbp),%rdi
mov    0x2d0e(%rip),%rax
mov    (%rax),%esi
mov    0x2d25(%rip),%rax
mov    (%rax),%edx
mov    0x2d04(%rip),%rax
mov    (%rax),%ecx
lea    -0x50(%rbp),%r8
call   1030 <XSendEvent@plt>
cmp    $0x0,%rax
jne    12ee <click+0x17e>
mov    0x2cf0(%rip),%rax
mov    (%rax),%edi
lea    0xd17(%rip),%rsi
call   1060 <fprintf@plt>
mov    -0x8(%rbp),%rdi
call   1080 <XFlush@plt>
mov    $0x1,%edi
call   1090 <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    %esi,%ebx
mov    %rdi,%r12
lea    0x8(%rsp),%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1050 <memset@plt>
mov    %ebx,0x10(%rsp)
mov    0x2e41(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x40(%rsp)
mov    %r12,%rdi
call   1040 <DefaultRootWindow@plt>
mov    %rax,0x28(%rsp)
test   %rax,%rax
je     1214 <click+0xa4>
mov    %rax,%rsi
lea    0x24(%rsp),%r13
lea    0x20(%rsp),%rbx
lea    0x1c(%rsp),%rbp
lea    0x18(%rsp),%r14
lea    0x14(%rsp),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rsi,0x38(%rsp)
sub    $0x8,%rsp
mov    %r12,%rdi
lea    0x38(%rsp),%rdx
lea    0x30(%rsp),%rcx
mov    %r13,%r8
mov    %rbx,%r9
push   %r15
push   %r14
push   %rbp
call   1070 <XQueryPointer@plt>
add    $0x20,%rsp
mov    0x28(%rsp),%rsi
test   %rsi,%rsi
jne    11e0 <click+0x70>
mov    0x2d9d(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x8(%rsp)
mov    0x2d98(%rip),%rbx
mov    (%rbx),%esi
mov    0x2daf(%rip),%rbp
mov    0x0(%rbp),%edx
mov    0x2dad(%rip),%rax
mov    (%rax),%ecx
lea    0x8(%rsp),%r8
mov    %r12,%rdi
call   1030 <XSendEvent@plt>
test   %rax,%rax
jne    1264 <click+0xf4>
mov    0x2d7a(%rip),%rax
mov    (%rax),%edi
lea    0xda1(%rip),%rsi
call   1060 <fprintf@plt>
mov    %r12,%rdi
call   1080 <XFlush@plt>
mov    $0x1,%edi
call   1090 <usleep@plt>
mov    0x2d2b(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x8(%rsp)
mov    (%rbx),%esi
mov    0x0(%rbp),%edx
mov    0x2d39(%rip),%rax
mov    (%rax),%ecx
lea    0x8(%rsp),%r8
mov    %r12,%rdi
call   1030 <XSendEvent@plt>
test   %rax,%rax
jne    12b8 <click+0x148>
mov    0x2d26(%rip),%rax
mov    (%rax),%edi
lea    0xd4d(%rip),%rsi
call   1060 <fprintf@plt>
mov    %r12,%rdi
call   1080 <XFlush@plt>
mov    $0x1,%edi
call   1090 <usleep@plt>
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.TYPE_6__ = type { i32, %struct.TYPE_5__ }
%struct.TYPE_5__ = type { i32, i32, i32, i32, i32, i32, i64, i32, i64, i32 }
@True = global i32 0
@ButtonPress = global i32 0
@PointerWindow = global i32 0
@ButtonPressMask = global i32 0
@stderr = global i32 0
@.str = [26 x i8] c"Error to send the event!\0A\00"
@ButtonRelease = global i32 0
@ButtonReleaseMask = global i32 0
define void @click(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca %struct.TYPE_6__
store i32* %0, i32** %3
store i32 %1, i32* %4
%6 = call i32 @memset(%struct.TYPE_6__* %5, i32 0, i32 64)
%7 = load i32, i32* %4
%8 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %5, i32 0, i32 1
%9 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %8, i32 0, i32 0
store i32 %7, i32* %9
%10 = load i32, i32* @True
%11 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %5, i32 0, i32 1
%12 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %11, i32 0, i32 9
store i32 %10, i32* %12
%13 = load i32*, i32** %3
%14 = call i64 @DefaultRootWindow(i32* %13)
%15 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %5, i32 0, i32 1
%16 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %15, i32 0, i32 6
store i64 %14, i64* %16
br label %17
17: ; preds = %22, %2
%18 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %5, i32 0, i32 1
%19 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %18, i32 0, i32 6
%20 = load i64, i64* %19
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %47
22: ; preds = %17
%23 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %5, i32 0, i32 1
%24 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %23, i32 0, i32 6
%25 = load i64, i64* %24
%26 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %5, i32 0, i32 1
%27 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %26, i32 0, i32 8
store i64 %25, i64* %27
%28 = load i32*, i32** %3
%29 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %5, i32 0, i32 1
%30 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %29, i32 0, i32 8
%31 = load i64, i64* %30
%32 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %5, i32 0, i32 1
%33 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %32, i32 0, i32 7
%34 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %5, i32 0, i32 1
%35 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %34, i32 0, i32 6
%36 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %5, i32 0, i32 1
%37 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %36, i32 0, i32 5
%38 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %5, i32 0, i32 1
%39 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %38, i32 0, i32 4
%40 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %5, i32 0, i32 1
%41 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %40, i32 0, i32 3
%42 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %5, i32 0, i32 1
%43 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %42, i32 0, i32 2
%44 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %5, i32 0, i32 1
%45 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %44, i32 0, i32 1
%46 = call i32 @XQueryPointer(i32* %28, i64 %31, i32* %33, i64* %35, i32* %37, i32* %39, i32* %41, i32* %43, i32* %45)
br label %17
47: ; preds = %17
%48 = load i32, i32* @ButtonPress
%49 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %5, i32 0, i32 0
store i32 %48, i32* %49
%50 = load i32*, i32** %3
%51 = load i32, i32* @PointerWindow
%52 = load i32, i32* @True
%53 = load i32, i32* @ButtonPressMask
%54 = call i64 @XSendEvent(i32* %50, i32 %51, i32 %52, i32 %53, %struct.TYPE_6__* %5)
%55 = icmp eq i64 %54, 0
br i1 %55, label %56, label %59
56: ; preds = %47
%57 = load i32, i32* @stderr
%58 = call i32 @fprintf(i32 %57, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
br label %59
59: ; preds = %56, %47
%60 = load i32*, i32** %3
%61 = call i32 @XFlush(i32* %60)
%62 = call i32 @usleep(i32 1)
%63 = load i32, i32* @ButtonRelease
%64 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %5, i32 0, i32 0
store i32 %63, i32* %64
%65 = load i32*, i32** %3
%66 = load i32, i32* @PointerWindow
%67 = load i32, i32* @True
%68 = load i32, i32* @ButtonReleaseMask
%69 = call i64 @XSendEvent(i32* %65, i32 %66, i32 %67, i32 %68, %struct.TYPE_6__* %5)
%70 = icmp eq i64 %69, 0
br i1 %70, label %71, label %74
71: ; preds = %59
%72 = load i32, i32* @stderr
%73 = call i32 @fprintf(i32 %72, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
br label %74
74: ; preds = %71, %59
%75 = load i32*, i32** %3
%76 = call i32 @XFlush(i32* %75)
%77 = call i32 @usleep(i32 1)
ret void
}

LLVM IR (-O2):
%struct.TYPE_6__ = type { i32, %struct.TYPE_5__ }
%struct.TYPE_5__ = type { i32, i32, i32, i32, i32, i32, i64, i32, i64, i32 }
@True = global i32 0
@ButtonPress = global i32 0
@PointerWindow = global i32 0
@ButtonPressMask = global i32 0
@stderr = global i32 0
@.str = [26 x i8] c"Error to send the event!\0A\00"
@ButtonRelease = global i32 0
@ButtonReleaseMask = global i32 0
define void @click(i32* %0, i32 %1) {
%3 = alloca %struct.TYPE_6__
%4 = bitcast %struct.TYPE_6__* %3 to i8*
%5 = call i32 @memset(%struct.TYPE_6__* %3, i32 0, i32 64)
%6 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %3, i64 0, i32 1, i32 0
store i32 %1, i32* %6
%7 = load i32, i32* @True
%8 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %3, i64 0, i32 1, i32 9
store i32 %7, i32* %8
%9 = call i64 @DefaultRootWindow(i32* %0)
%10 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %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_6__, %struct.TYPE_6__* %3, i64 0, i32 1, i32 8
%14 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %3, i64 0, i32 1, i32 7
%15 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %3, i64 0, i32 1, i32 5
%16 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %3, i64 0, i32 1, i32 4
%17 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %3, i64 0, i32 1, i32 3
%18 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %3, i64 0, i32 1, i32 2
%19 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %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_6__, %struct.TYPE_6__* %3, i64 0, i32 0
store i32 %26, i32* %27
%28 = load i32, i32* @PointerWindow
%29 = load i32, i32* @True
%30 = load i32, i32* @ButtonPressMask
%31 = call i64 @XSendEvent(i32* %0, i32 %28, i32 %29, i32 %30, %struct.TYPE_6__* %3)
%32 = icmp eq i64 %31, 0
br i1 %32, label %33, label %36
33: ; preds = %25
%34 = load i32, i32* @stderr
%35 = call i32 @fprintf(i32 %34, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
br label %36
36: ; preds = %33, %25
%37 = call i32 @XFlush(i32* %0)
%38 = call i32 @usleep(i32 1)
%39 = load i32, i32* @ButtonRelease
store i32 %39, i32* %27
%40 = load i32, i32* @PointerWindow
%41 = load i32, i32* @True
%42 = load i32, i32* @ButtonReleaseMask
%43 = call i64 @XSendEvent(i32* %0, i32 %40, i32 %41, i32 %42, %struct.TYPE_6__* %3)
%44 = icmp eq i64 %43, 0
br i1 %44, label %45, label %48
45: ; preds = %36
%46 = load i32, i32* @stderr
%47 = call i32 @fprintf(i32 %46, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
br label %48
48: ; preds = %45, %36
%49 = call i32 @XFlush(i32* %0)
%50 = call i32 @usleep(i32 1)
ret void
}