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


x86 assembly (clang, -O0):
<fft>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x2,-0x10(%rbp)
mov    $0x20,%eax
cmp    -0x10(%rbp),%rax
jbe    1389 <fft+0x259>
movq   -0x10(%rbp),%xmm0
movaps 0xebe(%rip),%xmm1
movaps %xmm1,-0x80(%rbp)
punpckldq %xmm1,%xmm0
movapd 0xebe(%rip),%xmm1
movaps %xmm1,-0x70(%rbp)
subpd  %xmm1,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
lea    0xeb4(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movaps -0x80(%rbp),%xmm2
movaps -0x70(%rbp),%xmm1
mov    -0x10(%rbp),%rax
add    %rax,%rax
mov    %rax,-0x28(%rbp)
movq   -0x10(%rbp),%xmm0
punpckldq %xmm2,%xmm0
subpd  %xmm1,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  0xe52(%rip),%xmm1
divsd  %xmm0,%xmm1
movsd  0xe2e(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  0xe2d(%rip),%xmm0
mulsd  -0x60(%rbp),%xmm0
call   1050 <sin@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  0xe0e(%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  0xde0(%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    137c <fft+0x24c>
movaps 0xdd6(%rip),%xmm1
movq   -0x20(%rbp),%xmm0
punpckldq %xmm1,%xmm0
movapd 0xdd5(%rip),%xmm1
subpd  %xmm1,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rsi
lea    0xdec(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
cmpq   $0x20,-0x30(%rbp)
ja     1303 <fft+0x1d3>
mov    -0x30(%rbp),%rax
add    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
movsd  -0x58(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm1
mov    -0x28(%rbp),%rsi
mov    -0x10(%rbp),%rdx
mov    -0x30(%rbp),%rcx
mov    -0x30(%rbp),%r8
add    $0x1,%r8
mov    -0x18(%rbp),%r9
mov    -0x18(%rbp),%rax
add    $0x1,%rax
lea    0xdb7(%rip),%rdi
mov    %rax,(%rsp)
mov    $0x2,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x18(%rbp),%rdx
movsd  -0x40(%rbp),%xmm0
movsd  -0x58(%rbp),%xmm1
call   1040 <calculoButterfly@plt>
mov    -0x28(%rbp),%rax
add    -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
jmp    1284 <fft+0x154>
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    1235 <fft+0x105>
mov    -0x28(%rbp),%rax
mov    %rax,-0x10(%rbp)
jmp    1147 <fft+0x17>
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fft>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
mov    %rdi,%r13
mov    $0x2,%ebx
xorpd  %xmm0,%xmm0
movhpd 0xef6(%rip),%xmm0
movapd %xmm0,0x50(%rsp)
lea    0xf34(%rip),%r12
nop
mov    %rbx,%rbp
movq   %rbx,%xmm1
punpckldq 0xe90(%rip),%xmm1
subpd  0xe98(%rip),%xmm1
movapd %xmm1,%xmm0
unpckhpd %xmm1,%xmm0
addsd  %xmm1,%xmm0
movapd %xmm0,0x10(%rsp)
lea    0xebf(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
add    %rbx,%rbx
movsd  0xe8d(%rip),%xmm0
divsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
mulsd  0xe81(%rip),%xmm0
call   1050 <sin@plt>
movapd %xmm0,%xmm1
mulsd  0xe78(%rip),%xmm1
mulsd  %xmm0,%xmm1
movapd %xmm1,0x20(%rsp)
movsd  0x10(%rsp),%xmm0
call   1050 <sin@plt>
movaps 0x20(%rsp),%xmm1
movlhps %xmm1,%xmm1
movaps %xmm1,0x20(%rsp)
movlhps %xmm0,%xmm0
movaps %xmm0,0x60(%rsp)
mov    $0x1,%r14d
movaps 0x50(%rsp),%xmm0
movaps %xmm0,0x10(%rsp)
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movq   %r14,%xmm1
punpckldq 0xde3(%rip),%xmm1
subpd  0xdeb(%rip),%xmm1
movapd %xmm1,%xmm0
unpckhpd %xmm1,%xmm0
addsd  %xmm1,%xmm0
lea    0xe39(%rip),%rdi
mov    %rbp,%rsi
mov    $0x1,%al
call   1030 <printf@plt>
movaps 0x10(%rsp),%xmm0
movhlps %xmm0,%xmm0
movaps %xmm0,0x30(%rsp)
mov    %r14,0x48(%rsp)
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
lea    (%r14,%rbp,1),%r15
lea    0x1(%r14),%r8
lea    (%r14,%rbp,1),%rax
add    $0x1,%rax
mov    %rax,(%rsp)
mov    %r12,%rdi
movaps 0x10(%rsp),%xmm0
movaps 0x30(%rsp),%xmm1
mov    %rbx,%rsi
mov    %rbp,%rdx
mov    %r14,%rcx
mov    %r15,%r9
mov    $0x2,%al
call   1030 <printf@plt>
mov    %r13,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
movapd 0x30(%rsp),%xmm0
movapd 0x10(%rsp),%xmm1
call   1040 <calculoButterfly@plt>
add    %rbx,%r14
cmp    $0x21,%r14
jb     1260 <fft+0x130>
movapd 0x10(%rsp),%xmm1
movapd %xmm1,%xmm0
xorpd  0xd57(%rip),%xmm0
movapd 0x30(%rsp),%xmm2
unpcklpd %xmm0,%xmm2
mulpd  0x60(%rsp),%xmm2
movapd %xmm1,%xmm0
mulpd  0x20(%rsp),%xmm0
addpd  %xmm2,%xmm0
addpd  %xmm0,%xmm1
movapd %xmm1,0x10(%rsp)
mov    0x48(%rsp),%r14
add    $0x2,%r14
cmp    %rbp,%r14
jb     1210 <fft+0xe0>
cmp    $0xf,%rbp
jbe    1160 <fft+0x30>
add    $0x78,%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 = [84 x i8] c" >>> FOR 2 -> wi:%f wr:%f istep:%lu mmax:%lu i:%lu i+1:%lu j:%lu j+1:%lu \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 = %95, %1
%15 = load i64, i64* %3
%16 = icmp ugt i64 32, %15
br i1 %16, label %17, label %97
17: ; preds = %14
%18 = load i64, i64* %3
%19 = uitofp i64 %18 to double
%20 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), double %19)
%21 = load i64, i64* %3
%22 = shl i64 %21, 1
store i64 %22, i64* %6
%23 = load i64, i64* %3
%24 = uitofp i64 %23 to double
%25 = fdiv double 0x401921FB54442D1C, %24
%26 = fmul double 1.000000e+00, %25
store double %26, double* %13
%27 = load double, double* %13
%28 = fmul double 5.000000e-01, %27
%29 = call double @sin(double %28)
store double %29, double* %8
%30 = load double, double* %8
%31 = fmul double -2.000000e+00, %30
%32 = load double, double* %8
%33 = fmul double %31, %32
store double %33, double* %10
%34 = load double, double* %13
%35 = call double @sin(double %34)
store double %35, double* %11
store double 1.000000e+00, double* %9
store double 0.000000e+00, double* %12
store i64 1, i64* %5
br label %36
36: ; preds = %92, %17
%37 = load i64, i64* %5
%38 = load i64, i64* %3
%39 = icmp ult i64 %37, %38
br i1 %39, label %40, label %95
40: ; preds = %36
%41 = load i64, i64* %5
%42 = uitofp i64 %41 to double
%43 = load i64, i64* %3
%44 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), double %42, i64 %43)
%45 = load i64, i64* %5
store i64 %45, i64* %7
br label %46
46: ; preds = %70, %40
%47 = load i64, i64* %7
%48 = icmp ule i64 %47, 32
br i1 %48, label %49, label %74
49: ; preds = %46
%50 = load i64, i64* %7
%51 = load i64, i64* %3
%52 = add i64 %50, %51
store i64 %52, i64* %4
%53 = load double, double* %12
%54 = load double, double* %9
%55 = load i64, i64* %6
%56 = load i64, i64* %3
%57 = load i64, i64* %7
%58 = load i64, i64* %7
%59 = add i64 %58, 1
%60 = load i64, i64* %4
%61 = load i64, i64* %4
%62 = add i64 %61, 1
%63 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([84 x i8], [84 x i8]* @.str.2, i64 0, i64 0), double %53, double %54, i64 %55, i64 %56, i64 %57, i64 %59, i64 %60, i64 %62)
%64 = load float*, float** %2
%65 = load i64, i64* %7
%66 = load i64, i64* %4
%67 = load double, double* %9
%68 = load double, double* %12
%69 = call i32 @calculoButterfly(float* %64, i64 %65, i64 %66, double %67, double %68)
br label %70
70: ; preds = %49
%71 = load i64, i64* %6
%72 = load i64, i64* %7
%73 = add i64 %72, %71
store i64 %73, i64* %7
br label %46
74: ; preds = %46
%75 = load double, double* %9
store double %75, double* %8
%76 = load double, double* %10
%77 = load double, double* %12
%78 = load double, double* %11
%79 = fmul double %77, %78
%80 = fneg double %79
%81 = call double @llvm.fmuladd.f64(double %75, double %76, double %80)
%82 = load double, double* %9
%83 = fadd double %81, %82
store double %83, double* %9
%84 = load double, double* %12
%85 = load double, double* %10
%86 = load double, double* %8
%87 = load double, double* %11
%88 = fmul double %86, %87
%89 = call double @llvm.fmuladd.f64(double %84, double %85, double %88)
%90 = load double, double* %12
%91 = fadd double %89, %90
store double %91, double* %12
br label %92
92: ; preds = %74
%93 = load i64, i64* %5
%94 = add i64 %93, 2
store i64 %94, i64* %5
br label %36
95: ; preds = %36
%96 = load i64, i64* %6
store i64 %96, i64* %3
br label %14
97: ; 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 = [84 x i8] c" >>> FOR 2 -> wi:%f wr:%f istep:%lu mmax:%lu i:%lu i+1:%lu j:%lu j+1:%lu \0A\00"
define void @fft(float* %0) {
br label %4
2: ; preds = %35
%3 = icmp ult i64 %5, 16
br i1 %3, label %4, label %45
4: ; preds = %2, %1
%5 = phi i64 [ 2, %1 ], [ %8, %2 ]
%6 = uitofp i64 %5 to double
%7 = tail call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), double %6)
%8 = shl nuw nsw i64 %5, 1
%9 = fdiv double 0x401921FB54442D1C, %6
%10 = fmul double %9, 5.000000e-01
%11 = tail call double @sin(double %10)
%12 = fmul double %11, -2.000000e+00
%13 = fmul double %11, %12
%14 = tail call double @sin(double %9)
%15 = insertelement <2 x double> poison, double %13, i64 0
%16 = shufflevector <2 x double> %15, <2 x double> poison, <2 x i32> zeroinitializer
%17 = insertelement <2 x double> poison, double %14, i64 0
%18 = shufflevector <2 x double> %17, <2 x double> poison, <2 x i32> zeroinitializer
br label %19
19: ; preds = %35, %4
%20 = phi i64 [ %43, %35 ], [ 1, %4 ]
%21 = phi <2 x double> [ %42, %35 ], [ <double 0.000000e+00, double 1.000000e+00>, %4 ]
%22 = uitofp i64 %20 to double
%23 = tail call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), double %22, i64 %5)
%24 = extractelement <2 x double> %21, i64 0
%25 = extractelement <2 x double> %21, i64 1
br label %26
26: ; preds = %19, %26
%27 = phi i64 [ %33, %26 ], [ %20, %19 ]
%28 = add nuw nsw i64 %27, %5
%29 = add nuw nsw i64 %27, 1
%30 = add nuw nsw i64 %28, 1
%31 = tail call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([84 x i8], [84 x i8]* @.str.2, i64 0, i64 0), double %24, double %25, i64 %8, i64 %5, i64 %27, i64 %29, i64 %28, i64 %30)
%32 = tail call i32 @calculoButterfly(float* %0, i64 %27, i64 %28, double %25, double %24)
%33 = add nuw nsw i64 %27, %8
%34 = icmp ult i64 %33, 33
br i1 %34, label %26, label %35
35: ; preds = %26
%36 = extractelement <2 x double> %21, i64 0
%37 = fneg double %36
%38 = insertelement <2 x double> poison, double %25, i64 0
%39 = insertelement <2 x double> %38, double %37, i64 1
%40 = fmul <2 x double> %18, %39
%41 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %21, <2 x double> %16, <2 x double> %40)
%42 = fadd <2 x double> %21, %41
%43 = add nuw nsw i64 %20, 2
%44 = icmp ult i64 %43, %5
br i1 %44, label %19, label %2
45: ; preds = %2
ret void
}