#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 */
double _logsumexp_pair(double, double);
double _logsumexp_sort_kahan_inplace(double *, int);
double log(int);
extern void _dtram_update_conf_energies(double *log_lagrangian_mult,
                                        double *bias_energies,
                                        double *conf_energies,
                                        int *count_matrices, int n_therm_states,
                                        int n_conf_states, double *scratch_TM,
                                        double *new_conf_energies) {
  int i, j, K, o;
  int MM = n_conf_states * n_conf_states, Ki, Kj;
  int CK, CKij, CKji, Ci;
  double divisor;
  for (i = 0; i < n_conf_states; ++i) {
    Ci = 0;
    o = 0;
    for (K = 0; K < n_therm_states; ++K) {
      Ki = K * n_conf_states + i;
      for (j = 0; j < n_conf_states; ++j) {
        Kj = K * n_conf_states + j;
        CKij = count_matrices[K * MM + i * n_conf_states + j];
        CKji = count_matrices[K * MM + j * n_conf_states + i];
        Ci += CKji;
        if (i == j) {
          scratch_TM[o] =
              (0 == CKij) ? -23.025850929940457 : log(1.0E-10 + (double)CKij);
          scratch_TM[o++] += conf_energies[i];
          continue;
        }
        CK = CKij + CKji;
        if (0 == CK)
          continue;
        divisor = _logsumexp_pair(
            log_lagrangian_mult[Kj] - conf_energies[i] - bias_energies[Ki],
            log_lagrangian_mult[Ki] - conf_energies[j] - bias_energies[Kj]);
        scratch_TM[o++] = log((double)CK) - bias_energies[Ki] +
                          log_lagrangian_mult[Kj] - divisor;
      }
    }
    new_conf_energies[i] = _logsumexp_sort_kahan_inplace(scratch_TM, o) -
                           log(n_therm_states * 1.0E-10 + (double)Ci);
  }
}


x86 assembly (clang, -O0):
<_dtram_update_conf_energies>:
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)
mov    -0x28(%rbp),%eax
imul   -0x28(%rbp),%eax
mov    %eax,-0x3c(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x28(%rbp),%eax
jge    13c5 <_dtram_update_conf_energies+0x295>
movl   $0x0,-0x54(%rbp)
movl   $0x0,-0x38(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    136a <_dtram_update_conf_energies+0x23a>
mov    -0x34(%rbp),%eax
imul   -0x28(%rbp),%eax
add    -0x2c(%rbp),%eax
mov    %eax,-0x40(%rbp)
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x28(%rbp),%eax
jge    1357 <_dtram_update_conf_energies+0x227>
mov    -0x34(%rbp),%eax
imul   -0x28(%rbp),%eax
add    -0x30(%rbp),%eax
mov    %eax,-0x44(%rbp)
mov    -0x20(%rbp),%rax
mov    -0x34(%rbp),%ecx
imul   -0x3c(%rbp),%ecx
mov    -0x2c(%rbp),%edx
imul   -0x28(%rbp),%edx
add    %edx,%ecx
add    -0x30(%rbp),%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x20(%rbp),%rax
mov    -0x34(%rbp),%ecx
imul   -0x3c(%rbp),%ecx
mov    -0x30(%rbp),%edx
imul   -0x28(%rbp),%edx
add    %edx,%ecx
add    -0x2c(%rbp),%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x50(%rbp)
mov    -0x50(%rbp),%eax
add    -0x54(%rbp),%eax
mov    %eax,-0x54(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x30(%rbp),%eax
jne    1294 <_dtram_update_conf_energies+0x164>
xor    %eax,%eax
cmp    -0x4c(%rbp),%eax
jne    1235 <_dtram_update_conf_energies+0x105>
movsd  0xddd(%rip),%xmm0
movsd  %xmm0,-0x68(%rbp)
jmp    1254 <_dtram_update_conf_energies+0x124>
cvtsi2sdl -0x4c(%rbp),%xmm1
movsd  0xdbe(%rip),%xmm0
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1050 <log@plt>
movsd  %xmm0,-0x68(%rbp)
movsd  -0x68(%rbp),%xmm0
mov    0x10(%rbp),%rax
movslq -0x38(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x18(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    0x10(%rbp),%rax
mov    -0x38(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x38(%rbp)
movslq %ecx,%rcx
addsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
jmp    1349 <_dtram_update_conf_energies+0x219>
mov    -0x4c(%rbp),%eax
add    -0x50(%rbp),%eax
mov    %eax,-0x48(%rbp)
xor    %eax,%eax
cmp    -0x48(%rbp),%eax
jne    12ad <_dtram_update_conf_energies+0x17d>
jmp    1349 <_dtram_update_conf_energies+0x219>
mov    -0x8(%rbp),%rax
movslq -0x44(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x2c(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x40(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x40(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x18(%rbp),%rax
movslq -0x30(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm1
mov    -0x10(%rbp),%rax
movslq -0x44(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm1
call   1040 <_logsumexp_pair@plt>
movsd  %xmm0,-0x60(%rbp)
cvtsi2sdl -0x48(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1050 <log@plt>
mov    -0x10(%rbp),%rax
movslq -0x40(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x44(%rbp),%rcx
addsd  (%rax,%rcx,8),%xmm0
subsd  -0x60(%rbp),%xmm0
mov    0x10(%rbp),%rax
mov    -0x38(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x38(%rbp)
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    11aa <_dtram_update_conf_energies+0x7a>
jmp    135c <_dtram_update_conf_energies+0x22c>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    118a <_dtram_update_conf_energies+0x5a>
mov    0x10(%rbp),%rdi
mov    -0x38(%rbp),%esi
call   1030 <_logsumexp_sort_kahan_inplace@plt>
movsd  %xmm0,-0x70(%rbp)
cvtsi2sdl -0x24(%rbp),%xmm0
cvtsi2sdl -0x54(%rbp),%xmm1
movsd  0xc73(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1050 <log@plt>
movaps %xmm0,%xmm1
movsd  -0x70(%rbp),%xmm0
subsd  %xmm1,%xmm0
mov    0x18(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1169 <_dtram_update_conf_energies+0x39>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_dtram_update_conf_energies>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xb8,%rsp
mov    %r8d,0x10(%rsp)
mov    %rcx,0x68(%rsp)
mov    %rdx,0x60(%rsp)
mov    %rsi,0x20(%rsp)
mov    %rdi,0x50(%rsp)
mov    %r9d,0x14(%rsp)
test   %r9d,%r9d
jle    143e <_dtram_update_conf_energies+0x30e>
mov    0x10(%rsp),%ecx
cvtsi2sd %ecx,%xmm0
mov    0xf0(%rsp),%r13
mov    0x14(%rsp),%eax
mov    %eax,%edx
mov    %ecx,%ecx
mov    %rcx,0x90(%rsp)
imul   %eax,%eax
mov    %eax,0x3c(%rsp)
lea    0x0(,%rdx,4),%rax
mov    %rax,0x78(%rsp)
mov    %rdx,0x48(%rsp)
lea    0x0(,%rdx,8),%rax
mov    %rax,0x88(%rsp)
xor    %eax,%eax
mov    %rax,0x70(%rsp)
mulsd  0xe48(%rip),%xmm0
movsd  %xmm0,0x80(%rsp)
mov    0x68(%rsp),%rax
mov    %rax,0x18(%rsp)
xor    %eax,%eax
mov    %rax,0x8(%rsp)
jmp    124c <_dtram_update_conf_energies+0x11c>
nopl   0x0(%rax)
mov    %r13,%rdi
call   1030 <_logsumexp_sort_kahan_inplace@plt>
xorps  %xmm1,%xmm1
cvtsi2sd %ebp,%xmm1
movsd  %xmm0,0x30(%rsp)
addsd  0x80(%rsp),%xmm1
cvttsd2si %xmm1,%edi
call   1050 <log@plt>
movsd  0x30(%rsp),%xmm1
subsd  %xmm0,%xmm1
mov    0xf8(%rsp),%rax
mov    0x8(%rsp),%rcx
movsd  %xmm1,(%rax,%rcx,8)
add    $0x1,%rcx
addq   $0x4,0x70(%rsp)
mov    0x18(%rsp),%rax
add    0x78(%rsp),%rax
mov    %rax,0x18(%rsp)
mov    %rcx,0x8(%rsp)
cmp    0x48(%rsp),%rcx
je     143e <_dtram_update_conf_energies+0x30e>
mov    $0x0,%esi
mov    $0x0,%ebp
cmpl   $0x0,0x10(%rsp)
jle    11e0 <_dtram_update_conf_energies+0xb0>
xor    %ecx,%ecx
mov    0x20(%rsp),%rax
mov    %rax,0x58(%rsp)
mov    0x50(%rsp),%rax
mov    %rax,0x28(%rsp)
mov    0x8(%rsp),%rax
mov    %eax,%r15d
xor    %edx,%edx
xor    %ebp,%ebp
xor    %esi,%esi
jmp    12d2 <_dtram_update_conf_energies+0x1a2>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0x98(%rsp),%rdx
add    $0x1,%rdx
mov    0x3c(%rsp),%eax
mov    0x40(%rsp),%r15d
add    %eax,%r15d
mov    0xa0(%rsp),%rcx
add    %eax,%ecx
mov    0x88(%rsp),%rax
add    %rax,0x28(%rsp)
add    %rax,0x58(%rsp)
cmp    0x90(%rsp),%rdx
je     11e0 <_dtram_update_conf_energies+0xb0>
mov    %rcx,0xa0(%rsp)
movslq %ecx,%rax
mov    0x18(%rsp),%rcx
lea    (%rcx,%rax,4),%rax
mov    %rax,0x30(%rsp)
mov    %rdx,0x98(%rsp)
imul   0x48(%rsp),%rdx
add    0x8(%rsp),%rdx
mov    %rdx,0xa8(%rsp)
xor    %r14d,%r14d
mov    %r15d,0x40(%rsp)
jmp    1349 <_dtram_update_conf_energies+0x219>
movslq %esi,%rax
movsd  %xmm0,0x0(%r13,%rax,8)
add    $0x1,%esi
mov    0x60(%rsp),%rcx
mov    0x8(%rsp),%rdx
addsd  (%rcx,%rdx,8),%xmm0
movsd  %xmm0,0x0(%r13,%rax,8)
add    %ebx,%ebp
add    0x14(%rsp),%r15d
add    $0x4,%r14
cmp    %r14,0x78(%rsp)
je     1290 <_dtram_update_conf_energies+0x160>
mov    0x30(%rsp),%rax
mov    (%rax,%r14,1),%r12d
movslq %r15d,%rax
mov    0x68(%rsp),%rcx
mov    (%rcx,%rax,4),%ebx
cmp    %r14,0x70(%rsp)
jne    13a0 <_dtram_update_conf_energies+0x270>
movsd  0xc94(%rip),%xmm0
test   %r12d,%r12d
je     1310 <_dtram_update_conf_energies+0x1e0>
xorps  %xmm0,%xmm0
cvtsi2sd %r12d,%xmm0
addsd  0xc87(%rip),%xmm0
cvttsd2si %xmm0,%edi
mov    %esi,%r12d
call   1050 <log@plt>
mov    %r12d,%esi
jmp    1310 <_dtram_update_conf_energies+0x1e0>
cs nopw 0x0(%rax,%rax,1)
nop
add    %ebx,%r12d
je     1333 <_dtram_update_conf_energies+0x203>
mov    0x28(%rsp),%rax
movsd  (%rax,%r14,2),%xmm0
mov    0x60(%rsp),%rax
mov    0x8(%rsp),%rcx
subsd  (%rax,%rcx,8),%xmm0
mov    0xa8(%rsp),%r13
mov    0x20(%rsp),%rcx
subsd  (%rcx,%r13,8),%xmm0
mov    0x50(%rsp),%rcx
movsd  (%rcx,%r13,8),%xmm1
subsd  (%rax,%r14,2),%xmm1
mov    0x58(%rsp),%rax
subsd  (%rax,%r14,2),%xmm1
mov    %esi,0x44(%rsp)
call   1040 <_logsumexp_pair@plt>
movsd  %xmm0,0xb0(%rsp)
mov    %r12d,%edi
call   1050 <log@plt>
mov    0x44(%rsp),%esi
mov    0x20(%rsp),%rax
subsd  (%rax,%r13,8),%xmm0
mov    0xf0(%rsp),%r13
mov    0x28(%rsp),%rax
addsd  (%rax,%r14,2),%xmm0
subsd  0xb0(%rsp),%xmm0
movslq %esi,%rax
add    $0x1,%esi
jmp    132c <_dtram_update_conf_energies+0x1fc>
add    $0xb8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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