#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*/ assert(int);
int atoi(char *);
int /*<<< orphan*/ compute_W(int, double *, double *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fft(int, double *, double *, double *, double *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ free(double *);
int /*<<< orphan*/ init_array(int, double *, double *);
scalar_t__ malloc(int);
int /*<<< orphan*/ output_array(int, double *, double *, char *);
int /*<<< orphan*/ permute_bitrev(int, double *, double *);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  int n;
  double *A_re, *A_im, *W_re, *W_im;
  if (argc <= 2) {
    fprintf(stderr, "Usage: ./fft n outfile\n");
    exit(-1);
  }
  n = atoi(argv[1]);
  A_re = (double *)malloc(sizeof(double) * n);
  A_im = (double *)malloc(sizeof(double) * n);
  W_re = (double *)malloc(sizeof(double) * n / 2);
  W_im = (double *)malloc(sizeof(double) * n / 2);
  assert(A_re != NULL && A_im != NULL && W_re != NULL && W_im != NULL);
  init_array(n, A_re, A_im);
  compute_W(n, W_re, W_im);
  fft(n, A_re, A_im, W_re, W_im);
  permute_bitrev(n, A_re, A_im);
  output_array(n, A_re, A_im, argv[2]);
  free(A_re);
  free(A_im);
  free(W_re);
  free(W_im);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jg     11ef <main+0x3f>
mov    0x2e09(%rip),%rax
mov    (%rax),%edi
lea    0xe20(%rip),%rsi
call   1080 <fprintf@plt>
mov    $0xffffffff,%edi
call   10c0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10b0 <atoi@plt>
mov    %eax,-0x14(%rbp)
movslq -0x14(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1090 <malloc@plt>
mov    %rax,-0x20(%rbp)
movslq -0x14(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1090 <malloc@plt>
mov    %rax,-0x28(%rbp)
movslq -0x14(%rbp),%rax
shl    $0x3,%rax
shr    $0x1,%rax
mov    %eax,%edi
call   1090 <malloc@plt>
mov    %rax,-0x30(%rbp)
movslq -0x14(%rbp),%rax
shl    $0x3,%rax
shr    $0x1,%rax
mov    %eax,%edi
call   1090 <malloc@plt>
mov    %rax,-0x38(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x20(%rbp)
mov    %al,-0x39(%rbp)
je     128e <main+0xde>
xor    %eax,%eax
cmpq   $0x0,-0x28(%rbp)
mov    %al,-0x39(%rbp)
je     128e <main+0xde>
xor    %eax,%eax
cmpq   $0x0,-0x30(%rbp)
mov    %al,-0x39(%rbp)
je     128e <main+0xde>
cmpq   $0x0,-0x38(%rbp)
setne  %al
mov    %al,-0x39(%rbp)
mov    -0x39(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
mov    -0x14(%rbp),%edi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1060 <init_array@plt>
mov    -0x14(%rbp),%edi
mov    -0x30(%rbp),%rsi
mov    -0x38(%rbp),%rdx
call   1040 <compute_W@plt>
mov    -0x14(%rbp),%edi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
mov    -0x30(%rbp),%rcx
mov    -0x38(%rbp),%r8
call   10d0 <fft@plt>
mov    -0x14(%rbp),%edi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1050 <permute_bitrev@plt>
mov    -0x14(%rbp),%edi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rcx
call   10a0 <output_array@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0x2,%edi
jle    12aa <main+0xfa>
mov    %rsi,%r14
mov    0x8(%rsi),%rdi
call   10b0 <atoi@plt>
mov    %eax,%ebx
lea    0x0(,%rbx,8),%ebp
mov    %ebp,%edi
call   1090 <malloc@plt>
mov    %rax,%r15
mov    %ebp,%edi
call   1090 <malloc@plt>
mov    %rax,%r12
lea    0x0(,%rbx,4),%ebp
mov    %ebp,%edi
call   1090 <malloc@plt>
mov    %rax,%r13
mov    %ebp,%edi
call   1090 <malloc@plt>
mov    %rax,%rbp
test   %r15,%r15
setne  %al
test   %r12,%r12
setne  %cl
and    %al,%cl
test   %r13,%r13
setne  %al
test   %rbp,%rbp
setne  %dl
and    %al,%dl
and    %cl,%dl
movzbl %dl,%edi
call   1070 <assert@plt>
mov    %ebx,%edi
mov    %r15,%rsi
mov    %r12,%rdx
call   1060 <init_array@plt>
mov    %ebx,%edi
mov    %r13,%rsi
mov    %rbp,%rdx
call   1040 <compute_W@plt>
mov    %ebx,%edi
mov    %r15,%rsi
mov    %r12,%rdx
mov    %r13,%rcx
mov    %rbp,%r8
call   10d0 <fft@plt>
mov    %ebx,%edi
mov    %r15,%rsi
mov    %r12,%rdx
call   1050 <permute_bitrev@plt>
mov    0x10(%r14),%rcx
mov    %ebx,%edi
mov    %r15,%rsi
mov    %r12,%rdx
call   10a0 <output_array@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %r12,%rdi
call   1030 <free@plt>
mov    %r13,%rdi
call   1030 <free@plt>
mov    %rbp,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2d2f(%rip),%rax
mov    (%rax),%edi
lea    0xd46(%rip),%rsi
call   1080 <fprintf@plt>
mov    $0xffffffff,%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [24 x i8] c"Usage: ./fft n outfile\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca double*
%8 = alloca double*
%9 = alloca double*
%10 = alloca double*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* %4
%12 = icmp sle i32 %11, 2
br i1 %12, label %13, label %17
13: ; preds = %2
%14 = load i32, i32* @stderr
%15 = call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%16 = call i32 @exit(i32 -1)
unreachable
17: ; preds = %2
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = call i32 @atoi(i8* %20)
store i32 %21, i32* %6
%22 = load i32, i32* %6
%23 = sext i32 %22 to i64
%24 = mul i64 8, %23
%25 = trunc i64 %24 to i32
%26 = call i64 @malloc(i32 %25)
%27 = inttoptr i64 %26 to double*
store double* %27, double** %7
%28 = load i32, i32* %6
%29 = sext i32 %28 to i64
%30 = mul i64 8, %29
%31 = trunc i64 %30 to i32
%32 = call i64 @malloc(i32 %31)
%33 = inttoptr i64 %32 to double*
store double* %33, double** %8
%34 = load i32, i32* %6
%35 = sext i32 %34 to i64
%36 = mul i64 8, %35
%37 = udiv i64 %36, 2
%38 = trunc i64 %37 to i32
%39 = call i64 @malloc(i32 %38)
%40 = inttoptr i64 %39 to double*
store double* %40, double** %9
%41 = load i32, i32* %6
%42 = sext i32 %41 to i64
%43 = mul i64 8, %42
%44 = udiv i64 %43, 2
%45 = trunc i64 %44 to i32
%46 = call i64 @malloc(i32 %45)
%47 = inttoptr i64 %46 to double*
store double* %47, double** %10
%48 = load double*, double** %7
%49 = icmp ne double* %48, null
br i1 %49, label %50, label %59
50: ; preds = %17
%51 = load double*, double** %8
%52 = icmp ne double* %51, null
br i1 %52, label %53, label %59
53: ; preds = %50
%54 = load double*, double** %9
%55 = icmp ne double* %54, null
br i1 %55, label %56, label %59
56: ; preds = %53
%57 = load double*, double** %10
%58 = icmp ne double* %57, null
br label %59
59: ; preds = %56, %53, %50, %17
%60 = phi i1 [ false, %53 ], [ false, %50 ], [ false, %17 ], [ %58, %56 ]
%61 = zext i1 %60 to i32
%62 = call i32 @assert(i32 %61)
%63 = load i32, i32* %6
%64 = load double*, double** %7
%65 = load double*, double** %8
%66 = call i32 @init_array(i32 %63, double* %64, double* %65)
%67 = load i32, i32* %6
%68 = load double*, double** %9
%69 = load double*, double** %10
%70 = call i32 @compute_W(i32 %67, double* %68, double* %69)
%71 = load i32, i32* %6
%72 = load double*, double** %7
%73 = load double*, double** %8
%74 = load double*, double** %9
%75 = load double*, double** %10
%76 = call i32 @fft(i32 %71, double* %72, double* %73, double* %74, double* %75)
%77 = load i32, i32* %6
%78 = load double*, double** %7
%79 = load double*, double** %8
%80 = call i32 @permute_bitrev(i32 %77, double* %78, double* %79)
%81 = load i32, i32* %6
%82 = load double*, double** %7
%83 = load double*, double** %8
%84 = load i8**, i8*** %5
%85 = getelementptr inbounds i8*, i8** %84, i64 2
%86 = load i8*, i8** %85
%87 = call i32 @output_array(i32 %81, double* %82, double* %83, i8* %86)
%88 = load double*, double** %7
%89 = call i32 @free(double* %88)
%90 = load double*, double** %8
%91 = call i32 @free(double* %90)
%92 = load double*, double** %9
%93 = call i32 @free(double* %92)
%94 = load double*, double** %10
%95 = call i32 @free(double* %94)
%96 = load i32, i32* %3
ret i32 %96
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [24 x i8] c"Usage: ./fft n outfile\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 3
br i1 %3, label %4, label %8
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%7 = tail call i32 @exit(i32 -1)
unreachable
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i32 @atoi(i8* %10)
%12 = sext i32 %11 to i64
%13 = shl nsw i64 %12, 3
%14 = trunc i64 %13 to i32
%15 = tail call i64 @malloc(i32 %14)
%16 = inttoptr i64 %15 to double*
%17 = tail call i64 @malloc(i32 %14)
%18 = inttoptr i64 %17 to double*
%19 = lshr exact i64 %13, 1
%20 = trunc i64 %19 to i32
%21 = tail call i64 @malloc(i32 %20)
%22 = inttoptr i64 %21 to double*
%23 = tail call i64 @malloc(i32 %20)
%24 = inttoptr i64 %23 to double*
%25 = icmp ne i64 %15, 0
%26 = icmp ne i64 %17, 0
%27 = select i1 %25, i1 %26, i1 false
%28 = icmp ne i64 %21, 0
%29 = select i1 %27, i1 %28, i1 false
%30 = icmp ne i64 %23, 0
%31 = select i1 %29, i1 %30, i1 false
%32 = zext i1 %31 to i32
%33 = tail call i32 @assert(i32 %32)
%34 = tail call i32 @init_array(i32 %11, double* %16, double* %18)
%35 = tail call i32 @compute_W(i32 %11, double* %22, double* %24)
%36 = tail call i32 @fft(i32 %11, double* %16, double* %18, double* %22, double* %24)
%37 = tail call i32 @permute_bitrev(i32 %11, double* %16, double* %18)
%38 = getelementptr inbounds i8*, i8** %1, i64 2
%39 = load i8*, i8** %38
%40 = tail call i32 @output_array(i32 %11, double* %16, double* %18, i8* %39)
%41 = tail call i32 @free(double* %16)
%42 = tail call i32 @free(double* %18)
%43 = tail call i32 @free(double* %22)
%44 = tail call i32 @free(double* %24)
ret i32 0
}