#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 fact(long);
double pow(double, long);
double Bernstein(long i, long n, double u) {
  return ((double)fact(n) / (fact(i) * fact(n - i))) * pow(u, i) *
         pow(1.0 - u, n - i);
}


x86 assembly (clang, -O0):
<Bernstein>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <fact@plt>
movsd  %xmm0,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <fact@plt>
movsd  %xmm0,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
sub    -0x8(%rbp),%rdi
call   1030 <fact@plt>
movsd  -0x38(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x30(%rbp),%xmm0
mulsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x18(%rbp),%xmm0
mov    -0x8(%rbp),%rdi
call   1040 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xe61(%rip),%xmm0
subsd  -0x18(%rbp),%xmm0
mov    -0x10(%rbp),%rdi
sub    -0x8(%rbp),%rdi
call   1040 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x20(%rbp),%xmm0
mulsd  %xmm1,%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Bernstein>:
push   %r14
push   %rbx
sub    $0x18,%rsp
movsd  %xmm0,0x8(%rsp)
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rsi,%rdi
call   1030 <fact@plt>
movsd  %xmm0,(%rsp)
mov    %r14,%rdi
call   1030 <fact@plt>
movsd  %xmm0,0x10(%rsp)
sub    %r14,%rbx
mov    %rbx,%rdi
call   1030 <fact@plt>
mulsd  0x10(%rsp),%xmm0
movsd  (%rsp),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
movsd  0x8(%rsp),%xmm0
mov    %r14,%rdi
call   1040 <pow@plt>
mulsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  0xe73(%rip),%xmm0
subsd  0x8(%rsp),%xmm0
mov    %rbx,%rdi
call   1040 <pow@plt>
mulsd  (%rsp),%xmm0
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define double @Bernstein(i64 %0, i64 %1, double %2) {
%4 = alloca i64
%5 = alloca i64
%6 = alloca double
store i64 %0, i64* %4
store i64 %1, i64* %5
store double %2, double* %6
%7 = load i64, i64* %5
%8 = call double @fact(i64 %7)
%9 = load i64, i64* %4
%10 = call double @fact(i64 %9)
%11 = load i64, i64* %5
%12 = load i64, i64* %4
%13 = sub nsw i64 %11, %12
%14 = call double @fact(i64 %13)
%15 = fmul double %10, %14
%16 = fdiv double %8, %15
%17 = load double, double* %6
%18 = load i64, i64* %4
%19 = call double @pow(double %17, i64 %18)
%20 = fmul double %16, %19
%21 = load double, double* %6
%22 = fsub double 1.000000e+00, %21
%23 = load i64, i64* %5
%24 = load i64, i64* %4
%25 = sub nsw i64 %23, %24
%26 = call double @pow(double %22, i64 %25)
%27 = fmul double %20, %26
ret double %27
}

LLVM IR (-O2):
define double @Bernstein(i64 %0, i64 %1, double %2) {
%4 = tail call double @fact(i64 %1)
%5 = tail call double @fact(i64 %0)
%6 = sub nsw i64 %1, %0
%7 = tail call double @fact(i64 %6)
%8 = fmul double %5, %7
%9 = fdiv double %4, %8
%10 = tail call double @pow(double %2, i64 %0)
%11 = fmul double %10, %9
%12 = fsub double 1.000000e+00, %2
%13 = tail call double @pow(double %12, i64 %6)
%14 = fmul double %13, %11
ret double %14
}