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>

#define abs(x) (((x)>0)?(x):-(x))
#define min(a, b) ((a)>(b)?(b):(a))

int main()
{
  int i, n;
  scanf("%d", &n);
  int h[n+1];
  int cost[n+1];
  for (i=0; i<n; i++)  scanf("%d", &h[i]);
  h[n] = h[n-1];
  cost[n] = cost[n-1] = 0;
  
  for (i=n-2; i>=0; i--)
    cost[i] = min(abs(h[i]-h[i+2])+cost[i+2], abs(h[i]-h[i+1])+cost[i+1]);

  printf("%d\n", cost[0]);

  return 0;
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%r15
	pushq	%r14
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	subq	$88, %rsp
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	.cfi_offset 12, -48
	.cfi_offset 3, -56
	movq	%fs:40, %rax
	movq	%rax, -56(%rbp)
	xorl	%eax, %eax
	movq	%rsp, %rax
	movq	%rax, %rbx
	leaq	-96(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-96(%rbp), %eax
	addl	$1, %eax
	movslq	%eax, %rdx
	subq	$1, %rdx
	movq	%rdx, -88(%rbp)
	movslq	%eax, %rdx
	movq	%rdx, -112(%rbp)
	movq	$0, -104(%rbp)
	movslq	%eax, %rdx
	movq	%rdx, -128(%rbp)
	movq	$0, -120(%rbp)
	cltq
	leaq	0(,%rax,4), %rdx
	movl	$16, %eax
	subq	$1, %rax
	addq	%rdx, %rax
	movl	$16, %edi
	movl	$0, %edx
	divq	%rdi
	imulq	$16, %rax, %rax
	movq	%rax, %rcx
	andq	$-4096, %rcx
	movq	%rsp, %rdx
	subq	%rcx, %rdx
.L2:
	cmpq	%rdx, %rsp
	je	.L3
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L2
.L3:
	movq	%rax, %rdx
	andl	$4095, %edx
	subq	%rdx, %rsp
	movq	%rax, %rdx
	andl	$4095, %edx
	testq	%rdx, %rdx
	je	.L4
	andl	$4095, %eax
	subq	$8, %rax
	addq	%rsp, %rax
	orq	$0, (%rax)
.L4:
	movq	%rsp, %rax
	addq	$3, %rax
	shrq	$2, %rax
	salq	$2, %rax
	movq	%rax, -80(%rbp)
	movl	-96(%rbp), %eax
	addl	$1, %eax
	movslq	%eax, %rdx
	subq	$1, %rdx
	movq	%rdx, -72(%rbp)
	movslq	%eax, %rdx
	movq	%rdx, %r14
	movl	$0, %r15d
	movslq	%eax, %rdx
	movq	%rdx, %r12
	movl	$0, %r13d
	cltq
	leaq	0(,%rax,4), %rdx
	movl	$16, %eax
	subq	$1, %rax
	addq	%rdx, %rax
	movl	$16, %edi
	movl	$0, %edx
	divq	%rdi
	imulq	$16, %rax, %rax
	movq	%rax, %rcx
	andq	$-4096, %rcx
	movq	%rsp, %rdx
	subq	%rcx, %rdx
.L5:
	cmpq	%rdx, %rsp
	je	.L6
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L5
.L6:
	movq	%rax, %rdx
	andl	$4095, %edx
	subq	%rdx, %rsp
	movq	%rax, %rdx
	andl	$4095, %edx
	testq	%rdx, %rdx
	je	.L7
	andl	$4095, %eax
	subq	$8, %rax
	addq	%rsp, %rax
	orq	$0, (%rax)
.L7:
	movq	%rsp, %rax
	addq	$3, %rax
	shrq	$2, %rax
	salq	$2, %rax
	movq	%rax, -64(%rbp)
	movl	$0, -92(%rbp)
	jmp	.L8
.L9:
	movl	-92(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-80(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -92(%rbp)
.L8:
	movl	-96(%rbp), %eax
	cmpl	%eax, -92(%rbp)
	jl	.L9
	movl	-96(%rbp), %eax
	leal	-1(%rax), %edx
	movl	-96(%rbp), %esi
	movq	-80(%rbp), %rax
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %ecx
	movq	-80(%rbp), %rax
	movslq	%esi, %rdx
	movl	%ecx, (%rax,%rdx,4)
	movl	-96(%rbp), %eax
	subl	$1, %eax
	movq	-64(%rbp), %rdx
	movslq	%eax, %rcx
	movl	$0, (%rdx,%rcx,4)
	movl	-96(%rbp), %esi
	movq	-64(%rbp), %rdx
	cltq
	movl	(%rdx,%rax,4), %ecx
	movq	-64(%rbp), %rax
	movslq	%esi, %rdx
	movl	%ecx, (%rax,%rdx,4)
	movl	-96(%rbp), %eax
	subl	$2, %eax
	movl	%eax, -92(%rbp)
	jmp	.L10
.L11:
	movq	-80(%rbp), %rax
	movl	-92(%rbp), %edx
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %ecx
	movl	-92(%rbp), %eax
	leal	2(%rax), %edx
	movq	-80(%rbp), %rax
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %edx
	movl	%ecx, %eax
	subl	%edx, %eax
	movl	%eax, %edx
	negl	%edx
	cmovns	%edx, %eax
	movl	%eax, %ecx
	movl	-92(%rbp), %eax
	leal	2(%rax), %edx
	movq	-64(%rbp), %rax
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %eax
	leal	(%rcx,%rax), %edx
	movq	-80(%rbp), %rax
	movl	-92(%rbp), %ecx
	movslq	%ecx, %rcx
	movl	(%rax,%rcx,4), %esi
	movl	-92(%rbp), %eax
	leal	1(%rax), %ecx
	movq	-80(%rbp), %rax
	movslq	%ecx, %rcx
	movl	(%rax,%rcx,4), %ecx
	movl	%esi, %eax
	subl	%ecx, %eax
	movl	%eax, %ecx
	negl	%ecx
	cmovns	%ecx, %eax
	movl	%eax, %esi
	movl	-92(%rbp), %eax
	leal	1(%rax), %ecx
	movq	-64(%rbp), %rax
	movslq	%ecx, %rcx
	movl	(%rax,%rcx,4), %eax
	addl	%esi, %eax
	cmpl	%eax, %edx
	cmovle	%edx, %eax
	movl	%eax, %ecx
	movq	-64(%rbp), %rax
	movl	-92(%rbp), %edx
	movslq	%edx, %rdx
	movl	%ecx, (%rax,%rdx,4)
	subl	$1, -92(%rbp)
.L10:
	cmpl	$0, -92(%rbp)
	jns	.L11
	movq	-64(%rbp), %rax
	movl	(%rax), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	%rbx, %rsp
	movq	-56(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L13
	call	__stack_chk_fail@PLT
.L13:
	leaq	-40(%rbp), %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.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:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%r15
	.cfi_offset 15, -24
	leaq	.LC0(%rip), %r15
	pushq	%r14
	leaq	-60(%rbp), %rsi
	movq	%r15, %rdi
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	subq	$40, %rsp
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	.cfi_offset 12, -48
	.cfi_offset 3, -56
	movq	%fs:40, %rax
	movq	%rax, -56(%rbp)
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	-60(%rbp), %ecx
	movq	%rsp, %rsi
	leal	1(%rcx), %eax
	cltq
	leaq	15(,%rax,4), %rax
	movq	%rax, %rdi
	movq	%rax, %rdx
	andq	$-4096, %rdi
	andq	$-16, %rdx
	subq	%rdi, %rsi
	cmpq	%rsi, %rsp
	je	.L3
.L26:
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	cmpq	%rsi, %rsp
	jne	.L26
.L3:
	andl	$4095, %edx
	subq	%rdx, %rsp
	testq	%rdx, %rdx
	jne	.L27
.L4:
	movq	%rax, %rdx
	movq	%rsp, %rsi
	andq	$-4096, %rax
	movq	%rsp, %r12
	andq	$-16, %rdx
	subq	%rax, %rsi
.L5:
	cmpq	%rsi, %rsp
	je	.L6
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L5
.L27:
	orq	$0, -8(%rsp,%rdx)
	jmp	.L4
.L6:
	andl	$4095, %edx
	subq	%rdx, %rsp
	testq	%rdx, %rdx
	jne	.L28
.L7:
	leaq	3(%rsp), %r13
	movq	%r13, %rax
	andq	$-4, %r13
	shrq	$2, %rax
	movq	%rax, -72(%rbp)
	testl	%ecx, %ecx
	jle	.L8
	movq	%r12, %rbx
	xorl	%r14d, %r14d
	.p2align 4,,10
	.p2align 3
.L9:
	movq	%rbx, %rsi
	movq	%r15, %rdi
	xorl	%eax, %eax
	addl	$1, %r14d
	call	__isoc99_scanf@PLT
	movl	-60(%rbp), %ecx
	addq	$4, %rbx
	cmpl	%r14d, %ecx
	jg	.L9
.L8:
	leal	-1(%rcx), %eax
	movq	-72(%rbp), %rbx
	movslq	%ecx, %rdx
	cltq
	movl	(%r12,%rax,4), %esi
	salq	$2, %rax
	movq	$0, (%rax,%rbx,4)
	movl	%ecx, %eax
	movl	%esi, (%r12,%rdx,4)
	subl	$2, %eax
	js	.L10
	salq	$2, %rdx
	leaq	-4(%rdx), %rsi
	leaq	0(%r13,%rdx), %r8
	addq	%r12, %rdx
	leaq	0(%r13,%rsi), %r10
	leaq	(%r12,%rsi), %r9
	cmpl	$7, %ecx
	jle	.L11
	movl	(%r10), %esi
	movl	(%r8), %edi
	movq	%r8, %rcx
	movl	(%rdx), %r10d
	movl	(%r9), %r9d
.L12:
	movl	-8(%rdx), %r11d
	movl	%r11d, %r8d
	subl	%r10d, %r8d
	movl	%r8d, %r10d
	negl	%r10d
	cmovs	%r8d, %r10d
	movl	%r11d, %r8d
	subl	%r9d, %r8d
	addl	%edi, %r10d
	movl	%r8d, %edi
	negl	%edi
	cmovs	%r8d, %edi
	movl	-12(%rdx), %r8d
	addl	%esi, %edi
	movl	%r8d, %r14d
	cmpl	%edi, %r10d
	cmovg	%edi, %r10d
	subl	%r9d, %r14d
	movl	%r8d, %r9d
	movl	%r14d, %edi
	negl	%edi
	movl	%r10d, -8(%rcx)
	cmovs	%r14d, %edi
	subl	%r11d, %r9d
	addl	%esi, %edi
	movl	%r9d, %esi
	negl	%esi
	cmovs	%r9d, %esi
	movl	-16(%rdx), %r9d
	addl	%r10d, %esi
	movl	%r9d, %r14d
	cmpl	%esi, %edi
	cmovg	%esi, %edi
	subl	%r11d, %r14d
	movl	%r9d, %r11d
	movl	%r14d, %esi
	negl	%esi
	movl	%edi, -12(%rcx)
	cmovs	%r14d, %esi
	subl	%r8d, %r11d
	addl	%r10d, %esi
	movl	%r11d, %r10d
	negl	%r10d
	cmovs	%r11d, %r10d
	movl	-20(%rdx), %r11d
	addl	%edi, %r10d
	cmpl	%r10d, %esi
	cmovg	%r10d, %esi
	movl	%r11d, %r10d
	subl	%r8d, %r10d
	movl	%r10d, %r8d
	movl	%esi, -16(%rcx)
	negl	%r8d
	cmovs	%r10d, %r8d
	movl	%r11d, %r10d
	subl	%r9d, %r10d
	addl	%edi, %r8d
	movl	%r10d, %edi
	negl	%edi
	cmovs	%r10d, %edi
	movl	-24(%rdx), %r10d
	addl	%esi, %edi
	movl	%r10d, %r14d
	cmpl	%edi, %r8d
	cmovg	%edi, %r8d
	subl	%r9d, %r14d
	movl	%r10d, %r9d
	movl	%r14d, %edi
	negl	%edi
	movl	%r8d, -20(%rcx)
	cmovs	%r14d, %edi
	subl	%r11d, %r9d
	addl	%esi, %edi
	movl	%r9d, %esi
	negl	%esi
	cmovs	%r9d, %esi
	movl	-28(%rdx), %r9d
	addl	%r8d, %esi
	movl	%r9d, %r14d
	cmpl	%esi, %edi
	cmovg	%esi, %edi
	subl	%r11d, %r14d
	movl	%r9d, %r11d
	movl	%r14d, %esi
	negl	%esi
	movl	%edi, -24(%rcx)
	cmovs	%r14d, %esi
	subl	%r10d, %r11d
	addl	%r8d, %esi
	movl	%r11d, %r8d
	negl	%r8d
	cmovs	%r11d, %r8d
	addl	%edi, %r8d
	cmpl	%r8d, %esi
	cmovg	%r8d, %esi
	movl	%eax, %r8d
	subq	$24, %rdx
	subl	$6, %eax
	subl	$7, %r8d
	subq	$24, %rcx
	movl	%esi, -4(%rcx)
	cmpl	$4, %r8d
	jg	.L12
.L11:
	cltq
	.p2align 4,,10
	.p2align 3
.L13:
	movl	(%r12,%rax,4), %esi
	movl	%esi, %ecx
	subl	4(%r12,%rax,4), %ecx
	movl	%ecx, %edx
	negl	%edx
	cmovs	%ecx, %edx
	subl	8(%r12,%rax,4), %esi
	addl	4(%r13,%rax,4), %edx
	movl	%esi, %ecx
	negl	%ecx
	cmovs	%esi, %ecx
	addl	8(%r13,%rax,4), %ecx
	cmpl	%ecx, %edx
	cmovg	%ecx, %edx
	movl	%edx, 0(%r13,%rax,4)
	subq	$1, %rax
	testl	%eax, %eax
	jns	.L13
.L10:
	movq	-72(%rbp), %rax
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	movl	0(,%rax,4), %edx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	-56(%rbp), %rax
	subq	%fs:40, %rax
	jne	.L29
	leaq	-40(%rbp), %rsp
	xorl	%eax, %eax
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_remember_state
	.cfi_def_cfa 7, 8
	ret
.L28:
	.cfi_restore_state
	orq	$0, -8(%rsp,%rdx)
	jmp	.L7
.L29:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.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:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%r15
	.cfi_offset 15, -24
	leaq	.LC0(%rip), %r15
	pushq	%r14
	leaq	-60(%rbp), %rsi
	movq	%r15, %rdi
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	subq	$40, %rsp
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	.cfi_offset 12, -48
	.cfi_offset 3, -56
	movq	%fs:40, %rax
	movq	%rax, -56(%rbp)
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	-60(%rbp), %ecx
	movq	%rsp, %rsi
	leal	1(%rcx), %eax
	cltq
	leaq	15(,%rax,4), %rax
	movq	%rax, %rdi
	movq	%rax, %rdx
	andq	$-4096, %rdi
	andq	$-16, %rdx
	subq	%rdi, %rsi
	cmpq	%rsi, %rsp
	je	.L3
.L26:
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	cmpq	%rsi, %rsp
	jne	.L26
.L3:
	andl	$4095, %edx
	subq	%rdx, %rsp
	testq	%rdx, %rdx
	jne	.L27
.L4:
	movq	%rax, %rdx
	movq	%rsp, %rsi
	andq	$-4096, %rax
	movq	%rsp, %r12
	andq	$-16, %rdx
	subq	%rax, %rsi
.L5:
	cmpq	%rsi, %rsp
	je	.L6
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L5
.L27:
	orq	$0, -8(%rsp,%rdx)
	jmp	.L4
.L6:
	andl	$4095, %edx
	subq	%rdx, %rsp
	testq	%rdx, %rdx
	jne	.L28
.L7:
	leaq	3(%rsp), %r13
	movq	%r13, %rax
	andq	$-4, %r13
	shrq	$2, %rax
	movq	%rax, -72(%rbp)
	testl	%ecx, %ecx
	jle	.L8
	movq	%r12, %rbx
	xorl	%r14d, %r14d
	.p2align 4,,10
	.p2align 3
.L9:
	movq	%rbx, %rsi
	movq	%r15, %rdi
	xorl	%eax, %eax
	addl	$1, %r14d
	call	__isoc99_scanf@PLT
	movl	-60(%rbp), %ecx
	addq	$4, %rbx
	cmpl	%r14d, %ecx
	jg	.L9
.L8:
	leal	-1(%rcx), %eax
	movq	-72(%rbp), %rbx
	movslq	%ecx, %rdx
	cltq
	movl	(%r12,%rax,4), %esi
	salq	$2, %rax
	movq	$0, (%rax,%rbx,4)
	movl	%ecx, %eax
	movl	%esi, (%r12,%rdx,4)
	subl	$2, %eax
	js	.L10
	salq	$2, %rdx
	leaq	-4(%rdx), %rsi
	leaq	0(%r13,%rdx), %r8
	addq	%r12, %rdx
	leaq	0(%r13,%rsi), %r10
	leaq	(%r12,%rsi), %r9
	cmpl	$7, %ecx
	jle	.L11
	movl	(%r10), %esi
	movl	(%r8), %edi
	movq	%r8, %rcx
	movl	(%rdx), %r10d
	movl	(%r9), %r9d
.L12:
	movl	-8(%rdx), %r11d
	movl	%r11d, %r8d
	subl	%r10d, %r8d
	movl	%r8d, %r10d
	negl	%r10d
	cmovs	%r8d, %r10d
	movl	%r11d, %r8d
	subl	%r9d, %r8d
	addl	%edi, %r10d
	movl	%r8d, %edi
	negl	%edi
	cmovs	%r8d, %edi
	movl	-12(%rdx), %r8d
	addl	%esi, %edi
	movl	%r8d, %r14d
	cmpl	%edi, %r10d
	cmovg	%edi, %r10d
	subl	%r9d, %r14d
	movl	%r8d, %r9d
	movl	%r14d, %edi
	negl	%edi
	movl	%r10d, -8(%rcx)
	cmovs	%r14d, %edi
	subl	%r11d, %r9d
	addl	%esi, %edi
	movl	%r9d, %esi
	negl	%esi
	cmovs	%r9d, %esi
	movl	-16(%rdx), %r9d
	addl	%r10d, %esi
	movl	%r9d, %r14d
	cmpl	%esi, %edi
	cmovg	%esi, %edi
	subl	%r11d, %r14d
	movl	%r9d, %r11d
	movl	%r14d, %esi
	negl	%esi
	movl	%edi, -12(%rcx)
	cmovs	%r14d, %esi
	subl	%r8d, %r11d
	addl	%r10d, %esi
	movl	%r11d, %r10d
	negl	%r10d
	cmovs	%r11d, %r10d
	movl	-20(%rdx), %r11d
	addl	%edi, %r10d
	cmpl	%r10d, %esi
	cmovg	%r10d, %esi
	movl	%r11d, %r10d
	subl	%r8d, %r10d
	movl	%r10d, %r8d
	movl	%esi, -16(%rcx)
	negl	%r8d
	cmovs	%r10d, %r8d
	movl	%r11d, %r10d
	subl	%r9d, %r10d
	addl	%edi, %r8d
	movl	%r10d, %edi
	negl	%edi
	cmovs	%r10d, %edi
	movl	-24(%rdx), %r10d
	addl	%esi, %edi
	movl	%r10d, %r14d
	cmpl	%edi, %r8d
	cmovg	%edi, %r8d
	subl	%r9d, %r14d
	movl	%r10d, %r9d
	movl	%r14d, %edi
	negl	%edi
	movl	%r8d, -20(%rcx)
	cmovs	%r14d, %edi
	subl	%r11d, %r9d
	addl	%esi, %edi
	movl	%r9d, %esi
	negl	%esi
	cmovs	%r9d, %esi
	movl	-28(%rdx), %r9d
	addl	%r8d, %esi
	movl	%r9d, %r14d
	cmpl	%esi, %edi
	cmovg	%esi, %edi
	subl	%r11d, %r14d
	movl	%r9d, %r11d
	movl	%r14d, %esi
	negl	%esi
	movl	%edi, -24(%rcx)
	cmovs	%r14d, %esi
	subl	%r10d, %r11d
	addl	%r8d, %esi
	movl	%r11d, %r8d
	negl	%r8d
	cmovs	%r11d, %r8d
	addl	%edi, %r8d
	cmpl	%r8d, %esi
	cmovg	%r8d, %esi
	movl	%eax, %r8d
	subq	$24, %rdx
	subl	$6, %eax
	subl	$7, %r8d
	subq	$24, %rcx
	movl	%esi, -4(%rcx)
	cmpl	$4, %r8d
	jg	.L12
.L11:
	cltq
	.p2align 4,,10
	.p2align 3
.L13:
	movl	(%r12,%rax,4), %esi
	movl	%esi, %ecx
	subl	4(%r12,%rax,4), %ecx
	movl	%ecx, %edx
	negl	%edx
	cmovs	%ecx, %edx
	subl	8(%r12,%rax,4), %esi
	addl	4(%r13,%rax,4), %edx
	movl	%esi, %ecx
	negl	%ecx
	cmovs	%esi, %ecx
	addl	8(%r13,%rax,4), %ecx
	cmpl	%ecx, %edx
	cmovg	%ecx, %edx
	movl	%edx, 0(%r13,%rax,4)
	subq	$1, %rax
	testl	%eax, %eax
	jns	.L13
.L10:
	movq	-72(%rbp), %rax
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	movl	0(,%rax,4), %edx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	-56(%rbp), %rax
	subq	%fs:40, %rax
	jne	.L29
	leaq	-40(%rbp), %rsp
	xorl	%eax, %eax
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_remember_state
	.cfi_def_cfa 7, 8
	ret
.L28:
	.cfi_restore_state
	orq	$0, -8(%rsp,%rdx)
	jmp	.L7
.L29:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.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>

#define abs(x) (((x)>0)?(x):-(x))
#define min(a, b) ((a)>(b)?(b):(a))

int main()
{
  int i, n;
  scanf("%d", &n);
  int h[n+1];
  int cost[n+1];
  for (i=0; i<n; i++)  scanf("%d", &h[i]);
  h[n] = h[n-1];
  cost[n] = cost[n-1] = 0;
  
  for (i=n-2; i>=0; i--)
    cost[i] = min(abs(h[i]-h[i+2])+cost[i+2], abs(h[i]-h[i+1])+cost[i+1]);

  printf("%d\n", cost[0]);

  return 0;
}

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>

#define abs(x) (((x)>0)?(x):-(x))
#define min(a, b) ((a)>(b)?(b):(a))

int main()
{
  int i, n;
  scanf("%d", &n);
  int h[n+1];
  int cost[n+1];
  for (i=0; i<n; i++)  scanf("%d", &h[i]);
  h[n] = h[n-1];
  cost[n] = cost[n-1] = 0;
  
  for (i=n-2; i>=0; i--)
    cost[i] = min(abs(h[i]-h[i+2])+cost[i+2], abs(h[i]-h[i+1])+cost[i+1]);

  printf("%d\n", cost[0]);

  return 0;
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%r15
	pushq	%r14
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	subq	$88, %rsp
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	.cfi_offset 12, -48
	.cfi_offset 3, -56
	movq	%fs:40, %rax
	movq	%rax, -56(%rbp)
	xorl	%eax, %eax
	movq	%rsp, %rax
	movq	%rax, %rbx
	leaq	-96(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-96(%rbp), %eax
	addl	$1, %eax
	movslq	%eax, %rdx
	subq	$1, %rdx
	movq	%rdx, -88(%rbp)
	movslq	%eax, %rdx
	movq	%rdx, -112(%rbp)
	movq	$0, -104(%rbp)
	movslq	%eax, %rdx
	movq	%rdx, -128(%rbp)
	movq	$0, -120(%rbp)
	cltq
	leaq	0(,%rax,4), %rdx
	movl	$16, %eax
	subq	$1, %rax
	addq	%rdx, %rax
	movl	$16, %edi
	movl	$0, %edx
	divq	%rdi
	imulq	$16, %rax, %rax
	movq	%rax, %rcx
	andq	$-4096, %rcx
	movq	%rsp, %rdx
	subq	%rcx, %rdx
.L2:
	cmpq	%rdx, %rsp
	je	.L3
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L2
.L3:
	movq	%rax, %rdx
	andl	$4095, %edx
	subq	%rdx, %rsp
	movq	%rax, %rdx
	andl	$4095, %edx
	testq	%rdx, %rdx
	je	.L4
	andl	$4095, %eax
	subq	$8, %rax
	addq	%rsp, %rax
	orq	$0, (%rax)
.L4:
	movq	%rsp, %rax
	addq	$3, %rax
	shrq	$2, %rax
	salq	$2, %rax
	movq	%rax, -80(%rbp)
	movl	-96(%rbp), %eax
	addl	$1, %eax
	movslq	%eax, %rdx
	subq	$1, %rdx
	movq	%rdx, -72(%rbp)
	movslq	%eax, %rdx
	movq	%rdx, %r14
	movl	$0, %r15d
	movslq	%eax, %rdx
	movq	%rdx, %r12
	movl	$0, %r13d
	cltq
	leaq	0(,%rax,4), %rdx
	movl	$16, %eax
	subq	$1, %rax
	addq	%rdx, %rax
	movl	$16, %edi
	movl	$0, %edx
	divq	%rdi
	imulq	$16, %rax, %rax
	movq	%rax, %rcx
	andq	$-4096, %rcx
	movq	%rsp, %rdx
	subq	%rcx, %rdx
.L5:
	cmpq	%rdx, %rsp
	je	.L6
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L5
.L6:
	movq	%rax, %rdx
	andl	$4095, %edx
	subq	%rdx, %rsp
	movq	%rax, %rdx
	andl	$4095, %edx
	testq	%rdx, %rdx
	je	.L7
	andl	$4095, %eax
	subq	$8, %rax
	addq	%rsp, %rax
	orq	$0, (%rax)
.L7:
	movq	%rsp, %rax
	addq	$3, %rax
	shrq	$2, %rax
	salq	$2, %rax
	movq	%rax, -64(%rbp)
	movl	$0, -92(%rbp)
	jmp	.L8
.L9:
	movl	-92(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-80(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -92(%rbp)
.L8:
	movl	-96(%rbp), %eax
	cmpl	%eax, -92(%rbp)
	jl	.L9
	movl	-96(%rbp), %eax
	leal	-1(%rax), %edx
	movl	-96(%rbp), %esi
	movq	-80(%rbp), %rax
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %ecx
	movq	-80(%rbp), %rax
	movslq	%esi, %rdx
	movl	%ecx, (%rax,%rdx,4)
	movl	-96(%rbp), %eax
	subl	$1, %eax
	movq	-64(%rbp), %rdx
	movslq	%eax, %rcx
	movl	$0, (%rdx,%rcx,4)
	movl	-96(%rbp), %esi
	movq	-64(%rbp), %rdx
	cltq
	movl	(%rdx,%rax,4), %ecx
	movq	-64(%rbp), %rax
	movslq	%esi, %rdx
	movl	%ecx, (%rax,%rdx,4)
	movl	-96(%rbp), %eax
	subl	$2, %eax
	movl	%eax, -92(%rbp)
	jmp	.L10
.L11:
	movq	-80(%rbp), %rax
	movl	-92(%rbp), %edx
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %ecx
	movl	-92(%rbp), %eax
	leal	2(%rax), %edx
	movq	-80(%rbp), %rax
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %edx
	movl	%ecx, %eax
	subl	%edx, %eax
	movl	%eax, %edx
	negl	%edx
	cmovns	%edx, %eax
	movl	%eax, %ecx
	movl	-92(%rbp), %eax
	leal	2(%rax), %edx
	movq	-64(%rbp), %rax
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %eax
	leal	(%rcx,%rax), %edx
	movq	-80(%rbp), %rax
	movl	-92(%rbp), %ecx
	movslq	%ecx, %rcx
	movl	(%rax,%rcx,4), %esi
	movl	-92(%rbp), %eax
	leal	1(%rax), %ecx
	movq	-80(%rbp), %rax
	movslq	%ecx, %rcx
	movl	(%rax,%rcx,4), %ecx
	movl	%esi, %eax
	subl	%ecx, %eax
	movl	%eax, %ecx
	negl	%ecx
	cmovns	%ecx, %eax
	movl	%eax, %esi
	movl	-92(%rbp), %eax
	leal	1(%rax), %ecx
	movq	-64(%rbp), %rax
	movslq	%ecx, %rcx
	movl	(%rax,%rcx,4), %eax
	addl	%esi, %eax
	cmpl	%eax, %edx
	cmovle	%edx, %eax
	movl	%eax, %ecx
	movq	-64(%rbp), %rax
	movl	-92(%rbp), %edx
	movslq	%edx, %rdx
	movl	%ecx, (%rax,%rdx,4)
	subl	$1, -92(%rbp)
.L10:
	cmpl	$0, -92(%rbp)
	jns	.L11
	movq	-64(%rbp), %rax
	movl	(%rax), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	%rbx, %rsp
	movq	-56(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L13
	call	__stack_chk_fail@PLT
.L13:
	leaq	-40(%rbp), %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.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
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%r15
	pushq	%r14
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	subq	$88, %rsp
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	.cfi_offset 12, -48
	.cfi_offset 3, -56
	movq	%fs:40, %rax
	movq	%rax, -56(%rbp)
	xorl	%eax, %eax
	movq	%rsp, %rax
	movq	%rax, %rbx
	leaq	-96(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-96(%rbp), %eax
	addl	$1, %eax
	movslq	%eax, %rdx
	subq	$1, %rdx
	movq	%rdx, -88(%rbp)
	movslq	%eax, %rdx
	movq	%rdx, -112(%rbp)
	movq	$0, -104(%rbp)
	movslq	%eax, %rdx
	movq	%rdx, -128(%rbp)
	movq	$0, -120(%rbp)
	cltq
	leaq	0(,%rax,4), %rdx
	movl	$16, %eax
	subq	$1, %rax
	addq	%rdx, %rax
	movl	$16, %edi
	movl	$0, %edx
	divq	%rdi
	imulq	$16, %rax, %rax
	movq	%rax, %rcx
	andq	$-4096, %rcx
	movq	%rsp, %rdx
	subq	%rcx, %rdx
.L2:
	cmpq	%rdx, %rsp
	je	.L3
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L2
.L3:
	movq	%rax, %rdx
	andl	$4095, %edx
	subq	%rdx, %rsp
	movq	%rax, %rdx
	andl	$4095, %edx
	testq	%rdx, %rdx
	je	.L4
	andl	$4095, %eax
	subq	$8, %rax
	addq	%rsp, %rax
	orq	$0, (%rax)
.L4:
	movq	%rsp, %rax
	addq	$3, %rax
	shrq	$2, %rax
	salq	$2, %rax
	movq	%rax, -80(%rbp)
	movl	-96(%rbp), %eax
	addl	$1, %eax
	movslq	%eax, %rdx
	subq	$1, %rdx
	movq	%rdx, -72(%rbp)
	movslq	%eax, %rdx
	movq	%rdx, %r14
	movl	$0, %r15d
	movslq	%eax, %rdx
	movq	%rdx, %r12
	movl	$0, %r13d
	cltq
	leaq	0(,%rax,4), %rdx
	movl	$16, %eax
	subq	$1, %rax
	addq	%rdx, %rax
	movl	$16, %edi
	movl	$0, %edx
	divq	%rdi
	imulq	$16, %rax, %rax
	movq	%rax, %rcx
	andq	$-4096, %rcx
	movq	%rsp, %rdx
	subq	%rcx, %rdx
.L5:
	cmpq	%rdx, %rsp
	je	.L6
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L5
.L6:
	movq	%rax, %rdx
	andl	$4095, %edx
	subq	%rdx, %rsp
	movq	%rax, %rdx
	andl	$4095, %edx
	testq	%rdx, %rdx
	je	.L7
	andl	$4095, %eax
	subq	$8, %rax
	addq	%rsp, %rax
	orq	$0, (%rax)
.L7:
	movq	%rsp, %rax
	addq	$3, %rax
	shrq	$2, %rax
	salq	$2, %rax
	movq	%rax, -64(%rbp)
	movl	$0, -92(%rbp)
	jmp	.L8
.L9:
	movl	-92(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-80(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -92(%rbp)
.L8:
	movl	-96(%rbp), %eax
	cmpl	%eax, -92(%rbp)
	jl	.L9
	movl	-96(%rbp), %eax
	leal	-1(%rax), %edx
	movl	-96(%rbp), %esi
	movq	-80(%rbp), %rax
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %ecx
	movq	-80(%rbp), %rax
	movslq	%esi, %rdx
	movl	%ecx, (%rax,%rdx,4)
	movl	-96(%rbp), %eax
	subl	$1, %eax
	movq	-64(%rbp), %rdx
	movslq	%eax, %rcx
	movl	$0, (%rdx,%rcx,4)
	movl	-96(%rbp), %esi
	movq	-64(%rbp), %rdx
	cltq
	movl	(%rdx,%rax,4), %ecx
	movq	-64(%rbp), %rax
	movslq	%esi, %rdx
	movl	%ecx, (%rax,%rdx,4)
	movl	-96(%rbp), %eax
	subl	$2, %eax
	movl	%eax, -92(%rbp)
	jmp	.L10
.L11:
	movq	-80(%rbp), %rax
	movl	-92(%rbp), %edx
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %ecx
	movl	-92(%rbp), %eax
	leal	2(%rax), %edx
	movq	-80(%rbp), %rax
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %edx
	movl	%ecx, %eax
	subl	%edx, %eax
	movl	%eax, %edx
	negl	%edx
	cmovns	%edx, %eax
	movl	%eax, %ecx
	movl	-92(%rbp), %eax
	leal	2(%rax), %edx
	movq	-64(%rbp), %rax
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %eax
	leal	(%rcx,%rax), %edx
	movq	-80(%rbp), %rax
	movl	-92(%rbp), %ecx
	movslq	%ecx, %rcx
	movl	(%rax,%rcx,4), %esi
	movl	-92(%rbp), %eax
	leal	1(%rax), %ecx
	movq	-80(%rbp), %rax
	movslq	%ecx, %rcx
	movl	(%rax,%rcx,4), %ecx
	movl	%esi, %eax
	subl	%ecx, %eax
	movl	%eax, %ecx
	negl	%ecx
	cmovns	%ecx, %eax
	movl	%eax, %esi
	movl	-92(%rbp), %eax
	leal	1(%rax), %ecx
	movq	-64(%rbp), %rax
	movslq	%ecx, %rcx
	movl	(%rax,%rcx,4), %eax
	addl	%esi, %eax
	cmpl	%eax, %edx
	cmovle	%edx, %eax
	movl	%eax, %ecx
	movq	-64(%rbp), %rax
	movl	-92(%rbp), %edx
	movslq	%edx, %rdx
	movl	%ecx, (%rax,%rdx,4)
	subl	$1, -92(%rbp)
.L10:
	cmpl	$0, -92(%rbp)
	jns	.L11
	movq	-64(%rbp), %rax
	movl	(%rax), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	%rbx, %rsp
	movq	-56(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L13
	call	__stack_chk_fail@PLT
.L13:
	leaq	-40(%rbp), %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.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:
