#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 *aa2dirichlet_code_lu();
double **declare_double(int, int);
int /*<<< orphan*/ free(int *);
int /*<<< orphan*/ memset(double *, int /*<<< orphan*/, int);
int strlen(char *);
double **aln2prf(char *seq, double **prf) {
  int *lu;
  int c, r, d;
  double tot;
  int slen = strlen(seq);
  lu = aa2dirichlet_code_lu();
  prf = declare_double(slen, 20);
  for (c = 0; c < slen; c++) {
    tot = 0;
    memset(prf[c], 0, sizeof(double) * 20);
    d = lu[seq[c]];
    if (d >= 0) {
      prf[c][d]++;
      tot++;
    }
    if (tot > 0) {
      for (r = 0; r < 20; r++) {
        prf[c][r] /= tot;
      }
    }
  }
  free(lu);
  return prf;
}


x86 assembly (clang, -O0):
<aln2prf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x34(%rbp)
mov    $0x0,%al
call   1070 <aa2dirichlet_code_lu@plt>
mov    %rax,-0x18(%rbp)
mov    -0x34(%rbp),%edi
mov    $0x14,%esi
call   1040 <declare_double@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x34(%rbp),%eax
jge    127c <aln2prf+0x12c>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
xor    %esi,%esi
mov    $0xa0,%edx
call   1060 <memset@plt>
mov    -0x18(%rbp),%rax
mov    -0x8(%rbp),%rcx
movslq -0x1c(%rbp),%rdx
movsbq (%rcx,%rdx,1),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jl     1210 <aln2prf+0xc0>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x24(%rbp),%rcx
movsd  0xe0c(%rip),%xmm0
addsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
movsd  0xdfa(%rip),%xmm0
addsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    1269 <aln2prf+0x119>
movl   $0x0,-0x20(%rbp)
cmpl   $0x14,-0x20(%rbp)
jge    1264 <aln2prf+0x114>
movsd  -0x30(%rbp),%xmm1
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1229 <aln2prf+0xd9>
jmp    1269 <aln2prf+0x119>
jmp    126e <aln2prf+0x11e>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    118f <aln2prf+0x3f>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x10(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<aln2prf>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdi,%r14
call   1050 <strlen@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1070 <aa2dirichlet_code_lu@plt>
mov    %rax,%r15
mov    %ebp,%edi
mov    $0x14,%esi
call   1040 <declare_double@plt>
mov    %rax,%rbx
test   %ebp,%ebp
jle    11ce <aln2prf+0x7e>
mov    %ebp,%r12d
xor    %ebp,%ebp
jmp    1199 <aln2prf+0x49>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%rbp
cmp    %rbp,%r12
je     11ce <aln2prf+0x7e>
mov    (%rbx,%rbp,8),%rdi
xor    %esi,%esi
mov    $0xa0,%edx
call   1060 <memset@plt>
movsbq (%r14,%rbp,1),%rax
mov    (%r15,%rax,4),%eax
test   %eax,%eax
js     1190 <aln2prf+0x40>
mov    (%rbx,%rbp,8),%rcx
movsd  (%rcx,%rax,8),%xmm0
addsd  0xe39(%rip),%xmm0
movsd  %xmm0,(%rcx,%rax,8)
jmp    1190 <aln2prf+0x40>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %rbx,%rax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define double** @aln2prf(i8* %0, double** %1) {
%3 = alloca i8*
%4 = alloca double**
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca double
%10 = alloca i32
store i8* %0, i8** %3
store double** %1, double*** %4
%11 = load i8*, i8** %3
%12 = call i32 @strlen(i8* %11)
store i32 %12, i32* %10
%13 = call i32* (...) @aa2dirichlet_code_lu()
store i32* %13, i32** %5
%14 = load i32, i32* %10
%15 = call double** @declare_double(i32 %14, i32 20)
store double** %15, double*** %4
store i32 0, i32* %6
br label %16
16: ; preds = %75, %2
%17 = load i32, i32* %6
%18 = load i32, i32* %10
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %78
20: ; preds = %16
store double 0.000000e+00, double* %9
%21 = load double**, double*** %4
%22 = load i32, i32* %6
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds double*, double** %21, i64 %23
%25 = load double*, double** %24
%26 = call i32 @memset(double* %25, i32 0, i32 160)
%27 = load i32*, i32** %5
%28 = load i8*, i8** %3
%29 = load i32, i32* %6
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8, i8* %28, i64 %30
%32 = load i8, i8* %31
%33 = sext i8 %32 to i64
%34 = getelementptr inbounds i32, i32* %27, i64 %33
%35 = load i32, i32* %34
store i32 %35, i32* %8
%36 = load i32, i32* %8
%37 = icmp sge i32 %36, 0
br i1 %37, label %38, label %51
38: ; preds = %20
%39 = load double**, double*** %4
%40 = load i32, i32* %6
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds double*, double** %39, i64 %41
%43 = load double*, double** %42
%44 = load i32, i32* %8
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds double, double* %43, i64 %45
%47 = load double, double* %46
%48 = fadd double %47, 1.000000e+00
store double %48, double* %46
%49 = load double, double* %9
%50 = fadd double %49, 1.000000e+00
store double %50, double* %9
br label %51
51: ; preds = %38, %20
%52 = load double, double* %9
%53 = fcmp ogt double %52, 0.000000e+00
br i1 %53, label %54, label %74
54: ; preds = %51
store i32 0, i32* %7
br label %55
55: ; preds = %70, %54
%56 = load i32, i32* %7
%57 = icmp slt i32 %56, 20
br i1 %57, label %58, label %73
58: ; preds = %55
%59 = load double, double* %9
%60 = load double**, double*** %4
%61 = load i32, i32* %6
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds double*, double** %60, i64 %62
%64 = load double*, double** %63
%65 = load i32, i32* %7
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds double, double* %64, i64 %66
%68 = load double, double* %67
%69 = fdiv double %68, %59
store double %69, double* %67
br label %70
70: ; preds = %58
%71 = load i32, i32* %7
%72 = add nsw i32 %71, 1
store i32 %72, i32* %7
br label %55
73: ; preds = %55
br label %74
74: ; preds = %73, %51
br label %75
75: ; preds = %74
%76 = load i32, i32* %6
%77 = add nsw i32 %76, 1
store i32 %77, i32* %6
br label %16
78: ; preds = %16
%79 = load i32*, i32** %5
%80 = call i32 @free(i32* %79)
%81 = load double**, double*** %4
ret double** %81
}

LLVM IR (-O2):
define double** @aln2prf(i8* %0, double** nocapture readnone %1) {
%3 = tail call i32 @strlen(i8* %0)
%4 = tail call i32* (...) @aa2dirichlet_code_lu()
%5 = tail call double** @declare_double(i32 %3, i32 20)
%6 = icmp sgt i32 %3, 0
br i1 %6, label %7, label %29
7: ; preds = %2
%8 = zext i32 %3 to i64
br label %9
9: ; preds = %7, %26
%10 = phi i64 [ 0, %7 ], [ %27, %26 ]
%11 = getelementptr inbounds double*, double** %5, i64 %10
%12 = load double*, double** %11
%13 = tail call i32 @memset(double* %12, i32 0, i32 160)
%14 = getelementptr inbounds i8, i8* %0, i64 %10
%15 = load i8, i8* %14
%16 = sext i8 %15 to i64
%17 = getelementptr inbounds i32, i32* %4, i64 %16
%18 = load i32, i32* %17
%19 = icmp sgt i32 %18, -1
br i1 %19, label %20, label %26
20: ; preds = %9
%21 = load double*, double** %11
%22 = zext i32 %18 to i64
%23 = getelementptr inbounds double, double* %21, i64 %22
%24 = load double, double* %23
%25 = fadd double %24, 1.000000e+00
store double %25, double* %23
br label %26
26: ; preds = %20, %9
%27 = add nuw nsw i64 %10, 1
%28 = icmp eq i64 %27, %8
br i1 %28, label %29, label %9
29: ; preds = %26, %2
%30 = tail call i32 @free(i32* %4)
ret double** %5
}