#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 {
  scalar_t__ type;
  int number;
  scalar_t__ value;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
scalar_t__ EINVAL;
scalar_t__ JS_EVENT_AXIS;
int /*<<< orphan*/ O_RDONLY;
scalar_t__ errno;
int /*<<< orphan*/ exit(int);
int fileno(int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ keydown(int, char *, int *);
int /*<<< orphan*/ keyup(int, char *, int *);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ *popen(char *, char *);
int /*<<< orphan*/ read(int, struct js_event *, int);
int /*<<< orphan*/ setlinebuf(int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
int strtol(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ usage(char *);
int main(int argc, char **argv) {
  if (argc < 4)
    usage(argv[0]);
  int js_fd = open(argv[1], O_RDONLY);
  if (js_fd == -1) {
    perror("Couldn't open joystick");
    usage(argv[0]);
  }
  int xaxis = strtol(argv[2], 0, 10);
  if (xaxis == 0 && errno == EINVAL)
    usage(argv[0]);
  int zaxis = strtol(argv[3], 0, 10);
  if (zaxis == 0 && errno == EINVAL)
    usage(argv[0]);
  FILE *xte = popen("xte", "w");
  if (xte == NULL) {
    fprintf(stderr, "Couldn't start xte. Did you install xautomation?\n");
    exit(1);
  }
  setlinebuf(xte);
  int xte_fd = fileno(xte);
  int n, e, s, w;
  n = e = s = w = 0;
  while (1) {
    struct js_event ev;
    read(js_fd, &ev, sizeof(struct js_event));
    if (ev.type == JS_EVENT_AXIS) {
      if (ev.number == xaxis) {
        if (ev.value < 0)
          keydown(xte_fd, "Left", &w);
        else if (ev.value > 0)
          keydown(xte_fd, "Right", &e);
        else {
          keyup(xte_fd, "Left", &w);
          keyup(xte_fd, "Right", &e);
        }
      } else if (ev.number == zaxis) {
        if (ev.value < 0)
          keydown(xte_fd, "Up", &n);
        else if (ev.value > 0)
          keydown(xte_fd, "Down", &s);
        else {
          keyup(xte_fd, "Up", &n);
          keyup(xte_fd, "Down", &s);
        }
      }
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x4,-0x8(%rbp)
jge    11ec <main+0x2c>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1090 <usage@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2ded(%rip),%rax
mov    (%rax),%esi
call   10a0 <open@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    1227 <main+0x67>
lea    0xdea(%rip),%rdi
call   10c0 <perror@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1090 <usage@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1070 <strtol@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jne    126e <main+0xae>
mov    0x2d79(%rip),%rax
mov    (%rax),%rax
mov    0x2d67(%rip),%rcx
cmp    (%rcx),%rax
jne    126e <main+0xae>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1090 <usage@plt>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1070 <strtol@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jne    12b5 <main+0xf5>
mov    0x2d32(%rip),%rax
mov    (%rax),%rax
mov    0x2d20(%rip),%rcx
cmp    (%rcx),%rax
jne    12b5 <main+0xf5>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1090 <usage@plt>
lea    0xd5b(%rip),%rdi
lea    0xd58(%rip),%rsi
call   10b0 <popen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    12f6 <main+0x136>
mov    0x2cf2(%rip),%rax
mov    (%rax),%edi
lea    0xd36(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
mov    -0x28(%rbp),%rdi
call   1030 <setlinebuf@plt>
mov    -0x28(%rbp),%rdi
call   1080 <fileno@plt>
mov    %eax,-0x2c(%rbp)
movl   $0x0,-0x3c(%rbp)
movl   $0x0,-0x38(%rbp)
movl   $0x0,-0x34(%rbp)
movl   $0x0,-0x30(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x58(%rbp),%rsi
mov    $0x18,%edx
call   1050 <read@plt>
mov    -0x58(%rbp),%rax
mov    0x2c9d(%rip),%rcx
cmp    (%rcx),%rax
jne    145a <main+0x29a>
mov    -0x50(%rbp),%eax
cmp    -0x18(%rbp),%eax
jne    13ce <main+0x20e>
cmpq   $0x0,-0x48(%rbp)
jge    137b <main+0x1bb>
mov    -0x2c(%rbp),%edi
lea    0xce2(%rip),%rsi
lea    -0x3c(%rbp),%rdx
call   1040 <keydown@plt>
jmp    13c9 <main+0x209>
cmpq   $0x0,-0x48(%rbp)
jle    139e <main+0x1de>
mov    -0x2c(%rbp),%edi
lea    0xcc4(%rip),%rsi
lea    -0x34(%rbp),%rdx
call   1040 <keydown@plt>
jmp    13c4 <main+0x204>
mov    -0x2c(%rbp),%edi
lea    0xca7(%rip),%rsi
lea    -0x3c(%rbp),%rdx
call   10e0 <keyup@plt>
mov    -0x2c(%rbp),%edi
lea    0xc99(%rip),%rsi
lea    -0x34(%rbp),%rdx
call   10e0 <keyup@plt>
jmp    13c9 <main+0x209>
jmp    1455 <main+0x295>
mov    -0x50(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jne    1450 <main+0x290>
cmpq   $0x0,-0x48(%rbp)
jge    13fd <main+0x23d>
mov    -0x2c(%rbp),%edi
lea    0xc6b(%rip),%rsi
lea    -0x30(%rbp),%rdx
call   1040 <keydown@plt>
jmp    144b <main+0x28b>
cmpq   $0x0,-0x48(%rbp)
jle    1420 <main+0x260>
mov    -0x2c(%rbp),%edi
lea    0xc4b(%rip),%rsi
lea    -0x38(%rbp),%rdx
call   1040 <keydown@plt>
jmp    1446 <main+0x286>
mov    -0x2c(%rbp),%edi
lea    0xc30(%rip),%rsi
lea    -0x30(%rbp),%rdx
call   10e0 <keyup@plt>
mov    -0x2c(%rbp),%edi
lea    0xc20(%rip),%rsi
lea    -0x38(%rbp),%rdx
call   10e0 <keyup@plt>
jmp    144b <main+0x28b>
jmp    1450 <main+0x290>
jmp    1455 <main+0x295>
jmp    145a <main+0x29a>
jmp    1327 <main+0x167>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%rbp
cmp    $0x3,%edi
jg     11df <main+0x1f>
mov    0x0(%rbp),%rdi
call   1090 <usage@plt>
mov    0x8(%rbp),%rdi
mov    0x2dfe(%rip),%rax
mov    (%rax),%esi
call   10a0 <open@plt>
mov    %eax,%ebx
cmp    $0xffffffff,%eax
je     13c0 <main+0x200>
mov    0x10(%rbp),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1070 <strtol@plt>
mov    %eax,%r15d
test   %eax,%eax
jne    1232 <main+0x72>
mov    0x2dae(%rip),%rax
mov    (%rax),%rax
mov    0x2d9c(%rip),%rcx
cmp    (%rcx),%rax
jne    1232 <main+0x72>
mov    0x0(%rbp),%rdi
call   1090 <usage@plt>
mov    0x18(%rbp),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1070 <strtol@plt>
mov    %eax,%r14d
test   %eax,%eax
jne    1268 <main+0xa8>
mov    0x2d78(%rip),%rax
mov    (%rax),%rax
mov    0x2d66(%rip),%rcx
cmp    (%rcx),%rax
jne    1268 <main+0xa8>
mov    0x0(%rbp),%rdi
call   1090 <usage@plt>
lea    0xda8(%rip),%rdi
lea    0xda5(%rip),%rsi
call   10b0 <popen@plt>
test   %rax,%rax
je     13da <main+0x21a>
mov    %rax,%rbp
mov    %rax,%rdi
call   1030 <setlinebuf@plt>
mov    %rbp,%rdi
call   1080 <fileno@plt>
mov    %eax,%r12d
movl   $0x0,(%rsp)
movl   $0x0,0x4(%rsp)
movl   $0x0,0x8(%rsp)
movl   $0x0,0xc(%rsp)
lea    0x10(%rsp),%rbp
mov    0x2d1b(%rip),%r13
jmp    12e0 <main+0x120>
mov    %r12d,%edi
lea    0xd7e(%rip),%rsi
mov    %rsp,%rdx
call   1040 <keydown@plt>
nopl   0x0(%rax)
mov    %ebx,%edi
mov    %rbp,%rsi
mov    $0x18,%edx
call   1050 <read@plt>
mov    0x10(%rsp),%rax
cmp    0x0(%r13),%rax
jne    12e0 <main+0x120>
mov    0x18(%rsp),%eax
cmp    %r15d,%eax
jne    1330 <main+0x170>
cmpq   $0x0,0x20(%rsp)
js     12c7 <main+0x107>
mov    %r12d,%edi
je     1355 <main+0x195>
lea    0xd3d(%rip),%rsi
lea    0x8(%rsp),%rdx
call   1040 <keydown@plt>
jmp    12e0 <main+0x120>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
cmp    %r14d,%eax
jne    12e0 <main+0x120>
cmpq   $0x0,0x20(%rsp)
js     137d <main+0x1bd>
mov    %r12d,%edi
je     1396 <main+0x1d6>
lea    0xd14(%rip),%rsi
lea    0x4(%rsp),%rdx
call   1040 <keydown@plt>
jmp    12e0 <main+0x120>
lea    0xcf3(%rip),%rsi
mov    %rsp,%rdx
call   10e0 <keyup@plt>
mov    %r12d,%edi
lea    0xce6(%rip),%rsi
lea    0x8(%rsp),%rdx
call   10e0 <keyup@plt>
jmp    12e0 <main+0x120>
mov    %r12d,%edi
lea    0xcd3(%rip),%rsi
lea    0xc(%rsp),%rdx
call   1040 <keydown@plt>
jmp    12e0 <main+0x120>
lea    0xcbd(%rip),%rsi
lea    0xc(%rsp),%rdx
call   10e0 <keyup@plt>
mov    %r12d,%edi
lea    0xcac(%rip),%rsi
lea    0x4(%rsp),%rdx
call   10e0 <keyup@plt>
jmp    12e0 <main+0x120>
lea    0xc39(%rip),%rdi
call   10c0 <perror@plt>
mov    0x0(%rbp),%rdi
call   1090 <usage@plt>
jmp    11fc <main+0x3c>
mov    0x2bef(%rip),%rax
mov    (%rax),%edi
lea    0xc33(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>

LLVM IR (-O0):
%struct.js_event = type { i64, i32, i64 }
@O_RDONLY = global i32 0
@.str = [23 x i8] c"Couldn't open joystick\00"
@errno = global i64 0
@EINVAL = global i64 0
@.str.1 = [4 x i8] c"xte\00"
@.str.2 = [2 x i8] c"w\00"
@stderr = global i32 0
@.str.3 = [50 x i8] c"Couldn't start xte. Did you install xautomation?\0A\00"
@JS_EVENT_AXIS = global i64 0
@.str.4 = [5 x i8] c"Left\00"
@.str.5 = [6 x i8] c"Right\00"
@.str.6 = [3 x i8] c"Up\00"
@.str.7 = [5 x i8] c"Down\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca %struct.js_event
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%16 = load i32, i32* %4
%17 = icmp slt i32 %16, 4
br i1 %17, label %18, label %23
18: ; preds = %2
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 0
%21 = load i8*, i8** %20
%22 = call i32 @usage(i8* %21)
br label %23
23: ; preds = %18, %2
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
%27 = load i32, i32* @O_RDONLY
%28 = call i32 @open(i8* %26, i32 %27)
store i32 %28, i32* %6
%29 = load i32, i32* %6
%30 = icmp eq i32 %29, -1
br i1 %30, label %31, label %37
31: ; preds = %23
%32 = call i32 @perror(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 0
%35 = load i8*, i8** %34
%36 = call i32 @usage(i8* %35)
br label %37
37: ; preds = %31, %23
%38 = load i8**, i8*** %5
%39 = getelementptr inbounds i8*, i8** %38, i64 2
%40 = load i8*, i8** %39
%41 = call i32 @strtol(i8* %40, i32 0, i32 10)
store i32 %41, i32* %7
%42 = load i32, i32* %7
%43 = icmp eq i32 %42, 0
br i1 %43, label %44, label %53
44: ; preds = %37
%45 = load i64, i64* @errno
%46 = load i64, i64* @EINVAL
%47 = icmp eq i64 %45, %46
br i1 %47, label %48, label %53
48: ; preds = %44
%49 = load i8**, i8*** %5
%50 = getelementptr inbounds i8*, i8** %49, i64 0
%51 = load i8*, i8** %50
%52 = call i32 @usage(i8* %51)
br label %53
53: ; preds = %48, %44, %37
%54 = load i8**, i8*** %5
%55 = getelementptr inbounds i8*, i8** %54, i64 3
%56 = load i8*, i8** %55
%57 = call i32 @strtol(i8* %56, i32 0, i32 10)
store i32 %57, i32* %8
%58 = load i32, i32* %8
%59 = icmp eq i32 %58, 0
br i1 %59, label %60, label %69
60: ; preds = %53
%61 = load i64, i64* @errno
%62 = load i64, i64* @EINVAL
%63 = icmp eq i64 %61, %62
br i1 %63, label %64, label %69
64: ; preds = %60
%65 = load i8**, i8*** %5
%66 = getelementptr inbounds i8*, i8** %65, i64 0
%67 = load i8*, i8** %66
%68 = call i32 @usage(i8* %67)
br label %69
69: ; preds = %64, %60, %53
%70 = call i32* @popen(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %70, i32** %9
%71 = load i32*, i32** %9
%72 = icmp eq i32* %71, null
br i1 %72, label %73, label %77
73: ; preds = %69
%74 = load i32, i32* @stderr
%75 = call i32 @fprintf(i32 %74, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.3, i64 0, i64 0))
%76 = call i32 @exit(i32 1)
unreachable
77: ; preds = %69
%78 = load i32*, i32** %9
%79 = call i32 @setlinebuf(i32* %78)
%80 = load i32*, i32** %9
%81 = call i32 @fileno(i32* %80)
store i32 %81, i32* %10
store i32 0, i32* %14
store i32 0, i32* %13
store i32 0, i32* %12
store i32 0, i32* %11
br label %82
82: ; preds = %77, %143
%83 = load i32, i32* %6
%84 = call i32 @read(i32 %83, %struct.js_event* %15, i32 24)
%85 = getelementptr inbounds %struct.js_event, %struct.js_event* %15, i32 0, i32 0
%86 = load i64, i64* %85
%87 = load i64, i64* @JS_EVENT_AXIS
%88 = icmp eq i64 %86, %87
br i1 %88, label %89, label %143
89: ; preds = %82
%90 = getelementptr inbounds %struct.js_event, %struct.js_event* %15, i32 0, i32 1
%91 = load i32, i32* %90
%92 = load i32, i32* %7
%93 = icmp eq i32 %91, %92
br i1 %93, label %94, label %115
94: ; preds = %89
%95 = getelementptr inbounds %struct.js_event, %struct.js_event* %15, i32 0, i32 2
%96 = load i64, i64* %95
%97 = icmp slt i64 %96, 0
br i1 %97, label %98, label %101
98: ; preds = %94
%99 = load i32, i32* %10
%100 = call i32 @keydown(i32 %99, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32* %14)
br label %114
101: ; preds = %94
%102 = getelementptr inbounds %struct.js_event, %struct.js_event* %15, i32 0, i32 2
%103 = load i64, i64* %102
%104 = icmp sgt i64 %103, 0
br i1 %104, label %105, label %108
105: ; preds = %101
%106 = load i32, i32* %10
%107 = call i32 @keydown(i32 %106, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i32* %12)
br label %113
108: ; preds = %101
%109 = load i32, i32* %10
%110 = call i32 @keyup(i32 %109, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32* %14)
%111 = load i32, i32* %10
%112 = call i32 @keyup(i32 %111, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i32* %12)
br label %113
113: ; preds = %108, %105
br label %114
114: ; preds = %113, %98
br label %142
115: ; preds = %89
%116 = getelementptr inbounds %struct.js_event, %struct.js_event* %15, i32 0, i32 1
%117 = load i32, i32* %116
%118 = load i32, i32* %8
%119 = icmp eq i32 %117, %118
br i1 %119, label %120, label %141
120: ; preds = %115
%121 = getelementptr inbounds %struct.js_event, %struct.js_event* %15, i32 0, i32 2
%122 = load i64, i64* %121
%123 = icmp slt i64 %122, 0
br i1 %123, label %124, label %127
124: ; preds = %120
%125 = load i32, i32* %10
%126 = call i32 @keydown(i32 %125, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %11)
br label %140
127: ; preds = %120
%128 = getelementptr inbounds %struct.js_event, %struct.js_event* %15, i32 0, i32 2
%129 = load i64, i64* %128
%130 = icmp sgt i64 %129, 0
br i1 %130, label %131, label %134
131: ; preds = %127
%132 = load i32, i32* %10
%133 = call i32 @keydown(i32 %132, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i32* %13)
br label %139
134: ; preds = %127
%135 = load i32, i32* %10
%136 = call i32 @keyup(i32 %135, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %11)
%137 = load i32, i32* %10
%138 = call i32 @keyup(i32 %137, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i32* %13)
br label %139
139: ; preds = %134, %131
br label %140
140: ; preds = %139, %124
br label %141
141: ; preds = %140, %115
br label %142
142: ; preds = %141, %114
br label %143
143: ; preds = %142, %82
br label %82
}

LLVM IR (-O2):
%struct.js_event = type { i64, i32, i64 }
@O_RDONLY = global i32 0
@.str = [23 x i8] c"Couldn't open joystick\00"
@errno = global i64 0
@EINVAL = global i64 0
@.str.1 = [4 x i8] c"xte\00"
@.str.2 = [2 x i8] c"w\00"
@stderr = global i32 0
@.str.3 = [50 x i8] c"Couldn't start xte. Did you install xautomation?\0A\00"
@JS_EVENT_AXIS = global i64 0
@.str.4 = [5 x i8] c"Left\00"
@.str.5 = [6 x i8] c"Right\00"
@.str.6 = [3 x i8] c"Up\00"
@.str.7 = [5 x i8] c"Down\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca %struct.js_event
%8 = icmp slt i32 %0, 4
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = load i8*, i8** %1
%11 = tail call i32 @usage(i8* %10)
br label %12
12: ; preds = %9, %2
%13 = getelementptr inbounds i8*, i8** %1, i64 1
%14 = load i8*, i8** %13
%15 = load i32, i32* @O_RDONLY
%16 = tail call i32 @open(i8* %14, i32 %15)
%17 = icmp eq i32 %16, -1
br i1 %17, label %18, label %22
18: ; preds = %12
%19 = tail call i32 @perror(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%20 = load i8*, i8** %1
%21 = tail call i32 @usage(i8* %20)
br label %22
22: ; preds = %18, %12
%23 = getelementptr inbounds i8*, i8** %1, i64 2
%24 = load i8*, i8** %23
%25 = tail call i32 @strtol(i8* %24, i32 0, i32 10)
%26 = icmp eq i32 %25, 0
br i1 %26, label %27, label %34
27: ; preds = %22
%28 = load i64, i64* @errno
%29 = load i64, i64* @EINVAL
%30 = icmp eq i64 %28, %29
br i1 %30, label %31, label %34
31: ; preds = %27
%32 = load i8*, i8** %1
%33 = tail call i32 @usage(i8* %32)
br label %34
34: ; preds = %31, %27, %22
%35 = getelementptr inbounds i8*, i8** %1, i64 3
%36 = load i8*, i8** %35
%37 = tail call i32 @strtol(i8* %36, i32 0, i32 10)
%38 = icmp eq i32 %37, 0
br i1 %38, label %39, label %46
39: ; preds = %34
%40 = load i64, i64* @errno
%41 = load i64, i64* @EINVAL
%42 = icmp eq i64 %40, %41
br i1 %42, label %43, label %46
43: ; preds = %39
%44 = load i8*, i8** %1
%45 = tail call i32 @usage(i8* %44)
br label %46
46: ; preds = %43, %39, %34
%47 = tail call i32* @popen(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%48 = icmp eq i32* %47, null
br i1 %48, label %49, label %53
49: ; preds = %46
%50 = load i32, i32* @stderr
%51 = tail call i32 @fprintf(i32 %50, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.3, i64 0, i64 0))
%52 = tail call i32 @exit(i32 1)
unreachable
53: ; preds = %46
%54 = tail call i32 @setlinebuf(i32* %47)
%55 = tail call i32 @fileno(i32* %47)
%56 = bitcast i32* %3 to i8*
%57 = bitcast i32* %4 to i8*
%58 = bitcast i32* %5 to i8*
%59 = bitcast i32* %6 to i8*
store i32 0, i32* %6
store i32 0, i32* %5
store i32 0, i32* %4
store i32 0, i32* %3
%60 = bitcast %struct.js_event* %7 to i8*
%61 = getelementptr inbounds %struct.js_event, %struct.js_event* %7, i64 0, i32 0
%62 = getelementptr inbounds %struct.js_event, %struct.js_event* %7, i64 0, i32 1
%63 = getelementptr inbounds %struct.js_event, %struct.js_event* %7, i64 0, i32 2
br label %64
64: ; preds = %98, %53
%65 = call i32 @read(i32 %16, %struct.js_event* %7, i32 24)
%66 = load i64, i64* %61
%67 = load i64, i64* @JS_EVENT_AXIS
%68 = icmp eq i64 %66, %67
br i1 %68, label %69, label %98
69: ; preds = %64
%70 = load i32, i32* %62
%71 = icmp eq i32 %70, %25
br i1 %71, label %72, label %84
72: ; preds = %69
%73 = load i64, i64* %63
%74 = icmp slt i64 %73, 0
br i1 %74, label %75, label %77
75: ; preds = %72
%76 = call i32 @keydown(i32 %55, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32* %6)
br label %98
77: ; preds = %72
%78 = icmp eq i64 %73, 0
br i1 %78, label %81, label %79
79: ; preds = %77
%80 = call i32 @keydown(i32 %55, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i32* %4)
br label %98
81: ; preds = %77
%82 = call i32 @keyup(i32 %55, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32* %6)
%83 = call i32 @keyup(i32 %55, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i32* %4)
br label %98
84: ; preds = %69
%85 = icmp eq i32 %70, %37
br i1 %85, label %86, label %98
86: ; preds = %84
%87 = load i64, i64* %63
%88 = icmp slt i64 %87, 0
br i1 %88, label %89, label %91
89: ; preds = %86
%90 = call i32 @keydown(i32 %55, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %3)
br label %98
91: ; preds = %86
%92 = icmp eq i64 %87, 0
br i1 %92, label %95, label %93
93: ; preds = %91
%94 = call i32 @keydown(i32 %55, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i32* %5)
br label %98
95: ; preds = %91
%96 = call i32 @keyup(i32 %55, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %3)
%97 = call i32 @keyup(i32 %55, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i32* %5)
br label %98
98: ; preds = %79, %81, %75, %89, %95, %93, %84, %64
br label %64
}