#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*/ N_point(int, double *);
int atoi(char *);
int /*<<< orphan*/ err_check(scalar_t__);
scalar_t__ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int scanf(char *, double *);
int main(int argc, char *argv[]) {
  errno = 0;
  int check = 0, i = 0, temp, N = atoi(argv[1]);
  double point_array[N], sum = 0, ave, *p;
  if (argc != 2) {
    printf(
        "\nN-Point Average: Input Error\n\nUsage: {Program_Name} N_value\n\n");
    exit(0);
  }
  printf("\n\n%d-Point Average\n\nInput Data\n", N);
  for (i; i < N; i++) {
    temp = i;
    if (scanf("%lf", &point_array[i]) == 1) {
      for (temp; temp + 1 > 0; --temp) {
        sum += point_array[temp];
        ave = sum / (i + 1);
      }
      printf("\nAverage = %lf", ave);
      sum = 0;
    } else {
      err_check(errno);
      printf("The # of inputs are less than the desired %d-point average\n", N);
      printf("The current average is %lf\n", ave);
      exit(0);
    }
  }
  p = point_array;
  N_point(N, p);
  err_check(errno);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e63(%rip),%rax
movq   $0x0,(%rax)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x28(%rbp)
lea    0xf(,%rax,8),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x50(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x30(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     11f0 <main+0x90>
lea    0xe1e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %edi,%edi
call   1080 <exit@plt>
mov    -0x20(%rbp),%esi
lea    0xe45(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    12f0 <main+0x190>
mov    -0x50(%rbp),%rsi
mov    -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
movslq -0x18(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rsi
lea    0xe41(%rip),%rdi
call   1060 <scanf@plt>
cmp    $0x1,%eax
jne    12a3 <main+0x143>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
cmp    $0x0,%eax
jle    1283 <main+0x123>
mov    -0x50(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
addsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
mov    -0x18(%rbp),%eax
add    $0x1,%eax
cvtsi2sd %eax,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x1c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1c(%rbp)
jmp    1237 <main+0xd7>
movsd  -0x40(%rbp),%xmm0
lea    0xdd0(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    12dd <main+0x17d>
mov    0x2d36(%rip),%rax
mov    (%rax),%rdi
call   1030 <err_check@plt>
mov    -0x20(%rbp),%esi
lea    0xdb2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movsd  -0x40(%rbp),%xmm0
lea    0xddb(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %edi,%edi
call   1080 <exit@plt>
jmp    12e2 <main+0x182>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1201 <main+0xa1>
mov    -0x50(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x20(%rbp),%edi
mov    -0x48(%rbp),%rsi
call   1050 <N_point@plt>
mov    0x2cd5(%rip),%rax
mov    (%rax),%rdi
call   1030 <err_check@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
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
mov    %edi,%r15d
mov    0x2e55(%rip),%rax
movq   $0x0,(%rax)
mov    0x8(%rsi),%rdi
call   1080 <atoi@plt>
mov    %eax,%r14d
mov    %rsp,%rbx
lea    0xf(,%r14,8),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
cmp    $0x2,%r15d
jne    134f <main+0x1df>
lea    0xe3c(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,-0x30(%rbp)
test   %r14d,%r14d
jle    1323 <main+0x1b3>
lea    0xe49(%rip),%rdi
mov    %rbx,%rsi
call   1070 <scanf@plt>
cmp    $0x1,%eax
jne    1362 <main+0x1f2>
mov    $0x1,%r13b
xor    %r12d,%r12d
mov    %rbx,%r15
xor    %r14d,%r14d
nop
lea    0x1(%r14),%eax
test   $0x7,%al
je     1240 <main+0xd0>
movzbl %r13b,%ecx
and    $0x7,%ecx
neg    %rcx
xorpd  %xmm0,%xmm0
xor    %eax,%eax
nopl   0x0(%rax,%rax,1)
addsd  (%r15,%rax,8),%xmm0
add    $0xffffffffffffffff,%rax
cmp    %rax,%rcx
jne    1220 <main+0xb0>
sub    %r12,%rax
cmp    $0x7,%r14
jae    124d <main+0xdd>
jmp    129a <main+0x12a>
nopw   0x0(%rax,%rax,1)
xorpd  %xmm0,%xmm0
mov    %r14,%rax
cmp    $0x7,%r14
jb     129a <main+0x12a>
add    $0x8,%rax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
addsd  -0x40(%rbx,%rax,8),%xmm0
addsd  -0x48(%rbx,%rax,8),%xmm0
addsd  -0x50(%rbx,%rax,8),%xmm0
addsd  -0x58(%rbx,%rax,8),%xmm0
addsd  -0x60(%rbx,%rax,8),%xmm0
addsd  -0x68(%rbx,%rax,8),%xmm0
addsd  -0x70(%rbx,%rax,8),%xmm0
addsd  -0x78(%rbx,%rax,8),%xmm0
add    $0xfffffffffffffff8,%rax
cmp    $0x7,%rax
jg     1260 <main+0xf0>
add    $0x1,%r14
xorps  %xmm1,%xmm1
cvtsi2sd %r14d,%xmm1
divsd  %xmm1,%xmm0
lea    0xd6f(%rip),%rdi
movsd  %xmm0,-0x38(%rbp)
mov    $0x1,%al
call   1050 <printf@plt>
cmp    -0x30(%rbp),%r14
je     1323 <main+0x1b3>
lea    (%rbx,%r14,8),%rsi
lea    0xd5d(%rip),%rdi
call   1070 <scanf@plt>
add    $0xffffffffffffffff,%r12
add    $0x8,%r15
add    $0x1,%r13b
cmp    $0x1,%eax
je     1200 <main+0x90>
mov    0x2cf1(%rip),%rax
mov    (%rax),%rdi
call   1030 <err_check@plt>
lea    0xd31(%rip),%rdi
mov    -0x30(%rbp),%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xd5b(%rip),%rdi
movsd  -0x38(%rbp),%xmm0
mov    $0x1,%al
call   1050 <printf@plt>
xor    %edi,%edi
call   1090 <exit@plt>
mov    -0x30(%rbp),%rdi
mov    %rbx,%rsi
call   1060 <N_point@plt>
mov    0x2caa(%rip),%rax
mov    (%rax),%rdi
call   1030 <err_check@plt>
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd31(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   1090 <exit@plt>
jmp    12e8 <main+0x178>

LLVM IR (-O0):
@errno = global i64 0
@.str = [63 x i8] c"\0AN-Point Average: Input Error\0A\0AUsage: {Program_Name} N_value\0A\0A\00"
@.str.1 = [32 x i8] c"\0A\0A%d-Point Average\0A\0AInput Data\0A\00"
@.str.2 = [4 x i8] c"%lf\00"
@.str.3 = [15 x i8] c"\0AAverage = %lf\00"
@.str.4 = [60 x i8] c"The # of inputs are less than the desired %d-point average\0A\00"
@.str.5 = [28 x i8] c"The current average is %lf\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i64
%12 = alloca double
%13 = alloca double
%14 = alloca double*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i64 0, i64* @errno
store i32 0, i32* %6
store i32 0, i32* %7
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i32 @atoi(i8* %17)
store i32 %18, i32* %9
%19 = load i32, i32* %9
%20 = zext i32 %19 to i64
%21 = call i8* @llvm.stacksave()
store i8* %21, i8** %10
%22 = alloca double, i64 %20
store i64 %20, i64* %11
store double 0.000000e+00, double* %12
%23 = load i32, i32* %4
%24 = icmp ne i32 %23, 2
br i1 %24, label %25, label %28
25: ; preds = %2
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str, i64 0, i64 0))
%27 = call i32 @exit(i32 0)
unreachable
28: ; preds = %2
%29 = load i32, i32* %9
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i32 %29)
%31 = load i32, i32* %7
br label %32
32: ; preds = %76, %28
%33 = load i32, i32* %7
%34 = load i32, i32* %9
%35 = icmp slt i32 %33, %34
br i1 %35, label %36, label %79
36: ; preds = %32
%37 = load i32, i32* %7
store i32 %37, i32* %8
%38 = load i32, i32* %7
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds double, double* %22, i64 %39
%41 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %40)
%42 = icmp eq i32 %41, 1
br i1 %42, label %43, label %67
43: ; preds = %36
%44 = load i32, i32* %8
br label %45
45: ; preds = %61, %43
%46 = load i32, i32* %8
%47 = add nsw i32 %46, 1
%48 = icmp sgt i32 %47, 0
br i1 %48, label %49, label %64
49: ; preds = %45
%50 = load i32, i32* %8
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds double, double* %22, i64 %51
%53 = load double, double* %52
%54 = load double, double* %12
%55 = fadd double %54, %53
store double %55, double* %12
%56 = load double, double* %12
%57 = load i32, i32* %7
%58 = add nsw i32 %57, 1
%59 = sitofp i32 %58 to double
%60 = fdiv double %56, %59
store double %60, double* %13
br label %61
61: ; preds = %49
%62 = load i32, i32* %8
%63 = add nsw i32 %62, -1
store i32 %63, i32* %8
br label %45
64: ; preds = %45
%65 = load double, double* %13
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), double %65)
store double 0.000000e+00, double* %12
br label %75
67: ; preds = %36
%68 = load i64, i64* @errno
%69 = call i32 @err_check(i64 %68)
%70 = load i32, i32* %9
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.4, i64 0, i64 0), i32 %70)
%72 = load double, double* %13
%73 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0), double %72)
%74 = call i32 @exit(i32 0)
unreachable
75: ; preds = %64
br label %76
76: ; preds = %75
%77 = load i32, i32* %7
%78 = add nsw i32 %77, 1
store i32 %78, i32* %7
br label %32
79: ; preds = %32
store double* %22, double** %14
%80 = load i32, i32* %9
%81 = load double*, double** %14
%82 = call i32 @N_point(i32 %80, double* %81)
%83 = load i64, i64* @errno
%84 = call i32 @err_check(i64 %83)
store i32 0, i32* %3
%85 = load i8*, i8** %10
%86 = load i32, i32* %3
ret i32 %86
}

LLVM IR (-O2):
@errno = global i64 0
@.str.1 = [32 x i8] c"\0A\0A%d-Point Average\0A\0AInput Data\0A\00"
@.str.2 = [4 x i8] c"%lf\00"
@.str.3 = [15 x i8] c"\0AAverage = %lf\00"
@.str.4 = [60 x i8] c"The # of inputs are less than the desired %d-point average\0A\00"
@.str.5 = [28 x i8] c"The current average is %lf\0A\00"
@str = [62 x i8] c"\0AN-Point Average: Input Error\0A\0AUsage: {Program_Name} N_value\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
store i64 0, i64* @errno
%3 = getelementptr inbounds i8*, i8** %1, i64 1
%4 = load i8*, i8** %3
%5 = tail call i32 @atoi(i8* %4)
%6 = zext i32 %5 to i64
%7 = alloca double, i64 %6
%8 = icmp eq i32 %0, 2
br i1 %8, label %12, label %9
9: ; preds = %2
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([62 x i8], [62 x i8]* @str, i64 0, i64 0))
%11 = tail call i32 @exit(i32 0)
unreachable
12: ; preds = %2
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i32 %5)
%14 = icmp sgt i32 %5, 0
br i1 %14, label %15, label %93
15: ; preds = %12
%16 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %7)
%17 = icmp eq i32 %16, 1
br i1 %17, label %22, label %86
18: ; preds = %78
%19 = getelementptr inbounds double, double* %7, i64 %80
%20 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %19)
%21 = icmp eq i32 %20, 1
br i1 %21, label %22, label %86
22: ; preds = %15, %18
%23 = phi i64 [ %80, %18 ], [ 0, %15 ]
%24 = add nuw i64 %23, 1
%25 = and i64 %24, 7
%26 = icmp eq i64 %25, 0
br i1 %26, label %37, label %27
27: ; preds = %22, %27
%28 = phi i64 [ %34, %27 ], [ %23, %22 ]
%29 = phi double [ %33, %27 ], [ 0.000000e+00, %22 ]
%30 = phi i64 [ %35, %27 ], [ 0, %22 ]
%31 = getelementptr inbounds double, double* %7, i64 %28
%32 = load double, double* %31
%33 = fadd double %29, %32
%34 = add nsw i64 %28, -1
%35 = add i64 %30, 1
%36 = icmp eq i64 %35, %25
br i1 %36, label %37, label %27
37: ; preds = %27, %22
%38 = phi i64 [ %23, %22 ], [ %34, %27 ]
%39 = phi double [ 0.000000e+00, %22 ], [ %33, %27 ]
%40 = phi double [ undef, %22 ], [ %33, %27 ]
%41 = icmp ult i64 %23, 7
br i1 %41, label %78, label %42
42: ; preds = %37, %42
%43 = phi i64 [ %76, %42 ], [ %38, %37 ]
%44 = phi double [ %75, %42 ], [ %39, %37 ]
%45 = getelementptr inbounds double, double* %7, i64 %43
%46 = load double, double* %45
%47 = fadd double %44, %46
%48 = add nsw i64 %43, -1
%49 = getelementptr inbounds double, double* %7, i64 %48
%50 = load double, double* %49
%51 = fadd double %47, %50
%52 = add nsw i64 %43, -2
%53 = getelementptr inbounds double, double* %7, i64 %52
%54 = load double, double* %53
%55 = fadd double %51, %54
%56 = add nsw i64 %43, -3
%57 = getelementptr inbounds double, double* %7, i64 %56
%58 = load double, double* %57
%59 = fadd double %55, %58
%60 = add nsw i64 %43, -4
%61 = getelementptr inbounds double, double* %7, i64 %60
%62 = load double, double* %61
%63 = fadd double %59, %62
%64 = add nsw i64 %43, -5
%65 = getelementptr inbounds double, double* %7, i64 %64
%66 = load double, double* %65
%67 = fadd double %63, %66
%68 = add nsw i64 %43, -6
%69 = getelementptr inbounds double, double* %7, i64 %68
%70 = load double, double* %69
%71 = fadd double %67, %70
%72 = add nsw i64 %43, -7
%73 = getelementptr inbounds double, double* %7, i64 %72
%74 = load double, double* %73
%75 = fadd double %71, %74
%76 = add nsw i64 %43, -8
%77 = icmp sgt i64 %43, 7
br i1 %77, label %42, label %78
78: ; preds = %42, %37
%79 = phi double [ %40, %37 ], [ %75, %42 ]
%80 = add nuw nsw i64 %23, 1
%81 = trunc i64 %80 to i32
%82 = sitofp i32 %81 to double
%83 = fdiv double %79, %82
%84 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), double %83)
%85 = icmp eq i64 %80, %6
br i1 %85, label %93, label %18
86: ; preds = %18, %15
%87 = phi double [ undef, %15 ], [ %83, %18 ]
%88 = load i64, i64* @errno
%89 = call i32 @err_check(i64 %88)
%90 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([60 x i8], [60 x i8]* @.str.4, i64 0, i64 0), i32 %5)
%91 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0), double %87)
%92 = call i32 @exit(i32 0)
unreachable
93: ; preds = %78, %12
%94 = call i32 @N_point(i32 %5, double* %7)
%95 = load i64, i64* @errno
%96 = call i32 @err_check(i64 %95)
ret i32 0
}