#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*/ cluster(char *, int);
int /*<<< orphan*/ compute_distances();
int /*<<< orphan*/ load_subsets(char *, char *);
int /*<<< orphan*/ load_vectors(char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, char *, ...);
int /*<<< orphan*/ usage();
int main(int argc, char *argv[]) {
  if (argc < 2)
    usage();
  char *root = argv[1];
  char vecfn[255];
  sprintf(vecfn, "vectors/%s.ds", root);
  printf("vector file '%s'\n", vecfn);
  load_vectors(vecfn);
  compute_distances();
  char outfn[255];
  sprintf(outfn, "results-gonzalez/%s.rank", root);
  cluster(outfn, 0);
  int index = 2;
  while (index < argc) {
    char subsetfn[255];
    sprintf(subsetfn, "vectors/%s", argv[index]);
    printf("subset file '%s'\n", subsetfn);
    char subsetfn2[255];
    sprintf(subsetfn2, "vectors/%s.all", argv[index]);
    printf("subset file '%s'\n", subsetfn2);
    load_subsets(subsetfn, subsetfn2);
    char outfn2[255];
    sprintf(outfn2, "results-gonzalez/%s.%s.rank", root, argv[index]);
    cluster(outfn2, 0);
    sprintf(outfn2, "results-gonzalez/%s.%s.baseline.rank", root, argv[index]);
    cluster(outfn2, 1);
    sprintf(outfn2, "results-gonzalez/%s.%s.best.rank", root, argv[index]);
    cluster(outfn2, 2);
    index++;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x530,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    119a <main+0x2a>
mov    $0x0,%al
call   1070 <usage@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
lea    -0x120(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xe48(%rip),%rsi
mov    $0x0,%al
call   1090 <sprintf@plt>
lea    -0x120(%rbp),%rsi
lea    0xe41(%rip),%rdi
call   1040 <printf@plt>
lea    -0x120(%rbp),%rdi
call   1060 <load_vectors@plt>
mov    $0x0,%al
call   1050 <compute_distances@plt>
lea    -0x220(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xe29(%rip),%rsi
mov    $0x0,%al
call   1090 <sprintf@plt>
lea    -0x220(%rbp),%rdi
xor    %esi,%esi
call   1030 <cluster@plt>
movl   $0x2,-0x224(%rbp)
mov    -0x224(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1362 <main+0x1f2>
lea    -0x330(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x224(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xdf7(%rip),%rsi
mov    $0x0,%al
call   1090 <sprintf@plt>
lea    -0x330(%rbp),%rsi
lea    0xded(%rip),%rdi
call   1040 <printf@plt>
lea    -0x430(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x224(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xddd(%rip),%rsi
mov    $0x0,%al
call   1090 <sprintf@plt>
lea    -0x430(%rbp),%rsi
lea    0xdb6(%rip),%rdi
call   1040 <printf@plt>
lea    -0x330(%rbp),%rdi
lea    -0x430(%rbp),%rsi
call   1080 <load_subsets@plt>
lea    -0x530(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x10(%rbp),%rax
movslq -0x224(%rbp),%rcx
mov    (%rax,%rcx,8),%rcx
lea    0xd9e(%rip),%rsi
mov    $0x0,%al
call   1090 <sprintf@plt>
lea    -0x530(%rbp),%rdi
xor    %esi,%esi
call   1030 <cluster@plt>
lea    -0x530(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x10(%rbp),%rax
movslq -0x224(%rbp),%rcx
mov    (%rax,%rcx,8),%rcx
lea    0xd84(%rip),%rsi
mov    $0x0,%al
call   1090 <sprintf@plt>
lea    -0x530(%rbp),%rdi
mov    $0x1,%esi
call   1030 <cluster@plt>
lea    -0x530(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x10(%rbp),%rax
movslq -0x224(%rbp),%rcx
mov    (%rax,%rcx,8),%rcx
lea    0xd70(%rip),%rsi
mov    $0x0,%al
call   1090 <sprintf@plt>
lea    -0x530(%rbp),%rdi
mov    $0x2,%esi
call   1030 <cluster@plt>
mov    -0x224(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x224(%rbp)
jmp    1216 <main+0xa6>
xor    %eax,%eax
add    $0x530,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x518,%rsp
mov    %rsi,%r12
mov    %edi,%r15d
cmp    $0x1,%edi
jg     1193 <main+0x23>
xor    %eax,%eax
call   1070 <usage@plt>
mov    0x8(%r12),%rbp
lea    0xe61(%rip),%rsi
lea    0x410(%rsp),%r14
mov    %r14,%rdi
mov    %rbp,%rdx
xor    %eax,%eax
call   1090 <sprintf@plt>
lea    0xe53(%rip),%rdi
mov    %r14,%rsi
call   1040 <printf@plt>
mov    %r14,%rdi
call   1060 <load_vectors@plt>
xor    %eax,%eax
call   1050 <compute_distances@plt>
lea    0xe47(%rip),%rsi
lea    0x310(%rsp),%r14
mov    %r14,%rdi
mov    %rbp,%rdx
xor    %eax,%eax
call   1090 <sprintf@plt>
mov    %r14,%rdi
xor    %esi,%esi
call   1030 <cluster@plt>
cmp    $0x3,%r15d
jl     12f8 <main+0x188>
mov    %r15d,%eax
mov    %rax,0x8(%rsp)
mov    $0x2,%r13d
mov    (%r12,%r13,8),%rdx
lea    0x210(%rsp),%r15
mov    %r15,%rdi
lea    0xe13(%rip),%rsi
xor    %eax,%eax
call   1090 <sprintf@plt>
mov    %r12,%rbx
lea    0xe0d(%rip),%r12
mov    %r12,%rdi
mov    %r15,%rsi
call   1040 <printf@plt>
mov    (%rbx,%r13,8),%rdx
lea    0x110(%rsp),%r14
mov    %r14,%rdi
lea    0xdfe(%rip),%rsi
xor    %eax,%eax
call   1090 <sprintf@plt>
mov    %r12,%rdi
mov    %rbx,%r12
mov    %r14,%rsi
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %r14,%rsi
call   1080 <load_subsets@plt>
mov    (%rbx,%r13,8),%rcx
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
lea    0xdda(%rip),%rsi
mov    %rbp,%rdx
xor    %eax,%eax
call   1090 <sprintf@plt>
mov    %rbx,%rdi
xor    %esi,%esi
call   1030 <cluster@plt>
mov    (%r12,%r13,8),%rcx
mov    %rbx,%rdi
lea    0xdd4(%rip),%rsi
mov    %rbp,%rdx
xor    %eax,%eax
call   1090 <sprintf@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
call   1030 <cluster@plt>
mov    (%r12,%r13,8),%rcx
mov    %rbx,%rdi
lea    0xdd4(%rip),%rsi
mov    %rbp,%rdx
xor    %eax,%eax
call   1090 <sprintf@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
call   1030 <cluster@plt>
add    $0x1,%r13
cmp    %r13,0x8(%rsp)
jne    1210 <main+0xa0>
xor    %eax,%eax
add    $0x518,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [14 x i8] c"vectors/%s.ds\00"
@.str.1 = [18 x i8] c"vector file '%s'\0A\00"
@.str.2 = [25 x i8] c"results-gonzalez/%s.rank\00"
@.str.3 = [11 x i8] c"vectors/%s\00"
@.str.4 = [18 x i8] c"subset file '%s'\0A\00"
@.str.5 = [15 x i8] c"vectors/%s.all\00"
@.str.6 = [28 x i8] c"results-gonzalez/%s.%s.rank\00"
@.str.7 = [37 x i8] c"results-gonzalez/%s.%s.baseline.rank\00"
@.str.8 = [33 x i8] c"results-gonzalez/%s.%s.best.rank\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca [255 x i8]
%8 = alloca [255 x i8]
%9 = alloca i32
%10 = alloca [255 x i8]
%11 = alloca [255 x i8]
%12 = alloca [255 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = load i32, i32* %4
%14 = icmp slt i32 %13, 2
br i1 %14, label %15, label %17
15: ; preds = %2
%16 = call i32 (...) @usage()
br label %17
17: ; preds = %15, %2
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
store i8* %20, i8** %6
%21 = getelementptr inbounds [255 x i8], [255 x i8]* %7, i64 0, i64 0
%22 = load i8*, i8** %6
%23 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %21, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %22)
%24 = getelementptr inbounds [255 x i8], [255 x i8]* %7, i64 0, i64 0
%25 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %24)
%26 = getelementptr inbounds [255 x i8], [255 x i8]* %7, i64 0, i64 0
%27 = call i32 @load_vectors(i8* %26)
%28 = call i32 (...) @compute_distances()
%29 = getelementptr inbounds [255 x i8], [255 x i8]* %8, i64 0, i64 0
%30 = load i8*, i8** %6
%31 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %29, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i8* %30)
%32 = getelementptr inbounds [255 x i8], [255 x i8]* %8, i64 0, i64 0
%33 = call i32 @cluster(i8* %32, i32 0)
store i32 2, i32* %9
br label %34
34: ; preds = %38, %17
%35 = load i32, i32* %9
%36 = load i32, i32* %4
%37 = icmp slt i32 %35, %36
br i1 %37, label %38, label %92
38: ; preds = %34
%39 = getelementptr inbounds [255 x i8], [255 x i8]* %10, i64 0, i64 0
%40 = load i8**, i8*** %5
%41 = load i32, i32* %9
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i8*, i8** %40, i64 %42
%44 = load i8*, i8** %43
%45 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %39, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* %44)
%46 = getelementptr inbounds [255 x i8], [255 x i8]* %10, i64 0, i64 0
%47 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), i8* %46)
%48 = getelementptr inbounds [255 x i8], [255 x i8]* %11, i64 0, i64 0
%49 = load i8**, i8*** %5
%50 = load i32, i32* %9
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds i8*, i8** %49, i64 %51
%53 = load i8*, i8** %52
%54 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %48, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i8* %53)
%55 = getelementptr inbounds [255 x i8], [255 x i8]* %11, i64 0, i64 0
%56 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), i8* %55)
%57 = getelementptr inbounds [255 x i8], [255 x i8]* %10, i64 0, i64 0
%58 = getelementptr inbounds [255 x i8], [255 x i8]* %11, i64 0, i64 0
%59 = call i32 @load_subsets(i8* %57, i8* %58)
%60 = getelementptr inbounds [255 x i8], [255 x i8]* %12, i64 0, i64 0
%61 = load i8*, i8** %6
%62 = load i8**, i8*** %5
%63 = load i32, i32* %9
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds i8*, i8** %62, i64 %64
%66 = load i8*, i8** %65
%67 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %60, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0), i8* %61, i8* %66)
%68 = getelementptr inbounds [255 x i8], [255 x i8]* %12, i64 0, i64 0
%69 = call i32 @cluster(i8* %68, i32 0)
%70 = getelementptr inbounds [255 x i8], [255 x i8]* %12, i64 0, i64 0
%71 = load i8*, i8** %6
%72 = load i8**, i8*** %5
%73 = load i32, i32* %9
%74 = sext i32 %73 to i64
%75 = getelementptr inbounds i8*, i8** %72, i64 %74
%76 = load i8*, i8** %75
%77 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %70, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.7, i64 0, i64 0), i8* %71, i8* %76)
%78 = getelementptr inbounds [255 x i8], [255 x i8]* %12, i64 0, i64 0
%79 = call i32 @cluster(i8* %78, i32 1)
%80 = getelementptr inbounds [255 x i8], [255 x i8]* %12, i64 0, i64 0
%81 = load i8*, i8** %6
%82 = load i8**, i8*** %5
%83 = load i32, i32* %9
%84 = sext i32 %83 to i64
%85 = getelementptr inbounds i8*, i8** %82, i64 %84
%86 = load i8*, i8** %85
%87 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %80, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.8, i64 0, i64 0), i8* %81, i8* %86)
%88 = getelementptr inbounds [255 x i8], [255 x i8]* %12, i64 0, i64 0
%89 = call i32 @cluster(i8* %88, i32 2)
%90 = load i32, i32* %9
%91 = add nsw i32 %90, 1
store i32 %91, i32* %9
br label %34
92: ; preds = %34
ret i32 0
}

LLVM IR (-O2):
@.str = [14 x i8] c"vectors/%s.ds\00"
@.str.1 = [18 x i8] c"vector file '%s'\0A\00"
@.str.2 = [25 x i8] c"results-gonzalez/%s.rank\00"
@.str.3 = [11 x i8] c"vectors/%s\00"
@.str.4 = [18 x i8] c"subset file '%s'\0A\00"
@.str.5 = [15 x i8] c"vectors/%s.all\00"
@.str.6 = [28 x i8] c"results-gonzalez/%s.%s.rank\00"
@.str.7 = [37 x i8] c"results-gonzalez/%s.%s.baseline.rank\00"
@.str.8 = [33 x i8] c"results-gonzalez/%s.%s.best.rank\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [255 x i8]
%4 = alloca [255 x i8]
%5 = alloca [255 x i8]
%6 = alloca [255 x i8]
%7 = alloca [255 x i8]
%8 = icmp slt i32 %0, 2
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = tail call i32 (...) @usage()
br label %11
11: ; preds = %9, %2
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 0
%15 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %14, i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %13)
%16 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %14)
%17 = call i32 @load_vectors(i8* %14)
%18 = call i32 (...) @compute_distances()
%19 = getelementptr inbounds [255 x i8], [255 x i8]* %4, i64 0, i64 0
%20 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %19, i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i8* %13)
%21 = call i32 @cluster(i8* %19, i32 0)
%22 = icmp sgt i32 %0, 2
br i1 %22, label %23, label %49
23: ; preds = %11
%24 = getelementptr inbounds [255 x i8], [255 x i8]* %5, i64 0, i64 0
%25 = getelementptr inbounds [255 x i8], [255 x i8]* %6, i64 0, i64 0
%26 = getelementptr inbounds [255 x i8], [255 x i8]* %7, i64 0, i64 0
%27 = zext i32 %0 to i64
br label %28
28: ; preds = %23, %28
%29 = phi i64 [ 2, %23 ], [ %47, %28 ]
%30 = getelementptr inbounds i8*, i8** %1, i64 %29
%31 = load i8*, i8** %30
%32 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %24, i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* %31)
%33 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), i8* %24)
%34 = load i8*, i8** %30
%35 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %25, i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i8* %34)
%36 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), i8* %25)
%37 = call i32 @load_subsets(i8* %24, i8* %25)
%38 = load i8*, i8** %30
%39 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %26, i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0), i8* %13, i8* %38)
%40 = call i32 @cluster(i8* %26, i32 0)
%41 = load i8*, i8** %30
%42 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %26, i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.7, i64 0, i64 0), i8* %13, i8* %41)
%43 = call i32 @cluster(i8* %26, i32 1)
%44 = load i8*, i8** %30
%45 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %26, i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.8, i64 0, i64 0), i8* %13, i8* %44)
%46 = call i32 @cluster(i8* %26, i32 2)
%47 = add nuw nsw i64 %29, 1
%48 = icmp eq i64 %47, %27
br i1 %48, label %49, label %28
49: ; preds = %28, %11
ret i32 0
}