#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ carregaVetor(float *, int /*<<< orphan*/ *, int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ four1(float *, int *, int *);
scalar_t__ fscanf(int /*<<< orphan*/ *, char *, int *);
float *malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  int j = 1;
  int positivoValue = 1;
  int *positivo;
  int tamVetValue = 0;
  int *tamVet;
  float *array_f;
  FILE *fA;
  tamVet = &tamVetValue;
  positivo = &positivoValue;
  if (argc < 2) {
    printf("ERRO: lista de argumentos incorreta: \n<prog> <arq-vetor> \n");
    return -1;
  }
  fA = fopen(argv[1], "r");
  if (fA == NULL) {
    printf("ERRO: leitura do arquivo com o vetor\n");
    return -1;
  }
  if (fscanf(fA, "%d", tamVet) == 0) {
    printf("erro ao ler o tamanho do vetor");
    return -1;
  }
  array_f = malloc(sizeof(float) * (*tamVet));
  if (array_f == NULL) {
    printf("ERRO: alocação do vetor\n");
    return -1;
  }
  if (!carregaVetor(array_f, fA, *tamVet))
    return -1;
  fclose(fA);
  four1(array_f, tamVet, positivo);
  for (j = 0; j < 8; j++)
    printf("%f ", array_f[j]);
  for (j = 0; j < 100000; j++) {
    four1(array_f, tamVet, positivo);
  }
  return 1;
}


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)
movl   $0x1,-0x14(%rbp)
movl   $0x1,-0x18(%rbp)
movl   $0x0,-0x24(%rbp)
lea    -0x24(%rbp),%rax
mov    %rax,-0x30(%rbp)
lea    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    11cf <main+0x5f>
lea    0xe44(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1339 <main+0x1c9>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xea3(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    120c <main+0x9c>
lea    0xe42(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1339 <main+0x1c9>
mov    -0x40(%rbp),%rdi
mov    -0x30(%rbp),%rdx
lea    0xe46(%rip),%rsi
call   1060 <fscanf@plt>
cmp    $0x0,%rax
jne    1244 <main+0xd4>
lea    0xe33(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1339 <main+0x1c9>
mov    -0x30(%rbp),%rax
movslq (%rax),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1080 <malloc@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    127f <main+0x10f>
lea    0xe17(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1339 <main+0x1c9>
mov    -0x38(%rbp),%rdi
mov    -0x40(%rbp),%rsi
mov    -0x30(%rbp),%rax
mov    (%rax),%edx
call   1030 <carregaVetor@plt>
cmp    $0x0,%eax
jne    12a7 <main+0x137>
movl   $0xffffffff,-0x4(%rbp)
jmp    1339 <main+0x1c9>
mov    -0x40(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x38(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1070 <four1@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x8,-0x14(%rbp)
jge    12ff <main+0x18f>
mov    -0x38(%rbp),%rax
movslq -0x14(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdb4(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    12c8 <main+0x158>
movl   $0x0,-0x14(%rbp)
cmpl   $0x186a0,-0x14(%rbp)
jge    1332 <main+0x1c2>
mov    -0x38(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1070 <four1@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1306 <main+0x196>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
movl   $0x1,0xc(%rsp)
movl   $0x0,0x8(%rsp)
cmp    $0x1,%edi
jg     11ad <main+0x2d>
lea    0xebd(%rip),%rdi
jmp    131a <main+0x19a>
mov    0x8(%rsi),%rdi
lea    0xeab(%rip),%rsi
call   10a0 <fopen@plt>
test   %rax,%rax
je     12fa <main+0x17a>
mov    %rax,%r14
lea    0xe30(%rip),%rsi
lea    0x8(%rsp),%rdx
mov    %rax,%rdi
call   1070 <fscanf@plt>
test   %rax,%rax
je     1303 <main+0x183>
mov    0x8(%rsp),%r15d
lea    0x0(,%r15,4),%edi
call   1090 <malloc@plt>
test   %rax,%rax
je     1313 <main+0x193>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r14,%rsi
mov    %r15d,%edx
call   1030 <carregaVetor@plt>
test   %eax,%eax
je     131f <main+0x19f>
mov    %r14,%rdi
call   1050 <fclose@plt>
lea    0x8(%rsp),%r14
lea    0xc(%rsp),%r15
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1080 <four1@plt>
movss  (%rbx),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdd9(%rip),%r12
mov    %r12,%rdi
mov    $0x1,%al
call   1060 <printf@plt>
movss  0x4(%rbx),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r12,%rdi
mov    $0x1,%al
call   1060 <printf@plt>
movss  0x8(%rbx),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r12,%rdi
mov    $0x1,%al
call   1060 <printf@plt>
movss  0xc(%rbx),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r12,%rdi
mov    $0x1,%al
call   1060 <printf@plt>
movss  0x10(%rbx),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r12,%rdi
mov    $0x1,%al
call   1060 <printf@plt>
movss  0x14(%rbx),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r12,%rdi
mov    $0x1,%al
call   1060 <printf@plt>
movss  0x18(%rbx),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r12,%rdi
mov    $0x1,%al
call   1060 <printf@plt>
movss  0x1c(%rbx),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r12,%rdi
mov    $0x1,%al
call   1060 <printf@plt>
mov    $0x186a0,%ebp
nopl   (%rax)
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1080 <four1@plt>
add    $0xffffffff,%ebp
jne    12e0 <main+0x160>
mov    $0x1,%eax
jmp    1324 <main+0x1a4>
lea    0xd3f(%rip),%rdi
jmp    131a <main+0x19a>
lea    0xcf9(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    131f <main+0x19f>
lea    0xd0c(%rip),%rdi
call   1040 <puts@plt>
mov    $0xffffffff,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [59 x i8] c"ERRO: lista de argumentos incorreta: \0A<prog> <arq-vetor> \0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [38 x i8] c"ERRO: leitura do arquivo com o vetor\0A\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [31 x i8] c"erro ao ler o tamanho do vetor\00"
@.str.5 = [27 x i8] c"ERRO: aloca\C3\A7\C3\A3o do vetor\0A\00"
@.str.6 = [4 x i8] c"%f \00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32*
%9 = alloca i32
%10 = alloca i32*
%11 = alloca float*
%12 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %6
store i32 1, i32* %7
store i32 0, i32* %9
store i32* %9, i32** %10
store i32* %7, i32** %8
%13 = load i32, i32* %4
%14 = icmp slt i32 %13, 2
br i1 %14, label %15, label %17
15: ; preds = %2
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
br label %86
17: ; preds = %2
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = call i32* @fopen(i8* %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %21, i32** %12
%22 = load i32*, i32** %12
%23 = icmp eq i32* %22, null
br i1 %23, label %24, label %26
24: ; preds = %17
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %3
br label %86
26: ; preds = %17
%27 = load i32*, i32** %12
%28 = load i32*, i32** %10
%29 = call i64 @fscanf(i32* %27, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %28)
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %33
31: ; preds = %26
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0))
store i32 -1, i32* %3
br label %86
33: ; preds = %26
%34 = load i32*, i32** %10
%35 = load i32, i32* %34
%36 = sext i32 %35 to i64
%37 = mul i64 4, %36
%38 = trunc i64 %37 to i32
%39 = call float* @malloc(i32 %38)
store float* %39, float** %11
%40 = load float*, float** %11
%41 = icmp eq float* %40, null
br i1 %41, label %42, label %44
42: ; preds = %33
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0))
store i32 -1, i32* %3
br label %86
44: ; preds = %33
%45 = load float*, float** %11
%46 = load i32*, i32** %12
%47 = load i32*, i32** %10
%48 = load i32, i32* %47
%49 = call i32 @carregaVetor(float* %45, i32* %46, i32 %48)
%50 = icmp ne i32 %49, 0
br i1 %50, label %52, label %51
51: ; preds = %44
store i32 -1, i32* %3
br label %86
52: ; preds = %44
%53 = load i32*, i32** %12
%54 = call i32 @fclose(i32* %53)
%55 = load float*, float** %11
%56 = load i32*, i32** %10
%57 = load i32*, i32** %8
%58 = call i32 @four1(float* %55, i32* %56, i32* %57)
store i32 0, i32* %6
br label %59
59: ; preds = %70, %52
%60 = load i32, i32* %6
%61 = icmp slt i32 %60, 8
br i1 %61, label %62, label %73
62: ; preds = %59
%63 = load float*, float** %11
%64 = load i32, i32* %6
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds float, float* %63, i64 %65
%67 = load float, float* %66
%68 = fpext float %67 to double
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), double %68)
br label %70
70: ; preds = %62
%71 = load i32, i32* %6
%72 = add nsw i32 %71, 1
store i32 %72, i32* %6
br label %59
73: ; preds = %59
store i32 0, i32* %6
br label %74
74: ; preds = %82, %73
%75 = load i32, i32* %6
%76 = icmp slt i32 %75, 100000
br i1 %76, label %77, label %85
77: ; preds = %74
%78 = load float*, float** %11
%79 = load i32*, i32** %10
%80 = load i32*, i32** %8
%81 = call i32 @four1(float* %78, i32* %79, i32* %80)
br label %82
82: ; preds = %77
%83 = load i32, i32* %6
%84 = add nsw i32 %83, 1
store i32 %84, i32* %6
br label %74
85: ; preds = %74
store i32 1, i32* %3
br label %86
86: ; preds = %85, %51, %42, %31, %24, %15
%87 = load i32, i32* %3
ret i32 %87
}

LLVM IR (-O2):
@.str.1 = [2 x i8] c"r\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [31 x i8] c"erro ao ler o tamanho do vetor\00"
@.str.6 = [4 x i8] c"%f \00"
@str = [26 x i8] c"ERRO: aloca\C3\A7\C3\A3o do vetor\00"
@str.7 = [37 x i8] c"ERRO: leitura do arquivo com o vetor\00"
@str.8 = [58 x i8] c"ERRO: lista de argumentos incorreta: \0A<prog> <arq-vetor> \00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %3 to i8*
store i32 1, i32* %3
%6 = bitcast i32* %4 to i8*
store i32 0, i32* %4
%7 = icmp slt i32 %0, 2
br i1 %7, label %8, label %10
8: ; preds = %2
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([58 x i8], [58 x i8]* @str.8, i64 0, i64 0))
br label %71
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = tail call i32* @fopen(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%14 = icmp eq i32* %13, null
br i1 %14, label %15, label %17
15: ; preds = %10
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.7, i64 0, i64 0))
br label %71
17: ; preds = %10
%18 = call i64 @fscanf(i32* %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %4)
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %17
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0))
br label %71
22: ; preds = %17
%23 = load i32, i32* %4
%24 = shl i32 %23, 2
%25 = call float* @malloc(i32 %24)
%26 = icmp eq float* %25, null
br i1 %26, label %27, label %29
27: ; preds = %22
%28 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
br label %71
29: ; preds = %22
%30 = call i32 @carregaVetor(float* %25, i32* %13, i32 %23)
%31 = icmp eq i32 %30, 0
br i1 %31, label %71, label %32
32: ; preds = %29
%33 = call i32 @fclose(i32* %13)
%34 = call i32 @four1(float* %25, i32* %4, i32* %3)
%35 = load float, float* %25
%36 = fpext float %35 to double
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), double %36)
%38 = getelementptr inbounds float, float* %25, i64 1
%39 = load float, float* %38
%40 = fpext float %39 to double
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), double %40)
%42 = getelementptr inbounds float, float* %25, i64 2
%43 = load float, float* %42
%44 = fpext float %43 to double
%45 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), double %44)
%46 = getelementptr inbounds float, float* %25, i64 3
%47 = load float, float* %46
%48 = fpext float %47 to double
%49 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), double %48)
%50 = getelementptr inbounds float, float* %25, i64 4
%51 = load float, float* %50
%52 = fpext float %51 to double
%53 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), double %52)
%54 = getelementptr inbounds float, float* %25, i64 5
%55 = load float, float* %54
%56 = fpext float %55 to double
%57 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), double %56)
%58 = getelementptr inbounds float, float* %25, i64 6
%59 = load float, float* %58
%60 = fpext float %59 to double
%61 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), double %60)
%62 = getelementptr inbounds float, float* %25, i64 7
%63 = load float, float* %62
%64 = fpext float %63 to double
%65 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), double %64)
br label %66
66: ; preds = %32, %66
%67 = phi i32 [ %69, %66 ], [ 0, %32 ]
%68 = call i32 @four1(float* %25, i32* %4, i32* %3)
%69 = add nuw nsw i32 %67, 1
%70 = icmp eq i32 %69, 100000
br i1 %70, label %71, label %66
71: ; preds = %66, %29, %27, %20, %15, %8
%72 = phi i32 [ -1, %8 ], [ -1, %15 ], [ -1, %20 ], [ -1, %27 ], [ -1, %29 ], [ 1, %66 ]
ret i32 %72
}