#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 **);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *, double);
int main(void) {
  char *line_pointer_array[5000];
  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));
      break;
    case 1:
      printf("FEW_LARGE"
             "_LINES = [%f]\n",
             average_time(test_array[(1)], line_pointer_array));
      break;
    case 2:
      printf("MANY_SMALL"
             "_LINES = [%f]\n",
             average_time(test_array[(2)], line_pointer_array));
      break;
    case 3:
      printf("MANY_LARGE"
             "_LINES = [%f]\n",
             average_time(test_array[(3)], line_pointer_array));
      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    $0x9c80,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeb7(%rip),%rdi
lea    0xec9(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x9c70(%rbp)
lea    0xeb8(%rip),%rdi
lea    0xeaf(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x9c68(%rbp)
lea    0xeb7(%rip),%rdi
lea    0xe95(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x9c60(%rbp)
lea    0xeb7(%rip),%rdi
lea    0xe7b(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x9c58(%rbp)
movl   $0x0,-0x9c74(%rbp)
cmpl   $0x3,-0x9c74(%rbp)
jg     12a3 <main+0x163>
mov    -0x9c74(%rbp),%eax
mov    %rax,-0x9c80(%rbp)
sub    $0x3,%rax
ja     128a <main+0x14a>
mov    -0x9c80(%rbp),%rax
lea    0xe0a(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x9c70(%rbp),%rdi
lea    -0x9c50(%rbp),%rsi
call   1030 <average_time@plt>
lea    0xe5f(%rip),%rdi
call   1050 <printf@plt>
jmp    128a <main+0x14a>
mov    -0x9c68(%rbp),%rdi
lea    -0x9c50(%rbp),%rsi
call   1030 <average_time@plt>
lea    0xe53(%rip),%rdi
call   1050 <printf@plt>
jmp    128a <main+0x14a>
mov    -0x9c60(%rbp),%rdi
lea    -0x9c50(%rbp),%rsi
call   1030 <average_time@plt>
lea    0xe47(%rip),%rdi
call   1050 <printf@plt>
jmp    128a <main+0x14a>
mov    -0x9c58(%rbp),%rdi
lea    -0x9c50(%rbp),%rsi
call   1030 <average_time@plt>
lea    0xe3c(%rip),%rdi
call   1050 <printf@plt>
jmp    128f <main+0x14f>
mov    -0x9c74(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x9c74(%rbp)
jmp    11c4 <main+0x84>
mov    -0x9c70(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x9c68(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x9c60(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x9c58(%rbp),%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x9c80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x9c40,%rsp
lea    0xea9(%rip),%rdi
lea    0xebb(%rip),%rbx
mov    %rbx,%rsi
call   1060 <fopen@plt>
mov    %rax,%r14
lea    0xeab(%rip),%rdi
mov    %rbx,%rsi
call   1060 <fopen@plt>
mov    %rax,%r15
lea    0xeb2(%rip),%rdi
mov    %rbx,%rsi
call   1060 <fopen@plt>
mov    %rax,%r12
lea    0xeba(%rip),%rdi
mov    %rbx,%rsi
call   1060 <fopen@plt>
mov    %rax,%r13
mov    %rsp,%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <average_time@plt>
lea    0xeb4(%rip),%rdi
call   1050 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1030 <average_time@plt>
lea    0xeb5(%rip),%rdi
call   1050 <printf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1030 <average_time@plt>
lea    0xeb6(%rip),%rdi
call   1050 <printf@plt>
mov    %r13,%rdi
mov    %rbx,%rsi
call   1030 <average_time@plt>
lea    0xeb8(%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    $0x9c40,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
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 [4 x i32*]
%4 = alloca i32
store i32 0, i32* %1
%5 = 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 = getelementptr inbounds [4 x i32*], [4 x i32*]* %3, i64 0, i64 0
store i32* %5, i32** %6
%7 = 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))
%8 = getelementptr inbounds [4 x i32*], [4 x i32*]* %3, i64 0, i64 1
store i32* %7, i32** %8
%9 = 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))
%10 = getelementptr inbounds [4 x i32*], [4 x i32*]* %3, i64 0, i64 2
store i32* %9, i32** %10
%11 = 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))
%12 = getelementptr inbounds [4 x i32*], [4 x i32*]* %3, i64 0, i64 3
store i32* %11, i32** %12
store i32 0, i32* %4
br label %13
13: ; preds = %43, %0
%14 = load i32, i32* %4
%15 = icmp sle i32 %14, 3
br i1 %15, label %16, label %46
16: ; preds = %13
%17 = load i32, i32* %4
switch i32 %17, label %42 [
i32 0, label %18
i32 1, label %24
i32 2, label %30
i32 3, label %36
]
18: ; preds = %16
%19 = getelementptr inbounds [4 x i32*], [4 x i32*]* %3, i64 0, i64 0
%20 = load i32*, i32** %19
%21 = getelementptr inbounds [5000 x i8*], [5000 x i8*]* %2, i64 0, i64 0
%22 = call double @average_time(i32* %20, i8** %21)
%23 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0), double %22)
br label %42
24: ; preds = %16
%25 = getelementptr inbounds [4 x i32*], [4 x i32*]* %3, i64 0, i64 1
%26 = load i32*, i32** %25
%27 = getelementptr inbounds [5000 x i8*], [5000 x i8*]* %2, i64 0, i64 0
%28 = call double @average_time(i32* %26, i8** %27)
%29 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.6, i64 0, i64 0), double %28)
br label %42
30: ; preds = %16
%31 = getelementptr inbounds [4 x i32*], [4 x i32*]* %3, i64 0, i64 2
%32 = load i32*, i32** %31
%33 = getelementptr inbounds [5000 x i8*], [5000 x i8*]* %2, i64 0, i64 0
%34 = call double @average_time(i32* %32, i8** %33)
%35 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.7, i64 0, i64 0), double %34)
br label %42
36: ; preds = %16
%37 = getelementptr inbounds [4 x i32*], [4 x i32*]* %3, i64 0, i64 3
%38 = load i32*, i32** %37
%39 = getelementptr inbounds [5000 x i8*], [5000 x i8*]* %2, i64 0, i64 0
%40 = call double @average_time(i32* %38, i8** %39)
%41 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.8, i64 0, i64 0), double %40)
br label %42
42: ; preds = %16, %36, %30, %24, %18
br label %43
43: ; preds = %42
%44 = load i32, i32* %4
%45 = add nsw i32 %44, 1
store i32 %45, i32* %4
br label %13
46: ; preds = %13
%47 = getelementptr inbounds [4 x i32*], [4 x i32*]* %3, i64 0, i64 0
%48 = load i32*, i32** %47
%49 = call i32 @fclose(i32* %48)
%50 = getelementptr inbounds [4 x i32*], [4 x i32*]* %3, i64 0, i64 1
%51 = load i32*, i32** %50
%52 = call i32 @fclose(i32* %51)
%53 = getelementptr inbounds [4 x i32*], [4 x i32*]* %3, i64 0, i64 2
%54 = load i32*, i32** %53
%55 = call i32 @fclose(i32* %54)
%56 = getelementptr inbounds [4 x i32*], [4 x i32*]* %3, i64 0, i64 3
%57 = load i32*, i32** %56
%58 = call i32 @fclose(i32* %57)
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 = bitcast [5000 x i8*]* %1 to i8*
%3 = 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))
%4 = 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))
%5 = 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))
%6 = 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))
%7 = getelementptr inbounds [5000 x i8*], [5000 x i8*]* %1, i64 0, i64 0
%8 = call double @average_time(i32* %3, i8** %7)
%9 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0), double %8)
%10 = call double @average_time(i32* %4, i8** %7)
%11 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.6, i64 0, i64 0), double %10)
%12 = call double @average_time(i32* %5, i8** %7)
%13 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.7, i64 0, i64 0), double %12)
%14 = call double @average_time(i32* %6, i8** %7)
%15 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.8, i64 0, i64 0), double %14)
%16 = call i32 @fclose(i32* %3)
%17 = call i32 @fclose(i32* %4)
%18 = call i32 @fclose(i32* %5)
%19 = call i32 @fclose(i32* %6)
ret i32 0
}