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


x86 assembly (clang, -O0):
<dspl_win_cos>:
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_cos+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_cos+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    11ce <dspl_win_cos+0xbe>
movsd  -0x18(%rbp),%xmm0
call   1030 <sin@plt>
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_cos+0x7e>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dspl_win_cos>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
test   %esi,%esi
jle    125c <dspl_win_cos+0x14c>
mov    %rdi,%r12
shr    $0x8,%edx
and    $0x1,%edx
lea    (%rdx,%rsi,1),%eax
add    $0xffffffff,%eax
cvtsi2sd %eax,%xmm0
movsd  0xec2(%rip),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x10(%rsp)
mov    %esi,%r15d
lea    -0x1(%r15),%rax
mov    %r15d,%r14d
and    $0x3,%r14d
cmp    $0x3,%rax
jae    1167 <dspl_win_cos+0x57>
xorpd  %xmm0,%xmm0
xor    %ebx,%ebx
jmp    121c <dspl_win_cos+0x10c>
and    $0xfffffffc,%r15d
xorpd  %xmm0,%xmm0
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsd  %xmm0,0x8(%rsp)
movsd  0x8(%rsp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,(%r12,%rbx,8)
movsd  0x8(%rsp),%xmm0
addsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x8(%rsp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,0x8(%r12,%rbx,8)
movsd  0x8(%rsp),%xmm0
addsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x8(%rsp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,0x10(%r12,%rbx,8)
movsd  0x8(%rsp),%xmm0
addsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x8(%rsp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,0x18(%r12,%rbx,8)
movsd  0x8(%rsp),%xmm0
addsd  0x10(%rsp),%xmm0
add    $0x4,%rbx
cmp    %rbx,%r15
jne    1180 <dspl_win_cos+0x70>
test   %r14,%r14
je     125c <dspl_win_cos+0x14c>
lea    (%r12,%rbx,8),%r15
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
movsd  %xmm0,0x8(%rsp)
movsd  0x8(%rsp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,(%r15,%rbx,8)
movsd  0x8(%rsp),%xmm0
addsd  0x10(%rsp),%xmm0
add    $0x1,%rbx
cmp    %rbx,%r14
jne    1230 <dspl_win_cos+0x120>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @dspl_win_cos(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 0x400921FB54442D18, %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 0x400921FB54442D18, %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 = %41, %26
%28 = load i32, i32* %9
%29 = load i32, i32* %5
%30 = icmp slt i32 %28, %29
br i1 %30, label %31, label %44
31: ; preds = %27
%32 = load double, double* %7
%33 = call double @sin(double %32)
%34 = load double*, double** %4
%35 = load i32, i32* %9
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds double, double* %34, i64 %36
store double %33, double* %37
%38 = load double, double* %8
%39 = load double, double* %7
%40 = fadd double %39, %38
store double %40, double* %7
br label %41
41: ; preds = %31
%42 = load i32, i32* %9
%43 = add nsw i32 %42, 1
store i32 %43, i32* %9
br label %27
44: ; preds = %27
ret void
}

LLVM IR (-O2):
define void @dspl_win_cos(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 0x400921FB54442D18, %8
%10 = icmp sgt i32 %1, 0
br i1 %10, label %11, label %54
11: ; preds = %3
%12 = zext i32 %1 to i64
%13 = add nsw i64 %12, -1
%14 = and i64 %12, 3
%15 = icmp ult i64 %13, 3
br i1 %15, label %40, label %16
16: ; preds = %11
%17 = and i64 %12, 4294967292
br label %18
18: ; preds = %18, %16
%19 = phi i64 [ 0, %16 ], [ %37, %18 ]
%20 = phi double [ 0.000000e+00, %16 ], [ %36, %18 ]
%21 = phi i64 [ 0, %16 ], [ %38, %18 ]
%22 = tail call double @sin(double %20)
%23 = getelementptr inbounds double, double* %0, i64 %19
store double %22, double* %23
%24 = fadd double %9, %20
%25 = or i64 %19, 1
%26 = tail call double @sin(double %24)
%27 = getelementptr inbounds double, double* %0, i64 %25
store double %26, double* %27
%28 = fadd double %9, %24
%29 = or i64 %19, 2
%30 = tail call double @sin(double %28)
%31 = getelementptr inbounds double, double* %0, i64 %29
store double %30, double* %31
%32 = fadd double %9, %28
%33 = or i64 %19, 3
%34 = tail call double @sin(double %32)
%35 = getelementptr inbounds double, double* %0, i64 %33
store double %34, double* %35
%36 = fadd double %9, %32
%37 = add nuw nsw i64 %19, 4
%38 = add i64 %21, 4
%39 = icmp eq i64 %38, %17
br i1 %39, label %40, label %18
40: ; preds = %18, %11
%41 = phi i64 [ 0, %11 ], [ %37, %18 ]
%42 = phi double [ 0.000000e+00, %11 ], [ %36, %18 ]
%43 = icmp eq i64 %14, 0
br i1 %43, label %54, label %44
44: ; preds = %40, %44
%45 = phi i64 [ %51, %44 ], [ %41, %40 ]
%46 = phi double [ %50, %44 ], [ %42, %40 ]
%47 = phi i64 [ %52, %44 ], [ 0, %40 ]
%48 = tail call double @sin(double %46)
%49 = getelementptr inbounds double, double* %0, i64 %45
store double %48, double* %49
%50 = fadd double %9, %46
%51 = add nuw nsw i64 %45, 1
%52 = add i64 %47, 1
%53 = icmp eq i64 %52, %14
br i1 %53, label %54, label %44
54: ; preds = %40, %44, %3
ret void
}