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

```c
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <stdint.h>
#include <string.h>
#include <math.h>

uint32_t p[100000];

struct {
	uint32_t x;
	uint32_t y;
} swapList[100000];

uint32_t ufTree[100000];

static uint32_t getRootIdx(const uint32_t idx) {
	uint32_t nextIdx = idx;
	while (1) {
		if (ufTree[nextIdx] == UINT32_MAX) {
			if (idx != nextIdx) {
				ufTree[idx] = nextIdx;
			}
			return nextIdx;
		}
		nextIdx = ufTree[nextIdx];
	}
}

static void mergeTree(const uint32_t root0, const uint32_t root1) {
	ufTree[root1] = root0;
}

int main(void) {
	uint32_t N, M;

	scanf("%"PRIu32" %"PRIu32"\n", &N, &M);
	for (uint32_t idx = 0; idx < N - 1; idx++) {
		scanf("%"PRIu32" ", &(p[idx]));
		ufTree[idx] = UINT32_MAX;
	}
	scanf("%"PRIu32"\n", &(p[N - 1]));
	ufTree[N - 1] = UINT32_MAX;
	for (uint32_t idx = 0; idx < M - 1; idx++) {
		scanf("%"PRIu32" %"PRIu32"\n", &(swapList[idx].x), &(swapList[idx].y));
	}
	scanf("%"PRIu32" %"PRIu32, &(swapList[M - 1].x), &(swapList[M - 1].y));

	for (uint32_t idx = 0; idx < M; idx++) {
		const uint32_t xRoot = getRootIdx(swapList[idx].x - 1);
		const uint32_t yRoot = getRootIdx(swapList[idx].y - 1);
		if (xRoot != yRoot) {
			mergeTree(xRoot, yRoot);
			continue;
		}
	}

	uint32_t matchCount = 0;
	for (uint32_t idx = 0; idx < N; idx++) {
		if (getRootIdx(idx) == getRootIdx(p[idx] - 1)) {
			matchCount++;
		}
	}

	printf("%"PRIu32, matchCount);

	return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	p
	.bss
	.align 32
	.type	p, @object
	.size	p, 400000
p:
	.zero	400000
	.globl	swapList
	.align 32
	.type	swapList, @object
	.size	swapList, 800000
swapList:
	.zero	800000
	.globl	ufTree
	.align 32
	.type	ufTree, @object
	.size	ufTree, 400000
ufTree:
	.zero	400000
	.text
	.type	getRootIdx, @function
getRootIdx:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -20(%rbp)
	movl	-20(%rbp), %eax
	movl	%eax, -4(%rbp)
.L5:
	movl	-4(%rbp), %eax
	leaq	0(,%rax,4), %rdx
	leaq	ufTree(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	$-1, %eax
	jne	.L2
	movl	-20(%rbp), %eax
	cmpl	-4(%rbp), %eax
	je	.L3
	movl	-20(%rbp), %eax
	leaq	0(,%rax,4), %rcx
	leaq	ufTree(%rip), %rdx
	movl	-4(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
.L3:
	movl	-4(%rbp), %eax
	jmp	.L6
.L2:
	movl	-4(%rbp), %eax
	leaq	0(,%rax,4), %rdx
	leaq	ufTree(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -4(%rbp)
	jmp	.L5
.L6:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	getRootIdx, .-getRootIdx
	.type	mergeTree, @function
mergeTree:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -4(%rbp)
	movl	%esi, -8(%rbp)
	movl	-8(%rbp), %eax
	leaq	0(,%rax,4), %rcx
	leaq	ufTree(%rip), %rdx
	movl	-4(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	mergeTree, .-mergeTree
	.section	.rodata
.LC0:
	.string	"%u %u\n"
.LC1:
	.string	"%u "
.LC2:
	.string	"%u\n"
.LC3:
	.string	"%u %u"
.LC4:
	.string	"%u"
	.text
	.globl	main
	.type	main, @function
main:
.LFB8:
	.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	$56, %rsp
	.cfi_offset 3, -24
	movq	%fs:40, %rax
	movq	%rax, -24(%rbp)
	xorl	%eax, %eax
	leaq	-56(%rbp), %rdx
	leaq	-60(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -52(%rbp)
	jmp	.L9
.L10:
	movl	-52(%rbp), %eax
	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
	movl	-52(%rbp), %eax
	leaq	0(,%rax,4), %rdx
	leaq	ufTree(%rip), %rax
	movl	$-1, (%rdx,%rax)
	addl	$1, -52(%rbp)
.L9:
	movl	-60(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -52(%rbp)
	jb	.L10
	movl	-60(%rbp), %eax
	subl	$1, %eax
	movl	%eax, %eax
	leaq	0(,%rax,4), %rdx
	leaq	p(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-60(%rbp), %eax
	subl	$1, %eax
	movl	%eax, %eax
	leaq	0(,%rax,4), %rdx
	leaq	ufTree(%rip), %rax
	movl	$-1, (%rdx,%rax)
	movl	$0, -48(%rbp)
	jmp	.L11
.L12:
	movl	-48(%rbp), %eax
	leaq	0(,%rax,8), %rdx
	leaq	swapList(%rip), %rax
	addq	%rdx, %rax
	leaq	4(%rax), %rdx
	movl	-48(%rbp), %eax
	leaq	0(,%rax,8), %rcx
	leaq	swapList(%rip), %rax
	addq	%rcx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -48(%rbp)
.L11:
	movl	-56(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -48(%rbp)
	jb	.L12
	movl	-56(%rbp), %eax
	subl	$1, %eax
	movl	%eax, %eax
	leaq	0(,%rax,8), %rdx
	leaq	swapList(%rip), %rax
	addq	%rdx, %rax
	leaq	4(%rax), %rdx
	movl	-56(%rbp), %eax
	subl	$1, %eax
	movl	%eax, %eax
	leaq	0(,%rax,8), %rcx
	leaq	swapList(%rip), %rax
	addq	%rcx, %rax
	movq	%rax, %rsi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -44(%rbp)
	jmp	.L13
.L15:
	movl	-44(%rbp), %eax
	leaq	0(,%rax,8), %rdx
	leaq	swapList(%rip), %rax
	movl	(%rdx,%rax), %eax
	subl	$1, %eax
	movl	%eax, %edi
	call	getRootIdx
	movl	%eax, -32(%rbp)
	movl	-44(%rbp), %eax
	leaq	0(,%rax,8), %rdx
	leaq	4+swapList(%rip), %rax
	movl	(%rdx,%rax), %eax
	subl	$1, %eax
	movl	%eax, %edi
	call	getRootIdx
	movl	%eax, -28(%rbp)
	movl	-32(%rbp), %eax
	cmpl	-28(%rbp), %eax
	je	.L14
	movl	-28(%rbp), %edx
	movl	-32(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	mergeTree
	nop
.L14:
	addl	$1, -44(%rbp)
.L13:
	movl	-56(%rbp), %eax
	cmpl	%eax, -44(%rbp)
	jb	.L15
	movl	$0, -40(%rbp)
	movl	$0, -36(%rbp)
	jmp	.L16
.L18:
	movl	-36(%rbp), %eax
	movl	%eax, %edi
	call	getRootIdx
	movl	%eax, %ebx
	movl	-36(%rbp), %eax
	leaq	0(,%rax,4), %rdx
	leaq	p(%rip), %rax
	movl	(%rdx,%rax), %eax
	subl	$1, %eax
	movl	%eax, %edi
	call	getRootIdx
	cmpl	%eax, %ebx
	jne	.L17
	addl	$1, -40(%rbp)
.L17:
	addl	$1, -36(%rbp)
.L16:
	movl	-60(%rbp), %eax
	cmpl	%eax, -36(%rbp)
	jb	.L18
	movl	-40(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC4(%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
.LFE8:
	.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
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%u %u\n"
.LC1:
	.string	"%u "
.LC2:
	.string	"%u\n"
.LC3:
	.string	"%u %u"
.LC4:
	.string	"%u"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB53:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	leaq	.LC0(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	movq	%r12, %rdi
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	subq	$16, %rsp
	.cfi_def_cfa_offset 64
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	leaq	4(%rsp), %rdx
	movq	%rsp, %rsi
	call	__isoc99_scanf@PLT
	cmpl	$1, (%rsp)
	je	.L23
	xorl	%r13d, %r13d
	leaq	p(%rip), %rbp
	leaq	.LC1(%rip), %r14
	leaq	ufTree(%rip), %rbx
	.p2align 4,,10
	.p2align 3
.L3:
	leaq	0(%rbp,%r13,4), %rsi
	movq	%r14, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	(%rsp), %eax
	movl	$-1, (%rbx,%r13,4)
	addq	$1, %r13
	subl	$1, %eax
	cmpl	%r13d, %eax
	ja	.L3
.L2:
	leaq	0(%rbp,%rax,4), %rsi
	leaq	.LC2(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	(%rsp), %eax
	subl	$1, %eax
	cmpl	$1, 4(%rsp)
	movl	$-1, (%rbx,%rax,4)
	je	.L24
	xorl	%r13d, %r13d
	leaq	swapList(%rip), %r14
	.p2align 4,,10
	.p2align 3
.L5:
	movl	%r13d, %esi
	movq	%r12, %rdi
	xorl	%eax, %eax
	addl	$1, %r13d
	salq	$3, %rsi
	leaq	4(%rsi,%r14), %rdx
	addq	%r14, %rsi
	call	__isoc99_scanf@PLT
	movl	4(%rsp), %eax
	subl	$1, %eax
	cmpl	%r13d, %eax
	ja	.L5
.L4:
	salq	$3, %rax
	leaq	.LC3(%rip), %rdi
	leaq	4(%rax,%r14), %rdx
	leaq	(%rax,%r14), %rsi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	4(%rsp), %eax
	testl	%eax, %eax
	je	.L15
	leaq	swapList(%rip), %rdi
	leal	-1(%rax), %edx
	leaq	8(%rdi), %rax
	leaq	(%rax,%rdx,8), %r8
	.p2align 4,,10
	.p2align 3
.L14:
	movl	(%rdi), %eax
	leal	-1(%rax), %edx
	movl	%edx, %eax
	.p2align 4,,10
	.p2align 3
.L9:
	movl	%eax, %eax
	movq	%rax, %rcx
	movl	(%rbx,%rax,4), %eax
	cmpl	$-1, %eax
	jne	.L9
	cmpl	%ecx, %edx
	je	.L10
	movl	%edx, %edx
	movl	%ecx, (%rbx,%rdx,4)
.L10:
	movl	4(%rdi), %eax
	leal	-1(%rax), %esi
	movl	%esi, %eax
	.p2align 4,,10
	.p2align 3
.L11:
	movl	%eax, %eax
	movq	%rax, %rdx
	movl	(%rbx,%rax,4), %eax
	cmpl	$-1, %eax
	jne	.L11
	cmpl	%edx, %esi
	je	.L12
	movl	%esi, %esi
	movl	%edx, (%rbx,%rsi,4)
.L12:
	cmpl	%ecx, %edx
	je	.L13
	movl	%ecx, (%rbx,%rdx,4)
.L13:
	addq	$8, %rdi
	cmpq	%rdi, %r8
	jne	.L14
.L15:
	movl	(%rsp), %r8d
	testl	%r8d, %r8d
	je	.L8
	movl	%r8d, %r9d
	xorl	%edi, %edi
	xorl	%r8d, %r8d
	.p2align 4,,10
	.p2align 3
.L21:
	movl	%edi, %ecx
	movl	%edi, %eax
	.p2align 4,,10
	.p2align 3
.L16:
	movl	%eax, %eax
	movq	%rax, %rdx
	movl	(%rbx,%rax,4), %eax
	cmpl	$-1, %eax
	jne	.L16
	cmpl	%ecx, %edx
	je	.L17
	movl	%edx, (%rbx,%rdi,4)
.L17:
	movl	0(%rbp,%rdi,4), %eax
	leal	-1(%rax), %esi
	movl	%esi, %eax
	.p2align 4,,10
	.p2align 3
.L18:
	movl	%eax, %eax
	movq	%rax, %rcx
	movl	(%rbx,%rax,4), %eax
	cmpl	$-1, %eax
	jne	.L18
	cmpl	%ecx, %esi
	je	.L19
	movl	%esi, %esi
	movl	%ecx, (%rbx,%rsi,4)
.L19:
	xorl	%eax, %eax
	cmpl	%edx, %ecx
	sete	%al
	addq	$1, %rdi
	addl	%eax, %r8d
	cmpq	%rdi, %r9
	jne	.L21
.L8:
	xorl	%eax, %eax
	movl	%r8d, %edx
	movl	$1, %edi
	leaq	.LC4(%rip), %rsi
	call	__printf_chk@PLT
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L35
	addq	$16, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 48
	xorl	%eax, %eax
	popq	%rbx
	.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
.L23:
	.cfi_restore_state
	xorl	%eax, %eax
	leaq	p(%rip), %rbp
	leaq	ufTree(%rip), %rbx
	jmp	.L2
.L24:
	xorl	%eax, %eax
	leaq	swapList(%rip), %r14
	jmp	.L4
.L35:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE53:
	.size	main, .-main
	.globl	ufTree
	.bss
	.align 32
	.type	ufTree, @object
	.size	ufTree, 400000
ufTree:
	.zero	400000
	.globl	swapList
	.align 32
	.type	swapList, @object
	.size	swapList, 800000
swapList:
	.zero	800000
	.globl	p
	.align 32
	.type	p, @object
	.size	p, 400000
p:
	.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
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%u %u\n"
.LC1:
	.string	"%u "
.LC2:
	.string	"%u\n"
.LC3:
	.string	"%u %u"
.LC4:
	.string	"%u"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB53:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	leaq	.LC0(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	movq	%r12, %rdi
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	subq	$16, %rsp
	.cfi_def_cfa_offset 64
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	leaq	4(%rsp), %rdx
	movq	%rsp, %rsi
	call	__isoc99_scanf@PLT
	cmpl	$1, (%rsp)
	je	.L23
	xorl	%r13d, %r13d
	leaq	p(%rip), %rbp
	leaq	.LC1(%rip), %r14
	leaq	ufTree(%rip), %rbx
	.p2align 4,,10
	.p2align 3
.L3:
	leaq	0(%rbp,%r13,4), %rsi
	movq	%r14, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	(%rsp), %eax
	movl	$-1, (%rbx,%r13,4)
	addq	$1, %r13
	subl	$1, %eax
	cmpl	%r13d, %eax
	ja	.L3
.L2:
	leaq	0(%rbp,%rax,4), %rsi
	leaq	.LC2(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	(%rsp), %eax
	subl	$1, %eax
	cmpl	$1, 4(%rsp)
	movl	$-1, (%rbx,%rax,4)
	je	.L24
	xorl	%r13d, %r13d
	leaq	swapList(%rip), %r14
	.p2align 4,,10
	.p2align 3
.L5:
	movl	%r13d, %esi
	movq	%r12, %rdi
	xorl	%eax, %eax
	addl	$1, %r13d
	salq	$3, %rsi
	leaq	4(%rsi,%r14), %rdx
	addq	%r14, %rsi
	call	__isoc99_scanf@PLT
	movl	4(%rsp), %eax
	subl	$1, %eax
	cmpl	%r13d, %eax
	ja	.L5
.L4:
	salq	$3, %rax
	leaq	.LC3(%rip), %rdi
	leaq	4(%rax,%r14), %rdx
	leaq	(%rax,%r14), %rsi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	4(%rsp), %eax
	testl	%eax, %eax
	je	.L15
	leaq	swapList(%rip), %rdi
	leal	-1(%rax), %edx
	leaq	8(%rdi), %rax
	leaq	(%rax,%rdx,8), %r8
	.p2align 4,,10
	.p2align 3
.L14:
	movl	(%rdi), %eax
	leal	-1(%rax), %edx
	movl	%edx, %eax
	.p2align 4,,10
	.p2align 3
.L9:
	movl	%eax, %eax
	movq	%rax, %rcx
	movl	(%rbx,%rax,4), %eax
	cmpl	$-1, %eax
	jne	.L9
	cmpl	%ecx, %edx
	je	.L10
	movl	%edx, %edx
	movl	%ecx, (%rbx,%rdx,4)
.L10:
	movl	4(%rdi), %eax
	leal	-1(%rax), %esi
	movl	%esi, %eax
	.p2align 4,,10
	.p2align 3
.L11:
	movl	%eax, %eax
	movq	%rax, %rdx
	movl	(%rbx,%rax,4), %eax
	cmpl	$-1, %eax
	jne	.L11
	cmpl	%edx, %esi
	je	.L12
	movl	%esi, %esi
	movl	%edx, (%rbx,%rsi,4)
.L12:
	cmpl	%ecx, %edx
	je	.L13
	movl	%ecx, (%rbx,%rdx,4)
.L13:
	addq	$8, %rdi
	cmpq	%rdi, %r8
	jne	.L14
.L15:
	movl	(%rsp), %r8d
	testl	%r8d, %r8d
	je	.L8
	movl	%r8d, %r9d
	xorl	%edi, %edi
	xorl	%r8d, %r8d
	.p2align 4,,10
	.p2align 3
.L21:
	movl	%edi, %ecx
	movl	%edi, %eax
	.p2align 4,,10
	.p2align 3
.L16:
	movl	%eax, %eax
	movq	%rax, %rdx
	movl	(%rbx,%rax,4), %eax
	cmpl	$-1, %eax
	jne	.L16
	cmpl	%ecx, %edx
	je	.L17
	movl	%edx, (%rbx,%rdi,4)
.L17:
	movl	0(%rbp,%rdi,4), %eax
	leal	-1(%rax), %esi
	movl	%esi, %eax
	.p2align 4,,10
	.p2align 3
.L18:
	movl	%eax, %eax
	movq	%rax, %rcx
	movl	(%rbx,%rax,4), %eax
	cmpl	$-1, %eax
	jne	.L18
	cmpl	%ecx, %esi
	je	.L19
	movl	%esi, %esi
	movl	%ecx, (%rbx,%rsi,4)
.L19:
	xorl	%eax, %eax
	cmpl	%edx, %ecx
	sete	%al
	addq	$1, %rdi
	addl	%eax, %r8d
	cmpq	%rdi, %r9
	jne	.L21
.L8:
	xorl	%eax, %eax
	movl	%r8d, %edx
	movl	$1, %edi
	leaq	.LC4(%rip), %rsi
	call	__printf_chk@PLT
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L35
	addq	$16, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 48
	xorl	%eax, %eax
	popq	%rbx
	.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
.L23:
	.cfi_restore_state
	xorl	%eax, %eax
	leaq	p(%rip), %rbp
	leaq	ufTree(%rip), %rbx
	jmp	.L2
.L24:
	xorl	%eax, %eax
	leaq	swapList(%rip), %r14
	jmp	.L4
.L35:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE53:
	.size	main, .-main
	.globl	ufTree
	.bss
	.align 32
	.type	ufTree, @object
	.size	ufTree, 400000
ufTree:
	.zero	400000
	.globl	swapList
	.align 32
	.type	swapList, @object
	.size	swapList, 800000
swapList:
	.zero	800000
	.globl	p
	.align 32
	.type	p, @object
	.size	p, 400000
p:
	.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:

#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <stdint.h>
#include <string.h>
#include <math.h>

uint32_t p[100000];

struct {
	uint32_t x;
	uint32_t y;
} swapList[100000];

uint32_t ufTree[100000];

static uint32_t getRootIdx(const uint32_t idx) {
	uint32_t nextIdx = idx;
	while (1) {
		if (ufTree[nextIdx] == UINT32_MAX) {
			if (idx != nextIdx) {
				ufTree[idx] = nextIdx;
			}
			return nextIdx;
		}
		nextIdx = ufTree[nextIdx];
	}
}

static void mergeTree(const uint32_t root0, const uint32_t root1) {
	ufTree[root1] = root0;
}

int main(void) {
	uint32_t N, M;

	scanf("%"PRIu32" %"PRIu32"\n", &N, &M);
	for (uint32_t idx = 0; idx < N - 1; idx++) {
		scanf("%"PRIu32" ", &(p[idx]));
		ufTree[idx] = UINT32_MAX;
	}
	scanf("%"PRIu32"\n", &(p[N - 1]));
	ufTree[N - 1] = UINT32_MAX;
	for (uint32_t idx = 0; idx < M - 1; idx++) {
		scanf("%"PRIu32" %"PRIu32"\n", &(swapList[idx].x), &(swapList[idx].y));
	}
	scanf("%"PRIu32" %"PRIu32, &(swapList[M - 1].x), &(swapList[M - 1].y));

	for (uint32_t idx = 0; idx < M; idx++) {
		const uint32_t xRoot = getRootIdx(swapList[idx].x - 1);
		const uint32_t yRoot = getRootIdx(swapList[idx].y - 1);
		if (xRoot != yRoot) {
			mergeTree(xRoot, yRoot);
			continue;
		}
	}

	uint32_t matchCount = 0;
	for (uint32_t idx = 0; idx < N; idx++) {
		if (getRootIdx(idx) == getRootIdx(p[idx] - 1)) {
			matchCount++;
		}
	}

	printf("%"PRIu32, matchCount);

	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
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <stdint.h>
#include <string.h>
#include <math.h>

uint32_t p[100000];

struct {
	uint32_t x;
	uint32_t y;
} swapList[100000];

uint32_t ufTree[100000];

static uint32_t getRootIdx(const uint32_t idx) {
	uint32_t nextIdx = idx;
	while (1) {
		if (ufTree[nextIdx] == UINT32_MAX) {
			if (idx != nextIdx) {
				ufTree[idx] = nextIdx;
			}
			return nextIdx;
		}
		nextIdx = ufTree[nextIdx];
	}
}

static void mergeTree(const uint32_t root0, const uint32_t root1) {
	ufTree[root1] = root0;
}

int main(void) {
	uint32_t N, M;

	scanf("%"PRIu32" %"PRIu32"\n", &N, &M);
	for (uint32_t idx = 0; idx < N - 1; idx++) {
		scanf("%"PRIu32" ", &(p[idx]));
		ufTree[idx] = UINT32_MAX;
	}
	scanf("%"PRIu32"\n", &(p[N - 1]));
	ufTree[N - 1] = UINT32_MAX;
	for (uint32_t idx = 0; idx < M - 1; idx++) {
		scanf("%"PRIu32" %"PRIu32"\n", &(swapList[idx].x), &(swapList[idx].y));
	}
	scanf("%"PRIu32" %"PRIu32, &(swapList[M - 1].x), &(swapList[M - 1].y));

	for (uint32_t idx = 0; idx < M; idx++) {
		const uint32_t xRoot = getRootIdx(swapList[idx].x - 1);
		const uint32_t yRoot = getRootIdx(swapList[idx].y - 1);
		if (xRoot != yRoot) {
			mergeTree(xRoot, yRoot);
			continue;
		}
	}

	uint32_t matchCount = 0;
	for (uint32_t idx = 0; idx < N; idx++) {
		if (getRootIdx(idx) == getRootIdx(p[idx] - 1)) {
			matchCount++;
		}
	}

	printf("%"PRIu32, matchCount);

	return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	p
	.bss
	.align 32
	.type	p, @object
	.size	p, 400000
p:
	.zero	400000
	.globl	swapList
	.align 32
	.type	swapList, @object
	.size	swapList, 800000
swapList:
	.zero	800000
	.globl	ufTree
	.align 32
	.type	ufTree, @object
	.size	ufTree, 400000
ufTree:
	.zero	400000
	.text
	.type	getRootIdx, @function
getRootIdx:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -20(%rbp)
	movl	-20(%rbp), %eax
	movl	%eax, -4(%rbp)
.L5:
	movl	-4(%rbp), %eax
	leaq	0(,%rax,4), %rdx
	leaq	ufTree(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	$-1, %eax
	jne	.L2
	movl	-20(%rbp), %eax
	cmpl	-4(%rbp), %eax
	je	.L3
	movl	-20(%rbp), %eax
	leaq	0(,%rax,4), %rcx
	leaq	ufTree(%rip), %rdx
	movl	-4(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
.L3:
	movl	-4(%rbp), %eax
	jmp	.L6
.L2:
	movl	-4(%rbp), %eax
	leaq	0(,%rax,4), %rdx
	leaq	ufTree(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -4(%rbp)
	jmp	.L5
.L6:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	getRootIdx, .-getRootIdx
	.type	mergeTree, @function
mergeTree:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -4(%rbp)
	movl	%esi, -8(%rbp)
	movl	-8(%rbp), %eax
	leaq	0(,%rax,4), %rcx
	leaq	ufTree(%rip), %rdx
	movl	-4(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	mergeTree, .-mergeTree
	.section	.rodata
.LC0:
	.string	"%u %u\n"
.LC1:
	.string	"%u "
.LC2:
	.string	"%u\n"
.LC3:
	.string	"%u %u"
.LC4:
	.string	"%u"
	.text
	.globl	main
	.type	main, @function
main:
.LFB8:
	.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	$56, %rsp
	.cfi_offset 3, -24
	movq	%fs:40, %rax
	movq	%rax, -24(%rbp)
	xorl	%eax, %eax
	leaq	-56(%rbp), %rdx
	leaq	-60(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -52(%rbp)
	jmp	.L9
.L10:
	movl	-52(%rbp), %eax
	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
	movl	-52(%rbp), %eax
	leaq	0(,%rax,4), %rdx
	leaq	ufTree(%rip), %rax
	movl	$-1, (%rdx,%rax)
	addl	$1, -52(%rbp)
.L9:
	movl	-60(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -52(%rbp)
	jb	.L10
	movl	-60(%rbp), %eax
	subl	$1, %eax
	movl	%eax, %eax
	leaq	0(,%rax,4), %rdx
	leaq	p(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-60(%rbp), %eax
	subl	$1, %eax
	movl	%eax, %eax
	leaq	0(,%rax,4), %rdx
	leaq	ufTree(%rip), %rax
	movl	$-1, (%rdx,%rax)
	movl	$0, -48(%rbp)
	jmp	.L11
.L12:
	movl	-48(%rbp), %eax
	leaq	0(,%rax,8), %rdx
	leaq	swapList(%rip), %rax
	addq	%rdx, %rax
	leaq	4(%rax), %rdx
	movl	-48(%rbp), %eax
	leaq	0(,%rax,8), %rcx
	leaq	swapList(%rip), %rax
	addq	%rcx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -48(%rbp)
.L11:
	movl	-56(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -48(%rbp)
	jb	.L12
	movl	-56(%rbp), %eax
	subl	$1, %eax
	movl	%eax, %eax
	leaq	0(,%rax,8), %rdx
	leaq	swapList(%rip), %rax
	addq	%rdx, %rax
	leaq	4(%rax), %rdx
	movl	-56(%rbp), %eax
	subl	$1, %eax
	movl	%eax, %eax
	leaq	0(,%rax,8), %rcx
	leaq	swapList(%rip), %rax
	addq	%rcx, %rax
	movq	%rax, %rsi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -44(%rbp)
	jmp	.L13
.L15:
	movl	-44(%rbp), %eax
	leaq	0(,%rax,8), %rdx
	leaq	swapList(%rip), %rax
	movl	(%rdx,%rax), %eax
	subl	$1, %eax
	movl	%eax, %edi
	call	getRootIdx
	movl	%eax, -32(%rbp)
	movl	-44(%rbp), %eax
	leaq	0(,%rax,8), %rdx
	leaq	4+swapList(%rip), %rax
	movl	(%rdx,%rax), %eax
	subl	$1, %eax
	movl	%eax, %edi
	call	getRootIdx
	movl	%eax, -28(%rbp)
	movl	-32(%rbp), %eax
	cmpl	-28(%rbp), %eax
	je	.L14
	movl	-28(%rbp), %edx
	movl	-32(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	mergeTree
	nop
.L14:
	addl	$1, -44(%rbp)
.L13:
	movl	-56(%rbp), %eax
	cmpl	%eax, -44(%rbp)
	jb	.L15
	movl	$0, -40(%rbp)
	movl	$0, -36(%rbp)
	jmp	.L16
.L18:
	movl	-36(%rbp), %eax
	movl	%eax, %edi
	call	getRootIdx
	movl	%eax, %ebx
	movl	-36(%rbp), %eax
	leaq	0(,%rax,4), %rdx
	leaq	p(%rip), %rax
	movl	(%rdx,%rax), %eax
	subl	$1, %eax
	movl	%eax, %edi
	call	getRootIdx
	cmpl	%eax, %ebx
	jne	.L17
	addl	$1, -40(%rbp)
.L17:
	addl	$1, -36(%rbp)
.L16:
	movl	-60(%rbp), %eax
	cmpl	%eax, -36(%rbp)
	jb	.L18
	movl	-40(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC4(%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
.LFE8:
	.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	p
	.bss
	.align 32
	.type	p, @object
	.size	p, 400000
p:
	.zero	400000
	.globl	swapList
	.align 32
	.type	swapList, @object
	.size	swapList, 800000
swapList:
	.zero	800000
	.globl	ufTree
	.align 32
	.type	ufTree, @object
	.size	ufTree, 400000
ufTree:
	.zero	400000
	.text
	.type	getRootIdx, @function
getRootIdx:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -20(%rbp)
	movl	-20(%rbp), %eax
	movl	%eax, -4(%rbp)
.L5:
	movl	-4(%rbp), %eax
	leaq	0(,%rax,4), %rdx
	leaq	ufTree(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	$-1, %eax
	jne	.L2
	movl	-20(%rbp), %eax
	cmpl	-4(%rbp), %eax
	je	.L3
	movl	-20(%rbp), %eax
	leaq	0(,%rax,4), %rcx
	leaq	ufTree(%rip), %rdx
	movl	-4(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
.L3:
	movl	-4(%rbp), %eax
	jmp	.L6
.L2:
	movl	-4(%rbp), %eax
	leaq	0(,%rax,4), %rdx
	leaq	ufTree(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -4(%rbp)
	jmp	.L5
.L6:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	getRootIdx, .-getRootIdx
	.type	mergeTree, @function
mergeTree:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -4(%rbp)
	movl	%esi, -8(%rbp)
	movl	-8(%rbp), %eax
	leaq	0(,%rax,4), %rcx
	leaq	ufTree(%rip), %rdx
	movl	-4(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	mergeTree, .-mergeTree
	.section	.rodata
.LC0:
	.string	"%u %u\n"
.LC1:
	.string	"%u "
.LC2:
	.string	"%u\n"
.LC3:
	.string	"%u %u"
.LC4:
	.string	"%u"
	.text
	.globl	main
	.type	main, @function
main:
.LFB8:
	.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	$56, %rsp
	.cfi_offset 3, -24
	movq	%fs:40, %rax
	movq	%rax, -24(%rbp)
	xorl	%eax, %eax
	leaq	-56(%rbp), %rdx
	leaq	-60(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -52(%rbp)
	jmp	.L9
.L10:
	movl	-52(%rbp), %eax
	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
	movl	-52(%rbp), %eax
	leaq	0(,%rax,4), %rdx
	leaq	ufTree(%rip), %rax
	movl	$-1, (%rdx,%rax)
	addl	$1, -52(%rbp)
.L9:
	movl	-60(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -52(%rbp)
	jb	.L10
	movl	-60(%rbp), %eax
	subl	$1, %eax
	movl	%eax, %eax
	leaq	0(,%rax,4), %rdx
	leaq	p(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-60(%rbp), %eax
	subl	$1, %eax
	movl	%eax, %eax
	leaq	0(,%rax,4), %rdx
	leaq	ufTree(%rip), %rax
	movl	$-1, (%rdx,%rax)
	movl	$0, -48(%rbp)
	jmp	.L11
.L12:
	movl	-48(%rbp), %eax
	leaq	0(,%rax,8), %rdx
	leaq	swapList(%rip), %rax
	addq	%rdx, %rax
	leaq	4(%rax), %rdx
	movl	-48(%rbp), %eax
	leaq	0(,%rax,8), %rcx
	leaq	swapList(%rip), %rax
	addq	%rcx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -48(%rbp)
.L11:
	movl	-56(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -48(%rbp)
	jb	.L12
	movl	-56(%rbp), %eax
	subl	$1, %eax
	movl	%eax, %eax
	leaq	0(,%rax,8), %rdx
	leaq	swapList(%rip), %rax
	addq	%rdx, %rax
	leaq	4(%rax), %rdx
	movl	-56(%rbp), %eax
	subl	$1, %eax
	movl	%eax, %eax
	leaq	0(,%rax,8), %rcx
	leaq	swapList(%rip), %rax
	addq	%rcx, %rax
	movq	%rax, %rsi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -44(%rbp)
	jmp	.L13
.L15:
	movl	-44(%rbp), %eax
	leaq	0(,%rax,8), %rdx
	leaq	swapList(%rip), %rax
	movl	(%rdx,%rax), %eax
	subl	$1, %eax
	movl	%eax, %edi
	call	getRootIdx
	movl	%eax, -32(%rbp)
	movl	-44(%rbp), %eax
	leaq	0(,%rax,8), %rdx
	leaq	4+swapList(%rip), %rax
	movl	(%rdx,%rax), %eax
	subl	$1, %eax
	movl	%eax, %edi
	call	getRootIdx
	movl	%eax, -28(%rbp)
	movl	-32(%rbp), %eax
	cmpl	-28(%rbp), %eax
	je	.L14
	movl	-28(%rbp), %edx
	movl	-32(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	mergeTree
	nop
.L14:
	addl	$1, -44(%rbp)
.L13:
	movl	-56(%rbp), %eax
	cmpl	%eax, -44(%rbp)
	jb	.L15
	movl	$0, -40(%rbp)
	movl	$0, -36(%rbp)
	jmp	.L16
.L18:
	movl	-36(%rbp), %eax
	movl	%eax, %edi
	call	getRootIdx
	movl	%eax, %ebx
	movl	-36(%rbp), %eax
	leaq	0(,%rax,4), %rdx
	leaq	p(%rip), %rax
	movl	(%rdx,%rax), %eax
	subl	$1, %eax
	movl	%eax, %edi
	call	getRootIdx
	cmpl	%eax, %ebx
	jne	.L17
	addl	$1, -40(%rbp)
.L17:
	addl	$1, -36(%rbp)
.L16:
	movl	-60(%rbp), %eax
	cmpl	%eax, -36(%rbp)
	jb	.L18
	movl	-40(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC4(%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
.LFE8:
	.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:
