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>
#include<string.h>
char M[105][105],c,D[5]="NESW";
int H,W,sh,sw,i,j,t[105][105][4],mv[4]={-1,0,1,0},d,nh,nw;
long long int L;
int out(int a,int b){return 0>a||a>=b;}

int f(int b)
{
	for(i=0;i<L;)
	{
		nh=sh+mv[d];nw=sw+mv[(d+1)%4];
		if(out(nh,H)||out(nw,W)||M[nh][nw]=='#')
		{
			d=(d+1)%4;
			continue;
		}
		if(b&&t[sh][sw][d]!=-1)
		{
			L=(L-i)%(i-t[sh][sw][d])+(i-t[sh][sw][d]);
			return 1;
		}
		t[sh][sw][d]=i++;
		sh=nh;sw=nw;
	}
	return 0;
}

int main()
{
	for(;scanf("%d%d%lld\n",&H,&W,&L),H;)
	{
		memset(t,-1,sizeof(t));
		memset(M,0,sizeof(M));
		for(i=0;i<H;i++)
			for(j=0;j<=W;j++)
			{
				c=getchar();
				if('A'<c&&c<'Z')
				{
					d=c=='N'?0:c=='E'?1:c=='S'?2:3;
					sh=i;sw=j;M[i][j]='.';
				}
				else M[i][j]=c;
			}
		if(f(1))f(0);
		printf("%d %d %c\n",sh+1,sw+1,D[d]);
	}
	return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	M
	.bss
	.align 32
	.type	M, @object
	.size	M, 11025
M:
	.zero	11025
	.globl	c
	.type	c, @object
	.size	c, 1
c:
	.zero	1
	.globl	D
	.data
	.type	D, @object
	.size	D, 5
D:
	.string	"NESW"
	.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	sh
	.align 4
	.type	sh, @object
	.size	sh, 4
sh:
	.zero	4
	.globl	sw
	.align 4
	.type	sw, @object
	.size	sw, 4
sw:
	.zero	4
	.globl	i
	.align 4
	.type	i, @object
	.size	i, 4
i:
	.zero	4
	.globl	j
	.align 4
	.type	j, @object
	.size	j, 4
j:
	.zero	4
	.globl	t
	.align 32
	.type	t, @object
	.size	t, 176400
t:
	.zero	176400
	.globl	mv
	.data
	.align 16
	.type	mv, @object
	.size	mv, 16
mv:
	.long	-1
	.long	0
	.long	1
	.long	0
	.globl	d
	.bss
	.align 4
	.type	d, @object
	.size	d, 4
d:
	.zero	4
	.globl	nh
	.align 4
	.type	nh, @object
	.size	nh, 4
nh:
	.zero	4
	.globl	nw
	.align 4
	.type	nw, @object
	.size	nw, 4
nw:
	.zero	4
	.globl	L
	.align 8
	.type	L, @object
	.size	L, 8
L:
	.zero	8
	.text
	.globl	out
	.type	out, @function
out:
.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)
	cmpl	$0, -4(%rbp)
	js	.L2
	movl	-4(%rbp), %eax
	cmpl	-8(%rbp), %eax
	jl	.L3
.L2:
	movl	$1, %eax
	jmp	.L5
.L3:
	movl	$0, %eax
.L5:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	out, .-out
	.globl	f
	.type	f, @function
f:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$8, %rsp
	movl	%edi, -4(%rbp)
	movl	$0, i(%rip)
	jmp	.L7
.L12:
	movl	d(%rip), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	mv(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	sh(%rip), %eax
	addl	%edx, %eax
	movl	%eax, nh(%rip)
	movl	d(%rip), %eax
	addl	$1, %eax
	cltd
	shrl	$30, %edx
	addl	%edx, %eax
	andl	$3, %eax
	subl	%edx, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	mv(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	sw(%rip), %eax
	addl	%edx, %eax
	movl	%eax, nw(%rip)
	movl	H(%rip), %edx
	movl	nh(%rip), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	out
	testl	%eax, %eax
	jne	.L8
	movl	W(%rip), %edx
	movl	nw(%rip), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	out
	testl	%eax, %eax
	jne	.L8
	movl	nh(%rip), %eax
	movl	nw(%rip), %edx
	movslq	%edx, %rcx
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$3, %rax
	addq	%rdx, %rax
	leaq	(%rax,%rcx), %rdx
	leaq	M(%rip), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	$35, %al
	jne	.L9
.L8:
	movl	d(%rip), %eax
	addl	$1, %eax
	cltd
	shrl	$30, %edx
	addl	%edx, %eax
	andl	$3, %eax
	subl	%edx, %eax
	movl	%eax, d(%rip)
	jmp	.L7
.L9:
	cmpl	$0, -4(%rbp)
	je	.L10
	movl	sh(%rip), %edx
	movl	sw(%rip), %eax
	movl	d(%rip), %ecx
	movslq	%ecx, %rcx
	movslq	%edx, %rdx
	movslq	%eax, %rsi
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$3, %rax
	addq	%rdx, %rax
	addq	%rsi, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	t(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	$-1, %eax
	je	.L10
	movq	L(%rip), %rax
	movl	i(%rip), %edx
	movslq	%edx, %rdx
	subq	%rdx, %rax
	movq	%rax, %rsi
	movl	i(%rip), %ecx
	movl	sh(%rip), %edx
	movl	sw(%rip), %eax
	movl	d(%rip), %edi
	movslq	%edi, %rdi
	movslq	%edx, %rdx
	movslq	%eax, %r8
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$3, %rax
	addq	%rdx, %rax
	addq	%r8, %rax
	salq	$2, %rax
	addq	%rdi, %rax
	leaq	0(,%rax,4), %rdx
	leaq	t(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	%ecx, %eax
	subl	%edx, %eax
	movslq	%eax, %rcx
	movq	%rsi, %rax
	cqto
	idivq	%rcx
	movq	%rdx, %r8
	movl	i(%rip), %ecx
	movl	sh(%rip), %edx
	movl	sw(%rip), %eax
	movl	d(%rip), %esi
	movslq	%esi, %rsi
	movslq	%edx, %rdx
	movslq	%eax, %rdi
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$3, %rax
	addq	%rdx, %rax
	addq	%rdi, %rax
	salq	$2, %rax
	addq	%rsi, %rax
	leaq	0(,%rax,4), %rdx
	leaq	t(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	%ecx, %eax
	subl	%edx, %eax
	cltq
	addq	%r8, %rax
	movq	%rax, L(%rip)
	movl	$1, %eax
	jmp	.L11
.L10:
	movl	i(%rip), %ecx
	leal	1(%rcx), %eax
	movl	%eax, i(%rip)
	movl	sh(%rip), %edx
	movl	sw(%rip), %eax
	movl	d(%rip), %esi
	movslq	%esi, %rsi
	movslq	%edx, %rdx
	movslq	%eax, %rdi
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$3, %rax
	addq	%rdx, %rax
	addq	%rdi, %rax
	salq	$2, %rax
	addq	%rsi, %rax
	leaq	0(,%rax,4), %rdx
	leaq	t(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	nh(%rip), %eax
	movl	%eax, sh(%rip)
	movl	nw(%rip), %eax
	movl	%eax, sw(%rip)
.L7:
	movl	i(%rip), %eax
	movslq	%eax, %rdx
	movq	L(%rip), %rax
	cmpq	%rax, %rdx
	jl	.L12
	movl	$0, %eax
.L11:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	f, .-f
	.section	.rodata
.LC0:
	.string	"%d %d %c\n"
.LC1:
	.string	"%d%d%lld\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB2:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	jmp	.L14
.L28:
	movl	$176400, %edx
	movl	$-1, %esi
	leaq	t(%rip), %rax
	movq	%rax, %rdi
	call	memset@PLT
	movl	$11025, %edx
	movl	$0, %esi
	leaq	M(%rip), %rax
	movq	%rax, %rdi
	call	memset@PLT
	movl	$0, i(%rip)
	jmp	.L15
.L26:
	movl	$0, j(%rip)
	jmp	.L16
.L25:
	call	getchar@PLT
	movb	%al, c(%rip)
	movzbl	c(%rip), %eax
	cmpb	$65, %al
	jle	.L17
	movzbl	c(%rip), %eax
	cmpb	$89, %al
	jg	.L17
	movzbl	c(%rip), %eax
	cmpb	$78, %al
	je	.L18
	movzbl	c(%rip), %eax
	cmpb	$69, %al
	je	.L19
	movzbl	c(%rip), %eax
	cmpb	$83, %al
	jne	.L20
	movl	$2, %eax
	jmp	.L23
.L20:
	movl	$3, %eax
	jmp	.L23
.L19:
	movl	$1, %eax
	jmp	.L23
.L18:
	movl	$0, %eax
.L23:
	movl	%eax, d(%rip)
	movl	i(%rip), %eax
	movl	%eax, sh(%rip)
	movl	j(%rip), %eax
	movl	%eax, sw(%rip)
	movl	i(%rip), %eax
	movl	j(%rip), %edx
	movslq	%edx, %rcx
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$3, %rax
	addq	%rdx, %rax
	leaq	(%rax,%rcx), %rdx
	leaq	M(%rip), %rax
	addq	%rdx, %rax
	movb	$46, (%rax)
	jmp	.L24
.L17:
	movl	i(%rip), %eax
	movl	j(%rip), %edx
	movzbl	c(%rip), %ecx
	movslq	%edx, %rsi
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$3, %rax
	addq	%rdx, %rax
	leaq	(%rax,%rsi), %rdx
	leaq	M(%rip), %rax
	addq	%rdx, %rax
	movb	%cl, (%rax)
.L24:
	movl	j(%rip), %eax
	addl	$1, %eax
	movl	%eax, j(%rip)
.L16:
	movl	j(%rip), %edx
	movl	W(%rip), %eax
	cmpl	%eax, %edx
	jle	.L25
	movl	i(%rip), %eax
	addl	$1, %eax
	movl	%eax, i(%rip)
.L15:
	movl	i(%rip), %edx
	movl	H(%rip), %eax
	cmpl	%eax, %edx
	jl	.L26
	movl	$1, %edi
	call	f
	testl	%eax, %eax
	je	.L27
	movl	$0, %edi
	call	f
.L27:
	movl	d(%rip), %eax
	cltq
	leaq	D(%rip), %rdx
	movzbl	(%rax,%rdx), %eax
	movsbl	%al, %eax
	movl	sw(%rip), %edx
	addl	$1, %edx
	movl	sh(%rip), %ecx
	leal	1(%rcx), %esi
	movl	%eax, %ecx
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L14:
	leaq	L(%rip), %rax
	movq	%rax, %rcx
	leaq	W(%rip), %rax
	movq	%rax, %rdx
	leaq	H(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	H(%rip), %eax
	testl	%eax, %eax
	jne	.L28
	movl	$0, %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2:
	.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	out
	.type	out, @function
out:
.LFB35:
	.cfi_startproc
	endbr64
	movl	%edi, %edx
	xorl	%eax, %eax
	shrl	$31, %edx
	cmpl	%esi, %edi
	setge	%al
	orl	%edx, %eax
	ret
	.cfi_endproc
.LFE35:
	.size	out, .-out
	.p2align 4
	.globl	f
	.type	f, @function
f:
.LFB36:
	.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
	movq	L(%rip), %rbx
	movl	$0, i(%rip)
	testq	%rbx, %rbx
	jle	.L4
	movl	H(%rip), %eax
	movl	%edi, %r8d
	movl	d(%rip), %r10d
	leaq	mv(%rip), %rbp
	movb	$0, -1(%rsp)
	movslq	sh(%rip), %rdi
	movl	%eax, -12(%rsp)
	movl	W(%rip), %eax
	movb	$0, -2(%rsp)
	movslq	sw(%rip), %r9
	movl	%eax, -8(%rsp)
	movslq	%r10d, %rax
	movl	0(%rbp,%rax,4), %r11d
	testl	%r8d, %r8d
	je	.L37
	xorl	%r13d, %r13d
	xorl	%r8d, %r8d
	jmp	.L5
	.p2align 4,,10
	.p2align 3
.L39:
	movl	%ecx, %r12d
	orl	%esi, %r12d
	shrl	$31, %r12d
	cmpl	-8(%rsp), %esi
	setge	%r14b
	orb	%r12b, %r14b
	jne	.L20
	movslq	%ecx, %r12
	movslq	%esi, %r14
	leaq	(%r12,%r12,2), %r15
	leaq	(%r12,%r15,4), %r15
	leaq	(%r12,%r15,8), %r12
	leaq	M(%rip), %r15
	addq	%r15, %r12
	cmpb	$35, (%r12,%r14)
	je	.L21
	movslq	%edi, %rax
	movslq	%r9d, %rdx
	movslq	%r10d, %r12
	leaq	(%rax,%rax,2), %r14
	leaq	(%rax,%r14,4), %r14
	leaq	(%rax,%r14,8), %rax
	addq	%rax, %rdx
	leaq	(%r12,%rdx,4), %rax
	leaq	t(%rip), %rdx
	movl	(%rdx,%rax,4), %edx
	cmpl	$-1, %edx
	jne	.L38
	movb	$1, -1(%rsp)
	leaq	t(%rip), %rdi
	movl	%esi, %r9d
	movl	%r8d, (%rdi,%rax,4)
	addl	$1, %r8d
	movl	%ecx, %edi
.L9:
	movslq	%r8d, %r13
	cmpq	%r13, %rbx
	jle	.L8
.L5:
	leal	1(%r10), %eax
	leal	(%rdi,%r11), %ecx
	cltd
	shrl	$30, %edx
	addl	%edx, %eax
	andl	$3, %eax
	subl	%edx, %eax
	movslq	%eax, %rdx
	movl	0(%rbp,%rdx,4), %edx
	leal	(%rdx,%r9), %esi
	cmpl	-12(%rsp), %ecx
	jl	.L39
.L21:
	movslq	%r8d, %r13
	movb	$1, -2(%rsp)
	movl	%edx, %r11d
	movl	%eax, %r10d
	cmpq	%r13, %rbx
	jg	.L5
.L8:
	cmpb	$0, -1(%rsp)
	movl	%esi, nw(%rip)
	movl	%ecx, nh(%rip)
	je	.L14
	movl	%r8d, i(%rip)
	movl	%r9d, sw(%rip)
	movl	%edi, sh(%rip)
.L14:
	cmpb	$0, -2(%rsp)
	je	.L4
	movl	%r10d, d(%rip)
.L4:
	popq	%rbx
	.cfi_remember_state
	.cfi_def_cfa_offset 48
	xorl	%eax, %eax
	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
.L37:
	.cfi_restore_state
	leaq	M(%rip), %r15
	jmp	.L7
	.p2align 4,,10
	.p2align 3
.L40:
	movl	%esi, %r12d
	orl	%ecx, %r12d
	shrl	$31, %r12d
	cmpl	%esi, -8(%rsp)
	setle	%r13b
	orb	%r12b, %r13b
	jne	.L17
	movslq	%ecx, %r12
	movslq	%esi, %r13
	leaq	(%r12,%r12,2), %r14
	leaq	(%r12,%r14,4), %r14
	leaq	(%r12,%r14,8), %r12
	addq	%r15, %r12
	cmpb	$35, (%r12,%r13)
	je	.L18
	leaq	(%rdi,%rdi,2), %rdx
	movslq	%r10d, %rax
	movb	$1, -1(%rsp)
	leaq	(%rdi,%rdx,4), %rdx
	leaq	(%rdi,%rdx,8), %rdx
	leaq	t(%rip), %rdi
	addq	%r9, %rdx
	movslq	%esi, %r9
	leaq	(%rax,%rdx,4), %rax
	movl	%r8d, (%rdi,%rax,4)
	addl	$1, %r8d
	movslq	%ecx, %rdi
.L6:
	movslq	%r8d, %rax
	cmpq	%rbx, %rax
	jge	.L8
.L7:
	leal	1(%r10), %eax
	leal	(%r11,%rdi), %ecx
	cltd
	shrl	$30, %edx
	addl	%edx, %eax
	andl	$3, %eax
	subl	%edx, %eax
	movslq	%eax, %rdx
	movl	0(%rbp,%rdx,4), %edx
	leal	(%rdx,%r9), %esi
	cmpl	%ecx, -12(%rsp)
	jg	.L40
.L18:
	movb	$1, -2(%rsp)
	movl	%edx, %r11d
	movl	%eax, %r10d
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L17:
	movb	%r13b, -2(%rsp)
	movl	%edx, %r11d
	movl	%eax, %r10d
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L20:
	movb	%r14b, -2(%rsp)
	movl	%edx, %r11d
	movl	%eax, %r10d
	jmp	.L9
.L38:
	cmpb	$0, -1(%rsp)
	movl	%esi, nw(%rip)
	movl	%ecx, nh(%rip)
	je	.L11
	movl	%r8d, i(%rip)
	movl	%r9d, sw(%rip)
	movl	%edi, sh(%rip)
.L11:
	cmpb	$0, -2(%rsp)
	je	.L12
	movl	%r10d, d(%rip)
.L12:
	movq	%rbx, %rax
	subl	%edx, %r8d
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	subq	%r13, %rax
	movslq	%r8d, %rcx
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	cqto
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	idivq	%rcx
	movl	$1, %eax
	addq	%rcx, %rdx
	movq	%rdx, L(%rip)
	ret
	.cfi_endproc
.LFE36:
	.size	f, .-f
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d %d %c\n"
.LC1:
	.string	"%d%d%lld\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB37:
	.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
	leaq	M(%rip), %r13
	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	$56, %rsp
	.cfi_def_cfa_offset 112
	.p2align 4,,10
	.p2align 3
.L42:
	leaq	L(%rip), %rcx
	leaq	W(%rip), %rdx
	xorl	%eax, %eax
	leaq	H(%rip), %rsi
	leaq	.LC1(%rip), %rdi
	call	__isoc99_scanf@PLT
	movl	H(%rip), %ebx
	testl	%ebx, %ebx
	je	.L88
	movl	$176400, %edx
	movl	$-1, %esi
	leaq	t(%rip), %rdi
	call	memset@PLT
	movl	$11025, %edx
	xorl	%esi, %esi
	movq	%r13, %rdi
	call	memset@PLT
	movl	$0, i(%rip)
	testl	%ebx, %ebx
	jle	.L43
	movl	W(%rip), %eax
	.p2align 4,,10
	.p2align 3
.L49:
	movl	$0, j(%rip)
	testl	%eax, %eax
	jns	.L48
	jmp	.L43
	.p2align 4,,10
	.p2align 3
.L90:
	subl	$69, %eax
	movl	$3, %edx
	cmpb	$14, %al
	ja	.L46
	movzbl	%al, %eax
	leaq	CSWTCH.65(%rip), %rbx
	movl	(%rbx,%rax,4), %edx
.L46:
	movslq	i(%rip), %rax
	movslq	j(%rip), %rsi
	movl	%edx, d(%rip)
	leaq	(%rax,%rax,2), %rdi
	movl	%eax, sh(%rip)
	movq	%rax, %rcx
	movq	%rsi, %rdx
	leaq	(%rax,%rdi,4), %rdi
	movl	%esi, sw(%rip)
	leaq	(%rax,%rdi,8), %rax
	addq	%r13, %rax
	movb	$46, (%rax,%rsi)
.L47:
	movl	W(%rip), %eax
	addl	$1, %edx
	movl	%edx, j(%rip)
	cmpl	%eax, %edx
	jg	.L89
.L48:
	movq	stdin(%rip), %rdi
	call	getc@PLT
	leal	-66(%rax), %edx
	movb	%al, c(%rip)
	cmpb	$23, %dl
	jbe	.L90
	movslq	i(%rip), %rsi
	movslq	j(%rip), %rdi
	leaq	(%rsi,%rsi,2), %r8
	movq	%rsi, %rcx
	movq	%rdi, %rdx
	leaq	(%rsi,%r8,4), %r8
	leaq	(%rsi,%r8,8), %rsi
	addq	%r13, %rsi
	movb	%al, (%rsi,%rdi)
	jmp	.L47
	.p2align 4,,10
	.p2align 3
.L89:
	movl	H(%rip), %ebx
	addl	$1, %ecx
	movl	%ecx, i(%rip)
	cmpl	%ecx, %ebx
	jg	.L49
.L43:
	movq	L(%rip), %rdi
	movl	d(%rip), %r11d
	movl	$0, i(%rip)
	movl	sh(%rip), %ecx
	movl	sw(%rip), %esi
	movq	%rdi, 8(%rsp)
	movl	%r11d, 36(%rsp)
	movl	%ecx, 40(%rsp)
	movl	%esi, 44(%rsp)
	testq	%rdi, %rdi
	jle	.L65
	movl	W(%rip), %edi
	movslq	%r11d, %rax
	movb	$0, 28(%rsp)
	xorl	%ebp, %ebp
	movb	$0, 24(%rsp)
	xorl	%r9d, %r9d
	movl	%edi, 20(%rsp)
	leaq	mv(%rip), %rdi
	movl	%ebx, 16(%rsp)
	movl	(%rdi,%rax,4), %r14d
	jmp	.L58
	.p2align 4,,10
	.p2align 3
.L93:
	movl	%edx, %ebx
	orl	%edi, %ebx
	shrl	$31, %ebx
	cmpl	20(%rsp), %edi
	setge	%r10b
	orb	%bl, %r10b
	jne	.L67
	movslq	%edx, %rbx
	movslq	%edi, %r12
	leaq	(%rbx,%rbx,2), %r15
	leaq	(%rbx,%r15,4), %r15
	leaq	(%rbx,%r15,8), %rbx
	addq	%r13, %rbx
	cmpb	$35, (%rbx,%r12)
	je	.L68
	movslq	%ecx, %rax
	movslq	%esi, %r8
	movslq	%r11d, %rbx
	leaq	(%rax,%rax,2), %r12
	leaq	(%rax,%r12,4), %r12
	leaq	(%rax,%r12,8), %rax
	addq	%r8, %rax
	leaq	(%rbx,%rax,4), %rax
	leaq	t(%rip), %rbx
	movl	(%rbx,%rax,4), %r8d
	cmpl	$-1, %r8d
	jne	.L91
	movb	$1, 28(%rsp)
	leaq	t(%rip), %rbx
	movl	%edi, %esi
	movl	%edx, %ecx
	movl	%r9d, (%rbx,%rax,4)
	addl	$1, %r9d
.L53:
	movslq	%r9d, %rbp
	cmpq	8(%rsp), %rbp
	jge	.L92
.L58:
	leal	1(%r11), %eax
	leaq	mv(%rip), %rbx
	movl	%eax, %edi
	leal	(%rcx,%r14), %edx
	sarl	$31, %edi
	shrl	$30, %edi
	addl	%edi, %eax
	andl	$3, %eax
	subl	%edi, %eax
	movslq	%eax, %rdi
	movl	(%rbx,%rdi,4), %r8d
	leal	(%r8,%rsi), %edi
	cmpl	16(%rsp), %edx
	jl	.L93
.L68:
	movb	$1, 24(%rsp)
	movl	%r8d, %r14d
	movl	%eax, %r11d
	movslq	%r9d, %rbp
	cmpq	8(%rsp), %rbp
	jl	.L58
.L92:
	cmpb	$0, 28(%rsp)
	movl	%edi, nw(%rip)
	movl	%edx, nh(%rip)
	je	.L70
	cmpb	$0, 24(%rsp)
	movl	%r9d, i(%rip)
	movl	%esi, sw(%rip)
	movl	%ecx, sh(%rip)
	je	.L87
.L96:
	movslq	%r11d, %rax
	movl	%r11d, d(%rip)
	movq	%rax, 8(%rsp)
	movq	%rax, %rbx
.L52:
	leaq	D(%rip), %rax
	leal	1(%rsi), %r9d
	movl	$1, %edi
	movsbl	(%rax,%rbx), %r8d
	leal	1(%rcx), %edx
	leaq	.LC0(%rip), %rsi
	xorl	%eax, %eax
	movl	%r9d, %ecx
	call	__printf_chk@PLT
	jmp	.L42
	.p2align 4,,10
	.p2align 3
.L67:
	movb	%r10b, 24(%rsp)
	movl	%r8d, %r14d
	movl	%eax, %r11d
	jmp	.L53
.L91:
	cmpb	$0, 28(%rsp)
	movl	16(%rsp), %ebx
	movb	%r10b, 35(%rsp)
	movl	%edi, nw(%rip)
	movl	%edx, nh(%rip)
	je	.L69
	movl	%esi, sw(%rip)
	movl	%ecx, sh(%rip)
.L55:
	cmpb	$0, 24(%rsp)
	je	.L56
	movl	%r11d, d(%rip)
	movl	%r11d, 36(%rsp)
.L56:
	movq	8(%rsp), %rax
	subl	%r8d, %r9d
	movl	$0, i(%rip)
	movslq	%r9d, %rdi
	subq	%rbp, %rax
	cqto
	idivq	%rdi
	leaq	(%rdx,%rdi), %rax
	testq	%rax, %rax
	movq	%rax, L(%rip)
	movq	%rax, %r14
	movslq	36(%rsp), %rax
	jle	.L86
	leaq	mv(%rip), %rdi
	movl	%ecx, 24(%rsp)
	movq	%rax, %r12
	xorl	%ebp, %ebp
	movq	%rax, 8(%rsp)
	movl	(%rdi,%rax,4), %r11d
	movslq	%esi, %r10
	movslq	%ecx, %rdx
	movb	$0, 16(%rsp)
	movl	%esi, 28(%rsp)
	jmp	.L61
	.p2align 4,,10
	.p2align 3
.L95:
	movl	%edi, %esi
	orl	%r8d, %esi
	shrl	$31, %esi
	cmpl	%r8d, 20(%rsp)
	setle	%r9b
	orb	%sil, %r9b
	jne	.L73
	movslq	%edi, %rsi
	movslq	%r8d, %r9
	leaq	(%rsi,%rsi,2), %r15
	leaq	(%rsi,%r15,4), %r15
	leaq	(%rsi,%r15,8), %rsi
	addq	%r13, %rsi
	cmpb	$35, (%rsi,%r9)
	je	.L74
	leaq	(%rdx,%rdx,2), %rcx
	movslq	%r12d, %rax
	movb	$1, 16(%rsp)
	leaq	(%rdx,%rcx,4), %rcx
	leaq	(%rdx,%rcx,8), %rdx
	leaq	t(%rip), %rcx
	addq	%r10, %rdx
	movslq	%r8d, %r10
	leaq	(%rax,%rdx,4), %rax
	movslq	%edi, %rdx
	movl	%ebp, (%rcx,%rax,4)
	addl	$1, %ebp
.L60:
	movslq	%ebp, %rax
	cmpq	%rax, %r14
	jle	.L94
.L61:
	leal	1(%r12), %eax
	leaq	mv(%rip), %rsi
	movl	%eax, %ecx
	leal	(%rdx,%r11), %edi
	sarl	$31, %ecx
	shrl	$30, %ecx
	addl	%ecx, %eax
	andl	$3, %eax
	subl	%ecx, %eax
	movslq	%eax, %rcx
	movl	(%rsi,%rcx,4), %ecx
	leal	(%r10,%rcx), %r8d
	cmpl	%ebx, %edi
	jl	.L95
.L74:
	movl	%eax, %r12d
	movslq	%ebp, %rax
	movb	$1, 35(%rsp)
	movl	%ecx, %r11d
	cmpq	%rax, %r14
	jg	.L61
.L94:
	cmpb	$0, 16(%rsp)
	movl	24(%rsp), %ecx
	movl	%r8d, nw(%rip)
	movl	%edi, nh(%rip)
	movl	28(%rsp), %esi
	je	.L75
	cmpb	$0, 35(%rsp)
	movl	%ebp, i(%rip)
	movl	%r10d, sw(%rip)
	movl	%edx, sh(%rip)
	je	.L76
.L97:
	movslq	%r12d, %rax
	movl	%r12d, d(%rip)
	movl	%edx, %ecx
	movl	%r10d, %esi
	movq	%rax, 8(%rsp)
	movq	%rax, %rbx
	jmp	.L52
	.p2align 4,,10
	.p2align 3
.L73:
	movb	%r9b, 35(%rsp)
	movl	%ecx, %r11d
	movl	%eax, %r12d
	jmp	.L60
.L70:
	cmpb	$0, 24(%rsp)
	movl	44(%rsp), %esi
	movl	40(%rsp), %ecx
	jne	.L96
.L87:
	movslq	36(%rsp), %rax
.L86:
	movq	%rax, 8(%rsp)
	movq	%rax, %rbx
	jmp	.L52
.L88:
	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
.L69:
	.cfi_restore_state
	movl	44(%rsp), %esi
	movl	40(%rsp), %ecx
	jmp	.L55
.L75:
	cmpb	$0, 35(%rsp)
	movl	%esi, %r10d
	movl	%ecx, %edx
	jne	.L97
.L76:
	movq	8(%rsp), %rbx
	movl	%edx, %ecx
	movl	%r10d, %esi
	jmp	.L52
.L65:
	movl	40(%rsp), %ecx
	movl	44(%rsp), %esi
	jmp	.L87
	.cfi_endproc
.LFE37:
	.size	main, .-main
	.section	.rodata
	.align 32
	.type	CSWTCH.65, @object
	.size	CSWTCH.65, 60
CSWTCH.65:
	.long	1
	.long	3
	.long	3
	.long	3
	.long	3
	.long	3
	.long	3
	.long	3
	.long	3
	.long	0
	.long	3
	.long	3
	.long	3
	.long	3
	.long	2
	.globl	L
	.bss
	.align 8
	.type	L, @object
	.size	L, 8
L:
	.zero	8
	.globl	nw
	.align 4
	.type	nw, @object
	.size	nw, 4
nw:
	.zero	4
	.globl	nh
	.align 4
	.type	nh, @object
	.size	nh, 4
nh:
	.zero	4
	.globl	d
	.align 4
	.type	d, @object
	.size	d, 4
d:
	.zero	4
	.globl	mv
	.data
	.align 16
	.type	mv, @object
	.size	mv, 16
mv:
	.long	-1
	.long	0
	.long	1
	.long	0
	.globl	t
	.bss
	.align 32
	.type	t, @object
	.size	t, 176400
t:
	.zero	176400
	.globl	j
	.align 4
	.type	j, @object
	.size	j, 4
j:
	.zero	4
	.globl	i
	.align 4
	.type	i, @object
	.size	i, 4
i:
	.zero	4
	.globl	sw
	.align 4
	.type	sw, @object
	.size	sw, 4
sw:
	.zero	4
	.globl	sh
	.align 4
	.type	sh, @object
	.size	sh, 4
sh:
	.zero	4
	.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	D
	.data
	.type	D, @object
	.size	D, 5
D:
	.string	"NESW"
	.globl	c
	.bss
	.type	c, @object
	.size	c, 1
c:
	.zero	1
	.globl	M
	.align 32
	.type	M, @object
	.size	M, 11025
M:
	.zero	11025
	.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	out
	.type	out, @function
out:
.LFB35:
	.cfi_startproc
	endbr64
	movl	%edi, %edx
	xorl	%eax, %eax
	shrl	$31, %edx
	cmpl	%esi, %edi
	setge	%al
	orl	%edx, %eax
	ret
	.cfi_endproc
.LFE35:
	.size	out, .-out
	.p2align 4
	.globl	f
	.type	f, @function
f:
.LFB36:
	.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
	movq	L(%rip), %rbx
	movl	$0, i(%rip)
	testq	%rbx, %rbx
	jle	.L4
	movl	H(%rip), %eax
	movl	%edi, %r8d
	movl	d(%rip), %r10d
	leaq	mv(%rip), %rbp
	movb	$0, -1(%rsp)
	movslq	sh(%rip), %rdi
	movl	%eax, -12(%rsp)
	movl	W(%rip), %eax
	movb	$0, -2(%rsp)
	movslq	sw(%rip), %r9
	movl	%eax, -8(%rsp)
	movslq	%r10d, %rax
	movl	0(%rbp,%rax,4), %r11d
	testl	%r8d, %r8d
	je	.L37
	xorl	%r13d, %r13d
	xorl	%r8d, %r8d
	jmp	.L5
	.p2align 4,,10
	.p2align 3
.L39:
	movl	%ecx, %r12d
	orl	%esi, %r12d
	shrl	$31, %r12d
	cmpl	-8(%rsp), %esi
	setge	%r14b
	orb	%r12b, %r14b
	jne	.L20
	movslq	%ecx, %r12
	movslq	%esi, %r14
	leaq	(%r12,%r12,2), %r15
	leaq	(%r12,%r15,4), %r15
	leaq	(%r12,%r15,8), %r12
	leaq	M(%rip), %r15
	addq	%r15, %r12
	cmpb	$35, (%r12,%r14)
	je	.L21
	movslq	%edi, %rax
	movslq	%r9d, %rdx
	movslq	%r10d, %r12
	leaq	(%rax,%rax,2), %r14
	leaq	(%rax,%r14,4), %r14
	leaq	(%rax,%r14,8), %rax
	addq	%rax, %rdx
	leaq	(%r12,%rdx,4), %rax
	leaq	t(%rip), %rdx
	movl	(%rdx,%rax,4), %edx
	cmpl	$-1, %edx
	jne	.L38
	movb	$1, -1(%rsp)
	leaq	t(%rip), %rdi
	movl	%esi, %r9d
	movl	%r8d, (%rdi,%rax,4)
	addl	$1, %r8d
	movl	%ecx, %edi
.L9:
	movslq	%r8d, %r13
	cmpq	%r13, %rbx
	jle	.L8
.L5:
	leal	1(%r10), %eax
	leal	(%rdi,%r11), %ecx
	cltd
	shrl	$30, %edx
	addl	%edx, %eax
	andl	$3, %eax
	subl	%edx, %eax
	movslq	%eax, %rdx
	movl	0(%rbp,%rdx,4), %edx
	leal	(%rdx,%r9), %esi
	cmpl	-12(%rsp), %ecx
	jl	.L39
.L21:
	movslq	%r8d, %r13
	movb	$1, -2(%rsp)
	movl	%edx, %r11d
	movl	%eax, %r10d
	cmpq	%r13, %rbx
	jg	.L5
.L8:
	cmpb	$0, -1(%rsp)
	movl	%esi, nw(%rip)
	movl	%ecx, nh(%rip)
	je	.L14
	movl	%r8d, i(%rip)
	movl	%r9d, sw(%rip)
	movl	%edi, sh(%rip)
.L14:
	cmpb	$0, -2(%rsp)
	je	.L4
	movl	%r10d, d(%rip)
.L4:
	popq	%rbx
	.cfi_remember_state
	.cfi_def_cfa_offset 48
	xorl	%eax, %eax
	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
.L37:
	.cfi_restore_state
	leaq	M(%rip), %r15
	jmp	.L7
	.p2align 4,,10
	.p2align 3
.L40:
	movl	%esi, %r12d
	orl	%ecx, %r12d
	shrl	$31, %r12d
	cmpl	%esi, -8(%rsp)
	setle	%r13b
	orb	%r12b, %r13b
	jne	.L17
	movslq	%ecx, %r12
	movslq	%esi, %r13
	leaq	(%r12,%r12,2), %r14
	leaq	(%r12,%r14,4), %r14
	leaq	(%r12,%r14,8), %r12
	addq	%r15, %r12
	cmpb	$35, (%r12,%r13)
	je	.L18
	leaq	(%rdi,%rdi,2), %rdx
	movslq	%r10d, %rax
	movb	$1, -1(%rsp)
	leaq	(%rdi,%rdx,4), %rdx
	leaq	(%rdi,%rdx,8), %rdx
	leaq	t(%rip), %rdi
	addq	%r9, %rdx
	movslq	%esi, %r9
	leaq	(%rax,%rdx,4), %rax
	movl	%r8d, (%rdi,%rax,4)
	addl	$1, %r8d
	movslq	%ecx, %rdi
.L6:
	movslq	%r8d, %rax
	cmpq	%rbx, %rax
	jge	.L8
.L7:
	leal	1(%r10), %eax
	leal	(%r11,%rdi), %ecx
	cltd
	shrl	$30, %edx
	addl	%edx, %eax
	andl	$3, %eax
	subl	%edx, %eax
	movslq	%eax, %rdx
	movl	0(%rbp,%rdx,4), %edx
	leal	(%rdx,%r9), %esi
	cmpl	%ecx, -12(%rsp)
	jg	.L40
.L18:
	movb	$1, -2(%rsp)
	movl	%edx, %r11d
	movl	%eax, %r10d
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L17:
	movb	%r13b, -2(%rsp)
	movl	%edx, %r11d
	movl	%eax, %r10d
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L20:
	movb	%r14b, -2(%rsp)
	movl	%edx, %r11d
	movl	%eax, %r10d
	jmp	.L9
.L38:
	cmpb	$0, -1(%rsp)
	movl	%esi, nw(%rip)
	movl	%ecx, nh(%rip)
	je	.L11
	movl	%r8d, i(%rip)
	movl	%r9d, sw(%rip)
	movl	%edi, sh(%rip)
.L11:
	cmpb	$0, -2(%rsp)
	je	.L12
	movl	%r10d, d(%rip)
.L12:
	movq	%rbx, %rax
	subl	%edx, %r8d
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	subq	%r13, %rax
	movslq	%r8d, %rcx
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	cqto
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	idivq	%rcx
	movl	$1, %eax
	addq	%rcx, %rdx
	movq	%rdx, L(%rip)
	ret
	.cfi_endproc
.LFE36:
	.size	f, .-f
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d %d %c\n"
.LC1:
	.string	"%d%d%lld\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB37:
	.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
	leaq	M(%rip), %r13
	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	$56, %rsp
	.cfi_def_cfa_offset 112
	.p2align 4,,10
	.p2align 3
.L42:
	leaq	L(%rip), %rcx
	leaq	W(%rip), %rdx
	xorl	%eax, %eax
	leaq	H(%rip), %rsi
	leaq	.LC1(%rip), %rdi
	call	__isoc99_scanf@PLT
	movl	H(%rip), %ebx
	testl	%ebx, %ebx
	je	.L88
	movl	$176400, %edx
	movl	$-1, %esi
	leaq	t(%rip), %rdi
	call	memset@PLT
	movl	$11025, %edx
	xorl	%esi, %esi
	movq	%r13, %rdi
	call	memset@PLT
	movl	$0, i(%rip)
	testl	%ebx, %ebx
	jle	.L43
	movl	W(%rip), %eax
	.p2align 4,,10
	.p2align 3
.L49:
	movl	$0, j(%rip)
	testl	%eax, %eax
	jns	.L48
	jmp	.L43
	.p2align 4,,10
	.p2align 3
.L90:
	subl	$69, %eax
	movl	$3, %edx
	cmpb	$14, %al
	ja	.L46
	movzbl	%al, %eax
	leaq	CSWTCH.65(%rip), %rbx
	movl	(%rbx,%rax,4), %edx
.L46:
	movslq	i(%rip), %rax
	movslq	j(%rip), %rsi
	movl	%edx, d(%rip)
	leaq	(%rax,%rax,2), %rdi
	movl	%eax, sh(%rip)
	movq	%rax, %rcx
	movq	%rsi, %rdx
	leaq	(%rax,%rdi,4), %rdi
	movl	%esi, sw(%rip)
	leaq	(%rax,%rdi,8), %rax
	addq	%r13, %rax
	movb	$46, (%rax,%rsi)
.L47:
	movl	W(%rip), %eax
	addl	$1, %edx
	movl	%edx, j(%rip)
	cmpl	%eax, %edx
	jg	.L89
.L48:
	movq	stdin(%rip), %rdi
	call	getc@PLT
	leal	-66(%rax), %edx
	movb	%al, c(%rip)
	cmpb	$23, %dl
	jbe	.L90
	movslq	i(%rip), %rsi
	movslq	j(%rip), %rdi
	leaq	(%rsi,%rsi,2), %r8
	movq	%rsi, %rcx
	movq	%rdi, %rdx
	leaq	(%rsi,%r8,4), %r8
	leaq	(%rsi,%r8,8), %rsi
	addq	%r13, %rsi
	movb	%al, (%rsi,%rdi)
	jmp	.L47
	.p2align 4,,10
	.p2align 3
.L89:
	movl	H(%rip), %ebx
	addl	$1, %ecx
	movl	%ecx, i(%rip)
	cmpl	%ecx, %ebx
	jg	.L49
.L43:
	movq	L(%rip), %rdi
	movl	d(%rip), %r11d
	movl	$0, i(%rip)
	movl	sh(%rip), %ecx
	movl	sw(%rip), %esi
	movq	%rdi, 8(%rsp)
	movl	%r11d, 36(%rsp)
	movl	%ecx, 40(%rsp)
	movl	%esi, 44(%rsp)
	testq	%rdi, %rdi
	jle	.L65
	movl	W(%rip), %edi
	movslq	%r11d, %rax
	movb	$0, 28(%rsp)
	xorl	%ebp, %ebp
	movb	$0, 24(%rsp)
	xorl	%r9d, %r9d
	movl	%edi, 20(%rsp)
	leaq	mv(%rip), %rdi
	movl	%ebx, 16(%rsp)
	movl	(%rdi,%rax,4), %r14d
	jmp	.L58
	.p2align 4,,10
	.p2align 3
.L93:
	movl	%edx, %ebx
	orl	%edi, %ebx
	shrl	$31, %ebx
	cmpl	20(%rsp), %edi
	setge	%r10b
	orb	%bl, %r10b
	jne	.L67
	movslq	%edx, %rbx
	movslq	%edi, %r12
	leaq	(%rbx,%rbx,2), %r15
	leaq	(%rbx,%r15,4), %r15
	leaq	(%rbx,%r15,8), %rbx
	addq	%r13, %rbx
	cmpb	$35, (%rbx,%r12)
	je	.L68
	movslq	%ecx, %rax
	movslq	%esi, %r8
	movslq	%r11d, %rbx
	leaq	(%rax,%rax,2), %r12
	leaq	(%rax,%r12,4), %r12
	leaq	(%rax,%r12,8), %rax
	addq	%r8, %rax
	leaq	(%rbx,%rax,4), %rax
	leaq	t(%rip), %rbx
	movl	(%rbx,%rax,4), %r8d
	cmpl	$-1, %r8d
	jne	.L91
	movb	$1, 28(%rsp)
	leaq	t(%rip), %rbx
	movl	%edi, %esi
	movl	%edx, %ecx
	movl	%r9d, (%rbx,%rax,4)
	addl	$1, %r9d
.L53:
	movslq	%r9d, %rbp
	cmpq	8(%rsp), %rbp
	jge	.L92
.L58:
	leal	1(%r11), %eax
	leaq	mv(%rip), %rbx
	movl	%eax, %edi
	leal	(%rcx,%r14), %edx
	sarl	$31, %edi
	shrl	$30, %edi
	addl	%edi, %eax
	andl	$3, %eax
	subl	%edi, %eax
	movslq	%eax, %rdi
	movl	(%rbx,%rdi,4), %r8d
	leal	(%r8,%rsi), %edi
	cmpl	16(%rsp), %edx
	jl	.L93
.L68:
	movb	$1, 24(%rsp)
	movl	%r8d, %r14d
	movl	%eax, %r11d
	movslq	%r9d, %rbp
	cmpq	8(%rsp), %rbp
	jl	.L58
.L92:
	cmpb	$0, 28(%rsp)
	movl	%edi, nw(%rip)
	movl	%edx, nh(%rip)
	je	.L70
	cmpb	$0, 24(%rsp)
	movl	%r9d, i(%rip)
	movl	%esi, sw(%rip)
	movl	%ecx, sh(%rip)
	je	.L87
.L96:
	movslq	%r11d, %rax
	movl	%r11d, d(%rip)
	movq	%rax, 8(%rsp)
	movq	%rax, %rbx
.L52:
	leaq	D(%rip), %rax
	leal	1(%rsi), %r9d
	movl	$1, %edi
	movsbl	(%rax,%rbx), %r8d
	leal	1(%rcx), %edx
	leaq	.LC0(%rip), %rsi
	xorl	%eax, %eax
	movl	%r9d, %ecx
	call	__printf_chk@PLT
	jmp	.L42
	.p2align 4,,10
	.p2align 3
.L67:
	movb	%r10b, 24(%rsp)
	movl	%r8d, %r14d
	movl	%eax, %r11d
	jmp	.L53
.L91:
	cmpb	$0, 28(%rsp)
	movl	16(%rsp), %ebx
	movb	%r10b, 35(%rsp)
	movl	%edi, nw(%rip)
	movl	%edx, nh(%rip)
	je	.L69
	movl	%esi, sw(%rip)
	movl	%ecx, sh(%rip)
.L55:
	cmpb	$0, 24(%rsp)
	je	.L56
	movl	%r11d, d(%rip)
	movl	%r11d, 36(%rsp)
.L56:
	movq	8(%rsp), %rax
	subl	%r8d, %r9d
	movl	$0, i(%rip)
	movslq	%r9d, %rdi
	subq	%rbp, %rax
	cqto
	idivq	%rdi
	leaq	(%rdx,%rdi), %rax
	testq	%rax, %rax
	movq	%rax, L(%rip)
	movq	%rax, %r14
	movslq	36(%rsp), %rax
	jle	.L86
	leaq	mv(%rip), %rdi
	movl	%ecx, 24(%rsp)
	movq	%rax, %r12
	xorl	%ebp, %ebp
	movq	%rax, 8(%rsp)
	movl	(%rdi,%rax,4), %r11d
	movslq	%esi, %r10
	movslq	%ecx, %rdx
	movb	$0, 16(%rsp)
	movl	%esi, 28(%rsp)
	jmp	.L61
	.p2align 4,,10
	.p2align 3
.L95:
	movl	%edi, %esi
	orl	%r8d, %esi
	shrl	$31, %esi
	cmpl	%r8d, 20(%rsp)
	setle	%r9b
	orb	%sil, %r9b
	jne	.L73
	movslq	%edi, %rsi
	movslq	%r8d, %r9
	leaq	(%rsi,%rsi,2), %r15
	leaq	(%rsi,%r15,4), %r15
	leaq	(%rsi,%r15,8), %rsi
	addq	%r13, %rsi
	cmpb	$35, (%rsi,%r9)
	je	.L74
	leaq	(%rdx,%rdx,2), %rcx
	movslq	%r12d, %rax
	movb	$1, 16(%rsp)
	leaq	(%rdx,%rcx,4), %rcx
	leaq	(%rdx,%rcx,8), %rdx
	leaq	t(%rip), %rcx
	addq	%r10, %rdx
	movslq	%r8d, %r10
	leaq	(%rax,%rdx,4), %rax
	movslq	%edi, %rdx
	movl	%ebp, (%rcx,%rax,4)
	addl	$1, %ebp
.L60:
	movslq	%ebp, %rax
	cmpq	%rax, %r14
	jle	.L94
.L61:
	leal	1(%r12), %eax
	leaq	mv(%rip), %rsi
	movl	%eax, %ecx
	leal	(%rdx,%r11), %edi
	sarl	$31, %ecx
	shrl	$30, %ecx
	addl	%ecx, %eax
	andl	$3, %eax
	subl	%ecx, %eax
	movslq	%eax, %rcx
	movl	(%rsi,%rcx,4), %ecx
	leal	(%r10,%rcx), %r8d
	cmpl	%ebx, %edi
	jl	.L95
.L74:
	movl	%eax, %r12d
	movslq	%ebp, %rax
	movb	$1, 35(%rsp)
	movl	%ecx, %r11d
	cmpq	%rax, %r14
	jg	.L61
.L94:
	cmpb	$0, 16(%rsp)
	movl	24(%rsp), %ecx
	movl	%r8d, nw(%rip)
	movl	%edi, nh(%rip)
	movl	28(%rsp), %esi
	je	.L75
	cmpb	$0, 35(%rsp)
	movl	%ebp, i(%rip)
	movl	%r10d, sw(%rip)
	movl	%edx, sh(%rip)
	je	.L76
.L97:
	movslq	%r12d, %rax
	movl	%r12d, d(%rip)
	movl	%edx, %ecx
	movl	%r10d, %esi
	movq	%rax, 8(%rsp)
	movq	%rax, %rbx
	jmp	.L52
	.p2align 4,,10
	.p2align 3
.L73:
	movb	%r9b, 35(%rsp)
	movl	%ecx, %r11d
	movl	%eax, %r12d
	jmp	.L60
.L70:
	cmpb	$0, 24(%rsp)
	movl	44(%rsp), %esi
	movl	40(%rsp), %ecx
	jne	.L96
.L87:
	movslq	36(%rsp), %rax
.L86:
	movq	%rax, 8(%rsp)
	movq	%rax, %rbx
	jmp	.L52
.L88:
	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
.L69:
	.cfi_restore_state
	movl	44(%rsp), %esi
	movl	40(%rsp), %ecx
	jmp	.L55
.L75:
	cmpb	$0, 35(%rsp)
	movl	%esi, %r10d
	movl	%ecx, %edx
	jne	.L97
.L76:
	movq	8(%rsp), %rbx
	movl	%edx, %ecx
	movl	%r10d, %esi
	jmp	.L52
.L65:
	movl	40(%rsp), %ecx
	movl	44(%rsp), %esi
	jmp	.L87
	.cfi_endproc
.LFE37:
	.size	main, .-main
	.section	.rodata
	.align 32
	.type	CSWTCH.65, @object
	.size	CSWTCH.65, 60
CSWTCH.65:
	.long	1
	.long	3
	.long	3
	.long	3
	.long	3
	.long	3
	.long	3
	.long	3
	.long	3
	.long	0
	.long	3
	.long	3
	.long	3
	.long	3
	.long	2
	.globl	L
	.bss
	.align 8
	.type	L, @object
	.size	L, 8
L:
	.zero	8
	.globl	nw
	.align 4
	.type	nw, @object
	.size	nw, 4
nw:
	.zero	4
	.globl	nh
	.align 4
	.type	nh, @object
	.size	nh, 4
nh:
	.zero	4
	.globl	d
	.align 4
	.type	d, @object
	.size	d, 4
d:
	.zero	4
	.globl	mv
	.data
	.align 16
	.type	mv, @object
	.size	mv, 16
mv:
	.long	-1
	.long	0
	.long	1
	.long	0
	.globl	t
	.bss
	.align 32
	.type	t, @object
	.size	t, 176400
t:
	.zero	176400
	.globl	j
	.align 4
	.type	j, @object
	.size	j, 4
j:
	.zero	4
	.globl	i
	.align 4
	.type	i, @object
	.size	i, 4
i:
	.zero	4
	.globl	sw
	.align 4
	.type	sw, @object
	.size	sw, 4
sw:
	.zero	4
	.globl	sh
	.align 4
	.type	sh, @object
	.size	sh, 4
sh:
	.zero	4
	.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	D
	.data
	.type	D, @object
	.size	D, 5
D:
	.string	"NESW"
	.globl	c
	.bss
	.type	c, @object
	.size	c, 1
c:
	.zero	1
	.globl	M
	.align 32
	.type	M, @object
	.size	M, 11025
M:
	.zero	11025
	.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>
#include<string.h>
char M[105][105],c,D[5]="NESW";
int H,W,sh,sw,i,j,t[105][105][4],mv[4]={-1,0,1,0},d,nh,nw;
long long int L;
int out(int a,int b){return 0>a||a>=b;}

int f(int b)
{
	for(i=0;i<L;)
	{
		nh=sh+mv[d];nw=sw+mv[(d+1)%4];
		if(out(nh,H)||out(nw,W)||M[nh][nw]=='#')
		{
			d=(d+1)%4;
			continue;
		}
		if(b&&t[sh][sw][d]!=-1)
		{
			L=(L-i)%(i-t[sh][sw][d])+(i-t[sh][sw][d]);
			return 1;
		}
		t[sh][sw][d]=i++;
		sh=nh;sw=nw;
	}
	return 0;
}

int main()
{
	for(;scanf("%d%d%lld\n",&H,&W,&L),H;)
	{
		memset(t,-1,sizeof(t));
		memset(M,0,sizeof(M));
		for(i=0;i<H;i++)
			for(j=0;j<=W;j++)
			{
				c=getchar();
				if('A'<c&&c<'Z')
				{
					d=c=='N'?0:c=='E'?1:c=='S'?2:3;
					sh=i;sw=j;M[i][j]='.';
				}
				else M[i][j]=c;
			}
		if(f(1))f(0);
		printf("%d %d %c\n",sh+1,sw+1,D[d]);
	}
	return 0;
}
3 3 10
E..
.#.
...
5 5 19
####.
.....
.#S#.
...#.
#.##.
5 5 6
#.#..
#....
##.#.
#..S.
#....
5 4 35
.#.#
....
.##.
.#S.
...#
0 0 0

1 3 E
4 5 S
4 4 E
5 1 S

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>
#include<string.h>
char M[105][105],c,D[5]="NESW";
int H,W,sh,sw,i,j,t[105][105][4],mv[4]={-1,0,1,0},d,nh,nw;
long long int L;
int out(int a,int b){return 0>a||a>=b;}

int f(int b)
{
	for(i=0;i<L;)
	{
		nh=sh+mv[d];nw=sw+mv[(d+1)%4];
		if(out(nh,H)||out(nw,W)||M[nh][nw]=='#')
		{
			d=(d+1)%4;
			continue;
		}
		if(b&&t[sh][sw][d]!=-1)
		{
			L=(L-i)%(i-t[sh][sw][d])+(i-t[sh][sw][d]);
			return 1;
		}
		t[sh][sw][d]=i++;
		sh=nh;sw=nw;
	}
	return 0;
}

int main()
{
	for(;scanf("%d%d%lld\n",&H,&W,&L),H;)
	{
		memset(t,-1,sizeof(t));
		memset(M,0,sizeof(M));
		for(i=0;i<H;i++)
			for(j=0;j<=W;j++)
			{
				c=getchar();
				if('A'<c&&c<'Z')
				{
					d=c=='N'?0:c=='E'?1:c=='S'?2:3;
					sh=i;sw=j;M[i][j]='.';
				}
				else M[i][j]=c;
			}
		if(f(1))f(0);
		printf("%d %d %c\n",sh+1,sw+1,D[d]);
	}
	return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	M
	.bss
	.align 32
	.type	M, @object
	.size	M, 11025
M:
	.zero	11025
	.globl	c
	.type	c, @object
	.size	c, 1
c:
	.zero	1
	.globl	D
	.data
	.type	D, @object
	.size	D, 5
D:
	.string	"NESW"
	.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	sh
	.align 4
	.type	sh, @object
	.size	sh, 4
sh:
	.zero	4
	.globl	sw
	.align 4
	.type	sw, @object
	.size	sw, 4
sw:
	.zero	4
	.globl	i
	.align 4
	.type	i, @object
	.size	i, 4
i:
	.zero	4
	.globl	j
	.align 4
	.type	j, @object
	.size	j, 4
j:
	.zero	4
	.globl	t
	.align 32
	.type	t, @object
	.size	t, 176400
t:
	.zero	176400
	.globl	mv
	.data
	.align 16
	.type	mv, @object
	.size	mv, 16
mv:
	.long	-1
	.long	0
	.long	1
	.long	0
	.globl	d
	.bss
	.align 4
	.type	d, @object
	.size	d, 4
d:
	.zero	4
	.globl	nh
	.align 4
	.type	nh, @object
	.size	nh, 4
nh:
	.zero	4
	.globl	nw
	.align 4
	.type	nw, @object
	.size	nw, 4
nw:
	.zero	4
	.globl	L
	.align 8
	.type	L, @object
	.size	L, 8
L:
	.zero	8
	.text
	.globl	out
	.type	out, @function
out:
.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)
	cmpl	$0, -4(%rbp)
	js	.L2
	movl	-4(%rbp), %eax
	cmpl	-8(%rbp), %eax
	jl	.L3
.L2:
	movl	$1, %eax
	jmp	.L5
.L3:
	movl	$0, %eax
.L5:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	out, .-out
	.globl	f
	.type	f, @function
f:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$8, %rsp
	movl	%edi, -4(%rbp)
	movl	$0, i(%rip)
	jmp	.L7
.L12:
	movl	d(%rip), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	mv(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	sh(%rip), %eax
	addl	%edx, %eax
	movl	%eax, nh(%rip)
	movl	d(%rip), %eax
	addl	$1, %eax
	cltd
	shrl	$30, %edx
	addl	%edx, %eax
	andl	$3, %eax
	subl	%edx, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	mv(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	sw(%rip), %eax
	addl	%edx, %eax
	movl	%eax, nw(%rip)
	movl	H(%rip), %edx
	movl	nh(%rip), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	out
	testl	%eax, %eax
	jne	.L8
	movl	W(%rip), %edx
	movl	nw(%rip), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	out
	testl	%eax, %eax
	jne	.L8
	movl	nh(%rip), %eax
	movl	nw(%rip), %edx
	movslq	%edx, %rcx
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$3, %rax
	addq	%rdx, %rax
	leaq	(%rax,%rcx), %rdx
	leaq	M(%rip), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	$35, %al
	jne	.L9
.L8:
	movl	d(%rip), %eax
	addl	$1, %eax
	cltd
	shrl	$30, %edx
	addl	%edx, %eax
	andl	$3, %eax
	subl	%edx, %eax
	movl	%eax, d(%rip)
	jmp	.L7
.L9:
	cmpl	$0, -4(%rbp)
	je	.L10
	movl	sh(%rip), %edx
	movl	sw(%rip), %eax
	movl	d(%rip), %ecx
	movslq	%ecx, %rcx
	movslq	%edx, %rdx
	movslq	%eax, %rsi
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$3, %rax
	addq	%rdx, %rax
	addq	%rsi, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	t(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	$-1, %eax
	je	.L10
	movq	L(%rip), %rax
	movl	i(%rip), %edx
	movslq	%edx, %rdx
	subq	%rdx, %rax
	movq	%rax, %rsi
	movl	i(%rip), %ecx
	movl	sh(%rip), %edx
	movl	sw(%rip), %eax
	movl	d(%rip), %edi
	movslq	%edi, %rdi
	movslq	%edx, %rdx
	movslq	%eax, %r8
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$3, %rax
	addq	%rdx, %rax
	addq	%r8, %rax
	salq	$2, %rax
	addq	%rdi, %rax
	leaq	0(,%rax,4), %rdx
	leaq	t(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	%ecx, %eax
	subl	%edx, %eax
	movslq	%eax, %rcx
	movq	%rsi, %rax
	cqto
	idivq	%rcx
	movq	%rdx, %r8
	movl	i(%rip), %ecx
	movl	sh(%rip), %edx
	movl	sw(%rip), %eax
	movl	d(%rip), %esi
	movslq	%esi, %rsi
	movslq	%edx, %rdx
	movslq	%eax, %rdi
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$3, %rax
	addq	%rdx, %rax
	addq	%rdi, %rax
	salq	$2, %rax
	addq	%rsi, %rax
	leaq	0(,%rax,4), %rdx
	leaq	t(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	%ecx, %eax
	subl	%edx, %eax
	cltq
	addq	%r8, %rax
	movq	%rax, L(%rip)
	movl	$1, %eax
	jmp	.L11
.L10:
	movl	i(%rip), %ecx
	leal	1(%rcx), %eax
	movl	%eax, i(%rip)
	movl	sh(%rip), %edx
	movl	sw(%rip), %eax
	movl	d(%rip), %esi
	movslq	%esi, %rsi
	movslq	%edx, %rdx
	movslq	%eax, %rdi
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$3, %rax
	addq	%rdx, %rax
	addq	%rdi, %rax
	salq	$2, %rax
	addq	%rsi, %rax
	leaq	0(,%rax,4), %rdx
	leaq	t(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	nh(%rip), %eax
	movl	%eax, sh(%rip)
	movl	nw(%rip), %eax
	movl	%eax, sw(%rip)
.L7:
	movl	i(%rip), %eax
	movslq	%eax, %rdx
	movq	L(%rip), %rax
	cmpq	%rax, %rdx
	jl	.L12
	movl	$0, %eax
.L11:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	f, .-f
	.section	.rodata
.LC0:
	.string	"%d %d %c\n"
.LC1:
	.string	"%d%d%lld\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB2:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	jmp	.L14
.L28:
	movl	$176400, %edx
	movl	$-1, %esi
	leaq	t(%rip), %rax
	movq	%rax, %rdi
	call	memset@PLT
	movl	$11025, %edx
	movl	$0, %esi
	leaq	M(%rip), %rax
	movq	%rax, %rdi
	call	memset@PLT
	movl	$0, i(%rip)
	jmp	.L15
.L26:
	movl	$0, j(%rip)
	jmp	.L16
.L25:
	call	getchar@PLT
	movb	%al, c(%rip)
	movzbl	c(%rip), %eax
	cmpb	$65, %al
	jle	.L17
	movzbl	c(%rip), %eax
	cmpb	$89, %al
	jg	.L17
	movzbl	c(%rip), %eax
	cmpb	$78, %al
	je	.L18
	movzbl	c(%rip), %eax
	cmpb	$69, %al
	je	.L19
	movzbl	c(%rip), %eax
	cmpb	$83, %al
	jne	.L20
	movl	$2, %eax
	jmp	.L23
.L20:
	movl	$3, %eax
	jmp	.L23
.L19:
	movl	$1, %eax
	jmp	.L23
.L18:
	movl	$0, %eax
.L23:
	movl	%eax, d(%rip)
	movl	i(%rip), %eax
	movl	%eax, sh(%rip)
	movl	j(%rip), %eax
	movl	%eax, sw(%rip)
	movl	i(%rip), %eax
	movl	j(%rip), %edx
	movslq	%edx, %rcx
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$3, %rax
	addq	%rdx, %rax
	leaq	(%rax,%rcx), %rdx
	leaq	M(%rip), %rax
	addq	%rdx, %rax
	movb	$46, (%rax)
	jmp	.L24
.L17:
	movl	i(%rip), %eax
	movl	j(%rip), %edx
	movzbl	c(%rip), %ecx
	movslq	%edx, %rsi
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$3, %rax
	addq	%rdx, %rax
	leaq	(%rax,%rsi), %rdx
	leaq	M(%rip), %rax
	addq	%rdx, %rax
	movb	%cl, (%rax)
.L24:
	movl	j(%rip), %eax
	addl	$1, %eax
	movl	%eax, j(%rip)
.L16:
	movl	j(%rip), %edx
	movl	W(%rip), %eax
	cmpl	%eax, %edx
	jle	.L25
	movl	i(%rip), %eax
	addl	$1, %eax
	movl	%eax, i(%rip)
.L15:
	movl	i(%rip), %edx
	movl	H(%rip), %eax
	cmpl	%eax, %edx
	jl	.L26
	movl	$1, %edi
	call	f
	testl	%eax, %eax
	je	.L27
	movl	$0, %edi
	call	f
.L27:
	movl	d(%rip), %eax
	cltq
	leaq	D(%rip), %rdx
	movzbl	(%rax,%rdx), %eax
	movsbl	%al, %eax
	movl	sw(%rip), %edx
	addl	$1, %edx
	movl	sh(%rip), %ecx
	leal	1(%rcx), %esi
	movl	%eax, %ecx
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L14:
	leaq	L(%rip), %rax
	movq	%rax, %rcx
	leaq	W(%rip), %rax
	movq	%rax, %rdx
	leaq	H(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	H(%rip), %eax
	testl	%eax, %eax
	jne	.L28
	movl	$0, %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2:
	.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	M
	.bss
	.align 32
	.type	M, @object
	.size	M, 11025
M:
	.zero	11025
	.globl	c
	.type	c, @object
	.size	c, 1
c:
	.zero	1
	.globl	D
	.data
	.type	D, @object
	.size	D, 5
D:
	.string	"NESW"
	.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	sh
	.align 4
	.type	sh, @object
	.size	sh, 4
sh:
	.zero	4
	.globl	sw
	.align 4
	.type	sw, @object
	.size	sw, 4
sw:
	.zero	4
	.globl	i
	.align 4
	.type	i, @object
	.size	i, 4
i:
	.zero	4
	.globl	j
	.align 4
	.type	j, @object
	.size	j, 4
j:
	.zero	4
	.globl	t
	.align 32
	.type	t, @object
	.size	t, 176400
t:
	.zero	176400
	.globl	mv
	.data
	.align 16
	.type	mv, @object
	.size	mv, 16
mv:
	.long	-1
	.long	0
	.long	1
	.long	0
	.globl	d
	.bss
	.align 4
	.type	d, @object
	.size	d, 4
d:
	.zero	4
	.globl	nh
	.align 4
	.type	nh, @object
	.size	nh, 4
nh:
	.zero	4
	.globl	nw
	.align 4
	.type	nw, @object
	.size	nw, 4
nw:
	.zero	4
	.globl	L
	.align 8
	.type	L, @object
	.size	L, 8
L:
	.zero	8
	.text
	.globl	out
	.type	out, @function
out:
.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)
	cmpl	$0, -4(%rbp)
	js	.L2
	movl	-4(%rbp), %eax
	cmpl	-8(%rbp), %eax
	jl	.L3
.L2:
	movl	$1, %eax
	jmp	.L5
.L3:
	movl	$0, %eax
.L5:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	out, .-out
	.globl	f
	.type	f, @function
f:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$8, %rsp
	movl	%edi, -4(%rbp)
	movl	$0, i(%rip)
	jmp	.L7
.L12:
	movl	d(%rip), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	mv(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	sh(%rip), %eax
	addl	%edx, %eax
	movl	%eax, nh(%rip)
	movl	d(%rip), %eax
	addl	$1, %eax
	cltd
	shrl	$30, %edx
	addl	%edx, %eax
	andl	$3, %eax
	subl	%edx, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	mv(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	sw(%rip), %eax
	addl	%edx, %eax
	movl	%eax, nw(%rip)
	movl	H(%rip), %edx
	movl	nh(%rip), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	out
	testl	%eax, %eax
	jne	.L8
	movl	W(%rip), %edx
	movl	nw(%rip), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	out
	testl	%eax, %eax
	jne	.L8
	movl	nh(%rip), %eax
	movl	nw(%rip), %edx
	movslq	%edx, %rcx
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$3, %rax
	addq	%rdx, %rax
	leaq	(%rax,%rcx), %rdx
	leaq	M(%rip), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	$35, %al
	jne	.L9
.L8:
	movl	d(%rip), %eax
	addl	$1, %eax
	cltd
	shrl	$30, %edx
	addl	%edx, %eax
	andl	$3, %eax
	subl	%edx, %eax
	movl	%eax, d(%rip)
	jmp	.L7
.L9:
	cmpl	$0, -4(%rbp)
	je	.L10
	movl	sh(%rip), %edx
	movl	sw(%rip), %eax
	movl	d(%rip), %ecx
	movslq	%ecx, %rcx
	movslq	%edx, %rdx
	movslq	%eax, %rsi
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$3, %rax
	addq	%rdx, %rax
	addq	%rsi, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	t(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	$-1, %eax
	je	.L10
	movq	L(%rip), %rax
	movl	i(%rip), %edx
	movslq	%edx, %rdx
	subq	%rdx, %rax
	movq	%rax, %rsi
	movl	i(%rip), %ecx
	movl	sh(%rip), %edx
	movl	sw(%rip), %eax
	movl	d(%rip), %edi
	movslq	%edi, %rdi
	movslq	%edx, %rdx
	movslq	%eax, %r8
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$3, %rax
	addq	%rdx, %rax
	addq	%r8, %rax
	salq	$2, %rax
	addq	%rdi, %rax
	leaq	0(,%rax,4), %rdx
	leaq	t(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	%ecx, %eax
	subl	%edx, %eax
	movslq	%eax, %rcx
	movq	%rsi, %rax
	cqto
	idivq	%rcx
	movq	%rdx, %r8
	movl	i(%rip), %ecx
	movl	sh(%rip), %edx
	movl	sw(%rip), %eax
	movl	d(%rip), %esi
	movslq	%esi, %rsi
	movslq	%edx, %rdx
	movslq	%eax, %rdi
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$3, %rax
	addq	%rdx, %rax
	addq	%rdi, %rax
	salq	$2, %rax
	addq	%rsi, %rax
	leaq	0(,%rax,4), %rdx
	leaq	t(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	%ecx, %eax
	subl	%edx, %eax
	cltq
	addq	%r8, %rax
	movq	%rax, L(%rip)
	movl	$1, %eax
	jmp	.L11
.L10:
	movl	i(%rip), %ecx
	leal	1(%rcx), %eax
	movl	%eax, i(%rip)
	movl	sh(%rip), %edx
	movl	sw(%rip), %eax
	movl	d(%rip), %esi
	movslq	%esi, %rsi
	movslq	%edx, %rdx
	movslq	%eax, %rdi
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$3, %rax
	addq	%rdx, %rax
	addq	%rdi, %rax
	salq	$2, %rax
	addq	%rsi, %rax
	leaq	0(,%rax,4), %rdx
	leaq	t(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	nh(%rip), %eax
	movl	%eax, sh(%rip)
	movl	nw(%rip), %eax
	movl	%eax, sw(%rip)
.L7:
	movl	i(%rip), %eax
	movslq	%eax, %rdx
	movq	L(%rip), %rax
	cmpq	%rax, %rdx
	jl	.L12
	movl	$0, %eax
.L11:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	f, .-f
	.section	.rodata
.LC0:
	.string	"%d %d %c\n"
.LC1:
	.string	"%d%d%lld\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB2:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	jmp	.L14
.L28:
	movl	$176400, %edx
	movl	$-1, %esi
	leaq	t(%rip), %rax
	movq	%rax, %rdi
	call	memset@PLT
	movl	$11025, %edx
	movl	$0, %esi
	leaq	M(%rip), %rax
	movq	%rax, %rdi
	call	memset@PLT
	movl	$0, i(%rip)
	jmp	.L15
.L26:
	movl	$0, j(%rip)
	jmp	.L16
.L25:
	call	getchar@PLT
	movb	%al, c(%rip)
	movzbl	c(%rip), %eax
	cmpb	$65, %al
	jle	.L17
	movzbl	c(%rip), %eax
	cmpb	$89, %al
	jg	.L17
	movzbl	c(%rip), %eax
	cmpb	$78, %al
	je	.L18
	movzbl	c(%rip), %eax
	cmpb	$69, %al
	je	.L19
	movzbl	c(%rip), %eax
	cmpb	$83, %al
	jne	.L20
	movl	$2, %eax
	jmp	.L23
.L20:
	movl	$3, %eax
	jmp	.L23
.L19:
	movl	$1, %eax
	jmp	.L23
.L18:
	movl	$0, %eax
.L23:
	movl	%eax, d(%rip)
	movl	i(%rip), %eax
	movl	%eax, sh(%rip)
	movl	j(%rip), %eax
	movl	%eax, sw(%rip)
	movl	i(%rip), %eax
	movl	j(%rip), %edx
	movslq	%edx, %rcx
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$3, %rax
	addq	%rdx, %rax
	leaq	(%rax,%rcx), %rdx
	leaq	M(%rip), %rax
	addq	%rdx, %rax
	movb	$46, (%rax)
	jmp	.L24
.L17:
	movl	i(%rip), %eax
	movl	j(%rip), %edx
	movzbl	c(%rip), %ecx
	movslq	%edx, %rsi
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$3, %rax
	addq	%rdx, %rax
	leaq	(%rax,%rsi), %rdx
	leaq	M(%rip), %rax
	addq	%rdx, %rax
	movb	%cl, (%rax)
.L24:
	movl	j(%rip), %eax
	addl	$1, %eax
	movl	%eax, j(%rip)
.L16:
	movl	j(%rip), %edx
	movl	W(%rip), %eax
	cmpl	%eax, %edx
	jle	.L25
	movl	i(%rip), %eax
	addl	$1, %eax
	movl	%eax, i(%rip)
.L15:
	movl	i(%rip), %edx
	movl	H(%rip), %eax
	cmpl	%eax, %edx
	jl	.L26
	movl	$1, %edi
	call	f
	testl	%eax, %eax
	je	.L27
	movl	$0, %edi
	call	f
.L27:
	movl	d(%rip), %eax
	cltq
	leaq	D(%rip), %rdx
	movzbl	(%rax,%rdx), %eax
	movsbl	%al, %eax
	movl	sw(%rip), %edx
	addl	$1, %edx
	movl	sh(%rip), %ecx
	leal	1(%rcx), %esi
	movl	%eax, %ecx
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L14:
	leaq	L(%rip), %rax
	movq	%rax, %rcx
	leaq	W(%rip), %rax
	movq	%rax, %rdx
	leaq	H(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	H(%rip), %eax
	testl	%eax, %eax
	jne	.L28
	movl	$0, %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2:
	.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:
