#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 */
int /*<<< orphan*/ __ogg_fdrffti(int, double *, int *);
double cos(double);
void __ogg_fdcosqi(int n, double *wsave, int *ifac) {
  static double pih = 1.57079632679489661923132169163975;
  static int k;
  static double fk, dt;
  dt = pih / n;
  fk = 0.;
  for (k = 0; k < n; k++) {
    fk += 1.;
    wsave[k] = cos(fk * dt);
  }
  __ogg_fdrffti(n, wsave + n, ifac);
}


x86 assembly (clang, -O0):
<__ogg_fdcosqi>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movsd  0x2ef5(%rip),%xmm0
cvtsi2sdl -0x4(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,0x2f04(%rip)
xorps  %xmm0,%xmm0
movsd  %xmm0,0x2ef1(%rip)
movl   $0x0,0x2edf(%rip)
mov    0x2ed9(%rip),%eax
cmp    -0x4(%rbp),%eax
jge    11c1 <__ogg_fdcosqi+0xa1>
movsd  0xe88(%rip),%xmm0
addsd  0x2ec8(%rip),%xmm0
movsd  %xmm0,0x2ec0(%rip)
movsd  0x2eb8(%rip),%xmm0
mulsd  0x2eb8(%rip),%xmm0
call   1030 <cos@plt>
mov    -0x10(%rbp),%rax
movslq 0x2e98(%rip),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    0x2e8d(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2e84(%rip)
jmp    1161 <__ogg_fdcosqi+0x41>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
movslq -0x4(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rsi
mov    -0x18(%rbp),%rdx
call   1040 <__ogg_fdrffti@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__ogg_fdcosqi>:
push   %rbp
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %edi,%ebp
cvtsi2sd %edi,%xmm1
movsd  0xec8(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,0x2f04(%rip)
movq   $0x0,0x2ef1(%rip)
movl   $0x0,0x2edf(%rip)
test   %edi,%edi
jle    11b0 <__ogg_fdcosqi+0x90>
movabs $0x3ff0000000000000,%rax
mov    %rax,0x2ed2(%rip)
xchg   %ax,%ax
call   1030 <cos@plt>
movslq 0x2ebc(%rip),%rax
movsd  %xmm0,(%rbx,%rax,8)
add    $0x1,%eax
mov    %eax,0x2eae(%rip)
cmp    %ebp,%eax
jge    11b0 <__ogg_fdcosqi+0x90>
movsd  0x2eaa(%rip),%xmm0
addsd  0xe6a(%rip),%xmm0
movsd  %xmm0,0x2e9a(%rip)
mulsd  0x2e9a(%rip),%xmm0
jmp    1170 <__ogg_fdcosqi+0x50>
movslq %ebp,%rax
lea    (%rbx,%rax,8),%rsi
mov    %ebp,%edi
mov    %r14,%rdx
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <__ogg_fdrffti@plt>

LLVM IR (-O0):
@__ogg_fdcosqi.pih = internal global double 0x3FF921FB54442D18
@__ogg_fdcosqi.k = internal global i32 0
@__ogg_fdcosqi.fk = internal global double 0.000000e+00
@__ogg_fdcosqi.dt = internal global double 0.000000e+00
define void @__ogg_fdcosqi(i32 %0, double* %1, i32* %2) {
%4 = alloca i32
%5 = alloca double*
%6 = alloca i32*
store i32 %0, i32* %4
store double* %1, double** %5
store i32* %2, i32** %6
%7 = load double, double* @__ogg_fdcosqi.pih
%8 = load i32, i32* %4
%9 = sitofp i32 %8 to double
%10 = fdiv double %7, %9
store double %10, double* @__ogg_fdcosqi.dt
store double 0.000000e+00, double* @__ogg_fdcosqi.fk
store i32 0, i32* @__ogg_fdcosqi.k
br label %11
11: ; preds = %26, %3
%12 = load i32, i32* @__ogg_fdcosqi.k
%13 = load i32, i32* %4
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %29
15: ; preds = %11
%16 = load double, double* @__ogg_fdcosqi.fk
%17 = fadd double %16, 1.000000e+00
store double %17, double* @__ogg_fdcosqi.fk
%18 = load double, double* @__ogg_fdcosqi.fk
%19 = load double, double* @__ogg_fdcosqi.dt
%20 = fmul double %18, %19
%21 = call double @cos(double %20)
%22 = load double*, double** %5
%23 = load i32, i32* @__ogg_fdcosqi.k
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds double, double* %22, i64 %24
store double %21, double* %25
br label %26
26: ; preds = %15
%27 = load i32, i32* @__ogg_fdcosqi.k
%28 = add nsw i32 %27, 1
store i32 %28, i32* @__ogg_fdcosqi.k
br label %11
29: ; preds = %11
%30 = load i32, i32* %4
%31 = load double*, double** %5
%32 = load i32, i32* %4
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds double, double* %31, i64 %33
%35 = load i32*, i32** %6
%36 = call i32 @__ogg_fdrffti(i32 %30, double* %34, i32* %35)
ret void
}

LLVM IR (-O2):
@__ogg_fdcosqi.k = internal unnamed_addr global i32 0
@__ogg_fdcosqi.fk = internal unnamed_addr global double 0.000000e+00
@__ogg_fdcosqi.dt = internal unnamed_addr global double 0.000000e+00
define void @__ogg_fdcosqi(i32 %0, double* %1, i32* %2) {
%4 = sitofp i32 %0 to double
%5 = fdiv double 0x3FF921FB54442D18, %4
store double %5, double* @__ogg_fdcosqi.dt
store double 0.000000e+00, double* @__ogg_fdcosqi.fk
store i32 0, i32* @__ogg_fdcosqi.k
%6 = icmp sgt i32 %0, 0
br i1 %6, label %7, label %25
7: ; preds = %3
store double 1.000000e+00, double* @__ogg_fdcosqi.fk
%8 = tail call double @cos(double %5)
%9 = load i32, i32* @__ogg_fdcosqi.k
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds double, double* %1, i64 %10
store double %8, double* %11
%12 = add nsw i32 %9, 1
store i32 %12, i32* @__ogg_fdcosqi.k
%13 = icmp slt i32 %12, %0
br i1 %13, label %14, label %25
14: ; preds = %7, %14
%15 = load double, double* @__ogg_fdcosqi.fk
%16 = load double, double* @__ogg_fdcosqi.dt
%17 = fadd double %15, 1.000000e+00
store double %17, double* @__ogg_fdcosqi.fk
%18 = fmul double %17, %16
%19 = tail call double @cos(double %18)
%20 = load i32, i32* @__ogg_fdcosqi.k
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds double, double* %1, i64 %21
store double %19, double* %22
%23 = add nsw i32 %20, 1
store i32 %23, i32* @__ogg_fdcosqi.k
%24 = icmp slt i32 %23, %0
br i1 %24, label %14, label %25
25: ; preds = %14, %7, %3
%26 = sext i32 %0 to i64
%27 = getelementptr inbounds double, double* %1, i64 %26
%28 = tail call i32 @__ogg_fdrffti(i32 %0, double* %27, i32* %2)
ret void
}