#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 calc_average(int *, int);
float calc_std(int *, float, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ system(char *);
void main() {
  int i, n = 2, number;
  float average, std;
  printf("Give the N:");
  scanf("%d", &n);
  if (n > 0) {
    int numbers[n];
    for (i = 0; i < n; i++) {
      printf("Give (%d) number:", i + 1);
      scanf("%d", &number);
      numbers[i] = number;
    }
    average = calc_average(numbers, n);
    std = calc_std(numbers, average, n);
    printf("Average:%f\n", average);
    printf("Standard Deviation:%f\n", std);
  }
  system("pause");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x2,-0x8(%rbp)
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe98(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1070 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
jle    125d <main+0x10d>
mov    -0x8(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x20(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1201 <main+0xb1>
mov    -0x4(%rbp),%esi
add    $0x1,%esi
lea    0xe41(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe30(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1070 <scanf@plt>
mov    -0x30(%rbp),%rax
mov    -0xc(%rbp),%edx
movslq -0x4(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    11b5 <main+0x65>
mov    -0x30(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1060 <calc_average@plt>
mov    -0x30(%rbp),%rdi
movss  %xmm0,-0x10(%rbp)
movss  -0x10(%rbp),%xmm0
mov    -0x8(%rbp),%esi
call   1050 <calc_std@plt>
movss  %xmm0,-0x14(%rbp)
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xde9(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdde(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
lea    0xde0(%rip),%rdi
call   1030 <system@plt>
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
movl   $0x2,-0x2c(%rbp)
lea    0xe91(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe8f(%rip),%rdi
lea    -0x2c(%rbp),%rsi
call   1070 <scanf@plt>
mov    -0x2c(%rbp),%eax
test   %eax,%eax
jle    1256 <main+0x106>
mov    %rsp,%rbx
mov    %rsp,%r13
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r13
mov    %r13,%rsp
mov    -0x2c(%rbp),%esi
test   %esi,%esi
jle    1208 <main+0xb8>
mov    %rbx,-0x38(%rbp)
lea    0xe51(%rip),%r15
lea    -0x40(%rbp),%r12
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    0x1(%rbx),%r14
lea    0xe34(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1070 <scanf@plt>
mov    -0x40(%rbp),%eax
mov    %eax,0x0(%r13,%rbx,4)
movslq -0x2c(%rbp),%rsi
mov    %r14,%rbx
cmp    %rsi,%r14
jl     11d0 <main+0x80>
mov    -0x38(%rbp),%rbx
mov    %r13,%rdi
call   1060 <calc_average@plt>
movss  %xmm0,-0x3c(%rbp)
mov    -0x2c(%rbp),%esi
mov    %r13,%rdi
call   1050 <calc_std@plt>
movss  %xmm0,-0x38(%rbp)
movss  -0x3c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdec(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movss  -0x38(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xde1(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    %rbx,%rsp
lea    0xde7(%rip),%rdi
call   1030 <system@plt>
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [12 x i8] c"Give the N:\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [18 x i8] c"Give (%d) number:\00"
@.str.3 = [12 x i8] c"Average:%f\0A\00"
@.str.4 = [23 x i8] c"Standard Deviation:%f\0A\00"
@.str.5 = [6 x i8] c"pause\00"
define void @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca float
%5 = alloca float
%6 = alloca i8*
%7 = alloca i64
store i32 2, i32* %2
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%10 = load i32, i32* %2
%11 = icmp sgt i32 %10, 0
br i1 %11, label %12, label %46
12: ; preds = %0
%13 = load i32, i32* %2
%14 = zext i32 %13 to i64
%15 = call i8* @llvm.stacksave()
store i8* %15, i8** %6
%16 = alloca i32, i64 %14
store i64 %14, i64* %7
store i32 0, i32* %1
br label %17
17: ; preds = %30, %12
%18 = load i32, i32* %1
%19 = load i32, i32* %2
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %33
21: ; preds = %17
%22 = load i32, i32* %1
%23 = add nsw i32 %22, 1
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %23)
%25 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%26 = load i32, i32* %3
%27 = load i32, i32* %1
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i32, i32* %16, i64 %28
store i32 %26, i32* %29
br label %30
30: ; preds = %21
%31 = load i32, i32* %1
%32 = add nsw i32 %31, 1
store i32 %32, i32* %1
br label %17
33: ; preds = %17
%34 = load i32, i32* %2
%35 = call float @calc_average(i32* %16, i32 %34)
store float %35, float* %4
%36 = load float, float* %4
%37 = load i32, i32* %2
%38 = call float @calc_std(i32* %16, float %36, i32 %37)
store float %38, float* %5
%39 = load float, float* %4
%40 = fpext float %39 to double
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), double %40)
%42 = load float, float* %5
%43 = fpext float %42 to double
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), double %43)
%45 = load i8*, i8** %6
br label %46
46: ; preds = %33, %0
%47 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [12 x i8] c"Give the N:\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [18 x i8] c"Give (%d) number:\00"
@.str.3 = [12 x i8] c"Average:%f\0A\00"
@.str.4 = [23 x i8] c"Standard Deviation:%f\0A\00"
@.str.5 = [6 x i8] c"pause\00"
define void @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
store i32 2, i32* %1
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%7 = load i32, i32* %1
%8 = icmp sgt i32 %7, 0
br i1 %8, label %9, label %35
9: ; preds = %0
%10 = zext i32 %7 to i64
%11 = call i8* @llvm.stacksave()
%12 = alloca i32, i64 %10
%13 = load i32, i32* %1
%14 = icmp sgt i32 %13, 0
br i1 %14, label %15, label %26
15: ; preds = %9, %15
%16 = phi i64 [ %17, %15 ], [ 0, %9 ]
%17 = add nuw nsw i64 %16, 1
%18 = trunc i64 %17 to i32
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %18)
%20 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%21 = load i32, i32* %2
%22 = getelementptr inbounds i32, i32* %12, i64 %16
store i32 %21, i32* %22
%23 = load i32, i32* %1
%24 = sext i32 %23 to i64
%25 = icmp slt i64 %17, %24
br i1 %25, label %15, label %26
26: ; preds = %15, %9
%27 = phi i32 [ %13, %9 ], [ %23, %15 ]
%28 = call float @calc_average(i32* %12, i32 %27)
%29 = load i32, i32* %1
%30 = call float @calc_std(i32* %12, float %28, i32 %29)
%31 = fpext float %28 to double
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), double %31)
%33 = fpext float %30 to double
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), double %33)
br label %35
35: ; preds = %26, %0
%36 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
ret void
}