#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*/ DISPLAY(int, int *);
int /*<<< orphan*/ POP(int, int *);
int /*<<< orphan*/ PUSH(int, int *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int MENU(int MAX, int STACK[]) {
  int option;
  printf("\n--------------------");
  printf("\n*****MAIN MENU*****");
  printf("\nEnter 1. To PUSH");
  printf("\nEnter 2. To POP");
  printf("\nEnter 3. To DISPLAY");
  printf("\nEnter 4. To EXIT");
  printf("\n____________________\n");
  printf("\nEnter your choice : ");
  scanf("%d", &option);
  printf("\n--------------------\n\n");
  switch (option) {
  case 1: {
    PUSH(MAX, STACK);
    MENU(MAX, STACK);
  } break;
  case 2: {
    POP(MAX, STACK);
    MENU(MAX, STACK);
  } break;
  case 3: {
    DISPLAY(MAX, STACK);
    MENU(MAX, STACK);
  } break;
  case 4:
    return 0;
    break;
  default: {
    printf("\nSorry ...!\nWrong entry...\nPlease enter the correct one.\n\n");
    MENU(MAX, STACK);
  } break;
  }
  return 0;
}


x86 assembly (clang, -O0):
<MENU>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe9a(%rip),%rdi
call   1030 <printf@plt>
lea    0xea4(%rip),%rdi
call   1030 <printf@plt>
lea    0xead(%rip),%rdi
call   1030 <printf@plt>
lea    0xeb3(%rip),%rdi
call   1030 <printf@plt>
lea    0xeb8(%rip),%rdi
call   1030 <printf@plt>
lea    0xec1(%rip),%rdi
call   1030 <printf@plt>
lea    0xec7(%rip),%rdi
call   1030 <printf@plt>
lea    0xed2(%rip),%rdi
call   1030 <printf@plt>
lea    0xedc(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1080 <scanf@plt>
lea    0xecf(%rip),%rdi
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x3,%eax
ja     1277 <MENU+0x117>
mov    -0x20(%rbp),%rax
lea    0xdf5(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1060 <PUSH@plt>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1050 <MENU@plt>
jmp    128f <MENU+0x12f>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1040 <POP@plt>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1050 <MENU@plt>
jmp    128f <MENU+0x12f>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1070 <DISPLAY@plt>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1050 <MENU@plt>
jmp    128f <MENU+0x12f>
movl   $0x0,-0x4(%rbp)
jmp    1296 <MENU+0x136>
lea    0xe4f(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1050 <MENU@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<MENU>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0xe91(%rip),%rdi
call   1040 <printf@plt>
lea    0xe9b(%rip),%rdi
call   1040 <printf@plt>
lea    0xea4(%rip),%rdi
call   1040 <printf@plt>
lea    0xeaa(%rip),%rdi
call   1040 <printf@plt>
lea    0xeaf(%rip),%rdi
call   1040 <printf@plt>
lea    0xeb8(%rip),%rdi
call   1040 <printf@plt>
lea    0xed7(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb2(%rip),%rdi
call   1040 <printf@plt>
lea    0xebc(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1090 <scanf@plt>
lea    0xec4(%rip),%rdi
call   1030 <puts@plt>
mov    0x4(%rsp),%eax
add    $0xffffffff,%eax
cmp    $0x3,%eax
ja     121d <MENU+0xad>
lea    0xdf8(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    %ebp,%edi
mov    %rbx,%rsi
call   1070 <PUSH@plt>
jmp    1241 <MENU+0xd1>
lea    0xea7(%rip),%rdi
call   1030 <puts@plt>
jmp    1241 <MENU+0xd1>
mov    %ebp,%edi
mov    %rbx,%rsi
call   1050 <POP@plt>
jmp    1241 <MENU+0xd1>
mov    %ebp,%edi
mov    %rbx,%rsi
call   1080 <DISPLAY@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
call   1060 <MENU@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [22 x i8] c"\0A--------------------\00"
@.str.1 = [21 x i8] c"\0A*****MAIN MENU*****\00"
@.str.2 = [18 x i8] c"\0AEnter 1. To PUSH\00"
@.str.3 = [17 x i8] c"\0AEnter 2. To POP\00"
@.str.4 = [21 x i8] c"\0AEnter 3. To DISPLAY\00"
@.str.5 = [18 x i8] c"\0AEnter 4. To EXIT\00"
@.str.6 = [23 x i8] c"\0A____________________\0A\00"
@.str.7 = [22 x i8] c"\0AEnter your choice : \00"
@.str.8 = [3 x i8] c"%d\00"
@.str.9 = [24 x i8] c"\0A--------------------\0A\0A\00"
@.str.10 = [59 x i8] c"\0ASorry ...!\0AWrong entry...\0APlease enter the correct one.\0A\0A\00"
define i32 @MENU(i32 %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32
store i32 %0, i32* %4
store i32* %1, i32** %5
%7 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
%11 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0))
%12 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0))
%13 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0))
%14 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i32* %6)
%16 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.9, i64 0, i64 0))
%17 = load i32, i32* %6
switch i32 %17, label %40 [
i32 1, label %18
i32 2, label %25
i32 3, label %32
i32 4, label %39
]
18: ; preds = %2
%19 = load i32, i32* %4
%20 = load i32*, i32** %5
%21 = call i32 @PUSH(i32 %19, i32* %20)
%22 = load i32, i32* %4
%23 = load i32*, i32** %5
%24 = call i32 @MENU(i32 %22, i32* %23)
br label %45
25: ; preds = %2
%26 = load i32, i32* %4
%27 = load i32*, i32** %5
%28 = call i32 @POP(i32 %26, i32* %27)
%29 = load i32, i32* %4
%30 = load i32*, i32** %5
%31 = call i32 @MENU(i32 %29, i32* %30)
br label %45
32: ; preds = %2
%33 = load i32, i32* %4
%34 = load i32*, i32** %5
%35 = call i32 @DISPLAY(i32 %33, i32* %34)
%36 = load i32, i32* %4
%37 = load i32*, i32** %5
%38 = call i32 @MENU(i32 %36, i32* %37)
br label %45
39: ; preds = %2
store i32 0, i32* %3
br label %46
40: ; preds = %2
%41 = call i32 @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.10, i64 0, i64 0))
%42 = load i32, i32* %4
%43 = load i32*, i32** %5
%44 = call i32 @MENU(i32 %42, i32* %43)
br label %45
45: ; preds = %40, %32, %25, %18
store i32 0, i32* %3
br label %46
46: ; preds = %45, %39
%47 = load i32, i32* %3
ret i32 %47
}

LLVM IR (-O2):
@.str = [22 x i8] c"\0A--------------------\00"
@.str.1 = [21 x i8] c"\0A*****MAIN MENU*****\00"
@.str.2 = [18 x i8] c"\0AEnter 1. To PUSH\00"
@.str.3 = [17 x i8] c"\0AEnter 2. To POP\00"
@.str.4 = [21 x i8] c"\0AEnter 3. To DISPLAY\00"
@.str.5 = [18 x i8] c"\0AEnter 4. To EXIT\00"
@.str.7 = [22 x i8] c"\0AEnter your choice : \00"
@.str.8 = [3 x i8] c"%d\00"
@str = [22 x i8] c"\0A____________________\00"
@str.11 = [23 x i8] c"\0A--------------------\0A\00"
@str.12 = [58 x i8] c"\0ASorry ...!\0AWrong entry...\0APlease enter the correct one.\0A\00"
define i32 @MENU(i32 %0, i32* %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%6 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
%7 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
%8 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
%9 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0))
%10 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0))
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
%12 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i32* %3)
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.11, i64 0, i64 0))
%15 = load i32, i32* %3
switch i32 %15, label %22 [
i32 1, label %16
i32 2, label %18
i32 3, label %20
i32 4, label %26
]
16: ; preds = %2
%17 = call i32 @PUSH(i32 %0, i32* %1)
br label %24
18: ; preds = %2
%19 = call i32 @POP(i32 %0, i32* %1)
br label %24
20: ; preds = %2
%21 = call i32 @DISPLAY(i32 %0, i32* %1)
br label %24
22: ; preds = %2
%23 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([58 x i8], [58 x i8]* @str.12, i64 0, i64 0))
br label %24
24: ; preds = %22, %20, %18, %16
%25 = call i32 @MENU(i32 %0, i32* %1)
br label %26
26: ; preds = %24, %2
ret i32 0
}