#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*/ destroy();
int /*<<< orphan*/ display();
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ pop();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ push(int);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ stackfull();
int /*<<< orphan*/ stacksize();
int /*<<< orphan*/ system(char *);
void main() {
  int choice, value;
  system("clear");
  while (1) {
    printf("Enter Your choice:\n");
    printf("1.PUSH\n2.POP\n3.DISPLAY\n4.STACKSIZE\n5.DESTROY\n6.STACKFULL "
           "CHECK\n7.EXIT\n\tChoice: ");
    scanf("%d", &choice);
    switch (choice) {
    case 1:
      printf("Enter the value to be pushed on to the stack: ");
      scanf("%d", &value);
      push(value);
      continue;
    case 2:
      pop();
      continue;
    case 3:
      display();
      continue;
    case 4:
      stacksize();
      continue;
    case 5:
      destroy();
      continue;
    case 6:
      stackfull();
      continue;
    case 7:
      exit(0);
    default:
      printf("YOU HAVE ENTERD A WRONG CHOICE");
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xe6d(%rip),%rdi
call   1040 <system@plt>
lea    0xe67(%rip),%rdi
call   1050 <printf@plt>
lea    0xe6f(%rip),%rdi
call   1050 <printf@plt>
lea    0xeb3(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1090 <scanf@plt>
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x6,%eax
ja     1271 <main+0xd1>
mov    -0x10(%rbp),%rax
lea    0xe04(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xe7d(%rip),%rdi
call   1050 <printf@plt>
lea    0xe6e(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1090 <scanf@plt>
mov    -0x8(%rbp),%edi
call   10a0 <push@plt>
jmp    11b4 <main+0x14>
mov    $0x0,%al
call   1060 <pop@plt>
jmp    11b4 <main+0x14>
mov    $0x0,%al
call   1030 <display@plt>
jmp    11b4 <main+0x14>
mov    $0x0,%al
call   10c0 <stacksize@plt>
jmp    11b4 <main+0x14>
mov    $0x0,%al
call   1070 <destroy@plt>
jmp    11b4 <main+0x14>
mov    $0x0,%al
call   1080 <stackfull@plt>
jmp    11b4 <main+0x14>
xor    %edi,%edi
call   10b0 <exit@plt>
lea    0xe40(%rip),%rdi
call   1050 <printf@plt>
jmp    11b4 <main+0x14>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xe5a(%rip),%rdi
call   1050 <system@plt>
lea    0xef5(%rip),%r14
lea    0xe4d(%rip),%r15
lea    0xe96(%rip),%rbx
lea    0x4(%rsp),%r12
lea    0xe18(%rip),%rbp
mov    %rsp,%r13
jmp    1200 <main+0x50>
xor    %eax,%eax
call   1090 <stackfull@plt>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
call   1060 <printf@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   10a0 <scanf@plt>
mov    0x4(%rsp),%eax
add    $0xffffffff,%eax
cmp    $0x6,%eax
ja     1252 <main+0xa2>
movslq 0x0(%rbp,%rax,4),%rax
add    %rbp,%rax
jmp    *%rax
lea    0xe3d(%rip),%rdi
call   1060 <printf@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   10a0 <scanf@plt>
mov    (%rsp),%edi
call   10b0 <push@plt>
jmp    1200 <main+0x50>
lea    0xe4b(%rip),%rdi
call   1060 <printf@plt>
jmp    1200 <main+0x50>
xor    %eax,%eax
call   1070 <pop@plt>
jmp    1200 <main+0x50>
xor    %eax,%eax
call   1040 <display@plt>
jmp    1200 <main+0x50>
xor    %eax,%eax
call   10d0 <stacksize@plt>
jmp    1200 <main+0x50>
xor    %eax,%eax
call   1080 <destroy@plt>
jmp    1200 <main+0x50>
xor    %edi,%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
@.str = [6 x i8] c"clear\00"
@.str.1 = [20 x i8] c"Enter Your choice:\0A\00"
@.str.2 = [80 x i8] c"1.PUSH\0A2.POP\0A3.DISPLAY\0A4.STACKSIZE\0A5.DESTROY\0A6.STACKFULL CHECK\0A7.EXIT\0A\09Choice: \00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [47 x i8] c"Enter the value to be pushed on to the stack: \00"
@.str.5 = [31 x i8] c"YOU HAVE ENTERD A WRONG CHOICE\00"
define void @main() {
%1 = alloca i32
%2 = alloca i32
%3 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
br label %4
4: ; preds = %0, %9, %14, %16, %18, %20, %22, %28
%5 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%6 = call i32 @printf(i8* getelementptr inbounds ([80 x i8], [80 x i8]* @.str.2, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %1)
%8 = load i32, i32* %1
switch i32 %8, label %26 [
i32 1, label %9
i32 2, label %14
i32 3, label %16
i32 4, label %18
i32 5, label %20
i32 6, label %22
i32 7, label %24
]
9: ; preds = %4
%10 = call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.4, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %2)
%12 = load i32, i32* %2
%13 = call i32 @push(i32 %12)
br label %4
14: ; preds = %4
%15 = call i32 (...) @pop()
br label %4
16: ; preds = %4
%17 = call i32 (...) @display()
br label %4
18: ; preds = %4
%19 = call i32 (...) @stacksize()
br label %4
20: ; preds = %4
%21 = call i32 (...) @destroy()
br label %4
22: ; preds = %4
%23 = call i32 (...) @stackfull()
br label %4
24: ; preds = %4
%25 = call i32 @exit(i32 0)
unreachable
26: ; preds = %4
%27 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.5, i64 0, i64 0))
br label %28
28: ; preds = %26
br label %4
}

LLVM IR (-O2):
@.str = [6 x i8] c"clear\00"
@.str.2 = [80 x i8] c"1.PUSH\0A2.POP\0A3.DISPLAY\0A4.STACKSIZE\0A5.DESTROY\0A6.STACKFULL CHECK\0A7.EXIT\0A\09Choice: \00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [47 x i8] c"Enter the value to be pushed on to the stack: \00"
@.str.5 = [31 x i8] c"YOU HAVE ENTERD A WRONG CHOICE\00"
@str = [19 x i8] c"Enter Your choice:\00"
define void @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
br label %6
6: ; preds = %16, %0
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
%8 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([80 x i8], [80 x i8]* @.str.2, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %1)
%10 = load i32, i32* %1
switch i32 %10, label %29 [
i32 1, label %11
i32 2, label %17
i32 3, label %19
i32 4, label %21
i32 5, label %23
i32 6, label %25
i32 7, label %27
]
11: ; preds = %6
%12 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @.str.4, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %2)
%14 = load i32, i32* %2
%15 = call i32 @push(i32 %14)
br label %16
16: ; preds = %11, %17, %19, %21, %23, %25, %29
br label %6
17: ; preds = %6
%18 = call i32 (...) @pop()
br label %16
19: ; preds = %6
%20 = call i32 (...) @display()
br label %16
21: ; preds = %6
%22 = call i32 (...) @stacksize()
br label %16
23: ; preds = %6
%24 = call i32 (...) @destroy()
br label %16
25: ; preds = %6
%26 = call i32 (...) @stackfull()
br label %16
27: ; preds = %6
%28 = call i32 @exit(i32 0)
unreachable
29: ; preds = %6
%30 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.5, i64 0, i64 0))
br label %16
}