#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 sqrt(double);
double divalent_to_monovalent(double divalent, double dntp) {
  if (divalent == 0)
    dntp = 0;
  if (divalent < 0 || dntp < 0)
    return -999999.9999;
  if (divalent < dntp)
    divalent = dntp;
  return 120 * (sqrt(divalent - dntp));
}


x86 assembly (clang, -O0):
<divalent_to_monovalent>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1142 <divalent_to_monovalent+0x32>
jp     1142 <divalent_to_monovalent+0x32>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
ja     115e <divalent_to_monovalent+0x4e>
xorps  %xmm0,%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    1170 <divalent_to_monovalent+0x60>
movsd  0xe9a(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11a9 <divalent_to_monovalent+0x99>
movsd  -0x10(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    118e <divalent_to_monovalent+0x7e>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
call   1030 <sqrt@plt>
imul   $0x78,%eax,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<divalent_to_monovalent>:
push   %rax
movapd %xmm0,%xmm2
xorpd  %xmm4,%xmm4
ucomisd %xmm0,%xmm4
movsd  0xedb(%rip),%xmm0
ja     1155 <divalent_to_monovalent+0x45>
movapd %xmm2,%xmm3
cmpeqsd %xmm4,%xmm3
andnpd %xmm1,%xmm3
ucomisd %xmm3,%xmm4
ja     1155 <divalent_to_monovalent+0x45>
movapd %xmm3,%xmm0
maxsd  %xmm2,%xmm0
subsd  %xmm3,%xmm0
call   1030 <sqrt@plt>
imul   $0x78,%eax,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
pop    %rax
ret

LLVM IR (-O0):
define double @divalent_to_monovalent(double %0, double %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca double
store double %0, double* %4
store double %1, double* %5
%6 = load double, double* %4
%7 = fcmp oeq double %6, 0.000000e+00
br i1 %7, label %8, label %9
8: ; preds = %2
store double 0.000000e+00, double* %5
br label %9
9: ; preds = %8, %2
%10 = load double, double* %4
%11 = fcmp olt double %10, 0.000000e+00
br i1 %11, label %15, label %12
12: ; preds = %9
%13 = load double, double* %5
%14 = fcmp olt double %13, 0.000000e+00
br i1 %14, label %15, label %16
15: ; preds = %12, %9
store double 0xC12E847FFFF2E48F, double* %3
br label %29
16: ; preds = %12
%17 = load double, double* %4
%18 = load double, double* %5
%19 = fcmp olt double %17, %18
br i1 %19, label %20, label %22
20: ; preds = %16
%21 = load double, double* %5
store double %21, double* %4
br label %22
22: ; preds = %20, %16
%23 = load double, double* %4
%24 = load double, double* %5
%25 = fsub double %23, %24
%26 = call i32 @sqrt(double %25)
%27 = mul nsw i32 120, %26
%28 = sitofp i32 %27 to double
store double %28, double* %3
br label %29
29: ; preds = %22, %15
%30 = load double, double* %3
ret double %30
}

LLVM IR (-O2):
define double @divalent_to_monovalent(double %0, double %1) {
%3 = fcmp oeq double %0, 0.000000e+00
%4 = select i1 %3, double 0.000000e+00, double %1
%5 = fcmp olt double %0, 0.000000e+00
%6 = fcmp olt double %4, 0.000000e+00
%7 = or i1 %5, %6
br i1 %7, label %15, label %8
8: ; preds = %2
%9 = fcmp ogt double %4, %0
%10 = select i1 %9, double %4, double %0
%11 = fsub double %10, %4
%12 = tail call i32 @sqrt(double %11)
%13 = mul nsw i32 %12, 120
%14 = sitofp i32 %13 to double
br label %15
15: ; preds = %2, %8
%16 = phi double [ %14, %8 ], [ 0xC12E847FFFF2E48F, %2 ]
ret double %16
}