#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__ sin(double);
double square(float);
void compute_window(int n, float *window) {
  int n2 = n >> 1, i;
  for (i = 0; i < n2; ++i)
    window[i] = (float)sin(0.5 * 3.14159265358979323846264f *
                           square((float)sin((i - 0 + 0.5) / n2 * 0.5 *
                                             3.14159265358979323846264f)));
}


x86 assembly (clang, -O0):
<compute_window>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%eax
sar    $0x1,%eax
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11c5 <compute_window+0xa5>
mov    -0x18(%rbp),%eax
sub    $0x0,%eax
cvtsi2sd %eax,%xmm0
movsd  0xeb3(%rip),%xmm1
addsd  %xmm1,%xmm0
cvtsi2sdl -0x14(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  0xe9e(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe8a(%rip),%xmm1
mulsd  %xmm1,%xmm0
call   1040 <sin@plt>
cvtsi2ss %rax,%xmm0
call   1030 <square@plt>
movaps %xmm0,%xmm1
movsd  0xe64(%rip),%xmm0
mulsd  %xmm1,%xmm0
call   1040 <sin@plt>
cvtsi2ss %rax,%xmm0
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    113f <compute_window+0x1f>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compute_window>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
cmp    $0x2,%edi
jl     11ab <compute_window+0x8b>
mov    %rsi,%r14
sar    %edi
cvtsi2sd %edi,%xmm0
movsd  %xmm0,0x8(%rsp)
cmp    $0x2,%edi
mov    $0x1,%r15d
cmovge %edi,%r15d
xor    %ebx,%ebx
nopl   0x0(%rax)
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
movsd  0xea1(%rip),%xmm1
addsd  %xmm1,%xmm0
divsd  0x8(%rsp),%xmm0
mulsd  %xmm1,%xmm0
mulsd  0xe93(%rip),%xmm0
call   1040 <sin@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
call   1030 <square@plt>
mulsd  0xe81(%rip),%xmm0
call   1040 <sin@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
movss  %xmm0,(%r14,%rbx,4)
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1150 <compute_window+0x30>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define void @compute_window(i32 %0, float* nocapture writeonly %1) {
%3 = ashr i32 %0, 1
%4 = icmp sgt i32 %0, 1
br i1 %4, label %5, label %26
5: ; preds = %2
%6 = sitofp i32 %3 to double
%7 = call i32 @llvm.smax.i32(i32 %3, i32 1)
%8 = zext i32 %7 to i64
br label %9
9: ; preds = %5, %9
%10 = phi i64 [ 0, %5 ], [ %24, %9 ]
%11 = trunc i64 %10 to i32
%12 = sitofp i32 %11 to double
%13 = fadd double %12, 5.000000e-01
%14 = fdiv double %13, %6
%15 = fmul double %14, 5.000000e-01
%16 = fmul double %15, 0x400921FB60000000
%17 = tail call i64 @sin(double %16)
%18 = sitofp i64 %17 to float
%19 = tail call double @square(float %18)
%20 = fmul double %19, 0x3FF921FB60000000
%21 = tail call i64 @sin(double %20)
%22 = sitofp i64 %21 to float
%23 = getelementptr inbounds float, float* %1, i64 %10
store float %22, float* %23
%24 = add nuw nsw i64 %10, 1
%25 = icmp eq i64 %24, %8
br i1 %25, label %26, label %9
26: ; preds = %9, %2
ret void
}