#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 cos(double);
double pow(double, double);
int /*<<< orphan*/ psycho_1_fft(double *, double *, int);
void psycho_3_fft(double sample[1024], double energy[1024]) {
  double x_real[1024];
  int i;
  static int init = 0;
  static double window[1024];
  if (!init) {
    double sqrt_8_over_3 = pow(8.0 / 3.0, 0.5);
    for (i = 0; i < 1024; i++) {
      window[i] = sqrt_8_over_3 * 0.5 *
                  (1 - cos(2.0 * 3.14159265358979 * i / (1024))) / 1024;
    }
    init++;
  }
  for (i = 0; i < 1024; i++)
    x_real[i] = (double)(sample[i] * window[i]);
  psycho_1_fft(x_real, energy, 1024);
}


x86 assembly (clang, -O0):
<psycho_3_fft>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2030,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x0,0x2f06(%rip)
jne    121f <psycho_3_fft+0xef>
movsd  0xea8(%rip),%xmm0
movsd  0xea8(%rip),%xmm1
call   1050 <pow@plt>
movsd  %xmm0,-0x2020(%rbp)
ff
movl   $0x0,-0x2014(%rbp)
cmpl   $0x400,-0x2014(%rbp)
jge    1210 <psycho_3_fft+0xe0>
movsd  0xe79(%rip),%xmm0
mulsd  -0x2020(%rbp),%xmm0
ff
movsd  %xmm0,-0x2028(%rbp)
ff
cvtsi2sdl -0x2014(%rbp),%xmm1
ff
movsd  0xe69(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  0xe55(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1030 <cos@plt>
movsd  -0x2028(%rbp),%xmm0
ff
mov    %eax,%ecx
mov    $0x1,%eax
sub    %ecx,%eax
cvtsi2sd %eax,%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe2b(%rip),%xmm1
divsd  %xmm1,%xmm0
movslq -0x2014(%rbp),%rcx
lea    0x2e69(%rip),%rax
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x2014(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2014(%rbp)
jmp    1177 <psycho_3_fft+0x47>
mov    0x2e3a(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2e31(%rip)
movl   $0x0,-0x2014(%rbp)
cmpl   $0x400,-0x2014(%rbp)
jge    1280 <psycho_3_fft+0x150>
mov    -0x8(%rbp),%rax
movslq -0x2014(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movslq -0x2014(%rbp),%rcx
lea    0x2e09(%rip),%rax
mulsd  (%rax,%rcx,8),%xmm0
movslq -0x2014(%rbp),%rax
movsd  %xmm0,-0x2010(%rbp,%rax,8)
ff ff
mov    -0x2014(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2014(%rbp)
jmp    1229 <psycho_3_fft+0xf9>
lea    -0x2010(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x400,%edx
call   1040 <psycho_1_fft@plt>
add    $0x2030,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<psycho_3_fft>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x2008,%rsp
mov    %rsi,%r14
mov    %rdi,%r15
cmpl   $0x0,0x2f05(%rip)
jne    11f8 <psycho_3_fft+0xd8>
xor    %ebx,%ebx
lea    0x2f06(%rip),%r12
nopw   0x0(%rax,%rax,1)
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
movsd  0xea1(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe9d(%rip),%xmm1
mulsd  %xmm1,%xmm0
call   1030 <cos@plt>
mov    $0x1,%ecx
sub    %eax,%ecx
xorps  %xmm0,%xmm0
cvtsi2sd %ecx,%xmm0
movsd  0xe86(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe72(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,(%r12,%rbx,8)
lea    0x1(%rbx),%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0xe4e(%rip),%xmm0
mulsd  %xmm1,%xmm0
call   1030 <cos@plt>
mov    $0x1,%ecx
sub    %eax,%ecx
xorps  %xmm0,%xmm0
cvtsi2sd %ecx,%xmm0
mulsd  0xe3f(%rip),%xmm0
mulsd  0xe2f(%rip),%xmm0
movsd  %xmm0,0x8(%r12,%rbx,8)
add    $0x2,%rbx
cmp    $0x400,%rbx
jne    1150 <psycho_3_fft+0x30>
addl   $0x1,0x2e48(%rip)
xor    %eax,%eax
lea    0x2e4f(%rip),%rcx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movupd (%r15,%rax,8),%xmm0
movupd 0x10(%r15,%rax,8),%xmm1
mulpd  (%rcx,%rax,8),%xmm0
mulpd  0x10(%rcx,%rax,8),%xmm1
movapd %xmm0,(%rsp,%rax,8)
movapd %xmm1,0x10(%rsp,%rax,8)
movupd 0x20(%r15,%rax,8),%xmm0
movupd 0x30(%r15,%rax,8),%xmm1
mulpd  0x20(%rcx,%rax,8),%xmm0
mulpd  0x30(%rcx,%rax,8),%xmm1
movapd %xmm0,0x20(%rsp,%rax,8)
movapd %xmm1,0x30(%rsp,%rax,8)
add    $0x8,%rax
cmp    $0x400,%rax
jne    1210 <psycho_3_fft+0xf0>
mov    %rsp,%rdi
mov    %r14,%rsi
mov    $0x400,%edx
call   1040 <psycho_1_fft@plt>
add    $0x2008,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@psycho_3_fft.init = internal global i32 0
@psycho_3_fft.window = internal global [1024 x double] zeroinitializer
define void @psycho_3_fft(double* %0, double* %1) {
%3 = alloca double*
%4 = alloca double*
%5 = alloca [1024 x double]
%6 = alloca i32
%7 = alloca double
store double* %0, double** %3
store double* %1, double** %4
%8 = load i32, i32* @psycho_3_fft.init
%9 = icmp ne i32 %8, 0
br i1 %9, label %36, label %10
10: ; preds = %2
%11 = call double @pow(double 0x4005555555555555, double 5.000000e-01)
store double %11, double* %7
store i32 0, i32* %6
br label %12
12: ; preds = %30, %10
%13 = load i32, i32* %6
%14 = icmp slt i32 %13, 1024
br i1 %14, label %15, label %33
15: ; preds = %12
%16 = load double, double* %7
%17 = fmul double %16, 5.000000e-01
%18 = load i32, i32* %6
%19 = sitofp i32 %18 to double
%20 = fmul double 0x401921FB54442D11, %19
%21 = fdiv double %20, 1.024000e+03
%22 = call i32 @cos(double %21)
%23 = sub nsw i32 1, %22
%24 = sitofp i32 %23 to double
%25 = fmul double %17, %24
%26 = fdiv double %25, 1.024000e+03
%27 = load i32, i32* %6
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [1024 x double], [1024 x double]* @psycho_3_fft.window, i64 0, i64 %28
store double %26, double* %29
br label %30
30: ; preds = %15
%31 = load i32, i32* %6
%32 = add nsw i32 %31, 1
store i32 %32, i32* %6
br label %12
33: ; preds = %12
%34 = load i32, i32* @psycho_3_fft.init
%35 = add nsw i32 %34, 1
store i32 %35, i32* @psycho_3_fft.init
br label %36
36: ; preds = %33, %2
store i32 0, i32* %6
br label %37
37: ; preds = %54, %36
%38 = load i32, i32* %6
%39 = icmp slt i32 %38, 1024
br i1 %39, label %40, label %57
40: ; preds = %37
%41 = load double*, double** %3
%42 = load i32, i32* %6
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds double, double* %41, i64 %43
%45 = load double, double* %44
%46 = load i32, i32* %6
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds [1024 x double], [1024 x double]* @psycho_3_fft.window, i64 0, i64 %47
%49 = load double, double* %48
%50 = fmul double %45, %49
%51 = load i32, i32* %6
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds [1024 x double], [1024 x double]* %5, i64 0, i64 %52
store double %50, double* %53
br label %54
54: ; preds = %40
%55 = load i32, i32* %6
%56 = add nsw i32 %55, 1
store i32 %56, i32* %6
br label %37
57: ; preds = %37
%58 = getelementptr inbounds [1024 x double], [1024 x double]* %5, i64 0, i64 0
%59 = load double*, double** %4
%60 = call i32 @psycho_1_fft(double* %58, double* %59, i32 1024)
ret void
}

LLVM IR (-O2):
@psycho_3_fft.init = internal unnamed_addr global i32 0
@psycho_3_fft.window = internal unnamed_addr global [1024 x double] zeroinitializer
define void @psycho_3_fft(double* nocapture %0, double* %1) {
%3 = alloca [1024 x double]
%4 = bitcast [1024 x double]* %3 to i8*
%5 = load i32, i32* @psycho_3_fft.init
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %35
7: ; preds = %2, %7
%8 = phi i64 [ %30, %7 ], [ 0, %2 ]
%9 = trunc i64 %8 to i32
%10 = sitofp i32 %9 to double
%11 = fmul double %10, 0x401921FB54442D11
%12 = fmul double %11, 0x3F50000000000000
%13 = tail call i32 @cos(double %12)
%14 = sub nsw i32 1, %13
%15 = sitofp i32 %14 to double
%16 = fmul double %15, 0x3FEA20BD700C2C3E
%17 = fmul double %16, 0x3F50000000000000
%18 = getelementptr inbounds [1024 x double], [1024 x double]* @psycho_3_fft.window, i64 0, i64 %8
store double %17, double* %18
%19 = or i64 %8, 1
%20 = trunc i64 %19 to i32
%21 = sitofp i32 %20 to double
%22 = fmul double %21, 0x401921FB54442D11
%23 = fmul double %22, 0x3F50000000000000
%24 = tail call i32 @cos(double %23)
%25 = sub nsw i32 1, %24
%26 = sitofp i32 %25 to double
%27 = fmul double %26, 0x3FEA20BD700C2C3E
%28 = fmul double %27, 0x3F50000000000000
%29 = getelementptr inbounds [1024 x double], [1024 x double]* @psycho_3_fft.window, i64 0, i64 %19
store double %28, double* %29
%30 = add nuw nsw i64 %8, 2
%31 = icmp eq i64 %30, 1024
br i1 %31, label %32, label %7
32: ; preds = %7
%33 = load i32, i32* @psycho_3_fft.init
%34 = add nsw i32 %33, 1
store i32 %34, i32* @psycho_3_fft.init
br label %35
35: ; preds = %2, %32
br label %36
36: ; preds = %36, %35
%37 = phi i64 [ 0, %35 ], [ %75, %36 ]
%38 = getelementptr inbounds double, double* %0, i64 %37
%39 = bitcast double* %38 to <2 x double>*
%40 = load <2 x double>, <2 x double>* %39
%41 = getelementptr inbounds double, double* %38, i64 2
%42 = bitcast double* %41 to <2 x double>*
%43 = load <2 x double>, <2 x double>* %42
%44 = getelementptr inbounds [1024 x double], [1024 x double]* @psycho_3_fft.window, i64 0, i64 %37
%45 = bitcast double* %44 to <2 x double>*
%46 = load <2 x double>, <2 x double>* %45
%47 = getelementptr inbounds double, double* %44, i64 2
%48 = bitcast double* %47 to <2 x double>*
%49 = load <2 x double>, <2 x double>* %48
%50 = fmul <2 x double> %40, %46
%51 = fmul <2 x double> %43, %49
%52 = getelementptr inbounds [1024 x double], [1024 x double]* %3, i64 0, i64 %37
%53 = bitcast double* %52 to <2 x double>*
store <2 x double> %50, <2 x double>* %53
%54 = getelementptr inbounds double, double* %52, i64 2
%55 = bitcast double* %54 to <2 x double>*
store <2 x double> %51, <2 x double>* %55
%56 = or i64 %37, 4
%57 = getelementptr inbounds double, double* %0, i64 %56
%58 = bitcast double* %57 to <2 x double>*
%59 = load <2 x double>, <2 x double>* %58
%60 = getelementptr inbounds double, double* %57, i64 2
%61 = bitcast double* %60 to <2 x double>*
%62 = load <2 x double>, <2 x double>* %61
%63 = getelementptr inbounds [1024 x double], [1024 x double]* @psycho_3_fft.window, i64 0, i64 %56
%64 = bitcast double* %63 to <2 x double>*
%65 = load <2 x double>, <2 x double>* %64
%66 = getelementptr inbounds double, double* %63, i64 2
%67 = bitcast double* %66 to <2 x double>*
%68 = load <2 x double>, <2 x double>* %67
%69 = fmul <2 x double> %59, %65
%70 = fmul <2 x double> %62, %68
%71 = getelementptr inbounds [1024 x double], [1024 x double]* %3, i64 0, i64 %56
%72 = bitcast double* %71 to <2 x double>*
store <2 x double> %69, <2 x double>* %72
%73 = getelementptr inbounds double, double* %71, i64 2
%74 = bitcast double* %73 to <2 x double>*
store <2 x double> %70, <2 x double>* %74
%75 = add nuw nsw i64 %37, 8
%76 = icmp eq i64 %75, 1024
br i1 %76, label %77, label %36
77: ; preds = %36
%78 = getelementptr inbounds [1024 x double], [1024 x double]* %3, i64 0, i64 0
%79 = call i32 @psycho_1_fft(double* %78, double* %1, i32 1024)
ret void
}