#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 hamming(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.54 - .46 * cos(phase));
    phase += delta;
  }
}


x86 assembly (clang, -O0):
<hamming>:
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 <hamming+0xdc>
movsd  -0x28(%rbp),%xmm0
call   1040 <cos@plt>
movsd  0xe55(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe51(%rip),%xmm1
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 <hamming+0x7b>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hamming>:
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     1245 <hamming+0x125>
cmp    $0x1,%r14
jne    1158 <hamming+0x38>
xorpd  %xmm0,%xmm0
xor    %ebx,%ebx
jmp    1220 <hamming+0x100>
cvtsi2sd %eax,%xmm2
mulsd  0xea4(%rip),%xmm2
addsd  %xmm2,%xmm2
movq   %r14,%xmm0
punpckldq 0xeab(%rip),%xmm0
subpd  0xeb3(%rip),%xmm0
movapd %xmm0,%xmm1
unpckhpd %xmm0,%xmm1
addsd  %xmm0,%xmm1
divsd  %xmm1,%xmm2
movsd  %xmm2,0x10(%rsp)
mov    %r14,%r12
and    $0xfffffffffffffffe,%r12
xorpd  %xmm0,%xmm0
xor    %ebx,%ebx
movsd  %xmm0,0x8(%rsp)
movsd  0x8(%rsp),%xmm0
call   1040 <cos@plt>
movsd  0xe57(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe53(%rip),%xmm1
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%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>
mulsd  0xe18(%rip),%xmm0
addsd  0xe18(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,0x4(%r15,%rbx,4)
movsd  0x8(%rsp),%xmm0
addsd  0x10(%rsp),%xmm0
add    $0x2,%rbx
cmp    %rbx,%r12
jne    11a0 <hamming+0x80>
test   $0x1,%r14b
je     1245 <hamming+0x125>
call   1040 <cos@plt>
mulsd  0xddd(%rip),%xmm0
addsd  0xddd(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,(%r15,%rbx,4)
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

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