#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*/ uinput;
struct TYPE_2__ {
  int vendor;
  int product;
  int version;
  int /*<<< orphan*/ bustype;
};
struct uinput_user_dev {
  int *absmax;
  scalar_t__ *absmin;
  TYPE_1__ id;
  int /*<<< orphan*/ name;
};

/* Variables and functions */
size_t ABS_X;
size_t ABS_Y;
int BTN_MOUSE;
int BTN_TASK;
int /*<<< orphan*/ BUS_BLUETOOTH;
int /*<<< orphan*/ EV_ABS;
int /*<<< orphan*/ EV_KEY;
int /*<<< orphan*/ EV_REL;
int KEY_ESC;
int KEY_MICMUTE;
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_ABSBIT;
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 *, int);
int /*<<< orphan*/ handle_event(int);
int ioctl(int, int /*<<< orphan*/, ...);
int /*<<< orphan*/ memset(struct uinput_user_dev *, int /*<<< orphan*/, int);
int open(char const *, int);
int /*<<< orphan*/ snprintf(int /*<<< orphan*/, int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
int write(int, struct uinput_user_dev *, int);
int main(int argc, char **argv) {
  const char *input = "/dev/uinput";
  int fd;
  int rc;
  int i;
  struct uinput_user_dev uinput;
  fd = open(input, O_WRONLY | O_NONBLOCK);
  if (fd < 0) {
    fprintf(stderr, "open uinput failed, fd: %d\n", fd);
    return fd;
  }
  rc = ioctl(fd, UI_SET_EVBIT, EV_KEY);
  for (i = KEY_ESC; i < KEY_MICMUTE; i++) {
    rc = ioctl(fd, UI_SET_KEYBIT, i);
  }
  rc = ioctl(fd, UI_SET_EVBIT, EV_REL);
  rc = ioctl(fd, UI_SET_RELBIT, REL_X);
  rc = ioctl(fd, UI_SET_RELBIT, REL_Y);
  for (i = BTN_MOUSE; i < BTN_TASK; i++) {
    rc = ioctl(fd, UI_SET_KEYBIT, i);
  }
  rc = ioctl(fd, UI_SET_EVBIT, EV_ABS);
  rc = ioctl(fd, UI_SET_ABSBIT, ABS_X);
  rc = ioctl(fd, UI_SET_ABSBIT, ABS_Y);
  memset(&uinput, 0, sizeof(uinput));
  snprintf(uinput.name, UINPUT_MAX_NAME_SIZE, "blueberry-input");
  uinput.id.bustype = BUS_BLUETOOTH;
  uinput.id.vendor = 0x0315;
  uinput.id.product = 0x0607;
  uinput.id.version = 0x0412;
  uinput.absmin[ABS_X] = 0;
  uinput.absmax[ABS_X] = 1920;
  uinput.absmin[ABS_Y] = 0;
  uinput.absmax[ABS_Y] = 1080;
  rc = write(fd, &uinput, sizeof(uinput));
  rc = ioctl(fd, UI_DEV_CREATE);
  handle_event(fd);
  rc = ioctl(fd, UI_DEV_DESTROY);
  close(fd);
  return rc;
}


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)
lea    0xe63(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    0x2d94(%rip),%rax
mov    (%rax),%esi
mov    0x2e0b(%rip),%rax
or     (%rax),%esi
call   1090 <open@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    11ec <main+0x6c>
mov    0x2d88(%rip),%rax
mov    (%rax),%edi
mov    -0x1c(%rbp),%edx
lea    0xe30(%rip),%rsi
call   1080 <fprintf@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1446 <main+0x2c6>
mov    -0x1c(%rbp),%edi
mov    0x2d9a(%rip),%rax
mov    (%rax),%esi
mov    0x2da9(%rip),%rax
mov    (%rax),%edx
mov    $0x0,%al
call   1060 <ioctl@plt>
mov    %eax,-0x20(%rbp)
mov    0x2db6(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    0x2dd7(%rip),%rcx
cmp    (%rcx),%eax
jge    1250 <main+0xd0>
mov    -0x1c(%rbp),%edi
mov    0x2d2d(%rip),%rax
mov    (%rax),%esi
mov    -0x24(%rbp),%edx
mov    $0x0,%al
call   1060 <ioctl@plt>
mov    %eax,-0x20(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1217 <main+0x97>
mov    -0x1c(%rbp),%edi
mov    0x2d36(%rip),%rax
mov    (%rax),%esi
mov    0x2d35(%rip),%rax
mov    (%rax),%edx
mov    $0x0,%al
call   1060 <ioctl@plt>
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%edi
mov    0x2d27(%rip),%rax
mov    (%rax),%esi
mov    0x2cf6(%rip),%rax
mov    (%rax),%edx
mov    $0x0,%al
call   1060 <ioctl@plt>
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%edi
mov    0x2d08(%rip),%rax
mov    (%rax),%esi
mov    0x2d4f(%rip),%rax
mov    (%rax),%edx
mov    $0x0,%al
call   1060 <ioctl@plt>
mov    %eax,-0x20(%rbp)
mov    0x2c9c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    0x2cf5(%rip),%rcx
cmp    (%rcx),%eax
jge    12f2 <main+0x172>
mov    -0x1c(%rbp),%edi
mov    0x2c8b(%rip),%rax
mov    (%rax),%esi
mov    -0x24(%rbp),%edx
mov    $0x0,%al
call   1060 <ioctl@plt>
mov    %eax,-0x20(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    12b9 <main+0x139>
mov    -0x1c(%rbp),%edi
mov    0x2c94(%rip),%rax
mov    (%rax),%esi
mov    0x2c2b(%rip),%rax
mov    (%rax),%edx
mov    $0x0,%al
call   1060 <ioctl@plt>
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%edi
mov    0x2c1d(%rip),%rax
mov    (%rax),%esi
mov    0x2c44(%rip),%rax
mov    (%rax),%rdx
mov    $0x0,%al
call   1060 <ioctl@plt>
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%edi
mov    0x2bfd(%rip),%rax
mov    (%rax),%esi
mov    0x2ca4(%rip),%rax
mov    (%rax),%rdx
mov    $0x0,%al
call   1060 <ioctl@plt>
mov    %eax,-0x20(%rbp)
lea    -0x50(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1050 <memset@plt>
mov    -0x30(%rbp),%edi
mov    0x2c1d(%rip),%rax
mov    (%rax),%esi
lea    0xcb4(%rip),%rdx
call   1040 <snprintf@plt>
mov    0x2c30(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
movl   $0x315,-0x40(%rbp)
movl   $0x607,-0x3c(%rbp)
movl   $0x412,-0x38(%rbp)
mov    -0x48(%rbp),%rax
mov    0x2bc3(%rip),%rcx
mov    (%rcx),%rcx
movq   $0x0,(%rax,%rcx,8)
mov    -0x50(%rbp),%rax
mov    0x2bad(%rip),%rcx
mov    (%rcx),%rcx
movl   $0x780,(%rax,%rcx,4)
mov    -0x48(%rbp),%rax
mov    0x2c18(%rip),%rcx
mov    (%rcx),%rcx
movq   $0x0,(%rax,%rcx,8)
mov    -0x50(%rbp),%rax
mov    0x2c02(%rip),%rcx
mov    (%rcx),%rcx
movl   $0x438,(%rax,%rcx,4)
mov    -0x1c(%rbp),%edi
lea    -0x50(%rbp),%rsi
mov    $0x28,%edx
call   1030 <write@plt>
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%edi
mov    0x2bd2(%rip),%rax
mov    (%rax),%esi
mov    $0x0,%al
call   1060 <ioctl@plt>
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%edi
call   10a0 <handle_event@plt>
mov    -0x1c(%rbp),%edi
mov    0x2b54(%rip),%rax
mov    (%rax),%esi
mov    $0x0,%al
call   1060 <ioctl@plt>
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%edi
call   1070 <close@plt>
mov    -0x20(%rbp),%eax
mov    %eax,-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    $0x30,%rsp
mov    0x2dad(%rip),%rax
mov    0x2e26(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
lea    0xe5b(%rip),%rdi
call   1090 <open@plt>
mov    %eax,%ebx
test   %eax,%eax
js     139e <main+0x21e>
mov    0x2dd5(%rip),%r14
mov    (%r14),%esi
mov    0x2de3(%rip),%rax
mov    (%rax),%edx
mov    %ebx,%edi
xor    %eax,%eax
call   1060 <ioctl@plt>
mov    0x2df1(%rip),%rax
mov    (%rax),%ebp
mov    0x2e18(%rip),%r15
cmp    (%r15),%ebp
jge    1207 <main+0x87>
mov    0x2d74(%rip),%r12
nopl   0x0(%rax)
mov    (%r12),%esi
mov    %ebx,%edi
mov    %ebp,%edx
xor    %eax,%eax
call   1060 <ioctl@plt>
add    $0x1,%ebp
cmp    (%r15),%ebp
jl     11f0 <main+0x70>
mov    (%r14),%esi
mov    0x2d87(%rip),%rax
mov    (%rax),%edx
mov    %ebx,%edi
xor    %eax,%eax
call   1060 <ioctl@plt>
mov    0x2d7d(%rip),%rbp
mov    0x0(%rbp),%esi
mov    0x2d4b(%rip),%rax
mov    (%rax),%edx
mov    %ebx,%edi
xor    %eax,%eax
call   1060 <ioctl@plt>
mov    0x0(%rbp),%esi
mov    0x2dae(%rip),%rax
mov    (%rax),%edx
mov    %ebx,%edi
xor    %eax,%eax
call   1060 <ioctl@plt>
mov    0x2cfc(%rip),%rax
mov    (%rax),%ebp
mov    0x2d5b(%rip),%r15
cmp    (%r15),%ebp
jge    1287 <main+0x107>
mov    0x2cf7(%rip),%r12
nopl   0x0(%rax)
mov    (%r12),%esi
mov    %ebx,%edi
mov    %ebp,%edx
xor    %eax,%eax
call   1060 <ioctl@plt>
add    $0x1,%ebp
cmp    (%r15),%ebp
jl     1270 <main+0xf0>
mov    (%r14),%esi
mov    0x2c9f(%rip),%rax
mov    (%rax),%edx
mov    %ebx,%edi
xor    %eax,%eax
call   1060 <ioctl@plt>
mov    0x2c95(%rip),%rbp
mov    0x0(%rbp),%esi
mov    0x2cbb(%rip),%r15
mov    (%r15),%rdx
mov    %ebx,%edi
xor    %eax,%eax
call   1060 <ioctl@plt>
mov    0x0(%rbp),%esi
mov    0x2d25(%rip),%rbp
mov    0x0(%rbp),%rdx
mov    %ebx,%edi
xor    %eax,%eax
call   1060 <ioctl@plt>
lea    0x8(%rsp),%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1050 <memset@plt>
mov    0x28(%rsp),%edi
mov    0x2c99(%rip),%rax
mov    (%rax),%esi
lea    0xd30(%rip),%rdx
call   1040 <snprintf@plt>
mov    0x2cac(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x24(%rsp)
movabs $0x60700000315,%rax
mov    %rax,0x18(%rsp)
movl   $0x412,0x20(%rsp)
mov    0x10(%rsp),%rax
mov    (%r15),%rcx
movq   $0x0,(%rax,%rcx,8)
mov    0x8(%rsp),%rcx
mov    (%r15),%rdx
movl   $0x780,(%rcx,%rdx,4)
mov    0x0(%rbp),%rdx
movq   $0x0,(%rax,%rdx,8)
mov    0x0(%rbp),%rax
movl   $0x438,(%rcx,%rax,4)
mov    %ebx,%edi
mov    %r14,%rsi
mov    $0x28,%edx
call   1030 <write@plt>
mov    0x2c73(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
xor    %eax,%eax
call   1060 <ioctl@plt>
mov    %ebx,%edi
call   10a0 <handle_event@plt>
mov    0x2bfa(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
xor    %eax,%eax
call   1060 <ioctl@plt>
mov    %eax,%ebp
mov    %ebx,%edi
call   1070 <close@plt>
mov    %ebp,%ebx
jmp    13b5 <main+0x235>
mov    0x2bb3(%rip),%rax
mov    (%rax),%edi
lea    0xc5e(%rip),%rsi
mov    %ebx,%edx
call   1080 <fprintf@plt>
mov    %ebx,%eax
add    $0x30,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.uinput_user_dev = type { i32*, i64*, %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
@stderr = global i32 0
@.str.1 = [28 x i8] c"open uinput failed, fd: %d\0A\00"
@UI_SET_EVBIT = global i32 0
@EV_KEY = global i32 0
@KEY_ESC = global i32 0
@KEY_MICMUTE = global i32 0
@UI_SET_KEYBIT = global i32 0
@EV_REL = global i32 0
@UI_SET_RELBIT = global i32 0
@REL_X = global i32 0
@REL_Y = global i32 0
@BTN_MOUSE = global i32 0
@BTN_TASK = global i32 0
@EV_ABS = global i32 0
@UI_SET_ABSBIT = global i32 0
@ABS_X = global i64 0
@ABS_Y = global i64 0
@UINPUT_MAX_NAME_SIZE = global i32 0
@.str.2 = [16 x i8] c"blueberry-input\00"
@BUS_BLUETOOTH = global i32 0
@UI_DEV_CREATE = global i32 0
@UI_DEV_DESTROY = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca %struct.uinput_user_dev
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8** %6
%11 = load i8*, i8** %6
%12 = load i32, i32* @O_WRONLY
%13 = load i32, i32* @O_NONBLOCK
%14 = or i32 %12, %13
%15 = call i32 @open(i8* %11, i32 %14)
store i32 %15, i32* %7
%16 = load i32, i32* %7
%17 = icmp slt i32 %16, 0
br i1 %17, label %18, label %23
18: ; preds = %2
%19 = load i32, i32* @stderr
%20 = load i32, i32* %7
%21 = call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i32 %20)
%22 = load i32, i32* %7
store i32 %22, i32* %3
br label %123
23: ; preds = %2
%24 = load i32, i32* %7
%25 = load i32, i32* @UI_SET_EVBIT
%26 = load i32, i32* @EV_KEY
%27 = call i32 (i32, i32, ...) @ioctl(i32 %24, i32 %25, i32 %26)
store i32 %27, i32* %8
%28 = load i32, i32* @KEY_ESC
store i32 %28, i32* %9
br label %29
29: ; preds = %38, %23
%30 = load i32, i32* %9
%31 = load i32, i32* @KEY_MICMUTE
%32 = icmp slt i32 %30, %31
br i1 %32, label %33, label %41
33: ; preds = %29
%34 = load i32, i32* %7
%35 = load i32, i32* @UI_SET_KEYBIT
%36 = load i32, i32* %9
%37 = call i32 (i32, i32, ...) @ioctl(i32 %34, i32 %35, i32 %36)
store i32 %37, i32* %8
br label %38
38: ; preds = %33
%39 = load i32, i32* %9
%40 = add nsw i32 %39, 1
store i32 %40, i32* %9
br label %29
41: ; preds = %29
%42 = load i32, i32* %7
%43 = load i32, i32* @UI_SET_EVBIT
%44 = load i32, i32* @EV_REL
%45 = call i32 (i32, i32, ...) @ioctl(i32 %42, i32 %43, i32 %44)
store i32 %45, i32* %8
%46 = load i32, i32* %7
%47 = load i32, i32* @UI_SET_RELBIT
%48 = load i32, i32* @REL_X
%49 = call i32 (i32, i32, ...) @ioctl(i32 %46, i32 %47, i32 %48)
store i32 %49, i32* %8
%50 = load i32, i32* %7
%51 = load i32, i32* @UI_SET_RELBIT
%52 = load i32, i32* @REL_Y
%53 = call i32 (i32, i32, ...) @ioctl(i32 %50, i32 %51, i32 %52)
store i32 %53, i32* %8
%54 = load i32, i32* @BTN_MOUSE
store i32 %54, i32* %9
br label %55
55: ; preds = %64, %41
%56 = load i32, i32* %9
%57 = load i32, i32* @BTN_TASK
%58 = icmp slt i32 %56, %57
br i1 %58, label %59, label %67
59: ; preds = %55
%60 = load i32, i32* %7
%61 = load i32, i32* @UI_SET_KEYBIT
%62 = load i32, i32* %9
%63 = call i32 (i32, i32, ...) @ioctl(i32 %60, i32 %61, i32 %62)
store i32 %63, i32* %8
br label %64
64: ; preds = %59
%65 = load i32, i32* %9
%66 = add nsw i32 %65, 1
store i32 %66, i32* %9
br label %55
67: ; preds = %55
%68 = load i32, i32* %7
%69 = load i32, i32* @UI_SET_EVBIT
%70 = load i32, i32* @EV_ABS
%71 = call i32 (i32, i32, ...) @ioctl(i32 %68, i32 %69, i32 %70)
store i32 %71, i32* %8
%72 = load i32, i32* %7
%73 = load i32, i32* @UI_SET_ABSBIT
%74 = load i64, i64* @ABS_X
%75 = call i32 (i32, i32, ...) @ioctl(i32 %72, i32 %73, i64 %74)
store i32 %75, i32* %8
%76 = load i32, i32* %7
%77 = load i32, i32* @UI_SET_ABSBIT
%78 = load i64, i64* @ABS_Y
%79 = call i32 (i32, i32, ...) @ioctl(i32 %76, i32 %77, i64 %78)
store i32 %79, i32* %8
%80 = call i32 @memset(%struct.uinput_user_dev* %10, i32 0, i32 40)
%81 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %10, i32 0, i32 3
%82 = load i32, i32* %81
%83 = load i32, i32* @UINPUT_MAX_NAME_SIZE
%84 = call i32 @snprintf(i32 %82, i32 %83, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%85 = load i32, i32* @BUS_BLUETOOTH
%86 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %10, i32 0, i32 2
%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* %10, i32 0, i32 2
%89 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %88, i32 0, i32 0
store i32 789, i32* %89
%90 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %10, i32 0, i32 2
%91 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %90, i32 0, i32 1
store i32 1543, i32* %91
%92 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %10, i32 0, i32 2
%93 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %92, i32 0, i32 2
store i32 1042, i32* %93
%94 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %10, i32 0, i32 1
%95 = load i64*, i64** %94
%96 = load i64, i64* @ABS_X
%97 = getelementptr inbounds i64, i64* %95, i64 %96
store i64 0, i64* %97
%98 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %10, i32 0, i32 0
%99 = load i32*, i32** %98
%100 = load i64, i64* @ABS_X
%101 = getelementptr inbounds i32, i32* %99, i64 %100
store i32 1920, i32* %101
%102 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %10, i32 0, i32 1
%103 = load i64*, i64** %102
%104 = load i64, i64* @ABS_Y
%105 = getelementptr inbounds i64, i64* %103, i64 %104
store i64 0, i64* %105
%106 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %10, i32 0, i32 0
%107 = load i32*, i32** %106
%108 = load i64, i64* @ABS_Y
%109 = getelementptr inbounds i32, i32* %107, i64 %108
store i32 1080, i32* %109
%110 = load i32, i32* %7
%111 = call i32 @write(i32 %110, %struct.uinput_user_dev* %10, i32 40)
store i32 %111, i32* %8
%112 = load i32, i32* %7
%113 = load i32, i32* @UI_DEV_CREATE
%114 = call i32 (i32, i32, ...) @ioctl(i32 %112, i32 %113)
store i32 %114, i32* %8
%115 = load i32, i32* %7
%116 = call i32 @handle_event(i32 %115)
%117 = load i32, i32* %7
%118 = load i32, i32* @UI_DEV_DESTROY
%119 = call i32 (i32, i32, ...) @ioctl(i32 %117, i32 %118)
store i32 %119, i32* %8
%120 = load i32, i32* %7
%121 = call i32 @close(i32 %120)
%122 = load i32, i32* %8
store i32 %122, i32* %3
br label %123
123: ; preds = %67, %18
%124 = load i32, i32* %3
ret i32 %124
}

LLVM IR (-O2):
%struct.uinput_user_dev = type { i32*, i64*, %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
@stderr = global i32 0
@.str.1 = [28 x i8] c"open uinput failed, fd: %d\0A\00"
@UI_SET_EVBIT = global i32 0
@EV_KEY = global i32 0
@KEY_ESC = global i32 0
@KEY_MICMUTE = global i32 0
@UI_SET_KEYBIT = global i32 0
@EV_REL = global i32 0
@UI_SET_RELBIT = global i32 0
@REL_X = global i32 0
@REL_Y = global i32 0
@BTN_MOUSE = global i32 0
@BTN_TASK = global i32 0
@EV_ABS = global i32 0
@UI_SET_ABSBIT = global i32 0
@ABS_X = global i64 0
@ABS_Y = global i64 0
@UINPUT_MAX_NAME_SIZE = global i32 0
@.str.2 = [16 x i8] c"blueberry-input\00"
@BUS_BLUETOOTH = global i32 0
@UI_DEV_CREATE = global i32 0
@UI_DEV_DESTROY = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca %struct.uinput_user_dev
%4 = bitcast %struct.uinput_user_dev* %3 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 %13
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = tail call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i32 %8)
br label %86
13: ; preds = %2
%14 = load i32, i32* @UI_SET_EVBIT
%15 = load i32, i32* @EV_KEY
%16 = tail call i32 (i32, i32, ...) @ioctl(i32 %8, i32 %14, i32 %15)
%17 = load i32, i32* @KEY_ESC
%18 = load i32, i32* @KEY_MICMUTE
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %27
20: ; preds = %13, %20
%21 = phi i32 [ %24, %20 ], [ %17, %13 ]
%22 = load i32, i32* @UI_SET_KEYBIT
%23 = tail call i32 (i32, i32, ...) @ioctl(i32 %8, i32 %22, i32 %21)
%24 = add nsw i32 %21, 1
%25 = load i32, i32* @KEY_MICMUTE
%26 = icmp slt i32 %24, %25
br i1 %26, label %20, label %27
27: ; preds = %20, %13
%28 = load i32, i32* @UI_SET_EVBIT
%29 = load i32, i32* @EV_REL
%30 = tail call i32 (i32, i32, ...) @ioctl(i32 %8, i32 %28, i32 %29)
%31 = load i32, i32* @UI_SET_RELBIT
%32 = load i32, i32* @REL_X
%33 = tail call i32 (i32, i32, ...) @ioctl(i32 %8, i32 %31, i32 %32)
%34 = load i32, i32* @UI_SET_RELBIT
%35 = load i32, i32* @REL_Y
%36 = tail call i32 (i32, i32, ...) @ioctl(i32 %8, i32 %34, i32 %35)
%37 = load i32, i32* @BTN_MOUSE
%38 = load i32, i32* @BTN_TASK
%39 = icmp slt i32 %37, %38
br i1 %39, label %40, label %47
40: ; preds = %27, %40
%41 = phi i32 [ %44, %40 ], [ %37, %27 ]
%42 = load i32, i32* @UI_SET_KEYBIT
%43 = tail call i32 (i32, i32, ...) @ioctl(i32 %8, i32 %42, i32 %41)
%44 = add nsw i32 %41, 1
%45 = load i32, i32* @BTN_TASK
%46 = icmp slt i32 %44, %45
br i1 %46, label %40, label %47
47: ; preds = %40, %27
%48 = load i32, i32* @UI_SET_EVBIT
%49 = load i32, i32* @EV_ABS
%50 = tail call i32 (i32, i32, ...) @ioctl(i32 %8, i32 %48, i32 %49)
%51 = load i32, i32* @UI_SET_ABSBIT
%52 = load i64, i64* @ABS_X
%53 = tail call i32 (i32, i32, ...) @ioctl(i32 %8, i32 %51, i64 %52)
%54 = load i32, i32* @UI_SET_ABSBIT
%55 = load i64, i64* @ABS_Y
%56 = tail call i32 (i32, i32, ...) @ioctl(i32 %8, i32 %54, i64 %55)
%57 = call i32 @memset(%struct.uinput_user_dev* %3, i32 0, i32 40)
%58 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %3, i64 0, i32 3
%59 = load i32, i32* %58
%60 = load i32, i32* @UINPUT_MAX_NAME_SIZE
%61 = call i32 @snprintf(i32 %59, i32 %60, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%62 = load i32, i32* @BUS_BLUETOOTH
%63 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %3, i64 0, i32 2, i32 3
store i32 %62, i32* %63
%64 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %3, i64 0, i32 2, i32 0
store i32 789, i32* %64
%65 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %3, i64 0, i32 2, i32 1
store i32 1543, i32* %65
%66 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %3, i64 0, i32 2, i32 2
store i32 1042, i32* %66
%67 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %3, i64 0, i32 1
%68 = load i64*, i64** %67
%69 = load i64, i64* @ABS_X
%70 = getelementptr inbounds i64, i64* %68, i64 %69
store i64 0, i64* %70
%71 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %3, i64 0, i32 0
%72 = load i32*, i32** %71
%73 = load i64, i64* @ABS_X
%74 = getelementptr inbounds i32, i32* %72, i64 %73
store i32 1920, i32* %74
%75 = load i64, i64* @ABS_Y
%76 = getelementptr inbounds i64, i64* %68, i64 %75
store i64 0, i64* %76
%77 = load i64, i64* @ABS_Y
%78 = getelementptr inbounds i32, i32* %72, i64 %77
store i32 1080, i32* %78
%79 = call i32 @write(i32 %8, %struct.uinput_user_dev* %3, i32 40)
%80 = load i32, i32* @UI_DEV_CREATE
%81 = call i32 (i32, i32, ...) @ioctl(i32 %8, i32 %80)
%82 = call i32 @handle_event(i32 %8)
%83 = load i32, i32* @UI_DEV_DESTROY
%84 = call i32 (i32, i32, ...) @ioctl(i32 %8, i32 %83)
%85 = call i32 @close(i32 %8)
br label %86
86: ; preds = %47, %10
%87 = phi i32 [ %8, %10 ], [ %84, %47 ]
ret i32 %87
}