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

/* Variables and functions */
int ABS_MAX;
size_t ABS_X;
int /*<<< orphan*/ BUS_USB;
int /*<<< orphan*/ EV_KEY;
int /*<<< orphan*/ EV_REL;
int /*<<< orphan*/ EV_SYN;
int KEY_A;
int /*<<< orphan*/ O_WRONLY;
int REL_MAX;
int REL_X;
int SYN_REPORT;
int /*<<< orphan*/ UI_DEV_CREATE;
int /*<<< orphan*/ UI_SET_EVBIT;
int /*<<< orphan*/ UI_SET_KEYBIT;
int /*<<< orphan*/ UI_SET_RELBIT;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int getchar();
scalar_t__ ioctl(int, int /*<<< orphan*/, ...);
int /*<<< orphan*/ memset(struct uinput_user_dev *, int /*<<< orphan*/, int);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ send_event(int, int /*<<< orphan*/, int, int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcpy(int /*<<< orphan*/, char *);
int write(int, struct uinput_user_dev *, int);
int main() {
  int i, fd;
  struct uinput_user_dev device;
  memset(&device, 0, sizeof device);
  fd = open("/dev/input/uinput", O_WRONLY);
  strcpy(device.name, "test mouse");
  device.id.bustype = BUS_USB;
  device.id.vendor = 1;
  device.id.product = 1;
  device.id.version = 1;
  for (i = 0; i < ABS_MAX; i++) {
    device.absmax[i] = -1;
    device.absmin[i] = -1;
    device.absfuzz[i] = -1;
    device.absflat[i] = -1;
  }
  device.absmin[ABS_X] = 0;
  device.absmax[ABS_X] = 255;
  device.absfuzz[ABS_X] = 0;
  device.absflat[ABS_X] = 0;
  if (write(fd, &device, sizeof(device)) != sizeof(device)) {
    fprintf(stderr, "error setup\n");
  }
  if (ioctl(fd, UI_SET_EVBIT, EV_KEY) < 0)
    fprintf(stderr, "error evbit key\n");
  if (ioctl(fd, UI_SET_KEYBIT, KEY_A) < 0)
    fprintf(stderr, "error evbit key\n");
  if (ioctl(fd, UI_SET_EVBIT, EV_REL) < 0)
    fprintf(stderr, "error evbit rel\n");
  for (i = REL_X; i < REL_MAX; i++)
    if (ioctl(fd, UI_SET_RELBIT, i) < 0)
      fprintf(stderr, "error setrelbit %d\n", i);
  if (ioctl(fd, UI_DEV_CREATE) < 0) {
    fprintf(stderr, "error create\n");
  }
  i = getchar();
  send_event(fd, EV_REL, REL_X, 2);
  send_event(fd, EV_SYN, SYN_REPORT, 0);
  send_event(fd, EV_KEY, KEY_A, 1);
  send_event(fd, EV_SYN, SYN_REPORT, 0);
  send_event(fd, EV_KEY, KEY_A, 0);
  send_event(fd, EV_SYN, SYN_REPORT, 0);
  i = getchar();
  printf("%d\n", i);
  close(fd);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x48(%rbp),%rdi
xor    %esi,%esi
mov    $0x38,%edx
call   1060 <memset@plt>
mov    0x2da2(%rip),%rax
mov    (%rax),%esi
lea    0xe31(%rip),%rdi
call   10b0 <open@plt>
mov    %eax,-0xc(%rbp)
mov    -0x18(%rbp),%edi
lea    0xe31(%rip),%rsi
call   1030 <strcpy@plt>
mov    0x2df3(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
movl   $0x1,-0x28(%rbp)
movl   $0x1,-0x24(%rbp)
movl   $0x1,-0x20(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    0x2d48(%rip),%rcx
cmp    (%rcx),%eax
jge    126a <main+0xca>
mov    -0x48(%rbp),%rax
movslq -0x8(%rbp),%rcx
movl   $0xffffffff,(%rax,%rcx,4)
mov    -0x40(%rbp),%rax
movslq -0x8(%rbp),%rcx
movl   $0xffffffff,(%rax,%rcx,4)
mov    -0x38(%rbp),%rax
movslq -0x8(%rbp),%rcx
movl   $0xffffffff,(%rax,%rcx,4)
mov    -0x30(%rbp),%rax
movslq -0x8(%rbp),%rcx
movl   $0xffffffff,(%rax,%rcx,4)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    120e <main+0x6e>
mov    -0x40(%rbp),%rax
mov    0x2d13(%rip),%rcx
mov    (%rcx),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    -0x48(%rbp),%rax
mov    0x2cfe(%rip),%rcx
mov    (%rcx),%rcx
movl   $0xff,(%rax,%rcx,4)
mov    -0x38(%rbp),%rax
mov    0x2ce9(%rip),%rcx
mov    (%rcx),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    -0x30(%rbp),%rax
mov    0x2cd4(%rip),%rcx
mov    (%rcx),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    -0xc(%rbp),%edi
lea    -0x48(%rbp),%rsi
mov    $0x38,%edx
call   1040 <write@plt>
cltq
cmp    $0x38,%rax
je     12f2 <main+0x152>
mov    0x2c96(%rip),%rax
mov    (%rax),%edi
lea    0xd32(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    -0xc(%rbp),%edi
mov    0x2cb4(%rip),%rax
mov    (%rax),%esi
mov    0x2cc3(%rip),%rax
mov    (%rax),%edx
mov    $0x0,%al
call   1070 <ioctl@plt>
cmp    $0x0,%rax
jge    132f <main+0x18f>
mov    0x2c59(%rip),%rax
mov    (%rax),%edi
lea    0xd02(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    -0xc(%rbp),%edi
mov    0x2c47(%rip),%rax
mov    (%rax),%esi
mov    0x2c8e(%rip),%rax
mov    (%rax),%edx
mov    $0x0,%al
call   1070 <ioctl@plt>
cmp    $0x0,%rax
jge    136c <main+0x1cc>
mov    0x2c1c(%rip),%rax
mov    (%rax),%edi
lea    0xcc5(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    -0xc(%rbp),%edi
mov    0x2c3a(%rip),%rax
mov    (%rax),%esi
mov    0x2c39(%rip),%rax
mov    (%rax),%edx
mov    $0x0,%al
call   1070 <ioctl@plt>
cmp    $0x0,%rax
jge    13a9 <main+0x209>
mov    0x2bdf(%rip),%rax
mov    (%rax),%edi
lea    0xc99(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    0x2be8(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    0x2be9(%rip),%rcx
cmp    (%rcx),%eax
jge    1414 <main+0x274>
mov    -0xc(%rbp),%edi
mov    0x2bef(%rip),%rax
mov    (%rax),%esi
mov    -0x8(%rbp),%edx
mov    $0x0,%al
call   1070 <ioctl@plt>
cmp    $0x0,%rax
jge    1401 <main+0x261>
mov    0x2b8a(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%edx
lea    0xc52(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
jmp    1406 <main+0x266>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    13b5 <main+0x215>
mov    -0xc(%rbp),%edi
mov    0x2bda(%rip),%rax
mov    (%rax),%esi
mov    $0x0,%al
call   1070 <ioctl@plt>
cmp    $0x0,%rax
jge    1448 <main+0x2a8>
mov    0x2b40(%rip),%rax
mov    (%rax),%edi
lea    0xc1f(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    $0x0,%al
call   1090 <getchar@plt>
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%edi
mov    0x2b5c(%rip),%rax
mov    (%rax),%esi
mov    0x2b33(%rip),%rax
mov    (%rax),%edx
mov    $0x2,%ecx
call   10c0 <send_event@plt>
mov    -0xc(%rbp),%edi
mov    0x2b6d(%rip),%rax
mov    (%rax),%esi
mov    0x2b1c(%rip),%rax
mov    (%rax),%edx
xor    %ecx,%ecx
call   10c0 <send_event@plt>
mov    -0xc(%rbp),%edi
mov    0x2b31(%rip),%rax
mov    (%rax),%esi
mov    0x2b30(%rip),%rax
mov    (%rax),%edx
mov    $0x1,%ecx
call   10c0 <send_event@plt>
mov    -0xc(%rbp),%edi
mov    0x2b32(%rip),%rax
mov    (%rax),%esi
mov    0x2ae1(%rip),%rax
mov    (%rax),%edx
xor    %ecx,%ecx
call   10c0 <send_event@plt>
mov    -0xc(%rbp),%edi
mov    0x2af6(%rip),%rax
mov    (%rax),%esi
mov    0x2af5(%rip),%rax
mov    (%rax),%edx
xor    %ecx,%ecx
call   10c0 <send_event@plt>
mov    -0xc(%rbp),%edi
mov    0x2afa(%rip),%rax
mov    (%rax),%esi
mov    0x2aa9(%rip),%rax
mov    (%rax),%edx
xor    %ecx,%ecx
call   10c0 <send_event@plt>
mov    $0x0,%al
call   1090 <getchar@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    0xb48(%rip),%rdi
call   1050 <printf@plt>
mov    -0xc(%rbp),%edi
call   1080 <close@plt>
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rsp,%rdi
xor    %esi,%esi
mov    $0x38,%edx
call   1060 <memset@plt>
mov    0x2da4(%rip),%rax
mov    (%rax),%esi
lea    0xe33(%rip),%rdi
call   10b0 <open@plt>
mov    %eax,%r15d
mov    0x30(%rsp),%edi
lea    0xe32(%rip),%rsi
call   1030 <strcpy@plt>
mov    0x2df4(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x2c(%rsp)
movabs $0x100000001,%rax
mov    %rax,0x20(%rsp)
movl   $0x1,0x28(%rsp)
mov    0x2d50(%rip),%rdi
cmpl   $0x0,(%rdi)
jle    125a <main+0xba>
mov    (%rsp),%rax
mov    0x8(%rsp),%rdx
mov    0x10(%rsp),%rcx
mov    0x18(%rsp),%rsi
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
movl   $0xffffffff,(%rax,%rbp,4)
movl   $0xffffffff,(%rdx,%rbp,4)
movl   $0xffffffff,(%rcx,%rbp,4)
movl   $0xffffffff,(%rsi,%rbp,4)
add    $0x1,%rbp
movslq (%rdi),%rbx
cmp    %rbx,%rbp
jl     1230 <main+0x90>
jmp    126d <main+0xcd>
mov    (%rsp),%rax
mov    0x8(%rsp),%rdx
mov    0x10(%rsp),%rcx
mov    0x18(%rsp),%rsi
mov    0x2d14(%rip),%rdi
mov    (%rdi),%rdi
movl   $0x0,(%rdx,%rdi,4)
movl   $0xff,(%rax,%rdi,4)
movl   $0x0,(%rcx,%rdi,4)
movl   $0x0,(%rsi,%rdi,4)
mov    %rsp,%rsi
mov    %r15d,%edi
mov    $0x38,%edx
call   1040 <write@plt>
cmp    $0x38,%eax
je     12bf <main+0x11f>
mov    0x2cc9(%rip),%rax
mov    (%rax),%edi
lea    0xd65(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    0x2cea(%rip),%rbp
mov    0x0(%rbp),%esi
mov    0x2cf8(%rip),%rax
mov    (%rax),%edx
mov    %r15d,%edi
xor    %eax,%eax
call   1070 <ioctl@plt>
test   %rax,%rax
jns    12f8 <main+0x158>
mov    0x2c90(%rip),%rax
mov    (%rax),%edi
lea    0xd39(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    0x2c81(%rip),%rax
mov    (%rax),%esi
mov    0x2cc8(%rip),%rax
mov    (%rax),%edx
mov    %r15d,%edi
xor    %eax,%eax
call   1070 <ioctl@plt>
test   %rax,%rax
jns    1330 <main+0x190>
mov    0x2c58(%rip),%rax
mov    (%rax),%edi
lea    0xd01(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    0x0(%rbp),%esi
mov    0x2c7e(%rip),%rax
mov    (%rax),%edx
mov    %r15d,%edi
xor    %eax,%eax
call   1070 <ioctl@plt>
test   %rax,%rax
jns    1362 <main+0x1c2>
mov    0x2c26(%rip),%rax
mov    (%rax),%edi
lea    0xce0(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    0x2c2f(%rip),%rax
mov    (%rax),%ebp
mov    0x2c36(%rip),%r12
cmp    (%r12),%ebp
jge    13be <main+0x21e>
mov    0x2c41(%rip),%r13
mov    0x2bf2(%rip),%rbx
lea    0xcbf(%rip),%r14
jmp    1399 <main+0x1f9>
nop
add    $0x1,%ebp
cmp    (%r12),%ebp
jge    13be <main+0x21e>
mov    0x0(%r13),%esi
mov    %r15d,%edi
mov    %ebp,%edx
xor    %eax,%eax
call   1070 <ioctl@plt>
test   %rax,%rax
jns    1390 <main+0x1f0>
mov    (%rbx),%edi
mov    %r14,%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   10a0 <fprintf@plt>
jmp    1390 <main+0x1f0>
mov    0x2c33(%rip),%rax
mov    (%rax),%esi
mov    %r15d,%edi
xor    %eax,%eax
call   1070 <ioctl@plt>
test   %rax,%rax
jns    13ed <main+0x24d>
mov    0x2b9b(%rip),%rax
mov    (%rax),%edi
lea    0xc7a(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
xor    %eax,%eax
call   1090 <getchar@plt>
mov    0x2bbd(%rip),%rax
mov    (%rax),%esi
mov    0x2b94(%rip),%rax
mov    (%rax),%edx
mov    %r15d,%edi
mov    $0x2,%ecx
call   10c0 <send_event@plt>
mov    0x2bce(%rip),%r14
mov    (%r14),%esi
mov    0x2b7c(%rip),%r12
mov    (%r12),%edx
mov    %r15d,%edi
xor    %ecx,%ecx
call   10c0 <send_event@plt>
mov    0x2b8f(%rip),%rbx
mov    (%rbx),%esi
mov    0x2b8e(%rip),%rbp
mov    0x0(%rbp),%edx
mov    %r15d,%edi
mov    $0x1,%ecx
call   10c0 <send_event@plt>
mov    (%r14),%esi
mov    (%r12),%edx
mov    %r15d,%edi
xor    %ecx,%ecx
call   10c0 <send_event@plt>
mov    (%rbx),%esi
mov    0x0(%rbp),%edx
mov    %r15d,%edi
xor    %ecx,%ecx
call   10c0 <send_event@plt>
mov    (%r14),%esi
mov    (%r12),%edx
mov    %r15d,%edi
xor    %ecx,%ecx
call   10c0 <send_event@plt>
xor    %eax,%eax
call   1090 <getchar@plt>
lea    0xbcb(%rip),%rdi
mov    %eax,%esi
call   1050 <printf@plt>
mov    %r15d,%edi
call   1080 <close@plt>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.uinput_user_dev = type { i32*, i32*, i32*, i32*, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32, i32, i32, i32 }
@.str = [18 x i8] c"/dev/input/uinput\00"
@O_WRONLY = global i32 0
@.str.1 = [11 x i8] c"test mouse\00"
@BUS_USB = global i32 0
@ABS_MAX = global i32 0
@ABS_X = global i64 0
@stderr = global i32 0
@.str.2 = [13 x i8] c"error setup\0A\00"
@UI_SET_EVBIT = global i32 0
@EV_KEY = global i32 0
@.str.3 = [17 x i8] c"error evbit key\0A\00"
@UI_SET_KEYBIT = global i32 0
@KEY_A = global i32 0
@EV_REL = global i32 0
@.str.4 = [17 x i8] c"error evbit rel\0A\00"
@REL_X = global i32 0
@REL_MAX = global i32 0
@UI_SET_RELBIT = global i32 0
@.str.5 = [20 x i8] c"error setrelbit %d\0A\00"
@UI_DEV_CREATE = global i32 0
@.str.6 = [14 x i8] c"error create\0A\00"
@EV_SYN = global i32 0
@SYN_REPORT = global i32 0
@.str.7 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca %struct.uinput_user_dev
store i32 0, i32* %1
%5 = call i32 @memset(%struct.uinput_user_dev* %4, i32 0, i32 56)
%6 = load i32, i32* @O_WRONLY
%7 = call i32 @open(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %6)
store i32 %7, i32* %3
%8 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %4, i32 0, i32 5
%9 = load i32, i32* %8
%10 = call i32 @strcpy(i32 %9, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%11 = load i32, i32* @BUS_USB
%12 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %4, i32 0, i32 4
%13 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %12, i32 0, i32 3
store i32 %11, i32* %13
%14 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %4, i32 0, i32 4
%15 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %14, i32 0, i32 0
store i32 1, i32* %15
%16 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %4, i32 0, i32 4
%17 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %16, i32 0, i32 1
store i32 1, i32* %17
%18 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %4, i32 0, i32 4
%19 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %18, i32 0, i32 2
store i32 1, i32* %19
store i32 0, i32* %2
br label %20
20: ; preds = %45, %0
%21 = load i32, i32* %2
%22 = load i32, i32* @ABS_MAX
%23 = icmp slt i32 %21, %22
br i1 %23, label %24, label %48
24: ; preds = %20
%25 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %4, i32 0, i32 0
%26 = load i32*, i32** %25
%27 = load i32, i32* %2
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i32, i32* %26, i64 %28
store i32 -1, i32* %29
%30 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %4, i32 0, i32 1
%31 = load i32*, i32** %30
%32 = load i32, i32* %2
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i32, i32* %31, i64 %33
store i32 -1, i32* %34
%35 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %4, i32 0, i32 2
%36 = load i32*, i32** %35
%37 = load i32, i32* %2
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i32, i32* %36, i64 %38
store i32 -1, i32* %39
%40 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %4, i32 0, i32 3
%41 = load i32*, i32** %40
%42 = load i32, i32* %2
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i32, i32* %41, i64 %43
store i32 -1, i32* %44
br label %45
45: ; preds = %24
%46 = load i32, i32* %2
%47 = add nsw i32 %46, 1
store i32 %47, i32* %2
br label %20
48: ; preds = %20
%49 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %4, i32 0, i32 1
%50 = load i32*, i32** %49
%51 = load i64, i64* @ABS_X
%52 = getelementptr inbounds i32, i32* %50, i64 %51
store i32 0, i32* %52
%53 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %4, i32 0, i32 0
%54 = load i32*, i32** %53
%55 = load i64, i64* @ABS_X
%56 = getelementptr inbounds i32, i32* %54, i64 %55
store i32 255, i32* %56
%57 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %4, i32 0, i32 2
%58 = load i32*, i32** %57
%59 = load i64, i64* @ABS_X
%60 = getelementptr inbounds i32, i32* %58, i64 %59
store i32 0, i32* %60
%61 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %4, i32 0, i32 3
%62 = load i32*, i32** %61
%63 = load i64, i64* @ABS_X
%64 = getelementptr inbounds i32, i32* %62, i64 %63
store i32 0, i32* %64
%65 = load i32, i32* %3
%66 = call i32 @write(i32 %65, %struct.uinput_user_dev* %4, i32 56)
%67 = sext i32 %66 to i64
%68 = icmp ne i64 %67, 56
br i1 %68, label %69, label %72
69: ; preds = %48
%70 = load i32, i32* @stderr
%71 = call i32 (i32, i8*, ...) @fprintf(i32 %70, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
br label %72
72: ; preds = %69, %48
%73 = load i32, i32* %3
%74 = load i32, i32* @UI_SET_EVBIT
%75 = load i32, i32* @EV_KEY
%76 = call i64 (i32, i32, ...) @ioctl(i32 %73, i32 %74, i32 %75)
%77 = icmp slt i64 %76, 0
br i1 %77, label %78, label %81
78: ; preds = %72
%79 = load i32, i32* @stderr
%80 = call i32 (i32, i8*, ...) @fprintf(i32 %79, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
br label %81
81: ; preds = %78, %72
%82 = load i32, i32* %3
%83 = load i32, i32* @UI_SET_KEYBIT
%84 = load i32, i32* @KEY_A
%85 = call i64 (i32, i32, ...) @ioctl(i32 %82, i32 %83, i32 %84)
%86 = icmp slt i64 %85, 0
br i1 %86, label %87, label %90
87: ; preds = %81
%88 = load i32, i32* @stderr
%89 = call i32 (i32, i8*, ...) @fprintf(i32 %88, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
br label %90
90: ; preds = %87, %81
%91 = load i32, i32* %3
%92 = load i32, i32* @UI_SET_EVBIT
%93 = load i32, i32* @EV_REL
%94 = call i64 (i32, i32, ...) @ioctl(i32 %91, i32 %92, i32 %93)
%95 = icmp slt i64 %94, 0
br i1 %95, label %96, label %99
96: ; preds = %90
%97 = load i32, i32* @stderr
%98 = call i32 (i32, i8*, ...) @fprintf(i32 %97, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
br label %99
99: ; preds = %96, %90
%100 = load i32, i32* @REL_X
store i32 %100, i32* %2
br label %101
101: ; preds = %116, %99
%102 = load i32, i32* %2
%103 = load i32, i32* @REL_MAX
%104 = icmp slt i32 %102, %103
br i1 %104, label %105, label %119
105: ; preds = %101
%106 = load i32, i32* %3
%107 = load i32, i32* @UI_SET_RELBIT
%108 = load i32, i32* %2
%109 = call i64 (i32, i32, ...) @ioctl(i32 %106, i32 %107, i32 %108)
%110 = icmp slt i64 %109, 0
br i1 %110, label %111, label %115
111: ; preds = %105
%112 = load i32, i32* @stderr
%113 = load i32, i32* %2
%114 = call i32 (i32, i8*, ...) @fprintf(i32 %112, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0), i32 %113)
br label %115
115: ; preds = %111, %105
br label %116
116: ; preds = %115
%117 = load i32, i32* %2
%118 = add nsw i32 %117, 1
store i32 %118, i32* %2
br label %101
119: ; preds = %101
%120 = load i32, i32* %3
%121 = load i32, i32* @UI_DEV_CREATE
%122 = call i64 (i32, i32, ...) @ioctl(i32 %120, i32 %121)
%123 = icmp slt i64 %122, 0
br i1 %123, label %124, label %127
124: ; preds = %119
%125 = load i32, i32* @stderr
%126 = call i32 (i32, i8*, ...) @fprintf(i32 %125, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0))
br label %127
127: ; preds = %124, %119
%128 = call i32 (...) @getchar()
store i32 %128, i32* %2
%129 = load i32, i32* %3
%130 = load i32, i32* @EV_REL
%131 = load i32, i32* @REL_X
%132 = call i32 @send_event(i32 %129, i32 %130, i32 %131, i32 2)
%133 = load i32, i32* %3
%134 = load i32, i32* @EV_SYN
%135 = load i32, i32* @SYN_REPORT
%136 = call i32 @send_event(i32 %133, i32 %134, i32 %135, i32 0)
%137 = load i32, i32* %3
%138 = load i32, i32* @EV_KEY
%139 = load i32, i32* @KEY_A
%140 = call i32 @send_event(i32 %137, i32 %138, i32 %139, i32 1)
%141 = load i32, i32* %3
%142 = load i32, i32* @EV_SYN
%143 = load i32, i32* @SYN_REPORT
%144 = call i32 @send_event(i32 %141, i32 %142, i32 %143, i32 0)
%145 = load i32, i32* %3
%146 = load i32, i32* @EV_KEY
%147 = load i32, i32* @KEY_A
%148 = call i32 @send_event(i32 %145, i32 %146, i32 %147, i32 0)
%149 = load i32, i32* %3
%150 = load i32, i32* @EV_SYN
%151 = load i32, i32* @SYN_REPORT
%152 = call i32 @send_event(i32 %149, i32 %150, i32 %151, i32 0)
%153 = call i32 (...) @getchar()
store i32 %153, i32* %2
%154 = load i32, i32* %2
%155 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i32 %154)
%156 = load i32, i32* %3
%157 = call i32 @close(i32 %156)
%158 = load i32, i32* %1
ret i32 %158
}

LLVM IR (-O2):
%struct.uinput_user_dev = type { i32*, i32*, i32*, i32*, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32, i32, i32, i32 }
@.str = [18 x i8] c"/dev/input/uinput\00"
@O_WRONLY = global i32 0
@.str.1 = [11 x i8] c"test mouse\00"
@BUS_USB = global i32 0
@ABS_MAX = global i32 0
@ABS_X = global i64 0
@stderr = global i32 0
@.str.2 = [13 x i8] c"error setup\0A\00"
@UI_SET_EVBIT = global i32 0
@EV_KEY = global i32 0
@.str.3 = [17 x i8] c"error evbit key\0A\00"
@UI_SET_KEYBIT = global i32 0
@KEY_A = global i32 0
@EV_REL = global i32 0
@.str.4 = [17 x i8] c"error evbit rel\0A\00"
@REL_X = global i32 0
@REL_MAX = global i32 0
@UI_SET_RELBIT = global i32 0
@.str.5 = [20 x i8] c"error setrelbit %d\0A\00"
@UI_DEV_CREATE = global i32 0
@.str.6 = [14 x i8] c"error create\0A\00"
@EV_SYN = global i32 0
@SYN_REPORT = global i32 0
@.str.7 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca %struct.uinput_user_dev
%2 = bitcast %struct.uinput_user_dev* %1 to i8*
%3 = call i32 @memset(%struct.uinput_user_dev* %1, i32 0, i32 56)
%4 = load i32, i32* @O_WRONLY
%5 = call i32 @open(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %4)
%6 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %1, i64 0, i32 5
%7 = load i32, i32* %6
%8 = call i32 @strcpy(i32 %7, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%9 = load i32, i32* @BUS_USB
%10 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %1, i64 0, i32 4, i32 3
store i32 %9, i32* %10
%11 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %1, i64 0, i32 4, i32 0
store i32 1, i32* %11
%12 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %1, i64 0, i32 4, i32 1
store i32 1, i32* %12
%13 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %1, i64 0, i32 4, i32 2
store i32 1, i32* %13
%14 = load i32, i32* @ABS_MAX
%15 = icmp sgt i32 %14, 0
br i1 %15, label %25, label %16
16: ; preds = %0
%17 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %1, i64 0, i32 1
%18 = load i32*, i32** %17
%19 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %1, i64 0, i32 0
%20 = load i32*, i32** %19
%21 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %1, i64 0, i32 2
%22 = load i32*, i32** %21
%23 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %1, i64 0, i32 3
%24 = load i32*, i32** %23
br label %44
25: ; preds = %0
%26 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %1, i64 0, i32 0
%27 = load i32*, i32** %26
%28 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %1, i64 0, i32 1
%29 = load i32*, i32** %28
%30 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %1, i64 0, i32 2
%31 = load i32*, i32** %30
%32 = getelementptr inbounds %struct.uinput_user_dev, %struct.uinput_user_dev* %1, i64 0, i32 3
%33 = load i32*, i32** %32
br label %34
34: ; preds = %25, %34
%35 = phi i64 [ 0, %25 ], [ %40, %34 ]
%36 = getelementptr inbounds i32, i32* %27, i64 %35
store i32 -1, i32* %36
%37 = getelementptr inbounds i32, i32* %29, i64 %35
store i32 -1, i32* %37
%38 = getelementptr inbounds i32, i32* %31, i64 %35
store i32 -1, i32* %38
%39 = getelementptr inbounds i32, i32* %33, i64 %35
store i32 -1, i32* %39
%40 = add nuw nsw i64 %35, 1
%41 = load i32, i32* @ABS_MAX
%42 = sext i32 %41 to i64
%43 = icmp slt i64 %40, %42
br i1 %43, label %34, label %44
44: ; preds = %34, %16
%45 = phi i32* [ %24, %16 ], [ %33, %34 ]
%46 = phi i32* [ %22, %16 ], [ %31, %34 ]
%47 = phi i32* [ %20, %16 ], [ %27, %34 ]
%48 = phi i32* [ %18, %16 ], [ %29, %34 ]
%49 = load i64, i64* @ABS_X
%50 = getelementptr inbounds i32, i32* %48, i64 %49
store i32 0, i32* %50
%51 = getelementptr inbounds i32, i32* %47, i64 %49
store i32 255, i32* %51
%52 = getelementptr inbounds i32, i32* %46, i64 %49
store i32 0, i32* %52
%53 = getelementptr inbounds i32, i32* %45, i64 %49
store i32 0, i32* %53
%54 = call i32 @write(i32 %5, %struct.uinput_user_dev* %1, i32 56)
%55 = icmp eq i32 %54, 56
br i1 %55, label %59, label %56
56: ; preds = %44
%57 = load i32, i32* @stderr
%58 = call i32 (i32, i8*, ...) @fprintf(i32 %57, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
br label %59
59: ; preds = %56, %44
%60 = load i32, i32* @UI_SET_EVBIT
%61 = load i32, i32* @EV_KEY
%62 = call i64 (i32, i32, ...) @ioctl(i32 %5, i32 %60, i32 %61)
%63 = icmp slt i64 %62, 0
br i1 %63, label %64, label %67
64: ; preds = %59
%65 = load i32, i32* @stderr
%66 = call i32 (i32, i8*, ...) @fprintf(i32 %65, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
br label %67
67: ; preds = %64, %59
%68 = load i32, i32* @UI_SET_KEYBIT
%69 = load i32, i32* @KEY_A
%70 = call i64 (i32, i32, ...) @ioctl(i32 %5, i32 %68, i32 %69)
%71 = icmp slt i64 %70, 0
br i1 %71, label %72, label %75
72: ; preds = %67
%73 = load i32, i32* @stderr
%74 = call i32 (i32, i8*, ...) @fprintf(i32 %73, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
br label %75
75: ; preds = %72, %67
%76 = load i32, i32* @UI_SET_EVBIT
%77 = load i32, i32* @EV_REL
%78 = call i64 (i32, i32, ...) @ioctl(i32 %5, i32 %76, i32 %77)
%79 = icmp slt i64 %78, 0
br i1 %79, label %80, label %83
80: ; preds = %75
%81 = load i32, i32* @stderr
%82 = call i32 (i32, i8*, ...) @fprintf(i32 %81, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
br label %83
83: ; preds = %80, %75
%84 = load i32, i32* @REL_X
%85 = load i32, i32* @REL_MAX
%86 = icmp slt i32 %84, %85
br i1 %86, label %87, label %99
87: ; preds = %83, %95
%88 = phi i32 [ %96, %95 ], [ %84, %83 ]
%89 = load i32, i32* @UI_SET_RELBIT
%90 = call i64 (i32, i32, ...) @ioctl(i32 %5, i32 %89, i32 %88)
%91 = icmp slt i64 %90, 0
br i1 %91, label %92, label %95
92: ; preds = %87
%93 = load i32, i32* @stderr
%94 = call i32 (i32, i8*, ...) @fprintf(i32 %93, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0), i32 %88)
br label %95
95: ; preds = %87, %92
%96 = add nsw i32 %88, 1
%97 = load i32, i32* @REL_MAX
%98 = icmp slt i32 %96, %97
br i1 %98, label %87, label %99
99: ; preds = %95, %83
%100 = load i32, i32* @UI_DEV_CREATE
%101 = call i64 (i32, i32, ...) @ioctl(i32 %5, i32 %100)
%102 = icmp slt i64 %101, 0
br i1 %102, label %103, label %106
103: ; preds = %99
%104 = load i32, i32* @stderr
%105 = call i32 (i32, i8*, ...) @fprintf(i32 %104, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0))
br label %106
106: ; preds = %103, %99
%107 = call i32 (...) @getchar()
%108 = load i32, i32* @EV_REL
%109 = load i32, i32* @REL_X
%110 = call i32 @send_event(i32 %5, i32 %108, i32 %109, i32 2)
%111 = load i32, i32* @EV_SYN
%112 = load i32, i32* @SYN_REPORT
%113 = call i32 @send_event(i32 %5, i32 %111, i32 %112, i32 0)
%114 = load i32, i32* @EV_KEY
%115 = load i32, i32* @KEY_A
%116 = call i32 @send_event(i32 %5, i32 %114, i32 %115, i32 1)
%117 = load i32, i32* @EV_SYN
%118 = load i32, i32* @SYN_REPORT
%119 = call i32 @send_event(i32 %5, i32 %117, i32 %118, i32 0)
%120 = load i32, i32* @EV_KEY
%121 = load i32, i32* @KEY_A
%122 = call i32 @send_event(i32 %5, i32 %120, i32 %121, i32 0)
%123 = load i32, i32* @EV_SYN
%124 = load i32, i32* @SYN_REPORT
%125 = call i32 @send_event(i32 %5, i32 %123, i32 %124, i32 0)
%126 = call i32 (...) @getchar()
%127 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i32 %126)
%128 = call i32 @close(i32 %5)
ret i32 0
}