#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*/ cpugovernor();
int /*<<< orphan*/ cpumenu();
int /*<<< orphan*/ fbimg();
int /*<<< orphan*/ frimg();
int /*<<< orphan*/ iosched();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ readahead();
int /*<<< orphan*/ readahead2();
int /*<<< orphan*/ readaheadmenu();
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ setscheduler();
int /*<<< orphan*/ uvovmenu();
int /*<<< orphan*/ vddlevels();
void load_menu(void) {
  int choice;
  do {
    printf("\n - S4 Utils v0.2 (by broodplank)\n\n");
    printf("  ----[ CPU Settings ]----\n");
    printf(" [1] Check current CPU frequency/voltage table and governor\n");
    printf(" [2] Undervolt / Overvolt CPU\n");
    printf(" [3] CPU Governor and Min/Max Freq\n\n");
    printf(" ----[ I/O Settings ]----\n");
    printf(" [4] Check current readahead and I/O scheduler \n");
    printf(" [5] Set Readahead for Internal/External SD\n");
    printf(" [6] Set I/O Scheduler\n\n");
    printf(" ----[ Install / Restore ]----\n");
    printf(" [7] Make current settings persistent\n");
    printf(" [8] Restore default settings\n\n");
    printf("  ----[ Extra ]----\n");
    printf(" [9] Fake Factory Reset\n\n");
    printf(" [0] Exit\n\n");
    printf("Selection: ");
    scanf("%d", &choice);
    switch (choice) {
    case 1:
      vddlevels();
      printf("\n");
      cpugovernor();
      break;
    case 2:
      uvovmenu();
      break;
    case 3:
      cpumenu();
      break;
    case 4:
      readahead();
      printf("\n");
      readahead2();
      printf("\n");
      iosched();
      break;
    case 5:
      readaheadmenu();
      break;
    case 6:
      setscheduler();
      break;
    case 7:
      fbimg();
      break;
    case 8:
      frimg();
      break;
    case 0:
      break;
    default:
      printf("Bad input, quitting!\n");
      break;
    }
  } while (choice != 0);
}


x86 assembly (clang, -O0):
<load_menu>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xe45(%rip),%rdi
call   1050 <printf@plt>
lea    0xe5d(%rip),%rdi
call   1050 <printf@plt>
lea    0xe6d(%rip),%rdi
call   1050 <printf@plt>
lea    0xe9e(%rip),%rdi
call   1050 <printf@plt>
lea    0xeb1(%rip),%rdi
call   1050 <printf@plt>
lea    0xeca(%rip),%rdi
call   1050 <printf@plt>
lea    0xed9(%rip),%rdi
call   1050 <printf@plt>
lea    0xefe(%rip),%rdi
call   1050 <printf@plt>
lea    0xf1f(%rip),%rdi
call   1050 <printf@plt>
lea    0xf2c(%rip),%rdi
call   1050 <printf@plt>
lea    0xf40(%rip),%rdi
call   1050 <printf@plt>
lea    0xf5b(%rip),%rdi
call   1050 <printf@plt>
lea    0xf6f(%rip),%rdi
call   1050 <printf@plt>
lea    0xf78(%rip),%rdi
call   1050 <printf@plt>
lea    0xf86(%rip),%rdi
call   1050 <printf@plt>
lea    0xf86(%rip),%rdi
call   1050 <printf@plt>
lea    0xf86(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   10d0 <scanf@plt>
mov    -0x4(%rbp),%eax
mov    %rax,-0x10(%rbp)
sub    $0x8,%rax
ja     136b <load_menu+0x19b>
mov    -0x10(%rbp),%rax
lea    0xd3c(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x0,%al
call   10e0 <vddlevels@plt>
lea    0xd6b(%rip),%rdi
call   1050 <printf@plt>
mov    $0x0,%al
call   1040 <cpugovernor@plt>
jmp    1377 <load_menu+0x1a7>
mov    $0x0,%al
call   10a0 <uvovmenu@plt>
jmp    1377 <load_menu+0x1a7>
mov    $0x0,%al
call   1080 <cpumenu@plt>
jmp    1377 <load_menu+0x1a7>
mov    $0x0,%al
call   10f0 <readahead@plt>
lea    0xd34(%rip),%rdi
call   1050 <printf@plt>
mov    $0x0,%al
call   10c0 <readahead2@plt>
lea    0xd21(%rip),%rdi
call   1050 <printf@plt>
mov    $0x0,%al
call   1070 <iosched@plt>
jmp    1377 <load_menu+0x1a7>
mov    $0x0,%al
call   1090 <readaheadmenu@plt>
jmp    1377 <load_menu+0x1a7>
mov    $0x0,%al
call   1030 <setscheduler@plt>
jmp    1377 <load_menu+0x1a7>
mov    $0x0,%al
call   1060 <fbimg@plt>
jmp    1377 <load_menu+0x1a7>
mov    $0x0,%al
call   10b0 <frimg@plt>
jmp    1377 <load_menu+0x1a7>
jmp    1377 <load_menu+0x1a7>
lea    0xeb6(%rip),%rdi
call   1050 <printf@plt>
jmp    137c <load_menu+0x1ac>
cmpl   $0x0,-0x4(%rbp)
jne    11d8 <load_menu+0x8>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<load_menu>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xff3(%rip),%r15
lea    0x1005(%rip),%r12
lea    0xe14(%rip),%r13
lea    0xe19(%rip),%rbx
lea    0x4(%rsp),%rbp
lea    0xddd(%rip),%r14
jmp    124b <load_menu+0x5b>
lea    0xfed(%rip),%rdi
call   1050 <puts@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
cmpl   $0x0,0x4(%rsp)
je     13b4 <load_menu+0x1c4>
lea    0xde1(%rip),%rdi
call   1050 <puts@plt>
lea    0xdf8(%rip),%rdi
call   1050 <puts@plt>
lea    0xe07(%rip),%rdi
call   1050 <puts@plt>
lea    0xe37(%rip),%rdi
call   1050 <puts@plt>
lea    0xe49(%rip),%rdi
call   1050 <puts@plt>
lea    0xe61(%rip),%rdi
call   1050 <puts@plt>
lea    0xe6f(%rip),%rdi
call   1050 <puts@plt>
lea    0xe93(%rip),%rdi
call   1050 <puts@plt>
lea    0xeb3(%rip),%rdi
call   1050 <puts@plt>
lea    0xebf(%rip),%rdi
call   1050 <puts@plt>
lea    0xed2(%rip),%rdi
call   1050 <puts@plt>
lea    0xeec(%rip),%rdi
call   1050 <puts@plt>
lea    0xeff(%rip),%rdi
call   1050 <puts@plt>
mov    %r15,%rdi
call   1050 <puts@plt>
mov    %r12,%rdi
call   1050 <puts@plt>
mov    %r13,%rdi
call   1070 <printf@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   10f0 <scanf@plt>
mov    0x4(%rsp),%eax
cmp    $0x8,%rax
ja     1225 <load_menu+0x35>
movslq (%r14,%rax,4),%rax
add    %r14,%rax
jmp    *%rax
xor    %eax,%eax
call   1100 <vddlevels@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
call   1060 <cpugovernor@plt>
jmp    1240 <load_menu+0x50>
xor    %eax,%eax
call   10c0 <uvovmenu@plt>
jmp    1240 <load_menu+0x50>
xor    %eax,%eax
call   10a0 <cpumenu@plt>
jmp    1240 <load_menu+0x50>
xor    %eax,%eax
call   1110 <readahead@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
call   10e0 <readahead2@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
call   1090 <iosched@plt>
jmp    1240 <load_menu+0x50>
xor    %eax,%eax
call   10b0 <readaheadmenu@plt>
jmp    1240 <load_menu+0x50>
xor    %eax,%eax
call   1040 <setscheduler@plt>
jmp    1240 <load_menu+0x50>
xor    %eax,%eax
call   1080 <fbimg@plt>
jmp    1240 <load_menu+0x50>
xor    %eax,%eax
call   10d0 <frimg@plt>
jmp    1240 <load_menu+0x50>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [36 x i8] c"\0A - S4 Utils v0.2 (by broodplank)\0A\0A\00"
@.str.1 = [28 x i8] c" ----[ CPU Settings ]----\0A\00"
@.str.2 = [61 x i8] c" [1] Check current CPU frequency/voltage table and governor\0A\00"
@.str.3 = [31 x i8] c" [2] Undervolt / Overvolt CPU\0A\00"
@.str.4 = [37 x i8] c" [3] CPU Governor and Min/Max Freq\0A\0A\00"
@.str.5 = [27 x i8] c" ----[ I/O Settings ]----\0A\00"
@.str.6 = [49 x i8] c" [4] Check current readahead and I/O scheduler \0A\00"
@.str.7 = [45 x i8] c" [5] Set Readahead for Internal/External SD\0A\00"
@.str.8 = [25 x i8] c" [6] Set I/O Scheduler\0A\0A\00"
@.str.9 = [32 x i8] c" ----[ Install / Restore ]----\0A\00"
@.str.10 = [39 x i8] c" [7] Make current settings persistent\0A\00"
@.str.11 = [32 x i8] c" [8] Restore default settings\0A\0A\00"
@.str.12 = [21 x i8] c" ----[ Extra ]----\0A\00"
@.str.13 = [26 x i8] c" [9] Fake Factory Reset\0A\0A\00"
@.str.14 = [12 x i8] c" [0] Exit\0A\0A\00"
@.str.15 = [12 x i8] c"Selection: \00"
@.str.16 = [3 x i8] c"%d\00"
@.str.17 = [2 x i8] c"\0A\00"
@.str.18 = [22 x i8] c"Bad input, quitting!\0A\00"
define void @load_menu() {
%1 = alloca i32
br label %2
2: ; preds = %47, %0
%3 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
%5 = call i32 @printf(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.2, i64 0, i64 0))
%6 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
%7 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0))
%8 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0))
%9 = call i32 @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.6, i64 0, i64 0))
%10 = call i32 @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.7, i64 0, i64 0))
%11 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.8, i64 0, i64 0))
%12 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.9, i64 0, i64 0))
%13 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.10, i64 0, i64 0))
%14 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.11, i64 0, i64 0))
%15 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.12, i64 0, i64 0))
%16 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.13, i64 0, i64 0))
%17 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.14, i64 0, i64 0))
%18 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.15, i64 0, i64 0))
%19 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.16, i64 0, i64 0), i32* %1)
%20 = load i32, i32* %1
switch i32 %20, label %44 [
i32 1, label %21
i32 2, label %25
i32 3, label %27
i32 4, label %29
i32 5, label %35
i32 6, label %37
i32 7, label %39
i32 8, label %41
i32 0, label %43
]
21: ; preds = %2
%22 = call i32 (...) @vddlevels()
%23 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.17, i64 0, i64 0))
%24 = call i32 (...) @cpugovernor()
br label %46
25: ; preds = %2
%26 = call i32 (...) @uvovmenu()
br label %46
27: ; preds = %2
%28 = call i32 (...) @cpumenu()
br label %46
29: ; preds = %2
%30 = call i32 (...) @readahead()
%31 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.17, i64 0, i64 0))
%32 = call i32 (...) @readahead2()
%33 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.17, i64 0, i64 0))
%34 = call i32 (...) @iosched()
br label %46
35: ; preds = %2
%36 = call i32 (...) @readaheadmenu()
br label %46
37: ; preds = %2
%38 = call i32 (...) @setscheduler()
br label %46
39: ; preds = %2
%40 = call i32 (...) @fbimg()
br label %46
41: ; preds = %2
%42 = call i32 (...) @frimg()
br label %46
43: ; preds = %2
br label %46
44: ; preds = %2
%45 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.18, i64 0, i64 0))
br label %46
46: ; preds = %44, %43, %41, %39, %37, %35, %29, %27, %25, %21
br label %47
47: ; preds = %46
%48 = load i32, i32* %1
%49 = icmp ne i32 %48, 0
br i1 %49, label %2, label %50
50: ; preds = %47
ret void
}

LLVM IR (-O2):
@.str.15 = [12 x i8] c"Selection: \00"
@.str.16 = [3 x i8] c"%d\00"
@str = [35 x i8] c"\0A - S4 Utils v0.2 (by broodplank)\0A\00"
@str.19 = [27 x i8] c" ----[ CPU Settings ]----\00"
@str.20 = [60 x i8] c" [1] Check current CPU frequency/voltage table and governor\00"
@str.21 = [30 x i8] c" [2] Undervolt / Overvolt CPU\00"
@str.22 = [36 x i8] c" [3] CPU Governor and Min/Max Freq\0A\00"
@str.23 = [26 x i8] c" ----[ I/O Settings ]----\00"
@str.24 = [48 x i8] c" [4] Check current readahead and I/O scheduler \00"
@str.25 = [44 x i8] c" [5] Set Readahead for Internal/External SD\00"
@str.26 = [24 x i8] c" [6] Set I/O Scheduler\0A\00"
@str.27 = [31 x i8] c" ----[ Install / Restore ]----\00"
@str.28 = [38 x i8] c" [7] Make current settings persistent\00"
@str.29 = [31 x i8] c" [8] Restore default settings\0A\00"
@str.30 = [20 x i8] c" ----[ Extra ]----\00"
@str.31 = [25 x i8] c" [9] Fake Factory Reset\0A\00"
@str.32 = [11 x i8] c" [0] Exit\0A\00"
@str.33 = [21 x i8] c"Bad input, quitting!\00"
define void @load_menu() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
br label %3
3: ; preds = %46, %0
%4 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str, i64 0, i64 0))
%5 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.19, i64 0, i64 0))
%6 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([60 x i8], [60 x i8]* @str.20, i64 0, i64 0))
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str.21, i64 0, i64 0))
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str.22, i64 0, i64 0))
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.23, i64 0, i64 0))
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @str.24, i64 0, i64 0))
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @str.25, i64 0, i64 0))
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.26, i64 0, i64 0))
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.27, i64 0, i64 0))
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str.28, i64 0, i64 0))
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.29, i64 0, i64 0))
%16 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.30, i64 0, i64 0))
%17 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.31, i64 0, i64 0))
%18 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.32, i64 0, i64 0))
%19 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.15, i64 0, i64 0))
%20 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.16, i64 0, i64 0), i32* %1)
%21 = load i32, i32* %1
switch i32 %21, label %44 [
i32 1, label %22
i32 2, label %26
i32 3, label %28
i32 4, label %30
i32 5, label %36
i32 6, label %38
i32 7, label %40
i32 8, label %42
i32 0, label %49
]
22: ; preds = %3
%23 = call i32 (...) @vddlevels()
%24 = call i32 @putchar(i32 10)
%25 = call i32 (...) @cpugovernor()
br label %46
26: ; preds = %3
%27 = call i32 (...) @uvovmenu()
br label %46
28: ; preds = %3
%29 = call i32 (...) @cpumenu()
br label %46
30: ; preds = %3
%31 = call i32 (...) @readahead()
%32 = call i32 @putchar(i32 10)
%33 = call i32 (...) @readahead2()
%34 = call i32 @putchar(i32 10)
%35 = call i32 (...) @iosched()
br label %46
36: ; preds = %3
%37 = call i32 (...) @readaheadmenu()
br label %46
38: ; preds = %3
%39 = call i32 (...) @setscheduler()
br label %46
40: ; preds = %3
%41 = call i32 (...) @fbimg()
br label %46
42: ; preds = %3
%43 = call i32 (...) @frimg()
br label %46
44: ; preds = %3
%45 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.33, i64 0, i64 0))
br label %46
46: ; preds = %22, %26, %28, %30, %36, %38, %40, %42, %44
%47 = load i32, i32* %1
%48 = icmp eq i32 %47, 0
br i1 %48, label %49, label %3
49: ; preds = %3, %46
ret void
}