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(x,y) (x>y?x:y)
int dx[]={1,0,-1,0};
int dy[]={0,-1,0,1};
typedef struct{
    int x;
    int y;
}data_t;
typedef struct{
    int head;
    int tail;
    data_t data[200000];
}queue_t;
queue_t queue;
void initqueue(){queue.head=queue.tail=0;}
void enqueue(data_t data){queue.data[queue.tail++]=data;}
data_t dequeue(){return queue.data[queue.head++];}

int h,w;
char map[1000][1000];

int bfs(data_t start,data_t goal){
    int dist[1000][1000];
    data_t now,move;

    initqueue();
    enqueue(start);
    
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            dist[i][j]=-1;
        }
    }
    dist[start.y][start.x]=0;

    while(queue.head!=queue.tail){   
        now=dequeue();
        for(int i=0;i<4;i++){
            move.x=now.x+dx[i];
            move.y=now.y+dy[i];
            if(move.x<0||w<=move.x||move.y<0||h<=move.y)continue;
            if(dist[move.y][move.x]!=-1||map[move.y][move.x]=='#')continue;
            enqueue(move);
            dist[move.y][move.x]=dist[now.y][now.x]+1;
        }
        if(dist[goal.y][goal.x]!=-1)return dist[goal.y][goal.x];
    }
    return -1;
}
int main(){
    scanf("%d %d",&h,&w);
    for(int i=0;i<h;i++)scanf("%s",map[i]);
    int ans=-1;
    data_t start,end;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(map[i][j]=='#')continue;
            for(int ii=0;ii<h;ii++){
                for(int jj=0;jj<w;jj++){
                    if(map[ii][jj]=='#')continue;
                    if(i==ii&&j==jj)continue;
                    start.x=j;
                    start.y=i;
                    end.x=jj;
                    end.y=ii;
                    ans=max(ans,bfs(start,end));
                }
            }
        }
    }
    printf("%d\n",ans);

    return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	dx
	.data
	.align 16
	.type	dx, @object
	.size	dx, 16
dx:
	.long	1
	.long	0
	.long	-1
	.long	0
	.globl	dy
	.align 16
	.type	dy, @object
	.size	dy, 16
dy:
	.long	0
	.long	-1
	.long	0
	.long	1
	.globl	queue
	.bss
	.align 32
	.type	queue, @object
	.size	queue, 1600008
queue:
	.zero	1600008
	.text
	.globl	initqueue
	.type	initqueue, @function
initqueue:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	$0, 4+queue(%rip)
	movl	4+queue(%rip), %eax
	movl	%eax, queue(%rip)
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	initqueue, .-initqueue
	.globl	enqueue
	.type	enqueue, @function
enqueue:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -8(%rbp)
	movl	4+queue(%rip), %eax
	leal	1(%rax), %edx
	movl	%edx, 4+queue(%rip)
	cltq
	leaq	0(,%rax,8), %rcx
	leaq	8+queue(%rip), %rdx
	movq	-8(%rbp), %rax
	movq	%rax, (%rcx,%rdx)
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	enqueue, .-enqueue
	.globl	dequeue
	.type	dequeue, @function
dequeue:
.LFB2:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	queue(%rip), %eax
	leal	1(%rax), %edx
	movl	%edx, queue(%rip)
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	8+queue(%rip), %rax
	movq	(%rdx,%rax), %rax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2:
	.size	dequeue, .-dequeue
	.globl	h
	.bss
	.align 4
	.type	h, @object
	.size	h, 4
h:
	.zero	4
	.globl	w
	.align 4
	.type	w, @object
	.size	w, 4
w:
	.zero	4
	.globl	map
	.align 32
	.type	map, @object
	.size	map, 1000000
map:
	.zero	1000000
	.text
	.globl	bfs
	.type	bfs, @function
bfs:
.LFB3:
	.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	$2368, %rsp
	movq	%rdi, -4000056(%rbp)
	movq	%rsi, -4000064(%rbp)
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, %eax
	call	initqueue
	movq	-4000056(%rbp), %rax
	movq	%rax, %rdi
	call	enqueue
	movl	$0, -4000044(%rbp)
	jmp	.L6
.L9:
	movl	$0, -4000040(%rbp)
	jmp	.L7
.L8:
	movl	-4000040(%rbp), %eax
	movslq	%eax, %rdx
	movl	-4000044(%rbp), %eax
	cltq
	imulq	$1000, %rax, %rax
	addq	%rdx, %rax
	movl	$-1, -4000016(%rbp,%rax,4)
	addl	$1, -4000040(%rbp)
.L7:
	movl	w(%rip), %eax
	cmpl	%eax, -4000040(%rbp)
	jl	.L8
	addl	$1, -4000044(%rbp)
.L6:
	movl	h(%rip), %eax
	cmpl	%eax, -4000044(%rbp)
	jl	.L9
	movl	-4000052(%rbp), %eax
	movl	-4000056(%rbp), %edx
	movslq	%edx, %rdx
	cltq
	imulq	$1000, %rax, %rax
	addq	%rdx, %rax
	movl	$0, -4000016(%rbp,%rax,4)
	jmp	.L10
.L19:
	movl	$0, %eax
	call	dequeue
	movq	%rax, -4000032(%rbp)
	movl	$0, -4000036(%rbp)
	jmp	.L11
.L17:
	movl	-4000032(%rbp), %ecx
	movl	-4000036(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	dx(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%ecx, %eax
	movl	%eax, -4000024(%rbp)
	movl	-4000028(%rbp), %ecx
	movl	-4000036(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	dy(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%ecx, %eax
	movl	%eax, -4000020(%rbp)
	movl	-4000024(%rbp), %eax
	testl	%eax, %eax
	js	.L22
	movl	-4000024(%rbp), %edx
	movl	w(%rip), %eax
	cmpl	%eax, %edx
	jge	.L22
	movl	-4000020(%rbp), %eax
	testl	%eax, %eax
	js	.L22
	movl	-4000020(%rbp), %edx
	movl	h(%rip), %eax
	cmpl	%eax, %edx
	jge	.L22
	movl	-4000020(%rbp), %eax
	movl	-4000024(%rbp), %edx
	movslq	%edx, %rdx
	cltq
	imulq	$1000, %rax, %rax
	addq	%rdx, %rax
	movl	-4000016(%rbp,%rax,4), %eax
	cmpl	$-1, %eax
	jne	.L23
	movl	-4000020(%rbp), %eax
	movl	-4000024(%rbp), %edx
	movslq	%edx, %rdx
	cltq
	imulq	$1000, %rax, %rax
	addq	%rax, %rdx
	leaq	map(%rip), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	$35, %al
	je	.L23
	movq	-4000024(%rbp), %rax
	movq	%rax, %rdi
	call	enqueue
	movl	-4000028(%rbp), %eax
	movl	-4000032(%rbp), %edx
	movslq	%edx, %rdx
	cltq
	imulq	$1000, %rax, %rax
	addq	%rdx, %rax
	movl	-4000016(%rbp,%rax,4), %edx
	movl	-4000020(%rbp), %eax
	movl	-4000024(%rbp), %ecx
	addl	$1, %edx
	movslq	%ecx, %rcx
	cltq
	imulq	$1000, %rax, %rax
	addq	%rcx, %rax
	movl	%edx, -4000016(%rbp,%rax,4)
	jmp	.L14
.L22:
	nop
	jmp	.L14
.L23:
	nop
.L14:
	addl	$1, -4000036(%rbp)
.L11:
	cmpl	$3, -4000036(%rbp)
	jle	.L17
	movl	-4000060(%rbp), %eax
	movl	-4000064(%rbp), %edx
	movslq	%edx, %rdx
	cltq
	imulq	$1000, %rax, %rax
	addq	%rdx, %rax
	movl	-4000016(%rbp,%rax,4), %eax
	cmpl	$-1, %eax
	je	.L10
	movl	-4000060(%rbp), %eax
	movl	-4000064(%rbp), %edx
	movslq	%edx, %rdx
	cltq
	imulq	$1000, %rax, %rax
	addq	%rdx, %rax
	movl	-4000016(%rbp,%rax,4), %eax
	jmp	.L20
.L10:
	movl	queue(%rip), %edx
	movl	4+queue(%rip), %eax
	cmpl	%eax, %edx
	jne	.L19
	movl	$-1, %eax
.L20:
	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
.LFE3:
	.size	bfs, .-bfs
	.section	.rodata
.LC0:
	.string	"%d %d"
.LC1:
	.string	"%s"
.LC2:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB4:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$48, %rsp
	leaq	w(%rip), %rax
	movq	%rax, %rdx
	leaq	h(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -40(%rbp)
	jmp	.L25
.L26:
	movl	-40(%rbp), %eax
	cltq
	imulq	$1000, %rax, %rax
	leaq	map(%rip), %rdx
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -40(%rbp)
.L25:
	movl	h(%rip), %eax
	cmpl	%eax, -40(%rbp)
	jl	.L26
	movl	$-1, -36(%rbp)
	movl	$0, -32(%rbp)
	jmp	.L27
.L41:
	movl	$0, -28(%rbp)
	jmp	.L28
.L40:
	movl	-28(%rbp), %eax
	movslq	%eax, %rdx
	movl	-32(%rbp), %eax
	cltq
	imulq	$1000, %rax, %rax
	addq	%rax, %rdx
	leaq	map(%rip), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	$35, %al
	je	.L43
	movl	$0, -24(%rbp)
	jmp	.L31
.L39:
	movl	$0, -20(%rbp)
	jmp	.L32
.L38:
	movl	-20(%rbp), %eax
	movslq	%eax, %rdx
	movl	-24(%rbp), %eax
	cltq
	imulq	$1000, %rax, %rax
	addq	%rax, %rdx
	leaq	map(%rip), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	$35, %al
	je	.L44
	movl	-32(%rbp), %eax
	cmpl	-24(%rbp), %eax
	jne	.L35
	movl	-28(%rbp), %eax
	cmpl	-20(%rbp), %eax
	je	.L45
.L35:
	movl	-28(%rbp), %eax
	movl	%eax, -16(%rbp)
	movl	-32(%rbp), %eax
	movl	%eax, -12(%rbp)
	movl	-20(%rbp), %eax
	movl	%eax, -8(%rbp)
	movl	-24(%rbp), %eax
	movl	%eax, -4(%rbp)
	movq	-8(%rbp), %rdx
	movq	-16(%rbp), %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	bfs
	cmpl	%eax, -36(%rbp)
	jg	.L36
	movq	-8(%rbp), %rdx
	movq	-16(%rbp), %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	bfs
	jmp	.L37
.L36:
	movl	-36(%rbp), %eax
.L37:
	movl	%eax, -36(%rbp)
	jmp	.L34
.L44:
	nop
	jmp	.L34
.L45:
	nop
.L34:
	addl	$1, -20(%rbp)
.L32:
	movl	w(%rip), %eax
	cmpl	%eax, -20(%rbp)
	jl	.L38
	addl	$1, -24(%rbp)
.L31:
	movl	h(%rip), %eax
	cmpl	%eax, -24(%rbp)
	jl	.L39
	jmp	.L30
.L43:
	nop
.L30:
	addl	$1, -28(%rbp)
.L28:
	movl	w(%rip), %eax
	cmpl	%eax, -28(%rbp)
	jl	.L40
	addl	$1, -32(%rbp)
.L27:
	movl	h(%rip), %eax
	cmpl	%eax, -32(%rbp)
	jl	.L41
	movl	-36(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE4:
	.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	initqueue
	.type	initqueue, @function
initqueue:
.LFB23:
	.cfi_startproc
	endbr64
	movq	$0, queue(%rip)
	ret
	.cfi_endproc
.LFE23:
	.size	initqueue, .-initqueue
	.p2align 4
	.globl	enqueue
	.type	enqueue, @function
enqueue:
.LFB24:
	.cfi_startproc
	endbr64
	movslq	4+queue(%rip), %rax
	leal	1(%rax), %edx
	movl	%edx, 4+queue(%rip)
	leaq	queue(%rip), %rdx
	movq	%rdi, 8(%rdx,%rax,8)
	ret
	.cfi_endproc
.LFE24:
	.size	enqueue, .-enqueue
	.p2align 4
	.globl	dequeue
	.type	dequeue, @function
dequeue:
.LFB25:
	.cfi_startproc
	endbr64
	movslq	queue(%rip), %rax
	leal	1(%rax), %edx
	movl	%edx, queue(%rip)
	leaq	queue(%rip), %rdx
	movq	8(%rdx,%rax,8), %rax
	ret
	.cfi_endproc
.LFE25:
	.size	dequeue, .-dequeue
	.p2align 4
	.globl	bfs
	.type	bfs, @function
bfs:
.LFB26:
	.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	$2360, %rsp
	.cfi_def_cfa_offset 4000112
	movl	h(%rip), %r15d
	movl	w(%rip), %r8d
	movq	%fs:40, %rax
	movq	%rax, 4000040(%rsp)
	xorl	%eax, %eax
	movq	.LC0(%rip), %rax
	movq	%rsi, %rbx
	movl	%edi, 4(%rsp)
	movq	%rdi, %xmm0
	movq	%rdi, 8+queue(%rip)
	movslq	%esi, %r14
	shrq	$32, %rbx
	pshufd	$0xe5, %xmm0, %xmm1
	movq	%rax, queue(%rip)
	movd	%xmm1, %r13d
	testl	%r15d, %r15d
	jle	.L6
	testl	%r8d, %r8d
	jle	.L6
	leal	-1(%r15), %eax
	movl	%r8d, 8(%rsp)
	movslq	%r8d, %rbp
	leaq	32(%rsp), %rcx
	imulq	$4000, %rax, %rax
	salq	$2, %rbp
	leaq	4032(%rsp,%rax), %r12
	.p2align 4,,10
	.p2align 3
.L7:
	movq	%rcx, %rdi
	movq	%rbp, %rdx
	movl	$255, %esi
	call	memset@PLT
	movq	%rax, %rcx
	addq	$4000, %rcx
	cmpq	%r12, %rcx
	jne	.L7
	movl	8(%rsp), %r8d
.L6:
	movslq	%r13d, %rax
	movslq	4(%rsp), %rdx
	movslq	%ebx, %r12
	movl	$1, %esi
	imulq	$1000, %rax, %rax
	movl	12+dx(%rip), %r9d
	movl	dx(%rip), %ebp
	leaq	queue(%rip), %rcx
	imulq	$1000, %r12, %r12
	movl	4+dx(%rip), %r11d
	movl	8+dx(%rip), %r10d
	movl	%r9d, 4(%rsp)
	addq	%rdx, %rax
	movl	$0, 32(%rsp,%rax,4)
	movl	dy(%rip), %eax
	addq	%r14, %r12
	movl	%ebp, %r14d
	movl	%eax, 8(%rsp)
	movl	4+dy(%rip), %eax
	movl	%eax, 12(%rsp)
	movl	8+dy(%rip), %eax
	movl	%eax, 16(%rsp)
	movl	12+dy(%rip), %eax
	movl	%eax, 20(%rsp)
	xorl	%eax, %eax
	.p2align 4,,10
	.p2align 3
.L13:
	leal	1(%rax), %edx
	movl	%edx, (%rcx)
	leaq	8(%rcx,%rax,8), %rdx
	movslq	(%rdx), %rax
	movslq	4(%rdx), %rdx
	movl	%eax, %ebx
	addl	%r14d, %ebx
	js	.L8
	movl	8(%rsp), %edi
	addl	%edx, %edi
	movl	%edi, %ebp
	shrl	$31, %ebp
	cmpl	%r8d, %ebx
	setge	%r13b
	orb	%r13b, %bpl
	jne	.L8
	cmpl	%edi, %r15d
	jle	.L8
	movslq	%edi, %rbp
	movslq	%ebx, %r13
	imulq	$1000, %rbp, %rbp
	leaq	0(%rbp,%r13), %r9
	cmpl	$-1, 32(%rsp,%r9,4)
	movq	%r9, 24(%rsp)
	jne	.L8
	leaq	map(%rip), %r9
	addq	%r9, %rbp
	cmpb	$35, 0(%rbp,%r13)
	je	.L8
	leal	1(%rsi), %ebp
	leaq	8(%rcx,%rsi,8), %rsi
	movq	24(%rsp), %r9
	movl	%ebp, 4+queue(%rip)
	movl	%edi, 4(%rsi)
	movslq	%eax, %rdi
	movl	%ebx, (%rsi)
	movslq	%edx, %rsi
	imulq	$1000, %rsi, %rsi
	addq	%rdi, %rsi
	movl	32(%rsp,%rsi,4), %esi
	addl	$1, %esi
	movl	%esi, 32(%rsp,%r9,4)
	.p2align 4,,10
	.p2align 3
.L8:
	movl	%eax, %edi
	addl	%r11d, %edi
	js	.L9
	movl	12(%rsp), %esi
	addl	%edx, %esi
	cmpl	%r8d, %edi
	movl	%esi, %ebx
	setge	%bpl
	shrl	$31, %ebx
	orb	%bpl, %bl
	jne	.L9
	cmpl	%esi, %r15d
	jle	.L9
	movslq	%esi, %rbx
	movslq	%edi, %rbp
	imulq	$1000, %rbx, %rbx
	leaq	(%rbx,%rbp), %r13
	cmpl	$-1, 32(%rsp,%r13,4)
	jne	.L9
	leaq	map(%rip), %r9
	addq	%r9, %rbx
	cmpb	$35, (%rbx,%rbp)
	je	.L9
	movslq	4+queue(%rip), %rbx
	leal	1(%rbx), %ebp
	leaq	8(%rcx,%rbx,8), %rbx
	movl	%ebp, 4+queue(%rip)
	movl	%esi, 4(%rbx)
	movslq	%edx, %rsi
	imulq	$1000, %rsi, %rsi
	movl	%edi, (%rbx)
	movslq	%eax, %rdi
	addq	%rdi, %rsi
	movl	32(%rsp,%rsi,4), %esi
	addl	$1, %esi
	movl	%esi, 32(%rsp,%r13,4)
	.p2align 4,,10
	.p2align 3
.L9:
	movl	%eax, %edi
	addl	%r10d, %edi
	js	.L10
	movl	16(%rsp), %esi
	addl	%edx, %esi
	movl	%esi, %ebx
	shrl	$31, %ebx
	cmpl	%r8d, %edi
	setge	%bpl
	orb	%bpl, %bl
	jne	.L10
	cmpl	%esi, %r15d
	jle	.L10
	movslq	%esi, %rbx
	movslq	%edi, %rbp
	imulq	$1000, %rbx, %rbx
	leaq	(%rbx,%rbp), %r13
	cmpl	$-1, 32(%rsp,%r13,4)
	jne	.L10
	leaq	map(%rip), %r9
	addq	%r9, %rbx
	cmpb	$35, (%rbx,%rbp)
	je	.L10
	movslq	4+queue(%rip), %rbx
	leal	1(%rbx), %ebp
	leaq	8(%rcx,%rbx,8), %rbx
	movl	%ebp, 4+queue(%rip)
	movl	%esi, 4(%rbx)
	movslq	%edx, %rsi
	imulq	$1000, %rsi, %rsi
	movl	%edi, (%rbx)
	movslq	%eax, %rdi
	addq	%rdi, %rsi
	movl	32(%rsp,%rsi,4), %esi
	addl	$1, %esi
	movl	%esi, 32(%rsp,%r13,4)
	.p2align 4,,10
	.p2align 3
.L10:
	movl	%eax, %edi
	addl	4(%rsp), %edi
	js	.L11
	movl	20(%rsp), %esi
	addl	%edx, %esi
	movl	%esi, %ebx
	shrl	$31, %ebx
	cmpl	%r8d, %edi
	setge	%bpl
	orb	%bpl, %bl
	jne	.L11
	cmpl	%esi, %r15d
	jle	.L11
	movslq	%esi, %rbx
	movslq	%edi, %rbp
	imulq	$1000, %rbx, %rbx
	leaq	(%rbx,%rbp), %r13
	cmpl	$-1, 32(%rsp,%r13,4)
	jne	.L11
	leaq	map(%rip), %r9
	addq	%r9, %rbx
	cmpb	$35, (%rbx,%rbp)
	je	.L11
	imulq	$1000, %rdx, %rdx
	movslq	4+queue(%rip), %rbx
	leal	1(%rbx), %ebp
	leaq	8(%rcx,%rbx,8), %rbx
	addq	%rdx, %rax
	movl	%ebp, 4+queue(%rip)
	movl	32(%rsp,%rax,4), %eax
	movl	%edi, (%rbx)
	movl	%esi, 4(%rbx)
	addl	$1, %eax
	movl	%eax, 32(%rsp,%r13,4)
	.p2align 4,,10
	.p2align 3
.L11:
	movl	32(%rsp,%r12,4), %r13d
	cmpl	$-1, %r13d
	jne	.L5
	movslq	(%rcx), %rax
	movslq	4+queue(%rip), %rsi
	cmpl	%esi, %eax
	jne	.L13
.L5:
	movq	4000040(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L18
	addq	$4000056, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	movl	%r13d, %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
.L18:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE26:
	.size	bfs, .-bfs
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC1:
	.string	"%d %d"
.LC2:
	.string	"%s"
.LC3:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB27:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	w(%rip), %rdx
	leaq	h(%rip), %rsi
	xorl	%eax, %eax
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	leaq	.LC1(%rip), %rdi
	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
	subq	$40, %rsp
	.cfi_def_cfa_offset 96
	call	__isoc99_scanf@PLT
	movl	h(%rip), %eax
	testl	%eax, %eax
	jle	.L20
	leaq	map(%rip), %rbp
	xorl	%ebx, %ebx
	leaq	.LC2(%rip), %r12
.L21:
	movq	%rbp, %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	addl	$1, %ebx
	call	__isoc99_scanf@PLT
	movl	h(%rip), %edx
	addq	$1000, %rbp
	cmpl	%ebx, %edx
	jg	.L21
	testl	%edx, %edx
	jle	.L20
	movl	$-1, 16(%rsp)
	movl	w(%rip), %eax
	xorl	%ebp, %ebp
.L22:
	movl	%ebp, 20(%rsp)
	testl	%eax, %eax
	jle	.L34
	imulq	$1000, %rbp, %r15
	leaq	map(%rip), %rsi
	movq	$0, 8(%rsp)
	addq	%r15, %rsi
	movq	%rsi, 24(%rsp)
	.p2align 4,,10
	.p2align 3
.L31:
	movq	8(%rsp), %rsi
	movq	24(%rsp), %rdi
	movd	20(%rsp), %xmm2
	movd	%esi, %xmm0
	cmpb	$35, (%rdi,%rsi)
	punpckldq	%xmm2, %xmm0
	je	.L23
	leaq	map(%rip), %r15
	xorl	%ebx, %ebx
	movq	%xmm0, %r14
	testl	%edx, %edx
	jle	.L23
	testl	%eax, %eax
	jle	.L34
	.p2align 4,,10
	.p2align 3
.L36:
	xorl	%r12d, %r12d
	jmp	.L28
	.p2align 4,,10
	.p2align 3
.L25:
	addq	$1, %r12
	cmpl	%r12d, %eax
	jle	.L48
.L28:
	movd	%r12d, %xmm0
	movd	%ebx, %xmm1
	cmpb	$35, (%r15,%r12)
	punpckldq	%xmm1, %xmm0
	je	.L25
	cmpl	%ebp, %ebx
	jne	.L37
	cmpl	%r12d, 8(%rsp)
	je	.L25
.L37:
	movq	%xmm0, %rsi
	movq	%r14, %rdi
	movq	%xmm0, %r13
	call	bfs
	cmpl	16(%rsp), %eax
	jge	.L27
.L47:
	movl	w(%rip), %eax
	addq	$1, %r12
	cmpl	%r12d, %eax
	jg	.L28
.L48:
	movl	h(%rip), %edx
	addl	$1, %ebx
	cmpl	%ebx, %edx
	jle	.L23
	addq	$1000, %r15
	testl	%eax, %eax
	jg	.L36
.L34:
	addq	$1, %rbp
	cmpl	%ebp, %edx
	jg	.L22
.L32:
	movl	16(%rsp), %edx
	leaq	.LC3(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	addq	$40, %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
	.p2align 4,,10
	.p2align 3
.L27:
	.cfi_restore_state
	movq	%r13, %rsi
	movq	%r14, %rdi
	call	bfs
	movl	%eax, 16(%rsp)
	jmp	.L47
	.p2align 4,,10
	.p2align 3
.L23:
	addq	$1, 8(%rsp)
	movq	8(%rsp), %rdi
	cmpl	%edi, %eax
	jg	.L31
	jmp	.L34
.L20:
	movl	$-1, 16(%rsp)
	jmp	.L32
	.cfi_endproc
.LFE27:
	.size	main, .-main
	.globl	map
	.bss
	.align 32
	.type	map, @object
	.size	map, 1000000
map:
	.zero	1000000
	.globl	w
	.align 4
	.type	w, @object
	.size	w, 4
w:
	.zero	4
	.globl	h
	.align 4
	.type	h, @object
	.size	h, 4
h:
	.zero	4
	.globl	queue
	.align 32
	.type	queue, @object
	.size	queue, 1600008
queue:
	.zero	1600008
	.globl	dy
	.data
	.align 16
	.type	dy, @object
	.size	dy, 16
dy:
	.long	0
	.long	-1
	.long	0
	.long	1
	.globl	dx
	.align 16
	.type	dx, @object
	.size	dx, 16
dx:
	.long	1
	.long	0
	.long	-1
	.long	0
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC0:
	.long	0
	.long	1
	.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	initqueue
	.type	initqueue, @function
initqueue:
.LFB23:
	.cfi_startproc
	endbr64
	movq	$0, queue(%rip)
	ret
	.cfi_endproc
.LFE23:
	.size	initqueue, .-initqueue
	.p2align 4
	.globl	enqueue
	.type	enqueue, @function
enqueue:
.LFB24:
	.cfi_startproc
	endbr64
	movslq	4+queue(%rip), %rax
	leal	1(%rax), %edx
	movl	%edx, 4+queue(%rip)
	leaq	queue(%rip), %rdx
	movq	%rdi, 8(%rdx,%rax,8)
	ret
	.cfi_endproc
.LFE24:
	.size	enqueue, .-enqueue
	.p2align 4
	.globl	dequeue
	.type	dequeue, @function
dequeue:
.LFB25:
	.cfi_startproc
	endbr64
	movslq	queue(%rip), %rax
	leal	1(%rax), %edx
	movl	%edx, queue(%rip)
	leaq	queue(%rip), %rdx
	movq	8(%rdx,%rax,8), %rax
	ret
	.cfi_endproc
.LFE25:
	.size	dequeue, .-dequeue
	.p2align 4
	.globl	bfs
	.type	bfs, @function
bfs:
.LFB26:
	.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	$2360, %rsp
	.cfi_def_cfa_offset 4000112
	movl	h(%rip), %r15d
	movl	w(%rip), %r8d
	movq	%fs:40, %rax
	movq	%rax, 4000040(%rsp)
	xorl	%eax, %eax
	movq	.LC0(%rip), %rax
	movq	%rsi, %rbx
	movl	%edi, 4(%rsp)
	movq	%rdi, %xmm0
	movq	%rdi, 8+queue(%rip)
	movslq	%esi, %r14
	shrq	$32, %rbx
	pshufd	$0xe5, %xmm0, %xmm1
	movq	%rax, queue(%rip)
	movd	%xmm1, %r13d
	testl	%r15d, %r15d
	jle	.L6
	testl	%r8d, %r8d
	jle	.L6
	leal	-1(%r15), %eax
	movl	%r8d, 8(%rsp)
	movslq	%r8d, %rbp
	leaq	32(%rsp), %rcx
	imulq	$4000, %rax, %rax
	salq	$2, %rbp
	leaq	4032(%rsp,%rax), %r12
	.p2align 4,,10
	.p2align 3
.L7:
	movq	%rcx, %rdi
	movq	%rbp, %rdx
	movl	$255, %esi
	call	memset@PLT
	movq	%rax, %rcx
	addq	$4000, %rcx
	cmpq	%r12, %rcx
	jne	.L7
	movl	8(%rsp), %r8d
.L6:
	movslq	%r13d, %rax
	movslq	4(%rsp), %rdx
	movslq	%ebx, %r12
	movl	$1, %esi
	imulq	$1000, %rax, %rax
	movl	12+dx(%rip), %r9d
	movl	dx(%rip), %ebp
	leaq	queue(%rip), %rcx
	imulq	$1000, %r12, %r12
	movl	4+dx(%rip), %r11d
	movl	8+dx(%rip), %r10d
	movl	%r9d, 4(%rsp)
	addq	%rdx, %rax
	movl	$0, 32(%rsp,%rax,4)
	movl	dy(%rip), %eax
	addq	%r14, %r12
	movl	%ebp, %r14d
	movl	%eax, 8(%rsp)
	movl	4+dy(%rip), %eax
	movl	%eax, 12(%rsp)
	movl	8+dy(%rip), %eax
	movl	%eax, 16(%rsp)
	movl	12+dy(%rip), %eax
	movl	%eax, 20(%rsp)
	xorl	%eax, %eax
	.p2align 4,,10
	.p2align 3
.L13:
	leal	1(%rax), %edx
	movl	%edx, (%rcx)
	leaq	8(%rcx,%rax,8), %rdx
	movslq	(%rdx), %rax
	movslq	4(%rdx), %rdx
	movl	%eax, %ebx
	addl	%r14d, %ebx
	js	.L8
	movl	8(%rsp), %edi
	addl	%edx, %edi
	movl	%edi, %ebp
	shrl	$31, %ebp
	cmpl	%r8d, %ebx
	setge	%r13b
	orb	%r13b, %bpl
	jne	.L8
	cmpl	%edi, %r15d
	jle	.L8
	movslq	%edi, %rbp
	movslq	%ebx, %r13
	imulq	$1000, %rbp, %rbp
	leaq	0(%rbp,%r13), %r9
	cmpl	$-1, 32(%rsp,%r9,4)
	movq	%r9, 24(%rsp)
	jne	.L8
	leaq	map(%rip), %r9
	addq	%r9, %rbp
	cmpb	$35, 0(%rbp,%r13)
	je	.L8
	leal	1(%rsi), %ebp
	leaq	8(%rcx,%rsi,8), %rsi
	movq	24(%rsp), %r9
	movl	%ebp, 4+queue(%rip)
	movl	%edi, 4(%rsi)
	movslq	%eax, %rdi
	movl	%ebx, (%rsi)
	movslq	%edx, %rsi
	imulq	$1000, %rsi, %rsi
	addq	%rdi, %rsi
	movl	32(%rsp,%rsi,4), %esi
	addl	$1, %esi
	movl	%esi, 32(%rsp,%r9,4)
	.p2align 4,,10
	.p2align 3
.L8:
	movl	%eax, %edi
	addl	%r11d, %edi
	js	.L9
	movl	12(%rsp), %esi
	addl	%edx, %esi
	cmpl	%r8d, %edi
	movl	%esi, %ebx
	setge	%bpl
	shrl	$31, %ebx
	orb	%bpl, %bl
	jne	.L9
	cmpl	%esi, %r15d
	jle	.L9
	movslq	%esi, %rbx
	movslq	%edi, %rbp
	imulq	$1000, %rbx, %rbx
	leaq	(%rbx,%rbp), %r13
	cmpl	$-1, 32(%rsp,%r13,4)
	jne	.L9
	leaq	map(%rip), %r9
	addq	%r9, %rbx
	cmpb	$35, (%rbx,%rbp)
	je	.L9
	movslq	4+queue(%rip), %rbx
	leal	1(%rbx), %ebp
	leaq	8(%rcx,%rbx,8), %rbx
	movl	%ebp, 4+queue(%rip)
	movl	%esi, 4(%rbx)
	movslq	%edx, %rsi
	imulq	$1000, %rsi, %rsi
	movl	%edi, (%rbx)
	movslq	%eax, %rdi
	addq	%rdi, %rsi
	movl	32(%rsp,%rsi,4), %esi
	addl	$1, %esi
	movl	%esi, 32(%rsp,%r13,4)
	.p2align 4,,10
	.p2align 3
.L9:
	movl	%eax, %edi
	addl	%r10d, %edi
	js	.L10
	movl	16(%rsp), %esi
	addl	%edx, %esi
	movl	%esi, %ebx
	shrl	$31, %ebx
	cmpl	%r8d, %edi
	setge	%bpl
	orb	%bpl, %bl
	jne	.L10
	cmpl	%esi, %r15d
	jle	.L10
	movslq	%esi, %rbx
	movslq	%edi, %rbp
	imulq	$1000, %rbx, %rbx
	leaq	(%rbx,%rbp), %r13
	cmpl	$-1, 32(%rsp,%r13,4)
	jne	.L10
	leaq	map(%rip), %r9
	addq	%r9, %rbx
	cmpb	$35, (%rbx,%rbp)
	je	.L10
	movslq	4+queue(%rip), %rbx
	leal	1(%rbx), %ebp
	leaq	8(%rcx,%rbx,8), %rbx
	movl	%ebp, 4+queue(%rip)
	movl	%esi, 4(%rbx)
	movslq	%edx, %rsi
	imulq	$1000, %rsi, %rsi
	movl	%edi, (%rbx)
	movslq	%eax, %rdi
	addq	%rdi, %rsi
	movl	32(%rsp,%rsi,4), %esi
	addl	$1, %esi
	movl	%esi, 32(%rsp,%r13,4)
	.p2align 4,,10
	.p2align 3
.L10:
	movl	%eax, %edi
	addl	4(%rsp), %edi
	js	.L11
	movl	20(%rsp), %esi
	addl	%edx, %esi
	movl	%esi, %ebx
	shrl	$31, %ebx
	cmpl	%r8d, %edi
	setge	%bpl
	orb	%bpl, %bl
	jne	.L11
	cmpl	%esi, %r15d
	jle	.L11
	movslq	%esi, %rbx
	movslq	%edi, %rbp
	imulq	$1000, %rbx, %rbx
	leaq	(%rbx,%rbp), %r13
	cmpl	$-1, 32(%rsp,%r13,4)
	jne	.L11
	leaq	map(%rip), %r9
	addq	%r9, %rbx
	cmpb	$35, (%rbx,%rbp)
	je	.L11
	imulq	$1000, %rdx, %rdx
	movslq	4+queue(%rip), %rbx
	leal	1(%rbx), %ebp
	leaq	8(%rcx,%rbx,8), %rbx
	addq	%rdx, %rax
	movl	%ebp, 4+queue(%rip)
	movl	32(%rsp,%rax,4), %eax
	movl	%edi, (%rbx)
	movl	%esi, 4(%rbx)
	addl	$1, %eax
	movl	%eax, 32(%rsp,%r13,4)
	.p2align 4,,10
	.p2align 3
.L11:
	movl	32(%rsp,%r12,4), %r13d
	cmpl	$-1, %r13d
	jne	.L5
	movslq	(%rcx), %rax
	movslq	4+queue(%rip), %rsi
	cmpl	%esi, %eax
	jne	.L13
.L5:
	movq	4000040(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L18
	addq	$4000056, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	movl	%r13d, %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
.L18:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE26:
	.size	bfs, .-bfs
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC1:
	.string	"%d %d"
.LC2:
	.string	"%s"
.LC3:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB27:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	w(%rip), %rdx
	leaq	h(%rip), %rsi
	xorl	%eax, %eax
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	leaq	.LC1(%rip), %rdi
	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
	subq	$40, %rsp
	.cfi_def_cfa_offset 96
	call	__isoc99_scanf@PLT
	movl	h(%rip), %eax
	testl	%eax, %eax
	jle	.L20
	leaq	map(%rip), %rbp
	xorl	%ebx, %ebx
	leaq	.LC2(%rip), %r12
.L21:
	movq	%rbp, %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	addl	$1, %ebx
	call	__isoc99_scanf@PLT
	movl	h(%rip), %edx
	addq	$1000, %rbp
	cmpl	%ebx, %edx
	jg	.L21
	testl	%edx, %edx
	jle	.L20
	movl	$-1, 16(%rsp)
	movl	w(%rip), %eax
	xorl	%ebp, %ebp
.L22:
	movl	%ebp, 20(%rsp)
	testl	%eax, %eax
	jle	.L34
	imulq	$1000, %rbp, %r15
	leaq	map(%rip), %rsi
	movq	$0, 8(%rsp)
	addq	%r15, %rsi
	movq	%rsi, 24(%rsp)
	.p2align 4,,10
	.p2align 3
.L31:
	movq	8(%rsp), %rsi
	movq	24(%rsp), %rdi
	movd	20(%rsp), %xmm2
	movd	%esi, %xmm0
	cmpb	$35, (%rdi,%rsi)
	punpckldq	%xmm2, %xmm0
	je	.L23
	leaq	map(%rip), %r15
	xorl	%ebx, %ebx
	movq	%xmm0, %r14
	testl	%edx, %edx
	jle	.L23
	testl	%eax, %eax
	jle	.L34
	.p2align 4,,10
	.p2align 3
.L36:
	xorl	%r12d, %r12d
	jmp	.L28
	.p2align 4,,10
	.p2align 3
.L25:
	addq	$1, %r12
	cmpl	%r12d, %eax
	jle	.L48
.L28:
	movd	%r12d, %xmm0
	movd	%ebx, %xmm1
	cmpb	$35, (%r15,%r12)
	punpckldq	%xmm1, %xmm0
	je	.L25
	cmpl	%ebp, %ebx
	jne	.L37
	cmpl	%r12d, 8(%rsp)
	je	.L25
.L37:
	movq	%xmm0, %rsi
	movq	%r14, %rdi
	movq	%xmm0, %r13
	call	bfs
	cmpl	16(%rsp), %eax
	jge	.L27
.L47:
	movl	w(%rip), %eax
	addq	$1, %r12
	cmpl	%r12d, %eax
	jg	.L28
.L48:
	movl	h(%rip), %edx
	addl	$1, %ebx
	cmpl	%ebx, %edx
	jle	.L23
	addq	$1000, %r15
	testl	%eax, %eax
	jg	.L36
.L34:
	addq	$1, %rbp
	cmpl	%ebp, %edx
	jg	.L22
.L32:
	movl	16(%rsp), %edx
	leaq	.LC3(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	addq	$40, %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
	.p2align 4,,10
	.p2align 3
.L27:
	.cfi_restore_state
	movq	%r13, %rsi
	movq	%r14, %rdi
	call	bfs
	movl	%eax, 16(%rsp)
	jmp	.L47
	.p2align 4,,10
	.p2align 3
.L23:
	addq	$1, 8(%rsp)
	movq	8(%rsp), %rdi
	cmpl	%edi, %eax
	jg	.L31
	jmp	.L34
.L20:
	movl	$-1, 16(%rsp)
	jmp	.L32
	.cfi_endproc
.LFE27:
	.size	main, .-main
	.globl	map
	.bss
	.align 32
	.type	map, @object
	.size	map, 1000000
map:
	.zero	1000000
	.globl	w
	.align 4
	.type	w, @object
	.size	w, 4
w:
	.zero	4
	.globl	h
	.align 4
	.type	h, @object
	.size	h, 4
h:
	.zero	4
	.globl	queue
	.align 32
	.type	queue, @object
	.size	queue, 1600008
queue:
	.zero	1600008
	.globl	dy
	.data
	.align 16
	.type	dy, @object
	.size	dy, 16
dy:
	.long	0
	.long	-1
	.long	0
	.long	1
	.globl	dx
	.align 16
	.type	dx, @object
	.size	dx, 16
dx:
	.long	1
	.long	0
	.long	-1
	.long	0
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC0:
	.long	0
	.long	1
	.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(x,y) (x>y?x:y)
int dx[]={1,0,-1,0};
int dy[]={0,-1,0,1};
typedef struct{
    int x;
    int y;
}data_t;
typedef struct{
    int head;
    int tail;
    data_t data[200000];
}queue_t;
queue_t queue;
void initqueue(){queue.head=queue.tail=0;}
void enqueue(data_t data){queue.data[queue.tail++]=data;}
data_t dequeue(){return queue.data[queue.head++];}

int h,w;
char map[1000][1000];

int bfs(data_t start,data_t goal){
    int dist[1000][1000];
    data_t now,move;

    initqueue();
    enqueue(start);
    
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            dist[i][j]=-1;
        }
    }
    dist[start.y][start.x]=0;

    while(queue.head!=queue.tail){   
        now=dequeue();
        for(int i=0;i<4;i++){
            move.x=now.x+dx[i];
            move.y=now.y+dy[i];
            if(move.x<0||w<=move.x||move.y<0||h<=move.y)continue;
            if(dist[move.y][move.x]!=-1||map[move.y][move.x]=='#')continue;
            enqueue(move);
            dist[move.y][move.x]=dist[now.y][now.x]+1;
        }
        if(dist[goal.y][goal.x]!=-1)return dist[goal.y][goal.x];
    }
    return -1;
}
int main(){
    scanf("%d %d",&h,&w);
    for(int i=0;i<h;i++)scanf("%s",map[i]);
    int ans=-1;
    data_t start,end;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(map[i][j]=='#')continue;
            for(int ii=0;ii<h;ii++){
                for(int jj=0;jj<w;jj++){
                    if(map[ii][jj]=='#')continue;
                    if(i==ii&&j==jj)continue;
                    start.x=j;
                    start.y=i;
                    end.x=jj;
                    end.y=ii;
                    ans=max(ans,bfs(start,end));
                }
            }
        }
    }
    printf("%d\n",ans);

    return 0;
}
3 3
...
../
...
 0 5
...#.
.#.#.
.#...
 0 5
.#...
.#.#.
.#...
 0 5
.#...
.#.#.
.$...
 0 5
.#..-
.#.#.
.$...
 0 5
.#..-
.#.#.
.$..-
 -1 5
.#..-
.#.#.
.$..-
 0 6
.#..-
.#.#.
.$..-
 0 6
.#..-
.#.$.
.$..-
 0 6
.#..-
.#/$.
.$..-

4
 -1
 -1
 -1
 -1
 -1
 -1
 -1
 -1
 -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(x,y) (x>y?x:y)
int dx[]={1,0,-1,0};
int dy[]={0,-1,0,1};
typedef struct{
    int x;
    int y;
}data_t;
typedef struct{
    int head;
    int tail;
    data_t data[200000];
}queue_t;
queue_t queue;
void initqueue(){queue.head=queue.tail=0;}
void enqueue(data_t data){queue.data[queue.tail++]=data;}
data_t dequeue(){return queue.data[queue.head++];}

int h,w;
char map[1000][1000];

int bfs(data_t start,data_t goal){
    int dist[1000][1000];
    data_t now,move;

    initqueue();
    enqueue(start);
    
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            dist[i][j]=-1;
        }
    }
    dist[start.y][start.x]=0;

    while(queue.head!=queue.tail){   
        now=dequeue();
        for(int i=0;i<4;i++){
            move.x=now.x+dx[i];
            move.y=now.y+dy[i];
            if(move.x<0||w<=move.x||move.y<0||h<=move.y)continue;
            if(dist[move.y][move.x]!=-1||map[move.y][move.x]=='#')continue;
            enqueue(move);
            dist[move.y][move.x]=dist[now.y][now.x]+1;
        }
        if(dist[goal.y][goal.x]!=-1)return dist[goal.y][goal.x];
    }
    return -1;
}
int main(){
    scanf("%d %d",&h,&w);
    for(int i=0;i<h;i++)scanf("%s",map[i]);
    int ans=-1;
    data_t start,end;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(map[i][j]=='#')continue;
            for(int ii=0;ii<h;ii++){
                for(int jj=0;jj<w;jj++){
                    if(map[ii][jj]=='#')continue;
                    if(i==ii&&j==jj)continue;
                    start.x=j;
                    start.y=i;
                    end.x=jj;
                    end.y=ii;
                    ans=max(ans,bfs(start,end));
                }
            }
        }
    }
    printf("%d\n",ans);

    return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	dx
	.data
	.align 16
	.type	dx, @object
	.size	dx, 16
dx:
	.long	1
	.long	0
	.long	-1
	.long	0
	.globl	dy
	.align 16
	.type	dy, @object
	.size	dy, 16
dy:
	.long	0
	.long	-1
	.long	0
	.long	1
	.globl	queue
	.bss
	.align 32
	.type	queue, @object
	.size	queue, 1600008
queue:
	.zero	1600008
	.text
	.globl	initqueue
	.type	initqueue, @function
initqueue:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	$0, 4+queue(%rip)
	movl	4+queue(%rip), %eax
	movl	%eax, queue(%rip)
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	initqueue, .-initqueue
	.globl	enqueue
	.type	enqueue, @function
enqueue:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -8(%rbp)
	movl	4+queue(%rip), %eax
	leal	1(%rax), %edx
	movl	%edx, 4+queue(%rip)
	cltq
	leaq	0(,%rax,8), %rcx
	leaq	8+queue(%rip), %rdx
	movq	-8(%rbp), %rax
	movq	%rax, (%rcx,%rdx)
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	enqueue, .-enqueue
	.globl	dequeue
	.type	dequeue, @function
dequeue:
.LFB2:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	queue(%rip), %eax
	leal	1(%rax), %edx
	movl	%edx, queue(%rip)
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	8+queue(%rip), %rax
	movq	(%rdx,%rax), %rax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2:
	.size	dequeue, .-dequeue
	.globl	h
	.bss
	.align 4
	.type	h, @object
	.size	h, 4
h:
	.zero	4
	.globl	w
	.align 4
	.type	w, @object
	.size	w, 4
w:
	.zero	4
	.globl	map
	.align 32
	.type	map, @object
	.size	map, 1000000
map:
	.zero	1000000
	.text
	.globl	bfs
	.type	bfs, @function
bfs:
.LFB3:
	.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	$2368, %rsp
	movq	%rdi, -4000056(%rbp)
	movq	%rsi, -4000064(%rbp)
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, %eax
	call	initqueue
	movq	-4000056(%rbp), %rax
	movq	%rax, %rdi
	call	enqueue
	movl	$0, -4000044(%rbp)
	jmp	.L6
.L9:
	movl	$0, -4000040(%rbp)
	jmp	.L7
.L8:
	movl	-4000040(%rbp), %eax
	movslq	%eax, %rdx
	movl	-4000044(%rbp), %eax
	cltq
	imulq	$1000, %rax, %rax
	addq	%rdx, %rax
	movl	$-1, -4000016(%rbp,%rax,4)
	addl	$1, -4000040(%rbp)
.L7:
	movl	w(%rip), %eax
	cmpl	%eax, -4000040(%rbp)
	jl	.L8
	addl	$1, -4000044(%rbp)
.L6:
	movl	h(%rip), %eax
	cmpl	%eax, -4000044(%rbp)
	jl	.L9
	movl	-4000052(%rbp), %eax
	movl	-4000056(%rbp), %edx
	movslq	%edx, %rdx
	cltq
	imulq	$1000, %rax, %rax
	addq	%rdx, %rax
	movl	$0, -4000016(%rbp,%rax,4)
	jmp	.L10
.L19:
	movl	$0, %eax
	call	dequeue
	movq	%rax, -4000032(%rbp)
	movl	$0, -4000036(%rbp)
	jmp	.L11
.L17:
	movl	-4000032(%rbp), %ecx
	movl	-4000036(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	dx(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%ecx, %eax
	movl	%eax, -4000024(%rbp)
	movl	-4000028(%rbp), %ecx
	movl	-4000036(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	dy(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%ecx, %eax
	movl	%eax, -4000020(%rbp)
	movl	-4000024(%rbp), %eax
	testl	%eax, %eax
	js	.L22
	movl	-4000024(%rbp), %edx
	movl	w(%rip), %eax
	cmpl	%eax, %edx
	jge	.L22
	movl	-4000020(%rbp), %eax
	testl	%eax, %eax
	js	.L22
	movl	-4000020(%rbp), %edx
	movl	h(%rip), %eax
	cmpl	%eax, %edx
	jge	.L22
	movl	-4000020(%rbp), %eax
	movl	-4000024(%rbp), %edx
	movslq	%edx, %rdx
	cltq
	imulq	$1000, %rax, %rax
	addq	%rdx, %rax
	movl	-4000016(%rbp,%rax,4), %eax
	cmpl	$-1, %eax
	jne	.L23
	movl	-4000020(%rbp), %eax
	movl	-4000024(%rbp), %edx
	movslq	%edx, %rdx
	cltq
	imulq	$1000, %rax, %rax
	addq	%rax, %rdx
	leaq	map(%rip), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	$35, %al
	je	.L23
	movq	-4000024(%rbp), %rax
	movq	%rax, %rdi
	call	enqueue
	movl	-4000028(%rbp), %eax
	movl	-4000032(%rbp), %edx
	movslq	%edx, %rdx
	cltq
	imulq	$1000, %rax, %rax
	addq	%rdx, %rax
	movl	-4000016(%rbp,%rax,4), %edx
	movl	-4000020(%rbp), %eax
	movl	-4000024(%rbp), %ecx
	addl	$1, %edx
	movslq	%ecx, %rcx
	cltq
	imulq	$1000, %rax, %rax
	addq	%rcx, %rax
	movl	%edx, -4000016(%rbp,%rax,4)
	jmp	.L14
.L22:
	nop
	jmp	.L14
.L23:
	nop
.L14:
	addl	$1, -4000036(%rbp)
.L11:
	cmpl	$3, -4000036(%rbp)
	jle	.L17
	movl	-4000060(%rbp), %eax
	movl	-4000064(%rbp), %edx
	movslq	%edx, %rdx
	cltq
	imulq	$1000, %rax, %rax
	addq	%rdx, %rax
	movl	-4000016(%rbp,%rax,4), %eax
	cmpl	$-1, %eax
	je	.L10
	movl	-4000060(%rbp), %eax
	movl	-4000064(%rbp), %edx
	movslq	%edx, %rdx
	cltq
	imulq	$1000, %rax, %rax
	addq	%rdx, %rax
	movl	-4000016(%rbp,%rax,4), %eax
	jmp	.L20
.L10:
	movl	queue(%rip), %edx
	movl	4+queue(%rip), %eax
	cmpl	%eax, %edx
	jne	.L19
	movl	$-1, %eax
.L20:
	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
.LFE3:
	.size	bfs, .-bfs
	.section	.rodata
.LC0:
	.string	"%d %d"
.LC1:
	.string	"%s"
.LC2:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB4:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$48, %rsp
	leaq	w(%rip), %rax
	movq	%rax, %rdx
	leaq	h(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -40(%rbp)
	jmp	.L25
.L26:
	movl	-40(%rbp), %eax
	cltq
	imulq	$1000, %rax, %rax
	leaq	map(%rip), %rdx
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -40(%rbp)
.L25:
	movl	h(%rip), %eax
	cmpl	%eax, -40(%rbp)
	jl	.L26
	movl	$-1, -36(%rbp)
	movl	$0, -32(%rbp)
	jmp	.L27
.L41:
	movl	$0, -28(%rbp)
	jmp	.L28
.L40:
	movl	-28(%rbp), %eax
	movslq	%eax, %rdx
	movl	-32(%rbp), %eax
	cltq
	imulq	$1000, %rax, %rax
	addq	%rax, %rdx
	leaq	map(%rip), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	$35, %al
	je	.L43
	movl	$0, -24(%rbp)
	jmp	.L31
.L39:
	movl	$0, -20(%rbp)
	jmp	.L32
.L38:
	movl	-20(%rbp), %eax
	movslq	%eax, %rdx
	movl	-24(%rbp), %eax
	cltq
	imulq	$1000, %rax, %rax
	addq	%rax, %rdx
	leaq	map(%rip), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	$35, %al
	je	.L44
	movl	-32(%rbp), %eax
	cmpl	-24(%rbp), %eax
	jne	.L35
	movl	-28(%rbp), %eax
	cmpl	-20(%rbp), %eax
	je	.L45
.L35:
	movl	-28(%rbp), %eax
	movl	%eax, -16(%rbp)
	movl	-32(%rbp), %eax
	movl	%eax, -12(%rbp)
	movl	-20(%rbp), %eax
	movl	%eax, -8(%rbp)
	movl	-24(%rbp), %eax
	movl	%eax, -4(%rbp)
	movq	-8(%rbp), %rdx
	movq	-16(%rbp), %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	bfs
	cmpl	%eax, -36(%rbp)
	jg	.L36
	movq	-8(%rbp), %rdx
	movq	-16(%rbp), %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	bfs
	jmp	.L37
.L36:
	movl	-36(%rbp), %eax
.L37:
	movl	%eax, -36(%rbp)
	jmp	.L34
.L44:
	nop
	jmp	.L34
.L45:
	nop
.L34:
	addl	$1, -20(%rbp)
.L32:
	movl	w(%rip), %eax
	cmpl	%eax, -20(%rbp)
	jl	.L38
	addl	$1, -24(%rbp)
.L31:
	movl	h(%rip), %eax
	cmpl	%eax, -24(%rbp)
	jl	.L39
	jmp	.L30
.L43:
	nop
.L30:
	addl	$1, -28(%rbp)
.L28:
	movl	w(%rip), %eax
	cmpl	%eax, -28(%rbp)
	jl	.L40
	addl	$1, -32(%rbp)
.L27:
	movl	h(%rip), %eax
	cmpl	%eax, -32(%rbp)
	jl	.L41
	movl	-36(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE4:
	.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	dx
	.data
	.align 16
	.type	dx, @object
	.size	dx, 16
dx:
	.long	1
	.long	0
	.long	-1
	.long	0
	.globl	dy
	.align 16
	.type	dy, @object
	.size	dy, 16
dy:
	.long	0
	.long	-1
	.long	0
	.long	1
	.globl	queue
	.bss
	.align 32
	.type	queue, @object
	.size	queue, 1600008
queue:
	.zero	1600008
	.text
	.globl	initqueue
	.type	initqueue, @function
initqueue:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	$0, 4+queue(%rip)
	movl	4+queue(%rip), %eax
	movl	%eax, queue(%rip)
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	initqueue, .-initqueue
	.globl	enqueue
	.type	enqueue, @function
enqueue:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -8(%rbp)
	movl	4+queue(%rip), %eax
	leal	1(%rax), %edx
	movl	%edx, 4+queue(%rip)
	cltq
	leaq	0(,%rax,8), %rcx
	leaq	8+queue(%rip), %rdx
	movq	-8(%rbp), %rax
	movq	%rax, (%rcx,%rdx)
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	enqueue, .-enqueue
	.globl	dequeue
	.type	dequeue, @function
dequeue:
.LFB2:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	queue(%rip), %eax
	leal	1(%rax), %edx
	movl	%edx, queue(%rip)
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	8+queue(%rip), %rax
	movq	(%rdx,%rax), %rax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2:
	.size	dequeue, .-dequeue
	.globl	h
	.bss
	.align 4
	.type	h, @object
	.size	h, 4
h:
	.zero	4
	.globl	w
	.align 4
	.type	w, @object
	.size	w, 4
w:
	.zero	4
	.globl	map
	.align 32
	.type	map, @object
	.size	map, 1000000
map:
	.zero	1000000
	.text
	.globl	bfs
	.type	bfs, @function
bfs:
.LFB3:
	.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	$2368, %rsp
	movq	%rdi, -4000056(%rbp)
	movq	%rsi, -4000064(%rbp)
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, %eax
	call	initqueue
	movq	-4000056(%rbp), %rax
	movq	%rax, %rdi
	call	enqueue
	movl	$0, -4000044(%rbp)
	jmp	.L6
.L9:
	movl	$0, -4000040(%rbp)
	jmp	.L7
.L8:
	movl	-4000040(%rbp), %eax
	movslq	%eax, %rdx
	movl	-4000044(%rbp), %eax
	cltq
	imulq	$1000, %rax, %rax
	addq	%rdx, %rax
	movl	$-1, -4000016(%rbp,%rax,4)
	addl	$1, -4000040(%rbp)
.L7:
	movl	w(%rip), %eax
	cmpl	%eax, -4000040(%rbp)
	jl	.L8
	addl	$1, -4000044(%rbp)
.L6:
	movl	h(%rip), %eax
	cmpl	%eax, -4000044(%rbp)
	jl	.L9
	movl	-4000052(%rbp), %eax
	movl	-4000056(%rbp), %edx
	movslq	%edx, %rdx
	cltq
	imulq	$1000, %rax, %rax
	addq	%rdx, %rax
	movl	$0, -4000016(%rbp,%rax,4)
	jmp	.L10
.L19:
	movl	$0, %eax
	call	dequeue
	movq	%rax, -4000032(%rbp)
	movl	$0, -4000036(%rbp)
	jmp	.L11
.L17:
	movl	-4000032(%rbp), %ecx
	movl	-4000036(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	dx(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%ecx, %eax
	movl	%eax, -4000024(%rbp)
	movl	-4000028(%rbp), %ecx
	movl	-4000036(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	dy(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%ecx, %eax
	movl	%eax, -4000020(%rbp)
	movl	-4000024(%rbp), %eax
	testl	%eax, %eax
	js	.L22
	movl	-4000024(%rbp), %edx
	movl	w(%rip), %eax
	cmpl	%eax, %edx
	jge	.L22
	movl	-4000020(%rbp), %eax
	testl	%eax, %eax
	js	.L22
	movl	-4000020(%rbp), %edx
	movl	h(%rip), %eax
	cmpl	%eax, %edx
	jge	.L22
	movl	-4000020(%rbp), %eax
	movl	-4000024(%rbp), %edx
	movslq	%edx, %rdx
	cltq
	imulq	$1000, %rax, %rax
	addq	%rdx, %rax
	movl	-4000016(%rbp,%rax,4), %eax
	cmpl	$-1, %eax
	jne	.L23
	movl	-4000020(%rbp), %eax
	movl	-4000024(%rbp), %edx
	movslq	%edx, %rdx
	cltq
	imulq	$1000, %rax, %rax
	addq	%rax, %rdx
	leaq	map(%rip), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	$35, %al
	je	.L23
	movq	-4000024(%rbp), %rax
	movq	%rax, %rdi
	call	enqueue
	movl	-4000028(%rbp), %eax
	movl	-4000032(%rbp), %edx
	movslq	%edx, %rdx
	cltq
	imulq	$1000, %rax, %rax
	addq	%rdx, %rax
	movl	-4000016(%rbp,%rax,4), %edx
	movl	-4000020(%rbp), %eax
	movl	-4000024(%rbp), %ecx
	addl	$1, %edx
	movslq	%ecx, %rcx
	cltq
	imulq	$1000, %rax, %rax
	addq	%rcx, %rax
	movl	%edx, -4000016(%rbp,%rax,4)
	jmp	.L14
.L22:
	nop
	jmp	.L14
.L23:
	nop
.L14:
	addl	$1, -4000036(%rbp)
.L11:
	cmpl	$3, -4000036(%rbp)
	jle	.L17
	movl	-4000060(%rbp), %eax
	movl	-4000064(%rbp), %edx
	movslq	%edx, %rdx
	cltq
	imulq	$1000, %rax, %rax
	addq	%rdx, %rax
	movl	-4000016(%rbp,%rax,4), %eax
	cmpl	$-1, %eax
	je	.L10
	movl	-4000060(%rbp), %eax
	movl	-4000064(%rbp), %edx
	movslq	%edx, %rdx
	cltq
	imulq	$1000, %rax, %rax
	addq	%rdx, %rax
	movl	-4000016(%rbp,%rax,4), %eax
	jmp	.L20
.L10:
	movl	queue(%rip), %edx
	movl	4+queue(%rip), %eax
	cmpl	%eax, %edx
	jne	.L19
	movl	$-1, %eax
.L20:
	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
.LFE3:
	.size	bfs, .-bfs
	.section	.rodata
.LC0:
	.string	"%d %d"
.LC1:
	.string	"%s"
.LC2:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB4:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$48, %rsp
	leaq	w(%rip), %rax
	movq	%rax, %rdx
	leaq	h(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -40(%rbp)
	jmp	.L25
.L26:
	movl	-40(%rbp), %eax
	cltq
	imulq	$1000, %rax, %rax
	leaq	map(%rip), %rdx
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -40(%rbp)
.L25:
	movl	h(%rip), %eax
	cmpl	%eax, -40(%rbp)
	jl	.L26
	movl	$-1, -36(%rbp)
	movl	$0, -32(%rbp)
	jmp	.L27
.L41:
	movl	$0, -28(%rbp)
	jmp	.L28
.L40:
	movl	-28(%rbp), %eax
	movslq	%eax, %rdx
	movl	-32(%rbp), %eax
	cltq
	imulq	$1000, %rax, %rax
	addq	%rax, %rdx
	leaq	map(%rip), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	$35, %al
	je	.L43
	movl	$0, -24(%rbp)
	jmp	.L31
.L39:
	movl	$0, -20(%rbp)
	jmp	.L32
.L38:
	movl	-20(%rbp), %eax
	movslq	%eax, %rdx
	movl	-24(%rbp), %eax
	cltq
	imulq	$1000, %rax, %rax
	addq	%rax, %rdx
	leaq	map(%rip), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	$35, %al
	je	.L44
	movl	-32(%rbp), %eax
	cmpl	-24(%rbp), %eax
	jne	.L35
	movl	-28(%rbp), %eax
	cmpl	-20(%rbp), %eax
	je	.L45
.L35:
	movl	-28(%rbp), %eax
	movl	%eax, -16(%rbp)
	movl	-32(%rbp), %eax
	movl	%eax, -12(%rbp)
	movl	-20(%rbp), %eax
	movl	%eax, -8(%rbp)
	movl	-24(%rbp), %eax
	movl	%eax, -4(%rbp)
	movq	-8(%rbp), %rdx
	movq	-16(%rbp), %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	bfs
	cmpl	%eax, -36(%rbp)
	jg	.L36
	movq	-8(%rbp), %rdx
	movq	-16(%rbp), %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	bfs
	jmp	.L37
.L36:
	movl	-36(%rbp), %eax
.L37:
	movl	%eax, -36(%rbp)
	jmp	.L34
.L44:
	nop
	jmp	.L34
.L45:
	nop
.L34:
	addl	$1, -20(%rbp)
.L32:
	movl	w(%rip), %eax
	cmpl	%eax, -20(%rbp)
	jl	.L38
	addl	$1, -24(%rbp)
.L31:
	movl	h(%rip), %eax
	cmpl	%eax, -24(%rbp)
	jl	.L39
	jmp	.L30
.L43:
	nop
.L30:
	addl	$1, -28(%rbp)
.L28:
	movl	w(%rip), %eax
	cmpl	%eax, -28(%rbp)
	jl	.L40
	addl	$1, -32(%rbp)
.L27:
	movl	h(%rip), %eax
	cmpl	%eax, -32(%rbp)
	jl	.L41
	movl	-36(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE4:
	.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:
