#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 sin(double);
void dspl_win_lanczos(double *w, int n, int win_type) {
  double y;
  double x = 0.0;
  int i;
  if ((win_type & 0x00000100) == 0x00000000)
    x = 6.283185307179586476925286766559 / (double)(n - 1);
  if ((win_type & 0x00000100) == 0x00000100)
    x = 6.283185307179586476925286766559 / (double)n;
  y = 0.0;
  for (i = 0; i < n; i++) {
    if ((y - 3.1415926535897932384626433832795) == 0.0)
      w[i] = 1.0;
    else
      w[i] = sin(y - 3.1415926535897932384626433832795) /
             (y - 3.1415926535897932384626433832795);
    y += x;
  }
}


x86 assembly (clang, -O0):
<dspl_win_lanczos>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x10(%rbp),%eax
and    $0x100,%eax
cmp    $0x0,%eax
jne    1156 <dspl_win_lanczos+0x46>
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
cvtsi2sd %eax,%xmm1
movsd  0xeb3(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x10(%rbp),%eax
and    $0x100,%eax
cmp    $0x100,%eax
jne    117f <dspl_win_lanczos+0x6f>
cvtsi2sdl -0xc(%rbp),%xmm1
movsd  0xe8a(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    122d <dspl_win_lanczos+0x11d>
movsd  -0x18(%rbp),%xmm0
movsd  0xe61(%rip),%xmm1
subsd  %xmm1,%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11d8 <dspl_win_lanczos+0xc8>
jp     11d8 <dspl_win_lanczos+0xc8>
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  0xe42(%rip),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
jmp    1210 <dspl_win_lanczos+0x100>
movsd  -0x18(%rbp),%xmm0
movsd  0xe23(%rip),%xmm1
subsd  %xmm1,%xmm0
call   1030 <sin@plt>
movsd  -0x18(%rbp),%xmm1
movsd  0xe0d(%rip),%xmm2
subsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x20(%rbp),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    118e <dspl_win_lanczos+0x7e>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dspl_win_lanczos>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
test   %esi,%esi
jle    1292 <dspl_win_lanczos+0x182>
mov    %rdi,%r15
mov    %esi,%r14d
cmp    $0x1,%esi
jne    1147 <dspl_win_lanczos+0x37>
movsd  0xed2(%rip),%xmm1
xor    %ebx,%ebx
test   $0x1,%r14b
jne    1263 <dspl_win_lanczos+0x153>
jmp    1292 <dspl_win_lanczos+0x182>
shr    $0x8,%edx
and    $0x1,%edx
lea    (%rdx,%rsi,1),%eax
add    $0xffffffff,%eax
cvtsi2sd %eax,%xmm0
movsd  0xea1(%rip),%xmm2
divsd  %xmm0,%xmm2
mov    %r14d,%r12d
and    $0xfffffffe,%r12d
xorpd  %xmm3,%xmm3
xor    %ebx,%ebx
movsd  0xe90(%rip),%xmm4
movsd  0xe90(%rip),%xmm5
xorpd  %xmm1,%xmm1
movsd  %xmm2,0x10(%rsp)
jmp    11a8 <dspl_win_lanczos+0x98>
nopl   0x0(%rax)
movsd  %xmm0,0x8(%r15,%rbx,8)
addsd  %xmm2,%xmm1
add    $0x2,%rbx
cmp    %rbx,%r12
je     1255 <dspl_win_lanczos+0x145>
movapd %xmm1,%xmm6
addsd  %xmm4,%xmm6
ucomisd %xmm3,%xmm6
movapd %xmm5,%xmm0
jne    11bc <dspl_win_lanczos+0xac>
jnp    11f5 <dspl_win_lanczos+0xe5>
movapd %xmm6,%xmm0
movsd  %xmm1,(%rsp)
movsd  %xmm6,0x8(%rsp)
call   1030 <sin@plt>
movsd  0xe38(%rip),%xmm5
movsd  0xe28(%rip),%xmm4
xorpd  %xmm3,%xmm3
movsd  0x10(%rsp),%xmm2
movsd  (%rsp),%xmm1
divsd  0x8(%rsp),%xmm0
movsd  %xmm0,(%r15,%rbx,8)
addsd  %xmm2,%xmm1
movapd %xmm1,%xmm6
addsd  %xmm4,%xmm6
ucomisd %xmm3,%xmm6
movapd %xmm5,%xmm0
jne    1217 <dspl_win_lanczos+0x107>
jnp    1190 <dspl_win_lanczos+0x80>
movapd %xmm6,%xmm0
movsd  %xmm1,(%rsp)
movsd  %xmm6,0x8(%rsp)
call   1030 <sin@plt>
movsd  0xddd(%rip),%xmm5
movsd  0xdcd(%rip),%xmm4
xorpd  %xmm3,%xmm3
movsd  0x10(%rsp),%xmm2
movsd  (%rsp),%xmm1
divsd  0x8(%rsp),%xmm0
jmp    1190 <dspl_win_lanczos+0x80>
addsd  0xdab(%rip),%xmm1
test   $0x1,%r14b
je     1292 <dspl_win_lanczos+0x182>
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm1
jne    1279 <dspl_win_lanczos+0x169>
jp     1279 <dspl_win_lanczos+0x169>
movsd  0xd99(%rip),%xmm0
jmp    128c <dspl_win_lanczos+0x17c>
movapd %xmm1,%xmm0
movsd  %xmm1,(%rsp)
call   1030 <sin@plt>
divsd  (%rsp),%xmm0
movsd  %xmm0,(%r15,%rbx,8)
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @dspl_win_lanczos(double* %0, i32 %1, i32 %2) {
%4 = alloca double*
%5 = alloca i32
%6 = alloca i32
%7 = alloca double
%8 = alloca double
%9 = alloca i32
store double* %0, double** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
store double 0.000000e+00, double* %8
%10 = load i32, i32* %6
%11 = and i32 %10, 256
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %18
13: ; preds = %3
%14 = load i32, i32* %5
%15 = sub nsw i32 %14, 1
%16 = sitofp i32 %15 to double
%17 = fdiv double 0x401921FB54442D18, %16
store double %17, double* %8
br label %18
18: ; preds = %13, %3
%19 = load i32, i32* %6
%20 = and i32 %19, 256
%21 = icmp eq i32 %20, 256
br i1 %21, label %22, label %26
22: ; preds = %18
%23 = load i32, i32* %5
%24 = sitofp i32 %23 to double
%25 = fdiv double 0x401921FB54442D18, %24
store double %25, double* %8
br label %26
26: ; preds = %22, %18
store double 0.000000e+00, double* %7
store i32 0, i32* %9
br label %27
27: ; preds = %55, %26
%28 = load i32, i32* %9
%29 = load i32, i32* %5
%30 = icmp slt i32 %28, %29
br i1 %30, label %31, label %58
31: ; preds = %27
%32 = load double, double* %7
%33 = fsub double %32, 0x400921FB54442D18
%34 = fcmp oeq double %33, 0.000000e+00
br i1 %34, label %35, label %40
35: ; preds = %31
%36 = load double*, double** %4
%37 = load i32, i32* %9
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds double, double* %36, i64 %38
store double 1.000000e+00, double* %39
br label %51
40: ; preds = %31
%41 = load double, double* %7
%42 = fsub double %41, 0x400921FB54442D18
%43 = call double @sin(double %42)
%44 = load double, double* %7
%45 = fsub double %44, 0x400921FB54442D18
%46 = fdiv double %43, %45
%47 = load double*, double** %4
%48 = load i32, i32* %9
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds double, double* %47, i64 %49
store double %46, double* %50
br label %51
51: ; preds = %40, %35
%52 = load double, double* %8
%53 = load double, double* %7
%54 = fadd double %53, %52
store double %54, double* %7
br label %55
55: ; preds = %51
%56 = load i32, i32* %9
%57 = add nsw i32 %56, 1
store i32 %57, i32* %9
br label %27
58: ; preds = %27
ret void
}

LLVM IR (-O2):
define void @dspl_win_lanczos(double* nocapture writeonly %0, i32 %1, i32 %2) {
%4 = lshr i32 %2, 8
%5 = and i32 %4, 1
%6 = add nsw i32 %5, -1
%7 = add nsw i32 %6, %1
%8 = sitofp i32 %7 to double
%9 = fdiv double 0x401921FB54442D18, %8
%10 = icmp sgt i32 %1, 0
br i1 %10, label %11, label %57
11: ; preds = %3
%12 = zext i32 %1 to i64
%13 = and i64 %12, 1
%14 = icmp eq i32 %1, 1
br i1 %14, label %45, label %15
15: ; preds = %11
%16 = and i64 %12, 4294967294
br label %17
17: ; preds = %36, %15
%18 = phi i64 [ 0, %15 ], [ %40, %36 ]
%19 = phi double [ 0.000000e+00, %15 ], [ %39, %36 ]
%20 = phi i64 [ 0, %15 ], [ %41, %36 ]
%21 = fadd double %19, 0xC00921FB54442D18
%22 = fcmp oeq double %21, 0.000000e+00
br i1 %22, label %26, label %23
23: ; preds = %17
%24 = tail call double @sin(double %21)
%25 = fdiv double %24, %21
br label %26
26: ; preds = %17, %23
%27 = phi double [ %25, %23 ], [ 1.000000e+00, %17 ]
%28 = getelementptr inbounds double, double* %0, i64 %18
store double %27, double* %28
%29 = fadd double %9, %19
%30 = or i64 %18, 1
%31 = fadd double %29, 0xC00921FB54442D18
%32 = fcmp oeq double %31, 0.000000e+00
br i1 %32, label %36, label %33
33: ; preds = %26
%34 = tail call double @sin(double %31)
%35 = fdiv double %34, %31
br label %36
36: ; preds = %33, %26
%37 = phi double [ %35, %33 ], [ 1.000000e+00, %26 ]
%38 = getelementptr inbounds double, double* %0, i64 %30
store double %37, double* %38
%39 = fadd double %9, %29
%40 = add nuw nsw i64 %18, 2
%41 = add i64 %20, 2
%42 = icmp eq i64 %41, %16
br i1 %42, label %43, label %17
43: ; preds = %36
%44 = fadd double %39, 0xC00921FB54442D18
br label %45
45: ; preds = %43, %11
%46 = phi i64 [ 0, %11 ], [ %40, %43 ]
%47 = phi double [ 0xC00921FB54442D18, %11 ], [ %44, %43 ]
%48 = icmp eq i64 %13, 0
br i1 %48, label %57, label %49
49: ; preds = %45
%50 = fcmp oeq double %47, 0.000000e+00
br i1 %50, label %54, label %51
51: ; preds = %49
%52 = tail call double @sin(double %47)
%53 = fdiv double %52, %47
br label %54
54: ; preds = %51, %49
%55 = phi double [ %53, %51 ], [ 1.000000e+00, %49 ]
%56 = getelementptr inbounds double, double* %0, i64 %46
store double %55, double* %56
br label %57
57: ; preds = %54, %45, %3
ret void
}