#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 ler_volumes(float *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, float *);
double volume_medio(float *, int, float, float);
int main() {
  float volumes[1000];
  int num = ler_volumes(volumes);
  printf("Foram lidos %d valores.\n", num);
  float min, max;
  printf("Indique o valor mínimo: ");
  scanf(" %f", &min);
  printf("%.1f\n", min);
  printf("Indique o valor máximo: ");
  scanf(" %f", &max);
  printf("%.1f\n", max);
  printf("O volume medio de enchimento foi de %.3f litros.\n",
         volume_medio(volumes, num, max, min));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xfc0,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0xfb0(%rbp),%rdi
call   1030 <ler_volumes@plt>
mov    %eax,-0xfb4(%rbp)
mov    -0xfb4(%rbp),%esi
lea    0xe8f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xea6(%rip),%rdi
lea    -0xfb8(%rbp),%rsi
call   1050 <scanf@plt>
movss  -0xfb8(%rbp),%xmm0
ff
cvtss2sd %xmm0,%xmm0
lea    0xe8b(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
lea    0xe83(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe6b(%rip),%rdi
lea    -0xfbc(%rbp),%rsi
call   1050 <scanf@plt>
movss  -0xfbc(%rbp),%xmm0
ff
cvtss2sd %xmm0,%xmm0
lea    0xe50(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
lea    -0xfb0(%rbp),%rdi
mov    -0xfb4(%rbp),%esi
movss  -0xfbc(%rbp),%xmm0
ff
movss  -0xfb8(%rbp),%xmm1
ff
call   1060 <volume_medio@plt>
lea    0xe40(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0xfc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0xfb8,%rsp
lea    0x10(%rsp),%r14
mov    %r14,%rdi
call   1030 <ler_volumes@plt>
mov    %eax,%ebp
lea    0xe9d(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xea6(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeb2(%rip),%r15
lea    0xc(%rsp),%rsi
mov    %r15,%rdi
call   1050 <scanf@plt>
movss  0xc(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe98(%rip),%rbx
mov    %rbx,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
lea    0xe8d(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x8(%rsp),%rsi
mov    %r15,%rdi
call   1050 <scanf@plt>
movss  0x8(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %rbx,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movss  0x8(%rsp),%xmm0
movss  0xc(%rsp),%xmm1
mov    %r14,%rdi
mov    %ebp,%esi
call   1060 <volume_medio@plt>
lea    0xe62(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0xfb8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [25 x i8] c"Foram lidos %d valores.\0A\00"
@.str.1 = [26 x i8] c"Indique o valor m\C3\ADnimo: \00"
@.str.2 = [4 x i8] c" %f\00"
@.str.3 = [6 x i8] c"%.1f\0A\00"
@.str.4 = [26 x i8] c"Indique o valor m\C3\A1ximo: \00"
@.str.5 = [50 x i8] c"O volume medio de enchimento foi de %.3f litros.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [1000 x float]
%3 = alloca i32
%4 = alloca float
%5 = alloca float
store i32 0, i32* %1
%6 = getelementptr inbounds [1000 x float], [1000 x float]* %2, i64 0, i64 0
%7 = call i32 @ler_volumes(float* %6)
store i32 %7, i32* %3
%8 = load i32, i32* %3
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %8)
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), float* %4)
%12 = load float, float* %4
%13 = fpext float %12 to double
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), double %13)
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0))
%16 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), float* %5)
%17 = load float, float* %5
%18 = fpext float %17 to double
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), double %18)
%20 = getelementptr inbounds [1000 x float], [1000 x float]* %2, i64 0, i64 0
%21 = load i32, i32* %3
%22 = load float, float* %5
%23 = load float, float* %4
%24 = call double @volume_medio(float* %20, i32 %21, float %22, float %23)
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.5, i64 0, i64 0), double %24)
ret i32 0
}

LLVM IR (-O2):
@.str = [25 x i8] c"Foram lidos %d valores.\0A\00"
@.str.1 = [26 x i8] c"Indique o valor m\C3\ADnimo: \00"
@.str.2 = [4 x i8] c" %f\00"
@.str.3 = [6 x i8] c"%.1f\0A\00"
@.str.4 = [26 x i8] c"Indique o valor m\C3\A1ximo: \00"
@.str.5 = [50 x i8] c"O volume medio de enchimento foi de %.3f litros.\0A\00"
define i32 @main() {
%1 = alloca [1000 x float]
%2 = alloca float
%3 = alloca float
%4 = bitcast [1000 x float]* %1 to i8*
%5 = getelementptr inbounds [1000 x float], [1000 x float]* %1, i64 0, i64 0
%6 = call i32 @ler_volumes(float* %5)
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %6)
%8 = bitcast float* %2 to i8*
%9 = bitcast float* %3 to i8*
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), float* %2)
%12 = load float, float* %2
%13 = fpext float %12 to double
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), double %13)
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0))
%16 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), float* %3)
%17 = load float, float* %3
%18 = fpext float %17 to double
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), double %18)
%20 = load float, float* %3
%21 = load float, float* %2
%22 = call double @volume_medio(float* %5, i32 %6, float %20, float %21)
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str.5, i64 0, i64 0), double %22)
ret i32 0
}