#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*/ *fopen(char *, char *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ getFileType(char *);
char *getMagicNumber(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char **argv) {
  char *fileInfo;
  if (argc != 2) {
    printf("usage: %s filename", argv[0]);
  } else {
    FILE *file = fopen(argv[1], "r");
    if (file == 0) {
      printf("Could not open file\n");
      return EXIT_FAILURE;
    } else {
      fileInfo = getMagicNumber(file);
      getFileType(fileInfo);
    }
  }
  free(fileInfo);
  return EXIT_SUCCESS;
}


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   $0x2,-0x8(%rbp)
je     118a <main+0x3a>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    11e7 <main+0x97>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe7a(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11cc <main+0x7c>
lea    0xe61(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2e1e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11fc <main+0xac>
mov    -0x20(%rbp),%rdi
call   1060 <getMagicNumber@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <getFileType@plt>
jmp    11e7 <main+0x97>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    0x2de1(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
cmp    $0x2,%edi
jne    11b6 <main+0x56>
mov    0x8(%rsi),%rdi
lea    0xea2(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     119f <main+0x3f>
mov    %rax,%rdi
call   1070 <getMagicNumber@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1050 <getFileType@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    0x2e3b(%rip),%rax
jmp    11b2 <main+0x52>
lea    0xe6f(%rip),%rdi
call   1040 <puts@plt>
mov    0x2e2e(%rip),%rax
mov    (%rax),%eax
pop    %rbx
ret
mov    (%rsi),%rsi
lea    0xe40(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>

LLVM IR (-O0):
@.str = [19 x i8] c"usage: %s filename\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [21 x i8] c"Could not open file\0A\00"
@EXIT_FAILURE = global i32 0
@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*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp ne i32 %8, 2
br i1 %9, label %10, label %15
10: ; preds = %2
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 0
%13 = load i8*, i8** %12
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %13)
br label %31
15: ; preds = %2
%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 ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %19, i32** %7
%20 = load i32*, i32** %7
%21 = icmp eq i32* %20, null
br i1 %21, label %22, label %25
22: ; preds = %15
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%24 = load i32, i32* @EXIT_FAILURE
store i32 %24, i32* %3
br label %35
25: ; preds = %15
%26 = load i32*, i32** %7
%27 = call i8* @getMagicNumber(i32* %26)
store i8* %27, i8** %6
%28 = load i8*, i8** %6
%29 = call i32 @getFileType(i8* %28)
br label %30
30: ; preds = %25
br label %31
31: ; preds = %30, %10
%32 = load i8*, i8** %6
%33 = call i32 @free(i8* %32)
%34 = load i32, i32* @EXIT_SUCCESS
store i32 %34, i32* %3
br label %35
35: ; preds = %31, %22
%36 = load i32, i32* %3
ret i32 %36
}

LLVM IR (-O2):
@.str = [19 x i8] c"usage: %s filename\00"
@.str.1 = [2 x i8] c"r\00"
@EXIT_FAILURE = global i32 0
@EXIT_SUCCESS = global i32 0
@str = [20 x i8] c"Could not open file\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %7, label %4
4: ; preds = %2
%5 = load i8*, i8** %1
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %5)
unreachable
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i32* @fopen(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %14
12: ; preds = %7
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
br label %18
14: ; preds = %7
%15 = tail call i8* @getMagicNumber(i32* %10)
%16 = tail call i32 @getFileType(i8* %15)
%17 = tail call i32 @free(i8* %15)
br label %18
18: ; preds = %12, %14
%19 = phi i32* [ @EXIT_SUCCESS, %14 ], [ @EXIT_FAILURE, %12 ]
%20 = load i32, i32* %19
ret i32 %20
}