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>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <limits.h>

int main(void) {
	int n;
	int p[100001];
	int cnt = 0;
	int temp;

	scanf("%d", &n);
	for (int i = 1; i <= n; i++) scanf("%d", &p[i]);

	for (int i = 1; i <= n; i++) {
		if (p[i] == i) {
			cnt++;
			if (i != n) {
				temp = p[i];
				p[i] = p[i + 1];
				p[i + 1] = temp;
			}
			else {
				temp = p[i];
				p[i] = p[1];
				p[1] = temp;
			}
		}
	}
	printf("%d", cnt);
	return 0;
}```

Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB51:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	leaq	-397312(%rsp), %r11
	.cfi_def_cfa 11, 397352
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	.cfi_def_cfa_register 7
	subq	$2728, %rsp
	.cfi_def_cfa_offset 400080
	leaq	.LC0(%rip), %r13
	movl	$1, %ebp
	movq	%r13, %rdi
	movq	%fs:40, %rax
	movq	%rax, 400024(%rsp)
	xorl	%eax, %eax
	leaq	12(%rsp), %rsi
	leaq	20(%rsp), %rbx
	movq	%rbx, %r12
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %eax
	testl	%eax, %eax
	jle	.L5
	.p2align 4,,10
	.p2align 3
.L4:
	movq	%r12, %rsi
	movq	%r13, %rdi
	xorl	%eax, %eax
	addl	$1, %ebp
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %edx
	addq	$4, %r12
	cmpl	%ebp, %edx
	jge	.L4
	testl	%edx, %edx
	jle	.L5
	leal	1(%rdx), %esi
	movl	$1, %eax
	xorl	%r8d, %r8d
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L6:
	addq	$1, %rax
	addq	$4, %rbx
	cmpq	%rsi, %rax
	je	.L3
.L8:
	cmpl	%eax, (%rbx)
	jne	.L6
	addl	$1, %r8d
	cmpl	%eax, %edx
	je	.L7
	movd	4(%rbx), %xmm0
	movd	%eax, %xmm1
	addq	$1, %rax
	addq	$4, %rbx
	punpckldq	%xmm1, %xmm0
	movq	%xmm0, -4(%rbx)
	cmpq	%rsi, %rax
	jne	.L8
.L3:
	xorl	%eax, %eax
	movl	%r8d, %edx
	movq	%r13, %rsi
	movl	$1, %edi
	call	__printf_chk@PLT
	movq	400024(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L16
	addq	$400040, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
.L7:
	.cfi_restore_state
	movl	20(%rsp), %ecx
	movl	%ecx, (%rbx)
	movl	%edx, 20(%rsp)
	jmp	.L6
.L5:
	xorl	%r8d, %r8d
	jmp	.L3
.L16:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE51:
	.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"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB51:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	leaq	-397312(%rsp), %r11
	.cfi_def_cfa 11, 397352
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	.cfi_def_cfa_register 7
	subq	$2728, %rsp
	.cfi_def_cfa_offset 400080
	leaq	.LC0(%rip), %r13
	movl	$1, %ebp
	movq	%r13, %rdi
	movq	%fs:40, %rax
	movq	%rax, 400024(%rsp)
	xorl	%eax, %eax
	leaq	12(%rsp), %rsi
	leaq	20(%rsp), %rbx
	movq	%rbx, %r12
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %eax
	testl	%eax, %eax
	jle	.L5
	.p2align 4,,10
	.p2align 3
.L4:
	movq	%r12, %rsi
	movq	%r13, %rdi
	xorl	%eax, %eax
	addl	$1, %ebp
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %edx
	addq	$4, %r12
	cmpl	%ebp, %edx
	jge	.L4
	testl	%edx, %edx
	jle	.L5
	leal	1(%rdx), %esi
	movl	$1, %eax
	xorl	%r8d, %r8d
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L6:
	addq	$1, %rax
	addq	$4, %rbx
	cmpq	%rsi, %rax
	je	.L3
.L8:
	cmpl	%eax, (%rbx)
	jne	.L6
	addl	$1, %r8d
	cmpl	%eax, %edx
	je	.L7
	movd	4(%rbx), %xmm0
	movd	%eax, %xmm1
	addq	$1, %rax
	addq	$4, %rbx
	punpckldq	%xmm1, %xmm0
	movq	%xmm0, -4(%rbx)
	cmpq	%rsi, %rax
	jne	.L8
.L3:
	xorl	%eax, %eax
	movl	%r8d, %edx
	movq	%r13, %rsi
	movl	$1, %edi
	call	__printf_chk@PLT
	movq	400024(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L16
	addq	$400040, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
.L7:
	.cfi_restore_state
	movl	20(%rsp), %ecx
	movl	%ecx, (%rbx)
	movl	%edx, 20(%rsp)
	jmp	.L6
.L5:
	xorl	%r8d, %r8d
	jmp	.L3
.L16:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE51:
	.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"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB51:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	leaq	-397312(%rsp), %r11
	.cfi_def_cfa 11, 397352
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	.cfi_def_cfa_register 7
	subq	$2728, %rsp
	.cfi_def_cfa_offset 400080
	leaq	.LC0(%rip), %r13
	movl	$1, %ebp
	movq	%r13, %rdi
	movq	%fs:40, %rax
	movq	%rax, 400024(%rsp)
	xorl	%eax, %eax
	leaq	12(%rsp), %rsi
	leaq	20(%rsp), %rbx
	movq	%rbx, %r12
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %eax
	testl	%eax, %eax
	jle	.L5
	.p2align 4,,10
	.p2align 3
.L4:
	movq	%r12, %rsi
	movq	%r13, %rdi
	xorl	%eax, %eax
	addl	$1, %ebp
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %edx
	addq	$4, %r12
	cmpl	%ebp, %edx
	jge	.L4
	testl	%edx, %edx
	jle	.L5
	leal	1(%rdx), %esi
	movl	$1, %eax
	xorl	%r8d, %r8d
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L6:
	addq	$1, %rax
	addq	$4, %rbx
	cmpq	%rsi, %rax
	je	.L3
.L8:
	cmpl	%eax, (%rbx)
	jne	.L6
	addl	$1, %r8d
	cmpl	%eax, %edx
	je	.L7
	movd	4(%rbx), %xmm0
	movd	%eax, %xmm1
	addq	$1, %rax
	addq	$4, %rbx
	punpckldq	%xmm1, %xmm0
	movq	%xmm0, -4(%rbx)
	cmpq	%rsi, %rax
	jne	.L8
.L3:
	xorl	%eax, %eax
	movl	%r8d, %edx
	movq	%r13, %rsi
	movl	$1, %edi
	call	__printf_chk@PLT
	movq	400024(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L16
	addq	$400040, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
.L7:
	.cfi_restore_state
	movl	20(%rsp), %ecx
	movl	%ecx, (%rbx)
	movl	%edx, 20(%rsp)
	jmp	.L6
.L5:
	xorl	%r8d, %r8d
	jmp	.L3
.L16:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE51:
	.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>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <limits.h>

int main(void) {
	int n;
	int p[100001];
	int cnt = 0;
	int temp;

	scanf("%d", &n);
	for (int i = 1; i <= n; i++) scanf("%d", &p[i]);

	for (int i = 1; i <= n; i++) {
		if (p[i] == i) {
			cnt++;
			if (i != n) {
				temp = p[i];
				p[i] = p[i + 1];
				p[i + 1] = temp;
			}
			else {
				temp = p[i];
				p[i] = p[1];
				p[1] = temp;
			}
		}
	}
	printf("%d", cnt);
	return 0;
}```
Given the following C code, your task is to generate highly optimized x86-64 assembly code.
C Code:

```c
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <limits.h>

int main(void) {
	int n;
	int p[100001];
	int cnt = 0;
	int temp;

	scanf("%d", &n);
	for (int i = 1; i <= n; i++) scanf("%d", &p[i]);

	for (int i = 1; i <= n; i++) {
		if (p[i] == i) {
			cnt++;
			if (i != n) {
				temp = p[i];
				p[i] = p[i + 1];
				p[i + 1] = temp;
			}
			else {
				temp = p[i];
				p[i] = p[1];
				p[1] = temp;
			}
		}
	}
	printf("%d", cnt);
	return 0;
}```

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 4 4 5 2
 9
1 2 4 9 5 8 7 6 6
 9
1 2 4 9 5 8 4 6 6
 5
0 4 4 5 1
 2
1 0
 2
1 1
 5
1 4 4 5 1
 2
1 -1
 2
0 2
 9
2 2 4 9 5 8 4 6 6

1 3 2 0 1 1 1 1 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>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <limits.h>

int main(void) {
	int n;
	int p[100001];
	int cnt = 0;
	int temp;

	scanf("%d", &n);
	for (int i = 1; i <= n; i++) scanf("%d", &p[i]);

	for (int i = 1; i <= n; i++) {
		if (p[i] == i) {
			cnt++;
			if (i != n) {
				temp = p[i];
				p[i] = p[i + 1];
				p[i + 1] = temp;
			}
			else {
				temp = p[i];
				p[i] = p[1];
				p[1] = temp;
			}
		}
	}
	printf("%d", cnt);
	return 0;
}```

Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB51:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	leaq	-397312(%rsp), %r11
	.cfi_def_cfa 11, 397352
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	.cfi_def_cfa_register 7
	subq	$2728, %rsp
	.cfi_def_cfa_offset 400080
	leaq	.LC0(%rip), %r13
	movl	$1, %ebp
	movq	%r13, %rdi
	movq	%fs:40, %rax
	movq	%rax, 400024(%rsp)
	xorl	%eax, %eax
	leaq	12(%rsp), %rsi
	leaq	20(%rsp), %rbx
	movq	%rbx, %r12
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %eax
	testl	%eax, %eax
	jle	.L5
	.p2align 4,,10
	.p2align 3
.L4:
	movq	%r12, %rsi
	movq	%r13, %rdi
	xorl	%eax, %eax
	addl	$1, %ebp
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %edx
	addq	$4, %r12
	cmpl	%ebp, %edx
	jge	.L4
	testl	%edx, %edx
	jle	.L5
	leal	1(%rdx), %esi
	movl	$1, %eax
	xorl	%r8d, %r8d
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L6:
	addq	$1, %rax
	addq	$4, %rbx
	cmpq	%rsi, %rax
	je	.L3
.L8:
	cmpl	%eax, (%rbx)
	jne	.L6
	addl	$1, %r8d
	cmpl	%eax, %edx
	je	.L7
	movd	4(%rbx), %xmm0
	movd	%eax, %xmm1
	addq	$1, %rax
	addq	$4, %rbx
	punpckldq	%xmm1, %xmm0
	movq	%xmm0, -4(%rbx)
	cmpq	%rsi, %rax
	jne	.L8
.L3:
	xorl	%eax, %eax
	movl	%r8d, %edx
	movq	%r13, %rsi
	movl	$1, %edi
	call	__printf_chk@PLT
	movq	400024(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L16
	addq	$400040, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
.L7:
	.cfi_restore_state
	movl	20(%rsp), %ecx
	movl	%ecx, (%rbx)
	movl	%edx, 20(%rsp)
	jmp	.L6
.L5:
	xorl	%r8d, %r8d
	jmp	.L3
.L16:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE51:
	.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"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB51:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	leaq	-397312(%rsp), %r11
	.cfi_def_cfa 11, 397352
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	.cfi_def_cfa_register 7
	subq	$2728, %rsp
	.cfi_def_cfa_offset 400080
	leaq	.LC0(%rip), %r13
	movl	$1, %ebp
	movq	%r13, %rdi
	movq	%fs:40, %rax
	movq	%rax, 400024(%rsp)
	xorl	%eax, %eax
	leaq	12(%rsp), %rsi
	leaq	20(%rsp), %rbx
	movq	%rbx, %r12
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %eax
	testl	%eax, %eax
	jle	.L5
	.p2align 4,,10
	.p2align 3
.L4:
	movq	%r12, %rsi
	movq	%r13, %rdi
	xorl	%eax, %eax
	addl	$1, %ebp
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %edx
	addq	$4, %r12
	cmpl	%ebp, %edx
	jge	.L4
	testl	%edx, %edx
	jle	.L5
	leal	1(%rdx), %esi
	movl	$1, %eax
	xorl	%r8d, %r8d
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L6:
	addq	$1, %rax
	addq	$4, %rbx
	cmpq	%rsi, %rax
	je	.L3
.L8:
	cmpl	%eax, (%rbx)
	jne	.L6
	addl	$1, %r8d
	cmpl	%eax, %edx
	je	.L7
	movd	4(%rbx), %xmm0
	movd	%eax, %xmm1
	addq	$1, %rax
	addq	$4, %rbx
	punpckldq	%xmm1, %xmm0
	movq	%xmm0, -4(%rbx)
	cmpq	%rsi, %rax
	jne	.L8
.L3:
	xorl	%eax, %eax
	movl	%r8d, %edx
	movq	%r13, %rsi
	movl	$1, %edi
	call	__printf_chk@PLT
	movq	400024(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L16
	addq	$400040, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
.L7:
	.cfi_restore_state
	movl	20(%rsp), %ecx
	movl	%ecx, (%rbx)
	movl	%edx, 20(%rsp)
	jmp	.L6
.L5:
	xorl	%r8d, %r8d
	jmp	.L3
.L16:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE51:
	.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:
```