#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 */
float average(int);
int find_max(int);
int /*<<< orphan*/ print_numbers(int);
int /*<<< orphan*/ printf(char *, int);
int read_numbers_from_file();
int main(void) {
  int length, max;
  float avg;
  length = read_numbers_from_file();
  printf("The length of the list is %d\n", length);
  print_numbers(length);
  avg = average(length);
  printf("The average of the list is %.3f\n", avg);
  max = find_max(length);
  printf("The largest number in the list is %d\n", max);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1030 <read_numbers_from_file@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    0xe8d(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%edi
call   1060 <print_numbers@plt>
mov    -0x8(%rbp),%edi
call   1050 <average@plt>
movss  %xmm0,-0x10(%rbp)
cvttss2si -0x10(%rbp),%esi
lea    0xe85(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%edi
call   1070 <find_max@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe8c(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %eax,%eax
call   1030 <read_numbers_from_file@plt>
mov    %eax,%ebx
lea    0xe9f(%rip),%rdi
mov    %eax,%esi
call   1040 <printf@plt>
mov    %ebx,%edi
call   1060 <print_numbers@plt>
mov    %ebx,%edi
call   1050 <average@plt>
cvttss2si %xmm0,%esi
lea    0xe9d(%rip),%rdi
call   1040 <printf@plt>
mov    %ebx,%edi
call   1070 <find_max@plt>
lea    0xeab(%rip),%rdi
mov    %eax,%esi
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [30 x i8] c"The length of the list is %d\0A\00"
@.str.1 = [33 x i8] c"The average of the list is %.3f\0A\00"
@.str.2 = [38 x i8] c"The largest number in the list is %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca float
store i32 0, i32* %1
%5 = call i32 (...) @read_numbers_from_file()
store i32 %5, i32* %2
%6 = load i32, i32* %2
%7 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32 %6)
%8 = load i32, i32* %2
%9 = call i32 @print_numbers(i32 %8)
%10 = load i32, i32* %2
%11 = call float @average(i32 %10)
store float %11, float* %4
%12 = load float, float* %4
%13 = fptosi float %12 to i32
%14 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i32 %13)
%15 = load i32, i32* %2
%16 = call i32 @find_max(i32 %15)
store i32 %16, i32* %3
%17 = load i32, i32* %3
%18 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0), i32 %17)
ret i32 0
}

LLVM IR (-O2):
@.str = [30 x i8] c"The length of the list is %d\0A\00"
@.str.1 = [33 x i8] c"The average of the list is %.3f\0A\00"
@.str.2 = [38 x i8] c"The largest number in the list is %d\0A\00"
define i32 @main() {
%1 = tail call i32 (...) @read_numbers_from_file()
%2 = tail call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32 %1)
%3 = tail call i32 @print_numbers(i32 %1)
%4 = tail call float @average(i32 %1)
%5 = fptosi float %4 to i32
%6 = tail call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i32 %5)
%7 = tail call i32 @find_max(i32 %1)
%8 = tail call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0), i32 %7)
ret i32 0
}