#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 *gp_alloc(int, char *);
double log(double);
double *cp_binomial(int points) {
  double *coeff;
  int n, k;
  int e;
  e = points;
  coeff = gp_alloc(e * sizeof(double), "bezier coefficients");
  n = points - 1;
  e = n / 2;
  coeff[0] = 0.0;
  for (k = 0; k < e; k++) {
    coeff[k + 1] = coeff[k] + log(((double)(n - k)) / ((double)(k + 1)));
  }
  for (k = n; k >= e; k--)
    coeff[k] = coeff[n - k];
  return (coeff);
}


x86 assembly (clang, -O0):
<cp_binomial>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x1c(%rbp)
movslq -0x1c(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
lea    0xebe(%rip),%rsi
call   1030 <gp_alloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x4(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11db <cp_binomial+0xbb>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x14(%rbp),%eax
sub    -0x18(%rbp),%eax
cvtsi2sd %eax,%xmm0
mov    -0x18(%rbp),%eax
add    $0x1,%eax
cvtsi2sd %eax,%xmm1
divsd  %xmm1,%xmm0
call   1040 <log@plt>
movaps %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
addsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1174 <cp_binomial+0x54>
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jl     121a <cp_binomial+0xfa>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
sub    -0x18(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x18(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x18(%rbp)
jmp    11e1 <cp_binomial+0xc1>
mov    -0x10(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cp_binomial>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %edi,%r14d
lea    0x0(,%r14,8),%edi
lea    0xec0(%rip),%rsi
call   1030 <gp_alloc@plt>
mov    %rax,%rbx
lea    -0x1(%r14),%eax
mov    %eax,0xc(%rsp)
shr    $0x1f,%eax
lea    (%r14,%rax,1),%r12d
add    $0xffffffff,%r12d
sar    %r12d
movq   $0x0,(%rbx)
cmp    $0x3,%r14d
jl     11e2 <cp_binomial+0xc2>
cmp    $0x2,%r12d
mov    $0x1,%r13d
cmovge %r12d,%r13d
neg    %r13
xorps  %xmm0,%xmm0
mov    $0x1,%ebp
mov    0xc(%rsp),%r15d
nopl   0x0(%rax)
movsd  %xmm0,0x10(%rsp)
xorps  %xmm0,%xmm0
cvtsi2sd %r15d,%xmm0
xorps  %xmm1,%xmm1
cvtsi2sd %ebp,%xmm1
divsd  %xmm1,%xmm0
call   1040 <log@plt>
movsd  0x10(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x10(%rsp)
movsd  0x10(%rsp),%xmm0
movsd  %xmm0,(%rbx,%rbp,8)
add    $0xffffffff,%r15d
lea    0x1(,%rbp,1),%rax
add    %r13,%rax
add    $0x1,%rbp
cmp    $0x1,%rax
jne    1190 <cp_binomial+0x70>
cmp    %r14d,%r12d
jge    1288 <cp_binomial+0x168>
movslq %r14d,%rax
movslq 0xc(%rsp),%r8
movslq %r12d,%rcx
sub    %r12d,%r14d
mov    %rcx,%rsi
not    %rsi
add    %rax,%rsi
and    $0x3,%r14
je     1239 <cp_binomial+0x119>
lea    (%rbx,%rax,8),%rdi
add    $0xfffffffffffffff8,%rdi
mov    %r8,%rdx
sub    %rax,%rdx
lea    (%rbx,%rdx,8),%rdx
add    $0x8,%rdx
xor    %ebp,%ebp
movsd  (%rdx,%rbp,8),%xmm0
movsd  %xmm0,(%rdi)
add    $0x1,%rbp
add    $0xfffffffffffffff8,%rdi
cmp    %rbp,%r14
jne    1220 <cp_binomial+0x100>
sub    %rbp,%rax
cmp    $0x3,%rsi
jb     1288 <cp_binomial+0x168>
sub    %rax,%r8
lea    (%rbx,%r8,8),%rdx
add    $0x20,%rdx
nopw   0x0(%rax,%rax,1)
movsd  -0x18(%rdx),%xmm0
movsd  %xmm0,-0x8(%rbx,%rax,8)
movsd  -0x10(%rdx),%xmm0
movsd  %xmm0,-0x10(%rbx,%rax,8)
movsd  -0x8(%rdx),%xmm0
movsd  %xmm0,-0x18(%rbx,%rax,8)
movsd  (%rdx),%xmm0
movsd  %xmm0,-0x20(%rbx,%rax,8)
add    $0xfffffffffffffffc,%rax
add    $0x20,%rdx
cmp    %rcx,%rax
jg     1250 <cp_binomial+0x130>
mov    %rbx,%rax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [20 x i8] c"bezier coefficients\00"
define double* @cp_binomial(i32 %0) {
%2 = alloca i32
%3 = alloca double*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %2
%7 = load i32, i32* %2
store i32 %7, i32* %6
%8 = load i32, i32* %6
%9 = sext i32 %8 to i64
%10 = mul i64 %9, 8
%11 = trunc i64 %10 to i32
%12 = call double* @gp_alloc(i32 %11, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
store double* %12, double** %3
%13 = load i32, i32* %2
%14 = sub nsw i32 %13, 1
store i32 %14, i32* %4
%15 = load i32, i32* %4
%16 = sdiv i32 %15, 2
store i32 %16, i32* %6
%17 = load double*, double** %3
%18 = getelementptr inbounds double, double* %17, i64 0
store double 0.000000e+00, double* %18
store i32 0, i32* %5
br label %19
19: ; preds = %44, %1
%20 = load i32, i32* %5
%21 = load i32, i32* %6
%22 = icmp slt i32 %20, %21
br i1 %22, label %23, label %47
23: ; preds = %19
%24 = load double*, double** %3
%25 = load i32, i32* %5
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds double, double* %24, i64 %26
%28 = load double, double* %27
%29 = load i32, i32* %4
%30 = load i32, i32* %5
%31 = sub nsw i32 %29, %30
%32 = sitofp i32 %31 to double
%33 = load i32, i32* %5
%34 = add nsw i32 %33, 1
%35 = sitofp i32 %34 to double
%36 = fdiv double %32, %35
%37 = call double @log(double %36)
%38 = fadd double %28, %37
%39 = load double*, double** %3
%40 = load i32, i32* %5
%41 = add nsw i32 %40, 1
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds double, double* %39, i64 %42
store double %38, double* %43
br label %44
44: ; preds = %23
%45 = load i32, i32* %5
%46 = add nsw i32 %45, 1
store i32 %46, i32* %5
br label %19
47: ; preds = %19
%48 = load i32, i32* %4
store i32 %48, i32* %5
br label %49
49: ; preds = %65, %47
%50 = load i32, i32* %5
%51 = load i32, i32* %6
%52 = icmp sge i32 %50, %51
br i1 %52, label %53, label %68
53: ; preds = %49
%54 = load double*, double** %3
%55 = load i32, i32* %4
%56 = load i32, i32* %5
%57 = sub nsw i32 %55, %56
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds double, double* %54, i64 %58
%60 = load double, double* %59
%61 = load double*, double** %3
%62 = load i32, i32* %5
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds double, double* %61, i64 %63
store double %60, double* %64
br label %65
65: ; preds = %53
%66 = load i32, i32* %5
%67 = add nsw i32 %66, -1
store i32 %67, i32* %5
br label %49
68: ; preds = %49
%69 = load double*, double** %3
ret double* %69
}

LLVM IR (-O2):
@.str = [20 x i8] c"bezier coefficients\00"
define double* @cp_binomial(i32 %0) {
%2 = shl i32 %0, 3
%3 = tail call double* @gp_alloc(i32 %2, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%4 = add nsw i32 %0, -1
%5 = sdiv i32 %4, 2
store double 0.000000e+00, double* %3
%6 = icmp sgt i32 %0, 2
br i1 %6, label %7, label %10
7: ; preds = %1
%8 = call i32 @llvm.smax.i32(i32 %5, i32 1)
%9 = zext i32 %8 to i64
br label %34
10: ; preds = %34, %1
%11 = icmp slt i32 %5, %0
br i1 %11, label %12, label %71
12: ; preds = %10
%13 = sext i32 %0 to i64
%14 = sext i32 %4 to i64
%15 = sext i32 %5 to i64
%16 = sub nsw i64 %13, %15
%17 = xor i64 %15, -1
%18 = add nsw i64 %17, %13
%19 = and i64 %16, 3
%20 = icmp eq i64 %19, 0
br i1 %20, label %31, label %21
21: ; preds = %12, %21
%22 = phi i64 [ %24, %21 ], [ %13, %12 ]
%23 = phi i64 [ %29, %21 ], [ 0, %12 ]
%24 = add nsw i64 %22, -1
%25 = sub nsw i64 %14, %24
%26 = getelementptr inbounds double, double* %3, i64 %25
%27 = load double, double* %26
%28 = getelementptr inbounds double, double* %3, i64 %24
store double %27, double* %28
%29 = add i64 %23, 1
%30 = icmp eq i64 %29, %19
br i1 %30, label %31, label %21
31: ; preds = %21, %12
%32 = phi i64 [ %13, %12 ], [ %24, %21 ]
%33 = icmp ult i64 %18, 3
br i1 %33, label %71, label %48
34: ; preds = %7, %34
%35 = phi double [ 0.000000e+00, %7 ], [ %45, %34 ]
%36 = phi i64 [ 0, %7 ], [ %40, %34 ]
%37 = trunc i64 %36 to i32
%38 = sub nsw i32 %4, %37
%39 = sitofp i32 %38 to double
%40 = add nuw nsw i64 %36, 1
%41 = trunc i64 %40 to i32
%42 = sitofp i32 %41 to double
%43 = fdiv double %39, %42
%44 = tail call double @log(double %43)
%45 = fadd double %35, %44
%46 = getelementptr inbounds double, double* %3, i64 %40
store double %45, double* %46
%47 = icmp eq i64 %40, %9
br i1 %47, label %10, label %34
48: ; preds = %31, %48
%49 = phi i64 [ %65, %48 ], [ %32, %31 ]
%50 = add nsw i64 %49, -1
%51 = sub nsw i64 %14, %50
%52 = getelementptr inbounds double, double* %3, i64 %51
%53 = load double, double* %52
%54 = getelementptr inbounds double, double* %3, i64 %50
store double %53, double* %54
%55 = add nsw i64 %49, -2
%56 = sub nsw i64 %14, %55
%57 = getelementptr inbounds double, double* %3, i64 %56
%58 = load double, double* %57
%59 = getelementptr inbounds double, double* %3, i64 %55
store double %58, double* %59
%60 = add nsw i64 %49, -3
%61 = sub nsw i64 %14, %60
%62 = getelementptr inbounds double, double* %3, i64 %61
%63 = load double, double* %62
%64 = getelementptr inbounds double, double* %3, i64 %60
store double %63, double* %64
%65 = add nsw i64 %49, -4
%66 = sub nsw i64 %14, %65
%67 = getelementptr inbounds double, double* %3, i64 %66
%68 = load double, double* %67
%69 = getelementptr inbounds double, double* %3, i64 %65
store double %68, double* %69
%70 = icmp sgt i64 %65, %15
br i1 %70, label %48, label %71
71: ; preds = %31, %48, %10
ret double* %3
}