#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 */
int atan(double);
double cos(int);
void blackman(float *window, unsigned long length) {
  unsigned long i;
  double pi, phase = 0, delta;
  pi = 4. * atan(1.0);
  delta = 2 * pi / (double)length;
  for (i = 0; i < length; i++) {
    window[i] = (float)(0.42 - .5 * cos(phase) + .08 * cos(2 * phase));
    phase += delta;
  }
}


x86 assembly (clang, -O0):
<blackman>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x28(%rbp)
movsd  0xec0(%rip),%xmm0
call   1030 <atan@plt>
cvtsi2sd %eax,%xmm0
movsd  0xeb7(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
addsd  %xmm0,%xmm0
movaps 0xec6(%rip),%xmm2
movq   -0x10(%rbp),%xmm1
punpckldq %xmm2,%xmm1
movapd 0xec5(%rip),%xmm2
subpd  %xmm2,%xmm1
movaps %xmm1,%xmm2
unpckhpd %xmm1,%xmm1
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    122c <blackman+0x10c>
cvttsd2si -0x28(%rbp),%edi
call   1040 <cos@plt>
movsd  0xe65(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe61(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  0xe40(%rip),%xmm0
mulsd  -0x28(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1040 <cos@plt>
movsd  -0x38(%rbp),%xmm1
movsd  0xe1d(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
movsd  -0x30(%rbp),%xmm0
addsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    119b <blackman+0x7b>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<blackman>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %rsi,%r15
mov    %rdi,%r14
movsd  0xec9(%rip),%xmm0
call   1030 <atan@plt>
test   %r15,%r15
je     11f5 <blackman+0xd5>
cvtsi2sd %eax,%xmm2
mulsd  0xeb7(%rip),%xmm2
addsd  %xmm2,%xmm2
movq   %r15,%xmm0
punpckldq 0xece(%rip),%xmm0
subpd  0xed6(%rip),%xmm0
movapd %xmm0,%xmm1
unpckhpd %xmm0,%xmm1
addsd  %xmm0,%xmm1
divsd  %xmm1,%xmm2
movsd  %xmm2,0x10(%rsp)
xorpd  %xmm0,%xmm0
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
movsd  %xmm0,0x8(%rsp)
cvttsd2si %xmm0,%edi
call   1040 <cos@plt>
mulsd  0xe69(%rip),%xmm0
addsd  0xe69(%rip),%xmm0
movsd  %xmm0,0x18(%rsp)
movsd  0x8(%rsp),%xmm0
addsd  %xmm0,%xmm0
cvttsd2si %xmm0,%edi
call   1040 <cos@plt>
mulsd  0xe50(%rip),%xmm0
addsd  0x18(%rsp),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,(%r14,%rbx,4)
movsd  0x8(%rsp),%xmm0
addsd  0x10(%rsp),%xmm0
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1190 <blackman+0x70>
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @blackman(float* %0, i64 %1) {
%3 = alloca float*
%4 = alloca i64
%5 = alloca i64
%6 = alloca double
%7 = alloca double
%8 = alloca double
store float* %0, float** %3
store i64 %1, i64* %4
store double 0.000000e+00, double* %7
%9 = call i32 @atan(double 1.000000e+00)
%10 = sitofp i32 %9 to double
%11 = fmul double 4.000000e+00, %10
store double %11, double* %6
%12 = load double, double* %6
%13 = fmul double 2.000000e+00, %12
%14 = load i64, i64* %4
%15 = uitofp i64 %14 to double
%16 = fdiv double %13, %15
store double %16, double* %8
store i64 0, i64* %5
br label %17
17: ; preds = %38, %2
%18 = load i64, i64* %5
%19 = load i64, i64* %4
%20 = icmp ult i64 %18, %19
br i1 %20, label %21, label %41
21: ; preds = %17
%22 = load double, double* %7
%23 = fptosi double %22 to i32
%24 = call double @cos(i32 %23)
%25 = call double @llvm.fmuladd.f64(double -5.000000e-01, double %24, double 4.200000e-01)
%26 = load double, double* %7
%27 = fmul double 2.000000e+00, %26
%28 = fptosi double %27 to i32
%29 = call double @cos(i32 %28)
%30 = call double @llvm.fmuladd.f64(double 8.000000e-02, double %29, double %25)
%31 = fptrunc double %30 to float
%32 = load float*, float** %3
%33 = load i64, i64* %5
%34 = getelementptr inbounds float, float* %32, i64 %33
store float %31, float* %34
%35 = load double, double* %8
%36 = load double, double* %7
%37 = fadd double %36, %35
store double %37, double* %7
br label %38
38: ; preds = %21
%39 = load i64, i64* %5
%40 = add i64 %39, 1
store i64 %40, i64* %5
br label %17
41: ; preds = %17
ret void
}

LLVM IR (-O2):
define void @blackman(float* nocapture writeonly %0, i64 %1) {
%3 = tail call i32 @atan(double 1.000000e+00)
%4 = sitofp i32 %3 to double
%5 = fmul double %4, 4.000000e+00
%6 = fmul double %5, 2.000000e+00
%7 = uitofp i64 %1 to double
%8 = fdiv double %6, %7
%9 = icmp eq i64 %1, 0
br i1 %9, label %25, label %10
10: ; preds = %2, %10
%11 = phi i64 [ %23, %10 ], [ 0, %2 ]
%12 = phi double [ %22, %10 ], [ 0.000000e+00, %2 ]
%13 = fptosi double %12 to i32
%14 = tail call double @cos(i32 %13)
%15 = tail call double @llvm.fmuladd.f64(double %14, double -5.000000e-01, double 4.200000e-01)
%16 = fmul double %12, 2.000000e+00
%17 = fptosi double %16 to i32
%18 = tail call double @cos(i32 %17)
%19 = tail call double @llvm.fmuladd.f64(double %18, double 8.000000e-02, double %15)
%20 = fptrunc double %19 to float
%21 = getelementptr inbounds float, float* %0, i64 %11
store float %20, float* %21
%22 = fadd double %8, %12
%23 = add nuw i64 %11, 1
%24 = icmp eq i64 %23, %1
br i1 %24, label %25, label %10
25: ; preds = %10, %2
ret void
}