#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*/ calculoButterflyLoopCompleto(float *, unsigned long,
                                                unsigned long, unsigned long,
                                                double, double);
int /*<<< orphan*/ printf(char *, unsigned long, ...);
double sin(double);
void fft(float data[]) {
  unsigned long mmax, j, m, istep, i;
  double wtemp, wr, wpr, wpi, wi, theta;
  mmax = 2;
  while (16 * 2 > mmax) {
    printf(">>> Inicio do while -> mmax:%lu\n", mmax);
    istep = mmax << 1;
    theta = 1 * (6.28318530717959 / mmax);
    wtemp = sin(0.5 * theta);
    wpr = -2.0 * wtemp * wtemp;
    wpi = sin(theta);
    wr = 1.0;
    wi = 0.0;
    for (m = 1; m < mmax; m += 2) {
      printf("     >>> FOR 1 -> m:%lu mmax:%lu\n", m, mmax);
      calculoButterflyLoopCompleto(data, m, mmax, istep, wr, wi);
      wr = (wtemp = wr) * wpr - wi * wpi + wr;
      wi = wi * wpr + wtemp * wpi + wi;
    }
    mmax = istep;
    printf("<<< Final do while -> istep:%lu mmax:%lu\n\n", istep, mmax);
  }
}


x86 assembly (clang, -O0):
<fft>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x2,-0x10(%rbp)
mov    $0x20,%eax
cmp    -0x10(%rbp),%rax
jbe    12ed <fft+0x1bd>
mov    -0x10(%rbp),%rsi
lea    0xee2(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
add    %rax,%rax
mov    %rax,-0x28(%rbp)
movaps 0xea9(%rip),%xmm1
movq   -0x10(%rbp),%xmm0
punpckldq %xmm1,%xmm0
movapd 0xea8(%rip),%xmm1
subpd  %xmm1,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  0xe79(%rip),%xmm1
divsd  %xmm0,%xmm1
movsd  0xe55(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  0xe54(%rip),%xmm0
mulsd  -0x60(%rbp),%xmm0
call   1050 <sin@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  0xe35(%rip),%xmm0
mulsd  -0x38(%rbp),%xmm0
mulsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x60(%rbp),%xmm0
call   1050 <sin@plt>
movsd  %xmm0,-0x50(%rbp)
movsd  0xe07(%rip),%xmm0
movsd  %xmm0,-0x40(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x58(%rbp)
movq   $0x1,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    12ca <fft+0x19a>
mov    -0x20(%rbp),%rsi
mov    -0x10(%rbp),%rdx
lea    0xe36(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x10(%rbp),%rdx
mov    -0x28(%rbp),%rcx
movsd  -0x40(%rbp),%xmm0
movsd  -0x58(%rbp),%xmm1
call   1040 <calculoButterflyLoopCompleto@plt>
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x48(%rbp),%xmm2
movsd  -0x58(%rbp),%xmm1
mulsd  -0x50(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
addsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x58(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm2
movsd  -0x38(%rbp),%xmm1
mulsd  -0x50(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
addsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    -0x20(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x20(%rbp)
jmp    120e <fft+0xde>
mov    -0x28(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x28(%rbp),%rsi
mov    -0x10(%rbp),%rdx
lea    0xda2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1144 <fft+0x14>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fft>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %rdi,%r15
mov    $0x2,%ebx
xorpd  %xmm0,%xmm0
movhpd 0xef6(%rip),%xmm0
movapd %xmm0,0x20(%rsp)
lea    0xf12(%rip),%r12
lea    0xf2d(%rip),%r13
cs nopw 0x0(%rax,%rax,1)
lea    0xed9(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
lea    (%rbx,%rbx,1),%rbp
movq   %rbx,%xmm0
punpckldq 0xe6e(%rip),%xmm0
subpd  0xe76(%rip),%xmm0
movapd %xmm0,%xmm1
unpckhpd %xmm0,%xmm1
addsd  %xmm0,%xmm1
movsd  0xe82(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,(%rsp)
mulsd  0xe79(%rip),%xmm0
call   1050 <sin@plt>
movapd %xmm0,%xmm1
mulsd  0xe70(%rip),%xmm1
mulsd  %xmm0,%xmm1
movapd %xmm1,0x10(%rsp)
movsd  (%rsp),%xmm0
call   1050 <sin@plt>
movaps 0x10(%rsp),%xmm1
movlhps %xmm1,%xmm1
movaps %xmm1,0x10(%rsp)
movlhps %xmm0,%xmm0
movaps %xmm0,0x30(%rsp)
mov    $0x1,%r14d
movaps 0x20(%rsp),%xmm0
movaps %xmm0,(%rsp)
nopl   0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1030 <printf@plt>
movaps (%rsp),%xmm1
movaps %xmm1,%xmm0
unpckhpd %xmm1,%xmm0
mov    %r15,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
mov    %rbp,%rcx
call   1040 <calculoButterflyLoopCompleto@plt>
movapd (%rsp),%xmm2
movapd %xmm2,%xmm0
xorpd  0xdd3(%rip),%xmm0
movapd %xmm2,%xmm1
shufpd $0x1,%xmm0,%xmm1
mulpd  0x30(%rsp),%xmm1
movapd %xmm2,%xmm0
mulpd  0x10(%rsp),%xmm0
addpd  %xmm1,%xmm0
addpd  %xmm0,%xmm2
movapd %xmm2,(%rsp)
add    $0x2,%r14
cmp    %rbx,%r14
jb     1210 <fft+0xe0>
mov    %r13,%rdi
mov    %rbp,%rsi
mov    %rbp,%rdx
xor    %eax,%eax
call   1030 <printf@plt>
cmp    $0x10,%rbx
mov    %rbp,%rbx
jb     1170 <fft+0x40>
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [33 x i8] c">>> Inicio do while -> mmax:%lu\0A\00"
@.str.1 = [34 x i8] c" >>> FOR 1 -> m:%lu mmax:%lu\0A\00"
@.str.2 = [43 x i8] c"<<< Final do while -> istep:%lu mmax:%lu\0A\0A\00"
define void @fft(float* %0) {
%2 = alloca float*
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
store float* %0, float** %2
store i64 2, i64* %3
br label %14
14: ; preds = %70, %1
%15 = load i64, i64* %3
%16 = icmp ugt i64 32, %15
br i1 %16, label %17, label %75
17: ; preds = %14
%18 = load i64, i64* %3
%19 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i64 %18)
%20 = load i64, i64* %3
%21 = shl i64 %20, 1
store i64 %21, i64* %6
%22 = load i64, i64* %3
%23 = uitofp i64 %22 to double
%24 = fdiv double 0x401921FB54442D1C, %23
%25 = fmul double 1.000000e+00, %24
store double %25, double* %13
%26 = load double, double* %13
%27 = fmul double 5.000000e-01, %26
%28 = call double @sin(double %27)
store double %28, double* %8
%29 = load double, double* %8
%30 = fmul double -2.000000e+00, %29
%31 = load double, double* %8
%32 = fmul double %30, %31
store double %32, double* %10
%33 = load double, double* %13
%34 = call double @sin(double %33)
store double %34, double* %11
store double 1.000000e+00, double* %9
store double 0.000000e+00, double* %12
store i64 1, i64* %5
br label %35
35: ; preds = %67, %17
%36 = load i64, i64* %5
%37 = load i64, i64* %3
%38 = icmp ult i64 %36, %37
br i1 %38, label %39, label %70
39: ; preds = %35
%40 = load i64, i64* %5
%41 = load i64, i64* %3
%42 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i64 %40, i64 %41)
%43 = load float*, float** %2
%44 = load i64, i64* %5
%45 = load i64, i64* %3
%46 = load i64, i64* %6
%47 = load double, double* %9
%48 = load double, double* %12
%49 = call i32 @calculoButterflyLoopCompleto(float* %43, i64 %44, i64 %45, i64 %46, double %47, double %48)
%50 = load double, double* %9
store double %50, double* %8
%51 = load double, double* %10
%52 = load double, double* %12
%53 = load double, double* %11
%54 = fmul double %52, %53
%55 = fneg double %54
%56 = call double @llvm.fmuladd.f64(double %50, double %51, double %55)
%57 = load double, double* %9
%58 = fadd double %56, %57
store double %58, double* %9
%59 = load double, double* %12
%60 = load double, double* %10
%61 = load double, double* %8
%62 = load double, double* %11
%63 = fmul double %61, %62
%64 = call double @llvm.fmuladd.f64(double %59, double %60, double %63)
%65 = load double, double* %12
%66 = fadd double %64, %65
store double %66, double* %12
br label %67
67: ; preds = %39
%68 = load i64, i64* %5
%69 = add i64 %68, 2
store i64 %69, i64* %5
br label %35
70: ; preds = %35
%71 = load i64, i64* %6
store i64 %71, i64* %3
%72 = load i64, i64* %6
%73 = load i64, i64* %3
%74 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0), i64 %72, i64 %73)
br label %14
75: ; preds = %14
ret void
}

LLVM IR (-O2):
@.str = [33 x i8] c">>> Inicio do while -> mmax:%lu\0A\00"
@.str.1 = [34 x i8] c" >>> FOR 1 -> m:%lu mmax:%lu\0A\00"
@.str.2 = [43 x i8] c"<<< Final do while -> istep:%lu mmax:%lu\0A\0A\00"
define void @fft(float* %0) {
br label %2
2: ; preds = %32, %1
%3 = phi i64 [ 2, %1 ], [ %5, %32 ]
%4 = tail call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i64 %3)
%5 = shl nuw nsw i64 %3, 1
%6 = uitofp i64 %3 to double
%7 = fdiv double 0x401921FB54442D1C, %6
%8 = fmul double %7, 5.000000e-01
%9 = tail call double @sin(double %8)
%10 = fmul double %9, -2.000000e+00
%11 = fmul double %9, %10
%12 = tail call double @sin(double %7)
%13 = insertelement <2 x double> poison, double %11, i64 0
%14 = shufflevector <2 x double> %13, <2 x double> poison, <2 x i32> zeroinitializer
%15 = insertelement <2 x double> poison, double %12, i64 0
%16 = shufflevector <2 x double> %15, <2 x double> poison, <2 x i32> zeroinitializer
br label %17
17: ; preds = %2, %17
%18 = phi i64 [ %30, %17 ], [ 1, %2 ]
%19 = phi <2 x double> [ %29, %17 ], [ <double 0.000000e+00, double 1.000000e+00>, %2 ]
%20 = tail call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i64 %18, i64 %3)
%21 = extractelement <2 x double> %19, i64 0
%22 = extractelement <2 x double> %19, i64 1
%23 = tail call i32 @calculoButterflyLoopCompleto(float* %0, i64 %18, i64 %3, i64 %5, double %22, double %21)
%24 = fneg double %21
%25 = insertelement <2 x double> poison, double %22, i64 0
%26 = insertelement <2 x double> %25, double %24, i64 1
%27 = fmul <2 x double> %16, %26
%28 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %19, <2 x double> %14, <2 x double> %27)
%29 = fadd <2 x double> %19, %28
%30 = add nuw nsw i64 %18, 2
%31 = icmp ult i64 %30, %3
br i1 %31, label %17, label %32
32: ; preds = %17
%33 = tail call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0), i64 %5, i64 %5)
%34 = icmp ult i64 %3, 16
br i1 %34, label %2, label %35
35: ; preds = %32
ret void
}