#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() {
  char ch;
  int choice;
  printf("MAIN MENU \n");
  printf("1.PUSH \n");
  printf("2.POP \n");
  printf("3.DISPLAY \n");
  printf("ENTER YOUR CHOICE \n");
  scanf("%d", &choice);
  while (choice < 4) {
    switch (choice) {
    case 1:
      push();
      break;
    case 2:
      pop();
      break;
    case 3:
      display();
      break;
    }
    printf("\n ENTER YOUR CHOICE \n");
    scanf("%d", &choice);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
call   1040 <printf@plt>
lea    0xe9a(%rip),%rdi
call   1040 <printf@plt>
lea    0xe97(%rip),%rdi
call   1040 <printf@plt>
lea    0xe93(%rip),%rdi
call   1040 <printf@plt>
lea    0xe98(%rip),%rdi
call   1040 <printf@plt>
lea    0xe87(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1060 <scanf@plt>
cmpl   $0x4,-0xc(%rbp)
jge    122b <main+0xdb>
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
sub    $0x1,%eax
je     11eb <main+0x9b>
jmp    11c9 <main+0x79>
mov    -0x10(%rbp),%eax
sub    $0x2,%eax
je     11f7 <main+0xa7>
jmp    11da <main+0x8a>
mov    -0x10(%rbp),%eax
sub    $0x3,%eax
je     1203 <main+0xb3>
jmp    120a <main+0xba>
mov    $0x0,%al
call   1070 <push@plt>
jmp    120a <main+0xba>
mov    $0x0,%al
call   1050 <pop@plt>
jmp    120a <main+0xba>
mov    $0x0,%al
call   1030 <display@plt>
lea    0xe1b(%rip),%rdi
call   1040 <printf@plt>
lea    0xe0c(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1060 <scanf@plt>
jmp    11ab <main+0x5b>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xea3(%rip),%rdi
call   1030 <puts@plt>
lea    0xea2(%rip),%rdi
call   1030 <puts@plt>
lea    0xe9e(%rip),%rdi
call   1030 <puts@plt>
lea    0xe99(%rip),%rdi
call   1030 <puts@plt>
lea    0xe9a(%rip),%rdi
call   1030 <puts@plt>
lea    0xe64(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1060 <scanf@plt>
mov    0xc(%rsp),%eax
cmp    $0x3,%eax
jg     1219 <main+0xc9>
lea    0xe72(%rip),%r14
lea    0xe43(%rip),%r15
lea    0xc(%rsp),%rbx
jmp    11f3 <main+0xa3>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %eax,%eax
call   1050 <pop@plt>
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1060 <scanf@plt>
mov    0xc(%rsp),%eax
cmp    $0x4,%eax
jge    1219 <main+0xc9>
cmp    $0x3,%eax
je     1210 <main+0xc0>
cmp    $0x2,%eax
je     11d0 <main+0x80>
cmp    $0x1,%eax
jne    11d7 <main+0x87>
xor    %eax,%eax
call   1070 <push@plt>
jmp    11d7 <main+0x87>
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1040 <display@plt>
jmp    11d7 <main+0x87>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [12 x i8] c"MAIN MENU \0A\00"
@.str.1 = [9 x i8] c"1.PUSH \0A\00"
@.str.2 = [8 x i8] c"2.POP \0A\00"
@.str.3 = [12 x i8] c"3.DISPLAY \0A\00"
@.str.4 = [20 x i8] c"ENTER YOUR CHOICE \0A\00"
@.str.5 = [3 x i8] c"%d\00"
@.str.6 = [22 x i8] c"\0A ENTER YOUR CHOICE \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%6 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%7 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%8 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %3)
br label %10
10: ; preds = %21, %0
%11 = load i32, i32* %3
%12 = icmp slt i32 %11, 4
br i1 %12, label %13, label %24
13: ; preds = %10
%14 = load i32, i32* %3
switch i32 %14, label %21 [
i32 1, label %15
i32 2, label %17
i32 3, label %19
]
15: ; preds = %13
%16 = call i32 (...) @push()
br label %21
17: ; preds = %13
%18 = call i32 (...) @pop()
br label %21
19: ; preds = %13
%20 = call i32 (...) @display()
br label %21
21: ; preds = %13, %19, %17, %15
%22 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0))
%23 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %3)
br label %10
24: ; preds = %10
ret i32 0
}

LLVM IR (-O2):
@.str.5 = [3 x i8] c"%d\00"
@str = [11 x i8] c"MAIN MENU \00"
@str.7 = [8 x i8] c"1.PUSH \00"
@str.8 = [7 x i8] c"2.POP \00"
@str.9 = [11 x i8] c"3.DISPLAY \00"
@str.10 = [19 x i8] c"ENTER YOUR CHOICE \00"
@str.11 = [21 x i8] c"\0A ENTER YOUR CHOICE \00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.7, i64 0, i64 0))
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str.8, i64 0, i64 0))
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.9, i64 0, i64 0))
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.10, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %1)
%9 = load i32, i32* %1
%10 = icmp slt i32 %9, 4
br i1 %10, label %11, label %24
11: ; preds = %0, %19
%12 = phi i32 [ %22, %19 ], [ %9, %0 ]
switch i32 %12, label %19 [
i32 1, label %13
i32 2, label %15
i32 3, label %17
]
13: ; preds = %11
%14 = call i32 (...) @push()
br label %19
15: ; preds = %11
%16 = call i32 (...) @pop()
br label %19
17: ; preds = %11
%18 = call i32 (...) @display()
br label %19
19: ; preds = %11, %17, %15, %13
%20 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.11, i64 0, i64 0))
%21 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %1)
%22 = load i32, i32* %1
%23 = icmp slt i32 %22, 4
br i1 %23, label %11, label %24
24: ; preds = %19, %0
ret i32 0
}