#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*/ cpufreqs();
int /*<<< orphan*/ cpugovernors();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
void cpumenu() {
  for (;;) {
    printf("What do you want to change?\n\n");
    printf(" [1] CPU Governor\n");
    printf(" [2] CPU Min Freq\n");
    printf(" [3] CPU Max Freq\n");
    printf(" [0] Exit\n");
    printf("\nChoice: ");
    int cpuchoice;
    scanf("%d", &cpuchoice);
    if (cpuchoice == 1)
      cpugovernors();
    if (cpuchoice == 2)
      cpufreqs();
    if (cpuchoice == 3)
      cpufreqs();
    if (cpuchoice == 0)
      break;
  }
}


x86 assembly (clang, -O0):
<cpumenu>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xeb1(%rip),%rdi
call   1040 <printf@plt>
lea    0xec3(%rip),%rdi
call   1040 <printf@plt>
lea    0xeca(%rip),%rdi
call   1040 <printf@plt>
lea    0xed1(%rip),%rdi
call   1040 <printf@plt>
lea    0xed8(%rip),%rdi
call   1040 <printf@plt>
lea    0xed7(%rip),%rdi
call   1040 <printf@plt>
lea    0xed5(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1050 <scanf@plt>
cmpl   $0x1,-0x4(%rbp)
jne    11b1 <cpumenu+0x71>
mov    $0x0,%al
call   1030 <cpugovernors@plt>
cmpl   $0x2,-0x4(%rbp)
jne    11c2 <cpumenu+0x82>
mov    $0x0,%al
call   1060 <cpufreqs@plt>
cmpl   $0x3,-0x4(%rbp)
jne    11d3 <cpumenu+0x93>
mov    $0x0,%al
call   1060 <cpufreqs@plt>
cmpl   $0x0,-0x4(%rbp)
jne    11e2 <cpumenu+0xa2>
jmp    11e7 <cpumenu+0xa7>
jmp    1148 <cpumenu+0x8>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cpumenu>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xeda(%rip),%r12
lea    0xee5(%rip),%r13
lea    0xef0(%rip),%rbx
lea    0xe89(%rip),%rbp
lea    0xe8c(%rip),%r14
lea    0x4(%rsp),%r15
jmp    1198 <cpumenu+0x48>
cs nopw 0x0(%rax,%rax,1)
nop
test   %eax,%eax
je     1220 <cpumenu+0xd0>
lea    0xe6e(%rip),%rdi
call   1040 <puts@plt>
lea    0xe7f(%rip),%rdi
call   1040 <puts@plt>
mov    %r12,%rdi
call   1040 <puts@plt>
mov    %r13,%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
call   1040 <puts@plt>
mov    %rbp,%rdi
call   1050 <printf@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   1060 <scanf@plt>
mov    0x4(%rsp),%eax
cmp    $0x1,%eax
je     11f0 <cpumenu+0xa0>
cmp    $0x2,%eax
je     1200 <cpumenu+0xb0>
cmp    $0x3,%eax
jne    1190 <cpumenu+0x40>
jmp    1210 <cpumenu+0xc0>
xor    %eax,%eax
call   1030 <cpugovernors@plt>
mov    0x4(%rsp),%eax
cmp    $0x2,%eax
jne    11e9 <cpumenu+0x99>
xor    %eax,%eax
call   1070 <cpufreqs@plt>
mov    0x4(%rsp),%eax
cmp    $0x3,%eax
jne    1190 <cpumenu+0x40>
xor    %eax,%eax
call   1070 <cpufreqs@plt>
mov    0x4(%rsp),%eax
jmp    1190 <cpumenu+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [30 x i8] c"What do you want to change?\0A\0A\00"
@.str.1 = [19 x i8] c" [1] CPU Governor\0A\00"
@.str.2 = [19 x i8] c" [2] CPU Min Freq\0A\00"
@.str.3 = [19 x i8] c" [3] CPU Max Freq\0A\00"
@.str.4 = [11 x i8] c" [0] Exit\0A\00"
@.str.5 = [10 x i8] c"\0AChoice: \00"
@.str.6 = [3 x i8] c"%d\00"
define void @cpumenu() {
%1 = alloca i32
br label %2
2: ; preds = %28, %0
%3 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%5 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
%6 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0))
%7 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
%8 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %1)
%10 = load i32, i32* %1
%11 = icmp eq i32 %10, 1
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = call i32 (...) @cpugovernors()
br label %14
14: ; preds = %12, %2
%15 = load i32, i32* %1
%16 = icmp eq i32 %15, 2
br i1 %16, label %17, label %19
17: ; preds = %14
%18 = call i32 (...) @cpufreqs()
br label %19
19: ; preds = %17, %14
%20 = load i32, i32* %1
%21 = icmp eq i32 %20, 3
br i1 %21, label %22, label %24
22: ; preds = %19
%23 = call i32 (...) @cpufreqs()
br label %24
24: ; preds = %22, %19
%25 = load i32, i32* %1
%26 = icmp eq i32 %25, 0
br i1 %26, label %27, label %28
27: ; preds = %24
br label %29
28: ; preds = %24
br label %2
29: ; preds = %27
ret void
}

LLVM IR (-O2):
@.str.5 = [10 x i8] c"\0AChoice: \00"
@.str.6 = [3 x i8] c"%d\00"
@str = [29 x i8] c"What do you want to change?\0A\00"
@str.7 = [18 x i8] c" [1] CPU Governor\00"
@str.8 = [18 x i8] c" [2] CPU Min Freq\00"
@str.9 = [18 x i8] c" [3] CPU Max Freq\00"
@str.10 = [10 x i8] c" [0] Exit\00"
define void @cpumenu() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
br label %3
3: ; preds = %28, %0
%4 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0))
%5 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.7, i64 0, i64 0))
%6 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.8, i64 0, i64 0))
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.9, i64 0, i64 0))
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.10, i64 0, i64 0))
%9 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %1)
%11 = load i32, i32* %1
%12 = icmp eq i32 %11, 1
br i1 %12, label %13, label %16
13: ; preds = %3
%14 = call i32 (...) @cpugovernors()
%15 = load i32, i32* %1
br label %16
16: ; preds = %13, %3
%17 = phi i32 [ %15, %13 ], [ %11, %3 ]
%18 = icmp eq i32 %17, 2
br i1 %18, label %19, label %22
19: ; preds = %16
%20 = call i32 (...) @cpufreqs()
%21 = load i32, i32* %1
br label %22
22: ; preds = %19, %16
%23 = phi i32 [ %21, %19 ], [ %17, %16 ]
%24 = icmp eq i32 %23, 3
br i1 %24, label %25, label %28
25: ; preds = %22
%26 = call i32 (...) @cpufreqs()
%27 = load i32, i32* %1
br label %28
28: ; preds = %25, %22
%29 = phi i32 [ %27, %25 ], [ %23, %22 ]
%30 = icmp eq i32 %29, 0
br i1 %30, label %31, label %3
31: ; preds = %28
ret void
}