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))

int dwdp[2002][2002],updp[2002][2002],lfdp[2002][2002],ridp[2002][2002];

int main(void){
    register int i,j,ri,rj;
    int h,w;
    scanf("%d %d",&h,&w);
    getchar();
    char grid[h][w];
    for(i = 0;i < h;i++,getchar())for(j = 0;j < w;j++)scanf("%c",&grid[i][j]);
    //down and up
    for(j = 1;j <= w;j++)for(i = 1;i <= h;i++){
        ri = h - i + 1;

        if(grid[i-1][j-1] != '#')updp[i][j] = updp[i-1][j] + 1;

        if(grid[ri-1][j-1] != '#')dwdp[ri][j] = dwdp[ri+1][j] + 1;
    }
    //left and right
    for(i = 1;i <= h;i++)for(j = 1;j <= w;j++){
        rj = w - j + 1;

        if(grid[i-1][j-1] != '#')lfdp[i][j] = lfdp[i][j-1] + 1;

        if(grid[i-1][rj-1] != '#')ridp[i][rj] = ridp[i][rj+1] + 1;
    }
    int ans = 0;
    for(i = 0;i < h;i++)for(j = 0;j < w;j++)ans = max(ans,dwdp[i+1][j+1]+updp[i+1][j+1]+lfdp[i+1][j+1]+ridp[i+1][j+1]-3/*overlap*/);
    printf("%d",max(ans,0));
    return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	dwdp
	.bss
	.align 32
	.type	dwdp, @object
	.size	dwdp, 16032016
dwdp:
	.zero	16032016
	.globl	updp
	.align 32
	.type	updp, @object
	.size	updp, 16032016
updp:
	.zero	16032016
	.globl	lfdp
	.align 32
	.type	lfdp, @object
	.size	lfdp, 16032016
lfdp:
	.zero	16032016
	.globl	ridp
	.align 32
	.type	ridp, @object
	.size	ridp, 16032016
ridp:
	.zero	16032016
	.section	.rodata
.LC0:
	.string	"%d %d"
.LC1:
	.string	"%c"
.LC2:
	.string	"%d"
	.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
	pushq	%r15
	pushq	%r14
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	subq	$120, %rsp
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	.cfi_offset 12, -48
	.cfi_offset 3, -56
	movq	%fs:40, %rax
	movq	%rax, -56(%rbp)
	xorl	%eax, %eax
	movq	%rsp, %rax
	movq	%rax, -152(%rbp)
	leaq	-88(%rbp), %rdx
	leaq	-92(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	call	getchar@PLT
	movl	-88(%rbp), %ecx
	movl	-92(%rbp), %esi
	movslq	%ecx, %rax
	subq	$1, %rax
	movq	%rax, -80(%rbp)
	movslq	%ecx, %rax
	movq	%rax, %r12
	movl	$0, %r13d
	movslq	%ecx, %r13
	movslq	%esi, %rax
	subq	$1, %rax
	movq	%rax, -72(%rbp)
	movslq	%ecx, %rax
	movq	%rax, -112(%rbp)
	movq	$0, -104(%rbp)
	movslq	%esi, %rax
	movq	%rax, -128(%rbp)
	movq	$0, -120(%rbp)
	movq	-112(%rbp), %r10
	movq	-104(%rbp), %r11
	movq	%r11, %rdx
	movq	-128(%rbp), %r8
	movq	-120(%rbp), %r9
	imulq	%r8, %rdx
	movq	%r9, %rax
	imulq	%r10, %rax
	leaq	(%rdx,%rax), %rdi
	movq	%r10, %rax
	mulq	%r8
	addq	%rdx, %rdi
	movq	%rdi, %rdx
	movslq	%ecx, %rax
	movq	%rax, -144(%rbp)
	movq	$0, -136(%rbp)
	movslq	%esi, %rax
	movq	%rax, %r14
	movl	$0, %r15d
	movq	-144(%rbp), %r8
	movq	-136(%rbp), %r9
	movq	%r9, %rdx
	imulq	%r14, %rdx
	movq	%r8, %rax
	imulq	%r15, %rax
	leaq	(%rdx,%rax), %rdi
	movq	%r8, %rax
	mulq	%r14
	addq	%rdx, %rdi
	movq	%rdi, %rdx
	movslq	%ecx, %rdx
	movslq	%esi, %rax
	imulq	%rdx, %rax
	movl	$16, %edx
	subq	$1, %rdx
	addq	%rdx, %rax
	movl	$16, %esi
	movl	$0, %edx
	divq	%rsi
	imulq	$16, %rax, %rax
	movq	%rax, %rcx
	andq	$-4096, %rcx
	movq	%rsp, %rdx
	subq	%rcx, %rdx
.L2:
	cmpq	%rdx, %rsp
	je	.L3
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L2
.L3:
	movq	%rax, %rdx
	andl	$4095, %edx
	subq	%rdx, %rsp
	movq	%rax, %rdx
	andl	$4095, %edx
	testq	%rdx, %rdx
	je	.L4
	andl	$4095, %eax
	subq	$8, %rax
	addq	%rsp, %rax
	orq	$0, (%rax)
.L4:
	movq	%rsp, %rax
	addq	$0, %rax
	movq	%rax, -64(%rbp)
	movl	$0, %ebx
	jmp	.L5
.L8:
	movl	$0, %r12d
	jmp	.L6
.L7:
	movslq	%r12d, %rdx
	movslq	%ebx, %rax
	imulq	%r13, %rax
	addq	%rax, %rdx
	movq	-64(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, %r12d
.L6:
	movl	-88(%rbp), %eax
	cmpl	%eax, %r12d
	jl	.L7
	addl	$1, %ebx
	call	getchar@PLT
.L5:
	movl	-92(%rbp), %eax
	cmpl	%eax, %ebx
	jl	.L8
	movl	$1, %r12d
	jmp	.L9
.L14:
	movl	$1, %ebx
	jmp	.L10
.L13:
	movl	-92(%rbp), %eax
	subl	%ebx, %eax
	leal	1(%rax), %r14d
	leal	-1(%rbx), %eax
	leal	-1(%r12), %edx
	movq	-64(%rbp), %rcx
	movslq	%edx, %rdx
	cltq
	imulq	%r13, %rax
	addq	%rcx, %rdx
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	$35, %al
	je	.L11
	leal	-1(%rbx), %eax
	movslq	%r12d, %rdx
	cltq
	imulq	$2002, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	updp(%rip), %rax
	movl	(%rdx,%rax), %eax
	leal	1(%rax), %ecx
	movslq	%r12d, %rdx
	movslq	%ebx, %rax
	imulq	$2002, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	updp(%rip), %rax
	movl	%ecx, (%rdx,%rax)
.L11:
	leal	-1(%r14), %eax
	leal	-1(%r12), %edx
	movq	-64(%rbp), %rcx
	movslq	%edx, %rdx
	cltq
	imulq	%r13, %rax
	addq	%rcx, %rdx
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	$35, %al
	je	.L12
	leal	1(%r14), %eax
	movslq	%r12d, %rdx
	cltq
	imulq	$2002, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	dwdp(%rip), %rax
	movl	(%rdx,%rax), %eax
	leal	1(%rax), %ecx
	movslq	%r12d, %rdx
	movslq	%r14d, %rax
	imulq	$2002, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	dwdp(%rip), %rax
	movl	%ecx, (%rdx,%rax)
.L12:
	addl	$1, %ebx
.L10:
	movl	-92(%rbp), %eax
	cmpl	%eax, %ebx
	jle	.L13
	addl	$1, %r12d
.L9:
	movl	-88(%rbp), %eax
	cmpl	%eax, %r12d
	jle	.L14
	movl	$1, %ebx
	jmp	.L15
.L20:
	movl	$1, %r12d
	jmp	.L16
.L19:
	movl	-88(%rbp), %eax
	subl	%r12d, %eax
	leal	1(%rax), %r14d
	leal	-1(%rbx), %eax
	leal	-1(%r12), %edx
	movq	-64(%rbp), %rcx
	movslq	%edx, %rdx
	cltq
	imulq	%r13, %rax
	addq	%rcx, %rdx
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	$35, %al
	je	.L17
	leal	-1(%r12), %eax
	movslq	%eax, %rdx
	movslq	%ebx, %rax
	imulq	$2002, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	lfdp(%rip), %rax
	movl	(%rdx,%rax), %eax
	leal	1(%rax), %ecx
	movslq	%r12d, %rdx
	movslq	%ebx, %rax
	imulq	$2002, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	lfdp(%rip), %rax
	movl	%ecx, (%rdx,%rax)
.L17:
	leal	-1(%rbx), %eax
	leal	-1(%r14), %edx
	movq	-64(%rbp), %rcx
	movslq	%edx, %rdx
	cltq
	imulq	%r13, %rax
	addq	%rcx, %rdx
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	$35, %al
	je	.L18
	leal	1(%r14), %eax
	movslq	%eax, %rdx
	movslq	%ebx, %rax
	imulq	$2002, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	ridp(%rip), %rax
	movl	(%rdx,%rax), %eax
	leal	1(%rax), %ecx
	movslq	%r14d, %rdx
	movslq	%ebx, %rax
	imulq	$2002, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	ridp(%rip), %rax
	movl	%ecx, (%rdx,%rax)
.L18:
	addl	$1, %r12d
.L16:
	movl	-88(%rbp), %eax
	cmpl	%eax, %r12d
	jle	.L19
	addl	$1, %ebx
.L15:
	movl	-92(%rbp), %eax
	cmpl	%eax, %ebx
	jle	.L20
	movl	$0, -84(%rbp)
	movl	$0, %ebx
	jmp	.L21
.L26:
	movl	$0, %r12d
	jmp	.L22
.L25:
	leal	1(%rbx), %eax
	leal	1(%r12), %edx
	movslq	%edx, %rdx
	cltq
	imulq	$2002, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	dwdp(%rip), %rax
	movl	(%rdx,%rax), %ecx
	leal	1(%rbx), %eax
	leal	1(%r12), %edx
	movslq	%edx, %rdx
	cltq
	imulq	$2002, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	updp(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%eax, %ecx
	leal	1(%rbx), %eax
	leal	1(%r12), %edx
	movslq	%edx, %rdx
	cltq
	imulq	$2002, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	lfdp(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%eax, %ecx
	leal	1(%rbx), %eax
	leal	1(%r12), %edx
	movslq	%edx, %rdx
	cltq
	imulq	$2002, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	ridp(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%ecx, %eax
	subl	$2, %eax
	cmpl	%eax, -84(%rbp)
	jge	.L23
	leal	1(%rbx), %eax
	leal	1(%r12), %edx
	movslq	%edx, %rdx
	cltq
	imulq	$2002, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	dwdp(%rip), %rax
	movl	(%rdx,%rax), %ecx
	leal	1(%rbx), %eax
	leal	1(%r12), %edx
	movslq	%edx, %rdx
	cltq
	imulq	$2002, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	updp(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%eax, %ecx
	leal	1(%rbx), %eax
	leal	1(%r12), %edx
	movslq	%edx, %rdx
	cltq
	imulq	$2002, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	lfdp(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%eax, %ecx
	leal	1(%rbx), %eax
	leal	1(%r12), %edx
	movslq	%edx, %rdx
	cltq
	imulq	$2002, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	ridp(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%ecx, %eax
	subl	$3, %eax
	jmp	.L24
.L23:
	movl	-84(%rbp), %eax
.L24:
	movl	%eax, -84(%rbp)
	addl	$1, %r12d
.L22:
	movl	-88(%rbp), %eax
	cmpl	%eax, %r12d
	jl	.L25
	addl	$1, %ebx
.L21:
	movl	-92(%rbp), %eax
	cmpl	%eax, %ebx
	jl	.L26
	movl	-84(%rbp), %eax
	movl	$0, %edx
	testl	%eax, %eax
	cmovs	%edx, %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-152(%rbp), %rsp
	movq	-56(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L28
	call	__stack_chk_fail@PLT
.L28:
	leaq	-40(%rbp), %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.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	"%c"
.LC2:
	.string	"%d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	leaq	.LC0(%rip), %rdi
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%r15
	pushq	%r14
	leaq	-60(%rbp), %rdx
	leaq	-64(%rbp), %rsi
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	subq	$40, %rsp
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	.cfi_offset 12, -48
	.cfi_offset 3, -56
	movq	%fs:40, %rax
	movq	%rax, -56(%rbp)
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movq	stdin(%rip), %rdi
	call	getc@PLT
	movslq	-60(%rbp), %rbx
	movslq	-64(%rbp), %rdx
	movq	%rsp, %rdi
	movq	%rdx, %rsi
	imulq	%rbx, %rdx
	movq	%rbx, %r10
	movl	%ebx, %eax
	addq	$15, %rdx
	movq	%rdx, %rcx
	andq	$-4096, %rdx
	subq	%rdx, %rdi
	andq	$-16, %rcx
	cmpq	%rdi, %rsp
	je	.L3
.L58:
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	cmpq	%rdi, %rsp
	jne	.L58
.L3:
	andl	$4095, %ecx
	subq	%rcx, %rsp
	testq	%rcx, %rcx
	jne	.L59
.L4:
	movq	%rsp, -72(%rbp)
	testl	%esi, %esi
	jle	.L5
	movq	%rsp, %r13
	xorl	%r15d, %r15d
	leaq	.LC1(%rip), %r14
	.p2align 4,,10
	.p2align 3
.L6:
	xorl	%r12d, %r12d
	testl	%eax, %eax
	jle	.L9
	.p2align 4,,10
	.p2align 3
.L7:
	leaq	(%r12,%r13), %rsi
	movq	%r14, %rdi
	xorl	%eax, %eax
	addq	$1, %r12
	call	__isoc99_scanf@PLT
	cmpl	%r12d, -60(%rbp)
	jg	.L7
.L9:
	movq	stdin(%rip), %rdi
	addl	$1, %r15d
	addq	%rbx, %r13
	call	getc@PLT
	movl	-64(%rbp), %esi
	cmpl	%r15d, %esi
	jle	.L8
	movl	-60(%rbp), %eax
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L8:
	movl	-60(%rbp), %r10d
	testl	%r10d, %r10d
	jle	.L10
	testl	%esi, %esi
	jle	.L56
	leaq	4+updp(%rip), %r11
	movslq	%r10d, %r8
	xorl	%r9d, %r9d
	.p2align 4,,10
	.p2align 3
.L14:
	movslq	%r9d, %rdi
	movq	%r11, %rcx
	xorl	%eax, %eax
	addq	-72(%rbp), %rdi
	.p2align 4,,10
	.p2align 3
.L13:
	movslq	%eax, %rdx
	imulq	%rbx, %rdx
	cmpb	$35, (%rdi,%rdx)
	je	.L17
	movl	(%rcx), %edx
	addl	$1, %edx
	movl	%edx, 8008(%rcx)
.L17:
	addl	$1, %eax
	addq	$8008, %rcx
	cmpl	%esi, %eax
	jne	.L13
	addq	$1, %r9
	addq	$4, %r11
	cmpq	%r8, %r9
	jne	.L14
	leal	1(%r10), %r11d
	movl	$1, %r15d
	leal	-1(%rsi), %r13d
	leaq	dwdp(%rip), %r14
	.p2align 4,,10
	.p2align 3
.L18:
	leal	-1(%r15), %edi
	movl	%r13d, %eax
	movslq	%r15d, %r9
	movslq	%edi, %rdi
	addq	-72(%rbp), %rdi
	.p2align 4,,10
	.p2align 3
.L20:
	movslq	%eax, %rdx
	imulq	%rbx, %rdx
	cmpb	$35, (%rdi,%rdx)
	je	.L19
	leal	2(%rax), %ecx
	leal	1(%rax), %edx
	movslq	%ecx, %rcx
	movslq	%edx, %rdx
	imulq	$2002, %rcx, %rcx
	imulq	$2002, %rdx, %rdx
	addq	%r9, %rcx
	movl	(%r14,%rcx,4), %ecx
	addq	%r9, %rdx
	addl	$1, %ecx
	movl	%ecx, (%r14,%rdx,4)
.L19:
	subl	$1, %eax
	jnb	.L20
	addl	$1, %r15d
	cmpl	%r11d, %r15d
	jne	.L18
	movl	%r13d, %r14d
	leal	-1(%r10), %r15d
	leaq	8012+lfdp(%rip), %r9
	movl	%r10d, %edi
	imulq	$8008, %r14, %r14
	movl	%r15d, -76(%rbp)
	leaq	8008(%r9), %rax
	addq	-72(%rbp), %rdi
	addq	%rax, %r14
	.p2align 4,,10
	.p2align 3
.L27:
	movq	%rdi, %rax
	movq	%r9, %rdx
	subq	%r15, %rax
	subq	$1, %rax
	.p2align 4,,10
	.p2align 3
.L26:
	cmpb	$35, (%rax)
	je	.L30
	movl	-4(%rdx), %ecx
	addl	$1, %ecx
	movl	%ecx, (%rdx)
.L30:
	addq	$1, %rax
	addq	$4, %rdx
	cmpq	%rdi, %rax
	jne	.L26
	addq	$8008, %r9
	leaq	(%rax,%rbx), %rdi
	cmpq	%r14, %r9
	jne	.L27
	addq	-72(%rbp), %r8
	addl	$1, %esi
	movl	$1, %r14d
	leaq	ridp(%rip), %r12
	.p2align 4,,10
	.p2align 3
.L24:
	movslq	%r14d, %r9
	movslq	%r11d, %rax
	movq	%r8, %rdx
	imulq	$2002, %r9, %r9
	.p2align 4,,10
	.p2align 3
.L23:
	cmpb	$35, -1(%rdx)
	leal	-1(%rax), %ecx
	je	.L22
	addq	%r9, %rax
	movslq	%ecx, %rdi
	movl	(%r12,%rax,4), %eax
	addq	%r9, %rdi
	addl	$1, %eax
	movl	%eax, (%r12,%rdi,4)
.L22:
	movslq	%ecx, %rax
	subq	$1, %rdx
	cmpl	$1, %eax
	jne	.L23
	addl	$1, %r14d
	addq	%rbx, %r8
	cmpl	%esi, %r14d
	jne	.L24
.L35:
	movl	%r13d, %eax
	movl	-76(%rbp), %ebx
	xorl	%ecx, %ecx
	leaq	4+updp(%rip), %r11
	imulq	$2002, %rax, %rax
	leaq	4+dwdp(%rip), %r9
	leaq	8012(,%rbx,4), %rsi
	leaq	4+lfdp(%rip), %r8
	leaq	4+ridp(%rip), %rdi
	leaq	4005(%rbx,%rax), %r12
	notq	%rbx
	salq	$2, %r12
	salq	$2, %rbx
	.p2align 4,,10
	.p2align 3
.L25:
	leaq	(%rbx,%rsi), %rdx
	testl	%r10d, %r10d
	jle	.L34
	.p2align 4,,10
	.p2align 3
.L32:
	movl	(%r9,%rdx), %eax
	addl	(%r11,%rdx), %eax
	addl	(%r8,%rdx), %eax
	addl	(%rdi,%rdx), %eax
	leal	-2(%rax), %r13d
	subl	$3, %eax
	cmpl	%ecx, %r13d
	cmovg	%eax, %ecx
	addq	$4, %rdx
	cmpq	%rdx, %rsi
	jne	.L32
.L34:
	addq	$8008, %rsi
	cmpq	%r12, %rsi
	jne	.L25
.L12:
	xorl	%edx, %edx
	testl	%ecx, %ecx
	leaq	.LC2(%rip), %rsi
	movl	$1, %edi
	cmovns	%ecx, %edx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	-56(%rbp), %rax
	subq	%fs:40, %rax
	jne	.L60
	leaq	-40(%rbp), %rsp
	xorl	%eax, %eax
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_remember_state
	.cfi_def_cfa 7, 8
	ret
.L59:
	.cfi_restore_state
	orq	$0, -8(%rsp,%rcx)
	jmp	.L4
.L5:
	testl	%r10d, %r10d
	jle	.L10
.L56:
	xorl	%ecx, %ecx
	jmp	.L12
.L10:
	leal	-1(%r10), %eax
	leal	-1(%rsi), %r13d
	movl	%eax, -76(%rbp)
	testl	%esi, %esi
	jg	.L35
	xorl	%ecx, %ecx
	jmp	.L12
.L60:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.globl	ridp
	.bss
	.align 32
	.type	ridp, @object
	.size	ridp, 16032016
ridp:
	.zero	16032016
	.globl	lfdp
	.align 32
	.type	lfdp, @object
	.size	lfdp, 16032016
lfdp:
	.zero	16032016
	.globl	updp
	.align 32
	.type	updp, @object
	.size	updp, 16032016
updp:
	.zero	16032016
	.globl	dwdp
	.align 32
	.type	dwdp, @object
	.size	dwdp, 16032016
dwdp:
	.zero	16032016
	.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	"%c"
.LC2:
	.string	"%d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	leaq	.LC0(%rip), %rdi
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%r15
	pushq	%r14
	leaq	-60(%rbp), %rdx
	leaq	-64(%rbp), %rsi
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	subq	$40, %rsp
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	.cfi_offset 12, -48
	.cfi_offset 3, -56
	movq	%fs:40, %rax
	movq	%rax, -56(%rbp)
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movq	stdin(%rip), %rdi
	call	getc@PLT
	movslq	-60(%rbp), %rbx
	movslq	-64(%rbp), %rdx
	movq	%rsp, %rdi
	movq	%rdx, %rsi
	imulq	%rbx, %rdx
	movq	%rbx, %r10
	movl	%ebx, %eax
	addq	$15, %rdx
	movq	%rdx, %rcx
	andq	$-4096, %rdx
	subq	%rdx, %rdi
	andq	$-16, %rcx
	cmpq	%rdi, %rsp
	je	.L3
.L58:
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	cmpq	%rdi, %rsp
	jne	.L58
.L3:
	andl	$4095, %ecx
	subq	%rcx, %rsp
	testq	%rcx, %rcx
	jne	.L59
.L4:
	movq	%rsp, -72(%rbp)
	testl	%esi, %esi
	jle	.L5
	movq	%rsp, %r13
	xorl	%r15d, %r15d
	leaq	.LC1(%rip), %r14
	.p2align 4,,10
	.p2align 3
.L6:
	xorl	%r12d, %r12d
	testl	%eax, %eax
	jle	.L9
	.p2align 4,,10
	.p2align 3
.L7:
	leaq	(%r12,%r13), %rsi
	movq	%r14, %rdi
	xorl	%eax, %eax
	addq	$1, %r12
	call	__isoc99_scanf@PLT
	cmpl	%r12d, -60(%rbp)
	jg	.L7
.L9:
	movq	stdin(%rip), %rdi
	addl	$1, %r15d
	addq	%rbx, %r13
	call	getc@PLT
	movl	-64(%rbp), %esi
	cmpl	%r15d, %esi
	jle	.L8
	movl	-60(%rbp), %eax
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L8:
	movl	-60(%rbp), %r10d
	testl	%r10d, %r10d
	jle	.L10
	testl	%esi, %esi
	jle	.L56
	leaq	4+updp(%rip), %r11
	movslq	%r10d, %r8
	xorl	%r9d, %r9d
	.p2align 4,,10
	.p2align 3
.L14:
	movslq	%r9d, %rdi
	movq	%r11, %rcx
	xorl	%eax, %eax
	addq	-72(%rbp), %rdi
	.p2align 4,,10
	.p2align 3
.L13:
	movslq	%eax, %rdx
	imulq	%rbx, %rdx
	cmpb	$35, (%rdi,%rdx)
	je	.L17
	movl	(%rcx), %edx
	addl	$1, %edx
	movl	%edx, 8008(%rcx)
.L17:
	addl	$1, %eax
	addq	$8008, %rcx
	cmpl	%esi, %eax
	jne	.L13
	addq	$1, %r9
	addq	$4, %r11
	cmpq	%r8, %r9
	jne	.L14
	leal	1(%r10), %r11d
	movl	$1, %r15d
	leal	-1(%rsi), %r13d
	leaq	dwdp(%rip), %r14
	.p2align 4,,10
	.p2align 3
.L18:
	leal	-1(%r15), %edi
	movl	%r13d, %eax
	movslq	%r15d, %r9
	movslq	%edi, %rdi
	addq	-72(%rbp), %rdi
	.p2align 4,,10
	.p2align 3
.L20:
	movslq	%eax, %rdx
	imulq	%rbx, %rdx
	cmpb	$35, (%rdi,%rdx)
	je	.L19
	leal	2(%rax), %ecx
	leal	1(%rax), %edx
	movslq	%ecx, %rcx
	movslq	%edx, %rdx
	imulq	$2002, %rcx, %rcx
	imulq	$2002, %rdx, %rdx
	addq	%r9, %rcx
	movl	(%r14,%rcx,4), %ecx
	addq	%r9, %rdx
	addl	$1, %ecx
	movl	%ecx, (%r14,%rdx,4)
.L19:
	subl	$1, %eax
	jnb	.L20
	addl	$1, %r15d
	cmpl	%r11d, %r15d
	jne	.L18
	movl	%r13d, %r14d
	leal	-1(%r10), %r15d
	leaq	8012+lfdp(%rip), %r9
	movl	%r10d, %edi
	imulq	$8008, %r14, %r14
	movl	%r15d, -76(%rbp)
	leaq	8008(%r9), %rax
	addq	-72(%rbp), %rdi
	addq	%rax, %r14
	.p2align 4,,10
	.p2align 3
.L27:
	movq	%rdi, %rax
	movq	%r9, %rdx
	subq	%r15, %rax
	subq	$1, %rax
	.p2align 4,,10
	.p2align 3
.L26:
	cmpb	$35, (%rax)
	je	.L30
	movl	-4(%rdx), %ecx
	addl	$1, %ecx
	movl	%ecx, (%rdx)
.L30:
	addq	$1, %rax
	addq	$4, %rdx
	cmpq	%rdi, %rax
	jne	.L26
	addq	$8008, %r9
	leaq	(%rax,%rbx), %rdi
	cmpq	%r14, %r9
	jne	.L27
	addq	-72(%rbp), %r8
	addl	$1, %esi
	movl	$1, %r14d
	leaq	ridp(%rip), %r12
	.p2align 4,,10
	.p2align 3
.L24:
	movslq	%r14d, %r9
	movslq	%r11d, %rax
	movq	%r8, %rdx
	imulq	$2002, %r9, %r9
	.p2align 4,,10
	.p2align 3
.L23:
	cmpb	$35, -1(%rdx)
	leal	-1(%rax), %ecx
	je	.L22
	addq	%r9, %rax
	movslq	%ecx, %rdi
	movl	(%r12,%rax,4), %eax
	addq	%r9, %rdi
	addl	$1, %eax
	movl	%eax, (%r12,%rdi,4)
.L22:
	movslq	%ecx, %rax
	subq	$1, %rdx
	cmpl	$1, %eax
	jne	.L23
	addl	$1, %r14d
	addq	%rbx, %r8
	cmpl	%esi, %r14d
	jne	.L24
.L35:
	movl	%r13d, %eax
	movl	-76(%rbp), %ebx
	xorl	%ecx, %ecx
	leaq	4+updp(%rip), %r11
	imulq	$2002, %rax, %rax
	leaq	4+dwdp(%rip), %r9
	leaq	8012(,%rbx,4), %rsi
	leaq	4+lfdp(%rip), %r8
	leaq	4+ridp(%rip), %rdi
	leaq	4005(%rbx,%rax), %r12
	notq	%rbx
	salq	$2, %r12
	salq	$2, %rbx
	.p2align 4,,10
	.p2align 3
.L25:
	leaq	(%rbx,%rsi), %rdx
	testl	%r10d, %r10d
	jle	.L34
	.p2align 4,,10
	.p2align 3
.L32:
	movl	(%r9,%rdx), %eax
	addl	(%r11,%rdx), %eax
	addl	(%r8,%rdx), %eax
	addl	(%rdi,%rdx), %eax
	leal	-2(%rax), %r13d
	subl	$3, %eax
	cmpl	%ecx, %r13d
	cmovg	%eax, %ecx
	addq	$4, %rdx
	cmpq	%rdx, %rsi
	jne	.L32
.L34:
	addq	$8008, %rsi
	cmpq	%r12, %rsi
	jne	.L25
.L12:
	xorl	%edx, %edx
	testl	%ecx, %ecx
	leaq	.LC2(%rip), %rsi
	movl	$1, %edi
	cmovns	%ecx, %edx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	-56(%rbp), %rax
	subq	%fs:40, %rax
	jne	.L60
	leaq	-40(%rbp), %rsp
	xorl	%eax, %eax
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_remember_state
	.cfi_def_cfa 7, 8
	ret
.L59:
	.cfi_restore_state
	orq	$0, -8(%rsp,%rcx)
	jmp	.L4
.L5:
	testl	%r10d, %r10d
	jle	.L10
.L56:
	xorl	%ecx, %ecx
	jmp	.L12
.L10:
	leal	-1(%r10), %eax
	leal	-1(%rsi), %r13d
	movl	%eax, -76(%rbp)
	testl	%esi, %esi
	jg	.L35
	xorl	%ecx, %ecx
	jmp	.L12
.L60:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.globl	ridp
	.bss
	.align 32
	.type	ridp, @object
	.size	ridp, 16032016
ridp:
	.zero	16032016
	.globl	lfdp
	.align 32
	.type	lfdp, @object
	.size	lfdp, 16032016
lfdp:
	.zero	16032016
	.globl	updp
	.align 32
	.type	updp, @object
	.size	updp, 16032016
updp:
	.zero	16032016
	.globl	dwdp
	.align 32
	.type	dwdp, @object
	.size	dwdp, 16032016
dwdp:
	.zero	16032016
	.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))

int dwdp[2002][2002],updp[2002][2002],lfdp[2002][2002],ridp[2002][2002];

int main(void){
    register int i,j,ri,rj;
    int h,w;
    scanf("%d %d",&h,&w);
    getchar();
    char grid[h][w];
    for(i = 0;i < h;i++,getchar())for(j = 0;j < w;j++)scanf("%c",&grid[i][j]);
    //down and up
    for(j = 1;j <= w;j++)for(i = 1;i <= h;i++){
        ri = h - i + 1;

        if(grid[i-1][j-1] != '#')updp[i][j] = updp[i-1][j] + 1;

        if(grid[ri-1][j-1] != '#')dwdp[ri][j] = dwdp[ri+1][j] + 1;
    }
    //left and right
    for(i = 1;i <= h;i++)for(j = 1;j <= w;j++){
        rj = w - j + 1;

        if(grid[i-1][j-1] != '#')lfdp[i][j] = lfdp[i][j-1] + 1;

        if(grid[i-1][rj-1] != '#')ridp[i][rj] = ridp[i][rj+1] + 1;
    }
    int ans = 0;
    for(i = 0;i < h;i++)for(j = 0;j < w;j++)ans = max(ans,dwdp[i+1][j+1]+updp[i+1][j+1]+lfdp[i+1][j+1]+ridp[i+1][j+1]-3/*overlap*/);
    printf("%d",max(ans,0));
    return 0;
}
3 6
#..#..
.....#
....#.
#.#...
 8 8
..#...#.
....#...
......
..###..#
...#..#-
....#.
...#...
.#..#
 4 8
#..#..
.....#
....#.
#.#...
 2 6
..#..
.....#
....#.
.#...
 1 8
..#...#.
....#...
......
..###..#
...#..#.
....#.
...#...
#..#.
 4 1
..#..
#.....
./..#.
.#...
 2 8
..#...#.
....#...
......
..###..#
...#..#.
....#.
...#...
#..#.
 8 8
/#....#.
...#....
......
..###..#
...#..#.
....#.
...#..-
#..#.
 1 6
#....
.....#
.$....
.#.,.
 1 1
.#...#..
.../#...
0.....
..###..#
.#/.#...
....#.
...#...
#..#.

7 15 11 5 3 1 5 14 5 1
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))

int dwdp[2002][2002],updp[2002][2002],lfdp[2002][2002],ridp[2002][2002];

int main(void){
    register int i,j,ri,rj;
    int h,w;
    scanf("%d %d",&h,&w);
    getchar();
    char grid[h][w];
    for(i = 0;i < h;i++,getchar())for(j = 0;j < w;j++)scanf("%c",&grid[i][j]);
    //down and up
    for(j = 1;j <= w;j++)for(i = 1;i <= h;i++){
        ri = h - i + 1;

        if(grid[i-1][j-1] != '#')updp[i][j] = updp[i-1][j] + 1;

        if(grid[ri-1][j-1] != '#')dwdp[ri][j] = dwdp[ri+1][j] + 1;
    }
    //left and right
    for(i = 1;i <= h;i++)for(j = 1;j <= w;j++){
        rj = w - j + 1;

        if(grid[i-1][j-1] != '#')lfdp[i][j] = lfdp[i][j-1] + 1;

        if(grid[i-1][rj-1] != '#')ridp[i][rj] = ridp[i][rj+1] + 1;
    }
    int ans = 0;
    for(i = 0;i < h;i++)for(j = 0;j < w;j++)ans = max(ans,dwdp[i+1][j+1]+updp[i+1][j+1]+lfdp[i+1][j+1]+ridp[i+1][j+1]-3/*overlap*/);
    printf("%d",max(ans,0));
    return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	dwdp
	.bss
	.align 32
	.type	dwdp, @object
	.size	dwdp, 16032016
dwdp:
	.zero	16032016
	.globl	updp
	.align 32
	.type	updp, @object
	.size	updp, 16032016
updp:
	.zero	16032016
	.globl	lfdp
	.align 32
	.type	lfdp, @object
	.size	lfdp, 16032016
lfdp:
	.zero	16032016
	.globl	ridp
	.align 32
	.type	ridp, @object
	.size	ridp, 16032016
ridp:
	.zero	16032016
	.section	.rodata
.LC0:
	.string	"%d %d"
.LC1:
	.string	"%c"
.LC2:
	.string	"%d"
	.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
	pushq	%r15
	pushq	%r14
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	subq	$120, %rsp
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	.cfi_offset 12, -48
	.cfi_offset 3, -56
	movq	%fs:40, %rax
	movq	%rax, -56(%rbp)
	xorl	%eax, %eax
	movq	%rsp, %rax
	movq	%rax, -152(%rbp)
	leaq	-88(%rbp), %rdx
	leaq	-92(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	call	getchar@PLT
	movl	-88(%rbp), %ecx
	movl	-92(%rbp), %esi
	movslq	%ecx, %rax
	subq	$1, %rax
	movq	%rax, -80(%rbp)
	movslq	%ecx, %rax
	movq	%rax, %r12
	movl	$0, %r13d
	movslq	%ecx, %r13
	movslq	%esi, %rax
	subq	$1, %rax
	movq	%rax, -72(%rbp)
	movslq	%ecx, %rax
	movq	%rax, -112(%rbp)
	movq	$0, -104(%rbp)
	movslq	%esi, %rax
	movq	%rax, -128(%rbp)
	movq	$0, -120(%rbp)
	movq	-112(%rbp), %r10
	movq	-104(%rbp), %r11
	movq	%r11, %rdx
	movq	-128(%rbp), %r8
	movq	-120(%rbp), %r9
	imulq	%r8, %rdx
	movq	%r9, %rax
	imulq	%r10, %rax
	leaq	(%rdx,%rax), %rdi
	movq	%r10, %rax
	mulq	%r8
	addq	%rdx, %rdi
	movq	%rdi, %rdx
	movslq	%ecx, %rax
	movq	%rax, -144(%rbp)
	movq	$0, -136(%rbp)
	movslq	%esi, %rax
	movq	%rax, %r14
	movl	$0, %r15d
	movq	-144(%rbp), %r8
	movq	-136(%rbp), %r9
	movq	%r9, %rdx
	imulq	%r14, %rdx
	movq	%r8, %rax
	imulq	%r15, %rax
	leaq	(%rdx,%rax), %rdi
	movq	%r8, %rax
	mulq	%r14
	addq	%rdx, %rdi
	movq	%rdi, %rdx
	movslq	%ecx, %rdx
	movslq	%esi, %rax
	imulq	%rdx, %rax
	movl	$16, %edx
	subq	$1, %rdx
	addq	%rdx, %rax
	movl	$16, %esi
	movl	$0, %edx
	divq	%rsi
	imulq	$16, %rax, %rax
	movq	%rax, %rcx
	andq	$-4096, %rcx
	movq	%rsp, %rdx
	subq	%rcx, %rdx
.L2:
	cmpq	%rdx, %rsp
	je	.L3
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L2
.L3:
	movq	%rax, %rdx
	andl	$4095, %edx
	subq	%rdx, %rsp
	movq	%rax, %rdx
	andl	$4095, %edx
	testq	%rdx, %rdx
	je	.L4
	andl	$4095, %eax
	subq	$8, %rax
	addq	%rsp, %rax
	orq	$0, (%rax)
.L4:
	movq	%rsp, %rax
	addq	$0, %rax
	movq	%rax, -64(%rbp)
	movl	$0, %ebx
	jmp	.L5
.L8:
	movl	$0, %r12d
	jmp	.L6
.L7:
	movslq	%r12d, %rdx
	movslq	%ebx, %rax
	imulq	%r13, %rax
	addq	%rax, %rdx
	movq	-64(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, %r12d
.L6:
	movl	-88(%rbp), %eax
	cmpl	%eax, %r12d
	jl	.L7
	addl	$1, %ebx
	call	getchar@PLT
.L5:
	movl	-92(%rbp), %eax
	cmpl	%eax, %ebx
	jl	.L8
	movl	$1, %r12d
	jmp	.L9
.L14:
	movl	$1, %ebx
	jmp	.L10
.L13:
	movl	-92(%rbp), %eax
	subl	%ebx, %eax
	leal	1(%rax), %r14d
	leal	-1(%rbx), %eax
	leal	-1(%r12), %edx
	movq	-64(%rbp), %rcx
	movslq	%edx, %rdx
	cltq
	imulq	%r13, %rax
	addq	%rcx, %rdx
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	$35, %al
	je	.L11
	leal	-1(%rbx), %eax
	movslq	%r12d, %rdx
	cltq
	imulq	$2002, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	updp(%rip), %rax
	movl	(%rdx,%rax), %eax
	leal	1(%rax), %ecx
	movslq	%r12d, %rdx
	movslq	%ebx, %rax
	imulq	$2002, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	updp(%rip), %rax
	movl	%ecx, (%rdx,%rax)
.L11:
	leal	-1(%r14), %eax
	leal	-1(%r12), %edx
	movq	-64(%rbp), %rcx
	movslq	%edx, %rdx
	cltq
	imulq	%r13, %rax
	addq	%rcx, %rdx
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	$35, %al
	je	.L12
	leal	1(%r14), %eax
	movslq	%r12d, %rdx
	cltq
	imulq	$2002, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	dwdp(%rip), %rax
	movl	(%rdx,%rax), %eax
	leal	1(%rax), %ecx
	movslq	%r12d, %rdx
	movslq	%r14d, %rax
	imulq	$2002, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	dwdp(%rip), %rax
	movl	%ecx, (%rdx,%rax)
.L12:
	addl	$1, %ebx
.L10:
	movl	-92(%rbp), %eax
	cmpl	%eax, %ebx
	jle	.L13
	addl	$1, %r12d
.L9:
	movl	-88(%rbp), %eax
	cmpl	%eax, %r12d
	jle	.L14
	movl	$1, %ebx
	jmp	.L15
.L20:
	movl	$1, %r12d
	jmp	.L16
.L19:
	movl	-88(%rbp), %eax
	subl	%r12d, %eax
	leal	1(%rax), %r14d
	leal	-1(%rbx), %eax
	leal	-1(%r12), %edx
	movq	-64(%rbp), %rcx
	movslq	%edx, %rdx
	cltq
	imulq	%r13, %rax
	addq	%rcx, %rdx
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	$35, %al
	je	.L17
	leal	-1(%r12), %eax
	movslq	%eax, %rdx
	movslq	%ebx, %rax
	imulq	$2002, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	lfdp(%rip), %rax
	movl	(%rdx,%rax), %eax
	leal	1(%rax), %ecx
	movslq	%r12d, %rdx
	movslq	%ebx, %rax
	imulq	$2002, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	lfdp(%rip), %rax
	movl	%ecx, (%rdx,%rax)
.L17:
	leal	-1(%rbx), %eax
	leal	-1(%r14), %edx
	movq	-64(%rbp), %rcx
	movslq	%edx, %rdx
	cltq
	imulq	%r13, %rax
	addq	%rcx, %rdx
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	$35, %al
	je	.L18
	leal	1(%r14), %eax
	movslq	%eax, %rdx
	movslq	%ebx, %rax
	imulq	$2002, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	ridp(%rip), %rax
	movl	(%rdx,%rax), %eax
	leal	1(%rax), %ecx
	movslq	%r14d, %rdx
	movslq	%ebx, %rax
	imulq	$2002, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	ridp(%rip), %rax
	movl	%ecx, (%rdx,%rax)
.L18:
	addl	$1, %r12d
.L16:
	movl	-88(%rbp), %eax
	cmpl	%eax, %r12d
	jle	.L19
	addl	$1, %ebx
.L15:
	movl	-92(%rbp), %eax
	cmpl	%eax, %ebx
	jle	.L20
	movl	$0, -84(%rbp)
	movl	$0, %ebx
	jmp	.L21
.L26:
	movl	$0, %r12d
	jmp	.L22
.L25:
	leal	1(%rbx), %eax
	leal	1(%r12), %edx
	movslq	%edx, %rdx
	cltq
	imulq	$2002, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	dwdp(%rip), %rax
	movl	(%rdx,%rax), %ecx
	leal	1(%rbx), %eax
	leal	1(%r12), %edx
	movslq	%edx, %rdx
	cltq
	imulq	$2002, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	updp(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%eax, %ecx
	leal	1(%rbx), %eax
	leal	1(%r12), %edx
	movslq	%edx, %rdx
	cltq
	imulq	$2002, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	lfdp(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%eax, %ecx
	leal	1(%rbx), %eax
	leal	1(%r12), %edx
	movslq	%edx, %rdx
	cltq
	imulq	$2002, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	ridp(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%ecx, %eax
	subl	$2, %eax
	cmpl	%eax, -84(%rbp)
	jge	.L23
	leal	1(%rbx), %eax
	leal	1(%r12), %edx
	movslq	%edx, %rdx
	cltq
	imulq	$2002, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	dwdp(%rip), %rax
	movl	(%rdx,%rax), %ecx
	leal	1(%rbx), %eax
	leal	1(%r12), %edx
	movslq	%edx, %rdx
	cltq
	imulq	$2002, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	updp(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%eax, %ecx
	leal	1(%rbx), %eax
	leal	1(%r12), %edx
	movslq	%edx, %rdx
	cltq
	imulq	$2002, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	lfdp(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%eax, %ecx
	leal	1(%rbx), %eax
	leal	1(%r12), %edx
	movslq	%edx, %rdx
	cltq
	imulq	$2002, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	ridp(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%ecx, %eax
	subl	$3, %eax
	jmp	.L24
.L23:
	movl	-84(%rbp), %eax
.L24:
	movl	%eax, -84(%rbp)
	addl	$1, %r12d
.L22:
	movl	-88(%rbp), %eax
	cmpl	%eax, %r12d
	jl	.L25
	addl	$1, %ebx
.L21:
	movl	-92(%rbp), %eax
	cmpl	%eax, %ebx
	jl	.L26
	movl	-84(%rbp), %eax
	movl	$0, %edx
	testl	%eax, %eax
	cmovs	%edx, %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-152(%rbp), %rsp
	movq	-56(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L28
	call	__stack_chk_fail@PLT
.L28:
	leaq	-40(%rbp), %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.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	dwdp
	.bss
	.align 32
	.type	dwdp, @object
	.size	dwdp, 16032016
dwdp:
	.zero	16032016
	.globl	updp
	.align 32
	.type	updp, @object
	.size	updp, 16032016
updp:
	.zero	16032016
	.globl	lfdp
	.align 32
	.type	lfdp, @object
	.size	lfdp, 16032016
lfdp:
	.zero	16032016
	.globl	ridp
	.align 32
	.type	ridp, @object
	.size	ridp, 16032016
ridp:
	.zero	16032016
	.section	.rodata
.LC0:
	.string	"%d %d"
.LC1:
	.string	"%c"
.LC2:
	.string	"%d"
	.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
	pushq	%r15
	pushq	%r14
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	subq	$120, %rsp
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	.cfi_offset 12, -48
	.cfi_offset 3, -56
	movq	%fs:40, %rax
	movq	%rax, -56(%rbp)
	xorl	%eax, %eax
	movq	%rsp, %rax
	movq	%rax, -152(%rbp)
	leaq	-88(%rbp), %rdx
	leaq	-92(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	call	getchar@PLT
	movl	-88(%rbp), %ecx
	movl	-92(%rbp), %esi
	movslq	%ecx, %rax
	subq	$1, %rax
	movq	%rax, -80(%rbp)
	movslq	%ecx, %rax
	movq	%rax, %r12
	movl	$0, %r13d
	movslq	%ecx, %r13
	movslq	%esi, %rax
	subq	$1, %rax
	movq	%rax, -72(%rbp)
	movslq	%ecx, %rax
	movq	%rax, -112(%rbp)
	movq	$0, -104(%rbp)
	movslq	%esi, %rax
	movq	%rax, -128(%rbp)
	movq	$0, -120(%rbp)
	movq	-112(%rbp), %r10
	movq	-104(%rbp), %r11
	movq	%r11, %rdx
	movq	-128(%rbp), %r8
	movq	-120(%rbp), %r9
	imulq	%r8, %rdx
	movq	%r9, %rax
	imulq	%r10, %rax
	leaq	(%rdx,%rax), %rdi
	movq	%r10, %rax
	mulq	%r8
	addq	%rdx, %rdi
	movq	%rdi, %rdx
	movslq	%ecx, %rax
	movq	%rax, -144(%rbp)
	movq	$0, -136(%rbp)
	movslq	%esi, %rax
	movq	%rax, %r14
	movl	$0, %r15d
	movq	-144(%rbp), %r8
	movq	-136(%rbp), %r9
	movq	%r9, %rdx
	imulq	%r14, %rdx
	movq	%r8, %rax
	imulq	%r15, %rax
	leaq	(%rdx,%rax), %rdi
	movq	%r8, %rax
	mulq	%r14
	addq	%rdx, %rdi
	movq	%rdi, %rdx
	movslq	%ecx, %rdx
	movslq	%esi, %rax
	imulq	%rdx, %rax
	movl	$16, %edx
	subq	$1, %rdx
	addq	%rdx, %rax
	movl	$16, %esi
	movl	$0, %edx
	divq	%rsi
	imulq	$16, %rax, %rax
	movq	%rax, %rcx
	andq	$-4096, %rcx
	movq	%rsp, %rdx
	subq	%rcx, %rdx
.L2:
	cmpq	%rdx, %rsp
	je	.L3
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L2
.L3:
	movq	%rax, %rdx
	andl	$4095, %edx
	subq	%rdx, %rsp
	movq	%rax, %rdx
	andl	$4095, %edx
	testq	%rdx, %rdx
	je	.L4
	andl	$4095, %eax
	subq	$8, %rax
	addq	%rsp, %rax
	orq	$0, (%rax)
.L4:
	movq	%rsp, %rax
	addq	$0, %rax
	movq	%rax, -64(%rbp)
	movl	$0, %ebx
	jmp	.L5
.L8:
	movl	$0, %r12d
	jmp	.L6
.L7:
	movslq	%r12d, %rdx
	movslq	%ebx, %rax
	imulq	%r13, %rax
	addq	%rax, %rdx
	movq	-64(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, %r12d
.L6:
	movl	-88(%rbp), %eax
	cmpl	%eax, %r12d
	jl	.L7
	addl	$1, %ebx
	call	getchar@PLT
.L5:
	movl	-92(%rbp), %eax
	cmpl	%eax, %ebx
	jl	.L8
	movl	$1, %r12d
	jmp	.L9
.L14:
	movl	$1, %ebx
	jmp	.L10
.L13:
	movl	-92(%rbp), %eax
	subl	%ebx, %eax
	leal	1(%rax), %r14d
	leal	-1(%rbx), %eax
	leal	-1(%r12), %edx
	movq	-64(%rbp), %rcx
	movslq	%edx, %rdx
	cltq
	imulq	%r13, %rax
	addq	%rcx, %rdx
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	$35, %al
	je	.L11
	leal	-1(%rbx), %eax
	movslq	%r12d, %rdx
	cltq
	imulq	$2002, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	updp(%rip), %rax
	movl	(%rdx,%rax), %eax
	leal	1(%rax), %ecx
	movslq	%r12d, %rdx
	movslq	%ebx, %rax
	imulq	$2002, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	updp(%rip), %rax
	movl	%ecx, (%rdx,%rax)
.L11:
	leal	-1(%r14), %eax
	leal	-1(%r12), %edx
	movq	-64(%rbp), %rcx
	movslq	%edx, %rdx
	cltq
	imulq	%r13, %rax
	addq	%rcx, %rdx
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	$35, %al
	je	.L12
	leal	1(%r14), %eax
	movslq	%r12d, %rdx
	cltq
	imulq	$2002, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	dwdp(%rip), %rax
	movl	(%rdx,%rax), %eax
	leal	1(%rax), %ecx
	movslq	%r12d, %rdx
	movslq	%r14d, %rax
	imulq	$2002, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	dwdp(%rip), %rax
	movl	%ecx, (%rdx,%rax)
.L12:
	addl	$1, %ebx
.L10:
	movl	-92(%rbp), %eax
	cmpl	%eax, %ebx
	jle	.L13
	addl	$1, %r12d
.L9:
	movl	-88(%rbp), %eax
	cmpl	%eax, %r12d
	jle	.L14
	movl	$1, %ebx
	jmp	.L15
.L20:
	movl	$1, %r12d
	jmp	.L16
.L19:
	movl	-88(%rbp), %eax
	subl	%r12d, %eax
	leal	1(%rax), %r14d
	leal	-1(%rbx), %eax
	leal	-1(%r12), %edx
	movq	-64(%rbp), %rcx
	movslq	%edx, %rdx
	cltq
	imulq	%r13, %rax
	addq	%rcx, %rdx
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	$35, %al
	je	.L17
	leal	-1(%r12), %eax
	movslq	%eax, %rdx
	movslq	%ebx, %rax
	imulq	$2002, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	lfdp(%rip), %rax
	movl	(%rdx,%rax), %eax
	leal	1(%rax), %ecx
	movslq	%r12d, %rdx
	movslq	%ebx, %rax
	imulq	$2002, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	lfdp(%rip), %rax
	movl	%ecx, (%rdx,%rax)
.L17:
	leal	-1(%rbx), %eax
	leal	-1(%r14), %edx
	movq	-64(%rbp), %rcx
	movslq	%edx, %rdx
	cltq
	imulq	%r13, %rax
	addq	%rcx, %rdx
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	$35, %al
	je	.L18
	leal	1(%r14), %eax
	movslq	%eax, %rdx
	movslq	%ebx, %rax
	imulq	$2002, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	ridp(%rip), %rax
	movl	(%rdx,%rax), %eax
	leal	1(%rax), %ecx
	movslq	%r14d, %rdx
	movslq	%ebx, %rax
	imulq	$2002, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	ridp(%rip), %rax
	movl	%ecx, (%rdx,%rax)
.L18:
	addl	$1, %r12d
.L16:
	movl	-88(%rbp), %eax
	cmpl	%eax, %r12d
	jle	.L19
	addl	$1, %ebx
.L15:
	movl	-92(%rbp), %eax
	cmpl	%eax, %ebx
	jle	.L20
	movl	$0, -84(%rbp)
	movl	$0, %ebx
	jmp	.L21
.L26:
	movl	$0, %r12d
	jmp	.L22
.L25:
	leal	1(%rbx), %eax
	leal	1(%r12), %edx
	movslq	%edx, %rdx
	cltq
	imulq	$2002, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	dwdp(%rip), %rax
	movl	(%rdx,%rax), %ecx
	leal	1(%rbx), %eax
	leal	1(%r12), %edx
	movslq	%edx, %rdx
	cltq
	imulq	$2002, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	updp(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%eax, %ecx
	leal	1(%rbx), %eax
	leal	1(%r12), %edx
	movslq	%edx, %rdx
	cltq
	imulq	$2002, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	lfdp(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%eax, %ecx
	leal	1(%rbx), %eax
	leal	1(%r12), %edx
	movslq	%edx, %rdx
	cltq
	imulq	$2002, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	ridp(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%ecx, %eax
	subl	$2, %eax
	cmpl	%eax, -84(%rbp)
	jge	.L23
	leal	1(%rbx), %eax
	leal	1(%r12), %edx
	movslq	%edx, %rdx
	cltq
	imulq	$2002, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	dwdp(%rip), %rax
	movl	(%rdx,%rax), %ecx
	leal	1(%rbx), %eax
	leal	1(%r12), %edx
	movslq	%edx, %rdx
	cltq
	imulq	$2002, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	updp(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%eax, %ecx
	leal	1(%rbx), %eax
	leal	1(%r12), %edx
	movslq	%edx, %rdx
	cltq
	imulq	$2002, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	lfdp(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%eax, %ecx
	leal	1(%rbx), %eax
	leal	1(%r12), %edx
	movslq	%edx, %rdx
	cltq
	imulq	$2002, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	ridp(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%ecx, %eax
	subl	$3, %eax
	jmp	.L24
.L23:
	movl	-84(%rbp), %eax
.L24:
	movl	%eax, -84(%rbp)
	addl	$1, %r12d
.L22:
	movl	-88(%rbp), %eax
	cmpl	%eax, %r12d
	jl	.L25
	addl	$1, %ebx
.L21:
	movl	-92(%rbp), %eax
	cmpl	%eax, %ebx
	jl	.L26
	movl	-84(%rbp), %eax
	movl	$0, %edx
	testl	%eax, %eax
	cmovs	%edx, %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-152(%rbp), %rsp
	movq	-56(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L28
	call	__stack_chk_fail@PLT
.L28:
	leaq	-40(%rbp), %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.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:
