#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 atoi(char *);
int /*<<< orphan*/ calculateANI(char *, int const, int const,
                                int /*<<< orphan*/);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ numberOfFiles(char *);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  if (argc == 4) {
    const int kmerSizeMinParam = atoi(argv[2]);
    const int kmerSizeMaxParam = atoi(argv[3]);
    const int fileSimilarityThresholdConstantParam = 0;
    FILE *f = fopen("ani.txt", "a");
    if (f == NULL) {
      printf("Error opening ani.txt\n");
      exit(1);
    }
    fprintf(f, "CREATE TABLE anilyze (Genus1, Species1, Genus2, Species2, "
               "kmerSize, Percentage real);\n");
    fprintf(f, "INSERT INTO anilyzeTable (Genus1, Species1, Genus2, Species2, "
               "kmerSize, Percentage) \nVALUES \n");
    fclose(f);
    if (kmerSizeMaxParam == 0) {
      calculateANI(argv[1], kmerSizeMinParam,
                   fileSimilarityThresholdConstantParam,
                   numberOfFiles(argv[1]));
    } else {
      for (int i = kmerSizeMinParam; i <= kmerSizeMaxParam; i++) {
        calculateANI(argv[1], i, fileSimilarityThresholdConstantParam,
                     numberOfFiles(argv[1]));
      }
    }
  } else {
    printf("%s",
           "Error, ./anilyzeExeC <User/path/locationOfFormattedFiles> "
           "<kmerSizeInteger> <filePercentSimilarityThresholdConstantInteger>");
    printf("%s", "Example: ./anilyzeExeC "
                 "/Users/jon/desktop/anilyze/C/tests/sampleTestFiles/ 2 4");
    printf("%s", "Please ./README for more information on formattedFiles");
    exit(EXIT_FAILURE);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x4,-0x8(%rbp)
jne    12c1 <main+0x141>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1090 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1090 <atoi@plt>
mov    %eax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
lea    0xe32(%rip),%rdi
lea    0xe33(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1201 <main+0x81>
lea    0xe1a(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
mov    -0x28(%rbp),%rdi
lea    0xe15(%rip),%rsi
call   1070 <fprintf@plt>
mov    -0x28(%rbp),%rdi
lea    0xe5c(%rip),%rsi
call   1070 <fprintf@plt>
mov    -0x28(%rbp),%rdi
call   1050 <fclose@plt>
cmpl   $0x0,-0x18(%rbp)
jne    1268 <main+0xe8>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x38(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1030 <numberOfFiles@plt>
mov    -0x38(%rbp),%rdi
mov    -0x30(%rbp),%esi
mov    %eax,%ecx
xor    %edx,%edx
call   1040 <calculateANI@plt>
jmp    12bc <main+0x13c>
mov    -0x14(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jg     12b7 <main+0x137>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x48(%rbp)
mov    -0x2c(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1030 <numberOfFiles@plt>
mov    -0x48(%rbp),%rdi
mov    -0x3c(%rbp),%esi
mov    %eax,%ecx
xor    %edx,%edx
call   1040 <calculateANI@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    126e <main+0xee>
jmp    12bc <main+0x13c>
jmp    130e <main+0x18e>
lea    0xe0e(%rip),%rdi
lea    0xe0a(%rip),%rsi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xdf9(%rip),%rdi
lea    0xe71(%rip),%rsi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xde4(%rip),%rdi
lea    0xeab(%rip),%rsi
mov    $0x0,%al
call   1060 <printf@plt>
mov    0x2cd9(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
cmp    $0x4,%edi
jne    1279 <main+0xe9>
mov    %rsi,%r14
mov    0x10(%rsi),%rdi
call   1090 <atoi@plt>
mov    %eax,%ebp
mov    0x18(%r14),%rdi
call   1090 <atoi@plt>
mov    %eax,%r12d
lea    0x1008(%rip),%rdi
lea    0xe37(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     12c1 <main+0x131>
mov    %rax,%r15
lea    0xe21(%rip),%rdi
mov    $0x56,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   10b0 <fwrite@plt>
lea    0xe5f(%rip),%rdi
mov    $0x5d,%esi
mov    $0x1,%edx
mov    %r15,%rcx
call   10b0 <fwrite@plt>
mov    %r15,%rdi
call   1060 <fclose@plt>
test   %r12d,%r12d
je     1254 <main+0xc4>
cmp    %r12d,%ebp
jg     126e <main+0xde>
add    $0x1,%r12d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    0x8(%r14),%rbx
mov    %rbx,%rdi
call   1030 <numberOfFiles@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
xor    %edx,%edx
mov    %eax,%ecx
call   1050 <calculateANI@plt>
add    $0x1,%ebp
cmp    %ebp,%r12d
jne    1230 <main+0xa0>
jmp    126e <main+0xde>
mov    0x8(%r14),%rbx
mov    %rbx,%rdi
call   1030 <numberOfFiles@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
xor    %edx,%edx
mov    %eax,%ecx
call   1050 <calculateANI@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe37(%rip),%rbx
lea    0xe33(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xe9e(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xedc(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x2d26(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
lea    0xef4(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@.str = [8 x i8] c"ani.txt\00"
@.str.1 = [2 x i8] c"a\00"
@.str.2 = [23 x i8] c"Error opening ani.txt\0A\00"
@.str.3 = [87 x i8] c"CREATE TABLE anilyze (Genus1, Species1, Genus2, Species2, kmerSize, Percentage real);\0A\00"
@.str.4 = [94 x i8] c"INSERT INTO anilyzeTable (Genus1, Species1, Genus2, Species2, kmerSize, Percentage) \0AVALUES \0A\00"
@.str.5 = [3 x i8] c"%s\00"
@.str.6 = [124 x i8] c"Error, ./anilyzeExeC <User/path/locationOfFormattedFiles> <kmerSizeInteger> <filePercentSimilarityThresholdConstantInteger>\00"
@.str.7 = [79 x i8] c"Example: ./anilyzeExeC /Users/jon/desktop/anilyze/C/tests/sampleTestFiles/ 2 4\00"
@.str.8 = [55 x i8] c"Please ./README for more information on formattedFiles\00"
@EXIT_FAILURE = global i32 0
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
%9 = alloca i32*
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* %4
%12 = icmp eq i32 %11, 4
br i1 %12, label %13, label %68
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 2
%16 = load i8*, i8** %15
%17 = call i32 @atoi(i8* %16)
store i32 %17, i32* %6
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 3
%20 = load i8*, i8** %19
%21 = call i32 @atoi(i8* %20)
store i32 %21, i32* %7
store i32 0, i32* %8
%22 = call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %22, i32** %9
%23 = load i32*, i32** %9
%24 = icmp eq i32* %23, null
br i1 %24, label %25, label %28
25: ; preds = %13
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
%27 = call i32 @exit(i32 1)
unreachable
28: ; preds = %13
%29 = load i32*, i32** %9
%30 = call i32 @fprintf(i32* %29, i8* getelementptr inbounds ([87 x i8], [87 x i8]* @.str.3, i64 0, i64 0))
%31 = load i32*, i32** %9
%32 = call i32 @fprintf(i32* %31, i8* getelementptr inbounds ([94 x i8], [94 x i8]* @.str.4, i64 0, i64 0))
%33 = load i32*, i32** %9
%34 = call i32 @fclose(i32* %33)
%35 = load i32, i32* %7
%36 = icmp eq i32 %35, 0
br i1 %36, label %37, label %47
37: ; preds = %28
%38 = load i8**, i8*** %5
%39 = getelementptr inbounds i8*, i8** %38, i64 1
%40 = load i8*, i8** %39
%41 = load i32, i32* %6
%42 = load i8**, i8*** %5
%43 = getelementptr inbounds i8*, i8** %42, i64 1
%44 = load i8*, i8** %43
%45 = call i32 @numberOfFiles(i8* %44)
%46 = call i32 @calculateANI(i8* %40, i32 %41, i32 0, i32 %45)
br label %67
47: ; preds = %28
%48 = load i32, i32* %6
store i32 %48, i32* %10
br label %49
49: ; preds = %63, %47
%50 = load i32, i32* %10
%51 = load i32, i32* %7
%52 = icmp sle i32 %50, %51
br i1 %52, label %53, label %66
53: ; preds = %49
%54 = load i8**, i8*** %5
%55 = getelementptr inbounds i8*, i8** %54, i64 1
%56 = load i8*, i8** %55
%57 = load i32, i32* %10
%58 = load i8**, i8*** %5
%59 = getelementptr inbounds i8*, i8** %58, i64 1
%60 = load i8*, i8** %59
%61 = call i32 @numberOfFiles(i8* %60)
%62 = call i32 @calculateANI(i8* %56, i32 %57, i32 0, i32 %61)
br label %63
63: ; preds = %53
%64 = load i32, i32* %10
%65 = add nsw i32 %64, 1
store i32 %65, i32* %10
br label %49
66: ; preds = %49
br label %67
67: ; preds = %66, %37
br label %74
68: ; preds = %2
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([124 x i8], [124 x i8]* @.str.6, i64 0, i64 0))
%70 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([79 x i8], [79 x i8]* @.str.7, i64 0, i64 0))
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.8, i64 0, i64 0))
%72 = load i32, i32* @EXIT_FAILURE
%73 = call i32 @exit(i32 %72)
unreachable
74: ; preds = %67
ret i32 0
}

LLVM IR (-O2):
@.str = [8 x i8] c"ani.txt\00"
@.str.1 = [2 x i8] c"a\00"
@.str.3 = [87 x i8] c"CREATE TABLE anilyze (Genus1, Species1, Genus2, Species2, kmerSize, Percentage real);\0A\00"
@.str.4 = [94 x i8] c"INSERT INTO anilyzeTable (Genus1, Species1, Genus2, Species2, kmerSize, Percentage) \0AVALUES \0A\00"
@.str.5 = [3 x i8] c"%s\00"
@.str.6 = [124 x i8] c"Error, ./anilyzeExeC <User/path/locationOfFormattedFiles> <kmerSizeInteger> <filePercentSimilarityThresholdConstantInteger>\00"
@.str.7 = [79 x i8] c"Example: ./anilyzeExeC /Users/jon/desktop/anilyze/C/tests/sampleTestFiles/ 2 4\00"
@.str.8 = [55 x i8] c"Please ./README for more information on formattedFiles\00"
@EXIT_FAILURE = global i32 0
@str = [22 x i8] c"Error opening ani.txt\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 4
br i1 %3, label %4, label %38
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 2
%6 = load i8*, i8** %5
%7 = tail call i32 @atoi(i8* %6)
%8 = getelementptr inbounds i8*, i8** %1, i64 3
%9 = load i8*, i8** %8
%10 = tail call i32 @atoi(i8* %9)
%11 = tail call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %16
13: ; preds = %4
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
%15 = tail call i32 @exit(i32 1)
unreachable
16: ; preds = %4
%17 = tail call i64 @fwrite(i8* getelementptr inbounds ([87 x i8], [87 x i8]* @.str.3, i64 0, i64 0), i64 86, i64 1, i32* %11)
%18 = tail call i64 @fwrite(i8* getelementptr inbounds ([94 x i8], [94 x i8]* @.str.4, i64 0, i64 0), i64 93, i64 1, i32* %11)
%19 = tail call i32 @fclose(i32* %11)
%20 = icmp eq i32 %10, 0
br i1 %20, label %25, label %21
21: ; preds = %16
%22 = icmp sgt i32 %7, %10
br i1 %22, label %37, label %23
23: ; preds = %21
%24 = getelementptr inbounds i8*, i8** %1, i64 1
br label %30
25: ; preds = %16
%26 = getelementptr inbounds i8*, i8** %1, i64 1
%27 = load i8*, i8** %26
%28 = tail call i32 @numberOfFiles(i8* %27)
%29 = tail call i32 @calculateANI(i8* %27, i32 %7, i32 0, i32 %28)
br label %37
30: ; preds = %23, %30
%31 = phi i32 [ %7, %23 ], [ %35, %30 ]
%32 = load i8*, i8** %24
%33 = tail call i32 @numberOfFiles(i8* %32)
%34 = tail call i32 @calculateANI(i8* %32, i32 %31, i32 0, i32 %33)
%35 = add i32 %31, 1
%36 = icmp eq i32 %31, %10
br i1 %36, label %37, label %30
37: ; preds = %30, %21, %25
ret i32 0
38: ; preds = %2
%39 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([124 x i8], [124 x i8]* @.str.6, i64 0, i64 0))
%40 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([79 x i8], [79 x i8]* @.str.7, i64 0, i64 0))
%41 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.8, i64 0, i64 0))
%42 = load i32, i32* @EXIT_FAILURE
%43 = tail call i32 @exit(i32 %42)
unreachable
}