#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */
typedef struct TYPE_2__ TYPE_1__;

/* Type definitions */
typedef int /*<<< orphan*/ uidev;
struct TYPE_2__ {
  int vendor;
  int product;
  int version;
  int /*<<< orphan*/ bustype;
};
struct uinput_user_dev {
  void **absmax;
  scalar_t__ *absmin;
  TYPE_1__ id;
  int /*<<< orphan*/ name;
};

/* Variables and functions */
size_t ABS_X;
size_t ABS_Y;
int /*<<< orphan*/ BTN_TOUCH;
int /*<<< orphan*/ BUS_VIRTUAL;
int /*<<< orphan*/ EV_ABS;
int /*<<< orphan*/ EV_KEY;
int /*<<< orphan*/ EV_REL;
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ REL_HWHEEL;
int /*<<< orphan*/ REL_WHEEL;
int /*<<< orphan*/ UINPUT_MAX_NAME_SIZE;
void *UINT16_MAX;
int /*<<< orphan*/ UI_DEV_CREATE;
int /*<<< orphan*/ UI_SET_ABSBIT;
int /*<<< orphan*/ UI_SET_EVBIT;
int /*<<< orphan*/ UI_SET_KEYBIT;
int /*<<< orphan*/ UI_SET_RELBIT;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
scalar_t__ ioctl(int, int /*<<< orphan*/, ...);
int /*<<< orphan*/ memset(struct uinput_user_dev *, int /*<<< orphan*/, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ snprintf(int /*<<< orphan*/, int /*<<< orphan*/, char *);
scalar_t__ write(int, struct uinput_user_dev *, int);
void init_device(int fd) {
  struct uinput_user_dev uidev;
  if (ioctl(fd, UI_SET_EVBIT, EV_REL) < 0) {
    perror("error: ioctl UI_SET_RELBIT EV_REL");
    exit(EXIT_FAILURE);
  };
  if (ioctl(fd, UI_SET_RELBIT, REL_WHEEL) < 0) {
    perror("error: ioctl UI_SET_RELBIT REL_WHEEL");
    exit(EXIT_FAILURE);
  };
  if (ioctl(fd, UI_SET_RELBIT, REL_HWHEEL) < 0) {
    perror("error: ioctl UI_SET_RELBIT REL_HWHEEL");
    exit(EXIT_FAILURE);
  };
  if (ioctl(fd, UI_SET_EVBIT, EV_KEY) < 0) {
    perror("error: ioctl UI_SET_EVBIT EV_KEY");
    exit(EXIT_FAILURE);
  };
  if (ioctl(fd, UI_SET_KEYBIT, BTN_TOUCH) < 0) {
    perror("error: ioctl UI_SET_KEYBIT");
    exit(EXIT_FAILURE);
  };
  if (ioctl(fd, UI_SET_EVBIT, EV_ABS) < 0) {
    perror("error: ioctl UI_SET_EVBIT EV_ABS");
    exit(EXIT_FAILURE);
  };
  if (ioctl(fd, UI_SET_ABSBIT, ABS_X) < 0) {
    perror("error: ioctl UI_SETEVBIT ABS_X");
    exit(EXIT_FAILURE);
  };
  if (ioctl(fd, UI_SET_ABSBIT, ABS_Y) < 0) {
    perror("error: ioctl UI_SETEVBIT ABS_Y");
    exit(EXIT_FAILURE);
  };
  memset(&uidev, 0, sizeof(uidev));
  snprintf(uidev.name, UINPUT_MAX_NAME_SIZE, "ScrollSkt");
  uidev.id.bustype = BUS_VIRTUAL;
  uidev.id.vendor = 0x1;
  uidev.id.product = 0x1;
  uidev.id.version = 1;
  uidev.absmin[ABS_X] = 0;
  uidev.absmax[ABS_X] = UINT16_MAX;
  uidev.absmin[ABS_Y] = 0;
  uidev.absmax[ABS_Y] = UINT16_MAX;
  if (write(fd, &uidev, sizeof(uidev)) < 0) {
    perror("error: write");
    exit(EXIT_FAILURE);
  };
  if (ioctl(fd, UI_DEV_CREATE) < 0) {
    perror("error: ioctl");
    exit(EXIT_FAILURE);
  };
}


x86 assembly (clang, -O0):
<init_device>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2e33(%rip),%rax
mov    (%rax),%esi
mov    0x2e32(%rip),%rax
mov    (%rax),%edx
mov    $0x0,%al
call   1060 <ioctl@plt>
cmp    $0x0,%rax
jge    11ab <init_device+0x4b>
lea    0xe68(%rip),%rdi
call   1070 <perror@plt>
mov    0x2dd4(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    -0x4(%rbp),%edi
mov    0x2e03(%rip),%rax
mov    (%rax),%esi
mov    0x2e12(%rip),%rax
mov    (%rax),%edx
mov    $0x0,%al
call   1060 <ioctl@plt>
cmp    $0x0,%rax
jge    11eb <init_device+0x8b>
lea    0xe4a(%rip),%rdi
call   1070 <perror@plt>
mov    0x2d94(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    -0x4(%rbp),%edi
mov    0x2dc3(%rip),%rax
mov    (%rax),%esi
mov    0x2d9a(%rip),%rax
mov    (%rax),%edx
mov    $0x0,%al
call   1060 <ioctl@plt>
cmp    $0x0,%rax
jge    122b <init_device+0xcb>
lea    0xe2f(%rip),%rdi
call   1070 <perror@plt>
mov    0x2d54(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    -0x4(%rbp),%edi
mov    0x2d73(%rip),%rax
mov    (%rax),%esi
mov    0x2d82(%rip),%rax
mov    (%rax),%edx
mov    $0x0,%al
call   1060 <ioctl@plt>
cmp    $0x0,%rax
jge    126b <init_device+0x10b>
lea    0xe15(%rip),%rdi
call   1070 <perror@plt>
mov    0x2d14(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    -0x4(%rbp),%edi
mov    0x2d0b(%rip),%rax
mov    (%rax),%esi
mov    0x2d4a(%rip),%rax
mov    (%rax),%edx
mov    $0x0,%al
call   1060 <ioctl@plt>
cmp    $0x0,%rax
jge    12ab <init_device+0x14b>
lea    0xdf6(%rip),%rdi
call   1070 <perror@plt>
mov    0x2cd4(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    -0x4(%rbp),%edi
mov    0x2cf3(%rip),%rax
mov    (%rax),%esi
mov    0x2c9a(%rip),%rax
mov    (%rax),%edx
mov    $0x0,%al
call   1060 <ioctl@plt>
cmp    $0x0,%rax
jge    12eb <init_device+0x18b>
lea    0xdd1(%rip),%rdi
call   1070 <perror@plt>
mov    0x2c94(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    -0x4(%rbp),%edi
mov    0x2c6b(%rip),%rax
mov    (%rax),%esi
mov    0x2c8a(%rip),%rax
mov    (%rax),%rdx
mov    $0x0,%al
call   1060 <ioctl@plt>
cmp    $0x0,%rax
jge    132c <init_device+0x1cc>
lea    0xdb1(%rip),%rdi
call   1070 <perror@plt>
mov    0x2c53(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    -0x4(%rbp),%edi
mov    0x2c2a(%rip),%rax
mov    (%rax),%esi
mov    0x2cb9(%rip),%rax
mov    (%rax),%rdx
mov    $0x0,%al
call   1060 <ioctl@plt>
cmp    $0x0,%rax
jge    136d <init_device+0x20d>
lea    0xd8f(%rip),%rdi
call   1070 <perror@plt>
mov    0x2c12(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1050 <memset@plt>
mov    -0x10(%rbp),%edi
mov    0x2c19(%rip),%rax
mov    (%rax),%esi
lea    0xd78(%rip),%rdx
call   1040 <snprintf@plt>
mov    0x2c3c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
movl   $0x1,-0x20(%rbp)
movl   $0x1,-0x1c(%rbp)
movl   $0x1,-0x18(%rbp)
mov    -0x28(%rbp),%rax
mov    0x2bc7(%rip),%rcx
mov    (%rcx),%rcx
movq   $0x0,(%rax,%rcx,8)
mov    0x2b9d(%rip),%rax
mov    (%rax),%rdx
mov    -0x30(%rbp),%rax
mov    0x2ba7(%rip),%rcx
mov    (%rcx),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x28(%rbp),%rax
mov    0x2c05(%rip),%rcx
mov    (%rcx),%rcx
movq   $0x0,(%rax,%rcx,8)
mov    0x2b6b(%rip),%rax
mov    (%rax),%rdx
mov    -0x30(%rbp),%rax
mov    0x2be5(%rip),%rcx
mov    (%rcx),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x4(%rbp),%edi
lea    -0x30(%rbp),%rsi
mov    $0x28,%edx
call   1030 <write@plt>
cmp    $0x0,%rax
jge    144f <init_device+0x2ef>
lea    0xcd6(%rip),%rdi
call   1070 <perror@plt>
mov    0x2b30(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    -0x4(%rbp),%edi
mov    0x2b97(%rip),%rax
mov    (%rax),%esi
mov    $0x0,%al
call   1060 <ioctl@plt>
cmp    $0x0,%rax
jge    1486 <init_device+0x326>
lea    0xcac(%rip),%rdi
call   1070 <perror@plt>
mov    0x2af9(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<init_device>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %edi,%ebx
mov    0x2e34(%rip),%r14
mov    (%r14),%esi
mov    0x2e32(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
call   1060 <ioctl@plt>
test   %rax,%rax
js     1344 <init_device+0x1e4>
mov    0x2e21(%rip),%r15
mov    (%r15),%esi
mov    0x2e2f(%rip),%rax
mov    (%rax),%edx
mov    %ebx,%edi
xor    %eax,%eax
call   1060 <ioctl@plt>
test   %rax,%rax
js     134d <init_device+0x1ed>
mov    (%r15),%esi
mov    0x2dd9(%rip),%rax
mov    (%rax),%edx
mov    %ebx,%edi
xor    %eax,%eax
call   1060 <ioctl@plt>
test   %rax,%rax
js     1356 <init_device+0x1f6>
mov    (%r14),%esi
mov    0x2de3(%rip),%rax
mov    (%rax),%edx
mov    %ebx,%edi
xor    %eax,%eax
call   1060 <ioctl@plt>
test   %rax,%rax
js     135f <init_device+0x1ff>
mov    0x2d88(%rip),%rax
mov    (%rax),%esi
mov    0x2dc7(%rip),%rax
mov    (%rax),%edx
mov    %ebx,%edi
xor    %eax,%eax
call   1060 <ioctl@plt>
test   %rax,%rax
js     1368 <init_device+0x208>
mov    (%r14),%esi
mov    0x2d39(%rip),%rax
mov    (%rax),%edx
mov    %ebx,%edi
xor    %eax,%eax
call   1060 <ioctl@plt>
test   %rax,%rax
js     1371 <init_device+0x211>
mov    0x2d26(%rip),%r14
mov    (%r14),%esi
mov    0x2d44(%rip),%r15
mov    (%r15),%rdx
mov    %ebx,%edi
xor    %eax,%eax
call   1060 <ioctl@plt>
test   %rax,%rax
js     137a <init_device+0x21a>
mov    (%r14),%esi
mov    0x2d95(%rip),%r12
mov    (%r12),%rdx
mov    %ebx,%edi
xor    %eax,%eax
call   1060 <ioctl@plt>
test   %rax,%rax
js     1383 <init_device+0x223>
mov    %rsp,%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1050 <memset@plt>
mov    0x20(%rsp),%edi
mov    0x2d0a(%rip),%rax
mov    (%rax),%esi
lea    0xe69(%rip),%rdx
call   1040 <snprintf@plt>
mov    0x2d2d(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x1c(%rsp)
movabs $0x100000001,%rax
mov    %rax,0x10(%rsp)
movl   $0x1,0x18(%rsp)
mov    0x8(%rsp),%rax
mov    (%r15),%rcx
movq   $0x0,(%rax,%rcx,8)
mov    0x2c91(%rip),%rax
mov    (%rax),%rcx
mov    (%rsp),%rdx
mov    (%r15),%rsi
mov    %rcx,(%rdx,%rsi,8)
mov    0x8(%rsp),%rcx
mov    (%r12),%rdx
movq   $0x0,(%rcx,%rdx,8)
mov    (%rax),%rax
mov    (%rsp),%rcx
mov    (%r12),%rdx
mov    %rax,(%rcx,%rdx,8)
mov    %ebx,%edi
mov    %r14,%rsi
mov    $0x28,%edx
call   1030 <write@plt>
test   %rax,%rax
js     138c <init_device+0x22c>
mov    0x2cc8(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
xor    %eax,%eax
call   1060 <ioctl@plt>
test   %rax,%rax
js     1395 <init_device+0x235>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
lea    0xcb5(%rip),%rdi
jmp    139c <init_device+0x23c>
lea    0xcce(%rip),%rdi
jmp    139c <init_device+0x23c>
lea    0xcea(%rip),%rdi
jmp    139c <init_device+0x23c>
lea    0xd07(%rip),%rdi
jmp    139c <init_device+0x23c>
lea    0xd1f(%rip),%rdi
jmp    139c <init_device+0x23c>
lea    0xd31(%rip),%rdi
jmp    139c <init_device+0x23c>
lea    0xd49(%rip),%rdi
jmp    139c <init_device+0x23c>
lea    0xd5f(%rip),%rdi
jmp    139c <init_device+0x23c>
lea    0xd7f(%rip),%rdi
jmp    139c <init_device+0x23c>
lea    0xd83(%rip),%rdi
call   1070 <perror@plt>
mov    0x2bd0(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>

LLVM IR (-O0):
%struct.uinput_user_dev = type { i8**, i64*, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32, i32, i32, i32 }
@UI_SET_EVBIT = global i32 0
@EV_REL = global i32 0
@.str = [34 x i8] c"error: ioctl UI_SET_RELBIT EV_REL\00"
@EXIT_FAILURE = global i32 0
@UI_SET_RELBIT = global i32 0
@REL_WHEEL = global i32 0
@.str.1 = [37 x i8] c"error: ioctl UI_SET_RELBIT REL_WHEEL\00"
@REL_HWHEEL = global i32 0
@.str.2 = [38 x i8] c"error: ioctl UI_SET_RELBIT REL_HWHEEL\00"
@EV_KEY = global i32 0
@.str.3 = [33 x i8] c"error: ioctl UI_SET_EVBIT EV_KEY\00"
@UI_SET_KEYBIT = global i32 0
@BTN_TOUCH = global i32 0
@.str.4 = [27 x i8] c"error: ioctl UI_SET_KEYBIT\00"
@EV_ABS = global i32 0
@.str.5 = [33 x i8] c"error: ioctl UI_SET_EVBIT EV_ABS\00"
@UI_SET_ABSBIT = global i32 0
@ABS_X = global i64 0
@.str.6 = [31 x i8] c"error: ioctl UI_SETEVBIT ABS_X\00"
@ABS_Y = global i64 0
@.str.7 = [31 x i8] c"error: ioctl UI_SETEVBIT ABS_Y\00"
@UINPUT_MAX_NAME_SIZE = global i32 0
@.str.8 = [10 x i8] c"ScrollSkt\00"
@BUS_VIRTUAL = global i32 0
@UINT16_MAX = global i8* null
@.str.9 = [13 x i8] c"error: write\00"
@UI_DEV_CREATE = global i32 0
@.str.10 = [13 x i8] c"error: ioctl\00"
define void @init_device(i32 %0) {
%2 = alloca i32
%3 = alloca %struct.uinput_user_dev
store i32 %0, i32* %2
%4 = load i32, i32* %2
%5 = load i32, i32* @UI_SET_EVBIT
%6 = load i32, i32* @EV_REL
%7 = call i64 (i32, i32, ...) @ioctl(i32 %4, i32 %5, i32 %6)
%8 = icmp slt i64 %7, 0
br i1 %8, label %9, label %13
9: ; preds = %1
%10 = call i32 @perror(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%11 = load i32, i32* @EXIT_FAILURE
%12 = call i32 @exit(i32 %11)
unreachable
13: ; preds = %1
%14 = load i32, i32* %2
%15 = load i32, i32* @UI_SET_RELBIT
%16 = load i32, i32* @REL_WHEEL
%17 = call i64 (i32, i32, ...) @ioctl(i32 %14, i32 %15, i32 %16)
%18 = icmp slt i64 %17, 0
br i1 %18, label %19, label %23
19: ; preds = %13
%20 = call i32 @perror(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0))
%21 = load i32, i32* @EXIT_FAILURE
%22 = call i32 @exit(i32 %21)
unreachable
23: ; preds = %13
%24 = load i32, i32* %2
%25 = load i32, i32* @UI_SET_RELBIT
%26 = load i32, i32* @REL_HWHEEL
%27 = call i64 (i32, i32, ...) @ioctl(i32 %24, i32 %25, i32 %26)
%28 = icmp slt i64 %27, 0
br i1 %28, label %29, label %33
29: ; preds = %23
%30 = call i32 @perror(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0))
%31 = load i32, i32* @EXIT_FAILURE
%32 = call i32 @exit(i32 %31)
unreachable
33: ; preds = %23
%34 = load i32, i32* %2
%35 = load i32, i32* @UI_SET_EVBIT
%36 = load i32, i32* @EV_KEY
%37 = call i64 (i32, i32, ...) @ioctl(i32 %34, i32 %35, i32 %36)
%38 = icmp slt i64 %37, 0
br i1 %38, label %39, label %43
39: ; preds = %33
%40 = call i32 @perror(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0))
%41 = load i32, i32* @EXIT_FAILURE
%42 = call i32 @exit(i32 %41)
unreachable
43: ; preds = %33
%44 = load i32, i32* %2
%45 = load i32, i32* @UI_SET_KEYBIT
%46 = load i32, i32* @BTN_TOUCH
%47 = call i64 (i32, i32, ...) @ioctl(i32 %44, i32 %45, i32 %46)
%48 = icmp slt i64 %47, 0
br i1 %48, label %49, label %53
49: ; preds = %43
%50 = call i32 @perror(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0))
%51 = load i32, i32* @EXIT_FAILURE
%52 = call i32 @exit(i32 %51)
unreachable
53: ; preds = %43
%54 = load i32, i32* %2
%55 = load i32, i32* @UI_SET_EVBIT
%56 = load i32, i32* @EV_ABS
%57 = call i64 (i32, i32, ...) @ioctl(i32 %54, i32 %55, i32 %56)
%58 = icmp slt i64 %57, 0
br i1 %58, label %59, label %63
59: ; preds = %53
%60 = call i32 @perror(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0))
%61 = load i32, i32* @EXIT_FAILURE
%62 = call i32 @exit(i32 %61)
unreachable
63: ; preds = %53
%64 = load i32, i32* %2
%65 = load i32, i32* @UI_SET_ABSBIT
%66 = load i64, i64* @ABS_X
%67 = call i64 (i32, i32, ...) @ioctl(i32 %64, i32 %65, i64 %66)
%68 = icmp slt i64 %67, 0
br i1 %68, label %69, label %73
69: ; preds = %63
%70 = call i32 @perror(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.6, i64 0, i64 0))
%71 = load i32, i32* @EXIT_FAILURE
%72 = call i32 @exit(i32 %71)
unreachable
73: ; preds = %63
%74 = load i32, i32* %2
%75 = load i32, i32* @UI_SET_ABSBIT
%76 = load i64, i64* @ABS_Y
%77 = call i64 (i32, i32, ...) @ioctl(i32 %74, i32 %75, i64 %76)
%78 = icmp slt i64 %77, 0
br i1 %78, label %79, label %83
79: ; preds = %73
%80 = call i32 @perror(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.7, i64 0, i64 0))
%81 = load i32, i32* @EXIT_FAILURE
%82 = call i32 @exit(i32 %81)
unreachable
83: ; preds = %73
%84 = call i32 @memset(%struct.uinput_user_dev* %3, i32 0, i32 40)
%85 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %3, i32 0, i32 3
%86 = load i32, i32* %85
%87 = load i32, i32* @UINPUT_MAX_NAME_SIZE
%88 = call i32 @snprintf(i32 %86, i32 %87, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0))
%89 = load i32, i32* @BUS_VIRTUAL
%90 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %3, i32 0, i32 2
%91 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %90, i32 0, i32 3
store i32 %89, i32* %91
%92 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %3, i32 0, i32 2
%93 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %92, i32 0, i32 0
store i32 1, i32* %93
%94 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %3, i32 0, i32 2
%95 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %94, i32 0, i32 1
store i32 1, i32* %95
%96 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %3, i32 0, i32 2
%97 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %96, i32 0, i32 2
store i32 1, i32* %97
%98 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %3, i32 0, i32 1
%99 = load i64*, i64** %98
%100 = load i64, i64* @ABS_X
%101 = getelementptr inbounds i64, i64* %99, i64 %100
store i64 0, i64* %101
%102 = load i8*, i8** @UINT16_MAX
%103 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %3, i32 0, i32 0
%104 = load i8**, i8*** %103
%105 = load i64, i64* @ABS_X
%106 = getelementptr inbounds i8*, i8** %104, i64 %105
store i8* %102, i8** %106
%107 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %3, i32 0, i32 1
%108 = load i64*, i64** %107
%109 = load i64, i64* @ABS_Y
%110 = getelementptr inbounds i64, i64* %108, i64 %109
store i64 0, i64* %110
%111 = load i8*, i8** @UINT16_MAX
%112 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %3, i32 0, i32 0
%113 = load i8**, i8*** %112
%114 = load i64, i64* @ABS_Y
%115 = getelementptr inbounds i8*, i8** %113, i64 %114
store i8* %111, i8** %115
%116 = load i32, i32* %2
%117 = call i64 @write(i32 %116, %struct.uinput_user_dev* %3, i32 40)
%118 = icmp slt i64 %117, 0
br i1 %118, label %119, label %123
119: ; preds = %83
%120 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.9, i64 0, i64 0))
%121 = load i32, i32* @EXIT_FAILURE
%122 = call i32 @exit(i32 %121)
unreachable
123: ; preds = %83
%124 = load i32, i32* %2
%125 = load i32, i32* @UI_DEV_CREATE
%126 = call i64 (i32, i32, ...) @ioctl(i32 %124, i32 %125)
%127 = icmp slt i64 %126, 0
br i1 %127, label %128, label %132
128: ; preds = %123
%129 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.10, i64 0, i64 0))
%130 = load i32, i32* @EXIT_FAILURE
%131 = call i32 @exit(i32 %130)
unreachable
132: ; preds = %123
ret void
}

LLVM IR (-O2):
%struct.uinput_user_dev = type { i8**, i64*, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32, i32, i32, i32 }
@UI_SET_EVBIT = global i32 0
@EV_REL = global i32 0
@.str = [34 x i8] c"error: ioctl UI_SET_RELBIT EV_REL\00"
@EXIT_FAILURE = global i32 0
@UI_SET_RELBIT = global i32 0
@REL_WHEEL = global i32 0
@.str.1 = [37 x i8] c"error: ioctl UI_SET_RELBIT REL_WHEEL\00"
@REL_HWHEEL = global i32 0
@.str.2 = [38 x i8] c"error: ioctl UI_SET_RELBIT REL_HWHEEL\00"
@EV_KEY = global i32 0
@.str.3 = [33 x i8] c"error: ioctl UI_SET_EVBIT EV_KEY\00"
@UI_SET_KEYBIT = global i32 0
@BTN_TOUCH = global i32 0
@.str.4 = [27 x i8] c"error: ioctl UI_SET_KEYBIT\00"
@EV_ABS = global i32 0
@.str.5 = [33 x i8] c"error: ioctl UI_SET_EVBIT EV_ABS\00"
@UI_SET_ABSBIT = global i32 0
@ABS_X = global i64 0
@.str.6 = [31 x i8] c"error: ioctl UI_SETEVBIT ABS_X\00"
@ABS_Y = global i64 0
@.str.7 = [31 x i8] c"error: ioctl UI_SETEVBIT ABS_Y\00"
@UINPUT_MAX_NAME_SIZE = global i32 0
@.str.8 = [10 x i8] c"ScrollSkt\00"
@BUS_VIRTUAL = global i32 0
@UINT16_MAX = global i8* null
@.str.9 = [13 x i8] c"error: write\00"
@UI_DEV_CREATE = global i32 0
@.str.10 = [13 x i8] c"error: ioctl\00"
define void @init_device(i32 %0) {
%2 = alloca %struct.uinput_user_dev
%3 = bitcast %struct.uinput_user_dev* %2 to i8*
%4 = load i32, i32* @UI_SET_EVBIT
%5 = load i32, i32* @EV_REL
%6 = tail call i64 (i32, i32, ...) @ioctl(i32 %0, i32 %4, i32 %5)
%7 = icmp slt i64 %6, 0
br i1 %7, label %8, label %12
8: ; preds = %1
%9 = tail call i32 @perror(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%10 = load i32, i32* @EXIT_FAILURE
%11 = tail call i32 @exit(i32 %10)
unreachable
12: ; preds = %1
%13 = load i32, i32* @UI_SET_RELBIT
%14 = load i32, i32* @REL_WHEEL
%15 = tail call i64 (i32, i32, ...) @ioctl(i32 %0, i32 %13, i32 %14)
%16 = icmp slt i64 %15, 0
br i1 %16, label %17, label %21
17: ; preds = %12
%18 = tail call i32 @perror(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0))
%19 = load i32, i32* @EXIT_FAILURE
%20 = tail call i32 @exit(i32 %19)
unreachable
21: ; preds = %12
%22 = load i32, i32* @UI_SET_RELBIT
%23 = load i32, i32* @REL_HWHEEL
%24 = tail call i64 (i32, i32, ...) @ioctl(i32 %0, i32 %22, i32 %23)
%25 = icmp slt i64 %24, 0
br i1 %25, label %26, label %30
26: ; preds = %21
%27 = tail call i32 @perror(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0))
%28 = load i32, i32* @EXIT_FAILURE
%29 = tail call i32 @exit(i32 %28)
unreachable
30: ; preds = %21
%31 = load i32, i32* @UI_SET_EVBIT
%32 = load i32, i32* @EV_KEY
%33 = tail call i64 (i32, i32, ...) @ioctl(i32 %0, i32 %31, i32 %32)
%34 = icmp slt i64 %33, 0
br i1 %34, label %35, label %39
35: ; preds = %30
%36 = tail call i32 @perror(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0))
%37 = load i32, i32* @EXIT_FAILURE
%38 = tail call i32 @exit(i32 %37)
unreachable
39: ; preds = %30
%40 = load i32, i32* @UI_SET_KEYBIT
%41 = load i32, i32* @BTN_TOUCH
%42 = tail call i64 (i32, i32, ...) @ioctl(i32 %0, i32 %40, i32 %41)
%43 = icmp slt i64 %42, 0
br i1 %43, label %44, label %48
44: ; preds = %39
%45 = tail call i32 @perror(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0))
%46 = load i32, i32* @EXIT_FAILURE
%47 = tail call i32 @exit(i32 %46)
unreachable
48: ; preds = %39
%49 = load i32, i32* @UI_SET_EVBIT
%50 = load i32, i32* @EV_ABS
%51 = tail call i64 (i32, i32, ...) @ioctl(i32 %0, i32 %49, i32 %50)
%52 = icmp slt i64 %51, 0
br i1 %52, label %53, label %57
53: ; preds = %48
%54 = tail call i32 @perror(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0))
%55 = load i32, i32* @EXIT_FAILURE
%56 = tail call i32 @exit(i32 %55)
unreachable
57: ; preds = %48
%58 = load i32, i32* @UI_SET_ABSBIT
%59 = load i64, i64* @ABS_X
%60 = tail call i64 (i32, i32, ...) @ioctl(i32 %0, i32 %58, i64 %59)
%61 = icmp slt i64 %60, 0
br i1 %61, label %62, label %66
62: ; preds = %57
%63 = tail call i32 @perror(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.6, i64 0, i64 0))
%64 = load i32, i32* @EXIT_FAILURE
%65 = tail call i32 @exit(i32 %64)
unreachable
66: ; preds = %57
%67 = load i32, i32* @UI_SET_ABSBIT
%68 = load i64, i64* @ABS_Y
%69 = tail call i64 (i32, i32, ...) @ioctl(i32 %0, i32 %67, i64 %68)
%70 = icmp slt i64 %69, 0
br i1 %70, label %71, label %75
71: ; preds = %66
%72 = tail call i32 @perror(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.7, i64 0, i64 0))
%73 = load i32, i32* @EXIT_FAILURE
%74 = tail call i32 @exit(i32 %73)
unreachable
75: ; preds = %66
%76 = call i32 @memset(%struct.uinput_user_dev* %2, i32 0, i32 40)
%77 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %2, i64 0, i32 3
%78 = load i32, i32* %77
%79 = load i32, i32* @UINPUT_MAX_NAME_SIZE
%80 = call i32 @snprintf(i32 %78, i32 %79, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0))
%81 = load i32, i32* @BUS_VIRTUAL
%82 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %2, i64 0, i32 2, i32 3
store i32 %81, i32* %82
%83 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %2, i64 0, i32 2, i32 0
store i32 1, i32* %83
%84 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %2, i64 0, i32 2, i32 1
store i32 1, i32* %84
%85 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %2, i64 0, i32 2, i32 2
store i32 1, i32* %85
%86 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %2, i64 0, i32 1
%87 = load i64*, i64** %86
%88 = load i64, i64* @ABS_X
%89 = getelementptr inbounds i64, i64* %87, i64 %88
store i64 0, i64* %89
%90 = load i8*, i8** @UINT16_MAX
%91 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %2, i64 0, i32 0
%92 = load i8**, i8*** %91
%93 = load i64, i64* @ABS_X
%94 = getelementptr inbounds i8*, i8** %92, i64 %93
store i8* %90, i8** %94
%95 = load i64*, i64** %86
%96 = load i64, i64* @ABS_Y
%97 = getelementptr inbounds i64, i64* %95, i64 %96
store i64 0, i64* %97
%98 = load i8*, i8** @UINT16_MAX
%99 = load i8**, i8*** %91
%100 = load i64, i64* @ABS_Y
%101 = getelementptr inbounds i8*, i8** %99, i64 %100
store i8* %98, i8** %101
%102 = call i64 @write(i32 %0, %struct.uinput_user_dev* %2, i32 40)
%103 = icmp slt i64 %102, 0
br i1 %103, label %104, label %108
104: ; preds = %75
%105 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.9, i64 0, i64 0))
%106 = load i32, i32* @EXIT_FAILURE
%107 = call i32 @exit(i32 %106)
unreachable
108: ; preds = %75
%109 = load i32, i32* @UI_DEV_CREATE
%110 = call i64 (i32, i32, ...) @ioctl(i32 %0, i32 %109)
%111 = icmp slt i64 %110, 0
br i1 %111, label %112, label %116
112: ; preds = %108
%113 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.10, i64 0, i64 0))
%114 = load i32, i32* @EXIT_FAILURE
%115 = call i32 @exit(i32 %114)
unreachable
116: ; preds = %108
ret void
}