#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*/ assert(int);
double log(double);
double *myfree(double *, int);
double *mymalloc(int);
double SHSupport(int nPos, int nBootstrap, int *col, double loglk[3],
                 double *site_likelihoods[3]) {
  long lPos = nPos;
  assert(nBootstrap > 0);
  double delta1 = loglk[0] - loglk[1];
  double delta2 = loglk[0] - loglk[2];
  double delta = delta1 < delta2 ? delta1 : delta2;
  double *siteloglk[3];
  int i, j;
  for (i = 0; i < 3; i++) {
    siteloglk[i] = mymalloc(sizeof(double) * nPos);
    for (j = 0; j < nPos; j++)
      siteloglk[i][j] = log(site_likelihoods[i][j]);
  }
  int nSupport = 0;
  int iBoot;
  for (iBoot = 0; iBoot < nBootstrap; iBoot++) {
    double resampled[3];
    for (i = 0; i < 3; i++)
      resampled[i] = -loglk[i];
    for (j = 0; j < nPos; j++) {
      int pos = col[iBoot * lPos + j];
      for (i = 0; i < 3; i++)
        resampled[i] += siteloglk[i][pos];
    }
    int iBest = 0;
    for (i = 1; i < 3; i++)
      if (resampled[i] > resampled[iBest])
        iBest = i;
    double resample1 = resampled[iBest] - resampled[(iBest + 1) % 3];
    double resample2 = resampled[iBest] - resampled[(iBest + 2) % 3];
    double resampleDelta = resample1 < resample2 ? resample1 : resample2;
    if (resampleDelta < delta)
      nSupport++;
  }
  for (i = 0; i < 3; i++)
    siteloglk[i] = myfree(siteloglk[i], sizeof(double) * nPos);
  return (nSupport / (double)nBootstrap);
}


x86 assembly (clang, -O0):
<SHSupport>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
movslq -0x4(%rbp),%rax
mov    %rax,-0x28(%rbp)
cmpl   $0x0,-0x8(%rbp)
setg   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x18(%rbp),%rax
subsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x18(%rbp),%rax
subsd  0x10(%rax),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x30(%rbp),%xmm1
movsd  -0x38(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    11c8 <SHSupport+0x88>
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0xb8(%rbp)
ff
jmp    11d5 <SHSupport+0x95>
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0xb8(%rbp)
ff
movsd  -0xb8(%rbp),%xmm0
ff
movsd  %xmm0,-0x40(%rbp)
movl   $0x0,-0x64(%rbp)
cmpl   $0x3,-0x64(%rbp)
jge    126e <SHSupport+0x12e>
movslq -0x4(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1040 <mymalloc@plt>
mov    %rax,%rcx
movslq -0x64(%rbp),%rax
mov    %rcx,-0x60(%rbp,%rax,8)
movl   $0x0,-0x68(%rbp)
mov    -0x68(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    125b <SHSupport+0x11b>
mov    -0x20(%rbp),%rax
movslq -0x64(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x68(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
call   1050 <log@plt>
movslq -0x64(%rbp),%rax
mov    -0x60(%rbp,%rax,8),%rax
movslq -0x68(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x68(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x68(%rbp)
jmp    1215 <SHSupport+0xd5>
jmp    1260 <SHSupport+0x120>
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    11e9 <SHSupport+0xa9>
movl   $0x0,-0x6c(%rbp)
movl   $0x0,-0x70(%rbp)
mov    -0x70(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    14ab <SHSupport+0x36b>
movl   $0x0,-0x64(%rbp)
cmpl   $0x3,-0x64(%rbp)
jge    12d8 <SHSupport+0x198>
mov    -0x18(%rbp),%rax
movslq -0x64(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movslq -0x64(%rbp),%rax
movsd  %xmm0,-0x90(%rbp,%rax,8)
ff ff
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    128f <SHSupport+0x14f>
movl   $0x0,-0x68(%rbp)
mov    -0x68(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1365 <SHSupport+0x225>
mov    -0x10(%rbp),%rax
movslq -0x70(%rbp),%rcx
imul   -0x28(%rbp),%rcx
movslq -0x68(%rbp),%rdx
add    %rdx,%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x94(%rbp)
movl   $0x0,-0x64(%rbp)
cmpl   $0x3,-0x64(%rbp)
jge    1352 <SHSupport+0x212>
movslq -0x64(%rbp),%rax
mov    -0x60(%rbp,%rax,8),%rax
movslq -0x94(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movslq -0x64(%rbp),%rax
addsd  -0x90(%rbp,%rax,8),%xmm0
ff ff
movsd  %xmm0,-0x90(%rbp,%rax,8)
ff ff
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    130f <SHSupport+0x1cf>
jmp    1357 <SHSupport+0x217>
mov    -0x68(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x68(%rbp)
jmp    12df <SHSupport+0x19f>
movl   $0x0,-0x98(%rbp)
movl   $0x1,-0x64(%rbp)
cmpl   $0x3,-0x64(%rbp)
jge    13bf <SHSupport+0x27f>
movslq -0x64(%rbp),%rax
movsd  -0x90(%rbp,%rax,8),%xmm0
ff ff
movslq -0x98(%rbp),%rax
ucomisd -0x90(%rbp,%rax,8),%xmm0
ff ff
jbe    13ac <SHSupport+0x26c>
mov    -0x64(%rbp),%eax
mov    %eax,-0x98(%rbp)
jmp    13b1 <SHSupport+0x271>
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    1376 <SHSupport+0x236>
movslq -0x98(%rbp),%rax
movsd  -0x90(%rbp,%rax,8),%xmm0
ff ff
mov    -0x98(%rbp),%eax
add    $0x1,%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
movslq %edx,%rax
subsd  -0x90(%rbp,%rax,8),%xmm0
ff ff
movsd  %xmm0,-0xa0(%rbp)
ff
movslq -0x98(%rbp),%rax
movsd  -0x90(%rbp,%rax,8),%xmm0
ff ff
mov    -0x98(%rbp),%eax
add    $0x2,%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
movslq %edx,%rax
subsd  -0x90(%rbp,%rax,8),%xmm0
ff ff
movsd  %xmm0,-0xa8(%rbp)
ff
movsd  -0xa0(%rbp),%xmm1
ff
movsd  -0xa8(%rbp),%xmm0
ff
ucomisd %xmm1,%xmm0
jbe    1458 <SHSupport+0x318>
movsd  -0xa0(%rbp),%xmm0
ff
movsd  %xmm0,-0xc0(%rbp)
ff
jmp    1468 <SHSupport+0x328>
movsd  -0xa8(%rbp),%xmm0
ff
movsd  %xmm0,-0xc0(%rbp)
ff
movsd  -0xc0(%rbp),%xmm0
ff
movsd  %xmm0,-0xb0(%rbp)
ff
movsd  -0xb0(%rbp),%xmm1
ff
movsd  -0x40(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1498 <SHSupport+0x358>
mov    -0x6c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x6c(%rbp)
jmp    149d <SHSupport+0x35d>
mov    -0x70(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x70(%rbp)
jmp    127c <SHSupport+0x13c>
movl   $0x0,-0x64(%rbp)
cmpl   $0x3,-0x64(%rbp)
jge    14ee <SHSupport+0x3ae>
movslq -0x64(%rbp),%rax
mov    -0x60(%rbp,%rax,8),%rdi
movslq -0x4(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%esi
call   1060 <myfree@plt>
mov    %rax,%rcx
movslq -0x64(%rbp),%rax
mov    %rcx,-0x60(%rbp,%rax,8)
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    14b2 <SHSupport+0x372>
cvtsi2sdl -0x6c(%rbp),%xmm0
cvtsi2sdl -0x8(%rbp),%xmm1
divsd  %xmm1,%xmm0
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SHSupport>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
mov    %r8,%r12
mov    %rcx,%rbp
mov    %rdx,0x30(%rsp)
mov    %edi,%ebx
xor    %edi,%edi
mov    %esi,0x4(%rsp)
test   %esi,%esi
setg   %dil
call   1030 <assert@plt>
movups 0x8(%rbp),%xmm0
movaps %xmm0,0x40(%rsp)
mov    %rbp,0x38(%rsp)
movsd  0x0(%rbp),%xmm0
movapd %xmm0,0x50(%rsp)
lea    0x0(,%rbx,8),%r14d
mov    %r14d,%edi
call   1040 <mymalloc@plt>
mov    %rax,%r13
mov    %ebx,%r15d
mov    %rbx,0x8(%rsp)
test   %ebx,%ebx
mov    %r14d,0x2c(%rsp)
jle    1255 <SHSupport+0x115>
xor    %ebp,%ebp
nop
mov    (%r12),%rax
movsd  (%rax,%rbp,8),%xmm0
call   1050 <log@plt>
movsd  %xmm0,0x0(%r13,%rbp,8)
add    $0x1,%rbp
cmp    %rbp,%r15
jne    11b0 <SHSupport+0x70>
mov    %r14d,%edi
call   1040 <mymalloc@plt>
mov    %rax,%rbp
cmpl   $0x0,0x8(%rsp)
jle    1260 <SHSupport+0x120>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
mov    0x8(%r12),%rax
movsd  (%rax,%rbx,8),%xmm0
call   1050 <log@plt>
movsd  %xmm0,0x0(%rbp,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%r15
jne    11f0 <SHSupport+0xb0>
mov    %r14d,%edi
call   1040 <mymalloc@plt>
mov    %rax,%r14
cmpl   $0x0,0x8(%rsp)
jle    124e <SHSupport+0x10e>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    0x10(%r12),%rax
movsd  (%rax,%rbx,8),%xmm0
call   1050 <log@plt>
movsd  %xmm0,(%r14,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1230 <SHSupport+0xf0>
mov    0x4(%rsp),%r12d
jmp    1270 <SHSupport+0x130>
mov    %r14d,%edi
call   1040 <mymalloc@plt>
mov    %rax,%rbp
mov    0x4(%rsp),%r12d
mov    %r14d,%edi
call   1040 <mymalloc@plt>
mov    %rax,%r14
test   %r12d,%r12d
movapd 0x50(%rsp),%xmm6
jle    1482 <SHSupport+0x342>
unpcklpd %xmm6,%xmm6
subpd  0x40(%rsp),%xmm6
movapd %xmm6,%xmm0
unpckhpd %xmm6,%xmm0
movslq 0x8(%rsp),%r8
minsd  %xmm0,%xmm6
mov    %r12d,%r10d
mov    0x38(%rsp),%rax
movdqu 0x8(%rax),%xmm0
movq   (%rax),%xmm1
movdqa 0xd4d(%rip),%xmm2
pxor   %xmm2,%xmm1
pxor   %xmm2,%xmm0
pshufd $0xee,%xmm0,%xmm2
mov    %r15d,%edx
and    $0xfffffffe,%edx
mov    0x30(%rsp),%rax
lea    0x4(%rax),%rsi
lea    0x0(,%r8,4),%r11
xor    %eax,%eax
mov    $0x2,%r9d
xor    %r12d,%r12d
jmp    136b <SHSupport+0x22b>
nopw   0x0(%rax,%rax,1)
xor    %edi,%edi
ucomisd %xmm3,%xmm4
seta   %dil
ucomisd 0x10(%rsp,%rdi,8),%xmm5
cmova  %r9d,%edi
movsd  0x10(%rsp,%rdi,8),%xmm3
lea    0x1(%rdi),%ebx
movzbl %bl,%ebx
imul   $0xab,%ebx,%ecx
shr    $0x9,%ecx
lea    (%rcx,%rcx,2),%ecx
sub    %cl,%bl
movzbl %bl,%ecx
movapd %xmm3,%xmm4
subsd  0x10(%rsp,%rcx,8),%xmm4
add    $0x2,%dil
movzbl %dil,%ecx
imul   $0xab,%ecx,%edi
shr    $0x9,%edi
lea    (%rdi,%rdi,2),%edi
sub    %dil,%cl
movzbl %cl,%ecx
subsd  0x10(%rsp,%rcx,8),%xmm3
minsd  %xmm3,%xmm4
xor    %ecx,%ecx
ucomisd %xmm4,%xmm6
seta   %cl
add    %ecx,%r12d
add    $0x1,%rax
add    %r11,%rsi
cmp    %r10,%rax
je     146d <SHSupport+0x32d>
movq   %xmm1,0x10(%rsp)
movdqu %xmm0,0x18(%rsp)
movdqa %xmm2,%xmm5
movdqa %xmm1,%xmm3
movdqa %xmm0,%xmm4
cmpl   $0x0,0x8(%rsp)
jle    12f0 <SHSupport+0x1b0>
cmpl   $0x1,0x8(%rsp)
jne    13b0 <SHSupport+0x270>
movdqa %xmm1,%xmm3
xor    %edi,%edi
movdqa %xmm0,%xmm4
test   $0x1,%r15b
je     12f0 <SHSupport+0x1b0>
jmp    142a <SHSupport+0x2ea>
nopl   0x0(%rax,%rax,1)
movdqa %xmm1,%xmm3
xor    %edi,%edi
movdqa %xmm0,%xmm4
nopw   0x0(%rax,%rax,1)
movslq -0x4(%rsi,%rdi,4),%rcx
addsd  0x0(%r13,%rcx,8),%xmm3
movsd  %xmm3,0x10(%rsp)
movsd  0x0(%rbp,%rcx,8),%xmm5
movhpd (%r14,%rcx,8),%xmm5
addpd  %xmm4,%xmm5
movupd %xmm5,0x18(%rsp)
movslq (%rsi,%rdi,4),%rcx
addsd  0x0(%r13,%rcx,8),%xmm3
movsd  %xmm3,0x10(%rsp)
movsd  0x0(%rbp,%rcx,8),%xmm4
movhpd (%r14,%rcx,8),%xmm4
addpd  %xmm5,%xmm4
movupd %xmm4,0x18(%rsp)
add    $0x2,%rdi
cmp    %rdi,%rdx
jne    13c0 <SHSupport+0x280>
movapd %xmm4,%xmm5
unpckhpd %xmm4,%xmm5
test   $0x1,%r15b
je     12f0 <SHSupport+0x1b0>
mov    %rax,%rbx
imul   %r8,%rbx
add    %rdi,%rbx
mov    0x30(%rsp),%rcx
movslq (%rcx,%rbx,4),%rdi
addsd  0x0(%r13,%rdi,8),%xmm3
movsd  %xmm3,0x10(%rsp)
movsd  0x0(%rbp,%rdi,8),%xmm5
movhpd (%r14,%rdi,8),%xmm5
addpd  %xmm5,%xmm4
movupd %xmm4,0x18(%rsp)
movapd %xmm4,%xmm5
unpckhpd %xmm4,%xmm5
jmp    12f0 <SHSupport+0x1b0>
xorps  %xmm0,%xmm0
cvtsi2sd %r12d,%xmm0
movsd  %xmm0,0x8(%rsp)
mov    0x4(%rsp),%r12d
jmp    148c <SHSupport+0x34c>
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x8(%rsp)
mov    %r13,%rdi
mov    0x2c(%rsp),%ebx
mov    %ebx,%esi
call   1060 <myfree@plt>
mov    %rbp,%rdi
mov    %ebx,%esi
call   1060 <myfree@plt>
mov    %r14,%rdi
mov    %ebx,%esi
call   1060 <myfree@plt>
cvtsi2sd %r12d,%xmm1
movsd  0x8(%rsp),%xmm0
divsd  %xmm1,%xmm0
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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