#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 dot(double *, double *, int);
double pow(double, int);
int prod(double *, int);
int surface_area_sphere(int);
double acgpdf_pcs(double *x, double *z, double **V, int d) {
  int i;
  double p = 1 / (prod(z, d) * surface_area_sphere(d - 1));
  double xv, md = 0;
  for (i = 0; i < d; i++) {
    xv = dot(x, V[i], d) / z[i];
    md += xv * xv;
  }
  p *= pow(md, -d / 2);
  return p;
}


x86 assembly (clang, -O0):
<acgpdf_pcs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1060 <prod@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x1c(%rbp),%edi
sub    $0x1,%edi
call   1040 <surface_area_sphere@plt>
mov    -0x3c(%rbp),%ecx
imul   %eax,%ecx
mov    $0x1,%eax
cltd
idiv   %ecx
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x28(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11f7 <acgpdf_pcs+0xb7>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
mov    -0x1c(%rbp),%edx
call   1030 <dot@plt>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
divsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm2
movsd  -0x38(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1197 <acgpdf_pcs+0x57>
movsd  -0x38(%rbp),%xmm0
xor    %eax,%eax
sub    -0x1c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
call   1050 <pow@plt>
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<acgpdf_pcs>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %ecx,%r15d
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%r12
mov    %rsi,%rdi
mov    %ecx,%esi
call   1060 <prod@plt>
mov    %eax,%ebp
lea    -0x1(%r15),%edi
call   1040 <surface_area_sphere@plt>
imul   %ebp,%eax
mov    %rax,0x10(%rsp)
test   %r15d,%r15d
jle    11d0 <acgpdf_pcs+0x90>
mov    %r15d,%ebp
xorpd  %xmm0,%xmm0
xor    %r13d,%r13d
cs nopw 0x0(%rax,%rax,1)
movsd  %xmm0,0x8(%rsp)
mov    (%r14,%r13,8),%rsi
mov    %r12,%rdi
mov    %r15d,%edx
call   1030 <dot@plt>
divsd  (%rbx,%r13,8),%xmm0
mulsd  %xmm0,%xmm0
movsd  0x8(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
movsd  0x8(%rsp),%xmm0
add    $0x1,%r13
cmp    %r13,%rbp
jne    1190 <acgpdf_pcs+0x50>
jmp    11d4 <acgpdf_pcs+0x94>
xorpd  %xmm0,%xmm0
mov    0x10(%rsp),%rdx
lea    0x1(%rdx),%eax
xor    %ecx,%ecx
cmp    $0x3,%eax
cmovb  %edx,%ecx
xorps  %xmm1,%xmm1
cvtsi2sd %ecx,%xmm1
movsd  %xmm1,0x8(%rsp)
mov    %r15d,%edi
shr    $0x1f,%edi
add    %r15d,%edi
sar    %edi
neg    %edi
call   1050 <pow@plt>
mulsd  0x8(%rsp),%xmm0
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define double @acgpdf_pcs(double* %0, double* %1, double** %2, i32 %3) {
%5 = alloca double*
%6 = alloca double*
%7 = alloca double**
%8 = alloca i32
%9 = alloca i32
%10 = alloca double
%11 = alloca double
%12 = alloca double
store double* %0, double** %5
store double* %1, double** %6
store double** %2, double*** %7
store i32 %3, i32* %8
%13 = load double*, double** %6
%14 = load i32, i32* %8
%15 = call i32 @prod(double* %13, i32 %14)
%16 = load i32, i32* %8
%17 = sub nsw i32 %16, 1
%18 = call i32 @surface_area_sphere(i32 %17)
%19 = mul nsw i32 %15, %18
%20 = sdiv i32 1, %19
%21 = sitofp i32 %20 to double
store double %21, double* %10
store double 0.000000e+00, double* %12
store i32 0, i32* %9
br label %22
22: ; preds = %45, %4
%23 = load i32, i32* %9
%24 = load i32, i32* %8
%25 = icmp slt i32 %23, %24
br i1 %25, label %26, label %48
26: ; preds = %22
%27 = load double*, double** %5
%28 = load double**, double*** %7
%29 = load i32, i32* %9
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds double*, double** %28, i64 %30
%32 = load double*, double** %31
%33 = load i32, i32* %8
%34 = call double @dot(double* %27, double* %32, i32 %33)
%35 = load double*, double** %6
%36 = load i32, i32* %9
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds double, double* %35, i64 %37
%39 = load double, double* %38
%40 = fdiv double %34, %39
store double %40, double* %11
%41 = load double, double* %11
%42 = load double, double* %11
%43 = load double, double* %12
%44 = call double @llvm.fmuladd.f64(double %41, double %42, double %43)
store double %44, double* %12
br label %45
45: ; preds = %26
%46 = load i32, i32* %9
%47 = add nsw i32 %46, 1
store i32 %47, i32* %9
br label %22
48: ; preds = %22
%49 = load double, double* %12
%50 = load i32, i32* %8
%51 = sub nsw i32 0, %50
%52 = sdiv i32 %51, 2
%53 = call double @pow(double %49, i32 %52)
%54 = load double, double* %10
%55 = fmul double %54, %53
store double %55, double* %10
%56 = load double, double* %10
ret double %56
}

LLVM IR (-O2):
define double @acgpdf_pcs(double* %0, double* %1, double** nocapture %2, i32 %3) {
%5 = tail call i32 @prod(double* %1, i32 %3)
%6 = add nsw i32 %3, -1
%7 = tail call i32 @surface_area_sphere(i32 %6)
%8 = mul nsw i32 %7, %5
%9 = icmp sgt i32 %3, 0
br i1 %9, label %10, label %24
10: ; preds = %4
%11 = zext i32 %3 to i64
br label %12
12: ; preds = %10, %12
%13 = phi i64 [ 0, %10 ], [ %22, %12 ]
%14 = phi double [ 0.000000e+00, %10 ], [ %21, %12 ]
%15 = getelementptr inbounds double*, double** %2, i64 %13
%16 = load double*, double** %15
%17 = tail call double @dot(double* %0, double* %16, i32 %3)
%18 = getelementptr inbounds double, double* %1, i64 %13
%19 = load double, double* %18
%20 = fdiv double %17, %19
%21 = tail call double @llvm.fmuladd.f64(double %20, double %20, double %14)
%22 = add nuw nsw i64 %13, 1
%23 = icmp eq i64 %22, %11
br i1 %23, label %24, label %12
24: ; preds = %12, %4
%25 = phi double [ 0.000000e+00, %4 ], [ %21, %12 ]
%26 = add i32 %8, 1
%27 = icmp ult i32 %26, 3
%28 = select i1 %27, i32 %8, i32 0
%29 = sitofp i32 %28 to double
%30 = sdiv i32 %3, -2
%31 = tail call double @pow(double %25, i32 %30)
%32 = fmul double %31, %29
ret double %32
}