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>

int main(void){
    int ec=0,wc=0,nc=0,sc=0;
    int flagew=0,flagns=0;
    char s[1000];
    scanf("%s",s);
    for(int i=0;i<=strlen(s);i++){
        if(s[i] == 'E')ec++;
        else if(s[i] == 'W')wc++;
        else if(s[i] == 'N')nc++;
        else if(s[i] == 'S')sc++;
    }
    if(ec == wc){
        flagew = 1;
    }else if(ec != 0 && wc != 0){
        flagew = 1;
    }
    if(nc == sc){
        flagns = 1;
    }else if(nc != 0 && sc != 0){
        flagns = 1;
    }
    if(flagns && flagew){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    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
	pushq	%rbx
	subq	$1048, %rsp
	.cfi_offset 3, -24
	movq	%fs:40, %rax
	movq	%rax, -24(%rbp)
	xorl	%eax, %eax
	movl	$0, -1052(%rbp)
	movl	$0, -1048(%rbp)
	movl	$0, -1044(%rbp)
	movl	$0, -1040(%rbp)
	movl	$0, -1036(%rbp)
	movl	$0, -1032(%rbp)
	leaq	-1024(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -1028(%rbp)
	jmp	.L2
.L7:
	movl	-1028(%rbp), %eax
	cltq
	movzbl	-1024(%rbp,%rax), %eax
	cmpb	$69, %al
	jne	.L3
	addl	$1, -1052(%rbp)
	jmp	.L4
.L3:
	movl	-1028(%rbp), %eax
	cltq
	movzbl	-1024(%rbp,%rax), %eax
	cmpb	$87, %al
	jne	.L5
	addl	$1, -1048(%rbp)
	jmp	.L4
.L5:
	movl	-1028(%rbp), %eax
	cltq
	movzbl	-1024(%rbp,%rax), %eax
	cmpb	$78, %al
	jne	.L6
	addl	$1, -1044(%rbp)
	jmp	.L4
.L6:
	movl	-1028(%rbp), %eax
	cltq
	movzbl	-1024(%rbp,%rax), %eax
	cmpb	$83, %al
	jne	.L4
	addl	$1, -1040(%rbp)
.L4:
	addl	$1, -1028(%rbp)
.L2:
	movl	-1028(%rbp), %eax
	movslq	%eax, %rbx
	leaq	-1024(%rbp), %rax
	movq	%rax, %rdi
	call	strlen@PLT
	cmpq	%rax, %rbx
	jbe	.L7
	movl	-1052(%rbp), %eax
	cmpl	-1048(%rbp), %eax
	jne	.L8
	movl	$1, -1036(%rbp)
	jmp	.L9
.L8:
	cmpl	$0, -1052(%rbp)
	je	.L9
	cmpl	$0, -1048(%rbp)
	je	.L9
	movl	$1, -1036(%rbp)
.L9:
	movl	-1044(%rbp), %eax
	cmpl	-1040(%rbp), %eax
	jne	.L10
	movl	$1, -1032(%rbp)
	jmp	.L11
.L10:
	cmpl	$0, -1044(%rbp)
	je	.L11
	cmpl	$0, -1040(%rbp)
	je	.L11
	movl	$1, -1032(%rbp)
.L11:
	cmpl	$0, -1032(%rbp)
	je	.L12
	cmpl	$0, -1036(%rbp)
	je	.L12
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	jmp	.L13
.L12:
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
.L13:
	movl	$0, %eax
	movq	-24(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L15
	call	__stack_chk_fail@PLT
.L15:
	movq	-8(%rbp), %rbx
	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:
.LFB35:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	leaq	.LC0(%rip), %rdi
	subq	$1008, %rsp
	.cfi_def_cfa_offset 1024
	movq	%fs:40, %rax
	movq	%rax, 1000(%rsp)
	xorl	%eax, %eax
	movq	%rsp, %rbx
	movq	%rbx, %rsi
	call	__isoc99_scanf@PLT
	movq	%rbx, %rdi
	call	strlen@PLT
	xorl	%edi, %edi
	xorl	%r9d, %r9d
	xorl	%esi, %esi
	movq	%rax, %r8
	movq	%rbx, %rax
	leaq	1(%rsp,%r8), %rcx
	xorl	%r8d, %r8d
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L2:
	cmpb	$87, %dl
	je	.L24
	cmpb	$78, %dl
	je	.L25
	cmpb	$83, %dl
	sete	%dl
	movzbl	%dl, %edx
	addl	%edx, %edi
.L3:
	addq	$1, %rax
	cmpq	%rax, %rcx
	je	.L26
.L6:
	movzbl	(%rax), %edx
	cmpb	$69, %dl
	jne	.L2
	addq	$1, %rax
	addl	$1, %esi
	cmpq	%rax, %rcx
	jne	.L6
.L26:
	cmpl	%r8d, %esi
	je	.L7
	testl	%esi, %esi
	je	.L9
	testl	%r8d, %r8d
	je	.L9
.L7:
	cmpl	%edi, %r9d
	je	.L11
	testl	%r9d, %r9d
	je	.L9
	testl	%edi, %edi
	je	.L9
.L11:
	leaq	.LC1(%rip), %rdi
	call	puts@PLT
	jmp	.L10
	.p2align 4,,10
	.p2align 3
.L24:
	addl	$1, %r8d
	jmp	.L3
	.p2align 4,,10
	.p2align 3
.L25:
	addl	$1, %r9d
	jmp	.L3
.L9:
	leaq	.LC2(%rip), %rdi
	call	puts@PLT
.L10:
	movq	1000(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L27
	addq	$1008, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 16
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 8
	ret
.L27:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE35:
	.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:
.LFB35:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	leaq	.LC0(%rip), %rdi
	subq	$1008, %rsp
	.cfi_def_cfa_offset 1024
	movq	%fs:40, %rax
	movq	%rax, 1000(%rsp)
	xorl	%eax, %eax
	movq	%rsp, %rbx
	movq	%rbx, %rsi
	call	__isoc99_scanf@PLT
	movq	%rbx, %rdi
	call	strlen@PLT
	xorl	%edi, %edi
	xorl	%r9d, %r9d
	xorl	%esi, %esi
	movq	%rax, %r8
	movq	%rbx, %rax
	leaq	1(%rsp,%r8), %rcx
	xorl	%r8d, %r8d
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L2:
	cmpb	$87, %dl
	je	.L24
	cmpb	$78, %dl
	je	.L25
	cmpb	$83, %dl
	sete	%dl
	movzbl	%dl, %edx
	addl	%edx, %edi
.L3:
	addq	$1, %rax
	cmpq	%rax, %rcx
	je	.L26
.L6:
	movzbl	(%rax), %edx
	cmpb	$69, %dl
	jne	.L2
	addq	$1, %rax
	addl	$1, %esi
	cmpq	%rax, %rcx
	jne	.L6
.L26:
	cmpl	%r8d, %esi
	je	.L7
	testl	%esi, %esi
	je	.L9
	testl	%r8d, %r8d
	je	.L9
.L7:
	cmpl	%edi, %r9d
	je	.L11
	testl	%r9d, %r9d
	je	.L9
	testl	%edi, %edi
	je	.L9
.L11:
	leaq	.LC1(%rip), %rdi
	call	puts@PLT
	jmp	.L10
	.p2align 4,,10
	.p2align 3
.L24:
	addl	$1, %r8d
	jmp	.L3
	.p2align 4,,10
	.p2align 3
.L25:
	addl	$1, %r9d
	jmp	.L3
.L9:
	leaq	.LC2(%rip), %rdi
	call	puts@PLT
.L10:
	movq	1000(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L27
	addq	$1008, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 16
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 8
	ret
.L27:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE35:
	.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>
#include <string.h>

int main(void){
    int ec=0,wc=0,nc=0,sc=0;
    int flagew=0,flagns=0;
    char s[1000];
    scanf("%s",s);
    for(int i=0;i<=strlen(s);i++){
        if(s[i] == 'E')ec++;
        else if(s[i] == 'W')wc++;
        else if(s[i] == 'N')nc++;
        else if(s[i] == 'S')sc++;
    }
    if(ec == wc){
        flagew = 1;
    }else if(ec != 0 && wc != 0){
        flagew = 1;
    }
    if(nc == sc){
        flagns = 1;
    }else if(nc != 0 && sc != 0){
        flagns = 1;
    }
    if(flagns && flagew){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    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>
#include <string.h>

int main(void){
    int ec=0,wc=0,nc=0,sc=0;
    int flagew=0,flagns=0;
    char s[1000];
    scanf("%s",s);
    for(int i=0;i<=strlen(s);i++){
        if(s[i] == 'E')ec++;
        else if(s[i] == 'W')wc++;
        else if(s[i] == 'N')nc++;
        else if(s[i] == 'S')sc++;
    }
    if(ec == wc){
        flagew = 1;
    }else if(ec != 0 && wc != 0){
        flagew = 1;
    }
    if(nc == sc){
        flagns = 1;
    }else if(nc != 0 && sc != 0){
        flagns = 1;
    }
    if(flagns && flagew){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    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
	pushq	%rbx
	subq	$1048, %rsp
	.cfi_offset 3, -24
	movq	%fs:40, %rax
	movq	%rax, -24(%rbp)
	xorl	%eax, %eax
	movl	$0, -1052(%rbp)
	movl	$0, -1048(%rbp)
	movl	$0, -1044(%rbp)
	movl	$0, -1040(%rbp)
	movl	$0, -1036(%rbp)
	movl	$0, -1032(%rbp)
	leaq	-1024(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -1028(%rbp)
	jmp	.L2
.L7:
	movl	-1028(%rbp), %eax
	cltq
	movzbl	-1024(%rbp,%rax), %eax
	cmpb	$69, %al
	jne	.L3
	addl	$1, -1052(%rbp)
	jmp	.L4
.L3:
	movl	-1028(%rbp), %eax
	cltq
	movzbl	-1024(%rbp,%rax), %eax
	cmpb	$87, %al
	jne	.L5
	addl	$1, -1048(%rbp)
	jmp	.L4
.L5:
	movl	-1028(%rbp), %eax
	cltq
	movzbl	-1024(%rbp,%rax), %eax
	cmpb	$78, %al
	jne	.L6
	addl	$1, -1044(%rbp)
	jmp	.L4
.L6:
	movl	-1028(%rbp), %eax
	cltq
	movzbl	-1024(%rbp,%rax), %eax
	cmpb	$83, %al
	jne	.L4
	addl	$1, -1040(%rbp)
.L4:
	addl	$1, -1028(%rbp)
.L2:
	movl	-1028(%rbp), %eax
	movslq	%eax, %rbx
	leaq	-1024(%rbp), %rax
	movq	%rax, %rdi
	call	strlen@PLT
	cmpq	%rax, %rbx
	jbe	.L7
	movl	-1052(%rbp), %eax
	cmpl	-1048(%rbp), %eax
	jne	.L8
	movl	$1, -1036(%rbp)
	jmp	.L9
.L8:
	cmpl	$0, -1052(%rbp)
	je	.L9
	cmpl	$0, -1048(%rbp)
	je	.L9
	movl	$1, -1036(%rbp)
.L9:
	movl	-1044(%rbp), %eax
	cmpl	-1040(%rbp), %eax
	jne	.L10
	movl	$1, -1032(%rbp)
	jmp	.L11
.L10:
	cmpl	$0, -1044(%rbp)
	je	.L11
	cmpl	$0, -1040(%rbp)
	je	.L11
	movl	$1, -1032(%rbp)
.L11:
	cmpl	$0, -1032(%rbp)
	je	.L12
	cmpl	$0, -1036(%rbp)
	je	.L12
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	jmp	.L13
.L12:
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
.L13:
	movl	$0, %eax
	movq	-24(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L15
	call	__stack_chk_fail@PLT
.L15:
	movq	-8(%rbp), %rbx
	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
	pushq	%rbx
	subq	$1048, %rsp
	.cfi_offset 3, -24
	movq	%fs:40, %rax
	movq	%rax, -24(%rbp)
	xorl	%eax, %eax
	movl	$0, -1052(%rbp)
	movl	$0, -1048(%rbp)
	movl	$0, -1044(%rbp)
	movl	$0, -1040(%rbp)
	movl	$0, -1036(%rbp)
	movl	$0, -1032(%rbp)
	leaq	-1024(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -1028(%rbp)
	jmp	.L2
.L7:
	movl	-1028(%rbp), %eax
	cltq
	movzbl	-1024(%rbp,%rax), %eax
	cmpb	$69, %al
	jne	.L3
	addl	$1, -1052(%rbp)
	jmp	.L4
.L3:
	movl	-1028(%rbp), %eax
	cltq
	movzbl	-1024(%rbp,%rax), %eax
	cmpb	$87, %al
	jne	.L5
	addl	$1, -1048(%rbp)
	jmp	.L4
.L5:
	movl	-1028(%rbp), %eax
	cltq
	movzbl	-1024(%rbp,%rax), %eax
	cmpb	$78, %al
	jne	.L6
	addl	$1, -1044(%rbp)
	jmp	.L4
.L6:
	movl	-1028(%rbp), %eax
	cltq
	movzbl	-1024(%rbp,%rax), %eax
	cmpb	$83, %al
	jne	.L4
	addl	$1, -1040(%rbp)
.L4:
	addl	$1, -1028(%rbp)
.L2:
	movl	-1028(%rbp), %eax
	movslq	%eax, %rbx
	leaq	-1024(%rbp), %rax
	movq	%rax, %rdi
	call	strlen@PLT
	cmpq	%rax, %rbx
	jbe	.L7
	movl	-1052(%rbp), %eax
	cmpl	-1048(%rbp), %eax
	jne	.L8
	movl	$1, -1036(%rbp)
	jmp	.L9
.L8:
	cmpl	$0, -1052(%rbp)
	je	.L9
	cmpl	$0, -1048(%rbp)
	je	.L9
	movl	$1, -1036(%rbp)
.L9:
	movl	-1044(%rbp), %eax
	cmpl	-1040(%rbp), %eax
	jne	.L10
	movl	$1, -1032(%rbp)
	jmp	.L11
.L10:
	cmpl	$0, -1044(%rbp)
	je	.L11
	cmpl	$0, -1040(%rbp)
	je	.L11
	movl	$1, -1032(%rbp)
.L11:
	cmpl	$0, -1032(%rbp)
	je	.L12
	cmpl	$0, -1036(%rbp)
	je	.L12
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	jmp	.L13
.L12:
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
.L13:
	movl	$0, %eax
	movq	-24(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L15
	call	__stack_chk_fail@PLT
.L15:
	movq	-8(%rbp), %rbx
	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:
