#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 */
typedef double pos;

/* Variables and functions */
double spliceFunction2(double, double);
double spliceFunction2der(double, double, double, double);
double spliceFunctionF_der(double pos, double neg, double x, double deltax,
                           double pos_der, double neg_der, double x_der,
                           double deltax_der) {
  const double d = spliceFunction2(x, deltax);
  return (d * (d > 0 ? (pos_der) : 0.0) + (1 - d) * (d < 1 ? (neg_der) : 0.0) +
          (d > 0 && d < 1
               ? spliceFunction2der((x), (deltax), (x_der), (deltax_der)) *
                     ((pos) - (neg))
               : 0.0));
}


x86 assembly (clang, -O0):
<spliceFunctionF_der>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  %xmm3,-0x20(%rbp)
movsd  %xmm4,-0x28(%rbp)
movsd  %xmm5,-0x30(%rbp)
movsd  %xmm6,-0x38(%rbp)
movsd  %xmm7,-0x40(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
call   1040 <spliceFunction2@plt>
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x48(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    1192 <spliceFunctionF_der+0x72>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
jmp    119f <spliceFunctionF_der+0x7f>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x58(%rbp)
jmp    119f <spliceFunctionF_der+0x7f>
movsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  0xe4f(%rip),%xmm0
subsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  0xe3d(%rip),%xmm0
ucomisd -0x48(%rbp),%xmm0
jbe    11dd <spliceFunctionF_der+0xbd>
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
jmp    11ea <spliceFunctionF_der+0xca>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x70(%rbp)
jmp    11ea <spliceFunctionF_der+0xca>
movsd  -0x68(%rbp),%xmm2
movsd  -0x50(%rbp),%xmm0
movsd  -0x60(%rbp),%xmm1
movsd  -0x70(%rbp),%xmm3
mulsd  %xmm3,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x48(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    1265 <spliceFunctionF_der+0x145>
movsd  0xdd7(%rip),%xmm0
ucomisd -0x48(%rbp),%xmm0
jbe    1265 <spliceFunctionF_der+0x145>
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  -0x38(%rbp),%xmm2
movsd  -0x40(%rbp),%xmm3
call   1030 <spliceFunction2der@plt>
movsd  -0x8(%rbp),%xmm1
subsd  -0x10(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x80(%rbp)
jmp    1272 <spliceFunctionF_der+0x152>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x80(%rbp)
jmp    1272 <spliceFunctionF_der+0x152>
movsd  -0x78(%rbp),%xmm0
movsd  -0x80(%rbp),%xmm1
addsd  %xmm1,%xmm0
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<spliceFunctionF_der>:
sub    $0x58,%rsp
movsd  %xmm7,(%rsp)
movsd  %xmm6,0x18(%rsp)
movaps %xmm5,0x40(%rsp)
movaps %xmm4,0x30(%rsp)
movsd  %xmm1,0x20(%rsp)
movsd  %xmm0,0x28(%rsp)
movsd  %xmm2,0x8(%rsp)
movapd %xmm2,%xmm0
movsd  %xmm3,0x10(%rsp)
movapd %xmm3,%xmm1
call   1040 <spliceFunction2@plt>
movapd %xmm0,%xmm4
xorpd  %xmm3,%xmm3
ucomisd %xmm3,%xmm0
xorpd  %xmm0,%xmm0
jbe    11c0 <spliceFunctionF_der+0xa0>
movsd  0xe88(%rip),%xmm0
ucomisd %xmm4,%xmm0
xorpd  %xmm0,%xmm0
jbe    11c0 <spliceFunctionF_der+0xa0>
movsd  0x8(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
movsd  0x18(%rsp),%xmm2
movsd  (%rsp),%xmm3
movsd  %xmm4,(%rsp)
call   1030 <spliceFunction2der@plt>
movsd  (%rsp),%xmm4
xorpd  %xmm3,%xmm3
movsd  0x28(%rsp),%xmm1
subsd  0x20(%rsp),%xmm1
mulsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
cmpltsd %xmm4,%xmm3
andpd  0x30(%rsp),%xmm3
movsd  0xe2d(%rip),%xmm1
movapd %xmm4,%xmm2
cmpltsd %xmm1,%xmm2
subsd  %xmm4,%xmm1
andpd  0x40(%rsp),%xmm2
mulsd  %xmm1,%xmm2
mulsd  %xmm4,%xmm3
addsd  %xmm2,%xmm3
addsd  %xmm0,%xmm3
movapd %xmm3,%xmm0
add    $0x58,%rsp
ret

LLVM IR (-O0):
define double @spliceFunctionF_der(double %0, double %1, double %2, double %3, double %4, double %5, double %6, double %7) {
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca double
%17 = alloca double
store double %0, double* %9
store double %1, double* %10
store double %2, double* %11
store double %3, double* %12
store double %4, double* %13
store double %5, double* %14
store double %6, double* %15
store double %7, double* %16
%18 = load double, double* %11
%19 = load double, double* %12
%20 = call double @spliceFunction2(double %18, double %19)
store double %20, double* %17
%21 = load double, double* %17
%22 = load double, double* %17
%23 = fcmp ogt double %22, 0.000000e+00
br i1 %23, label %24, label %26
24: ; preds = %8
%25 = load double, double* %13
br label %27
26: ; preds = %8
br label %27
27: ; preds = %26, %24
%28 = phi double [ %25, %24 ], [ 0.000000e+00, %26 ]
%29 = load double, double* %17
%30 = fsub double 1.000000e+00, %29
%31 = load double, double* %17
%32 = fcmp olt double %31, 1.000000e+00
br i1 %32, label %33, label %35
33: ; preds = %27
%34 = load double, double* %14
br label %36
35: ; preds = %27
br label %36
36: ; preds = %35, %33
%37 = phi double [ %34, %33 ], [ 0.000000e+00, %35 ]
%38 = fmul double %30, %37
%39 = call double @llvm.fmuladd.f64(double %21, double %28, double %38)
%40 = load double, double* %17
%41 = fcmp ogt double %40, 0.000000e+00
br i1 %41, label %42, label %55
42: ; preds = %36
%43 = load double, double* %17
%44 = fcmp olt double %43, 1.000000e+00
br i1 %44, label %45, label %55
45: ; preds = %42
%46 = load double, double* %11
%47 = load double, double* %12
%48 = load double, double* %15
%49 = load double, double* %16
%50 = call double @spliceFunction2der(double %46, double %47, double %48, double %49)
%51 = load double, double* %9
%52 = load double, double* %10
%53 = fsub double %51, %52
%54 = fmul double %50, %53
br label %56
55: ; preds = %42, %36
br label %56
56: ; preds = %55, %45
%57 = phi double [ %54, %45 ], [ 0.000000e+00, %55 ]
%58 = fadd double %39, %57
ret double %58
}

LLVM IR (-O2):
define double @spliceFunctionF_der(double %0, double %1, double %2, double %3, double %4, double %5, double %6, double %7) {
%9 = tail call double @spliceFunction2(double %2, double %3)
%10 = fcmp ogt double %9, 0.000000e+00
%11 = fcmp olt double %9, 1.000000e+00
%12 = and i1 %10, %11
br i1 %12, label %13, label %17
13: ; preds = %8
%14 = tail call double @spliceFunction2der(double %2, double %3, double %6, double %7)
%15 = fsub double %0, %1
%16 = fmul double %15, %14
br label %17
17: ; preds = %8, %13
%18 = phi double [ %16, %13 ], [ 0.000000e+00, %8 ]
%19 = select i1 %10, double %4, double 0.000000e+00
%20 = fsub double 1.000000e+00, %9
%21 = select i1 %11, double %5, double 0.000000e+00
%22 = fmul double %20, %21
%23 = tail call double @llvm.fmuladd.f64(double %9, double %19, double %22)
%24 = fadd double %23, %18
ret double %24
}