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

```c
// AOJ 2809: Graduation Ceremony
// 2018.1.4 bal4u@uu

#include <stdio.h>

#define min(a,b) ((a)<=(b)?(a):(b))
#define max(a,b) ((a)>=(b)?(a):(b))

#define MAX 2002

char s[MAX];
short u[MAX], d[MAX], l[MAX], r[MAX];
int dx[4] = { 0,1,0,-1};	// URDL
int dy[4] = {-1,0,1, 0};
int tr['Z'];

int main()
{
	int k, i, j, j2, dir, ans;
	char *p;

	tr['U'] = 0, tr['R'] = 1, tr['D'] = 2, tr['L'] = 3;

	scanf("%s%d", s, &k);
	p = s; while (*p) {
		dir = tr[*p++];
		j2 = j = k; while (j--) {
			u[j2] = min(-d[j], u[j2]) + dy[dir];
			r[j2] = max(-l[j], r[j2]) + dx[dir];
			d[j2] = max(-u[j], d[j2]) + dy[dir];
			l[j2] = min(-r[j], l[j2]) + dx[dir];
			j2--;
		}
		l[0] += dx[dir], r[0] = l[0];
		d[0] += dy[dir], u[0] = d[0];
	}
	ans = 0;
	for (i = 0; i <= k; i++) {
		j  = -l[i];   if (j  < r[i  ]) j  = r[i];
		j2 = -u[k-i]; if (j2 < d[k-i]) j2 = d[k-i];
		j += j2;
		if (j > ans) ans = j;
	}
	printf("%d\n", ans);
	return 0;
}

```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	s
	.bss
	.align 32
	.type	s, @object
	.size	s, 2002
s:
	.zero	2002
	.globl	u
	.align 32
	.type	u, @object
	.size	u, 4004
u:
	.zero	4004
	.globl	d
	.align 32
	.type	d, @object
	.size	d, 4004
d:
	.zero	4004
	.globl	l
	.align 32
	.type	l, @object
	.size	l, 4004
l:
	.zero	4004
	.globl	r
	.align 32
	.type	r, @object
	.size	r, 4004
r:
	.zero	4004
	.globl	dx
	.data
	.align 16
	.type	dx, @object
	.size	dx, 16
dx:
	.long	0
	.long	1
	.long	0
	.long	-1
	.globl	dy
	.align 16
	.type	dy, @object
	.size	dy, 16
dy:
	.long	-1
	.long	0
	.long	1
	.long	0
	.globl	tr
	.bss
	.align 32
	.type	tr, @object
	.size	tr, 360
tr:
	.zero	360
	.section	.rodata
.LC0:
	.string	"%s%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
	subq	$48, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, 340+tr(%rip)
	movl	$1, 328+tr(%rip)
	movl	$2, 272+tr(%rip)
	movl	$3, 304+tr(%rip)
	leaq	-40(%rbp), %rax
	movq	%rax, %rdx
	leaq	s(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	leaq	s(%rip), %rax
	movq	%rax, -16(%rbp)
	jmp	.L2
.L5:
	movq	-16(%rbp), %rax
	leaq	1(%rax), %rdx
	movq	%rdx, -16(%rbp)
	movzbl	(%rax), %eax
	movsbl	%al, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	tr(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -20(%rbp)
	movl	-40(%rbp), %eax
	movl	%eax, -32(%rbp)
	movl	-32(%rbp), %eax
	movl	%eax, -28(%rbp)
	jmp	.L3
.L4:
	movl	-32(%rbp), %eax
	cltq
	leaq	(%rax,%rax), %rdx
	leaq	d(%rip), %rax
	movzwl	(%rdx,%rax), %eax
	cwtl
	negl	%eax
	movl	%eax, %edx
	movl	-28(%rbp), %eax
	cltq
	leaq	(%rax,%rax), %rcx
	leaq	u(%rip), %rax
	movzwl	(%rcx,%rax), %eax
	cwtl
	cmpl	%eax, %edx
	cmovle	%edx, %eax
	movl	%eax, %ecx
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	dy(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%ecx, %eax
	movl	%eax, %ecx
	movl	-28(%rbp), %eax
	cltq
	leaq	(%rax,%rax), %rdx
	leaq	u(%rip), %rax
	movw	%cx, (%rdx,%rax)
	movl	-32(%rbp), %eax
	cltq
	leaq	(%rax,%rax), %rdx
	leaq	l(%rip), %rax
	movzwl	(%rdx,%rax), %eax
	cwtl
	negl	%eax
	movl	%eax, %edx
	movl	-28(%rbp), %eax
	cltq
	leaq	(%rax,%rax), %rcx
	leaq	r(%rip), %rax
	movzwl	(%rcx,%rax), %eax
	cwtl
	cmpl	%eax, %edx
	cmovge	%edx, %eax
	movl	%eax, %ecx
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	dx(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%ecx, %eax
	movl	%eax, %ecx
	movl	-28(%rbp), %eax
	cltq
	leaq	(%rax,%rax), %rdx
	leaq	r(%rip), %rax
	movw	%cx, (%rdx,%rax)
	movl	-32(%rbp), %eax
	cltq
	leaq	(%rax,%rax), %rdx
	leaq	u(%rip), %rax
	movzwl	(%rdx,%rax), %eax
	cwtl
	negl	%eax
	movl	%eax, %edx
	movl	-28(%rbp), %eax
	cltq
	leaq	(%rax,%rax), %rcx
	leaq	d(%rip), %rax
	movzwl	(%rcx,%rax), %eax
	cwtl
	cmpl	%eax, %edx
	cmovge	%edx, %eax
	movl	%eax, %ecx
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	dy(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%ecx, %eax
	movl	%eax, %ecx
	movl	-28(%rbp), %eax
	cltq
	leaq	(%rax,%rax), %rdx
	leaq	d(%rip), %rax
	movw	%cx, (%rdx,%rax)
	movl	-32(%rbp), %eax
	cltq
	leaq	(%rax,%rax), %rdx
	leaq	r(%rip), %rax
	movzwl	(%rdx,%rax), %eax
	cwtl
	negl	%eax
	movl	%eax, %edx
	movl	-28(%rbp), %eax
	cltq
	leaq	(%rax,%rax), %rcx
	leaq	l(%rip), %rax
	movzwl	(%rcx,%rax), %eax
	cwtl
	cmpl	%eax, %edx
	cmovle	%edx, %eax
	movl	%eax, %ecx
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	dx(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%ecx, %eax
	movl	%eax, %ecx
	movl	-28(%rbp), %eax
	cltq
	leaq	(%rax,%rax), %rdx
	leaq	l(%rip), %rax
	movw	%cx, (%rdx,%rax)
	subl	$1, -28(%rbp)
.L3:
	movl	-32(%rbp), %eax
	leal	-1(%rax), %edx
	movl	%edx, -32(%rbp)
	testl	%eax, %eax
	jne	.L4
	movzwl	l(%rip), %eax
	movl	%eax, %ecx
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	dx(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%ecx, %eax
	movw	%ax, l(%rip)
	movzwl	l(%rip), %eax
	movw	%ax, r(%rip)
	movzwl	d(%rip), %eax
	movl	%eax, %ecx
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	dy(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%ecx, %eax
	movw	%ax, d(%rip)
	movzwl	d(%rip), %eax
	movw	%ax, u(%rip)
.L2:
	movq	-16(%rbp), %rax
	movzbl	(%rax), %eax
	testb	%al, %al
	jne	.L5
	movl	$0, -24(%rbp)
	movl	$0, -36(%rbp)
	jmp	.L6
.L10:
	movl	-36(%rbp), %eax
	cltq
	leaq	(%rax,%rax), %rdx
	leaq	l(%rip), %rax
	movzwl	(%rdx,%rax), %eax
	cwtl
	negl	%eax
	movl	%eax, -32(%rbp)
	movl	-36(%rbp), %eax
	cltq
	leaq	(%rax,%rax), %rdx
	leaq	r(%rip), %rax
	movzwl	(%rdx,%rax), %eax
	cwtl
	cmpl	%eax, -32(%rbp)
	jge	.L7
	movl	-36(%rbp), %eax
	cltq
	leaq	(%rax,%rax), %rdx
	leaq	r(%rip), %rax
	movzwl	(%rdx,%rax), %eax
	cwtl
	movl	%eax, -32(%rbp)
.L7:
	movl	-40(%rbp), %eax
	subl	-36(%rbp), %eax
	cltq
	leaq	(%rax,%rax), %rdx
	leaq	u(%rip), %rax
	movzwl	(%rdx,%rax), %eax
	cwtl
	negl	%eax
	movl	%eax, -28(%rbp)
	movl	-40(%rbp), %eax
	subl	-36(%rbp), %eax
	cltq
	leaq	(%rax,%rax), %rdx
	leaq	d(%rip), %rax
	movzwl	(%rdx,%rax), %eax
	cwtl
	cmpl	%eax, -28(%rbp)
	jge	.L8
	movl	-40(%rbp), %eax
	subl	-36(%rbp), %eax
	cltq
	leaq	(%rax,%rax), %rdx
	leaq	d(%rip), %rax
	movzwl	(%rdx,%rax), %eax
	cwtl
	movl	%eax, -28(%rbp)
.L8:
	movl	-28(%rbp), %eax
	addl	%eax, -32(%rbp)
	movl	-32(%rbp), %eax
	cmpl	-24(%rbp), %eax
	jle	.L9
	movl	-32(%rbp), %eax
	movl	%eax, -24(%rbp)
.L9:
	addl	$1, -36(%rbp)
.L6:
	movl	-40(%rbp), %eax
	cmpl	%eax, -36(%rbp)
	jle	.L10
	movl	-24(%rbp), %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	.L12
	call	__stack_chk_fail@PLT
.L12:
	leave
	.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	"%s%d"
.LC1:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	.LC0(%rip), %rdi
	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	s(%rip), %rbx
	movq	%rbx, %rsi
	subq	$104, %rsp
	.cfi_def_cfa_offset 160
	movq	%fs:40, %rax
	movq	%rax, 88(%rsp)
	xorl	%eax, %eax
	leaq	84(%rsp), %rdx
	movl	$0, 340+tr(%rip)
	movl	$1, 328+tr(%rip)
	movl	$2, 272+tr(%rip)
	movl	$3, 304+tr(%rip)
	call	__isoc99_scanf@PLT
	movsbq	s(%rip), %rax
	testb	%al, %al
	je	.L2
	movslq	84(%rsp), %rdx
	leaq	r(%rip), %r12
	leaq	l(%rip), %r14
	movq	%rbx, 8(%rsp)
	leaq	u(%rip), %r10
	leaq	d(%rip), %r13
	leal	-1(%rdx), %ecx
	movl	%edx, 16(%rsp)
	addq	%rdx, %rdx
	movl	%ecx, 44(%rsp)
	leaq	(%r12,%rdx), %rcx
	movq	%rcx, 72(%rsp)
	leaq	(%r14,%rdx), %rcx
	movq	%rcx, 32(%rsp)
	leaq	(%r10,%rdx), %rcx
	addq	%r13, %rdx
	movq	%rcx, 64(%rsp)
	movq	%rdx, 24(%rsp)
	.p2align 4,,10
	.p2align 3
.L4:
	leaq	tr(%rip), %rdx
	leaq	dx(%rip), %rcx
	addq	$1, 8(%rsp)
	movslq	(%rdx,%rax,4), %rdx
	leaq	dy(%rip), %rax
	movl	(%rax,%rdx,4), %eax
	movl	(%rcx,%rdx,4), %edx
	movl	16(%rsp), %ecx
	movl	%eax, 20(%rsp)
	movl	%edx, 40(%rsp)
	testl	%ecx, %ecx
	je	.L9
	cmpl	$2, 16(%rsp)
	jle	.L13
	movq	72(%rsp), %rbx
	movq	64(%rsp), %rcx
	movq	%r14, 48(%rsp)
	movq	32(%rsp), %rdi
	movq	24(%rsp), %r15
	movq	%r12, 56(%rsp)
	movswl	(%rcx), %ebp
	movswl	(%rbx), %r9d
	movq	%rbx, %r8
	movq	%rcx, %rsi
	movswl	(%r15), %ebx
	movswl	(%rdi), %ecx
	movl	44(%rsp), %r11d
	movl	%ebx, 4(%rsp)
	movl	%ecx, (%rsp)
.L7:
	movswl	-2(%r15), %r12d
	movswl	-2(%rdi), %ebx
	movswl	-2(%rsi), %r14d
	movl	%r12d, %ecx
	negl	%ecx
	cmpl	%ebp, %ecx
	cmovg	%ebp, %ecx
	movswl	-2(%r8), %ebp
	addl	%eax, %ecx
	movw	%cx, (%rsi)
	movl	%ebx, %ecx
	negl	%ecx
	cmpl	%r9d, %ecx
	cmovl	%r9d, %ecx
	movl	4(%rsp), %r9d
	addl	%edx, %ecx
	movw	%cx, (%r8)
	movl	%r14d, %ecx
	negl	%ecx
	cmpl	%r9d, %ecx
	cmovl	%r9d, %ecx
	movl	(%rsp), %r9d
	addl	%eax, %ecx
	movw	%cx, (%r15)
	movl	%ebp, %ecx
	negl	%ecx
	cmpl	%r9d, %ecx
	cmovg	%r9d, %ecx
	movswl	-4(%r15), %r9d
	movl	%r9d, 4(%rsp)
	negl	%r9d
	addl	%edx, %ecx
	cmpl	%r14d, %r9d
	movw	%cx, (%rdi)
	leal	-1(%r11), %ecx
	cmovg	%r14d, %r9d
	movswl	-4(%rdi), %r14d
	addl	%eax, %r9d
	movl	%r14d, (%rsp)
	movw	%r9w, -2(%rsi)
	movl	%r14d, %r9d
	negl	%r9d
	cmpl	%ebp, %r9d
	cmovl	%ebp, %r9d
	movswl	-4(%rsi), %ebp
	addl	%edx, %r9d
	movw	%r9w, -2(%r8)
	movl	%ebp, %r9d
	negl	%r9d
	cmpl	%r12d, %r9d
	cmovl	%r12d, %r9d
	addl	%eax, %r9d
	movw	%r9w, -2(%r15)
	movswl	-4(%r8), %r9d
	movl	%r9d, %r12d
	negl	%r12d
	cmpl	%ebx, %r12d
	cmovg	%ebx, %r12d
	subl	$2, %r11d
	subq	$4, %r15
	subq	$4, %rsi
	subq	$4, %rdi
	subq	$4, %r8
	addl	%edx, %r12d
	movw	%r12w, 2(%rdi)
	cmpl	$1, %r11d
	jg	.L7
	movq	48(%rsp), %r14
	movq	56(%rsp), %r12
.L6:
	movslq	%r11d, %r8
	movl	%r11d, %esi
	leaq	-1(%r8), %r9
	movq	%r9, %r11
	subq	%rsi, %r11
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L22:
	subq	$1, %r9
.L8:
	movslq	%ecx, %rsi
	movswl	0(%r13,%r8,2), %edi
	movl	%r8d, %ecx
	movswl	(%r10,%rsi,2), %ebx
	negl	%edi
	cmpl	%ebx, %edi
	cmovg	%ebx, %edi
	movswl	(%r12,%rsi,2), %ebx
	addl	%eax, %edi
	movw	%di, (%r10,%rsi,2)
	movswl	(%r14,%r8,2), %edi
	negl	%edi
	cmpl	%ebx, %edi
	cmovl	%ebx, %edi
	movswl	0(%r13,%rsi,2), %ebx
	addl	%edx, %edi
	movw	%di, (%r12,%rsi,2)
	movswl	(%r10,%r8,2), %edi
	negl	%edi
	cmpl	%ebx, %edi
	cmovl	%ebx, %edi
	addl	%eax, %edi
	movw	%di, 0(%r13,%rsi,2)
	movswl	(%r12,%r8,2), %edi
	movswl	(%r14,%rsi,2), %r8d
	negl	%edi
	cmpl	%r8d, %edi
	cmovg	%r8d, %edi
	movq	%r9, %r8
	addl	%edx, %edi
	movw	%di, (%r14,%rsi,2)
	cmpq	%r11, %r9
	jne	.L22
.L9:
	movzwl	40(%rsp), %eax
	addw	(%r14), %ax
	movw	%ax, (%r14)
	movw	%ax, (%r12)
	movzwl	20(%rsp), %eax
	addw	0(%r13), %ax
	movw	%ax, 0(%r13)
	movw	%ax, (%r10)
	movq	8(%rsp), %rax
	movsbq	(%rax), %rax
	testb	%al, %al
	jne	.L4
.L5:
	movl	16(%rsp), %eax
	testl	%eax, %eax
	js	.L14
	movslq	%eax, %rsi
	leaq	u(%rip), %r9
	xorl	%edi, %edi
	xorl	%ecx, %ecx
	leaq	2(%rsi,%rsi), %r10
	addq	%rsi, %rsi
	leaq	d(%rip), %rax
	xorl	%r8d, %r8d
	addq	%rsi, %r9
	leaq	r(%rip), %r12
	addq	%rax, %rsi
	leaq	l(%rip), %r14
	.p2align 4,,10
	.p2align 3
.L11:
	movswl	(%r14,%rcx), %eax
	movswl	(%r12,%rcx), %edx
	movswl	(%rsi,%rdi), %r11d
	negl	%eax
	cmpl	%edx, %eax
	cmovge	%eax, %edx
	movswl	(%r9,%rdi), %eax
	negl	%eax
	cmpl	%r11d, %eax
	cmovl	%r11d, %eax
	addl	%edx, %eax
	cmpl	%eax, %r8d
	cmovl	%eax, %r8d
	addq	$2, %rcx
	subq	$2, %rdi
	cmpq	%rcx, %r10
	jne	.L11
.L10:
	xorl	%eax, %eax
	movl	%r8d, %edx
	movl	$1, %edi
	leaq	.LC1(%rip), %rsi
	call	__printf_chk@PLT
	movq	88(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L23
	addq	$104, %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
.L13:
	.cfi_restore_state
	movl	44(%rsp), %r11d
	movl	16(%rsp), %ecx
	jmp	.L6
.L2:
	movl	84(%rsp), %eax
	movl	%eax, 16(%rsp)
	jmp	.L5
.L14:
	xorl	%r8d, %r8d
	jmp	.L10
.L23:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.globl	tr
	.bss
	.align 32
	.type	tr, @object
	.size	tr, 360
tr:
	.zero	360
	.globl	dy
	.data
	.align 16
	.type	dy, @object
	.size	dy, 16
dy:
	.long	-1
	.long	0
	.long	1
	.long	0
	.globl	dx
	.align 16
	.type	dx, @object
	.size	dx, 16
dx:
	.long	0
	.long	1
	.long	0
	.long	-1
	.globl	r
	.bss
	.align 32
	.type	r, @object
	.size	r, 4004
r:
	.zero	4004
	.globl	l
	.align 32
	.type	l, @object
	.size	l, 4004
l:
	.zero	4004
	.globl	d
	.align 32
	.type	d, @object
	.size	d, 4004
d:
	.zero	4004
	.globl	u
	.align 32
	.type	u, @object
	.size	u, 4004
u:
	.zero	4004
	.globl	s
	.align 32
	.type	s, @object
	.size	s, 2002
s:
	.zero	2002
	.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	"%s%d"
.LC1:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	.LC0(%rip), %rdi
	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	s(%rip), %rbx
	movq	%rbx, %rsi
	subq	$104, %rsp
	.cfi_def_cfa_offset 160
	movq	%fs:40, %rax
	movq	%rax, 88(%rsp)
	xorl	%eax, %eax
	leaq	84(%rsp), %rdx
	movl	$0, 340+tr(%rip)
	movl	$1, 328+tr(%rip)
	movl	$2, 272+tr(%rip)
	movl	$3, 304+tr(%rip)
	call	__isoc99_scanf@PLT
	movsbq	s(%rip), %rax
	testb	%al, %al
	je	.L2
	movslq	84(%rsp), %rdx
	leaq	r(%rip), %r12
	leaq	l(%rip), %r14
	movq	%rbx, 8(%rsp)
	leaq	u(%rip), %r10
	leaq	d(%rip), %r13
	leal	-1(%rdx), %ecx
	movl	%edx, 16(%rsp)
	addq	%rdx, %rdx
	movl	%ecx, 44(%rsp)
	leaq	(%r12,%rdx), %rcx
	movq	%rcx, 72(%rsp)
	leaq	(%r14,%rdx), %rcx
	movq	%rcx, 32(%rsp)
	leaq	(%r10,%rdx), %rcx
	addq	%r13, %rdx
	movq	%rcx, 64(%rsp)
	movq	%rdx, 24(%rsp)
	.p2align 4,,10
	.p2align 3
.L4:
	leaq	tr(%rip), %rdx
	leaq	dx(%rip), %rcx
	addq	$1, 8(%rsp)
	movslq	(%rdx,%rax,4), %rdx
	leaq	dy(%rip), %rax
	movl	(%rax,%rdx,4), %eax
	movl	(%rcx,%rdx,4), %edx
	movl	16(%rsp), %ecx
	movl	%eax, 20(%rsp)
	movl	%edx, 40(%rsp)
	testl	%ecx, %ecx
	je	.L9
	cmpl	$2, 16(%rsp)
	jle	.L13
	movq	72(%rsp), %rbx
	movq	64(%rsp), %rcx
	movq	%r14, 48(%rsp)
	movq	32(%rsp), %rdi
	movq	24(%rsp), %r15
	movq	%r12, 56(%rsp)
	movswl	(%rcx), %ebp
	movswl	(%rbx), %r9d
	movq	%rbx, %r8
	movq	%rcx, %rsi
	movswl	(%r15), %ebx
	movswl	(%rdi), %ecx
	movl	44(%rsp), %r11d
	movl	%ebx, 4(%rsp)
	movl	%ecx, (%rsp)
.L7:
	movswl	-2(%r15), %r12d
	movswl	-2(%rdi), %ebx
	movswl	-2(%rsi), %r14d
	movl	%r12d, %ecx
	negl	%ecx
	cmpl	%ebp, %ecx
	cmovg	%ebp, %ecx
	movswl	-2(%r8), %ebp
	addl	%eax, %ecx
	movw	%cx, (%rsi)
	movl	%ebx, %ecx
	negl	%ecx
	cmpl	%r9d, %ecx
	cmovl	%r9d, %ecx
	movl	4(%rsp), %r9d
	addl	%edx, %ecx
	movw	%cx, (%r8)
	movl	%r14d, %ecx
	negl	%ecx
	cmpl	%r9d, %ecx
	cmovl	%r9d, %ecx
	movl	(%rsp), %r9d
	addl	%eax, %ecx
	movw	%cx, (%r15)
	movl	%ebp, %ecx
	negl	%ecx
	cmpl	%r9d, %ecx
	cmovg	%r9d, %ecx
	movswl	-4(%r15), %r9d
	movl	%r9d, 4(%rsp)
	negl	%r9d
	addl	%edx, %ecx
	cmpl	%r14d, %r9d
	movw	%cx, (%rdi)
	leal	-1(%r11), %ecx
	cmovg	%r14d, %r9d
	movswl	-4(%rdi), %r14d
	addl	%eax, %r9d
	movl	%r14d, (%rsp)
	movw	%r9w, -2(%rsi)
	movl	%r14d, %r9d
	negl	%r9d
	cmpl	%ebp, %r9d
	cmovl	%ebp, %r9d
	movswl	-4(%rsi), %ebp
	addl	%edx, %r9d
	movw	%r9w, -2(%r8)
	movl	%ebp, %r9d
	negl	%r9d
	cmpl	%r12d, %r9d
	cmovl	%r12d, %r9d
	addl	%eax, %r9d
	movw	%r9w, -2(%r15)
	movswl	-4(%r8), %r9d
	movl	%r9d, %r12d
	negl	%r12d
	cmpl	%ebx, %r12d
	cmovg	%ebx, %r12d
	subl	$2, %r11d
	subq	$4, %r15
	subq	$4, %rsi
	subq	$4, %rdi
	subq	$4, %r8
	addl	%edx, %r12d
	movw	%r12w, 2(%rdi)
	cmpl	$1, %r11d
	jg	.L7
	movq	48(%rsp), %r14
	movq	56(%rsp), %r12
.L6:
	movslq	%r11d, %r8
	movl	%r11d, %esi
	leaq	-1(%r8), %r9
	movq	%r9, %r11
	subq	%rsi, %r11
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L22:
	subq	$1, %r9
.L8:
	movslq	%ecx, %rsi
	movswl	0(%r13,%r8,2), %edi
	movl	%r8d, %ecx
	movswl	(%r10,%rsi,2), %ebx
	negl	%edi
	cmpl	%ebx, %edi
	cmovg	%ebx, %edi
	movswl	(%r12,%rsi,2), %ebx
	addl	%eax, %edi
	movw	%di, (%r10,%rsi,2)
	movswl	(%r14,%r8,2), %edi
	negl	%edi
	cmpl	%ebx, %edi
	cmovl	%ebx, %edi
	movswl	0(%r13,%rsi,2), %ebx
	addl	%edx, %edi
	movw	%di, (%r12,%rsi,2)
	movswl	(%r10,%r8,2), %edi
	negl	%edi
	cmpl	%ebx, %edi
	cmovl	%ebx, %edi
	addl	%eax, %edi
	movw	%di, 0(%r13,%rsi,2)
	movswl	(%r12,%r8,2), %edi
	movswl	(%r14,%rsi,2), %r8d
	negl	%edi
	cmpl	%r8d, %edi
	cmovg	%r8d, %edi
	movq	%r9, %r8
	addl	%edx, %edi
	movw	%di, (%r14,%rsi,2)
	cmpq	%r11, %r9
	jne	.L22
.L9:
	movzwl	40(%rsp), %eax
	addw	(%r14), %ax
	movw	%ax, (%r14)
	movw	%ax, (%r12)
	movzwl	20(%rsp), %eax
	addw	0(%r13), %ax
	movw	%ax, 0(%r13)
	movw	%ax, (%r10)
	movq	8(%rsp), %rax
	movsbq	(%rax), %rax
	testb	%al, %al
	jne	.L4
.L5:
	movl	16(%rsp), %eax
	testl	%eax, %eax
	js	.L14
	movslq	%eax, %rsi
	leaq	u(%rip), %r9
	xorl	%edi, %edi
	xorl	%ecx, %ecx
	leaq	2(%rsi,%rsi), %r10
	addq	%rsi, %rsi
	leaq	d(%rip), %rax
	xorl	%r8d, %r8d
	addq	%rsi, %r9
	leaq	r(%rip), %r12
	addq	%rax, %rsi
	leaq	l(%rip), %r14
	.p2align 4,,10
	.p2align 3
.L11:
	movswl	(%r14,%rcx), %eax
	movswl	(%r12,%rcx), %edx
	movswl	(%rsi,%rdi), %r11d
	negl	%eax
	cmpl	%edx, %eax
	cmovge	%eax, %edx
	movswl	(%r9,%rdi), %eax
	negl	%eax
	cmpl	%r11d, %eax
	cmovl	%r11d, %eax
	addl	%edx, %eax
	cmpl	%eax, %r8d
	cmovl	%eax, %r8d
	addq	$2, %rcx
	subq	$2, %rdi
	cmpq	%rcx, %r10
	jne	.L11
.L10:
	xorl	%eax, %eax
	movl	%r8d, %edx
	movl	$1, %edi
	leaq	.LC1(%rip), %rsi
	call	__printf_chk@PLT
	movq	88(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L23
	addq	$104, %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
.L13:
	.cfi_restore_state
	movl	44(%rsp), %r11d
	movl	16(%rsp), %ecx
	jmp	.L6
.L2:
	movl	84(%rsp), %eax
	movl	%eax, 16(%rsp)
	jmp	.L5
.L14:
	xorl	%r8d, %r8d
	jmp	.L10
.L23:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.globl	tr
	.bss
	.align 32
	.type	tr, @object
	.size	tr, 360
tr:
	.zero	360
	.globl	dy
	.data
	.align 16
	.type	dy, @object
	.size	dy, 16
dy:
	.long	-1
	.long	0
	.long	1
	.long	0
	.globl	dx
	.align 16
	.type	dx, @object
	.size	dx, 16
dx:
	.long	0
	.long	1
	.long	0
	.long	-1
	.globl	r
	.bss
	.align 32
	.type	r, @object
	.size	r, 4004
r:
	.zero	4004
	.globl	l
	.align 32
	.type	l, @object
	.size	l, 4004
l:
	.zero	4004
	.globl	d
	.align 32
	.type	d, @object
	.size	d, 4004
d:
	.zero	4004
	.globl	u
	.align 32
	.type	u, @object
	.size	u, 4004
u:
	.zero	4004
	.globl	s
	.align 32
	.type	s, @object
	.size	s, 2002
s:
	.zero	2002
	.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:

// AOJ 2809: Graduation Ceremony
// 2018.1.4 bal4u@uu

#include <stdio.h>

#define min(a,b) ((a)<=(b)?(a):(b))
#define max(a,b) ((a)>=(b)?(a):(b))

#define MAX 2002

char s[MAX];
short u[MAX], d[MAX], l[MAX], r[MAX];
int dx[4] = { 0,1,0,-1};	// URDL
int dy[4] = {-1,0,1, 0};
int tr['Z'];

int main()
{
	int k, i, j, j2, dir, ans;
	char *p;

	tr['U'] = 0, tr['R'] = 1, tr['D'] = 2, tr['L'] = 3;

	scanf("%s%d", s, &k);
	p = s; while (*p) {
		dir = tr[*p++];
		j2 = j = k; while (j--) {
			u[j2] = min(-d[j], u[j2]) + dy[dir];
			r[j2] = max(-l[j], r[j2]) + dx[dir];
			d[j2] = max(-u[j], d[j2]) + dy[dir];
			l[j2] = min(-r[j], l[j2]) + dx[dir];
			j2--;
		}
		l[0] += dx[dir], r[0] = l[0];
		d[0] += dy[dir], u[0] = d[0];
	}
	ans = 0;
	for (i = 0; i <= k; i++) {
		j  = -l[i];   if (j  < r[i  ]) j  = r[i];
		j2 = -u[k-i]; if (j2 < d[k-i]) j2 = d[k-i];
		j += j2;
		if (j > ans) ans = j;
	}
	printf("%d\n", ans);
	return 0;
}


RRLUDDD
1
 RRLUDDD
0
 RSLUDDD
4
 DDDULRR
1
 RRULDDD
0
 RSLUDDD
5
 DDDULRR
2
 RSLDDDU
4
 DDUDLRR
2
 DSLRDDU
4

5
 3
 7
 5
 3
 7
 7
 7
 5
 7

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

```c
// AOJ 2809: Graduation Ceremony
// 2018.1.4 bal4u@uu

#include <stdio.h>

#define min(a,b) ((a)<=(b)?(a):(b))
#define max(a,b) ((a)>=(b)?(a):(b))

#define MAX 2002

char s[MAX];
short u[MAX], d[MAX], l[MAX], r[MAX];
int dx[4] = { 0,1,0,-1};	// URDL
int dy[4] = {-1,0,1, 0};
int tr['Z'];

int main()
{
	int k, i, j, j2, dir, ans;
	char *p;

	tr['U'] = 0, tr['R'] = 1, tr['D'] = 2, tr['L'] = 3;

	scanf("%s%d", s, &k);
	p = s; while (*p) {
		dir = tr[*p++];
		j2 = j = k; while (j--) {
			u[j2] = min(-d[j], u[j2]) + dy[dir];
			r[j2] = max(-l[j], r[j2]) + dx[dir];
			d[j2] = max(-u[j], d[j2]) + dy[dir];
			l[j2] = min(-r[j], l[j2]) + dx[dir];
			j2--;
		}
		l[0] += dx[dir], r[0] = l[0];
		d[0] += dy[dir], u[0] = d[0];
	}
	ans = 0;
	for (i = 0; i <= k; i++) {
		j  = -l[i];   if (j  < r[i  ]) j  = r[i];
		j2 = -u[k-i]; if (j2 < d[k-i]) j2 = d[k-i];
		j += j2;
		if (j > ans) ans = j;
	}
	printf("%d\n", ans);
	return 0;
}

```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	s
	.bss
	.align 32
	.type	s, @object
	.size	s, 2002
s:
	.zero	2002
	.globl	u
	.align 32
	.type	u, @object
	.size	u, 4004
u:
	.zero	4004
	.globl	d
	.align 32
	.type	d, @object
	.size	d, 4004
d:
	.zero	4004
	.globl	l
	.align 32
	.type	l, @object
	.size	l, 4004
l:
	.zero	4004
	.globl	r
	.align 32
	.type	r, @object
	.size	r, 4004
r:
	.zero	4004
	.globl	dx
	.data
	.align 16
	.type	dx, @object
	.size	dx, 16
dx:
	.long	0
	.long	1
	.long	0
	.long	-1
	.globl	dy
	.align 16
	.type	dy, @object
	.size	dy, 16
dy:
	.long	-1
	.long	0
	.long	1
	.long	0
	.globl	tr
	.bss
	.align 32
	.type	tr, @object
	.size	tr, 360
tr:
	.zero	360
	.section	.rodata
.LC0:
	.string	"%s%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
	subq	$48, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, 340+tr(%rip)
	movl	$1, 328+tr(%rip)
	movl	$2, 272+tr(%rip)
	movl	$3, 304+tr(%rip)
	leaq	-40(%rbp), %rax
	movq	%rax, %rdx
	leaq	s(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	leaq	s(%rip), %rax
	movq	%rax, -16(%rbp)
	jmp	.L2
.L5:
	movq	-16(%rbp), %rax
	leaq	1(%rax), %rdx
	movq	%rdx, -16(%rbp)
	movzbl	(%rax), %eax
	movsbl	%al, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	tr(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -20(%rbp)
	movl	-40(%rbp), %eax
	movl	%eax, -32(%rbp)
	movl	-32(%rbp), %eax
	movl	%eax, -28(%rbp)
	jmp	.L3
.L4:
	movl	-32(%rbp), %eax
	cltq
	leaq	(%rax,%rax), %rdx
	leaq	d(%rip), %rax
	movzwl	(%rdx,%rax), %eax
	cwtl
	negl	%eax
	movl	%eax, %edx
	movl	-28(%rbp), %eax
	cltq
	leaq	(%rax,%rax), %rcx
	leaq	u(%rip), %rax
	movzwl	(%rcx,%rax), %eax
	cwtl
	cmpl	%eax, %edx
	cmovle	%edx, %eax
	movl	%eax, %ecx
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	dy(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%ecx, %eax
	movl	%eax, %ecx
	movl	-28(%rbp), %eax
	cltq
	leaq	(%rax,%rax), %rdx
	leaq	u(%rip), %rax
	movw	%cx, (%rdx,%rax)
	movl	-32(%rbp), %eax
	cltq
	leaq	(%rax,%rax), %rdx
	leaq	l(%rip), %rax
	movzwl	(%rdx,%rax), %eax
	cwtl
	negl	%eax
	movl	%eax, %edx
	movl	-28(%rbp), %eax
	cltq
	leaq	(%rax,%rax), %rcx
	leaq	r(%rip), %rax
	movzwl	(%rcx,%rax), %eax
	cwtl
	cmpl	%eax, %edx
	cmovge	%edx, %eax
	movl	%eax, %ecx
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	dx(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%ecx, %eax
	movl	%eax, %ecx
	movl	-28(%rbp), %eax
	cltq
	leaq	(%rax,%rax), %rdx
	leaq	r(%rip), %rax
	movw	%cx, (%rdx,%rax)
	movl	-32(%rbp), %eax
	cltq
	leaq	(%rax,%rax), %rdx
	leaq	u(%rip), %rax
	movzwl	(%rdx,%rax), %eax
	cwtl
	negl	%eax
	movl	%eax, %edx
	movl	-28(%rbp), %eax
	cltq
	leaq	(%rax,%rax), %rcx
	leaq	d(%rip), %rax
	movzwl	(%rcx,%rax), %eax
	cwtl
	cmpl	%eax, %edx
	cmovge	%edx, %eax
	movl	%eax, %ecx
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	dy(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%ecx, %eax
	movl	%eax, %ecx
	movl	-28(%rbp), %eax
	cltq
	leaq	(%rax,%rax), %rdx
	leaq	d(%rip), %rax
	movw	%cx, (%rdx,%rax)
	movl	-32(%rbp), %eax
	cltq
	leaq	(%rax,%rax), %rdx
	leaq	r(%rip), %rax
	movzwl	(%rdx,%rax), %eax
	cwtl
	negl	%eax
	movl	%eax, %edx
	movl	-28(%rbp), %eax
	cltq
	leaq	(%rax,%rax), %rcx
	leaq	l(%rip), %rax
	movzwl	(%rcx,%rax), %eax
	cwtl
	cmpl	%eax, %edx
	cmovle	%edx, %eax
	movl	%eax, %ecx
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	dx(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%ecx, %eax
	movl	%eax, %ecx
	movl	-28(%rbp), %eax
	cltq
	leaq	(%rax,%rax), %rdx
	leaq	l(%rip), %rax
	movw	%cx, (%rdx,%rax)
	subl	$1, -28(%rbp)
.L3:
	movl	-32(%rbp), %eax
	leal	-1(%rax), %edx
	movl	%edx, -32(%rbp)
	testl	%eax, %eax
	jne	.L4
	movzwl	l(%rip), %eax
	movl	%eax, %ecx
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	dx(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%ecx, %eax
	movw	%ax, l(%rip)
	movzwl	l(%rip), %eax
	movw	%ax, r(%rip)
	movzwl	d(%rip), %eax
	movl	%eax, %ecx
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	dy(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%ecx, %eax
	movw	%ax, d(%rip)
	movzwl	d(%rip), %eax
	movw	%ax, u(%rip)
.L2:
	movq	-16(%rbp), %rax
	movzbl	(%rax), %eax
	testb	%al, %al
	jne	.L5
	movl	$0, -24(%rbp)
	movl	$0, -36(%rbp)
	jmp	.L6
.L10:
	movl	-36(%rbp), %eax
	cltq
	leaq	(%rax,%rax), %rdx
	leaq	l(%rip), %rax
	movzwl	(%rdx,%rax), %eax
	cwtl
	negl	%eax
	movl	%eax, -32(%rbp)
	movl	-36(%rbp), %eax
	cltq
	leaq	(%rax,%rax), %rdx
	leaq	r(%rip), %rax
	movzwl	(%rdx,%rax), %eax
	cwtl
	cmpl	%eax, -32(%rbp)
	jge	.L7
	movl	-36(%rbp), %eax
	cltq
	leaq	(%rax,%rax), %rdx
	leaq	r(%rip), %rax
	movzwl	(%rdx,%rax), %eax
	cwtl
	movl	%eax, -32(%rbp)
.L7:
	movl	-40(%rbp), %eax
	subl	-36(%rbp), %eax
	cltq
	leaq	(%rax,%rax), %rdx
	leaq	u(%rip), %rax
	movzwl	(%rdx,%rax), %eax
	cwtl
	negl	%eax
	movl	%eax, -28(%rbp)
	movl	-40(%rbp), %eax
	subl	-36(%rbp), %eax
	cltq
	leaq	(%rax,%rax), %rdx
	leaq	d(%rip), %rax
	movzwl	(%rdx,%rax), %eax
	cwtl
	cmpl	%eax, -28(%rbp)
	jge	.L8
	movl	-40(%rbp), %eax
	subl	-36(%rbp), %eax
	cltq
	leaq	(%rax,%rax), %rdx
	leaq	d(%rip), %rax
	movzwl	(%rdx,%rax), %eax
	cwtl
	movl	%eax, -28(%rbp)
.L8:
	movl	-28(%rbp), %eax
	addl	%eax, -32(%rbp)
	movl	-32(%rbp), %eax
	cmpl	-24(%rbp), %eax
	jle	.L9
	movl	-32(%rbp), %eax
	movl	%eax, -24(%rbp)
.L9:
	addl	$1, -36(%rbp)
.L6:
	movl	-40(%rbp), %eax
	cmpl	%eax, -36(%rbp)
	jle	.L10
	movl	-24(%rbp), %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	.L12
	call	__stack_chk_fail@PLT
.L12:
	leave
	.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
	.globl	s
	.bss
	.align 32
	.type	s, @object
	.size	s, 2002
s:
	.zero	2002
	.globl	u
	.align 32
	.type	u, @object
	.size	u, 4004
u:
	.zero	4004
	.globl	d
	.align 32
	.type	d, @object
	.size	d, 4004
d:
	.zero	4004
	.globl	l
	.align 32
	.type	l, @object
	.size	l, 4004
l:
	.zero	4004
	.globl	r
	.align 32
	.type	r, @object
	.size	r, 4004
r:
	.zero	4004
	.globl	dx
	.data
	.align 16
	.type	dx, @object
	.size	dx, 16
dx:
	.long	0
	.long	1
	.long	0
	.long	-1
	.globl	dy
	.align 16
	.type	dy, @object
	.size	dy, 16
dy:
	.long	-1
	.long	0
	.long	1
	.long	0
	.globl	tr
	.bss
	.align 32
	.type	tr, @object
	.size	tr, 360
tr:
	.zero	360
	.section	.rodata
.LC0:
	.string	"%s%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
	subq	$48, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, 340+tr(%rip)
	movl	$1, 328+tr(%rip)
	movl	$2, 272+tr(%rip)
	movl	$3, 304+tr(%rip)
	leaq	-40(%rbp), %rax
	movq	%rax, %rdx
	leaq	s(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	leaq	s(%rip), %rax
	movq	%rax, -16(%rbp)
	jmp	.L2
.L5:
	movq	-16(%rbp), %rax
	leaq	1(%rax), %rdx
	movq	%rdx, -16(%rbp)
	movzbl	(%rax), %eax
	movsbl	%al, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	tr(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -20(%rbp)
	movl	-40(%rbp), %eax
	movl	%eax, -32(%rbp)
	movl	-32(%rbp), %eax
	movl	%eax, -28(%rbp)
	jmp	.L3
.L4:
	movl	-32(%rbp), %eax
	cltq
	leaq	(%rax,%rax), %rdx
	leaq	d(%rip), %rax
	movzwl	(%rdx,%rax), %eax
	cwtl
	negl	%eax
	movl	%eax, %edx
	movl	-28(%rbp), %eax
	cltq
	leaq	(%rax,%rax), %rcx
	leaq	u(%rip), %rax
	movzwl	(%rcx,%rax), %eax
	cwtl
	cmpl	%eax, %edx
	cmovle	%edx, %eax
	movl	%eax, %ecx
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	dy(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%ecx, %eax
	movl	%eax, %ecx
	movl	-28(%rbp), %eax
	cltq
	leaq	(%rax,%rax), %rdx
	leaq	u(%rip), %rax
	movw	%cx, (%rdx,%rax)
	movl	-32(%rbp), %eax
	cltq
	leaq	(%rax,%rax), %rdx
	leaq	l(%rip), %rax
	movzwl	(%rdx,%rax), %eax
	cwtl
	negl	%eax
	movl	%eax, %edx
	movl	-28(%rbp), %eax
	cltq
	leaq	(%rax,%rax), %rcx
	leaq	r(%rip), %rax
	movzwl	(%rcx,%rax), %eax
	cwtl
	cmpl	%eax, %edx
	cmovge	%edx, %eax
	movl	%eax, %ecx
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	dx(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%ecx, %eax
	movl	%eax, %ecx
	movl	-28(%rbp), %eax
	cltq
	leaq	(%rax,%rax), %rdx
	leaq	r(%rip), %rax
	movw	%cx, (%rdx,%rax)
	movl	-32(%rbp), %eax
	cltq
	leaq	(%rax,%rax), %rdx
	leaq	u(%rip), %rax
	movzwl	(%rdx,%rax), %eax
	cwtl
	negl	%eax
	movl	%eax, %edx
	movl	-28(%rbp), %eax
	cltq
	leaq	(%rax,%rax), %rcx
	leaq	d(%rip), %rax
	movzwl	(%rcx,%rax), %eax
	cwtl
	cmpl	%eax, %edx
	cmovge	%edx, %eax
	movl	%eax, %ecx
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	dy(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%ecx, %eax
	movl	%eax, %ecx
	movl	-28(%rbp), %eax
	cltq
	leaq	(%rax,%rax), %rdx
	leaq	d(%rip), %rax
	movw	%cx, (%rdx,%rax)
	movl	-32(%rbp), %eax
	cltq
	leaq	(%rax,%rax), %rdx
	leaq	r(%rip), %rax
	movzwl	(%rdx,%rax), %eax
	cwtl
	negl	%eax
	movl	%eax, %edx
	movl	-28(%rbp), %eax
	cltq
	leaq	(%rax,%rax), %rcx
	leaq	l(%rip), %rax
	movzwl	(%rcx,%rax), %eax
	cwtl
	cmpl	%eax, %edx
	cmovle	%edx, %eax
	movl	%eax, %ecx
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	dx(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%ecx, %eax
	movl	%eax, %ecx
	movl	-28(%rbp), %eax
	cltq
	leaq	(%rax,%rax), %rdx
	leaq	l(%rip), %rax
	movw	%cx, (%rdx,%rax)
	subl	$1, -28(%rbp)
.L3:
	movl	-32(%rbp), %eax
	leal	-1(%rax), %edx
	movl	%edx, -32(%rbp)
	testl	%eax, %eax
	jne	.L4
	movzwl	l(%rip), %eax
	movl	%eax, %ecx
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	dx(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%ecx, %eax
	movw	%ax, l(%rip)
	movzwl	l(%rip), %eax
	movw	%ax, r(%rip)
	movzwl	d(%rip), %eax
	movl	%eax, %ecx
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	dy(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%ecx, %eax
	movw	%ax, d(%rip)
	movzwl	d(%rip), %eax
	movw	%ax, u(%rip)
.L2:
	movq	-16(%rbp), %rax
	movzbl	(%rax), %eax
	testb	%al, %al
	jne	.L5
	movl	$0, -24(%rbp)
	movl	$0, -36(%rbp)
	jmp	.L6
.L10:
	movl	-36(%rbp), %eax
	cltq
	leaq	(%rax,%rax), %rdx
	leaq	l(%rip), %rax
	movzwl	(%rdx,%rax), %eax
	cwtl
	negl	%eax
	movl	%eax, -32(%rbp)
	movl	-36(%rbp), %eax
	cltq
	leaq	(%rax,%rax), %rdx
	leaq	r(%rip), %rax
	movzwl	(%rdx,%rax), %eax
	cwtl
	cmpl	%eax, -32(%rbp)
	jge	.L7
	movl	-36(%rbp), %eax
	cltq
	leaq	(%rax,%rax), %rdx
	leaq	r(%rip), %rax
	movzwl	(%rdx,%rax), %eax
	cwtl
	movl	%eax, -32(%rbp)
.L7:
	movl	-40(%rbp), %eax
	subl	-36(%rbp), %eax
	cltq
	leaq	(%rax,%rax), %rdx
	leaq	u(%rip), %rax
	movzwl	(%rdx,%rax), %eax
	cwtl
	negl	%eax
	movl	%eax, -28(%rbp)
	movl	-40(%rbp), %eax
	subl	-36(%rbp), %eax
	cltq
	leaq	(%rax,%rax), %rdx
	leaq	d(%rip), %rax
	movzwl	(%rdx,%rax), %eax
	cwtl
	cmpl	%eax, -28(%rbp)
	jge	.L8
	movl	-40(%rbp), %eax
	subl	-36(%rbp), %eax
	cltq
	leaq	(%rax,%rax), %rdx
	leaq	d(%rip), %rax
	movzwl	(%rdx,%rax), %eax
	cwtl
	movl	%eax, -28(%rbp)
.L8:
	movl	-28(%rbp), %eax
	addl	%eax, -32(%rbp)
	movl	-32(%rbp), %eax
	cmpl	-24(%rbp), %eax
	jle	.L9
	movl	-32(%rbp), %eax
	movl	%eax, -24(%rbp)
.L9:
	addl	$1, -36(%rbp)
.L6:
	movl	-40(%rbp), %eax
	cmpl	%eax, -36(%rbp)
	jle	.L10
	movl	-24(%rbp), %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	.L12
	call	__stack_chk_fail@PLT
.L12:
	leave
	.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:
