#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*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
void main(void) {
  int choice, element, flag = 1, temp;
  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: {
      printf("\nEnter element to be pushed: ");
      scanf("%d", &element);
      Push(element);
      printf("\nPushed Element: %d", element);
      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,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     1339 <main+0x1c9>
lea    0xe84(%rip),%rdi
xor    %eax,%eax
mov    %al,-0x19(%rbp)
call   1030 <printf@plt>
mov    -0x19(%rbp),%al
lea    0xe83(%rip),%rdi
mov    %rdi,-0x28(%rbp)
call   1030 <printf@plt>
mov    -0x19(%rbp),%al
lea    0xe82(%rip),%rdi
call   1030 <printf@plt>
mov    -0x19(%rbp),%al
lea    0xe7c(%rip),%rdi
call   1030 <printf@plt>
mov    -0x19(%rbp),%al
lea    0xe75(%rip),%rdi
call   1030 <printf@plt>
mov    -0x19(%rbp),%al
lea    0xe6e(%rip),%rdi
call   1030 <printf@plt>
mov    -0x19(%rbp),%al
lea    0xe6b(%rip),%rdi
call   1030 <printf@plt>
mov    -0x28(%rbp),%rdi
mov    -0x19(%rbp),%al
call   1030 <printf@plt>
mov    -0x19(%rbp),%al
lea    0xe59(%rip),%rdi
call   1030 <printf@plt>
lea    0xe91(%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     1326 <main+0x1b6>
mov    -0x18(%rbp),%rax
lea    0xdbd(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xe29(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe4a(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1090 <scanf@plt>
mov    -0x8(%rbp),%edi
call   1060 <Push@plt>
mov    -0x8(%rbp),%esi
lea    0xe1e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1334 <main+0x1c4>
mov    $0x0,%al
call   1070 <isEmpty@plt>
cmp    $0x0,%eax
jne    12b8 <main+0x148>
mov    $0x0,%al
call   1040 <Pop@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%esi
lea    0xe02(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12c6 <main+0x156>
lea    0xe03(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1334 <main+0x1c4>
mov    $0x0,%al
call   1070 <isEmpty@plt>
cmp    $0x0,%eax
jne    12fb <main+0x18b>
mov    $0x0,%al
call   1050 <Top@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%esi
lea    0xde6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1309 <main+0x199>
lea    0xde4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1334 <main+0x1c4>
mov    $0x0,%al
call   1080 <Display@plt>
jmp    1334 <main+0x1c4>
movl   $0x0,-0xc(%rbp)
jmp    1334 <main+0x1c4>
lea    0xdc9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    117f <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    0xea5(%rip),%rbx
lea    0xed5(%rip),%r14
lea    0xed7(%rip),%r15
lea    0xf14(%rip),%r12
lea    0x4(%rsp),%r13
lea    0xe5d(%rip),%rbp
jmp    11b3 <main+0x43>
lea    0xf4a(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe5a(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe67(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe62(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe5c(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe56(%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     11a5 <main+0x35>
movslq 0x0(%rbp,%rax,4),%rax
add    %rbp,%rax
jmp    *%rax
lea    0xe2f(%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    0xe29(%rip),%rdi
jmp    12cd <main+0x15d>
xor    %eax,%eax
call   1070 <isEmpty@plt>
test   %eax,%eax
je     12ad <main+0x13d>
lea    0xe3d(%rip),%rdi
jmp    11ac <main+0x3c>
xor    %eax,%eax
call   1070 <isEmpty@plt>
test   %eax,%eax
je     12bd <main+0x14d>
lea    0xe4a(%rip),%rdi
jmp    11ac <main+0x3c>
xor    %eax,%eax
call   1080 <Display@plt>
jmp    11b3 <main+0x43>
xor    %eax,%eax
call   1040 <Pop@plt>
lea    0xdf3(%rip),%rdi
jmp    12cb <main+0x15b>
xor    %eax,%eax
call   1050 <Top@plt>
lea    0xe0a(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    11b3 <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 = [20 x i8] c"Popped Element: %d \00"
@.str.12 = [19 x i8] c"\0AStack Underflow..\00"
@.str.13 = [17 x i8] c"\0ATop Element: %d\00"
@.str.14 = [16 x i8] c"\0AStack is Empty\00"
@.str.15 = [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* %3
br label %5
5: ; preds = %52, %0
%6 = load i32, i32* %3
%7 = icmp ne i32 %6, 0
br i1 %7, label %8, label %53
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 %50 [
i32 1, label %20
i32 2, label %27
i32 3, label %37
i32 4, label %47
i32 5, label %49
]
20: ; preds = %8
%21 = call i32 (i8*, ...) @printf(i8* 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* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.10, i64 0, i64 0), i32 %25)
br label %52
27: ; preds = %8
%28 = call i32 (...) @isEmpty()
%29 = icmp ne i32 %28, 0
br i1 %29, label %34, label %30
30: ; preds = %27
%31 = call i32 (...) @Pop()
store i32 %31, i32* %4
%32 = load i32, i32* %4
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.11, i64 0, i64 0), i32 %32)
br label %36
34: ; preds = %27
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.12, i64 0, i64 0))
br label %36
36: ; preds = %34, %30
br label %52
37: ; preds = %8
%38 = call i32 (...) @isEmpty()
%39 = icmp ne i32 %38, 0
br i1 %39, label %44, label %40
40: ; preds = %37
%41 = call i32 (...) @Top()
store i32 %41, i32* %4
%42 = load i32, i32* %4
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.13, i64 0, i64 0), i32 %42)
br label %46
44: ; preds = %37
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.14, i64 0, i64 0))
br label %46
46: ; preds = %44, %40
br label %52
47: ; preds = %8
%48 = call i32 (...) @Display()
br label %52
49: ; preds = %8
store i32 0, i32* %3
br label %52
50: ; preds = %8
%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, %49, %47, %46, %36, %20
br label %5
53: ; 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 = [20 x i8] c"Popped Element: %d \00"
@.str.12 = [19 x i8] c"\0AStack Underflow..\00"
@.str.13 = [17 x i8] c"\0ATop Element: %d\00"
@.str.14 = [16 x i8] c"\0AStack is Empty\00"
@.str.15 = [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 = %38, %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 %43 [
i32 1, label %17
i32 2, label %24
i32 3, label %32
i32 4, label %41
i32 5, label %45
]
17: ; preds = %5
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.9, i64 0, i64 0))
%19 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i32* %2)
%20 = load i32, i32* %2
%21 = call i32 @Push(i32 %20)
%22 = load i32, i32* %2
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.10, i64 0, i64 0), i32 %22)
br label %38
24: ; preds = %5
%25 = call i32 (...) @isEmpty()
%26 = icmp eq i32 %25, 0
br i1 %26, label %27, label %30
27: ; preds = %24
%28 = call i32 (...) @Pop()
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.11, i64 0, i64 0), i32 %28)
br label %38
30: ; preds = %24
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.12, i64 0, i64 0))
br label %38
32: ; preds = %5
%33 = call i32 (...) @isEmpty()
%34 = icmp eq i32 %33, 0
br i1 %34, label %35, label %39
35: ; preds = %32
%36 = call i32 (...) @Top()
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.13, i64 0, i64 0), i32 %36)
br label %38
38: ; preds = %35, %39, %27, %30, %43, %41, %17
br label %5
39: ; preds = %32
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.14, i64 0, i64 0))
br label %38
41: ; preds = %5
%42 = call i32 (...) @Display()
br label %38
43: ; preds = %5
%44 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.15, i64 0, i64 0))
br label %38
45: ; preds = %5
ret void
}