#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 timeval {
  int tv_sec;
  scalar_t__ tv_usec;
};
struct js_event {
  int x;
  int y;
  int buttons;
  int type;
  size_t number;
  int value;
  int time;
};
struct JS_DATA_TYPE {
  int x;
  int y;
  int buttons;
  int type;
  size_t number;
  int value;
  int time;
};
typedef int /*<<< orphan*/ fd_set;

/* Variables and functions */
scalar_t__ EAGAIN;
int /*<<< orphan*/ FD_SET(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ FD_ZERO(int /*<<< orphan*/ *);
int /*<<< orphan*/ F_SETFL;
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;
scalar_t__ JS_RETURN;
int /*<<< orphan*/ O_NONBLOCK;
int /*<<< orphan*/ O_RDONLY;
int *calloc(unsigned char, int);
scalar_t__ errno;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fcntl(int, int /*<<< orphan*/, int /*<<< orphan*/);
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);
scalar_t__ select(int, int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                  int /*<<< orphan*/ *, struct timeval *);
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ strcmp(char *, char *);
int /*<<< orphan*/ usleep(int);
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 || argc > 3 || !strcmp("--help", argv[1])) {
    puts("");
    puts("Usage: jstest [<mode>] <device>");
    puts("");
    puts("Modes:");
    puts("  --normal           One-line mode showing immediate status");
    puts("  --old              Same as --normal, using 0.x interface");
    puts("  --event            Prints events as they come in");
    puts("  --nonblock         Same as --event, in nonblocking mode");
    puts("  --select           Same as --event, using select() call");
    puts("");
    exit(1);
  }
  if ((fd = open(argv[argc - 1], O_RDONLY)) < 0) {
    perror("jstest");
    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("Testing ... (interrupt to exit)\n");
  if ((argc == 2 && version < 0x010000) || !strcmp("--old", argv[1])) {
    struct JS_DATA_TYPE js;
    while (1) {
      if (read(fd, &js, JS_RETURN) != JS_RETURN) {
        perror("\njstest: error reading");
        exit(1);
      }
      printf("Axes: X:%3d Y:%3d Buttons: A:%s B:%s\r", js.x, js.y,
             (js.buttons & 1) ? "on " : "off",
             (js.buttons & 2) ? "on " : "off");
      fflush(stdout);
      usleep(10000);
    }
  }
  if (argc == 2 || !strcmp("--normal", argv[1])) {
    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("\njstest: error reading");
        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("Axes: ");
        for (i = 0; i < axes; i++)
          printf("%2d:%6d ", i, axis[i]);
      }
      if (buttons) {
        printf("Buttons: ");
        for (i = 0; i < buttons; i++)
          printf("%2d:%s ", i, button[i] ? "on " : "off");
      }
      fflush(stdout);
    }
  }
  if (!strcmp("--event", argv[1])) {
    struct js_event js;
    while (1) {
      if (read(fd, &js, sizeof(struct js_event)) != sizeof(struct js_event)) {
        perror("\njstest: error reading");
        exit(1);
      }
      printf("Event: type %d, time %d, number %d, value %d\n", js.type, js.time,
             js.number, js.value);
    }
  }
  if (!strcmp("--nonblock", argv[1])) {
    struct js_event js;
    fcntl(fd, F_SETFL, O_NONBLOCK);
    while (1) {
      while (read(fd, &js, sizeof(struct js_event)) ==
             sizeof(struct js_event)) {
        printf("Event: type %d, time %d, number %d, value %d\n", js.type,
               js.time, js.number, js.value);
      }
      if (errno != EAGAIN) {
        perror("\njstest: error reading");
        exit(1);
      }
      usleep(10000);
    }
  }
  if (!strcmp("--select", argv[1])) {
    struct js_event js;
    struct timeval tv;
    fd_set set;
    tv.tv_sec = 1;
    tv.tv_usec = 0;
    while (1) {
      FD_ZERO(&set);
      FD_SET(fd, &set);
      if (select(fd + 1, &set, NULL, NULL, &tv)) {
        if (read(fd, &js, sizeof(struct js_event)) != sizeof(struct js_event)) {
          perror("\njstest: error reading");
          exit(1);
        }
        printf("Event: type %d, time %d, number %d, value %d\n", js.type,
               js.time, js.number, js.value);
      }
    }
  }
  printf("jstest: unknown mode: %s\n", argv[1]);
  return -1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x180,%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    0xdba(%rip),%rsi
mov    $0x80,%edx
call   10a0 <memcpy@plt>
cmpl   $0x2,-0x8(%rbp)
jl     1281 <main+0x71>
cmpl   $0x3,-0x8(%rbp)
jg     1281 <main+0x71>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe0d(%rip),%rdi
call   1090 <strcmp@plt>
cmp    $0x0,%eax
jne    1303 <main+0xf3>
lea    0xfb2(%rip),%rdi
call   1030 <puts@plt>
lea    0xdf3(%rip),%rdi
call   1030 <puts@plt>
lea    0xf9a(%rip),%rdi
call   1030 <puts@plt>
lea    0xdfb(%rip),%rdi
call   1030 <puts@plt>
lea    0xdf6(%rip),%rdi
call   1030 <puts@plt>
lea    0xe26(%rip),%rdi
call   1030 <puts@plt>
lea    0xe55(%rip),%rdi
call   1030 <puts@plt>
lea    0xe7c(%rip),%rdi
call   1030 <puts@plt>
lea    0xeaa(%rip),%rdi
call   1030 <puts@plt>
lea    0xf46(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1100 <exit@plt>
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
mov    0x2cb5(%rip),%rax
mov    (%rax),%esi
call   10e0 <open@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jge    1344 <main+0x134>
lea    0xe97(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x1,%edi
call   1100 <exit@plt>
mov    -0x14(%rbp),%edi
mov    0x2c9a(%rip),%rax
mov    (%rax),%esi
lea    -0x1c(%rbp),%rdx
mov    $0x0,%al
call   1060 <ioctl@plt>
mov    -0x14(%rbp),%edi
mov    0x2c5b(%rip),%rax
mov    (%rax),%esi
lea    -0x15(%rbp),%rdx
mov    $0x0,%al
call   1060 <ioctl@plt>
mov    -0x14(%rbp),%edi
mov    0x2c34(%rip),%rax
mov    (%rax),%esi
lea    -0x16(%rbp),%rdx
mov    $0x0,%al
call   1060 <ioctl@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x170(%rbp)
mov    $0x80,%edi
call   1110 <JSIOCGNAME@plt>
mov    -0x170(%rbp),%edi
mov    %eax,%esi
lea    -0xa0(%rbp),%rdx
mov    $0x0,%al
call   1060 <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    0xdec(%rip),%rdi
mov    %eax,(%rsp)
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe22(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
cmpl   $0x2,-0x8(%rbp)
jne    1416 <main+0x206>
cmpl   $0x10000,-0x1c(%rbp)
jl     1433 <main+0x223>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe16(%rip),%rdi
call   1090 <strcmp@plt>
cmp    $0x0,%eax
jne    14ee <main+0x2de>
jmp    1438 <main+0x228>
mov    -0x14(%rbp),%edi
lea    -0xc0(%rbp),%rsi
mov    0x2b97(%rip),%rax
mov    (%rax),%rax
mov    %eax,%edx
call   1070 <read@plt>
cltq
mov    0x2b84(%rip),%rcx
cmp    (%rcx),%rax
je     147b <main+0x26b>
lea    0xdd5(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x1,%edi
call   1100 <exit@plt>
mov    -0xc0(%rbp),%esi
mov    -0xbc(%rbp),%edx
mov    -0xb8(%rbp),%edi
and    $0x1,%edi
lea    0xdeb(%rip),%rcx
lea    0xde0(%rip),%rax
cmp    $0x0,%edi
cmovne %rax,%rcx
mov    -0xb8(%rbp),%edi
and    $0x2,%edi
lea    0xdcd(%rip),%r8
lea    0xdc2(%rip),%rax
cmp    $0x0,%edi
cmovne %rax,%r8
lea    0xd8e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2ac0(%rip),%rax
mov    (%rax),%edi
call   10d0 <fflush@plt>
mov    $0x2710,%edi
call   1130 <usleep@plt>
jmp    1438 <main+0x228>
cmpl   $0x2,-0x8(%rbp)
je     1515 <main+0x305>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xd7f(%rip),%rdi
call   1090 <strcmp@plt>
cmp    $0x0,%eax
jne    1701 <main+0x4f1>
mov    $0x4,%esi
movzbl -0x15(%rbp),%edi
call   1080 <calloc@plt>
mov    %rax,-0xc8(%rbp)
mov    $0x1,%esi
movzbl -0x16(%rbp),%edi
call   1080 <calloc@plt>
mov    %rax,-0xd0(%rbp)
mov    -0x14(%rbp),%edi
lea    -0xf8(%rbp),%rsi
mov    $0x20,%edx
call   1070 <read@plt>
cltq
cmp    $0x20,%rax
je     1575 <main+0x365>
lea    0xcdb(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x1,%edi
call   1100 <exit@plt>
mov    -0xec(%rbp),%eax
mov    0x2a1e(%rip),%rcx
mov    (%rcx),%ecx
not    %ecx
and    %ecx,%eax
mov    %eax,-0x174(%rbp)
sub    $0x80,%eax
je     15b4 <main+0x3a4>
jmp    159e <main+0x38e>
mov    -0x174(%rbp),%eax
sub    $0x81,%eax
je     15d0 <main+0x3c0>
jmp    15e7 <main+0x3d7>
mov    -0xe0(%rbp),%edx
mov    -0xd0(%rbp),%rax
mov    -0xe8(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
jmp    15e7 <main+0x3d7>
mov    -0xe0(%rbp),%edx
mov    -0xc8(%rbp),%rax
mov    -0xe8(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
lea    0xc8e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
cmpb   $0x0,-0x15(%rbp)
je     1667 <main+0x457>
lea    0xc89(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0xd4(%rbp)
mov    -0xd4(%rbp),%eax
movzbl -0x15(%rbp),%ecx
cmp    %ecx,%eax
jge    1662 <main+0x452>
mov    -0xd4(%rbp),%esi
mov    -0xc8(%rbp),%rax
movslq -0xd4(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
lea    0xc4f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0xd4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xd4(%rbp)
jmp    1617 <main+0x407>
jmp    1667 <main+0x457>
cmpb   $0x0,-0x16(%rbp)
je     16ee <main+0x4de>
lea    0xc27(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0xd4(%rbp)
mov    -0xd4(%rbp),%eax
movzbl -0x16(%rbp),%ecx
cmp    %ecx,%eax
jge    16e9 <main+0x4d9>
mov    -0xd4(%rbp),%esi
mov    -0xd0(%rbp),%rax
movslq -0xd4(%rbp),%rcx
mov    (%rax,%rcx,4),%ecx
lea    0xbc9(%rip),%rdx
lea    0xbbe(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rdx
lea    0xbdb(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0xd4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xd4(%rbp)
jmp    1689 <main+0x479>
jmp    16ee <main+0x4de>
mov    0x28a3(%rip),%rax
mov    (%rax),%edi
call   10d0 <fflush@plt>
jmp    153f <main+0x32f>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xba1(%rip),%rdi
call   1090 <strcmp@plt>
cmp    $0x0,%eax
jne    1786 <main+0x576>
jmp    1723 <main+0x513>
mov    -0x14(%rbp),%edi
lea    -0x118(%rbp),%rsi
mov    $0x20,%edx
call   1070 <read@plt>
cltq
cmp    $0x20,%rax
je     1759 <main+0x549>
lea    0xaf7(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x1,%edi
call   1100 <exit@plt>
mov    -0x10c(%rbp),%esi
mov    -0xfc(%rbp),%edx
mov    -0x108(%rbp),%rcx
mov    -0x100(%rbp),%r8d
lea    0xb3f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1723 <main+0x513>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xb52(%rip),%rdi
call   1090 <strcmp@plt>
cmp    $0x0,%eax
jne    184e <main+0x63e>
mov    -0x14(%rbp),%edi
mov    0x280b(%rip),%rax
mov    (%rax),%esi
mov    0x2822(%rip),%rax
mov    (%rax),%edx
call   1040 <fcntl@plt>
jmp    17c2 <main+0x5b2>
mov    -0x14(%rbp),%edi
lea    -0x138(%rbp),%rsi
mov    $0x20,%edx
call   1070 <read@plt>
cltq
cmp    $0x20,%rax
jne    180f <main+0x5ff>
mov    -0x12c(%rbp),%esi
mov    -0x11c(%rbp),%edx
mov    -0x128(%rbp),%rcx
mov    -0x120(%rbp),%r8d
lea    0xab6(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    17c2 <main+0x5b2>
mov    0x2792(%rip),%rax
mov    (%rax),%rax
mov    0x2768(%rip),%rcx
cmp    (%rcx),%rax
je     183f <main+0x62f>
lea    0xa11(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x1,%edi
call   1100 <exit@plt>
mov    $0x2710,%edi
call   1130 <usleep@plt>
jmp    17bd <main+0x5ad>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xa95(%rip),%rdi
call   1090 <strcmp@plt>
cmp    $0x0,%eax
jne    1928 <main+0x718>
movl   $0x1,-0x168(%rbp)
movq   $0x0,-0x160(%rbp)
lea    -0x16c(%rbp),%rdi
call   10b0 <FD_ZERO@plt>
mov    -0x14(%rbp),%edi
lea    -0x16c(%rbp),%rsi
call   1120 <FD_SET@plt>
mov    -0x14(%rbp),%edi
add    $0x1,%edi
lea    -0x16c(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%ecx
lea    -0x168(%rbp),%r8
mov    %rcx,%rdx
call   10c0 <select@plt>
cmp    $0x0,%rax
je     1923 <main+0x713>
mov    -0x14(%rbp),%edi
lea    -0x158(%rbp),%rsi
mov    $0x20,%edx
call   1070 <read@plt>
cltq
cmp    $0x20,%rax
je     18fb <main+0x6eb>
lea    0x955(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x1,%edi
call   1100 <exit@plt>
mov    -0x14c(%rbp),%esi
mov    -0x13c(%rbp),%edx
mov    -0x148(%rbp),%rcx
mov    -0x140(%rbp),%r8d
lea    0x99d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1880 <main+0x670>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0x9c4(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0xffffffff,%eax
add    $0x180,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xd8,%rsp
mov    %edi,%r12d
movb   $0x2,0x13(%rsp)
movb   $0x2,0x12(%rsp)
movl   $0x800,0x14(%rsp)
movaps 0xe33(%rip),%xmm0
movaps %xmm0,0xc0(%rsp)
movaps 0xe14(%rip),%xmm0
movaps %xmm0,0xb0(%rsp)
movaps 0xdf5(%rip),%xmm0
movaps %xmm0,0xa0(%rsp)
movaps 0xdd6(%rip),%xmm0
movaps %xmm0,0x90(%rsp)
movaps 0xdb7(%rip),%xmm0
movaps %xmm0,0x80(%rsp)
movaps 0xd98(%rip),%xmm0
movaps %xmm0,0x70(%rsp)
movaps 0xd7c(%rip),%xmm0
movaps %xmm0,0x60(%rsp)
movaps 0xd60(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
lea    -0x4(%r12),%eax
cmp    $0xfffffffe,%eax
jb     1450 <main+0x240>
mov    %rsi,%r15
mov    0x8(%rsi),%rsi
lea    0xdbf(%rip),%rdi
call   10a0 <strcmp@plt>
test   %eax,%eax
je     1450 <main+0x240>
lea    -0x1(%r12),%eax
mov    (%r15,%rax,8),%rdi
mov    0x2cf2(%rip),%rax
mov    (%rax),%esi
call   10e0 <open@plt>
test   %eax,%eax
js     16d7 <main+0x4c7>
mov    %eax,%r14d
mov    0x2cf1(%rip),%rax
mov    (%rax),%esi
lea    0x14(%rsp),%rdx
mov    %r14d,%edi
xor    %eax,%eax
call   1070 <ioctl@plt>
mov    0x2cb1(%rip),%rax
mov    (%rax),%esi
lea    0x13(%rsp),%rdx
mov    %r14d,%edi
xor    %eax,%eax
call   1070 <ioctl@plt>
mov    0x2c89(%rip),%rax
mov    (%rax),%esi
lea    0x12(%rsp),%rdx
mov    %r14d,%edi
xor    %eax,%eax
call   1070 <ioctl@plt>
mov    $0x80,%edi
call   1110 <JSIOCGNAME@plt>
lea    0x50(%rsp),%rbp
mov    %r14d,%edi
mov    %eax,%esi
mov    %rbp,%rdx
xor    %eax,%eax
call   1070 <ioctl@plt>
movzbl 0x13(%rsp),%edx
movzbl 0x12(%rsp),%ecx
mov    0x14(%rsp),%eax
movzbl %ah,%ebx
movzbl %al,%esi
sar    $0x10,%eax
mov    %esi,(%rsp)
lea    0xe5c(%rip),%rdi
mov    %rbp,%rsi
mov    %eax,%r8d
mov    %ebx,%r9d
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xf66(%rip),%rdi
call   1040 <puts@plt>
cmp    $0x2,%r12d
jne    13a7 <main+0x197>
cmpl   $0x10000,0x14(%rsp)
jl     14cc <main+0x2bc>
mov    0x8(%r15),%rbp
lea    0xe68(%rip),%rdi
mov    %rbp,%rsi
call   10a0 <strcmp@plt>
test   %eax,%eax
je     14cc <main+0x2bc>
cmp    $0x2,%r12d
je     156a <main+0x35a>
lea    0xe92(%rip),%rdi
mov    %rbp,%rsi
call   10a0 <strcmp@plt>
test   %eax,%eax
je     156a <main+0x35a>
lea    0xea6(%rip),%rdi
mov    %rbp,%rsi
call   10a0 <strcmp@plt>
test   %eax,%eax
je     16e0 <main+0x4d0>
lea    0xec5(%rip),%rdi
mov    %rbp,%rsi
call   10a0 <strcmp@plt>
test   %eax,%eax
je     1757 <main+0x547>
lea    0xeb9(%rip),%rdi
mov    %rbp,%rsi
call   10a0 <strcmp@plt>
test   %eax,%eax
je     17da <main+0x5ca>
lea    0xeab(%rip),%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0xffffffff,%eax
add    $0xd8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xc26(%rip),%rdi
call   1040 <puts@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xc30(%rip),%rdi
call   1040 <puts@plt>
lea    0xc2b(%rip),%rdi
call   1040 <puts@plt>
lea    0xc5b(%rip),%rdi
call   1040 <puts@plt>
lea    0xc8a(%rip),%rdi
call   1040 <puts@plt>
lea    0xcb1(%rip),%rdi
call   1040 <puts@plt>
lea    0xcdf(%rip),%rdi
call   1040 <puts@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    $0x1,%edi
call   1100 <exit@plt>
mov    0x2b0d(%rip),%r13
mov    0x0(%r13),%edx
lea    0x18(%rsp),%rsi
mov    %r14d,%edi
call   1080 <read@plt>
cltq
cmp    %rax,0x0(%r13)
jne    1741 <main+0x531>
lea    0xd6a(%rip),%rbp
lea    0xd5f(%rip),%rbx
mov    0x2a93(%rip),%r15
lea    0x18(%rsp),%r12
nopw   0x0(%rax,%rax,1)
mov    0x18(%rsp),%esi
mov    0x20(%rsp),%eax
test   $0x1,%al
mov    %rbx,%rcx
cmove  %rbp,%rcx
mov    0x1c(%rsp),%edx
test   $0x2,%al
mov    %rbx,%r8
cmove  %rbp,%r8
lea    0xd02(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    (%r15),%edi
call   10d0 <fflush@plt>
mov    $0x2710,%edi
call   1130 <usleep@plt>
mov    0x0(%r13),%edx
mov    %r14d,%edi
mov    %r12,%rsi
call   1080 <read@plt>
cltq
cmp    %rax,0x0(%r13)
je     1510 <main+0x300>
jmp    1741 <main+0x531>
movzbl 0x13(%rsp),%edi
mov    $0x4,%esi
call   1090 <calloc@plt>
mov    %rax,%r13
movzbl 0x12(%rsp),%edi
mov    $0x1,%esi
call   1090 <calloc@plt>
mov    %rax,%rbp
lea    0x18(%rsp),%rsi
mov    %r14d,%edi
mov    $0x20,%edx
call   1080 <read@plt>
cmp    $0x20,%eax
jne    1741 <main+0x531>
lea    0xcb1(%rip),%rbx
lea    0xcbe(%rip),%r12
jmp    15e9 <main+0x3d9>
nopl   0x0(%rax)
mov    0x29d1(%rip),%rax
mov    (%rax),%edi
call   10d0 <fflush@plt>
mov    %r14d,%edi
lea    0x18(%rsp),%rsi
mov    $0x20,%edx
call   1080 <read@plt>
cmp    $0x20,%eax
jne    1741 <main+0x531>
mov    0x29b0(%rip),%rax
mov    (%rax),%eax
not    %eax
and    0x24(%rsp),%eax
mov    %rbp,%rcx
cmp    $0x80,%eax
je     160c <main+0x3fc>
cmp    $0x81,%eax
jne    1618 <main+0x408>
mov    %r13,%rcx
mov    0x30(%rsp),%eax
mov    0x28(%rsp),%rdx
mov    %eax,(%rcx,%rdx,4)
mov    %rbx,%r15
mov    $0xd,%edi
call   1030 <putchar@plt>
cmpb   $0x0,0x13(%rsp)
je     166f <main+0x45f>
lea    0xc3b(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
cmpb   $0x0,0x13(%rsp)
je     166f <main+0x45f>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0x0(%r13,%rbx,4),%edx
mov    %r12,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1060 <printf@plt>
add    $0x1,%rbx
movzbl 0x13(%rsp),%eax
cmp    %rax,%rbx
jb     1650 <main+0x440>
cmpb   $0x0,0x12(%rsp)
mov    %r15,%rbx
je     15c0 <main+0x3b0>
lea    0xbfa(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
cmpb   $0x0,0x12(%rsp)
je     15c0 <main+0x3b0>
xor    %r15d,%r15d
jmp    16c3 <main+0x4b3>
nopl   0x0(%rax,%rax,1)
lea    0xbe1(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1060 <printf@plt>
add    $0x1,%r15
movzbl 0x12(%rsp),%eax
cmp    %rax,%r15
jae    15c0 <main+0x3b0>
cmpl   $0x0,0x0(%rbp,%r15,4)
mov    %rbx,%rdx
je     16a0 <main+0x490>
lea    0xb88(%rip),%rdx
jmp    16a0 <main+0x490>
lea    0xaee(%rip),%rdi
jmp    1748 <main+0x538>
lea    0x18(%rsp),%rsi
mov    %r14d,%edi
mov    $0x20,%edx
call   1080 <read@plt>
cmp    $0x20,%eax
jne    1741 <main+0x531>
lea    0xb9a(%rip),%rbx
lea    0x18(%rsp),%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0x24(%rsp),%esi
mov    0x34(%rsp),%edx
mov    0x28(%rsp),%rcx
mov    0x30(%rsp),%r8d
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r14d,%edi
mov    %rbp,%rsi
mov    $0x20,%edx
call   1080 <read@plt>
cmp    $0x20,%eax
je     1710 <main+0x500>
lea    0xad8(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x1,%edi
call   1100 <exit@plt>
mov    0x285a(%rip),%rax
mov    (%rax),%esi
mov    0x2871(%rip),%rax
mov    (%rax),%edx
mov    %r14d,%edi
call   1050 <fcntl@plt>
lea    0x18(%rsp),%rbx
lea    0xb1b(%rip),%rbp
mov    0x2824(%rip),%r15
mov    0x27fd(%rip),%r12
jmp    17ac <main+0x59c>
nopl   (%rax)
mov    0x24(%rsp),%esi
mov    0x34(%rsp),%edx
mov    0x28(%rsp),%rcx
mov    0x30(%rsp),%r8d
mov    %rbp,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r14d,%edi
mov    %rbx,%rsi
mov    $0x20,%edx
call   1080 <read@plt>
cmp    $0x20,%eax
je     1790 <main+0x580>
mov    (%r15),%rax
cmp    (%r12),%rax
jne    1741 <main+0x531>
mov    $0x2710,%edi
call   1130 <usleep@plt>
jmp    17ac <main+0x59c>
movl   $0x1,0x40(%rsp)
movq   $0x0,0x48(%rsp)
mov    %r14d,%ebx
add    $0x1,%ebx
lea    0x3c(%rsp),%rbp
lea    0x40(%rsp),%r15
lea    0x18(%rsp),%r12
lea    0xa91(%rip),%r13
nopw   0x0(%rax,%rax,1)
mov    %rbp,%rdi
call   10b0 <FD_ZERO@plt>
mov    %r14d,%edi
mov    %rbp,%rsi
call   1120 <FD_SET@plt>
mov    %ebx,%edi
mov    %rbp,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
mov    %r15,%r8
call   10c0 <select@plt>
test   %rax,%rax
je     1810 <main+0x600>
mov    %r14d,%edi
mov    %r12,%rsi
mov    $0x20,%edx
call   1080 <read@plt>
cmp    $0x20,%eax
jne    1741 <main+0x531>
mov    0x24(%rsp),%esi
mov    0x34(%rsp),%edx
mov    0x28(%rsp),%rcx
mov    0x30(%rsp),%r8d
mov    %r13,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    1810 <main+0x600>

LLVM IR (-O0):
%struct.JS_DATA_TYPE = type { i32, i32, i32, i32, i64, i32, i32 }
%struct.js_event = type { i32, i32, i32, i32, i64, i32, i32 }
%struct.timeval = type { i32, i64 }
@__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 = [1 x i8] zeroinitializer
@.str.2 = [32 x i8] c"Usage: jstest [<mode>] <device>\00"
@.str.3 = [7 x i8] c"Modes:\00"
@.str.4 = [60 x i8] c" --normal One-line mode showing immediate status\00"
@.str.5 = [59 x i8] c" --old Same as --normal, using 0.x interface\00"
@.str.6 = [51 x i8] c" --event Prints events as they come in\00"
@.str.7 = [58 x i8] c" --nonblock Same as --event, in nonblocking mode\00"
@.str.8 = [58 x i8] c" --select Same as --event, using select() call\00"
@O_RDONLY = global i32 0
@.str.9 = [7 x i8] c"jstest\00"
@JSIOCGVERSION = global i32 0
@JSIOCGAXES = global i32 0
@JSIOCGBUTTONS = global i32 0
@.str.10 = [71 x i8] c"Joystick (%s) has %d axes and %d buttons. Driver version is %d.%d.%d.\0A\00"
@.str.11 = [33 x i8] c"Testing ... (interrupt to exit)\0A\00"
@.str.12 = [6 x i8] c"--old\00"
@JS_RETURN = global i64 0
@.str.13 = [23 x i8] c"\0Ajstest: error reading\00"
@.str.14 = [38 x i8] c"Axes: X:%3d Y:%3d Buttons: A:%s B:%s\0D\00"
@.str.15 = [4 x i8] c"on \00"
@.str.16 = [4 x i8] c"off\00"
@stdout = global i32 0
@.str.17 = [9 x i8] c"--normal\00"
@JS_EVENT_INIT = global i32 0
@.str.18 = [2 x i8] c"\0D\00"
@.str.19 = [7 x i8] c"Axes: \00"
@.str.20 = [9 x i8] c"%2d:%6d \00"
@.str.21 = [10 x i8] c"Buttons: \00"
@.str.22 = [8 x i8] c"%2d:%s \00"
@.str.23 = [8 x i8] c"--event\00"
@.str.24 = [46 x i8] c"Event: type %d, time %d, number %d, value %d\0A\00"
@.str.25 = [11 x i8] c"--nonblock\00"
@F_SETFL = global i32 0
@O_NONBLOCK = global i32 0
@errno = global i64 0
@EAGAIN = global i64 0
@.str.26 = [9 x i8] c"--select\00"
@.str.27 = [26 x i8] c"jstest: unknown mode: %s\0A\00"
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 %struct.JS_DATA_TYPE
%12 = alloca i32*
%13 = alloca i32*
%14 = alloca i32
%15 = alloca %struct.js_event
%16 = alloca %struct.js_event
%17 = alloca %struct.js_event
%18 = alloca %struct.js_event
%19 = alloca %struct.timeval
%20 = alloca i32
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
%21 = bitcast [128 x i8]* %10 to i8*
%22 = load i32, i32* %4
%23 = icmp slt i32 %22, 2
br i1 %23, label %33, label %24
24: ; preds = %2
%25 = load i32, i32* %4
%26 = icmp sgt i32 %25, 3
br i1 %26, label %33, label %27
27: ; preds = %24
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 1
%30 = load i8*, i8** %29
%31 = call i32 @strcmp(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %30)
%32 = icmp ne i32 %31, 0
br i1 %32, label %45, label %33
33: ; preds = %27, %24, %2
%34 = call i32 @puts(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
%35 = call i32 @puts(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
%36 = call i32 @puts(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
%37 = call i32 @puts(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%38 = call i32 @puts(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.4, i64 0, i64 0))
%39 = call i32 @puts(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.5, i64 0, i64 0))
%40 = call i32 @puts(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.6, i64 0, i64 0))
%41 = call i32 @puts(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.7, i64 0, i64 0))
%42 = call i32 @puts(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.8, i64 0, i64 0))
%43 = call i32 @puts(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
%44 = call i32 @exit(i32 1)
unreachable
45: ; preds = %27
%46 = load i8**, i8*** %5
%47 = load i32, i32* %4
%48 = sub nsw i32 %47, 1
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds i8*, i8** %46, i64 %49
%51 = load i8*, i8** %50
%52 = load i32, i32* @O_RDONLY
%53 = call i32 @open(i8* %51, i32 %52)
store i32 %53, i32* %6
%54 = icmp slt i32 %53, 0
br i1 %54, label %55, label %58
55: ; preds = %45
%56 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0))
%57 = call i32 @exit(i32 1)
unreachable
58: ; preds = %45
%59 = load i32, i32* %6
%60 = load i32, i32* @JSIOCGVERSION
%61 = call i32 (i32, i32, ...) @ioctl(i32 %59, i32 %60, i32* %9)
%62 = load i32, i32* %6
%63 = load i32, i32* @JSIOCGAXES
%64 = call i32 (i32, i32, ...) @ioctl(i32 %62, i32 %63, i8* %7)
%65 = load i32, i32* %6
%66 = load i32, i32* @JSIOCGBUTTONS
%67 = call i32 (i32, i32, ...) @ioctl(i32 %65, i32 %66, i8* %8)
%68 = load i32, i32* %6
%69 = call i32 @JSIOCGNAME(i32 128)
%70 = getelementptr inbounds [128 x i8], [128 x i8]* %10, i64 0, i64 0
%71 = call i32 (i32, i32, ...) @ioctl(i32 %68, i32 %69, i8* %70)
%72 = getelementptr inbounds [128 x i8], [128 x i8]* %10, i64 0, i64 0
%73 = load i8, i8* %7
%74 = zext i8 %73 to i32
%75 = load i8, i8* %8
%76 = zext i8 %75 to i32
%77 = load i32, i32* %9
%78 = ashr i32 %77, 16
%79 = load i32, i32* %9
%80 = ashr i32 %79, 8
%81 = and i32 %80, 255
%82 = load i32, i32* %9
%83 = and i32 %82, 255
%84 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.10, i64 0, i64 0), i8* %72, i32 %74, i32 %76, i32 %78, i32 %81, i32 %83)
%85 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.11, i64 0, i64 0))
%86 = load i32, i32* %4
%87 = icmp eq i32 %86, 2
br i1 %87, label %88, label %91
88: ; preds = %58
%89 = load i32, i32* %9
%90 = icmp slt i32 %89, 65536
br i1 %90, label %97, label %91
91: ; preds = %88, %58
%92 = load i8**, i8*** %5
%93 = getelementptr inbounds i8*, i8** %92, i64 1
%94 = load i8*, i8** %93
%95 = call i32 @strcmp(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.12, i64 0, i64 0), i8* %94)
%96 = icmp ne i32 %95, 0
br i1 %96, label %131, label %97
97: ; preds = %91, %88
br label %98
98: ; preds = %97, %110
%99 = load i32, i32* %6
%100 = bitcast %struct.JS_DATA_TYPE* %11 to %struct.js_event*
%101 = load i64, i64* @JS_RETURN
%102 = trunc i64 %101 to i32
%103 = call i32 @read(i32 %99, %struct.js_event* %100, i32 %102)
%104 = sext i32 %103 to i64
%105 = load i64, i64* @JS_RETURN
%106 = icmp ne i64 %104, %105
br i1 %106, label %107, label %110
107: ; preds = %98
%108 = call i32 @perror(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.13, i64 0, i64 0))
%109 = call i32 @exit(i32 1)
unreachable
110: ; preds = %98
%111 = getelementptr inbounds %struct.JS_DATA_TYPE, %struct.JS_DATA_TYPE* %11, i32 0, i32 0
%112 = load i32, i32* %111
%113 = getelementptr inbounds %struct.JS_DATA_TYPE, %struct.JS_DATA_TYPE* %11, i32 0, i32 1
%114 = load i32, i32* %113
%115 = getelementptr inbounds %struct.JS_DATA_TYPE, %struct.JS_DATA_TYPE* %11, i32 0, i32 2
%116 = load i32, i32* %115
%117 = and i32 %116, 1
%118 = icmp ne i32 %117, 0
%119 = zext i1 %118 to i64
%120 = select i1 %118, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.15, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.16, i64 0, i64 0)
%121 = getelementptr inbounds %struct.JS_DATA_TYPE, %struct.JS_DATA_TYPE* %11, i32 0, i32 2
%122 = load i32, i32* %121
%123 = and i32 %122, 2
%124 = icmp ne i32 %123, 0
%125 = zext i1 %124 to i64
%126 = select i1 %124, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.15, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.16, i64 0, i64 0)
%127 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.14, i64 0, i64 0), i32 %112, i32 %114, i8* %120, i8* %126)
%128 = load i32, i32* @stdout
%129 = call i32 @fflush(i32 %128)
%130 = call i32 @usleep(i32 10000)
br label %98
131: ; preds = %91
%132 = load i32, i32* %4
%133 = icmp eq i32 %132, 2
br i1 %133, label %140, label %134
134: ; preds = %131
%135 = load i8**, i8*** %5
%136 = getelementptr inbounds i8*, i8** %135, i64 1
%137 = load i8*, i8** %136
%138 = call i32 @strcmp(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.17, i64 0, i64 0), i8* %137)
%139 = icmp ne i32 %138, 0
br i1 %139, label %224, label %140
140: ; preds = %134, %131
%141 = load i8, i8* %7
%142 = call i32* @calloc(i8 zeroext %141, i32 4)
store i32* %142, i32** %12
%143 = load i8, i8* %8
%144 = call i32* @calloc(i8 zeroext %143, i32 1)
store i32* %144, i32** %13
br label %145
145: ; preds = %140, %221
%146 = load i32, i32* %6
%147 = call i32 @read(i32 %146, %struct.js_event* %15, i32 32)
%148 = sext i32 %147 to i64
%149 = icmp ne i64 %148, 32
br i1 %149, label %150, label %153
150: ; preds = %145
%151 = call i32 @perror(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.13, i64 0, i64 0))
%152 = call i32 @exit(i32 1)
unreachable
153: ; preds = %145
%154 = getelementptr inbounds %struct.js_event, %struct.js_event* %15, i32 0, i32 3
%155 = load i32, i32* %154
%156 = load i32, i32* @JS_EVENT_INIT
%157 = xor i32 %156, -1
%158 = and i32 %155, %157
switch i32 %158, label %173 [
i32 128, label %159
i32 129, label %166
]
159: ; preds = %153
%160 = getelementptr inbounds %struct.js_event, %struct.js_event* %15, i32 0, i32 5
%161 = load i32, i32* %160
%162 = load i32*, i32** %13
%163 = getelementptr inbounds %struct.js_event, %struct.js_event* %15, i32 0, i32 4
%164 = load i64, i64* %163
%165 = getelementptr inbounds i32, i32* %162, i64 %164
store i32 %161, i32* %165
br label %173
166: ; preds = %153
%167 = getelementptr inbounds %struct.js_event, %struct.js_event* %15, i32 0, i32 5
%168 = load i32, i32* %167
%169 = load i32*, i32** %12
%170 = getelementptr inbounds %struct.js_event, %struct.js_event* %15, i32 0, i32 4
%171 = load i64, i64* %170
%172 = getelementptr inbounds i32, i32* %169, i64 %171
store i32 %168, i32* %172
br label %173
173: ; preds = %153, %166, %159
%174 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.18, i64 0, i64 0))
%175 = load i8, i8* %7
%176 = icmp ne i8 %175, 0
br i1 %176, label %177, label %196
177: ; preds = %173
%178 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.19, i64 0, i64 0))
store i32 0, i32* %14
br label %179
179: ; preds = %192, %177
%180 = load i32, i32* %14
%181 = load i8, i8* %7
%182 = zext i8 %181 to i32
%183 = icmp slt i32 %180, %182
br i1 %183, label %184, label %195
184: ; preds = %179
%185 = load i32, i32* %14
%186 = load i32*, i32** %12
%187 = load i32, i32* %14
%188 = sext i32 %187 to i64
%189 = getelementptr inbounds i32, i32* %186, i64 %188
%190 = load i32, i32* %189
%191 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.20, i64 0, i64 0), i32 %185, i32 %190)
br label %192
192: ; preds = %184
%193 = load i32, i32* %14
%194 = add nsw i32 %193, 1
store i32 %194, i32* %14
br label %179
195: ; preds = %179
br label %196
196: ; preds = %195, %173
%197 = load i8, i8* %8
%198 = icmp ne i8 %197, 0
br i1 %198, label %199, label %221
199: ; preds = %196
%200 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.21, i64 0, i64 0))
store i32 0, i32* %14
br label %201
201: ; preds = %217, %199
%202 = load i32, i32* %14
%203 = load i8, i8* %8
%204 = zext i8 %203 to i32
%205 = icmp slt i32 %202, %204
br i1 %205, label %206, label %220
206: ; preds = %201
%207 = load i32, i32* %14
%208 = load i32*, i32** %13
%209 = load i32, i32* %14
%210 = sext i32 %209 to i64
%211 = getelementptr inbounds i32, i32* %208, i64 %210
%212 = load i32, i32* %211
%213 = icmp ne i32 %212, 0
%214 = zext i1 %213 to i64
%215 = select i1 %213, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.15, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.16, i64 0, i64 0)
%216 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.22, i64 0, i64 0), i32 %207, i8* %215)
br label %217
217: ; preds = %206
%218 = load i32, i32* %14
%219 = add nsw i32 %218, 1
store i32 %219, i32* %14
br label %201
220: ; preds = %201
br label %221
221: ; preds = %220, %196
%222 = load i32, i32* @stdout
%223 = call i32 @fflush(i32 %222)
br label %145
224: ; preds = %134
%225 = load i8**, i8*** %5
%226 = getelementptr inbounds i8*, i8** %225, i64 1
%227 = load i8*, i8** %226
%228 = call i32 @strcmp(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.23, i64 0, i64 0), i8* %227)
%229 = icmp ne i32 %228, 0
br i1 %229, label %249, label %230
230: ; preds = %224
br label %231
231: ; preds = %230, %239
%232 = load i32, i32* %6
%233 = call i32 @read(i32 %232, %struct.js_event* %16, i32 32)
%234 = sext i32 %233 to i64
%235 = icmp ne i64 %234, 32
br i1 %235, label %236, label %239
236: ; preds = %231
%237 = call i32 @perror(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.13, i64 0, i64 0))
%238 = call i32 @exit(i32 1)
unreachable
239: ; preds = %231
%240 = getelementptr inbounds %struct.js_event, %struct.js_event* %16, i32 0, i32 3
%241 = load i32, i32* %240
%242 = getelementptr inbounds %struct.js_event, %struct.js_event* %16, i32 0, i32 6
%243 = load i32, i32* %242
%244 = getelementptr inbounds %struct.js_event, %struct.js_event* %16, i32 0, i32 4
%245 = load i64, i64* %244
%246 = getelementptr inbounds %struct.js_event, %struct.js_event* %16, i32 0, i32 5
%247 = load i32, i32* %246
%248 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.24, i64 0, i64 0), i32 %241, i32 %243, i64 %245, i32 %247)
br label %231
249: ; preds = %224
%250 = load i8**, i8*** %5
%251 = getelementptr inbounds i8*, i8** %250, i64 1
%252 = load i8*, i8** %251
%253 = call i32 @strcmp(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.25, i64 0, i64 0), i8* %252)
%254 = icmp ne i32 %253, 0
br i1 %254, label %285, label %255
255: ; preds = %249
%256 = load i32, i32* %6
%257 = load i32, i32* @F_SETFL
%258 = load i32, i32* @O_NONBLOCK
%259 = call i32 @fcntl(i32 %256, i32 %257, i32 %258)
br label %260
260: ; preds = %255, %283
br label %261
261: ; preds = %266, %260
%262 = load i32, i32* %6
%263 = call i32 @read(i32 %262, %struct.js_event* %17, i32 32)
%264 = sext i32 %263 to i64
%265 = icmp eq i64 %264, 32
br i1 %265, label %266, label %276
266: ; preds = %261
%267 = getelementptr inbounds %struct.js_event, %struct.js_event* %17, i32 0, i32 3
%268 = load i32, i32* %267
%269 = getelementptr inbounds %struct.js_event, %struct.js_event* %17, i32 0, i32 6
%270 = load i32, i32* %269
%271 = getelementptr inbounds %struct.js_event, %struct.js_event* %17, i32 0, i32 4
%272 = load i64, i64* %271
%273 = getelementptr inbounds %struct.js_event, %struct.js_event* %17, i32 0, i32 5
%274 = load i32, i32* %273
%275 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.24, i64 0, i64 0), i32 %268, i32 %270, i64 %272, i32 %274)
br label %261
276: ; preds = %261
%277 = load i64, i64* @errno
%278 = load i64, i64* @EAGAIN
%279 = icmp ne i64 %277, %278
br i1 %279, label %280, label %283
280: ; preds = %276
%281 = call i32 @perror(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.13, i64 0, i64 0))
%282 = call i32 @exit(i32 1)
unreachable
283: ; preds = %276
%284 = call i32 @usleep(i32 10000)
br label %260
285: ; preds = %249
%286 = load i8**, i8*** %5
%287 = getelementptr inbounds i8*, i8** %286, i64 1
%288 = load i8*, i8** %287
%289 = call i32 @strcmp(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.26, i64 0, i64 0), i8* %288)
%290 = icmp ne i32 %289, 0
br i1 %290, label %321, label %291
291: ; preds = %285
%292 = getelementptr inbounds %struct.timeval, %struct.timeval* %19, i32 0, i32 0
store i32 1, i32* %292
%293 = getelementptr inbounds %struct.timeval, %struct.timeval* %19, i32 0, i32 1
store i64 0, i64* %293
br label %294
294: ; preds = %291, %320
%295 = call i32 @FD_ZERO(i32* %20)
%296 = load i32, i32* %6
%297 = call i32 @FD_SET(i32 %296, i32* %20)
%298 = load i32, i32* %6
%299 = add nsw i32 %298, 1
%300 = call i64 @select(i32 %299, i32* %20, i32* null, i32* null, %struct.timeval* %19)
%301 = icmp ne i64 %300, 0
br i1 %301, label %302, label %320
302: ; preds = %294
%303 = load i32, i32* %6
%304 = call i32 @read(i32 %303, %struct.js_event* %18, i32 32)
%305 = sext i32 %304 to i64
%306 = icmp ne i64 %305, 32
br i1 %306, label %307, label %310
307: ; preds = %302
%308 = call i32 @perror(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.13, i64 0, i64 0))
%309 = call i32 @exit(i32 1)
unreachable
310: ; preds = %302
%311 = getelementptr inbounds %struct.js_event, %struct.js_event* %18, i32 0, i32 3
%312 = load i32, i32* %311
%313 = getelementptr inbounds %struct.js_event, %struct.js_event* %18, i32 0, i32 6
%314 = load i32, i32* %313
%315 = getelementptr inbounds %struct.js_event, %struct.js_event* %18, i32 0, i32 4
%316 = load i64, i64* %315
%317 = getelementptr inbounds %struct.js_event, %struct.js_event* %18, i32 0, i32 5
%318 = load i32, i32* %317
%319 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.24, i64 0, i64 0), i32 %312, i32 %314, i64 %316, i32 %318)
br label %320
320: ; preds = %310, %294
br label %294
321: ; preds = %285
%322 = load i8**, i8*** %5
%323 = getelementptr inbounds i8*, i8** %322, i64 1
%324 = load i8*, i8** %323
%325 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.27, i64 0, i64 0), i8* %324)
ret i32 -1
}

LLVM IR (-O2):
%struct.JS_DATA_TYPE = type { i32, i32, i32, i32, i64, i32, i32 }
%struct.js_event = type { i32, i32, i32, i32, i64, i32, i32 }
%struct.timeval = type { i32, i64 }
@__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.2 = [32 x i8] c"Usage: jstest [<mode>] <device>\00"
@.str.3 = [7 x i8] c"Modes:\00"
@.str.4 = [60 x i8] c" --normal One-line mode showing immediate status\00"
@.str.5 = [59 x i8] c" --old Same as --normal, using 0.x interface\00"
@.str.6 = [51 x i8] c" --event Prints events as they come in\00"
@.str.7 = [58 x i8] c" --nonblock Same as --event, in nonblocking mode\00"
@.str.8 = [58 x i8] c" --select Same as --event, using select() call\00"
@O_RDONLY = global i32 0
@.str.9 = [7 x i8] c"jstest\00"
@JSIOCGVERSION = global i32 0
@JSIOCGAXES = global i32 0
@JSIOCGBUTTONS = global i32 0
@.str.10 = [71 x i8] c"Joystick (%s) has %d axes and %d buttons. Driver version is %d.%d.%d.\0A\00"
@.str.12 = [6 x i8] c"--old\00"
@JS_RETURN = global i64 0
@.str.13 = [23 x i8] c"\0Ajstest: error reading\00"
@.str.14 = [38 x i8] c"Axes: X:%3d Y:%3d Buttons: A:%s B:%s\0D\00"
@.str.15 = [4 x i8] c"on \00"
@.str.16 = [4 x i8] c"off\00"
@stdout = global i32 0
@.str.17 = [9 x i8] c"--normal\00"
@JS_EVENT_INIT = global i32 0
@.str.19 = [7 x i8] c"Axes: \00"
@.str.20 = [9 x i8] c"%2d:%6d \00"
@.str.21 = [10 x i8] c"Buttons: \00"
@.str.22 = [8 x i8] c"%2d:%s \00"
@.str.23 = [8 x i8] c"--event\00"
@.str.24 = [46 x i8] c"Event: type %d, time %d, number %d, value %d\0A\00"
@.str.25 = [11 x i8] c"--nonblock\00"
@F_SETFL = global i32 0
@O_NONBLOCK = global i32 0
@errno = global i64 0
@EAGAIN = global i64 0
@.str.26 = [9 x i8] c"--select\00"
@.str.27 = [26 x i8] c"jstest: unknown mode: %s\0A\00"
@str = [32 x i8] c"Testing ... (interrupt 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_DATA_TYPE
%8 = alloca %struct.js_event
%9 = alloca %struct.js_event
%10 = alloca %struct.js_event
%11 = alloca %struct.js_event
%12 = alloca %struct.timeval
%13 = alloca i32
store i8 2, i8* %3
store i8 2, i8* %4
%14 = bitcast i32* %5 to i8*
store i32 2048, i32* %5
%15 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%16 = add i32 %0, -4
%17 = icmp ult i32 %16, -2
br i1 %17, label %23, label %18
18: ; preds = %2
%19 = getelementptr inbounds i8*, i8** %1, i64 1
%20 = load i8*, i8** %19
%21 = tail call i32 @strcmp(i8* dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* dereferenceable(1) %20)
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %35
23: ; preds = %18, %2
%24 = tail call i32 @putchar(i32 10)
%25 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
%26 = tail call i32 @putchar(i32 10)
%27 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%28 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([60 x i8], [60 x i8]* @.str.4, i64 0, i64 0))
%29 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([59 x i8], [59 x i8]* @.str.5, i64 0, i64 0))
%30 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @.str.6, i64 0, i64 0))
%31 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([58 x i8], [58 x i8]* @.str.7, i64 0, i64 0))
%32 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([58 x i8], [58 x i8]* @.str.8, i64 0, i64 0))
%33 = tail call i32 @putchar(i32 10)
%34 = tail call i32 @exit(i32 1)
unreachable
35: ; preds = %18
%36 = add nsw i32 %0, -1
%37 = zext i32 %36 to i64
%38 = getelementptr inbounds i8*, i8** %1, i64 %37
%39 = load i8*, i8** %38
%40 = load i32, i32* @O_RDONLY
%41 = tail call i32 @open(i8* %39, i32 %40)
%42 = icmp slt i32 %41, 0
br i1 %42, label %43, label %46
43: ; preds = %35
%44 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0))
%45 = tail call i32 @exit(i32 1)
unreachable
46: ; preds = %35
%47 = load i32, i32* @JSIOCGVERSION
%48 = call i32 (i32, i32, ...) @ioctl(i32 %41, i32 %47, i32* %5)
%49 = load i32, i32* @JSIOCGAXES
%50 = call i32 (i32, i32, ...) @ioctl(i32 %41, i32 %49, i8* %3)
%51 = load i32, i32* @JSIOCGBUTTONS
%52 = call i32 (i32, i32, ...) @ioctl(i32 %41, i32 %51, i8* %4)
%53 = call i32 @JSIOCGNAME(i32 128)
%54 = call i32 (i32, i32, ...) @ioctl(i32 %41, i32 %53, i8* %15)
%55 = load i8, i8* %3
%56 = zext i8 %55 to i32
%57 = load i8, i8* %4
%58 = zext i8 %57 to i32
%59 = load i32, i32* %5
%60 = ashr i32 %59, 16
%61 = lshr i32 %59, 8
%62 = and i32 %61, 255
%63 = and i32 %59, 255
%64 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([71 x i8], [71 x i8]* @.str.10, i64 0, i64 0), i8* %15, i32 %56, i32 %58, i32 %60, i32 %62, i32 %63)
%65 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str, i64 0, i64 0))
%66 = icmp eq i32 %0, 2
%67 = load i32, i32* %5
%68 = icmp slt i32 %67, 65536
%69 = select i1 %66, i1 %68, i1 false
br i1 %69, label %74, label %70
70: ; preds = %46
%71 = load i8*, i8** %19
%72 = call i32 @strcmp(i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.12, i64 0, i64 0), i8* dereferenceable(1) %71)
%73 = icmp eq i32 %72, 0
br i1 %73, label %74, label %110
74: ; preds = %46, %70
%75 = bitcast %struct.JS_DATA_TYPE* %7 to i8*
%76 = bitcast %struct.JS_DATA_TYPE* %7 to %struct.js_event*
%77 = load i64, i64* @JS_RETURN
%78 = trunc i64 %77 to i32
%79 = call i32 @read(i32 %41, %struct.js_event* %76, i32 %78)
%80 = sext i32 %79 to i64
%81 = load i64, i64* @JS_RETURN
%82 = icmp eq i64 %81, %80
br i1 %82, label %83, label %87
83: ; preds = %74
%84 = getelementptr inbounds %struct.JS_DATA_TYPE, %struct.JS_DATA_TYPE* %7, i64 0, i32 0
%85 = getelementptr inbounds %struct.JS_DATA_TYPE, %struct.JS_DATA_TYPE* %7, i64 0, i32 1
%86 = getelementptr inbounds %struct.JS_DATA_TYPE, %struct.JS_DATA_TYPE* %7, i64 0, i32 2
br label %90
87: ; preds = %90, %74
%88 = call i32 @perror(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.13, i64 0, i64 0))
%89 = call i32 @exit(i32 1)
unreachable
90: ; preds = %83, %90
%91 = load i32, i32* %84
%92 = load i32, i32* %85
%93 = load i32, i32* %86
%94 = and i32 %93, 1
%95 = icmp eq i32 %94, 0
%96 = select i1 %95, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.16, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.15, i64 0, i64 0)
%97 = and i32 %93, 2
%98 = icmp eq i32 %97, 0
%99 = select i1 %98, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.16, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.15, i64 0, i64 0)
%100 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.14, i64 0, i64 0), i32 %91, i32 %92, i8* %96, i8* %99)
%101 = load i32, i32* @stdout
%102 = call i32 @fflush(i32 %101)
%103 = call i32 @usleep(i32 10000)
%104 = load i64, i64* @JS_RETURN
%105 = trunc i64 %104 to i32
%106 = call i32 @read(i32 %41, %struct.js_event* %76, i32 %105)
%107 = sext i32 %106 to i64
%108 = load i64, i64* @JS_RETURN
%109 = icmp eq i64 %108, %107
br i1 %109, label %90, label %87
110: ; preds = %70
br i1 %66, label %114, label %111
111: ; preds = %110
%112 = call i32 @strcmp(i8* dereferenceable(9) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.17, i64 0, i64 0), i8* dereferenceable(1) %71)
%113 = icmp eq i32 %112, 0
br i1 %113, label %114, label %182
114: ; preds = %111, %110
%115 = bitcast %struct.js_event* %8 to i8*
%116 = load i8, i8* %3
%117 = call i32* @calloc(i8 zeroext %116, i32 4)
%118 = load i8, i8* %4
%119 = call i32* @calloc(i8 zeroext %118, i32 1)
%120 = call i32 @read(i32 %41, %struct.js_event* %8, i32 32)
%121 = icmp eq i32 %120, 32
br i1 %121, label %122, label %126
122: ; preds = %114
%123 = getelementptr inbounds %struct.js_event, %struct.js_event* %8, i64 0, i32 3
%124 = getelementptr inbounds %struct.js_event, %struct.js_event* %8, i64 0, i32 5
%125 = getelementptr inbounds %struct.js_event, %struct.js_event* %8, i64 0, i32 4
br label %129
126: ; preds = %177, %114
%127 = call i32 @perror(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.13, i64 0, i64 0))
%128 = call i32 @exit(i32 1)
unreachable
129: ; preds = %122, %177
%130 = load i32, i32* %123
%131 = load i32, i32* @JS_EVENT_INIT
%132 = xor i32 %131, -1
%133 = and i32 %130, %132
switch i32 %133, label %140 [
i32 128, label %135
i32 129, label %134
]
134: ; preds = %129
br label %135
135: ; preds = %129, %134
%136 = phi i32* [ %117, %134 ], [ %119, %129 ]
%137 = load i32, i32* %124
%138 = load i64, i64* %125
%139 = getelementptr inbounds i32, i32* %136, i64 %138
store i32 %137, i32* %139
br label %140
140: ; preds = %135, %129
%141 = call i32 @putchar(i32 13)
%142 = load i8, i8* %3
%143 = icmp eq i8 %142, 0
br i1 %143, label %158, label %144
144: ; preds = %140
%145 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.19, i64 0, i64 0))
%146 = load i8, i8* %3
%147 = icmp eq i8 %146, 0
br i1 %147, label %158, label %148
148: ; preds = %144, %148
%149 = phi i64 [ %154, %148 ], [ 0, %144 ]
%150 = getelementptr inbounds i32, i32* %117, i64 %149
%151 = load i32, i32* %150
%152 = trunc i64 %149 to i32
%153 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.20, i64 0, i64 0), i32 %152, i32 %151)
%154 = add nuw nsw i64 %149, 1
%155 = load i8, i8* %3
%156 = zext i8 %155 to i64
%157 = icmp ult i64 %154, %156
br i1 %157, label %148, label %158
158: ; preds = %148, %144, %140
%159 = load i8, i8* %4
%160 = icmp eq i8 %159, 0
br i1 %160, label %177, label %161
161: ; preds = %158
%162 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.21, i64 0, i64 0))
%163 = load i8, i8* %4
%164 = icmp eq i8 %163, 0
br i1 %164, label %177, label %165
165: ; preds = %161, %165
%166 = phi i64 [ %173, %165 ], [ 0, %161 ]
%167 = getelementptr inbounds i32, i32* %119, i64 %166
%168 = load i32, i32* %167
%169 = icmp eq i32 %168, 0
%170 = select i1 %169, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.16, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.15, i64 0, i64 0)
%171 = trunc i64 %166 to i32
%172 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.22, i64 0, i64 0), i32 %171, i8* %170)
%173 = add nuw nsw i64 %166, 1
%174 = load i8, i8* %4
%175 = zext i8 %174 to i64
%176 = icmp ult i64 %173, %175
br i1 %176, label %165, label %177
177: ; preds = %165, %161, %158
%178 = load i32, i32* @stdout
%179 = call i32 @fflush(i32 %178)
%180 = call i32 @read(i32 %41, %struct.js_event* %8, i32 32)
%181 = icmp eq i32 %180, 32
br i1 %181, label %129, label %126
182: ; preds = %111
%183 = call i32 @strcmp(i8* dereferenceable(8) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.23, i64 0, i64 0), i8* dereferenceable(1) %71)
%184 = icmp eq i32 %183, 0
br i1 %184, label %185, label %205
185: ; preds = %182
%186 = bitcast %struct.js_event* %9 to i8*
%187 = call i32 @read(i32 %41, %struct.js_event* %9, i32 32)
%188 = icmp eq i32 %187, 32
br i1 %188, label %189, label %194
189: ; preds = %185
%190 = getelementptr inbounds %struct.js_event, %struct.js_event* %9, i64 0, i32 3
%191 = getelementptr inbounds %struct.js_event, %struct.js_event* %9, i64 0, i32 6
%192 = getelementptr inbounds %struct.js_event, %struct.js_event* %9, i64 0, i32 4
%193 = getelementptr inbounds %struct.js_event, %struct.js_event* %9, i64 0, i32 5
br label %197
194: ; preds = %197, %185
%195 = call i32 @perror(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.13, i64 0, i64 0))
%196 = call i32 @exit(i32 1)
unreachable
197: ; preds = %189, %197
%198 = load i32, i32* %190
%199 = load i32, i32* %191
%200 = load i64, i64* %192
%201 = load i32, i32* %193
%202 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str.24, i64 0, i64 0), i32 %198, i32 %199, i64 %200, i32 %201)
%203 = call i32 @read(i32 %41, %struct.js_event* %9, i32 32)
%204 = icmp eq i32 %203, 32
br i1 %204, label %197, label %194
205: ; preds = %182
%206 = call i32 @strcmp(i8* dereferenceable(11) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.25, i64 0, i64 0), i8* dereferenceable(1) %71)
%207 = icmp eq i32 %206, 0
br i1 %207, label %208, label %237
208: ; preds = %205
%209 = bitcast %struct.js_event* %10 to i8*
%210 = load i32, i32* @F_SETFL
%211 = load i32, i32* @O_NONBLOCK
%212 = call i32 @fcntl(i32 %41, i32 %210, i32 %211)
%213 = getelementptr inbounds %struct.js_event, %struct.js_event* %10, i64 0, i32 3
%214 = getelementptr inbounds %struct.js_event, %struct.js_event* %10, i64 0, i32 6
%215 = getelementptr inbounds %struct.js_event, %struct.js_event* %10, i64 0, i32 4
%216 = getelementptr inbounds %struct.js_event, %struct.js_event* %10, i64 0, i32 5
br label %217
217: ; preds = %235, %208
%218 = call i32 @read(i32 %41, %struct.js_event* %10, i32 32)
%219 = icmp eq i32 %218, 32
br i1 %219, label %220, label %228
220: ; preds = %217, %220
%221 = load i32, i32* %213
%222 = load i32, i32* %214
%223 = load i64, i64* %215
%224 = load i32, i32* %216
%225 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str.24, i64 0, i64 0), i32 %221, i32 %222, i64 %223, i32 %224)
%226 = call i32 @read(i32 %41, %struct.js_event* %10, i32 32)
%227 = icmp eq i32 %226, 32
br i1 %227, label %220, label %228
228: ; preds = %220, %217
%229 = load i64, i64* @errno
%230 = load i64, i64* @EAGAIN
%231 = icmp eq i64 %229, %230
br i1 %231, label %235, label %232
232: ; preds = %228
%233 = call i32 @perror(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.13, i64 0, i64 0))
%234 = call i32 @exit(i32 1)
unreachable
235: ; preds = %228
%236 = call i32 @usleep(i32 10000)
br label %217
237: ; preds = %205
%238 = call i32 @strcmp(i8* dereferenceable(9) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.26, i64 0, i64 0), i8* dereferenceable(1) %71)
%239 = icmp eq i32 %238, 0
br i1 %239, label %240, label %269
240: ; preds = %237
%241 = bitcast %struct.js_event* %11 to i8*
%242 = bitcast %struct.timeval* %12 to i8*
%243 = bitcast i32* %13 to i8*
%244 = getelementptr inbounds %struct.timeval, %struct.timeval* %12, i64 0, i32 0
store i32 1, i32* %244
%245 = getelementptr inbounds %struct.timeval, %struct.timeval* %12, i64 0, i32 1
store i64 0, i64* %245
%246 = add nuw nsw i32 %41, 1
%247 = getelementptr inbounds %struct.js_event, %struct.js_event* %11, i64 0, i32 3
%248 = getelementptr inbounds %struct.js_event, %struct.js_event* %11, i64 0, i32 6
%249 = getelementptr inbounds %struct.js_event, %struct.js_event* %11, i64 0, i32 4
%250 = getelementptr inbounds %struct.js_event, %struct.js_event* %11, i64 0, i32 5
br label %251
251: ; preds = %268, %240
%252 = call i32 @FD_ZERO(i32* %13)
%253 = call i32 @FD_SET(i32 %41, i32* %13)
%254 = call i64 @select(i32 %246, i32* %13, i32* null, i32* null, %struct.timeval* %12)
%255 = icmp eq i64 %254, 0
br i1 %255, label %268, label %256
256: ; preds = %251
%257 = call i32 @read(i32 %41, %struct.js_event* %11, i32 32)
%258 = icmp eq i32 %257, 32
br i1 %258, label %262, label %259
259: ; preds = %256
%260 = call i32 @perror(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.13, i64 0, i64 0))
%261 = call i32 @exit(i32 1)
unreachable
262: ; preds = %256
%263 = load i32, i32* %247
%264 = load i32, i32* %248
%265 = load i64, i64* %249
%266 = load i32, i32* %250
%267 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str.24, i64 0, i64 0), i32 %263, i32 %264, i64 %265, i32 %266)
br label %268
268: ; preds = %262, %251
br label %251
269: ; preds = %237
%270 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.27, i64 0, i64 0), i8* %71)
ret i32 -1
}