#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*/ printf(char *, double, ...);
int /*<<< orphan*/ scanf(char *, double *);
void displaySumSmallest(int numValues) {
  int count;
  double sum, value, average, smallest;
  printf("Please enter %d values:\n", numValues);
  sum = 0.0;
  for (count = 1; count <= numValues; count++) {
    scanf("%lf", &value);
    sum = sum + value;
    if (count == 1)
      smallest = value;
    else if (value < smallest)
      smallest = value;
  }
  average = sum / numValues;
  printf("The sum is: %2.2lf\n"
         "The average is: %2.2lf\n"
         "The smallest is: %2.2lf\n\n",
         sum, average, smallest);
}


x86 assembly (clang, -O0):
<displaySumSmallest>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
cvtsi2sdl -0x4(%rbp),%xmm0
lea    0xec9(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x10(%rbp)
movl   $0x1,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     11c7 <displaySumSmallest+0xa7>
lea    0xeb9(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1040 <scanf@plt>
movsd  -0x10(%rbp),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    1191 <displaySumSmallest+0x71>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    11b4 <displaySumSmallest+0x94>
movsd  -0x18(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    11af <displaySumSmallest+0x8f>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    11b4 <displaySumSmallest+0x94>
jmp    11b9 <displaySumSmallest+0x99>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    114d <displaySumSmallest+0x2d>
movsd  -0x10(%rbp),%xmm0
cvtsi2sdl -0x4(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm2
lea    0xe2d(%rip),%rdi
mov    $0x3,%al
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<displaySumSmallest>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %edi,%ebx
cvtsi2sd %edi,%xmm0
lea    0xeca(%rip),%rdi
movsd  %xmm0,0x8(%rsp)
mov    $0x1,%al
call   1030 <printf@plt>
lea    0xecf(%rip),%rdi
mov    %rsp,%rsi
call   1040 <scanf@plt>
movsd  (%rsp),%xmm1
xorpd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
cmp    $0x1,%ebx
jne    116a <displaySumSmallest+0x4a>
movapd %xmm1,%xmm2
jmp    11b5 <displaySumSmallest+0x95>
add    $0xffffffff,%ebx
lea    0xea5(%rip),%r14
mov    %rsp,%r15
nopw   0x0(%rax,%rax,1)
movsd  %xmm1,0x10(%rsp)
movsd  %xmm0,0x18(%rsp)
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <scanf@plt>
movsd  0x18(%rsp),%xmm0
movsd  (%rsp),%xmm2
addsd  %xmm2,%xmm0
minsd  0x10(%rsp),%xmm2
movapd %xmm2,%xmm1
add    $0xffffffff,%ebx
jne    1180 <displaySumSmallest+0x60>
movapd %xmm0,%xmm1
divsd  0x8(%rsp),%xmm1
lea    0xe57(%rip),%rdi
mov    $0x3,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [25 x i8] c"Please enter %d values:\0A\00"
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [68 x i8] c"The sum is: %2.2lf\0AThe average is: %2.2lf\0AThe smallest is: %2.2lf\0A\0A\00"
define void @displaySumSmallest(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
store i32 %0, i32* %2
%8 = load i32, i32* %2
%9 = sitofp i32 %8 to double
%10 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), double %9)
store double 0.000000e+00, double* %4
store i32 1, i32* %3
br label %11
11: ; preds = %32, %1
%12 = load i32, i32* %3
%13 = load i32, i32* %2
%14 = icmp sle i32 %12, %13
br i1 %14, label %15, label %35
15: ; preds = %11
%16 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %5)
%17 = load double, double* %4
%18 = load double, double* %5
%19 = fadd double %17, %18
store double %19, double* %4
%20 = load i32, i32* %3
%21 = icmp eq i32 %20, 1
br i1 %21, label %22, label %24
22: ; preds = %15
%23 = load double, double* %5
store double %23, double* %7
br label %31
24: ; preds = %15
%25 = load double, double* %5
%26 = load double, double* %7
%27 = fcmp olt double %25, %26
br i1 %27, label %28, label %30
28: ; preds = %24
%29 = load double, double* %5
store double %29, double* %7
br label %30
30: ; preds = %28, %24
br label %31
31: ; preds = %30, %22
br label %32
32: ; preds = %31
%33 = load i32, i32* %3
%34 = add nsw i32 %33, 1
store i32 %34, i32* %3
br label %11
35: ; preds = %11
%36 = load double, double* %4
%37 = load i32, i32* %2
%38 = sitofp i32 %37 to double
%39 = fdiv double %36, %38
store double %39, double* %6
%40 = load double, double* %4
%41 = load double, double* %6
%42 = load double, double* %7
%43 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.2, i64 0, i64 0), double %40, double %41, double %42)
ret void
}

LLVM IR (-O2):
@.str = [25 x i8] c"Please enter %d values:\0A\00"
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [68 x i8] c"The sum is: %2.2lf\0AThe average is: %2.2lf\0AThe smallest is: %2.2lf\0A\0A\00"
define void @displaySumSmallest(i32 %0) {
%2 = alloca double
%3 = bitcast double* %2 to i8*
%4 = sitofp i32 %0 to double
%5 = tail call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), double %4)
%6 = icmp sgt i32 %0, 0
%7 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %2)
%8 = load double, double* %2
%9 = fadd double %8, 0.000000e+00
%10 = icmp eq i32 %0, 1
br i1 %10, label %22, label %11
11: ; preds = %1, %11
%12 = phi double [ %19, %11 ], [ %8, %1 ]
%13 = phi i32 [ %20, %11 ], [ 2, %1 ]
%14 = phi double [ %17, %11 ], [ %9, %1 ]
%15 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %2)
%16 = load double, double* %2
%17 = fadd double %14, %16
%18 = fcmp olt double %16, %12
%19 = select i1 %18, double %16, double %12
%20 = add nuw i32 %13, 1
%21 = icmp eq i32 %13, %0
br i1 %21, label %22, label %11
22: ; preds = %11, %1
%23 = phi double [ %8, %1 ], [ %19, %11 ]
%24 = phi double [ %9, %1 ], [ %17, %11 ]
%25 = fdiv double %24, %4
%26 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.2, i64 0, i64 0), double %24, double %25, double %23)
ret void
}