#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 cos(int);
int /*<<< orphan*/ rffti(int, double *);
int sin(int);
void costi(int n, double wsave[]) {
  static const double pi = 3.14159265358979;
  int k, kc, ns2;
  double dt;
  if (n <= 3)
    return;
  ns2 = n / 2;
  dt = pi / (n - 1);
  for (k = 1; k < ns2; k++) {
    kc = n - k - 1;
    wsave[k] = 2 * sin(k * dt);
    wsave[kc] = 2 * cos(k * dt);
  }
  rffti(n - 1, &wsave[n]);
}


x86 assembly (clang, -O0):
<costi>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x4(%rbp)
jg     114e <costi+0x1e>
jmp    120c <costi+0xdc>
mov    -0x4(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x1c(%rbp)
mov    -0x4(%rbp),%eax
sub    $0x1,%eax
cvtsi2sd %eax,%xmm1
movsd  0xe92(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11f2 <costi+0xc2>
mov    -0x4(%rbp),%eax
sub    -0x14(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x18(%rbp)
cvtsi2sdl -0x14(%rbp),%xmm0
mulsd  -0x28(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1040 <sin@plt>
shl    $0x1,%eax
cvtsi2sd %eax,%xmm0
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
cvtsi2sdl -0x14(%rbp),%xmm0
mulsd  -0x28(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1050 <cos@plt>
shl    $0x1,%eax
cvtsi2sd %eax,%xmm0
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    117e <costi+0x4e>
mov    -0x4(%rbp),%edi
sub    $0x1,%edi
mov    -0x10(%rbp),%rsi
movslq -0x4(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rsi
call   1030 <rffti@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<costi>:
cmp    $0x4,%edi
jge    1136 <costi+0x6>
ret
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r13
mov    %edi,%r14d
lea    -0x1(%r14),%eax
mov    %eax,0xc(%rsp)
cvtsi2sd %eax,%xmm0
movsd  0xea2(%rip),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x10(%rsp)
mov    %edi,%r12d
shr    %r12d
lea    -0x2(%r14),%ebx
mov    $0x1,%r15d
nopl   0x0(%rax,%rax,1)
xorps  %xmm0,%xmm0
cvtsi2sd %r15d,%xmm0
mulsd  0x10(%rsp),%xmm0
cvttsd2si %xmm0,%ebp
mov    %ebp,%edi
call   1040 <sin@plt>
add    %eax,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,0x0(%r13,%r15,8)
mov    %ebp,%edi
call   1050 <cos@plt>
add    %eax,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movslq %ebx,%rbx
movsd  %xmm0,0x0(%r13,%rbx,8)
add    $0x1,%r15
add    $0xffffffff,%ebx
cmp    %r15,%r12
jne    1180 <costi+0x50>
movslq %r14d,%rax
lea    0x0(,%rax,8),%rsi
add    %r13,%rsi
mov    0xc(%rsp),%edi
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <rffti@plt>

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

LLVM IR (-O2):
define void @costi(i32 %0, double* %1) {
%3 = icmp slt i32 %0, 4
br i1 %3, label %34, label %4
4: ; preds = %2
%5 = add nsw i32 %0, -1
%6 = sitofp i32 %5 to double
%7 = fdiv double 0x400921FB54442D11, %6
%8 = lshr i32 %0, 1
%9 = zext i32 %8 to i64
br label %10
10: ; preds = %4, %10
%11 = phi i64 [ 1, %4 ], [ %28, %10 ]
%12 = trunc i64 %11 to i32
%13 = xor i32 %12, -1
%14 = add i32 %13, %0
%15 = trunc i64 %11 to i32
%16 = sitofp i32 %15 to double
%17 = fmul double %7, %16
%18 = fptosi double %17 to i32
%19 = tail call i32 @sin(i32 %18)
%20 = shl nsw i32 %19, 1
%21 = sitofp i32 %20 to double
%22 = getelementptr inbounds double, double* %1, i64 %11
store double %21, double* %22
%23 = tail call i32 @cos(i32 %18)
%24 = shl nsw i32 %23, 1
%25 = sitofp i32 %24 to double
%26 = sext i32 %14 to i64
%27 = getelementptr inbounds double, double* %1, i64 %26
store double %25, double* %27
%28 = add nuw nsw i64 %11, 1
%29 = icmp eq i64 %28, %9
br i1 %29, label %30, label %10
30: ; preds = %10
%31 = sext i32 %0 to i64
%32 = getelementptr inbounds double, double* %1, i64 %31
%33 = tail call i32 @rffti(i32 %5, double* %32)
br label %34
34: ; preds = %2, %30
ret void
}