#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, count;
  float avg, d, sum = 0;
  float num[100];
  printf("How many numbers? ");
  scanf("%d", &n);
  printf("\n");
  for (count = 0; count < n; count++) {
    printf("i = %d x = ", count + 1);
    scanf("%f", &num[count]);
    sum += num[count];
  }
  avg = sum / n;
  printf("\nAverage is: %5.2f\n\n", avg);
  for (count = 0; count < n; count++) {
    d = num[count] - avg;
    printf("i = %d x = %5.2f d = %5.2f\n", count + 1, num[count], d);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1b0,%rsp
movl   $0x0,-0x4(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x18(%rbp)
lea    0xebf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec4(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xed7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11d4 <main+0xb4>
mov    -0xc(%rbp),%esi
add    $0x1,%esi
lea    0xe8e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movslq -0xc(%rbp),%rax
lea    -0x1b0(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe7a(%rip),%rdi
mov    $0x0,%al
call   1040 <scanf@plt>
movslq -0xc(%rbp),%rax
movss  -0x1b0(%rbp,%rax,4),%xmm0
ff ff
addss  -0x18(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    116f <main+0x4f>
movss  -0x18(%rbp),%xmm0
cvtsi2ssl -0x8(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe2e(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1264 <main+0x144>
movslq -0xc(%rbp),%rax
movss  -0x1b0(%rbp,%rax,4),%xmm0
ff ff
subss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
mov    -0xc(%rbp),%esi
add    $0x1,%esi
movslq -0xc(%rbp),%rax
movss  -0x1b0(%rbp,%rax,4),%xmm0
ff ff
cvtss2sd %xmm0,%xmm0
movss  -0x14(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xdeb(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1205 <main+0xe5>
xor    %eax,%eax
add    $0x1b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x1a8,%rsp
lea    0xebb(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xec0(%rip),%rdi
lea    0x8(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x8(%rsp),%eax
xorps  %xmm1,%xmm1
test   %eax,%eax
jle    11cd <main+0x9d>
lea    0x10(%rsp),%r12
lea    0xe96(%rip),%r14
lea    0xe9b(%rip),%r15
xor    %ebx,%ebx
nopl   0x0(%rax)
movss  %xmm1,0xc(%rsp)
add    $0x1,%rbx
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
movss  0xc(%rsp),%xmm1
addss  (%r12),%xmm1
movslq 0x8(%rsp),%rax
add    $0x4,%r12
cmp    %rax,%rbx
jl     1190 <main+0x60>
cvtsi2ss %eax,%xmm0
divss  %xmm0,%xmm1
movss  %xmm1,0xc(%rsp)
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
lea    0xe3c(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
cmpl   $0x0,0x8(%rsp)
jle    1231 <main+0x101>
xor    %ebx,%ebx
lea    0xe3a(%rip),%r14
movss  0x10(%rsp,%rbx,4),%xmm1
add    $0x1,%rbx
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
subss  0xc(%rsp),%xmm1
cvtss2sd %xmm1,%xmm1
mov    %r14,%rdi
mov    %ebx,%esi
mov    $0x2,%al
call   1040 <printf@plt>
movslq 0x8(%rsp),%rax
cmp    %rax,%rbx
jl     1200 <main+0xd0>
xor    %eax,%eax
add    $0x1a8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [19 x i8] c"How many numbers? \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [12 x i8] c"i = %d x = \00"
@.str.4 = [3 x i8] c"%f\00"
@.str.5 = [21 x i8] c"\0AAverage is: %5.2f\0A\0A\00"
@.str.6 = [28 x i8] c"i = %d x = %5.2f d = %5.2f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca [100 x float]
store i32 0, i32* %1
store float 0.000000e+00, float* %6
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%9 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %3
br label %11
11: ; preds = %29, %0
%12 = load i32, i32* %3
%13 = load i32, i32* %2
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %32
15: ; preds = %11
%16 = load i32, i32* %3
%17 = add nsw i32 %16, 1
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 %17)
%19 = load i32, i32* %3
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [100 x float], [100 x float]* %7, i64 0, i64 %20
%22 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), float* %21)
%23 = load i32, i32* %3
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [100 x float], [100 x float]* %7, i64 0, i64 %24
%26 = load float, float* %25
%27 = load float, float* %6
%28 = fadd float %27, %26
store float %28, float* %6
br label %29
29: ; preds = %15
%30 = load i32, i32* %3
%31 = add nsw i32 %30, 1
store i32 %31, i32* %3
br label %11
32: ; preds = %11
%33 = load float, float* %6
%34 = load i32, i32* %2
%35 = sitofp i32 %34 to float
%36 = fdiv float %33, %35
store float %36, float* %4
%37 = load float, float* %4
%38 = fpext float %37 to double
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), double %38)
store i32 0, i32* %3
br label %40
40: ; preds = %61, %32
%41 = load i32, i32* %3
%42 = load i32, i32* %2
%43 = icmp slt i32 %41, %42
br i1 %43, label %44, label %64
44: ; preds = %40
%45 = load i32, i32* %3
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds [100 x float], [100 x float]* %7, i64 0, i64 %46
%48 = load float, float* %47
%49 = load float, float* %4
%50 = fsub float %48, %49
store float %50, float* %5
%51 = load i32, i32* %3
%52 = add nsw i32 %51, 1
%53 = load i32, i32* %3
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds [100 x float], [100 x float]* %7, i64 0, i64 %54
%56 = load float, float* %55
%57 = fpext float %56 to double
%58 = load float, float* %5
%59 = fpext float %58 to double
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0), i32 %52, double %57, double %59)
br label %61
61: ; preds = %44
%62 = load i32, i32* %3
%63 = add nsw i32 %62, 1
store i32 %63, i32* %3
br label %40
64: ; preds = %40
ret i32 0
}

LLVM IR (-O2):
@.str = [19 x i8] c"How many numbers? \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [12 x i8] c"i = %d x = \00"
@.str.4 = [3 x i8] c"%f\00"
@.str.5 = [21 x i8] c"\0AAverage is: %5.2f\0A\0A\00"
@.str.6 = [28 x i8] c"i = %d x = %5.2f d = %5.2f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x float]
%3 = bitcast i32* %1 to i8*
%4 = bitcast [100 x float]* %2 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%6 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%7 = call i32 @putchar(i32 10)
%8 = load i32, i32* %1
%9 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %23
10: ; preds = %0, %10
%11 = phi i64 [ %13, %10 ], [ 0, %0 ]
%12 = phi float [ %19, %10 ], [ 0.000000e+00, %0 ]
%13 = add nuw nsw i64 %11, 1
%14 = trunc i64 %13 to i32
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 %14)
%16 = getelementptr inbounds [100 x float], [100 x float]* %2, i64 0, i64 %11
%17 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), float* %16)
%18 = load float, float* %16
%19 = fadd float %12, %18
%20 = load i32, i32* %1
%21 = sext i32 %20 to i64
%22 = icmp slt i64 %13, %21
br i1 %22, label %10, label %23
23: ; preds = %10, %0
%24 = phi float [ 0.000000e+00, %0 ], [ %19, %10 ]
%25 = phi i32 [ %8, %0 ], [ %20, %10 ]
%26 = sitofp i32 %25 to float
%27 = fdiv float %24, %26
%28 = fpext float %27 to double
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), double %28)
%30 = load i32, i32* %1
%31 = icmp sgt i32 %30, 0
br i1 %31, label %32, label %45
32: ; preds = %23, %32
%33 = phi i64 [ %37, %32 ], [ 0, %23 ]
%34 = getelementptr inbounds [100 x float], [100 x float]* %2, i64 0, i64 %33
%35 = load float, float* %34
%36 = fsub float %35, %27
%37 = add nuw nsw i64 %33, 1
%38 = fpext float %35 to double
%39 = fpext float %36 to double
%40 = trunc i64 %37 to i32
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0), i32 %40, double %38, double %39)
%42 = load i32, i32* %1
%43 = sext i32 %42 to i64
%44 = icmp slt i64 %37, %43
br i1 %44, label %32, label %45
45: ; preds = %32, %23
ret i32 0
}