#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 /*<<< orphan*/ SEEK_END;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fread(char *, int, long, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
long ftell(int /*<<< orphan*/ *);
char *malloc(long);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
scalar_t__ strncmp(char *, char *, int);
char *strtok(char *, char *);
int main(int argc, char *args[]) {
  char *file_contents;
  long input_file_size;
  char linebreak[2] = "\n";
  char *line;
  printf("Loading file: %s \n", args[1]);
  FILE *ft = fopen(args[1], "rb");
  if (ft) {
    fseek(ft, 0, SEEK_END);
    input_file_size = ftell(ft);
    rewind(ft);
    file_contents = malloc(input_file_size * (sizeof(char)));
    fread(file_contents, sizeof(char), input_file_size, ft);
    fclose(ft);
    printf("Loaded File\n\n");
    line = strtok(file_contents, linebreak);
    while (line != NULL) {
      if (strncmp(&line[0], "#", 1)) {
        printf("%s ", line);
      } else {
        printf("\n");
      }
      line = strtok(NULL, linebreak);
    }
  } else {
    printf("Could not load file.");
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xe65(%rip),%ax
mov    %ax,-0x22(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe30(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe2d(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
je     12dd <main+0x13d>
mov    -0x38(%rbp),%rdi
mov    0x2de3(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   10a0 <fseek@plt>
mov    -0x38(%rbp),%rdi
call   1080 <ftell@plt>
mov    %rax,-0x20(%rbp)
mov    -0x38(%rbp),%rdi
call   1070 <rewind@plt>
mov    -0x20(%rbp),%rdi
shl    $0x0,%rdi
call   1090 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    -0x38(%rbp),%rcx
mov    $0x1,%esi
call   1040 <fread@plt>
mov    -0x38(%rbp),%rdi
call   1050 <fclose@plt>
lea    0xdbb(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x18(%rbp),%rdi
lea    -0x22(%rbp),%rsi
call   10c0 <strtok@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     12d8 <main+0x138>
mov    -0x30(%rbp),%rdi
lea    0xd9b(%rip),%rsi
mov    $0x1,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     12b4 <main+0x114>
mov    -0x30(%rbp),%rsi
lea    0xd7e(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    12c2 <main+0x122>
lea    0xd67(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x22(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edi
call   10c0 <strtok@plt>
mov    %rax,-0x30(%rbp)
jmp    1273 <main+0xd3>
jmp    12eb <main+0x14b>
lea    0xd46(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xd30(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
movw   $0xa,0x6(%rsp)
mov    0x8(%rsi),%rsi
lea    0xe23(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
mov    0x8(%rbx),%rdi
lea    0xe24(%rip),%rsi
call   10d0 <fopen@plt>
test   %rax,%rax
je     12d0 <main+0x110>
mov    %rax,%rbx
mov    0x2de1(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   10c0 <fseek@plt>
mov    %rbx,%rdi
call   10a0 <ftell@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1090 <rewind@plt>
mov    %r14,%rdi
call   10b0 <malloc@plt>
mov    %rax,%r15
mov    %rax,%rdi
mov    $0x1,%esi
mov    %r14,%rdx
mov    %rbx,%rcx
call   1060 <fread@plt>
mov    %rbx,%rdi
call   1070 <fclose@plt>
lea    0xdde(%rip),%rdi
call   1050 <puts@plt>
lea    0x6(%rsp),%rsi
mov    %r15,%rdi
call   10e0 <strtok@plt>
test   %rax,%rax
je     12de <main+0x11e>
mov    %rax,%rbx
lea    0xda2(%rip),%r14
lea    0x6(%rsp),%r12
lea    0xd98(%rip),%r15
jmp    12ac <main+0xec>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %edi,%edi
mov    %r12,%rsi
call   10e0 <strtok@plt>
mov    %rax,%rbx
test   %rax,%rax
je     12de <main+0x11e>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x1,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
je     1290 <main+0xd0>
mov    %r15,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
jmp    129a <main+0xda>
lea    0xd45(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.main.linebreak = [2 x i8] c"\0A\00"
@.str = [19 x i8] c"Loading file: %s \0A\00"
@.str.1 = [3 x i8] c"rb\00"
@SEEK_END = global i32 0
@.str.2 = [14 x i8] c"Loaded File\0A\0A\00"
@.str.3 = [2 x i8] c"#\00"
@.str.4 = [4 x i8] c"%s \00"
@.str.5 = [2 x i8] c"\0A\00"
@.str.6 = [21 x i8] c"Could not load file.\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i64
%8 = alloca [2 x i8]
%9 = alloca i8*
%10 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = bitcast [2 x i8]* %8 to i8*
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %14)
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
%19 = call i32* @fopen(i8* %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %19, i32** %10
%20 = load i32*, i32** %10
%21 = icmp ne i32* %20, null
br i1 %21, label %22, label %60
22: ; preds = %2
%23 = load i32*, i32** %10
%24 = load i32, i32* @SEEK_END
%25 = call i32 @fseek(i32* %23, i32 0, i32 %24)
%26 = load i32*, i32** %10
%27 = call i64 @ftell(i32* %26)
store i64 %27, i64* %7
%28 = load i32*, i32** %10
%29 = call i32 @rewind(i32* %28)
%30 = load i64, i64* %7
%31 = mul i64 %30, 1
%32 = call i8* @malloc(i64 %31)
store i8* %32, i8** %6
%33 = load i8*, i8** %6
%34 = load i64, i64* %7
%35 = load i32*, i32** %10
%36 = call i32 @fread(i8* %33, i32 1, i64 %34, i32* %35)
%37 = load i32*, i32** %10
%38 = call i32 @fclose(i32* %37)
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%40 = load i8*, i8** %6
%41 = getelementptr inbounds [2 x i8], [2 x i8]* %8, i64 0, i64 0
%42 = call i8* @strtok(i8* %40, i8* %41)
store i8* %42, i8** %9
br label %43
43: ; preds = %56, %22
%44 = load i8*, i8** %9
%45 = icmp ne i8* %44, null
br i1 %45, label %46, label %59
46: ; preds = %43
%47 = load i8*, i8** %9
%48 = getelementptr inbounds i8, i8* %47, i64 0
%49 = call i64 @strncmp(i8* %48, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i32 1)
%50 = icmp ne i64 %49, 0
br i1 %50, label %51, label %54
51: ; preds = %46
%52 = load i8*, i8** %9
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %52)
br label %56
54: ; preds = %46
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %56
56: ; preds = %54, %51
%57 = getelementptr inbounds [2 x i8], [2 x i8]* %8, i64 0, i64 0
%58 = call i8* @strtok(i8* null, i8* %57)
store i8* %58, i8** %9
br label %43
59: ; preds = %43
br label %62
60: ; preds = %2
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0))
br label %62
62: ; preds = %60, %59
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [19 x i8] c"Loading file: %s \0A\00"
@.str.1 = [3 x i8] c"rb\00"
@SEEK_END = global i32 0
@.str.3 = [2 x i8] c"#\00"
@.str.4 = [4 x i8] c"%s \00"
@.str.6 = [21 x i8] c"Could not load file.\00"
@str = [13 x i8] c"Loaded File\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i16
%4 = bitcast i16* %3 to i8*
store i16 10, i16* %3
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = load i8*, i8** %5
%9 = tail call i32* @fopen(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i32* %9, null
br i1 %10, label %33, label %11
11: ; preds = %2
%12 = load i32, i32* @SEEK_END
%13 = tail call i32 @fseek(i32* %9, i32 0, i32 %12)
%14 = tail call i64 @ftell(i32* %9)
%15 = tail call i32 @rewind(i32* %9)
%16 = tail call i8* @malloc(i64 %14)
%17 = tail call i32 @fread(i8* %16, i32 1, i64 %14, i32* %9)
%18 = tail call i32 @fclose(i32* %9)
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str, i64 0, i64 0))
%20 = call i8* @strtok(i8* %16, i8* %4)
%21 = icmp eq i8* %20, null
br i1 %21, label %35, label %22
22: ; preds = %11, %30
%23 = phi i8* [ %31, %30 ], [ %20, %11 ]
%24 = tail call i64 @strncmp(i8* %23, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i32 1)
%25 = icmp eq i64 %24, 0
br i1 %25, label %28, label %26
26: ; preds = %22
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %23)
br label %30
28: ; preds = %22
%29 = tail call i32 @putchar(i32 10)
br label %30
30: ; preds = %28, %26
%31 = call i8* @strtok(i8* null, i8* %4)
%32 = icmp eq i8* %31, null
br i1 %32, label %35, label %22
33: ; preds = %2
%34 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0))
br label %35
35: ; preds = %30, %11, %33
%36 = tail call i32 @putchar(i32 10)
ret i32 0
}