#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*/ assert(int);
int find_xb(double, double const *, int, int);
double lagrange_interp_1D(double, double *, int, double *);
double lagrange_interp_1Dfo(double x, int order, const double x_values[],
                            int num_x, const double y_values[]) {
  assert(order % 2 == 0);
  assert(num_x > order);
  double mx[order + 1];
  double my[order + 1];
  int i;
  int ix = find_xb(x, x_values, num_x, order / 2);
  for (i = 0; i < order + 1; i++) {
    mx[i] = x_values[ix + i - order / 2];
    my[i] = y_values[ix + i - order / 2];
  }
  return lagrange_interp_1D(x, mx, order + 1, my);
}


x86 assembly (clang, -O0):
<lagrange_interp_1Dfo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    %edi,-0xc(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %rcx,-0x28(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,%edx
shr    $0x1f,%edx
mov    %eax,%ecx
add    %edx,%ecx
and    $0xfffffffe,%ecx
sub    %ecx,%eax
sete   %al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x1c(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    %ecx,%eax
setg   %al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %rsp,%rcx
mov    %rcx,-0x30(%rbp)
lea    0xf(,%rax,8),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x58(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x38(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
lea    0xf(,%rax,8),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x50(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x40(%rbp)
movsd  -0x8(%rbp),%xmm0
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%edx
call   1040 <find_xb@plt>
mov    %eax,-0x48(%rbp)
movl   $0x0,-0x44(%rbp)
mov    -0x44(%rbp),%eax
mov    -0xc(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jge    1276 <lagrange_interp_1Dfo+0x146>
mov    -0x18(%rbp),%rcx
mov    -0x48(%rbp),%eax
add    -0x44(%rbp),%eax
mov    %eax,-0x60(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x2,%esi
cltd
idiv   %esi
mov    -0x60(%rbp),%edx
mov    %eax,%esi
mov    -0x58(%rbp),%rax
sub    %esi,%edx
movslq %edx,%rdx
movsd  (%rcx,%rdx,8),%xmm0
movslq -0x44(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x28(%rbp),%rcx
mov    -0x48(%rbp),%eax
add    -0x44(%rbp),%eax
mov    %eax,-0x5c(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x2,%esi
cltd
idiv   %esi
mov    -0x5c(%rbp),%edx
mov    %eax,%esi
mov    -0x50(%rbp),%rax
sub    %esi,%edx
movslq %edx,%rdx
movsd  (%rcx,%rdx,8),%xmm0
movslq -0x44(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    11ef <lagrange_interp_1Dfo+0xbf>
mov    -0x50(%rbp),%rdx
mov    -0x58(%rbp),%rdi
movsd  -0x8(%rbp),%xmm0
mov    -0xc(%rbp),%esi
add    $0x1,%esi
call   1030 <lagrange_interp_1D@plt>
mov    -0x30(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lagrange_interp_1Dfo>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rcx,%r14
mov    %edx,%r15d
mov    %edx,-0x2c(%rbp)
mov    %rsi,%r12
mov    %edi,%ebx
movsd  %xmm0,-0x38(%rbp)
not    %edi
and    $0x1,%edi
call   1050 <assert@plt>
xor    %edi,%edi
cmp    %ebx,%r15d
setg   %dil
call   1050 <assert@plt>
lea    0x1(%rbx),%eax
mov    %rax,-0x40(%rbp)
mov    %rsp,%r13
lea    0xf(,%rax,8),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r13
mov    %r13,%rsp
mov    %rsp,%r15
sub    %rax,%r15
mov    %r15,%rsp
mov    %ebx,%edx
shr    $0x1f,%edx
add    %ebx,%edx
sar    %edx
movsd  -0x38(%rbp),%xmm0
mov    %r12,%rdi
mov    -0x2c(%rbp),%esi
mov    %edx,-0x2c(%rbp)
call   1040 <find_xb@plt>
mov    -0x40(%rbp),%rsi
test   %ebx,%ebx
js     1364 <lagrange_interp_1Dfo+0x234>
mov    %eax,%r9d
sub    -0x2c(%rbp),%r9d
cmp    $0x4,%esi
jae    125e <lagrange_interp_1Dfo+0x12e>
xor    %ecx,%ecx
mov    %rcx,%rdx
not    %rdx
test   $0x1,%sil
je     11fa <lagrange_interp_1Dfo+0xca>
add    %ecx,%r9d
movslq %r9d,%rdi
movsd  (%r12,%rdi,8),%xmm0
movsd  %xmm0,0x0(%r13,%rcx,8)
movsd  (%r14,%rdi,8),%xmm0
movsd  %xmm0,(%r15,%rcx,8)
or     $0x1,%rcx
add    %rsi,%rdx
je     1364 <lagrange_interp_1Dfo+0x234>
sub    -0x2c(%rbp),%eax
cs nopw 0x0(%rax,%rax,1)
lea    (%rax,%rcx,1),%rdx
movslq %edx,%rdx
movsd  (%r12,%rdx,8),%xmm0
movsd  %xmm0,0x0(%r13,%rcx,8)
movsd  (%r14,%rdx,8),%xmm0
movsd  %xmm0,(%r15,%rcx,8)
add    $0x1,%edx
movslq %edx,%rdx
movsd  (%r12,%rdx,8),%xmm0
movsd  %xmm0,0x8(%r13,%rcx,8)
movsd  (%r14,%rdx,8),%xmm0
movsd  %xmm0,0x8(%r15,%rcx,8)
add    $0x2,%rcx
cmp    %rcx,%rsi
jne    1210 <lagrange_interp_1Dfo+0xe0>
jmp    1364 <lagrange_interp_1Dfo+0x234>
lea    -0x1(%rsi),%rdx
lea    (%r9,%rdx,1),%edi
xor    %ecx,%ecx
cmp    %r9d,%edi
jl     11cb <lagrange_interp_1Dfo+0x9b>
shr    $0x20,%rdx
jne    11cb <lagrange_interp_1Dfo+0x9b>
mov    %esi,%ecx
and    $0xfffffffc,%ecx
lea    -0x4(%rcx),%rdx
mov    %rdx,%r8
shr    $0x2,%r8
add    $0x1,%r8
test   %rdx,%rdx
je     1383 <lagrange_interp_1Dfo+0x253>
mov    %r8,%r10
and    $0xfffffffffffffffe,%r10
xor    %edi,%edi
mov    %r9d,%edx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movslq %edx,%rdx
movups (%r12,%rdx,8),%xmm0
movups 0x10(%r12,%rdx,8),%xmm1
movaps %xmm0,0x0(%r13,%rdi,8)
movaps %xmm1,0x10(%r13,%rdi,8)
movups (%r14,%rdx,8),%xmm0
movups 0x10(%r14,%rdx,8),%xmm1
movaps %xmm0,(%r15,%rdi,8)
movaps %xmm1,0x10(%r15,%rdi,8)
lea    0x4(%rdx),%ebx
movslq %ebx,%rbx
movups (%r12,%rbx,8),%xmm0
movups 0x10(%r12,%rbx,8),%xmm1
movaps %xmm0,0x20(%r13,%rdi,8)
movaps %xmm1,0x30(%r13,%rdi,8)
movups (%r14,%rbx,8),%xmm0
movups 0x10(%r14,%rbx,8),%xmm1
movaps %xmm0,0x20(%r15,%rdi,8)
movaps %xmm1,0x30(%r15,%rdi,8)
add    $0x8,%rdi
add    $0x8,%edx
add    $0xfffffffffffffffe,%r10
jne    12b0 <lagrange_interp_1Dfo+0x180>
test   $0x1,%r8b
je     135b <lagrange_interp_1Dfo+0x22b>
lea    (%r9,%rdi,1),%edx
movslq %edx,%rdx
movups (%r12,%rdx,8),%xmm0
movups 0x10(%r12,%rdx,8),%xmm1
movaps %xmm0,0x0(%r13,%rdi,8)
movaps %xmm1,0x10(%r13,%rdi,8)
movups (%r14,%rdx,8),%xmm0
movups 0x10(%r14,%rdx,8),%xmm1
movaps %xmm0,(%r15,%rdi,8)
movaps %xmm1,0x10(%r15,%rdi,8)
cmp    %rsi,%rcx
jne    11cb <lagrange_interp_1Dfo+0x9b>
movsd  -0x38(%rbp),%xmm0
mov    %r13,%rdi
mov    %r15,%rdx
call   1030 <lagrange_interp_1D@plt>
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %edi,%edi
test   $0x1,%r8b
jne    1327 <lagrange_interp_1Dfo+0x1f7>
jmp    135b <lagrange_interp_1Dfo+0x22b>

LLVM IR (-O0):
define double @lagrange_interp_1Dfo(double %0, i32 %1, double* %2, i32 %3, double* %4) {
%6 = alloca double
%7 = alloca i32
%8 = alloca double*
%9 = alloca i32
%10 = alloca double*
%11 = alloca i8*
%12 = alloca i64
%13 = alloca i64
%14 = alloca i32
%15 = alloca i32
store double %0, double* %6
store i32 %1, i32* %7
store double* %2, double** %8
store i32 %3, i32* %9
store double* %4, double** %10
%16 = load i32, i32* %7
%17 = srem i32 %16, 2
%18 = icmp eq i32 %17, 0
%19 = zext i1 %18 to i32
%20 = call i32 @assert(i32 %19)
%21 = load i32, i32* %9
%22 = load i32, i32* %7
%23 = icmp sgt i32 %21, %22
%24 = zext i1 %23 to i32
%25 = call i32 @assert(i32 %24)
%26 = load i32, i32* %7
%27 = add nsw i32 %26, 1
%28 = zext i32 %27 to i64
%29 = call i8* @llvm.stacksave()
store i8* %29, i8** %11
%30 = alloca double, i64 %28
store i64 %28, i64* %12
%31 = load i32, i32* %7
%32 = add nsw i32 %31, 1
%33 = zext i32 %32 to i64
%34 = alloca double, i64 %33
store i64 %33, i64* %13
%35 = load double, double* %6
%36 = load double*, double** %8
%37 = load i32, i32* %9
%38 = load i32, i32* %7
%39 = sdiv i32 %38, 2
%40 = call i32 @find_xb(double %35, double* %36, i32 %37, i32 %39)
store i32 %40, i32* %15
store i32 0, i32* %14
br label %41
41: ; preds = %73, %5
%42 = load i32, i32* %14
%43 = load i32, i32* %7
%44 = add nsw i32 %43, 1
%45 = icmp slt i32 %42, %44
br i1 %45, label %46, label %76
46: ; preds = %41
%47 = load double*, double** %8
%48 = load i32, i32* %15
%49 = load i32, i32* %14
%50 = add nsw i32 %48, %49
%51 = load i32, i32* %7
%52 = sdiv i32 %51, 2
%53 = sub nsw i32 %50, %52
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds double, double* %47, i64 %54
%56 = load double, double* %55
%57 = load i32, i32* %14
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds double, double* %30, i64 %58
store double %56, double* %59
%60 = load double*, double** %10
%61 = load i32, i32* %15
%62 = load i32, i32* %14
%63 = add nsw i32 %61, %62
%64 = load i32, i32* %7
%65 = sdiv i32 %64, 2
%66 = sub nsw i32 %63, %65
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds double, double* %60, i64 %67
%69 = load double, double* %68
%70 = load i32, i32* %14
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds double, double* %34, i64 %71
store double %69, double* %72
br label %73
73: ; preds = %46
%74 = load i32, i32* %14
%75 = add nsw i32 %74, 1
store i32 %75, i32* %14
br label %41
76: ; preds = %41
%77 = load double, double* %6
%78 = load i32, i32* %7
%79 = add nsw i32 %78, 1
%80 = call double @lagrange_interp_1D(double %77, double* %30, i32 %79, double* %34)
%81 = load i8*, i8** %11
ret double %80
}

LLVM IR (-O2):
define double @lagrange_interp_1Dfo(double %0, i32 %1, double* %2, i32 %3, double* nocapture %4) {
%6 = and i32 %1, 1
%7 = xor i32 %6, 1
%8 = tail call i32 @assert(i32 %7)
%9 = icmp sgt i32 %3, %1
%10 = zext i1 %9 to i32
%11 = tail call i32 @assert(i32 %10)
%12 = add i32 %1, 1
%13 = zext i32 %12 to i64
%14 = alloca double, i64 %13
%15 = alloca double, i64 %13
%16 = sdiv i32 %1, 2
%17 = tail call i32 @find_xb(double %0, double* %2, i32 %3, i32 %16)
%18 = icmp slt i32 %1, 0
br i1 %18, label %164, label %19
19: ; preds = %5
%20 = sub i32 %17, %16
%21 = icmp ult i32 %12, 4
br i1 %21, label %121, label %22
22: ; preds = %19
%23 = add nsw i64 %13, -1
%24 = sub i32 %17, %16
%25 = trunc i64 %23 to i32
%26 = add i32 %24, %25
%27 = icmp slt i32 %26, %24
%28 = icmp ugt i64 %23, 4294967295
%29 = or i1 %27, %28
br i1 %29, label %121, label %30
30: ; preds = %22
%31 = and i64 %13, 4294967292
%32 = add nsw i64 %31, -4
%33 = lshr exact i64 %32, 2
%34 = add nuw nsw i64 %33, 1
%35 = and i64 %34, 1
%36 = icmp eq i64 %32, 0
br i1 %36, label %92, label %37
37: ; preds = %30
%38 = and i64 %34, 9223372036854775806
br label %39
39: ; preds = %39, %37
%40 = phi i64 [ 0, %37 ], [ %89, %39 ]
%41 = phi i64 [ 0, %37 ], [ %90, %39 ]
%42 = trunc i64 %40 to i32
%43 = add i32 %20, %42
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds double, double* %2, i64 %44
%46 = bitcast double* %45 to <2 x double>*
%47 = load <2 x double>, <2 x double>* %46
%48 = getelementptr inbounds double, double* %45, i64 2
%49 = bitcast double* %48 to <2 x double>*
%50 = load <2 x double>, <2 x double>* %49
%51 = getelementptr inbounds double, double* %14, i64 %40
%52 = bitcast double* %51 to <2 x double>*
store <2 x double> %47, <2 x double>* %52
%53 = getelementptr inbounds double, double* %51, i64 2
%54 = bitcast double* %53 to <2 x double>*
store <2 x double> %50, <2 x double>* %54
%55 = getelementptr inbounds double, double* %4, i64 %44
%56 = bitcast double* %55 to <2 x double>*
%57 = load <2 x double>, <2 x double>* %56
%58 = getelementptr inbounds double, double* %55, i64 2
%59 = bitcast double* %58 to <2 x double>*
%60 = load <2 x double>, <2 x double>* %59
%61 = getelementptr inbounds double, double* %15, i64 %40
%62 = bitcast double* %61 to <2 x double>*
store <2 x double> %57, <2 x double>* %62
%63 = getelementptr inbounds double, double* %61, i64 2
%64 = bitcast double* %63 to <2 x double>*
store <2 x double> %60, <2 x double>* %64
%65 = or i64 %40, 4
%66 = trunc i64 %65 to i32
%67 = add i32 %20, %66
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds double, double* %2, i64 %68
%70 = bitcast double* %69 to <2 x double>*
%71 = load <2 x double>, <2 x double>* %70
%72 = getelementptr inbounds double, double* %69, i64 2
%73 = bitcast double* %72 to <2 x double>*
%74 = load <2 x double>, <2 x double>* %73
%75 = getelementptr inbounds double, double* %14, i64 %65
%76 = bitcast double* %75 to <2 x double>*
store <2 x double> %71, <2 x double>* %76
%77 = getelementptr inbounds double, double* %75, i64 2
%78 = bitcast double* %77 to <2 x double>*
store <2 x double> %74, <2 x double>* %78
%79 = getelementptr inbounds double, double* %4, i64 %68
%80 = bitcast double* %79 to <2 x double>*
%81 = load <2 x double>, <2 x double>* %80
%82 = getelementptr inbounds double, double* %79, i64 2
%83 = bitcast double* %82 to <2 x double>*
%84 = load <2 x double>, <2 x double>* %83
%85 = getelementptr inbounds double, double* %15, i64 %65
%86 = bitcast double* %85 to <2 x double>*
store <2 x double> %81, <2 x double>* %86
%87 = getelementptr inbounds double, double* %85, i64 2
%88 = bitcast double* %87 to <2 x double>*
store <2 x double> %84, <2 x double>* %88
%89 = add nuw i64 %40, 8
%90 = add i64 %41, 2
%91 = icmp eq i64 %90, %38
br i1 %91, label %92, label %39
92: ; preds = %39, %30
%93 = phi i64 [ 0, %30 ], [ %89, %39 ]
%94 = icmp eq i64 %35, 0
br i1 %94, label %119, label %95
95: ; preds = %92
%96 = trunc i64 %93 to i32
%97 = add i32 %20, %96
%98 = sext i32 %97 to i64
%99 = getelementptr inbounds double, double* %2, i64 %98
%100 = bitcast double* %99 to <2 x double>*
%101 = load <2 x double>, <2 x double>* %100
%102 = getelementptr inbounds double, double* %99, i64 2
%103 = bitcast double* %102 to <2 x double>*
%104 = load <2 x double>, <2 x double>* %103
%105 = getelementptr inbounds double, double* %14, i64 %93
%106 = bitcast double* %105 to <2 x double>*
store <2 x double> %101, <2 x double>* %106
%107 = getelementptr inbounds double, double* %105, i64 2
%108 = bitcast double* %107 to <2 x double>*
store <2 x double> %104, <2 x double>* %108
%109 = getelementptr inbounds double, double* %4, i64 %98
%110 = bitcast double* %109 to <2 x double>*
%111 = load <2 x double>, <2 x double>* %110
%112 = getelementptr inbounds double, double* %109, i64 2
%113 = bitcast double* %112 to <2 x double>*
%114 = load <2 x double>, <2 x double>* %113
%115 = getelementptr inbounds double, double* %15, i64 %93
%116 = bitcast double* %115 to <2 x double>*
store <2 x double> %111, <2 x double>* %116
%117 = getelementptr inbounds double, double* %115, i64 2
%118 = bitcast double* %117 to <2 x double>*
store <2 x double> %114, <2 x double>* %118
br label %119
119: ; preds = %92, %95
%120 = icmp eq i64 %31, %13
br i1 %120, label %164, label %121
121: ; preds = %22, %19, %119
%122 = phi i64 [ 0, %22 ], [ 0, %19 ], [ %31, %119 ]
%123 = xor i64 %122, -1
%124 = and i64 %13, 1
%125 = icmp eq i64 %124, 0
br i1 %125, label %137, label %126
126: ; preds = %121
%127 = trunc i64 %122 to i32
%128 = add i32 %20, %127
%129 = sext i32 %128 to i64
%130 = getelementptr inbounds double, double* %2, i64 %129
%131 = load double, double* %130
%132 = getelementptr inbounds double, double* %14, i64 %122
store double %131, double* %132
%133 = getelementptr inbounds double, double* %4, i64 %129
%134 = load double, double* %133
%135 = getelementptr inbounds double, double* %15, i64 %122
store double %134, double* %135
%136 = or i64 %122, 1
br label %137
137: ; preds = %126, %121
%138 = phi i64 [ %122, %121 ], [ %136, %126 ]
%139 = sub nsw i64 0, %13
%140 = icmp eq i64 %123, %139
br i1 %140, label %164, label %141
141: ; preds = %137, %141
%142 = phi i64 [ %162, %141 ], [ %138, %137 ]
%143 = trunc i64 %142 to i32
%144 = add i32 %20, %143
%145 = sext i32 %144 to i64
%146 = getelementptr inbounds double, double* %2, i64 %145
%147 = load double, double* %146
%148 = getelementptr inbounds double, double* %14, i64 %142
store double %147, double* %148
%149 = getelementptr inbounds double, double* %4, i64 %145
%150 = load double, double* %149
%151 = getelementptr inbounds double, double* %15, i64 %142
store double %150, double* %151
%152 = add nuw nsw i64 %142, 1
%153 = trunc i64 %152 to i32
%154 = add i32 %20, %153
%155 = sext i32 %154 to i64
%156 = getelementptr inbounds double, double* %2, i64 %155
%157 = load double, double* %156
%158 = getelementptr inbounds double, double* %14, i64 %152
store double %157, double* %158
%159 = getelementptr inbounds double, double* %4, i64 %155
%160 = load double, double* %159
%161 = getelementptr inbounds double, double* %15, i64 %152
store double %160, double* %161
%162 = add nuw nsw i64 %142, 2
%163 = icmp eq i64 %162, %13
br i1 %163, label %164, label %141
164: ; preds = %137, %141, %119, %5
%165 = call double @lagrange_interp_1D(double %0, double* %14, i32 %12, double* %15)
ret double %165
}