#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 *, unsigned long,
                                             unsigned long, unsigned long,
                                             double, double, int);
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;
        unsigned long blocoAtual;
        for (blocoAtual = 0; blocoAtual < 2; blocoAtual++) {
          printf("     qtdBlocos:%lu\n", blocoAtual);
          calculoButterflyLoopBloco(data, ((16 * 2 / 2) * blocoAtual) + m, mmax,
                                    istep, wr, wi, tamBloco);
        }
      } else {
        printf("     processa na main\n");
        calculoButterflyLoopBloco(data, m, mmax, istep, wr, wi, 16 / mmax);
      }
      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    $0x80,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x2,-0x10(%rbp)
mov    $0x20,%eax
cmp    -0x10(%rbp),%rax
jbe    13b7 <fft+0x287>
mov    -0x10(%rbp),%rsi
lea    0xedf(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
add    %rax,%rax
mov    %rax,-0x28(%rbp)
movaps 0xea6(%rip),%xmm1
movq   -0x10(%rbp),%xmm0
punpckldq %xmm1,%xmm0
movapd 0xea5(%rip),%xmm1
subpd  %xmm1,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  0xe76(%rip),%xmm1
divsd  %xmm0,%xmm1
movsd  0xe52(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  0xe51(%rip),%xmm0
mulsd  -0x60(%rbp),%xmm0
call   1050 <sin@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  0xe32(%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  0xe04(%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    1394 <fft+0x264>
mov    -0x20(%rbp),%rsi
mov    -0x10(%rbp),%rdx
lea    0xe33(%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     12d8 <fft+0x1a8>
lea    0xe30(%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)
movq   $0x0,-0x70(%rbp)
cmpq   $0x2,-0x70(%rbp)
jae    12d3 <fft+0x1a3>
mov    -0x70(%rbp),%rsi
lea    0xe0f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x70(%rbp),%rsi
shl    $0x4,%rsi
add    -0x20(%rbp),%rsi
mov    -0x10(%rbp),%rdx
mov    -0x28(%rbp),%rcx
movsd  -0x40(%rbp),%xmm0
movsd  -0x58(%rbp),%xmm1
mov    -0x68(%rbp),%rax
mov    %eax,%r8d
call   1040 <calculoButterflyLoopBloco@plt>
mov    -0x70(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x70(%rbp)
jmp    1277 <fft+0x147>
jmp    131b <fft+0x1eb>
lea    0xdd1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x10(%rbp),%rax
mov    %rax,-0x78(%rbp)
mov    -0x28(%rbp),%rcx
movsd  -0x40(%rbp),%xmm0
movsd  -0x58(%rbp),%xmm1
mov    $0x10,%eax
xor    %edx,%edx
divq   -0x10(%rbp)
mov    -0x78(%rbp),%rdx
mov    %eax,%r8d
call   1040 <calculoButterflyLoopBloco@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    1211 <fft+0xe1>
mov    -0x28(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x28(%rbp),%rsi
mov    -0x10(%rbp),%rdx
lea    0xd1c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1147 <fft+0x17>
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fft>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
mov    %rdi,0x18(%rsp)
mov    $0x2,%ebx
xorpd  %xmm0,%xmm0
movhpd 0xee4(%rip),%xmm0
movapd %xmm0,0x30(%rsp)
mov    0x18(%rsp),%r13
jmp    11a6 <fft+0x66>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    0xf20(%rip),%rdi
mov    0x10(%rsp),%rbp
mov    %rbp,%rsi
mov    %rbp,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x10,%rbx
mov    %rbp,%rbx
jae    1381 <fft+0x241>
lea    0xea3(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    (%rbx,%rbx,1),%rax
mov    %rax,0x10(%rsp)
movq   %rbx,%xmm0
punpckldq 0xe33(%rip),%xmm0
subpd  0xe3b(%rip),%xmm0
movapd %xmm0,%xmm1
unpckhpd %xmm0,%xmm1
addsd  %xmm0,%xmm1
movsd  0xe47(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,(%rsp)
mulsd  0xe3e(%rip),%xmm0
call   1060 <sin@plt>
movapd %xmm0,%xmm1
mulsd  0xe35(%rip),%xmm1
mulsd  %xmm0,%xmm1
movapd %xmm1,0x20(%rsp)
movsd  (%rsp),%xmm0
call   1060 <sin@plt>
movaps 0x20(%rsp),%xmm1
movlhps %xmm1,%xmm1
movaps %xmm1,0x20(%rsp)
movlhps %xmm0,%xmm0
movaps %xmm0,0x50(%rsp)
mov    $0x11,%r14d
movaps 0x30(%rsp),%xmm2
jmp    12c5 <fft+0x185>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
lea    0xe7b(%rip),%rdi
call   1030 <puts@plt>
movaps (%rsp),%xmm1
movaps %xmm1,%xmm0
unpckhpd %xmm1,%xmm0
mov    0x18(%rsp),%rdi
mov    %rbp,%rsi
mov    %rbx,%rdx
mov    0x10(%rsp),%rcx
mov    %r12d,%r8d
call   1050 <calculoButterflyLoopBloco@plt>
movapd (%rsp),%xmm2
movapd %xmm2,%xmm0
xorpd  0xd90(%rip),%xmm0
movapd %xmm2,%xmm1
shufpd $0x1,%xmm0,%xmm1
mulpd  0x50(%rsp),%xmm1
movapd %xmm2,%xmm0
mulpd  0x20(%rsp),%xmm0
addpd  %xmm1,%xmm0
addpd  %xmm0,%xmm2
lea    0x2(%r14),%rax
add    $0xfffffffffffffff2,%r14
cmp    %rbx,%r14
mov    %rax,%r14
jae    1180 <fft+0x40>
movaps %xmm2,(%rsp)
lea    -0x10(%r14),%rbp
lea    0xd9d(%rip),%rdi
mov    %rbp,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x10,%rbx
ja     1300 <fft+0x1c0>
mov    $0x10,%eax
xor    %edx,%edx
div    %ebx
mov    %eax,%r12d
cmp    $0x8,%rbx
ja     1250 <fft+0x110>
jmp    130d <fft+0x1cd>
nop
xor    %r12d,%r12d
cmp    $0x8,%rbx
ja     1250 <fft+0x110>
lea    0xdd4(%rip),%rdi
call   1030 <puts@plt>
shr    %r12
lea    0xd70(%rip),%r15
mov    %r15,%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1040 <printf@plt>
movaps (%rsp),%xmm1
movaps %xmm1,%xmm0
unpckhpd %xmm1,%xmm0
movaps %xmm0,0x40(%rsp)
mov    %r13,%rdi
mov    %rbp,%rsi
mov    %rbx,%rdx
mov    0x10(%rsp),%rbp
mov    %rbp,%rcx
mov    %r12d,%r8d
call   1050 <calculoButterflyLoopBloco@plt>
mov    $0x1,%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r13,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
mov    %rbp,%rcx
movaps 0x40(%rsp),%xmm0
movaps (%rsp),%xmm1
jmp    1277 <fft+0x137>
add    $0x68,%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 = [20 x i8] c" qtdBlocos:%lu\0A\00"
@.str.4 = [23 x i8] c" processa na main\0A\00"
@.str.5 = [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
%15 = alloca i64
store float* %0, float** %2
store i64 2, i64* %3
br label %16
16: ; preds = %108, %1
%17 = load i64, i64* %3
%18 = icmp ugt i64 32, %17
br i1 %18, label %19, label %113
19: ; preds = %16
%20 = load i64, i64* %3
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i64 %20)
%22 = load i64, i64* %3
%23 = shl i64 %22, 1
store i64 %23, i64* %6
%24 = load i64, i64* %3
%25 = uitofp i64 %24 to double
%26 = fdiv double 0x401921FB54442D1C, %25
%27 = fmul double 1.000000e+00, %26
store double %27, double* %13
%28 = load double, double* %13
%29 = fmul double 5.000000e-01, %28
%30 = call double @sin(double %29)
store double %30, double* %8
%31 = load double, double* %8
%32 = fmul double -2.000000e+00, %31
%33 = load double, double* %8
%34 = fmul double %32, %33
store double %34, double* %10
%35 = load double, double* %13
%36 = call double @sin(double %35)
store double %36, double* %11
store double 1.000000e+00, double* %9
store double 0.000000e+00, double* %12
store i64 1, i64* %5
br label %37
37: ; preds = %105, %19
%38 = load i64, i64* %5
%39 = load i64, i64* %3
%40 = icmp ult i64 %38, %39
br i1 %40, label %41, label %108
41: ; preds = %37
%42 = load i64, i64* %5
%43 = load i64, i64* %3
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i64 %42, i64 %43)
%45 = load i64, i64* %3
%46 = udiv i64 16, %45
%47 = icmp uge i64 %46, 2
br i1 %47, label %48, label %75
48: ; preds = %41
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
%50 = load i64, i64* %3
%51 = udiv i64 16, %50
%52 = udiv i64 %51, 2
store i64 %52, i64* %14
store i64 0, i64* %15
br label %53
53: ; preds = %71, %48
%54 = load i64, i64* %15
%55 = icmp ult i64 %54, 2
br i1 %55, label %56, label %74
56: ; preds = %53
%57 = load i64, i64* %15
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i64 %57)
%59 = load float*, float** %2
%60 = load i64, i64* %15
%61 = mul i64 16, %60
%62 = load i64, i64* %5
%63 = add i64 %61, %62
%64 = load i64, i64* %3
%65 = load i64, i64* %6
%66 = load double, double* %9
%67 = load double, double* %12
%68 = load i64, i64* %14
%69 = trunc i64 %68 to i32
%70 = call i32 @calculoButterflyLoopBloco(float* %59, i64 %63, i64 %64, i64 %65, double %66, double %67, i32 %69)
br label %71
71: ; preds = %56
%72 = load i64, i64* %15
%73 = add i64 %72, 1
store i64 %73, i64* %15
br label %53
74: ; preds = %53
br label %87
75: ; preds = %41
%76 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0))
%77 = load float*, float** %2
%78 = load i64, i64* %5
%79 = load i64, i64* %3
%80 = load i64, i64* %6
%81 = load double, double* %9
%82 = load double, double* %12
%83 = load i64, i64* %3
%84 = udiv i64 16, %83
%85 = trunc i64 %84 to i32
%86 = call i32 @calculoButterflyLoopBloco(float* %77, i64 %78, i64 %79, i64 %80, double %81, double %82, i32 %85)
br label %87
87: ; preds = %75, %74
%88 = load double, double* %9
store double %88, double* %8
%89 = load double, double* %10
%90 = load double, double* %12
%91 = load double, double* %11
%92 = fmul double %90, %91
%93 = fneg double %92
%94 = call double @llvm.fmuladd.f64(double %88, double %89, double %93)
%95 = load double, double* %9
%96 = fadd double %94, %95
store double %96, double* %9
%97 = load double, double* %12
%98 = load double, double* %10
%99 = load double, double* %8
%100 = load double, double* %11
%101 = fmul double %99, %100
%102 = call double @llvm.fmuladd.f64(double %97, double %98, double %101)
%103 = load double, double* %12
%104 = fadd double %102, %103
store double %104, double* %12
br label %105
105: ; preds = %87
%106 = load i64, i64* %5
%107 = add i64 %106, 2
store i64 %107, i64* %5
br label %37
108: ; preds = %37
%109 = load i64, i64* %6
store i64 %109, i64* %3
%110 = load i64, i64* %6
%111 = load i64, i64* %3
%112 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.5, i64 0, i64 0), i64 %110, i64 %111)
br label %16
113: ; preds = %16
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.3 = [20 x i8] c" qtdBlocos:%lu\0A\00"
@.str.5 = [43 x i8] c"<<< Final do while -> istep:%lu mmax:%lu\0A\0A\00"
@str = [22 x i8] c" processa na main\00"
@str.6 = [24 x i8] c" processa em thread\00"
define void @fft(float* %0) {
br label %2
2: ; preds = %51, %1
%3 = phi i64 [ 2, %1 ], [ %5, %51 ]
%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 = insertelement <2 x double> poison, double %11, i64 0
%15 = shufflevector <2 x double> %14, <2 x double> poison, <2 x i32> zeroinitializer
%16 = insertelement <2 x double> poison, double %12, i64 0
%17 = shufflevector <2 x double> %16, <2 x double> poison, <2 x i32> zeroinitializer
br label %18
18: ; preds = %2, %40
%19 = phi i64 [ 1, %2 ], [ %49, %40 ]
%20 = phi <2 x double> [ <double 0.000000e+00, double 1.000000e+00>, %2 ], [ %48, %40 ]
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i64 %19, i64 %3)
%22 = udiv i64 16, %3
br i1 %13, label %23, label %34
23: ; preds = %18
%24 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.6, i64 0, i64 0))
%25 = lshr i64 %22, 1
%26 = trunc i64 %25 to i32
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i64 0)
%28 = extractelement <2 x double> %20, i64 0
%29 = extractelement <2 x double> %20, i64 1
%30 = tail call i32 @calculoButterflyLoopBloco(float* %0, i64 %19, i64 %3, i64 %5, double %29, double %28, i32 %26)
%31 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i64 1)
%32 = add nuw nsw i64 %19, 16
%33 = tail call i32 @calculoButterflyLoopBloco(float* %0, i64 %32, i64 %3, i64 %5, double %29, double %28, i32 %26)
br label %40
34: ; preds = %18
%35 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
%36 = trunc i64 %22 to i32
%37 = extractelement <2 x double> %20, i64 0
%38 = extractelement <2 x double> %20, i64 1
%39 = tail call i32 @calculoButterflyLoopBloco(float* %0, i64 %19, i64 %3, i64 %5, double %38, double %37, i32 %36)
br label %40
40: ; preds = %23, %34
%41 = extractelement <2 x double> %20, i64 0
%42 = fneg double %41
%43 = extractelement <2 x double> %20, i64 1
%44 = insertelement <2 x double> poison, double %43, i64 0
%45 = insertelement <2 x double> %44, double %42, i64 1
%46 = fmul <2 x double> %17, %45
%47 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %20, <2 x double> %15, <2 x double> %46)
%48 = fadd <2 x double> %20, %47
%49 = add nuw nsw i64 %19, 2
%50 = icmp ult i64 %49, %3
br i1 %50, label %18, label %51
51: ; preds = %40
%52 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.5, i64 0, i64 0), i64 %5, i64 %5)
%53 = icmp ult i64 %3, 16
br i1 %53, label %2, label %54
54: ; preds = %51
ret void
}