#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 */
int /*<<< orphan*/ exit(int);
double fabs(double);
int /*<<< orphan*/ printf(char *, ...);
void splint(double xa[], double ya[], double y2a[], int n, double x,
            double *y) {
  int klo, khi, k;
  double h, b, a;
  klo = 0;
  khi = n - 1;
  while ((khi - klo) > 1) {
    k = (khi + klo) >> 1;
    if (xa[k] > x)
      khi = k;
    else
      klo = k;
  }
  h = xa[khi] - xa[klo];
  if (fabs(h) < 1.0E-10) {
    printf("\n\n Error in function splint(): ");
    printf("\n The difference h = %4.1E -- too small\n", h);
    exit(1);
  }
  a = (xa[khi] - x) / h;
  b = (x - xa[klo]) / h;
  *y =
      a * ya[klo] + b * ya[khi] +
      ((a * a * a - a) * y2a[klo] + (b * b * b - b) * y2a[khi]) * (h * h) / 6.0;
}


x86 assembly (clang, -O0):
<splint>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
movsd  %xmm0,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x1c(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x38(%rbp)
mov    -0x38(%rbp),%eax
sub    -0x34(%rbp),%eax
cmp    $0x1,%eax
jle    1199 <splint+0x79>
mov    -0x38(%rbp),%eax
add    -0x34(%rbp),%eax
sar    $0x1,%eax
mov    %eax,-0x3c(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
ucomisd -0x28(%rbp),%xmm0
jbe    118e <splint+0x6e>
mov    -0x3c(%rbp),%eax
mov    %eax,-0x38(%rbp)
jmp    1194 <splint+0x74>
mov    -0x3c(%rbp),%eax
mov    %eax,-0x34(%rbp)
jmp    1150 <splint+0x30>
mov    -0x8(%rbp),%rax
movslq -0x38(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x34(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm1
movaps 0xe4c(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  0xe30(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1205 <splint+0xe5>
lea    0xe3f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movsd  -0x48(%rbp),%xmm0
lea    0xe4c(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   1040 <exit@plt>
mov    -0x8(%rbp),%rax
movslq -0x38(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
subsd  -0x28(%rbp),%xmm0
divsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x28(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x34(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
divsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x58(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
movsd  -0x50(%rbp),%xmm1
mov    -0x10(%rbp),%rax
movslq -0x38(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  -0x58(%rbp),%xmm1
mulsd  -0x58(%rbp),%xmm1
movsd  -0x58(%rbp),%xmm3
movsd  -0x58(%rbp),%xmm2
movq   %xmm2,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm2
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
mov    -0x18(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm3
movsd  -0x50(%rbp),%xmm2
mulsd  -0x50(%rbp),%xmm2
movsd  -0x50(%rbp),%xmm5
movsd  -0x50(%rbp),%xmm4
movq   %xmm4,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm4
mulsd  %xmm5,%xmm2
addsd  %xmm4,%xmm2
mov    -0x18(%rbp),%rax
movslq -0x38(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm2
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
movsd  -0x48(%rbp),%xmm2
mulsd  -0x48(%rbp),%xmm2
mulsd  %xmm2,%xmm1
movsd  0xd01(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<splint>:
sub    $0x18,%rsp
lea    -0x1(%rcx),%r10d
xor    %r9d,%r9d
cmp    $0x3,%ecx
jge    114e <splint+0x2e>
jmp    116a <splint+0x4a>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %ecx,%r9d
mov    %r10d,%eax
sub    %r9d,%eax
cmp    $0x1,%eax
jle    1167 <splint+0x47>
lea    (%r9,%r10,1),%ecx
sar    %ecx
movslq %ecx,%rax
movsd  (%rdi,%rax,8),%xmm1
ucomisd %xmm0,%xmm1
jbe    1140 <splint+0x20>
mov    %ecx,%r10d
jmp    1143 <splint+0x23>
movslq %r9d,%r9
movslq %r10d,%rax
movsd  (%rdi,%rax,8),%xmm1
movsd  (%rdi,%r9,8),%xmm2
movapd %xmm1,%xmm5
subsd  %xmm2,%xmm5
movapd 0xe78(%rip),%xmm3
andpd  %xmm5,%xmm3
movsd  0xe7c(%rip),%xmm4
ucomisd %xmm3,%xmm4
ja     120e <splint+0xee>
subsd  %xmm0,%xmm1
divsd  %xmm5,%xmm1
subsd  %xmm2,%xmm0
divsd  %xmm5,%xmm0
movsd  (%rsi,%rax,8),%xmm2
mulsd  %xmm0,%xmm2
movsd  (%rsi,%r9,8),%xmm3
mulsd  %xmm1,%xmm3
movapd %xmm1,%xmm4
mulsd  %xmm1,%xmm4
mulsd  %xmm1,%xmm4
subsd  %xmm1,%xmm4
movapd %xmm0,%xmm1
mulsd  %xmm0,%xmm1
mulsd  %xmm0,%xmm1
subsd  %xmm0,%xmm1
mulsd  (%rdx,%rax,8),%xmm1
mulsd  (%rdx,%r9,8),%xmm4
addsd  %xmm2,%xmm3
addsd  %xmm1,%xmm4
mulsd  %xmm5,%xmm5
mulsd  %xmm4,%xmm5
divsd  0xe18(%rip),%xmm5
addsd  %xmm3,%xmm5
movsd  %xmm5,(%r8)
add    $0x18,%rsp
ret
lea    0xe0b(%rip),%rdi
xor    %eax,%eax
movapd %xmm5,(%rsp)
call   1030 <printf@plt>
lea    0xe18(%rip),%rdi
movaps (%rsp),%xmm0
mov    $0x1,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@.str = [32 x i8] c"\0A\0A Error in function splint(): \00"
@.str.1 = [41 x i8] c"\0A The difference h = %4.1E -- too small\0A\00"
define void @splint(double* %0, double* %1, double* %2, i32 %3, double %4, double* %5) {
%7 = alloca double*
%8 = alloca double*
%9 = alloca double*
%10 = alloca i32
%11 = alloca double
%12 = alloca double*
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca double
%17 = alloca double
%18 = alloca double
store double* %0, double** %7
store double* %1, double** %8
store double* %2, double** %9
store i32 %3, i32* %10
store double %4, double* %11
store double* %5, double** %12
store i32 0, i32* %13
%19 = load i32, i32* %10
%20 = sub nsw i32 %19, 1
store i32 %20, i32* %14
br label %21
21: ; preds = %42, %6
%22 = load i32, i32* %14
%23 = load i32, i32* %13
%24 = sub nsw i32 %22, %23
%25 = icmp sgt i32 %24, 1
br i1 %25, label %26, label %43
26: ; preds = %21
%27 = load i32, i32* %14
%28 = load i32, i32* %13
%29 = add nsw i32 %27, %28
%30 = ashr i32 %29, 1
store i32 %30, i32* %15
%31 = load double*, double** %7
%32 = load i32, i32* %15
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds double, double* %31, i64 %33
%35 = load double, double* %34
%36 = load double, double* %11
%37 = fcmp ogt double %35, %36
br i1 %37, label %38, label %40
38: ; preds = %26
%39 = load i32, i32* %15
store i32 %39, i32* %14
br label %42
40: ; preds = %26
%41 = load i32, i32* %15
store i32 %41, i32* %13
br label %42
42: ; preds = %40, %38
br label %21
43: ; preds = %21
%44 = load double*, double** %7
%45 = load i32, i32* %14
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds double, double* %44, i64 %46
%48 = load double, double* %47
%49 = load double*, double** %7
%50 = load i32, i32* %13
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds double, double* %49, i64 %51
%53 = load double, double* %52
%54 = fsub double %48, %53
store double %54, double* %16
%55 = load double, double* %16
%56 = call double @llvm.fabs.f64(double %55)
%57 = fcmp olt double %56, 1.000000e-10
br i1 %57, label %58, label %63
58: ; preds = %43
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%60 = load double, double* %16
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0), double %60)
%62 = call i32 @exit(i32 1)
unreachable
63: ; preds = %43
%64 = load double*, double** %7
%65 = load i32, i32* %14
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds double, double* %64, i64 %66
%68 = load double, double* %67
%69 = load double, double* %11
%70 = fsub double %68, %69
%71 = load double, double* %16
%72 = fdiv double %70, %71
store double %72, double* %18
%73 = load double, double* %11
%74 = load double*, double** %7
%75 = load i32, i32* %13
%76 = sext i32 %75 to i64
%77 = getelementptr inbounds double, double* %74, i64 %76
%78 = load double, double* %77
%79 = fsub double %73, %78
%80 = load double, double* %16
%81 = fdiv double %79, %80
store double %81, double* %17
%82 = load double, double* %18
%83 = load double*, double** %8
%84 = load i32, i32* %13
%85 = sext i32 %84 to i64
%86 = getelementptr inbounds double, double* %83, i64 %85
%87 = load double, double* %86
%88 = load double, double* %17
%89 = load double*, double** %8
%90 = load i32, i32* %14
%91 = sext i32 %90 to i64
%92 = getelementptr inbounds double, double* %89, i64 %91
%93 = load double, double* %92
%94 = fmul double %88, %93
%95 = call double @llvm.fmuladd.f64(double %82, double %87, double %94)
%96 = load double, double* %18
%97 = load double, double* %18
%98 = fmul double %96, %97
%99 = load double, double* %18
%100 = load double, double* %18
%101 = fneg double %100
%102 = call double @llvm.fmuladd.f64(double %98, double %99, double %101)
%103 = load double*, double** %9
%104 = load i32, i32* %13
%105 = sext i32 %104 to i64
%106 = getelementptr inbounds double, double* %103, i64 %105
%107 = load double, double* %106
%108 = load double, double* %17
%109 = load double, double* %17
%110 = fmul double %108, %109
%111 = load double, double* %17
%112 = load double, double* %17
%113 = fneg double %112
%114 = call double @llvm.fmuladd.f64(double %110, double %111, double %113)
%115 = load double*, double** %9
%116 = load i32, i32* %14
%117 = sext i32 %116 to i64
%118 = getelementptr inbounds double, double* %115, i64 %117
%119 = load double, double* %118
%120 = fmul double %114, %119
%121 = call double @llvm.fmuladd.f64(double %102, double %107, double %120)
%122 = load double, double* %16
%123 = load double, double* %16
%124 = fmul double %122, %123
%125 = fmul double %121, %124
%126 = fdiv double %125, 6.000000e+00
%127 = fadd double %95, %126
%128 = load double*, double** %12
store double %127, double* %128
ret void
}

LLVM IR (-O2):
@.str = [32 x i8] c"\0A\0A Error in function splint(): \00"
@.str.1 = [41 x i8] c"\0A The difference h = %4.1E -- too small\0A\00"
define void @splint(double* nocapture %0, double* nocapture %1, double* nocapture %2, i32 %3, double %4, double* nocapture writeonly %5) {
%7 = add nsw i32 %3, -1
%8 = icmp sgt i32 %3, 2
br i1 %8, label %9, label %24
9: ; preds = %6, %9
%10 = phi i32 [ %19, %9 ], [ 0, %6 ]
%11 = phi i32 [ %18, %9 ], [ %7, %6 ]
%12 = add nsw i32 %10, %11
%13 = ashr i32 %12, 1
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds double, double* %0, i64 %14
%16 = load double, double* %15
%17 = fcmp ogt double %16, %4
%18 = select i1 %17, i32 %13, i32 %11
%19 = select i1 %17, i32 %10, i32 %13
%20 = sub nsw i32 %18, %19
%21 = icmp sgt i32 %20, 1
br i1 %21, label %9, label %22
22: ; preds = %9
%23 = sext i32 %19 to i64
br label %24
24: ; preds = %22, %6
%25 = phi i32 [ %7, %6 ], [ %18, %22 ]
%26 = phi i64 [ 0, %6 ], [ %23, %22 ]
%27 = sext i32 %25 to i64
%28 = getelementptr inbounds double, double* %0, i64 %27
%29 = load double, double* %28
%30 = getelementptr inbounds double, double* %0, i64 %26
%31 = load double, double* %30
%32 = fsub double %29, %31
%33 = tail call double @llvm.fabs.f64(double %32)
%34 = fcmp olt double %33, 1.000000e-10
br i1 %34, label %35, label %39
35: ; preds = %24
%36 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%37 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0), double %32)
%38 = tail call i32 @exit(i32 1)
unreachable
39: ; preds = %24
%40 = fsub double %29, %4
%41 = fdiv double %40, %32
%42 = fsub double %4, %31
%43 = fdiv double %42, %32
%44 = getelementptr inbounds double, double* %1, i64 %26
%45 = load double, double* %44
%46 = getelementptr inbounds double, double* %1, i64 %27
%47 = load double, double* %46
%48 = fmul double %43, %47
%49 = tail call double @llvm.fmuladd.f64(double %41, double %45, double %48)
%50 = fmul double %41, %41
%51 = fneg double %41
%52 = tail call double @llvm.fmuladd.f64(double %50, double %41, double %51)
%53 = getelementptr inbounds double, double* %2, i64 %26
%54 = load double, double* %53
%55 = fmul double %43, %43
%56 = fneg double %43
%57 = tail call double @llvm.fmuladd.f64(double %55, double %43, double %56)
%58 = getelementptr inbounds double, double* %2, i64 %27
%59 = load double, double* %58
%60 = fmul double %57, %59
%61 = tail call double @llvm.fmuladd.f64(double %52, double %54, double %60)
%62 = fmul double %32, %32
%63 = fmul double %62, %61
%64 = fdiv double %63, 6.000000e+00
%65 = fadd double %49, %64
store double %65, double* %5
ret void
}