#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 exp(double);
scalar_t__ isinf(double);
double log_dgamma(double, double, double);
double maximum(double *, int);
int rbernoulli(double);
void sample_L_m(int D, int p, double ***Lambda_t, double par_p_t, double *par_0,
                double *par_1, int ***L_t) {
  double tmp[2], tmp_new[2], tmp_max, prob[2], sum;
  for (int d = 0; d < D; d++) {
    L_t[d][p - 1][p - 1] = -1;
    for (int i = 0; i < p - 1; i++) {
      for (int j = i; j < p; j++) {
        if (j == i) {
          L_t[d][i][j] = -1;
        } else {
          tmp[0] = log_dgamma(Lambda_t[d][i][j], par_1[0], par_1[1]);
          tmp[1] = log_dgamma(Lambda_t[d][i][j], par_0[0], par_0[1]);
          if (isinf(tmp[0]) && isinf(tmp[1])) {
            tmp_new[0] = 0.5;
            tmp_new[1] = 0.5;
          } else {
            tmp_max = maximum(tmp, 2);
            tmp_new[0] = tmp[0] - tmp_max;
            tmp_new[1] = tmp[1] - tmp_max;
          }
          prob[0] = par_p_t * exp(tmp_new[0]);
          prob[1] = (1.0 - par_p_t) * exp(tmp_new[1]);
          sum = prob[0] + prob[1];
          prob[0] = prob[0] / sum;
          prob[1] = prob[1] / sum;
          L_t[d][i][j] = rbernoulli(prob[0]);
          L_t[d][j][i] = L_t[d][i][j];
        }
      }
    }
  }
}


x86 assembly (clang, -O0):
<sample_L_m>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
movl   $0x0,-0x7c(%rbp)
mov    -0x7c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1436 <sample_L_m+0x2e6>
mov    -0x30(%rbp),%rax
movslq -0x7c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movl   $0xffffffff,(%rax,%rcx,4)
movl   $0x0,-0x80(%rbp)
mov    -0x80(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    1423 <sample_L_m+0x2d3>
mov    -0x80(%rbp),%eax
mov    %eax,-0x84(%rbp)
mov    -0x84(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1410 <sample_L_m+0x2c0>
mov    -0x84(%rbp),%eax
cmp    -0x80(%rbp),%eax
jne    1218 <sample_L_m+0xc8>
mov    -0x30(%rbp),%rax
movslq -0x7c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x80(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x84(%rbp),%rcx
movl   $0xffffffff,(%rax,%rcx,4)
jmp    13f7 <sample_L_m+0x2a7>
mov    -0x10(%rbp),%rax
movslq -0x7c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x80(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x84(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x28(%rbp),%rax
movsd  (%rax),%xmm1
mov    -0x28(%rbp),%rax
movsd  0x8(%rax),%xmm2
call   1040 <log_dgamma@plt>
movsd  %xmm0,-0x40(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x7c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x80(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x84(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x20(%rbp),%rax
movsd  (%rax),%xmm1
mov    -0x20(%rbp),%rax
movsd  0x8(%rax),%xmm2
call   1040 <log_dgamma@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x40(%rbp),%xmm0
call   1070 <isinf@plt>
cmp    $0x0,%rax
je     12d5 <sample_L_m+0x185>
movsd  -0x38(%rbp),%xmm0
call   1070 <isinf@plt>
cmp    $0x0,%rax
je     12d5 <sample_L_m+0x185>
movsd  0xd42(%rip),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  0xd35(%rip),%xmm0
movsd  %xmm0,-0x48(%rbp)
jmp    1306 <sample_L_m+0x1b6>
lea    -0x40(%rbp),%rdi
mov    $0x2,%esi
call   1030 <maximum@plt>
movsd  %xmm0,-0x58(%rbp)
movsd  -0x40(%rbp),%xmm0
subsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x38(%rbp),%xmm0
subsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x98(%rbp)
ff
movsd  -0x50(%rbp),%xmm0
call   1050 <exp@plt>
movaps %xmm0,%xmm1
movsd  -0x98(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  0xccf(%rip),%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
movsd  -0x48(%rbp),%xmm0
call   1050 <exp@plt>
movaps %xmm0,%xmm1
movsd  -0x90(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x70(%rbp),%xmm0
addsd  -0x68(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x70(%rbp),%xmm0
divsd  -0x78(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x68(%rbp),%xmm0
divsd  -0x78(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x70(%rbp),%xmm0
call   1060 <rbernoulli@plt>
mov    %eax,%edx
mov    -0x30(%rbp),%rax
movslq -0x7c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x80(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x84(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x30(%rbp),%rax
movslq -0x7c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x80(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x84(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
mov    -0x30(%rbp),%rax
movslq -0x7c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x84(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x80(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
jmp    13fc <sample_L_m+0x2ac>
mov    -0x84(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x84(%rbp)
jmp    11d3 <sample_L_m+0x83>
jmp    1415 <sample_L_m+0x2c5>
mov    -0x80(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x80(%rbp)
jmp    11b9 <sample_L_m+0x69>
jmp    1428 <sample_L_m+0x2d8>
mov    -0x7c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7c(%rbp)
jmp    117d <sample_L_m+0x2d>
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sample_L_m>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xa8,%rsp
mov    %r9,0x20(%rsp)
mov    %r8,0x70(%rsp)
mov    %rcx,0x68(%rsp)
movsd  %xmm0,0x18(%rsp)
mov    %rdx,0x60(%rsp)
mov    %rsi,0x10(%rsp)
test   %edi,%edi
jle    13c9 <sample_L_m+0x279>
mov    0x10(%rsp),%rax
lea    -0x1(%rax),%edx
movslq %edx,%rcx
mov    %rcx,0x30(%rsp)
movsd  0xe60(%rip),%xmm0
subsd  0x18(%rsp),%xmm0
movsd  %xmm0,0x58(%rsp)
movslq %eax,%rbx
mov    %edi,%eax
mov    %rax,0x28(%rsp)
mov    %ebx,%edi
xor    %r13d,%r13d
mov    %rdx,0x48(%rsp)
mov    %rbx,0x40(%rsp)
mov    %rdi,0x38(%rsp)
mov    0x60(%rsp),%r12
jmp    11ef <sample_L_m+0x9f>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%r13
cmp    0x28(%rsp),%r13
je     13c9 <sample_L_m+0x279>
mov    0x20(%rsp),%rax
mov    (%rax,%r13,8),%rcx
mov    0x30(%rsp),%rsi
mov    (%rcx,%rsi,8),%rax
movl   $0xffffffff,(%rax,%rsi,4)
cmpl   $0x2,0x10(%rsp)
jl     11e0 <sample_L_m+0x90>
xor    %ebp,%ebp
jmp    122f <sample_L_m+0xdf>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%rbp
mov    %rbp,%rax
mov    %rax,%rbp
cmp    %rdx,%rax
je     11e0 <sample_L_m+0x90>
cmp    %rbx,%rbp
jge    1220 <sample_L_m+0xd0>
mov    (%rcx,%rbp,8),%rax
movl   $0xffffffff,(%rax,%rbp,4)
lea    0x1(%rbp),%rax
cmp    %rdi,%rax
je     1227 <sample_L_m+0xd7>
mov    %rax,0x50(%rsp)
lea    0x0(,%rbp,8),%r14
lea    0x8(,%rbp,8),%r15
lea    0x0(,%rbp,4),%rax
mov    %rax,0x78(%rsp)
sub    %rbp,%rdi
mov    %rdi,0x80(%rsp)
mov    $0x1,%ebx
jmp    12a5 <sample_L_m+0x155>
nopl   0x0(%rax)
lea    (%rcx,%rbp,8),%rdx
mov    $0xffffffff,%eax
mov    (%rdx),%rdx
mov    %eax,(%rdx,%rbp,4)
add    $0x1,%rbx
add    $0x8,%r15
cmp    %rbx,0x80(%rsp)
je     13b0 <sample_L_m+0x260>
test   %rbx,%rbx
je     1280 <sample_L_m+0x130>
mov    (%r12,%r13,8),%rax
mov    (%rax,%rbp,8),%rax
add    %r14,%rax
movsd  (%rax,%rbx,8),%xmm0
mov    0x70(%rsp),%rax
movsd  (%rax),%xmm1
movsd  0x8(%rax),%xmm2
call   1040 <log_dgamma@plt>
movsd  %xmm0,(%rsp)
mov    (%r12,%r13,8),%rax
mov    (%rax,%rbp,8),%rax
add    %r14,%rax
movsd  (%rax,%rbx,8),%xmm0
mov    0x68(%rsp),%rax
movsd  (%rax),%xmm1
movsd  0x8(%rax),%xmm2
call   1040 <log_dgamma@plt>
movsd  %xmm0,0x8(%rsp)
movsd  (%rsp),%xmm0
call   1070 <isinf@plt>
test   %rax,%rax
je     1322 <sample_L_m+0x1d2>
movsd  0x8(%rsp),%xmm0
call   1070 <isinf@plt>
movapd 0xcf3(%rip),%xmm1
test   %rax,%rax
jne    133c <sample_L_m+0x1ec>
mov    %rsp,%rdi
mov    $0x2,%esi
call   1030 <maximum@plt>
movapd (%rsp),%xmm1
unpcklpd %xmm0,%xmm0
subpd  %xmm0,%xmm1
movapd %xmm1,0x90(%rsp)
movapd %xmm1,%xmm0
call   1050 <exp@plt>
mulsd  0x18(%rsp),%xmm0
movsd  %xmm0,0x88(%rsp)
movapd 0x90(%rsp),%xmm0
unpckhpd %xmm0,%xmm0
call   1050 <exp@plt>
mulsd  0x58(%rsp),%xmm0
movsd  0x88(%rsp),%xmm1
addsd  %xmm1,%xmm0
divsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
call   1060 <rbernoulli@plt>
mov    0x20(%rsp),%rcx
mov    (%rcx,%r13,8),%rcx
mov    (%rcx,%rbp,8),%rdx
add    0x78(%rsp),%rdx
mov    %eax,(%rdx,%rbx,4)
lea    (%rcx,%r15,1),%rdx
jmp    1289 <sample_L_m+0x139>
nopl   (%rax)
mov    0x48(%rsp),%rdx
mov    0x40(%rsp),%rbx
mov    0x38(%rsp),%rdi
mov    0x50(%rsp),%rax
jmp    1227 <sample_L_m+0xd7>
add    $0xa8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @sample_L_m(i32 %0, i32 %1, double*** nocapture %2, double %3, double* nocapture %4, double* nocapture %5, i32*** nocapture %6) {
%8 = alloca <2 x double>
%9 = bitcast <2 x double>* %8 to i8*
%10 = icmp sgt i32 %0, 0
br i1 %10, label %11, label %24
11: ; preds = %7
%12 = add nsw i32 %1, -1
%13 = sext i32 %12 to i64
%14 = icmp sgt i32 %1, 1
%15 = getelementptr inbounds double, double* %5, i64 1
%16 = getelementptr inbounds <2 x double>, <2 x double>* %8, i64 0, i64 0
%17 = getelementptr inbounds double, double* %4, i64 1
%18 = getelementptr inbounds <2 x double>, <2 x double>* %8, i64 0, i64 1
%19 = fsub double 1.000000e+00, %3
%20 = sext i32 %1 to i64
%21 = zext i32 %0 to i64
%22 = zext i32 %12 to i64
%23 = zext i32 %1 to i64
br label %25
24: ; preds = %47, %7
ret void
25: ; preds = %11, %47
%26 = phi i64 [ 0, %11 ], [ %48, %47 ]
%27 = getelementptr inbounds i32**, i32*** %6, i64 %26
%28 = load i32**, i32*** %27
%29 = getelementptr inbounds i32*, i32** %28, i64 %13
%30 = load i32*, i32** %29
%31 = getelementptr inbounds i32, i32* %30, i64 %13
store i32 -1, i32* %31
br i1 %14, label %32, label %47
32: ; preds = %25
%33 = getelementptr inbounds double**, double*** %2, i64 %26
br label %34
34: ; preds = %32, %50
%35 = phi i32** [ %28, %32 ], [ %52, %50 ]
%36 = phi i32** [ %28, %32 ], [ %53, %50 ]
%37 = phi i64 [ 0, %32 ], [ %51, %50 ]
%38 = icmp slt i64 %37, %20
br i1 %38, label %41, label %39
39: ; preds = %34
%40 = add nuw nsw i64 %37, 1
br label %50
41: ; preds = %34
%42 = getelementptr inbounds i32*, i32** %36, i64 %37
%43 = load i32*, i32** %42
%44 = getelementptr inbounds i32, i32* %43, i64 %37
store i32 -1, i32* %44
%45 = add nuw nsw i64 %37, 1
%46 = icmp eq i64 %45, %23
br i1 %46, label %50, label %55
47: ; preds = %50, %25
%48 = add nuw nsw i64 %26, 1
%49 = icmp eq i64 %48, %21
br i1 %49, label %24, label %25
50: ; preds = %107, %41, %39
%51 = phi i64 [ %40, %39 ], [ %45, %41 ], [ %45, %107 ]
%52 = phi i32** [ %35, %39 ], [ %35, %41 ], [ %110, %107 ]
%53 = phi i32** [ %36, %39 ], [ %36, %41 ], [ %110, %107 ]
%54 = icmp eq i64 %51, %22
br i1 %54, label %47, label %34
55: ; preds = %41, %107
%56 = phi i32** [ %110, %107 ], [ %35, %41 ]
%57 = phi i64 [ %113, %107 ], [ %45, %41 ]
%58 = icmp eq i64 %57, %37
br i1 %58, label %59, label %61
59: ; preds = %55
%60 = getelementptr inbounds i32*, i32** %56, i64 %37
br label %107
61: ; preds = %55
%62 = load double**, double*** %33
%63 = getelementptr inbounds double*, double** %62, i64 %37
%64 = load double*, double** %63
%65 = getelementptr inbounds double, double* %64, i64 %57
%66 = load double, double* %65
%67 = load double, double* %5
%68 = load double, double* %15
%69 = call double @log_dgamma(double %66, double %67, double %68)
store double %69, double* %16
%70 = load double**, double*** %33
%71 = getelementptr inbounds double*, double** %70, i64 %37
%72 = load double*, double** %71
%73 = getelementptr inbounds double, double* %72, i64 %57
%74 = load double, double* %73
%75 = load double, double* %4
%76 = load double, double* %17
%77 = call double @log_dgamma(double %74, double %75, double %76)
store double %77, double* %18
%78 = load double, double* %16
%79 = call i64 @isinf(double %78)
%80 = icmp eq i64 %79, 0
br i1 %80, label %85, label %81
81: ; preds = %61
%82 = load double, double* %18
%83 = call i64 @isinf(double %82)
%84 = icmp eq i64 %83, 0
br i1 %84, label %85, label %91
85: ; preds = %81, %61
%86 = call double @maximum(double* %16, i32 2)
%87 = load <2 x double>, <2 x double>* %8
%88 = insertelement <2 x double> poison, double %86, i64 0
%89 = shufflevector <2 x double> %88, <2 x double> poison, <2 x i32> zeroinitializer
%90 = fsub <2 x double> %87, %89
br label %91
91: ; preds = %81, %85
%92 = phi <2 x double> [ %90, %85 ], [ <double 5.000000e-01, double 5.000000e-01>, %81 ]
%93 = extractelement <2 x double> %92, i64 0
%94 = call double @exp(double %93)
%95 = fmul double %94, %3
%96 = extractelement <2 x double> %92, i64 1
%97 = call double @exp(double %96)
%98 = fmul double %19, %97
%99 = fadd double %95, %98
%100 = fdiv double %95, %99
%101 = call i32 @rbernoulli(double %100)
%102 = load i32**, i32*** %27
%103 = getelementptr inbounds i32*, i32** %102, i64 %37
%104 = load i32*, i32** %103
%105 = getelementptr inbounds i32, i32* %104, i64 %57
store i32 %101, i32* %105
%106 = getelementptr inbounds i32*, i32** %102, i64 %57
br label %107
107: ; preds = %59, %91
%108 = phi i32** [ %60, %59 ], [ %106, %91 ]
%109 = phi i32 [ -1, %59 ], [ %101, %91 ]
%110 = phi i32** [ %56, %59 ], [ %102, %91 ]
%111 = load i32*, i32** %108
%112 = getelementptr inbounds i32, i32* %111, i64 %37
store i32 %109, i32* %112
%113 = add nuw nsw i64 %57, 1
%114 = icmp eq i64 %113, %23
br i1 %114, label %50, label %55
}