#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 int16_t;

/* Variables and functions */
double *calloc(int, int);
int /*<<< orphan*/ expVecTimesPlusAccum(int const, double const, double const *,
                                        double const, double const *, double *,
                                        double *);
int /*<<< orphan*/ free(double *);
void expsByLengthVec(const int16_t ns, const int16_t nc, const int16_t dims,
                     const int16_t q0, const int16_t maxlen,
                     const int16_t *restrict tmat, const double *restrict tprob,
                     const double *restrict tvec, const double *restrict fprob,
                     const double *restrict fvec, double *outp, double *outv) {
  double *accump = calloc(((int)ns) * (maxlen + 1), sizeof(double));
  double *accumv = calloc(((int)ns) * dims * (maxlen + 1), sizeof(double));
  accump[q0] = 1;
  for (int n = 1; n <= maxlen; ++n)
    for (int q = 0; q < ns; ++q)
      for (int c = 0; c < nc; ++c) {
        int qprime = tmat[c * ns + q];
        expVecTimesPlusAccum(
            dims, tprob[c * ns + q], tvec + (c * ns + q) * dims,
            accump[(n - 1) * ns + q], accumv + ((n - 1) * ns + q) * dims,
            accump + (n * ns + qprime), accumv + (n * ns + qprime) * dims);
      }
  for (int n = 0; n <= maxlen; ++n)
    for (int q = 0; q < ns; ++q) {
      expVecTimesPlusAccum(dims, accump[n * ns + q],
                           accumv + (n * ns + q) * dims, fprob[q],
                           fvec + q * dims, outp + n, outv + n * dims);
    }
  free(accump);
  free(accumv);
}


x86 assembly (clang, -O0):
<expsByLengthVec>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    0x38(%rbp),%rax
mov    0x30(%rbp),%rax
mov    0x28(%rbp),%rax
mov    0x20(%rbp),%rax
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    %r8d,-0x14(%rbp)
mov    %r9,-0x20(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x14(%rbp),%eax
add    $0x1,%eax
imul   %eax,%edi
mov    $0x8,%esi
call   1050 <calloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x4(%rbp),%edi
imul   -0xc(%rbp),%edi
mov    -0x14(%rbp),%eax
add    $0x1,%eax
imul   %eax,%edi
mov    $0x8,%esi
call   1050 <calloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsd  0xe54(%rip),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
movl   $0x1,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x14(%rbp),%eax
jg     12d7 <expsByLengthVec+0x1a7>
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    12c4 <expsByLengthVec+0x194>
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    12b1 <expsByLengthVec+0x181>
mov    -0x20(%rbp),%rax
mov    -0x3c(%rbp),%ecx
imul   -0x4(%rbp),%ecx
add    -0x38(%rbp),%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x40(%rbp)
mov    -0xc(%rbp),%edi
mov    0x10(%rbp),%rax
mov    -0x3c(%rbp),%ecx
imul   -0x4(%rbp),%ecx
add    -0x38(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    0x18(%rbp),%rsi
mov    -0x3c(%rbp),%eax
imul   -0x4(%rbp),%eax
add    -0x38(%rbp),%eax
imul   -0xc(%rbp),%eax
cltq
shl    $0x3,%rax
add    %rax,%rsi
mov    -0x28(%rbp),%rax
mov    -0x34(%rbp),%ecx
sub    $0x1,%ecx
imul   -0x4(%rbp),%ecx
add    -0x38(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x30(%rbp),%rdx
mov    -0x34(%rbp),%eax
sub    $0x1,%eax
imul   -0x4(%rbp),%eax
add    -0x38(%rbp),%eax
imul   -0xc(%rbp),%eax
cltq
shl    $0x3,%rax
add    %rax,%rdx
mov    -0x28(%rbp),%rcx
mov    -0x34(%rbp),%eax
imul   -0x4(%rbp),%eax
add    -0x40(%rbp),%eax
cltq
shl    $0x3,%rax
add    %rax,%rcx
mov    -0x30(%rbp),%r8
mov    -0x34(%rbp),%eax
imul   -0x4(%rbp),%eax
add    -0x40(%rbp),%eax
imul   -0xc(%rbp),%eax
cltq
shl    $0x3,%rax
add    %rax,%r8
call   1040 <expVecTimesPlusAccum@plt>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    11de <expsByLengthVec+0xae>
jmp    12b6 <expsByLengthVec+0x186>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    11cb <expsByLengthVec+0x9b>
jmp    12c9 <expsByLengthVec+0x199>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    11b8 <expsByLengthVec+0x88>
movl   $0x0,-0x44(%rbp)
mov    -0x44(%rbp),%eax
cmp    -0x14(%rbp),%eax
jg     139b <expsByLengthVec+0x26b>
movl   $0x0,-0x48(%rbp)
mov    -0x48(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1388 <expsByLengthVec+0x258>
mov    -0xc(%rbp),%edi
mov    -0x28(%rbp),%rax
mov    -0x44(%rbp),%ecx
imul   -0x4(%rbp),%ecx
add    -0x48(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x30(%rbp),%rsi
mov    -0x44(%rbp),%eax
imul   -0x4(%rbp),%eax
add    -0x48(%rbp),%eax
imul   -0xc(%rbp),%eax
cltq
shl    $0x3,%rax
add    %rax,%rsi
mov    0x20(%rbp),%rax
movslq -0x48(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    0x28(%rbp),%rdx
mov    -0x48(%rbp),%eax
imul   -0xc(%rbp),%eax
cltq
shl    $0x3,%rax
add    %rax,%rdx
mov    0x30(%rbp),%rcx
movslq -0x44(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rcx
mov    0x38(%rbp),%r8
mov    -0x44(%rbp),%eax
imul   -0xc(%rbp),%eax
cltq
shl    $0x3,%rax
add    %rax,%r8
call   1040 <expVecTimesPlusAccum@plt>
mov    -0x48(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48(%rbp)
jmp    12f1 <expsByLengthVec+0x1c1>
jmp    138d <expsByLengthVec+0x25d>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    12de <expsByLengthVec+0x1ae>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<expsByLengthVec>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xd8,%rsp
mov    %r9,0x98(%rsp)
mov    %r8d,%r14d
mov    %ecx,0x8(%rsp)
mov    %edx,%r12d
mov    %esi,0x34(%rsp)
mov    %edi,%ebp
mov    0x138(%rsp),%rax
mov    %rax,0xb0(%rsp)
mov    0x130(%rsp),%rax
mov    %rax,0xa8(%rsp)
mov    0x128(%rsp),%rax
mov    %rax,0xa0(%rsp)
mov    0x120(%rsp),%rax
mov    %rax,0xb8(%rsp)
mov    0x118(%rsp),%rax
mov    %rax,0x90(%rsp)
mov    0x110(%rsp),%rax
mov    %rax,0x88(%rsp)
lea    0x1(%r14),%r13d
mov    %r13d,%r15d
imul   %edi,%r15d
mov    %r15d,%edi
mov    $0x8,%esi
call   1050 <calloc@plt>
mov    %rax,%rbx
imul   %r12d,%r15d
mov    %r15d,%edi
mov    $0x8,%esi
call   1050 <calloc@plt>
movslq 0x8(%rsp),%rdx
movabs $0x3ff0000000000000,%rcx
mov    %rcx,(%rbx,%rdx,8)
movslq %r12d,%rcx
mov    %rcx,0x38(%rsp)
movslq %ebp,%rcx
mov    %rcx,0x10(%rsp)
mov    %r13d,%ecx
mov    %rcx,0x70(%rsp)
mov    %ebp,0xc(%rsp)
mov    %ebp,%ecx
mov    %rcx,0x78(%rsp)
mov    %r14,0x80(%rsp)
test   %r14d,%r14d
mov    %r12d,0x8(%rsp)
mov    %rbx,0x58(%rsp)
mov    %rax,0x40(%rsp)
jle    13ef <expsByLengthVec+0x2bf>
mov    %rbx,%r10
mov    %r12d,%r8d
mov    0x34(%rsp),%ecx
mov    %rcx,0xc0(%rsp)
mov    0x38(%rsp),%rcx
lea    0x0(,%rcx,8),%rdx
mov    %rdx,0xd0(%rsp)
mov    %rcx,%rdx
mov    0x10(%rsp),%rcx
imul   %rcx,%rdx
shl    $0x3,%rdx
lea    0x0(,%rcx,4),%rbp
mov    $0x1,%ecx
mov    %rcx,0x48(%rsp)
mov    %rdx,0x28(%rsp)
mov    %rbp,0x20(%rsp)
jmp    12a9 <expsByLengthVec+0x179>
mov    0x48(%rsp),%rcx
add    $0x1,%rcx
mov    %rcx,0x48(%rsp)
cmp    0x70(%rsp),%rcx
je     13ef <expsByLengthVec+0x2bf>
cmpl   $0x0,0xc(%rsp)
jle    1290 <expsByLengthVec+0x160>
mov    0x48(%rsp),%rcx
lea    -0x1(%rcx),%rbx
imul   0x10(%rsp),%rbx
mov    %rbx,0xc8(%rsp)
mov    %ecx,%esi
imul   0xc(%rsp),%esi
mov    0x88(%rsp),%rbx
mov    0x98(%rsp),%r13
mov    0x90(%rsp),%rcx
mov    %rcx,0x18(%rsp)
xor    %ecx,%ecx
mov    %rcx,0x50(%rsp)
jmp    1336 <expsByLengthVec+0x206>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0x50(%rsp),%rdi
add    $0x1,%rdi
mov    0x18(%rsp),%rcx
add    0xd0(%rsp),%rcx
mov    %rcx,0x18(%rsp)
add    $0x4,%r13
add    $0x8,%rbx
mov    %rdi,%rcx
mov    %rdi,0x50(%rsp)
cmp    0x78(%rsp),%rdi
je     1290 <expsByLengthVec+0x160>
cmpl   $0x0,0x34(%rsp)
jle    1300 <expsByLengthVec+0x1d0>
mov    0xc8(%rsp),%rcx
mov    0x50(%rsp),%rdi
add    %rdi,%rcx
mov    %rcx,%rdi
mov    %rcx,0x68(%rsp)
imul   0x38(%rsp),%rcx
lea    (%rax,%rcx,8),%rax
mov    %rax,0x60(%rsp)
mov    0xc0(%rsp),%r12
xor    %r15d,%r15d
mov    0x18(%rsp),%r14
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movslq 0x0(%r13,%r15,1),%rax
movsd  (%rbx,%r15,2),%xmm0
mov    0x68(%rsp),%rcx
movsd  (%r10,%rcx,8),%xmm1
movslq %esi,%rdx
add    %rax,%rdx
lea    (%r10,%rdx,8),%rcx
imul   %r8d,%edx
movslq %edx,%rax
mov    0x40(%rsp),%rdx
mov    %esi,%ebp
lea    (%rdx,%rax,8),%r8
mov    0x8(%rsp),%edi
mov    %r14,%rsi
mov    0x60(%rsp),%rdx
call   1040 <expVecTimesPlusAccum@plt>
mov    %ebp,%esi
mov    0x20(%rsp),%rbp
mov    0x28(%rsp),%rdx
mov    0x40(%rsp),%rax
mov    0x58(%rsp),%r10
mov    0x8(%rsp),%r8d
add    %rdx,%r14
add    %rbp,%r15
add    $0xffffffffffffffff,%r12
jne    1380 <expsByLengthVec+0x250>
jmp    1300 <expsByLengthVec+0x1d0>
cmpl   $0x0,0x80(%rsp)
js     150b <expsByLengthVec+0x3db>
mov    0x38(%rsp),%rax
lea    0x0(,%rax,8),%rbx
mov    %rax,%rcx
mov    0x10(%rsp),%rax
imul   %rax,%rcx
shl    $0x3,%rcx
mov    %rcx,0x18(%rsp)
shl    $0x3,%rax
mov    %rax,0x10(%rsp)
xor    %eax,%eax
mov    %rax,0x28(%rsp)
mov    0x58(%rsp),%r15
mov    0x40(%rsp),%rax
mov    %rax,0x20(%rsp)
mov    0xb8(%rsp),%r12
jmp    1480 <expsByLengthVec+0x350>
nopl   0x0(%rax,%rax,1)
mov    0x28(%rsp),%rcx
add    $0x1,%rcx
mov    0x20(%rsp),%rax
add    0x18(%rsp),%rax
mov    %rax,0x20(%rsp)
add    0x10(%rsp),%r15
mov    %rcx,%rax
mov    %rcx,0x28(%rsp)
cmp    0x70(%rsp),%rcx
je     150b <expsByLengthVec+0x3db>
cmpl   $0x0,0xc(%rsp)
jle    1450 <expsByLengthVec+0x320>
mov    0xa8(%rsp),%rax
mov    0x28(%rsp),%rcx
lea    (%rax,%rcx,8),%rax
mov    %rax,0x68(%rsp)
mov    %rcx,%rax
imul   0x38(%rsp),%rax
mov    0xb0(%rsp),%rcx
lea    (%rcx,%rax,8),%rax
mov    %rax,0x60(%rsp)
mov    0x20(%rsp),%r13
mov    0xa0(%rsp),%r14
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
movsd  (%r15,%rbp,8),%xmm0
movsd  (%r12,%rbp,8),%xmm1
mov    0x8(%rsp),%edi
mov    %r13,%rsi
mov    %r14,%rdx
mov    0x68(%rsp),%rcx
mov    0x60(%rsp),%r8
call   1040 <expVecTimesPlusAccum@plt>
add    $0x1,%rbp
add    %rbx,%r14
add    %rbx,%r13
cmp    %rbp,0x78(%rsp)
jne    14d0 <expsByLengthVec+0x3a0>
jmp    1450 <expsByLengthVec+0x320>
mov    0x58(%rsp),%rdi
call   1030 <free@plt>
mov    0x40(%rsp),%rdi
add    $0xd8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>

LLVM IR (-O0):
define void @expsByLengthVec(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i32* noalias %5, double* noalias %6, double* noalias %7, double* noalias %8, double* noalias %9, double* %10, double* %11) {
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32*
%19 = alloca double*
%20 = alloca double*
%21 = alloca double*
%22 = alloca double*
%23 = alloca double*
%24 = alloca double*
%25 = alloca double*
%26 = alloca double*
%27 = alloca i32
%28 = alloca i32
%29 = alloca i32
%30 = alloca i32
%31 = alloca i32
%32 = alloca i32
store i32 %0, i32* %13
store i32 %1, i32* %14
store i32 %2, i32* %15
store i32 %3, i32* %16
store i32 %4, i32* %17
store i32* %5, i32** %18
store double* %6, double** %19
store double* %7, double** %20
store double* %8, double** %21
store double* %9, double** %22
store double* %10, double** %23
store double* %11, double** %24
%33 = load i32, i32* %13
%34 = load i32, i32* %17
%35 = add nsw i32 %34, 1
%36 = mul nsw i32 %33, %35
%37 = call double* @calloc(i32 %36, i32 8)
store double* %37, double** %25
%38 = load i32, i32* %13
%39 = load i32, i32* %15
%40 = mul nsw i32 %38, %39
%41 = load i32, i32* %17
%42 = add nsw i32 %41, 1
%43 = mul nsw i32 %40, %42
%44 = call double* @calloc(i32 %43, i32 8)
store double* %44, double** %26
%45 = load double*, double** %25
%46 = load i32, i32* %16
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds double, double* %45, i64 %47
store double 1.000000e+00, double* %48
store i32 1, i32* %27
br label %49
49: ; preds = %141, %12
%50 = load i32, i32* %27
%51 = load i32, i32* %17
%52 = icmp sle i32 %50, %51
br i1 %52, label %53, label %144
53: ; preds = %49
store i32 0, i32* %28
br label %54
54: ; preds = %137, %53
%55 = load i32, i32* %28
%56 = load i32, i32* %13
%57 = icmp slt i32 %55, %56
br i1 %57, label %58, label %140
58: ; preds = %54
store i32 0, i32* %29
br label %59
59: ; preds = %133, %58
%60 = load i32, i32* %29
%61 = load i32, i32* %14
%62 = icmp slt i32 %60, %61
br i1 %62, label %63, label %136
63: ; preds = %59
%64 = load i32*, i32** %18
%65 = load i32, i32* %29
%66 = load i32, i32* %13
%67 = mul nsw i32 %65, %66
%68 = load i32, i32* %28
%69 = add nsw i32 %67, %68
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds i32, i32* %64, i64 %70
%72 = load i32, i32* %71
store i32 %72, i32* %30
%73 = load i32, i32* %15
%74 = load double*, double** %19
%75 = load i32, i32* %29
%76 = load i32, i32* %13
%77 = mul nsw i32 %75, %76
%78 = load i32, i32* %28
%79 = add nsw i32 %77, %78
%80 = sext i32 %79 to i64
%81 = getelementptr inbounds double, double* %74, i64 %80
%82 = load double, double* %81
%83 = load double*, double** %20
%84 = load i32, i32* %29
%85 = load i32, i32* %13
%86 = mul nsw i32 %84, %85
%87 = load i32, i32* %28
%88 = add nsw i32 %86, %87
%89 = load i32, i32* %15
%90 = mul nsw i32 %88, %89
%91 = sext i32 %90 to i64
%92 = getelementptr inbounds double, double* %83, i64 %91
%93 = load double*, double** %25
%94 = load i32, i32* %27
%95 = sub nsw i32 %94, 1
%96 = load i32, i32* %13
%97 = mul nsw i32 %95, %96
%98 = load i32, i32* %28
%99 = add nsw i32 %97, %98
%100 = sext i32 %99 to i64
%101 = getelementptr inbounds double, double* %93, i64 %100
%102 = load double, double* %101
%103 = load double*, double** %26
%104 = load i32, i32* %27
%105 = sub nsw i32 %104, 1
%106 = load i32, i32* %13
%107 = mul nsw i32 %105, %106
%108 = load i32, i32* %28
%109 = add nsw i32 %107, %108
%110 = load i32, i32* %15
%111 = mul nsw i32 %109, %110
%112 = sext i32 %111 to i64
%113 = getelementptr inbounds double, double* %103, i64 %112
%114 = load double*, double** %25
%115 = load i32, i32* %27
%116 = load i32, i32* %13
%117 = mul nsw i32 %115, %116
%118 = load i32, i32* %30
%119 = add nsw i32 %117, %118
%120 = sext i32 %119 to i64
%121 = getelementptr inbounds double, double* %114, i64 %120
%122 = load double*, double** %26
%123 = load i32, i32* %27
%124 = load i32, i32* %13
%125 = mul nsw i32 %123, %124
%126 = load i32, i32* %30
%127 = add nsw i32 %125, %126
%128 = load i32, i32* %15
%129 = mul nsw i32 %127, %128
%130 = sext i32 %129 to i64
%131 = getelementptr inbounds double, double* %122, i64 %130
%132 = call i32 @expVecTimesPlusAccum(i32 %73, double %82, double* %92, double %102, double* %113, double* %121, double* %131)
br label %133
133: ; preds = %63
%134 = load i32, i32* %29
%135 = add nsw i32 %134, 1
store i32 %135, i32* %29
br label %59
136: ; preds = %59
br label %137
137: ; preds = %136
%138 = load i32, i32* %28
%139 = add nsw i32 %138, 1
store i32 %139, i32* %28
br label %54
140: ; preds = %54
br label %141
141: ; preds = %140
%142 = load i32, i32* %27
%143 = add nsw i32 %142, 1
store i32 %143, i32* %27
br label %49
144: ; preds = %49
store i32 0, i32* %31
br label %145
145: ; preds = %201, %144
%146 = load i32, i32* %31
%147 = load i32, i32* %17
%148 = icmp sle i32 %146, %147
br i1 %148, label %149, label %204
149: ; preds = %145
store i32 0, i32* %32
br label %150
150: ; preds = %197, %149
%151 = load i32, i32* %32
%152 = load i32, i32* %13
%153 = icmp slt i32 %151, %152
br i1 %153, label %154, label %200
154: ; preds = %150
%155 = load i32, i32* %15
%156 = load double*, double** %25
%157 = load i32, i32* %31
%158 = load i32, i32* %13
%159 = mul nsw i32 %157, %158
%160 = load i32, i32* %32
%161 = add nsw i32 %159, %160
%162 = sext i32 %161 to i64
%163 = getelementptr inbounds double, double* %156, i64 %162
%164 = load double, double* %163
%165 = load double*, double** %26
%166 = load i32, i32* %31
%167 = load i32, i32* %13
%168 = mul nsw i32 %166, %167
%169 = load i32, i32* %32
%170 = add nsw i32 %168, %169
%171 = load i32, i32* %15
%172 = mul nsw i32 %170, %171
%173 = sext i32 %172 to i64
%174 = getelementptr inbounds double, double* %165, i64 %173
%175 = load double*, double** %21
%176 = load i32, i32* %32
%177 = sext i32 %176 to i64
%178 = getelementptr inbounds double, double* %175, i64 %177
%179 = load double, double* %178
%180 = load double*, double** %22
%181 = load i32, i32* %32
%182 = load i32, i32* %15
%183 = mul nsw i32 %181, %182
%184 = sext i32 %183 to i64
%185 = getelementptr inbounds double, double* %180, i64 %184
%186 = load double*, double** %23
%187 = load i32, i32* %31
%188 = sext i32 %187 to i64
%189 = getelementptr inbounds double, double* %186, i64 %188
%190 = load double*, double** %24
%191 = load i32, i32* %31
%192 = load i32, i32* %15
%193 = mul nsw i32 %191, %192
%194 = sext i32 %193 to i64
%195 = getelementptr inbounds double, double* %190, i64 %194
%196 = call i32 @expVecTimesPlusAccum(i32 %155, double %164, double* %174, double %179, double* %185, double* %189, double* %195)
br label %197
197: ; preds = %154
%198 = load i32, i32* %32
%199 = add nsw i32 %198, 1
store i32 %199, i32* %32
br label %150
200: ; preds = %150
br label %201
201: ; preds = %200
%202 = load i32, i32* %31
%203 = add nsw i32 %202, 1
store i32 %203, i32* %31
br label %145
204: ; preds = %145
%205 = load double*, double** %25
%206 = call i32 @free(double* %205)
%207 = load double*, double** %26
%208 = call i32 @free(double* %207)
ret void
}

LLVM IR (-O2):
define void @expsByLengthVec(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i32* noalias nocapture %5, double* noalias nocapture %6, double* noalias %7, double* noalias nocapture %8, double* noalias %9, double* %10, double* %11) {
%13 = add i32 %4, 1
%14 = mul i32 %13, %0
%15 = tail call double* @calloc(i32 %14, i32 8)
%16 = mul i32 %14, %2
%17 = tail call double* @calloc(i32 %16, i32 8)
%18 = sext i32 %3 to i64
%19 = getelementptr inbounds double, double* %15, i64 %18
store double 1.000000e+00, double* %19
%20 = icmp slt i32 %4, 1
br i1 %20, label %36, label %21
21: ; preds = %12
%22 = icmp sgt i32 %0, 0
%23 = icmp sgt i32 %1, 0
%24 = sext i32 %0 to i64
%25 = sext i32 %2 to i64
%26 = zext i32 %13 to i64
%27 = zext i32 %0 to i64
%28 = zext i32 %1 to i64
br label %29
29: ; preds = %21, %51
%30 = phi i64 [ 1, %21 ], [ %52, %51 ]
br i1 %22, label %31, label %51
31: ; preds = %29
%32 = add nsw i64 %30, -1
%33 = mul nsw i64 %32, %24
%34 = trunc i64 %30 to i32
%35 = mul i32 %34, %0
br label %44
36: ; preds = %51, %12
%37 = icmp slt i32 %4, 0
br i1 %37, label %84, label %38
38: ; preds = %36
%39 = icmp sgt i32 %0, 0
%40 = sext i32 %2 to i64
%41 = sext i32 %0 to i64
%42 = zext i32 %13 to i64
%43 = zext i32 %0 to i64
br label %77
44: ; preds = %31, %54
%45 = phi i64 [ 0, %31 ], [ %55, %54 ]
br i1 %23, label %46, label %54
46: ; preds = %44
%47 = add nsw i64 %45, %33
%48 = getelementptr inbounds double, double* %15, i64 %47
%49 = mul nsw i64 %47, %25
%50 = getelementptr inbounds double, double* %17, i64 %49
br label %57
51: ; preds = %54, %29
%52 = add nuw nsw i64 %30, 1
%53 = icmp eq i64 %52, %26
br i1 %53, label %36, label %29
54: ; preds = %57, %44
%55 = add nuw nsw i64 %45, 1
%56 = icmp eq i64 %55, %27
br i1 %56, label %51, label %44
57: ; preds = %46, %57
%58 = phi i64 [ 0, %46 ], [ %75, %57 ]
%59 = mul nsw i64 %58, %24
%60 = add nsw i64 %59, %45
%61 = getelementptr inbounds i32, i32* %5, i64 %60
%62 = load i32, i32* %61
%63 = getelementptr inbounds double, double* %6, i64 %60
%64 = load double, double* %63
%65 = mul nsw i64 %60, %25
%66 = getelementptr inbounds double, double* %7, i64 %65
%67 = load double, double* %48
%68 = add nsw i32 %62, %35
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds double, double* %15, i64 %69
%71 = mul nsw i32 %68, %2
%72 = sext i32 %71 to i64
%73 = getelementptr inbounds double, double* %17, i64 %72
%74 = tail call i32 @expVecTimesPlusAccum(i32 %2, double %64, double* %66, double %67, double* %50, double* %70, double* %73)
%75 = add nuw nsw i64 %58, 1
%76 = icmp eq i64 %75, %28
br i1 %76, label %54, label %57
77: ; preds = %38, %87
%78 = phi i64 [ 0, %38 ], [ %88, %87 ]
br i1 %39, label %79, label %87
79: ; preds = %77
%80 = mul nsw i64 %78, %41
%81 = getelementptr inbounds double, double* %10, i64 %78
%82 = mul nsw i64 %78, %40
%83 = getelementptr inbounds double, double* %11, i64 %82
br label %90
84: ; preds = %87, %36
%85 = tail call i32 @free(double* %15)
%86 = tail call i32 @free(double* %17)
ret void
87: ; preds = %90, %77
%88 = add nuw nsw i64 %78, 1
%89 = icmp eq i64 %88, %42
br i1 %89, label %84, label %77
90: ; preds = %79, %90
%91 = phi i64 [ 0, %79 ], [ %102, %90 ]
%92 = add nsw i64 %91, %80
%93 = getelementptr inbounds double, double* %15, i64 %92
%94 = load double, double* %93
%95 = mul nsw i64 %92, %40
%96 = getelementptr inbounds double, double* %17, i64 %95
%97 = getelementptr inbounds double, double* %8, i64 %91
%98 = load double, double* %97
%99 = mul nsw i64 %91, %40
%100 = getelementptr inbounds double, double* %9, i64 %99
%101 = tail call i32 @expVecTimesPlusAccum(i32 %2, double %94, double* %96, double %98, double* %100, double* %81, double* %83)
%102 = add nuw nsw i64 %91, 1
%103 = icmp eq i64 %102, %43
br i1 %103, label %87, label %90
}