#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 */
scalar_t__ EOF;
int EXIT_SUCCESS;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
scalar_t__ fscanf(int /*<<< orphan*/ *, char *, char **, char *, double *);
int /*<<< orphan*/ printf(char *, int const);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char const *);
int /*<<< orphan*/ system(char *);
int main() {
  const int repeat = 100;
  int i;
  for (i = 0; i < repeat; ++i) {
    system("free_adt");
    system("free_c");
  }
  FILE *fp;
  char filename[] = "result_free";
  if ((fp = fopen(filename, "r")) == NULL) {
    fprintf(stderr, "Cannot open file %s\n", filename);
    exit(-1);
  }
  const int str_len = 50;
  const char C[] = "C";
  const char ADT[] = "ADT";
  char str[str_len], equal;
  double num, total = 0, counter = 0;
  double a_sum = 0, c_sum = 0;
  while (fscanf(fp, "%s %c %lf", &str, &equal, &num) != EOF) {
    if (strcmp(str, C) == 0) {
      c_sum += num;
    } else if (strcmp(str, ADT) == 0) {
      a_sum += num;
    }
    total = total + num;
    counter++;
  }
  counter = counter / 2;
  a_sum = a_sum / counter;
  c_sum = c_sum / counter;
  printf("\nThe total repeat times of program execution: %d\n", repeat);
  printf("The average time use in c version is %lf\n", c_sum);
  printf("The average time use in ADT version is %lf\n", a_sum);
  fclose(fp);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x64,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x64,-0xc(%rbp)
jge    11cd <main+0x4d>
lea    0xe62(%rip),%rdi
call   1040 <system@plt>
lea    0xe5f(%rip),%rdi
call   1040 <system@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    119d <main+0x1d>
mov    0xe4c(%rip),%rax
mov    %rax,-0x24(%rbp)
mov    0xe4a(%rip),%eax
mov    %eax,-0x1c(%rbp)
lea    -0x24(%rbp),%rdi
lea    0xe40(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    1222 <main+0xa2>
mov    0x2dd2(%rip),%rax
mov    (%rax),%edi
lea    -0x24(%rbp),%rdx
lea    0xe1b(%rip),%rsi
call   1080 <fprintf@plt>
mov    $0xffffffff,%edi
call   10a0 <exit@plt>
movl   $0x32,-0x28(%rbp)
movw   $0x43,-0x2a(%rbp)
movl   $0x544441,-0x30(%rbp)
mov    %rsp,%rax
mov    %rax,-0x38(%rbp)
mov    %rsp,%rax
add    $0xffffffffffffffc0,%rax
mov    %rax,-0x70(%rbp)
mov    %rax,%rsp
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x50(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x58(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x60(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x68(%rbp)
mov    -0x70(%rbp),%rdx
mov    -0x18(%rbp),%rdi
lea    0xdcf(%rip),%rsi
lea    -0x39(%rbp),%rcx
lea    -0x48(%rbp),%r8
call   1060 <fscanf@plt>
mov    0x2d5a(%rip),%rcx
cmp    (%rcx),%rax
je     1313 <main+0x193>
mov    -0x70(%rbp),%rdi
lea    -0x2a(%rbp),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    12c2 <main+0x142>
movsd  -0x48(%rbp),%xmm0
addsd  -0x68(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
jmp    12ed <main+0x16d>
mov    -0x70(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    12e8 <main+0x168>
movsd  -0x48(%rbp),%xmm0
addsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
jmp    12ed <main+0x16d>
movsd  -0x50(%rbp),%xmm0
addsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  0xd04(%rip),%xmm0
addsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
jmp    126b <main+0xeb>
movsd  -0x58(%rbp),%xmm0
movsd  0xce0(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x60(%rbp),%xmm0
divsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x68(%rbp),%xmm0
divsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
lea    0xd05(%rip),%rdi
mov    $0x64,%esi
call   1050 <printf@plt>
cvttsd2si -0x68(%rbp),%esi
lea    0xd21(%rip),%rdi
call   1050 <printf@plt>
cvttsd2si -0x60(%rbp),%esi
lea    0xd3a(%rip),%rdi
call   1050 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
mov    0x2c46(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    $0x64,%ebx
lea    0xe73(%rip),%r14
lea    0xe75(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14,%rdi
call   1040 <system@plt>
mov    %r15,%rdi
call   1040 <system@plt>
add    $0xffffffff,%ebx
jne    11b0 <main+0x30>
movabs $0x665f746c75736572,%rax
74 5f 66
mov    %rax,-0x60(%rbp)
movl   $0x656572,-0x58(%rbp)
lea    0xe4b(%rip),%rsi
lea    -0x60(%rbp),%rdi
call   1090 <fopen@plt>
test   %rax,%rax
je     1377 <main+0x1f7>
mov    %rax,%r14
mov    %rsp,%r15
movw   $0x43,-0x2c(%rbp)
movl   $0x544441,-0x54(%rbp)
mov    %rsp,%rbx
add    $0xffffffffffffffc0,%rbx
mov    %rbx,%rsp
lea    0xe2c(%rip),%rsi
lea    -0x29(%rbp),%rcx
lea    -0x50(%rbp),%r8
mov    %rax,%rdi
mov    %rbx,%rdx
call   1060 <fscanf@plt>
mov    0x2db7(%rip),%rcx
xorpd  %xmm2,%xmm2
xorpd  %xmm0,%xmm0
xorpd  %xmm1,%xmm1
cmp    (%rcx),%rax
je     130f <main+0x18f>
mov    %r15,-0x68(%rbp)
xorpd  %xmm0,%xmm0
movsd  %xmm0,-0x40(%rbp)
lea    0xde9(%rip),%r12
lea    -0x29(%rbp),%r13
lea    -0x50(%rbp),%r15
xorpd  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
xorpd  %xmm0,%xmm0
movsd  %xmm0,-0x48(%rbp)
jmp    12c1 <main+0x141>
cs nopw 0x0(%rax,%rax,1)
movsd  -0x40(%rbp),%xmm0
addsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x48(%rbp),%xmm0
addsd  0xd64(%rip),%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    %r14,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
mov    %r13,%rcx
mov    %r15,%r8
call   1060 <fscanf@plt>
mov    0x2d2c(%rip),%rcx
cmp    (%rcx),%rax
je     12f4 <main+0x174>
mov    %rbx,%rdi
lea    -0x2c(%rbp),%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     1280 <main+0x100>
mov    %rbx,%rdi
lea    -0x54(%rbp),%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
jne    128f <main+0x10f>
movsd  -0x38(%rbp),%xmm0
addsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    128f <main+0x10f>
movsd  -0x48(%rbp),%xmm2
mulsd  0xd07(%rip),%xmm2
mov    -0x68(%rbp),%r15
movsd  -0x38(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm1
divsd  %xmm2,%xmm0
movsd  %xmm0,-0x38(%rbp)
divsd  %xmm2,%xmm1
movsd  %xmm1,-0x40(%rbp)
lea    0xd25(%rip),%rdi
mov    $0x64,%esi
call   1050 <printf@plt>
cvttsd2si -0x40(%rbp),%esi
lea    0xd41(%rip),%rdi
call   1050 <printf@plt>
cvttsd2si -0x38(%rbp),%esi
lea    0xd5a(%rip),%rdi
call   1050 <printf@plt>
mov    %r14,%rdi
call   1030 <fclose@plt>
mov    0x2c6d(%rip),%rax
mov    (%rax),%eax
mov    %r15,%rsp
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2c5a(%rip),%rax
mov    (%rax),%edi
lea    0xca7(%rip),%rsi
lea    -0x60(%rbp),%rdx
call   1080 <fprintf@plt>
mov    $0xffffffff,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@.str = [9 x i8] c"free_adt\00"
@.str.1 = [7 x i8] c"free_c\00"
@__const.main.filename = [12 x i8] c"result_free\00"
@.str.2 = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.3 = [21 x i8] c"Cannot open file %s\0A\00"
@__const.main.C = [2 x i8] c"C\00"
@__const.main.ADT = [4 x i8] c"ADT\00"
@.str.4 = [10 x i8] c"%s %c %lf\00"
@EOF = global i64 0
@.str.5 = [50 x i8] c"\0AThe total repeat times of program execution: %d\0A\00"
@.str.6 = [42 x i8] c"The average time use in c version is %lf\0A\00"
@.str.7 = [44 x i8] c"The average time use in ADT version is %lf\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32*
%5 = alloca [12 x i8]
%6 = alloca i32
%7 = alloca [2 x i8]
%8 = alloca [4 x i8]
%9 = alloca i8*
%10 = alloca i8
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double
store i32 0, i32* %1
store i32 100, i32* %2
store i32 0, i32* %3
br label %16
16: ; preds = %22, %0
%17 = load i32, i32* %3
%18 = icmp slt i32 %17, 100
br i1 %18, label %19, label %25
19: ; preds = %16
%20 = call i32 @system(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%21 = call i32 @system(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
br label %22
22: ; preds = %19
%23 = load i32, i32* %3
%24 = add nsw i32 %23, 1
store i32 %24, i32* %3
br label %16
25: ; preds = %16
%26 = bitcast [12 x i8]* %5 to i8*
%27 = getelementptr inbounds [12 x i8], [12 x i8]* %5, i64 0, i64 0
%28 = call i32* @fopen(i8* %27, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %28, i32** %4
%29 = icmp eq i32* %28, null
br i1 %29, label %30, label %35
30: ; preds = %25
%31 = load i32, i32* @stderr
%32 = getelementptr inbounds [12 x i8], [12 x i8]* %5, i64 0, i64 0
%33 = call i32 @fprintf(i32 %31, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i8* %32)
%34 = call i32 @exit(i32 -1)
unreachable
35: ; preds = %25
store i32 50, i32* %6
%36 = bitcast [2 x i8]* %7 to i8*
%37 = bitcast [4 x i8]* %8 to i8*
%38 = call i8* @llvm.stacksave()
store i8* %38, i8** %9
%39 = alloca i8, i64 50
store double 0.000000e+00, double* %12
store double 0.000000e+00, double* %13
store double 0.000000e+00, double* %14
store double 0.000000e+00, double* %15
br label %40
40: ; preds = %63, %35
%41 = load i32*, i32** %4
%42 = bitcast i8* %39 to i8**
%43 = call i64 @fscanf(i32* %41, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8** %42, i8* %10, double* %11)
%44 = load i64, i64* @EOF
%45 = icmp ne i64 %43, %44
br i1 %45, label %46, label %69
46: ; preds = %40
%47 = getelementptr inbounds [2 x i8], [2 x i8]* %7, i64 0, i64 0
%48 = call i64 @strcmp(i8* %39, i8* %47)
%49 = icmp eq i64 %48, 0
br i1 %49, label %50, label %54
50: ; preds = %46
%51 = load double, double* %11
%52 = load double, double* %15
%53 = fadd double %52, %51
store double %53, double* %15
br label %63
54: ; preds = %46
%55 = getelementptr inbounds [4 x i8], [4 x i8]* %8, i64 0, i64 0
%56 = call i64 @strcmp(i8* %39, i8* %55)
%57 = icmp eq i64 %56, 0
br i1 %57, label %58, label %62
58: ; preds = %54
%59 = load double, double* %11
%60 = load double, double* %14
%61 = fadd double %60, %59
store double %61, double* %14
br label %62
62: ; preds = %58, %54
br label %63
63: ; preds = %62, %50
%64 = load double, double* %12
%65 = load double, double* %11
%66 = fadd double %64, %65
store double %66, double* %12
%67 = load double, double* %13
%68 = fadd double %67, 1.000000e+00
store double %68, double* %13
br label %40
69: ; preds = %40
%70 = load double, double* %13
%71 = fdiv double %70, 2.000000e+00
store double %71, double* %13
%72 = load double, double* %14
%73 = load double, double* %13
%74 = fdiv double %72, %73
store double %74, double* %14
%75 = load double, double* %15
%76 = load double, double* %13
%77 = fdiv double %75, %76
store double %77, double* %15
%78 = call i32 @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.5, i64 0, i64 0), i32 100)
%79 = load double, double* %15
%80 = fptosi double %79 to i32
%81 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.6, i64 0, i64 0), i32 %80)
%82 = load double, double* %14
%83 = fptosi double %82 to i32
%84 = call i32 @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.7, i64 0, i64 0), i32 %83)
%85 = load i32*, i32** %4
%86 = call i32 @fclose(i32* %85)
%87 = load i32, i32* @EXIT_SUCCESS
store i32 %87, i32* %1
%88 = load i8*, i8** %9
%89 = load i32, i32* %1
ret i32 %89
}

LLVM IR (-O2):
@.str = [9 x i8] c"free_adt\00"
@.str.1 = [7 x i8] c"free_c\00"
@__const.main.filename = [12 x i8] c"result_free\00"
@.str.2 = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.3 = [21 x i8] c"Cannot open file %s\0A\00"
@.str.4 = [10 x i8] c"%s %c %lf\00"
@EOF = global i64 0
@.str.5 = [50 x i8] c"\0AThe total repeat times of program execution: %d\0A\00"
@.str.6 = [42 x i8] c"The average time use in c version is %lf\0A\00"
@.str.7 = [44 x i8] c"The average time use in ADT version is %lf\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca [12 x i8]
%2 = alloca i16
%3 = alloca i32
%4 = alloca i8
%5 = alloca double
br label %6
6: ; preds = %0, %6
%7 = phi i32 [ 0, %0 ], [ %10, %6 ]
%8 = tail call i32 @system(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%9 = tail call i32 @system(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%10 = add nuw nsw i32 %7, 1
%11 = icmp eq i32 %10, 100
br i1 %11, label %12, label %6
12: ; preds = %6
%13 = getelementptr inbounds [12 x i8], [12 x i8]* %1, i64 0, i64 0
%14 = call i32* @fopen(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %20
16: ; preds = %12
%17 = load i32, i32* @stderr
%18 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i8* %13)
%19 = call i32 @exit(i32 -1)
unreachable
20: ; preds = %12
%21 = bitcast i16* %2 to i8*
store i16 67, i16* %2
%22 = bitcast i32* %3 to i8*
store i32 5522497, i32* %3
%23 = tail call i8* @llvm.stacksave()
%24 = alloca [50 x i8]
%25 = getelementptr inbounds [50 x i8], [50 x i8]* %24, i64 0, i64 0
%26 = bitcast double* %5 to i8*
%27 = bitcast [50 x i8]* %24 to i8**
%28 = call i64 @fscanf(i32* %14, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8** %27, i8* %4, double* %5)
%29 = load i64, i64* @EOF
%30 = icmp eq i64 %28, %29
br i1 %30, label %55, label %31
31: ; preds = %20, %46
%32 = phi double [ %48, %46 ], [ 0.000000e+00, %20 ]
%33 = phi double [ %47, %46 ], [ 0.000000e+00, %20 ]
%34 = phi double [ %49, %46 ], [ 0.000000e+00, %20 ]
%35 = call i64 @strcmp(i8* %25, i8* %21)
%36 = icmp eq i64 %35, 0
br i1 %36, label %37, label %40
37: ; preds = %31
%38 = load double, double* %5
%39 = fadd double %32, %38
br label %46
40: ; preds = %31
%41 = call i64 @strcmp(i8* %25, i8* %22)
%42 = icmp eq i64 %41, 0
br i1 %42, label %43, label %46
43: ; preds = %40
%44 = load double, double* %5
%45 = fadd double %33, %44
br label %46
46: ; preds = %40, %43, %37
%47 = phi double [ %33, %37 ], [ %45, %43 ], [ %33, %40 ]
%48 = phi double [ %39, %37 ], [ %32, %43 ], [ %32, %40 ]
%49 = fadd double %34, 1.000000e+00
%50 = call i64 @fscanf(i32* %14, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8** %27, i8* %4, double* %5)
%51 = load i64, i64* @EOF
%52 = icmp eq i64 %50, %51
br i1 %52, label %53, label %31
53: ; preds = %46
%54 = fmul double %49, 5.000000e-01
br label %55
55: ; preds = %53, %20
%56 = phi double [ 0.000000e+00, %20 ], [ %54, %53 ]
%57 = phi double [ 0.000000e+00, %20 ], [ %47, %53 ]
%58 = phi double [ 0.000000e+00, %20 ], [ %48, %53 ]
%59 = fdiv double %57, %56
%60 = fdiv double %58, %56
%61 = call i32 @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.5, i64 0, i64 0), i32 100)
%62 = fptosi double %60 to i32
%63 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.6, i64 0, i64 0), i32 %62)
%64 = fptosi double %59 to i32
%65 = call i32 @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.7, i64 0, i64 0), i32 %64)
%66 = call i32 @fclose(i32* %14)
%67 = load i32, i32* @EXIT_SUCCESS
ret i32 %67
}