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>
#define max(a,b) ((a)>(b) ? (a) : (b))
#define max3(a,b,c) max(max((a), (b)),(c))
main(){
    int n,m,N;
    int i,j;
    int h,r;
    int map[1000][1000]={{0,},};
    while(scanf("%d",&n)==1){
        for(i=0;i<1000;i++)
            for(j=0;j<1000;j++)
                map[i][j]=0;
        if(!n)break;
        for(i=0;i<n;i++){
            scanf("%d %d",&h,&r);
            map[h][r]=1;
        }
        scanf("%d",&m);
        for(;i<n+m;i++){
            scanf("%d %d",&h,&r);
            map[h][r]=1;
        }
        for(i=1;i<1000;i++){
            for(j=1;j<1000;j++){
                map[i][j]=max3(map[i][j]+map[i-1][j-1],map[i-1][j],map[i][j-1]);
            }
        }
        printf("%d\n",map[999][999]);
    }
    return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.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	-3997696(%rsp), %r11
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	subq	$2352, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-4000016(%rbp), %rax
	movl	$4000000, %edx
	movl	$0, %esi
	movq	%rax, %rdi
	call	memset@PLT
	jmp	.L2
.L17:
	movl	$0, -4000024(%rbp)
	jmp	.L3
.L6:
	movl	$0, -4000020(%rbp)
	jmp	.L4
.L5:
	movl	-4000020(%rbp), %eax
	movslq	%eax, %rdx
	movl	-4000024(%rbp), %eax
	cltq
	imulq	$1000, %rax, %rax
	addq	%rdx, %rax
	movl	$0, -4000016(%rbp,%rax,4)
	addl	$1, -4000020(%rbp)
.L4:
	cmpl	$999, -4000020(%rbp)
	jle	.L5
	addl	$1, -4000024(%rbp)
.L3:
	cmpl	$999, -4000024(%rbp)
	jle	.L6
	movl	-4000040(%rbp), %eax
	testl	%eax, %eax
	je	.L20
	movl	$0, -4000024(%rbp)
	jmp	.L9
.L10:
	leaq	-4000028(%rbp), %rdx
	leaq	-4000032(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-4000032(%rbp), %eax
	movl	-4000028(%rbp), %edx
	movslq	%edx, %rdx
	cltq
	imulq	$1000, %rax, %rax
	addq	%rdx, %rax
	movl	$1, -4000016(%rbp,%rax,4)
	addl	$1, -4000024(%rbp)
.L9:
	movl	-4000040(%rbp), %eax
	cmpl	%eax, -4000024(%rbp)
	jl	.L10
	leaq	-4000036(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	jmp	.L11
.L12:
	leaq	-4000028(%rbp), %rdx
	leaq	-4000032(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-4000032(%rbp), %eax
	movl	-4000028(%rbp), %edx
	movslq	%edx, %rdx
	cltq
	imulq	$1000, %rax, %rax
	addq	%rdx, %rax
	movl	$1, -4000016(%rbp,%rax,4)
	addl	$1, -4000024(%rbp)
.L11:
	movl	-4000040(%rbp), %edx
	movl	-4000036(%rbp), %eax
	addl	%edx, %eax
	cmpl	%eax, -4000024(%rbp)
	jl	.L12
	movl	$1, -4000024(%rbp)
	jmp	.L13
.L16:
	movl	$1, -4000020(%rbp)
	jmp	.L14
.L15:
	movl	-4000020(%rbp), %eax
	subl	$1, %eax
	movslq	%eax, %rdx
	movl	-4000024(%rbp), %eax
	cltq
	imulq	$1000, %rax, %rax
	addq	%rdx, %rax
	movl	-4000016(%rbp,%rax,4), %edx
	movl	-4000024(%rbp), %eax
	leal	-1(%rax), %ecx
	movl	-4000020(%rbp), %eax
	movslq	%eax, %rsi
	movslq	%ecx, %rax
	imulq	$1000, %rax, %rax
	addq	%rsi, %rax
	movl	-4000016(%rbp,%rax,4), %eax
	movl	-4000020(%rbp), %ecx
	movslq	%ecx, %rsi
	movl	-4000024(%rbp), %ecx
	movslq	%ecx, %rcx
	imulq	$1000, %rcx, %rcx
	addq	%rsi, %rcx
	movl	-4000016(%rbp,%rcx,4), %edi
	movl	-4000024(%rbp), %ecx
	leal	-1(%rcx), %esi
	movl	-4000020(%rbp), %ecx
	subl	$1, %ecx
	movslq	%ecx, %r8
	movslq	%esi, %rcx
	imulq	$1000, %rcx, %rcx
	addq	%r8, %rcx
	movl	-4000016(%rbp,%rcx,4), %ecx
	addl	%edi, %ecx
	cmpl	%ecx, %eax
	cmovl	%ecx, %eax
	cmpl	%eax, %edx
	cmovge	%edx, %eax
	movl	-4000020(%rbp), %edx
	movslq	%edx, %rcx
	movl	-4000024(%rbp), %edx
	movslq	%edx, %rdx
	imulq	$1000, %rdx, %rdx
	addq	%rcx, %rdx
	movl	%eax, -4000016(%rbp,%rdx,4)
	addl	$1, -4000020(%rbp)
.L14:
	cmpl	$999, -4000020(%rbp)
	jle	.L15
	addl	$1, -4000024(%rbp)
.L13:
	cmpl	$999, -4000024(%rbp)
	jle	.L16
	movl	-20(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L2:
	leaq	-4000040(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	cmpl	$1, %eax
	je	.L17
	jmp	.L8
.L20:
	nop
.L8:
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L19
	call	__stack_chk_fail@PLT
.L19:
	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	-3997696(%rsp), %r11
	.cfi_def_cfa 11, 3997752
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	.cfi_def_cfa_register 7
	subq	$2344, %rsp
	.cfi_def_cfa_offset 4000096
	leaq	.LC1(%rip), %rbp
	leaq	.LC0(%rip), %rbx
	movq	%fs:40, %rax
	movq	%rax, 4000024(%rsp)
	xorl	%eax, %eax
	movq	%rsp, %r13
.L2:
	xorl	%eax, %eax
	movq	%r13, %rsi
	movq	%rbp, %rdi
	call	__isoc99_scanf@PLT
	cmpl	$1, %eax
	jne	.L11
	leaq	16(%rsp), %rdi
	movl	$4000000, %edx
	xorl	%esi, %esi
	call	memset@PLT
	movl	(%rsp), %eax
	testl	%eax, %eax
	je	.L11
	movl	$0, %r14d
	jle	.L3
	leaq	12(%rsp), %r12
	leaq	8(%rsp), %r15
.L4:
	movq	%r12, %rdx
	movq	%r15, %rsi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movslq	8(%rsp), %rax
	movslq	12(%rsp), %rcx
	addl	$1, %r14d
	imulq	$1000, %rax, %rax
	addq	%rcx, %rax
	movl	$1, 16(%rsp,%rax,4)
	cmpl	%r14d, (%rsp)
	jg	.L4
.L3:
	leaq	4(%rsp), %rsi
	movq	%rbp, %rdi
	leaq	12(%rsp), %r12
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	4(%rsp), %eax
	addl	(%rsp), %eax
	leaq	8(%rsp), %r15
	cmpl	%eax, %r14d
	jge	.L7
.L5:
	movq	%r12, %rdx
	movq	%r15, %rsi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movslq	8(%rsp), %rax
	movslq	12(%rsp), %rcx
	addl	$1, %r14d
	imulq	$1000, %rax, %rax
	addq	%rcx, %rax
	movl	$1, 16(%rsp,%rax,4)
	movl	4(%rsp), %eax
	addl	(%rsp), %eax
	cmpl	%r14d, %eax
	jg	.L5
.L7:
	leaq	4020(%rsp), %rsi
	movl	$1, %edi
	xorl	%r8d, %r8d
	movq	$-4000, %r9
	.p2align 4,,10
	.p2align 3
.L6:
	movl	-4(%rsi), %r10d
	movl	-4004(%rsi), %eax
	leal	-1(%rdi), %edx
	movq	%rsi, %r11
	movl	$1, %r14d
.L9:
	leaq	(%r11,%r9), %r15
	addl	(%r11), %eax
	movl	(%r15,%r8), %ecx
	cmpl	%ecx, %eax
	cmovl	%ecx, %eax
	cmpl	%r10d, %eax
	cmovge	%eax, %r10d
	addl	4(%r11), %ecx
	movl	%r10d, (%r11)
	movl	4(%r15,%r8), %eax
	cmpl	%eax, %ecx
	cmovl	%eax, %ecx
	cmpl	%r10d, %ecx
	cmovge	%ecx, %r10d
	addl	$2, %r14d
	addq	$8, %r11
	movl	%r10d, -4(%r11)
	cmpl	$999, %r14d
	jne	.L9
	movslq	%edi, %rcx
	movl	3988(%rsi), %r10d
	movslq	%edx, %rdx
	imulq	$4000, %rcx, %rcx
	movl	4012(%rsp,%rcx), %eax
	addl	-12(%rsi), %eax
	cmpl	%r10d, %eax
	cmovl	%r10d, %eax
	imulq	$4000, %rdx, %rdx
	movl	4012(%rsp,%rdx), %edx
	cmpl	%edx, %eax
	cmovl	%edx, %eax
	addl	$1, %edi
	addq	$4000, %rsi
	subq	$4000, %r9
	addq	$4000, %r8
	movl	%eax, 4012(%rsp,%rcx)
	cmpl	$1000, %edi
	jne	.L6
	movl	4000012(%rsp), %edx
	leaq	.LC2(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L2
.L11:
	movq	4000024(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L30
	addq	$4000040, %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
.L30:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.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:

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	-3997696(%rsp), %r11
	.cfi_def_cfa 11, 3997752
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	.cfi_def_cfa_register 7
	subq	$2344, %rsp
	.cfi_def_cfa_offset 4000096
	leaq	.LC1(%rip), %rbp
	leaq	.LC0(%rip), %rbx
	movq	%fs:40, %rax
	movq	%rax, 4000024(%rsp)
	xorl	%eax, %eax
	movq	%rsp, %r13
.L2:
	xorl	%eax, %eax
	movq	%r13, %rsi
	movq	%rbp, %rdi
	call	__isoc99_scanf@PLT
	cmpl	$1, %eax
	jne	.L11
	leaq	16(%rsp), %rdi
	movl	$4000000, %edx
	xorl	%esi, %esi
	call	memset@PLT
	movl	(%rsp), %eax
	testl	%eax, %eax
	je	.L11
	movl	$0, %r14d
	jle	.L3
	leaq	12(%rsp), %r12
	leaq	8(%rsp), %r15
.L4:
	movq	%r12, %rdx
	movq	%r15, %rsi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movslq	8(%rsp), %rax
	movslq	12(%rsp), %rcx
	addl	$1, %r14d
	imulq	$1000, %rax, %rax
	addq	%rcx, %rax
	movl	$1, 16(%rsp,%rax,4)
	cmpl	%r14d, (%rsp)
	jg	.L4
.L3:
	leaq	4(%rsp), %rsi
	movq	%rbp, %rdi
	leaq	12(%rsp), %r12
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	4(%rsp), %eax
	addl	(%rsp), %eax
	leaq	8(%rsp), %r15
	cmpl	%eax, %r14d
	jge	.L7
.L5:
	movq	%r12, %rdx
	movq	%r15, %rsi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movslq	8(%rsp), %rax
	movslq	12(%rsp), %rcx
	addl	$1, %r14d
	imulq	$1000, %rax, %rax
	addq	%rcx, %rax
	movl	$1, 16(%rsp,%rax,4)
	movl	4(%rsp), %eax
	addl	(%rsp), %eax
	cmpl	%r14d, %eax
	jg	.L5
.L7:
	leaq	4020(%rsp), %rsi
	movl	$1, %edi
	xorl	%r8d, %r8d
	movq	$-4000, %r9
	.p2align 4,,10
	.p2align 3
.L6:
	movl	-4(%rsi), %r10d
	movl	-4004(%rsi), %eax
	leal	-1(%rdi), %edx
	movq	%rsi, %r11
	movl	$1, %r14d
.L9:
	leaq	(%r11,%r9), %r15
	addl	(%r11), %eax
	movl	(%r15,%r8), %ecx
	cmpl	%ecx, %eax
	cmovl	%ecx, %eax
	cmpl	%r10d, %eax
	cmovge	%eax, %r10d
	addl	4(%r11), %ecx
	movl	%r10d, (%r11)
	movl	4(%r15,%r8), %eax
	cmpl	%eax, %ecx
	cmovl	%eax, %ecx
	cmpl	%r10d, %ecx
	cmovge	%ecx, %r10d
	addl	$2, %r14d
	addq	$8, %r11
	movl	%r10d, -4(%r11)
	cmpl	$999, %r14d
	jne	.L9
	movslq	%edi, %rcx
	movl	3988(%rsi), %r10d
	movslq	%edx, %rdx
	imulq	$4000, %rcx, %rcx
	movl	4012(%rsp,%rcx), %eax
	addl	-12(%rsi), %eax
	cmpl	%r10d, %eax
	cmovl	%r10d, %eax
	imulq	$4000, %rdx, %rdx
	movl	4012(%rsp,%rdx), %edx
	cmpl	%edx, %eax
	cmovl	%edx, %eax
	addl	$1, %edi
	addq	$4000, %rsi
	subq	$4000, %r9
	addq	$4000, %r8
	movl	%eax, 4012(%rsp,%rcx)
	cmpl	$1000, %edi
	jne	.L6
	movl	4000012(%rsp), %edx
	leaq	.LC2(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L2
.L11:
	movq	4000024(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L30
	addq	$4000040, %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
.L30:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.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:

#include <stdio.h>
#define max(a,b) ((a)>(b) ? (a) : (b))
#define max3(a,b,c) max(max((a), (b)),(c))
main(){
    int n,m,N;
    int i,j;
    int h,r;
    int map[1000][1000]={{0,},};
    while(scanf("%d",&n)==1){
        for(i=0;i<1000;i++)
            for(j=0;j<1000;j++)
                map[i][j]=0;
        if(!n)break;
        for(i=0;i<n;i++){
            scanf("%d %d",&h,&r);
            map[h][r]=1;
        }
        scanf("%d",&m);
        for(;i<n+m;i++){
            scanf("%d %d",&h,&r);
            map[h][r]=1;
        }
        for(i=1;i<1000;i++){
            for(j=1;j<1000;j++){
                map[i][j]=max3(map[i][j]+map[i-1][j-1],map[i-1][j],map[i][j-1]);
            }
        }
        printf("%d\n",map[999][999]);
    }
    return 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
#include <stdio.h>
#define max(a,b) ((a)>(b) ? (a) : (b))
#define max3(a,b,c) max(max((a), (b)),(c))
main(){
    int n,m,N;
    int i,j;
    int h,r;
    int map[1000][1000]={{0,},};
    while(scanf("%d",&n)==1){
        for(i=0;i<1000;i++)
            for(j=0;j<1000;j++)
                map[i][j]=0;
        if(!n)break;
        for(i=0;i<n;i++){
            scanf("%d %d",&h,&r);
            map[h][r]=1;
        }
        scanf("%d",&m);
        for(;i<n+m;i++){
            scanf("%d %d",&h,&r);
            map[h][r]=1;
        }
        for(i=1;i<1000;i++){
            for(j=1;j<1000;j++){
                map[i][j]=max3(map[i][j]+map[i-1][j-1],map[i-1][j],map[i][j-1]);
            }
        }
        printf("%d\n",map[999][999]);
    }
    return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.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	-3997696(%rsp), %r11
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	subq	$2352, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-4000016(%rbp), %rax
	movl	$4000000, %edx
	movl	$0, %esi
	movq	%rax, %rdi
	call	memset@PLT
	jmp	.L2
.L17:
	movl	$0, -4000024(%rbp)
	jmp	.L3
.L6:
	movl	$0, -4000020(%rbp)
	jmp	.L4
.L5:
	movl	-4000020(%rbp), %eax
	movslq	%eax, %rdx
	movl	-4000024(%rbp), %eax
	cltq
	imulq	$1000, %rax, %rax
	addq	%rdx, %rax
	movl	$0, -4000016(%rbp,%rax,4)
	addl	$1, -4000020(%rbp)
.L4:
	cmpl	$999, -4000020(%rbp)
	jle	.L5
	addl	$1, -4000024(%rbp)
.L3:
	cmpl	$999, -4000024(%rbp)
	jle	.L6
	movl	-4000040(%rbp), %eax
	testl	%eax, %eax
	je	.L20
	movl	$0, -4000024(%rbp)
	jmp	.L9
.L10:
	leaq	-4000028(%rbp), %rdx
	leaq	-4000032(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-4000032(%rbp), %eax
	movl	-4000028(%rbp), %edx
	movslq	%edx, %rdx
	cltq
	imulq	$1000, %rax, %rax
	addq	%rdx, %rax
	movl	$1, -4000016(%rbp,%rax,4)
	addl	$1, -4000024(%rbp)
.L9:
	movl	-4000040(%rbp), %eax
	cmpl	%eax, -4000024(%rbp)
	jl	.L10
	leaq	-4000036(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	jmp	.L11
.L12:
	leaq	-4000028(%rbp), %rdx
	leaq	-4000032(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-4000032(%rbp), %eax
	movl	-4000028(%rbp), %edx
	movslq	%edx, %rdx
	cltq
	imulq	$1000, %rax, %rax
	addq	%rdx, %rax
	movl	$1, -4000016(%rbp,%rax,4)
	addl	$1, -4000024(%rbp)
.L11:
	movl	-4000040(%rbp), %edx
	movl	-4000036(%rbp), %eax
	addl	%edx, %eax
	cmpl	%eax, -4000024(%rbp)
	jl	.L12
	movl	$1, -4000024(%rbp)
	jmp	.L13
.L16:
	movl	$1, -4000020(%rbp)
	jmp	.L14
.L15:
	movl	-4000020(%rbp), %eax
	subl	$1, %eax
	movslq	%eax, %rdx
	movl	-4000024(%rbp), %eax
	cltq
	imulq	$1000, %rax, %rax
	addq	%rdx, %rax
	movl	-4000016(%rbp,%rax,4), %edx
	movl	-4000024(%rbp), %eax
	leal	-1(%rax), %ecx
	movl	-4000020(%rbp), %eax
	movslq	%eax, %rsi
	movslq	%ecx, %rax
	imulq	$1000, %rax, %rax
	addq	%rsi, %rax
	movl	-4000016(%rbp,%rax,4), %eax
	movl	-4000020(%rbp), %ecx
	movslq	%ecx, %rsi
	movl	-4000024(%rbp), %ecx
	movslq	%ecx, %rcx
	imulq	$1000, %rcx, %rcx
	addq	%rsi, %rcx
	movl	-4000016(%rbp,%rcx,4), %edi
	movl	-4000024(%rbp), %ecx
	leal	-1(%rcx), %esi
	movl	-4000020(%rbp), %ecx
	subl	$1, %ecx
	movslq	%ecx, %r8
	movslq	%esi, %rcx
	imulq	$1000, %rcx, %rcx
	addq	%r8, %rcx
	movl	-4000016(%rbp,%rcx,4), %ecx
	addl	%edi, %ecx
	cmpl	%ecx, %eax
	cmovl	%ecx, %eax
	cmpl	%eax, %edx
	cmovge	%edx, %eax
	movl	-4000020(%rbp), %edx
	movslq	%edx, %rcx
	movl	-4000024(%rbp), %edx
	movslq	%edx, %rdx
	imulq	$1000, %rdx, %rdx
	addq	%rcx, %rdx
	movl	%eax, -4000016(%rbp,%rdx,4)
	addl	$1, -4000020(%rbp)
.L14:
	cmpl	$999, -4000020(%rbp)
	jle	.L15
	addl	$1, -4000024(%rbp)
.L13:
	cmpl	$999, -4000024(%rbp)
	jle	.L16
	movl	-20(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L2:
	leaq	-4000040(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	cmpl	$1, %eax
	je	.L17
	jmp	.L8
.L20:
	nop
.L8:
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L19
	call	__stack_chk_fail@PLT
.L19:
	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
	.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	-3997696(%rsp), %r11
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	subq	$2352, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-4000016(%rbp), %rax
	movl	$4000000, %edx
	movl	$0, %esi
	movq	%rax, %rdi
	call	memset@PLT
	jmp	.L2
.L17:
	movl	$0, -4000024(%rbp)
	jmp	.L3
.L6:
	movl	$0, -4000020(%rbp)
	jmp	.L4
.L5:
	movl	-4000020(%rbp), %eax
	movslq	%eax, %rdx
	movl	-4000024(%rbp), %eax
	cltq
	imulq	$1000, %rax, %rax
	addq	%rdx, %rax
	movl	$0, -4000016(%rbp,%rax,4)
	addl	$1, -4000020(%rbp)
.L4:
	cmpl	$999, -4000020(%rbp)
	jle	.L5
	addl	$1, -4000024(%rbp)
.L3:
	cmpl	$999, -4000024(%rbp)
	jle	.L6
	movl	-4000040(%rbp), %eax
	testl	%eax, %eax
	je	.L20
	movl	$0, -4000024(%rbp)
	jmp	.L9
.L10:
	leaq	-4000028(%rbp), %rdx
	leaq	-4000032(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-4000032(%rbp), %eax
	movl	-4000028(%rbp), %edx
	movslq	%edx, %rdx
	cltq
	imulq	$1000, %rax, %rax
	addq	%rdx, %rax
	movl	$1, -4000016(%rbp,%rax,4)
	addl	$1, -4000024(%rbp)
.L9:
	movl	-4000040(%rbp), %eax
	cmpl	%eax, -4000024(%rbp)
	jl	.L10
	leaq	-4000036(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	jmp	.L11
.L12:
	leaq	-4000028(%rbp), %rdx
	leaq	-4000032(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-4000032(%rbp), %eax
	movl	-4000028(%rbp), %edx
	movslq	%edx, %rdx
	cltq
	imulq	$1000, %rax, %rax
	addq	%rdx, %rax
	movl	$1, -4000016(%rbp,%rax,4)
	addl	$1, -4000024(%rbp)
.L11:
	movl	-4000040(%rbp), %edx
	movl	-4000036(%rbp), %eax
	addl	%edx, %eax
	cmpl	%eax, -4000024(%rbp)
	jl	.L12
	movl	$1, -4000024(%rbp)
	jmp	.L13
.L16:
	movl	$1, -4000020(%rbp)
	jmp	.L14
.L15:
	movl	-4000020(%rbp), %eax
	subl	$1, %eax
	movslq	%eax, %rdx
	movl	-4000024(%rbp), %eax
	cltq
	imulq	$1000, %rax, %rax
	addq	%rdx, %rax
	movl	-4000016(%rbp,%rax,4), %edx
	movl	-4000024(%rbp), %eax
	leal	-1(%rax), %ecx
	movl	-4000020(%rbp), %eax
	movslq	%eax, %rsi
	movslq	%ecx, %rax
	imulq	$1000, %rax, %rax
	addq	%rsi, %rax
	movl	-4000016(%rbp,%rax,4), %eax
	movl	-4000020(%rbp), %ecx
	movslq	%ecx, %rsi
	movl	-4000024(%rbp), %ecx
	movslq	%ecx, %rcx
	imulq	$1000, %rcx, %rcx
	addq	%rsi, %rcx
	movl	-4000016(%rbp,%rcx,4), %edi
	movl	-4000024(%rbp), %ecx
	leal	-1(%rcx), %esi
	movl	-4000020(%rbp), %ecx
	subl	$1, %ecx
	movslq	%ecx, %r8
	movslq	%esi, %rcx
	imulq	$1000, %rcx, %rcx
	addq	%r8, %rcx
	movl	-4000016(%rbp,%rcx,4), %ecx
	addl	%edi, %ecx
	cmpl	%ecx, %eax
	cmovl	%ecx, %eax
	cmpl	%eax, %edx
	cmovge	%edx, %eax
	movl	-4000020(%rbp), %edx
	movslq	%edx, %rcx
	movl	-4000024(%rbp), %edx
	movslq	%edx, %rdx
	imulq	$1000, %rdx, %rdx
	addq	%rcx, %rdx
	movl	%eax, -4000016(%rbp,%rdx,4)
	addl	$1, -4000020(%rbp)
.L14:
	cmpl	$999, -4000020(%rbp)
	jle	.L15
	addl	$1, -4000024(%rbp)
.L13:
	cmpl	$999, -4000024(%rbp)
	jle	.L16
	movl	-20(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L2:
	leaq	-4000040(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	cmpl	$1, %eax
	je	.L17
	jmp	.L8
.L20:
	nop
.L8:
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L19
	call	__stack_chk_fail@PLT
.L19:
	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:
