#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*/ *);
int /*<<< orphan*/ scanf(char *, char **);
scalar_t__ strncmp(char *, char *, int);
char *strtok(char *, char *);
int main() {
  char str[100];
  char *file_contents;
  long input_file_size;
  char linebreak[2] = "\n";
  char *line;
  printf("Enter any string ( upto 100 character ) \n");
  scanf("%s", &str);
  printf("Loading file: %s", str);
  FILE *ft = fopen(str, "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.");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xe81(%rip),%ax
mov    %ax,-0x82(%rbp)
lea    0xe29(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x70(%rbp),%rsi
lea    0xe4f(%rip),%rdi
call   10b0 <scanf@plt>
lea    -0x70(%rbp),%rsi
lea    0xe31(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x70(%rbp),%rdi
lea    0xe30(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x98(%rbp)
cmpq   $0x0,-0x98(%rbp)
je     132c <main+0x17c>
mov    -0x98(%rbp),%rdi
mov    0x2db5(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   10a0 <fseek@plt>
mov    -0x98(%rbp),%rdi
call   1080 <ftell@plt>
mov    %rax,-0x80(%rbp)
mov    -0x98(%rbp),%rdi
call   1070 <rewind@plt>
mov    -0x80(%rbp),%rdi
shl    $0x0,%rdi
call   1090 <malloc@plt>
mov    %rax,-0x78(%rbp)
mov    -0x78(%rbp),%rdi
mov    -0x80(%rbp),%rdx
mov    -0x98(%rbp),%rcx
mov    $0x1,%esi
call   1040 <fread@plt>
mov    -0x98(%rbp),%rdi
call   1050 <fclose@plt>
lea    0xda9(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x78(%rbp),%rdi
lea    -0x82(%rbp),%rsi
call   10d0 <strtok@plt>
mov    %rax,-0x90(%rbp)
cmpq   $0x0,-0x90(%rbp)
je     1327 <main+0x177>
mov    -0x90(%rbp),%rdi
lea    0xd7d(%rip),%rsi
mov    $0x1,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     12fd <main+0x14d>
mov    -0x90(%rbp),%rsi
lea    0xd5d(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    130b <main+0x15b>
lea    0xd46(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x82(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edi
call   10d0 <strtok@plt>
mov    %rax,-0x90(%rbp)
jmp    12b3 <main+0x103>
jmp    133a <main+0x18a>
lea    0xd1f(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
xor    %eax,%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x78,%rsp
movw   $0xa,0xe(%rsp)
lea    0xe46(%rip),%rdi
call   1050 <puts@plt>
lea    0xe19(%rip),%rdi
lea    0x10(%rsp),%rbx
mov    %rbx,%rsi
call   10d0 <scanf@plt>
lea    0xdf7(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xdf7(%rip),%rsi
mov    %rbx,%rdi
call   10e0 <fopen@plt>
test   %rax,%rax
je     12f0 <main+0x120>
mov    %rax,%rbx
mov    0x2db3(%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    0xdd7(%rip),%rdi
call   1050 <puts@plt>
lea    0xe(%rsp),%rsi
mov    %r15,%rdi
call   10f0 <strtok@plt>
test   %rax,%rax
je     12fe <main+0x12e>
mov    %rax,%rbx
lea    0xd72(%rip),%r14
lea    0xe(%rsp),%r12
lea    0xd68(%rip),%r15
jmp    12cc <main+0xfc>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %edi,%edi
mov    %r12,%rsi
call   10f0 <strtok@plt>
mov    %rax,%rbx
test   %rax,%rax
je     12fe <main+0x12e>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x1,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
je     12b0 <main+0xe0>
mov    %r15,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
jmp    12ba <main+0xea>
lea    0xd23(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
xor    %eax,%eax
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

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