#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);
double tcr(double a, double b, double c) {
  double p = (a + b + c) / 2;
  if (p == 0)
    return 0;
  p = (p - a) * (p - b) * (p - c) / p;
  if (p < 0)
    return 0;
  return sqrt(p);
}


x86 assembly (clang, -O0):
<tcr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
addsd  -0x18(%rbp),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  0xec2(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    116c <tcr+0x5c>
jp     116c <tcr+0x5c>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11c6 <tcr+0xb6>
movsd  -0x28(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
subsd  -0x18(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  -0x28(%rbp),%xmm1
subsd  -0x20(%rbp),%xmm1
mulsd  %xmm1,%xmm0
divsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x28(%rbp),%xmm0
jbe    11b7 <tcr+0xa7>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11c6 <tcr+0xb6>
movsd  -0x28(%rbp),%xmm0
call   1030 <sqrt@plt>
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tcr>:
movapd %xmm0,%xmm4
addsd  %xmm1,%xmm4
addsd  %xmm2,%xmm4
mulsd  0xedc(%rip),%xmm4
xorpd  %xmm3,%xmm3
ucomisd %xmm3,%xmm4
jne    1135 <tcr+0x25>
jp     1135 <tcr+0x25>
movapd %xmm3,%xmm0
ret
movapd %xmm4,%xmm3
subsd  %xmm0,%xmm3
movapd %xmm4,%xmm5
subsd  %xmm1,%xmm5
mulsd  %xmm3,%xmm5
movapd %xmm4,%xmm0
subsd  %xmm2,%xmm0
mulsd  %xmm5,%xmm0
divsd  %xmm4,%xmm0
xorpd  %xmm3,%xmm3
ucomisd %xmm0,%xmm3
ja     1130 <tcr+0x20>
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1179 <tcr+0x69>
xorps  %xmm3,%xmm3
sqrtsd %xmm0,%xmm3
movapd %xmm3,%xmm0
ret
jmp    1030 <sqrt@plt>

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

LLVM IR (-O2):
define double @tcr(double %0, double %1, double %2) {
%4 = fadd double %0, %1
%5 = fadd double %4, %2
%6 = fmul double %5, 5.000000e-01
%7 = fcmp oeq double %6, 0.000000e+00
br i1 %7, label %18, label %8
8: ; preds = %3
%9 = fsub double %6, %0
%10 = fsub double %6, %1
%11 = fmul double %9, %10
%12 = fsub double %6, %2
%13 = fmul double %12, %11
%14 = fdiv double %13, %6
%15 = fcmp olt double %14, 0.000000e+00
br i1 %15, label %18, label %16
16: ; preds = %8
%17 = tail call double @sqrt(double %14)
br label %18
18: ; preds = %8, %3, %16
%19 = phi double [ %17, %16 ], [ 0.000000e+00, %3 ], [ 0.000000e+00, %8 ]
ret double %19
}