#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(int);
void blackman(float *blackman, int N) {
  float M;
  int n;
  M = (N - 1) / 2;
  for (n = 0; n < N; n++) {
    blackman[n] =
        0.42 + 0.5 * cos((2 * 3.14159265359 * ((float)n - M)) / (2 * M + 1)) +
        0.08 * cos((4 * 3.14159265359 * ((float)n - M)) / (2 * M - 1));
  }
}


x86 assembly (clang, -O0):
<blackman>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    121a <blackman+0x10a>
cvtsi2ssl -0x14(%rbp),%xmm0
subss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xec1(%rip),%xmm0
mulsd  %xmm1,%xmm0
movss  -0x10(%rbp),%xmm1
addss  %xmm1,%xmm1
movss  0xeb8(%rip),%xmm2
addss  %xmm2,%xmm1
cvtss2sd %xmm1,%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1030 <cos@plt>
movsd  0xe7f(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe7b(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
cvtsi2ssl -0x14(%rbp),%xmm0
subss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe4c(%rip),%xmm0
mulsd  %xmm1,%xmm0
movss  -0x10(%rbp),%xmm1
addss  %xmm1,%xmm1
movss  0xe57(%rip),%xmm2
addss  %xmm2,%xmm1
cvtss2sd %xmm1,%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1030 <cos@plt>
movsd  -0x20(%rbp),%xmm1
movsd  0xe0d(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    113d <blackman+0x2d>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<blackman>:
push   %r15
push   %r14
push   %rbx
sub    $0x30,%rsp
test   %esi,%esi
jle    11f6 <blackman+0xe6>
mov    %rdi,%r14
lea    -0x1(%rsi),%eax
shr    $0x1f,%eax
add    %esi,%eax
add    $0xffffffff,%eax
sar    %eax
cvtsi2ss %eax,%xmm0
movss  %xmm0,0xc(%rsp)
addss  %xmm0,%xmm0
movss  0xeb9(%rip),%xmm1
addss  %xmm0,%xmm1
cvtss2sd %xmm1,%xmm1
movsd  %xmm1,0x18(%rsp)
addss  0xea7(%rip),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,0x10(%rsp)
mov    %esi,%r15d
xor    %ebx,%ebx
nopl   0x0(%rax)
xorps  %xmm0,%xmm0
cvtsi2ss %ebx,%xmm0
subss  0xc(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,0x28(%rsp)
mulsd  0xe79(%rip),%xmm0
divsd  0x18(%rsp),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <cos@plt>
mulsd  0xe6a(%rip),%xmm0
addsd  0xe6a(%rip),%xmm0
movsd  %xmm0,0x20(%rsp)
movsd  0x28(%rsp),%xmm0
mulsd  0xe5e(%rip),%xmm0
divsd  0x10(%rsp),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <cos@plt>
mulsd  0xe4f(%rip),%xmm0
addsd  0x20(%rsp),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,(%r14,%rbx,4)
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1170 <blackman+0x60>
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @blackman(float* %0, i32 %1) {
%3 = alloca float*
%4 = alloca i32
%5 = alloca float
%6 = alloca i32
store float* %0, float** %3
store i32 %1, i32* %4
%7 = load i32, i32* %4
%8 = sub nsw i32 %7, 1
%9 = sdiv i32 %8, 2
%10 = sitofp i32 %9 to float
store float %10, float* %5
store i32 0, i32* %6
br label %11
11: ; preds = %47, %2
%12 = load i32, i32* %6
%13 = load i32, i32* %4
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %50
15: ; preds = %11
%16 = load i32, i32* %6
%17 = sitofp i32 %16 to float
%18 = load float, float* %5
%19 = fsub float %17, %18
%20 = fpext float %19 to double
%21 = fmul double 0x401921FB54442EEA, %20
%22 = load float, float* %5
%23 = call float @llvm.fmuladd.f32(float 2.000000e+00, float %22, float 1.000000e+00)
%24 = fpext float %23 to double
%25 = fdiv double %21, %24
%26 = fptosi double %25 to i32
%27 = call double @cos(i32 %26)
%28 = call double @llvm.fmuladd.f64(double 5.000000e-01, double %27, double 4.200000e-01)
%29 = load i32, i32* %6
%30 = sitofp i32 %29 to float
%31 = load float, float* %5
%32 = fsub float %30, %31
%33 = fpext float %32 to double
%34 = fmul double 0x402921FB54442EEA, %33
%35 = load float, float* %5
%36 = call float @llvm.fmuladd.f32(float 2.000000e+00, float %35, float -1.000000e+00)
%37 = fpext float %36 to double
%38 = fdiv double %34, %37
%39 = fptosi double %38 to i32
%40 = call double @cos(i32 %39)
%41 = call double @llvm.fmuladd.f64(double 8.000000e-02, double %40, double %28)
%42 = fptrunc double %41 to float
%43 = load float*, float** %3
%44 = load i32, i32* %6
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds float, float* %43, i64 %45
store float %42, float* %46
br label %47
47: ; preds = %15
%48 = load i32, i32* %6
%49 = add nsw i32 %48, 1
store i32 %49, i32* %6
br label %11
50: ; preds = %11
ret void
}

LLVM IR (-O2):
define void @blackman(float* nocapture writeonly %0, i32 %1) {
%3 = add nsw i32 %1, -1
%4 = sdiv i32 %3, 2
%5 = sitofp i32 %4 to float
%6 = icmp sgt i32 %1, 0
br i1 %6, label %7, label %33
7: ; preds = %2
%8 = tail call float @llvm.fmuladd.f32(float %5, float 2.000000e+00, float 1.000000e+00)
%9 = fpext float %8 to double
%10 = tail call float @llvm.fmuladd.f32(float %5, float 2.000000e+00, float -1.000000e+00)
%11 = fpext float %10 to double
%12 = zext i32 %1 to i64
br label %13
13: ; preds = %7, %13
%14 = phi i64 [ 0, %7 ], [ %31, %13 ]
%15 = trunc i64 %14 to i32
%16 = sitofp i32 %15 to float
%17 = fsub float %16, %5
%18 = fpext float %17 to double
%19 = fmul double %18, 0x401921FB54442EEA
%20 = fdiv double %19, %9
%21 = fptosi double %20 to i32
%22 = tail call double @cos(i32 %21)
%23 = tail call double @llvm.fmuladd.f64(double %22, double 5.000000e-01, double 4.200000e-01)
%24 = fmul double %18, 0x402921FB54442EEA
%25 = fdiv double %24, %11
%26 = fptosi double %25 to i32
%27 = tail call double @cos(i32 %26)
%28 = tail call double @llvm.fmuladd.f64(double %27, double 8.000000e-02, double %23)
%29 = fptrunc double %28 to float
%30 = getelementptr inbounds float, float* %0, i64 %14
store float %29, float* %30
%31 = add nuw nsw i64 %14, 1
%32 = icmp eq i64 %31, %12
br i1 %32, label %33, label %13
33: ; preds = %13, %2
ret void
}