#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*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int choice, num, n, a[100], data, s;
  void display(int[], int);
  void insert(int[], int, int, int);
  int del_hi_priori(int[], int, int);
  n = 0;
  int lb = 0;
  while (1) {
    printf(".....MAIN MENU.....n");
    printf("n1.Insert.n");
    printf("2.Delete.n");
    printf("3.Display.n");
    printf("4.Quit.n");
    printf("nEnter your choice : ");
    scanf("%d", &choice);
    switch (choice) {
    case 1:
      printf("Enter data to be inserted : ");
      scanf("%d", &data);
      insert(a, n, data, lb);
      n++;
      break;
    case 2:
      s = del_hi_priori(a, n + 1, lb);
      if (s != 0)
        printf("nThe deleted value is : %d n", s);
      if (n > 0)
        n--;
      break;
    case 3:
      printf("n");
      display(a, n);
      break;
    case 4:
      return 0;
    default:
      printf("Invalid choice.n");
    }
    printf("nn");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1c0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x1ac(%rbp)
lea    0xe96(%rip),%rdi
xor    %eax,%eax
mov    %al,-0x1b9(%rbp)
call   1040 <printf@plt>
mov    -0x1b9(%rbp),%al
lea    0xe91(%rip),%rdi
call   1040 <printf@plt>
mov    -0x1b9(%rbp),%al
lea    0xe8b(%rip),%rdi
call   1040 <printf@plt>
mov    -0x1b9(%rbp),%al
lea    0xe84(%rip),%rdi
call   1040 <printf@plt>
mov    -0x1b9(%rbp),%al
lea    0xe7e(%rip),%rdi
call   1040 <printf@plt>
mov    -0x1b9(%rbp),%al
lea    0xe75(%rip),%rdi
call   1040 <printf@plt>
lea    0xe7f(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x1b8(%rbp)
sub    $0x3,%eax
ja     12ee <main+0x19e>
mov    -0x1b8(%rbp),%rax
lea    0xde9(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xe43(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe32(%rip),%rdi
lea    -0x1a4(%rbp),%rsi
call   1050 <scanf@plt>
lea    -0x1a0(%rbp),%rdi
mov    -0x10(%rbp),%esi
mov    -0x1a4(%rbp),%edx
mov    -0x1ac(%rbp),%ecx
call   1060 <insert@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    12fc <main+0x1ac>
lea    -0x1a0(%rbp),%rdi
mov    -0x10(%rbp),%esi
add    $0x1,%esi
mov    -0x1ac(%rbp),%edx
call   1070 <del_hi_priori@plt>
mov    %eax,-0x1a8(%rbp)
cmpl   $0x0,-0x1a8(%rbp)
je     12a9 <main+0x159>
mov    -0x1a8(%rbp),%esi
lea    0xde5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x0,-0x10(%rbp)
jle    12bc <main+0x16c>
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
jmp    12fc <main+0x1ac>
lea    0xdda(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x1a0(%rbp),%rdi
mov    -0x10(%rbp),%esi
call   1030 <display@plt>
jmp    12fc <main+0x1ac>
xor    %eax,%eax
add    $0x1c0,%rsp
pop    %rbp
ret
lea    0xdaf(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xdb2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1173 <main+0x23>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1a8,%rsp
lea    0xed9(%rip),%rbp
lea    0xee8(%rip),%r14
lea    0xc(%rsp),%r15
lea    0xf2a(%rip),%r12
lea    0xe6e(%rip),%rbx
xor    %r13d,%r13d
jmp    11b8 <main+0x58>
nopw   0x0(%rax,%rax,1)
lea    0xefd(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r12,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe51(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe58(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe56(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe53(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe51(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbp,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   1060 <scanf@plt>
mov    0xc(%rsp),%eax
add    $0xffffffff,%eax
cmp    $0x3,%eax
ja     11a0 <main+0x40>
movslq (%rbx,%rax,4),%rax
add    %rbx,%rax
jmp    *%rax
lea    0xe3b(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
lea    0x8(%rsp),%rsi
call   1060 <scanf@plt>
mov    0x8(%rsp),%edx
lea    0x10(%rsp),%rdi
mov    %r13d,%esi
xor    %ecx,%ecx
call   1070 <insert@plt>
add    $0x1,%r13d
jmp    11ae <main+0x4e>
nop
lea    0x1(%r13),%esi
lea    0x10(%rsp),%rdi
xor    %edx,%edx
call   1080 <del_hi_priori@plt>
test   %eax,%eax
je     1284 <main+0x124>
lea    0xe0c(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
test   %r13d,%r13d
setg   %al
sub    %eax,%r13d
jmp    11ae <main+0x4e>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    $0x6e,%edi
call   1030 <putchar@plt>
lea    0x10(%rsp),%rdi
mov    %r13d,%esi
call   1040 <display@plt>
jmp    11ae <main+0x4e>
xor    %eax,%eax
add    $0x1a8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [21 x i8] c".....MAIN MENU.....n\00"
@.str.1 = [12 x i8] c"n1.Insert.n\00"
@.str.2 = [11 x i8] c"2.Delete.n\00"
@.str.3 = [12 x i8] c"3.Display.n\00"
@.str.4 = [9 x i8] c"4.Quit.n\00"
@.str.5 = [22 x i8] c"nEnter your choice : \00"
@.str.6 = [3 x i8] c"%d\00"
@.str.7 = [29 x i8] c"Enter data to be inserted : \00"
@.str.8 = [29 x i8] c"nThe deleted value is : %d n\00"
@.str.9 = [2 x i8] c"n\00"
@.str.10 = [17 x i8] c"Invalid choice.n\00"
@.str.11 = [3 x i8] c"nn\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca [100 x i32]
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %4
store i32 0, i32* %8
br label %9
9: ; preds = %0, %52
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0))
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %2)
%17 = load i32, i32* %2
switch i32 %17, label %50 [
i32 1, label %18
i32 2, label %27
i32 3, label %45
i32 4, label %49
]
18: ; preds = %9
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.7, i64 0, i64 0))
%20 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %6)
%21 = getelementptr inbounds [100 x i32], [100 x i32]* %5, i64 0, i64 0
%22 = load i32, i32* %4
%23 = load i32, i32* %6
%24 = load i32, i32* %8
%25 = load i32, i32* %4
%26 = add nsw i32 %25, 1
store i32 %26, i32* %4
br label %52
27: ; preds = %9
%28 = getelementptr inbounds [100 x i32], [100 x i32]* %5, i64 0, i64 0
%29 = load i32, i32* %4
%30 = add nsw i32 %29, 1
%31 = load i32, i32* %8
%32 = call i32 @del_hi_priori(i32* %28, i32 %30, i32 %31)
store i32 %32, i32* %7
%33 = load i32, i32* %7
%34 = icmp ne i32 %33, 0
br i1 %34, label %35, label %38
35: ; preds = %27
%36 = load i32, i32* %7
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.8, i64 0, i64 0), i32 %36)
br label %38
38: ; preds = %35, %27
%39 = load i32, i32* %4
%40 = icmp sgt i32 %39, 0
br i1 %40, label %41, label %44
41: ; preds = %38
%42 = load i32, i32* %4
%43 = add nsw i32 %42, -1
store i32 %43, i32* %4
br label %44
44: ; preds = %41, %38
br label %52
45: ; preds = %9
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
%47 = getelementptr inbounds [100 x i32], [100 x i32]* %5, i64 0, i64 0
%48 = load i32, i32* %4
br label %52
49: ; preds = %9
ret i32 0
50: ; preds = %9
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.10, i64 0, i64 0))
br label %52
52: ; preds = %50, %45, %44, %18
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0))
br label %9
}

LLVM IR (-O2):
@.str = [21 x i8] c".....MAIN MENU.....n\00"
@.str.1 = [12 x i8] c"n1.Insert.n\00"
@.str.2 = [11 x i8] c"2.Delete.n\00"
@.str.3 = [12 x i8] c"3.Display.n\00"
@.str.4 = [9 x i8] c"4.Quit.n\00"
@.str.5 = [22 x i8] c"nEnter your choice : \00"
@.str.6 = [3 x i8] c"%d\00"
@.str.7 = [29 x i8] c"Enter data to be inserted : \00"
@.str.8 = [29 x i8] c"nThe deleted value is : %d n\00"
@.str.10 = [17 x i8] c"Invalid choice.n\00"
@.str.11 = [3 x i8] c"nn\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i32]
%3 = alloca i32
%4 = bitcast i32* %1 to i8*
%5 = bitcast [100 x i32]* %2 to i8*
%6 = bitcast i32* %3 to i8*
%7 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 0
br label %8
8: ; preds = %38, %0
%9 = phi i32 [ 0, %0 ], [ %39, %38 ]
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0))
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %1)
%17 = load i32, i32* %1
switch i32 %17, label %36 [
i32 1, label %18
i32 2, label %23
i32 3, label %33
i32 4, label %35
]
18: ; preds = %8
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.7, i64 0, i64 0))
%20 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %3)
%21 = load i32, i32* %3
%22 = add nsw i32 %9, 1
br label %38
23: ; preds = %8
%24 = add nsw i32 %9, 1
%25 = call i32 @del_hi_priori(i32* %7, i32 %24, i32 0)
%26 = icmp eq i32 %25, 0
br i1 %26, label %29, label %27
27: ; preds = %23
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.8, i64 0, i64 0), i32 %25)
br label %29
29: ; preds = %27, %23
%30 = icmp sgt i32 %9, 0
%31 = sext i1 %30 to i32
%32 = add nsw i32 %9, %31
br label %38
33: ; preds = %8
%34 = call i32 @putchar(i32 110)
br label %38
35: ; preds = %8
ret i32 0
36: ; preds = %8
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.10, i64 0, i64 0))
br label %38
38: ; preds = %29, %36, %33, %18
%39 = phi i32 [ %9, %36 ], [ %9, %33 ], [ %22, %18 ], [ %32, %29 ]
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0))
br label %8
}