#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 */
struct pca_group {
  int dummy;
};

/* Variables and functions */
scalar_t__ bhattacharyya_coefficient(struct pca_group *, struct pca_group *);
double sqrt(scalar_t__);
double pca_group_distance_hellinger(struct pca_group *groupA,
                                    struct pca_group *groupB) {
  if (groupA == groupB)
    return 0.0;
  else
    return sqrt(1.0 - bhattacharyya_coefficient(groupA, groupB));
}


x86 assembly (clang, -O0):
<pca_group_distance_hellinger>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
cmp    -0x18(%rbp),%rax
jne    114b <pca_group_distance_hellinger+0x2b>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1178 <pca_group_distance_hellinger+0x58>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <bhattacharyya_coefficient@plt>
cvtsi2sd %rax,%xmm1
movsd  0xe9b(%rip),%xmm0
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rdi
call   1030 <sqrt@plt>
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pca_group_distance_hellinger>:
cmp    %rsi,%rdi
je     1147 <pca_group_distance_hellinger+0x27>
push   %rax
call   1040 <bhattacharyya_coefficient@plt>
cvtsi2sd %rax,%xmm0
movsd  0xec8(%rip),%xmm1
subsd  %xmm0,%xmm1
cvttsd2si %xmm1,%rdi
pop    %rax
jmp    1030 <sqrt@plt>
xorps  %xmm0,%xmm0
ret

LLVM IR (-O0):
%struct.pca_group = type { i32 }
define double @pca_group_distance_hellinger(%struct.pca_group* %0, %struct.pca_group* %1) {
%3 = alloca double
%4 = alloca %struct.pca_group*
%5 = alloca %struct.pca_group*
store %struct.pca_group* %0, %struct.pca_group** %4
store %struct.pca_group* %1, %struct.pca_group** %5
%6 = load %struct.pca_group*, %struct.pca_group** %4
%7 = load %struct.pca_group*, %struct.pca_group** %5
%8 = icmp eq %struct.pca_group* %6, %7
br i1 %8, label %9, label %10
9: ; preds = %2
store double 0.000000e+00, double* %3
br label %18
10: ; preds = %2
%11 = load %struct.pca_group*, %struct.pca_group** %4
%12 = load %struct.pca_group*, %struct.pca_group** %5
%13 = call i64 @bhattacharyya_coefficient(%struct.pca_group* %11, %struct.pca_group* %12)
%14 = sitofp i64 %13 to double
%15 = fsub double 1.000000e+00, %14
%16 = fptosi double %15 to i64
%17 = call double @sqrt(i64 %16)
store double %17, double* %3
br label %18
18: ; preds = %10, %9
%19 = load double, double* %3
ret double %19
}

LLVM IR (-O2):
%struct.pca_group = type { i32 }
define double @pca_group_distance_hellinger(%struct.pca_group* %0, %struct.pca_group* %1) {
%3 = icmp eq %struct.pca_group* %0, %1
br i1 %3, label %10, label %4
4: ; preds = %2
%5 = tail call i64 @bhattacharyya_coefficient(%struct.pca_group* %0, %struct.pca_group* %1)
%6 = sitofp i64 %5 to double
%7 = fsub double 1.000000e+00, %6
%8 = fptosi double %7 to i64
%9 = tail call double @sqrt(i64 %8)
br label %10
10: ; preds = %2, %4
%11 = phi double [ %9, %4 ], [ 0.000000e+00, %2 ]
ret double %11
}