#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*/ calculoButterflyLoopBloco(float *, int, unsigned long,
                                             unsigned long, double, double,
                                             unsigned long);
int /*<<< orphan*/ calculoButterflyLoopCompleto(float *, unsigned long,
                                                unsigned long, unsigned long,
                                                double, double);
int /*<<< orphan*/ printf(char *, ...);
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);
      if (16 / mmax >= 2) {
        printf("     processa em thread\n");
        unsigned long tamBloco = 16 / mmax / 2;
        calculoButterflyLoopBloco(data, m, mmax, istep, wr, wi, tamBloco);
        calculoButterflyLoopBloco(data, 16 * 2 / 2 + m, mmax, istep, wr, wi,
                                  tamBloco);
      } else {
        printf("     processa na main\n");
        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    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x2,-0x10(%rbp)
mov    $0x20,%eax
cmp    -0x10(%rbp),%rax
jbe    1398 <fft+0x258>
mov    -0x10(%rbp),%rsi
lea    0xed2(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
add    %rax,%rax
mov    %rax,-0x28(%rbp)
movaps 0xe99(%rip),%xmm1
movq   -0x10(%rbp),%xmm0
punpckldq %xmm1,%xmm0
movapd 0xe98(%rip),%xmm1
subpd  %xmm1,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  0xe69(%rip),%xmm1
divsd  %xmm0,%xmm1
movsd  0xe45(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  0xe44(%rip),%xmm0
mulsd  -0x60(%rbp),%xmm0
call   1060 <sin@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  0xe25(%rip),%xmm0
mulsd  -0x38(%rbp),%xmm0
mulsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x60(%rbp),%xmm0
call   1060 <sin@plt>
movsd  %xmm0,-0x50(%rbp)
movsd  0xdf7(%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    1375 <fft+0x235>
mov    -0x20(%rbp),%rsi
mov    -0x10(%rbp),%rdx
lea    0xe26(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x10,%eax
xor    %ecx,%ecx
mov    %ecx,%edx
divq   -0x10(%rbp)
cmp    $0x2,%rax
jb     12cf <fft+0x18f>
lea    0xe23(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x10,%eax
xor    %ecx,%ecx
mov    %ecx,%edx
divq   -0x10(%rbp)
shr    $0x1,%rax
mov    %rax,-0x68(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rax
mov    %eax,%esi
mov    -0x10(%rbp),%rdx
mov    -0x28(%rbp),%rcx
movsd  -0x40(%rbp),%xmm0
movsd  -0x58(%rbp),%xmm1
mov    -0x68(%rbp),%r8
call   1040 <calculoButterflyLoopBloco@plt>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rax
add    $0x10,%rax
mov    %eax,%esi
mov    -0x10(%rbp),%rdx
mov    -0x28(%rbp),%rcx
movsd  -0x40(%rbp),%xmm0
movsd  -0x58(%rbp),%xmm1
mov    -0x68(%rbp),%r8
call   1040 <calculoButterflyLoopBloco@plt>
jmp    12fc <fft+0x1bc>
lea    0xdc6(%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   1050 <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    121e <fft+0xde>
mov    -0x28(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x28(%rbp),%rsi
mov    -0x10(%rbp),%rdx
lea    0xd27(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1154 <fft+0x14>
add    $0x70,%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,%r15
mov    $0x2,%ebx
xorpd  %xmm0,%xmm0
movhpd 0xed6(%rip),%xmm0
movapd %xmm0,0x40(%rsp)
lea    0xef2(%rip),%r12
mov    $0x10,%al
movzbl %al,%eax
mov    %ax,0xe(%rsp)
jmp    11b1 <fft+0x61>
nopl   0x0(%rax,%rax,1)
lea    0xefc(%rip),%rdi
mov    %r13,%rsi
mov    %r13,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x10,%rbx
mov    %r13,%rbx
jae    1355 <fft+0x205>
lea    0xe98(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    (%rbx,%rbx,1),%r13
movq   %rbx,%xmm0
punpckldq 0xe2d(%rip),%xmm0
subpd  0xe35(%rip),%xmm0
movapd %xmm0,%xmm1
unpckhpd %xmm0,%xmm1
addsd  %xmm0,%xmm1
movsd  0xe41(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,0x10(%rsp)
mulsd  0xe37(%rip),%xmm0
call   1070 <sin@plt>
movapd %xmm0,%xmm1
mulsd  0xe2e(%rip),%xmm1
mulsd  %xmm0,%xmm1
movapd %xmm1,0x20(%rsp)
movsd  0x10(%rsp),%xmm0
call   1070 <sin@plt>
movaps 0x20(%rsp),%xmm1
movlhps %xmm1,%xmm1
movaps %xmm1,0x20(%rsp)
movlhps %xmm0,%xmm0
movaps %xmm0,0x60(%rsp)
mov    $0x1,%r14d
movaps 0x40(%rsp),%xmm2
mov    %rbx,0x38(%rsp)
jmp    12b9 <fft+0x169>
xchg   %ax,%ax
lea    0xe67(%rip),%rdi
call   1030 <puts@plt>
movaps 0x10(%rsp),%xmm1
movaps %xmm1,%xmm0
unpckhpd %xmm1,%xmm0
mov    %r15,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
mov    %r13,%rcx
call   1060 <calculoButterflyLoopCompleto@plt>
movapd 0x10(%rsp),%xmm2
movapd %xmm2,%xmm0
xorpd  0xd95(%rip),%xmm0
movapd %xmm2,%xmm1
shufpd $0x1,%xmm0,%xmm1
mulpd  0x60(%rsp),%xmm1
movapd %xmm2,%xmm0
mulpd  0x20(%rsp),%xmm0
addpd  %xmm1,%xmm0
addpd  %xmm0,%xmm2
add    $0x2,%r14
cmp    %rbx,%r14
jae    1190 <fft+0x40>
movaps %xmm2,0x10(%rsp)
mov    %r12,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x8,%rbx
ja     1250 <fft+0x100>
movzwl 0xe(%rsp),%eax
div    %bl
mov    %r13,%rbx
mov    %r15,%r13
mov    %r12,%r15
mov    %eax,%r12d
lea    0xde2(%rip),%rdi
call   1030 <puts@plt>
shr    %r12b
movzbl %r12b,%ebp
mov    %r15,%r12
mov    %r13,%r15
mov    %rbx,%r13
mov    0x38(%rsp),%rbx
movaps 0x10(%rsp),%xmm1
movaps %xmm1,%xmm0
unpckhpd %xmm1,%xmm0
movaps %xmm0,0x50(%rsp)
mov    %r15,%rdi
mov    %r14d,%esi
mov    %rbx,%rdx
mov    %r13,%rcx
mov    %rbp,%r8
call   1050 <calculoButterflyLoopBloco@plt>
lea    0x10(%r14),%esi
mov    %r15,%rdi
mov    %rbx,%rdx
mov    %r13,%rcx
movaps 0x50(%rsp),%xmm0
movaps 0x10(%rsp),%xmm1
mov    %rbp,%r8
call   1050 <calculoButterflyLoopBloco@plt>
jmp    1279 <fft+0x129>
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 = [25 x i8] c" processa em thread\0A\00"
@.str.3 = [23 x i8] c" processa na main\0A\00"
@.str.4 = [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
%14 = alloca i64
store float* %0, float** %2
store i64 2, i64* %3
br label %15
15: ; preds = %101, %1
%16 = load i64, i64* %3
%17 = icmp ugt i64 32, %16
br i1 %17, label %18, label %106
18: ; preds = %15
%19 = load i64, i64* %3
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i64 %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 = %98, %18
%37 = load i64, i64* %5
%38 = load i64, i64* %3
%39 = icmp ult i64 %37, %38
br i1 %39, label %40, label %101
40: ; preds = %36
%41 = load i64, i64* %5
%42 = load i64, i64* %3
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i64 %41, i64 %42)
%44 = load i64, i64* %3
%45 = udiv i64 16, %44
%46 = icmp uge i64 %45, 2
br i1 %46, label %47, label %71
47: ; preds = %40
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
%49 = load i64, i64* %3
%50 = udiv i64 16, %49
%51 = udiv i64 %50, 2
store i64 %51, i64* %14
%52 = load float*, float** %2
%53 = load i64, i64* %5
%54 = trunc i64 %53 to i32
%55 = load i64, i64* %3
%56 = load i64, i64* %6
%57 = load double, double* %9
%58 = load double, double* %12
%59 = load i64, i64* %14
%60 = call i32 @calculoButterflyLoopBloco(float* %52, i32 %54, i64 %55, i64 %56, double %57, double %58, i64 %59)
%61 = load float*, float** %2
%62 = load i64, i64* %5
%63 = add i64 16, %62
%64 = trunc i64 %63 to i32
%65 = load i64, i64* %3
%66 = load i64, i64* %6
%67 = load double, double* %9
%68 = load double, double* %12
%69 = load i64, i64* %14
%70 = call i32 @calculoButterflyLoopBloco(float* %61, i32 %64, i64 %65, i64 %66, double %67, double %68, i64 %69)
br label %80
71: ; preds = %40
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0))
%73 = load float*, float** %2
%74 = load i64, i64* %5
%75 = load i64, i64* %3
%76 = load i64, i64* %6
%77 = load double, double* %9
%78 = load double, double* %12
%79 = call i32 @calculoButterflyLoopCompleto(float* %73, i64 %74, i64 %75, i64 %76, double %77, double %78)
br label %80
80: ; preds = %71, %47
%81 = load double, double* %9
store double %81, double* %8
%82 = load double, double* %10
%83 = load double, double* %12
%84 = load double, double* %11
%85 = fmul double %83, %84
%86 = fneg double %85
%87 = call double @llvm.fmuladd.f64(double %81, double %82, double %86)
%88 = load double, double* %9
%89 = fadd double %87, %88
store double %89, double* %9
%90 = load double, double* %12
%91 = load double, double* %10
%92 = load double, double* %8
%93 = load double, double* %11
%94 = fmul double %92, %93
%95 = call double @llvm.fmuladd.f64(double %90, double %91, double %94)
%96 = load double, double* %12
%97 = fadd double %95, %96
store double %97, double* %12
br label %98
98: ; preds = %80
%99 = load i64, i64* %5
%100 = add i64 %99, 2
store i64 %100, i64* %5
br label %36
101: ; preds = %36
%102 = load i64, i64* %6
store i64 %102, i64* %3
%103 = load i64, i64* %6
%104 = load i64, i64* %3
%105 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.4, i64 0, i64 0), i64 %103, i64 %104)
br label %15
106: ; preds = %15
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.4 = [43 x i8] c"<<< Final do while -> istep:%lu mmax:%lu\0A\0A\00"
@str = [22 x i8] c" processa na main\00"
@str.5 = [24 x i8] c" processa em thread\00"
define void @fft(float* %0) {
br label %2
2: ; preds = %50, %1
%3 = phi i64 [ 2, %1 ], [ %5, %50 ]
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) 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 = icmp ult i64 %3, 9
%14 = trunc i64 %3 to i8
%15 = insertelement <2 x double> poison, double %11, i64 0
%16 = shufflevector <2 x double> %15, <2 x double> poison, <2 x i32> zeroinitializer
%17 = insertelement <2 x double> poison, double %12, i64 0
%18 = shufflevector <2 x double> %17, <2 x double> poison, <2 x i32> zeroinitializer
br label %19
19: ; preds = %2, %39
%20 = phi i64 [ 1, %2 ], [ %48, %39 ]
%21 = phi <2 x double> [ <double 0.000000e+00, double 1.000000e+00>, %2 ], [ %47, %39 ]
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i64 %20, i64 %3)
br i1 %13, label %23, label %34
23: ; preds = %19
%24 = udiv i8 16, %14
%25 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.5, i64 0, i64 0))
%26 = lshr i8 %24, 1
%27 = zext i8 %26 to i64
%28 = trunc i64 %20 to i32
%29 = extractelement <2 x double> %21, i64 0
%30 = extractelement <2 x double> %21, i64 1
%31 = tail call i32 @calculoButterflyLoopBloco(float* %0, i32 %28, i64 %3, i64 %5, double %30, double %29, i64 %27)
%32 = add i32 %28, 16
%33 = tail call i32 @calculoButterflyLoopBloco(float* %0, i32 %32, i64 %3, i64 %5, double %30, double %29, i64 %27)
br label %39
34: ; preds = %19
%35 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
%36 = extractelement <2 x double> %21, i64 0
%37 = extractelement <2 x double> %21, i64 1
%38 = tail call i32 @calculoButterflyLoopCompleto(float* %0, i64 %20, i64 %3, i64 %5, double %37, double %36)
br label %39
39: ; preds = %34, %23
%40 = extractelement <2 x double> %21, i64 0
%41 = fneg double %40
%42 = extractelement <2 x double> %21, i64 1
%43 = insertelement <2 x double> poison, double %42, i64 0
%44 = insertelement <2 x double> %43, double %41, i64 1
%45 = fmul <2 x double> %18, %44
%46 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %21, <2 x double> %16, <2 x double> %45)
%47 = fadd <2 x double> %21, %46
%48 = add nuw nsw i64 %20, 2
%49 = icmp ult i64 %48, %3
br i1 %49, label %19, label %50
50: ; preds = %39
%51 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.4, i64 0, i64 0), i64 %5, i64 %5)
%52 = icmp ult i64 %3, 16
br i1 %52, label %2, label %53
53: ; preds = %50
ret void
}