#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_2__ TYPE_1__;

/* Type definitions */
typedef int /*<<< orphan*/ uidev;
struct TYPE_2__ {
  int vendor;
  int product;
  int version;
  int /*<<< orphan*/ bustype;
};
struct uinput_user_dev {
  TYPE_1__ id;
  int /*<<< orphan*/ name;
};
struct input_event {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ BTN_LEFT;
int /*<<< orphan*/ BUS_USB;
int /*<<< orphan*/ EV_KEY;
int /*<<< orphan*/ EV_REL;
int /*<<< orphan*/ EXIT_FAILURE;
int O_NONBLOCK;
int O_WRONLY;
int /*<<< orphan*/ REL_X;
int /*<<< orphan*/ REL_Y;
int /*<<< orphan*/ UINPUT_MAX_NAME_SIZE;
int /*<<< orphan*/ UI_DEV_CREATE;
int /*<<< orphan*/ UI_DEV_DESTROY;
int /*<<< orphan*/ UI_SET_EVBIT;
int /*<<< orphan*/ UI_SET_KEYBIT;
int /*<<< orphan*/ UI_SET_RELBIT;
int /*<<< orphan*/ click(int);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
scalar_t__ ioctl(int, int /*<<< orphan*/, ...);
int /*<<< orphan*/ memset(struct uinput_user_dev *, int /*<<< orphan*/, int);
int /*<<< orphan*/ move_mouse(int, int, int);
int open(char *, int);
int /*<<< orphan*/ perror(char *);
int rand();
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ snprintf(int /*<<< orphan*/, int /*<<< orphan*/, char *);
scalar_t__ write(int, struct uinput_user_dev *, int);
int main(void) {
  int fd;
  struct uinput_user_dev uidev;
  struct input_event ev;
  int dx, dy;
  int i;
  if ((fd = open("/dev/uinput", O_WRONLY | O_NONBLOCK)) < 0)
    do {
      perror("error: open");
      exit(EXIT_FAILURE);
    } while (0);
  if (ioctl(fd, UI_SET_EVBIT, EV_KEY) < 0)
    do {
      perror("error: ioctl");
      exit(EXIT_FAILURE);
    } while (0);
  if (ioctl(fd, UI_SET_KEYBIT, BTN_LEFT) < 0)
    do {
      perror("error: ioctl");
      exit(EXIT_FAILURE);
    } while (0);
  if (ioctl(fd, UI_SET_EVBIT, EV_REL) < 0)
    do {
      perror("error: ioctl");
      exit(EXIT_FAILURE);
    } while (0);
  if (ioctl(fd, UI_SET_RELBIT, REL_X) < 0)
    do {
      perror("error: ioctl");
      exit(EXIT_FAILURE);
    } while (0);
  if (ioctl(fd, UI_SET_RELBIT, REL_Y) < 0)
    do {
      perror("error: ioctl");
      exit(EXIT_FAILURE);
    } while (0);
  memset(&uidev, 0, sizeof(uidev));
  snprintf(uidev.name, UINPUT_MAX_NAME_SIZE, "uinput-sample");
  uidev.id.bustype = BUS_USB;
  uidev.id.vendor = 0x1;
  uidev.id.product = 0x1;
  uidev.id.version = 1;
  if (write(fd, &uidev, sizeof(uidev)) < 0)
    do {
      perror("error: write");
      exit(EXIT_FAILURE);
    } while (0);
  if (ioctl(fd, UI_DEV_CREATE) < 0)
    do {
      perror("error: ioctl");
      exit(EXIT_FAILURE);
    } while (0);
  sleep(2);
  while (1) {
    for (i = 0; i < 100; i++) {
      move_mouse(fd, rand() % 10 - 5, rand() % 10 - 5);
    }
    sleep(2);
    click(fd);
    sleep(5);
  }
  sleep(2);
  if (ioctl(fd, UI_DEV_DESTROY) < 0)
    do {
      perror("error: ioctl");
      exit(EXIT_FAILURE);
    } while (0);
  close(fd);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2daa(%rip),%rax
mov    (%rax),%esi
mov    0x2e01(%rip),%rax
or     (%rax),%esi
lea    0xe28(%rip),%rdi
call   1080 <open@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jge    1208 <main+0x58>
jmp    11ee <main+0x3e>
lea    0xe17(%rip),%rdi
call   1090 <perror@plt>
mov    0x2d7f(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
mov    -0x8(%rbp),%edi
mov    0x2d96(%rip),%rax
mov    (%rax),%esi
mov    0x2da5(%rip),%rax
mov    (%rax),%edx
mov    $0x0,%al
call   1070 <ioctl@plt>
cmp    $0x0,%rax
jge    124d <main+0x9d>
jmp    1233 <main+0x83>
lea    0xdde(%rip),%rdi
call   1090 <perror@plt>
mov    0x2d3a(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
mov    -0x8(%rbp),%edi
mov    0x2d31(%rip),%rax
mov    (%rax),%esi
mov    0x2d68(%rip),%rax
mov    (%rax),%edx
mov    $0x0,%al
call   1070 <ioctl@plt>
cmp    $0x0,%rax
jge    1292 <main+0xe2>
jmp    1278 <main+0xc8>
lea    0xd99(%rip),%rdi
call   1090 <perror@plt>
mov    0x2cf5(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
mov    -0x8(%rbp),%edi
mov    0x2d0c(%rip),%rax
mov    (%rax),%esi
mov    0x2d0b(%rip),%rax
mov    (%rax),%edx
mov    $0x0,%al
call   1070 <ioctl@plt>
cmp    $0x0,%rax
jge    12d7 <main+0x127>
jmp    12bd <main+0x10d>
lea    0xd54(%rip),%rdi
call   1090 <perror@plt>
mov    0x2cb0(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
mov    -0x8(%rbp),%edi
mov    0x2cd7(%rip),%rax
mov    (%rax),%esi
mov    0x2cae(%rip),%rax
mov    (%rax),%edx
mov    $0x0,%al
call   1070 <ioctl@plt>
cmp    $0x0,%rax
jge    131c <main+0x16c>
jmp    1302 <main+0x152>
lea    0xd0f(%rip),%rdi
call   1090 <perror@plt>
mov    0x2c6b(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
mov    -0x8(%rbp),%edi
mov    0x2c92(%rip),%rax
mov    (%rax),%esi
mov    0x2cc9(%rip),%rax
mov    (%rax),%edx
mov    $0x0,%al
call   1070 <ioctl@plt>
cmp    $0x0,%rax
jge    1361 <main+0x1b1>
jmp    1347 <main+0x197>
lea    0xcca(%rip),%rdi
call   1090 <perror@plt>
mov    0x2c26(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0x14,%edx
call   1060 <memset@plt>
mov    -0x10(%rbp),%edi
mov    0x2c25(%rip),%rax
mov    (%rax),%esi
lea    0xca1(%rip),%rdx
call   1050 <snprintf@plt>
mov    0x2c50(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
movl   $0x1,-0x20(%rbp)
movl   $0x1,-0x1c(%rbp)
movl   $0x1,-0x18(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x20(%rbp),%rsi
mov    $0x14,%edx
call   1040 <write@plt>
cmp    $0x0,%rax
jge    13e4 <main+0x234>
jmp    13ca <main+0x21a>
lea    0xc62(%rip),%rdi
call   1090 <perror@plt>
mov    0x2ba3(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
mov    -0x8(%rbp),%edi
mov    0x2c02(%rip),%rax
mov    (%rax),%esi
mov    $0x0,%al
call   1070 <ioctl@plt>
cmp    $0x0,%rax
jge    1420 <main+0x270>
jmp    1406 <main+0x256>
lea    0xc0b(%rip),%rdi
call   1090 <perror@plt>
mov    0x2b67(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
mov    $0x2,%edi
call   10c0 <sleep@plt>
movl   $0x0,-0x34(%rbp)
cmpl   $0x64,-0x34(%rbp)
jge    1481 <main+0x2d1>
mov    -0x8(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    $0x0,%al
call   10d0 <rand@plt>
mov    $0xa,%ecx
cltd
idiv   %ecx
sub    $0x5,%edx
mov    %edx,-0x38(%rbp)
mov    $0x0,%al
call   10d0 <rand@plt>
mov    -0x3c(%rbp),%edi
mov    -0x38(%rbp),%esi
mov    $0xa,%ecx
cltd
idiv   %ecx
sub    $0x5,%edx
call   1030 <move_mouse@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1431 <main+0x281>
mov    $0x2,%edi
call   10c0 <sleep@plt>
mov    -0x8(%rbp),%edi
call   10b0 <click@plt>
mov    $0x5,%edi
call   10c0 <sleep@plt>
jmp    142a <main+0x27a>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    0x2daf(%rip),%rax
mov    0x2e08(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
lea    0xe2d(%rip),%rdi
call   1080 <open@plt>
test   %eax,%eax
js     13c9 <main+0x219>
mov    %eax,%r15d
mov    0x2dbe(%rip),%rbx
mov    (%rbx),%esi
mov    0x2dcd(%rip),%rax
mov    (%rax),%edx
mov    %r15d,%edi
xor    %eax,%eax
call   1070 <ioctl@plt>
test   %rax,%rax
js     13af <main+0x1ff>
mov    0x2d79(%rip),%rax
mov    (%rax),%esi
mov    0x2db0(%rip),%rax
mov    (%rax),%edx
mov    %r15d,%edi
xor    %eax,%eax
call   1070 <ioctl@plt>
test   %rax,%rax
js     13af <main+0x1ff>
mov    (%rbx),%esi
mov    0x2d7a(%rip),%rax
mov    (%rax),%edx
mov    %r15d,%edi
xor    %eax,%eax
call   1070 <ioctl@plt>
test   %rax,%rax
js     13af <main+0x1ff>
mov    0x2d66(%rip),%rbx
mov    (%rbx),%esi
mov    0x2d3d(%rip),%rax
mov    (%rax),%edx
mov    %r15d,%edi
xor    %eax,%eax
call   1070 <ioctl@plt>
test   %rax,%rax
js     13af <main+0x1ff>
mov    (%rbx),%esi
mov    0x2d7f(%rip),%rax
mov    (%rax),%edx
mov    %r15d,%edi
xor    %eax,%eax
call   1070 <ioctl@plt>
test   %rax,%rax
js     13af <main+0x1ff>
mov    %rsp,%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x14,%edx
call   1060 <memset@plt>
mov    0x10(%rsp),%edi
mov    0x2cf5(%rip),%rax
mov    (%rax),%esi
lea    0xd71(%rip),%rdx
call   1050 <snprintf@plt>
mov    0x2d20(%rip),%rax
mov    (%rax),%eax
mov    %eax,0xc(%rsp)
movabs $0x100000001,%rax
mov    %rax,(%rsp)
movl   $0x1,0x8(%rsp)
mov    %r15d,%edi
mov    %r14,%rsi
mov    $0x14,%edx
call   1040 <write@plt>
test   %rax,%rax
js     13d2 <main+0x222>
mov    0x2cf4(%rip),%rax
mov    (%rax),%esi
mov    %r15d,%edi
xor    %eax,%eax
call   1070 <ioctl@plt>
test   %rax,%rax
js     13af <main+0x1ff>
mov    $0x2,%edi
cs nopw 0x0(%rax,%rax,1)
call   10c0 <sleep@plt>
mov    $0x64,%ebx
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   10d0 <rand@plt>
cltq
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rcx
add    %edx,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
neg    %ecx
lea    (%rax,%rcx,1),%ebp
add    $0xfffffffb,%ebp
xor    %eax,%eax
call   10d0 <rand@plt>
cltq
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rcx
add    %edx,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
neg    %ecx
lea    (%rax,%rcx,1),%edx
add    $0xfffffffb,%edx
mov    %r15d,%edi
mov    %ebp,%esi
call   1030 <move_mouse@plt>
add    $0xffffffff,%ebx
jne    1330 <main+0x180>
mov    $0x2,%edi
call   10c0 <sleep@plt>
mov    %r15d,%edi
call   10b0 <click@plt>
mov    $0x5,%edi
jmp    1320 <main+0x170>
lea    0xc62(%rip),%rdi
call   1090 <perror@plt>
mov    0x2bbe(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
lea    0xc3c(%rip),%rdi
jmp    13b6 <main+0x206>
lea    0xc5a(%rip),%rdi
jmp    13b6 <main+0x206>

LLVM IR (-O0):
%struct.uinput_user_dev = type { %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32, i32, i32, i32 }
%struct.input_event = type { i32 }
@.str = [12 x i8] c"/dev/uinput\00"
@O_WRONLY = global i32 0
@O_NONBLOCK = global i32 0
@.str.1 = [12 x i8] c"error: open\00"
@EXIT_FAILURE = global i32 0
@UI_SET_EVBIT = global i32 0
@EV_KEY = global i32 0
@.str.2 = [13 x i8] c"error: ioctl\00"
@UI_SET_KEYBIT = global i32 0
@BTN_LEFT = global i32 0
@EV_REL = global i32 0
@UI_SET_RELBIT = global i32 0
@REL_X = global i32 0
@REL_Y = global i32 0
@UINPUT_MAX_NAME_SIZE = global i32 0
@.str.3 = [14 x i8] c"uinput-sample\00"
@BUS_USB = global i32 0
@.str.4 = [13 x i8] c"error: write\00"
@UI_DEV_CREATE = global i32 0
@UI_DEV_DESTROY = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca %struct.uinput_user_dev
%4 = alloca %struct.input_event
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
%8 = load i32, i32* @O_WRONLY
%9 = load i32, i32* @O_NONBLOCK
%10 = or i32 %8, %9
%11 = call i32 @open(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %10)
store i32 %11, i32* %2
%12 = icmp slt i32 %11, 0
br i1 %12, label %13, label %19
13: ; preds = %0
br label %14
14: ; preds = %13
%15 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%16 = load i32, i32* @EXIT_FAILURE
%17 = call i32 @exit(i32 %16)
unreachable
18: ; No predecessors!
br label %19
19: ; preds = %18, %0
%20 = load i32, i32* %2
%21 = load i32, i32* @UI_SET_EVBIT
%22 = load i32, i32* @EV_KEY
%23 = call i64 (i32, i32, ...) @ioctl(i32 %20, i32 %21, i32 %22)
%24 = icmp slt i64 %23, 0
br i1 %24, label %25, label %31
25: ; preds = %19
br label %26
26: ; preds = %25
%27 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%28 = load i32, i32* @EXIT_FAILURE
%29 = call i32 @exit(i32 %28)
unreachable
30: ; No predecessors!
br label %31
31: ; preds = %30, %19
%32 = load i32, i32* %2
%33 = load i32, i32* @UI_SET_KEYBIT
%34 = load i32, i32* @BTN_LEFT
%35 = call i64 (i32, i32, ...) @ioctl(i32 %32, i32 %33, i32 %34)
%36 = icmp slt i64 %35, 0
br i1 %36, label %37, label %43
37: ; preds = %31
br label %38
38: ; preds = %37
%39 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%40 = load i32, i32* @EXIT_FAILURE
%41 = call i32 @exit(i32 %40)
unreachable
42: ; No predecessors!
br label %43
43: ; preds = %42, %31
%44 = load i32, i32* %2
%45 = load i32, i32* @UI_SET_EVBIT
%46 = load i32, i32* @EV_REL
%47 = call i64 (i32, i32, ...) @ioctl(i32 %44, i32 %45, i32 %46)
%48 = icmp slt i64 %47, 0
br i1 %48, label %49, label %55
49: ; preds = %43
br label %50
50: ; preds = %49
%51 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%52 = load i32, i32* @EXIT_FAILURE
%53 = call i32 @exit(i32 %52)
unreachable
54: ; No predecessors!
br label %55
55: ; preds = %54, %43
%56 = load i32, i32* %2
%57 = load i32, i32* @UI_SET_RELBIT
%58 = load i32, i32* @REL_X
%59 = call i64 (i32, i32, ...) @ioctl(i32 %56, i32 %57, i32 %58)
%60 = icmp slt i64 %59, 0
br i1 %60, label %61, label %67
61: ; preds = %55
br label %62
62: ; preds = %61
%63 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%64 = load i32, i32* @EXIT_FAILURE
%65 = call i32 @exit(i32 %64)
unreachable
66: ; No predecessors!
br label %67
67: ; preds = %66, %55
%68 = load i32, i32* %2
%69 = load i32, i32* @UI_SET_RELBIT
%70 = load i32, i32* @REL_Y
%71 = call i64 (i32, i32, ...) @ioctl(i32 %68, i32 %69, i32 %70)
%72 = icmp slt i64 %71, 0
br i1 %72, label %73, label %79
73: ; preds = %67
br label %74
74: ; preds = %73
%75 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%76 = load i32, i32* @EXIT_FAILURE
%77 = call i32 @exit(i32 %76)
unreachable
78: ; No predecessors!
br label %79
79: ; preds = %78, %67
%80 = call i32 @memset(%struct.uinput_user_dev* %3, i32 0, i32 20)
%81 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %3, i32 0, i32 1
%82 = load i32, i32* %81
%83 = load i32, i32* @UINPUT_MAX_NAME_SIZE
%84 = call i32 @snprintf(i32 %82, i32 %83, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
%85 = load i32, i32* @BUS_USB
%86 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %3, i32 0, i32 0
%87 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %86, i32 0, i32 3
store i32 %85, i32* %87
%88 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %3, i32 0, i32 0
%89 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %88, i32 0, i32 0
store i32 1, i32* %89
%90 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %3, i32 0, i32 0
%91 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %90, i32 0, i32 1
store i32 1, i32* %91
%92 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %3, i32 0, i32 0
%93 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %92, i32 0, i32 2
store i32 1, i32* %93
%94 = load i32, i32* %2
%95 = call i64 @write(i32 %94, %struct.uinput_user_dev* %3, i32 20)
%96 = icmp slt i64 %95, 0
br i1 %96, label %97, label %103
97: ; preds = %79
br label %98
98: ; preds = %97
%99 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
%100 = load i32, i32* @EXIT_FAILURE
%101 = call i32 @exit(i32 %100)
unreachable
102: ; No predecessors!
br label %103
103: ; preds = %102, %79
%104 = load i32, i32* %2
%105 = load i32, i32* @UI_DEV_CREATE
%106 = call i64 (i32, i32, ...) @ioctl(i32 %104, i32 %105)
%107 = icmp slt i64 %106, 0
br i1 %107, label %108, label %114
108: ; preds = %103
br label %109
109: ; preds = %108
%110 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%111 = load i32, i32* @EXIT_FAILURE
%112 = call i32 @exit(i32 %111)
unreachable
113: ; No predecessors!
br label %114
114: ; preds = %113, %103
%115 = call i32 @sleep(i32 2)
br label %116
116: ; preds = %114, %132
store i32 0, i32* %7
br label %117
117: ; preds = %129, %116
%118 = load i32, i32* %7
%119 = icmp slt i32 %118, 100
br i1 %119, label %120, label %132
120: ; preds = %117
%121 = load i32, i32* %2
%122 = call i32 (...) @rand()
%123 = srem i32 %122, 10
%124 = sub nsw i32 %123, 5
%125 = call i32 (...) @rand()
%126 = srem i32 %125, 10
%127 = sub nsw i32 %126, 5
%128 = call i32 @move_mouse(i32 %121, i32 %124, i32 %127)
br label %129
129: ; preds = %120
%130 = load i32, i32* %7
%131 = add nsw i32 %130, 1
store i32 %131, i32* %7
br label %117
132: ; preds = %117
%133 = call i32 @sleep(i32 2)
%134 = load i32, i32* %2
%135 = call i32 @click(i32 %134)
%136 = call i32 @sleep(i32 5)
br label %116
}

LLVM IR (-O2):
%struct.uinput_user_dev = type { %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32, i32, i32, i32 }
@.str = [12 x i8] c"/dev/uinput\00"
@O_WRONLY = global i32 0
@O_NONBLOCK = global i32 0
@.str.1 = [12 x i8] c"error: open\00"
@EXIT_FAILURE = global i32 0
@UI_SET_EVBIT = global i32 0
@EV_KEY = global i32 0
@.str.2 = [13 x i8] c"error: ioctl\00"
@UI_SET_KEYBIT = global i32 0
@BTN_LEFT = global i32 0
@EV_REL = global i32 0
@UI_SET_RELBIT = global i32 0
@REL_X = global i32 0
@REL_Y = global i32 0
@UINPUT_MAX_NAME_SIZE = global i32 0
@.str.3 = [14 x i8] c"uinput-sample\00"
@BUS_USB = global i32 0
@.str.4 = [13 x i8] c"error: write\00"
@UI_DEV_CREATE = global i32 0
@UI_DEV_DESTROY = global i32 0
define i32 @main() {
%1 = alloca %struct.uinput_user_dev
%2 = bitcast %struct.uinput_user_dev* %1 to i8*
%3 = load i32, i32* @O_WRONLY
%4 = load i32, i32* @O_NONBLOCK
%5 = or i32 %4, %3
%6 = tail call i32 @open(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = icmp slt i32 %6, 0
br i1 %7, label %8, label %12
8: ; preds = %0
%9 = tail call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%10 = load i32, i32* @EXIT_FAILURE
%11 = tail call i32 @exit(i32 %10)
unreachable
12: ; preds = %0
%13 = load i32, i32* @UI_SET_EVBIT
%14 = load i32, i32* @EV_KEY
%15 = tail call i64 (i32, i32, ...) @ioctl(i32 %6, i32 %13, i32 %14)
%16 = icmp slt i64 %15, 0
br i1 %16, label %17, label %21
17: ; preds = %12
%18 = tail call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%19 = load i32, i32* @EXIT_FAILURE
%20 = tail call i32 @exit(i32 %19)
unreachable
21: ; preds = %12
%22 = load i32, i32* @UI_SET_KEYBIT
%23 = load i32, i32* @BTN_LEFT
%24 = tail call i64 (i32, i32, ...) @ioctl(i32 %6, i32 %22, i32 %23)
%25 = icmp slt i64 %24, 0
br i1 %25, label %26, label %30
26: ; preds = %21
%27 = tail call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%28 = load i32, i32* @EXIT_FAILURE
%29 = tail call i32 @exit(i32 %28)
unreachable
30: ; preds = %21
%31 = load i32, i32* @UI_SET_EVBIT
%32 = load i32, i32* @EV_REL
%33 = tail call i64 (i32, i32, ...) @ioctl(i32 %6, i32 %31, i32 %32)
%34 = icmp slt i64 %33, 0
br i1 %34, label %35, label %39
35: ; preds = %30
%36 = tail call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%37 = load i32, i32* @EXIT_FAILURE
%38 = tail call i32 @exit(i32 %37)
unreachable
39: ; preds = %30
%40 = load i32, i32* @UI_SET_RELBIT
%41 = load i32, i32* @REL_X
%42 = tail call i64 (i32, i32, ...) @ioctl(i32 %6, i32 %40, i32 %41)
%43 = icmp slt i64 %42, 0
br i1 %43, label %44, label %48
44: ; preds = %39
%45 = tail call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%46 = load i32, i32* @EXIT_FAILURE
%47 = tail call i32 @exit(i32 %46)
unreachable
48: ; preds = %39
%49 = load i32, i32* @UI_SET_RELBIT
%50 = load i32, i32* @REL_Y
%51 = tail call i64 (i32, i32, ...) @ioctl(i32 %6, i32 %49, i32 %50)
%52 = icmp slt i64 %51, 0
br i1 %52, label %53, label %57
53: ; preds = %48
%54 = tail call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%55 = load i32, i32* @EXIT_FAILURE
%56 = tail call i32 @exit(i32 %55)
unreachable
57: ; preds = %48
%58 = call i32 @memset(%struct.uinput_user_dev* %1, i32 0, i32 20)
%59 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %1, i64 0, i32 1
%60 = load i32, i32* %59
%61 = load i32, i32* @UINPUT_MAX_NAME_SIZE
%62 = call i32 @snprintf(i32 %60, i32 %61, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
%63 = load i32, i32* @BUS_USB
%64 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %1, i64 0, i32 0, i32 3
store i32 %63, i32* %64
%65 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %1, i64 0, i32 0, i32 0
store i32 1, i32* %65
%66 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %1, i64 0, i32 0, i32 1
store i32 1, i32* %66
%67 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %1, i64 0, i32 0, i32 2
store i32 1, i32* %67
%68 = call i64 @write(i32 %6, %struct.uinput_user_dev* %1, i32 20)
%69 = icmp slt i64 %68, 0
br i1 %69, label %70, label %74
70: ; preds = %57
%71 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
%72 = load i32, i32* @EXIT_FAILURE
%73 = call i32 @exit(i32 %72)
unreachable
74: ; preds = %57
%75 = load i32, i32* @UI_DEV_CREATE
%76 = call i64 (i32, i32, ...) @ioctl(i32 %6, i32 %75)
%77 = icmp slt i64 %76, 0
br i1 %77, label %78, label %82
78: ; preds = %74
%79 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%80 = load i32, i32* @EXIT_FAILURE
%81 = call i32 @exit(i32 %80)
unreachable
82: ; preds = %74, %96
%83 = phi i32 [ 5, %96 ], [ 2, %74 ]
%84 = call i32 @sleep(i32 %83)
br label %85
85: ; preds = %82, %85
%86 = phi i32 [ 0, %82 ], [ %94, %85 ]
%87 = call i32 (...) @rand()
%88 = srem i32 %87, 10
%89 = add nsw i32 %88, -5
%90 = call i32 (...) @rand()
%91 = srem i32 %90, 10
%92 = add nsw i32 %91, -5
%93 = call i32 @move_mouse(i32 %6, i32 %89, i32 %92)
%94 = add nuw nsw i32 %86, 1
%95 = icmp eq i32 %94, 100
br i1 %95, label %96, label %85
96: ; preds = %85
%97 = call i32 @sleep(i32 2)
%98 = call i32 @click(i32 %6)
br label %82
}