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 <stdlib.h>
#include <string.h>
char a[60000];
typedef struct list ls;
struct node {
  char str[11];
  int lev;
  struct node* next;
} *qs,*qe;
typedef struct node st;
int add(char* buf)
{
  int l = strlen(buf);
  int i = 0,j=0;
  for(i=0;i<l-1;i++){
    switch(buf[i]){
    case 'r':
      j = j*3;
      break;
    case 'g':
      j = j*3+1;
      break;
    case 'b':
      j = j*3+2;
      break;
    }
  }
  if(a[j] == 1) return 0;
  a[j] = 1;
  return 1;
}
void push(char* buf,int l)
{
  if(qe == NULL) {
    qe = (st *)(malloc(sizeof(st)));
    qs = qe;
  } else {
    qe->next = (st *)(malloc(sizeof(st)));
    qe = qe->next;
  }
  strcpy(qe->str,buf);
  qe->lev = l;
  qe->next = NULL;
}
struct node* pop()
{
  st* p = qs;
  if(qs == NULL) return NULL;
  qs = qs->next;
  if(qs == NULL) qe = NULL;
  return p;
}
void flush()
{
  st* q=qs;
  while(q!=NULL){
    qs = qs->next;
    free(q);
    q = qs;
  }
  qe = NULL;
  memset(a,0,sizeof(a));
}
int search()
{
  int i,l;
  st *p;
  char s[11];
  char c;
  while((p = pop()) != NULL){
    l = strlen(p->str);
    c = (p->str)[0];
    for(i=1; i<l; i++){
      if((p->str)[i] != c) break;
    }
    if(i==l) return p->lev;
    for(i=0; i<l-1; i++){
      strcpy(s,p->str);
      if((s[i] == 'r' && s[i+1] == 'g')
	 || (s[i] == 'g' && s[i+1] == 'r')){
	s[i] = s[i+1] = 'b';
	if(add(s)) push(s,p->lev+1);
      } else if((s[i] == 'r' && s[i+1] == 'b')
	 || (s[i] == 'b' && s[i+1] == 'r')){
	s[i] = s[i+1] = 'g';
	if(add(s)) push(s,p->lev+1);
      } else if((s[i] == 'b' && s[i+1] == 'g')
	 || (s[i] == 'g' && s[i+1] == 'b')){
	s[i] = s[i+1] = 'r';
	if(add(s)) push(s,p->lev+1);
      }
    }
    free(p);
  }
  return -1;
}
int main()
{
  char buf[11];
  int n;
  for(;;){
    scanf("%s",buf);
    if(strcmp(buf,"0") == 0) break;
    flush();
    add(buf);
    push(buf,0);
    n = search();
    if(n==-1) printf("NA\n");
    else printf("%d\n",n);
  }
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	a
	.bss
	.align 32
	.type	a, @object
	.size	a, 60000
a:
	.zero	60000
	.globl	qs
	.align 8
	.type	qs, @object
	.size	qs, 8
qs:
	.zero	8
	.globl	qe
	.align 8
	.type	qe, @object
	.size	qe, 8
qe:
	.zero	8
	.text
	.globl	add
	.type	add, @function
add:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movq	%rdi, -24(%rbp)
	movq	-24(%rbp), %rax
	movq	%rax, %rdi
	call	strlen@PLT
	movl	%eax, -4(%rbp)
	movl	$0, -12(%rbp)
	movl	$0, -8(%rbp)
	movl	$0, -12(%rbp)
	jmp	.L2
.L7:
	movl	-12(%rbp), %eax
	movslq	%eax, %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	movsbl	%al, %eax
	cmpl	$114, %eax
	je	.L3
	cmpl	$114, %eax
	jg	.L4
	cmpl	$98, %eax
	je	.L5
	cmpl	$103, %eax
	je	.L6
	jmp	.L4
.L3:
	movl	-8(%rbp), %edx
	movl	%edx, %eax
	addl	%eax, %eax
	addl	%edx, %eax
	movl	%eax, -8(%rbp)
	jmp	.L4
.L6:
	movl	-8(%rbp), %edx
	movl	%edx, %eax
	addl	%eax, %eax
	addl	%edx, %eax
	addl	$1, %eax
	movl	%eax, -8(%rbp)
	jmp	.L4
.L5:
	movl	-8(%rbp), %edx
	movl	%edx, %eax
	addl	%eax, %eax
	addl	%edx, %eax
	addl	$2, %eax
	movl	%eax, -8(%rbp)
	nop
.L4:
	addl	$1, -12(%rbp)
.L2:
	movl	-4(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -12(%rbp)
	jl	.L7
	movl	-8(%rbp), %eax
	cltq
	leaq	a(%rip), %rdx
	movzbl	(%rax,%rdx), %eax
	cmpb	$1, %al
	jne	.L8
	movl	$0, %eax
	jmp	.L9
.L8:
	movl	-8(%rbp), %eax
	cltq
	leaq	a(%rip), %rdx
	movb	$1, (%rax,%rdx)
	movl	$1, %eax
.L9:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	add, .-add
	.globl	push
	.type	push, @function
push:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%rbx
	subq	$24, %rsp
	.cfi_offset 3, -24
	movq	%rdi, -24(%rbp)
	movl	%esi, -28(%rbp)
	movq	qe(%rip), %rax
	testq	%rax, %rax
	jne	.L11
	movl	$24, %edi
	call	malloc@PLT
	movq	%rax, qe(%rip)
	movq	qe(%rip), %rax
	movq	%rax, qs(%rip)
	jmp	.L12
.L11:
	movq	qe(%rip), %rbx
	movl	$24, %edi
	call	malloc@PLT
	movq	%rax, 16(%rbx)
	movq	qe(%rip), %rax
	movq	16(%rax), %rax
	movq	%rax, qe(%rip)
.L12:
	movq	qe(%rip), %rax
	movq	%rax, %rdx
	movq	-24(%rbp), %rax
	movq	%rax, %rsi
	movq	%rdx, %rdi
	call	strcpy@PLT
	movq	qe(%rip), %rax
	movl	-28(%rbp), %edx
	movl	%edx, 12(%rax)
	movq	qe(%rip), %rax
	movq	$0, 16(%rax)
	nop
	movq	-8(%rbp), %rbx
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	push, .-push
	.globl	pop
	.type	pop, @function
pop:
.LFB8:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	qs(%rip), %rax
	movq	%rax, -8(%rbp)
	movq	qs(%rip), %rax
	testq	%rax, %rax
	jne	.L14
	movl	$0, %eax
	jmp	.L15
.L14:
	movq	qs(%rip), %rax
	movq	16(%rax), %rax
	movq	%rax, qs(%rip)
	movq	qs(%rip), %rax
	testq	%rax, %rax
	jne	.L16
	movq	$0, qe(%rip)
.L16:
	movq	-8(%rbp), %rax
.L15:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.size	pop, .-pop
	.globl	flush
	.type	flush, @function
flush:
.LFB9:
	.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
	movq	qs(%rip), %rax
	movq	%rax, -8(%rbp)
	jmp	.L18
.L19:
	movq	qs(%rip), %rax
	movq	16(%rax), %rax
	movq	%rax, qs(%rip)
	movq	-8(%rbp), %rax
	movq	%rax, %rdi
	call	free@PLT
	movq	qs(%rip), %rax
	movq	%rax, -8(%rbp)
.L18:
	cmpq	$0, -8(%rbp)
	jne	.L19
	movq	$0, qe(%rip)
	movl	$60000, %edx
	movl	$0, %esi
	leaq	a(%rip), %rax
	movq	%rax, %rdi
	call	memset@PLT
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE9:
	.size	flush, .-flush
	.globl	search
	.type	search, @function
search:
.LFB10:
	.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
	jmp	.L21
.L41:
	movq	-32(%rbp), %rax
	movq	%rax, %rdi
	call	strlen@PLT
	movl	%eax, -36(%rbp)
	movq	-32(%rbp), %rax
	movzbl	(%rax), %eax
	movb	%al, -41(%rbp)
	movl	$1, -40(%rbp)
	jmp	.L22
.L25:
	movq	-32(%rbp), %rdx
	movl	-40(%rbp), %eax
	cltq
	movzbl	(%rdx,%rax), %eax
	cmpb	%al, -41(%rbp)
	jne	.L44
	addl	$1, -40(%rbp)
.L22:
	movl	-40(%rbp), %eax
	cmpl	-36(%rbp), %eax
	jl	.L25
	jmp	.L24
.L44:
	nop
.L24:
	movl	-40(%rbp), %eax
	cmpl	-36(%rbp), %eax
	jne	.L26
	movq	-32(%rbp), %rax
	movl	12(%rax), %eax
	jmp	.L42
.L26:
	movl	$0, -40(%rbp)
	jmp	.L28
.L40:
	movq	-32(%rbp), %rdx
	leaq	-19(%rbp), %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strcpy@PLT
	movl	-40(%rbp), %eax
	cltq
	movzbl	-19(%rbp,%rax), %eax
	cmpb	$114, %al
	jne	.L29
	movl	-40(%rbp), %eax
	addl	$1, %eax
	cltq
	movzbl	-19(%rbp,%rax), %eax
	cmpb	$103, %al
	je	.L30
.L29:
	movl	-40(%rbp), %eax
	cltq
	movzbl	-19(%rbp,%rax), %eax
	cmpb	$103, %al
	jne	.L31
	movl	-40(%rbp), %eax
	addl	$1, %eax
	cltq
	movzbl	-19(%rbp,%rax), %eax
	cmpb	$114, %al
	jne	.L31
.L30:
	movl	-40(%rbp), %eax
	addl	$1, %eax
	movslq	%eax, %rdx
	movb	$98, -19(%rbp,%rdx)
	cltq
	movzbl	-19(%rbp,%rax), %edx
	movl	-40(%rbp), %eax
	cltq
	movb	%dl, -19(%rbp,%rax)
	leaq	-19(%rbp), %rax
	movq	%rax, %rdi
	call	add
	testl	%eax, %eax
	je	.L33
	movq	-32(%rbp), %rax
	movl	12(%rax), %eax
	leal	1(%rax), %edx
	leaq	-19(%rbp), %rax
	movl	%edx, %esi
	movq	%rax, %rdi
	call	push
	jmp	.L33
.L31:
	movl	-40(%rbp), %eax
	cltq
	movzbl	-19(%rbp,%rax), %eax
	cmpb	$114, %al
	jne	.L34
	movl	-40(%rbp), %eax
	addl	$1, %eax
	cltq
	movzbl	-19(%rbp,%rax), %eax
	cmpb	$98, %al
	je	.L35
.L34:
	movl	-40(%rbp), %eax
	cltq
	movzbl	-19(%rbp,%rax), %eax
	cmpb	$98, %al
	jne	.L36
	movl	-40(%rbp), %eax
	addl	$1, %eax
	cltq
	movzbl	-19(%rbp,%rax), %eax
	cmpb	$114, %al
	jne	.L36
.L35:
	movl	-40(%rbp), %eax
	addl	$1, %eax
	movslq	%eax, %rdx
	movb	$103, -19(%rbp,%rdx)
	cltq
	movzbl	-19(%rbp,%rax), %edx
	movl	-40(%rbp), %eax
	cltq
	movb	%dl, -19(%rbp,%rax)
	leaq	-19(%rbp), %rax
	movq	%rax, %rdi
	call	add
	testl	%eax, %eax
	je	.L33
	movq	-32(%rbp), %rax
	movl	12(%rax), %eax
	leal	1(%rax), %edx
	leaq	-19(%rbp), %rax
	movl	%edx, %esi
	movq	%rax, %rdi
	call	push
	jmp	.L33
.L36:
	movl	-40(%rbp), %eax
	cltq
	movzbl	-19(%rbp,%rax), %eax
	cmpb	$98, %al
	jne	.L38
	movl	-40(%rbp), %eax
	addl	$1, %eax
	cltq
	movzbl	-19(%rbp,%rax), %eax
	cmpb	$103, %al
	je	.L39
.L38:
	movl	-40(%rbp), %eax
	cltq
	movzbl	-19(%rbp,%rax), %eax
	cmpb	$103, %al
	jne	.L33
	movl	-40(%rbp), %eax
	addl	$1, %eax
	cltq
	movzbl	-19(%rbp,%rax), %eax
	cmpb	$98, %al
	jne	.L33
.L39:
	movl	-40(%rbp), %eax
	addl	$1, %eax
	movslq	%eax, %rdx
	movb	$114, -19(%rbp,%rdx)
	cltq
	movzbl	-19(%rbp,%rax), %edx
	movl	-40(%rbp), %eax
	cltq
	movb	%dl, -19(%rbp,%rax)
	leaq	-19(%rbp), %rax
	movq	%rax, %rdi
	call	add
	testl	%eax, %eax
	je	.L33
	movq	-32(%rbp), %rax
	movl	12(%rax), %eax
	leal	1(%rax), %edx
	leaq	-19(%rbp), %rax
	movl	%edx, %esi
	movq	%rax, %rdi
	call	push
.L33:
	addl	$1, -40(%rbp)
.L28:
	movl	-36(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -40(%rbp)
	jl	.L40
	movq	-32(%rbp), %rax
	movq	%rax, %rdi
	call	free@PLT
.L21:
	movl	$0, %eax
	call	pop
	movq	%rax, -32(%rbp)
	cmpq	$0, -32(%rbp)
	jne	.L41
	movl	$-1, %eax
.L42:
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L43
	call	__stack_chk_fail@PLT
.L43:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE10:
	.size	search, .-search
	.section	.rodata
.LC0:
	.string	"%s"
.LC1:
	.string	"0"
.LC2:
	.string	"NA"
.LC3:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB11:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
.L50:
	leaq	-19(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	leaq	-19(%rbp), %rax
	leaq	.LC1(%rip), %rdx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	je	.L54
	movl	$0, %eax
	call	flush
	leaq	-19(%rbp), %rax
	movq	%rax, %rdi
	call	add
	leaq	-19(%rbp), %rax
	movl	$0, %esi
	movq	%rax, %rdi
	call	push
	movl	$0, %eax
	call	search
	movl	%eax, -24(%rbp)
	cmpl	$-1, -24(%rbp)
	jne	.L48
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	jmp	.L50
.L48:
	movl	-24(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L50
.L54:
	nop
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L52
	call	__stack_chk_fail@PLT
.L52:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE11:
	.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	add
	.type	add, @function
add:
.LFB51:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	movq	%rdi, %rbx
	call	strlen@PLT
	cmpl	$1, %eax
	jle	.L9
	subl	$2, %eax
	movq	%rbx, %rdi
	xorl	%edx, %edx
	leaq	1(%rbx,%rax), %rcx
	jmp	.L7
	.p2align 4,,10
	.p2align 3
.L15:
	cmpb	$98, %al
	je	.L14
.L6:
	addq	$1, %rdi
	cmpq	%rcx, %rdi
	je	.L2
.L7:
	movzbl	(%rdi), %eax
	cmpb	$103, %al
	je	.L3
	cmpb	$114, %al
	jne	.L15
	addq	$1, %rdi
	leal	(%rdx,%rdx,2), %edx
	cmpq	%rcx, %rdi
	jne	.L7
.L2:
	leaq	a(%rip), %rcx
	movslq	%edx, %rdx
	xorl	%eax, %eax
	cmpb	$1, (%rcx,%rdx)
	je	.L1
	movb	$1, (%rcx,%rdx)
	movl	$1, %eax
.L1:
	popq	%rbx
	.cfi_remember_state
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L3:
	.cfi_restore_state
	leal	1(%rdx,%rdx,2), %edx
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L14:
	leal	2(%rdx,%rdx,2), %edx
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L9:
	xorl	%edx, %edx
	jmp	.L2
	.cfi_endproc
.LFE51:
	.size	add, .-add
	.p2align 4
	.globl	push
	.type	push, @function
push:
.LFB52:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movq	qe(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	movq	%rdi, %rbp
	movl	$24, %edi
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	movl	%esi, %ebx
	testq	%r12, %r12
	je	.L20
	call	malloc@PLT
	movq	%rax, 16(%r12)
	movq	%rax, %rdi
	movq	%rax, qe(%rip)
.L18:
	movq	%rbp, %rsi
	movl	$11, %edx
	call	__strcpy_chk@PLT
	movq	qe(%rip), %rax
	movl	%ebx, 12(%rax)
	movq	$0, 16(%rax)
	popq	%rbx
	.cfi_remember_state
	.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
.L20:
	.cfi_restore_state
	call	malloc@PLT
	movq	%rax, qe(%rip)
	movq	%rax, %rdi
	movq	%rax, qs(%rip)
	jmp	.L18
	.cfi_endproc
.LFE52:
	.size	push, .-push
	.p2align 4
	.globl	pop
	.type	pop, @function
pop:
.LFB53:
	.cfi_startproc
	endbr64
	movq	qs(%rip), %rax
	testq	%rax, %rax
	je	.L21
	movq	16(%rax), %rdx
	movq	%rdx, qs(%rip)
	testq	%rdx, %rdx
	je	.L26
.L21:
	ret
	.p2align 4,,10
	.p2align 3
.L26:
	movq	$0, qe(%rip)
	ret
	.cfi_endproc
.LFE53:
	.size	pop, .-pop
	.p2align 4
	.globl	flush
	.type	flush, @function
flush:
.LFB54:
	.cfi_startproc
	endbr64
	subq	$8, %rsp
	.cfi_def_cfa_offset 16
	movq	qs(%rip), %rdi
	testq	%rdi, %rdi
	je	.L29
	.p2align 4,,10
	.p2align 3
.L28:
	movq	16(%rdi), %rax
	movq	%rax, qs(%rip)
	call	free@PLT
	movq	qs(%rip), %rdi
	testq	%rdi, %rdi
	jne	.L28
.L29:
	movl	$60000, %edx
	xorl	%esi, %esi
	leaq	a(%rip), %rdi
	movq	$0, qe(%rip)
	addq	$8, %rsp
	.cfi_def_cfa_offset 8
	jmp	memset@PLT
	.cfi_endproc
.LFE54:
	.size	flush, .-flush
	.p2align 4
	.globl	search
	.type	search, @function
search:
.LFB55:
	.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
	leaq	a(%rip), %r14
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$72, %rsp
	.cfi_def_cfa_offset 128
	movq	qs(%rip), %r15
	movq	%fs:40, %rax
	movq	%rax, 56(%rsp)
	xorl	%eax, %eax
	testq	%r15, %r15
	je	.L34
	.p2align 4,,10
	.p2align 3
.L35:
	movq	16(%r15), %rax
	movq	%rax, qs(%rip)
	testq	%rax, %rax
	je	.L344
.L143:
	movq	%r15, %rdi
	call	strlen@PLT
	movzbl	(%r15), %edx
	cmpl	$1, %eax
	jle	.L345
	cmpb	1(%r15), %dl
	jne	.L248
	cmpl	$2, %eax
	je	.L149
	cmpb	2(%r15), %dl
	jne	.L248
	cmpl	$3, %eax
	je	.L150
	cmpb	3(%r15), %dl
	jne	.L248
	cmpl	$4, %eax
	je	.L151
	cmpb	4(%r15), %dl
	jne	.L248
	cmpl	$5, %eax
	je	.L152
	cmpb	5(%r15), %dl
	jne	.L248
	cmpl	$6, %eax
	je	.L153
	cmpb	6(%r15), %dl
	jne	.L248
	cmpl	$7, %eax
	je	.L154
	cmpb	7(%r15), %dl
	jne	.L248
	cmpl	$8, %eax
	je	.L155
	cmpb	8(%r15), %dl
	jne	.L248
	cmpl	$9, %eax
	je	.L156
	cmpb	9(%r15), %dl
	jne	.L248
	cmpl	$10, %eax
	je	.L157
	cmpb	%dl, 10(%r15)
	jne	.L248
	movl	$11, %edx
.L37:
	cmpl	%edx, %eax
	je	.L38
.L248:
	leal	-1(%rax), %r12d
	leaq	46(%rsp), %rbx
	xorl	%ebp, %ebp
	leaq	45(%rsp), %r13
	jmp	.L141
	.p2align 4,,10
	.p2align 3
.L40:
	cmpb	$103, %al
	je	.L346
	cmpb	$98, %al
	jne	.L74
	movzbl	(%rbx), %eax
	cmpb	$114, %al
	je	.L77
	cmpb	$103, %al
	je	.L110
.L74:
	addq	$1, %rbx
	cmpl	%ebp, %r12d
	jle	.L142
.L141:
	movl	$11, %edx
	movq	%r15, %rsi
	movq	%r13, %rdi
	addl	$1, %ebp
	call	__strcpy_chk@PLT
	movzbl	-1(%rbx), %eax
	cmpb	$114, %al
	jne	.L40
	movzbl	(%rbx), %eax
	cmpb	$103, %al
	je	.L41
	cmpb	$98, %al
	jne	.L74
.L77:
	movb	$103, (%rbx)
	movb	$103, -1(%rbx)
.L342:
	movq	%r13, %rdi
	call	strlen@PLT
	leal	-1(%rax), %ecx
	movq	%rax, %rdx
	testl	%ecx, %ecx
	jle	.L162
	movzbl	45(%rsp), %esi
	movl	$2, %eax
	cmpb	$98, %sil
	je	.L112
	xorl	%eax, %eax
	cmpb	$103, %sil
	sete	%al
.L112:
	cmpl	$1, %ecx
	je	.L111
	movzbl	46(%rsp), %esi
	cmpb	$103, %sil
	je	.L114
	cmpb	$114, %sil
	je	.L115
	cmpb	$98, %sil
	je	.L347
.L116:
	cmpl	$2, %ecx
	je	.L111
	movzbl	47(%rsp), %esi
	cmpb	$103, %sil
	je	.L117
	cmpb	$114, %sil
	je	.L118
	cmpb	$98, %sil
	je	.L348
.L119:
	cmpl	$3, %ecx
	je	.L111
	movzbl	48(%rsp), %esi
	cmpb	$103, %sil
	je	.L120
	cmpb	$114, %sil
	je	.L121
	cmpb	$98, %sil
	je	.L349
.L122:
	cmpl	$4, %ecx
	je	.L111
	movzbl	49(%rsp), %esi
	cmpb	$103, %sil
	je	.L123
	cmpb	$114, %sil
	je	.L124
	cmpb	$98, %sil
	je	.L350
.L125:
	cmpl	$5, %ecx
	je	.L111
	movzbl	50(%rsp), %esi
	cmpb	$103, %sil
	je	.L126
	cmpb	$114, %sil
	je	.L127
	cmpb	$98, %sil
	je	.L351
.L128:
	cmpl	$6, %ecx
	je	.L111
	movzbl	51(%rsp), %esi
	cmpb	$103, %sil
	je	.L129
	cmpb	$114, %sil
	je	.L130
	cmpb	$98, %sil
	je	.L352
.L131:
	cmpl	$7, %ecx
	je	.L111
	movzbl	52(%rsp), %esi
	cmpb	$103, %sil
	je	.L132
	cmpb	$114, %sil
	je	.L133
	cmpb	$98, %sil
	je	.L353
.L134:
	cmpl	$9, %ecx
	jne	.L111
	movzbl	53(%rsp), %ecx
	cmpb	$103, %cl
	je	.L135
	cmpb	$114, %cl
	je	.L136
	cmpb	$98, %cl
	je	.L354
.L111:
	cltq
	cmpb	$1, (%r14,%rax)
	je	.L74
	movb	$1, (%r14,%rax)
	movq	qe(%rip), %rcx
	movl	12(%r15), %eax
	movl	%eax, 12(%rsp)
	testq	%rcx, %rcx
	je	.L355
	movl	$24, %edi
	movq	%rdx, 24(%rsp)
	movq	%rcx, 16(%rsp)
	call	malloc@PLT
	movq	16(%rsp), %rcx
	movq	24(%rsp), %rdx
	movq	%rax, %rdi
	movq	%rax, 16(%rcx)
	movq	%rax, qe(%rip)
.L140:
	addq	$1, %rdx
	movl	$11, %ecx
	movq	%r13, %rsi
	addq	$1, %rbx
	call	__memcpy_chk@PLT
	movl	12(%rsp), %edx
	movq	qe(%rip), %rax
	addl	$1, %edx
	movq	$0, 16(%rax)
	movl	%edx, 12(%rax)
	cmpl	%ebp, %r12d
	jg	.L141
	.p2align 4,,10
	.p2align 3
.L142:
	movq	%r15, %rdi
	call	free@PLT
	movq	qs(%rip), %r15
	testq	%r15, %r15
	jne	.L35
.L34:
	movl	$-1, %eax
.L33:
	movq	56(%rsp), %rdx
	subq	%fs:40, %rdx
	jne	.L356
	addq	$72, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	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
.L346:
	.cfi_restore_state
	movzbl	(%rbx), %eax
	cmpb	$114, %al
	je	.L41
	cmpb	$98, %al
	jne	.L74
.L110:
	movb	$114, (%rbx)
	movb	$114, -1(%rbx)
	jmp	.L342
	.p2align 4,,10
	.p2align 3
.L41:
	movb	$98, (%rbx)
	movb	$98, -1(%rbx)
	jmp	.L342
	.p2align 4,,10
	.p2align 3
.L347:
	leal	2(%rax,%rax,2), %eax
	jmp	.L116
	.p2align 4,,10
	.p2align 3
.L115:
	leal	(%rax,%rax,2), %eax
	jmp	.L116
	.p2align 4,,10
	.p2align 3
.L114:
	leal	1(%rax,%rax,2), %eax
	jmp	.L116
	.p2align 4,,10
	.p2align 3
.L117:
	leal	1(%rax,%rax,2), %eax
	jmp	.L119
	.p2align 4,,10
	.p2align 3
.L348:
	leal	2(%rax,%rax,2), %eax
	jmp	.L119
	.p2align 4,,10
	.p2align 3
.L118:
	leal	(%rax,%rax,2), %eax
	jmp	.L119
	.p2align 4,,10
	.p2align 3
.L121:
	leal	(%rax,%rax,2), %eax
	jmp	.L122
	.p2align 4,,10
	.p2align 3
.L120:
	leal	1(%rax,%rax,2), %eax
	jmp	.L122
	.p2align 4,,10
	.p2align 3
.L349:
	leal	2(%rax,%rax,2), %eax
	jmp	.L122
	.p2align 4,,10
	.p2align 3
.L123:
	leal	1(%rax,%rax,2), %eax
	jmp	.L125
	.p2align 4,,10
	.p2align 3
.L350:
	leal	2(%rax,%rax,2), %eax
	jmp	.L125
	.p2align 4,,10
	.p2align 3
.L124:
	leal	(%rax,%rax,2), %eax
	jmp	.L125
	.p2align 4,,10
	.p2align 3
.L351:
	leal	2(%rax,%rax,2), %eax
	jmp	.L128
	.p2align 4,,10
	.p2align 3
.L127:
	leal	(%rax,%rax,2), %eax
	jmp	.L128
	.p2align 4,,10
	.p2align 3
.L126:
	leal	1(%rax,%rax,2), %eax
	jmp	.L128
	.p2align 4,,10
	.p2align 3
.L129:
	leal	1(%rax,%rax,2), %eax
	jmp	.L131
	.p2align 4,,10
	.p2align 3
.L352:
	leal	2(%rax,%rax,2), %eax
	jmp	.L131
	.p2align 4,,10
	.p2align 3
.L130:
	leal	(%rax,%rax,2), %eax
	jmp	.L131
	.p2align 4,,10
	.p2align 3
.L162:
	xorl	%eax, %eax
	jmp	.L111
	.p2align 4,,10
	.p2align 3
.L355:
	movl	$24, %edi
	movq	%rdx, 16(%rsp)
	call	malloc@PLT
	movq	16(%rsp), %rdx
	movq	%rax, qe(%rip)
	movq	%rax, %rdi
	movq	%rax, qs(%rip)
	jmp	.L140
	.p2align 4,,10
	.p2align 3
.L133:
	leal	(%rax,%rax,2), %eax
	jmp	.L134
	.p2align 4,,10
	.p2align 3
.L132:
	leal	1(%rax,%rax,2), %eax
	jmp	.L134
	.p2align 4,,10
	.p2align 3
.L353:
	leal	2(%rax,%rax,2), %eax
	jmp	.L134
	.p2align 4,,10
	.p2align 3
.L135:
	leal	1(%rax,%rax,2), %eax
	jmp	.L111
	.p2align 4,,10
	.p2align 3
.L354:
	leal	2(%rax,%rax,2), %eax
	jmp	.L111
	.p2align 4,,10
	.p2align 3
.L136:
	leal	(%rax,%rax,2), %eax
	jmp	.L111
	.p2align 4,,10
	.p2align 3
.L344:
	movq	$0, qe(%rip)
	jmp	.L143
.L345:
	jne	.L142
.L38:
	movl	12(%r15), %eax
	jmp	.L33
.L149:
	movl	$2, %edx
	jmp	.L37
.L150:
	movl	$3, %edx
	jmp	.L37
.L151:
	movl	$4, %edx
	jmp	.L37
.L152:
	movl	$5, %edx
	jmp	.L37
.L153:
	movl	$6, %edx
	jmp	.L37
.L154:
	movl	$7, %edx
	jmp	.L37
.L155:
	movl	$8, %edx
	jmp	.L37
.L156:
	movl	$9, %edx
	jmp	.L37
.L157:
	movl	$10, %edx
	jmp	.L37
.L356:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE55:
	.size	search, .-search
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%s"
.LC1:
	.string	"0"
.LC2:
	.string	"NA"
.LC3:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB56:
	.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
	leaq	.LC2(%rip), %r14
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	leaq	.LC3(%rip), %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	leaq	.LC0(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	leaq	a(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$40, %rsp
	.cfi_def_cfa_offset 96
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	leaq	13(%rsp), %rbx
	.p2align 4,,10
	.p2align 3
.L358:
	xorl	%eax, %eax
	movq	%rbx, %rsi
	movq	%r12, %rdi
	call	__isoc99_scanf@PLT
	cmpw	$48, (%rbx)
	jne	.L423
	jmp	.L424
	.p2align 4,,10
	.p2align 3
.L362:
	movq	16(%rdi), %rax
	movq	%rax, qs(%rip)
	call	free@PLT
.L423:
	movq	qs(%rip), %rdi
	testq	%rdi, %rdi
	jne	.L362
	movl	$60000, %edx
	xorl	%esi, %esi
	movq	%rbp, %rdi
	call	memset@PLT
	movq	%rbx, %rdi
	call	strlen@PLT
	leal	-1(%rax), %edx
	movq	%rax, %r15
	xorl	%eax, %eax
	testl	%edx, %edx
	jle	.L364
	movzbl	13(%rsp), %ecx
	movl	$2, %eax
	cmpb	$98, %cl
	je	.L366
	xorl	%eax, %eax
	cmpb	$103, %cl
	sete	%al
.L366:
	cmpl	$1, %edx
	je	.L364
	movzbl	14(%rsp), %ecx
	cmpb	$103, %cl
	je	.L368
	cmpb	$114, %cl
	je	.L369
	cmpb	$98, %cl
	je	.L425
.L370:
	cmpl	$2, %edx
	je	.L364
	movzbl	15(%rsp), %ecx
	cmpb	$103, %cl
	je	.L371
	cmpb	$114, %cl
	je	.L372
	cmpb	$98, %cl
	je	.L426
.L373:
	cmpl	$3, %edx
	je	.L364
	movzbl	16(%rsp), %ecx
	cmpb	$103, %cl
	je	.L374
	cmpb	$114, %cl
	je	.L375
	cmpb	$98, %cl
	je	.L427
.L376:
	cmpl	$4, %edx
	je	.L364
	movzbl	17(%rsp), %ecx
	cmpb	$103, %cl
	je	.L377
	cmpb	$114, %cl
	je	.L378
	cmpb	$98, %cl
	je	.L428
.L379:
	cmpl	$5, %edx
	je	.L364
	movzbl	18(%rsp), %ecx
	cmpb	$103, %cl
	je	.L380
	cmpb	$114, %cl
	je	.L381
	cmpb	$98, %cl
	je	.L429
.L382:
	cmpl	$6, %edx
	je	.L364
	movzbl	19(%rsp), %ecx
	cmpb	$103, %cl
	je	.L383
	cmpb	$114, %cl
	je	.L384
	cmpb	$98, %cl
	je	.L430
.L385:
	cmpl	$7, %edx
	je	.L364
	movzbl	20(%rsp), %ecx
	cmpb	$103, %cl
	je	.L386
	cmpb	$114, %cl
	je	.L387
	cmpb	$98, %cl
	je	.L431
.L388:
	cmpl	$9, %edx
	jne	.L364
	movzbl	21(%rsp), %edx
	cmpb	$103, %dl
	je	.L389
	cmpb	$114, %dl
	je	.L390
	cmpb	$98, %dl
	je	.L432
.L364:
	cltq
	movl	$24, %edi
	movb	$1, 0(%rbp,%rax)
	call	malloc@PLT
	leaq	1(%r15), %rdx
	movl	$11, %ecx
	movq	%rbx, %rsi
	movq	%rax, %rdi
	movq	%rax, qe(%rip)
	movq	%rax, qs(%rip)
	call	__memcpy_chk@PLT
	movl	$0, 12(%rax)
	movq	$0, 16(%rax)
	xorl	%eax, %eax
	call	search
	movl	%eax, %edx
	cmpl	$-1, %eax
	je	.L433
	movq	%r13, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L358
	.p2align 4,,10
	.p2align 3
.L424:
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L434
	addq	$40, %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
	.p2align 4,,10
	.p2align 3
.L433:
	.cfi_restore_state
	movq	%r14, %rdi
	call	puts@PLT
	jmp	.L358
	.p2align 4,,10
	.p2align 3
.L425:
	leal	2(%rax,%rax,2), %eax
	jmp	.L370
	.p2align 4,,10
	.p2align 3
.L369:
	leal	(%rax,%rax,2), %eax
	jmp	.L370
	.p2align 4,,10
	.p2align 3
.L368:
	leal	1(%rax,%rax,2), %eax
	jmp	.L370
	.p2align 4,,10
	.p2align 3
.L371:
	leal	1(%rax,%rax,2), %eax
	jmp	.L373
	.p2align 4,,10
	.p2align 3
.L426:
	leal	2(%rax,%rax,2), %eax
	jmp	.L373
	.p2align 4,,10
	.p2align 3
.L372:
	leal	(%rax,%rax,2), %eax
	jmp	.L373
	.p2align 4,,10
	.p2align 3
.L375:
	leal	(%rax,%rax,2), %eax
	jmp	.L376
	.p2align 4,,10
	.p2align 3
.L374:
	leal	1(%rax,%rax,2), %eax
	jmp	.L376
	.p2align 4,,10
	.p2align 3
.L427:
	leal	2(%rax,%rax,2), %eax
	jmp	.L376
	.p2align 4,,10
	.p2align 3
.L377:
	leal	1(%rax,%rax,2), %eax
	jmp	.L379
	.p2align 4,,10
	.p2align 3
.L428:
	leal	2(%rax,%rax,2), %eax
	jmp	.L379
	.p2align 4,,10
	.p2align 3
.L378:
	leal	(%rax,%rax,2), %eax
	jmp	.L379
	.p2align 4,,10
	.p2align 3
.L429:
	leal	2(%rax,%rax,2), %eax
	jmp	.L382
	.p2align 4,,10
	.p2align 3
.L381:
	leal	(%rax,%rax,2), %eax
	jmp	.L382
	.p2align 4,,10
	.p2align 3
.L380:
	leal	1(%rax,%rax,2), %eax
	jmp	.L382
	.p2align 4,,10
	.p2align 3
.L383:
	leal	1(%rax,%rax,2), %eax
	jmp	.L385
	.p2align 4,,10
	.p2align 3
.L430:
	leal	2(%rax,%rax,2), %eax
	jmp	.L385
	.p2align 4,,10
	.p2align 3
.L384:
	leal	(%rax,%rax,2), %eax
	jmp	.L385
	.p2align 4,,10
	.p2align 3
.L387:
	leal	(%rax,%rax,2), %eax
	jmp	.L388
	.p2align 4,,10
	.p2align 3
.L386:
	leal	1(%rax,%rax,2), %eax
	jmp	.L388
	.p2align 4,,10
	.p2align 3
.L431:
	leal	2(%rax,%rax,2), %eax
	jmp	.L388
.L389:
	leal	1(%rax,%rax,2), %eax
	jmp	.L364
	.p2align 4,,10
	.p2align 3
.L432:
	leal	2(%rax,%rax,2), %eax
	jmp	.L364
	.p2align 4,,10
	.p2align 3
.L390:
	leal	(%rax,%rax,2), %eax
	jmp	.L364
.L434:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE56:
	.size	main, .-main
	.globl	qe
	.bss
	.align 8
	.type	qe, @object
	.size	qe, 8
qe:
	.zero	8
	.globl	qs
	.align 8
	.type	qs, @object
	.size	qs, 8
qs:
	.zero	8
	.globl	a
	.align 32
	.type	a, @object
	.size	a, 60000
a:
	.zero	60000
	.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	add
	.type	add, @function
add:
.LFB51:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	movq	%rdi, %rbx
	call	strlen@PLT
	cmpl	$1, %eax
	jle	.L9
	subl	$2, %eax
	movq	%rbx, %rdi
	xorl	%edx, %edx
	leaq	1(%rbx,%rax), %rcx
	jmp	.L7
	.p2align 4,,10
	.p2align 3
.L15:
	cmpb	$98, %al
	je	.L14
.L6:
	addq	$1, %rdi
	cmpq	%rcx, %rdi
	je	.L2
.L7:
	movzbl	(%rdi), %eax
	cmpb	$103, %al
	je	.L3
	cmpb	$114, %al
	jne	.L15
	addq	$1, %rdi
	leal	(%rdx,%rdx,2), %edx
	cmpq	%rcx, %rdi
	jne	.L7
.L2:
	leaq	a(%rip), %rcx
	movslq	%edx, %rdx
	xorl	%eax, %eax
	cmpb	$1, (%rcx,%rdx)
	je	.L1
	movb	$1, (%rcx,%rdx)
	movl	$1, %eax
.L1:
	popq	%rbx
	.cfi_remember_state
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L3:
	.cfi_restore_state
	leal	1(%rdx,%rdx,2), %edx
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L14:
	leal	2(%rdx,%rdx,2), %edx
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L9:
	xorl	%edx, %edx
	jmp	.L2
	.cfi_endproc
.LFE51:
	.size	add, .-add
	.p2align 4
	.globl	push
	.type	push, @function
push:
.LFB52:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movq	qe(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	movq	%rdi, %rbp
	movl	$24, %edi
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	movl	%esi, %ebx
	testq	%r12, %r12
	je	.L20
	call	malloc@PLT
	movq	%rax, 16(%r12)
	movq	%rax, %rdi
	movq	%rax, qe(%rip)
.L18:
	movq	%rbp, %rsi
	movl	$11, %edx
	call	__strcpy_chk@PLT
	movq	qe(%rip), %rax
	movl	%ebx, 12(%rax)
	movq	$0, 16(%rax)
	popq	%rbx
	.cfi_remember_state
	.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
.L20:
	.cfi_restore_state
	call	malloc@PLT
	movq	%rax, qe(%rip)
	movq	%rax, %rdi
	movq	%rax, qs(%rip)
	jmp	.L18
	.cfi_endproc
.LFE52:
	.size	push, .-push
	.p2align 4
	.globl	pop
	.type	pop, @function
pop:
.LFB53:
	.cfi_startproc
	endbr64
	movq	qs(%rip), %rax
	testq	%rax, %rax
	je	.L21
	movq	16(%rax), %rdx
	movq	%rdx, qs(%rip)
	testq	%rdx, %rdx
	je	.L26
.L21:
	ret
	.p2align 4,,10
	.p2align 3
.L26:
	movq	$0, qe(%rip)
	ret
	.cfi_endproc
.LFE53:
	.size	pop, .-pop
	.p2align 4
	.globl	flush
	.type	flush, @function
flush:
.LFB54:
	.cfi_startproc
	endbr64
	subq	$8, %rsp
	.cfi_def_cfa_offset 16
	movq	qs(%rip), %rdi
	testq	%rdi, %rdi
	je	.L29
	.p2align 4,,10
	.p2align 3
.L28:
	movq	16(%rdi), %rax
	movq	%rax, qs(%rip)
	call	free@PLT
	movq	qs(%rip), %rdi
	testq	%rdi, %rdi
	jne	.L28
.L29:
	movl	$60000, %edx
	xorl	%esi, %esi
	leaq	a(%rip), %rdi
	movq	$0, qe(%rip)
	addq	$8, %rsp
	.cfi_def_cfa_offset 8
	jmp	memset@PLT
	.cfi_endproc
.LFE54:
	.size	flush, .-flush
	.p2align 4
	.globl	search
	.type	search, @function
search:
.LFB55:
	.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
	leaq	a(%rip), %r14
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$72, %rsp
	.cfi_def_cfa_offset 128
	movq	qs(%rip), %r15
	movq	%fs:40, %rax
	movq	%rax, 56(%rsp)
	xorl	%eax, %eax
	testq	%r15, %r15
	je	.L34
	.p2align 4,,10
	.p2align 3
.L35:
	movq	16(%r15), %rax
	movq	%rax, qs(%rip)
	testq	%rax, %rax
	je	.L344
.L143:
	movq	%r15, %rdi
	call	strlen@PLT
	movzbl	(%r15), %edx
	cmpl	$1, %eax
	jle	.L345
	cmpb	1(%r15), %dl
	jne	.L248
	cmpl	$2, %eax
	je	.L149
	cmpb	2(%r15), %dl
	jne	.L248
	cmpl	$3, %eax
	je	.L150
	cmpb	3(%r15), %dl
	jne	.L248
	cmpl	$4, %eax
	je	.L151
	cmpb	4(%r15), %dl
	jne	.L248
	cmpl	$5, %eax
	je	.L152
	cmpb	5(%r15), %dl
	jne	.L248
	cmpl	$6, %eax
	je	.L153
	cmpb	6(%r15), %dl
	jne	.L248
	cmpl	$7, %eax
	je	.L154
	cmpb	7(%r15), %dl
	jne	.L248
	cmpl	$8, %eax
	je	.L155
	cmpb	8(%r15), %dl
	jne	.L248
	cmpl	$9, %eax
	je	.L156
	cmpb	9(%r15), %dl
	jne	.L248
	cmpl	$10, %eax
	je	.L157
	cmpb	%dl, 10(%r15)
	jne	.L248
	movl	$11, %edx
.L37:
	cmpl	%edx, %eax
	je	.L38
.L248:
	leal	-1(%rax), %r12d
	leaq	46(%rsp), %rbx
	xorl	%ebp, %ebp
	leaq	45(%rsp), %r13
	jmp	.L141
	.p2align 4,,10
	.p2align 3
.L40:
	cmpb	$103, %al
	je	.L346
	cmpb	$98, %al
	jne	.L74
	movzbl	(%rbx), %eax
	cmpb	$114, %al
	je	.L77
	cmpb	$103, %al
	je	.L110
.L74:
	addq	$1, %rbx
	cmpl	%ebp, %r12d
	jle	.L142
.L141:
	movl	$11, %edx
	movq	%r15, %rsi
	movq	%r13, %rdi
	addl	$1, %ebp
	call	__strcpy_chk@PLT
	movzbl	-1(%rbx), %eax
	cmpb	$114, %al
	jne	.L40
	movzbl	(%rbx), %eax
	cmpb	$103, %al
	je	.L41
	cmpb	$98, %al
	jne	.L74
.L77:
	movb	$103, (%rbx)
	movb	$103, -1(%rbx)
.L342:
	movq	%r13, %rdi
	call	strlen@PLT
	leal	-1(%rax), %ecx
	movq	%rax, %rdx
	testl	%ecx, %ecx
	jle	.L162
	movzbl	45(%rsp), %esi
	movl	$2, %eax
	cmpb	$98, %sil
	je	.L112
	xorl	%eax, %eax
	cmpb	$103, %sil
	sete	%al
.L112:
	cmpl	$1, %ecx
	je	.L111
	movzbl	46(%rsp), %esi
	cmpb	$103, %sil
	je	.L114
	cmpb	$114, %sil
	je	.L115
	cmpb	$98, %sil
	je	.L347
.L116:
	cmpl	$2, %ecx
	je	.L111
	movzbl	47(%rsp), %esi
	cmpb	$103, %sil
	je	.L117
	cmpb	$114, %sil
	je	.L118
	cmpb	$98, %sil
	je	.L348
.L119:
	cmpl	$3, %ecx
	je	.L111
	movzbl	48(%rsp), %esi
	cmpb	$103, %sil
	je	.L120
	cmpb	$114, %sil
	je	.L121
	cmpb	$98, %sil
	je	.L349
.L122:
	cmpl	$4, %ecx
	je	.L111
	movzbl	49(%rsp), %esi
	cmpb	$103, %sil
	je	.L123
	cmpb	$114, %sil
	je	.L124
	cmpb	$98, %sil
	je	.L350
.L125:
	cmpl	$5, %ecx
	je	.L111
	movzbl	50(%rsp), %esi
	cmpb	$103, %sil
	je	.L126
	cmpb	$114, %sil
	je	.L127
	cmpb	$98, %sil
	je	.L351
.L128:
	cmpl	$6, %ecx
	je	.L111
	movzbl	51(%rsp), %esi
	cmpb	$103, %sil
	je	.L129
	cmpb	$114, %sil
	je	.L130
	cmpb	$98, %sil
	je	.L352
.L131:
	cmpl	$7, %ecx
	je	.L111
	movzbl	52(%rsp), %esi
	cmpb	$103, %sil
	je	.L132
	cmpb	$114, %sil
	je	.L133
	cmpb	$98, %sil
	je	.L353
.L134:
	cmpl	$9, %ecx
	jne	.L111
	movzbl	53(%rsp), %ecx
	cmpb	$103, %cl
	je	.L135
	cmpb	$114, %cl
	je	.L136
	cmpb	$98, %cl
	je	.L354
.L111:
	cltq
	cmpb	$1, (%r14,%rax)
	je	.L74
	movb	$1, (%r14,%rax)
	movq	qe(%rip), %rcx
	movl	12(%r15), %eax
	movl	%eax, 12(%rsp)
	testq	%rcx, %rcx
	je	.L355
	movl	$24, %edi
	movq	%rdx, 24(%rsp)
	movq	%rcx, 16(%rsp)
	call	malloc@PLT
	movq	16(%rsp), %rcx
	movq	24(%rsp), %rdx
	movq	%rax, %rdi
	movq	%rax, 16(%rcx)
	movq	%rax, qe(%rip)
.L140:
	addq	$1, %rdx
	movl	$11, %ecx
	movq	%r13, %rsi
	addq	$1, %rbx
	call	__memcpy_chk@PLT
	movl	12(%rsp), %edx
	movq	qe(%rip), %rax
	addl	$1, %edx
	movq	$0, 16(%rax)
	movl	%edx, 12(%rax)
	cmpl	%ebp, %r12d
	jg	.L141
	.p2align 4,,10
	.p2align 3
.L142:
	movq	%r15, %rdi
	call	free@PLT
	movq	qs(%rip), %r15
	testq	%r15, %r15
	jne	.L35
.L34:
	movl	$-1, %eax
.L33:
	movq	56(%rsp), %rdx
	subq	%fs:40, %rdx
	jne	.L356
	addq	$72, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	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
.L346:
	.cfi_restore_state
	movzbl	(%rbx), %eax
	cmpb	$114, %al
	je	.L41
	cmpb	$98, %al
	jne	.L74
.L110:
	movb	$114, (%rbx)
	movb	$114, -1(%rbx)
	jmp	.L342
	.p2align 4,,10
	.p2align 3
.L41:
	movb	$98, (%rbx)
	movb	$98, -1(%rbx)
	jmp	.L342
	.p2align 4,,10
	.p2align 3
.L347:
	leal	2(%rax,%rax,2), %eax
	jmp	.L116
	.p2align 4,,10
	.p2align 3
.L115:
	leal	(%rax,%rax,2), %eax
	jmp	.L116
	.p2align 4,,10
	.p2align 3
.L114:
	leal	1(%rax,%rax,2), %eax
	jmp	.L116
	.p2align 4,,10
	.p2align 3
.L117:
	leal	1(%rax,%rax,2), %eax
	jmp	.L119
	.p2align 4,,10
	.p2align 3
.L348:
	leal	2(%rax,%rax,2), %eax
	jmp	.L119
	.p2align 4,,10
	.p2align 3
.L118:
	leal	(%rax,%rax,2), %eax
	jmp	.L119
	.p2align 4,,10
	.p2align 3
.L121:
	leal	(%rax,%rax,2), %eax
	jmp	.L122
	.p2align 4,,10
	.p2align 3
.L120:
	leal	1(%rax,%rax,2), %eax
	jmp	.L122
	.p2align 4,,10
	.p2align 3
.L349:
	leal	2(%rax,%rax,2), %eax
	jmp	.L122
	.p2align 4,,10
	.p2align 3
.L123:
	leal	1(%rax,%rax,2), %eax
	jmp	.L125
	.p2align 4,,10
	.p2align 3
.L350:
	leal	2(%rax,%rax,2), %eax
	jmp	.L125
	.p2align 4,,10
	.p2align 3
.L124:
	leal	(%rax,%rax,2), %eax
	jmp	.L125
	.p2align 4,,10
	.p2align 3
.L351:
	leal	2(%rax,%rax,2), %eax
	jmp	.L128
	.p2align 4,,10
	.p2align 3
.L127:
	leal	(%rax,%rax,2), %eax
	jmp	.L128
	.p2align 4,,10
	.p2align 3
.L126:
	leal	1(%rax,%rax,2), %eax
	jmp	.L128
	.p2align 4,,10
	.p2align 3
.L129:
	leal	1(%rax,%rax,2), %eax
	jmp	.L131
	.p2align 4,,10
	.p2align 3
.L352:
	leal	2(%rax,%rax,2), %eax
	jmp	.L131
	.p2align 4,,10
	.p2align 3
.L130:
	leal	(%rax,%rax,2), %eax
	jmp	.L131
	.p2align 4,,10
	.p2align 3
.L162:
	xorl	%eax, %eax
	jmp	.L111
	.p2align 4,,10
	.p2align 3
.L355:
	movl	$24, %edi
	movq	%rdx, 16(%rsp)
	call	malloc@PLT
	movq	16(%rsp), %rdx
	movq	%rax, qe(%rip)
	movq	%rax, %rdi
	movq	%rax, qs(%rip)
	jmp	.L140
	.p2align 4,,10
	.p2align 3
.L133:
	leal	(%rax,%rax,2), %eax
	jmp	.L134
	.p2align 4,,10
	.p2align 3
.L132:
	leal	1(%rax,%rax,2), %eax
	jmp	.L134
	.p2align 4,,10
	.p2align 3
.L353:
	leal	2(%rax,%rax,2), %eax
	jmp	.L134
	.p2align 4,,10
	.p2align 3
.L135:
	leal	1(%rax,%rax,2), %eax
	jmp	.L111
	.p2align 4,,10
	.p2align 3
.L354:
	leal	2(%rax,%rax,2), %eax
	jmp	.L111
	.p2align 4,,10
	.p2align 3
.L136:
	leal	(%rax,%rax,2), %eax
	jmp	.L111
	.p2align 4,,10
	.p2align 3
.L344:
	movq	$0, qe(%rip)
	jmp	.L143
.L345:
	jne	.L142
.L38:
	movl	12(%r15), %eax
	jmp	.L33
.L149:
	movl	$2, %edx
	jmp	.L37
.L150:
	movl	$3, %edx
	jmp	.L37
.L151:
	movl	$4, %edx
	jmp	.L37
.L152:
	movl	$5, %edx
	jmp	.L37
.L153:
	movl	$6, %edx
	jmp	.L37
.L154:
	movl	$7, %edx
	jmp	.L37
.L155:
	movl	$8, %edx
	jmp	.L37
.L156:
	movl	$9, %edx
	jmp	.L37
.L157:
	movl	$10, %edx
	jmp	.L37
.L356:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE55:
	.size	search, .-search
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%s"
.LC1:
	.string	"0"
.LC2:
	.string	"NA"
.LC3:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB56:
	.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
	leaq	.LC2(%rip), %r14
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	leaq	.LC3(%rip), %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	leaq	.LC0(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	leaq	a(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$40, %rsp
	.cfi_def_cfa_offset 96
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	leaq	13(%rsp), %rbx
	.p2align 4,,10
	.p2align 3
.L358:
	xorl	%eax, %eax
	movq	%rbx, %rsi
	movq	%r12, %rdi
	call	__isoc99_scanf@PLT
	cmpw	$48, (%rbx)
	jne	.L423
	jmp	.L424
	.p2align 4,,10
	.p2align 3
.L362:
	movq	16(%rdi), %rax
	movq	%rax, qs(%rip)
	call	free@PLT
.L423:
	movq	qs(%rip), %rdi
	testq	%rdi, %rdi
	jne	.L362
	movl	$60000, %edx
	xorl	%esi, %esi
	movq	%rbp, %rdi
	call	memset@PLT
	movq	%rbx, %rdi
	call	strlen@PLT
	leal	-1(%rax), %edx
	movq	%rax, %r15
	xorl	%eax, %eax
	testl	%edx, %edx
	jle	.L364
	movzbl	13(%rsp), %ecx
	movl	$2, %eax
	cmpb	$98, %cl
	je	.L366
	xorl	%eax, %eax
	cmpb	$103, %cl
	sete	%al
.L366:
	cmpl	$1, %edx
	je	.L364
	movzbl	14(%rsp), %ecx
	cmpb	$103, %cl
	je	.L368
	cmpb	$114, %cl
	je	.L369
	cmpb	$98, %cl
	je	.L425
.L370:
	cmpl	$2, %edx
	je	.L364
	movzbl	15(%rsp), %ecx
	cmpb	$103, %cl
	je	.L371
	cmpb	$114, %cl
	je	.L372
	cmpb	$98, %cl
	je	.L426
.L373:
	cmpl	$3, %edx
	je	.L364
	movzbl	16(%rsp), %ecx
	cmpb	$103, %cl
	je	.L374
	cmpb	$114, %cl
	je	.L375
	cmpb	$98, %cl
	je	.L427
.L376:
	cmpl	$4, %edx
	je	.L364
	movzbl	17(%rsp), %ecx
	cmpb	$103, %cl
	je	.L377
	cmpb	$114, %cl
	je	.L378
	cmpb	$98, %cl
	je	.L428
.L379:
	cmpl	$5, %edx
	je	.L364
	movzbl	18(%rsp), %ecx
	cmpb	$103, %cl
	je	.L380
	cmpb	$114, %cl
	je	.L381
	cmpb	$98, %cl
	je	.L429
.L382:
	cmpl	$6, %edx
	je	.L364
	movzbl	19(%rsp), %ecx
	cmpb	$103, %cl
	je	.L383
	cmpb	$114, %cl
	je	.L384
	cmpb	$98, %cl
	je	.L430
.L385:
	cmpl	$7, %edx
	je	.L364
	movzbl	20(%rsp), %ecx
	cmpb	$103, %cl
	je	.L386
	cmpb	$114, %cl
	je	.L387
	cmpb	$98, %cl
	je	.L431
.L388:
	cmpl	$9, %edx
	jne	.L364
	movzbl	21(%rsp), %edx
	cmpb	$103, %dl
	je	.L389
	cmpb	$114, %dl
	je	.L390
	cmpb	$98, %dl
	je	.L432
.L364:
	cltq
	movl	$24, %edi
	movb	$1, 0(%rbp,%rax)
	call	malloc@PLT
	leaq	1(%r15), %rdx
	movl	$11, %ecx
	movq	%rbx, %rsi
	movq	%rax, %rdi
	movq	%rax, qe(%rip)
	movq	%rax, qs(%rip)
	call	__memcpy_chk@PLT
	movl	$0, 12(%rax)
	movq	$0, 16(%rax)
	xorl	%eax, %eax
	call	search
	movl	%eax, %edx
	cmpl	$-1, %eax
	je	.L433
	movq	%r13, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L358
	.p2align 4,,10
	.p2align 3
.L424:
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L434
	addq	$40, %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
	.p2align 4,,10
	.p2align 3
.L433:
	.cfi_restore_state
	movq	%r14, %rdi
	call	puts@PLT
	jmp	.L358
	.p2align 4,,10
	.p2align 3
.L425:
	leal	2(%rax,%rax,2), %eax
	jmp	.L370
	.p2align 4,,10
	.p2align 3
.L369:
	leal	(%rax,%rax,2), %eax
	jmp	.L370
	.p2align 4,,10
	.p2align 3
.L368:
	leal	1(%rax,%rax,2), %eax
	jmp	.L370
	.p2align 4,,10
	.p2align 3
.L371:
	leal	1(%rax,%rax,2), %eax
	jmp	.L373
	.p2align 4,,10
	.p2align 3
.L426:
	leal	2(%rax,%rax,2), %eax
	jmp	.L373
	.p2align 4,,10
	.p2align 3
.L372:
	leal	(%rax,%rax,2), %eax
	jmp	.L373
	.p2align 4,,10
	.p2align 3
.L375:
	leal	(%rax,%rax,2), %eax
	jmp	.L376
	.p2align 4,,10
	.p2align 3
.L374:
	leal	1(%rax,%rax,2), %eax
	jmp	.L376
	.p2align 4,,10
	.p2align 3
.L427:
	leal	2(%rax,%rax,2), %eax
	jmp	.L376
	.p2align 4,,10
	.p2align 3
.L377:
	leal	1(%rax,%rax,2), %eax
	jmp	.L379
	.p2align 4,,10
	.p2align 3
.L428:
	leal	2(%rax,%rax,2), %eax
	jmp	.L379
	.p2align 4,,10
	.p2align 3
.L378:
	leal	(%rax,%rax,2), %eax
	jmp	.L379
	.p2align 4,,10
	.p2align 3
.L429:
	leal	2(%rax,%rax,2), %eax
	jmp	.L382
	.p2align 4,,10
	.p2align 3
.L381:
	leal	(%rax,%rax,2), %eax
	jmp	.L382
	.p2align 4,,10
	.p2align 3
.L380:
	leal	1(%rax,%rax,2), %eax
	jmp	.L382
	.p2align 4,,10
	.p2align 3
.L383:
	leal	1(%rax,%rax,2), %eax
	jmp	.L385
	.p2align 4,,10
	.p2align 3
.L430:
	leal	2(%rax,%rax,2), %eax
	jmp	.L385
	.p2align 4,,10
	.p2align 3
.L384:
	leal	(%rax,%rax,2), %eax
	jmp	.L385
	.p2align 4,,10
	.p2align 3
.L387:
	leal	(%rax,%rax,2), %eax
	jmp	.L388
	.p2align 4,,10
	.p2align 3
.L386:
	leal	1(%rax,%rax,2), %eax
	jmp	.L388
	.p2align 4,,10
	.p2align 3
.L431:
	leal	2(%rax,%rax,2), %eax
	jmp	.L388
.L389:
	leal	1(%rax,%rax,2), %eax
	jmp	.L364
	.p2align 4,,10
	.p2align 3
.L432:
	leal	2(%rax,%rax,2), %eax
	jmp	.L364
	.p2align 4,,10
	.p2align 3
.L390:
	leal	(%rax,%rax,2), %eax
	jmp	.L364
.L434:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE56:
	.size	main, .-main
	.globl	qe
	.bss
	.align 8
	.type	qe, @object
	.size	qe, 8
qe:
	.zero	8
	.globl	qs
	.align 8
	.type	qs, @object
	.size	qs, 8
qs:
	.zero	8
	.globl	a
	.align 32
	.type	a, @object
	.size	a, 60000
a:
	.zero	60000
	.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 <stdlib.h>
#include <string.h>
char a[60000];
typedef struct list ls;
struct node {
  char str[11];
  int lev;
  struct node* next;
} *qs,*qe;
typedef struct node st;
int add(char* buf)
{
  int l = strlen(buf);
  int i = 0,j=0;
  for(i=0;i<l-1;i++){
    switch(buf[i]){
    case 'r':
      j = j*3;
      break;
    case 'g':
      j = j*3+1;
      break;
    case 'b':
      j = j*3+2;
      break;
    }
  }
  if(a[j] == 1) return 0;
  a[j] = 1;
  return 1;
}
void push(char* buf,int l)
{
  if(qe == NULL) {
    qe = (st *)(malloc(sizeof(st)));
    qs = qe;
  } else {
    qe->next = (st *)(malloc(sizeof(st)));
    qe = qe->next;
  }
  strcpy(qe->str,buf);
  qe->lev = l;
  qe->next = NULL;
}
struct node* pop()
{
  st* p = qs;
  if(qs == NULL) return NULL;
  qs = qs->next;
  if(qs == NULL) qe = NULL;
  return p;
}
void flush()
{
  st* q=qs;
  while(q!=NULL){
    qs = qs->next;
    free(q);
    q = qs;
  }
  qe = NULL;
  memset(a,0,sizeof(a));
}
int search()
{
  int i,l;
  st *p;
  char s[11];
  char c;
  while((p = pop()) != NULL){
    l = strlen(p->str);
    c = (p->str)[0];
    for(i=1; i<l; i++){
      if((p->str)[i] != c) break;
    }
    if(i==l) return p->lev;
    for(i=0; i<l-1; i++){
      strcpy(s,p->str);
      if((s[i] == 'r' && s[i+1] == 'g')
	 || (s[i] == 'g' && s[i+1] == 'r')){
	s[i] = s[i+1] = 'b';
	if(add(s)) push(s,p->lev+1);
      } else if((s[i] == 'r' && s[i+1] == 'b')
	 || (s[i] == 'b' && s[i+1] == 'r')){
	s[i] = s[i+1] = 'g';
	if(add(s)) push(s,p->lev+1);
      } else if((s[i] == 'b' && s[i+1] == 'g')
	 || (s[i] == 'g' && s[i+1] == 'b')){
	s[i] = s[i+1] = 'r';
	if(add(s)) push(s,p->lev+1);
      }
    }
    free(p);
  }
  return -1;
}
int main()
{
  char buf[11];
  int n;
  for(;;){
    scanf("%s",buf);
    if(strcmp(buf,"0") == 0) break;
    flush();
    add(buf);
    push(buf,0);
    n = search();
    if(n==-1) printf("NA\n");
    else printf("%d\n",n);
  }
}
rbgrg
rbbgbbr
bgr
rgbbrgbr
bggrgbgrr
gbrggrbggr
rrrrr
bgbr
0
 rbgrg
gbbrbbr
gbr
rgbbrgbr
rrgbgrggb
gbrggrbggr
rrrrr
bgbr
0
 rbgrg
rbbgbbr
bgr
bgbrrgbr
bggrgbgrr
gbrggrbggr
rrrrr
bgbr
0
 rbgrg
rgbrbbb
rbg
rgbbrgbr
rrgbgrggb
gbrggrbggr
rrrrr
bgrb
0
 rggrb
rgbrbbb
rbg
rbgrbbgr
rrgbgrggb
gbrggrbggr
rrrrr
bgrb
0
 gbgrr
rbbgbbr
bgr
bgbrrgbr
bggrgbgrr
gbrggrbggr
rrrrr
bgbr
0
 grgbr
rbbgbbr
bgr
rbgbrgbr
bggrgbgrr
gbrggrbggr
rrrrr
rbgb
0
 rrgbg
rbbgbbr
bgr
brgrbbgr
bggrgbgrr
rggbrggrbg
rrrrr
gbrb
0
 rbgrg
bbbrbgr
rbg
rgbbrgrb
rrgbgrggb
ggrgbrbggr
rrrrr
bgbr
0
 rrgbg
rbbgbbr
bgr
brgrbbgr
bggrgbgrr
rggbrggrbg
rrrrr
grbb
0

5
7
1
6
NA
8
0
4
 5
4
1
6
NA
8
0
4
 5
7
1
9
NA
8
0
4
 5
7
1
6
NA
8
0
1
 2
7
1
6
NA
8
0
1
 8
7
1
9
NA
8
0
4
 5
7
1
3
NA
8
0
4
 8
7
1
6
NA
8
0
4
 5
7
1
6
NA
11
0
4
 8
7
1
6
NA
8
0
1

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 <stdlib.h>
#include <string.h>
char a[60000];
typedef struct list ls;
struct node {
  char str[11];
  int lev;
  struct node* next;
} *qs,*qe;
typedef struct node st;
int add(char* buf)
{
  int l = strlen(buf);
  int i = 0,j=0;
  for(i=0;i<l-1;i++){
    switch(buf[i]){
    case 'r':
      j = j*3;
      break;
    case 'g':
      j = j*3+1;
      break;
    case 'b':
      j = j*3+2;
      break;
    }
  }
  if(a[j] == 1) return 0;
  a[j] = 1;
  return 1;
}
void push(char* buf,int l)
{
  if(qe == NULL) {
    qe = (st *)(malloc(sizeof(st)));
    qs = qe;
  } else {
    qe->next = (st *)(malloc(sizeof(st)));
    qe = qe->next;
  }
  strcpy(qe->str,buf);
  qe->lev = l;
  qe->next = NULL;
}
struct node* pop()
{
  st* p = qs;
  if(qs == NULL) return NULL;
  qs = qs->next;
  if(qs == NULL) qe = NULL;
  return p;
}
void flush()
{
  st* q=qs;
  while(q!=NULL){
    qs = qs->next;
    free(q);
    q = qs;
  }
  qe = NULL;
  memset(a,0,sizeof(a));
}
int search()
{
  int i,l;
  st *p;
  char s[11];
  char c;
  while((p = pop()) != NULL){
    l = strlen(p->str);
    c = (p->str)[0];
    for(i=1; i<l; i++){
      if((p->str)[i] != c) break;
    }
    if(i==l) return p->lev;
    for(i=0; i<l-1; i++){
      strcpy(s,p->str);
      if((s[i] == 'r' && s[i+1] == 'g')
	 || (s[i] == 'g' && s[i+1] == 'r')){
	s[i] = s[i+1] = 'b';
	if(add(s)) push(s,p->lev+1);
      } else if((s[i] == 'r' && s[i+1] == 'b')
	 || (s[i] == 'b' && s[i+1] == 'r')){
	s[i] = s[i+1] = 'g';
	if(add(s)) push(s,p->lev+1);
      } else if((s[i] == 'b' && s[i+1] == 'g')
	 || (s[i] == 'g' && s[i+1] == 'b')){
	s[i] = s[i+1] = 'r';
	if(add(s)) push(s,p->lev+1);
      }
    }
    free(p);
  }
  return -1;
}
int main()
{
  char buf[11];
  int n;
  for(;;){
    scanf("%s",buf);
    if(strcmp(buf,"0") == 0) break;
    flush();
    add(buf);
    push(buf,0);
    n = search();
    if(n==-1) printf("NA\n");
    else printf("%d\n",n);
  }
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	a
	.bss
	.align 32
	.type	a, @object
	.size	a, 60000
a:
	.zero	60000
	.globl	qs
	.align 8
	.type	qs, @object
	.size	qs, 8
qs:
	.zero	8
	.globl	qe
	.align 8
	.type	qe, @object
	.size	qe, 8
qe:
	.zero	8
	.text
	.globl	add
	.type	add, @function
add:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movq	%rdi, -24(%rbp)
	movq	-24(%rbp), %rax
	movq	%rax, %rdi
	call	strlen@PLT
	movl	%eax, -4(%rbp)
	movl	$0, -12(%rbp)
	movl	$0, -8(%rbp)
	movl	$0, -12(%rbp)
	jmp	.L2
.L7:
	movl	-12(%rbp), %eax
	movslq	%eax, %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	movsbl	%al, %eax
	cmpl	$114, %eax
	je	.L3
	cmpl	$114, %eax
	jg	.L4
	cmpl	$98, %eax
	je	.L5
	cmpl	$103, %eax
	je	.L6
	jmp	.L4
.L3:
	movl	-8(%rbp), %edx
	movl	%edx, %eax
	addl	%eax, %eax
	addl	%edx, %eax
	movl	%eax, -8(%rbp)
	jmp	.L4
.L6:
	movl	-8(%rbp), %edx
	movl	%edx, %eax
	addl	%eax, %eax
	addl	%edx, %eax
	addl	$1, %eax
	movl	%eax, -8(%rbp)
	jmp	.L4
.L5:
	movl	-8(%rbp), %edx
	movl	%edx, %eax
	addl	%eax, %eax
	addl	%edx, %eax
	addl	$2, %eax
	movl	%eax, -8(%rbp)
	nop
.L4:
	addl	$1, -12(%rbp)
.L2:
	movl	-4(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -12(%rbp)
	jl	.L7
	movl	-8(%rbp), %eax
	cltq
	leaq	a(%rip), %rdx
	movzbl	(%rax,%rdx), %eax
	cmpb	$1, %al
	jne	.L8
	movl	$0, %eax
	jmp	.L9
.L8:
	movl	-8(%rbp), %eax
	cltq
	leaq	a(%rip), %rdx
	movb	$1, (%rax,%rdx)
	movl	$1, %eax
.L9:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	add, .-add
	.globl	push
	.type	push, @function
push:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%rbx
	subq	$24, %rsp
	.cfi_offset 3, -24
	movq	%rdi, -24(%rbp)
	movl	%esi, -28(%rbp)
	movq	qe(%rip), %rax
	testq	%rax, %rax
	jne	.L11
	movl	$24, %edi
	call	malloc@PLT
	movq	%rax, qe(%rip)
	movq	qe(%rip), %rax
	movq	%rax, qs(%rip)
	jmp	.L12
.L11:
	movq	qe(%rip), %rbx
	movl	$24, %edi
	call	malloc@PLT
	movq	%rax, 16(%rbx)
	movq	qe(%rip), %rax
	movq	16(%rax), %rax
	movq	%rax, qe(%rip)
.L12:
	movq	qe(%rip), %rax
	movq	%rax, %rdx
	movq	-24(%rbp), %rax
	movq	%rax, %rsi
	movq	%rdx, %rdi
	call	strcpy@PLT
	movq	qe(%rip), %rax
	movl	-28(%rbp), %edx
	movl	%edx, 12(%rax)
	movq	qe(%rip), %rax
	movq	$0, 16(%rax)
	nop
	movq	-8(%rbp), %rbx
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	push, .-push
	.globl	pop
	.type	pop, @function
pop:
.LFB8:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	qs(%rip), %rax
	movq	%rax, -8(%rbp)
	movq	qs(%rip), %rax
	testq	%rax, %rax
	jne	.L14
	movl	$0, %eax
	jmp	.L15
.L14:
	movq	qs(%rip), %rax
	movq	16(%rax), %rax
	movq	%rax, qs(%rip)
	movq	qs(%rip), %rax
	testq	%rax, %rax
	jne	.L16
	movq	$0, qe(%rip)
.L16:
	movq	-8(%rbp), %rax
.L15:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.size	pop, .-pop
	.globl	flush
	.type	flush, @function
flush:
.LFB9:
	.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
	movq	qs(%rip), %rax
	movq	%rax, -8(%rbp)
	jmp	.L18
.L19:
	movq	qs(%rip), %rax
	movq	16(%rax), %rax
	movq	%rax, qs(%rip)
	movq	-8(%rbp), %rax
	movq	%rax, %rdi
	call	free@PLT
	movq	qs(%rip), %rax
	movq	%rax, -8(%rbp)
.L18:
	cmpq	$0, -8(%rbp)
	jne	.L19
	movq	$0, qe(%rip)
	movl	$60000, %edx
	movl	$0, %esi
	leaq	a(%rip), %rax
	movq	%rax, %rdi
	call	memset@PLT
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE9:
	.size	flush, .-flush
	.globl	search
	.type	search, @function
search:
.LFB10:
	.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
	jmp	.L21
.L41:
	movq	-32(%rbp), %rax
	movq	%rax, %rdi
	call	strlen@PLT
	movl	%eax, -36(%rbp)
	movq	-32(%rbp), %rax
	movzbl	(%rax), %eax
	movb	%al, -41(%rbp)
	movl	$1, -40(%rbp)
	jmp	.L22
.L25:
	movq	-32(%rbp), %rdx
	movl	-40(%rbp), %eax
	cltq
	movzbl	(%rdx,%rax), %eax
	cmpb	%al, -41(%rbp)
	jne	.L44
	addl	$1, -40(%rbp)
.L22:
	movl	-40(%rbp), %eax
	cmpl	-36(%rbp), %eax
	jl	.L25
	jmp	.L24
.L44:
	nop
.L24:
	movl	-40(%rbp), %eax
	cmpl	-36(%rbp), %eax
	jne	.L26
	movq	-32(%rbp), %rax
	movl	12(%rax), %eax
	jmp	.L42
.L26:
	movl	$0, -40(%rbp)
	jmp	.L28
.L40:
	movq	-32(%rbp), %rdx
	leaq	-19(%rbp), %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strcpy@PLT
	movl	-40(%rbp), %eax
	cltq
	movzbl	-19(%rbp,%rax), %eax
	cmpb	$114, %al
	jne	.L29
	movl	-40(%rbp), %eax
	addl	$1, %eax
	cltq
	movzbl	-19(%rbp,%rax), %eax
	cmpb	$103, %al
	je	.L30
.L29:
	movl	-40(%rbp), %eax
	cltq
	movzbl	-19(%rbp,%rax), %eax
	cmpb	$103, %al
	jne	.L31
	movl	-40(%rbp), %eax
	addl	$1, %eax
	cltq
	movzbl	-19(%rbp,%rax), %eax
	cmpb	$114, %al
	jne	.L31
.L30:
	movl	-40(%rbp), %eax
	addl	$1, %eax
	movslq	%eax, %rdx
	movb	$98, -19(%rbp,%rdx)
	cltq
	movzbl	-19(%rbp,%rax), %edx
	movl	-40(%rbp), %eax
	cltq
	movb	%dl, -19(%rbp,%rax)
	leaq	-19(%rbp), %rax
	movq	%rax, %rdi
	call	add
	testl	%eax, %eax
	je	.L33
	movq	-32(%rbp), %rax
	movl	12(%rax), %eax
	leal	1(%rax), %edx
	leaq	-19(%rbp), %rax
	movl	%edx, %esi
	movq	%rax, %rdi
	call	push
	jmp	.L33
.L31:
	movl	-40(%rbp), %eax
	cltq
	movzbl	-19(%rbp,%rax), %eax
	cmpb	$114, %al
	jne	.L34
	movl	-40(%rbp), %eax
	addl	$1, %eax
	cltq
	movzbl	-19(%rbp,%rax), %eax
	cmpb	$98, %al
	je	.L35
.L34:
	movl	-40(%rbp), %eax
	cltq
	movzbl	-19(%rbp,%rax), %eax
	cmpb	$98, %al
	jne	.L36
	movl	-40(%rbp), %eax
	addl	$1, %eax
	cltq
	movzbl	-19(%rbp,%rax), %eax
	cmpb	$114, %al
	jne	.L36
.L35:
	movl	-40(%rbp), %eax
	addl	$1, %eax
	movslq	%eax, %rdx
	movb	$103, -19(%rbp,%rdx)
	cltq
	movzbl	-19(%rbp,%rax), %edx
	movl	-40(%rbp), %eax
	cltq
	movb	%dl, -19(%rbp,%rax)
	leaq	-19(%rbp), %rax
	movq	%rax, %rdi
	call	add
	testl	%eax, %eax
	je	.L33
	movq	-32(%rbp), %rax
	movl	12(%rax), %eax
	leal	1(%rax), %edx
	leaq	-19(%rbp), %rax
	movl	%edx, %esi
	movq	%rax, %rdi
	call	push
	jmp	.L33
.L36:
	movl	-40(%rbp), %eax
	cltq
	movzbl	-19(%rbp,%rax), %eax
	cmpb	$98, %al
	jne	.L38
	movl	-40(%rbp), %eax
	addl	$1, %eax
	cltq
	movzbl	-19(%rbp,%rax), %eax
	cmpb	$103, %al
	je	.L39
.L38:
	movl	-40(%rbp), %eax
	cltq
	movzbl	-19(%rbp,%rax), %eax
	cmpb	$103, %al
	jne	.L33
	movl	-40(%rbp), %eax
	addl	$1, %eax
	cltq
	movzbl	-19(%rbp,%rax), %eax
	cmpb	$98, %al
	jne	.L33
.L39:
	movl	-40(%rbp), %eax
	addl	$1, %eax
	movslq	%eax, %rdx
	movb	$114, -19(%rbp,%rdx)
	cltq
	movzbl	-19(%rbp,%rax), %edx
	movl	-40(%rbp), %eax
	cltq
	movb	%dl, -19(%rbp,%rax)
	leaq	-19(%rbp), %rax
	movq	%rax, %rdi
	call	add
	testl	%eax, %eax
	je	.L33
	movq	-32(%rbp), %rax
	movl	12(%rax), %eax
	leal	1(%rax), %edx
	leaq	-19(%rbp), %rax
	movl	%edx, %esi
	movq	%rax, %rdi
	call	push
.L33:
	addl	$1, -40(%rbp)
.L28:
	movl	-36(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -40(%rbp)
	jl	.L40
	movq	-32(%rbp), %rax
	movq	%rax, %rdi
	call	free@PLT
.L21:
	movl	$0, %eax
	call	pop
	movq	%rax, -32(%rbp)
	cmpq	$0, -32(%rbp)
	jne	.L41
	movl	$-1, %eax
.L42:
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L43
	call	__stack_chk_fail@PLT
.L43:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE10:
	.size	search, .-search
	.section	.rodata
.LC0:
	.string	"%s"
.LC1:
	.string	"0"
.LC2:
	.string	"NA"
.LC3:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB11:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
.L50:
	leaq	-19(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	leaq	-19(%rbp), %rax
	leaq	.LC1(%rip), %rdx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	je	.L54
	movl	$0, %eax
	call	flush
	leaq	-19(%rbp), %rax
	movq	%rax, %rdi
	call	add
	leaq	-19(%rbp), %rax
	movl	$0, %esi
	movq	%rax, %rdi
	call	push
	movl	$0, %eax
	call	search
	movl	%eax, -24(%rbp)
	cmpl	$-1, -24(%rbp)
	jne	.L48
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	jmp	.L50
.L48:
	movl	-24(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L50
.L54:
	nop
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L52
	call	__stack_chk_fail@PLT
.L52:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE11:
	.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	a
	.bss
	.align 32
	.type	a, @object
	.size	a, 60000
a:
	.zero	60000
	.globl	qs
	.align 8
	.type	qs, @object
	.size	qs, 8
qs:
	.zero	8
	.globl	qe
	.align 8
	.type	qe, @object
	.size	qe, 8
qe:
	.zero	8
	.text
	.globl	add
	.type	add, @function
add:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movq	%rdi, -24(%rbp)
	movq	-24(%rbp), %rax
	movq	%rax, %rdi
	call	strlen@PLT
	movl	%eax, -4(%rbp)
	movl	$0, -12(%rbp)
	movl	$0, -8(%rbp)
	movl	$0, -12(%rbp)
	jmp	.L2
.L7:
	movl	-12(%rbp), %eax
	movslq	%eax, %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	movsbl	%al, %eax
	cmpl	$114, %eax
	je	.L3
	cmpl	$114, %eax
	jg	.L4
	cmpl	$98, %eax
	je	.L5
	cmpl	$103, %eax
	je	.L6
	jmp	.L4
.L3:
	movl	-8(%rbp), %edx
	movl	%edx, %eax
	addl	%eax, %eax
	addl	%edx, %eax
	movl	%eax, -8(%rbp)
	jmp	.L4
.L6:
	movl	-8(%rbp), %edx
	movl	%edx, %eax
	addl	%eax, %eax
	addl	%edx, %eax
	addl	$1, %eax
	movl	%eax, -8(%rbp)
	jmp	.L4
.L5:
	movl	-8(%rbp), %edx
	movl	%edx, %eax
	addl	%eax, %eax
	addl	%edx, %eax
	addl	$2, %eax
	movl	%eax, -8(%rbp)
	nop
.L4:
	addl	$1, -12(%rbp)
.L2:
	movl	-4(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -12(%rbp)
	jl	.L7
	movl	-8(%rbp), %eax
	cltq
	leaq	a(%rip), %rdx
	movzbl	(%rax,%rdx), %eax
	cmpb	$1, %al
	jne	.L8
	movl	$0, %eax
	jmp	.L9
.L8:
	movl	-8(%rbp), %eax
	cltq
	leaq	a(%rip), %rdx
	movb	$1, (%rax,%rdx)
	movl	$1, %eax
.L9:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	add, .-add
	.globl	push
	.type	push, @function
push:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%rbx
	subq	$24, %rsp
	.cfi_offset 3, -24
	movq	%rdi, -24(%rbp)
	movl	%esi, -28(%rbp)
	movq	qe(%rip), %rax
	testq	%rax, %rax
	jne	.L11
	movl	$24, %edi
	call	malloc@PLT
	movq	%rax, qe(%rip)
	movq	qe(%rip), %rax
	movq	%rax, qs(%rip)
	jmp	.L12
.L11:
	movq	qe(%rip), %rbx
	movl	$24, %edi
	call	malloc@PLT
	movq	%rax, 16(%rbx)
	movq	qe(%rip), %rax
	movq	16(%rax), %rax
	movq	%rax, qe(%rip)
.L12:
	movq	qe(%rip), %rax
	movq	%rax, %rdx
	movq	-24(%rbp), %rax
	movq	%rax, %rsi
	movq	%rdx, %rdi
	call	strcpy@PLT
	movq	qe(%rip), %rax
	movl	-28(%rbp), %edx
	movl	%edx, 12(%rax)
	movq	qe(%rip), %rax
	movq	$0, 16(%rax)
	nop
	movq	-8(%rbp), %rbx
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	push, .-push
	.globl	pop
	.type	pop, @function
pop:
.LFB8:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	qs(%rip), %rax
	movq	%rax, -8(%rbp)
	movq	qs(%rip), %rax
	testq	%rax, %rax
	jne	.L14
	movl	$0, %eax
	jmp	.L15
.L14:
	movq	qs(%rip), %rax
	movq	16(%rax), %rax
	movq	%rax, qs(%rip)
	movq	qs(%rip), %rax
	testq	%rax, %rax
	jne	.L16
	movq	$0, qe(%rip)
.L16:
	movq	-8(%rbp), %rax
.L15:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.size	pop, .-pop
	.globl	flush
	.type	flush, @function
flush:
.LFB9:
	.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
	movq	qs(%rip), %rax
	movq	%rax, -8(%rbp)
	jmp	.L18
.L19:
	movq	qs(%rip), %rax
	movq	16(%rax), %rax
	movq	%rax, qs(%rip)
	movq	-8(%rbp), %rax
	movq	%rax, %rdi
	call	free@PLT
	movq	qs(%rip), %rax
	movq	%rax, -8(%rbp)
.L18:
	cmpq	$0, -8(%rbp)
	jne	.L19
	movq	$0, qe(%rip)
	movl	$60000, %edx
	movl	$0, %esi
	leaq	a(%rip), %rax
	movq	%rax, %rdi
	call	memset@PLT
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE9:
	.size	flush, .-flush
	.globl	search
	.type	search, @function
search:
.LFB10:
	.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
	jmp	.L21
.L41:
	movq	-32(%rbp), %rax
	movq	%rax, %rdi
	call	strlen@PLT
	movl	%eax, -36(%rbp)
	movq	-32(%rbp), %rax
	movzbl	(%rax), %eax
	movb	%al, -41(%rbp)
	movl	$1, -40(%rbp)
	jmp	.L22
.L25:
	movq	-32(%rbp), %rdx
	movl	-40(%rbp), %eax
	cltq
	movzbl	(%rdx,%rax), %eax
	cmpb	%al, -41(%rbp)
	jne	.L44
	addl	$1, -40(%rbp)
.L22:
	movl	-40(%rbp), %eax
	cmpl	-36(%rbp), %eax
	jl	.L25
	jmp	.L24
.L44:
	nop
.L24:
	movl	-40(%rbp), %eax
	cmpl	-36(%rbp), %eax
	jne	.L26
	movq	-32(%rbp), %rax
	movl	12(%rax), %eax
	jmp	.L42
.L26:
	movl	$0, -40(%rbp)
	jmp	.L28
.L40:
	movq	-32(%rbp), %rdx
	leaq	-19(%rbp), %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strcpy@PLT
	movl	-40(%rbp), %eax
	cltq
	movzbl	-19(%rbp,%rax), %eax
	cmpb	$114, %al
	jne	.L29
	movl	-40(%rbp), %eax
	addl	$1, %eax
	cltq
	movzbl	-19(%rbp,%rax), %eax
	cmpb	$103, %al
	je	.L30
.L29:
	movl	-40(%rbp), %eax
	cltq
	movzbl	-19(%rbp,%rax), %eax
	cmpb	$103, %al
	jne	.L31
	movl	-40(%rbp), %eax
	addl	$1, %eax
	cltq
	movzbl	-19(%rbp,%rax), %eax
	cmpb	$114, %al
	jne	.L31
.L30:
	movl	-40(%rbp), %eax
	addl	$1, %eax
	movslq	%eax, %rdx
	movb	$98, -19(%rbp,%rdx)
	cltq
	movzbl	-19(%rbp,%rax), %edx
	movl	-40(%rbp), %eax
	cltq
	movb	%dl, -19(%rbp,%rax)
	leaq	-19(%rbp), %rax
	movq	%rax, %rdi
	call	add
	testl	%eax, %eax
	je	.L33
	movq	-32(%rbp), %rax
	movl	12(%rax), %eax
	leal	1(%rax), %edx
	leaq	-19(%rbp), %rax
	movl	%edx, %esi
	movq	%rax, %rdi
	call	push
	jmp	.L33
.L31:
	movl	-40(%rbp), %eax
	cltq
	movzbl	-19(%rbp,%rax), %eax
	cmpb	$114, %al
	jne	.L34
	movl	-40(%rbp), %eax
	addl	$1, %eax
	cltq
	movzbl	-19(%rbp,%rax), %eax
	cmpb	$98, %al
	je	.L35
.L34:
	movl	-40(%rbp), %eax
	cltq
	movzbl	-19(%rbp,%rax), %eax
	cmpb	$98, %al
	jne	.L36
	movl	-40(%rbp), %eax
	addl	$1, %eax
	cltq
	movzbl	-19(%rbp,%rax), %eax
	cmpb	$114, %al
	jne	.L36
.L35:
	movl	-40(%rbp), %eax
	addl	$1, %eax
	movslq	%eax, %rdx
	movb	$103, -19(%rbp,%rdx)
	cltq
	movzbl	-19(%rbp,%rax), %edx
	movl	-40(%rbp), %eax
	cltq
	movb	%dl, -19(%rbp,%rax)
	leaq	-19(%rbp), %rax
	movq	%rax, %rdi
	call	add
	testl	%eax, %eax
	je	.L33
	movq	-32(%rbp), %rax
	movl	12(%rax), %eax
	leal	1(%rax), %edx
	leaq	-19(%rbp), %rax
	movl	%edx, %esi
	movq	%rax, %rdi
	call	push
	jmp	.L33
.L36:
	movl	-40(%rbp), %eax
	cltq
	movzbl	-19(%rbp,%rax), %eax
	cmpb	$98, %al
	jne	.L38
	movl	-40(%rbp), %eax
	addl	$1, %eax
	cltq
	movzbl	-19(%rbp,%rax), %eax
	cmpb	$103, %al
	je	.L39
.L38:
	movl	-40(%rbp), %eax
	cltq
	movzbl	-19(%rbp,%rax), %eax
	cmpb	$103, %al
	jne	.L33
	movl	-40(%rbp), %eax
	addl	$1, %eax
	cltq
	movzbl	-19(%rbp,%rax), %eax
	cmpb	$98, %al
	jne	.L33
.L39:
	movl	-40(%rbp), %eax
	addl	$1, %eax
	movslq	%eax, %rdx
	movb	$114, -19(%rbp,%rdx)
	cltq
	movzbl	-19(%rbp,%rax), %edx
	movl	-40(%rbp), %eax
	cltq
	movb	%dl, -19(%rbp,%rax)
	leaq	-19(%rbp), %rax
	movq	%rax, %rdi
	call	add
	testl	%eax, %eax
	je	.L33
	movq	-32(%rbp), %rax
	movl	12(%rax), %eax
	leal	1(%rax), %edx
	leaq	-19(%rbp), %rax
	movl	%edx, %esi
	movq	%rax, %rdi
	call	push
.L33:
	addl	$1, -40(%rbp)
.L28:
	movl	-36(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -40(%rbp)
	jl	.L40
	movq	-32(%rbp), %rax
	movq	%rax, %rdi
	call	free@PLT
.L21:
	movl	$0, %eax
	call	pop
	movq	%rax, -32(%rbp)
	cmpq	$0, -32(%rbp)
	jne	.L41
	movl	$-1, %eax
.L42:
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L43
	call	__stack_chk_fail@PLT
.L43:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE10:
	.size	search, .-search
	.section	.rodata
.LC0:
	.string	"%s"
.LC1:
	.string	"0"
.LC2:
	.string	"NA"
.LC3:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB11:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
.L50:
	leaq	-19(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	leaq	-19(%rbp), %rax
	leaq	.LC1(%rip), %rdx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	je	.L54
	movl	$0, %eax
	call	flush
	leaq	-19(%rbp), %rax
	movq	%rax, %rdi
	call	add
	leaq	-19(%rbp), %rax
	movl	$0, %esi
	movq	%rax, %rdi
	call	push
	movl	$0, %eax
	call	search
	movl	%eax, -24(%rbp)
	cmpl	$-1, -24(%rbp)
	jne	.L48
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	jmp	.L50
.L48:
	movl	-24(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L50
.L54:
	nop
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L52
	call	__stack_chk_fail@PLT
.L52:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE11:
	.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:
