#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__ {
  size_t vendor;
  size_t product;
  int version;
  int /*<<< orphan*/ bustype;
};
struct uinput_user_dev {
  void **absflat;
  void **absfuzz;
  void **absmax;
  void **absmin;
  TYPE_1__ id;
  int /*<<< orphan*/ name;
};
typedef size_t __u16;
typedef void *__s32;

/* Variables and functions */
int /*<<< orphan*/ BUS_USB;
int /*<<< orphan*/ EV_ABS;
int /*<<< orphan*/ EV_KEY;
int /*<<< orphan*/ EV_MSC;
int /*<<< orphan*/ EV_REL;
int /*<<< orphan*/ EV_REP;
int /*<<< orphan*/ MSC_SCAN;
int O_NONBLOCK;
int O_WRONLY;
int /*<<< orphan*/ UINPUT_MAX_NAME_SIZE;
int /*<<< orphan*/ UI_DEV_CREATE;
int /*<<< orphan*/ UI_SET_ABSBIT;
int /*<<< orphan*/ UI_SET_EVBIT;
int /*<<< orphan*/ UI_SET_KEYBIT;
int /*<<< orphan*/ UI_SET_MSCBIT;
int /*<<< orphan*/ UI_SET_RELBIT;
int /*<<< orphan*/ close(int);
scalar_t__ ioctl(int, int /*<<< orphan*/, ...);
int /*<<< orphan*/ memset(struct uinput_user_dev *, int /*<<< orphan*/, int);
int open(char *, int);
int /*<<< orphan*/ strncpy(int /*<<< orphan*/, char *, int /*<<< orphan*/);
scalar_t__ write(int, struct uinput_user_dev *, int);
int uinput_init(int key_len, __u16 *key, int abs_len, __u16 *abs,
                __s32 *abs_min, __s32 *abs_max, __s32 *abs_fuzz,
                __s32 *abs_flat, int rel_len, __u16 *rel, int keyboard,
                __u16 vendor, __u16 product, char *name) {
  struct uinput_user_dev uidev;
  int fd;
  int i;
  memset(&uidev, 0, sizeof(uidev));
  fd = open("/dev/uinput", O_WRONLY | O_NONBLOCK);
  if (fd < 0)
    return -1;
  strncpy(uidev.name, name, UINPUT_MAX_NAME_SIZE);
  uidev.id.bustype = BUS_USB;
  uidev.id.vendor = vendor;
  uidev.id.product = product;
  uidev.id.version = 1;
  if (key_len > 0 && ioctl(fd, UI_SET_EVBIT, EV_KEY) < 0) {
    close(fd);
    return -2;
  }
  for (i = 0; i < key_len; i++) {
    if (ioctl(fd, UI_SET_KEYBIT, key[i]) < 0) {
      close(fd);
      return -3;
    }
  }
  if (abs_len > 0 && ioctl(fd, UI_SET_EVBIT, EV_ABS) < 0) {
    close(fd);
    return -4;
    ;
  }
  for (i = 0; i < abs_len; i++) {
    if (ioctl(fd, UI_SET_ABSBIT, abs[i]) < 0) {
      close(fd);
      return -5;
    }
    uidev.absmin[abs[i]] = abs_min[i];
    uidev.absmax[abs[i]] = abs_max[i];
    uidev.absfuzz[abs[i]] = abs_fuzz[i];
    uidev.absflat[abs[i]] = abs_flat[i];
  }
  if (rel_len > 0 && ioctl(fd, UI_SET_EVBIT, EV_REL) < 0) {
    close(fd);
    return -6;
  }
  for (i = 0; i < rel_len; i++) {
    if (ioctl(fd, UI_SET_RELBIT, rel[i]) < 0) {
      close(fd);
      return -7;
    }
  }
  if (keyboard) {
    if (ioctl(fd, UI_SET_EVBIT, EV_MSC) < 0) {
      close(fd);
      return -8;
    }
    if (ioctl(fd, UI_SET_MSCBIT, MSC_SCAN) < 0) {
      close(fd);
      return -9;
    }
    if (ioctl(fd, UI_SET_EVBIT, EV_REP) < 0) {
      close(fd);
      return -10;
    }
  }
  if (write(fd, &uidev, sizeof(uidev)) < 0) {
    close(fd);
    return -11;
  }
  if (ioctl(fd, UI_DEV_CREATE) < 0) {
    close(fd);
    return -12;
  }
  return fd;
}


x86 assembly (clang, -O0):
<uinput_init>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    0x48(%rbp),%rax
mov    0x40(%rbp),%rax
mov    0x38(%rbp),%rax
mov    0x30(%rbp),%eax
mov    0x28(%rbp),%rax
mov    0x20(%rbp),%eax
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
lea    -0x70(%rbp),%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1050 <memset@plt>
mov    0x2dba(%rip),%rax
mov    (%rax),%esi
mov    0x2e19(%rip),%rax
or     (%rax),%esi
lea    0xe38(%rip),%rdi
call   1080 <open@plt>
mov    %eax,-0x74(%rbp)
cmpl   $0x0,-0x74(%rbp)
jge    11e6 <uinput_init+0x86>
movl   $0xffffffff,-0x4(%rbp)
jmp    15b1 <uinput_init+0x451>
mov    -0x38(%rbp),%edi
mov    0x48(%rbp),%rsi
mov    0x2dac(%rip),%rax
mov    (%rax),%edx
call   1030 <strncpy@plt>
mov    0x2de6(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x3c(%rbp)
mov    0x38(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    0x40(%rbp),%rax
mov    %rax,-0x48(%rbp)
movl   $0x1,-0x40(%rbp)
cmpl   $0x0,-0x8(%rbp)
jle    1262 <uinput_init+0x102>
mov    -0x74(%rbp),%edi
mov    0x2d76(%rip),%rax
mov    (%rax),%esi
mov    0x2d95(%rip),%rax
mov    (%rax),%edx
mov    $0x0,%al
call   1060 <ioctl@plt>
cmp    $0x0,%rax
jge    1262 <uinput_init+0x102>
mov    -0x74(%rbp),%edi
call   1070 <close@plt>
movl   $0xfffffffe,-0x4(%rbp)
jmp    15b1 <uinput_init+0x451>
movl   $0x0,-0x78(%rbp)
mov    -0x78(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    12c5 <uinput_init+0x165>
mov    -0x74(%rbp),%edi
mov    0x2d09(%rip),%rax
mov    (%rax),%esi
mov    -0x10(%rbp),%rax
movslq -0x78(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
mov    $0x0,%al
call   1060 <ioctl@plt>
cmp    $0x0,%rax
jge    12b2 <uinput_init+0x152>
mov    -0x74(%rbp),%edi
call   1070 <close@plt>
movl   $0xfffffffd,-0x4(%rbp)
jmp    15b1 <uinput_init+0x451>
jmp    12b7 <uinput_init+0x157>
mov    -0x78(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x78(%rbp)
jmp    1269 <uinput_init+0x109>
cmpl   $0x0,-0x14(%rbp)
jle    1309 <uinput_init+0x1a9>
mov    -0x74(%rbp),%edi
mov    0x2ccf(%rip),%rax
mov    (%rax),%esi
mov    0x2c7e(%rip),%rax
mov    (%rax),%edx
mov    $0x0,%al
call   1060 <ioctl@plt>
cmp    $0x0,%rax
jge    1309 <uinput_init+0x1a9>
mov    -0x74(%rbp),%edi
call   1070 <close@plt>
movl   $0xfffffffc,-0x4(%rbp)
jmp    15b1 <uinput_init+0x451>
movl   $0x0,-0x78(%rbp)
mov    -0x78(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    13e7 <uinput_init+0x287>
mov    -0x74(%rbp),%edi
mov    0x2c42(%rip),%rax
mov    (%rax),%esi
mov    -0x20(%rbp),%rax
movslq -0x78(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
mov    $0x0,%al
call   1060 <ioctl@plt>
cmp    $0x0,%rax
jge    1359 <uinput_init+0x1f9>
mov    -0x74(%rbp),%edi
call   1070 <close@plt>
movl   $0xfffffffb,-0x4(%rbp)
jmp    15b1 <uinput_init+0x451>
mov    -0x28(%rbp),%rax
movslq -0x78(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
mov    -0x58(%rbp),%rax
mov    -0x20(%rbp),%rcx
movslq -0x78(%rbp),%rsi
mov    (%rcx,%rsi,8),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x30(%rbp),%rax
movslq -0x78(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
mov    -0x60(%rbp),%rax
mov    -0x20(%rbp),%rcx
movslq -0x78(%rbp),%rsi
mov    (%rcx,%rsi,8),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    0x10(%rbp),%rax
movslq -0x78(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
mov    -0x68(%rbp),%rax
mov    -0x20(%rbp),%rcx
movslq -0x78(%rbp),%rsi
mov    (%rcx,%rsi,8),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    0x18(%rbp),%rax
movslq -0x78(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
mov    -0x70(%rbp),%rax
mov    -0x20(%rbp),%rcx
movslq -0x78(%rbp),%rsi
mov    (%rcx,%rsi,8),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x78(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x78(%rbp)
jmp    1310 <uinput_init+0x1b0>
cmpl   $0x0,0x20(%rbp)
jle    142b <uinput_init+0x2cb>
mov    -0x74(%rbp),%edi
mov    0x2bad(%rip),%rax
mov    (%rax),%esi
mov    0x2bb4(%rip),%rax
mov    (%rax),%edx
mov    $0x0,%al
call   1060 <ioctl@plt>
cmp    $0x0,%rax
jge    142b <uinput_init+0x2cb>
mov    -0x74(%rbp),%edi
call   1070 <close@plt>
movl   $0xfffffffa,-0x4(%rbp)
jmp    15b1 <uinput_init+0x451>
movl   $0x0,-0x78(%rbp)
mov    -0x78(%rbp),%eax
cmp    0x20(%rbp),%eax
jge    148e <uinput_init+0x32e>
mov    -0x74(%rbp),%edi
mov    0x2b78(%rip),%rax
mov    (%rax),%esi
mov    0x28(%rbp),%rax
movslq -0x78(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
mov    $0x0,%al
call   1060 <ioctl@plt>
cmp    $0x0,%rax
jge    147b <uinput_init+0x31b>
mov    -0x74(%rbp),%edi
call   1070 <close@plt>
movl   $0xfffffff9,-0x4(%rbp)
jmp    15b1 <uinput_init+0x451>
jmp    1480 <uinput_init+0x320>
mov    -0x78(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x78(%rbp)
jmp    1432 <uinput_init+0x2d2>
cmpl   $0x0,0x30(%rbp)
je     154b <uinput_init+0x3eb>
mov    -0x74(%rbp),%edi
mov    0x2b06(%rip),%rax
mov    (%rax),%esi
mov    0x2b1d(%rip),%rax
mov    (%rax),%edx
mov    $0x0,%al
call   1060 <ioctl@plt>
cmp    $0x0,%rax
jge    14d2 <uinput_init+0x372>
mov    -0x74(%rbp),%edi
call   1070 <close@plt>
movl   $0xfffffff8,-0x4(%rbp)
jmp    15b1 <uinput_init+0x451>
mov    -0x74(%rbp),%edi
mov    0x2abc(%rip),%rax
mov    (%rax),%esi
mov    0x2a9b(%rip),%rax
mov    (%rax),%edx
mov    $0x0,%al
call   1060 <ioctl@plt>
cmp    $0x0,%rax
jge    150c <uinput_init+0x3ac>
mov    -0x74(%rbp),%edi
call   1070 <close@plt>
movl   $0xfffffff7,-0x4(%rbp)
jmp    15b1 <uinput_init+0x451>
mov    -0x74(%rbp),%edi
mov    0x2a92(%rip),%rax
mov    (%rax),%esi
mov    0x2a91(%rip),%rax
mov    (%rax),%edx
mov    $0x0,%al
call   1060 <ioctl@plt>
cmp    $0x0,%rax
jge    1546 <uinput_init+0x3e6>
mov    -0x74(%rbp),%edi
call   1070 <close@plt>
movl   $0xfffffff6,-0x4(%rbp)
jmp    15b1 <uinput_init+0x451>
jmp    154b <uinput_init+0x3eb>
mov    -0x74(%rbp),%edi
lea    -0x70(%rbp),%rsi
mov    $0x40,%edx
call   1040 <write@plt>
cmp    $0x0,%rax
jge    157a <uinput_init+0x41a>
mov    -0x74(%rbp),%edi
call   1070 <close@plt>
movl   $0xfffffff5,-0x4(%rbp)
jmp    15b1 <uinput_init+0x451>
mov    -0x74(%rbp),%edi
mov    0x2a74(%rip),%rax
mov    (%rax),%esi
mov    $0x0,%al
call   1060 <ioctl@plt>
cmp    $0x0,%rax
jge    15ab <uinput_init+0x44b>
mov    -0x74(%rbp),%edi
call   1070 <close@plt>
movl   $0xfffffff4,-0x4(%rbp)
jmp    15b1 <uinput_init+0x451>
mov    -0x74(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<uinput_init>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %r9,0x10(%rsp)
mov    %r8,0x8(%rsp)
mov    %rcx,%r12
mov    %edx,%ebp
mov    %rsi,%r14
mov    %edi,%ebx
lea    0x18(%rsp),%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1050 <memset@plt>
mov    0x2dd6(%rip),%rax
mov    0x2e37(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
lea    0xe54(%rip),%rdi
call   1080 <open@plt>
test   %eax,%eax
js     1429 <uinput_init+0x2c9>
mov    %eax,%r13d
mov    %ebp,0x4(%rsp)
mov    0xc8(%rsp),%rsi
mov    0xc0(%rsp),%r15
mov    0xb8(%rsp),%rbp
mov    0x50(%rsp),%edi
mov    0x2dbd(%rip),%rax
mov    (%rax),%edx
call   1030 <strncpy@plt>
mov    0x2df7(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x4c(%rsp)
mov    %rbp,0x38(%rsp)
mov    %r15,0x40(%rsp)
movl   $0x1,0x48(%rsp)
test   %ebx,%ebx
jle    1263 <uinput_init+0x103>
mov    0x2d94(%rip),%rax
mov    (%rax),%esi
mov    0x2db3(%rip),%rax
mov    (%rax),%edx
mov    %r13d,%edi
xor    %eax,%eax
call   1060 <ioctl@plt>
test   %rax,%rax
js     1431 <uinput_init+0x2d1>
mov    %ebx,%ebx
mov    0x2d4d(%rip),%r15
xor    %ebp,%ebp
nopl   (%rax)
mov    (%r15),%esi
mov    (%r14,%rbp,8),%rdx
mov    %r13d,%edi
xor    %eax,%eax
call   1060 <ioctl@plt>
test   %rax,%rax
js     1438 <uinput_init+0x2d8>
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    1240 <uinput_init+0xe0>
mov    0x4(%rsp),%ebx
test   %ebx,%ebx
jle    131d <uinput_init+0x1bd>
mov    0x2d32(%rip),%rax
mov    (%rax),%esi
mov    0x2ce1(%rip),%rax
mov    (%rax),%edx
mov    %r13d,%edi
xor    %eax,%eax
call   1060 <ioctl@plt>
test   %rax,%rax
js     143f <uinput_init+0x2df>
mov    0x90(%rsp),%rbp
mov    %ebx,%r14d
mov    0x2cc2(%rip),%rbx
xor    %r15d,%r15d
nopl   0x0(%rax)
mov    (%rbx),%esi
mov    (%r12,%r15,8),%rdx
mov    %r13d,%edi
xor    %eax,%eax
call   1060 <ioctl@plt>
test   %rax,%rax
js     1446 <uinput_init+0x2e6>
mov    0x8(%rsp),%rax
mov    (%rax,%r15,8),%rax
mov    0x30(%rsp),%rcx
mov    (%r12,%r15,8),%rdx
mov    %rax,(%rcx,%rdx,8)
mov    0x10(%rsp),%rax
mov    (%rax,%r15,8),%rax
mov    0x28(%rsp),%rcx
mov    %rax,(%rcx,%rdx,8)
mov    0x0(%rbp,%r15,8),%rax
mov    0x20(%rsp),%rcx
mov    %rax,(%rcx,%rdx,8)
mov    0x98(%rsp),%rax
mov    (%rax,%r15,8),%rax
mov    0x18(%rsp),%rcx
mov    %rax,(%rcx,%rdx,8)
add    $0x1,%r15
cmp    %r15,%r14
jne    12b0 <uinput_init+0x150>
mov    0xa0(%rsp),%ebx
test   %ebx,%ebx
jle    1383 <uinput_init+0x223>
mov    0x2c79(%rip),%rax
mov    (%rax),%esi
mov    0x2c80(%rip),%rax
mov    (%rax),%edx
mov    %r13d,%edi
xor    %eax,%eax
call   1060 <ioctl@plt>
test   %rax,%rax
js     144d <uinput_init+0x2ed>
mov    0xa8(%rsp),%r14
mov    %ebx,%ebx
mov    0x2c62(%rip),%r15
xor    %ebp,%ebp
mov    (%r15),%esi
mov    (%r14,%rbp,8),%rdx
mov    %r13d,%edi
xor    %eax,%eax
call   1060 <ioctl@plt>
test   %rax,%rax
js     1454 <uinput_init+0x2f4>
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    1360 <uinput_init+0x200>
cmpl   $0x0,0xb0(%rsp)
je     13f3 <uinput_init+0x293>
mov    0x2c14(%rip),%rbp
mov    0x0(%rbp),%esi
mov    0x2c2a(%rip),%rax
mov    (%rax),%edx
mov    %r13d,%edi
xor    %eax,%eax
call   1060 <ioctl@plt>
test   %rax,%rax
js     145b <uinput_init+0x2fb>
mov    0x2bde(%rip),%rax
mov    (%rax),%esi
mov    0x2bbd(%rip),%rax
mov    (%rax),%edx
mov    %r13d,%edi
xor    %eax,%eax
call   1060 <ioctl@plt>
test   %rax,%rax
js     1469 <uinput_init+0x309>
mov    0x0(%rbp),%esi
mov    0x2bce(%rip),%rax
mov    (%rax),%edx
mov    %r13d,%edi
xor    %eax,%eax
call   1060 <ioctl@plt>
test   %rax,%rax
js     1470 <uinput_init+0x310>
lea    0x18(%rsp),%rsi
mov    %r13d,%edi
mov    $0x40,%edx
call   1040 <write@plt>
test   %rax,%rax
js     1462 <uinput_init+0x302>
mov    0x2be7(%rip),%rax
mov    (%rax),%esi
mov    %r13d,%edi
xor    %eax,%eax
call   1060 <ioctl@plt>
test   %rax,%rax
jns    1480 <uinput_init+0x320>
mov    $0xfffffff4,%ebp
jmp    1475 <uinput_init+0x315>
mov    $0xffffffff,%r13d
jmp    1480 <uinput_init+0x320>
mov    $0xfffffffe,%ebp
jmp    1475 <uinput_init+0x315>
mov    $0xfffffffd,%ebp
jmp    1475 <uinput_init+0x315>
mov    $0xfffffffc,%ebp
jmp    1475 <uinput_init+0x315>
mov    $0xfffffffb,%ebp
jmp    1475 <uinput_init+0x315>
mov    $0xfffffffa,%ebp
jmp    1475 <uinput_init+0x315>
mov    $0xfffffff9,%ebp
jmp    1475 <uinput_init+0x315>
mov    $0xfffffff8,%ebp
jmp    1475 <uinput_init+0x315>
mov    $0xfffffff5,%ebp
jmp    1475 <uinput_init+0x315>
mov    $0xfffffff7,%ebp
jmp    1475 <uinput_init+0x315>
mov    $0xfffffff6,%ebp
mov    %r13d,%edi
call   1070 <close@plt>
mov    %ebp,%r13d
mov    %r13d,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.uinput_user_dev = type { i8**, i8**, i8**, i8**, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i64, i64, i32, i32 }
@.str = [12 x i8] c"/dev/uinput\00"
@O_WRONLY = global i32 0
@O_NONBLOCK = global i32 0
@UINPUT_MAX_NAME_SIZE = global i32 0
@BUS_USB = global i32 0
@UI_SET_EVBIT = global i32 0
@EV_KEY = global i32 0
@UI_SET_KEYBIT = global i32 0
@EV_ABS = global i32 0
@UI_SET_ABSBIT = global i32 0
@EV_REL = global i32 0
@UI_SET_RELBIT = global i32 0
@EV_MSC = global i32 0
@UI_SET_MSCBIT = global i32 0
@MSC_SCAN = global i32 0
@EV_REP = global i32 0
@UI_DEV_CREATE = global i32 0
define i32 @uinput_init(i32 %0, i64* %1, i32 %2, i64* %3, i8** %4, i8** %5, i8** %6, i8** %7, i32 %8, i64* %9, i32 %10, i64 %11, i64 %12, i8* %13) {
%15 = alloca i32
%16 = alloca i32
%17 = alloca i64*
%18 = alloca i32
%19 = alloca i64*
%20 = alloca i8**
%21 = alloca i8**
%22 = alloca i8**
%23 = alloca i8**
%24 = alloca i32
%25 = alloca i64*
%26 = alloca i32
%27 = alloca i64
%28 = alloca i64
%29 = alloca i8*
%30 = alloca %struct.uinput_user_dev
%31 = alloca i32
%32 = alloca i32
store i32 %0, i32* %16
store i64* %1, i64** %17
store i32 %2, i32* %18
store i64* %3, i64** %19
store i8** %4, i8*** %20
store i8** %5, i8*** %21
store i8** %6, i8*** %22
store i8** %7, i8*** %23
store i32 %8, i32* %24
store i64* %9, i64** %25
store i32 %10, i32* %26
store i64 %11, i64* %27
store i64 %12, i64* %28
store i8* %13, i8** %29
%33 = call i32 @memset(%struct.uinput_user_dev* %30, i32 0, i32 64)
%34 = load i32, i32* @O_WRONLY
%35 = load i32, i32* @O_NONBLOCK
%36 = or i32 %34, %35
%37 = call i32 @open(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %36)
store i32 %37, i32* %31
%38 = load i32, i32* %31
%39 = icmp slt i32 %38, 0
br i1 %39, label %40, label %41
40: ; preds = %14
store i32 -1, i32* %15
br label %259
41: ; preds = %14
%42 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %30, i32 0, i32 5
%43 = load i32, i32* %42
%44 = load i8*, i8** %29
%45 = load i32, i32* @UINPUT_MAX_NAME_SIZE
%46 = call i32 @strncpy(i32 %43, i8* %44, i32 %45)
%47 = load i32, i32* @BUS_USB
%48 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %30, i32 0, i32 4
%49 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %48, i32 0, i32 3
store i32 %47, i32* %49
%50 = load i64, i64* %27
%51 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %30, i32 0, i32 4
%52 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %51, i32 0, i32 0
store i64 %50, i64* %52
%53 = load i64, i64* %28
%54 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %30, i32 0, i32 4
%55 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %54, i32 0, i32 1
store i64 %53, i64* %55
%56 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %30, i32 0, i32 4
%57 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %56, i32 0, i32 2
store i32 1, i32* %57
%58 = load i32, i32* %16
%59 = icmp sgt i32 %58, 0
br i1 %59, label %60, label %69
60: ; preds = %41
%61 = load i32, i32* %31
%62 = load i32, i32* @UI_SET_EVBIT
%63 = load i32, i32* @EV_KEY
%64 = call i64 (i32, i32, ...) @ioctl(i32 %61, i32 %62, i32 %63)
%65 = icmp slt i64 %64, 0
br i1 %65, label %66, label %69
66: ; preds = %60
%67 = load i32, i32* %31
%68 = call i32 @close(i32 %67)
store i32 -2, i32* %15
br label %259
69: ; preds = %60, %41
store i32 0, i32* %32
br label %70
70: ; preds = %88, %69
%71 = load i32, i32* %32
%72 = load i32, i32* %16
%73 = icmp slt i32 %71, %72
br i1 %73, label %74, label %91
74: ; preds = %70
%75 = load i32, i32* %31
%76 = load i32, i32* @UI_SET_KEYBIT
%77 = load i64*, i64** %17
%78 = load i32, i32* %32
%79 = sext i32 %78 to i64
%80 = getelementptr inbounds i64, i64* %77, i64 %79
%81 = load i64, i64* %80
%82 = call i64 (i32, i32, ...) @ioctl(i32 %75, i32 %76, i64 %81)
%83 = icmp slt i64 %82, 0
br i1 %83, label %84, label %87
84: ; preds = %74
%85 = load i32, i32* %31
%86 = call i32 @close(i32 %85)
store i32 -3, i32* %15
br label %259
87: ; preds = %74
br label %88
88: ; preds = %87
%89 = load i32, i32* %32
%90 = add nsw i32 %89, 1
store i32 %90, i32* %32
br label %70
91: ; preds = %70
%92 = load i32, i32* %18
%93 = icmp sgt i32 %92, 0
br i1 %93, label %94, label %103
94: ; preds = %91
%95 = load i32, i32* %31
%96 = load i32, i32* @UI_SET_EVBIT
%97 = load i32, i32* @EV_ABS
%98 = call i64 (i32, i32, ...) @ioctl(i32 %95, i32 %96, i32 %97)
%99 = icmp slt i64 %98, 0
br i1 %99, label %100, label %103
100: ; preds = %94
%101 = load i32, i32* %31
%102 = call i32 @close(i32 %101)
store i32 -4, i32* %15
br label %259
103: ; preds = %94, %91
store i32 0, i32* %32
br label %104
104: ; preds = %174, %103
%105 = load i32, i32* %32
%106 = load i32, i32* %18
%107 = icmp slt i32 %105, %106
br i1 %107, label %108, label %177
108: ; preds = %104
%109 = load i32, i32* %31
%110 = load i32, i32* @UI_SET_ABSBIT
%111 = load i64*, i64** %19
%112 = load i32, i32* %32
%113 = sext i32 %112 to i64
%114 = getelementptr inbounds i64, i64* %111, i64 %113
%115 = load i64, i64* %114
%116 = call i64 (i32, i32, ...) @ioctl(i32 %109, i32 %110, i64 %115)
%117 = icmp slt i64 %116, 0
br i1 %117, label %118, label %121
118: ; preds = %108
%119 = load i32, i32* %31
%120 = call i32 @close(i32 %119)
store i32 -5, i32* %15
br label %259
121: ; preds = %108
%122 = load i8**, i8*** %20
%123 = load i32, i32* %32
%124 = sext i32 %123 to i64
%125 = getelementptr inbounds i8*, i8** %122, i64 %124
%126 = load i8*, i8** %125
%127 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %30, i32 0, i32 3
%128 = load i8**, i8*** %127
%129 = load i64*, i64** %19
%130 = load i32, i32* %32
%131 = sext i32 %130 to i64
%132 = getelementptr inbounds i64, i64* %129, i64 %131
%133 = load i64, i64* %132
%134 = getelementptr inbounds i8*, i8** %128, i64 %133
store i8* %126, i8** %134
%135 = load i8**, i8*** %21
%136 = load i32, i32* %32
%137 = sext i32 %136 to i64
%138 = getelementptr inbounds i8*, i8** %135, i64 %137
%139 = load i8*, i8** %138
%140 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %30, i32 0, i32 2
%141 = load i8**, i8*** %140
%142 = load i64*, i64** %19
%143 = load i32, i32* %32
%144 = sext i32 %143 to i64
%145 = getelementptr inbounds i64, i64* %142, i64 %144
%146 = load i64, i64* %145
%147 = getelementptr inbounds i8*, i8** %141, i64 %146
store i8* %139, i8** %147
%148 = load i8**, i8*** %22
%149 = load i32, i32* %32
%150 = sext i32 %149 to i64
%151 = getelementptr inbounds i8*, i8** %148, i64 %150
%152 = load i8*, i8** %151
%153 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %30, i32 0, i32 1
%154 = load i8**, i8*** %153
%155 = load i64*, i64** %19
%156 = load i32, i32* %32
%157 = sext i32 %156 to i64
%158 = getelementptr inbounds i64, i64* %155, i64 %157
%159 = load i64, i64* %158
%160 = getelementptr inbounds i8*, i8** %154, i64 %159
store i8* %152, i8** %160
%161 = load i8**, i8*** %23
%162 = load i32, i32* %32
%163 = sext i32 %162 to i64
%164 = getelementptr inbounds i8*, i8** %161, i64 %163
%165 = load i8*, i8** %164
%166 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %30, i32 0, i32 0
%167 = load i8**, i8*** %166
%168 = load i64*, i64** %19
%169 = load i32, i32* %32
%170 = sext i32 %169 to i64
%171 = getelementptr inbounds i64, i64* %168, i64 %170
%172 = load i64, i64* %171
%173 = getelementptr inbounds i8*, i8** %167, i64 %172
store i8* %165, i8** %173
br label %174
174: ; preds = %121
%175 = load i32, i32* %32
%176 = add nsw i32 %175, 1
store i32 %176, i32* %32
br label %104
177: ; preds = %104
%178 = load i32, i32* %24
%179 = icmp sgt i32 %178, 0
br i1 %179, label %180, label %189
180: ; preds = %177
%181 = load i32, i32* %31
%182 = load i32, i32* @UI_SET_EVBIT
%183 = load i32, i32* @EV_REL
%184 = call i64 (i32, i32, ...) @ioctl(i32 %181, i32 %182, i32 %183)
%185 = icmp slt i64 %184, 0
br i1 %185, label %186, label %189
186: ; preds = %180
%187 = load i32, i32* %31
%188 = call i32 @close(i32 %187)
store i32 -6, i32* %15
br label %259
189: ; preds = %180, %177
store i32 0, i32* %32
br label %190
190: ; preds = %208, %189
%191 = load i32, i32* %32
%192 = load i32, i32* %24
%193 = icmp slt i32 %191, %192
br i1 %193, label %194, label %211
194: ; preds = %190
%195 = load i32, i32* %31
%196 = load i32, i32* @UI_SET_RELBIT
%197 = load i64*, i64** %25
%198 = load i32, i32* %32
%199 = sext i32 %198 to i64
%200 = getelementptr inbounds i64, i64* %197, i64 %199
%201 = load i64, i64* %200
%202 = call i64 (i32, i32, ...) @ioctl(i32 %195, i32 %196, i64 %201)
%203 = icmp slt i64 %202, 0
br i1 %203, label %204, label %207
204: ; preds = %194
%205 = load i32, i32* %31
%206 = call i32 @close(i32 %205)
store i32 -7, i32* %15
br label %259
207: ; preds = %194
br label %208
208: ; preds = %207
%209 = load i32, i32* %32
%210 = add nsw i32 %209, 1
store i32 %210, i32* %32
br label %190
211: ; preds = %190
%212 = load i32, i32* %26
%213 = icmp ne i32 %212, 0
br i1 %213, label %214, label %242
214: ; preds = %211
%215 = load i32, i32* %31
%216 = load i32, i32* @UI_SET_EVBIT
%217 = load i32, i32* @EV_MSC
%218 = call i64 (i32, i32, ...) @ioctl(i32 %215, i32 %216, i32 %217)
%219 = icmp slt i64 %218, 0
br i1 %219, label %220, label %223
220: ; preds = %214
%221 = load i32, i32* %31
%222 = call i32 @close(i32 %221)
store i32 -8, i32* %15
br label %259
223: ; preds = %214
%224 = load i32, i32* %31
%225 = load i32, i32* @UI_SET_MSCBIT
%226 = load i32, i32* @MSC_SCAN
%227 = call i64 (i32, i32, ...) @ioctl(i32 %224, i32 %225, i32 %226)
%228 = icmp slt i64 %227, 0
br i1 %228, label %229, label %232
229: ; preds = %223
%230 = load i32, i32* %31
%231 = call i32 @close(i32 %230)
store i32 -9, i32* %15
br label %259
232: ; preds = %223
%233 = load i32, i32* %31
%234 = load i32, i32* @UI_SET_EVBIT
%235 = load i32, i32* @EV_REP
%236 = call i64 (i32, i32, ...) @ioctl(i32 %233, i32 %234, i32 %235)
%237 = icmp slt i64 %236, 0
br i1 %237, label %238, label %241
238: ; preds = %232
%239 = load i32, i32* %31
%240 = call i32 @close(i32 %239)
store i32 -10, i32* %15
br label %259
241: ; preds = %232
br label %242
242: ; preds = %241, %211
%243 = load i32, i32* %31
%244 = call i64 @write(i32 %243, %struct.uinput_user_dev* %30, i32 64)
%245 = icmp slt i64 %244, 0
br i1 %245, label %246, label %249
246: ; preds = %242
%247 = load i32, i32* %31
%248 = call i32 @close(i32 %247)
store i32 -11, i32* %15
br label %259
249: ; preds = %242
%250 = load i32, i32* %31
%251 = load i32, i32* @UI_DEV_CREATE
%252 = call i64 (i32, i32, ...) @ioctl(i32 %250, i32 %251)
%253 = icmp slt i64 %252, 0
br i1 %253, label %254, label %257
254: ; preds = %249
%255 = load i32, i32* %31
%256 = call i32 @close(i32 %255)
store i32 -12, i32* %15
br label %259
257: ; preds = %249
%258 = load i32, i32* %31
store i32 %258, i32* %15
br label %259
259: ; preds = %257, %254, %246, %238, %229, %220, %204, %186, %118, %100, %84, %66, %40
%260 = load i32, i32* %15
ret i32 %260
}

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