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>

int N, a[2001], dp[2][2001][2001];

int recursion_X(int y, int k)
{
	if (dp[0][y][k] >= 0) return dp[0][y][k];
	else dp[0][y][k] = abs(a[N] - a[y]);
	
	int i, tmp;
	for (i = k; i <= N - 1; i++) {
		tmp = recursion_Y(i, i + 1);
		if (tmp > dp[0][y][k]) dp[0][y][k] = tmp;
	}
	return dp[0][y][k];
}

int recursion_Y(int x, int k)
{
	if (dp[1][x][k] >= 0) return dp[1][x][k];
	else dp[1][x][k] = abs(a[N] - a[x]);
	
	int i, tmp;
	for (i = k; i <= N - 1; i++) {
		tmp = recursion_X(i, i + 1);
		if (tmp < dp[1][x][k]) dp[1][x][k] = tmp;
	}
	return dp[1][x][k];
}

int main()
{
	int i, j;
	scanf("%d %d %d", &N, &i, &(a[0]));
	for (i = 1; i <= N; i++) scanf("%d", &(a[i]));
	for (i = 0; i <= N; i++) {
		for (j = 1; j <= N; j++) {
			dp[0][i][j] = -1;
			dp[1][i][j] = -1;
		}
	}
	printf("%d\n", recursion_X(0, 1));
	fflush(stdout);
	return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	N
	.bss
	.align 4
	.type	N, @object
	.size	N, 4
N:
	.zero	4
	.globl	a
	.align 32
	.type	a, @object
	.size	a, 8004
a:
	.zero	8004
	.globl	dp
	.align 32
	.type	dp, @object
	.size	dp, 32032008
dp:
	.zero	32032008
	.text
	.globl	recursion_X
	.type	recursion_X, @function
recursion_X:
.LFB6:
	.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	%esi, -24(%rbp)
	movl	-24(%rbp), %eax
	movslq	%eax, %rdx
	movl	-20(%rbp), %eax
	cltq
	imulq	$2001, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	dp(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	js	.L2
	movl	-24(%rbp), %eax
	movslq	%eax, %rdx
	movl	-20(%rbp), %eax
	cltq
	imulq	$2001, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	dp(%rip), %rax
	movl	(%rdx,%rax), %eax
	jmp	.L3
.L2:
	movl	N(%rip), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-20(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	a(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	subl	%edx, %eax
	movl	%eax, %edx
	negl	%edx
	cmovns	%edx, %eax
	movl	-24(%rbp), %edx
	movslq	%edx, %rcx
	movl	-20(%rbp), %edx
	movslq	%edx, %rdx
	imulq	$2001, %rdx, %rdx
	addq	%rcx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	dp(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movl	-24(%rbp), %eax
	movl	%eax, -8(%rbp)
	jmp	.L4
.L6:
	movl	-8(%rbp), %eax
	leal	1(%rax), %edx
	movl	-8(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	movl	$0, %eax
	call	recursion_Y
	movl	%eax, -4(%rbp)
	movl	-24(%rbp), %eax
	movslq	%eax, %rdx
	movl	-20(%rbp), %eax
	cltq
	imulq	$2001, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	dp(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -4(%rbp)
	jle	.L5
	movl	-24(%rbp), %eax
	movslq	%eax, %rdx
	movl	-20(%rbp), %eax
	cltq
	imulq	$2001, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rcx
	leaq	dp(%rip), %rdx
	movl	-4(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
.L5:
	addl	$1, -8(%rbp)
.L4:
	movl	N(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jl	.L6
	movl	-24(%rbp), %eax
	movslq	%eax, %rdx
	movl	-20(%rbp), %eax
	cltq
	imulq	$2001, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	dp(%rip), %rax
	movl	(%rdx,%rax), %eax
.L3:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	recursion_X, .-recursion_X
	.globl	recursion_Y
	.type	recursion_Y, @function
recursion_Y:
.LFB7:
	.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	%esi, -24(%rbp)
	movl	-24(%rbp), %eax
	movslq	%eax, %rdx
	movl	-20(%rbp), %eax
	cltq
	imulq	$2001, %rax, %rax
	addq	%rdx, %rax
	addq	$4004001, %rax
	leaq	0(,%rax,4), %rdx
	leaq	dp(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	js	.L8
	movl	-24(%rbp), %eax
	movslq	%eax, %rdx
	movl	-20(%rbp), %eax
	cltq
	imulq	$2001, %rax, %rax
	addq	%rdx, %rax
	addq	$4004001, %rax
	leaq	0(,%rax,4), %rdx
	leaq	dp(%rip), %rax
	movl	(%rdx,%rax), %eax
	jmp	.L9
.L8:
	movl	N(%rip), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-20(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	a(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	subl	%edx, %eax
	movl	%eax, %edx
	negl	%edx
	cmovns	%edx, %eax
	movl	-24(%rbp), %edx
	movslq	%edx, %rcx
	movl	-20(%rbp), %edx
	movslq	%edx, %rdx
	imulq	$2001, %rdx, %rdx
	addq	%rcx, %rdx
	addq	$4004001, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	dp(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movl	-24(%rbp), %eax
	movl	%eax, -8(%rbp)
	jmp	.L10
.L12:
	movl	-8(%rbp), %eax
	leal	1(%rax), %edx
	movl	-8(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	recursion_X
	movl	%eax, -4(%rbp)
	movl	-24(%rbp), %eax
	movslq	%eax, %rdx
	movl	-20(%rbp), %eax
	cltq
	imulq	$2001, %rax, %rax
	addq	%rdx, %rax
	addq	$4004001, %rax
	leaq	0(,%rax,4), %rdx
	leaq	dp(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -4(%rbp)
	jge	.L11
	movl	-24(%rbp), %eax
	movslq	%eax, %rdx
	movl	-20(%rbp), %eax
	cltq
	imulq	$2001, %rax, %rax
	addq	%rdx, %rax
	addq	$4004001, %rax
	leaq	0(,%rax,4), %rcx
	leaq	dp(%rip), %rdx
	movl	-4(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
.L11:
	addl	$1, -8(%rbp)
.L10:
	movl	N(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jl	.L12
	movl	-24(%rbp), %eax
	movslq	%eax, %rdx
	movl	-20(%rbp), %eax
	cltq
	imulq	$2001, %rax, %rax
	addq	%rdx, %rax
	addq	$4004001, %rax
	leaq	0(,%rax,4), %rdx
	leaq	dp(%rip), %rax
	movl	(%rdx,%rax), %eax
.L9:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	recursion_Y, .-recursion_Y
	.section	.rodata
.LC0:
	.string	"%d %d %d"
.LC1:
	.string	"%d"
.LC2:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB8:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$16, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-16(%rbp), %rax
	leaq	a(%rip), %rdx
	movq	%rdx, %rcx
	movq	%rax, %rdx
	leaq	N(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$1, -16(%rbp)
	jmp	.L14
.L15:
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-16(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -16(%rbp)
.L14:
	movl	-16(%rbp), %edx
	movl	N(%rip), %eax
	cmpl	%eax, %edx
	jle	.L15
	movl	$0, -16(%rbp)
	jmp	.L16
.L19:
	movl	$1, -12(%rbp)
	jmp	.L17
.L18:
	movl	-16(%rbp), %eax
	movl	-12(%rbp), %edx
	movslq	%edx, %rdx
	cltq
	imulq	$2001, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	dp(%rip), %rax
	movl	$-1, (%rdx,%rax)
	movl	-16(%rbp), %eax
	movl	-12(%rbp), %edx
	movslq	%edx, %rdx
	cltq
	imulq	$2001, %rax, %rax
	addq	%rdx, %rax
	addq	$4004001, %rax
	leaq	0(,%rax,4), %rdx
	leaq	dp(%rip), %rax
	movl	$-1, (%rdx,%rax)
	addl	$1, -12(%rbp)
.L17:
	movl	N(%rip), %eax
	cmpl	%eax, -12(%rbp)
	jle	.L18
	movl	-16(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -16(%rbp)
.L16:
	movl	-16(%rbp), %edx
	movl	N(%rip), %eax
	cmpl	%eax, %edx
	jle	.L19
	movl	$1, %esi
	movl	$0, %edi
	call	recursion_X
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movq	stdout(%rip), %rax
	movq	%rax, %rdi
	call	fflush@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L21
	call	__stack_chk_fail@PLT
.L21:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.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
	.type	recursion_Y.part.0, @function
recursion_Y.part.0:
.LFB42:
	.cfi_startproc
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	leaq	a(%rip), %rcx
	movslq	%edi, %rdi
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	leaq	dp(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	subq	$8, %rsp
	.cfi_def_cfa_offset 48
	movslq	N(%rip), %rax
	movq	%rax, %rdx
	movl	(%rcx,%rax,4), %eax
	subl	(%rcx,%rdi,4), %eax
	movl	%eax, %r8d
	negl	%r8d
	cmovs	%eax, %r8d
	imulq	$2001, %rdi, %rdi
	movslq	%esi, %rax
	leaq	4004001(%rdi,%rax), %r13
	movl	%r8d, (%r12,%r13,4)
	cmpl	%esi, %edx
	jle	.L1
	imulq	$8008, %rax, %rax
	movl	%esi, %ebx
	leaq	4(%r12,%rax), %rbp
	.p2align 4,,10
	.p2align 3
.L5:
	movl	0(%rbp), %eax
	movl	%ebx, %edi
	addl	$1, %ebx
	testl	%eax, %eax
	jns	.L3
	movl	%ebx, %esi
	call	recursion_X.part.0
	movl	N(%rip), %edx
	movl	(%r12,%r13,4), %r8d
.L3:
	cmpl	%r8d, %eax
	jge	.L4
	movl	%eax, (%r12,%r13,4)
	movl	%eax, %r8d
.L4:
	addq	$8008, %rbp
	cmpl	%edx, %ebx
	jl	.L5
.L1:
	addq	$8, %rsp
	.cfi_def_cfa_offset 40
	movl	%r8d, %eax
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE42:
	.size	recursion_Y.part.0, .-recursion_Y.part.0
	.p2align 4
	.type	recursion_X.part.0, @function
recursion_X.part.0:
.LFB43:
	.cfi_startproc
	movslq	N(%rip), %rax
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	leaq	a(%rip), %rcx
	movslq	%esi, %r14
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	leaq	dp(%rip), %r13
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	movslq	%edi, %r12
	movq	%rax, %rdx
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	movl	(%rcx,%rax,4), %eax
	subl	(%rcx,%r12,4), %eax
	movl	%eax, %r8d
	negl	%r8d
	cmovs	%eax, %r8d
	imulq	$2001, %r12, %r12
	leaq	(%r12,%r14), %rax
	movl	%r8d, 0(%r13,%rax,4)
	cmpl	%r14d, %edx
	jle	.L9
	imulq	$8008, %r14, %rax
	movq	%r14, %rbx
	leaq	16016008(%r13,%rax), %rbp
	.p2align 4,,10
	.p2align 3
.L13:
	movl	0(%rbp), %eax
	movl	%ebx, %edi
	addl	$1, %ebx
	testl	%eax, %eax
	jns	.L11
	movl	%ebx, %esi
	call	recursion_Y.part.0
	leaq	(%r12,%r14), %rcx
	movl	N(%rip), %edx
	movl	0(%r13,%rcx,4), %r8d
.L11:
	cmpl	%r8d, %eax
	jle	.L12
	leaq	(%r12,%r14), %rcx
	movl	%eax, %r8d
	movl	%eax, 0(%r13,%rcx,4)
.L12:
	addq	$8008, %rbp
	cmpl	%edx, %ebx
	jl	.L13
.L9:
	popq	%rbx
	.cfi_def_cfa_offset 40
	movl	%r8d, %eax
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE43:
	.size	recursion_X.part.0, .-recursion_X.part.0
	.p2align 4
	.globl	recursion_X
	.type	recursion_X, @function
recursion_X:
.LFB39:
	.cfi_startproc
	endbr64
	movslq	%edi, %rax
	movslq	%esi, %rdx
	imulq	$2001, %rax, %rax
	addq	%rdx, %rax
	leaq	dp(%rip), %rdx
	movl	(%rdx,%rax,4), %eax
	testl	%eax, %eax
	jns	.L16
	jmp	recursion_X.part.0
	.p2align 4,,10
	.p2align 3
.L16:
	ret
	.cfi_endproc
.LFE39:
	.size	recursion_X, .-recursion_X
	.p2align 4
	.globl	recursion_Y
	.type	recursion_Y, @function
recursion_Y:
.LFB40:
	.cfi_startproc
	endbr64
	movslq	%edi, %rax
	movslq	%esi, %rdx
	imulq	$2001, %rax, %rax
	leaq	4004001(%rdx,%rax), %rdx
	leaq	dp(%rip), %rax
	movl	(%rax,%rdx,4), %eax
	testl	%eax, %eax
	jns	.L18
	jmp	recursion_Y.part.0
	.p2align 4,,10
	.p2align 3
.L18:
	ret
	.cfi_endproc
.LFE40:
	.size	recursion_Y, .-recursion_Y
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d %d %d"
.LC1:
	.string	"%d"
.LC2:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB41:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	leaq	N(%rip), %rsi
	leaq	.LC0(%rip), %rdi
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	leaq	a(%rip), %rbx
	movq	%rbx, %rcx
	subq	$24, %rsp
	.cfi_def_cfa_offset 64
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	leaq	4(%rsp), %rdx
	call	__isoc99_scanf@PLT
	movl	N(%rip), %ebp
	movl	$1, 4(%rsp)
	testl	%ebp, %ebp
	jle	.L21
	movl	$1, %eax
	leaq	.LC1(%rip), %r12
	.p2align 4,,10
	.p2align 3
.L22:
	cltq
	movq	%r12, %rdi
	leaq	(%rbx,%rax,4), %rsi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	4(%rsp), %eax
	movl	N(%rip), %ebp
	addl	$1, %eax
	movl	%eax, 4(%rsp)
	cmpl	%ebp, %eax
	jle	.L22
.L21:
	movl	$0, 4(%rsp)
	testl	%ebp, %ebp
	js	.L23
	movslq	%ebp, %r13
	leaq	4+dp(%rip), %rbx
	imulq	$8004, %r13, %r13
	leaq	8004(%rbx), %rax
	addq	%rax, %r13
	leal	-1(%rbp), %eax
	leaq	4(,%rax,4), %r12
	.p2align 4,,10
	.p2align 3
.L24:
	testl	%ebp, %ebp
	je	.L27
	movq	%r12, %rdx
	movl	$255, %esi
	movq	%rbx, %rdi
	call	memset@PLT
	leaq	16016004(%rbx), %rdi
	movq	%r12, %rdx
	movl	$255, %esi
	call	memset@PLT
.L27:
	addq	$8004, %rbx
	cmpq	%r13, %rbx
	jne	.L24
	addl	$1, %ebp
	movl	%ebp, 4(%rsp)
.L23:
	movl	4+dp(%rip), %edx
	testl	%edx, %edx
	jns	.L28
	movl	$1, %esi
	xorl	%edi, %edi
	call	recursion_X.part.0
	movl	%eax, %edx
.L28:
	movl	$1, %edi
	xorl	%eax, %eax
	leaq	.LC2(%rip), %rsi
	call	__printf_chk@PLT
	movq	stdout(%rip), %rdi
	call	fflush@PLT
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L32
	addq	$24, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
.L32:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE41:
	.size	main, .-main
	.globl	dp
	.bss
	.align 32
	.type	dp, @object
	.size	dp, 32032008
dp:
	.zero	32032008
	.globl	a
	.align 32
	.type	a, @object
	.size	a, 8004
a:
	.zero	8004
	.globl	N
	.align 4
	.type	N, @object
	.size	N, 4
N:
	.zero	4
	.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
	.type	recursion_Y.part.0, @function
recursion_Y.part.0:
.LFB42:
	.cfi_startproc
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	leaq	a(%rip), %rcx
	movslq	%edi, %rdi
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	leaq	dp(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	subq	$8, %rsp
	.cfi_def_cfa_offset 48
	movslq	N(%rip), %rax
	movq	%rax, %rdx
	movl	(%rcx,%rax,4), %eax
	subl	(%rcx,%rdi,4), %eax
	movl	%eax, %r8d
	negl	%r8d
	cmovs	%eax, %r8d
	imulq	$2001, %rdi, %rdi
	movslq	%esi, %rax
	leaq	4004001(%rdi,%rax), %r13
	movl	%r8d, (%r12,%r13,4)
	cmpl	%esi, %edx
	jle	.L1
	imulq	$8008, %rax, %rax
	movl	%esi, %ebx
	leaq	4(%r12,%rax), %rbp
	.p2align 4,,10
	.p2align 3
.L5:
	movl	0(%rbp), %eax
	movl	%ebx, %edi
	addl	$1, %ebx
	testl	%eax, %eax
	jns	.L3
	movl	%ebx, %esi
	call	recursion_X.part.0
	movl	N(%rip), %edx
	movl	(%r12,%r13,4), %r8d
.L3:
	cmpl	%r8d, %eax
	jge	.L4
	movl	%eax, (%r12,%r13,4)
	movl	%eax, %r8d
.L4:
	addq	$8008, %rbp
	cmpl	%edx, %ebx
	jl	.L5
.L1:
	addq	$8, %rsp
	.cfi_def_cfa_offset 40
	movl	%r8d, %eax
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE42:
	.size	recursion_Y.part.0, .-recursion_Y.part.0
	.p2align 4
	.type	recursion_X.part.0, @function
recursion_X.part.0:
.LFB43:
	.cfi_startproc
	movslq	N(%rip), %rax
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	leaq	a(%rip), %rcx
	movslq	%esi, %r14
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	leaq	dp(%rip), %r13
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	movslq	%edi, %r12
	movq	%rax, %rdx
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	movl	(%rcx,%rax,4), %eax
	subl	(%rcx,%r12,4), %eax
	movl	%eax, %r8d
	negl	%r8d
	cmovs	%eax, %r8d
	imulq	$2001, %r12, %r12
	leaq	(%r12,%r14), %rax
	movl	%r8d, 0(%r13,%rax,4)
	cmpl	%r14d, %edx
	jle	.L9
	imulq	$8008, %r14, %rax
	movq	%r14, %rbx
	leaq	16016008(%r13,%rax), %rbp
	.p2align 4,,10
	.p2align 3
.L13:
	movl	0(%rbp), %eax
	movl	%ebx, %edi
	addl	$1, %ebx
	testl	%eax, %eax
	jns	.L11
	movl	%ebx, %esi
	call	recursion_Y.part.0
	leaq	(%r12,%r14), %rcx
	movl	N(%rip), %edx
	movl	0(%r13,%rcx,4), %r8d
.L11:
	cmpl	%r8d, %eax
	jle	.L12
	leaq	(%r12,%r14), %rcx
	movl	%eax, %r8d
	movl	%eax, 0(%r13,%rcx,4)
.L12:
	addq	$8008, %rbp
	cmpl	%edx, %ebx
	jl	.L13
.L9:
	popq	%rbx
	.cfi_def_cfa_offset 40
	movl	%r8d, %eax
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE43:
	.size	recursion_X.part.0, .-recursion_X.part.0
	.p2align 4
	.globl	recursion_X
	.type	recursion_X, @function
recursion_X:
.LFB39:
	.cfi_startproc
	endbr64
	movslq	%edi, %rax
	movslq	%esi, %rdx
	imulq	$2001, %rax, %rax
	addq	%rdx, %rax
	leaq	dp(%rip), %rdx
	movl	(%rdx,%rax,4), %eax
	testl	%eax, %eax
	jns	.L16
	jmp	recursion_X.part.0
	.p2align 4,,10
	.p2align 3
.L16:
	ret
	.cfi_endproc
.LFE39:
	.size	recursion_X, .-recursion_X
	.p2align 4
	.globl	recursion_Y
	.type	recursion_Y, @function
recursion_Y:
.LFB40:
	.cfi_startproc
	endbr64
	movslq	%edi, %rax
	movslq	%esi, %rdx
	imulq	$2001, %rax, %rax
	leaq	4004001(%rdx,%rax), %rdx
	leaq	dp(%rip), %rax
	movl	(%rax,%rdx,4), %eax
	testl	%eax, %eax
	jns	.L18
	jmp	recursion_Y.part.0
	.p2align 4,,10
	.p2align 3
.L18:
	ret
	.cfi_endproc
.LFE40:
	.size	recursion_Y, .-recursion_Y
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d %d %d"
.LC1:
	.string	"%d"
.LC2:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB41:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	leaq	N(%rip), %rsi
	leaq	.LC0(%rip), %rdi
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	leaq	a(%rip), %rbx
	movq	%rbx, %rcx
	subq	$24, %rsp
	.cfi_def_cfa_offset 64
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	leaq	4(%rsp), %rdx
	call	__isoc99_scanf@PLT
	movl	N(%rip), %ebp
	movl	$1, 4(%rsp)
	testl	%ebp, %ebp
	jle	.L21
	movl	$1, %eax
	leaq	.LC1(%rip), %r12
	.p2align 4,,10
	.p2align 3
.L22:
	cltq
	movq	%r12, %rdi
	leaq	(%rbx,%rax,4), %rsi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	4(%rsp), %eax
	movl	N(%rip), %ebp
	addl	$1, %eax
	movl	%eax, 4(%rsp)
	cmpl	%ebp, %eax
	jle	.L22
.L21:
	movl	$0, 4(%rsp)
	testl	%ebp, %ebp
	js	.L23
	movslq	%ebp, %r13
	leaq	4+dp(%rip), %rbx
	imulq	$8004, %r13, %r13
	leaq	8004(%rbx), %rax
	addq	%rax, %r13
	leal	-1(%rbp), %eax
	leaq	4(,%rax,4), %r12
	.p2align 4,,10
	.p2align 3
.L24:
	testl	%ebp, %ebp
	je	.L27
	movq	%r12, %rdx
	movl	$255, %esi
	movq	%rbx, %rdi
	call	memset@PLT
	leaq	16016004(%rbx), %rdi
	movq	%r12, %rdx
	movl	$255, %esi
	call	memset@PLT
.L27:
	addq	$8004, %rbx
	cmpq	%r13, %rbx
	jne	.L24
	addl	$1, %ebp
	movl	%ebp, 4(%rsp)
.L23:
	movl	4+dp(%rip), %edx
	testl	%edx, %edx
	jns	.L28
	movl	$1, %esi
	xorl	%edi, %edi
	call	recursion_X.part.0
	movl	%eax, %edx
.L28:
	movl	$1, %edi
	xorl	%eax, %eax
	leaq	.LC2(%rip), %rsi
	call	__printf_chk@PLT
	movq	stdout(%rip), %rdi
	call	fflush@PLT
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L32
	addq	$24, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
.L32:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE41:
	.size	main, .-main
	.globl	dp
	.bss
	.align 32
	.type	dp, @object
	.size	dp, 32032008
dp:
	.zero	32032008
	.globl	a
	.align 32
	.type	a, @object
	.size	a, 8004
a:
	.zero	8004
	.globl	N
	.align 4
	.type	N, @object
	.size	N, 4
N:
	.zero	4
	.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>

int N, a[2001], dp[2][2001][2001];

int recursion_X(int y, int k)
{
	if (dp[0][y][k] >= 0) return dp[0][y][k];
	else dp[0][y][k] = abs(a[N] - a[y]);
	
	int i, tmp;
	for (i = k; i <= N - 1; i++) {
		tmp = recursion_Y(i, i + 1);
		if (tmp > dp[0][y][k]) dp[0][y][k] = tmp;
	}
	return dp[0][y][k];
}

int recursion_Y(int x, int k)
{
	if (dp[1][x][k] >= 0) return dp[1][x][k];
	else dp[1][x][k] = abs(a[N] - a[x]);
	
	int i, tmp;
	for (i = k; i <= N - 1; i++) {
		tmp = recursion_X(i, i + 1);
		if (tmp < dp[1][x][k]) dp[1][x][k] = tmp;
	}
	return dp[1][x][k];
}

int main()
{
	int i, j;
	scanf("%d %d %d", &N, &i, &(a[0]));
	for (i = 1; i <= N; i++) scanf("%d", &(a[i]));
	for (i = 0; i <= N; i++) {
		for (j = 1; j <= N; j++) {
			dp[0][i][j] = -1;
			dp[1][i][j] = -1;
		}
	}
	printf("%d\n", recursion_X(0, 1));
	fflush(stdout);
	return 0;
}
3 100 100
10 1000 100

900

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>

int N, a[2001], dp[2][2001][2001];

int recursion_X(int y, int k)
{
	if (dp[0][y][k] >= 0) return dp[0][y][k];
	else dp[0][y][k] = abs(a[N] - a[y]);
	
	int i, tmp;
	for (i = k; i <= N - 1; i++) {
		tmp = recursion_Y(i, i + 1);
		if (tmp > dp[0][y][k]) dp[0][y][k] = tmp;
	}
	return dp[0][y][k];
}

int recursion_Y(int x, int k)
{
	if (dp[1][x][k] >= 0) return dp[1][x][k];
	else dp[1][x][k] = abs(a[N] - a[x]);
	
	int i, tmp;
	for (i = k; i <= N - 1; i++) {
		tmp = recursion_X(i, i + 1);
		if (tmp < dp[1][x][k]) dp[1][x][k] = tmp;
	}
	return dp[1][x][k];
}

int main()
{
	int i, j;
	scanf("%d %d %d", &N, &i, &(a[0]));
	for (i = 1; i <= N; i++) scanf("%d", &(a[i]));
	for (i = 0; i <= N; i++) {
		for (j = 1; j <= N; j++) {
			dp[0][i][j] = -1;
			dp[1][i][j] = -1;
		}
	}
	printf("%d\n", recursion_X(0, 1));
	fflush(stdout);
	return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	N
	.bss
	.align 4
	.type	N, @object
	.size	N, 4
N:
	.zero	4
	.globl	a
	.align 32
	.type	a, @object
	.size	a, 8004
a:
	.zero	8004
	.globl	dp
	.align 32
	.type	dp, @object
	.size	dp, 32032008
dp:
	.zero	32032008
	.text
	.globl	recursion_X
	.type	recursion_X, @function
recursion_X:
.LFB6:
	.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	%esi, -24(%rbp)
	movl	-24(%rbp), %eax
	movslq	%eax, %rdx
	movl	-20(%rbp), %eax
	cltq
	imulq	$2001, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	dp(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	js	.L2
	movl	-24(%rbp), %eax
	movslq	%eax, %rdx
	movl	-20(%rbp), %eax
	cltq
	imulq	$2001, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	dp(%rip), %rax
	movl	(%rdx,%rax), %eax
	jmp	.L3
.L2:
	movl	N(%rip), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-20(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	a(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	subl	%edx, %eax
	movl	%eax, %edx
	negl	%edx
	cmovns	%edx, %eax
	movl	-24(%rbp), %edx
	movslq	%edx, %rcx
	movl	-20(%rbp), %edx
	movslq	%edx, %rdx
	imulq	$2001, %rdx, %rdx
	addq	%rcx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	dp(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movl	-24(%rbp), %eax
	movl	%eax, -8(%rbp)
	jmp	.L4
.L6:
	movl	-8(%rbp), %eax
	leal	1(%rax), %edx
	movl	-8(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	movl	$0, %eax
	call	recursion_Y
	movl	%eax, -4(%rbp)
	movl	-24(%rbp), %eax
	movslq	%eax, %rdx
	movl	-20(%rbp), %eax
	cltq
	imulq	$2001, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	dp(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -4(%rbp)
	jle	.L5
	movl	-24(%rbp), %eax
	movslq	%eax, %rdx
	movl	-20(%rbp), %eax
	cltq
	imulq	$2001, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rcx
	leaq	dp(%rip), %rdx
	movl	-4(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
.L5:
	addl	$1, -8(%rbp)
.L4:
	movl	N(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jl	.L6
	movl	-24(%rbp), %eax
	movslq	%eax, %rdx
	movl	-20(%rbp), %eax
	cltq
	imulq	$2001, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	dp(%rip), %rax
	movl	(%rdx,%rax), %eax
.L3:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	recursion_X, .-recursion_X
	.globl	recursion_Y
	.type	recursion_Y, @function
recursion_Y:
.LFB7:
	.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	%esi, -24(%rbp)
	movl	-24(%rbp), %eax
	movslq	%eax, %rdx
	movl	-20(%rbp), %eax
	cltq
	imulq	$2001, %rax, %rax
	addq	%rdx, %rax
	addq	$4004001, %rax
	leaq	0(,%rax,4), %rdx
	leaq	dp(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	js	.L8
	movl	-24(%rbp), %eax
	movslq	%eax, %rdx
	movl	-20(%rbp), %eax
	cltq
	imulq	$2001, %rax, %rax
	addq	%rdx, %rax
	addq	$4004001, %rax
	leaq	0(,%rax,4), %rdx
	leaq	dp(%rip), %rax
	movl	(%rdx,%rax), %eax
	jmp	.L9
.L8:
	movl	N(%rip), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-20(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	a(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	subl	%edx, %eax
	movl	%eax, %edx
	negl	%edx
	cmovns	%edx, %eax
	movl	-24(%rbp), %edx
	movslq	%edx, %rcx
	movl	-20(%rbp), %edx
	movslq	%edx, %rdx
	imulq	$2001, %rdx, %rdx
	addq	%rcx, %rdx
	addq	$4004001, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	dp(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movl	-24(%rbp), %eax
	movl	%eax, -8(%rbp)
	jmp	.L10
.L12:
	movl	-8(%rbp), %eax
	leal	1(%rax), %edx
	movl	-8(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	recursion_X
	movl	%eax, -4(%rbp)
	movl	-24(%rbp), %eax
	movslq	%eax, %rdx
	movl	-20(%rbp), %eax
	cltq
	imulq	$2001, %rax, %rax
	addq	%rdx, %rax
	addq	$4004001, %rax
	leaq	0(,%rax,4), %rdx
	leaq	dp(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -4(%rbp)
	jge	.L11
	movl	-24(%rbp), %eax
	movslq	%eax, %rdx
	movl	-20(%rbp), %eax
	cltq
	imulq	$2001, %rax, %rax
	addq	%rdx, %rax
	addq	$4004001, %rax
	leaq	0(,%rax,4), %rcx
	leaq	dp(%rip), %rdx
	movl	-4(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
.L11:
	addl	$1, -8(%rbp)
.L10:
	movl	N(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jl	.L12
	movl	-24(%rbp), %eax
	movslq	%eax, %rdx
	movl	-20(%rbp), %eax
	cltq
	imulq	$2001, %rax, %rax
	addq	%rdx, %rax
	addq	$4004001, %rax
	leaq	0(,%rax,4), %rdx
	leaq	dp(%rip), %rax
	movl	(%rdx,%rax), %eax
.L9:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	recursion_Y, .-recursion_Y
	.section	.rodata
.LC0:
	.string	"%d %d %d"
.LC1:
	.string	"%d"
.LC2:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB8:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$16, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-16(%rbp), %rax
	leaq	a(%rip), %rdx
	movq	%rdx, %rcx
	movq	%rax, %rdx
	leaq	N(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$1, -16(%rbp)
	jmp	.L14
.L15:
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-16(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -16(%rbp)
.L14:
	movl	-16(%rbp), %edx
	movl	N(%rip), %eax
	cmpl	%eax, %edx
	jle	.L15
	movl	$0, -16(%rbp)
	jmp	.L16
.L19:
	movl	$1, -12(%rbp)
	jmp	.L17
.L18:
	movl	-16(%rbp), %eax
	movl	-12(%rbp), %edx
	movslq	%edx, %rdx
	cltq
	imulq	$2001, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	dp(%rip), %rax
	movl	$-1, (%rdx,%rax)
	movl	-16(%rbp), %eax
	movl	-12(%rbp), %edx
	movslq	%edx, %rdx
	cltq
	imulq	$2001, %rax, %rax
	addq	%rdx, %rax
	addq	$4004001, %rax
	leaq	0(,%rax,4), %rdx
	leaq	dp(%rip), %rax
	movl	$-1, (%rdx,%rax)
	addl	$1, -12(%rbp)
.L17:
	movl	N(%rip), %eax
	cmpl	%eax, -12(%rbp)
	jle	.L18
	movl	-16(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -16(%rbp)
.L16:
	movl	-16(%rbp), %edx
	movl	N(%rip), %eax
	cmpl	%eax, %edx
	jle	.L19
	movl	$1, %esi
	movl	$0, %edi
	call	recursion_X
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movq	stdout(%rip), %rax
	movq	%rax, %rdi
	call	fflush@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L21
	call	__stack_chk_fail@PLT
.L21:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.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	N
	.bss
	.align 4
	.type	N, @object
	.size	N, 4
N:
	.zero	4
	.globl	a
	.align 32
	.type	a, @object
	.size	a, 8004
a:
	.zero	8004
	.globl	dp
	.align 32
	.type	dp, @object
	.size	dp, 32032008
dp:
	.zero	32032008
	.text
	.globl	recursion_X
	.type	recursion_X, @function
recursion_X:
.LFB6:
	.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	%esi, -24(%rbp)
	movl	-24(%rbp), %eax
	movslq	%eax, %rdx
	movl	-20(%rbp), %eax
	cltq
	imulq	$2001, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	dp(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	js	.L2
	movl	-24(%rbp), %eax
	movslq	%eax, %rdx
	movl	-20(%rbp), %eax
	cltq
	imulq	$2001, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	dp(%rip), %rax
	movl	(%rdx,%rax), %eax
	jmp	.L3
.L2:
	movl	N(%rip), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-20(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	a(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	subl	%edx, %eax
	movl	%eax, %edx
	negl	%edx
	cmovns	%edx, %eax
	movl	-24(%rbp), %edx
	movslq	%edx, %rcx
	movl	-20(%rbp), %edx
	movslq	%edx, %rdx
	imulq	$2001, %rdx, %rdx
	addq	%rcx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	dp(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movl	-24(%rbp), %eax
	movl	%eax, -8(%rbp)
	jmp	.L4
.L6:
	movl	-8(%rbp), %eax
	leal	1(%rax), %edx
	movl	-8(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	movl	$0, %eax
	call	recursion_Y
	movl	%eax, -4(%rbp)
	movl	-24(%rbp), %eax
	movslq	%eax, %rdx
	movl	-20(%rbp), %eax
	cltq
	imulq	$2001, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	dp(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -4(%rbp)
	jle	.L5
	movl	-24(%rbp), %eax
	movslq	%eax, %rdx
	movl	-20(%rbp), %eax
	cltq
	imulq	$2001, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rcx
	leaq	dp(%rip), %rdx
	movl	-4(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
.L5:
	addl	$1, -8(%rbp)
.L4:
	movl	N(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jl	.L6
	movl	-24(%rbp), %eax
	movslq	%eax, %rdx
	movl	-20(%rbp), %eax
	cltq
	imulq	$2001, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	dp(%rip), %rax
	movl	(%rdx,%rax), %eax
.L3:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	recursion_X, .-recursion_X
	.globl	recursion_Y
	.type	recursion_Y, @function
recursion_Y:
.LFB7:
	.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	%esi, -24(%rbp)
	movl	-24(%rbp), %eax
	movslq	%eax, %rdx
	movl	-20(%rbp), %eax
	cltq
	imulq	$2001, %rax, %rax
	addq	%rdx, %rax
	addq	$4004001, %rax
	leaq	0(,%rax,4), %rdx
	leaq	dp(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	js	.L8
	movl	-24(%rbp), %eax
	movslq	%eax, %rdx
	movl	-20(%rbp), %eax
	cltq
	imulq	$2001, %rax, %rax
	addq	%rdx, %rax
	addq	$4004001, %rax
	leaq	0(,%rax,4), %rdx
	leaq	dp(%rip), %rax
	movl	(%rdx,%rax), %eax
	jmp	.L9
.L8:
	movl	N(%rip), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-20(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	a(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	subl	%edx, %eax
	movl	%eax, %edx
	negl	%edx
	cmovns	%edx, %eax
	movl	-24(%rbp), %edx
	movslq	%edx, %rcx
	movl	-20(%rbp), %edx
	movslq	%edx, %rdx
	imulq	$2001, %rdx, %rdx
	addq	%rcx, %rdx
	addq	$4004001, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	dp(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movl	-24(%rbp), %eax
	movl	%eax, -8(%rbp)
	jmp	.L10
.L12:
	movl	-8(%rbp), %eax
	leal	1(%rax), %edx
	movl	-8(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	recursion_X
	movl	%eax, -4(%rbp)
	movl	-24(%rbp), %eax
	movslq	%eax, %rdx
	movl	-20(%rbp), %eax
	cltq
	imulq	$2001, %rax, %rax
	addq	%rdx, %rax
	addq	$4004001, %rax
	leaq	0(,%rax,4), %rdx
	leaq	dp(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -4(%rbp)
	jge	.L11
	movl	-24(%rbp), %eax
	movslq	%eax, %rdx
	movl	-20(%rbp), %eax
	cltq
	imulq	$2001, %rax, %rax
	addq	%rdx, %rax
	addq	$4004001, %rax
	leaq	0(,%rax,4), %rcx
	leaq	dp(%rip), %rdx
	movl	-4(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
.L11:
	addl	$1, -8(%rbp)
.L10:
	movl	N(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jl	.L12
	movl	-24(%rbp), %eax
	movslq	%eax, %rdx
	movl	-20(%rbp), %eax
	cltq
	imulq	$2001, %rax, %rax
	addq	%rdx, %rax
	addq	$4004001, %rax
	leaq	0(,%rax,4), %rdx
	leaq	dp(%rip), %rax
	movl	(%rdx,%rax), %eax
.L9:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	recursion_Y, .-recursion_Y
	.section	.rodata
.LC0:
	.string	"%d %d %d"
.LC1:
	.string	"%d"
.LC2:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB8:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$16, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-16(%rbp), %rax
	leaq	a(%rip), %rdx
	movq	%rdx, %rcx
	movq	%rax, %rdx
	leaq	N(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$1, -16(%rbp)
	jmp	.L14
.L15:
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-16(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -16(%rbp)
.L14:
	movl	-16(%rbp), %edx
	movl	N(%rip), %eax
	cmpl	%eax, %edx
	jle	.L15
	movl	$0, -16(%rbp)
	jmp	.L16
.L19:
	movl	$1, -12(%rbp)
	jmp	.L17
.L18:
	movl	-16(%rbp), %eax
	movl	-12(%rbp), %edx
	movslq	%edx, %rdx
	cltq
	imulq	$2001, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	dp(%rip), %rax
	movl	$-1, (%rdx,%rax)
	movl	-16(%rbp), %eax
	movl	-12(%rbp), %edx
	movslq	%edx, %rdx
	cltq
	imulq	$2001, %rax, %rax
	addq	%rdx, %rax
	addq	$4004001, %rax
	leaq	0(,%rax,4), %rdx
	leaq	dp(%rip), %rax
	movl	$-1, (%rdx,%rax)
	addl	$1, -12(%rbp)
.L17:
	movl	N(%rip), %eax
	cmpl	%eax, -12(%rbp)
	jle	.L18
	movl	-16(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -16(%rbp)
.L16:
	movl	-16(%rbp), %edx
	movl	N(%rip), %eax
	cmpl	%eax, %edx
	jle	.L19
	movl	$1, %esi
	movl	$0, %edi
	call	recursion_X
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movq	stdout(%rip), %rax
	movq	%rax, %rdi
	call	fflush@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L21
	call	__stack_chk_fail@PLT
.L21:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.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:
