#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_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ extract_files();
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ print_file_data();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ read_files(int /*<<< orphan*/ *);
int main(int argc, char *argv[]) {
  if (argc > 1) {
    FILE *fp;
    fp = fopen(argv[1], "r");
    if (fp == NULL) {
      printf("File does not exist!\n");
      exit(EXIT_FAILURE);
    }
    read_files(fp);
    print_file_data();
    extract_files();
    fclose(fp);
    exit(EXIT_SUCCESS);
  } else {
    printf("Usage: ./tar filename\n");
    exit(EXIT_FAILURE);
  }
}


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   $0x1,-0x8(%rbp)
jle    11fb <main+0x8b>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe61(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11cd <main+0x5d>
lea    0xe48(%rip),%rdi
call   1050 <printf@plt>
mov    0x2e1a(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
mov    -0x18(%rbp),%rdi
call   1070 <read_files@plt>
mov    $0x0,%al
call   1060 <print_file_data@plt>
mov    $0x0,%al
call   1030 <extract_files@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
mov    0x2de4(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
lea    0xe16(%rip),%rdi
call   1050 <printf@plt>
mov    0x2dd2(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbx
cmp    $0x2,%edi
jl     1194 <main+0x24>
mov    0x8(%rsi),%rdi
lea    0xe7f(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
jne    11ae <main+0x3e>
lea    0xe86(%rip),%rdi
jmp    119b <main+0x2b>
lea    0xe67(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e39(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1070 <read_files@plt>
xor    %eax,%eax
call   1060 <print_file_data@plt>
xor    %eax,%eax
call   1040 <extract_files@plt>
mov    %rbx,%rdi
call   1050 <fclose@plt>
mov    0x2e02(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [22 x i8] c"File does not exist!\0A\00"
@EXIT_FAILURE = global i32 0
@EXIT_SUCCESS = global i32 0
@.str.2 = [23 x i8] c"Usage: ./tar filename\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp sgt i32 %7, 1
br i1 %8, label %9, label %29
9: ; preds = %2
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 1
%12 = load i8*, i8** %11
%13 = call i32* @fopen(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %13, i32** %6
%14 = load i32*, i32** %6
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %20
16: ; preds = %9
%17 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
%18 = load i32, i32* @EXIT_FAILURE
%19 = call i32 @exit(i32 %18)
unreachable
20: ; preds = %9
%21 = load i32*, i32** %6
%22 = call i32 @read_files(i32* %21)
%23 = call i32 (...) @print_file_data()
%24 = call i32 (...) @extract_files()
%25 = load i32*, i32** %6
%26 = call i32 @fclose(i32* %25)
%27 = load i32, i32* @EXIT_SUCCESS
%28 = call i32 @exit(i32 %27)
unreachable
29: ; preds = %2
%30 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
%31 = load i32, i32* @EXIT_FAILURE
%32 = call i32 @exit(i32 %31)
unreachable
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@EXIT_FAILURE = global i32 0
@EXIT_SUCCESS = global i32 0
@str = [22 x i8] c"Usage: ./tar filename\00"
@str.3 = [21 x i8] c"File does not exist!\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %4, label %20
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32* @fopen(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i32* %7, null
br i1 %8, label %9, label %13
9: ; preds = %4
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.3, i64 0, i64 0))
%11 = load i32, i32* @EXIT_FAILURE
%12 = tail call i32 @exit(i32 %11)
unreachable
13: ; preds = %4
%14 = tail call i32 @read_files(i32* %7)
%15 = tail call i32 (...) @print_file_data()
%16 = tail call i32 (...) @extract_files()
%17 = tail call i32 @fclose(i32* %7)
%18 = load i32, i32* @EXIT_SUCCESS
%19 = tail call i32 @exit(i32 %18)
unreachable
20: ; preds = %2
%21 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
%22 = load i32, i32* @EXIT_FAILURE
%23 = tail call i32 @exit(i32 %22)
unreachable
}