#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*/ fftss_free(double *);
scalar_t__ fftss_malloc(int);
scalar_t__ fftss_test_dft_1d(long, double *, double *, int, int /*<<< orphan*/);
int fftss_version(char *);
int /*<<< orphan*/ printf(char *, ...);
int testall() {
  int status = 0;
  double *b0, *b1;
  long logn;
  long n;
  int ver;
  char name[16];
  ver = fftss_version(name);
  printf("FFTSS library version 2.0, update-%d(%s).\n\n", ver, name);
  for (logn = 1; logn <= 16; logn++) {
    n = 1 << logn;
    b0 = (double *)fftss_malloc(sizeof(double) * 2 * n);
    b1 = (double *)fftss_malloc(sizeof(double) * 2 * n);
    status += fftss_test_dft_1d(n, b0, b1, 1, 0);
    status += fftss_test_dft_1d(n, b1, b0, -1, 0);
    fftss_free(b0);
    fftss_free(b1);
  }
  if (status)
    printf("\nTotal %d test(s) failed.\n", status);
  else
    printf("\nAll tests passed in this library.\n");
  return status;
}


x86 assembly (clang, -O0):
<testall>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x40(%rbp),%rdi
call   1030 <fftss_version@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%esi
lea    -0x40(%rbp),%rdx
lea    0xe87(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movq   $0x1,-0x20(%rbp)
cmpq   $0x10,-0x20(%rbp)
jg     123b <testall+0xeb>
mov    -0x20(%rbp),%rax
mov    %eax,%ecx
mov    $0x1,%eax
shl    %cl,%eax
cltq
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
shl    $0x4,%rax
mov    %eax,%edi
call   1070 <fftss_malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x28(%rbp),%rax
shl    $0x4,%rax
mov    %eax,%edi
call   1070 <fftss_malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    $0x1,%ecx
xor    %r8d,%r8d
call   1050 <fftss_test_dft_1d@plt>
mov    %rax,%rcx
movslq -0x4(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x4(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x10(%rbp),%rdx
mov    $0xffffffff,%ecx
xor    %r8d,%r8d
call   1050 <fftss_test_dft_1d@plt>
mov    %rax,%rcx
movslq -0x4(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x4(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <fftss_free@plt>
mov    -0x18(%rbp),%rdi
call   1060 <fftss_free@plt>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1188 <testall+0x38>
cmpl   $0x0,-0x4(%rbp)
je     125b <testall+0x10b>
mov    -0x4(%rbp),%esi
lea    0xddd(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1269 <testall+0x119>
lea    0xde5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<testall>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsp,%r14
mov    %r14,%rdi
call   1040 <fftss_version@plt>
lea    0xe80(%rip),%rdi
xor    %r15d,%r15d
mov    %eax,%esi
mov    %r14,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xfffffffffffffff0,%r13
cs nopw 0x0(%rax,%rax,1)
lea    0x11(%r13),%ecx
mov    $0x1,%ebx
shl    %cl,%ebx
mov    %ebx,%ebp
shl    $0x4,%ebp
mov    %ebp,%edi
call   1080 <fftss_malloc@plt>
mov    %rax,%r14
mov    %ebp,%edi
call   1080 <fftss_malloc@plt>
mov    %rax,%r12
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %rax,%rdx
mov    $0x1,%ecx
xor    %r8d,%r8d
call   1060 <fftss_test_dft_1d@plt>
mov    %rax,%rbp
add    %r15d,%ebp
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r14,%rdx
mov    $0xffffffff,%ecx
xor    %r8d,%r8d
call   1060 <fftss_test_dft_1d@plt>
mov    %rax,%r15
add    %ebp,%r15d
mov    %r14,%rdi
call   1070 <fftss_free@plt>
mov    %r12,%rdi
call   1070 <fftss_free@plt>
inc    %r13
jne    11a0 <testall+0x40>
test   %r15d,%r15d
je     1229 <testall+0xc9>
lea    0xe0f(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1235 <testall+0xd5>
lea    0xe17(%rip),%rdi
call   1030 <puts@plt>
mov    %r15d,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [44 x i8] c"FFTSS library version 2.0, update-%d(%s).\0A\0A\00"
@.str.1 = [27 x i8] c"\0ATotal %d test(s) failed.\0A\00"
@.str.2 = [36 x i8] c"\0AAll tests passed in this library.\0A\00"
define i32 @testall() {
%1 = alloca i32
%2 = alloca double*
%3 = alloca double*
%4 = alloca i64
%5 = alloca i64
%6 = alloca i32
%7 = alloca [16 x i8]
store i32 0, i32* %1
%8 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 0
%9 = call i32 @fftss_version(i8* %8)
store i32 %9, i32* %6
%10 = load i32, i32* %6
%11 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 0
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i32 %10, i8* %11)
store i64 1, i64* %4
br label %13
13: ; preds = %51, %0
%14 = load i64, i64* %4
%15 = icmp sle i64 %14, 16
br i1 %15, label %16, label %54
16: ; preds = %13
%17 = load i64, i64* %4
%18 = trunc i64 %17 to i32
%19 = shl i32 1, %18
%20 = sext i32 %19 to i64
store i64 %20, i64* %5
%21 = load i64, i64* %5
%22 = mul i64 16, %21
%23 = trunc i64 %22 to i32
%24 = call i64 @fftss_malloc(i32 %23)
%25 = inttoptr i64 %24 to double*
store double* %25, double** %2
%26 = load i64, i64* %5
%27 = mul i64 16, %26
%28 = trunc i64 %27 to i32
%29 = call i64 @fftss_malloc(i32 %28)
%30 = inttoptr i64 %29 to double*
store double* %30, double** %3
%31 = load i64, i64* %5
%32 = load double*, double** %2
%33 = load double*, double** %3
%34 = call i64 @fftss_test_dft_1d(i64 %31, double* %32, double* %33, i32 1, i32 0)
%35 = load i32, i32* %1
%36 = sext i32 %35 to i64
%37 = add nsw i64 %36, %34
%38 = trunc i64 %37 to i32
store i32 %38, i32* %1
%39 = load i64, i64* %5
%40 = load double*, double** %3
%41 = load double*, double** %2
%42 = call i64 @fftss_test_dft_1d(i64 %39, double* %40, double* %41, i32 -1, i32 0)
%43 = load i32, i32* %1
%44 = sext i32 %43 to i64
%45 = add nsw i64 %44, %42
%46 = trunc i64 %45 to i32
store i32 %46, i32* %1
%47 = load double*, double** %2
%48 = call i32 @fftss_free(double* %47)
%49 = load double*, double** %3
%50 = call i32 @fftss_free(double* %49)
br label %51
51: ; preds = %16
%52 = load i64, i64* %4
%53 = add nsw i64 %52, 1
store i64 %53, i64* %4
br label %13
54: ; preds = %13
%55 = load i32, i32* %1
%56 = icmp ne i32 %55, 0
br i1 %56, label %57, label %60
57: ; preds = %54
%58 = load i32, i32* %1
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i32 %58)
br label %62
60: ; preds = %54
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0))
br label %62
62: ; preds = %60, %57
%63 = load i32, i32* %1
ret i32 %63
}

LLVM IR (-O2):
@.str = [44 x i8] c"FFTSS library version 2.0, update-%d(%s).\0A\0A\00"
@.str.1 = [27 x i8] c"\0ATotal %d test(s) failed.\0A\00"
@str = [35 x i8] c"\0AAll tests passed in this library.\00"
define i32 @testall() {
%1 = alloca [16 x i8]
%2 = getelementptr inbounds [16 x i8], [16 x i8]* %1, i64 0, i64 0
%3 = call i32 @fftss_version(i8* %2)
%4 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i32 %3, i8* %2)
br label %5
5: ; preds = %0, %5
%6 = phi i32 [ 0, %0 ], [ %21, %5 ]
%7 = phi i64 [ 1, %0 ], [ %24, %5 ]
%8 = trunc i64 %7 to i32
%9 = shl nuw nsw i32 1, %8
%10 = zext i32 %9 to i64
%11 = shl nuw nsw i32 %9, 4
%12 = call i64 @fftss_malloc(i32 %11)
%13 = inttoptr i64 %12 to double*
%14 = call i64 @fftss_malloc(i32 %11)
%15 = inttoptr i64 %14 to double*
%16 = call i64 @fftss_test_dft_1d(i64 %10, double* %13, double* %15, i32 1, i32 0)
%17 = trunc i64 %16 to i32
%18 = add i32 %6, %17
%19 = call i64 @fftss_test_dft_1d(i64 %10, double* %15, double* %13, i32 -1, i32 0)
%20 = trunc i64 %19 to i32
%21 = add i32 %18, %20
%22 = call i32 @fftss_free(double* %13)
%23 = call i32 @fftss_free(double* %15)
%24 = add nuw nsw i64 %7, 1
%25 = icmp eq i64 %24, 17
br i1 %25, label %26, label %5
26: ; preds = %5
%27 = icmp eq i32 %21, 0
br i1 %27, label %30, label %28
28: ; preds = %26
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i32 %21)
br label %32
30: ; preds = %26
%31 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str, i64 0, i64 0))
br label %32
32: ; preds = %30, %28
ret i32 %21
}