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 <unistd.h>

int main()
{
	int i;
	int n;
	int w;
	int r;

	r = 0;
	w = 0;
	scanf("%d", &n);
	char str[n + 1];
	scanf("%s", str);
	i = 0;
	while (str[i])
	{
		if (str[i] == 'R')
			r++;
		i++;
		n--;
	}
	i = 0;
	while (r)
	{
		if (str[i] == 'W')
			w++;
		i++;
		r--;
	}
	printf("%d", w);
	return (0);
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%s"
	.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	%r15
	pushq	%r14
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	subq	$56, %rsp
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	.cfi_offset 12, -48
	.cfi_offset 3, -56
	movq	%fs:40, %rax
	movq	%rax, -56(%rbp)
	xorl	%eax, %eax
	movq	%rsp, %rax
	movq	%rax, %rbx
	movl	$0, -76(%rbp)
	movl	$0, -80(%rbp)
	leaq	-88(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-88(%rbp), %eax
	addl	$1, %eax
	movslq	%eax, %rdx
	subq	$1, %rdx
	movq	%rdx, -72(%rbp)
	movslq	%eax, %rdx
	movq	%rdx, %r14
	movl	$0, %r15d
	movslq	%eax, %rdx
	movq	%rdx, %r12
	movl	$0, %r13d
	cltq
	movl	$16, %edx
	subq	$1, %rdx
	addq	%rdx, %rax
	movl	$16, %esi
	movl	$0, %edx
	divq	%rsi
	imulq	$16, %rax, %rax
	movq	%rax, %rcx
	andq	$-4096, %rcx
	movq	%rsp, %rdx
	subq	%rcx, %rdx
.L2:
	cmpq	%rdx, %rsp
	je	.L3
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L2
.L3:
	movq	%rax, %rdx
	andl	$4095, %edx
	subq	%rdx, %rsp
	movq	%rax, %rdx
	andl	$4095, %edx
	testq	%rdx, %rdx
	je	.L4
	andl	$4095, %eax
	subq	$8, %rax
	addq	%rsp, %rax
	orq	$0, (%rax)
.L4:
	movq	%rsp, %rax
	addq	$0, %rax
	movq	%rax, -64(%rbp)
	movq	-64(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -84(%rbp)
	jmp	.L5
.L7:
	movq	-64(%rbp), %rdx
	movl	-84(%rbp), %eax
	cltq
	movzbl	(%rdx,%rax), %eax
	cmpb	$82, %al
	jne	.L6
	addl	$1, -76(%rbp)
.L6:
	addl	$1, -84(%rbp)
	movl	-88(%rbp), %eax
	subl	$1, %eax
	movl	%eax, -88(%rbp)
.L5:
	movq	-64(%rbp), %rdx
	movl	-84(%rbp), %eax
	cltq
	movzbl	(%rdx,%rax), %eax
	testb	%al, %al
	jne	.L7
	movl	$0, -84(%rbp)
	jmp	.L8
.L10:
	movq	-64(%rbp), %rdx
	movl	-84(%rbp), %eax
	cltq
	movzbl	(%rdx,%rax), %eax
	cmpb	$87, %al
	jne	.L9
	addl	$1, -80(%rbp)
.L9:
	addl	$1, -84(%rbp)
	subl	$1, -76(%rbp)
.L8:
	cmpl	$0, -76(%rbp)
	jne	.L10
	movl	-80(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	%rbx, %rsp
	movq	-56(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L12
	call	__stack_chk_fail@PLT
.L12:
	leaq	-40(%rbp), %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.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	"%d"
.LC1:
	.string	"%s"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB35:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%r12
	.cfi_offset 12, -24
	leaq	.LC0(%rip), %r12
	pushq	%rbx
	leaq	-28(%rbp), %rsi
	movq	%r12, %rdi
	subq	$16, %rsp
	.cfi_offset 3, -32
	movq	%fs:40, %rax
	movq	%rax, -24(%rbp)
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	-28(%rbp), %eax
	movq	%rsp, %rcx
	addl	$1, %eax
	cltq
	addq	$15, %rax
	movq	%rax, %rdx
	andq	$-4096, %rax
	subq	%rax, %rcx
	andq	$-16, %rdx
	cmpq	%rcx, %rsp
	je	.L3
.L84:
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	cmpq	%rcx, %rsp
	jne	.L84
.L3:
	andl	$4095, %edx
	subq	%rdx, %rsp
	testq	%rdx, %rdx
	jne	.L85
.L4:
	movq	%rsp, %rsi
	leaq	.LC1(%rip), %rdi
	xorl	%eax, %eax
	movq	%rsp, %rbx
	call	__isoc99_scanf@PLT
	movzbl	(%rsp), %edx
	testb	%dl, %dl
	je	.L9
	movl	-28(%rbp), %edi
	movq	%rsp, %rsi
	movq	%rsp, %rax
	xorl	%ecx, %ecx
	leal	-1(%rdi,%rbx), %r8d
	.p2align 4,,10
	.p2align 3
.L8:
	cmpb	$82, %dl
	movl	%r8d, %edi
	sete	%dl
	subl	%eax, %edi
	addq	$1, %rax
	movzbl	%dl, %edx
	addl	%edx, %ecx
	movzbl	(%rax), %edx
	testb	%dl, %dl
	jne	.L8
	movl	%edi, -28(%rbp)
	testl	%ecx, %ecx
	je	.L9
	movl	%ecx, %edi
	cmpl	$15, %ecx
	jle	.L30
	pxor	%xmm1, %xmm1
	pxor	%xmm4, %xmm4
	pxor	%xmm3, %xmm3
	movl	%ecx, %eax
	shrl	$4, %eax
	movdqa	.LC2(%rip), %xmm6
	movdqa	.LC3(%rip), %xmm5
	leal	-1(%rax), %edx
	leaq	16(%rsi), %rax
	salq	$4, %rdx
	addq	%rax, %rdx
	jmp	.L11
	.p2align 4,,10
	.p2align 3
.L86:
	addq	$16, %rax
.L11:
	movdqu	(%rsi), %xmm0
	movdqa	%xmm4, %xmm7
	movq	%rax, %rsi
	pcmpeqb	%xmm6, %xmm0
	pand	%xmm5, %xmm0
	pcmpgtb	%xmm0, %xmm7
	movdqa	%xmm0, %xmm2
	punpcklbw	%xmm7, %xmm2
	punpckhbw	%xmm7, %xmm0
	movdqa	%xmm3, %xmm7
	pcmpgtw	%xmm2, %xmm7
	movdqa	%xmm2, %xmm8
	punpcklwd	%xmm7, %xmm8
	punpckhwd	%xmm7, %xmm2
	movdqa	%xmm0, %xmm7
	paddd	%xmm8, %xmm1
	paddd	%xmm2, %xmm1
	movdqa	%xmm3, %xmm2
	pcmpgtw	%xmm0, %xmm2
	punpcklwd	%xmm2, %xmm7
	punpckhwd	%xmm2, %xmm0
	paddd	%xmm7, %xmm1
	paddd	%xmm0, %xmm1
	cmpq	%rax, %rdx
	jne	.L86
	movdqa	%xmm1, %xmm0
	movl	%ecx, %eax
	psrldq	$8, %xmm0
	andl	$-16, %eax
	paddd	%xmm0, %xmm1
	subl	%eax, %ecx
	movdqa	%xmm1, %xmm0
	psrldq	$4, %xmm0
	paddd	%xmm0, %xmm1
	movd	%xmm1, %edx
	cmpl	%eax, %edi
	je	.L6
.L10:
	movslq	%eax, %rsi
	cmpb	$87, (%rbx,%rsi)
	sete	%sil
	movzbl	%sil, %esi
	addl	%esi, %edx
	leal	1(%rax), %esi
	cmpl	$1, %ecx
	je	.L6
	movslq	%esi, %rsi
	cmpb	$87, (%rbx,%rsi)
	sete	%sil
	movzbl	%sil, %esi
	addl	%esi, %edx
	leal	2(%rax), %esi
	cmpl	$2, %ecx
	je	.L6
	movslq	%esi, %rsi
	cmpb	$87, (%rbx,%rsi)
	jne	.L15
	addl	$1, %edx
.L15:
	leal	3(%rax), %esi
	cmpl	$3, %ecx
	je	.L6
	movslq	%esi, %rsi
	cmpb	$87, (%rbx,%rsi)
	jne	.L16
	addl	$1, %edx
.L16:
	leal	4(%rax), %esi
	cmpl	$4, %ecx
	je	.L6
	movslq	%esi, %rsi
	cmpb	$87, (%rbx,%rsi)
	jne	.L17
	addl	$1, %edx
.L17:
	leal	5(%rax), %esi
	cmpl	$5, %ecx
	je	.L6
	movslq	%esi, %rsi
	cmpb	$87, (%rbx,%rsi)
	jne	.L18
	addl	$1, %edx
.L18:
	leal	6(%rax), %esi
	cmpl	$6, %ecx
	je	.L6
	movslq	%esi, %rsi
	cmpb	$87, (%rbx,%rsi)
	jne	.L19
	addl	$1, %edx
.L19:
	leal	7(%rax), %esi
	cmpl	$7, %ecx
	je	.L6
	movslq	%esi, %rsi
	cmpb	$87, (%rbx,%rsi)
	jne	.L20
	addl	$1, %edx
.L20:
	leal	8(%rax), %esi
	cmpl	$8, %ecx
	je	.L6
	movslq	%esi, %rsi
	cmpb	$87, (%rbx,%rsi)
	jne	.L21
	addl	$1, %edx
.L21:
	leal	9(%rax), %esi
	cmpl	$9, %ecx
	je	.L6
	movslq	%esi, %rsi
	cmpb	$87, (%rbx,%rsi)
	je	.L87
.L22:
	leal	10(%rax), %esi
	cmpl	$10, %ecx
	je	.L6
	movslq	%esi, %rsi
	cmpb	$87, (%rbx,%rsi)
	je	.L88
.L23:
	leal	11(%rax), %esi
	cmpl	$11, %ecx
	je	.L6
	movslq	%esi, %rsi
	cmpb	$87, (%rbx,%rsi)
	je	.L89
.L24:
	leal	12(%rax), %esi
	cmpl	$12, %ecx
	je	.L6
	movslq	%esi, %rsi
	cmpb	$87, (%rbx,%rsi)
	je	.L90
.L25:
	leal	13(%rax), %esi
	cmpl	$13, %ecx
	je	.L6
	movslq	%esi, %rsi
	cmpb	$87, (%rbx,%rsi)
	jne	.L26
	addl	$1, %edx
.L26:
	addl	$14, %eax
	cmpl	$14, %ecx
	je	.L6
	cltq
	cmpb	$87, (%rbx,%rax)
	jne	.L6
	addl	$1, %edx
	.p2align 4,,10
	.p2align 3
.L6:
	xorl	%eax, %eax
	movq	%r12, %rsi
	movl	$1, %edi
	call	__printf_chk@PLT
	movq	-24(%rbp), %rax
	subq	%fs:40, %rax
	jne	.L91
	leaq	-16(%rbp), %rsp
	xorl	%eax, %eax
	popq	%rbx
	popq	%r12
	popq	%rbp
	.cfi_remember_state
	.cfi_def_cfa 7, 8
	ret
.L85:
	.cfi_restore_state
	orq	$0, -8(%rsp,%rdx)
	jmp	.L4
.L87:
	addl	$1, %edx
	jmp	.L22
.L88:
	addl	$1, %edx
	jmp	.L23
.L89:
	addl	$1, %edx
	jmp	.L24
.L90:
	addl	$1, %edx
	jmp	.L25
.L9:
	xorl	%edx, %edx
	jmp	.L6
.L30:
	xorl	%edx, %edx
	xorl	%eax, %eax
	jmp	.L10
.L91:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE35:
	.size	main, .-main
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC2:
	.byte	87
	.byte	87
	.byte	87
	.byte	87
	.byte	87
	.byte	87
	.byte	87
	.byte	87
	.byte	87
	.byte	87
	.byte	87
	.byte	87
	.byte	87
	.byte	87
	.byte	87
	.byte	87
	.align 16
.LC3:
	.byte	1
	.byte	1
	.byte	1
	.byte	1
	.byte	1
	.byte	1
	.byte	1
	.byte	1
	.byte	1
	.byte	1
	.byte	1
	.byte	1
	.byte	1
	.byte	1
	.byte	1
	.byte	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
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	"%s"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB35:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%r12
	.cfi_offset 12, -24
	leaq	.LC0(%rip), %r12
	pushq	%rbx
	leaq	-28(%rbp), %rsi
	movq	%r12, %rdi
	subq	$16, %rsp
	.cfi_offset 3, -32
	movq	%fs:40, %rax
	movq	%rax, -24(%rbp)
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	-28(%rbp), %eax
	movq	%rsp, %rcx
	addl	$1, %eax
	cltq
	addq	$15, %rax
	movq	%rax, %rdx
	andq	$-4096, %rax
	subq	%rax, %rcx
	andq	$-16, %rdx
	cmpq	%rcx, %rsp
	je	.L3
.L84:
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	cmpq	%rcx, %rsp
	jne	.L84
.L3:
	andl	$4095, %edx
	subq	%rdx, %rsp
	testq	%rdx, %rdx
	jne	.L85
.L4:
	movq	%rsp, %rsi
	leaq	.LC1(%rip), %rdi
	xorl	%eax, %eax
	movq	%rsp, %rbx
	call	__isoc99_scanf@PLT
	movzbl	(%rsp), %edx
	testb	%dl, %dl
	je	.L9
	movl	-28(%rbp), %edi
	movq	%rsp, %rsi
	movq	%rsp, %rax
	xorl	%ecx, %ecx
	leal	-1(%rdi,%rbx), %r8d
	.p2align 4,,10
	.p2align 3
.L8:
	cmpb	$82, %dl
	movl	%r8d, %edi
	sete	%dl
	subl	%eax, %edi
	addq	$1, %rax
	movzbl	%dl, %edx
	addl	%edx, %ecx
	movzbl	(%rax), %edx
	testb	%dl, %dl
	jne	.L8
	movl	%edi, -28(%rbp)
	testl	%ecx, %ecx
	je	.L9
	movl	%ecx, %edi
	cmpl	$15, %ecx
	jle	.L30
	pxor	%xmm1, %xmm1
	pxor	%xmm4, %xmm4
	pxor	%xmm3, %xmm3
	movl	%ecx, %eax
	shrl	$4, %eax
	movdqa	.LC2(%rip), %xmm6
	movdqa	.LC3(%rip), %xmm5
	leal	-1(%rax), %edx
	leaq	16(%rsi), %rax
	salq	$4, %rdx
	addq	%rax, %rdx
	jmp	.L11
	.p2align 4,,10
	.p2align 3
.L86:
	addq	$16, %rax
.L11:
	movdqu	(%rsi), %xmm0
	movdqa	%xmm4, %xmm7
	movq	%rax, %rsi
	pcmpeqb	%xmm6, %xmm0
	pand	%xmm5, %xmm0
	pcmpgtb	%xmm0, %xmm7
	movdqa	%xmm0, %xmm2
	punpcklbw	%xmm7, %xmm2
	punpckhbw	%xmm7, %xmm0
	movdqa	%xmm3, %xmm7
	pcmpgtw	%xmm2, %xmm7
	movdqa	%xmm2, %xmm8
	punpcklwd	%xmm7, %xmm8
	punpckhwd	%xmm7, %xmm2
	movdqa	%xmm0, %xmm7
	paddd	%xmm8, %xmm1
	paddd	%xmm2, %xmm1
	movdqa	%xmm3, %xmm2
	pcmpgtw	%xmm0, %xmm2
	punpcklwd	%xmm2, %xmm7
	punpckhwd	%xmm2, %xmm0
	paddd	%xmm7, %xmm1
	paddd	%xmm0, %xmm1
	cmpq	%rax, %rdx
	jne	.L86
	movdqa	%xmm1, %xmm0
	movl	%ecx, %eax
	psrldq	$8, %xmm0
	andl	$-16, %eax
	paddd	%xmm0, %xmm1
	subl	%eax, %ecx
	movdqa	%xmm1, %xmm0
	psrldq	$4, %xmm0
	paddd	%xmm0, %xmm1
	movd	%xmm1, %edx
	cmpl	%eax, %edi
	je	.L6
.L10:
	movslq	%eax, %rsi
	cmpb	$87, (%rbx,%rsi)
	sete	%sil
	movzbl	%sil, %esi
	addl	%esi, %edx
	leal	1(%rax), %esi
	cmpl	$1, %ecx
	je	.L6
	movslq	%esi, %rsi
	cmpb	$87, (%rbx,%rsi)
	sete	%sil
	movzbl	%sil, %esi
	addl	%esi, %edx
	leal	2(%rax), %esi
	cmpl	$2, %ecx
	je	.L6
	movslq	%esi, %rsi
	cmpb	$87, (%rbx,%rsi)
	jne	.L15
	addl	$1, %edx
.L15:
	leal	3(%rax), %esi
	cmpl	$3, %ecx
	je	.L6
	movslq	%esi, %rsi
	cmpb	$87, (%rbx,%rsi)
	jne	.L16
	addl	$1, %edx
.L16:
	leal	4(%rax), %esi
	cmpl	$4, %ecx
	je	.L6
	movslq	%esi, %rsi
	cmpb	$87, (%rbx,%rsi)
	jne	.L17
	addl	$1, %edx
.L17:
	leal	5(%rax), %esi
	cmpl	$5, %ecx
	je	.L6
	movslq	%esi, %rsi
	cmpb	$87, (%rbx,%rsi)
	jne	.L18
	addl	$1, %edx
.L18:
	leal	6(%rax), %esi
	cmpl	$6, %ecx
	je	.L6
	movslq	%esi, %rsi
	cmpb	$87, (%rbx,%rsi)
	jne	.L19
	addl	$1, %edx
.L19:
	leal	7(%rax), %esi
	cmpl	$7, %ecx
	je	.L6
	movslq	%esi, %rsi
	cmpb	$87, (%rbx,%rsi)
	jne	.L20
	addl	$1, %edx
.L20:
	leal	8(%rax), %esi
	cmpl	$8, %ecx
	je	.L6
	movslq	%esi, %rsi
	cmpb	$87, (%rbx,%rsi)
	jne	.L21
	addl	$1, %edx
.L21:
	leal	9(%rax), %esi
	cmpl	$9, %ecx
	je	.L6
	movslq	%esi, %rsi
	cmpb	$87, (%rbx,%rsi)
	je	.L87
.L22:
	leal	10(%rax), %esi
	cmpl	$10, %ecx
	je	.L6
	movslq	%esi, %rsi
	cmpb	$87, (%rbx,%rsi)
	je	.L88
.L23:
	leal	11(%rax), %esi
	cmpl	$11, %ecx
	je	.L6
	movslq	%esi, %rsi
	cmpb	$87, (%rbx,%rsi)
	je	.L89
.L24:
	leal	12(%rax), %esi
	cmpl	$12, %ecx
	je	.L6
	movslq	%esi, %rsi
	cmpb	$87, (%rbx,%rsi)
	je	.L90
.L25:
	leal	13(%rax), %esi
	cmpl	$13, %ecx
	je	.L6
	movslq	%esi, %rsi
	cmpb	$87, (%rbx,%rsi)
	jne	.L26
	addl	$1, %edx
.L26:
	addl	$14, %eax
	cmpl	$14, %ecx
	je	.L6
	cltq
	cmpb	$87, (%rbx,%rax)
	jne	.L6
	addl	$1, %edx
	.p2align 4,,10
	.p2align 3
.L6:
	xorl	%eax, %eax
	movq	%r12, %rsi
	movl	$1, %edi
	call	__printf_chk@PLT
	movq	-24(%rbp), %rax
	subq	%fs:40, %rax
	jne	.L91
	leaq	-16(%rbp), %rsp
	xorl	%eax, %eax
	popq	%rbx
	popq	%r12
	popq	%rbp
	.cfi_remember_state
	.cfi_def_cfa 7, 8
	ret
.L85:
	.cfi_restore_state
	orq	$0, -8(%rsp,%rdx)
	jmp	.L4
.L87:
	addl	$1, %edx
	jmp	.L22
.L88:
	addl	$1, %edx
	jmp	.L23
.L89:
	addl	$1, %edx
	jmp	.L24
.L90:
	addl	$1, %edx
	jmp	.L25
.L9:
	xorl	%edx, %edx
	jmp	.L6
.L30:
	xorl	%edx, %edx
	xorl	%eax, %eax
	jmp	.L10
.L91:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE35:
	.size	main, .-main
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC2:
	.byte	87
	.byte	87
	.byte	87
	.byte	87
	.byte	87
	.byte	87
	.byte	87
	.byte	87
	.byte	87
	.byte	87
	.byte	87
	.byte	87
	.byte	87
	.byte	87
	.byte	87
	.byte	87
	.align 16
.LC3:
	.byte	1
	.byte	1
	.byte	1
	.byte	1
	.byte	1
	.byte	1
	.byte	1
	.byte	1
	.byte	1
	.byte	1
	.byte	1
	.byte	1
	.byte	1
	.byte	1
	.byte	1
	.byte	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>
#include <unistd.h>

int main()
{
	int i;
	int n;
	int w;
	int r;

	r = 0;
	w = 0;
	scanf("%d", &n);
	char str[n + 1];
	scanf("%s", str);
	i = 0;
	while (str[i])
	{
		if (str[i] == 'R')
			r++;
		i++;
		n--;
	}
	i = 0;
	while (r)
	{
		if (str[i] == 'W')
			w++;
		i++;
		r--;
	}
	printf("%d", w);
	return (0);
}
8
RRWRWWRW
 2
RQ
 8
RRWWWRRW
 8
WRWWWRRR
 8
WWWWRRRR
 8
RRWRVWRW
 4
RRWW
 4
RWWR
 2
RS
 4
RRVW

1 0 2 3 4 1 0 1 0 0
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 <unistd.h>

int main()
{
	int i;
	int n;
	int w;
	int r;

	r = 0;
	w = 0;
	scanf("%d", &n);
	char str[n + 1];
	scanf("%s", str);
	i = 0;
	while (str[i])
	{
		if (str[i] == 'R')
			r++;
		i++;
		n--;
	}
	i = 0;
	while (r)
	{
		if (str[i] == 'W')
			w++;
		i++;
		r--;
	}
	printf("%d", w);
	return (0);
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%s"
	.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	%r15
	pushq	%r14
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	subq	$56, %rsp
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	.cfi_offset 12, -48
	.cfi_offset 3, -56
	movq	%fs:40, %rax
	movq	%rax, -56(%rbp)
	xorl	%eax, %eax
	movq	%rsp, %rax
	movq	%rax, %rbx
	movl	$0, -76(%rbp)
	movl	$0, -80(%rbp)
	leaq	-88(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-88(%rbp), %eax
	addl	$1, %eax
	movslq	%eax, %rdx
	subq	$1, %rdx
	movq	%rdx, -72(%rbp)
	movslq	%eax, %rdx
	movq	%rdx, %r14
	movl	$0, %r15d
	movslq	%eax, %rdx
	movq	%rdx, %r12
	movl	$0, %r13d
	cltq
	movl	$16, %edx
	subq	$1, %rdx
	addq	%rdx, %rax
	movl	$16, %esi
	movl	$0, %edx
	divq	%rsi
	imulq	$16, %rax, %rax
	movq	%rax, %rcx
	andq	$-4096, %rcx
	movq	%rsp, %rdx
	subq	%rcx, %rdx
.L2:
	cmpq	%rdx, %rsp
	je	.L3
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L2
.L3:
	movq	%rax, %rdx
	andl	$4095, %edx
	subq	%rdx, %rsp
	movq	%rax, %rdx
	andl	$4095, %edx
	testq	%rdx, %rdx
	je	.L4
	andl	$4095, %eax
	subq	$8, %rax
	addq	%rsp, %rax
	orq	$0, (%rax)
.L4:
	movq	%rsp, %rax
	addq	$0, %rax
	movq	%rax, -64(%rbp)
	movq	-64(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -84(%rbp)
	jmp	.L5
.L7:
	movq	-64(%rbp), %rdx
	movl	-84(%rbp), %eax
	cltq
	movzbl	(%rdx,%rax), %eax
	cmpb	$82, %al
	jne	.L6
	addl	$1, -76(%rbp)
.L6:
	addl	$1, -84(%rbp)
	movl	-88(%rbp), %eax
	subl	$1, %eax
	movl	%eax, -88(%rbp)
.L5:
	movq	-64(%rbp), %rdx
	movl	-84(%rbp), %eax
	cltq
	movzbl	(%rdx,%rax), %eax
	testb	%al, %al
	jne	.L7
	movl	$0, -84(%rbp)
	jmp	.L8
.L10:
	movq	-64(%rbp), %rdx
	movl	-84(%rbp), %eax
	cltq
	movzbl	(%rdx,%rax), %eax
	cmpb	$87, %al
	jne	.L9
	addl	$1, -80(%rbp)
.L9:
	addl	$1, -84(%rbp)
	subl	$1, -76(%rbp)
.L8:
	cmpl	$0, -76(%rbp)
	jne	.L10
	movl	-80(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	%rbx, %rsp
	movq	-56(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L12
	call	__stack_chk_fail@PLT
.L12:
	leaq	-40(%rbp), %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.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	"%d"
.LC1:
	.string	"%s"
	.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	%r15
	pushq	%r14
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	subq	$56, %rsp
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	.cfi_offset 12, -48
	.cfi_offset 3, -56
	movq	%fs:40, %rax
	movq	%rax, -56(%rbp)
	xorl	%eax, %eax
	movq	%rsp, %rax
	movq	%rax, %rbx
	movl	$0, -76(%rbp)
	movl	$0, -80(%rbp)
	leaq	-88(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-88(%rbp), %eax
	addl	$1, %eax
	movslq	%eax, %rdx
	subq	$1, %rdx
	movq	%rdx, -72(%rbp)
	movslq	%eax, %rdx
	movq	%rdx, %r14
	movl	$0, %r15d
	movslq	%eax, %rdx
	movq	%rdx, %r12
	movl	$0, %r13d
	cltq
	movl	$16, %edx
	subq	$1, %rdx
	addq	%rdx, %rax
	movl	$16, %esi
	movl	$0, %edx
	divq	%rsi
	imulq	$16, %rax, %rax
	movq	%rax, %rcx
	andq	$-4096, %rcx
	movq	%rsp, %rdx
	subq	%rcx, %rdx
.L2:
	cmpq	%rdx, %rsp
	je	.L3
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L2
.L3:
	movq	%rax, %rdx
	andl	$4095, %edx
	subq	%rdx, %rsp
	movq	%rax, %rdx
	andl	$4095, %edx
	testq	%rdx, %rdx
	je	.L4
	andl	$4095, %eax
	subq	$8, %rax
	addq	%rsp, %rax
	orq	$0, (%rax)
.L4:
	movq	%rsp, %rax
	addq	$0, %rax
	movq	%rax, -64(%rbp)
	movq	-64(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -84(%rbp)
	jmp	.L5
.L7:
	movq	-64(%rbp), %rdx
	movl	-84(%rbp), %eax
	cltq
	movzbl	(%rdx,%rax), %eax
	cmpb	$82, %al
	jne	.L6
	addl	$1, -76(%rbp)
.L6:
	addl	$1, -84(%rbp)
	movl	-88(%rbp), %eax
	subl	$1, %eax
	movl	%eax, -88(%rbp)
.L5:
	movq	-64(%rbp), %rdx
	movl	-84(%rbp), %eax
	cltq
	movzbl	(%rdx,%rax), %eax
	testb	%al, %al
	jne	.L7
	movl	$0, -84(%rbp)
	jmp	.L8
.L10:
	movq	-64(%rbp), %rdx
	movl	-84(%rbp), %eax
	cltq
	movzbl	(%rdx,%rax), %eax
	cmpb	$87, %al
	jne	.L9
	addl	$1, -80(%rbp)
.L9:
	addl	$1, -84(%rbp)
	subl	$1, -76(%rbp)
.L8:
	cmpl	$0, -76(%rbp)
	jne	.L10
	movl	-80(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	%rbx, %rsp
	movq	-56(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L12
	call	__stack_chk_fail@PLT
.L12:
	leaq	-40(%rbp), %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.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:
