#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 */
struct uinput_user_dev {
  scalar_t__ *name;
};
typedef int /*<<< orphan*/ dev;

/* Variables and functions */
int /*<<< orphan*/ BTN_LEFT;
int /*<<< orphan*/ BTN_MIDDLE;
int /*<<< orphan*/ BTN_RIGHT;
int /*<<< orphan*/ EV_KEY;
int /*<<< orphan*/ EV_REL;
int /*<<< orphan*/ O_RDWR;
int /*<<< orphan*/ REL_WHEEL;
int /*<<< orphan*/ REL_X;
int /*<<< orphan*/ REL_Y;
int /*<<< orphan*/ UI_DEV_CREATE;
int /*<<< orphan*/ UI_SET_EVBIT;
int /*<<< orphan*/ UI_SET_KEYBIT;
int /*<<< orphan*/ UI_SET_RELBIT;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
scalar_t__ ioctl(int, int /*<<< orphan*/, ...);
int /*<<< orphan*/ memset(struct uinput_user_dev *, int /*<<< orphan*/, int);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ perror(int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strncpy(scalar_t__ *, char const *, int);
int write(int, struct uinput_user_dev *, int);
int setup_uinputfd(const char *name) {
  int fd;
  struct uinput_user_dev dev;
  fd = open("/dev/input/uinput", O_RDWR);
  if (fd == -1) {
    fd = open("/dev/uinput", O_RDWR);
    if (fd == -1) {
      fd = open("/dev/misc/uinput", O_RDWR);
      if (fd == -1) {
        fprintf(stderr, "could not open %s\n", "uinput");
        perror(NULL);
        return -1;
      }
    }
  }
  memset(&dev, 0, sizeof(dev));
  strncpy(dev.name, name, sizeof(dev.name));
  dev.name[sizeof(dev.name) - 1] = 0;
  if (write(fd, &dev, sizeof(dev)) != sizeof(dev)) {
    goto setup_error;
  }
  if ((ioctl(fd, UI_SET_EVBIT, EV_KEY) != 0) ||
      (ioctl(fd, UI_SET_KEYBIT, BTN_LEFT) != 0) ||
      (ioctl(fd, UI_SET_KEYBIT, BTN_MIDDLE) != 0) ||
      (ioctl(fd, UI_SET_KEYBIT, BTN_RIGHT) != 0)) {
    goto setup_error;
  }
  if ((ioctl(fd, UI_SET_EVBIT, EV_REL) != 0) ||
      (ioctl(fd, UI_SET_RELBIT, REL_X) != 0) ||
      (ioctl(fd, UI_SET_RELBIT, REL_Y) != 0) ||
      (ioctl(fd, UI_SET_RELBIT, REL_WHEEL) != 0)) {
    goto setup_error;
  }
  if (ioctl(fd, UI_DEV_CREATE) != 0) {
    goto setup_error;
  }
  return fd;
setup_error:
  fprintf(stderr, "could not setup %s\n", "uinput");
  perror(NULL);
  close(fd);
  return -1;
}


x86 assembly (clang, -O0):
<setup_uinputfd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    0x2e3d(%rip),%rax
mov    (%rax),%esi
lea    0xe64(%rip),%rdi
call   1090 <open@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    122d <setup_uinputfd+0xad>
mov    0x2e1b(%rip),%rax
mov    (%rax),%esi
lea    0xe54(%rip),%rdi
call   1090 <open@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    1228 <setup_uinputfd+0xa8>
mov    0x2df9(%rip),%rax
mov    (%rax),%esi
lea    0xe3e(%rip),%rdi
call   1090 <open@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    1223 <setup_uinputfd+0xa3>
mov    0x2d87(%rip),%rax
mov    (%rax),%edi
lea    0xe2d(%rip),%rsi
lea    0xe1f(%rip),%rdx
call   1080 <fprintf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10a0 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1418 <setup_uinputfd+0x298>
jmp    1228 <setup_uinputfd+0xa8>
jmp    122d <setup_uinputfd+0xad>
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1050 <memset@plt>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x8,%edx
call   1030 <strncpy@plt>
mov    -0x20(%rbp),%rax
movq   $0x0,0x38(%rax)
mov    -0x14(%rbp),%edi
lea    -0x20(%rbp),%rsi
mov    $0x8,%edx
call   1040 <write@plt>
cltq
cmp    $0x8,%rax
je     127d <setup_uinputfd+0xfd>
jmp    13e4 <setup_uinputfd+0x264>
mov    -0x14(%rbp),%edi
mov    0x2d19(%rip),%rax
mov    (%rax),%esi
mov    0x2d28(%rip),%rax
mov    (%rax),%edx
mov    $0x0,%al
call   1060 <ioctl@plt>
cmp    $0x0,%rax
jne    1315 <setup_uinputfd+0x195>
mov    -0x14(%rbp),%edi
mov    0x2cdb(%rip),%rax
mov    (%rax),%esi
mov    0x2d0a(%rip),%rax
mov    (%rax),%edx
mov    $0x0,%al
call   1060 <ioctl@plt>
cmp    $0x0,%rax
jne    1315 <setup_uinputfd+0x195>
mov    -0x14(%rbp),%edi
mov    0x2cb5(%rip),%rax
mov    (%rax),%esi
mov    0x2c9c(%rip),%rax
mov    (%rax),%edx
mov    $0x0,%al
call   1060 <ioctl@plt>
cmp    $0x0,%rax
jne    1315 <setup_uinputfd+0x195>
mov    -0x14(%rbp),%edi
mov    0x2c8f(%rip),%rax
mov    (%rax),%esi
mov    0x2cee(%rip),%rax
mov    (%rax),%edx
mov    $0x0,%al
call   1060 <ioctl@plt>
cmp    $0x0,%rax
je     131a <setup_uinputfd+0x19a>
jmp    13e4 <setup_uinputfd+0x264>
mov    -0x14(%rbp),%edi
mov    0x2c7c(%rip),%rax
mov    (%rax),%esi
mov    0x2c7b(%rip),%rax
mov    (%rax),%edx
mov    $0x0,%al
call   1060 <ioctl@plt>
cmp    $0x0,%rax
jne    13b2 <setup_uinputfd+0x232>
mov    -0x14(%rbp),%edi
mov    0x2c66(%rip),%rax
mov    (%rax),%esi
mov    0x2c45(%rip),%rax
mov    (%rax),%edx
mov    $0x0,%al
call   1060 <ioctl@plt>
cmp    $0x0,%rax
jne    13b2 <setup_uinputfd+0x232>
mov    -0x14(%rbp),%edi
mov    0x2c40(%rip),%rax
mov    (%rax),%esi
mov    0x2c7f(%rip),%rax
mov    (%rax),%edx
mov    $0x0,%al
call   1060 <ioctl@plt>
cmp    $0x0,%rax
jne    13b2 <setup_uinputfd+0x232>
mov    -0x14(%rbp),%edi
mov    0x2c1a(%rip),%rax
mov    (%rax),%esi
mov    0x2c29(%rip),%rax
mov    (%rax),%edx
mov    $0x0,%al
call   1060 <ioctl@plt>
cmp    $0x0,%rax
je     13b7 <setup_uinputfd+0x237>
jmp    13e4 <setup_uinputfd+0x264>
mov    -0x14(%rbp),%edi
mov    0x2c27(%rip),%rax
mov    (%rax),%esi
mov    $0x0,%al
call   1060 <ioctl@plt>
cmp    $0x0,%rax
je     13d9 <setup_uinputfd+0x259>
jmp    13e4 <setup_uinputfd+0x264>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1418 <setup_uinputfd+0x298>
mov    0x2b95(%rip),%rax
mov    (%rax),%edi
lea    0xc4e(%rip),%rsi
lea    0xc2d(%rip),%rdx
call   1080 <fprintf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10a0 <perror@plt>
mov    -0x14(%rbp),%edi
call   1070 <close@plt>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<setup_uinputfd>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%r14
mov    0x2e3d(%rip),%r15
mov    (%r15),%esi
lea    0xe63(%rip),%rdi
call   1090 <open@plt>
mov    %eax,%ebx
cmp    $0xffffffff,%eax
jne    11d9 <setup_uinputfd+0x59>
mov    (%r15),%esi
lea    0xe5f(%rip),%rdi
call   1090 <open@plt>
mov    %eax,%ebx
cmp    $0xffffffff,%eax
jne    11d9 <setup_uinputfd+0x59>
mov    (%r15),%esi
lea    0xe55(%rip),%rdi
call   1090 <open@plt>
mov    %eax,%ebx
cmp    $0xffffffff,%eax
je     136b <setup_uinputfd+0x1eb>
lea    0x8(%rsp),%r15
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1050 <memset@plt>
mov    0x8(%rsp),%rdi
mov    %r14,%rsi
mov    $0x8,%edx
call   1030 <strncpy@plt>
mov    0x8(%rsp),%rax
movq   $0x0,0x38(%rax)
mov    %ebx,%edi
mov    %r15,%rsi
mov    $0x8,%edx
call   1040 <write@plt>
cmp    $0x8,%eax
jne    1330 <setup_uinputfd+0x1b0>
mov    0x2d75(%rip),%r14
mov    (%r14),%esi
mov    0x2d83(%rip),%rax
mov    (%rax),%edx
mov    %ebx,%edi
xor    %eax,%eax
call   1060 <ioctl@plt>
test   %rax,%rax
jne    1330 <setup_uinputfd+0x1b0>
mov    0x2d38(%rip),%r15
mov    (%r15),%esi
mov    0x2d66(%rip),%rax
mov    (%rax),%edx
mov    %ebx,%edi
xor    %eax,%eax
call   1060 <ioctl@plt>
test   %rax,%rax
jne    1330 <setup_uinputfd+0x1b0>
mov    (%r15),%esi
mov    0x2d00(%rip),%rax
mov    (%rax),%edx
mov    %ebx,%edi
xor    %eax,%eax
call   1060 <ioctl@plt>
test   %rax,%rax
jne    1330 <setup_uinputfd+0x1b0>
mov    (%r15),%esi
mov    0x2d5a(%rip),%rax
mov    (%rax),%edx
mov    %ebx,%edi
xor    %eax,%eax
call   1060 <ioctl@plt>
test   %rax,%rax
jne    1330 <setup_uinputfd+0x1b0>
mov    (%r14),%esi
mov    0x2cf4(%rip),%rax
mov    (%rax),%edx
mov    %ebx,%edi
xor    %eax,%eax
call   1060 <ioctl@plt>
test   %rax,%rax
jne    1330 <setup_uinputfd+0x1b0>
mov    0x2ce5(%rip),%r14
mov    (%r14),%esi
mov    0x2cc3(%rip),%rax
mov    (%rax),%edx
mov    %ebx,%edi
xor    %eax,%eax
call   1060 <ioctl@plt>
test   %rax,%rax
jne    1330 <setup_uinputfd+0x1b0>
mov    (%r14),%esi
mov    0x2d09(%rip),%rax
mov    (%rax),%edx
mov    %ebx,%edi
xor    %eax,%eax
call   1060 <ioctl@plt>
test   %rax,%rax
jne    1330 <setup_uinputfd+0x1b0>
mov    (%r14),%esi
mov    0x2cbf(%rip),%rax
mov    (%rax),%edx
mov    %ebx,%edi
xor    %eax,%eax
call   1060 <ioctl@plt>
test   %rax,%rax
jne    1330 <setup_uinputfd+0x1b0>
mov    0x2cc8(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
xor    %eax,%eax
call   1060 <ioctl@plt>
test   %rax,%rax
je     135f <setup_uinputfd+0x1df>
mov    0x2c49(%rip),%rax
mov    (%rax),%edi
lea    0xd02(%rip),%rsi
lea    0xce1(%rip),%rdx
call   1080 <fprintf@plt>
xor    %edi,%edi
call   10a0 <perror@plt>
mov    %ebx,%edi
call   1070 <close@plt>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
mov    0x2c0e(%rip),%rax
mov    (%rax),%edi
lea    0xcb4(%rip),%rsi
lea    0xca6(%rip),%rdx
call   1080 <fprintf@plt>
xor    %edi,%edi
call   10a0 <perror@plt>
jmp    135a <setup_uinputfd+0x1da>

LLVM IR (-O0):
%struct.uinput_user_dev = type { i64* }
@.str = [18 x i8] c"/dev/input/uinput\00"
@O_RDWR = global i32 0
@.str.1 = [12 x i8] c"/dev/uinput\00"
@.str.2 = [17 x i8] c"/dev/misc/uinput\00"
@stderr = global i32 0
@.str.3 = [19 x i8] c"could not open %s\0A\00"
@.str.4 = [7 x i8] c"uinput\00"
@UI_SET_EVBIT = global i32 0
@EV_KEY = global i32 0
@UI_SET_KEYBIT = global i32 0
@BTN_LEFT = global i32 0
@BTN_MIDDLE = global i32 0
@BTN_RIGHT = global i32 0
@EV_REL = global i32 0
@UI_SET_RELBIT = global i32 0
@REL_X = global i32 0
@REL_Y = global i32 0
@REL_WHEEL = global i32 0
@UI_DEV_CREATE = global i32 0
@.str.5 = [20 x i8] c"could not setup %s\0A\00"
define i32 @setup_uinputfd(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca %struct.uinput_user_dev
store i8* %0, i8** %3
%6 = load i32, i32* @O_RDWR
%7 = call i32 @open(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %6)
store i32 %7, i32* %4
%8 = load i32, i32* %4
%9 = icmp eq i32 %8, -1
br i1 %9, label %10, label %26
10: ; preds = %1
%11 = load i32, i32* @O_RDWR
%12 = call i32 @open(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %11)
store i32 %12, i32* %4
%13 = load i32, i32* %4
%14 = icmp eq i32 %13, -1
br i1 %14, label %15, label %25
15: ; preds = %10
%16 = load i32, i32* @O_RDWR
%17 = call i32 @open(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 %16)
store i32 %17, i32* %4
%18 = load i32, i32* %4
%19 = icmp eq i32 %18, -1
br i1 %19, label %20, label %24
20: ; preds = %15
%21 = load i32, i32* @stderr
%22 = call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%23 = call i32 @perror(i32* null)
store i32 -1, i32* %2
br label %104
24: ; preds = %15
br label %25
25: ; preds = %24, %10
br label %26
26: ; preds = %25, %1
%27 = call i32 @memset(%struct.uinput_user_dev* %5, i32 0, i32 8)
%28 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %5, i32 0, i32 0
%29 = load i64*, i64** %28
%30 = load i8*, i8** %3
%31 = call i32 @strncpy(i64* %29, i8* %30, i32 8)
%32 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %5, i32 0, i32 0
%33 = load i64*, i64** %32
%34 = getelementptr inbounds i64, i64* %33, i64 7
store i64 0, i64* %34
%35 = load i32, i32* %4
%36 = call i32 @write(i32 %35, %struct.uinput_user_dev* %5, i32 8)
%37 = sext i32 %36 to i64
%38 = icmp ne i64 %37, 8
br i1 %38, label %39, label %40
39: ; preds = %26
br label %98
40: ; preds = %26
%41 = load i32, i32* %4
%42 = load i32, i32* @UI_SET_EVBIT
%43 = load i32, i32* @EV_KEY
%44 = call i64 (i32, i32, ...) @ioctl(i32 %41, i32 %42, i32 %43)
%45 = icmp ne i64 %44, 0
br i1 %45, label %64, label %46
46: ; preds = %40
%47 = load i32, i32* %4
%48 = load i32, i32* @UI_SET_KEYBIT
%49 = load i32, i32* @BTN_LEFT
%50 = call i64 (i32, i32, ...) @ioctl(i32 %47, i32 %48, i32 %49)
%51 = icmp ne i64 %50, 0
br i1 %51, label %64, label %52
52: ; preds = %46
%53 = load i32, i32* %4
%54 = load i32, i32* @UI_SET_KEYBIT
%55 = load i32, i32* @BTN_MIDDLE
%56 = call i64 (i32, i32, ...) @ioctl(i32 %53, i32 %54, i32 %55)
%57 = icmp ne i64 %56, 0
br i1 %57, label %64, label %58
58: ; preds = %52
%59 = load i32, i32* %4
%60 = load i32, i32* @UI_SET_KEYBIT
%61 = load i32, i32* @BTN_RIGHT
%62 = call i64 (i32, i32, ...) @ioctl(i32 %59, i32 %60, i32 %61)
%63 = icmp ne i64 %62, 0
br i1 %63, label %64, label %65
64: ; preds = %58, %52, %46, %40
br label %98
65: ; preds = %58
%66 = load i32, i32* %4
%67 = load i32, i32* @UI_SET_EVBIT
%68 = load i32, i32* @EV_REL
%69 = call i64 (i32, i32, ...) @ioctl(i32 %66, i32 %67, i32 %68)
%70 = icmp ne i64 %69, 0
br i1 %70, label %89, label %71
71: ; preds = %65
%72 = load i32, i32* %4
%73 = load i32, i32* @UI_SET_RELBIT
%74 = load i32, i32* @REL_X
%75 = call i64 (i32, i32, ...) @ioctl(i32 %72, i32 %73, i32 %74)
%76 = icmp ne i64 %75, 0
br i1 %76, label %89, label %77
77: ; preds = %71
%78 = load i32, i32* %4
%79 = load i32, i32* @UI_SET_RELBIT
%80 = load i32, i32* @REL_Y
%81 = call i64 (i32, i32, ...) @ioctl(i32 %78, i32 %79, i32 %80)
%82 = icmp ne i64 %81, 0
br i1 %82, label %89, label %83
83: ; preds = %77
%84 = load i32, i32* %4
%85 = load i32, i32* @UI_SET_RELBIT
%86 = load i32, i32* @REL_WHEEL
%87 = call i64 (i32, i32, ...) @ioctl(i32 %84, i32 %85, i32 %86)
%88 = icmp ne i64 %87, 0
br i1 %88, label %89, label %90
89: ; preds = %83, %77, %71, %65
br label %98
90: ; preds = %83
%91 = load i32, i32* %4
%92 = load i32, i32* @UI_DEV_CREATE
%93 = call i64 (i32, i32, ...) @ioctl(i32 %91, i32 %92)
%94 = icmp ne i64 %93, 0
br i1 %94, label %95, label %96
95: ; preds = %90
br label %98
96: ; preds = %90
%97 = load i32, i32* %4
store i32 %97, i32* %2
br label %104
98: ; preds = %95, %89, %64, %39
%99 = load i32, i32* @stderr
%100 = call i32 @fprintf(i32 %99, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%101 = call i32 @perror(i32* null)
%102 = load i32, i32* %4
%103 = call i32 @close(i32 %102)
store i32 -1, i32* %2
br label %104
104: ; preds = %98, %96, %20
%105 = load i32, i32* %2
ret i32 %105
}

LLVM IR (-O2):
%struct.uinput_user_dev = type { i64* }
@.str = [18 x i8] c"/dev/input/uinput\00"
@O_RDWR = global i32 0
@.str.1 = [12 x i8] c"/dev/uinput\00"
@.str.2 = [17 x i8] c"/dev/misc/uinput\00"
@stderr = global i32 0
@.str.3 = [19 x i8] c"could not open %s\0A\00"
@.str.4 = [7 x i8] c"uinput\00"
@UI_SET_EVBIT = global i32 0
@EV_KEY = global i32 0
@UI_SET_KEYBIT = global i32 0
@BTN_LEFT = global i32 0
@BTN_MIDDLE = global i32 0
@BTN_RIGHT = global i32 0
@EV_REL = global i32 0
@UI_SET_RELBIT = global i32 0
@REL_X = global i32 0
@REL_Y = global i32 0
@REL_WHEEL = global i32 0
@UI_DEV_CREATE = global i32 0
@.str.5 = [20 x i8] c"could not setup %s\0A\00"
define i32 @setup_uinputfd(i8* %0) {
%2 = alloca %struct.uinput_user_dev
%3 = bitcast %struct.uinput_user_dev* %2 to i8*
%4 = load i32, i32* @O_RDWR
%5 = tail call i32 @open(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %4)
%6 = icmp eq i32 %5, -1
br i1 %6, label %7, label %19
7: ; preds = %1
%8 = load i32, i32* @O_RDWR
%9 = tail call i32 @open(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %8)
%10 = icmp eq i32 %9, -1
br i1 %10, label %11, label %19
11: ; preds = %7
%12 = load i32, i32* @O_RDWR
%13 = tail call i32 @open(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 %12)
%14 = icmp eq i32 %13, -1
br i1 %14, label %15, label %19
15: ; preds = %11
%16 = load i32, i32* @stderr
%17 = tail call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%18 = tail call i32 @perror(i32* null)
br label %78
19: ; preds = %7, %11, %1
%20 = phi i32 [ %13, %11 ], [ %9, %7 ], [ %5, %1 ]
%21 = call i32 @memset(%struct.uinput_user_dev* %2, i32 0, i32 8)
%22 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %2, i64 0, i32 0
%23 = load i64*, i64** %22
%24 = call i32 @strncpy(i64* %23, i8* %0, i32 8)
%25 = load i64*, i64** %22
%26 = getelementptr inbounds i64, i64* %25, i64 7
store i64 0, i64* %26
%27 = call i32 @write(i32 %20, %struct.uinput_user_dev* %2, i32 8)
%28 = icmp eq i32 %27, 8
br i1 %28, label %29, label %73
29: ; preds = %19
%30 = load i32, i32* @UI_SET_EVBIT
%31 = load i32, i32* @EV_KEY
%32 = call i64 (i32, i32, ...) @ioctl(i32 %20, i32 %30, i32 %31)
%33 = icmp eq i64 %32, 0
br i1 %33, label %34, label %73
34: ; preds = %29
%35 = load i32, i32* @UI_SET_KEYBIT
%36 = load i32, i32* @BTN_LEFT
%37 = call i64 (i32, i32, ...) @ioctl(i32 %20, i32 %35, i32 %36)
%38 = icmp eq i64 %37, 0
br i1 %38, label %39, label %73
39: ; preds = %34
%40 = load i32, i32* @UI_SET_KEYBIT
%41 = load i32, i32* @BTN_MIDDLE
%42 = call i64 (i32, i32, ...) @ioctl(i32 %20, i32 %40, i32 %41)
%43 = icmp eq i64 %42, 0
br i1 %43, label %44, label %73
44: ; preds = %39
%45 = load i32, i32* @UI_SET_KEYBIT
%46 = load i32, i32* @BTN_RIGHT
%47 = call i64 (i32, i32, ...) @ioctl(i32 %20, i32 %45, i32 %46)
%48 = icmp eq i64 %47, 0
br i1 %48, label %49, label %73
49: ; preds = %44
%50 = load i32, i32* @UI_SET_EVBIT
%51 = load i32, i32* @EV_REL
%52 = call i64 (i32, i32, ...) @ioctl(i32 %20, i32 %50, i32 %51)
%53 = icmp eq i64 %52, 0
br i1 %53, label %54, label %73
54: ; preds = %49
%55 = load i32, i32* @UI_SET_RELBIT
%56 = load i32, i32* @REL_X
%57 = call i64 (i32, i32, ...) @ioctl(i32 %20, i32 %55, i32 %56)
%58 = icmp eq i64 %57, 0
br i1 %58, label %59, label %73
59: ; preds = %54
%60 = load i32, i32* @UI_SET_RELBIT
%61 = load i32, i32* @REL_Y
%62 = call i64 (i32, i32, ...) @ioctl(i32 %20, i32 %60, i32 %61)
%63 = icmp eq i64 %62, 0
br i1 %63, label %64, label %73
64: ; preds = %59
%65 = load i32, i32* @UI_SET_RELBIT
%66 = load i32, i32* @REL_WHEEL
%67 = call i64 (i32, i32, ...) @ioctl(i32 %20, i32 %65, i32 %66)
%68 = icmp eq i64 %67, 0
br i1 %68, label %69, label %73
69: ; preds = %64
%70 = load i32, i32* @UI_DEV_CREATE
%71 = call i64 (i32, i32, ...) @ioctl(i32 %20, i32 %70)
%72 = icmp eq i64 %71, 0
br i1 %72, label %78, label %73
73: ; preds = %69, %49, %54, %59, %64, %29, %34, %39, %44, %19
%74 = load i32, i32* @stderr
%75 = call i32 @fprintf(i32 %74, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%76 = call i32 @perror(i32* null)
%77 = call i32 @close(i32 %20)
br label %78
78: ; preds = %69, %73, %15
%79 = phi i32 [ -1, %15 ], [ -1, %73 ], [ %20, %69 ]
ret i32 %79
}