#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;
  int tv_usec;
};
struct input_event {
  int type;
  int code;
  int value;
  TYPE_1__ time;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ fread(struct input_event *, int, int, int /*<<< orphan*/ *);
struct input_event *malloc(int);
int /*<<< orphan*/ printf(char *, int, int, int, int, int);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  struct input_event *ie;
  FILE *evdev;
  if (argc != 2) {
    fprintf(stderr, "\aError: No evdev file.\n");
    exit(EXIT_FAILURE);
  }
  ie = malloc(sizeof(struct input_event));
  evdev = fopen(argv[1], "r");
  while (!feof(evdev)) {
    fread(ie, 1, sizeof(struct input_event), evdev);
    printf("Time: Sec: %d,\tUSec: %d,\tType: %d,\tCode: %d,\tValue: %d\n",
           ie->time.tv_sec, ie->time.tv_usec, ie->type, ie->code, ie->value);
  }
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     11b3 <main+0x43>
mov    0x2e49(%rip),%rax
mov    (%rax),%edi
lea    0xe60(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2e2c(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
mov    $0x14,%edi
call   1070 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe48(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1060 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11f7 <main+0x87>
jmp    1243 <main+0xd3>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rcx
mov    $0x1,%esi
mov    $0x14,%edx
call   1030 <fread@plt>
mov    -0x18(%rbp),%rax
mov    0xc(%rax),%esi
mov    -0x18(%rbp),%rax
mov    0x10(%rax),%edx
mov    -0x18(%rbp),%rax
mov    (%rax),%ecx
mov    -0x18(%rbp),%rax
mov    0x4(%rax),%r8d
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%r9d
lea    0xde1(%rip),%rdi
call   1040 <printf@plt>
jmp    11d9 <main+0x69>
mov    0x2d86(%rip),%rax
mov    (%rax),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
cmp    $0x2,%edi
jne    11f8 <main+0x88>
mov    %rsi,%r14
mov    $0x14,%edi
call   1070 <malloc@plt>
mov    %rax,%rbx
mov    0x8(%r14),%rdi
lea    0xe83(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%r14
mov    %rax,%rdi
call   1060 <feof@plt>
test   %eax,%eax
jne    11e9 <main+0x79>
lea    0xe6a(%rip),%r15
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x14,%edx
mov    %r14,%rcx
call   1030 <fread@plt>
mov    0xc(%rbx),%esi
mov    0x10(%rbx),%edx
mov    (%rbx),%ecx
mov    0x4(%rbx),%r8d
mov    0x8(%rbx),%r9d
mov    %r15,%rdi
call   1040 <printf@plt>
mov    %r14,%rdi
call   1060 <feof@plt>
test   %eax,%eax
je     11b0 <main+0x40>
mov    0x2de0(%rip),%rax
mov    (%rax),%eax
pop    %rbx
pop    %r14
pop    %r15
ret
mov    0x2de1(%rip),%rax
mov    (%rax),%edi
lea    0xdf8(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2dc4(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>

LLVM IR (-O0):
%struct.input_event = type { i32, i32, i32, %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i32, i32 }
@stderr = global i32 0
@.str = [24 x i8] c"\07Error: No evdev file.\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [56 x i8] c"Time: Sec: %d,\09USec: %d,\09Type: %d,\09Code: %d,\09Value: %d\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.input_event*
%7 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp ne i32 %8, 2
br i1 %9, label %10, label %15
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%13 = load i32, i32* @EXIT_FAILURE
%14 = call i32 @exit(i32 %13)
unreachable
15: ; preds = %2
%16 = call %struct.input_event* @malloc(i32 20)
store %struct.input_event* %16, %struct.input_event** %6
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
%20 = call i32* @fopen(i8* %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %20, i32** %7
br label %21
21: ; preds = %26, %15
%22 = load i32*, i32** %7
%23 = call i32 @feof(i32* %22)
%24 = icmp ne i32 %23, 0
%25 = xor i1 %24, true
br i1 %25, label %26, label %48
26: ; preds = %21
%27 = load %struct.input_event*, %struct.input_event** %6
%28 = load i32*, i32** %7
%29 = call i32 @fread(%struct.input_event* %27, i32 1, i32 20, i32* %28)
%30 = load %struct.input_event*, %struct.input_event** %6
%31 = getelementptr inbounds %struct.input_event, %struct.input_event* %30, i32 0, i32 3
%32 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %31, i32 0, i32 0
%33 = load i32, i32* %32
%34 = load %struct.input_event*, %struct.input_event** %6
%35 = getelementptr inbounds %struct.input_event, %struct.input_event* %34, i32 0, i32 3
%36 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %35, i32 0, i32 1
%37 = load i32, i32* %36
%38 = load %struct.input_event*, %struct.input_event** %6
%39 = getelementptr inbounds %struct.input_event, %struct.input_event* %38, i32 0, i32 0
%40 = load i32, i32* %39
%41 = load %struct.input_event*, %struct.input_event** %6
%42 = getelementptr inbounds %struct.input_event, %struct.input_event* %41, i32 0, i32 1
%43 = load i32, i32* %42
%44 = load %struct.input_event*, %struct.input_event** %6
%45 = getelementptr inbounds %struct.input_event, %struct.input_event* %44, i32 0, i32 2
%46 = load i32, i32* %45
%47 = call i32 @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.2, i64 0, i64 0), i32 %33, i32 %37, i32 %40, i32 %43, i32 %46)
br label %21
48: ; preds = %21
%49 = load i32, i32* @EXIT_SUCCESS
ret i32 %49
}

LLVM IR (-O2):
%struct.input_event = type { i32, i32, i32, %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i32, i32 }
@stderr = global i32 0
@.str = [24 x i8] c"\07Error: No evdev file.\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [56 x i8] c"Time: Sec: %d,\09USec: %d,\09Type: %d,\09Code: %d,\09Value: %d\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %9, label %4
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%7 = load i32, i32* @EXIT_FAILURE
%8 = tail call i32 @exit(i32 %7)
unreachable
9: ; preds = %2
%10 = tail call %struct.input_event* @malloc(i32 20)
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = tail call i32* @fopen(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%14 = tail call i32 @feof(i32* %13)
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %32
16: ; preds = %9
%17 = getelementptr inbounds %struct.input_event, %struct.input_event* %10, i64 0, i32 3, i32 0
%18 = getelementptr inbounds %struct.input_event, %struct.input_event* %10, i64 0, i32 3, i32 1
%19 = getelementptr inbounds %struct.input_event, %struct.input_event* %10, i64 0, i32 0
%20 = getelementptr inbounds %struct.input_event, %struct.input_event* %10, i64 0, i32 1
%21 = getelementptr inbounds %struct.input_event, %struct.input_event* %10, i64 0, i32 2
br label %22
22: ; preds = %16, %22
%23 = tail call i32 @fread(%struct.input_event* %10, i32 1, i32 20, i32* %13)
%24 = load i32, i32* %17
%25 = load i32, i32* %18
%26 = load i32, i32* %19
%27 = load i32, i32* %20
%28 = load i32, i32* %21
%29 = tail call i32 @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.2, i64 0, i64 0), i32 %24, i32 %25, i32 %26, i32 %27, i32 %28)
%30 = tail call i32 @feof(i32* %13)
%31 = icmp eq i32 %30, 0
br i1 %31, label %22, label %32
32: ; preds = %22, %9
%33 = load i32, i32* @EXIT_SUCCESS
ret i32 %33
}