#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 int /*<<< orphan*/ FILE;

/* Variables and functions */
int EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ aslc_fclose(int /*<<< orphan*/ *, char const *);
char *aslc_fread(int /*<<< orphan*/ *, int /*<<< orphan*/ *, size_t *);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ printf(char *, char const *);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
int main(int argc, char **argv) {
  const char *fn = NULL;
  FILE *fd = NULL;
  size_t len = 0;
  char *buf = NULL;
  if (argc > 2) {
    fprintf(stderr, "[E] Only one file can be compiled at a time.\n");
    return EXIT_FAILURE;
  }
  fn = argv[1];
  fd = fopen(fn, "r");
  if (fd == NULL) {
    fprintf(stderr, "[E] Cannot open file `%s' for reading: %s\n", fn,
            strerror(errno));
    return EXIT_FAILURE;
  }
  buf = aslc_fread(fd, NULL, &len);
  if (buf == NULL) {
    fprintf(stderr, "[E] Cannot read file `%s': %s\n", fn, strerror(errno));
    aslc_fclose(fd, fn);
    return EXIT_FAILURE;
  }
  aslc_fclose(fd, fn);
  printf("[C] %s\n", fn);
  free(buf);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
cmpl   $0x2,-0x8(%rbp)
jle    11d8 <main+0x68>
mov    0x2e29(%rip),%rax
mov    (%rax),%edi
lea    0xe40(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    0x2e02(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12f8 <main+0x188>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe3f(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    124e <main+0xde>
mov    0x2dd6(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    0x2dba(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
mov    -0x3c(%rbp),%edi
mov    -0x38(%rbp),%rdx
mov    %rax,%rcx
lea    0xdfa(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    0x2d8c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12f8 <main+0x188>
mov    -0x20(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
lea    -0x28(%rbp),%rdx
call   1060 <aslc_fread@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    12c6 <main+0x156>
mov    0x2d6b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    0x2d4f(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
mov    -0x4c(%rbp),%edi
mov    -0x48(%rbp),%rdx
mov    %rax,%rcx
lea    0xdba(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <aslc_fclose@plt>
mov    0x2d14(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12f8 <main+0x188>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <aslc_fclose@plt>
mov    -0x18(%rbp),%rsi
lea    0xd9c(%rip),%rdi
call   1040 <printf@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    0x2cd5(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
movq   $0x0,(%rsp)
cmp    $0x3,%edi
jl     11a0 <main+0x30>
mov    0x2e55(%rip),%rax
mov    (%rax),%edi
lea    0xe6c(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
jmp    1262 <main+0xf2>
mov    0x8(%rsi),%r14
lea    0xe83(%rip),%rsi
mov    %r14,%rdi
call   1080 <fopen@plt>
test   %rax,%rax
je     11fb <main+0x8b>
mov    %rax,%rbx
mov    %rsp,%rdx
mov    %rax,%rdi
xor    %esi,%esi
call   1060 <aslc_fread@plt>
test   %rax,%rax
je     122a <main+0xba>
mov    %rax,%r15
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <aslc_fclose@plt>
lea    0xe98(%rip),%rdi
mov    %r14,%rsi
call   1040 <printf@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    0x2dcf(%rip),%rax
jmp    1269 <main+0xf9>
mov    0x2dde(%rip),%rax
mov    (%rax),%ebx
mov    0x2dcd(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
lea    0xe17(%rip),%rsi
mov    %ebx,%edi
mov    %r14,%rdx
mov    %rax,%rcx
xor    %eax,%eax
call   1070 <fprintf@plt>
jmp    1262 <main+0xf2>
mov    0x2daf(%rip),%rax
mov    (%rax),%ebp
mov    0x2d9e(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
lea    0xe13(%rip),%rsi
mov    %ebp,%edi
mov    %r14,%rdx
mov    %rax,%rcx
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <aslc_fclose@plt>
mov    0x2d67(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [46 x i8] c"[E] Only one file can be compiled at a time.\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [43 x i8] c"[E] Cannot open file `%s' for reading: %s\0A\00"
@errno = global i32 0
@.str.3 = [31 x i8] c"[E] Cannot read file `%s': %s\0A\00"
@.str.4 = [8 x i8] c"[C] %s\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 i8*
%7 = alloca i32*
%8 = alloca i64
%9 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* null, i8** %6
store i32* null, i32** %7
store i64 0, i64* %8
store i8* null, i8** %9
%10 = load i32, i32* %4
%11 = icmp sgt i32 %10, 2
br i1 %11, label %12, label %16
12: ; preds = %2
%13 = load i32, i32* @stderr
%14 = call i32 (i32, i8*, ...) @fprintf(i32 %13, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0))
%15 = load i32, i32* @EXIT_FAILURE
store i32 %15, i32* %3
br label %55
16: ; preds = %2
%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 i32* @fopen(i8* %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %21, i32** %7
%22 = load i32*, i32** %7
%23 = icmp eq i32* %22, null
br i1 %23, label %24, label %31
24: ; preds = %16
%25 = load i32, i32* @stderr
%26 = load i8*, i8** %6
%27 = load i32, i32* @errno
%28 = call i8* @strerror(i32 %27)
%29 = call i32 (i32, i8*, ...) @fprintf(i32 %25, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0), i8* %26, i8* %28)
%30 = load i32, i32* @EXIT_FAILURE
store i32 %30, i32* %3
br label %55
31: ; preds = %16
%32 = load i32*, i32** %7
%33 = call i8* @aslc_fread(i32* %32, i32* null, i64* %8)
store i8* %33, i8** %9
%34 = load i8*, i8** %9
%35 = icmp eq i8* %34, null
br i1 %35, label %36, label %46
36: ; preds = %31
%37 = load i32, i32* @stderr
%38 = load i8*, i8** %6
%39 = load i32, i32* @errno
%40 = call i8* @strerror(i32 %39)
%41 = call i32 (i32, i8*, ...) @fprintf(i32 %37, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i8* %38, i8* %40)
%42 = load i32*, i32** %7
%43 = load i8*, i8** %6
%44 = call i32 @aslc_fclose(i32* %42, i8* %43)
%45 = load i32, i32* @EXIT_FAILURE
store i32 %45, i32* %3
br label %55
46: ; preds = %31
%47 = load i32*, i32** %7
%48 = load i8*, i8** %6
%49 = call i32 @aslc_fclose(i32* %47, i8* %48)
%50 = load i8*, i8** %6
%51 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8* %50)
%52 = load i8*, i8** %9
%53 = call i32 @free(i8* %52)
%54 = load i32, i32* @EXIT_SUCCESS
store i32 %54, i32* %3
br label %55
55: ; preds = %46, %36, %24, %12
%56 = load i32, i32* %3
ret i32 %56
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [46 x i8] c"[E] Only one file can be compiled at a time.\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [43 x i8] c"[E] Cannot open file `%s' for reading: %s\0A\00"
@errno = global i32 0
@.str.3 = [31 x i8] c"[E] Cannot read file `%s': %s\0A\00"
@.str.4 = [8 x i8] c"[C] %s\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i64
%4 = bitcast i64* %3 to i8*
store i64 0, i64* %3
%5 = icmp sgt i32 %0, 2
br i1 %5, label %6, label %9
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = tail call i32 (i32, i8*, ...) @fprintf(i32 %7, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0))
br label %32
9: ; preds = %2
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = tail call i32* @fopen(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%13 = icmp eq i32* %12, null
br i1 %13, label %14, label %19
14: ; preds = %9
%15 = load i32, i32* @stderr
%16 = load i32, i32* @errno
%17 = tail call i8* @strerror(i32 %16)
%18 = tail call i32 (i32, i8*, ...) @fprintf(i32 %15, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0), i8* %11, i8* %17)
br label %32
19: ; preds = %9
%20 = call i8* @aslc_fread(i32* %12, i32* null, i64* %3)
%21 = icmp eq i8* %20, null
br i1 %21, label %22, label %28
22: ; preds = %19
%23 = load i32, i32* @stderr
%24 = load i32, i32* @errno
%25 = call i8* @strerror(i32 %24)
%26 = call i32 (i32, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i8* %11, i8* %25)
%27 = call i32 @aslc_fclose(i32* %12, i8* %11)
br label %32
28: ; preds = %19
%29 = call i32 @aslc_fclose(i32* %12, i8* %11)
%30 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8* %11)
%31 = call i32 @free(i8* %20)
br label %32
32: ; preds = %28, %22, %14, %6
%33 = phi i32* [ @EXIT_FAILURE, %6 ], [ @EXIT_FAILURE, %14 ], [ @EXIT_FAILURE, %22 ], [ @EXIT_SUCCESS, %28 ]
%34 = load i32, i32* %33
ret i32 %34
}