#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 cos(double);
double sin(double);
int FourierWindow(double freq, double *input, double *outputr, double *outputi,
                  size_t position, size_t length, size_t samplerate) {
  size_t i;
  double domega_dsample =
      2 * (3.1415926535897932384626433832795) * freq / samplerate;
  for (i = 0; i < length; i++) {
    outputr[i] = input[i] * cos(domega_dsample * (i + position));
    outputi[i] = input[i] * sin(domega_dsample * (i + position));
  }
  return 1;
}


x86 assembly (clang, -O0):
<FourierWindow>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    %r9,-0x38(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  0xeab(%rip),%xmm1
mulsd  %xmm1,%xmm0
movaps 0xeb0(%rip),%xmm2
movq   -0x38(%rbp),%xmm1
punpckldq %xmm2,%xmm1
movapd 0xeaf(%rip),%xmm2
subpd  %xmm2,%xmm1
movaps %xmm1,%xmm2
unpckhpd %xmm1,%xmm1
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movq   $0x0,-0x40(%rbp)
mov    -0x40(%rbp),%rax
cmp    -0x30(%rbp),%rax
jae    127f <FourierWindow+0x15f>
mov    -0x10(%rbp),%rcx
mov    -0x40(%rbp),%rax
movsd  (%rcx,%rax,8),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x48(%rbp),%xmm0
mov    -0x28(%rbp),%rcx
add    %rcx,%rax
movq   %rax,%xmm1
movaps 0xe47(%rip),%xmm2
movaps %xmm2,-0x80(%rbp)
punpckldq %xmm2,%xmm1
movapd 0xe47(%rip),%xmm2
movaps %xmm2,-0x70(%rbp)
subpd  %xmm2,%xmm1
movaps %xmm1,%xmm2
unpckhpd %xmm1,%xmm1
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
call   1040 <cos@plt>
movaps -0x80(%rbp),%xmm3
movaps -0x70(%rbp),%xmm2
movaps %xmm0,%xmm1
movsd  -0x58(%rbp),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
mov    -0x40(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x10(%rbp),%rcx
mov    -0x40(%rbp),%rax
movsd  (%rcx,%rax,8),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x48(%rbp),%xmm0
mov    -0x28(%rbp),%rcx
add    %rcx,%rax
movq   %rax,%xmm1
punpckldq %xmm3,%xmm1
subpd  %xmm2,%xmm1
movaps %xmm1,%xmm2
unpckhpd %xmm1,%xmm1
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
call   1030 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x50(%rbp),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x20(%rbp),%rax
mov    -0x40(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x40(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x40(%rbp)
jmp    1191 <FourierWindow+0x71>
mov    $0x1,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<FourierWindow>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
test   %r8,%r8
je     11f4 <FourierWindow+0xd4>
mov    %r8,%r13
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%r12
mov    %rdi,%rbx
movapd %xmm0,%xmm2
mulsd  0xeae(%rip),%xmm2
movq   %r9,%xmm0
punpckldq 0xeb1(%rip),%xmm0
subpd  0xeb9(%rip),%xmm0
movapd %xmm0,%xmm1
unpckhpd %xmm0,%xmm1
addsd  %xmm0,%xmm1
divsd  %xmm1,%xmm2
movsd  %xmm2,0x8(%rsp)
xor    %ebp,%ebp
nop
movsd  (%rbx,%rbp,8),%xmm0
movsd  %xmm0,(%rsp)
lea    (%r14,%rbp,1),%rax
movq   %rax,%xmm1
punpckldq 0xe75(%rip),%xmm1
subpd  0xe7d(%rip),%xmm1
movapd %xmm1,%xmm0
unpckhpd %xmm1,%xmm0
addsd  %xmm1,%xmm0
mulsd  0x8(%rsp),%xmm0
movapd %xmm0,0x10(%rsp)
call   1040 <cos@plt>
mulsd  (%rsp),%xmm0
movsd  %xmm0,(%r12,%rbp,8)
movsd  (%rbx,%rbp,8),%xmm0
movsd  %xmm0,(%rsp)
movapd 0x10(%rsp),%xmm0
call   1030 <sin@plt>
mulsd  (%rsp),%xmm0
movsd  %xmm0,(%r15,%rbp,8)
add    $0x1,%rbp
cmp    %rbp,%r13
jne    1180 <FourierWindow+0x60>
mov    $0x1,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @FourierWindow(double %0, double* %1, double* %2, double* %3, i64 %4, i64 %5, i64 %6) {
%8 = alloca double
%9 = alloca double*
%10 = alloca double*
%11 = alloca double*
%12 = alloca i64
%13 = alloca i64
%14 = alloca i64
%15 = alloca i64
%16 = alloca double
store double %0, double* %8
store double* %1, double** %9
store double* %2, double** %10
store double* %3, double** %11
store i64 %4, i64* %12
store i64 %5, i64* %13
store i64 %6, i64* %14
%17 = load double, double* %8
%18 = fmul double 0x401921FB54442D18, %17
%19 = load i64, i64* %14
%20 = uitofp i64 %19 to double
%21 = fdiv double %18, %20
store double %21, double* %16
store i64 0, i64* %15
br label %22
22: ; preds = %57, %7
%23 = load i64, i64* %15
%24 = load i64, i64* %13
%25 = icmp ult i64 %23, %24
br i1 %25, label %26, label %60
26: ; preds = %22
%27 = load double*, double** %9
%28 = load i64, i64* %15
%29 = getelementptr inbounds double, double* %27, i64 %28
%30 = load double, double* %29
%31 = load double, double* %16
%32 = load i64, i64* %15
%33 = load i64, i64* %12
%34 = add i64 %32, %33
%35 = uitofp i64 %34 to double
%36 = fmul double %31, %35
%37 = call double @cos(double %36)
%38 = fmul double %30, %37
%39 = load double*, double** %10
%40 = load i64, i64* %15
%41 = getelementptr inbounds double, double* %39, i64 %40
store double %38, double* %41
%42 = load double*, double** %9
%43 = load i64, i64* %15
%44 = getelementptr inbounds double, double* %42, i64 %43
%45 = load double, double* %44
%46 = load double, double* %16
%47 = load i64, i64* %15
%48 = load i64, i64* %12
%49 = add i64 %47, %48
%50 = uitofp i64 %49 to double
%51 = fmul double %46, %50
%52 = call double @sin(double %51)
%53 = fmul double %45, %52
%54 = load double*, double** %11
%55 = load i64, i64* %15
%56 = getelementptr inbounds double, double* %54, i64 %55
store double %53, double* %56
br label %57
57: ; preds = %26
%58 = load i64, i64* %15
%59 = add i64 %58, 1
store i64 %59, i64* %15
br label %22
60: ; preds = %22
ret i32 1
}

LLVM IR (-O2):
define i32 @FourierWindow(double %0, double* nocapture %1, double* nocapture writeonly %2, double* nocapture writeonly %3, i64 %4, i64 %5, i64 %6) {
%8 = fmul double %0, 0x401921FB54442D18
%9 = uitofp i64 %6 to double
%10 = fdiv double %8, %9
%11 = icmp eq i64 %5, 0
br i1 %11, label %28, label %12
12: ; preds = %7, %12
%13 = phi i64 [ %26, %12 ], [ 0, %7 ]
%14 = getelementptr inbounds double, double* %1, i64 %13
%15 = load double, double* %14
%16 = add i64 %13, %4
%17 = uitofp i64 %16 to double
%18 = fmul double %10, %17
%19 = tail call double @cos(double %18)
%20 = fmul double %15, %19
%21 = getelementptr inbounds double, double* %2, i64 %13
store double %20, double* %21
%22 = load double, double* %14
%23 = tail call double @sin(double %18)
%24 = fmul double %22, %23
%25 = getelementptr inbounds double, double* %3, i64 %13
store double %24, double* %25
%26 = add nuw i64 %13, 1
%27 = icmp eq i64 %26, %5
br i1 %27, label %28, label %12
28: ; preds = %12, %7
ret i32 1
}