#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
char *getMBR(int /*<<< orphan*/ *);
int /*<<< orphan*/ parsePartitionEntries(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
void mbrAnalysis(FILE *f, char *sourcefile, char *output, long long size) {
  char *masterbootrecord;
  FILE *mdata_output_file;
  mdata_output_file = fopen(output, "w");
  printf("\nAuthor:   %s\n", "JD Durick <jd@vmforensics.org>");
  printf("Program:  %s\n", "mbrChunker");
  printf("Website:  %s\n", "http://vmforensics.org");
  printf("Version:  %s\n", "0.3 $Rev: 19 $");
  printf("Revision date:  %s\n",
         "2010-07-05 08:27:47 -0400 (Mon, 05 Jul 2010)");
  printf("\nMBR Analysis of %s\n", sourcefile);
  printf("Metadata file location:  %6s\n", output);
  printf("File size in bytes:  %lld\n", size);
  fprintf(mdata_output_file, "\nAuthor:   %s\n",
          "JD Durick <jd@vmforensics.org>");
  fprintf(mdata_output_file, "Program:  %s\n", "mbrChunker");
  fprintf(mdata_output_file, "Website:  %s\n", "http://vmforensics.org");
  fprintf(mdata_output_file, "Version:  %s\n", "0.3 $Rev: 19 $");
  fprintf(mdata_output_file, "Revision date:  %s\n",
          "2010-07-05 08:27:47 -0400 (Mon, 05 Jul 2010)");
  fprintf(mdata_output_file, "======================================\n");
  fprintf(mdata_output_file, "\nMBR Analysis of %s\n", sourcefile);
  fprintf(mdata_output_file, "Metadata file location:  %6s\n", output);
  fprintf(mdata_output_file, "File size in bytes:  %lld\n", size);
  masterbootrecord = getMBR(f);
  parsePartitionEntries(masterbootrecord, mdata_output_file);
  fclose(mdata_output_file);
  return;
}


x86 assembly (clang, -O0):
<mbrAnalysis>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe7d(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x30(%rbp)
lea    0xe6f(%rip),%rdi
lea    0xe77(%rip),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe88(%rip),%rdi
lea    0xe8f(%rip),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe8c(%rip),%rdi
lea    0xe93(%rip),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe9c(%rip),%rdi
lea    0xea3(%rip),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xea4(%rip),%rdi
lea    0xeb1(%rip),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rsi
lea    0xecc(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rsi
lea    0xecf(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%rsi
lea    0xedb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x30(%rbp),%rdi
lea    0xdcc(%rip),%rsi
lea    0xdd4(%rip),%rdx
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x30(%rbp),%rdi
lea    0xde1(%rip),%rsi
lea    0xde8(%rip),%rdx
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x30(%rbp),%rdi
lea    0xde1(%rip),%rsi
lea    0xde8(%rip),%rdx
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x30(%rbp),%rdi
lea    0xded(%rip),%rsi
lea    0xdf4(%rip),%rdx
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x30(%rbp),%rdi
lea    0xdf1(%rip),%rsi
lea    0xdfe(%rip),%rdx
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x30(%rbp),%rdi
lea    0xe67(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xe03(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x30(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xe02(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x30(%rbp),%rdi
mov    -0x20(%rbp),%rdx
lea    0xe0a(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x8(%rbp),%rdi
call   1080 <getMBR@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1050 <parsePartitionEntries@plt>
mov    -0x30(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mbrAnalysis>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r15
mov    %rdx,%r12
mov    %rsi,%r13
mov    %rdi,(%rsp)
lea    0xe71(%rip),%rsi
mov    %rdx,%rdi
call   1070 <fopen@plt>
mov    %rax,%rbx
lea    0xe61(%rip),%rdi
lea    0xe69(%rip),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe7a(%rip),%rdi
lea    0xe81(%rip),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe7e(%rip),%rdi
lea    0xe85(%rip),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe8e(%rip),%rdi
lea    0xe95(%rip),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe96(%rip),%r14
lea    0xea3(%rip),%rbp
mov    %r14,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xebc(%rip),%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xec0(%rip),%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xecd(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
lea    0xdbc(%rip),%rsi
lea    0xdc4(%rip),%rdx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    %rbx,%rdi
lea    0xdd2(%rip),%rsi
lea    0xdd9(%rip),%rdx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    %rbx,%rdi
lea    0xdd3(%rip),%rsi
lea    0xdda(%rip),%rdx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    %rbx,%rdi
lea    0xde0(%rip),%rsi
lea    0xde7(%rip),%rdx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %rbp,%rdx
xor    %eax,%eax
call   1060 <fprintf@plt>
lea    0xe67(%rip),%rdi
mov    $0x27,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1080 <fwrite@plt>
mov    %rbx,%rdi
lea    0xdfd(%rip),%rsi
mov    %r13,%rdx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    %rbx,%rdi
lea    0xdfe(%rip),%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    %rbx,%rdi
lea    0xe08(%rip),%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    (%rsp),%rdi
call   1090 <getMBR@plt>
mov    %rax,%rdi
mov    %rbx,%rsi
call   1050 <parsePartitionEntries@plt>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <fclose@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"w\00"
@.str.1 = [15 x i8] c"\0AAuthor: %s\0A\00"
@.str.2 = [31 x i8] c"JD Durick <jd@vmforensics.org>\00"
@.str.3 = [14 x i8] c"Program: %s\0A\00"
@.str.4 = [11 x i8] c"mbrChunker\00"
@.str.5 = [14 x i8] c"Website: %s\0A\00"
@.str.6 = [23 x i8] c"http://vmforensics.org\00"
@.str.7 = [14 x i8] c"Version: %s\0A\00"
@.str.8 = [15 x i8] c"0.3 $Rev: 19 $\00"
@.str.9 = [20 x i8] c"Revision date: %s\0A\00"
@.str.10 = [45 x i8] c"2010-07-05 08:27:47 -0400 (Mon, 05 Jul 2010)\00"
@.str.11 = [21 x i8] c"\0AMBR Analysis of %s\0A\00"
@.str.12 = [30 x i8] c"Metadata file location: %6s\0A\00"
@.str.13 = [27 x i8] c"File size in bytes: %lld\0A\00"
@.str.14 = [40 x i8] c"======================================\0A\00"
define void @mbrAnalysis(i32* %0, i8* %1, i8* %2, i64 %3) {
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i8*
%10 = alloca i32*
store i32* %0, i32** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i64 %3, i64* %8
%11 = load i8*, i8** %7
%12 = call i32* @fopen(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %12, i32** %10
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0))
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0))
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0))
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.10, i64 0, i64 0))
%18 = load i8*, i8** %6
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.11, i64 0, i64 0), i8* %18)
%20 = load i8*, i8** %7
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.12, i64 0, i64 0), i8* %20)
%22 = load i64, i64* %8
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.13, i64 0, i64 0), i64 %22)
%24 = load i32*, i32** %10
%25 = call i32 (i32*, i8*, ...) @fprintf(i32* %24, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0))
%26 = load i32*, i32** %10
%27 = call i32 (i32*, i8*, ...) @fprintf(i32* %26, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
%28 = load i32*, i32** %10
%29 = call i32 (i32*, i8*, ...) @fprintf(i32* %28, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0))
%30 = load i32*, i32** %10
%31 = call i32 (i32*, i8*, ...) @fprintf(i32* %30, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0))
%32 = load i32*, i32** %10
%33 = call i32 (i32*, i8*, ...) @fprintf(i32* %32, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.10, i64 0, i64 0))
%34 = load i32*, i32** %10
%35 = call i32 (i32*, i8*, ...) @fprintf(i32* %34, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.14, i64 0, i64 0))
%36 = load i32*, i32** %10
%37 = load i8*, i8** %6
%38 = call i32 (i32*, i8*, ...) @fprintf(i32* %36, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.11, i64 0, i64 0), i8* %37)
%39 = load i32*, i32** %10
%40 = load i8*, i8** %7
%41 = call i32 (i32*, i8*, ...) @fprintf(i32* %39, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.12, i64 0, i64 0), i8* %40)
%42 = load i32*, i32** %10
%43 = load i64, i64* %8
%44 = call i32 (i32*, i8*, ...) @fprintf(i32* %42, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.13, i64 0, i64 0), i64 %43)
%45 = load i32*, i32** %5
%46 = call i8* @getMBR(i32* %45)
store i8* %46, i8** %9
%47 = load i8*, i8** %9
%48 = load i32*, i32** %10
%49 = call i32 @parsePartitionEntries(i8* %47, i32* %48)
%50 = load i32*, i32** %10
%51 = call i32 @fclose(i32* %50)
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"w\00"
@.str.1 = [15 x i8] c"\0AAuthor: %s\0A\00"
@.str.2 = [31 x i8] c"JD Durick <jd@vmforensics.org>\00"
@.str.3 = [14 x i8] c"Program: %s\0A\00"
@.str.4 = [11 x i8] c"mbrChunker\00"
@.str.5 = [14 x i8] c"Website: %s\0A\00"
@.str.6 = [23 x i8] c"http://vmforensics.org\00"
@.str.7 = [14 x i8] c"Version: %s\0A\00"
@.str.8 = [15 x i8] c"0.3 $Rev: 19 $\00"
@.str.9 = [20 x i8] c"Revision date: %s\0A\00"
@.str.10 = [45 x i8] c"2010-07-05 08:27:47 -0400 (Mon, 05 Jul 2010)\00"
@.str.11 = [21 x i8] c"\0AMBR Analysis of %s\0A\00"
@.str.12 = [30 x i8] c"Metadata file location: %6s\0A\00"
@.str.13 = [27 x i8] c"File size in bytes: %lld\0A\00"
@.str.14 = [40 x i8] c"======================================\0A\00"
define void @mbrAnalysis(i32* %0, i8* %1, i8* %2, i64 %3) {
%5 = tail call i32* @fopen(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0))
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0))
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0))
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.10, i64 0, i64 0))
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.11, i64 0, i64 0), i8* %1)
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.12, i64 0, i64 0), i8* %2)
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.13, i64 0, i64 0), i64 %3)
%14 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %5, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0))
%15 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %5, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
%16 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %5, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0))
%17 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %5, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0))
%18 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %5, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.10, i64 0, i64 0))
%19 = tail call i64 @fwrite(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.14, i64 0, i64 0), i64 39, i64 1, i32* %5)
%20 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %5, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.11, i64 0, i64 0), i8* %1)
%21 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %5, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.12, i64 0, i64 0), i8* %2)
%22 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %5, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.13, i64 0, i64 0), i64 %3)
%23 = tail call i8* @getMBR(i32* %0)
%24 = tail call i32 @parsePartitionEntries(i8* %23, i32* %5)
%25 = tail call i32 @fclose(i32* %5)
ret void
}