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


x86 assembly (clang, -O0):
<_dtram_update_log_lagrangian_mult>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%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    1367 <_dtram_update_log_lagrangian_mult+0x237>
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    1354 <_dtram_update_log_lagrangian_mult+0x224>
mov    -0x34(%rbp),%eax
imul   -0x28(%rbp),%eax
add    -0x2c(%rbp),%eax
mov    %eax,-0x40(%rbp)
movl   $0x0,-0x38(%rbp)
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x28(%rbp),%eax
jge    132d <_dtram_update_log_lagrangian_mult+0x1fd>
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    -0x2c(%rbp),%eax
cmp    -0x30(%rbp),%eax
jne    1254 <_dtram_update_log_lagrangian_mult+0x124>
xor    %eax,%eax
cmp    -0x4c(%rbp),%eax
jne    1218 <_dtram_update_log_lagrangian_mult+0xe8>
movsd  0xdfa(%rip),%xmm0
movsd  %xmm0,-0x60(%rbp)
jmp    1233 <_dtram_update_log_lagrangian_mult+0x103>
cvtsi2sdl -0x4c(%rbp),%xmm1
movsd  0xddb(%rip),%xmm0
addsd  %xmm1,%xmm0
call   1050 <log@plt>
movsd  %xmm0,-0x60(%rbp)
movsd  -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)
jmp    131f <_dtram_update_log_lagrangian_mult+0x1ef>
mov    -0x4c(%rbp),%eax
add    -0x50(%rbp),%eax
mov    %eax,-0x48(%rbp)
mov    -0x34(%rbp),%eax
imul   -0x28(%rbp),%eax
add    -0x30(%rbp),%eax
mov    %eax,-0x44(%rbp)
xor    %eax,%eax
cmp    -0x48(%rbp),%eax
jne    127a <_dtram_update_log_lagrangian_mult+0x14a>
jmp    131f <_dtram_update_log_lagrangian_mult+0x1ef>
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,-0x58(%rbp)
cvtsi2sdl -0x48(%rbp),%xmm0
call   1050 <log@plt>
mov    -0x10(%rbp),%rax
movslq -0x44(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x30(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x40(%rbp),%rcx
addsd  (%rax,%rcx,8),%xmm0
subsd  -0x58(%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    11a3 <_dtram_update_log_lagrangian_mult+0x73>
mov    0x10(%rbp),%rdi
mov    -0x38(%rbp),%esi
call   1030 <_logsumexp_sort_kahan_inplace@plt>
mov    0x18(%rbp),%rax
movslq -0x40(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    117c <_dtram_update_log_lagrangian_mult+0x4c>
jmp    1359 <_dtram_update_log_lagrangian_mult+0x229>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1169 <_dtram_update_log_lagrangian_mult+0x39>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_dtram_update_log_lagrangian_mult>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xa8,%rsp
mov    %r8d,0x8(%rsp)
mov    %rcx,0x58(%rsp)
mov    %rdx,0x90(%rsp)
mov    %rsi,0x38(%rsp)
mov    %rdi,0x10(%rsp)
mov    %r9d,0xc(%rsp)
test   %r9d,%r9d
jle    13d0 <_dtram_update_log_lagrangian_mult+0x2a0>
mov    0xe0(%rsp),%rbx
mov    0xc(%rsp),%eax
mov    %eax,%ecx
mov    0x8(%rsp),%edx
mov    %rdx,0x78(%rsp)
imul   %eax,%eax
mov    %eax,0x1c(%rsp)
lea    0x0(,%rcx,4),%rax
mov    %rax,0x68(%rsp)
mov    %rcx,0x30(%rsp)
lea    0x0(,%rcx,8),%rax
mov    %rax,0x70(%rsp)
xor    %eax,%eax
mov    %rax,0x60(%rsp)
mov    0x58(%rsp),%rax
mov    %rax,0x28(%rsp)
xor    %eax,%eax
mov    %rax,(%rsp)
jmp    11fa <_dtram_update_log_lagrangian_mult+0xca>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    (%rsp),%rcx
add    $0x1,%rcx
addq   $0x4,0x60(%rsp)
mov    0x68(%rsp),%rax
add    %rax,0x28(%rsp)
mov    %rcx,%rax
mov    %rcx,(%rsp)
cmp    0x30(%rsp),%rcx
je     13d0 <_dtram_update_log_lagrangian_mult+0x2a0>
cmpl   $0x0,0x8(%rsp)
jle    11d0 <_dtram_update_log_lagrangian_mult+0xa0>
xor    %ecx,%ecx
mov    0x38(%rsp),%rax
mov    %rax,0x48(%rsp)
mov    0x10(%rsp),%rax
mov    %rax,0x40(%rsp)
mov    (%rsp),%rax
mov    %eax,%r14d
xor    %edx,%edx
jmp    1288 <_dtram_update_log_lagrangian_mult+0x158>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rbx,%rdi
mov    %ebp,%esi
call   1030 <_logsumexp_sort_kahan_inplace@plt>
mov    0xe8(%rsp),%rax
mov    0x50(%rsp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    0x80(%rsp),%rdx
add    $0x1,%rdx
mov    0x1c(%rsp),%eax
mov    0x20(%rsp),%r14d
add    %eax,%r14d
mov    0x88(%rsp),%rcx
add    %eax,%ecx
mov    0x70(%rsp),%rax
add    %rax,0x40(%rsp)
add    %rax,0x48(%rsp)
cmp    0x78(%rsp),%rdx
je     11d0 <_dtram_update_log_lagrangian_mult+0xa0>
mov    %rcx,0x88(%rsp)
movslq %ecx,%rax
mov    0x28(%rsp),%rcx
lea    (%rcx,%rax,4),%r12
mov    %rdx,0x80(%rsp)
imul   0x30(%rsp),%rdx
add    (%rsp),%rdx
mov    %rdx,0x50(%rsp)
xor    %r13d,%r13d
mov    %r14d,0x20(%rsp)
xor    %ebp,%ebp
mov    %r12,0x98(%rsp)
jmp    12ef <_dtram_update_log_lagrangian_mult+0x1bf>
nopw   0x0(%rax,%rax,1)
movslq %ebp,%rax
add    $0x1,%ebp
movsd  %xmm0,(%rbx,%rax,8)
add    0xc(%rsp),%r14d
add    $0x4,%r13
cmp    %r13,0x68(%rsp)
je     1230 <_dtram_update_log_lagrangian_mult+0x100>
mov    (%r12,%r13,1),%r15d
cmp    %r13,0x60(%rsp)
jne    1320 <_dtram_update_log_lagrangian_mult+0x1f0>
movsd  0xcfe(%rip),%xmm0
test   %r15d,%r15d
je     12d0 <_dtram_update_log_lagrangian_mult+0x1a0>
xorps  %xmm0,%xmm0
cvtsi2sd %r15d,%xmm0
addsd  0xcf1(%rip),%xmm0
call   1050 <log@plt>
jmp    12d0 <_dtram_update_log_lagrangian_mult+0x1a0>
xchg   %ax,%ax
movslq %r14d,%rax
mov    0x58(%rsp),%rcx
add    (%rcx,%rax,4),%r15d
je     12db <_dtram_update_log_lagrangian_mult+0x1ab>
mov    0x40(%rsp),%rax
movsd  (%rax,%r13,2),%xmm0
mov    0x90(%rsp),%rbx
mov    (%rsp),%rax
subsd  (%rbx,%rax,8),%xmm0
mov    0x38(%rsp),%rax
mov    %ebp,0x24(%rsp)
mov    0x50(%rsp),%r12
subsd  (%rax,%r12,8),%xmm0
mov    0x10(%rsp),%rax
movsd  (%rax,%r12,8),%xmm1
subsd  (%rbx,%r13,2),%xmm1
mov    0x48(%rsp),%rbp
subsd  0x0(%rbp,%r13,2),%xmm1
call   1040 <_logsumexp_pair@plt>
movsd  %xmm0,0xa0(%rsp)
xorps  %xmm0,%xmm0
cvtsi2sd %r15d,%xmm0
call   1050 <log@plt>
subsd  0x0(%rbp,%r13,2),%xmm0
subsd  (%rbx,%r13,2),%xmm0
mov    0xe0(%rsp),%rbx
mov    0x10(%rsp),%rax
addsd  (%rax,%r12,8),%xmm0
mov    0x24(%rsp),%ebp
mov    0x98(%rsp),%r12
subsd  0xa0(%rsp),%xmm0
jmp    12d0 <_dtram_update_log_lagrangian_mult+0x1a0>
add    $0xa8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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