#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 sqrt(double const);
double radius_from_diagonal(double r_minor, double x_core, double thick_rim,
                            double thick_face, double length) {
  const double radius_max = (x_core < 1.0 ? r_minor : x_core * r_minor);
  const double radius_max_tot = radius_max + thick_rim;
  const double length_tot = length + 2.0 * thick_face;
  return sqrt(radius_max_tot * radius_max_tot + 0.25 * length_tot * length_tot);
}


x86 assembly (clang, -O0):
<radius_from_diagonal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  %xmm3,-0x20(%rbp)
movsd  %xmm4,-0x28(%rbp)
movsd  0xec7(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    1153 <radius_from_diagonal+0x43>
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
jmp    1162 <radius_from_diagonal+0x52>
movsd  -0x10(%rbp),%xmm0
mulsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x28(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm0
addsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm2
movsd  0xe64(%rip),%xmm1
mulsd  -0x40(%rbp),%xmm1
mulsd  -0x40(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1030 <sqrt@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<radius_from_diagonal>:
movapd %xmm0,%xmm5
movsd  0xee4(%rip),%xmm0
maxsd  %xmm1,%xmm0
mulsd  %xmm5,%xmm0
addsd  %xmm2,%xmm0
addsd  %xmm3,%xmm3
addsd  %xmm4,%xmm3
movsd  0xed0(%rip),%xmm1
mulsd  %xmm3,%xmm1
mulsd  %xmm3,%xmm1
mulsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1157 <radius_from_diagonal+0x47>
sqrtsd %xmm0,%xmm0
ret
jmp    1030 <sqrt@plt>

LLVM IR (-O0):
define double @radius_from_diagonal(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
%13 = 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
%14 = load double, double* %7
%15 = fcmp olt double %14, 1.000000e+00
br i1 %15, label %16, label %18
16: ; preds = %5
%17 = load double, double* %6
br label %22
18: ; preds = %5
%19 = load double, double* %7
%20 = load double, double* %6
%21 = fmul double %19, %20
br label %22
22: ; preds = %18, %16
%23 = phi double [ %17, %16 ], [ %21, %18 ]
store double %23, double* %11
%24 = load double, double* %11
%25 = load double, double* %8
%26 = fadd double %24, %25
store double %26, double* %12
%27 = load double, double* %10
%28 = load double, double* %9
%29 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %28, double %27)
store double %29, double* %13
%30 = load double, double* %12
%31 = load double, double* %12
%32 = load double, double* %13
%33 = fmul double 2.500000e-01, %32
%34 = load double, double* %13
%35 = fmul double %33, %34
%36 = call double @llvm.fmuladd.f64(double %30, double %31, double %35)
%37 = call double @sqrt(double %36)
ret double %37
}

LLVM IR (-O2):
define double @radius_from_diagonal(double %0, double %1, double %2, double %3, double %4) {
%6 = fcmp olt double %1, 1.000000e+00
%7 = select i1 %6, double 1.000000e+00, double %1
%8 = fmul double %7, %0
%9 = fadd double %8, %2
%10 = tail call double @llvm.fmuladd.f64(double %3, double 2.000000e+00, double %4)
%11 = fmul double %10, 2.500000e-01
%12 = fmul double %10, %11
%13 = tail call double @llvm.fmuladd.f64(double %9, double %9, double %12)
%14 = tail call double @sqrt(double %13)
ret double %14
}