#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 */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int fscanf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ pclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *popen(char *, char *);
double osfreq(void) {
  FILE *f;
  double result;
  int s;
  f = fopen("/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq", "r");
  if (f) {
    s = fscanf(f, "%lf", &result);
    fclose(f);
    if (s > 0)
      return 1000.0 * result;
  }
  f = fopen("/sys/devices/system/cpu/cpu0/clock_tick", "r");
  if (f) {
    s = fscanf(f, "%lf", &result);
    fclose(f);
    if (s > 0)
      return result;
  }
  f = fopen("/proc/cpuinfo", "r");
  if (f) {
    for (;;) {
      s = fscanf(f, "cpu MHz : %lf", &result);
      if (s > 0)
        break;
      if (s == 0)
        s = fscanf(f, "%*[^\n]\n");
      if (s < 0) {
        result = 0;
        break;
      }
    }
    fclose(f);
    if (result)
      return 1000000.0 * result;
  }
  f = fopen("/proc/cpuinfo", "r");
  if (f) {
    for (;;) {
      s = fscanf(f, "clock : %lf", &result);
      if (s > 0)
        break;
      if (s == 0)
        s = fscanf(f, "%*[^\n]\n");
      if (s < 0) {
        result = 0;
        break;
      }
    }
    fclose(f);
    if (result)
      return 1000000.0 * result;
  }
  f = popen("/usr/sbin/lsattr -E -l proc0 -a frequency 2>/dev/null", "r");
  if (f) {
    s = fscanf(f, "frequency %lf", &result);
    pclose(f);
    if (s > 0)
      return result;
  }
  f = popen("/usr/sbin/psrinfo -v 2>/dev/null", "r");
  if (f) {
    for (;;) {
      s = fscanf(f, " The %*s processor operates at %lf MHz", &result);
      if (s > 0)
        break;
      if (s == 0)
        s = fscanf(f, "%*[^\n]\n");
      if (s < 0) {
        result = 0;
        break;
      }
    }
    pclose(f);
    if (result)
      return 1000000.0 * result;
  }
  return 0;
}


x86 assembly (clang, -O0):
<osfreq>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xeb1(%rip),%rdi
lea    0xee0(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11c2 <osfreq+0x72>
mov    -0x10(%rbp),%rdi
lea    0xf17(%rip),%rsi
lea    -0x18(%rbp),%rdx
mov    $0x0,%al
call   1050 <fscanf@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
cmpl   $0x0,-0x1c(%rbp)
jle    11bd <osfreq+0x6d>
movsd  0xe5a(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    14f2 <osfreq+0x3a2>
jmp    11c2 <osfreq+0x72>
lea    0xe7f(%rip),%rdi
lea    0xe76(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1224 <osfreq+0xd4>
mov    -0x10(%rbp),%rdi
lea    0xead(%rip),%rsi
lea    -0x18(%rbp),%rdx
mov    $0x0,%al
call   1050 <fscanf@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
cmpl   $0x0,-0x1c(%rbp)
jle    121f <osfreq+0xcf>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    14f2 <osfreq+0x3a2>
jmp    1224 <osfreq+0xd4>
lea    0xe45(%rip),%rdi
lea    0xe14(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     12f0 <osfreq+0x1a0>
jmp    124b <osfreq+0xfb>
mov    -0x10(%rbp),%rdi
lea    0xe28(%rip),%rsi
lea    -0x18(%rbp),%rdx
mov    $0x0,%al
call   1050 <fscanf@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jle    1273 <osfreq+0x123>
jmp    12ae <osfreq+0x15e>
cmpl   $0x0,-0x1c(%rbp)
jne    1292 <osfreq+0x142>
mov    -0x10(%rbp),%rdi
lea    0xe04(%rip),%rsi
mov    $0x0,%al
call   1050 <fscanf@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    12a9 <osfreq+0x159>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    12ae <osfreq+0x15e>
jmp    124b <osfreq+0xfb>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
movsd  -0x18(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    12d4 <osfreq+0x184>
jp     12d4 <osfreq+0x184>
jmp    12eb <osfreq+0x19b>
movsd  0xd24(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    14f2 <osfreq+0x3a2>
jmp    12f0 <osfreq+0x1a0>
lea    0xd79(%rip),%rdi
lea    0xd48(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     13bc <osfreq+0x26c>
jmp    1317 <osfreq+0x1c7>
mov    -0x10(%rbp),%rdi
lea    0xd72(%rip),%rsi
lea    -0x18(%rbp),%rdx
mov    $0x0,%al
call   1050 <fscanf@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jle    133f <osfreq+0x1ef>
jmp    137a <osfreq+0x22a>
cmpl   $0x0,-0x1c(%rbp)
jne    135e <osfreq+0x20e>
mov    -0x10(%rbp),%rdi
lea    0xd38(%rip),%rsi
mov    $0x0,%al
call   1050 <fscanf@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    1375 <osfreq+0x225>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    137a <osfreq+0x22a>
jmp    1317 <osfreq+0x1c7>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
movsd  -0x18(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    13a0 <osfreq+0x250>
jp     13a0 <osfreq+0x250>
jmp    13b7 <osfreq+0x267>
movsd  0xc58(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    14f2 <osfreq+0x3a2>
jmp    13bc <osfreq+0x26c>
lea    0xcdd(%rip),%rdi
lea    0xc7c(%rip),%rsi
call   1060 <popen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     141e <osfreq+0x2ce>
mov    -0x10(%rbp),%rdi
lea    0xced(%rip),%rsi
lea    -0x18(%rbp),%rdx
mov    $0x0,%al
call   1050 <fscanf@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <pclose@plt>
cmpl   $0x0,-0x1c(%rbp)
jle    1419 <osfreq+0x2c9>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    14f2 <osfreq+0x3a2>
jmp    141e <osfreq+0x2ce>
lea    0xcbf(%rip),%rdi
lea    0xc1a(%rip),%rsi
call   1060 <popen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     14ea <osfreq+0x39a>
jmp    1445 <osfreq+0x2f5>
mov    -0x10(%rbp),%rdi
lea    0xcb5(%rip),%rsi
lea    -0x18(%rbp),%rdx
mov    $0x0,%al
call   1050 <fscanf@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jle    146d <osfreq+0x31d>
jmp    14a8 <osfreq+0x358>
cmpl   $0x0,-0x1c(%rbp)
jne    148c <osfreq+0x33c>
mov    -0x10(%rbp),%rdi
lea    0xc0a(%rip),%rsi
mov    $0x0,%al
call   1050 <fscanf@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    14a3 <osfreq+0x353>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    14a8 <osfreq+0x358>
jmp    1445 <osfreq+0x2f5>
mov    -0x10(%rbp),%rdi
call   1040 <pclose@plt>
movsd  -0x18(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    14ce <osfreq+0x37e>
jp     14ce <osfreq+0x37e>
jmp    14e5 <osfreq+0x395>
movsd  0xb2a(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    14f2 <osfreq+0x3a2>
jmp    14ea <osfreq+0x39a>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<osfreq>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xead(%rip),%rdi
lea    0xedc(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     11ae <osfreq+0x5e>
mov    %rax,%rbx
lea    0xf1e(%rip),%rsi
lea    0x8(%rsp),%rdx
mov    %rax,%rdi
xor    %eax,%eax
call   1050 <fscanf@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1030 <fclose@plt>
test   %ebp,%ebp
jle    11ae <osfreq+0x5e>
movsd  0x8(%rsp),%xmm0
mulsd  0xe57(%rip),%xmm0
jmp    1302 <osfreq+0x1b2>
lea    0xe93(%rip),%rdi
lea    0xe8a(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     11f8 <osfreq+0xa8>
mov    %rax,%rbx
lea    0xecc(%rip),%rsi
lea    0x8(%rsp),%rdx
mov    %rax,%rdi
xor    %eax,%eax
call   1050 <fscanf@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1030 <fclose@plt>
test   %ebp,%ebp
jle    11f8 <osfreq+0xa8>
movsd  0x8(%rsp),%xmm0
jmp    1302 <osfreq+0x1b2>
lea    0xe71(%rip),%rdi
lea    0xe40(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     1282 <osfreq+0x132>
mov    %rax,%rbx
lea    0xe64(%rip),%r14
lea    0x8(%rsp),%r15
lea    0xe66(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   1050 <fscanf@plt>
test   %eax,%eax
jg     1260 <osfreq+0x110>
jne    1257 <osfreq+0x107>
mov    %rbx,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1050 <fscanf@plt>
test   %eax,%eax
jns    1230 <osfreq+0xe0>
movq   $0x0,0x8(%rsp)
mov    %rbx,%rdi
call   1030 <fclose@plt>
movsd  0x8(%rsp),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    12fa <osfreq+0x1aa>
jp     12fa <osfreq+0x1aa>
lea    0xde7(%rip),%rdi
lea    0xdb6(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     130f <osfreq+0x1bf>
mov    %rax,%rbx
lea    0xdf0(%rip),%r14
lea    0x8(%rsp),%r15
lea    0xddc(%rip),%r12
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   1050 <fscanf@plt>
test   %eax,%eax
jg     12e0 <osfreq+0x190>
jne    12d7 <osfreq+0x187>
mov    %rbx,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1050 <fscanf@plt>
test   %eax,%eax
jns    12b0 <osfreq+0x160>
movq   $0x0,0x8(%rsp)
mov    %rbx,%rdi
call   1030 <fclose@plt>
movsd  0x8(%rsp),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    12fa <osfreq+0x1aa>
jnp    130f <osfreq+0x1bf>
mulsd  0xd06(%rip),%xmm0
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd8a(%rip),%rdi
lea    0xd29(%rip),%rsi
call   1060 <popen@plt>
test   %rax,%rax
je     1352 <osfreq+0x202>
mov    %rax,%rbx
lea    0xda5(%rip),%rsi
lea    0x8(%rsp),%rdx
mov    %rax,%rdi
xor    %eax,%eax
call   1050 <fscanf@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1040 <pclose@plt>
test   %ebp,%ebp
jg     11ed <osfreq+0x9d>
lea    0xd8b(%rip),%rdi
lea    0xce6(%rip),%rsi
call   1060 <popen@plt>
test   %rax,%rax
je     13df <osfreq+0x28f>
mov    %rax,%rbx
lea    0xd91(%rip),%r14
lea    0x8(%rsp),%r15
lea    0xd0c(%rip),%r12
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   1050 <fscanf@plt>
test   %eax,%eax
jg     13b0 <osfreq+0x260>
jne    13a7 <osfreq+0x257>
mov    %rbx,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1050 <fscanf@plt>
test   %eax,%eax
jns    1380 <osfreq+0x230>
movq   $0x0,0x8(%rsp)
mov    %rbx,%rdi
call   1040 <pclose@plt>
movsd  0x8(%rsp),%xmm1
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm1
jne    13ce <osfreq+0x27e>
jnp    1302 <osfreq+0x1b2>
mulsd  0xc32(%rip),%xmm1
movapd %xmm1,%xmm0
jmp    1302 <osfreq+0x1b2>
xorpd  %xmm0,%xmm0
jmp    1302 <osfreq+0x1b2>

LLVM IR (-O0):
@.str = [54 x i8] c"/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [4 x i8] c"%lf\00"
@.str.3 = [40 x i8] c"/sys/devices/system/cpu/cpu0/clock_tick\00"
@.str.4 = [14 x i8] c"/proc/cpuinfo\00"
@.str.5 = [14 x i8] c"cpu MHz : %lf\00"
@.str.6 = [8 x i8] c"%*[^\0A]\0A\00"
@.str.7 = [12 x i8] c"clock : %lf\00"
@.str.8 = [54 x i8] c"/usr/sbin/lsattr -E -l proc0 -a frequency 2>/dev/null\00"
@.str.9 = [14 x i8] c"frequency %lf\00"
@.str.10 = [33 x i8] c"/usr/sbin/psrinfo -v 2>/dev/null\00"
@.str.11 = [39 x i8] c" The %*s processor operates at %lf MHz\00"
define double @osfreq() {
%1 = alloca double
%2 = alloca i32*
%3 = alloca double
%4 = alloca i32
%5 = call i32* @fopen(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %5, i32** %2
%6 = load i32*, i32** %2
%7 = icmp ne i32* %6, null
br i1 %7, label %8, label %19
8: ; preds = %0
%9 = load i32*, i32** %2
%10 = call i32 (i32*, i8*, ...) @fscanf(i32* %9, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %3)
store i32 %10, i32* %4
%11 = load i32*, i32** %2
%12 = call i32 @fclose(i32* %11)
%13 = load i32, i32* %4
%14 = icmp sgt i32 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %8
%16 = load double, double* %3
%17 = fmul double 1.000000e+03, %16
store double %17, double* %1
br label %141
18: ; preds = %8
br label %19
19: ; preds = %18, %0
%20 = call i32* @fopen(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %20, i32** %2
%21 = load i32*, i32** %2
%22 = icmp ne i32* %21, null
br i1 %22, label %23, label %33
23: ; preds = %19
%24 = load i32*, i32** %2
%25 = call i32 (i32*, i8*, ...) @fscanf(i32* %24, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %3)
store i32 %25, i32* %4
%26 = load i32*, i32** %2
%27 = call i32 @fclose(i32* %26)
%28 = load i32, i32* %4
%29 = icmp sgt i32 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %23
%31 = load double, double* %3
store double %31, double* %1
br label %141
32: ; preds = %23
br label %33
33: ; preds = %32, %19
%34 = call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %34, i32** %2
%35 = load i32*, i32** %2
%36 = icmp ne i32* %35, null
br i1 %36, label %37, label %64
37: ; preds = %33
br label %38
38: ; preds = %54, %37
%39 = load i32*, i32** %2
%40 = call i32 (i32*, i8*, ...) @fscanf(i32* %39, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), double* %3)
store i32 %40, i32* %4
%41 = load i32, i32* %4
%42 = icmp sgt i32 %41, 0
br i1 %42, label %43, label %44
43: ; preds = %38
br label %55
44: ; preds = %38
%45 = load i32, i32* %4
%46 = icmp eq i32 %45, 0
br i1 %46, label %47, label %50
47: ; preds = %44
%48 = load i32*, i32** %2
%49 = call i32 (i32*, i8*, ...) @fscanf(i32* %48, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0))
store i32 %49, i32* %4
br label %50
50: ; preds = %47, %44
%51 = load i32, i32* %4
%52 = icmp slt i32 %51, 0
br i1 %52, label %53, label %54
53: ; preds = %50
store double 0.000000e+00, double* %3
br label %55
54: ; preds = %50
br label %38
55: ; preds = %53, %43
%56 = load i32*, i32** %2
%57 = call i32 @fclose(i32* %56)
%58 = load double, double* %3
%59 = fcmp une double %58, 0.000000e+00
br i1 %59, label %60, label %63
60: ; preds = %55
%61 = load double, double* %3
%62 = fmul double 1.000000e+06, %61
store double %62, double* %1
br label %141
63: ; preds = %55
br label %64
64: ; preds = %63, %33
%65 = call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %65, i32** %2
%66 = load i32*, i32** %2
%67 = icmp ne i32* %66, null
br i1 %67, label %68, label %95
68: ; preds = %64
br label %69
69: ; preds = %85, %68
%70 = load i32*, i32** %2
%71 = call i32 (i32*, i8*, ...) @fscanf(i32* %70, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0), double* %3)
store i32 %71, i32* %4
%72 = load i32, i32* %4
%73 = icmp sgt i32 %72, 0
br i1 %73, label %74, label %75
74: ; preds = %69
br label %86
75: ; preds = %69
%76 = load i32, i32* %4
%77 = icmp eq i32 %76, 0
br i1 %77, label %78, label %81
78: ; preds = %75
%79 = load i32*, i32** %2
%80 = call i32 (i32*, i8*, ...) @fscanf(i32* %79, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0))
store i32 %80, i32* %4
br label %81
81: ; preds = %78, %75
%82 = load i32, i32* %4
%83 = icmp slt i32 %82, 0
br i1 %83, label %84, label %85
84: ; preds = %81
store double 0.000000e+00, double* %3
br label %86
85: ; preds = %81
br label %69
86: ; preds = %84, %74
%87 = load i32*, i32** %2
%88 = call i32 @fclose(i32* %87)
%89 = load double, double* %3
%90 = fcmp une double %89, 0.000000e+00
br i1 %90, label %91, label %94
91: ; preds = %86
%92 = load double, double* %3
%93 = fmul double 1.000000e+06, %92
store double %93, double* %1
br label %141
94: ; preds = %86
br label %95
95: ; preds = %94, %64
%96 = call i32* @popen(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %96, i32** %2
%97 = load i32*, i32** %2
%98 = icmp ne i32* %97, null
br i1 %98, label %99, label %109
99: ; preds = %95
%100 = load i32*, i32** %2
%101 = call i32 (i32*, i8*, ...) @fscanf(i32* %100, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.9, i64 0, i64 0), double* %3)
store i32 %101, i32* %4
%102 = load i32*, i32** %2
%103 = call i32 @pclose(i32* %102)
%104 = load i32, i32* %4
%105 = icmp sgt i32 %104, 0
br i1 %105, label %106, label %108
106: ; preds = %99
%107 = load double, double* %3
store double %107, double* %1
br label %141
108: ; preds = %99
br label %109
109: ; preds = %108, %95
%110 = call i32* @popen(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %110, i32** %2
%111 = load i32*, i32** %2
%112 = icmp ne i32* %111, null
br i1 %112, label %113, label %140
113: ; preds = %109
br label %114
114: ; preds = %130, %113
%115 = load i32*, i32** %2
%116 = call i32 (i32*, i8*, ...) @fscanf(i32* %115, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.11, i64 0, i64 0), double* %3)
store i32 %116, i32* %4
%117 = load i32, i32* %4
%118 = icmp sgt i32 %117, 0
br i1 %118, label %119, label %120
119: ; preds = %114
br label %131
120: ; preds = %114
%121 = load i32, i32* %4
%122 = icmp eq i32 %121, 0
br i1 %122, label %123, label %126
123: ; preds = %120
%124 = load i32*, i32** %2
%125 = call i32 (i32*, i8*, ...) @fscanf(i32* %124, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0))
store i32 %125, i32* %4
br label %126
126: ; preds = %123, %120
%127 = load i32, i32* %4
%128 = icmp slt i32 %127, 0
br i1 %128, label %129, label %130
129: ; preds = %126
store double 0.000000e+00, double* %3
br label %131
130: ; preds = %126
br label %114
131: ; preds = %129, %119
%132 = load i32*, i32** %2
%133 = call i32 @pclose(i32* %132)
%134 = load double, double* %3
%135 = fcmp une double %134, 0.000000e+00
br i1 %135, label %136, label %139
136: ; preds = %131
%137 = load double, double* %3
%138 = fmul double 1.000000e+06, %137
store double %138, double* %1
br label %141
139: ; preds = %131
br label %140
140: ; preds = %139, %109
store double 0.000000e+00, double* %1
br label %141
141: ; preds = %140, %136, %106, %91, %60, %30, %15
%142 = load double, double* %1
ret double %142
}

LLVM IR (-O2):
@.str = [54 x i8] c"/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [4 x i8] c"%lf\00"
@.str.3 = [40 x i8] c"/sys/devices/system/cpu/cpu0/clock_tick\00"
@.str.4 = [14 x i8] c"/proc/cpuinfo\00"
@.str.5 = [14 x i8] c"cpu MHz : %lf\00"
@.str.6 = [8 x i8] c"%*[^\0A]\0A\00"
@.str.7 = [12 x i8] c"clock : %lf\00"
@.str.8 = [54 x i8] c"/usr/sbin/lsattr -E -l proc0 -a frequency 2>/dev/null\00"
@.str.9 = [14 x i8] c"frequency %lf\00"
@.str.10 = [33 x i8] c"/usr/sbin/psrinfo -v 2>/dev/null\00"
@.str.11 = [39 x i8] c" The %*s processor operates at %lf MHz\00"
define double @osfreq() {
%1 = alloca double
%2 = bitcast double* %1 to i8*
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %12, label %5
5: ; preds = %0
%6 = call i32 (i32*, i8*, ...) @fscanf(i32* %3, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %1)
%7 = call i32 @fclose(i32* %3)
%8 = icmp sgt i32 %6, 0
br i1 %8, label %9, label %12
9: ; preds = %5
%10 = load double, double* %1
%11 = fmul double %10, 1.000000e+03
br label %84
12: ; preds = %5, %0
%13 = call i32* @fopen(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%14 = icmp eq i32* %13, null
br i1 %14, label %21, label %15
15: ; preds = %12
%16 = call i32 (i32*, i8*, ...) @fscanf(i32* %13, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %1)
%17 = call i32 @fclose(i32* %13)
%18 = icmp sgt i32 %16, 0
br i1 %18, label %19, label %21
19: ; preds = %15
%20 = load double, double* %1
br label %84
21: ; preds = %15, %12
%22 = call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%23 = icmp eq i32* %22, null
br i1 %23, label %39, label %24
24: ; preds = %21, %29
%25 = call i32 (i32*, i8*, ...) @fscanf(i32* %22, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), double* %1)
%26 = icmp sgt i32 %25, 0
br i1 %26, label %33, label %27
27: ; preds = %24
%28 = icmp eq i32 %25, 0
br i1 %28, label %29, label %32
29: ; preds = %27
%30 = call i32 (i32*, i8*, ...) @fscanf(i32* %22, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0))
%31 = icmp slt i32 %30, 0
br i1 %31, label %32, label %24
32: ; preds = %27, %29
store double 0.000000e+00, double* %1
br label %33
33: ; preds = %24, %32
%34 = call i32 @fclose(i32* %22)
%35 = load double, double* %1
%36 = fcmp une double %35, 0.000000e+00
br i1 %36, label %37, label %39
37: ; preds = %33
%38 = fmul double %35, 1.000000e+06
br label %84
39: ; preds = %33, %21
%40 = call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%41 = icmp eq i32* %40, null
br i1 %41, label %57, label %42
42: ; preds = %39, %47
%43 = call i32 (i32*, i8*, ...) @fscanf(i32* %40, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0), double* %1)
%44 = icmp sgt i32 %43, 0
br i1 %44, label %51, label %45
45: ; preds = %42
%46 = icmp eq i32 %43, 0
br i1 %46, label %47, label %50
47: ; preds = %45
%48 = call i32 (i32*, i8*, ...) @fscanf(i32* %40, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0))
%49 = icmp slt i32 %48, 0
br i1 %49, label %50, label %42
50: ; preds = %45, %47
store double 0.000000e+00, double* %1
br label %51
51: ; preds = %42, %50
%52 = call i32 @fclose(i32* %40)
%53 = load double, double* %1
%54 = fcmp une double %53, 0.000000e+00
br i1 %54, label %55, label %57
55: ; preds = %51
%56 = fmul double %53, 1.000000e+06
br label %84
57: ; preds = %51, %39
%58 = call i32* @popen(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%59 = icmp eq i32* %58, null
br i1 %59, label %66, label %60
60: ; preds = %57
%61 = call i32 (i32*, i8*, ...) @fscanf(i32* %58, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.9, i64 0, i64 0), double* %1)
%62 = call i32 @pclose(i32* %58)
%63 = icmp sgt i32 %61, 0
br i1 %63, label %64, label %66
64: ; preds = %60
%65 = load double, double* %1
br label %84
66: ; preds = %60, %57
%67 = call i32* @popen(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%68 = icmp eq i32* %67, null
br i1 %68, label %84, label %69
69: ; preds = %66, %74
%70 = call i32 (i32*, i8*, ...) @fscanf(i32* %67, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.11, i64 0, i64 0), double* %1)
%71 = icmp sgt i32 %70, 0
br i1 %71, label %78, label %72
72: ; preds = %69
%73 = icmp eq i32 %70, 0
br i1 %73, label %74, label %77
74: ; preds = %72
%75 = call i32 (i32*, i8*, ...) @fscanf(i32* %67, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0))
%76 = icmp slt i32 %75, 0
br i1 %76, label %77, label %69
77: ; preds = %72, %74
store double 0.000000e+00, double* %1
br label %78
78: ; preds = %69, %77
%79 = call i32 @pclose(i32* %67)
%80 = load double, double* %1
%81 = fcmp une double %80, 0.000000e+00
br i1 %81, label %82, label %84
82: ; preds = %78
%83 = fmul double %80, 1.000000e+06
br label %84
84: ; preds = %66, %78, %82, %64, %55, %37, %19, %9
%85 = phi double [ %11, %9 ], [ %20, %19 ], [ %38, %37 ], [ %56, %55 ], [ %65, %64 ], [ %83, %82 ], [ 0.000000e+00, %78 ], [ 0.000000e+00, %66 ]
ret double %85
}