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(void){

        int r=0,g=0,b=0;
        int ng = 0;
        long n;

        scanf("%ld",&n);
        char s[n];
        scanf("%s",&s);

        for(int i=0;i<n;i++){           //1つ目の条件を満たしているr*g*bを求められるようにカウントしとく
                if(s[i]=='R'){
                        r++;
                }else if(s[i]=='G'){
                        g++;
                }else{
                        b++;
                }   
        }   

        int k;

        for(int i=0;i<n;i++){                   //i固定
                for(int j=i+1;j<n;j++){         //j固定
                        k = j+(j-i);            //ngのものを計算するためにkをngの条件に設定
                        if(k>=n){               //kがnを超えるものは初めに取り除く
                                continue;
                        }   
                        if((s[i] != s[j]) && (s[j] != s[k]) &&(s[k] != s[i])){//二つ目の条件違反してるけど1つ>目の条件満たしているもの
                                ng++;
                        }   
                }   
        }   

printf("%ld\n",r*g*b-ng);
}

```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%ld"
.LC1:
	.string	"%s"
.LC2:
	.string	"%ld\n"
	.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	$72, %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, -112(%rbp)
	movl	$0, -108(%rbp)
	movl	$0, -104(%rbp)
	movl	$0, -100(%rbp)
	leaq	-80(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	-80(%rbp), %rax
	leaq	-1(%rax), %rdx
	movq	%rdx, -72(%rbp)
	movq	%rax, %rdx
	movq	%rdx, %r14
	movl	$0, %r15d
	movq	%rax, %rdx
	movq	%rdx, %r12
	movl	$0, %r13d
	movq	%rax, %rdx
	movl	$16, %eax
	subq	$1, %rax
	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, -96(%rbp)
	jmp	.L5
.L9:
	movq	-64(%rbp), %rdx
	movl	-96(%rbp), %eax
	cltq
	movzbl	(%rdx,%rax), %eax
	cmpb	$82, %al
	jne	.L6
	addl	$1, -112(%rbp)
	jmp	.L7
.L6:
	movq	-64(%rbp), %rdx
	movl	-96(%rbp), %eax
	cltq
	movzbl	(%rdx,%rax), %eax
	cmpb	$71, %al
	jne	.L8
	addl	$1, -108(%rbp)
	jmp	.L7
.L8:
	addl	$1, -104(%rbp)
.L7:
	addl	$1, -96(%rbp)
.L5:
	movl	-96(%rbp), %eax
	movslq	%eax, %rdx
	movq	-80(%rbp), %rax
	cmpq	%rax, %rdx
	jl	.L9
	movl	$0, -92(%rbp)
	jmp	.L10
.L15:
	movl	-92(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -88(%rbp)
	jmp	.L11
.L14:
	movl	-88(%rbp), %eax
	subl	-92(%rbp), %eax
	movl	%eax, %edx
	movl	-88(%rbp), %eax
	addl	%edx, %eax
	movl	%eax, -84(%rbp)
	movl	-84(%rbp), %eax
	movslq	%eax, %rdx
	movq	-80(%rbp), %rax
	cmpq	%rax, %rdx
	jge	.L18
	movq	-64(%rbp), %rdx
	movl	-92(%rbp), %eax
	cltq
	movzbl	(%rdx,%rax), %ecx
	movq	-64(%rbp), %rdx
	movl	-88(%rbp), %eax
	cltq
	movzbl	(%rdx,%rax), %eax
	cmpb	%al, %cl
	je	.L13
	movq	-64(%rbp), %rdx
	movl	-88(%rbp), %eax
	cltq
	movzbl	(%rdx,%rax), %ecx
	movq	-64(%rbp), %rdx
	movl	-84(%rbp), %eax
	cltq
	movzbl	(%rdx,%rax), %eax
	cmpb	%al, %cl
	je	.L13
	movq	-64(%rbp), %rdx
	movl	-84(%rbp), %eax
	cltq
	movzbl	(%rdx,%rax), %ecx
	movq	-64(%rbp), %rdx
	movl	-92(%rbp), %eax
	cltq
	movzbl	(%rdx,%rax), %eax
	cmpb	%al, %cl
	je	.L13
	addl	$1, -100(%rbp)
	jmp	.L13
.L18:
	nop
.L13:
	addl	$1, -88(%rbp)
.L11:
	movl	-88(%rbp), %eax
	movslq	%eax, %rdx
	movq	-80(%rbp), %rax
	cmpq	%rax, %rdx
	jl	.L14
	addl	$1, -92(%rbp)
.L10:
	movl	-92(%rbp), %eax
	movslq	%eax, %rdx
	movq	-80(%rbp), %rax
	cmpq	%rax, %rdx
	jl	.L15
	movl	-112(%rbp), %eax
	imull	-108(%rbp), %eax
	imull	-104(%rbp), %eax
	subl	-100(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movq	%rbx, %rsp
	movl	$0, %eax
	movq	-56(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L17
	call	__stack_chk_fail@PLT
.L17:
	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	"%ld"
.LC1:
	.string	"%s"
.LC5:
	.string	"%ld\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	leaq	.LC0(%rip), %rdi
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%r15
	pushq	%r14
	leaq	-64(%rbp), %rsi
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	subq	$40, %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
	call	__isoc99_scanf@PLT
	movq	-64(%rbp), %rax
	movq	%rsp, %rcx
	addq	$15, %rax
	movq	%rax, %rdx
	andq	$-4096, %rax
	subq	%rax, %rcx
	andq	$-16, %rdx
	cmpq	%rcx, %rsp
	je	.L3
.L42:
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	cmpq	%rcx, %rsp
	jne	.L42
.L3:
	andl	$4095, %edx
	subq	%rdx, %rsp
	testq	%rdx, %rdx
	jne	.L43
.L4:
	movq	%rsp, %rsi
	leaq	.LC1(%rip), %rdi
	xorl	%eax, %eax
	movq	%rsp, %rbx
	call	__isoc99_scanf@PLT
	movq	-64(%rbp), %rcx
	testq	%rcx, %rcx
	jle	.L21
	leaq	-1(%rcx), %rax
	movq	%rax, %r8
	cmpq	$14, %rax
	jbe	.L22
	movq	%rcx, %rdx
	pxor	%xmm5, %xmm5
	pcmpeqd	%xmm9, %xmm9
	movq	%rsp, %rax
	andq	$-16, %rdx
	movdqa	%xmm5, %xmm12
	movdqa	.LC2(%rip), %xmm11
	movdqa	.LC3(%rip), %xmm10
	movdqa	%xmm5, %xmm3
	pxor	%xmm7, %xmm7
	pxor	%xmm6, %xmm6
	addq	%rsp, %rdx
	movdqa	.LC4(%rip), %xmm8
	.p2align 4,,10
	.p2align 3
.L7:
	movdqu	(%rax), %xmm1
	movdqa	%xmm7, %xmm4
	movdqu	(%rax), %xmm0
	addq	$16, %rax
	movdqa	%xmm6, %xmm14
	pcmpeqb	%xmm11, %xmm1
	pcmpeqb	%xmm10, %xmm0
	movdqa	%xmm1, %xmm2
	pand	%xmm8, %xmm1
	pcmpgtb	%xmm1, %xmm4
	movdqa	%xmm1, %xmm13
	por	%xmm0, %xmm2
	pand	%xmm8, %xmm0
	pxor	%xmm9, %xmm2
	punpcklbw	%xmm4, %xmm13
	punpckhbw	%xmm4, %xmm1
	pcmpgtw	%xmm13, %xmm14
	movdqa	%xmm13, %xmm4
	punpcklwd	%xmm14, %xmm4
	punpckhwd	%xmm14, %xmm13
	movdqa	%xmm6, %xmm14
	paddd	%xmm4, %xmm3
	movdqa	%xmm6, %xmm4
	pcmpgtw	%xmm1, %xmm4
	paddd	%xmm13, %xmm3
	movdqa	%xmm1, %xmm13
	punpcklwd	%xmm4, %xmm13
	punpckhwd	%xmm4, %xmm1
	paddd	%xmm13, %xmm3
	movdqa	%xmm0, %xmm13
	paddd	%xmm1, %xmm3
	movdqa	%xmm7, %xmm1
	pcmpgtb	%xmm0, %xmm1
	punpcklbw	%xmm1, %xmm13
	punpckhbw	%xmm1, %xmm0
	movdqa	%xmm12, %xmm1
	pcmpgtw	%xmm13, %xmm14
	movdqa	%xmm13, %xmm4
	movdqa	%xmm0, %xmm12
	punpcklwd	%xmm14, %xmm4
	punpckhwd	%xmm14, %xmm13
	paddd	%xmm4, %xmm1
	movdqa	%xmm6, %xmm4
	pcmpgtw	%xmm0, %xmm4
	paddd	%xmm13, %xmm1
	punpcklwd	%xmm4, %xmm12
	punpckhwd	%xmm4, %xmm0
	paddd	%xmm12, %xmm1
	paddd	%xmm0, %xmm1
	movdqa	%xmm2, %xmm0
	movdqa	%xmm1, %xmm12
	movdqa	%xmm7, %xmm1
	pcmpgtb	%xmm2, %xmm1
	punpcklbw	%xmm1, %xmm0
	punpckhbw	%xmm1, %xmm2
	movdqa	%xmm6, %xmm1
	pcmpgtw	%xmm0, %xmm1
	movdqa	%xmm0, %xmm4
	punpcklwd	%xmm1, %xmm4
	punpckhwd	%xmm1, %xmm0
	movdqa	%xmm2, %xmm1
	psubd	%xmm4, %xmm5
	psubd	%xmm0, %xmm5
	movdqa	%xmm6, %xmm0
	pcmpgtw	%xmm2, %xmm0
	punpcklwd	%xmm0, %xmm1
	punpckhwd	%xmm0, %xmm2
	psubd	%xmm1, %xmm5
	psubd	%xmm2, %xmm5
	cmpq	%rax, %rdx
	jne	.L7
	movdqa	%xmm5, %xmm0
	movdqa	%xmm12, %xmm1
	movq	%rcx, %rdx
	psrldq	$8, %xmm0
	andq	$-16, %rdx
	paddd	%xmm0, %xmm5
	movslq	%edx, %rax
	movdqa	%xmm5, %xmm0
	psrldq	$4, %xmm0
	paddd	%xmm0, %xmm5
	movdqa	%xmm12, %xmm0
	psrldq	$8, %xmm0
	movd	%xmm5, %r11d
	paddd	%xmm0, %xmm1
	movdqa	%xmm1, %xmm0
	psrldq	$4, %xmm0
	paddd	%xmm0, %xmm1
	movdqa	%xmm3, %xmm0
	psrldq	$8, %xmm0
	movd	%xmm1, -72(%rbp)
	paddd	%xmm0, %xmm3
	movdqa	%xmm3, %xmm0
	psrldq	$4, %xmm0
	paddd	%xmm0, %xmm3
	movd	%xmm3, -68(%rbp)
	cmpq	%rdx, %rcx
	je	.L8
.L6:
	movl	-68(%rbp), %esi
	movl	-72(%rbp), %edi
	jmp	.L11
	.p2align 4,,10
	.p2align 3
.L35:
	cmpb	$71, %dl
	je	.L44
	addl	$1, %r11d
.L13:
	addq	$1, %rax
	cmpq	%rax, %rcx
	jle	.L45
.L11:
	movzbl	(%rbx,%rax), %edx
	cmpb	$82, %dl
	jne	.L35
	addq	$1, %rax
	addl	$1, %esi
	cmpq	%rax, %rcx
	jg	.L11
.L45:
	movl	%esi, -68(%rbp)
	movl	%edi, -72(%rbp)
	cmpq	$1, %rcx
	jle	.L40
.L8:
	movl	%r11d, -76(%rbp)
	movl	$2, %r13d
	xorl	%r9d, %r9d
	xorl	%r12d, %r12d
	movq	$-2, %r15
	movl	$1, %r14d
	movq	%r8, %r11
	.p2align 4,,10
	.p2align 3
.L18:
	leaq	(%r9,%r15), %r10
	movq	%r13, %rdx
	movq	%r14, %rax
	addq	%r13, %r10
	addq	%rbx, %r10
	.p2align 4,,10
	.p2align 3
.L17:
	cmpq	%rdx, %rcx
	jle	.L16
	movzbl	(%rbx,%r9), %esi
	movzbl	(%rbx,%rax), %edi
	cmpb	%dil, %sil
	je	.L16
	movzbl	(%r10,%rdx), %r8d
	cmpb	%r8b, %sil
	je	.L16
	cmpb	%r8b, %dil
	setne	%sil
	cmpb	$1, %sil
	sbbl	$-1, %r12d
.L16:
	addq	$1, %rax
	addq	$2, %rdx
	cmpq	%rcx, %rax
	jl	.L17
	addq	$1, %r9
	addq	$1, %r14
	addq	$1, %r13
	subq	$2, %r15
	cmpq	%r11, %r9
	jne	.L18
	movl	-76(%rbp), %r11d
.L5:
	movl	-72(%rbp), %edx
	imull	-68(%rbp), %edx
	xorl	%eax, %eax
	movl	$1, %edi
	leaq	.LC5(%rip), %rsi
	imull	%r11d, %edx
	subl	%r12d, %edx
	call	__printf_chk@PLT
	movq	-56(%rbp), %rax
	subq	%fs:40, %rax
	jne	.L46
	leaq	-40(%rbp), %rsp
	xorl	%eax, %eax
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_remember_state
	.cfi_def_cfa 7, 8
	ret
	.p2align 4,,10
	.p2align 3
.L44:
	.cfi_restore_state
	addl	$1, %edi
	jmp	.L13
.L21:
	movl	$0, -72(%rbp)
	xorl	%r11d, %r11d
	movl	$0, -68(%rbp)
.L40:
	xorl	%r12d, %r12d
	jmp	.L5
.L43:
	orq	$0, -8(%rsp,%rdx)
	jmp	.L4
.L22:
	movl	$0, -72(%rbp)
	xorl	%eax, %eax
	xorl	%r11d, %r11d
	movl	$0, -68(%rbp)
	jmp	.L6
.L46:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC2:
	.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
.LC3:
	.byte	71
	.byte	71
	.byte	71
	.byte	71
	.byte	71
	.byte	71
	.byte	71
	.byte	71
	.byte	71
	.byte	71
	.byte	71
	.byte	71
	.byte	71
	.byte	71
	.byte	71
	.byte	71
	.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
.LC0:
	.string	"%ld"
.LC1:
	.string	"%s"
.LC5:
	.string	"%ld\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	leaq	.LC0(%rip), %rdi
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%r15
	pushq	%r14
	leaq	-64(%rbp), %rsi
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	subq	$40, %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
	call	__isoc99_scanf@PLT
	movq	-64(%rbp), %rax
	movq	%rsp, %rcx
	addq	$15, %rax
	movq	%rax, %rdx
	andq	$-4096, %rax
	subq	%rax, %rcx
	andq	$-16, %rdx
	cmpq	%rcx, %rsp
	je	.L3
.L42:
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	cmpq	%rcx, %rsp
	jne	.L42
.L3:
	andl	$4095, %edx
	subq	%rdx, %rsp
	testq	%rdx, %rdx
	jne	.L43
.L4:
	movq	%rsp, %rsi
	leaq	.LC1(%rip), %rdi
	xorl	%eax, %eax
	movq	%rsp, %rbx
	call	__isoc99_scanf@PLT
	movq	-64(%rbp), %rcx
	testq	%rcx, %rcx
	jle	.L21
	leaq	-1(%rcx), %rax
	movq	%rax, %r8
	cmpq	$14, %rax
	jbe	.L22
	movq	%rcx, %rdx
	pxor	%xmm5, %xmm5
	pcmpeqd	%xmm9, %xmm9
	movq	%rsp, %rax
	andq	$-16, %rdx
	movdqa	%xmm5, %xmm12
	movdqa	.LC2(%rip), %xmm11
	movdqa	.LC3(%rip), %xmm10
	movdqa	%xmm5, %xmm3
	pxor	%xmm7, %xmm7
	pxor	%xmm6, %xmm6
	addq	%rsp, %rdx
	movdqa	.LC4(%rip), %xmm8
	.p2align 4,,10
	.p2align 3
.L7:
	movdqu	(%rax), %xmm1
	movdqa	%xmm7, %xmm4
	movdqu	(%rax), %xmm0
	addq	$16, %rax
	movdqa	%xmm6, %xmm14
	pcmpeqb	%xmm11, %xmm1
	pcmpeqb	%xmm10, %xmm0
	movdqa	%xmm1, %xmm2
	pand	%xmm8, %xmm1
	pcmpgtb	%xmm1, %xmm4
	movdqa	%xmm1, %xmm13
	por	%xmm0, %xmm2
	pand	%xmm8, %xmm0
	pxor	%xmm9, %xmm2
	punpcklbw	%xmm4, %xmm13
	punpckhbw	%xmm4, %xmm1
	pcmpgtw	%xmm13, %xmm14
	movdqa	%xmm13, %xmm4
	punpcklwd	%xmm14, %xmm4
	punpckhwd	%xmm14, %xmm13
	movdqa	%xmm6, %xmm14
	paddd	%xmm4, %xmm3
	movdqa	%xmm6, %xmm4
	pcmpgtw	%xmm1, %xmm4
	paddd	%xmm13, %xmm3
	movdqa	%xmm1, %xmm13
	punpcklwd	%xmm4, %xmm13
	punpckhwd	%xmm4, %xmm1
	paddd	%xmm13, %xmm3
	movdqa	%xmm0, %xmm13
	paddd	%xmm1, %xmm3
	movdqa	%xmm7, %xmm1
	pcmpgtb	%xmm0, %xmm1
	punpcklbw	%xmm1, %xmm13
	punpckhbw	%xmm1, %xmm0
	movdqa	%xmm12, %xmm1
	pcmpgtw	%xmm13, %xmm14
	movdqa	%xmm13, %xmm4
	movdqa	%xmm0, %xmm12
	punpcklwd	%xmm14, %xmm4
	punpckhwd	%xmm14, %xmm13
	paddd	%xmm4, %xmm1
	movdqa	%xmm6, %xmm4
	pcmpgtw	%xmm0, %xmm4
	paddd	%xmm13, %xmm1
	punpcklwd	%xmm4, %xmm12
	punpckhwd	%xmm4, %xmm0
	paddd	%xmm12, %xmm1
	paddd	%xmm0, %xmm1
	movdqa	%xmm2, %xmm0
	movdqa	%xmm1, %xmm12
	movdqa	%xmm7, %xmm1
	pcmpgtb	%xmm2, %xmm1
	punpcklbw	%xmm1, %xmm0
	punpckhbw	%xmm1, %xmm2
	movdqa	%xmm6, %xmm1
	pcmpgtw	%xmm0, %xmm1
	movdqa	%xmm0, %xmm4
	punpcklwd	%xmm1, %xmm4
	punpckhwd	%xmm1, %xmm0
	movdqa	%xmm2, %xmm1
	psubd	%xmm4, %xmm5
	psubd	%xmm0, %xmm5
	movdqa	%xmm6, %xmm0
	pcmpgtw	%xmm2, %xmm0
	punpcklwd	%xmm0, %xmm1
	punpckhwd	%xmm0, %xmm2
	psubd	%xmm1, %xmm5
	psubd	%xmm2, %xmm5
	cmpq	%rax, %rdx
	jne	.L7
	movdqa	%xmm5, %xmm0
	movdqa	%xmm12, %xmm1
	movq	%rcx, %rdx
	psrldq	$8, %xmm0
	andq	$-16, %rdx
	paddd	%xmm0, %xmm5
	movslq	%edx, %rax
	movdqa	%xmm5, %xmm0
	psrldq	$4, %xmm0
	paddd	%xmm0, %xmm5
	movdqa	%xmm12, %xmm0
	psrldq	$8, %xmm0
	movd	%xmm5, %r11d
	paddd	%xmm0, %xmm1
	movdqa	%xmm1, %xmm0
	psrldq	$4, %xmm0
	paddd	%xmm0, %xmm1
	movdqa	%xmm3, %xmm0
	psrldq	$8, %xmm0
	movd	%xmm1, -72(%rbp)
	paddd	%xmm0, %xmm3
	movdqa	%xmm3, %xmm0
	psrldq	$4, %xmm0
	paddd	%xmm0, %xmm3
	movd	%xmm3, -68(%rbp)
	cmpq	%rdx, %rcx
	je	.L8
.L6:
	movl	-68(%rbp), %esi
	movl	-72(%rbp), %edi
	jmp	.L11
	.p2align 4,,10
	.p2align 3
.L35:
	cmpb	$71, %dl
	je	.L44
	addl	$1, %r11d
.L13:
	addq	$1, %rax
	cmpq	%rax, %rcx
	jle	.L45
.L11:
	movzbl	(%rbx,%rax), %edx
	cmpb	$82, %dl
	jne	.L35
	addq	$1, %rax
	addl	$1, %esi
	cmpq	%rax, %rcx
	jg	.L11
.L45:
	movl	%esi, -68(%rbp)
	movl	%edi, -72(%rbp)
	cmpq	$1, %rcx
	jle	.L40
.L8:
	movl	%r11d, -76(%rbp)
	movl	$2, %r13d
	xorl	%r9d, %r9d
	xorl	%r12d, %r12d
	movq	$-2, %r15
	movl	$1, %r14d
	movq	%r8, %r11
	.p2align 4,,10
	.p2align 3
.L18:
	leaq	(%r9,%r15), %r10
	movq	%r13, %rdx
	movq	%r14, %rax
	addq	%r13, %r10
	addq	%rbx, %r10
	.p2align 4,,10
	.p2align 3
.L17:
	cmpq	%rdx, %rcx
	jle	.L16
	movzbl	(%rbx,%r9), %esi
	movzbl	(%rbx,%rax), %edi
	cmpb	%dil, %sil
	je	.L16
	movzbl	(%r10,%rdx), %r8d
	cmpb	%r8b, %sil
	je	.L16
	cmpb	%r8b, %dil
	setne	%sil
	cmpb	$1, %sil
	sbbl	$-1, %r12d
.L16:
	addq	$1, %rax
	addq	$2, %rdx
	cmpq	%rcx, %rax
	jl	.L17
	addq	$1, %r9
	addq	$1, %r14
	addq	$1, %r13
	subq	$2, %r15
	cmpq	%r11, %r9
	jne	.L18
	movl	-76(%rbp), %r11d
.L5:
	movl	-72(%rbp), %edx
	imull	-68(%rbp), %edx
	xorl	%eax, %eax
	movl	$1, %edi
	leaq	.LC5(%rip), %rsi
	imull	%r11d, %edx
	subl	%r12d, %edx
	call	__printf_chk@PLT
	movq	-56(%rbp), %rax
	subq	%fs:40, %rax
	jne	.L46
	leaq	-40(%rbp), %rsp
	xorl	%eax, %eax
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_remember_state
	.cfi_def_cfa 7, 8
	ret
	.p2align 4,,10
	.p2align 3
.L44:
	.cfi_restore_state
	addl	$1, %edi
	jmp	.L13
.L21:
	movl	$0, -72(%rbp)
	xorl	%r11d, %r11d
	movl	$0, -68(%rbp)
.L40:
	xorl	%r12d, %r12d
	jmp	.L5
.L43:
	orq	$0, -8(%rsp,%rdx)
	jmp	.L4
.L22:
	movl	$0, -72(%rbp)
	xorl	%eax, %eax
	xorl	%r11d, %r11d
	movl	$0, -68(%rbp)
	jmp	.L6
.L46:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC2:
	.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
.LC3:
	.byte	71
	.byte	71
	.byte	71
	.byte	71
	.byte	71
	.byte	71
	.byte	71
	.byte	71
	.byte	71
	.byte	71
	.byte	71
	.byte	71
	.byte	71
	.byte	71
	.byte	71
	.byte	71
	.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>


int main(void){

        int r=0,g=0,b=0;
        int ng = 0;
        long n;

        scanf("%ld",&n);
        char s[n];
        scanf("%s",&s);

        for(int i=0;i<n;i++){           //1つ目の条件を満たしているr*g*bを求められるようにカウントしとく
                if(s[i]=='R'){
                        r++;
                }else if(s[i]=='G'){
                        g++;
                }else{
                        b++;
                }   
        }   

        int k;

        for(int i=0;i<n;i++){                   //i固定
                for(int j=i+1;j<n;j++){         //j固定
                        k = j+(j-i);            //ngのものを計算するためにkをngの条件に設定
                        if(k>=n){               //kがnを超えるものは初めに取り除く
                                continue;
                        }   
                        if((s[i] != s[j]) && (s[j] != s[k]) &&(s[k] != s[i])){//二つ目の条件違反してるけど1つ>目の条件満たしているもの
                                ng++;
                        }   
                }   
        }   

printf("%ld\n",r*g*b-ng);
}


4
BGRR
 39
BBBGBBBRBGBRBGBRBGGBRRRBBGRRBBGGBRGBRBR
 39
RBRBRRBGGBBRRGBBGRRBGGBRBGBRBGBRBBBGBBB
 4
GRRB
 39
RRRBGRBGGBBRRGBBRBRBGGBRBGBRBGBRBBBGBBB
 39
BBBGBBBRBGBRBGBRBGGBRRBBBGRRBBGGBRGRRBR
 39
RRRBGRBGGBBRRGBBRBRBGGBRBGBRBGBBBBBGBBR
 39
RRRBGRBGGBBRRGBBRRBBGGBRBGBRBGBBBBBGBBR
 39
RBBGBBBBBGBRBRBRBGGBBGRBBGRRBBGGRRGBBRR
 4
RGBR

1
 1800
 1796
 2
 1804
 1806
 1813
 1811
 1803
 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>


int main(void){

        int r=0,g=0,b=0;
        int ng = 0;
        long n;

        scanf("%ld",&n);
        char s[n];
        scanf("%s",&s);

        for(int i=0;i<n;i++){           //1つ目の条件を満たしているr*g*bを求められるようにカウントしとく
                if(s[i]=='R'){
                        r++;
                }else if(s[i]=='G'){
                        g++;
                }else{
                        b++;
                }   
        }   

        int k;

        for(int i=0;i<n;i++){                   //i固定
                for(int j=i+1;j<n;j++){         //j固定
                        k = j+(j-i);            //ngのものを計算するためにkをngの条件に設定
                        if(k>=n){               //kがnを超えるものは初めに取り除く
                                continue;
                        }   
                        if((s[i] != s[j]) && (s[j] != s[k]) &&(s[k] != s[i])){//二つ目の条件違反してるけど1つ>目の条件満たしているもの
                                ng++;
                        }   
                }   
        }   

printf("%ld\n",r*g*b-ng);
}

```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%ld"
.LC1:
	.string	"%s"
.LC2:
	.string	"%ld\n"
	.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	$72, %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, -112(%rbp)
	movl	$0, -108(%rbp)
	movl	$0, -104(%rbp)
	movl	$0, -100(%rbp)
	leaq	-80(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	-80(%rbp), %rax
	leaq	-1(%rax), %rdx
	movq	%rdx, -72(%rbp)
	movq	%rax, %rdx
	movq	%rdx, %r14
	movl	$0, %r15d
	movq	%rax, %rdx
	movq	%rdx, %r12
	movl	$0, %r13d
	movq	%rax, %rdx
	movl	$16, %eax
	subq	$1, %rax
	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, -96(%rbp)
	jmp	.L5
.L9:
	movq	-64(%rbp), %rdx
	movl	-96(%rbp), %eax
	cltq
	movzbl	(%rdx,%rax), %eax
	cmpb	$82, %al
	jne	.L6
	addl	$1, -112(%rbp)
	jmp	.L7
.L6:
	movq	-64(%rbp), %rdx
	movl	-96(%rbp), %eax
	cltq
	movzbl	(%rdx,%rax), %eax
	cmpb	$71, %al
	jne	.L8
	addl	$1, -108(%rbp)
	jmp	.L7
.L8:
	addl	$1, -104(%rbp)
.L7:
	addl	$1, -96(%rbp)
.L5:
	movl	-96(%rbp), %eax
	movslq	%eax, %rdx
	movq	-80(%rbp), %rax
	cmpq	%rax, %rdx
	jl	.L9
	movl	$0, -92(%rbp)
	jmp	.L10
.L15:
	movl	-92(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -88(%rbp)
	jmp	.L11
.L14:
	movl	-88(%rbp), %eax
	subl	-92(%rbp), %eax
	movl	%eax, %edx
	movl	-88(%rbp), %eax
	addl	%edx, %eax
	movl	%eax, -84(%rbp)
	movl	-84(%rbp), %eax
	movslq	%eax, %rdx
	movq	-80(%rbp), %rax
	cmpq	%rax, %rdx
	jge	.L18
	movq	-64(%rbp), %rdx
	movl	-92(%rbp), %eax
	cltq
	movzbl	(%rdx,%rax), %ecx
	movq	-64(%rbp), %rdx
	movl	-88(%rbp), %eax
	cltq
	movzbl	(%rdx,%rax), %eax
	cmpb	%al, %cl
	je	.L13
	movq	-64(%rbp), %rdx
	movl	-88(%rbp), %eax
	cltq
	movzbl	(%rdx,%rax), %ecx
	movq	-64(%rbp), %rdx
	movl	-84(%rbp), %eax
	cltq
	movzbl	(%rdx,%rax), %eax
	cmpb	%al, %cl
	je	.L13
	movq	-64(%rbp), %rdx
	movl	-84(%rbp), %eax
	cltq
	movzbl	(%rdx,%rax), %ecx
	movq	-64(%rbp), %rdx
	movl	-92(%rbp), %eax
	cltq
	movzbl	(%rdx,%rax), %eax
	cmpb	%al, %cl
	je	.L13
	addl	$1, -100(%rbp)
	jmp	.L13
.L18:
	nop
.L13:
	addl	$1, -88(%rbp)
.L11:
	movl	-88(%rbp), %eax
	movslq	%eax, %rdx
	movq	-80(%rbp), %rax
	cmpq	%rax, %rdx
	jl	.L14
	addl	$1, -92(%rbp)
.L10:
	movl	-92(%rbp), %eax
	movslq	%eax, %rdx
	movq	-80(%rbp), %rax
	cmpq	%rax, %rdx
	jl	.L15
	movl	-112(%rbp), %eax
	imull	-108(%rbp), %eax
	imull	-104(%rbp), %eax
	subl	-100(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movq	%rbx, %rsp
	movl	$0, %eax
	movq	-56(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L17
	call	__stack_chk_fail@PLT
.L17:
	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	"%ld"
.LC1:
	.string	"%s"
.LC2:
	.string	"%ld\n"
	.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	$72, %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, -112(%rbp)
	movl	$0, -108(%rbp)
	movl	$0, -104(%rbp)
	movl	$0, -100(%rbp)
	leaq	-80(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	-80(%rbp), %rax
	leaq	-1(%rax), %rdx
	movq	%rdx, -72(%rbp)
	movq	%rax, %rdx
	movq	%rdx, %r14
	movl	$0, %r15d
	movq	%rax, %rdx
	movq	%rdx, %r12
	movl	$0, %r13d
	movq	%rax, %rdx
	movl	$16, %eax
	subq	$1, %rax
	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, -96(%rbp)
	jmp	.L5
.L9:
	movq	-64(%rbp), %rdx
	movl	-96(%rbp), %eax
	cltq
	movzbl	(%rdx,%rax), %eax
	cmpb	$82, %al
	jne	.L6
	addl	$1, -112(%rbp)
	jmp	.L7
.L6:
	movq	-64(%rbp), %rdx
	movl	-96(%rbp), %eax
	cltq
	movzbl	(%rdx,%rax), %eax
	cmpb	$71, %al
	jne	.L8
	addl	$1, -108(%rbp)
	jmp	.L7
.L8:
	addl	$1, -104(%rbp)
.L7:
	addl	$1, -96(%rbp)
.L5:
	movl	-96(%rbp), %eax
	movslq	%eax, %rdx
	movq	-80(%rbp), %rax
	cmpq	%rax, %rdx
	jl	.L9
	movl	$0, -92(%rbp)
	jmp	.L10
.L15:
	movl	-92(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -88(%rbp)
	jmp	.L11
.L14:
	movl	-88(%rbp), %eax
	subl	-92(%rbp), %eax
	movl	%eax, %edx
	movl	-88(%rbp), %eax
	addl	%edx, %eax
	movl	%eax, -84(%rbp)
	movl	-84(%rbp), %eax
	movslq	%eax, %rdx
	movq	-80(%rbp), %rax
	cmpq	%rax, %rdx
	jge	.L18
	movq	-64(%rbp), %rdx
	movl	-92(%rbp), %eax
	cltq
	movzbl	(%rdx,%rax), %ecx
	movq	-64(%rbp), %rdx
	movl	-88(%rbp), %eax
	cltq
	movzbl	(%rdx,%rax), %eax
	cmpb	%al, %cl
	je	.L13
	movq	-64(%rbp), %rdx
	movl	-88(%rbp), %eax
	cltq
	movzbl	(%rdx,%rax), %ecx
	movq	-64(%rbp), %rdx
	movl	-84(%rbp), %eax
	cltq
	movzbl	(%rdx,%rax), %eax
	cmpb	%al, %cl
	je	.L13
	movq	-64(%rbp), %rdx
	movl	-84(%rbp), %eax
	cltq
	movzbl	(%rdx,%rax), %ecx
	movq	-64(%rbp), %rdx
	movl	-92(%rbp), %eax
	cltq
	movzbl	(%rdx,%rax), %eax
	cmpb	%al, %cl
	je	.L13
	addl	$1, -100(%rbp)
	jmp	.L13
.L18:
	nop
.L13:
	addl	$1, -88(%rbp)
.L11:
	movl	-88(%rbp), %eax
	movslq	%eax, %rdx
	movq	-80(%rbp), %rax
	cmpq	%rax, %rdx
	jl	.L14
	addl	$1, -92(%rbp)
.L10:
	movl	-92(%rbp), %eax
	movslq	%eax, %rdx
	movq	-80(%rbp), %rax
	cmpq	%rax, %rdx
	jl	.L15
	movl	-112(%rbp), %eax
	imull	-108(%rbp), %eax
	imull	-104(%rbp), %eax
	subl	-100(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movq	%rbx, %rsp
	movl	$0, %eax
	movq	-56(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L17
	call	__stack_chk_fail@PLT
.L17:
	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:
