#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 */
double atof(char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ system(char *);
double cpufreq_info() {
  system("cat /proc/cpuinfo |grep MHz|sed 's/cpu\\sMHz\\s*:\\s//'|tail -n 1 > "
         "/tmp/cpufreq.txt");
  FILE *tmp_file;
  tmp_file = fopen("/tmp/cpufreq.txt", "r");
  char tmp_str[30];
  fgets(tmp_str, 30, tmp_file);
  fclose(tmp_file);
  return atof(tmp_str);
}


x86 assembly (clang, -O0):
<cpufreq_info>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
lea    0xea1(%rip),%rdi
call   1050 <system@plt>
lea    0xed6(%rip),%rdi
lea    0xee0(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x8(%rbp)
lea    -0x30(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    $0x1e,%esi
call   1060 <fgets@plt>
mov    -0x8(%rbp),%rdi
call   1040 <fclose@plt>
lea    -0x30(%rbp),%rdi
call   1030 <atof@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cpufreq_info>:
push   %r14
push   %rbx
sub    $0x28,%rsp
lea    0xea2(%rip),%rdi
call   1050 <system@plt>
lea    0xed7(%rip),%rdi
lea    0xee1(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%rbx
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0x1e,%esi
mov    %rax,%rdx
call   1060 <fgets@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    %r14,%rdi
call   1030 <atof@plt>
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [82 x i8] c"cat /proc/cpuinfo |grep MHz|sed 's/cpu\\sMHz\\s*:\\s//'|tail -n 1 > /tmp/cpufreq.txt\00"
@.str.1 = [17 x i8] c"/tmp/cpufreq.txt\00"
@.str.2 = [2 x i8] c"r\00"
define double @cpufreq_info() {
%1 = alloca i32*
%2 = alloca [30 x i8]
%3 = call i32 @system(i8* getelementptr inbounds ([82 x i8], [82 x i8]* @.str, i64 0, i64 0))
%4 = call i32* @fopen(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %4, i32** %1
%5 = getelementptr inbounds [30 x i8], [30 x i8]* %2, i64 0, i64 0
%6 = load i32*, i32** %1
%7 = call i32 @fgets(i8* %5, i32 30, i32* %6)
%8 = load i32*, i32** %1
%9 = call i32 @fclose(i32* %8)
%10 = getelementptr inbounds [30 x i8], [30 x i8]* %2, i64 0, i64 0
%11 = call double @atof(i8* %10)
ret double %11
}

LLVM IR (-O2):
@.str = [82 x i8] c"cat /proc/cpuinfo |grep MHz|sed 's/cpu\\sMHz\\s*:\\s//'|tail -n 1 > /tmp/cpufreq.txt\00"
@.str.1 = [17 x i8] c"/tmp/cpufreq.txt\00"
@.str.2 = [2 x i8] c"r\00"
define double @cpufreq_info() {
%1 = alloca [30 x i8]
%2 = tail call i32 @system(i8* getelementptr inbounds ([82 x i8], [82 x i8]* @.str, i64 0, i64 0))
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%4 = getelementptr inbounds [30 x i8], [30 x i8]* %1, i64 0, i64 0
%5 = call i32 @fgets(i8* %4, i32 30, i32* %3)
%6 = call i32 @fclose(i32* %3)
%7 = call double @atof(i8* %4)
ret double %7
}