#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 Pop();
int /*<<< orphan*/ Push(int);
int Top();
int /*<<< orphan*/ isEmpty();
int /*<<< orphan*/ isFull();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
void main(void) {
  int choice, element, temp, flag = 1;
  while (flag) {
    printf("\n\nStack Operations");
    printf("\n----------------");
    printf("\n1. Push");
    printf("\n2. Pop");
    printf("\n3. Top");
    printf("\n4. Display");
    printf("\n5. Exit");
    printf("\n----------------");
    printf("\nEnter your choice: ");
    scanf("%d", &choice);
    switch (choice) {
    case 1: {
      if (!isFull()) {
        printf("\nEnter element to be pushed: ");
        scanf("%d", &element);
        Push(element);
        printf("\nPushed Element: %d", element);
      } else {
        printf("\nStack Overflow..");
      }
      break;
    }
    case 2: {
      if (!isEmpty()) {
        temp = Pop();
        printf("Popped Element: %d ", temp);
      } else {
        printf("\nStack Underflow..");
      }
      break;
    }
    case 3: {
      if (!isEmpty()) {
        temp = Top();
        printf("\nTop Element: %d", temp);
      } else {
        printf("\nStack is Empty");
      }
      break;
    }
    case 4: {
      Display();
      break;
    }
    case 5: {
      flag = 0;
      break;
    }
    default: {
      printf("\nInvalid Choice");
    }
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x1,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     136c <main+0x1ec>
lea    0xe74(%rip),%rdi
xor    %eax,%eax
mov    %al,-0x19(%rbp)
call   1030 <printf@plt>
mov    -0x19(%rbp),%al
lea    0xe73(%rip),%rdi
mov    %rdi,-0x28(%rbp)
call   1030 <printf@plt>
mov    -0x19(%rbp),%al
lea    0xe72(%rip),%rdi
call   1030 <printf@plt>
mov    -0x19(%rbp),%al
lea    0xe6c(%rip),%rdi
call   1030 <printf@plt>
mov    -0x19(%rbp),%al
lea    0xe65(%rip),%rdi
call   1030 <printf@plt>
mov    -0x19(%rbp),%al
lea    0xe5e(%rip),%rdi
call   1030 <printf@plt>
mov    -0x19(%rbp),%al
lea    0xe5b(%rip),%rdi
call   1030 <printf@plt>
mov    -0x28(%rbp),%rdi
mov    -0x19(%rbp),%al
call   1030 <printf@plt>
mov    -0x19(%rbp),%al
lea    0xe49(%rip),%rdi
call   1030 <printf@plt>
lea    0xe81(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1090 <scanf@plt>
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x4,%eax
ja     1359 <main+0x1d9>
mov    -0x18(%rbp),%rax
lea    0xdad(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x0,%al
call   10a0 <isFull@plt>
cmp    $0x0,%eax
jne    12a8 <main+0x128>
lea    0xe09(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe2a(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1090 <scanf@plt>
mov    -0x8(%rbp),%edi
call   1060 <Push@plt>
mov    -0x8(%rbp),%esi
lea    0xdfe(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12b6 <main+0x136>
lea    0xdff(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1367 <main+0x1e7>
mov    $0x0,%al
call   1070 <isEmpty@plt>
cmp    $0x0,%eax
jne    12eb <main+0x16b>
mov    $0x0,%al
call   1040 <Pop@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xde1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12f9 <main+0x179>
lea    0xde2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1367 <main+0x1e7>
mov    $0x0,%al
call   1070 <isEmpty@plt>
cmp    $0x0,%eax
jne    132e <main+0x1ae>
mov    $0x0,%al
call   1050 <Top@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xdc5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    133c <main+0x1bc>
lea    0xdc3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1367 <main+0x1e7>
mov    $0x0,%al
call   1080 <Display@plt>
jmp    1367 <main+0x1e7>
movl   $0x0,-0x10(%rbp)
jmp    1367 <main+0x1e7>
lea    0xda8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    118f <main+0xf>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xe95(%rip),%rbx
lea    0xec5(%rip),%r14
lea    0xec7(%rip),%r15
lea    0xf04(%rip),%r12
lea    0x4(%rsp),%r13
lea    0xe4d(%rip),%rbp
jmp    11c3 <main+0x43>
lea    0xf4c(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe4a(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe57(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe52(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe4c(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe46(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r12,%rdi
mov    %r13,%rsi
call   1090 <scanf@plt>
mov    0x4(%rsp),%eax
add    $0xffffffff,%eax
cmp    $0x4,%eax
ja     11b5 <main+0x35>
movslq 0x0(%rbp,%rax,4),%rax
add    %rbp,%rax
jmp    *%rax
xor    %eax,%eax
call   10a0 <isFull@plt>
test   %eax,%eax
je     12a7 <main+0x127>
lea    0xe46(%rip),%rdi
jmp    11bc <main+0x3c>
xor    %eax,%eax
call   1070 <isEmpty@plt>
test   %eax,%eax
je     12d4 <main+0x154>
lea    0xe55(%rip),%rdi
jmp    11bc <main+0x3c>
xor    %eax,%eax
call   1070 <isEmpty@plt>
test   %eax,%eax
je     12e4 <main+0x164>
lea    0xe62(%rip),%rdi
jmp    11bc <main+0x3c>
xor    %eax,%eax
call   1080 <Display@plt>
jmp    11c3 <main+0x43>
lea    0xdce(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r12,%rdi
mov    %rsp,%rsi
call   1090 <scanf@plt>
mov    (%rsp),%edi
call   1060 <Push@plt>
mov    (%rsp),%esi
lea    0xdc8(%rip),%rdi
jmp    12f4 <main+0x174>
xor    %eax,%eax
call   1040 <Pop@plt>
lea    0xdde(%rip),%rdi
jmp    12f2 <main+0x172>
xor    %eax,%eax
call   1050 <Top@plt>
lea    0xdf5(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    11c3 <main+0x43>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [19 x i8] c"\0A\0AStack Operations\00"
@.str.1 = [18 x i8] c"\0A----------------\00"
@.str.2 = [9 x i8] c"\0A1. Push\00"
@.str.3 = [8 x i8] c"\0A2. Pop\00"
@.str.4 = [8 x i8] c"\0A3. Top\00"
@.str.5 = [12 x i8] c"\0A4. Display\00"
@.str.6 = [9 x i8] c"\0A5. Exit\00"
@.str.7 = [21 x i8] c"\0AEnter your choice: \00"
@.str.8 = [3 x i8] c"%d\00"
@.str.9 = [30 x i8] c"\0AEnter element to be pushed: \00"
@.str.10 = [20 x i8] c"\0APushed Element: %d\00"
@.str.11 = [18 x i8] c"\0AStack Overflow..\00"
@.str.12 = [20 x i8] c"Popped Element: %d \00"
@.str.13 = [19 x i8] c"\0AStack Underflow..\00"
@.str.14 = [17 x i8] c"\0ATop Element: %d\00"
@.str.15 = [16 x i8] c"\0AStack is Empty\00"
@.str.16 = [16 x i8] c"\0AInvalid Choice\00"
define void @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 1, i32* %4
br label %5
5: ; preds = %58, %0
%6 = load i32, i32* %4
%7 = icmp ne i32 %6, 0
br i1 %7, label %8, label %59
8: ; preds = %5
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0))
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0))
%18 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i32* %1)
%19 = load i32, i32* %1
switch i32 %19, label %56 [
i32 1, label %20
i32 2, label %33
i32 3, label %43
i32 4, label %53
i32 5, label %55
]
20: ; preds = %8
%21 = call i32 (...) @isFull()
%22 = icmp ne i32 %21, 0
br i1 %22, label %30, label %23
23: ; preds = %20
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.9, i64 0, i64 0))
%25 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i32* %2)
%26 = load i32, i32* %2
%27 = call i32 @Push(i32 %26)
%28 = load i32, i32* %2
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.10, i64 0, i64 0), i32 %28)
br label %32
30: ; preds = %20
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.11, i64 0, i64 0))
br label %32
32: ; preds = %30, %23
br label %58
33: ; preds = %8
%34 = call i32 (...) @isEmpty()
%35 = icmp ne i32 %34, 0
br i1 %35, label %40, label %36
36: ; preds = %33
%37 = call i32 (...) @Pop()
store i32 %37, i32* %3
%38 = load i32, i32* %3
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.12, i64 0, i64 0), i32 %38)
br label %42
40: ; preds = %33
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.13, i64 0, i64 0))
br label %42
42: ; preds = %40, %36
br label %58
43: ; preds = %8
%44 = call i32 (...) @isEmpty()
%45 = icmp ne i32 %44, 0
br i1 %45, label %50, label %46
46: ; preds = %43
%47 = call i32 (...) @Top()
store i32 %47, i32* %3
%48 = load i32, i32* %3
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.14, i64 0, i64 0), i32 %48)
br label %52
50: ; preds = %43
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.15, i64 0, i64 0))
br label %52
52: ; preds = %50, %46
br label %58
53: ; preds = %8
%54 = call i32 (...) @Display()
br label %58
55: ; preds = %8
store i32 0, i32* %4
br label %58
56: ; preds = %8
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.16, i64 0, i64 0))
br label %58
58: ; preds = %56, %55, %53, %52, %42, %32
br label %5
59: ; preds = %5
ret void
}

LLVM IR (-O2):
@.str = [19 x i8] c"\0A\0AStack Operations\00"
@.str.1 = [18 x i8] c"\0A----------------\00"
@.str.2 = [9 x i8] c"\0A1. Push\00"
@.str.3 = [8 x i8] c"\0A2. Pop\00"
@.str.4 = [8 x i8] c"\0A3. Top\00"
@.str.5 = [12 x i8] c"\0A4. Display\00"
@.str.6 = [9 x i8] c"\0A5. Exit\00"
@.str.7 = [21 x i8] c"\0AEnter your choice: \00"
@.str.8 = [3 x i8] c"%d\00"
@.str.9 = [30 x i8] c"\0AEnter element to be pushed: \00"
@.str.10 = [20 x i8] c"\0APushed Element: %d\00"
@.str.11 = [18 x i8] c"\0AStack Overflow..\00"
@.str.12 = [20 x i8] c"Popped Element: %d \00"
@.str.13 = [19 x i8] c"\0AStack Underflow..\00"
@.str.14 = [17 x i8] c"\0ATop Element: %d\00"
@.str.15 = [16 x i8] c"\0AStack is Empty\00"
@.str.16 = [16 x i8] c"\0AInvalid Choice\00"
define void @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
br label %5
5: ; preds = %43, %0
%6 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0))
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 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* %1)
%16 = load i32, i32* %1
switch i32 %16, label %48 [
i32 1, label %17
i32 2, label %29
i32 3, label %37
i32 4, label %46
i32 5, label %50
]
17: ; preds = %5
%18 = call i32 (...) @isFull()
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %27
20: ; preds = %17
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.9, i64 0, i64 0))
%22 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i32* %2)
%23 = load i32, i32* %2
%24 = call i32 @Push(i32 %23)
%25 = load i32, i32* %2
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.10, i64 0, i64 0), i32 %25)
br label %43
27: ; preds = %17
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.11, i64 0, i64 0))
br label %43
29: ; preds = %5
%30 = call i32 (...) @isEmpty()
%31 = icmp eq i32 %30, 0
br i1 %31, label %32, label %35
32: ; preds = %29
%33 = call i32 (...) @Pop()
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.12, i64 0, i64 0), i32 %33)
br label %43
35: ; preds = %29
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.13, i64 0, i64 0))
br label %43
37: ; preds = %5
%38 = call i32 (...) @isEmpty()
%39 = icmp eq i32 %38, 0
br i1 %39, label %40, label %44
40: ; preds = %37
%41 = call i32 (...) @Top()
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.14, i64 0, i64 0), i32 %41)
br label %43
43: ; preds = %40, %44, %32, %35, %20, %27, %48, %46
br label %5
44: ; preds = %37
%45 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.15, i64 0, i64 0))
br label %43
46: ; preds = %5
%47 = call i32 (...) @Display()
br label %43
48: ; preds = %5
%49 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.16, i64 0, i64 0))
br label %43
50: ; preds = %5
ret void
}