#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_physical_die_id(int);
int get_physical_package_id(int);
int get_topo_max_cpus();
int /*<<< orphan*/ set_cpufreq_scaling_min_max_from_cpuinfo(int,
                                                            int /*<<< orphan*/,
                                                            int /*<<< orphan*/);
void set_scaling_min_to_cpuinfo_min(int cpu) {
  int i, pkg_id, die_id;
  pkg_id = get_physical_package_id(cpu);
  die_id = get_physical_die_id(cpu);
  for (i = 0; i < get_topo_max_cpus(); ++i) {
    if (pkg_id != get_physical_package_id(i) ||
        die_id != get_physical_die_id(i))
      continue;
    set_cpufreq_scaling_min_max_from_cpuinfo(i, 0, 0);
  }
}


x86 assembly (clang, -O0):
<set_scaling_min_to_cpuinfo_min>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
call   1030 <get_physical_package_id@plt>
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%edi
call   1050 <get_physical_die_id@plt>
mov    %eax,-0x10(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    $0x0,%al
call   1060 <get_topo_max_cpus@plt>
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
cmp    %ecx,%eax
jge    11d7 <set_scaling_min_to_cpuinfo_min+0x97>
mov    -0xc(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%edi
call   1030 <get_physical_package_id@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
cmp    %ecx,%eax
jne    11b8 <set_scaling_min_to_cpuinfo_min+0x78>
mov    -0x10(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%edi
call   1050 <get_physical_die_id@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
cmp    %ecx,%eax
je     11bd <set_scaling_min_to_cpuinfo_min+0x7d>
jmp    11c9 <set_scaling_min_to_cpuinfo_min+0x89>
mov    -0x8(%rbp),%edi
xor    %edx,%edx
mov    %edx,%esi
call   1040 <set_cpufreq_scaling_min_max_from_cpuinfo@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1168 <set_scaling_min_to_cpuinfo_min+0x28>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_scaling_min_to_cpuinfo_min>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%ebp
call   1030 <get_physical_package_id@plt>
mov    %eax,%ebx
mov    %ebp,%edi
call   1050 <get_physical_die_id@plt>
mov    %eax,%r14d
xor    %eax,%eax
call   1060 <get_topo_max_cpus@plt>
test   %eax,%eax
jle    11a2 <set_scaling_min_to_cpuinfo_min+0x62>
xor    %ebp,%ebp
jmp    117e <set_scaling_min_to_cpuinfo_min+0x3e>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%ebp
xor    %eax,%eax
call   1060 <get_topo_max_cpus@plt>
cmp    %eax,%ebp
jge    11a2 <set_scaling_min_to_cpuinfo_min+0x62>
mov    %ebp,%edi
call   1030 <get_physical_package_id@plt>
cmp    %eax,%ebx
jne    1170 <set_scaling_min_to_cpuinfo_min+0x30>
mov    %ebp,%edi
call   1050 <get_physical_die_id@plt>
cmp    %eax,%r14d
jne    1170 <set_scaling_min_to_cpuinfo_min+0x30>
mov    %ebp,%edi
xor    %esi,%esi
xor    %edx,%edx
call   1040 <set_cpufreq_scaling_min_max_from_cpuinfo@plt>
jmp    1170 <set_scaling_min_to_cpuinfo_min+0x30>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @set_scaling_min_to_cpuinfo_min(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %2
%6 = load i32, i32* %2
%7 = call i32 @get_physical_package_id(i32 %6)
store i32 %7, i32* %4
%8 = load i32, i32* %2
%9 = call i32 @get_physical_die_id(i32 %8)
store i32 %9, i32* %5
store i32 0, i32* %3
br label %10
10: ; preds = %28, %1
%11 = load i32, i32* %3
%12 = call i32 (...) @get_topo_max_cpus()
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %31
14: ; preds = %10
%15 = load i32, i32* %4
%16 = load i32, i32* %3
%17 = call i32 @get_physical_package_id(i32 %16)
%18 = icmp ne i32 %15, %17
br i1 %18, label %24, label %19
19: ; preds = %14
%20 = load i32, i32* %5
%21 = load i32, i32* %3
%22 = call i32 @get_physical_die_id(i32 %21)
%23 = icmp ne i32 %20, %22
br i1 %23, label %24, label %25
24: ; preds = %19, %14
br label %28
25: ; preds = %19
%26 = load i32, i32* %3
%27 = call i32 @set_cpufreq_scaling_min_max_from_cpuinfo(i32 %26, i32 0, i32 0)
br label %28
28: ; preds = %25, %24
%29 = load i32, i32* %3
%30 = add nsw i32 %29, 1
store i32 %30, i32* %3
br label %10
31: ; preds = %10
ret void
}

LLVM IR (-O2):
define void @set_scaling_min_to_cpuinfo_min(i32 %0) {
%2 = tail call i32 @get_physical_package_id(i32 %0)
%3 = tail call i32 @get_physical_die_id(i32 %0)
%4 = tail call i32 (...) @get_topo_max_cpus()
%5 = icmp sgt i32 %4, 0
br i1 %5, label %6, label %19
6: ; preds = %1, %15
%7 = phi i32 [ %16, %15 ], [ 0, %1 ]
%8 = tail call i32 @get_physical_package_id(i32 %7)
%9 = icmp eq i32 %2, %8
br i1 %9, label %10, label %15
10: ; preds = %6
%11 = tail call i32 @get_physical_die_id(i32 %7)
%12 = icmp eq i32 %3, %11
br i1 %12, label %13, label %15
13: ; preds = %10
%14 = tail call i32 @set_cpufreq_scaling_min_max_from_cpuinfo(i32 %7, i32 0, i32 0)
br label %15
15: ; preds = %6, %10, %13
%16 = add nuw nsw i32 %7, 1
%17 = tail call i32 (...) @get_topo_max_cpus()
%18 = icmp slt i32 %16, %17
br i1 %18, label %6, label %19
19: ; preds = %15, %1
ret void
}