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

```c
#include<stdio.h>

int main(){
	char s[1001];scanf("%s",s);
	int nwes[4]={0},i=0;
	while(s[i]!=0){
		if(s[i]=='N')nwes[0]=1;
		if(s[i]=='W')nwes[1]=1;
		if(s[i]=='S')nwes[2]=1;
		if(s[i]=='E')nwes[3]=1;
		i++;
	}
	if(nwes[0]==1&&nwes[1]==1&&
	nwes[2]==1&&nwes[3]==1){
		puts("Yes");
		return 0;
	}else if(nwes[0]==1&&nwes[1]==0&&
	nwes[2]==1&&nwes[3]==0){
		puts("Yes");
		return 0;
	}else if(nwes[0]==0&&nwes[1]==1&&
	nwes[2]==0&&nwes[3]==1){
		puts("Yes");
		return 0;
	}else{
		puts("No");
		return 0;
	}
	return 0;
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%s"
.LC1:
	.string	"Yes"
.LC2:
	.string	"No"
	.text
	.globl	main
	.type	main, @function
main:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$1056, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-1024(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	$0, -1040(%rbp)
	movq	$0, -1032(%rbp)
	movl	$0, -1044(%rbp)
	jmp	.L2
.L7:
	movl	-1044(%rbp), %eax
	cltq
	movzbl	-1024(%rbp,%rax), %eax
	cmpb	$78, %al
	jne	.L3
	movl	$1, -1040(%rbp)
.L3:
	movl	-1044(%rbp), %eax
	cltq
	movzbl	-1024(%rbp,%rax), %eax
	cmpb	$87, %al
	jne	.L4
	movl	$1, -1036(%rbp)
.L4:
	movl	-1044(%rbp), %eax
	cltq
	movzbl	-1024(%rbp,%rax), %eax
	cmpb	$83, %al
	jne	.L5
	movl	$1, -1032(%rbp)
.L5:
	movl	-1044(%rbp), %eax
	cltq
	movzbl	-1024(%rbp,%rax), %eax
	cmpb	$69, %al
	jne	.L6
	movl	$1, -1028(%rbp)
.L6:
	addl	$1, -1044(%rbp)
.L2:
	movl	-1044(%rbp), %eax
	cltq
	movzbl	-1024(%rbp,%rax), %eax
	testb	%al, %al
	jne	.L7
	movl	-1040(%rbp), %eax
	cmpl	$1, %eax
	jne	.L8
	movl	-1036(%rbp), %eax
	cmpl	$1, %eax
	jne	.L8
	movl	-1032(%rbp), %eax
	cmpl	$1, %eax
	jne	.L8
	movl	-1028(%rbp), %eax
	cmpl	$1, %eax
	jne	.L8
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	movl	$0, %eax
	jmp	.L12
.L8:
	movl	-1040(%rbp), %eax
	cmpl	$1, %eax
	jne	.L10
	movl	-1036(%rbp), %eax
	testl	%eax, %eax
	jne	.L10
	movl	-1032(%rbp), %eax
	cmpl	$1, %eax
	jne	.L10
	movl	-1028(%rbp), %eax
	testl	%eax, %eax
	jne	.L10
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	movl	$0, %eax
	jmp	.L12
.L10:
	movl	-1040(%rbp), %eax
	testl	%eax, %eax
	jne	.L11
	movl	-1036(%rbp), %eax
	cmpl	$1, %eax
	jne	.L11
	movl	-1032(%rbp), %eax
	testl	%eax, %eax
	jne	.L11
	movl	-1028(%rbp), %eax
	cmpl	$1, %eax
	jne	.L11
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	movl	$0, %eax
	jmp	.L12
.L11:
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	movl	$0, %eax
.L12:
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L13
	call	__stack_chk_fail@PLT
.L13:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:
```

Only output the optimized assembly code. Do not include any other text. Do not write any comments in the assembly code. Wrap the assembly code in ```assembly``` tags.
user
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%s"
.LC1:
	.string	"Yes"
.LC2:
	.string	"No"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	subq	$1032, %rsp
	.cfi_def_cfa_offset 1040
	leaq	.LC0(%rip), %rdi
	movq	%fs:40, %rax
	movq	%rax, 1016(%rsp)
	xorl	%eax, %eax
	movq	%rsp, %rsi
	call	__isoc99_scanf@PLT
	movzbl	(%rsp), %eax
	testb	%al, %al
	je	.L2
	leaq	1(%rsp), %rdx
	xorl	%ecx, %ecx
	xorl	%edi, %edi
	xorl	%r8d, %r8d
	xorl	%esi, %esi
	movl	$1, %r9d
	jmp	.L4
	.p2align 4,,10
	.p2align 3
.L22:
	cmpb	$87, %al
	je	.L11
	cmpb	$83, %al
	jne	.L20
	movl	$1, %esi
.L3:
	movzbl	(%rdx), %eax
	addq	$1, %rdx
	testb	%al, %al
	je	.L21
.L4:
	cmpb	$78, %al
	jne	.L22
	movzbl	(%rdx), %eax
	addq	$1, %rdx
	movl	$1, %r8d
	testb	%al, %al
	jne	.L4
.L21:
	cmpl	$1, %r8d
	je	.L23
	andl	%edi, %ecx
	xorl	$1, %esi
	testb	%sil, %cl
	jne	.L8
.L2:
	leaq	.LC2(%rip), %rdi
	call	puts@PLT
.L7:
	movq	1016(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L24
	xorl	%eax, %eax
	addq	$1032, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 8
	ret
.L20:
	.cfi_restore_state
	cmpb	$69, %al
	cmove	%r9d, %ecx
	jmp	.L3
	.p2align 4,,10
	.p2align 3
.L11:
	movl	$1, %edi
	jmp	.L3
.L23:
	movl	%ecx, %eax
	andl	%edi, %eax
	testb	%sil, %al
	jne	.L8
	orl	%edi, %ecx
	xorl	$1, %ecx
	testb	%sil, %cl
	je	.L2
.L8:
	leaq	.LC1(%rip), %rdi
	call	puts@PLT
	jmp	.L7
.L24:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:

rule
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%s"
.LC1:
	.string	"Yes"
.LC2:
	.string	"No"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	subq	$1032, %rsp
	.cfi_def_cfa_offset 1040
	leaq	.LC0(%rip), %rdi
	movq	%fs:40, %rax
	movq	%rax, 1016(%rsp)
	xorl	%eax, %eax
	movq	%rsp, %rsi
	call	__isoc99_scanf@PLT
	movzbl	(%rsp), %eax
	testb	%al, %al
	je	.L2
	leaq	1(%rsp), %rdx
	xorl	%ecx, %ecx
	xorl	%edi, %edi
	xorl	%r8d, %r8d
	xorl	%esi, %esi
	movl	$1, %r9d
	jmp	.L4
	.p2align 4,,10
	.p2align 3
.L22:
	cmpb	$87, %al
	je	.L11
	cmpb	$83, %al
	jne	.L20
	movl	$1, %esi
.L3:
	movzbl	(%rdx), %eax
	addq	$1, %rdx
	testb	%al, %al
	je	.L21
.L4:
	cmpb	$78, %al
	jne	.L22
	movzbl	(%rdx), %eax
	addq	$1, %rdx
	movl	$1, %r8d
	testb	%al, %al
	jne	.L4
.L21:
	cmpl	$1, %r8d
	je	.L23
	andl	%edi, %ecx
	xorl	$1, %esi
	testb	%sil, %cl
	jne	.L8
.L2:
	leaq	.LC2(%rip), %rdi
	call	puts@PLT
.L7:
	movq	1016(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L24
	xorl	%eax, %eax
	addq	$1032, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 8
	ret
.L20:
	.cfi_restore_state
	cmpb	$69, %al
	cmove	%r9d, %ecx
	jmp	.L3
	.p2align 4,,10
	.p2align 3
.L11:
	movl	$1, %edi
	jmp	.L3
.L23:
	movl	%ecx, %eax
	andl	%edi, %eax
	testb	%sil, %al
	jne	.L8
	orl	%edi, %ecx
	xorl	$1, %ecx
	testb	%sil, %cl
	je	.L2
.L8:
	leaq	.LC1(%rip), %rdi
	call	puts@PLT
	jmp	.L7
.L24:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:

#include<stdio.h>

int main(){
	char s[1001];scanf("%s",s);
	int nwes[4]={0},i=0;
	while(s[i]!=0){
		if(s[i]=='N')nwes[0]=1;
		if(s[i]=='W')nwes[1]=1;
		if(s[i]=='S')nwes[2]=1;
		if(s[i]=='E')nwes[3]=1;
		i++;
	}
	if(nwes[0]==1&&nwes[1]==1&&
	nwes[2]==1&&nwes[3]==1){
		puts("Yes");
		return 0;
	}else if(nwes[0]==1&&nwes[1]==0&&
	nwes[2]==1&&nwes[3]==0){
		puts("Yes");
		return 0;
	}else if(nwes[0]==0&&nwes[1]==1&&
	nwes[2]==0&&nwes[3]==1){
		puts("Yes");
		return 0;
	}else{
		puts("No");
		return 0;
	}
	return 0;
}

SEWN
 NNDW
 ESWN
 NSNSNNSN
 WNES
 NEWS
 ENWS
 NWES
 WNEN
 SNEW

Yes
 No
 Yes
 Yes
 Yes
 Yes
 Yes
 Yes
 No
 Yes

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

```c
#include<stdio.h>

int main(){
	char s[1001];scanf("%s",s);
	int nwes[4]={0},i=0;
	while(s[i]!=0){
		if(s[i]=='N')nwes[0]=1;
		if(s[i]=='W')nwes[1]=1;
		if(s[i]=='S')nwes[2]=1;
		if(s[i]=='E')nwes[3]=1;
		i++;
	}
	if(nwes[0]==1&&nwes[1]==1&&
	nwes[2]==1&&nwes[3]==1){
		puts("Yes");
		return 0;
	}else if(nwes[0]==1&&nwes[1]==0&&
	nwes[2]==1&&nwes[3]==0){
		puts("Yes");
		return 0;
	}else if(nwes[0]==0&&nwes[1]==1&&
	nwes[2]==0&&nwes[3]==1){
		puts("Yes");
		return 0;
	}else{
		puts("No");
		return 0;
	}
	return 0;
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%s"
.LC1:
	.string	"Yes"
.LC2:
	.string	"No"
	.text
	.globl	main
	.type	main, @function
main:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$1056, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-1024(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	$0, -1040(%rbp)
	movq	$0, -1032(%rbp)
	movl	$0, -1044(%rbp)
	jmp	.L2
.L7:
	movl	-1044(%rbp), %eax
	cltq
	movzbl	-1024(%rbp,%rax), %eax
	cmpb	$78, %al
	jne	.L3
	movl	$1, -1040(%rbp)
.L3:
	movl	-1044(%rbp), %eax
	cltq
	movzbl	-1024(%rbp,%rax), %eax
	cmpb	$87, %al
	jne	.L4
	movl	$1, -1036(%rbp)
.L4:
	movl	-1044(%rbp), %eax
	cltq
	movzbl	-1024(%rbp,%rax), %eax
	cmpb	$83, %al
	jne	.L5
	movl	$1, -1032(%rbp)
.L5:
	movl	-1044(%rbp), %eax
	cltq
	movzbl	-1024(%rbp,%rax), %eax
	cmpb	$69, %al
	jne	.L6
	movl	$1, -1028(%rbp)
.L6:
	addl	$1, -1044(%rbp)
.L2:
	movl	-1044(%rbp), %eax
	cltq
	movzbl	-1024(%rbp,%rax), %eax
	testb	%al, %al
	jne	.L7
	movl	-1040(%rbp), %eax
	cmpl	$1, %eax
	jne	.L8
	movl	-1036(%rbp), %eax
	cmpl	$1, %eax
	jne	.L8
	movl	-1032(%rbp), %eax
	cmpl	$1, %eax
	jne	.L8
	movl	-1028(%rbp), %eax
	cmpl	$1, %eax
	jne	.L8
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	movl	$0, %eax
	jmp	.L12
.L8:
	movl	-1040(%rbp), %eax
	cmpl	$1, %eax
	jne	.L10
	movl	-1036(%rbp), %eax
	testl	%eax, %eax
	jne	.L10
	movl	-1032(%rbp), %eax
	cmpl	$1, %eax
	jne	.L10
	movl	-1028(%rbp), %eax
	testl	%eax, %eax
	jne	.L10
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	movl	$0, %eax
	jmp	.L12
.L10:
	movl	-1040(%rbp), %eax
	testl	%eax, %eax
	jne	.L11
	movl	-1036(%rbp), %eax
	cmpl	$1, %eax
	jne	.L11
	movl	-1032(%rbp), %eax
	testl	%eax, %eax
	jne	.L11
	movl	-1028(%rbp), %eax
	cmpl	$1, %eax
	jne	.L11
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	movl	$0, %eax
	jmp	.L12
.L11:
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	movl	$0, %eax
.L12:
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L13
	call	__stack_chk_fail@PLT
.L13:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:
```

Only output the optimized assembly code. Do not include any other text. Do not write any comments in the assembly code. Wrap the assembly code in ```assembly``` tags.
train
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%s"
.LC1:
	.string	"Yes"
.LC2:
	.string	"No"
	.text
	.globl	main
	.type	main, @function
main:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$1056, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-1024(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	$0, -1040(%rbp)
	movq	$0, -1032(%rbp)
	movl	$0, -1044(%rbp)
	jmp	.L2
.L7:
	movl	-1044(%rbp), %eax
	cltq
	movzbl	-1024(%rbp,%rax), %eax
	cmpb	$78, %al
	jne	.L3
	movl	$1, -1040(%rbp)
.L3:
	movl	-1044(%rbp), %eax
	cltq
	movzbl	-1024(%rbp,%rax), %eax
	cmpb	$87, %al
	jne	.L4
	movl	$1, -1036(%rbp)
.L4:
	movl	-1044(%rbp), %eax
	cltq
	movzbl	-1024(%rbp,%rax), %eax
	cmpb	$83, %al
	jne	.L5
	movl	$1, -1032(%rbp)
.L5:
	movl	-1044(%rbp), %eax
	cltq
	movzbl	-1024(%rbp,%rax), %eax
	cmpb	$69, %al
	jne	.L6
	movl	$1, -1028(%rbp)
.L6:
	addl	$1, -1044(%rbp)
.L2:
	movl	-1044(%rbp), %eax
	cltq
	movzbl	-1024(%rbp,%rax), %eax
	testb	%al, %al
	jne	.L7
	movl	-1040(%rbp), %eax
	cmpl	$1, %eax
	jne	.L8
	movl	-1036(%rbp), %eax
	cmpl	$1, %eax
	jne	.L8
	movl	-1032(%rbp), %eax
	cmpl	$1, %eax
	jne	.L8
	movl	-1028(%rbp), %eax
	cmpl	$1, %eax
	jne	.L8
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	movl	$0, %eax
	jmp	.L12
.L8:
	movl	-1040(%rbp), %eax
	cmpl	$1, %eax
	jne	.L10
	movl	-1036(%rbp), %eax
	testl	%eax, %eax
	jne	.L10
	movl	-1032(%rbp), %eax
	cmpl	$1, %eax
	jne	.L10
	movl	-1028(%rbp), %eax
	testl	%eax, %eax
	jne	.L10
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	movl	$0, %eax
	jmp	.L12
.L10:
	movl	-1040(%rbp), %eax
	testl	%eax, %eax
	jne	.L11
	movl	-1036(%rbp), %eax
	cmpl	$1, %eax
	jne	.L11
	movl	-1032(%rbp), %eax
	testl	%eax, %eax
	jne	.L11
	movl	-1028(%rbp), %eax
	cmpl	$1, %eax
	jne	.L11
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	movl	$0, %eax
	jmp	.L12
.L11:
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	movl	$0, %eax
.L12:
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L13
	call	__stack_chk_fail@PLT
.L13:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:
