Given the following C code and 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);
}```

Assembly Code:

```assembly
	.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:
```

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.
Optimized Assembly Code:

user
```assembly
	.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
```assembly
	.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:
```
```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);
}```
Given the following C 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);
}```

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.
Optimized Assembly Code:

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 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);
}```

Assembly Code:

```assembly
	.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:
```

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.
Optimized Assembly Code:

train
```assembly
	.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:
```