#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 */
struct heap {
  int dummy;
};

/* Variables and functions */
struct heap *createHeap(int, int /*<<< orphan*/);
int delete (struct heap *);
int /*<<< orphan*/ displayHeap(struct heap *);
int /*<<< orphan*/ insert(struct heap *, int, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  struct heap *h = createHeap(2, 0);
  int c = 0;
  int i, n;
  for (i = 0; i < 8; i++) {
    printf("Enter the element you want enter to queue\n");
    scanf("%d", &n);
    insert(h, n, c);
    c++;
  }
  displayHeap(h);
  int key = delete (h);
  printf("\n\n%d is the deleted element \n", key);
  delete (h);
  displayHeap(h);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x2,%edi
xor    %esi,%esi
call   1040 <createHeap@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0x8,-0x18(%rbp)
jge    11db <main+0x7b>
lea    0xe62(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe7f(%rip),%rdi
lea    -0x1c(%rbp),%rsi
call   1060 <scanf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1070 <insert@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    118d <main+0x2d>
mov    -0x10(%rbp),%rdi
call   1050 <displayHeap@plt>
mov    -0x10(%rbp),%rdi
call   1080 <delete@plt>
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%esi
lea    0xe34(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1080 <delete@plt>
mov    -0x10(%rbp),%rdi
call   1050 <displayHeap@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    $0x2,%edi
xor    %esi,%esi
call   1050 <createHeap@plt>
mov    %rax,%rbx
lea    0xe93(%rip),%r14
mov    %r14,%rdi
call   1030 <puts@plt>
lea    0xe63(%rip),%r15
lea    0x4(%rsp),%r12
mov    %r15,%rdi
mov    %r12,%rsi
call   1070 <scanf@plt>
mov    0x4(%rsp),%esi
mov    %rbx,%rdi
xor    %edx,%edx
call   1080 <insert@plt>
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1070 <scanf@plt>
mov    0x4(%rsp),%esi
mov    %rbx,%rdi
mov    $0x1,%edx
call   1080 <insert@plt>
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1070 <scanf@plt>
mov    0x4(%rsp),%esi
mov    %rbx,%rdi
mov    $0x2,%edx
call   1080 <insert@plt>
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1070 <scanf@plt>
mov    0x4(%rsp),%esi
mov    %rbx,%rdi
mov    $0x3,%edx
call   1080 <insert@plt>
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1070 <scanf@plt>
mov    0x4(%rsp),%esi
mov    %rbx,%rdi
mov    $0x4,%edx
call   1080 <insert@plt>
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1070 <scanf@plt>
mov    0x4(%rsp),%esi
mov    %rbx,%rdi
mov    $0x5,%edx
call   1080 <insert@plt>
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1070 <scanf@plt>
mov    0x4(%rsp),%esi
mov    %rbx,%rdi
mov    $0x6,%edx
call   1080 <insert@plt>
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1070 <scanf@plt>
mov    0x4(%rsp),%esi
mov    %rbx,%rdi
mov    $0x7,%edx
call   1080 <insert@plt>
mov    %rbx,%rdi
call   1060 <displayHeap@plt>
mov    %rbx,%rdi
call   1090 <delete@plt>
lea    0xd35(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1090 <delete@plt>
mov    %rbx,%rdi
call   1060 <displayHeap@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.heap = type { i32 }
@.str = [43 x i8] c"Enter the element you want enter to queue\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [30 x i8] c"\0A\0A%d is the deleted element \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.heap*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
%7 = call %struct.heap* @createHeap(i32 2, i32 0)
store %struct.heap* %7, %struct.heap** %2
store i32 0, i32* %3
store i32 0, i32* %4
br label %8
8: ; preds = %20, %0
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 8
br i1 %10, label %11, label %23
11: ; preds = %8
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %5)
%14 = load %struct.heap*, %struct.heap** %2
%15 = load i32, i32* %5
%16 = load i32, i32* %3
%17 = call i32 @insert(%struct.heap* %14, i32 %15, i32 %16)
%18 = load i32, i32* %3
%19 = add nsw i32 %18, 1
store i32 %19, i32* %3
br label %20
20: ; preds = %11
%21 = load i32, i32* %4
%22 = add nsw i32 %21, 1
store i32 %22, i32* %4
br label %8
23: ; preds = %8
%24 = load %struct.heap*, %struct.heap** %2
%25 = call i32 @displayHeap(%struct.heap* %24)
%26 = load %struct.heap*, %struct.heap** %2
%27 = call i32 @delete(%struct.heap* %26)
store i32 %27, i32* %6
%28 = load i32, i32* %6
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i32 %28)
%30 = load %struct.heap*, %struct.heap** %2
%31 = call i32 @delete(%struct.heap* %30)
%32 = load %struct.heap*, %struct.heap** %2
%33 = call i32 @displayHeap(%struct.heap* %32)
%34 = load i32, i32* %1
ret i32 %34
}

LLVM IR (-O2):
%struct.heap = type { i32 }
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [30 x i8] c"\0A\0A%d is the deleted element \0A\00"
@str = [42 x i8] c"Enter the element you want enter to queue\00"
define i32 @main() {
%1 = alloca i32
%2 = tail call %struct.heap* @createHeap(i32 2, i32 0)
%3 = bitcast i32* %1 to i8*
%4 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%6 = load i32, i32* %1
%7 = call i32 @insert(%struct.heap* %2, i32 %6, i32 0)
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 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
%11 = call i32 @insert(%struct.heap* %2, i32 %10, i32 1)
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%14 = load i32, i32* %1
%15 = call i32 @insert(%struct.heap* %2, i32 %14, i32 2)
%16 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str, i64 0, i64 0))
%17 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%18 = load i32, i32* %1
%19 = call i32 @insert(%struct.heap* %2, i32 %18, i32 3)
%20 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str, i64 0, i64 0))
%21 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%22 = load i32, i32* %1
%23 = call i32 @insert(%struct.heap* %2, i32 %22, i32 4)
%24 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str, i64 0, i64 0))
%25 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%26 = load i32, i32* %1
%27 = call i32 @insert(%struct.heap* %2, i32 %26, i32 5)
%28 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str, i64 0, i64 0))
%29 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%30 = load i32, i32* %1
%31 = call i32 @insert(%struct.heap* %2, i32 %30, i32 6)
%32 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str, i64 0, i64 0))
%33 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%34 = load i32, i32* %1
%35 = call i32 @insert(%struct.heap* %2, i32 %34, i32 7)
%36 = call i32 @displayHeap(%struct.heap* %2)
%37 = call i32 @delete(%struct.heap* %2)
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i32 %37)
%39 = call i32 @delete(%struct.heap* %2)
%40 = call i32 @displayHeap(%struct.heap* %2)
ret i32 0
}