#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 timeval {
  int tv_sec;
  int tv_usec;
};

/* Variables and functions */
unsigned long long generic_get_cpu_clockrate(int);
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
int /*<<< orphan*/ has_invariant_rdtsc();
int /*<<< orphan*/ has_rdtsc();
int /*<<< orphan*/ scaling_governor(int, char *, int);
scalar_t__ strcmp(char *, char *);
unsigned long long timestamp();
unsigned long long get_cpu_clockrate(int check, int cpu) {
  unsigned long long start1_tsc, start2_tsc, end1_tsc, end2_tsc;
  unsigned long long start_time, end_time;
  unsigned long long clock_lower_bound, clock_upper_bound, clock;
  unsigned long long clockrate = 0;
  int i, num_measurements = 0, min_measurements;
  char tmp[512];
  struct timeval ts;
  if (check) {
    scaling_governor(-1, tmp, 512);
    if (!has_invariant_rdtsc() && (strcmp(tmp, "performance")) &&
        (strcmp(tmp, "powersave")))
      return generic_get_cpu_clockrate(cpu);
    min_measurements = 5;
  } else
    min_measurements = 20;
  if (!has_rdtsc())
    return generic_get_cpu_clockrate(cpu);
  i = 3;
  do {
    start1_tsc = timestamp();
    gettimeofday(&ts, NULL);
    start2_tsc = timestamp();
    start_time = ts.tv_sec * 1000000 + ts.tv_usec;
    do {
      end1_tsc = timestamp();
    } while (end1_tsc < start2_tsc + 1000000 * i);
    end1_tsc = timestamp();
    gettimeofday(&ts, NULL);
    end2_tsc = timestamp();
    end_time = ts.tv_sec * 1000000 + ts.tv_usec;
    clock_lower_bound =
        (((end1_tsc - start2_tsc) * 1000000) / (end_time - start_time));
    clock_upper_bound =
        (((end2_tsc - start1_tsc) * 1000000) / (end_time - start_time));
    if (((double)clock_lower_bound > (((double)clock_upper_bound) * 0.999)) &&
        ((end_time - start_time) > 2000)) {
      num_measurements++;
      clock = (clock_lower_bound + clock_upper_bound) / 2;
      if (clockrate == 0)
        clockrate = clock;
      else if ((check) && (clock < clockrate))
        clockrate = clock;
      else if ((!check) && (clock > clockrate))
        clockrate = clock;
    }
    i += 2;
  } while (((end_time - start_time) < 10000) ||
           (num_measurements < min_measurements));
  return clockrate;
}


x86 assembly (clang, -O0):
<get_cpu_clockrate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x290,%rsp
mov    %edi,-0xc(%rbp)
mov    %esi,-0x10(%rbp)
movq   $0x0,-0x60(%rbp)
movl   $0x0,-0x68(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     1217 <get_cpu_clockrate+0xa7>
lea    -0x270(%rbp),%rsi
mov    $0xffffffff,%edi
mov    $0x200,%edx
call   1030 <scaling_governor@plt>
mov    $0x0,%al
call   1090 <has_invariant_rdtsc@plt>
cmp    $0x0,%eax
jne    120b <get_cpu_clockrate+0x9b>
lea    -0x270(%rbp),%rdi
lea    0xe62(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
je     120b <get_cpu_clockrate+0x9b>
lea    -0x270(%rbp),%rdi
lea    0xe51(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
je     120b <get_cpu_clockrate+0x9b>
mov    -0x10(%rbp),%edi
call   1080 <generic_get_cpu_clockrate@plt>
mov    %rax,-0x8(%rbp)
jmp    1498 <get_cpu_clockrate+0x328>
movl   $0x5,-0x6c(%rbp)
jmp    121e <get_cpu_clockrate+0xae>
movl   $0x14,-0x6c(%rbp)
mov    $0x0,%al
call   1040 <has_rdtsc@plt>
cmp    $0x0,%eax
jne    123f <get_cpu_clockrate+0xcf>
mov    -0x10(%rbp),%edi
call   1080 <generic_get_cpu_clockrate@plt>
mov    %rax,-0x8(%rbp)
jmp    1498 <get_cpu_clockrate+0x328>
movl   $0x3,-0x64(%rbp)
mov    $0x0,%al
call   1050 <timestamp@plt>
mov    %rax,-0x18(%rbp)
lea    -0x278(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1060 <gettimeofday@plt>
mov    $0x0,%al
call   1050 <timestamp@plt>
mov    %rax,-0x20(%rbp)
imul   $0xf4240,-0x278(%rbp),%eax
add    -0x274(%rbp),%eax
cltq
mov    %rax,-0x38(%rbp)
mov    $0x0,%al
call   1050 <timestamp@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    -0x20(%rbp),%rcx
imul   $0xf4240,-0x64(%rbp),%edx
movslq %edx,%rdx
add    %rdx,%rcx
cmp    %rcx,%rax
jb     1282 <get_cpu_clockrate+0x112>
xor    %eax,%eax
mov    %eax,-0x288(%rbp)
mov    %al,-0x281(%rbp)
call   1050 <timestamp@plt>
mov    %rax,%rcx
mov    -0x288(%rbp),%eax
mov    %rcx,-0x28(%rbp)
mov    %eax,%esi
mov    %rsi,-0x280(%rbp)
lea    -0x278(%rbp),%rdi
call   1060 <gettimeofday@plt>
mov    -0x281(%rbp),%al
call   1050 <timestamp@plt>
mov    -0x280(%rbp),%rdx
mov    %rax,-0x30(%rbp)
mov    -0x278(%rbp),%eax
mov    -0x274(%rbp),%ecx
imul   $0xf4240,%eax,%eax
add    %ecx,%eax
cltq
mov    %rax,-0x40(%rbp)
mov    -0x28(%rbp),%rax
mov    -0x20(%rbp),%rcx
sub    %rcx,%rax
imul   $0xf4240,%rax,%rax
mov    -0x40(%rbp),%rcx
mov    -0x38(%rbp),%rsi
sub    %rsi,%rcx
div    %rcx
mov    -0x280(%rbp),%rdx
mov    %rax,-0x48(%rbp)
mov    -0x30(%rbp),%rax
mov    -0x18(%rbp),%rcx
sub    %rcx,%rax
imul   $0xf4240,%rax,%rax
mov    -0x40(%rbp),%rcx
mov    -0x38(%rbp),%rsi
sub    %rsi,%rcx
div    %rcx
mov    %rax,-0x50(%rbp)
movaps 0xcaa(%rip),%xmm3
movq   -0x48(%rbp),%xmm0
punpckldq %xmm3,%xmm0
movapd 0xca9(%rip),%xmm2
subpd  %xmm2,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
movq   -0x50(%rbp),%xmm1
punpckldq %xmm3,%xmm1
subpd  %xmm2,%xmm1
movaps %xmm1,%xmm2
unpckhpd %xmm1,%xmm1
addsd  %xmm2,%xmm1
movsd  0xc5a(%rip),%xmm2
mulsd  %xmm2,%xmm1
ucomisd %xmm1,%xmm0
jbe    144d <get_cpu_clockrate+0x2dd>
mov    -0x40(%rbp),%rax
sub    -0x38(%rbp),%rax
cmp    $0x7d0,%rax
jbe    144d <get_cpu_clockrate+0x2dd>
mov    -0x68(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x68(%rbp)
mov    -0x48(%rbp),%rax
add    -0x50(%rbp),%rax
shr    $0x1,%rax
mov    %rax,-0x58(%rbp)
cmpq   $0x0,-0x60(%rbp)
jne    13f9 <get_cpu_clockrate+0x289>
mov    -0x58(%rbp),%rax
mov    %rax,-0x60(%rbp)
jmp    1448 <get_cpu_clockrate+0x2d8>
cmpl   $0x0,-0xc(%rbp)
je     141e <get_cpu_clockrate+0x2ae>
mov    -0x58(%rbp),%rax
cmp    -0x60(%rbp),%rax
jae    141e <get_cpu_clockrate+0x2ae>
mov    -0x58(%rbp),%rax
mov    %rax,-0x60(%rbp)
jmp    1443 <get_cpu_clockrate+0x2d3>
cmpl   $0x0,-0xc(%rbp)
jne    143e <get_cpu_clockrate+0x2ce>
mov    -0x58(%rbp),%rax
cmp    -0x60(%rbp),%rax
jbe    143e <get_cpu_clockrate+0x2ce>
mov    -0x58(%rbp),%rax
mov    %rax,-0x60(%rbp)
jmp    1443 <get_cpu_clockrate+0x2d3>
jmp    1448 <get_cpu_clockrate+0x2d8>
jmp    144d <get_cpu_clockrate+0x2dd>
mov    -0x64(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x64(%rbp)
mov    -0x40(%rbp),%rcx
sub    -0x38(%rbp),%rcx
mov    $0x1,%al
cmp    $0x2710,%rcx
mov    %al,-0x289(%rbp)
jb     1482 <get_cpu_clockrate+0x312>
mov    -0x68(%rbp),%eax
cmp    -0x6c(%rbp),%eax
setl   %al
mov    %al,-0x289(%rbp)
mov    -0x289(%rbp),%al
test   $0x1,%al
jne    1246 <get_cpu_clockrate+0xd6>
mov    -0x60(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x290,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_cpu_clockrate>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x228,%rsp
mov    %esi,%ebx
mov    %edi,0x14(%rsp)
test   %edi,%edi
je     11e4 <get_cpu_clockrate+0x74>
lea    0x20(%rsp),%rsi
mov    $0xffffffff,%edi
mov    $0x200,%edx
call   1030 <scaling_governor@plt>
xor    %eax,%eax
call   1090 <has_invariant_rdtsc@plt>
movl   $0x5,0x18(%rsp)
test   %eax,%eax
jne    11ec <get_cpu_clockrate+0x7c>
lea    0xe6f(%rip),%rsi
lea    0x20(%rsp),%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
je     11ec <get_cpu_clockrate+0x7c>
lea    0xe65(%rip),%rsi
lea    0x20(%rsp),%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
jne    13c1 <get_cpu_clockrate+0x251>
jmp    11ec <get_cpu_clockrate+0x7c>
movl   $0x14,0x18(%rsp)
xor    %eax,%eax
call   1040 <has_rdtsc@plt>
test   %eax,%eax
je     13c1 <get_cpu_clockrate+0x251>
cmpl   $0x0,0x14(%rsp)
setne  0x7(%rsp)
mov    $0x3,%r14d
xor    %r12d,%r12d
movl   $0x0,0x1c(%rsp)
cs nopw 0x0(%rax,%rax,1)
xor    %eax,%eax
call   1050 <timestamp@plt>
mov    %rax,%r13
lea    0x8(%rsp),%rdi
xor    %esi,%esi
call   1060 <gettimeofday@plt>
xor    %eax,%eax
call   1050 <timestamp@plt>
mov    %rax,%rbp
movslq 0x8(%rsp),%rax
imul   $0xf4240,%rax,%rax
movslq 0xc(%rsp),%r15
add    %rax,%r15
imul   $0xf4240,%r14d,%ebx
add    %rbp,%rbx
xchg   %ax,%ax
xor    %eax,%eax
call   1050 <timestamp@plt>
cmp    %rbx,%rax
jb     1260 <get_cpu_clockrate+0xf0>
xor    %eax,%eax
call   1050 <timestamp@plt>
mov    %rax,%rbx
lea    0x8(%rsp),%rdi
xor    %esi,%esi
call   1060 <gettimeofday@plt>
xor    %eax,%eax
call   1050 <timestamp@plt>
mov    %rax,%rsi
movslq 0x8(%rsp),%rax
imul   $0xf4240,%rax,%rax
movslq 0xc(%rsp),%rdi
add    %rax,%rdi
sub    %r15,%rdi
sub    %rbp,%rbx
imul   $0xf4240,%rbx,%rax
mov    %rax,%rcx
or     %rdi,%rcx
shr    $0x20,%rcx
je     12d0 <get_cpu_clockrate+0x160>
xor    %edx,%edx
div    %rdi
mov    %rax,%rcx
jmp    12d6 <get_cpu_clockrate+0x166>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %edx,%edx
div    %edi
mov    %eax,%ecx
sub    %r13,%rsi
imul   $0xf4240,%rsi,%rax
mov    %rax,%rdx
or     %rdi,%rdx
shr    $0x20,%rdx
je     1300 <get_cpu_clockrate+0x190>
xor    %edx,%edx
div    %rdi
jmp    1304 <get_cpu_clockrate+0x194>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %edx,%edx
div    %edi
movq   %rcx,%xmm0
movdqa 0xcef(%rip),%xmm2
punpckldq %xmm2,%xmm0
movapd 0xcf3(%rip),%xmm3
subpd  %xmm3,%xmm0
movapd %xmm0,%xmm1
unpckhpd %xmm0,%xmm1
addsd  %xmm0,%xmm1
movq   %rax,%xmm0
punpckldq %xmm2,%xmm0
subpd  %xmm3,%xmm0
movapd %xmm0,%xmm2
unpckhpd %xmm0,%xmm2
addsd  %xmm0,%xmm2
mulsd  0xcd2(%rip),%xmm2
ucomisd %xmm2,%xmm1
jbe    13a0 <get_cpu_clockrate+0x230>
cmp    $0x7d1,%rdi
jb     13a0 <get_cpu_clockrate+0x230>
addl   $0x1,0x1c(%rsp)
add    %rcx,%rax
shr    %rax
test   %r12,%r12
je     138c <get_cpu_clockrate+0x21c>
cmp    %r12,%rax
mov    %r12,%rcx
cmovb  %rax,%rcx
cmpb   $0x0,0x7(%rsp)
cmove  %r12,%rcx
cmpl   $0x0,0x14(%rsp)
je     1391 <get_cpu_clockrate+0x221>
mov    %rcx,%r12
jmp    13a0 <get_cpu_clockrate+0x230>
mov    %rax,%r12
jmp    13a0 <get_cpu_clockrate+0x230>
cmp    %r12,%rax
cmova  %rax,%r12
nopl   0x0(%rax,%rax,1)
add    $0x2,%r14
cmp    $0x2710,%rdi
jb     1220 <get_cpu_clockrate+0xb0>
mov    0x1c(%rsp),%eax
cmp    0x18(%rsp),%eax
jl     1220 <get_cpu_clockrate+0xb0>
jmp    13cb <get_cpu_clockrate+0x25b>
mov    %ebx,%edi
call   1080 <generic_get_cpu_clockrate@plt>
mov    %rax,%r12
mov    %r12,%rax
add    $0x228,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.timeval = type { i32, i32 }
@.str = [12 x i8] c"performance\00"
@.str.1 = [10 x i8] c"powersave\00"
define i64 @get_cpu_clockrate(i32 %0, i32 %1) {
%3 = alloca i64
%4 = alloca i32
%5 = alloca i32
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
%9 = alloca i64
%10 = alloca i64
%11 = alloca i64
%12 = alloca i64
%13 = alloca i64
%14 = alloca i64
%15 = alloca i64
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca [512 x i8]
%20 = alloca %struct.timeval
store i32 %0, i32* %4
store i32 %1, i32* %5
store i64 0, i64* %15
store i32 0, i32* %17
%21 = load i32, i32* %4
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %40
23: ; preds = %2
%24 = getelementptr inbounds [512 x i8], [512 x i8]* %19, i64 0, i64 0
%25 = call i32 @scaling_governor(i32 -1, i8* %24, i32 512)
%26 = call i32 (...) @has_invariant_rdtsc()
%27 = icmp ne i32 %26, 0
br i1 %27, label %39, label %28
28: ; preds = %23
%29 = getelementptr inbounds [512 x i8], [512 x i8]* %19, i64 0, i64 0
%30 = call i64 @strcmp(i8* %29, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%31 = icmp ne i64 %30, 0
br i1 %31, label %32, label %39
32: ; preds = %28
%33 = getelementptr inbounds [512 x i8], [512 x i8]* %19, i64 0, i64 0
%34 = call i64 @strcmp(i8* %33, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%35 = icmp ne i64 %34, 0
br i1 %35, label %36, label %39
36: ; preds = %32
%37 = load i32, i32* %5
%38 = call i64 @generic_get_cpu_clockrate(i32 %37)
store i64 %38, i64* %3
br label %155
39: ; preds = %32, %28, %23
store i32 5, i32* %18
br label %41
40: ; preds = %2
store i32 20, i32* %18
br label %41
41: ; preds = %40, %39
%42 = call i32 (...) @has_rdtsc()
%43 = icmp ne i32 %42, 0
br i1 %43, label %47, label %44
44: ; preds = %41
%45 = load i32, i32* %5
%46 = call i64 @generic_get_cpu_clockrate(i32 %45)
store i64 %46, i64* %3
br label %155
47: ; preds = %41
store i32 3, i32* %16
br label %48
48: ; preds = %151, %47
%49 = call i64 (...) @timestamp()
store i64 %49, i64* %6
%50 = call i32 @gettimeofday(%struct.timeval* %20, i32* null)
%51 = call i64 (...) @timestamp()
store i64 %51, i64* %7
%52 = getelementptr inbounds %struct.timeval, %struct.timeval* %20, i32 0, i32 0
%53 = load i32, i32* %52
%54 = mul nsw i32 %53, 1000000
%55 = getelementptr inbounds %struct.timeval, %struct.timeval* %20, i32 0, i32 1
%56 = load i32, i32* %55
%57 = add nsw i32 %54, %56
%58 = sext i32 %57 to i64
store i64 %58, i64* %10
br label %59
59: ; preds = %61, %48
%60 = call i64 (...) @timestamp()
store i64 %60, i64* %8
br label %61
61: ; preds = %59
%62 = load i64, i64* %8
%63 = load i64, i64* %7
%64 = load i32, i32* %16
%65 = mul nsw i32 1000000, %64
%66 = sext i32 %65 to i64
%67 = add i64 %63, %66
%68 = icmp ult i64 %62, %67
br i1 %68, label %59, label %69
69: ; preds = %61
%70 = call i64 (...) @timestamp()
store i64 %70, i64* %8
%71 = call i32 @gettimeofday(%struct.timeval* %20, i32* null)
%72 = call i64 (...) @timestamp()
store i64 %72, i64* %9
%73 = getelementptr inbounds %struct.timeval, %struct.timeval* %20, i32 0, i32 0
%74 = load i32, i32* %73
%75 = mul nsw i32 %74, 1000000
%76 = getelementptr inbounds %struct.timeval, %struct.timeval* %20, i32 0, i32 1
%77 = load i32, i32* %76
%78 = add nsw i32 %75, %77
%79 = sext i32 %78 to i64
store i64 %79, i64* %11
%80 = load i64, i64* %8
%81 = load i64, i64* %7
%82 = sub i64 %80, %81
%83 = mul i64 %82, 1000000
%84 = load i64, i64* %11
%85 = load i64, i64* %10
%86 = sub i64 %84, %85
%87 = udiv i64 %83, %86
store i64 %87, i64* %12
%88 = load i64, i64* %9
%89 = load i64, i64* %6
%90 = sub i64 %88, %89
%91 = mul i64 %90, 1000000
%92 = load i64, i64* %11
%93 = load i64, i64* %10
%94 = sub i64 %92, %93
%95 = udiv i64 %91, %94
store i64 %95, i64* %13
%96 = load i64, i64* %12
%97 = uitofp i64 %96 to double
%98 = load i64, i64* %13
%99 = uitofp i64 %98 to double
%100 = fmul double %99, 0x3FEFF7CED916872B
%101 = fcmp ogt double %97, %100
br i1 %101, label %102, label %139
102: ; preds = %69
%103 = load i64, i64* %11
%104 = load i64, i64* %10
%105 = sub i64 %103, %104
%106 = icmp ugt i64 %105, 2000
br i1 %106, label %107, label %139
107: ; preds = %102
%108 = load i32, i32* %17
%109 = add nsw i32 %108, 1
store i32 %109, i32* %17
%110 = load i64, i64* %12
%111 = load i64, i64* %13
%112 = add i64 %110, %111
%113 = udiv i64 %112, 2
store i64 %113, i64* %14
%114 = load i64, i64* %15
%115 = icmp eq i64 %114, 0
br i1 %115, label %116, label %118
116: ; preds = %107
%117 = load i64, i64* %14
store i64 %117, i64* %15
br label %138
118: ; preds = %107
%119 = load i32, i32* %4
%120 = icmp ne i32 %119, 0
br i1 %120, label %121, label %127
121: ; preds = %118
%122 = load i64, i64* %14
%123 = load i64, i64* %15
%124 = icmp ult i64 %122, %123
br i1 %124, label %125, label %127
125: ; preds = %121
%126 = load i64, i64* %14
store i64 %126, i64* %15
br label %137
127: ; preds = %121, %118
%128 = load i32, i32* %4
%129 = icmp ne i32 %128, 0
br i1 %129, label %136, label %130
130: ; preds = %127
%131 = load i64, i64* %14
%132 = load i64, i64* %15
%133 = icmp ugt i64 %131, %132
br i1 %133, label %134, label %136
134: ; preds = %130
%135 = load i64, i64* %14
store i64 %135, i64* %15
br label %136
136: ; preds = %134, %130, %127
br label %137
137: ; preds = %136, %125
br label %138
138: ; preds = %137, %116
br label %139
139: ; preds = %138, %102, %69
%140 = load i32, i32* %16
%141 = add nsw i32 %140, 2
store i32 %141, i32* %16
br label %142
142: ; preds = %139
%143 = load i64, i64* %11
%144 = load i64, i64* %10
%145 = sub i64 %143, %144
%146 = icmp ult i64 %145, 10000
br i1 %146, label %151, label %147
147: ; preds = %142
%148 = load i32, i32* %17
%149 = load i32, i32* %18
%150 = icmp slt i32 %148, %149
br label %151
151: ; preds = %147, %142
%152 = phi i1 [ true, %142 ], [ %150, %147 ]
br i1 %152, label %48, label %153
153: ; preds = %151
%154 = load i64, i64* %15
store i64 %154, i64* %3
br label %155
155: ; preds = %153, %44, %36
%156 = load i64, i64* %3
ret i64 %156
}

LLVM IR (-O2):
%struct.timeval = type { i32, i32 }
@.str = [12 x i8] c"performance\00"
@.str.1 = [10 x i8] c"powersave\00"
define i64 @get_cpu_clockrate(i32 %0, i32 %1) {
%3 = alloca [512 x i8]
%4 = alloca %struct.timeval
%5 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%6 = bitcast %struct.timeval* %4 to i8*
%7 = icmp eq i32 %0, 0
br i1 %7, label %18, label %8
8: ; preds = %2
%9 = call i32 @scaling_governor(i32 -1, i8* %5, i32 512)
%10 = call i32 (...) @has_invariant_rdtsc()
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %18
12: ; preds = %8
%13 = call i64 @strcmp(i8* %5, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%14 = icmp eq i64 %13, 0
br i1 %14, label %18, label %15
15: ; preds = %12
%16 = call i64 @strcmp(i8* %5, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %85
18: ; preds = %2, %8, %12, %15
%19 = phi i32 [ 5, %15 ], [ 5, %12 ], [ 5, %8 ], [ 20, %2 ]
%20 = call i32 (...) @has_rdtsc()
%21 = icmp eq i32 %20, 0
br i1 %21, label %85, label %22
22: ; preds = %18
%23 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i64 0, i32 0
%24 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i64 0, i32 1
%25 = xor i1 %7, true
br label %26
26: ; preds = %22, %78
%27 = phi i64 [ 3, %22 ], [ %81, %78 ]
%28 = phi i64 [ 0, %22 ], [ %79, %78 ]
%29 = phi i32 [ 0, %22 ], [ %80, %78 ]
%30 = call i64 (...) @timestamp()
%31 = call i32 @gettimeofday(%struct.timeval* %4, i32* null)
%32 = call i64 (...) @timestamp()
%33 = load i32, i32* %23
%34 = mul nsw i32 %33, 1000000
%35 = load i32, i32* %24
%36 = add nsw i32 %34, %35
%37 = mul i64 %27, 1000000
%38 = and i64 %37, 4294967232
%39 = add i64 %32, %38
br label %40
40: ; preds = %40, %26
%41 = call i64 (...) @timestamp()
%42 = icmp ult i64 %41, %39
br i1 %42, label %40, label %43
43: ; preds = %40
%44 = sext i32 %36 to i64
%45 = call i64 (...) @timestamp()
%46 = call i32 @gettimeofday(%struct.timeval* %4, i32* null)
%47 = call i64 (...) @timestamp()
%48 = load i32, i32* %23
%49 = mul nsw i32 %48, 1000000
%50 = load i32, i32* %24
%51 = add nsw i32 %49, %50
%52 = sext i32 %51 to i64
%53 = sub i64 %45, %32
%54 = mul i64 %53, 1000000
%55 = sub nsw i64 %52, %44
%56 = udiv i64 %54, %55
%57 = sub i64 %47, %30
%58 = mul i64 %57, 1000000
%59 = udiv i64 %58, %55
%60 = uitofp i64 %56 to double
%61 = uitofp i64 %59 to double
%62 = fmul double %61, 0x3FEFF7CED916872B
%63 = fcmp olt double %62, %60
%64 = icmp ugt i64 %55, 2000
%65 = select i1 %63, i1 %64, i1 false
br i1 %65, label %66, label %78
66: ; preds = %43
%67 = add nsw i32 %29, 1
%68 = add i64 %59, %56
%69 = lshr i64 %68, 1
%70 = icmp eq i64 %28, 0
br i1 %70, label %78, label %71
71: ; preds = %66
%72 = icmp ult i64 %69, %28
%73 = select i1 %25, i1 %72, i1 false
%74 = select i1 %73, i64 %69, i64 %28
br i1 %7, label %75, label %78
75: ; preds = %71
%76 = icmp ugt i64 %69, %28
%77 = select i1 %76, i64 %69, i64 %28
br label %78
78: ; preds = %75, %71, %66, %43
%79 = phi i64 [ %28, %43 ], [ %69, %66 ], [ %74, %71 ], [ %77, %75 ]
%80 = phi i32 [ %29, %43 ], [ %67, %66 ], [ %67, %71 ], [ %67, %75 ]
%81 = add nuw i64 %27, 2
%82 = icmp ult i64 %55, 10000
%83 = icmp slt i32 %80, %19
%84 = select i1 %82, i1 true, i1 %83
br i1 %84, label %26, label %87
85: ; preds = %18, %15
%86 = call i64 @generic_get_cpu_clockrate(i32 %1)
br label %87
87: ; preds = %78, %85
%88 = phi i64 [ %86, %85 ], [ %79, %78 ]
ret i64 %88
}