Given the following C code and unoptimized assembly code, your task is to generate highly optimized x86-64 assembly code.
C Code:

```c
/*
  AOJ #0309
  title:New Drug Development
  @kankichi573
 */
#include <stdio.h>
#include <string.h>
#define DIV 1000000007
int n;
int from[1001],to[1001];
char node[1001][3];
int res[1001];

long long solve(int no)
{
  char *p;
  int i;
  long long acc;
  
  p=&node[no][0];
  // printf("n=%d k=%s\n",no,p);
  
  if(*p=='E')
    {
      for(i=0,acc=1;i<n-1;i++)
	if(from[i]==no)
	  acc = (acc * solve(to[i])) % DIV;
      if(p[1]=='?')
	  acc = (acc + 1) % DIV;
    }

  if(*p=='R')
    {
      for(i=0,acc=1;i<n-1;i++)
	if(from[i]==no)
	  {
	    acc = (acc * (1+solve(to[i]))) % DIV;
	    // printf("%d* %d %d\n",i,solve(to[i]),acc);
	  }
      if(p[1]!='?')
	acc  = (acc - 1) % DIV;
    }
  
  if(*p=='A')
    {
      for(i=0,acc=0;i<n-1;i++)
	if(from[i]==no)
	  {
	    acc = (acc + solve(to[i])) % DIV;
	  }
      if(p[1]=='?')
	acc  = (acc + 1)  % DIV;
    }
  res[no]=acc;
  return(acc);
}
dump()
{
  int i;
  for(i=1;i<=n;i++)
    printf("%d: %d\n",i,res[i]);
}
int main()
{
  int i,ret;
  
  scanf("%d",&n);
  for(i=1;i<=n;i++)
    scanf("%s",&node[i][0]);

  for(i=0;i<n;i++)
    scanf("%d %d",&from[i],&to[i]);
  ret=solve(1);
  #ifdef DEBUG
  dump();
  #endif
  printf("%d\n",ret);
  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	from
	.align 32
	.type	from, @object
	.size	from, 4004
from:
	.zero	4004
	.globl	to
	.align 32
	.type	to, @object
	.size	to, 4004
to:
	.zero	4004
	.globl	node
	.align 32
	.type	node, @object
	.size	node, 3003
node:
	.zero	3003
	.globl	res
	.align 32
	.type	res, @object
	.size	res, 4004
res:
	.zero	4004
	.text
	.globl	solve
	.type	solve, @function
solve:
.LFB0:
	.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
	movl	%edi, -36(%rbp)
	movl	-36(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	leaq	node(%rip), %rdx
	addq	%rdx, %rax
	movq	%rax, -8(%rbp)
	movq	-8(%rbp), %rax
	movzbl	(%rax), %eax
	cmpb	$69, %al
	jne	.L2
	movl	$0, -20(%rbp)
	movq	$1, -16(%rbp)
	jmp	.L3
.L5:
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	from(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -36(%rbp)
	jne	.L4
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	to(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, %edi
	call	solve
	imulq	-16(%rbp), %rax
	movq	%rax, %rcx
	movabsq	$-8543223828751151131, %rdx
	movq	%rcx, %rax
	imulq	%rdx
	leaq	(%rdx,%rcx), %rax
	sarq	$29, %rax
	movq	%rcx, %rdx
	sarq	$63, %rdx
	subq	%rdx, %rax
	movq	%rax, -16(%rbp)
	movq	-16(%rbp), %rax
	imulq	$1000000007, %rax, %rdx
	movq	%rcx, %rax
	subq	%rdx, %rax
	movq	%rax, -16(%rbp)
.L4:
	addl	$1, -20(%rbp)
.L3:
	movl	n(%rip), %eax
	subl	$1, %eax
	cmpl	%eax, -20(%rbp)
	jl	.L5
	movq	-8(%rbp), %rax
	addq	$1, %rax
	movzbl	(%rax), %eax
	cmpb	$63, %al
	jne	.L2
	movq	-16(%rbp), %rax
	leaq	1(%rax), %rcx
	movabsq	$-8543223828751151131, %rdx
	movq	%rcx, %rax
	imulq	%rdx
	leaq	(%rdx,%rcx), %rax
	sarq	$29, %rax
	movq	%rcx, %rdx
	sarq	$63, %rdx
	subq	%rdx, %rax
	movq	%rax, -16(%rbp)
	movq	-16(%rbp), %rax
	imulq	$1000000007, %rax, %rdx
	movq	%rcx, %rax
	subq	%rdx, %rax
	movq	%rax, -16(%rbp)
.L2:
	movq	-8(%rbp), %rax
	movzbl	(%rax), %eax
	cmpb	$82, %al
	jne	.L6
	movl	$0, -20(%rbp)
	movq	$1, -16(%rbp)
	jmp	.L7
.L9:
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	from(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -36(%rbp)
	jne	.L8
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	to(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, %edi
	call	solve
	addq	$1, %rax
	imulq	-16(%rbp), %rax
	movq	%rax, %rcx
	movabsq	$-8543223828751151131, %rdx
	movq	%rcx, %rax
	imulq	%rdx
	leaq	(%rdx,%rcx), %rax
	sarq	$29, %rax
	movq	%rcx, %rdx
	sarq	$63, %rdx
	subq	%rdx, %rax
	movq	%rax, -16(%rbp)
	movq	-16(%rbp), %rax
	imulq	$1000000007, %rax, %rdx
	movq	%rcx, %rax
	subq	%rdx, %rax
	movq	%rax, -16(%rbp)
.L8:
	addl	$1, -20(%rbp)
.L7:
	movl	n(%rip), %eax
	subl	$1, %eax
	cmpl	%eax, -20(%rbp)
	jl	.L9
	movq	-8(%rbp), %rax
	addq	$1, %rax
	movzbl	(%rax), %eax
	cmpb	$63, %al
	je	.L6
	movq	-16(%rbp), %rax
	leaq	-1(%rax), %rcx
	movabsq	$-8543223828751151131, %rdx
	movq	%rcx, %rax
	imulq	%rdx
	leaq	(%rdx,%rcx), %rax
	sarq	$29, %rax
	movq	%rcx, %rdx
	sarq	$63, %rdx
	subq	%rdx, %rax
	movq	%rax, -16(%rbp)
	movq	-16(%rbp), %rax
	imulq	$1000000007, %rax, %rdx
	movq	%rcx, %rax
	subq	%rdx, %rax
	movq	%rax, -16(%rbp)
.L6:
	movq	-8(%rbp), %rax
	movzbl	(%rax), %eax
	cmpb	$65, %al
	jne	.L10
	movl	$0, -20(%rbp)
	movq	$0, -16(%rbp)
	jmp	.L11
.L13:
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	from(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -36(%rbp)
	jne	.L12
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	to(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, %edi
	call	solve
	movq	-16(%rbp), %rdx
	leaq	(%rax,%rdx), %rcx
	movabsq	$-8543223828751151131, %rdx
	movq	%rcx, %rax
	imulq	%rdx
	leaq	(%rdx,%rcx), %rax
	sarq	$29, %rax
	movq	%rcx, %rdx
	sarq	$63, %rdx
	subq	%rdx, %rax
	movq	%rax, -16(%rbp)
	movq	-16(%rbp), %rax
	imulq	$1000000007, %rax, %rdx
	movq	%rcx, %rax
	subq	%rdx, %rax
	movq	%rax, -16(%rbp)
.L12:
	addl	$1, -20(%rbp)
.L11:
	movl	n(%rip), %eax
	subl	$1, %eax
	cmpl	%eax, -20(%rbp)
	jl	.L13
	movq	-8(%rbp), %rax
	addq	$1, %rax
	movzbl	(%rax), %eax
	cmpb	$63, %al
	jne	.L10
	movq	-16(%rbp), %rax
	leaq	1(%rax), %rcx
	movabsq	$-8543223828751151131, %rdx
	movq	%rcx, %rax
	imulq	%rdx
	leaq	(%rdx,%rcx), %rax
	sarq	$29, %rax
	movq	%rcx, %rdx
	sarq	$63, %rdx
	subq	%rdx, %rax
	movq	%rax, -16(%rbp)
	movq	-16(%rbp), %rax
	imulq	$1000000007, %rax, %rdx
	movq	%rcx, %rax
	subq	%rdx, %rax
	movq	%rax, -16(%rbp)
.L10:
	movq	-16(%rbp), %rax
	movl	%eax, %ecx
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	res(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movq	-16(%rbp), %rax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	solve, .-solve
	.section	.rodata
.LC0:
	.string	"%d: %d\n"
	.text
	.globl	dump
	.type	dump, @function
dump:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$16, %rsp
	movl	$1, -4(%rbp)
	jmp	.L16
.L17:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	res(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-4(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	addl	$1, -4(%rbp)
.L16:
	movl	n(%rip), %eax
	cmpl	%eax, -4(%rbp)
	jle	.L17
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	dump, .-dump
	.section	.rodata
.LC1:
	.string	"%d"
.LC2:
	.string	"%s"
.LC3:
	.string	"%d %d"
.LC4:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB2:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$16, %rsp
	leaq	n(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$1, -8(%rbp)
	jmp	.L19
.L20:
	movl	-8(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	leaq	node(%rip), %rdx
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -8(%rbp)
.L19:
	movl	n(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jle	.L20
	movl	$0, -8(%rbp)
	jmp	.L21
.L22:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	to(%rip), %rax
	addq	%rax, %rdx
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	from(%rip), %rax
	addq	%rcx, %rax
	movq	%rax, %rsi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -8(%rbp)
.L21:
	movl	n(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jl	.L22
	movl	$1, %edi
	call	solve
	movl	%eax, -4(%rbp)
	movl	-4(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC4(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2:
	.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
	.p2align 4
	.globl	solve
	.type	solve, @function
solve:
.LFB35:
	.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
	movslq	%edi, %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	leaq	0(%r13,%r13,2), %r14
	leaq	node(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	addq	%r12, %r14
	movq	%r13, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
	movzbl	(%r14), %esi
	cmpb	$69, %sil
	je	.L29
.L2:
	cmpb	$82, %sil
	je	.L30
.L8:
	cmpb	$65, %sil
	je	.L14
.L21:
	movl	%ebx, %edx
	movq	%rbx, %r12
.L15:
	leaq	res(%rip), %rax
	movl	%edx, (%rax,%r13,4)
	addq	$24, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	movq	%r12, %rax
	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
	.p2align 4,,10
	.p2align 3
.L29:
	.cfi_restore_state
	movl	n(%rip), %eax
	cmpl	$1, %eax
	jle	.L3
	xorl	%r8d, %r8d
	movl	$1, %ebx
	leaq	from(%rip), %r15
	leaq	to(%rip), %r9
.L7:
	cmpl	%ebp, (%r15,%r8,4)
	je	.L31
	addq	$1, %r8
	leal	-1(%rax), %edx
	cmpl	%r8d, %edx
	jg	.L7
.L6:
	leaq	0(%r13,%r13,2), %rax
	cmpb	$63, 1(%r14)
	movzbl	(%r12,%rax), %esi
	jne	.L2
	movabsq	$-8543223828751151131, %rdx
	leaq	1(%rbx), %rdi
	movq	%rdi, %rax
	imulq	%rdx
	movq	%rdi, %rax
	sarq	$63, %rax
	leaq	(%rdx,%rdi), %rbx
	sarq	$29, %rbx
	subq	%rax, %rbx
	imulq	$1000000007, %rbx, %rax
	subq	%rax, %rdi
	movq	%rdi, %rbx
	jmp	.L2
	.p2align 4,,10
	.p2align 3
.L14:
	movl	n(%rip), %eax
	xorl	%r12d, %r12d
	cmpl	$1, %eax
	jle	.L16
	xorl	%ecx, %ecx
	leaq	from(%rip), %r15
	leaq	to(%rip), %rbx
.L19:
	cmpl	%ebp, (%r15,%rcx,4)
	je	.L32
	addq	$1, %rcx
	leal	-1(%rax), %edx
	cmpl	%ecx, %edx
	jg	.L19
.L16:
	cmpb	$63, 1(%r14)
	jne	.L27
	movabsq	$-8543223828751151131, %rdx
	leaq	1(%r12), %rcx
	movq	%rcx, %rax
	imulq	%rdx
	movq	%rcx, %rax
	sarq	$63, %rax
	leaq	(%rdx,%rcx), %rbx
	sarq	$29, %rbx
	subq	%rax, %rbx
	imulq	$1000000007, %rbx, %rax
	subq	%rax, %rcx
	movq	%rcx, %r12
.L27:
	movl	%r12d, %edx
	jmp	.L15
	.p2align 4,,10
	.p2align 3
.L30:
	movl	n(%rip), %eax
	cmpl	$1, %eax
	jle	.L9
	xorl	%r8d, %r8d
	movl	$1, %ebx
	leaq	from(%rip), %r15
	leaq	to(%rip), %r9
.L13:
	cmpl	%ebp, (%r15,%r8,4)
	je	.L33
	addq	$1, %r8
	leal	-1(%rax), %edx
	cmpl	%r8d, %edx
	jg	.L13
.L12:
	leaq	0(%r13,%r13,2), %rax
	cmpb	$63, 1(%r14)
	movzbl	(%r12,%rax), %esi
	je	.L8
	movabsq	$-8543223828751151131, %rdx
	leaq	-1(%rbx), %rcx
	movq	%rcx, %rax
	imulq	%rdx
	movq	%rcx, %rax
	sarq	$63, %rax
	leaq	(%rdx,%rcx), %rbx
	sarq	$29, %rbx
	subq	%rax, %rbx
	imulq	$1000000007, %rbx, %rax
	subq	%rax, %rcx
	movq	%rcx, %rbx
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L33:
	movl	(%r9,%r8,4), %edi
	movq	%r8, 8(%rsp)
	call	solve
	movq	8(%rsp), %r8
	leaq	to(%rip), %r9
	leaq	1(%rax), %rsi
	movabsq	$-8543223828751151131, %rax
	imulq	%rbx, %rsi
	addq	$1, %r8
	imulq	%rsi
	movq	%rsi, %rax
	sarq	$63, %rax
	leaq	(%rdx,%rsi), %rbx
	sarq	$29, %rbx
	subq	%rax, %rbx
	imulq	$1000000007, %rbx, %rax
	subq	%rax, %rsi
	movl	n(%rip), %eax
	movq	%rsi, %rbx
	leal	-1(%rax), %edx
	cmpl	%r8d, %edx
	jg	.L13
	jmp	.L12
	.p2align 4,,10
	.p2align 3
.L32:
	movl	(%rbx,%rcx,4), %edi
	movq	%rcx, 8(%rsp)
	call	solve
	movq	8(%rsp), %rcx
	leaq	(%rax,%r12), %rdi
	movabsq	$-8543223828751151131, %rax
	imulq	%rdi
	movq	%rdi, %rax
	addq	$1, %rcx
	sarq	$63, %rax
	leaq	(%rdx,%rdi), %r12
	sarq	$29, %r12
	subq	%rax, %r12
	imulq	$1000000007, %r12, %rax
	subq	%rax, %rdi
	movl	n(%rip), %eax
	movq	%rdi, %r12
	leal	-1(%rax), %edx
	cmpl	%ecx, %edx
	jg	.L19
	jmp	.L16
	.p2align 4,,10
	.p2align 3
.L31:
	movl	(%r9,%r8,4), %edi
	movq	%r8, 8(%rsp)
	call	solve
	movq	8(%rsp), %r8
	leaq	to(%rip), %r9
	imulq	%rbx, %rax
	addq	$1, %r8
	movq	%rax, %rsi
	movabsq	$-8543223828751151131, %rax
	imulq	%rsi
	movq	%rsi, %rax
	sarq	$63, %rax
	leaq	(%rdx,%rsi), %rbx
	sarq	$29, %rbx
	subq	%rax, %rbx
	imulq	$1000000007, %rbx, %rax
	subq	%rax, %rsi
	movl	n(%rip), %eax
	movq	%rsi, %rbx
	leal	-1(%rax), %edx
	cmpl	%r8d, %edx
	jg	.L7
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L9:
	xorl	%ebx, %ebx
	cmpb	$63, 1(%r14)
	movl	$1, %edx
	movl	$1, %r12d
	jne	.L21
	jmp	.L15
	.p2align 4,,10
	.p2align 3
.L3:
	xorl	%ebx, %ebx
	cmpb	$63, 1(%r14)
	sete	%bl
	addq	$1, %rbx
	jmp	.L21
	.cfi_endproc
.LFE35:
	.size	solve, .-solve
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d: %d\n"
	.text
	.p2align 4
	.globl	dump
	.type	dump, @function
dump:
.LFB36:
	.cfi_startproc
	endbr64
	movl	n(%rip), %eax
	testl	%eax, %eax
	jle	.L39
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	leaq	res(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	leaq	.LC0(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	movl	$1, %ebx
	.p2align 4,,10
	.p2align 3
.L36:
	movl	(%r12,%rbx,4), %ecx
	movl	%ebx, %edx
	xorl	%eax, %eax
	movq	%rbp, %rsi
	movl	$1, %edi
	addq	$1, %rbx
	call	__printf_chk@PLT
	cmpl	%ebx, n(%rip)
	jge	.L36
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L39:
	.cfi_restore 3
	.cfi_restore 6
	.cfi_restore 12
	ret
	.cfi_endproc
.LFE36:
	.size	dump, .-dump
	.section	.rodata.str1.1
.LC1:
	.string	"%d"
.LC2:
	.string	"%d\n"
.LC3:
	.string	"%s"
.LC4:
	.string	"%d %d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB37:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	leaq	n(%rip), %rsi
	leaq	.LC1(%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
	subq	$8, %rsp
	.cfi_def_cfa_offset 48
	call	__isoc99_scanf@PLT
	movl	n(%rip), %eax
	testl	%eax, %eax
	jle	.L45
	leaq	3+node(%rip), %rbp
	movl	$1, %ebx
	leaq	.LC3(%rip), %r12
	.p2align 4,,10
	.p2align 3
.L44:
	movq	%rbp, %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	addl	$1, %ebx
	call	__isoc99_scanf@PLT
	movl	n(%rip), %eax
	addq	$3, %rbp
	cmpl	%ebx, %eax
	jge	.L44
	testl	%eax, %eax
	jle	.L45
	leaq	from(%rip), %rbp
	xorl	%ebx, %ebx
	leaq	to(%rip), %r13
	leaq	.LC4(%rip), %r12
	.p2align 4,,10
	.p2align 3
.L46:
	leaq	0(%r13,%rbx,4), %rdx
	movq	%rbp, %rsi
	xorl	%eax, %eax
	movq	%r12, %rdi
	call	__isoc99_scanf@PLT
	addq	$1, %rbx
	addq	$4, %rbp
	cmpl	%ebx, n(%rip)
	jg	.L46
.L45:
	movl	$1, %edi
	call	solve
	leaq	.LC2(%rip), %rsi
	movl	$1, %edi
	movl	%eax, %edx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	addq	$8, %rsp
	.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
	.cfi_endproc
.LFE37:
	.size	main, .-main
	.globl	res
	.bss
	.align 32
	.type	res, @object
	.size	res, 4004
res:
	.zero	4004
	.globl	node
	.align 32
	.type	node, @object
	.size	node, 3003
node:
	.zero	3003
	.globl	to
	.align 32
	.type	to, @object
	.size	to, 4004
to:
	.zero	4004
	.globl	from
	.align 32
	.type	from, @object
	.size	from, 4004
from:
	.zero	4004
	.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
	.p2align 4
	.globl	solve
	.type	solve, @function
solve:
.LFB35:
	.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
	movslq	%edi, %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	leaq	0(%r13,%r13,2), %r14
	leaq	node(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	addq	%r12, %r14
	movq	%r13, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
	movzbl	(%r14), %esi
	cmpb	$69, %sil
	je	.L29
.L2:
	cmpb	$82, %sil
	je	.L30
.L8:
	cmpb	$65, %sil
	je	.L14
.L21:
	movl	%ebx, %edx
	movq	%rbx, %r12
.L15:
	leaq	res(%rip), %rax
	movl	%edx, (%rax,%r13,4)
	addq	$24, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	movq	%r12, %rax
	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
	.p2align 4,,10
	.p2align 3
.L29:
	.cfi_restore_state
	movl	n(%rip), %eax
	cmpl	$1, %eax
	jle	.L3
	xorl	%r8d, %r8d
	movl	$1, %ebx
	leaq	from(%rip), %r15
	leaq	to(%rip), %r9
.L7:
	cmpl	%ebp, (%r15,%r8,4)
	je	.L31
	addq	$1, %r8
	leal	-1(%rax), %edx
	cmpl	%r8d, %edx
	jg	.L7
.L6:
	leaq	0(%r13,%r13,2), %rax
	cmpb	$63, 1(%r14)
	movzbl	(%r12,%rax), %esi
	jne	.L2
	movabsq	$-8543223828751151131, %rdx
	leaq	1(%rbx), %rdi
	movq	%rdi, %rax
	imulq	%rdx
	movq	%rdi, %rax
	sarq	$63, %rax
	leaq	(%rdx,%rdi), %rbx
	sarq	$29, %rbx
	subq	%rax, %rbx
	imulq	$1000000007, %rbx, %rax
	subq	%rax, %rdi
	movq	%rdi, %rbx
	jmp	.L2
	.p2align 4,,10
	.p2align 3
.L14:
	movl	n(%rip), %eax
	xorl	%r12d, %r12d
	cmpl	$1, %eax
	jle	.L16
	xorl	%ecx, %ecx
	leaq	from(%rip), %r15
	leaq	to(%rip), %rbx
.L19:
	cmpl	%ebp, (%r15,%rcx,4)
	je	.L32
	addq	$1, %rcx
	leal	-1(%rax), %edx
	cmpl	%ecx, %edx
	jg	.L19
.L16:
	cmpb	$63, 1(%r14)
	jne	.L27
	movabsq	$-8543223828751151131, %rdx
	leaq	1(%r12), %rcx
	movq	%rcx, %rax
	imulq	%rdx
	movq	%rcx, %rax
	sarq	$63, %rax
	leaq	(%rdx,%rcx), %rbx
	sarq	$29, %rbx
	subq	%rax, %rbx
	imulq	$1000000007, %rbx, %rax
	subq	%rax, %rcx
	movq	%rcx, %r12
.L27:
	movl	%r12d, %edx
	jmp	.L15
	.p2align 4,,10
	.p2align 3
.L30:
	movl	n(%rip), %eax
	cmpl	$1, %eax
	jle	.L9
	xorl	%r8d, %r8d
	movl	$1, %ebx
	leaq	from(%rip), %r15
	leaq	to(%rip), %r9
.L13:
	cmpl	%ebp, (%r15,%r8,4)
	je	.L33
	addq	$1, %r8
	leal	-1(%rax), %edx
	cmpl	%r8d, %edx
	jg	.L13
.L12:
	leaq	0(%r13,%r13,2), %rax
	cmpb	$63, 1(%r14)
	movzbl	(%r12,%rax), %esi
	je	.L8
	movabsq	$-8543223828751151131, %rdx
	leaq	-1(%rbx), %rcx
	movq	%rcx, %rax
	imulq	%rdx
	movq	%rcx, %rax
	sarq	$63, %rax
	leaq	(%rdx,%rcx), %rbx
	sarq	$29, %rbx
	subq	%rax, %rbx
	imulq	$1000000007, %rbx, %rax
	subq	%rax, %rcx
	movq	%rcx, %rbx
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L33:
	movl	(%r9,%r8,4), %edi
	movq	%r8, 8(%rsp)
	call	solve
	movq	8(%rsp), %r8
	leaq	to(%rip), %r9
	leaq	1(%rax), %rsi
	movabsq	$-8543223828751151131, %rax
	imulq	%rbx, %rsi
	addq	$1, %r8
	imulq	%rsi
	movq	%rsi, %rax
	sarq	$63, %rax
	leaq	(%rdx,%rsi), %rbx
	sarq	$29, %rbx
	subq	%rax, %rbx
	imulq	$1000000007, %rbx, %rax
	subq	%rax, %rsi
	movl	n(%rip), %eax
	movq	%rsi, %rbx
	leal	-1(%rax), %edx
	cmpl	%r8d, %edx
	jg	.L13
	jmp	.L12
	.p2align 4,,10
	.p2align 3
.L32:
	movl	(%rbx,%rcx,4), %edi
	movq	%rcx, 8(%rsp)
	call	solve
	movq	8(%rsp), %rcx
	leaq	(%rax,%r12), %rdi
	movabsq	$-8543223828751151131, %rax
	imulq	%rdi
	movq	%rdi, %rax
	addq	$1, %rcx
	sarq	$63, %rax
	leaq	(%rdx,%rdi), %r12
	sarq	$29, %r12
	subq	%rax, %r12
	imulq	$1000000007, %r12, %rax
	subq	%rax, %rdi
	movl	n(%rip), %eax
	movq	%rdi, %r12
	leal	-1(%rax), %edx
	cmpl	%ecx, %edx
	jg	.L19
	jmp	.L16
	.p2align 4,,10
	.p2align 3
.L31:
	movl	(%r9,%r8,4), %edi
	movq	%r8, 8(%rsp)
	call	solve
	movq	8(%rsp), %r8
	leaq	to(%rip), %r9
	imulq	%rbx, %rax
	addq	$1, %r8
	movq	%rax, %rsi
	movabsq	$-8543223828751151131, %rax
	imulq	%rsi
	movq	%rsi, %rax
	sarq	$63, %rax
	leaq	(%rdx,%rsi), %rbx
	sarq	$29, %rbx
	subq	%rax, %rbx
	imulq	$1000000007, %rbx, %rax
	subq	%rax, %rsi
	movl	n(%rip), %eax
	movq	%rsi, %rbx
	leal	-1(%rax), %edx
	cmpl	%r8d, %edx
	jg	.L7
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L9:
	xorl	%ebx, %ebx
	cmpb	$63, 1(%r14)
	movl	$1, %edx
	movl	$1, %r12d
	jne	.L21
	jmp	.L15
	.p2align 4,,10
	.p2align 3
.L3:
	xorl	%ebx, %ebx
	cmpb	$63, 1(%r14)
	sete	%bl
	addq	$1, %rbx
	jmp	.L21
	.cfi_endproc
.LFE35:
	.size	solve, .-solve
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d: %d\n"
	.text
	.p2align 4
	.globl	dump
	.type	dump, @function
dump:
.LFB36:
	.cfi_startproc
	endbr64
	movl	n(%rip), %eax
	testl	%eax, %eax
	jle	.L39
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	leaq	res(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	leaq	.LC0(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	movl	$1, %ebx
	.p2align 4,,10
	.p2align 3
.L36:
	movl	(%r12,%rbx,4), %ecx
	movl	%ebx, %edx
	xorl	%eax, %eax
	movq	%rbp, %rsi
	movl	$1, %edi
	addq	$1, %rbx
	call	__printf_chk@PLT
	cmpl	%ebx, n(%rip)
	jge	.L36
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L39:
	.cfi_restore 3
	.cfi_restore 6
	.cfi_restore 12
	ret
	.cfi_endproc
.LFE36:
	.size	dump, .-dump
	.section	.rodata.str1.1
.LC1:
	.string	"%d"
.LC2:
	.string	"%d\n"
.LC3:
	.string	"%s"
.LC4:
	.string	"%d %d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB37:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	leaq	n(%rip), %rsi
	leaq	.LC1(%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
	subq	$8, %rsp
	.cfi_def_cfa_offset 48
	call	__isoc99_scanf@PLT
	movl	n(%rip), %eax
	testl	%eax, %eax
	jle	.L45
	leaq	3+node(%rip), %rbp
	movl	$1, %ebx
	leaq	.LC3(%rip), %r12
	.p2align 4,,10
	.p2align 3
.L44:
	movq	%rbp, %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	addl	$1, %ebx
	call	__isoc99_scanf@PLT
	movl	n(%rip), %eax
	addq	$3, %rbp
	cmpl	%ebx, %eax
	jge	.L44
	testl	%eax, %eax
	jle	.L45
	leaq	from(%rip), %rbp
	xorl	%ebx, %ebx
	leaq	to(%rip), %r13
	leaq	.LC4(%rip), %r12
	.p2align 4,,10
	.p2align 3
.L46:
	leaq	0(%r13,%rbx,4), %rdx
	movq	%rbp, %rsi
	xorl	%eax, %eax
	movq	%r12, %rdi
	call	__isoc99_scanf@PLT
	addq	$1, %rbx
	addq	$4, %rbp
	cmpl	%ebx, n(%rip)
	jg	.L46
.L45:
	movl	$1, %edi
	call	solve
	leaq	.LC2(%rip), %rsi
	movl	$1, %edi
	movl	%eax, %edx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	addq	$8, %rsp
	.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
	.cfi_endproc
.LFE37:
	.size	main, .-main
	.globl	res
	.bss
	.align 32
	.type	res, @object
	.size	res, 4004
res:
	.zero	4004
	.globl	node
	.align 32
	.type	node, @object
	.size	node, 3003
node:
	.zero	3003
	.globl	to
	.align 32
	.type	to, @object
	.size	to, 4004
to:
	.zero	4004
	.globl	from
	.align 32
	.type	from, @object
	.size	from, 4004
from:
	.zero	4004
	.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:

/*
  AOJ #0309
  title:New Drug Development
  @kankichi573
 */
#include <stdio.h>
#include <string.h>
#define DIV 1000000007
int n;
int from[1001],to[1001];
char node[1001][3];
int res[1001];

long long solve(int no)
{
  char *p;
  int i;
  long long acc;
  
  p=&node[no][0];
  // printf("n=%d k=%s\n",no,p);
  
  if(*p=='E')
    {
      for(i=0,acc=1;i<n-1;i++)
	if(from[i]==no)
	  acc = (acc * solve(to[i])) % DIV;
      if(p[1]=='?')
	  acc = (acc + 1) % DIV;
    }

  if(*p=='R')
    {
      for(i=0,acc=1;i<n-1;i++)
	if(from[i]==no)
	  {
	    acc = (acc * (1+solve(to[i]))) % DIV;
	    // printf("%d* %d %d\n",i,solve(to[i]),acc);
	  }
      if(p[1]!='?')
	acc  = (acc - 1) % DIV;
    }
  
  if(*p=='A')
    {
      for(i=0,acc=0;i<n-1;i++)
	if(from[i]==no)
	  {
	    acc = (acc + solve(to[i])) % DIV;
	  }
      if(p[1]=='?')
	acc  = (acc + 1)  % DIV;
    }
  res[no]=acc;
  return(acc);
}
dump()
{
  int i;
  for(i=1;i<=n;i++)
    printf("%d: %d\n",i,res[i]);
}
int main()
{
  int i,ret;
  
  scanf("%d",&n);
  for(i=1;i<=n;i++)
    scanf("%s",&node[i][0]);

  for(i=0;i<n;i++)
    scanf("%d %d",&from[i],&to[i]);
  ret=solve(1);
  #ifdef DEBUG
  dump();
  #endif
  printf("%d\n",ret);
  return(0);
}
12
A
E
E
E
R?
E?
E?
E
E
E
E?
E
1 2
1 3
1 4
2 5
4 6
4 7
5 8
5 9
7 10
7 11
11 12

11

Given the following C code and unoptimized assembly code, your task is to generate highly optimized x86-64 assembly code.
C Code:

```c
/*
  AOJ #0309
  title:New Drug Development
  @kankichi573
 */
#include <stdio.h>
#include <string.h>
#define DIV 1000000007
int n;
int from[1001],to[1001];
char node[1001][3];
int res[1001];

long long solve(int no)
{
  char *p;
  int i;
  long long acc;
  
  p=&node[no][0];
  // printf("n=%d k=%s\n",no,p);
  
  if(*p=='E')
    {
      for(i=0,acc=1;i<n-1;i++)
	if(from[i]==no)
	  acc = (acc * solve(to[i])) % DIV;
      if(p[1]=='?')
	  acc = (acc + 1) % DIV;
    }

  if(*p=='R')
    {
      for(i=0,acc=1;i<n-1;i++)
	if(from[i]==no)
	  {
	    acc = (acc * (1+solve(to[i]))) % DIV;
	    // printf("%d* %d %d\n",i,solve(to[i]),acc);
	  }
      if(p[1]!='?')
	acc  = (acc - 1) % DIV;
    }
  
  if(*p=='A')
    {
      for(i=0,acc=0;i<n-1;i++)
	if(from[i]==no)
	  {
	    acc = (acc + solve(to[i])) % DIV;
	  }
      if(p[1]=='?')
	acc  = (acc + 1)  % DIV;
    }
  res[no]=acc;
  return(acc);
}
dump()
{
  int i;
  for(i=1;i<=n;i++)
    printf("%d: %d\n",i,res[i]);
}
int main()
{
  int i,ret;
  
  scanf("%d",&n);
  for(i=1;i<=n;i++)
    scanf("%s",&node[i][0]);

  for(i=0;i<n;i++)
    scanf("%d %d",&from[i],&to[i]);
  ret=solve(1);
  #ifdef DEBUG
  dump();
  #endif
  printf("%d\n",ret);
  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	from
	.align 32
	.type	from, @object
	.size	from, 4004
from:
	.zero	4004
	.globl	to
	.align 32
	.type	to, @object
	.size	to, 4004
to:
	.zero	4004
	.globl	node
	.align 32
	.type	node, @object
	.size	node, 3003
node:
	.zero	3003
	.globl	res
	.align 32
	.type	res, @object
	.size	res, 4004
res:
	.zero	4004
	.text
	.globl	solve
	.type	solve, @function
solve:
.LFB0:
	.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
	movl	%edi, -36(%rbp)
	movl	-36(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	leaq	node(%rip), %rdx
	addq	%rdx, %rax
	movq	%rax, -8(%rbp)
	movq	-8(%rbp), %rax
	movzbl	(%rax), %eax
	cmpb	$69, %al
	jne	.L2
	movl	$0, -20(%rbp)
	movq	$1, -16(%rbp)
	jmp	.L3
.L5:
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	from(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -36(%rbp)
	jne	.L4
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	to(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, %edi
	call	solve
	imulq	-16(%rbp), %rax
	movq	%rax, %rcx
	movabsq	$-8543223828751151131, %rdx
	movq	%rcx, %rax
	imulq	%rdx
	leaq	(%rdx,%rcx), %rax
	sarq	$29, %rax
	movq	%rcx, %rdx
	sarq	$63, %rdx
	subq	%rdx, %rax
	movq	%rax, -16(%rbp)
	movq	-16(%rbp), %rax
	imulq	$1000000007, %rax, %rdx
	movq	%rcx, %rax
	subq	%rdx, %rax
	movq	%rax, -16(%rbp)
.L4:
	addl	$1, -20(%rbp)
.L3:
	movl	n(%rip), %eax
	subl	$1, %eax
	cmpl	%eax, -20(%rbp)
	jl	.L5
	movq	-8(%rbp), %rax
	addq	$1, %rax
	movzbl	(%rax), %eax
	cmpb	$63, %al
	jne	.L2
	movq	-16(%rbp), %rax
	leaq	1(%rax), %rcx
	movabsq	$-8543223828751151131, %rdx
	movq	%rcx, %rax
	imulq	%rdx
	leaq	(%rdx,%rcx), %rax
	sarq	$29, %rax
	movq	%rcx, %rdx
	sarq	$63, %rdx
	subq	%rdx, %rax
	movq	%rax, -16(%rbp)
	movq	-16(%rbp), %rax
	imulq	$1000000007, %rax, %rdx
	movq	%rcx, %rax
	subq	%rdx, %rax
	movq	%rax, -16(%rbp)
.L2:
	movq	-8(%rbp), %rax
	movzbl	(%rax), %eax
	cmpb	$82, %al
	jne	.L6
	movl	$0, -20(%rbp)
	movq	$1, -16(%rbp)
	jmp	.L7
.L9:
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	from(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -36(%rbp)
	jne	.L8
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	to(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, %edi
	call	solve
	addq	$1, %rax
	imulq	-16(%rbp), %rax
	movq	%rax, %rcx
	movabsq	$-8543223828751151131, %rdx
	movq	%rcx, %rax
	imulq	%rdx
	leaq	(%rdx,%rcx), %rax
	sarq	$29, %rax
	movq	%rcx, %rdx
	sarq	$63, %rdx
	subq	%rdx, %rax
	movq	%rax, -16(%rbp)
	movq	-16(%rbp), %rax
	imulq	$1000000007, %rax, %rdx
	movq	%rcx, %rax
	subq	%rdx, %rax
	movq	%rax, -16(%rbp)
.L8:
	addl	$1, -20(%rbp)
.L7:
	movl	n(%rip), %eax
	subl	$1, %eax
	cmpl	%eax, -20(%rbp)
	jl	.L9
	movq	-8(%rbp), %rax
	addq	$1, %rax
	movzbl	(%rax), %eax
	cmpb	$63, %al
	je	.L6
	movq	-16(%rbp), %rax
	leaq	-1(%rax), %rcx
	movabsq	$-8543223828751151131, %rdx
	movq	%rcx, %rax
	imulq	%rdx
	leaq	(%rdx,%rcx), %rax
	sarq	$29, %rax
	movq	%rcx, %rdx
	sarq	$63, %rdx
	subq	%rdx, %rax
	movq	%rax, -16(%rbp)
	movq	-16(%rbp), %rax
	imulq	$1000000007, %rax, %rdx
	movq	%rcx, %rax
	subq	%rdx, %rax
	movq	%rax, -16(%rbp)
.L6:
	movq	-8(%rbp), %rax
	movzbl	(%rax), %eax
	cmpb	$65, %al
	jne	.L10
	movl	$0, -20(%rbp)
	movq	$0, -16(%rbp)
	jmp	.L11
.L13:
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	from(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -36(%rbp)
	jne	.L12
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	to(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, %edi
	call	solve
	movq	-16(%rbp), %rdx
	leaq	(%rax,%rdx), %rcx
	movabsq	$-8543223828751151131, %rdx
	movq	%rcx, %rax
	imulq	%rdx
	leaq	(%rdx,%rcx), %rax
	sarq	$29, %rax
	movq	%rcx, %rdx
	sarq	$63, %rdx
	subq	%rdx, %rax
	movq	%rax, -16(%rbp)
	movq	-16(%rbp), %rax
	imulq	$1000000007, %rax, %rdx
	movq	%rcx, %rax
	subq	%rdx, %rax
	movq	%rax, -16(%rbp)
.L12:
	addl	$1, -20(%rbp)
.L11:
	movl	n(%rip), %eax
	subl	$1, %eax
	cmpl	%eax, -20(%rbp)
	jl	.L13
	movq	-8(%rbp), %rax
	addq	$1, %rax
	movzbl	(%rax), %eax
	cmpb	$63, %al
	jne	.L10
	movq	-16(%rbp), %rax
	leaq	1(%rax), %rcx
	movabsq	$-8543223828751151131, %rdx
	movq	%rcx, %rax
	imulq	%rdx
	leaq	(%rdx,%rcx), %rax
	sarq	$29, %rax
	movq	%rcx, %rdx
	sarq	$63, %rdx
	subq	%rdx, %rax
	movq	%rax, -16(%rbp)
	movq	-16(%rbp), %rax
	imulq	$1000000007, %rax, %rdx
	movq	%rcx, %rax
	subq	%rdx, %rax
	movq	%rax, -16(%rbp)
.L10:
	movq	-16(%rbp), %rax
	movl	%eax, %ecx
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	res(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movq	-16(%rbp), %rax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	solve, .-solve
	.section	.rodata
.LC0:
	.string	"%d: %d\n"
	.text
	.globl	dump
	.type	dump, @function
dump:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$16, %rsp
	movl	$1, -4(%rbp)
	jmp	.L16
.L17:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	res(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-4(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	addl	$1, -4(%rbp)
.L16:
	movl	n(%rip), %eax
	cmpl	%eax, -4(%rbp)
	jle	.L17
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	dump, .-dump
	.section	.rodata
.LC1:
	.string	"%d"
.LC2:
	.string	"%s"
.LC3:
	.string	"%d %d"
.LC4:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB2:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$16, %rsp
	leaq	n(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$1, -8(%rbp)
	jmp	.L19
.L20:
	movl	-8(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	leaq	node(%rip), %rdx
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -8(%rbp)
.L19:
	movl	n(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jle	.L20
	movl	$0, -8(%rbp)
	jmp	.L21
.L22:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	to(%rip), %rax
	addq	%rax, %rdx
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	from(%rip), %rax
	addq	%rcx, %rax
	movq	%rax, %rsi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -8(%rbp)
.L21:
	movl	n(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jl	.L22
	movl	$1, %edi
	call	solve
	movl	%eax, -4(%rbp)
	movl	-4(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC4(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2:
	.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	from
	.align 32
	.type	from, @object
	.size	from, 4004
from:
	.zero	4004
	.globl	to
	.align 32
	.type	to, @object
	.size	to, 4004
to:
	.zero	4004
	.globl	node
	.align 32
	.type	node, @object
	.size	node, 3003
node:
	.zero	3003
	.globl	res
	.align 32
	.type	res, @object
	.size	res, 4004
res:
	.zero	4004
	.text
	.globl	solve
	.type	solve, @function
solve:
.LFB0:
	.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
	movl	%edi, -36(%rbp)
	movl	-36(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	leaq	node(%rip), %rdx
	addq	%rdx, %rax
	movq	%rax, -8(%rbp)
	movq	-8(%rbp), %rax
	movzbl	(%rax), %eax
	cmpb	$69, %al
	jne	.L2
	movl	$0, -20(%rbp)
	movq	$1, -16(%rbp)
	jmp	.L3
.L5:
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	from(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -36(%rbp)
	jne	.L4
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	to(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, %edi
	call	solve
	imulq	-16(%rbp), %rax
	movq	%rax, %rcx
	movabsq	$-8543223828751151131, %rdx
	movq	%rcx, %rax
	imulq	%rdx
	leaq	(%rdx,%rcx), %rax
	sarq	$29, %rax
	movq	%rcx, %rdx
	sarq	$63, %rdx
	subq	%rdx, %rax
	movq	%rax, -16(%rbp)
	movq	-16(%rbp), %rax
	imulq	$1000000007, %rax, %rdx
	movq	%rcx, %rax
	subq	%rdx, %rax
	movq	%rax, -16(%rbp)
.L4:
	addl	$1, -20(%rbp)
.L3:
	movl	n(%rip), %eax
	subl	$1, %eax
	cmpl	%eax, -20(%rbp)
	jl	.L5
	movq	-8(%rbp), %rax
	addq	$1, %rax
	movzbl	(%rax), %eax
	cmpb	$63, %al
	jne	.L2
	movq	-16(%rbp), %rax
	leaq	1(%rax), %rcx
	movabsq	$-8543223828751151131, %rdx
	movq	%rcx, %rax
	imulq	%rdx
	leaq	(%rdx,%rcx), %rax
	sarq	$29, %rax
	movq	%rcx, %rdx
	sarq	$63, %rdx
	subq	%rdx, %rax
	movq	%rax, -16(%rbp)
	movq	-16(%rbp), %rax
	imulq	$1000000007, %rax, %rdx
	movq	%rcx, %rax
	subq	%rdx, %rax
	movq	%rax, -16(%rbp)
.L2:
	movq	-8(%rbp), %rax
	movzbl	(%rax), %eax
	cmpb	$82, %al
	jne	.L6
	movl	$0, -20(%rbp)
	movq	$1, -16(%rbp)
	jmp	.L7
.L9:
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	from(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -36(%rbp)
	jne	.L8
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	to(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, %edi
	call	solve
	addq	$1, %rax
	imulq	-16(%rbp), %rax
	movq	%rax, %rcx
	movabsq	$-8543223828751151131, %rdx
	movq	%rcx, %rax
	imulq	%rdx
	leaq	(%rdx,%rcx), %rax
	sarq	$29, %rax
	movq	%rcx, %rdx
	sarq	$63, %rdx
	subq	%rdx, %rax
	movq	%rax, -16(%rbp)
	movq	-16(%rbp), %rax
	imulq	$1000000007, %rax, %rdx
	movq	%rcx, %rax
	subq	%rdx, %rax
	movq	%rax, -16(%rbp)
.L8:
	addl	$1, -20(%rbp)
.L7:
	movl	n(%rip), %eax
	subl	$1, %eax
	cmpl	%eax, -20(%rbp)
	jl	.L9
	movq	-8(%rbp), %rax
	addq	$1, %rax
	movzbl	(%rax), %eax
	cmpb	$63, %al
	je	.L6
	movq	-16(%rbp), %rax
	leaq	-1(%rax), %rcx
	movabsq	$-8543223828751151131, %rdx
	movq	%rcx, %rax
	imulq	%rdx
	leaq	(%rdx,%rcx), %rax
	sarq	$29, %rax
	movq	%rcx, %rdx
	sarq	$63, %rdx
	subq	%rdx, %rax
	movq	%rax, -16(%rbp)
	movq	-16(%rbp), %rax
	imulq	$1000000007, %rax, %rdx
	movq	%rcx, %rax
	subq	%rdx, %rax
	movq	%rax, -16(%rbp)
.L6:
	movq	-8(%rbp), %rax
	movzbl	(%rax), %eax
	cmpb	$65, %al
	jne	.L10
	movl	$0, -20(%rbp)
	movq	$0, -16(%rbp)
	jmp	.L11
.L13:
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	from(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -36(%rbp)
	jne	.L12
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	to(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, %edi
	call	solve
	movq	-16(%rbp), %rdx
	leaq	(%rax,%rdx), %rcx
	movabsq	$-8543223828751151131, %rdx
	movq	%rcx, %rax
	imulq	%rdx
	leaq	(%rdx,%rcx), %rax
	sarq	$29, %rax
	movq	%rcx, %rdx
	sarq	$63, %rdx
	subq	%rdx, %rax
	movq	%rax, -16(%rbp)
	movq	-16(%rbp), %rax
	imulq	$1000000007, %rax, %rdx
	movq	%rcx, %rax
	subq	%rdx, %rax
	movq	%rax, -16(%rbp)
.L12:
	addl	$1, -20(%rbp)
.L11:
	movl	n(%rip), %eax
	subl	$1, %eax
	cmpl	%eax, -20(%rbp)
	jl	.L13
	movq	-8(%rbp), %rax
	addq	$1, %rax
	movzbl	(%rax), %eax
	cmpb	$63, %al
	jne	.L10
	movq	-16(%rbp), %rax
	leaq	1(%rax), %rcx
	movabsq	$-8543223828751151131, %rdx
	movq	%rcx, %rax
	imulq	%rdx
	leaq	(%rdx,%rcx), %rax
	sarq	$29, %rax
	movq	%rcx, %rdx
	sarq	$63, %rdx
	subq	%rdx, %rax
	movq	%rax, -16(%rbp)
	movq	-16(%rbp), %rax
	imulq	$1000000007, %rax, %rdx
	movq	%rcx, %rax
	subq	%rdx, %rax
	movq	%rax, -16(%rbp)
.L10:
	movq	-16(%rbp), %rax
	movl	%eax, %ecx
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	res(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movq	-16(%rbp), %rax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	solve, .-solve
	.section	.rodata
.LC0:
	.string	"%d: %d\n"
	.text
	.globl	dump
	.type	dump, @function
dump:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$16, %rsp
	movl	$1, -4(%rbp)
	jmp	.L16
.L17:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	res(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-4(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	addl	$1, -4(%rbp)
.L16:
	movl	n(%rip), %eax
	cmpl	%eax, -4(%rbp)
	jle	.L17
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	dump, .-dump
	.section	.rodata
.LC1:
	.string	"%d"
.LC2:
	.string	"%s"
.LC3:
	.string	"%d %d"
.LC4:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB2:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$16, %rsp
	leaq	n(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$1, -8(%rbp)
	jmp	.L19
.L20:
	movl	-8(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	leaq	node(%rip), %rdx
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -8(%rbp)
.L19:
	movl	n(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jle	.L20
	movl	$0, -8(%rbp)
	jmp	.L21
.L22:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	to(%rip), %rax
	addq	%rax, %rdx
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	from(%rip), %rax
	addq	%rcx, %rax
	movq	%rax, %rsi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -8(%rbp)
.L21:
	movl	n(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jl	.L22
	movl	$1, %edi
	call	solve
	movl	%eax, -4(%rbp)
	movl	-4(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC4(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2:
	.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:
