#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 */
size_t aaIndex(char, char *, int);
double simScore(char *s1, char *s2, double **scoreMatrix, int seqlength,
                char *alphabet, int alphabetSize) {
  int i;
  double sum = 0.0;
  for (i = 0; i < seqlength; i++)
    sum += scoreMatrix[aaIndex(s1[i], alphabet, alphabetSize)]
                      [aaIndex(s2[i], alphabet, alphabetSize)];
  return (sum);
}


x86 assembly (clang, -O0):
<simScore>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9d,-0x2c(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11b9 <simScore+0xa9>
mov    -0x18(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x30(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    -0x28(%rbp),%rsi
mov    -0x2c(%rbp),%edx
movsbl %al,%edi
call   1030 <aaIndex@plt>
mov    %rax,%rcx
mov    -0x48(%rbp),%rax
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x40(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x30(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    -0x28(%rbp),%rsi
mov    -0x2c(%rbp),%edx
movsbl %al,%edi
call   1030 <aaIndex@plt>
mov    %rax,%rcx
mov    -0x40(%rbp),%rax
movsd  (%rax,%rcx,8),%xmm0
addsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    113e <simScore+0x2e>
movsd  -0x38(%rbp),%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<simScore>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
test   %ecx,%ecx
jle    1189 <simScore+0x79>
mov    %r9d,%r12d
mov    %r8,%rbx
mov    %rdx,%rbp
mov    %rdi,%r13
mov    %ecx,%eax
mov    %rax,0x8(%rsp)
xorpd  %xmm0,%xmm0
xor    %r14d,%r14d
mov    %rsi,(%rsp)
movsd  %xmm0,0x10(%rsp)
movsbl 0x0(%r13,%r14,1),%edi
mov    %rbx,%rsi
mov    %r12d,%edx
call   1030 <aaIndex@plt>
mov    0x0(%rbp,%rax,8),%r15
mov    (%rsp),%rax
movsbl (%rax,%r14,1),%edi
mov    %rbx,%rsi
mov    %r12d,%edx
call   1030 <aaIndex@plt>
movsd  0x10(%rsp),%xmm0
addsd  (%r15,%rax,8),%xmm0
add    $0x1,%r14
cmp    %r14,0x8(%rsp)
jne    1140 <simScore+0x30>
jmp    118d <simScore+0x7d>
xorpd  %xmm0,%xmm0
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define double @simScore(i8* %0, i8* %1, double** %2, i32 %3, i8* %4, i32 %5) {
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca double**
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i32
%14 = alloca double
store i8* %0, i8** %7
store i8* %1, i8** %8
store double** %2, double*** %9
store i32 %3, i32* %10
store i8* %4, i8** %11
store i32 %5, i32* %12
store double 0.000000e+00, double* %14
store i32 0, i32* %13
br label %15
15: ; preds = %43, %6
%16 = load i32, i32* %13
%17 = load i32, i32* %10
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %46
19: ; preds = %15
%20 = load double**, double*** %9
%21 = load i8*, i8** %7
%22 = load i32, i32* %13
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %21, i64 %23
%25 = load i8, i8* %24
%26 = load i8*, i8** %11
%27 = load i32, i32* %12
%28 = call i64 @aaIndex(i8 signext %25, i8* %26, i32 %27)
%29 = getelementptr inbounds double*, double** %20, i64 %28
%30 = load double*, double** %29
%31 = load i8*, i8** %8
%32 = load i32, i32* %13
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8, i8* %31, i64 %33
%35 = load i8, i8* %34
%36 = load i8*, i8** %11
%37 = load i32, i32* %12
%38 = call i64 @aaIndex(i8 signext %35, i8* %36, i32 %37)
%39 = getelementptr inbounds double, double* %30, i64 %38
%40 = load double, double* %39
%41 = load double, double* %14
%42 = fadd double %41, %40
store double %42, double* %14
br label %43
43: ; preds = %19
%44 = load i32, i32* %13
%45 = add nsw i32 %44, 1
store i32 %45, i32* %13
br label %15
46: ; preds = %15
%47 = load double, double* %14
ret double %47
}

LLVM IR (-O2):
define double @simScore(i8* nocapture %0, i8* nocapture %1, double** nocapture %2, i32 %3, i8* %4, i32 %5) {
%7 = icmp sgt i32 %3, 0
br i1 %7, label %8, label %26
8: ; preds = %6
%9 = zext i32 %3 to i64
br label %10
10: ; preds = %8, %10
%11 = phi i64 [ 0, %8 ], [ %24, %10 ]
%12 = phi double [ 0.000000e+00, %8 ], [ %23, %10 ]
%13 = getelementptr inbounds i8, i8* %0, i64 %11
%14 = load i8, i8* %13
%15 = tail call i64 @aaIndex(i8 signext %14, i8* %4, i32 %5)
%16 = getelementptr inbounds double*, double** %2, i64 %15
%17 = load double*, double** %16
%18 = getelementptr inbounds i8, i8* %1, i64 %11
%19 = load i8, i8* %18
%20 = tail call i64 @aaIndex(i8 signext %19, i8* %4, i32 %5)
%21 = getelementptr inbounds double, double* %17, i64 %20
%22 = load double, double* %21
%23 = fadd double %12, %22
%24 = add nuw nsw i64 %11, 1
%25 = icmp eq i64 %24, %9
br i1 %25, label %26, label %10
26: ; preds = %10, %6
%27 = phi double [ 0.000000e+00, %6 ], [ %23, %10 ]
ret double %27
}