#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 atoi(char *);
int /*<<< orphan*/ fft(float *, unsigned long, int);
int /*<<< orphan*/ free(float *);
int /*<<< orphan*/ imprimeVetor(float *, unsigned long);
float *malloc(int);
int /*<<< orphan*/ printf(char *);
unsigned long strtoul(char *, int /*<<< orphan*/ *, int);
int main(int argc, char *argv[]) {
  unsigned long tamTotalArray, qtdElementos, qtdElementosArray;
  int qtdProcessos;
  float *data;
  if (argc < 3) {
    printf("ERRO: informe s quantidade de elementos do FFT, a quantidade de "
           "threads : <./fft-mpi> <qtdElementos> <qtdProcessos> \n");
    return -1;
  }
  qtdElementos = strtoul(argv[1], NULL, 10);
  qtdElementosArray = qtdElementos * 2;
  tamTotalArray = qtdElementosArray + 1;
  qtdProcessos = atoi(argv[2]);
  data = malloc(sizeof(float) * tamTotalArray);
  fft(data, tamTotalArray, qtdProcessos);
  imprimeVetor(data, tamTotalArray);
  free(data);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    11a8 <main+0x38>
lea    0xe69(%rip),%rdi
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1223 <main+0xb3>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1060 <strtoul@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
shl    $0x1,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x18(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x2c(%rbp),%edx
call   1090 <fft@plt>
mov    -0x38(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1080 <imprimeVetor@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
cmp    $0x2,%edi
jg     1190 <main+0x20>
lea    0xe7d(%rip),%rdi
call   1040 <puts@plt>
mov    $0xffffffff,%r14d
jmp    11e9 <main+0x79>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
xor    %r14d,%r14d
xor    %esi,%esi
mov    $0xa,%edx
call   1060 <strtoul@plt>
lea    (%rax,%rax,1),%r15
add    $0x1,%r15
mov    0x10(%rbx),%rdi
call   1070 <atoi@plt>
mov    %eax,%ebp
lea    0x0(,%r15,4),%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r15,%rsi
mov    %ebp,%edx
call   1090 <fft@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1080 <imprimeVetor@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [118 x i8] c"ERRO: informe s quantidade de elementos do FFT, a quantidade de threads : <./fft-mpi> <qtdElementos> <qtdProcessos> \0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
%9 = alloca i32
%10 = alloca float*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* %4
%12 = icmp slt i32 %11, 3
br i1 %12, label %13, label %15
13: ; preds = %2
%14 = call i32 @printf(i8* getelementptr inbounds ([118 x i8], [118 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
br label %41
15: ; preds = %2
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
%19 = call i64 @strtoul(i8* %18, i32* null, i32 10)
store i64 %19, i64* %7
%20 = load i64, i64* %7
%21 = mul i64 %20, 2
store i64 %21, i64* %8
%22 = load i64, i64* %8
%23 = add i64 %22, 1
store i64 %23, i64* %6
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 2
%26 = load i8*, i8** %25
%27 = call i32 @atoi(i8* %26)
store i32 %27, i32* %9
%28 = load i64, i64* %6
%29 = mul i64 4, %28
%30 = trunc i64 %29 to i32
%31 = call float* @malloc(i32 %30)
store float* %31, float** %10
%32 = load float*, float** %10
%33 = load i64, i64* %6
%34 = load i32, i32* %9
%35 = call i32 @fft(float* %32, i64 %33, i32 %34)
%36 = load float*, float** %10
%37 = load i64, i64* %6
%38 = call i32 @imprimeVetor(float* %36, i64 %37)
%39 = load float*, float** %10
%40 = call i32 @free(float* %39)
br label %41
41: ; preds = %15, %13
%42 = load i32, i32* %3
ret i32 %42
}

LLVM IR (-O2):
@str = [117 x i8] c"ERRO: informe s quantidade de elementos do FFT, a quantidade de threads : <./fft-mpi> <qtdElementos> <qtdProcessos> \00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 3
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([117 x i8], [117 x i8]* @str, i64 0, i64 0))
br label %21
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i64 @strtoul(i8* nocapture %8, i32* null, i32 10)
%10 = shl i64 %9, 1
%11 = or i64 %10, 1
%12 = getelementptr inbounds i8*, i8** %1, i64 2
%13 = load i8*, i8** %12
%14 = tail call i32 @atoi(i8* %13)
%15 = trunc i64 %11 to i32
%16 = shl i32 %15, 2
%17 = tail call float* @malloc(i32 %16)
%18 = tail call i32 @fft(float* %17, i64 %11, i32 %14)
%19 = tail call i32 @imprimeVetor(float* %17, i64 %11)
%20 = tail call i32 @free(float* %17)
br label %21
21: ; preds = %6, %4
%22 = phi i32 [ -1, %4 ], [ 0, %6 ]
ret i32 %22
}