#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 */
struct cpuidle_datas {
  int dummy;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, double, size_t);
int load_text_data_line(char *, struct cpuidle_datas *, char *, double *,
                        double *, size_t *);
int /*<<< orphan*/ setup_topo_states(struct cpuidle_datas *);
int /*<<< orphan*/ stderr;
void load_text_data_lines(FILE *f, char *buffer, struct cpuidle_datas *datas) {
  double begin = 0, end = 0;
  size_t count = 0, start = 1;
  setup_topo_states(datas);
  do {
    if (load_text_data_line(buffer, datas, "%*[^]]] %*s %lf:%*[^=]=%u%*[^=]=%d",
                            &begin, &end, &start) != -1) {
      count++;
    }
  } while (fgets(buffer, 256, f));
  fprintf(stderr, "Log is %lf secs long with %zu events\n", end - begin, count);
}


x86 assembly (clang, -O0):
<load_text_data_lines>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
movq   $0x1,-0x38(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <setup_topo_states@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
lea    0xe74(%rip),%rdx
lea    -0x20(%rbp),%rcx
lea    -0x28(%rbp),%r8
lea    -0x38(%rbp),%r9
call   1040 <load_text_data_line@plt>
cmp    $0xffffffff,%eax
je     11b2 <load_text_data_lines+0x72>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    11b7 <load_text_data_lines+0x77>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    $0x100,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
jne    117d <load_text_data_lines+0x3d>
mov    0x2e06(%rip),%rax
mov    (%rax),%edi
movsd  -0x28(%rbp),%xmm0
subsd  -0x20(%rbp),%xmm0
mov    -0x30(%rbp),%rdx
lea    0xe32(%rip),%rsi
call   1060 <fprintf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<load_text_data_lines>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%r12
movq   $0x0,0x8(%rsp)
movq   $0x0,(%rsp)
movq   $0x1,0x10(%rsp)
mov    %rdx,%rdi
call   1030 <setup_topo_states@plt>
xor    %ebx,%ebx
mov    %rsp,%r13
lea    0x10(%rsp),%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r15,%rdi
mov    %r14,%rsi
lea    0xe63(%rip),%rdx
lea    0x8(%rsp),%rcx
mov    %r13,%r8
mov    %rbp,%r9
call   1040 <load_text_data_line@plt>
xor    %ecx,%ecx
cmp    $0xffffffff,%eax
setne  %cl
add    %rcx,%rbx
mov    %r15,%rdi
mov    $0x100,%esi
mov    %r12,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
jne    1190 <load_text_data_lines+0x50>
mov    0x2e0c(%rip),%rax
mov    (%rax),%edi
movsd  (%rsp),%xmm0
subsd  0x8(%rsp),%xmm0
lea    0xe3b(%rip),%rsi
mov    %rbx,%rdx
call   1060 <fprintf@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.cpuidle_datas = type { i32 }
@.str = [35 x i8] c"%*[^]]] %*s %lf:%*[^=]=%u%*[^=]=%d\00"
@stderr = global i32 0
@.str.1 = [38 x i8] c"Log is %lf secs long with %zu events\0A\00"
define void @load_text_data_lines(i32* %0, i8* %1, %struct.cpuidle_datas* %2) {
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca %struct.cpuidle_datas*
%7 = alloca double
%8 = alloca double
%9 = alloca i64
%10 = alloca i64
store i32* %0, i32** %4
store i8* %1, i8** %5
store %struct.cpuidle_datas* %2, %struct.cpuidle_datas** %6
store double 0.000000e+00, double* %7
store double 0.000000e+00, double* %8
store i64 0, i64* %9
store i64 1, i64* %10
%11 = load %struct.cpuidle_datas*, %struct.cpuidle_datas** %6
%12 = call i32 @setup_topo_states(%struct.cpuidle_datas* %11)
br label %13
13: ; preds = %22, %3
%14 = load i8*, i8** %5
%15 = load %struct.cpuidle_datas*, %struct.cpuidle_datas** %6
%16 = call i32 @load_text_data_line(i8* %14, %struct.cpuidle_datas* %15, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), double* %7, double* %8, i64* %10)
%17 = icmp ne i32 %16, -1
br i1 %17, label %18, label %21
18: ; preds = %13
%19 = load i64, i64* %9
%20 = add i64 %19, 1
store i64 %20, i64* %9
br label %21
21: ; preds = %18, %13
br label %22
22: ; preds = %21
%23 = load i8*, i8** %5
%24 = load i32*, i32** %4
%25 = call i64 @fgets(i8* %23, i32 256, i32* %24)
%26 = icmp ne i64 %25, 0
br i1 %26, label %13, label %27
27: ; preds = %22
%28 = load i32, i32* @stderr
%29 = load double, double* %8
%30 = load double, double* %7
%31 = fsub double %29, %30
%32 = load i64, i64* %9
%33 = call i32 @fprintf(i32 %28, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), double %31, i64 %32)
ret void
}

LLVM IR (-O2):
%struct.cpuidle_datas = type { i32 }
@.str = [35 x i8] c"%*[^]]] %*s %lf:%*[^=]=%u%*[^=]=%d\00"
@stderr = global i32 0
@.str.1 = [38 x i8] c"Log is %lf secs long with %zu events\0A\00"
define void @load_text_data_lines(i32* nocapture %0, i8* %1, %struct.cpuidle_datas* %2) {
%4 = alloca double
%5 = alloca double
%6 = alloca i64
%7 = bitcast double* %4 to i8*
store double 0.000000e+00, double* %4
%8 = bitcast double* %5 to i8*
store double 0.000000e+00, double* %5
%9 = bitcast i64* %6 to i8*
store i64 1, i64* %6
%10 = tail call i32 @setup_topo_states(%struct.cpuidle_datas* %2)
br label %11
11: ; preds = %11, %3
%12 = phi i64 [ 0, %3 ], [ %16, %11 ]
%13 = call i32 @load_text_data_line(i8* %1, %struct.cpuidle_datas* %2, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), double* %4, double* %5, i64* %6)
%14 = icmp ne i32 %13, -1
%15 = zext i1 %14 to i64
%16 = add i64 %12, %15
%17 = call i64 @fgets(i8* %1, i32 256, i32* %0)
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %11
19: ; preds = %11
%20 = load i32, i32* @stderr
%21 = load double, double* %5
%22 = load double, double* %4
%23 = fsub double %21, %22
%24 = call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), double %23, i64 %16)
ret void
}