void gamma_index(int ndim, int *shape, double *first_matrix,
                 double *second_matrix, double *result, double dd, double dta) {
  double rel_dd = dd / dta;
  double *first_matrix_rel;
  double *second_matrix_rel;
  int *strides;
  int *running_index;
  int total_size = 1;
  int i;
  strides = (int *)malloc(sizeof(int) * ndim);
  strides[ndim - 1] = 1;
  for (i = ndim - 1; i > 0; i--) {
    strides[i - 1] = strides[i] * shape[i];
    total_size *= shape[i];
  }
  total_size *= shape[0];
  first_matrix_rel = malloc(sizeof(double) * total_size);
  second_matrix_rel = malloc(sizeof(double) * total_size);
  for (i = 0; i < total_size; i++) {
    first_matrix_rel[i] = first_matrix[i] / rel_dd;
    second_matrix_rel[i] = second_matrix[i] / rel_dd;
  }
  running_index = (int *)malloc(sizeof(int) * ndim);
  for (i = 0; i < ndim; i++) {
    running_index[i] = 0;
  }
  for (int j = 0; j < total_size; j++) {
    result[j] = sqrt(gamma_index_point(ndim, shape, strides, running_index,
                                       first_matrix_rel, second_matrix_rel)) /
                dta;
    running_index[ndim - 1]++;
    i = ndim - 1;
    for (i = ndim - 1; i > 0; i--) {
      if (running_index[i] == shape[i]) {
        running_index[i] = 0;
        running_index[i - 1]++;
      } else {
        break;
      }
    }
  }
  free(strides);
  free(running_index);
  free(first_matrix_rel);
  free(second_matrix_rel);
}


x86 assembly (clang, -O0):
<gamma_index>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
movsd  %xmm0,-0x30(%rbp)
movsd  %xmm1,-0x38(%rbp)
movsd  -0x30(%rbp),%xmm0
divsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movl   $0x1,-0x64(%rbp)
movslq -0x4(%rbp),%rdi
shl    $0x2,%rdi
call   1050 <malloc@plt>
mov    %rax,-0x58(%rbp)
mov    -0x58(%rbp),%rax
mov    -0x4(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movl   $0x1,(%rax,%rcx,4)
mov    -0x4(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x68(%rbp)
cmpl   $0x0,-0x68(%rbp)
jle    11fa <gamma_index+0xba>
mov    -0x58(%rbp),%rax
movslq -0x68(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
mov    -0x10(%rbp),%rax
movslq -0x68(%rbp),%rcx
imul   (%rax,%rcx,4),%edx
mov    -0x58(%rbp),%rax
mov    -0x68(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x10(%rbp),%rax
movslq -0x68(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
imul   -0x64(%rbp),%eax
mov    %eax,-0x64(%rbp)
mov    -0x68(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x68(%rbp)
jmp    11a9 <gamma_index+0x69>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
imul   -0x64(%rbp),%eax
mov    %eax,-0x64(%rbp)
movslq -0x64(%rbp),%rdi
shl    $0x3,%rdi
call   1050 <malloc@plt>
mov    %rax,-0x48(%rbp)
movslq -0x64(%rbp),%rdi
shl    $0x3,%rdi
call   1050 <malloc@plt>
mov    %rax,-0x50(%rbp)
movl   $0x0,-0x68(%rbp)
mov    -0x68(%rbp),%eax
cmp    -0x64(%rbp),%eax
jge    1288 <gamma_index+0x148>
mov    -0x18(%rbp),%rax
movslq -0x68(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
divsd  -0x40(%rbp),%xmm0
mov    -0x48(%rbp),%rax
movslq -0x68(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x20(%rbp),%rax
movslq -0x68(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
divsd  -0x40(%rbp),%xmm0
mov    -0x50(%rbp),%rax
movslq -0x68(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x68(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x68(%rbp)
jmp    1230 <gamma_index+0xf0>
movslq -0x4(%rbp),%rdi
shl    $0x2,%rdi
call   1050 <malloc@plt>
mov    %rax,-0x60(%rbp)
movl   $0x0,-0x68(%rbp)
mov    -0x68(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    12c9 <gamma_index+0x189>
mov    -0x60(%rbp),%rax
movslq -0x68(%rbp),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    -0x68(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x68(%rbp)
jmp    12a0 <gamma_index+0x160>
movl   $0x0,-0x6c(%rbp)
mov    -0x6c(%rbp),%eax
cmp    -0x64(%rbp),%eax
jge    13b8 <gamma_index+0x278>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x58(%rbp),%rdx
mov    -0x60(%rbp),%rcx
mov    -0x48(%rbp),%r8
mov    -0x50(%rbp),%r9
mov    $0x0,%al
call   1040 <gamma_index_point@plt>
cvtsi2sd %eax,%xmm0
call   1060 <sqrt@plt>
divsd  -0x38(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movslq -0x6c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x60(%rbp),%rax
mov    -0x4(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%edx
add    $0x1,%edx
mov    %edx,(%rax,%rcx,4)
mov    -0x4(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x68(%rbp)
mov    -0x4(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x68(%rbp)
cmpl   $0x0,-0x68(%rbp)
jle    13a5 <gamma_index+0x265>
mov    -0x60(%rbp),%rax
movslq -0x68(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    -0x10(%rbp),%rcx
movslq -0x68(%rbp),%rdx
cmp    (%rcx,%rdx,4),%eax
jne    138d <gamma_index+0x24d>
mov    -0x60(%rbp),%rax
movslq -0x68(%rbp),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    -0x60(%rbp),%rax
mov    -0x68(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%edx
add    $0x1,%edx
mov    %edx,(%rax,%rcx,4)
jmp    1392 <gamma_index+0x252>
jmp    13a5 <gamma_index+0x265>
jmp    1397 <gamma_index+0x257>
mov    -0x68(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x68(%rbp)
jmp    133d <gamma_index+0x1fd>
jmp    13aa <gamma_index+0x26a>
mov    -0x6c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x6c(%rbp)
jmp    12d0 <gamma_index+0x190>
mov    -0x58(%rbp),%rdi
call   1030 <free@plt>
mov    -0x60(%rbp),%rdi
call   1030 <free@plt>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
mov    -0x50(%rbp),%rdi
call   1030 <free@plt>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gamma_index>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
movq   %xmm1,0x18(%rsp)
movdqa %xmm0,0x30(%rsp)
mov    %r8,0x50(%rsp)
mov    %rcx,%r12
mov    %rdx,0x48(%rsp)
mov    %rsi,%rbx
mov    %rdi,0x10(%rsp)
movslq %edi,%rbp
lea    0x0(,%rbp,4),%rdi
mov    %rdi,0x40(%rsp)
call   1060 <malloc@plt>
mov    %rax,%r11
lea    -0x1(%rbp),%rsi
movl   $0x1,-0x4(%rax,%rbp,4)
mov    $0x1,%edi
cmp    $0x2,%ebp
mov    %rsi,0x20(%rsp)
jl     1200 <gamma_index+0xb0>
mov    %esi,%r14d
cmp    $0x1,%esi
mov    %r14,%r9
adc    $0xffffffffffffffff,%r9
add    $0x1,%r9
mov    $0x1,%edi
cmp    $0x8,%r9
jae    1477 <gamma_index+0x327>
mov    %r14,%rax
add    $0x1,%rax
nopl   0x0(%rax)
mov    -0x4(%rbx,%rax,4),%ecx
mov    -0x4(%r11,%rax,4),%edx
imul   %ecx,%edx
lea    -0x2(%rax),%esi
mov    %edx,(%r11,%rsi,4)
imul   %ecx,%edi
add    $0xffffffffffffffff,%rax
cmp    $0x1,%rax
ja     11e0 <gamma_index+0x90>
mov    %r11,0x28(%rsp)
movslq (%rbx),%rax
movslq %edi,%rbp
imul   %rax,%rbp
mov    %rbp,%r15
shl    $0x3,%r15
mov    %r15,%rdi
call   1060 <malloc@plt>
mov    %rax,%r14
mov    %r15,%rdi
call   1060 <malloc@plt>
mov    %rax,%r13
mov    %ebp,%r15d
mov    %rbp,0x8(%rsp)
test   %ebp,%ebp
movapd 0x30(%rsp),%xmm2
mov    0x48(%rsp),%rdi
jle    1339 <gamma_index+0x1e9>
divsd  0x18(%rsp),%xmm2
cmpl   $0x1,0x8(%rsp)
jne    125b <gamma_index+0x10b>
xor    %eax,%eax
jmp    1310 <gamma_index+0x1c0>
mov    %r15d,%eax
and    $0xfffffffe,%eax
movapd %xmm2,%xmm0
unpcklpd %xmm2,%xmm0
lea    -0x2(%rax),%rcx
mov    %rcx,%rdx
shr    %rdx
add    $0x1,%rdx
test   %rcx,%rcx
je     1661 <gamma_index+0x511>
mov    %rdx,%rsi
and    $0xfffffffffffffffe,%rsi
xor    %ecx,%ecx
nopl   0x0(%rax)
movupd (%rdi,%rcx,8),%xmm1
divpd  %xmm0,%xmm1
movupd %xmm1,(%r14,%rcx,8)
movupd (%r12,%rcx,8),%xmm1
divpd  %xmm0,%xmm1
movupd %xmm1,0x0(%r13,%rcx,8)
movupd 0x10(%rdi,%rcx,8),%xmm1
divpd  %xmm0,%xmm1
movupd %xmm1,0x10(%r14,%rcx,8)
movupd 0x10(%r12,%rcx,8),%xmm1
divpd  %xmm0,%xmm1
movupd %xmm1,0x10(%r13,%rcx,8)
add    $0x4,%rcx
add    $0xfffffffffffffffe,%rsi
jne    1290 <gamma_index+0x140>
test   $0x1,%dl
je     1302 <gamma_index+0x1b2>
movupd (%rdi,%rcx,8),%xmm1
divpd  %xmm0,%xmm1
movupd %xmm1,(%r14,%rcx,8)
movupd (%r12,%rcx,8),%xmm1
divpd  %xmm0,%xmm1
movupd %xmm1,0x0(%r13,%rcx,8)
cmp    %r15,%rax
je     1339 <gamma_index+0x1e9>
nopw   0x0(%rax,%rax,1)
movsd  (%rdi,%rax,8),%xmm0
divsd  %xmm2,%xmm0
movsd  %xmm0,(%r14,%rax,8)
movsd  (%r12,%rax,8),%xmm0
divsd  %xmm2,%xmm0
movsd  %xmm0,0x0(%r13,%rax,8)
add    $0x1,%rax
cmp    %rax,%r15
jne    1310 <gamma_index+0x1c0>
mov    0x40(%rsp),%rdi
call   1060 <malloc@plt>
mov    %rax,%rbp
mov    0x10(%rsp),%rdi
test   %edi,%edi
jle    1364 <gamma_index+0x214>
mov    %edi,%edx
shl    $0x2,%rdx
mov    %rbp,%rdi
xor    %esi,%esi
call   1040 <memset@plt>
mov    0x10(%rsp),%rdi
cmpl   $0x0,0x8(%rsp)
mov    0x28(%rsp),%rdx
mov    0x20(%rsp),%rax
jle    1449 <gamma_index+0x2f9>
mov    %eax,%eax
mov    %rax,0x8(%rsp)
lea    -0x2(%rdi),%eax
lea    0x0(,%rax,4),%rax
add    %rbp,%rax
mov    %rax,0x30(%rsp)
xor    %r12d,%r12d
jmp    13ad <gamma_index+0x25d>
nopl   0x0(%rax,%rax,1)
add    $0x1,%r12
cmp    %r15,%r12
je     1449 <gamma_index+0x2f9>
mov    %rbx,%rsi
mov    %rbp,%rcx
mov    %r14,%r8
mov    %r13,%r9
xor    %eax,%eax
call   1050 <gamma_index_point@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
ucomisd 0xc41(%rip),%xmm0
jb     13e0 <gamma_index+0x290>
sqrtsd %xmm0,%xmm0
jmp    13e5 <gamma_index+0x295>
nopw   0x0(%rax,%rax,1)
call   1070 <sqrt@plt>
divsd  0x18(%rsp),%xmm0
mov    0x50(%rsp),%rax
movsd  %xmm0,(%rax,%r12,8)
mov    0x20(%rsp),%rax
addl   $0x1,0x0(%rbp,%rax,4)
mov    0x10(%rsp),%rdi
cmp    $0x2,%edi
mov    0x28(%rsp),%rdx
jl     13a0 <gamma_index+0x250>
mov    0x8(%rsp),%rax
mov    0x0(%rbp,%rax,4),%esi
mov    0x30(%rsp),%rax
mov    %edi,%ecx
nop
add    $0xffffffff,%ecx
cmp    (%rbx,%rcx,4),%esi
jne    13a0 <gamma_index+0x250>
movl   $0x0,0x0(%rbp,%rcx,4)
mov    (%rax),%esi
add    $0x1,%esi
mov    %esi,(%rax)
add    $0xfffffffffffffffc,%rax
cmp    $0x1,%ecx
jg     1420 <gamma_index+0x2d0>
jmp    13a0 <gamma_index+0x250>
mov    %rdx,%rdi
call   1030 <free@plt>
mov    %rbp,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %r13,%rdi
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>
cmp    $0x1,%esi
mov    %r14,%rcx
adc    $0xffffffffffffffff,%rcx
mov    0x10(%rsp),%rax
lea    -0x2(%rax),%r8d
mov    $0x4,%edx
mov    %rcx,%rax
mul    %rdx
seto   %dl
cmp    %ecx,%r8d
jb     11d2 <gamma_index+0x82>
shr    $0x20,%rcx
jne    11d2 <gamma_index+0x82>
lea    (%r11,%r8,4),%rbp
mov    %rbp,%rcx
sub    %rax,%rcx
cmp    %rbp,%rcx
ja     11d2 <gamma_index+0x82>
test   %dl,%dl
jne    11d2 <gamma_index+0x82>
lea    (%r11,%r14,4),%rbp
mov    %rbp,%rcx
sub    %rax,%rcx
cmp    %rbp,%rcx
ja     11d2 <gamma_index+0x82>
test   %dl,%dl
jne    11d2 <gamma_index+0x82>
lea    0x0(,%r14,4),%rcx
xor    %eax,%eax
test   %esi,%esi
setne  %al
lea    0x0(,%r8,4),%rdx
lea    (%rdx,%rax,4),%rdx
sub    %rcx,%rdx
add    %r11,%rdx
lea    (%r11,%r14,4),%rbp
add    $0x4,%rbp
cmp    %rbp,%rdx
jae    1524 <gamma_index+0x3d4>
lea    (%r11,%r8,4),%rdx
add    $0x4,%rdx
lea    (%r11,%rax,4),%rax
cmp    %rdx,%rax
jb     11d2 <gamma_index+0x82>
mov    %r9,%r8
and    $0xfffffffffffffff8,%r8
mov    %r14,%rax
sub    %r8,%rax
mov    %r8,%r10
neg    %r10
lea    (%rcx,%r11,1),%rdi
add    $0xfffffffffffffff4,%rdi
lea    (%rbx,%r14,4),%rcx
add    $0xfffffffffffffff4,%rcx
mov    $0xffffffff,%ebp
add    %r14,%rbp
movdqa 0xaa9(%rip),%xmm0
xor    %esi,%esi
movdqa %xmm0,%xmm1
nopl   (%rax)
movdqu -0x10(%rdi,%rsi,4),%xmm8
movdqu (%rdi,%rsi,4),%xmm6
movdqu -0x10(%rcx,%rsi,4),%xmm5
movdqu (%rcx,%rsi,4),%xmm7
pshufd $0x1b,%xmm7,%xmm3
pshufd $0x1b,%xmm5,%xmm10
pshufd $0xf5,%xmm7,%xmm4
pshufd $0x4e,%xmm7,%xmm9
pmuludq %xmm6,%xmm7
pshufd $0xe8,%xmm7,%xmm7
pshufd $0xf5,%xmm6,%xmm6
pmuludq %xmm6,%xmm4
pshufd $0xe8,%xmm4,%xmm4
punpckldq %xmm4,%xmm7
pshufd $0xf5,%xmm5,%xmm4
pshufd $0x4e,%xmm5,%xmm6
pmuludq %xmm8,%xmm5
pshufd $0xe8,%xmm5,%xmm5
pshufd $0xf5,%xmm8,%xmm2
pmuludq %xmm2,%xmm4
pshufd $0xe8,%xmm4,%xmm2
punpckldq %xmm2,%xmm5
lea    0x0(%rbp,%rsi,1),%edx
movdqu %xmm7,-0xc(%r11,%rdx,4)
movdqu %xmm5,-0x1c(%r11,%rdx,4)
pshufd $0xf5,%xmm0,%xmm2
pmuludq %xmm9,%xmm2
pshufd $0xe8,%xmm2,%xmm2
pmuludq %xmm0,%xmm3
pshufd $0xe8,%xmm3,%xmm0
punpckldq %xmm2,%xmm0
pshufd $0xf5,%xmm1,%xmm2
pmuludq %xmm6,%xmm2
pshufd $0xe8,%xmm2,%xmm2
pmuludq %xmm1,%xmm10
pshufd $0xe8,%xmm10,%xmm1
punpckldq %xmm2,%xmm1
add    $0xfffffffffffffff8,%rsi
cmp    %rsi,%r10
jne    1560 <gamma_index+0x410>
pshufd $0xf5,%xmm0,%xmm2
pshufd $0xf5,%xmm1,%xmm3
pmuludq %xmm2,%xmm3
pmuludq %xmm0,%xmm1
pshufd $0xee,%xmm1,%xmm0
pmuludq %xmm1,%xmm0
pshufd $0xaa,%xmm3,%xmm1
pmuludq %xmm3,%xmm1
pmuludq %xmm0,%xmm1
movd   %xmm1,%edi
cmp    %r8,%r9
jne    11d5 <gamma_index+0x85>
jmp    1200 <gamma_index+0xb0>
xor    %ecx,%ecx
test   $0x1,%dl
jne    12e2 <gamma_index+0x192>
jmp    1302 <gamma_index+0x1b2>

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

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