#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 */
scalar_t__ cos(float);
void ham(float *win, int n) {
  int i;
  for (i = 0; i < n; i++)
    win[i] = 0.54f - 0.46f * (float)cos((2.0f * 3.14159265358979323846f * (i)) /
                                        (n - 1));
}


x86 assembly (clang, -O0):
<ham>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    118e <ham+0x7e>
cvtsi2ssl -0x10(%rbp),%xmm1
movss  0xec9(%rip),%xmm0
mulss  %xmm1,%xmm0
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
cvtsi2ss %eax,%xmm1
divss  %xmm1,%xmm0
call   1030 <cos@plt>
cvtsi2ss %rax,%xmm0
movss  0xe9d(%rip),%xmm1
mulss  %xmm1,%xmm0
movss  0xe95(%rip),%xmm1
addss  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1126 <ham+0x16>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ham>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %esi,%esi
jle    1232 <ham+0x122>
mov    %rdi,%r14
lea    -0x1(%rsi),%eax
cvtsi2ss %eax,%xmm0
mov    %esi,%r15d
cmp    $0x1,%esi
jne    1143 <ham+0x33>
xor    %ebx,%ebx
test   $0x1,%r15b
jne    11f9 <ham+0xe9>
jmp    1232 <ham+0x122>
mov    %r15d,%r12d
and    $0xfffffffe,%r12d
xor    %ebx,%ebx
movss  %xmm0,0x4(%rsp)
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xorps  %xmm0,%xmm0
cvtsi2ss %ebx,%xmm0
movss  0xe91(%rip),%xmm1
mulss  %xmm1,%xmm0
divss  0x4(%rsp),%xmm0
call   1030 <cos@plt>
xorps  %xmm1,%xmm1
cvtsi2ss %rax,%xmm1
movss  0xe76(%rip),%xmm0
mulss  %xmm0,%xmm1
lea    0x1(%rbx),%eax
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
movss  0xe64(%rip),%xmm2
addss  %xmm2,%xmm1
movss  %xmm1,(%r14,%rbx,4)
mulss  0xe4a(%rip),%xmm0
divss  0x4(%rsp),%xmm0
call   1030 <cos@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
mulss  0xe33(%rip),%xmm0
addss  0xe2f(%rip),%xmm0
movss  %xmm0,0x4(%r14,%rbx,4)
add    $0x2,%rbx
cmp    %r12,%rbx
jne    1160 <ham+0x50>
movss  0x4(%rsp),%xmm0
test   $0x1,%r15b
je     1232 <ham+0x122>
movaps %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtsi2ss %ebx,%xmm0
mulss  0xdf5(%rip),%xmm0
divss  %xmm1,%xmm0
call   1030 <cos@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
mulss  0xde0(%rip),%xmm0
addss  0xddc(%rip),%xmm0
movss  %xmm0,(%r14,%rbx,4)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @ham(float* %0, i32 %1) {
%3 = alloca float*
%4 = alloca i32
%5 = alloca i32
store float* %0, float** %3
store i32 %1, i32* %4
store i32 0, i32* %5
br label %6
6: ; preds = %25, %2
%7 = load i32, i32* %5
%8 = load i32, i32* %4
%9 = icmp slt i32 %7, %8
br i1 %9, label %10, label %28
10: ; preds = %6
%11 = load i32, i32* %5
%12 = sitofp i32 %11 to float
%13 = fmul float 0x401921FB60000000, %12
%14 = load i32, i32* %4
%15 = sub nsw i32 %14, 1
%16 = sitofp i32 %15 to float
%17 = fdiv float %13, %16
%18 = call i64 @cos(float %17)
%19 = sitofp i64 %18 to float
%20 = call float @llvm.fmuladd.f32(float 0xBFDD70A3E0000000, float %19, float 0x3FE147AE20000000)
%21 = load float*, float** %3
%22 = load i32, i32* %5
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds float, float* %21, i64 %23
store float %20, float* %24
br label %25
25: ; preds = %10
%26 = load i32, i32* %5
%27 = add nsw i32 %26, 1
store i32 %27, i32* %5
br label %6
28: ; preds = %6
ret void
}

LLVM IR (-O2):
define void @ham(float* nocapture writeonly %0, i32 %1) {
%3 = icmp sgt i32 %1, 0
br i1 %3, label %4, label %47
4: ; preds = %2
%5 = add nsw i32 %1, -1
%6 = sitofp i32 %5 to float
%7 = zext i32 %1 to i64
%8 = and i64 %7, 1
%9 = icmp eq i32 %1, 1
br i1 %9, label %35, label %10
10: ; preds = %4
%11 = and i64 %7, 4294967294
br label %12
12: ; preds = %12, %10
%13 = phi i64 [ 0, %10 ], [ %32, %12 ]
%14 = phi i64 [ 0, %10 ], [ %33, %12 ]
%15 = trunc i64 %13 to i32
%16 = sitofp i32 %15 to float
%17 = fmul float %16, 0x401921FB60000000
%18 = fdiv float %17, %6
%19 = tail call i64 @cos(float %18)
%20 = sitofp i64 %19 to float
%21 = tail call float @llvm.fmuladd.f32(float %20, float 0xBFDD70A3E0000000, float 0x3FE147AE20000000)
%22 = getelementptr inbounds float, float* %0, i64 %13
store float %21, float* %22
%23 = or i64 %13, 1
%24 = trunc i64 %23 to i32
%25 = sitofp i32 %24 to float
%26 = fmul float %25, 0x401921FB60000000
%27 = fdiv float %26, %6
%28 = tail call i64 @cos(float %27)
%29 = sitofp i64 %28 to float
%30 = tail call float @llvm.fmuladd.f32(float %29, float 0xBFDD70A3E0000000, float 0x3FE147AE20000000)
%31 = getelementptr inbounds float, float* %0, i64 %23
store float %30, float* %31
%32 = add nuw nsw i64 %13, 2
%33 = add i64 %14, 2
%34 = icmp eq i64 %33, %11
br i1 %34, label %35, label %12
35: ; preds = %12, %4
%36 = phi i64 [ 0, %4 ], [ %32, %12 ]
%37 = icmp eq i64 %8, 0
br i1 %37, label %47, label %38
38: ; preds = %35
%39 = trunc i64 %36 to i32
%40 = sitofp i32 %39 to float
%41 = fmul float %40, 0x401921FB60000000
%42 = fdiv float %41, %6
%43 = tail call i64 @cos(float %42)
%44 = sitofp i64 %43 to float
%45 = tail call float @llvm.fmuladd.f32(float %44, float 0xBFDD70A3E0000000, float 0x3FE147AE20000000)
%46 = getelementptr inbounds float, float* %0, i64 %36
store float %45, float* %46
br label %47
47: ; preds = %38, %35, %2
ret void
}