#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*/ HierarchicalCluster(int /*<<< orphan*/ *, char, int, char);
int /*<<< orphan*/ Save(int /*<<< orphan*/ *, int, int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *const, char *);
int /*<<< orphan*/ free(char *const);
char *malloc(int const);
int /*<<< orphan*/ printf(char *, char *const);
int /*<<< orphan*/ sprintf(char *const, char *, char *);
int strlen(char *);
void Hierarchical(char genemetric, char arraymetric, char method,
                  char *jobname) {
  FILE *outputfile;
  const int n = strlen(jobname) + strlen(".ext") + 1;
  char *const filename = malloc(n * sizeof(char));
  if (genemetric) {
    sprintf(filename, "%s.gtr", jobname);
    outputfile = fopen(filename, "wt");
    if (!outputfile)
      printf("Failed opening output file %s\n", filename);
    else {
      HierarchicalCluster(outputfile, genemetric, 0, method);
      fclose(outputfile);
    }
  }
  if (arraymetric) {
    sprintf(filename, "%s.atr", jobname);
    outputfile = fopen(filename, "wt");
    if (!outputfile)
      printf("Failed opening output file %s\n", filename);
    else {
      HierarchicalCluster(outputfile, arraymetric, 1, method);
      fclose(outputfile);
    }
  }
  sprintf(filename, "%s.cdt", jobname);
  outputfile = fopen(filename, "wt");
  if (!outputfile)
    printf("Failed opening output file %s\n", filename);
  else {
    Save(outputfile, genemetric != '\0', arraymetric != '\0');
    fclose(outputfile);
  }
  free(filename);
  return;
}


x86 assembly (clang, -O0):
<Hierarchical>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %dl,%al
mov    %sil,%dl
mov    %dil,%sil
mov    %sil,-0x1(%rbp)
mov    %dl,-0x2(%rbp)
mov    %al,-0x3(%rbp)
mov    %rcx,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x2c(%rbp)
lea    0xe3f(%rip),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
add    %ecx,%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
movslq -0x1c(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   1080 <malloc@plt>
mov    %rax,-0x28(%rbp)
cmpb   $0x0,-0x1(%rbp)
je     125b <Hierarchical+0xcb>
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xe06(%rip),%rsi
call   10a0 <sprintf@plt>
mov    -0x28(%rbp),%rdi
lea    0xdfd(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1238 <Hierarchical+0xa8>
mov    -0x28(%rbp),%rsi
lea    0xde1(%rip),%rdi
call   1060 <printf@plt>
jmp    1256 <Hierarchical+0xc6>
mov    -0x18(%rbp),%rdi
mov    -0x1(%rbp),%al
xor    %edx,%edx
movsbl %al,%esi
movsbl -0x3(%rbp),%ecx
call   1070 <HierarchicalCluster@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
jmp    125b <Hierarchical+0xcb>
cmpb   $0x0,-0x2(%rbp)
je     12d3 <Hierarchical+0x143>
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xdba(%rip),%rsi
call   10a0 <sprintf@plt>
mov    -0x28(%rbp),%rdi
lea    0xd88(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    12ad <Hierarchical+0x11d>
mov    -0x28(%rbp),%rsi
lea    0xd6c(%rip),%rdi
call   1060 <printf@plt>
jmp    12ce <Hierarchical+0x13e>
mov    -0x18(%rbp),%rdi
mov    -0x2(%rbp),%al
mov    $0x1,%edx
movsbl %al,%esi
movsbl -0x3(%rbp),%ecx
call   1070 <HierarchicalCluster@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
jmp    12d3 <Hierarchical+0x143>
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xd53(%rip),%rsi
call   10a0 <sprintf@plt>
mov    -0x28(%rbp),%rdi
lea    0xd1a(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    131b <Hierarchical+0x18b>
mov    -0x28(%rbp),%rsi
lea    0xcfe(%rip),%rdi
call   1060 <printf@plt>
jmp    134b <Hierarchical+0x1bb>
mov    -0x18(%rbp),%rdi
movsbl -0x1(%rbp),%eax
cmp    $0x0,%eax
setne  %al
and    $0x1,%al
movzbl %al,%esi
movsbl -0x2(%rbp),%eax
cmp    $0x0,%eax
setne  %al
and    $0x1,%al
movzbl %al,%edx
call   10b0 <Save@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Hierarchical>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r13
mov    %edx,%r12d
mov    %esi,%r14d
mov    %edi,%r15d
mov    %rcx,%rdi
call   1050 <strlen@plt>
mov    %eax,%ebx
lea    0xe48(%rip),%rdi
call   1050 <strlen@plt>
lea    (%rbx,%rax,1),%edi
add    $0x1,%edi
call   1080 <malloc@plt>
mov    %rax,%rbx
test   %r15b,%r15b
je     1213 <Hierarchical+0x83>
lea    0xe2e(%rip),%rsi
mov    %rbx,%rdi
mov    %r13,%rdx
call   10a0 <sprintf@plt>
lea    0xe23(%rip),%rsi
mov    %rbx,%rdi
call   1090 <fopen@plt>
test   %rax,%rax
je     1260 <Hierarchical+0xd0>
mov    %rax,%rbp
movsbl %r15b,%esi
movsbl %r12b,%ecx
mov    %rax,%rdi
xor    %edx,%edx
call   1070 <HierarchicalCluster@plt>
mov    %rbp,%rdi
call   1040 <fclose@plt>
test   %r14b,%r14b
je     1285 <Hierarchical+0xf5>
lea    0xe0f(%rip),%rsi
mov    %rbx,%rdi
mov    %r13,%rdx
call   10a0 <sprintf@plt>
lea    0xddb(%rip),%rsi
mov    %rbx,%rdi
call   1090 <fopen@plt>
test   %rax,%rax
je     1276 <Hierarchical+0xe6>
mov    %rax,%rbp
movsbl %r14b,%esi
movsbl %r12b,%ecx
mov    %rax,%rdi
mov    $0x1,%edx
call   1070 <HierarchicalCluster@plt>
mov    %rbp,%rdi
call   1040 <fclose@plt>
jmp    1285 <Hierarchical+0xf5>
lea    0xda8(%rip),%rdi
mov    %rbx,%rsi
call   1060 <printf@plt>
test   %r14b,%r14b
jne    1218 <Hierarchical+0x88>
jmp    1285 <Hierarchical+0xf5>
lea    0xd92(%rip),%rdi
mov    %rbx,%rsi
call   1060 <printf@plt>
lea    0xda9(%rip),%rsi
mov    %rbx,%rdi
mov    %r13,%rdx
call   10a0 <sprintf@plt>
lea    0xd6e(%rip),%rsi
mov    %rbx,%rdi
call   1090 <fopen@plt>
test   %rax,%rax
je     12d1 <Hierarchical+0x141>
mov    %rax,%rbp
xor    %esi,%esi
test   %r15b,%r15b
setne  %sil
xor    %edx,%edx
test   %r14b,%r14b
setne  %dl
mov    %rax,%rdi
call   10b0 <Save@plt>
mov    %rbp,%rdi
call   1040 <fclose@plt>
jmp    12e0 <Hierarchical+0x150>
lea    0xd37(%rip),%rdi
mov    %rbx,%rsi
call   1060 <printf@plt>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>

LLVM IR (-O0):
@.str = [5 x i8] c".ext\00"
@.str.1 = [7 x i8] c"%s.gtr\00"
@.str.2 = [3 x i8] c"wt\00"
@.str.3 = [31 x i8] c"Failed opening output file %s\0A\00"
@.str.4 = [7 x i8] c"%s.atr\00"
@.str.5 = [7 x i8] c"%s.cdt\00"
define void @Hierarchical(i8 signext %0, i8 signext %1, i8 signext %2, i8* %3) {
%5 = alloca i8
%6 = alloca i8
%7 = alloca i8
%8 = alloca i8*
%9 = alloca i32*
%10 = alloca i32
%11 = alloca i8*
store i8 %0, i8* %5
store i8 %1, i8* %6
store i8 %2, i8* %7
store i8* %3, i8** %8
%12 = load i8*, i8** %8
%13 = call i32 @strlen(i8* %12)
%14 = call i32 @strlen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%15 = add nsw i32 %13, %14
%16 = add nsw i32 %15, 1
store i32 %16, i32* %10
%17 = load i32, i32* %10
%18 = sext i32 %17 to i64
%19 = mul i64 %18, 1
%20 = trunc i64 %19 to i32
%21 = call i8* @malloc(i32 %20)
store i8* %21, i8** %11
%22 = load i8, i8* %5
%23 = icmp ne i8 %22, 0
br i1 %23, label %24, label %43
24: ; preds = %4
%25 = load i8*, i8** %11
%26 = load i8*, i8** %8
%27 = call i32 @sprintf(i8* %25, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %26)
%28 = load i8*, i8** %11
%29 = call i32* @fopen(i8* %28, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i32* %29, i32** %9
%30 = load i32*, i32** %9
%31 = icmp ne i32* %30, null
br i1 %31, label %35, label %32
32: ; preds = %24
%33 = load i8*, i8** %11
%34 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i8* %33)
br label %42
35: ; preds = %24
%36 = load i32*, i32** %9
%37 = load i8, i8* %5
%38 = load i8, i8* %7
%39 = call i32 @HierarchicalCluster(i32* %36, i8 signext %37, i32 0, i8 signext %38)
%40 = load i32*, i32** %9
%41 = call i32 @fclose(i32* %40)
br label %42
42: ; preds = %35, %32
br label %43
43: ; preds = %42, %4
%44 = load i8, i8* %6
%45 = icmp ne i8 %44, 0
br i1 %45, label %46, label %65
46: ; preds = %43
%47 = load i8*, i8** %11
%48 = load i8*, i8** %8
%49 = call i32 @sprintf(i8* %47, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i8* %48)
%50 = load i8*, i8** %11
%51 = call i32* @fopen(i8* %50, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i32* %51, i32** %9
%52 = load i32*, i32** %9
%53 = icmp ne i32* %52, null
br i1 %53, label %57, label %54
54: ; preds = %46
%55 = load i8*, i8** %11
%56 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i8* %55)
br label %64
57: ; preds = %46
%58 = load i32*, i32** %9
%59 = load i8, i8* %6
%60 = load i8, i8* %7
%61 = call i32 @HierarchicalCluster(i32* %58, i8 signext %59, i32 1, i8 signext %60)
%62 = load i32*, i32** %9
%63 = call i32 @fclose(i32* %62)
br label %64
64: ; preds = %57, %54
br label %65
65: ; preds = %64, %43
%66 = load i8*, i8** %11
%67 = load i8*, i8** %8
%68 = call i32 @sprintf(i8* %66, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i8* %67)
%69 = load i8*, i8** %11
%70 = call i32* @fopen(i8* %69, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i32* %70, i32** %9
%71 = load i32*, i32** %9
%72 = icmp ne i32* %71, null
br i1 %72, label %76, label %73
73: ; preds = %65
%74 = load i8*, i8** %11
%75 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i8* %74)
br label %89
76: ; preds = %65
%77 = load i32*, i32** %9
%78 = load i8, i8* %5
%79 = sext i8 %78 to i32
%80 = icmp ne i32 %79, 0
%81 = zext i1 %80 to i32
%82 = load i8, i8* %6
%83 = sext i8 %82 to i32
%84 = icmp ne i32 %83, 0
%85 = zext i1 %84 to i32
%86 = call i32 @Save(i32* %77, i32 %81, i32 %85)
%87 = load i32*, i32** %9
%88 = call i32 @fclose(i32* %87)
br label %89
89: ; preds = %76, %73
%90 = load i8*, i8** %11
%91 = call i32 @free(i8* %90)
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c".ext\00"
@.str.1 = [7 x i8] c"%s.gtr\00"
@.str.2 = [3 x i8] c"wt\00"
@.str.3 = [31 x i8] c"Failed opening output file %s\0A\00"
@.str.4 = [7 x i8] c"%s.atr\00"
@.str.5 = [7 x i8] c"%s.cdt\00"
define void @Hierarchical(i8 signext %0, i8 signext %1, i8 signext %2, i8* %3) {
%5 = tail call i32 @strlen(i8* %3)
%6 = tail call i32 @strlen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%7 = add i32 %5, 1
%8 = add i32 %7, %6
%9 = tail call i8* @malloc(i32 %8)
%10 = icmp eq i8 %0, 0
br i1 %10, label %20, label %11
11: ; preds = %4
%12 = tail call i32 @sprintf(i8* dereferenceable(1) %9, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%13 = tail call i32* @fopen(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%14 = icmp eq i32* %13, null
br i1 %14, label %15, label %17
15: ; preds = %11
%16 = tail call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i8* %9)
br label %20
17: ; preds = %11
%18 = tail call i32 @HierarchicalCluster(i32* %13, i8 signext %0, i32 0, i8 signext %2)
%19 = tail call i32 @fclose(i32* %13)
br label %20
20: ; preds = %15, %17, %4
%21 = icmp eq i8 %1, 0
br i1 %21, label %31, label %22
22: ; preds = %20
%23 = tail call i32 @sprintf(i8* dereferenceable(1) %9, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i8* %3)
%24 = tail call i32* @fopen(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%25 = icmp eq i32* %24, null
br i1 %25, label %26, label %28
26: ; preds = %22
%27 = tail call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i8* %9)
br label %31
28: ; preds = %22
%29 = tail call i32 @HierarchicalCluster(i32* %24, i8 signext %1, i32 1, i8 signext %2)
%30 = tail call i32 @fclose(i32* %24)
br label %31
31: ; preds = %26, %28, %20
%32 = tail call i32 @sprintf(i8* dereferenceable(1) %9, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i8* %3)
%33 = tail call i32* @fopen(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%34 = icmp eq i32* %33, null
br i1 %34, label %35, label %37
35: ; preds = %31
%36 = tail call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i8* %9)
br label %44
37: ; preds = %31
%38 = icmp ne i8 %0, 0
%39 = zext i1 %38 to i32
%40 = icmp ne i8 %1, 0
%41 = zext i1 %40 to i32
%42 = tail call i32 @Save(i32* %33, i32 %39, i32 %41)
%43 = tail call i32 @fclose(i32* %33)
br label %44
44: ; preds = %37, %35
%45 = tail call i32 @free(i8* %9)
ret void
}