#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 */

/* Variables and functions */
int /*<<< orphan*/ closeDB();
int connectDB();
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int scanDirectory(char *);
int testMD5();
int main(int argc, char **argv) {
  int result = connectDB();
  if (result) {
    printf("Failed to connect database, aborting...\n");
    return 1;
  }
  if (argc != 2) {
    perror("Please supply a path to a folder or file.\n");
    return 1;
  } else {
    int pass = scanDirectory(argv[1]);
    if (pass) {
      printf("Failed scanning directory for argument %s\n", argv[1]);
    }
  }
  int testResult = testMD5();
  if (testResult) {
    printf("Failed unit test");
  }
  closeDB();
  printf("Scan complete.");
  return 0;
}


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)
mov    $0x0,%al
call   1050 <connectDB@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     11a4 <main+0x44>
lea    0xe6f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1239 <main+0xd9>
cmpl   $0x2,-0x8(%rbp)
je     11c6 <main+0x66>
lea    0xe74(%rip),%rdi
call   1070 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    1239 <main+0xd9>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <scanDirectory@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     11f6 <main+0x96>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe65(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11fb <main+0x9b>
mov    $0x0,%al
call   1080 <testMD5@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     121d <main+0xbd>
lea    0xe69(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1030 <closeDB@plt>
lea    0xe65(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
xor    %eax,%eax
call   1060 <connectDB@plt>
test   %eax,%eax
je     1196 <main+0x26>
lea    0xeec(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%ebx
jmp    11ea <main+0x7a>
cmp    $0x2,%ebp
jne    11f3 <main+0x83>
mov    0x8(%rbx),%rdi
call   1070 <scanDirectory@plt>
test   %eax,%eax
je     11ba <main+0x4a>
mov    0x8(%rbx),%rsi
lea    0xe78(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %ebx,%ebx
xor    %eax,%eax
call   1090 <testMD5@plt>
test   %eax,%eax
je     11d5 <main+0x65>
lea    0xe88(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1030 <closeDB@plt>
lea    0xe84(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
lea    0xe06(%rip),%rdi
call   1080 <perror@plt>
mov    $0x1,%ebx
jmp    11ea <main+0x7a>

LLVM IR (-O0):
@.str = [41 x i8] c"Failed to connect database, aborting...\0A\00"
@.str.1 = [43 x i8] c"Please supply a path to a folder or file.\0A\00"
@.str.2 = [43 x i8] c"Failed scanning directory for argument %s\0A\00"
@.str.3 = [17 x i8] c"Failed unit test\00"
@.str.4 = [15 x i8] c"Scan complete.\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = call i32 (...) @connectDB()
store i32 %9, i32* %6
%10 = load i32, i32* %6
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %41
14: ; preds = %2
%15 = load i32, i32* %4
%16 = icmp ne i32 %15, 2
br i1 %16, label %17, label %19
17: ; preds = %14
%18 = call i32 @perror(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %3
br label %41
19: ; preds = %14
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
%23 = call i32 @scanDirectory(i8* %22)
store i32 %23, i32* %7
%24 = load i32, i32* %7
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %31
26: ; preds = %19
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 1
%29 = load i8*, i8** %28
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0), i8* %29)
br label %31
31: ; preds = %26, %19
br label %32
32: ; preds = %31
%33 = call i32 (...) @testMD5()
store i32 %33, i32* %8
%34 = load i32, i32* %8
%35 = icmp ne i32 %34, 0
br i1 %35, label %36, label %38
36: ; preds = %32
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
br label %38
38: ; preds = %36, %32
%39 = call i32 (...) @closeDB()
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %3
br label %41
41: ; preds = %38, %17, %12
%42 = load i32, i32* %3
ret i32 %42
}

LLVM IR (-O2):
@.str.1 = [43 x i8] c"Please supply a path to a folder or file.\0A\00"
@.str.2 = [43 x i8] c"Failed scanning directory for argument %s\0A\00"
@.str.3 = [17 x i8] c"Failed unit test\00"
@.str.4 = [15 x i8] c"Scan complete.\00"
@str = [40 x i8] c"Failed to connect database, aborting...\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = tail call i32 (...) @connectDB()
%4 = icmp eq i32 %3, 0
br i1 %4, label %7, label %5
5: ; preds = %2
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str, i64 0, i64 0))
br label %27
7: ; preds = %2
%8 = icmp eq i32 %0, 2
br i1 %8, label %11, label %9
9: ; preds = %7
%10 = tail call i32 @perror(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0))
br label %27
11: ; preds = %7
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = tail call i32 @scanDirectory(i8* %13)
%15 = icmp eq i32 %14, 0
br i1 %15, label %19, label %16
16: ; preds = %11
%17 = load i8*, i8** %12
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0), i8* %17)
br label %19
19: ; preds = %16, %11
%20 = tail call i32 (...) @testMD5()
%21 = icmp eq i32 %20, 0
br i1 %21, label %24, label %22
22: ; preds = %19
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
br label %24
24: ; preds = %22, %19
%25 = tail call i32 (...) @closeDB()
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
br label %27
27: ; preds = %24, %9, %5
%28 = phi i32 [ 1, %5 ], [ 1, %9 ], [ 0, %24 ]
ret i32 %28
}