#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*/ fprintf(int /*<<< orphan*/, char *, int, int, ...);
int /*<<< orphan*/ stderr;
void _tram_direct_get_Ref_K_i(double *lagrangian_mult,
                              double *biased_conf_weights, int *count_matrices,
                              int *state_counts, int n_therm_states,
                              int n_conf_states, double *R_K_i) {
  int i, j, K, Ki, Kj, KMM;
  int CCT_Kij, CKi;
  for (K = 0; K < n_therm_states; ++K) {
    KMM = K * n_conf_states * n_conf_states;
    for (i = 0; i < n_conf_states; ++i) {
      CKi = 0;
      Ki = K * n_conf_states + i;
      R_K_i[Ki] = 0.0;
      if (0 == state_counts[Ki])
        continue;
      for (j = 0; j < n_conf_states; ++j) {
        CCT_Kij = count_matrices[KMM + i * n_conf_states + j];
        CKi += count_matrices[KMM + j * n_conf_states + i];
        Kj = K * n_conf_states + j;
        if (i == j) {
          R_K_i[Ki] += CCT_Kij;
        } else {
          CCT_Kij += count_matrices[KMM + j * n_conf_states + i];
          if (0 < CCT_Kij) {
            if (lagrangian_mult[Ki] == 0 && lagrangian_mult[Kj] == 0)
              fprintf(stderr, "R:Warning nu[%d,%d]=nu[%d,%d]=0\n", K, i, K, j);
            if (biased_conf_weights[Ki] == 0)
              fprintf(stderr, "R:Warning Z[%d,%d]=0\n", K, i);
            if (biased_conf_weights[Kj] == 0)
              fprintf(stderr, "R:Warning Z[%d,%d]=0\n", K, j);
            R_K_i[Ki] +=
                (double)CCT_Kij /
                (1.0 + (lagrangian_mult[Ki] / lagrangian_mult[Kj]) *
                           (biased_conf_weights[Kj] / biased_conf_weights[Ki]));
          }
        }
      }
      R_K_i[Ki] += state_counts[Ki] - CKi;
      if (0 < R_K_i[Ki])
        R_K_i[Ki] /= biased_conf_weights[Ki];
    }
  }
}


x86 assembly (clang, -O0):
<_tram_direct_get_Ref_K_i>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
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)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    142e <_tram_direct_get_Ref_K_i+0x31e>
mov    -0x34(%rbp),%eax
imul   -0x28(%rbp),%eax
imul   -0x28(%rbp),%eax
mov    %eax,-0x40(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x28(%rbp),%eax
jge    141b <_tram_direct_get_Ref_K_i+0x30b>
movl   $0x0,-0x48(%rbp)
mov    -0x34(%rbp),%eax
imul   -0x28(%rbp),%eax
add    -0x2c(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    0x10(%rbp),%rax
movslq -0x38(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x20(%rbp),%rcx
movslq -0x38(%rbp),%rdx
xor    %eax,%eax
cmp    (%rcx,%rdx,4),%eax
jne    11a4 <_tram_direct_get_Ref_K_i+0x94>
jmp    140d <_tram_direct_get_Ref_K_i+0x2fd>
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x28(%rbp),%eax
jge    13a7 <_tram_direct_get_Ref_K_i+0x297>
mov    -0x18(%rbp),%rax
mov    -0x40(%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,-0x44(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x40(%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
add    -0x48(%rbp),%eax
mov    %eax,-0x48(%rbp)
mov    -0x34(%rbp),%eax
imul   -0x28(%rbp),%eax
add    -0x30(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x30(%rbp),%eax
jne    1227 <_tram_direct_get_Ref_K_i+0x117>
cvtsi2sdl -0x44(%rbp),%xmm0
mov    0x10(%rbp),%rax
movslq -0x38(%rbp),%rcx
addsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
jmp    1394 <_tram_direct_get_Ref_K_i+0x284>
mov    -0x18(%rbp),%rax
mov    -0x40(%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
add    -0x44(%rbp),%eax
mov    %eax,-0x44(%rbp)
xor    %eax,%eax
cmp    -0x44(%rbp),%eax
jge    138f <_tram_direct_get_Ref_K_i+0x27f>
mov    -0x8(%rbp),%rax
movslq -0x38(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    12b6 <_tram_direct_get_Ref_K_i+0x1a6>
jp     12b6 <_tram_direct_get_Ref_K_i+0x1a6>
mov    -0x8(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    12b6 <_tram_direct_get_Ref_K_i+0x1a6>
jp     12b6 <_tram_direct_get_Ref_K_i+0x1a6>
mov    0x2d48(%rip),%rax
mov    (%rax),%edi
mov    -0x34(%rbp),%edx
mov    -0x2c(%rbp),%ecx
mov    -0x34(%rbp),%r8d
mov    -0x30(%rbp),%r9d
lea    0xd59(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x10(%rbp),%rax
movslq -0x38(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    12f3 <_tram_direct_get_Ref_K_i+0x1e3>
jp     12f3 <_tram_direct_get_Ref_K_i+0x1e3>
mov    0x2d03(%rip),%rax
mov    (%rax),%edi
mov    -0x34(%rbp),%edx
mov    -0x2c(%rbp),%ecx
lea    0xd3d(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x10(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1330 <_tram_direct_get_Ref_K_i+0x220>
jp     1330 <_tram_direct_get_Ref_K_i+0x220>
mov    0x2cc6(%rip),%rax
mov    (%rax),%edi
mov    -0x34(%rbp),%edx
mov    -0x30(%rbp),%ecx
lea    0xd00(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
cvtsi2sdl -0x44(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x38(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x8(%rbp),%rax
movslq -0x3c(%rbp),%rcx
divsd  (%rax,%rcx,8),%xmm1
mov    -0x10(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
mov    -0x10(%rbp),%rax
movslq -0x38(%rbp),%rcx
divsd  (%rax,%rcx,8),%xmm2
mulsd  %xmm2,%xmm1
movsd  0xc8b(%rip),%xmm2
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
mov    0x10(%rbp),%rax
movslq -0x38(%rbp),%rcx
addsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
jmp    1394 <_tram_direct_get_Ref_K_i+0x284>
jmp    1399 <_tram_direct_get_Ref_K_i+0x289>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    11ab <_tram_direct_get_Ref_K_i+0x9b>
mov    -0x20(%rbp),%rax
movslq -0x38(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
sub    -0x48(%rbp),%eax
cvtsi2sd %eax,%xmm0
mov    0x10(%rbp),%rax
movslq -0x38(%rbp),%rcx
addsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    0x10(%rbp),%rax
movslq -0x38(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    1408 <_tram_direct_get_Ref_K_i+0x2f8>
mov    -0x10(%rbp),%rax
movslq -0x38(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    0x10(%rbp),%rax
movslq -0x38(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
jmp    140d <_tram_direct_get_Ref_K_i+0x2fd>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    115c <_tram_direct_get_Ref_K_i+0x4c>
jmp    1420 <_tram_direct_get_Ref_K_i+0x310>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    113b <_tram_direct_get_Ref_K_i+0x2b>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_tram_direct_get_Ref_K_i>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xa8,%rsp
mov    %r9d,0xc(%rsp)
mov    %rdx,0x60(%rsp)
mov    %rsi,0x18(%rsp)
mov    %rdi,0x48(%rsp)
test   %r8d,%r8d
jle    1480 <_tram_direct_get_Ref_K_i+0x370>
mov    0xe0(%rsp),%rdx
movslq 0xc(%rsp),%rax
mov    %r8d,%esi
mov    %rsi,0x80(%rsp)
mov    %eax,%esi
mov    %eax,%edi
imul   %eax,%edi
mov    %edi,0x50(%rsp)
lea    0x0(,%rax,8),%rdi
mov    %rdi,0x78(%rsp)
mov    %rax,%rdi
imul   %rax,%rdi
shl    $0x2,%rdi
mov    %rdi,0x70(%rsp)
mov    %rax,0x68(%rsp)
lea    0x0(,%rax,4),%rax
mov    %rax,0x90(%rsp)
xorpd  %xmm3,%xmm3
mov    0x60(%rsp),%rax
mov    %rax,0x20(%rsp)
mov    0x18(%rsp),%rdi
mov    0x48(%rsp),%rax
mov    %rax,0x28(%rsp)
movl   $0x0,0x8(%rsp)
xor    %eax,%eax
mov    %rax,0x10(%rsp)
mov    %rsi,0x30(%rsp)
mov    %rcx,0x88(%rsp)
jmp    121c <_tram_direct_get_Ref_K_i+0x10c>
xchg   %ax,%ax
mov    0x10(%rsp),%rbp
add    $0x1,%rbp
mov    0x8(%rsp),%eax
add    0x50(%rsp),%eax
mov    %eax,0x8(%rsp)
mov    0x78(%rsp),%rax
add    %rax,0x28(%rsp)
mov    0x58(%rsp),%rdi
add    %rax,%rdi
mov    0x20(%rsp),%rax
add    0x70(%rsp),%rax
mov    %rax,0x20(%rsp)
mov    %rbp,%rax
mov    %rbp,0x10(%rsp)
cmp    0x80(%rsp),%rbp
je     1480 <_tram_direct_get_Ref_K_i+0x370>
mov    %rdi,0x58(%rsp)
cmpl   $0x0,0xc(%rsp)
jle    11d0 <_tram_direct_get_Ref_K_i+0xc0>
mov    0x10(%rsp),%rax
imul   0x68(%rsp),%rax
mov    %rax,0x98(%rsp)
mov    0x20(%rsp),%rbp
mov    0x8(%rsp),%r15d
xor    %r8d,%r8d
jmp    1269 <_tram_direct_get_Ref_K_i+0x159>
nopw   0x0(%rax,%rax,1)
add    $0x1,%r8
add    $0x1,%r15d
add    0x90(%rsp),%rbp
cmp    %rsi,%r8
je     11d0 <_tram_direct_get_Ref_K_i+0xc0>
mov    0x98(%rsp),%rax
lea    (%r8,%rax,1),%rdi
movq   $0x0,(%rdx,%rdi,8)
cmpl   $0x0,(%rcx,%rdi,4)
je     1250 <_tram_direct_get_Ref_K_i+0x140>
xor    %r12d,%r12d
xorpd  %xmm0,%xmm0
mov    %r15d,0x54(%rsp)
xor    %ebx,%ebx
mov    %r8,0x40(%rsp)
mov    %rdi,0x38(%rsp)
mov    %rbp,0xa0(%rsp)
jmp    12d6 <_tram_direct_get_Ref_K_i+0x1c6>
cs nopw 0x0(%rax,%rax,1)
nop
xorps  %xmm1,%xmm1
cvtsi2sd %r13d,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rdx,%rdi,8)
add    %r14d,%ebx
add    $0x1,%r12
add    0xc(%rsp),%r15d
cmp    %r12,%rsi
je     1440 <_tram_direct_get_Ref_K_i+0x330>
mov    0x0(%rbp,%r12,4),%r13d
movslq %r15d,%rax
mov    0x60(%rsp),%rcx
mov    (%rcx,%rax,4),%r14d
cmp    %r12,%r8
je     12b0 <_tram_direct_get_Ref_K_i+0x1a0>
add    %r14d,%r13d
jle    12c1 <_tram_direct_get_Ref_K_i+0x1b1>
mov    0x48(%rsp),%rax
movsd  (%rax,%rdi,8),%xmm0
ucomisd %xmm3,%xmm0
jne    1356 <_tram_direct_get_Ref_K_i+0x246>
jp     1356 <_tram_direct_get_Ref_K_i+0x246>
mov    0x28(%rsp),%rax
movsd  (%rax,%r12,8),%xmm0
ucomisd %xmm3,%xmm0
jne    1356 <_tram_direct_get_Ref_K_i+0x246>
jp     1356 <_tram_direct_get_Ref_K_i+0x246>
mov    0x2cc3(%rip),%rax
mov    (%rax),%edi
lea    0xce2(%rip),%rsi
mov    0x10(%rsp),%rdx
mov    %r8d,%ecx
mov    %edx,%r8d
mov    %r12d,%r9d
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    0x38(%rsp),%rdi
mov    0x40(%rsp),%r8
xorpd  %xmm3,%xmm3
mov    0x30(%rsp),%rsi
mov    0xe0(%rsp),%rdx
mov    0x18(%rsp),%rax
movsd  (%rax,%rdi,8),%xmm0
ucomisd %xmm3,%xmm0
jne    13a2 <_tram_direct_get_Ref_K_i+0x292>
jp     13a2 <_tram_direct_get_Ref_K_i+0x292>
mov    0x2c71(%rip),%rax
mov    (%rax),%edi
lea    0xcb1(%rip),%rsi
mov    0x10(%rsp),%rdx
mov    %r8d,%ecx
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    0x38(%rsp),%rdi
mov    0x40(%rsp),%r8
xorpd  %xmm3,%xmm3
mov    0x30(%rsp),%rsi
mov    0xe0(%rsp),%rdx
mov    0x58(%rsp),%rbp
movsd  0x0(%rbp,%r12,8),%xmm1
ucomisd %xmm3,%xmm1
jne    13f7 <_tram_direct_get_Ref_K_i+0x2e7>
jp     13f7 <_tram_direct_get_Ref_K_i+0x2e7>
mov    0x2c23(%rip),%rax
mov    (%rax),%edi
lea    0xc63(%rip),%rsi
mov    0x10(%rsp),%rdx
mov    %r12d,%ecx
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    0x38(%rsp),%rdi
mov    0x40(%rsp),%r8
xorpd  %xmm3,%xmm3
mov    0x30(%rsp),%rsi
mov    0xe0(%rsp),%rdx
movsd  0x0(%rbp,%r12,8),%xmm1
xorps  %xmm0,%xmm0
cvtsi2sd %r13d,%xmm0
mov    0x48(%rsp),%rax
movsd  (%rax,%rdi,8),%xmm2
mov    0x28(%rsp),%rax
divsd  (%rax,%r12,8),%xmm2
mov    0x18(%rsp),%rax
divsd  (%rax,%rdi,8),%xmm1
mulsd  %xmm2,%xmm1
addsd  0xbd6(%rip),%xmm1
divsd  %xmm1,%xmm0
addsd  (%rdx,%rdi,8),%xmm0
mov    0xa0(%rsp),%rbp
jmp    12bc <_tram_direct_get_Ref_K_i+0x1ac>
mov    0x88(%rsp),%rcx
mov    (%rcx,%rdi,4),%eax
sub    %ebx,%eax
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rdx,%rdi,8)
ucomisd %xmm3,%xmm0
mov    0x54(%rsp),%r15d
jbe    1250 <_tram_direct_get_Ref_K_i+0x140>
mov    0x18(%rsp),%rax
divsd  (%rax,%rdi,8),%xmm0
movsd  %xmm0,(%rdx,%rdi,8)
jmp    1250 <_tram_direct_get_Ref_K_i+0x140>
add    $0xa8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [33 x i8] c"R:Warning nu[%d,%d]=nu[%d,%d]=0\0A\00"
@.str.1 = [22 x i8] c"R:Warning Z[%d,%d]=0\0A\00"
define void @_tram_direct_get_Ref_K_i(double* %0, double* %1, i32* %2, i32* %3, i32 %4, i32 %5, double* %6) {
%8 = alloca double*
%9 = alloca double*
%10 = alloca i32*
%11 = alloca i32*
%12 = alloca i32
%13 = alloca i32
%14 = alloca double*
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
%22 = alloca i32
store double* %0, double** %8
store double* %1, double** %9
store i32* %2, i32** %10
store i32* %3, i32** %11
store i32 %4, i32* %12
store i32 %5, i32* %13
store double* %6, double** %14
store i32 0, i32* %17
br label %23
23: ; preds = %238, %7
%24 = load i32, i32* %17
%25 = load i32, i32* %12
%26 = icmp slt i32 %24, %25
br i1 %26, label %27, label %241
27: ; preds = %23
%28 = load i32, i32* %17
%29 = load i32, i32* %13
%30 = mul nsw i32 %28, %29
%31 = load i32, i32* %13
%32 = mul nsw i32 %30, %31
store i32 %32, i32* %20
store i32 0, i32* %15
br label %33
33: ; preds = %234, %27
%34 = load i32, i32* %15
%35 = load i32, i32* %13
%36 = icmp slt i32 %34, %35
br i1 %36, label %37, label %237
37: ; preds = %33
store i32 0, i32* %22
%38 = load i32, i32* %17
%39 = load i32, i32* %13
%40 = mul nsw i32 %38, %39
%41 = load i32, i32* %15
%42 = add nsw i32 %40, %41
store i32 %42, i32* %18
%43 = load double*, double** %14
%44 = load i32, i32* %18
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds double, double* %43, i64 %45
store double 0.000000e+00, double* %46
%47 = load i32*, i32** %11
%48 = load i32, i32* %18
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds i32, i32* %47, i64 %49
%51 = load i32, i32* %50
%52 = icmp eq i32 0, %51
br i1 %52, label %53, label %54
53: ; preds = %37
br label %234
54: ; preds = %37
store i32 0, i32* %16
br label %55
55: ; preds = %197, %54
%56 = load i32, i32* %16
%57 = load i32, i32* %13
%58 = icmp slt i32 %56, %57
br i1 %58, label %59, label %200
59: ; preds = %55
%60 = load i32*, i32** %10
%61 = load i32, i32* %20
%62 = load i32, i32* %15
%63 = load i32, i32* %13
%64 = mul nsw i32 %62, %63
%65 = add nsw i32 %61, %64
%66 = load i32, i32* %16
%67 = add nsw i32 %65, %66
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds i32, i32* %60, i64 %68
%70 = load i32, i32* %69
store i32 %70, i32* %21
%71 = load i32*, i32** %10
%72 = load i32, i32* %20
%73 = load i32, i32* %16
%74 = load i32, i32* %13
%75 = mul nsw i32 %73, %74
%76 = add nsw i32 %72, %75
%77 = load i32, i32* %15
%78 = add nsw i32 %76, %77
%79 = sext i32 %78 to i64
%80 = getelementptr inbounds i32, i32* %71, i64 %79
%81 = load i32, i32* %80
%82 = load i32, i32* %22
%83 = add nsw i32 %82, %81
store i32 %83, i32* %22
%84 = load i32, i32* %17
%85 = load i32, i32* %13
%86 = mul nsw i32 %84, %85
%87 = load i32, i32* %16
%88 = add nsw i32 %86, %87
store i32 %88, i32* %19
%89 = load i32, i32* %15
%90 = load i32, i32* %16
%91 = icmp eq i32 %89, %90
br i1 %91, label %92, label %101
92: ; preds = %59
%93 = load i32, i32* %21
%94 = sitofp i32 %93 to double
%95 = load double*, double** %14
%96 = load i32, i32* %18
%97 = sext i32 %96 to i64
%98 = getelementptr inbounds double, double* %95, i64 %97
%99 = load double, double* %98
%100 = fadd double %99, %94
store double %100, double* %98
br label %196
101: ; preds = %59
%102 = load i32*, i32** %10
%103 = load i32, i32* %20
%104 = load i32, i32* %16
%105 = load i32, i32* %13
%106 = mul nsw i32 %104, %105
%107 = add nsw i32 %103, %106
%108 = load i32, i32* %15
%109 = add nsw i32 %107, %108
%110 = sext i32 %109 to i64
%111 = getelementptr inbounds i32, i32* %102, i64 %110
%112 = load i32, i32* %111
%113 = load i32, i32* %21
%114 = add nsw i32 %113, %112
store i32 %114, i32* %21
%115 = load i32, i32* %21
%116 = icmp slt i32 0, %115
br i1 %116, label %117, label %195
117: ; preds = %101
%118 = load double*, double** %8
%119 = load i32, i32* %18
%120 = sext i32 %119 to i64
%121 = getelementptr inbounds double, double* %118, i64 %120
%122 = load double, double* %121
%123 = fcmp oeq double %122, 0.000000e+00
br i1 %123, label %124, label %138
124: ; preds = %117
%125 = load double*, double** %8
%126 = load i32, i32* %19
%127 = sext i32 %126 to i64
%128 = getelementptr inbounds double, double* %125, i64 %127
%129 = load double, double* %128
%130 = fcmp oeq double %129, 0.000000e+00
br i1 %130, label %131, label %138
131: ; preds = %124
%132 = load i32, i32* @stderr
%133 = load i32, i32* %17
%134 = load i32, i32* %15
%135 = load i32, i32* %17
%136 = load i32, i32* %16
%137 = call i32 (i32, i8*, i32, i32, ...) @fprintf(i32 %132, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i32 %133, i32 %134, i32 %135, i32 %136)
br label %138
138: ; preds = %131, %124, %117
%139 = load double*, double** %9
%140 = load i32, i32* %18
%141 = sext i32 %140 to i64
%142 = getelementptr inbounds double, double* %139, i64 %141
%143 = load double, double* %142
%144 = fcmp oeq double %143, 0.000000e+00
br i1 %144, label %145, label %150
145: ; preds = %138
%146 = load i32, i32* @stderr
%147 = load i32, i32* %17
%148 = load i32, i32* %15
%149 = call i32 (i32, i8*, i32, i32, ...) @fprintf(i32 %146, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 %147, i32 %148)
br label %150
150: ; preds = %145, %138
%151 = load double*, double** %9
%152 = load i32, i32* %19
%153 = sext i32 %152 to i64
%154 = getelementptr inbounds double, double* %151, i64 %153
%155 = load double, double* %154
%156 = fcmp oeq double %155, 0.000000e+00
br i1 %156, label %157, label %162
157: ; preds = %150
%158 = load i32, i32* @stderr
%159 = load i32, i32* %17
%160 = load i32, i32* %16
%161 = call i32 (i32, i8*, i32, i32, ...) @fprintf(i32 %158, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 %159, i32 %160)
br label %162
162: ; preds = %157, %150
%163 = load i32, i32* %21
%164 = sitofp i32 %163 to double
%165 = load double*, double** %8
%166 = load i32, i32* %18
%167 = sext i32 %166 to i64
%168 = getelementptr inbounds double, double* %165, i64 %167
%169 = load double, double* %168
%170 = load double*, double** %8
%171 = load i32, i32* %19
%172 = sext i32 %171 to i64
%173 = getelementptr inbounds double, double* %170, i64 %172
%174 = load double, double* %173
%175 = fdiv double %169, %174
%176 = load double*, double** %9
%177 = load i32, i32* %19
%178 = sext i32 %177 to i64
%179 = getelementptr inbounds double, double* %176, i64 %178
%180 = load double, double* %179
%181 = load double*, double** %9
%182 = load i32, i32* %18
%183 = sext i32 %182 to i64
%184 = getelementptr inbounds double, double* %181, i64 %183
%185 = load double, double* %184
%186 = fdiv double %180, %185
%187 = call double @llvm.fmuladd.f64(double %175, double %186, double 1.000000e+00)
%188 = fdiv double %164, %187
%189 = load double*, double** %14
%190 = load i32, i32* %18
%191 = sext i32 %190 to i64
%192 = getelementptr inbounds double, double* %189, i64 %191
%193 = load double, double* %192
%194 = fadd double %193, %188
store double %194, double* %192
br label %195
195: ; preds = %162, %101
br label %196
196: ; preds = %195, %92
br label %197
197: ; preds = %196
%198 = load i32, i32* %16
%199 = add nsw i32 %198, 1
store i32 %199, i32* %16
br label %55
200: ; preds = %55
%201 = load i32*, i32** %11
%202 = load i32, i32* %18
%203 = sext i32 %202 to i64
%204 = getelementptr inbounds i32, i32* %201, i64 %203
%205 = load i32, i32* %204
%206 = load i32, i32* %22
%207 = sub nsw i32 %205, %206
%208 = sitofp i32 %207 to double
%209 = load double*, double** %14
%210 = load i32, i32* %18
%211 = sext i32 %210 to i64
%212 = getelementptr inbounds double, double* %209, i64 %211
%213 = load double, double* %212
%214 = fadd double %213, %208
store double %214, double* %212
%215 = load double*, double** %14
%216 = load i32, i32* %18
%217 = sext i32 %216 to i64
%218 = getelementptr inbounds double, double* %215, i64 %217
%219 = load double, double* %218
%220 = fcmp olt double 0.000000e+00, %219
br i1 %220, label %221, label %233
221: ; preds = %200
%222 = load double*, double** %9
%223 = load i32, i32* %18
%224 = sext i32 %223 to i64
%225 = getelementptr inbounds double, double* %222, i64 %224
%226 = load double, double* %225
%227 = load double*, double** %14
%228 = load i32, i32* %18
%229 = sext i32 %228 to i64
%230 = getelementptr inbounds double, double* %227, i64 %229
%231 = load double, double* %230
%232 = fdiv double %231, %226
store double %232, double* %230
br label %233
233: ; preds = %221, %200
br label %234
234: ; preds = %233, %53
%235 = load i32, i32* %15
%236 = add nsw i32 %235, 1
store i32 %236, i32* %15
br label %33
237: ; preds = %33
br label %238
238: ; preds = %237
%239 = load i32, i32* %17
%240 = add nsw i32 %239, 1
store i32 %240, i32* %17
br label %23
241: ; preds = %23
ret void
}

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