#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 */

/* Variables and functions */
int get_cpufreq_base_freq(int);
int parse_int_file(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ set_cpufreq_scaling_min_max(int, int /*<<< orphan*/, int);
void adjust_scaling_min_from_base_freq(int cpu) {
  int base_freq, scaling_min_freq;
  scaling_min_freq = parse_int_file(
      0, "/sys/devices/system/cpu/cpu%d/cpufreq/scaling_min_freq", cpu);
  base_freq = get_cpufreq_base_freq(cpu);
  if (scaling_min_freq < base_freq)
    set_cpufreq_scaling_min_max(cpu, 0, base_freq);
}


x86 assembly (clang, -O0):
<adjust_scaling_min_from_base_freq>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edx
xor    %edi,%edi
lea    0xeb9(%rip),%rsi
call   1030 <parse_int_file@plt>
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%edi
call   1040 <get_cpufreq_base_freq@plt>
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1173 <adjust_scaling_min_from_base_freq+0x43>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%edx
xor    %esi,%esi
call   1050 <set_cpufreq_scaling_min_max@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<adjust_scaling_min_from_base_freq>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebx
lea    0xec4(%rip),%rsi
xor    %edi,%edi
mov    %ebx,%edx
call   1030 <parse_int_file@plt>
mov    %eax,%ebp
mov    %ebx,%edi
call   1040 <get_cpufreq_base_freq@plt>
cmp    %eax,%ebp
jge    1163 <adjust_scaling_min_from_base_freq+0x33>
mov    %ebx,%edi
xor    %esi,%esi
mov    %eax,%edx
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1050 <set_cpufreq_scaling_min_max@plt>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [55 x i8] c"/sys/devices/system/cpu/cpu%d/cpufreq/scaling_min_freq\00"
define void @adjust_scaling_min_from_base_freq(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %2
%5 = load i32, i32* %2
%6 = call i32 @parse_int_file(i32 0, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str, i64 0, i64 0), i32 %5)
store i32 %6, i32* %4
%7 = load i32, i32* %2
%8 = call i32 @get_cpufreq_base_freq(i32 %7)
store i32 %8, i32* %3
%9 = load i32, i32* %4
%10 = load i32, i32* %3
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %16
12: ; preds = %1
%13 = load i32, i32* %2
%14 = load i32, i32* %3
%15 = call i32 @set_cpufreq_scaling_min_max(i32 %13, i32 0, i32 %14)
br label %16
16: ; preds = %12, %1
ret void
}

LLVM IR (-O2):
@.str = [55 x i8] c"/sys/devices/system/cpu/cpu%d/cpufreq/scaling_min_freq\00"
define void @adjust_scaling_min_from_base_freq(i32 %0) {
%2 = tail call i32 @parse_int_file(i32 0, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str, i64 0, i64 0), i32 %0)
%3 = tail call i32 @get_cpufreq_base_freq(i32 %0)
%4 = icmp slt i32 %2, %3
br i1 %4, label %5, label %7
5: ; preds = %1
%6 = tail call i32 @set_cpufreq_scaling_min_max(i32 %0, i32 0, i32 %3)
br label %7
7: ; preds = %5, %1
ret void
}