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

```c
#define max(x,y)((x)>(y)?(x):(y))
D[1000][1000],a[1000][1000];
n,h,r;
main(){
	for(;scanf("%d",&n),n;){
		memset(D,0,sizeof(D));
		memset(a,0,sizeof(a));
		for(;n--;){
			scanf("%d%d",&h,&r);
			a[h][r]=1;
		}
		scanf("%d",&n);
		for(;n--;){
			scanf("%d%d",&h,&r);
			a[h][r]=1;
		}
		for(h=1;h<1000;h++){
			for(r=1;r<1000;r++)
				D[h][r]=max(max(D[h-1][r],D[h][r-1]),D[h-1][r-1]+a[h][r]);
		}
		printf("%d\n",D[999][999]);
	}
	exit(0);
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	D
	.bss
	.align 32
	.type	D, @object
	.size	D, 4000000
D:
	.zero	4000000
	.globl	a
	.align 32
	.type	a, @object
	.size	a, 4000000
a:
	.zero	4000000
	.globl	n
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	h
	.align 4
	.type	h, @object
	.size	h, 4
h:
	.zero	4
	.globl	r
	.align 4
	.type	r, @object
	.size	r, 4
r:
	.zero	4
	.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
	jmp	.L2
.L11:
	movl	$4000000, %edx
	movl	$0, %esi
	leaq	D(%rip), %rax
	movq	%rax, %rdi
	call	memset@PLT
	movl	$4000000, %edx
	movl	$0, %esi
	leaq	a(%rip), %rax
	movq	%rax, %rdi
	call	memset@PLT
	jmp	.L3
.L4:
	leaq	r(%rip), %rax
	movq	%rax, %rdx
	leaq	h(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	scanf@PLT
	movl	h(%rip), %eax
	movl	r(%rip), %edx
	movslq	%edx, %rdx
	cltq
	imulq	$1000, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	$1, (%rdx,%rax)
.L3:
	movl	n(%rip), %eax
	leal	-1(%rax), %edx
	movl	%edx, n(%rip)
	testl	%eax, %eax
	jne	.L4
	leaq	n(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	scanf@PLT
	jmp	.L5
.L6:
	leaq	r(%rip), %rax
	movq	%rax, %rdx
	leaq	h(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	scanf@PLT
	movl	h(%rip), %eax
	movl	r(%rip), %edx
	movslq	%edx, %rdx
	cltq
	imulq	$1000, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	$1, (%rdx,%rax)
.L5:
	movl	n(%rip), %eax
	leal	-1(%rax), %edx
	movl	%edx, n(%rip)
	testl	%eax, %eax
	jne	.L6
	movl	$1, h(%rip)
	jmp	.L7
.L10:
	movl	$1, r(%rip)
	jmp	.L8
.L9:
	movl	h(%rip), %eax
	leal	-1(%rax), %edx
	movl	r(%rip), %eax
	subl	$1, %eax
	movslq	%eax, %rcx
	movslq	%edx, %rax
	imulq	$1000, %rax, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	D(%rip), %rax
	movl	(%rdx,%rax), %ecx
	movl	h(%rip), %eax
	movl	r(%rip), %edx
	movslq	%edx, %rdx
	cltq
	imulq	$1000, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%eax, %ecx
	movl	h(%rip), %eax
	movl	r(%rip), %edx
	subl	$1, %edx
	movslq	%edx, %rdx
	cltq
	imulq	$1000, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	D(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	h(%rip), %eax
	leal	-1(%rax), %esi
	movl	r(%rip), %eax
	movslq	%eax, %rdi
	movslq	%esi, %rax
	imulq	$1000, %rax, %rax
	addq	%rdi, %rax
	leaq	0(,%rax,4), %rsi
	leaq	D(%rip), %rax
	movl	(%rsi,%rax), %eax
	cmpl	%eax, %edx
	cmovge	%edx, %eax
	movl	h(%rip), %edx
	movl	r(%rip), %esi
	cmpl	%eax, %ecx
	cmovge	%ecx, %eax
	movslq	%esi, %rcx
	movslq	%edx, %rdx
	imulq	$1000, %rdx, %rdx
	addq	%rcx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	D(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movl	r(%rip), %eax
	addl	$1, %eax
	movl	%eax, r(%rip)
.L8:
	movl	r(%rip), %eax
	cmpl	$999, %eax
	jle	.L9
	movl	h(%rip), %eax
	addl	$1, %eax
	movl	%eax, h(%rip)
.L7:
	movl	h(%rip), %eax
	cmpl	$999, %eax
	jle	.L10
	movl	3999996+D(%rip), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L2:
	leaq	n(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	scanf@PLT
	movl	n(%rip), %eax
	testl	%eax, %eax
	jne	.L11
	movl	$0, %edi
	call	exit@PLT
	.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:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	n(%rip), %r15
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	leaq	.LC1(%rip), %r14
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	leaq	r(%rip), %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	leaq	h(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	leaq	a(%rip), %rbx
	subq	$8, %rsp
	.cfi_def_cfa_offset 64
	.p2align 4,,10
	.p2align 3
.L2:
	movq	%r15, %rsi
	movq	%r14, %rdi
	xorl	%eax, %eax
	call	scanf@PLT
	movl	n(%rip), %ebp
	testl	%ebp, %ebp
	je	.L18
	movl	$4000000, %edx
	xorl	%esi, %esi
	leaq	D(%rip), %rdi
	subl	$1, %ebp
	call	memset@PLT
	movl	$4000000, %edx
	xorl	%esi, %esi
	movq	%rbx, %rdi
	call	memset@PLT
	movl	%ebp, n(%rip)
	leaq	.LC0(%rip), %rbp
	.p2align 4,,10
	.p2align 3
.L3:
	movq	%r13, %rdx
	movq	%r12, %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	scanf@PLT
	movslq	h(%rip), %rax
	movslq	r(%rip), %rdx
	imulq	$1000, %rax, %rax
	addq	%rdx, %rax
	movl	$1, (%rbx,%rax,4)
	movl	n(%rip), %eax
	leal	-1(%rax), %edx
	movl	%edx, n(%rip)
	testl	%eax, %eax
	jne	.L3
	movq	%r15, %rsi
	movq	%r14, %rdi
	call	scanf@PLT
	jmp	.L16
	.p2align 4,,10
	.p2align 3
.L4:
	movq	%r13, %rdx
	movq	%r12, %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	scanf@PLT
	movslq	h(%rip), %rax
	movslq	r(%rip), %rdx
	imulq	$1000, %rax, %rax
	addq	%rdx, %rax
	movl	$1, (%rbx,%rax,4)
.L16:
	movl	n(%rip), %eax
	leal	-1(%rax), %edx
	movl	%edx, n(%rip)
	testl	%eax, %eax
	jne	.L4
	leaq	D(%rip), %rdi
	leaq	4000+a(%rip), %r9
	leaq	4000(%rdi), %r8
	leaq	3996000(%rdi), %r10
	.p2align 4,,10
	.p2align 3
.L5:
	movl	(%r8), %eax
	movl	(%rdi), %ecx
	movl	$1, %edx
	.p2align 4,,10
	.p2align 3
.L7:
	movl	(%r9,%rdx,4), %esi
	addl	%ecx, %esi
	movl	(%rdi,%rdx,4), %ecx
	cmpl	%eax, %ecx
	cmovge	%ecx, %eax
	cmpl	%esi, %eax
	cmovl	%esi, %eax
	movl	%eax, (%r8,%rdx,4)
	addq	$1, %rdx
	cmpq	$1000, %rdx
	jne	.L7
	addq	$4000, %rdi
	addq	$4000, %r9
	addq	$4000, %r8
	cmpq	%r10, %rdi
	jne	.L5
	movl	3999996+D(%rip), %esi
	xorl	%eax, %eax
	leaq	.LC2(%rip), %rdi
	movl	$1000, r(%rip)
	movl	$1000, h(%rip)
	call	printf@PLT
	jmp	.L2
.L18:
	xorl	%edi, %edi
	call	exit@PLT
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.globl	r
	.bss
	.align 4
	.type	r, @object
	.size	r, 4
r:
	.zero	4
	.globl	h
	.align 4
	.type	h, @object
	.size	h, 4
h:
	.zero	4
	.globl	n
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	a
	.align 32
	.type	a, @object
	.size	a, 4000000
a:
	.zero	4000000
	.globl	D
	.align 32
	.type	D, @object
	.size	D, 4000000
D:
	.zero	4000000
	.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:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	n(%rip), %r15
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	leaq	.LC1(%rip), %r14
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	leaq	r(%rip), %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	leaq	h(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	leaq	a(%rip), %rbx
	subq	$8, %rsp
	.cfi_def_cfa_offset 64
	.p2align 4,,10
	.p2align 3
.L2:
	movq	%r15, %rsi
	movq	%r14, %rdi
	xorl	%eax, %eax
	call	scanf@PLT
	movl	n(%rip), %ebp
	testl	%ebp, %ebp
	je	.L18
	movl	$4000000, %edx
	xorl	%esi, %esi
	leaq	D(%rip), %rdi
	subl	$1, %ebp
	call	memset@PLT
	movl	$4000000, %edx
	xorl	%esi, %esi
	movq	%rbx, %rdi
	call	memset@PLT
	movl	%ebp, n(%rip)
	leaq	.LC0(%rip), %rbp
	.p2align 4,,10
	.p2align 3
.L3:
	movq	%r13, %rdx
	movq	%r12, %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	scanf@PLT
	movslq	h(%rip), %rax
	movslq	r(%rip), %rdx
	imulq	$1000, %rax, %rax
	addq	%rdx, %rax
	movl	$1, (%rbx,%rax,4)
	movl	n(%rip), %eax
	leal	-1(%rax), %edx
	movl	%edx, n(%rip)
	testl	%eax, %eax
	jne	.L3
	movq	%r15, %rsi
	movq	%r14, %rdi
	call	scanf@PLT
	jmp	.L16
	.p2align 4,,10
	.p2align 3
.L4:
	movq	%r13, %rdx
	movq	%r12, %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	scanf@PLT
	movslq	h(%rip), %rax
	movslq	r(%rip), %rdx
	imulq	$1000, %rax, %rax
	addq	%rdx, %rax
	movl	$1, (%rbx,%rax,4)
.L16:
	movl	n(%rip), %eax
	leal	-1(%rax), %edx
	movl	%edx, n(%rip)
	testl	%eax, %eax
	jne	.L4
	leaq	D(%rip), %rdi
	leaq	4000+a(%rip), %r9
	leaq	4000(%rdi), %r8
	leaq	3996000(%rdi), %r10
	.p2align 4,,10
	.p2align 3
.L5:
	movl	(%r8), %eax
	movl	(%rdi), %ecx
	movl	$1, %edx
	.p2align 4,,10
	.p2align 3
.L7:
	movl	(%r9,%rdx,4), %esi
	addl	%ecx, %esi
	movl	(%rdi,%rdx,4), %ecx
	cmpl	%eax, %ecx
	cmovge	%ecx, %eax
	cmpl	%esi, %eax
	cmovl	%esi, %eax
	movl	%eax, (%r8,%rdx,4)
	addq	$1, %rdx
	cmpq	$1000, %rdx
	jne	.L7
	addq	$4000, %rdi
	addq	$4000, %r9
	addq	$4000, %r8
	cmpq	%r10, %rdi
	jne	.L5
	movl	3999996+D(%rip), %esi
	xorl	%eax, %eax
	leaq	.LC2(%rip), %rdi
	movl	$1000, r(%rip)
	movl	$1000, h(%rip)
	call	printf@PLT
	jmp	.L2
.L18:
	xorl	%edi, %edi
	call	exit@PLT
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.globl	r
	.bss
	.align 4
	.type	r, @object
	.size	r, 4
r:
	.zero	4
	.globl	h
	.align 4
	.type	h, @object
	.size	h, 4
h:
	.zero	4
	.globl	n
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	a
	.align 32
	.type	a, @object
	.size	a, 4000000
a:
	.zero	4000000
	.globl	D
	.align 32
	.type	D, @object
	.size	D, 4000000
D:
	.zero	4000000
	.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:

#define max(x,y)((x)>(y)?(x):(y))
D[1000][1000],a[1000][1000];
n,h,r;
main(){
	for(;scanf("%d",&n),n;){
		memset(D,0,sizeof(D));
		memset(a,0,sizeof(a));
		for(;n--;){
			scanf("%d%d",&h,&r);
			a[h][r]=1;
		}
		scanf("%d",&n);
		for(;n--;){
			scanf("%d%d",&h,&r);
			a[h][r]=1;
		}
		for(h=1;h<1000;h++){
			for(r=1;r<1000;r++)
				D[h][r]=max(max(D[h-1][r],D[h][r-1]),D[h-1][r-1]+a[h][r]);
		}
		printf("%d\n",D[999][999]);
	}
	exit(0);
}
6
1 1
4 3
6 5
8 6
10 10
14 14
5
2 1
5 4
6 6
9 8
15 10
4
1 1
4 3
6 5
8 6
3
2 2
5 4
6 6
4
1 1
4 3
6 5
8 6
4
10 10
12 11
18 15
24 20
0
 6
1 1
4 3
6 5
8 6
10 10
14 14
5
2 2
5 4
6 6
9 8
15 10
4
1 1
4 3
6 5
8 6
3
2 2
5 4
6 6
4
1 2
4 3
6 5
8 6
4
10 10
12 11
18 15
24 20
0
 6
1 1
4 3
6 5
8 6
10 10
14 14
5
2 2
5 4
6 6
9 8
15 10
4
1 1
4 3
6 5
8 6
3
4 2
5 4
6 6
4
1 1
4 3
6 5
8 6
4
10 10
12 11
18 15
24 20
0
 6
1 1
4 3
6 0
8 6
10 10
14 14
5
2 2
5 4
6 6
9 8
15 10
4
1 1
4 3
6 5
8 6
3
2 2
9 4
6 6
4
1 2
4 3
6 5
8 6
4
10 10
12 11
18 15
24 20
0
 6
1 1
4 3
6 0
8 6
10 10
14 14
5
2 2
5 4
6 6
9 10
15 10
4
1 1
4 3
6 5
12 6
3
2 2
9 4
9 6
4
1 2
4 3
6 5
8 6
4
10 10
12 11
18 15
24 20
0
 6
1 1
4 3
6 0
8 6
10 10
14 14
5
2 2
5 4
6 6
9 8
15 10
4
2 1
4 3
6 5
8 6
3
2 2
9 4
6 6
4
1 2
4 3
6 5
8 6
4
10 10
12 11
18 15
24 20
0
 6
1 1
4 3
6 0
8 6
10 10
14 14
5
2 2
5 4
6 6
9 10
15 10
4
1 1
4 3
6 5
12 6
3
1 2
9 4
9 6
4
1 2
4 3
6 5
8 6
4
10 10
12 11
18 15
24 20
0
 6
1 1
4 3
6 5
8 6
10 10
14 14
5
2 2
5 4
6 6
9 15
15 20
4
1 1
4 3
6 3
8 6
3
4 2
5 4
6 6
4
1 1
4 3
6 5
8 6
4
10 10
12 11
18 15
24 20
0
 6
0 1
4 3
6 5
8 6
10 10
14 14
5
2 1
5 5
6 6
9 8
15 10
4
1 1
4 3
6 5
8 6
3
2 2
5 4
6 6
4
1 1
4 3
6 5
8 6
4
10 10
12 11
18 15
24 20
0
 6
1 1
4 3
6 5
8 6
10 10
14 14
5
2 2
5 4
6 6
9 15
15 10
4
1 1
4 3
6 5
8 11
3
4 2
5 4
6 7
4
1 1
4 3
6 5
8 6
4
10 2
12 11
18 15
24 20
0

8
6
8
 9
6
8
 9
5
8
 8
5
8
 7
5
8
 8
4
8
 7
4
8
 9
4
8
 7
6
8
 8
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
#define max(x,y)((x)>(y)?(x):(y))
D[1000][1000],a[1000][1000];
n,h,r;
main(){
	for(;scanf("%d",&n),n;){
		memset(D,0,sizeof(D));
		memset(a,0,sizeof(a));
		for(;n--;){
			scanf("%d%d",&h,&r);
			a[h][r]=1;
		}
		scanf("%d",&n);
		for(;n--;){
			scanf("%d%d",&h,&r);
			a[h][r]=1;
		}
		for(h=1;h<1000;h++){
			for(r=1;r<1000;r++)
				D[h][r]=max(max(D[h-1][r],D[h][r-1]),D[h-1][r-1]+a[h][r]);
		}
		printf("%d\n",D[999][999]);
	}
	exit(0);
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	D
	.bss
	.align 32
	.type	D, @object
	.size	D, 4000000
D:
	.zero	4000000
	.globl	a
	.align 32
	.type	a, @object
	.size	a, 4000000
a:
	.zero	4000000
	.globl	n
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	h
	.align 4
	.type	h, @object
	.size	h, 4
h:
	.zero	4
	.globl	r
	.align 4
	.type	r, @object
	.size	r, 4
r:
	.zero	4
	.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
	jmp	.L2
.L11:
	movl	$4000000, %edx
	movl	$0, %esi
	leaq	D(%rip), %rax
	movq	%rax, %rdi
	call	memset@PLT
	movl	$4000000, %edx
	movl	$0, %esi
	leaq	a(%rip), %rax
	movq	%rax, %rdi
	call	memset@PLT
	jmp	.L3
.L4:
	leaq	r(%rip), %rax
	movq	%rax, %rdx
	leaq	h(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	scanf@PLT
	movl	h(%rip), %eax
	movl	r(%rip), %edx
	movslq	%edx, %rdx
	cltq
	imulq	$1000, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	$1, (%rdx,%rax)
.L3:
	movl	n(%rip), %eax
	leal	-1(%rax), %edx
	movl	%edx, n(%rip)
	testl	%eax, %eax
	jne	.L4
	leaq	n(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	scanf@PLT
	jmp	.L5
.L6:
	leaq	r(%rip), %rax
	movq	%rax, %rdx
	leaq	h(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	scanf@PLT
	movl	h(%rip), %eax
	movl	r(%rip), %edx
	movslq	%edx, %rdx
	cltq
	imulq	$1000, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	$1, (%rdx,%rax)
.L5:
	movl	n(%rip), %eax
	leal	-1(%rax), %edx
	movl	%edx, n(%rip)
	testl	%eax, %eax
	jne	.L6
	movl	$1, h(%rip)
	jmp	.L7
.L10:
	movl	$1, r(%rip)
	jmp	.L8
.L9:
	movl	h(%rip), %eax
	leal	-1(%rax), %edx
	movl	r(%rip), %eax
	subl	$1, %eax
	movslq	%eax, %rcx
	movslq	%edx, %rax
	imulq	$1000, %rax, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	D(%rip), %rax
	movl	(%rdx,%rax), %ecx
	movl	h(%rip), %eax
	movl	r(%rip), %edx
	movslq	%edx, %rdx
	cltq
	imulq	$1000, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%eax, %ecx
	movl	h(%rip), %eax
	movl	r(%rip), %edx
	subl	$1, %edx
	movslq	%edx, %rdx
	cltq
	imulq	$1000, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	D(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	h(%rip), %eax
	leal	-1(%rax), %esi
	movl	r(%rip), %eax
	movslq	%eax, %rdi
	movslq	%esi, %rax
	imulq	$1000, %rax, %rax
	addq	%rdi, %rax
	leaq	0(,%rax,4), %rsi
	leaq	D(%rip), %rax
	movl	(%rsi,%rax), %eax
	cmpl	%eax, %edx
	cmovge	%edx, %eax
	movl	h(%rip), %edx
	movl	r(%rip), %esi
	cmpl	%eax, %ecx
	cmovge	%ecx, %eax
	movslq	%esi, %rcx
	movslq	%edx, %rdx
	imulq	$1000, %rdx, %rdx
	addq	%rcx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	D(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movl	r(%rip), %eax
	addl	$1, %eax
	movl	%eax, r(%rip)
.L8:
	movl	r(%rip), %eax
	cmpl	$999, %eax
	jle	.L9
	movl	h(%rip), %eax
	addl	$1, %eax
	movl	%eax, h(%rip)
.L7:
	movl	h(%rip), %eax
	cmpl	$999, %eax
	jle	.L10
	movl	3999996+D(%rip), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L2:
	leaq	n(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	scanf@PLT
	movl	n(%rip), %eax
	testl	%eax, %eax
	jne	.L11
	movl	$0, %edi
	call	exit@PLT
	.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	D
	.bss
	.align 32
	.type	D, @object
	.size	D, 4000000
D:
	.zero	4000000
	.globl	a
	.align 32
	.type	a, @object
	.size	a, 4000000
a:
	.zero	4000000
	.globl	n
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	h
	.align 4
	.type	h, @object
	.size	h, 4
h:
	.zero	4
	.globl	r
	.align 4
	.type	r, @object
	.size	r, 4
r:
	.zero	4
	.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
	jmp	.L2
.L11:
	movl	$4000000, %edx
	movl	$0, %esi
	leaq	D(%rip), %rax
	movq	%rax, %rdi
	call	memset@PLT
	movl	$4000000, %edx
	movl	$0, %esi
	leaq	a(%rip), %rax
	movq	%rax, %rdi
	call	memset@PLT
	jmp	.L3
.L4:
	leaq	r(%rip), %rax
	movq	%rax, %rdx
	leaq	h(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	scanf@PLT
	movl	h(%rip), %eax
	movl	r(%rip), %edx
	movslq	%edx, %rdx
	cltq
	imulq	$1000, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	$1, (%rdx,%rax)
.L3:
	movl	n(%rip), %eax
	leal	-1(%rax), %edx
	movl	%edx, n(%rip)
	testl	%eax, %eax
	jne	.L4
	leaq	n(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	scanf@PLT
	jmp	.L5
.L6:
	leaq	r(%rip), %rax
	movq	%rax, %rdx
	leaq	h(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	scanf@PLT
	movl	h(%rip), %eax
	movl	r(%rip), %edx
	movslq	%edx, %rdx
	cltq
	imulq	$1000, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	$1, (%rdx,%rax)
.L5:
	movl	n(%rip), %eax
	leal	-1(%rax), %edx
	movl	%edx, n(%rip)
	testl	%eax, %eax
	jne	.L6
	movl	$1, h(%rip)
	jmp	.L7
.L10:
	movl	$1, r(%rip)
	jmp	.L8
.L9:
	movl	h(%rip), %eax
	leal	-1(%rax), %edx
	movl	r(%rip), %eax
	subl	$1, %eax
	movslq	%eax, %rcx
	movslq	%edx, %rax
	imulq	$1000, %rax, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	D(%rip), %rax
	movl	(%rdx,%rax), %ecx
	movl	h(%rip), %eax
	movl	r(%rip), %edx
	movslq	%edx, %rdx
	cltq
	imulq	$1000, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%eax, %ecx
	movl	h(%rip), %eax
	movl	r(%rip), %edx
	subl	$1, %edx
	movslq	%edx, %rdx
	cltq
	imulq	$1000, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	D(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	h(%rip), %eax
	leal	-1(%rax), %esi
	movl	r(%rip), %eax
	movslq	%eax, %rdi
	movslq	%esi, %rax
	imulq	$1000, %rax, %rax
	addq	%rdi, %rax
	leaq	0(,%rax,4), %rsi
	leaq	D(%rip), %rax
	movl	(%rsi,%rax), %eax
	cmpl	%eax, %edx
	cmovge	%edx, %eax
	movl	h(%rip), %edx
	movl	r(%rip), %esi
	cmpl	%eax, %ecx
	cmovge	%ecx, %eax
	movslq	%esi, %rcx
	movslq	%edx, %rdx
	imulq	$1000, %rdx, %rdx
	addq	%rcx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	D(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movl	r(%rip), %eax
	addl	$1, %eax
	movl	%eax, r(%rip)
.L8:
	movl	r(%rip), %eax
	cmpl	$999, %eax
	jle	.L9
	movl	h(%rip), %eax
	addl	$1, %eax
	movl	%eax, h(%rip)
.L7:
	movl	h(%rip), %eax
	cmpl	$999, %eax
	jle	.L10
	movl	3999996+D(%rip), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L2:
	leaq	n(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	scanf@PLT
	movl	n(%rip), %eax
	testl	%eax, %eax
	jne	.L11
	movl	$0, %edi
	call	exit@PLT
	.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:
