#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 */

/* Variables and functions */
int /*<<< orphan*/ EX_OSERR;
int /*<<< orphan*/ EX_USAGE;
int /*<<< orphan*/ err(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ printf(char *, char *);
char *read_file(char *);
int main(int argc, char **argv) {
  char *filename;
  char *buffer;
  if (argc < 2 || argc > 3)
    err(EX_USAGE, "Usage: parser FILE");
  filename = argv[1];
  buffer = read_file(filename);
  if (!buffer)
    err(EX_OSERR, "Could not read %s", filename);
  printf("%s", buffer);
  return 0;
}


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)
jl     115a <main+0x2a>
cmpl   $0x3,-0x8(%rbp)
jle    1171 <main+0x41>
mov    0x2e87(%rip),%rax
mov    (%rax),%edi
lea    0xe96(%rip),%rsi
mov    $0x0,%al
call   1050 <err@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <read_file@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11b0 <main+0x80>
mov    0x2e3c(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
lea    0xe6a(%rip),%rsi
mov    $0x0,%al
call   1050 <err@plt>
mov    -0x20(%rbp),%rsi
lea    0xe67(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
add    $0xfffffffc,%edi
cmp    $0xfffffffd,%edi
ja     1156 <main+0x26>
mov    0x2ea2(%rip),%rax
mov    (%rax),%edi
lea    0xeb1(%rip),%rsi
xor    %eax,%eax
call   1050 <err@plt>
mov    0x8(%rbx),%r14
mov    %r14,%rdi
call   1040 <read_file@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1184 <main+0x54>
mov    0x2e67(%rip),%rax
mov    (%rax),%edi
lea    0xe99(%rip),%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1050 <err@plt>
lea    0xe97(%rip),%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@EX_USAGE = global i32 0
@.str = [19 x i8] c"Usage: parser FILE\00"
@EX_OSERR = global i32 0
@.str.1 = [18 x i8] c"Could not read %s\00"
@.str.2 = [3 x i8] c"%s\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 2
br i1 %9, label %13, label %10
10: ; preds = %2
%11 = load i32, i32* %4
%12 = icmp sgt i32 %11, 3
br i1 %12, label %13, label %16
13: ; preds = %10, %2
%14 = load i32, i32* @EX_USAGE
%15 = call i32 (i32, i8*, ...) @err(i32 %14, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
br label %16
16: ; preds = %13, %10
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
store i8* %19, i8** %6
%20 = load i8*, i8** %6
%21 = call i8* @read_file(i8* %20)
store i8* %21, i8** %7
%22 = load i8*, i8** %7
%23 = icmp ne i8* %22, null
br i1 %23, label %28, label %24
24: ; preds = %16
%25 = load i32, i32* @EX_OSERR
%26 = load i8*, i8** %6
%27 = call i32 (i32, i8*, ...) @err(i32 %25, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %26)
br label %28
28: ; preds = %24, %16
%29 = load i8*, i8** %7
%30 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %29)
ret i32 0
}

LLVM IR (-O2):
@EX_USAGE = global i32 0
@.str = [19 x i8] c"Usage: parser FILE\00"
@EX_OSERR = global i32 0
@.str.1 = [18 x i8] c"Could not read %s\00"
@.str.2 = [3 x i8] c"%s\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = add i32 %0, -4
%4 = icmp ult i32 %3, -2
br i1 %4, label %5, label %8
5: ; preds = %2
%6 = load i32, i32* @EX_USAGE
%7 = tail call i32 (i32, i8*, ...) @err(i32 %6, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
br label %8
8: ; preds = %2, %5
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i8* @read_file(i8* %10)
%12 = icmp eq i8* %11, null
br i1 %12, label %13, label %16
13: ; preds = %8
%14 = load i32, i32* @EX_OSERR
%15 = tail call i32 (i32, i8*, ...) @err(i32 %14, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %10)
br label %16
16: ; preds = %13, %8
%17 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %11)
ret i32 0
}