#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*/ cosqf1(int, double *, double *, double *);
void cosqf(int n, double x[], double wsave[]) {
  static const double sqrt2 = 1.4142135623731;
  double tsqx;
  if (n < 2) {
    return;
  } else if (n == 2) {
    tsqx = sqrt2 * x[1];
    x[1] = x[0] - tsqx;
    x[0] += tsqx;
  } else {
    cosqf1(n, x, wsave, &wsave[n]);
  }
}


x86 assembly (clang, -O0):
<cosqf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
cmpl   $0x2,-0x4(%rbp)
jge    1132 <cosqf+0x22>
jmp    11a2 <cosqf+0x92>
cmpl   $0x2,-0x4(%rbp)
jne    117e <cosqf+0x6e>
mov    -0x10(%rbp),%rax
movsd  0xeb8(%rip),%xmm0
mulsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
subsd  -0x20(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x8(%rax)
movsd  -0x20(%rbp),%xmm0
mov    -0x10(%rbp),%rax
addsd  (%rax),%xmm0
movsd  %xmm0,(%rax)
jmp    119d <cosqf+0x8d>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x18(%rbp),%rcx
movslq -0x4(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rcx
call   1030 <cosqf1@plt>
jmp    11a2 <cosqf+0x92>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cosqf>:
cmp    $0x2,%edi
jl     113d <cosqf+0x2d>
jne    113e <cosqf+0x2e>
movsd  (%rsi),%xmm0
movsd  0x8(%rsi),%xmm1
mulsd  0xed8(%rip),%xmm1
movapd %xmm0,%xmm2
subsd  %xmm1,%xmm2
movsd  %xmm2,0x8(%rsi)
addsd  %xmm0,%xmm1
movsd  %xmm1,(%rsi)
ret
mov    %edi,%eax
lea    (%rdx,%rax,8),%rcx
jmp    1030 <cosqf1@plt>

LLVM IR (-O0):
@cosqf.sqrt2 = internal constant double 0x3FF6A09E667F3BE3
define void @cosqf(i32 %0, double* %1, double* %2) {
%4 = alloca i32
%5 = alloca double*
%6 = alloca double*
%7 = alloca double
store i32 %0, i32* %4
store double* %1, double** %5
store double* %2, double** %6
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 2
br i1 %9, label %10, label %11
10: ; preds = %3
br label %41
11: ; preds = %3
%12 = load i32, i32* %4
%13 = icmp eq i32 %12, 2
br i1 %13, label %14, label %31
14: ; preds = %11
%15 = load double*, double** %5
%16 = getelementptr inbounds double, double* %15, i64 1
%17 = load double, double* %16
%18 = fmul double 0x3FF6A09E667F3BE3, %17
store double %18, double* %7
%19 = load double*, double** %5
%20 = getelementptr inbounds double, double* %19, i64 0
%21 = load double, double* %20
%22 = load double, double* %7
%23 = fsub double %21, %22
%24 = load double*, double** %5
%25 = getelementptr inbounds double, double* %24, i64 1
store double %23, double* %25
%26 = load double, double* %7
%27 = load double*, double** %5
%28 = getelementptr inbounds double, double* %27, i64 0
%29 = load double, double* %28
%30 = fadd double %29, %26
store double %30, double* %28
br label %40
31: ; preds = %11
%32 = load i32, i32* %4
%33 = load double*, double** %5
%34 = load double*, double** %6
%35 = load double*, double** %6
%36 = load i32, i32* %4
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds double, double* %35, i64 %37
%39 = call i32 @cosqf1(i32 %32, double* %33, double* %34, double* %38)
br label %40
40: ; preds = %31, %14
br label %41
41: ; preds = %10, %40
ret void
}

LLVM IR (-O2):
define void @cosqf(i32 %0, double* %1, double* %2) {
%4 = icmp slt i32 %0, 2
br i1 %4, label %18, label %5
5: ; preds = %3
%6 = icmp eq i32 %0, 2
br i1 %6, label %7, label %14
7: ; preds = %5
%8 = getelementptr inbounds double, double* %1, i64 1
%9 = load double, double* %8
%10 = fmul double %9, 0x3FF6A09E667F3BE3
%11 = load double, double* %1
%12 = fsub double %11, %10
store double %12, double* %8
%13 = fadd double %11, %10
store double %13, double* %1
br label %18
14: ; preds = %5
%15 = zext i32 %0 to i64
%16 = getelementptr inbounds double, double* %2, i64 %15
%17 = tail call i32 @cosqf1(i32 %0, double* %1, double* %2, double* %16)
br label %18
18: ; preds = %14, %7, %3
ret void
}