#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
double average_time(int /*<<< orphan*/ *, char **, char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *, double);
int main(void) {
  char *line_pointer_array[5000];
  char lines_buffer[5000 * 1000];
  FILE *test_array[4];
  test_array[0] = fopen("test_few_small_lines.asc", "r");
  test_array[1] = fopen("test_few_large_lines.asc", "r");
  test_array[2] = fopen("test_many_small_lines.asc", "r");
  test_array[3] = fopen("test_many_large_lines.asc", "r");
  int element;
  for (element = 0; element <= 3; ++element) {
    switch (element) {
    case 0:
      printf("FEW_SMALL"
             "_LINES = [%f]\n",
             average_time(test_array[(0)], line_pointer_array, lines_buffer));
      break;
    case 1:
      printf("FEW_LARGE"
             "_LINES = [%f]\n",
             average_time(test_array[(1)], line_pointer_array, lines_buffer));
      break;
    case 2:
      printf("MANY_SMALL"
             "_LINES = [%f]\n",
             average_time(test_array[(2)], line_pointer_array, lines_buffer));
      break;
    case 3:
      printf("MANY_LARGE"
             "_LINES = [%f]\n",
             average_time(test_array[(3)], line_pointer_array, lines_buffer));
      break;
    }
  }
  fclose(test_array[0]);
  fclose(test_array[1]);
  fclose(test_array[2]);
  fclose(test_array[3]);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x4ce7c0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeb7(%rip),%rdi
lea    0xec9(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x4ce7b0(%rbp)
lea    0xeb8(%rip),%rdi
lea    0xeaf(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x4ce7a8(%rbp)
lea    0xeb7(%rip),%rdi
lea    0xe95(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x4ce7a0(%rbp)
lea    0xeb7(%rip),%rdi
lea    0xe7b(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x4ce798(%rbp)
movl   $0x0,-0x4ce7b4(%rbp)
cmpl   $0x3,-0x4ce7b4(%rbp)
jg     12bf <main+0x17f>
mov    -0x4ce7b4(%rbp),%eax
mov    %rax,-0x4ce7c0(%rbp)
sub    $0x3,%rax
ja     12a6 <main+0x166>
mov    -0x4ce7c0(%rbp),%rax
lea    0xe0a(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x4ce7b0(%rbp),%rdi
lea    -0x9c50(%rbp),%rsi
lea    -0x4ce790(%rbp),%rdx
call   1030 <average_time@plt>
lea    0xe58(%rip),%rdi
call   1050 <printf@plt>
jmp    12a6 <main+0x166>
mov    -0x4ce7a8(%rbp),%rdi
lea    -0x9c50(%rbp),%rsi
lea    -0x4ce790(%rbp),%rdx
call   1030 <average_time@plt>
lea    0xe45(%rip),%rdi
call   1050 <printf@plt>
jmp    12a6 <main+0x166>
mov    -0x4ce7a0(%rbp),%rdi
lea    -0x9c50(%rbp),%rsi
lea    -0x4ce790(%rbp),%rdx
call   1030 <average_time@plt>
lea    0xe32(%rip),%rdi
call   1050 <printf@plt>
jmp    12a6 <main+0x166>
mov    -0x4ce798(%rbp),%rdi
lea    -0x9c50(%rbp),%rsi
lea    -0x4ce790(%rbp),%rdx
call   1030 <average_time@plt>
lea    0xe20(%rip),%rdi
call   1050 <printf@plt>
jmp    12ab <main+0x16b>
mov    -0x4ce7b4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4ce7b4(%rbp)
jmp    11c4 <main+0x84>
mov    -0x4ce7b0(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x4ce7a8(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x4ce7a0(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x4ce798(%rbp),%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x4ce7c0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x4ce788,%rsp
lea    0xea8(%rip),%rdi
lea    0xeba(%rip),%rbx
mov    %rbx,%rsi
call   1060 <fopen@plt>
mov    %rax,%r14
lea    0xeaa(%rip),%rdi
mov    %rbx,%rsi
call   1060 <fopen@plt>
mov    %rax,%r15
lea    0xeb1(%rip),%rdi
mov    %rbx,%rsi
call   1060 <fopen@plt>
mov    %rax,%r12
lea    0xeb9(%rip),%rdi
mov    %rbx,%rsi
call   1060 <fopen@plt>
mov    %rax,%r13
mov    %rsp,%rbx
lea    0x9c40(%rsp),%rbp
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %rbp,%rdx
call   1030 <average_time@plt>
lea    0xea8(%rip),%rdi
call   1050 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %rbp,%rdx
call   1030 <average_time@plt>
lea    0xea6(%rip),%rdi
call   1050 <printf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
mov    %rbp,%rdx
call   1030 <average_time@plt>
lea    0xea4(%rip),%rdi
call   1050 <printf@plt>
mov    %r13,%rdi
mov    %rbx,%rsi
mov    %rbp,%rdx
call   1030 <average_time@plt>
lea    0xea3(%rip),%rdi
call   1050 <printf@plt>
mov    %r14,%rdi
call   1040 <fclose@plt>
mov    %r15,%rdi
call   1040 <fclose@plt>
mov    %r12,%rdi
call   1040 <fclose@plt>
mov    %r13,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x4ce788,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [25 x i8] c"test_few_small_lines.asc\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [25 x i8] c"test_few_large_lines.asc\00"
@.str.3 = [26 x i8] c"test_many_small_lines.asc\00"
@.str.4 = [26 x i8] c"test_many_large_lines.asc\00"
@.str.5 = [24 x i8] c"FEW_SMALL_LINES = [%f]\0A\00"
@.str.6 = [24 x i8] c"FEW_LARGE_LINES = [%f]\0A\00"
@.str.7 = [25 x i8] c"MANY_SMALL_LINES = [%f]\0A\00"
@.str.8 = [25 x i8] c"MANY_LARGE_LINES = [%f]\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [5000 x i8*]
%3 = alloca [5000000 x i8]
%4 = alloca [4 x i32*]
%5 = alloca i32
store i32 0, i32* %1
%6 = call i32* @fopen(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%7 = getelementptr inbounds [4 x i32*], [4 x i32*]* %4, i64 0, i64 0
store i32* %6, i32** %7
%8 = call i32* @fopen(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%9 = getelementptr inbounds [4 x i32*], [4 x i32*]* %4, i64 0, i64 1
store i32* %8, i32** %9
%10 = call i32* @fopen(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%11 = getelementptr inbounds [4 x i32*], [4 x i32*]* %4, i64 0, i64 2
store i32* %10, i32** %11
%12 = call i32* @fopen(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%13 = getelementptr inbounds [4 x i32*], [4 x i32*]* %4, i64 0, i64 3
store i32* %12, i32** %13
store i32 0, i32* %5
br label %14
14: ; preds = %48, %0
%15 = load i32, i32* %5
%16 = icmp sle i32 %15, 3
br i1 %16, label %17, label %51
17: ; preds = %14
%18 = load i32, i32* %5
switch i32 %18, label %47 [
i32 0, label %19
i32 1, label %26
i32 2, label %33
i32 3, label %40
]
19: ; preds = %17
%20 = getelementptr inbounds [4 x i32*], [4 x i32*]* %4, i64 0, i64 0
%21 = load i32*, i32** %20
%22 = getelementptr inbounds [5000 x i8*], [5000 x i8*]* %2, i64 0, i64 0
%23 = getelementptr inbounds [5000000 x i8], [5000000 x i8]* %3, i64 0, i64 0
%24 = call double @average_time(i32* %21, i8** %22, i8* %23)
%25 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0), double %24)
br label %47
26: ; preds = %17
%27 = getelementptr inbounds [4 x i32*], [4 x i32*]* %4, i64 0, i64 1
%28 = load i32*, i32** %27
%29 = getelementptr inbounds [5000 x i8*], [5000 x i8*]* %2, i64 0, i64 0
%30 = getelementptr inbounds [5000000 x i8], [5000000 x i8]* %3, i64 0, i64 0
%31 = call double @average_time(i32* %28, i8** %29, i8* %30)
%32 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.6, i64 0, i64 0), double %31)
br label %47
33: ; preds = %17
%34 = getelementptr inbounds [4 x i32*], [4 x i32*]* %4, i64 0, i64 2
%35 = load i32*, i32** %34
%36 = getelementptr inbounds [5000 x i8*], [5000 x i8*]* %2, i64 0, i64 0
%37 = getelementptr inbounds [5000000 x i8], [5000000 x i8]* %3, i64 0, i64 0
%38 = call double @average_time(i32* %35, i8** %36, i8* %37)
%39 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.7, i64 0, i64 0), double %38)
br label %47
40: ; preds = %17
%41 = getelementptr inbounds [4 x i32*], [4 x i32*]* %4, i64 0, i64 3
%42 = load i32*, i32** %41
%43 = getelementptr inbounds [5000 x i8*], [5000 x i8*]* %2, i64 0, i64 0
%44 = getelementptr inbounds [5000000 x i8], [5000000 x i8]* %3, i64 0, i64 0
%45 = call double @average_time(i32* %42, i8** %43, i8* %44)
%46 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.8, i64 0, i64 0), double %45)
br label %47
47: ; preds = %17, %40, %33, %26, %19
br label %48
48: ; preds = %47
%49 = load i32, i32* %5
%50 = add nsw i32 %49, 1
store i32 %50, i32* %5
br label %14
51: ; preds = %14
%52 = getelementptr inbounds [4 x i32*], [4 x i32*]* %4, i64 0, i64 0
%53 = load i32*, i32** %52
%54 = call i32 @fclose(i32* %53)
%55 = getelementptr inbounds [4 x i32*], [4 x i32*]* %4, i64 0, i64 1
%56 = load i32*, i32** %55
%57 = call i32 @fclose(i32* %56)
%58 = getelementptr inbounds [4 x i32*], [4 x i32*]* %4, i64 0, i64 2
%59 = load i32*, i32** %58
%60 = call i32 @fclose(i32* %59)
%61 = getelementptr inbounds [4 x i32*], [4 x i32*]* %4, i64 0, i64 3
%62 = load i32*, i32** %61
%63 = call i32 @fclose(i32* %62)
ret i32 0
}

LLVM IR (-O2):
@.str = [25 x i8] c"test_few_small_lines.asc\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [25 x i8] c"test_few_large_lines.asc\00"
@.str.3 = [26 x i8] c"test_many_small_lines.asc\00"
@.str.4 = [26 x i8] c"test_many_large_lines.asc\00"
@.str.5 = [24 x i8] c"FEW_SMALL_LINES = [%f]\0A\00"
@.str.6 = [24 x i8] c"FEW_LARGE_LINES = [%f]\0A\00"
@.str.7 = [25 x i8] c"MANY_SMALL_LINES = [%f]\0A\00"
@.str.8 = [25 x i8] c"MANY_LARGE_LINES = [%f]\0A\00"
define i32 @main() {
%1 = alloca [5000 x i8*]
%2 = alloca [5000000 x i8]
%3 = bitcast [5000 x i8*]* %1 to i8*
%4 = getelementptr inbounds [5000000 x i8], [5000000 x i8]* %2, i64 0, i64 0
%5 = tail call i32* @fopen(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%6 = tail call i32* @fopen(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%7 = tail call i32* @fopen(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%8 = tail call i32* @fopen(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%9 = getelementptr inbounds [5000 x i8*], [5000 x i8*]* %1, i64 0, i64 0
%10 = call double @average_time(i32* %5, i8** %9, i8* %4)
%11 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0), double %10)
%12 = call double @average_time(i32* %6, i8** %9, i8* %4)
%13 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.6, i64 0, i64 0), double %12)
%14 = call double @average_time(i32* %7, i8** %9, i8* %4)
%15 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.7, i64 0, i64 0), double %14)
%16 = call double @average_time(i32* %8, i8** %9, i8* %4)
%17 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.8, i64 0, i64 0), double %16)
%18 = call i32 @fclose(i32* %5)
%19 = call i32 @fclose(i32* %6)
%20 = call i32 @fclose(i32* %7)
%21 = call i32 @fclose(i32* %8)
ret i32 0
}