double adjust_x(double x, double xp, double sc, double delta, double kappa) {
  double y;
  double d;
  d = xp - sc;
  d = d < 0 ? -d : d;
  y = d / (kappa + d);
  if (xp > sc) {
    x -= delta * y;
  } else {
    x += delta * y;
  }
  return x;
}


x86 assembly (clang, -O0):
<adjust_x>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  %xmm3,-0x20(%rbp)
movsd  %xmm4,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x38(%rbp),%xmm0
jbe    1160 <adjust_x+0x60>
movsd  -0x38(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x40(%rbp)
jmp    116a <adjust_x+0x6a>
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
addsd  -0x38(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x10(%rbp),%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    11d4 <adjust_x+0xd4>
movsd  -0x20(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm2
movsd  -0x8(%rbp),%xmm1
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11f0 <adjust_x+0xf0>
movsd  -0x20(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm2
movsd  -0x8(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<adjust_x>:
movapd %xmm1,%xmm9
subsd  %xmm2,%xmm9
movapd 0xeee(%rip),%xmm6
movapd %xmm9,%xmm7
xorpd  %xmm6,%xmm7
xorpd  %xmm8,%xmm8
movapd %xmm9,%xmm5
cmpltsd %xmm8,%xmm5
andpd  %xmm5,%xmm7
andnpd %xmm9,%xmm5
orpd   %xmm7,%xmm5
addsd  %xmm5,%xmm4
divsd  %xmm4,%xmm5
xorpd  %xmm3,%xmm6
cmpltsd %xmm1,%xmm2
andpd  %xmm2,%xmm6
andnpd %xmm3,%xmm2
orpd   %xmm2,%xmm6
mulsd  %xmm5,%xmm6
addsd  %xmm6,%xmm0
ret

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

LLVM IR (-O2):
define double @adjust_x(double %0, double %1, double %2, double %3, double %4) {
%6 = fsub double %1, %2
%7 = fcmp olt double %6, 0.000000e+00
%8 = fneg double %6
%9 = select i1 %7, double %8, double %6
%10 = fadd double %9, %4
%11 = fdiv double %9, %10
%12 = fcmp ogt double %1, %2
%13 = fneg double %3
%14 = select i1 %12, double %13, double %3
%15 = tail call double @llvm.fmuladd.f64(double %14, double %11, double %0)
ret double %15
}