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


x86 assembly (clang, -O0):
<BatchInterpolatedGradZ3DZeroWarp>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    0x28(%rbp),%rax
mov    0x20(%rbp),%rax
movsd  0x18(%rbp),%xmm8
mov    0x10(%rbp),%rax
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)
mov    %r9,-0x48(%rbp)
movsd  %xmm3,-0x50(%rbp)
movsd  %xmm4,-0x58(%rbp)
movsd  %xmm5,-0x60(%rbp)
movsd  %xmm6,-0x68(%rbp)
movsd  %xmm7,-0x70(%rbp)
movq   $0x0,-0x90(%rbp)
movq   $0x0,-0xa8(%rbp)
cvtsi2sdq -0xa8(%rbp),%xmm1
ff ff
movsd  -0x68(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1309 <BatchInterpolatedGradZ3DZeroWarp+0x1f9>
movq   $0x0,-0xa0(%rbp)
cvtsi2sdq -0xa0(%rbp),%xmm1
ff ff
movsd  -0x50(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    12ed <BatchInterpolatedGradZ3DZeroWarp+0x1dd>
movq   $0x0,-0x98(%rbp)
cvtsi2sdq -0x98(%rbp),%xmm1
ff ff
movsd  -0x30(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    12d1 <BatchInterpolatedGradZ3DZeroWarp+0x1c1>
cvtsi2ssq -0x98(%rbp),%xmm0
ff ff
mov    -0x48(%rbp),%rax
mov    -0x90(%rbp),%rcx
addss  (%rax,%rcx,4),%xmm0
cvtss2sd %xmm0,%xmm0
subsd  -0x38(%rbp),%xmm0
divsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
cvtsi2ssq -0xa0(%rbp),%xmm0
ff ff
mov    0x10(%rbp),%rax
mov    -0x90(%rbp),%rcx
addss  (%rax,%rcx,4),%xmm0
cvtss2sd %xmm0,%xmm0
subsd  -0x58(%rbp),%xmm0
divsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x80(%rbp)
cvtsi2ssq -0xa8(%rbp),%xmm0
ff ff
mov    0x20(%rbp),%rax
mov    -0x90(%rbp),%rcx
addss  (%rax,%rcx,4),%xmm0
cvtss2sd %xmm0,%xmm0
subsd  -0x70(%rbp),%xmm0
divsd  0x18(%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    0x28(%rbp),%r8
call   1030 <InterpolatedGradZ3DZero@plt>
divsd  0x18(%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    11c9 <BatchInterpolatedGradZ3DZeroWarp+0xb9>
jmp    12d6 <BatchInterpolatedGradZ3DZeroWarp+0x1c6>
mov    -0xa0(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0xa0(%rbp)
jmp    11a6 <BatchInterpolatedGradZ3DZeroWarp+0x96>
jmp    12f2 <BatchInterpolatedGradZ3DZeroWarp+0x1e2>
mov    -0xa8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0xa8(%rbp)
jmp    1183 <BatchInterpolatedGradZ3DZeroWarp+0x73>
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<BatchInterpolatedGradZ3DZeroWarp>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x98,%rsp
mov    %r9,0x30(%rsp)
mov    %rdi,0x28(%rsp)
xorpd  %xmm10,%xmm10
movsd  %xmm6,0x18(%rsp)
ucomisd %xmm10,%xmm6
jbe    1369 <BatchInterpolatedGradZ3DZeroWarp+0x259>
movapd %xmm1,%xmm8
movapd %xmm0,%xmm9
mov    %r8,%rbx
mov    %rcx,%r14
mov    %rsi,%r15
mov    0xe8(%rsp),%r13
movsd  0xd8(%rsp),%xmm6
xor    %eax,%eax
mov    %rax,0x8(%rsp)
xor    %ebp,%ebp
movsd  %xmm7,0x70(%rsp)
movsd  %xmm5,0x68(%rsp)
movsd  %xmm4,0x60(%rsp)
movsd  %xmm3,0x20(%rsp)
movsd  %xmm2,0x58(%rsp)
movsd  %xmm1,0x50(%rsp)
movsd  %xmm0,0x48(%rsp)
jmp    11c9 <BatchInterpolatedGradZ3DZeroWarp+0xb9>
nopw   0x0(%rax,%rax,1)
mov    0x8(%rsp),%rdi
add    $0x1,%rdi
mov    %rdi,%rax
mov    %rdi,0x8(%rsp)
xorps  %xmm0,%xmm0
cvtsi2sd %rdi,%xmm0
movsd  0x18(%rsp),%xmm1
ucomisd %xmm0,%xmm1
jbe    1369 <BatchInterpolatedGradZ3DZeroWarp+0x259>
ucomisd %xmm10,%xmm3
jbe    11a0 <BatchInterpolatedGradZ3DZeroWarp+0x90>
xorps  %xmm11,%xmm11
cvtsi2ssq 0x8(%rsp),%xmm11
xor    %eax,%eax
movss  %xmm11,0x10(%rsp)
jmp    1202 <BatchInterpolatedGradZ3DZeroWarp+0xf2>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%rax
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
ucomisd %xmm0,%xmm3
jbe    11a0 <BatchInterpolatedGradZ3DZeroWarp+0x90>
ucomisd %xmm10,%xmm9
jbe    11f0 <BatchInterpolatedGradZ3DZeroWarp+0xe0>
mov    %rax,0x38(%rsp)
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
movss  %xmm0,0x14(%rsp)
mov    0x30(%rsp),%rax
lea    (%rax,%rbp,4),%rax
mov    %rax,0x90(%rsp)
mov    0xd0(%rsp),%rax
lea    (%rax,%rbp,4),%rax
mov    %rax,0x88(%rsp)
mov    0xe0(%rsp),%rax
lea    (%rax,%rbp,4),%rax
mov    %rax,0x80(%rsp)
mov    0x28(%rsp),%rax
mov    %rbp,0x40(%rsp)
lea    (%rax,%rbp,4),%rax
mov    %rax,0x78(%rsp)
xor    %r12d,%r12d
nopl   0x0(%rax,%rax,1)
xorps  %xmm0,%xmm0
cvtsi2ss %r12,%xmm0
mov    0x90(%rsp),%rax
addss  (%rax,%r12,4),%xmm0
cvtss2sd %xmm0,%xmm0
subsd  %xmm8,%xmm0
divsd  %xmm2,%xmm0
mov    0x88(%rsp),%rax
movss  (%rax,%r12,4),%xmm1
addss  0x14(%rsp),%xmm1
cvtss2sd %xmm1,%xmm1
subsd  %xmm4,%xmm1
divsd  %xmm5,%xmm1
mov    0x80(%rsp),%rax
movss  (%rax,%r12,4),%xmm2
addss  %xmm11,%xmm2
cvtss2sd %xmm2,%xmm2
subsd  %xmm7,%xmm2
divsd  %xmm6,%xmm2
mov    %r15,%rdi
mov    %rdx,%rsi
mov    %rdx,%rbp
mov    %r14,%rdx
mov    %rbx,%rcx
mov    %r13,%r8
call   1030 <InterpolatedGradZ3DZero@plt>
movss  0x10(%rsp),%xmm11
movsd  0xd8(%rsp),%xmm6
mov    %rbp,%rdx
movsd  0x48(%rsp),%xmm9
movsd  0x50(%rsp),%xmm8
movsd  0x58(%rsp),%xmm2
movsd  0x60(%rsp),%xmm4
movsd  0x68(%rsp),%xmm5
movsd  0x70(%rsp),%xmm7
divsd  %xmm6,%xmm0
cvtsd2ss %xmm0,%xmm0
mov    0x78(%rsp),%rax
movss  %xmm0,(%rax,%r12,4)
add    $0x1,%r12
xorps  %xmm0,%xmm0
cvtsi2sd %r12,%xmm0
ucomisd %xmm0,%xmm9
ja     1270 <BatchInterpolatedGradZ3DZeroWarp+0x160>
mov    0x40(%rsp),%rbp
add    %r12,%rbp
movsd  0x20(%rsp),%xmm3
xorpd  %xmm10,%xmm10
mov    0x38(%rsp),%rax
jmp    11f0 <BatchInterpolatedGradZ3DZeroWarp+0xe0>
add    $0x98,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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