// File: /workspace/github_c_makefile_star2_O0/diaxen[P]fft-garden/test.c
// Function: main
int main()
{
  for (int count = MIN_COUNT; count <= MAX_COUNT; count *= 2)
    {
      complex double s[count];	/* input */
      complex double t[count];	/* tested implementation output */
      complex double r[count];	/* reference output */

      /* random input */
      for (unsigned i = 0; i < count; i++)
	s[i] = (drand48() - .5) + I * (drand48() - .5);

      /* run fft under test */
      fft_init(count);

      /* run reference fft */
      simple_dft(count, r, s, 1);

#ifdef INPLACE
      fft(count, s);
      memcpy(t, s, sizeof(s));
#else
      fft(count, t, s);
#endif

      fft_cleanup();

      /* compare outputs */
      for (unsigned i = 0; i < count; i++)
	if (cabs(t[i] - r[i]) > 0.0001)
	  {
	    printf("LEN: %u\n", count);
	    printf("INPUT: ");
	    print_cpx_array(s, count);
	    printf("FFT: ");
	    print_cpx_array(t, count);
	    printf("REF: ");
	    print_cpx_array(r, count);
	    abort();
	  }

      printf("Ok %u\n", count);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movl $0x0, -0x4(%rbp)
movl $0x4, -0x8(%rbp)
cmpl $0x1000, -0x8(%rbp)     # imm = 0x1000
jg 0x148f
movl -0x8(%rbp), %eax
movq %rsp, %rcx
movq %rcx, -0x10(%rbp)
movq %rax, %rdx
shlq $0x4, %rdx
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0x58(%rbp)
movq %rcx, %rsp
movq %rax, -0x18(%rbp)
movl -0x8(%rbp), %eax
movq %rax, %rdx
shlq $0x4, %rdx
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0x50(%rbp)
movq %rcx, %rsp
movq %rax, -0x20(%rbp)
movl -0x8(%rbp), %eax
movq %rax, %rdx
shlq $0x4, %rdx
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0x48(%rbp)
movq %rcx, %rsp
movq %rax, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0x8(%rbp), %eax
jae 0x1352
callq 0x10b0
movsd 0x2d21(%rip), %xmm1     # 0x4018
subsd %xmm1, %xmm0
movsd %xmm0, -0x60(%rbp)
callq 0x10b0
movsd -0x60(%rbp), %xmm1
movq -0x58(%rbp), %rax
movaps %xmm0, %xmm3
movsd 0x2cff(%rip), %xmm0     # 0x4018
subsd %xmm0, %xmm3
xorps %xmm2, %xmm2
mulsd %xmm3, %xmm2
movsd 0x2ce4(%rip), %xmm0     # 0x4010
mulsd %xmm3, %xmm0
addsd %xmm2, %xmm1
movl -0x2c(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movsd %xmm1, (%rax)
movsd %xmm0, 0x8(%rax)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x12e2
movl -0x8(%rbp), %edi
callq 0x22b0
movq -0x48(%rbp), %rsi
movq -0x58(%rbp), %rdx
movl -0x8(%rbp), %edi
movl $0x1, %ecx
callq 0x14a0
movq -0x50(%rbp), %rsi
movq -0x58(%rbp), %rdx
movl -0x8(%rbp), %edi
callq 0x1e50
movb $0x0, %al
callq 0x22d0
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %eax
cmpl -0x8(%rbp), %eax
jae 0x146a
movq -0x48(%rbp), %rax
movq -0x50(%rbp), %rcx
movl -0x30(%rbp), %edx
shlq $0x4, %rdx
addq %rdx, %rcx
movsd (%rcx), %xmm1
movsd 0x8(%rcx), %xmm0
movl -0x30(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movsd (%rax), %xmm3
movsd 0x8(%rax), %xmm2
subsd %xmm3, %xmm1
subsd %xmm2, %xmm0
movsd %xmm1, -0x40(%rbp)
movsd %xmm0, -0x38(%rbp)
movsd -0x40(%rbp), %xmm0
movsd -0x38(%rbp), %xmm1
callq 0x1090
movsd 0x2c18(%rip), %xmm1     # 0x4008
ucomisd %xmm1, %xmm0
jbe 0x145a
movl -0x8(%rbp), %esi
leaq 0x2c33(%rip), %rdi      # 0x4033
movb $0x0, %al
callq 0x1060
leaq 0x2c2e(%rip), %rdi      # 0x403c
movb $0x0, %al
callq 0x1060
movq -0x58(%rbp), %rdi
movl -0x8(%rbp), %esi
callq 0x11f0
leaq 0x2c1c(%rip), %rdi      # 0x4044
movb $0x0, %al
callq 0x1060
movq -0x50(%rbp), %rdi
movl -0x8(%rbp), %esi
callq 0x11f0
leaq 0x2c08(%rip), %rdi      # 0x404a
movb $0x0, %al
callq 0x1060
movq -0x48(%rbp), %rdi
movl -0x8(%rbp), %esi
callq 0x11f0
callq 0x1040
jmp 0x145c
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x138d
movl -0x8(%rbp), %esi
leaq 0x2bdc(%rip), %rdi      # 0x4050
movb $0x0, %al
callq 0x1060
movq -0x10(%rbp), %rax
movq %rax, %rsp
movl -0x8(%rbp), %eax
shll %eax
movl %eax, -0x8(%rbp)
jmp 0x1276
movl -0x4(%rbp), %eax
movq %rbp, %rsp
popq %rbp
retq
nopw (%rax,%rax)