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];
	scanf("%s", &S);
	
	int i, a[100001], count = 0;
	for (i = 0; S[i] != 0; i++) {
		a[i] = S[i] - '0';
		if (i % 2 == 0) a[i] ^= 1;
		count += a[i];
	}
	
	if (count <= i / 2) printf("%d\n", count);
	else printf("%d\n", i - count);
	fflush(stdout);
	return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%s"
.LC1:
	.string	"%d\n"
	.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	-499712(%rsp), %r11
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	subq	$336, %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, -500036(%rbp)
	movl	$0, -500040(%rbp)
	jmp	.L2
.L4:
	movl	-500040(%rbp), %eax
	cltq
	movzbl	-100016(%rbp,%rax), %eax
	movsbl	%al, %eax
	leal	-48(%rax), %edx
	movl	-500040(%rbp), %eax
	cltq
	movl	%edx, -500032(%rbp,%rax,4)
	movl	-500040(%rbp), %eax
	andl	$1, %eax
	testl	%eax, %eax
	jne	.L3
	movl	-500040(%rbp), %eax
	cltq
	movl	-500032(%rbp,%rax,4), %eax
	xorl	$1, %eax
	movl	%eax, %edx
	movl	-500040(%rbp), %eax
	cltq
	movl	%edx, -500032(%rbp,%rax,4)
.L3:
	movl	-500040(%rbp), %eax
	cltq
	movl	-500032(%rbp,%rax,4), %eax
	addl	%eax, -500036(%rbp)
	addl	$1, -500040(%rbp)
.L2:
	movl	-500040(%rbp), %eax
	cltq
	movzbl	-100016(%rbp,%rax), %eax
	testb	%al, %al
	jne	.L4
	movl	-500040(%rbp), %eax
	movl	%eax, %edx
	shrl	$31, %edx
	addl	%edx, %eax
	sarl	%eax
	cmpl	%eax, -500036(%rbp)
	jg	.L5
	movl	-500036(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L6
.L5:
	movl	-500040(%rbp), %eax
	subl	-500036(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L6:
	movq	stdout(%rip), %rax
	movq	%rax, %rdi
	call	fflush@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\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	leaq	-98304(%rsp), %r11
	.cfi_def_cfa 11, 98312
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	.cfi_def_cfa_register 7
	subq	$1720, %rsp
	.cfi_def_cfa_offset 100032
	leaq	.LC0(%rip), %rdi
	movq	%fs:40, %rax
	movq	%rax, 100008(%rsp)
	xorl	%eax, %eax
	movq	%rsp, %rsi
	call	__isoc99_scanf@PLT
	movsbl	(%rsp), %eax
	testb	%al, %al
	je	.L8
	leaq	1(%rsp), %rcx
	xorl	%r8d, %r8d
	xorl	%edx, %edx
	.p2align 4,,10
	.p2align 3
.L4:
	subl	$48, %eax
	movl	%eax, %esi
	xorl	$1, %esi
	testb	$1, %dl
	cmove	%esi, %eax
	addq	$1, %rcx
	addl	$1, %edx
	addl	%eax, %r8d
	movsbl	-1(%rcx), %eax
	testb	%al, %al
	jne	.L4
	movl	%edx, %eax
	sarl	%eax
	cmpl	%r8d, %eax
	jge	.L2
	subl	%r8d, %edx
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L6:
	movq	stdout(%rip), %rdi
	call	fflush@PLT
	movq	100008(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L12
	xorl	%eax, %eax
	addq	$100024, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 8
	ret
.L8:
	.cfi_restore_state
	xorl	%r8d, %r8d
.L2:
	movl	%r8d, %edx
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L6
.L12:
	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\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	leaq	-98304(%rsp), %r11
	.cfi_def_cfa 11, 98312
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	.cfi_def_cfa_register 7
	subq	$1720, %rsp
	.cfi_def_cfa_offset 100032
	leaq	.LC0(%rip), %rdi
	movq	%fs:40, %rax
	movq	%rax, 100008(%rsp)
	xorl	%eax, %eax
	movq	%rsp, %rsi
	call	__isoc99_scanf@PLT
	movsbl	(%rsp), %eax
	testb	%al, %al
	je	.L8
	leaq	1(%rsp), %rcx
	xorl	%r8d, %r8d
	xorl	%edx, %edx
	.p2align 4,,10
	.p2align 3
.L4:
	subl	$48, %eax
	movl	%eax, %esi
	xorl	$1, %esi
	testb	$1, %dl
	cmove	%esi, %eax
	addq	$1, %rcx
	addl	$1, %edx
	addl	%eax, %r8d
	movsbl	-1(%rcx), %eax
	testb	%al, %al
	jne	.L4
	movl	%edx, %eax
	sarl	%eax
	cmpl	%r8d, %eax
	jge	.L2
	subl	%r8d, %edx
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L6:
	movq	stdout(%rip), %rdi
	call	fflush@PLT
	movq	100008(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L12
	xorl	%eax, %eax
	addq	$100024, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 8
	ret
.L8:
	.cfi_restore_state
	xorl	%r8d, %r8d
.L2:
	movl	%r8d, %edx
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L6
.L12:
	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];
	scanf("%s", &S);
	
	int i, a[100001], count = 0;
	for (i = 0; S[i] != 0; i++) {
		a[i] = S[i] - '0';
		if (i % 2 == 0) a[i] ^= 1;
		count += a[i];
	}
	
	if (count <= i / 2) printf("%d\n", count);
	else printf("%d\n", i - count);
	fflush(stdout);
	return 0;
}
10110010
 010
 10110110
 00110110
 100
 10100110
 01110110
 01110111
 10011010
 1

2
 0
 3
 4
 1
 2
 3
 2
 2
 0

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];
	scanf("%s", &S);
	
	int i, a[100001], count = 0;
	for (i = 0; S[i] != 0; i++) {
		a[i] = S[i] - '0';
		if (i % 2 == 0) a[i] ^= 1;
		count += a[i];
	}
	
	if (count <= i / 2) printf("%d\n", count);
	else printf("%d\n", i - count);
	fflush(stdout);
	return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%s"
.LC1:
	.string	"%d\n"
	.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	-499712(%rsp), %r11
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	subq	$336, %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, -500036(%rbp)
	movl	$0, -500040(%rbp)
	jmp	.L2
.L4:
	movl	-500040(%rbp), %eax
	cltq
	movzbl	-100016(%rbp,%rax), %eax
	movsbl	%al, %eax
	leal	-48(%rax), %edx
	movl	-500040(%rbp), %eax
	cltq
	movl	%edx, -500032(%rbp,%rax,4)
	movl	-500040(%rbp), %eax
	andl	$1, %eax
	testl	%eax, %eax
	jne	.L3
	movl	-500040(%rbp), %eax
	cltq
	movl	-500032(%rbp,%rax,4), %eax
	xorl	$1, %eax
	movl	%eax, %edx
	movl	-500040(%rbp), %eax
	cltq
	movl	%edx, -500032(%rbp,%rax,4)
.L3:
	movl	-500040(%rbp), %eax
	cltq
	movl	-500032(%rbp,%rax,4), %eax
	addl	%eax, -500036(%rbp)
	addl	$1, -500040(%rbp)
.L2:
	movl	-500040(%rbp), %eax
	cltq
	movzbl	-100016(%rbp,%rax), %eax
	testb	%al, %al
	jne	.L4
	movl	-500040(%rbp), %eax
	movl	%eax, %edx
	shrl	$31, %edx
	addl	%edx, %eax
	sarl	%eax
	cmpl	%eax, -500036(%rbp)
	jg	.L5
	movl	-500036(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L6
.L5:
	movl	-500040(%rbp), %eax
	subl	-500036(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L6:
	movq	stdout(%rip), %rax
	movq	%rax, %rdi
	call	fflush@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\n"
	.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	-499712(%rsp), %r11
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	subq	$336, %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, -500036(%rbp)
	movl	$0, -500040(%rbp)
	jmp	.L2
.L4:
	movl	-500040(%rbp), %eax
	cltq
	movzbl	-100016(%rbp,%rax), %eax
	movsbl	%al, %eax
	leal	-48(%rax), %edx
	movl	-500040(%rbp), %eax
	cltq
	movl	%edx, -500032(%rbp,%rax,4)
	movl	-500040(%rbp), %eax
	andl	$1, %eax
	testl	%eax, %eax
	jne	.L3
	movl	-500040(%rbp), %eax
	cltq
	movl	-500032(%rbp,%rax,4), %eax
	xorl	$1, %eax
	movl	%eax, %edx
	movl	-500040(%rbp), %eax
	cltq
	movl	%edx, -500032(%rbp,%rax,4)
.L3:
	movl	-500040(%rbp), %eax
	cltq
	movl	-500032(%rbp,%rax,4), %eax
	addl	%eax, -500036(%rbp)
	addl	$1, -500040(%rbp)
.L2:
	movl	-500040(%rbp), %eax
	cltq
	movzbl	-100016(%rbp,%rax), %eax
	testb	%al, %al
	jne	.L4
	movl	-500040(%rbp), %eax
	movl	%eax, %edx
	shrl	$31, %edx
	addl	%edx, %eax
	sarl	%eax
	cmpl	%eax, -500036(%rbp)
	jg	.L5
	movl	-500036(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L6
.L5:
	movl	-500040(%rbp), %eax
	subl	-500036(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L6:
	movq	stdout(%rip), %rax
	movq	%rax, %rdi
	call	fflush@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:
