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

```c
// AOJ 1280: Slim Span
// 2017.10.22 bal4u@uu

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX 100
/* UNION-FIND library */
int p[MAX], rank[MAX], pp[MAX];
void link(int x, int y) {
	if (rank[x] > rank[y]) p[y] = x;
	else { p[x] = y; if (rank[x] == rank[y]) rank[y] = rank[y] + 1;	}
}
int find_set(int x) { if (x != p[x]) p[x] = find_set(p[x]);	return p[x]; }
void union_set(int x, int y) { link(find_set(x), find_set(y)); }

#define INF 0x7fffffff
typedef struct { int x, y, w; } EDGE;
EDGE edge[5000], edge2[5000], *end; int m;

char buf[130], *b;
int getInt(void)
{
	int n = 0;
	if (*b == ' ') b++;
	n = 0; while (*b >= '0' ) n = (n<<3) + (n<<1) + (*b++ & 0xf);
	return n;
}

#define VMAX 10000
int f[VMAX+1], vmax, vmin;
void distsort()
{
	int i, x;
	register EDGE *ep;

	memset(f, 0, sizeof(f));
	for (ep = edge; ep < end; ep++) f[ep->w]++;
	for (i = vmin+1; i <= vmax; i++) f[i] += f[i-1];
	for (i = m-1; i >= 0; i--) {
		x = edge[i].w, edge2[--f[x]] = edge[i];
	}
	end = edge2 + (end - edge);
}

int main() 
{
	int n, i, j, k, ans, sz;
	register EDGE *ep;

	for (j = 0; j < 100; j++)  pp[j] = j;
	while (fgets(b=buf, 128, stdin) && *b != '0') {
		n = getInt(), m = getInt();
		sz = sizeof(int)*n;
		for (vmin = VMAX+1, vmin = 0, ep = edge, k = m; k--; ep++) {
			fgets(b=buf, 128, stdin);
			ep->x = getInt()-1, ep->y = getInt()-1, ep->w = i = getInt();
			if (i < vmin) vmin = i;	else if (i > vmax) vmax = i;
		}
		end = ep;

		distsort();

		ans = INF;
		for (i = 0; i < m; i++) {
			memcpy(p, pp, sz), memset(rank, 0, sz);
			for (k = 1, ep = edge2+i; ep < end; ep++) {
				if (find_set(ep->x) != find_set(ep->y)) {
					union_set(ep->x, ep->y);
					if (++k == n) {
						if (ep->w - edge2[i].w < ans) {
							ans = ep->w - edge2[i].w;
							if (ans == 0) goto done;
						}
						break;
					}
				}
			}
		}
		if (ans == INF) puts("-1");
		else {
done:		printf("%d\n", ans);
		}
	}
	return 0; 
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	p
	.bss
	.align 32
	.type	p, @object
	.size	p, 400
p:
	.zero	400
	.globl	rank
	.align 32
	.type	rank, @object
	.size	rank, 400
rank:
	.zero	400
	.globl	pp
	.align 32
	.type	pp, @object
	.size	pp, 400
pp:
	.zero	400
	.text
	.globl	link
	.type	link, @function
link:
.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, -4(%rbp)
	movl	%esi, -8(%rbp)
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	rank(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	rank(%rip), %rax
	movl	(%rcx,%rax), %eax
	cmpl	%eax, %edx
	jle	.L2
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	p(%rip), %rdx
	movl	-4(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	jmp	.L4
.L2:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	p(%rip), %rdx
	movl	-8(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	rank(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	rank(%rip), %rax
	movl	(%rcx,%rax), %eax
	cmpl	%eax, %edx
	jne	.L4
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	rank(%rip), %rax
	movl	(%rdx,%rax), %eax
	leal	1(%rax), %ecx
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	rank(%rip), %rax
	movl	%ecx, (%rdx,%rax)
.L4:
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	link, .-link
	.globl	find_set
	.type	find_set, @function
find_set:
.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	.L6
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	p(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, %edi
	call	find_set
	movl	-4(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	p(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
.L6:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	p(%rip), %rax
	movl	(%rdx,%rax), %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	find_set, .-find_set
	.globl	union_set
	.type	union_set, @function
union_set:
.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	$24, %rsp
	.cfi_offset 3, -24
	movl	%edi, -20(%rbp)
	movl	%esi, -24(%rbp)
	movl	-24(%rbp), %eax
	movl	%eax, %edi
	call	find_set
	movl	%eax, %ebx
	movl	-20(%rbp), %eax
	movl	%eax, %edi
	call	find_set
	movl	%ebx, %esi
	movl	%eax, %edi
	call	link
	nop
	movq	-8(%rbp), %rbx
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.size	union_set, .-union_set
	.globl	edge
	.bss
	.align 32
	.type	edge, @object
	.size	edge, 60000
edge:
	.zero	60000
	.globl	edge2
	.align 32
	.type	edge2, @object
	.size	edge2, 60000
edge2:
	.zero	60000
	.globl	end
	.align 8
	.type	end, @object
	.size	end, 8
end:
	.zero	8
	.globl	m
	.align 4
	.type	m, @object
	.size	m, 4
m:
	.zero	4
	.globl	buf
	.align 32
	.type	buf, @object
	.size	buf, 130
buf:
	.zero	130
	.globl	b
	.align 8
	.type	b, @object
	.size	b, 8
b:
	.zero	8
	.text
	.globl	getInt
	.type	getInt, @function
getInt:
.LFB9:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	$0, -4(%rbp)
	movq	b(%rip), %rax
	movzbl	(%rax), %eax
	cmpb	$32, %al
	jne	.L10
	movq	b(%rip), %rax
	addq	$1, %rax
	movq	%rax, b(%rip)
.L10:
	movl	$0, -4(%rbp)
	jmp	.L11
.L12:
	movl	-4(%rbp), %eax
	leal	0(,%rax,8), %edx
	movl	-4(%rbp), %eax
	addl	%eax, %eax
	leal	(%rdx,%rax), %ecx
	movq	b(%rip), %rax
	leaq	1(%rax), %rdx
	movq	%rdx, b(%rip)
	movzbl	(%rax), %eax
	movsbl	%al, %eax
	andl	$15, %eax
	addl	%ecx, %eax
	movl	%eax, -4(%rbp)
.L11:
	movq	b(%rip), %rax
	movzbl	(%rax), %eax
	cmpb	$47, %al
	jg	.L12
	movl	-4(%rbp), %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE9:
	.size	getInt, .-getInt
	.globl	f
	.bss
	.align 32
	.type	f, @object
	.size	f, 40004
f:
	.zero	40004
	.globl	vmax
	.align 4
	.type	vmax, @object
	.size	vmax, 4
vmax:
	.zero	4
	.globl	vmin
	.align 4
	.type	vmin, @object
	.size	vmin, 4
vmin:
	.zero	4
	.text
	.globl	distsort
	.type	distsort, @function
distsort:
.LFB10:
	.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	$24, %rsp
	.cfi_offset 3, -24
	movl	$40004, %edx
	movl	$0, %esi
	leaq	f(%rip), %rax
	movq	%rax, %rdi
	call	memset@PLT
	leaq	edge(%rip), %rbx
	jmp	.L15
.L16:
	movl	8(%rbx), %eax
	movslq	%eax, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	f(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	leal	1(%rdx), %ecx
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	f(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	addq	$12, %rbx
.L15:
	movq	end(%rip), %rax
	cmpq	%rax, %rbx
	jb	.L16
	movl	vmin(%rip), %eax
	addl	$1, %eax
	movl	%eax, -24(%rbp)
	jmp	.L17
.L18:
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	f(%rip), %rax
	movl	(%rdx,%rax), %ecx
	movl	-24(%rbp), %eax
	subl	$1, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	f(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%eax, %ecx
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	f(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	addl	$1, -24(%rbp)
.L17:
	movl	vmax(%rip), %eax
	cmpl	%eax, -24(%rbp)
	jle	.L18
	movl	m(%rip), %eax
	subl	$1, %eax
	movl	%eax, -24(%rbp)
	jmp	.L19
.L20:
	movl	-24(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	leaq	8+edge(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -20(%rbp)
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	f(%rip), %rax
	movl	(%rdx,%rax), %eax
	leal	-1(%rax), %ecx
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	f(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	f(%rip), %rax
	movl	(%rdx,%rax), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rcx
	leaq	edge2(%rip), %rdx
	movl	-24(%rbp), %eax
	movslq	%eax, %rsi
	movq	%rsi, %rax
	addq	%rax, %rax
	addq	%rsi, %rax
	salq	$2, %rax
	movq	%rax, %rsi
	leaq	edge(%rip), %rax
	movq	(%rsi,%rax), %rdi
	movq	%rdi, (%rcx,%rdx)
	movl	8(%rsi,%rax), %eax
	movl	%eax, 8(%rcx,%rdx)
	subl	$1, -24(%rbp)
.L19:
	cmpl	$0, -24(%rbp)
	jns	.L20
	movq	end(%rip), %rax
	leaq	edge(%rip), %rdx
	subq	%rdx, %rax
	movq	%rax, %rdx
	leaq	edge2(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, end(%rip)
	nop
	movq	-8(%rbp), %rbx
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE10:
	.size	distsort, .-distsort
	.section	.rodata
.LC0:
	.string	"-1"
.LC1:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB11:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%r12
	pushq	%rbx
	subq	$32, %rsp
	.cfi_offset 12, -24
	.cfi_offset 3, -32
	movl	$0, -36(%rbp)
	jmp	.L22
.L23:
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	pp(%rip), %rdx
	movl	-36(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	addl	$1, -36(%rbp)
.L22:
	cmpl	$99, -36(%rbp)
	jle	.L23
	jmp	.L24
.L38:
	call	getInt
	movl	%eax, -24(%rbp)
	call	getInt
	movl	%eax, m(%rip)
	movl	-24(%rbp), %eax
	cltq
	sall	$2, %eax
	movl	%eax, -20(%rbp)
	movl	$10001, vmin(%rip)
	movl	$0, vmin(%rip)
	leaq	edge(%rip), %rbx
	movl	m(%rip), %eax
	movl	%eax, -32(%rbp)
	jmp	.L25
.L28:
	movq	stdin(%rip), %rdx
	leaq	buf(%rip), %rax
	movq	%rax, b(%rip)
	movq	b(%rip), %rax
	movl	$128, %esi
	movq	%rax, %rdi
	call	fgets@PLT
	call	getInt
	subl	$1, %eax
	movl	%eax, (%rbx)
	call	getInt
	subl	$1, %eax
	movl	%eax, 4(%rbx)
	call	getInt
	movl	%eax, -40(%rbp)
	movl	-40(%rbp), %eax
	movl	%eax, 8(%rbx)
	movl	vmin(%rip), %eax
	cmpl	%eax, -40(%rbp)
	jge	.L26
	movl	-40(%rbp), %eax
	movl	%eax, vmin(%rip)
	jmp	.L27
.L26:
	movl	vmax(%rip), %eax
	cmpl	%eax, -40(%rbp)
	jle	.L27
	movl	-40(%rbp), %eax
	movl	%eax, vmax(%rip)
.L27:
	addq	$12, %rbx
.L25:
	movl	-32(%rbp), %eax
	leal	-1(%rax), %edx
	movl	%edx, -32(%rbp)
	testl	%eax, %eax
	jne	.L28
	movq	%rbx, end(%rip)
	movl	$0, %eax
	call	distsort
	movl	$2147483647, -28(%rbp)
	movl	$0, -40(%rbp)
	jmp	.L29
.L36:
	movl	-20(%rbp), %eax
	cltq
	movq	%rax, %rdx
	leaq	pp(%rip), %rax
	movq	%rax, %rsi
	leaq	p(%rip), %rax
	movq	%rax, %rdi
	call	memcpy@PLT
	movl	-20(%rbp), %eax
	cltq
	movq	%rax, %rdx
	movl	$0, %esi
	leaq	rank(%rip), %rax
	movq	%rax, %rdi
	call	memset@PLT
	movl	$1, -32(%rbp)
	movl	-40(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	leaq	edge2(%rip), %rax
	leaq	(%rdx,%rax), %rbx
	jmp	.L30
.L35:
	movl	(%rbx), %eax
	movl	%eax, %edi
	call	find_set
	movl	%eax, %r12d
	movl	4(%rbx), %eax
	movl	%eax, %edi
	call	find_set
	cmpl	%eax, %r12d
	je	.L31
	movl	4(%rbx), %edx
	movl	(%rbx), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	union_set
	addl	$1, -32(%rbp)
	movl	-32(%rbp), %eax
	cmpl	-24(%rbp), %eax
	jne	.L31
	movl	8(%rbx), %ecx
	movl	-40(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	leaq	8+edge2(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	%ecx, %eax
	subl	%edx, %eax
	cmpl	%eax, -28(%rbp)
	jle	.L40
	movl	8(%rbx), %ecx
	movl	-40(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	leaq	8+edge2(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	%ecx, %eax
	subl	%edx, %eax
	movl	%eax, -28(%rbp)
	cmpl	$0, -28(%rbp)
	jne	.L40
	jmp	.L33
.L31:
	addq	$12, %rbx
.L30:
	movq	end(%rip), %rax
	cmpq	%rax, %rbx
	jb	.L35
	jmp	.L34
.L40:
	nop
.L34:
	addl	$1, -40(%rbp)
.L29:
	movl	m(%rip), %eax
	cmpl	%eax, -40(%rbp)
	jl	.L36
	cmpl	$2147483647, -28(%rbp)
	jne	.L41
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	jmp	.L24
.L41:
	nop
.L33:
	movl	-28(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L24:
	movq	stdin(%rip), %rdx
	leaq	buf(%rip), %rax
	movq	%rax, b(%rip)
	movq	b(%rip), %rax
	movl	$128, %esi
	movq	%rax, %rdi
	call	fgets@PLT
	testq	%rax, %rax
	je	.L37
	movq	b(%rip), %rax
	movzbl	(%rax), %eax
	cmpb	$48, %al
	jne	.L38
.L37:
	movl	$0, %eax
	addq	$32, %rsp
	popq	%rbx
	popq	%r12
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE11:
	.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	link
	.type	link, @function
link:
.LFB51:
	.cfi_startproc
	endbr64
	leaq	rank(%rip), %rax
	movslq	%edi, %r8
	movslq	%esi, %rdx
	movl	(%rax,%r8,4), %ecx
	cmpl	(%rax,%rdx,4), %ecx
	jle	.L2
	leaq	p(%rip), %rax
	movl	%edi, (%rax,%rdx,4)
	ret
	.p2align 4,,10
	.p2align 3
.L2:
	leaq	p(%rip), %rdi
	movl	%esi, (%rdi,%r8,4)
	je	.L5
	ret
	.p2align 4,,10
	.p2align 3
.L5:
	addl	$1, %ecx
	movl	%ecx, (%rax,%rdx,4)
	ret
	.cfi_endproc
.LFE51:
	.size	link, .-link
	.p2align 4
	.globl	find_set
	.type	find_set, @function
find_set:
.LFB52:
	.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
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	movslq	%edi, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	leaq	p(%rip), %rbx
	movq	%rbp, %rax
	movl	(%rbx,%rbp,4), %edx
	cmpl	%ebp, %edx
	jne	.L13
	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
.L13:
	.cfi_restore_state
	movslq	%edx, %r12
	movl	(%rbx,%r12,4), %eax
	cmpl	%eax, %edx
	je	.L8
	movslq	%eax, %r13
	movl	(%rbx,%r13,4), %edx
	cmpl	%edx, %eax
	jne	.L14
.L9:
	movl	%edx, (%rbx,%r12,4)
	movl	%edx, %eax
.L8:
	movl	%eax, (%rbx,%rbp,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
.L14:
	.cfi_restore_state
	movslq	%edx, %r14
	movl	(%rbx,%r14,4), %edi
	cmpl	%edi, %edx
	je	.L10
	call	find_set
	movl	%eax, (%rbx,%r14,4)
	movl	%eax, %edi
.L10:
	movl	%edi, (%rbx,%r13,4)
	movl	%edi, %edx
	jmp	.L9
	.cfi_endproc
.LFE52:
	.size	find_set, .-find_set
	.p2align 4
	.globl	union_set
	.type	union_set, @function
union_set:
.LFB53:
	.cfi_startproc
	endbr64
	leaq	p(%rip), %rcx
	movslq	%esi, %r9
	subq	$8, %rsp
	.cfi_def_cfa_offset 16
	movl	%edi, %r8d
	movl	(%rcx,%r9,4), %r10d
	cmpl	%r10d, %esi
	jne	.L26
.L16:
	movslq	%r8d, %rsi
	movl	(%rcx,%rsi,4), %eax
	cmpl	%eax, %r8d
	jne	.L27
.L20:
	leaq	rank(%rip), %rdx
	movslq	%eax, %r8
	movslq	%r10d, %rsi
	movl	(%rdx,%r8,4), %edi
	cmpl	(%rdx,%rsi,4), %edi
	jle	.L23
	movl	%eax, (%rcx,%rsi,4)
.L15:
	addq	$8, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L23:
	.cfi_restore_state
	movl	%r10d, (%rcx,%r8,4)
	jne	.L15
	addl	$1, %edi
	movl	%edi, (%rdx,%rsi,4)
	addq	$8, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L27:
	.cfi_restore_state
	movslq	%eax, %r8
	movl	(%rcx,%r8,4), %edx
	cmpl	%edx, %eax
	je	.L21
	movslq	%edx, %r9
	movl	(%rcx,%r9,4), %edi
	cmpl	%edi, %edx
	jne	.L28
.L22:
	movl	%edi, (%rcx,%r8,4)
	movl	%edi, %edx
.L21:
	movl	%edx, (%rcx,%rsi,4)
	movl	%edx, %eax
	jmp	.L20
	.p2align 4,,10
	.p2align 3
.L26:
	movslq	%r10d, %rsi
	movl	(%rcx,%rsi,4), %eax
	cmpl	%eax, %r10d
	je	.L17
	movslq	%eax, %r10
	movl	(%rcx,%r10,4), %edx
	cmpl	%edx, %eax
	jne	.L29
.L18:
	movl	%edx, (%rcx,%rsi,4)
	movl	%edx, %eax
.L17:
	movl	%eax, (%rcx,%r9,4)
	movl	%eax, %r10d
	jmp	.L16
	.p2align 4,,10
	.p2align 3
.L29:
	movslq	%edx, %r11
	movl	(%rcx,%r11,4), %edi
	cmpl	%edi, %edx
	je	.L19
	call	find_set
	movl	%eax, (%rcx,%r11,4)
	movl	%eax, %edi
.L19:
	movl	%edi, (%rcx,%r10,4)
	movl	%edi, %edx
	jmp	.L18
	.p2align 4,,10
	.p2align 3
.L28:
	call	find_set
	movl	%eax, (%rcx,%r9,4)
	movl	%eax, %edi
	jmp	.L22
	.cfi_endproc
.LFE53:
	.size	union_set, .-union_set
	.p2align 4
	.globl	getInt
	.type	getInt, @function
getInt:
.LFB54:
	.cfi_startproc
	endbr64
	movq	b(%rip), %rax
	movzbl	(%rax), %edx
	cmpb	$32, %dl
	jne	.L31
	leaq	1(%rax), %rcx
	movq	%rcx, b(%rip)
	movzbl	1(%rax), %edx
	movq	%rcx, %rax
.L31:
	cmpb	$47, %dl
	jle	.L34
	addq	$1, %rax
	xorl	%r8d, %r8d
	.p2align 4,,10
	.p2align 3
.L33:
	movq	%rax, b(%rip)
	movzbl	-1(%rax), %edx
	addq	$1, %rax
	leal	(%r8,%r8,4), %ecx
	andl	$15, %edx
	cmpb	$47, -1(%rax)
	leal	(%rdx,%rcx,2), %r8d
	jg	.L33
	movl	%r8d, %eax
	ret
	.p2align 4,,10
	.p2align 3
.L34:
	xorl	%r8d, %r8d
	movl	%r8d, %eax
	ret
	.cfi_endproc
.LFE54:
	.size	getInt, .-getInt
	.p2align 4
	.globl	distsort
	.type	distsort, @function
distsort:
.LFB55:
	.cfi_startproc
	endbr64
	leaq	f(%rip), %rcx
	subq	$8, %rsp
	.cfi_def_cfa_offset 16
	movl	$40004, %edx
	xorl	%esi, %esi
	movq	%rcx, %rdi
	call	memset@PLT
	movq	end(%rip), %r8
	leaq	edge(%rip), %r9
	movq	%rax, %rcx
	cmpq	%r9, %r8
	jbe	.L37
	movq	%r9, %rax
	.p2align 4,,10
	.p2align 3
.L38:
	movslq	8(%rax), %rdx
	addq	$12, %rax
	addl	$1, (%rcx,%rdx,4)
	cmpq	%r8, %rax
	jb	.L38
.L37:
	movl	vmin(%rip), %edi
	movl	vmax(%rip), %esi
	cmpl	%esi, %edi
	jge	.L39
	movslq	%edi, %r10
	subl	$1, %esi
	subl	%edi, %esi
	leaq	(%rcx,%r10,4), %rax
	leaq	4+f(%rip), %rdi
	addq	%r10, %rsi
	movl	(%rax), %edx
	leaq	(%rdi,%rsi,4), %rsi
	.p2align 4,,10
	.p2align 3
.L40:
	addl	4(%rax), %edx
	addq	$4, %rax
	movl	%edx, (%rax)
	cmpq	%rsi, %rax
	jne	.L40
.L39:
	movl	m(%rip), %esi
	leaq	edge2(%rip), %r10
	testl	%esi, %esi
	jle	.L41
	movslq	%esi, %rax
	subl	$1, %esi
	leaq	(%rax,%rax,2), %rdx
	subq	%rsi, %rax
	leaq	(%rax,%rax,2), %rsi
	leaq	-12+edge(%rip), %rax
	leaq	(%r9,%rdx,4), %rdx
	leaq	(%rax,%rsi,4), %r11
	.p2align 4,,10
	.p2align 3
.L42:
	movslq	-4(%rdx), %rdi
	subq	$12, %rdx
	movl	(%rcx,%rdi,4), %eax
	movq	%rdi, %rsi
	subl	$1, %eax
	movl	%eax, (%rcx,%rdi,4)
	cltq
	movq	(%rdx), %rdi
	leaq	(%rax,%rax,2), %rax
	leaq	(%r10,%rax,4), %rax
	movq	%rdi, (%rax)
	movl	%esi, 8(%rax)
	cmpq	%rdx, %r11
	jne	.L42
.L41:
	subq	%r9, %r8
	addq	%r8, %r10
	movq	%r10, end(%rip)
	addq	$8, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE55:
	.size	distsort, .-distsort
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC2:
	.string	"-1"
.LC3:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB56:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	pp(%rip), %rax
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	leaq	400(%rax), %rdx
	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
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$56, %rsp
	.cfi_def_cfa_offset 112
	movdqa	.LC0(%rip), %xmm0
	movdqa	.LC1(%rip), %xmm2
	.p2align 4,,10
	.p2align 3
.L49:
	movdqa	%xmm0, %xmm1
	addq	$16, %rax
	paddd	%xmm2, %xmm0
	movaps	%xmm1, -16(%rax)
	cmpq	%rax, %rdx
	jne	.L49
	leaq	p(%rip), %r12
.L50:
	leaq	buf(%rip), %rax
	movq	stdin(%rip), %rdx
	movl	$128, %esi
	movq	%rax, %rdi
	movq	%rax, b(%rip)
	call	fgets@PLT
	testq	%rax, %rax
	je	.L121
	movq	b(%rip), %rax
	movzbl	(%rax), %ecx
	cmpb	$48, %cl
	je	.L121
	cmpb	$32, %cl
	jne	.L51
	leaq	1(%rax), %rdx
	movq	%rdx, b(%rip)
	movzbl	1(%rax), %ecx
	movq	%rdx, %rax
.L51:
	cmpb	$47, %cl
	jle	.L112
	leaq	1(%rax), %rdx
	xorl	%r15d, %r15d
	.p2align 4,,10
	.p2align 3
.L53:
	movq	%rdx, %rax
	movq	%rdx, b(%rip)
	movzbl	-1(%rdx), %edx
	leal	(%r15,%r15,4), %ecx
	andl	$15, %edx
	leal	(%rdx,%rcx,2), %r15d
	movzbl	(%rax), %ecx
	leaq	1(%rax), %rdx
	cmpb	$47, %cl
	jg	.L53
	leal	0(,%r15,4), %ebx
.L52:
	cmpb	$32, %cl
	jne	.L54
	leaq	1(%rax), %rdx
	movq	%rdx, b(%rip)
	cmpb	$47, 1(%rax)
	jle	.L54
	addq	$2, %rax
	xorl	%edx, %edx
	.p2align 4,,10
	.p2align 3
.L55:
	movq	%rax, b(%rip)
	leal	(%rdx,%rdx,4), %ecx
	movzbl	-1(%rax), %edx
	addq	$1, %rax
	andl	$15, %edx
	cmpb	$47, -1(%rax)
	leal	(%rdx,%rcx,2), %edx
	jg	.L55
	movl	%edx, m(%rip)
	movl	$0, vmin(%rip)
	testl	%edx, %edx
	je	.L113
	leaq	edge(%rip), %rdi
	leaq	(%rdx,%rdx,2), %rax
	leaq	(%rdi,%rax,4), %rbp
	movq	%rdi, %r13
	.p2align 4,,10
	.p2align 3
.L68:
	leaq	buf(%rip), %rax
	movq	stdin(%rip), %rdx
	movl	$128, %esi
	movq	%rax, %rdi
	movq	%rax, b(%rip)
	call	fgets@PLT
	movq	b(%rip), %rax
	movzbl	(%rax), %edx
	cmpb	$32, %dl
	jne	.L57
	leaq	1(%rax), %rcx
	movq	%rcx, b(%rip)
	movzbl	1(%rax), %edx
	movq	%rcx, %rax
.L57:
	cmpb	$47, %dl
	jle	.L114
	leaq	1(%rax), %rcx
	xorl	%edx, %edx
	.p2align 4,,10
	.p2align 3
.L59:
	movq	%rcx, b(%rip)
	leal	(%rdx,%rdx,4), %esi
	movzbl	-1(%rcx), %edx
	movq	%rcx, %rax
	leaq	1(%rcx), %rcx
	andl	$15, %edx
	cmpb	$47, (%rax)
	leal	(%rdx,%rsi,2), %edx
	jg	.L59
	subl	$1, %edx
.L58:
	movl	%edx, 0(%r13)
	cmpb	$32, (%rax)
	jne	.L60
	addq	$1, %rax
	movq	%rax, b(%rip)
.L60:
	cmpb	$47, (%rax)
	jle	.L115
	leaq	1(%rax), %rcx
	xorl	%edx, %edx
	.p2align 4,,10
	.p2align 3
.L62:
	movq	%rcx, b(%rip)
	leal	(%rdx,%rdx,4), %esi
	movzbl	-1(%rcx), %edx
	movq	%rcx, %rax
	leaq	1(%rcx), %rcx
	andl	$15, %edx
	cmpb	$47, (%rax)
	leal	(%rdx,%rsi,2), %edx
	jg	.L62
	subl	$1, %edx
.L61:
	movl	%edx, 4(%r13)
	cmpb	$32, (%rax)
	jne	.L63
	addq	$1, %rax
	movq	%rax, b(%rip)
.L63:
	cmpb	$47, (%rax)
	jle	.L116
	addq	$1, %rax
	xorl	%edx, %edx
	.p2align 4,,10
	.p2align 3
.L65:
	movq	%rax, b(%rip)
	leal	(%rdx,%rdx,4), %ecx
	movzbl	-1(%rax), %edx
	addq	$1, %rax
	andl	$15, %edx
	cmpb	$47, -1(%rax)
	leal	(%rdx,%rcx,2), %edx
	jg	.L65
.L64:
	cmpl	%edx, vmin(%rip)
	movl	%edx, 8(%r13)
	jle	.L66
	movl	%edx, vmin(%rip)
.L67:
	addq	$12, %r13
	cmpq	%rbp, %r13
	jne	.L68
.L56:
	xorl	%eax, %eax
	movq	%rbp, end(%rip)
	call	distsort
	movl	m(%rip), %r13d
	testl	%r13d, %r13d
	jle	.L107
	movslq	%ebx, %rax
	movl	$2147483647, 28(%rsp)
	movq	end(%rip), %rbp
	leaq	rank(%rip), %rbx
	movq	%rax, 16(%rsp)
	leaq	edge2(%rip), %rax
	movq	%rax, 8(%rsp)
	movl	$0, 24(%rsp)
	.p2align 4,,10
	.p2align 3
.L106:
	movq	16(%rsp), %r14
	movl	$400, %ecx
	leaq	pp(%rip), %rsi
	movq	%r12, %rdi
	movq	%r14, %rdx
	call	__memcpy_chk@PLT
	movl	$400, %ecx
	movq	%r14, %rdx
	xorl	%esi, %esi
	movq	%rbx, %rdi
	call	__memset_chk@PLT
	movq	8(%rsp), %rax
	cmpq	%rbp, %rax
	jnb	.L71
	movq	%rax, %rsi
	movl	$1, %r10d
	jmp	.L105
	.p2align 4,,10
	.p2align 3
.L138:
	movslq	%r13d, %r9
	movl	(%r12,%r9,4), %eax
	cmpl	%eax, %r13d
	je	.L80
	movslq	%eax, %r11
	movl	(%r12,%r11,4), %edx
	cmpl	%edx, %eax
	je	.L81
	movslq	%edx, %r13
	movl	(%r12,%r13,4), %eax
	cmpl	%eax, %edx
	je	.L82
	movslq	%eax, %r14
	movl	(%r12,%r14,4), %edi
	cmpl	%edi, %eax
	je	.L83
	movslq	%edi, %rdx
	movl	(%r12,%rdx,4), %eax
	cmpl	%eax, %edi
	je	.L84
	movslq	%eax, %rdi
	movq	%rdi, 32(%rsp)
	movl	(%r12,%rdi,4), %edi
	cmpl	%edi, %eax
	je	.L85
	movq	%rdx, 40(%rsp)
	call	find_set
	movq	40(%rsp), %rdx
	movl	%eax, %edi
	movq	32(%rsp), %rax
	movl	%edi, (%r12,%rax,4)
.L85:
	movl	%edi, (%r12,%rdx,4)
	movl	%edi, %eax
.L84:
	movl	%eax, (%r12,%r14,4)
	movl	%eax, %edi
.L83:
	movl	%edi, (%r12,%r13,4)
	movl	%edi, %eax
.L82:
	movl	%eax, (%r12,%r11,4)
	movl	%eax, %edx
.L81:
	movl	%edx, (%r12,%r9,4)
	movl	%edx, %eax
.L80:
	movl	%eax, (%r12,%r8,4)
	cmpl	%eax, %ecx
	je	.L86
	movslq	4(%rsi), %r8
	movl	(%rsi), %ecx
	movl	(%r12,%r8,4), %eax
	movq	%r8, %r13
	cmpl	%eax, %r8d
	je	.L87
	movslq	%eax, %r11
	movl	(%r12,%r11,4), %r13d
	cmpl	%r13d, %eax
	je	.L88
	movslq	%r13d, %r9
	movl	(%r12,%r9,4), %eax
	cmpl	%eax, %r13d
	je	.L89
	movslq	%eax, %r13
	movl	(%r12,%r13,4), %edx
	cmpl	%edx, %eax
	je	.L90
	movslq	%edx, %r14
	movl	(%r12,%r14,4), %eax
	cmpl	%eax, %edx
	je	.L91
	movslq	%eax, %rdx
	movl	(%r12,%rdx,4), %edi
	cmpl	%edi, %eax
	je	.L92
	movslq	%edi, %rax
	movq	%rax, 32(%rsp)
	movl	(%r12,%rax,4), %eax
	cmpl	%eax, %edi
	je	.L93
	movl	%eax, %edi
	movq	%rdx, 40(%rsp)
	call	find_set
	movq	32(%rsp), %rdi
	movq	40(%rsp), %rdx
	movl	%eax, (%r12,%rdi,4)
.L93:
	movl	%eax, (%r12,%rdx,4)
	movl	%eax, %edi
.L92:
	movl	%edi, (%r12,%r14,4)
	movl	%edi, %eax
.L91:
	movl	%eax, (%r12,%r13,4)
	movl	%eax, %edx
.L90:
	movl	%edx, (%r12,%r9,4)
	movl	%edx, %eax
.L89:
	movl	%eax, (%r12,%r11,4)
	movl	%eax, %r13d
.L88:
	movl	%r13d, (%r12,%r8,4)
.L87:
	movslq	%ecx, %r8
	movl	(%r12,%r8,4), %eax
	cmpl	%eax, %ecx
	je	.L94
	movslq	%eax, %rcx
	movl	(%r12,%rcx,4), %edx
	cmpl	%edx, %eax
	je	.L95
	movslq	%edx, %r9
	movl	(%r12,%r9,4), %eax
	cmpl	%eax, %edx
	je	.L96
	movslq	%eax, %r11
	movl	(%r12,%r11,4), %edx
	cmpl	%edx, %eax
	je	.L97
	movslq	%edx, %r14
	movl	(%r12,%r14,4), %eax
	cmpl	%eax, %edx
	je	.L98
	movslq	%eax, %rdx
	movl	(%r12,%rdx,4), %edi
	cmpl	%edi, %eax
	je	.L99
	movslq	%edi, %rax
	movq	%rax, 32(%rsp)
	movl	(%r12,%rax,4), %eax
	cmpl	%eax, %edi
	je	.L100
	movl	%eax, %edi
	movq	%rdx, 40(%rsp)
	call	find_set
	movq	32(%rsp), %rdi
	movq	40(%rsp), %rdx
	movl	%eax, (%r12,%rdi,4)
.L100:
	movl	%eax, (%r12,%rdx,4)
	movl	%eax, %edi
.L99:
	movl	%edi, (%r12,%r14,4)
	movl	%edi, %eax
.L98:
	movl	%eax, (%r12,%r11,4)
	movl	%eax, %edx
.L97:
	movl	%edx, (%r12,%r9,4)
	movl	%edx, %eax
.L96:
	movl	%eax, (%r12,%rcx,4)
	movl	%eax, %edx
.L95:
	movl	%edx, (%r12,%r8,4)
	movl	%edx, %eax
.L94:
	movslq	%eax, %rdi
	movslq	%r13d, %rdx
	movl	(%rbx,%rdi,4), %ecx
	cmpl	(%rbx,%rdx,4), %ecx
	jle	.L101
	movl	%eax, (%r12,%rdx,4)
.L102:
	addl	$1, %r10d
	cmpl	%r15d, %r10d
	je	.L137
.L86:
	addq	$12, %rsi
	cmpq	%rbp, %rsi
	jnb	.L136
.L105:
	movslq	(%rsi), %r8
	movl	(%r12,%r8,4), %ecx
	cmpl	%ecx, %r8d
	je	.L72
	movslq	%ecx, %r9
	movl	(%r12,%r9,4), %eax
	cmpl	%eax, %ecx
	je	.L73
	movslq	%eax, %rcx
	movl	(%r12,%rcx,4), %edx
	cmpl	%edx, %eax
	je	.L74
	movslq	%edx, %r11
	movl	(%r12,%r11,4), %eax
	cmpl	%eax, %edx
	je	.L75
	movslq	%eax, %r13
	movl	(%r12,%r13,4), %edx
	cmpl	%edx, %eax
	je	.L76
	movslq	%edx, %r14
	movl	(%r12,%r14,4), %edi
	cmpl	%edi, %edx
	je	.L77
	movslq	%edi, %rdx
	movl	(%r12,%rdx,4), %eax
	movq	%rdx, 32(%rsp)
	cmpl	%eax, %edi
	je	.L78
	movl	%eax, %edi
	call	find_set
	movq	32(%rsp), %rdx
	movl	%eax, (%r12,%rdx,4)
.L78:
	movl	%eax, (%r12,%r14,4)
	movl	%eax, %edi
.L77:
	movl	%edi, (%r12,%r13,4)
	movl	%edi, %edx
.L76:
	movl	%edx, (%r12,%r11,4)
	movl	%edx, %eax
.L75:
	movl	%eax, (%r12,%rcx,4)
	movl	%eax, %edx
.L74:
	movl	%edx, (%r12,%r9,4)
	movl	%edx, %eax
.L73:
	movl	%eax, (%r12,%r8,4)
	movl	%eax, %ecx
.L72:
	movslq	4(%rsi), %r8
	movl	(%r12,%r8,4), %r13d
	cmpl	%r13d, %r8d
	jne	.L138
	cmpl	%ecx, %r13d
	je	.L86
	movl	(%rsi), %ecx
	jmp	.L87
	.p2align 4,,10
	.p2align 3
.L101:
	movl	%r13d, (%r12,%rdi,4)
	jne	.L102
	addl	$1, %ecx
	addl	$1, %r10d
	movl	%ecx, (%rbx,%rdx,4)
	cmpl	%r15d, %r10d
	jne	.L86
	.p2align 4,,10
	.p2align 3
.L137:
	movq	8(%rsp), %rdi
	movl	8(%rsi), %eax
	subl	8(%rdi), %eax
	cmpl	28(%rsp), %eax
	jge	.L136
	testl	%eax, %eax
	je	.L118
	movl	%eax, 28(%rsp)
	movl	m(%rip), %r13d
	.p2align 4,,10
	.p2align 3
.L71:
	addl	$1, 24(%rsp)
	movl	24(%rsp), %eax
	addq	$12, 8(%rsp)
	cmpl	%r13d, %eax
	jl	.L106
	cmpl	$2147483647, 28(%rsp)
	je	.L107
.L104:
	movl	28(%rsp), %edx
	leaq	.LC3(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L50
	.p2align 4,,10
	.p2align 3
.L136:
	movl	m(%rip), %r13d
	jmp	.L71
	.p2align 4,,10
	.p2align 3
.L66:
	cmpl	%edx, vmax(%rip)
	jge	.L67
	movl	%edx, vmax(%rip)
	jmp	.L67
.L114:
	movl	$-1, %edx
	jmp	.L58
.L116:
	xorl	%edx, %edx
	jmp	.L64
.L115:
	movl	$-1, %edx
	jmp	.L61
.L107:
	leaq	.LC2(%rip), %rdi
	call	puts@PLT
	jmp	.L50
.L118:
	movl	$0, 28(%rsp)
	jmp	.L104
.L54:
	movl	$0, m(%rip)
	leaq	edge(%rip), %rbp
	movl	$0, vmin(%rip)
	jmp	.L56
.L112:
	xorl	%ebx, %ebx
	xorl	%r15d, %r15d
	jmp	.L52
.L121:
	addq	$56, %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
.L113:
	.cfi_restore_state
	leaq	edge(%rip), %rbp
	jmp	.L56
	.cfi_endproc
.LFE56:
	.size	main, .-main
	.globl	vmin
	.bss
	.align 4
	.type	vmin, @object
	.size	vmin, 4
vmin:
	.zero	4
	.globl	vmax
	.align 4
	.type	vmax, @object
	.size	vmax, 4
vmax:
	.zero	4
	.globl	f
	.align 32
	.type	f, @object
	.size	f, 40004
f:
	.zero	40004
	.globl	b
	.align 8
	.type	b, @object
	.size	b, 8
b:
	.zero	8
	.globl	buf
	.align 32
	.type	buf, @object
	.size	buf, 130
buf:
	.zero	130
	.globl	m
	.align 4
	.type	m, @object
	.size	m, 4
m:
	.zero	4
	.globl	end
	.align 8
	.type	end, @object
	.size	end, 8
end:
	.zero	8
	.globl	edge2
	.align 32
	.type	edge2, @object
	.size	edge2, 60000
edge2:
	.zero	60000
	.globl	edge
	.align 32
	.type	edge, @object
	.size	edge, 60000
edge:
	.zero	60000
	.globl	pp
	.align 32
	.type	pp, @object
	.size	pp, 400
pp:
	.zero	400
	.globl	rank
	.align 32
	.type	rank, @object
	.size	rank, 400
rank:
	.zero	400
	.globl	p
	.align 32
	.type	p, @object
	.size	p, 400
p:
	.zero	400
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC0:
	.long	0
	.long	1
	.long	2
	.long	3
	.align 16
.LC1:
	.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	link
	.type	link, @function
link:
.LFB51:
	.cfi_startproc
	endbr64
	leaq	rank(%rip), %rax
	movslq	%edi, %r8
	movslq	%esi, %rdx
	movl	(%rax,%r8,4), %ecx
	cmpl	(%rax,%rdx,4), %ecx
	jle	.L2
	leaq	p(%rip), %rax
	movl	%edi, (%rax,%rdx,4)
	ret
	.p2align 4,,10
	.p2align 3
.L2:
	leaq	p(%rip), %rdi
	movl	%esi, (%rdi,%r8,4)
	je	.L5
	ret
	.p2align 4,,10
	.p2align 3
.L5:
	addl	$1, %ecx
	movl	%ecx, (%rax,%rdx,4)
	ret
	.cfi_endproc
.LFE51:
	.size	link, .-link
	.p2align 4
	.globl	find_set
	.type	find_set, @function
find_set:
.LFB52:
	.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
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	movslq	%edi, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	leaq	p(%rip), %rbx
	movq	%rbp, %rax
	movl	(%rbx,%rbp,4), %edx
	cmpl	%ebp, %edx
	jne	.L13
	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
.L13:
	.cfi_restore_state
	movslq	%edx, %r12
	movl	(%rbx,%r12,4), %eax
	cmpl	%eax, %edx
	je	.L8
	movslq	%eax, %r13
	movl	(%rbx,%r13,4), %edx
	cmpl	%edx, %eax
	jne	.L14
.L9:
	movl	%edx, (%rbx,%r12,4)
	movl	%edx, %eax
.L8:
	movl	%eax, (%rbx,%rbp,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
.L14:
	.cfi_restore_state
	movslq	%edx, %r14
	movl	(%rbx,%r14,4), %edi
	cmpl	%edi, %edx
	je	.L10
	call	find_set
	movl	%eax, (%rbx,%r14,4)
	movl	%eax, %edi
.L10:
	movl	%edi, (%rbx,%r13,4)
	movl	%edi, %edx
	jmp	.L9
	.cfi_endproc
.LFE52:
	.size	find_set, .-find_set
	.p2align 4
	.globl	union_set
	.type	union_set, @function
union_set:
.LFB53:
	.cfi_startproc
	endbr64
	leaq	p(%rip), %rcx
	movslq	%esi, %r9
	subq	$8, %rsp
	.cfi_def_cfa_offset 16
	movl	%edi, %r8d
	movl	(%rcx,%r9,4), %r10d
	cmpl	%r10d, %esi
	jne	.L26
.L16:
	movslq	%r8d, %rsi
	movl	(%rcx,%rsi,4), %eax
	cmpl	%eax, %r8d
	jne	.L27
.L20:
	leaq	rank(%rip), %rdx
	movslq	%eax, %r8
	movslq	%r10d, %rsi
	movl	(%rdx,%r8,4), %edi
	cmpl	(%rdx,%rsi,4), %edi
	jle	.L23
	movl	%eax, (%rcx,%rsi,4)
.L15:
	addq	$8, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L23:
	.cfi_restore_state
	movl	%r10d, (%rcx,%r8,4)
	jne	.L15
	addl	$1, %edi
	movl	%edi, (%rdx,%rsi,4)
	addq	$8, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L27:
	.cfi_restore_state
	movslq	%eax, %r8
	movl	(%rcx,%r8,4), %edx
	cmpl	%edx, %eax
	je	.L21
	movslq	%edx, %r9
	movl	(%rcx,%r9,4), %edi
	cmpl	%edi, %edx
	jne	.L28
.L22:
	movl	%edi, (%rcx,%r8,4)
	movl	%edi, %edx
.L21:
	movl	%edx, (%rcx,%rsi,4)
	movl	%edx, %eax
	jmp	.L20
	.p2align 4,,10
	.p2align 3
.L26:
	movslq	%r10d, %rsi
	movl	(%rcx,%rsi,4), %eax
	cmpl	%eax, %r10d
	je	.L17
	movslq	%eax, %r10
	movl	(%rcx,%r10,4), %edx
	cmpl	%edx, %eax
	jne	.L29
.L18:
	movl	%edx, (%rcx,%rsi,4)
	movl	%edx, %eax
.L17:
	movl	%eax, (%rcx,%r9,4)
	movl	%eax, %r10d
	jmp	.L16
	.p2align 4,,10
	.p2align 3
.L29:
	movslq	%edx, %r11
	movl	(%rcx,%r11,4), %edi
	cmpl	%edi, %edx
	je	.L19
	call	find_set
	movl	%eax, (%rcx,%r11,4)
	movl	%eax, %edi
.L19:
	movl	%edi, (%rcx,%r10,4)
	movl	%edi, %edx
	jmp	.L18
	.p2align 4,,10
	.p2align 3
.L28:
	call	find_set
	movl	%eax, (%rcx,%r9,4)
	movl	%eax, %edi
	jmp	.L22
	.cfi_endproc
.LFE53:
	.size	union_set, .-union_set
	.p2align 4
	.globl	getInt
	.type	getInt, @function
getInt:
.LFB54:
	.cfi_startproc
	endbr64
	movq	b(%rip), %rax
	movzbl	(%rax), %edx
	cmpb	$32, %dl
	jne	.L31
	leaq	1(%rax), %rcx
	movq	%rcx, b(%rip)
	movzbl	1(%rax), %edx
	movq	%rcx, %rax
.L31:
	cmpb	$47, %dl
	jle	.L34
	addq	$1, %rax
	xorl	%r8d, %r8d
	.p2align 4,,10
	.p2align 3
.L33:
	movq	%rax, b(%rip)
	movzbl	-1(%rax), %edx
	addq	$1, %rax
	leal	(%r8,%r8,4), %ecx
	andl	$15, %edx
	cmpb	$47, -1(%rax)
	leal	(%rdx,%rcx,2), %r8d
	jg	.L33
	movl	%r8d, %eax
	ret
	.p2align 4,,10
	.p2align 3
.L34:
	xorl	%r8d, %r8d
	movl	%r8d, %eax
	ret
	.cfi_endproc
.LFE54:
	.size	getInt, .-getInt
	.p2align 4
	.globl	distsort
	.type	distsort, @function
distsort:
.LFB55:
	.cfi_startproc
	endbr64
	leaq	f(%rip), %rcx
	subq	$8, %rsp
	.cfi_def_cfa_offset 16
	movl	$40004, %edx
	xorl	%esi, %esi
	movq	%rcx, %rdi
	call	memset@PLT
	movq	end(%rip), %r8
	leaq	edge(%rip), %r9
	movq	%rax, %rcx
	cmpq	%r9, %r8
	jbe	.L37
	movq	%r9, %rax
	.p2align 4,,10
	.p2align 3
.L38:
	movslq	8(%rax), %rdx
	addq	$12, %rax
	addl	$1, (%rcx,%rdx,4)
	cmpq	%r8, %rax
	jb	.L38
.L37:
	movl	vmin(%rip), %edi
	movl	vmax(%rip), %esi
	cmpl	%esi, %edi
	jge	.L39
	movslq	%edi, %r10
	subl	$1, %esi
	subl	%edi, %esi
	leaq	(%rcx,%r10,4), %rax
	leaq	4+f(%rip), %rdi
	addq	%r10, %rsi
	movl	(%rax), %edx
	leaq	(%rdi,%rsi,4), %rsi
	.p2align 4,,10
	.p2align 3
.L40:
	addl	4(%rax), %edx
	addq	$4, %rax
	movl	%edx, (%rax)
	cmpq	%rsi, %rax
	jne	.L40
.L39:
	movl	m(%rip), %esi
	leaq	edge2(%rip), %r10
	testl	%esi, %esi
	jle	.L41
	movslq	%esi, %rax
	subl	$1, %esi
	leaq	(%rax,%rax,2), %rdx
	subq	%rsi, %rax
	leaq	(%rax,%rax,2), %rsi
	leaq	-12+edge(%rip), %rax
	leaq	(%r9,%rdx,4), %rdx
	leaq	(%rax,%rsi,4), %r11
	.p2align 4,,10
	.p2align 3
.L42:
	movslq	-4(%rdx), %rdi
	subq	$12, %rdx
	movl	(%rcx,%rdi,4), %eax
	movq	%rdi, %rsi
	subl	$1, %eax
	movl	%eax, (%rcx,%rdi,4)
	cltq
	movq	(%rdx), %rdi
	leaq	(%rax,%rax,2), %rax
	leaq	(%r10,%rax,4), %rax
	movq	%rdi, (%rax)
	movl	%esi, 8(%rax)
	cmpq	%rdx, %r11
	jne	.L42
.L41:
	subq	%r9, %r8
	addq	%r8, %r10
	movq	%r10, end(%rip)
	addq	$8, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE55:
	.size	distsort, .-distsort
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC2:
	.string	"-1"
.LC3:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB56:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	pp(%rip), %rax
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	leaq	400(%rax), %rdx
	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
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$56, %rsp
	.cfi_def_cfa_offset 112
	movdqa	.LC0(%rip), %xmm0
	movdqa	.LC1(%rip), %xmm2
	.p2align 4,,10
	.p2align 3
.L49:
	movdqa	%xmm0, %xmm1
	addq	$16, %rax
	paddd	%xmm2, %xmm0
	movaps	%xmm1, -16(%rax)
	cmpq	%rax, %rdx
	jne	.L49
	leaq	p(%rip), %r12
.L50:
	leaq	buf(%rip), %rax
	movq	stdin(%rip), %rdx
	movl	$128, %esi
	movq	%rax, %rdi
	movq	%rax, b(%rip)
	call	fgets@PLT
	testq	%rax, %rax
	je	.L121
	movq	b(%rip), %rax
	movzbl	(%rax), %ecx
	cmpb	$48, %cl
	je	.L121
	cmpb	$32, %cl
	jne	.L51
	leaq	1(%rax), %rdx
	movq	%rdx, b(%rip)
	movzbl	1(%rax), %ecx
	movq	%rdx, %rax
.L51:
	cmpb	$47, %cl
	jle	.L112
	leaq	1(%rax), %rdx
	xorl	%r15d, %r15d
	.p2align 4,,10
	.p2align 3
.L53:
	movq	%rdx, %rax
	movq	%rdx, b(%rip)
	movzbl	-1(%rdx), %edx
	leal	(%r15,%r15,4), %ecx
	andl	$15, %edx
	leal	(%rdx,%rcx,2), %r15d
	movzbl	(%rax), %ecx
	leaq	1(%rax), %rdx
	cmpb	$47, %cl
	jg	.L53
	leal	0(,%r15,4), %ebx
.L52:
	cmpb	$32, %cl
	jne	.L54
	leaq	1(%rax), %rdx
	movq	%rdx, b(%rip)
	cmpb	$47, 1(%rax)
	jle	.L54
	addq	$2, %rax
	xorl	%edx, %edx
	.p2align 4,,10
	.p2align 3
.L55:
	movq	%rax, b(%rip)
	leal	(%rdx,%rdx,4), %ecx
	movzbl	-1(%rax), %edx
	addq	$1, %rax
	andl	$15, %edx
	cmpb	$47, -1(%rax)
	leal	(%rdx,%rcx,2), %edx
	jg	.L55
	movl	%edx, m(%rip)
	movl	$0, vmin(%rip)
	testl	%edx, %edx
	je	.L113
	leaq	edge(%rip), %rdi
	leaq	(%rdx,%rdx,2), %rax
	leaq	(%rdi,%rax,4), %rbp
	movq	%rdi, %r13
	.p2align 4,,10
	.p2align 3
.L68:
	leaq	buf(%rip), %rax
	movq	stdin(%rip), %rdx
	movl	$128, %esi
	movq	%rax, %rdi
	movq	%rax, b(%rip)
	call	fgets@PLT
	movq	b(%rip), %rax
	movzbl	(%rax), %edx
	cmpb	$32, %dl
	jne	.L57
	leaq	1(%rax), %rcx
	movq	%rcx, b(%rip)
	movzbl	1(%rax), %edx
	movq	%rcx, %rax
.L57:
	cmpb	$47, %dl
	jle	.L114
	leaq	1(%rax), %rcx
	xorl	%edx, %edx
	.p2align 4,,10
	.p2align 3
.L59:
	movq	%rcx, b(%rip)
	leal	(%rdx,%rdx,4), %esi
	movzbl	-1(%rcx), %edx
	movq	%rcx, %rax
	leaq	1(%rcx), %rcx
	andl	$15, %edx
	cmpb	$47, (%rax)
	leal	(%rdx,%rsi,2), %edx
	jg	.L59
	subl	$1, %edx
.L58:
	movl	%edx, 0(%r13)
	cmpb	$32, (%rax)
	jne	.L60
	addq	$1, %rax
	movq	%rax, b(%rip)
.L60:
	cmpb	$47, (%rax)
	jle	.L115
	leaq	1(%rax), %rcx
	xorl	%edx, %edx
	.p2align 4,,10
	.p2align 3
.L62:
	movq	%rcx, b(%rip)
	leal	(%rdx,%rdx,4), %esi
	movzbl	-1(%rcx), %edx
	movq	%rcx, %rax
	leaq	1(%rcx), %rcx
	andl	$15, %edx
	cmpb	$47, (%rax)
	leal	(%rdx,%rsi,2), %edx
	jg	.L62
	subl	$1, %edx
.L61:
	movl	%edx, 4(%r13)
	cmpb	$32, (%rax)
	jne	.L63
	addq	$1, %rax
	movq	%rax, b(%rip)
.L63:
	cmpb	$47, (%rax)
	jle	.L116
	addq	$1, %rax
	xorl	%edx, %edx
	.p2align 4,,10
	.p2align 3
.L65:
	movq	%rax, b(%rip)
	leal	(%rdx,%rdx,4), %ecx
	movzbl	-1(%rax), %edx
	addq	$1, %rax
	andl	$15, %edx
	cmpb	$47, -1(%rax)
	leal	(%rdx,%rcx,2), %edx
	jg	.L65
.L64:
	cmpl	%edx, vmin(%rip)
	movl	%edx, 8(%r13)
	jle	.L66
	movl	%edx, vmin(%rip)
.L67:
	addq	$12, %r13
	cmpq	%rbp, %r13
	jne	.L68
.L56:
	xorl	%eax, %eax
	movq	%rbp, end(%rip)
	call	distsort
	movl	m(%rip), %r13d
	testl	%r13d, %r13d
	jle	.L107
	movslq	%ebx, %rax
	movl	$2147483647, 28(%rsp)
	movq	end(%rip), %rbp
	leaq	rank(%rip), %rbx
	movq	%rax, 16(%rsp)
	leaq	edge2(%rip), %rax
	movq	%rax, 8(%rsp)
	movl	$0, 24(%rsp)
	.p2align 4,,10
	.p2align 3
.L106:
	movq	16(%rsp), %r14
	movl	$400, %ecx
	leaq	pp(%rip), %rsi
	movq	%r12, %rdi
	movq	%r14, %rdx
	call	__memcpy_chk@PLT
	movl	$400, %ecx
	movq	%r14, %rdx
	xorl	%esi, %esi
	movq	%rbx, %rdi
	call	__memset_chk@PLT
	movq	8(%rsp), %rax
	cmpq	%rbp, %rax
	jnb	.L71
	movq	%rax, %rsi
	movl	$1, %r10d
	jmp	.L105
	.p2align 4,,10
	.p2align 3
.L138:
	movslq	%r13d, %r9
	movl	(%r12,%r9,4), %eax
	cmpl	%eax, %r13d
	je	.L80
	movslq	%eax, %r11
	movl	(%r12,%r11,4), %edx
	cmpl	%edx, %eax
	je	.L81
	movslq	%edx, %r13
	movl	(%r12,%r13,4), %eax
	cmpl	%eax, %edx
	je	.L82
	movslq	%eax, %r14
	movl	(%r12,%r14,4), %edi
	cmpl	%edi, %eax
	je	.L83
	movslq	%edi, %rdx
	movl	(%r12,%rdx,4), %eax
	cmpl	%eax, %edi
	je	.L84
	movslq	%eax, %rdi
	movq	%rdi, 32(%rsp)
	movl	(%r12,%rdi,4), %edi
	cmpl	%edi, %eax
	je	.L85
	movq	%rdx, 40(%rsp)
	call	find_set
	movq	40(%rsp), %rdx
	movl	%eax, %edi
	movq	32(%rsp), %rax
	movl	%edi, (%r12,%rax,4)
.L85:
	movl	%edi, (%r12,%rdx,4)
	movl	%edi, %eax
.L84:
	movl	%eax, (%r12,%r14,4)
	movl	%eax, %edi
.L83:
	movl	%edi, (%r12,%r13,4)
	movl	%edi, %eax
.L82:
	movl	%eax, (%r12,%r11,4)
	movl	%eax, %edx
.L81:
	movl	%edx, (%r12,%r9,4)
	movl	%edx, %eax
.L80:
	movl	%eax, (%r12,%r8,4)
	cmpl	%eax, %ecx
	je	.L86
	movslq	4(%rsi), %r8
	movl	(%rsi), %ecx
	movl	(%r12,%r8,4), %eax
	movq	%r8, %r13
	cmpl	%eax, %r8d
	je	.L87
	movslq	%eax, %r11
	movl	(%r12,%r11,4), %r13d
	cmpl	%r13d, %eax
	je	.L88
	movslq	%r13d, %r9
	movl	(%r12,%r9,4), %eax
	cmpl	%eax, %r13d
	je	.L89
	movslq	%eax, %r13
	movl	(%r12,%r13,4), %edx
	cmpl	%edx, %eax
	je	.L90
	movslq	%edx, %r14
	movl	(%r12,%r14,4), %eax
	cmpl	%eax, %edx
	je	.L91
	movslq	%eax, %rdx
	movl	(%r12,%rdx,4), %edi
	cmpl	%edi, %eax
	je	.L92
	movslq	%edi, %rax
	movq	%rax, 32(%rsp)
	movl	(%r12,%rax,4), %eax
	cmpl	%eax, %edi
	je	.L93
	movl	%eax, %edi
	movq	%rdx, 40(%rsp)
	call	find_set
	movq	32(%rsp), %rdi
	movq	40(%rsp), %rdx
	movl	%eax, (%r12,%rdi,4)
.L93:
	movl	%eax, (%r12,%rdx,4)
	movl	%eax, %edi
.L92:
	movl	%edi, (%r12,%r14,4)
	movl	%edi, %eax
.L91:
	movl	%eax, (%r12,%r13,4)
	movl	%eax, %edx
.L90:
	movl	%edx, (%r12,%r9,4)
	movl	%edx, %eax
.L89:
	movl	%eax, (%r12,%r11,4)
	movl	%eax, %r13d
.L88:
	movl	%r13d, (%r12,%r8,4)
.L87:
	movslq	%ecx, %r8
	movl	(%r12,%r8,4), %eax
	cmpl	%eax, %ecx
	je	.L94
	movslq	%eax, %rcx
	movl	(%r12,%rcx,4), %edx
	cmpl	%edx, %eax
	je	.L95
	movslq	%edx, %r9
	movl	(%r12,%r9,4), %eax
	cmpl	%eax, %edx
	je	.L96
	movslq	%eax, %r11
	movl	(%r12,%r11,4), %edx
	cmpl	%edx, %eax
	je	.L97
	movslq	%edx, %r14
	movl	(%r12,%r14,4), %eax
	cmpl	%eax, %edx
	je	.L98
	movslq	%eax, %rdx
	movl	(%r12,%rdx,4), %edi
	cmpl	%edi, %eax
	je	.L99
	movslq	%edi, %rax
	movq	%rax, 32(%rsp)
	movl	(%r12,%rax,4), %eax
	cmpl	%eax, %edi
	je	.L100
	movl	%eax, %edi
	movq	%rdx, 40(%rsp)
	call	find_set
	movq	32(%rsp), %rdi
	movq	40(%rsp), %rdx
	movl	%eax, (%r12,%rdi,4)
.L100:
	movl	%eax, (%r12,%rdx,4)
	movl	%eax, %edi
.L99:
	movl	%edi, (%r12,%r14,4)
	movl	%edi, %eax
.L98:
	movl	%eax, (%r12,%r11,4)
	movl	%eax, %edx
.L97:
	movl	%edx, (%r12,%r9,4)
	movl	%edx, %eax
.L96:
	movl	%eax, (%r12,%rcx,4)
	movl	%eax, %edx
.L95:
	movl	%edx, (%r12,%r8,4)
	movl	%edx, %eax
.L94:
	movslq	%eax, %rdi
	movslq	%r13d, %rdx
	movl	(%rbx,%rdi,4), %ecx
	cmpl	(%rbx,%rdx,4), %ecx
	jle	.L101
	movl	%eax, (%r12,%rdx,4)
.L102:
	addl	$1, %r10d
	cmpl	%r15d, %r10d
	je	.L137
.L86:
	addq	$12, %rsi
	cmpq	%rbp, %rsi
	jnb	.L136
.L105:
	movslq	(%rsi), %r8
	movl	(%r12,%r8,4), %ecx
	cmpl	%ecx, %r8d
	je	.L72
	movslq	%ecx, %r9
	movl	(%r12,%r9,4), %eax
	cmpl	%eax, %ecx
	je	.L73
	movslq	%eax, %rcx
	movl	(%r12,%rcx,4), %edx
	cmpl	%edx, %eax
	je	.L74
	movslq	%edx, %r11
	movl	(%r12,%r11,4), %eax
	cmpl	%eax, %edx
	je	.L75
	movslq	%eax, %r13
	movl	(%r12,%r13,4), %edx
	cmpl	%edx, %eax
	je	.L76
	movslq	%edx, %r14
	movl	(%r12,%r14,4), %edi
	cmpl	%edi, %edx
	je	.L77
	movslq	%edi, %rdx
	movl	(%r12,%rdx,4), %eax
	movq	%rdx, 32(%rsp)
	cmpl	%eax, %edi
	je	.L78
	movl	%eax, %edi
	call	find_set
	movq	32(%rsp), %rdx
	movl	%eax, (%r12,%rdx,4)
.L78:
	movl	%eax, (%r12,%r14,4)
	movl	%eax, %edi
.L77:
	movl	%edi, (%r12,%r13,4)
	movl	%edi, %edx
.L76:
	movl	%edx, (%r12,%r11,4)
	movl	%edx, %eax
.L75:
	movl	%eax, (%r12,%rcx,4)
	movl	%eax, %edx
.L74:
	movl	%edx, (%r12,%r9,4)
	movl	%edx, %eax
.L73:
	movl	%eax, (%r12,%r8,4)
	movl	%eax, %ecx
.L72:
	movslq	4(%rsi), %r8
	movl	(%r12,%r8,4), %r13d
	cmpl	%r13d, %r8d
	jne	.L138
	cmpl	%ecx, %r13d
	je	.L86
	movl	(%rsi), %ecx
	jmp	.L87
	.p2align 4,,10
	.p2align 3
.L101:
	movl	%r13d, (%r12,%rdi,4)
	jne	.L102
	addl	$1, %ecx
	addl	$1, %r10d
	movl	%ecx, (%rbx,%rdx,4)
	cmpl	%r15d, %r10d
	jne	.L86
	.p2align 4,,10
	.p2align 3
.L137:
	movq	8(%rsp), %rdi
	movl	8(%rsi), %eax
	subl	8(%rdi), %eax
	cmpl	28(%rsp), %eax
	jge	.L136
	testl	%eax, %eax
	je	.L118
	movl	%eax, 28(%rsp)
	movl	m(%rip), %r13d
	.p2align 4,,10
	.p2align 3
.L71:
	addl	$1, 24(%rsp)
	movl	24(%rsp), %eax
	addq	$12, 8(%rsp)
	cmpl	%r13d, %eax
	jl	.L106
	cmpl	$2147483647, 28(%rsp)
	je	.L107
.L104:
	movl	28(%rsp), %edx
	leaq	.LC3(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L50
	.p2align 4,,10
	.p2align 3
.L136:
	movl	m(%rip), %r13d
	jmp	.L71
	.p2align 4,,10
	.p2align 3
.L66:
	cmpl	%edx, vmax(%rip)
	jge	.L67
	movl	%edx, vmax(%rip)
	jmp	.L67
.L114:
	movl	$-1, %edx
	jmp	.L58
.L116:
	xorl	%edx, %edx
	jmp	.L64
.L115:
	movl	$-1, %edx
	jmp	.L61
.L107:
	leaq	.LC2(%rip), %rdi
	call	puts@PLT
	jmp	.L50
.L118:
	movl	$0, 28(%rsp)
	jmp	.L104
.L54:
	movl	$0, m(%rip)
	leaq	edge(%rip), %rbp
	movl	$0, vmin(%rip)
	jmp	.L56
.L112:
	xorl	%ebx, %ebx
	xorl	%r15d, %r15d
	jmp	.L52
.L121:
	addq	$56, %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
.L113:
	.cfi_restore_state
	leaq	edge(%rip), %rbp
	jmp	.L56
	.cfi_endproc
.LFE56:
	.size	main, .-main
	.globl	vmin
	.bss
	.align 4
	.type	vmin, @object
	.size	vmin, 4
vmin:
	.zero	4
	.globl	vmax
	.align 4
	.type	vmax, @object
	.size	vmax, 4
vmax:
	.zero	4
	.globl	f
	.align 32
	.type	f, @object
	.size	f, 40004
f:
	.zero	40004
	.globl	b
	.align 8
	.type	b, @object
	.size	b, 8
b:
	.zero	8
	.globl	buf
	.align 32
	.type	buf, @object
	.size	buf, 130
buf:
	.zero	130
	.globl	m
	.align 4
	.type	m, @object
	.size	m, 4
m:
	.zero	4
	.globl	end
	.align 8
	.type	end, @object
	.size	end, 8
end:
	.zero	8
	.globl	edge2
	.align 32
	.type	edge2, @object
	.size	edge2, 60000
edge2:
	.zero	60000
	.globl	edge
	.align 32
	.type	edge, @object
	.size	edge, 60000
edge:
	.zero	60000
	.globl	pp
	.align 32
	.type	pp, @object
	.size	pp, 400
pp:
	.zero	400
	.globl	rank
	.align 32
	.type	rank, @object
	.size	rank, 400
rank:
	.zero	400
	.globl	p
	.align 32
	.type	p, @object
	.size	p, 400
p:
	.zero	400
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC0:
	.long	0
	.long	1
	.long	2
	.long	3
	.align 16
.LC1:
	.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:

// AOJ 1280: Slim Span
// 2017.10.22 bal4u@uu

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX 100
/* UNION-FIND library */
int p[MAX], rank[MAX], pp[MAX];
void link(int x, int y) {
	if (rank[x] > rank[y]) p[y] = x;
	else { p[x] = y; if (rank[x] == rank[y]) rank[y] = rank[y] + 1;	}
}
int find_set(int x) { if (x != p[x]) p[x] = find_set(p[x]);	return p[x]; }
void union_set(int x, int y) { link(find_set(x), find_set(y)); }

#define INF 0x7fffffff
typedef struct { int x, y, w; } EDGE;
EDGE edge[5000], edge2[5000], *end; int m;

char buf[130], *b;
int getInt(void)
{
	int n = 0;
	if (*b == ' ') b++;
	n = 0; while (*b >= '0' ) n = (n<<3) + (n<<1) + (*b++ & 0xf);
	return n;
}

#define VMAX 10000
int f[VMAX+1], vmax, vmin;
void distsort()
{
	int i, x;
	register EDGE *ep;

	memset(f, 0, sizeof(f));
	for (ep = edge; ep < end; ep++) f[ep->w]++;
	for (i = vmin+1; i <= vmax; i++) f[i] += f[i-1];
	for (i = m-1; i >= 0; i--) {
		x = edge[i].w, edge2[--f[x]] = edge[i];
	}
	end = edge2 + (end - edge);
}

int main() 
{
	int n, i, j, k, ans, sz;
	register EDGE *ep;

	for (j = 0; j < 100; j++)  pp[j] = j;
	while (fgets(b=buf, 128, stdin) && *b != '0') {
		n = getInt(), m = getInt();
		sz = sizeof(int)*n;
		for (vmin = VMAX+1, vmin = 0, ep = edge, k = m; k--; ep++) {
			fgets(b=buf, 128, stdin);
			ep->x = getInt()-1, ep->y = getInt()-1, ep->w = i = getInt();
			if (i < vmin) vmin = i;	else if (i > vmax) vmax = i;
		}
		end = ep;

		distsort();

		ans = INF;
		for (i = 0; i < m; i++) {
			memcpy(p, pp, sz), memset(rank, 0, sz);
			for (k = 1, ep = edge2+i; ep < end; ep++) {
				if (find_set(ep->x) != find_set(ep->y)) {
					union_set(ep->x, ep->y);
					if (++k == n) {
						if (ep->w - edge2[i].w < ans) {
							ans = ep->w - edge2[i].w;
							if (ans == 0) goto done;
						}
						break;
					}
				}
			}
		}
		if (ans == INF) puts("-1");
		else {
done:		printf("%d\n", ans);
		}
	}
	return 0; 
}
4 5
1 2 3
1 3 5
1 4 6
2 4 6
3 4 7
4 6
1 2 10
1 3 100
1 4 90
2 3 20
2 4 80
3 4 40
2 1
1 2 1
3 0
3 1
1 2 1
3 3
1 2 2
2 3 5
1 3 6
5 10
1 2 110
1 3 120
1 4 130
1 5 120
2 3 110
2 4 120
2 5 130
3 4 120
3 5 110
4 5 120
5 10
1 2 9384
1 3 887
1 4 2778
1 5 6916
2 3 7794
2 4 8336
2 5 5387
3 4 493
3 5 6650
4 5 1422
5 8
1 2 1
2 3 100
3 8 100
4 5 100
1 5 50
2 5 50
3 5 50
4 1 150
0 0
 4 5
1 2 3
1 3 5
1 4 6
2 4 7
3 4 7
4 6
1 2 10
1 3 100
1 4 90
2 3 20
2 4 80
3 4 40
2 1
1 2 1
3 0
3 1
1 2 1
3 3
1 2 2
2 3 5
1 3 6
5 10
1 2 110
1 3 120
1 4 130
1 5 120
2 3 110
2 4 120
2 5 130
3 4 120
3 5 110
4 5 120
5 10
1 2 9384
1 3 887
1 4 2778
1 5 6916
2 3 7794
2 4 8336
2 5 5387
3 4 493
3 4 6650
4 5 1422
5 8
1 2 1
2 3 100
3 8 100
4 5 100
1 5 50
2 5 50
3 5 50
4 1 150
0 0
 4 5
1 2 3
1 3 5
1 4 6
2 4 7
3 4 7
4 6
1 2 10
1 3 100
1 4 90
2 3 20
2 4 80
3 4 40
2 1
1 2 1
3 0
3 1
1 2 1
3 3
1 0 2
2 3 5
1 3 6
5 10
1 2 110
1 3 138
1 4 130
1 5 120
2 3 110
2 4 120
2 9 130
3 3 120
3 5 110
4 5 120
5 10
1 2 9384
1 3 887
1 4 2778
1 5 6916
2 3 7794
2 4 8336
2 5 5387
3 4 493
3 5 6650
4 5 1422
5 8
1 2 1
2 3 100
3 8 100
4 5 100
1 5 50
2 5 33
3 5 50
4 2 150
0 0
 6 5
1 2 3
1 3 5
1 4 6
2 4 7
3 4 7
4 6
1 2 10
1 3 100
1 4 90
3 3 20
2 4 80
3 4 40
2 1
1 2 1
3 0
3 1
1 2 1
3 3
1 0 2
2 3 5
1 3 6
5 10
1 2 110
1 3 138
1 4 130
1 5 120
4 3 110
2 4 98
2 9 130
3 2 120
3 5 110
4 5 120
5 10
1 2 9384
1 3 887
1 4 2778
1 5 6916
2 3 7794
2 4 8336
2 5 5387
6 4 493
3 5 6650
4 5 1422
5 8
1 2 1
2 3 100
3 8 100
4 5 100
1 5 50
2 5 33
3 5 50
4 2 150
0 0
 4 5
1 2 3
1 3 5
1 4 6
2 4 6
3 4 7
4 6
1 2 10
1 3 101
1 4 90
2 3 20
2 4 80
3 4 40
2 1
1 2 1
3 0
3 1
1 2 1
3 3
1 2 2
2 3 5
1 3 6
5 10
1 2 110
1 3 120
1 4 130
1 5 120
2 3 110
2 4 120
2 5 130
3 4 120
3 5 110
4 5 120
5 10
1 2 9384
1 3 887
1 4 2778
1 5 6916
2 3 7794
2 4 8336
2 5 5387
3 4 493
3 5 6650
4 5 1422
5 8
1 2 1
2 3 100
3 4 100
4 5 100
1 5 50
2 5 50
3 5 50
4 1 150
0 0
 4 5
1 2 3
1 3 5
1 4 6
2 4 6
3 4 6
4 6
1 2 10
1 3 100
1 4 90
2 3 20
2 4 80
3 4 40
2 1
1 2 1
3 0
3 1
1 2 1
3 3
1 2 2
2 3 5
1 3 6
5 10
1 2 110
1 3 120
1 4 130
1 5 120
2 3 110
2 4 120
2 5 130
3 4 120
3 5 110
4 5 120
5 10
1 2 9384
1 3 887
1 4 2778
1 5 6916
2 3 7794
2 4 8336
2 5 5387
3 4 493
3 5 6650
4 5 1422
5 8
1 2 1
2 3 100
3 8 100
4 5 100
1 5 50
2 5 50
3 5 50
4 1 150
0 0
 4 5
1 2 3
1 3 5
1 4 6
2 4 7
3 4 7
4 6
1 2 10
1 3 100
1 4 90
2 3 20
2 4 80
3 4 40
2 1
1 2 1
3 0
3 1
1 2 1
3 3
1 2 2
2 3 5
1 3 6
5 10
1 2 110
1 3 120
1 4 130
1 5 120
2 3 110
2 4 120
2 5 130
3 4 120
3 5 110
4 5 120
5 10
1 2 9384
1 3 887
1 4 2778
1 5 6916
2 3 7794
2 4 6931
2 5 5387
3 4 493
3 4 6650
4 5 1422
5 8
1 2 1
2 3 100
3 8 100
4 5 100
1 5 50
2 5 50
3 1 50
4 1 150
0 0
 6 5
1 2 3
1 3 5
1 4 6
2 4 7
3 4 7
4 6
1 2 10
1 3 100
1 4 175
3 3 30
2 4 80
3 4 40
2 1
1 2 1
3 0
3 1
1 2 1
3 3
1 0 2
2 3 5
1 3 6
5 10
1 2 110
1 3 138
1 4 130
1 5 120
4 3 110
2 4 98
2 9 130
3 2 120
3 5 110
4 5 120
5 10
1 2 9384
1 3 887
1 4 2778
1 5 6916
2 3 7794
2 4 8336
2 5 5387
6 4 493
3 5 6650
4 5 1422
5 8
1 2 1
2 3 100
3 8 100
4 5 100
1 5 50
2 5 33
3 5 50
4 2 150
0 0
 4 5
1 2 3
1 3 5
0 4 6
2 4 7
3 4 7
4 6
1 2 10
1 3 100
1 4 90
2 3 20
2 4 80
3 4 40
2 1
1 2 1
3 0
3 1
1 2 1
3 3
1 2 2
2 3 5
1 3 6
5 10
1 2 110
1 3 120
1 4 130
1 5 120
2 3 110
2 4 120
2 5 130
3 4 120
3 5 110
4 5 120
5 10
1 2 9384
1 3 1290
1 4 2778
1 5 6916
2 3 7794
2 4 8336
2 5 5387
3 4 493
3 5 6650
4 5 1422
5 8
1 2 1
2 3 100
3 8 100
4 5 100
1 5 50
2 5 50
3 5 50
4 1 150
0 0
 6 5
1 2 3
1 3 5
1 4 6
2 4 7
3 4 7
4 6
1 2 10
1 3 100
1 4 175
3 3 30
2 4 80
3 4 40
2 1
1 2 1
3 0
3 1
1 2 1
3 3
1 0 2
2 3 5
1 3 6
5 10
1 2 110
1 3 138
1 4 130
1 5 120
4 3 110
2 4 98
2 9 130
3 2 120
3 5 110
4 5 120
5 10
1 2 9384
1 3 887
1 4 2778
1 5 6916
2 3 7794
2 4 8336
2 5 5387
6 4 493
3 5 6650
4 5 1422
5 8
1 2 1
0 3 100
3 8 100
4 5 100
1 5 50
2 5 33
3 5 50
4 2 150
0 0

1
20
0
-1
-1
1
0
1686
50
 1
20
0
-1
-1
1
0
2407
50
 1
20
0
-1
-1
1
10
1686
50
 -1
20
0
-1
-1
1
10
1686
50
 1
21
0
-1
-1
1
0
1686
50
 0
20
0
-1
-1
1
0
1686
50
 1
20
0
-1
-1
1
0
1544
50
 -1
60
0
-1
-1
1
10
1686
50
 2
20
0
-1
-1
1
0
1686
50
 -1
60
0
-1
-1
1
10
1686
67

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

```c
// AOJ 1280: Slim Span
// 2017.10.22 bal4u@uu

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX 100
/* UNION-FIND library */
int p[MAX], rank[MAX], pp[MAX];
void link(int x, int y) {
	if (rank[x] > rank[y]) p[y] = x;
	else { p[x] = y; if (rank[x] == rank[y]) rank[y] = rank[y] + 1;	}
}
int find_set(int x) { if (x != p[x]) p[x] = find_set(p[x]);	return p[x]; }
void union_set(int x, int y) { link(find_set(x), find_set(y)); }

#define INF 0x7fffffff
typedef struct { int x, y, w; } EDGE;
EDGE edge[5000], edge2[5000], *end; int m;

char buf[130], *b;
int getInt(void)
{
	int n = 0;
	if (*b == ' ') b++;
	n = 0; while (*b >= '0' ) n = (n<<3) + (n<<1) + (*b++ & 0xf);
	return n;
}

#define VMAX 10000
int f[VMAX+1], vmax, vmin;
void distsort()
{
	int i, x;
	register EDGE *ep;

	memset(f, 0, sizeof(f));
	for (ep = edge; ep < end; ep++) f[ep->w]++;
	for (i = vmin+1; i <= vmax; i++) f[i] += f[i-1];
	for (i = m-1; i >= 0; i--) {
		x = edge[i].w, edge2[--f[x]] = edge[i];
	}
	end = edge2 + (end - edge);
}

int main() 
{
	int n, i, j, k, ans, sz;
	register EDGE *ep;

	for (j = 0; j < 100; j++)  pp[j] = j;
	while (fgets(b=buf, 128, stdin) && *b != '0') {
		n = getInt(), m = getInt();
		sz = sizeof(int)*n;
		for (vmin = VMAX+1, vmin = 0, ep = edge, k = m; k--; ep++) {
			fgets(b=buf, 128, stdin);
			ep->x = getInt()-1, ep->y = getInt()-1, ep->w = i = getInt();
			if (i < vmin) vmin = i;	else if (i > vmax) vmax = i;
		}
		end = ep;

		distsort();

		ans = INF;
		for (i = 0; i < m; i++) {
			memcpy(p, pp, sz), memset(rank, 0, sz);
			for (k = 1, ep = edge2+i; ep < end; ep++) {
				if (find_set(ep->x) != find_set(ep->y)) {
					union_set(ep->x, ep->y);
					if (++k == n) {
						if (ep->w - edge2[i].w < ans) {
							ans = ep->w - edge2[i].w;
							if (ans == 0) goto done;
						}
						break;
					}
				}
			}
		}
		if (ans == INF) puts("-1");
		else {
done:		printf("%d\n", ans);
		}
	}
	return 0; 
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	p
	.bss
	.align 32
	.type	p, @object
	.size	p, 400
p:
	.zero	400
	.globl	rank
	.align 32
	.type	rank, @object
	.size	rank, 400
rank:
	.zero	400
	.globl	pp
	.align 32
	.type	pp, @object
	.size	pp, 400
pp:
	.zero	400
	.text
	.globl	link
	.type	link, @function
link:
.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, -4(%rbp)
	movl	%esi, -8(%rbp)
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	rank(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	rank(%rip), %rax
	movl	(%rcx,%rax), %eax
	cmpl	%eax, %edx
	jle	.L2
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	p(%rip), %rdx
	movl	-4(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	jmp	.L4
.L2:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	p(%rip), %rdx
	movl	-8(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	rank(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	rank(%rip), %rax
	movl	(%rcx,%rax), %eax
	cmpl	%eax, %edx
	jne	.L4
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	rank(%rip), %rax
	movl	(%rdx,%rax), %eax
	leal	1(%rax), %ecx
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	rank(%rip), %rax
	movl	%ecx, (%rdx,%rax)
.L4:
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	link, .-link
	.globl	find_set
	.type	find_set, @function
find_set:
.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	.L6
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	p(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, %edi
	call	find_set
	movl	-4(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	p(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
.L6:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	p(%rip), %rax
	movl	(%rdx,%rax), %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	find_set, .-find_set
	.globl	union_set
	.type	union_set, @function
union_set:
.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	$24, %rsp
	.cfi_offset 3, -24
	movl	%edi, -20(%rbp)
	movl	%esi, -24(%rbp)
	movl	-24(%rbp), %eax
	movl	%eax, %edi
	call	find_set
	movl	%eax, %ebx
	movl	-20(%rbp), %eax
	movl	%eax, %edi
	call	find_set
	movl	%ebx, %esi
	movl	%eax, %edi
	call	link
	nop
	movq	-8(%rbp), %rbx
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.size	union_set, .-union_set
	.globl	edge
	.bss
	.align 32
	.type	edge, @object
	.size	edge, 60000
edge:
	.zero	60000
	.globl	edge2
	.align 32
	.type	edge2, @object
	.size	edge2, 60000
edge2:
	.zero	60000
	.globl	end
	.align 8
	.type	end, @object
	.size	end, 8
end:
	.zero	8
	.globl	m
	.align 4
	.type	m, @object
	.size	m, 4
m:
	.zero	4
	.globl	buf
	.align 32
	.type	buf, @object
	.size	buf, 130
buf:
	.zero	130
	.globl	b
	.align 8
	.type	b, @object
	.size	b, 8
b:
	.zero	8
	.text
	.globl	getInt
	.type	getInt, @function
getInt:
.LFB9:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	$0, -4(%rbp)
	movq	b(%rip), %rax
	movzbl	(%rax), %eax
	cmpb	$32, %al
	jne	.L10
	movq	b(%rip), %rax
	addq	$1, %rax
	movq	%rax, b(%rip)
.L10:
	movl	$0, -4(%rbp)
	jmp	.L11
.L12:
	movl	-4(%rbp), %eax
	leal	0(,%rax,8), %edx
	movl	-4(%rbp), %eax
	addl	%eax, %eax
	leal	(%rdx,%rax), %ecx
	movq	b(%rip), %rax
	leaq	1(%rax), %rdx
	movq	%rdx, b(%rip)
	movzbl	(%rax), %eax
	movsbl	%al, %eax
	andl	$15, %eax
	addl	%ecx, %eax
	movl	%eax, -4(%rbp)
.L11:
	movq	b(%rip), %rax
	movzbl	(%rax), %eax
	cmpb	$47, %al
	jg	.L12
	movl	-4(%rbp), %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE9:
	.size	getInt, .-getInt
	.globl	f
	.bss
	.align 32
	.type	f, @object
	.size	f, 40004
f:
	.zero	40004
	.globl	vmax
	.align 4
	.type	vmax, @object
	.size	vmax, 4
vmax:
	.zero	4
	.globl	vmin
	.align 4
	.type	vmin, @object
	.size	vmin, 4
vmin:
	.zero	4
	.text
	.globl	distsort
	.type	distsort, @function
distsort:
.LFB10:
	.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	$24, %rsp
	.cfi_offset 3, -24
	movl	$40004, %edx
	movl	$0, %esi
	leaq	f(%rip), %rax
	movq	%rax, %rdi
	call	memset@PLT
	leaq	edge(%rip), %rbx
	jmp	.L15
.L16:
	movl	8(%rbx), %eax
	movslq	%eax, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	f(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	leal	1(%rdx), %ecx
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	f(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	addq	$12, %rbx
.L15:
	movq	end(%rip), %rax
	cmpq	%rax, %rbx
	jb	.L16
	movl	vmin(%rip), %eax
	addl	$1, %eax
	movl	%eax, -24(%rbp)
	jmp	.L17
.L18:
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	f(%rip), %rax
	movl	(%rdx,%rax), %ecx
	movl	-24(%rbp), %eax
	subl	$1, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	f(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%eax, %ecx
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	f(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	addl	$1, -24(%rbp)
.L17:
	movl	vmax(%rip), %eax
	cmpl	%eax, -24(%rbp)
	jle	.L18
	movl	m(%rip), %eax
	subl	$1, %eax
	movl	%eax, -24(%rbp)
	jmp	.L19
.L20:
	movl	-24(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	leaq	8+edge(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -20(%rbp)
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	f(%rip), %rax
	movl	(%rdx,%rax), %eax
	leal	-1(%rax), %ecx
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	f(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	f(%rip), %rax
	movl	(%rdx,%rax), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rcx
	leaq	edge2(%rip), %rdx
	movl	-24(%rbp), %eax
	movslq	%eax, %rsi
	movq	%rsi, %rax
	addq	%rax, %rax
	addq	%rsi, %rax
	salq	$2, %rax
	movq	%rax, %rsi
	leaq	edge(%rip), %rax
	movq	(%rsi,%rax), %rdi
	movq	%rdi, (%rcx,%rdx)
	movl	8(%rsi,%rax), %eax
	movl	%eax, 8(%rcx,%rdx)
	subl	$1, -24(%rbp)
.L19:
	cmpl	$0, -24(%rbp)
	jns	.L20
	movq	end(%rip), %rax
	leaq	edge(%rip), %rdx
	subq	%rdx, %rax
	movq	%rax, %rdx
	leaq	edge2(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, end(%rip)
	nop
	movq	-8(%rbp), %rbx
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE10:
	.size	distsort, .-distsort
	.section	.rodata
.LC0:
	.string	"-1"
.LC1:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB11:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%r12
	pushq	%rbx
	subq	$32, %rsp
	.cfi_offset 12, -24
	.cfi_offset 3, -32
	movl	$0, -36(%rbp)
	jmp	.L22
.L23:
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	pp(%rip), %rdx
	movl	-36(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	addl	$1, -36(%rbp)
.L22:
	cmpl	$99, -36(%rbp)
	jle	.L23
	jmp	.L24
.L38:
	call	getInt
	movl	%eax, -24(%rbp)
	call	getInt
	movl	%eax, m(%rip)
	movl	-24(%rbp), %eax
	cltq
	sall	$2, %eax
	movl	%eax, -20(%rbp)
	movl	$10001, vmin(%rip)
	movl	$0, vmin(%rip)
	leaq	edge(%rip), %rbx
	movl	m(%rip), %eax
	movl	%eax, -32(%rbp)
	jmp	.L25
.L28:
	movq	stdin(%rip), %rdx
	leaq	buf(%rip), %rax
	movq	%rax, b(%rip)
	movq	b(%rip), %rax
	movl	$128, %esi
	movq	%rax, %rdi
	call	fgets@PLT
	call	getInt
	subl	$1, %eax
	movl	%eax, (%rbx)
	call	getInt
	subl	$1, %eax
	movl	%eax, 4(%rbx)
	call	getInt
	movl	%eax, -40(%rbp)
	movl	-40(%rbp), %eax
	movl	%eax, 8(%rbx)
	movl	vmin(%rip), %eax
	cmpl	%eax, -40(%rbp)
	jge	.L26
	movl	-40(%rbp), %eax
	movl	%eax, vmin(%rip)
	jmp	.L27
.L26:
	movl	vmax(%rip), %eax
	cmpl	%eax, -40(%rbp)
	jle	.L27
	movl	-40(%rbp), %eax
	movl	%eax, vmax(%rip)
.L27:
	addq	$12, %rbx
.L25:
	movl	-32(%rbp), %eax
	leal	-1(%rax), %edx
	movl	%edx, -32(%rbp)
	testl	%eax, %eax
	jne	.L28
	movq	%rbx, end(%rip)
	movl	$0, %eax
	call	distsort
	movl	$2147483647, -28(%rbp)
	movl	$0, -40(%rbp)
	jmp	.L29
.L36:
	movl	-20(%rbp), %eax
	cltq
	movq	%rax, %rdx
	leaq	pp(%rip), %rax
	movq	%rax, %rsi
	leaq	p(%rip), %rax
	movq	%rax, %rdi
	call	memcpy@PLT
	movl	-20(%rbp), %eax
	cltq
	movq	%rax, %rdx
	movl	$0, %esi
	leaq	rank(%rip), %rax
	movq	%rax, %rdi
	call	memset@PLT
	movl	$1, -32(%rbp)
	movl	-40(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	leaq	edge2(%rip), %rax
	leaq	(%rdx,%rax), %rbx
	jmp	.L30
.L35:
	movl	(%rbx), %eax
	movl	%eax, %edi
	call	find_set
	movl	%eax, %r12d
	movl	4(%rbx), %eax
	movl	%eax, %edi
	call	find_set
	cmpl	%eax, %r12d
	je	.L31
	movl	4(%rbx), %edx
	movl	(%rbx), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	union_set
	addl	$1, -32(%rbp)
	movl	-32(%rbp), %eax
	cmpl	-24(%rbp), %eax
	jne	.L31
	movl	8(%rbx), %ecx
	movl	-40(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	leaq	8+edge2(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	%ecx, %eax
	subl	%edx, %eax
	cmpl	%eax, -28(%rbp)
	jle	.L40
	movl	8(%rbx), %ecx
	movl	-40(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	leaq	8+edge2(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	%ecx, %eax
	subl	%edx, %eax
	movl	%eax, -28(%rbp)
	cmpl	$0, -28(%rbp)
	jne	.L40
	jmp	.L33
.L31:
	addq	$12, %rbx
.L30:
	movq	end(%rip), %rax
	cmpq	%rax, %rbx
	jb	.L35
	jmp	.L34
.L40:
	nop
.L34:
	addl	$1, -40(%rbp)
.L29:
	movl	m(%rip), %eax
	cmpl	%eax, -40(%rbp)
	jl	.L36
	cmpl	$2147483647, -28(%rbp)
	jne	.L41
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	jmp	.L24
.L41:
	nop
.L33:
	movl	-28(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L24:
	movq	stdin(%rip), %rdx
	leaq	buf(%rip), %rax
	movq	%rax, b(%rip)
	movq	b(%rip), %rax
	movl	$128, %esi
	movq	%rax, %rdi
	call	fgets@PLT
	testq	%rax, %rax
	je	.L37
	movq	b(%rip), %rax
	movzbl	(%rax), %eax
	cmpb	$48, %al
	jne	.L38
.L37:
	movl	$0, %eax
	addq	$32, %rsp
	popq	%rbx
	popq	%r12
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE11:
	.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, 400
p:
	.zero	400
	.globl	rank
	.align 32
	.type	rank, @object
	.size	rank, 400
rank:
	.zero	400
	.globl	pp
	.align 32
	.type	pp, @object
	.size	pp, 400
pp:
	.zero	400
	.text
	.globl	link
	.type	link, @function
link:
.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, -4(%rbp)
	movl	%esi, -8(%rbp)
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	rank(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	rank(%rip), %rax
	movl	(%rcx,%rax), %eax
	cmpl	%eax, %edx
	jle	.L2
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	p(%rip), %rdx
	movl	-4(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	jmp	.L4
.L2:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	p(%rip), %rdx
	movl	-8(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	rank(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	rank(%rip), %rax
	movl	(%rcx,%rax), %eax
	cmpl	%eax, %edx
	jne	.L4
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	rank(%rip), %rax
	movl	(%rdx,%rax), %eax
	leal	1(%rax), %ecx
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	rank(%rip), %rax
	movl	%ecx, (%rdx,%rax)
.L4:
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	link, .-link
	.globl	find_set
	.type	find_set, @function
find_set:
.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	.L6
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	p(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, %edi
	call	find_set
	movl	-4(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	p(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
.L6:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	p(%rip), %rax
	movl	(%rdx,%rax), %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	find_set, .-find_set
	.globl	union_set
	.type	union_set, @function
union_set:
.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	$24, %rsp
	.cfi_offset 3, -24
	movl	%edi, -20(%rbp)
	movl	%esi, -24(%rbp)
	movl	-24(%rbp), %eax
	movl	%eax, %edi
	call	find_set
	movl	%eax, %ebx
	movl	-20(%rbp), %eax
	movl	%eax, %edi
	call	find_set
	movl	%ebx, %esi
	movl	%eax, %edi
	call	link
	nop
	movq	-8(%rbp), %rbx
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.size	union_set, .-union_set
	.globl	edge
	.bss
	.align 32
	.type	edge, @object
	.size	edge, 60000
edge:
	.zero	60000
	.globl	edge2
	.align 32
	.type	edge2, @object
	.size	edge2, 60000
edge2:
	.zero	60000
	.globl	end
	.align 8
	.type	end, @object
	.size	end, 8
end:
	.zero	8
	.globl	m
	.align 4
	.type	m, @object
	.size	m, 4
m:
	.zero	4
	.globl	buf
	.align 32
	.type	buf, @object
	.size	buf, 130
buf:
	.zero	130
	.globl	b
	.align 8
	.type	b, @object
	.size	b, 8
b:
	.zero	8
	.text
	.globl	getInt
	.type	getInt, @function
getInt:
.LFB9:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	$0, -4(%rbp)
	movq	b(%rip), %rax
	movzbl	(%rax), %eax
	cmpb	$32, %al
	jne	.L10
	movq	b(%rip), %rax
	addq	$1, %rax
	movq	%rax, b(%rip)
.L10:
	movl	$0, -4(%rbp)
	jmp	.L11
.L12:
	movl	-4(%rbp), %eax
	leal	0(,%rax,8), %edx
	movl	-4(%rbp), %eax
	addl	%eax, %eax
	leal	(%rdx,%rax), %ecx
	movq	b(%rip), %rax
	leaq	1(%rax), %rdx
	movq	%rdx, b(%rip)
	movzbl	(%rax), %eax
	movsbl	%al, %eax
	andl	$15, %eax
	addl	%ecx, %eax
	movl	%eax, -4(%rbp)
.L11:
	movq	b(%rip), %rax
	movzbl	(%rax), %eax
	cmpb	$47, %al
	jg	.L12
	movl	-4(%rbp), %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE9:
	.size	getInt, .-getInt
	.globl	f
	.bss
	.align 32
	.type	f, @object
	.size	f, 40004
f:
	.zero	40004
	.globl	vmax
	.align 4
	.type	vmax, @object
	.size	vmax, 4
vmax:
	.zero	4
	.globl	vmin
	.align 4
	.type	vmin, @object
	.size	vmin, 4
vmin:
	.zero	4
	.text
	.globl	distsort
	.type	distsort, @function
distsort:
.LFB10:
	.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	$24, %rsp
	.cfi_offset 3, -24
	movl	$40004, %edx
	movl	$0, %esi
	leaq	f(%rip), %rax
	movq	%rax, %rdi
	call	memset@PLT
	leaq	edge(%rip), %rbx
	jmp	.L15
.L16:
	movl	8(%rbx), %eax
	movslq	%eax, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	f(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	leal	1(%rdx), %ecx
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	f(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	addq	$12, %rbx
.L15:
	movq	end(%rip), %rax
	cmpq	%rax, %rbx
	jb	.L16
	movl	vmin(%rip), %eax
	addl	$1, %eax
	movl	%eax, -24(%rbp)
	jmp	.L17
.L18:
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	f(%rip), %rax
	movl	(%rdx,%rax), %ecx
	movl	-24(%rbp), %eax
	subl	$1, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	f(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%eax, %ecx
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	f(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	addl	$1, -24(%rbp)
.L17:
	movl	vmax(%rip), %eax
	cmpl	%eax, -24(%rbp)
	jle	.L18
	movl	m(%rip), %eax
	subl	$1, %eax
	movl	%eax, -24(%rbp)
	jmp	.L19
.L20:
	movl	-24(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	leaq	8+edge(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -20(%rbp)
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	f(%rip), %rax
	movl	(%rdx,%rax), %eax
	leal	-1(%rax), %ecx
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	f(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	f(%rip), %rax
	movl	(%rdx,%rax), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rcx
	leaq	edge2(%rip), %rdx
	movl	-24(%rbp), %eax
	movslq	%eax, %rsi
	movq	%rsi, %rax
	addq	%rax, %rax
	addq	%rsi, %rax
	salq	$2, %rax
	movq	%rax, %rsi
	leaq	edge(%rip), %rax
	movq	(%rsi,%rax), %rdi
	movq	%rdi, (%rcx,%rdx)
	movl	8(%rsi,%rax), %eax
	movl	%eax, 8(%rcx,%rdx)
	subl	$1, -24(%rbp)
.L19:
	cmpl	$0, -24(%rbp)
	jns	.L20
	movq	end(%rip), %rax
	leaq	edge(%rip), %rdx
	subq	%rdx, %rax
	movq	%rax, %rdx
	leaq	edge2(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, end(%rip)
	nop
	movq	-8(%rbp), %rbx
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE10:
	.size	distsort, .-distsort
	.section	.rodata
.LC0:
	.string	"-1"
.LC1:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB11:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%r12
	pushq	%rbx
	subq	$32, %rsp
	.cfi_offset 12, -24
	.cfi_offset 3, -32
	movl	$0, -36(%rbp)
	jmp	.L22
.L23:
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	pp(%rip), %rdx
	movl	-36(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	addl	$1, -36(%rbp)
.L22:
	cmpl	$99, -36(%rbp)
	jle	.L23
	jmp	.L24
.L38:
	call	getInt
	movl	%eax, -24(%rbp)
	call	getInt
	movl	%eax, m(%rip)
	movl	-24(%rbp), %eax
	cltq
	sall	$2, %eax
	movl	%eax, -20(%rbp)
	movl	$10001, vmin(%rip)
	movl	$0, vmin(%rip)
	leaq	edge(%rip), %rbx
	movl	m(%rip), %eax
	movl	%eax, -32(%rbp)
	jmp	.L25
.L28:
	movq	stdin(%rip), %rdx
	leaq	buf(%rip), %rax
	movq	%rax, b(%rip)
	movq	b(%rip), %rax
	movl	$128, %esi
	movq	%rax, %rdi
	call	fgets@PLT
	call	getInt
	subl	$1, %eax
	movl	%eax, (%rbx)
	call	getInt
	subl	$1, %eax
	movl	%eax, 4(%rbx)
	call	getInt
	movl	%eax, -40(%rbp)
	movl	-40(%rbp), %eax
	movl	%eax, 8(%rbx)
	movl	vmin(%rip), %eax
	cmpl	%eax, -40(%rbp)
	jge	.L26
	movl	-40(%rbp), %eax
	movl	%eax, vmin(%rip)
	jmp	.L27
.L26:
	movl	vmax(%rip), %eax
	cmpl	%eax, -40(%rbp)
	jle	.L27
	movl	-40(%rbp), %eax
	movl	%eax, vmax(%rip)
.L27:
	addq	$12, %rbx
.L25:
	movl	-32(%rbp), %eax
	leal	-1(%rax), %edx
	movl	%edx, -32(%rbp)
	testl	%eax, %eax
	jne	.L28
	movq	%rbx, end(%rip)
	movl	$0, %eax
	call	distsort
	movl	$2147483647, -28(%rbp)
	movl	$0, -40(%rbp)
	jmp	.L29
.L36:
	movl	-20(%rbp), %eax
	cltq
	movq	%rax, %rdx
	leaq	pp(%rip), %rax
	movq	%rax, %rsi
	leaq	p(%rip), %rax
	movq	%rax, %rdi
	call	memcpy@PLT
	movl	-20(%rbp), %eax
	cltq
	movq	%rax, %rdx
	movl	$0, %esi
	leaq	rank(%rip), %rax
	movq	%rax, %rdi
	call	memset@PLT
	movl	$1, -32(%rbp)
	movl	-40(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	leaq	edge2(%rip), %rax
	leaq	(%rdx,%rax), %rbx
	jmp	.L30
.L35:
	movl	(%rbx), %eax
	movl	%eax, %edi
	call	find_set
	movl	%eax, %r12d
	movl	4(%rbx), %eax
	movl	%eax, %edi
	call	find_set
	cmpl	%eax, %r12d
	je	.L31
	movl	4(%rbx), %edx
	movl	(%rbx), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	union_set
	addl	$1, -32(%rbp)
	movl	-32(%rbp), %eax
	cmpl	-24(%rbp), %eax
	jne	.L31
	movl	8(%rbx), %ecx
	movl	-40(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	leaq	8+edge2(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	%ecx, %eax
	subl	%edx, %eax
	cmpl	%eax, -28(%rbp)
	jle	.L40
	movl	8(%rbx), %ecx
	movl	-40(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	leaq	8+edge2(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	%ecx, %eax
	subl	%edx, %eax
	movl	%eax, -28(%rbp)
	cmpl	$0, -28(%rbp)
	jne	.L40
	jmp	.L33
.L31:
	addq	$12, %rbx
.L30:
	movq	end(%rip), %rax
	cmpq	%rax, %rbx
	jb	.L35
	jmp	.L34
.L40:
	nop
.L34:
	addl	$1, -40(%rbp)
.L29:
	movl	m(%rip), %eax
	cmpl	%eax, -40(%rbp)
	jl	.L36
	cmpl	$2147483647, -28(%rbp)
	jne	.L41
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	jmp	.L24
.L41:
	nop
.L33:
	movl	-28(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L24:
	movq	stdin(%rip), %rdx
	leaq	buf(%rip), %rax
	movq	%rax, b(%rip)
	movq	b(%rip), %rax
	movl	$128, %esi
	movq	%rax, %rdi
	call	fgets@PLT
	testq	%rax, %rax
	je	.L37
	movq	b(%rip), %rax
	movzbl	(%rax), %eax
	cmpb	$48, %al
	jne	.L38
.L37:
	movl	$0, %eax
	addq	$32, %rsp
	popq	%rbx
	popq	%r12
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE11:
	.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:
