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>

/*[which card][for multiple cards of the same number]*/
int acl[1001][5000];
int acl_num[1001];
int acl_used[1001];

int main(void) {
	int b_cards[5000];
	int num_a,num_b;
	int start;
	int i,j;
	int currentcard;
	int currentpos=-1;
	int currentscore=0;
	int maxscore=0;
	int ok;
	scanf("%d%d",&num_a,&num_b);
	for(i=0;i<num_a;i++) {
		scanf("%d",&currentcard);
		/*record where the cards are*/
		acl[currentcard][acl_num[currentcard]]=i;
		acl_num[currentcard]++;
	}
	for(i=0;i<num_b;i++) {
		scanf("%d",&b_cards[i]);
	}
	for(start=0;start<num_b;start++) {
		for(j=1;j<=1000;j++)acl_used[j]=0;
		currentscore=0;
		currentpos=-1;
		for(i=start;i<num_b;i++) {
			currentcard=b_cards[i];
			ok=0;
			while(acl_num[currentcard]-acl_used[currentcard]>0) {
				if(acl[currentcard][acl_used[currentcard]]>currentpos) {
					ok=1;
					break;
				}
				acl_used[currentcard]++;
			}
			if(ok) {
				currentpos=acl[currentcard][acl_used[currentcard]];
				acl_used[currentcard]++;
				currentscore++;
			} else {
				break;
			}
		}
		if(currentscore>maxscore)maxscore=currentscore;
	}
	printf("%d\n",maxscore);
	return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	acl
	.bss
	.align 32
	.type	acl, @object
	.size	acl, 20020000
acl:
	.zero	20020000
	.globl	acl_num
	.align 32
	.type	acl_num, @object
	.size	acl_num, 4004
acl_num:
	.zero	4004
	.globl	acl_used
	.align 32
	.type	acl_used, @object
	.size	acl_used, 4004
acl_used:
	.zero	4004
	.section	.rodata
.LC0:
	.string	"%d%d"
.LC1:
	.string	"%d"
.LC2:
	.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
	leaq	-16384(%rsp), %r11
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	subq	$3680, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$-1, -20032(%rbp)
	movl	$0, -20028(%rbp)
	movl	$0, -20024(%rbp)
	leaq	-20052(%rbp), %rdx
	leaq	-20056(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -20040(%rbp)
	jmp	.L2
.L3:
	leaq	-20048(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-20048(%rbp), %eax
	movl	-20048(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	acl_num(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	movslq	%edx, %rdx
	cltq
	imulq	$5000, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rcx
	leaq	acl(%rip), %rdx
	movl	-20040(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	movl	-20048(%rbp), %eax
	movslq	%eax, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	acl_num(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	leal	1(%rdx), %ecx
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	acl_num(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	addl	$1, -20040(%rbp)
.L2:
	movl	-20056(%rbp), %eax
	cmpl	%eax, -20040(%rbp)
	jl	.L3
	movl	$0, -20040(%rbp)
	jmp	.L4
.L5:
	leaq	-20016(%rbp), %rdx
	movl	-20040(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -20040(%rbp)
.L4:
	movl	-20052(%rbp), %eax
	cmpl	%eax, -20040(%rbp)
	jl	.L5
	movl	$0, -20044(%rbp)
	jmp	.L6
.L19:
	movl	$1, -20036(%rbp)
	jmp	.L7
.L8:
	movl	-20036(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	acl_used(%rip), %rax
	movl	$0, (%rdx,%rax)
	addl	$1, -20036(%rbp)
.L7:
	cmpl	$1000, -20036(%rbp)
	jle	.L8
	movl	$0, -20028(%rbp)
	movl	$-1, -20032(%rbp)
	movl	-20044(%rbp), %eax
	movl	%eax, -20040(%rbp)
	jmp	.L9
.L17:
	movl	-20040(%rbp), %eax
	cltq
	movl	-20016(%rbp,%rax,4), %eax
	movl	%eax, -20048(%rbp)
	movl	$0, -20020(%rbp)
	jmp	.L10
.L13:
	movl	-20048(%rbp), %eax
	movl	-20048(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	acl_used(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	movslq	%edx, %rdx
	cltq
	imulq	$5000, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	acl(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -20032(%rbp)
	jge	.L11
	movl	$1, -20020(%rbp)
	jmp	.L12
.L11:
	movl	-20048(%rbp), %eax
	movslq	%eax, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	acl_used(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	leal	1(%rdx), %ecx
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	acl_used(%rip), %rax
	movl	%ecx, (%rdx,%rax)
.L10:
	movl	-20048(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	acl_num(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-20048(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	acl_used(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	subl	%edx, %eax
	testl	%eax, %eax
	jg	.L13
.L12:
	cmpl	$0, -20020(%rbp)
	je	.L22
	movl	-20048(%rbp), %eax
	movl	-20048(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	acl_used(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	movslq	%edx, %rdx
	cltq
	imulq	$5000, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	acl(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -20032(%rbp)
	movl	-20048(%rbp), %eax
	movslq	%eax, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	acl_used(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	leal	1(%rdx), %ecx
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	acl_used(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	addl	$1, -20028(%rbp)
	addl	$1, -20040(%rbp)
.L9:
	movl	-20052(%rbp), %eax
	cmpl	%eax, -20040(%rbp)
	jl	.L17
	jmp	.L16
.L22:
	nop
.L16:
	movl	-20028(%rbp), %eax
	cmpl	-20024(%rbp), %eax
	jle	.L18
	movl	-20028(%rbp), %eax
	movl	%eax, -20024(%rbp)
.L18:
	addl	$1, -20044(%rbp)
.L6:
	movl	-20052(%rbp), %eax
	cmpl	%eax, -20044(%rbp)
	jl	.L19
	movl	-20024(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@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
.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%d"
.LC1:
	.string	"%d"
.LC2:
	.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
	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	-16384(%rsp), %r11
	.cfi_def_cfa 11, 16440
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	.cfi_def_cfa_register 7
	subq	$3672, %rsp
	.cfi_def_cfa_offset 20112
	leaq	.LC0(%rip), %rdi
	xorl	%r14d, %r14d
	leaq	.LC1(%rip), %r12
	leaq	acl_num(%rip), %rbx
	leaq	acl(%rip), %rbp
	movq	%fs:40, %rax
	movq	%rax, 20040(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rdx
	leaq	20(%rsp), %rsi
	leaq	28(%rsp), %r13
	call	__isoc99_scanf@PLT
	movl	20(%rsp), %edx
	testl	%edx, %edx
	jle	.L5
.L2:
	movq	%r13, %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movslq	28(%rsp), %rdx
	movslq	(%rbx,%rdx,4), %rsi
	imulq	$5000, %rdx, %rcx
	movq	%rsi, %rax
	addq	%rsi, %rcx
	addl	$1, %eax
	movl	%r14d, 0(%rbp,%rcx,4)
	addl	$1, %r14d
	movl	%eax, (%rbx,%rdx,4)
	cmpl	%r14d, 20(%rsp)
	jg	.L2
.L5:
	movl	24(%rsp), %eax
	testl	%eax, %eax
	jle	.L4
	leaq	32(%rsp), %rbp
	xorl	%ebx, %ebx
	leaq	.LC1(%rip), %r12
	movq	%rbp, %r13
.L7:
	movq	%r13, %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	addl	$1, %ebx
	call	__isoc99_scanf@PLT
	movl	24(%rsp), %r10d
	addq	$4, %r13
	cmpl	%ebx, %r10d
	jg	.L7
	testl	%r10d, %r10d
	jle	.L4
	movslq	%r10d, %rax
	movl	$0, 4(%rsp)
	xorl	%r12d, %r12d
	leaq	acl_num(%rip), %rbx
	movq	%rax, 8(%rsp)
	leaq	acl_used(%rip), %r8
	leaq	acl(%rip), %r11
.L11:
	leaq	12+acl_used(%rip), %rdi
	xorl	%eax, %eax
	movq	%r12, %r13
	xorl	%r14d, %r14d
	andq	$-8, %rdi
	leaq	4+acl_used(%rip), %rcx
	movq	$0, 4+acl_used(%rip)
	movl	$-1, %r9d
	movq	$0, 3996+acl_used(%rip)
	subq	%rdi, %rcx
	addl	$4000, %ecx
	shrl	$3, %ecx
	rep stosq
	.p2align 4,,10
	.p2align 3
.L12:
	movslq	0(%rbp,%r13,4), %rcx
	movl	(%rbx,%rcx,4), %esi
	movl	(%r8,%rcx,4), %eax
	movq	%rcx, %r15
	cmpl	%eax, %esi
	jle	.L8
	imulq	$20000, %rcx, %rdi
	addl	$1, %eax
	addl	$1, %esi
	cltq
	addq	%r11, %rdi
	jmp	.L10
	.p2align 4,,10
	.p2align 3
.L27:
	addq	$1, %rax
	movl	%esi, %edx
	subl	%eax, %edx
	testl	%edx, %edx
	jle	.L8
.L10:
	movl	-4(%rdi,%rax,4), %edx
	movl	%eax, (%r8,%rcx,4)
	cmpl	%r9d, %edx
	jle	.L27
	addq	$1, %r13
	addl	$1, %r14d
	cmpl	%r13d, %r10d
	jle	.L8
	movl	%edx, %r9d
	jmp	.L12
	.p2align 4,,10
	.p2align 3
.L8:
	movl	4(%rsp), %eax
	cmpl	%r14d, %eax
	cmovge	%eax, %r14d
	addq	$1, %r12
	movl	%r14d, 4(%rsp)
	cmpq	8(%rsp), %r12
	jne	.L11
	movl	%r15d, 28(%rsp)
	movl	%r14d, %edx
.L6:
	xorl	%eax, %eax
	leaq	.LC2(%rip), %rsi
	movl	$1, %edi
	call	__printf_chk@PLT
	movq	20040(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L28
	addq	$20056, %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
.L4:
	.cfi_restore_state
	movl	$0, 4(%rsp)
	movl	4(%rsp), %edx
	jmp	.L6
.L28:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.globl	acl_used
	.bss
	.align 32
	.type	acl_used, @object
	.size	acl_used, 4004
acl_used:
	.zero	4004
	.globl	acl_num
	.align 32
	.type	acl_num, @object
	.size	acl_num, 4004
acl_num:
	.zero	4004
	.globl	acl
	.align 32
	.type	acl, @object
	.size	acl, 20020000
acl:
	.zero	20020000
	.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%d"
.LC1:
	.string	"%d"
.LC2:
	.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
	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	-16384(%rsp), %r11
	.cfi_def_cfa 11, 16440
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	.cfi_def_cfa_register 7
	subq	$3672, %rsp
	.cfi_def_cfa_offset 20112
	leaq	.LC0(%rip), %rdi
	xorl	%r14d, %r14d
	leaq	.LC1(%rip), %r12
	leaq	acl_num(%rip), %rbx
	leaq	acl(%rip), %rbp
	movq	%fs:40, %rax
	movq	%rax, 20040(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rdx
	leaq	20(%rsp), %rsi
	leaq	28(%rsp), %r13
	call	__isoc99_scanf@PLT
	movl	20(%rsp), %edx
	testl	%edx, %edx
	jle	.L5
.L2:
	movq	%r13, %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movslq	28(%rsp), %rdx
	movslq	(%rbx,%rdx,4), %rsi
	imulq	$5000, %rdx, %rcx
	movq	%rsi, %rax
	addq	%rsi, %rcx
	addl	$1, %eax
	movl	%r14d, 0(%rbp,%rcx,4)
	addl	$1, %r14d
	movl	%eax, (%rbx,%rdx,4)
	cmpl	%r14d, 20(%rsp)
	jg	.L2
.L5:
	movl	24(%rsp), %eax
	testl	%eax, %eax
	jle	.L4
	leaq	32(%rsp), %rbp
	xorl	%ebx, %ebx
	leaq	.LC1(%rip), %r12
	movq	%rbp, %r13
.L7:
	movq	%r13, %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	addl	$1, %ebx
	call	__isoc99_scanf@PLT
	movl	24(%rsp), %r10d
	addq	$4, %r13
	cmpl	%ebx, %r10d
	jg	.L7
	testl	%r10d, %r10d
	jle	.L4
	movslq	%r10d, %rax
	movl	$0, 4(%rsp)
	xorl	%r12d, %r12d
	leaq	acl_num(%rip), %rbx
	movq	%rax, 8(%rsp)
	leaq	acl_used(%rip), %r8
	leaq	acl(%rip), %r11
.L11:
	leaq	12+acl_used(%rip), %rdi
	xorl	%eax, %eax
	movq	%r12, %r13
	xorl	%r14d, %r14d
	andq	$-8, %rdi
	leaq	4+acl_used(%rip), %rcx
	movq	$0, 4+acl_used(%rip)
	movl	$-1, %r9d
	movq	$0, 3996+acl_used(%rip)
	subq	%rdi, %rcx
	addl	$4000, %ecx
	shrl	$3, %ecx
	rep stosq
	.p2align 4,,10
	.p2align 3
.L12:
	movslq	0(%rbp,%r13,4), %rcx
	movl	(%rbx,%rcx,4), %esi
	movl	(%r8,%rcx,4), %eax
	movq	%rcx, %r15
	cmpl	%eax, %esi
	jle	.L8
	imulq	$20000, %rcx, %rdi
	addl	$1, %eax
	addl	$1, %esi
	cltq
	addq	%r11, %rdi
	jmp	.L10
	.p2align 4,,10
	.p2align 3
.L27:
	addq	$1, %rax
	movl	%esi, %edx
	subl	%eax, %edx
	testl	%edx, %edx
	jle	.L8
.L10:
	movl	-4(%rdi,%rax,4), %edx
	movl	%eax, (%r8,%rcx,4)
	cmpl	%r9d, %edx
	jle	.L27
	addq	$1, %r13
	addl	$1, %r14d
	cmpl	%r13d, %r10d
	jle	.L8
	movl	%edx, %r9d
	jmp	.L12
	.p2align 4,,10
	.p2align 3
.L8:
	movl	4(%rsp), %eax
	cmpl	%r14d, %eax
	cmovge	%eax, %r14d
	addq	$1, %r12
	movl	%r14d, 4(%rsp)
	cmpq	8(%rsp), %r12
	jne	.L11
	movl	%r15d, 28(%rsp)
	movl	%r14d, %edx
.L6:
	xorl	%eax, %eax
	leaq	.LC2(%rip), %rsi
	movl	$1, %edi
	call	__printf_chk@PLT
	movq	20040(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L28
	addq	$20056, %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
.L4:
	.cfi_restore_state
	movl	$0, 4(%rsp)
	movl	4(%rsp), %edx
	jmp	.L6
.L28:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.globl	acl_used
	.bss
	.align 32
	.type	acl_used, @object
	.size	acl_used, 4004
acl_used:
	.zero	4004
	.globl	acl_num
	.align 32
	.type	acl_num, @object
	.size	acl_num, 4004
acl_num:
	.zero	4004
	.globl	acl
	.align 32
	.type	acl, @object
	.size	acl, 20020000
acl:
	.zero	20020000
	.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>

/*[which card][for multiple cards of the same number]*/
int acl[1001][5000];
int acl_num[1001];
int acl_used[1001];

int main(void) {
	int b_cards[5000];
	int num_a,num_b;
	int start;
	int i,j;
	int currentcard;
	int currentpos=-1;
	int currentscore=0;
	int maxscore=0;
	int ok;
	scanf("%d%d",&num_a,&num_b);
	for(i=0;i<num_a;i++) {
		scanf("%d",&currentcard);
		/*record where the cards are*/
		acl[currentcard][acl_num[currentcard]]=i;
		acl_num[currentcard]++;
	}
	for(i=0;i<num_b;i++) {
		scanf("%d",&b_cards[i]);
	}
	for(start=0;start<num_b;start++) {
		for(j=1;j<=1000;j++)acl_used[j]=0;
		currentscore=0;
		currentpos=-1;
		for(i=start;i<num_b;i++) {
			currentcard=b_cards[i];
			ok=0;
			while(acl_num[currentcard]-acl_used[currentcard]>0) {
				if(acl[currentcard][acl_used[currentcard]]>currentpos) {
					ok=1;
					break;
				}
				acl_used[currentcard]++;
			}
			if(ok) {
				currentpos=acl[currentcard][acl_used[currentcard]];
				acl_used[currentcard]++;
				currentscore++;
			} else {
				break;
			}
		}
		if(currentscore>maxscore)maxscore=currentscore;
	}
	printf("%d\n",maxscore);
	return 0;
}
5 4
1 2 3 4 5
3 1 4 1

2

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>

/*[which card][for multiple cards of the same number]*/
int acl[1001][5000];
int acl_num[1001];
int acl_used[1001];

int main(void) {
	int b_cards[5000];
	int num_a,num_b;
	int start;
	int i,j;
	int currentcard;
	int currentpos=-1;
	int currentscore=0;
	int maxscore=0;
	int ok;
	scanf("%d%d",&num_a,&num_b);
	for(i=0;i<num_a;i++) {
		scanf("%d",&currentcard);
		/*record where the cards are*/
		acl[currentcard][acl_num[currentcard]]=i;
		acl_num[currentcard]++;
	}
	for(i=0;i<num_b;i++) {
		scanf("%d",&b_cards[i]);
	}
	for(start=0;start<num_b;start++) {
		for(j=1;j<=1000;j++)acl_used[j]=0;
		currentscore=0;
		currentpos=-1;
		for(i=start;i<num_b;i++) {
			currentcard=b_cards[i];
			ok=0;
			while(acl_num[currentcard]-acl_used[currentcard]>0) {
				if(acl[currentcard][acl_used[currentcard]]>currentpos) {
					ok=1;
					break;
				}
				acl_used[currentcard]++;
			}
			if(ok) {
				currentpos=acl[currentcard][acl_used[currentcard]];
				acl_used[currentcard]++;
				currentscore++;
			} else {
				break;
			}
		}
		if(currentscore>maxscore)maxscore=currentscore;
	}
	printf("%d\n",maxscore);
	return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	acl
	.bss
	.align 32
	.type	acl, @object
	.size	acl, 20020000
acl:
	.zero	20020000
	.globl	acl_num
	.align 32
	.type	acl_num, @object
	.size	acl_num, 4004
acl_num:
	.zero	4004
	.globl	acl_used
	.align 32
	.type	acl_used, @object
	.size	acl_used, 4004
acl_used:
	.zero	4004
	.section	.rodata
.LC0:
	.string	"%d%d"
.LC1:
	.string	"%d"
.LC2:
	.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
	leaq	-16384(%rsp), %r11
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	subq	$3680, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$-1, -20032(%rbp)
	movl	$0, -20028(%rbp)
	movl	$0, -20024(%rbp)
	leaq	-20052(%rbp), %rdx
	leaq	-20056(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -20040(%rbp)
	jmp	.L2
.L3:
	leaq	-20048(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-20048(%rbp), %eax
	movl	-20048(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	acl_num(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	movslq	%edx, %rdx
	cltq
	imulq	$5000, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rcx
	leaq	acl(%rip), %rdx
	movl	-20040(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	movl	-20048(%rbp), %eax
	movslq	%eax, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	acl_num(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	leal	1(%rdx), %ecx
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	acl_num(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	addl	$1, -20040(%rbp)
.L2:
	movl	-20056(%rbp), %eax
	cmpl	%eax, -20040(%rbp)
	jl	.L3
	movl	$0, -20040(%rbp)
	jmp	.L4
.L5:
	leaq	-20016(%rbp), %rdx
	movl	-20040(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -20040(%rbp)
.L4:
	movl	-20052(%rbp), %eax
	cmpl	%eax, -20040(%rbp)
	jl	.L5
	movl	$0, -20044(%rbp)
	jmp	.L6
.L19:
	movl	$1, -20036(%rbp)
	jmp	.L7
.L8:
	movl	-20036(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	acl_used(%rip), %rax
	movl	$0, (%rdx,%rax)
	addl	$1, -20036(%rbp)
.L7:
	cmpl	$1000, -20036(%rbp)
	jle	.L8
	movl	$0, -20028(%rbp)
	movl	$-1, -20032(%rbp)
	movl	-20044(%rbp), %eax
	movl	%eax, -20040(%rbp)
	jmp	.L9
.L17:
	movl	-20040(%rbp), %eax
	cltq
	movl	-20016(%rbp,%rax,4), %eax
	movl	%eax, -20048(%rbp)
	movl	$0, -20020(%rbp)
	jmp	.L10
.L13:
	movl	-20048(%rbp), %eax
	movl	-20048(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	acl_used(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	movslq	%edx, %rdx
	cltq
	imulq	$5000, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	acl(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -20032(%rbp)
	jge	.L11
	movl	$1, -20020(%rbp)
	jmp	.L12
.L11:
	movl	-20048(%rbp), %eax
	movslq	%eax, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	acl_used(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	leal	1(%rdx), %ecx
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	acl_used(%rip), %rax
	movl	%ecx, (%rdx,%rax)
.L10:
	movl	-20048(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	acl_num(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-20048(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	acl_used(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	subl	%edx, %eax
	testl	%eax, %eax
	jg	.L13
.L12:
	cmpl	$0, -20020(%rbp)
	je	.L22
	movl	-20048(%rbp), %eax
	movl	-20048(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	acl_used(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	movslq	%edx, %rdx
	cltq
	imulq	$5000, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	acl(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -20032(%rbp)
	movl	-20048(%rbp), %eax
	movslq	%eax, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	acl_used(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	leal	1(%rdx), %ecx
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	acl_used(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	addl	$1, -20028(%rbp)
	addl	$1, -20040(%rbp)
.L9:
	movl	-20052(%rbp), %eax
	cmpl	%eax, -20040(%rbp)
	jl	.L17
	jmp	.L16
.L22:
	nop
.L16:
	movl	-20028(%rbp), %eax
	cmpl	-20024(%rbp), %eax
	jle	.L18
	movl	-20028(%rbp), %eax
	movl	%eax, -20024(%rbp)
.L18:
	addl	$1, -20044(%rbp)
.L6:
	movl	-20052(%rbp), %eax
	cmpl	%eax, -20044(%rbp)
	jl	.L19
	movl	-20024(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@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
.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	acl
	.bss
	.align 32
	.type	acl, @object
	.size	acl, 20020000
acl:
	.zero	20020000
	.globl	acl_num
	.align 32
	.type	acl_num, @object
	.size	acl_num, 4004
acl_num:
	.zero	4004
	.globl	acl_used
	.align 32
	.type	acl_used, @object
	.size	acl_used, 4004
acl_used:
	.zero	4004
	.section	.rodata
.LC0:
	.string	"%d%d"
.LC1:
	.string	"%d"
.LC2:
	.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
	leaq	-16384(%rsp), %r11
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	subq	$3680, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$-1, -20032(%rbp)
	movl	$0, -20028(%rbp)
	movl	$0, -20024(%rbp)
	leaq	-20052(%rbp), %rdx
	leaq	-20056(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -20040(%rbp)
	jmp	.L2
.L3:
	leaq	-20048(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-20048(%rbp), %eax
	movl	-20048(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	acl_num(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	movslq	%edx, %rdx
	cltq
	imulq	$5000, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rcx
	leaq	acl(%rip), %rdx
	movl	-20040(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	movl	-20048(%rbp), %eax
	movslq	%eax, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	acl_num(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	leal	1(%rdx), %ecx
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	acl_num(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	addl	$1, -20040(%rbp)
.L2:
	movl	-20056(%rbp), %eax
	cmpl	%eax, -20040(%rbp)
	jl	.L3
	movl	$0, -20040(%rbp)
	jmp	.L4
.L5:
	leaq	-20016(%rbp), %rdx
	movl	-20040(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -20040(%rbp)
.L4:
	movl	-20052(%rbp), %eax
	cmpl	%eax, -20040(%rbp)
	jl	.L5
	movl	$0, -20044(%rbp)
	jmp	.L6
.L19:
	movl	$1, -20036(%rbp)
	jmp	.L7
.L8:
	movl	-20036(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	acl_used(%rip), %rax
	movl	$0, (%rdx,%rax)
	addl	$1, -20036(%rbp)
.L7:
	cmpl	$1000, -20036(%rbp)
	jle	.L8
	movl	$0, -20028(%rbp)
	movl	$-1, -20032(%rbp)
	movl	-20044(%rbp), %eax
	movl	%eax, -20040(%rbp)
	jmp	.L9
.L17:
	movl	-20040(%rbp), %eax
	cltq
	movl	-20016(%rbp,%rax,4), %eax
	movl	%eax, -20048(%rbp)
	movl	$0, -20020(%rbp)
	jmp	.L10
.L13:
	movl	-20048(%rbp), %eax
	movl	-20048(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	acl_used(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	movslq	%edx, %rdx
	cltq
	imulq	$5000, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	acl(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -20032(%rbp)
	jge	.L11
	movl	$1, -20020(%rbp)
	jmp	.L12
.L11:
	movl	-20048(%rbp), %eax
	movslq	%eax, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	acl_used(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	leal	1(%rdx), %ecx
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	acl_used(%rip), %rax
	movl	%ecx, (%rdx,%rax)
.L10:
	movl	-20048(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	acl_num(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-20048(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	acl_used(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	subl	%edx, %eax
	testl	%eax, %eax
	jg	.L13
.L12:
	cmpl	$0, -20020(%rbp)
	je	.L22
	movl	-20048(%rbp), %eax
	movl	-20048(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	acl_used(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	movslq	%edx, %rdx
	cltq
	imulq	$5000, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	acl(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -20032(%rbp)
	movl	-20048(%rbp), %eax
	movslq	%eax, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	acl_used(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	leal	1(%rdx), %ecx
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	acl_used(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	addl	$1, -20028(%rbp)
	addl	$1, -20040(%rbp)
.L9:
	movl	-20052(%rbp), %eax
	cmpl	%eax, -20040(%rbp)
	jl	.L17
	jmp	.L16
.L22:
	nop
.L16:
	movl	-20028(%rbp), %eax
	cmpl	-20024(%rbp), %eax
	jle	.L18
	movl	-20028(%rbp), %eax
	movl	%eax, -20024(%rbp)
.L18:
	addl	$1, -20044(%rbp)
.L6:
	movl	-20052(%rbp), %eax
	cmpl	%eax, -20044(%rbp)
	jl	.L19
	movl	-20024(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@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
.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:
