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 <math.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
int main(void)
{
	int n;//石の個数
	char *c;//石の色 n個
	int lw=0;//左にあるWの数
	int rr=0;//右にあるRの数
	int *aaa;//しきいi(i=0^n+1)の時の操作回数 n+1個
	int min=INT_MAX;
	scanf("%d",&n);
	c=(char *)malloc(sizeof(char)*n);
	aaa=(int *)malloc(sizeof(int)*n+1);
	int i;
	for(i=0;i<n;i++)
	{
		scanf(" %c",&c[i]);//改行を読み込まない
	}
	for(i=0;i<n;i++)
	{
		if(c[i]=='R')
		{
			rr++;
		}
	}
	if(lw<rr)
	{
		aaa[0]=rr;
	}
	else
	{
		aaa[0]=lw;
	}
	for(i=1;i<n+1;i++)
	{
		if(c[i-1]=='W')
		{
			lw++;
		}
		else
		{
			rr--;
		}
		
		if(lw<rr)
		{
			aaa[i]=rr;
		}
		else
		{
			aaa[i]=lw;
		}
	}
	for(i=0;i<n+1;i++)
	{
		if(aaa[i]<min)
		{
			min=aaa[i];
		}
	}
	printf("%d",min);
	

	
	free(c);
	c=NULL;
	free(aaa);
	aaa=NULL;
	return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	" %c"
	.text
	.globl	main
	.type	main, @function
main:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$48, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -40(%rbp)
	movl	$0, -36(%rbp)
	movl	$2147483647, -32(%rbp)
	leaq	-44(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-44(%rbp), %eax
	cltq
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, -24(%rbp)
	movl	-44(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	$1, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, -16(%rbp)
	movl	$0, -28(%rbp)
	jmp	.L2
.L3:
	movl	-28(%rbp), %eax
	movslq	%eax, %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -28(%rbp)
.L2:
	movl	-44(%rbp), %eax
	cmpl	%eax, -28(%rbp)
	jl	.L3
	movl	$0, -28(%rbp)
	jmp	.L4
.L6:
	movl	-28(%rbp), %eax
	movslq	%eax, %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	$82, %al
	jne	.L5
	addl	$1, -36(%rbp)
.L5:
	addl	$1, -28(%rbp)
.L4:
	movl	-44(%rbp), %eax
	cmpl	%eax, -28(%rbp)
	jl	.L6
	movl	-40(%rbp), %eax
	cmpl	-36(%rbp), %eax
	jge	.L7
	movq	-16(%rbp), %rax
	movl	-36(%rbp), %edx
	movl	%edx, (%rax)
	jmp	.L8
.L7:
	movq	-16(%rbp), %rax
	movl	-40(%rbp), %edx
	movl	%edx, (%rax)
.L8:
	movl	$1, -28(%rbp)
	jmp	.L9
.L14:
	movl	-28(%rbp), %eax
	cltq
	leaq	-1(%rax), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	$87, %al
	jne	.L10
	addl	$1, -40(%rbp)
	jmp	.L11
.L10:
	subl	$1, -36(%rbp)
.L11:
	movl	-40(%rbp), %eax
	cmpl	-36(%rbp), %eax
	jge	.L12
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rax, %rdx
	movl	-36(%rbp), %eax
	movl	%eax, (%rdx)
	jmp	.L13
.L12:
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rax, %rdx
	movl	-40(%rbp), %eax
	movl	%eax, (%rdx)
.L13:
	addl	$1, -28(%rbp)
.L9:
	movl	-44(%rbp), %eax
	cmpl	%eax, -28(%rbp)
	jle	.L14
	movl	$0, -28(%rbp)
	jmp	.L15
.L17:
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cmpl	%eax, -32(%rbp)
	jle	.L16
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, -32(%rbp)
.L16:
	addl	$1, -28(%rbp)
.L15:
	movl	-44(%rbp), %eax
	cmpl	%eax, -28(%rbp)
	jle	.L17
	movl	-32(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movq	-24(%rbp), %rax
	movq	%rax, %rdi
	call	free@PLT
	movq	$0, -24(%rbp)
	movq	-16(%rbp), %rax
	movq	%rax, %rdi
	call	free@PLT
	movq	$0, -16(%rbp)
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L19
	call	__stack_chk_fail@PLT
.L19:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.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
.LC1:
	.string	"%d"
.LC2:
	.string	" %c"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB51:
	.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	.LC1(%rip), %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movq	%r13, %rdi
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	leaq	4(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movslq	4(%rsp), %r12
	movq	%r12, %rdi
	movq	%r12, %rbx
	call	malloc@PLT
	leaq	1(,%r12,4), %rdi
	movq	%rax, %rbp
	call	malloc@PLT
	movq	%rax, %r12
	testl	%ebx, %ebx
	jle	.L2
	xorl	%ebx, %ebx
	leaq	.LC2(%rip), %r14
	.p2align 4,,10
	.p2align 3
.L3:
	leaq	(%rbx,%rbp), %rsi
	movq	%r14, %rdi
	xorl	%eax, %eax
	addq	$1, %rbx
	call	__isoc99_scanf@PLT
	movl	4(%rsp), %ecx
	movq	%rbp, %r15
	cmpl	%ebx, %ecx
	jg	.L3
	testl	%ecx, %ecx
	jle	.L31
	leal	-1(%rcx), %eax
	cmpl	$14, %eax
	jbe	.L32
	pxor	%xmm1, %xmm1
	pxor	%xmm5, %xmm5
	pxor	%xmm4, %xmm4
	movl	%ecx, %eax
	shrl	$4, %eax
	movdqa	.LC3(%rip), %xmm7
	movdqa	.LC4(%rip), %xmm6
	salq	$4, %rax
	addq	%rbp, %rax
	.p2align 4,,10
	.p2align 3
.L5:
	movdqu	(%r15), %xmm0
	movdqa	%xmm5, %xmm3
	addq	$16, %r15
	pcmpeqb	%xmm7, %xmm0
	pand	%xmm6, %xmm0
	pcmpgtb	%xmm0, %xmm3
	movdqa	%xmm0, %xmm2
	punpcklbw	%xmm3, %xmm2
	punpckhbw	%xmm3, %xmm0
	movdqa	%xmm4, %xmm3
	pcmpgtw	%xmm2, %xmm3
	movdqa	%xmm2, %xmm8
	punpcklwd	%xmm3, %xmm8
	punpckhwd	%xmm3, %xmm2
	movdqa	%xmm0, %xmm3
	paddd	%xmm8, %xmm1
	paddd	%xmm2, %xmm1
	movdqa	%xmm4, %xmm2
	pcmpgtw	%xmm0, %xmm2
	punpcklwd	%xmm2, %xmm3
	punpckhwd	%xmm2, %xmm0
	paddd	%xmm3, %xmm1
	paddd	%xmm0, %xmm1
	cmpq	%rax, %r15
	jne	.L5
	movdqa	%xmm1, %xmm0
	movl	%ecx, %edx
	psrldq	$8, %xmm0
	andl	$-16, %edx
	paddd	%xmm0, %xmm1
	movdqa	%xmm1, %xmm0
	psrldq	$4, %xmm0
	paddd	%xmm0, %xmm1
	movd	%xmm1, %eax
	testb	$15, %cl
	je	.L6
.L4:
	movslq	%edx, %rsi
	cmpb	$82, 0(%rbp,%rsi)
	sete	%sil
	movzbl	%sil, %esi
	addl	%esi, %eax
	leal	1(%rdx), %esi
	cmpl	%esi, %ecx
	jle	.L6
	movslq	%esi, %rsi
	cmpb	$82, 0(%rbp,%rsi)
	sete	%sil
	movzbl	%sil, %esi
	addl	%esi, %eax
	leal	2(%rdx), %esi
	cmpl	%esi, %ecx
	jle	.L6
	movslq	%esi, %rsi
	cmpb	$82, 0(%rbp,%rsi)
	je	.L42
.L9:
	leal	3(%rdx), %esi
	cmpl	%esi, %ecx
	jle	.L6
	movslq	%esi, %rsi
	cmpb	$82, 0(%rbp,%rsi)
	je	.L43
.L10:
	leal	4(%rdx), %esi
	cmpl	%esi, %ecx
	jle	.L6
	movslq	%esi, %rsi
	cmpb	$82, 0(%rbp,%rsi)
	je	.L44
.L11:
	leal	5(%rdx), %esi
	cmpl	%esi, %ecx
	jle	.L6
	movslq	%esi, %rsi
	cmpb	$82, 0(%rbp,%rsi)
	jne	.L12
	addl	$1, %eax
.L12:
	leal	6(%rdx), %esi
	cmpl	%esi, %ecx
	jle	.L6
	movslq	%esi, %rsi
	cmpb	$82, 0(%rbp,%rsi)
	jne	.L13
	addl	$1, %eax
.L13:
	leal	7(%rdx), %esi
	cmpl	%esi, %ecx
	jle	.L6
	movslq	%esi, %rsi
	cmpb	$82, 0(%rbp,%rsi)
	jne	.L14
	addl	$1, %eax
.L14:
	leal	8(%rdx), %esi
	cmpl	%esi, %ecx
	jle	.L6
	movslq	%esi, %rsi
	cmpb	$82, 0(%rbp,%rsi)
	jne	.L15
	addl	$1, %eax
.L15:
	leal	9(%rdx), %esi
	cmpl	%esi, %ecx
	jle	.L6
	movslq	%esi, %rsi
	cmpb	$82, 0(%rbp,%rsi)
	je	.L45
.L16:
	leal	10(%rdx), %esi
	cmpl	%esi, %ecx
	jle	.L6
	movslq	%esi, %rsi
	cmpb	$82, 0(%rbp,%rsi)
	je	.L46
.L17:
	leal	11(%rdx), %esi
	cmpl	%esi, %ecx
	jle	.L6
	movslq	%esi, %rsi
	cmpb	$82, 0(%rbp,%rsi)
	je	.L47
.L18:
	leal	12(%rdx), %esi
	cmpl	%esi, %ecx
	jle	.L6
	movslq	%esi, %rsi
	cmpb	$82, 0(%rbp,%rsi)
	je	.L48
.L19:
	leal	13(%rdx), %esi
	cmpl	%esi, %ecx
	jle	.L6
	movslq	%esi, %rsi
	cmpb	$82, 0(%rbp,%rsi)
	jne	.L20
	addl	$1, %eax
.L20:
	addl	$14, %edx
	cmpl	%edx, %ecx
	jle	.L6
	movslq	%edx, %rdx
	cmpb	$82, 0(%rbp,%rdx)
	jne	.L6
	addl	$1, %eax
	.p2align 4,,10
	.p2align 3
.L6:
	movl	%eax, (%r12)
	movl	%ecx, %r8d
	xorl	%edx, %edx
	xorl	%esi, %esi
	jmp	.L25
	.p2align 4,,10
	.p2align 3
.L23:
	subl	$1, %eax
.L24:
	cmpl	%esi, %eax
	movl	%esi, %edi
	cmovge	%eax, %edi
	movl	%edi, 4(%r12,%rdx,4)
	addq	$1, %rdx
	cmpq	%r8, %rdx
	je	.L49
.L25:
	cmpb	$87, 0(%rbp,%rdx)
	jne	.L23
	addl	$1, %esi
	jmp	.L24
	.p2align 4,,10
	.p2align 3
.L49:
	leal	1(%rcx), %esi
	cmpl	$2, %ecx
	jle	.L33
	movl	%esi, %edx
	movdqa	.LC0(%rip), %xmm0
	movq	%r12, %rax
	shrl	$2, %edx
	subl	$1, %edx
	salq	$4, %rdx
	leaq	16(%r12,%rdx), %rdx
	.p2align 4,,10
	.p2align 3
.L27:
	movdqu	(%rax), %xmm1
	movdqu	(%rax), %xmm5
	addq	$16, %rax
	pcmpgtd	%xmm0, %xmm1
	pand	%xmm1, %xmm0
	pandn	%xmm5, %xmm1
	por	%xmm1, %xmm0
	cmpq	%rax, %rdx
	jne	.L27
	movdqa	%xmm0, %xmm2
	movl	%esi, %ebx
	psrldq	$8, %xmm2
	andl	$-4, %ebx
	andl	$3, %esi
	movdqa	%xmm2, %xmm1
	pcmpgtd	%xmm0, %xmm1
	pand	%xmm1, %xmm0
	pandn	%xmm2, %xmm1
	por	%xmm0, %xmm1
	movdqa	%xmm1, %xmm2
	psrldq	$4, %xmm2
	movdqa	%xmm2, %xmm0
	pcmpgtd	%xmm1, %xmm0
	pand	%xmm0, %xmm1
	pandn	%xmm2, %xmm0
	por	%xmm1, %xmm0
	movd	%xmm0, %edx
	je	.L29
.L26:
	movslq	%ebx, %rax
	leaq	0(,%rax,4), %rsi
	movl	(%r12,%rax,4), %eax
	cmpl	%eax, %edx
	cmovg	%eax, %edx
	leal	1(%rbx), %eax
	cmpl	%ecx, %eax
	jg	.L29
	movl	4(%r12,%rsi), %eax
	cmpl	%eax, %edx
	cmovg	%eax, %edx
	addl	$2, %ebx
	cmpl	%ecx, %ebx
	jg	.L29
	movl	8(%r12,%rsi), %eax
	cmpl	%eax, %edx
	cmovg	%eax, %edx
.L29:
	movq	%r13, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	%rbp, %rdi
	call	free@PLT
	movq	%r12, %rdi
	call	free@PLT
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L50
	addq	$24, %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
.L42:
	.cfi_restore_state
	addl	$1, %eax
	jmp	.L9
.L43:
	addl	$1, %eax
	jmp	.L10
.L44:
	addl	$1, %eax
	jmp	.L11
.L45:
	addl	$1, %eax
	jmp	.L16
.L46:
	addl	$1, %eax
	jmp	.L17
.L47:
	addl	$1, %eax
	jmp	.L18
.L48:
	addl	$1, %eax
	jmp	.L19
.L31:
	movl	%ecx, %ebx
.L2:
	movl	$0, (%r12)
	testl	%ebx, %ebx
	je	.L34
	movl	$2147483647, %edx
	jmp	.L29
.L32:
	xorl	%edx, %edx
	xorl	%eax, %eax
	jmp	.L4
.L33:
	xorl	%ebx, %ebx
	movl	$2147483647, %edx
	jmp	.L26
.L34:
	xorl	%ecx, %ecx
	movl	$2147483647, %edx
	jmp	.L26
.L50:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE51:
	.size	main, .-main
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC0:
	.long	2147483647
	.long	2147483647
	.long	2147483647
	.long	2147483647
	.align 16
.LC3:
	.byte	82
	.byte	82
	.byte	82
	.byte	82
	.byte	82
	.byte	82
	.byte	82
	.byte	82
	.byte	82
	.byte	82
	.byte	82
	.byte	82
	.byte	82
	.byte	82
	.byte	82
	.byte	82
	.align 16
.LC4:
	.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
.LC1:
	.string	"%d"
.LC2:
	.string	" %c"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB51:
	.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	.LC1(%rip), %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movq	%r13, %rdi
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	leaq	4(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movslq	4(%rsp), %r12
	movq	%r12, %rdi
	movq	%r12, %rbx
	call	malloc@PLT
	leaq	1(,%r12,4), %rdi
	movq	%rax, %rbp
	call	malloc@PLT
	movq	%rax, %r12
	testl	%ebx, %ebx
	jle	.L2
	xorl	%ebx, %ebx
	leaq	.LC2(%rip), %r14
	.p2align 4,,10
	.p2align 3
.L3:
	leaq	(%rbx,%rbp), %rsi
	movq	%r14, %rdi
	xorl	%eax, %eax
	addq	$1, %rbx
	call	__isoc99_scanf@PLT
	movl	4(%rsp), %ecx
	movq	%rbp, %r15
	cmpl	%ebx, %ecx
	jg	.L3
	testl	%ecx, %ecx
	jle	.L31
	leal	-1(%rcx), %eax
	cmpl	$14, %eax
	jbe	.L32
	pxor	%xmm1, %xmm1
	pxor	%xmm5, %xmm5
	pxor	%xmm4, %xmm4
	movl	%ecx, %eax
	shrl	$4, %eax
	movdqa	.LC3(%rip), %xmm7
	movdqa	.LC4(%rip), %xmm6
	salq	$4, %rax
	addq	%rbp, %rax
	.p2align 4,,10
	.p2align 3
.L5:
	movdqu	(%r15), %xmm0
	movdqa	%xmm5, %xmm3
	addq	$16, %r15
	pcmpeqb	%xmm7, %xmm0
	pand	%xmm6, %xmm0
	pcmpgtb	%xmm0, %xmm3
	movdqa	%xmm0, %xmm2
	punpcklbw	%xmm3, %xmm2
	punpckhbw	%xmm3, %xmm0
	movdqa	%xmm4, %xmm3
	pcmpgtw	%xmm2, %xmm3
	movdqa	%xmm2, %xmm8
	punpcklwd	%xmm3, %xmm8
	punpckhwd	%xmm3, %xmm2
	movdqa	%xmm0, %xmm3
	paddd	%xmm8, %xmm1
	paddd	%xmm2, %xmm1
	movdqa	%xmm4, %xmm2
	pcmpgtw	%xmm0, %xmm2
	punpcklwd	%xmm2, %xmm3
	punpckhwd	%xmm2, %xmm0
	paddd	%xmm3, %xmm1
	paddd	%xmm0, %xmm1
	cmpq	%rax, %r15
	jne	.L5
	movdqa	%xmm1, %xmm0
	movl	%ecx, %edx
	psrldq	$8, %xmm0
	andl	$-16, %edx
	paddd	%xmm0, %xmm1
	movdqa	%xmm1, %xmm0
	psrldq	$4, %xmm0
	paddd	%xmm0, %xmm1
	movd	%xmm1, %eax
	testb	$15, %cl
	je	.L6
.L4:
	movslq	%edx, %rsi
	cmpb	$82, 0(%rbp,%rsi)
	sete	%sil
	movzbl	%sil, %esi
	addl	%esi, %eax
	leal	1(%rdx), %esi
	cmpl	%esi, %ecx
	jle	.L6
	movslq	%esi, %rsi
	cmpb	$82, 0(%rbp,%rsi)
	sete	%sil
	movzbl	%sil, %esi
	addl	%esi, %eax
	leal	2(%rdx), %esi
	cmpl	%esi, %ecx
	jle	.L6
	movslq	%esi, %rsi
	cmpb	$82, 0(%rbp,%rsi)
	je	.L42
.L9:
	leal	3(%rdx), %esi
	cmpl	%esi, %ecx
	jle	.L6
	movslq	%esi, %rsi
	cmpb	$82, 0(%rbp,%rsi)
	je	.L43
.L10:
	leal	4(%rdx), %esi
	cmpl	%esi, %ecx
	jle	.L6
	movslq	%esi, %rsi
	cmpb	$82, 0(%rbp,%rsi)
	je	.L44
.L11:
	leal	5(%rdx), %esi
	cmpl	%esi, %ecx
	jle	.L6
	movslq	%esi, %rsi
	cmpb	$82, 0(%rbp,%rsi)
	jne	.L12
	addl	$1, %eax
.L12:
	leal	6(%rdx), %esi
	cmpl	%esi, %ecx
	jle	.L6
	movslq	%esi, %rsi
	cmpb	$82, 0(%rbp,%rsi)
	jne	.L13
	addl	$1, %eax
.L13:
	leal	7(%rdx), %esi
	cmpl	%esi, %ecx
	jle	.L6
	movslq	%esi, %rsi
	cmpb	$82, 0(%rbp,%rsi)
	jne	.L14
	addl	$1, %eax
.L14:
	leal	8(%rdx), %esi
	cmpl	%esi, %ecx
	jle	.L6
	movslq	%esi, %rsi
	cmpb	$82, 0(%rbp,%rsi)
	jne	.L15
	addl	$1, %eax
.L15:
	leal	9(%rdx), %esi
	cmpl	%esi, %ecx
	jle	.L6
	movslq	%esi, %rsi
	cmpb	$82, 0(%rbp,%rsi)
	je	.L45
.L16:
	leal	10(%rdx), %esi
	cmpl	%esi, %ecx
	jle	.L6
	movslq	%esi, %rsi
	cmpb	$82, 0(%rbp,%rsi)
	je	.L46
.L17:
	leal	11(%rdx), %esi
	cmpl	%esi, %ecx
	jle	.L6
	movslq	%esi, %rsi
	cmpb	$82, 0(%rbp,%rsi)
	je	.L47
.L18:
	leal	12(%rdx), %esi
	cmpl	%esi, %ecx
	jle	.L6
	movslq	%esi, %rsi
	cmpb	$82, 0(%rbp,%rsi)
	je	.L48
.L19:
	leal	13(%rdx), %esi
	cmpl	%esi, %ecx
	jle	.L6
	movslq	%esi, %rsi
	cmpb	$82, 0(%rbp,%rsi)
	jne	.L20
	addl	$1, %eax
.L20:
	addl	$14, %edx
	cmpl	%edx, %ecx
	jle	.L6
	movslq	%edx, %rdx
	cmpb	$82, 0(%rbp,%rdx)
	jne	.L6
	addl	$1, %eax
	.p2align 4,,10
	.p2align 3
.L6:
	movl	%eax, (%r12)
	movl	%ecx, %r8d
	xorl	%edx, %edx
	xorl	%esi, %esi
	jmp	.L25
	.p2align 4,,10
	.p2align 3
.L23:
	subl	$1, %eax
.L24:
	cmpl	%esi, %eax
	movl	%esi, %edi
	cmovge	%eax, %edi
	movl	%edi, 4(%r12,%rdx,4)
	addq	$1, %rdx
	cmpq	%r8, %rdx
	je	.L49
.L25:
	cmpb	$87, 0(%rbp,%rdx)
	jne	.L23
	addl	$1, %esi
	jmp	.L24
	.p2align 4,,10
	.p2align 3
.L49:
	leal	1(%rcx), %esi
	cmpl	$2, %ecx
	jle	.L33
	movl	%esi, %edx
	movdqa	.LC0(%rip), %xmm0
	movq	%r12, %rax
	shrl	$2, %edx
	subl	$1, %edx
	salq	$4, %rdx
	leaq	16(%r12,%rdx), %rdx
	.p2align 4,,10
	.p2align 3
.L27:
	movdqu	(%rax), %xmm1
	movdqu	(%rax), %xmm5
	addq	$16, %rax
	pcmpgtd	%xmm0, %xmm1
	pand	%xmm1, %xmm0
	pandn	%xmm5, %xmm1
	por	%xmm1, %xmm0
	cmpq	%rax, %rdx
	jne	.L27
	movdqa	%xmm0, %xmm2
	movl	%esi, %ebx
	psrldq	$8, %xmm2
	andl	$-4, %ebx
	andl	$3, %esi
	movdqa	%xmm2, %xmm1
	pcmpgtd	%xmm0, %xmm1
	pand	%xmm1, %xmm0
	pandn	%xmm2, %xmm1
	por	%xmm0, %xmm1
	movdqa	%xmm1, %xmm2
	psrldq	$4, %xmm2
	movdqa	%xmm2, %xmm0
	pcmpgtd	%xmm1, %xmm0
	pand	%xmm0, %xmm1
	pandn	%xmm2, %xmm0
	por	%xmm1, %xmm0
	movd	%xmm0, %edx
	je	.L29
.L26:
	movslq	%ebx, %rax
	leaq	0(,%rax,4), %rsi
	movl	(%r12,%rax,4), %eax
	cmpl	%eax, %edx
	cmovg	%eax, %edx
	leal	1(%rbx), %eax
	cmpl	%ecx, %eax
	jg	.L29
	movl	4(%r12,%rsi), %eax
	cmpl	%eax, %edx
	cmovg	%eax, %edx
	addl	$2, %ebx
	cmpl	%ecx, %ebx
	jg	.L29
	movl	8(%r12,%rsi), %eax
	cmpl	%eax, %edx
	cmovg	%eax, %edx
.L29:
	movq	%r13, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	%rbp, %rdi
	call	free@PLT
	movq	%r12, %rdi
	call	free@PLT
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L50
	addq	$24, %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
.L42:
	.cfi_restore_state
	addl	$1, %eax
	jmp	.L9
.L43:
	addl	$1, %eax
	jmp	.L10
.L44:
	addl	$1, %eax
	jmp	.L11
.L45:
	addl	$1, %eax
	jmp	.L16
.L46:
	addl	$1, %eax
	jmp	.L17
.L47:
	addl	$1, %eax
	jmp	.L18
.L48:
	addl	$1, %eax
	jmp	.L19
.L31:
	movl	%ecx, %ebx
.L2:
	movl	$0, (%r12)
	testl	%ebx, %ebx
	je	.L34
	movl	$2147483647, %edx
	jmp	.L29
.L32:
	xorl	%edx, %edx
	xorl	%eax, %eax
	jmp	.L4
.L33:
	xorl	%ebx, %ebx
	movl	$2147483647, %edx
	jmp	.L26
.L34:
	xorl	%ecx, %ecx
	movl	$2147483647, %edx
	jmp	.L26
.L50:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE51:
	.size	main, .-main
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC0:
	.long	2147483647
	.long	2147483647
	.long	2147483647
	.long	2147483647
	.align 16
.LC3:
	.byte	82
	.byte	82
	.byte	82
	.byte	82
	.byte	82
	.byte	82
	.byte	82
	.byte	82
	.byte	82
	.byte	82
	.byte	82
	.byte	82
	.byte	82
	.byte	82
	.byte	82
	.byte	82
	.align 16
.LC4:
	.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 <math.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
int main(void)
{
	int n;//石の個数
	char *c;//石の色 n個
	int lw=0;//左にあるWの数
	int rr=0;//右にあるRの数
	int *aaa;//しきいi(i=0^n+1)の時の操作回数 n+1個
	int min=INT_MAX;
	scanf("%d",&n);
	c=(char *)malloc(sizeof(char)*n);
	aaa=(int *)malloc(sizeof(int)*n+1);
	int i;
	for(i=0;i<n;i++)
	{
		scanf(" %c",&c[i]);//改行を読み込まない
	}
	for(i=0;i<n;i++)
	{
		if(c[i]=='R')
		{
			rr++;
		}
	}
	if(lw<rr)
	{
		aaa[0]=rr;
	}
	else
	{
		aaa[0]=lw;
	}
	for(i=1;i<n+1;i++)
	{
		if(c[i-1]=='W')
		{
			lw++;
		}
		else
		{
			rr--;
		}
		
		if(lw<rr)
		{
			aaa[i]=rr;
		}
		else
		{
			aaa[i]=lw;
		}
	}
	for(i=0;i<n+1;i++)
	{
		if(aaa[i]<min)
		{
			min=aaa[i];
		}
	}
	printf("%d",min);
	

	
	free(c);
	c=NULL;
	free(aaa);
	aaa=NULL;
	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 <math.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
int main(void)
{
	int n;//石の個数
	char *c;//石の色 n個
	int lw=0;//左にあるWの数
	int rr=0;//右にあるRの数
	int *aaa;//しきいi(i=0^n+1)の時の操作回数 n+1個
	int min=INT_MAX;
	scanf("%d",&n);
	c=(char *)malloc(sizeof(char)*n);
	aaa=(int *)malloc(sizeof(int)*n+1);
	int i;
	for(i=0;i<n;i++)
	{
		scanf(" %c",&c[i]);//改行を読み込まない
	}
	for(i=0;i<n;i++)
	{
		if(c[i]=='R')
		{
			rr++;
		}
	}
	if(lw<rr)
	{
		aaa[0]=rr;
	}
	else
	{
		aaa[0]=lw;
	}
	for(i=1;i<n+1;i++)
	{
		if(c[i-1]=='W')
		{
			lw++;
		}
		else
		{
			rr--;
		}
		
		if(lw<rr)
		{
			aaa[i]=rr;
		}
		else
		{
			aaa[i]=lw;
		}
	}
	for(i=0;i<n+1;i++)
	{
		if(aaa[i]<min)
		{
			min=aaa[i];
		}
	}
	printf("%d",min);
	

	
	free(c);
	c=NULL;
	free(aaa);
	aaa=NULL;
	return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	" %c"
	.text
	.globl	main
	.type	main, @function
main:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$48, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -40(%rbp)
	movl	$0, -36(%rbp)
	movl	$2147483647, -32(%rbp)
	leaq	-44(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-44(%rbp), %eax
	cltq
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, -24(%rbp)
	movl	-44(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	$1, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, -16(%rbp)
	movl	$0, -28(%rbp)
	jmp	.L2
.L3:
	movl	-28(%rbp), %eax
	movslq	%eax, %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -28(%rbp)
.L2:
	movl	-44(%rbp), %eax
	cmpl	%eax, -28(%rbp)
	jl	.L3
	movl	$0, -28(%rbp)
	jmp	.L4
.L6:
	movl	-28(%rbp), %eax
	movslq	%eax, %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	$82, %al
	jne	.L5
	addl	$1, -36(%rbp)
.L5:
	addl	$1, -28(%rbp)
.L4:
	movl	-44(%rbp), %eax
	cmpl	%eax, -28(%rbp)
	jl	.L6
	movl	-40(%rbp), %eax
	cmpl	-36(%rbp), %eax
	jge	.L7
	movq	-16(%rbp), %rax
	movl	-36(%rbp), %edx
	movl	%edx, (%rax)
	jmp	.L8
.L7:
	movq	-16(%rbp), %rax
	movl	-40(%rbp), %edx
	movl	%edx, (%rax)
.L8:
	movl	$1, -28(%rbp)
	jmp	.L9
.L14:
	movl	-28(%rbp), %eax
	cltq
	leaq	-1(%rax), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	$87, %al
	jne	.L10
	addl	$1, -40(%rbp)
	jmp	.L11
.L10:
	subl	$1, -36(%rbp)
.L11:
	movl	-40(%rbp), %eax
	cmpl	-36(%rbp), %eax
	jge	.L12
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rax, %rdx
	movl	-36(%rbp), %eax
	movl	%eax, (%rdx)
	jmp	.L13
.L12:
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rax, %rdx
	movl	-40(%rbp), %eax
	movl	%eax, (%rdx)
.L13:
	addl	$1, -28(%rbp)
.L9:
	movl	-44(%rbp), %eax
	cmpl	%eax, -28(%rbp)
	jle	.L14
	movl	$0, -28(%rbp)
	jmp	.L15
.L17:
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cmpl	%eax, -32(%rbp)
	jle	.L16
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, -32(%rbp)
.L16:
	addl	$1, -28(%rbp)
.L15:
	movl	-44(%rbp), %eax
	cmpl	%eax, -28(%rbp)
	jle	.L17
	movl	-32(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movq	-24(%rbp), %rax
	movq	%rax, %rdi
	call	free@PLT
	movq	$0, -24(%rbp)
	movq	-16(%rbp), %rax
	movq	%rax, %rdi
	call	free@PLT
	movq	$0, -16(%rbp)
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L19
	call	__stack_chk_fail@PLT
.L19:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.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	" %c"
	.text
	.globl	main
	.type	main, @function
main:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$48, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -40(%rbp)
	movl	$0, -36(%rbp)
	movl	$2147483647, -32(%rbp)
	leaq	-44(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-44(%rbp), %eax
	cltq
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, -24(%rbp)
	movl	-44(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	$1, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, -16(%rbp)
	movl	$0, -28(%rbp)
	jmp	.L2
.L3:
	movl	-28(%rbp), %eax
	movslq	%eax, %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -28(%rbp)
.L2:
	movl	-44(%rbp), %eax
	cmpl	%eax, -28(%rbp)
	jl	.L3
	movl	$0, -28(%rbp)
	jmp	.L4
.L6:
	movl	-28(%rbp), %eax
	movslq	%eax, %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	$82, %al
	jne	.L5
	addl	$1, -36(%rbp)
.L5:
	addl	$1, -28(%rbp)
.L4:
	movl	-44(%rbp), %eax
	cmpl	%eax, -28(%rbp)
	jl	.L6
	movl	-40(%rbp), %eax
	cmpl	-36(%rbp), %eax
	jge	.L7
	movq	-16(%rbp), %rax
	movl	-36(%rbp), %edx
	movl	%edx, (%rax)
	jmp	.L8
.L7:
	movq	-16(%rbp), %rax
	movl	-40(%rbp), %edx
	movl	%edx, (%rax)
.L8:
	movl	$1, -28(%rbp)
	jmp	.L9
.L14:
	movl	-28(%rbp), %eax
	cltq
	leaq	-1(%rax), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	$87, %al
	jne	.L10
	addl	$1, -40(%rbp)
	jmp	.L11
.L10:
	subl	$1, -36(%rbp)
.L11:
	movl	-40(%rbp), %eax
	cmpl	-36(%rbp), %eax
	jge	.L12
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rax, %rdx
	movl	-36(%rbp), %eax
	movl	%eax, (%rdx)
	jmp	.L13
.L12:
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rax, %rdx
	movl	-40(%rbp), %eax
	movl	%eax, (%rdx)
.L13:
	addl	$1, -28(%rbp)
.L9:
	movl	-44(%rbp), %eax
	cmpl	%eax, -28(%rbp)
	jle	.L14
	movl	$0, -28(%rbp)
	jmp	.L15
.L17:
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cmpl	%eax, -32(%rbp)
	jle	.L16
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, -32(%rbp)
.L16:
	addl	$1, -28(%rbp)
.L15:
	movl	-44(%rbp), %eax
	cmpl	%eax, -28(%rbp)
	jle	.L17
	movl	-32(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movq	-24(%rbp), %rax
	movq	%rax, %rdi
	call	free@PLT
	movq	$0, -24(%rbp)
	movq	-16(%rbp), %rax
	movq	%rax, %rdi
	call	free@PLT
	movq	$0, -16(%rbp)
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L19
	call	__stack_chk_fail@PLT
.L19:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.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:
