#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 /*<<< orphan*/ Alert(char *);
double cos(double);
double sqrt(double);
double lawOfCosinesFarSide(double alpha, double a, double b) {
  double tmp;
  if (a <= 0.0 || b <= 0.0) {
    Alert("lawOfCosinesFarSide():  side length(s) non-positive");
    return 0.0;
  }
  tmp = a * a + b * b - 2.0 * a * b * cos(alpha);
  if (tmp <= 0.0) {
    Alert("lawOfCosinesFarSide():  bad triangle parameters");
    return 0.0;
  }
  return sqrt(tmp);
}


x86 assembly (clang, -O0):
<lawOfCosinesFarSide>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x18(%rbp),%xmm0
jae    1163 <lawOfCosinesFarSide+0x33>
xorps  %xmm0,%xmm0
ucomisd -0x20(%rbp),%xmm0
jb     117c <lawOfCosinesFarSide+0x4c>
lea    0xe9e(%rip),%rdi
call   1030 <Alert@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1225 <lawOfCosinesFarSide+0xf5>
movsd  -0x18(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm2
movsd  -0x20(%rbp),%xmm1
mulsd  -0x20(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  0xe5b(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1040 <cos@plt>
movsd  -0x38(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x30(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x28(%rbp),%xmm0
jb     1216 <lawOfCosinesFarSide+0xe6>
lea    0xe38(%rip),%rdi
call   1030 <Alert@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1225 <lawOfCosinesFarSide+0xf5>
movsd  -0x28(%rbp),%xmm0
call   1050 <sqrt@plt>
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lawOfCosinesFarSide>:
sub    $0x18,%rsp
xorpd  %xmm3,%xmm3
ucomisd %xmm1,%xmm3
jae    11ab <lawOfCosinesFarSide+0x7b>
ucomisd %xmm2,%xmm3
jae    11ab <lawOfCosinesFarSide+0x7b>
movapd %xmm2,%xmm3
mulsd  %xmm2,%xmm3
movapd %xmm1,%xmm4
mulsd  %xmm1,%xmm4
addsd  %xmm3,%xmm4
movsd  %xmm4,0x8(%rsp)
movsd  %xmm1,0x10(%rsp)
movsd  %xmm2,(%rsp)
call   1040 <cos@plt>
movsd  0x10(%rsp),%xmm1
mulsd  0xe84(%rip),%xmm1
mulsd  (%rsp),%xmm1
mulsd  %xmm0,%xmm1
addsd  0x8(%rsp),%xmm1
xorpd  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
jae    11b4 <lawOfCosinesFarSide+0x84>
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm1
jb     11c9 <lawOfCosinesFarSide+0x99>
xorps  %xmm0,%xmm0
sqrtsd %xmm1,%xmm0
add    $0x18,%rsp
ret
lea    0xe56(%rip),%rdi
jmp    11bb <lawOfCosinesFarSide+0x8b>
lea    0xe81(%rip),%rdi
call   1030 <Alert@plt>
xorpd  %xmm0,%xmm0
add    $0x18,%rsp
ret
movapd %xmm1,%xmm0
add    $0x18,%rsp
jmp    1050 <sqrt@plt>

LLVM IR (-O0):
@.str = [52 x i8] c"lawOfCosinesFarSide(): side length(s) non-positive\00"
@.str.1 = [48 x i8] c"lawOfCosinesFarSide(): bad triangle parameters\00"
define double @lawOfCosinesFarSide(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* %6
%10 = fcmp ole double %9, 0.000000e+00
br i1 %10, label %14, label %11
11: ; preds = %3
%12 = load double, double* %7
%13 = fcmp ole double %12, 0.000000e+00
br i1 %13, label %14, label %16
14: ; preds = %11, %3
%15 = call i32 @Alert(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0))
store double 0.000000e+00, double* %4
br label %38
16: ; preds = %11
%17 = load double, double* %6
%18 = load double, double* %6
%19 = load double, double* %7
%20 = load double, double* %7
%21 = fmul double %19, %20
%22 = call double @llvm.fmuladd.f64(double %17, double %18, double %21)
%23 = load double, double* %6
%24 = fmul double 2.000000e+00, %23
%25 = load double, double* %7
%26 = fmul double %24, %25
%27 = load double, double* %5
%28 = call double @cos(double %27)
%29 = fneg double %26
%30 = call double @llvm.fmuladd.f64(double %29, double %28, double %22)
store double %30, double* %8
%31 = load double, double* %8
%32 = fcmp ole double %31, 0.000000e+00
br i1 %32, label %33, label %35
33: ; preds = %16
%34 = call i32 @Alert(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.1, i64 0, i64 0))
store double 0.000000e+00, double* %4
br label %38
35: ; preds = %16
%36 = load double, double* %8
%37 = call double @sqrt(double %36)
store double %37, double* %4
br label %38
38: ; preds = %35, %33, %14
%39 = load double, double* %4
ret double %39
}

LLVM IR (-O2):
@.str = [52 x i8] c"lawOfCosinesFarSide(): side length(s) non-positive\00"
@.str.1 = [48 x i8] c"lawOfCosinesFarSide(): bad triangle parameters\00"
define double @lawOfCosinesFarSide(double %0, double %1, double %2) {
%4 = fcmp ole double %1, 0.000000e+00
%5 = fcmp ole double %2, 0.000000e+00
%6 = or i1 %4, %5
br i1 %6, label %7, label %9
7: ; preds = %3
%8 = tail call i32 @Alert(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0))
br label %21
9: ; preds = %3
%10 = fmul double %2, %2
%11 = tail call double @llvm.fmuladd.f64(double %1, double %1, double %10)
%12 = tail call double @cos(double %0)
%13 = fmul double %1, -2.000000e+00
%14 = fmul double %13, %2
%15 = tail call double @llvm.fmuladd.f64(double %14, double %12, double %11)
%16 = fcmp ugt double %15, 0.000000e+00
br i1 %16, label %19, label %17
17: ; preds = %9
%18 = tail call i32 @Alert(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.1, i64 0, i64 0))
br label %21
19: ; preds = %9
%20 = tail call double @sqrt(double %15)
br label %21
21: ; preds = %19, %17, %7
%22 = phi double [ 0.000000e+00, %7 ], [ 0.000000e+00, %17 ], [ %20, %19 ]
ret double %22
}