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 swap(int *a,int *b){
  *a^=*b;
  *b^=*a;
  *a^=*b;
  return;
}

int main(){
  int n,p[30];
  int A,B,C,T,S=0;
  scanf("%d",&n);
  for(int i=1;i<=n;i++)
    scanf("%d",p+i);
  for(int i=2;i<n;i++){
    A=p[i-1];
    B=p[i];
    C=p[i+1];
    T=B;
    if(A<B) swap(&A,&B);
    if(B<C) swap(&B,&C);
    if(A<B) swap(&A,&B);
    if(T==B) S++;
  }
  printf("%d\n",S);
  return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	swap
	.type	swap, @function
swap:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -8(%rbp)
	movq	%rsi, -16(%rbp)
	movq	-8(%rbp), %rax
	movl	(%rax), %edx
	movq	-16(%rbp), %rax
	movl	(%rax), %eax
	xorl	%eax, %edx
	movq	-8(%rbp), %rax
	movl	%edx, (%rax)
	movq	-16(%rbp), %rax
	movl	(%rax), %edx
	movq	-8(%rbp), %rax
	movl	(%rax), %eax
	xorl	%eax, %edx
	movq	-16(%rbp), %rax
	movl	%edx, (%rax)
	movq	-8(%rbp), %rax
	movl	(%rax), %edx
	movq	-16(%rbp), %rax
	movl	(%rax), %eax
	xorl	%eax, %edx
	movq	-8(%rbp), %rax
	movl	%edx, (%rax)
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	swap, .-swap
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$160, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -144(%rbp)
	leaq	-160(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$1, -140(%rbp)
	jmp	.L4
.L5:
	movl	-140(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	-128(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -140(%rbp)
.L4:
	movl	-160(%rbp), %eax
	cmpl	%eax, -140(%rbp)
	jle	.L5
	movl	$2, -136(%rbp)
	jmp	.L6
.L11:
	movl	-136(%rbp), %eax
	subl	$1, %eax
	cltq
	movl	-128(%rbp,%rax,4), %eax
	movl	%eax, -156(%rbp)
	movl	-136(%rbp), %eax
	cltq
	movl	-128(%rbp,%rax,4), %eax
	movl	%eax, -152(%rbp)
	movl	-136(%rbp), %eax
	addl	$1, %eax
	cltq
	movl	-128(%rbp,%rax,4), %eax
	movl	%eax, -148(%rbp)
	movl	-152(%rbp), %eax
	movl	%eax, -132(%rbp)
	movl	-156(%rbp), %edx
	movl	-152(%rbp), %eax
	cmpl	%eax, %edx
	jge	.L7
	leaq	-152(%rbp), %rdx
	leaq	-156(%rbp), %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	swap
.L7:
	movl	-152(%rbp), %edx
	movl	-148(%rbp), %eax
	cmpl	%eax, %edx
	jge	.L8
	leaq	-148(%rbp), %rdx
	leaq	-152(%rbp), %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	swap
.L8:
	movl	-156(%rbp), %edx
	movl	-152(%rbp), %eax
	cmpl	%eax, %edx
	jge	.L9
	leaq	-152(%rbp), %rdx
	leaq	-156(%rbp), %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	swap
.L9:
	movl	-152(%rbp), %eax
	cmpl	%eax, -132(%rbp)
	jne	.L10
	addl	$1, -144(%rbp)
.L10:
	addl	$1, -136(%rbp)
.L6:
	movl	-160(%rbp), %eax
	cmpl	%eax, -136(%rbp)
	jl	.L11
	movl	-144(%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	.L13
	call	__stack_chk_fail@PLT
.L13:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.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
	.p2align 4
	.globl	swap
	.type	swap, @function
swap:
.LFB23:
	.cfi_startproc
	endbr64
	movl	(%rdi), %eax
	xorl	(%rsi), %eax
	movl	%eax, (%rdi)
	xorl	(%rsi), %eax
	movl	%eax, (%rsi)
	xorl	%eax, (%rdi)
	ret
	.cfi_endproc
.LFE23:
	.size	swap, .-swap
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC2:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB24:
	.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	$144, %rsp
	.cfi_def_cfa_offset 176
	movq	%fs:40, %rax
	movq	%rax, 136(%rsp)
	xorl	%eax, %eax
	leaq	12(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %eax
	testl	%eax, %eax
	jle	.L24
	leaq	20(%rsp), %rbp
	movl	$1, %ebx
	.p2align 4,,10
	.p2align 3
.L5:
	movq	%rbp, %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	addl	$1, %ebx
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %eax
	addq	$4, %rbp
	cmpl	%ebx, %eax
	jge	.L5
	cmpl	$2, %eax
	jle	.L24
	leal	-3(%rax), %edx
	leal	-2(%rax), %ecx
	cmpl	$2, %edx
	jbe	.L25
	movdqu	20(%rsp), %xmm3
	movdqu	24(%rsp), %xmm0
	movl	%ecx, %edx
	movdqu	28(%rsp), %xmm4
	shrl	$2, %edx
	movdqa	%xmm3, %xmm1
	movdqa	%xmm0, %xmm2
	pcmpgtd	%xmm0, %xmm1
	movdqa	%xmm1, %xmm5
	pand	%xmm1, %xmm2
	pandn	%xmm3, %xmm5
	pand	%xmm1, %xmm3
	pandn	%xmm0, %xmm1
	por	%xmm2, %xmm5
	movdqa	%xmm4, %xmm2
	por	%xmm3, %xmm1
	pcmpgtd	%xmm5, %xmm2
	pand	%xmm2, %xmm4
	pandn	%xmm5, %xmm2
	por	%xmm4, %xmm2
	movdqa	%xmm2, %xmm3
	pcmpgtd	%xmm1, %xmm3
	pand	%xmm3, %xmm1
	pandn	%xmm2, %xmm3
	por	%xmm1, %xmm3
	pcmpeqd	%xmm3, %xmm0
	pand	.LC1(%rip), %xmm0
	cmpl	$1, %edx
	je	.L7
	movdqu	36(%rsp), %xmm2
	movdqu	40(%rsp), %xmm4
	movdqu	44(%rsp), %xmm5
	movdqa	%xmm2, %xmm1
	movdqa	%xmm4, %xmm3
	pcmpgtd	%xmm4, %xmm1
	movdqa	%xmm1, %xmm6
	pand	%xmm1, %xmm3
	pandn	%xmm2, %xmm6
	pand	%xmm1, %xmm2
	pandn	%xmm4, %xmm1
	por	%xmm3, %xmm6
	movdqa	%xmm5, %xmm3
	por	%xmm2, %xmm1
	pcmpgtd	%xmm6, %xmm3
	pand	%xmm3, %xmm5
	pandn	%xmm6, %xmm3
	por	%xmm5, %xmm3
	movdqa	%xmm3, %xmm2
	pcmpgtd	%xmm1, %xmm2
	pand	%xmm2, %xmm1
	pandn	%xmm3, %xmm2
	por	%xmm1, %xmm2
	pcmpeqd	%xmm4, %xmm2
	psubd	%xmm2, %xmm0
	cmpl	$2, %edx
	je	.L7
	movdqu	52(%rsp), %xmm2
	movdqu	56(%rsp), %xmm4
	movdqu	60(%rsp), %xmm5
	movdqa	%xmm2, %xmm1
	movdqa	%xmm4, %xmm3
	pcmpgtd	%xmm4, %xmm1
	movdqa	%xmm1, %xmm6
	pand	%xmm1, %xmm3
	pandn	%xmm2, %xmm6
	pand	%xmm1, %xmm2
	pandn	%xmm4, %xmm1
	por	%xmm3, %xmm6
	movdqa	%xmm5, %xmm3
	por	%xmm2, %xmm1
	pcmpgtd	%xmm6, %xmm3
	pand	%xmm3, %xmm5
	pandn	%xmm6, %xmm3
	por	%xmm5, %xmm3
	movdqa	%xmm3, %xmm2
	pcmpgtd	%xmm1, %xmm2
	pand	%xmm2, %xmm1
	pandn	%xmm3, %xmm2
	por	%xmm1, %xmm2
	pcmpeqd	%xmm4, %xmm2
	psubd	%xmm2, %xmm0
	cmpl	$3, %edx
	je	.L7
	movdqu	68(%rsp), %xmm2
	movdqu	72(%rsp), %xmm4
	movdqu	76(%rsp), %xmm5
	movdqa	%xmm2, %xmm1
	movdqa	%xmm4, %xmm3
	pcmpgtd	%xmm4, %xmm1
	movdqa	%xmm1, %xmm6
	pand	%xmm1, %xmm3
	pandn	%xmm2, %xmm6
	pand	%xmm1, %xmm2
	pandn	%xmm4, %xmm1
	por	%xmm3, %xmm6
	movdqa	%xmm5, %xmm3
	por	%xmm2, %xmm1
	pcmpgtd	%xmm6, %xmm3
	pand	%xmm3, %xmm5
	pandn	%xmm6, %xmm3
	por	%xmm5, %xmm3
	movdqa	%xmm3, %xmm2
	pcmpgtd	%xmm1, %xmm2
	pand	%xmm2, %xmm1
	pandn	%xmm3, %xmm2
	por	%xmm1, %xmm2
	pcmpeqd	%xmm4, %xmm2
	psubd	%xmm2, %xmm0
	cmpl	$4, %edx
	je	.L7
	movdqu	84(%rsp), %xmm2
	movdqu	88(%rsp), %xmm4
	movdqu	92(%rsp), %xmm5
	movdqa	%xmm2, %xmm1
	movdqa	%xmm4, %xmm3
	pcmpgtd	%xmm4, %xmm1
	movdqa	%xmm1, %xmm6
	pand	%xmm1, %xmm3
	pandn	%xmm2, %xmm6
	pand	%xmm1, %xmm2
	pandn	%xmm4, %xmm1
	por	%xmm3, %xmm6
	movdqa	%xmm5, %xmm3
	por	%xmm2, %xmm1
	pcmpgtd	%xmm6, %xmm3
	pand	%xmm3, %xmm5
	pandn	%xmm6, %xmm3
	por	%xmm5, %xmm3
	movdqa	%xmm3, %xmm2
	pcmpgtd	%xmm1, %xmm2
	pand	%xmm2, %xmm1
	pandn	%xmm3, %xmm2
	por	%xmm1, %xmm2
	pcmpeqd	%xmm4, %xmm2
	psubd	%xmm2, %xmm0
	cmpl	$5, %edx
	je	.L7
	movdqu	100(%rsp), %xmm2
	movdqu	104(%rsp), %xmm4
	movdqu	108(%rsp), %xmm5
	movdqa	%xmm2, %xmm1
	movdqa	%xmm4, %xmm3
	pcmpgtd	%xmm4, %xmm1
	movdqa	%xmm1, %xmm6
	pand	%xmm1, %xmm3
	pandn	%xmm2, %xmm6
	pand	%xmm1, %xmm2
	pandn	%xmm4, %xmm1
	por	%xmm3, %xmm6
	movdqa	%xmm5, %xmm3
	por	%xmm2, %xmm1
	pcmpgtd	%xmm6, %xmm3
	pand	%xmm3, %xmm5
	pandn	%xmm6, %xmm3
	por	%xmm5, %xmm3
	movdqa	%xmm3, %xmm2
	pcmpgtd	%xmm1, %xmm2
	pand	%xmm2, %xmm1
	pandn	%xmm3, %xmm2
	por	%xmm1, %xmm2
	pcmpeqd	%xmm4, %xmm2
	psubd	%xmm2, %xmm0
.L7:
	movdqa	%xmm0, %xmm1
	movl	%ecx, %edi
	psrldq	$8, %xmm1
	andl	$-4, %edi
	paddd	%xmm1, %xmm0
	leal	2(%rdi), %esi
	movdqa	%xmm0, %xmm1
	psrldq	$4, %xmm1
	paddd	%xmm1, %xmm0
	movd	%xmm0, %edx
	cmpl	%edi, %ecx
	je	.L4
.L6:
	movslq	%esi, %r8
	leaq	16(%rsp), %r9
	leal	-1(%rax), %r11d
	leaq	0(,%r8,4), %rcx
	leal	1(%rsi), %r10d
	leaq	12(%rsp,%rcx), %rdi
	addq	%r9, %rcx
	cmpl	%r10d, %r11d
	jle	.L9
	cmpl	%esi, %eax
	jle	.L9
	movl	(%rdi), %r8d
	movl	(%rcx), %ecx
	leal	2(%rsi), %edi
	movslq	%edi, %rdi
.L12:
	movl	%r8d, %esi
	movl	%ecx, %r10d
	movl	-4(%r9,%rdi,4), %r8d
	cmpl	%ecx, %esi
	jge	.L56
.L10:
	cmpl	%esi, %r8d
	cmovge	%r8d, %esi
	cmpl	%r10d, %esi
	cmovg	%r10d, %esi
	cmpl	%ecx, %esi
	je	.L57
.L21:
	movl	(%r9,%rdi,4), %r10d
	movl	%edi, %esi
	movl	%r8d, %ebx
	cmpl	%ecx, %r8d
	jle	.L58
.L19:
	cmpl	%ecx, %r10d
	cmovge	%r10d, %ecx
	cmpl	%ebx, %ecx
	cmovg	%ebx, %ecx
	cmpl	%ecx, %r8d
	je	.L59
.L11:
	addq	$2, %rdi
	leal	-1(%rdi), %ecx
	cmpl	%ecx, %r11d
	jg	.L27
	movslq	%esi, %r8
	leal	1(%rsi), %r10d
.L9:
	leal	-1(%rsi), %ecx
	movslq	%ecx, %rcx
	movl	16(%rsp,%rcx,4), %edi
	movl	16(%rsp,%r8,4), %ecx
	movslq	%r10d, %r8
	movl	16(%rsp,%r8,4), %r8d
	movl	%ecx, %r9d
	cmpl	%ecx, %edi
	jge	.L60
.L13:
	cmpl	%edi, %r8d
	cmovge	%r8d, %edi
	cmpl	%r9d, %edi
	cmovg	%r9d, %edi
	cmpl	%edi, %ecx
	jne	.L14
	addl	$1, %edx
.L14:
	cmpl	%r10d, %eax
	jle	.L4
	leal	2(%rsi), %r10d
	movl	%r8d, %r9d
	movslq	%r10d, %rdi
	movl	16(%rsp,%rdi,4), %edi
	cmpl	%r8d, %ecx
	jge	.L61
.L15:
	cmpl	%ecx, %edi
	cmovge	%edi, %ecx
	cmpl	%r9d, %ecx
	cmovg	%r9d, %ecx
	cmpl	%ecx, %r8d
	jne	.L16
	addl	$1, %edx
.L16:
	cmpl	%r10d, %eax
	jle	.L4
	addl	$3, %esi
	movl	%edi, %ecx
	movslq	%esi, %rsi
	movl	16(%rsp,%rsi,4), %eax
	cmpl	%edi, %r8d
	jge	.L62
.L17:
	cmpl	%r8d, %eax
	cmovl	%r8d, %eax
	cmpl	%ecx, %eax
	cmovg	%ecx, %eax
	cmpl	%edi, %eax
	je	.L63
.L4:
	xorl	%eax, %eax
	leaq	.LC2(%rip), %rsi
	movl	$1, %edi
	call	__printf_chk@PLT
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L64
	addq	$144, %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
.L27:
	.cfi_restore_state
	movl	%r10d, %ecx
	jmp	.L12
.L58:
	movl	%ecx, %ebx
	movl	%r8d, %ecx
	jmp	.L19
.L56:
	movl	%esi, %r10d
	movl	%ecx, %esi
	jmp	.L10
.L57:
	addl	$1, %edx
	jmp	.L21
.L59:
	addl	$1, %edx
	jmp	.L11
.L60:
	movl	%edi, %r9d
	movl	%ecx, %edi
	jmp	.L13
.L61:
	movl	%ecx, %r9d
	movl	%r8d, %ecx
	jmp	.L15
.L62:
	movl	%r8d, %ecx
	movl	%edi, %r8d
	jmp	.L17
.L63:
	addl	$1, %edx
	jmp	.L4
.L24:
	xorl	%edx, %edx
	jmp	.L4
.L25:
	movl	$2, %esi
	xorl	%edx, %edx
	jmp	.L6
.L64:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE24:
	.size	main, .-main
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC1:
	.long	1
	.long	1
	.long	1
	.long	1
	.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
	.p2align 4
	.globl	swap
	.type	swap, @function
swap:
.LFB23:
	.cfi_startproc
	endbr64
	movl	(%rdi), %eax
	xorl	(%rsi), %eax
	movl	%eax, (%rdi)
	xorl	(%rsi), %eax
	movl	%eax, (%rsi)
	xorl	%eax, (%rdi)
	ret
	.cfi_endproc
.LFE23:
	.size	swap, .-swap
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC2:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB24:
	.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	$144, %rsp
	.cfi_def_cfa_offset 176
	movq	%fs:40, %rax
	movq	%rax, 136(%rsp)
	xorl	%eax, %eax
	leaq	12(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %eax
	testl	%eax, %eax
	jle	.L24
	leaq	20(%rsp), %rbp
	movl	$1, %ebx
	.p2align 4,,10
	.p2align 3
.L5:
	movq	%rbp, %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	addl	$1, %ebx
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %eax
	addq	$4, %rbp
	cmpl	%ebx, %eax
	jge	.L5
	cmpl	$2, %eax
	jle	.L24
	leal	-3(%rax), %edx
	leal	-2(%rax), %ecx
	cmpl	$2, %edx
	jbe	.L25
	movdqu	20(%rsp), %xmm3
	movdqu	24(%rsp), %xmm0
	movl	%ecx, %edx
	movdqu	28(%rsp), %xmm4
	shrl	$2, %edx
	movdqa	%xmm3, %xmm1
	movdqa	%xmm0, %xmm2
	pcmpgtd	%xmm0, %xmm1
	movdqa	%xmm1, %xmm5
	pand	%xmm1, %xmm2
	pandn	%xmm3, %xmm5
	pand	%xmm1, %xmm3
	pandn	%xmm0, %xmm1
	por	%xmm2, %xmm5
	movdqa	%xmm4, %xmm2
	por	%xmm3, %xmm1
	pcmpgtd	%xmm5, %xmm2
	pand	%xmm2, %xmm4
	pandn	%xmm5, %xmm2
	por	%xmm4, %xmm2
	movdqa	%xmm2, %xmm3
	pcmpgtd	%xmm1, %xmm3
	pand	%xmm3, %xmm1
	pandn	%xmm2, %xmm3
	por	%xmm1, %xmm3
	pcmpeqd	%xmm3, %xmm0
	pand	.LC1(%rip), %xmm0
	cmpl	$1, %edx
	je	.L7
	movdqu	36(%rsp), %xmm2
	movdqu	40(%rsp), %xmm4
	movdqu	44(%rsp), %xmm5
	movdqa	%xmm2, %xmm1
	movdqa	%xmm4, %xmm3
	pcmpgtd	%xmm4, %xmm1
	movdqa	%xmm1, %xmm6
	pand	%xmm1, %xmm3
	pandn	%xmm2, %xmm6
	pand	%xmm1, %xmm2
	pandn	%xmm4, %xmm1
	por	%xmm3, %xmm6
	movdqa	%xmm5, %xmm3
	por	%xmm2, %xmm1
	pcmpgtd	%xmm6, %xmm3
	pand	%xmm3, %xmm5
	pandn	%xmm6, %xmm3
	por	%xmm5, %xmm3
	movdqa	%xmm3, %xmm2
	pcmpgtd	%xmm1, %xmm2
	pand	%xmm2, %xmm1
	pandn	%xmm3, %xmm2
	por	%xmm1, %xmm2
	pcmpeqd	%xmm4, %xmm2
	psubd	%xmm2, %xmm0
	cmpl	$2, %edx
	je	.L7
	movdqu	52(%rsp), %xmm2
	movdqu	56(%rsp), %xmm4
	movdqu	60(%rsp), %xmm5
	movdqa	%xmm2, %xmm1
	movdqa	%xmm4, %xmm3
	pcmpgtd	%xmm4, %xmm1
	movdqa	%xmm1, %xmm6
	pand	%xmm1, %xmm3
	pandn	%xmm2, %xmm6
	pand	%xmm1, %xmm2
	pandn	%xmm4, %xmm1
	por	%xmm3, %xmm6
	movdqa	%xmm5, %xmm3
	por	%xmm2, %xmm1
	pcmpgtd	%xmm6, %xmm3
	pand	%xmm3, %xmm5
	pandn	%xmm6, %xmm3
	por	%xmm5, %xmm3
	movdqa	%xmm3, %xmm2
	pcmpgtd	%xmm1, %xmm2
	pand	%xmm2, %xmm1
	pandn	%xmm3, %xmm2
	por	%xmm1, %xmm2
	pcmpeqd	%xmm4, %xmm2
	psubd	%xmm2, %xmm0
	cmpl	$3, %edx
	je	.L7
	movdqu	68(%rsp), %xmm2
	movdqu	72(%rsp), %xmm4
	movdqu	76(%rsp), %xmm5
	movdqa	%xmm2, %xmm1
	movdqa	%xmm4, %xmm3
	pcmpgtd	%xmm4, %xmm1
	movdqa	%xmm1, %xmm6
	pand	%xmm1, %xmm3
	pandn	%xmm2, %xmm6
	pand	%xmm1, %xmm2
	pandn	%xmm4, %xmm1
	por	%xmm3, %xmm6
	movdqa	%xmm5, %xmm3
	por	%xmm2, %xmm1
	pcmpgtd	%xmm6, %xmm3
	pand	%xmm3, %xmm5
	pandn	%xmm6, %xmm3
	por	%xmm5, %xmm3
	movdqa	%xmm3, %xmm2
	pcmpgtd	%xmm1, %xmm2
	pand	%xmm2, %xmm1
	pandn	%xmm3, %xmm2
	por	%xmm1, %xmm2
	pcmpeqd	%xmm4, %xmm2
	psubd	%xmm2, %xmm0
	cmpl	$4, %edx
	je	.L7
	movdqu	84(%rsp), %xmm2
	movdqu	88(%rsp), %xmm4
	movdqu	92(%rsp), %xmm5
	movdqa	%xmm2, %xmm1
	movdqa	%xmm4, %xmm3
	pcmpgtd	%xmm4, %xmm1
	movdqa	%xmm1, %xmm6
	pand	%xmm1, %xmm3
	pandn	%xmm2, %xmm6
	pand	%xmm1, %xmm2
	pandn	%xmm4, %xmm1
	por	%xmm3, %xmm6
	movdqa	%xmm5, %xmm3
	por	%xmm2, %xmm1
	pcmpgtd	%xmm6, %xmm3
	pand	%xmm3, %xmm5
	pandn	%xmm6, %xmm3
	por	%xmm5, %xmm3
	movdqa	%xmm3, %xmm2
	pcmpgtd	%xmm1, %xmm2
	pand	%xmm2, %xmm1
	pandn	%xmm3, %xmm2
	por	%xmm1, %xmm2
	pcmpeqd	%xmm4, %xmm2
	psubd	%xmm2, %xmm0
	cmpl	$5, %edx
	je	.L7
	movdqu	100(%rsp), %xmm2
	movdqu	104(%rsp), %xmm4
	movdqu	108(%rsp), %xmm5
	movdqa	%xmm2, %xmm1
	movdqa	%xmm4, %xmm3
	pcmpgtd	%xmm4, %xmm1
	movdqa	%xmm1, %xmm6
	pand	%xmm1, %xmm3
	pandn	%xmm2, %xmm6
	pand	%xmm1, %xmm2
	pandn	%xmm4, %xmm1
	por	%xmm3, %xmm6
	movdqa	%xmm5, %xmm3
	por	%xmm2, %xmm1
	pcmpgtd	%xmm6, %xmm3
	pand	%xmm3, %xmm5
	pandn	%xmm6, %xmm3
	por	%xmm5, %xmm3
	movdqa	%xmm3, %xmm2
	pcmpgtd	%xmm1, %xmm2
	pand	%xmm2, %xmm1
	pandn	%xmm3, %xmm2
	por	%xmm1, %xmm2
	pcmpeqd	%xmm4, %xmm2
	psubd	%xmm2, %xmm0
.L7:
	movdqa	%xmm0, %xmm1
	movl	%ecx, %edi
	psrldq	$8, %xmm1
	andl	$-4, %edi
	paddd	%xmm1, %xmm0
	leal	2(%rdi), %esi
	movdqa	%xmm0, %xmm1
	psrldq	$4, %xmm1
	paddd	%xmm1, %xmm0
	movd	%xmm0, %edx
	cmpl	%edi, %ecx
	je	.L4
.L6:
	movslq	%esi, %r8
	leaq	16(%rsp), %r9
	leal	-1(%rax), %r11d
	leaq	0(,%r8,4), %rcx
	leal	1(%rsi), %r10d
	leaq	12(%rsp,%rcx), %rdi
	addq	%r9, %rcx
	cmpl	%r10d, %r11d
	jle	.L9
	cmpl	%esi, %eax
	jle	.L9
	movl	(%rdi), %r8d
	movl	(%rcx), %ecx
	leal	2(%rsi), %edi
	movslq	%edi, %rdi
.L12:
	movl	%r8d, %esi
	movl	%ecx, %r10d
	movl	-4(%r9,%rdi,4), %r8d
	cmpl	%ecx, %esi
	jge	.L56
.L10:
	cmpl	%esi, %r8d
	cmovge	%r8d, %esi
	cmpl	%r10d, %esi
	cmovg	%r10d, %esi
	cmpl	%ecx, %esi
	je	.L57
.L21:
	movl	(%r9,%rdi,4), %r10d
	movl	%edi, %esi
	movl	%r8d, %ebx
	cmpl	%ecx, %r8d
	jle	.L58
.L19:
	cmpl	%ecx, %r10d
	cmovge	%r10d, %ecx
	cmpl	%ebx, %ecx
	cmovg	%ebx, %ecx
	cmpl	%ecx, %r8d
	je	.L59
.L11:
	addq	$2, %rdi
	leal	-1(%rdi), %ecx
	cmpl	%ecx, %r11d
	jg	.L27
	movslq	%esi, %r8
	leal	1(%rsi), %r10d
.L9:
	leal	-1(%rsi), %ecx
	movslq	%ecx, %rcx
	movl	16(%rsp,%rcx,4), %edi
	movl	16(%rsp,%r8,4), %ecx
	movslq	%r10d, %r8
	movl	16(%rsp,%r8,4), %r8d
	movl	%ecx, %r9d
	cmpl	%ecx, %edi
	jge	.L60
.L13:
	cmpl	%edi, %r8d
	cmovge	%r8d, %edi
	cmpl	%r9d, %edi
	cmovg	%r9d, %edi
	cmpl	%edi, %ecx
	jne	.L14
	addl	$1, %edx
.L14:
	cmpl	%r10d, %eax
	jle	.L4
	leal	2(%rsi), %r10d
	movl	%r8d, %r9d
	movslq	%r10d, %rdi
	movl	16(%rsp,%rdi,4), %edi
	cmpl	%r8d, %ecx
	jge	.L61
.L15:
	cmpl	%ecx, %edi
	cmovge	%edi, %ecx
	cmpl	%r9d, %ecx
	cmovg	%r9d, %ecx
	cmpl	%ecx, %r8d
	jne	.L16
	addl	$1, %edx
.L16:
	cmpl	%r10d, %eax
	jle	.L4
	addl	$3, %esi
	movl	%edi, %ecx
	movslq	%esi, %rsi
	movl	16(%rsp,%rsi,4), %eax
	cmpl	%edi, %r8d
	jge	.L62
.L17:
	cmpl	%r8d, %eax
	cmovl	%r8d, %eax
	cmpl	%ecx, %eax
	cmovg	%ecx, %eax
	cmpl	%edi, %eax
	je	.L63
.L4:
	xorl	%eax, %eax
	leaq	.LC2(%rip), %rsi
	movl	$1, %edi
	call	__printf_chk@PLT
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L64
	addq	$144, %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
.L27:
	.cfi_restore_state
	movl	%r10d, %ecx
	jmp	.L12
.L58:
	movl	%ecx, %ebx
	movl	%r8d, %ecx
	jmp	.L19
.L56:
	movl	%esi, %r10d
	movl	%ecx, %esi
	jmp	.L10
.L57:
	addl	$1, %edx
	jmp	.L21
.L59:
	addl	$1, %edx
	jmp	.L11
.L60:
	movl	%edi, %r9d
	movl	%ecx, %edi
	jmp	.L13
.L61:
	movl	%ecx, %r9d
	movl	%r8d, %ecx
	jmp	.L15
.L62:
	movl	%r8d, %ecx
	movl	%edi, %r8d
	jmp	.L17
.L63:
	addl	$1, %edx
	jmp	.L4
.L24:
	xorl	%edx, %edx
	jmp	.L4
.L25:
	movl	$2, %esi
	xorl	%edx, %edx
	jmp	.L6
.L64:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE24:
	.size	main, .-main
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC1:
	.long	1
	.long	1
	.long	1
	.long	1
	.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 swap(int *a,int *b){
  *a^=*b;
  *b^=*a;
  *a^=*b;
  return;
}

int main(){
  int n,p[30];
  int A,B,C,T,S=0;
  scanf("%d",&n);
  for(int i=1;i<=n;i++)
    scanf("%d",p+i);
  for(int i=2;i<n;i++){
    A=p[i-1];
    B=p[i];
    C=p[i+1];
    T=B;
    if(A<B) swap(&A,&B);
    if(B<C) swap(&B,&C);
    if(A<B) swap(&A,&B);
    if(T==B) S++;
  }
  printf("%d\n",S);
  return 0;
}
9
9 6 3 2 5 14 7 4 1
 5
2 3 5 4 2
 9
14 17 3 4 5 25 7 4 0
 5
2 1 5 4 2
 9
14 12 3 2 9 14 1 4 0
 5
2 6 4 8 3
 9
14 6 3 2 5 14 7 4 1
 9
14 6 3 2 5 14 7 4 0
 9
14 12 3 2 5 14 7 4 0
 9
14 12 3 2 5 14 7 4 -1

5
 2
 4
 1
 3
 0
 5
 5
 5
 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>

void swap(int *a,int *b){
  *a^=*b;
  *b^=*a;
  *a^=*b;
  return;
}

int main(){
  int n,p[30];
  int A,B,C,T,S=0;
  scanf("%d",&n);
  for(int i=1;i<=n;i++)
    scanf("%d",p+i);
  for(int i=2;i<n;i++){
    A=p[i-1];
    B=p[i];
    C=p[i+1];
    T=B;
    if(A<B) swap(&A,&B);
    if(B<C) swap(&B,&C);
    if(A<B) swap(&A,&B);
    if(T==B) S++;
  }
  printf("%d\n",S);
  return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	swap
	.type	swap, @function
swap:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -8(%rbp)
	movq	%rsi, -16(%rbp)
	movq	-8(%rbp), %rax
	movl	(%rax), %edx
	movq	-16(%rbp), %rax
	movl	(%rax), %eax
	xorl	%eax, %edx
	movq	-8(%rbp), %rax
	movl	%edx, (%rax)
	movq	-16(%rbp), %rax
	movl	(%rax), %edx
	movq	-8(%rbp), %rax
	movl	(%rax), %eax
	xorl	%eax, %edx
	movq	-16(%rbp), %rax
	movl	%edx, (%rax)
	movq	-8(%rbp), %rax
	movl	(%rax), %edx
	movq	-16(%rbp), %rax
	movl	(%rax), %eax
	xorl	%eax, %edx
	movq	-8(%rbp), %rax
	movl	%edx, (%rax)
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	swap, .-swap
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$160, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -144(%rbp)
	leaq	-160(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$1, -140(%rbp)
	jmp	.L4
.L5:
	movl	-140(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	-128(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -140(%rbp)
.L4:
	movl	-160(%rbp), %eax
	cmpl	%eax, -140(%rbp)
	jle	.L5
	movl	$2, -136(%rbp)
	jmp	.L6
.L11:
	movl	-136(%rbp), %eax
	subl	$1, %eax
	cltq
	movl	-128(%rbp,%rax,4), %eax
	movl	%eax, -156(%rbp)
	movl	-136(%rbp), %eax
	cltq
	movl	-128(%rbp,%rax,4), %eax
	movl	%eax, -152(%rbp)
	movl	-136(%rbp), %eax
	addl	$1, %eax
	cltq
	movl	-128(%rbp,%rax,4), %eax
	movl	%eax, -148(%rbp)
	movl	-152(%rbp), %eax
	movl	%eax, -132(%rbp)
	movl	-156(%rbp), %edx
	movl	-152(%rbp), %eax
	cmpl	%eax, %edx
	jge	.L7
	leaq	-152(%rbp), %rdx
	leaq	-156(%rbp), %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	swap
.L7:
	movl	-152(%rbp), %edx
	movl	-148(%rbp), %eax
	cmpl	%eax, %edx
	jge	.L8
	leaq	-148(%rbp), %rdx
	leaq	-152(%rbp), %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	swap
.L8:
	movl	-156(%rbp), %edx
	movl	-152(%rbp), %eax
	cmpl	%eax, %edx
	jge	.L9
	leaq	-152(%rbp), %rdx
	leaq	-156(%rbp), %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	swap
.L9:
	movl	-152(%rbp), %eax
	cmpl	%eax, -132(%rbp)
	jne	.L10
	addl	$1, -144(%rbp)
.L10:
	addl	$1, -136(%rbp)
.L6:
	movl	-160(%rbp), %eax
	cmpl	%eax, -136(%rbp)
	jl	.L11
	movl	-144(%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	.L13
	call	__stack_chk_fail@PLT
.L13:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.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
	.globl	swap
	.type	swap, @function
swap:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -8(%rbp)
	movq	%rsi, -16(%rbp)
	movq	-8(%rbp), %rax
	movl	(%rax), %edx
	movq	-16(%rbp), %rax
	movl	(%rax), %eax
	xorl	%eax, %edx
	movq	-8(%rbp), %rax
	movl	%edx, (%rax)
	movq	-16(%rbp), %rax
	movl	(%rax), %edx
	movq	-8(%rbp), %rax
	movl	(%rax), %eax
	xorl	%eax, %edx
	movq	-16(%rbp), %rax
	movl	%edx, (%rax)
	movq	-8(%rbp), %rax
	movl	(%rax), %edx
	movq	-16(%rbp), %rax
	movl	(%rax), %eax
	xorl	%eax, %edx
	movq	-8(%rbp), %rax
	movl	%edx, (%rax)
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	swap, .-swap
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$160, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -144(%rbp)
	leaq	-160(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$1, -140(%rbp)
	jmp	.L4
.L5:
	movl	-140(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	-128(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -140(%rbp)
.L4:
	movl	-160(%rbp), %eax
	cmpl	%eax, -140(%rbp)
	jle	.L5
	movl	$2, -136(%rbp)
	jmp	.L6
.L11:
	movl	-136(%rbp), %eax
	subl	$1, %eax
	cltq
	movl	-128(%rbp,%rax,4), %eax
	movl	%eax, -156(%rbp)
	movl	-136(%rbp), %eax
	cltq
	movl	-128(%rbp,%rax,4), %eax
	movl	%eax, -152(%rbp)
	movl	-136(%rbp), %eax
	addl	$1, %eax
	cltq
	movl	-128(%rbp,%rax,4), %eax
	movl	%eax, -148(%rbp)
	movl	-152(%rbp), %eax
	movl	%eax, -132(%rbp)
	movl	-156(%rbp), %edx
	movl	-152(%rbp), %eax
	cmpl	%eax, %edx
	jge	.L7
	leaq	-152(%rbp), %rdx
	leaq	-156(%rbp), %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	swap
.L7:
	movl	-152(%rbp), %edx
	movl	-148(%rbp), %eax
	cmpl	%eax, %edx
	jge	.L8
	leaq	-148(%rbp), %rdx
	leaq	-152(%rbp), %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	swap
.L8:
	movl	-156(%rbp), %edx
	movl	-152(%rbp), %eax
	cmpl	%eax, %edx
	jge	.L9
	leaq	-152(%rbp), %rdx
	leaq	-156(%rbp), %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	swap
.L9:
	movl	-152(%rbp), %eax
	cmpl	%eax, -132(%rbp)
	jne	.L10
	addl	$1, -144(%rbp)
.L10:
	addl	$1, -136(%rbp)
.L6:
	movl	-160(%rbp), %eax
	cmpl	%eax, -136(%rbp)
	jl	.L11
	movl	-144(%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	.L13
	call	__stack_chk_fail@PLT
.L13:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.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:
