#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 */
scalar_t__ CheckPointerDouble(double *, char *);
int /*<<< orphan*/ IsPowerOfTwo(unsigned int);
unsigned int NumberOfBitsNeeded(unsigned int);
unsigned int ReverseBits(unsigned int, unsigned int);
double cos(double);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, unsigned int);
double sin(double);
int /*<<< orphan*/ stderr;
int fft_double(unsigned NumSamples, int InverseTransform, double *RealIn,
               double *ImagIn, double *RealOut, double *ImagOut) {
  unsigned NumBits;
  unsigned i, j, k, n;
  unsigned BlockSize, BlockEnd;
  double angle_numerator = -2.0 * (3.14159265358979323846);
  double tr, ti;
  if (!IsPowerOfTwo(NumSamples) || (NumSamples < 2)) {
    fprintf(stderr, "Error in fft():  NumSamples=%u is not power of two\n",
            NumSamples);
    return 0;
  }
  if (InverseTransform)
    angle_numerator = -angle_numerator;
  if (CheckPointerDouble(RealIn, "RealIn") == 0)
    return 0;
  ;
  if (CheckPointerDouble(RealOut, "RealOut") == 0)
    return 0;
  ;
  if (CheckPointerDouble(ImagOut, "ImagOut") == 0)
    return 0;
  ;
  NumBits = NumberOfBitsNeeded(NumSamples);
  for (i = 0; i < NumSamples; i++) {
    j = ReverseBits(i, NumBits);
    RealOut[j] = RealIn[i];
    ImagOut[j] = (ImagIn == NULL) ? 0.0 : ImagIn[i];
  }
  BlockEnd = 1;
  for (BlockSize = 2; BlockSize <= NumSamples; BlockSize <<= 1) {
    double delta_angle = angle_numerator / (double)BlockSize;
    double sm2 = sin(-2 * delta_angle);
    double sm1 = sin(-delta_angle);
    double cm2 = cos(-2 * delta_angle);
    double cm1 = cos(-delta_angle);
    double w = 2 * cm1;
    double ar0, ar1, ar2, ai0, ai1, ai2;
    for (i = 0; i < NumSamples; i += BlockSize) {
      ar2 = cm2;
      ar1 = cm1;
      ai2 = sm2;
      ai1 = sm1;
      for (j = i, n = 0; n < BlockEnd; j++, n++) {
        ar0 = w * ar1 - ar2;
        ar2 = ar1;
        ar1 = ar0;
        ai0 = w * ai1 - ai2;
        ai2 = ai1;
        ai1 = ai0;
        k = j + BlockEnd;
        tr = ar0 * RealOut[k] - ai0 * ImagOut[k];
        ti = ar0 * ImagOut[k] + ai0 * RealOut[k];
        RealOut[k] = RealOut[j] - tr;
        ImagOut[k] = ImagOut[j] - ti;
        RealOut[j] += tr;
        ImagOut[j] += ti;
      }
    }
    BlockEnd = BlockSize;
  }
  if (InverseTransform) {
    double denom = (double)NumSamples;
    for (i = 0; i < NumSamples; i++) {
      RealOut[i] /= denom;
      ImagOut[i] /= denom;
    }
  }
  return 1;
}


x86 assembly (clang, -O0):
<fft_double>:
push   %rbp
mov    %rsp,%rbp
sub    $0xe0,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
movsd  0xe67(%rip),%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    -0x8(%rbp),%edi
call   1040 <IsPowerOfTwo@plt>
cmp    $0x0,%eax
je     11b9 <fft_double+0x49>
cmpl   $0x2,-0x8(%rbp)
jae    11dd <fft_double+0x6d>
mov    0x2e20(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%edx
lea    0xe4c(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    16aa <fft_double+0x53a>
cmpl   $0x0,-0xc(%rbp)
je     1208 <fft_double+0x98>
movsd  -0x58(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe39(%rip),%rsi
call   1070 <CheckPointerDouble@plt>
cmp    $0x0,%rax
jne    122e <fft_double+0xbe>
movl   $0x0,-0x4(%rbp)
jmp    16aa <fft_double+0x53a>
mov    -0x28(%rbp),%rdi
lea    0xe1a(%rip),%rsi
call   1070 <CheckPointerDouble@plt>
cmp    $0x0,%rax
jne    1254 <fft_double+0xe4>
movl   $0x0,-0x4(%rbp)
jmp    16aa <fft_double+0x53a>
mov    -0x30(%rbp),%rdi
lea    0xdfc(%rip),%rsi
call   1070 <CheckPointerDouble@plt>
cmp    $0x0,%rax
jne    127a <fft_double+0x10a>
movl   $0x0,-0x4(%rbp)
jmp    16aa <fft_double+0x53a>
mov    -0x8(%rbp),%edi
call   1030 <NumberOfBitsNeeded@plt>
mov    %eax,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0x8(%rbp),%eax
jae    130f <fft_double+0x19f>
mov    -0x38(%rbp),%edi
mov    -0x34(%rbp),%esi
call   1090 <ReverseBits@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x38(%rbp),%ecx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x28(%rbp),%rax
mov    -0x3c(%rbp),%ecx
movsd  %xmm0,(%rax,%rcx,8)
cmpq   $0x0,-0x20(%rbp)
jne    12d9 <fft_double+0x169>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0xd8(%rbp)
ff
jmp    12ed <fft_double+0x17d>
mov    -0x20(%rbp),%rax
mov    -0x38(%rbp),%ecx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0xd8(%rbp)
ff
movsd  -0xd8(%rbp),%xmm0
ff
mov    -0x30(%rbp),%rax
mov    -0x3c(%rbp),%ecx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    128c <fft_double+0x11c>
movl   $0x1,-0x4c(%rbp)
movl   $0x2,-0x48(%rbp)
mov    -0x48(%rbp),%eax
cmp    -0x8(%rbp),%eax
ja     1629 <fft_double+0x4b9>
movsd  -0x58(%rbp),%xmm0
mov    -0x48(%rbp),%eax
cvtsi2sd %rax,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  0xcc9(%rip),%xmm0
mulsd  -0x70(%rbp),%xmm0
call   1060 <sin@plt>
movsd  %xmm0,-0x78(%rbp)
movsd  -0x70(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
call   1060 <sin@plt>
movsd  %xmm0,-0x80(%rbp)
movsd  0xc8c(%rip),%xmm0
mulsd  -0x70(%rbp),%xmm0
call   1080 <cos@plt>
movsd  %xmm0,-0x88(%rbp)
ff
movsd  -0x70(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
call   1080 <cos@plt>
movsd  %xmm0,-0x90(%rbp)
ff
movsd  0xc41(%rip),%xmm0
mulsd  -0x90(%rbp),%xmm0
ff
movsd  %xmm0,-0x98(%rbp)
ff
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0x8(%rbp),%eax
jae    1615 <fft_double+0x4a5>
movsd  -0x88(%rbp),%xmm0
ff
movsd  %xmm0,-0xb0(%rbp)
ff
movsd  -0x90(%rbp),%xmm0
ff
movsd  %xmm0,-0xa8(%rbp)
ff
movsd  -0x78(%rbp),%xmm0
movsd  %xmm0,-0xc8(%rbp)
ff
movsd  -0x80(%rbp),%xmm0
movsd  %xmm0,-0xc0(%rbp)
ff
mov    -0x38(%rbp),%eax
mov    %eax,-0x3c(%rbp)
movl   $0x0,-0x44(%rbp)
mov    -0x44(%rbp),%eax
cmp    -0x4c(%rbp),%eax
jae    1602 <fft_double+0x492>
movsd  -0x98(%rbp),%xmm0
ff
movsd  -0xa8(%rbp),%xmm2
ff
movsd  -0xb0(%rbp),%xmm1
ff
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0xa0(%rbp)
ff
movsd  -0xa8(%rbp),%xmm0
ff
movsd  %xmm0,-0xb0(%rbp)
ff
movsd  -0xa0(%rbp),%xmm0
ff
movsd  %xmm0,-0xa8(%rbp)
ff
movsd  -0x98(%rbp),%xmm0
ff
movsd  -0xc0(%rbp),%xmm2
ff
movsd  -0xc8(%rbp),%xmm1
ff
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0xb8(%rbp)
ff
movsd  -0xc0(%rbp),%xmm0
ff
movsd  %xmm0,-0xc8(%rbp)
ff
movsd  -0xb8(%rbp),%xmm0
ff
movsd  %xmm0,-0xc0(%rbp)
ff
mov    -0x3c(%rbp),%eax
add    -0x4c(%rbp),%eax
mov    %eax,-0x40(%rbp)
movsd  -0xa0(%rbp),%xmm0
ff
mov    -0x28(%rbp),%rax
mov    -0x40(%rbp),%ecx
movsd  (%rax,%rcx,8),%xmm2
movsd  -0xb8(%rbp),%xmm1
ff
mov    -0x30(%rbp),%rax
mov    -0x40(%rbp),%ecx
mulsd  (%rax,%rcx,8),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0xa0(%rbp),%xmm0
ff
mov    -0x30(%rbp),%rax
mov    -0x40(%rbp),%ecx
movsd  (%rax,%rcx,8),%xmm2
movsd  -0xb8(%rbp),%xmm1
ff
mov    -0x28(%rbp),%rax
mov    -0x40(%rbp),%ecx
mulsd  (%rax,%rcx,8),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
mov    -0x28(%rbp),%rax
mov    -0x3c(%rbp),%ecx
movsd  (%rax,%rcx,8),%xmm0
subsd  -0x60(%rbp),%xmm0
mov    -0x28(%rbp),%rax
mov    -0x40(%rbp),%ecx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x30(%rbp),%rax
mov    -0x3c(%rbp),%ecx
movsd  (%rax,%rcx,8),%xmm0
subsd  -0x68(%rbp),%xmm0
mov    -0x30(%rbp),%rax
mov    -0x40(%rbp),%ecx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x60(%rbp),%xmm0
mov    -0x28(%rbp),%rax
mov    -0x3c(%rbp),%ecx
addsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x68(%rbp),%xmm0
mov    -0x30(%rbp),%rax
mov    -0x3c(%rbp),%ecx
addsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    1431 <fft_double+0x2c1>
jmp    1607 <fft_double+0x497>
mov    -0x48(%rbp),%eax
add    -0x38(%rbp),%eax
mov    %eax,-0x38(%rbp)
jmp    13de <fft_double+0x26e>
mov    -0x48(%rbp),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x48(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x48(%rbp)
jmp    131d <fft_double+0x1ad>
cmpl   $0x0,-0xc(%rbp)
je     16a3 <fft_double+0x533>
mov    -0x8(%rbp),%eax
cvtsi2sd %rax,%xmm0
movsd  %xmm0,-0xd0(%rbp)
ff
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0x8(%rbp),%eax
jae    169e <fft_double+0x52e>
movsd  -0xd0(%rbp),%xmm1
ff
mov    -0x28(%rbp),%rax
mov    -0x38(%rbp),%ecx
movsd  (%rax,%rcx,8),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0xd0(%rbp),%xmm1
ff
mov    -0x30(%rbp),%rax
mov    -0x38(%rbp),%ecx
movsd  (%rax,%rcx,8),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    164a <fft_double+0x4da>
jmp    16a3 <fft_double+0x533>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xe0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fft_double>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
mov    %r9,%r14
mov    %r8,%rbx
mov    %rcx,%rbp
mov    %rdx,0x8(%rsp)
mov    %esi,%r12d
mov    %edi,%r13d
call   1040 <IsPowerOfTwo@plt>
cmp    $0x2,%r13d
jb     1283 <fft_double+0x113>
test   %eax,%eax
je     1283 <fft_double+0x113>
xor    %r15d,%r15d
mov    %r12d,0x1c(%rsp)
test   %r12d,%r12d
sete   0x30(%rsp)
lea    0xe9c(%rip),%rsi
mov    0x8(%rsp),%rdi
call   1070 <CheckPointerDouble@plt>
xor    %r12d,%r12d
test   %rax,%rax
je     129e <fft_double+0x12e>
lea    0xe86(%rip),%rsi
mov    %rbx,%rdi
call   1070 <CheckPointerDouble@plt>
test   %rax,%rax
je     129e <fft_double+0x12e>
lea    0xe76(%rip),%rsi
mov    %r14,%rdi
call   1070 <CheckPointerDouble@plt>
test   %rax,%rax
je     129e <fft_double+0x12e>
mov    %r13d,%eax
mov    %rax,0x10(%rsp)
mov    0x30(%rsp),%al
mov    %al,%r15b
lea    0xde4(%rip),%rax
movsd  (%rax,%r15,8),%xmm0
movsd  %xmm0,0x48(%rsp)
mov    %r13d,%edi
call   1030 <NumberOfBitsNeeded@plt>
mov    %eax,%r12d
xor    %r15d,%r15d
jmp    125b <fft_double+0xeb>
nopl   0x0(%rax,%rax,1)
movsd  0x0(%rbp,%r15,8),%xmm0
mov    0x10(%rsp),%rcx
movsd  %xmm0,(%r14,%rax,8)
add    $0x1,%r15
cmp    %r15,%rcx
je     12b0 <fft_double+0x140>
mov    %r15d,%edi
mov    %r12d,%esi
call   1090 <ReverseBits@plt>
mov    0x8(%rsp),%rcx
movsd  (%rcx,%r15,8),%xmm0
mov    %eax,%eax
movsd  %xmm0,(%rbx,%rax,8)
test   %rbp,%rbp
jne    1240 <fft_double+0xd0>
xorpd  %xmm0,%xmm0
jmp    1247 <fft_double+0xd7>
mov    0x2d56(%rip),%rax
mov    (%rax),%edi
lea    0xd95(%rip),%rsi
mov    %r13d,%edx
call   1050 <fprintf@plt>
xor    %r12d,%r12d
mov    %r12d,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0x1,%ebp
mov    $0x2,%eax
jmp    12d0 <fft_double+0x160>
nopl   0x0(%rax)
lea    (%r15,%r15,1),%eax
mov    %r15d,%ebp
cmp    %r13d,%eax
ja     141d <fft_double+0x2ad>
mov    %eax,%r15d
mov    %eax,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  0x48(%rsp),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
movapd %xmm1,%xmm0
mulsd  0xd27(%rip),%xmm0
movsd  %xmm0,0x20(%rsp)
call   1060 <sin@plt>
movapd %xmm0,0x30(%rsp)
movsd  0x8(%rsp),%xmm0
call   1060 <sin@plt>
xorps  0xcf4(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movsd  0x20(%rsp),%xmm0
call   1080 <cos@plt>
movaps %xmm0,0x20(%rsp)
movsd  0x8(%rsp),%xmm0
call   1080 <cos@plt>
movapd 0x50(%rsp),%xmm8
movapd 0x30(%rsp),%xmm7
unpcklpd 0x20(%rsp),%xmm7
unpcklpd %xmm0,%xmm8
addsd  %xmm0,%xmm0
unpcklpd %xmm0,%xmm0
xor    %eax,%eax
mov    %ebp,%ecx
jmp    137f <fft_double+0x20f>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    %r15d,%eax
add    %r15d,%ecx
cmp    %r13d,%eax
jae    12c0 <fft_double+0x150>
test   %ebp,%ebp
je     1370 <fft_double+0x200>
xor    %edx,%edx
movapd %xmm8,%xmm1
movapd %xmm7,%xmm3
xchg   %ax,%ax
movapd %xmm1,%xmm2
lea    (%rax,%rdx,1),%esi
movapd %xmm0,%xmm1
mulpd  %xmm2,%xmm1
lea    (%rcx,%rdx,1),%edi
movsd  (%rbx,%rdi,8),%xmm4
subpd  %xmm3,%xmm1
movsd  (%r14,%rdi,8),%xmm3
movapd %xmm1,%xmm5
unpckhpd %xmm1,%xmm5
movapd %xmm5,%xmm6
mulsd  %xmm3,%xmm5
mulsd  %xmm1,%xmm3
mulsd  %xmm4,%xmm6
subsd  %xmm3,%xmm6
movsd  (%rbx,%rsi,8),%xmm3
mulsd  %xmm1,%xmm4
subsd  %xmm6,%xmm3
movsd  %xmm3,(%rbx,%rdi,8)
movsd  (%r14,%rsi,8),%xmm3
addsd  %xmm4,%xmm5
subsd  %xmm5,%xmm3
movsd  %xmm3,(%r14,%rdi,8)
addsd  (%rbx,%rsi,8),%xmm6
movsd  %xmm6,(%rbx,%rsi,8)
addsd  (%r14,%rsi,8),%xmm5
movsd  %xmm5,(%r14,%rsi,8)
add    $0x1,%edx
movapd %xmm2,%xmm3
cmp    %edx,%ebp
jne    1390 <fft_double+0x220>
jmp    1370 <fft_double+0x200>
mov    $0x1,%r12d
cmpl   $0x0,0x1c(%rsp)
je     129e <fft_double+0x12e>
mov    0x10(%rsp),%rdi
xorps  %xmm0,%xmm0
cvtsi2sd %rdi,%xmm0
cmp    $0x2,%edi
jae    1447 <fft_double+0x2d7>
xor    %eax,%eax
jmp    1510 <fft_double+0x3a0>
lea    (%r14,%rdi,8),%rax
cmp    %rbx,%rax
jbe    1460 <fft_double+0x2f0>
lea    (%rbx,%rdi,8),%rax
cmp    %r14,%rax
jbe    1460 <fft_double+0x2f0>
xor    %eax,%eax
jmp    1510 <fft_double+0x3a0>
mov    %edi,%eax
and    $0xfffffffe,%eax
movapd %xmm0,%xmm1
unpcklpd %xmm0,%xmm1
lea    -0x2(%rax),%rcx
mov    %rcx,%rdx
shr    %rdx
add    $0x1,%rdx
test   %rcx,%rcx
je     14dc <fft_double+0x36c>
mov    %rdx,%rsi
and    $0xfffffffffffffffe,%rsi
xor    %ecx,%ecx
nopl   0x0(%rax)
movupd (%rbx,%rcx,8),%xmm2
divpd  %xmm1,%xmm2
movupd %xmm2,(%rbx,%rcx,8)
movupd (%r14,%rcx,8),%xmm2
divpd  %xmm1,%xmm2
movupd %xmm2,(%r14,%rcx,8)
movupd 0x10(%rbx,%rcx,8),%xmm2
divpd  %xmm1,%xmm2
movupd %xmm2,0x10(%rbx,%rcx,8)
movupd 0x10(%r14,%rcx,8),%xmm2
divpd  %xmm1,%xmm2
movupd %xmm2,0x10(%r14,%rcx,8)
add    $0x4,%rcx
add    $0xfffffffffffffffe,%rsi
jne    1490 <fft_double+0x320>
jmp    14de <fft_double+0x36e>
xor    %ecx,%ecx
test   $0x1,%dl
je     1501 <fft_double+0x391>
movupd (%rbx,%rcx,8),%xmm2
divpd  %xmm1,%xmm2
movupd %xmm2,(%rbx,%rcx,8)
movupd (%r14,%rcx,8),%xmm2
divpd  %xmm1,%xmm2
movupd %xmm2,(%r14,%rcx,8)
cmp    %rdi,%rax
je     129e <fft_double+0x12e>
nopw   0x0(%rax,%rax,1)
movsd  (%rbx,%rax,8),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,(%rbx,%rax,8)
movsd  (%r14,%rax,8),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,(%r14,%rax,8)
add    $0x1,%rax
cmp    %rax,%rdi
jne    1510 <fft_double+0x3a0>
jmp    129e <fft_double+0x12e>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [52 x i8] c"Error in fft(): NumSamples=%u is not power of two\0A\00"
@.str.1 = [7 x i8] c"RealIn\00"
@.str.2 = [8 x i8] c"RealOut\00"
@.str.3 = [8 x i8] c"ImagOut\00"
define i32 @fft_double(i32 %0, i32 %1, double* %2, double* %3, double* %4, double* %5) {
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca double*
%11 = alloca double*
%12 = alloca double*
%13 = alloca double*
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = alloca double
%22 = alloca double
%23 = alloca double
%24 = alloca double
%25 = alloca double
%26 = alloca double
%27 = alloca double
%28 = alloca double
%29 = alloca double
%30 = alloca double
%31 = alloca double
%32 = alloca double
%33 = alloca double
%34 = alloca double
%35 = alloca double
%36 = alloca double
store i32 %0, i32* %8
store i32 %1, i32* %9
store double* %2, double** %10
store double* %3, double** %11
store double* %4, double** %12
store double* %5, double** %13
store double 0xC01921FB54442D18, double* %21
%37 = load i32, i32* %8
%38 = call i32 @IsPowerOfTwo(i32 %37)
%39 = icmp ne i32 %38, 0
br i1 %39, label %40, label %43
40: ; preds = %6
%41 = load i32, i32* %8
%42 = icmp ult i32 %41, 2
br i1 %42, label %43, label %47
43: ; preds = %40, %6
%44 = load i32, i32* @stderr
%45 = load i32, i32* %8
%46 = call i32 @fprintf(i32 %44, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0), i32 %45)
store i32 0, i32* %7
br label %272
47: ; preds = %40
%48 = load i32, i32* %9
%49 = icmp ne i32 %48, 0
br i1 %49, label %50, label %53
50: ; preds = %47
%51 = load double, double* %21
%52 = fneg double %51
store double %52, double* %21
br label %53
53: ; preds = %50, %47
%54 = load double*, double** %10
%55 = call i64 @CheckPointerDouble(double* %54, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%56 = icmp eq i64 %55, 0
br i1 %56, label %57, label %58
57: ; preds = %53
store i32 0, i32* %7
br label %272
58: ; preds = %53
%59 = load double*, double** %12
%60 = call i64 @CheckPointerDouble(double* %59, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%61 = icmp eq i64 %60, 0
br i1 %61, label %62, label %63
62: ; preds = %58
store i32 0, i32* %7
br label %272
63: ; preds = %58
%64 = load double*, double** %13
%65 = call i64 @CheckPointerDouble(double* %64, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%66 = icmp eq i64 %65, 0
br i1 %66, label %67, label %68
67: ; preds = %63
store i32 0, i32* %7
br label %272
68: ; preds = %63
%69 = load i32, i32* %8
%70 = call i32 @NumberOfBitsNeeded(i32 %69)
store i32 %70, i32* %14
store i32 0, i32* %15
br label %71
71: ; preds = %103, %68
%72 = load i32, i32* %15
%73 = load i32, i32* %8
%74 = icmp ult i32 %72, %73
br i1 %74, label %75, label %106
75: ; preds = %71
%76 = load i32, i32* %15
%77 = load i32, i32* %14
%78 = call i32 @ReverseBits(i32 %76, i32 %77)
store i32 %78, i32* %16
%79 = load double*, double** %10
%80 = load i32, i32* %15
%81 = zext i32 %80 to i64
%82 = getelementptr inbounds double, double* %79, i64 %81
%83 = load double, double* %82
%84 = load double*, double** %12
%85 = load i32, i32* %16
%86 = zext i32 %85 to i64
%87 = getelementptr inbounds double, double* %84, i64 %86
store double %83, double* %87
%88 = load double*, double** %11
%89 = icmp eq double* %88, null
br i1 %89, label %90, label %91
90: ; preds = %75
br label %97
91: ; preds = %75
%92 = load double*, double** %11
%93 = load i32, i32* %15
%94 = zext i32 %93 to i64
%95 = getelementptr inbounds double, double* %92, i64 %94
%96 = load double, double* %95
br label %97
97: ; preds = %91, %90
%98 = phi double [ 0.000000e+00, %90 ], [ %96, %91 ]
%99 = load double*, double** %13
%100 = load i32, i32* %16
%101 = zext i32 %100 to i64
%102 = getelementptr inbounds double, double* %99, i64 %101
store double %98, double* %102
br label %103
103: ; preds = %97
%104 = load i32, i32* %15
%105 = add i32 %104, 1
store i32 %105, i32* %15
br label %71
106: ; preds = %71
store i32 1, i32* %20
store i32 2, i32* %19
br label %107
107: ; preds = %239, %106
%108 = load i32, i32* %19
%109 = load i32, i32* %8
%110 = icmp ule i32 %108, %109
br i1 %110, label %111, label %242
111: ; preds = %107
%112 = load double, double* %21
%113 = load i32, i32* %19
%114 = uitofp i32 %113 to double
%115 = fdiv double %112, %114
store double %115, double* %24
%116 = load double, double* %24
%117 = fmul double -2.000000e+00, %116
%118 = call double @sin(double %117)
store double %118, double* %25
%119 = load double, double* %24
%120 = fneg double %119
%121 = call double @sin(double %120)
store double %121, double* %26
%122 = load double, double* %24
%123 = fmul double -2.000000e+00, %122
%124 = call double @cos(double %123)
store double %124, double* %27
%125 = load double, double* %24
%126 = fneg double %125
%127 = call double @cos(double %126)
store double %127, double* %28
%128 = load double, double* %28
%129 = fmul double 2.000000e+00, %128
store double %129, double* %29
store i32 0, i32* %15
br label %130
130: ; preds = %233, %111
%131 = load i32, i32* %15
%132 = load i32, i32* %8
%133 = icmp ult i32 %131, %132
br i1 %133, label %134, label %237
134: ; preds = %130
%135 = load double, double* %27
store double %135, double* %32
%136 = load double, double* %28
store double %136, double* %31
%137 = load double, double* %25
store double %137, double* %35
%138 = load double, double* %26
store double %138, double* %34
%139 = load i32, i32* %15
store i32 %139, i32* %16
store i32 0, i32* %18
br label %140
140: ; preds = %227, %134
%141 = load i32, i32* %18
%142 = load i32, i32* %20
%143 = icmp ult i32 %141, %142
br i1 %143, label %144, label %232
144: ; preds = %140
%145 = load double, double* %29
%146 = load double, double* %31
%147 = load double, double* %32
%148 = fneg double %147
%149 = call double @llvm.fmuladd.f64(double %145, double %146, double %148)
store double %149, double* %30
%150 = load double, double* %31
store double %150, double* %32
%151 = load double, double* %30
store double %151, double* %31
%152 = load double, double* %29
%153 = load double, double* %34
%154 = load double, double* %35
%155 = fneg double %154
%156 = call double @llvm.fmuladd.f64(double %152, double %153, double %155)
store double %156, double* %33
%157 = load double, double* %34
store double %157, double* %35
%158 = load double, double* %33
store double %158, double* %34
%159 = load i32, i32* %16
%160 = load i32, i32* %20
%161 = add i32 %159, %160
store i32 %161, i32* %17
%162 = load double, double* %30
%163 = load double*, double** %12
%164 = load i32, i32* %17
%165 = zext i32 %164 to i64
%166 = getelementptr inbounds double, double* %163, i64 %165
%167 = load double, double* %166
%168 = load double, double* %33
%169 = load double*, double** %13
%170 = load i32, i32* %17
%171 = zext i32 %170 to i64
%172 = getelementptr inbounds double, double* %169, i64 %171
%173 = load double, double* %172
%174 = fmul double %168, %173
%175 = fneg double %174
%176 = call double @llvm.fmuladd.f64(double %162, double %167, double %175)
store double %176, double* %22
%177 = load double, double* %30
%178 = load double*, double** %13
%179 = load i32, i32* %17
%180 = zext i32 %179 to i64
%181 = getelementptr inbounds double, double* %178, i64 %180
%182 = load double, double* %181
%183 = load double, double* %33
%184 = load double*, double** %12
%185 = load i32, i32* %17
%186 = zext i32 %185 to i64
%187 = getelementptr inbounds double, double* %184, i64 %186
%188 = load double, double* %187
%189 = fmul double %183, %188
%190 = call double @llvm.fmuladd.f64(double %177, double %182, double %189)
store double %190, double* %23
%191 = load double*, double** %12
%192 = load i32, i32* %16
%193 = zext i32 %192 to i64
%194 = getelementptr inbounds double, double* %191, i64 %193
%195 = load double, double* %194
%196 = load double, double* %22
%197 = fsub double %195, %196
%198 = load double*, double** %12
%199 = load i32, i32* %17
%200 = zext i32 %199 to i64
%201 = getelementptr inbounds double, double* %198, i64 %200
store double %197, double* %201
%202 = load double*, double** %13
%203 = load i32, i32* %16
%204 = zext i32 %203 to i64
%205 = getelementptr inbounds double, double* %202, i64 %204
%206 = load double, double* %205
%207 = load double, double* %23
%208 = fsub double %206, %207
%209 = load double*, double** %13
%210 = load i32, i32* %17
%211 = zext i32 %210 to i64
%212 = getelementptr inbounds double, double* %209, i64 %211
store double %208, double* %212
%213 = load double, double* %22
%214 = load double*, double** %12
%215 = load i32, i32* %16
%216 = zext i32 %215 to i64
%217 = getelementptr inbounds double, double* %214, i64 %216
%218 = load double, double* %217
%219 = fadd double %218, %213
store double %219, double* %217
%220 = load double, double* %23
%221 = load double*, double** %13
%222 = load i32, i32* %16
%223 = zext i32 %222 to i64
%224 = getelementptr inbounds double, double* %221, i64 %223
%225 = load double, double* %224
%226 = fadd double %225, %220
store double %226, double* %224
br label %227
227: ; preds = %144
%228 = load i32, i32* %16
%229 = add i32 %228, 1
store i32 %229, i32* %16
%230 = load i32, i32* %18
%231 = add i32 %230, 1
store i32 %231, i32* %18
br label %140
232: ; preds = %140
br label %233
233: ; preds = %232
%234 = load i32, i32* %19
%235 = load i32, i32* %15
%236 = add i32 %235, %234
store i32 %236, i32* %15
br label %130
237: ; preds = %130
%238 = load i32, i32* %19
store i32 %238, i32* %20
br label %239
239: ; preds = %237
%240 = load i32, i32* %19
%241 = shl i32 %240, 1
store i32 %241, i32* %19
br label %107
242: ; preds = %107
%243 = load i32, i32* %9
%244 = icmp ne i32 %243, 0
br i1 %244, label %245, label %271
245: ; preds = %242
%246 = load i32, i32* %8
%247 = uitofp i32 %246 to double
store double %247, double* %36
store i32 0, i32* %15
br label %248
248: ; preds = %267, %245
%249 = load i32, i32* %15
%250 = load i32, i32* %8
%251 = icmp ult i32 %249, %250
br i1 %251, label %252, label %270
252: ; preds = %248
%253 = load double, double* %36
%254 = load double*, double** %12
%255 = load i32, i32* %15
%256 = zext i32 %255 to i64
%257 = getelementptr inbounds double, double* %254, i64 %256
%258 = load double, double* %257
%259 = fdiv double %258, %253
store double %259, double* %257
%260 = load double, double* %36
%261 = load double*, double** %13
%262 = load i32, i32* %15
%263 = zext i32 %262 to i64
%264 = getelementptr inbounds double, double* %261, i64 %263
%265 = load double, double* %264
%266 = fdiv double %265, %260
store double %266, double* %264
br label %267
267: ; preds = %252
%268 = load i32, i32* %15
%269 = add i32 %268, 1
store i32 %269, i32* %15
br label %248
270: ; preds = %248
br label %271
271: ; preds = %270, %242
store i32 1, i32* %7
br label %272
272: ; preds = %271, %67, %62, %57, %43
%273 = load i32, i32* %7
ret i32 %273
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [52 x i8] c"Error in fft(): NumSamples=%u is not power of two\0A\00"
@.str.1 = [7 x i8] c"RealIn\00"
@.str.2 = [8 x i8] c"RealOut\00"
@.str.3 = [8 x i8] c"ImagOut\00"
define i32 @fft_double(i32 %0, i32 %1, double* %2, double* %3, double* %4, double* %5) {
%7 = tail call i32 @IsPowerOfTwo(i32 %0)
%8 = icmp eq i32 %7, 0
%9 = icmp ult i32 %0, 2
%10 = or i1 %9, %8
br i1 %10, label %11, label %14
11: ; preds = %6
%12 = load i32, i32* @stderr
%13 = tail call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0), i32 %0)
br label %183
14: ; preds = %6
%15 = icmp eq i32 %1, 0
%16 = select i1 %15, double 0xC01921FB54442D18, double 0x401921FB54442D18
%17 = tail call i64 @CheckPointerDouble(double* %2, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %183, label %19
19: ; preds = %14
%20 = tail call i64 @CheckPointerDouble(double* %4, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%21 = icmp eq i64 %20, 0
br i1 %21, label %183, label %22
22: ; preds = %19
%23 = tail call i64 @CheckPointerDouble(double* %5, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%24 = icmp eq i64 %23, 0
br i1 %24, label %183, label %25
25: ; preds = %22
%26 = tail call i32 @NumberOfBitsNeeded(i32 %0)
%27 = icmp eq double* %3, null
%28 = zext i32 %0 to i64
br label %29
29: ; preds = %25, %40
%30 = phi i64 [ 0, %25 ], [ %43, %40 ]
%31 = trunc i64 %30 to i32
%32 = tail call i32 @ReverseBits(i32 %31, i32 %26)
%33 = getelementptr inbounds double, double* %2, i64 %30
%34 = load double, double* %33
%35 = zext i32 %32 to i64
%36 = getelementptr inbounds double, double* %4, i64 %35
store double %34, double* %36
br i1 %27, label %40, label %37
37: ; preds = %29
%38 = getelementptr inbounds double, double* %3, i64 %30
%39 = load double, double* %38
br label %40
40: ; preds = %29, %37
%41 = phi double [ %39, %37 ], [ 0.000000e+00, %29 ]
%42 = getelementptr inbounds double, double* %5, i64 %35
store double %41, double* %42
%43 = add nuw nsw i64 %30, 1
%44 = icmp eq i64 %43, %28
br i1 %44, label %45, label %29
45: ; preds = %40, %103
%46 = phi i32 [ %104, %103 ], [ 2, %40 ]
%47 = phi i32 [ %46, %103 ], [ 1, %40 ]
%48 = uitofp i32 %46 to double
%49 = fdiv double %16, %48
%50 = fmul double %49, -2.000000e+00
%51 = tail call double @sin(double %50)
%52 = tail call double @sin(double %49)
%53 = fneg double %52
%54 = tail call double @cos(double %50)
%55 = tail call double @cos(double %49)
%56 = fmul double %55, 2.000000e+00
%57 = icmp eq i32 %47, 0
%58 = insertelement <2 x double> poison, double %51, i64 0
%59 = insertelement <2 x double> %58, double %54, i64 1
%60 = insertelement <2 x double> poison, double %53, i64 0
%61 = insertelement <2 x double> %60, double %55, i64 1
%62 = insertelement <2 x double> poison, double %56, i64 0
%63 = shufflevector <2 x double> %62, <2 x double> poison, <2 x i32> zeroinitializer
br label %64
64: ; preds = %45, %99
%65 = phi i32 [ %47, %45 ], [ %102, %99 ]
%66 = phi i32 [ 0, %45 ], [ %100, %99 ]
br i1 %57, label %99, label %67
67: ; preds = %64, %67
%68 = phi i32 [ %97, %67 ], [ %66, %64 ]
%69 = phi <2 x double> [ %72, %67 ], [ %61, %64 ]
%70 = phi <2 x double> [ %69, %67 ], [ %59, %64 ]
%71 = fneg <2 x double> %70
%72 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %63, <2 x double> %69, <2 x double> %71)
%73 = add i32 %68, %47
%74 = zext i32 %73 to i64
%75 = getelementptr inbounds double, double* %4, i64 %74
%76 = load double, double* %75
%77 = getelementptr inbounds double, double* %5, i64 %74
%78 = load double, double* %77
%79 = extractelement <2 x double> %72, i64 0
%80 = fneg double %79
%81 = fmul double %78, %80
%82 = extractelement <2 x double> %72, i64 1
%83 = tail call double @llvm.fmuladd.f64(double %82, double %76, double %81)
%84 = fmul double %79, %76
%85 = tail call double @llvm.fmuladd.f64(double %82, double %78, double %84)
%86 = zext i32 %68 to i64
%87 = getelementptr inbounds double, double* %4, i64 %86
%88 = load double, double* %87
%89 = fsub double %88, %83
store double %89, double* %75
%90 = getelementptr inbounds double, double* %5, i64 %86
%91 = load double, double* %90
%92 = fsub double %91, %85
store double %92, double* %77
%93 = load double, double* %87
%94 = fadd double %83, %93
store double %94, double* %87
%95 = load double, double* %90
%96 = fadd double %85, %95
store double %96, double* %90
%97 = add i32 %68, 1
%98 = icmp eq i32 %97, %65
br i1 %98, label %99, label %67
99: ; preds = %67, %64
%100 = add i32 %66, %46
%101 = icmp ult i32 %100, %0
%102 = add i32 %65, %46
br i1 %101, label %64, label %103
103: ; preds = %99
%104 = shl i32 %46, 1
%105 = icmp ugt i32 %104, %0
br i1 %105, label %106, label %45
106: ; preds = %103
br i1 %15, label %183, label %107
107: ; preds = %106
%108 = uitofp i32 %0 to double
%109 = zext i32 %0 to i64
%110 = icmp ult i32 %0, 2
br i1 %110, label %171, label %111
111: ; preds = %107
%112 = getelementptr double, double* %4, i64 %28
%113 = getelementptr double, double* %5, i64 %28
%114 = icmp ugt double* %113, %4
%115 = icmp ugt double* %112, %5
%116 = and i1 %114, %115
br i1 %116, label %171, label %117
117: ; preds = %111
%118 = and i64 %28, 4294967294
%119 = insertelement <2 x double> poison, double %108, i64 0
%120 = shufflevector <2 x double> %119, <2 x double> poison, <2 x i32> zeroinitializer
%121 = add nsw i64 %118, -2
%122 = lshr exact i64 %121, 1
%123 = add nuw i64 %122, 1
%124 = and i64 %123, 1
%125 = icmp eq i64 %121, 0
br i1 %125, label %155, label %126
126: ; preds = %117
%127 = and i64 %123, -2
br label %128
128: ; preds = %128, %126
%129 = phi i64 [ 0, %126 ], [ %152, %128 ]
%130 = phi i64 [ 0, %126 ], [ %153, %128 ]
%131 = getelementptr inbounds double, double* %4, i64 %129
%132 = bitcast double* %131 to <2 x double>*
%133 = load <2 x double>, <2 x double>* %132
%134 = fdiv <2 x double> %133, %120
%135 = bitcast double* %131 to <2 x double>*
store <2 x double> %134, <2 x double>* %135
%136 = getelementptr inbounds double, double* %5, i64 %129
%137 = bitcast double* %136 to <2 x double>*
%138 = load <2 x double>, <2 x double>* %137
%139 = fdiv <2 x double> %138, %120
%140 = bitcast double* %136 to <2 x double>*
store <2 x double> %139, <2 x double>* %140
%141 = or i64 %129, 2
%142 = getelementptr inbounds double, double* %4, i64 %141
%143 = bitcast double* %142 to <2 x double>*
%144 = load <2 x double>, <2 x double>* %143
%145 = fdiv <2 x double> %144, %120
%146 = bitcast double* %142 to <2 x double>*
store <2 x double> %145, <2 x double>* %146
%147 = getelementptr inbounds double, double* %5, i64 %141
%148 = bitcast double* %147 to <2 x double>*
%149 = load <2 x double>, <2 x double>* %148
%150 = fdiv <2 x double> %149, %120
%151 = bitcast double* %147 to <2 x double>*
store <2 x double> %150, <2 x double>* %151
%152 = add nuw i64 %129, 4
%153 = add nuw i64 %130, 2
%154 = icmp eq i64 %153, %127
br i1 %154, label %155, label %128
155: ; preds = %128, %117
%156 = phi i64 [ 0, %117 ], [ %152, %128 ]
%157 = icmp eq i64 %124, 0
br i1 %157, label %169, label %158
158: ; preds = %155
%159 = getelementptr inbounds double, double* %4, i64 %156
%160 = bitcast double* %159 to <2 x double>*
%161 = load <2 x double>, <2 x double>* %160
%162 = fdiv <2 x double> %161, %120
%163 = bitcast double* %159 to <2 x double>*
store <2 x double> %162, <2 x double>* %163
%164 = getelementptr inbounds double, double* %5, i64 %156
%165 = bitcast double* %164 to <2 x double>*
%166 = load <2 x double>, <2 x double>* %165
%167 = fdiv <2 x double> %166, %120
%168 = bitcast double* %164 to <2 x double>*
store <2 x double> %167, <2 x double>* %168
br label %169
169: ; preds = %155, %158
%170 = icmp eq i64 %118, %28
br i1 %170, label %183, label %171
171: ; preds = %111, %107, %169
%172 = phi i64 [ 0, %111 ], [ 0, %107 ], [ %118, %169 ]
br label %173
173: ; preds = %171, %173
%174 = phi i64 [ %181, %173 ], [ %172, %171 ]
%175 = getelementptr inbounds double, double* %4, i64 %174
%176 = load double, double* %175
%177 = fdiv double %176, %108
store double %177, double* %175
%178 = getelementptr inbounds double, double* %5, i64 %174
%179 = load double, double* %178
%180 = fdiv double %179, %108
store double %180, double* %178
%181 = add nuw nsw i64 %174, 1
%182 = icmp eq i64 %181, %109
br i1 %182, label %183, label %173
183: ; preds = %173, %169, %106, %22, %19, %14, %11
%184 = phi i32 [ 0, %11 ], [ 0, %14 ], [ 0, %19 ], [ 0, %22 ], [ 1, %106 ], [ 1, %169 ], [ 1, %173 ]
ret i32 %184
}