#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 {
  int value;
  void *code;
  void *type;
  TYPE_1__ id;
  int /*<<< orphan*/ name;
};
struct input_event {
  int value;
  void *code;
  void *type;
  TYPE_1__ id;
  int /*<<< orphan*/ name;
};

/* Variables and functions */
int /*<<< orphan*/ BTN_LEFT;
int /*<<< orphan*/ BUS_USB;
void *EV_KEY;
int /*<<< orphan*/ EXIT_FAILURE;
void *KEY_D;
int O_NONBLOCK;
int O_WRONLY;
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*/ close(int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
scalar_t__ ioctl(int, int /*<<< orphan*/, ...);
int /*<<< orphan*/ memset(struct uinput_user_dev *, int /*<<< orphan*/, int);
int open(char *, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ snprintf(int /*<<< orphan*/, int /*<<< orphan*/, char *);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
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;
  fd = open("/dev/uinput", O_WRONLY | O_NONBLOCK);
  if (fd < 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);
  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);
  srand(time(NULL));
  while (1) {
    memset(&ev, 0, sizeof(struct input_event));
    ev.type = EV_KEY;
    ev.code = KEY_D;
    ev.value = 1;
    if (write(fd, &ev, sizeof(struct input_event)) < 0)
      do {
        perror("error: write");
        exit(EXIT_FAILURE);
      } while (0);
    memset(&ev, 0, sizeof(struct input_event));
    ev.type = EV_KEY;
    ev.code = KEY_D;
    ev.value = 0;
    if (write(fd, &ev, sizeof(struct input_event)) < 0)
      do {
        perror("error: write");
        exit(EXIT_FAILURE);
      } while (0);
    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    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2dcf(%rip),%rax
mov    (%rax),%esi
mov    0x2e16(%rip),%rax
or     (%rax),%esi
lea    0xe35(%rip),%rdi
call   1090 <open@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    11fc <main+0x5c>
jmp    11e2 <main+0x42>
lea    0xe23(%rip),%rdi
call   10a0 <perror@plt>
mov    0x2da3(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>
mov    -0x8(%rbp),%edi
mov    0x2dba(%rip),%rax
mov    (%rax),%esi
mov    0x2db9(%rip),%rax
mov    (%rax),%rdx
mov    $0x0,%al
call   1060 <ioctl@plt>
cmp    $0x0,%rax
jge    1242 <main+0xa2>
jmp    1228 <main+0x88>
lea    0xde9(%rip),%rdi
call   10a0 <perror@plt>
mov    0x2d5d(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>
mov    -0x8(%rbp),%edi
mov    0x2d5c(%rip),%rax
mov    (%rax),%esi
mov    0x2d7b(%rip),%rax
mov    (%rax),%edx
mov    $0x0,%al
call   1060 <ioctl@plt>
cmp    $0x0,%rax
jge    1287 <main+0xe7>
jmp    126d <main+0xcd>
lea    0xda4(%rip),%rdi
call   10a0 <perror@plt>
mov    0x2d18(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>
lea    -0x38(%rbp),%rdi
xor    %esi,%esi
mov    $0x30,%edx
call   1050 <memset@plt>
mov    -0x10(%rbp),%edi
mov    0x2d17(%rip),%rax
mov    (%rax),%esi
lea    0xd7b(%rip),%rdx
call   1040 <snprintf@plt>
mov    0x2d32(%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    -0x38(%rbp),%rsi
mov    $0x30,%edx
call   1030 <write@plt>
cmp    $0x0,%rax
jge    130a <main+0x16a>
jmp    12f0 <main+0x150>
lea    0xd3c(%rip),%rdi
call   10a0 <perror@plt>
mov    0x2c95(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>
mov    -0x8(%rbp),%edi
mov    0x2ce4(%rip),%rax
mov    (%rax),%esi
mov    $0x0,%al
call   1060 <ioctl@plt>
cmp    $0x0,%rax
jge    1346 <main+0x1a6>
jmp    132c <main+0x18c>
lea    0xce5(%rip),%rdi
call   10a0 <perror@plt>
mov    0x2c59(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1080 <time@plt>
mov    %eax,%edi
call   1070 <srand@plt>
lea    -0x68(%rbp),%rdi
xor    %esi,%esi
mov    $0x30,%edx
call   1050 <memset@plt>
mov    0x2c5b(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x58(%rbp)
mov    0x2c25(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x60(%rbp)
movl   $0x1,-0x68(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x68(%rbp),%rsi
mov    $0x30,%edx
call   1030 <write@plt>
cmp    $0x0,%rax
jge    13c3 <main+0x223>
jmp    13a9 <main+0x209>
lea    0xc83(%rip),%rdi
call   10a0 <perror@plt>
mov    0x2bdc(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>
lea    -0x68(%rbp),%rdi
xor    %esi,%esi
mov    $0x30,%edx
call   1050 <memset@plt>
mov    0x2bee(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x58(%rbp)
mov    0x2bb8(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x60(%rbp)
movl   $0x0,-0x68(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x68(%rbp),%rsi
mov    $0x30,%edx
call   1030 <write@plt>
cmp    $0x0,%rax
jge    1430 <main+0x290>
jmp    1416 <main+0x276>
lea    0xc16(%rip),%rdi
call   10a0 <perror@plt>
mov    0x2b6f(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>
mov    $0x5,%edi
call   10c0 <sleep@plt>
jmp    1356 <main+0x1b6>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x68,%rsp
mov    0x2dd7(%rip),%rax
mov    0x2e20(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
lea    0xe3d(%rip),%rdi
call   1090 <open@plt>
test   %eax,%eax
jns    11d8 <main+0x38>
lea    0xe39(%rip),%rdi
jmp    12af <main+0x10f>
mov    %eax,%r15d
mov    0x2dde(%rip),%rax
mov    (%rax),%esi
mov    0x2ddd(%rip),%r14
mov    (%r14),%rdx
mov    %r15d,%edi
xor    %eax,%eax
call   1060 <ioctl@plt>
test   %rax,%rax
js     12a8 <main+0x108>
mov    0x2da0(%rip),%rax
mov    (%rax),%esi
mov    0x2dbf(%rip),%rax
mov    (%rax),%edx
mov    %r15d,%edi
xor    %eax,%eax
call   1060 <ioctl@plt>
test   %rax,%rax
js     12a8 <main+0x108>
lea    0x38(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x30,%edx
call   1050 <memset@plt>
mov    0x60(%rsp),%edi
mov    0x2d73(%rip),%rax
mov    (%rax),%esi
lea    0xdd7(%rip),%rdx
call   1040 <snprintf@plt>
mov    0x2d8e(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x5c(%rsp)
movabs $0x100000001,%rax
mov    %rax,0x50(%rsp)
movl   $0x1,0x58(%rsp)
mov    %r15d,%edi
mov    %rbx,%rsi
mov    $0x30,%edx
call   1030 <write@plt>
test   %rax,%rax
js     13b8 <main+0x218>
mov    0x2d61(%rip),%rax
mov    (%rax),%esi
mov    %r15d,%edi
xor    %eax,%eax
call   1060 <ioctl@plt>
test   %rax,%rax
jns    12c2 <main+0x122>
lea    0xd69(%rip),%rdi
call   10a0 <perror@plt>
mov    0x2cdd(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>
xor    %edi,%edi
call   1080 <time@plt>
mov    %eax,%edi
call   1070 <srand@plt>
lea    0x8(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x30,%edx
call   1050 <memset@plt>
mov    (%r14),%rax
mov    %rax,0x18(%rsp)
mov    0x2cad(%rip),%rbp
mov    0x0(%rbp),%rax
mov    %rax,0x10(%rsp)
movl   $0x1,0x8(%rsp)
mov    %r15d,%edi
mov    %rbx,%rsi
mov    $0x30,%edx
call   1030 <write@plt>
test   %rax,%rax
js     13b8 <main+0x218>
lea    0x8(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x30,%edx
call   1050 <memset@plt>
mov    (%r14),%rax
mov    %rax,0x18(%rsp)
mov    0x0(%rbp),%rax
mov    %rax,0x10(%rsp)
movl   $0x0,0x8(%rsp)
mov    %r15d,%edi
mov    %rbx,%rsi
mov    $0x30,%edx
call   1030 <write@plt>
test   %rax,%rax
js     13b8 <main+0x218>
mov    $0x5,%edi
call   10c0 <sleep@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x30,%edx
call   1050 <memset@plt>
mov    (%r14),%rax
mov    %rax,0x18(%rsp)
mov    0x0(%rbp),%rax
mov    %rax,0x10(%rsp)
movl   $0x1,0x8(%rsp)
mov    %r15d,%edi
mov    %rbx,%rsi
mov    $0x30,%edx
call   1030 <write@plt>
test   %rax,%rax
jns    1330 <main+0x190>
lea    0xc74(%rip),%rdi
jmp    12af <main+0x10f>

LLVM IR (-O0):
%struct.uinput_user_dev = type { i32, i8*, i8*, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32, i32, i32, i32 }
%struct.input_event = type { i32, i8*, i8*, %struct.TYPE_2__, 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 i8* null
@.str.2 = [13 x i8] c"error: ioctl\00"
@UI_SET_KEYBIT = global i32 0
@BTN_LEFT = 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
@KEY_D = global i8* null
@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 = load i32, i32* %2
%13 = icmp slt i32 %12, 0
br i1 %13, label %14, label %20
14: ; preds = %0
br label %15
15: ; preds = %14
%16 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%17 = load i32, i32* @EXIT_FAILURE
%18 = call i32 @exit(i32 %17)
unreachable
19: ; No predecessors!
br label %20
20: ; preds = %19, %0
%21 = load i32, i32* %2
%22 = load i32, i32* @UI_SET_EVBIT
%23 = load i8*, i8** @EV_KEY
%24 = call i64 (i32, i32, ...) @ioctl(i32 %21, i32 %22, i8* %23)
%25 = icmp slt i64 %24, 0
br i1 %25, label %26, label %32
26: ; preds = %20
br label %27
27: ; preds = %26
%28 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%29 = load i32, i32* @EXIT_FAILURE
%30 = call i32 @exit(i32 %29)
unreachable
31: ; No predecessors!
br label %32
32: ; preds = %31, %20
%33 = load i32, i32* %2
%34 = load i32, i32* @UI_SET_KEYBIT
%35 = load i32, i32* @BTN_LEFT
%36 = call i64 (i32, i32, ...) @ioctl(i32 %33, i32 %34, i32 %35)
%37 = icmp slt i64 %36, 0
br i1 %37, label %38, label %44
38: ; preds = %32
br label %39
39: ; preds = %38
%40 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%41 = load i32, i32* @EXIT_FAILURE
%42 = call i32 @exit(i32 %41)
unreachable
43: ; No predecessors!
br label %44
44: ; preds = %43, %32
%45 = call i32 @memset(%struct.uinput_user_dev* %3, i32 0, i32 48)
%46 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %3, i32 0, i32 4
%47 = load i32, i32* %46
%48 = load i32, i32* @UINPUT_MAX_NAME_SIZE
%49 = call i32 @snprintf(i32 %47, i32 %48, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
%50 = load i32, i32* @BUS_USB
%51 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %3, i32 0, i32 3
%52 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %51, i32 0, i32 3
store i32 %50, i32* %52
%53 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %3, i32 0, i32 3
%54 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %53, i32 0, i32 0
store i32 1, i32* %54
%55 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %3, i32 0, i32 3
%56 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %55, i32 0, i32 1
store i32 1, i32* %56
%57 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %3, i32 0, i32 3
%58 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %57, i32 0, i32 2
store i32 1, i32* %58
%59 = load i32, i32* %2
%60 = call i64 @write(i32 %59, %struct.uinput_user_dev* %3, i32 48)
%61 = icmp slt i64 %60, 0
br i1 %61, label %62, label %68
62: ; preds = %44
br label %63
63: ; preds = %62
%64 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
%65 = load i32, i32* @EXIT_FAILURE
%66 = call i32 @exit(i32 %65)
unreachable
67: ; No predecessors!
br label %68
68: ; preds = %67, %44
%69 = load i32, i32* %2
%70 = load i32, i32* @UI_DEV_CREATE
%71 = call i64 (i32, i32, ...) @ioctl(i32 %69, i32 %70)
%72 = icmp slt i64 %71, 0
br i1 %72, label %73, label %79
73: ; preds = %68
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, %68
%80 = call i32 @time(i32* null)
%81 = call i32 @srand(i32 %80)
br label %82
82: ; preds = %79, %118
%83 = bitcast %struct.input_event* %4 to %struct.uinput_user_dev*
%84 = call i32 @memset(%struct.uinput_user_dev* %83, i32 0, i32 48)
%85 = load i8*, i8** @EV_KEY
%86 = getelementptr inbounds %struct.input_event, %struct.input_event* %4, i32 0, i32 2
store i8* %85, i8** %86
%87 = load i8*, i8** @KEY_D
%88 = getelementptr inbounds %struct.input_event, %struct.input_event* %4, i32 0, i32 1
store i8* %87, i8** %88
%89 = getelementptr inbounds %struct.input_event, %struct.input_event* %4, i32 0, i32 0
store i32 1, i32* %89
%90 = load i32, i32* %2
%91 = bitcast %struct.input_event* %4 to %struct.uinput_user_dev*
%92 = call i64 @write(i32 %90, %struct.uinput_user_dev* %91, i32 48)
%93 = icmp slt i64 %92, 0
br i1 %93, label %94, label %100
94: ; preds = %82
br label %95
95: ; preds = %94
%96 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
%97 = load i32, i32* @EXIT_FAILURE
%98 = call i32 @exit(i32 %97)
unreachable
99: ; No predecessors!
br label %100
100: ; preds = %99, %82
%101 = bitcast %struct.input_event* %4 to %struct.uinput_user_dev*
%102 = call i32 @memset(%struct.uinput_user_dev* %101, i32 0, i32 48)
%103 = load i8*, i8** @EV_KEY
%104 = getelementptr inbounds %struct.input_event, %struct.input_event* %4, i32 0, i32 2
store i8* %103, i8** %104
%105 = load i8*, i8** @KEY_D
%106 = getelementptr inbounds %struct.input_event, %struct.input_event* %4, i32 0, i32 1
store i8* %105, i8** %106
%107 = getelementptr inbounds %struct.input_event, %struct.input_event* %4, i32 0, i32 0
store i32 0, i32* %107
%108 = load i32, i32* %2
%109 = bitcast %struct.input_event* %4 to %struct.uinput_user_dev*
%110 = call i64 @write(i32 %108, %struct.uinput_user_dev* %109, i32 48)
%111 = icmp slt i64 %110, 0
br i1 %111, label %112, label %118
112: ; preds = %100
br label %113
113: ; preds = %112
%114 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
%115 = load i32, i32* @EXIT_FAILURE
%116 = call i32 @exit(i32 %115)
unreachable
117: ; No predecessors!
br label %118
118: ; preds = %117, %100
%119 = call i32 @sleep(i32 5)
br label %82
}

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