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>
#include<stdlib.h>
#
int n,v,e[100001][3],i,p[10001],r=0;

int c(const void *x,const void *y)
{
	return ((int*)x)[2]-((int*)y)[2];
}

int a(int x)
{
	return p[x]==x?x:a(p[x]);
}

int main()
{
	scanf("%d%d",&n,&v);
	for(i=0;i<=n;i++)
		p[i]=i;
	for(i=0;i<v;i++)
		scanf("%d%d%d",&e[i][0],&e[i][1],&e[i][2]);
	qsort(e,v,sizeof(int[3]),c);
	for(i=0;i<v;i++)
		if(a(e[i][0])!=a(e[i][1]))
		{
			r+=e[i][2];
			p[a(e[i][0])]=p[a(e[i][1])];
		}
	printf("%d\n",r);
	return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	n
	.bss
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	v
	.align 4
	.type	v, @object
	.size	v, 4
v:
	.zero	4
	.globl	e
	.align 32
	.type	e, @object
	.size	e, 1200012
e:
	.zero	1200012
	.globl	i
	.align 4
	.type	i, @object
	.size	i, 4
i:
	.zero	4
	.globl	p
	.align 32
	.type	p, @object
	.size	p, 40004
p:
	.zero	40004
	.globl	r
	.align 4
	.type	r, @object
	.size	r, 4
r:
	.zero	4
	.text
	.globl	c
	.type	c, @function
c:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -8(%rbp)
	movq	%rsi, -16(%rbp)
	movq	-8(%rbp), %rax
	addq	$8, %rax
	movl	(%rax), %eax
	movq	-16(%rbp), %rdx
	addq	$8, %rdx
	movl	(%rdx), %edx
	subl	%edx, %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	c, .-c
	.globl	a
	.type	a, @function
a:
.LFB7:
	.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	p(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -4(%rbp)
	je	.L4
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	p(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, %edi
	call	a
	jmp	.L6
.L4:
	movl	-4(%rbp), %eax
.L6:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	a, .-a
	.section	.rodata
.LC0:
	.string	"%d%d"
.LC1:
	.string	"%d%d%d"
.LC2:
	.string	"%d\n"
	.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	$8, %rsp
	.cfi_offset 3, -24
	leaq	v(%rip), %rax
	movq	%rax, %rdx
	leaq	n(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, i(%rip)
	jmp	.L8
.L9:
	movl	i(%rip), %edx
	movl	i(%rip), %eax
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	p(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movl	i(%rip), %eax
	addl	$1, %eax
	movl	%eax, i(%rip)
.L8:
	movl	i(%rip), %edx
	movl	n(%rip), %eax
	cmpl	%eax, %edx
	jle	.L9
	movl	$0, i(%rip)
	jmp	.L10
.L11:
	movl	i(%rip), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	leaq	8(%rax), %rdx
	leaq	e(%rip), %rax
	leaq	(%rdx,%rax), %rcx
	movl	i(%rip), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	leaq	4(%rax), %rdx
	leaq	e(%rip), %rax
	addq	%rax, %rdx
	movl	i(%rip), %eax
	movslq	%eax, %rsi
	movq	%rsi, %rax
	addq	%rax, %rax
	addq	%rsi, %rax
	salq	$2, %rax
	leaq	e(%rip), %rsi
	addq	%rsi, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	i(%rip), %eax
	addl	$1, %eax
	movl	%eax, i(%rip)
.L10:
	movl	i(%rip), %edx
	movl	v(%rip), %eax
	cmpl	%eax, %edx
	jl	.L11
	movl	v(%rip), %eax
	cltq
	leaq	c(%rip), %rdx
	movq	%rdx, %rcx
	movl	$12, %edx
	movq	%rax, %rsi
	leaq	e(%rip), %rax
	movq	%rax, %rdi
	call	qsort@PLT
	movl	$0, i(%rip)
	jmp	.L12
.L14:
	movl	i(%rip), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	leaq	e(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, %edi
	call	a
	movl	%eax, %ebx
	movl	i(%rip), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	leaq	4+e(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, %edi
	call	a
	cmpl	%eax, %ebx
	je	.L13
	movl	i(%rip), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	leaq	8+e(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	r(%rip), %eax
	addl	%edx, %eax
	movl	%eax, r(%rip)
	movl	i(%rip), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	leaq	4+e(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, %edi
	call	a
	movl	%eax, %ebx
	movl	i(%rip), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	leaq	e(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, %edi
	call	a
	movl	%eax, %edx
	movslq	%ebx, %rax
	leaq	0(,%rax,4), %rcx
	leaq	p(%rip), %rax
	movl	(%rcx,%rax), %eax
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	p(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
.L13:
	movl	i(%rip), %eax
	addl	$1, %eax
	movl	%eax, i(%rip)
.L12:
	movl	i(%rip), %edx
	movl	v(%rip), %eax
	cmpl	%eax, %edx
	jl	.L14
	movl	r(%rip), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	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
	.p2align 4
	.globl	c
	.type	c, @function
c:
.LFB39:
	.cfi_startproc
	endbr64
	movl	8(%rdi), %eax
	subl	8(%rsi), %eax
	ret
	.cfi_endproc
.LFE39:
	.size	c, .-c
	.p2align 4
	.globl	a
	.type	a, @function
a:
.LFB40:
	.cfi_startproc
	endbr64
	movl	%edi, %eax
	leaq	p(%rip), %rcx
	.p2align 4,,10
	.p2align 3
.L4:
	cltq
	movq	%rax, %rdx
	movl	(%rcx,%rax,4), %eax
	cmpl	%edx, %eax
	jne	.L4
	ret
	.cfi_endproc
.LFE40:
	.size	a, .-a
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC1:
	.string	"%d%d"
.LC3:
	.string	"%d%d%d"
.LC4:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB41:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	leaq	v(%rip), %rdx
	leaq	n(%rip), %rsi
	xorl	%eax, %eax
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	leaq	.LC1(%rip), %rdi
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	call	__isoc99_scanf@PLT
	movl	n(%rip), %ecx
	testl	%ecx, %ecx
	js	.L7
	leal	1(%rcx), %edi
	cmpl	$2, %ecx
	jle	.L22
	movl	%edi, %edx
	leaq	p(%rip), %rsi
	movdqa	.LC0(%rip), %xmm0
	movdqa	.LC2(%rip), %xmm2
	shrl	$2, %edx
	leaq	16(%rsi), %r8
	movq	%rsi, %rax
	subl	$1, %edx
	salq	$4, %rdx
	addq	%r8, %rdx
	.p2align 4,,10
	.p2align 3
.L9:
	movdqa	%xmm0, %xmm1
	addq	$16, %rax
	paddd	%xmm2, %xmm0
	movaps	%xmm1, -16(%rax)
	cmpq	%rdx, %rax
	jne	.L9
	movl	%edi, %eax
	andl	$-4, %eax
	andl	$3, %edi
	je	.L7
.L8:
	movslq	%eax, %rdx
	movl	%eax, (%rsi,%rdx,4)
	leal	1(%rax), %edx
	cmpl	%ecx, %edx
	jg	.L7
	movslq	%edx, %rdi
	addl	$2, %eax
	movl	%edx, (%rsi,%rdi,4)
	cmpl	%eax, %ecx
	jl	.L7
	movslq	%eax, %rdx
	movl	%eax, (%rsi,%rdx,4)
.L7:
	movl	v(%rip), %edx
	leaq	e(%rip), %r12
	movl	$0, i(%rip)
	testl	%edx, %edx
	jle	.L11
	xorl	%eax, %eax
	leaq	.LC3(%rip), %rbx
	.p2align 4,,10
	.p2align 3
.L12:
	cltq
	movq	%rbx, %rdi
	leaq	(%rax,%rax,2), %rsi
	xorl	%eax, %eax
	salq	$2, %rsi
	leaq	4(%rsi,%r12), %rdx
	leaq	8(%rsi,%r12), %rcx
	addq	%r12, %rsi
	call	__isoc99_scanf@PLT
	movl	i(%rip), %eax
	movl	v(%rip), %edx
	addl	$1, %eax
	movl	%eax, i(%rip)
	cmpl	%edx, %eax
	jl	.L12
.L11:
	movslq	%edx, %rsi
	movq	%r12, %rdi
	leaq	c(%rip), %rcx
	movl	$12, %edx
	call	qsort@PLT
	movl	v(%rip), %ebx
	movl	$0, i(%rip)
	movl	r(%rip), %r12d
	testl	%ebx, %ebx
	jle	.L14
	leal	-1(%rbx), %eax
	leaq	e(%rip), %r9
	movl	%r12d, %r11d
	xorl	%ebp, %ebp
	leaq	(%rax,%rax,2), %rdx
	leaq	12(%r9), %rax
	leaq	(%rax,%rdx,4), %r10
	leaq	p(%rip), %rsi
	.p2align 4,,10
	.p2align 3
.L20:
	movl	(%r9), %edi
	movl	%edi, %eax
	.p2align 4,,10
	.p2align 3
.L15:
	cltq
	movq	%rax, %rdx
	movl	(%rsi,%rax,4), %eax
	cmpl	%eax, %edx
	jne	.L15
	movl	4(%r9), %r8d
	movl	%r8d, %eax
	.p2align 4,,10
	.p2align 3
.L16:
	cltq
	movq	%rax, %rcx
	movl	(%rsi,%rax,4), %eax
	cmpl	%ecx, %eax
	jne	.L16
	cmpl	%edx, %eax
	jne	.L35
.L17:
	addq	$12, %r9
	cmpq	%r10, %r9
	jne	.L20
	movl	%ebx, i(%rip)
	testb	%bpl, %bpl
	je	.L14
	movl	%r11d, r(%rip)
	movl	%r11d, %r12d
.L14:
	movl	%r12d, %edx
	leaq	.LC4(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	popq	%rbx
	.cfi_remember_state
	.cfi_def_cfa_offset 24
	xorl	%eax, %eax
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L35:
	.cfi_restore_state
	addl	8(%r9), %r11d
	.p2align 4,,10
	.p2align 3
.L18:
	movslq	%r8d, %rdx
	movl	(%rsi,%rdx,4), %r8d
	cmpl	%r8d, %edx
	jne	.L18
	.p2align 4,,10
	.p2align 3
.L19:
	movslq	%edi, %rdx
	movslq	(%rsi,%rdx,4), %rdi
	cmpl	%edi, %edx
	jne	.L19
	movl	%r8d, (%rsi,%rdi,4)
	movl	$1, %ebp
	jmp	.L17
.L22:
	xorl	%eax, %eax
	leaq	p(%rip), %rsi
	jmp	.L8
	.cfi_endproc
.LFE41:
	.size	main, .-main
	.globl	r
	.bss
	.align 4
	.type	r, @object
	.size	r, 4
r:
	.zero	4
	.globl	p
	.align 32
	.type	p, @object
	.size	p, 40004
p:
	.zero	40004
	.globl	i
	.align 4
	.type	i, @object
	.size	i, 4
i:
	.zero	4
	.globl	e
	.align 32
	.type	e, @object
	.size	e, 1200012
e:
	.zero	1200012
	.globl	v
	.align 4
	.type	v, @object
	.size	v, 4
v:
	.zero	4
	.globl	n
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.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	c
	.type	c, @function
c:
.LFB39:
	.cfi_startproc
	endbr64
	movl	8(%rdi), %eax
	subl	8(%rsi), %eax
	ret
	.cfi_endproc
.LFE39:
	.size	c, .-c
	.p2align 4
	.globl	a
	.type	a, @function
a:
.LFB40:
	.cfi_startproc
	endbr64
	movl	%edi, %eax
	leaq	p(%rip), %rcx
	.p2align 4,,10
	.p2align 3
.L4:
	cltq
	movq	%rax, %rdx
	movl	(%rcx,%rax,4), %eax
	cmpl	%edx, %eax
	jne	.L4
	ret
	.cfi_endproc
.LFE40:
	.size	a, .-a
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC1:
	.string	"%d%d"
.LC3:
	.string	"%d%d%d"
.LC4:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB41:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	leaq	v(%rip), %rdx
	leaq	n(%rip), %rsi
	xorl	%eax, %eax
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	leaq	.LC1(%rip), %rdi
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	call	__isoc99_scanf@PLT
	movl	n(%rip), %ecx
	testl	%ecx, %ecx
	js	.L7
	leal	1(%rcx), %edi
	cmpl	$2, %ecx
	jle	.L22
	movl	%edi, %edx
	leaq	p(%rip), %rsi
	movdqa	.LC0(%rip), %xmm0
	movdqa	.LC2(%rip), %xmm2
	shrl	$2, %edx
	leaq	16(%rsi), %r8
	movq	%rsi, %rax
	subl	$1, %edx
	salq	$4, %rdx
	addq	%r8, %rdx
	.p2align 4,,10
	.p2align 3
.L9:
	movdqa	%xmm0, %xmm1
	addq	$16, %rax
	paddd	%xmm2, %xmm0
	movaps	%xmm1, -16(%rax)
	cmpq	%rdx, %rax
	jne	.L9
	movl	%edi, %eax
	andl	$-4, %eax
	andl	$3, %edi
	je	.L7
.L8:
	movslq	%eax, %rdx
	movl	%eax, (%rsi,%rdx,4)
	leal	1(%rax), %edx
	cmpl	%ecx, %edx
	jg	.L7
	movslq	%edx, %rdi
	addl	$2, %eax
	movl	%edx, (%rsi,%rdi,4)
	cmpl	%eax, %ecx
	jl	.L7
	movslq	%eax, %rdx
	movl	%eax, (%rsi,%rdx,4)
.L7:
	movl	v(%rip), %edx
	leaq	e(%rip), %r12
	movl	$0, i(%rip)
	testl	%edx, %edx
	jle	.L11
	xorl	%eax, %eax
	leaq	.LC3(%rip), %rbx
	.p2align 4,,10
	.p2align 3
.L12:
	cltq
	movq	%rbx, %rdi
	leaq	(%rax,%rax,2), %rsi
	xorl	%eax, %eax
	salq	$2, %rsi
	leaq	4(%rsi,%r12), %rdx
	leaq	8(%rsi,%r12), %rcx
	addq	%r12, %rsi
	call	__isoc99_scanf@PLT
	movl	i(%rip), %eax
	movl	v(%rip), %edx
	addl	$1, %eax
	movl	%eax, i(%rip)
	cmpl	%edx, %eax
	jl	.L12
.L11:
	movslq	%edx, %rsi
	movq	%r12, %rdi
	leaq	c(%rip), %rcx
	movl	$12, %edx
	call	qsort@PLT
	movl	v(%rip), %ebx
	movl	$0, i(%rip)
	movl	r(%rip), %r12d
	testl	%ebx, %ebx
	jle	.L14
	leal	-1(%rbx), %eax
	leaq	e(%rip), %r9
	movl	%r12d, %r11d
	xorl	%ebp, %ebp
	leaq	(%rax,%rax,2), %rdx
	leaq	12(%r9), %rax
	leaq	(%rax,%rdx,4), %r10
	leaq	p(%rip), %rsi
	.p2align 4,,10
	.p2align 3
.L20:
	movl	(%r9), %edi
	movl	%edi, %eax
	.p2align 4,,10
	.p2align 3
.L15:
	cltq
	movq	%rax, %rdx
	movl	(%rsi,%rax,4), %eax
	cmpl	%eax, %edx
	jne	.L15
	movl	4(%r9), %r8d
	movl	%r8d, %eax
	.p2align 4,,10
	.p2align 3
.L16:
	cltq
	movq	%rax, %rcx
	movl	(%rsi,%rax,4), %eax
	cmpl	%ecx, %eax
	jne	.L16
	cmpl	%edx, %eax
	jne	.L35
.L17:
	addq	$12, %r9
	cmpq	%r10, %r9
	jne	.L20
	movl	%ebx, i(%rip)
	testb	%bpl, %bpl
	je	.L14
	movl	%r11d, r(%rip)
	movl	%r11d, %r12d
.L14:
	movl	%r12d, %edx
	leaq	.LC4(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	popq	%rbx
	.cfi_remember_state
	.cfi_def_cfa_offset 24
	xorl	%eax, %eax
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L35:
	.cfi_restore_state
	addl	8(%r9), %r11d
	.p2align 4,,10
	.p2align 3
.L18:
	movslq	%r8d, %rdx
	movl	(%rsi,%rdx,4), %r8d
	cmpl	%r8d, %edx
	jne	.L18
	.p2align 4,,10
	.p2align 3
.L19:
	movslq	%edi, %rdx
	movslq	(%rsi,%rdx,4), %rdi
	cmpl	%edi, %edx
	jne	.L19
	movl	%r8d, (%rsi,%rdi,4)
	movl	$1, %ebp
	jmp	.L17
.L22:
	xorl	%eax, %eax
	leaq	p(%rip), %rsi
	jmp	.L8
	.cfi_endproc
.LFE41:
	.size	main, .-main
	.globl	r
	.bss
	.align 4
	.type	r, @object
	.size	r, 4
r:
	.zero	4
	.globl	p
	.align 32
	.type	p, @object
	.size	p, 40004
p:
	.zero	40004
	.globl	i
	.align 4
	.type	i, @object
	.size	i, 4
i:
	.zero	4
	.globl	e
	.align 32
	.type	e, @object
	.size	e, 1200012
e:
	.zero	1200012
	.globl	v
	.align 4
	.type	v, @object
	.size	v, 4
v:
	.zero	4
	.globl	n
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.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>
#include<stdlib.h>
#
int n,v,e[100001][3],i,p[10001],r=0;

int c(const void *x,const void *y)
{
	return ((int*)x)[2]-((int*)y)[2];
}

int a(int x)
{
	return p[x]==x?x:a(p[x]);
}

int main()
{
	scanf("%d%d",&n,&v);
	for(i=0;i<=n;i++)
		p[i]=i;
	for(i=0;i<v;i++)
		scanf("%d%d%d",&e[i][0],&e[i][1],&e[i][2]);
	qsort(e,v,sizeof(int[3]),c);
	for(i=0;i<v;i++)
		if(a(e[i][0])!=a(e[i][1]))
		{
			r+=e[i][2];
			p[a(e[i][0])]=p[a(e[i][1])];
		}
	printf("%d\n",r);
	return 0;
}
6 9
0 1 1
0 2 3
1 2 2
1 3 7
2 4 1
1 4 3
3 4 1
3 5 1
4 5 6
 4 6
0 1 2
1 2 1
2 3 1
3 0 1
0 2 1
1 3 5
 6 9
0 2 1
0 2 3
0 2 2
1 3 7
2 4 1
1 4 3
3 2 1
3 5 1
2 5 6
 6 9
0 1 1
0 2 3
1 2 2
1 3 7
2 4 1
1 4 3
3 4 1
3 1 1
4 5 6
 6 2
0 2 1
0 2 3
1 2 2
1 3 7
2 4 1
1 4 3
3 2 1
3 5 1
2 5 6
 6 9
0 2 1
0 2 3
0 2 2
1 3 7
2 4 1
0 4 2
3 2 1
3 5 1
2 5 6
 4 6
0 1 2
1 2 1
0 3 0
3 0 1
0 2 1
1 3 5
 6 2
0 1 1
0 2 3
1 2 2
1 3 7
2 4 1
1 4 3
3 2 1
3 5 1
2 5 6
 6 9
0 2 1
0 2 3
0 2 2
1 3 7
2 4 2
1 4 3
3 2 1
3 5 1
2 5 10
 6 9
0 2 1
0 2 3
1 2 2
1 3 7
2 4 4
1 2 3
3 2 1
3 5 1
2 5 10

6
 3
 7
 10
 1
 11
 2
 4
 8
 9

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>
#include<stdlib.h>
#
int n,v,e[100001][3],i,p[10001],r=0;

int c(const void *x,const void *y)
{
	return ((int*)x)[2]-((int*)y)[2];
}

int a(int x)
{
	return p[x]==x?x:a(p[x]);
}

int main()
{
	scanf("%d%d",&n,&v);
	for(i=0;i<=n;i++)
		p[i]=i;
	for(i=0;i<v;i++)
		scanf("%d%d%d",&e[i][0],&e[i][1],&e[i][2]);
	qsort(e,v,sizeof(int[3]),c);
	for(i=0;i<v;i++)
		if(a(e[i][0])!=a(e[i][1]))
		{
			r+=e[i][2];
			p[a(e[i][0])]=p[a(e[i][1])];
		}
	printf("%d\n",r);
	return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	n
	.bss
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	v
	.align 4
	.type	v, @object
	.size	v, 4
v:
	.zero	4
	.globl	e
	.align 32
	.type	e, @object
	.size	e, 1200012
e:
	.zero	1200012
	.globl	i
	.align 4
	.type	i, @object
	.size	i, 4
i:
	.zero	4
	.globl	p
	.align 32
	.type	p, @object
	.size	p, 40004
p:
	.zero	40004
	.globl	r
	.align 4
	.type	r, @object
	.size	r, 4
r:
	.zero	4
	.text
	.globl	c
	.type	c, @function
c:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -8(%rbp)
	movq	%rsi, -16(%rbp)
	movq	-8(%rbp), %rax
	addq	$8, %rax
	movl	(%rax), %eax
	movq	-16(%rbp), %rdx
	addq	$8, %rdx
	movl	(%rdx), %edx
	subl	%edx, %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	c, .-c
	.globl	a
	.type	a, @function
a:
.LFB7:
	.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	p(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -4(%rbp)
	je	.L4
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	p(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, %edi
	call	a
	jmp	.L6
.L4:
	movl	-4(%rbp), %eax
.L6:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	a, .-a
	.section	.rodata
.LC0:
	.string	"%d%d"
.LC1:
	.string	"%d%d%d"
.LC2:
	.string	"%d\n"
	.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	$8, %rsp
	.cfi_offset 3, -24
	leaq	v(%rip), %rax
	movq	%rax, %rdx
	leaq	n(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, i(%rip)
	jmp	.L8
.L9:
	movl	i(%rip), %edx
	movl	i(%rip), %eax
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	p(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movl	i(%rip), %eax
	addl	$1, %eax
	movl	%eax, i(%rip)
.L8:
	movl	i(%rip), %edx
	movl	n(%rip), %eax
	cmpl	%eax, %edx
	jle	.L9
	movl	$0, i(%rip)
	jmp	.L10
.L11:
	movl	i(%rip), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	leaq	8(%rax), %rdx
	leaq	e(%rip), %rax
	leaq	(%rdx,%rax), %rcx
	movl	i(%rip), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	leaq	4(%rax), %rdx
	leaq	e(%rip), %rax
	addq	%rax, %rdx
	movl	i(%rip), %eax
	movslq	%eax, %rsi
	movq	%rsi, %rax
	addq	%rax, %rax
	addq	%rsi, %rax
	salq	$2, %rax
	leaq	e(%rip), %rsi
	addq	%rsi, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	i(%rip), %eax
	addl	$1, %eax
	movl	%eax, i(%rip)
.L10:
	movl	i(%rip), %edx
	movl	v(%rip), %eax
	cmpl	%eax, %edx
	jl	.L11
	movl	v(%rip), %eax
	cltq
	leaq	c(%rip), %rdx
	movq	%rdx, %rcx
	movl	$12, %edx
	movq	%rax, %rsi
	leaq	e(%rip), %rax
	movq	%rax, %rdi
	call	qsort@PLT
	movl	$0, i(%rip)
	jmp	.L12
.L14:
	movl	i(%rip), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	leaq	e(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, %edi
	call	a
	movl	%eax, %ebx
	movl	i(%rip), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	leaq	4+e(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, %edi
	call	a
	cmpl	%eax, %ebx
	je	.L13
	movl	i(%rip), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	leaq	8+e(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	r(%rip), %eax
	addl	%edx, %eax
	movl	%eax, r(%rip)
	movl	i(%rip), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	leaq	4+e(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, %edi
	call	a
	movl	%eax, %ebx
	movl	i(%rip), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	leaq	e(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, %edi
	call	a
	movl	%eax, %edx
	movslq	%ebx, %rax
	leaq	0(,%rax,4), %rcx
	leaq	p(%rip), %rax
	movl	(%rcx,%rax), %eax
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	p(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
.L13:
	movl	i(%rip), %eax
	addl	$1, %eax
	movl	%eax, i(%rip)
.L12:
	movl	i(%rip), %edx
	movl	v(%rip), %eax
	cmpl	%eax, %edx
	jl	.L14
	movl	r(%rip), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	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	n
	.bss
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	v
	.align 4
	.type	v, @object
	.size	v, 4
v:
	.zero	4
	.globl	e
	.align 32
	.type	e, @object
	.size	e, 1200012
e:
	.zero	1200012
	.globl	i
	.align 4
	.type	i, @object
	.size	i, 4
i:
	.zero	4
	.globl	p
	.align 32
	.type	p, @object
	.size	p, 40004
p:
	.zero	40004
	.globl	r
	.align 4
	.type	r, @object
	.size	r, 4
r:
	.zero	4
	.text
	.globl	c
	.type	c, @function
c:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -8(%rbp)
	movq	%rsi, -16(%rbp)
	movq	-8(%rbp), %rax
	addq	$8, %rax
	movl	(%rax), %eax
	movq	-16(%rbp), %rdx
	addq	$8, %rdx
	movl	(%rdx), %edx
	subl	%edx, %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	c, .-c
	.globl	a
	.type	a, @function
a:
.LFB7:
	.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	p(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -4(%rbp)
	je	.L4
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	p(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, %edi
	call	a
	jmp	.L6
.L4:
	movl	-4(%rbp), %eax
.L6:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	a, .-a
	.section	.rodata
.LC0:
	.string	"%d%d"
.LC1:
	.string	"%d%d%d"
.LC2:
	.string	"%d\n"
	.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	$8, %rsp
	.cfi_offset 3, -24
	leaq	v(%rip), %rax
	movq	%rax, %rdx
	leaq	n(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, i(%rip)
	jmp	.L8
.L9:
	movl	i(%rip), %edx
	movl	i(%rip), %eax
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	p(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movl	i(%rip), %eax
	addl	$1, %eax
	movl	%eax, i(%rip)
.L8:
	movl	i(%rip), %edx
	movl	n(%rip), %eax
	cmpl	%eax, %edx
	jle	.L9
	movl	$0, i(%rip)
	jmp	.L10
.L11:
	movl	i(%rip), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	leaq	8(%rax), %rdx
	leaq	e(%rip), %rax
	leaq	(%rdx,%rax), %rcx
	movl	i(%rip), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	leaq	4(%rax), %rdx
	leaq	e(%rip), %rax
	addq	%rax, %rdx
	movl	i(%rip), %eax
	movslq	%eax, %rsi
	movq	%rsi, %rax
	addq	%rax, %rax
	addq	%rsi, %rax
	salq	$2, %rax
	leaq	e(%rip), %rsi
	addq	%rsi, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	i(%rip), %eax
	addl	$1, %eax
	movl	%eax, i(%rip)
.L10:
	movl	i(%rip), %edx
	movl	v(%rip), %eax
	cmpl	%eax, %edx
	jl	.L11
	movl	v(%rip), %eax
	cltq
	leaq	c(%rip), %rdx
	movq	%rdx, %rcx
	movl	$12, %edx
	movq	%rax, %rsi
	leaq	e(%rip), %rax
	movq	%rax, %rdi
	call	qsort@PLT
	movl	$0, i(%rip)
	jmp	.L12
.L14:
	movl	i(%rip), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	leaq	e(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, %edi
	call	a
	movl	%eax, %ebx
	movl	i(%rip), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	leaq	4+e(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, %edi
	call	a
	cmpl	%eax, %ebx
	je	.L13
	movl	i(%rip), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	leaq	8+e(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	r(%rip), %eax
	addl	%edx, %eax
	movl	%eax, r(%rip)
	movl	i(%rip), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	leaq	4+e(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, %edi
	call	a
	movl	%eax, %ebx
	movl	i(%rip), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	leaq	e(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, %edi
	call	a
	movl	%eax, %edx
	movslq	%ebx, %rax
	leaq	0(,%rax,4), %rcx
	leaq	p(%rip), %rax
	movl	(%rcx,%rax), %eax
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	p(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
.L13:
	movl	i(%rip), %eax
	addl	$1, %eax
	movl	%eax, i(%rip)
.L12:
	movl	i(%rip), %edx
	movl	v(%rip), %eax
	cmpl	%eax, %edx
	jl	.L14
	movl	r(%rip), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	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:
