#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*/ flushall();
int /*<<< orphan*/ getchar();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
main() {
  int ages[5];
  int i;
  int youngest, oldest;
  int total_age;
  total_age = 0;
  printf("Please enter the ages of 5 people\n");
  for (i = 0; i < 5; i++) {
    scanf("%d", &ages[i]);
    flushall();
    total_age = total_age + ages[i];
  }
  youngest = ages[0];
  oldest = ages[0];
  for (i = 0; i < 5; i++) {
    if (ages[i] > oldest) {
      oldest = ages[i];
    }
    if (ages[i] < youngest) {
      youngest = ages[i];
    }
  }
  printf("\nThe youngest is %d", youngest);
  printf("\nThe oldest is %d", oldest);
  printf("\nThe average age is %1f", (float)total_age / 5);
  getchar();
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x30(%rbp)
lea    0xea7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x24(%rbp)
cmpl   $0x5,-0x24(%rbp)
jge    11b3 <main+0x73>
movslq -0x24(%rbp),%rax
lea    -0x20(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xebf(%rip),%rdi
call   1060 <scanf@plt>
mov    $0x0,%al
call   1040 <flushall@plt>
mov    -0x30(%rbp),%eax
movslq -0x24(%rbp),%rcx
add    -0x20(%rbp,%rcx,4),%eax
mov    %eax,-0x30(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    116b <main+0x2b>
mov    -0x20(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x2c(%rbp)
movl   $0x0,-0x24(%rbp)
cmpl   $0x5,-0x24(%rbp)
jge    121b <main+0xdb>
movslq -0x24(%rbp),%rax
mov    -0x20(%rbp,%rax,4),%eax
cmp    -0x2c(%rbp),%eax
jle    11ec <main+0xac>
movslq -0x24(%rbp),%rax
mov    -0x20(%rbp,%rax,4),%eax
mov    %eax,-0x2c(%rbp)
movslq -0x24(%rbp),%rax
mov    -0x20(%rbp,%rax,4),%eax
cmp    -0x28(%rbp),%eax
jge    1208 <main+0xc8>
movslq -0x24(%rbp),%rax
mov    -0x20(%rbp,%rax,4),%eax
mov    %eax,-0x28(%rbp)
jmp    120d <main+0xcd>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11c6 <main+0x86>
mov    -0x28(%rbp),%esi
lea    0xe02(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x2c(%rbp),%esi
lea    0xe05(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cvtsi2ssl -0x30(%rbp),%xmm0
movss  0xdb6(%rip),%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdf4(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
lea    0xee5(%rip),%rdi
call   1030 <puts@plt>
lea    0xebe(%rip),%rbx
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1070 <scanf@plt>
xor    %eax,%eax
call   1050 <flushall@plt>
mov    (%rsp),%ebp
lea    0x4(%rsp),%rsi
mov    %rbx,%rdi
call   1070 <scanf@plt>
xor    %eax,%eax
call   1050 <flushall@plt>
lea    0x8(%rsp),%rsi
add    0x4(%rsp),%ebp
mov    %rbx,%rdi
call   1070 <scanf@plt>
xor    %eax,%eax
call   1050 <flushall@plt>
lea    0xc(%rsp),%rsi
add    0x8(%rsp),%ebp
mov    %rbx,%rdi
call   1070 <scanf@plt>
xor    %eax,%eax
call   1050 <flushall@plt>
lea    0x10(%rsp),%rsi
add    0xc(%rsp),%ebp
mov    %rbx,%rdi
call   1070 <scanf@plt>
xor    %eax,%eax
call   1050 <flushall@plt>
mov    (%rsp),%esi
mov    0x4(%rsp),%eax
cmp    %esi,%eax
mov    %esi,%ebx
cmovg  %eax,%ebx
cmovl  %eax,%esi
mov    0x8(%rsp),%eax
cmp    %ebx,%eax
cmovg  %eax,%ebx
cmp    %esi,%eax
cmovl  %eax,%esi
mov    0xc(%rsp),%eax
cmp    %ebx,%eax
cmovg  %eax,%ebx
cmp    %esi,%eax
cmovl  %eax,%esi
mov    0x10(%rsp),%eax
cmp    %ebx,%eax
cmovg  %eax,%ebx
cmp    %esi,%eax
cmovl  %eax,%esi
add    %eax,%ebp
lea    0xde6(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xdec(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
cvtsi2ss %ebp,%xmm0
divss  0xdbf(%rip),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdde(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [35 x i8] c"Please enter the ages of 5 people\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [20 x i8] c"\0AThe youngest is %d\00"
@.str.3 = [18 x i8] c"\0AThe oldest is %d\00"
@.str.4 = [24 x i8] c"\0AThe average age is %1f\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [5 x i32]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %6
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %8
8: ; preds = %23, %0
%9 = load i32, i32* %3
%10 = icmp slt i32 %9, 5
br i1 %10, label %11, label %26
11: ; preds = %8
%12 = load i32, i32* %3
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 %13
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %14)
%16 = call i32 (...) @flushall()
%17 = load i32, i32* %6
%18 = load i32, i32* %3
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 %19
%21 = load i32, i32* %20
%22 = add nsw i32 %17, %21
store i32 %22, i32* %6
br label %23
23: ; preds = %11
%24 = load i32, i32* %3
%25 = add nsw i32 %24, 1
store i32 %25, i32* %3
br label %8
26: ; preds = %8
%27 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 0
%28 = load i32, i32* %27
store i32 %28, i32* %4
%29 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 0
%30 = load i32, i32* %29
store i32 %30, i32* %5
store i32 0, i32* %3
br label %31
31: ; preds = %59, %26
%32 = load i32, i32* %3
%33 = icmp slt i32 %32, 5
br i1 %33, label %34, label %62
34: ; preds = %31
%35 = load i32, i32* %3
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 %36
%38 = load i32, i32* %37
%39 = load i32, i32* %5
%40 = icmp sgt i32 %38, %39
br i1 %40, label %41, label %46
41: ; preds = %34
%42 = load i32, i32* %3
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 %43
%45 = load i32, i32* %44
store i32 %45, i32* %5
br label %46
46: ; preds = %41, %34
%47 = load i32, i32* %3
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 %48
%50 = load i32, i32* %49
%51 = load i32, i32* %4
%52 = icmp slt i32 %50, %51
br i1 %52, label %53, label %58
53: ; preds = %46
%54 = load i32, i32* %3
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 %55
%57 = load i32, i32* %56
store i32 %57, i32* %4
br label %58
58: ; preds = %53, %46
br label %59
59: ; preds = %58
%60 = load i32, i32* %3
%61 = add nsw i32 %60, 1
store i32 %61, i32* %3
br label %31
62: ; preds = %31
%63 = load i32, i32* %4
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i32 %63)
%65 = load i32, i32* %5
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i32 %65)
%67 = load i32, i32* %6
%68 = sitofp i32 %67 to float
%69 = fdiv float %68, 5.000000e+00
%70 = fpext float %69 to double
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), double %70)
%72 = call i32 (...) @getchar()
%73 = load i32, i32* %1
ret i32 %73
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [20 x i8] c"\0AThe youngest is %d\00"
@.str.3 = [18 x i8] c"\0AThe oldest is %d\00"
@.str.4 = [24 x i8] c"\0AThe average age is %1f\00"
@str = [34 x i8] c"Please enter the ages of 5 people\00"
define i32 @main() {
%1 = alloca [5 x i32]
%2 = bitcast [5 x i32]* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str, i64 0, i64 0))
%4 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 0
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%6 = call i32 (...) @flushall()
%7 = load i32, i32* %4
%8 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 1
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %8)
%10 = call i32 (...) @flushall()
%11 = load i32, i32* %8
%12 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 2
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %12)
%14 = call i32 (...) @flushall()
%15 = load i32, i32* %12
%16 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 3
%17 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %16)
%18 = call i32 (...) @flushall()
%19 = load i32, i32* %16
%20 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 4
%21 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %20)
%22 = call i32 (...) @flushall()
%23 = load i32, i32* %20
%24 = load i32, i32* %4
%25 = load i32, i32* %8
%26 = icmp sgt i32 %25, %24
%27 = select i1 %26, i32 %25, i32 %24
%28 = icmp slt i32 %25, %24
%29 = select i1 %28, i32 %25, i32 %24
%30 = load i32, i32* %12
%31 = icmp sgt i32 %30, %27
%32 = select i1 %31, i32 %30, i32 %27
%33 = icmp slt i32 %30, %29
%34 = select i1 %33, i32 %30, i32 %29
%35 = load i32, i32* %16
%36 = icmp sgt i32 %35, %32
%37 = select i1 %36, i32 %35, i32 %32
%38 = icmp slt i32 %35, %34
%39 = select i1 %38, i32 %35, i32 %34
%40 = icmp sgt i32 %23, %37
%41 = select i1 %40, i32 %23, i32 %37
%42 = icmp slt i32 %23, %39
%43 = select i1 %42, i32 %23, i32 %39
%44 = add nsw i32 %11, %7
%45 = add nsw i32 %15, %44
%46 = add nsw i32 %19, %45
%47 = add nsw i32 %23, %46
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i32 %43)
%49 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i32 %41)
%50 = sitofp i32 %47 to float
%51 = fdiv float %50, 5.000000e+00
%52 = fpext float %51 to double
%53 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), double %52)
%54 = call i32 (...) @getchar()
ret i32 0
}