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 n,i,j;
long r=0,g=0,b=0,q;
char s[4001];
int main(){
    scanf("%d%s",&n,s);
    for(i=0;i<n;i++)s[i]=='R'?r++:s[i]=='G'?g++:b++;
    q=r*g*b;
    for(i=0;i<n;i++){
        for(j=1;i+2*j<n;j++){
            if(s[i]!=s[i+j]&&s[i]!=s[i+2*j]&&s[i+2*j]!=s[i+j])q--;
        }
    }
    printf("%ld",q);
    return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	n
	.bss
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	i
	.align 4
	.type	i, @object
	.size	i, 4
i:
	.zero	4
	.globl	j
	.align 4
	.type	j, @object
	.size	j, 4
j:
	.zero	4
	.globl	r
	.align 8
	.type	r, @object
	.size	r, 8
r:
	.zero	8
	.globl	g
	.align 8
	.type	g, @object
	.size	g, 8
g:
	.zero	8
	.globl	b
	.align 8
	.type	b, @object
	.size	b, 8
b:
	.zero	8
	.globl	q
	.align 8
	.type	q, @object
	.size	q, 8
q:
	.zero	8
	.globl	s
	.align 32
	.type	s, @object
	.size	s, 4001
s:
	.zero	4001
	.section	.rodata
.LC0:
	.string	"%d%s"
.LC1:
	.string	"%ld"
	.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
	leaq	s(%rip), %rax
	movq	%rax, %rdx
	leaq	n(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, i(%rip)
	jmp	.L2
.L7:
	movl	i(%rip), %eax
	cltq
	leaq	s(%rip), %rdx
	movzbl	(%rax,%rdx), %eax
	cmpb	$82, %al
	jne	.L3
	movq	r(%rip), %rax
	addq	$1, %rax
	movq	%rax, r(%rip)
	jmp	.L4
.L3:
	movl	i(%rip), %eax
	cltq
	leaq	s(%rip), %rdx
	movzbl	(%rax,%rdx), %eax
	cmpb	$71, %al
	jne	.L5
	movq	g(%rip), %rax
	addq	$1, %rax
	movq	%rax, g(%rip)
	jmp	.L4
.L5:
	movq	b(%rip), %rax
	addq	$1, %rax
	movq	%rax, b(%rip)
.L4:
	movl	i(%rip), %eax
	addl	$1, %eax
	movl	%eax, i(%rip)
.L2:
	movl	i(%rip), %edx
	movl	n(%rip), %eax
	cmpl	%eax, %edx
	jl	.L7
	movq	r(%rip), %rdx
	movq	g(%rip), %rax
	imulq	%rax, %rdx
	movq	b(%rip), %rax
	imulq	%rdx, %rax
	movq	%rax, q(%rip)
	movl	$0, i(%rip)
	jmp	.L8
.L12:
	movl	$1, j(%rip)
	jmp	.L9
.L11:
	movl	i(%rip), %eax
	cltq
	leaq	s(%rip), %rdx
	movzbl	(%rax,%rdx), %edx
	movl	i(%rip), %ecx
	movl	j(%rip), %eax
	addl	%ecx, %eax
	cltq
	leaq	s(%rip), %rcx
	movzbl	(%rax,%rcx), %eax
	cmpb	%al, %dl
	je	.L10
	movl	i(%rip), %eax
	cltq
	leaq	s(%rip), %rdx
	movzbl	(%rax,%rdx), %edx
	movl	j(%rip), %eax
	leal	(%rax,%rax), %ecx
	movl	i(%rip), %eax
	addl	%ecx, %eax
	cltq
	leaq	s(%rip), %rcx
	movzbl	(%rax,%rcx), %eax
	cmpb	%al, %dl
	je	.L10
	movl	j(%rip), %eax
	leal	(%rax,%rax), %edx
	movl	i(%rip), %eax
	addl	%edx, %eax
	cltq
	leaq	s(%rip), %rdx
	movzbl	(%rax,%rdx), %edx
	movl	i(%rip), %ecx
	movl	j(%rip), %eax
	addl	%ecx, %eax
	cltq
	leaq	s(%rip), %rcx
	movzbl	(%rax,%rcx), %eax
	cmpb	%al, %dl
	je	.L10
	movq	q(%rip), %rax
	subq	$1, %rax
	movq	%rax, q(%rip)
.L10:
	movl	j(%rip), %eax
	addl	$1, %eax
	movl	%eax, j(%rip)
.L9:
	movl	j(%rip), %eax
	leal	(%rax,%rax), %edx
	movl	i(%rip), %eax
	addl	%eax, %edx
	movl	n(%rip), %eax
	cmpl	%eax, %edx
	jl	.L11
	movl	i(%rip), %eax
	addl	$1, %eax
	movl	%eax, i(%rip)
.L8:
	movl	i(%rip), %edx
	movl	n(%rip), %eax
	cmpl	%eax, %edx
	jl	.L12
	movq	q(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	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%s"
.LC1:
	.string	"%ld"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	leaq	n(%rip), %rsi
	leaq	.LC0(%rip), %rdi
	xorl	%eax, %eax
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	leaq	s(%rip), %rbx
	movq	%rbx, %rdx
	subq	$8, %rsp
	.cfi_def_cfa_offset 48
	call	__isoc99_scanf@PLT
	movl	n(%rip), %r12d
	movl	$0, i(%rip)
	testl	%r12d, %r12d
	jle	.L2
	movq	r(%rip), %r10
	leaq	1(%rbx), %rax
	movq	%rbx, %rcx
	xorl	%ebp, %ebp
	leal	-1(%r12), %esi
	movq	b(%rip), %rdi
	movq	g(%rip), %r11
	xorl	%r9d, %r9d
	addq	%rax, %rsi
	movq	%r10, %r8
	movq	%rbx, %rax
	xorl	%ebx, %ebx
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L3:
	cmpb	$71, %dl
	je	.L37
	addq	$1, %rdi
	movl	$1, %r9d
.L4:
	addq	$1, %rax
	cmpq	%rax, %rsi
	je	.L38
.L6:
	movzbl	(%rax), %edx
	cmpb	$82, %dl
	jne	.L3
	addq	$1, %rax
	addq	$1, %r8
	movl	$1, %ebx
	cmpq	%rax, %rsi
	jne	.L6
.L38:
	testb	%r9b, %r9b
	je	.L7
	movq	%rdi, b(%rip)
.L7:
	testb	%bpl, %bpl
	je	.L8
	movq	%r11, g(%rip)
.L8:
	testb	%bl, %bl
	je	.L9
	movq	%r8, r(%rip)
	movq	%r8, %r10
.L9:
	imulq	g(%rip), %r10
	leal	-3(%r12), %ebx
	movl	$2, %r11d
	xorl	%ebp, %ebp
	imulq	b(%rip), %r10
	leal	2(%r12), %r13d
	movq	%r10, q(%rip)
	.p2align 4,,10
	.p2align 3
.L13:
	cmpl	%r12d, %r11d
	jge	.L15
	movl	%ebx, %r9d
	movzbl	(%rcx), %edi
	movl	$1, %eax
	shrl	%r9d
	leal	2(%r9), %r8d
	movq	%r8, %r9
	.p2align 4,,10
	.p2align 3
.L12:
	movzbl	(%rcx,%rax), %edx
	cmpb	%dl, %dil
	je	.L11
	movzbl	(%rcx,%rax,2), %esi
	cmpb	%sil, %dl
	setne	%dl
	cmpb	%sil, %dil
	setne	%sil
	andb	%sil, %dl
	je	.L11
	subq	$1, %r10
	movl	%edx, %ebp
.L11:
	addq	$1, %rax
	cmpq	%rax, %r8
	jne	.L12
	addl	$1, %r11d
	subl	$1, %ebx
	addq	$1, %rcx
	cmpl	%r11d, %r13d
	jne	.L13
.L39:
	movl	%r9d, j(%rip)
	movl	%r12d, i(%rip)
	testb	%bpl, %bpl
	je	.L14
	movq	%r10, q(%rip)
.L14:
	movq	q(%rip), %rdx
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	addq	$8, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L37:
	.cfi_restore_state
	addq	$1, %r11
	movl	$1, %ebp
	jmp	.L4
	.p2align 4,,10
	.p2align 3
.L15:
	addl	$1, %r11d
	movl	$1, %r9d
	subl	$1, %ebx
	addq	$1, %rcx
	cmpl	%r11d, %r13d
	jne	.L13
	jmp	.L39
.L2:
	movq	g(%rip), %rax
	imulq	r(%rip), %rax
	imulq	b(%rip), %rax
	movq	%rax, q(%rip)
	jmp	.L14
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.globl	s
	.bss
	.align 32
	.type	s, @object
	.size	s, 4001
s:
	.zero	4001
	.globl	q
	.align 8
	.type	q, @object
	.size	q, 8
q:
	.zero	8
	.globl	b
	.align 8
	.type	b, @object
	.size	b, 8
b:
	.zero	8
	.globl	g
	.align 8
	.type	g, @object
	.size	g, 8
g:
	.zero	8
	.globl	r
	.align 8
	.type	r, @object
	.size	r, 8
r:
	.zero	8
	.globl	j
	.align 4
	.type	j, @object
	.size	j, 4
j:
	.zero	4
	.globl	i
	.align 4
	.type	i, @object
	.size	i, 4
i:
	.zero	4
	.globl	n
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.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%s"
.LC1:
	.string	"%ld"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	leaq	n(%rip), %rsi
	leaq	.LC0(%rip), %rdi
	xorl	%eax, %eax
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	leaq	s(%rip), %rbx
	movq	%rbx, %rdx
	subq	$8, %rsp
	.cfi_def_cfa_offset 48
	call	__isoc99_scanf@PLT
	movl	n(%rip), %r12d
	movl	$0, i(%rip)
	testl	%r12d, %r12d
	jle	.L2
	movq	r(%rip), %r10
	leaq	1(%rbx), %rax
	movq	%rbx, %rcx
	xorl	%ebp, %ebp
	leal	-1(%r12), %esi
	movq	b(%rip), %rdi
	movq	g(%rip), %r11
	xorl	%r9d, %r9d
	addq	%rax, %rsi
	movq	%r10, %r8
	movq	%rbx, %rax
	xorl	%ebx, %ebx
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L3:
	cmpb	$71, %dl
	je	.L37
	addq	$1, %rdi
	movl	$1, %r9d
.L4:
	addq	$1, %rax
	cmpq	%rax, %rsi
	je	.L38
.L6:
	movzbl	(%rax), %edx
	cmpb	$82, %dl
	jne	.L3
	addq	$1, %rax
	addq	$1, %r8
	movl	$1, %ebx
	cmpq	%rax, %rsi
	jne	.L6
.L38:
	testb	%r9b, %r9b
	je	.L7
	movq	%rdi, b(%rip)
.L7:
	testb	%bpl, %bpl
	je	.L8
	movq	%r11, g(%rip)
.L8:
	testb	%bl, %bl
	je	.L9
	movq	%r8, r(%rip)
	movq	%r8, %r10
.L9:
	imulq	g(%rip), %r10
	leal	-3(%r12), %ebx
	movl	$2, %r11d
	xorl	%ebp, %ebp
	imulq	b(%rip), %r10
	leal	2(%r12), %r13d
	movq	%r10, q(%rip)
	.p2align 4,,10
	.p2align 3
.L13:
	cmpl	%r12d, %r11d
	jge	.L15
	movl	%ebx, %r9d
	movzbl	(%rcx), %edi
	movl	$1, %eax
	shrl	%r9d
	leal	2(%r9), %r8d
	movq	%r8, %r9
	.p2align 4,,10
	.p2align 3
.L12:
	movzbl	(%rcx,%rax), %edx
	cmpb	%dl, %dil
	je	.L11
	movzbl	(%rcx,%rax,2), %esi
	cmpb	%sil, %dl
	setne	%dl
	cmpb	%sil, %dil
	setne	%sil
	andb	%sil, %dl
	je	.L11
	subq	$1, %r10
	movl	%edx, %ebp
.L11:
	addq	$1, %rax
	cmpq	%rax, %r8
	jne	.L12
	addl	$1, %r11d
	subl	$1, %ebx
	addq	$1, %rcx
	cmpl	%r11d, %r13d
	jne	.L13
.L39:
	movl	%r9d, j(%rip)
	movl	%r12d, i(%rip)
	testb	%bpl, %bpl
	je	.L14
	movq	%r10, q(%rip)
.L14:
	movq	q(%rip), %rdx
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	addq	$8, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L37:
	.cfi_restore_state
	addq	$1, %r11
	movl	$1, %ebp
	jmp	.L4
	.p2align 4,,10
	.p2align 3
.L15:
	addl	$1, %r11d
	movl	$1, %r9d
	subl	$1, %ebx
	addq	$1, %rcx
	cmpl	%r11d, %r13d
	jne	.L13
	jmp	.L39
.L2:
	movq	g(%rip), %rax
	imulq	r(%rip), %rax
	imulq	b(%rip), %rax
	movq	%rax, q(%rip)
	jmp	.L14
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.globl	s
	.bss
	.align 32
	.type	s, @object
	.size	s, 4001
s:
	.zero	4001
	.globl	q
	.align 8
	.type	q, @object
	.size	q, 8
q:
	.zero	8
	.globl	b
	.align 8
	.type	b, @object
	.size	b, 8
b:
	.zero	8
	.globl	g
	.align 8
	.type	g, @object
	.size	g, 8
g:
	.zero	8
	.globl	r
	.align 8
	.type	r, @object
	.size	r, 8
r:
	.zero	8
	.globl	j
	.align 4
	.type	j, @object
	.size	j, 4
j:
	.zero	4
	.globl	i
	.align 4
	.type	i, @object
	.size	i, 4
i:
	.zero	4
	.globl	n
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.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 n,i,j;
long r=0,g=0,b=0,q;
char s[4001];
int main(){
    scanf("%d%s",&n,s);
    for(i=0;i<n;i++)s[i]=='R'?r++:s[i]=='G'?g++:b++;
    q=r*g*b;
    for(i=0;i<n;i++){
        for(j=1;i+2*j<n;j++){
            if(s[i]!=s[i+j]&&s[i]!=s[i+2*j]&&s[i+2*j]!=s[i+j])q--;
        }
    }
    printf("%ld",q);
    return 0;
}
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 n,i,j;
long r=0,g=0,b=0,q;
char s[4001];
int main(){
    scanf("%d%s",&n,s);
    for(i=0;i<n;i++)s[i]=='R'?r++:s[i]=='G'?g++:b++;
    q=r*g*b;
    for(i=0;i<n;i++){
        for(j=1;i+2*j<n;j++){
            if(s[i]!=s[i+j]&&s[i]!=s[i+2*j]&&s[i+2*j]!=s[i+j])q--;
        }
    }
    printf("%ld",q);
    return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	n
	.bss
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	i
	.align 4
	.type	i, @object
	.size	i, 4
i:
	.zero	4
	.globl	j
	.align 4
	.type	j, @object
	.size	j, 4
j:
	.zero	4
	.globl	r
	.align 8
	.type	r, @object
	.size	r, 8
r:
	.zero	8
	.globl	g
	.align 8
	.type	g, @object
	.size	g, 8
g:
	.zero	8
	.globl	b
	.align 8
	.type	b, @object
	.size	b, 8
b:
	.zero	8
	.globl	q
	.align 8
	.type	q, @object
	.size	q, 8
q:
	.zero	8
	.globl	s
	.align 32
	.type	s, @object
	.size	s, 4001
s:
	.zero	4001
	.section	.rodata
.LC0:
	.string	"%d%s"
.LC1:
	.string	"%ld"
	.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
	leaq	s(%rip), %rax
	movq	%rax, %rdx
	leaq	n(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, i(%rip)
	jmp	.L2
.L7:
	movl	i(%rip), %eax
	cltq
	leaq	s(%rip), %rdx
	movzbl	(%rax,%rdx), %eax
	cmpb	$82, %al
	jne	.L3
	movq	r(%rip), %rax
	addq	$1, %rax
	movq	%rax, r(%rip)
	jmp	.L4
.L3:
	movl	i(%rip), %eax
	cltq
	leaq	s(%rip), %rdx
	movzbl	(%rax,%rdx), %eax
	cmpb	$71, %al
	jne	.L5
	movq	g(%rip), %rax
	addq	$1, %rax
	movq	%rax, g(%rip)
	jmp	.L4
.L5:
	movq	b(%rip), %rax
	addq	$1, %rax
	movq	%rax, b(%rip)
.L4:
	movl	i(%rip), %eax
	addl	$1, %eax
	movl	%eax, i(%rip)
.L2:
	movl	i(%rip), %edx
	movl	n(%rip), %eax
	cmpl	%eax, %edx
	jl	.L7
	movq	r(%rip), %rdx
	movq	g(%rip), %rax
	imulq	%rax, %rdx
	movq	b(%rip), %rax
	imulq	%rdx, %rax
	movq	%rax, q(%rip)
	movl	$0, i(%rip)
	jmp	.L8
.L12:
	movl	$1, j(%rip)
	jmp	.L9
.L11:
	movl	i(%rip), %eax
	cltq
	leaq	s(%rip), %rdx
	movzbl	(%rax,%rdx), %edx
	movl	i(%rip), %ecx
	movl	j(%rip), %eax
	addl	%ecx, %eax
	cltq
	leaq	s(%rip), %rcx
	movzbl	(%rax,%rcx), %eax
	cmpb	%al, %dl
	je	.L10
	movl	i(%rip), %eax
	cltq
	leaq	s(%rip), %rdx
	movzbl	(%rax,%rdx), %edx
	movl	j(%rip), %eax
	leal	(%rax,%rax), %ecx
	movl	i(%rip), %eax
	addl	%ecx, %eax
	cltq
	leaq	s(%rip), %rcx
	movzbl	(%rax,%rcx), %eax
	cmpb	%al, %dl
	je	.L10
	movl	j(%rip), %eax
	leal	(%rax,%rax), %edx
	movl	i(%rip), %eax
	addl	%edx, %eax
	cltq
	leaq	s(%rip), %rdx
	movzbl	(%rax,%rdx), %edx
	movl	i(%rip), %ecx
	movl	j(%rip), %eax
	addl	%ecx, %eax
	cltq
	leaq	s(%rip), %rcx
	movzbl	(%rax,%rcx), %eax
	cmpb	%al, %dl
	je	.L10
	movq	q(%rip), %rax
	subq	$1, %rax
	movq	%rax, q(%rip)
.L10:
	movl	j(%rip), %eax
	addl	$1, %eax
	movl	%eax, j(%rip)
.L9:
	movl	j(%rip), %eax
	leal	(%rax,%rax), %edx
	movl	i(%rip), %eax
	addl	%eax, %edx
	movl	n(%rip), %eax
	cmpl	%eax, %edx
	jl	.L11
	movl	i(%rip), %eax
	addl	$1, %eax
	movl	%eax, i(%rip)
.L8:
	movl	i(%rip), %edx
	movl	n(%rip), %eax
	cmpl	%eax, %edx
	jl	.L12
	movq	q(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	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
	.globl	n
	.bss
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	i
	.align 4
	.type	i, @object
	.size	i, 4
i:
	.zero	4
	.globl	j
	.align 4
	.type	j, @object
	.size	j, 4
j:
	.zero	4
	.globl	r
	.align 8
	.type	r, @object
	.size	r, 8
r:
	.zero	8
	.globl	g
	.align 8
	.type	g, @object
	.size	g, 8
g:
	.zero	8
	.globl	b
	.align 8
	.type	b, @object
	.size	b, 8
b:
	.zero	8
	.globl	q
	.align 8
	.type	q, @object
	.size	q, 8
q:
	.zero	8
	.globl	s
	.align 32
	.type	s, @object
	.size	s, 4001
s:
	.zero	4001
	.section	.rodata
.LC0:
	.string	"%d%s"
.LC1:
	.string	"%ld"
	.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
	leaq	s(%rip), %rax
	movq	%rax, %rdx
	leaq	n(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, i(%rip)
	jmp	.L2
.L7:
	movl	i(%rip), %eax
	cltq
	leaq	s(%rip), %rdx
	movzbl	(%rax,%rdx), %eax
	cmpb	$82, %al
	jne	.L3
	movq	r(%rip), %rax
	addq	$1, %rax
	movq	%rax, r(%rip)
	jmp	.L4
.L3:
	movl	i(%rip), %eax
	cltq
	leaq	s(%rip), %rdx
	movzbl	(%rax,%rdx), %eax
	cmpb	$71, %al
	jne	.L5
	movq	g(%rip), %rax
	addq	$1, %rax
	movq	%rax, g(%rip)
	jmp	.L4
.L5:
	movq	b(%rip), %rax
	addq	$1, %rax
	movq	%rax, b(%rip)
.L4:
	movl	i(%rip), %eax
	addl	$1, %eax
	movl	%eax, i(%rip)
.L2:
	movl	i(%rip), %edx
	movl	n(%rip), %eax
	cmpl	%eax, %edx
	jl	.L7
	movq	r(%rip), %rdx
	movq	g(%rip), %rax
	imulq	%rax, %rdx
	movq	b(%rip), %rax
	imulq	%rdx, %rax
	movq	%rax, q(%rip)
	movl	$0, i(%rip)
	jmp	.L8
.L12:
	movl	$1, j(%rip)
	jmp	.L9
.L11:
	movl	i(%rip), %eax
	cltq
	leaq	s(%rip), %rdx
	movzbl	(%rax,%rdx), %edx
	movl	i(%rip), %ecx
	movl	j(%rip), %eax
	addl	%ecx, %eax
	cltq
	leaq	s(%rip), %rcx
	movzbl	(%rax,%rcx), %eax
	cmpb	%al, %dl
	je	.L10
	movl	i(%rip), %eax
	cltq
	leaq	s(%rip), %rdx
	movzbl	(%rax,%rdx), %edx
	movl	j(%rip), %eax
	leal	(%rax,%rax), %ecx
	movl	i(%rip), %eax
	addl	%ecx, %eax
	cltq
	leaq	s(%rip), %rcx
	movzbl	(%rax,%rcx), %eax
	cmpb	%al, %dl
	je	.L10
	movl	j(%rip), %eax
	leal	(%rax,%rax), %edx
	movl	i(%rip), %eax
	addl	%edx, %eax
	cltq
	leaq	s(%rip), %rdx
	movzbl	(%rax,%rdx), %edx
	movl	i(%rip), %ecx
	movl	j(%rip), %eax
	addl	%ecx, %eax
	cltq
	leaq	s(%rip), %rcx
	movzbl	(%rax,%rcx), %eax
	cmpb	%al, %dl
	je	.L10
	movq	q(%rip), %rax
	subq	$1, %rax
	movq	%rax, q(%rip)
.L10:
	movl	j(%rip), %eax
	addl	$1, %eax
	movl	%eax, j(%rip)
.L9:
	movl	j(%rip), %eax
	leal	(%rax,%rax), %edx
	movl	i(%rip), %eax
	addl	%eax, %edx
	movl	n(%rip), %eax
	cmpl	%eax, %edx
	jl	.L11
	movl	i(%rip), %eax
	addl	$1, %eax
	movl	%eax, i(%rip)
.L8:
	movl	i(%rip), %edx
	movl	n(%rip), %eax
	cmpl	%eax, %edx
	jl	.L12
	movq	q(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	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:
