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<string.h>
int main(){
	int i,j,n,h;
	char S,str[101];
	int A=0,B=0;
	for(i=0;scanf("%s",str)&&str[0]!='0';i++,A=0,B=0){
		if(i%3+1==3)S='A';
		h=strlen(str);
		for(j=1;j<h;j++){
			if(str[j]=='A')A++;
			else B++;
		}
		if(B>A)B++;
		else A++;
		printf("%d %d\n",A,B);
	}
	exit(0);
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d %d\n"
.LC1:
	.string	"%s"
	.text
	.globl	main
	.type	main, @function
main:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$144, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -124(%rbp)
	movl	$0, -120(%rbp)
	movl	$0, -132(%rbp)
	jmp	.L2
.L11:
	movl	-132(%rbp), %edx
	movslq	%edx, %rax
	imulq	$1431655766, %rax, %rax
	shrq	$32, %rax
	movl	%edx, %ecx
	sarl	$31, %ecx
	subl	%ecx, %eax
	movl	%eax, %ecx
	addl	%ecx, %ecx
	addl	%eax, %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	cmpl	$2, %eax
	jne	.L3
	movb	$65, -133(%rbp)
.L3:
	leaq	-112(%rbp), %rax
	movq	%rax, %rdi
	call	strlen@PLT
	movl	%eax, -116(%rbp)
	movl	$1, -128(%rbp)
	jmp	.L4
.L7:
	movl	-128(%rbp), %eax
	cltq
	movzbl	-112(%rbp,%rax), %eax
	cmpb	$65, %al
	jne	.L5
	addl	$1, -124(%rbp)
	jmp	.L6
.L5:
	addl	$1, -120(%rbp)
.L6:
	addl	$1, -128(%rbp)
.L4:
	movl	-128(%rbp), %eax
	cmpl	-116(%rbp), %eax
	jl	.L7
	movl	-120(%rbp), %eax
	cmpl	-124(%rbp), %eax
	jle	.L8
	addl	$1, -120(%rbp)
	jmp	.L9
.L8:
	addl	$1, -124(%rbp)
.L9:
	movl	-120(%rbp), %edx
	movl	-124(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	addl	$1, -132(%rbp)
	movl	$0, -124(%rbp)
	movl	$0, -120(%rbp)
.L2:
	leaq	-112(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	testl	%eax, %eax
	je	.L10
	movzbl	-112(%rbp), %eax
	cmpb	$48, %al
	jne	.L11
.L10:
	movl	$0, %edi
	call	exit@PLT
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:
```

Only output the optimized assembly code. Do not include any other text. Do not write any comments in the assembly code. Wrap the assembly code in ```assembly``` tags.
user
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC2:
	.string	"%d %d\n"
.LC3:
	.string	"%s"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB35:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	leaq	.LC2(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	leaq	.LC3(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	subq	$112, %rsp
	.cfi_def_cfa_offset 144
	movq	%fs:40, %rax
	movq	%rax, 104(%rsp)
	xorl	%eax, %eax
	movq	%rsp, %rbx
	jmp	.L2
	.p2align 4,,10
	.p2align 3
.L38:
	addl	$1, %ecx
.L39:
	movq	%r12, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L2:
	xorl	%eax, %eax
	movq	%rbx, %rsi
	movq	%rbp, %rdi
	call	__isoc99_scanf@PLT
	testl	%eax, %eax
	je	.L40
	cmpb	$48, (%rsp)
	je	.L40
	movq	%rbx, %rdi
	call	strlen@PLT
	cmpq	$1, %rax
	jbe	.L43
	leal	-2(%rax), %edx
	leal	-1(%rax), %edi
	cmpl	$14, %edx
	jbe	.L44
	movdqu	1(%rsp), %xmm1
	pxor	%xmm5, %xmm5
	pxor	%xmm4, %xmm4
	movl	%edi, %edx
	movdqa	.LC1(%rip), %xmm2
	movdqa	%xmm5, %xmm0
	movdqa	%xmm4, %xmm3
	shrl	$4, %edx
	pcmpeqb	.LC0(%rip), %xmm1
	pand	%xmm1, %xmm2
	pandn	.LC1(%rip), %xmm1
	pcmpgtb	%xmm2, %xmm0
	movdqa	%xmm2, %xmm6
	punpcklbw	%xmm0, %xmm6
	punpckhbw	%xmm0, %xmm2
	pcmpgtw	%xmm6, %xmm3
	movdqa	%xmm6, %xmm7
	movdqa	%xmm6, %xmm0
	movdqa	%xmm2, %xmm6
	punpcklwd	%xmm3, %xmm7
	punpckhwd	%xmm3, %xmm0
	movdqa	%xmm4, %xmm3
	pcmpgtw	%xmm2, %xmm3
	paddd	%xmm7, %xmm0
	punpcklwd	%xmm3, %xmm6
	punpckhwd	%xmm3, %xmm2
	paddd	%xmm6, %xmm0
	movdqa	%xmm0, %xmm3
	movdqa	%xmm5, %xmm0
	pcmpgtb	%xmm1, %xmm0
	paddd	%xmm2, %xmm3
	movdqa	%xmm1, %xmm2
	punpcklbw	%xmm0, %xmm2
	punpckhbw	%xmm0, %xmm1
	movdqa	%xmm4, %xmm0
	pcmpgtw	%xmm2, %xmm0
	movdqa	%xmm2, %xmm6
	punpcklwd	%xmm0, %xmm6
	punpckhwd	%xmm0, %xmm2
	movdqa	%xmm4, %xmm0
	pcmpgtw	%xmm1, %xmm0
	paddd	%xmm6, %xmm2
	movdqa	%xmm1, %xmm6
	punpcklwd	%xmm0, %xmm6
	punpckhwd	%xmm0, %xmm1
	paddd	%xmm6, %xmm2
	movdqa	%xmm2, %xmm0
	paddd	%xmm1, %xmm0
	cmpl	$1, %edx
	je	.L5
	movdqu	17(%rsp), %xmm1
	movdqa	%xmm5, %xmm6
	movdqa	%xmm4, %xmm8
	movdqa	.LC1(%rip), %xmm2
	pcmpeqb	.LC0(%rip), %xmm1
	pand	%xmm1, %xmm2
	pandn	.LC1(%rip), %xmm1
	pcmpgtb	%xmm2, %xmm6
	movdqa	%xmm2, %xmm7
	punpcklbw	%xmm6, %xmm7
	punpckhbw	%xmm6, %xmm2
	pcmpgtw	%xmm7, %xmm8
	movdqa	%xmm7, %xmm6
	punpcklwd	%xmm8, %xmm6
	punpckhwd	%xmm8, %xmm7
	paddd	%xmm6, %xmm3
	movdqa	%xmm4, %xmm6
	pcmpgtw	%xmm2, %xmm6
	paddd	%xmm7, %xmm3
	movdqa	%xmm2, %xmm7
	punpcklwd	%xmm6, %xmm7
	punpckhwd	%xmm6, %xmm2
	movdqa	%xmm1, %xmm6
	paddd	%xmm7, %xmm3
	movdqa	%xmm4, %xmm7
	paddd	%xmm2, %xmm3
	movdqa	%xmm5, %xmm2
	pcmpgtb	%xmm1, %xmm2
	punpcklbw	%xmm2, %xmm6
	punpckhbw	%xmm2, %xmm1
	pcmpgtw	%xmm6, %xmm7
	movdqa	%xmm6, %xmm2
	punpcklwd	%xmm7, %xmm2
	punpckhwd	%xmm7, %xmm6
	paddd	%xmm2, %xmm0
	movdqa	%xmm4, %xmm2
	pcmpgtw	%xmm1, %xmm2
	paddd	%xmm6, %xmm0
	movdqa	%xmm1, %xmm6
	punpcklwd	%xmm2, %xmm6
	punpckhwd	%xmm2, %xmm1
	paddd	%xmm6, %xmm0
	paddd	%xmm1, %xmm0
	cmpl	$2, %edx
	je	.L5
	movdqu	33(%rsp), %xmm1
	movdqa	%xmm5, %xmm6
	movdqa	%xmm4, %xmm8
	movdqa	.LC1(%rip), %xmm2
	pcmpeqb	.LC0(%rip), %xmm1
	pand	%xmm1, %xmm2
	pandn	.LC1(%rip), %xmm1
	pcmpgtb	%xmm2, %xmm6
	movdqa	%xmm2, %xmm7
	punpcklbw	%xmm6, %xmm7
	punpckhbw	%xmm6, %xmm2
	pcmpgtw	%xmm7, %xmm8
	movdqa	%xmm7, %xmm6
	punpcklwd	%xmm8, %xmm6
	punpckhwd	%xmm8, %xmm7
	paddd	%xmm6, %xmm3
	movdqa	%xmm4, %xmm6
	pcmpgtw	%xmm2, %xmm6
	paddd	%xmm7, %xmm3
	movdqa	%xmm2, %xmm7
	punpcklwd	%xmm6, %xmm7
	punpckhwd	%xmm6, %xmm2
	movdqa	%xmm1, %xmm6
	paddd	%xmm7, %xmm3
	movdqa	%xmm4, %xmm7
	paddd	%xmm2, %xmm3
	movdqa	%xmm5, %xmm2
	pcmpgtb	%xmm1, %xmm2
	punpcklbw	%xmm2, %xmm6
	punpckhbw	%xmm2, %xmm1
	pcmpgtw	%xmm6, %xmm7
	movdqa	%xmm6, %xmm2
	punpcklwd	%xmm7, %xmm2
	punpckhwd	%xmm7, %xmm6
	paddd	%xmm2, %xmm0
	movdqa	%xmm4, %xmm2
	pcmpgtw	%xmm1, %xmm2
	paddd	%xmm6, %xmm0
	movdqa	%xmm1, %xmm6
	punpcklwd	%xmm2, %xmm6
	punpckhwd	%xmm2, %xmm1
	paddd	%xmm6, %xmm0
	paddd	%xmm1, %xmm0
	cmpl	$3, %edx
	je	.L5
	movdqu	49(%rsp), %xmm1
	movdqa	%xmm5, %xmm6
	movdqa	%xmm4, %xmm8
	movdqa	.LC1(%rip), %xmm2
	pcmpeqb	.LC0(%rip), %xmm1
	pand	%xmm1, %xmm2
	pandn	.LC1(%rip), %xmm1
	pcmpgtb	%xmm2, %xmm6
	movdqa	%xmm2, %xmm7
	punpcklbw	%xmm6, %xmm7
	punpckhbw	%xmm6, %xmm2
	pcmpgtw	%xmm7, %xmm8
	movdqa	%xmm7, %xmm6
	punpcklwd	%xmm8, %xmm6
	punpckhwd	%xmm8, %xmm7
	paddd	%xmm6, %xmm3
	movdqa	%xmm4, %xmm6
	pcmpgtw	%xmm2, %xmm6
	paddd	%xmm7, %xmm3
	movdqa	%xmm2, %xmm7
	punpcklwd	%xmm6, %xmm7
	punpckhwd	%xmm6, %xmm2
	movdqa	%xmm1, %xmm6
	paddd	%xmm7, %xmm3
	movdqa	%xmm4, %xmm7
	paddd	%xmm2, %xmm3
	movdqa	%xmm5, %xmm2
	pcmpgtb	%xmm1, %xmm2
	punpcklbw	%xmm2, %xmm6
	punpckhbw	%xmm2, %xmm1
	pcmpgtw	%xmm6, %xmm7
	movdqa	%xmm6, %xmm2
	punpcklwd	%xmm7, %xmm2
	punpckhwd	%xmm7, %xmm6
	paddd	%xmm2, %xmm0
	movdqa	%xmm4, %xmm2
	pcmpgtw	%xmm1, %xmm2
	paddd	%xmm6, %xmm0
	movdqa	%xmm1, %xmm6
	punpcklwd	%xmm2, %xmm6
	punpckhwd	%xmm2, %xmm1
	paddd	%xmm6, %xmm0
	paddd	%xmm1, %xmm0
	cmpl	$4, %edx
	je	.L5
	movdqu	65(%rsp), %xmm1
	movdqa	%xmm5, %xmm6
	movdqa	%xmm4, %xmm8
	movdqa	.LC1(%rip), %xmm2
	pcmpeqb	.LC0(%rip), %xmm1
	pand	%xmm1, %xmm2
	pandn	.LC1(%rip), %xmm1
	pcmpgtb	%xmm2, %xmm6
	movdqa	%xmm2, %xmm7
	punpcklbw	%xmm6, %xmm7
	punpckhbw	%xmm6, %xmm2
	pcmpgtw	%xmm7, %xmm8
	movdqa	%xmm7, %xmm6
	punpcklwd	%xmm8, %xmm6
	punpckhwd	%xmm8, %xmm7
	paddd	%xmm6, %xmm3
	movdqa	%xmm4, %xmm6
	pcmpgtw	%xmm2, %xmm6
	paddd	%xmm7, %xmm3
	movdqa	%xmm2, %xmm7
	punpcklwd	%xmm6, %xmm7
	punpckhwd	%xmm6, %xmm2
	movdqa	%xmm1, %xmm6
	paddd	%xmm7, %xmm3
	movdqa	%xmm4, %xmm7
	paddd	%xmm2, %xmm3
	movdqa	%xmm5, %xmm2
	pcmpgtb	%xmm1, %xmm2
	punpcklbw	%xmm2, %xmm6
	punpckhbw	%xmm2, %xmm1
	pcmpgtw	%xmm6, %xmm7
	movdqa	%xmm6, %xmm2
	punpcklwd	%xmm7, %xmm2
	punpckhwd	%xmm7, %xmm6
	paddd	%xmm2, %xmm0
	movdqa	%xmm4, %xmm2
	pcmpgtw	%xmm1, %xmm2
	paddd	%xmm6, %xmm0
	movdqa	%xmm1, %xmm6
	punpcklwd	%xmm2, %xmm6
	punpckhwd	%xmm2, %xmm1
	paddd	%xmm6, %xmm0
	paddd	%xmm1, %xmm0
	cmpl	$6, %edx
	jne	.L5
	movdqu	81(%rsp), %xmm2
	movdqa	%xmm5, %xmm6
	movdqa	%xmm4, %xmm8
	movdqa	.LC1(%rip), %xmm1
	pcmpeqb	.LC0(%rip), %xmm2
	pand	%xmm2, %xmm1
	pandn	.LC1(%rip), %xmm2
	pcmpgtb	%xmm1, %xmm6
	movdqa	%xmm1, %xmm7
	pcmpgtb	%xmm2, %xmm5
	punpcklbw	%xmm6, %xmm7
	punpckhbw	%xmm6, %xmm1
	pcmpgtw	%xmm7, %xmm8
	movdqa	%xmm7, %xmm6
	punpcklwd	%xmm8, %xmm6
	punpckhwd	%xmm8, %xmm7
	paddd	%xmm6, %xmm3
	movdqa	%xmm4, %xmm6
	pcmpgtw	%xmm1, %xmm6
	paddd	%xmm7, %xmm3
	movdqa	%xmm1, %xmm7
	punpcklwd	%xmm6, %xmm7
	punpckhwd	%xmm6, %xmm1
	movdqa	%xmm4, %xmm6
	paddd	%xmm7, %xmm3
	paddd	%xmm1, %xmm3
	movdqa	%xmm5, %xmm1
	movdqa	%xmm2, %xmm5
	punpcklbw	%xmm1, %xmm5
	punpckhbw	%xmm1, %xmm2
	pcmpgtw	%xmm5, %xmm6
	pcmpgtw	%xmm2, %xmm4
	movdqa	%xmm5, %xmm1
	punpcklwd	%xmm6, %xmm1
	punpckhwd	%xmm6, %xmm5
	paddd	%xmm0, %xmm1
	movdqa	%xmm4, %xmm0
	movdqa	%xmm2, %xmm4
	punpcklwd	%xmm0, %xmm4
	paddd	%xmm5, %xmm1
	punpckhwd	%xmm0, %xmm2
	paddd	%xmm4, %xmm1
	movdqa	%xmm1, %xmm0
	paddd	%xmm2, %xmm0
.L5:
	movdqa	%xmm0, %xmm1
	movl	%edi, %r8d
	psrldq	$8, %xmm1
	andl	$-16, %r8d
	paddd	%xmm0, %xmm1
	leal	1(%r8), %esi
	movdqa	%xmm1, %xmm0
	psrldq	$4, %xmm0
	paddd	%xmm0, %xmm1
	movdqa	%xmm3, %xmm0
	psrldq	$8, %xmm0
	movd	%xmm1, %ecx
	paddd	%xmm3, %xmm0
	movdqa	%xmm0, %xmm1
	psrldq	$4, %xmm1
	paddd	%xmm1, %xmm0
	movd	%xmm0, %edx
	cmpl	%r8d, %edi
	je	.L6
.L4:
	movslq	%esi, %rdi
	cmpb	$65, (%rsp,%rdi)
	je	.L62
	addl	$1, %ecx
.L8:
	leal	1(%rsi), %edi
	cmpl	%eax, %edi
	jge	.L6
	movslq	%edi, %rdi
	cmpb	$65, (%rsp,%rdi)
	je	.L63
	addl	$1, %ecx
.L10:
	leal	2(%rsi), %edi
	cmpl	%edi, %eax
	jle	.L6
	movslq	%edi, %rdi
	cmpb	$65, (%rsp,%rdi)
	je	.L64
	addl	$1, %ecx
.L12:
	leal	3(%rsi), %edi
	cmpl	%edi, %eax
	jle	.L6
	movslq	%edi, %rdi
	cmpb	$65, (%rsp,%rdi)
	je	.L65
	addl	$1, %ecx
.L14:
	leal	4(%rsi), %edi
	cmpl	%edi, %eax
	jle	.L6
	movslq	%edi, %rdi
	cmpb	$65, (%rsp,%rdi)
	je	.L66
	addl	$1, %ecx
.L16:
	leal	5(%rsi), %edi
	cmpl	%edi, %eax
	jle	.L6
	movslq	%edi, %rdi
	cmpb	$65, (%rsp,%rdi)
	je	.L67
	addl	$1, %ecx
.L18:
	leal	6(%rsi), %edi
	cmpl	%edi, %eax
	jle	.L6
	movslq	%edi, %rdi
	cmpb	$65, (%rsp,%rdi)
	je	.L68
	addl	$1, %ecx
.L20:
	leal	7(%rsi), %edi
	cmpl	%edi, %eax
	jle	.L6
	movslq	%edi, %rdi
	cmpb	$65, (%rsp,%rdi)
	je	.L69
	addl	$1, %ecx
.L22:
	leal	8(%rsi), %edi
	cmpl	%edi, %eax
	jle	.L6
	movslq	%edi, %rdi
	cmpb	$65, (%rsp,%rdi)
	je	.L70
	addl	$1, %ecx
.L24:
	leal	9(%rsi), %edi
	cmpl	%edi, %eax
	jle	.L6
	movslq	%edi, %rdi
	cmpb	$65, (%rsp,%rdi)
	je	.L71
	addl	$1, %ecx
.L26:
	leal	10(%rsi), %edi
	cmpl	%edi, %eax
	jle	.L6
	movslq	%edi, %rdi
	cmpb	$65, (%rsp,%rdi)
	je	.L72
	addl	$1, %ecx
.L28:
	leal	11(%rsi), %edi
	cmpl	%edi, %eax
	jle	.L6
	movslq	%edi, %rdi
	cmpb	$65, (%rsp,%rdi)
	je	.L73
	addl	$1, %ecx
.L30:
	leal	12(%rsi), %edi
	cmpl	%edi, %eax
	jle	.L6
	movslq	%edi, %rdi
	cmpb	$65, (%rsp,%rdi)
	je	.L74
	addl	$1, %ecx
.L32:
	leal	13(%rsi), %edi
	cmpl	%edi, %eax
	jle	.L6
	movslq	%edi, %rdi
	cmpb	$65, (%rsp,%rdi)
	je	.L75
	addl	$1, %ecx
.L34:
	addl	$14, %esi
	cmpl	%esi, %eax
	jle	.L6
	movslq	%esi, %rsi
	cmpb	$65, (%rsp,%rsi)
	je	.L35
	addl	$1, %ecx
	.p2align 4,,10
	.p2align 3
.L6:
	cmpl	%ecx, %edx
	jl	.L38
	addl	$1, %edx
	jmp	.L39
	.p2align 4,,10
	.p2align 3
.L62:
	addl	$1, %edx
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L63:
	addl	$1, %edx
	jmp	.L10
	.p2align 4,,10
	.p2align 3
.L64:
	addl	$1, %edx
	jmp	.L12
	.p2align 4,,10
	.p2align 3
.L65:
	addl	$1, %edx
	jmp	.L14
	.p2align 4,,10
	.p2align 3
.L66:
	addl	$1, %edx
	jmp	.L16
	.p2align 4,,10
	.p2align 3
.L67:
	addl	$1, %edx
	jmp	.L18
	.p2align 4,,10
	.p2align 3
.L68:
	addl	$1, %edx
	jmp	.L20
	.p2align 4,,10
	.p2align 3
.L69:
	addl	$1, %edx
	jmp	.L22
	.p2align 4,,10
	.p2align 3
.L40:
	xorl	%edi, %edi
	call	exit@PLT
	.p2align 4,,10
	.p2align 3
.L70:
	addl	$1, %edx
	jmp	.L24
	.p2align 4,,10
	.p2align 3
.L43:
	movl	$1, %edx
	xorl	%ecx, %ecx
	jmp	.L39
	.p2align 4,,10
	.p2align 3
.L71:
	addl	$1, %edx
	jmp	.L26
.L44:
	xorl	%ecx, %ecx
	xorl	%edx, %edx
	movl	$1, %esi
	jmp	.L4
.L72:
	addl	$1, %edx
	jmp	.L28
.L73:
	addl	$1, %edx
	jmp	.L30
.L74:
	addl	$1, %edx
	jmp	.L32
.L75:
	addl	$1, %edx
	jmp	.L34
.L35:
	addl	$1, %edx
	jmp	.L6
	.cfi_endproc
.LFE35:
	.size	main, .-main
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC0:
	.byte	65
	.byte	65
	.byte	65
	.byte	65
	.byte	65
	.byte	65
	.byte	65
	.byte	65
	.byte	65
	.byte	65
	.byte	65
	.byte	65
	.byte	65
	.byte	65
	.byte	65
	.byte	65
	.align 16
.LC1:
	.byte	1
	.byte	1
	.byte	1
	.byte	1
	.byte	1
	.byte	1
	.byte	1
	.byte	1
	.byte	1
	.byte	1
	.byte	1
	.byte	1
	.byte	1
	.byte	1
	.byte	1
	.byte	1
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:

rule
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC2:
	.string	"%d %d\n"
.LC3:
	.string	"%s"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB35:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	leaq	.LC2(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	leaq	.LC3(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	subq	$112, %rsp
	.cfi_def_cfa_offset 144
	movq	%fs:40, %rax
	movq	%rax, 104(%rsp)
	xorl	%eax, %eax
	movq	%rsp, %rbx
	jmp	.L2
	.p2align 4,,10
	.p2align 3
.L38:
	addl	$1, %ecx
.L39:
	movq	%r12, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L2:
	xorl	%eax, %eax
	movq	%rbx, %rsi
	movq	%rbp, %rdi
	call	__isoc99_scanf@PLT
	testl	%eax, %eax
	je	.L40
	cmpb	$48, (%rsp)
	je	.L40
	movq	%rbx, %rdi
	call	strlen@PLT
	cmpq	$1, %rax
	jbe	.L43
	leal	-2(%rax), %edx
	leal	-1(%rax), %edi
	cmpl	$14, %edx
	jbe	.L44
	movdqu	1(%rsp), %xmm1
	pxor	%xmm5, %xmm5
	pxor	%xmm4, %xmm4
	movl	%edi, %edx
	movdqa	.LC1(%rip), %xmm2
	movdqa	%xmm5, %xmm0
	movdqa	%xmm4, %xmm3
	shrl	$4, %edx
	pcmpeqb	.LC0(%rip), %xmm1
	pand	%xmm1, %xmm2
	pandn	.LC1(%rip), %xmm1
	pcmpgtb	%xmm2, %xmm0
	movdqa	%xmm2, %xmm6
	punpcklbw	%xmm0, %xmm6
	punpckhbw	%xmm0, %xmm2
	pcmpgtw	%xmm6, %xmm3
	movdqa	%xmm6, %xmm7
	movdqa	%xmm6, %xmm0
	movdqa	%xmm2, %xmm6
	punpcklwd	%xmm3, %xmm7
	punpckhwd	%xmm3, %xmm0
	movdqa	%xmm4, %xmm3
	pcmpgtw	%xmm2, %xmm3
	paddd	%xmm7, %xmm0
	punpcklwd	%xmm3, %xmm6
	punpckhwd	%xmm3, %xmm2
	paddd	%xmm6, %xmm0
	movdqa	%xmm0, %xmm3
	movdqa	%xmm5, %xmm0
	pcmpgtb	%xmm1, %xmm0
	paddd	%xmm2, %xmm3
	movdqa	%xmm1, %xmm2
	punpcklbw	%xmm0, %xmm2
	punpckhbw	%xmm0, %xmm1
	movdqa	%xmm4, %xmm0
	pcmpgtw	%xmm2, %xmm0
	movdqa	%xmm2, %xmm6
	punpcklwd	%xmm0, %xmm6
	punpckhwd	%xmm0, %xmm2
	movdqa	%xmm4, %xmm0
	pcmpgtw	%xmm1, %xmm0
	paddd	%xmm6, %xmm2
	movdqa	%xmm1, %xmm6
	punpcklwd	%xmm0, %xmm6
	punpckhwd	%xmm0, %xmm1
	paddd	%xmm6, %xmm2
	movdqa	%xmm2, %xmm0
	paddd	%xmm1, %xmm0
	cmpl	$1, %edx
	je	.L5
	movdqu	17(%rsp), %xmm1
	movdqa	%xmm5, %xmm6
	movdqa	%xmm4, %xmm8
	movdqa	.LC1(%rip), %xmm2
	pcmpeqb	.LC0(%rip), %xmm1
	pand	%xmm1, %xmm2
	pandn	.LC1(%rip), %xmm1
	pcmpgtb	%xmm2, %xmm6
	movdqa	%xmm2, %xmm7
	punpcklbw	%xmm6, %xmm7
	punpckhbw	%xmm6, %xmm2
	pcmpgtw	%xmm7, %xmm8
	movdqa	%xmm7, %xmm6
	punpcklwd	%xmm8, %xmm6
	punpckhwd	%xmm8, %xmm7
	paddd	%xmm6, %xmm3
	movdqa	%xmm4, %xmm6
	pcmpgtw	%xmm2, %xmm6
	paddd	%xmm7, %xmm3
	movdqa	%xmm2, %xmm7
	punpcklwd	%xmm6, %xmm7
	punpckhwd	%xmm6, %xmm2
	movdqa	%xmm1, %xmm6
	paddd	%xmm7, %xmm3
	movdqa	%xmm4, %xmm7
	paddd	%xmm2, %xmm3
	movdqa	%xmm5, %xmm2
	pcmpgtb	%xmm1, %xmm2
	punpcklbw	%xmm2, %xmm6
	punpckhbw	%xmm2, %xmm1
	pcmpgtw	%xmm6, %xmm7
	movdqa	%xmm6, %xmm2
	punpcklwd	%xmm7, %xmm2
	punpckhwd	%xmm7, %xmm6
	paddd	%xmm2, %xmm0
	movdqa	%xmm4, %xmm2
	pcmpgtw	%xmm1, %xmm2
	paddd	%xmm6, %xmm0
	movdqa	%xmm1, %xmm6
	punpcklwd	%xmm2, %xmm6
	punpckhwd	%xmm2, %xmm1
	paddd	%xmm6, %xmm0
	paddd	%xmm1, %xmm0
	cmpl	$2, %edx
	je	.L5
	movdqu	33(%rsp), %xmm1
	movdqa	%xmm5, %xmm6
	movdqa	%xmm4, %xmm8
	movdqa	.LC1(%rip), %xmm2
	pcmpeqb	.LC0(%rip), %xmm1
	pand	%xmm1, %xmm2
	pandn	.LC1(%rip), %xmm1
	pcmpgtb	%xmm2, %xmm6
	movdqa	%xmm2, %xmm7
	punpcklbw	%xmm6, %xmm7
	punpckhbw	%xmm6, %xmm2
	pcmpgtw	%xmm7, %xmm8
	movdqa	%xmm7, %xmm6
	punpcklwd	%xmm8, %xmm6
	punpckhwd	%xmm8, %xmm7
	paddd	%xmm6, %xmm3
	movdqa	%xmm4, %xmm6
	pcmpgtw	%xmm2, %xmm6
	paddd	%xmm7, %xmm3
	movdqa	%xmm2, %xmm7
	punpcklwd	%xmm6, %xmm7
	punpckhwd	%xmm6, %xmm2
	movdqa	%xmm1, %xmm6
	paddd	%xmm7, %xmm3
	movdqa	%xmm4, %xmm7
	paddd	%xmm2, %xmm3
	movdqa	%xmm5, %xmm2
	pcmpgtb	%xmm1, %xmm2
	punpcklbw	%xmm2, %xmm6
	punpckhbw	%xmm2, %xmm1
	pcmpgtw	%xmm6, %xmm7
	movdqa	%xmm6, %xmm2
	punpcklwd	%xmm7, %xmm2
	punpckhwd	%xmm7, %xmm6
	paddd	%xmm2, %xmm0
	movdqa	%xmm4, %xmm2
	pcmpgtw	%xmm1, %xmm2
	paddd	%xmm6, %xmm0
	movdqa	%xmm1, %xmm6
	punpcklwd	%xmm2, %xmm6
	punpckhwd	%xmm2, %xmm1
	paddd	%xmm6, %xmm0
	paddd	%xmm1, %xmm0
	cmpl	$3, %edx
	je	.L5
	movdqu	49(%rsp), %xmm1
	movdqa	%xmm5, %xmm6
	movdqa	%xmm4, %xmm8
	movdqa	.LC1(%rip), %xmm2
	pcmpeqb	.LC0(%rip), %xmm1
	pand	%xmm1, %xmm2
	pandn	.LC1(%rip), %xmm1
	pcmpgtb	%xmm2, %xmm6
	movdqa	%xmm2, %xmm7
	punpcklbw	%xmm6, %xmm7
	punpckhbw	%xmm6, %xmm2
	pcmpgtw	%xmm7, %xmm8
	movdqa	%xmm7, %xmm6
	punpcklwd	%xmm8, %xmm6
	punpckhwd	%xmm8, %xmm7
	paddd	%xmm6, %xmm3
	movdqa	%xmm4, %xmm6
	pcmpgtw	%xmm2, %xmm6
	paddd	%xmm7, %xmm3
	movdqa	%xmm2, %xmm7
	punpcklwd	%xmm6, %xmm7
	punpckhwd	%xmm6, %xmm2
	movdqa	%xmm1, %xmm6
	paddd	%xmm7, %xmm3
	movdqa	%xmm4, %xmm7
	paddd	%xmm2, %xmm3
	movdqa	%xmm5, %xmm2
	pcmpgtb	%xmm1, %xmm2
	punpcklbw	%xmm2, %xmm6
	punpckhbw	%xmm2, %xmm1
	pcmpgtw	%xmm6, %xmm7
	movdqa	%xmm6, %xmm2
	punpcklwd	%xmm7, %xmm2
	punpckhwd	%xmm7, %xmm6
	paddd	%xmm2, %xmm0
	movdqa	%xmm4, %xmm2
	pcmpgtw	%xmm1, %xmm2
	paddd	%xmm6, %xmm0
	movdqa	%xmm1, %xmm6
	punpcklwd	%xmm2, %xmm6
	punpckhwd	%xmm2, %xmm1
	paddd	%xmm6, %xmm0
	paddd	%xmm1, %xmm0
	cmpl	$4, %edx
	je	.L5
	movdqu	65(%rsp), %xmm1
	movdqa	%xmm5, %xmm6
	movdqa	%xmm4, %xmm8
	movdqa	.LC1(%rip), %xmm2
	pcmpeqb	.LC0(%rip), %xmm1
	pand	%xmm1, %xmm2
	pandn	.LC1(%rip), %xmm1
	pcmpgtb	%xmm2, %xmm6
	movdqa	%xmm2, %xmm7
	punpcklbw	%xmm6, %xmm7
	punpckhbw	%xmm6, %xmm2
	pcmpgtw	%xmm7, %xmm8
	movdqa	%xmm7, %xmm6
	punpcklwd	%xmm8, %xmm6
	punpckhwd	%xmm8, %xmm7
	paddd	%xmm6, %xmm3
	movdqa	%xmm4, %xmm6
	pcmpgtw	%xmm2, %xmm6
	paddd	%xmm7, %xmm3
	movdqa	%xmm2, %xmm7
	punpcklwd	%xmm6, %xmm7
	punpckhwd	%xmm6, %xmm2
	movdqa	%xmm1, %xmm6
	paddd	%xmm7, %xmm3
	movdqa	%xmm4, %xmm7
	paddd	%xmm2, %xmm3
	movdqa	%xmm5, %xmm2
	pcmpgtb	%xmm1, %xmm2
	punpcklbw	%xmm2, %xmm6
	punpckhbw	%xmm2, %xmm1
	pcmpgtw	%xmm6, %xmm7
	movdqa	%xmm6, %xmm2
	punpcklwd	%xmm7, %xmm2
	punpckhwd	%xmm7, %xmm6
	paddd	%xmm2, %xmm0
	movdqa	%xmm4, %xmm2
	pcmpgtw	%xmm1, %xmm2
	paddd	%xmm6, %xmm0
	movdqa	%xmm1, %xmm6
	punpcklwd	%xmm2, %xmm6
	punpckhwd	%xmm2, %xmm1
	paddd	%xmm6, %xmm0
	paddd	%xmm1, %xmm0
	cmpl	$6, %edx
	jne	.L5
	movdqu	81(%rsp), %xmm2
	movdqa	%xmm5, %xmm6
	movdqa	%xmm4, %xmm8
	movdqa	.LC1(%rip), %xmm1
	pcmpeqb	.LC0(%rip), %xmm2
	pand	%xmm2, %xmm1
	pandn	.LC1(%rip), %xmm2
	pcmpgtb	%xmm1, %xmm6
	movdqa	%xmm1, %xmm7
	pcmpgtb	%xmm2, %xmm5
	punpcklbw	%xmm6, %xmm7
	punpckhbw	%xmm6, %xmm1
	pcmpgtw	%xmm7, %xmm8
	movdqa	%xmm7, %xmm6
	punpcklwd	%xmm8, %xmm6
	punpckhwd	%xmm8, %xmm7
	paddd	%xmm6, %xmm3
	movdqa	%xmm4, %xmm6
	pcmpgtw	%xmm1, %xmm6
	paddd	%xmm7, %xmm3
	movdqa	%xmm1, %xmm7
	punpcklwd	%xmm6, %xmm7
	punpckhwd	%xmm6, %xmm1
	movdqa	%xmm4, %xmm6
	paddd	%xmm7, %xmm3
	paddd	%xmm1, %xmm3
	movdqa	%xmm5, %xmm1
	movdqa	%xmm2, %xmm5
	punpcklbw	%xmm1, %xmm5
	punpckhbw	%xmm1, %xmm2
	pcmpgtw	%xmm5, %xmm6
	pcmpgtw	%xmm2, %xmm4
	movdqa	%xmm5, %xmm1
	punpcklwd	%xmm6, %xmm1
	punpckhwd	%xmm6, %xmm5
	paddd	%xmm0, %xmm1
	movdqa	%xmm4, %xmm0
	movdqa	%xmm2, %xmm4
	punpcklwd	%xmm0, %xmm4
	paddd	%xmm5, %xmm1
	punpckhwd	%xmm0, %xmm2
	paddd	%xmm4, %xmm1
	movdqa	%xmm1, %xmm0
	paddd	%xmm2, %xmm0
.L5:
	movdqa	%xmm0, %xmm1
	movl	%edi, %r8d
	psrldq	$8, %xmm1
	andl	$-16, %r8d
	paddd	%xmm0, %xmm1
	leal	1(%r8), %esi
	movdqa	%xmm1, %xmm0
	psrldq	$4, %xmm0
	paddd	%xmm0, %xmm1
	movdqa	%xmm3, %xmm0
	psrldq	$8, %xmm0
	movd	%xmm1, %ecx
	paddd	%xmm3, %xmm0
	movdqa	%xmm0, %xmm1
	psrldq	$4, %xmm1
	paddd	%xmm1, %xmm0
	movd	%xmm0, %edx
	cmpl	%r8d, %edi
	je	.L6
.L4:
	movslq	%esi, %rdi
	cmpb	$65, (%rsp,%rdi)
	je	.L62
	addl	$1, %ecx
.L8:
	leal	1(%rsi), %edi
	cmpl	%eax, %edi
	jge	.L6
	movslq	%edi, %rdi
	cmpb	$65, (%rsp,%rdi)
	je	.L63
	addl	$1, %ecx
.L10:
	leal	2(%rsi), %edi
	cmpl	%edi, %eax
	jle	.L6
	movslq	%edi, %rdi
	cmpb	$65, (%rsp,%rdi)
	je	.L64
	addl	$1, %ecx
.L12:
	leal	3(%rsi), %edi
	cmpl	%edi, %eax
	jle	.L6
	movslq	%edi, %rdi
	cmpb	$65, (%rsp,%rdi)
	je	.L65
	addl	$1, %ecx
.L14:
	leal	4(%rsi), %edi
	cmpl	%edi, %eax
	jle	.L6
	movslq	%edi, %rdi
	cmpb	$65, (%rsp,%rdi)
	je	.L66
	addl	$1, %ecx
.L16:
	leal	5(%rsi), %edi
	cmpl	%edi, %eax
	jle	.L6
	movslq	%edi, %rdi
	cmpb	$65, (%rsp,%rdi)
	je	.L67
	addl	$1, %ecx
.L18:
	leal	6(%rsi), %edi
	cmpl	%edi, %eax
	jle	.L6
	movslq	%edi, %rdi
	cmpb	$65, (%rsp,%rdi)
	je	.L68
	addl	$1, %ecx
.L20:
	leal	7(%rsi), %edi
	cmpl	%edi, %eax
	jle	.L6
	movslq	%edi, %rdi
	cmpb	$65, (%rsp,%rdi)
	je	.L69
	addl	$1, %ecx
.L22:
	leal	8(%rsi), %edi
	cmpl	%edi, %eax
	jle	.L6
	movslq	%edi, %rdi
	cmpb	$65, (%rsp,%rdi)
	je	.L70
	addl	$1, %ecx
.L24:
	leal	9(%rsi), %edi
	cmpl	%edi, %eax
	jle	.L6
	movslq	%edi, %rdi
	cmpb	$65, (%rsp,%rdi)
	je	.L71
	addl	$1, %ecx
.L26:
	leal	10(%rsi), %edi
	cmpl	%edi, %eax
	jle	.L6
	movslq	%edi, %rdi
	cmpb	$65, (%rsp,%rdi)
	je	.L72
	addl	$1, %ecx
.L28:
	leal	11(%rsi), %edi
	cmpl	%edi, %eax
	jle	.L6
	movslq	%edi, %rdi
	cmpb	$65, (%rsp,%rdi)
	je	.L73
	addl	$1, %ecx
.L30:
	leal	12(%rsi), %edi
	cmpl	%edi, %eax
	jle	.L6
	movslq	%edi, %rdi
	cmpb	$65, (%rsp,%rdi)
	je	.L74
	addl	$1, %ecx
.L32:
	leal	13(%rsi), %edi
	cmpl	%edi, %eax
	jle	.L6
	movslq	%edi, %rdi
	cmpb	$65, (%rsp,%rdi)
	je	.L75
	addl	$1, %ecx
.L34:
	addl	$14, %esi
	cmpl	%esi, %eax
	jle	.L6
	movslq	%esi, %rsi
	cmpb	$65, (%rsp,%rsi)
	je	.L35
	addl	$1, %ecx
	.p2align 4,,10
	.p2align 3
.L6:
	cmpl	%ecx, %edx
	jl	.L38
	addl	$1, %edx
	jmp	.L39
	.p2align 4,,10
	.p2align 3
.L62:
	addl	$1, %edx
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L63:
	addl	$1, %edx
	jmp	.L10
	.p2align 4,,10
	.p2align 3
.L64:
	addl	$1, %edx
	jmp	.L12
	.p2align 4,,10
	.p2align 3
.L65:
	addl	$1, %edx
	jmp	.L14
	.p2align 4,,10
	.p2align 3
.L66:
	addl	$1, %edx
	jmp	.L16
	.p2align 4,,10
	.p2align 3
.L67:
	addl	$1, %edx
	jmp	.L18
	.p2align 4,,10
	.p2align 3
.L68:
	addl	$1, %edx
	jmp	.L20
	.p2align 4,,10
	.p2align 3
.L69:
	addl	$1, %edx
	jmp	.L22
	.p2align 4,,10
	.p2align 3
.L40:
	xorl	%edi, %edi
	call	exit@PLT
	.p2align 4,,10
	.p2align 3
.L70:
	addl	$1, %edx
	jmp	.L24
	.p2align 4,,10
	.p2align 3
.L43:
	movl	$1, %edx
	xorl	%ecx, %ecx
	jmp	.L39
	.p2align 4,,10
	.p2align 3
.L71:
	addl	$1, %edx
	jmp	.L26
.L44:
	xorl	%ecx, %ecx
	xorl	%edx, %edx
	movl	$1, %esi
	jmp	.L4
.L72:
	addl	$1, %edx
	jmp	.L28
.L73:
	addl	$1, %edx
	jmp	.L30
.L74:
	addl	$1, %edx
	jmp	.L32
.L75:
	addl	$1, %edx
	jmp	.L34
.L35:
	addl	$1, %edx
	jmp	.L6
	.cfi_endproc
.LFE35:
	.size	main, .-main
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC0:
	.byte	65
	.byte	65
	.byte	65
	.byte	65
	.byte	65
	.byte	65
	.byte	65
	.byte	65
	.byte	65
	.byte	65
	.byte	65
	.byte	65
	.byte	65
	.byte	65
	.byte	65
	.byte	65
	.align 16
.LC1:
	.byte	1
	.byte	1
	.byte	1
	.byte	1
	.byte	1
	.byte	1
	.byte	1
	.byte	1
	.byte	1
	.byte	1
	.byte	1
	.byte	1
	.byte	1
	.byte	1
	.byte	1
	.byte	1
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:

#include<stdio.h>
#include<string.h>
int main(){
	int i,j,n,h;
	char S,str[101];
	int A=0,B=0;
	for(i=0;scanf("%s",str)&&str[0]!='0';i++,A=0,B=0){
		if(i%3+1==3)S='A';
		h=strlen(str);
		for(j=1;j<h;j++){
			if(str[j]=='A')A++;
			else B++;
		}
		if(B>A)B++;
		else A++;
		printf("%d %d\n",A,B);
	}
	exit(0);
}
AABBAAABABAABBBAABA
AABBBABBABBAAABABABAAB
BABAABAABABABBAAAB
AABABAAABBAABBBABAA
AAAAAAAAAAA
ABBBBBBBBBB
0
 ABAABBBAABABAAABBAA
AABBBABBABBAAABABABAAB
BABAABAABABABBAAAB
AABABAAABBAABBBABAA
AAAAAAAAAAA
ABBBBBABBBB
0
 ABAABBBAABABAAABBAA
AABBBABBABBAAABABABAAB
BABAABAABABABBAAAB
AABAABBAABBAAABABAA
AAAAAAAAAAA
ABBBBBABBBB
0
 ABAABABAABABAAABBAA
AABBBABBABBAAABABABAAB
BABAABAABABABBAAAB
AABABAAABBAABBBABAA
AAAAAAAAAAA
ABBBBBABBBB
0
 AABBAAABABAABBBAABA
AABBBABBABBAAABABABAAB
BABAABAABABABBAAAB
AABAABBAABBAAABABAA
AAAAAAAAAAA
ABBBABABBBB
0
 ABBABBAAABABAAABBAA
AABBBABBABBAAABABABAAB
BABAABAABABABBBAAB
AABBBBBAABAAAABABAA
AAAAAAAAAAA
ABBBBBABBBB
0
 AABBAAABABAABBBAABA
AABBBABBABBAAABABABAAB
BABAABAABAABBBAAAB
AABAABBAABBAAABABAB
AAAAAAAAAAA
ABBBABABBBB
0
 ABAABBBAABABAAABBAA
AABBBABBABBAAABABABAAB
BABAABAABABABBAAAA
AABAABBAABBAAABABAA
AAAAAAAAAAA
ABBBBBABBBB
0
 ABBABBAAABABAAABBAA
AABBBABBABBAAABABABAAB
BABAABAABABABBBAAB
AABBBBBAABAAAABABAA
AAAAAAAAAAA
ABBBBBABBBA
0
 AABBAAABABAABBBAABA
AABBBABBABBAAABABABAAB
BABAABAABAABBBAAAB
AABAABBAABBAAABABAB
AAAAAAAAAAA
ABBAABABBBB
0

11 8
10 12
11 7
11 8
11 0
0 11
 11 8
10 12
11 7
11 8
11 0
1 10
 11 8
10 12
11 7
12 7
11 0
1 10
 12 7
10 12
11 7
11 8
11 0
1 10
 11 8
10 12
11 7
12 7
11 0
2 9
 11 8
10 12
10 8
11 8
11 0
1 10
 11 8
10 12
11 7
11 8
11 0
2 9
 11 8
10 12
12 6
12 7
11 0
1 10
 11 8
10 12
10 8
11 8
11 0
2 9
 11 8
10 12
11 7
11 8
11 0
3 8

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<string.h>
int main(){
	int i,j,n,h;
	char S,str[101];
	int A=0,B=0;
	for(i=0;scanf("%s",str)&&str[0]!='0';i++,A=0,B=0){
		if(i%3+1==3)S='A';
		h=strlen(str);
		for(j=1;j<h;j++){
			if(str[j]=='A')A++;
			else B++;
		}
		if(B>A)B++;
		else A++;
		printf("%d %d\n",A,B);
	}
	exit(0);
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d %d\n"
.LC1:
	.string	"%s"
	.text
	.globl	main
	.type	main, @function
main:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$144, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -124(%rbp)
	movl	$0, -120(%rbp)
	movl	$0, -132(%rbp)
	jmp	.L2
.L11:
	movl	-132(%rbp), %edx
	movslq	%edx, %rax
	imulq	$1431655766, %rax, %rax
	shrq	$32, %rax
	movl	%edx, %ecx
	sarl	$31, %ecx
	subl	%ecx, %eax
	movl	%eax, %ecx
	addl	%ecx, %ecx
	addl	%eax, %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	cmpl	$2, %eax
	jne	.L3
	movb	$65, -133(%rbp)
.L3:
	leaq	-112(%rbp), %rax
	movq	%rax, %rdi
	call	strlen@PLT
	movl	%eax, -116(%rbp)
	movl	$1, -128(%rbp)
	jmp	.L4
.L7:
	movl	-128(%rbp), %eax
	cltq
	movzbl	-112(%rbp,%rax), %eax
	cmpb	$65, %al
	jne	.L5
	addl	$1, -124(%rbp)
	jmp	.L6
.L5:
	addl	$1, -120(%rbp)
.L6:
	addl	$1, -128(%rbp)
.L4:
	movl	-128(%rbp), %eax
	cmpl	-116(%rbp), %eax
	jl	.L7
	movl	-120(%rbp), %eax
	cmpl	-124(%rbp), %eax
	jle	.L8
	addl	$1, -120(%rbp)
	jmp	.L9
.L8:
	addl	$1, -124(%rbp)
.L9:
	movl	-120(%rbp), %edx
	movl	-124(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	addl	$1, -132(%rbp)
	movl	$0, -124(%rbp)
	movl	$0, -120(%rbp)
.L2:
	leaq	-112(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	testl	%eax, %eax
	je	.L10
	movzbl	-112(%rbp), %eax
	cmpb	$48, %al
	jne	.L11
.L10:
	movl	$0, %edi
	call	exit@PLT
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:
```

Only output the optimized assembly code. Do not include any other text. Do not write any comments in the assembly code. Wrap the assembly code in ```assembly``` tags.
train
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d %d\n"
.LC1:
	.string	"%s"
	.text
	.globl	main
	.type	main, @function
main:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$144, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -124(%rbp)
	movl	$0, -120(%rbp)
	movl	$0, -132(%rbp)
	jmp	.L2
.L11:
	movl	-132(%rbp), %edx
	movslq	%edx, %rax
	imulq	$1431655766, %rax, %rax
	shrq	$32, %rax
	movl	%edx, %ecx
	sarl	$31, %ecx
	subl	%ecx, %eax
	movl	%eax, %ecx
	addl	%ecx, %ecx
	addl	%eax, %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	cmpl	$2, %eax
	jne	.L3
	movb	$65, -133(%rbp)
.L3:
	leaq	-112(%rbp), %rax
	movq	%rax, %rdi
	call	strlen@PLT
	movl	%eax, -116(%rbp)
	movl	$1, -128(%rbp)
	jmp	.L4
.L7:
	movl	-128(%rbp), %eax
	cltq
	movzbl	-112(%rbp,%rax), %eax
	cmpb	$65, %al
	jne	.L5
	addl	$1, -124(%rbp)
	jmp	.L6
.L5:
	addl	$1, -120(%rbp)
.L6:
	addl	$1, -128(%rbp)
.L4:
	movl	-128(%rbp), %eax
	cmpl	-116(%rbp), %eax
	jl	.L7
	movl	-120(%rbp), %eax
	cmpl	-124(%rbp), %eax
	jle	.L8
	addl	$1, -120(%rbp)
	jmp	.L9
.L8:
	addl	$1, -124(%rbp)
.L9:
	movl	-120(%rbp), %edx
	movl	-124(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	addl	$1, -132(%rbp)
	movl	$0, -124(%rbp)
	movl	$0, -120(%rbp)
.L2:
	leaq	-112(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	testl	%eax, %eax
	je	.L10
	movzbl	-112(%rbp), %eax
	cmpb	$48, %al
	jne	.L11
.L10:
	movl	$0, %edi
	call	exit@PLT
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:
