#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 */
size_t ijk2n(int, int, int);
double pow(double, int);
double tricubic_eval(double a[64], double x, double y, double z) {
  int i, j, k;
  double ret = (double)(0.0);
  for (i = 0; i < 4; i++) {
    for (j = 0; j < 4; j++) {
      for (k = 0; k < 4; k++) {
        ret += a[ijk2n(i, j, k)] * pow(x, i) * pow(y, j) * pow(z, k);
      }
    }
  }
  return (ret);
}


x86 assembly (clang, -O0):
<tricubic_eval>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
movl   $0x0,-0x24(%rbp)
cmpl   $0x4,-0x24(%rbp)
jge    1234 <tricubic_eval+0x114>
movl   $0x0,-0x28(%rbp)
cmpl   $0x4,-0x28(%rbp)
jge    1221 <tricubic_eval+0x101>
movl   $0x0,-0x2c(%rbp)
cmpl   $0x4,-0x2c(%rbp)
jge    120e <tricubic_eval+0xee>
mov    -0x8(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x24(%rbp),%edi
mov    -0x28(%rbp),%esi
mov    -0x2c(%rbp),%edx
call   1030 <ijk2n@plt>
mov    %rax,%rcx
mov    -0x58(%rbp),%rax
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x10(%rbp),%xmm0
mov    -0x24(%rbp),%edi
call   1040 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x50(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x18(%rbp),%xmm0
mov    -0x28(%rbp),%edi
call   1040 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x48(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x20(%rbp),%xmm0
mov    -0x2c(%rbp),%edi
call   1040 <pow@plt>
movaps %xmm0,%xmm2
movsd  -0x40(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    116c <tricubic_eval+0x4c>
jmp    1213 <tricubic_eval+0xf3>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    115b <tricubic_eval+0x3b>
jmp    1226 <tricubic_eval+0x106>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    114a <tricubic_eval+0x2a>
movsd  -0x38(%rbp),%xmm0
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tricubic_eval>:
push   %rbp
push   %r14
push   %rbx
sub    $0x30,%rsp
movsd  %xmm2,0x28(%rsp)
movsd  %xmm1,0x20(%rsp)
movsd  %xmm0,0x18(%rsp)
mov    %rdi,%r14
xor    %ebp,%ebp
xorpd  %xmm0,%xmm0
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsd  %xmm0,0x10(%rsp)
mov    %ebp,%edi
mov    %ebx,%esi
xor    %edx,%edx
call   1030 <ijk2n@plt>
movsd  (%r14,%rax,8),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x18(%rsp),%xmm0
mov    %ebp,%edi
call   1040 <pow@plt>
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x20(%rsp),%xmm0
mov    %ebx,%edi
call   1040 <pow@plt>
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x28(%rsp),%xmm0
xor    %edi,%edi
call   1040 <pow@plt>
mulsd  0x8(%rsp),%xmm0
addsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
mov    %ebp,%edi
mov    %ebx,%esi
mov    $0x1,%edx
call   1030 <ijk2n@plt>
movsd  (%r14,%rax,8),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x18(%rsp),%xmm0
mov    %ebp,%edi
call   1040 <pow@plt>
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x20(%rsp),%xmm0
mov    %ebx,%edi
call   1040 <pow@plt>
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x28(%rsp),%xmm0
mov    $0x1,%edi
call   1040 <pow@plt>
mulsd  0x8(%rsp),%xmm0
addsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
mov    %ebp,%edi
mov    %ebx,%esi
mov    $0x2,%edx
call   1030 <ijk2n@plt>
movsd  (%r14,%rax,8),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x18(%rsp),%xmm0
mov    %ebp,%edi
call   1040 <pow@plt>
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x20(%rsp),%xmm0
mov    %ebx,%edi
call   1040 <pow@plt>
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x28(%rsp),%xmm0
mov    $0x2,%edi
call   1040 <pow@plt>
mulsd  0x8(%rsp),%xmm0
addsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
mov    %ebp,%edi
mov    %ebx,%esi
mov    $0x3,%edx
call   1030 <ijk2n@plt>
movsd  (%r14,%rax,8),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x18(%rsp),%xmm0
mov    %ebp,%edi
call   1040 <pow@plt>
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x20(%rsp),%xmm0
mov    %ebx,%edi
call   1040 <pow@plt>
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x28(%rsp),%xmm0
mov    $0x3,%edi
call   1040 <pow@plt>
mulsd  0x8(%rsp),%xmm0
addsd  0x10(%rsp),%xmm0
add    $0x1,%ebx
cmp    $0x4,%ebx
jne    1160 <tricubic_eval+0x40>
add    $0x1,%ebp
cmp    $0x4,%ebp
jne    1150 <tricubic_eval+0x30>
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define double @tricubic_eval(double* %0, double %1, double %2, double %3) {
%5 = alloca double*
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca double
store double* %0, double** %5
store double %1, double* %6
store double %2, double* %7
store double %3, double* %8
store double 0.000000e+00, double* %12
store i32 0, i32* %9
br label %13
13: ; preds = %53, %4
%14 = load i32, i32* %9
%15 = icmp slt i32 %14, 4
br i1 %15, label %16, label %56
16: ; preds = %13
store i32 0, i32* %10
br label %17
17: ; preds = %49, %16
%18 = load i32, i32* %10
%19 = icmp slt i32 %18, 4
br i1 %19, label %20, label %52
20: ; preds = %17
store i32 0, i32* %11
br label %21
21: ; preds = %45, %20
%22 = load i32, i32* %11
%23 = icmp slt i32 %22, 4
br i1 %23, label %24, label %48
24: ; preds = %21
%25 = load double*, double** %5
%26 = load i32, i32* %9
%27 = load i32, i32* %10
%28 = load i32, i32* %11
%29 = call i64 @ijk2n(i32 %26, i32 %27, i32 %28)
%30 = getelementptr inbounds double, double* %25, i64 %29
%31 = load double, double* %30
%32 = load double, double* %6
%33 = load i32, i32* %9
%34 = call double @pow(double %32, i32 %33)
%35 = fmul double %31, %34
%36 = load double, double* %7
%37 = load i32, i32* %10
%38 = call double @pow(double %36, i32 %37)
%39 = fmul double %35, %38
%40 = load double, double* %8
%41 = load i32, i32* %11
%42 = call double @pow(double %40, i32 %41)
%43 = load double, double* %12
%44 = call double @llvm.fmuladd.f64(double %39, double %42, double %43)
store double %44, double* %12
br label %45
45: ; preds = %24
%46 = load i32, i32* %11
%47 = add nsw i32 %46, 1
store i32 %47, i32* %11
br label %21
48: ; preds = %21
br label %49
49: ; preds = %48
%50 = load i32, i32* %10
%51 = add nsw i32 %50, 1
store i32 %51, i32* %10
br label %17
52: ; preds = %17
br label %53
53: ; preds = %52
%54 = load i32, i32* %9
%55 = add nsw i32 %54, 1
store i32 %55, i32* %9
br label %13
56: ; preds = %13
%57 = load double, double* %12
ret double %57
}

LLVM IR (-O2):
define double @tricubic_eval(double* nocapture %0, double %1, double %2, double %3) {
br label %5
5: ; preds = %4, %49
%6 = phi double [ 0.000000e+00, %4 ], [ %46, %49 ]
%7 = phi i32 [ 0, %4 ], [ %50, %49 ]
br label %8
8: ; preds = %5, %8
%9 = phi double [ %6, %5 ], [ %46, %8 ]
%10 = phi i32 [ 0, %5 ], [ %47, %8 ]
%11 = tail call i64 @ijk2n(i32 %7, i32 %10, i32 0)
%12 = getelementptr inbounds double, double* %0, i64 %11
%13 = load double, double* %12
%14 = tail call double @pow(double %1, i32 %7)
%15 = fmul double %13, %14
%16 = tail call double @pow(double %2, i32 %10)
%17 = fmul double %15, %16
%18 = tail call double @pow(double %3, i32 0)
%19 = tail call double @llvm.fmuladd.f64(double %17, double %18, double %9)
%20 = tail call i64 @ijk2n(i32 %7, i32 %10, i32 1)
%21 = getelementptr inbounds double, double* %0, i64 %20
%22 = load double, double* %21
%23 = tail call double @pow(double %1, i32 %7)
%24 = fmul double %22, %23
%25 = tail call double @pow(double %2, i32 %10)
%26 = fmul double %24, %25
%27 = tail call double @pow(double %3, i32 1)
%28 = tail call double @llvm.fmuladd.f64(double %26, double %27, double %19)
%29 = tail call i64 @ijk2n(i32 %7, i32 %10, i32 2)
%30 = getelementptr inbounds double, double* %0, i64 %29
%31 = load double, double* %30
%32 = tail call double @pow(double %1, i32 %7)
%33 = fmul double %31, %32
%34 = tail call double @pow(double %2, i32 %10)
%35 = fmul double %33, %34
%36 = tail call double @pow(double %3, i32 2)
%37 = tail call double @llvm.fmuladd.f64(double %35, double %36, double %28)
%38 = tail call i64 @ijk2n(i32 %7, i32 %10, i32 3)
%39 = getelementptr inbounds double, double* %0, i64 %38
%40 = load double, double* %39
%41 = tail call double @pow(double %1, i32 %7)
%42 = fmul double %40, %41
%43 = tail call double @pow(double %2, i32 %10)
%44 = fmul double %42, %43
%45 = tail call double @pow(double %3, i32 3)
%46 = tail call double @llvm.fmuladd.f64(double %44, double %45, double %37)
%47 = add nuw nsw i32 %10, 1
%48 = icmp eq i32 %47, 4
br i1 %48, label %49, label %8
49: ; preds = %8
%50 = add nuw nsw i32 %7, 1
%51 = icmp eq i32 %50, 4
br i1 %51, label %52, label %5
52: ; preds = %49
ret double %46
}