#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 {
  int *absmax;
  scalar_t__ *absmin;
  TYPE_1__ id;
  int /*<<< orphan*/ name;
};

/* Variables and functions */
size_t ABS_PRESSURE;
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_SYN;
int /*<<< orphan*/ EXIT_FAILURE;
int SHRT_MAX;
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*/ 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_SYN) < 0) {
    perror("error: ioctl UI_SET_EVBIT EV_SYN");
    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);
  };
  if (ioctl(fd, UI_SET_ABSBIT, ABS_PRESSURE) < 0) {
    perror("error: ioctl UI_SETEVBIT ABS_PRESSURE");
    exit(EXIT_FAILURE);
  };
  memset(&uidev, 0, sizeof(uidev));
  snprintf(uidev.name, UINPUT_MAX_NAME_SIZE, "Network Tablet");
  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] = SHRT_MAX;
  uidev.absmin[ABS_Y] = 0;
  uidev.absmax[ABS_Y] = SHRT_MAX;
  uidev.absmin[ABS_PRESSURE] = 0;
  uidev.absmax[ABS_PRESSURE] = SHRT_MAX / 2;
  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    0x2e43(%rip),%rax
mov    (%rax),%esi
mov    0x2e62(%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    0x2ddc(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    -0x4(%rbp),%edi
mov    0x2e03(%rip),%rax
mov    (%rax),%esi
mov    0x2e02(%rip),%rax
mov    (%rax),%edx
mov    $0x0,%al
call   1060 <ioctl@plt>
cmp    $0x0,%rax
jge    11eb <init_device+0x8b>
lea    0xe49(%rip),%rdi
call   1070 <perror@plt>
mov    0x2d9c(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    -0x4(%rbp),%edi
mov    0x2da3(%rip),%rax
mov    (%rax),%esi
mov    0x2dca(%rip),%rax
mov    (%rax),%edx
mov    $0x0,%al
call   1060 <ioctl@plt>
cmp    $0x0,%rax
jge    122b <init_device+0xcb>
lea    0xe2a(%rip),%rdi
call   1070 <perror@plt>
mov    0x2d5c(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    -0x4(%rbp),%edi
mov    0x2d83(%rip),%rax
mov    (%rax),%esi
mov    0x2d2a(%rip),%rax
mov    (%rax),%edx
mov    $0x0,%al
call   1060 <ioctl@plt>
cmp    $0x0,%rax
jge    126b <init_device+0x10b>
lea    0xe05(%rip),%rdi
call   1070 <perror@plt>
mov    0x2d1c(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    -0x4(%rbp),%edi
mov    0x2cfb(%rip),%rax
mov    (%rax),%esi
mov    0x2d22(%rip),%rax
mov    (%rax),%rdx
mov    $0x0,%al
call   1060 <ioctl@plt>
cmp    $0x0,%rax
jge    12ac <init_device+0x14c>
lea    0xde5(%rip),%rdi
call   1070 <perror@plt>
mov    0x2cdb(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    -0x4(%rbp),%edi
mov    0x2cba(%rip),%rax
mov    (%rax),%esi
mov    0x2d39(%rip),%rax
mov    (%rax),%rdx
mov    $0x0,%al
call   1060 <ioctl@plt>
cmp    $0x0,%rax
jge    12ed <init_device+0x18d>
lea    0xdc3(%rip),%rdi
call   1070 <perror@plt>
mov    0x2c9a(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    -0x4(%rbp),%edi
mov    0x2c79(%rip),%rax
mov    (%rax),%esi
mov    0x2c90(%rip),%rax
mov    (%rax),%rdx
mov    $0x0,%al
call   1060 <ioctl@plt>
cmp    $0x0,%rax
jge    132e <init_device+0x1ce>
lea    0xda1(%rip),%rdi
call   1070 <perror@plt>
mov    0x2c59(%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    0x2c68(%rip),%rax
mov    (%rax),%esi
lea    0xd91(%rip),%rdx
call   1040 <snprintf@plt>
mov    0x2c73(%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    0x2c1e(%rip),%rcx
mov    (%rcx),%rcx
movq   $0x0,(%rax,%rcx,8)
mov    0x2bf4(%rip),%rax
mov    (%rax),%edx
mov    -0x30(%rbp),%rax
mov    0x2bff(%rip),%rcx
mov    (%rcx),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x28(%rbp),%rax
mov    0x2c46(%rip),%rcx
mov    (%rcx),%rcx
movq   $0x0,(%rax,%rcx,8)
mov    0x2bc4(%rip),%rax
mov    (%rax),%edx
mov    -0x30(%rbp),%rax
mov    0x2c27(%rip),%rcx
mov    (%rcx),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x28(%rbp),%rax
mov    0x2bae(%rip),%rcx
mov    (%rcx),%rcx
movq   $0x0,(%rax,%rcx,8)
mov    0x2b94(%rip),%rax
mov    (%rax),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%edx
mov    -0x30(%rbp),%rax
mov    0x2b85(%rip),%rcx
mov    (%rcx),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x4(%rbp),%edi
lea    -0x30(%rbp),%rsi
mov    $0x28,%edx
call   1030 <write@plt>
cmp    $0x0,%rax
jge    1446 <init_device+0x2e6>
lea    0xcbe(%rip),%rdi
call   1070 <perror@plt>
mov    0x2b41(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    -0x4(%rbp),%edi
mov    0x2ba0(%rip),%rax
mov    (%rax),%esi
mov    $0x0,%al
call   1060 <ioctl@plt>
cmp    $0x0,%rax
jge    147d <init_device+0x31d>
lea    0xc94(%rip),%rdi
call   1070 <perror@plt>
mov    0x2b0a(%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   %r13
push   %r12
push   %rbx
sub    $0x30,%rsp
mov    %edi,%ebx
mov    0x2e42(%rip),%r14
mov    (%r14),%esi
mov    0x2e60(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
call   1060 <ioctl@plt>
test   %rax,%rax
js     1339 <init_device+0x1d9>
mov    (%r14),%esi
mov    0x2e24(%rip),%rax
mov    (%rax),%edx
mov    %ebx,%edi
xor    %eax,%eax
call   1060 <ioctl@plt>
test   %rax,%rax
js     1342 <init_device+0x1e2>
mov    0x2de1(%rip),%rax
mov    (%rax),%esi
mov    0x2e08(%rip),%rax
mov    (%rax),%edx
mov    %ebx,%edi
xor    %eax,%eax
call   1060 <ioctl@plt>
test   %rax,%rax
js     134b <init_device+0x1eb>
mov    (%r14),%esi
mov    0x2d8a(%rip),%rax
mov    (%rax),%edx
mov    %ebx,%edi
xor    %eax,%eax
call   1060 <ioctl@plt>
test   %rax,%rax
js     1354 <init_device+0x1f4>
mov    0x2d77(%rip),%r14
mov    (%r14),%esi
mov    0x2d9d(%rip),%r15
mov    (%r15),%rdx
mov    %ebx,%edi
xor    %eax,%eax
call   1060 <ioctl@plt>
test   %rax,%rax
js     135d <init_device+0x1fd>
mov    (%r14),%esi
mov    0x2dd6(%rip),%r12
mov    (%r12),%rdx
mov    %ebx,%edi
xor    %eax,%eax
call   1060 <ioctl@plt>
test   %rax,%rax
js     1366 <init_device+0x206>
mov    (%r14),%esi
mov    0x2d4e(%rip),%r13
mov    0x0(%r13),%rdx
mov    %ebx,%edi
xor    %eax,%eax
call   1060 <ioctl@plt>
test   %rax,%rax
js     136f <init_device+0x20f>
lea    0x8(%rsp),%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1050 <memset@plt>
mov    0x28(%rsp),%edi
mov    0x2d39(%rip),%rax
mov    (%rax),%esi
lea    0xe62(%rip),%rdx
call   1040 <snprintf@plt>
mov    0x2d44(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x24(%rsp)
movabs $0x100000001,%rax
mov    %rax,0x18(%rsp)
movl   $0x1,0x20(%rsp)
mov    0x10(%rsp),%rax
mov    (%r15),%rcx
movq   $0x0,(%rax,%rcx,8)
mov    0x2cc8(%rip),%rcx
mov    (%rcx),%edx
mov    0x8(%rsp),%rsi
mov    (%r15),%rdi
mov    %edx,(%rsi,%rdi,4)
mov    (%r12),%rdx
movq   $0x0,(%rax,%rdx,8)
mov    (%rcx),%edx
mov    (%r12),%rdi
mov    %edx,(%rsi,%rdi,4)
mov    0x0(%r13),%rdx
movq   $0x0,(%rax,%rdx,8)
mov    (%rcx),%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
add    %eax,%ecx
sar    %ecx
mov    0x0(%r13),%rax
mov    %ecx,(%rsi,%rax,4)
mov    %ebx,%edi
mov    %r14,%rsi
mov    $0x28,%edx
call   1030 <write@plt>
test   %rax,%rax
js     1378 <init_device+0x218>
mov    0x2cd5(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
xor    %eax,%eax
call   1060 <ioctl@plt>
test   %rax,%rax
js     1381 <init_device+0x221>
add    $0x30,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
lea    0xcc0(%rip),%rdi
jmp    1388 <init_device+0x228>
lea    0xcd8(%rip),%rdi
jmp    1388 <init_device+0x228>
lea    0xcf0(%rip),%rdi
jmp    1388 <init_device+0x228>
lea    0xd02(%rip),%rdi
jmp    1388 <init_device+0x228>
lea    0xd1a(%rip),%rdi
jmp    1388 <init_device+0x228>
lea    0xd30(%rip),%rdi
jmp    1388 <init_device+0x228>
lea    0xd46(%rip),%rdi
jmp    1388 <init_device+0x228>
lea    0xd72(%rip),%rdi
jmp    1388 <init_device+0x228>
lea    0xd76(%rip),%rdi
call   1070 <perror@plt>
mov    0x2bec(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>

LLVM IR (-O0):
%struct.uinput_user_dev = type { i32*, i64*, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32, i32, i32, i32 }
@UI_SET_EVBIT = global i32 0
@EV_SYN = global i32 0
@.str = [33 x i8] c"error: ioctl UI_SET_EVBIT EV_SYN\00"
@EXIT_FAILURE = global i32 0
@EV_KEY = global i32 0
@.str.1 = [33 x i8] c"error: ioctl UI_SET_EVBIT EV_KEY\00"
@UI_SET_KEYBIT = global i32 0
@BTN_TOUCH = global i32 0
@.str.2 = [27 x i8] c"error: ioctl UI_SET_KEYBIT\00"
@EV_ABS = global i32 0
@.str.3 = [33 x i8] c"error: ioctl UI_SET_EVBIT EV_ABS\00"
@UI_SET_ABSBIT = global i32 0
@ABS_X = global i64 0
@.str.4 = [31 x i8] c"error: ioctl UI_SETEVBIT ABS_X\00"
@ABS_Y = global i64 0
@.str.5 = [31 x i8] c"error: ioctl UI_SETEVBIT ABS_Y\00"
@ABS_PRESSURE = global i64 0
@.str.6 = [38 x i8] c"error: ioctl UI_SETEVBIT ABS_PRESSURE\00"
@UINPUT_MAX_NAME_SIZE = global i32 0
@.str.7 = [15 x i8] c"Network Tablet\00"
@BUS_VIRTUAL = global i32 0
@SHRT_MAX = global i32 0
@.str.8 = [13 x i8] c"error: write\00"
@UI_DEV_CREATE = global i32 0
@.str.9 = [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_SYN
%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 ([33 x i8], [33 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_EVBIT
%16 = load i32, i32* @EV_KEY
%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 ([33 x i8], [33 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_KEYBIT
%26 = load i32, i32* @BTN_TOUCH
%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 ([27 x i8], [27 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_ABS
%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_ABSBIT
%46 = load i64, i64* @ABS_X
%47 = call i64 (i32, i32, ...) @ioctl(i32 %44, i32 %45, i64 %46)
%48 = icmp slt i64 %47, 0
br i1 %48, label %49, label %53
49: ; preds = %43
%50 = call i32 @perror(i8* getelementptr inbounds ([31 x i8], [31 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_ABSBIT
%56 = load i64, i64* @ABS_Y
%57 = call i64 (i32, i32, ...) @ioctl(i32 %54, i32 %55, i64 %56)
%58 = icmp slt i64 %57, 0
br i1 %58, label %59, label %63
59: ; preds = %53
%60 = call i32 @perror(i8* getelementptr inbounds ([31 x i8], [31 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_PRESSURE
%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 ([38 x i8], [38 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 = call i32 @memset(%struct.uinput_user_dev* %3, i32 0, i32 40)
%75 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %3, i32 0, i32 3
%76 = load i32, i32* %75
%77 = load i32, i32* @UINPUT_MAX_NAME_SIZE
%78 = call i32 @snprintf(i32 %76, i32 %77, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0))
%79 = load i32, i32* @BUS_VIRTUAL
%80 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %3, i32 0, i32 2
%81 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %80, i32 0, i32 3
store i32 %79, i32* %81
%82 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %3, i32 0, i32 2
%83 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %82, i32 0, i32 0
store i32 1, i32* %83
%84 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %3, i32 0, i32 2
%85 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %84, i32 0, i32 1
store i32 1, i32* %85
%86 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %3, i32 0, i32 2
%87 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %86, i32 0, i32 2
store i32 1, i32* %87
%88 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %3, i32 0, i32 1
%89 = load i64*, i64** %88
%90 = load i64, i64* @ABS_X
%91 = getelementptr inbounds i64, i64* %89, i64 %90
store i64 0, i64* %91
%92 = load i32, i32* @SHRT_MAX
%93 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %3, i32 0, i32 0
%94 = load i32*, i32** %93
%95 = load i64, i64* @ABS_X
%96 = getelementptr inbounds i32, i32* %94, i64 %95
store i32 %92, i32* %96
%97 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %3, i32 0, i32 1
%98 = load i64*, i64** %97
%99 = load i64, i64* @ABS_Y
%100 = getelementptr inbounds i64, i64* %98, i64 %99
store i64 0, i64* %100
%101 = load i32, i32* @SHRT_MAX
%102 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %3, i32 0, i32 0
%103 = load i32*, i32** %102
%104 = load i64, i64* @ABS_Y
%105 = getelementptr inbounds i32, i32* %103, i64 %104
store i32 %101, i32* %105
%106 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %3, i32 0, i32 1
%107 = load i64*, i64** %106
%108 = load i64, i64* @ABS_PRESSURE
%109 = getelementptr inbounds i64, i64* %107, i64 %108
store i64 0, i64* %109
%110 = load i32, i32* @SHRT_MAX
%111 = sdiv i32 %110, 2
%112 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %3, i32 0, i32 0
%113 = load i32*, i32** %112
%114 = load i64, i64* @ABS_PRESSURE
%115 = getelementptr inbounds i32, i32* %113, i64 %114
store i32 %111, i32* %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 = %73
%120 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0))
%121 = load i32, i32* @EXIT_FAILURE
%122 = call i32 @exit(i32 %121)
unreachable
123: ; preds = %73
%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.9, 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 { i32*, i64*, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32, i32, i32, i32 }
@UI_SET_EVBIT = global i32 0
@EV_SYN = global i32 0
@.str = [33 x i8] c"error: ioctl UI_SET_EVBIT EV_SYN\00"
@EXIT_FAILURE = global i32 0
@EV_KEY = global i32 0
@.str.1 = [33 x i8] c"error: ioctl UI_SET_EVBIT EV_KEY\00"
@UI_SET_KEYBIT = global i32 0
@BTN_TOUCH = global i32 0
@.str.2 = [27 x i8] c"error: ioctl UI_SET_KEYBIT\00"
@EV_ABS = global i32 0
@.str.3 = [33 x i8] c"error: ioctl UI_SET_EVBIT EV_ABS\00"
@UI_SET_ABSBIT = global i32 0
@ABS_X = global i64 0
@.str.4 = [31 x i8] c"error: ioctl UI_SETEVBIT ABS_X\00"
@ABS_Y = global i64 0
@.str.5 = [31 x i8] c"error: ioctl UI_SETEVBIT ABS_Y\00"
@ABS_PRESSURE = global i64 0
@.str.6 = [38 x i8] c"error: ioctl UI_SETEVBIT ABS_PRESSURE\00"
@UINPUT_MAX_NAME_SIZE = global i32 0
@.str.7 = [15 x i8] c"Network Tablet\00"
@BUS_VIRTUAL = global i32 0
@SHRT_MAX = global i32 0
@.str.8 = [13 x i8] c"error: write\00"
@UI_DEV_CREATE = global i32 0
@.str.9 = [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_SYN
%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 ([33 x i8], [33 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_EVBIT
%14 = load i32, i32* @EV_KEY
%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 ([33 x i8], [33 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_KEYBIT
%23 = load i32, i32* @BTN_TOUCH
%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 ([27 x i8], [27 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_ABS
%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_ABSBIT
%41 = load i64, i64* @ABS_X
%42 = tail call i64 (i32, i32, ...) @ioctl(i32 %0, i32 %40, i64 %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 ([31 x i8], [31 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_ABSBIT
%50 = load i64, i64* @ABS_Y
%51 = tail call i64 (i32, i32, ...) @ioctl(i32 %0, i32 %49, i64 %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 ([31 x i8], [31 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_PRESSURE
%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 ([38 x i8], [38 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 = call i32 @memset(%struct.uinput_user_dev* %2, i32 0, i32 40)
%68 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %2, i64 0, i32 3
%69 = load i32, i32* %68
%70 = load i32, i32* @UINPUT_MAX_NAME_SIZE
%71 = call i32 @snprintf(i32 %69, i32 %70, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0))
%72 = load i32, i32* @BUS_VIRTUAL
%73 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %2, i64 0, i32 2, i32 3
store i32 %72, i32* %73
%74 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %2, i64 0, i32 2, i32 0
store i32 1, i32* %74
%75 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %2, i64 0, i32 2, i32 1
store i32 1, i32* %75
%76 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %2, i64 0, i32 2, i32 2
store i32 1, i32* %76
%77 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %2, i64 0, i32 1
%78 = load i64*, i64** %77
%79 = load i64, i64* @ABS_X
%80 = getelementptr inbounds i64, i64* %78, i64 %79
store i64 0, i64* %80
%81 = load i32, i32* @SHRT_MAX
%82 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %2, i64 0, i32 0
%83 = load i32*, i32** %82
%84 = load i64, i64* @ABS_X
%85 = getelementptr inbounds i32, i32* %83, i64 %84
store i32 %81, i32* %85
%86 = load i64, i64* @ABS_Y
%87 = getelementptr inbounds i64, i64* %78, i64 %86
store i64 0, i64* %87
%88 = load i32, i32* @SHRT_MAX
%89 = load i64, i64* @ABS_Y
%90 = getelementptr inbounds i32, i32* %83, i64 %89
store i32 %88, i32* %90
%91 = load i64, i64* @ABS_PRESSURE
%92 = getelementptr inbounds i64, i64* %78, i64 %91
store i64 0, i64* %92
%93 = load i32, i32* @SHRT_MAX
%94 = sdiv i32 %93, 2
%95 = load i64, i64* @ABS_PRESSURE
%96 = getelementptr inbounds i32, i32* %83, i64 %95
store i32 %94, i32* %96
%97 = call i64 @write(i32 %0, %struct.uinput_user_dev* %2, i32 40)
%98 = icmp slt i64 %97, 0
br i1 %98, label %99, label %103
99: ; preds = %66
%100 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0))
%101 = load i32, i32* @EXIT_FAILURE
%102 = call i32 @exit(i32 %101)
unreachable
103: ; preds = %66
%104 = load i32, i32* @UI_DEV_CREATE
%105 = call i64 (i32, i32, ...) @ioctl(i32 %0, i32 %104)
%106 = icmp slt i64 %105, 0
br i1 %106, label %107, label %111
107: ; preds = %103
%108 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.9, i64 0, i64 0))
%109 = load i32, i32* @EXIT_FAILURE
%110 = call i32 @exit(i32 %109)
unreachable
111: ; preds = %103
ret void
}