#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 cos(int);
float *tml_sr_Malloc(int);
int /*<<< orphan*/ tml_sr_vMpy2(float *, float *, int);
void tml_sr_WinHann(float *vec, int N) {
  int i;
  float *w = tml_sr_Malloc(N);
  for (i = 0; i < N; i++)
    w[i] =
        (float)(0.5 *
                (1 -
                 cos(2 * (3.141592653589793115997963468544185161590576171875) *
                     i / (N - 1))));
  tml_sr_vMpy2(w, vec, N);
}


x86 assembly (clang, -O0):
<tml_sr_WinHann>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%edi
call   1030 <tml_sr_Malloc@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11be <tml_sr_WinHann+0x8e>
cvtsi2sdl -0x10(%rbp),%xmm1
movsd  0xe9d(%rip),%xmm0
mulsd  %xmm1,%xmm0
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
cvtsi2sd %eax,%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1050 <cos@plt>
mov    %eax,%ecx
mov    $0x1,%eax
sub    %ecx,%eax
cvtsi2sd %eax,%xmm1
movsd  0xe65(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x18(%rbp),%rax
movslq -0x10(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1152 <tml_sr_WinHann+0x22>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0xc(%rbp),%edx
call   1040 <tml_sr_vMpy2@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tml_sr_WinHann>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %esi,%r15d
mov    %rdi,%r14
mov    %esi,%edi
call   1030 <tml_sr_Malloc@plt>
mov    %rax,%r12
test   %r15d,%r15d
jle    11b7 <tml_sr_WinHann+0x87>
lea    -0x1(%r15),%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,0x8(%rsp)
mov    %r15d,%r13d
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
mulsd  0xe81(%rip),%xmm0
divsd  0x8(%rsp),%xmm0
cvttsd2si %xmm0,%edi
call   1050 <cos@plt>
mov    $0x1,%ecx
sub    %eax,%ecx
xorps  %xmm0,%xmm0
cvtsi2sd %ecx,%xmm0
mulsd  0xe64(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,(%r12,%rbx,4)
add    $0x1,%rbx
cmp    %rbx,%r13
jne    1170 <tml_sr_WinHann+0x40>
mov    %r12,%rdi
mov    %r14,%rsi
mov    %r15d,%edx
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1040 <tml_sr_vMpy2@plt>

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

LLVM IR (-O2):
define void @tml_sr_WinHann(float* %0, i32 %1) {
%3 = tail call float* @tml_sr_Malloc(i32 %1)
%4 = icmp sgt i32 %1, 0
br i1 %4, label %5, label %24
5: ; preds = %2
%6 = add nsw i32 %1, -1
%7 = sitofp i32 %6 to double
%8 = zext i32 %1 to i64
br label %9
9: ; preds = %5, %9
%10 = phi i64 [ 0, %5 ], [ %22, %9 ]
%11 = trunc i64 %10 to i32
%12 = sitofp i32 %11 to double
%13 = fmul double %12, 0x401921FB54442D18
%14 = fdiv double %13, %7
%15 = fptosi double %14 to i32
%16 = tail call i32 @cos(i32 %15)
%17 = sub nsw i32 1, %16
%18 = sitofp i32 %17 to double
%19 = fmul double %18, 5.000000e-01
%20 = fptrunc double %19 to float
%21 = getelementptr inbounds float, float* %3, i64 %10
store float %20, float* %21
%22 = add nuw nsw i64 %10, 1
%23 = icmp eq i64 %22, %8
br i1 %23, label %24, label %9
24: ; preds = %9, %2
%25 = tail call i32 @tml_sr_vMpy2(float* %3, float* %0, i32 %1)
ret void
}