#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*/ create();
int /*<<< orphan*/ display();
int /*<<< orphan*/ initialise();
int pop();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ push(int);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int choice = 0;
  initialise();
  int num, item;
  create();
  while (choice != 4) {
    printf("\nWelcome! press \n1)push \n2)display \n3)pop \n4)exit \n");
    scanf("%d", &choice);
    switch (choice) {
    case 1: {
      printf("Enter number ");
      scanf("%d", &num);
      push(num);
      break;
    }
    case 2: {
      display();
      break;
    }
    case 3: {
      item = pop();
      printf("popped item: %d\n", item);
      break;
    }
    case 4: {
      return 0;
    }
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    $0x0,%al
call   1090 <initialise@plt>
mov    $0x0,%al
call   1060 <create@plt>
cmpl   $0x4,-0x8(%rbp)
je     124d <main+0xdd>
lea    0xe6b(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe91(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1070 <scanf@plt>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x3,%eax
ja     1248 <main+0xd8>
mov    -0x18(%rbp),%rax
lea    0xe24(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xe5b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe4a(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1070 <scanf@plt>
mov    -0xc(%rbp),%edi
call   1080 <push@plt>
jmp    1248 <main+0xd8>
mov    $0x0,%al
call   1030 <display@plt>
jmp    1248 <main+0xd8>
mov    $0x0,%al
call   1050 <pop@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%esi
lea    0xe25(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1248 <main+0xd8>
movl   $0x0,-0x4(%rbp)
jmp    124d <main+0xdd>
jmp    1194 <main+0x24>
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
movl   $0x0,(%rsp)
xor    %eax,%eax
call   10a0 <initialise@plt>
xor    %eax,%eax
call   1070 <create@plt>
lea    0xe8b(%rip),%r14
lea    0xe62(%rip),%rbx
mov    %rsp,%r15
lea    0xe48(%rip),%r12
lea    0x4(%rsp),%r13
lea    0xe5d(%rip),%rbp
jmp    11eb <main+0x6b>
cs nopw 0x0(%rax,%rax,1)
xor    %eax,%eax
call   1060 <pop@plt>
mov    %rbp,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%rsp),%eax
cmp    $0x4,%eax
je     1249 <main+0xc9>
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1080 <scanf@plt>
mov    (%rsp),%eax
lea    -0x1(%rax),%ecx
cmp    $0x3,%ecx
ja     11e6 <main+0x66>
movslq (%r12,%rcx,4),%rax
add    %r12,%rax
jmp    *%rax
lea    0xdfa(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   1080 <scanf@plt>
mov    0x4(%rsp),%edi
call   1090 <push@plt>
jmp    11e3 <main+0x63>
cs nopw 0x0(%rax,%rax,1)
xor    %eax,%eax
call   1040 <display@plt>
jmp    11e3 <main+0x63>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [52 x i8] c"\0AWelcome! press \0A1)push \0A2)display \0A3)pop \0A4)exit \0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [14 x i8] c"Enter number \00"
@.str.3 = [17 x i8] c"popped item: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
%5 = call i32 (...) @initialise()
%6 = call i32 (...) @create()
br label %7
7: ; preds = %26, %0
%8 = load i32, i32* %2
%9 = icmp ne i32 %8, 4
br i1 %9, label %10, label %27
10: ; preds = %7
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%13 = load i32, i32* %2
switch i32 %13, label %26 [
i32 1, label %14
i32 2, label %19
i32 3, label %21
i32 4, label %25
]
14: ; preds = %10
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%17 = load i32, i32* %3
%18 = call i32 @push(i32 %17)
br label %26
19: ; preds = %10
%20 = call i32 (...) @display()
br label %26
21: ; preds = %10
%22 = call i32 (...) @pop()
store i32 %22, i32* %4
%23 = load i32, i32* %4
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i32 %23)
br label %26
25: ; preds = %10
store i32 0, i32* %1
br label %27
26: ; preds = %10, %21, %19, %14
br label %7
27: ; preds = %25, %7
%28 = load i32, i32* %1
ret i32 %28
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [14 x i8] c"Enter number \00"
@.str.3 = [17 x i8] c"popped item: %d\0A\00"
@str = [51 x i8] c"\0AWelcome! press \0A1)push \0A2)display \0A3)pop \0A4)exit \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%4 = tail call i32 (...) @initialise()
%5 = bitcast i32* %2 to i8*
%6 = tail call i32 (...) @create()
br label %7
7: ; preds = %0, %23
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @str, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%10 = load i32, i32* %1
switch i32 %10, label %23 [
i32 1, label %11
i32 2, label %16
i32 3, label %18
i32 4, label %26
]
11: ; preds = %7
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%14 = load i32, i32* %2
%15 = call i32 @push(i32 %14)
br label %21
16: ; preds = %7
%17 = call i32 (...) @display()
br label %21
18: ; preds = %7
%19 = call i32 (...) @pop()
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i32 %19)
br label %21
21: ; preds = %11, %16, %18
%22 = load i32, i32* %1
br label %23
23: ; preds = %21, %7
%24 = phi i32 [ %22, %21 ], [ %10, %7 ]
%25 = icmp eq i32 %24, 4
br i1 %25, label %26, label %7
26: ; preds = %7, %23
ret i32 0
}