#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 /*<<< orphan*/ _tram_estimate_transition_matrix(double *, double *, int *,
                                                    int, double *, double *);
int log(double);
double _tram_discrete_log_likelihood_lower_bound(
    double *log_lagrangian_mult, double *biased_conf_energies,
    int *count_matrices, int *state_counts, int n_therm_states,
    int n_conf_states, double *scratch_M, double *scratch_MM) {
  double a, b;
  int K, i, j;
  int KM, KMM, Ki;
  int CKij;
  double *T_ij;
  a = 0;
  T_ij = scratch_MM;
  for (K = 0; K < n_therm_states; ++K) {
    KM = K * n_conf_states;
    KMM = KM * n_conf_states;
    _tram_estimate_transition_matrix(
        &log_lagrangian_mult[KM], &biased_conf_energies[KM],
        &count_matrices[KMM], n_conf_states, scratch_M, T_ij);
    for (i = 0; i < n_conf_states; ++i) {
      for (j = 0; j < n_conf_states; ++j) {
        CKij = count_matrices[KMM + i * n_conf_states + j];
        if (0 == CKij)
          continue;
        if (i == j) {
          a += ((double)CKij + 0) * log(T_ij[i * n_conf_states + j]);
        } else {
          a += CKij * log(T_ij[i * n_conf_states + j]);
        }
      }
    }
  }
  b = 0;
  for (K = 0; K < n_therm_states; ++K) {
    KM = K * n_conf_states;
    for (i = 0; i < n_conf_states; ++i) {
      Ki = KM + i;
      if (state_counts[Ki] > 0)
        b += (state_counts[Ki] + 0) * biased_conf_energies[Ki];
    }
  }
  return a + b;
}


x86 assembly (clang, -O0):
<_tram_discrete_log_likelihood_lower_bound>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    %r9d,-0x28(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    0x18(%rbp),%rax
mov    %rax,-0x60(%rbp)
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    12d6 <_tram_discrete_log_likelihood_lower_bound+0x1b6>
mov    -0x3c(%rbp),%eax
imul   -0x28(%rbp),%eax
mov    %eax,-0x48(%rbp)
mov    -0x48(%rbp),%eax
imul   -0x28(%rbp),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x8(%rbp),%rdi
movslq -0x48(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdi
mov    -0x10(%rbp),%rsi
movslq -0x48(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rsi
mov    -0x18(%rbp),%rdx
movslq -0x4c(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdx
mov    -0x28(%rbp),%ecx
mov    0x10(%rbp),%r8
mov    -0x60(%rbp),%r9
call   1030 <_tram_estimate_transition_matrix@plt>
movl   $0x0,-0x40(%rbp)
mov    -0x40(%rbp),%eax
cmp    -0x28(%rbp),%eax
jge    12c3 <_tram_discrete_log_likelihood_lower_bound+0x1a3>
movl   $0x0,-0x44(%rbp)
mov    -0x44(%rbp),%eax
cmp    -0x28(%rbp),%eax
jge    12b0 <_tram_discrete_log_likelihood_lower_bound+0x190>
mov    -0x18(%rbp),%rax
mov    -0x4c(%rbp),%ecx
mov    -0x40(%rbp),%edx
imul   -0x28(%rbp),%edx
add    %edx,%ecx
add    -0x44(%rbp),%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x54(%rbp)
xor    %eax,%eax
cmp    -0x54(%rbp),%eax
jne    120e <_tram_discrete_log_likelihood_lower_bound+0xee>
jmp    12a2 <_tram_discrete_log_likelihood_lower_bound+0x182>
mov    -0x40(%rbp),%eax
cmp    -0x44(%rbp),%eax
jne    1266 <_tram_discrete_log_likelihood_lower_bound+0x146>
cvtsi2sdl -0x54(%rbp),%xmm0
xorps  %xmm1,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
mov    -0x60(%rbp),%rax
mov    -0x40(%rbp),%ecx
imul   -0x28(%rbp),%ecx
add    -0x44(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
call   1040 <log@plt>
movsd  -0x68(%rbp),%xmm0
cvtsi2sd %eax,%xmm2
movsd  -0x30(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    129d <_tram_discrete_log_likelihood_lower_bound+0x17d>
mov    -0x54(%rbp),%eax
mov    %eax,-0x6c(%rbp)
mov    -0x60(%rbp),%rax
mov    -0x40(%rbp),%ecx
imul   -0x28(%rbp),%ecx
add    -0x44(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
call   1040 <log@plt>
mov    %eax,%ecx
mov    -0x6c(%rbp),%eax
imul   %ecx,%eax
cvtsi2sd %eax,%xmm0
addsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    12a2 <_tram_discrete_log_likelihood_lower_bound+0x182>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    11d6 <_tram_discrete_log_likelihood_lower_bound+0xb6>
jmp    12b5 <_tram_discrete_log_likelihood_lower_bound+0x195>
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    11c3 <_tram_discrete_log_likelihood_lower_bound+0xa3>
jmp    12c8 <_tram_discrete_log_likelihood_lower_bound+0x1a8>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    115f <_tram_discrete_log_likelihood_lower_bound+0x3f>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    1380 <_tram_discrete_log_likelihood_lower_bound+0x260>
mov    -0x3c(%rbp),%eax
imul   -0x28(%rbp),%eax
mov    %eax,-0x48(%rbp)
movl   $0x0,-0x40(%rbp)
mov    -0x40(%rbp),%eax
cmp    -0x28(%rbp),%eax
jge    136d <_tram_discrete_log_likelihood_lower_bound+0x24d>
mov    -0x48(%rbp),%eax
add    -0x40(%rbp),%eax
mov    %eax,-0x50(%rbp)
mov    -0x20(%rbp),%rax
movslq -0x50(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
jle    135a <_tram_discrete_log_likelihood_lower_bound+0x23a>
mov    -0x20(%rbp),%rax
movslq -0x50(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
add    $0x0,%eax
cvtsi2sd %eax,%xmm0
mov    -0x10(%rbp),%rax
movslq -0x50(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
movsd  -0x38(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    135f <_tram_discrete_log_likelihood_lower_bound+0x23f>
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    1302 <_tram_discrete_log_likelihood_lower_bound+0x1e2>
jmp    1372 <_tram_discrete_log_likelihood_lower_bound+0x252>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    12e5 <_tram_discrete_log_likelihood_lower_bound+0x1c5>
movsd  -0x30(%rbp),%xmm0
addsd  -0x38(%rbp),%xmm0
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_tram_discrete_log_likelihood_lower_bound>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x88,%rsp
mov    %rcx,0x38(%rsp)
mov    %rsi,0x20(%rsp)
mov    %rdi,0x58(%rsp)
test   %r8d,%r8d
jle    13eb <_tram_discrete_log_likelihood_lower_bound+0x2cb>
mov    %rdx,%rbx
mov    0xc8(%rsp),%r14
movslq %r9d,%rax
mov    %r8d,0x30(%rsp)
mov    %r8d,%ecx
mov    %rcx,0x40(%rsp)
mov    %eax,%ecx
mov    %rcx,0x18(%rsp)
mov    %eax,%ecx
imul   %ecx,%ecx
shl    $0x20,%rcx
mov    %rcx,0x50(%rsp)
mov    %rax,%rcx
shl    $0x20,%rcx
mov    %rcx,0x70(%rsp)
mov    %rax,0x10(%rsp)
lea    0x0(,%rax,8),%rax
mov    %rax,0x48(%rsp)
xorpd  %xmm0,%xmm0
xor    %r15d,%r15d
xor    %r12d,%r12d
mov    %r9d,0x34(%rsp)
jmp    11e1 <_tram_discrete_log_likelihood_lower_bound+0xc1>
nopl   0x0(%rax,%rax,1)
movsd  0x8(%rsp),%xmm0
mov    0x60(%rsp),%r12
add    $0x1,%r12
mov    0x68(%rsp),%r15
add    0x50(%rsp),%r15
cmp    0x40(%rsp),%r12
mov    0x34(%rsp),%r9d
mov    0xc8(%rsp),%r14
je     130d <_tram_discrete_log_likelihood_lower_bound+0x1ed>
movsd  %xmm0,0x8(%rsp)
mov    %r12,%rax
mov    0x10(%rsp),%rbp
imul   %rbp,%rax
mov    0x58(%rsp),%rcx
lea    (%rcx,%rax,8),%rdi
mov    0x20(%rsp),%rcx
lea    (%rcx,%rax,8),%rsi
imul   %rbp,%rax
lea    (%rbx,%rax,4),%rdx
mov    %ebp,%ecx
mov    0xc0(%rsp),%r8
mov    %r14,%r9
call   1030 <_tram_estimate_transition_matrix@plt>
test   %ebp,%ebp
mov    %r15,0x68(%rsp)
mov    %r12,0x60(%rsp)
jle    11b0 <_tram_discrete_log_likelihood_lower_bound+0x90>
mov    %r14,0x28(%rsp)
xor    %r14d,%r14d
movsd  0x8(%rsp),%xmm0
jmp    1268 <_tram_discrete_log_likelihood_lower_bound+0x148>
nopl   (%rax)
add    $0x1,%r14
mov    0x78(%rsp),%r15
add    0x70(%rsp),%r15
mov    0x28(%rsp),%rax
add    0x48(%rsp),%rax
mov    %rax,0x28(%rsp)
cmp    0x18(%rsp),%r14
je     11b6 <_tram_discrete_log_likelihood_lower_bound+0x96>
mov    %r14,%rbp
imul   0x10(%rsp),%rbp
add    %r14,%rbp
mov    %r15,0x78(%rsp)
xor    %r13d,%r13d
jmp    12bd <_tram_discrete_log_likelihood_lower_bound+0x19d>
xchg   %ax,%ax
mov    0x28(%rsp),%rax
movsd  (%rax,%r13,8),%xmm0
call   1040 <log@plt>
imul   %r12d,%eax
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
movsd  0x8(%rsp),%xmm0
addsd  %xmm1,%xmm0
add    $0x1,%r13
movabs $0x100000000,%rax
add    %rax,%r15
cmp    %r13,0x18(%rsp)
je     1240 <_tram_discrete_log_likelihood_lower_bound+0x120>
mov    %r15,%rax
sar    $0x1e,%rax
mov    (%rbx,%rax,1),%r12d
test   %r12d,%r12d
je     12a5 <_tram_discrete_log_likelihood_lower_bound+0x185>
movsd  %xmm0,0x8(%rsp)
cmp    %r13,%r14
jne    1280 <_tram_discrete_log_likelihood_lower_bound+0x160>
xorps  %xmm0,%xmm0
cvtsi2sd %r12d,%xmm0
movsd  %xmm0,0x80(%rsp)
mov    0xc8(%rsp),%rax
movsd  (%rax,%rbp,8),%xmm0
call   1040 <log@plt>
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
mulsd  0x80(%rsp),%xmm1
jmp    129b <_tram_discrete_log_likelihood_lower_bound+0x17b>
cmpl   $0x0,0x30(%rsp)
jle    13ef <_tram_discrete_log_likelihood_lower_bound+0x2cf>
mov    0x18(%rsp),%rax
and    $0xfffffffe,%eax
mov    0x20(%rsp),%rcx
add    $0x8,%rcx
mov    0x38(%rsp),%rdx
add    $0x4,%rdx
mov    0x10(%rsp),%rsi
lea    0x0(,%rsi,4),%r8
xorpd  %xmm2,%xmm2
xor    %esi,%esi
jmp    1367 <_tram_discrete_log_likelihood_lower_bound+0x247>
nopw   0x0(%rax,%rax,1)
add    $0x1,%rsi
add    0x48(%rsp),%rcx
add    %r8,%rdx
cmp    0x40(%rsp),%rsi
je     13f3 <_tram_discrete_log_likelihood_lower_bound+0x2d3>
test   %r9d,%r9d
jle    1350 <_tram_discrete_log_likelihood_lower_bound+0x230>
xor    %ebp,%ebp
cmp    $0x1,%r9d
jne    13b9 <_tram_discrete_log_likelihood_lower_bound+0x299>
testb  $0x1,0x18(%rsp)
je     1350 <_tram_discrete_log_likelihood_lower_bound+0x230>
mov    %rsi,%rdi
imul   0x10(%rsp),%rdi
add    %rdi,%rbp
mov    0x38(%rsp),%rdi
mov    (%rdi,%rbp,4),%ebx
test   %ebx,%ebx
jle    1350 <_tram_discrete_log_likelihood_lower_bound+0x230>
xorps  %xmm1,%xmm1
cvtsi2sd %ebx,%xmm1
mov    0x20(%rsp),%rdi
mulsd  (%rdi,%rbp,8),%xmm1
addsd  %xmm1,%xmm2
jmp    1350 <_tram_discrete_log_likelihood_lower_bound+0x230>
nopw   0x0(%rax,%rax,1)
add    $0x2,%rbp
cmp    %rbp,%rax
je     1374 <_tram_discrete_log_likelihood_lower_bound+0x254>
mov    -0x4(%rdx,%rbp,4),%ebx
test   %ebx,%ebx
jle    13d2 <_tram_discrete_log_likelihood_lower_bound+0x2b2>
xorps  %xmm1,%xmm1
cvtsi2sd %ebx,%xmm1
mulsd  -0x8(%rcx,%rbp,8),%xmm1
addsd  %xmm1,%xmm2
mov    (%rdx,%rbp,4),%ebx
test   %ebx,%ebx
jle    13b0 <_tram_discrete_log_likelihood_lower_bound+0x290>
xorps  %xmm1,%xmm1
cvtsi2sd %ebx,%xmm1
mulsd  (%rcx,%rbp,8),%xmm1
addsd  %xmm1,%xmm2
jmp    13b0 <_tram_discrete_log_likelihood_lower_bound+0x290>
xorpd  %xmm0,%xmm0
xorpd  %xmm2,%xmm2
addsd  %xmm2,%xmm0
add    $0x88,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define double @_tram_discrete_log_likelihood_lower_bound(double* %0, double* %1, i32* %2, i32* nocapture %3, i32 %4, i32 %5, double* %6, double* %7) {
%9 = icmp sgt i32 %4, 0
br i1 %9, label %10, label %129
10: ; preds = %8
%11 = icmp sgt i32 %5, 0
%12 = sext i32 %5 to i64
%13 = zext i32 %4 to i64
%14 = zext i32 %5 to i64
br label %24
15: ; preds = %72
br i1 %9, label %16, label %129
16: ; preds = %15
%17 = icmp sgt i32 %5, 0
%18 = sext i32 %5 to i64
%19 = zext i32 %4 to i64
%20 = and i64 %14, 1
%21 = icmp eq i32 %5, 1
%22 = and i64 %14, 4294967294
%23 = icmp eq i64 %20, 0
br label %76
24: ; preds = %10, %72
%25 = phi i64 [ 0, %10 ], [ %74, %72 ]
%26 = phi double [ 0.000000e+00, %10 ], [ %73, %72 ]
%27 = mul nsw i64 %25, %12
%28 = mul nsw i64 %27, %12
%29 = getelementptr inbounds double, double* %0, i64 %27
%30 = getelementptr inbounds double, double* %1, i64 %27
%31 = getelementptr inbounds i32, i32* %2, i64 %28
%32 = tail call i32 @_tram_estimate_transition_matrix(double* %29, double* %30, i32* %31, i32 %5, double* %6, double* %7)
br i1 %11, label %33, label %72
33: ; preds = %24, %69
%34 = phi i64 [ %70, %69 ], [ 0, %24 ]
%35 = phi double [ %66, %69 ], [ %26, %24 ]
%36 = mul nsw i64 %34, %12
%37 = add nsw i64 %34, %36
%38 = getelementptr inbounds double, double* %7, i64 %37
br label %39
39: ; preds = %33, %65
%40 = phi i64 [ 0, %33 ], [ %67, %65 ]
%41 = phi double [ %35, %33 ], [ %66, %65 ]
%42 = add i64 %40, %36
%43 = add i64 %42, %28
%44 = shl i64 %43, 32
%45 = ashr exact i64 %44, 32
%46 = getelementptr inbounds i32, i32* %2, i64 %45
%47 = load i32, i32* %46
%48 = icmp eq i32 %47, 0
br i1 %48, label %65, label %49
49: ; preds = %39
%50 = icmp eq i64 %34, %40
br i1 %50, label %51, label %57
51: ; preds = %49
%52 = sitofp i32 %47 to double
%53 = load double, double* %38
%54 = tail call i32 @log(double %53)
%55 = sitofp i32 %54 to double
%56 = tail call double @llvm.fmuladd.f64(double %52, double %55, double %41)
br label %65
57: ; preds = %49
%58 = add nsw i64 %40, %36
%59 = getelementptr inbounds double, double* %7, i64 %58
%60 = load double, double* %59
%61 = tail call i32 @log(double %60)
%62 = mul nsw i32 %61, %47
%63 = sitofp i32 %62 to double
%64 = fadd double %41, %63
br label %65
65: ; preds = %51, %57, %39
%66 = phi double [ %41, %39 ], [ %56, %51 ], [ %64, %57 ]
%67 = add nuw nsw i64 %40, 1
%68 = icmp eq i64 %67, %14
br i1 %68, label %69, label %39
69: ; preds = %65
%70 = add nuw nsw i64 %34, 1
%71 = icmp eq i64 %70, %14
br i1 %71, label %72, label %33
72: ; preds = %69, %24
%73 = phi double [ %26, %24 ], [ %66, %69 ]
%74 = add nuw nsw i64 %25, 1
%75 = icmp eq i64 %74, %13
br i1 %75, label %15, label %24
76: ; preds = %16, %125
%77 = phi i64 [ 0, %16 ], [ %127, %125 ]
%78 = phi double [ 0.000000e+00, %16 ], [ %126, %125 ]
%79 = mul nsw i64 %77, %18
br i1 %17, label %80, label %125
80: ; preds = %76
br i1 %21, label %111, label %81
81: ; preds = %80, %106
%82 = phi i64 [ %108, %106 ], [ 0, %80 ]
%83 = phi double [ %107, %106 ], [ %78, %80 ]
%84 = phi i64 [ %109, %106 ], [ 0, %80 ]
%85 = add nsw i64 %82, %79
%86 = getelementptr inbounds i32, i32* %3, i64 %85
%87 = load i32, i32* %86
%88 = icmp sgt i32 %87, 0
br i1 %88, label %89, label %94
89: ; preds = %81
%90 = sitofp i32 %87 to double
%91 = getelementptr inbounds double, double* %1, i64 %85
%92 = load double, double* %91
%93 = tail call double @llvm.fmuladd.f64(double %90, double %92, double %83)
br label %94
94: ; preds = %81, %89
%95 = phi double [ %93, %89 ], [ %83, %81 ]
%96 = or i64 %82, 1
%97 = add nsw i64 %96, %79
%98 = getelementptr inbounds i32, i32* %3, i64 %97
%99 = load i32, i32* %98
%100 = icmp sgt i32 %99, 0
br i1 %100, label %101, label %106
101: ; preds = %94
%102 = sitofp i32 %99 to double
%103 = getelementptr inbounds double, double* %1, i64 %97
%104 = load double, double* %103
%105 = tail call double @llvm.fmuladd.f64(double %102, double %104, double %95)
br label %106
106: ; preds = %101, %94
%107 = phi double [ %105, %101 ], [ %95, %94 ]
%108 = add nuw nsw i64 %82, 2
%109 = add i64 %84, 2
%110 = icmp eq i64 %109, %22
br i1 %110, label %111, label %81
111: ; preds = %106, %80
%112 = phi double [ undef, %80 ], [ %107, %106 ]
%113 = phi i64 [ 0, %80 ], [ %108, %106 ]
%114 = phi double [ %78, %80 ], [ %107, %106 ]
br i1 %23, label %125, label %115
115: ; preds = %111
%116 = add nsw i64 %113, %79
%117 = getelementptr inbounds i32, i32* %3, i64 %116
%118 = load i32, i32* %117
%119 = icmp sgt i32 %118, 0
br i1 %119, label %120, label %125
120: ; preds = %115
%121 = sitofp i32 %118 to double
%122 = getelementptr inbounds double, double* %1, i64 %116
%123 = load double, double* %122
%124 = tail call double @llvm.fmuladd.f64(double %121, double %123, double %114)
br label %125
125: ; preds = %111, %120, %115, %76
%126 = phi double [ %78, %76 ], [ %112, %111 ], [ %124, %120 ], [ %114, %115 ]
%127 = add nuw nsw i64 %77, 1
%128 = icmp eq i64 %127, %19
br i1 %128, label %129, label %76
129: ; preds = %125, %8, %15
%130 = phi double [ %73, %15 ], [ 0.000000e+00, %8 ], [ %73, %125 ]
%131 = phi double [ 0.000000e+00, %15 ], [ 0.000000e+00, %8 ], [ %126, %125 ]
%132 = fadd double %130, %131
ret double %132
}