#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(double);
void hanning(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.5 * (1.0 - cos(phase)));
    phase += delta;
  }
}


x86 assembly (clang, -O0):
<hanning>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%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 0xeb6(%rip),%xmm2
movq   -0x10(%rbp),%xmm1
punpckldq %xmm2,%xmm1
movapd 0xeb5(%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    11fc <hanning+0xdc>
movsd  -0x28(%rbp),%xmm0
call   1040 <cos@plt>
movsd  0xe45(%rip),%xmm1
subsd  %xmm0,%xmm1
movsd  0xe49(%rip),%xmm0
mulsd  %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 <hanning+0x7b>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hanning>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r14
mov    %rdi,%r15
movsd  0xec7(%rip),%xmm0
call   1030 <atan@plt>
test   %r14,%r14
je     125c <hanning+0x13c>
cmp    $0x1,%r14
jne    1158 <hanning+0x38>
xorpd  %xmm1,%xmm1
xor    %ebx,%ebx
jmp    122c <hanning+0x10c>
cvtsi2sd %eax,%xmm2
mulsd  0xea4(%rip),%xmm2
movq   %r14,%xmm0
punpckldq 0xeaf(%rip),%xmm0
subpd  0xeb7(%rip),%xmm0
addsd  %xmm2,%xmm2
movapd %xmm0,%xmm1
unpckhpd %xmm0,%xmm1
addsd  %xmm0,%xmm1
divsd  %xmm1,%xmm2
movsd  %xmm2,0x10(%rsp)
mov    %r14,%r12
and    $0xfffffffffffffffe,%r12
xorpd  %xmm1,%xmm1
xor    %ebx,%ebx
movsd  %xmm1,0x8(%rsp)
movapd %xmm1,%xmm0
call   1040 <cos@plt>
movsd  0xe49(%rip),%xmm1
subsd  %xmm0,%xmm1
movsd  0xe4d(%rip),%xmm0
mulsd  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtsd2ss %xmm1,%xmm0
movss  %xmm0,(%r15,%rbx,4)
movsd  0x8(%rsp),%xmm0
addsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x8(%rsp),%xmm0
call   1040 <cos@plt>
movsd  0xe07(%rip),%xmm1
subsd  %xmm0,%xmm1
mulsd  0xe0b(%rip),%xmm1
xorps  %xmm0,%xmm0
cvtsd2ss %xmm1,%xmm0
movsd  0x8(%rsp),%xmm1
movss  %xmm0,0x4(%r15,%rbx,4)
addsd  0x10(%rsp),%xmm1
add    $0x2,%rbx
cmp    %rbx,%r12
jne    11a0 <hanning+0x80>
test   $0x1,%r14b
je     125c <hanning+0x13c>
movapd %xmm1,%xmm0
call   1040 <cos@plt>
movsd  0xdbd(%rip),%xmm1
subsd  %xmm0,%xmm1
mulsd  0xdc1(%rip),%xmm1
xorps  %xmm0,%xmm0
cvtsd2ss %xmm1,%xmm0
movss  %xmm0,(%r15,%rbx,4)
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @hanning(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 = %33, %2
%18 = load i64, i64* %5
%19 = load i64, i64* %4
%20 = icmp ult i64 %18, %19
br i1 %20, label %21, label %36
21: ; preds = %17
%22 = load double, double* %7
%23 = call double @cos(double %22)
%24 = fsub double 1.000000e+00, %23
%25 = fmul double 5.000000e-01, %24
%26 = fptrunc double %25 to float
%27 = load float*, float** %3
%28 = load i64, i64* %5
%29 = getelementptr inbounds float, float* %27, i64 %28
store float %26, float* %29
%30 = load double, double* %8
%31 = load double, double* %7
%32 = fadd double %31, %30
store double %32, double* %7
br label %33
33: ; preds = %21
%34 = load i64, i64* %5
%35 = add i64 %34, 1
store i64 %35, i64* %5
br label %17
36: ; preds = %17
ret void
}

LLVM IR (-O2):
define void @hanning(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 %45, label %10
10: ; preds = %2
%11 = and i64 %1, 1
%12 = icmp eq i64 %1, 1
br i1 %12, label %35, label %13
13: ; preds = %10
%14 = and i64 %1, -2
br label %15
15: ; preds = %15, %13
%16 = phi i64 [ 0, %13 ], [ %32, %15 ]
%17 = phi double [ 0.000000e+00, %13 ], [ %31, %15 ]
%18 = phi i64 [ 0, %13 ], [ %33, %15 ]
%19 = tail call double @cos(double %17)
%20 = fsub double 1.000000e+00, %19
%21 = fmul double %20, 5.000000e-01
%22 = fptrunc double %21 to float
%23 = getelementptr inbounds float, float* %0, i64 %16
store float %22, float* %23
%24 = fadd double %8, %17
%25 = or i64 %16, 1
%26 = tail call double @cos(double %24)
%27 = fsub double 1.000000e+00, %26
%28 = fmul double %27, 5.000000e-01
%29 = fptrunc double %28 to float
%30 = getelementptr inbounds float, float* %0, i64 %25
store float %29, float* %30
%31 = fadd double %8, %24
%32 = add nuw i64 %16, 2
%33 = add i64 %18, 2
%34 = icmp eq i64 %33, %14
br i1 %34, label %35, label %15
35: ; preds = %15, %10
%36 = phi i64 [ 0, %10 ], [ %32, %15 ]
%37 = phi double [ 0.000000e+00, %10 ], [ %31, %15 ]
%38 = icmp eq i64 %11, 0
br i1 %38, label %45, label %39
39: ; preds = %35
%40 = tail call double @cos(double %37)
%41 = fsub double 1.000000e+00, %40
%42 = fmul double %41, 5.000000e-01
%43 = fptrunc double %42 to float
%44 = getelementptr inbounds float, float* %0, i64 %36
store float %43, float* %44
br label %45
45: ; preds = %39, %35, %2
ret void
}