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 main(void) {
  int n,a[100],i,j,count,ans = 0;
  scanf("%d",&n);
  for (i = 0;i < n;i++) {
    scanf("%d",&a[i]);
  }
  for (i = 0;i < n - 1;i++) {
    if (a[i] == a[i + 1]) {
      count = 2;
      for (j = i + 2;j < n;j++) {
        if (a[i] == a[j]) {
          count++;
        } else {
          break;
        }
      }
      ans += count / 2;
      i = j - 1;
    }
  }
  printf("%d\n",ans);
}
```

Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	"%d\n"
	.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
	leaq	.LC0(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	movq	%r12, %rdi
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	subq	$432, %rsp
	.cfi_def_cfa_offset 464
	movq	%fs:40, %rax
	movq	%rax, 424(%rsp)
	xorl	%eax, %eax
	leaq	12(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %r8d
	testl	%r8d, %r8d
	jle	.L2
	leaq	16(%rsp), %rbp
	xorl	%ebx, %ebx
	.p2align 4,,10
	.p2align 3
.L3:
	movq	%rbp, %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	addl	$1, %ebx
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %r8d
	addq	$4, %rbp
	cmpl	%ebx, %r8d
	jg	.L3
.L2:
	leal	-1(%r8), %r10d
	xorl	%r11d, %r11d
	testl	%r10d, %r10d
	jle	.L4
	xorl	%edx, %edx
	leaq	16(%rsp), %rbx
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L11:
	movl	%eax, %edx
	cmpl	%edx, %r10d
	jle	.L4
.L8:
	leal	1(%rdx), %eax
	movslq	%edx, %rcx
	movslq	%eax, %rdi
	movl	16(%rsp,%rcx,4), %esi
	cmpl	16(%rsp,%rdi,4), %esi
	jne	.L11
	leal	2(%rdx), %edi
	cmpl	%r8d, %edi
	jge	.L12
	movl	%r8d, %r9d
	leaq	8(%rbx,%rcx,4), %rcx
	movl	$2, %eax
	subl	%edx, %r9d
	jmp	.L7
	.p2align 4,,10
	.p2align 3
.L19:
	addl	$1, %eax
	addl	$1, %edi
	addq	$4, %rcx
	cmpl	%eax, %r9d
	je	.L13
.L7:
	cmpl	(%rcx), %esi
	je	.L19
.L13:
	movl	%edi, %edx
.L6:
	sarl	%eax
	addl	%eax, %r11d
	cmpl	%edx, %r10d
	jg	.L8
	.p2align 4,,10
	.p2align 3
.L4:
	xorl	%eax, %eax
	movl	%r11d, %edx
	movl	$1, %edi
	leaq	.LC1(%rip), %rsi
	call	__printf_chk@PLT
	movq	424(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L20
	addq	$432, %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
.L12:
	.cfi_restore_state
	movl	%edi, %edx
	movl	$2, %eax
	jmp	.L6
.L20:
	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:
```

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	"%d"
.LC1:
	.string	"%d\n"
	.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
	leaq	.LC0(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	movq	%r12, %rdi
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	subq	$432, %rsp
	.cfi_def_cfa_offset 464
	movq	%fs:40, %rax
	movq	%rax, 424(%rsp)
	xorl	%eax, %eax
	leaq	12(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %r8d
	testl	%r8d, %r8d
	jle	.L2
	leaq	16(%rsp), %rbp
	xorl	%ebx, %ebx
	.p2align 4,,10
	.p2align 3
.L3:
	movq	%rbp, %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	addl	$1, %ebx
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %r8d
	addq	$4, %rbp
	cmpl	%ebx, %r8d
	jg	.L3
.L2:
	leal	-1(%r8), %r10d
	xorl	%r11d, %r11d
	testl	%r10d, %r10d
	jle	.L4
	xorl	%edx, %edx
	leaq	16(%rsp), %rbx
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L11:
	movl	%eax, %edx
	cmpl	%edx, %r10d
	jle	.L4
.L8:
	leal	1(%rdx), %eax
	movslq	%edx, %rcx
	movslq	%eax, %rdi
	movl	16(%rsp,%rcx,4), %esi
	cmpl	16(%rsp,%rdi,4), %esi
	jne	.L11
	leal	2(%rdx), %edi
	cmpl	%r8d, %edi
	jge	.L12
	movl	%r8d, %r9d
	leaq	8(%rbx,%rcx,4), %rcx
	movl	$2, %eax
	subl	%edx, %r9d
	jmp	.L7
	.p2align 4,,10
	.p2align 3
.L19:
	addl	$1, %eax
	addl	$1, %edi
	addq	$4, %rcx
	cmpl	%eax, %r9d
	je	.L13
.L7:
	cmpl	(%rcx), %esi
	je	.L19
.L13:
	movl	%edi, %edx
.L6:
	sarl	%eax
	addl	%eax, %r11d
	cmpl	%edx, %r10d
	jg	.L8
	.p2align 4,,10
	.p2align 3
.L4:
	xorl	%eax, %eax
	movl	%r11d, %edx
	movl	$1, %edi
	leaq	.LC1(%rip), %rsi
	call	__printf_chk@PLT
	movq	424(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L20
	addq	$432, %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
.L12:
	.cfi_restore_state
	movl	%edi, %edx
	movl	$2, %eax
	jmp	.L6
.L20:
	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
```assembly
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	"%d\n"
	.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
	leaq	.LC0(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	movq	%r12, %rdi
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	subq	$432, %rsp
	.cfi_def_cfa_offset 464
	movq	%fs:40, %rax
	movq	%rax, 424(%rsp)
	xorl	%eax, %eax
	leaq	12(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %r8d
	testl	%r8d, %r8d
	jle	.L2
	leaq	16(%rsp), %rbp
	xorl	%ebx, %ebx
	.p2align 4,,10
	.p2align 3
.L3:
	movq	%rbp, %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	addl	$1, %ebx
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %r8d
	addq	$4, %rbp
	cmpl	%ebx, %r8d
	jg	.L3
.L2:
	leal	-1(%r8), %r10d
	xorl	%r11d, %r11d
	testl	%r10d, %r10d
	jle	.L4
	xorl	%edx, %edx
	leaq	16(%rsp), %rbx
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L11:
	movl	%eax, %edx
	cmpl	%edx, %r10d
	jle	.L4
.L8:
	leal	1(%rdx), %eax
	movslq	%edx, %rcx
	movslq	%eax, %rdi
	movl	16(%rsp,%rcx,4), %esi
	cmpl	16(%rsp,%rdi,4), %esi
	jne	.L11
	leal	2(%rdx), %edi
	cmpl	%r8d, %edi
	jge	.L12
	movl	%r8d, %r9d
	leaq	8(%rbx,%rcx,4), %rcx
	movl	$2, %eax
	subl	%edx, %r9d
	jmp	.L7
	.p2align 4,,10
	.p2align 3
.L19:
	addl	$1, %eax
	addl	$1, %edi
	addq	$4, %rcx
	cmpl	%eax, %r9d
	je	.L13
.L7:
	cmpl	(%rcx), %esi
	je	.L19
.L13:
	movl	%edi, %edx
.L6:
	sarl	%eax
	addl	%eax, %r11d
	cmpl	%edx, %r10d
	jg	.L8
	.p2align 4,,10
	.p2align 3
.L4:
	xorl	%eax, %eax
	movl	%r11d, %edx
	movl	$1, %edi
	leaq	.LC1(%rip), %rsi
	call	__printf_chk@PLT
	movq	424(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L20
	addq	$432, %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
.L12:
	.cfi_restore_state
	movl	%edi, %edx
	movl	$2, %eax
	jmp	.L6
.L20:
	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:
```
```c
#include <stdio.h>

int main(void) {
  int n,a[100],i,j,count,ans = 0;
  scanf("%d",&n);
  for (i = 0;i < n;i++) {
    scanf("%d",&a[i]);
  }
  for (i = 0;i < n - 1;i++) {
    if (a[i] == a[i + 1]) {
      count = 2;
      for (j = i + 2;j < n;j++) {
        if (a[i] == a[j]) {
          count++;
        } else {
          break;
        }
      }
      ans += count / 2;
      i = j - 1;
    }
  }
  printf("%d\n",ans);
}
```
Given the following C code, your task is to generate highly optimized x86-64 assembly code.
C Code:

```c
#include <stdio.h>

int main(void) {
  int n,a[100],i,j,count,ans = 0;
  scanf("%d",&n);
  for (i = 0;i < n;i++) {
    scanf("%d",&a[i]);
  }
  for (i = 0;i < n - 1;i++) {
    if (a[i] == a[i + 1]) {
      count = 2;
      for (j = i + 2;j < n;j++) {
        if (a[i] == a[j]) {
          count++;
        } else {
          break;
        }
      }
      ans += count / 2;
      i = j - 1;
    }
  }
  printf("%d\n",ans);
}
```

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:

5
1 1 3 2 2
 3
0 2 1
 14
1 1 2 3 3 3 4 4 4 4 1 2 3 4
 3
1 2 2
 14
1 1 3 3 3 3 4 4 4 4 1 2 3 4
 14
1 1 3 3 3 4 3 4 4 4 1 2 3 4
 5
1 1 1 1 0
 5
1 1 6 2 2
 5
1 2 1 1 0
 5
1 1 9 2 2

2
 0
 4
 1
 5
 3
 2
 2
 1
 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 main(void) {
  int n,a[100],i,j,count,ans = 0;
  scanf("%d",&n);
  for (i = 0;i < n;i++) {
    scanf("%d",&a[i]);
  }
  for (i = 0;i < n - 1;i++) {
    if (a[i] == a[i + 1]) {
      count = 2;
      for (j = i + 2;j < n;j++) {
        if (a[i] == a[j]) {
          count++;
        } else {
          break;
        }
      }
      ans += count / 2;
      i = j - 1;
    }
  }
  printf("%d\n",ans);
}
```

Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	"%d\n"
	.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
	leaq	.LC0(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	movq	%r12, %rdi
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	subq	$432, %rsp
	.cfi_def_cfa_offset 464
	movq	%fs:40, %rax
	movq	%rax, 424(%rsp)
	xorl	%eax, %eax
	leaq	12(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %r8d
	testl	%r8d, %r8d
	jle	.L2
	leaq	16(%rsp), %rbp
	xorl	%ebx, %ebx
	.p2align 4,,10
	.p2align 3
.L3:
	movq	%rbp, %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	addl	$1, %ebx
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %r8d
	addq	$4, %rbp
	cmpl	%ebx, %r8d
	jg	.L3
.L2:
	leal	-1(%r8), %r10d
	xorl	%r11d, %r11d
	testl	%r10d, %r10d
	jle	.L4
	xorl	%edx, %edx
	leaq	16(%rsp), %rbx
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L11:
	movl	%eax, %edx
	cmpl	%edx, %r10d
	jle	.L4
.L8:
	leal	1(%rdx), %eax
	movslq	%edx, %rcx
	movslq	%eax, %rdi
	movl	16(%rsp,%rcx,4), %esi
	cmpl	16(%rsp,%rdi,4), %esi
	jne	.L11
	leal	2(%rdx), %edi
	cmpl	%r8d, %edi
	jge	.L12
	movl	%r8d, %r9d
	leaq	8(%rbx,%rcx,4), %rcx
	movl	$2, %eax
	subl	%edx, %r9d
	jmp	.L7
	.p2align 4,,10
	.p2align 3
.L19:
	addl	$1, %eax
	addl	$1, %edi
	addq	$4, %rcx
	cmpl	%eax, %r9d
	je	.L13
.L7:
	cmpl	(%rcx), %esi
	je	.L19
.L13:
	movl	%edi, %edx
.L6:
	sarl	%eax
	addl	%eax, %r11d
	cmpl	%edx, %r10d
	jg	.L8
	.p2align 4,,10
	.p2align 3
.L4:
	xorl	%eax, %eax
	movl	%r11d, %edx
	movl	$1, %edi
	leaq	.LC1(%rip), %rsi
	call	__printf_chk@PLT
	movq	424(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L20
	addq	$432, %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
.L12:
	.cfi_restore_state
	movl	%edi, %edx
	movl	$2, %eax
	jmp	.L6
.L20:
	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:
```

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	"%d"
.LC1:
	.string	"%d\n"
	.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
	leaq	.LC0(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	movq	%r12, %rdi
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	subq	$432, %rsp
	.cfi_def_cfa_offset 464
	movq	%fs:40, %rax
	movq	%rax, 424(%rsp)
	xorl	%eax, %eax
	leaq	12(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %r8d
	testl	%r8d, %r8d
	jle	.L2
	leaq	16(%rsp), %rbp
	xorl	%ebx, %ebx
	.p2align 4,,10
	.p2align 3
.L3:
	movq	%rbp, %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	addl	$1, %ebx
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %r8d
	addq	$4, %rbp
	cmpl	%ebx, %r8d
	jg	.L3
.L2:
	leal	-1(%r8), %r10d
	xorl	%r11d, %r11d
	testl	%r10d, %r10d
	jle	.L4
	xorl	%edx, %edx
	leaq	16(%rsp), %rbx
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L11:
	movl	%eax, %edx
	cmpl	%edx, %r10d
	jle	.L4
.L8:
	leal	1(%rdx), %eax
	movslq	%edx, %rcx
	movslq	%eax, %rdi
	movl	16(%rsp,%rcx,4), %esi
	cmpl	16(%rsp,%rdi,4), %esi
	jne	.L11
	leal	2(%rdx), %edi
	cmpl	%r8d, %edi
	jge	.L12
	movl	%r8d, %r9d
	leaq	8(%rbx,%rcx,4), %rcx
	movl	$2, %eax
	subl	%edx, %r9d
	jmp	.L7
	.p2align 4,,10
	.p2align 3
.L19:
	addl	$1, %eax
	addl	$1, %edi
	addq	$4, %rcx
	cmpl	%eax, %r9d
	je	.L13
.L7:
	cmpl	(%rcx), %esi
	je	.L19
.L13:
	movl	%edi, %edx
.L6:
	sarl	%eax
	addl	%eax, %r11d
	cmpl	%edx, %r10d
	jg	.L8
	.p2align 4,,10
	.p2align 3
.L4:
	xorl	%eax, %eax
	movl	%r11d, %edx
	movl	$1, %edi
	leaq	.LC1(%rip), %rsi
	call	__printf_chk@PLT
	movq	424(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L20
	addq	$432, %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
.L12:
	.cfi_restore_state
	movl	%edi, %edx
	movl	$2, %eax
	jmp	.L6
.L20:
	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:
```