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

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
scalar_t__ clock();
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ free(char *);
int getline(char **, size_t *, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, int, float);
int main(int argc, char **argv) {
  FILE *fp;
  char *line = NULL;
  size_t len = 0;
  ssize_t read;
  int index = 0;
  clock_t t1, t2;
  fp = fopen("test.log", "r");
  if (fp == NULL) {
    exit(EXIT_FAILURE);
  }
  t1 = clock();
  while ((read = getline(&line, &len, fp)) != -1) {
    index++;
  }
  t2 = clock();
  float diff = (((float)t2 - (float)t1) / 1000000.0F) * 1000;
  printf("%d %f", index, diff);
  fclose(fp);
  if (line)
    free(line);
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movl   $0x0,-0x30(%rbp)
lea    0xe64(%rip),%rdi
lea    0xe66(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11cd <main+0x5d>
mov    0x2e1a(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
mov    $0x0,%al
call   1040 <clock@plt>
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%rdx
lea    -0x20(%rbp),%rdi
lea    -0x28(%rbp),%rsi
call   1080 <getline@plt>
mov    %eax,-0x2c(%rbp)
cmp    $0xffffffff,%eax
je     1203 <main+0x93>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    11d8 <main+0x68>
mov    $0x0,%al
call   1040 <clock@plt>
mov    %rax,-0x40(%rbp)
cvtsi2ssq -0x40(%rbp),%xmm0
cvtsi2ssq -0x38(%rbp),%xmm1
subss  %xmm1,%xmm0
movss  0xdde(%rip),%xmm1
divss  %xmm1,%xmm0
movss  0xdce(%rip),%xmm1
mulss  %xmm1,%xmm0
movss  %xmm0,-0x44(%rbp)
mov    -0x30(%rbp),%esi
movss  -0x44(%rbp),%xmm0
lea    0xdc9(%rip),%rdi
call   1060 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1050 <fclose@plt>
cmpq   $0x0,-0x20(%rbp)
je     126c <main+0xfc>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    0x2d65(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
movq   $0x0,(%rsp)
movq   $0x0,0x8(%rsp)
lea    0xe74(%rip),%rdi
lea    0xe76(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
jne    11b3 <main+0x43>
mov    0x2e34(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1040 <clock@plt>
mov    %rax,%r14
mov    $0xffffffff,%ebp
mov    %rsp,%r15
lea    0x8(%rsp),%r12
nopl   (%rax)
mov    %r15,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
call   1080 <getline@plt>
add    $0x1,%ebp
cmp    $0xffffffff,%eax
jne    11d0 <main+0x60>
xor    %eax,%eax
call   1040 <clock@plt>
cvtsi2ss %rax,%xmm0
cvtsi2ss %r14,%xmm1
subss  %xmm1,%xmm0
divss  0xdfd(%rip),%xmm0
mulss  0xdf9(%rip),%xmm0
lea    0xe01(%rip),%rdi
mov    %ebp,%esi
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1050 <fclose@plt>
mov    (%rsp),%rdi
test   %rdi,%rdi
je     122f <main+0xbf>
call   1030 <free@plt>
mov    0x2da2(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [9 x i8] c"test.log\00"
@.str.1 = [2 x i8] c"r\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [6 x i8] c"%d %f\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i32
%10 = alloca i32
%11 = alloca i64
%12 = alloca i64
%13 = alloca float
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* null, i8** %7
store i64 0, i64* %8
store i32 0, i32* %10
%14 = call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %14, i32** %6
%15 = load i32*, i32** %6
%16 = icmp eq i32* %15, null
br i1 %16, label %17, label %20
17: ; preds = %2
%18 = load i32, i32* @EXIT_FAILURE
%19 = call i32 @exit(i32 %18)
unreachable
20: ; preds = %2
%21 = call i64 (...) @clock()
store i64 %21, i64* %11
br label %22
22: ; preds = %26, %20
%23 = load i32*, i32** %6
%24 = call i32 @getline(i8** %7, i64* %8, i32* %23)
store i32 %24, i32* %9
%25 = icmp ne i32 %24, -1
br i1 %25, label %26, label %29
26: ; preds = %22
%27 = load i32, i32* %10
%28 = add nsw i32 %27, 1
store i32 %28, i32* %10
br label %22
29: ; preds = %22
%30 = call i64 (...) @clock()
store i64 %30, i64* %12
%31 = load i64, i64* %12
%32 = sitofp i64 %31 to float
%33 = load i64, i64* %11
%34 = sitofp i64 %33 to float
%35 = fsub float %32, %34
%36 = fdiv float %35, 1.000000e+06
%37 = fmul float %36, 1.000000e+03
store float %37, float* %13
%38 = load i32, i32* %10
%39 = load float, float* %13
%40 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %38, float %39)
%41 = load i32*, i32** %6
%42 = call i32 @fclose(i32* %41)
%43 = load i8*, i8** %7
%44 = icmp ne i8* %43, null
br i1 %44, label %45, label %48
45: ; preds = %29
%46 = load i8*, i8** %7
%47 = call i32 @free(i8* %46)
br label %48
48: ; preds = %45, %29
%49 = load i32, i32* @EXIT_SUCCESS
%50 = call i32 @exit(i32 %49)
unreachable
}

LLVM IR (-O2):
@.str = [9 x i8] c"test.log\00"
@.str.1 = [2 x i8] c"r\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [6 x i8] c"%d %f\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = bitcast i8** %3 to i8*
store i8* null, i8** %3
%6 = bitcast i64* %4 to i8*
store i64 0, i64* %4
%7 = tail call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%8 = icmp eq i32* %7, null
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = load i32, i32* @EXIT_FAILURE
%11 = tail call i32 @exit(i32 %10)
unreachable
12: ; preds = %2
%13 = tail call i64 (...) @clock()
br label %14
14: ; preds = %14, %12
%15 = phi i32 [ 0, %12 ], [ %18, %14 ]
%16 = call i32 @getline(i8** %3, i64* %4, i32* %7)
%17 = icmp eq i32 %16, -1
%18 = add nuw nsw i32 %15, 1
br i1 %17, label %19, label %14
19: ; preds = %14
%20 = call i64 (...) @clock()
%21 = sitofp i64 %20 to float
%22 = sitofp i64 %13 to float
%23 = fsub float %21, %22
%24 = fdiv float %23, 1.000000e+06
%25 = fmul float %24, 1.000000e+03
%26 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %15, float %25)
%27 = call i32 @fclose(i32* %7)
%28 = load i8*, i8** %3
%29 = icmp eq i8* %28, null
br i1 %29, label %32, label %30
30: ; preds = %19
%31 = call i32 @free(i8* %28)
br label %32
32: ; preds = %30, %19
%33 = load i32, i32* @EXIT_SUCCESS
%34 = call i32 @exit(i32 %33)
unreachable
}