#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 */

/* Type definitions */
struct js_event {
  int type;
  size_t number;
  int value;
};

/* Variables and functions */
int /*<<< orphan*/ JSIOCGAXES;
int /*<<< orphan*/ JSIOCGBUTTONS;
int /*<<< orphan*/ JSIOCGNAME(int);
int /*<<< orphan*/ JSIOCGVERSION;
#define JS_EVENT_AXIS 129
#define JS_EVENT_BUTTON 128
int JS_EVENT_INIT;
int /*<<< orphan*/ O_RDONLY;
int *calloc(unsigned char, int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ ioctl(int, int /*<<< orphan*/, ...);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ puts(char *);
int read(int, struct js_event *, int);
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ strcmp(char *, char *);
int main(int argc, char **argv) {
  int fd;
  unsigned char axes = 2;
  unsigned char buttons = 2;
  int version = 0x000800;
  char name[128] = "Unknown";
  if (argc != 2 || !strcmp("--help", argv[1])) {
    puts("Usage: jscommander <device>");
    exit(1);
  }
  if ((fd = open(argv[argc - 1], O_RDONLY)) < 0) {
    perror("jscommander: Unable to read file descriptor");
    exit(1);
  }
  ioctl(fd, JSIOCGVERSION, &version);
  ioctl(fd, JSIOCGAXES, &axes);
  ioctl(fd, JSIOCGBUTTONS, &buttons);
  ioctl(fd, JSIOCGNAME(128), name);
  printf(
      "Joystick (%s) has %d axes and %d buttons. Driver version is %d.%d.%d.\n",
      name, axes, buttons, version >> 16, (version >> 8) & 0xff,
      version & 0xff);
  printf("Running... (SIGINT to exit)\n");
  int *axis;
  int *button;
  int i;
  struct js_event js;
  axis = calloc(axes, sizeof(int));
  button = calloc(buttons, sizeof(char));
  while (1) {
    if (read(fd, &js, sizeof(struct js_event)) != sizeof(struct js_event)) {
      perror("\njscommander: Error reading device");
      exit(1);
    }
    switch (js.type & ~JS_EVENT_INIT) {
    case JS_EVENT_BUTTON:
      button[js.number] = js.value;
      break;
    case JS_EVENT_AXIS:
      axis[js.number] = js.value;
      break;
    }
    printf("\r");
    if (axes) {
      printf("%dx%dy", axis[0] / 364 + 90, axis[1] / 364 + 90);
    }
    fflush(stdout);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xe0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movb   $0x2,-0x15(%rbp)
movb   $0x2,-0x16(%rbp)
movl   $0x800,-0x1c(%rbp)
lea    -0xa0(%rbp),%rdi
lea    0xe0a(%rip),%rsi
mov    $0x80,%edx
call   1090 <memcpy@plt>
cmpl   $0x2,-0x8(%rbp)
jne    1227 <main+0x67>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe67(%rip),%rdi
call   1080 <strcmp@plt>
cmp    $0x0,%eax
jne    123d <main+0x7d>
lea    0xe59(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
mov    0x2d8b(%rip),%rax
mov    (%rax),%esi
call   10b0 <open@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jge    127e <main+0xbe>
lea    0xe34(%rip),%rdi
call   10c0 <perror@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
mov    -0x14(%rbp),%edi
mov    0x2d60(%rip),%rax
mov    (%rax),%esi
lea    -0x1c(%rbp),%rdx
mov    $0x0,%al
call   1050 <ioctl@plt>
mov    -0x14(%rbp),%edi
mov    0x2d31(%rip),%rax
mov    (%rax),%esi
lea    -0x15(%rbp),%rdx
mov    $0x0,%al
call   1050 <ioctl@plt>
mov    -0x14(%rbp),%edi
mov    0x2d12(%rip),%rax
mov    (%rax),%esi
lea    -0x16(%rbp),%rdx
mov    $0x0,%al
call   1050 <ioctl@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0xd4(%rbp)
mov    $0x80,%edi
call   10e0 <JSIOCGNAME@plt>
mov    -0xd4(%rbp),%edi
mov    %eax,%esi
lea    -0xa0(%rbp),%rdx
mov    $0x0,%al
call   1050 <ioctl@plt>
lea    -0xa0(%rbp),%rsi
movzbl -0x15(%rbp),%edx
movzbl -0x16(%rbp),%ecx
mov    -0x1c(%rbp),%r8d
sar    $0x10,%r8d
mov    -0x1c(%rbp),%r9d
sar    $0x8,%r9d
and    $0xff,%r9d
mov    -0x1c(%rbp),%eax
and    $0xff,%eax
lea    0xdae(%rip),%rdi
mov    %eax,(%rsp)
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xde4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x4,%esi
movzbl -0x15(%rbp),%edi
call   1070 <calloc@plt>
mov    %rax,-0xa8(%rbp)
mov    $0x1,%esi
movzbl -0x16(%rbp),%edi
call   1070 <calloc@plt>
mov    %rax,-0xb0(%rbp)
mov    -0x14(%rbp),%edi
lea    -0xd0(%rbp),%rsi
mov    $0x18,%edx
call   1060 <read@plt>
cltq
cmp    $0x18,%rax
je     1399 <main+0x1d9>
lea    0xda9(%rip),%rdi
call   10c0 <perror@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
mov    -0xd0(%rbp),%eax
mov    0x2c1a(%rip),%rcx
mov    (%rcx),%ecx
not    %ecx
and    %ecx,%eax
mov    %eax,-0xd8(%rbp)
sub    $0x80,%eax
je     13d8 <main+0x218>
jmp    13c2 <main+0x202>
mov    -0xd8(%rbp),%eax
sub    $0x81,%eax
je     13f4 <main+0x234>
jmp    140b <main+0x24b>
mov    -0xc0(%rbp),%edx
mov    -0xb0(%rbp),%rax
mov    -0xc8(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
jmp    140b <main+0x24b>
mov    -0xc0(%rbp),%edx
mov    -0xa8(%rbp),%rax
mov    -0xc8(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
lea    0xd44(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpb   $0x0,-0x15(%rbp)
je     145e <main+0x29e>
mov    -0xa8(%rbp),%rax
mov    (%rax),%eax
mov    $0x16c,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
add    $0x5a,%esi
mov    -0xa8(%rbp),%rax
mov    0x4(%rax),%eax
mov    $0x16c,%ecx
cltd
idiv   %ecx
mov    %eax,%edx
add    $0x5a,%edx
lea    0xd01(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2b53(%rip),%rax
mov    (%rax),%edi
call   10a0 <fflush@plt>
jmp    1363 <main+0x1a3>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xb8,%rsp
movb   $0x2,0x12(%rsp)
movb   $0x2,0x13(%rsp)
movl   $0x800,0x14(%rsp)
movaps 0xe86(%rip),%xmm0
movaps %xmm0,0xa0(%rsp)
movaps 0xe67(%rip),%xmm0
movaps %xmm0,0x90(%rsp)
movaps 0xe48(%rip),%xmm0
movaps %xmm0,0x80(%rsp)
movaps 0xe29(%rip),%xmm0
movaps %xmm0,0x70(%rsp)
movaps 0xe0d(%rip),%xmm0
movaps %xmm0,0x60(%rsp)
movaps 0xdf1(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movaps 0xdd5(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xdb9(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
cmp    $0x2,%edi
jne    1268 <main+0xa8>
mov    0x8(%rsi),%rbx
lea    0xe24(%rip),%rdi
mov    %rbx,%rsi
call   1090 <strcmp@plt>
test   %eax,%eax
jne    127e <main+0xbe>
lea    0xe18(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
mov    0x2d5b(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   10b0 <open@plt>
test   %eax,%eax
jns    129f <main+0xdf>
lea    0xe09(%rip),%rdi
jmp    1454 <main+0x294>
mov    %eax,%r14d
mov    0x2d3f(%rip),%rax
mov    (%rax),%esi
lea    0x14(%rsp),%rdx
mov    %r14d,%edi
xor    %eax,%eax
call   1060 <ioctl@plt>
mov    0x2d0f(%rip),%rax
mov    (%rax),%esi
lea    0x12(%rsp),%rdx
mov    %r14d,%edi
xor    %eax,%eax
call   1060 <ioctl@plt>
mov    0x2cef(%rip),%rax
mov    (%rax),%esi
lea    0x13(%rsp),%rdx
mov    %r14d,%edi
xor    %eax,%eax
call   1060 <ioctl@plt>
mov    $0x80,%edi
call   10e0 <JSIOCGNAME@plt>
lea    0x30(%rsp),%rbx
mov    %r14d,%edi
mov    %eax,%esi
mov    %rbx,%rdx
xor    %eax,%eax
call   1060 <ioctl@plt>
movzbl 0x12(%rsp),%edx
movzbl 0x13(%rsp),%ecx
mov    0x14(%rsp),%eax
movzbl %ah,%ebp
movzbl %al,%esi
sar    $0x10,%eax
mov    %esi,(%rsp)
lea    0xda6(%rip),%rdi
mov    %rbx,%rsi
mov    %eax,%r8d
mov    %ebp,%r9d
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe00(%rip),%rdi
call   1040 <puts@plt>
movzbl 0x12(%rsp),%edi
mov    $0x4,%esi
call   1080 <calloc@plt>
mov    %rax,%rbx
movzbl 0x13(%rsp),%edi
mov    $0x1,%esi
call   1080 <calloc@plt>
mov    %rax,%rbp
lea    0x18(%rsp),%rsi
mov    %r14d,%edi
mov    $0x18,%edx
call   1070 <read@plt>
cmp    $0x18,%eax
jne    144d <main+0x28d>
mov    0x2c35(%rip),%r13
mov    0x2c26(%rip),%r12
lea    0x18(%rsp),%r15
jmp    13c2 <main+0x202>
nopl   0x0(%rax)
mov    (%r12),%edi
call   10a0 <fflush@plt>
mov    %r14d,%edi
mov    %r15,%rsi
mov    $0x18,%edx
call   1070 <read@plt>
cmp    $0x18,%eax
jne    144d <main+0x28d>
mov    0x0(%r13),%eax
not    %eax
and    0x18(%rsp),%eax
mov    %rbp,%rcx
cmp    $0x80,%eax
je     13e0 <main+0x220>
cmp    $0x81,%eax
jne    13ec <main+0x22c>
mov    %rbx,%rcx
mov    0x28(%rsp),%eax
mov    0x20(%rsp),%rdx
mov    %eax,(%rcx,%rdx,4)
mov    $0xd,%edi
call   1030 <putchar@plt>
cmpb   $0x0,0x12(%rsp)
je     13a0 <main+0x1e0>
movslq (%rbx),%rax
imul   $0xffffffffb40b40b5,%rax,%rcx
shr    $0x20,%rcx
add    %eax,%ecx
mov    %ecx,%eax
sar    $0x8,%eax
shr    $0x1f,%ecx
lea    (%rax,%rcx,1),%esi
add    $0x5a,%esi
movslq 0x4(%rbx),%rax
imul   $0xffffffffb40b40b5,%rax,%rcx
shr    $0x20,%rcx
add    %eax,%ecx
mov    %ecx,%eax
sar    $0x8,%eax
shr    $0x1f,%ecx
lea    (%rax,%rcx,1),%edx
add    $0x5a,%edx
lea    0xcf8(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    13a0 <main+0x1e0>
lea    0xcc2(%rip),%rdi
call   10c0 <perror@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>

LLVM IR (-O0):
%struct.js_event = type { i32, i64, i32 }
@__const.main.name = [128 x i8] c"Unknown\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str = [7 x i8] c"--help\00"
@.str.1 = [28 x i8] c"Usage: jscommander <device>\00"
@O_RDONLY = global i32 0
@.str.2 = [44 x i8] c"jscommander: Unable to read file descriptor\00"
@JSIOCGVERSION = global i32 0
@JSIOCGAXES = global i32 0
@JSIOCGBUTTONS = global i32 0
@.str.3 = [71 x i8] c"Joystick (%s) has %d axes and %d buttons. Driver version is %d.%d.%d.\0A\00"
@.str.4 = [29 x i8] c"Running... (SIGINT to exit)\0A\00"
@.str.5 = [35 x i8] c"\0Ajscommander: Error reading device\00"
@JS_EVENT_INIT = global i32 0
@.str.6 = [2 x i8] c"\0D\00"
@.str.7 = [7 x i8] c"%dx%dy\00"
@stdout = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8
%8 = alloca i8
%9 = alloca i32
%10 = alloca [128 x i8]
%11 = alloca i32*
%12 = alloca i32*
%13 = alloca i32
%14 = alloca %struct.js_event
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8 2, i8* %7
store i8 2, i8* %8
store i32 2048, i32* %9
%15 = bitcast [128 x i8]* %10 to i8*
%16 = load i32, i32* %4
%17 = icmp ne i32 %16, 2
br i1 %17, label %24, label %18
18: ; preds = %2
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = call i32 @strcmp(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %21)
%23 = icmp ne i32 %22, 0
br i1 %23, label %27, label %24
24: ; preds = %18, %2
%25 = call i32 @puts(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
%26 = call i32 @exit(i32 1)
unreachable
27: ; preds = %18
%28 = load i8**, i8*** %5
%29 = load i32, i32* %4
%30 = sub nsw i32 %29, 1
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8*, i8** %28, i64 %31
%33 = load i8*, i8** %32
%34 = load i32, i32* @O_RDONLY
%35 = call i32 @open(i8* %33, i32 %34)
store i32 %35, i32* %6
%36 = icmp slt i32 %35, 0
br i1 %36, label %37, label %40
37: ; preds = %27
%38 = call i32 @perror(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0))
%39 = call i32 @exit(i32 1)
unreachable
40: ; preds = %27
%41 = load i32, i32* %6
%42 = load i32, i32* @JSIOCGVERSION
%43 = call i32 (i32, i32, ...) @ioctl(i32 %41, i32 %42, i32* %9)
%44 = load i32, i32* %6
%45 = load i32, i32* @JSIOCGAXES
%46 = call i32 (i32, i32, ...) @ioctl(i32 %44, i32 %45, i8* %7)
%47 = load i32, i32* %6
%48 = load i32, i32* @JSIOCGBUTTONS
%49 = call i32 (i32, i32, ...) @ioctl(i32 %47, i32 %48, i8* %8)
%50 = load i32, i32* %6
%51 = call i32 @JSIOCGNAME(i32 128)
%52 = getelementptr inbounds [128 x i8], [128 x i8]* %10, i64 0, i64 0
%53 = call i32 (i32, i32, ...) @ioctl(i32 %50, i32 %51, i8* %52)
%54 = getelementptr inbounds [128 x i8], [128 x i8]* %10, i64 0, i64 0
%55 = load i8, i8* %7
%56 = zext i8 %55 to i32
%57 = load i8, i8* %8
%58 = zext i8 %57 to i32
%59 = load i32, i32* %9
%60 = ashr i32 %59, 16
%61 = load i32, i32* %9
%62 = ashr i32 %61, 8
%63 = and i32 %62, 255
%64 = load i32, i32* %9
%65 = and i32 %64, 255
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.3, i64 0, i64 0), i8* %54, i32 %56, i32 %58, i32 %60, i32 %63, i32 %65)
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0))
%68 = load i8, i8* %7
%69 = call i32* @calloc(i8 zeroext %68, i32 4)
store i32* %69, i32** %11
%70 = load i8, i8* %8
%71 = call i32* @calloc(i8 zeroext %70, i32 1)
store i32* %71, i32** %12
br label %72
72: ; preds = %40, %116
%73 = load i32, i32* %6
%74 = call i32 @read(i32 %73, %struct.js_event* %14, i32 24)
%75 = sext i32 %74 to i64
%76 = icmp ne i64 %75, 24
br i1 %76, label %77, label %80
77: ; preds = %72
%78 = call i32 @perror(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.5, i64 0, i64 0))
%79 = call i32 @exit(i32 1)
unreachable
80: ; preds = %72
%81 = getelementptr inbounds %struct.js_event, %struct.js_event* %14, i32 0, i32 0
%82 = load i32, i32* %81
%83 = load i32, i32* @JS_EVENT_INIT
%84 = xor i32 %83, -1
%85 = and i32 %82, %84
switch i32 %85, label %100 [
i32 128, label %86
i32 129, label %93
]
86: ; preds = %80
%87 = getelementptr inbounds %struct.js_event, %struct.js_event* %14, i32 0, i32 2
%88 = load i32, i32* %87
%89 = load i32*, i32** %12
%90 = getelementptr inbounds %struct.js_event, %struct.js_event* %14, i32 0, i32 1
%91 = load i64, i64* %90
%92 = getelementptr inbounds i32, i32* %89, i64 %91
store i32 %88, i32* %92
br label %100
93: ; preds = %80
%94 = getelementptr inbounds %struct.js_event, %struct.js_event* %14, i32 0, i32 2
%95 = load i32, i32* %94
%96 = load i32*, i32** %11
%97 = getelementptr inbounds %struct.js_event, %struct.js_event* %14, i32 0, i32 1
%98 = load i64, i64* %97
%99 = getelementptr inbounds i32, i32* %96, i64 %98
store i32 %95, i32* %99
br label %100
100: ; preds = %80, %93, %86
%101 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%102 = load i8, i8* %7
%103 = icmp ne i8 %102, 0
br i1 %103, label %104, label %116
104: ; preds = %100
%105 = load i32*, i32** %11
%106 = getelementptr inbounds i32, i32* %105, i64 0
%107 = load i32, i32* %106
%108 = sdiv i32 %107, 364
%109 = add nsw i32 %108, 90
%110 = load i32*, i32** %11
%111 = getelementptr inbounds i32, i32* %110, i64 1
%112 = load i32, i32* %111
%113 = sdiv i32 %112, 364
%114 = add nsw i32 %113, 90
%115 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i32 %109, i32 %114)
br label %116
116: ; preds = %104, %100
%117 = load i32, i32* @stdout
%118 = call i32 @fflush(i32 %117)
br label %72
}

LLVM IR (-O2):
%struct.js_event = type { i32, i64, i32 }
@__const.main.name = [128 x i8] c"Unknown\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str = [7 x i8] c"--help\00"
@.str.1 = [28 x i8] c"Usage: jscommander <device>\00"
@O_RDONLY = global i32 0
@.str.2 = [44 x i8] c"jscommander: Unable to read file descriptor\00"
@JSIOCGVERSION = global i32 0
@JSIOCGAXES = global i32 0
@JSIOCGBUTTONS = global i32 0
@.str.3 = [71 x i8] c"Joystick (%s) has %d axes and %d buttons. Driver version is %d.%d.%d.\0A\00"
@.str.5 = [35 x i8] c"\0Ajscommander: Error reading device\00"
@JS_EVENT_INIT = global i32 0
@.str.7 = [7 x i8] c"%dx%dy\00"
@stdout = global i32 0
@str = [28 x i8] c"Running... (SIGINT to exit)\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i8
%4 = alloca i8
%5 = alloca i32
%6 = alloca [128 x i8]
%7 = alloca %struct.js_event
store i8 2, i8* %3
store i8 2, i8* %4
%8 = bitcast i32* %5 to i8*
store i32 2048, i32* %5
%9 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%10 = icmp eq i32 %0, 2
br i1 %10, label %11, label %16
11: ; preds = %2
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = tail call i32 @strcmp(i8* dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* dereferenceable(1) %13)
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %11, %2
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
%18 = tail call i32 @exit(i32 1)
unreachable
19: ; preds = %11
%20 = load i32, i32* @O_RDONLY
%21 = tail call i32 @open(i8* %13, i32 %20)
%22 = icmp slt i32 %21, 0
br i1 %22, label %23, label %26
23: ; preds = %19
%24 = tail call i32 @perror(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0))
%25 = tail call i32 @exit(i32 1)
unreachable
26: ; preds = %19
%27 = load i32, i32* @JSIOCGVERSION
%28 = call i32 (i32, i32, ...) @ioctl(i32 %21, i32 %27, i32* %5)
%29 = load i32, i32* @JSIOCGAXES
%30 = call i32 (i32, i32, ...) @ioctl(i32 %21, i32 %29, i8* %3)
%31 = load i32, i32* @JSIOCGBUTTONS
%32 = call i32 (i32, i32, ...) @ioctl(i32 %21, i32 %31, i8* %4)
%33 = call i32 @JSIOCGNAME(i32 128)
%34 = call i32 (i32, i32, ...) @ioctl(i32 %21, i32 %33, i8* %9)
%35 = load i8, i8* %3
%36 = zext i8 %35 to i32
%37 = load i8, i8* %4
%38 = zext i8 %37 to i32
%39 = load i32, i32* %5
%40 = ashr i32 %39, 16
%41 = lshr i32 %39, 8
%42 = and i32 %41, 255
%43 = and i32 %39, 255
%44 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([71 x i8], [71 x i8]* @.str.3, i64 0, i64 0), i8* %9, i32 %36, i32 %38, i32 %40, i32 %42, i32 %43)
%45 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str, i64 0, i64 0))
%46 = bitcast %struct.js_event* %7 to i8*
%47 = load i8, i8* %3
%48 = call i32* @calloc(i8 zeroext %47, i32 4)
%49 = load i8, i8* %4
%50 = call i32* @calloc(i8 zeroext %49, i32 1)
%51 = call i32 @read(i32 %21, %struct.js_event* %7, i32 24)
%52 = icmp eq i32 %51, 24
br i1 %52, label %53, label %58
53: ; preds = %26
%54 = getelementptr inbounds %struct.js_event, %struct.js_event* %7, i64 0, i32 0
%55 = getelementptr inbounds %struct.js_event, %struct.js_event* %7, i64 0, i32 2
%56 = getelementptr inbounds %struct.js_event, %struct.js_event* %7, i64 0, i32 1
%57 = getelementptr inbounds i32, i32* %48, i64 1
br label %61
58: ; preds = %84, %26
%59 = call i32 @perror(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.5, i64 0, i64 0))
%60 = call i32 @exit(i32 1)
unreachable
61: ; preds = %53, %84
%62 = load i32, i32* %54
%63 = load i32, i32* @JS_EVENT_INIT
%64 = xor i32 %63, -1
%65 = and i32 %62, %64
switch i32 %65, label %72 [
i32 128, label %67
i32 129, label %66
]
66: ; preds = %61
br label %67
67: ; preds = %61, %66
%68 = phi i32* [ %48, %66 ], [ %50, %61 ]
%69 = load i32, i32* %55
%70 = load i64, i64* %56
%71 = getelementptr inbounds i32, i32* %68, i64 %70
store i32 %69, i32* %71
br label %72
72: ; preds = %67, %61
%73 = call i32 @putchar(i32 13)
%74 = load i8, i8* %3
%75 = icmp eq i8 %74, 0
br i1 %75, label %84, label %76
76: ; preds = %72
%77 = load i32, i32* %48
%78 = sdiv i32 %77, 364
%79 = add nsw i32 %78, 90
%80 = load i32, i32* %57
%81 = sdiv i32 %80, 364
%82 = add nsw i32 %81, 90
%83 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i32 %79, i32 %82)
br label %84
84: ; preds = %76, %72
%85 = load i32, i32* @stdout
%86 = call i32 @fflush(i32 %85)
%87 = call i32 @read(i32 %21, %struct.js_event* %7, i32 24)
%88 = icmp eq i32 %87, 24
br i1 %88, label %61, label %58
}