#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 *, ...);
int /*<<< orphan*/ scanf(char *, ...);
int main() {
  int n;
  printf("Please enter positive integer: ");
  scanf("%d", &n);
  int i;
  double min, max, sum = 0, avg = 0;
  for (i = 1; i <= n; i++) {
    double currentNum;
    printf("num%d = ", i);
    scanf("%lf", &currentNum);
    if (i == 1) {
      min = currentNum;
      max = currentNum;
    }
    sum += currentNum;
    if (currentNum >= max) {
      max = currentNum;
    }
    if (currentNum <= min) {
      min = currentNum;
    }
  }
  avg = sum / n;
  printf("min = %.2f\n", min);
  printf("max = %.2f\n", max);
  printf("sum = %.2f\n", sum);
  printf("avg = %.2f\n", avg);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xedc(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     120d <main+0xed>
mov    -0xc(%rbp),%esi
lea    0xea7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xea2(%rip),%rdi
lea    -0x38(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
cmpl   $0x1,-0xc(%rbp)
jne    11b3 <main+0x93>
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x38(%rbp),%xmm0
addsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x38(%rbp),%xmm0
ucomisd -0x20(%rbp),%xmm0
jb     11dc <main+0xbc>
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x38(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jb     11fa <main+0xda>
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    11ff <main+0xdf>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1166 <main+0x46>
movsd  -0x28(%rbp),%xmm0
cvtsi2sdl -0x8(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x18(%rbp),%xmm0
lea    0xe04(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  -0x20(%rbp),%xmm0
lea    0xdfd(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  -0x28(%rbp),%xmm0
lea    0xdf6(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  -0x30(%rbp),%xmm0
lea    0xdef(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x40,%rsp
lea    0xecd(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xedf(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
xorpd  %xmm4,%xmm4
lea    0xecb(%rip),%r14
lea    0xecd(%rip),%r15
lea    0x28(%rsp),%r12
xor    %ebp,%ebp
jmp    11b9 <main+0x99>
nopl   0x0(%rax,%rax,1)
movsd  (%rsp),%xmm4
addsd  %xmm6,%xmm4
movapd %xmm2,%xmm5
cmplesd %xmm6,%xmm5
movapd %xmm5,%xmm3
andnpd %xmm2,%xmm3
andpd  %xmm6,%xmm5
orpd   %xmm3,%xmm5
movapd %xmm5,0x30(%rsp)
movapd %xmm6,%xmm0
cmplesd %xmm1,%xmm0
movapd %xmm0,%xmm2
andnpd %xmm1,%xmm2
andpd  %xmm6,%xmm0
orpd   %xmm2,%xmm0
mov    0xc(%rsp),%eax
cmp    %eax,%ebp
jge    1208 <main+0xe8>
movaps %xmm0,0x10(%rsp)
movsd  %xmm4,(%rsp)
mov    %ebp,%ebx
lea    0x1(%rbx),%ebp
mov    %r14,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
movsd  0x28(%rsp),%xmm6
movapd %xmm6,%xmm1
movapd %xmm6,%xmm2
test   %ebx,%ebx
je     1170 <main+0x50>
movapd 0x10(%rsp),%xmm1
movapd 0x30(%rsp),%xmm2
jmp    1170 <main+0x50>
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
movapd %xmm4,%xmm2
divsd  %xmm1,%xmm2
movsd  %xmm2,0x10(%rsp)
lea    0xe0c(%rip),%rdi
mov    $0x1,%al
movsd  %xmm4,(%rsp)
call   1030 <printf@plt>
lea    0xe05(%rip),%rdi
movaps 0x30(%rsp),%xmm0
mov    $0x1,%al
call   1030 <printf@plt>
lea    0xdfe(%rip),%rdi
movsd  (%rsp),%xmm0
mov    $0x1,%al
call   1030 <printf@plt>
lea    0xdf7(%rip),%rdi
movsd  0x10(%rsp),%xmm0
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [32 x i8] c"Please enter positive integer: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [9 x i8] c"num%d = \00"
@.str.3 = [4 x i8] c"%lf\00"
@.str.4 = [12 x i8] c"min = %.2f\0A\00"
@.str.5 = [12 x i8] c"max = %.2f\0A\00"
@.str.6 = [12 x i8] c"sum = %.2f\0A\00"
@.str.7 = [12 x i8] c"avg = %.2f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
store i32 0, i32* %1
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
store double 0.000000e+00, double* %6
store double 0.000000e+00, double* %7
store i32 1, i32* %3
br label %11
11: ; preds = %40, %0
%12 = load i32, i32* %3
%13 = load i32, i32* %2
%14 = icmp sle i32 %12, %13
br i1 %14, label %15, label %43
15: ; preds = %11
%16 = load i32, i32* %3
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %16)
%18 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), double* %8)
%19 = load i32, i32* %3
%20 = icmp eq i32 %19, 1
br i1 %20, label %21, label %24
21: ; preds = %15
%22 = load double, double* %8
store double %22, double* %4
%23 = load double, double* %8
store double %23, double* %5
br label %24
24: ; preds = %21, %15
%25 = load double, double* %8
%26 = load double, double* %6
%27 = fadd double %26, %25
store double %27, double* %6
%28 = load double, double* %8
%29 = load double, double* %5
%30 = fcmp oge double %28, %29
br i1 %30, label %31, label %33
31: ; preds = %24
%32 = load double, double* %8
store double %32, double* %5
br label %33
33: ; preds = %31, %24
%34 = load double, double* %8
%35 = load double, double* %4
%36 = fcmp ole double %34, %35
br i1 %36, label %37, label %39
37: ; preds = %33
%38 = load double, double* %8
store double %38, double* %4
br label %39
39: ; preds = %37, %33
br label %40
40: ; preds = %39
%41 = load i32, i32* %3
%42 = add nsw i32 %41, 1
store i32 %42, i32* %3
br label %11
43: ; preds = %11
%44 = load double, double* %6
%45 = load i32, i32* %2
%46 = sitofp i32 %45 to double
%47 = fdiv double %44, %46
store double %47, double* %7
%48 = load double, double* %4
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), double %48)
%50 = load double, double* %5
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), double %50)
%52 = load double, double* %6
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0), double %52)
%54 = load double, double* %7
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0), double %54)
ret i32 0
}

LLVM IR (-O2):
@.str = [32 x i8] c"Please enter positive integer: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [9 x i8] c"num%d = \00"
@.str.3 = [4 x i8] c"%lf\00"
@.str.4 = [12 x i8] c"min = %.2f\0A\00"
@.str.5 = [12 x i8] c"max = %.2f\0A\00"
@.str.6 = [12 x i8] c"sum = %.2f\0A\00"
@.str.7 = [12 x i8] c"avg = %.2f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = bitcast i32* %1 to i8*
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%5 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%6 = load i32, i32* %1
%7 = icmp sgt i32 %6, 0
%8 = bitcast double* %2 to i8*
br label %9
9: ; preds = %0, %9
%10 = phi double [ 0.000000e+00, %0 ], [ %20, %9 ]
%11 = phi double [ undef, %0 ], [ %22, %9 ]
%12 = phi double [ undef, %0 ], [ %24, %9 ]
%13 = phi i32 [ 1, %0 ], [ %25, %9 ]
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %13)
%15 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), double* %2)
%16 = icmp eq i32 %13, 1
%17 = load double, double* %2
%18 = select i1 %16, double %17, double %12
%19 = select i1 %16, double %17, double %11
%20 = fadd double %10, %17
%21 = fcmp oge double %17, %19
%22 = select i1 %21, double %17, double %19
%23 = fcmp ole double %17, %18
%24 = select i1 %23, double %17, double %18
%25 = add nuw nsw i32 %13, 1
%26 = load i32, i32* %1
%27 = icmp slt i32 %13, %26
br i1 %27, label %9, label %28
28: ; preds = %9
%29 = sitofp i32 %26 to double
%30 = fdiv double %20, %29
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), double %24)
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), double %22)
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0), double %20)
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0), double %30)
ret i32 0
}