#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 */
long exp(scalar_t__);
double hermite(long, double);
scalar_t__ logfac(long);
void hermite_weight(long n, double *hroot, double *weights) {
  long i;
  double hr2;
  double numerator;
  numerator = exp(0.6931471805599 * (n - 1.) + logfac(n)) / (n * n);
  for (i = 0; i < n; i++) {
    hr2 = hermite(n - 1, hroot[i]);
    weights[i] = numerator / (hr2 * hr2);
  }
}


x86 assembly (clang, -O0):
<hermite_weight>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
cvtsi2sdq -0x8(%rbp),%xmm0
movsd  0xeb6(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <logfac@plt>
movsd  -0x38(%rbp),%xmm0
cvtsi2sd %rax,%xmm1
movsd  0xe8a(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rdi
call   1040 <exp@plt>
mov    -0x8(%rbp),%rcx
imul   -0x8(%rbp),%rcx
cqto
idiv   %rcx
cvtsi2sd %rax,%xmm0
movsd  %xmm0,-0x30(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x8(%rbp),%rax
jge    1206 <hermite_weight+0xd6>
mov    -0x8(%rbp),%rdi
sub    $0x1,%rdi
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
call   1030 <hermite@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
mulsd  -0x28(%rbp),%xmm1
divsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    11a8 <hermite_weight+0x78>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hermite_weight>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%r12
cvtsi2sd %rdi,%xmm0
addsd  0xead(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
call   1050 <logfac@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  0x8(%rsp),%xmm1
mulsd  0xe94(%rip),%xmm1
addsd  %xmm0,%xmm1
cvttsd2si %xmm1,%rdi
call   1040 <exp@plt>
mov    %r12,%rcx
imul   %r12,%rcx
mov    %rax,%rdx
or     %rcx,%rdx
shr    $0x20,%rdx
je     11a1 <hermite_weight+0x71>
cqto
idiv   %rcx
test   %r12,%r12
jg     11aa <hermite_weight+0x7a>
jmp    11eb <hermite_weight+0xbb>
xor    %edx,%edx
div    %ecx
test   %r12,%r12
jle    11eb <hermite_weight+0xbb>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  %xmm0,0x8(%rsp)
lea    -0x1(%r12),%r13
xor    %ebx,%ebx
nop
movsd  (%r15,%rbx,8),%xmm0
mov    %r13,%rdi
call   1030 <hermite@plt>
mulsd  %xmm0,%xmm0
movsd  0x8(%rsp),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,(%r14,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%r12
jne    11c0 <hermite_weight+0x90>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @hermite_weight(i64 %0, double* %1, double* %2) {
%4 = alloca i64
%5 = alloca double*
%6 = alloca double*
%7 = alloca i64
%8 = alloca double
%9 = alloca double
store i64 %0, i64* %4
store double* %1, double** %5
store double* %2, double** %6
%10 = load i64, i64* %4
%11 = sitofp i64 %10 to double
%12 = fsub double %11, 1.000000e+00
%13 = load i64, i64* %4
%14 = call i64 @logfac(i64 %13)
%15 = sitofp i64 %14 to double
%16 = call double @llvm.fmuladd.f64(double 0x3FE62E42FEFA3857, double %12, double %15)
%17 = fptosi double %16 to i64
%18 = call i64 @exp(i64 %17)
%19 = load i64, i64* %4
%20 = load i64, i64* %4
%21 = mul nsw i64 %19, %20
%22 = sdiv i64 %18, %21
%23 = sitofp i64 %22 to double
store double %23, double* %9
store i64 0, i64* %7
br label %24
24: ; preds = %44, %3
%25 = load i64, i64* %7
%26 = load i64, i64* %4
%27 = icmp slt i64 %25, %26
br i1 %27, label %28, label %47
28: ; preds = %24
%29 = load i64, i64* %4
%30 = sub nsw i64 %29, 1
%31 = load double*, double** %5
%32 = load i64, i64* %7
%33 = getelementptr inbounds double, double* %31, i64 %32
%34 = load double, double* %33
%35 = call double @hermite(i64 %30, double %34)
store double %35, double* %8
%36 = load double, double* %9
%37 = load double, double* %8
%38 = load double, double* %8
%39 = fmul double %37, %38
%40 = fdiv double %36, %39
%41 = load double*, double** %6
%42 = load i64, i64* %7
%43 = getelementptr inbounds double, double* %41, i64 %42
store double %40, double* %43
br label %44
44: ; preds = %28
%45 = load i64, i64* %7
%46 = add nsw i64 %45, 1
store i64 %46, i64* %7
br label %24
47: ; preds = %24
ret void
}

LLVM IR (-O2):
define void @hermite_weight(i64 %0, double* nocapture %1, double* nocapture writeonly %2) {
%4 = sitofp i64 %0 to double
%5 = fadd double %4, -1.000000e+00
%6 = tail call i64 @logfac(i64 %0)
%7 = sitofp i64 %6 to double
%8 = tail call double @llvm.fmuladd.f64(double %5, double 0x3FE62E42FEFA3857, double %7)
%9 = fptosi double %8 to i64
%10 = tail call i64 @exp(i64 %9)
%11 = mul nsw i64 %0, %0
%12 = sdiv i64 %10, %11
%13 = sitofp i64 %12 to double
%14 = icmp sgt i64 %0, 0
br i1 %14, label %15, label %27
15: ; preds = %3
%16 = add nsw i64 %0, -1
br label %17
17: ; preds = %15, %17
%18 = phi i64 [ 0, %15 ], [ %25, %17 ]
%19 = getelementptr inbounds double, double* %1, i64 %18
%20 = load double, double* %19
%21 = tail call double @hermite(i64 %16, double %20)
%22 = fmul double %21, %21
%23 = fdiv double %13, %22
%24 = getelementptr inbounds double, double* %2, i64 %18
store double %23, double* %24
%25 = add nuw nsw i64 %18, 1
%26 = icmp eq i64 %25, %0
br i1 %26, label %27, label %17
27: ; preds = %17, %3
ret void
}