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>
int main(){
  char s[100001];
  int i,t,n,x;
  scanf("%s",s);
  for(n=0;s[n];n++);
  x=n;for(i=1;i<n;i++)if(s[i]!=s[i-1]){t=i<n-i?n-i:i;x=t<x?t:x;}
  printf("%d",x);
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%s"
.LC1:
	.string	"%d"
	.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
	leaq	-98304(%rsp), %r11
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	subq	$1728, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-100016(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -100028(%rbp)
	jmp	.L2
.L3:
	addl	$1, -100028(%rbp)
.L2:
	movl	-100028(%rbp), %eax
	cltq
	movzbl	-100016(%rbp,%rax), %eax
	testb	%al, %al
	jne	.L3
	movl	-100028(%rbp), %eax
	movl	%eax, -100024(%rbp)
	movl	$1, -100032(%rbp)
	jmp	.L4
.L6:
	movl	-100032(%rbp), %eax
	cltq
	movzbl	-100016(%rbp,%rax), %edx
	movl	-100032(%rbp), %eax
	subl	$1, %eax
	cltq
	movzbl	-100016(%rbp,%rax), %eax
	cmpb	%al, %dl
	je	.L5
	movl	-100028(%rbp), %eax
	subl	-100032(%rbp), %eax
	movl	-100032(%rbp), %edx
	cmpl	%eax, %edx
	cmovge	%edx, %eax
	movl	%eax, -100020(%rbp)
	movl	-100024(%rbp), %edx
	movl	-100020(%rbp), %eax
	cmpl	%eax, %edx
	cmovle	%edx, %eax
	movl	%eax, -100024(%rbp)
.L5:
	addl	$1, -100032(%rbp)
.L4:
	movl	-100032(%rbp), %eax
	cmpl	-100028(%rbp), %eax
	jl	.L6
	movl	-100024(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L8
	call	__stack_chk_fail@PLT
.L8:
	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"
.LC1:
	.string	"%d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	leaq	-98304(%rsp), %r11
	.cfi_def_cfa 11, 98336
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	.cfi_def_cfa_register 7
	subq	$1712, %rsp
	.cfi_def_cfa_offset 100048
	leaq	.LC0(%rip), %rdi
	movq	%fs:40, %rax
	movq	%rax, 100008(%rsp)
	xorl	%eax, %eax
	movq	%rsp, %rbx
	movq	%rbx, %rsi
	call	__isoc99_scanf@PLT
	movzbl	(%rsp), %esi
	testb	%sil, %sil
	je	.L11
	leaq	1(%rsp), %rax
	xorl	%ecx, %ecx
	.p2align 4,,10
	.p2align 3
.L3:
	addq	$1, %rax
	movl	%ecx, %edi
	addl	$1, %ecx
	cmpb	$0, -1(%rax)
	jne	.L3
	cmpl	$1, %ecx
	je	.L12
	leal	-1(%rdi), %r12d
	cmpl	$2, %edi
	jle	.L13
	movl	%edi, %edx
	leaq	2(%rsp), %r9
	movl	%ecx, %r8d
	movl	$1, %eax
.L7:
	cmpl	%eax, %edx
	movl	%eax, %r10d
	movzbl	-1(%r9), %r11d
	leal	1(%rax), %ebp
	cmovge	%edx, %r10d
	cmpl	%r10d, %r8d
	cmovle	%r8d, %r10d
	cmpb	%sil, %r11b
	movzbl	(%r9), %esi
	cmovne	%r10d, %r8d
	cmpb	%sil, %r11b
	je	.L6
	leal	-1(%rdx), %r10d
	cmpl	%ebp, %r10d
	cmovl	%ebp, %r10d
	cmpl	%r10d, %r8d
	cmovg	%r10d, %r8d
.L6:
	addl	$2, %eax
	subl	$2, %edx
	addq	$2, %r9
	cmpl	%eax, %r12d
	jg	.L7
.L4:
	movslq	%eax, %rdx
	addq	%rbx, %rdx
	jmp	.L9
	.p2align 4,,10
	.p2align 3
.L14:
	movl	%esi, %eax
.L9:
	movzbl	-1(%rdx), %ebx
	cmpb	%bl, (%rdx)
	je	.L8
	movl	%ecx, %esi
	subl	%eax, %esi
	cmpl	%eax, %esi
	cmovl	%eax, %esi
	cmpl	%esi, %r8d
	cmovg	%esi, %r8d
.L8:
	leal	1(%rax), %esi
	addq	$1, %rdx
	cmpl	%eax, %edi
	jg	.L14
.L2:
	xorl	%eax, %eax
	movl	%r8d, %edx
	movl	$1, %edi
	leaq	.LC1(%rip), %rsi
	call	__printf_chk@PLT
	movq	100008(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L19
	addq	$100016, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 32
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
.L11:
	.cfi_restore_state
	xorl	%r8d, %r8d
	jmp	.L2
.L13:
	movl	%ecx, %r8d
	movl	$1, %eax
	jmp	.L4
.L12:
	movl	$1, %r8d
	jmp	.L2
.L19:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.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"
.LC1:
	.string	"%d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	leaq	-98304(%rsp), %r11
	.cfi_def_cfa 11, 98336
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	.cfi_def_cfa_register 7
	subq	$1712, %rsp
	.cfi_def_cfa_offset 100048
	leaq	.LC0(%rip), %rdi
	movq	%fs:40, %rax
	movq	%rax, 100008(%rsp)
	xorl	%eax, %eax
	movq	%rsp, %rbx
	movq	%rbx, %rsi
	call	__isoc99_scanf@PLT
	movzbl	(%rsp), %esi
	testb	%sil, %sil
	je	.L11
	leaq	1(%rsp), %rax
	xorl	%ecx, %ecx
	.p2align 4,,10
	.p2align 3
.L3:
	addq	$1, %rax
	movl	%ecx, %edi
	addl	$1, %ecx
	cmpb	$0, -1(%rax)
	jne	.L3
	cmpl	$1, %ecx
	je	.L12
	leal	-1(%rdi), %r12d
	cmpl	$2, %edi
	jle	.L13
	movl	%edi, %edx
	leaq	2(%rsp), %r9
	movl	%ecx, %r8d
	movl	$1, %eax
.L7:
	cmpl	%eax, %edx
	movl	%eax, %r10d
	movzbl	-1(%r9), %r11d
	leal	1(%rax), %ebp
	cmovge	%edx, %r10d
	cmpl	%r10d, %r8d
	cmovle	%r8d, %r10d
	cmpb	%sil, %r11b
	movzbl	(%r9), %esi
	cmovne	%r10d, %r8d
	cmpb	%sil, %r11b
	je	.L6
	leal	-1(%rdx), %r10d
	cmpl	%ebp, %r10d
	cmovl	%ebp, %r10d
	cmpl	%r10d, %r8d
	cmovg	%r10d, %r8d
.L6:
	addl	$2, %eax
	subl	$2, %edx
	addq	$2, %r9
	cmpl	%eax, %r12d
	jg	.L7
.L4:
	movslq	%eax, %rdx
	addq	%rbx, %rdx
	jmp	.L9
	.p2align 4,,10
	.p2align 3
.L14:
	movl	%esi, %eax
.L9:
	movzbl	-1(%rdx), %ebx
	cmpb	%bl, (%rdx)
	je	.L8
	movl	%ecx, %esi
	subl	%eax, %esi
	cmpl	%eax, %esi
	cmovl	%eax, %esi
	cmpl	%esi, %r8d
	cmovg	%esi, %r8d
.L8:
	leal	1(%rax), %esi
	addq	$1, %rdx
	cmpl	%eax, %edi
	jg	.L14
.L2:
	xorl	%eax, %eax
	movl	%r8d, %edx
	movl	$1, %edi
	leaq	.LC1(%rip), %rsi
	call	__printf_chk@PLT
	movq	100008(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L19
	addq	$100016, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 32
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
.L11:
	.cfi_restore_state
	xorl	%r8d, %r8d
	jmp	.L2
.L13:
	movl	%ecx, %r8d
	movl	$1, %eax
	jmp	.L4
.L12:
	movl	$1, %r8d
	jmp	.L2
.L19:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.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>
int main(){
  char s[100001];
  int i,t,n,x;
  scanf("%s",s);
  for(n=0;s[n];n++);
  x=n;for(i=1;i<n;i++)if(s[i]!=s[i-1]){t=i<n-i?n-i:i;x=t<x?t:x;}
  printf("%d",x);
}

100000010
 011
 00001101
 111
 00011101
 100000101
 11111111
 000000000
 100000011
 100001011

7 2 4 3 5 6 8 9 7 5
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>
int main(){
  char s[100001];
  int i,t,n,x;
  scanf("%s",s);
  for(n=0;s[n];n++);
  x=n;for(i=1;i<n;i++)if(s[i]!=s[i-1]){t=i<n-i?n-i:i;x=t<x?t:x;}
  printf("%d",x);
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%s"
.LC1:
	.string	"%d"
	.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
	leaq	-98304(%rsp), %r11
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	subq	$1728, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-100016(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -100028(%rbp)
	jmp	.L2
.L3:
	addl	$1, -100028(%rbp)
.L2:
	movl	-100028(%rbp), %eax
	cltq
	movzbl	-100016(%rbp,%rax), %eax
	testb	%al, %al
	jne	.L3
	movl	-100028(%rbp), %eax
	movl	%eax, -100024(%rbp)
	movl	$1, -100032(%rbp)
	jmp	.L4
.L6:
	movl	-100032(%rbp), %eax
	cltq
	movzbl	-100016(%rbp,%rax), %edx
	movl	-100032(%rbp), %eax
	subl	$1, %eax
	cltq
	movzbl	-100016(%rbp,%rax), %eax
	cmpb	%al, %dl
	je	.L5
	movl	-100028(%rbp), %eax
	subl	-100032(%rbp), %eax
	movl	-100032(%rbp), %edx
	cmpl	%eax, %edx
	cmovge	%edx, %eax
	movl	%eax, -100020(%rbp)
	movl	-100024(%rbp), %edx
	movl	-100020(%rbp), %eax
	cmpl	%eax, %edx
	cmovle	%edx, %eax
	movl	%eax, -100024(%rbp)
.L5:
	addl	$1, -100032(%rbp)
.L4:
	movl	-100032(%rbp), %eax
	cmpl	-100028(%rbp), %eax
	jl	.L6
	movl	-100024(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L8
	call	__stack_chk_fail@PLT
.L8:
	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"
.LC1:
	.string	"%d"
	.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
	leaq	-98304(%rsp), %r11
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	subq	$1728, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-100016(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -100028(%rbp)
	jmp	.L2
.L3:
	addl	$1, -100028(%rbp)
.L2:
	movl	-100028(%rbp), %eax
	cltq
	movzbl	-100016(%rbp,%rax), %eax
	testb	%al, %al
	jne	.L3
	movl	-100028(%rbp), %eax
	movl	%eax, -100024(%rbp)
	movl	$1, -100032(%rbp)
	jmp	.L4
.L6:
	movl	-100032(%rbp), %eax
	cltq
	movzbl	-100016(%rbp,%rax), %edx
	movl	-100032(%rbp), %eax
	subl	$1, %eax
	cltq
	movzbl	-100016(%rbp,%rax), %eax
	cmpb	%al, %dl
	je	.L5
	movl	-100028(%rbp), %eax
	subl	-100032(%rbp), %eax
	movl	-100032(%rbp), %edx
	cmpl	%eax, %edx
	cmovge	%edx, %eax
	movl	%eax, -100020(%rbp)
	movl	-100024(%rbp), %edx
	movl	-100020(%rbp), %eax
	cmpl	%eax, %edx
	cmovle	%edx, %eax
	movl	%eax, -100024(%rbp)
.L5:
	addl	$1, -100032(%rbp)
.L4:
	movl	-100032(%rbp), %eax
	cmpl	-100028(%rbp), %eax
	jl	.L6
	movl	-100024(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L8
	call	__stack_chk_fail@PLT
.L8:
	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:
