#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 */
typedef char uint8_t;
typedef char uint16_t;
struct js_event {
  int type;
  size_t number;
  char value;
};

/* Variables and functions */
int /*<<< orphan*/ ABS_MAX;
scalar_t__ BTN_MISC;
int /*<<< orphan*/ JSIOCGAXES;
int /*<<< orphan*/ JSIOCGAXMAP;
int /*<<< orphan*/ JSIOCGBTNMAP;
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__ KEY_MAX;
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ binprint(int, char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int inb(int);
int /*<<< orphan*/ ioctl(int, int /*<<< orphan*/, ...);
scalar_t__ ioperm(int, int, int);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int read(int, struct js_event *, int);
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ system(char *);
int /*<<< orphan*/ usleep(int);
int main(int argc, char **argv) {
  char bin_DTA[255];
  char bin_STA[255];
  char bin_CTR[255];
  int fd;
  int i;
  unsigned char buttons = 2;
  char *button;
  unsigned char axes = 2;
  int *axis;
  int version = 0x000800;
  char name[255] = "Unknown";
  uint16_t btnmap[KEY_MAX - BTN_MISC + 1];
  uint8_t axmap[ABS_MAX + 1];
  struct js_event js;
  if (argc < 2) {
    printf("Usage: %s <device>\n\nDevice could be: /dev/js0\n", argv[0]);
    return 0;
  }
  if ((fd = open(argv[1], O_RDONLY)) < 0) {
    printf("Error: Cannot open device %s!\n", argv[1]);
    exit(1);
  }
  if (read(fd, &js, sizeof(struct js_event)) != sizeof(struct js_event)) {
    perror("\njstest: error reading");
    return 1;
  }
  ioctl(fd, JSIOCGVERSION, &version);
  ioctl(fd, JSIOCGAXES, &axes);
  ioctl(fd, JSIOCGBUTTONS, &buttons);
  ioctl(fd, JSIOCGNAME(255), name);
  ioctl(fd, JSIOCGAXMAP, axmap);
  ioctl(fd, JSIOCGBTNMAP, btnmap);
  while (1) {
    if (ioperm(0x378, 3, 1)) {
      perror("ioperm");
      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;
    default:
      break;
    }
    system("clear");
    binprint(inb(0x378 + 0), bin_DTA);
    binprint(inb(0x378 + 1), bin_STA);
    binprint(inb(0x378 + 2), bin_CTR);
    printf("Name: %s\nVersion %d\nButtons: %d\n", name, version, buttons);
    printf("\n------------ RUNNING SCAN ------------\n");
    printf("Data\t\tStatus\t\tControl\n");
    printf("----\t\t------\t\t-------\n");
    printf("%d  \t\t%d    \t\t%d     \n", inb(0x378 + 0), inb(0x378 + 1),
           inb(0x378 + 2));
    printf("%s\t%s\t%s\n\n", bin_DTA, bin_STA, bin_CTR);
    printf("Test area:\n----------\n\r");
    if (axes) {
      printf("Axes: ");
      for (i = 0; i < axes; i++)
        printf("%2d:%6d ", i, axis[i]);
    }
    if (buttons) {
      printf("\n\nButtons: ");
      for (i = 0; i < buttons; i++)
        printf("%2d:%s", i, button[i] ? "on " : "off");
    }
    printf("\n\nInterrupt (CTRL+C) to exit...\n");
    fflush(stdout);
    usleep(10000);
    if (read(fd, &js, sizeof(struct js_event)) != sizeof(struct js_event)) {
      perror("\njstest: error reading");
      return 1;
    }
    if (ioperm(0x378, 3, 0)) {
      perror("ioperm");
      exit(1);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x4a0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movb   $0x2,-0x319(%rbp)
movb   $0x2,-0x329(%rbp)
movl   $0x800,-0x33c(%rbp)
lea    0xde8(%rip),%rsi
lea    -0x440(%rbp),%rdi
mov    $0xff,%edx
call   1090 <memcpy@plt>
mov    0x2d80(%rip),%rax
mov    (%rax),%rdx
mov    0x2d5e(%rip),%rax
mov    (%rax),%rax
sub    %rax,%rdx
mov    %rdx,%rax
add    $0x1,%rax
mov    %rsp,%rcx
mov    %rcx,-0x448(%rbp)
add    $0x10,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x488(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x450(%rbp)
mov    0x2d11(%rip),%rax
mov    (%rax),%eax
add    $0x1,%eax
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x480(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x458(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    12d3 <main+0xf3>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe49(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x474(%rbp)
jmp    178e <main+0x5ae>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2cfe(%rip),%rax
mov    (%rax),%esi
call   10b0 <open@plt>
mov    %eax,-0x314(%rbp)
cmp    $0x0,%eax
jge    1318 <main+0x138>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe27(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
mov    -0x314(%rbp),%edi
lea    -0x470(%rbp),%rsi
mov    $0x18,%edx
call   1060 <read@plt>
cltq
cmp    $0x18,%rax
je     135d <main+0x17d>
lea    0xe0b(%rip),%rdi
call   10d0 <perror@plt>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0x474(%rbp)
jmp    178e <main+0x5ae>
mov    -0x314(%rbp),%edi
mov    0x2c7e(%rip),%rax
mov    (%rax),%esi
lea    -0x33c(%rbp),%rdx
mov    $0x0,%al
call   1050 <ioctl@plt>
mov    -0x314(%rbp),%edi
mov    0x2c39(%rip),%rax
mov    (%rax),%esi
lea    -0x329(%rbp),%rdx
mov    $0x0,%al
call   1050 <ioctl@plt>
mov    -0x314(%rbp),%edi
mov    0x2c14(%rip),%rax
mov    (%rax),%esi
lea    -0x319(%rbp),%rdx
mov    $0x0,%al
call   1050 <ioctl@plt>
mov    -0x314(%rbp),%eax
mov    %eax,-0x48c(%rbp)
mov    $0xff,%edi
call   10f0 <JSIOCGNAME@plt>
mov    -0x48c(%rbp),%edi
mov    %eax,%esi
lea    -0x440(%rbp),%rdx
mov    $0x0,%al
call   1050 <ioctl@plt>
mov    -0x480(%rbp),%rdx
mov    -0x314(%rbp),%edi
mov    0x2be4(%rip),%rax
mov    (%rax),%esi
mov    $0x0,%al
call   1050 <ioctl@plt>
mov    -0x488(%rbp),%rdx
mov    -0x314(%rbp),%edi
mov    0x2bbf(%rip),%rax
mov    (%rax),%esi
mov    $0x0,%al
call   1050 <ioctl@plt>
jmp    141f <main+0x23f>
mov    $0x378,%edi
mov    $0x3,%esi
mov    $0x1,%edx
call   1070 <ioperm@plt>
cmp    $0x0,%rax
je     1453 <main+0x273>
lea    0xd20(%rip),%rdi
call   10d0 <perror@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
mov    -0x470(%rbp),%eax
mov    0x2b48(%rip),%rcx
mov    (%rcx),%ecx
not    %ecx
and    %ecx,%eax
mov    %eax,-0x490(%rbp)
sub    $0x80,%eax
je     1492 <main+0x2b2>
jmp    147c <main+0x29c>
mov    -0x490(%rbp),%eax
sub    $0x81,%eax
je     14ae <main+0x2ce>
jmp    14cb <main+0x2eb>
mov    -0x460(%rbp),%dl
mov    -0x328(%rbp),%rax
mov    -0x468(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
jmp    14d0 <main+0x2f0>
movsbl -0x460(%rbp),%edx
mov    -0x338(%rbp),%rax
mov    -0x468(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
jmp    14d0 <main+0x2f0>
jmp    14d0 <main+0x2f0>
lea    0xc94(%rip),%rdi
call   1030 <system@plt>
mov    $0x378,%edi
call   1080 <inb@plt>
mov    %eax,%edi
lea    -0x110(%rbp),%rsi
call   10c0 <binprint@plt>
mov    $0x379,%edi
call   1080 <inb@plt>
mov    %eax,%edi
lea    -0x210(%rbp),%rsi
call   10c0 <binprint@plt>
mov    $0x37a,%edi
call   1080 <inb@plt>
mov    %eax,%edi
lea    -0x310(%rbp),%rsi
call   10c0 <binprint@plt>
lea    -0x440(%rbp),%rsi
mov    -0x33c(%rbp),%edx
movzbl -0x319(%rbp),%ecx
lea    0xc32(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xc45(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xc60(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xc69(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x378,%edi
call   1080 <inb@plt>
mov    %eax,-0x498(%rbp)
mov    $0x379,%edi
call   1080 <inb@plt>
mov    %eax,-0x494(%rbp)
mov    $0x37a,%edi
call   1080 <inb@plt>
mov    -0x498(%rbp),%esi
mov    -0x494(%rbp),%edx
mov    %eax,%ecx
lea    0xc3a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x110(%rbp),%rsi
lea    -0x210(%rbp),%rdx
lea    -0x310(%rbp),%rcx
lea    0xc2e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xc2b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpb   $0x0,-0x329(%rbp)
je     165f <main+0x47f>
lea    0xc28(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x318(%rbp)
mov    -0x318(%rbp),%eax
movzbl -0x329(%rbp),%ecx
cmp    %ecx,%eax
jge    165a <main+0x47a>
mov    -0x318(%rbp),%esi
mov    -0x338(%rbp),%rax
movslq -0x318(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
lea    0xbeb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x318(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x318(%rbp)
jmp    160c <main+0x42c>
jmp    165f <main+0x47f>
cmpb   $0x0,-0x319(%rbp)
je     16ed <main+0x50d>
lea    0xbc0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x318(%rbp)
mov    -0x318(%rbp),%eax
movzbl -0x319(%rbp),%ecx
cmp    %ecx,%eax
jge    16e8 <main+0x508>
mov    -0x318(%rbp),%esi
mov    -0x328(%rbp),%rax
movslq -0x318(%rbp),%rcx
movsbl (%rax,%rcx,1),%ecx
lea    0xb92(%rip),%rdx
lea    0xb87(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rdx
lea    0xb72(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x318(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x318(%rbp)
jmp    1684 <main+0x4a4>
jmp    16ed <main+0x50d>
lea    0xb5a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x289e(%rip),%rax
mov    (%rax),%edi
call   10a0 <fflush@plt>
mov    $0x2710,%edi
call   1100 <usleep@plt>
mov    -0x314(%rbp),%edi
lea    -0x470(%rbp),%rsi
mov    $0x18,%edx
call   1060 <read@plt>
cltq
cmp    $0x18,%rax
je     1758 <main+0x578>
lea    0xa10(%rip),%rdi
call   10d0 <perror@plt>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0x474(%rbp)
jmp    178e <main+0x5ae>
mov    $0x378,%edi
mov    $0x3,%esi
xor    %edx,%edx
call   1070 <ioperm@plt>
cmp    $0x0,%rax
je     1789 <main+0x5a9>
lea    0x9ea(%rip),%rdi
call   10d0 <perror@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
jmp    141a <main+0x23a>
mov    -0x448(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x438,%rsp
mov    %rsi,%r15
mov    %edi,%r12d
movb   $0x2,-0x29(%rbp)
movb   $0x2,-0x2a(%rbp)
movl   $0x800,-0x30(%rbp)
lea    0xde0(%rip),%rsi
lea    -0x160(%rbp),%rdi
mov    $0xff,%edx
call   10a0 <memcpy@plt>
mov    %rsp,%r13
mov    0x2d75(%rip),%rax
mov    (%rax),%rax
mov    0x2d5b(%rip),%rcx
sub    (%rcx),%rax
add    $0x10,%rax
and    $0xfffffffffffffff0,%rax
mov    %rsp,%r14
sub    %rax,%r14
mov    %r14,%rsp
mov    0x2d30(%rip),%rax
mov    (%rax),%eax
add    $0x1,%eax
mov    %rsp,%rbx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
cmp    $0x1,%r12d
jg     12a3 <main+0xb3>
mov    (%r15),%rsi
lea    0xe79(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r13,%rsp
mov    %ebx,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x8(%r15),%rdi
mov    0x2d32(%rip),%rax
mov    (%rax),%esi
call   10c0 <open@plt>
test   %eax,%eax
js     15c4 <main+0x3d4>
mov    %eax,%r12d
lea    -0x58(%rbp),%rsi
mov    %eax,%edi
mov    $0x18,%edx
call   1070 <read@plt>
cmp    $0x18,%eax
jne    1594 <main+0x3a4>
mov    %r13,-0x40(%rbp)
mov    0x2d04(%rip),%rax
mov    (%rax),%esi
lea    -0x30(%rbp),%rdx
mov    %r12d,%edi
xor    %eax,%eax
call   1060 <ioctl@plt>
mov    0x2cc5(%rip),%rax
mov    (%rax),%esi
lea    -0x2a(%rbp),%rdx
mov    %r12d,%edi
xor    %eax,%eax
call   1060 <ioctl@plt>
mov    0x2ca6(%rip),%rax
mov    (%rax),%esi
lea    -0x29(%rbp),%rdx
mov    %r12d,%edi
xor    %eax,%eax
call   1060 <ioctl@plt>
mov    $0xff,%edi
call   1100 <JSIOCGNAME@plt>
lea    -0x160(%rbp),%rdx
mov    %r12d,%edi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <ioctl@plt>
mov    0x2c92(%rip),%rax
mov    (%rax),%esi
mov    %r12d,%edi
mov    %rbx,%rdx
xor    %eax,%eax
call   1060 <ioctl@plt>
mov    0x2c74(%rip),%rax
mov    (%rax),%esi
mov    %r12d,-0x34(%rbp)
mov    %r12d,%edi
mov    %r14,%rdx
xor    %eax,%eax
call   1060 <ioctl@plt>
lea    0xe72(%rip),%r15
lea    0xe72(%rip),%r12
lea    0xe4f(%rip),%r13
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    $0x378,%edi
mov    $0x3,%esi
mov    $0x1,%edx
call   1080 <ioperm@plt>
test   %rax,%rax
jne    157e <main+0x38e>
lea    0xdb7(%rip),%rdi
call   1040 <system@plt>
mov    $0x378,%edi
call   1090 <inb@plt>
mov    %eax,%edi
lea    -0x460(%rbp),%rsi
call   10d0 <binprint@plt>
mov    $0x379,%edi
call   1090 <inb@plt>
mov    %eax,%edi
lea    -0x360(%rbp),%rsi
call   10d0 <binprint@plt>
mov    $0x37a,%edi
call   1090 <inb@plt>
mov    %eax,%edi
lea    -0x260(%rbp),%rsi
call   10d0 <binprint@plt>
mov    -0x30(%rbp),%edx
movzbl -0x29(%rbp),%ecx
lea    0xd62(%rip),%rdi
lea    -0x160(%rbp),%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xdcf(%rip),%rdi
call   1030 <puts@plt>
lea    0xdeb(%rip),%rdi
call   1030 <puts@plt>
lea    0xdf5(%rip),%rdi
call   1030 <puts@plt>
mov    $0x378,%edi
call   1090 <inb@plt>
mov    %eax,%ebx
mov    $0x379,%edi
call   1090 <inb@plt>
mov    %eax,%r14d
mov    $0x37a,%edi
call   1090 <inb@plt>
lea    0xd27(%rip),%rdi
mov    %ebx,%esi
mov    %r14d,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xd29(%rip),%rdi
lea    -0x460(%rbp),%rsi
lea    -0x360(%rbp),%rdx
lea    -0x260(%rbp),%rcx
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xd11(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
cmpb   $0x0,-0x2a(%rbp)
je     14e7 <main+0x2f7>
lea    0xd15(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
cmpb   $0x0,-0x2a(%rbp)
je     14e7 <main+0x2f7>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
mov    %r13,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%ebx
movzbl -0x2a(%rbp),%eax
cmp    %eax,%ebx
jb     14d0 <main+0x2e0>
cmpb   $0x0,-0x29(%rbp)
je     152a <main+0x33a>
lea    0xce8(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
cmpb   $0x0,-0x29(%rbp)
je     152a <main+0x33a>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r15,%rdi
mov    %ebx,%esi
mov    %r12,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%ebx
movzbl -0x29(%rbp),%eax
cmp    %eax,%ebx
jb     1510 <main+0x320>
lea    0xd16(%rip),%rdi
call   1030 <puts@plt>
mov    0x2a6b(%rip),%rax
mov    (%rax),%edi
call   10b0 <fflush@plt>
mov    $0x2710,%edi
call   1110 <usleep@plt>
mov    -0x34(%rbp),%edi
lea    -0x58(%rbp),%rsi
mov    $0x18,%edx
call   1070 <read@plt>
cmp    $0x18,%eax
jne    15aa <main+0x3ba>
mov    $0x378,%edi
mov    $0x3,%esi
xor    %edx,%edx
call   1080 <ioperm@plt>
test   %rax,%rax
je     1390 <main+0x1a0>
lea    0xbdf(%rip),%rdi
call   10e0 <perror@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
lea    0xbb2(%rip),%rdi
call   10e0 <perror@plt>
mov    $0x1,%ebx
jmp    128f <main+0x9f>
lea    0xb9c(%rip),%rdi
call   10e0 <perror@plt>
mov    $0x1,%ebx
mov    -0x40(%rbp),%r13
jmp    128f <main+0x9f>
mov    0x8(%r15),%rsi
lea    0xb5f(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>

LLVM IR (-O0):
%struct.js_event = type { i32, i64, i8 }
@__const.main.name = [255 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\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@KEY_MAX = global i64 0
@BTN_MISC = global i64 0
@ABS_MAX = global i32 0
@.str = [47 x i8] c"Usage: %s <device>\0A\0ADevice could be: /dev/js0\0A\00"
@O_RDONLY = global i32 0
@.str.1 = [31 x i8] c"Error: Cannot open device %s!\0A\00"
@.str.2 = [23 x i8] c"\0Ajstest: error reading\00"
@JSIOCGVERSION = global i32 0
@JSIOCGAXES = global i32 0
@JSIOCGBUTTONS = global i32 0
@JSIOCGAXMAP = global i32 0
@JSIOCGBTNMAP = global i32 0
@.str.3 = [7 x i8] c"ioperm\00"
@JS_EVENT_INIT = global i32 0
@.str.4 = [6 x i8] c"clear\00"
@.str.5 = [33 x i8] c"Name: %s\0AVersion %d\0AButtons: %d\0A\00"
@.str.6 = [41 x i8] c"\0A------------ RUNNING SCAN ------------\0A\00"
@.str.7 = [23 x i8] c"Data\09\09Status\09\09Control\0A\00"
@.str.8 = [23 x i8] c"----\09\09------\09\09-------\0A\00"
@.str.9 = [23 x i8] c"%d \09\09%d \09\09%d \0A\00"
@.str.10 = [11 x i8] c"%s\09%s\09%s\0A\0A\00"
@.str.11 = [24 x i8] c"Test area:\0A----------\0A\0D\00"
@.str.12 = [7 x i8] c"Axes: \00"
@.str.13 = [9 x i8] c"%2d:%6d \00"
@.str.14 = [12 x i8] c"\0A\0AButtons: \00"
@.str.15 = [7 x i8] c"%2d:%s\00"
@.str.16 = [4 x i8] c"on \00"
@.str.17 = [4 x i8] c"off\00"
@.str.18 = [33 x i8] c"\0A\0AInterrupt (CTRL+C) to exit...\0A\00"
@stdout = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [255 x i8]
%7 = alloca [255 x i8]
%8 = alloca [255 x i8]
%9 = alloca i32
%10 = alloca i32
%11 = alloca i8
%12 = alloca i8*
%13 = alloca i8
%14 = alloca i32*
%15 = alloca i32
%16 = alloca [255 x i8]
%17 = alloca i8*
%18 = alloca i64
%19 = alloca i64
%20 = alloca %struct.js_event
%21 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8 2, i8* %11
store i8 2, i8* %13
store i32 2048, i32* %15
%22 = bitcast [255 x i8]* %16 to i8*
%23 = load i64, i64* @KEY_MAX
%24 = load i64, i64* @BTN_MISC
%25 = sub nsw i64 %23, %24
%26 = add nsw i64 %25, 1
%27 = call i8* @llvm.stacksave()
store i8* %27, i8** %17
%28 = alloca i8, i64 %26
store i64 %26, i64* %18
%29 = load i32, i32* @ABS_MAX
%30 = add nsw i32 %29, 1
%31 = zext i32 %30 to i64
%32 = alloca i8, i64 %31
store i64 %31, i64* %19
%33 = load i32, i32* %4
%34 = icmp slt i32 %33, 2
br i1 %34, label %35, label %40
35: ; preds = %2
%36 = load i8**, i8*** %5
%37 = getelementptr inbounds i8*, i8** %36, i64 0
%38 = load i8*, i8** %37
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i8* %38)
store i32 0, i32* %3
store i32 1, i32* %21
br label %202
40: ; preds = %2
%41 = load i8**, i8*** %5
%42 = getelementptr inbounds i8*, i8** %41, i64 1
%43 = load i8*, i8** %42
%44 = load i32, i32* @O_RDONLY
%45 = call i32 @open(i8* %43, i32 %44)
store i32 %45, i32* %9
%46 = icmp slt i32 %45, 0
br i1 %46, label %47, label %53
47: ; preds = %40
%48 = load i8**, i8*** %5
%49 = getelementptr inbounds i8*, i8** %48, i64 1
%50 = load i8*, i8** %49
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i8* %50)
%52 = call i32 @exit(i32 1)
unreachable
53: ; preds = %40
%54 = load i32, i32* %9
%55 = call i32 @read(i32 %54, %struct.js_event* %20, i32 24)
%56 = sext i32 %55 to i64
%57 = icmp ne i64 %56, 24
br i1 %57, label %58, label %60
58: ; preds = %53
%59 = call i32 @perror(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %3
store i32 1, i32* %21
br label %202
60: ; preds = %53
%61 = load i32, i32* %9
%62 = load i32, i32* @JSIOCGVERSION
%63 = call i32 (i32, i32, ...) @ioctl(i32 %61, i32 %62, i32* %15)
%64 = load i32, i32* %9
%65 = load i32, i32* @JSIOCGAXES
%66 = call i32 (i32, i32, ...) @ioctl(i32 %64, i32 %65, i8* %13)
%67 = load i32, i32* %9
%68 = load i32, i32* @JSIOCGBUTTONS
%69 = call i32 (i32, i32, ...) @ioctl(i32 %67, i32 %68, i8* %11)
%70 = load i32, i32* %9
%71 = call i32 @JSIOCGNAME(i32 255)
%72 = getelementptr inbounds [255 x i8], [255 x i8]* %16, i64 0, i64 0
%73 = call i32 (i32, i32, ...) @ioctl(i32 %70, i32 %71, i8* %72)
%74 = load i32, i32* %9
%75 = load i32, i32* @JSIOCGAXMAP
%76 = call i32 (i32, i32, ...) @ioctl(i32 %74, i32 %75, i8* %32)
%77 = load i32, i32* %9
%78 = load i32, i32* @JSIOCGBTNMAP
%79 = call i32 (i32, i32, ...) @ioctl(i32 %77, i32 %78, i8* %28)
br label %80
80: ; preds = %201, %60
br label %81
81: ; preds = %80
%82 = call i64 @ioperm(i32 888, i32 3, i32 1)
%83 = icmp ne i64 %82, 0
br i1 %83, label %84, label %87
84: ; preds = %81
%85 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%86 = call i32 @exit(i32 1)
unreachable
87: ; preds = %81
%88 = getelementptr inbounds %struct.js_event, %struct.js_event* %20, i32 0, i32 0
%89 = load i32, i32* %88
%90 = load i32, i32* @JS_EVENT_INIT
%91 = xor i32 %90, -1
%92 = and i32 %89, %91
switch i32 %92, label %108 [
i32 128, label %93
i32 129, label %100
]
93: ; preds = %87
%94 = getelementptr inbounds %struct.js_event, %struct.js_event* %20, i32 0, i32 2
%95 = load i8, i8* %94
%96 = load i8*, i8** %12
%97 = getelementptr inbounds %struct.js_event, %struct.js_event* %20, i32 0, i32 1
%98 = load i64, i64* %97
%99 = getelementptr inbounds i8, i8* %96, i64 %98
store i8 %95, i8* %99
br label %109
100: ; preds = %87
%101 = getelementptr inbounds %struct.js_event, %struct.js_event* %20, i32 0, i32 2
%102 = load i8, i8* %101
%103 = sext i8 %102 to i32
%104 = load i32*, i32** %14
%105 = getelementptr inbounds %struct.js_event, %struct.js_event* %20, i32 0, i32 1
%106 = load i64, i64* %105
%107 = getelementptr inbounds i32, i32* %104, i64 %106
store i32 %103, i32* %107
br label %109
108: ; preds = %87
br label %109
109: ; preds = %108, %100, %93
%110 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%111 = call i32 @inb(i32 888)
%112 = getelementptr inbounds [255 x i8], [255 x i8]* %6, i64 0, i64 0
%113 = call i32 @binprint(i32 %111, i8* %112)
%114 = call i32 @inb(i32 889)
%115 = getelementptr inbounds [255 x i8], [255 x i8]* %7, i64 0, i64 0
%116 = call i32 @binprint(i32 %114, i8* %115)
%117 = call i32 @inb(i32 890)
%118 = getelementptr inbounds [255 x i8], [255 x i8]* %8, i64 0, i64 0
%119 = call i32 @binprint(i32 %117, i8* %118)
%120 = getelementptr inbounds [255 x i8], [255 x i8]* %16, i64 0, i64 0
%121 = load i32, i32* %15
%122 = load i8, i8* %11
%123 = zext i8 %122 to i32
%124 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0), i8* %120, i32 %121, i32 %123)
%125 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.6, i64 0, i64 0))
%126 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0))
%127 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.8, i64 0, i64 0))
%128 = call i32 @inb(i32 888)
%129 = call i32 @inb(i32 889)
%130 = call i32 @inb(i32 890)
%131 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.9, i64 0, i64 0), i32 %128, i32 %129, i32 %130)
%132 = getelementptr inbounds [255 x i8], [255 x i8]* %6, i64 0, i64 0
%133 = getelementptr inbounds [255 x i8], [255 x i8]* %7, i64 0, i64 0
%134 = getelementptr inbounds [255 x i8], [255 x i8]* %8, i64 0, i64 0
%135 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.10, i64 0, i64 0), i8* %132, i8* %133, i8* %134)
%136 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.11, i64 0, i64 0))
%137 = load i8, i8* %13
%138 = icmp ne i8 %137, 0
br i1 %138, label %139, label %158
139: ; preds = %109
%140 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.12, i64 0, i64 0))
store i32 0, i32* %10
br label %141
141: ; preds = %154, %139
%142 = load i32, i32* %10
%143 = load i8, i8* %13
%144 = zext i8 %143 to i32
%145 = icmp slt i32 %142, %144
br i1 %145, label %146, label %157
146: ; preds = %141
%147 = load i32, i32* %10
%148 = load i32*, i32** %14
%149 = load i32, i32* %10
%150 = sext i32 %149 to i64
%151 = getelementptr inbounds i32, i32* %148, i64 %150
%152 = load i32, i32* %151
%153 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.13, i64 0, i64 0), i32 %147, i32 %152)
br label %154
154: ; preds = %146
%155 = load i32, i32* %10
%156 = add nsw i32 %155, 1
store i32 %156, i32* %10
br label %141
157: ; preds = %141
br label %158
158: ; preds = %157, %109
%159 = load i8, i8* %11
%160 = icmp ne i8 %159, 0
br i1 %160, label %161, label %184
161: ; preds = %158
%162 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.14, i64 0, i64 0))
store i32 0, i32* %10
br label %163
163: ; preds = %180, %161
%164 = load i32, i32* %10
%165 = load i8, i8* %11
%166 = zext i8 %165 to i32
%167 = icmp slt i32 %164, %166
br i1 %167, label %168, label %183
168: ; preds = %163
%169 = load i32, i32* %10
%170 = load i8*, i8** %12
%171 = load i32, i32* %10
%172 = sext i32 %171 to i64
%173 = getelementptr inbounds i8, i8* %170, i64 %172
%174 = load i8, i8* %173
%175 = sext i8 %174 to i32
%176 = icmp ne i32 %175, 0
%177 = zext i1 %176 to i64
%178 = select i1 %176, 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.17, i64 0, i64 0)
%179 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.15, i64 0, i64 0), i32 %169, i8* %178)
br label %180
180: ; preds = %168
%181 = load i32, i32* %10
%182 = add nsw i32 %181, 1
store i32 %182, i32* %10
br label %163
183: ; preds = %163
br label %184
184: ; preds = %183, %158
%185 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.18, i64 0, i64 0))
%186 = load i32, i32* @stdout
%187 = call i32 @fflush(i32 %186)
%188 = call i32 @usleep(i32 10000)
%189 = load i32, i32* %9
%190 = call i32 @read(i32 %189, %struct.js_event* %20, i32 24)
%191 = sext i32 %190 to i64
%192 = icmp ne i64 %191, 24
br i1 %192, label %193, label %195
193: ; preds = %184
%194 = call i32 @perror(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %3
store i32 1, i32* %21
br label %202
195: ; preds = %184
%196 = call i64 @ioperm(i32 888, i32 3, i32 0)
%197 = icmp ne i64 %196, 0
br i1 %197, label %198, label %201
198: ; preds = %195
%199 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%200 = call i32 @exit(i32 1)
unreachable
201: ; preds = %195
br label %80
202: ; preds = %193, %58, %35
%203 = load i8*, i8** %17
%204 = load i32, i32* %3
ret i32 %204
}

LLVM IR (-O2):
%struct.js_event = type { i32, i64, i8 }
@__const.main.name = [255 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\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@KEY_MAX = global i64 0
@BTN_MISC = global i64 0
@ABS_MAX = global i32 0
@.str = [47 x i8] c"Usage: %s <device>\0A\0ADevice could be: /dev/js0\0A\00"
@O_RDONLY = global i32 0
@.str.1 = [31 x i8] c"Error: Cannot open device %s!\0A\00"
@.str.2 = [23 x i8] c"\0Ajstest: error reading\00"
@JSIOCGVERSION = global i32 0
@JSIOCGAXES = global i32 0
@JSIOCGBUTTONS = global i32 0
@JSIOCGAXMAP = global i32 0
@JSIOCGBTNMAP = global i32 0
@.str.3 = [7 x i8] c"ioperm\00"
@JS_EVENT_INIT = global i32 0
@.str.4 = [6 x i8] c"clear\00"
@.str.5 = [33 x i8] c"Name: %s\0AVersion %d\0AButtons: %d\0A\00"
@.str.9 = [23 x i8] c"%d \09\09%d \09\09%d \0A\00"
@.str.10 = [11 x i8] c"%s\09%s\09%s\0A\0A\00"
@.str.11 = [24 x i8] c"Test area:\0A----------\0A\0D\00"
@.str.12 = [7 x i8] c"Axes: \00"
@.str.13 = [9 x i8] c"%2d:%6d \00"
@.str.14 = [12 x i8] c"\0A\0AButtons: \00"
@.str.15 = [7 x i8] c"%2d:%s\00"
@.str.17 = [4 x i8] c"off\00"
@stdout = global i32 0
@str = [40 x i8] c"\0A------------ RUNNING SCAN ------------\00"
@str.19 = [22 x i8] c"Data\09\09Status\09\09Control\00"
@str.20 = [22 x i8] c"----\09\09------\09\09-------\00"
@str.21 = [32 x i8] c"\0A\0AInterrupt (CTRL+C) to exit...\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [255 x i8]
%4 = alloca [255 x i8]
%5 = alloca [255 x i8]
%6 = alloca i8
%7 = alloca i8
%8 = alloca i32
%9 = alloca [255 x i8]
%10 = alloca %struct.js_event
%11 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 0
%12 = getelementptr inbounds [255 x i8], [255 x i8]* %4, i64 0, i64 0
%13 = getelementptr inbounds [255 x i8], [255 x i8]* %5, i64 0, i64 0
store i8 2, i8* %6
store i8 2, i8* %7
%14 = bitcast i32* %8 to i8*
store i32 2048, i32* %8
%15 = getelementptr inbounds [255 x i8], [255 x i8]* %9, i64 0, i64 0
%16 = load i64, i64* @KEY_MAX
%17 = load i64, i64* @BTN_MISC
%18 = add i64 %16, 1
%19 = sub i64 %18, %17
%20 = tail call i8* @llvm.stacksave()
%21 = alloca i8, i64 %19
%22 = load i32, i32* @ABS_MAX
%23 = add nsw i32 %22, 1
%24 = zext i32 %23 to i64
%25 = alloca i8, i64 %24
%26 = bitcast %struct.js_event* %10 to i8*
%27 = icmp slt i32 %0, 2
br i1 %27, label %28, label %31
28: ; preds = %2
%29 = load i8*, i8** %1
%30 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i8* %29)
br label %128
31: ; preds = %2
%32 = getelementptr inbounds i8*, i8** %1, i64 1
%33 = load i8*, i8** %32
%34 = load i32, i32* @O_RDONLY
%35 = tail call i32 @open(i8* %33, i32 %34)
%36 = icmp slt i32 %35, 0
br i1 %36, label %37, label %41
37: ; preds = %31
%38 = load i8*, i8** %32
%39 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i8* %38)
%40 = tail call i32 @exit(i32 1)
unreachable
41: ; preds = %31
%42 = call i32 @read(i32 %35, %struct.js_event* %10, i32 24)
%43 = icmp eq i32 %42, 24
br i1 %43, label %46, label %44
44: ; preds = %41
%45 = tail call i32 @perror(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
br label %128
46: ; preds = %41
%47 = load i32, i32* @JSIOCGVERSION
%48 = call i32 (i32, i32, ...) @ioctl(i32 %35, i32 %47, i32* %8)
%49 = load i32, i32* @JSIOCGAXES
%50 = call i32 (i32, i32, ...) @ioctl(i32 %35, i32 %49, i8* %7)
%51 = load i32, i32* @JSIOCGBUTTONS
%52 = call i32 (i32, i32, ...) @ioctl(i32 %35, i32 %51, i8* %6)
%53 = call i32 @JSIOCGNAME(i32 255)
%54 = call i32 (i32, i32, ...) @ioctl(i32 %35, i32 %53, i8* %15)
%55 = load i32, i32* @JSIOCGAXMAP
%56 = call i32 (i32, i32, ...) @ioctl(i32 %35, i32 %55, i8* %25)
%57 = load i32, i32* @JSIOCGBTNMAP
%58 = call i32 (i32, i32, ...) @ioctl(i32 %35, i32 %57, i8* %21)
br label %59
59: ; preds = %122, %46
%60 = call i64 @ioperm(i32 888, i32 3, i32 1)
%61 = icmp eq i64 %60, 0
br i1 %61, label %65, label %62
62: ; preds = %59
%63 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%64 = call i32 @exit(i32 1)
unreachable
65: ; preds = %59
%66 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%67 = call i32 @inb(i32 888)
%68 = call i32 @binprint(i32 %67, i8* %11)
%69 = call i32 @inb(i32 889)
%70 = call i32 @binprint(i32 %69, i8* %12)
%71 = call i32 @inb(i32 890)
%72 = call i32 @binprint(i32 %71, i8* %13)
%73 = load i32, i32* %8
%74 = load i8, i8* %6
%75 = zext i8 %74 to i32
%76 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0), i8* %15, i32 %73, i32 %75)
%77 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str, i64 0, i64 0))
%78 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.19, i64 0, i64 0))
%79 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.20, i64 0, i64 0))
%80 = call i32 @inb(i32 888)
%81 = call i32 @inb(i32 889)
%82 = call i32 @inb(i32 890)
%83 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.9, i64 0, i64 0), i32 %80, i32 %81, i32 %82)
%84 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.10, i64 0, i64 0), i8* %11, i8* %12, i8* %13)
%85 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.11, i64 0, i64 0))
%86 = load i8, i8* %7
%87 = icmp eq i8 %86, 0
br i1 %87, label %99, label %88
88: ; preds = %65
%89 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.12, i64 0, i64 0))
%90 = load i8, i8* %7
%91 = icmp eq i8 %90, 0
br i1 %91, label %99, label %92
92: ; preds = %88, %92
%93 = phi i32 [ %95, %92 ], [ 0, %88 ]
%94 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.13, i64 0, i64 0), i32 %93, i32 undef)
%95 = add nuw nsw i32 %93, 1
%96 = load i8, i8* %7
%97 = zext i8 %96 to i32
%98 = icmp ult i32 %95, %97
br i1 %98, label %92, label %99
99: ; preds = %92, %88, %65
%100 = load i8, i8* %6
%101 = icmp eq i8 %100, 0
br i1 %101, label %113, label %102
102: ; preds = %99
%103 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.14, i64 0, i64 0))
%104 = load i8, i8* %6
%105 = icmp eq i8 %104, 0
br i1 %105, label %113, label %106
106: ; preds = %102, %106
%107 = phi i32 [ %109, %106 ], [ 0, %102 ]
%108 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.15, i64 0, i64 0), i32 %107, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.17, i64 0, i64 0))
%109 = add nuw nsw i32 %107, 1
%110 = load i8, i8* %6
%111 = zext i8 %110 to i32
%112 = icmp ult i32 %109, %111
br i1 %112, label %106, label %113
113: ; preds = %106, %102, %99
%114 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.21, i64 0, i64 0))
%115 = load i32, i32* @stdout
%116 = call i32 @fflush(i32 %115)
%117 = call i32 @usleep(i32 10000)
%118 = call i32 @read(i32 %35, %struct.js_event* %10, i32 24)
%119 = icmp eq i32 %118, 24
br i1 %119, label %122, label %120
120: ; preds = %113
%121 = call i32 @perror(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
br label %128
122: ; preds = %113
%123 = call i64 @ioperm(i32 888, i32 3, i32 0)
%124 = icmp eq i64 %123, 0
br i1 %124, label %59, label %125
125: ; preds = %122
%126 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%127 = call i32 @exit(i32 1)
unreachable
128: ; preds = %120, %44, %28
%129 = phi i32 [ 0, %28 ], [ 1, %44 ], [ 1, %120 ]
ret i32 %129
}