#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 EXIT_FAILURE;
int EXIT_SUCCESS;
char *basename(char *);
scalar_t__ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, ...);
int /*<<< orphan*/ printf(char *, double);
int /*<<< orphan*/ stderr;
double strtod(char *, char **);
int main(int argc, char *argv[]) {
  double total, mean, current;
  int count, i;
  char *ep;
  if (argc < 2) {
    fprintf(stderr, "usage: %s NUM...\n", basename(argv[0]));
    return EXIT_FAILURE;
  }
  total = 0.0;
  current = 0.0;
  count = 0;
  for (i = 1; i < argc; ++i) {
    errno = 0;
    current = strtod(argv[i], &ep);
    if (errno || *ep) {
      fprintf(stderr, "%s: '%s' is not a valid number, skipping...\n",
              basename(argv[0]), argv[i]);
    } else {
      total += current;
      ++count;
    }
  }
  mean = (double)total / count;
  printf("Total:           %10.2f\n", total);
  printf("Numbers:         %10d\n", count);
  printf("Arithmetic mean: %10.2f\n", mean);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    119d <main+0x5d>
mov    0x2e79(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1060 <basename@plt>
mov    -0x3c(%rbp),%edi
mov    %rax,%rdx
lea    0xe7b(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2e3d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12ca <main+0x18a>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
movl   $0x1,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1278 <main+0x138>
mov    0x2e0a(%rip),%rax
movq   $0x0,(%rax)
mov    -0x10(%rbp),%rax
movslq -0x30(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    -0x38(%rbp),%rsi
call   1030 <strtod@plt>
movsd  %xmm0,-0x28(%rbp)
mov    0x2de2(%rip),%rax
cmpq   $0x0,(%rax)
jne    1210 <main+0xd0>
mov    -0x38(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     124d <main+0x10d>
mov    0x2dc9(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x40(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1060 <basename@plt>
mov    -0x40(%rbp),%edi
mov    %rax,%rdx
mov    -0x10(%rbp),%rax
movslq -0x30(%rbp),%rcx
mov    (%rax,%rcx,8),%rcx
lea    0xdd1(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
jmp    1265 <main+0x125>
movsd  -0x28(%rbp),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    126a <main+0x12a>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    11bb <main+0x7b>
movsd  -0x18(%rbp),%xmm0
cvtsi2sdl -0x2c(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
lea    0xda8(%rip),%rdi
call   1040 <printf@plt>
cvtsi2sdl -0x2c(%rbp),%xmm0
lea    0xdb0(%rip),%rdi
call   1040 <printf@plt>
movsd  -0x20(%rbp),%xmm0
lea    0xdb6(%rip),%rdi
call   1040 <printf@plt>
mov    0x2d03(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%r13
cmp    $0x2,%edi
jge    1187 <main+0x47>
mov    0x2e83(%rip),%rax
mov    (%rax),%ebp
mov    0x0(%r13),%rdi
call   1060 <basename@plt>
lea    0xe91(%rip),%rsi
mov    %ebp,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    0x2e4e(%rip),%rax
jmp    1275 <main+0x135>
mov    %edi,%r12d
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x10(%rsp)
mov    $0x1,%ebx
mov    0x2e38(%rip),%r15
lea    0x20(%rsp),%r14
movl   $0x0,0x8(%rsp)
jmp    11e3 <main+0xa3>
nop
mov    0x2e29(%rip),%rax
mov    (%rax),%ebp
mov    0x0(%r13),%rdi
call   1060 <basename@plt>
mov    0x0(%r13,%rbx,8),%rcx
mov    %ebp,%edi
lea    0xe42(%rip),%rsi
mov    %rax,%rdx
xor    %eax,%eax
call   1050 <fprintf@plt>
add    $0x1,%rbx
cmp    %rbx,%r12
je     121e <main+0xde>
movq   $0x0,(%r15)
mov    0x0(%r13,%rbx,8),%rdi
mov    %r14,%rsi
call   1030 <strtod@plt>
cmpq   $0x0,(%r15)
jne    11b0 <main+0x70>
mov    0x20(%rsp),%rax
cmpb   $0x0,(%rax)
jne    11b0 <main+0x70>
movsd  0x10(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x10(%rsp)
addl   $0x1,0x8(%rsp)
jmp    11da <main+0x9a>
cvtsi2sdl 0x8(%rsp),%xmm2
movsd  %xmm2,0x18(%rsp)
movsd  0x10(%rsp),%xmm0
movapd %xmm0,%xmm1
divsd  %xmm2,%xmm1
movsd  %xmm1,0x8(%rsp)
lea    0xdfa(%rip),%rdi
call   1040 <printf@plt>
lea    0xe07(%rip),%rdi
movsd  0x18(%rsp),%xmm0
call   1040 <printf@plt>
lea    0xe0c(%rip),%rdi
movsd  0x8(%rsp),%xmm0
call   1040 <printf@plt>
mov    0x2d53(%rip),%rax
mov    (%rax),%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [18 x i8] c"usage: %s NUM...\0A\00"
@EXIT_FAILURE = global i32 0
@errno = global i64 0
@.str.1 = [45 x i8] c"%s: '%s' is not a valid number, skipping...\0A\00"
@.str.2 = [25 x i8] c"Total: %10.2f\0A\00"
@.str.3 = [23 x i8] c"Numbers: %10d\0A\00"
@.str.4 = [25 x i8] c"Arithmetic mean: %10.2f\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca i32
%10 = alloca i32
%11 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = load i32, i32* %4
%13 = icmp slt i32 %12, 2
br i1 %13, label %14, label %22
14: ; preds = %2
%15 = load i32, i32* @stderr
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 0
%18 = load i8*, i8** %17
%19 = call i8* @basename(i8* %18)
%20 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %15, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %19)
%21 = load i32, i32* @EXIT_FAILURE
store i32 %21, i32* %3
br label %76
22: ; preds = %2
store double 0.000000e+00, double* %6
store double 0.000000e+00, double* %8
store i32 0, i32* %9
store i32 1, i32* %10
br label %23
23: ; preds = %60, %22
%24 = load i32, i32* %10
%25 = load i32, i32* %4
%26 = icmp slt i32 %24, %25
br i1 %26, label %27, label %63
27: ; preds = %23
store i64 0, i64* @errno
%28 = load i8**, i8*** %5
%29 = load i32, i32* %10
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8*, i8** %28, i64 %30
%32 = load i8*, i8** %31
%33 = call double @strtod(i8* %32, i8** %11)
store double %33, double* %8
%34 = load i64, i64* @errno
%35 = icmp ne i64 %34, 0
br i1 %35, label %41, label %36
36: ; preds = %27
%37 = load i8*, i8** %11
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = icmp ne i32 %39, 0
br i1 %40, label %41, label %53
41: ; preds = %36, %27
%42 = load i32, i32* @stderr
%43 = load i8**, i8*** %5
%44 = getelementptr inbounds i8*, i8** %43, i64 0
%45 = load i8*, i8** %44
%46 = call i8* @basename(i8* %45)
%47 = load i8**, i8*** %5
%48 = load i32, i32* %10
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds i8*, i8** %47, i64 %49
%51 = load i8*, i8** %50
%52 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %42, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0), i8* %46, i8* %51)
br label %59
53: ; preds = %36
%54 = load double, double* %8
%55 = load double, double* %6
%56 = fadd double %55, %54
store double %56, double* %6
%57 = load i32, i32* %9
%58 = add nsw i32 %57, 1
store i32 %58, i32* %9
br label %59
59: ; preds = %53, %41
br label %60
60: ; preds = %59
%61 = load i32, i32* %10
%62 = add nsw i32 %61, 1
store i32 %62, i32* %10
br label %23
63: ; preds = %23
%64 = load double, double* %6
%65 = load i32, i32* %9
%66 = sitofp i32 %65 to double
%67 = fdiv double %64, %66
store double %67, double* %7
%68 = load double, double* %6
%69 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), double %68)
%70 = load i32, i32* %9
%71 = sitofp i32 %70 to double
%72 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), double %71)
%73 = load double, double* %7
%74 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), double %73)
%75 = load i32, i32* @EXIT_SUCCESS
store i32 %75, i32* %3
br label %76
76: ; preds = %63, %14
%77 = load i32, i32* %3
ret i32 %77
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [18 x i8] c"usage: %s NUM...\0A\00"
@EXIT_FAILURE = global i32 0
@errno = global i64 0
@.str.1 = [45 x i8] c"%s: '%s' is not a valid number, skipping...\0A\00"
@.str.2 = [25 x i8] c"Total: %10.2f\0A\00"
@.str.3 = [23 x i8] c"Numbers: %10d\0A\00"
@.str.4 = [25 x i8] c"Arithmetic mean: %10.2f\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i8*
%4 = bitcast i8** %3 to i8*
%5 = icmp slt i32 %0, 2
br i1 %5, label %8, label %6
6: ; preds = %2
%7 = zext i32 %0 to i64
br label %13
8: ; preds = %2
%9 = load i32, i32* @stderr
%10 = load i8*, i8** %1
%11 = tail call i8* @basename(i8* %10)
%12 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %11)
br label %46
13: ; preds = %6, %35
%14 = phi i64 [ 1, %6 ], [ %38, %35 ]
%15 = phi i32 [ 0, %6 ], [ %37, %35 ]
%16 = phi double [ 0.000000e+00, %6 ], [ %36, %35 ]
store i64 0, i64* @errno
%17 = getelementptr inbounds i8*, i8** %1, i64 %14
%18 = load i8*, i8** %17
%19 = call double @strtod(i8* %18, i8** %3)
%20 = load i64, i64* @errno
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %26
22: ; preds = %13
%23 = load i8*, i8** %3
%24 = load i8, i8* %23
%25 = icmp eq i8 %24, 0
br i1 %25, label %32, label %26
26: ; preds = %22, %13
%27 = load i32, i32* @stderr
%28 = load i8*, i8** %1
%29 = tail call i8* @basename(i8* %28)
%30 = load i8*, i8** %17
%31 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0), i8* %29, i8* %30)
br label %35
32: ; preds = %22
%33 = fadd double %16, %19
%34 = add nsw i32 %15, 1
br label %35
35: ; preds = %26, %32
%36 = phi double [ %16, %26 ], [ %33, %32 ]
%37 = phi i32 [ %15, %26 ], [ %34, %32 ]
%38 = add nuw nsw i64 %14, 1
%39 = icmp eq i64 %38, %7
br i1 %39, label %40, label %13
40: ; preds = %35
%41 = sitofp i32 %37 to double
%42 = fdiv double %36, %41
%43 = tail call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), double %36)
%44 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), double %41)
%45 = tail call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), double %42)
br label %46
46: ; preds = %40, %8
%47 = phi i32* [ @EXIT_FAILURE, %8 ], [ @EXIT_SUCCESS, %40 ]
%48 = load i32, i32* %47
ret i32 %48
}