#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*/ exit(int);
int /*<<< orphan*/ printf(char *, double, double);
double sqrt(double);
double strength_coherence(double s1, double s2) {
  if (s1 + s2 == 0) {
    printf("Invalid strength values: s1=%f, s2=%f\n", s1, s2);
    exit(-1);
  }
  return 2.0 * sqrt(s1 * s2) / (s1 + s2);
}


x86 assembly (clang, -O0):
<strength_coherence>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  -0x8(%rbp),%xmm0
addsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    117f <strength_coherence+0x4f>
jp     117f <strength_coherence+0x4f>
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
lea    0xe98(%rip),%rdi
call   1030 <printf@plt>
mov    $0xffffffff,%edi
call   1050 <exit@plt>
movsd  -0x8(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
call   1040 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  0xe67(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  -0x8(%rbp),%xmm1
addsd  -0x10(%rbp),%xmm1
divsd  %xmm1,%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strength_coherence>:
push   %rax
movapd %xmm0,%xmm3
addsd  %xmm1,%xmm3
xorpd  %xmm2,%xmm2
ucomisd %xmm2,%xmm3
jne    1145 <strength_coherence+0x15>
jnp    116e <strength_coherence+0x3e>
mulsd  %xmm1,%xmm0
ucomisd %xmm2,%xmm0
jb     1155 <strength_coherence+0x25>
sqrtsd %xmm0,%xmm0
jmp    1164 <strength_coherence+0x34>
movsd  %xmm3,(%rsp)
call   1040 <sqrt@plt>
movsd  (%rsp),%xmm3
addsd  %xmm0,%xmm0
divsd  %xmm3,%xmm0
pop    %rax
ret
lea    0xe8b(%rip),%rdi
call   1030 <printf@plt>
mov    $0xffffffff,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [39 x i8] c"Invalid strength values: s1=%f, s2=%f\0A\00"
define double @strength_coherence(double %0, double %1) {
%3 = alloca double
%4 = alloca double
store double %0, double* %3
store double %1, double* %4
%5 = load double, double* %3
%6 = load double, double* %4
%7 = fadd double %5, %6
%8 = fcmp oeq double %7, 0.000000e+00
br i1 %8, label %9, label %14
9: ; preds = %2
%10 = load double, double* %3
%11 = load double, double* %4
%12 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), double %10, double %11)
%13 = call i32 @exit(i32 -1)
unreachable
14: ; preds = %2
%15 = load double, double* %3
%16 = load double, double* %4
%17 = fmul double %15, %16
%18 = call double @sqrt(double %17)
%19 = fmul double 2.000000e+00, %18
%20 = load double, double* %3
%21 = load double, double* %4
%22 = fadd double %20, %21
%23 = fdiv double %19, %22
ret double %23
}

LLVM IR (-O2):
@.str = [39 x i8] c"Invalid strength values: s1=%f, s2=%f\0A\00"
define double @strength_coherence(double %0, double %1) {
%3 = fadd double %0, %1
%4 = fcmp oeq double %3, 0.000000e+00
br i1 %4, label %5, label %8
5: ; preds = %2
%6 = tail call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), double %0, double %1)
%7 = tail call i32 @exit(i32 -1)
unreachable
8: ; preds = %2
%9 = fmul double %0, %1
%10 = tail call double @sqrt(double %9)
%11 = fmul double %10, 2.000000e+00
%12 = fdiv double %11, %3
ret double %12
}