#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 */
scalar_t__ exp(double);
int integerrng(int, int);
double log(double);
double uniformrng();
void CO_select_forward_1(double *prob, int *n1, int *n2, double *fx,
                         int N_population, double temp) {
  int i;
  double fx_min;
  double un;
  double fx_sum;
  double ss;
  *n1 = integerrng(1, N_population);
  fx_min = ((*n1 == 1) ? fx[2] : fx[1]);
  for (i = 1; i <= N_population; i++)
    if ((i != *n1) && fx[i] < fx_min)
      fx_min = fx[i];
  fx_sum = 0.0;
  for (i = 1; i <= N_population; i++)
    if (i != *n1)
      fx_sum += exp((-fx[i] + fx_min) / temp);
  if (fx_sum == 0.0) {
    *n2 = integerrng(1, N_population - 1);
    if (*n2 >= *n1)
      (*n2)++;
  } else {
    un = uniformrng();
    ss = 0.0;
    *n2 = 0;
    do {
      (*n2)++;
      if (*n2 != *n1)
        ss += exp((-fx[*n2] + fx_min) / temp - log(fx_sum));
    } while (ss < un && *n2 <= N_population);
  }
  if (fx_sum == 0.0)
    *prob = -log((double)N_population - 1) - log((double)N_population);
  else
    *prob =
        (-fx[*n2] + fx_min) / temp - log(fx_sum) - log((double)N_population);
}


x86 assembly (clang, -O0):
<CO_select_forward_1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
movsd  %xmm0,-0x30(%rbp)
mov    -0x24(%rbp),%esi
mov    $0x1,%edi
call   1040 <integerrng@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
cmpl   $0x1,(%rax)
jne    1199 <CO_select_forward_1+0x59>
mov    -0x20(%rbp),%rax
movsd  0x10(%rax),%xmm0
movsd  %xmm0,-0x60(%rbp)
jmp    11a7 <CO_select_forward_1+0x67>
mov    -0x20(%rbp),%rax
movsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movl   $0x1,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x24(%rbp),%eax
jg     1214 <CO_select_forward_1+0xd4>
mov    -0x34(%rbp),%eax
mov    -0x10(%rbp),%rcx
cmp    (%rcx),%eax
je     1201 <CO_select_forward_1+0xc1>
mov    -0x20(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
movsd  -0x40(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1201 <CO_select_forward_1+0xc1>
mov    -0x20(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x40(%rbp)
jmp    1206 <CO_select_forward_1+0xc6>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    11b8 <CO_select_forward_1+0x78>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x50(%rbp)
movl   $0x1,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x24(%rbp),%eax
jg     1293 <CO_select_forward_1+0x153>
mov    -0x34(%rbp),%eax
mov    -0x10(%rbp),%rcx
cmp    (%rcx),%eax
je     1280 <CO_select_forward_1+0x140>
mov    -0x20(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
addsd  -0x40(%rbp),%xmm0
divsd  -0x30(%rbp),%xmm0
call   1050 <exp@plt>
cvtsi2sd %rax,%xmm0
addsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
jmp    1285 <CO_select_forward_1+0x145>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1223 <CO_select_forward_1+0xe3>
movsd  -0x50(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    12e5 <CO_select_forward_1+0x1a5>
jp     12e5 <CO_select_forward_1+0x1a5>
mov    -0x24(%rbp),%esi
sub    $0x1,%esi
mov    $0x1,%edi
call   1040 <integerrng@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
mov    -0x10(%rbp),%rcx
cmp    (%rcx),%eax
jl     12e0 <CO_select_forward_1+0x1a0>
mov    -0x18(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
jmp    13bd <CO_select_forward_1+0x27d>
mov    $0x0,%al
call   1030 <uniformrng@plt>
movsd  %xmm0,-0x48(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
mov    -0x10(%rbp),%rcx
cmp    (%rcx),%eax
je     1380 <CO_select_forward_1+0x240>
mov    -0x20(%rbp),%rax
mov    -0x18(%rbp),%rcx
movslq (%rcx),%rcx
movsd  (%rax,%rcx,8),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
addsd  -0x40(%rbp),%xmm0
divsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x50(%rbp),%xmm0
call   1060 <log@plt>
movaps %xmm0,%xmm1
movsd  -0x68(%rbp),%xmm0
subsd  %xmm1,%xmm0
call   1050 <exp@plt>
cvtsi2sd %rax,%xmm0
addsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
jmp    1385 <CO_select_forward_1+0x245>
movsd  -0x58(%rbp),%xmm1
movsd  -0x48(%rbp),%xmm0
xor    %eax,%eax
ucomisd %xmm1,%xmm0
mov    %al,-0x69(%rbp)
jbe    13ad <CO_select_forward_1+0x26d>
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
cmp    -0x24(%rbp),%eax
setle  %al
mov    %al,-0x69(%rbp)
mov    -0x69(%rbp),%al
test   $0x1,%al
jne    1303 <CO_select_forward_1+0x1c3>
jmp    13bd <CO_select_forward_1+0x27d>
movsd  -0x50(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    142a <CO_select_forward_1+0x2ea>
jp     142a <CO_select_forward_1+0x2ea>
cvtsi2sdl -0x24(%rbp),%xmm0
movsd  0xc1e(%rip),%xmm1
subsd  %xmm1,%xmm0
call   1060 <log@plt>
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x78(%rbp)
cvtsi2sdl -0x24(%rbp),%xmm0
call   1060 <log@plt>
movaps %xmm0,%xmm1
movsd  -0x78(%rbp),%xmm0
subsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    149f <CO_select_forward_1+0x35f>
mov    -0x20(%rbp),%rax
mov    -0x18(%rbp),%rcx
movslq (%rcx),%rcx
movsd  (%rax,%rcx,8),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
addsd  -0x40(%rbp),%xmm0
divsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
movsd  -0x50(%rbp),%xmm0
call   1060 <log@plt>
movaps %xmm0,%xmm1
movsd  -0x88(%rbp),%xmm0
ff
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x80(%rbp)
cvtsi2sdl -0x24(%rbp),%xmm0
call   1060 <log@plt>
movaps %xmm0,%xmm1
movsd  -0x80(%rbp),%xmm0
subsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,(%rax)
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CO_select_forward_1>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
movsd  %xmm0,0x28(%rsp)
mov    %r8d,%r12d
mov    %rcx,%rbx
mov    %rdx,%r15
mov    %rsi,%r13
mov    %rdi,%r14
mov    $0x1,%edi
mov    %r8d,%esi
call   1040 <integerrng@plt>
mov    %eax,0x0(%r13)
test   %r12d,%r12d
jle    12ab <CO_select_forward_1+0x16b>
xor    %ecx,%ecx
cmp    $0x1,%eax
sete   %cl
movsd  0x8(%rbx,%rcx,8),%xmm1
mov    %eax,%ecx
mov    %r12d,%r8d
cmp    $0x1,%r12d
jne    11a3 <CO_select_forward_1+0x63>
mov    $0x1,%edx
test   $0x1,%r8b
jne    11f5 <CO_select_forward_1+0xb5>
jmp    1209 <CO_select_forward_1+0xc9>
mov    %r8d,%edi
and    $0xfffffffe,%edi
mov    $0x1,%esi
jmp    11b9 <CO_select_forward_1+0x79>
lea    0x1(%rbp),%rsi
cmp    %rdi,%rbp
je     11eb <CO_select_forward_1+0xab>
mov    %rsi,%rdx
cmp    %rsi,%rcx
je     11d0 <CO_select_forward_1+0x90>
movsd  (%rbx,%rdx,8),%xmm0
ucomisd %xmm0,%xmm1
jbe    11d0 <CO_select_forward_1+0x90>
movapd %xmm0,%xmm1
lea    0x1(%rdx),%rbp
cmp    %rcx,%rbp
je     11b0 <CO_select_forward_1+0x70>
movsd  0x8(%rbx,%rdx,8),%xmm0
ucomisd %xmm0,%xmm1
jbe    11b0 <CO_select_forward_1+0x70>
movapd %xmm0,%xmm1
jmp    11b0 <CO_select_forward_1+0x70>
add    $0x2,%rdx
test   $0x1,%r8b
je     1209 <CO_select_forward_1+0xc9>
cmp    %rcx,%rdx
je     1209 <CO_select_forward_1+0xc9>
movsd  (%rbx,%rdx,8),%xmm0
ucomisd %xmm0,%xmm1
jbe    1209 <CO_select_forward_1+0xc9>
movapd %xmm0,%xmm1
test   %r12d,%r12d
jle    12ab <CO_select_forward_1+0x16b>
mov    %r14,0x30(%rsp)
lea    0x1(%r12),%ecx
mov    $0x2,%ebp
sub    %rcx,%rbp
xorpd  %xmm0,%xmm0
mov    $0x1,%r14d
movapd %xmm1,0x10(%rsp)
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %eax,%eax
cmp    %rax,%r14
je     1286 <CO_select_forward_1+0x146>
movsd  %xmm0,0x8(%rsp)
movapd %xmm1,%xmm0
subsd  (%rbx,%r14,8),%xmm0
divsd  0x28(%rsp),%xmm0
call   1050 <exp@plt>
movapd 0x10(%rsp),%xmm1
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  0x8(%rsp),%xmm2
addsd  %xmm0,%xmm2
movsd  %xmm2,0x8(%rsp)
movsd  0x8(%rsp),%xmm0
lea    (%r14,%rbp,1),%rax
cmp    $0x1,%rax
je     129a <CO_select_forward_1+0x15a>
mov    0x0(%r13),%eax
add    $0x1,%r14
jmp    1240 <CO_select_forward_1+0x100>
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
mov    0x30(%rsp),%r14
jne    131f <CO_select_forward_1+0x1df>
jp     131f <CO_select_forward_1+0x1df>
lea    -0x1(%r12),%esi
mov    $0x1,%edi
call   1040 <integerrng@plt>
mov    %eax,(%r15)
cmp    0x0(%r13),%eax
jl     12c9 <CO_select_forward_1+0x189>
add    $0x1,%eax
mov    %eax,(%r15)
xorps  %xmm1,%xmm1
cvtsi2sd %r12d,%xmm1
movsd  %xmm1,0x8(%rsp)
movsd  0xd21(%rip),%xmm0
addsd  %xmm1,%xmm0
call   1060 <log@plt>
xorpd  0xd20(%rip),%xmm0
movapd %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
call   1060 <log@plt>
movapd 0x10(%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,(%r14)
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xorpd  %xmm1,%xmm1
movsd  %xmm1,0x20(%rsp)
movsd  %xmm0,0x8(%rsp)
xor    %ebp,%ebp
xor    %eax,%eax
call   1030 <uniformrng@plt>
movapd %xmm0,%xmm2
movsd  %xmm0,0x38(%rsp)
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%ebp
mov    %ebp,(%r15)
cmp    0x0(%r13),%ebp
movapd 0x10(%rsp),%xmm0
jne    1370 <CO_select_forward_1+0x230>
movsd  0x20(%rsp),%xmm1
jmp    13ba <CO_select_forward_1+0x27a>
nopw   0x0(%rax,%rax,1)
movslq %ebp,%rax
subsd  (%rbx,%rax,8),%xmm0
divsd  0x28(%rsp),%xmm0
movsd  %xmm0,0x40(%rsp)
movsd  0x8(%rsp),%xmm0
call   1060 <log@plt>
movsd  0x40(%rsp),%xmm1
subsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
call   1050 <exp@plt>
movsd  0x38(%rsp),%xmm2
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  0x20(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x20(%rsp)
ucomisd %xmm1,%xmm2
jbe    13ce <CO_select_forward_1+0x28e>
mov    (%r15),%ebp
cmp    %r12d,%ebp
jle    1350 <CO_select_forward_1+0x210>
movslq (%r15),%rax
movapd 0x10(%rsp),%xmm0
subsd  (%rbx,%rax,8),%xmm0
divsd  0x28(%rsp),%xmm0
movapd %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
call   1060 <log@plt>
movapd 0x10(%rsp),%xmm1
subsd  %xmm0,%xmm1
movapd %xmm1,0x10(%rsp)
xorps  %xmm0,%xmm0
cvtsi2sd %r12d,%xmm0
jmp    12fc <CO_select_forward_1+0x1bc>

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

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