#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 expectedProtSimScore(double *, double **, int);
int /*<<< orphan*/ free(double *);
scalar_t__ mCalloc(int, int);
int /*<<< orphan*/ memset(double *, int /*<<< orphan*/, unsigned long);
double scoreDistij(int, int, char *, char *, int, double, double *, double **,
                   char *, int);
double simScore(char *, char *, double **, int, char *, int);
void scoreDist(double *P, char **data, int numSpecies, int seqLength,
               double **scoreMatrix, double **D, char *alphabet,
               int alphabetSize) {
  int i, j;
  double simExp;
  double *simDiags;
  simDiags = (double *)mCalloc(numSpecies, sizeof(double));
  memset(simDiags, 0, (unsigned long)numSpecies * sizeof(double));
  simExp = seqLength * expectedProtSimScore(P, scoreMatrix, alphabetSize);
  for (i = 0; i < numSpecies; i++) {
    D[i] = (double *)mCalloc(numSpecies, sizeof(double));
    D[i][i] = 0.0;
    simDiags[i] = simScore(data[i], data[i], scoreMatrix, seqLength, alphabet,
                           alphabetSize);
  }
  for (i = 0; i < numSpecies - 1; i++) {
    for (j = i + 1; j < numSpecies; j++)
      D[i][j] = D[j][i] =
          scoreDistij(i, j, data[i], data[j], seqLength, simExp, simDiags,
                      scoreMatrix, alphabet, alphabetSize);
  }
  free(simDiags);
  return;
}


x86 assembly (clang, -O0):
<scoreDist>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    0x18(%rbp),%eax
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
mov    %r9,-0x28(%rbp)
mov    -0x14(%rbp),%edi
mov    $0x8,%esi
call   1070 <mCalloc@plt>
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rdi
movslq -0x14(%rbp),%rdx
shl    $0x3,%rdx
xor    %esi,%esi
call   1060 <memset@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x44(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    0x18(%rbp),%edx
call   1050 <expectedProtSimScore@plt>
mov    %eax,%ecx
mov    -0x44(%rbp),%eax
imul   %ecx,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x38(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    125e <scoreDist+0xfe>
mov    -0x14(%rbp),%edi
mov    $0x8,%esi
call   1070 <mCalloc@plt>
mov    %rax,%rdx
mov    -0x28(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x28(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x2c(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x18(%rbp),%ecx
mov    0x10(%rbp),%r8
mov    0x18(%rbp),%r9d
call   1080 <simScore@plt>
mov    -0x40(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11d7 <scoreDist+0x77>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    131e <scoreDist+0x1be>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    130b <scoreDist+0x1ab>
mov    -0x2c(%rbp),%edi
mov    -0x30(%rbp),%esi
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
mov    -0x10(%rbp),%rax
movslq -0x30(%rbp),%rcx
mov    (%rax,%rcx,8),%rcx
mov    -0x18(%rbp),%r8d
movsd  -0x38(%rbp),%xmm0
mov    -0x40(%rbp),%r9
mov    -0x20(%rbp),%r11
mov    0x10(%rbp),%r10
mov    0x18(%rbp),%eax
mov    %r11,(%rsp)
mov    %r10,0x8(%rsp)
mov    %eax,0x10(%rsp)
call   1030 <scoreDistij@plt>
mov    -0x28(%rbp),%rax
movslq -0x30(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x2c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x28(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x30(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    127f <scoreDist+0x11f>
jmp    1310 <scoreDist+0x1b0>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1265 <scoreDist+0x105>
mov    -0x40(%rbp),%rdi
call   1040 <free@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<scoreDist>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
mov    %r9,0x38(%rsp)
mov    %r8,%r15
mov    %ecx,0x4(%rsp)
mov    %edx,%r13d
mov    %rsi,0x10(%rsp)
mov    %rdi,%r12
mov    0xa8(%rsp),%ebx
mov    0xa0(%rsp),%rax
mov    %rax,0x20(%rsp)
mov    %edx,%edi
mov    $0x8,%esi
call   1070 <mCalloc@plt>
movslq %r13d,%rbp
lea    0x0(,%rbp,8),%rdx
mov    %rax,0x8(%rsp)
mov    %rax,%rdi
xor    %esi,%esi
call   1060 <memset@plt>
mov    %r12,%rdi
mov    %r15,%rsi
mov    %rbx,0x30(%rsp)
mov    %ebx,%edx
call   1050 <expectedProtSimScore@plt>
mov    %rbp,0x50(%rsp)
test   %ebp,%ebp
jle    132e <scoreDist+0x1ce>
imul   0x4(%rsp),%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,0x60(%rsp)
mov    %r13d,%eax
mov    %r15,0x18(%rsp)
xor    %ebx,%ebx
mov    0x20(%rsp),%r12
mov    0x38(%rsp),%r14
mov    0x10(%rsp),%rbp
mov    0x8(%rsp),%r15
mov    %rax,0x40(%rsp)
mov    %r13d,%edi
mov    $0x8,%esi
call   1070 <mCalloc@plt>
mov    %rax,(%r14,%rbx,8)
movq   $0x0,(%rax,%rbx,8)
mov    0x0(%rbp,%rbx,8),%rdi
mov    %rdi,%rsi
mov    0x18(%rsp),%rdx
mov    0x4(%rsp),%ecx
mov    %r12,%r8
mov    0x30(%rsp),%r9
call   1080 <simScore@plt>
mov    0x40(%rsp),%rax
movsd  %xmm0,(%r15,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%rax
jne    1210 <scoreDist+0xb0>
cmp    $0x2,%r13d
mov    0x18(%rsp),%rax
jl     132e <scoreDist+0x1ce>
add    $0xffffffff,%r13d
mov    $0x1,%ecx
mov    %rcx,0x28(%rsp)
xor    %r12d,%r12d
mov    %r13,0x48(%rsp)
mov    0x4(%rsp),%ebx
mov    0x30(%rsp),%rbp
mov    0x20(%rsp),%r15
mov    0x8(%rsp),%r14
jmp    12b5 <scoreDist+0x155>
cs nopw 0x0(%rax,%rax,1)
nop
addq   $0x1,0x28(%rsp)
mov    0x48(%rsp),%r13
mov    0x58(%rsp),%r12
cmp    %r13,%r12
je     132e <scoreDist+0x1ce>
lea    0x1(%r12),%rcx
mov    %rcx,0x58(%rsp)
cmp    0x50(%rsp),%rcx
mov    0x10(%rsp),%rsi
jge    12a0 <scoreDist+0x140>
mov    0x28(%rsp),%r13
mov    (%rsi,%r12,8),%rdx
mov    (%rsi,%r13,8),%rcx
sub    $0x8,%rsp
mov    %r12d,%edi
mov    %r13d,%esi
mov    %ebx,%r8d
movsd  0x68(%rsp),%xmm0
mov    %r14,%r9
push   %rbp
push   %r15
push   %rax
call   1030 <scoreDistij@plt>
mov    0x30(%rsp),%rsi
mov    0x58(%rsp),%rcx
add    $0x20,%rsp
mov    (%rcx,%r13,8),%rax
movsd  %xmm0,(%rax,%r12,8)
mov    (%rcx,%r12,8),%rax
movsd  %xmm0,(%rax,%r13,8)
mov    0x18(%rsp),%rax
add    $0x1,%r13
cmp    %r13,0x40(%rsp)
jne    12d0 <scoreDist+0x170>
jmp    12a0 <scoreDist+0x140>
mov    0x8(%rsp),%rdi
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <free@plt>

LLVM IR (-O0):
define void @scoreDist(double* %0, i8** %1, i32 %2, i32 %3, double** %4, double** %5, i8* %6, i32 %7) {
%9 = alloca double*
%10 = alloca i8**
%11 = alloca i32
%12 = alloca i32
%13 = alloca double**
%14 = alloca double**
%15 = alloca i8*
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca double
%20 = alloca double*
store double* %0, double** %9
store i8** %1, i8*** %10
store i32 %2, i32* %11
store i32 %3, i32* %12
store double** %4, double*** %13
store double** %5, double*** %14
store i8* %6, i8** %15
store i32 %7, i32* %16
%21 = load i32, i32* %11
%22 = call i64 @mCalloc(i32 %21, i32 8)
%23 = inttoptr i64 %22 to double*
store double* %23, double** %20
%24 = load double*, double** %20
%25 = load i32, i32* %11
%26 = sext i32 %25 to i64
%27 = mul i64 %26, 8
%28 = call i32 @memset(double* %24, i32 0, i64 %27)
%29 = load i32, i32* %12
%30 = load double*, double** %9
%31 = load double**, double*** %13
%32 = load i32, i32* %16
%33 = call i32 @expectedProtSimScore(double* %30, double** %31, i32 %32)
%34 = mul nsw i32 %29, %33
%35 = sitofp i32 %34 to double
store double %35, double* %19
store i32 0, i32* %17
br label %36
36: ; preds = %75, %8
%37 = load i32, i32* %17
%38 = load i32, i32* %11
%39 = icmp slt i32 %37, %38
br i1 %39, label %40, label %78
40: ; preds = %36
%41 = load i32, i32* %11
%42 = call i64 @mCalloc(i32 %41, i32 8)
%43 = inttoptr i64 %42 to double*
%44 = load double**, double*** %14
%45 = load i32, i32* %17
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds double*, double** %44, i64 %46
store double* %43, double** %47
%48 = load double**, double*** %14
%49 = load i32, i32* %17
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds double*, double** %48, i64 %50
%52 = load double*, double** %51
%53 = load i32, i32* %17
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds double, double* %52, i64 %54
store double 0.000000e+00, double* %55
%56 = load i8**, i8*** %10
%57 = load i32, i32* %17
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds i8*, i8** %56, i64 %58
%60 = load i8*, i8** %59
%61 = load i8**, i8*** %10
%62 = load i32, i32* %17
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds i8*, i8** %61, i64 %63
%65 = load i8*, i8** %64
%66 = load double**, double*** %13
%67 = load i32, i32* %12
%68 = load i8*, i8** %15
%69 = load i32, i32* %16
%70 = call double @simScore(i8* %60, i8* %65, double** %66, i32 %67, i8* %68, i32 %69)
%71 = load double*, double** %20
%72 = load i32, i32* %17
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds double, double* %71, i64 %73
store double %70, double* %74
br label %75
75: ; preds = %40
%76 = load i32, i32* %17
%77 = add nsw i32 %76, 1
store i32 %77, i32* %17
br label %36
78: ; preds = %36
store i32 0, i32* %17
br label %79
79: ; preds = %131, %78
%80 = load i32, i32* %17
%81 = load i32, i32* %11
%82 = sub nsw i32 %81, 1
%83 = icmp slt i32 %80, %82
br i1 %83, label %84, label %134
84: ; preds = %79
%85 = load i32, i32* %17
%86 = add nsw i32 %85, 1
store i32 %86, i32* %18
br label %87
87: ; preds = %127, %84
%88 = load i32, i32* %18
%89 = load i32, i32* %11
%90 = icmp slt i32 %88, %89
br i1 %90, label %91, label %130
91: ; preds = %87
%92 = load i32, i32* %17
%93 = load i32, i32* %18
%94 = load i8**, i8*** %10
%95 = load i32, i32* %17
%96 = sext i32 %95 to i64
%97 = getelementptr inbounds i8*, i8** %94, i64 %96
%98 = load i8*, i8** %97
%99 = load i8**, i8*** %10
%100 = load i32, i32* %18
%101 = sext i32 %100 to i64
%102 = getelementptr inbounds i8*, i8** %99, i64 %101
%103 = load i8*, i8** %102
%104 = load i32, i32* %12
%105 = load double, double* %19
%106 = load double*, double** %20
%107 = load double**, double*** %13
%108 = load i8*, i8** %15
%109 = load i32, i32* %16
%110 = call double @scoreDistij(i32 %92, i32 %93, i8* %98, i8* %103, i32 %104, double %105, double* %106, double** %107, i8* %108, i32 %109)
%111 = load double**, double*** %14
%112 = load i32, i32* %18
%113 = sext i32 %112 to i64
%114 = getelementptr inbounds double*, double** %111, i64 %113
%115 = load double*, double** %114
%116 = load i32, i32* %17
%117 = sext i32 %116 to i64
%118 = getelementptr inbounds double, double* %115, i64 %117
store double %110, double* %118
%119 = load double**, double*** %14
%120 = load i32, i32* %17
%121 = sext i32 %120 to i64
%122 = getelementptr inbounds double*, double** %119, i64 %121
%123 = load double*, double** %122
%124 = load i32, i32* %18
%125 = sext i32 %124 to i64
%126 = getelementptr inbounds double, double* %123, i64 %125
store double %110, double* %126
br label %127
127: ; preds = %91
%128 = load i32, i32* %18
%129 = add nsw i32 %128, 1
store i32 %129, i32* %18
br label %87
130: ; preds = %87
br label %131
131: ; preds = %130
%132 = load i32, i32* %17
%133 = add nsw i32 %132, 1
store i32 %133, i32* %17
br label %79
134: ; preds = %79
%135 = load double*, double** %20
%136 = call i32 @free(double* %135)
ret void
}

LLVM IR (-O2):
define void @scoreDist(double* %0, i8** nocapture %1, i32 %2, i32 %3, double** %4, double** nocapture %5, i8* %6, i32 %7) {
%9 = tail call i64 @mCalloc(i32 %2, i32 8)
%10 = inttoptr i64 %9 to double*
%11 = sext i32 %2 to i64
%12 = shl nsw i64 %11, 3
%13 = tail call i32 @memset(double* %10, i32 0, i64 %12)
%14 = tail call i32 @expectedProtSimScore(double* %0, double** %4, i32 %7)
%15 = mul nsw i32 %14, %3
%16 = sitofp i32 %15 to double
%17 = icmp sgt i32 %2, 0
br i1 %17, label %18, label %64
18: ; preds = %8
%19 = zext i32 %2 to i64
br label %26
20: ; preds = %26
%21 = icmp sgt i32 %2, 1
br i1 %21, label %22, label %64
22: ; preds = %20
%23 = add nsw i32 %2, -1
%24 = zext i32 %23 to i64
%25 = zext i32 %2 to i64
br label %41
26: ; preds = %18, %26
%27 = phi i64 [ 0, %18 ], [ %36, %26 ]
%28 = tail call i64 @mCalloc(i32 %2, i32 8)
%29 = inttoptr i64 %28 to double*
%30 = getelementptr inbounds double*, double** %5, i64 %27
store double* %29, double** %30
%31 = getelementptr inbounds double, double* %29, i64 %27
store double 0.000000e+00, double* %31
%32 = getelementptr inbounds i8*, i8** %1, i64 %27
%33 = load i8*, i8** %32
%34 = tail call double @simScore(i8* %33, i8* %33, double** %4, i32 %3, i8* %6, i32 %7)
%35 = getelementptr inbounds double, double* %10, i64 %27
store double %34, double* %35
%36 = add nuw nsw i64 %27, 1
%37 = icmp eq i64 %36, %19
br i1 %37, label %20, label %26
38: ; preds = %50, %41
%39 = add nuw nsw i64 %43, 1
%40 = icmp eq i64 %44, %24
br i1 %40, label %64, label %41
41: ; preds = %22, %38
%42 = phi i64 [ 0, %22 ], [ %44, %38 ]
%43 = phi i64 [ 1, %22 ], [ %39, %38 ]
%44 = add nuw nsw i64 %42, 1
%45 = icmp slt i64 %44, %11
br i1 %45, label %46, label %38
46: ; preds = %41
%47 = getelementptr inbounds i8*, i8** %1, i64 %42
%48 = getelementptr inbounds double*, double** %5, i64 %42
%49 = trunc i64 %42 to i32
br label %50
50: ; preds = %46, %50
%51 = phi i64 [ %43, %46 ], [ %62, %50 ]
%52 = load i8*, i8** %47
%53 = getelementptr inbounds i8*, i8** %1, i64 %51
%54 = load i8*, i8** %53
%55 = trunc i64 %51 to i32
%56 = tail call double @scoreDistij(i32 %49, i32 %55, i8* %52, i8* %54, i32 %3, double %16, double* %10, double** %4, i8* %6, i32 %7)
%57 = getelementptr inbounds double*, double** %5, i64 %51
%58 = load double*, double** %57
%59 = getelementptr inbounds double, double* %58, i64 %42
store double %56, double* %59
%60 = load double*, double** %48
%61 = getelementptr inbounds double, double* %60, i64 %51
store double %56, double* %61
%62 = add nuw nsw i64 %51, 1
%63 = icmp eq i64 %62, %25
br i1 %63, label %38, label %50
64: ; preds = %38, %8, %20
%65 = tail call i32 @free(double* %10)
ret void
}