#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 EINVAL;
int proc_modify_policy_governor(unsigned int, char *);
int strlen(char *);
int sysfs_modify_policy_governor(unsigned int, char *);
int cpufreq_modify_policy_governor(unsigned int cpu, char *governor) {
  int ret;
  if ((!governor) || (strlen(governor) > 19))
    return -EINVAL;
  ret = sysfs_modify_policy_governor(cpu, governor);
  if (ret)
    ret = proc_modify_policy_governor(cpu, governor);
  return (ret);
}


x86 assembly (clang, -O0):
<cpufreq_modify_policy_governor>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     115c <cpufreq_modify_policy_governor+0x2c>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x13,%eax
jle    116f <cpufreq_modify_policy_governor+0x3f>
xor    %eax,%eax
mov    0x2e7b(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    119d <cpufreq_modify_policy_governor+0x6d>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1040 <sysfs_modify_policy_governor@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     1197 <cpufreq_modify_policy_governor+0x67>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1050 <proc_modify_policy_governor@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cpufreq_modify_policy_governor>:
push   %rbp
push   %rbx
push   %rax
test   %rsi,%rsi
je     114a <cpufreq_modify_policy_governor+0x1a>
mov    %rsi,%rbx
mov    %edi,%ebp
mov    %rsi,%rdi
call   1030 <strlen@plt>
cmp    $0x14,%eax
jl     115c <cpufreq_modify_policy_governor+0x2c>
mov    0x2e8f(%rip),%rcx
xor    %eax,%eax
sub    (%rcx),%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
mov    %ebp,%edi
mov    %rbx,%rsi
call   1040 <sysfs_modify_policy_governor@plt>
test   %eax,%eax
je     117a <cpufreq_modify_policy_governor+0x4a>
mov    %ebp,%edi
mov    %rbx,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1050 <proc_modify_policy_governor@plt>
xor    %eax,%eax
jmp    1155 <cpufreq_modify_policy_governor+0x25>

LLVM IR (-O0):
@EINVAL = global i32 0
define i32 @cpufreq_modify_policy_governor(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
store i32 %0, i32* %4
store i8* %1, i8** %5
%7 = load i8*, i8** %5
%8 = icmp ne i8* %7, null
br i1 %8, label %9, label %13
9: ; preds = %2
%10 = load i8*, i8** %5
%11 = call i32 @strlen(i8* %10)
%12 = icmp sgt i32 %11, 19
br i1 %12, label %13, label %16
13: ; preds = %9, %2
%14 = load i32, i32* @EINVAL
%15 = sub nsw i32 0, %14
store i32 %15, i32* %3
br label %28
16: ; preds = %9
%17 = load i32, i32* %4
%18 = load i8*, i8** %5
%19 = call i32 @sysfs_modify_policy_governor(i32 %17, i8* %18)
store i32 %19, i32* %6
%20 = load i32, i32* %6
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %26
22: ; preds = %16
%23 = load i32, i32* %4
%24 = load i8*, i8** %5
%25 = call i32 @proc_modify_policy_governor(i32 %23, i8* %24)
store i32 %25, i32* %6
br label %26
26: ; preds = %22, %16
%27 = load i32, i32* %6
store i32 %27, i32* %3
br label %28
28: ; preds = %26, %13
%29 = load i32, i32* %3
ret i32 %29
}

LLVM IR (-O2):
@EINVAL = global i32 0
define i32 @cpufreq_modify_policy_governor(i32 %0, i8* %1) {
%3 = icmp eq i8* %1, null
br i1 %3, label %7, label %4
4: ; preds = %2
%5 = tail call i32 @strlen(i8* %1)
%6 = icmp sgt i32 %5, 19
br i1 %6, label %7, label %10
7: ; preds = %4, %2
%8 = load i32, i32* @EINVAL
%9 = sub nsw i32 0, %8
br label %15
10: ; preds = %4
%11 = tail call i32 @sysfs_modify_policy_governor(i32 %0, i8* %1)
%12 = icmp eq i32 %11, 0
br i1 %12, label %15, label %13
13: ; preds = %10
%14 = tail call i32 @proc_modify_policy_governor(i32 %0, i8* %1)
br label %15
15: ; preds = %10, %13, %7
%16 = phi i32 [ %9, %7 ], [ %14, %13 ], [ 0, %10 ]
ret i32 %16
}