#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(int);
int /*<<< orphan*/ rffti(int, double *);
void cosqi(int n, double wsave[]) {
  static const double pih = 1.57079632679491;
  int k;
  double dt;
  dt = pih / n;
  for (k = 0; k < n; k++)
    wsave[k] = cos((k + 1) * dt);
  rffti(n, &wsave[n]);
}


x86 assembly (clang, -O0):
<cosqi>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
cvtsi2sdl -0x4(%rbp),%xmm1
movsd  0xec4(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    118b <cosqi+0x6b>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
cvtsi2sd %eax,%xmm0
mulsd  -0x20(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1040 <cos@plt>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    114c <cosqi+0x2c>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
movslq -0x4(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rsi
call   1030 <rffti@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cosqi>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r13
mov    %edi,%r15d
test   %edi,%edi
jle    11df <cosqi+0xbf>
cvtsi2sd %r15d,%xmm0
movsd  0xeba(%rip),%xmm1
divsd  %xmm0,%xmm1
mov    %r15d,%r14d
cmp    $0x1,%r15d
jne    1157 <cosqi+0x37>
xor    %ebx,%ebx
jmp    11bb <cosqi+0x9b>
mov    %r14d,%r12d
and    $0xfffffffe,%r12d
xor    %ebp,%ebp
movsd  %xmm1,(%rsp)
cs nopw 0x0(%rax,%rax,1)
nop
lea    0x1(%rbp),%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1040 <cos@plt>
lea    0x2(%rbp),%rbx
xorps  %xmm1,%xmm1
cvtsi2sd %ebx,%xmm1
movsd  %xmm0,0x0(%r13,%rbp,8)
mulsd  (%rsp),%xmm1
cvttsd2si %xmm1,%edi
call   1040 <cos@plt>
movsd  (%rsp),%xmm1
movsd  %xmm0,0x8(%r13,%rbp,8)
mov    %rbx,%rbp
cmp    %rbx,%r12
jne    1170 <cosqi+0x50>
test   $0x1,%r14b
je     11df <cosqi+0xbf>
lea    0x1(%rbx),%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  %xmm0,%xmm1
cvttsd2si %xmm1,%edi
call   1040 <cos@plt>
movsd  %xmm0,0x0(%r13,%rbx,8)
movslq %r15d,%rax
lea    0x0(,%rax,8),%rsi
add    %r13,%rsi
mov    %r15d,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <rffti@plt>

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

LLVM IR (-O2):
define void @cosqi(i32 %0, double* %1) {
%3 = sitofp i32 %0 to double
%4 = fdiv double 0x3FF921FB54442D55, %3
%5 = icmp sgt i32 %0, 0
br i1 %5, label %6, label %42
6: ; preds = %2
%7 = zext i32 %0 to i64
%8 = and i64 %7, 1
%9 = icmp eq i32 %0, 1
br i1 %9, label %31, label %10
10: ; preds = %6
%11 = and i64 %7, 4294967294
br label %12
12: ; preds = %12, %10
%13 = phi i64 [ 0, %10 ], [ %22, %12 ]
%14 = phi i64 [ 0, %10 ], [ %29, %12 ]
%15 = or i64 %13, 1
%16 = trunc i64 %15 to i32
%17 = sitofp i32 %16 to double
%18 = fmul double %4, %17
%19 = fptosi double %18 to i32
%20 = tail call double @cos(i32 %19)
%21 = getelementptr inbounds double, double* %1, i64 %13
store double %20, double* %21
%22 = add nuw nsw i64 %13, 2
%23 = trunc i64 %22 to i32
%24 = sitofp i32 %23 to double
%25 = fmul double %4, %24
%26 = fptosi double %25 to i32
%27 = tail call double @cos(i32 %26)
%28 = getelementptr inbounds double, double* %1, i64 %15
store double %27, double* %28
%29 = add i64 %14, 2
%30 = icmp eq i64 %29, %11
br i1 %30, label %31, label %12
31: ; preds = %12, %6
%32 = phi i64 [ 0, %6 ], [ %22, %12 ]
%33 = icmp eq i64 %8, 0
br i1 %33, label %42, label %34
34: ; preds = %31
%35 = trunc i64 %32 to i32
%36 = add i32 %35, 1
%37 = sitofp i32 %36 to double
%38 = fmul double %4, %37
%39 = fptosi double %38 to i32
%40 = tail call double @cos(i32 %39)
%41 = getelementptr inbounds double, double* %1, i64 %32
store double %40, double* %41
br label %42
42: ; preds = %34, %31, %2
%43 = sext i32 %0 to i64
%44 = getelementptr inbounds double, double* %1, i64 %43
%45 = tail call i32 @rffti(i32 %0, double* %44)
ret void
}