#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*/ FE_ALL_EXCEPT;
int FE_DIVBYZERO;
int FE_INVALID;
int FE_OVERFLOW;
int FE_UNDERFLOW;
int /*<<< orphan*/ assert(int);
double exp2(double);
int /*<<< orphan*/ feclearexcept(int /*<<< orphan*/);
int /*<<< orphan*/ fetestexcept(int);
int /*<<< orphan*/ islessequal(double const, double);
int /*<<< orphan*/ isnan(double const);
scalar_t__ log2(double const);
double geom_mean_log(const double *const x, const size_t count) {
  assert(NULL != x);
  double sum = 0.0;
  assert(!feclearexcept(FE_ALL_EXCEPT));
  for (size_t i = 0; i < count; i++) {
    assert(!isnan(x[i]) && !islessequal(x[i], 0.0));
    sum += log2(x[i]);
  }
  double gm = exp2(sum / (double)count);
  assert(!fetestexcept(FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW));
  return gm;
}


x86 assembly (clang, -O0):
<geom_mean_log>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xor    %eax,%eax
cmp    -0x8(%rbp),%rax
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    0x2e26(%rip),%rax
mov    (%rax),%edi
call   1090 <feclearexcept@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    1252 <geom_mean_log+0xe2>
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
call   1080 <isnan@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x29(%rbp)
jne    1213 <geom_mean_log+0xa3>
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
xorps  %xmm1,%xmm1
call   1070 <islessequal@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
call   1040 <log2@plt>
cvtsi2sd %rax,%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    11c3 <geom_mean_log+0x53>
movsd  -0x18(%rbp),%xmm0
movaps 0xda2(%rip),%xmm2
movq   -0x10(%rbp),%xmm1
punpckldq %xmm2,%xmm1
movapd 0xda1(%rip),%xmm2
subpd  %xmm2,%xmm1
movaps %xmm1,%xmm2
unpckhpd %xmm1,%xmm1
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
call   1050 <exp2@plt>
movsd  %xmm0,-0x28(%rbp)
mov    0x2d5d(%rip),%rax
mov    (%rax),%edi
mov    0x2d3c(%rip),%rax
or     (%rax),%edi
mov    0x2d1b(%rip),%rax
or     (%rax),%edi
mov    0x2d32(%rip),%rax
or     (%rax),%edi
call   1030 <fetestexcept@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
movsd  -0x28(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<geom_mean_log>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r14
mov    %rdi,%r15
xor    %edi,%edi
test   %r15,%r15
setne  %dil
call   1060 <assert@plt>
mov    0x2e34(%rip),%rax
mov    (%rax),%edi
call   1090 <feclearexcept@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1060 <assert@plt>
xorpd  %xmm0,%xmm0
test   %r14,%r14
je     121a <geom_mean_log+0xaa>
xor    %ebx,%ebx
jmp    1201 <geom_mean_log+0x91>
cs nopw 0x0(%rax,%rax,1)
nop
movsd  (%r15,%rbx,8),%xmm0
xorps  %xmm1,%xmm1
call   1070 <islessequal@plt>
test   %eax,%eax
sete   %al
movzbl %al,%edi
call   1060 <assert@plt>
movsd  (%r15,%rbx,8),%xmm0
call   1040 <log2@plt>
xorps  %xmm1,%xmm1
cvtsi2sd %rax,%xmm1
movsd  0x8(%rsp),%xmm0
addsd  %xmm1,%xmm0
add    $0x1,%rbx
cmp    %rbx,%r14
je     121a <geom_mean_log+0xaa>
movsd  %xmm0,0x8(%rsp)
movsd  (%r15,%rbx,8),%xmm0
call   1080 <isnan@plt>
test   %eax,%eax
je     11c0 <geom_mean_log+0x50>
xor    %eax,%eax
jmp    11d3 <geom_mean_log+0x63>
movq   %r14,%xmm2
punpckldq 0xdd9(%rip),%xmm2
subpd  0xde1(%rip),%xmm2
movapd %xmm2,%xmm1
unpckhpd %xmm2,%xmm1
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
call   1050 <exp2@plt>
mov    0x2da5(%rip),%rax
mov    0x2d86(%rip),%rcx
mov    (%rcx),%edi
or     (%rax),%edi
mov    0x2d63(%rip),%rax
or     (%rax),%edi
movsd  %xmm0,0x8(%rsp)
mov    0x2d74(%rip),%rax
or     (%rax),%edi
call   1030 <fetestexcept@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1060 <assert@plt>
movsd  0x8(%rsp),%xmm0
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@FE_ALL_EXCEPT = global i32 0
@FE_INVALID = global i32 0
@FE_DIVBYZERO = global i32 0
@FE_OVERFLOW = global i32 0
@FE_UNDERFLOW = global i32 0
define double @geom_mean_log(double* %0, i64 %1) {
%3 = alloca double*
%4 = alloca i64
%5 = alloca double
%6 = alloca i64
%7 = alloca double
store double* %0, double** %3
store i64 %1, i64* %4
%8 = load double*, double** %3
%9 = icmp ne double* null, %8
%10 = zext i1 %9 to i32
%11 = call i32 @assert(i32 %10)
store double 0.000000e+00, double* %5
%12 = load i32, i32* @FE_ALL_EXCEPT
%13 = call i32 @feclearexcept(i32 %12)
%14 = icmp ne i32 %13, 0
%15 = xor i1 %14, true
%16 = zext i1 %15 to i32
%17 = call i32 @assert(i32 %16)
store i64 0, i64* %6
br label %18
18: ; preds = %49, %2
%19 = load i64, i64* %6
%20 = load i64, i64* %4
%21 = icmp ult i64 %19, %20
br i1 %21, label %22, label %52
22: ; preds = %18
%23 = load double*, double** %3
%24 = load i64, i64* %6
%25 = getelementptr inbounds double, double* %23, i64 %24
%26 = load double, double* %25
%27 = call i32 @isnan(double %26)
%28 = icmp ne i32 %27, 0
br i1 %28, label %37, label %29
29: ; preds = %22
%30 = load double*, double** %3
%31 = load i64, i64* %6
%32 = getelementptr inbounds double, double* %30, i64 %31
%33 = load double, double* %32
%34 = call i32 @islessequal(double %33, double 0.000000e+00)
%35 = icmp ne i32 %34, 0
%36 = xor i1 %35, true
br label %37
37: ; preds = %29, %22
%38 = phi i1 [ false, %22 ], [ %36, %29 ]
%39 = zext i1 %38 to i32
%40 = call i32 @assert(i32 %39)
%41 = load double*, double** %3
%42 = load i64, i64* %6
%43 = getelementptr inbounds double, double* %41, i64 %42
%44 = load double, double* %43
%45 = call i64 @log2(double %44)
%46 = sitofp i64 %45 to double
%47 = load double, double* %5
%48 = fadd double %47, %46
store double %48, double* %5
br label %49
49: ; preds = %37
%50 = load i64, i64* %6
%51 = add i64 %50, 1
store i64 %51, i64* %6
br label %18
52: ; preds = %18
%53 = load double, double* %5
%54 = load i64, i64* %4
%55 = uitofp i64 %54 to double
%56 = fdiv double %53, %55
%57 = call double @exp2(double %56)
store double %57, double* %7
%58 = load i32, i32* @FE_INVALID
%59 = load i32, i32* @FE_DIVBYZERO
%60 = or i32 %58, %59
%61 = load i32, i32* @FE_OVERFLOW
%62 = or i32 %60, %61
%63 = load i32, i32* @FE_UNDERFLOW
%64 = or i32 %62, %63
%65 = call i32 @fetestexcept(i32 %64)
%66 = icmp ne i32 %65, 0
%67 = xor i1 %66, true
%68 = zext i1 %67 to i32
%69 = call i32 @assert(i32 %68)
%70 = load double, double* %7
ret double %70
}

LLVM IR (-O2):
@FE_ALL_EXCEPT = global i32 0
@FE_INVALID = global i32 0
@FE_DIVBYZERO = global i32 0
@FE_OVERFLOW = global i32 0
@FE_UNDERFLOW = global i32 0
define double @geom_mean_log(double* %0, i64 %1) {
%3 = icmp ne double* %0, null
%4 = zext i1 %3 to i32
%5 = tail call i32 @assert(i32 %4)
%6 = load i32, i32* @FE_ALL_EXCEPT
%7 = tail call i32 @feclearexcept(i32 %6)
%8 = icmp eq i32 %7, 0
%9 = zext i1 %8 to i32
%10 = tail call i32 @assert(i32 %9)
%11 = icmp eq i64 %1, 0
br i1 %11, label %12, label %28
12: ; preds = %39, %2
%13 = phi double [ 0.000000e+00, %2 ], [ %46, %39 ]
%14 = uitofp i64 %1 to double
%15 = fdiv double %13, %14
%16 = tail call double @exp2(double %15)
%17 = load i32, i32* @FE_INVALID
%18 = load i32, i32* @FE_DIVBYZERO
%19 = or i32 %18, %17
%20 = load i32, i32* @FE_OVERFLOW
%21 = or i32 %19, %20
%22 = load i32, i32* @FE_UNDERFLOW
%23 = or i32 %21, %22
%24 = tail call i32 @fetestexcept(i32 %23)
%25 = icmp eq i32 %24, 0
%26 = zext i1 %25 to i32
%27 = tail call i32 @assert(i32 %26)
ret double %16
28: ; preds = %2, %39
%29 = phi double [ %46, %39 ], [ 0.000000e+00, %2 ]
%30 = phi i64 [ %47, %39 ], [ 0, %2 ]
%31 = getelementptr inbounds double, double* %0, i64 %30
%32 = load double, double* %31
%33 = tail call i32 @isnan(double %32)
%34 = icmp eq i32 %33, 0
br i1 %34, label %35, label %39
35: ; preds = %28
%36 = load double, double* %31
%37 = tail call i32 @islessequal(double %36, double 0.000000e+00)
%38 = icmp eq i32 %37, 0
br label %39
39: ; preds = %35, %28
%40 = phi i1 [ false, %28 ], [ %38, %35 ]
%41 = zext i1 %40 to i32
%42 = tail call i32 @assert(i32 %41)
%43 = load double, double* %31
%44 = tail call i64 @log2(double %43)
%45 = sitofp i64 %44 to double
%46 = fadd double %29, %45
%47 = add nuw i64 %30, 1
%48 = icmp eq i64 %47, %1
br i1 %48, label %12, label %28
}