#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*/ avaliacao(char *, int);
int /*<<< orphan*/ free(float *);
int /*<<< orphan*/ inicializacao();
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, float);
scalar_t__ rand();
int /*<<< orphan*/ srand(int);
int main() {
  int i;
  float *z, s = 0.f;
  z = (float *)malloc(sizeof(float) * 50000000);
  srand(424242);
  for (i = 0; i < 50000000; i++) {
    z[i] = (float)rand() / 100000000.0;
  }
  inicializacao();
  for (i = 0; i < 50000000; i++) {
    s += z[i];
  }
  avaliacao("Exercicio E - Padrão", 50000000);
  printf("%f\n", s);
  free(z);
  volatile double s2 = s;
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
mov    $0xbebc200,%edi
call   1070 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    $0x67932,%edi
call   1060 <srand@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x2faf080,-0x8(%rbp)
jge    11ee <main+0x7e>
mov    $0x0,%al
call   1090 <rand@plt>
cvtsi2ss %rax,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe35(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x10(%rbp),%rax
movslq -0x8(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11a6 <main+0x36>
mov    $0x0,%al
call   1080 <inicializacao@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x2faf080,-0x8(%rbp)
jge    122e <main+0xbe>
mov    -0x10(%rbp),%rax
movslq -0x8(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
addss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11fc <main+0x8c>
lea    0xdd3(%rip),%rdi
mov    $0x2faf080,%esi
call   1030 <avaliacao@plt>
movss  -0x14(%rbp),%xmm0
lea    0xdd3(%rip),%rdi
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1040 <free@plt>
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    $0xbebc200,%edi
call   1070 <malloc@plt>
mov    %rax,%r14
mov    $0x67932,%edi
call   1060 <srand@plt>
xor    %ebx,%ebx
xor    %eax,%eax
call   1090 <rand@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
divss  0xe59(%rip),%xmm0
movss  %xmm0,(%r14,%rbx,4)
add    $0x1,%rbx
cmp    $0x2faf080,%rbx
jne    1190 <main+0x20>
xor    %eax,%eax
call   1080 <inicializacao@plt>
xorps  %xmm0,%xmm0
mov    $0x7,%eax
nopl   0x0(%rax)
addss  -0x1c(%r14,%rax,4),%xmm0
addss  -0x18(%r14,%rax,4),%xmm0
addss  -0x14(%r14,%rax,4),%xmm0
addss  -0x10(%r14,%rax,4),%xmm0
addss  -0xc(%r14,%rax,4),%xmm0
addss  -0x8(%r14,%rax,4),%xmm0
addss  -0x4(%r14,%rax,4),%xmm0
addss  (%r14,%rax,4),%xmm0
add    $0x8,%rax
cmp    $0x2faf087,%rax
jne    11d0 <main+0x60>
lea    0xdea(%rip),%rdi
mov    $0x2faf080,%esi
movss  %xmm0,0xc(%rsp)
call   1030 <avaliacao@plt>
lea    0xde9(%rip),%rdi
movss  0xc(%rsp),%xmm0
call   1050 <printf@plt>
mov    %r14,%rdi
call   1040 <free@plt>
movss  0xc(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,0x10(%rsp)
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [22 x i8] c"Exercicio E - Padr\C3\A3o\00"
@.str.1 = [4 x i8] c"%f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca float*
%4 = alloca float
%5 = alloca double
store i32 0, i32* %1
store float 0.000000e+00, float* %4
%6 = call i64 @malloc(i32 200000000)
%7 = inttoptr i64 %6 to float*
store float* %7, float** %3
%8 = call i32 @srand(i32 424242)
store i32 0, i32* %2
br label %9
9: ; preds = %22, %0
%10 = load i32, i32* %2
%11 = icmp slt i32 %10, 50000000
br i1 %11, label %12, label %25
12: ; preds = %9
%13 = call i64 (...) @rand()
%14 = sitofp i64 %13 to float
%15 = fpext float %14 to double
%16 = fdiv double %15, 1.000000e+08
%17 = fptrunc double %16 to float
%18 = load float*, float** %3
%19 = load i32, i32* %2
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds float, float* %18, i64 %20
store float %17, float* %21
br label %22
22: ; preds = %12
%23 = load i32, i32* %2
%24 = add nsw i32 %23, 1
store i32 %24, i32* %2
br label %9
25: ; preds = %9
%26 = call i32 (...) @inicializacao()
store i32 0, i32* %2
br label %27
27: ; preds = %38, %25
%28 = load i32, i32* %2
%29 = icmp slt i32 %28, 50000000
br i1 %29, label %30, label %41
30: ; preds = %27
%31 = load float*, float** %3
%32 = load i32, i32* %2
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds float, float* %31, i64 %33
%35 = load float, float* %34
%36 = load float, float* %4
%37 = fadd float %36, %35
store float %37, float* %4
br label %38
38: ; preds = %30
%39 = load i32, i32* %2
%40 = add nsw i32 %39, 1
store i32 %40, i32* %2
br label %27
41: ; preds = %27
%42 = call i32 @avaliacao(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 50000000)
%43 = load float, float* %4
%44 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), float %43)
%45 = load float*, float** %3
%46 = call i32 @free(float* %45)
%47 = load float, float* %4
%48 = fpext float %47 to double
store volatile double %48, double* %5
ret i32 0
}

LLVM IR (-O2):
@.str = [22 x i8] c"Exercicio E - Padr\C3\A3o\00"
@.str.1 = [4 x i8] c"%f\0A\00"
define i32 @main() {
%1 = alloca double
%2 = tail call i64 @malloc(i32 200000000)
%3 = inttoptr i64 %2 to float*
%4 = tail call i32 @srand(i32 424242)
br label %5
5: ; preds = %0, %5
%6 = phi i64 [ 0, %0 ], [ %11, %5 ]
%7 = tail call i64 (...) @rand()
%8 = sitofp i64 %7 to float
%9 = fdiv float %8, 1.000000e+08
%10 = getelementptr inbounds float, float* %3, i64 %6
store float %9, float* %10
%11 = add nuw nsw i64 %6, 1
%12 = icmp eq i64 %11, 50000000
br i1 %12, label %13, label %5
13: ; preds = %5
%14 = tail call i32 (...) @inicializacao()
br label %15
15: ; preds = %15, %13
%16 = phi i64 [ 0, %13 ], [ %49, %15 ]
%17 = phi float [ 0.000000e+00, %13 ], [ %48, %15 ]
%18 = getelementptr inbounds float, float* %3, i64 %16
%19 = load float, float* %18
%20 = fadd float %17, %19
%21 = or i64 %16, 1
%22 = getelementptr inbounds float, float* %3, i64 %21
%23 = load float, float* %22
%24 = fadd float %20, %23
%25 = or i64 %16, 2
%26 = getelementptr inbounds float, float* %3, i64 %25
%27 = load float, float* %26
%28 = fadd float %24, %27
%29 = or i64 %16, 3
%30 = getelementptr inbounds float, float* %3, i64 %29
%31 = load float, float* %30
%32 = fadd float %28, %31
%33 = or i64 %16, 4
%34 = getelementptr inbounds float, float* %3, i64 %33
%35 = load float, float* %34
%36 = fadd float %32, %35
%37 = or i64 %16, 5
%38 = getelementptr inbounds float, float* %3, i64 %37
%39 = load float, float* %38
%40 = fadd float %36, %39
%41 = or i64 %16, 6
%42 = getelementptr inbounds float, float* %3, i64 %41
%43 = load float, float* %42
%44 = fadd float %40, %43
%45 = or i64 %16, 7
%46 = getelementptr inbounds float, float* %3, i64 %45
%47 = load float, float* %46
%48 = fadd float %44, %47
%49 = add nuw nsw i64 %16, 8
%50 = icmp eq i64 %49, 50000000
br i1 %50, label %51, label %15
51: ; preds = %15
%52 = tail call i32 @avaliacao(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 50000000)
%53 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), float %48)
%54 = tail call i32 @free(float* %3)
%55 = bitcast double* %1 to i8*
%56 = fpext float %48 to double
store volatile double %56, double* %1
ret i32 0
}