Given the following C code and unoptimized assembly code, your task is to generate highly optimized x86-64 assembly code.
C Code:

```c
/* Coached by rainboy */
#include <stdio.h>
#include <string.h>

#define N 100000

int dsu[N];

int find(int i) {
	return dsu[i] < 0 ? i : (dsu[i] = find(dsu[i]));
}

void join(int i, int j) {
	i = find(i);
	j = find(j);
	if (i == j)
		return;
	if (dsu[i] > dsu[j])
		dsu[i] = j;
	else {
		if (dsu[i] == dsu[j])
			dsu[i]--;
		dsu[j] = i;
	}
}

int main() {
	static int pp[N];
	int n, m, i, j, ans;

	scanf("%d%d", &n, &m);
	for (i = 0; i < n; i++)
		scanf("%d", &pp[i]), pp[i]--;
	memset(dsu, -1, n * sizeof *dsu);
	while (m--) {
		scanf("%d%d", &i, &j), i--, j--;
		join(i, j);
	}
	ans = 0;
	for (i = 0; i < n; i++)
		if (find(i) == find(pp[i]))
			ans++;
	printf("%d\n", ans);
	return 0;
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	dsu
	.bss
	.align 32
	.type	dsu, @object
	.size	dsu, 400000
dsu:
	.zero	400000
	.text
	.globl	find
	.type	find, @function
find:
.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	dsu(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	js	.L2
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	dsu(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, %edi
	call	find
	movl	-4(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	dsu(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	dsu(%rip), %rax
	movl	(%rdx,%rax), %eax
	jmp	.L4
.L2:
	movl	-4(%rbp), %eax
.L4:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	find, .-find
	.globl	join
	.type	join, @function
join:
.LFB1:
	.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	%esi, -8(%rbp)
	movl	-4(%rbp), %eax
	movl	%eax, %edi
	call	find
	movl	%eax, -4(%rbp)
	movl	-8(%rbp), %eax
	movl	%eax, %edi
	call	find
	movl	%eax, -8(%rbp)
	movl	-4(%rbp), %eax
	cmpl	-8(%rbp), %eax
	je	.L10
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	dsu(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	dsu(%rip), %rax
	movl	(%rcx,%rax), %eax
	cmpl	%eax, %edx
	jle	.L8
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	dsu(%rip), %rdx
	movl	-8(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	jmp	.L5
.L8:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	dsu(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	dsu(%rip), %rax
	movl	(%rcx,%rax), %eax
	cmpl	%eax, %edx
	jne	.L9
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	dsu(%rip), %rax
	movl	(%rdx,%rax), %eax
	leal	-1(%rax), %ecx
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	dsu(%rip), %rax
	movl	%ecx, (%rdx,%rax)
.L9:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	dsu(%rip), %rdx
	movl	-4(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	jmp	.L5
.L10:
	nop
.L5:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	join, .-join
	.section	.rodata
.LC0:
	.string	"%d%d"
.LC1:
	.string	"%d"
.LC2:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB2:
	.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
	leaq	-40(%rbp), %rdx
	leaq	-44(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -36(%rbp)
	jmp	.L12
.L13:
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	pp.0(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-36(%rbp), %eax
	movslq	%eax, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	pp.0(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	leal	-1(%rdx), %ecx
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	pp.0(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	-36(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -36(%rbp)
.L12:
	movl	-36(%rbp), %edx
	movl	-44(%rbp), %eax
	cmpl	%eax, %edx
	jl	.L13
	movl	-44(%rbp), %eax
	cltq
	salq	$2, %rax
	movq	%rax, %rdx
	movl	$-1, %esi
	leaq	dsu(%rip), %rax
	movq	%rax, %rdi
	call	memset@PLT
	jmp	.L14
.L15:
	leaq	-32(%rbp), %rdx
	leaq	-36(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-36(%rbp), %eax
	subl	$1, %eax
	movl	%eax, -36(%rbp)
	movl	-32(%rbp), %eax
	subl	$1, %eax
	movl	%eax, -32(%rbp)
	movl	-32(%rbp), %edx
	movl	-36(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	join
.L14:
	movl	-40(%rbp), %eax
	leal	-1(%rax), %edx
	movl	%edx, -40(%rbp)
	testl	%eax, %eax
	jne	.L15
	movl	$0, -28(%rbp)
	movl	$0, -36(%rbp)
	jmp	.L16
.L18:
	movl	-36(%rbp), %eax
	movl	%eax, %edi
	call	find
	movl	%eax, %ebx
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	pp.0(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, %edi
	call	find
	cmpl	%eax, %ebx
	jne	.L17
	addl	$1, -28(%rbp)
.L17:
	movl	-36(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -36(%rbp)
.L16:
	movl	-36(%rbp), %edx
	movl	-44(%rbp), %eax
	cmpl	%eax, %edx
	jl	.L18
	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	.L20
	call	__stack_chk_fail@PLT
.L20:
	movq	-8(%rbp), %rbx
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2:
	.size	main, .-main
	.local	pp.0
	.comm	pp.0,400000,32
	.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	find
	.type	find, @function
find:
.LFB35:
	.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
	movslq	%edi, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	leaq	dsu(%rip), %rbx
	movq	%rbp, %rax
	subq	$8, %rsp
	.cfi_def_cfa_offset 48
	movl	(%rbx,%rbp,4), %edx
	testl	%edx, %edx
	jns	.L8
	addq	$8, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	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
	.p2align 4,,10
	.p2align 3
.L8:
	.cfi_restore_state
	movslq	%edx, %r12
	movl	(%rbx,%r12,4), %eax
	testl	%eax, %eax
	jns	.L9
.L3:
	movl	%edx, (%rbx,%rbp,4)
	addq	$8, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	movl	%edx, %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
	.p2align 4,,10
	.p2align 3
.L9:
	.cfi_restore_state
	movslq	%eax, %r13
	movl	(%rbx,%r13,4), %edi
	testl	%edi, %edi
	js	.L4
	call	find
	movl	%eax, (%rbx,%r13,4)
.L4:
	movl	%eax, (%rbx,%r12,4)
	movl	%eax, %edx
	jmp	.L3
	.cfi_endproc
.LFE35:
	.size	find, .-find
	.p2align 4
	.globl	join
	.type	join, @function
join:
.LFB36:
	.cfi_startproc
	endbr64
	movslq	%edi, %r9
	leaq	dsu(%rip), %rcx
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	movq	%r9, %r8
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	movl	(%rcx,%r9,4), %eax
	testl	%eax, %eax
	jns	.L34
.L11:
	movslq	%esi, %r9
	movl	(%rcx,%r9,4), %eax
	testl	%eax, %eax
	jns	.L35
.L20:
	cmpl	%r8d, %esi
	je	.L10
	movslq	%r8d, %rax
	movslq	%esi, %r9
	movl	(%rcx,%rax,4), %edx
	cmpl	(%rcx,%r9,4), %edx
	jg	.L36
	jne	.L31
	subl	$1, %edx
	movl	%edx, (%rcx,%rax,4)
.L31:
	movl	%r8d, (%rcx,%r9,4)
.L10:
	popq	%rbx
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L36:
	.cfi_restore_state
	movl	%esi, (%rcx,%rax,4)
	popq	%rbx
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L35:
	.cfi_restore_state
	movslq	%eax, %rsi
	movl	(%rcx,%rsi,4), %edx
	testl	%edx, %edx
	jns	.L37
.L21:
	movl	%eax, (%rcx,%r9,4)
	movl	%eax, %esi
	jmp	.L20
	.p2align 4,,10
	.p2align 3
.L34:
	movslq	%eax, %r8
	movl	(%rcx,%r8,4), %edx
	testl	%edx, %edx
	jns	.L38
.L12:
	movl	%eax, (%rcx,%r9,4)
	movl	%eax, %r8d
	jmp	.L11
	.p2align 4,,10
	.p2align 3
.L37:
	movslq	%edx, %r10
	movl	(%rcx,%r10,4), %eax
	testl	%eax, %eax
	jns	.L39
.L22:
	movl	%edx, (%rcx,%rsi,4)
	movl	%edx, %eax
	jmp	.L21
	.p2align 4,,10
	.p2align 3
.L38:
	movslq	%edx, %r10
	movl	(%rcx,%r10,4), %eax
	testl	%eax, %eax
	jns	.L40
.L13:
	movl	%edx, (%rcx,%r8,4)
	movl	%edx, %eax
	jmp	.L12
	.p2align 4,,10
	.p2align 3
.L39:
	movslq	%eax, %r11
	movl	(%rcx,%r11,4), %edx
	testl	%edx, %edx
	jns	.L41
.L23:
	movl	%eax, (%rcx,%r10,4)
	movl	%eax, %edx
	jmp	.L22
	.p2align 4,,10
	.p2align 3
.L40:
	movslq	%eax, %r11
	movl	(%rcx,%r11,4), %edx
	testl	%edx, %edx
	jns	.L42
.L14:
	movl	%eax, (%rcx,%r10,4)
	movl	%eax, %edx
	jmp	.L13
	.p2align 4,,10
	.p2align 3
.L42:
	movslq	%edx, %rbx
	movl	(%rcx,%rbx,4), %eax
	testl	%eax, %eax
	jns	.L43
.L15:
	movl	%edx, (%rcx,%r11,4)
	movl	%edx, %eax
	jmp	.L14
	.p2align 4,,10
	.p2align 3
.L41:
	movslq	%edx, %rbx
	movl	(%rcx,%rbx,4), %eax
	testl	%eax, %eax
	jns	.L44
.L24:
	movl	%edx, (%rcx,%r11,4)
	movl	%edx, %eax
	jmp	.L23
	.p2align 4,,10
	.p2align 3
.L43:
	movslq	%eax, %rbp
	movl	(%rcx,%rbp,4), %edx
	testl	%edx, %edx
	jns	.L45
.L16:
	movl	%eax, (%rcx,%rbx,4)
	movl	%eax, %edx
	jmp	.L15
	.p2align 4,,10
	.p2align 3
.L44:
	movslq	%eax, %rbp
	movl	(%rcx,%rbp,4), %edx
	testl	%edx, %edx
	jns	.L46
.L25:
	movl	%eax, (%rcx,%rbx,4)
	movl	%eax, %edx
	jmp	.L24
.L45:
	movslq	%edx, %r12
	movl	(%rcx,%r12,4), %eax
	testl	%eax, %eax
	jns	.L47
.L17:
	movl	%edx, (%rcx,%rbp,4)
	movl	%edx, %eax
	jmp	.L16
.L46:
	movslq	%edx, %r12
	movl	(%rcx,%r12,4), %eax
	testl	%eax, %eax
	jns	.L48
.L26:
	movl	%edx, (%rcx,%rbp,4)
	movl	%edx, %eax
	jmp	.L25
.L47:
	movslq	%eax, %r13
	movl	(%rcx,%r13,4), %edx
	testl	%edx, %edx
	jns	.L49
.L18:
	movl	%eax, (%rcx,%r12,4)
	movl	%eax, %edx
	jmp	.L17
.L48:
	movslq	%eax, %r13
	movl	(%rcx,%r13,4), %edx
	testl	%edx, %edx
	jns	.L50
.L27:
	movl	%eax, (%rcx,%r12,4)
	movl	%eax, %edx
	jmp	.L26
.L49:
	movslq	%edx, %r14
	movl	(%rcx,%r14,4), %edi
	testl	%edi, %edi
	js	.L19
	call	find
	movl	%eax, (%rcx,%r14,4)
	movl	%eax, %edx
.L19:
	movl	%edx, (%rcx,%r13,4)
	movl	%edx, %eax
	jmp	.L18
.L50:
	movslq	%edx, %r14
	movl	(%rcx,%r14,4), %edi
	testl	%edi, %edi
	js	.L28
	call	find
	movl	%eax, (%rcx,%r14,4)
	movl	%eax, %edx
.L28:
	movl	%edx, (%rcx,%r13,4)
	movl	%edx, %eax
	jmp	.L27
	.cfi_endproc
.LFE36:
	.size	join, .-join
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d%d"
.LC1:
	.string	"%d"
.LC2:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB37:
	.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	.LC0(%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
	movslq	8(%rsp), %rdx
	movl	$0, 16(%rsp)
	testl	%edx, %edx
	jle	.L52
	xorl	%eax, %eax
	leaq	pp.0(%rip), %r12
	leaq	.LC1(%rip), %rbx
	.p2align 4,,10
	.p2align 3
.L53:
	cltq
	movq	%rbx, %rdi
	leaq	(%r12,%rax,4), %rsi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movslq	16(%rsp), %rdx
	movq	%rdx, %rax
	subl	$1, (%r12,%rdx,4)
	movslq	8(%rsp), %rdx
	addl	$1, %eax
	movl	%eax, 16(%rsp)
	cmpl	%edx, %eax
	jl	.L53
.L52:
	leaq	dsu(%rip), %rbx
	salq	$2, %rdx
	movl	$400000, %ecx
	movl	$-1, %esi
	movq	%rbx, %rdi
	leaq	20(%rsp), %r13
	leaq	16(%rsp), %r12
	call	__memset_chk@PLT
	movl	12(%rsp), %eax
	leal	-1(%rax), %edx
	movl	%edx, 12(%rsp)
	testl	%eax, %eax
	je	.L57
	.p2align 4,,10
	.p2align 3
.L54:
	movq	%r13, %rdx
	movq	%r12, %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	16(%rsp), %eax
	leal	-1(%rax), %edi
	movl	20(%rsp), %eax
	movl	%edi, 16(%rsp)
	leal	-1(%rax), %esi
	movl	%esi, 20(%rsp)
	call	join
	movl	12(%rsp), %eax
	leal	-1(%rax), %edx
	movl	%edx, 12(%rsp)
	testl	%eax, %eax
	jne	.L54
.L57:
	movl	8(%rsp), %edx
	xorl	%r9d, %r9d
	xorl	%eax, %eax
	leaq	pp.0(%rip), %r12
	movl	$0, 16(%rsp)
	testl	%edx, %edx
	jg	.L55
	jmp	.L56
	.p2align 4,,10
	.p2align 3
.L77:
	movslq	(%r12,%rsi,4), %r8
	movl	%eax, %ecx
	movl	(%rbx,%r8,4), %edx
	movq	%r8, %rsi
	testl	%edx, %edx
	jns	.L87
.L66:
	xorl	%edx, %edx
	cmpl	%ecx, %esi
	sete	%dl
	addl	$1, %eax
	movl	%eax, 16(%rsp)
	addl	%edx, %r9d
	cmpl	8(%rsp), %eax
	jge	.L56
.L55:
	movslq	%eax, %rsi
	movl	(%rbx,%rsi,4), %ecx
	testl	%ecx, %ecx
	js	.L77
	movslq	%ecx, %r8
	movl	(%rbx,%r8,4), %edx
	testl	%edx, %edx
	jns	.L88
.L59:
	movl	%ecx, (%rbx,%rsi,4)
	movslq	%eax, %rsi
	movslq	(%r12,%rsi,4), %r8
	movl	(%rbx,%r8,4), %edx
	movq	%r8, %rsi
	testl	%edx, %edx
	js	.L66
.L87:
	movslq	%edx, %r10
	movl	(%rbx,%r10,4), %esi
	testl	%esi, %esi
	jns	.L89
.L67:
	movl	%edx, (%rbx,%r8,4)
	movl	%edx, %esi
	jmp	.L66
	.p2align 4,,10
	.p2align 3
.L88:
	movslq	%edx, %r10
	movl	(%rbx,%r10,4), %ecx
	testl	%ecx, %ecx
	jns	.L90
.L60:
	movl	%edx, (%rbx,%r8,4)
	movl	%edx, %ecx
	jmp	.L59
	.p2align 4,,10
	.p2align 3
.L89:
	movslq	%esi, %r11
	movl	(%rbx,%r11,4), %edx
	testl	%edx, %edx
	jns	.L91
.L68:
	movl	%esi, (%rbx,%r10,4)
	movl	%esi, %edx
	jmp	.L67
	.p2align 4,,10
	.p2align 3
.L56:
	xorl	%eax, %eax
	movl	%r9d, %edx
	movl	$1, %edi
	leaq	.LC2(%rip), %rsi
	call	__printf_chk@PLT
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L92
	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
.L90:
	.cfi_restore_state
	movslq	%ecx, %r11
	movl	(%rbx,%r11,4), %eax
	testl	%eax, %eax
	jns	.L93
.L61:
	movl	%ecx, (%rbx,%r10,4)
	movl	16(%rsp), %eax
	movl	%ecx, %edx
	jmp	.L60
.L91:
	movslq	%edx, %rsi
	movl	(%rbx,%rsi,4), %eax
	testl	%eax, %eax
	jns	.L94
.L69:
	movl	%edx, (%rbx,%r11,4)
	movl	16(%rsp), %eax
	movl	%edx, %esi
	jmp	.L68
.L94:
	movslq	%eax, %rbp
	movl	(%rbx,%rbp,4), %edx
	testl	%edx, %edx
	jns	.L95
.L70:
	movl	%eax, (%rbx,%rsi,4)
	movl	%eax, %edx
	jmp	.L69
.L93:
	movslq	%eax, %rcx
	movl	(%rbx,%rcx,4), %edx
	testl	%edx, %edx
	jns	.L96
.L62:
	movl	%eax, (%rbx,%r11,4)
	movl	%eax, %ecx
	jmp	.L61
.L96:
	movslq	%edx, %rbp
	movl	(%rbx,%rbp,4), %eax
	testl	%eax, %eax
	jns	.L97
.L63:
	movl	%edx, (%rbx,%rcx,4)
	movl	%edx, %eax
	jmp	.L62
.L95:
	movslq	%edx, %r13
	movl	(%rbx,%r13,4), %eax
	testl	%eax, %eax
	jns	.L98
.L71:
	movl	%edx, (%rbx,%rbp,4)
	movl	%edx, %eax
	jmp	.L70
.L97:
	movslq	%eax, %r13
	movl	(%rbx,%r13,4), %edx
	testl	%edx, %edx
	jns	.L99
.L64:
	movl	%eax, (%rbx,%rbp,4)
	movl	%eax, %edx
	jmp	.L63
.L98:
	movslq	%eax, %r14
	movl	(%rbx,%r14,4), %edx
	testl	%edx, %edx
	jns	.L100
.L72:
	movl	%eax, (%rbx,%r13,4)
	movl	%eax, %edx
	jmp	.L71
.L99:
	movslq	%edx, %r14
	movl	(%rbx,%r14,4), %edi
	testl	%edi, %edi
	js	.L65
	call	find
	movl	%eax, (%rbx,%r14,4)
	movl	%eax, %edx
.L65:
	movl	%edx, (%rbx,%r13,4)
	movl	%edx, %eax
	jmp	.L64
.L100:
	movslq	%edx, %r15
	movl	(%rbx,%r15,4), %edi
	testl	%edi, %edi
	js	.L73
	call	find
	movl	%eax, (%rbx,%r15,4)
	movl	%eax, %edx
.L73:
	movl	%edx, (%rbx,%r14,4)
	movl	%edx, %eax
	jmp	.L72
.L92:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE37:
	.size	main, .-main
	.local	pp.0
	.comm	pp.0,400000,32
	.globl	dsu
	.bss
	.align 32
	.type	dsu, @object
	.size	dsu, 400000
dsu:
	.zero	400000
	.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	find
	.type	find, @function
find:
.LFB35:
	.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
	movslq	%edi, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	leaq	dsu(%rip), %rbx
	movq	%rbp, %rax
	subq	$8, %rsp
	.cfi_def_cfa_offset 48
	movl	(%rbx,%rbp,4), %edx
	testl	%edx, %edx
	jns	.L8
	addq	$8, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	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
	.p2align 4,,10
	.p2align 3
.L8:
	.cfi_restore_state
	movslq	%edx, %r12
	movl	(%rbx,%r12,4), %eax
	testl	%eax, %eax
	jns	.L9
.L3:
	movl	%edx, (%rbx,%rbp,4)
	addq	$8, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	movl	%edx, %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
	.p2align 4,,10
	.p2align 3
.L9:
	.cfi_restore_state
	movslq	%eax, %r13
	movl	(%rbx,%r13,4), %edi
	testl	%edi, %edi
	js	.L4
	call	find
	movl	%eax, (%rbx,%r13,4)
.L4:
	movl	%eax, (%rbx,%r12,4)
	movl	%eax, %edx
	jmp	.L3
	.cfi_endproc
.LFE35:
	.size	find, .-find
	.p2align 4
	.globl	join
	.type	join, @function
join:
.LFB36:
	.cfi_startproc
	endbr64
	movslq	%edi, %r9
	leaq	dsu(%rip), %rcx
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	movq	%r9, %r8
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	movl	(%rcx,%r9,4), %eax
	testl	%eax, %eax
	jns	.L34
.L11:
	movslq	%esi, %r9
	movl	(%rcx,%r9,4), %eax
	testl	%eax, %eax
	jns	.L35
.L20:
	cmpl	%r8d, %esi
	je	.L10
	movslq	%r8d, %rax
	movslq	%esi, %r9
	movl	(%rcx,%rax,4), %edx
	cmpl	(%rcx,%r9,4), %edx
	jg	.L36
	jne	.L31
	subl	$1, %edx
	movl	%edx, (%rcx,%rax,4)
.L31:
	movl	%r8d, (%rcx,%r9,4)
.L10:
	popq	%rbx
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L36:
	.cfi_restore_state
	movl	%esi, (%rcx,%rax,4)
	popq	%rbx
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L35:
	.cfi_restore_state
	movslq	%eax, %rsi
	movl	(%rcx,%rsi,4), %edx
	testl	%edx, %edx
	jns	.L37
.L21:
	movl	%eax, (%rcx,%r9,4)
	movl	%eax, %esi
	jmp	.L20
	.p2align 4,,10
	.p2align 3
.L34:
	movslq	%eax, %r8
	movl	(%rcx,%r8,4), %edx
	testl	%edx, %edx
	jns	.L38
.L12:
	movl	%eax, (%rcx,%r9,4)
	movl	%eax, %r8d
	jmp	.L11
	.p2align 4,,10
	.p2align 3
.L37:
	movslq	%edx, %r10
	movl	(%rcx,%r10,4), %eax
	testl	%eax, %eax
	jns	.L39
.L22:
	movl	%edx, (%rcx,%rsi,4)
	movl	%edx, %eax
	jmp	.L21
	.p2align 4,,10
	.p2align 3
.L38:
	movslq	%edx, %r10
	movl	(%rcx,%r10,4), %eax
	testl	%eax, %eax
	jns	.L40
.L13:
	movl	%edx, (%rcx,%r8,4)
	movl	%edx, %eax
	jmp	.L12
	.p2align 4,,10
	.p2align 3
.L39:
	movslq	%eax, %r11
	movl	(%rcx,%r11,4), %edx
	testl	%edx, %edx
	jns	.L41
.L23:
	movl	%eax, (%rcx,%r10,4)
	movl	%eax, %edx
	jmp	.L22
	.p2align 4,,10
	.p2align 3
.L40:
	movslq	%eax, %r11
	movl	(%rcx,%r11,4), %edx
	testl	%edx, %edx
	jns	.L42
.L14:
	movl	%eax, (%rcx,%r10,4)
	movl	%eax, %edx
	jmp	.L13
	.p2align 4,,10
	.p2align 3
.L42:
	movslq	%edx, %rbx
	movl	(%rcx,%rbx,4), %eax
	testl	%eax, %eax
	jns	.L43
.L15:
	movl	%edx, (%rcx,%r11,4)
	movl	%edx, %eax
	jmp	.L14
	.p2align 4,,10
	.p2align 3
.L41:
	movslq	%edx, %rbx
	movl	(%rcx,%rbx,4), %eax
	testl	%eax, %eax
	jns	.L44
.L24:
	movl	%edx, (%rcx,%r11,4)
	movl	%edx, %eax
	jmp	.L23
	.p2align 4,,10
	.p2align 3
.L43:
	movslq	%eax, %rbp
	movl	(%rcx,%rbp,4), %edx
	testl	%edx, %edx
	jns	.L45
.L16:
	movl	%eax, (%rcx,%rbx,4)
	movl	%eax, %edx
	jmp	.L15
	.p2align 4,,10
	.p2align 3
.L44:
	movslq	%eax, %rbp
	movl	(%rcx,%rbp,4), %edx
	testl	%edx, %edx
	jns	.L46
.L25:
	movl	%eax, (%rcx,%rbx,4)
	movl	%eax, %edx
	jmp	.L24
.L45:
	movslq	%edx, %r12
	movl	(%rcx,%r12,4), %eax
	testl	%eax, %eax
	jns	.L47
.L17:
	movl	%edx, (%rcx,%rbp,4)
	movl	%edx, %eax
	jmp	.L16
.L46:
	movslq	%edx, %r12
	movl	(%rcx,%r12,4), %eax
	testl	%eax, %eax
	jns	.L48
.L26:
	movl	%edx, (%rcx,%rbp,4)
	movl	%edx, %eax
	jmp	.L25
.L47:
	movslq	%eax, %r13
	movl	(%rcx,%r13,4), %edx
	testl	%edx, %edx
	jns	.L49
.L18:
	movl	%eax, (%rcx,%r12,4)
	movl	%eax, %edx
	jmp	.L17
.L48:
	movslq	%eax, %r13
	movl	(%rcx,%r13,4), %edx
	testl	%edx, %edx
	jns	.L50
.L27:
	movl	%eax, (%rcx,%r12,4)
	movl	%eax, %edx
	jmp	.L26
.L49:
	movslq	%edx, %r14
	movl	(%rcx,%r14,4), %edi
	testl	%edi, %edi
	js	.L19
	call	find
	movl	%eax, (%rcx,%r14,4)
	movl	%eax, %edx
.L19:
	movl	%edx, (%rcx,%r13,4)
	movl	%edx, %eax
	jmp	.L18
.L50:
	movslq	%edx, %r14
	movl	(%rcx,%r14,4), %edi
	testl	%edi, %edi
	js	.L28
	call	find
	movl	%eax, (%rcx,%r14,4)
	movl	%eax, %edx
.L28:
	movl	%edx, (%rcx,%r13,4)
	movl	%edx, %eax
	jmp	.L27
	.cfi_endproc
.LFE36:
	.size	join, .-join
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d%d"
.LC1:
	.string	"%d"
.LC2:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB37:
	.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	.LC0(%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
	movslq	8(%rsp), %rdx
	movl	$0, 16(%rsp)
	testl	%edx, %edx
	jle	.L52
	xorl	%eax, %eax
	leaq	pp.0(%rip), %r12
	leaq	.LC1(%rip), %rbx
	.p2align 4,,10
	.p2align 3
.L53:
	cltq
	movq	%rbx, %rdi
	leaq	(%r12,%rax,4), %rsi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movslq	16(%rsp), %rdx
	movq	%rdx, %rax
	subl	$1, (%r12,%rdx,4)
	movslq	8(%rsp), %rdx
	addl	$1, %eax
	movl	%eax, 16(%rsp)
	cmpl	%edx, %eax
	jl	.L53
.L52:
	leaq	dsu(%rip), %rbx
	salq	$2, %rdx
	movl	$400000, %ecx
	movl	$-1, %esi
	movq	%rbx, %rdi
	leaq	20(%rsp), %r13
	leaq	16(%rsp), %r12
	call	__memset_chk@PLT
	movl	12(%rsp), %eax
	leal	-1(%rax), %edx
	movl	%edx, 12(%rsp)
	testl	%eax, %eax
	je	.L57
	.p2align 4,,10
	.p2align 3
.L54:
	movq	%r13, %rdx
	movq	%r12, %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	16(%rsp), %eax
	leal	-1(%rax), %edi
	movl	20(%rsp), %eax
	movl	%edi, 16(%rsp)
	leal	-1(%rax), %esi
	movl	%esi, 20(%rsp)
	call	join
	movl	12(%rsp), %eax
	leal	-1(%rax), %edx
	movl	%edx, 12(%rsp)
	testl	%eax, %eax
	jne	.L54
.L57:
	movl	8(%rsp), %edx
	xorl	%r9d, %r9d
	xorl	%eax, %eax
	leaq	pp.0(%rip), %r12
	movl	$0, 16(%rsp)
	testl	%edx, %edx
	jg	.L55
	jmp	.L56
	.p2align 4,,10
	.p2align 3
.L77:
	movslq	(%r12,%rsi,4), %r8
	movl	%eax, %ecx
	movl	(%rbx,%r8,4), %edx
	movq	%r8, %rsi
	testl	%edx, %edx
	jns	.L87
.L66:
	xorl	%edx, %edx
	cmpl	%ecx, %esi
	sete	%dl
	addl	$1, %eax
	movl	%eax, 16(%rsp)
	addl	%edx, %r9d
	cmpl	8(%rsp), %eax
	jge	.L56
.L55:
	movslq	%eax, %rsi
	movl	(%rbx,%rsi,4), %ecx
	testl	%ecx, %ecx
	js	.L77
	movslq	%ecx, %r8
	movl	(%rbx,%r8,4), %edx
	testl	%edx, %edx
	jns	.L88
.L59:
	movl	%ecx, (%rbx,%rsi,4)
	movslq	%eax, %rsi
	movslq	(%r12,%rsi,4), %r8
	movl	(%rbx,%r8,4), %edx
	movq	%r8, %rsi
	testl	%edx, %edx
	js	.L66
.L87:
	movslq	%edx, %r10
	movl	(%rbx,%r10,4), %esi
	testl	%esi, %esi
	jns	.L89
.L67:
	movl	%edx, (%rbx,%r8,4)
	movl	%edx, %esi
	jmp	.L66
	.p2align 4,,10
	.p2align 3
.L88:
	movslq	%edx, %r10
	movl	(%rbx,%r10,4), %ecx
	testl	%ecx, %ecx
	jns	.L90
.L60:
	movl	%edx, (%rbx,%r8,4)
	movl	%edx, %ecx
	jmp	.L59
	.p2align 4,,10
	.p2align 3
.L89:
	movslq	%esi, %r11
	movl	(%rbx,%r11,4), %edx
	testl	%edx, %edx
	jns	.L91
.L68:
	movl	%esi, (%rbx,%r10,4)
	movl	%esi, %edx
	jmp	.L67
	.p2align 4,,10
	.p2align 3
.L56:
	xorl	%eax, %eax
	movl	%r9d, %edx
	movl	$1, %edi
	leaq	.LC2(%rip), %rsi
	call	__printf_chk@PLT
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L92
	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
.L90:
	.cfi_restore_state
	movslq	%ecx, %r11
	movl	(%rbx,%r11,4), %eax
	testl	%eax, %eax
	jns	.L93
.L61:
	movl	%ecx, (%rbx,%r10,4)
	movl	16(%rsp), %eax
	movl	%ecx, %edx
	jmp	.L60
.L91:
	movslq	%edx, %rsi
	movl	(%rbx,%rsi,4), %eax
	testl	%eax, %eax
	jns	.L94
.L69:
	movl	%edx, (%rbx,%r11,4)
	movl	16(%rsp), %eax
	movl	%edx, %esi
	jmp	.L68
.L94:
	movslq	%eax, %rbp
	movl	(%rbx,%rbp,4), %edx
	testl	%edx, %edx
	jns	.L95
.L70:
	movl	%eax, (%rbx,%rsi,4)
	movl	%eax, %edx
	jmp	.L69
.L93:
	movslq	%eax, %rcx
	movl	(%rbx,%rcx,4), %edx
	testl	%edx, %edx
	jns	.L96
.L62:
	movl	%eax, (%rbx,%r11,4)
	movl	%eax, %ecx
	jmp	.L61
.L96:
	movslq	%edx, %rbp
	movl	(%rbx,%rbp,4), %eax
	testl	%eax, %eax
	jns	.L97
.L63:
	movl	%edx, (%rbx,%rcx,4)
	movl	%edx, %eax
	jmp	.L62
.L95:
	movslq	%edx, %r13
	movl	(%rbx,%r13,4), %eax
	testl	%eax, %eax
	jns	.L98
.L71:
	movl	%edx, (%rbx,%rbp,4)
	movl	%edx, %eax
	jmp	.L70
.L97:
	movslq	%eax, %r13
	movl	(%rbx,%r13,4), %edx
	testl	%edx, %edx
	jns	.L99
.L64:
	movl	%eax, (%rbx,%rbp,4)
	movl	%eax, %edx
	jmp	.L63
.L98:
	movslq	%eax, %r14
	movl	(%rbx,%r14,4), %edx
	testl	%edx, %edx
	jns	.L100
.L72:
	movl	%eax, (%rbx,%r13,4)
	movl	%eax, %edx
	jmp	.L71
.L99:
	movslq	%edx, %r14
	movl	(%rbx,%r14,4), %edi
	testl	%edi, %edi
	js	.L65
	call	find
	movl	%eax, (%rbx,%r14,4)
	movl	%eax, %edx
.L65:
	movl	%edx, (%rbx,%r13,4)
	movl	%edx, %eax
	jmp	.L64
.L100:
	movslq	%edx, %r15
	movl	(%rbx,%r15,4), %edi
	testl	%edi, %edi
	js	.L73
	call	find
	movl	%eax, (%rbx,%r15,4)
	movl	%eax, %edx
.L73:
	movl	%edx, (%rbx,%r14,4)
	movl	%edx, %eax
	jmp	.L72
.L92:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE37:
	.size	main, .-main
	.local	pp.0
	.comm	pp.0,400000,32
	.globl	dsu
	.bss
	.align 32
	.type	dsu, @object
	.size	dsu, 400000
dsu:
	.zero	400000
	.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:

/* Coached by rainboy */
#include <stdio.h>
#include <string.h>

#define N 100000

int dsu[N];

int find(int i) {
	return dsu[i] < 0 ? i : (dsu[i] = find(dsu[i]));
}

void join(int i, int j) {
	i = find(i);
	j = find(j);
	if (i == j)
		return;
	if (dsu[i] > dsu[j])
		dsu[i] = j;
	else {
		if (dsu[i] == dsu[j])
			dsu[i]--;
		dsu[j] = i;
	}
}

int main() {
	static int pp[N];
	int n, m, i, j, ans;

	scanf("%d%d", &n, &m);
	for (i = 0; i < n; i++)
		scanf("%d", &pp[i]), pp[i]--;
	memset(dsu, -1, n * sizeof *dsu);
	while (m--) {
		scanf("%d%d", &i, &j), i--, j--;
		join(i, j);
	}
	ans = 0;
	for (i = 0; i < n; i++)
		if (find(i) == find(pp[i]))
			ans++;
	printf("%d\n", ans);
	return 0;
}

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
/* Coached by rainboy */
#include <stdio.h>
#include <string.h>

#define N 100000

int dsu[N];

int find(int i) {
	return dsu[i] < 0 ? i : (dsu[i] = find(dsu[i]));
}

void join(int i, int j) {
	i = find(i);
	j = find(j);
	if (i == j)
		return;
	if (dsu[i] > dsu[j])
		dsu[i] = j;
	else {
		if (dsu[i] == dsu[j])
			dsu[i]--;
		dsu[j] = i;
	}
}

int main() {
	static int pp[N];
	int n, m, i, j, ans;

	scanf("%d%d", &n, &m);
	for (i = 0; i < n; i++)
		scanf("%d", &pp[i]), pp[i]--;
	memset(dsu, -1, n * sizeof *dsu);
	while (m--) {
		scanf("%d%d", &i, &j), i--, j--;
		join(i, j);
	}
	ans = 0;
	for (i = 0; i < n; i++)
		if (find(i) == find(pp[i]))
			ans++;
	printf("%d\n", ans);
	return 0;
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	dsu
	.bss
	.align 32
	.type	dsu, @object
	.size	dsu, 400000
dsu:
	.zero	400000
	.text
	.globl	find
	.type	find, @function
find:
.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	dsu(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	js	.L2
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	dsu(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, %edi
	call	find
	movl	-4(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	dsu(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	dsu(%rip), %rax
	movl	(%rdx,%rax), %eax
	jmp	.L4
.L2:
	movl	-4(%rbp), %eax
.L4:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	find, .-find
	.globl	join
	.type	join, @function
join:
.LFB1:
	.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	%esi, -8(%rbp)
	movl	-4(%rbp), %eax
	movl	%eax, %edi
	call	find
	movl	%eax, -4(%rbp)
	movl	-8(%rbp), %eax
	movl	%eax, %edi
	call	find
	movl	%eax, -8(%rbp)
	movl	-4(%rbp), %eax
	cmpl	-8(%rbp), %eax
	je	.L10
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	dsu(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	dsu(%rip), %rax
	movl	(%rcx,%rax), %eax
	cmpl	%eax, %edx
	jle	.L8
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	dsu(%rip), %rdx
	movl	-8(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	jmp	.L5
.L8:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	dsu(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	dsu(%rip), %rax
	movl	(%rcx,%rax), %eax
	cmpl	%eax, %edx
	jne	.L9
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	dsu(%rip), %rax
	movl	(%rdx,%rax), %eax
	leal	-1(%rax), %ecx
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	dsu(%rip), %rax
	movl	%ecx, (%rdx,%rax)
.L9:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	dsu(%rip), %rdx
	movl	-4(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	jmp	.L5
.L10:
	nop
.L5:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	join, .-join
	.section	.rodata
.LC0:
	.string	"%d%d"
.LC1:
	.string	"%d"
.LC2:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB2:
	.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
	leaq	-40(%rbp), %rdx
	leaq	-44(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -36(%rbp)
	jmp	.L12
.L13:
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	pp.0(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-36(%rbp), %eax
	movslq	%eax, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	pp.0(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	leal	-1(%rdx), %ecx
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	pp.0(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	-36(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -36(%rbp)
.L12:
	movl	-36(%rbp), %edx
	movl	-44(%rbp), %eax
	cmpl	%eax, %edx
	jl	.L13
	movl	-44(%rbp), %eax
	cltq
	salq	$2, %rax
	movq	%rax, %rdx
	movl	$-1, %esi
	leaq	dsu(%rip), %rax
	movq	%rax, %rdi
	call	memset@PLT
	jmp	.L14
.L15:
	leaq	-32(%rbp), %rdx
	leaq	-36(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-36(%rbp), %eax
	subl	$1, %eax
	movl	%eax, -36(%rbp)
	movl	-32(%rbp), %eax
	subl	$1, %eax
	movl	%eax, -32(%rbp)
	movl	-32(%rbp), %edx
	movl	-36(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	join
.L14:
	movl	-40(%rbp), %eax
	leal	-1(%rax), %edx
	movl	%edx, -40(%rbp)
	testl	%eax, %eax
	jne	.L15
	movl	$0, -28(%rbp)
	movl	$0, -36(%rbp)
	jmp	.L16
.L18:
	movl	-36(%rbp), %eax
	movl	%eax, %edi
	call	find
	movl	%eax, %ebx
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	pp.0(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, %edi
	call	find
	cmpl	%eax, %ebx
	jne	.L17
	addl	$1, -28(%rbp)
.L17:
	movl	-36(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -36(%rbp)
.L16:
	movl	-36(%rbp), %edx
	movl	-44(%rbp), %eax
	cmpl	%eax, %edx
	jl	.L18
	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	.L20
	call	__stack_chk_fail@PLT
.L20:
	movq	-8(%rbp), %rbx
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2:
	.size	main, .-main
	.local	pp.0
	.comm	pp.0,400000,32
	.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	dsu
	.bss
	.align 32
	.type	dsu, @object
	.size	dsu, 400000
dsu:
	.zero	400000
	.text
	.globl	find
	.type	find, @function
find:
.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	dsu(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	js	.L2
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	dsu(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, %edi
	call	find
	movl	-4(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	dsu(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	dsu(%rip), %rax
	movl	(%rdx,%rax), %eax
	jmp	.L4
.L2:
	movl	-4(%rbp), %eax
.L4:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	find, .-find
	.globl	join
	.type	join, @function
join:
.LFB1:
	.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	%esi, -8(%rbp)
	movl	-4(%rbp), %eax
	movl	%eax, %edi
	call	find
	movl	%eax, -4(%rbp)
	movl	-8(%rbp), %eax
	movl	%eax, %edi
	call	find
	movl	%eax, -8(%rbp)
	movl	-4(%rbp), %eax
	cmpl	-8(%rbp), %eax
	je	.L10
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	dsu(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	dsu(%rip), %rax
	movl	(%rcx,%rax), %eax
	cmpl	%eax, %edx
	jle	.L8
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	dsu(%rip), %rdx
	movl	-8(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	jmp	.L5
.L8:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	dsu(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	dsu(%rip), %rax
	movl	(%rcx,%rax), %eax
	cmpl	%eax, %edx
	jne	.L9
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	dsu(%rip), %rax
	movl	(%rdx,%rax), %eax
	leal	-1(%rax), %ecx
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	dsu(%rip), %rax
	movl	%ecx, (%rdx,%rax)
.L9:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	dsu(%rip), %rdx
	movl	-4(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	jmp	.L5
.L10:
	nop
.L5:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	join, .-join
	.section	.rodata
.LC0:
	.string	"%d%d"
.LC1:
	.string	"%d"
.LC2:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB2:
	.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
	leaq	-40(%rbp), %rdx
	leaq	-44(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -36(%rbp)
	jmp	.L12
.L13:
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	pp.0(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-36(%rbp), %eax
	movslq	%eax, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	pp.0(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	leal	-1(%rdx), %ecx
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	pp.0(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	-36(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -36(%rbp)
.L12:
	movl	-36(%rbp), %edx
	movl	-44(%rbp), %eax
	cmpl	%eax, %edx
	jl	.L13
	movl	-44(%rbp), %eax
	cltq
	salq	$2, %rax
	movq	%rax, %rdx
	movl	$-1, %esi
	leaq	dsu(%rip), %rax
	movq	%rax, %rdi
	call	memset@PLT
	jmp	.L14
.L15:
	leaq	-32(%rbp), %rdx
	leaq	-36(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-36(%rbp), %eax
	subl	$1, %eax
	movl	%eax, -36(%rbp)
	movl	-32(%rbp), %eax
	subl	$1, %eax
	movl	%eax, -32(%rbp)
	movl	-32(%rbp), %edx
	movl	-36(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	join
.L14:
	movl	-40(%rbp), %eax
	leal	-1(%rax), %edx
	movl	%edx, -40(%rbp)
	testl	%eax, %eax
	jne	.L15
	movl	$0, -28(%rbp)
	movl	$0, -36(%rbp)
	jmp	.L16
.L18:
	movl	-36(%rbp), %eax
	movl	%eax, %edi
	call	find
	movl	%eax, %ebx
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	pp.0(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, %edi
	call	find
	cmpl	%eax, %ebx
	jne	.L17
	addl	$1, -28(%rbp)
.L17:
	movl	-36(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -36(%rbp)
.L16:
	movl	-36(%rbp), %edx
	movl	-44(%rbp), %eax
	cmpl	%eax, %edx
	jl	.L18
	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	.L20
	call	__stack_chk_fail@PLT
.L20:
	movq	-8(%rbp), %rbx
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2:
	.size	main, .-main
	.local	pp.0
	.comm	pp.0,400000,32
	.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:
