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 a[100001],p[100001];

int dfs(int x){
  if(a[x]==x)
    return x;
  else 
    a[x]=dfs(a[x]);
  return a[x];
}

int main(){
  int i,n,m,x,y,cnt=0,l,r;
  scanf("%d %d",&n,&m);
  for(i=0;i<=n;i++)
    a[i]=i;
  p[0]=0;
  for(i=0;i<n;i++)
    scanf("%d",&p[i+1]);
  for(i=0;i<m;i++){
    scanf("%d %d",&x,&y);
    if(x>y)
      a[dfs(x)]=a[dfs(y)];
    else
      a[dfs(y)]=a[dfs(x)];
  }
  for(i=1;i<=n;i++){
    x=dfs(i);
    y=dfs(p[i]);
    if(x==y)
      cnt++;
  }
  printf("%d\n",cnt);
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	a
	.bss
	.align 32
	.type	a, @object
	.size	a, 400004
a:
	.zero	400004
	.globl	p
	.align 32
	.type	p, @object
	.size	p, 400004
p:
	.zero	400004
	.text
	.globl	dfs
	.type	dfs, @function
dfs:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$16, %rsp
	movl	%edi, -4(%rbp)
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -4(%rbp)
	jne	.L2
	movl	-4(%rbp), %eax
	jmp	.L3
.L2:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, %edi
	call	dfs
	movl	-4(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	a(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %eax
.L3:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	dfs, .-dfs
	.section	.rodata
.LC0:
	.string	"%d %d"
.LC1:
	.string	"%d"
.LC2:
	.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
	pushq	%rbx
	subq	$40, %rsp
	.cfi_offset 3, -24
	movq	%fs:40, %rax
	movq	%rax, -24(%rbp)
	xorl	%eax, %eax
	movl	$0, -28(%rbp)
	leaq	-44(%rbp), %rdx
	leaq	-48(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -32(%rbp)
	jmp	.L5
.L6:
	movl	-32(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	a(%rip), %rdx
	movl	-32(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	addl	$1, -32(%rbp)
.L5:
	movl	-48(%rbp), %eax
	cmpl	%eax, -32(%rbp)
	jle	.L6
	movl	$0, p(%rip)
	movl	$0, -32(%rbp)
	jmp	.L7
.L8:
	movl	-32(%rbp), %eax
	addl	$1, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	p(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -32(%rbp)
.L7:
	movl	-48(%rbp), %eax
	cmpl	%eax, -32(%rbp)
	jl	.L8
	movl	$0, -32(%rbp)
	jmp	.L9
.L12:
	leaq	-36(%rbp), %rdx
	leaq	-40(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-40(%rbp), %edx
	movl	-36(%rbp), %eax
	cmpl	%eax, %edx
	jle	.L10
	movl	-36(%rbp), %eax
	movl	%eax, %edi
	call	dfs
	movl	%eax, %ebx
	movl	-40(%rbp), %eax
	movl	%eax, %edi
	call	dfs
	movl	%eax, %edx
	movslq	%ebx, %rax
	leaq	0(,%rax,4), %rcx
	leaq	a(%rip), %rax
	movl	(%rcx,%rax), %eax
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	a(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	jmp	.L11
.L10:
	movl	-40(%rbp), %eax
	movl	%eax, %edi
	call	dfs
	movl	%eax, %ebx
	movl	-36(%rbp), %eax
	movl	%eax, %edi
	call	dfs
	movl	%eax, %edx
	movslq	%ebx, %rax
	leaq	0(,%rax,4), %rcx
	leaq	a(%rip), %rax
	movl	(%rcx,%rax), %eax
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	a(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
.L11:
	addl	$1, -32(%rbp)
.L9:
	movl	-44(%rbp), %eax
	cmpl	%eax, -32(%rbp)
	jl	.L12
	movl	$1, -32(%rbp)
	jmp	.L13
.L15:
	movl	-32(%rbp), %eax
	movl	%eax, %edi
	call	dfs
	movl	%eax, -40(%rbp)
	movl	-32(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	p(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, %edi
	call	dfs
	movl	%eax, -36(%rbp)
	movl	-40(%rbp), %edx
	movl	-36(%rbp), %eax
	cmpl	%eax, %edx
	jne	.L14
	addl	$1, -28(%rbp)
.L14:
	addl	$1, -32(%rbp)
.L13:
	movl	-48(%rbp), %eax
	cmpl	%eax, -32(%rbp)
	jle	.L15
	movl	-28(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-24(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L17
	call	__stack_chk_fail@PLT
.L17:
	movq	-8(%rbp), %rbx
	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	dfs
	.type	dfs, @function
dfs:
.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
	movslq	%edi, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	leaq	a(%rip), %rbx
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
	movl	(%rbx,%rbp,4), %edx
	movl	%edx, %eax
	cmpl	%edi, %edx
	je	.L1
	movslq	%edx, %r12
	movl	(%rbx,%r12,4), %eax
	cmpl	%eax, %edx
	je	.L3
	movslq	%eax, %r13
	movl	(%rbx,%r13,4), %edx
	cmpl	%edx, %eax
	je	.L4
	movslq	%edx, %r14
	movl	(%rbx,%r14,4), %eax
	cmpl	%eax, %edx
	je	.L5
	movslq	%eax, %r15
	movl	(%rbx,%r15,4), %edx
	cmpl	%edx, %eax
	je	.L6
	movslq	%edx, %rcx
	movl	(%rbx,%rcx,4), %eax
	movq	%rcx, 8(%rsp)
	cmpl	%eax, %edx
	je	.L7
	movl	%eax, %edi
	call	dfs
	movq	8(%rsp), %rcx
	movl	%eax, (%rbx,%rcx,4)
.L7:
	movl	%eax, (%rbx,%r15,4)
.L6:
	movl	%eax, (%rbx,%r14,4)
.L5:
	movl	%eax, (%rbx,%r13,4)
.L4:
	movl	%eax, (%rbx,%r12,4)
.L3:
	movl	%eax, (%rbx,%rbp,4)
.L1:
	addq	$24, %rsp
	.cfi_def_cfa_offset 56
	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
	.cfi_endproc
.LFE23:
	.size	dfs, .-dfs
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC1:
	.string	"%d %d"
.LC3:
	.string	"%d"
.LC4:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB24:
	.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
	leaq	.LC1(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movq	%rbp, %rdi
	subq	$40, %rsp
	.cfi_def_cfa_offset 96
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	leaq	12(%rsp), %rdx
	leaq	8(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movl	8(%rsp), %ecx
	testl	%ecx, %ecx
	js	.L15
	leal	1(%rcx), %esi
	cmpl	$2, %ecx
	jle	.L66
	movl	%esi, %edx
	leaq	a(%rip), %rbx
	movdqa	.LC0(%rip), %xmm0
	movdqa	.LC2(%rip), %xmm2
	shrl	$2, %edx
	leaq	16(%rbx), %rdi
	movq	%rbx, %rax
	subl	$1, %edx
	salq	$4, %rdx
	addq	%rdi, %rdx
	.p2align 4,,10
	.p2align 3
.L17:
	movdqa	%xmm0, %xmm1
	addq	$16, %rax
	paddd	%xmm2, %xmm0
	movaps	%xmm1, -16(%rax)
	cmpq	%rdx, %rax
	jne	.L17
	movl	%esi, %eax
	andl	$-4, %eax
	andl	$3, %esi
	je	.L21
.L16:
	movslq	%eax, %rdx
	movl	%eax, (%rbx,%rdx,4)
	leal	1(%rax), %edx
	cmpl	%edx, %ecx
	jl	.L22
	movslq	%edx, %rsi
	addl	$2, %eax
	movl	%edx, (%rbx,%rsi,4)
	cmpl	%ecx, %eax
	jg	.L21
	movslq	%eax, %rdx
	movl	%eax, (%rbx,%rdx,4)
.L21:
	movl	$0, p(%rip)
.L19:
	leaq	4+p(%rip), %r13
	xorl	%r12d, %r12d
	leaq	.LC3(%rip), %r14
	.p2align 4,,10
	.p2align 3
.L23:
	movq	%r13, %rsi
	movq	%r14, %rdi
	xorl	%eax, %eax
	addl	$1, %r12d
	call	__isoc99_scanf@PLT
	addq	$4, %r13
	cmpl	8(%rsp), %r12d
	jl	.L23
	movl	12(%rsp), %edx
	testl	%edx, %edx
	jle	.L50
.L24:
	xorl	%r14d, %r14d
	leaq	20(%rsp), %r13
	leaq	16(%rsp), %r12
	.p2align 4,,10
	.p2align 3
.L49:
	movq	%r13, %rdx
	movq	%r12, %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	16(%rsp), %edx
	movl	20(%rsp), %eax
	cmpl	%eax, %edx
	jle	.L27
	movslq	%eax, %rsi
	movslq	(%rbx,%rsi,4), %r8
	movq	%r8, %rdi
	cmpl	%r8d, %eax
	je	.L28
	movl	(%rbx,%r8,4), %eax
	cmpl	%eax, %r8d
	je	.L29
	movslq	%eax, %r9
	movl	%eax, %edi
	movl	(%rbx,%r9,4), %ecx
	cmpl	%ecx, %eax
	je	.L30
	movslq	%ecx, %r10
	movl	%ecx, %edi
	movl	(%rbx,%r10,4), %eax
	cmpl	%eax, %ecx
	je	.L31
	movslq	%eax, %r11
	movl	(%rbx,%r11,4), %edi
	cmpl	%edi, %eax
	je	.L32
	call	dfs
	movl	16(%rsp), %edx
	movl	%eax, (%rbx,%r11,4)
	movl	%eax, %edi
.L32:
	movl	%edi, (%rbx,%r10,4)
.L31:
	movl	%edi, (%rbx,%r9,4)
.L30:
	movl	%edi, (%rbx,%r8,4)
	movslq	%edi, %r8
.L29:
	movl	%edi, (%rbx,%rsi,4)
.L28:
	movslq	%edx, %rsi
	movl	(%rbx,%rsi,4), %eax
	cmpl	%edx, %eax
	je	.L44
	movslq	%eax, %r9
	movl	(%rbx,%r9,4), %edi
	cmpl	%edi, %eax
	je	.L45
.L97:
	movslq	%edi, %r10
	movl	(%rbx,%r10,4), %eax
	cmpl	%eax, %edi
	je	.L46
	movslq	%eax, %r11
	movl	%eax, %edi
	movl	(%rbx,%r11,4), %edx
	cmpl	%edx, %eax
	je	.L47
	movslq	%edx, %r15
	movl	(%rbx,%r15,4), %edi
	cmpl	%edi, %edx
	je	.L48
	call	dfs
	movl	%eax, (%rbx,%r15,4)
	movl	%eax, %edi
.L48:
	movl	%edi, (%rbx,%r11,4)
.L47:
	movl	%edi, (%rbx,%r10,4)
.L46:
	movl	%edi, (%rbx,%r9,4)
.L45:
	movl	%edi, (%rbx,%rsi,4)
	movslq	%edi, %rsi
.L44:
	movl	(%rbx,%r8,4), %eax
	addl	$1, %r14d
	movl	%eax, (%rbx,%rsi,4)
	cmpl	%r14d, 12(%rsp)
	jg	.L49
.L50:
	movl	8(%rsp), %eax
	movl	$1, %esi
	xorl	%r8d, %r8d
	leaq	p(%rip), %r9
	testl	%eax, %eax
	jle	.L26
	.p2align 4,,10
	.p2align 3
.L25:
	movl	(%rbx,%rsi,4), %edx
	movl	%esi, %eax
	cmpl	%esi, %edx
	je	.L52
	movslq	%edx, %r10
	movl	(%rbx,%r10,4), %eax
	cmpl	%eax, %edx
	je	.L53
	movslq	%eax, %r11
	movl	(%rbx,%r11,4), %edx
	cmpl	%edx, %eax
	je	.L54
	movslq	%edx, %rbp
	movl	(%rbx,%rbp,4), %eax
	cmpl	%eax, %edx
	je	.L55
	movslq	%eax, %r12
	movl	(%rbx,%r12,4), %edx
	cmpl	%edx, %eax
	je	.L56
	movslq	%edx, %r13
	movl	(%rbx,%r13,4), %eax
	cmpl	%eax, %edx
	je	.L57
	movl	%eax, %edi
	call	dfs
	movl	%eax, (%rbx,%r13,4)
.L57:
	movl	%eax, (%rbx,%r12,4)
.L56:
	movl	%eax, (%rbx,%rbp,4)
.L55:
	movl	%eax, (%rbx,%r11,4)
.L54:
	movl	%eax, (%rbx,%r10,4)
.L53:
	movl	%eax, (%rbx,%rsi,4)
.L52:
	movslq	(%r9,%rsi,4), %r10
	movl	%eax, 16(%rsp)
	movl	(%rbx,%r10,4), %edi
	cmpl	%edi, %r10d
	je	.L58
	movslq	%edi, %r11
	movl	(%rbx,%r11,4), %edx
	cmpl	%edx, %edi
	je	.L59
	movslq	%edx, %rbp
	movl	(%rbx,%rbp,4), %edi
	cmpl	%edi, %edx
	je	.L60
	movslq	%edi, %r12
	movl	(%rbx,%r12,4), %edx
	cmpl	%edx, %edi
	je	.L61
	movslq	%edx, %r13
	movl	%edx, %edi
	movl	(%rbx,%r13,4), %eax
	cmpl	%eax, %edx
	je	.L62
	movslq	%eax, %r14
	movl	(%rbx,%r14,4), %edi
	cmpl	%edi, %eax
	je	.L63
	call	dfs
	movl	%eax, (%rbx,%r14,4)
	movl	%eax, %edi
.L63:
	movl	%edi, (%rbx,%r13,4)
.L62:
	movl	%edi, (%rbx,%r12,4)
	movl	16(%rsp), %eax
.L61:
	movl	%edi, (%rbx,%rbp,4)
.L60:
	movl	%edi, (%rbx,%r11,4)
.L59:
	movl	%edi, (%rbx,%r10,4)
.L58:
	cmpl	%eax, %edi
	movl	%edi, 20(%rsp)
	sete	%al
	addq	$1, %rsi
	movzbl	%al, %eax
	addl	%eax, %r8d
	cmpl	%esi, 8(%rsp)
	jge	.L25
.L51:
	xorl	%eax, %eax
	movl	%r8d, %edx
	movl	$1, %edi
	leaq	.LC4(%rip), %rsi
	call	__printf_chk@PLT
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L98
	addq	$40, %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
	.p2align 4,,10
	.p2align 3
.L27:
	.cfi_restore_state
	movslq	%edx, %rsi
	movslq	(%rbx,%rsi,4), %r8
	movq	%r8, %rdi
	cmpl	%r8d, %edx
	je	.L39
	movl	(%rbx,%r8,4), %edx
	cmpl	%edx, %r8d
	je	.L40
	movslq	%edx, %r9
	movl	%edx, %edi
	movl	(%rbx,%r9,4), %ecx
	cmpl	%ecx, %edx
	je	.L41
	movslq	%ecx, %r10
	movl	%ecx, %edi
	movl	(%rbx,%r10,4), %edx
	cmpl	%edx, %ecx
	je	.L42
	movslq	%edx, %r11
	movl	(%rbx,%r11,4), %edi
	cmpl	%edi, %edx
	je	.L43
	call	dfs
	movl	%eax, (%rbx,%r11,4)
	movl	%eax, %edi
	movl	20(%rsp), %eax
.L43:
	movl	%edi, (%rbx,%r10,4)
.L42:
	movl	%edi, (%rbx,%r9,4)
.L41:
	movl	%edi, (%rbx,%r8,4)
	movslq	%edi, %r8
.L40:
	movl	%edi, (%rbx,%rsi,4)
.L39:
	movslq	%eax, %rsi
	movl	(%rbx,%rsi,4), %edx
	cmpl	%eax, %edx
	je	.L44
	movslq	%edx, %r9
	movl	(%rbx,%r9,4), %edi
	cmpl	%edi, %edx
	jne	.L97
	jmp	.L45
.L15:
	movl	$0, p(%rip)
.L20:
	cmpl	$0, 12(%rsp)
	leaq	a(%rip), %rbx
	jg	.L24
.L26:
	xorl	%r8d, %r8d
	jmp	.L51
.L66:
	xorl	%eax, %eax
	leaq	a(%rip), %rbx
	jmp	.L16
.L22:
	movl	$0, p(%rip)
	testl	%ecx, %ecx
	jg	.L19
	jmp	.L20
.L98:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE24:
	.size	main, .-main
	.globl	p
	.bss
	.align 32
	.type	p, @object
	.size	p, 400004
p:
	.zero	400004
	.globl	a
	.align 32
	.type	a, @object
	.size	a, 400004
a:
	.zero	400004
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC0:
	.long	0
	.long	1
	.long	2
	.long	3
	.align 16
.LC2:
	.long	4
	.long	4
	.long	4
	.long	4
	.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	dfs
	.type	dfs, @function
dfs:
.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
	movslq	%edi, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	leaq	a(%rip), %rbx
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
	movl	(%rbx,%rbp,4), %edx
	movl	%edx, %eax
	cmpl	%edi, %edx
	je	.L1
	movslq	%edx, %r12
	movl	(%rbx,%r12,4), %eax
	cmpl	%eax, %edx
	je	.L3
	movslq	%eax, %r13
	movl	(%rbx,%r13,4), %edx
	cmpl	%edx, %eax
	je	.L4
	movslq	%edx, %r14
	movl	(%rbx,%r14,4), %eax
	cmpl	%eax, %edx
	je	.L5
	movslq	%eax, %r15
	movl	(%rbx,%r15,4), %edx
	cmpl	%edx, %eax
	je	.L6
	movslq	%edx, %rcx
	movl	(%rbx,%rcx,4), %eax
	movq	%rcx, 8(%rsp)
	cmpl	%eax, %edx
	je	.L7
	movl	%eax, %edi
	call	dfs
	movq	8(%rsp), %rcx
	movl	%eax, (%rbx,%rcx,4)
.L7:
	movl	%eax, (%rbx,%r15,4)
.L6:
	movl	%eax, (%rbx,%r14,4)
.L5:
	movl	%eax, (%rbx,%r13,4)
.L4:
	movl	%eax, (%rbx,%r12,4)
.L3:
	movl	%eax, (%rbx,%rbp,4)
.L1:
	addq	$24, %rsp
	.cfi_def_cfa_offset 56
	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
	.cfi_endproc
.LFE23:
	.size	dfs, .-dfs
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC1:
	.string	"%d %d"
.LC3:
	.string	"%d"
.LC4:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB24:
	.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
	leaq	.LC1(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movq	%rbp, %rdi
	subq	$40, %rsp
	.cfi_def_cfa_offset 96
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	leaq	12(%rsp), %rdx
	leaq	8(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movl	8(%rsp), %ecx
	testl	%ecx, %ecx
	js	.L15
	leal	1(%rcx), %esi
	cmpl	$2, %ecx
	jle	.L66
	movl	%esi, %edx
	leaq	a(%rip), %rbx
	movdqa	.LC0(%rip), %xmm0
	movdqa	.LC2(%rip), %xmm2
	shrl	$2, %edx
	leaq	16(%rbx), %rdi
	movq	%rbx, %rax
	subl	$1, %edx
	salq	$4, %rdx
	addq	%rdi, %rdx
	.p2align 4,,10
	.p2align 3
.L17:
	movdqa	%xmm0, %xmm1
	addq	$16, %rax
	paddd	%xmm2, %xmm0
	movaps	%xmm1, -16(%rax)
	cmpq	%rdx, %rax
	jne	.L17
	movl	%esi, %eax
	andl	$-4, %eax
	andl	$3, %esi
	je	.L21
.L16:
	movslq	%eax, %rdx
	movl	%eax, (%rbx,%rdx,4)
	leal	1(%rax), %edx
	cmpl	%edx, %ecx
	jl	.L22
	movslq	%edx, %rsi
	addl	$2, %eax
	movl	%edx, (%rbx,%rsi,4)
	cmpl	%ecx, %eax
	jg	.L21
	movslq	%eax, %rdx
	movl	%eax, (%rbx,%rdx,4)
.L21:
	movl	$0, p(%rip)
.L19:
	leaq	4+p(%rip), %r13
	xorl	%r12d, %r12d
	leaq	.LC3(%rip), %r14
	.p2align 4,,10
	.p2align 3
.L23:
	movq	%r13, %rsi
	movq	%r14, %rdi
	xorl	%eax, %eax
	addl	$1, %r12d
	call	__isoc99_scanf@PLT
	addq	$4, %r13
	cmpl	8(%rsp), %r12d
	jl	.L23
	movl	12(%rsp), %edx
	testl	%edx, %edx
	jle	.L50
.L24:
	xorl	%r14d, %r14d
	leaq	20(%rsp), %r13
	leaq	16(%rsp), %r12
	.p2align 4,,10
	.p2align 3
.L49:
	movq	%r13, %rdx
	movq	%r12, %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	16(%rsp), %edx
	movl	20(%rsp), %eax
	cmpl	%eax, %edx
	jle	.L27
	movslq	%eax, %rsi
	movslq	(%rbx,%rsi,4), %r8
	movq	%r8, %rdi
	cmpl	%r8d, %eax
	je	.L28
	movl	(%rbx,%r8,4), %eax
	cmpl	%eax, %r8d
	je	.L29
	movslq	%eax, %r9
	movl	%eax, %edi
	movl	(%rbx,%r9,4), %ecx
	cmpl	%ecx, %eax
	je	.L30
	movslq	%ecx, %r10
	movl	%ecx, %edi
	movl	(%rbx,%r10,4), %eax
	cmpl	%eax, %ecx
	je	.L31
	movslq	%eax, %r11
	movl	(%rbx,%r11,4), %edi
	cmpl	%edi, %eax
	je	.L32
	call	dfs
	movl	16(%rsp), %edx
	movl	%eax, (%rbx,%r11,4)
	movl	%eax, %edi
.L32:
	movl	%edi, (%rbx,%r10,4)
.L31:
	movl	%edi, (%rbx,%r9,4)
.L30:
	movl	%edi, (%rbx,%r8,4)
	movslq	%edi, %r8
.L29:
	movl	%edi, (%rbx,%rsi,4)
.L28:
	movslq	%edx, %rsi
	movl	(%rbx,%rsi,4), %eax
	cmpl	%edx, %eax
	je	.L44
	movslq	%eax, %r9
	movl	(%rbx,%r9,4), %edi
	cmpl	%edi, %eax
	je	.L45
.L97:
	movslq	%edi, %r10
	movl	(%rbx,%r10,4), %eax
	cmpl	%eax, %edi
	je	.L46
	movslq	%eax, %r11
	movl	%eax, %edi
	movl	(%rbx,%r11,4), %edx
	cmpl	%edx, %eax
	je	.L47
	movslq	%edx, %r15
	movl	(%rbx,%r15,4), %edi
	cmpl	%edi, %edx
	je	.L48
	call	dfs
	movl	%eax, (%rbx,%r15,4)
	movl	%eax, %edi
.L48:
	movl	%edi, (%rbx,%r11,4)
.L47:
	movl	%edi, (%rbx,%r10,4)
.L46:
	movl	%edi, (%rbx,%r9,4)
.L45:
	movl	%edi, (%rbx,%rsi,4)
	movslq	%edi, %rsi
.L44:
	movl	(%rbx,%r8,4), %eax
	addl	$1, %r14d
	movl	%eax, (%rbx,%rsi,4)
	cmpl	%r14d, 12(%rsp)
	jg	.L49
.L50:
	movl	8(%rsp), %eax
	movl	$1, %esi
	xorl	%r8d, %r8d
	leaq	p(%rip), %r9
	testl	%eax, %eax
	jle	.L26
	.p2align 4,,10
	.p2align 3
.L25:
	movl	(%rbx,%rsi,4), %edx
	movl	%esi, %eax
	cmpl	%esi, %edx
	je	.L52
	movslq	%edx, %r10
	movl	(%rbx,%r10,4), %eax
	cmpl	%eax, %edx
	je	.L53
	movslq	%eax, %r11
	movl	(%rbx,%r11,4), %edx
	cmpl	%edx, %eax
	je	.L54
	movslq	%edx, %rbp
	movl	(%rbx,%rbp,4), %eax
	cmpl	%eax, %edx
	je	.L55
	movslq	%eax, %r12
	movl	(%rbx,%r12,4), %edx
	cmpl	%edx, %eax
	je	.L56
	movslq	%edx, %r13
	movl	(%rbx,%r13,4), %eax
	cmpl	%eax, %edx
	je	.L57
	movl	%eax, %edi
	call	dfs
	movl	%eax, (%rbx,%r13,4)
.L57:
	movl	%eax, (%rbx,%r12,4)
.L56:
	movl	%eax, (%rbx,%rbp,4)
.L55:
	movl	%eax, (%rbx,%r11,4)
.L54:
	movl	%eax, (%rbx,%r10,4)
.L53:
	movl	%eax, (%rbx,%rsi,4)
.L52:
	movslq	(%r9,%rsi,4), %r10
	movl	%eax, 16(%rsp)
	movl	(%rbx,%r10,4), %edi
	cmpl	%edi, %r10d
	je	.L58
	movslq	%edi, %r11
	movl	(%rbx,%r11,4), %edx
	cmpl	%edx, %edi
	je	.L59
	movslq	%edx, %rbp
	movl	(%rbx,%rbp,4), %edi
	cmpl	%edi, %edx
	je	.L60
	movslq	%edi, %r12
	movl	(%rbx,%r12,4), %edx
	cmpl	%edx, %edi
	je	.L61
	movslq	%edx, %r13
	movl	%edx, %edi
	movl	(%rbx,%r13,4), %eax
	cmpl	%eax, %edx
	je	.L62
	movslq	%eax, %r14
	movl	(%rbx,%r14,4), %edi
	cmpl	%edi, %eax
	je	.L63
	call	dfs
	movl	%eax, (%rbx,%r14,4)
	movl	%eax, %edi
.L63:
	movl	%edi, (%rbx,%r13,4)
.L62:
	movl	%edi, (%rbx,%r12,4)
	movl	16(%rsp), %eax
.L61:
	movl	%edi, (%rbx,%rbp,4)
.L60:
	movl	%edi, (%rbx,%r11,4)
.L59:
	movl	%edi, (%rbx,%r10,4)
.L58:
	cmpl	%eax, %edi
	movl	%edi, 20(%rsp)
	sete	%al
	addq	$1, %rsi
	movzbl	%al, %eax
	addl	%eax, %r8d
	cmpl	%esi, 8(%rsp)
	jge	.L25
.L51:
	xorl	%eax, %eax
	movl	%r8d, %edx
	movl	$1, %edi
	leaq	.LC4(%rip), %rsi
	call	__printf_chk@PLT
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L98
	addq	$40, %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
	.p2align 4,,10
	.p2align 3
.L27:
	.cfi_restore_state
	movslq	%edx, %rsi
	movslq	(%rbx,%rsi,4), %r8
	movq	%r8, %rdi
	cmpl	%r8d, %edx
	je	.L39
	movl	(%rbx,%r8,4), %edx
	cmpl	%edx, %r8d
	je	.L40
	movslq	%edx, %r9
	movl	%edx, %edi
	movl	(%rbx,%r9,4), %ecx
	cmpl	%ecx, %edx
	je	.L41
	movslq	%ecx, %r10
	movl	%ecx, %edi
	movl	(%rbx,%r10,4), %edx
	cmpl	%edx, %ecx
	je	.L42
	movslq	%edx, %r11
	movl	(%rbx,%r11,4), %edi
	cmpl	%edi, %edx
	je	.L43
	call	dfs
	movl	%eax, (%rbx,%r11,4)
	movl	%eax, %edi
	movl	20(%rsp), %eax
.L43:
	movl	%edi, (%rbx,%r10,4)
.L42:
	movl	%edi, (%rbx,%r9,4)
.L41:
	movl	%edi, (%rbx,%r8,4)
	movslq	%edi, %r8
.L40:
	movl	%edi, (%rbx,%rsi,4)
.L39:
	movslq	%eax, %rsi
	movl	(%rbx,%rsi,4), %edx
	cmpl	%eax, %edx
	je	.L44
	movslq	%edx, %r9
	movl	(%rbx,%r9,4), %edi
	cmpl	%edi, %edx
	jne	.L97
	jmp	.L45
.L15:
	movl	$0, p(%rip)
.L20:
	cmpl	$0, 12(%rsp)
	leaq	a(%rip), %rbx
	jg	.L24
.L26:
	xorl	%r8d, %r8d
	jmp	.L51
.L66:
	xorl	%eax, %eax
	leaq	a(%rip), %rbx
	jmp	.L16
.L22:
	movl	$0, p(%rip)
	testl	%ecx, %ecx
	jg	.L19
	jmp	.L20
.L98:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE24:
	.size	main, .-main
	.globl	p
	.bss
	.align 32
	.type	p, @object
	.size	p, 400004
p:
	.zero	400004
	.globl	a
	.align 32
	.type	a, @object
	.size	a, 400004
a:
	.zero	400004
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC0:
	.long	0
	.long	1
	.long	2
	.long	3
	.align 16
.LC2:
	.long	4
	.long	4
	.long	4
	.long	4
	.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 a[100001],p[100001];

int dfs(int x){
  if(a[x]==x)
    return x;
  else 
    a[x]=dfs(a[x]);
  return a[x];
}

int main(){
  int i,n,m,x,y,cnt=0,l,r;
  scanf("%d %d",&n,&m);
  for(i=0;i<=n;i++)
    a[i]=i;
  p[0]=0;
  for(i=0;i<n;i++)
    scanf("%d",&p[i+1]);
  for(i=0;i<m;i++){
    scanf("%d %d",&x,&y);
    if(x>y)
      a[dfs(x)]=a[dfs(y)];
    else
      a[dfs(y)]=a[dfs(x)];
  }
  for(i=1;i<=n;i++){
    x=dfs(i);
    y=dfs(p[i]);
    if(x==y)
      cnt++;
  }
  printf("%d\n",cnt);
}
3 2
3 2 1
1 2
1 3
 5 2
5 3 1 4 3
1 3
5 4
 10 8
5 3 6 8 7 10 9 1 2 4
3 1
4 2
5 9
2 5
6 5
3 5
8 9
7 9
 5 2
5 3 1 4 2
1 2
5 4
 10 8
5 3 6 8 7 10 9 1 2 4
3 1
7 1
5 9
2 8
6 5
3 5
8 9
7 9
 10 8
5 3 6 8 7 10 9 1 2 4
3 1
4 1
5 9
2 2
6 5
3 5
8 9
7 9
 10 8
5 3 6 8 7 10 9 1 2 4
3 1
4 2
5 9
2 5
6 5
4 4
8 9
7 9
 10 8
5 3 6 8 7 10 9 1 2 4
3 1
6 1
5 9
2 2
6 5
3 5
8 9
7 9
 10 8
5 3 6 8 7 10 9 1 3 4
3 1
6 2
5 9
2 5
6 5
4 4
8 9
9 9
 10 8
5 3 6 8 7 10 9 1 2 4
3 1
4 1
5 9
2 8
6 5
3 5
8 9
7 9

3
 2
 8
 1
 7
 6
 4
 5
 0
 8

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 a[100001],p[100001];

int dfs(int x){
  if(a[x]==x)
    return x;
  else 
    a[x]=dfs(a[x]);
  return a[x];
}

int main(){
  int i,n,m,x,y,cnt=0,l,r;
  scanf("%d %d",&n,&m);
  for(i=0;i<=n;i++)
    a[i]=i;
  p[0]=0;
  for(i=0;i<n;i++)
    scanf("%d",&p[i+1]);
  for(i=0;i<m;i++){
    scanf("%d %d",&x,&y);
    if(x>y)
      a[dfs(x)]=a[dfs(y)];
    else
      a[dfs(y)]=a[dfs(x)];
  }
  for(i=1;i<=n;i++){
    x=dfs(i);
    y=dfs(p[i]);
    if(x==y)
      cnt++;
  }
  printf("%d\n",cnt);
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	a
	.bss
	.align 32
	.type	a, @object
	.size	a, 400004
a:
	.zero	400004
	.globl	p
	.align 32
	.type	p, @object
	.size	p, 400004
p:
	.zero	400004
	.text
	.globl	dfs
	.type	dfs, @function
dfs:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$16, %rsp
	movl	%edi, -4(%rbp)
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -4(%rbp)
	jne	.L2
	movl	-4(%rbp), %eax
	jmp	.L3
.L2:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, %edi
	call	dfs
	movl	-4(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	a(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %eax
.L3:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	dfs, .-dfs
	.section	.rodata
.LC0:
	.string	"%d %d"
.LC1:
	.string	"%d"
.LC2:
	.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
	pushq	%rbx
	subq	$40, %rsp
	.cfi_offset 3, -24
	movq	%fs:40, %rax
	movq	%rax, -24(%rbp)
	xorl	%eax, %eax
	movl	$0, -28(%rbp)
	leaq	-44(%rbp), %rdx
	leaq	-48(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -32(%rbp)
	jmp	.L5
.L6:
	movl	-32(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	a(%rip), %rdx
	movl	-32(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	addl	$1, -32(%rbp)
.L5:
	movl	-48(%rbp), %eax
	cmpl	%eax, -32(%rbp)
	jle	.L6
	movl	$0, p(%rip)
	movl	$0, -32(%rbp)
	jmp	.L7
.L8:
	movl	-32(%rbp), %eax
	addl	$1, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	p(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -32(%rbp)
.L7:
	movl	-48(%rbp), %eax
	cmpl	%eax, -32(%rbp)
	jl	.L8
	movl	$0, -32(%rbp)
	jmp	.L9
.L12:
	leaq	-36(%rbp), %rdx
	leaq	-40(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-40(%rbp), %edx
	movl	-36(%rbp), %eax
	cmpl	%eax, %edx
	jle	.L10
	movl	-36(%rbp), %eax
	movl	%eax, %edi
	call	dfs
	movl	%eax, %ebx
	movl	-40(%rbp), %eax
	movl	%eax, %edi
	call	dfs
	movl	%eax, %edx
	movslq	%ebx, %rax
	leaq	0(,%rax,4), %rcx
	leaq	a(%rip), %rax
	movl	(%rcx,%rax), %eax
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	a(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	jmp	.L11
.L10:
	movl	-40(%rbp), %eax
	movl	%eax, %edi
	call	dfs
	movl	%eax, %ebx
	movl	-36(%rbp), %eax
	movl	%eax, %edi
	call	dfs
	movl	%eax, %edx
	movslq	%ebx, %rax
	leaq	0(,%rax,4), %rcx
	leaq	a(%rip), %rax
	movl	(%rcx,%rax), %eax
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	a(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
.L11:
	addl	$1, -32(%rbp)
.L9:
	movl	-44(%rbp), %eax
	cmpl	%eax, -32(%rbp)
	jl	.L12
	movl	$1, -32(%rbp)
	jmp	.L13
.L15:
	movl	-32(%rbp), %eax
	movl	%eax, %edi
	call	dfs
	movl	%eax, -40(%rbp)
	movl	-32(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	p(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, %edi
	call	dfs
	movl	%eax, -36(%rbp)
	movl	-40(%rbp), %edx
	movl	-36(%rbp), %eax
	cmpl	%eax, %edx
	jne	.L14
	addl	$1, -28(%rbp)
.L14:
	addl	$1, -32(%rbp)
.L13:
	movl	-48(%rbp), %eax
	cmpl	%eax, -32(%rbp)
	jle	.L15
	movl	-28(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-24(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L17
	call	__stack_chk_fail@PLT
.L17:
	movq	-8(%rbp), %rbx
	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	a
	.bss
	.align 32
	.type	a, @object
	.size	a, 400004
a:
	.zero	400004
	.globl	p
	.align 32
	.type	p, @object
	.size	p, 400004
p:
	.zero	400004
	.text
	.globl	dfs
	.type	dfs, @function
dfs:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$16, %rsp
	movl	%edi, -4(%rbp)
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -4(%rbp)
	jne	.L2
	movl	-4(%rbp), %eax
	jmp	.L3
.L2:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, %edi
	call	dfs
	movl	-4(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	a(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %eax
.L3:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	dfs, .-dfs
	.section	.rodata
.LC0:
	.string	"%d %d"
.LC1:
	.string	"%d"
.LC2:
	.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
	pushq	%rbx
	subq	$40, %rsp
	.cfi_offset 3, -24
	movq	%fs:40, %rax
	movq	%rax, -24(%rbp)
	xorl	%eax, %eax
	movl	$0, -28(%rbp)
	leaq	-44(%rbp), %rdx
	leaq	-48(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -32(%rbp)
	jmp	.L5
.L6:
	movl	-32(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	a(%rip), %rdx
	movl	-32(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	addl	$1, -32(%rbp)
.L5:
	movl	-48(%rbp), %eax
	cmpl	%eax, -32(%rbp)
	jle	.L6
	movl	$0, p(%rip)
	movl	$0, -32(%rbp)
	jmp	.L7
.L8:
	movl	-32(%rbp), %eax
	addl	$1, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	p(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -32(%rbp)
.L7:
	movl	-48(%rbp), %eax
	cmpl	%eax, -32(%rbp)
	jl	.L8
	movl	$0, -32(%rbp)
	jmp	.L9
.L12:
	leaq	-36(%rbp), %rdx
	leaq	-40(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-40(%rbp), %edx
	movl	-36(%rbp), %eax
	cmpl	%eax, %edx
	jle	.L10
	movl	-36(%rbp), %eax
	movl	%eax, %edi
	call	dfs
	movl	%eax, %ebx
	movl	-40(%rbp), %eax
	movl	%eax, %edi
	call	dfs
	movl	%eax, %edx
	movslq	%ebx, %rax
	leaq	0(,%rax,4), %rcx
	leaq	a(%rip), %rax
	movl	(%rcx,%rax), %eax
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	a(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	jmp	.L11
.L10:
	movl	-40(%rbp), %eax
	movl	%eax, %edi
	call	dfs
	movl	%eax, %ebx
	movl	-36(%rbp), %eax
	movl	%eax, %edi
	call	dfs
	movl	%eax, %edx
	movslq	%ebx, %rax
	leaq	0(,%rax,4), %rcx
	leaq	a(%rip), %rax
	movl	(%rcx,%rax), %eax
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	a(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
.L11:
	addl	$1, -32(%rbp)
.L9:
	movl	-44(%rbp), %eax
	cmpl	%eax, -32(%rbp)
	jl	.L12
	movl	$1, -32(%rbp)
	jmp	.L13
.L15:
	movl	-32(%rbp), %eax
	movl	%eax, %edi
	call	dfs
	movl	%eax, -40(%rbp)
	movl	-32(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	p(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, %edi
	call	dfs
	movl	%eax, -36(%rbp)
	movl	-40(%rbp), %edx
	movl	-36(%rbp), %eax
	cmpl	%eax, %edx
	jne	.L14
	addl	$1, -28(%rbp)
.L14:
	addl	$1, -32(%rbp)
.L13:
	movl	-48(%rbp), %eax
	cmpl	%eax, -32(%rbp)
	jle	.L15
	movl	-28(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-24(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L17
	call	__stack_chk_fail@PLT
.L17:
	movq	-8(%rbp), %rbx
	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:
