double flott_nid(double ab, double a, double b) {
  double ret_val = -1.0;
  double max = (((a) > (b)) ? (a) : (b));
  double min = (((a) < (b)) ? (a) : (b));
  if (max > 0.0) {
    ret_val = (ab - min) / max;
  }
  return ret_val;
}


x86 assembly (clang, -O0):
<flott_nid>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  0xee5(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    113f <flott_nid+0x3f>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    1149 <flott_nid+0x49>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1176 <flott_nid+0x76>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
jmp    1180 <flott_nid+0x80>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    11b0 <flott_nid+0xb0>
movsd  -0x8(%rbp),%xmm0
subsd  -0x30(%rbp),%xmm0
divsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<flott_nid>:
movapd %xmm1,%xmm3
maxsd  %xmm2,%xmm3
xorpd  %xmm4,%xmm4
ucomisd %xmm4,%xmm3
jbe    111f <flott_nid+0x1f>
minsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
divsd  %xmm3,%xmm0
ret
movsd  0xed9(%rip),%xmm0
ret

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

LLVM IR (-O2):
define double @flott_nid(double %0, double %1, double %2) {
%4 = fcmp ogt double %1, %2
%5 = select i1 %4, double %1, double %2
%6 = fcmp ogt double %5, 0.000000e+00
br i1 %6, label %7, label %12
7: ; preds = %3
%8 = fcmp olt double %1, %2
%9 = select i1 %8, double %1, double %2
%10 = fsub double %0, %9
%11 = fdiv double %10, %5
br label %12
12: ; preds = %7, %3
%13 = phi double [ %11, %7 ], [ -1.000000e+00, %3 ]
ret double %13
}