#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*/ cosqb1(int, double *, double *, double *);
void cosqb(int n, double x[], double wsave[]) {
  static const double tsqrt2 = 2.82842712474619;
  double x1;
  if (n < 2) {
    x[0] *= 4;
  } else if (n == 2) {
    x1 = 4 * (x[0] + x[1]);
    x[1] = tsqrt2 * (x[0] - x[1]);
    x[0] = x1;
  } else
    cosqb1(n, x, wsave, &wsave[n]);
}


x86 assembly (clang, -O0):
<cosqb>:
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    1146 <cosqb+0x36>
mov    -0x10(%rbp),%rax
movsd  0xecf(%rip),%xmm0
mulsd  (%rax),%xmm0
movsd  %xmm0,(%rax)
jmp    11ce <cosqb+0xbe>
cmpl   $0x2,-0x4(%rbp)
jne    11aa <cosqb+0x9a>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm1
mov    -0x10(%rbp),%rax
addsd  0x8(%rax),%xmm1
movsd  0xe9f(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm1
mov    -0x10(%rbp),%rax
subsd  0x8(%rax),%xmm1
movsd  0xe75(%rip),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x8(%rax)
movsd  -0x20(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    11c9 <cosqb+0xb9>
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 <cosqb1@plt>
jmp    11ce <cosqb+0xbe>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cosqb>:
cmp    $0x1,%edi
jg     1126 <cosqb+0x16>
movsd  (%rsi),%xmm0
mulsd  0xedf(%rip),%xmm0
movsd  %xmm0,(%rsi)
ret
cmp    $0x2,%edi
jne    115a <cosqb+0x4a>
movsd  (%rsi),%xmm0
movsd  0x8(%rsi),%xmm1
movapd %xmm0,%xmm2
addsd  %xmm1,%xmm2
mulsd  0xebc(%rip),%xmm2
subsd  %xmm1,%xmm0
mulsd  0xeb8(%rip),%xmm0
movsd  %xmm0,0x8(%rsi)
movsd  %xmm2,(%rsi)
ret
mov    %edi,%eax
lea    (%rdx,%rax,8),%rcx
jmp    1030 <cosqb1@plt>

LLVM IR (-O0):
@cosqb.tsqrt2 = internal constant double 0x4006A09E667F3BCC
define void @cosqb(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 %15
10: ; preds = %3
%11 = load double*, double** %5
%12 = getelementptr inbounds double, double* %11, i64 0
%13 = load double, double* %12
%14 = fmul double %13, 4.000000e+00
store double %14, double* %12
br label %50
15: ; preds = %3
%16 = load i32, i32* %4
%17 = icmp eq i32 %16, 2
br i1 %17, label %18, label %40
18: ; preds = %15
%19 = load double*, double** %5
%20 = getelementptr inbounds double, double* %19, i64 0
%21 = load double, double* %20
%22 = load double*, double** %5
%23 = getelementptr inbounds double, double* %22, i64 1
%24 = load double, double* %23
%25 = fadd double %21, %24
%26 = fmul double 4.000000e+00, %25
store double %26, double* %7
%27 = load double*, double** %5
%28 = getelementptr inbounds double, double* %27, i64 0
%29 = load double, double* %28
%30 = load double*, double** %5
%31 = getelementptr inbounds double, double* %30, i64 1
%32 = load double, double* %31
%33 = fsub double %29, %32
%34 = fmul double 0x4006A09E667F3BCC, %33
%35 = load double*, double** %5
%36 = getelementptr inbounds double, double* %35, i64 1
store double %34, double* %36
%37 = load double, double* %7
%38 = load double*, double** %5
%39 = getelementptr inbounds double, double* %38, i64 0
store double %37, double* %39
br label %49
40: ; preds = %15
%41 = load i32, i32* %4
%42 = load double*, double** %5
%43 = load double*, double** %6
%44 = load double*, double** %6
%45 = load i32, i32* %4
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds double, double* %44, i64 %46
%48 = call i32 @cosqb1(i32 %41, double* %42, double* %43, double* %47)
br label %49
49: ; preds = %40, %18
br label %50
50: ; preds = %49, %10
ret void
}

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