#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*/ delet4Darray_int_continuousMem(int ****, int, int, int, int);
double exp(double);
int /*<<< orphan*/ free(double *);
double log_dsty_Y(int, int, int, int ****, double ***);
int ****make4Darray_int_continuousMem(int, int, int, int);
scalar_t__ malloc(int);
double maximum(double *, int);
int rdiscrete(int, double *);
int sample_cla(int M, int D, int p, int R, int n, double ****Lambda_t,
               double *P_dp_t, int *****Y_t) {
  int tmp;
  double *ss, *ss_new, *Prob;
  int ****Y_t_n;
  Y_t_n = make4Darray_int_continuousMem(D, R, p, p);
  for (int d = 0; d < D; d++) {
    for (int r = 0; r < R; r++) {
      for (int i = 0; i < p; i++) {
        for (int j = 0; j < p; j++) {
          Y_t_n[d][r][i][j] = Y_t[n][d][r][i][j];
        }
      }
    }
  }
  ss = (double *)malloc(M * sizeof(double));
  ss_new = (double *)malloc(M * sizeof(double));
  Prob = (double *)malloc(M * sizeof(double));
  double ss_max;
  for (int m = 0; m < M; m++) {
    ss[m] = log_dsty_Y(D, R, p, Y_t_n, Lambda_t[m]);
  }
  ss_max = maximum(ss, M);
  for (int m = 0; m < M; m++) {
    ss_new[m] = ss[m] - ss_max;
    Prob[m] = P_dp_t[m] * exp(ss_new[m]);
  }
  tmp = rdiscrete(M, Prob);
  free(ss);
  free(ss_new);
  free(Prob);
  delet4Darray_int_continuousMem(Y_t_n, D, R, p, p);
  return (tmp);
}


x86 assembly (clang, -O0):
<sample_cla>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    %r8d,-0x14(%rbp)
mov    %r9,-0x20(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0xc(%rbp),%ecx
call   10a0 <make4Darray_int_continuousMem@plt>
mov    %rax,-0x48(%rbp)
movl   $0x0,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    129a <sample_cla+0x11a>
movl   $0x0,-0x50(%rbp)
mov    -0x50(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    1287 <sample_cla+0x107>
movl   $0x0,-0x54(%rbp)
mov    -0x54(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1274 <sample_cla+0xf4>
movl   $0x0,-0x58(%rbp)
mov    -0x58(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1261 <sample_cla+0xe1>
mov    0x18(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x4c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x50(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x54(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x58(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
mov    -0x48(%rbp),%rax
movslq -0x4c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x50(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x54(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x58(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x58(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x58(%rbp)
jmp    11f9 <sample_cla+0x79>
jmp    1266 <sample_cla+0xe6>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    11e6 <sample_cla+0x66>
jmp    1279 <sample_cla+0xf9>
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
jmp    11d3 <sample_cla+0x53>
jmp    128c <sample_cla+0x10c>
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    11c0 <sample_cla+0x40>
movslq -0x4(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1080 <malloc@plt>
mov    %rax,-0x30(%rbp)
movslq -0x4(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1080 <malloc@plt>
mov    %rax,-0x38(%rbp)
movslq -0x4(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1080 <malloc@plt>
mov    %rax,-0x40(%rbp)
movl   $0x0,-0x64(%rbp)
mov    -0x64(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    131f <sample_cla+0x19f>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x48(%rbp),%rcx
mov    -0x20(%rbp),%rax
movslq -0x64(%rbp),%r8
mov    (%rax,%r8,8),%r8
call   1070 <log_dsty_Y@plt>
mov    -0x30(%rbp),%rax
movslq -0x64(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    12da <sample_cla+0x15a>
mov    -0x30(%rbp),%rdi
mov    -0x4(%rbp),%esi
call   1030 <maximum@plt>
movsd  %xmm0,-0x60(%rbp)
movl   $0x0,-0x68(%rbp)
mov    -0x68(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    13ad <sample_cla+0x22d>
mov    -0x30(%rbp),%rax
movslq -0x68(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
subsd  -0x60(%rbp),%xmm0
mov    -0x38(%rbp),%rax
movslq -0x68(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    0x10(%rbp),%rax
movslq -0x68(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x70(%rbp)
mov    -0x38(%rbp),%rax
movslq -0x68(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
call   1090 <exp@plt>
movaps %xmm0,%xmm1
movsd  -0x70(%rbp),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x40(%rbp),%rax
movslq -0x68(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x68(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x68(%rbp)
jmp    1337 <sample_cla+0x1b7>
mov    -0x4(%rbp),%edi
mov    -0x40(%rbp),%rsi
call   1050 <rdiscrete@plt>
mov    %eax,-0x24(%rbp)
mov    -0x30(%rbp),%rdi
call   1040 <free@plt>
mov    -0x38(%rbp),%rdi
call   1040 <free@plt>
mov    -0x40(%rbp),%rdi
call   1040 <free@plt>
mov    -0x48(%rbp),%rdi
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0xc(%rbp),%ecx
mov    -0xc(%rbp),%r8d
call   1060 <delet4Darray_int_continuousMem@plt>
mov    -0x24(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sample_cla>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
mov    %r9,0x50(%rsp)
mov    %r8d,%r14d
mov    %ecx,%r15d
mov    %edx,%ebx
mov    %esi,%ebp
mov    %rdi,0x10(%rsp)
mov    %esi,%edi
mov    %ecx,%esi
mov    %edx,%ecx
call   10a0 <make4Darray_int_continuousMem@plt>
mov    %rax,0x30(%rsp)
test   %ebp,%ebp
mov    %r15d,0x24(%rsp)
mov    %ebp,0x20(%rsp)
jle    1435 <sample_cla+0x2b5>
movslq %r14d,%rax
mov    %rax,0x60(%rsp)
mov    %ebp,%eax
mov    %rax,0x58(%rsp)
mov    %r15d,%eax
mov    %rax,0x38(%rsp)
mov    %ebx,%edi
mov    %edi,%r12d
and    $0xfffffff8,%r12d
lea    -0x8(%r12),%rax
mov    %rax,0x28(%rsp)
shr    $0x3,%rax
add    $0x1,%rax
mov    %eax,%ebp
and    $0x3,%ebp
and    $0xfffffffffffffffc,%rax
mov    %rax,0x40(%rsp)
mov    %edi,%r13d
and    $0x3,%r13d
mov    %rbp,0x48(%rsp)
shl    $0x5,%rbp
xor    %eax,%eax
mov    %rax,0x18(%rsp)
jmp    1241 <sample_cla+0xc1>
nopl   0x0(%rax)
mov    0x18(%rsp),%rcx
add    $0x1,%rcx
mov    %rcx,%rax
mov    %rcx,0x18(%rsp)
cmp    0x58(%rsp),%rcx
mov    0x24(%rsp),%r15d
je     1435 <sample_cla+0x2b5>
test   %r15d,%r15d
mov    0x30(%rsp),%r14
jle    1220 <sample_cla+0xa0>
xor    %eax,%eax
mov    %rax,0x8(%rsp)
jmp    1278 <sample_cla+0xf8>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0x8(%rsp),%rcx
add    $0x1,%rcx
mov    %rcx,%rax
mov    %rcx,0x8(%rsp)
cmp    0x38(%rsp),%rcx
je     1220 <sample_cla+0xa0>
test   %ebx,%ebx
jle    1260 <sample_cla+0xe0>
mov    0xa8(%rsp),%rax
mov    0x60(%rsp),%rcx
mov    (%rax,%rcx,8),%rcx
mov    0x18(%rsp),%rax
mov    (%rcx,%rax,8),%rcx
mov    0x8(%rsp),%rdx
mov    (%rcx,%rdx,8),%r8
mov    (%r14,%rax,8),%rcx
mov    (%rcx,%rdx,8),%r9
xor    %r15d,%r15d
jmp    12b9 <sample_cla+0x139>
nopl   0x0(%rax)
add    $0x1,%r15
cmp    %rdi,%r15
je     1260 <sample_cla+0xe0>
mov    (%r8,%r15,8),%r10
mov    (%r9,%r15,8),%r11
cmp    $0x8,%ebx
jb     12dc <sample_cla+0x15c>
lea    (%r10,%rdi,4),%rcx
cmp    %rcx,%r11
jae    1350 <sample_cla+0x1d0>
lea    (%r11,%rdi,4),%rcx
cmp    %rcx,%r10
jae    1350 <sample_cla+0x1d0>
xor    %edx,%edx
mov    %rdx,%rcx
not    %rcx
add    %rdi,%rcx
test   %r13,%r13
je     1302 <sample_cla+0x182>
mov    %r13,%rsi
nop
mov    (%r10,%rdx,4),%eax
mov    %eax,(%r11,%rdx,4)
add    $0x1,%rdx
add    $0xffffffffffffffff,%rsi
jne    12f0 <sample_cla+0x170>
cmp    $0x3,%rcx
jb     12b0 <sample_cla+0x130>
nopl   0x0(%rax,%rax,1)
mov    (%r10,%rdx,4),%eax
mov    %eax,(%r11,%rdx,4)
mov    0x4(%r10,%rdx,4),%eax
mov    %eax,0x4(%r11,%rdx,4)
mov    0x8(%r10,%rdx,4),%eax
mov    %eax,0x8(%r11,%rdx,4)
mov    0xc(%r10,%rdx,4),%eax
mov    %eax,0xc(%r11,%rdx,4)
add    $0x4,%rdx
cmp    %rdx,%rdi
jne    1310 <sample_cla+0x190>
jmp    12b0 <sample_cla+0x130>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
cmpq   $0x18,0x28(%rsp)
jae    135f <sample_cla+0x1df>
xor    %edx,%edx
jmp    13dc <sample_cla+0x25c>
mov    0x40(%rsp),%r14
xor    %edx,%edx
cs nopw 0x0(%rax,%rax,1)
movups (%r10,%rdx,4),%xmm0
movups 0x10(%r10,%rdx,4),%xmm1
movups %xmm0,(%r11,%rdx,4)
movups %xmm1,0x10(%r11,%rdx,4)
movups 0x20(%r10,%rdx,4),%xmm0
movups 0x30(%r10,%rdx,4),%xmm1
movups %xmm0,0x20(%r11,%rdx,4)
movups %xmm1,0x30(%r11,%rdx,4)
movups 0x40(%r10,%rdx,4),%xmm0
movups 0x50(%r10,%rdx,4),%xmm1
movups %xmm0,0x40(%r11,%rdx,4)
movups %xmm1,0x50(%r11,%rdx,4)
movupd 0x60(%r10,%rdx,4),%xmm0
movupd 0x70(%r10,%rdx,4),%xmm1
movupd %xmm0,0x60(%r11,%rdx,4)
movupd %xmm1,0x70(%r11,%rdx,4)
add    $0x20,%rdx
add    $0xfffffffffffffffc,%r14
jne    1370 <sample_cla+0x1f0>
cmpq   $0x0,0x48(%rsp)
je     141f <sample_cla+0x29f>
lea    (%r11,%rdx,4),%rcx
add    $0x10,%rcx
lea    (%r10,%rdx,4),%rdx
add    $0x10,%rdx
xor    %esi,%esi
cs nopw 0x0(%rax,%rax,1)
movupd -0x10(%rdx,%rsi,1),%xmm0
movupd (%rdx,%rsi,1),%xmm1
movupd %xmm0,-0x10(%rcx,%rsi,1)
movupd %xmm1,(%rcx,%rsi,1)
add    $0x20,%rsi
cmp    %rsi,%rbp
jne    1400 <sample_cla+0x280>
mov    %r12,%rdx
cmp    %rdi,%r12
mov    0x30(%rsp),%r14
je     12b0 <sample_cla+0x130>
jmp    12de <sample_cla+0x15e>
mov    0x10(%rsp),%rbp
lea    0x0(,%rbp,8),%r13d
mov    %r13d,%edi
call   1080 <malloc@plt>
mov    %rax,%r14
mov    %r13d,%edi
call   1080 <malloc@plt>
mov    %rax,%r12
mov    %r13d,%edi
mov    %rbp,%r13
call   1080 <malloc@plt>
mov    %rax,%rbp
test   %r13d,%r13d
jle    1542 <sample_cla+0x3c2>
mov    %rbp,0x18(%rsp)
mov    %r12,0x38(%rsp)
mov    0x10(%rsp),%eax
mov    %rax,0x28(%rsp)
xor    %ebp,%ebp
mov    0x20(%rsp),%r13d
mov    0x30(%rsp),%r12
mov    %r14,0x8(%rsp)
mov    0x50(%rsp),%r14
nopl   0x0(%rax,%rax,1)
mov    (%r14,%rbp,8),%r8
mov    %r13d,%edi
mov    %r15d,%esi
mov    %ebx,%edx
mov    %r12,%rcx
call   1070 <log_dsty_Y@plt>
mov    0x8(%rsp),%rax
movsd  %xmm0,(%rax,%rbp,8)
add    $0x1,%rbp
cmp    %rbp,0x28(%rsp)
jne    14a0 <sample_cla+0x320>
mov    0x8(%rsp),%r14
mov    %r14,%rdi
mov    0x10(%rsp),%rbp
mov    %ebp,%esi
call   1030 <maximum@plt>
test   %ebp,%ebp
mov    0x38(%rsp),%r12
mov    0x18(%rsp),%rbp
mov    0xa0(%rsp),%r13
jle    154f <sample_cla+0x3cf>
movapd %xmm0,%xmm1
xor    %r15d,%r15d
movsd  %xmm0,0x40(%rsp)
movsd  (%r14,%r15,8),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,(%r12,%r15,8)
movsd  0x0(%r13,%r15,8),%xmm1
movsd  %xmm1,0x48(%rsp)
call   1090 <exp@plt>
movsd  0x40(%rsp),%xmm1
mulsd  0x48(%rsp),%xmm0
movsd  %xmm0,0x0(%rbp,%r15,8)
add    $0x1,%r15
cmp    %r15,0x28(%rsp)
jne    1500 <sample_cla+0x380>
jmp    154f <sample_cla+0x3cf>
mov    %r14,%rdi
mov    0x10(%rsp),%rsi
call   1030 <maximum@plt>
mov    0x10(%rsp),%rdi
mov    %rbp,%rsi
call   1050 <rdiscrete@plt>
mov    %eax,%r15d
mov    %r14,%rdi
call   1040 <free@plt>
mov    %r12,%rdi
call   1040 <free@plt>
mov    %rbp,%rdi
call   1040 <free@plt>
mov    0x30(%rsp),%rdi
mov    0x20(%rsp),%esi
mov    0x24(%rsp),%edx
mov    %ebx,%ecx
mov    %ebx,%r8d
call   1060 <delet4Darray_int_continuousMem@plt>
mov    %r15d,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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