#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 */
double population_std_deviation(double *, int);
double population_variance(double *, int);
int /*<<< orphan*/ printf(char *, double);
double sample_std_deviation(double *, int);
double sample_variance(double *, int);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ translateCSV(char *, double *, int *);
int /*<<< orphan*/ usage();
int /*<<< orphan*/ validateCSV(char *);
int main(int argc, char *argv[]) {
  double numbers[102400] = {0.0};
  int count = 0;
  if (argc != 3 || !validateCSV(argv[2])) {
    usage();
  } else {
    translateCSV(argv[2], numbers, &count);
    if (strcmp(argv[1], "sampvar") == 0) {
      printf("The sample variance is %f\n", sample_variance(numbers, count));
    } else if (strcmp(argv[1], "sstddev") == 0) {
      printf("The sample standard deviatation is %f\n",
             sample_std_deviation(numbers, count));
    } else if (strcmp(argv[1], "popvar") == 0) {
      printf("The population variance is %f\n",
             population_variance(numbers, count));
    } else if (strcmp(argv[1], "pstddev") == 0) {
      printf("The population standard deviatation is %f\n",
             population_std_deviation(numbers, count));
    } else {
      usage();
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc8020,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0xc8010(%rbp),%rdi
xor    %esi,%esi
mov    $0xc8000,%edx
call   1060 <memset@plt>
movl   $0x0,-0xc8014(%rbp)
cmpl   $0x3,-0x8(%rbp)
jne    11f6 <main+0x56>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1030 <validateCSV@plt>
cmp    $0x0,%eax
jne    1202 <main+0x62>
mov    $0x0,%al
call   10b0 <usage@plt>
jmp    133c <main+0x19c>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    -0xc8010(%rbp),%rsi
lea    -0xc8014(%rbp),%rdx
call   10a0 <translateCSV@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdd4(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    125e <main+0xbe>
lea    -0xc8010(%rbp),%rdi
mov    -0xc8014(%rbp),%esi
call   1090 <sample_variance@plt>
lea    0xdb4(%rip),%rdi
call   1040 <printf@plt>
jmp    1337 <main+0x197>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdb6(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    129f <main+0xff>
lea    -0xc8010(%rbp),%rdi
mov    -0xc8014(%rbp),%esi
call   10c0 <sample_std_deviation@plt>
lea    0xd96(%rip),%rdi
call   1040 <printf@plt>
jmp    1332 <main+0x192>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xda4(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    12e0 <main+0x140>
lea    -0xc8010(%rbp),%rdi
mov    -0xc8014(%rbp),%esi
call   1080 <population_variance@plt>
lea    0xd83(%rip),%rdi
call   1040 <printf@plt>
jmp    132d <main+0x18d>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xd89(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    1321 <main+0x181>
lea    -0xc8010(%rbp),%rdi
mov    -0xc8014(%rbp),%esi
call   1050 <population_std_deviation@plt>
lea    0xd69(%rip),%rdi
call   1040 <printf@plt>
jmp    1328 <main+0x188>
mov    $0x0,%al
call   10b0 <usage@plt>
jmp    132d <main+0x18d>
jmp    1332 <main+0x192>
jmp    1337 <main+0x197>
jmp    133c <main+0x19c>
xor    %eax,%eax
add    $0xc8020,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0xc8018,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0x10(%rsp),%rdi
mov    $0xc8000,%edx
xor    %esi,%esi
call   1060 <memset@plt>
movl   $0x0,0xc(%rsp)
cmp    $0x3,%ebp
jne    1240 <main+0xa0>
mov    0x10(%rbx),%rdi
call   1030 <validateCSV@plt>
test   %eax,%eax
je     1240 <main+0xa0>
mov    0x10(%rbx),%rdi
lea    0x10(%rsp),%rsi
lea    0xc(%rsp),%rdx
call   10a0 <translateCSV@plt>
mov    0x8(%rbx),%rdi
lea    0xe09(%rip),%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     1253 <main+0xb3>
mov    0x8(%rbx),%rdi
lea    0xe17(%rip),%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     126f <main+0xcf>
mov    0x8(%rbx),%rdi
lea    0xe31(%rip),%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     128b <main+0xeb>
mov    0x8(%rbx),%rdi
lea    0xe42(%rip),%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     12a7 <main+0x107>
xor    %eax,%eax
call   10b0 <usage@plt>
xor    %eax,%eax
add    $0xc8018,%rsp
pop    %rbx
pop    %rbp
ret
mov    0xc(%rsp),%esi
lea    0x10(%rsp),%rdi
call   1090 <sample_variance@plt>
lea    0xda0(%rip),%rdi
call   1040 <printf@plt>
jmp    1247 <main+0xa7>
mov    0xc(%rsp),%esi
lea    0x10(%rsp),%rdi
call   10c0 <sample_std_deviation@plt>
lea    0xda7(%rip),%rdi
call   1040 <printf@plt>
jmp    1247 <main+0xa7>
mov    0xc(%rsp),%esi
lea    0x10(%rsp),%rdi
call   1080 <population_variance@plt>
lea    0xdb9(%rip),%rdi
call   1040 <printf@plt>
jmp    1247 <main+0xa7>
mov    0xc(%rsp),%esi
lea    0x10(%rsp),%rdi
call   1050 <population_std_deviation@plt>
lea    0xdc4(%rip),%rdi
call   1040 <printf@plt>
jmp    1247 <main+0xa7>

LLVM IR (-O0):
@.str = [8 x i8] c"sampvar\00"
@.str.1 = [27 x i8] c"The sample variance is %f\0A\00"
@.str.2 = [8 x i8] c"sstddev\00"
@.str.3 = [39 x i8] c"The sample standard deviatation is %f\0A\00"
@.str.4 = [7 x i8] c"popvar\00"
@.str.5 = [31 x i8] c"The population variance is %f\0A\00"
@.str.6 = [8 x i8] c"pstddev\00"
@.str.7 = [43 x i8] c"The population standard deviatation is %f\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [102400 x double]
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = bitcast [102400 x double]* %6 to i8*
store i32 0, i32* %7
%9 = load i32, i32* %4
%10 = icmp ne i32 %9, 3
br i1 %10, label %17, label %11
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 2
%14 = load i8*, i8** %13
%15 = call i32 @validateCSV(i8* %14)
%16 = icmp ne i32 %15, 0
br i1 %16, label %19, label %17
17: ; preds = %11, %2
%18 = call i32 (...) @usage()
br label %74
19: ; preds = %11
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 2
%22 = load i8*, i8** %21
%23 = getelementptr inbounds [102400 x double], [102400 x double]* %6, i64 0, i64 0
%24 = call i32 @translateCSV(i8* %22, double* %23, i32* %7)
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 1
%27 = load i8*, i8** %26
%28 = call i64 @strcmp(i8* %27, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%29 = icmp eq i64 %28, 0
br i1 %29, label %30, label %35
30: ; preds = %19
%31 = getelementptr inbounds [102400 x double], [102400 x double]* %6, i64 0, i64 0
%32 = load i32, i32* %7
%33 = call double @sample_variance(double* %31, i32 %32)
%34 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), double %33)
br label %73
35: ; preds = %19
%36 = load i8**, i8*** %5
%37 = getelementptr inbounds i8*, i8** %36, i64 1
%38 = load i8*, i8** %37
%39 = call i64 @strcmp(i8* %38, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%40 = icmp eq i64 %39, 0
br i1 %40, label %41, label %46
41: ; preds = %35
%42 = getelementptr inbounds [102400 x double], [102400 x double]* %6, i64 0, i64 0
%43 = load i32, i32* %7
%44 = call double @sample_std_deviation(double* %42, i32 %43)
%45 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0), double %44)
br label %72
46: ; preds = %35
%47 = load i8**, i8*** %5
%48 = getelementptr inbounds i8*, i8** %47, i64 1
%49 = load i8*, i8** %48
%50 = call i64 @strcmp(i8* %49, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%51 = icmp eq i64 %50, 0
br i1 %51, label %52, label %57
52: ; preds = %46
%53 = getelementptr inbounds [102400 x double], [102400 x double]* %6, i64 0, i64 0
%54 = load i32, i32* %7
%55 = call double @population_variance(double* %53, i32 %54)
%56 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.5, i64 0, i64 0), double %55)
br label %71
57: ; preds = %46
%58 = load i8**, i8*** %5
%59 = getelementptr inbounds i8*, i8** %58, i64 1
%60 = load i8*, i8** %59
%61 = call i64 @strcmp(i8* %60, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0))
%62 = icmp eq i64 %61, 0
br i1 %62, label %63, label %68
63: ; preds = %57
%64 = getelementptr inbounds [102400 x double], [102400 x double]* %6, i64 0, i64 0
%65 = load i32, i32* %7
%66 = call double @population_std_deviation(double* %64, i32 %65)
%67 = call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.7, i64 0, i64 0), double %66)
br label %70
68: ; preds = %57
%69 = call i32 (...) @usage()
br label %70
70: ; preds = %68, %63
br label %71
71: ; preds = %70, %52
br label %72
72: ; preds = %71, %41
br label %73
73: ; preds = %72, %30
br label %74
74: ; preds = %73, %17
ret i32 0
}

LLVM IR (-O2):
@.str = [8 x i8] c"sampvar\00"
@.str.1 = [27 x i8] c"The sample variance is %f\0A\00"
@.str.2 = [8 x i8] c"sstddev\00"
@.str.3 = [39 x i8] c"The sample standard deviatation is %f\0A\00"
@.str.4 = [7 x i8] c"popvar\00"
@.str.5 = [31 x i8] c"The population variance is %f\0A\00"
@.str.6 = [8 x i8] c"pstddev\00"
@.str.7 = [43 x i8] c"The population standard deviatation is %f\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [102400 x double]
%4 = alloca i32
%5 = bitcast [102400 x double]* %3 to i8*
%6 = bitcast i32* %4 to i8*
store i32 0, i32* %4
%7 = icmp eq i32 %0, 3
br i1 %7, label %8, label %13
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 2
%10 = load i8*, i8** %9
%11 = tail call i32 @validateCSV(i8* %10)
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %8, %2
%14 = tail call i32 (...) @usage()
br label %53
15: ; preds = %8
%16 = load i8*, i8** %9
%17 = getelementptr inbounds [102400 x double], [102400 x double]* %3, i64 0, i64 0
%18 = call i32 @translateCSV(i8* %16, double* %17, i32* %4)
%19 = getelementptr inbounds i8*, i8** %1, i64 1
%20 = load i8*, i8** %19
%21 = call i64 @strcmp(i8* %20, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %27
23: ; preds = %15
%24 = load i32, i32* %4
%25 = call double @sample_variance(double* %17, i32 %24)
%26 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), double %25)
br label %53
27: ; preds = %15
%28 = load i8*, i8** %19
%29 = call i64 @strcmp(i8* %28, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %35
31: ; preds = %27
%32 = load i32, i32* %4
%33 = call double @sample_std_deviation(double* %17, i32 %32)
%34 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0), double %33)
br label %53
35: ; preds = %27
%36 = load i8*, i8** %19
%37 = call i64 @strcmp(i8* %36, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%38 = icmp eq i64 %37, 0
br i1 %38, label %39, label %43
39: ; preds = %35
%40 = load i32, i32* %4
%41 = call double @population_variance(double* %17, i32 %40)
%42 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.5, i64 0, i64 0), double %41)
br label %53
43: ; preds = %35
%44 = load i8*, i8** %19
%45 = call i64 @strcmp(i8* %44, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0))
%46 = icmp eq i64 %45, 0
br i1 %46, label %47, label %51
47: ; preds = %43
%48 = load i32, i32* %4
%49 = call double @population_std_deviation(double* %17, i32 %48)
%50 = call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.7, i64 0, i64 0), double %49)
br label %53
51: ; preds = %43
%52 = call i32 (...) @usage()
br label %53
53: ; preds = %23, %39, %51, %47, %31, %13
ret i32 0
}