#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 getInsertPosition();
int getInsertQuantity();
int /*<<< orphan*/ getMultipleEntries(int, int);
int /*<<< orphan*/ getOneEntry(int);
int /*<<< orphan*/ printEntries(int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ saveMultipleEntries(int, int);
int /*<<< orphan*/ saveOneEntry(int);
int /*<<< orphan*/ scanf(char *, int *);
int menu() {
  int menu, status = 0, position, quantity;
  do {
    printf("\n[1] Create and insert one entry");
    printf("\n[2] Create and insert multiple entries");
    printf("\n[3] Find and print one entry");
    printf("\n[4] Find and print multiple entries");
    scanf("%d", &menu);
    switch (menu) {
    case 1:
      status = 0;
      position = getInsertPosition();
      saveOneEntry(position);
      break;
    case 2:
      status = 0;
      position = getInsertPosition();
      quantity = getInsertQuantity();
      saveMultipleEntries(position, quantity);
      break;
    case 3:
      status = 0;
      position = getInsertPosition();
      printEntries(getOneEntry(position), 1);
      break;
    case 4:
      status = 0;
      position = getInsertPosition();
      quantity = getInsertQuantity();
      printEntries(getMultipleEntries(position, quantity), quantity);
      break;
    default:
      status = 1;
      printf("\nPlease, select a valid option!!!");
      break;
    }
  } while (status == 1);
}


x86 assembly (clang, -O0):
<menu>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0xc(%rbp)
lea    0xe6a(%rip),%rdi
call   1060 <printf@plt>
lea    0xe7f(%rip),%rdi
call   1060 <printf@plt>
lea    0xe9b(%rip),%rdi
call   1060 <printf@plt>
lea    0xead(%rip),%rdi
call   1060 <printf@plt>
lea    0xec6(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   10a0 <scanf@plt>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x3,%eax
ja     12b0 <menu+0x120>
mov    -0x20(%rbp),%rax
lea    0xe01(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x0,-0xc(%rbp)
mov    $0x0,%al
call   1050 <getInsertPosition@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%edi
call   1090 <saveOneEntry@plt>
jmp    12c3 <menu+0x133>
movl   $0x0,-0xc(%rbp)
mov    $0x0,%al
call   1050 <getInsertPosition@plt>
mov    %eax,-0x10(%rbp)
mov    $0x0,%al
call   1080 <getInsertQuantity@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%edi
mov    -0x14(%rbp),%esi
call   10b0 <saveMultipleEntries@plt>
jmp    12c3 <menu+0x133>
movl   $0x0,-0xc(%rbp)
mov    $0x0,%al
call   1050 <getInsertPosition@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%edi
call   1030 <getOneEntry@plt>
mov    %eax,%edi
mov    $0x1,%esi
call   1040 <printEntries@plt>
jmp    12c3 <menu+0x133>
movl   $0x0,-0xc(%rbp)
mov    $0x0,%al
call   1050 <getInsertPosition@plt>
mov    %eax,-0x10(%rbp)
mov    $0x0,%al
call   1080 <getInsertQuantity@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%edi
mov    -0x14(%rbp),%esi
call   1070 <getMultipleEntries@plt>
mov    %eax,%edi
mov    -0x14(%rbp),%esi
call   1040 <printEntries@plt>
jmp    12c3 <menu+0x133>
movl   $0x1,-0xc(%rbp)
lea    0xde1(%rip),%rdi
call   1060 <printf@plt>
jmp    12c8 <menu+0x138>
cmpl   $0x1,-0xc(%rbp)
je     119f <menu+0xf>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<menu>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xe6e(%rip),%r14
lea    0xe88(%rip),%r15
lea    0xea9(%rip),%r12
lea    0xec0(%rip),%r13
lea    0xede(%rip),%rbx
lea    0x4(%rsp),%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r14,%rdi
call   1060 <printf@plt>
mov    %r15,%rdi
call   1060 <printf@plt>
mov    %r12,%rdi
call   1060 <printf@plt>
mov    %r13,%rdi
call   1060 <printf@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   10a0 <scanf@plt>
mov    0x4(%rsp),%eax
add    $0xffffffff,%eax
cmp    $0x3,%eax
jbe    1215 <menu+0x85>
lea    0xe91(%rip),%rdi
call   1060 <printf@plt>
jmp    11d0 <menu+0x40>
lea    0xde4(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
xor    %eax,%eax
call   1050 <getInsertPosition@plt>
mov    %eax,%edi
call   1090 <saveOneEntry@plt>
jmp    1290 <menu+0x100>
xor    %eax,%eax
call   1050 <getInsertPosition@plt>
mov    %eax,%edi
call   1030 <getOneEntry@plt>
mov    %eax,%edi
mov    $0x1,%esi
call   1040 <printEntries@plt>
jmp    1290 <menu+0x100>
xor    %eax,%eax
call   1050 <getInsertPosition@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1080 <getInsertQuantity@plt>
mov    %eax,%ebp
mov    %ebx,%edi
mov    %eax,%esi
call   1070 <getMultipleEntries@plt>
mov    %eax,%edi
mov    %ebp,%esi
call   1040 <printEntries@plt>
jmp    1290 <menu+0x100>
xor    %eax,%eax
call   1050 <getInsertPosition@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1080 <getInsertQuantity@plt>
mov    %ebx,%edi
mov    %eax,%esi
call   10b0 <saveMultipleEntries@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [33 x i8] c"\0A[1] Create and insert one entry\00"
@.str.1 = [40 x i8] c"\0A[2] Create and insert multiple entries\00"
@.str.2 = [30 x i8] c"\0A[3] Find and print one entry\00"
@.str.3 = [37 x i8] c"\0A[4] Find and print multiple entries\00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [34 x i8] c"\0APlease, select a valid option!!!\00"
define i32 @menu() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %3
br label %6
6: ; preds = %39, %0
%7 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %2)
%12 = load i32, i32* %2
switch i32 %12, label %36 [
i32 1, label %13
i32 2, label %17
i32 3, label %23
i32 4, label %28
]
13: ; preds = %6
store i32 0, i32* %3
%14 = call i32 (...) @getInsertPosition()
store i32 %14, i32* %4
%15 = load i32, i32* %4
%16 = call i32 @saveOneEntry(i32 %15)
br label %38
17: ; preds = %6
store i32 0, i32* %3
%18 = call i32 (...) @getInsertPosition()
store i32 %18, i32* %4
%19 = call i32 (...) @getInsertQuantity()
store i32 %19, i32* %5
%20 = load i32, i32* %4
%21 = load i32, i32* %5
%22 = call i32 @saveMultipleEntries(i32 %20, i32 %21)
br label %38
23: ; preds = %6
store i32 0, i32* %3
%24 = call i32 (...) @getInsertPosition()
store i32 %24, i32* %4
%25 = load i32, i32* %4
%26 = call i32 @getOneEntry(i32 %25)
%27 = call i32 @printEntries(i32 %26, i32 1)
br label %38
28: ; preds = %6
store i32 0, i32* %3
%29 = call i32 (...) @getInsertPosition()
store i32 %29, i32* %4
%30 = call i32 (...) @getInsertQuantity()
store i32 %30, i32* %5
%31 = load i32, i32* %4
%32 = load i32, i32* %5
%33 = call i32 @getMultipleEntries(i32 %31, i32 %32)
%34 = load i32, i32* %5
%35 = call i32 @printEntries(i32 %33, i32 %34)
br label %38
36: ; preds = %6
store i32 1, i32* %3
%37 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.5, i64 0, i64 0))
br label %38
38: ; preds = %36, %28, %23, %17, %13
br label %39
39: ; preds = %38
%40 = load i32, i32* %3
%41 = icmp eq i32 %40, 1
br i1 %41, label %6, label %42
42: ; preds = %39
%43 = load i32, i32* %1
ret i32 %43
}

LLVM IR (-O2):
@.str = [33 x i8] c"\0A[1] Create and insert one entry\00"
@.str.1 = [40 x i8] c"\0A[2] Create and insert multiple entries\00"
@.str.2 = [30 x i8] c"\0A[3] Find and print one entry\00"
@.str.3 = [37 x i8] c"\0A[4] Find and print multiple entries\00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [34 x i8] c"\0APlease, select a valid option!!!\00"
define i32 @menu() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
br label %3
3: ; preds = %26, %0
%4 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0))
%6 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
%7 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %1)
%9 = load i32, i32* %1
switch i32 %9, label %26 [
i32 1, label %10
i32 2, label %13
i32 3, label %17
i32 4, label %21
]
10: ; preds = %3
%11 = call i32 (...) @getInsertPosition()
%12 = call i32 @saveOneEntry(i32 %11)
br label %28
13: ; preds = %3
%14 = call i32 (...) @getInsertPosition()
%15 = call i32 (...) @getInsertQuantity()
%16 = call i32 @saveMultipleEntries(i32 %14, i32 %15)
br label %28
17: ; preds = %3
%18 = call i32 (...) @getInsertPosition()
%19 = call i32 @getOneEntry(i32 %18)
%20 = call i32 @printEntries(i32 %19, i32 1)
br label %28
21: ; preds = %3
%22 = call i32 (...) @getInsertPosition()
%23 = call i32 (...) @getInsertQuantity()
%24 = call i32 @getMultipleEntries(i32 %22, i32 %23)
%25 = call i32 @printEntries(i32 %24, i32 %23)
br label %28
26: ; preds = %3
%27 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.5, i64 0, i64 0))
br label %3
28: ; preds = %21, %17, %13, %10
ret i32 undef
}