#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 atoi(char *);
int /*<<< orphan*/ defaultConfig();
int /*<<< orphan*/ do_analysis();
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int getopt(int, char **, char *);
int /*<<< orphan*/ grep_car_parallel(char *, int);
int /*<<< orphan*/ grep_car_serial(char *, int);
int /*<<< orphan*/ helpOutput();
double omp_get_wtime();
char *optarg;
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  int opt;
  double start, end;
  double time_spent_grep;
  double time_spent_mv;
  double time_spent_reduction;
  double time_spent_noredution;
  int num_cars = 2500;
  int iter_time;
  char *file_name = NULL;
  while ((opt = getopt(argc, argv, "hf:c:t:")) != -1) {
    switch (opt) {
    case 'h':
      helpOutput();
      defaultConfig();
      break;
    case 'f':
      file_name = optarg;
      break;
    case 'c':
      num_cars = atoi(optarg);
      break;
    case 't':
      iter_time = atoi(optarg);
      break;
    default:
      fprintf(stderr, "Usage: %s [-f] [-c] [-t] [-h]", argv[0]);
      exit(EXIT_FAILURE);
    }
  }
  printf("filename:");
  start = omp_get_wtime();
  grep_car_serial(file_name, num_cars);
  end = omp_get_wtime();
  time_spent_grep = end - start;
  printf("time_spent_grep: %.16g\n", time_spent_grep);
  grep_car_parallel(file_name, num_cars);
  do_analysis();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x9c4,-0x4c(%rbp)
movq   $0x0,-0x58(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe65(%rip),%rdx
call   1090 <getopt@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
je     12a0 <main+0xf0>
mov    -0x14(%rbp),%eax
add    $0xffffff9d,%eax
mov    %eax,%ecx
mov    %rcx,-0x60(%rbp)
sub    $0x11,%eax
ja     1271 <main+0xc1>
mov    -0x60(%rbp),%rax
lea    0xdec(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x0,%al
call   1080 <helpOutput@plt>
mov    $0x0,%al
call   10d0 <defaultConfig@plt>
jmp    129b <main+0xeb>
mov    0x2dc1(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x58(%rbp)
jmp    129b <main+0xeb>
mov    0x2dae(%rip),%rax
mov    (%rax),%rdi
call   10a0 <atoi@plt>
mov    %eax,-0x4c(%rbp)
jmp    129b <main+0xeb>
mov    0x2d97(%rip),%rax
mov    (%rax),%rdi
call   10a0 <atoi@plt>
mov    %eax,-0x50(%rbp)
jmp    129b <main+0xeb>
mov    0x2d60(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xdc8(%rip),%rsi
call   1070 <fprintf@plt>
mov    0x2d3c(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
jmp    11d5 <main+0x25>
lea    0xdc7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1030 <omp_get_wtime@plt>
movsd  %xmm0,-0x20(%rbp)
mov    -0x58(%rbp),%rdi
mov    -0x4c(%rbp),%esi
call   1050 <grep_car_serial@plt>
mov    $0x0,%al
call   1030 <omp_get_wtime@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
subsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
lea    0xd8b(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    -0x58(%rbp),%rdi
mov    -0x4c(%rbp),%esi
call   10b0 <grep_car_parallel@plt>
mov    $0x0,%al
call   1060 <do_analysis@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r13
mov    %edi,%ebx
mov    $0x9c4,%r14d
lea    0xe7b(%rip),%r12
lea    0xe2c(%rip),%rbp
xor    %r15d,%r15d
jmp    11ee <main+0x3e>
nopl   0x0(%rax)
xor    %eax,%eax
call   1080 <helpOutput@plt>
xor    %eax,%eax
call   10d0 <defaultConfig@plt>
mov    %ebx,%edi
mov    %r13,%rsi
mov    %r12,%rdx
call   1090 <getopt@plt>
lea    -0x63(%rax),%ecx
cmp    $0x11,%ecx
ja     122d <main+0x7d>
movslq 0x0(%rbp,%rcx,4),%rax
add    %rbp,%rax
jmp    *%rax
mov    0x2de4(%rip),%rax
mov    (%rax),%rdi
call   10a0 <atoi@plt>
mov    %eax,%r14d
jmp    11ee <main+0x3e>
mov    0x2dd0(%rip),%rax
mov    (%rax),%r15
jmp    11ee <main+0x3e>
cmp    $0xffffffff,%eax
jne    1294 <main+0xe4>
lea    0xe35(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1030 <omp_get_wtime@plt>
movsd  %xmm0,(%rsp)
mov    %r15,%rdi
mov    %r14d,%esi
call   1050 <grep_car_serial@plt>
xor    %eax,%eax
call   1030 <omp_get_wtime@plt>
subsd  (%rsp),%xmm0
lea    0xe0e(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %r14d,%esi
call   10b0 <grep_car_parallel@plt>
xor    %eax,%eax
call   1060 <do_analysis@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2d3d(%rip),%rax
mov    (%rax),%edi
mov    0x0(%r13),%rdx
lea    0xda8(%rip),%rsi
call   1070 <fprintf@plt>
mov    0x2d1c(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
@.str = [8 x i8] c"hf:c:t:\00"
@optarg = global i8* null
@stderr = global i32 0
@.str.1 = [30 x i8] c"Usage: %s [-f] [-c] [-t] [-h]\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [10 x i8] c"filename:\00"
@.str.3 = [24 x i8] c"time_spent_grep: %.16g\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca i32
%14 = alloca i32
%15 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 2500, i32* %13
store i8* null, i8** %15
br label %16
16: ; preds = %42, %2
%17 = load i32, i32* %4
%18 = load i8**, i8*** %5
%19 = call i32 @getopt(i32 %17, i8** %18, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
store i32 %19, i32* %6
%20 = icmp ne i32 %19, -1
br i1 %20, label %21, label %43
21: ; preds = %16
%22 = load i32, i32* %6
switch i32 %22, label %34 [
i32 104, label %23
i32 102, label %26
i32 99, label %28
i32 116, label %31
]
23: ; preds = %21
%24 = call i32 (...) @helpOutput()
%25 = call i32 (...) @defaultConfig()
br label %42
26: ; preds = %21
%27 = load i8*, i8** @optarg
store i8* %27, i8** %15
br label %42
28: ; preds = %21
%29 = load i8*, i8** @optarg
%30 = call i32 @atoi(i8* %29)
store i32 %30, i32* %13
br label %42
31: ; preds = %21
%32 = load i8*, i8** @optarg
%33 = call i32 @atoi(i8* %32)
store i32 %33, i32* %14
br label %42
34: ; preds = %21
%35 = load i32, i32* @stderr
%36 = load i8**, i8*** %5
%37 = getelementptr inbounds i8*, i8** %36, i64 0
%38 = load i8*, i8** %37
%39 = call i32 @fprintf(i32 %35, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* %38)
%40 = load i32, i32* @EXIT_FAILURE
%41 = call i32 @exit(i32 %40)
unreachable
42: ; preds = %31, %28, %26, %23
br label %16
43: ; preds = %16
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%45 = call double (...) @omp_get_wtime()
store double %45, double* %7
%46 = load i8*, i8** %15
%47 = load i32, i32* %13
%48 = call i32 @grep_car_serial(i8* %46, i32 %47)
%49 = call double (...) @omp_get_wtime()
store double %49, double* %8
%50 = load double, double* %8
%51 = load double, double* %7
%52 = fsub double %50, %51
store double %52, double* %9
%53 = load double, double* %9
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), double %53)
%55 = load i8*, i8** %15
%56 = load i32, i32* %13
%57 = call i32 @grep_car_parallel(i8* %55, i32 %56)
%58 = call i32 (...) @do_analysis()
ret i32 0
}

LLVM IR (-O2):
@.str = [8 x i8] c"hf:c:t:\00"
@optarg = global i8* null
@stderr = global i32 0
@.str.1 = [30 x i8] c"Usage: %s [-f] [-c] [-t] [-h]\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [10 x i8] c"filename:\00"
@.str.3 = [24 x i8] c"time_spent_grep: %.16g\0A\00"
define i32 @main(i32 %0, i8** %1) {
br label %3
3: ; preds = %16, %2
%4 = phi i32 [ %18, %16 ], [ 2500, %2 ]
%5 = phi i8* [ %7, %16 ], [ null, %2 ]
br label %6
6: ; preds = %3, %14
%7 = phi i8* [ %5, %3 ], [ %15, %14 ]
br label %8
8: ; preds = %10, %6
%9 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
switch i32 %9, label %19 [
i32 -1, label %25
i32 104, label %11
i32 102, label %14
i32 99, label %16
i32 116, label %10
]
10: ; preds = %8, %11
br label %8
11: ; preds = %8
%12 = tail call i32 (...) @helpOutput()
%13 = tail call i32 (...) @defaultConfig()
br label %10
14: ; preds = %8
%15 = load i8*, i8** @optarg
br label %6
16: ; preds = %8
%17 = load i8*, i8** @optarg
%18 = tail call i32 @atoi(i8* %17)
br label %3
19: ; preds = %8
%20 = load i32, i32* @stderr
%21 = load i8*, i8** %1
%22 = tail call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* %21)
%23 = load i32, i32* @EXIT_FAILURE
%24 = tail call i32 @exit(i32 %23)
unreachable
25: ; preds = %8
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%27 = tail call double (...) @omp_get_wtime()
%28 = tail call i32 @grep_car_serial(i8* %7, i32 %4)
%29 = tail call double (...) @omp_get_wtime()
%30 = fsub double %29, %27
%31 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), double %30)
%32 = tail call i32 @grep_car_parallel(i8* %7, i32 %4)
%33 = tail call i32 (...) @do_analysis()
ret i32 0
}