#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 const pow(double const, int);
double eval_spline3(double x, const double *xs, const double *h,
                    const double *A, const double *B, const double *M) {
  int i;
  double h_temp;
  i = 0;
  while (x > xs[i]) {
    i++;
  }
  i--;
  h_temp = 6 * h[i + 1];
  return (M[i] * pow(xs[i + 1] - x, 3) / h_temp +
          M[i + 1] * pow(x - xs[i], 3) / h_temp + A[i] * (x - xs[i]) + B[i]);
}


x86 assembly (clang, -O0):
<eval_spline3>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
movsd  -0x8(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
ucomisd (%rax,%rcx,8),%xmm0
jbe    115e <eval_spline3+0x4e>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1138 <eval_spline3+0x28>
mov    -0x34(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x34(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x34(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  0xe84(%rip),%xmm0
mulsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x30(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x34(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
subsd  -0x8(%rbp),%xmm0
mov    $0x3,%edi
call   1030 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x58(%rbp),%xmm0
mulsd  %xmm1,%xmm0
divsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    -0x30(%rbp),%rax
mov    -0x34(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x8(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
mov    $0x3,%edi
call   1030 <pow@plt>
movsd  -0x50(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x48(%rbp),%xmm0
mulsd  %xmm2,%xmm0
divsd  -0x40(%rbp),%xmm0
addsd  %xmm0,%xmm1
mov    -0x20(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  -0x8(%rbp),%xmm2
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x28(%rbp),%rax
movslq -0x34(%rbp),%rcx
addsd  (%rax,%rcx,8),%xmm0
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<eval_spline3>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %r8,%r12
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rdi,%r13
movapd %xmm0,%xmm1
movabs $0xfffffffe00000000,%rbx
ff ff ff
mov    $0xffffffffffffffff,%rax
movabs $0x100000000,%rcx
nopl   0x0(%rax)
add    %rcx,%rbx
movsd  0x8(%r13,%rax,8),%xmm0
add    $0x1,%rax
ucomisd %xmm0,%xmm1
ja     1150 <eval_spline3+0x40>
mov    %eax,%ebp
shl    $0x3,%rbp
movsd  (%rsi,%rbp,1),%xmm2
mulsd  0xe89(%rip),%xmm2
movapd %xmm2,0x30(%rsp)
sar    $0x1d,%rbx
subsd  %xmm1,%xmm0
movsd  (%r12,%rbx,1),%xmm2
movaps %xmm2,0x10(%rsp)
mov    $0x3,%edi
movsd  %xmm1,0x8(%rsp)
call   1030 <pow@plt>
movapd %xmm0,0x20(%rsp)
movsd  0x8(%rsp),%xmm0
subsd  0x0(%r13,%rbx,1),%xmm0
movaps 0x10(%rsp),%xmm1
movhps (%r12,%rbp,1),%xmm1
movaps %xmm1,0x10(%rsp)
mov    $0x3,%edi
call   1030 <pow@plt>
movapd 0x20(%rsp),%xmm2
unpcklpd %xmm0,%xmm2
mulpd  0x10(%rsp),%xmm2
movapd 0x30(%rsp),%xmm0
unpcklpd %xmm0,%xmm0
divpd  %xmm0,%xmm2
movapd %xmm2,%xmm1
unpckhpd %xmm2,%xmm1
movsd  0x8(%rsp),%xmm0
subsd  0x0(%r13,%rbx,1),%xmm0
mulsd  (%r15,%rbx,1),%xmm0
addsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
addsd  (%r14,%rbx,1),%xmm0
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define double @eval_spline3(double %0, double* %1, double* %2, double* %3, double* %4, double* %5) {
%7 = alloca double
%8 = alloca double*
%9 = alloca double*
%10 = alloca double*
%11 = alloca double*
%12 = alloca double*
%13 = alloca i32
%14 = alloca double
store double %0, double* %7
store double* %1, double** %8
store double* %2, double** %9
store double* %3, double** %10
store double* %4, double** %11
store double* %5, double** %12
store i32 0, i32* %13
br label %15
15: ; preds = %23, %6
%16 = load double, double* %7
%17 = load double*, double** %8
%18 = load i32, i32* %13
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds double, double* %17, i64 %19
%21 = load double, double* %20
%22 = fcmp ogt double %16, %21
br i1 %22, label %23, label %26
23: ; preds = %15
%24 = load i32, i32* %13
%25 = add nsw i32 %24, 1
store i32 %25, i32* %13
br label %15
26: ; preds = %15
%27 = load i32, i32* %13
%28 = add nsw i32 %27, -1
store i32 %28, i32* %13
%29 = load double*, double** %9
%30 = load i32, i32* %13
%31 = add nsw i32 %30, 1
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds double, double* %29, i64 %32
%34 = load double, double* %33
%35 = fmul double 6.000000e+00, %34
store double %35, double* %14
%36 = load double*, double** %12
%37 = load i32, i32* %13
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds double, double* %36, i64 %38
%40 = load double, double* %39
%41 = load double*, double** %8
%42 = load i32, i32* %13
%43 = add nsw i32 %42, 1
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds double, double* %41, i64 %44
%46 = load double, double* %45
%47 = load double, double* %7
%48 = fsub double %46, %47
%49 = call double @pow(double %48, i32 3)
%50 = fmul double %40, %49
%51 = load double, double* %14
%52 = fdiv double %50, %51
%53 = load double*, double** %12
%54 = load i32, i32* %13
%55 = add nsw i32 %54, 1
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds double, double* %53, i64 %56
%58 = load double, double* %57
%59 = load double, double* %7
%60 = load double*, double** %8
%61 = load i32, i32* %13
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds double, double* %60, i64 %62
%64 = load double, double* %63
%65 = fsub double %59, %64
%66 = call double @pow(double %65, i32 3)
%67 = fmul double %58, %66
%68 = load double, double* %14
%69 = fdiv double %67, %68
%70 = fadd double %52, %69
%71 = load double*, double** %10
%72 = load i32, i32* %13
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds double, double* %71, i64 %73
%75 = load double, double* %74
%76 = load double, double* %7
%77 = load double*, double** %8
%78 = load i32, i32* %13
%79 = sext i32 %78 to i64
%80 = getelementptr inbounds double, double* %77, i64 %79
%81 = load double, double* %80
%82 = fsub double %76, %81
%83 = call double @llvm.fmuladd.f64(double %75, double %82, double %70)
%84 = load double*, double** %11
%85 = load i32, i32* %13
%86 = sext i32 %85 to i64
%87 = getelementptr inbounds double, double* %84, i64 %86
%88 = load double, double* %87
%89 = fadd double %83, %88
ret double %89
}

LLVM IR (-O2):
define double @eval_spline3(double %0, double* nocapture %1, double* nocapture %2, double* nocapture %3, double* nocapture %4, double* nocapture %5) {
br label %7
7: ; preds = %7, %6
%8 = phi i64 [ %12, %7 ], [ 0, %6 ]
%9 = getelementptr inbounds double, double* %1, i64 %8
%10 = load double, double* %9
%11 = fcmp olt double %10, %0
%12 = add nuw i64 %8, 1
br i1 %11, label %7, label %13
13: ; preds = %7
%14 = and i64 %8, 4294967295
%15 = getelementptr inbounds double, double* %2, i64 %14
%16 = load double, double* %15
%17 = fmul double %16, 6.000000e+00
%18 = shl i64 %8, 32
%19 = add i64 %18, -4294967296
%20 = ashr exact i64 %19, 32
%21 = getelementptr inbounds double, double* %5, i64 %20
%22 = load double, double* %21
%23 = fsub double %10, %0
%24 = tail call double @pow(double %23, i32 3)
%25 = getelementptr inbounds double, double* %5, i64 %14
%26 = load double, double* %25
%27 = getelementptr inbounds double, double* %1, i64 %20
%28 = load double, double* %27
%29 = fsub double %0, %28
%30 = tail call double @pow(double %29, i32 3)
%31 = insertelement <2 x double> poison, double %22, i64 0
%32 = insertelement <2 x double> %31, double %26, i64 1
%33 = insertelement <2 x double> poison, double %24, i64 0
%34 = insertelement <2 x double> %33, double %30, i64 1
%35 = fmul <2 x double> %32, %34
%36 = insertelement <2 x double> poison, double %17, i64 0
%37 = shufflevector <2 x double> %36, <2 x double> poison, <2 x i32> zeroinitializer
%38 = fdiv <2 x double> %35, %37
%39 = shufflevector <2 x double> %38, <2 x double> poison, <2 x i32> <i32 1, i32 undef>
%40 = fadd <2 x double> %38, %39
%41 = extractelement <2 x double> %40, i64 0
%42 = getelementptr inbounds double, double* %3, i64 %20
%43 = load double, double* %42
%44 = load double, double* %27
%45 = fsub double %0, %44
%46 = tail call double @llvm.fmuladd.f64(double %43, double %45, double %41)
%47 = getelementptr inbounds double, double* %4, i64 %20
%48 = load double, double* %47
%49 = fadd double %48, %46
ret double %49
}