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

```c
#include <stdio.h>
int n, i;
int a, b;
char s[200001], c;
int main(void){
  while((c=getchar())!=10){s[n++]=c;}
  scanf("%s",&s);
  for(i=0; i<n; i++){
    if(b>0){
      if(s[i]=='S'){
        b++;
      }else{
        b--;
      }
    }else{
      if(s[i]=='T'){
        a++;
      }else{
        b++;
      }
    }
  }
  printf("%d\n", a*2);
}
```

Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%s"
.LC1:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	leaq	s(%rip), %rbp
	jmp	.L2
	.p2align 4,,10
	.p2align 3
.L3:
	movslq	n(%rip), %rdx
	leal	1(%rdx), %ecx
	movb	%al, 0(%rbp,%rdx)
	movl	%ecx, n(%rip)
.L2:
	movq	stdin(%rip), %rdi
	call	getc@PLT
	movb	%al, c(%rip)
	cmpb	$10, %al
	jne	.L3
	movq	%rbp, %rsi
	leaq	.LC0(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	n(%rip), %r10d
	movl	$0, i(%rip)
	movl	a(%rip), %edx
	testl	%r10d, %r10d
	jle	.L5
	leaq	s(%rip), %rax
	movl	%edx, %r9d
	xorl	%r11d, %r11d
	xorl	%r8d, %r8d
	leal	-1(%r10), %esi
	leaq	1(%rax), %rdi
	movl	b(%rip), %ecx
	addq	%rsi, %rdi
	jmp	.L10
	.p2align 4,,10
	.p2align 3
.L23:
	cmpb	$83, %sil
	je	.L9
	subl	$1, %ecx
	movl	$1, %r8d
.L8:
	addq	$1, %rax
	cmpq	%rax, %rdi
	je	.L22
.L10:
	movzbl	(%rax), %esi
	testl	%ecx, %ecx
	jg	.L23
	cmpb	$84, %sil
	je	.L24
.L9:
	addq	$1, %rax
	addl	$1, %ecx
	movl	$1, %r8d
	cmpq	%rax, %rdi
	jne	.L10
.L22:
	movl	%r10d, i(%rip)
	testb	%r11b, %r11b
	je	.L11
	movl	%r9d, a(%rip)
	movl	%r9d, %edx
.L11:
	testb	%r8b, %r8b
	je	.L5
	movl	%ecx, b(%rip)
.L5:
	addl	%edx, %edx
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	xorl	%eax, %eax
	popq	%rbp
	.cfi_remember_state
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L24:
	.cfi_restore_state
	addl	$1, %r9d
	movl	$1, %r11d
	jmp	.L8
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.globl	c
	.bss
	.type	c, @object
	.size	c, 1
c:
	.zero	1
	.globl	s
	.align 32
	.type	s, @object
	.size	s, 200001
s:
	.zero	200001
	.globl	b
	.align 4
	.type	b, @object
	.size	b, 4
b:
	.zero	4
	.globl	a
	.align 4
	.type	a, @object
	.size	a, 4
a:
	.zero	4
	.globl	i
	.align 4
	.type	i, @object
	.size	i, 4
i:
	.zero	4
	.globl	n
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:
```

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.
Optimized Assembly Code:

user
```assembly
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%s"
.LC1:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	leaq	s(%rip), %rbp
	jmp	.L2
	.p2align 4,,10
	.p2align 3
.L3:
	movslq	n(%rip), %rdx
	leal	1(%rdx), %ecx
	movb	%al, 0(%rbp,%rdx)
	movl	%ecx, n(%rip)
.L2:
	movq	stdin(%rip), %rdi
	call	getc@PLT
	movb	%al, c(%rip)
	cmpb	$10, %al
	jne	.L3
	movq	%rbp, %rsi
	leaq	.LC0(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	n(%rip), %r10d
	movl	$0, i(%rip)
	movl	a(%rip), %edx
	testl	%r10d, %r10d
	jle	.L5
	leaq	s(%rip), %rax
	movl	%edx, %r9d
	xorl	%r11d, %r11d
	xorl	%r8d, %r8d
	leal	-1(%r10), %esi
	leaq	1(%rax), %rdi
	movl	b(%rip), %ecx
	addq	%rsi, %rdi
	jmp	.L10
	.p2align 4,,10
	.p2align 3
.L23:
	cmpb	$83, %sil
	je	.L9
	subl	$1, %ecx
	movl	$1, %r8d
.L8:
	addq	$1, %rax
	cmpq	%rax, %rdi
	je	.L22
.L10:
	movzbl	(%rax), %esi
	testl	%ecx, %ecx
	jg	.L23
	cmpb	$84, %sil
	je	.L24
.L9:
	addq	$1, %rax
	addl	$1, %ecx
	movl	$1, %r8d
	cmpq	%rax, %rdi
	jne	.L10
.L22:
	movl	%r10d, i(%rip)
	testb	%r11b, %r11b
	je	.L11
	movl	%r9d, a(%rip)
	movl	%r9d, %edx
.L11:
	testb	%r8b, %r8b
	je	.L5
	movl	%ecx, b(%rip)
.L5:
	addl	%edx, %edx
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	xorl	%eax, %eax
	popq	%rbp
	.cfi_remember_state
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L24:
	.cfi_restore_state
	addl	$1, %r9d
	movl	$1, %r11d
	jmp	.L8
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.globl	c
	.bss
	.type	c, @object
	.size	c, 1
c:
	.zero	1
	.globl	s
	.align 32
	.type	s, @object
	.size	s, 200001
s:
	.zero	200001
	.globl	b
	.align 4
	.type	b, @object
	.size	b, 4
b:
	.zero	4
	.globl	a
	.align 4
	.type	a, @object
	.size	a, 4
a:
	.zero	4
	.globl	i
	.align 4
	.type	i, @object
	.size	i, 4
i:
	.zero	4
	.globl	n
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:
```
rule
```assembly
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%s"
.LC1:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	leaq	s(%rip), %rbp
	jmp	.L2
	.p2align 4,,10
	.p2align 3
.L3:
	movslq	n(%rip), %rdx
	leal	1(%rdx), %ecx
	movb	%al, 0(%rbp,%rdx)
	movl	%ecx, n(%rip)
.L2:
	movq	stdin(%rip), %rdi
	call	getc@PLT
	movb	%al, c(%rip)
	cmpb	$10, %al
	jne	.L3
	movq	%rbp, %rsi
	leaq	.LC0(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	n(%rip), %r10d
	movl	$0, i(%rip)
	movl	a(%rip), %edx
	testl	%r10d, %r10d
	jle	.L5
	leaq	s(%rip), %rax
	movl	%edx, %r9d
	xorl	%r11d, %r11d
	xorl	%r8d, %r8d
	leal	-1(%r10), %esi
	leaq	1(%rax), %rdi
	movl	b(%rip), %ecx
	addq	%rsi, %rdi
	jmp	.L10
	.p2align 4,,10
	.p2align 3
.L23:
	cmpb	$83, %sil
	je	.L9
	subl	$1, %ecx
	movl	$1, %r8d
.L8:
	addq	$1, %rax
	cmpq	%rax, %rdi
	je	.L22
.L10:
	movzbl	(%rax), %esi
	testl	%ecx, %ecx
	jg	.L23
	cmpb	$84, %sil
	je	.L24
.L9:
	addq	$1, %rax
	addl	$1, %ecx
	movl	$1, %r8d
	cmpq	%rax, %rdi
	jne	.L10
.L22:
	movl	%r10d, i(%rip)
	testb	%r11b, %r11b
	je	.L11
	movl	%r9d, a(%rip)
	movl	%r9d, %edx
.L11:
	testb	%r8b, %r8b
	je	.L5
	movl	%ecx, b(%rip)
.L5:
	addl	%edx, %edx
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	xorl	%eax, %eax
	popq	%rbp
	.cfi_remember_state
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L24:
	.cfi_restore_state
	addl	$1, %r9d
	movl	$1, %r11d
	jmp	.L8
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.globl	c
	.bss
	.type	c, @object
	.size	c, 1
c:
	.zero	1
	.globl	s
	.align 32
	.type	s, @object
	.size	s, 200001
s:
	.zero	200001
	.globl	b
	.align 4
	.type	b, @object
	.size	b, 4
b:
	.zero	4
	.globl	a
	.align 4
	.type	a, @object
	.size	a, 4
a:
	.zero	4
	.globl	i
	.align 4
	.type	i, @object
	.size	i, 4
i:
	.zero	4
	.globl	n
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:
```
```c
#include <stdio.h>
int n, i;
int a, b;
char s[200001], c;
int main(void){
  while((c=getchar())!=10){s[n++]=c;}
  scanf("%s",&s);
  for(i=0; i<n; i++){
    if(b>0){
      if(s[i]=='S'){
        b++;
      }else{
        b--;
      }
    }else{
      if(s[i]=='T'){
        a++;
      }else{
        b++;
      }
    }
  }
  printf("%d\n", a*2);
}
```
Given the following C code, your task is to generate highly optimized x86-64 assembly code.
C Code:

```c
#include <stdio.h>
int n, i;
int a, b;
char s[200001], c;
int main(void){
  while((c=getchar())!=10){s[n++]=c;}
  scanf("%s",&s);
  for(i=0; i<n; i++){
    if(b>0){
      if(s[i]=='S'){
        b++;
      }else{
        b--;
      }
    }else{
      if(s[i]=='T'){
        a++;
      }else{
        b++;
      }
    }
  }
  printf("%d\n", a*2);
}
```

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.
Optimized Assembly Code:

SSTTTSST
 STTTSS
 SSSTTT
 TTTSSS
 TTTTSSSS
 TSTSST
 SSTTTS
 TSSTST
 STTSST
 TSSSTT

2
 4
 0
 6
 8
 2
 2
 2
 2
 2

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

```c
#include <stdio.h>
int n, i;
int a, b;
char s[200001], c;
int main(void){
  while((c=getchar())!=10){s[n++]=c;}
  scanf("%s",&s);
  for(i=0; i<n; i++){
    if(b>0){
      if(s[i]=='S'){
        b++;
      }else{
        b--;
      }
    }else{
      if(s[i]=='T'){
        a++;
      }else{
        b++;
      }
    }
  }
  printf("%d\n", a*2);
}
```

Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%s"
.LC1:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	leaq	s(%rip), %rbp
	jmp	.L2
	.p2align 4,,10
	.p2align 3
.L3:
	movslq	n(%rip), %rdx
	leal	1(%rdx), %ecx
	movb	%al, 0(%rbp,%rdx)
	movl	%ecx, n(%rip)
.L2:
	movq	stdin(%rip), %rdi
	call	getc@PLT
	movb	%al, c(%rip)
	cmpb	$10, %al
	jne	.L3
	movq	%rbp, %rsi
	leaq	.LC0(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	n(%rip), %r10d
	movl	$0, i(%rip)
	movl	a(%rip), %edx
	testl	%r10d, %r10d
	jle	.L5
	leaq	s(%rip), %rax
	movl	%edx, %r9d
	xorl	%r11d, %r11d
	xorl	%r8d, %r8d
	leal	-1(%r10), %esi
	leaq	1(%rax), %rdi
	movl	b(%rip), %ecx
	addq	%rsi, %rdi
	jmp	.L10
	.p2align 4,,10
	.p2align 3
.L23:
	cmpb	$83, %sil
	je	.L9
	subl	$1, %ecx
	movl	$1, %r8d
.L8:
	addq	$1, %rax
	cmpq	%rax, %rdi
	je	.L22
.L10:
	movzbl	(%rax), %esi
	testl	%ecx, %ecx
	jg	.L23
	cmpb	$84, %sil
	je	.L24
.L9:
	addq	$1, %rax
	addl	$1, %ecx
	movl	$1, %r8d
	cmpq	%rax, %rdi
	jne	.L10
.L22:
	movl	%r10d, i(%rip)
	testb	%r11b, %r11b
	je	.L11
	movl	%r9d, a(%rip)
	movl	%r9d, %edx
.L11:
	testb	%r8b, %r8b
	je	.L5
	movl	%ecx, b(%rip)
.L5:
	addl	%edx, %edx
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	xorl	%eax, %eax
	popq	%rbp
	.cfi_remember_state
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L24:
	.cfi_restore_state
	addl	$1, %r9d
	movl	$1, %r11d
	jmp	.L8
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.globl	c
	.bss
	.type	c, @object
	.size	c, 1
c:
	.zero	1
	.globl	s
	.align 32
	.type	s, @object
	.size	s, 200001
s:
	.zero	200001
	.globl	b
	.align 4
	.type	b, @object
	.size	b, 4
b:
	.zero	4
	.globl	a
	.align 4
	.type	a, @object
	.size	a, 4
a:
	.zero	4
	.globl	i
	.align 4
	.type	i, @object
	.size	i, 4
i:
	.zero	4
	.globl	n
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:
```

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.
Optimized Assembly Code:

train
```assembly
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%s"
.LC1:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	leaq	s(%rip), %rbp
	jmp	.L2
	.p2align 4,,10
	.p2align 3
.L3:
	movslq	n(%rip), %rdx
	leal	1(%rdx), %ecx
	movb	%al, 0(%rbp,%rdx)
	movl	%ecx, n(%rip)
.L2:
	movq	stdin(%rip), %rdi
	call	getc@PLT
	movb	%al, c(%rip)
	cmpb	$10, %al
	jne	.L3
	movq	%rbp, %rsi
	leaq	.LC0(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	n(%rip), %r10d
	movl	$0, i(%rip)
	movl	a(%rip), %edx
	testl	%r10d, %r10d
	jle	.L5
	leaq	s(%rip), %rax
	movl	%edx, %r9d
	xorl	%r11d, %r11d
	xorl	%r8d, %r8d
	leal	-1(%r10), %esi
	leaq	1(%rax), %rdi
	movl	b(%rip), %ecx
	addq	%rsi, %rdi
	jmp	.L10
	.p2align 4,,10
	.p2align 3
.L23:
	cmpb	$83, %sil
	je	.L9
	subl	$1, %ecx
	movl	$1, %r8d
.L8:
	addq	$1, %rax
	cmpq	%rax, %rdi
	je	.L22
.L10:
	movzbl	(%rax), %esi
	testl	%ecx, %ecx
	jg	.L23
	cmpb	$84, %sil
	je	.L24
.L9:
	addq	$1, %rax
	addl	$1, %ecx
	movl	$1, %r8d
	cmpq	%rax, %rdi
	jne	.L10
.L22:
	movl	%r10d, i(%rip)
	testb	%r11b, %r11b
	je	.L11
	movl	%r9d, a(%rip)
	movl	%r9d, %edx
.L11:
	testb	%r8b, %r8b
	je	.L5
	movl	%ecx, b(%rip)
.L5:
	addl	%edx, %edx
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	xorl	%eax, %eax
	popq	%rbp
	.cfi_remember_state
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L24:
	.cfi_restore_state
	addl	$1, %r9d
	movl	$1, %r11d
	jmp	.L8
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.globl	c
	.bss
	.type	c, @object
	.size	c, 1
c:
	.zero	1
	.globl	s
	.align 32
	.type	s, @object
	.size	s, 200001
s:
	.zero	200001
	.globl	b
	.align 4
	.type	b, @object
	.size	b, 4
b:
	.zero	4
	.globl	a
	.align 4
	.type	a, @object
	.size	a, 4
a:
	.zero	4
	.globl	i
	.align 4
	.type	i, @object
	.size	i, 4
i:
	.zero	4
	.globl	n
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:
```