#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 /*<<< orphan*/ pop();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ push();
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int choice, flag = 0;
start:
  printf("\n***********************Menu**************************\n");
  printf("1.)display the stack\n");
  printf("2.)push an element into the stack\n");
  printf("3.)pop an element from the stack\n");
  printf("4.)exit\n");
  printf("\n\nenter your choice=");
  scanf("%d", &choice);
  switch (choice) {
  case 1:
    display();
    break;
  case 2:
    push();
    break;
  case 3:
    pop();
    break;
  case 4:
    flag = 1;
    break;
  default:
    printf("\n\nPlease enter a valid choice\n\n");
    goto start;
  }
  if (flag == 0) {
    goto start;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
lea    0xea3(%rip),%rdi
call   1040 <printf@plt>
lea    0xecf(%rip),%rdi
call   1040 <printf@plt>
lea    0xed9(%rip),%rdi
call   1040 <printf@plt>
lea    0xef0(%rip),%rdi
call   1040 <printf@plt>
lea    0xf06(%rip),%rdi
call   1040 <printf@plt>
lea    0xf03(%rip),%rdi
call   1040 <printf@plt>
lea    0xf0c(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1060 <scanf@plt>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x3,%eax
ja     1217 <main+0xc7>
mov    -0x18(%rbp),%rax
lea    0xe22(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x0,%al
call   1030 <display@plt>
jmp    1228 <main+0xd8>
mov    $0x0,%al
call   1070 <push@plt>
jmp    1228 <main+0xd8>
mov    $0x0,%al
call   1050 <pop@plt>
jmp    1228 <main+0xd8>
movl   $0x1,-0xc(%rbp)
jmp    1228 <main+0xd8>
lea    0xea6(%rip),%rdi
call   1040 <printf@plt>
jmp    1166 <main+0x16>
cmpl   $0x0,-0xc(%rbp)
jne    1237 <main+0xe7>
jmp    1166 <main+0x16>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xf24(%rip),%r13
lea    0xf3e(%rip),%rbx
lea    0xe90(%rip),%rbp
lea    0xe9e(%rip),%r14
lea    0x4(%rsp),%r15
lea    0xe6d(%rip),%r12
jmp    11a7 <main+0x47>
cs nopw 0x0(%rax,%rax,1)
nop
xor    %eax,%eax
call   1060 <pop@plt>
lea    0xe7a(%rip),%rdi
call   1030 <puts@plt>
lea    0xea5(%rip),%rdi
call   1030 <puts@plt>
lea    0xeae(%rip),%rdi
call   1030 <puts@plt>
mov    %r13,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
mov    %rbp,%rdi
call   1050 <printf@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   1070 <scanf@plt>
mov    0x4(%rsp),%eax
add    $0xffffffff,%eax
cmp    $0x3,%eax
ja     1210 <main+0xb0>
movslq (%r12,%rax,4),%rax
add    %r12,%rax
jmp    *%rax
xor    %eax,%eax
call   1040 <display@plt>
jmp    11a7 <main+0x47>
nopl   0x0(%rax)
lea    0xea8(%rip),%rdi
call   1030 <puts@plt>
jmp    11a7 <main+0x47>
xchg   %ax,%ax
xor    %eax,%eax
call   1080 <push@plt>
jmp    11a7 <main+0x47>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [56 x i8] c"\0A***********************Menu**************************\0A\00"
@.str.1 = [22 x i8] c"1.)display the stack\0A\00"
@.str.2 = [35 x i8] c"2.)push an element into the stack\0A\00"
@.str.3 = [34 x i8] c"3.)pop an element from the stack\0A\00"
@.str.4 = [9 x i8] c"4.)exit\0A\00"
@.str.5 = [21 x i8] c"\0A\0Aenter your choice=\00"
@.str.6 = [3 x i8] c"%d\00"
@.str.7 = [32 x i8] c"\0A\0APlease enter a valid choice\0A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
br label %4
4: ; preds = %25, %20, %0
%5 = call i32 @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0))
%9 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%10 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %2)
%12 = load i32, i32* %2
switch i32 %12, label %20 [
i32 1, label %13
i32 2, label %15
i32 3, label %17
i32 4, label %19
]
13: ; preds = %4
%14 = call i32 (...) @display()
br label %22
15: ; preds = %4
%16 = call i32 (...) @push()
br label %22
17: ; preds = %4
%18 = call i32 (...) @pop()
br label %22
19: ; preds = %4
store i32 1, i32* %3
br label %22
20: ; preds = %4
%21 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.7, i64 0, i64 0))
br label %4
22: ; preds = %19, %17, %15, %13
%23 = load i32, i32* %3
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %26
25: ; preds = %22
br label %4
26: ; preds = %22
%27 = load i32, i32* %1
ret i32 %27
}

LLVM IR (-O2):
@.str.5 = [21 x i8] c"\0A\0Aenter your choice=\00"
@.str.6 = [3 x i8] c"%d\00"
@str = [55 x i8] c"\0A***********************Menu**************************\00"
@str.8 = [21 x i8] c"1.)display the stack\00"
@str.9 = [34 x i8] c"2.)push an element into the stack\00"
@str.10 = [33 x i8] c"3.)pop an element from the stack\00"
@str.11 = [8 x i8] c"4.)exit\00"
@str.12 = [31 x i8] c"\0A\0APlease enter a valid choice\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
br label %3
3: ; preds = %20, %0
%4 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @str, i64 0, i64 0))
%5 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.8, i64 0, i64 0))
%6 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str.9, i64 0, i64 0))
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.10, i64 0, i64 0))
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.11, i64 0, i64 0))
%9 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %1)
%11 = load i32, i32* %1
switch i32 %11, label %18 [
i32 1, label %12
i32 2, label %14
i32 3, label %16
i32 4, label %21
]
12: ; preds = %3
%13 = call i32 (...) @display()
br label %20
14: ; preds = %3
%15 = call i32 (...) @push()
br label %20
16: ; preds = %3
%17 = call i32 (...) @pop()
br label %20
18: ; preds = %3
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.12, i64 0, i64 0))
br label %20
20: ; preds = %18, %16, %14, %12
br label %3
21: ; preds = %3
ret i32 0
}