#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;
  size_t 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, __u16 version, 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 = version;
  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    0x50(%rbp),%rax
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    -0x78(%rbp),%rdi
xor    %esi,%esi
mov    $0x48,%edx
call   1050 <memset@plt>
mov    0x2db6(%rip),%rax
mov    (%rax),%esi
mov    0x2e15(%rip),%rax
or     (%rax),%esi
lea    0xe34(%rip),%rdi
call   1080 <open@plt>
mov    %eax,-0x7c(%rbp)
cmpl   $0x0,-0x7c(%rbp)
jge    11ea <uinput_init+0x8a>
movl   $0xffffffff,-0x4(%rbp)
jmp    15b6 <uinput_init+0x456>
mov    -0x38(%rbp),%edi
mov    0x50(%rbp),%rsi
mov    0x2da8(%rip),%rax
mov    (%rax),%edx
call   1030 <strncpy@plt>
mov    0x2de2(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x40(%rbp)
mov    0x38(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    0x40(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    0x48(%rbp),%rax
mov    %rax,-0x48(%rbp)
cmpl   $0x0,-0x8(%rbp)
jle    1267 <uinput_init+0x107>
mov    -0x7c(%rbp),%edi
mov    0x2d71(%rip),%rax
mov    (%rax),%esi
mov    0x2d90(%rip),%rax
mov    (%rax),%edx
mov    $0x0,%al
call   1060 <ioctl@plt>
cmp    $0x0,%rax
jge    1267 <uinput_init+0x107>
mov    -0x7c(%rbp),%edi
call   1070 <close@plt>
movl   $0xfffffffe,-0x4(%rbp)
jmp    15b6 <uinput_init+0x456>
movl   $0x0,-0x80(%rbp)
mov    -0x80(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    12ca <uinput_init+0x16a>
mov    -0x7c(%rbp),%edi
mov    0x2d04(%rip),%rax
mov    (%rax),%esi
mov    -0x10(%rbp),%rax
movslq -0x80(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
mov    $0x0,%al
call   1060 <ioctl@plt>
cmp    $0x0,%rax
jge    12b7 <uinput_init+0x157>
mov    -0x7c(%rbp),%edi
call   1070 <close@plt>
movl   $0xfffffffd,-0x4(%rbp)
jmp    15b6 <uinput_init+0x456>
jmp    12bc <uinput_init+0x15c>
mov    -0x80(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x80(%rbp)
jmp    126e <uinput_init+0x10e>
cmpl   $0x0,-0x14(%rbp)
jle    130e <uinput_init+0x1ae>
mov    -0x7c(%rbp),%edi
mov    0x2cca(%rip),%rax
mov    (%rax),%esi
mov    0x2c79(%rip),%rax
mov    (%rax),%edx
mov    $0x0,%al
call   1060 <ioctl@plt>
cmp    $0x0,%rax
jge    130e <uinput_init+0x1ae>
mov    -0x7c(%rbp),%edi
call   1070 <close@plt>
movl   $0xfffffffc,-0x4(%rbp)
jmp    15b6 <uinput_init+0x456>
movl   $0x0,-0x80(%rbp)
mov    -0x80(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    13ec <uinput_init+0x28c>
mov    -0x7c(%rbp),%edi
mov    0x2c3d(%rip),%rax
mov    (%rax),%esi
mov    -0x20(%rbp),%rax
movslq -0x80(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
mov    $0x0,%al
call   1060 <ioctl@plt>
cmp    $0x0,%rax
jge    135e <uinput_init+0x1fe>
mov    -0x7c(%rbp),%edi
call   1070 <close@plt>
movl   $0xfffffffb,-0x4(%rbp)
jmp    15b6 <uinput_init+0x456>
mov    -0x28(%rbp),%rax
movslq -0x80(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
mov    -0x60(%rbp),%rax
mov    -0x20(%rbp),%rcx
movslq -0x80(%rbp),%rsi
mov    (%rcx,%rsi,8),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x30(%rbp),%rax
movslq -0x80(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
mov    -0x68(%rbp),%rax
mov    -0x20(%rbp),%rcx
movslq -0x80(%rbp),%rsi
mov    (%rcx,%rsi,8),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    0x10(%rbp),%rax
movslq -0x80(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
mov    -0x70(%rbp),%rax
mov    -0x20(%rbp),%rcx
movslq -0x80(%rbp),%rsi
mov    (%rcx,%rsi,8),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    0x18(%rbp),%rax
movslq -0x80(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
mov    -0x78(%rbp),%rax
mov    -0x20(%rbp),%rcx
movslq -0x80(%rbp),%rsi
mov    (%rcx,%rsi,8),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x80(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x80(%rbp)
jmp    1315 <uinput_init+0x1b5>
cmpl   $0x0,0x20(%rbp)
jle    1430 <uinput_init+0x2d0>
mov    -0x7c(%rbp),%edi
mov    0x2ba8(%rip),%rax
mov    (%rax),%esi
mov    0x2baf(%rip),%rax
mov    (%rax),%edx
mov    $0x0,%al
call   1060 <ioctl@plt>
cmp    $0x0,%rax
jge    1430 <uinput_init+0x2d0>
mov    -0x7c(%rbp),%edi
call   1070 <close@plt>
movl   $0xfffffffa,-0x4(%rbp)
jmp    15b6 <uinput_init+0x456>
movl   $0x0,-0x80(%rbp)
mov    -0x80(%rbp),%eax
cmp    0x20(%rbp),%eax
jge    1493 <uinput_init+0x333>
mov    -0x7c(%rbp),%edi
mov    0x2b73(%rip),%rax
mov    (%rax),%esi
mov    0x28(%rbp),%rax
movslq -0x80(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
mov    $0x0,%al
call   1060 <ioctl@plt>
cmp    $0x0,%rax
jge    1480 <uinput_init+0x320>
mov    -0x7c(%rbp),%edi
call   1070 <close@plt>
movl   $0xfffffff9,-0x4(%rbp)
jmp    15b6 <uinput_init+0x456>
jmp    1485 <uinput_init+0x325>
mov    -0x80(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x80(%rbp)
jmp    1437 <uinput_init+0x2d7>
cmpl   $0x0,0x30(%rbp)
je     1550 <uinput_init+0x3f0>
mov    -0x7c(%rbp),%edi
mov    0x2b01(%rip),%rax
mov    (%rax),%esi
mov    0x2b18(%rip),%rax
mov    (%rax),%edx
mov    $0x0,%al
call   1060 <ioctl@plt>
cmp    $0x0,%rax
jge    14d7 <uinput_init+0x377>
mov    -0x7c(%rbp),%edi
call   1070 <close@plt>
movl   $0xfffffff8,-0x4(%rbp)
jmp    15b6 <uinput_init+0x456>
mov    -0x7c(%rbp),%edi
mov    0x2ab7(%rip),%rax
mov    (%rax),%esi
mov    0x2a96(%rip),%rax
mov    (%rax),%edx
mov    $0x0,%al
call   1060 <ioctl@plt>
cmp    $0x0,%rax
jge    1511 <uinput_init+0x3b1>
mov    -0x7c(%rbp),%edi
call   1070 <close@plt>
movl   $0xfffffff7,-0x4(%rbp)
jmp    15b6 <uinput_init+0x456>
mov    -0x7c(%rbp),%edi
mov    0x2a8d(%rip),%rax
mov    (%rax),%esi
mov    0x2a8c(%rip),%rax
mov    (%rax),%edx
mov    $0x0,%al
call   1060 <ioctl@plt>
cmp    $0x0,%rax
jge    154b <uinput_init+0x3eb>
mov    -0x7c(%rbp),%edi
call   1070 <close@plt>
movl   $0xfffffff6,-0x4(%rbp)
jmp    15b6 <uinput_init+0x456>
jmp    1550 <uinput_init+0x3f0>
mov    -0x7c(%rbp),%edi
lea    -0x78(%rbp),%rsi
mov    $0x48,%edx
call   1040 <write@plt>
cmp    $0x0,%rax
jge    157f <uinput_init+0x41f>
mov    -0x7c(%rbp),%edi
call   1070 <close@plt>
movl   $0xfffffff5,-0x4(%rbp)
jmp    15b6 <uinput_init+0x456>
mov    -0x7c(%rbp),%edi
mov    0x2a6f(%rip),%rax
mov    (%rax),%esi
mov    $0x0,%al
call   1060 <ioctl@plt>
cmp    $0x0,%rax
jge    15b0 <uinput_init+0x450>
mov    -0x7c(%rbp),%edi
call   1070 <close@plt>
movl   $0xfffffff4,-0x4(%rbp)
jmp    15b6 <uinput_init+0x456>
mov    -0x7c(%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    $0x68,%rsp
mov    %r9,0x18(%rsp)
mov    %r8,0x10(%rsp)
mov    %rcx,%r12
mov    %edx,%ebx
mov    %rsi,%r14
mov    %edi,%r13d
lea    0x20(%rsp),%rdi
xor    %esi,%esi
mov    $0x48,%edx
call   1050 <memset@plt>
mov    0x2dd5(%rip),%rax
mov    0x2e36(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
lea    0xe53(%rip),%rdi
call   1080 <open@plt>
test   %eax,%eax
js     143a <uinput_init+0x2da>
mov    %eax,%r15d
mov    %ebx,0xc(%rsp)
mov    0xe0(%rsp),%rsi
mov    0xd0(%rsp),%rbp
mov    0xc8(%rsp),%rbx
mov    0x60(%rsp),%edi
mov    0x2dbc(%rip),%rax
mov    (%rax),%edx
call   1030 <strncpy@plt>
mov    0x2df6(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x58(%rsp)
mov    %rbx,0x40(%rsp)
mov    %rbp,0x48(%rsp)
mov    0xd8(%rsp),%rax
mov    %rax,0x50(%rsp)
test   %r13d,%r13d
jle    1274 <uinput_init+0x114>
mov    0x2d8d(%rip),%rax
mov    (%rax),%esi
mov    0x2dac(%rip),%rax
mov    (%rax),%edx
mov    %r15d,%edi
xor    %eax,%eax
call   1060 <ioctl@plt>
test   %rax,%rax
js     1442 <uinput_init+0x2e2>
mov    %r13d,%ebx
mov    0x2d45(%rip),%r13
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
mov    0x0(%r13),%esi
mov    (%r14,%rbp,8),%rdx
mov    %r15d,%edi
xor    %eax,%eax
call   1060 <ioctl@plt>
test   %rax,%rax
js     1449 <uinput_init+0x2e9>
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    1250 <uinput_init+0xf0>
mov    0xc(%rsp),%ebx
test   %ebx,%ebx
jle    132d <uinput_init+0x1cd>
mov    0x2d21(%rip),%rax
mov    (%rax),%esi
mov    0x2cd0(%rip),%rax
mov    (%rax),%edx
mov    %r15d,%edi
xor    %eax,%eax
call   1060 <ioctl@plt>
test   %rax,%rax
js     1450 <uinput_init+0x2f0>
mov    0xa0(%rsp),%rbp
mov    %ebx,%r14d
mov    0x2cb1(%rip),%rbx
xor    %r13d,%r13d
nopw   0x0(%rax,%rax,1)
mov    (%rbx),%esi
mov    (%r12,%r13,8),%rdx
mov    %r15d,%edi
xor    %eax,%eax
call   1060 <ioctl@plt>
test   %rax,%rax
js     1457 <uinput_init+0x2f7>
mov    0x10(%rsp),%rax
mov    (%rax,%r13,8),%rax
mov    0x38(%rsp),%rcx
mov    (%r12,%r13,8),%rdx
mov    %rax,(%rcx,%rdx,8)
mov    0x18(%rsp),%rax
mov    (%rax,%r13,8),%rax
mov    0x30(%rsp),%rcx
mov    %rax,(%rcx,%rdx,8)
mov    0x0(%rbp,%r13,8),%rax
mov    0x28(%rsp),%rcx
mov    %rax,(%rcx,%rdx,8)
mov    0xa8(%rsp),%rax
mov    (%rax,%r13,8),%rax
mov    0x20(%rsp),%rcx
mov    %rax,(%rcx,%rdx,8)
add    $0x1,%r13
cmp    %r13,%r14
jne    12c0 <uinput_init+0x160>
mov    0xb0(%rsp),%ebx
test   %ebx,%ebx
jle    1394 <uinput_init+0x234>
mov    0x2c69(%rip),%rax
mov    (%rax),%esi
mov    0x2c70(%rip),%rax
mov    (%rax),%edx
mov    %r15d,%edi
xor    %eax,%eax
call   1060 <ioctl@plt>
test   %rax,%rax
js     145e <uinput_init+0x2fe>
mov    0xb8(%rsp),%r14
mov    %ebx,%ebx
mov    0x2c52(%rip),%r12
xor    %ebp,%ebp
mov    (%r12),%esi
mov    (%r14,%rbp,8),%rdx
mov    %r15d,%edi
xor    %eax,%eax
call   1060 <ioctl@plt>
test   %rax,%rax
js     1465 <uinput_init+0x305>
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    1370 <uinput_init+0x210>
cmpl   $0x0,0xc0(%rsp)
je     1404 <uinput_init+0x2a4>
mov    0x2c03(%rip),%rbp
mov    0x0(%rbp),%esi
mov    0x2c19(%rip),%rax
mov    (%rax),%edx
mov    %r15d,%edi
xor    %eax,%eax
call   1060 <ioctl@plt>
test   %rax,%rax
js     146c <uinput_init+0x30c>
mov    0x2bcd(%rip),%rax
mov    (%rax),%esi
mov    0x2bac(%rip),%rax
mov    (%rax),%edx
mov    %r15d,%edi
xor    %eax,%eax
call   1060 <ioctl@plt>
test   %rax,%rax
js     147a <uinput_init+0x31a>
mov    0x0(%rbp),%esi
mov    0x2bbd(%rip),%rax
mov    (%rax),%edx
mov    %r15d,%edi
xor    %eax,%eax
call   1060 <ioctl@plt>
test   %rax,%rax
js     1481 <uinput_init+0x321>
lea    0x20(%rsp),%rsi
mov    %r15d,%edi
mov    $0x48,%edx
call   1040 <write@plt>
test   %rax,%rax
js     1473 <uinput_init+0x313>
mov    0x2bd6(%rip),%rax
mov    (%rax),%esi
mov    %r15d,%edi
xor    %eax,%eax
call   1060 <ioctl@plt>
test   %rax,%rax
jns    1491 <uinput_init+0x331>
mov    $0xfffffff4,%ebp
jmp    1486 <uinput_init+0x326>
mov    $0xffffffff,%r15d
jmp    1491 <uinput_init+0x331>
mov    $0xfffffffe,%ebp
jmp    1486 <uinput_init+0x326>
mov    $0xfffffffd,%ebp
jmp    1486 <uinput_init+0x326>
mov    $0xfffffffc,%ebp
jmp    1486 <uinput_init+0x326>
mov    $0xfffffffb,%ebp
jmp    1486 <uinput_init+0x326>
mov    $0xfffffffa,%ebp
jmp    1486 <uinput_init+0x326>
mov    $0xfffffff9,%ebp
jmp    1486 <uinput_init+0x326>
mov    $0xfffffff8,%ebp
jmp    1486 <uinput_init+0x326>
mov    $0xfffffff5,%ebp
jmp    1486 <uinput_init+0x326>
mov    $0xfffffff7,%ebp
jmp    1486 <uinput_init+0x326>
mov    $0xfffffff6,%ebp
mov    %r15d,%edi
call   1070 <close@plt>
mov    %ebp,%r15d
mov    %r15d,%eax
add    $0x68,%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, i64, 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, i64 %13, i8* %14) {
%16 = alloca i32
%17 = alloca i32
%18 = alloca i64*
%19 = alloca i32
%20 = alloca i64*
%21 = alloca i8**
%22 = alloca i8**
%23 = alloca i8**
%24 = alloca i8**
%25 = alloca i32
%26 = alloca i64*
%27 = alloca i32
%28 = alloca i64
%29 = alloca i64
%30 = alloca i64
%31 = alloca i8*
%32 = alloca %struct.uinput_user_dev
%33 = alloca i32
%34 = alloca i32
store i32 %0, i32* %17
store i64* %1, i64** %18
store i32 %2, i32* %19
store i64* %3, i64** %20
store i8** %4, i8*** %21
store i8** %5, i8*** %22
store i8** %6, i8*** %23
store i8** %7, i8*** %24
store i32 %8, i32* %25
store i64* %9, i64** %26
store i32 %10, i32* %27
store i64 %11, i64* %28
store i64 %12, i64* %29
store i64 %13, i64* %30
store i8* %14, i8** %31
%35 = call i32 @memset(%struct.uinput_user_dev* %32, i32 0, i32 72)
%36 = load i32, i32* @O_WRONLY
%37 = load i32, i32* @O_NONBLOCK
%38 = or i32 %36, %37
%39 = call i32 @open(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %38)
store i32 %39, i32* %33
%40 = load i32, i32* %33
%41 = icmp slt i32 %40, 0
br i1 %41, label %42, label %43
42: ; preds = %15
store i32 -1, i32* %16
br label %262
43: ; preds = %15
%44 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %32, i32 0, i32 5
%45 = load i32, i32* %44
%46 = load i8*, i8** %31
%47 = load i32, i32* @UINPUT_MAX_NAME_SIZE
%48 = call i32 @strncpy(i32 %45, i8* %46, i32 %47)
%49 = load i32, i32* @BUS_USB
%50 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %32, i32 0, i32 4
%51 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %50, i32 0, i32 3
store i32 %49, i32* %51
%52 = load i64, i64* %28
%53 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %32, i32 0, i32 4
%54 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %53, i32 0, i32 0
store i64 %52, i64* %54
%55 = load i64, i64* %29
%56 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %32, i32 0, i32 4
%57 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %56, i32 0, i32 1
store i64 %55, i64* %57
%58 = load i64, i64* %30
%59 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %32, i32 0, i32 4
%60 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %59, i32 0, i32 2
store i64 %58, i64* %60
%61 = load i32, i32* %17
%62 = icmp sgt i32 %61, 0
br i1 %62, label %63, label %72
63: ; preds = %43
%64 = load i32, i32* %33
%65 = load i32, i32* @UI_SET_EVBIT
%66 = load i32, i32* @EV_KEY
%67 = call i64 (i32, i32, ...) @ioctl(i32 %64, i32 %65, i32 %66)
%68 = icmp slt i64 %67, 0
br i1 %68, label %69, label %72
69: ; preds = %63
%70 = load i32, i32* %33
%71 = call i32 @close(i32 %70)
store i32 -2, i32* %16
br label %262
72: ; preds = %63, %43
store i32 0, i32* %34
br label %73
73: ; preds = %91, %72
%74 = load i32, i32* %34
%75 = load i32, i32* %17
%76 = icmp slt i32 %74, %75
br i1 %76, label %77, label %94
77: ; preds = %73
%78 = load i32, i32* %33
%79 = load i32, i32* @UI_SET_KEYBIT
%80 = load i64*, i64** %18
%81 = load i32, i32* %34
%82 = sext i32 %81 to i64
%83 = getelementptr inbounds i64, i64* %80, i64 %82
%84 = load i64, i64* %83
%85 = call i64 (i32, i32, ...) @ioctl(i32 %78, i32 %79, i64 %84)
%86 = icmp slt i64 %85, 0
br i1 %86, label %87, label %90
87: ; preds = %77
%88 = load i32, i32* %33
%89 = call i32 @close(i32 %88)
store i32 -3, i32* %16
br label %262
90: ; preds = %77
br label %91
91: ; preds = %90
%92 = load i32, i32* %34
%93 = add nsw i32 %92, 1
store i32 %93, i32* %34
br label %73
94: ; preds = %73
%95 = load i32, i32* %19
%96 = icmp sgt i32 %95, 0
br i1 %96, label %97, label %106
97: ; preds = %94
%98 = load i32, i32* %33
%99 = load i32, i32* @UI_SET_EVBIT
%100 = load i32, i32* @EV_ABS
%101 = call i64 (i32, i32, ...) @ioctl(i32 %98, i32 %99, i32 %100)
%102 = icmp slt i64 %101, 0
br i1 %102, label %103, label %106
103: ; preds = %97
%104 = load i32, i32* %33
%105 = call i32 @close(i32 %104)
store i32 -4, i32* %16
br label %262
106: ; preds = %97, %94
store i32 0, i32* %34
br label %107
107: ; preds = %177, %106
%108 = load i32, i32* %34
%109 = load i32, i32* %19
%110 = icmp slt i32 %108, %109
br i1 %110, label %111, label %180
111: ; preds = %107
%112 = load i32, i32* %33
%113 = load i32, i32* @UI_SET_ABSBIT
%114 = load i64*, i64** %20
%115 = load i32, i32* %34
%116 = sext i32 %115 to i64
%117 = getelementptr inbounds i64, i64* %114, i64 %116
%118 = load i64, i64* %117
%119 = call i64 (i32, i32, ...) @ioctl(i32 %112, i32 %113, i64 %118)
%120 = icmp slt i64 %119, 0
br i1 %120, label %121, label %124
121: ; preds = %111
%122 = load i32, i32* %33
%123 = call i32 @close(i32 %122)
store i32 -5, i32* %16
br label %262
124: ; preds = %111
%125 = load i8**, i8*** %21
%126 = load i32, i32* %34
%127 = sext i32 %126 to i64
%128 = getelementptr inbounds i8*, i8** %125, i64 %127
%129 = load i8*, i8** %128
%130 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %32, i32 0, i32 3
%131 = load i8**, i8*** %130
%132 = load i64*, i64** %20
%133 = load i32, i32* %34
%134 = sext i32 %133 to i64
%135 = getelementptr inbounds i64, i64* %132, i64 %134
%136 = load i64, i64* %135
%137 = getelementptr inbounds i8*, i8** %131, i64 %136
store i8* %129, i8** %137
%138 = load i8**, i8*** %22
%139 = load i32, i32* %34
%140 = sext i32 %139 to i64
%141 = getelementptr inbounds i8*, i8** %138, i64 %140
%142 = load i8*, i8** %141
%143 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %32, i32 0, i32 2
%144 = load i8**, i8*** %143
%145 = load i64*, i64** %20
%146 = load i32, i32* %34
%147 = sext i32 %146 to i64
%148 = getelementptr inbounds i64, i64* %145, i64 %147
%149 = load i64, i64* %148
%150 = getelementptr inbounds i8*, i8** %144, i64 %149
store i8* %142, i8** %150
%151 = load i8**, i8*** %23
%152 = load i32, i32* %34
%153 = sext i32 %152 to i64
%154 = getelementptr inbounds i8*, i8** %151, i64 %153
%155 = load i8*, i8** %154
%156 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %32, i32 0, i32 1
%157 = load i8**, i8*** %156
%158 = load i64*, i64** %20
%159 = load i32, i32* %34
%160 = sext i32 %159 to i64
%161 = getelementptr inbounds i64, i64* %158, i64 %160
%162 = load i64, i64* %161
%163 = getelementptr inbounds i8*, i8** %157, i64 %162
store i8* %155, i8** %163
%164 = load i8**, i8*** %24
%165 = load i32, i32* %34
%166 = sext i32 %165 to i64
%167 = getelementptr inbounds i8*, i8** %164, i64 %166
%168 = load i8*, i8** %167
%169 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %32, i32 0, i32 0
%170 = load i8**, i8*** %169
%171 = load i64*, i64** %20
%172 = load i32, i32* %34
%173 = sext i32 %172 to i64
%174 = getelementptr inbounds i64, i64* %171, i64 %173
%175 = load i64, i64* %174
%176 = getelementptr inbounds i8*, i8** %170, i64 %175
store i8* %168, i8** %176
br label %177
177: ; preds = %124
%178 = load i32, i32* %34
%179 = add nsw i32 %178, 1
store i32 %179, i32* %34
br label %107
180: ; preds = %107
%181 = load i32, i32* %25
%182 = icmp sgt i32 %181, 0
br i1 %182, label %183, label %192
183: ; preds = %180
%184 = load i32, i32* %33
%185 = load i32, i32* @UI_SET_EVBIT
%186 = load i32, i32* @EV_REL
%187 = call i64 (i32, i32, ...) @ioctl(i32 %184, i32 %185, i32 %186)
%188 = icmp slt i64 %187, 0
br i1 %188, label %189, label %192
189: ; preds = %183
%190 = load i32, i32* %33
%191 = call i32 @close(i32 %190)
store i32 -6, i32* %16
br label %262
192: ; preds = %183, %180
store i32 0, i32* %34
br label %193
193: ; preds = %211, %192
%194 = load i32, i32* %34
%195 = load i32, i32* %25
%196 = icmp slt i32 %194, %195
br i1 %196, label %197, label %214
197: ; preds = %193
%198 = load i32, i32* %33
%199 = load i32, i32* @UI_SET_RELBIT
%200 = load i64*, i64** %26
%201 = load i32, i32* %34
%202 = sext i32 %201 to i64
%203 = getelementptr inbounds i64, i64* %200, i64 %202
%204 = load i64, i64* %203
%205 = call i64 (i32, i32, ...) @ioctl(i32 %198, i32 %199, i64 %204)
%206 = icmp slt i64 %205, 0
br i1 %206, label %207, label %210
207: ; preds = %197
%208 = load i32, i32* %33
%209 = call i32 @close(i32 %208)
store i32 -7, i32* %16
br label %262
210: ; preds = %197
br label %211
211: ; preds = %210
%212 = load i32, i32* %34
%213 = add nsw i32 %212, 1
store i32 %213, i32* %34
br label %193
214: ; preds = %193
%215 = load i32, i32* %27
%216 = icmp ne i32 %215, 0
br i1 %216, label %217, label %245
217: ; preds = %214
%218 = load i32, i32* %33
%219 = load i32, i32* @UI_SET_EVBIT
%220 = load i32, i32* @EV_MSC
%221 = call i64 (i32, i32, ...) @ioctl(i32 %218, i32 %219, i32 %220)
%222 = icmp slt i64 %221, 0
br i1 %222, label %223, label %226
223: ; preds = %217
%224 = load i32, i32* %33
%225 = call i32 @close(i32 %224)
store i32 -8, i32* %16
br label %262
226: ; preds = %217
%227 = load i32, i32* %33
%228 = load i32, i32* @UI_SET_MSCBIT
%229 = load i32, i32* @MSC_SCAN
%230 = call i64 (i32, i32, ...) @ioctl(i32 %227, i32 %228, i32 %229)
%231 = icmp slt i64 %230, 0
br i1 %231, label %232, label %235
232: ; preds = %226
%233 = load i32, i32* %33
%234 = call i32 @close(i32 %233)
store i32 -9, i32* %16
br label %262
235: ; preds = %226
%236 = load i32, i32* %33
%237 = load i32, i32* @UI_SET_EVBIT
%238 = load i32, i32* @EV_REP
%239 = call i64 (i32, i32, ...) @ioctl(i32 %236, i32 %237, i32 %238)
%240 = icmp slt i64 %239, 0
br i1 %240, label %241, label %244
241: ; preds = %235
%242 = load i32, i32* %33
%243 = call i32 @close(i32 %242)
store i32 -10, i32* %16
br label %262
244: ; preds = %235
br label %245
245: ; preds = %244, %214
%246 = load i32, i32* %33
%247 = call i64 @write(i32 %246, %struct.uinput_user_dev* %32, i32 72)
%248 = icmp slt i64 %247, 0
br i1 %248, label %249, label %252
249: ; preds = %245
%250 = load i32, i32* %33
%251 = call i32 @close(i32 %250)
store i32 -11, i32* %16
br label %262
252: ; preds = %245
%253 = load i32, i32* %33
%254 = load i32, i32* @UI_DEV_CREATE
%255 = call i64 (i32, i32, ...) @ioctl(i32 %253, i32 %254)
%256 = icmp slt i64 %255, 0
br i1 %256, label %257, label %260
257: ; preds = %252
%258 = load i32, i32* %33
%259 = call i32 @close(i32 %258)
store i32 -12, i32* %16
br label %262
260: ; preds = %252
%261 = load i32, i32* %33
store i32 %261, i32* %16
br label %262
262: ; preds = %260, %257, %249, %241, %232, %223, %207, %189, %121, %103, %87, %69, %42
%263 = load i32, i32* %16
ret i32 %263
}

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