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>

int queue[1000020][3];
char instr[1000][1001];
int checked[1000][1000];
int st = 0;
int en = 0;
int df[4][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};

void append(int i, int j, int k) {
	queue[en][0] = i;
	queue[en][1] = j;
	queue[en][2] = k;
	checked[i][j] = 1;
	en++;
	return;
}

int main() {
	int H,W,res = 0;
	scanf("%d %d\n",&H,&W);
	for (int i=0;i<H;i++) gets(instr[i]);
	for (int i=0;i<H;i++) for (int j=0;j < W;j++) checked[i][j]=0;
	for (int i=0;i<H;i++) for (int j=0;j < W;j++) {
		if (instr[i][j] == '#') {
			checked[i][j]=1;
			queue[en][0]=i;
			queue[en][1]=j;
			queue[en][2]=0;
			en++;
		}
	}

	while (st < en) {
		int i = queue[st][0];
		int j = queue[st][1];
		int k = queue[st][2];
		st++;
		for (int l = 0; l < 4; l++) {
			if (i+df[l][0]<H && i+df[l][0]>=0 && j+df[l][1]<W && j+df[l][1] >= 0 && !checked[i+df[l][0]][j+df[l][1]]) {
				append(i+df[l][0], j+df[l][1], k+1);
				res = k+1;
			}
		}
	}
	printf("%d\n", res);
	return 0;
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	queue
	.bss
	.align 32
	.type	queue, @object
	.size	queue, 12000240
queue:
	.zero	12000240
	.globl	instr
	.align 32
	.type	instr, @object
	.size	instr, 1001000
instr:
	.zero	1001000
	.globl	checked
	.align 32
	.type	checked, @object
	.size	checked, 4000000
checked:
	.zero	4000000
	.globl	st
	.align 4
	.type	st, @object
	.size	st, 4
st:
	.zero	4
	.globl	en
	.align 4
	.type	en, @object
	.size	en, 4
en:
	.zero	4
	.globl	df
	.data
	.align 32
	.type	df, @object
	.size	df, 32
df:
	.long	0
	.long	1
	.long	0
	.long	-1
	.long	1
	.long	0
	.long	-1
	.long	0
	.text
	.globl	append
	.type	append, @function
append:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -4(%rbp)
	movl	%esi, -8(%rbp)
	movl	%edx, -12(%rbp)
	movl	en(%rip), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rcx
	leaq	queue(%rip), %rdx
	movl	-4(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	movl	en(%rip), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rcx
	leaq	4+queue(%rip), %rdx
	movl	-8(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	movl	en(%rip), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rcx
	leaq	8+queue(%rip), %rdx
	movl	-12(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	movl	-8(%rbp), %eax
	movslq	%eax, %rdx
	movl	-4(%rbp), %eax
	cltq
	imulq	$1000, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	checked(%rip), %rax
	movl	$1, (%rdx,%rax)
	movl	en(%rip), %eax
	addl	$1, %eax
	movl	%eax, en(%rip)
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	append, .-append
	.section	.rodata
.LC0:
	.string	"%d %d\n"
.LC1:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$64, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -48(%rbp)
	leaq	-52(%rbp), %rdx
	leaq	-56(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -44(%rbp)
	jmp	.L4
.L5:
	movl	-44(%rbp), %eax
	cltq
	imulq	$1001, %rax, %rax
	leaq	instr(%rip), %rdx
	addq	%rdx, %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	gets@PLT
	addl	$1, -44(%rbp)
.L4:
	movl	-56(%rbp), %eax
	cmpl	%eax, -44(%rbp)
	jl	.L5
	movl	$0, -40(%rbp)
	jmp	.L6
.L9:
	movl	$0, -36(%rbp)
	jmp	.L7
.L8:
	movl	-36(%rbp), %eax
	movslq	%eax, %rdx
	movl	-40(%rbp), %eax
	cltq
	imulq	$1000, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	checked(%rip), %rax
	movl	$0, (%rdx,%rax)
	addl	$1, -36(%rbp)
.L7:
	movl	-52(%rbp), %eax
	cmpl	%eax, -36(%rbp)
	jl	.L8
	addl	$1, -40(%rbp)
.L6:
	movl	-56(%rbp), %eax
	cmpl	%eax, -40(%rbp)
	jl	.L9
	movl	$0, -32(%rbp)
	jmp	.L10
.L14:
	movl	$0, -28(%rbp)
	jmp	.L11
.L13:
	movl	-28(%rbp), %eax
	movslq	%eax, %rdx
	movl	-32(%rbp), %eax
	cltq
	imulq	$1001, %rax, %rax
	addq	%rax, %rdx
	leaq	instr(%rip), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	$35, %al
	jne	.L12
	movl	-28(%rbp), %eax
	movslq	%eax, %rdx
	movl	-32(%rbp), %eax
	cltq
	imulq	$1000, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	checked(%rip), %rax
	movl	$1, (%rdx,%rax)
	movl	en(%rip), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rcx
	leaq	queue(%rip), %rdx
	movl	-32(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	movl	en(%rip), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rcx
	leaq	4+queue(%rip), %rdx
	movl	-28(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	movl	en(%rip), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	leaq	8+queue(%rip), %rax
	movl	$0, (%rdx,%rax)
	movl	en(%rip), %eax
	addl	$1, %eax
	movl	%eax, en(%rip)
.L12:
	addl	$1, -28(%rbp)
.L11:
	movl	-52(%rbp), %eax
	cmpl	%eax, -28(%rbp)
	jl	.L13
	addl	$1, -32(%rbp)
.L10:
	movl	-56(%rbp), %eax
	cmpl	%eax, -32(%rbp)
	jl	.L14
	jmp	.L15
.L19:
	movl	st(%rip), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	leaq	queue(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -20(%rbp)
	movl	st(%rip), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	leaq	4+queue(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -16(%rbp)
	movl	st(%rip), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	leaq	8+queue(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -12(%rbp)
	movl	st(%rip), %eax
	addl	$1, %eax
	movl	%eax, st(%rip)
	movl	$0, -24(%rbp)
	jmp	.L16
.L18:
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	df(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-20(%rbp), %eax
	addl	%eax, %edx
	movl	-56(%rbp), %eax
	cmpl	%eax, %edx
	jge	.L17
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	df(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-20(%rbp), %eax
	addl	%edx, %eax
	testl	%eax, %eax
	js	.L17
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	4+df(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-16(%rbp), %eax
	addl	%eax, %edx
	movl	-52(%rbp), %eax
	cmpl	%eax, %edx
	jge	.L17
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	4+df(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-16(%rbp), %eax
	addl	%edx, %eax
	testl	%eax, %eax
	js	.L17
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	df(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-20(%rbp), %eax
	leal	(%rdx,%rax), %ecx
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	4+df(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-16(%rbp), %eax
	addl	%edx, %eax
	movslq	%eax, %rdx
	movslq	%ecx, %rax
	imulq	$1000, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	checked(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	jne	.L17
	movl	-12(%rbp), %eax
	leal	1(%rax), %edx
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rcx
	leaq	4+df(%rip), %rax
	movl	(%rcx,%rax), %ecx
	movl	-16(%rbp), %eax
	addl	%eax, %ecx
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rsi
	leaq	df(%rip), %rax
	movl	(%rsi,%rax), %esi
	movl	-20(%rbp), %eax
	addl	%esi, %eax
	movl	%ecx, %esi
	movl	%eax, %edi
	call	append
	movl	-12(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -48(%rbp)
.L17:
	addl	$1, -24(%rbp)
.L16:
	cmpl	$3, -24(%rbp)
	jle	.L18
.L15:
	movl	st(%rip), %edx
	movl	en(%rip), %eax
	cmpl	%eax, %edx
	jl	.L19
	movl	-48(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L21
	call	__stack_chk_fail@PLT
.L21:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.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
	.p2align 4
	.globl	append
	.type	append, @function
append:
.LFB23:
	.cfi_startproc
	endbr64
	movl	%edx, %r8d
	movd	%edi, %xmm0
	movslq	en(%rip), %rdx
	movslq	%edi, %rdi
	imulq	$1000, %rdi, %rdi
	movd	%esi, %xmm1
	leaq	queue(%rip), %rcx
	movslq	%esi, %rsi
	movq	%rdx, %rax
	leaq	(%rdx,%rdx,2), %rdx
	punpckldq	%xmm1, %xmm0
	salq	$2, %rdx
	addl	$1, %eax
	movq	%xmm0, (%rcx,%rdx)
	addq	%rsi, %rdi
	movl	%r8d, 8(%rcx,%rdx)
	leaq	checked(%rip), %rdx
	movl	$1, (%rdx,%rdi,4)
	movl	%eax, en(%rip)
	ret
	.cfi_endproc
.LFE23:
	.size	append, .-append
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d %d\n"
.LC1:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB24:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	.LC0(%rip), %rdi
	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
	xorl	%r12d, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	leaq	instr(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movq	%rbp, %r13
	subq	$56, %rsp
	.cfi_def_cfa_offset 112
	movq	%fs:40, %rax
	movq	%rax, 40(%rsp)
	xorl	%eax, %eax
	leaq	36(%rsp), %rdx
	leaq	32(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movl	32(%rsp), %ebx
	testl	%ebx, %ebx
	jle	.L53
	.p2align 4,,10
	.p2align 3
.L5:
	movq	%r13, %rdi
	xorl	%eax, %eax
	addl	$1, %r12d
	addq	$1001, %r13
	call	gets@PLT
	movl	32(%rsp), %ebx
	cmpl	%r12d, %ebx
	jg	.L5
	testl	%ebx, %ebx
	jle	.L53
	movl	36(%rsp), %r13d
	testl	%r13d, %r13d
	jle	.L8
	leal	-1(%rbx), %r12d
	leaq	checked(%rip), %rcx
	movslq	%r13d, %r14
	imulq	$4000, %r12, %r12
	leaq	4000(%rcx), %rax
	salq	$2, %r14
	addq	%rax, %r12
	.p2align 4,,10
	.p2align 3
.L9:
	movq	%rcx, %rdi
	movq	%r14, %rdx
	xorl	%esi, %esi
	call	memset@PLT
	movq	%rax, %rcx
	addq	$4000, %rcx
	cmpq	%rcx, %r12
	jne	.L9
.L8:
	movl	en(%rip), %r12d
	xorl	%ecx, %ecx
	pxor	%xmm0, %xmm0
	movslq	%r13d, %rsi
	leaq	checked(%rip), %r8
	leaq	queue(%rip), %rdi
	movl	%r12d, %edx
	.p2align 4,,10
	.p2align 3
.L7:
	xorl	%eax, %eax
	testl	%r13d, %r13d
	jle	.L14
	.p2align 4,,10
	.p2align 3
.L11:
	movdqa	%xmm0, %xmm1
	movd	%eax, %xmm4
	cmpb	$35, 0(%rbp,%rax)
	punpckldq	%xmm4, %xmm1
	jne	.L10
	movslq	%edx, %rcx
	movl	$1, (%r8,%rax,4)
	addl	$1, %edx
	leaq	(%rcx,%rcx,2), %rcx
	movl	$0, 8(%rdi,%rcx,4)
	movq	%xmm1, (%rdi,%rcx,4)
	movl	$1, %ecx
.L10:
	addq	$1, %rax
	cmpq	%rsi, %rax
	jne	.L11
.L14:
	movd	%xmm0, %eax
	addq	$1001, %rbp
	addq	$4000, %r8
	addl	$1, %eax
	movd	%eax, %xmm0
	cmpl	%eax, %ebx
	jne	.L7
	testb	%cl, %cl
	je	.L23
	movl	%edx, en(%rip)
	movl	%edx, %r12d
.L23:
	movl	st(%rip), %edi
	cmpl	%r12d, %edi
	jge	.L25
	movl	36(%rsp), %eax
	leaq	queue(%rip), %rcx
	movb	$0, 23(%rsp)
	movl	$0, 16(%rsp)
	movl	df(%rip), %r15d
	movl	%eax, 4(%rsp)
	movl	16+df(%rip), %eax
	movq	df(%rip), %xmm7
	movl	8+df(%rip), %r14d
	movq	8+df(%rip), %xmm6
	movl	%eax, 8(%rsp)
	movq	16+df(%rip), %xmm5
	movl	24+df(%rip), %eax
	movq	24+df(%rip), %xmm4
	movl	%eax, 12(%rsp)
	movslq	%edi, %rax
	leaq	(%rax,%rax,2), %rax
	leaq	(%rcx,%rax,4), %rcx
	jmp	.L21
	.p2align 4,,10
	.p2align 3
.L17:
	leal	(%rax,%r14), %esi
	movl	%esi, %edx
	orl	%r11d, %edx
	notl	%edx
	shrl	$31, %edx
	cmpl	%esi, %ebx
	setg	%r8b
	andb	%r8b, %dl
	jne	.L54
.L18:
	movl	8(%rsp), %esi
	addl	%eax, %esi
	movl	%esi, %edx
	orl	%r10d, %edx
	notl	%edx
	shrl	$31, %edx
	cmpl	%esi, %ebx
	setg	%r8b
	andb	%r8b, %dl
	jne	.L55
.L19:
	addl	12(%rsp), %eax
	movl	%eax, %edx
	orl	%r9d, %edx
	notl	%edx
	shrl	$31, %edx
	cmpl	%eax, %ebx
	setg	%sil
	andb	%sil, %dl
	jne	.L56
.L20:
	addq	$12, %rcx
	cmpl	%r12d, %edi
	jge	.L57
.L21:
	movq	(%rcx), %xmm0
	movl	(%rcx), %eax
	addl	$1, %edi
	movl	8(%rcx), %r13d
	movdqa	%xmm0, %xmm1
	leal	(%rax,%r15), %esi
	paddd	%xmm4, %xmm1
	movl	%esi, %edx
	pshufd	$0xe5, %xmm1, %xmm2
	movd	%xmm2, %r9d
	movdqa	%xmm0, %xmm2
	paddd	%xmm5, %xmm2
	pshufd	$0xe5, %xmm2, %xmm3
	movd	%xmm3, %r10d
	movdqa	%xmm0, %xmm3
	paddd	%xmm7, %xmm0
	paddd	%xmm6, %xmm3
	pshufd	$0xe5, %xmm0, %xmm9
	movd	%xmm9, %ebp
	orl	%ebp, %edx
	pshufd	$0xe5, %xmm3, %xmm8
	movd	%xmm8, %r11d
	notl	%edx
	shrl	$31, %edx
	cmpl	%esi, %ebx
	setg	%r8b
	andb	%r8b, %dl
	je	.L17
	cmpl	%ebp, 4(%rsp)
	jle	.L17
	movslq	%esi, %rsi
	movslq	%ebp, %rbp
	imulq	$1000, %rsi, %rsi
	addq	%rbp, %rsi
	leaq	checked(%rip), %rbp
	movl	0(%rbp,%rsi,4), %ebp
	movq	%rsi, 24(%rsp)
	testl	%ebp, %ebp
	jne	.L17
	leal	1(%r13), %r8d
	leaq	queue(%rip), %rsi
	movb	%dl, 23(%rsp)
	movl	%r8d, %ebp
	movl	%r8d, 16(%rsp)
	movslq	%r12d, %r8
	addl	$1, %r12d
	imulq	$12, %r8, %r8
	movl	%ebp, 8(%rsi,%r8)
	leaq	checked(%rip), %rbp
	movq	%xmm0, (%rsi,%r8)
	movq	24(%rsp), %rsi
	movl	$1, 0(%rbp,%rsi,4)
	jmp	.L17
	.p2align 4,,10
	.p2align 3
.L56:
	cmpl	%r9d, 4(%rsp)
	jle	.L20
	cltq
	movslq	%r9d, %r9
	imulq	$1000, %rax, %rax
	addq	%r9, %rax
	leaq	checked(%rip), %r9
	movl	(%r9,%rax,4), %esi
	testl	%esi, %esi
	jne	.L20
	movslq	%r12d, %rsi
	leal	1(%r13), %r10d
	movb	%dl, 23(%rsp)
	addl	$1, %r12d
	imulq	$12, %rsi, %rsi
	leaq	queue(%rip), %r11
	movl	%r10d, 16(%rsp)
	movq	%xmm1, (%r11,%rsi)
	movl	%r10d, 8(%r11,%rsi)
	movl	$1, (%r9,%rax,4)
	jmp	.L20
	.p2align 4,,10
	.p2align 3
.L55:
	cmpl	%r10d, 4(%rsp)
	jle	.L19
	movslq	%esi, %rsi
	movslq	%r10d, %r10
	imulq	$1000, %rsi, %rsi
	addq	%r10, %rsi
	leaq	checked(%rip), %r10
	movl	(%r10,%rsi,4), %r8d
	testl	%r8d, %r8d
	jne	.L19
	movslq	%r12d, %r8
	leal	1(%r13), %r11d
	movb	%dl, 23(%rsp)
	addl	$1, %r12d
	imulq	$12, %r8, %r8
	leaq	queue(%rip), %rbp
	movl	%r11d, 16(%rsp)
	movq	%xmm2, 0(%rbp,%r8)
	movl	%r11d, 8(%rbp,%r8)
	movl	$1, (%r10,%rsi,4)
	jmp	.L19
	.p2align 4,,10
	.p2align 3
.L54:
	cmpl	%r11d, 4(%rsp)
	jle	.L18
	movslq	%esi, %rsi
	movslq	%r11d, %r11
	imulq	$1000, %rsi, %rsi
	addq	%r11, %rsi
	leaq	checked(%rip), %r11
	movl	(%r11,%rsi,4), %r11d
	testl	%r11d, %r11d
	jne	.L18
	movslq	%r12d, %r8
	leal	1(%r13), %ebp
	movb	%dl, 23(%rsp)
	addl	$1, %r12d
	imulq	$12, %r8, %r8
	leaq	queue(%rip), %r11
	movl	%ebp, 16(%rsp)
	movq	%xmm3, (%r11,%r8)
	movl	%ebp, 8(%r11,%r8)
	leaq	checked(%rip), %r11
	movl	$1, (%r11,%rsi,4)
	jmp	.L18
	.p2align 4,,10
	.p2align 3
.L57:
	cmpb	$0, 23(%rsp)
	movl	%edi, st(%rip)
	je	.L16
	movl	%r12d, en(%rip)
.L16:
	movl	16(%rsp), %edx
	xorl	%eax, %eax
	movl	$1, %edi
	leaq	.LC1(%rip), %rsi
	call	__printf_chk@PLT
	movq	40(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L58
	addq	$56, %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
.L25:
	.cfi_restore_state
	movl	$0, 16(%rsp)
	jmp	.L16
.L53:
	movl	en(%rip), %r12d
	jmp	.L23
.L58:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE24:
	.size	main, .-main
	.globl	df
	.data
	.align 32
	.type	df, @object
	.size	df, 32
df:
	.long	0
	.long	1
	.long	0
	.long	-1
	.long	1
	.long	0
	.long	-1
	.long	0
	.globl	en
	.bss
	.align 4
	.type	en, @object
	.size	en, 4
en:
	.zero	4
	.globl	st
	.align 4
	.type	st, @object
	.size	st, 4
st:
	.zero	4
	.globl	checked
	.align 32
	.type	checked, @object
	.size	checked, 4000000
checked:
	.zero	4000000
	.globl	instr
	.align 32
	.type	instr, @object
	.size	instr, 1001000
instr:
	.zero	1001000
	.globl	queue
	.align 32
	.type	queue, @object
	.size	queue, 12000240
queue:
	.zero	12000240
	.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
	.p2align 4
	.globl	append
	.type	append, @function
append:
.LFB23:
	.cfi_startproc
	endbr64
	movl	%edx, %r8d
	movd	%edi, %xmm0
	movslq	en(%rip), %rdx
	movslq	%edi, %rdi
	imulq	$1000, %rdi, %rdi
	movd	%esi, %xmm1
	leaq	queue(%rip), %rcx
	movslq	%esi, %rsi
	movq	%rdx, %rax
	leaq	(%rdx,%rdx,2), %rdx
	punpckldq	%xmm1, %xmm0
	salq	$2, %rdx
	addl	$1, %eax
	movq	%xmm0, (%rcx,%rdx)
	addq	%rsi, %rdi
	movl	%r8d, 8(%rcx,%rdx)
	leaq	checked(%rip), %rdx
	movl	$1, (%rdx,%rdi,4)
	movl	%eax, en(%rip)
	ret
	.cfi_endproc
.LFE23:
	.size	append, .-append
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d %d\n"
.LC1:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB24:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	.LC0(%rip), %rdi
	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
	xorl	%r12d, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	leaq	instr(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movq	%rbp, %r13
	subq	$56, %rsp
	.cfi_def_cfa_offset 112
	movq	%fs:40, %rax
	movq	%rax, 40(%rsp)
	xorl	%eax, %eax
	leaq	36(%rsp), %rdx
	leaq	32(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movl	32(%rsp), %ebx
	testl	%ebx, %ebx
	jle	.L53
	.p2align 4,,10
	.p2align 3
.L5:
	movq	%r13, %rdi
	xorl	%eax, %eax
	addl	$1, %r12d
	addq	$1001, %r13
	call	gets@PLT
	movl	32(%rsp), %ebx
	cmpl	%r12d, %ebx
	jg	.L5
	testl	%ebx, %ebx
	jle	.L53
	movl	36(%rsp), %r13d
	testl	%r13d, %r13d
	jle	.L8
	leal	-1(%rbx), %r12d
	leaq	checked(%rip), %rcx
	movslq	%r13d, %r14
	imulq	$4000, %r12, %r12
	leaq	4000(%rcx), %rax
	salq	$2, %r14
	addq	%rax, %r12
	.p2align 4,,10
	.p2align 3
.L9:
	movq	%rcx, %rdi
	movq	%r14, %rdx
	xorl	%esi, %esi
	call	memset@PLT
	movq	%rax, %rcx
	addq	$4000, %rcx
	cmpq	%rcx, %r12
	jne	.L9
.L8:
	movl	en(%rip), %r12d
	xorl	%ecx, %ecx
	pxor	%xmm0, %xmm0
	movslq	%r13d, %rsi
	leaq	checked(%rip), %r8
	leaq	queue(%rip), %rdi
	movl	%r12d, %edx
	.p2align 4,,10
	.p2align 3
.L7:
	xorl	%eax, %eax
	testl	%r13d, %r13d
	jle	.L14
	.p2align 4,,10
	.p2align 3
.L11:
	movdqa	%xmm0, %xmm1
	movd	%eax, %xmm4
	cmpb	$35, 0(%rbp,%rax)
	punpckldq	%xmm4, %xmm1
	jne	.L10
	movslq	%edx, %rcx
	movl	$1, (%r8,%rax,4)
	addl	$1, %edx
	leaq	(%rcx,%rcx,2), %rcx
	movl	$0, 8(%rdi,%rcx,4)
	movq	%xmm1, (%rdi,%rcx,4)
	movl	$1, %ecx
.L10:
	addq	$1, %rax
	cmpq	%rsi, %rax
	jne	.L11
.L14:
	movd	%xmm0, %eax
	addq	$1001, %rbp
	addq	$4000, %r8
	addl	$1, %eax
	movd	%eax, %xmm0
	cmpl	%eax, %ebx
	jne	.L7
	testb	%cl, %cl
	je	.L23
	movl	%edx, en(%rip)
	movl	%edx, %r12d
.L23:
	movl	st(%rip), %edi
	cmpl	%r12d, %edi
	jge	.L25
	movl	36(%rsp), %eax
	leaq	queue(%rip), %rcx
	movb	$0, 23(%rsp)
	movl	$0, 16(%rsp)
	movl	df(%rip), %r15d
	movl	%eax, 4(%rsp)
	movl	16+df(%rip), %eax
	movq	df(%rip), %xmm7
	movl	8+df(%rip), %r14d
	movq	8+df(%rip), %xmm6
	movl	%eax, 8(%rsp)
	movq	16+df(%rip), %xmm5
	movl	24+df(%rip), %eax
	movq	24+df(%rip), %xmm4
	movl	%eax, 12(%rsp)
	movslq	%edi, %rax
	leaq	(%rax,%rax,2), %rax
	leaq	(%rcx,%rax,4), %rcx
	jmp	.L21
	.p2align 4,,10
	.p2align 3
.L17:
	leal	(%rax,%r14), %esi
	movl	%esi, %edx
	orl	%r11d, %edx
	notl	%edx
	shrl	$31, %edx
	cmpl	%esi, %ebx
	setg	%r8b
	andb	%r8b, %dl
	jne	.L54
.L18:
	movl	8(%rsp), %esi
	addl	%eax, %esi
	movl	%esi, %edx
	orl	%r10d, %edx
	notl	%edx
	shrl	$31, %edx
	cmpl	%esi, %ebx
	setg	%r8b
	andb	%r8b, %dl
	jne	.L55
.L19:
	addl	12(%rsp), %eax
	movl	%eax, %edx
	orl	%r9d, %edx
	notl	%edx
	shrl	$31, %edx
	cmpl	%eax, %ebx
	setg	%sil
	andb	%sil, %dl
	jne	.L56
.L20:
	addq	$12, %rcx
	cmpl	%r12d, %edi
	jge	.L57
.L21:
	movq	(%rcx), %xmm0
	movl	(%rcx), %eax
	addl	$1, %edi
	movl	8(%rcx), %r13d
	movdqa	%xmm0, %xmm1
	leal	(%rax,%r15), %esi
	paddd	%xmm4, %xmm1
	movl	%esi, %edx
	pshufd	$0xe5, %xmm1, %xmm2
	movd	%xmm2, %r9d
	movdqa	%xmm0, %xmm2
	paddd	%xmm5, %xmm2
	pshufd	$0xe5, %xmm2, %xmm3
	movd	%xmm3, %r10d
	movdqa	%xmm0, %xmm3
	paddd	%xmm7, %xmm0
	paddd	%xmm6, %xmm3
	pshufd	$0xe5, %xmm0, %xmm9
	movd	%xmm9, %ebp
	orl	%ebp, %edx
	pshufd	$0xe5, %xmm3, %xmm8
	movd	%xmm8, %r11d
	notl	%edx
	shrl	$31, %edx
	cmpl	%esi, %ebx
	setg	%r8b
	andb	%r8b, %dl
	je	.L17
	cmpl	%ebp, 4(%rsp)
	jle	.L17
	movslq	%esi, %rsi
	movslq	%ebp, %rbp
	imulq	$1000, %rsi, %rsi
	addq	%rbp, %rsi
	leaq	checked(%rip), %rbp
	movl	0(%rbp,%rsi,4), %ebp
	movq	%rsi, 24(%rsp)
	testl	%ebp, %ebp
	jne	.L17
	leal	1(%r13), %r8d
	leaq	queue(%rip), %rsi
	movb	%dl, 23(%rsp)
	movl	%r8d, %ebp
	movl	%r8d, 16(%rsp)
	movslq	%r12d, %r8
	addl	$1, %r12d
	imulq	$12, %r8, %r8
	movl	%ebp, 8(%rsi,%r8)
	leaq	checked(%rip), %rbp
	movq	%xmm0, (%rsi,%r8)
	movq	24(%rsp), %rsi
	movl	$1, 0(%rbp,%rsi,4)
	jmp	.L17
	.p2align 4,,10
	.p2align 3
.L56:
	cmpl	%r9d, 4(%rsp)
	jle	.L20
	cltq
	movslq	%r9d, %r9
	imulq	$1000, %rax, %rax
	addq	%r9, %rax
	leaq	checked(%rip), %r9
	movl	(%r9,%rax,4), %esi
	testl	%esi, %esi
	jne	.L20
	movslq	%r12d, %rsi
	leal	1(%r13), %r10d
	movb	%dl, 23(%rsp)
	addl	$1, %r12d
	imulq	$12, %rsi, %rsi
	leaq	queue(%rip), %r11
	movl	%r10d, 16(%rsp)
	movq	%xmm1, (%r11,%rsi)
	movl	%r10d, 8(%r11,%rsi)
	movl	$1, (%r9,%rax,4)
	jmp	.L20
	.p2align 4,,10
	.p2align 3
.L55:
	cmpl	%r10d, 4(%rsp)
	jle	.L19
	movslq	%esi, %rsi
	movslq	%r10d, %r10
	imulq	$1000, %rsi, %rsi
	addq	%r10, %rsi
	leaq	checked(%rip), %r10
	movl	(%r10,%rsi,4), %r8d
	testl	%r8d, %r8d
	jne	.L19
	movslq	%r12d, %r8
	leal	1(%r13), %r11d
	movb	%dl, 23(%rsp)
	addl	$1, %r12d
	imulq	$12, %r8, %r8
	leaq	queue(%rip), %rbp
	movl	%r11d, 16(%rsp)
	movq	%xmm2, 0(%rbp,%r8)
	movl	%r11d, 8(%rbp,%r8)
	movl	$1, (%r10,%rsi,4)
	jmp	.L19
	.p2align 4,,10
	.p2align 3
.L54:
	cmpl	%r11d, 4(%rsp)
	jle	.L18
	movslq	%esi, %rsi
	movslq	%r11d, %r11
	imulq	$1000, %rsi, %rsi
	addq	%r11, %rsi
	leaq	checked(%rip), %r11
	movl	(%r11,%rsi,4), %r11d
	testl	%r11d, %r11d
	jne	.L18
	movslq	%r12d, %r8
	leal	1(%r13), %ebp
	movb	%dl, 23(%rsp)
	addl	$1, %r12d
	imulq	$12, %r8, %r8
	leaq	queue(%rip), %r11
	movl	%ebp, 16(%rsp)
	movq	%xmm3, (%r11,%r8)
	movl	%ebp, 8(%r11,%r8)
	leaq	checked(%rip), %r11
	movl	$1, (%r11,%rsi,4)
	jmp	.L18
	.p2align 4,,10
	.p2align 3
.L57:
	cmpb	$0, 23(%rsp)
	movl	%edi, st(%rip)
	je	.L16
	movl	%r12d, en(%rip)
.L16:
	movl	16(%rsp), %edx
	xorl	%eax, %eax
	movl	$1, %edi
	leaq	.LC1(%rip), %rsi
	call	__printf_chk@PLT
	movq	40(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L58
	addq	$56, %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
.L25:
	.cfi_restore_state
	movl	$0, 16(%rsp)
	jmp	.L16
.L53:
	movl	en(%rip), %r12d
	jmp	.L23
.L58:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE24:
	.size	main, .-main
	.globl	df
	.data
	.align 32
	.type	df, @object
	.size	df, 32
df:
	.long	0
	.long	1
	.long	0
	.long	-1
	.long	1
	.long	0
	.long	-1
	.long	0
	.globl	en
	.bss
	.align 4
	.type	en, @object
	.size	en, 4
en:
	.zero	4
	.globl	st
	.align 4
	.type	st, @object
	.size	st, 4
st:
	.zero	4
	.globl	checked
	.align 32
	.type	checked, @object
	.size	checked, 4000000
checked:
	.zero	4000000
	.globl	instr
	.align 32
	.type	instr, @object
	.size	instr, 1001000
instr:
	.zero	1001000
	.globl	queue
	.align 32
	.type	queue, @object
	.size	queue, 12000240
queue:
	.zero	12000240
	.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>

int queue[1000020][3];
char instr[1000][1001];
int checked[1000][1000];
int st = 0;
int en = 0;
int df[4][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};

void append(int i, int j, int k) {
	queue[en][0] = i;
	queue[en][1] = j;
	queue[en][2] = k;
	checked[i][j] = 1;
	en++;
	return;
}

int main() {
	int H,W,res = 0;
	scanf("%d %d\n",&H,&W);
	for (int i=0;i<H;i++) gets(instr[i]);
	for (int i=0;i<H;i++) for (int j=0;j < W;j++) checked[i][j]=0;
	for (int i=0;i<H;i++) for (int j=0;j < W;j++) {
		if (instr[i][j] == '#') {
			checked[i][j]=1;
			queue[en][0]=i;
			queue[en][1]=j;
			queue[en][2]=0;
			en++;
		}
	}

	while (st < en) {
		int i = queue[st][0];
		int j = queue[st][1];
		int k = queue[st][2];
		st++;
		for (int l = 0; l < 4; l++) {
			if (i+df[l][0]<H && i+df[l][0]>=0 && j+df[l][1]<W && j+df[l][1] >= 0 && !checked[i+df[l][0]][j+df[l][1]]) {
				append(i+df[l][0], j+df[l][1], k+1);
				res = k+1;
			}
		}
	}
	printf("%d\n", res);
	return 0;
}

2 3
...
.#.
...
 6 6
..#..#
......
..#..
......
.#....
-...#.
 2 6
#.#...
......
..#0.
......
.#.-..
--..#-
 2 3
...
.#.
..-
 2 3
/..
.#.
..-
 2 3
/..
.#.
..,
 3 3
...
/#.
...
 2 3
...
.#.
..,
 3 3
../
/#.
...
 3 3
-..
.#.
...

2
 3
 4
 2
 2
 2
 2
 2
 2
 2

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

```c
#include <stdio.h>

int queue[1000020][3];
char instr[1000][1001];
int checked[1000][1000];
int st = 0;
int en = 0;
int df[4][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};

void append(int i, int j, int k) {
	queue[en][0] = i;
	queue[en][1] = j;
	queue[en][2] = k;
	checked[i][j] = 1;
	en++;
	return;
}

int main() {
	int H,W,res = 0;
	scanf("%d %d\n",&H,&W);
	for (int i=0;i<H;i++) gets(instr[i]);
	for (int i=0;i<H;i++) for (int j=0;j < W;j++) checked[i][j]=0;
	for (int i=0;i<H;i++) for (int j=0;j < W;j++) {
		if (instr[i][j] == '#') {
			checked[i][j]=1;
			queue[en][0]=i;
			queue[en][1]=j;
			queue[en][2]=0;
			en++;
		}
	}

	while (st < en) {
		int i = queue[st][0];
		int j = queue[st][1];
		int k = queue[st][2];
		st++;
		for (int l = 0; l < 4; l++) {
			if (i+df[l][0]<H && i+df[l][0]>=0 && j+df[l][1]<W && j+df[l][1] >= 0 && !checked[i+df[l][0]][j+df[l][1]]) {
				append(i+df[l][0], j+df[l][1], k+1);
				res = k+1;
			}
		}
	}
	printf("%d\n", res);
	return 0;
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	queue
	.bss
	.align 32
	.type	queue, @object
	.size	queue, 12000240
queue:
	.zero	12000240
	.globl	instr
	.align 32
	.type	instr, @object
	.size	instr, 1001000
instr:
	.zero	1001000
	.globl	checked
	.align 32
	.type	checked, @object
	.size	checked, 4000000
checked:
	.zero	4000000
	.globl	st
	.align 4
	.type	st, @object
	.size	st, 4
st:
	.zero	4
	.globl	en
	.align 4
	.type	en, @object
	.size	en, 4
en:
	.zero	4
	.globl	df
	.data
	.align 32
	.type	df, @object
	.size	df, 32
df:
	.long	0
	.long	1
	.long	0
	.long	-1
	.long	1
	.long	0
	.long	-1
	.long	0
	.text
	.globl	append
	.type	append, @function
append:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -4(%rbp)
	movl	%esi, -8(%rbp)
	movl	%edx, -12(%rbp)
	movl	en(%rip), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rcx
	leaq	queue(%rip), %rdx
	movl	-4(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	movl	en(%rip), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rcx
	leaq	4+queue(%rip), %rdx
	movl	-8(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	movl	en(%rip), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rcx
	leaq	8+queue(%rip), %rdx
	movl	-12(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	movl	-8(%rbp), %eax
	movslq	%eax, %rdx
	movl	-4(%rbp), %eax
	cltq
	imulq	$1000, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	checked(%rip), %rax
	movl	$1, (%rdx,%rax)
	movl	en(%rip), %eax
	addl	$1, %eax
	movl	%eax, en(%rip)
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	append, .-append
	.section	.rodata
.LC0:
	.string	"%d %d\n"
.LC1:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$64, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -48(%rbp)
	leaq	-52(%rbp), %rdx
	leaq	-56(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -44(%rbp)
	jmp	.L4
.L5:
	movl	-44(%rbp), %eax
	cltq
	imulq	$1001, %rax, %rax
	leaq	instr(%rip), %rdx
	addq	%rdx, %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	gets@PLT
	addl	$1, -44(%rbp)
.L4:
	movl	-56(%rbp), %eax
	cmpl	%eax, -44(%rbp)
	jl	.L5
	movl	$0, -40(%rbp)
	jmp	.L6
.L9:
	movl	$0, -36(%rbp)
	jmp	.L7
.L8:
	movl	-36(%rbp), %eax
	movslq	%eax, %rdx
	movl	-40(%rbp), %eax
	cltq
	imulq	$1000, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	checked(%rip), %rax
	movl	$0, (%rdx,%rax)
	addl	$1, -36(%rbp)
.L7:
	movl	-52(%rbp), %eax
	cmpl	%eax, -36(%rbp)
	jl	.L8
	addl	$1, -40(%rbp)
.L6:
	movl	-56(%rbp), %eax
	cmpl	%eax, -40(%rbp)
	jl	.L9
	movl	$0, -32(%rbp)
	jmp	.L10
.L14:
	movl	$0, -28(%rbp)
	jmp	.L11
.L13:
	movl	-28(%rbp), %eax
	movslq	%eax, %rdx
	movl	-32(%rbp), %eax
	cltq
	imulq	$1001, %rax, %rax
	addq	%rax, %rdx
	leaq	instr(%rip), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	$35, %al
	jne	.L12
	movl	-28(%rbp), %eax
	movslq	%eax, %rdx
	movl	-32(%rbp), %eax
	cltq
	imulq	$1000, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	checked(%rip), %rax
	movl	$1, (%rdx,%rax)
	movl	en(%rip), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rcx
	leaq	queue(%rip), %rdx
	movl	-32(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	movl	en(%rip), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rcx
	leaq	4+queue(%rip), %rdx
	movl	-28(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	movl	en(%rip), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	leaq	8+queue(%rip), %rax
	movl	$0, (%rdx,%rax)
	movl	en(%rip), %eax
	addl	$1, %eax
	movl	%eax, en(%rip)
.L12:
	addl	$1, -28(%rbp)
.L11:
	movl	-52(%rbp), %eax
	cmpl	%eax, -28(%rbp)
	jl	.L13
	addl	$1, -32(%rbp)
.L10:
	movl	-56(%rbp), %eax
	cmpl	%eax, -32(%rbp)
	jl	.L14
	jmp	.L15
.L19:
	movl	st(%rip), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	leaq	queue(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -20(%rbp)
	movl	st(%rip), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	leaq	4+queue(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -16(%rbp)
	movl	st(%rip), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	leaq	8+queue(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -12(%rbp)
	movl	st(%rip), %eax
	addl	$1, %eax
	movl	%eax, st(%rip)
	movl	$0, -24(%rbp)
	jmp	.L16
.L18:
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	df(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-20(%rbp), %eax
	addl	%eax, %edx
	movl	-56(%rbp), %eax
	cmpl	%eax, %edx
	jge	.L17
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	df(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-20(%rbp), %eax
	addl	%edx, %eax
	testl	%eax, %eax
	js	.L17
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	4+df(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-16(%rbp), %eax
	addl	%eax, %edx
	movl	-52(%rbp), %eax
	cmpl	%eax, %edx
	jge	.L17
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	4+df(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-16(%rbp), %eax
	addl	%edx, %eax
	testl	%eax, %eax
	js	.L17
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	df(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-20(%rbp), %eax
	leal	(%rdx,%rax), %ecx
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	4+df(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-16(%rbp), %eax
	addl	%edx, %eax
	movslq	%eax, %rdx
	movslq	%ecx, %rax
	imulq	$1000, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	checked(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	jne	.L17
	movl	-12(%rbp), %eax
	leal	1(%rax), %edx
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rcx
	leaq	4+df(%rip), %rax
	movl	(%rcx,%rax), %ecx
	movl	-16(%rbp), %eax
	addl	%eax, %ecx
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rsi
	leaq	df(%rip), %rax
	movl	(%rsi,%rax), %esi
	movl	-20(%rbp), %eax
	addl	%esi, %eax
	movl	%ecx, %esi
	movl	%eax, %edi
	call	append
	movl	-12(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -48(%rbp)
.L17:
	addl	$1, -24(%rbp)
.L16:
	cmpl	$3, -24(%rbp)
	jle	.L18
.L15:
	movl	st(%rip), %edx
	movl	en(%rip), %eax
	cmpl	%eax, %edx
	jl	.L19
	movl	-48(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L21
	call	__stack_chk_fail@PLT
.L21:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.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	queue
	.bss
	.align 32
	.type	queue, @object
	.size	queue, 12000240
queue:
	.zero	12000240
	.globl	instr
	.align 32
	.type	instr, @object
	.size	instr, 1001000
instr:
	.zero	1001000
	.globl	checked
	.align 32
	.type	checked, @object
	.size	checked, 4000000
checked:
	.zero	4000000
	.globl	st
	.align 4
	.type	st, @object
	.size	st, 4
st:
	.zero	4
	.globl	en
	.align 4
	.type	en, @object
	.size	en, 4
en:
	.zero	4
	.globl	df
	.data
	.align 32
	.type	df, @object
	.size	df, 32
df:
	.long	0
	.long	1
	.long	0
	.long	-1
	.long	1
	.long	0
	.long	-1
	.long	0
	.text
	.globl	append
	.type	append, @function
append:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -4(%rbp)
	movl	%esi, -8(%rbp)
	movl	%edx, -12(%rbp)
	movl	en(%rip), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rcx
	leaq	queue(%rip), %rdx
	movl	-4(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	movl	en(%rip), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rcx
	leaq	4+queue(%rip), %rdx
	movl	-8(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	movl	en(%rip), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rcx
	leaq	8+queue(%rip), %rdx
	movl	-12(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	movl	-8(%rbp), %eax
	movslq	%eax, %rdx
	movl	-4(%rbp), %eax
	cltq
	imulq	$1000, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	checked(%rip), %rax
	movl	$1, (%rdx,%rax)
	movl	en(%rip), %eax
	addl	$1, %eax
	movl	%eax, en(%rip)
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	append, .-append
	.section	.rodata
.LC0:
	.string	"%d %d\n"
.LC1:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$64, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -48(%rbp)
	leaq	-52(%rbp), %rdx
	leaq	-56(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -44(%rbp)
	jmp	.L4
.L5:
	movl	-44(%rbp), %eax
	cltq
	imulq	$1001, %rax, %rax
	leaq	instr(%rip), %rdx
	addq	%rdx, %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	gets@PLT
	addl	$1, -44(%rbp)
.L4:
	movl	-56(%rbp), %eax
	cmpl	%eax, -44(%rbp)
	jl	.L5
	movl	$0, -40(%rbp)
	jmp	.L6
.L9:
	movl	$0, -36(%rbp)
	jmp	.L7
.L8:
	movl	-36(%rbp), %eax
	movslq	%eax, %rdx
	movl	-40(%rbp), %eax
	cltq
	imulq	$1000, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	checked(%rip), %rax
	movl	$0, (%rdx,%rax)
	addl	$1, -36(%rbp)
.L7:
	movl	-52(%rbp), %eax
	cmpl	%eax, -36(%rbp)
	jl	.L8
	addl	$1, -40(%rbp)
.L6:
	movl	-56(%rbp), %eax
	cmpl	%eax, -40(%rbp)
	jl	.L9
	movl	$0, -32(%rbp)
	jmp	.L10
.L14:
	movl	$0, -28(%rbp)
	jmp	.L11
.L13:
	movl	-28(%rbp), %eax
	movslq	%eax, %rdx
	movl	-32(%rbp), %eax
	cltq
	imulq	$1001, %rax, %rax
	addq	%rax, %rdx
	leaq	instr(%rip), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	$35, %al
	jne	.L12
	movl	-28(%rbp), %eax
	movslq	%eax, %rdx
	movl	-32(%rbp), %eax
	cltq
	imulq	$1000, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	checked(%rip), %rax
	movl	$1, (%rdx,%rax)
	movl	en(%rip), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rcx
	leaq	queue(%rip), %rdx
	movl	-32(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	movl	en(%rip), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rcx
	leaq	4+queue(%rip), %rdx
	movl	-28(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	movl	en(%rip), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	leaq	8+queue(%rip), %rax
	movl	$0, (%rdx,%rax)
	movl	en(%rip), %eax
	addl	$1, %eax
	movl	%eax, en(%rip)
.L12:
	addl	$1, -28(%rbp)
.L11:
	movl	-52(%rbp), %eax
	cmpl	%eax, -28(%rbp)
	jl	.L13
	addl	$1, -32(%rbp)
.L10:
	movl	-56(%rbp), %eax
	cmpl	%eax, -32(%rbp)
	jl	.L14
	jmp	.L15
.L19:
	movl	st(%rip), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	leaq	queue(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -20(%rbp)
	movl	st(%rip), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	leaq	4+queue(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -16(%rbp)
	movl	st(%rip), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	leaq	8+queue(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -12(%rbp)
	movl	st(%rip), %eax
	addl	$1, %eax
	movl	%eax, st(%rip)
	movl	$0, -24(%rbp)
	jmp	.L16
.L18:
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	df(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-20(%rbp), %eax
	addl	%eax, %edx
	movl	-56(%rbp), %eax
	cmpl	%eax, %edx
	jge	.L17
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	df(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-20(%rbp), %eax
	addl	%edx, %eax
	testl	%eax, %eax
	js	.L17
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	4+df(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-16(%rbp), %eax
	addl	%eax, %edx
	movl	-52(%rbp), %eax
	cmpl	%eax, %edx
	jge	.L17
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	4+df(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-16(%rbp), %eax
	addl	%edx, %eax
	testl	%eax, %eax
	js	.L17
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	df(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-20(%rbp), %eax
	leal	(%rdx,%rax), %ecx
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	4+df(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-16(%rbp), %eax
	addl	%edx, %eax
	movslq	%eax, %rdx
	movslq	%ecx, %rax
	imulq	$1000, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	checked(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	jne	.L17
	movl	-12(%rbp), %eax
	leal	1(%rax), %edx
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rcx
	leaq	4+df(%rip), %rax
	movl	(%rcx,%rax), %ecx
	movl	-16(%rbp), %eax
	addl	%eax, %ecx
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rsi
	leaq	df(%rip), %rax
	movl	(%rsi,%rax), %esi
	movl	-20(%rbp), %eax
	addl	%esi, %eax
	movl	%ecx, %esi
	movl	%eax, %edi
	call	append
	movl	-12(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -48(%rbp)
.L17:
	addl	$1, -24(%rbp)
.L16:
	cmpl	$3, -24(%rbp)
	jle	.L18
.L15:
	movl	st(%rip), %edx
	movl	en(%rip), %eax
	cmpl	%eax, %edx
	jl	.L19
	movl	-48(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L21
	call	__stack_chk_fail@PLT
.L21:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.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:
