#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;
};

/* Variables and functions */
int cpu_change_pstate(struct cpuidle_datas *, unsigned int, unsigned int,
                      double);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int get_wakeup_irq(struct cpuidle_datas *, char *);
int sscanf(char *, char *, double *, unsigned int *, unsigned int *);
int /*<<< orphan*/ stderr;
int store_data(double, unsigned int, unsigned int, struct cpuidle_datas *);
scalar_t__ strstr(char *, char *);
int load_text_data_line(char *buffer, struct cpuidle_datas *datas, char *format,
                        double *begin, double *end, size_t *start) {
  unsigned int state, freq, cpu;
  double time;
  if (strstr(buffer, "cpu_idle")) {
    if (sscanf(buffer, format, &time, &state, &cpu) != 3) {
      fprintf(stderr, "warning: Unrecognized cpuidle "
                      "record. The result of analysis might "
                      "be wrong.\n");
      return -1;
    }
    if (*start) {
      *begin = time;
      *start = 0;
    }
    *end = time;
    return store_data(time, state, cpu, datas);
  }
  if (strstr(buffer, "cpu_frequency")) {
    if (sscanf(buffer, format, &time, &freq, &cpu) != 3) {
      fprintf(stderr, "warning: Unrecognized cpufreq "
                      "record. The result of analysis might "
                      "be wrong.\n");
      return -1;
    }
    return cpu_change_pstate(datas, cpu, freq, time);
  }
  return get_wakeup_irq(datas, buffer);
}


x86 assembly (clang, -O0):
<load_text_data_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    %r9,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe75(%rip),%rsi
call   1080 <strstr@plt>
cmp    $0x0,%rax
je     122c <load_text_data_line+0xcc>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
lea    -0x50(%rbp),%rdx
lea    -0x3c(%rbp),%rcx
lea    -0x44(%rbp),%r8
call   1060 <sscanf@plt>
cmp    $0x3,%eax
je     11dd <load_text_data_line+0x7d>
mov    0x2e1d(%rip),%rax
mov    (%rax),%edi
lea    0xe3d(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12b5 <load_text_data_line+0x155>
mov    -0x38(%rbp),%rax
cmpq   $0x0,(%rax)
je     1203 <load_text_data_line+0xa3>
movsd  -0x50(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x38(%rbp),%rax
movq   $0x0,(%rax)
movsd  -0x50(%rbp),%xmm0
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x50(%rbp),%xmm0
mov    -0x3c(%rbp),%edi
mov    -0x44(%rbp),%esi
mov    -0x18(%rbp),%rdx
call   1050 <store_data@plt>
mov    %eax,-0x4(%rbp)
jmp    12b5 <load_text_data_line+0x155>
mov    -0x10(%rbp),%rdi
lea    0xe20(%rip),%rsi
call   1080 <strstr@plt>
cmp    $0x0,%rax
je     12a5 <load_text_data_line+0x145>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
lea    -0x50(%rbp),%rdx
lea    -0x40(%rbp),%rcx
lea    -0x44(%rbp),%r8
call   1060 <sscanf@plt>
cmp    $0x3,%eax
je     1289 <load_text_data_line+0x129>
mov    0x2d71(%rip),%rax
mov    (%rax),%edi
lea    0xded(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12b5 <load_text_data_line+0x155>
mov    -0x18(%rbp),%rdi
mov    -0x44(%rbp),%esi
mov    -0x40(%rbp),%edx
movsd  -0x50(%rbp),%xmm0
call   1070 <cpu_change_pstate@plt>
mov    %eax,-0x4(%rbp)
jmp    12b5 <load_text_data_line+0x155>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <get_wakeup_irq@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<load_text_data_line>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r9,%r12
mov    %r8,%r15
mov    %rcx,%r13
mov    %rdx,%rbx
mov    %rsi,%r14
mov    %rdi,%rbp
lea    0xe79(%rip),%rsi
call   1080 <strstr@plt>
test   %rax,%rax
je     11e9 <load_text_data_line+0x89>
lea    0x10(%rsp),%rdx
lea    0xc(%rsp),%rcx
lea    0x8(%rsp),%r8
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1060 <sscanf@plt>
cmp    $0x3,%eax
jne    1234 <load_text_data_line+0xd4>
cmpq   $0x0,(%r12)
movsd  0x10(%rsp),%xmm0
je     11cf <load_text_data_line+0x6f>
movsd  %xmm0,0x0(%r13)
movq   $0x0,(%r12)
movsd  %xmm0,(%r15)
mov    0xc(%rsp),%edi
mov    0x8(%rsp),%esi
mov    %r14,%rdx
call   1050 <store_data@plt>
jmp    1279 <load_text_data_line+0x119>
lea    0xe67(%rip),%rsi
mov    %rbp,%rdi
call   1080 <strstr@plt>
test   %rax,%rax
je     1246 <load_text_data_line+0xe6>
lea    0x10(%rsp),%rdx
lea    0xc(%rsp),%rcx
lea    0x8(%rsp),%r8
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1060 <sscanf@plt>
cmp    $0x3,%eax
jne    125f <load_text_data_line+0xff>
mov    0x8(%rsp),%esi
mov    0xc(%rsp),%edx
movsd  0x10(%rsp),%xmm0
mov    %r14,%rdi
call   1070 <cpu_change_pstate@plt>
jmp    1279 <load_text_data_line+0x119>
mov    0x2da5(%rip),%rax
mov    (%rax),%edi
lea    0xdc5(%rip),%rsi
jmp    126f <load_text_data_line+0x10f>
mov    %r14,%rdi
mov    %rbp,%rsi
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <get_wakeup_irq@plt>
mov    0x2d7a(%rip),%rax
mov    (%rax),%edi
lea    0xdf6(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0xffffffff,%eax
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 = [9 x i8] c"cpu_idle\00"
@stderr = global i32 0
@.str.1 = [78 x i8] c"warning: Unrecognized cpuidle record. The result of analysis might be wrong.\0A\00"
@.str.2 = [14 x i8] c"cpu_frequency\00"
@.str.3 = [78 x i8] c"warning: Unrecognized cpufreq record. The result of analysis might be wrong.\0A\00"
define i32 @load_text_data_line(i8* %0, %struct.cpuidle_datas* %1, i8* %2, double* %3, double* %4, i64* %5) {
%7 = alloca i32
%8 = alloca i8*
%9 = alloca %struct.cpuidle_datas*
%10 = alloca i8*
%11 = alloca double*
%12 = alloca double*
%13 = alloca i64*
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca double
store i8* %0, i8** %8
store %struct.cpuidle_datas* %1, %struct.cpuidle_datas** %9
store i8* %2, i8** %10
store double* %3, double** %11
store double* %4, double** %12
store i64* %5, i64** %13
%18 = load i8*, i8** %8
%19 = call i64 @strstr(i8* %18, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %45
21: ; preds = %6
%22 = load i8*, i8** %8
%23 = load i8*, i8** %10
%24 = call i32 @sscanf(i8* %22, i8* %23, double* %17, i32* %14, i32* %16)
%25 = icmp ne i32 %24, 3
br i1 %25, label %26, label %29
26: ; preds = %21
%27 = load i32, i32* @stderr
%28 = call i32 @fprintf(i32 %27, i8* getelementptr inbounds ([78 x i8], [78 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %7
br label %67
29: ; preds = %21
%30 = load i64*, i64** %13
%31 = load i64, i64* %30
%32 = icmp ne i64 %31, 0
br i1 %32, label %33, label %37
33: ; preds = %29
%34 = load double, double* %17
%35 = load double*, double** %11
store double %34, double* %35
%36 = load i64*, i64** %13
store i64 0, i64* %36
br label %37
37: ; preds = %33, %29
%38 = load double, double* %17
%39 = load double*, double** %12
store double %38, double* %39
%40 = load double, double* %17
%41 = load i32, i32* %14
%42 = load i32, i32* %16
%43 = load %struct.cpuidle_datas*, %struct.cpuidle_datas** %9
%44 = call i32 @store_data(double %40, i32 %41, i32 %42, %struct.cpuidle_datas* %43)
store i32 %44, i32* %7
br label %67
45: ; preds = %6
%46 = load i8*, i8** %8
%47 = call i64 @strstr(i8* %46, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%48 = icmp ne i64 %47, 0
br i1 %48, label %49, label %63
49: ; preds = %45
%50 = load i8*, i8** %8
%51 = load i8*, i8** %10
%52 = call i32 @sscanf(i8* %50, i8* %51, double* %17, i32* %15, i32* %16)
%53 = icmp ne i32 %52, 3
br i1 %53, label %54, label %57
54: ; preds = %49
%55 = load i32, i32* @stderr
%56 = call i32 @fprintf(i32 %55, i8* getelementptr inbounds ([78 x i8], [78 x i8]* @.str.3, i64 0, i64 0))
store i32 -1, i32* %7
br label %67
57: ; preds = %49
%58 = load %struct.cpuidle_datas*, %struct.cpuidle_datas** %9
%59 = load i32, i32* %16
%60 = load i32, i32* %15
%61 = load double, double* %17
%62 = call i32 @cpu_change_pstate(%struct.cpuidle_datas* %58, i32 %59, i32 %60, double %61)
store i32 %62, i32* %7
br label %67
63: ; preds = %45
%64 = load %struct.cpuidle_datas*, %struct.cpuidle_datas** %9
%65 = load i8*, i8** %8
%66 = call i32 @get_wakeup_irq(%struct.cpuidle_datas* %64, i8* %65)
store i32 %66, i32* %7
br label %67
67: ; preds = %63, %57, %54, %37, %26
%68 = load i32, i32* %7
ret i32 %68
}

LLVM IR (-O2):
%struct.cpuidle_datas = type { i32 }
@.str = [9 x i8] c"cpu_idle\00"
@stderr = global i32 0
@.str.1 = [78 x i8] c"warning: Unrecognized cpuidle record. The result of analysis might be wrong.\0A\00"
@.str.2 = [14 x i8] c"cpu_frequency\00"
@.str.3 = [78 x i8] c"warning: Unrecognized cpufreq record. The result of analysis might be wrong.\0A\00"
define i32 @load_text_data_line(i8* %0, %struct.cpuidle_datas* %1, i8* nocapture %2, double* nocapture writeonly %3, double* nocapture writeonly %4, i64* nocapture %5) {
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca double
%11 = bitcast i32* %7 to i8*
%12 = bitcast i32* %8 to i8*
%13 = bitcast i32* %9 to i8*
%14 = bitcast double* %10 to i8*
%15 = tail call i64 @strstr(i8* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %32, label %17
17: ; preds = %6
%18 = call i32 @sscanf(i8* %0, i8* %2, double* %10, i32* %7, i32* %9)
%19 = icmp eq i32 %18, 3
br i1 %19, label %23, label %20
20: ; preds = %17
%21 = load i32, i32* @stderr
%22 = call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([78 x i8], [78 x i8]* @.str.1, i64 0, i64 0))
br label %48
23: ; preds = %17
%24 = load i64, i64* %5
%25 = icmp eq i64 %24, 0
%26 = load double, double* %10
br i1 %25, label %28, label %27
27: ; preds = %23
store double %26, double* %3
store i64 0, i64* %5
br label %28
28: ; preds = %23, %27
store double %26, double* %4
%29 = load i32, i32* %7
%30 = load i32, i32* %9
%31 = call i32 @store_data(double %26, i32 %29, i32 %30, %struct.cpuidle_datas* %1)
br label %48
32: ; preds = %6
%33 = tail call i64 @strstr(i8* %0, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%34 = icmp eq i64 %33, 0
br i1 %34, label %46, label %35
35: ; preds = %32
%36 = call i32 @sscanf(i8* %0, i8* %2, double* %10, i32* %8, i32* %9)
%37 = icmp eq i32 %36, 3
br i1 %37, label %41, label %38
38: ; preds = %35
%39 = load i32, i32* @stderr
%40 = call i32 @fprintf(i32 %39, i8* getelementptr inbounds ([78 x i8], [78 x i8]* @.str.3, i64 0, i64 0))
br label %48
41: ; preds = %35
%42 = load i32, i32* %9
%43 = load i32, i32* %8
%44 = load double, double* %10
%45 = call i32 @cpu_change_pstate(%struct.cpuidle_datas* %1, i32 %42, i32 %43, double %44)
br label %48
46: ; preds = %32
%47 = tail call i32 @get_wakeup_irq(%struct.cpuidle_datas* %1, i8* %0)
br label %48
48: ; preds = %46, %41, %38, %28, %20
%49 = phi i32 [ -1, %20 ], [ %31, %28 ], [ -1, %38 ], [ %45, %41 ], [ %47, %46 ]
ret i32 %49
}