#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 Izero(double);
double sqrt(double);
void CalculateKBDWindow(double *win, double alpha, int length) {
  int i;
  double IBeta;
  double tmp;
  double sum = 0.0;
  alpha *= 3.14159265358979323846;
  IBeta = 1.0 / Izero(alpha);
  for (i = 0; i < (length >> 1); i++) {
    tmp = 4.0 * (double)i / (double)length - 1.0;
    win[i] = Izero(alpha * sqrt(1.0 - tmp * tmp)) * IBeta;
    sum += win[i];
  }
  sum = 1.0 / sum;
  tmp = 0.0;
  for (i = 0; i < (length >> 1); i++) {
    tmp += win[i];
    win[i] = sqrt(tmp * sum);
  }
}


x86 assembly (clang, -O0):
<CalculateKBDWindow>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xec4(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1030 <Izero@plt>
movaps %xmm0,%xmm1
movsd  0xe9d(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    -0x14(%rbp),%ecx
sar    $0x1,%ecx
cmp    %ecx,%eax
jge    1237 <CalculateKBDWindow+0x117>
cvtsi2sdl -0x18(%rbp),%xmm1
movsd  0xe7f(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvtsi2sdl -0x14(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  0xe5a(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm1,%xmm0
movsd  0xe1a(%rip),%xmm1
addsd  %xmm1,%xmm0
call   1040 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
mulsd  %xmm1,%xmm0
call   1030 <Izero@plt>
mulsd  -0x20(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
addsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1173 <CalculateKBDWindow+0x53>
movsd  0xdc1(%rip),%xmm0
divsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    -0x14(%rbp),%ecx
sar    $0x1,%ecx
cmp    %ecx,%eax
jge    12aa <CalculateKBDWindow+0x18a>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
addsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
mulsd  -0x30(%rbp),%xmm0
call   1040 <sqrt@plt>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1258 <CalculateKBDWindow+0x138>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CalculateKBDWindow>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    %esi,%r14d
mov    %rdi,%rbx
mulsd  0xec8(%rip),%xmm0
movsd  %xmm0,0x10(%rsp)
call   1030 <Izero@plt>
cmp    $0x2,%r14d
jl     130c <CalculateKBDWindow+0x1ec>
movsd  0xeb3(%rip),%xmm2
movapd %xmm2,%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x20(%rsp)
mov    %r14d,%eax
sar    %eax
xorps  %xmm0,%xmm0
cvtsi2sd %r14d,%xmm0
movsd  %xmm0,0x18(%rsp)
cmp    $0x2,%eax
mov    $0x1,%r15d
cmovge %eax,%r15d
xor    %ebp,%ebp
xorpd  %xmm3,%xmm3
jmp    11ca <CalculateKBDWindow+0xaa>
nopl   0x0(%rax,%rax,1)
movapd %xmm2,%xmm0
call   1040 <sqrt@plt>
mulsd  0x10(%rsp),%xmm0
call   1030 <Izero@plt>
mulsd  0x20(%rsp),%xmm0
movsd  %xmm0,(%rbx,%rbp,8)
movsd  0x8(%rsp),%xmm3
addsd  %xmm0,%xmm3
add    $0x1,%rbp
cmp    %rbp,%r15
movsd  0xe40(%rip),%xmm2
je     1208 <CalculateKBDWindow+0xe8>
xorps  %xmm1,%xmm1
cvtsi2sd %ebp,%xmm1
mulsd  0xe37(%rip),%xmm1
divsd  0x18(%rsp),%xmm1
addsd  0xe31(%rip),%xmm1
mulsd  %xmm1,%xmm1
subsd  %xmm1,%xmm2
ucomisd 0xe29(%rip),%xmm2
movsd  %xmm3,0x8(%rsp)
jb     1190 <CalculateKBDWindow+0x70>
xorps  %xmm0,%xmm0
sqrtsd %xmm2,%xmm0
jmp    1199 <CalculateKBDWindow+0x79>
cmp    $0x2,%r14d
jl     130c <CalculateKBDWindow+0x1ec>
divsd  %xmm3,%xmm2
cmp    $0x4,%r14d
jge    124f <CalculateKBDWindow+0x12f>
xorpd  %xmm1,%xmm1
xor    %ebp,%ebp
test   $0x1,%r15b
je     130c <CalculateKBDWindow+0x1ec>
addsd  (%rbx,%rbp,8),%xmm1
mulsd  %xmm1,%xmm2
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm2
jb     12fe <CalculateKBDWindow+0x1de>
xorps  %xmm0,%xmm0
sqrtsd %xmm2,%xmm0
jmp    1307 <CalculateKBDWindow+0x1e7>
mov    %r15d,%r14d
and    $0x7ffffffe,%r14d
xorpd  %xmm3,%xmm3
xor    %ebp,%ebp
xorpd  %xmm1,%xmm1
movsd  %xmm2,0x10(%rsp)
jmp    129a <CalculateKBDWindow+0x17a>
nopl   0x0(%rax,%rax,1)
movsd  %xmm1,0x8(%rsp)
call   1040 <sqrt@plt>
xorpd  %xmm3,%xmm3
movsd  0x8(%rsp),%xmm1
movsd  0x10(%rsp),%xmm2
movsd  %xmm0,0x8(%rbx,%rbp,8)
add    $0x2,%rbp
cmp    %rbp,%r14
je     1222 <CalculateKBDWindow+0x102>
addsd  (%rbx,%rbp,8),%xmm1
movapd %xmm2,%xmm0
mulsd  %xmm1,%xmm0
ucomisd %xmm3,%xmm0
jb     12c0 <CalculateKBDWindow+0x1a0>
sqrtsd %xmm0,%xmm0
jmp    12db <CalculateKBDWindow+0x1bb>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsd  %xmm1,0x8(%rsp)
call   1040 <sqrt@plt>
xorpd  %xmm3,%xmm3
movsd  0x8(%rsp),%xmm1
movsd  0x10(%rsp),%xmm2
movsd  %xmm0,(%rbx,%rbp,8)
addsd  0x8(%rbx,%rbp,8),%xmm1
movapd %xmm2,%xmm0
mulsd  %xmm1,%xmm0
ucomisd %xmm3,%xmm0
jb     1270 <CalculateKBDWindow+0x150>
sqrtsd %xmm0,%xmm0
jmp    128b <CalculateKBDWindow+0x16b>
movapd %xmm2,%xmm0
call   1040 <sqrt@plt>
movsd  %xmm0,(%rbx,%rbp,8)
add    $0x28,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @CalculateKBDWindow(double* %0, double %1, i32 %2) {
%4 = alloca double*
%5 = alloca double
%6 = alloca i32
%7 = alloca i32
%8 = alloca double
%9 = alloca double
%10 = alloca double
store double* %0, double** %4
store double %1, double* %5
store i32 %2, i32* %6
store double 0.000000e+00, double* %10
%11 = load double, double* %5
%12 = fmul double %11, 0x400921FB54442D18
store double %12, double* %5
%13 = load double, double* %5
%14 = call double @Izero(double %13)
%15 = fdiv double 1.000000e+00, %14
store double %15, double* %8
store i32 0, i32* %7
br label %16
16: ; preds = %50, %3
%17 = load i32, i32* %7
%18 = load i32, i32* %6
%19 = ashr i32 %18, 1
%20 = icmp slt i32 %17, %19
br i1 %20, label %21, label %53
21: ; preds = %16
%22 = load i32, i32* %7
%23 = sitofp i32 %22 to double
%24 = fmul double 4.000000e+00, %23
%25 = load i32, i32* %6
%26 = sitofp i32 %25 to double
%27 = fdiv double %24, %26
%28 = fsub double %27, 1.000000e+00
store double %28, double* %9
%29 = load double, double* %5
%30 = load double, double* %9
%31 = load double, double* %9
%32 = fneg double %30
%33 = call double @llvm.fmuladd.f64(double %32, double %31, double 1.000000e+00)
%34 = call double @sqrt(double %33)
%35 = fmul double %29, %34
%36 = call double @Izero(double %35)
%37 = load double, double* %8
%38 = fmul double %36, %37
%39 = load double*, double** %4
%40 = load i32, i32* %7
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds double, double* %39, i64 %41
store double %38, double* %42
%43 = load double*, double** %4
%44 = load i32, i32* %7
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds double, double* %43, i64 %45
%47 = load double, double* %46
%48 = load double, double* %10
%49 = fadd double %48, %47
store double %49, double* %10
br label %50
50: ; preds = %21
%51 = load i32, i32* %7
%52 = add nsw i32 %51, 1
store i32 %52, i32* %7
br label %16
53: ; preds = %16
%54 = load double, double* %10
%55 = fdiv double 1.000000e+00, %54
store double %55, double* %10
store double 0.000000e+00, double* %9
store i32 0, i32* %7
br label %56
56: ; preds = %77, %53
%57 = load i32, i32* %7
%58 = load i32, i32* %6
%59 = ashr i32 %58, 1
%60 = icmp slt i32 %57, %59
br i1 %60, label %61, label %80
61: ; preds = %56
%62 = load double*, double** %4
%63 = load i32, i32* %7
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds double, double* %62, i64 %64
%66 = load double, double* %65
%67 = load double, double* %9
%68 = fadd double %67, %66
store double %68, double* %9
%69 = load double, double* %9
%70 = load double, double* %10
%71 = fmul double %69, %70
%72 = call double @sqrt(double %71)
%73 = load double*, double** %4
%74 = load i32, i32* %7
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds double, double* %73, i64 %75
store double %72, double* %76
br label %77
77: ; preds = %61
%78 = load i32, i32* %7
%79 = add nsw i32 %78, 1
store i32 %79, i32* %7
br label %56
80: ; preds = %56
ret void
}

LLVM IR (-O2):
define void @CalculateKBDWindow(double* nocapture %0, double %1, i32 %2) {
%4 = fmul double %1, 0x400921FB54442D18
%5 = tail call double @Izero(double %4)
%6 = fdiv double 1.000000e+00, %5
%7 = icmp sgt i32 %2, 1
br i1 %7, label %8, label %66
8: ; preds = %3
%9 = ashr i32 %2, 1
%10 = sitofp i32 %2 to double
%11 = call i32 @llvm.smax.i32(i32 %9, i32 1)
%12 = zext i32 %11 to i64
br label %13
13: ; preds = %8, %13
%14 = phi i64 [ 0, %8 ], [ %29, %13 ]
%15 = phi double [ 0.000000e+00, %8 ], [ %28, %13 ]
%16 = trunc i64 %14 to i32
%17 = sitofp i32 %16 to double
%18 = fmul double %17, 4.000000e+00
%19 = fdiv double %18, %10
%20 = fadd double %19, -1.000000e+00
%21 = fneg double %20
%22 = tail call double @llvm.fmuladd.f64(double %21, double %20, double 1.000000e+00)
%23 = tail call double @sqrt(double %22)
%24 = fmul double %4, %23
%25 = tail call double @Izero(double %24)
%26 = fmul double %6, %25
%27 = getelementptr inbounds double, double* %0, i64 %14
store double %26, double* %27
%28 = fadd double %15, %26
%29 = add nuw nsw i64 %14, 1
%30 = icmp eq i64 %29, %12
br i1 %30, label %31, label %13
31: ; preds = %13
%32 = fdiv double 1.000000e+00, %28
br i1 %7, label %33, label %66
33: ; preds = %31
%34 = and i64 %12, 1
%35 = icmp slt i32 %2, 4
br i1 %35, label %56, label %36
36: ; preds = %33
%37 = and i64 %12, 2147483646
br label %38
38: ; preds = %38, %36
%39 = phi i64 [ 0, %36 ], [ %53, %38 ]
%40 = phi double [ 0.000000e+00, %36 ], [ %50, %38 ]
%41 = phi i64 [ 0, %36 ], [ %54, %38 ]
%42 = getelementptr inbounds double, double* %0, i64 %39
%43 = load double, double* %42
%44 = fadd double %40, %43
%45 = fmul double %32, %44
%46 = tail call double @sqrt(double %45)
store double %46, double* %42
%47 = or i64 %39, 1
%48 = getelementptr inbounds double, double* %0, i64 %47
%49 = load double, double* %48
%50 = fadd double %44, %49
%51 = fmul double %32, %50
%52 = tail call double @sqrt(double %51)
store double %52, double* %48
%53 = add nuw nsw i64 %39, 2
%54 = add i64 %41, 2
%55 = icmp eq i64 %54, %37
br i1 %55, label %56, label %38
56: ; preds = %38, %33
%57 = phi i64 [ 0, %33 ], [ %53, %38 ]
%58 = phi double [ 0.000000e+00, %33 ], [ %50, %38 ]
%59 = icmp eq i64 %34, 0
br i1 %59, label %66, label %60
60: ; preds = %56
%61 = getelementptr inbounds double, double* %0, i64 %57
%62 = load double, double* %61
%63 = fadd double %58, %62
%64 = fmul double %32, %63
%65 = tail call double @sqrt(double %64)
store double %65, double* %61
br label %66
66: ; preds = %60, %56, %3, %31
ret void
}