#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 binomial_coefficient(int, int);
int /*<<< orphan*/ initialize_array(double *, int);
double internal_pow(double, int);
void binomial(int degree, double delta, double out[]) {
  initialize_array(out, 3);
  int i;
  for (i = 0; i <= degree; i++) {
    out[degree - i] =
        binomial_coefficient(degree, i) * internal_pow(delta, degree - i);
  }
}


x86 assembly (clang, -O0):
<binomial>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
movsd  %xmm0,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    $0x3,%esi
call   1050 <initialize_array@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     11b1 <binomial+0x81>
mov    -0x4(%rbp),%edi
mov    -0x1c(%rbp),%esi
call   1040 <binomial_coefficient@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm0
mov    -0x4(%rbp),%edi
sub    -0x1c(%rbp),%edi
call   1030 <internal_pow@plt>
movaps %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
mov    -0x4(%rbp),%ecx
sub    -0x1c(%rbp),%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1159 <binomial+0x29>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<binomial>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r14
movsd  %xmm0,(%rsp)
mov    %edi,%r15d
mov    %rsi,%rdi
mov    $0x3,%esi
call   1050 <initialize_array@plt>
test   %r15d,%r15d
js     11a6 <binomial+0x76>
mov    %r15d,%r12d
lea    0x1(%r15),%r13d
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r15d,%edi
mov    %ebx,%esi
call   1040 <binomial_coefficient@plt>
movsd  %xmm0,0x8(%rsp)
movsd  (%rsp),%xmm0
mov    %r12d,%edi
call   1030 <internal_pow@plt>
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,(%r14,%r12,8)
add    $0x1,%rbx
add    $0xffffffffffffffff,%r12
cmp    %rbx,%r13
jne    1170 <binomial+0x40>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @binomial(i32 %0, double %1, double* %2) {
%4 = alloca i32
%5 = alloca double
%6 = alloca double*
%7 = alloca i32
store i32 %0, i32* %4
store double %1, double* %5
store double* %2, double** %6
%8 = load double*, double** %6
%9 = call i32 @initialize_array(double* %8, i32 3)
store i32 0, i32* %7
br label %10
10: ; preds = %30, %3
%11 = load i32, i32* %7
%12 = load i32, i32* %4
%13 = icmp sle i32 %11, %12
br i1 %13, label %14, label %33
14: ; preds = %10
%15 = load i32, i32* %4
%16 = load i32, i32* %7
%17 = call double @binomial_coefficient(i32 %15, i32 %16)
%18 = load double, double* %5
%19 = load i32, i32* %4
%20 = load i32, i32* %7
%21 = sub nsw i32 %19, %20
%22 = call double @internal_pow(double %18, i32 %21)
%23 = fmul double %17, %22
%24 = load double*, double** %6
%25 = load i32, i32* %4
%26 = load i32, i32* %7
%27 = sub nsw i32 %25, %26
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds double, double* %24, i64 %28
store double %23, double* %29
br label %30
30: ; preds = %14
%31 = load i32, i32* %7
%32 = add nsw i32 %31, 1
store i32 %32, i32* %7
br label %10
33: ; preds = %10
ret void
}

LLVM IR (-O2):
define void @binomial(i32 %0, double %1, double* %2) {
%4 = tail call i32 @initialize_array(double* %2, i32 3)
%5 = icmp slt i32 %0, 0
br i1 %5, label %21, label %6
6: ; preds = %3
%7 = zext i32 %0 to i64
%8 = add nuw i32 %0, 1
%9 = zext i32 %8 to i64
br label %10
10: ; preds = %6, %10
%11 = phi i64 [ 0, %6 ], [ %19, %10 ]
%12 = trunc i64 %11 to i32
%13 = tail call double @binomial_coefficient(i32 %0, i32 %12)
%14 = sub nsw i64 %7, %11
%15 = trunc i64 %14 to i32
%16 = tail call double @internal_pow(double %1, i32 %15)
%17 = fmul double %13, %16
%18 = getelementptr inbounds double, double* %2, i64 %14
store double %17, double* %18
%19 = add nuw nsw i64 %11, 1
%20 = icmp eq i64 %19, %9
br i1 %20, label %21, label %10
21: ; preds = %10, %3
ret void
}