#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 hamming(int size, float *array) {
  int i;
  float w, win_frq;
  win_frq = 6.283185309564 / size;
  for (i = 0; i < size / 2; i++) {
    w = 0.54 - 0.46 * cos(i * win_frq);
    array[i] *= w;
    array[size - i] *= w;
  }
}


x86 assembly (clang, -O0):
<hamming>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
cvtsi2sdl -0x4(%rbp),%xmm1
movsd  0xed4(%rip),%xmm0
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x1c(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
cmp    %ecx,%eax
jge    11d3 <hamming+0xc3>
cvtsi2ssl -0x14(%rbp),%xmm0
mulss  -0x1c(%rbp),%xmm0
cvttss2si %xmm0,%edi
call   1030 <cos@plt>
movsd  0xe8f(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe8b(%rip),%xmm1
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x18(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mulss  (%rax,%rcx,4),%xmm0
movss  %xmm0,(%rax,%rcx,4)
movss  -0x18(%rbp),%xmm0
mov    -0x10(%rbp),%rax
mov    -0x4(%rbp),%ecx
sub    -0x14(%rbp),%ecx
movslq %ecx,%rcx
mulss  (%rax,%rcx,4),%xmm0
movss  %xmm0,(%rax,%rcx,4)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1140 <hamming+0x30>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hamming>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
cmp    $0x2,%edi
jl     11a3 <hamming+0x93>
mov    %rsi,%r15
mov    %edi,%r14d
cvtsi2sd %edi,%xmm0
movsd  0xecd(%rip),%xmm1
divsd  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtsd2ss %xmm1,%xmm0
movss  %xmm0,0x4(%rsp)
mov    %edi,%eax
shr    %r14d
lea    (%rsi,%rax,4),%r12
xor    %ebx,%ebx
nop
xorps  %xmm0,%xmm0
cvtsi2ss %ebx,%xmm0
mulss  0x4(%rsp),%xmm0
cvttss2si %xmm0,%edi
call   1030 <cos@plt>
mulsd  0xe9a(%rip),%xmm0
addsd  0xe9a(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  (%r15,%rbx,4),%xmm1
mulss  %xmm0,%xmm1
movss  %xmm1,(%r15,%rbx,4)
mulss  (%r12),%xmm0
movss  %xmm0,(%r12)
add    $0x1,%rbx
add    $0xfffffffffffffffc,%r12
cmp    %rbx,%r14
jne    1150 <hamming+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define void @hamming(i32 %0, float* nocapture %1) {
%3 = sitofp i32 %0 to double
%4 = fdiv double 0x401921FB546D23DB, %3
%5 = fptrunc double %4 to float
%6 = icmp sgt i32 %0, 1
br i1 %6, label %7, label %29
7: ; preds = %2
%8 = lshr i32 %0, 1
%9 = zext i32 %0 to i64
%10 = zext i32 %8 to i64
br label %11
11: ; preds = %7, %11
%12 = phi i64 [ 0, %7 ], [ %27, %11 ]
%13 = trunc i64 %12 to i32
%14 = sitofp i32 %13 to float
%15 = fmul float %5, %14
%16 = fptosi float %15 to i32
%17 = tail call double @cos(i32 %16)
%18 = tail call double @llvm.fmuladd.f64(double %17, double -4.600000e-01, double 5.400000e-01)
%19 = fptrunc double %18 to float
%20 = getelementptr inbounds float, float* %1, i64 %12
%21 = load float, float* %20
%22 = fmul float %21, %19
store float %22, float* %20
%23 = sub nsw i64 %9, %12
%24 = getelementptr inbounds float, float* %1, i64 %23
%25 = load float, float* %24
%26 = fmul float %25, %19
store float %26, float* %24
%27 = add nuw nsw i64 %12, 1
%28 = icmp eq i64 %27, %10
br i1 %28, label %29, label %11
29: ; preds = %11, %2
ret void
}