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>
void flip(unsigned char Go[],int n);

int main(){
	unsigned char Go[100000];
	int i,j;
	int n;
	int sum;
	
	while(1){
		scanf("%d\n",&n);
		if(n==0)break;
		for(i=0;i<n;i++){
			scanf("%d\n",&Go[i]);
			if(i%2){
				if(Go[i]+Go[i-1]==1){
					flip(Go,i);
				}
			}
		}
		sum=0;
		for(i=0;i<n;i++)sum+=Go[i];
		printf("%d\n",n-sum);
	}
	return 0;
}


void flip(unsigned char Go[],int i){
	int k;

	for(k=i-1;k>=0;k--){
		if(Go[k]==Go[i])break;
		Go[k]=Go[i];
	}

	return;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.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	-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
.L9:
	leaq	-100028(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-100028(%rbp), %eax
	testl	%eax, %eax
	je	.L13
	movl	$0, -100024(%rbp)
	jmp	.L4
.L6:
	leaq	-100016(%rbp), %rdx
	movl	-100024(%rbp), %eax
	cltq
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-100024(%rbp), %eax
	andl	$1, %eax
	testl	%eax, %eax
	je	.L5
	movl	-100024(%rbp), %eax
	cltq
	movzbl	-100016(%rbp,%rax), %eax
	movzbl	%al, %edx
	movl	-100024(%rbp), %eax
	subl	$1, %eax
	cltq
	movzbl	-100016(%rbp,%rax), %eax
	movzbl	%al, %eax
	addl	%edx, %eax
	cmpl	$1, %eax
	jne	.L5
	movl	-100024(%rbp), %edx
	leaq	-100016(%rbp), %rax
	movl	%edx, %esi
	movq	%rax, %rdi
	call	flip
.L5:
	addl	$1, -100024(%rbp)
.L4:
	movl	-100028(%rbp), %eax
	cmpl	%eax, -100024(%rbp)
	jl	.L6
	movl	$0, -100020(%rbp)
	movl	$0, -100024(%rbp)
	jmp	.L7
.L8:
	movl	-100024(%rbp), %eax
	cltq
	movzbl	-100016(%rbp,%rax), %eax
	movzbl	%al, %eax
	addl	%eax, -100020(%rbp)
	addl	$1, -100024(%rbp)
.L7:
	movl	-100028(%rbp), %eax
	cmpl	%eax, -100024(%rbp)
	jl	.L8
	movl	-100028(%rbp), %eax
	subl	-100020(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L9
.L13:
	nop
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L11
	call	__stack_chk_fail@PLT
.L11:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.globl	flip
	.type	flip, @function
flip:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -24(%rbp)
	movl	%esi, -28(%rbp)
	movl	-28(%rbp), %eax
	subl	$1, %eax
	movl	%eax, -4(%rbp)
	jmp	.L15
.L18:
	movl	-4(%rbp), %eax
	movslq	%eax, %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %edx
	movl	-28(%rbp), %eax
	movslq	%eax, %rcx
	movq	-24(%rbp), %rax
	addq	%rcx, %rax
	movzbl	(%rax), %eax
	cmpb	%al, %dl
	je	.L20
	movl	-28(%rbp), %eax
	movslq	%eax, %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	-4(%rbp), %edx
	movslq	%edx, %rcx
	movq	-24(%rbp), %rdx
	addq	%rcx, %rdx
	movzbl	(%rax), %eax
	movb	%al, (%rdx)
	subl	$1, -4(%rbp)
.L15:
	cmpl	$0, -4(%rbp)
	jns	.L18
	jmp	.L17
.L20:
	nop
.L17:
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	flip, .-flip
	.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	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	leaq	-98304(%rsp), %r11
	.cfi_def_cfa 11, 98360
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	.cfi_def_cfa_register 7
	subq	$1752, %rsp
	.cfi_def_cfa_offset 100112
	leaq	.LC0(%rip), %rbp
	movq	%fs:40, %rax
	movq	%rax, 100040(%rsp)
	xorl	%eax, %eax
	leaq	28(%rsp), %rax
	leaq	32(%rsp), %r12
	movq	%rax, 8(%rsp)
	.p2align 4,,10
	.p2align 3
.L13:
	movq	8(%rsp), %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	28(%rsp), %edx
	testl	%edx, %edx
	je	.L2
	jle	.L4
	movq	%r12, %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	movq	%r12, %r14
	call	__isoc99_scanf@PLT
	movl	28(%rsp), %edx
	xorl	%r15d, %r15d
	movl	$1, %r13d
	cmpl	$1, %edx
	jle	.L7
	.p2align 4,,10
	.p2align 3
.L6:
	movq	%r14, %rbx
	addq	$1, %r14
	xorl	%eax, %eax
	movq	%rbp, %rdi
	movq	%r14, %rsi
	call	__isoc99_scanf@PLT
	andl	$1, %r13d
	je	.L8
	movzbl	1(%rbx), %eax
	movzbl	(%rbx), %ecx
	movq	%rbx, %rdx
	addl	%ecx, %eax
	cmpl	$1, %eax
	je	.L24
.L8:
	addq	$1, %r15
	movl	28(%rsp), %edx
	leal	1(%r15), %r13d
	cmpl	%r13d, %edx
	jg	.L6
.L7:
	testl	%edx, %edx
	jle	.L4
	leal	-1(%rdx), %eax
	cmpl	$14, %eax
	jbe	.L16
	movl	%edx, %ecx
	pxor	%xmm0, %xmm0
	pxor	%xmm4, %xmm4
	movq	%r12, %rax
	shrl	$4, %ecx
	pxor	%xmm3, %xmm3
	subl	$1, %ecx
	salq	$4, %rcx
	leaq	48(%rsp,%rcx), %rcx
	.p2align 4,,10
	.p2align 3
.L11:
	movdqa	(%rax), %xmm1
	addq	$16, %rax
	movdqa	%xmm1, %xmm2
	punpckhbw	%xmm4, %xmm1
	punpcklbw	%xmm4, %xmm2
	movdqa	%xmm2, %xmm5
	punpckhwd	%xmm3, %xmm2
	punpcklwd	%xmm3, %xmm5
	paddd	%xmm5, %xmm0
	paddd	%xmm2, %xmm0
	movdqa	%xmm1, %xmm2
	punpckhwd	%xmm3, %xmm1
	punpcklwd	%xmm3, %xmm2
	paddd	%xmm2, %xmm0
	paddd	%xmm1, %xmm0
	cmpq	%rcx, %rax
	jne	.L11
	movdqa	%xmm0, %xmm1
	movl	%edx, %ecx
	psrldq	$8, %xmm1
	andl	$-16, %ecx
	paddd	%xmm1, %xmm0
	movdqa	%xmm0, %xmm1
	psrldq	$4, %xmm1
	paddd	%xmm1, %xmm0
	movd	%xmm0, %eax
	testb	$15, %dl
	je	.L12
.L10:
	movslq	%ecx, %rsi
	movzbl	32(%rsp,%rsi), %esi
	addl	%esi, %eax
	leal	1(%rcx), %esi
	cmpl	%edx, %esi
	jge	.L12
	movslq	%esi, %rsi
	movzbl	32(%rsp,%rsi), %esi
	addl	%esi, %eax
	leal	2(%rcx), %esi
	cmpl	%esi, %edx
	jle	.L12
	movslq	%esi, %rsi
	movzbl	32(%rsp,%rsi), %esi
	addl	%esi, %eax
	leal	3(%rcx), %esi
	cmpl	%esi, %edx
	jle	.L12
	movslq	%esi, %rsi
	movzbl	32(%rsp,%rsi), %esi
	addl	%esi, %eax
	leal	4(%rcx), %esi
	cmpl	%esi, %edx
	jle	.L12
	movslq	%esi, %rsi
	movzbl	32(%rsp,%rsi), %esi
	addl	%esi, %eax
	leal	5(%rcx), %esi
	cmpl	%esi, %edx
	jle	.L12
	movslq	%esi, %rsi
	movzbl	32(%rsp,%rsi), %esi
	addl	%esi, %eax
	leal	6(%rcx), %esi
	cmpl	%esi, %edx
	jle	.L12
	movslq	%esi, %rsi
	movzbl	32(%rsp,%rsi), %esi
	addl	%esi, %eax
	leal	7(%rcx), %esi
	cmpl	%esi, %edx
	jle	.L12
	movslq	%esi, %rsi
	movzbl	32(%rsp,%rsi), %esi
	addl	%esi, %eax
	leal	8(%rcx), %esi
	cmpl	%esi, %edx
	jle	.L12
	movslq	%esi, %rsi
	movzbl	32(%rsp,%rsi), %esi
	addl	%esi, %eax
	leal	9(%rcx), %esi
	cmpl	%esi, %edx
	jle	.L12
	movslq	%esi, %rsi
	movzbl	32(%rsp,%rsi), %esi
	addl	%esi, %eax
	leal	10(%rcx), %esi
	cmpl	%esi, %edx
	jle	.L12
	movslq	%esi, %rsi
	movzbl	32(%rsp,%rsi), %esi
	addl	%esi, %eax
	leal	11(%rcx), %esi
	cmpl	%esi, %edx
	jle	.L12
	movslq	%esi, %rsi
	movzbl	32(%rsp,%rsi), %esi
	addl	%esi, %eax
	leal	12(%rcx), %esi
	cmpl	%esi, %edx
	jle	.L12
	movslq	%esi, %rsi
	movzbl	32(%rsp,%rsi), %esi
	addl	%esi, %eax
	leal	13(%rcx), %esi
	cmpl	%esi, %edx
	jle	.L12
	movslq	%esi, %rsi
	addl	$14, %ecx
	movzbl	32(%rsp,%rsi), %esi
	addl	%esi, %eax
	cmpl	%ecx, %edx
	jle	.L12
	movslq	%ecx, %rcx
	movzbl	32(%rsp,%rcx), %ecx
	addl	%ecx, %eax
	.p2align 4,,10
	.p2align 3
.L12:
	subl	%eax, %edx
.L4:
	movq	%rbp, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L13
	.p2align 4,,10
	.p2align 3
.L24:
	leaq	-1(%rbx), %rcx
	subq	%r15, %rcx
	.p2align 4,,10
	.p2align 3
.L9:
	movzbl	1(%rdx), %eax
	cmpb	%al, (%rbx)
	je	.L8
	movb	%al, (%rbx)
	subq	$1, %rbx
	cmpq	%rcx, %rbx
	jne	.L9
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L2:
	movq	100040(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L25
	addq	$100056, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
.L16:
	.cfi_restore_state
	xorl	%eax, %eax
	xorl	%ecx, %ecx
	jmp	.L10
.L25:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.text
	.p2align 4
	.globl	flip
	.type	flip, @function
flip:
.LFB24:
	.cfi_startproc
	endbr64
	movl	%esi, %edx
	subl	$1, %edx
	js	.L26
	movslq	%esi, %rsi
	movslq	%edx, %rax
	movl	%edx, %edx
	leaq	-2(%rdi,%rsi), %rcx
	leaq	(%rdi,%rsi), %r8
	addq	%rdi, %rax
	subq	%rdx, %rcx
	jmp	.L29
	.p2align 4,,10
	.p2align 3
.L31:
	movb	%dl, (%rax)
	subq	$1, %rax
	cmpq	%rcx, %rax
	je	.L26
.L29:
	movzbl	(%r8), %edx
	cmpb	%dl, (%rax)
	jne	.L31
.L26:
	ret
	.cfi_endproc
.LFE24:
	.size	flip, .-flip
	.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	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	leaq	-98304(%rsp), %r11
	.cfi_def_cfa 11, 98360
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	.cfi_def_cfa_register 7
	subq	$1752, %rsp
	.cfi_def_cfa_offset 100112
	leaq	.LC0(%rip), %rbp
	movq	%fs:40, %rax
	movq	%rax, 100040(%rsp)
	xorl	%eax, %eax
	leaq	28(%rsp), %rax
	leaq	32(%rsp), %r12
	movq	%rax, 8(%rsp)
	.p2align 4,,10
	.p2align 3
.L13:
	movq	8(%rsp), %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	28(%rsp), %edx
	testl	%edx, %edx
	je	.L2
	jle	.L4
	movq	%r12, %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	movq	%r12, %r14
	call	__isoc99_scanf@PLT
	movl	28(%rsp), %edx
	xorl	%r15d, %r15d
	movl	$1, %r13d
	cmpl	$1, %edx
	jle	.L7
	.p2align 4,,10
	.p2align 3
.L6:
	movq	%r14, %rbx
	addq	$1, %r14
	xorl	%eax, %eax
	movq	%rbp, %rdi
	movq	%r14, %rsi
	call	__isoc99_scanf@PLT
	andl	$1, %r13d
	je	.L8
	movzbl	1(%rbx), %eax
	movzbl	(%rbx), %ecx
	movq	%rbx, %rdx
	addl	%ecx, %eax
	cmpl	$1, %eax
	je	.L24
.L8:
	addq	$1, %r15
	movl	28(%rsp), %edx
	leal	1(%r15), %r13d
	cmpl	%r13d, %edx
	jg	.L6
.L7:
	testl	%edx, %edx
	jle	.L4
	leal	-1(%rdx), %eax
	cmpl	$14, %eax
	jbe	.L16
	movl	%edx, %ecx
	pxor	%xmm0, %xmm0
	pxor	%xmm4, %xmm4
	movq	%r12, %rax
	shrl	$4, %ecx
	pxor	%xmm3, %xmm3
	subl	$1, %ecx
	salq	$4, %rcx
	leaq	48(%rsp,%rcx), %rcx
	.p2align 4,,10
	.p2align 3
.L11:
	movdqa	(%rax), %xmm1
	addq	$16, %rax
	movdqa	%xmm1, %xmm2
	punpckhbw	%xmm4, %xmm1
	punpcklbw	%xmm4, %xmm2
	movdqa	%xmm2, %xmm5
	punpckhwd	%xmm3, %xmm2
	punpcklwd	%xmm3, %xmm5
	paddd	%xmm5, %xmm0
	paddd	%xmm2, %xmm0
	movdqa	%xmm1, %xmm2
	punpckhwd	%xmm3, %xmm1
	punpcklwd	%xmm3, %xmm2
	paddd	%xmm2, %xmm0
	paddd	%xmm1, %xmm0
	cmpq	%rcx, %rax
	jne	.L11
	movdqa	%xmm0, %xmm1
	movl	%edx, %ecx
	psrldq	$8, %xmm1
	andl	$-16, %ecx
	paddd	%xmm1, %xmm0
	movdqa	%xmm0, %xmm1
	psrldq	$4, %xmm1
	paddd	%xmm1, %xmm0
	movd	%xmm0, %eax
	testb	$15, %dl
	je	.L12
.L10:
	movslq	%ecx, %rsi
	movzbl	32(%rsp,%rsi), %esi
	addl	%esi, %eax
	leal	1(%rcx), %esi
	cmpl	%edx, %esi
	jge	.L12
	movslq	%esi, %rsi
	movzbl	32(%rsp,%rsi), %esi
	addl	%esi, %eax
	leal	2(%rcx), %esi
	cmpl	%esi, %edx
	jle	.L12
	movslq	%esi, %rsi
	movzbl	32(%rsp,%rsi), %esi
	addl	%esi, %eax
	leal	3(%rcx), %esi
	cmpl	%esi, %edx
	jle	.L12
	movslq	%esi, %rsi
	movzbl	32(%rsp,%rsi), %esi
	addl	%esi, %eax
	leal	4(%rcx), %esi
	cmpl	%esi, %edx
	jle	.L12
	movslq	%esi, %rsi
	movzbl	32(%rsp,%rsi), %esi
	addl	%esi, %eax
	leal	5(%rcx), %esi
	cmpl	%esi, %edx
	jle	.L12
	movslq	%esi, %rsi
	movzbl	32(%rsp,%rsi), %esi
	addl	%esi, %eax
	leal	6(%rcx), %esi
	cmpl	%esi, %edx
	jle	.L12
	movslq	%esi, %rsi
	movzbl	32(%rsp,%rsi), %esi
	addl	%esi, %eax
	leal	7(%rcx), %esi
	cmpl	%esi, %edx
	jle	.L12
	movslq	%esi, %rsi
	movzbl	32(%rsp,%rsi), %esi
	addl	%esi, %eax
	leal	8(%rcx), %esi
	cmpl	%esi, %edx
	jle	.L12
	movslq	%esi, %rsi
	movzbl	32(%rsp,%rsi), %esi
	addl	%esi, %eax
	leal	9(%rcx), %esi
	cmpl	%esi, %edx
	jle	.L12
	movslq	%esi, %rsi
	movzbl	32(%rsp,%rsi), %esi
	addl	%esi, %eax
	leal	10(%rcx), %esi
	cmpl	%esi, %edx
	jle	.L12
	movslq	%esi, %rsi
	movzbl	32(%rsp,%rsi), %esi
	addl	%esi, %eax
	leal	11(%rcx), %esi
	cmpl	%esi, %edx
	jle	.L12
	movslq	%esi, %rsi
	movzbl	32(%rsp,%rsi), %esi
	addl	%esi, %eax
	leal	12(%rcx), %esi
	cmpl	%esi, %edx
	jle	.L12
	movslq	%esi, %rsi
	movzbl	32(%rsp,%rsi), %esi
	addl	%esi, %eax
	leal	13(%rcx), %esi
	cmpl	%esi, %edx
	jle	.L12
	movslq	%esi, %rsi
	addl	$14, %ecx
	movzbl	32(%rsp,%rsi), %esi
	addl	%esi, %eax
	cmpl	%ecx, %edx
	jle	.L12
	movslq	%ecx, %rcx
	movzbl	32(%rsp,%rcx), %ecx
	addl	%ecx, %eax
	.p2align 4,,10
	.p2align 3
.L12:
	subl	%eax, %edx
.L4:
	movq	%rbp, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L13
	.p2align 4,,10
	.p2align 3
.L24:
	leaq	-1(%rbx), %rcx
	subq	%r15, %rcx
	.p2align 4,,10
	.p2align 3
.L9:
	movzbl	1(%rdx), %eax
	cmpb	%al, (%rbx)
	je	.L8
	movb	%al, (%rbx)
	subq	$1, %rbx
	cmpq	%rcx, %rbx
	jne	.L9
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L2:
	movq	100040(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L25
	addq	$100056, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
.L16:
	.cfi_restore_state
	xorl	%eax, %eax
	xorl	%ecx, %ecx
	jmp	.L10
.L25:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.text
	.p2align 4
	.globl	flip
	.type	flip, @function
flip:
.LFB24:
	.cfi_startproc
	endbr64
	movl	%esi, %edx
	subl	$1, %edx
	js	.L26
	movslq	%esi, %rsi
	movslq	%edx, %rax
	movl	%edx, %edx
	leaq	-2(%rdi,%rsi), %rcx
	leaq	(%rdi,%rsi), %r8
	addq	%rdi, %rax
	subq	%rdx, %rcx
	jmp	.L29
	.p2align 4,,10
	.p2align 3
.L31:
	movb	%dl, (%rax)
	subq	$1, %rax
	cmpq	%rcx, %rax
	je	.L26
.L29:
	movzbl	(%r8), %edx
	cmpb	%dl, (%rax)
	jne	.L31
.L26:
	ret
	.cfi_endproc
.LFE24:
	.size	flip, .-flip
	.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>
void flip(unsigned char Go[],int n);

int main(){
	unsigned char Go[100000];
	int i,j;
	int n;
	int sum;
	
	while(1){
		scanf("%d\n",&n);
		if(n==0)break;
		for(i=0;i<n;i++){
			scanf("%d\n",&Go[i]);
			if(i%2){
				if(Go[i]+Go[i-1]==1){
					flip(Go,i);
				}
			}
		}
		sum=0;
		for(i=0;i<n;i++)sum+=Go[i];
		printf("%d\n",n-sum);
	}
	return 0;
}


void flip(unsigned char Go[],int i){
	int k;

	for(k=i-1;k>=0;k--){
		if(Go[k]==Go[i])break;
		Go[k]=Go[i];
	}

	return;
}
8
1
1
1
1
0
0
0
0
8
1
0
1
1
0
0
0
1
0
 8
1
1
1
1
0
0
0
0
8
1
0
0
1
0
0
0
1
0
 8
1
0
1
1
0
0
0
0
4
1
0
1
1
0
0
0
1
0
 8
1
0
1
1
0
0
0
0
2
1
0
1
1
0
0
-1
1
0
 8
0
0
1
1
0
0
0
0
2
1
0
2
1
0
0
-1
1
0
 8
1
1
1
1
0
0
0
0
8
1
0
1
1
0
0
1
1
0
 8
1
0
1
1
0
0
-1
0
8
1
0
0
1
0
0
0
1
0
 8
1
1
2
1
0
0
0
0
1
0
0
1
1
0
0
0
1
0
 8
0
0
1
1
0
0
0
0
3
1
0
1
1
0
0
-1
1
0
 8
1
1
1
1
1
0
0
0
8
1
0
1
1
0
0
1
1
0

4
2
 4
0
 6
2
 6
2
0
 6
2
2
 4
4
 -249
0
 3
1
 6
2
1
 8
4

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>
void flip(unsigned char Go[],int n);

int main(){
	unsigned char Go[100000];
	int i,j;
	int n;
	int sum;
	
	while(1){
		scanf("%d\n",&n);
		if(n==0)break;
		for(i=0;i<n;i++){
			scanf("%d\n",&Go[i]);
			if(i%2){
				if(Go[i]+Go[i-1]==1){
					flip(Go,i);
				}
			}
		}
		sum=0;
		for(i=0;i<n;i++)sum+=Go[i];
		printf("%d\n",n-sum);
	}
	return 0;
}


void flip(unsigned char Go[],int i){
	int k;

	for(k=i-1;k>=0;k--){
		if(Go[k]==Go[i])break;
		Go[k]=Go[i];
	}

	return;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.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	-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
.L9:
	leaq	-100028(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-100028(%rbp), %eax
	testl	%eax, %eax
	je	.L13
	movl	$0, -100024(%rbp)
	jmp	.L4
.L6:
	leaq	-100016(%rbp), %rdx
	movl	-100024(%rbp), %eax
	cltq
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-100024(%rbp), %eax
	andl	$1, %eax
	testl	%eax, %eax
	je	.L5
	movl	-100024(%rbp), %eax
	cltq
	movzbl	-100016(%rbp,%rax), %eax
	movzbl	%al, %edx
	movl	-100024(%rbp), %eax
	subl	$1, %eax
	cltq
	movzbl	-100016(%rbp,%rax), %eax
	movzbl	%al, %eax
	addl	%edx, %eax
	cmpl	$1, %eax
	jne	.L5
	movl	-100024(%rbp), %edx
	leaq	-100016(%rbp), %rax
	movl	%edx, %esi
	movq	%rax, %rdi
	call	flip
.L5:
	addl	$1, -100024(%rbp)
.L4:
	movl	-100028(%rbp), %eax
	cmpl	%eax, -100024(%rbp)
	jl	.L6
	movl	$0, -100020(%rbp)
	movl	$0, -100024(%rbp)
	jmp	.L7
.L8:
	movl	-100024(%rbp), %eax
	cltq
	movzbl	-100016(%rbp,%rax), %eax
	movzbl	%al, %eax
	addl	%eax, -100020(%rbp)
	addl	$1, -100024(%rbp)
.L7:
	movl	-100028(%rbp), %eax
	cmpl	%eax, -100024(%rbp)
	jl	.L8
	movl	-100028(%rbp), %eax
	subl	-100020(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L9
.L13:
	nop
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L11
	call	__stack_chk_fail@PLT
.L11:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.globl	flip
	.type	flip, @function
flip:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -24(%rbp)
	movl	%esi, -28(%rbp)
	movl	-28(%rbp), %eax
	subl	$1, %eax
	movl	%eax, -4(%rbp)
	jmp	.L15
.L18:
	movl	-4(%rbp), %eax
	movslq	%eax, %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %edx
	movl	-28(%rbp), %eax
	movslq	%eax, %rcx
	movq	-24(%rbp), %rax
	addq	%rcx, %rax
	movzbl	(%rax), %eax
	cmpb	%al, %dl
	je	.L20
	movl	-28(%rbp), %eax
	movslq	%eax, %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	-4(%rbp), %edx
	movslq	%edx, %rcx
	movq	-24(%rbp), %rdx
	addq	%rcx, %rdx
	movzbl	(%rax), %eax
	movb	%al, (%rdx)
	subl	$1, -4(%rbp)
.L15:
	cmpl	$0, -4(%rbp)
	jns	.L18
	jmp	.L17
.L20:
	nop
.L17:
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	flip, .-flip
	.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\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	-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
.L9:
	leaq	-100028(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-100028(%rbp), %eax
	testl	%eax, %eax
	je	.L13
	movl	$0, -100024(%rbp)
	jmp	.L4
.L6:
	leaq	-100016(%rbp), %rdx
	movl	-100024(%rbp), %eax
	cltq
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-100024(%rbp), %eax
	andl	$1, %eax
	testl	%eax, %eax
	je	.L5
	movl	-100024(%rbp), %eax
	cltq
	movzbl	-100016(%rbp,%rax), %eax
	movzbl	%al, %edx
	movl	-100024(%rbp), %eax
	subl	$1, %eax
	cltq
	movzbl	-100016(%rbp,%rax), %eax
	movzbl	%al, %eax
	addl	%edx, %eax
	cmpl	$1, %eax
	jne	.L5
	movl	-100024(%rbp), %edx
	leaq	-100016(%rbp), %rax
	movl	%edx, %esi
	movq	%rax, %rdi
	call	flip
.L5:
	addl	$1, -100024(%rbp)
.L4:
	movl	-100028(%rbp), %eax
	cmpl	%eax, -100024(%rbp)
	jl	.L6
	movl	$0, -100020(%rbp)
	movl	$0, -100024(%rbp)
	jmp	.L7
.L8:
	movl	-100024(%rbp), %eax
	cltq
	movzbl	-100016(%rbp,%rax), %eax
	movzbl	%al, %eax
	addl	%eax, -100020(%rbp)
	addl	$1, -100024(%rbp)
.L7:
	movl	-100028(%rbp), %eax
	cmpl	%eax, -100024(%rbp)
	jl	.L8
	movl	-100028(%rbp), %eax
	subl	-100020(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L9
.L13:
	nop
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L11
	call	__stack_chk_fail@PLT
.L11:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.globl	flip
	.type	flip, @function
flip:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -24(%rbp)
	movl	%esi, -28(%rbp)
	movl	-28(%rbp), %eax
	subl	$1, %eax
	movl	%eax, -4(%rbp)
	jmp	.L15
.L18:
	movl	-4(%rbp), %eax
	movslq	%eax, %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %edx
	movl	-28(%rbp), %eax
	movslq	%eax, %rcx
	movq	-24(%rbp), %rax
	addq	%rcx, %rax
	movzbl	(%rax), %eax
	cmpb	%al, %dl
	je	.L20
	movl	-28(%rbp), %eax
	movslq	%eax, %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	-4(%rbp), %edx
	movslq	%edx, %rcx
	movq	-24(%rbp), %rdx
	addq	%rcx, %rdx
	movzbl	(%rax), %eax
	movb	%al, (%rdx)
	subl	$1, -4(%rbp)
.L15:
	cmpl	$0, -4(%rbp)
	jns	.L18
	jmp	.L17
.L20:
	nop
.L17:
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	flip, .-flip
	.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:
