#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*/ dcsqb1(int, double *, double *, double *, int *);
void __ogg_fdcosqb(int n, double *x, double *wsave, int *ifac) {
  static double tsqrt2 = 2.8284271247461900976033774484194;
  double x1;
  if (n < 2) {
    x[0] *= 4;
    return;
  }
  if (n == 2) {
    x1 = (x[0] + x[1]) * 4;
    x[1] = tsqrt2 * (x[0] - x[1]);
    x[0] = x1;
    return;
  }
  dcsqb1(n, x, wsave, wsave + n, ifac);
}


x86 assembly (clang, -O0):
<__ogg_fdcosqb>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
cmpl   $0x2,-0x4(%rbp)
jge    114a <__ogg_fdcosqb+0x3a>
mov    -0x10(%rbp),%rax
movsd  0xec3(%rip),%xmm0
mulsd  (%rax),%xmm0
movsd  %xmm0,(%rax)
jmp    11d1 <__ogg_fdcosqb+0xc1>
cmpl   $0x2,-0x4(%rbp)
jne    11ae <__ogg_fdcosqb+0x9e>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x10(%rbp),%rax
addsd  0x8(%rax),%xmm0
movsd  0xe93(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0x2eaa(%rip),%xmm0
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm1
mov    -0x10(%rbp),%rax
subsd  0x8(%rax),%xmm1
mulsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x8(%rax)
movsd  -0x28(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    11d1 <__ogg_fdcosqb+0xc1>
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
mov    -0x20(%rbp),%r8
call   1030 <dcsqb1@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__ogg_fdcosqb>:
cmp    $0x1,%edi
jg     1126 <__ogg_fdcosqb+0x16>
movsd  (%rsi),%xmm0
mulsd  0xedf(%rip),%xmm0
movsd  %xmm0,(%rsi)
ret
cmp    $0x2,%edi
jne    115a <__ogg_fdcosqb+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    %rcx,%r8
mov    %edi,%eax
lea    (%rdx,%rax,8),%rcx
jmp    1030 <dcsqb1@plt>

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

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