#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*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int menu_selection() {
  int selection;
  printf("******************** MAIN MENU ***********************\n");
  printf("*                                                    *\n");
  printf("* 1 --> Enter integer number at the end of the list  *\n");
  printf("* 2 --> Enter integer number at the head of the list *\n");
  printf("* 3 --> Search node                                  *\n");
  printf("* 4 --> Count nodes                                  *\n");
  printf("* 5 --> Display list data                            *\n");
  printf("* 6 --> Delete node                                  *\n");
  printf("* 7 --> Save integer list to file                    *\n");
  printf("* 8 --> Load integer list from file                  *\n");
  printf("* 9 --> Quit program                                 *\n");
  printf("*                                                    *\n");
  printf("******************************************************\n\n");
  do {
    printf("Enter your choice >");
    scanf("%d", &selection);
  } while (selection < 1 || selection > 9);
  printf("\n");
  return (selection);
}


x86 assembly (clang, -O0):
<menu_selection>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xed1(%rip),%rdi
call   1030 <printf@plt>
lea    0xefd(%rip),%rdi
call   1030 <printf@plt>
lea    0xf29(%rip),%rdi
call   1030 <printf@plt>
lea    0xf55(%rip),%rdi
call   1030 <printf@plt>
lea    0xf81(%rip),%rdi
call   1030 <printf@plt>
lea    0xfad(%rip),%rdi
call   1030 <printf@plt>
lea    0xfd9(%rip),%rdi
call   1030 <printf@plt>
lea    0x1005(%rip),%rdi
call   1030 <printf@plt>
lea    0x1031(%rip),%rdi
call   1030 <printf@plt>
lea    0x105d(%rip),%rdi
call   1030 <printf@plt>
lea    0x1089(%rip),%rdi
call   1030 <printf@plt>
lea    0xe85(%rip),%rdi
call   1030 <printf@plt>
lea    0x10a9(%rip),%rdi
call   1030 <printf@plt>
lea    0x10d6(%rip),%rdi
call   1030 <printf@plt>
lea    0x10de(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1040 <scanf@plt>
mov    $0x1,%al
cmpl   $0x1,-0x4(%rbp)
mov    %al,-0x5(%rbp)
jl     11f9 <menu_selection+0xd9>
cmpl   $0x9,-0x4(%rbp)
setg   %al
mov    %al,-0x5(%rbp)
mov    -0x5(%rbp),%al
test   $0x1,%al
jne    11c4 <menu_selection+0xa4>
lea    0x1094(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<menu_selection>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xec7(%rip),%rdi
call   1040 <puts@plt>
lea    0x10e1(%rip),%rbx
mov    %rbx,%rdi
call   1040 <puts@plt>
lea    0xee3(%rip),%rdi
call   1040 <puts@plt>
lea    0xf0e(%rip),%rdi
call   1040 <puts@plt>
lea    0xf39(%rip),%rdi
call   1040 <puts@plt>
lea    0xf64(%rip),%rdi
call   1040 <puts@plt>
lea    0xf8f(%rip),%rdi
call   1040 <puts@plt>
lea    0xfba(%rip),%rdi
call   1040 <puts@plt>
lea    0xfe5(%rip),%rdi
call   1040 <puts@plt>
lea    0x1010(%rip),%rdi
call   1040 <puts@plt>
lea    0x103b(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
call   1040 <puts@plt>
lea    0x1095(%rip),%rdi
call   1040 <puts@plt>
lea    0xe15(%rip),%r14
lea    0xe22(%rip),%r15
lea    0xc(%rsp),%rbx
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1050 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1060 <scanf@plt>
mov    0xc(%rsp),%eax
add    $0xfffffff6,%eax
cmp    $0xfffffff7,%eax
jb     1200 <menu_selection+0xc0>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0xc(%rsp),%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [56 x i8] c"******************** MAIN MENU ***********************\0A\00"
@.str.1 = [56 x i8] c"* *\0A\00"
@.str.2 = [56 x i8] c"* 1 --> Enter integer number at the end of the list *\0A\00"
@.str.3 = [56 x i8] c"* 2 --> Enter integer number at the head of the list *\0A\00"
@.str.4 = [56 x i8] c"* 3 --> Search node *\0A\00"
@.str.5 = [56 x i8] c"* 4 --> Count nodes *\0A\00"
@.str.6 = [56 x i8] c"* 5 --> Display list data *\0A\00"
@.str.7 = [56 x i8] c"* 6 --> Delete node *\0A\00"
@.str.8 = [56 x i8] c"* 7 --> Save integer list to file *\0A\00"
@.str.9 = [56 x i8] c"* 8 --> Load integer list from file *\0A\00"
@.str.10 = [56 x i8] c"* 9 --> Quit program *\0A\00"
@.str.11 = [57 x i8] c"******************************************************\0A\0A\00"
@.str.12 = [20 x i8] c"Enter your choice >\00"
@.str.13 = [3 x i8] c"%d\00"
@.str.14 = [2 x i8] c"\0A\00"
define i32 @menu_selection() {
%1 = alloca i32
%2 = call i32 @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0))
%3 = call i32 @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.1, i64 0, i64 0))
%4 = call i32 @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.2, i64 0, i64 0))
%5 = call i32 @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.3, i64 0, i64 0))
%6 = call i32 @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.4, i64 0, i64 0))
%7 = call i32 @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.5, i64 0, i64 0))
%8 = call i32 @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.6, i64 0, i64 0))
%9 = call i32 @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.7, i64 0, i64 0))
%10 = call i32 @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.8, i64 0, i64 0))
%11 = call i32 @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.9, i64 0, i64 0))
%12 = call i32 @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.10, i64 0, i64 0))
%13 = call i32 @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.1, i64 0, i64 0))
%14 = call i32 @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.11, i64 0, i64 0))
br label %15
15: ; preds = %24, %0
%16 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.12, i64 0, i64 0))
%17 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.13, i64 0, i64 0), i32* %1)
br label %18
18: ; preds = %15
%19 = load i32, i32* %1
%20 = icmp slt i32 %19, 1
br i1 %20, label %24, label %21
21: ; preds = %18
%22 = load i32, i32* %1
%23 = icmp sgt i32 %22, 9
br label %24
24: ; preds = %21, %18
%25 = phi i1 [ true, %18 ], [ %23, %21 ]
br i1 %25, label %15, label %26
26: ; preds = %24
%27 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.14, i64 0, i64 0))
%28 = load i32, i32* %1
ret i32 %28
}

LLVM IR (-O2):
@.str.12 = [20 x i8] c"Enter your choice >\00"
@.str.13 = [3 x i8] c"%d\00"
@str = [55 x i8] c"******************** MAIN MENU ***********************\00"
@str.16 = [55 x i8] c"* 1 --> Enter integer number at the end of the list *\00"
@str.17 = [55 x i8] c"* 2 --> Enter integer number at the head of the list *\00"
@str.18 = [55 x i8] c"* 3 --> Search node *\00"
@str.19 = [55 x i8] c"* 4 --> Count nodes *\00"
@str.20 = [55 x i8] c"* 5 --> Display list data *\00"
@str.21 = [55 x i8] c"* 6 --> Delete node *\00"
@str.22 = [55 x i8] c"* 7 --> Save integer list to file *\00"
@str.23 = [55 x i8] c"* 8 --> Load integer list from file *\00"
@str.24 = [55 x i8] c"* 9 --> Quit program *\00"
@str.25 = [55 x i8] c"* *\00"
@str.26 = [56 x i8] c"******************************************************\0A\00"
define i32 @menu_selection() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @str.25, i64 0, i64 0))
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @str.16, i64 0, i64 0))
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @str.17, i64 0, i64 0))
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @str.18, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @str.19, i64 0, i64 0))
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @str.20, i64 0, i64 0))
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @str.21, i64 0, i64 0))
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @str.22, i64 0, i64 0))
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @str.23, i64 0, i64 0))
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @str.24, i64 0, i64 0))
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @str.25, i64 0, i64 0))
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @str.26, i64 0, i64 0))
br label %16
16: ; preds = %16, %0
%17 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.12, i64 0, i64 0))
%18 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.13, i64 0, i64 0), i32* %1)
%19 = load i32, i32* %1
%20 = add i32 %19, -10
%21 = icmp ult i32 %20, -9
br i1 %21, label %16, label %22
22: ; preds = %16
%23 = call i32 @putchar(i32 10)
%24 = load i32, i32* %1
ret i32 %24
}