#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*/ EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
int atoi(char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
scalar_t__ is_num(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
scalar_t__ time_summation(char *, int, int);
int main(int argc, char *argv[]) {
  if (argc > 3 || argc == 1) {
    printf("Usage: %s <filepath> [<num executions>]\n", argv[0]);
    exit(EXIT_FAILURE);
  }
  char *filepath = argv[1];
  int num_proc;
  printf("Enter the number of parallel processes to utilize (1, 2, or 4):\n");
  scanf("%d", &num_proc);
  int num_tests;
  if (argc == 3) {
    if (is_num(argv[2]) == 0) {
      printf("Invalid number of executions specified.\n");
      exit(EXIT_FAILURE);
    } else {
      num_tests = atoi(argv[2]);
    }
  } else {
    num_tests = 1;
  }
  printf("---------------------------------------------------------\n");
  printf("Filename: %s\n", filepath);
  int i;
  double total_time = 0;
  int should_print = 0;
  for (i = 0; i < num_tests; i++) {
    if (i == (num_tests - 1)) {
      should_print = 1;
    }
    total_time += time_summation(filepath, num_proc, should_print);
  }
  if (num_tests == 1) {
    printf("Execution time: %f seconds\n", total_time);
  } else {
    total_time = total_time / (double)num_tests;
    printf("Execution time: %f seconds (averaged over %d tests)\n", total_time,
           num_tests);
  }
  printf("---------------------------------------------------------\n");
  exit(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   $0x3,-0x8(%rbp)
jg     118a <main+0x2a>
cmpl   $0x1,-0x8(%rbp)
jne    11ad <main+0x4d>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe68(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2e3a(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
lea    0xe69(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe9c(%rip),%rdi
lea    -0x1c(%rbp),%rsi
call   1060 <scanf@plt>
cmpl   $0x3,-0x8(%rbp)
jne    1229 <main+0xc9>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1050 <is_num@plt>
cmp    $0x0,%rax
jne    1214 <main+0xb4>
lea    0xe6e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2dd3(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x20(%rbp)
jmp    1230 <main+0xd0>
movl   $0x1,-0x20(%rbp)
lea    0xe5f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rsi
lea    0xe88(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    12b6 <main+0x156>
mov    -0x24(%rbp),%eax
mov    -0x20(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jne    128a <main+0x12a>
movl   $0x1,-0x34(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x34(%rbp),%edx
call   1040 <time_summation@plt>
cvtsi2sd %rax,%xmm0
addsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1266 <main+0x106>
cmpl   $0x1,-0x20(%rbp)
jne    12d8 <main+0x178>
movsd  -0x30(%rbp),%xmm0
lea    0xe13(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    1301 <main+0x1a1>
movsd  -0x30(%rbp),%xmm0
cvtsi2sdl -0x20(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
mov    -0x20(%rbp),%esi
lea    0xe01(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
lea    0xd8e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2cc2(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r15
cmp    $0x3,%edi
jg     11d3 <main+0x63>
mov    %edi,%ebp
cmp    $0x1,%edi
je     11d3 <main+0x63>
mov    0x8(%r15),%r12
lea    0xef5(%rip),%rdi
call   1030 <puts@plt>
lea    0xe87(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1070 <scanf@plt>
mov    $0x1,%r14d
cmp    $0x3,%ebp
jne    11fe <main+0x8e>
mov    0x10(%r15),%rdi
call   1060 <is_num@plt>
test   %rax,%rax
jne    11f2 <main+0x82>
lea    0xf39(%rip),%rdi
call   1030 <puts@plt>
jmp    11e4 <main+0x74>
mov    (%r15),%rsi
lea    0xe23(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2df5(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
mov    0x10(%r15),%rdi
call   1080 <atoi@plt>
mov    %eax,%r14d
lea    0xec6(%rip),%rdi
call   1030 <puts@plt>
lea    0xe1b(%rip),%rdi
xor    %ebp,%ebp
mov    %r12,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
xorpd  %xmm0,%xmm0
test   %r14d,%r14d
jle    1277 <main+0x107>
xorpd  %xmm0,%xmm0
mov    %r14d,%ebx
nopl   (%rax)
movsd  %xmm0,0x8(%rsp)
cmp    $0x1,%ebx
cmove  %ebx,%ebp
mov    0x4(%rsp),%esi
mov    %r12,%rdi
mov    %ebp,%edx
call   1050 <time_summation@plt>
movsd  0x8(%rsp),%xmm0
xorps  %xmm1,%xmm1
cvtsi2sd %rax,%xmm1
addsd  %xmm1,%xmm0
add    $0xffffffff,%ebx
jne    1230 <main+0xc0>
cmp    $0x1,%r14d
jne    1277 <main+0x107>
lea    0xdcc(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
jmp    1294 <main+0x124>
xorps  %xmm1,%xmm1
cvtsi2sd %r14d,%xmm1
divsd  %xmm1,%xmm0
lea    0xdcc(%rip),%rdi
mov    %r14d,%esi
mov    $0x1,%al
call   1040 <printf@plt>
lea    0xe30(%rip),%rdi
call   1030 <puts@plt>
mov    0x2d31(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [41 x i8] c"Usage: %s <filepath> [<num executions>]\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [65 x i8] c"Enter the number of parallel processes to utilize (1, 2, or 4):\0A\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [41 x i8] c"Invalid number of executions specified.\0A\00"
@.str.4 = [59 x i8] c"---------------------------------------------------------\0A\00"
@.str.5 = [14 x i8] c"Filename: %s\0A\00"
@.str.6 = [28 x i8] c"Execution time: %f seconds\0A\00"
@.str.7 = [53 x i8] c"Execution time: %f seconds (averaged over %d tests)\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 i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca double
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = load i32, i32* %4
%13 = icmp sgt i32 %12, 3
br i1 %13, label %17, label %14
14: ; preds = %2
%15 = load i32, i32* %4
%16 = icmp eq i32 %15, 1
br i1 %16, label %17, label %24
17: ; preds = %14, %2
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 0
%20 = load i8*, i8** %19
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i8* %20)
%22 = load i32, i32* @EXIT_FAILURE
%23 = call i32 @exit(i32 %22)
unreachable
24: ; preds = %14
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 1
%27 = load i8*, i8** %26
store i8* %27, i8** %6
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.1, i64 0, i64 0))
%29 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %7)
%30 = load i32, i32* %4
%31 = icmp eq i32 %30, 3
br i1 %31, label %32, label %48
32: ; preds = %24
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 2
%35 = load i8*, i8** %34
%36 = call i64 @is_num(i8* %35)
%37 = icmp eq i64 %36, 0
br i1 %37, label %38, label %42
38: ; preds = %32
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.3, i64 0, i64 0))
%40 = load i32, i32* @EXIT_FAILURE
%41 = call i32 @exit(i32 %40)
unreachable
42: ; preds = %32
%43 = load i8**, i8*** %5
%44 = getelementptr inbounds i8*, i8** %43, i64 2
%45 = load i8*, i8** %44
%46 = call i32 @atoi(i8* %45)
store i32 %46, i32* %8
br label %47
47: ; preds = %42
br label %49
48: ; preds = %24
store i32 1, i32* %8
br label %49
49: ; preds = %48, %47
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.4, i64 0, i64 0))
%51 = load i8*, i8** %6
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i8* %51)
store double 0.000000e+00, double* %10
store i32 0, i32* %11
store i32 0, i32* %9
br label %53
53: ; preds = %71, %49
%54 = load i32, i32* %9
%55 = load i32, i32* %8
%56 = icmp slt i32 %54, %55
br i1 %56, label %57, label %74
57: ; preds = %53
%58 = load i32, i32* %9
%59 = load i32, i32* %8
%60 = sub nsw i32 %59, 1
%61 = icmp eq i32 %58, %60
br i1 %61, label %62, label %63
62: ; preds = %57
store i32 1, i32* %11
br label %63
63: ; preds = %62, %57
%64 = load i8*, i8** %6
%65 = load i32, i32* %7
%66 = load i32, i32* %11
%67 = call i64 @time_summation(i8* %64, i32 %65, i32 %66)
%68 = sitofp i64 %67 to double
%69 = load double, double* %10
%70 = fadd double %69, %68
store double %70, double* %10
br label %71
71: ; preds = %63
%72 = load i32, i32* %9
%73 = add nsw i32 %72, 1
store i32 %73, i32* %9
br label %53
74: ; preds = %53
%75 = load i32, i32* %8
%76 = icmp eq i32 %75, 1
br i1 %76, label %77, label %80
77: ; preds = %74
%78 = load double, double* %10
%79 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0), double %78)
br label %88
80: ; preds = %74
%81 = load double, double* %10
%82 = load i32, i32* %8
%83 = sitofp i32 %82 to double
%84 = fdiv double %81, %83
store double %84, double* %10
%85 = load double, double* %10
%86 = load i32, i32* %8
%87 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.7, i64 0, i64 0), double %85, i32 %86)
br label %88
88: ; preds = %80, %77
%89 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.4, i64 0, i64 0))
%90 = load i32, i32* @EXIT_SUCCESS
%91 = call i32 @exit(i32 %90)
unreachable
}

LLVM IR (-O2):
@.str = [41 x i8] c"Usage: %s <filepath> [<num executions>]\0A\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [3 x i8] c"%d\00"
@.str.5 = [14 x i8] c"Filename: %s\0A\00"
@.str.6 = [28 x i8] c"Execution time: %f seconds\0A\00"
@.str.7 = [53 x i8] c"Execution time: %f seconds (averaged over %d tests)\0A\00"
@EXIT_SUCCESS = global i32 0
@str = [64 x i8] c"Enter the number of parallel processes to utilize (1, 2, or 4):\00"
@str.9 = [58 x i8] c"---------------------------------------------------------\00"
@str.10 = [40 x i8] c"Invalid number of executions specified.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = icmp sgt i32 %0, 3
%5 = icmp eq i32 %0, 1
%6 = or i1 %4, %5
br i1 %6, label %7, label %12
7: ; preds = %2
%8 = load i8*, i8** %1
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = load i32, i32* @EXIT_FAILURE
%11 = tail call i32 @exit(i32 %10)
unreachable
12: ; preds = %2
%13 = getelementptr inbounds i8*, i8** %1, i64 1
%14 = load i8*, i8** %13
%15 = bitcast i32* %3 to i8*
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([64 x i8], [64 x i8]* @str, i64 0, i64 0))
%17 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%18 = icmp eq i32 %0, 3
br i1 %18, label %19, label %31
19: ; preds = %12
%20 = getelementptr inbounds i8*, i8** %1, i64 2
%21 = load i8*, i8** %20
%22 = call i64 @is_num(i8* %21)
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %28
24: ; preds = %19
%25 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str.10, i64 0, i64 0))
%26 = load i32, i32* @EXIT_FAILURE
%27 = call i32 @exit(i32 %26)
unreachable
28: ; preds = %19
%29 = load i8*, i8** %20
%30 = call i32 @atoi(i8* %29)
br label %31
31: ; preds = %12, %28
%32 = phi i32 [ %30, %28 ], [ 1, %12 ]
%33 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([58 x i8], [58 x i8]* @str.9, i64 0, i64 0))
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i8* %14)
%35 = icmp sgt i32 %32, 0
br i1 %35, label %36, label %54
36: ; preds = %31
%37 = add nsw i32 %32, -1
br label %38
38: ; preds = %36, %38
%39 = phi i32 [ 0, %36 ], [ %43, %38 ]
%40 = phi double [ 0.000000e+00, %36 ], [ %47, %38 ]
%41 = phi i32 [ 0, %36 ], [ %48, %38 ]
%42 = icmp eq i32 %41, %37
%43 = select i1 %42, i32 1, i32 %39
%44 = load i32, i32* %3
%45 = call i64 @time_summation(i8* %14, i32 %44, i32 %43)
%46 = sitofp i64 %45 to double
%47 = fadd double %40, %46
%48 = add nuw nsw i32 %41, 1
%49 = icmp eq i32 %48, %32
br i1 %49, label %50, label %38
50: ; preds = %38
%51 = icmp eq i32 %32, 1
br i1 %51, label %52, label %54
52: ; preds = %50
%53 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0), double %47)
br label %59
54: ; preds = %31, %50
%55 = phi double [ %47, %50 ], [ 0.000000e+00, %31 ]
%56 = sitofp i32 %32 to double
%57 = fdiv double %55, %56
%58 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @.str.7, i64 0, i64 0), double %57, i32 %32)
br label %59
59: ; preds = %54, %52
%60 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([58 x i8], [58 x i8]* @str.9, i64 0, i64 0))
%61 = load i32, i32* @EXIT_SUCCESS
%62 = call i32 @exit(i32 %61)
unreachable
}