#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 *);
scalar_t__ scanf(char *, ...);
int menu(void) {
  int response = 1;
  do {
    if (response < 1 || response > 11)
      printf("\n*****Wrong selection. Select option 1-9*****\n\n\n");
    printf("\n*** SLL INTERFACE MENU ***\n\n");
    printf("Choose option:\n");
    printf("1) Create new empty list (removes previously created one.\n");
    printf("2) Add node at beginning of list.\n");
    printf("3) Add node at end of list.\n");
    printf("4) Add node in right place like list was sorted ascending.\n");
    printf("5) Remove node from the list.\n");
    printf("6) Reverse list.\n");
    printf("7) Sort list.\n");
    printf("8) Print all nodes in the list.\n");
    printf("9) Remove list.\n");
    printf("10) Count nodes in the list.\n");
    printf("11) Quit.\n");
    if (scanf("%d", &response) == 0)
      scanf("%*s");
  } while (response < 1 || response > 11);
  return response;
}


x86 assembly (clang, -O0):
<menu>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x1,-0x4(%rbp)
cmpl   $0x1,-0x4(%rbp)
jl     1143 <menu+0x23>
cmpl   $0xb,-0x4(%rbp)
jle    114f <menu+0x2f>
lea    0xeb6(%rip),%rdi
call   1030 <printf@plt>
lea    0xedb(%rip),%rdi
call   1030 <printf@plt>
lea    0xeed(%rip),%rdi
call   1030 <printf@plt>
lea    0xef1(%rip),%rdi
call   1030 <printf@plt>
lea    0xf20(%rip),%rdi
call   1030 <printf@plt>
lea    0xf37(%rip),%rdi
call   1030 <printf@plt>
lea    0xf48(%rip),%rdi
call   1030 <printf@plt>
lea    0xf78(%rip),%rdi
call   1030 <printf@plt>
lea    0xf8b(%rip),%rdi
call   1030 <printf@plt>
lea    0xf91(%rip),%rdi
call   1030 <printf@plt>
lea    0xf94(%rip),%rdi
call   1030 <printf@plt>
lea    0xfa9(%rip),%rdi
call   1030 <printf@plt>
lea    0xfae(%rip),%rdi
call   1030 <printf@plt>
lea    0xfc0(%rip),%rdi
call   1030 <printf@plt>
lea    0xfbf(%rip),%rdi
lea    -0x4(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
cmp    $0x0,%rax
jne    1215 <menu+0xf5>
lea    0xfa6(%rip),%rdi
mov    $0x0,%al
call   1040 <scanf@plt>
jmp    121a <menu+0xfa>
mov    $0x1,%al
cmpl   $0x1,-0x4(%rbp)
mov    %al,-0x5(%rbp)
jl     1233 <menu+0x113>
cmpl   $0xb,-0x4(%rbp)
setg   %al
mov    %al,-0x5(%rbp)
mov    -0x5(%rbp),%al
test   $0x1,%al
jne    112f <menu+0xf>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<menu>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
movl   $0x1,0x4(%rsp)
mov    $0x1,%eax
lea    0xfe4(%rip),%rbx
lea    0xffd(%rip),%rbp
lea    0x1006(%rip),%r14
lea    0x101c(%rip),%r15
lea    0xea5(%rip),%r12
lea    0x4(%rsp),%r13
jmp    121a <menu+0xfa>
cs nopw 0x0(%rax,%rax,1)
nop
lea    0xe90(%rip),%rdi
call   1030 <puts@plt>
lea    0xea1(%rip),%rdi
call   1030 <puts@plt>
lea    0xea4(%rip),%rdi
call   1030 <puts@plt>
lea    0xed2(%rip),%rdi
call   1030 <puts@plt>
lea    0xee8(%rip),%rdi
call   1030 <puts@plt>
lea    0xef8(%rip),%rdi
call   1030 <puts@plt>
lea    0xf27(%rip),%rdi
call   1030 <puts@plt>
lea    0xf39(%rip),%rdi
call   1030 <puts@plt>
lea    0xf3e(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
mov    %rbp,%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
call   1030 <puts@plt>
mov    %r12,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
test   %rax,%rax
je     1240 <menu+0x120>
mov    0x4(%rsp),%eax
lea    -0xc(%rax),%ecx
cmp    $0xfffffff5,%ecx
jae    1250 <menu+0x130>
add    $0xfffffff4,%eax
cmp    $0xfffffff4,%eax
ja     1170 <menu+0x50>
lea    0xf4d(%rip),%rdi
call   1030 <puts@plt>
jmp    1170 <menu+0x50>
nopw   0x0(%rax,%rax,1)
lea    0xdbc(%rip),%rdi
xor    %eax,%eax
call   1040 <scanf@plt>
jmp    120e <menu+0xee>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [49 x i8] c"\0A*****Wrong selection. Select option 1-9*****\0A\0A\0A\00"
@.str.1 = [30 x i8] c"\0A*** SLL INTERFACE MENU ***\0A\0A\00"
@.str.2 = [16 x i8] c"Choose option:\0A\00"
@.str.3 = [59 x i8] c"1) Create new empty list (removes previously created one.\0A\00"
@.str.4 = [35 x i8] c"2) Add node at beginning of list.\0A\00"
@.str.5 = [29 x i8] c"3) Add node at end of list.\0A\00"
@.str.6 = [60 x i8] c"4) Add node in right place like list was sorted ascending.\0A\00"
@.str.7 = [31 x i8] c"5) Remove node from the list.\0A\00"
@.str.8 = [18 x i8] c"6) Reverse list.\0A\00"
@.str.9 = [15 x i8] c"7) Sort list.\0A\00"
@.str.10 = [33 x i8] c"8) Print all nodes in the list.\0A\00"
@.str.11 = [17 x i8] c"9) Remove list.\0A\00"
@.str.12 = [30 x i8] c"10) Count nodes in the list.\0A\00"
@.str.13 = [11 x i8] c"11) Quit.\0A\00"
@.str.14 = [3 x i8] c"%d\00"
@.str.15 = [4 x i8] c"%*s\00"
define i32 @menu() {
%1 = alloca i32
store i32 1, i32* %1
br label %2
2: ; preds = %35, %0
%3 = load i32, i32* %1
%4 = icmp slt i32 %3, 1
br i1 %4, label %8, label %5
5: ; preds = %2
%6 = load i32, i32* %1
%7 = icmp sgt i32 %6, 11
br i1 %7, label %8, label %10
8: ; preds = %5, %2
%9 = call i32 @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0))
br label %10
10: ; preds = %8, %5
%11 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0))
%12 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%13 = call i32 @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.3, i64 0, i64 0))
%14 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.4, i64 0, i64 0))
%15 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0))
%16 = call i32 @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.6, i64 0, i64 0))
%17 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.7, i64 0, i64 0))
%18 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.8, i64 0, i64 0))
%19 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.9, i64 0, i64 0))
%20 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.10, i64 0, i64 0))
%21 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.11, i64 0, i64 0))
%22 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.12, i64 0, i64 0))
%23 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.13, i64 0, i64 0))
%24 = call i64 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.14, i64 0, i64 0), i32* %1)
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %28
26: ; preds = %10
%27 = call i64 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.15, i64 0, i64 0))
br label %28
28: ; preds = %26, %10
br label %29
29: ; preds = %28
%30 = load i32, i32* %1
%31 = icmp slt i32 %30, 1
br i1 %31, label %35, label %32
32: ; preds = %29
%33 = load i32, i32* %1
%34 = icmp sgt i32 %33, 11
br label %35
35: ; preds = %32, %29
%36 = phi i1 [ true, %29 ], [ %34, %32 ]
br i1 %36, label %2, label %37
37: ; preds = %35
%38 = load i32, i32* %1
ret i32 %38
}

LLVM IR (-O2):
@.str.14 = [3 x i8] c"%d\00"
@.str.15 = [4 x i8] c"%*s\00"
@str = [29 x i8] c"\0A*** SLL INTERFACE MENU ***\0A\00"
@str.16 = [15 x i8] c"Choose option:\00"
@str.17 = [58 x i8] c"1) Create new empty list (removes previously created one.\00"
@str.18 = [34 x i8] c"2) Add node at beginning of list.\00"
@str.19 = [28 x i8] c"3) Add node at end of list.\00"
@str.20 = [59 x i8] c"4) Add node in right place like list was sorted ascending.\00"
@str.21 = [30 x i8] c"5) Remove node from the list.\00"
@str.22 = [17 x i8] c"6) Reverse list.\00"
@str.23 = [14 x i8] c"7) Sort list.\00"
@str.24 = [32 x i8] c"8) Print all nodes in the list.\00"
@str.25 = [16 x i8] c"9) Remove list.\00"
@str.26 = [29 x i8] c"10) Count nodes in the list.\00"
@str.27 = [10 x i8] c"11) Quit.\00"
@str.28 = [48 x i8] c"\0A*****Wrong selection. Select option 1-9*****\0A\0A\00"
define i32 @menu() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i32 1, i32* %1
br label %3
3: ; preds = %27, %0
%4 = phi i32 [ %28, %27 ], [ 1, %0 ]
%5 = add i32 %4, -12
%6 = icmp ult i32 %5, -11
br i1 %6, label %7, label %9
7: ; preds = %3
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @str.28, i64 0, i64 0))
br label %9
9: ; preds = %3, %7
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0))
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.16, i64 0, i64 0))
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([58 x i8], [58 x i8]* @str.17, i64 0, i64 0))
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str.18, i64 0, i64 0))
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.19, i64 0, i64 0))
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([59 x i8], [59 x i8]* @str.20, i64 0, i64 0))
%16 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str.21, i64 0, i64 0))
%17 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.22, i64 0, i64 0))
%18 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.23, i64 0, i64 0))
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.24, i64 0, i64 0))
%20 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.25, i64 0, i64 0))
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.26, i64 0, i64 0))
%22 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.27, i64 0, i64 0))
%23 = call i64 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.14, i64 0, i64 0), i32* %1)
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %9
%26 = call i64 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.15, i64 0, i64 0))
br label %27
27: ; preds = %9, %25
%28 = load i32, i32* %1
%29 = add i32 %28, -12
%30 = icmp ult i32 %29, -11
br i1 %30, label %3, label %31
31: ; preds = %27
ret i32 %28
}