#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 cos(double);
double *blackman(double *w, const int leng) {
  int i;
  double arg, x;
  double *p;
  arg = 6.2831853071795864769252867665590 / (leng - 1);
  for (p = w, i = 0; i < leng; i++) {
    x = arg * i;
    *p++ = 0.42 - 0.50 * cos(x) + 0.08 * cos(x + x);
  }
  return (w);
}


x86 assembly (clang, -O0):
<blackman>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
cvtsi2sd %eax,%xmm1
movsd  0xecf(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11d4 <blackman+0xc4>
movsd  -0x18(%rbp),%xmm0
cvtsi2sdl -0x10(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1030 <cos@plt>
movsd  0xe96(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe92(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x20(%rbp),%xmm0
addsd  -0x20(%rbp),%xmm0
call   1030 <cos@plt>
movsd  -0x30(%rbp),%xmm1
movsd  0xe5d(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x28(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x28(%rbp)
movsd  %xmm0,(%rax)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1149 <blackman+0x39>
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<blackman>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x20,%rsp
mov    %rdi,%r14
test   %esi,%esi
jle    129f <blackman+0x18f>
mov    %esi,%r15d
lea    -0x1(%r15),%eax
cvtsi2sd %eax,%xmm0
movsd  0xec6(%rip),%xmm1
divsd  %xmm0,%xmm1
xorpd  %xmm0,%xmm0
mov    %r14,%r12
cmp    $0x1,%esi
je     124f <blackman+0x13f>
mov    %r15d,%ebp
and    $0xfffffffe,%ebp
xor    %ebx,%ebx
xorpd  %xmm0,%xmm0
mov    %r14,%r12
movsd  %xmm1,(%rsp)
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsd  %xmm0,0x18(%rsp)
mulsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
movapd %xmm1,%xmm0
call   1030 <cos@plt>
movapd %xmm0,%xmm1
movsd  0xe73(%rip),%xmm0
mulsd  %xmm0,%xmm1
movsd  0xe6f(%rip),%xmm0
addsd  %xmm0,%xmm1
movsd  %xmm1,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
addsd  %xmm0,%xmm0
call   1030 <cos@plt>
movsd  0xe56(%rip),%xmm1
mulsd  %xmm1,%xmm0
addsd  0x10(%rsp),%xmm0
movsd  %xmm0,(%r12)
lea    0x1(%rbx),%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  (%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
call   1030 <cos@plt>
mulsd  0xe14(%rip),%xmm0
addsd  0xe14(%rip),%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
addsd  %xmm0,%xmm0
call   1030 <cos@plt>
movsd  (%rsp),%xmm1
mulsd  0xdfa(%rip),%xmm0
addsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x8(%r12)
movsd  0x18(%rsp),%xmm0
add    $0x10,%r12
addsd  0xde3(%rip),%xmm0
add    $0x2,%ebx
cmp    %ebx,%ebp
jne    1170 <blackman+0x60>
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
test   $0x1,%r15b
je     129f <blackman+0x18f>
mulsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
movapd %xmm1,%xmm0
call   1030 <cos@plt>
mulsd  0xd99(%rip),%xmm0
addsd  0xd99(%rip),%xmm0
movsd  %xmm0,0x18(%rsp)
movsd  (%rsp),%xmm0
addsd  %xmm0,%xmm0
call   1030 <cos@plt>
mulsd  0xd85(%rip),%xmm0
addsd  0x18(%rsp),%xmm0
movsd  %xmm0,(%r12)
mov    %r14,%rax
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define double* @blackman(double* %0, i32 %1) {
%3 = alloca double*
%4 = alloca i32
%5 = alloca i32
%6 = alloca double
%7 = alloca double
%8 = alloca double*
store double* %0, double** %3
store i32 %1, i32* %4
%9 = load i32, i32* %4
%10 = sub nsw i32 %9, 1
%11 = sitofp i32 %10 to double
%12 = fdiv double 0x401921FB54442D18, %11
store double %12, double* %6
%13 = load double*, double** %3
store double* %13, double** %8
store i32 0, i32* %5
br label %14
14: ; preds = %33, %2
%15 = load i32, i32* %5
%16 = load i32, i32* %4
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %36
18: ; preds = %14
%19 = load double, double* %6
%20 = load i32, i32* %5
%21 = sitofp i32 %20 to double
%22 = fmul double %19, %21
store double %22, double* %7
%23 = load double, double* %7
%24 = call double @cos(double %23)
%25 = call double @llvm.fmuladd.f64(double -5.000000e-01, double %24, double 4.200000e-01)
%26 = load double, double* %7
%27 = load double, double* %7
%28 = fadd double %26, %27
%29 = call double @cos(double %28)
%30 = call double @llvm.fmuladd.f64(double 8.000000e-02, double %29, double %25)
%31 = load double*, double** %8
%32 = getelementptr inbounds double, double* %31, i32 1
store double* %32, double** %8
store double %30, double* %31
br label %33
33: ; preds = %18
%34 = load i32, i32* %5
%35 = add nsw i32 %34, 1
store i32 %35, i32* %5
br label %14
36: ; preds = %14
%37 = load double*, double** %3
ret double* %37
}

LLVM IR (-O2):
define double* @blackman(double* returned writeonly %0, i32 %1) {
%3 = add nsw i32 %1, -1
%4 = sitofp i32 %3 to double
%5 = fdiv double 0x401921FB54442D18, %4
%6 = icmp sgt i32 %1, 0
br i1 %6, label %7, label %49
7: ; preds = %2
%8 = and i32 %1, 1
%9 = icmp eq i32 %1, 1
br i1 %9, label %38, label %10
10: ; preds = %7
%11 = and i32 %1, -2
br label %12
12: ; preds = %12, %10
%13 = phi double* [ %0, %10 ], [ %32, %12 ]
%14 = phi i32 [ 0, %10 ], [ %33, %12 ]
%15 = phi i32 [ 0, %10 ], [ %34, %12 ]
%16 = sitofp i32 %14 to double
%17 = fmul double %5, %16
%18 = tail call double @cos(double %17)
%19 = tail call double @llvm.fmuladd.f64(double %18, double -5.000000e-01, double 4.200000e-01)
%20 = fadd double %17, %17
%21 = tail call double @cos(double %20)
%22 = tail call double @llvm.fmuladd.f64(double %21, double 8.000000e-02, double %19)
%23 = getelementptr inbounds double, double* %13, i64 1
store double %22, double* %13
%24 = or i32 %14, 1
%25 = sitofp i32 %24 to double
%26 = fmul double %5, %25
%27 = tail call double @cos(double %26)
%28 = tail call double @llvm.fmuladd.f64(double %27, double -5.000000e-01, double 4.200000e-01)
%29 = fadd double %26, %26
%30 = tail call double @cos(double %29)
%31 = tail call double @llvm.fmuladd.f64(double %30, double 8.000000e-02, double %28)
%32 = getelementptr inbounds double, double* %13, i64 2
store double %31, double* %23
%33 = add nuw nsw i32 %14, 2
%34 = add i32 %15, 2
%35 = icmp eq i32 %34, %11
br i1 %35, label %36, label %12
36: ; preds = %12
%37 = sitofp i32 %33 to double
br label %38
38: ; preds = %36, %7
%39 = phi double* [ %0, %7 ], [ %32, %36 ]
%40 = phi double [ 0.000000e+00, %7 ], [ %37, %36 ]
%41 = icmp eq i32 %8, 0
br i1 %41, label %49, label %42
42: ; preds = %38
%43 = fmul double %5, %40
%44 = tail call double @cos(double %43)
%45 = tail call double @llvm.fmuladd.f64(double %44, double -5.000000e-01, double 4.200000e-01)
%46 = fadd double %43, %43
%47 = tail call double @cos(double %46)
%48 = tail call double @llvm.fmuladd.f64(double %47, double 8.000000e-02, double %45)
store double %48, double* %39
br label %49
49: ; preds = %42, %38, %2
ret double* %0
}