#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 asin(double);
int /*<<< orphan*/ tan(double);
int tanh(int /*<<< orphan*/);
double spliceFunction2(double x, double deltax) {
  if (deltax < 0) {
    x = -x;
    deltax = -deltax;
  }
  if (x <= -deltax) {
    return 0;
  } else if (x >= deltax) {
    return 1;
  } else {
    double piHalf = asin(1.0);
    return (1 + tanh(tan((x / deltax) * piHalf))) / 2;
  }
}


x86 assembly (clang, -O0):
<spliceFunction2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    1192 <spliceFunction2+0x62>
movsd  -0x10(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x18(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
ucomisd %xmm1,%xmm0
jb     11ca <spliceFunction2+0x9a>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    122d <spliceFunction2+0xfd>
movsd  -0x10(%rbp),%xmm0
ucomisd -0x18(%rbp),%xmm0
jb     11ec <spliceFunction2+0xbc>
movsd  0xe1e(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    122d <spliceFunction2+0xfd>
movsd  0xe0c(%rip),%xmm0
call   1040 <asin@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
divsd  -0x18(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
call   1050 <tan@plt>
mov    %eax,%edi
call   1030 <tanh@plt>
add    $0x1,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<spliceFunction2>:
push   %rax
movapd %xmm0,%xmm3
xorpd  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
movapd 0xecb(%rip),%xmm4
movapd %xmm3,%xmm5
xorpd  %xmm4,%xmm5
movapd %xmm1,%xmm2
cmpltsd %xmm0,%xmm2
andpd  %xmm2,%xmm5
andnpd %xmm3,%xmm2
orpd   %xmm5,%xmm2
jbe    1158 <spliceFunction2+0x38>
xorpd  %xmm4,%xmm1
xorpd  %xmm1,%xmm4
ucomisd %xmm2,%xmm4
jae    119a <spliceFunction2+0x7a>
ucomisd %xmm1,%xmm2
jae    119c <spliceFunction2+0x7c>
divsd  %xmm1,%xmm2
mulsd  0xea4(%rip),%xmm2
movapd %xmm2,%xmm0
call   1040 <tan@plt>
mov    %eax,%edi
call   1030 <tanh@plt>
mov    %eax,%ecx
add    $0x1,%ecx
shr    $0x1f,%ecx
add    %ecx,%eax
add    $0x1,%eax
sar    %eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
pop    %rax
ret
movsd  0xe6c(%rip),%xmm0
pop    %rax
ret

LLVM IR (-O0):
define double @spliceFunction2(double %0, double %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
store double %0, double* %4
store double %1, double* %5
%7 = load double, double* %5
%8 = fcmp olt double %7, 0.000000e+00
br i1 %8, label %9, label %14
9: ; preds = %2
%10 = load double, double* %4
%11 = fneg double %10
store double %11, double* %4
%12 = load double, double* %5
%13 = fneg double %12
store double %13, double* %5
br label %14
14: ; preds = %9, %2
%15 = load double, double* %4
%16 = load double, double* %5
%17 = fneg double %16
%18 = fcmp ole double %15, %17
br i1 %18, label %19, label %20
19: ; preds = %14
store double 0.000000e+00, double* %3
br label %37
20: ; preds = %14
%21 = load double, double* %4
%22 = load double, double* %5
%23 = fcmp oge double %21, %22
br i1 %23, label %24, label %25
24: ; preds = %20
store double 1.000000e+00, double* %3
br label %37
25: ; preds = %20
%26 = call double @asin(double 1.000000e+00)
store double %26, double* %6
%27 = load double, double* %4
%28 = load double, double* %5
%29 = fdiv double %27, %28
%30 = load double, double* %6
%31 = fmul double %29, %30
%32 = call i32 @tan(double %31)
%33 = call i32 @tanh(i32 %32)
%34 = add nsw i32 1, %33
%35 = sdiv i32 %34, 2
%36 = sitofp i32 %35 to double
store double %36, double* %3
br label %37
37: ; preds = %25, %24, %19
%38 = load double, double* %3
ret double %38
}

LLVM IR (-O2):
define double @spliceFunction2(double %0, double %1) {
%3 = fcmp olt double %1, 0.000000e+00
%4 = fneg double %0
%5 = fneg double %1
%6 = select i1 %3, double %4, double %0
%7 = select i1 %3, double %5, double %1
%8 = fneg double %7
%9 = fcmp ugt double %6, %8
br i1 %9, label %10, label %20
10: ; preds = %2
%11 = fcmp ult double %6, %7
br i1 %11, label %12, label %20
12: ; preds = %10
%13 = fdiv double %6, %7
%14 = fmul double %13, 0x3FF921FB54442D18
%15 = tail call i32 @tan(double %14)
%16 = tail call i32 @tanh(i32 %15)
%17 = add nsw i32 %16, 1
%18 = sdiv i32 %17, 2
%19 = sitofp i32 %18 to double
br label %20
20: ; preds = %10, %2, %12
%21 = phi double [ %19, %12 ], [ 0.000000e+00, %2 ], [ 1.000000e+00, %10 ]
ret double %21
}