#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 FE_INVALID;
int FE_OVERFLOW;
int FE_UNDERFLOW;
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ fetestexcept(int);
double pow(double, int);
double getGeoMean(double *val, long int often) {
  double GeoMean = 1;
  assert(often != 0);
  for (size_t i = 0; i < often; ++i) {
    GeoMean = GeoMean * pow(val[i], 1. / often);
    assert(!fetestexcept(FE_INVALID | FE_OVERFLOW | FE_UNDERFLOW));
  }
  return GeoMean;
}


x86 assembly (clang, -O0):
<getGeoMean>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movsd  0xeb8(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    11fb <getGeoMean+0xcb>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
cvtsi2sdq -0x10(%rbp),%xmm2
movsd  0xe66(%rip),%xmm1
divsd  %xmm2,%xmm1
cvttsd2si %xmm1,%edi
call   1050 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    0x2e31(%rip),%rax
mov    (%rax),%edi
mov    0x2e08(%rip),%rax
or     (%rax),%edi
mov    0x2e0f(%rip),%rax
or     (%rax),%edi
call   1030 <fetestexcept@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1167 <getGeoMean+0x37>
movsd  -0x18(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getGeoMean>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %rdi,%r14
xor    %edi,%edi
test   %rsi,%rsi
setne  %dil
call   1040 <assert@plt>
test   %r15,%r15
je     11c9 <getGeoMean+0x99>
cvtsi2sd %r15,%xmm0
movsd  0xe9f(%rip),%xmm1
movsd  %xmm1,(%rsp)
divsd  %xmm0,%xmm1
cvttsd2si %xmm1,%ebp
xor    %ebx,%ebx
mov    0x2e59(%rip),%r13
mov    0x2e62(%rip),%r12
xchg   %ax,%ax
movsd  (%r14,%rbx,8),%xmm0
mov    %ebp,%edi
call   1050 <pow@plt>
movsd  (%rsp),%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
mov    0x0(%r13),%edi
mov    0x2e4a(%rip),%rax
or     (%rax),%edi
or     (%r12),%edi
call   1030 <fetestexcept@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1040 <assert@plt>
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1180 <getGeoMean+0x50>
jmp    11d6 <getGeoMean+0xa6>
movsd  0xe2f(%rip),%xmm0
movsd  %xmm0,(%rsp)
movsd  (%rsp),%xmm0
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@FE_INVALID = global i32 0
@FE_OVERFLOW = global i32 0
@FE_UNDERFLOW = global i32 0
define double @getGeoMean(double* %0, i64 %1) {
%3 = alloca double*
%4 = alloca i64
%5 = alloca double
%6 = alloca i64
store double* %0, double** %3
store i64 %1, i64* %4
store double 1.000000e+00, double* %5
%7 = load i64, i64* %4
%8 = icmp ne i64 %7, 0
%9 = zext i1 %8 to i32
%10 = call i32 @assert(i32 %9)
store i64 0, i64* %6
br label %11
11: ; preds = %37, %2
%12 = load i64, i64* %6
%13 = load i64, i64* %4
%14 = icmp ult i64 %12, %13
br i1 %14, label %15, label %40
15: ; preds = %11
%16 = load double, double* %5
%17 = load double*, double** %3
%18 = load i64, i64* %6
%19 = getelementptr inbounds double, double* %17, i64 %18
%20 = load double, double* %19
%21 = load i64, i64* %4
%22 = sitofp i64 %21 to double
%23 = fdiv double 1.000000e+00, %22
%24 = fptosi double %23 to i32
%25 = call double @pow(double %20, i32 %24)
%26 = fmul double %16, %25
store double %26, double* %5
%27 = load i32, i32* @FE_INVALID
%28 = load i32, i32* @FE_OVERFLOW
%29 = or i32 %27, %28
%30 = load i32, i32* @FE_UNDERFLOW
%31 = or i32 %29, %30
%32 = call i32 @fetestexcept(i32 %31)
%33 = icmp ne i32 %32, 0
%34 = xor i1 %33, true
%35 = zext i1 %34 to i32
%36 = call i32 @assert(i32 %35)
br label %37
37: ; preds = %15
%38 = load i64, i64* %6
%39 = add i64 %38, 1
store i64 %39, i64* %6
br label %11
40: ; preds = %11
%41 = load double, double* %5
ret double %41
}

LLVM IR (-O2):
@FE_INVALID = global i32 0
@FE_OVERFLOW = global i32 0
@FE_UNDERFLOW = global i32 0
define double @getGeoMean(double* nocapture %0, i64 %1) {
%3 = icmp ne i64 %1, 0
%4 = zext i1 %3 to i32
%5 = tail call i32 @assert(i32 %4)
%6 = icmp eq i64 %1, 0
br i1 %6, label %11, label %7
7: ; preds = %2
%8 = sitofp i64 %1 to double
%9 = fdiv double 1.000000e+00, %8
%10 = fptosi double %9 to i32
br label %13
11: ; preds = %13, %2
%12 = phi double [ 1.000000e+00, %2 ], [ %19, %13 ]
ret double %12
13: ; preds = %7, %13
%14 = phi i64 [ 0, %7 ], [ %29, %13 ]
%15 = phi double [ 1.000000e+00, %7 ], [ %19, %13 ]
%16 = getelementptr inbounds double, double* %0, i64 %14
%17 = load double, double* %16
%18 = tail call double @pow(double %17, i32 %10)
%19 = fmul double %15, %18
%20 = load i32, i32* @FE_INVALID
%21 = load i32, i32* @FE_OVERFLOW
%22 = or i32 %21, %20
%23 = load i32, i32* @FE_UNDERFLOW
%24 = or i32 %22, %23
%25 = tail call i32 @fetestexcept(i32 %24)
%26 = icmp eq i32 %25, 0
%27 = zext i1 %26 to i32
%28 = tail call i32 @assert(i32 %27)
%29 = add nuw i64 %14, 1
%30 = icmp eq i64 %29, %1
br i1 %30, label %11, label %13
}