#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, double *);
double calculoSuporte(int quantidadeVelas) {
  FILE *arquivo;
  double cotacao[quantidadeVelas];
  double suporte = 0;
  int i;
  arquivo = fopen("dadosFibonacci.txt", "rt");
  for (i = 0; i < quantidadeVelas; i++) {
    fscanf(arquivo, "%lf", &cotacao[i]);
    if (suporte < cotacao[i])
      suporte = cotacao[i];
  }
  fclose(arquivo);
  return suporte;
}


x86 assembly (clang, -O0):
<calculoSuporte>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
lea    0xf(,%rax,8),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x38(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
lea    0xe8f(%rip),%rdi
lea    0xe9b(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11f4 <calculoSuporte+0xc4>
mov    -0x38(%rbp),%rdx
mov    -0x10(%rbp),%rdi
movslq -0x2c(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdx
lea    0xe68(%rip),%rsi
call   1040 <fscanf@plt>
mov    -0x38(%rbp),%rax
movsd  -0x28(%rbp),%xmm1
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
ucomisd %xmm1,%xmm0
jbe    11e1 <calculoSuporte+0xb1>
mov    -0x38(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    11e6 <calculoSuporte+0xb6>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1188 <calculoSuporte+0x58>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
movsd  -0x28(%rbp),%xmm0
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calculoSuporte>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %edi,%r15d
mov    %edi,%r12d
mov    %rsp,%rbx
lea    0xf(,%r12,8),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
lea    0xe9f(%rip),%rdi
lea    0xeab(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,%r14
test   %r15d,%r15d
jle    11ac <calculoSuporte+0x7c>
xorpd  %xmm1,%xmm1
lea    0xe96(%rip),%r15
movsd  %xmm1,-0x28(%rbp)
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1040 <fscanf@plt>
movsd  (%rbx),%xmm0
maxsd  -0x28(%rbp),%xmm0
add    $0x8,%rbx
movapd %xmm0,%xmm1
add    $0xffffffffffffffff,%r12
jne    1180 <calculoSuporte+0x50>
jmp    11b0 <calculoSuporte+0x80>
xorpd  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    %r14,%rdi
call   1030 <fclose@plt>
movsd  -0x28(%rbp),%xmm0
lea    -0x20(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [19 x i8] c"dadosFibonacci.txt\00"
@.str.1 = [3 x i8] c"rt\00"
@.str.2 = [4 x i8] c"%lf\00"
define double @calculoSuporte(i32 %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i8*
%5 = alloca i64
%6 = alloca double
%7 = alloca i32
store i32 %0, i32* %2
%8 = load i32, i32* %2
%9 = zext i32 %8 to i64
%10 = call i8* @llvm.stacksave()
store i8* %10, i8** %4
%11 = alloca double, i64 %9
store i64 %9, i64* %5
store double 0.000000e+00, double* %6
%12 = call i32* @fopen(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %12, i32** %3
store i32 0, i32* %7
br label %13
13: ; preds = %35, %1
%14 = load i32, i32* %7
%15 = load i32, i32* %2
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %38
17: ; preds = %13
%18 = load i32*, i32** %3
%19 = load i32, i32* %7
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds double, double* %11, i64 %20
%22 = call i32 @fscanf(i32* %18, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %21)
%23 = load double, double* %6
%24 = load i32, i32* %7
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds double, double* %11, i64 %25
%27 = load double, double* %26
%28 = fcmp olt double %23, %27
br i1 %28, label %29, label %34
29: ; preds = %17
%30 = load i32, i32* %7
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds double, double* %11, i64 %31
%33 = load double, double* %32
store double %33, double* %6
br label %34
34: ; preds = %29, %17
br label %35
35: ; preds = %34
%36 = load i32, i32* %7
%37 = add nsw i32 %36, 1
store i32 %37, i32* %7
br label %13
38: ; preds = %13
%39 = load i32*, i32** %3
%40 = call i32 @fclose(i32* %39)
%41 = load double, double* %6
%42 = load i8*, i8** %4
ret double %41
}

LLVM IR (-O2):
@.str = [19 x i8] c"dadosFibonacci.txt\00"
@.str.1 = [3 x i8] c"rt\00"
@.str.2 = [4 x i8] c"%lf\00"
define double @calculoSuporte(i32 %0) {
%2 = zext i32 %0 to i64
%3 = alloca double, i64 %2
%4 = tail call i32* @fopen(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%5 = icmp sgt i32 %0, 0
br i1 %5, label %6, label %16
6: ; preds = %1, %6
%7 = phi i64 [ %14, %6 ], [ 0, %1 ]
%8 = phi double [ %13, %6 ], [ 0.000000e+00, %1 ]
%9 = getelementptr inbounds double, double* %3, i64 %7
%10 = call i32 @fscanf(i32* %4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %9)
%11 = load double, double* %9
%12 = fcmp olt double %8, %11
%13 = select i1 %12, double %11, double %8
%14 = add nuw nsw i64 %7, 1
%15 = icmp eq i64 %14, %2
br i1 %15, label %16, label %6
16: ; preds = %6, %1
%17 = phi double [ 0.000000e+00, %1 ], [ %13, %6 ]
%18 = call i32 @fclose(i32* %4)
ret double %17
}