#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 */

/* Type definitions */
typedef int /*<<< orphan*/ Window;
typedef int /*<<< orphan*/ Display;

/* Variables and functions */
int /*<<< orphan*/ DefaultRootWindow(int /*<<< orphan*/ *);
int DisplayHeight(int /*<<< orphan*/ *, int);
int DisplayWidth(int /*<<< orphan*/ *, int);
int /*<<< orphan*/ None;
int /*<<< orphan*/ STDIN_FILENO;
int ScreenCount(int /*<<< orphan*/ *);
int /*<<< orphan*/ XCloseDisplay(int /*<<< orphan*/ *);
int /*<<< orphan*/ XFlush(int /*<<< orphan*/ *);
int /*<<< orphan*/ *XOpenDisplay(int /*<<< orphan*/ *);
int /*<<< orphan*/ XWarpPointer(int /*<<< orphan*/ *, int /*<<< orphan*/,
                                int /*<<< orphan*/, int /*<<< orphan*/,
                                int /*<<< orphan*/, int /*<<< orphan*/,
                                int /*<<< orphan*/, int, int);
int /*<<< orphan*/ click(int /*<<< orphan*/ *, int /*<<< orphan*/, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ isatty(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, int, ...);
int /*<<< orphan*/ querypointer(int /*<<< orphan*/ *, int /*<<< orphan*/, int *,
                                int *);
int scanf(char *, int *, int *, int *);
int /*<<< orphan*/ stderr;
int main(int __attribute__((unused)) argc, char *argv[]) {
  Display *dpy = XOpenDisplay(NULL);
  if (!dpy) {
    fprintf(
        stderr,
        "Couldn't open display.\n"
        " - If you're running through SSH, try `DISPLAY=localhost:0.0 %s`.\n"
        " - If that didn't help, see http://unix.stackexchange.com/a/10126.\n",
        argv[0]);
    return 1;
  }
  Window root = DefaultRootWindow(dpy);
  for (int screen = 0; screen < ScreenCount(dpy); ++screen) {
    int width = DisplayWidth(dpy, screen);
    int height = DisplayHeight(dpy, screen);
    printf("Screen %d: %dx%d\n", screen, width, height);
  }
  int x, y, button = 1;
  querypointer(dpy, root, &x, &y);
  printf("Pre: %d,%d\n", x, y);
  if (!isatty(STDIN_FILENO)) {
    if (3 != scanf("%d %d %d", &x, &y, &button)) {
      fprintf(stderr,
              "Error in your input! It should be three integers: x y click\n");
      return 1;
    }
  } else
    x = y = 10;
  XWarpPointer(dpy, None, root, 0, 0, 0, 0, x, y);
  XFlush(dpy);
  if (button) {
    printf("Clicking button %d\n", button);
    click(dpy, root, button);
  }
  querypointer(dpy, root, &x, &y);
  printf("Post: %d,%d\n", x, y);
  XCloseDisplay(dpy);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   10a0 <XOpenDisplay@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1238 <main+0x58>
mov    0x2dc3(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xddb(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    13ed <main+0x20d>
mov    -0x18(%rbp),%rdi
call   1060 <DefaultRootWindow@plt>
mov    %eax,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    -0x18(%rbp),%rdi
call   1090 <ScreenCount@plt>
mov    %eax,%ecx
mov    -0x38(%rbp),%eax
cmp    %ecx,%eax
jge    12aa <main+0xca>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%esi
call   1050 <DisplayWidth@plt>
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%esi
call   1040 <DisplayHeight@plt>
mov    %eax,-0x28(%rbp)
mov    -0x20(%rbp),%esi
mov    -0x24(%rbp),%edx
mov    -0x28(%rbp),%ecx
lea    0xe08(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    124b <main+0x6b>
movl   $0x1,-0x34(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
lea    -0x2c(%rbp),%rdx
lea    -0x30(%rbp),%rcx
call   10d0 <querypointer@plt>
mov    -0x2c(%rbp),%esi
mov    -0x30(%rbp),%edx
lea    0xddd(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    0x2cf0(%rip),%rax
mov    (%rax),%edi
call   1030 <isatty@plt>
cmp    $0x0,%eax
jne    133f <main+0x15f>
lea    0xdc4(%rip),%rdi
lea    -0x2c(%rbp),%rsi
lea    -0x30(%rbp),%rdx
lea    -0x34(%rbp),%rcx
call   10c0 <scanf@plt>
mov    %eax,%ecx
mov    $0x3,%eax
cmp    %ecx,%eax
je     133a <main+0x15a>
mov    0x2cba(%rip),%rax
mov    (%rax),%edi
lea    0xd9d(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    13ed <main+0x20d>
jmp    134d <main+0x16d>
movl   $0xa,-0x30(%rbp)
movl   $0xa,-0x2c(%rbp)
mov    -0x18(%rbp),%rdi
mov    0x2c90(%rip),%rax
mov    (%rax),%esi
mov    -0x1c(%rbp),%edx
mov    -0x2c(%rbp),%r10d
mov    -0x30(%rbp),%eax
xor    %r9d,%r9d
mov    %r9d,%ecx
mov    %r9d,%r8d
movl   $0x0,(%rsp)
mov    %r10d,0x8(%rsp)
mov    %eax,0x10(%rsp)
call   1080 <XWarpPointer@plt>
mov    -0x18(%rbp),%rdi
call   10e0 <XFlush@plt>
cmpl   $0x0,-0x34(%rbp)
je     13b5 <main+0x1d5>
mov    -0x34(%rbp),%esi
lea    0xd62(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x34(%rbp),%edx
call   1100 <click@plt>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
lea    -0x2c(%rbp),%rdx
lea    -0x30(%rbp),%rcx
call   10d0 <querypointer@plt>
mov    -0x2c(%rbp),%esi
mov    -0x30(%rbp),%edx
lea    0xd3f(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x18(%rbp),%rdi
call   10f0 <XCloseDisplay@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbp
xor    %edi,%edi
call   10a0 <XOpenDisplay@plt>
test   %rax,%rax
je     12c6 <main+0xe6>
mov    %rax,%r12
mov    %rax,%rdi
call   1060 <DefaultRootWindow@plt>
mov    %eax,%r14d
mov    %r12,%rdi
call   1090 <ScreenCount@plt>
test   %eax,%eax
jle    1265 <main+0x85>
lea    0xe7d(%rip),%r15
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r12,%rdi
mov    %ebp,%esi
call   1050 <DisplayWidth@plt>
mov    %eax,%ebx
mov    %r12,%rdi
mov    %ebp,%esi
call   1040 <DisplayHeight@plt>
mov    %r15,%rdi
mov    %ebp,%esi
mov    %ebx,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1070 <printf@plt>
add    $0x1,%ebp
mov    %r12,%rdi
call   1090 <ScreenCount@plt>
cmp    %eax,%ebp
jl     1230 <main+0x50>
movl   $0x1,0xc(%rsp)
lea    0x8(%rsp),%rdx
lea    0x4(%rsp),%rcx
mov    %r12,%rdi
mov    %r14d,%esi
call   10d0 <querypointer@plt>
mov    0x8(%rsp),%esi
mov    0x4(%rsp),%edx
lea    0xe1e(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x2d31(%rip),%rax
mov    (%rax),%edi
call   1030 <isatty@plt>
test   %eax,%eax
je     12e6 <main+0x106>
movl   $0xa,0x4(%rsp)
movl   $0xa,0x8(%rsp)
mov    $0xa,%ebx
mov    $0xa,%eax
jmp    1312 <main+0x132>
mov    0x2d0b(%rip),%rax
mov    (%rax),%edi
mov    0x0(%rbp),%rdx
lea    0xd26(%rip),%rsi
xor    %eax,%eax
call   10b0 <fprintf@plt>
jmp    13b5 <main+0x1d5>
lea    0xdce(%rip),%rdi
lea    0x8(%rsp),%rsi
lea    0x4(%rsp),%rdx
lea    0xc(%rsp),%rcx
call   10c0 <scanf@plt>
cmp    $0x3,%eax
jne    139e <main+0x1be>
mov    0x8(%rsp),%eax
mov    0x4(%rsp),%ebx
mov    0x2ccf(%rip),%rcx
mov    (%rcx),%esi
sub    $0x8,%rsp
xor    %ebp,%ebp
mov    %r12,%rdi
mov    %r14d,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
xor    %r9d,%r9d
push   %rbx
push   %rax
push   $0x0
call   1080 <XWarpPointer@plt>
add    $0x20,%rsp
mov    %r12,%rdi
call   10e0 <XFlush@plt>
mov    0xc(%rsp),%esi
test   %esi,%esi
je     1369 <main+0x189>
lea    0xdae(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0xc(%rsp),%edx
mov    %r12,%rdi
mov    %r14d,%esi
call   1100 <click@plt>
lea    0x8(%rsp),%rdx
lea    0x4(%rsp),%rcx
mov    %r12,%rdi
mov    %r14d,%esi
call   10d0 <querypointer@plt>
mov    0x8(%rsp),%esi
mov    0x4(%rsp),%edx
lea    0xd88(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r12,%rdi
call   10f0 <XCloseDisplay@plt>
jmp    13ba <main+0x1da>
mov    0x2c33(%rip),%rax
mov    (%rax),%edi
lea    0xd16(%rip),%rsi
xor    %eax,%eax
call   10b0 <fprintf@plt>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [157 x i8] c"Couldn't open display.\0A - If you're running through SSH, try `DISPLAY=localhost:0.0 %s`.\0A - If that didn't help, see http://unix.stackexchange.com/a/10126.\0A\00"
@.str.1 = [18 x i8] c"Screen %d: %dx%d\0A\00"
@.str.2 = [12 x i8] c"Pre: %d,%d\0A\00"
@STDIN_FILENO = global i32 0
@.str.3 = [9 x i8] c"%d %d %d\00"
@.str.4 = [61 x i8] c"Error in your input! It should be three integers: x y click\0A\00"
@None = global i32 0
@.str.5 = [20 x i8] c"Clicking button %d\0A\00"
@.str.6 = [13 x i8] c"Post: %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 i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%14 = call i32* @XOpenDisplay(i32* null)
store i32* %14, i32** %6
%15 = load i32*, i32** %6
%16 = icmp ne i32* %15, null
br i1 %16, label %23, label %17
17: ; preds = %2
%18 = load i32, i32* @stderr
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 0
%21 = load i8*, i8** %20
%22 = call i32 (i32, i8*, ...) @fprintf(i32 %18, i8* getelementptr inbounds ([157 x i8], [157 x i8]* @.str, i64 0, i64 0), i8* %21)
store i32 1, i32* %3
br label %90
23: ; preds = %2
%24 = load i32*, i32** %6
%25 = call i32 @DefaultRootWindow(i32* %24)
store i32 %25, i32* %7
store i32 0, i32* %8
br label %26
26: ; preds = %42, %23
%27 = load i32, i32* %8
%28 = load i32*, i32** %6
%29 = call i32 @ScreenCount(i32* %28)
%30 = icmp slt i32 %27, %29
br i1 %30, label %31, label %45
31: ; preds = %26
%32 = load i32*, i32** %6
%33 = load i32, i32* %8
%34 = call i32 @DisplayWidth(i32* %32, i32 %33)
store i32 %34, i32* %9
%35 = load i32*, i32** %6
%36 = load i32, i32* %8
%37 = call i32 @DisplayHeight(i32* %35, i32 %36)
store i32 %37, i32* %10
%38 = load i32, i32* %8
%39 = load i32, i32* %9
%40 = load i32, i32* %10
%41 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 %38, i32 %39, i32 %40)
br label %42
42: ; preds = %31
%43 = load i32, i32* %8
%44 = add nsw i32 %43, 1
store i32 %44, i32* %8
br label %26
45: ; preds = %26
store i32 1, i32* %13
%46 = load i32*, i32** %6
%47 = load i32, i32* %7
%48 = call i32 @querypointer(i32* %46, i32 %47, i32* %11, i32* %12)
%49 = load i32, i32* %11
%50 = load i32, i32* %12
%51 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %49, i32 %50)
%52 = load i32, i32* @STDIN_FILENO
%53 = call i32 @isatty(i32 %52)
%54 = icmp ne i32 %53, 0
br i1 %54, label %62, label %55
55: ; preds = %45
%56 = call i32 @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32* %11, i32* %12, i32* %13)
%57 = icmp ne i32 3, %56
br i1 %57, label %58, label %61
58: ; preds = %55
%59 = load i32, i32* @stderr
%60 = call i32 (i32, i8*, ...) @fprintf(i32 %59, i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.4, i64 0, i64 0))
store i32 1, i32* %3
br label %90
61: ; preds = %55
br label %63
62: ; preds = %45
store i32 10, i32* %12
store i32 10, i32* %11
br label %63
63: ; preds = %62, %61
%64 = load i32*, i32** %6
%65 = load i32, i32* @None
%66 = load i32, i32* %7
%67 = load i32, i32* %11
%68 = load i32, i32* %12
%69 = call i32 @XWarpPointer(i32* %64, i32 %65, i32 %66, i32 0, i32 0, i32 0, i32 0, i32 %67, i32 %68)
%70 = load i32*, i32** %6
%71 = call i32 @XFlush(i32* %70)
%72 = load i32, i32* %13
%73 = icmp ne i32 %72, 0
br i1 %73, label %74, label %81
74: ; preds = %63
%75 = load i32, i32* %13
%76 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0), i32 %75)
%77 = load i32*, i32** %6
%78 = load i32, i32* %7
%79 = load i32, i32* %13
%80 = call i32 @click(i32* %77, i32 %78, i32 %79)
br label %81
81: ; preds = %74, %63
%82 = load i32*, i32** %6
%83 = load i32, i32* %7
%84 = call i32 @querypointer(i32* %82, i32 %83, i32* %11, i32* %12)
%85 = load i32, i32* %11
%86 = load i32, i32* %12
%87 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0), i32 %85, i32 %86)
%88 = load i32*, i32** %6
%89 = call i32 @XCloseDisplay(i32* %88)
store i32 0, i32* %3
br label %90
90: ; preds = %81, %58, %17
%91 = load i32, i32* %3
ret i32 %91
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [157 x i8] c"Couldn't open display.\0A - If you're running through SSH, try `DISPLAY=localhost:0.0 %s`.\0A - If that didn't help, see http://unix.stackexchange.com/a/10126.\0A\00"
@.str.1 = [18 x i8] c"Screen %d: %dx%d\0A\00"
@.str.2 = [12 x i8] c"Pre: %d,%d\0A\00"
@STDIN_FILENO = global i32 0
@.str.3 = [9 x i8] c"%d %d %d\00"
@.str.4 = [61 x i8] c"Error in your input! It should be three integers: x y click\0A\00"
@None = global i32 0
@.str.5 = [20 x i8] c"Clicking button %d\0A\00"
@.str.6 = [13 x i8] c"Post: %d,%d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = tail call i32* @XOpenDisplay(i32* null)
%7 = icmp eq i32* %6, null
br i1 %7, label %8, label %12
8: ; preds = %2
%9 = load i32, i32* @stderr
%10 = load i8*, i8** %1
%11 = tail call i32 (i32, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([157 x i8], [157 x i8]* @.str, i64 0, i64 0), i8* %10)
br label %65
12: ; preds = %2
%13 = tail call i32 @DefaultRootWindow(i32* %6)
%14 = tail call i32 @ScreenCount(i32* %6)
%15 = icmp sgt i32 %14, 0
br i1 %15, label %27, label %16
16: ; preds = %27, %12
%17 = bitcast i32* %3 to i8*
%18 = bitcast i32* %4 to i8*
%19 = bitcast i32* %5 to i8*
store i32 1, i32* %5
%20 = call i32 @querypointer(i32* %6, i32 %13, i32* %3, i32* %4)
%21 = load i32, i32* %3
%22 = load i32, i32* %4
%23 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %21, i32 %22)
%24 = load i32, i32* @STDIN_FILENO
%25 = call i32 @isatty(i32 %24)
%26 = icmp eq i32 %25, 0
br i1 %26, label %35, label %44
27: ; preds = %12, %27
%28 = phi i32 [ %32, %27 ], [ 0, %12 ]
%29 = tail call i32 @DisplayWidth(i32* %6, i32 %28)
%30 = tail call i32 @DisplayHeight(i32* %6, i32 %28)
%31 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 %28, i32 %29, i32 %30)
%32 = add nuw nsw i32 %28, 1
%33 = tail call i32 @ScreenCount(i32* %6)
%34 = icmp slt i32 %32, %33
br i1 %34, label %27, label %16
35: ; preds = %16
%36 = call i32 @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32* %3, i32* %4, i32* %5)
%37 = icmp eq i32 %36, 3
br i1 %37, label %38, label %41
38: ; preds = %35
%39 = load i32, i32* %3
%40 = load i32, i32* %4
br label %45
41: ; preds = %35
%42 = load i32, i32* @stderr
%43 = call i32 (i32, i8*, ...) @fprintf(i32 %42, i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.4, i64 0, i64 0))
br label %63
44: ; preds = %16
store i32 10, i32* %4
store i32 10, i32* %3
br label %45
45: ; preds = %38, %44
%46 = phi i32 [ %40, %38 ], [ 10, %44 ]
%47 = phi i32 [ %39, %38 ], [ 10, %44 ]
%48 = load i32, i32* @None
%49 = call i32 @XWarpPointer(i32* %6, i32 %48, i32 %13, i32 0, i32 0, i32 0, i32 0, i32 %47, i32 %46)
%50 = call i32 @XFlush(i32* %6)
%51 = load i32, i32* %5
%52 = icmp eq i32 %51, 0
br i1 %52, label %57, label %53
53: ; preds = %45
%54 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0), i32 %51)
%55 = load i32, i32* %5
%56 = call i32 @click(i32* %6, i32 %13, i32 %55)
br label %57
57: ; preds = %53, %45
%58 = call i32 @querypointer(i32* %6, i32 %13, i32* %3, i32* %4)
%59 = load i32, i32* %3
%60 = load i32, i32* %4
%61 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0), i32 %59, i32 %60)
%62 = call i32 @XCloseDisplay(i32* %6)
br label %63
63: ; preds = %57, %41
%64 = phi i32 [ 0, %57 ], [ 1, %41 ]
br label %65
65: ; preds = %63, %8
%66 = phi i32 [ %64, %63 ], [ 1, %8 ]
ret i32 %66
}