#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*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ indent(char *);
int /*<<< orphan*/ linenum(char *);
int /*<<< orphan*/ printf(char *);
int main(int argc, char *argv[]) {
  FILE *fp;
  char line[80];
  if (argc < 2) {
    printf("No filename entered.\n");
    exit(1);
  }
  if ((fp = fopen(argv[1], "r")) == NULL) {
    printf("Could not open file.\n");
    exit(1);
  }
  while (fgets(line, sizeof line, fp) != NULL) {
    linenum(line);
    indent(line);
  }
  fclose(fp);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    11a6 <main+0x36>
lea    0xe69(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe61(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    11de <main+0x6e>
lea    0xe49(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
jmp    11e3 <main+0x73>
lea    -0x70(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x50,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
je     1216 <main+0xa6>
lea    -0x70(%rbp),%rdi
call   1070 <linenum@plt>
lea    -0x70(%rbp),%rdi
call   1060 <indent@plt>
jmp    11e3 <main+0x73>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x58,%rsp
cmp    $0x1,%edi
jle    11e7 <main+0x77>
mov    0x8(%rsi),%rdi
lea    0xe79(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     11f0 <main+0x80>
mov    %rax,%r14
mov    %rsp,%rdi
mov    $0x50,%esi
mov    %rax,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
je     11d5 <main+0x65>
mov    %rsp,%rbx
nopl   0x0(%rax)
mov    %rbx,%rdi
call   1070 <linenum@plt>
mov    %rbx,%rdi
call   1060 <indent@plt>
mov    %rbx,%rdi
mov    $0x50,%esi
mov    %r14,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
jne    11b0 <main+0x40>
mov    %r14,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r14
ret
lea    0xe29(%rip),%rdi
jmp    11f7 <main+0x87>
lea    0xe0b(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [22 x i8] c"No filename entered.\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [22 x i8] c"Could not open file.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca [80 x 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 %10, label %13
10: ; preds = %2
%11 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%12 = call i32 @exit(i32 1)
unreachable
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = call i32* @fopen(i8* %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %17, i32** %6
%18 = icmp eq i32* %17, null
br i1 %18, label %19, label %22
19: ; preds = %13
%20 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%21 = call i32 @exit(i32 1)
unreachable
22: ; preds = %13
br label %23
23: ; preds = %28, %22
%24 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%25 = load i32*, i32** %6
%26 = call i32* @fgets(i8* %24, i32 80, i32* %25)
%27 = icmp ne i32* %26, null
br i1 %27, label %28, label %33
28: ; preds = %23
%29 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%30 = call i32 @linenum(i8* %29)
%31 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%32 = call i32 @indent(i8* %31)
br label %23
33: ; preds = %23
%34 = load i32*, i32** %6
%35 = call i32 @fclose(i32* %34)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [2 x i8] c"r\00"
@str = [21 x i8] c"Could not open file.\00"
@str.3 = [21 x i8] c"No filename entered.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [80 x i8]
%4 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%5 = icmp slt i32 %0, 2
br i1 %5, label %6, label %9
6: ; preds = %2
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.3, i64 0, i64 0))
%8 = tail call i32 @exit(i32 1)
unreachable
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 %17, label %14
14: ; preds = %9
%15 = call i32* @fgets(i8* %4, i32 80, i32* %12)
%16 = icmp eq i32* %15, null
br i1 %16, label %25, label %20
17: ; preds = %9
%18 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
%19 = tail call i32 @exit(i32 1)
unreachable
20: ; preds = %14, %20
%21 = call i32 @linenum(i8* %4)
%22 = call i32 @indent(i8* %4)
%23 = call i32* @fgets(i8* %4, i32 80, i32* %12)
%24 = icmp eq i32* %23, null
br i1 %24, label %25, label %20
25: ; preds = %20, %14
%26 = call i32 @fclose(i32* %12)
ret i32 0
}