#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */
typedef struct TYPE_2__ TYPE_1__;

/* Type definitions */
struct TYPE_2__ {
  int tv_sec;
  char *tv_usec;
};
struct input_event {
  scalar_t__ type;
  int value;
  TYPE_1__ time;
  int /*<<< orphan*/ code;
};
typedef int /*<<< orphan*/ name;
typedef int /*<<< orphan*/ keybits;
typedef int /*<<< orphan*/ evbits;

/* Variables and functions */
int EINVAL;
int /*<<< orphan*/ EVIOCGBIT(scalar_t__, int);
int /*<<< orphan*/ EVIOCGID;
int /*<<< orphan*/ EVIOCGNAME(int);
int /*<<< orphan*/ EVIOCGVERSION;
scalar_t__ EV_KEY;
scalar_t__ EV_LED;
scalar_t__ EV_SYN;
size_t ID_BUS;
size_t ID_PRODUCT;
size_t ID_VENDOR;
size_t ID_VERSION;
int /*<<< orphan*/ O_RDWR;
int /*<<< orphan*/ SYN_DROPPED;
int /*<<< orphan*/ close(int);
int errno;
int /*<<< orphan*/ flash_led(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ ioctl(int, int /*<<< orphan*/, ...);
int open(char *, int /*<<< orphan*/);
int read(int, struct input_event *, int);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ stderr;
char *strerror(int);
int main(int argc, char *argv[]) {
  int fd, sz;
  unsigned i;
  unsigned version;
  unsigned short id[4];
  char name[256] = "N/A";
  struct input_event ev[16];
  if (argc < 2) {
    fprintf(stderr,
            "Usage: %s /dev/input/eventN\n"
            "Where X = input device number\n",
            argv[0]);
    return EINVAL;
  }
  if ((fd = open(argv[1], O_RDWR)) < 0) {
    fprintf(stderr,
            "ERR %d:\n"
            "Unable to open `%s'\n"
            "%s\n",
            errno, argv[1], strerror(errno));
    return 1;
  }
  ioctl(fd, EVIOCGVERSION, &version);
  ioctl(fd, EVIOCGID, id);
  ioctl(fd, EVIOCGNAME(sizeof(name)), name);
  unsigned evbits;
  ioctl(fd, EVIOCGBIT(0, sizeof(evbits)), &evbits);
  unsigned long long keybits[4] = {0, 0, 0, 0};
  ioctl(fd, EVIOCGBIT(EV_KEY, sizeof(keybits)), keybits);
  fprintf(stderr,
          "Name      : %s\n"
          "Version   : %d.%d.%d\n"
          "ID        : Bus=%04x Vendor=%04x Product=%04x Version=%04x\n"
          "EV bits   : %x\n"
          "KEY bits  : %016llx %016llx %016llx %016llx\n"
          "----------\n",
          name, version >> 16, (version >> 8) & 0xff, version & 0xff,
          id[ID_BUS], id[ID_VENDOR], id[ID_PRODUCT], id[ID_VERSION], evbits,
          keybits[3], keybits[2], keybits[1], keybits[0]);
  int waitsyn = 0;
  while (1) {
    flash_led(fd);
    sleep(1);
  }
  for (;;) {
    sz = read(fd, ev, sizeof(struct input_event) * 16);
    if (sz < (int)sizeof(struct input_event)) {
      fprintf(stderr,
              "ERR %d:\n"
              "Reading of `%s' failed\n"
              "%s\n",
              errno, argv[1], strerror(errno));
      goto fine;
    }
    for (i = 0; i < sz / sizeof(struct input_event); ++i) {
      if (waitsyn) {
        if (ev[i].type == EV_SYN)
          waitsyn = 0;
        continue;
      }
      if (ev[i].type == EV_SYN) {
        if (ev[i].code == SYN_DROPPED)
          waitsyn = 1;
        continue;
      } else if (ev[i].type == EV_KEY) {
        fprintf(stderr,
                "%ld.%06ld: "
                "code=%02x "
                "value=%s\n",
                ev[i].time.tv_sec, ev[i].time.tv_usec, ev[i].code,
                ev[i].value == 1   ? "pressed"
                : ev[i].value == 0 ? "released"
                                   : "repeated");
        if (ev[i].value == 1)
          flash_led(fd);
      } else if (ev[i].type == EV_LED) {
        fprintf(stderr,
                "%ld.%06ld: "
                "LED code=%02x "
                "value=%s\n",
                ev[i].time.tv_sec, ev[i].time.tv_usec, ev[i].code,
                ev[i].value == 1 ? "on" : "off");
      }
    }
  }
fine:
  close(fd);
  return errno;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x458,%rsp
movl   $0x0,-0x2c(%rbp)
mov    %edi,-0x30(%rbp)
mov    %rsi,-0x38(%rbp)
lea    -0x150(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1040 <memset@plt>
movb   $0x4e,-0x150(%rbp)
movb   $0x2f,-0x14f(%rbp)
movb   $0x41,-0x14e(%rbp)
cmpl   $0x2,-0x30(%rbp)
jge    1213 <main+0x83>
mov    0x2dcd(%rip),%rax
mov    (%rax),%edi
mov    -0x38(%rbp),%rax
mov    (%rax),%rdx
lea    0xe05(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2d97(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
jmp    1464 <main+0x2d4>
mov    -0x38(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2dc6(%rip),%rax
mov    (%rax),%esi
call   1080 <open@plt>
mov    %eax,-0x3c(%rbp)
cmp    $0x0,%eax
jge    12a0 <main+0x110>
mov    0x2d7c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x418(%rbp)
mov    0x2d65(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x414(%rbp)
mov    -0x38(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x410(%rbp)
mov    0x2d47(%rip),%rax
mov    (%rax),%edi
call   10a0 <strerror@plt>
mov    -0x418(%rbp),%edi
mov    -0x414(%rbp),%edx
mov    -0x410(%rbp),%rcx
mov    %rax,%r8
lea    0xdae(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0x1,-0x2c(%rbp)
jmp    1464 <main+0x2d4>
mov    -0x3c(%rbp),%edi
mov    0x2cde(%rip),%rax
mov    (%rax),%esi
lea    -0x48(%rbp),%rdx
mov    $0x0,%al
call   1050 <ioctl@plt>
mov    -0x3c(%rbp),%edi
mov    0x2d17(%rip),%rax
mov    (%rax),%esi
lea    -0x50(%rbp),%rdx
mov    $0x0,%al
call   1050 <ioctl@plt>
mov    -0x3c(%rbp),%eax
mov    %eax,-0x42c(%rbp)
mov    $0x100,%edi
call   1090 <EVIOCGNAME@plt>
mov    -0x42c(%rbp),%edi
mov    %eax,%esi
lea    -0x150(%rbp),%rdx
mov    $0x0,%al
call   1050 <ioctl@plt>
mov    -0x3c(%rbp),%eax
mov    %eax,-0x428(%rbp)
xor    %eax,%eax
mov    %eax,%edi
mov    $0x4,%esi
call   1030 <EVIOCGBIT@plt>
mov    -0x428(%rbp),%edi
mov    %eax,%esi
lea    -0x3d4(%rbp),%rdx
mov    $0x0,%al
call   1050 <ioctl@plt>
lea    -0x400(%rbp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1040 <memset@plt>
mov    -0x3c(%rbp),%eax
mov    %eax,-0x424(%rbp)
mov    0x2c89(%rip),%rax
mov    (%rax),%rdi
mov    $0x20,%esi
call   1030 <EVIOCGBIT@plt>
mov    -0x424(%rbp),%edi
mov    %eax,%esi
lea    -0x400(%rbp),%rdx
mov    $0x0,%al
call   1050 <ioctl@plt>
mov    0x2c47(%rip),%rax
mov    (%rax),%edi
lea    -0x150(%rbp),%rdx
mov    -0x48(%rbp),%ecx
shr    $0x10,%ecx
mov    -0x48(%rbp),%r8d
shr    $0x8,%r8d
and    $0xff,%r8d
mov    -0x48(%rbp),%r9d
and    $0xff,%r9d
mov    0x2bf7(%rip),%rax
mov    (%rax),%rax
movzwl -0x50(%rbp,%rax,2),%eax
mov    0x2c30(%rip),%rsi
mov    (%rsi),%rsi
movzwl -0x50(%rbp,%rsi,2),%r13d
mov    0x2be8(%rip),%rsi
mov    (%rsi),%rsi
movzwl -0x50(%rbp,%rsi,2),%r12d
mov    0x2bf8(%rip),%rsi
mov    (%rsi),%rsi
movzwl -0x50(%rbp,%rsi,2),%r15d
mov    -0x3d4(%rbp),%r14d
mov    -0x3e8(%rbp),%rbx
mov    -0x3f0(%rbp),%r11
mov    -0x3f8(%rbp),%r10
mov    -0x400(%rbp),%rsi
mov    %rsi,-0x420(%rbp)
lea    0xc51(%rip),%rsi
mov    %eax,(%rsp)
mov    -0x420(%rbp),%rax
mov    %r13d,0x8(%rsp)
mov    %r12d,0x10(%rsp)
mov    %r15d,0x18(%rsp)
mov    %r14d,0x20(%rsp)
mov    %rbx,0x28(%rsp)
mov    %r11,0x30(%rsp)
mov    %r10,0x38(%rsp)
mov    %rax,0x40(%rsp)
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0x0,-0x404(%rbp)
mov    -0x3c(%rbp),%edi
call   1070 <flash_led@plt>
mov    $0x1,%edi
call   10b0 <sleep@plt>
jmp    144d <main+0x2bd>
mov    -0x2c(%rbp),%eax
add    $0x458,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x130,%rsp
mov    %rsi,%r14
xorps  %xmm0,%xmm0
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x120(%rsp)
movaps %xmm0,0x110(%rsp)
movaps %xmm0,0x100(%rsp)
movaps %xmm0,0xf0(%rsp)
movaps %xmm0,0xe0(%rsp)
movaps %xmm0,0xd0(%rsp)
movaps %xmm0,0xc0(%rsp)
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movw   $0x2f4e,0x30(%rsp)
movb   $0x41,0x32(%rsp)
cmp    $0x1,%edi
jg     123f <main+0xbf>
mov    0x2d9a(%rip),%rax
mov    (%rax),%edi
mov    (%r14),%rdx
lea    0xdd6(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    0x2d68(%rip),%rax
mov    (%rax),%eax
jmp    13cd <main+0x24d>
mov    0x8(%r14),%rdi
mov    0x2d9e(%rip),%rax
mov    (%rax),%esi
call   1070 <open@plt>
test   %eax,%eax
js     1393 <main+0x213>
mov    %eax,%ebx
mov    0x2d26(%rip),%rax
mov    (%rax),%esi
lea    0xc(%rsp),%rdx
mov    %ebx,%edi
xor    %eax,%eax
call   1040 <ioctl@plt>
mov    0x2d5f(%rip),%rax
mov    (%rax),%esi
mov    %rsp,%rdx
mov    %ebx,%edi
xor    %eax,%eax
call   1040 <ioctl@plt>
mov    $0x100,%edi
call   1080 <EVIOCGNAME@plt>
lea    0x30(%rsp),%r14
mov    %ebx,%edi
mov    %eax,%esi
mov    %r14,%rdx
xor    %eax,%eax
call   1040 <ioctl@plt>
xor    %edi,%edi
mov    $0x4,%esi
call   1030 <EVIOCGBIT@plt>
lea    0x8(%rsp),%rdx
mov    %ebx,%edi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <ioctl@plt>
xorps  %xmm0,%xmm0
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
mov    0x2cfc(%rip),%rax
mov    (%rax),%rdi
mov    $0x20,%esi
call   1030 <EVIOCGBIT@plt>
lea    0x10(%rsp),%rdx
mov    %ebx,%edi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <ioctl@plt>
mov    0x2cc0(%rip),%rax
mov    (%rax),%edi
mov    0xc(%rsp),%ecx
movzbl %ch,%eax
movzbl %cl,%r9d
shr    $0x10,%ecx
mov    0x2c89(%rip),%rdx
mov    (%rdx),%rdx
movzwl (%rsp,%rdx,2),%r10d
mov    0x2cc2(%rip),%rdx
mov    (%rdx),%rdx
movzwl (%rsp,%rdx,2),%r11d
mov    0x2c7b(%rip),%rdx
mov    (%rdx),%rdx
movzwl (%rsp,%rdx,2),%r15d
mov    0x2c8c(%rip),%rdx
mov    (%rdx),%rdx
movzwl (%rsp,%rdx,2),%r12d
mov    0x8(%rsp),%ebp
sub    $0x8,%rsp
lea    0xd08(%rip),%rsi
mov    %r14,%rdx
mov    %eax,%r8d
xor    %eax,%eax
push   0x18(%rsp)
push   0x28(%rsp)
push   0x38(%rsp)
push   0x48(%rsp)
push   %rbp
push   %r12
push   %r15
push   %r11
push   %r10
call   1050 <fprintf@plt>
add    $0x50,%rsp
nopl   (%rax)
mov    %ebx,%edi
call   1060 <flash_led@plt>
mov    $0x1,%edi
call   10a0 <sleep@plt>
jmp    1380 <main+0x200>
mov    0x2c1e(%rip),%rax
mov    (%rax),%ebx
mov    0x2c0d(%rip),%rax
mov    (%rax),%ebp
mov    0x8(%r14),%r14
mov    %ebp,%edi
call   1090 <strerror@plt>
lea    0xc84(%rip),%rsi
mov    %ebx,%edi
mov    %ebp,%edx
mov    %r14,%rcx
mov    %rax,%r8
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0x1,%eax
add    $0x130,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.input_event = type { i64, i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32, i8* }
@stderr = global i32 0
@.str = [59 x i8] c"Usage: %s /dev/input/eventN\0AWhere X = input device number\0A\00"
@EINVAL = global i32 0
@O_RDWR = global i32 0
@.str.1 = [32 x i8] c"ERR %d:\0AUnable to open `%s'\0A%s\0A\00"
@errno = global i32 0
@EVIOCGVERSION = global i32 0
@EVIOCGID = global i32 0
@EV_KEY = global i64 0
@.str.2 = [166 x i8] c"Name : %s\0AVersion : %d.%d.%d\0AID : Bus=%04x Vendor=%04x Product=%04x Version=%04x\0AEV bits : %x\0AKEY bits : %016llx %016llx %016llx %016llx\0A----------\0A\00"
@ID_BUS = global i64 0
@ID_VENDOR = global i64 0
@ID_PRODUCT = global i64 0
@ID_VERSION = global i64 0
@EV_LED = global i64 0
@EV_SYN = global i64 0
@SYN_DROPPED = global i32 0
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 [4 x i16]
%11 = alloca [256 x i8]
%12 = alloca [16 x %struct.input_event]
%13 = alloca i32
%14 = alloca [4 x i64]
%15 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%16 = bitcast [256 x i8]* %11 to i8*
%17 = bitcast i8* %16 to [256 x i8]*
%18 = getelementptr inbounds [256 x i8], [256 x i8]* %17, i32 0, i32 0
store i8 78, i8* %18
%19 = getelementptr inbounds [256 x i8], [256 x i8]* %17, i32 0, i32 1
store i8 47, i8* %19
%20 = getelementptr inbounds [256 x i8], [256 x i8]* %17, i32 0, i32 2
store i8 65, i8* %20
%21 = load i32, i32* %4
%22 = icmp slt i32 %21, 2
br i1 %22, label %23, label %30
23: ; preds = %2
%24 = load i32, i32* @stderr
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 0
%27 = load i8*, i8** %26
%28 = call i32 (i32, i8*, ...) @fprintf(i32 %24, i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str, i64 0, i64 0), i8* %27)
%29 = load i32, i32* @EINVAL
store i32 %29, i32* %3
br label %110
30: ; preds = %2
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 1
%33 = load i8*, i8** %32
%34 = load i32, i32* @O_RDWR
%35 = call i32 @open(i8* %33, i32 %34)
store i32 %35, i32* %6
%36 = icmp slt i32 %35, 0
br i1 %36, label %37, label %46
37: ; preds = %30
%38 = load i32, i32* @stderr
%39 = load i32, i32* @errno
%40 = load i8**, i8*** %5
%41 = getelementptr inbounds i8*, i8** %40, i64 1
%42 = load i8*, i8** %41
%43 = load i32, i32* @errno
%44 = call i8* @strerror(i32 %43)
%45 = call i32 (i32, i8*, ...) @fprintf(i32 %38, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i32 %39, i8* %42, i8* %44)
store i32 1, i32* %3
br label %110
46: ; preds = %30
%47 = load i32, i32* %6
%48 = load i32, i32* @EVIOCGVERSION
%49 = call i32 (i32, i32, ...) @ioctl(i32 %47, i32 %48, i32* %9)
%50 = load i32, i32* %6
%51 = load i32, i32* @EVIOCGID
%52 = getelementptr inbounds [4 x i16], [4 x i16]* %10, i64 0, i64 0
%53 = call i32 (i32, i32, ...) @ioctl(i32 %50, i32 %51, i16* %52)
%54 = load i32, i32* %6
%55 = call i32 @EVIOCGNAME(i32 256)
%56 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%57 = call i32 (i32, i32, ...) @ioctl(i32 %54, i32 %55, i8* %56)
%58 = load i32, i32* %6
%59 = call i32 @EVIOCGBIT(i64 0, i32 4)
%60 = call i32 (i32, i32, ...) @ioctl(i32 %58, i32 %59, i32* %13)
%61 = bitcast [4 x i64]* %14 to i8*
%62 = load i32, i32* %6
%63 = load i64, i64* @EV_KEY
%64 = call i32 @EVIOCGBIT(i64 %63, i32 32)
%65 = getelementptr inbounds [4 x i64], [4 x i64]* %14, i64 0, i64 0
%66 = call i32 (i32, i32, ...) @ioctl(i32 %62, i32 %64, i64* %65)
%67 = load i32, i32* @stderr
%68 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%69 = load i32, i32* %9
%70 = lshr i32 %69, 16
%71 = load i32, i32* %9
%72 = lshr i32 %71, 8
%73 = and i32 %72, 255
%74 = load i32, i32* %9
%75 = and i32 %74, 255
%76 = load i64, i64* @ID_BUS
%77 = getelementptr inbounds [4 x i16], [4 x i16]* %10, i64 0, i64 %76
%78 = load i16, i16* %77
%79 = zext i16 %78 to i32
%80 = load i64, i64* @ID_VENDOR
%81 = getelementptr inbounds [4 x i16], [4 x i16]* %10, i64 0, i64 %80
%82 = load i16, i16* %81
%83 = zext i16 %82 to i32
%84 = load i64, i64* @ID_PRODUCT
%85 = getelementptr inbounds [4 x i16], [4 x i16]* %10, i64 0, i64 %84
%86 = load i16, i16* %85
%87 = zext i16 %86 to i32
%88 = load i64, i64* @ID_VERSION
%89 = getelementptr inbounds [4 x i16], [4 x i16]* %10, i64 0, i64 %88
%90 = load i16, i16* %89
%91 = zext i16 %90 to i32
%92 = load i32, i32* %13
%93 = getelementptr inbounds [4 x i64], [4 x i64]* %14, i64 0, i64 3
%94 = load i64, i64* %93
%95 = getelementptr inbounds [4 x i64], [4 x i64]* %14, i64 0, i64 2
%96 = load i64, i64* %95
%97 = getelementptr inbounds [4 x i64], [4 x i64]* %14, i64 0, i64 1
%98 = load i64, i64* %97
%99 = getelementptr inbounds [4 x i64], [4 x i64]* %14, i64 0, i64 0
%100 = load i64, i64* %99
%101 = call i32 (i32, i8*, ...) @fprintf(i32 %67, i8* getelementptr inbounds ([166 x i8], [166 x i8]* @.str.2, i64 0, i64 0), i8* %68, i32 %70, i32 %73, i32 %75, i32 %79, i32 %83, i32 %87, i32 %91, i32 %92, i64 %94, i64 %96, i64 %98, i64 %100)
store i32 0, i32* %15
br label %102
102: ; preds = %46, %102
%103 = load i32, i32* %6
%104 = call i32 @flash_led(i32 %103)
%105 = call i32 @sleep(i32 1)
br label %102
106: ; No predecessors!
%107 = load i32, i32* %6
%108 = call i32 @close(i32 %107)
%109 = load i32, i32* @errno
store i32 %109, i32* %3
br label %110
110: ; preds = %106, %37, %23
%111 = load i32, i32* %3
ret i32 %111
}

LLVM IR (-O2):
%struct.input_event = type { i64, i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32, i8* }
@stderr = global i32 0
@.str = [59 x i8] c"Usage: %s /dev/input/eventN\0AWhere X = input device number\0A\00"
@EINVAL = global i32 0
@O_RDWR = global i32 0
@.str.1 = [32 x i8] c"ERR %d:\0AUnable to open `%s'\0A%s\0A\00"
@errno = global i32 0
@EVIOCGVERSION = global i32 0
@EVIOCGID = global i32 0
@EV_KEY = global i64 0
@.str.2 = [166 x i8] c"Name : %s\0AVersion : %d.%d.%d\0AID : Bus=%04x Vendor=%04x Product=%04x Version=%04x\0AEV bits : %x\0AKEY bits : %016llx %016llx %016llx %016llx\0A----------\0A\00"
@ID_BUS = global i64 0
@ID_VENDOR = global i64 0
@ID_PRODUCT = global i64 0
@ID_VERSION = global i64 0
@EV_LED = global i64 0
@EV_SYN = global i64 0
@SYN_DROPPED = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca [4 x i16]
%5 = alloca [256 x i8]
%6 = alloca i32
%7 = alloca [4 x i64]
%8 = bitcast i32* %3 to i8*
%9 = bitcast [4 x i16]* %4 to i8*
%10 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
store i8 78, i8* %10
%11 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 1
store i8 47, i8* %11
%12 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 2
store i8 65, i8* %12
%13 = icmp slt i32 %0, 2
br i1 %13, label %14, label %19
14: ; preds = %2
%15 = load i32, i32* @stderr
%16 = load i8*, i8** %1
%17 = tail call i32 (i32, i8*, ...) @fprintf(i32 %15, i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str, i64 0, i64 0), i8* %16)
%18 = load i32, i32* @EINVAL
br label %81
19: ; preds = %2
%20 = getelementptr inbounds i8*, i8** %1, i64 1
%21 = load i8*, i8** %20
%22 = load i32, i32* @O_RDWR
%23 = tail call i32 @open(i8* %21, i32 %22)
%24 = icmp slt i32 %23, 0
br i1 %24, label %25, label %31
25: ; preds = %19
%26 = load i32, i32* @stderr
%27 = load i32, i32* @errno
%28 = load i8*, i8** %20
%29 = tail call i8* @strerror(i32 %27)
%30 = tail call i32 (i32, i8*, ...) @fprintf(i32 %26, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i32 %27, i8* %28, i8* %29)
br label %81
31: ; preds = %19
%32 = load i32, i32* @EVIOCGVERSION
%33 = call i32 (i32, i32, ...) @ioctl(i32 %23, i32 %32, i32* %3)
%34 = load i32, i32* @EVIOCGID
%35 = getelementptr inbounds [4 x i16], [4 x i16]* %4, i64 0, i64 0
%36 = call i32 (i32, i32, ...) @ioctl(i32 %23, i32 %34, i16* %35)
%37 = call i32 @EVIOCGNAME(i32 256)
%38 = call i32 (i32, i32, ...) @ioctl(i32 %23, i32 %37, i8* %10)
%39 = bitcast i32* %6 to i8*
%40 = call i32 @EVIOCGBIT(i64 0, i32 4)
%41 = call i32 (i32, i32, ...) @ioctl(i32 %23, i32 %40, i32* %6)
%42 = bitcast [4 x i64]* %7 to i8*
%43 = load i64, i64* @EV_KEY
%44 = call i32 @EVIOCGBIT(i64 %43, i32 32)
%45 = getelementptr inbounds [4 x i64], [4 x i64]* %7, i64 0, i64 0
%46 = call i32 (i32, i32, ...) @ioctl(i32 %23, i32 %44, i64* %45)
%47 = load i32, i32* @stderr
%48 = load i32, i32* %3
%49 = lshr i32 %48, 16
%50 = lshr i32 %48, 8
%51 = and i32 %50, 255
%52 = and i32 %48, 255
%53 = load i64, i64* @ID_BUS
%54 = getelementptr inbounds [4 x i16], [4 x i16]* %4, i64 0, i64 %53
%55 = load i16, i16* %54
%56 = zext i16 %55 to i32
%57 = load i64, i64* @ID_VENDOR
%58 = getelementptr inbounds [4 x i16], [4 x i16]* %4, i64 0, i64 %57
%59 = load i16, i16* %58
%60 = zext i16 %59 to i32
%61 = load i64, i64* @ID_PRODUCT
%62 = getelementptr inbounds [4 x i16], [4 x i16]* %4, i64 0, i64 %61
%63 = load i16, i16* %62
%64 = zext i16 %63 to i32
%65 = load i64, i64* @ID_VERSION
%66 = getelementptr inbounds [4 x i16], [4 x i16]* %4, i64 0, i64 %65
%67 = load i16, i16* %66
%68 = zext i16 %67 to i32
%69 = load i32, i32* %6
%70 = getelementptr inbounds [4 x i64], [4 x i64]* %7, i64 0, i64 3
%71 = load i64, i64* %70
%72 = getelementptr inbounds [4 x i64], [4 x i64]* %7, i64 0, i64 2
%73 = load i64, i64* %72
%74 = getelementptr inbounds [4 x i64], [4 x i64]* %7, i64 0, i64 1
%75 = load i64, i64* %74
%76 = load i64, i64* %45
%77 = call i32 (i32, i8*, ...) @fprintf(i32 %47, i8* getelementptr inbounds ([166 x i8], [166 x i8]* @.str.2, i64 0, i64 0), i8* %10, i32 %49, i32 %51, i32 %52, i32 %56, i32 %60, i32 %64, i32 %68, i32 %69, i64 %71, i64 %73, i64 %75, i64 %76)
br label %78
78: ; preds = %78, %31
%79 = call i32 @flash_led(i32 %23)
%80 = call i32 @sleep(i32 1)
br label %78
81: ; preds = %25, %14
%82 = phi i32 [ %18, %14 ], [ 1, %25 ]
ret i32 %82
}