#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*/ 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_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    0x2e4b(%rip),%rax
mov    (%rax),%esi
mov    0x2e4a(%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    0x2de4(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    -0x4(%rbp),%edi
mov    0x2deb(%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    0xe49(%rip),%rdi
call   1070 <perror@plt>
mov    0x2da4(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    -0x4(%rbp),%edi
mov    0x2dcb(%rip),%rax
mov    (%rax),%esi
mov    0x2d72(%rip),%rax
mov    (%rax),%edx
mov    $0x0,%al
call   1060 <ioctl@plt>
cmp    $0x0,%rax
jge    122b <init_device+0xcb>
lea    0xe24(%rip),%rdi
call   1070 <perror@plt>
mov    0x2d64(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    -0x4(%rbp),%edi
mov    0x2d43(%rip),%rax
mov    (%rax),%esi
mov    0x2d6a(%rip),%rax
mov    (%rax),%rdx
mov    $0x0,%al
call   1060 <ioctl@plt>
cmp    $0x0,%rax
jge    126c <init_device+0x10c>
lea    0xe04(%rip),%rdi
call   1070 <perror@plt>
mov    0x2d23(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    -0x4(%rbp),%edi
mov    0x2d02(%rip),%rax
mov    (%rax),%esi
mov    0x2d79(%rip),%rax
mov    (%rax),%rdx
mov    $0x0,%al
call   1060 <ioctl@plt>
cmp    $0x0,%rax
jge    12ad <init_device+0x14d>
lea    0xde2(%rip),%rdi
call   1070 <perror@plt>
mov    0x2ce2(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    -0x4(%rbp),%edi
mov    0x2cc1(%rip),%rax
mov    (%rax),%esi
mov    0x2cd8(%rip),%rax
mov    (%rax),%rdx
mov    $0x0,%al
call   1060 <ioctl@plt>
cmp    $0x0,%rax
jge    12ee <init_device+0x18e>
lea    0xdc0(%rip),%rdi
call   1070 <perror@plt>
mov    0x2ca1(%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    0x2cb0(%rip),%rax
mov    (%rax),%esi
lea    0xdb0(%rip),%rdx
call   1040 <snprintf@plt>
mov    0x2cbb(%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    0x2c66(%rip),%rcx
mov    (%rcx),%rcx
movq   $0x0,(%rax,%rcx,8)
mov    0x2c3c(%rip),%rax
mov    (%rax),%edx
mov    -0x30(%rbp),%rax
mov    0x2c47(%rip),%rcx
mov    (%rcx),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x28(%rbp),%rax
mov    0x2c86(%rip),%rcx
mov    (%rcx),%rcx
movq   $0x0,(%rax,%rcx,8)
mov    0x2c0c(%rip),%rax
mov    (%rax),%edx
mov    -0x30(%rbp),%rax
mov    0x2c67(%rip),%rcx
mov    (%rcx),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x28(%rbp),%rax
mov    0x2bf6(%rip),%rcx
mov    (%rcx),%rcx
movq   $0x0,(%rax,%rcx,8)
mov    0x2bdc(%rip),%rax
mov    (%rax),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%edx
mov    -0x30(%rbp),%rax
mov    0x2bcd(%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    1406 <init_device+0x2a6>
lea    0xcdd(%rip),%rdi
call   1070 <perror@plt>
mov    0x2b89(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    -0x4(%rbp),%edi
mov    0x2be0(%rip),%rax
mov    (%rax),%esi
mov    $0x0,%al
call   1060 <ioctl@plt>
cmp    $0x0,%rax
jge    143d <init_device+0x2dd>
lea    0xcb3(%rip),%rdi
call   1070 <perror@plt>
mov    0x2b52(%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    0x2e4a(%rip),%r14
mov    (%r14),%esi
mov    0x2e48(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
call   1060 <ioctl@plt>
test   %rax,%rax
js     131b <init_device+0x1bb>
mov    0x2e07(%rip),%rax
mov    (%rax),%esi
mov    0x2e2e(%rip),%rax
mov    (%rax),%edx
mov    %ebx,%edi
xor    %eax,%eax
call   1060 <ioctl@plt>
test   %rax,%rax
js     1324 <init_device+0x1c4>
mov    (%r14),%esi
mov    0x2db0(%rip),%rax
mov    (%rax),%edx
mov    %ebx,%edi
xor    %eax,%eax
call   1060 <ioctl@plt>
test   %rax,%rax
js     132d <init_device+0x1cd>
mov    0x2d9d(%rip),%r14
mov    (%r14),%esi
mov    0x2dc3(%rip),%r15
mov    (%r15),%rdx
mov    %ebx,%edi
xor    %eax,%eax
call   1060 <ioctl@plt>
test   %rax,%rax
js     1336 <init_device+0x1d6>
mov    (%r14),%esi
mov    0x2df4(%rip),%r12
mov    (%r12),%rdx
mov    %ebx,%edi
xor    %eax,%eax
call   1060 <ioctl@plt>
test   %rax,%rax
js     133f <init_device+0x1df>
mov    (%r14),%esi
mov    0x2d74(%rip),%r13
mov    0x0(%r13),%rdx
mov    %ebx,%edi
xor    %eax,%eax
call   1060 <ioctl@plt>
test   %rax,%rax
js     1348 <init_device+0x1e8>
lea    0x8(%rsp),%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1050 <memset@plt>
mov    0x28(%rsp),%edi
mov    0x2d5f(%rip),%rax
mov    (%rax),%esi
lea    0xe5f(%rip),%rdx
call   1040 <snprintf@plt>
mov    0x2d6a(%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    0x2cee(%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     1351 <init_device+0x1f1>
mov    0x2cf3(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
xor    %eax,%eax
call   1060 <ioctl@plt>
test   %rax,%rax
js     135a <init_device+0x1fa>
add    $0x30,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
lea    0xcde(%rip),%rdi
jmp    1361 <init_device+0x201>
lea    0xcf6(%rip),%rdi
jmp    1361 <init_device+0x201>
lea    0xd08(%rip),%rdi
jmp    1361 <init_device+0x201>
lea    0xd20(%rip),%rdi
jmp    1361 <init_device+0x201>
lea    0xd36(%rip),%rdi
jmp    1361 <init_device+0x201>
lea    0xd4c(%rip),%rdi
jmp    1361 <init_device+0x201>
lea    0xd78(%rip),%rdi
jmp    1361 <init_device+0x201>
lea    0xd7c(%rip),%rdi
call   1070 <perror@plt>
mov    0x2c1b(%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_KEY = global i32 0
@.str = [33 x i8] c"error: ioctl UI_SET_EVBIT EV_KEY\00"
@EXIT_FAILURE = global i32 0
@UI_SET_KEYBIT = global i32 0
@BTN_TOUCH = global i32 0
@.str.1 = [27 x i8] c"error: ioctl UI_SET_KEYBIT\00"
@EV_ABS = global i32 0
@.str.2 = [33 x i8] c"error: ioctl UI_SET_EVBIT EV_ABS\00"
@UI_SET_ABSBIT = global i32 0
@ABS_X = global i64 0
@.str.3 = [31 x i8] c"error: ioctl UI_SETEVBIT ABS_X\00"
@ABS_Y = global i64 0
@.str.4 = [31 x i8] c"error: ioctl UI_SETEVBIT ABS_Y\00"
@ABS_PRESSURE = global i64 0
@.str.5 = [38 x i8] c"error: ioctl UI_SETEVBIT ABS_PRESSURE\00"
@UINPUT_MAX_NAME_SIZE = global i32 0
@.str.6 = [15 x i8] c"Network Tablet\00"
@BUS_VIRTUAL = global i32 0
@SHRT_MAX = global i32 0
@.str.7 = [13 x i8] c"error: write\00"
@UI_DEV_CREATE = global i32 0
@.str.8 = [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_KEY
%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_KEYBIT
%16 = load i32, i32* @BTN_TOUCH
%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 ([27 x i8], [27 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_EVBIT
%26 = load i32, i32* @EV_ABS
%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 ([33 x i8], [33 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_ABSBIT
%36 = load i64, i64* @ABS_X
%37 = call i64 (i32, i32, ...) @ioctl(i32 %34, i32 %35, i64 %36)
%38 = icmp slt i64 %37, 0
br i1 %38, label %39, label %43
39: ; preds = %33
%40 = call i32 @perror(i8* getelementptr inbounds ([31 x i8], [31 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_Y
%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_PRESSURE
%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 ([38 x i8], [38 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 = call i32 @memset(%struct.uinput_user_dev* %3, i32 0, i32 40)
%65 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %3, i32 0, i32 3
%66 = load i32, i32* %65
%67 = load i32, i32* @UINPUT_MAX_NAME_SIZE
%68 = call i32 @snprintf(i32 %66, i32 %67, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0))
%69 = load i32, i32* @BUS_VIRTUAL
%70 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %3, i32 0, i32 2
%71 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %70, i32 0, i32 3
store i32 %69, i32* %71
%72 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %3, i32 0, i32 2
%73 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %72, i32 0, i32 0
store i32 1, i32* %73
%74 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %3, i32 0, i32 2
%75 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %74, i32 0, i32 1
store i32 1, i32* %75
%76 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %3, i32 0, i32 2
%77 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %76, i32 0, i32 2
store i32 1, i32* %77
%78 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %3, i32 0, i32 1
%79 = load i64*, i64** %78
%80 = load i64, i64* @ABS_X
%81 = getelementptr inbounds i64, i64* %79, i64 %80
store i64 0, i64* %81
%82 = load i32, i32* @SHRT_MAX
%83 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %3, i32 0, i32 0
%84 = load i32*, i32** %83
%85 = load i64, i64* @ABS_X
%86 = getelementptr inbounds i32, i32* %84, i64 %85
store i32 %82, i32* %86
%87 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %3, i32 0, i32 1
%88 = load i64*, i64** %87
%89 = load i64, i64* @ABS_Y
%90 = getelementptr inbounds i64, i64* %88, i64 %89
store i64 0, i64* %90
%91 = load i32, i32* @SHRT_MAX
%92 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %3, i32 0, i32 0
%93 = load i32*, i32** %92
%94 = load i64, i64* @ABS_Y
%95 = getelementptr inbounds i32, i32* %93, i64 %94
store i32 %91, i32* %95
%96 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %3, i32 0, i32 1
%97 = load i64*, i64** %96
%98 = load i64, i64* @ABS_PRESSURE
%99 = getelementptr inbounds i64, i64* %97, i64 %98
store i64 0, i64* %99
%100 = load i32, i32* @SHRT_MAX
%101 = sdiv i32 %100, 2
%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_PRESSURE
%105 = getelementptr inbounds i32, i32* %103, i64 %104
store i32 %101, i32* %105
%106 = load i32, i32* %2
%107 = call i64 @write(i32 %106, %struct.uinput_user_dev* %3, i32 40)
%108 = icmp slt i64 %107, 0
br i1 %108, label %109, label %113
109: ; preds = %63
%110 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0))
%111 = load i32, i32* @EXIT_FAILURE
%112 = call i32 @exit(i32 %111)
unreachable
113: ; preds = %63
%114 = load i32, i32* %2
%115 = load i32, i32* @UI_DEV_CREATE
%116 = call i64 (i32, i32, ...) @ioctl(i32 %114, i32 %115)
%117 = icmp slt i64 %116, 0
br i1 %117, label %118, label %122
118: ; preds = %113
%119 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0))
%120 = load i32, i32* @EXIT_FAILURE
%121 = call i32 @exit(i32 %120)
unreachable
122: ; preds = %113
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_KEY = global i32 0
@.str = [33 x i8] c"error: ioctl UI_SET_EVBIT EV_KEY\00"
@EXIT_FAILURE = global i32 0
@UI_SET_KEYBIT = global i32 0
@BTN_TOUCH = global i32 0
@.str.1 = [27 x i8] c"error: ioctl UI_SET_KEYBIT\00"
@EV_ABS = global i32 0
@.str.2 = [33 x i8] c"error: ioctl UI_SET_EVBIT EV_ABS\00"
@UI_SET_ABSBIT = global i32 0
@ABS_X = global i64 0
@.str.3 = [31 x i8] c"error: ioctl UI_SETEVBIT ABS_X\00"
@ABS_Y = global i64 0
@.str.4 = [31 x i8] c"error: ioctl UI_SETEVBIT ABS_Y\00"
@ABS_PRESSURE = global i64 0
@.str.5 = [38 x i8] c"error: ioctl UI_SETEVBIT ABS_PRESSURE\00"
@UINPUT_MAX_NAME_SIZE = global i32 0
@.str.6 = [15 x i8] c"Network Tablet\00"
@BUS_VIRTUAL = global i32 0
@SHRT_MAX = global i32 0
@.str.7 = [13 x i8] c"error: write\00"
@UI_DEV_CREATE = global i32 0
@.str.8 = [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_KEY
%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_KEYBIT
%14 = load i32, i32* @BTN_TOUCH
%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 ([27 x i8], [27 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_EVBIT
%23 = load i32, i32* @EV_ABS
%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 ([33 x i8], [33 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_ABSBIT
%32 = load i64, i64* @ABS_X
%33 = tail call i64 (i32, i32, ...) @ioctl(i32 %0, i32 %31, i64 %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 ([31 x i8], [31 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_Y
%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_PRESSURE
%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 ([38 x i8], [38 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 = call i32 @memset(%struct.uinput_user_dev* %2, i32 0, i32 40)
%59 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %2, i64 0, i32 3
%60 = load i32, i32* %59
%61 = load i32, i32* @UINPUT_MAX_NAME_SIZE
%62 = call i32 @snprintf(i32 %60, i32 %61, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0))
%63 = load i32, i32* @BUS_VIRTUAL
%64 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %2, i64 0, i32 2, i32 3
store i32 %63, i32* %64
%65 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %2, i64 0, i32 2, i32 0
store i32 1, i32* %65
%66 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %2, i64 0, i32 2, i32 1
store i32 1, i32* %66
%67 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %2, i64 0, i32 2, i32 2
store i32 1, i32* %67
%68 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %2, i64 0, i32 1
%69 = load i64*, i64** %68
%70 = load i64, i64* @ABS_X
%71 = getelementptr inbounds i64, i64* %69, i64 %70
store i64 0, i64* %71
%72 = load i32, i32* @SHRT_MAX
%73 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %2, i64 0, i32 0
%74 = load i32*, i32** %73
%75 = load i64, i64* @ABS_X
%76 = getelementptr inbounds i32, i32* %74, i64 %75
store i32 %72, i32* %76
%77 = load i64, i64* @ABS_Y
%78 = getelementptr inbounds i64, i64* %69, i64 %77
store i64 0, i64* %78
%79 = load i32, i32* @SHRT_MAX
%80 = load i64, i64* @ABS_Y
%81 = getelementptr inbounds i32, i32* %74, i64 %80
store i32 %79, i32* %81
%82 = load i64, i64* @ABS_PRESSURE
%83 = getelementptr inbounds i64, i64* %69, i64 %82
store i64 0, i64* %83
%84 = load i32, i32* @SHRT_MAX
%85 = sdiv i32 %84, 2
%86 = load i64, i64* @ABS_PRESSURE
%87 = getelementptr inbounds i32, i32* %74, i64 %86
store i32 %85, i32* %87
%88 = call i64 @write(i32 %0, %struct.uinput_user_dev* %2, i32 40)
%89 = icmp slt i64 %88, 0
br i1 %89, label %90, label %94
90: ; preds = %57
%91 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0))
%92 = load i32, i32* @EXIT_FAILURE
%93 = call i32 @exit(i32 %92)
unreachable
94: ; preds = %57
%95 = load i32, i32* @UI_DEV_CREATE
%96 = call i64 (i32, i32, ...) @ioctl(i32 %0, i32 %95)
%97 = icmp slt i64 %96, 0
br i1 %97, label %98, label %102
98: ; preds = %94
%99 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0))
%100 = load i32, i32* @EXIT_FAILURE
%101 = call i32 @exit(i32 %100)
unreachable
102: ; preds = %94
ret void
}