#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 /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
scalar_t__ seteuid(int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcmp(char *, char *);
scalar_t__ sys_cpu_setall(char *, char *);
int /*<<< orphan*/ sys_cpufreq_set(char *, char *);
int main(int argc, char *argv[]) {
  if (argc != 3) {
    fprintf(stderr, "Invalid command. Syntax:\n");
    fprintf(stderr,
            "\tfreqset <frequency|governor> <freq-level|governor-name>\n");
    return 1;
  }
  if (seteuid(0)) {
    fprintf(stderr, "Unable to assume root privileges\n");
    return 1;
  }
  if (!strcmp(argv[1], "frequency")) {
    if (sys_cpu_setall("scaling_setspeed", argv[2]) == 0) {
      fprintf(stderr, "Unable to open frequency interface for writing.\n");
      return 1;
    }
    return 0;
  } else if (!strcmp(argv[1], "governor")) {
    if (sys_cpu_setall("scaling_governor", argv[2]) == 0) {
      fprintf(stderr, "Unable to open governor interface for writing.\n");
      return 1;
    }
    if (!strcmp(argv[2], "ondemand"))
      sys_cpufreq_set("ondemand/ignore_nice_load", "0");
    else if (!strcmp(argv[2], "conservative"))
      sys_cpufreq_set("conservative/ignore_nice_load", "0");
    return 0;
  } else {
    fprintf(stderr, "Unknown command.\n");
    return 1;
  }
  seteuid(-1);
  return -1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     11a6 <main+0x56>
mov    0x2e69(%rip),%rax
mov    (%rax),%edi
lea    0xe80(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2e54(%rip),%rax
mov    (%rax),%edi
lea    0xe85(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    132e <main+0x1de>
xor    %edi,%edi
call   1070 <seteuid@plt>
cmp    $0x0,%rax
je     11d8 <main+0x88>
mov    0x2e22(%rip),%rax
mov    (%rax),%edi
lea    0xe8d(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    132e <main+0x1de>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe8f(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    1240 <main+0xf0>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
lea    0xe7c(%rip),%rdi
call   1050 <sys_cpu_setall@plt>
cmp    $0x0,%rax
jne    1234 <main+0xe4>
mov    0x2dc6(%rip),%rax
mov    (%rax),%edi
lea    0xe6e(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    132e <main+0x1de>
movl   $0x0,-0x4(%rbp)
jmp    132e <main+0x1de>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe7b(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    1312 <main+0x1c2>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
lea    0xe56(%rip),%rdi
call   1050 <sys_cpu_setall@plt>
cmp    $0x0,%rax
jne    129c <main+0x14c>
mov    0x2d5e(%rip),%rax
mov    (%rax),%edi
lea    0xe48(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    132e <main+0x1de>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe58(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    12d1 <main+0x181>
lea    0xe4c(%rip),%rdi
lea    0xe5f(%rip),%rsi
call   1060 <sys_cpufreq_set@plt>
jmp    1306 <main+0x1b6>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe48(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    1301 <main+0x1b1>
lea    0xe40(%rip),%rdi
lea    0xe2a(%rip),%rsi
call   1060 <sys_cpufreq_set@plt>
jmp    1306 <main+0x1b6>
movl   $0x0,-0x4(%rbp)
jmp    132e <main+0x1de>
mov    0x2cc7(%rip),%rax
mov    (%rax),%edi
lea    0xe31(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
cmp    $0x3,%edi
jne    117a <main+0x2a>
mov    %rsi,%rbx
xor    %edi,%edi
call   1070 <seteuid@plt>
test   %rax,%rax
je     11ac <main+0x5c>
mov    0x2e71(%rip),%rax
mov    (%rax),%edi
lea    0xedc(%rip),%rsi
jmp    1198 <main+0x48>
mov    0x2e5f(%rip),%rbx
mov    (%rbx),%edi
lea    0xe76(%rip),%rsi
call   1040 <fprintf@plt>
mov    (%rbx),%edi
lea    0xe82(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    0x8(%rbx),%r14
lea    0xebf(%rip),%rsi
mov    %r14,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     11e8 <main+0x98>
lea    0xf00(%rip),%rsi
mov    %r14,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     1211 <main+0xc1>
mov    0x2e03(%rip),%rax
mov    (%rax),%edi
lea    0xf6d(%rip),%rsi
jmp    1198 <main+0x48>
mov    0x10(%rbx),%rsi
lea    0xe8d(%rip),%rdi
call   1050 <sys_cpu_setall@plt>
xor    %ebx,%ebx
test   %rax,%rax
jne    11a2 <main+0x52>
mov    0x2dda(%rip),%rax
mov    (%rax),%edi
lea    0xe82(%rip),%rsi
jmp    1198 <main+0x48>
mov    0x10(%rbx),%rsi
lea    0xea6(%rip),%rdi
call   1050 <sys_cpu_setall@plt>
test   %rax,%rax
je     126e <main+0x11e>
mov    0x10(%rbx),%rbx
lea    0xed2(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     1283 <main+0x133>
lea    0xee4(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
xor    %ebx,%ebx
test   %eax,%eax
jne    11a2 <main+0x52>
lea    0xed8(%rip),%rdi
lea    0xec2(%rip),%rsi
call   1060 <sys_cpufreq_set@plt>
jmp    11a2 <main+0x52>
mov    0x2d6b(%rip),%rax
mov    (%rax),%edi
lea    0xe55(%rip),%rsi
jmp    1198 <main+0x48>
lea    0xe82(%rip),%rdi
lea    0xe95(%rip),%rsi
call   1060 <sys_cpufreq_set@plt>
xor    %ebx,%ebx
jmp    11a2 <main+0x52>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [26 x i8] c"Invalid command. Syntax:\0A\00"
@.str.1 = [58 x i8] c"\09freqset <frequency|governor> <freq-level|governor-name>\0A\00"
@.str.2 = [34 x i8] c"Unable to assume root privileges\0A\00"
@.str.3 = [10 x i8] c"frequency\00"
@.str.4 = [17 x i8] c"scaling_setspeed\00"
@.str.5 = [49 x i8] c"Unable to open frequency interface for writing.\0A\00"
@.str.6 = [9 x i8] c"governor\00"
@.str.7 = [17 x i8] c"scaling_governor\00"
@.str.8 = [48 x i8] c"Unable to open governor interface for writing.\0A\00"
@.str.9 = [9 x i8] c"ondemand\00"
@.str.10 = [26 x i8] c"ondemand/ignore_nice_load\00"
@.str.11 = [2 x i8] c"0\00"
@.str.12 = [13 x i8] c"conservative\00"
@.str.13 = [30 x i8] c"conservative/ignore_nice_load\00"
@.str.14 = [18 x i8] c"Unknown command.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = load i32, i32* %4
%7 = icmp ne i32 %6, 3
br i1 %7, label %8, label %13
8: ; preds = %2
%9 = load i32, i32* @stderr
%10 = call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%11 = load i32, i32* @stderr
%12 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %3
br label %71
13: ; preds = %2
%14 = call i64 @seteuid(i32 0)
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %13
%17 = load i32, i32* @stderr
%18 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %3
br label %71
19: ; preds = %13
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
%23 = call i32 @strcmp(i8* %22, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%24 = icmp ne i32 %23, 0
br i1 %24, label %35, label %25
25: ; preds = %19
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 2
%28 = load i8*, i8** %27
%29 = call i64 @sys_cpu_setall(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i8* %28)
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %34
31: ; preds = %25
%32 = load i32, i32* @stderr
%33 = call i32 @fprintf(i32 %32, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.5, i64 0, i64 0))
store i32 1, i32* %3
br label %71
34: ; preds = %25
store i32 0, i32* %3
br label %71
35: ; preds = %19
%36 = load i8**, i8*** %5
%37 = getelementptr inbounds i8*, i8** %36, i64 1
%38 = load i8*, i8** %37
%39 = call i32 @strcmp(i8* %38, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
%40 = icmp ne i32 %39, 0
br i1 %40, label %68, label %41
41: ; preds = %35
%42 = load i8**, i8*** %5
%43 = getelementptr inbounds i8*, i8** %42, i64 2
%44 = load i8*, i8** %43
%45 = call i64 @sys_cpu_setall(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0), i8* %44)
%46 = icmp eq i64 %45, 0
br i1 %46, label %47, label %50
47: ; preds = %41
%48 = load i32, i32* @stderr
%49 = call i32 @fprintf(i32 %48, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.8, i64 0, i64 0))
store i32 1, i32* %3
br label %71
50: ; preds = %41
%51 = load i8**, i8*** %5
%52 = getelementptr inbounds i8*, i8** %51, i64 2
%53 = load i8*, i8** %52
%54 = call i32 @strcmp(i8* %53, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i64 0, i64 0))
%55 = icmp ne i32 %54, 0
br i1 %55, label %58, label %56
56: ; preds = %50
%57 = call i32 @sys_cpufreq_set(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0))
br label %67
58: ; preds = %50
%59 = load i8**, i8*** %5
%60 = getelementptr inbounds i8*, i8** %59, i64 2
%61 = load i8*, i8** %60
%62 = call i32 @strcmp(i8* %61, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.12, i64 0, i64 0))
%63 = icmp ne i32 %62, 0
br i1 %63, label %66, label %64
64: ; preds = %58
%65 = call i32 @sys_cpufreq_set(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.13, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0))
br label %66
66: ; preds = %64, %58
br label %67
67: ; preds = %66, %56
store i32 0, i32* %3
br label %71
68: ; preds = %35
%69 = load i32, i32* @stderr
%70 = call i32 @fprintf(i32 %69, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.14, i64 0, i64 0))
store i32 1, i32* %3
br label %71
71: ; preds = %68, %67, %47, %34, %31, %16, %8
%72 = load i32, i32* %3
ret i32 %72
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [26 x i8] c"Invalid command. Syntax:\0A\00"
@.str.1 = [58 x i8] c"\09freqset <frequency|governor> <freq-level|governor-name>\0A\00"
@.str.2 = [34 x i8] c"Unable to assume root privileges\0A\00"
@.str.3 = [10 x i8] c"frequency\00"
@.str.4 = [17 x i8] c"scaling_setspeed\00"
@.str.5 = [49 x i8] c"Unable to open frequency interface for writing.\0A\00"
@.str.6 = [9 x i8] c"governor\00"
@.str.7 = [17 x i8] c"scaling_governor\00"
@.str.8 = [48 x i8] c"Unable to open governor interface for writing.\0A\00"
@.str.9 = [9 x i8] c"ondemand\00"
@.str.10 = [26 x i8] c"ondemand/ignore_nice_load\00"
@.str.11 = [2 x i8] c"0\00"
@.str.12 = [13 x i8] c"conservative\00"
@.str.13 = [30 x i8] c"conservative/ignore_nice_load\00"
@.str.14 = [18 x i8] c"Unknown command.\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 3
br i1 %3, label %9, label %4
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%7 = load i32, i32* @stderr
%8 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.1, i64 0, i64 0))
br label %53
9: ; preds = %2
%10 = tail call i64 @seteuid(i32 0)
%11 = icmp eq i64 %10, 0
br i1 %11, label %15, label %12
12: ; preds = %9
%13 = load i32, i32* @stderr
%14 = tail call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0))
br label %53
15: ; preds = %9
%16 = getelementptr inbounds i8*, i8** %1, i64 1
%17 = load i8*, i8** %16
%18 = tail call i32 @strcmp(i8* dereferenceable(1) %17, i8* dereferenceable(10) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %28
20: ; preds = %15
%21 = getelementptr inbounds i8*, i8** %1, i64 2
%22 = load i8*, i8** %21
%23 = tail call i64 @sys_cpu_setall(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i8* %22)
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %53
25: ; preds = %20
%26 = load i32, i32* @stderr
%27 = tail call i32 @fprintf(i32 %26, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.5, i64 0, i64 0))
br label %53
28: ; preds = %15
%29 = tail call i32 @strcmp(i8* dereferenceable(1) %17, i8* dereferenceable(9) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
%30 = icmp eq i32 %29, 0
br i1 %30, label %31, label %50
31: ; preds = %28
%32 = getelementptr inbounds i8*, i8** %1, i64 2
%33 = load i8*, i8** %32
%34 = tail call i64 @sys_cpu_setall(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0), i8* %33)
%35 = icmp eq i64 %34, 0
br i1 %35, label %36, label %39
36: ; preds = %31
%37 = load i32, i32* @stderr
%38 = tail call i32 @fprintf(i32 %37, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.8, i64 0, i64 0))
br label %53
39: ; preds = %31
%40 = load i8*, i8** %32
%41 = tail call i32 @strcmp(i8* dereferenceable(1) %40, i8* dereferenceable(9) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i64 0, i64 0))
%42 = icmp eq i32 %41, 0
br i1 %42, label %43, label %45
43: ; preds = %39
%44 = tail call i32 @sys_cpufreq_set(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0))
br label %53
45: ; preds = %39
%46 = tail call i32 @strcmp(i8* dereferenceable(1) %40, i8* dereferenceable(13) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.12, i64 0, i64 0))
%47 = icmp eq i32 %46, 0
br i1 %47, label %48, label %53
48: ; preds = %45
%49 = tail call i32 @sys_cpufreq_set(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.13, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0))
br label %53
50: ; preds = %28
%51 = load i32, i32* @stderr
%52 = tail call i32 @fprintf(i32 %51, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.14, i64 0, i64 0))
br label %53
53: ; preds = %43, %48, %45, %20, %50, %36, %25, %12, %4
%54 = phi i32 [ 1, %4 ], [ 1, %12 ], [ 1, %50 ], [ 1, %36 ], [ 1, %25 ], [ 0, %20 ], [ 0, %45 ], [ 0, %48 ], [ 0, %43 ]
ret i32 %54
}