#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 _kahan_summation(double *, int);
int /*<<< orphan*/ _mixed_sort(double *, int /*<<< orphan*/, int);
extern void _renormalize_transition_matrix(double *p, int n_conf_states,
                                           double *scratch_M) {
  int i, j;
  double sum, max_sum = 0.0;
  for (i = 0; i < n_conf_states; ++i) {
    for (j = 0; j < n_conf_states; ++j)
      scratch_M[j] = p[i * n_conf_states + j];
    _mixed_sort(scratch_M, 0, n_conf_states - 1);
    sum = _kahan_summation(scratch_M, n_conf_states);
    max_sum = (max_sum > sum) ? max_sum : sum;
  }
  if (0.0 >= max_sum)
    return;
  for (i = 0; i < n_conf_states; ++i) {
    for (j = 0; j < n_conf_states; ++j) {
      p[i * n_conf_states + j] /= max_sum;
      if (i == j)
        scratch_M[i] = 0.0;
      else
        scratch_M[i] = p[i * n_conf_states + j];
    }
    _mixed_sort(scratch_M, 0, n_conf_states - 1);
    p[i * n_conf_states + i] = 1.0 - _kahan_summation(scratch_M, n_conf_states);
  }
}


x86 assembly (clang, -O0):
<_renormalize_transition_matrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11f5 <_renormalize_transition_matrix+0xd5>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1192 <_renormalize_transition_matrix+0x72>
mov    -0x8(%rbp),%rax
mov    -0x1c(%rbp),%ecx
imul   -0xc(%rbp),%ecx
add    -0x20(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1155 <_renormalize_transition_matrix+0x35>
mov    -0x18(%rbp),%rdi
mov    -0xc(%rbp),%edx
sub    $0x1,%edx
xor    %esi,%esi
call   1040 <_mixed_sort@plt>
mov    -0x18(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1030 <_kahan_summation@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x30(%rbp),%xmm0
ucomisd -0x28(%rbp),%xmm0
jbe    11d3 <_renormalize_transition_matrix+0xb3>
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    11dd <_renormalize_transition_matrix+0xbd>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1142 <_renormalize_transition_matrix+0x22>
xorps  %xmm0,%xmm0
ucomisd -0x30(%rbp),%xmm0
jb     1208 <_renormalize_transition_matrix+0xe8>
jmp    12f9 <_renormalize_transition_matrix+0x1d9>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    12f9 <_renormalize_transition_matrix+0x1d9>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    12a9 <_renormalize_transition_matrix+0x189>
movsd  -0x30(%rbp),%xmm1
mov    -0x8(%rbp),%rax
mov    -0x1c(%rbp),%ecx
imul   -0xc(%rbp),%ecx
add    -0x20(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jne    1273 <_renormalize_transition_matrix+0x153>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
jmp    1296 <_renormalize_transition_matrix+0x176>
mov    -0x8(%rbp),%rax
mov    -0x1c(%rbp),%ecx
imul   -0xc(%rbp),%ecx
add    -0x20(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
jmp    129b <_renormalize_transition_matrix+0x17b>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1222 <_renormalize_transition_matrix+0x102>
mov    -0x18(%rbp),%rdi
mov    -0xc(%rbp),%edx
sub    $0x1,%edx
xor    %esi,%esi
call   1040 <_mixed_sort@plt>
mov    -0x18(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1030 <_kahan_summation@plt>
movaps %xmm0,%xmm1
movsd  0xd2f(%rip),%xmm0
subsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
mov    -0x1c(%rbp),%ecx
imul   -0xc(%rbp),%ecx
add    -0x1c(%rbp),%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    120f <_renormalize_transition_matrix+0xef>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_renormalize_transition_matrix>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x88,%rsp
test   %esi,%esi
jle    15ff <_renormalize_transition_matrix+0x4df>
mov    %rdx,%rbx
lea    -0x1(%rsi),%eax
mov    %eax,0x4(%rsp)
mov    %esi,%r15d
lea    (%rdx,%r15,8),%rax
mov    %rax,0x80(%rsp)
mov    %r15d,%eax
and    $0xfffffffc,%eax
mov    %rax,0x78(%rsp)
add    $0xfffffffffffffffc,%rax
mov    %rax,0x70(%rsp)
shr    $0x2,%rax
add    $0x1,%rax
mov    %eax,%ecx
and    $0x3,%ecx
and    $0xfffffffffffffffc,%rax
mov    %rax,0x58(%rsp)
mov    %r15d,%eax
and    $0x3,%eax
mov    %rax,0x8(%rsp)
mov    %rdi,%r14
lea    0x70(%rdi),%r12
lea    0x0(,%r15,8),%rax
mov    %rax,0x18(%rsp)
lea    0x10(%rdx),%rax
mov    %rax,0x60(%rsp)
lea    0x10(%rdi),%r13
mov    %rcx,0x68(%rsp)
mov    %rcx,%rdi
shl    $0x5,%rdi
xorpd  %xmm4,%xmm4
xor    %ebp,%ebp
mov    %r14,0x20(%rsp)
mov    %rsi,0x28(%rsp)
mov    %rdi,0x10(%rsp)
jmp    121f <_renormalize_transition_matrix+0xff>
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
xor    %esi,%esi
mov    0x4(%rsp),%edx
call   1040 <_mixed_sort@plt>
mov    %rbx,%rdi
mov    0x28(%rsp),%rbp
mov    %ebp,%esi
call   1030 <_kahan_summation@plt>
mov    %rbp,%rsi
movapd 0x40(%rsp),%xmm4
maxsd  %xmm0,%xmm4
mov    0x30(%rsp),%rbp
add    $0x1,%rbp
mov    0x18(%rsp),%rax
add    %rax,%r12
add    %rax,%r13
add    %rax,%r14
cmp    %r15,%rbp
mov    0x10(%rsp),%rdi
je     13d5 <_renormalize_transition_matrix+0x2b5>
cmp    $0x4,%esi
movapd %xmm4,0x40(%rsp)
mov    %rbp,0x30(%rsp)
jb     125e <_renormalize_transition_matrix+0x13e>
mov    %rbp,%rax
imul   %r15,%rax
lea    (%rax,%r15,1),%rcx
mov    0x20(%rsp),%rdx
lea    (%rdx,%rcx,8),%rcx
cmp    %rbx,%rcx
jbe    12f0 <_renormalize_transition_matrix+0x1d0>
lea    (%rdx,%rax,8),%rax
cmp    0x80(%rsp),%rax
jae    12f0 <_renormalize_transition_matrix+0x1d0>
xor    %eax,%eax
mov    %rax,%rcx
not    %rcx
add    %r15,%rcx
mov    0x8(%rsp),%rdx
test   %rdx,%rdx
je     1295 <_renormalize_transition_matrix+0x175>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsd  (%r14,%rax,8),%xmm0
movsd  %xmm0,(%rbx,%rax,8)
add    $0x1,%rax
add    $0xffffffffffffffff,%rdx
jne    1280 <_renormalize_transition_matrix+0x160>
cmp    $0x3,%rcx
jb     11d0 <_renormalize_transition_matrix+0xb0>
nop
movsd  -0x10(%r13,%rax,8),%xmm0
movsd  %xmm0,(%rbx,%rax,8)
movsd  -0x8(%r13,%rax,8),%xmm0
movsd  %xmm0,0x8(%rbx,%rax,8)
movsd  0x0(%r13,%rax,8),%xmm0
movsd  %xmm0,0x10(%rbx,%rax,8)
movsd  0x8(%r13,%rax,8),%xmm0
movsd  %xmm0,0x18(%rbx,%rax,8)
add    $0x4,%rax
cmp    %rax,%r15
jne    12a0 <_renormalize_transition_matrix+0x180>
jmp    11d0 <_renormalize_transition_matrix+0xb0>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
cmpq   $0xc,0x70(%rsp)
jae    12fc <_renormalize_transition_matrix+0x1dc>
xor    %eax,%eax
jmp    1374 <_renormalize_transition_matrix+0x254>
mov    0x58(%rsp),%rcx
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movups -0x70(%r12,%rax,8),%xmm0
movups -0x60(%r12,%rax,8),%xmm1
movups %xmm0,(%rbx,%rax,8)
movups %xmm1,0x10(%rbx,%rax,8)
movups -0x50(%r12,%rax,8),%xmm0
movups -0x40(%r12,%rax,8),%xmm1
movups %xmm0,0x20(%rbx,%rax,8)
movups %xmm1,0x30(%rbx,%rax,8)
movups -0x30(%r12,%rax,8),%xmm0
movups -0x20(%r12,%rax,8),%xmm1
movups %xmm0,0x40(%rbx,%rax,8)
movups %xmm1,0x50(%rbx,%rax,8)
movupd -0x10(%r12,%rax,8),%xmm0
movupd (%r12,%rax,8),%xmm1
movupd %xmm0,0x60(%rbx,%rax,8)
movupd %xmm1,0x70(%rbx,%rax,8)
add    $0x10,%rax
add    $0xfffffffffffffffc,%rcx
jne    1310 <_renormalize_transition_matrix+0x1f0>
cmpq   $0x0,0x68(%rsp)
je     13bf <_renormalize_transition_matrix+0x29f>
mov    0x60(%rsp),%rcx
lea    (%rcx,%rax,8),%rcx
lea    0x0(,%rax,8),%rax
add    %r13,%rax
xor    %edx,%edx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movupd -0x10(%rax,%rdx,1),%xmm0
movupd (%rax,%rdx,1),%xmm1
movupd %xmm0,-0x10(%rcx,%rdx,1)
movupd %xmm1,(%rcx,%rdx,1)
add    $0x20,%rdx
cmp    %rdx,%rdi
jne    13a0 <_renormalize_transition_matrix+0x280>
mov    0x78(%rsp),%rcx
mov    %rcx,%rax
cmp    %r15,%rcx
je     11d0 <_renormalize_transition_matrix+0xb0>
jmp    1260 <_renormalize_transition_matrix+0x140>
xorpd  %xmm0,%xmm0
ucomisd %xmm4,%xmm0
mov    0x20(%rsp),%rdi
jae    15ff <_renormalize_transition_matrix+0x4df>
test   %esi,%esi
jle    15ff <_renormalize_transition_matrix+0x4df>
mov    %r15d,%r9d
and    $0xfffffffe,%r9d
movapd %xmm4,%xmm5
unpcklpd %xmm4,%xmm5
mov    %r15,%rax
neg    %rax
mov    %rax,0x8(%rsp)
lea    0x0(,%r15,8),%rax
mov    %rax,0x18(%rsp)
xor    %ebp,%ebp
movdqa 0xbef(%rip),%xmm6
mov    %rdi,%r13
movapd %xmm5,0x30(%rsp)
movapd %xmm4,0x40(%rsp)
mov    %r9,0x10(%rsp)
mov    0x28(%rsp),%r12
jmp    14a1 <_renormalize_transition_matrix+0x381>
nopl   0x0(%rax)
mov    %rbx,%rdi
xor    %esi,%esi
mov    0x4(%rsp),%edx
call   1040 <_mixed_sort@plt>
mov    %rbx,%rdi
mov    %r12d,%esi
call   1030 <_kahan_summation@plt>
mov    0x10(%rsp),%r9
movapd 0x40(%rsp),%xmm4
mov    %r12,%rsi
mov    0x20(%rsp),%rdi
movsd  0xbac(%rip),%xmm1
subsd  %xmm0,%xmm1
add    %rbp,%r14
movsd  %xmm1,(%rdi,%r14,8)
add    $0x1,%rbp
add    0x18(%rsp),%r13
cmp    %r15,%rbp
movapd 0x30(%rsp),%xmm5
movdqa 0xb75(%rip),%xmm6
je     15ff <_renormalize_transition_matrix+0x4df>
mov    %rbp,%r14
imul   %r15,%r14
cmp    $0x2,%esi
jb     14dd <_renormalize_transition_matrix+0x3bd>
mov    %rbp,%rax
imul   %r15,%rax
lea    (%rbx,%rbp,8),%rcx
add    $0x8,%rcx
lea    (%rdi,%rax,8),%rdx
cmp    %rcx,%rdx
jae    1590 <_renormalize_transition_matrix+0x470>
lea    (%rbx,%rbp,8),%rcx
add    %r15,%rax
lea    (%rdi,%rax,8),%rax
cmp    %rax,%rcx
jae    1590 <_renormalize_transition_matrix+0x470>
xor    %ecx,%ecx
mov    %rcx,%rax
test   $0x1,%r15b
je     1513 <_renormalize_transition_matrix+0x3f3>
lea    (%rcx,%r14,1),%rax
movsd  (%rdi,%rax,8),%xmm0
divsd  %xmm4,%xmm0
movsd  %xmm0,(%rdi,%rax,8)
xorpd  %xmm1,%xmm1
cmp    %rcx,%rbp
je     1507 <_renormalize_transition_matrix+0x3e7>
movapd %xmm0,%xmm1
movsd  %xmm1,(%rbx,%rbp,8)
mov    %rcx,%rax
or     $0x1,%rax
not    %rcx
cmp    0x8(%rsp),%rcx
jne    1542 <_renormalize_transition_matrix+0x422>
jmp    1440 <_renormalize_transition_matrix+0x320>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movq   %xmm0,(%rbx,%rbp,8)
add    $0x2,%rax
cmp    %r15,%rax
je     1440 <_renormalize_transition_matrix+0x320>
movsd  0x0(%r13,%rax,8),%xmm1
divsd  %xmm4,%xmm1
movsd  %xmm1,0x0(%r13,%rax,8)
pxor   %xmm0,%xmm0
pxor   %xmm2,%xmm2
cmp    %rax,%rbp
je     1565 <_renormalize_transition_matrix+0x445>
movapd %xmm1,%xmm2
movq   %xmm2,(%rbx,%rbp,8)
movsd  0x8(%r13,%rax,8),%xmm1
divsd  %xmm4,%xmm1
movsd  %xmm1,0x8(%r13,%rax,8)
lea    0x1(%rax),%rcx
cmp    %rcx,%rbp
je     1530 <_renormalize_transition_matrix+0x410>
movapd %xmm1,%xmm0
jmp    1530 <_renormalize_transition_matrix+0x410>
nopl   0x0(%rax,%rax,1)
movq   %rbp,%xmm0
pshufd $0x44,%xmm0,%xmm0
xor    %eax,%eax
movdqa 0xa5c(%rip),%xmm3
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movdqa %xmm3,%xmm2
movupd 0x0(%r13,%rax,8),%xmm1
divpd  %xmm5,%xmm1
movupd %xmm1,0x0(%r13,%rax,8)
add    $0x2,%rax
paddq  %xmm6,%xmm3
cmp    %rax,%r9
jne    15b0 <_renormalize_transition_matrix+0x490>
pcmpeqd %xmm2,%xmm0
pshufd $0xb1,%xmm0,%xmm2
pand   %xmm0,%xmm2
pandn  %xmm1,%xmm2
pshufd $0xee,%xmm2,%xmm0
movq   %xmm0,(%rbx,%rbp,8)
mov    %r9,%rcx
cmp    %r15,%r9
je     1440 <_renormalize_transition_matrix+0x320>
jmp    14df <_renormalize_transition_matrix+0x3bf>
add    $0x88,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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