#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 InterpolatedGradZ3DMirr(float *, long, long, long, double, double,
                               double, long);
extern void BatchInterpolatedGradZ3DMirr(float *Bout, float *Bcoeff, long Width,
                                         long Height, long Slice, double nx,
                                         double offx, double mx, double ny,
                                         double offy, double my, double nz,
                                         double offz, double mz,
                                         long SplineDegree) {
  double x, y, z;
  long idx;
  long idcoordx, idcoordy, idcoordz;
  idx = 0;
  for (idcoordz = 0; idcoordz < nz; idcoordz++) {
    for (idcoordy = 0; idcoordy < ny; idcoordy++) {
      for (idcoordx = 0; idcoordx < nx; idcoordx++) {
        x = (idcoordx - offx) / mx;
        y = (idcoordy - offy) / my;
        z = (idcoordz - offz) / mz;
        Bout[idx++] = InterpolatedGradZ3DMirr(Bcoeff, Width, Height, Slice, x,
                                              y, z, SplineDegree) /
                      mz;
      }
    }
  }
}


x86 assembly (clang, -O0):
<BatchInterpolatedGradZ3DMirr>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
movsd  0x10(%rbp),%xmm8
mov    %rdi,-0x8(%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  %xmm2,-0x40(%rbp)
movsd  %xmm3,-0x48(%rbp)
movsd  %xmm4,-0x50(%rbp)
movsd  %xmm5,-0x58(%rbp)
movsd  %xmm6,-0x60(%rbp)
movsd  %xmm7,-0x68(%rbp)
mov    %r9,-0x70(%rbp)
movq   $0x0,-0x90(%rbp)
movq   $0x0,-0xa8(%rbp)
cvtsi2sdq -0xa8(%rbp),%xmm1
ff ff
movsd  -0x60(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    12c1 <BatchInterpolatedGradZ3DMirr+0x1b1>
movq   $0x0,-0xa0(%rbp)
cvtsi2sdq -0xa0(%rbp),%xmm1
ff ff
movsd  -0x48(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    12a5 <BatchInterpolatedGradZ3DMirr+0x195>
movq   $0x0,-0x98(%rbp)
cvtsi2sdq -0x98(%rbp),%xmm1
ff ff
movsd  -0x30(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1289 <BatchInterpolatedGradZ3DMirr+0x179>
cvtsi2sdq -0x98(%rbp),%xmm0
ff ff
subsd  -0x38(%rbp),%xmm0
divsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
cvtsi2sdq -0xa0(%rbp),%xmm0
ff ff
subsd  -0x50(%rbp),%xmm0
divsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x80(%rbp)
cvtsi2sdq -0xa8(%rbp),%xmm0
ff ff
subsd  -0x68(%rbp),%xmm0
divsd  0x10(%rbp),%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
movsd  -0x78(%rbp),%xmm0
movsd  -0x80(%rbp),%xmm1
movsd  -0x88(%rbp),%xmm2
ff
mov    -0x70(%rbp),%r8
call   1030 <InterpolatedGradZ3DMirr@plt>
divsd  0x10(%rbp),%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x8(%rbp),%rax
mov    -0x90(%rbp),%rcx
mov    %rcx,%rdx
add    $0x1,%rdx
mov    %rdx,-0x90(%rbp)
movss  %xmm0,(%rax,%rcx,4)
mov    -0x98(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x98(%rbp)
jmp    11bd <BatchInterpolatedGradZ3DMirr+0xad>
jmp    128e <BatchInterpolatedGradZ3DMirr+0x17e>
mov    -0xa0(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0xa0(%rbp)
jmp    119a <BatchInterpolatedGradZ3DMirr+0x8a>
jmp    12aa <BatchInterpolatedGradZ3DMirr+0x19a>
mov    -0xa8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0xa8(%rbp)
jmp    1177 <BatchInterpolatedGradZ3DMirr+0x67>
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<BatchInterpolatedGradZ3DMirr>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
movsd  %xmm7,0x8(%rsp)
movsd  %xmm5,0x30(%rsp)
movsd  %xmm4,0x28(%rsp)
mov    %rdi,0x20(%rsp)
xorpd  %xmm8,%xmm8
movsd  %xmm6,0x10(%rsp)
ucomisd %xmm8,%xmm6
jbe    12c3 <BatchInterpolatedGradZ3DMirr+0x1b3>
mov    %r9,%r15
movapd %xmm0,%xmm4
mov    %r8,%r12
mov    %rcx,%r13
mov    %rdx,%rbx
movsd  0xb0(%rsp),%xmm6
xor    %eax,%eax
mov    %rax,(%rsp)
xorpd  %xmm7,%xmm7
xor    %ebp,%ebp
movsd  %xmm3,0x18(%rsp)
movsd  %xmm2,0x58(%rsp)
movsd  %xmm1,0x50(%rsp)
movsd  %xmm0,0x48(%rsp)
jmp    11b7 <BatchInterpolatedGradZ3DMirr+0xa7>
nopw   0x0(%rax,%rax,1)
mov    (%rsp),%rdi
add    $0x1,%rdi
mov    %rdi,%rax
mov    %rdi,(%rsp)
xorps  %xmm7,%xmm7
cvtsi2sd %rdi,%xmm7
movsd  0x10(%rsp),%xmm0
ucomisd %xmm7,%xmm0
jbe    12c3 <BatchInterpolatedGradZ3DMirr+0x1b3>
ucomisd %xmm8,%xmm3
jbe    1190 <BatchInterpolatedGradZ3DMirr+0x80>
subsd  0x8(%rsp),%xmm7
divsd  %xmm6,%xmm7
xorpd  %xmm5,%xmm5
xor    %eax,%eax
movsd  %xmm7,0x60(%rsp)
jmp    11f2 <BatchInterpolatedGradZ3DMirr+0xe2>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%rax
xorps  %xmm5,%xmm5
cvtsi2sd %rax,%xmm5
ucomisd %xmm5,%xmm3
jbe    1190 <BatchInterpolatedGradZ3DMirr+0x80>
ucomisd %xmm8,%xmm4
jbe    11e0 <BatchInterpolatedGradZ3DMirr+0xd0>
mov    %rax,0x38(%rsp)
subsd  0x28(%rsp),%xmm5
divsd  0x30(%rsp),%xmm5
mov    0x20(%rsp),%rax
mov    %rbp,0x40(%rsp)
lea    (%rax,%rbp,4),%rax
mov    %rax,0x68(%rsp)
xorpd  %xmm0,%xmm0
xor    %r14d,%r14d
movsd  %xmm5,0x70(%rsp)
nopw   0x0(%rax,%rax,1)
subsd  %xmm1,%xmm0
divsd  %xmm2,%xmm0
mov    %rsi,%rdi
mov    %rsi,%rbp
mov    %rbx,%rsi
mov    %r13,%rdx
mov    %r12,%rcx
movapd %xmm5,%xmm1
movapd %xmm7,%xmm2
mov    %r15,%r8
call   1030 <InterpolatedGradZ3DMirr@plt>
movsd  0x70(%rsp),%xmm5
movsd  0x60(%rsp),%xmm7
movsd  0xb0(%rsp),%xmm6
mov    %rbp,%rsi
movsd  0x48(%rsp),%xmm4
movsd  0x50(%rsp),%xmm1
movsd  0x58(%rsp),%xmm2
divsd  %xmm6,%xmm0
cvtsd2ss %xmm0,%xmm0
mov    0x68(%rsp),%rax
movss  %xmm0,(%rax,%r14,4)
add    $0x1,%r14
xorps  %xmm0,%xmm0
cvtsi2sd %r14,%xmm0
ucomisd %xmm0,%xmm4
ja     1230 <BatchInterpolatedGradZ3DMirr+0x120>
mov    0x40(%rsp),%rbp
add    %r14,%rbp
movsd  0x18(%rsp),%xmm3
xorpd  %xmm8,%xmm8
mov    0x38(%rsp),%rax
jmp    11e0 <BatchInterpolatedGradZ3DMirr+0xd0>
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @BatchInterpolatedGradZ3DMirr(float* %0, float* %1, i64 %2, i64 %3, i64 %4, double %5, double %6, double %7, double %8, double %9, double %10, double %11, double %12, double %13, i64 %14) {
%16 = alloca float*
%17 = alloca float*
%18 = alloca i64
%19 = alloca i64
%20 = alloca i64
%21 = alloca double
%22 = alloca double
%23 = alloca double
%24 = alloca double
%25 = alloca double
%26 = alloca double
%27 = alloca double
%28 = alloca double
%29 = alloca double
%30 = alloca i64
%31 = alloca double
%32 = alloca double
%33 = alloca double
%34 = alloca i64
%35 = alloca i64
%36 = alloca i64
%37 = alloca i64
store float* %0, float** %16
store float* %1, float** %17
store i64 %2, i64* %18
store i64 %3, i64* %19
store i64 %4, i64* %20
store double %5, double* %21
store double %6, double* %22
store double %7, double* %23
store double %8, double* %24
store double %9, double* %25
store double %10, double* %26
store double %11, double* %27
store double %12, double* %28
store double %13, double* %29
store i64 %14, i64* %30
store i64 0, i64* %34
store i64 0, i64* %37
br label %38
38: ; preds = %98, %15
%39 = load i64, i64* %37
%40 = sitofp i64 %39 to double
%41 = load double, double* %27
%42 = fcmp olt double %40, %41
br i1 %42, label %43, label %101
43: ; preds = %38
store i64 0, i64* %36
br label %44
44: ; preds = %94, %43
%45 = load i64, i64* %36
%46 = sitofp i64 %45 to double
%47 = load double, double* %24
%48 = fcmp olt double %46, %47
br i1 %48, label %49, label %97
49: ; preds = %44
store i64 0, i64* %35
br label %50
50: ; preds = %90, %49
%51 = load i64, i64* %35
%52 = sitofp i64 %51 to double
%53 = load double, double* %21
%54 = fcmp olt double %52, %53
br i1 %54, label %55, label %93
55: ; preds = %50
%56 = load i64, i64* %35
%57 = sitofp i64 %56 to double
%58 = load double, double* %22
%59 = fsub double %57, %58
%60 = load double, double* %23
%61 = fdiv double %59, %60
store double %61, double* %31
%62 = load i64, i64* %36
%63 = sitofp i64 %62 to double
%64 = load double, double* %25
%65 = fsub double %63, %64
%66 = load double, double* %26
%67 = fdiv double %65, %66
store double %67, double* %32
%68 = load i64, i64* %37
%69 = sitofp i64 %68 to double
%70 = load double, double* %28
%71 = fsub double %69, %70
%72 = load double, double* %29
%73 = fdiv double %71, %72
store double %73, double* %33
%74 = load float*, float** %17
%75 = load i64, i64* %18
%76 = load i64, i64* %19
%77 = load i64, i64* %20
%78 = load double, double* %31
%79 = load double, double* %32
%80 = load double, double* %33
%81 = load i64, i64* %30
%82 = call double @InterpolatedGradZ3DMirr(float* %74, i64 %75, i64 %76, i64 %77, double %78, double %79, double %80, i64 %81)
%83 = load double, double* %29
%84 = fdiv double %82, %83
%85 = fptrunc double %84 to float
%86 = load float*, float** %16
%87 = load i64, i64* %34
%88 = add nsw i64 %87, 1
store i64 %88, i64* %34
%89 = getelementptr inbounds float, float* %86, i64 %87
store float %85, float* %89
br label %90
90: ; preds = %55
%91 = load i64, i64* %35
%92 = add nsw i64 %91, 1
store i64 %92, i64* %35
br label %50
93: ; preds = %50
br label %94
94: ; preds = %93
%95 = load i64, i64* %36
%96 = add nsw i64 %95, 1
store i64 %96, i64* %36
br label %44
97: ; preds = %44
br label %98
98: ; preds = %97
%99 = load i64, i64* %37
%100 = add nsw i64 %99, 1
store i64 %100, i64* %37
br label %38
101: ; preds = %38
ret void
}

LLVM IR (-O2):
define void @BatchInterpolatedGradZ3DMirr(float* nocapture writeonly %0, float* %1, i64 %2, i64 %3, i64 %4, double %5, double %6, double %7, double %8, double %9, double %10, double %11, double %12, double %13, i64 %14) {
%16 = fcmp ogt double %11, 0.000000e+00
br i1 %16, label %17, label %58
17: ; preds = %15
%18 = fcmp ogt double %8, 0.000000e+00
%19 = fcmp ogt double %5, 0.000000e+00
br label %20
20: ; preds = %17, %53
%21 = phi double [ 0.000000e+00, %17 ], [ %56, %53 ]
%22 = phi i64 [ 0, %17 ], [ %55, %53 ]
%23 = phi i64 [ 0, %17 ], [ %54, %53 ]
br i1 %18, label %24, label %53
24: ; preds = %20
%25 = fsub double %21, %12
%26 = fdiv double %25, %13
br label %27
27: ; preds = %24, %48
%28 = phi double [ 0.000000e+00, %24 ], [ %51, %48 ]
%29 = phi i64 [ 0, %24 ], [ %50, %48 ]
%30 = phi i64 [ %23, %24 ], [ %49, %48 ]
br i1 %19, label %31, label %48
31: ; preds = %27
%32 = fsub double %28, %9
%33 = fdiv double %32, %10
br label %34
34: ; preds = %31, %34
%35 = phi double [ 0.000000e+00, %31 ], [ %46, %34 ]
%36 = phi i64 [ 0, %31 ], [ %45, %34 ]
%37 = phi i64 [ %30, %31 ], [ %43, %34 ]
%38 = fsub double %35, %6
%39 = fdiv double %38, %7
%40 = tail call double @InterpolatedGradZ3DMirr(float* %1, i64 %2, i64 %3, i64 %4, double %39, double %33, double %26, i64 %14)
%41 = fdiv double %40, %13
%42 = fptrunc double %41 to float
%43 = add nsw i64 %37, 1
%44 = getelementptr inbounds float, float* %0, i64 %37
store float %42, float* %44
%45 = add nuw nsw i64 %36, 1
%46 = sitofp i64 %45 to double
%47 = fcmp olt double %46, %5
br i1 %47, label %34, label %48
48: ; preds = %34, %27
%49 = phi i64 [ %30, %27 ], [ %43, %34 ]
%50 = add nuw nsw i64 %29, 1
%51 = sitofp i64 %50 to double
%52 = fcmp olt double %51, %8
br i1 %52, label %27, label %53
53: ; preds = %48, %20
%54 = phi i64 [ %23, %20 ], [ %49, %48 ]
%55 = add nuw nsw i64 %22, 1
%56 = sitofp i64 %55 to double
%57 = fcmp olt double %56, %11
br i1 %57, label %20, label %58
58: ; preds = %53, %15
ret void
}