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>

#define MAX_STONES      100000
#define min(a, b)       ( (a) < (b) ? (a) : (b) )
#define SANITY          0
#define DEBUG           0

int
main(void)
{
    int dp[MAX_STONES], heights[MAX_STONES], n;

    scanf("%d", &n);
    
    #if SANITY
    if(n < 2 || n > MAX_STONES)
    {
        fprintf(stderr, "The number of stones is outside the bounds\n");
        return 1;
    }
    #endif

    /* Read the stone heights */
    for(int i = 0; i < n; i++)
    {
        scanf("%d", &heights[i]);
        #if SANITY
        if(heights[i] < 1 || heights[i] > 10000)
        {
            fprintf(stderr, "The stone height is outside the bounds\n");
            return 2;
        }
        #endif
    }

    /* Build the table */
    dp[0] = 0;
    dp[1] = abs(heights[1] - heights[0]);
    for(int i = 2; i <= n; i++)
    {
        int one_skip_cost, two_skip_cost;
        one_skip_cost = abs(heights[i] - heights[i-1]) + dp[i-1];
        two_skip_cost = abs(heights[i] - heights[i-2]) + dp[i-2];
        dp[i] = one_skip_cost < two_skip_cost ? one_skip_cost : two_skip_cost;        
    }

    #if DEBUG
    for(int i = 0; i < n; i++)
        printf("%d\t", dp[i]);
    putchar('\n');
    #endif

    /* Output the result */
    printf("%d\n", dp[n-1]);

}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	leaq	-798720(%rsp), %r11
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	subq	$1328, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-800036(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -800032(%rbp)
	jmp	.L2
.L3:
	leaq	-400016(%rbp), %rdx
	movl	-800032(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -800032(%rbp)
.L2:
	movl	-800036(%rbp), %eax
	cmpl	%eax, -800032(%rbp)
	jl	.L3
	movl	$0, -800016(%rbp)
	movl	-400012(%rbp), %eax
	movl	-400016(%rbp), %edx
	subl	%edx, %eax
	movl	%eax, %edx
	negl	%edx
	cmovns	%edx, %eax
	movl	%eax, -800012(%rbp)
	movl	$2, -800028(%rbp)
	jmp	.L4
.L5:
	movl	-800028(%rbp), %eax
	cltq
	movl	-400016(%rbp,%rax,4), %edx
	movl	-800028(%rbp), %eax
	subl	$1, %eax
	cltq
	movl	-400016(%rbp,%rax,4), %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	movl	%eax, %edx
	negl	%edx
	cmovs	%eax, %edx
	movl	-800028(%rbp), %eax
	subl	$1, %eax
	cltq
	movl	-800016(%rbp,%rax,4), %eax
	addl	%edx, %eax
	movl	%eax, -800024(%rbp)
	movl	-800028(%rbp), %eax
	cltq
	movl	-400016(%rbp,%rax,4), %edx
	movl	-800028(%rbp), %eax
	subl	$2, %eax
	cltq
	movl	-400016(%rbp,%rax,4), %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	movl	%eax, %edx
	negl	%edx
	cmovs	%eax, %edx
	movl	-800028(%rbp), %eax
	subl	$2, %eax
	cltq
	movl	-800016(%rbp,%rax,4), %eax
	addl	%edx, %eax
	movl	%eax, -800020(%rbp)
	movl	-800020(%rbp), %edx
	movl	-800024(%rbp), %eax
	cmpl	%eax, %edx
	cmovg	%eax, %edx
	movl	-800028(%rbp), %eax
	cltq
	movl	%edx, -800016(%rbp,%rax,4)
	addl	$1, -800028(%rbp)
.L4:
	movl	-800036(%rbp), %eax
	cmpl	%eax, -800028(%rbp)
	jle	.L5
	movl	-800036(%rbp), %eax
	subl	$1, %eax
	cltq
	movl	-800016(%rbp,%rax,4), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L7
	call	__stack_chk_fail@PLT
.L7:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.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
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB39:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	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
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	leaq	-798720(%rsp), %r11
	.cfi_def_cfa 11, 798776
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	.cfi_def_cfa_register 7
	subq	$1336, %rsp
	.cfi_def_cfa_offset 800112
	leaq	.LC0(%rip), %r13
	movq	%r13, %rdi
	movq	%fs:40, %rax
	movq	%rax, 800040(%rsp)
	xorl	%eax, %eax
	leaq	28(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movl	28(%rsp), %edx
	testl	%edx, %edx
	jle	.L2
	leaq	400032(%rsp), %rbx
	xorl	%ebp, %ebp
	movq	%rbx, %r12
	.p2align 4,,10
	.p2align 3
.L3:
	movq	%r12, %rsi
	movq	%r13, %rdi
	xorl	%eax, %eax
	addl	$1, %ebp
	call	__isoc99_scanf@PLT
	movl	28(%rsp), %edx
	addq	$4, %r12
	cmpl	%ebp, %edx
	jg	.L3
	movl	400036(%rsp), %r12d
	movl	400032(%rsp), %r13d
	movl	$0, 32(%rsp)
	movl	%r12d, %eax
	subl	%r13d, %eax
	movl	%eax, %ecx
	negl	%ecx
	cmovs	%eax, %ecx
	movl	%ecx, 36(%rsp)
	cmpl	$1, %edx
	jle	.L8
	leal	-4(%rdx), %eax
	movl	%eax, 12(%rsp)
	cmpl	$7, %edx
	jle	.L10
	leaq	400040(%rsp), %r11
	movl	$8, %ebp
	xorl	%esi, %esi
	leaq	32(%rsp), %rax
.L6:
	movl	(%r11), %r9d
	movl	%r9d, %edi
	movl	%r9d, %r10d
	subl	%r12d, %edi
	movl	%edi, %r8d
	negl	%r8d
	cmovs	%edi, %r8d
	subl	%r13d, %r10d
	movl	%r10d, %edi
	addl	%ecx, %r8d
	negl	%edi
	cmovs	%r10d, %edi
	addl	%edi, %esi
	cmpl	%esi, %r8d
	cmovg	%esi, %r8d
	movl	4(%r11), %esi
	movl	%esi, %edi
	movl	%esi, %r13d
	movd	%r8d, %xmm0
	subl	%r9d, %edi
	movl	%edi, %r10d
	negl	%r10d
	cmovs	%edi, %r10d
	subl	%r12d, %r13d
	movl	8(%r11), %r12d
	movl	%r13d, %edi
	addl	%r8d, %r10d
	negl	%edi
	cmovs	%r13d, %edi
	movl	%r12d, %r13d
	addl	%edi, %ecx
	cmpl	%ecx, %r10d
	cmovg	%ecx, %r10d
	movl	%r12d, %ecx
	subl	%esi, %ecx
	movl	%ecx, %edi
	movd	%r10d, %xmm1
	negl	%edi
	punpckldq	%xmm1, %xmm0
	cmovs	%ecx, %edi
	subl	%r9d, %r13d
	movq	%xmm0, -24(%rax,%rbp,4)
	movl	%r13d, %ecx
	addl	%r10d, %edi
	negl	%ecx
	cmovs	%r13d, %ecx
	addl	%r8d, %ecx
	cmpl	%ecx, %edi
	cmovg	%ecx, %edi
	movl	12(%r11), %ecx
	movl	%ecx, %r13d
	movd	%edi, %xmm0
	subl	%r12d, %r13d
	movl	%r13d, %r9d
	negl	%r9d
	cmovs	%r13d, %r9d
	movl	%ecx, %r13d
	subl	%esi, %r13d
	movl	%r13d, %esi
	addl	%edi, %r9d
	negl	%esi
	cmovs	%r13d, %esi
	movl	16(%r11), %r13d
	addl	%r10d, %esi
	movl	%r13d, %r14d
	cmpl	%esi, %r9d
	cmovg	%esi, %r9d
	subl	%ecx, %r14d
	movl	%r14d, %esi
	negl	%esi
	movd	%r9d, %xmm2
	cmovs	%r14d, %esi
	movl	%r13d, %r14d
	punpckldq	%xmm2, %xmm0
	subl	%r12d, %r14d
	movq	%xmm0, -16(%rax,%rbp,4)
	movl	%r14d, %r12d
	addl	%r9d, %esi
	negl	%r12d
	cmovs	%r14d, %r12d
	addl	%edi, %r12d
	movl	%ebp, %edi
	cmpl	%r12d, %esi
	cmovg	%r12d, %esi
	movl	20(%r11), %r12d
	movl	%r12d, %r15d
	movd	%esi, %xmm0
	subl	%r13d, %r15d
	movl	%r15d, %r14d
	negl	%r14d
	cmovs	%r15d, %r14d
	movl	%r12d, %r15d
	subl	%ecx, %r15d
	movl	%r15d, %ecx
	addl	%esi, %r14d
	negl	%ecx
	cmovs	%r15d, %ecx
	addl	%r9d, %ecx
	cmpl	%ecx, %r14d
	cmovle	%r14d, %ecx
	addq	$24, %r11
	movd	%ecx, %xmm3
	punpckldq	%xmm3, %xmm0
	movq	%xmm0, -8(%rax,%rbp,4)
	addq	$6, %rbp
	leal	-5(%rbp), %r8d
	cmpl	%r8d, 12(%rsp)
	jg	.L6
.L5:
	movslq	%edi, %rcx
	salq	$2, %rcx
	addq	%rcx, %rbx
	addq	%rcx, %rax
	.p2align 4,,10
	.p2align 3
.L7:
	movl	(%rbx), %r8d
	movl	%r8d, %esi
	subl	-8(%rbx), %esi
	movl	%esi, %ecx
	negl	%ecx
	cmovs	%esi, %ecx
	subl	-4(%rbx), %r8d
	addl	-8(%rax), %ecx
	movl	%r8d, %esi
	negl	%esi
	cmovs	%r8d, %esi
	addl	-4(%rax), %esi
	cmpl	%esi, %ecx
	cmovg	%esi, %ecx
	addl	$1, %edi
	addq	$4, %rbx
	addq	$4, %rax
	movl	%ecx, -4(%rax)
	cmpl	%edi, %edx
	jge	.L7
.L8:
	subl	$1, %edx
	xorl	%eax, %eax
	movl	$1, %edi
	movslq	%edx, %rdx
	leaq	.LC1(%rip), %rsi
	movl	32(%rsp,%rdx,4), %edx
	call	__printf_chk@PLT
	movq	800040(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L17
	addq	$800056, %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
.L2:
	.cfi_restore_state
	movl	400036(%rsp), %eax
	subl	400032(%rsp), %eax
	movl	$0, 32(%rsp)
	movl	%eax, %ecx
	negl	%ecx
	cmovns	%ecx, %eax
	movl	%eax, 36(%rsp)
	jmp	.L8
.L10:
	movl	$2, %edi
	leaq	32(%rsp), %rax
	jmp	.L5
.L17:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE39:
	.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
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB39:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	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
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	leaq	-798720(%rsp), %r11
	.cfi_def_cfa 11, 798776
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	.cfi_def_cfa_register 7
	subq	$1336, %rsp
	.cfi_def_cfa_offset 800112
	leaq	.LC0(%rip), %r13
	movq	%r13, %rdi
	movq	%fs:40, %rax
	movq	%rax, 800040(%rsp)
	xorl	%eax, %eax
	leaq	28(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movl	28(%rsp), %edx
	testl	%edx, %edx
	jle	.L2
	leaq	400032(%rsp), %rbx
	xorl	%ebp, %ebp
	movq	%rbx, %r12
	.p2align 4,,10
	.p2align 3
.L3:
	movq	%r12, %rsi
	movq	%r13, %rdi
	xorl	%eax, %eax
	addl	$1, %ebp
	call	__isoc99_scanf@PLT
	movl	28(%rsp), %edx
	addq	$4, %r12
	cmpl	%ebp, %edx
	jg	.L3
	movl	400036(%rsp), %r12d
	movl	400032(%rsp), %r13d
	movl	$0, 32(%rsp)
	movl	%r12d, %eax
	subl	%r13d, %eax
	movl	%eax, %ecx
	negl	%ecx
	cmovs	%eax, %ecx
	movl	%ecx, 36(%rsp)
	cmpl	$1, %edx
	jle	.L8
	leal	-4(%rdx), %eax
	movl	%eax, 12(%rsp)
	cmpl	$7, %edx
	jle	.L10
	leaq	400040(%rsp), %r11
	movl	$8, %ebp
	xorl	%esi, %esi
	leaq	32(%rsp), %rax
.L6:
	movl	(%r11), %r9d
	movl	%r9d, %edi
	movl	%r9d, %r10d
	subl	%r12d, %edi
	movl	%edi, %r8d
	negl	%r8d
	cmovs	%edi, %r8d
	subl	%r13d, %r10d
	movl	%r10d, %edi
	addl	%ecx, %r8d
	negl	%edi
	cmovs	%r10d, %edi
	addl	%edi, %esi
	cmpl	%esi, %r8d
	cmovg	%esi, %r8d
	movl	4(%r11), %esi
	movl	%esi, %edi
	movl	%esi, %r13d
	movd	%r8d, %xmm0
	subl	%r9d, %edi
	movl	%edi, %r10d
	negl	%r10d
	cmovs	%edi, %r10d
	subl	%r12d, %r13d
	movl	8(%r11), %r12d
	movl	%r13d, %edi
	addl	%r8d, %r10d
	negl	%edi
	cmovs	%r13d, %edi
	movl	%r12d, %r13d
	addl	%edi, %ecx
	cmpl	%ecx, %r10d
	cmovg	%ecx, %r10d
	movl	%r12d, %ecx
	subl	%esi, %ecx
	movl	%ecx, %edi
	movd	%r10d, %xmm1
	negl	%edi
	punpckldq	%xmm1, %xmm0
	cmovs	%ecx, %edi
	subl	%r9d, %r13d
	movq	%xmm0, -24(%rax,%rbp,4)
	movl	%r13d, %ecx
	addl	%r10d, %edi
	negl	%ecx
	cmovs	%r13d, %ecx
	addl	%r8d, %ecx
	cmpl	%ecx, %edi
	cmovg	%ecx, %edi
	movl	12(%r11), %ecx
	movl	%ecx, %r13d
	movd	%edi, %xmm0
	subl	%r12d, %r13d
	movl	%r13d, %r9d
	negl	%r9d
	cmovs	%r13d, %r9d
	movl	%ecx, %r13d
	subl	%esi, %r13d
	movl	%r13d, %esi
	addl	%edi, %r9d
	negl	%esi
	cmovs	%r13d, %esi
	movl	16(%r11), %r13d
	addl	%r10d, %esi
	movl	%r13d, %r14d
	cmpl	%esi, %r9d
	cmovg	%esi, %r9d
	subl	%ecx, %r14d
	movl	%r14d, %esi
	negl	%esi
	movd	%r9d, %xmm2
	cmovs	%r14d, %esi
	movl	%r13d, %r14d
	punpckldq	%xmm2, %xmm0
	subl	%r12d, %r14d
	movq	%xmm0, -16(%rax,%rbp,4)
	movl	%r14d, %r12d
	addl	%r9d, %esi
	negl	%r12d
	cmovs	%r14d, %r12d
	addl	%edi, %r12d
	movl	%ebp, %edi
	cmpl	%r12d, %esi
	cmovg	%r12d, %esi
	movl	20(%r11), %r12d
	movl	%r12d, %r15d
	movd	%esi, %xmm0
	subl	%r13d, %r15d
	movl	%r15d, %r14d
	negl	%r14d
	cmovs	%r15d, %r14d
	movl	%r12d, %r15d
	subl	%ecx, %r15d
	movl	%r15d, %ecx
	addl	%esi, %r14d
	negl	%ecx
	cmovs	%r15d, %ecx
	addl	%r9d, %ecx
	cmpl	%ecx, %r14d
	cmovle	%r14d, %ecx
	addq	$24, %r11
	movd	%ecx, %xmm3
	punpckldq	%xmm3, %xmm0
	movq	%xmm0, -8(%rax,%rbp,4)
	addq	$6, %rbp
	leal	-5(%rbp), %r8d
	cmpl	%r8d, 12(%rsp)
	jg	.L6
.L5:
	movslq	%edi, %rcx
	salq	$2, %rcx
	addq	%rcx, %rbx
	addq	%rcx, %rax
	.p2align 4,,10
	.p2align 3
.L7:
	movl	(%rbx), %r8d
	movl	%r8d, %esi
	subl	-8(%rbx), %esi
	movl	%esi, %ecx
	negl	%ecx
	cmovs	%esi, %ecx
	subl	-4(%rbx), %r8d
	addl	-8(%rax), %ecx
	movl	%r8d, %esi
	negl	%esi
	cmovs	%r8d, %esi
	addl	-4(%rax), %esi
	cmpl	%esi, %ecx
	cmovg	%esi, %ecx
	addl	$1, %edi
	addq	$4, %rbx
	addq	$4, %rax
	movl	%ecx, -4(%rax)
	cmpl	%edi, %edx
	jge	.L7
.L8:
	subl	$1, %edx
	xorl	%eax, %eax
	movl	$1, %edi
	movslq	%edx, %rdx
	leaq	.LC1(%rip), %rsi
	movl	32(%rsp,%rdx,4), %edx
	call	__printf_chk@PLT
	movq	800040(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L17
	addq	$800056, %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
.L2:
	.cfi_restore_state
	movl	400036(%rsp), %eax
	subl	400032(%rsp), %eax
	movl	$0, 32(%rsp)
	movl	%eax, %ecx
	negl	%ecx
	cmovns	%ecx, %eax
	movl	%eax, 36(%rsp)
	jmp	.L8
.L10:
	movl	$2, %edi
	leaq	32(%rsp), %rax
	jmp	.L5
.L17:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE39:
	.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>

#define MAX_STONES      100000
#define min(a, b)       ( (a) < (b) ? (a) : (b) )
#define SANITY          0
#define DEBUG           0

int
main(void)
{
    int dp[MAX_STONES], heights[MAX_STONES], n;

    scanf("%d", &n);
    
    #if SANITY
    if(n < 2 || n > MAX_STONES)
    {
        fprintf(stderr, "The number of stones is outside the bounds\n");
        return 1;
    }
    #endif

    /* Read the stone heights */
    for(int i = 0; i < n; i++)
    {
        scanf("%d", &heights[i]);
        #if SANITY
        if(heights[i] < 1 || heights[i] > 10000)
        {
            fprintf(stderr, "The stone height is outside the bounds\n");
            return 2;
        }
        #endif
    }

    /* Build the table */
    dp[0] = 0;
    dp[1] = abs(heights[1] - heights[0]);
    for(int i = 2; i <= n; i++)
    {
        int one_skip_cost, two_skip_cost;
        one_skip_cost = abs(heights[i] - heights[i-1]) + dp[i-1];
        two_skip_cost = abs(heights[i] - heights[i-2]) + dp[i-2];
        dp[i] = one_skip_cost < two_skip_cost ? one_skip_cost : two_skip_cost;        
    }

    #if DEBUG
    for(int i = 0; i < n; i++)
        printf("%d\t", dp[i]);
    putchar('\n');
    #endif

    /* Output the result */
    printf("%d\n", dp[n-1]);

}

6
30 10 60 10 60 57
 4
10 14 40 20
 2
18 10
 4
5 14 40 20
 2
33 10
 6
30 12 60 10 60 9
 2
9 10
 6
30 12 60 17 60 9
 2
9 18
 6
30 12 60 33 60 9

33
 10
 8
 15
 23
 21
 1
 31
 9
 63

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>

#define MAX_STONES      100000
#define min(a, b)       ( (a) < (b) ? (a) : (b) )
#define SANITY          0
#define DEBUG           0

int
main(void)
{
    int dp[MAX_STONES], heights[MAX_STONES], n;

    scanf("%d", &n);
    
    #if SANITY
    if(n < 2 || n > MAX_STONES)
    {
        fprintf(stderr, "The number of stones is outside the bounds\n");
        return 1;
    }
    #endif

    /* Read the stone heights */
    for(int i = 0; i < n; i++)
    {
        scanf("%d", &heights[i]);
        #if SANITY
        if(heights[i] < 1 || heights[i] > 10000)
        {
            fprintf(stderr, "The stone height is outside the bounds\n");
            return 2;
        }
        #endif
    }

    /* Build the table */
    dp[0] = 0;
    dp[1] = abs(heights[1] - heights[0]);
    for(int i = 2; i <= n; i++)
    {
        int one_skip_cost, two_skip_cost;
        one_skip_cost = abs(heights[i] - heights[i-1]) + dp[i-1];
        two_skip_cost = abs(heights[i] - heights[i-2]) + dp[i-2];
        dp[i] = one_skip_cost < two_skip_cost ? one_skip_cost : two_skip_cost;        
    }

    #if DEBUG
    for(int i = 0; i < n; i++)
        printf("%d\t", dp[i]);
    putchar('\n');
    #endif

    /* Output the result */
    printf("%d\n", dp[n-1]);

}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	leaq	-798720(%rsp), %r11
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	subq	$1328, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-800036(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -800032(%rbp)
	jmp	.L2
.L3:
	leaq	-400016(%rbp), %rdx
	movl	-800032(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -800032(%rbp)
.L2:
	movl	-800036(%rbp), %eax
	cmpl	%eax, -800032(%rbp)
	jl	.L3
	movl	$0, -800016(%rbp)
	movl	-400012(%rbp), %eax
	movl	-400016(%rbp), %edx
	subl	%edx, %eax
	movl	%eax, %edx
	negl	%edx
	cmovns	%edx, %eax
	movl	%eax, -800012(%rbp)
	movl	$2, -800028(%rbp)
	jmp	.L4
.L5:
	movl	-800028(%rbp), %eax
	cltq
	movl	-400016(%rbp,%rax,4), %edx
	movl	-800028(%rbp), %eax
	subl	$1, %eax
	cltq
	movl	-400016(%rbp,%rax,4), %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	movl	%eax, %edx
	negl	%edx
	cmovs	%eax, %edx
	movl	-800028(%rbp), %eax
	subl	$1, %eax
	cltq
	movl	-800016(%rbp,%rax,4), %eax
	addl	%edx, %eax
	movl	%eax, -800024(%rbp)
	movl	-800028(%rbp), %eax
	cltq
	movl	-400016(%rbp,%rax,4), %edx
	movl	-800028(%rbp), %eax
	subl	$2, %eax
	cltq
	movl	-400016(%rbp,%rax,4), %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	movl	%eax, %edx
	negl	%edx
	cmovs	%eax, %edx
	movl	-800028(%rbp), %eax
	subl	$2, %eax
	cltq
	movl	-800016(%rbp,%rax,4), %eax
	addl	%edx, %eax
	movl	%eax, -800020(%rbp)
	movl	-800020(%rbp), %edx
	movl	-800024(%rbp), %eax
	cmpl	%eax, %edx
	cmovg	%eax, %edx
	movl	-800028(%rbp), %eax
	cltq
	movl	%edx, -800016(%rbp,%rax,4)
	addl	$1, -800028(%rbp)
.L4:
	movl	-800036(%rbp), %eax
	cmpl	%eax, -800028(%rbp)
	jle	.L5
	movl	-800036(%rbp), %eax
	subl	$1, %eax
	cltq
	movl	-800016(%rbp,%rax,4), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L7
	call	__stack_chk_fail@PLT
.L7:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.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.
val
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	leaq	-798720(%rsp), %r11
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	subq	$1328, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-800036(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -800032(%rbp)
	jmp	.L2
.L3:
	leaq	-400016(%rbp), %rdx
	movl	-800032(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -800032(%rbp)
.L2:
	movl	-800036(%rbp), %eax
	cmpl	%eax, -800032(%rbp)
	jl	.L3
	movl	$0, -800016(%rbp)
	movl	-400012(%rbp), %eax
	movl	-400016(%rbp), %edx
	subl	%edx, %eax
	movl	%eax, %edx
	negl	%edx
	cmovns	%edx, %eax
	movl	%eax, -800012(%rbp)
	movl	$2, -800028(%rbp)
	jmp	.L4
.L5:
	movl	-800028(%rbp), %eax
	cltq
	movl	-400016(%rbp,%rax,4), %edx
	movl	-800028(%rbp), %eax
	subl	$1, %eax
	cltq
	movl	-400016(%rbp,%rax,4), %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	movl	%eax, %edx
	negl	%edx
	cmovs	%eax, %edx
	movl	-800028(%rbp), %eax
	subl	$1, %eax
	cltq
	movl	-800016(%rbp,%rax,4), %eax
	addl	%edx, %eax
	movl	%eax, -800024(%rbp)
	movl	-800028(%rbp), %eax
	cltq
	movl	-400016(%rbp,%rax,4), %edx
	movl	-800028(%rbp), %eax
	subl	$2, %eax
	cltq
	movl	-400016(%rbp,%rax,4), %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	movl	%eax, %edx
	negl	%edx
	cmovs	%eax, %edx
	movl	-800028(%rbp), %eax
	subl	$2, %eax
	cltq
	movl	-800016(%rbp,%rax,4), %eax
	addl	%edx, %eax
	movl	%eax, -800020(%rbp)
	movl	-800020(%rbp), %edx
	movl	-800024(%rbp), %eax
	cmpl	%eax, %edx
	cmovg	%eax, %edx
	movl	-800028(%rbp), %eax
	cltq
	movl	%edx, -800016(%rbp,%rax,4)
	addl	$1, -800028(%rbp)
.L4:
	movl	-800036(%rbp), %eax
	cmpl	%eax, -800028(%rbp)
	jle	.L5
	movl	-800036(%rbp), %eax
	subl	$1, %eax
	cltq
	movl	-800016(%rbp,%rax,4), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L7
	call	__stack_chk_fail@PLT
.L7:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.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:
