#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 */
double pow(double const, double);
double geom_mean_pow(const double *x, const size_t count) {
  double res = 1.0;
  double factor = 1.0 / count;
  for (int i = 0; i < count; i++) {
    res *= pow(x[i], factor);
  }
  return res;
}


x86 assembly (clang, -O0):
<geom_mean_pow>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movabs $0x3ff0000000000000,%rax
mov    %rax,-0x18(%rbp)
movaps 0xedb(%rip),%xmm0
movq   -0x10(%rbp),%xmm1
punpckldq %xmm0,%xmm1
movapd 0xeda(%rip),%xmm0
subpd  %xmm0,%xmm1
movaps %xmm1,%xmm0
unpckhpd %xmm1,%xmm1
addsd  %xmm0,%xmm1
movsd  0xea3(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movslq -0x24(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    11aa <geom_mean_pow+0x9a>
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  -0x20(%rbp),%xmm1
call   1030 <pow@plt>
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    116d <geom_mean_pow+0x5d>
movsd  -0x18(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<geom_mean_pow>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
movsd  0xefd(%rip),%xmm2
test   %rsi,%rsi
je     125a <geom_mean_pow+0x14a>
mov    %rsi,%r14
mov    %rdi,%r12
movq   %rsi,%xmm0
punpckldq 0xec1(%rip),%xmm0
subpd  0xec9(%rip),%xmm0
movapd %xmm0,%xmm1
unpckhpd %xmm0,%xmm1
addsd  %xmm0,%xmm1
divsd  %xmm1,%xmm2
movapd %xmm2,%xmm0
lea    -0x1(%rsi),%rax
mov    %r14d,%r15d
and    $0x3,%r15d
cmp    $0x3,%rax
movsd  %xmm2,0x10(%rsp)
jae    1181 <geom_mean_pow+0x71>
movsd  0xea6(%rip),%xmm2
xor    %ebx,%ebx
jmp    1218 <geom_mean_pow+0x108>
and    $0xfffffffffffffffc,%r14
movsd  0xe93(%rip),%xmm2
xor    %ebx,%ebx
nop
movsd  %xmm2,0x8(%rsp)
movsd  (%r12,%rbx,8),%xmm0
movsd  0x10(%rsp),%xmm1
call   1030 <pow@plt>
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x8(%r12,%rbx,8),%xmm0
movsd  0x10(%rsp),%xmm1
call   1030 <pow@plt>
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x10(%r12,%rbx,8),%xmm0
movsd  0x10(%rsp),%xmm1
call   1030 <pow@plt>
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x18(%r12,%rbx,8),%xmm0
movsd  0x10(%rsp),%xmm1
call   1030 <pow@plt>
movapd %xmm0,%xmm2
mulsd  0x8(%rsp),%xmm2
add    $0x4,%rbx
cmp    %rbx,%r14
jne    1190 <geom_mean_pow+0x80>
test   %r15,%r15
je     125a <geom_mean_pow+0x14a>
lea    (%r12,%rbx,8),%r14
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsd  %xmm2,0x8(%rsp)
movsd  (%r14,%rbx,8),%xmm0
movsd  0x10(%rsp),%xmm1
call   1030 <pow@plt>
movsd  0x8(%rsp),%xmm2
mulsd  %xmm0,%xmm2
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1230 <geom_mean_pow+0x120>
movapd %xmm2,%xmm0
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define double @geom_mean_pow(double* %0, i64 %1) {
%3 = alloca double*
%4 = alloca i64
%5 = alloca double
%6 = alloca double
%7 = alloca i32
store double* %0, double** %3
store i64 %1, i64* %4
store double 1.000000e+00, double* %5
%8 = load i64, i64* %4
%9 = uitofp i64 %8 to double
%10 = fdiv double 1.000000e+00, %9
store double %10, double* %6
store i32 0, i32* %7
br label %11
11: ; preds = %26, %2
%12 = load i32, i32* %7
%13 = sext i32 %12 to i64
%14 = load i64, i64* %4
%15 = icmp ult i64 %13, %14
br i1 %15, label %16, label %29
16: ; preds = %11
%17 = load double*, double** %3
%18 = load i32, i32* %7
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds double, double* %17, i64 %19
%21 = load double, double* %20
%22 = load double, double* %6
%23 = call double @pow(double %21, double %22)
%24 = load double, double* %5
%25 = fmul double %24, %23
store double %25, double* %5
br label %26
26: ; preds = %16
%27 = load i32, i32* %7
%28 = add nsw i32 %27, 1
store i32 %28, i32* %7
br label %11
29: ; preds = %11
%30 = load double, double* %5
ret double %30
}

LLVM IR (-O2):
define double @geom_mean_pow(double* nocapture %0, i64 %1) {
%3 = uitofp i64 %1 to double
%4 = fdiv double 1.000000e+00, %3
%5 = icmp eq i64 %1, 0
br i1 %5, label %28, label %6
6: ; preds = %2
%7 = add i64 %1, -1
%8 = and i64 %1, 3
%9 = icmp ult i64 %7, 3
br i1 %9, label %12, label %10
10: ; preds = %6
%11 = and i64 %1, -4
br label %30
12: ; preds = %30, %6
%13 = phi double [ undef, %6 ], [ %52, %30 ]
%14 = phi i64 [ 0, %6 ], [ %53, %30 ]
%15 = phi double [ 1.000000e+00, %6 ], [ %52, %30 ]
%16 = icmp eq i64 %8, 0
br i1 %16, label %28, label %17
17: ; preds = %12, %17
%18 = phi i64 [ %25, %17 ], [ %14, %12 ]
%19 = phi double [ %24, %17 ], [ %15, %12 ]
%20 = phi i64 [ %26, %17 ], [ 0, %12 ]
%21 = getelementptr inbounds double, double* %0, i64 %18
%22 = load double, double* %21
%23 = tail call double @pow(double %22, double %4)
%24 = fmul double %19, %23
%25 = add nuw nsw i64 %18, 1
%26 = add i64 %20, 1
%27 = icmp eq i64 %26, %8
br i1 %27, label %28, label %17
28: ; preds = %12, %17, %2
%29 = phi double [ 1.000000e+00, %2 ], [ %13, %12 ], [ %24, %17 ]
ret double %29
30: ; preds = %30, %10
%31 = phi i64 [ 0, %10 ], [ %53, %30 ]
%32 = phi double [ 1.000000e+00, %10 ], [ %52, %30 ]
%33 = phi i64 [ 0, %10 ], [ %54, %30 ]
%34 = getelementptr inbounds double, double* %0, i64 %31
%35 = load double, double* %34
%36 = tail call double @pow(double %35, double %4)
%37 = fmul double %32, %36
%38 = or i64 %31, 1
%39 = getelementptr inbounds double, double* %0, i64 %38
%40 = load double, double* %39
%41 = tail call double @pow(double %40, double %4)
%42 = fmul double %37, %41
%43 = or i64 %31, 2
%44 = getelementptr inbounds double, double* %0, i64 %43
%45 = load double, double* %44
%46 = tail call double @pow(double %45, double %4)
%47 = fmul double %42, %46
%48 = or i64 %31, 3
%49 = getelementptr inbounds double, double* %0, i64 %48
%50 = load double, double* %49
%51 = tail call double @pow(double %50, double %4)
%52 = fmul double %47, %51
%53 = add nuw nsw i64 %31, 4
%54 = add i64 %33, 4
%55 = icmp eq i64 %54, %11
br i1 %55, label %12, label %30
}