#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*/ delete_by_priority(int);
int /*<<< orphan*/ display_pqueue();
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ insert_by_priority(int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
void main() {
  int n, ch;
  printf("\n1 - Insert an element into queue");
  printf("\n2 - Delete an element from queue");
  printf("\n3 - Display queue elements");
  printf("\n4 - Exit");
  create();
  while (1) {
    printf("\nEnter your choice : ");
    scanf("%d", &ch);
    switch (ch) {
    case 1:
      printf("\nEnter value to be inserted : ");
      scanf("%d", &n);
      insert_by_priority(n);
      break;
    case 2:
      printf("\nEnter value to delete : ");
      scanf("%d", &n);
      delete_by_priority(n);
      break;
    case 3:
      display_pqueue();
      break;
    case 4:
      exit(0);
    default:
      printf("\nChoice is incorrect, Enter a correct choice");
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xe91(%rip),%rdi
call   1040 <printf@plt>
lea    0xea7(%rip),%rdi
call   1040 <printf@plt>
lea    0xebd(%rip),%rdi
call   1040 <printf@plt>
lea    0xecd(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <create@plt>
lea    0xec4(%rip),%rdi
call   1040 <printf@plt>
lea    0xece(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1080 <scanf@plt>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x3,%eax
ja     1259 <main+0xe9>
mov    -0x10(%rbp),%rax
lea    0xe15(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xe98(%rip),%rdi
call   1040 <printf@plt>
lea    0xe89(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1080 <scanf@plt>
mov    -0x4(%rbp),%edi
call   1030 <insert_by_priority@plt>
jmp    1265 <main+0xf5>
lea    0xe8e(%rip),%rdi
call   1040 <printf@plt>
lea    0xe60(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1080 <scanf@plt>
mov    -0x4(%rbp),%edi
call   1060 <delete_by_priority@plt>
jmp    1265 <main+0xf5>
mov    $0x0,%al
call   1070 <display_pqueue@plt>
jmp    1265 <main+0xf5>
xor    %edi,%edi
call   1090 <exit@plt>
lea    0xe6c(%rip),%rdi
call   1040 <printf@plt>
jmp    11af <main+0x3f>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xe8e(%rip),%rdi
call   1040 <printf@plt>
lea    0xea4(%rip),%rdi
call   1040 <printf@plt>
lea    0xeba(%rip),%rdi
call   1040 <printf@plt>
lea    0xeca(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <create@plt>
lea    0xec1(%rip),%r14
lea    0xed0(%rip),%rbx
lea    0x4(%rsp),%r15
lea    0xe34(%rip),%r13
mov    %rsp,%rbp
lea    0xedc(%rip),%r12
jmp    11e7 <main+0x77>
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1070 <display_pqueue@plt>
mov    %r14,%rdi
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1080 <scanf@plt>
mov    0x4(%rsp),%eax
add    $0xffffffff,%eax
cmp    $0x3,%eax
ja     1240 <main+0xd0>
movslq 0x0(%r13,%rax,4),%rax
add    %r13,%rax
jmp    *%rax
lea    0xe7c(%rip),%rdi
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1080 <scanf@plt>
mov    (%rsp),%edi
call   1030 <insert_by_priority@plt>
jmp    11e7 <main+0x77>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    0xe85(%rip),%rdi
call   1040 <printf@plt>
jmp    11e7 <main+0x77>
xchg   %ax,%ax
mov    %r12,%rdi
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1080 <scanf@plt>
mov    (%rsp),%edi
call   1060 <delete_by_priority@plt>
jmp    11e7 <main+0x77>
xor    %edi,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [34 x i8] c"\0A1 - Insert an element into queue\00"
@.str.1 = [34 x i8] c"\0A2 - Delete an element from queue\00"
@.str.2 = [28 x i8] c"\0A3 - Display queue elements\00"
@.str.3 = [10 x i8] c"\0A4 - Exit\00"
@.str.4 = [22 x i8] c"\0AEnter your choice : \00"
@.str.5 = [3 x i8] c"%d\00"
@.str.6 = [31 x i8] c"\0AEnter value to be inserted : \00"
@.str.7 = [26 x i8] c"\0AEnter value to delete : \00"
@.str.8 = [45 x i8] c"\0AChoice is incorrect, Enter a correct choice\00"
define void @main() {
%1 = alloca i32
%2 = alloca i32
%3 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
%5 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
%6 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%7 = call i32 (...) @create()
br label %8
8: ; preds = %0, %28
%9 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %2)
%11 = load i32, i32* %2
switch i32 %11, label %26 [
i32 1, label %12
i32 2, label %17
i32 3, label %22
i32 4, label %24
]
12: ; preds = %8
%13 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.6, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %1)
%15 = load i32, i32* %1
%16 = call i32 @insert_by_priority(i32 %15)
br label %28
17: ; preds = %8
%18 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.7, i64 0, i64 0))
%19 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %1)
%20 = load i32, i32* %1
%21 = call i32 @delete_by_priority(i32 %20)
br label %28
22: ; preds = %8
%23 = call i32 (...) @display_pqueue()
br label %28
24: ; preds = %8
%25 = call i32 @exit(i32 0)
unreachable
26: ; preds = %8
%27 = call i32 @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.8, i64 0, i64 0))
br label %28
28: ; preds = %26, %22, %17, %12
br label %8
}

LLVM IR (-O2):
@.str = [34 x i8] c"\0A1 - Insert an element into queue\00"
@.str.1 = [34 x i8] c"\0A2 - Delete an element from queue\00"
@.str.2 = [28 x i8] c"\0A3 - Display queue elements\00"
@.str.3 = [10 x i8] c"\0A4 - Exit\00"
@.str.4 = [22 x i8] c"\0AEnter your choice : \00"
@.str.5 = [3 x i8] c"%d\00"
@.str.6 = [31 x i8] c"\0AEnter value to be inserted : \00"
@.str.7 = [26 x i8] c"\0AEnter value to delete : \00"
@.str.8 = [45 x i8] c"\0AChoice is incorrect, Enter a correct choice\00"
define void @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%6 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
%7 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
%8 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%9 = tail call i32 (...) @create()
br label %10
10: ; preds = %30, %0
%11 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %2)
%13 = load i32, i32* %2
switch i32 %13, label %28 [
i32 1, label %14
i32 2, label %19
i32 3, label %24
i32 4, label %26
]
14: ; preds = %10
%15 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.6, i64 0, i64 0))
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %1)
%17 = load i32, i32* %1
%18 = call i32 @insert_by_priority(i32 %17)
br label %30
19: ; preds = %10
%20 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.7, 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 = call i32 @delete_by_priority(i32 %22)
br label %30
24: ; preds = %10
%25 = call i32 (...) @display_pqueue()
br label %30
26: ; preds = %10
%27 = call i32 @exit(i32 0)
unreachable
28: ; preds = %10
%29 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.8, i64 0, i64 0))
br label %30
30: ; preds = %28, %24, %19, %14
br label %10
}