Given the following C code and unoptimized assembly code, your task is to generate highly optimized x86-64 assembly code.
C Code:

```c

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX_CMD_LENGTH 10
#define MAX_HEAP_LENGTH 100
#define POS_INF_KEY 2000000000
#define NEG_INF_KEY -1

void swap(int array[], int i, int j) {
    int temp = array[i];
    array[i] = array[j];
    array[j] = temp;
}

typedef struct {
    int * array;
    int heap_size;
    int length;
    int array_size;
} Heap;

//Heap createHeap(int length) {
//    Heap heap;
//    
//    heap.array = (int *)malloc((length+1) * sizeof(int));
//    heap.array[0] = 0; // NOT USED
//    heap.heap_size = heap.length = length;
//    
//    return heap;
//}

Heap createHeap() {
    Heap heap;
    
    // one slot of memory is allocated for the unused 0-slot
    heap.array = (int *)malloc(1 * sizeof(int));
    heap.array[0] = 0; // NOT USED
    
    // hence memory allocated = (1+length) * sizeof int
    heap.array_size = heap.heap_size = heap.length = 0;
    
    return heap;
}
Heap lengthenHeap(Heap *p_heap) { // lengthen to heap_size
    p_heap->array_size = p_heap->heap_size;

    int * reacllocated_heap_array = (int *)realloc(p_heap->array, (p_heap->array_size+1) * sizeof(int));
    
    if (reacllocated_heap_array)
        p_heap->array = reacllocated_heap_array;
    else
        printf("Unable to reacllocate");
}

int parentOfIndex(int index) {
    return index/2;
}
int leftOfIndex(int index) {
    return 2*index;
}
int rightOfIndex(int index) {
    return 2*index+1;
}

void maxHeapify(Heap heap, int iThis) {
    int iLeft = leftOfIndex(iThis);
    int iRight = rightOfIndex(iThis);
    int iLargest;
    
    if (iLeft <= heap.heap_size && heap.array[iLeft] > heap.array[iThis]) 
        iLargest = iLeft;
    else
        iLargest = iThis;
    
    if (iRight <= heap.heap_size && heap.array[iRight] > heap.array[iLargest]) 
        iLargest = iRight;
    
    if (iLargest != iThis) {
        swap(heap.array, iThis, iLargest);
        // iLargest is no longer the index for largest value within the trinode.
        maxHeapify(heap, iLargest);
    }
}
void buildMaxHeap(Heap *p_heap) {
    p_heap->heap_size = p_heap->length;
    
    for (int i = p_heap->length/2; i >= 1; i--)
        maxHeapify(*p_heap, i);
}

int heapExtractMax(Heap *p_heap) {
    if (p_heap->heap_size < 1) return NEG_INF_KEY; // error
    
    int max = p_heap->array[1];
    p_heap->array[1] = p_heap->array[p_heap->heap_size];
    p_heap->heap_size--;
    maxHeapify(*p_heap,1);
    return max;
}


void heapIncreaseKey(Heap *p_heap, int nodeIndex, int keyToBeIncreasedTo) {
    if (keyToBeIncreasedTo < p_heap->array[nodeIndex]) return; //error
    
    p_heap->array[nodeIndex] = keyToBeIncreasedTo;
    
    while (nodeIndex > 1 && p_heap->array[parentOfIndex(nodeIndex)] < p_heap->array[nodeIndex]) {
        swap(p_heap->array, nodeIndex, parentOfIndex(nodeIndex));
        nodeIndex = parentOfIndex(nodeIndex);
    }
    
    p_heap->length = p_heap->heap_size;
}
void maxHeapInsert(Heap *p_heap, int keyToBeAdded) {
    p_heap->length = p_heap->heap_size++;
    
    if (p_heap->array_size < p_heap->heap_size)
        lengthenHeap(p_heap);
    
    p_heap->array[p_heap->heap_size] = NEG_INF_KEY;
    heapIncreaseKey(p_heap, p_heap->heap_size, keyToBeAdded);
}



// sorting
void heapSort(Heap *p_heap) {
    buildMaxHeap(p_heap);
    
    for (int i = p_heap->length; i >= 2; i--) {
        swap(p_heap->array, 1, i);
        p_heap->heap_size--;
        maxHeapify(*p_heap, 1);
    }
}


int main(int argc, char** argv) {
    char command[MAX_CMD_LENGTH];
    
    Heap heap = createHeap();
    int nodeKey;
    // 1-origin
    
    while (1) {
        scanf("%s", command);
        
        if (strcmp(command, "insert") == 0) {
            scanf("%d", &(nodeKey));
            maxHeapInsert(&heap, nodeKey);
        }
        else if (strcmp(command, "extract") == 0)
            printf("%d\n", heapExtractMax(&heap));
        else if (strcmp(command, "end") == 0)
            return EXIT_SUCCESS;
    }
    
//    for (int i = 1; i <= nCommands; i++)
//        scanf("%d", &(heap.array[i]));
//    
//    //--- Lect 9 Prob B
//    buildMaxHeap(heap);
//    
//    for (int i = 1; i <= heap.length; i++) 
//        printf(" %d", heap.array[i]);
//    
//    printf("\n");
//    
//    //--- Lect 9 Prob A
//    for (int i = 1; i <= nNode; i++) {
//        printf("node %d: ", i);
//        printf("key = %d, ", heap.array[i]);
//        
//        if (i/2 > 0)
//            printf("parent key = %d, ", heap.array[i/2]);
//        
//        if (2*i <= heap.length)
//            printf("left key = %d, ", heap.array[2*i]);
//        
//        if (2*i+1 <= heap.length)
//            printf("right key = %d, ", heap.array[2*i+1]);
//        
//        printf("\n");
//    }

    return (EXIT_SUCCESS);
}


```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	swap
	.type	swap, @function
swap:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -24(%rbp)
	movl	%esi, -28(%rbp)
	movl	%edx, -32(%rbp)
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, -4(%rbp)
	movl	-32(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	-28(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	movq	-24(%rbp), %rdx
	addq	%rcx, %rdx
	movl	(%rax), %eax
	movl	%eax, (%rdx)
	movl	-32(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rax, %rdx
	movl	-4(%rbp), %eax
	movl	%eax, (%rdx)
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	swap, .-swap
	.globl	createHeap
	.type	createHeap, @function
createHeap:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$48, %rsp
	movq	%rdi, -40(%rbp)
	movl	$4, %edi
	call	malloc@PLT
	movq	%rax, -32(%rbp)
	movq	-32(%rbp), %rax
	movl	$0, (%rax)
	movl	$0, -20(%rbp)
	movl	-20(%rbp), %eax
	movl	%eax, -24(%rbp)
	movl	-24(%rbp), %eax
	movl	%eax, -16(%rbp)
	movq	-40(%rbp), %rcx
	movq	-32(%rbp), %rax
	movq	-24(%rbp), %rdx
	movq	%rax, (%rcx)
	movq	%rdx, 8(%rcx)
	movq	-16(%rbp), %rax
	movq	%rax, 16(%rcx)
	movq	-40(%rbp), %rax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	createHeap, .-createHeap
	.section	.rodata
.LC0:
	.string	"Unable to reacllocate"
	.text
	.globl	lengthenHeap
	.type	lengthenHeap, @function
lengthenHeap:
.LFB8:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movq	%rdi, -24(%rbp)
	movq	%rsi, -32(%rbp)
	movq	-32(%rbp), %rax
	movl	8(%rax), %edx
	movq	-32(%rbp), %rax
	movl	%edx, 16(%rax)
	movq	-32(%rbp), %rax
	movl	16(%rax), %eax
	addl	$1, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-32(%rbp), %rax
	movq	(%rax), %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	realloc@PLT
	movq	%rax, -8(%rbp)
	cmpq	$0, -8(%rbp)
	je	.L5
	movq	-32(%rbp), %rax
	movq	-8(%rbp), %rdx
	movq	%rdx, (%rax)
	jmp	.L6
.L5:
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L6:
	nop
	movq	-24(%rbp), %rax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.size	lengthenHeap, .-lengthenHeap
	.globl	parentOfIndex
	.type	parentOfIndex, @function
parentOfIndex:
.LFB9:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -4(%rbp)
	movl	-4(%rbp), %eax
	movl	%eax, %edx
	shrl	$31, %edx
	addl	%edx, %eax
	sarl	%eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE9:
	.size	parentOfIndex, .-parentOfIndex
	.globl	leftOfIndex
	.type	leftOfIndex, @function
leftOfIndex:
.LFB10:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -4(%rbp)
	movl	-4(%rbp), %eax
	addl	%eax, %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE10:
	.size	leftOfIndex, .-leftOfIndex
	.globl	rightOfIndex
	.type	rightOfIndex, @function
rightOfIndex:
.LFB11:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -4(%rbp)
	movl	-4(%rbp), %eax
	addl	%eax, %eax
	addl	$1, %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE11:
	.size	rightOfIndex, .-rightOfIndex
	.globl	maxHeapify
	.type	maxHeapify, @function
maxHeapify:
.LFB12:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movl	%edi, -20(%rbp)
	movl	-20(%rbp), %eax
	movl	%eax, %edi
	call	leftOfIndex
	movl	%eax, -8(%rbp)
	movl	-20(%rbp), %eax
	movl	%eax, %edi
	call	rightOfIndex
	movl	%eax, -4(%rbp)
	movl	24(%rbp), %eax
	cmpl	%eax, -8(%rbp)
	jg	.L14
	movq	16(%rbp), %rdx
	movl	-8(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movq	16(%rbp), %rcx
	movl	-20(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rcx, %rax
	movl	(%rax), %eax
	cmpl	%eax, %edx
	jle	.L14
	movl	-8(%rbp), %eax
	movl	%eax, -12(%rbp)
	jmp	.L15
.L14:
	movl	-20(%rbp), %eax
	movl	%eax, -12(%rbp)
.L15:
	movl	24(%rbp), %eax
	cmpl	%eax, -4(%rbp)
	jg	.L16
	movq	16(%rbp), %rdx
	movl	-4(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movq	16(%rbp), %rcx
	movl	-12(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rcx, %rax
	movl	(%rax), %eax
	cmpl	%eax, %edx
	jle	.L16
	movl	-4(%rbp), %eax
	movl	%eax, -12(%rbp)
.L16:
	movl	-12(%rbp), %eax
	cmpl	-20(%rbp), %eax
	je	.L18
	movq	16(%rbp), %rax
	movl	-12(%rbp), %edx
	movl	-20(%rbp), %ecx
	movl	%ecx, %esi
	movq	%rax, %rdi
	call	swap
	movl	-12(%rbp), %eax
	subq	$8, %rsp
	pushq	32(%rbp)
	pushq	24(%rbp)
	pushq	16(%rbp)
	movl	%eax, %edi
	call	maxHeapify
	addq	$32, %rsp
.L18:
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE12:
	.size	maxHeapify, .-maxHeapify
	.globl	buildMaxHeap
	.type	buildMaxHeap, @function
buildMaxHeap:
.LFB13:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movq	%rdi, -24(%rbp)
	movq	-24(%rbp), %rax
	movl	12(%rax), %edx
	movq	-24(%rbp), %rax
	movl	%edx, 8(%rax)
	movq	-24(%rbp), %rax
	movl	12(%rax), %eax
	movl	%eax, %edx
	shrl	$31, %edx
	addl	%edx, %eax
	sarl	%eax
	movl	%eax, -4(%rbp)
	jmp	.L20
.L21:
	movl	-4(%rbp), %edx
	subq	$8, %rsp
	movq	-24(%rbp), %rax
	pushq	16(%rax)
	pushq	8(%rax)
	pushq	(%rax)
	movl	%edx, %edi
	call	maxHeapify
	addq	$32, %rsp
	subl	$1, -4(%rbp)
.L20:
	cmpl	$0, -4(%rbp)
	jg	.L21
	nop
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE13:
	.size	buildMaxHeap, .-buildMaxHeap
	.globl	heapExtractMax
	.type	heapExtractMax, @function
heapExtractMax:
.LFB14:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movq	%rdi, -24(%rbp)
	movq	-24(%rbp), %rax
	movl	8(%rax), %eax
	testl	%eax, %eax
	jg	.L23
	movl	$-1, %eax
	jmp	.L24
.L23:
	movq	-24(%rbp), %rax
	movq	(%rax), %rax
	movl	4(%rax), %eax
	movl	%eax, -4(%rbp)
	movq	-24(%rbp), %rax
	movq	(%rax), %rdx
	movq	-24(%rbp), %rax
	movl	8(%rax), %eax
	cltq
	salq	$2, %rax
	leaq	(%rdx,%rax), %rcx
	movq	-24(%rbp), %rax
	movq	(%rax), %rax
	leaq	4(%rax), %rdx
	movl	(%rcx), %eax
	movl	%eax, (%rdx)
	movq	-24(%rbp), %rax
	movl	8(%rax), %eax
	leal	-1(%rax), %edx
	movq	-24(%rbp), %rax
	movl	%edx, 8(%rax)
	subq	$8, %rsp
	movq	-24(%rbp), %rax
	pushq	16(%rax)
	pushq	8(%rax)
	pushq	(%rax)
	movl	$1, %edi
	call	maxHeapify
	addq	$32, %rsp
	movl	-4(%rbp), %eax
.L24:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE14:
	.size	heapExtractMax, .-heapExtractMax
	.globl	heapIncreaseKey
	.type	heapIncreaseKey, @function
heapIncreaseKey:
.LFB15:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%rbx
	subq	$16, %rsp
	.cfi_offset 3, -24
	movq	%rdi, -16(%rbp)
	movl	%esi, -20(%rbp)
	movl	%edx, -24(%rbp)
	movq	-16(%rbp), %rax
	movq	(%rax), %rdx
	movl	-20(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cmpl	%eax, -24(%rbp)
	jl	.L31
	movq	-16(%rbp), %rax
	movq	(%rax), %rdx
	movl	-20(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rax, %rdx
	movl	-24(%rbp), %eax
	movl	%eax, (%rdx)
	jmp	.L28
.L30:
	movl	-20(%rbp), %eax
	movl	%eax, %edi
	call	parentOfIndex
	movl	%eax, %edx
	movq	-16(%rbp), %rax
	movq	(%rax), %rax
	movl	-20(%rbp), %ecx
	movl	%ecx, %esi
	movq	%rax, %rdi
	call	swap
	movl	-20(%rbp), %eax
	movl	%eax, %edi
	call	parentOfIndex
	movl	%eax, -20(%rbp)
.L28:
	cmpl	$1, -20(%rbp)
	jle	.L29
	movq	-16(%rbp), %rax
	movq	(%rax), %rbx
	movl	-20(%rbp), %eax
	movl	%eax, %edi
	call	parentOfIndex
	cltq
	salq	$2, %rax
	addq	%rbx, %rax
	movl	(%rax), %edx
	movq	-16(%rbp), %rax
	movq	(%rax), %rcx
	movl	-20(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rcx, %rax
	movl	(%rax), %eax
	cmpl	%eax, %edx
	jl	.L30
.L29:
	movq	-16(%rbp), %rax
	movl	8(%rax), %edx
	movq	-16(%rbp), %rax
	movl	%edx, 12(%rax)
	jmp	.L25
.L31:
	nop
.L25:
	movq	-8(%rbp), %rbx
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE15:
	.size	heapIncreaseKey, .-heapIncreaseKey
	.globl	maxHeapInsert
	.type	maxHeapInsert, @function
maxHeapInsert:
.LFB16:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$64, %rsp
	movq	%rdi, -24(%rbp)
	movl	%esi, -28(%rbp)
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movq	-24(%rbp), %rax
	movl	8(%rax), %eax
	leal	1(%rax), %ecx
	movq	-24(%rbp), %rdx
	movl	%ecx, 8(%rdx)
	movq	-24(%rbp), %rdx
	movl	%eax, 12(%rdx)
	movq	-24(%rbp), %rax
	movl	16(%rax), %edx
	movq	-24(%rbp), %rax
	movl	8(%rax), %eax
	cmpl	%eax, %edx
	jge	.L33
	leaq	-64(%rbp), %rax
	movq	-24(%rbp), %rdx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	lengthenHeap
.L33:
	movq	-24(%rbp), %rax
	movq	(%rax), %rdx
	movq	-24(%rbp), %rax
	movl	8(%rax), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movl	$-1, (%rax)
	movq	-24(%rbp), %rax
	movl	8(%rax), %ecx
	movl	-28(%rbp), %edx
	movq	-24(%rbp), %rax
	movl	%ecx, %esi
	movq	%rax, %rdi
	call	heapIncreaseKey
	nop
	movq	-8(%rbp), %rax
	subq	%fs:40, %rax
	je	.L34
	call	__stack_chk_fail@PLT
.L34:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE16:
	.size	maxHeapInsert, .-maxHeapInsert
	.globl	heapSort
	.type	heapSort, @function
heapSort:
.LFB17:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movq	%rdi, -24(%rbp)
	movq	-24(%rbp), %rax
	movq	%rax, %rdi
	call	buildMaxHeap
	movq	-24(%rbp), %rax
	movl	12(%rax), %eax
	movl	%eax, -4(%rbp)
	jmp	.L36
.L37:
	movq	-24(%rbp), %rax
	movq	(%rax), %rax
	movl	-4(%rbp), %edx
	movl	$1, %esi
	movq	%rax, %rdi
	call	swap
	movq	-24(%rbp), %rax
	movl	8(%rax), %eax
	leal	-1(%rax), %edx
	movq	-24(%rbp), %rax
	movl	%edx, 8(%rax)
	subq	$8, %rsp
	movq	-24(%rbp), %rax
	pushq	16(%rax)
	pushq	8(%rax)
	pushq	(%rax)
	movl	$1, %edi
	call	maxHeapify
	addq	$32, %rsp
	subl	$1, -4(%rbp)
.L36:
	cmpl	$1, -4(%rbp)
	jg	.L37
	nop
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE17:
	.size	heapSort, .-heapSort
	.section	.rodata
.LC1:
	.string	"%s"
.LC2:
	.string	"insert"
.LC3:
	.string	"%d"
.LC4:
	.string	"extract"
.LC5:
	.string	"%d\n"
.LC6:
	.string	"end"
	.text
	.globl	main
	.type	main, @function
main:
.LFB18:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$80, %rsp
	movl	%edi, -68(%rbp)
	movq	%rsi, -80(%rbp)
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-48(%rbp), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	createHeap
.L43:
	leaq	-18(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	leaq	-18(%rbp), %rax
	leaq	.LC2(%rip), %rdx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L39
	leaq	-52(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-52(%rbp), %edx
	leaq	-48(%rbp), %rax
	movl	%edx, %esi
	movq	%rax, %rdi
	call	maxHeapInsert
	jmp	.L43
.L39:
	leaq	-18(%rbp), %rax
	leaq	.LC4(%rip), %rdx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L41
	leaq	-48(%rbp), %rax
	movq	%rax, %rdi
	call	heapExtractMax
	movl	%eax, %esi
	leaq	.LC5(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L43
.L41:
	leaq	-18(%rbp), %rax
	leaq	.LC6(%rip), %rdx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L43
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L44
	call	__stack_chk_fail@PLT
.L44:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE18:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:
```

Only output the optimized assembly code. Do not include any other text. Do not write any comments in the assembly code. Wrap the assembly code in ```assembly``` tags.
user
	.file	"temp.c"
	.text
	.p2align 4
	.globl	swap
	.type	swap, @function
swap:
.LFB51:
	.cfi_startproc
	endbr64
	movslq	%esi, %rsi
	movslq	%edx, %rdx
	leaq	(%rdi,%rsi,4), %rcx
	leaq	(%rdi,%rdx,4), %rax
	movl	(%rcx), %esi
	movl	(%rax), %edx
	movl	%edx, (%rcx)
	movl	%esi, (%rax)
	ret
	.cfi_endproc
.LFE51:
	.size	swap, .-swap
	.p2align 4
	.globl	createHeap
	.type	createHeap, @function
createHeap:
.LFB52:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movq	%rdi, %r12
	movl	$4, %edi
	call	malloc@PLT
	movq	$0, 8(%r12)
	movl	$0, (%rax)
	movq	%rax, (%r12)
	movq	%r12, %rax
	movl	$0, 16(%r12)
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE52:
	.size	createHeap, .-createHeap
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"Unable to reacllocate"
	.text
	.p2align 4
	.globl	lengthenHeap
	.type	lengthenHeap, @function
lengthenHeap:
.LFB53:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movq	%rdi, %r12
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	movq	%rsi, %rbx
	subq	$8, %rsp
	.cfi_def_cfa_offset 32
	movl	8(%rsi), %eax
	movq	(%rbx), %rdi
	movl	%eax, 16(%rsi)
	leal	1(%rax), %esi
	movslq	%esi, %rsi
	salq	$2, %rsi
	call	realloc@PLT
	testq	%rax, %rax
	je	.L6
	movq	%rax, (%rbx)
.L7:
	addq	$8, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 24
	movq	%r12, %rax
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
.L6:
	.cfi_restore_state
	leaq	.LC0(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L7
	.cfi_endproc
.LFE53:
	.size	lengthenHeap, .-lengthenHeap
	.p2align 4
	.globl	parentOfIndex
	.type	parentOfIndex, @function
parentOfIndex:
.LFB54:
	.cfi_startproc
	endbr64
	movl	%edi, %eax
	shrl	$31, %eax
	addl	%edi, %eax
	sarl	%eax
	ret
	.cfi_endproc
.LFE54:
	.size	parentOfIndex, .-parentOfIndex
	.p2align 4
	.globl	leftOfIndex
	.type	leftOfIndex, @function
leftOfIndex:
.LFB55:
	.cfi_startproc
	endbr64
	leal	(%rdi,%rdi), %eax
	ret
	.cfi_endproc
.LFE55:
	.size	leftOfIndex, .-leftOfIndex
	.p2align 4
	.globl	rightOfIndex
	.type	rightOfIndex, @function
rightOfIndex:
.LFB56:
	.cfi_startproc
	endbr64
	leal	1(%rdi,%rdi), %eax
	ret
	.cfi_endproc
.LFE56:
	.size	rightOfIndex, .-rightOfIndex
	.p2align 4
	.globl	maxHeapify
	.type	maxHeapify, @function
maxHeapify:
.LFB57:
	.cfi_startproc
	endbr64
	movq	8(%rsp), %rsi
	movl	16(%rsp), %r10d
	jmp	.L16
	.p2align 4,,10
	.p2align 3
.L20:
	movslq	%eax, %r9
	movslq	%edi, %r11
	leaq	(%rsi,%r9,4), %rdx
	movl	(%rdx), %ecx
	cmpl	(%rsi,%r11,4), %ecx
	jle	.L13
	cmpl	%r10d, %r8d
	jle	.L17
.L14:
	cmpl	%edi, %eax
	je	.L12
	movslq	%edi, %rdi
	leaq	(%rsi,%rdi,4), %rdi
	movl	(%rdi), %r8d
	movl	%ecx, (%rdi)
	movl	%eax, %edi
	movl	%r8d, (%rdx)
.L16:
	leal	(%rdi,%rdi), %eax
	leal	1(%rax), %r8d
	cmpl	%eax, %r10d
	jge	.L20
.L13:
	cmpl	%r10d, %r8d
	jg	.L12
	movl	%edi, %eax
	movslq	%edi, %r9
.L17:
	movslq	%r8d, %rdx
	leaq	(%rsi,%r9,4), %r9
	leaq	(%rsi,%rdx,4), %rdx
	movl	(%r9), %r11d
	movl	(%rdx), %ecx
	cmpl	%r11d, %ecx
	jg	.L18
	movl	%r11d, %ecx
	movq	%r9, %rdx
	jmp	.L14
	.p2align 4,,10
	.p2align 3
.L18:
	movl	%r8d, %eax
	jmp	.L14
	.p2align 4,,10
	.p2align 3
.L12:
	ret
	.cfi_endproc
.LFE57:
	.size	maxHeapify, .-maxHeapify
	.p2align 4
	.globl	buildMaxHeap
	.type	buildMaxHeap, @function
buildMaxHeap:
.LFB58:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	movl	12(%rdi), %r9d
	movl	%r9d, %ebx
	movl	%r9d, 8(%rdi)
	shrl	$31, %ebx
	addl	%r9d, %ebx
	sarl	%ebx
	cmpl	$1, %r9d
	jle	.L21
	movq	%rdi, %rbp
	movq	(%rdi), %rdi
	.p2align 4,,10
	.p2align 3
.L27:
	movslq	%ebx, %rax
	jmp	.L26
	.p2align 4,,10
	.p2align 3
.L35:
	movslq	%edx, %r10
	movslq	%eax, %r11
	leaq	(%rdi,%r10,4), %rcx
	movl	(%rcx), %esi
	cmpl	(%rdi,%r11,4), %esi
	jle	.L23
	cmpl	%r9d, %r8d
	jle	.L28
.L24:
	cmpl	%edx, %eax
	je	.L25
	leaq	(%rdi,%rax,4), %rax
	movl	(%rax), %r8d
	movl	%esi, (%rax)
	movslq	%edx, %rax
	movl	%r8d, (%rcx)
.L26:
	leal	(%rax,%rax), %edx
	leal	1(%rdx), %r8d
	cmpl	%r9d, %edx
	jle	.L35
.L23:
	cmpl	%r9d, %r8d
	jg	.L25
	movl	%eax, %edx
	movslq	%eax, %r10
.L28:
	movslq	%r8d, %rcx
	leaq	(%rdi,%r10,4), %r10
	leaq	(%rdi,%rcx,4), %rcx
	movl	(%r10), %r11d
	movl	(%rcx), %esi
	cmpl	%r11d, %esi
	jg	.L29
	movl	%r11d, %esi
	movq	%r10, %rcx
	jmp	.L24
	.p2align 4,,10
	.p2align 3
.L29:
	movl	%r8d, %edx
	jmp	.L24
	.p2align 4,,10
	.p2align 3
.L25:
	subl	$1, %ebx
	je	.L21
	movl	8(%rbp), %r9d
	jmp	.L27
	.p2align 4,,10
	.p2align 3
.L21:
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE58:
	.size	buildMaxHeap, .-buildMaxHeap
	.p2align 4
	.globl	heapExtractMax
	.type	heapExtractMax, @function
heapExtractMax:
.LFB59:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movslq	8(%rdi), %rax
	testl	%eax, %eax
	jle	.L43
	movq	(%rdi), %rcx
	movl	(%rcx,%rax,4), %eax
	movl	4(%rcx), %r12d
	movl	%eax, 4(%rcx)
	movl	8(%rdi), %eax
	leal	-1(%rax), %r9d
	movl	$1, %eax
	movl	%r9d, 8(%rdi)
	jmp	.L41
	.p2align 4,,10
	.p2align 3
.L47:
	movslq	%edx, %r10
	movslq	%eax, %r11
	leaq	(%rcx,%r10,4), %rsi
	movl	(%rsi), %edi
	cmpl	(%rcx,%r11,4), %edi
	jle	.L38
	cmpl	%r8d, %r9d
	jge	.L42
.L39:
	cmpl	%edx, %eax
	je	.L36
	leaq	(%rcx,%rax,4), %rax
	movl	(%rax), %r8d
	movl	%edi, (%rax)
	movslq	%edx, %rax
	movl	%r8d, (%rsi)
.L41:
	leal	(%rax,%rax), %edx
	leal	1(%rdx), %r8d
	cmpl	%edx, %r9d
	jge	.L47
.L38:
	cmpl	%r8d, %r9d
	jl	.L36
	movl	%eax, %edx
	movslq	%eax, %r10
.L42:
	movslq	%r8d, %rsi
	leaq	(%rcx,%r10,4), %r10
	leaq	(%rcx,%rsi,4), %rsi
	movl	(%r10), %r11d
	movl	(%rsi), %edi
	cmpl	%r11d, %edi
	jg	.L44
	movl	%r11d, %edi
	movq	%r10, %rsi
	jmp	.L39
	.p2align 4,,10
	.p2align 3
.L44:
	movl	%r8d, %edx
	jmp	.L39
.L43:
	movl	$-1, %r12d
.L36:
	movl	%r12d, %eax
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE59:
	.size	heapExtractMax, .-heapExtractMax
	.p2align 4
	.globl	heapIncreaseKey
	.type	heapIncreaseKey, @function
heapIncreaseKey:
.LFB60:
	.cfi_startproc
	endbr64
	movq	(%rdi), %r8
	movslq	%esi, %rax
	movq	%rdi, %r9
	leaq	(%r8,%rax,4), %rax
	cmpl	%edx, (%rax)
	jg	.L48
	movl	%edx, (%rax)
	cmpl	$1, %esi
	jg	.L50
	jmp	.L51
	.p2align 4,,10
	.p2align 3
.L52:
	movl	%ecx, (%rax)
	movl	%edx, (%rdi)
	cmpl	$1, %esi
	je	.L51
.L50:
	movslq	%esi, %rax
	sarl	%esi
	movslq	%esi, %rcx
	leaq	(%r8,%rax,4), %rax
	leaq	(%r8,%rcx,4), %rdi
	movl	(%rdi), %ecx
	cmpl	%edx, %ecx
	jl	.L52
.L51:
	movl	8(%r9), %eax
	movl	%eax, 12(%r9)
	ret
	.p2align 4,,10
	.p2align 3
.L48:
	ret
	.cfi_endproc
.LFE60:
	.size	heapIncreaseKey, .-heapIncreaseKey
	.p2align 4
	.globl	maxHeapInsert
	.type	maxHeapInsert, @function
maxHeapInsert:
.LFB61:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rdi, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	movl	%esi, %ebx
	subq	$8, %rsp
	.cfi_def_cfa_offset 32
	movl	8(%rdi), %edx
	leal	1(%rdx), %eax
	movd	%edx, %xmm1
	movd	%eax, %xmm0
	punpckldq	%xmm1, %xmm0
	movq	%xmm0, 8(%rdi)
	movq	(%rdi), %rdi
	cmpl	16(%rbp), %eax
	jg	.L69
.L58:
	cltq
	movl	$-1, (%rdi,%rax,4)
	movslq	8(%rbp), %rdx
	movq	%rdx, %rax
	leaq	(%rdi,%rdx,4), %rdx
	cmpl	(%rdx), %ebx
	jl	.L57
	movl	%ebx, (%rdx)
	cmpl	$1, %eax
	jg	.L61
	jmp	.L62
	.p2align 4,,10
	.p2align 3
.L63:
	movl	%ecx, (%rdx)
	movl	%ebx, (%rsi)
	cmpl	$1, %eax
	je	.L62
.L61:
	movslq	%eax, %rdx
	sarl	%eax
	movslq	%eax, %rcx
	leaq	(%rdi,%rdx,4), %rdx
	leaq	(%rdi,%rcx,4), %rsi
	movl	(%rsi), %ecx
	cmpl	%ecx, %ebx
	jg	.L63
.L62:
	movl	8(%rbp), %eax
	movl	%eax, 12(%rbp)
.L57:
	addq	$8, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L69:
	.cfi_restore_state
	leal	2(%rdx), %esi
	movl	%eax, 16(%rbp)
	movslq	%esi, %rsi
	salq	$2, %rsi
	call	realloc@PLT
	movq	%rax, %rdi
	testq	%rax, %rax
	je	.L59
	movq	%rax, 0(%rbp)
	movl	8(%rbp), %eax
	jmp	.L58
.L59:
	movl	$1, %edi
	leaq	.LC0(%rip), %rsi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	0(%rbp), %rdi
	movl	8(%rbp), %eax
	jmp	.L58
	.cfi_endproc
.LFE61:
	.size	maxHeapInsert, .-maxHeapInsert
	.p2align 4
	.globl	heapSort
	.type	heapSort, @function
heapSort:
.LFB62:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	movl	12(%rdi), %r10d
	movl	%r10d, %ebp
	movl	%r10d, 8(%rdi)
	shrl	$31, %ebp
	addl	%r10d, %ebp
	sarl	%ebp
	cmpl	$1, %r10d
	jle	.L70
	movq	(%rdi), %rdx
	movq	%rdi, %r9
	.p2align 4,,10
	.p2align 3
.L78:
	movslq	%ebp, %rax
	jmp	.L75
	.p2align 4,,10
	.p2align 3
.L92:
	movslq	%ecx, %r11
	movslq	%eax, %rbx
	leaq	(%rdx,%r11,4), %rsi
	movl	(%rsi), %edi
	cmpl	(%rdx,%rbx,4), %edi
	jle	.L72
	cmpl	%r10d, %r8d
	jle	.L85
.L73:
	cmpl	%ecx, %eax
	je	.L74
	leaq	(%rdx,%rax,4), %rax
	movl	(%rax), %r8d
	movl	%edi, (%rax)
	movslq	%ecx, %rax
	movl	%r8d, (%rsi)
.L75:
	leal	(%rax,%rax), %ecx
	leal	1(%rcx), %r8d
	cmpl	%r10d, %ecx
	jle	.L92
.L72:
	cmpl	%r10d, %r8d
	jg	.L74
	movl	%eax, %ecx
	movslq	%eax, %r11
.L85:
	movslq	%r8d, %rsi
	leaq	(%rdx,%r11,4), %r11
	leaq	(%rdx,%rsi,4), %rsi
	movl	(%r11), %ebx
	movl	(%rsi), %edi
	cmpl	%ebx, %edi
	jg	.L86
	movl	%ebx, %edi
	movq	%r11, %rsi
	jmp	.L73
	.p2align 4,,10
	.p2align 3
.L86:
	movl	%r8d, %ecx
	jmp	.L73
	.p2align 4,,10
	.p2align 3
.L74:
	subl	$1, %ebp
	je	.L93
	movl	8(%r9), %r10d
	jmp	.L78
	.p2align 4,,10
	.p2align 3
.L81:
	subq	$1, %rbp
	cmpl	$1, %ebp
	jg	.L83
.L70:
	popq	%rbx
	.cfi_remember_state
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L93:
	.cfi_restore_state
	movslq	12(%r9), %rbp
	cmpl	$1, %ebp
	jle	.L70
	.p2align 4,,10
	.p2align 3
.L83:
	movl	4(%rdx), %eax
	movl	(%rdx,%rbp,4), %ecx
	movl	%ecx, 4(%rdx)
	movl	%eax, (%rdx,%rbp,4)
	movl	8(%r9), %eax
	leal	-1(%rax), %r10d
	movl	$1, %eax
	movl	%r10d, 8(%r9)
	jmp	.L82
	.p2align 4,,10
	.p2align 3
.L94:
	movslq	%ecx, %r11
	movslq	%eax, %rbx
	leaq	(%rdx,%r11,4), %rsi
	movl	(%rsi), %edi
	cmpl	(%rdx,%rbx,4), %edi
	jle	.L79
	cmpl	%r8d, %r10d
	jge	.L84
.L80:
	cmpl	%ecx, %eax
	je	.L81
	leaq	(%rdx,%rax,4), %rax
	movl	(%rax), %r8d
	movl	%edi, (%rax)
	movslq	%ecx, %rax
	movl	%r8d, (%rsi)
.L82:
	leal	(%rax,%rax), %ecx
	leal	1(%rcx), %r8d
	cmpl	%ecx, %r10d
	jge	.L94
.L79:
	cmpl	%r8d, %r10d
	jl	.L81
	movl	%eax, %ecx
	movslq	%eax, %r11
.L84:
	movslq	%r8d, %rsi
	leaq	(%rdx,%r11,4), %r11
	leaq	(%rdx,%rsi,4), %rsi
	movl	(%r11), %ebx
	movl	(%rsi), %edi
	cmpl	%ebx, %edi
	jg	.L87
	movl	%ebx, %edi
	movq	%r11, %rsi
	jmp	.L80
	.p2align 4,,10
	.p2align 3
.L87:
	movl	%r8d, %ecx
	jmp	.L80
	.cfi_endproc
.LFE62:
	.size	heapSort, .-heapSort
	.section	.rodata.str1.1
.LC1:
	.string	"%s"
.LC2:
	.string	"insert"
.LC3:
	.string	"%d"
.LC4:
	.string	"extract"
.LC5:
	.string	"%d\n"
.LC6:
	.string	"end"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB63:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movl	$4, %edi
	xorl	%r15d, %r15d
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	leaq	.LC5(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movabsq	$32760367481649253, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	leaq	.LC1(%rip), %rbx
	subq	$56, %rsp
	.cfi_def_cfa_offset 112
	movq	%fs:40, %rax
	movq	%rax, 40(%rsp)
	xorl	%eax, %eax
	leaq	30(%rsp), %r13
	call	malloc@PLT
	movl	$0, 8(%rsp)
	movl	$0, (%rax)
	movq	%rax, %r14
	.p2align 4,,10
	.p2align 3
.L96:
	xorl	%eax, %eax
	movq	%r13, %rsi
	movq	%rbx, %rdi
	call	__isoc99_scanf@PLT
	cmpl	$1702063721, 0(%r13)
	je	.L132
.L97:
	cmpq	%rbp, 0(%r13)
	je	.L133
	cmpl	$6581861, 0(%r13)
	jne	.L96
	movq	40(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L134
	addq	$56, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L132:
	.cfi_restore_state
	cmpw	$29810, 4(%r13)
	jne	.L97
	cmpb	$0, 6(%r13)
	jne	.L97
	leaq	24(%rsp), %rsi
	leaq	.LC3(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	24(%rsp), %r8d
	leal	1(%r15), %r9d
	cmpl	%r9d, 8(%rsp)
	jl	.L135
.L100:
	movslq	%r9d, %rax
	leaq	(%r14,%rax,4), %rax
	cmpl	$-1, %r8d
	jl	.L101
	movl	%r8d, (%rax)
	movl	$1, %r15d
	movl	%r9d, %eax
	cmpl	$1, %r9d
	jne	.L102
	jmp	.L96
	.p2align 4,,10
	.p2align 3
.L104:
	movl	%ecx, (%rdx)
	movl	%r8d, (%rsi)
	cmpl	$1, %eax
	je	.L119
.L102:
	movslq	%eax, %rdx
	sarl	%eax
	movslq	%eax, %rcx
	leaq	(%r14,%rdx,4), %rdx
	leaq	(%r14,%rcx,4), %rsi
	movl	(%rsi), %ecx
	cmpl	%ecx, %r8d
	jg	.L104
.L119:
	movl	%r9d, %r15d
	jmp	.L96
	.p2align 4,,10
	.p2align 3
.L133:
	testl	%r15d, %r15d
	je	.L136
	movslq	%r15d, %rax
	movl	4(%r14), %r8d
	subl	$1, %r15d
	movl	(%r14,%rax,4), %eax
	movl	%eax, 4(%r14)
	movl	$1, %eax
	jmp	.L112
	.p2align 4,,10
	.p2align 3
.L137:
	movslq	%ecx, %rdx
	movslq	%eax, %r10
	leaq	(%r14,%rdx,4), %rsi
	movl	(%rsi), %edi
	cmpl	(%r14,%r10,4), %edi
	jle	.L109
	cmpl	%r9d, %r15d
	jge	.L115
.L110:
	cmpl	%ecx, %eax
	je	.L108
	leaq	(%r14,%rax,4), %rax
	movl	(%rax), %edx
	movl	%edi, (%rax)
	movslq	%ecx, %rax
	movl	%edx, (%rsi)
.L112:
	leal	(%rax,%rax), %ecx
	leal	1(%rcx), %r9d
	cmpl	%ecx, %r15d
	jge	.L137
.L109:
	cmpl	%r9d, %r15d
	jl	.L108
	movl	%eax, %ecx
	movslq	%eax, %rdx
.L115:
	movslq	%r9d, %rsi
	leaq	(%r14,%rdx,4), %rdx
	leaq	(%r14,%rsi,4), %rsi
	movl	(%rdx), %r10d
	movl	(%rsi), %edi
	cmpl	%r10d, %edi
	jg	.L121
	movl	%r10d, %edi
	movq	%rdx, %rsi
	jmp	.L110
	.p2align 4,,10
	.p2align 3
.L121:
	movl	%r9d, %ecx
	jmp	.L110
.L136:
	orl	$-1, %r8d
	.p2align 4,,10
	.p2align 3
.L108:
	movl	%r8d, %edx
	movq	%r12, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L96
	.p2align 4,,10
	.p2align 3
.L101:
	movl	$-1, (%rax)
	movl	%r9d, %r15d
	jmp	.L96
.L135:
	leal	2(%r15), %esi
	movq	%r14, %rdi
	movl	%r9d, 12(%rsp)
	movslq	%esi, %rsi
	movl	%r8d, 8(%rsp)
	salq	$2, %rsi
	call	realloc@PLT
	movl	12(%rsp), %r9d
	movl	8(%rsp), %r8d
	testq	%rax, %rax
	movl	%r9d, 8(%rsp)
	je	.L138
	movq	%rax, %r14
	jmp	.L100
.L138:
	leaq	.LC0(%rip), %rsi
	movl	$1, %edi
	movl	%r8d, 12(%rsp)
	call	__printf_chk@PLT
	movl	8(%rsp), %r9d
	movl	12(%rsp), %r8d
	jmp	.L100
.L134:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE63:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:

rule
	.file	"temp.c"
	.text
	.p2align 4
	.globl	swap
	.type	swap, @function
swap:
.LFB51:
	.cfi_startproc
	endbr64
	movslq	%esi, %rsi
	movslq	%edx, %rdx
	leaq	(%rdi,%rsi,4), %rcx
	leaq	(%rdi,%rdx,4), %rax
	movl	(%rcx), %esi
	movl	(%rax), %edx
	movl	%edx, (%rcx)
	movl	%esi, (%rax)
	ret
	.cfi_endproc
.LFE51:
	.size	swap, .-swap
	.p2align 4
	.globl	createHeap
	.type	createHeap, @function
createHeap:
.LFB52:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movq	%rdi, %r12
	movl	$4, %edi
	call	malloc@PLT
	movq	$0, 8(%r12)
	movl	$0, (%rax)
	movq	%rax, (%r12)
	movq	%r12, %rax
	movl	$0, 16(%r12)
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE52:
	.size	createHeap, .-createHeap
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"Unable to reacllocate"
	.text
	.p2align 4
	.globl	lengthenHeap
	.type	lengthenHeap, @function
lengthenHeap:
.LFB53:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movq	%rdi, %r12
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	movq	%rsi, %rbx
	subq	$8, %rsp
	.cfi_def_cfa_offset 32
	movl	8(%rsi), %eax
	movq	(%rbx), %rdi
	movl	%eax, 16(%rsi)
	leal	1(%rax), %esi
	movslq	%esi, %rsi
	salq	$2, %rsi
	call	realloc@PLT
	testq	%rax, %rax
	je	.L6
	movq	%rax, (%rbx)
.L7:
	addq	$8, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 24
	movq	%r12, %rax
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
.L6:
	.cfi_restore_state
	leaq	.LC0(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L7
	.cfi_endproc
.LFE53:
	.size	lengthenHeap, .-lengthenHeap
	.p2align 4
	.globl	parentOfIndex
	.type	parentOfIndex, @function
parentOfIndex:
.LFB54:
	.cfi_startproc
	endbr64
	movl	%edi, %eax
	shrl	$31, %eax
	addl	%edi, %eax
	sarl	%eax
	ret
	.cfi_endproc
.LFE54:
	.size	parentOfIndex, .-parentOfIndex
	.p2align 4
	.globl	leftOfIndex
	.type	leftOfIndex, @function
leftOfIndex:
.LFB55:
	.cfi_startproc
	endbr64
	leal	(%rdi,%rdi), %eax
	ret
	.cfi_endproc
.LFE55:
	.size	leftOfIndex, .-leftOfIndex
	.p2align 4
	.globl	rightOfIndex
	.type	rightOfIndex, @function
rightOfIndex:
.LFB56:
	.cfi_startproc
	endbr64
	leal	1(%rdi,%rdi), %eax
	ret
	.cfi_endproc
.LFE56:
	.size	rightOfIndex, .-rightOfIndex
	.p2align 4
	.globl	maxHeapify
	.type	maxHeapify, @function
maxHeapify:
.LFB57:
	.cfi_startproc
	endbr64
	movq	8(%rsp), %rsi
	movl	16(%rsp), %r10d
	jmp	.L16
	.p2align 4,,10
	.p2align 3
.L20:
	movslq	%eax, %r9
	movslq	%edi, %r11
	leaq	(%rsi,%r9,4), %rdx
	movl	(%rdx), %ecx
	cmpl	(%rsi,%r11,4), %ecx
	jle	.L13
	cmpl	%r10d, %r8d
	jle	.L17
.L14:
	cmpl	%edi, %eax
	je	.L12
	movslq	%edi, %rdi
	leaq	(%rsi,%rdi,4), %rdi
	movl	(%rdi), %r8d
	movl	%ecx, (%rdi)
	movl	%eax, %edi
	movl	%r8d, (%rdx)
.L16:
	leal	(%rdi,%rdi), %eax
	leal	1(%rax), %r8d
	cmpl	%eax, %r10d
	jge	.L20
.L13:
	cmpl	%r10d, %r8d
	jg	.L12
	movl	%edi, %eax
	movslq	%edi, %r9
.L17:
	movslq	%r8d, %rdx
	leaq	(%rsi,%r9,4), %r9
	leaq	(%rsi,%rdx,4), %rdx
	movl	(%r9), %r11d
	movl	(%rdx), %ecx
	cmpl	%r11d, %ecx
	jg	.L18
	movl	%r11d, %ecx
	movq	%r9, %rdx
	jmp	.L14
	.p2align 4,,10
	.p2align 3
.L18:
	movl	%r8d, %eax
	jmp	.L14
	.p2align 4,,10
	.p2align 3
.L12:
	ret
	.cfi_endproc
.LFE57:
	.size	maxHeapify, .-maxHeapify
	.p2align 4
	.globl	buildMaxHeap
	.type	buildMaxHeap, @function
buildMaxHeap:
.LFB58:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	movl	12(%rdi), %r9d
	movl	%r9d, %ebx
	movl	%r9d, 8(%rdi)
	shrl	$31, %ebx
	addl	%r9d, %ebx
	sarl	%ebx
	cmpl	$1, %r9d
	jle	.L21
	movq	%rdi, %rbp
	movq	(%rdi), %rdi
	.p2align 4,,10
	.p2align 3
.L27:
	movslq	%ebx, %rax
	jmp	.L26
	.p2align 4,,10
	.p2align 3
.L35:
	movslq	%edx, %r10
	movslq	%eax, %r11
	leaq	(%rdi,%r10,4), %rcx
	movl	(%rcx), %esi
	cmpl	(%rdi,%r11,4), %esi
	jle	.L23
	cmpl	%r9d, %r8d
	jle	.L28
.L24:
	cmpl	%edx, %eax
	je	.L25
	leaq	(%rdi,%rax,4), %rax
	movl	(%rax), %r8d
	movl	%esi, (%rax)
	movslq	%edx, %rax
	movl	%r8d, (%rcx)
.L26:
	leal	(%rax,%rax), %edx
	leal	1(%rdx), %r8d
	cmpl	%r9d, %edx
	jle	.L35
.L23:
	cmpl	%r9d, %r8d
	jg	.L25
	movl	%eax, %edx
	movslq	%eax, %r10
.L28:
	movslq	%r8d, %rcx
	leaq	(%rdi,%r10,4), %r10
	leaq	(%rdi,%rcx,4), %rcx
	movl	(%r10), %r11d
	movl	(%rcx), %esi
	cmpl	%r11d, %esi
	jg	.L29
	movl	%r11d, %esi
	movq	%r10, %rcx
	jmp	.L24
	.p2align 4,,10
	.p2align 3
.L29:
	movl	%r8d, %edx
	jmp	.L24
	.p2align 4,,10
	.p2align 3
.L25:
	subl	$1, %ebx
	je	.L21
	movl	8(%rbp), %r9d
	jmp	.L27
	.p2align 4,,10
	.p2align 3
.L21:
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE58:
	.size	buildMaxHeap, .-buildMaxHeap
	.p2align 4
	.globl	heapExtractMax
	.type	heapExtractMax, @function
heapExtractMax:
.LFB59:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movslq	8(%rdi), %rax
	testl	%eax, %eax
	jle	.L43
	movq	(%rdi), %rcx
	movl	(%rcx,%rax,4), %eax
	movl	4(%rcx), %r12d
	movl	%eax, 4(%rcx)
	movl	8(%rdi), %eax
	leal	-1(%rax), %r9d
	movl	$1, %eax
	movl	%r9d, 8(%rdi)
	jmp	.L41
	.p2align 4,,10
	.p2align 3
.L47:
	movslq	%edx, %r10
	movslq	%eax, %r11
	leaq	(%rcx,%r10,4), %rsi
	movl	(%rsi), %edi
	cmpl	(%rcx,%r11,4), %edi
	jle	.L38
	cmpl	%r8d, %r9d
	jge	.L42
.L39:
	cmpl	%edx, %eax
	je	.L36
	leaq	(%rcx,%rax,4), %rax
	movl	(%rax), %r8d
	movl	%edi, (%rax)
	movslq	%edx, %rax
	movl	%r8d, (%rsi)
.L41:
	leal	(%rax,%rax), %edx
	leal	1(%rdx), %r8d
	cmpl	%edx, %r9d
	jge	.L47
.L38:
	cmpl	%r8d, %r9d
	jl	.L36
	movl	%eax, %edx
	movslq	%eax, %r10
.L42:
	movslq	%r8d, %rsi
	leaq	(%rcx,%r10,4), %r10
	leaq	(%rcx,%rsi,4), %rsi
	movl	(%r10), %r11d
	movl	(%rsi), %edi
	cmpl	%r11d, %edi
	jg	.L44
	movl	%r11d, %edi
	movq	%r10, %rsi
	jmp	.L39
	.p2align 4,,10
	.p2align 3
.L44:
	movl	%r8d, %edx
	jmp	.L39
.L43:
	movl	$-1, %r12d
.L36:
	movl	%r12d, %eax
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE59:
	.size	heapExtractMax, .-heapExtractMax
	.p2align 4
	.globl	heapIncreaseKey
	.type	heapIncreaseKey, @function
heapIncreaseKey:
.LFB60:
	.cfi_startproc
	endbr64
	movq	(%rdi), %r8
	movslq	%esi, %rax
	movq	%rdi, %r9
	leaq	(%r8,%rax,4), %rax
	cmpl	%edx, (%rax)
	jg	.L48
	movl	%edx, (%rax)
	cmpl	$1, %esi
	jg	.L50
	jmp	.L51
	.p2align 4,,10
	.p2align 3
.L52:
	movl	%ecx, (%rax)
	movl	%edx, (%rdi)
	cmpl	$1, %esi
	je	.L51
.L50:
	movslq	%esi, %rax
	sarl	%esi
	movslq	%esi, %rcx
	leaq	(%r8,%rax,4), %rax
	leaq	(%r8,%rcx,4), %rdi
	movl	(%rdi), %ecx
	cmpl	%edx, %ecx
	jl	.L52
.L51:
	movl	8(%r9), %eax
	movl	%eax, 12(%r9)
	ret
	.p2align 4,,10
	.p2align 3
.L48:
	ret
	.cfi_endproc
.LFE60:
	.size	heapIncreaseKey, .-heapIncreaseKey
	.p2align 4
	.globl	maxHeapInsert
	.type	maxHeapInsert, @function
maxHeapInsert:
.LFB61:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rdi, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	movl	%esi, %ebx
	subq	$8, %rsp
	.cfi_def_cfa_offset 32
	movl	8(%rdi), %edx
	leal	1(%rdx), %eax
	movd	%edx, %xmm1
	movd	%eax, %xmm0
	punpckldq	%xmm1, %xmm0
	movq	%xmm0, 8(%rdi)
	movq	(%rdi), %rdi
	cmpl	16(%rbp), %eax
	jg	.L69
.L58:
	cltq
	movl	$-1, (%rdi,%rax,4)
	movslq	8(%rbp), %rdx
	movq	%rdx, %rax
	leaq	(%rdi,%rdx,4), %rdx
	cmpl	(%rdx), %ebx
	jl	.L57
	movl	%ebx, (%rdx)
	cmpl	$1, %eax
	jg	.L61
	jmp	.L62
	.p2align 4,,10
	.p2align 3
.L63:
	movl	%ecx, (%rdx)
	movl	%ebx, (%rsi)
	cmpl	$1, %eax
	je	.L62
.L61:
	movslq	%eax, %rdx
	sarl	%eax
	movslq	%eax, %rcx
	leaq	(%rdi,%rdx,4), %rdx
	leaq	(%rdi,%rcx,4), %rsi
	movl	(%rsi), %ecx
	cmpl	%ecx, %ebx
	jg	.L63
.L62:
	movl	8(%rbp), %eax
	movl	%eax, 12(%rbp)
.L57:
	addq	$8, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L69:
	.cfi_restore_state
	leal	2(%rdx), %esi
	movl	%eax, 16(%rbp)
	movslq	%esi, %rsi
	salq	$2, %rsi
	call	realloc@PLT
	movq	%rax, %rdi
	testq	%rax, %rax
	je	.L59
	movq	%rax, 0(%rbp)
	movl	8(%rbp), %eax
	jmp	.L58
.L59:
	movl	$1, %edi
	leaq	.LC0(%rip), %rsi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	0(%rbp), %rdi
	movl	8(%rbp), %eax
	jmp	.L58
	.cfi_endproc
.LFE61:
	.size	maxHeapInsert, .-maxHeapInsert
	.p2align 4
	.globl	heapSort
	.type	heapSort, @function
heapSort:
.LFB62:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	movl	12(%rdi), %r10d
	movl	%r10d, %ebp
	movl	%r10d, 8(%rdi)
	shrl	$31, %ebp
	addl	%r10d, %ebp
	sarl	%ebp
	cmpl	$1, %r10d
	jle	.L70
	movq	(%rdi), %rdx
	movq	%rdi, %r9
	.p2align 4,,10
	.p2align 3
.L78:
	movslq	%ebp, %rax
	jmp	.L75
	.p2align 4,,10
	.p2align 3
.L92:
	movslq	%ecx, %r11
	movslq	%eax, %rbx
	leaq	(%rdx,%r11,4), %rsi
	movl	(%rsi), %edi
	cmpl	(%rdx,%rbx,4), %edi
	jle	.L72
	cmpl	%r10d, %r8d
	jle	.L85
.L73:
	cmpl	%ecx, %eax
	je	.L74
	leaq	(%rdx,%rax,4), %rax
	movl	(%rax), %r8d
	movl	%edi, (%rax)
	movslq	%ecx, %rax
	movl	%r8d, (%rsi)
.L75:
	leal	(%rax,%rax), %ecx
	leal	1(%rcx), %r8d
	cmpl	%r10d, %ecx
	jle	.L92
.L72:
	cmpl	%r10d, %r8d
	jg	.L74
	movl	%eax, %ecx
	movslq	%eax, %r11
.L85:
	movslq	%r8d, %rsi
	leaq	(%rdx,%r11,4), %r11
	leaq	(%rdx,%rsi,4), %rsi
	movl	(%r11), %ebx
	movl	(%rsi), %edi
	cmpl	%ebx, %edi
	jg	.L86
	movl	%ebx, %edi
	movq	%r11, %rsi
	jmp	.L73
	.p2align 4,,10
	.p2align 3
.L86:
	movl	%r8d, %ecx
	jmp	.L73
	.p2align 4,,10
	.p2align 3
.L74:
	subl	$1, %ebp
	je	.L93
	movl	8(%r9), %r10d
	jmp	.L78
	.p2align 4,,10
	.p2align 3
.L81:
	subq	$1, %rbp
	cmpl	$1, %ebp
	jg	.L83
.L70:
	popq	%rbx
	.cfi_remember_state
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L93:
	.cfi_restore_state
	movslq	12(%r9), %rbp
	cmpl	$1, %ebp
	jle	.L70
	.p2align 4,,10
	.p2align 3
.L83:
	movl	4(%rdx), %eax
	movl	(%rdx,%rbp,4), %ecx
	movl	%ecx, 4(%rdx)
	movl	%eax, (%rdx,%rbp,4)
	movl	8(%r9), %eax
	leal	-1(%rax), %r10d
	movl	$1, %eax
	movl	%r10d, 8(%r9)
	jmp	.L82
	.p2align 4,,10
	.p2align 3
.L94:
	movslq	%ecx, %r11
	movslq	%eax, %rbx
	leaq	(%rdx,%r11,4), %rsi
	movl	(%rsi), %edi
	cmpl	(%rdx,%rbx,4), %edi
	jle	.L79
	cmpl	%r8d, %r10d
	jge	.L84
.L80:
	cmpl	%ecx, %eax
	je	.L81
	leaq	(%rdx,%rax,4), %rax
	movl	(%rax), %r8d
	movl	%edi, (%rax)
	movslq	%ecx, %rax
	movl	%r8d, (%rsi)
.L82:
	leal	(%rax,%rax), %ecx
	leal	1(%rcx), %r8d
	cmpl	%ecx, %r10d
	jge	.L94
.L79:
	cmpl	%r8d, %r10d
	jl	.L81
	movl	%eax, %ecx
	movslq	%eax, %r11
.L84:
	movslq	%r8d, %rsi
	leaq	(%rdx,%r11,4), %r11
	leaq	(%rdx,%rsi,4), %rsi
	movl	(%r11), %ebx
	movl	(%rsi), %edi
	cmpl	%ebx, %edi
	jg	.L87
	movl	%ebx, %edi
	movq	%r11, %rsi
	jmp	.L80
	.p2align 4,,10
	.p2align 3
.L87:
	movl	%r8d, %ecx
	jmp	.L80
	.cfi_endproc
.LFE62:
	.size	heapSort, .-heapSort
	.section	.rodata.str1.1
.LC1:
	.string	"%s"
.LC2:
	.string	"insert"
.LC3:
	.string	"%d"
.LC4:
	.string	"extract"
.LC5:
	.string	"%d\n"
.LC6:
	.string	"end"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB63:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movl	$4, %edi
	xorl	%r15d, %r15d
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	leaq	.LC5(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movabsq	$32760367481649253, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	leaq	.LC1(%rip), %rbx
	subq	$56, %rsp
	.cfi_def_cfa_offset 112
	movq	%fs:40, %rax
	movq	%rax, 40(%rsp)
	xorl	%eax, %eax
	leaq	30(%rsp), %r13
	call	malloc@PLT
	movl	$0, 8(%rsp)
	movl	$0, (%rax)
	movq	%rax, %r14
	.p2align 4,,10
	.p2align 3
.L96:
	xorl	%eax, %eax
	movq	%r13, %rsi
	movq	%rbx, %rdi
	call	__isoc99_scanf@PLT
	cmpl	$1702063721, 0(%r13)
	je	.L132
.L97:
	cmpq	%rbp, 0(%r13)
	je	.L133
	cmpl	$6581861, 0(%r13)
	jne	.L96
	movq	40(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L134
	addq	$56, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L132:
	.cfi_restore_state
	cmpw	$29810, 4(%r13)
	jne	.L97
	cmpb	$0, 6(%r13)
	jne	.L97
	leaq	24(%rsp), %rsi
	leaq	.LC3(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	24(%rsp), %r8d
	leal	1(%r15), %r9d
	cmpl	%r9d, 8(%rsp)
	jl	.L135
.L100:
	movslq	%r9d, %rax
	leaq	(%r14,%rax,4), %rax
	cmpl	$-1, %r8d
	jl	.L101
	movl	%r8d, (%rax)
	movl	$1, %r15d
	movl	%r9d, %eax
	cmpl	$1, %r9d
	jne	.L102
	jmp	.L96
	.p2align 4,,10
	.p2align 3
.L104:
	movl	%ecx, (%rdx)
	movl	%r8d, (%rsi)
	cmpl	$1, %eax
	je	.L119
.L102:
	movslq	%eax, %rdx
	sarl	%eax
	movslq	%eax, %rcx
	leaq	(%r14,%rdx,4), %rdx
	leaq	(%r14,%rcx,4), %rsi
	movl	(%rsi), %ecx
	cmpl	%ecx, %r8d
	jg	.L104
.L119:
	movl	%r9d, %r15d
	jmp	.L96
	.p2align 4,,10
	.p2align 3
.L133:
	testl	%r15d, %r15d
	je	.L136
	movslq	%r15d, %rax
	movl	4(%r14), %r8d
	subl	$1, %r15d
	movl	(%r14,%rax,4), %eax
	movl	%eax, 4(%r14)
	movl	$1, %eax
	jmp	.L112
	.p2align 4,,10
	.p2align 3
.L137:
	movslq	%ecx, %rdx
	movslq	%eax, %r10
	leaq	(%r14,%rdx,4), %rsi
	movl	(%rsi), %edi
	cmpl	(%r14,%r10,4), %edi
	jle	.L109
	cmpl	%r9d, %r15d
	jge	.L115
.L110:
	cmpl	%ecx, %eax
	je	.L108
	leaq	(%r14,%rax,4), %rax
	movl	(%rax), %edx
	movl	%edi, (%rax)
	movslq	%ecx, %rax
	movl	%edx, (%rsi)
.L112:
	leal	(%rax,%rax), %ecx
	leal	1(%rcx), %r9d
	cmpl	%ecx, %r15d
	jge	.L137
.L109:
	cmpl	%r9d, %r15d
	jl	.L108
	movl	%eax, %ecx
	movslq	%eax, %rdx
.L115:
	movslq	%r9d, %rsi
	leaq	(%r14,%rdx,4), %rdx
	leaq	(%r14,%rsi,4), %rsi
	movl	(%rdx), %r10d
	movl	(%rsi), %edi
	cmpl	%r10d, %edi
	jg	.L121
	movl	%r10d, %edi
	movq	%rdx, %rsi
	jmp	.L110
	.p2align 4,,10
	.p2align 3
.L121:
	movl	%r9d, %ecx
	jmp	.L110
.L136:
	orl	$-1, %r8d
	.p2align 4,,10
	.p2align 3
.L108:
	movl	%r8d, %edx
	movq	%r12, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L96
	.p2align 4,,10
	.p2align 3
.L101:
	movl	$-1, (%rax)
	movl	%r9d, %r15d
	jmp	.L96
.L135:
	leal	2(%r15), %esi
	movq	%r14, %rdi
	movl	%r9d, 12(%rsp)
	movslq	%esi, %rsi
	movl	%r8d, 8(%rsp)
	salq	$2, %rsi
	call	realloc@PLT
	movl	12(%rsp), %r9d
	movl	8(%rsp), %r8d
	testq	%rax, %rax
	movl	%r9d, 8(%rsp)
	je	.L138
	movq	%rax, %r14
	jmp	.L100
.L138:
	leaq	.LC0(%rip), %rsi
	movl	$1, %edi
	movl	%r8d, 12(%rsp)
	call	__printf_chk@PLT
	movl	8(%rsp), %r9d
	movl	12(%rsp), %r8d
	jmp	.L100
.L134:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE63:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:


#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX_CMD_LENGTH 10
#define MAX_HEAP_LENGTH 100
#define POS_INF_KEY 2000000000
#define NEG_INF_KEY -1

void swap(int array[], int i, int j) {
    int temp = array[i];
    array[i] = array[j];
    array[j] = temp;
}

typedef struct {
    int * array;
    int heap_size;
    int length;
    int array_size;
} Heap;

//Heap createHeap(int length) {
//    Heap heap;
//    
//    heap.array = (int *)malloc((length+1) * sizeof(int));
//    heap.array[0] = 0; // NOT USED
//    heap.heap_size = heap.length = length;
//    
//    return heap;
//}

Heap createHeap() {
    Heap heap;
    
    // one slot of memory is allocated for the unused 0-slot
    heap.array = (int *)malloc(1 * sizeof(int));
    heap.array[0] = 0; // NOT USED
    
    // hence memory allocated = (1+length) * sizeof int
    heap.array_size = heap.heap_size = heap.length = 0;
    
    return heap;
}
Heap lengthenHeap(Heap *p_heap) { // lengthen to heap_size
    p_heap->array_size = p_heap->heap_size;

    int * reacllocated_heap_array = (int *)realloc(p_heap->array, (p_heap->array_size+1) * sizeof(int));
    
    if (reacllocated_heap_array)
        p_heap->array = reacllocated_heap_array;
    else
        printf("Unable to reacllocate");
}

int parentOfIndex(int index) {
    return index/2;
}
int leftOfIndex(int index) {
    return 2*index;
}
int rightOfIndex(int index) {
    return 2*index+1;
}

void maxHeapify(Heap heap, int iThis) {
    int iLeft = leftOfIndex(iThis);
    int iRight = rightOfIndex(iThis);
    int iLargest;
    
    if (iLeft <= heap.heap_size && heap.array[iLeft] > heap.array[iThis]) 
        iLargest = iLeft;
    else
        iLargest = iThis;
    
    if (iRight <= heap.heap_size && heap.array[iRight] > heap.array[iLargest]) 
        iLargest = iRight;
    
    if (iLargest != iThis) {
        swap(heap.array, iThis, iLargest);
        // iLargest is no longer the index for largest value within the trinode.
        maxHeapify(heap, iLargest);
    }
}
void buildMaxHeap(Heap *p_heap) {
    p_heap->heap_size = p_heap->length;
    
    for (int i = p_heap->length/2; i >= 1; i--)
        maxHeapify(*p_heap, i);
}

int heapExtractMax(Heap *p_heap) {
    if (p_heap->heap_size < 1) return NEG_INF_KEY; // error
    
    int max = p_heap->array[1];
    p_heap->array[1] = p_heap->array[p_heap->heap_size];
    p_heap->heap_size--;
    maxHeapify(*p_heap,1);
    return max;
}


void heapIncreaseKey(Heap *p_heap, int nodeIndex, int keyToBeIncreasedTo) {
    if (keyToBeIncreasedTo < p_heap->array[nodeIndex]) return; //error
    
    p_heap->array[nodeIndex] = keyToBeIncreasedTo;
    
    while (nodeIndex > 1 && p_heap->array[parentOfIndex(nodeIndex)] < p_heap->array[nodeIndex]) {
        swap(p_heap->array, nodeIndex, parentOfIndex(nodeIndex));
        nodeIndex = parentOfIndex(nodeIndex);
    }
    
    p_heap->length = p_heap->heap_size;
}
void maxHeapInsert(Heap *p_heap, int keyToBeAdded) {
    p_heap->length = p_heap->heap_size++;
    
    if (p_heap->array_size < p_heap->heap_size)
        lengthenHeap(p_heap);
    
    p_heap->array[p_heap->heap_size] = NEG_INF_KEY;
    heapIncreaseKey(p_heap, p_heap->heap_size, keyToBeAdded);
}



// sorting
void heapSort(Heap *p_heap) {
    buildMaxHeap(p_heap);
    
    for (int i = p_heap->length; i >= 2; i--) {
        swap(p_heap->array, 1, i);
        p_heap->heap_size--;
        maxHeapify(*p_heap, 1);
    }
}


int main(int argc, char** argv) {
    char command[MAX_CMD_LENGTH];
    
    Heap heap = createHeap();
    int nodeKey;
    // 1-origin
    
    while (1) {
        scanf("%s", command);
        
        if (strcmp(command, "insert") == 0) {
            scanf("%d", &(nodeKey));
            maxHeapInsert(&heap, nodeKey);
        }
        else if (strcmp(command, "extract") == 0)
            printf("%d\n", heapExtractMax(&heap));
        else if (strcmp(command, "end") == 0)
            return EXIT_SUCCESS;
    }
    
//    for (int i = 1; i <= nCommands; i++)
//        scanf("%d", &(heap.array[i]));
//    
//    //--- Lect 9 Prob B
//    buildMaxHeap(heap);
//    
//    for (int i = 1; i <= heap.length; i++) 
//        printf(" %d", heap.array[i]);
//    
//    printf("\n");
//    
//    //--- Lect 9 Prob A
//    for (int i = 1; i <= nNode; i++) {
//        printf("node %d: ", i);
//        printf("key = %d, ", heap.array[i]);
//        
//        if (i/2 > 0)
//            printf("parent key = %d, ", heap.array[i/2]);
//        
//        if (2*i <= heap.length)
//            printf("left key = %d, ", heap.array[2*i]);
//        
//        if (2*i+1 <= heap.length)
//            printf("right key = %d, ", heap.array[2*i+1]);
//        
//        printf("\n");
//    }

    return (EXIT_SUCCESS);
}



insert 8
insert 1
extract
insert 10
extract
insert 11
extract
extract
end
 insert 9
insert 2
extract
insert 10
extract
insert 11
extract
extract
end
 insert 8
insert 2
extract
insert 16
extract
insert 11
extract
extract
end
 insert 8
insert 1
extract
insert 15
extract
insert 11
extract
extract
end
 insert 8
insert 0
extract
insert 10
extract
insert 11
extract
extract
end
 insert 8
insert 2
extract
insert 8
extract
insert 11
extract
extract
end
 insert 8
insert 2
extract
insert 4
extract
insert 11
extract
extract
end
 insert 8
insert 2
extract
insert 10
extract
insert 14
extract
extract
end
 insert 9
insert 2
extract
insert 4
extract
insert 11
extract
extract
end
 insert 8
insert 0
extract
insert 4
extract
insert 11
extract
extract
end

8
10
11
1
 9
10
11
2
 8
16
11
2
 8
15
11
1
 8
10
11
0
 8
8
11
2
 8
4
11
2
 8
10
14
2
 9
4
11
2
 8
4
11
0

Given the following C code and unoptimized assembly code, your task is to generate highly optimized x86-64 assembly code.
C Code:

```c

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX_CMD_LENGTH 10
#define MAX_HEAP_LENGTH 100
#define POS_INF_KEY 2000000000
#define NEG_INF_KEY -1

void swap(int array[], int i, int j) {
    int temp = array[i];
    array[i] = array[j];
    array[j] = temp;
}

typedef struct {
    int * array;
    int heap_size;
    int length;
    int array_size;
} Heap;

//Heap createHeap(int length) {
//    Heap heap;
//    
//    heap.array = (int *)malloc((length+1) * sizeof(int));
//    heap.array[0] = 0; // NOT USED
//    heap.heap_size = heap.length = length;
//    
//    return heap;
//}

Heap createHeap() {
    Heap heap;
    
    // one slot of memory is allocated for the unused 0-slot
    heap.array = (int *)malloc(1 * sizeof(int));
    heap.array[0] = 0; // NOT USED
    
    // hence memory allocated = (1+length) * sizeof int
    heap.array_size = heap.heap_size = heap.length = 0;
    
    return heap;
}
Heap lengthenHeap(Heap *p_heap) { // lengthen to heap_size
    p_heap->array_size = p_heap->heap_size;

    int * reacllocated_heap_array = (int *)realloc(p_heap->array, (p_heap->array_size+1) * sizeof(int));
    
    if (reacllocated_heap_array)
        p_heap->array = reacllocated_heap_array;
    else
        printf("Unable to reacllocate");
}

int parentOfIndex(int index) {
    return index/2;
}
int leftOfIndex(int index) {
    return 2*index;
}
int rightOfIndex(int index) {
    return 2*index+1;
}

void maxHeapify(Heap heap, int iThis) {
    int iLeft = leftOfIndex(iThis);
    int iRight = rightOfIndex(iThis);
    int iLargest;
    
    if (iLeft <= heap.heap_size && heap.array[iLeft] > heap.array[iThis]) 
        iLargest = iLeft;
    else
        iLargest = iThis;
    
    if (iRight <= heap.heap_size && heap.array[iRight] > heap.array[iLargest]) 
        iLargest = iRight;
    
    if (iLargest != iThis) {
        swap(heap.array, iThis, iLargest);
        // iLargest is no longer the index for largest value within the trinode.
        maxHeapify(heap, iLargest);
    }
}
void buildMaxHeap(Heap *p_heap) {
    p_heap->heap_size = p_heap->length;
    
    for (int i = p_heap->length/2; i >= 1; i--)
        maxHeapify(*p_heap, i);
}

int heapExtractMax(Heap *p_heap) {
    if (p_heap->heap_size < 1) return NEG_INF_KEY; // error
    
    int max = p_heap->array[1];
    p_heap->array[1] = p_heap->array[p_heap->heap_size];
    p_heap->heap_size--;
    maxHeapify(*p_heap,1);
    return max;
}


void heapIncreaseKey(Heap *p_heap, int nodeIndex, int keyToBeIncreasedTo) {
    if (keyToBeIncreasedTo < p_heap->array[nodeIndex]) return; //error
    
    p_heap->array[nodeIndex] = keyToBeIncreasedTo;
    
    while (nodeIndex > 1 && p_heap->array[parentOfIndex(nodeIndex)] < p_heap->array[nodeIndex]) {
        swap(p_heap->array, nodeIndex, parentOfIndex(nodeIndex));
        nodeIndex = parentOfIndex(nodeIndex);
    }
    
    p_heap->length = p_heap->heap_size;
}
void maxHeapInsert(Heap *p_heap, int keyToBeAdded) {
    p_heap->length = p_heap->heap_size++;
    
    if (p_heap->array_size < p_heap->heap_size)
        lengthenHeap(p_heap);
    
    p_heap->array[p_heap->heap_size] = NEG_INF_KEY;
    heapIncreaseKey(p_heap, p_heap->heap_size, keyToBeAdded);
}



// sorting
void heapSort(Heap *p_heap) {
    buildMaxHeap(p_heap);
    
    for (int i = p_heap->length; i >= 2; i--) {
        swap(p_heap->array, 1, i);
        p_heap->heap_size--;
        maxHeapify(*p_heap, 1);
    }
}


int main(int argc, char** argv) {
    char command[MAX_CMD_LENGTH];
    
    Heap heap = createHeap();
    int nodeKey;
    // 1-origin
    
    while (1) {
        scanf("%s", command);
        
        if (strcmp(command, "insert") == 0) {
            scanf("%d", &(nodeKey));
            maxHeapInsert(&heap, nodeKey);
        }
        else if (strcmp(command, "extract") == 0)
            printf("%d\n", heapExtractMax(&heap));
        else if (strcmp(command, "end") == 0)
            return EXIT_SUCCESS;
    }
    
//    for (int i = 1; i <= nCommands; i++)
//        scanf("%d", &(heap.array[i]));
//    
//    //--- Lect 9 Prob B
//    buildMaxHeap(heap);
//    
//    for (int i = 1; i <= heap.length; i++) 
//        printf(" %d", heap.array[i]);
//    
//    printf("\n");
//    
//    //--- Lect 9 Prob A
//    for (int i = 1; i <= nNode; i++) {
//        printf("node %d: ", i);
//        printf("key = %d, ", heap.array[i]);
//        
//        if (i/2 > 0)
//            printf("parent key = %d, ", heap.array[i/2]);
//        
//        if (2*i <= heap.length)
//            printf("left key = %d, ", heap.array[2*i]);
//        
//        if (2*i+1 <= heap.length)
//            printf("right key = %d, ", heap.array[2*i+1]);
//        
//        printf("\n");
//    }

    return (EXIT_SUCCESS);
}


```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	swap
	.type	swap, @function
swap:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -24(%rbp)
	movl	%esi, -28(%rbp)
	movl	%edx, -32(%rbp)
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, -4(%rbp)
	movl	-32(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	-28(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	movq	-24(%rbp), %rdx
	addq	%rcx, %rdx
	movl	(%rax), %eax
	movl	%eax, (%rdx)
	movl	-32(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rax, %rdx
	movl	-4(%rbp), %eax
	movl	%eax, (%rdx)
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	swap, .-swap
	.globl	createHeap
	.type	createHeap, @function
createHeap:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$48, %rsp
	movq	%rdi, -40(%rbp)
	movl	$4, %edi
	call	malloc@PLT
	movq	%rax, -32(%rbp)
	movq	-32(%rbp), %rax
	movl	$0, (%rax)
	movl	$0, -20(%rbp)
	movl	-20(%rbp), %eax
	movl	%eax, -24(%rbp)
	movl	-24(%rbp), %eax
	movl	%eax, -16(%rbp)
	movq	-40(%rbp), %rcx
	movq	-32(%rbp), %rax
	movq	-24(%rbp), %rdx
	movq	%rax, (%rcx)
	movq	%rdx, 8(%rcx)
	movq	-16(%rbp), %rax
	movq	%rax, 16(%rcx)
	movq	-40(%rbp), %rax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	createHeap, .-createHeap
	.section	.rodata
.LC0:
	.string	"Unable to reacllocate"
	.text
	.globl	lengthenHeap
	.type	lengthenHeap, @function
lengthenHeap:
.LFB8:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movq	%rdi, -24(%rbp)
	movq	%rsi, -32(%rbp)
	movq	-32(%rbp), %rax
	movl	8(%rax), %edx
	movq	-32(%rbp), %rax
	movl	%edx, 16(%rax)
	movq	-32(%rbp), %rax
	movl	16(%rax), %eax
	addl	$1, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-32(%rbp), %rax
	movq	(%rax), %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	realloc@PLT
	movq	%rax, -8(%rbp)
	cmpq	$0, -8(%rbp)
	je	.L5
	movq	-32(%rbp), %rax
	movq	-8(%rbp), %rdx
	movq	%rdx, (%rax)
	jmp	.L6
.L5:
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L6:
	nop
	movq	-24(%rbp), %rax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.size	lengthenHeap, .-lengthenHeap
	.globl	parentOfIndex
	.type	parentOfIndex, @function
parentOfIndex:
.LFB9:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -4(%rbp)
	movl	-4(%rbp), %eax
	movl	%eax, %edx
	shrl	$31, %edx
	addl	%edx, %eax
	sarl	%eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE9:
	.size	parentOfIndex, .-parentOfIndex
	.globl	leftOfIndex
	.type	leftOfIndex, @function
leftOfIndex:
.LFB10:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -4(%rbp)
	movl	-4(%rbp), %eax
	addl	%eax, %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE10:
	.size	leftOfIndex, .-leftOfIndex
	.globl	rightOfIndex
	.type	rightOfIndex, @function
rightOfIndex:
.LFB11:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -4(%rbp)
	movl	-4(%rbp), %eax
	addl	%eax, %eax
	addl	$1, %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE11:
	.size	rightOfIndex, .-rightOfIndex
	.globl	maxHeapify
	.type	maxHeapify, @function
maxHeapify:
.LFB12:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movl	%edi, -20(%rbp)
	movl	-20(%rbp), %eax
	movl	%eax, %edi
	call	leftOfIndex
	movl	%eax, -8(%rbp)
	movl	-20(%rbp), %eax
	movl	%eax, %edi
	call	rightOfIndex
	movl	%eax, -4(%rbp)
	movl	24(%rbp), %eax
	cmpl	%eax, -8(%rbp)
	jg	.L14
	movq	16(%rbp), %rdx
	movl	-8(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movq	16(%rbp), %rcx
	movl	-20(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rcx, %rax
	movl	(%rax), %eax
	cmpl	%eax, %edx
	jle	.L14
	movl	-8(%rbp), %eax
	movl	%eax, -12(%rbp)
	jmp	.L15
.L14:
	movl	-20(%rbp), %eax
	movl	%eax, -12(%rbp)
.L15:
	movl	24(%rbp), %eax
	cmpl	%eax, -4(%rbp)
	jg	.L16
	movq	16(%rbp), %rdx
	movl	-4(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movq	16(%rbp), %rcx
	movl	-12(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rcx, %rax
	movl	(%rax), %eax
	cmpl	%eax, %edx
	jle	.L16
	movl	-4(%rbp), %eax
	movl	%eax, -12(%rbp)
.L16:
	movl	-12(%rbp), %eax
	cmpl	-20(%rbp), %eax
	je	.L18
	movq	16(%rbp), %rax
	movl	-12(%rbp), %edx
	movl	-20(%rbp), %ecx
	movl	%ecx, %esi
	movq	%rax, %rdi
	call	swap
	movl	-12(%rbp), %eax
	subq	$8, %rsp
	pushq	32(%rbp)
	pushq	24(%rbp)
	pushq	16(%rbp)
	movl	%eax, %edi
	call	maxHeapify
	addq	$32, %rsp
.L18:
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE12:
	.size	maxHeapify, .-maxHeapify
	.globl	buildMaxHeap
	.type	buildMaxHeap, @function
buildMaxHeap:
.LFB13:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movq	%rdi, -24(%rbp)
	movq	-24(%rbp), %rax
	movl	12(%rax), %edx
	movq	-24(%rbp), %rax
	movl	%edx, 8(%rax)
	movq	-24(%rbp), %rax
	movl	12(%rax), %eax
	movl	%eax, %edx
	shrl	$31, %edx
	addl	%edx, %eax
	sarl	%eax
	movl	%eax, -4(%rbp)
	jmp	.L20
.L21:
	movl	-4(%rbp), %edx
	subq	$8, %rsp
	movq	-24(%rbp), %rax
	pushq	16(%rax)
	pushq	8(%rax)
	pushq	(%rax)
	movl	%edx, %edi
	call	maxHeapify
	addq	$32, %rsp
	subl	$1, -4(%rbp)
.L20:
	cmpl	$0, -4(%rbp)
	jg	.L21
	nop
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE13:
	.size	buildMaxHeap, .-buildMaxHeap
	.globl	heapExtractMax
	.type	heapExtractMax, @function
heapExtractMax:
.LFB14:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movq	%rdi, -24(%rbp)
	movq	-24(%rbp), %rax
	movl	8(%rax), %eax
	testl	%eax, %eax
	jg	.L23
	movl	$-1, %eax
	jmp	.L24
.L23:
	movq	-24(%rbp), %rax
	movq	(%rax), %rax
	movl	4(%rax), %eax
	movl	%eax, -4(%rbp)
	movq	-24(%rbp), %rax
	movq	(%rax), %rdx
	movq	-24(%rbp), %rax
	movl	8(%rax), %eax
	cltq
	salq	$2, %rax
	leaq	(%rdx,%rax), %rcx
	movq	-24(%rbp), %rax
	movq	(%rax), %rax
	leaq	4(%rax), %rdx
	movl	(%rcx), %eax
	movl	%eax, (%rdx)
	movq	-24(%rbp), %rax
	movl	8(%rax), %eax
	leal	-1(%rax), %edx
	movq	-24(%rbp), %rax
	movl	%edx, 8(%rax)
	subq	$8, %rsp
	movq	-24(%rbp), %rax
	pushq	16(%rax)
	pushq	8(%rax)
	pushq	(%rax)
	movl	$1, %edi
	call	maxHeapify
	addq	$32, %rsp
	movl	-4(%rbp), %eax
.L24:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE14:
	.size	heapExtractMax, .-heapExtractMax
	.globl	heapIncreaseKey
	.type	heapIncreaseKey, @function
heapIncreaseKey:
.LFB15:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%rbx
	subq	$16, %rsp
	.cfi_offset 3, -24
	movq	%rdi, -16(%rbp)
	movl	%esi, -20(%rbp)
	movl	%edx, -24(%rbp)
	movq	-16(%rbp), %rax
	movq	(%rax), %rdx
	movl	-20(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cmpl	%eax, -24(%rbp)
	jl	.L31
	movq	-16(%rbp), %rax
	movq	(%rax), %rdx
	movl	-20(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rax, %rdx
	movl	-24(%rbp), %eax
	movl	%eax, (%rdx)
	jmp	.L28
.L30:
	movl	-20(%rbp), %eax
	movl	%eax, %edi
	call	parentOfIndex
	movl	%eax, %edx
	movq	-16(%rbp), %rax
	movq	(%rax), %rax
	movl	-20(%rbp), %ecx
	movl	%ecx, %esi
	movq	%rax, %rdi
	call	swap
	movl	-20(%rbp), %eax
	movl	%eax, %edi
	call	parentOfIndex
	movl	%eax, -20(%rbp)
.L28:
	cmpl	$1, -20(%rbp)
	jle	.L29
	movq	-16(%rbp), %rax
	movq	(%rax), %rbx
	movl	-20(%rbp), %eax
	movl	%eax, %edi
	call	parentOfIndex
	cltq
	salq	$2, %rax
	addq	%rbx, %rax
	movl	(%rax), %edx
	movq	-16(%rbp), %rax
	movq	(%rax), %rcx
	movl	-20(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rcx, %rax
	movl	(%rax), %eax
	cmpl	%eax, %edx
	jl	.L30
.L29:
	movq	-16(%rbp), %rax
	movl	8(%rax), %edx
	movq	-16(%rbp), %rax
	movl	%edx, 12(%rax)
	jmp	.L25
.L31:
	nop
.L25:
	movq	-8(%rbp), %rbx
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE15:
	.size	heapIncreaseKey, .-heapIncreaseKey
	.globl	maxHeapInsert
	.type	maxHeapInsert, @function
maxHeapInsert:
.LFB16:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$64, %rsp
	movq	%rdi, -24(%rbp)
	movl	%esi, -28(%rbp)
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movq	-24(%rbp), %rax
	movl	8(%rax), %eax
	leal	1(%rax), %ecx
	movq	-24(%rbp), %rdx
	movl	%ecx, 8(%rdx)
	movq	-24(%rbp), %rdx
	movl	%eax, 12(%rdx)
	movq	-24(%rbp), %rax
	movl	16(%rax), %edx
	movq	-24(%rbp), %rax
	movl	8(%rax), %eax
	cmpl	%eax, %edx
	jge	.L33
	leaq	-64(%rbp), %rax
	movq	-24(%rbp), %rdx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	lengthenHeap
.L33:
	movq	-24(%rbp), %rax
	movq	(%rax), %rdx
	movq	-24(%rbp), %rax
	movl	8(%rax), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movl	$-1, (%rax)
	movq	-24(%rbp), %rax
	movl	8(%rax), %ecx
	movl	-28(%rbp), %edx
	movq	-24(%rbp), %rax
	movl	%ecx, %esi
	movq	%rax, %rdi
	call	heapIncreaseKey
	nop
	movq	-8(%rbp), %rax
	subq	%fs:40, %rax
	je	.L34
	call	__stack_chk_fail@PLT
.L34:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE16:
	.size	maxHeapInsert, .-maxHeapInsert
	.globl	heapSort
	.type	heapSort, @function
heapSort:
.LFB17:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movq	%rdi, -24(%rbp)
	movq	-24(%rbp), %rax
	movq	%rax, %rdi
	call	buildMaxHeap
	movq	-24(%rbp), %rax
	movl	12(%rax), %eax
	movl	%eax, -4(%rbp)
	jmp	.L36
.L37:
	movq	-24(%rbp), %rax
	movq	(%rax), %rax
	movl	-4(%rbp), %edx
	movl	$1, %esi
	movq	%rax, %rdi
	call	swap
	movq	-24(%rbp), %rax
	movl	8(%rax), %eax
	leal	-1(%rax), %edx
	movq	-24(%rbp), %rax
	movl	%edx, 8(%rax)
	subq	$8, %rsp
	movq	-24(%rbp), %rax
	pushq	16(%rax)
	pushq	8(%rax)
	pushq	(%rax)
	movl	$1, %edi
	call	maxHeapify
	addq	$32, %rsp
	subl	$1, -4(%rbp)
.L36:
	cmpl	$1, -4(%rbp)
	jg	.L37
	nop
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE17:
	.size	heapSort, .-heapSort
	.section	.rodata
.LC1:
	.string	"%s"
.LC2:
	.string	"insert"
.LC3:
	.string	"%d"
.LC4:
	.string	"extract"
.LC5:
	.string	"%d\n"
.LC6:
	.string	"end"
	.text
	.globl	main
	.type	main, @function
main:
.LFB18:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$80, %rsp
	movl	%edi, -68(%rbp)
	movq	%rsi, -80(%rbp)
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-48(%rbp), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	createHeap
.L43:
	leaq	-18(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	leaq	-18(%rbp), %rax
	leaq	.LC2(%rip), %rdx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L39
	leaq	-52(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-52(%rbp), %edx
	leaq	-48(%rbp), %rax
	movl	%edx, %esi
	movq	%rax, %rdi
	call	maxHeapInsert
	jmp	.L43
.L39:
	leaq	-18(%rbp), %rax
	leaq	.LC4(%rip), %rdx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L41
	leaq	-48(%rbp), %rax
	movq	%rax, %rdi
	call	heapExtractMax
	movl	%eax, %esi
	leaq	.LC5(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L43
.L41:
	leaq	-18(%rbp), %rax
	leaq	.LC6(%rip), %rdx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L43
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L44
	call	__stack_chk_fail@PLT
.L44:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE18:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:
```

Only output the optimized assembly code. Do not include any other text. Do not write any comments in the assembly code. Wrap the assembly code in ```assembly``` tags.
train
	.file	"temp.c"
	.text
	.globl	swap
	.type	swap, @function
swap:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -24(%rbp)
	movl	%esi, -28(%rbp)
	movl	%edx, -32(%rbp)
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, -4(%rbp)
	movl	-32(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	-28(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	movq	-24(%rbp), %rdx
	addq	%rcx, %rdx
	movl	(%rax), %eax
	movl	%eax, (%rdx)
	movl	-32(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rax, %rdx
	movl	-4(%rbp), %eax
	movl	%eax, (%rdx)
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	swap, .-swap
	.globl	createHeap
	.type	createHeap, @function
createHeap:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$48, %rsp
	movq	%rdi, -40(%rbp)
	movl	$4, %edi
	call	malloc@PLT
	movq	%rax, -32(%rbp)
	movq	-32(%rbp), %rax
	movl	$0, (%rax)
	movl	$0, -20(%rbp)
	movl	-20(%rbp), %eax
	movl	%eax, -24(%rbp)
	movl	-24(%rbp), %eax
	movl	%eax, -16(%rbp)
	movq	-40(%rbp), %rcx
	movq	-32(%rbp), %rax
	movq	-24(%rbp), %rdx
	movq	%rax, (%rcx)
	movq	%rdx, 8(%rcx)
	movq	-16(%rbp), %rax
	movq	%rax, 16(%rcx)
	movq	-40(%rbp), %rax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	createHeap, .-createHeap
	.section	.rodata
.LC0:
	.string	"Unable to reacllocate"
	.text
	.globl	lengthenHeap
	.type	lengthenHeap, @function
lengthenHeap:
.LFB8:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movq	%rdi, -24(%rbp)
	movq	%rsi, -32(%rbp)
	movq	-32(%rbp), %rax
	movl	8(%rax), %edx
	movq	-32(%rbp), %rax
	movl	%edx, 16(%rax)
	movq	-32(%rbp), %rax
	movl	16(%rax), %eax
	addl	$1, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-32(%rbp), %rax
	movq	(%rax), %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	realloc@PLT
	movq	%rax, -8(%rbp)
	cmpq	$0, -8(%rbp)
	je	.L5
	movq	-32(%rbp), %rax
	movq	-8(%rbp), %rdx
	movq	%rdx, (%rax)
	jmp	.L6
.L5:
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L6:
	nop
	movq	-24(%rbp), %rax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.size	lengthenHeap, .-lengthenHeap
	.globl	parentOfIndex
	.type	parentOfIndex, @function
parentOfIndex:
.LFB9:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -4(%rbp)
	movl	-4(%rbp), %eax
	movl	%eax, %edx
	shrl	$31, %edx
	addl	%edx, %eax
	sarl	%eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE9:
	.size	parentOfIndex, .-parentOfIndex
	.globl	leftOfIndex
	.type	leftOfIndex, @function
leftOfIndex:
.LFB10:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -4(%rbp)
	movl	-4(%rbp), %eax
	addl	%eax, %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE10:
	.size	leftOfIndex, .-leftOfIndex
	.globl	rightOfIndex
	.type	rightOfIndex, @function
rightOfIndex:
.LFB11:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -4(%rbp)
	movl	-4(%rbp), %eax
	addl	%eax, %eax
	addl	$1, %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE11:
	.size	rightOfIndex, .-rightOfIndex
	.globl	maxHeapify
	.type	maxHeapify, @function
maxHeapify:
.LFB12:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movl	%edi, -20(%rbp)
	movl	-20(%rbp), %eax
	movl	%eax, %edi
	call	leftOfIndex
	movl	%eax, -8(%rbp)
	movl	-20(%rbp), %eax
	movl	%eax, %edi
	call	rightOfIndex
	movl	%eax, -4(%rbp)
	movl	24(%rbp), %eax
	cmpl	%eax, -8(%rbp)
	jg	.L14
	movq	16(%rbp), %rdx
	movl	-8(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movq	16(%rbp), %rcx
	movl	-20(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rcx, %rax
	movl	(%rax), %eax
	cmpl	%eax, %edx
	jle	.L14
	movl	-8(%rbp), %eax
	movl	%eax, -12(%rbp)
	jmp	.L15
.L14:
	movl	-20(%rbp), %eax
	movl	%eax, -12(%rbp)
.L15:
	movl	24(%rbp), %eax
	cmpl	%eax, -4(%rbp)
	jg	.L16
	movq	16(%rbp), %rdx
	movl	-4(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movq	16(%rbp), %rcx
	movl	-12(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rcx, %rax
	movl	(%rax), %eax
	cmpl	%eax, %edx
	jle	.L16
	movl	-4(%rbp), %eax
	movl	%eax, -12(%rbp)
.L16:
	movl	-12(%rbp), %eax
	cmpl	-20(%rbp), %eax
	je	.L18
	movq	16(%rbp), %rax
	movl	-12(%rbp), %edx
	movl	-20(%rbp), %ecx
	movl	%ecx, %esi
	movq	%rax, %rdi
	call	swap
	movl	-12(%rbp), %eax
	subq	$8, %rsp
	pushq	32(%rbp)
	pushq	24(%rbp)
	pushq	16(%rbp)
	movl	%eax, %edi
	call	maxHeapify
	addq	$32, %rsp
.L18:
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE12:
	.size	maxHeapify, .-maxHeapify
	.globl	buildMaxHeap
	.type	buildMaxHeap, @function
buildMaxHeap:
.LFB13:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movq	%rdi, -24(%rbp)
	movq	-24(%rbp), %rax
	movl	12(%rax), %edx
	movq	-24(%rbp), %rax
	movl	%edx, 8(%rax)
	movq	-24(%rbp), %rax
	movl	12(%rax), %eax
	movl	%eax, %edx
	shrl	$31, %edx
	addl	%edx, %eax
	sarl	%eax
	movl	%eax, -4(%rbp)
	jmp	.L20
.L21:
	movl	-4(%rbp), %edx
	subq	$8, %rsp
	movq	-24(%rbp), %rax
	pushq	16(%rax)
	pushq	8(%rax)
	pushq	(%rax)
	movl	%edx, %edi
	call	maxHeapify
	addq	$32, %rsp
	subl	$1, -4(%rbp)
.L20:
	cmpl	$0, -4(%rbp)
	jg	.L21
	nop
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE13:
	.size	buildMaxHeap, .-buildMaxHeap
	.globl	heapExtractMax
	.type	heapExtractMax, @function
heapExtractMax:
.LFB14:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movq	%rdi, -24(%rbp)
	movq	-24(%rbp), %rax
	movl	8(%rax), %eax
	testl	%eax, %eax
	jg	.L23
	movl	$-1, %eax
	jmp	.L24
.L23:
	movq	-24(%rbp), %rax
	movq	(%rax), %rax
	movl	4(%rax), %eax
	movl	%eax, -4(%rbp)
	movq	-24(%rbp), %rax
	movq	(%rax), %rdx
	movq	-24(%rbp), %rax
	movl	8(%rax), %eax
	cltq
	salq	$2, %rax
	leaq	(%rdx,%rax), %rcx
	movq	-24(%rbp), %rax
	movq	(%rax), %rax
	leaq	4(%rax), %rdx
	movl	(%rcx), %eax
	movl	%eax, (%rdx)
	movq	-24(%rbp), %rax
	movl	8(%rax), %eax
	leal	-1(%rax), %edx
	movq	-24(%rbp), %rax
	movl	%edx, 8(%rax)
	subq	$8, %rsp
	movq	-24(%rbp), %rax
	pushq	16(%rax)
	pushq	8(%rax)
	pushq	(%rax)
	movl	$1, %edi
	call	maxHeapify
	addq	$32, %rsp
	movl	-4(%rbp), %eax
.L24:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE14:
	.size	heapExtractMax, .-heapExtractMax
	.globl	heapIncreaseKey
	.type	heapIncreaseKey, @function
heapIncreaseKey:
.LFB15:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%rbx
	subq	$16, %rsp
	.cfi_offset 3, -24
	movq	%rdi, -16(%rbp)
	movl	%esi, -20(%rbp)
	movl	%edx, -24(%rbp)
	movq	-16(%rbp), %rax
	movq	(%rax), %rdx
	movl	-20(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cmpl	%eax, -24(%rbp)
	jl	.L31
	movq	-16(%rbp), %rax
	movq	(%rax), %rdx
	movl	-20(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rax, %rdx
	movl	-24(%rbp), %eax
	movl	%eax, (%rdx)
	jmp	.L28
.L30:
	movl	-20(%rbp), %eax
	movl	%eax, %edi
	call	parentOfIndex
	movl	%eax, %edx
	movq	-16(%rbp), %rax
	movq	(%rax), %rax
	movl	-20(%rbp), %ecx
	movl	%ecx, %esi
	movq	%rax, %rdi
	call	swap
	movl	-20(%rbp), %eax
	movl	%eax, %edi
	call	parentOfIndex
	movl	%eax, -20(%rbp)
.L28:
	cmpl	$1, -20(%rbp)
	jle	.L29
	movq	-16(%rbp), %rax
	movq	(%rax), %rbx
	movl	-20(%rbp), %eax
	movl	%eax, %edi
	call	parentOfIndex
	cltq
	salq	$2, %rax
	addq	%rbx, %rax
	movl	(%rax), %edx
	movq	-16(%rbp), %rax
	movq	(%rax), %rcx
	movl	-20(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rcx, %rax
	movl	(%rax), %eax
	cmpl	%eax, %edx
	jl	.L30
.L29:
	movq	-16(%rbp), %rax
	movl	8(%rax), %edx
	movq	-16(%rbp), %rax
	movl	%edx, 12(%rax)
	jmp	.L25
.L31:
	nop
.L25:
	movq	-8(%rbp), %rbx
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE15:
	.size	heapIncreaseKey, .-heapIncreaseKey
	.globl	maxHeapInsert
	.type	maxHeapInsert, @function
maxHeapInsert:
.LFB16:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$64, %rsp
	movq	%rdi, -24(%rbp)
	movl	%esi, -28(%rbp)
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movq	-24(%rbp), %rax
	movl	8(%rax), %eax
	leal	1(%rax), %ecx
	movq	-24(%rbp), %rdx
	movl	%ecx, 8(%rdx)
	movq	-24(%rbp), %rdx
	movl	%eax, 12(%rdx)
	movq	-24(%rbp), %rax
	movl	16(%rax), %edx
	movq	-24(%rbp), %rax
	movl	8(%rax), %eax
	cmpl	%eax, %edx
	jge	.L33
	leaq	-64(%rbp), %rax
	movq	-24(%rbp), %rdx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	lengthenHeap
.L33:
	movq	-24(%rbp), %rax
	movq	(%rax), %rdx
	movq	-24(%rbp), %rax
	movl	8(%rax), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movl	$-1, (%rax)
	movq	-24(%rbp), %rax
	movl	8(%rax), %ecx
	movl	-28(%rbp), %edx
	movq	-24(%rbp), %rax
	movl	%ecx, %esi
	movq	%rax, %rdi
	call	heapIncreaseKey
	nop
	movq	-8(%rbp), %rax
	subq	%fs:40, %rax
	je	.L34
	call	__stack_chk_fail@PLT
.L34:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE16:
	.size	maxHeapInsert, .-maxHeapInsert
	.globl	heapSort
	.type	heapSort, @function
heapSort:
.LFB17:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movq	%rdi, -24(%rbp)
	movq	-24(%rbp), %rax
	movq	%rax, %rdi
	call	buildMaxHeap
	movq	-24(%rbp), %rax
	movl	12(%rax), %eax
	movl	%eax, -4(%rbp)
	jmp	.L36
.L37:
	movq	-24(%rbp), %rax
	movq	(%rax), %rax
	movl	-4(%rbp), %edx
	movl	$1, %esi
	movq	%rax, %rdi
	call	swap
	movq	-24(%rbp), %rax
	movl	8(%rax), %eax
	leal	-1(%rax), %edx
	movq	-24(%rbp), %rax
	movl	%edx, 8(%rax)
	subq	$8, %rsp
	movq	-24(%rbp), %rax
	pushq	16(%rax)
	pushq	8(%rax)
	pushq	(%rax)
	movl	$1, %edi
	call	maxHeapify
	addq	$32, %rsp
	subl	$1, -4(%rbp)
.L36:
	cmpl	$1, -4(%rbp)
	jg	.L37
	nop
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE17:
	.size	heapSort, .-heapSort
	.section	.rodata
.LC1:
	.string	"%s"
.LC2:
	.string	"insert"
.LC3:
	.string	"%d"
.LC4:
	.string	"extract"
.LC5:
	.string	"%d\n"
.LC6:
	.string	"end"
	.text
	.globl	main
	.type	main, @function
main:
.LFB18:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$80, %rsp
	movl	%edi, -68(%rbp)
	movq	%rsi, -80(%rbp)
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-48(%rbp), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	createHeap
.L43:
	leaq	-18(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	leaq	-18(%rbp), %rax
	leaq	.LC2(%rip), %rdx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L39
	leaq	-52(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-52(%rbp), %edx
	leaq	-48(%rbp), %rax
	movl	%edx, %esi
	movq	%rax, %rdi
	call	maxHeapInsert
	jmp	.L43
.L39:
	leaq	-18(%rbp), %rax
	leaq	.LC4(%rip), %rdx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L41
	leaq	-48(%rbp), %rax
	movq	%rax, %rdi
	call	heapExtractMax
	movl	%eax, %esi
	leaq	.LC5(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L43
.L41:
	leaq	-18(%rbp), %rax
	leaq	.LC6(%rip), %rdx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L43
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L44
	call	__stack_chk_fail@PLT
.L44:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE18:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:
