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()
{
	char input[15],temp[15];
	scanf("%s",input);
	int len = strlen(input);
	int i = 0,j = 0;
	while(len--)
	{
		if(input[j] == 'B')
		{
			if(i > 0)
			{
				i--;
			}
			temp[i] = ' ';
			j++;
		}
		else{
			temp[i] = input[j];
			i++;
			j++;
		}
	}
	temp[i] = '\0';
	printf("%s\n",temp);
	return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.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	$64, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-38(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	leaq	-38(%rbp), %rax
	movq	%rax, %rdi
	call	strlen@PLT
	movl	%eax, -52(%rbp)
	movl	$0, -48(%rbp)
	movl	$0, -44(%rbp)
	jmp	.L2
.L5:
	movl	-44(%rbp), %eax
	cltq
	movzbl	-38(%rbp,%rax), %eax
	cmpb	$66, %al
	jne	.L3
	cmpl	$0, -48(%rbp)
	jle	.L4
	subl	$1, -48(%rbp)
.L4:
	movl	-48(%rbp), %eax
	cltq
	movb	$32, -23(%rbp,%rax)
	addl	$1, -44(%rbp)
	jmp	.L2
.L3:
	movl	-44(%rbp), %eax
	cltq
	movzbl	-38(%rbp,%rax), %edx
	movl	-48(%rbp), %eax
	cltq
	movb	%dl, -23(%rbp,%rax)
	addl	$1, -48(%rbp)
	addl	$1, -44(%rbp)
.L2:
	movl	-52(%rbp), %eax
	leal	-1(%rax), %edx
	movl	%edx, -52(%rbp)
	testl	%eax, %eax
	jne	.L5
	movl	-48(%rbp), %eax
	cltq
	movb	$0, -23(%rbp,%rax)
	leaq	-23(%rbp), %rax
	movq	%rax, %rdi
	call	puts@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L7
	call	__stack_chk_fail@PLT
.L7:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:
```

Only output the optimized assembly code. Do not include any other text. Do not write any comments in the assembly code. Wrap the assembly code in ```assembly``` tags.
user
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%s"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB35:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	leaq	.LC0(%rip), %rdi
	subq	$48, %rsp
	.cfi_def_cfa_offset 64
	movq	%fs:40, %rax
	movq	%rax, 40(%rsp)
	xorl	%eax, %eax
	leaq	10(%rsp), %rbp
	movq	%rbp, %rsi
	call	__isoc99_scanf@PLT
	movq	%rbp, %rdi
	call	strlen@PLT
	testq	%rax, %rax
	je	.L58
	movzbl	10(%rsp), %ecx
	leal	-1(%rax), %edx
	cmpb	$66, %cl
	je	.L3
	movb	%cl, 25(%rsp)
	leal	-2(%rax), %ecx
	testl	%edx, %edx
	je	.L59
	movzbl	11(%rsp), %edx
	cmpb	$66, %dl
	je	.L5
	movl	$1, %esi
.L6:
	movslq	%esi, %rdi
	leal	-1(%rcx), %eax
	movb	%dl, 25(%rsp,%rdi)
	leal	1(%rsi), %edx
	testl	%ecx, %ecx
	je	.L113
	movzbl	12(%rsp), %ecx
	cmpb	$66, %cl
	je	.L11
	movl	%edx, %esi
	movl	%eax, %edx
.L10:
	movslq	%esi, %rax
	movb	%cl, 25(%rsp,%rax)
	movl	%edx, %eax
	leal	1(%rsi), %edx
.L12:
	leal	-1(%rax), %ecx
	testl	%eax, %eax
	je	.L113
	movzbl	13(%rsp), %eax
	cmpb	$66, %al
	je	.L15
.L14:
	movslq	%edx, %rsi
	addl	$1, %edx
	movb	%al, 25(%rsp,%rsi)
.L16:
	testl	%ecx, %ecx
	je	.L113
	movzbl	14(%rsp), %eax
	cmpb	$66, %al
	je	.L18
	movslq	%edx, %rsi
	addl	$1, %edx
	movb	%al, 25(%rsp,%rsi)
.L19:
	cmpl	$1, %ecx
	je	.L113
	movzbl	15(%rsp), %eax
	cmpb	$66, %al
	je	.L22
	movslq	%edx, %rsi
	addl	$1, %edx
	movb	%al, 25(%rsp,%rsi)
.L23:
	cmpl	$2, %ecx
	je	.L113
	movzbl	16(%rsp), %eax
	cmpb	$66, %al
	je	.L26
	movslq	%edx, %rsi
	addl	$1, %edx
	movb	%al, 25(%rsp,%rsi)
.L27:
	cmpl	$3, %ecx
	je	.L113
	movzbl	17(%rsp), %eax
	cmpb	$66, %al
	je	.L30
	movslq	%edx, %rsi
	addl	$1, %edx
	movb	%al, 25(%rsp,%rsi)
.L31:
	cmpl	$4, %ecx
	je	.L113
	movzbl	18(%rsp), %eax
	cmpb	$66, %al
	je	.L34
	movslq	%edx, %rsi
	addl	$1, %edx
	movb	%al, 25(%rsp,%rsi)
.L35:
	cmpl	$5, %ecx
	je	.L113
	movzbl	19(%rsp), %eax
	cmpb	$66, %al
	je	.L38
	movslq	%edx, %rsi
	addl	$1, %edx
	movb	%al, 25(%rsp,%rsi)
.L39:
	cmpl	$6, %ecx
	je	.L113
	movzbl	20(%rsp), %eax
	cmpb	$66, %al
	je	.L42
	movslq	%edx, %rsi
	addl	$1, %edx
	movb	%al, 25(%rsp,%rsi)
.L43:
	cmpl	$7, %ecx
	je	.L113
	movzbl	21(%rsp), %eax
	cmpb	$66, %al
	je	.L46
	movslq	%edx, %rsi
	addl	$1, %edx
	movb	%al, 25(%rsp,%rsi)
.L47:
	cmpl	$8, %ecx
	je	.L113
	movzbl	22(%rsp), %eax
	cmpb	$66, %al
	je	.L50
	movslq	%edx, %rsi
	addl	$1, %edx
	movb	%al, 25(%rsp,%rsi)
.L51:
	cmpl	$9, %ecx
	je	.L113
	movzbl	23(%rsp), %eax
	cmpb	$66, %al
	je	.L117
	movslq	%edx, %rcx
	addl	$1, %edx
	movb	%al, 25(%rsp,%rcx)
	.p2align 4,,10
	.p2align 3
.L113:
	movslq	%edx, %rax
.L2:
	leaq	25(%rsp), %rdi
	movb	$0, 25(%rsp,%rax)
	call	puts@PLT
	movq	40(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L118
	addq	$48, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 16
	xorl	%eax, %eax
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
.L5:
	.cfi_restore_state
	movb	$32, 25(%rsp)
.L115:
	leal	-3(%rax), %edx
	testl	%ecx, %ecx
	je	.L58
	movzbl	12(%rsp), %ecx
	cmpb	$66, %cl
	je	.L9
	xorl	%esi, %esi
	jmp	.L10
.L3:
	movb	$32, 25(%rsp)
	leal	-2(%rax), %ecx
	testl	%edx, %edx
	je	.L58
	movzbl	11(%rsp), %edx
	cmpb	$66, %dl
	je	.L115
	xorl	%esi, %esi
	jmp	.L6
.L42:
	cmpl	$1, %edx
	adcl	$-1, %edx
	movslq	%edx, %rax
	movb	$32, 25(%rsp,%rax)
	jmp	.L43
.L9:
	movb	$32, 25(%rsp)
	leal	-1(%rdx), %ecx
	testl	%edx, %edx
	je	.L58
	movzbl	13(%rsp), %eax
	xorl	%edx, %edx
	cmpb	$66, %al
	jne	.L14
.L13:
	movslq	%edx, %rax
	movb	$32, 25(%rsp,%rax)
	jmp	.L16
.L18:
	cmpl	$1, %edx
	adcl	$-1, %edx
	movslq	%edx, %rax
	movb	$32, 25(%rsp,%rax)
	jmp	.L19
.L15:
	cmpl	$1, %edx
	adcl	$-1, %edx
	jmp	.L13
.L58:
	xorl	%eax, %eax
	jmp	.L2
.L22:
	cmpl	$1, %edx
	adcl	$-1, %edx
	movslq	%edx, %rax
	movb	$32, 25(%rsp,%rax)
	jmp	.L23
.L26:
	cmpl	$1, %edx
	adcl	$-1, %edx
	movslq	%edx, %rax
	movb	$32, 25(%rsp,%rax)
	jmp	.L27
.L11:
	movb	$32, 25(%rsp,%rdi)
	movl	%esi, %edx
	jmp	.L12
.L30:
	cmpl	$1, %edx
	adcl	$-1, %edx
	movslq	%edx, %rax
	movb	$32, 25(%rsp,%rax)
	jmp	.L31
.L34:
	cmpl	$1, %edx
	adcl	$-1, %edx
	movslq	%edx, %rax
	movb	$32, 25(%rsp,%rax)
	jmp	.L35
.L38:
	cmpl	$1, %edx
	adcl	$-1, %edx
	movslq	%edx, %rax
	movb	$32, 25(%rsp,%rax)
	jmp	.L39
.L46:
	cmpl	$1, %edx
	adcl	$-1, %edx
	movslq	%edx, %rax
	movb	$32, 25(%rsp,%rax)
	jmp	.L47
.L50:
	cmpl	$1, %edx
	adcl	$-1, %edx
	movslq	%edx, %rax
	movb	$32, 25(%rsp,%rax)
	jmp	.L51
.L117:
	cmpl	$1, %edx
	adcl	$-1, %edx
	movslq	%edx, %rax
	movb	$32, 25(%rsp,%rax)
	jmp	.L2
.L59:
	movl	$1, %eax
	jmp	.L2
.L118:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE35:
	.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:

rule
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%s"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB35:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	leaq	.LC0(%rip), %rdi
	subq	$48, %rsp
	.cfi_def_cfa_offset 64
	movq	%fs:40, %rax
	movq	%rax, 40(%rsp)
	xorl	%eax, %eax
	leaq	10(%rsp), %rbp
	movq	%rbp, %rsi
	call	__isoc99_scanf@PLT
	movq	%rbp, %rdi
	call	strlen@PLT
	testq	%rax, %rax
	je	.L58
	movzbl	10(%rsp), %ecx
	leal	-1(%rax), %edx
	cmpb	$66, %cl
	je	.L3
	movb	%cl, 25(%rsp)
	leal	-2(%rax), %ecx
	testl	%edx, %edx
	je	.L59
	movzbl	11(%rsp), %edx
	cmpb	$66, %dl
	je	.L5
	movl	$1, %esi
.L6:
	movslq	%esi, %rdi
	leal	-1(%rcx), %eax
	movb	%dl, 25(%rsp,%rdi)
	leal	1(%rsi), %edx
	testl	%ecx, %ecx
	je	.L113
	movzbl	12(%rsp), %ecx
	cmpb	$66, %cl
	je	.L11
	movl	%edx, %esi
	movl	%eax, %edx
.L10:
	movslq	%esi, %rax
	movb	%cl, 25(%rsp,%rax)
	movl	%edx, %eax
	leal	1(%rsi), %edx
.L12:
	leal	-1(%rax), %ecx
	testl	%eax, %eax
	je	.L113
	movzbl	13(%rsp), %eax
	cmpb	$66, %al
	je	.L15
.L14:
	movslq	%edx, %rsi
	addl	$1, %edx
	movb	%al, 25(%rsp,%rsi)
.L16:
	testl	%ecx, %ecx
	je	.L113
	movzbl	14(%rsp), %eax
	cmpb	$66, %al
	je	.L18
	movslq	%edx, %rsi
	addl	$1, %edx
	movb	%al, 25(%rsp,%rsi)
.L19:
	cmpl	$1, %ecx
	je	.L113
	movzbl	15(%rsp), %eax
	cmpb	$66, %al
	je	.L22
	movslq	%edx, %rsi
	addl	$1, %edx
	movb	%al, 25(%rsp,%rsi)
.L23:
	cmpl	$2, %ecx
	je	.L113
	movzbl	16(%rsp), %eax
	cmpb	$66, %al
	je	.L26
	movslq	%edx, %rsi
	addl	$1, %edx
	movb	%al, 25(%rsp,%rsi)
.L27:
	cmpl	$3, %ecx
	je	.L113
	movzbl	17(%rsp), %eax
	cmpb	$66, %al
	je	.L30
	movslq	%edx, %rsi
	addl	$1, %edx
	movb	%al, 25(%rsp,%rsi)
.L31:
	cmpl	$4, %ecx
	je	.L113
	movzbl	18(%rsp), %eax
	cmpb	$66, %al
	je	.L34
	movslq	%edx, %rsi
	addl	$1, %edx
	movb	%al, 25(%rsp,%rsi)
.L35:
	cmpl	$5, %ecx
	je	.L113
	movzbl	19(%rsp), %eax
	cmpb	$66, %al
	je	.L38
	movslq	%edx, %rsi
	addl	$1, %edx
	movb	%al, 25(%rsp,%rsi)
.L39:
	cmpl	$6, %ecx
	je	.L113
	movzbl	20(%rsp), %eax
	cmpb	$66, %al
	je	.L42
	movslq	%edx, %rsi
	addl	$1, %edx
	movb	%al, 25(%rsp,%rsi)
.L43:
	cmpl	$7, %ecx
	je	.L113
	movzbl	21(%rsp), %eax
	cmpb	$66, %al
	je	.L46
	movslq	%edx, %rsi
	addl	$1, %edx
	movb	%al, 25(%rsp,%rsi)
.L47:
	cmpl	$8, %ecx
	je	.L113
	movzbl	22(%rsp), %eax
	cmpb	$66, %al
	je	.L50
	movslq	%edx, %rsi
	addl	$1, %edx
	movb	%al, 25(%rsp,%rsi)
.L51:
	cmpl	$9, %ecx
	je	.L113
	movzbl	23(%rsp), %eax
	cmpb	$66, %al
	je	.L117
	movslq	%edx, %rcx
	addl	$1, %edx
	movb	%al, 25(%rsp,%rcx)
	.p2align 4,,10
	.p2align 3
.L113:
	movslq	%edx, %rax
.L2:
	leaq	25(%rsp), %rdi
	movb	$0, 25(%rsp,%rax)
	call	puts@PLT
	movq	40(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L118
	addq	$48, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 16
	xorl	%eax, %eax
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
.L5:
	.cfi_restore_state
	movb	$32, 25(%rsp)
.L115:
	leal	-3(%rax), %edx
	testl	%ecx, %ecx
	je	.L58
	movzbl	12(%rsp), %ecx
	cmpb	$66, %cl
	je	.L9
	xorl	%esi, %esi
	jmp	.L10
.L3:
	movb	$32, 25(%rsp)
	leal	-2(%rax), %ecx
	testl	%edx, %edx
	je	.L58
	movzbl	11(%rsp), %edx
	cmpb	$66, %dl
	je	.L115
	xorl	%esi, %esi
	jmp	.L6
.L42:
	cmpl	$1, %edx
	adcl	$-1, %edx
	movslq	%edx, %rax
	movb	$32, 25(%rsp,%rax)
	jmp	.L43
.L9:
	movb	$32, 25(%rsp)
	leal	-1(%rdx), %ecx
	testl	%edx, %edx
	je	.L58
	movzbl	13(%rsp), %eax
	xorl	%edx, %edx
	cmpb	$66, %al
	jne	.L14
.L13:
	movslq	%edx, %rax
	movb	$32, 25(%rsp,%rax)
	jmp	.L16
.L18:
	cmpl	$1, %edx
	adcl	$-1, %edx
	movslq	%edx, %rax
	movb	$32, 25(%rsp,%rax)
	jmp	.L19
.L15:
	cmpl	$1, %edx
	adcl	$-1, %edx
	jmp	.L13
.L58:
	xorl	%eax, %eax
	jmp	.L2
.L22:
	cmpl	$1, %edx
	adcl	$-1, %edx
	movslq	%edx, %rax
	movb	$32, 25(%rsp,%rax)
	jmp	.L23
.L26:
	cmpl	$1, %edx
	adcl	$-1, %edx
	movslq	%edx, %rax
	movb	$32, 25(%rsp,%rax)
	jmp	.L27
.L11:
	movb	$32, 25(%rsp,%rdi)
	movl	%esi, %edx
	jmp	.L12
.L30:
	cmpl	$1, %edx
	adcl	$-1, %edx
	movslq	%edx, %rax
	movb	$32, 25(%rsp,%rax)
	jmp	.L31
.L34:
	cmpl	$1, %edx
	adcl	$-1, %edx
	movslq	%edx, %rax
	movb	$32, 25(%rsp,%rax)
	jmp	.L35
.L38:
	cmpl	$1, %edx
	adcl	$-1, %edx
	movslq	%edx, %rax
	movb	$32, 25(%rsp,%rax)
	jmp	.L39
.L46:
	cmpl	$1, %edx
	adcl	$-1, %edx
	movslq	%edx, %rax
	movb	$32, 25(%rsp,%rax)
	jmp	.L47
.L50:
	cmpl	$1, %edx
	adcl	$-1, %edx
	movslq	%edx, %rax
	movb	$32, 25(%rsp,%rax)
	jmp	.L51
.L117:
	cmpl	$1, %edx
	adcl	$-1, %edx
	movslq	%edx, %rax
	movb	$32, 25(%rsp,%rax)
	jmp	.L2
.L59:
	movl	$1, %eax
	jmp	.L2
.L118:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE35:
	.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:

#include<stdio.h>
#include<string.h>
int main()
{
	char input[15],temp[15];
	scanf("%s",input);
	int len = strlen(input);
	int i = 0,j = 0;
	while(len--)
	{
		if(input[j] == 'B')
		{
			if(i > 0)
			{
				i--;
			}
			temp[i] = ' ';
			j++;
		}
		else{
			temp[i] = input[j];
			i++;
			j++;
		}
	}
	temp[i] = '\0';
	printf("%s\n",temp);
	return 0;
}
01B1
 BB11
 B01B
 02B0
 /BB1
 1B10
 B010
 B110
 B011
 B101

01
 11
 0
 00
 1
 10
 010
 110
 011
 101

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()
{
	char input[15],temp[15];
	scanf("%s",input);
	int len = strlen(input);
	int i = 0,j = 0;
	while(len--)
	{
		if(input[j] == 'B')
		{
			if(i > 0)
			{
				i--;
			}
			temp[i] = ' ';
			j++;
		}
		else{
			temp[i] = input[j];
			i++;
			j++;
		}
	}
	temp[i] = '\0';
	printf("%s\n",temp);
	return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.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	$64, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-38(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	leaq	-38(%rbp), %rax
	movq	%rax, %rdi
	call	strlen@PLT
	movl	%eax, -52(%rbp)
	movl	$0, -48(%rbp)
	movl	$0, -44(%rbp)
	jmp	.L2
.L5:
	movl	-44(%rbp), %eax
	cltq
	movzbl	-38(%rbp,%rax), %eax
	cmpb	$66, %al
	jne	.L3
	cmpl	$0, -48(%rbp)
	jle	.L4
	subl	$1, -48(%rbp)
.L4:
	movl	-48(%rbp), %eax
	cltq
	movb	$32, -23(%rbp,%rax)
	addl	$1, -44(%rbp)
	jmp	.L2
.L3:
	movl	-44(%rbp), %eax
	cltq
	movzbl	-38(%rbp,%rax), %edx
	movl	-48(%rbp), %eax
	cltq
	movb	%dl, -23(%rbp,%rax)
	addl	$1, -48(%rbp)
	addl	$1, -44(%rbp)
.L2:
	movl	-52(%rbp), %eax
	leal	-1(%rax), %edx
	movl	%edx, -52(%rbp)
	testl	%eax, %eax
	jne	.L5
	movl	-48(%rbp), %eax
	cltq
	movb	$0, -23(%rbp,%rax)
	leaq	-23(%rbp), %rax
	movq	%rax, %rdi
	call	puts@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L7
	call	__stack_chk_fail@PLT
.L7:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:
```

Only output the optimized assembly code. Do not include any other text. Do not write any comments in the assembly code. Wrap the assembly code in ```assembly``` tags.
train
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.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	$64, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-38(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	leaq	-38(%rbp), %rax
	movq	%rax, %rdi
	call	strlen@PLT
	movl	%eax, -52(%rbp)
	movl	$0, -48(%rbp)
	movl	$0, -44(%rbp)
	jmp	.L2
.L5:
	movl	-44(%rbp), %eax
	cltq
	movzbl	-38(%rbp,%rax), %eax
	cmpb	$66, %al
	jne	.L3
	cmpl	$0, -48(%rbp)
	jle	.L4
	subl	$1, -48(%rbp)
.L4:
	movl	-48(%rbp), %eax
	cltq
	movb	$32, -23(%rbp,%rax)
	addl	$1, -44(%rbp)
	jmp	.L2
.L3:
	movl	-44(%rbp), %eax
	cltq
	movzbl	-38(%rbp,%rax), %edx
	movl	-48(%rbp), %eax
	cltq
	movb	%dl, -23(%rbp,%rax)
	addl	$1, -48(%rbp)
	addl	$1, -44(%rbp)
.L2:
	movl	-52(%rbp), %eax
	leal	-1(%rax), %edx
	movl	%edx, -52(%rbp)
	testl	%eax, %eax
	jne	.L5
	movl	-48(%rbp), %eax
	cltq
	movb	$0, -23(%rbp,%rax)
	leaq	-23(%rbp), %rax
	movq	%rax, %rdi
	call	puts@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L7
	call	__stack_chk_fail@PLT
.L7:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:
