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>
 
void unite(long *affiliation, long *group, long p, long q) {
  long i,j;
  j = 0;
  for (i = 0; j < group[q]; i++) {
    if(affiliation[i] == q) {
      affiliation[i] = p;
      j++;
    }
  }
  group[p] += group[q];
}
 
int main()
{
  long n,m,i,s,t,p,q;
  long *affiliation,*group;
  scanf("%ld %ld",&n,&m);
  affiliation = (long*)malloc(sizeof(long) * n);
  for (i = 0; i < n; i++) affiliation[i] = -1;
  group = (long*)malloc(sizeof(long) * m);
  for (i = 0; i < m; i++) group[i] = 0;
  p = 0;
  for (i = 0; i < m; i++) {
    scanf("%ld %ld", &s, &t);
    if(affiliation[s] == -1 && affiliation[t] == -1) {
      affiliation[s] = p;
      affiliation[t] = p;
      group[p] += 2;
      p++;
    }
    else if(affiliation[s] != -1 && affiliation[t] == -1) {
      affiliation[t] = affiliation[s];
      group[affiliation[s]]++;
    }
    else if(affiliation[s] == -1 && affiliation[t] != -1) {
      affiliation[s] = affiliation[t];
      group[affiliation[t]]++;
    }
    else if(affiliation[s] != affiliation[t]){
      (affiliation[s] < affiliation[t]) ? unite(affiliation,group,affiliation[s],affiliation[t]):unite(affiliation,group,affiliation[t],affiliation[s]);
    }
  }
  scanf("%ld",&q);
  for (i = 0; i < q; i++) {
    scanf("%ld %ld", &s, &t);
    if(affiliation[s] == affiliation[t] && affiliation[s] != -1) printf("yes\n");
    else printf("no\n");
  }
  free(affiliation);
  free(group);
   
  return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	unite
	.type	unite, @function
unite:
.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, -24(%rbp)
	movq	%rsi, -32(%rbp)
	movq	%rdx, -40(%rbp)
	movq	%rcx, -48(%rbp)
	movq	$0, -8(%rbp)
	movq	$0, -16(%rbp)
	jmp	.L2
.L4:
	movq	-16(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rax
	cmpq	%rax, -48(%rbp)
	jne	.L3
	movq	-16(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	movq	-24(%rbp), %rax
	addq	%rax, %rdx
	movq	-40(%rbp), %rax
	movq	%rax, (%rdx)
	addq	$1, -8(%rbp)
.L3:
	addq	$1, -16(%rbp)
.L2:
	movq	-48(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	movq	-32(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rax
	cmpq	%rax, -8(%rbp)
	jl	.L4
	movq	-40(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	movq	-32(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rcx
	movq	-48(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	movq	-32(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rdx
	movq	-40(%rbp), %rax
	leaq	0(,%rax,8), %rsi
	movq	-32(%rbp), %rax
	addq	%rsi, %rax
	addq	%rcx, %rdx
	movq	%rdx, (%rax)
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	unite, .-unite
	.section	.rodata
.LC0:
	.string	"%ld %ld"
.LC1:
	.string	"%ld"
.LC2:
	.string	"yes"
.LC3:
	.string	"no"
	.text
	.globl	main
	.type	main, @function
main:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$80, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-72(%rbp), %rdx
	leaq	-80(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	-80(%rbp), %rax
	salq	$3, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, -24(%rbp)
	movq	$0, -40(%rbp)
	jmp	.L6
.L7:
	movq	-40(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movq	$-1, (%rax)
	addq	$1, -40(%rbp)
.L6:
	movq	-80(%rbp), %rax
	cmpq	%rax, -40(%rbp)
	jl	.L7
	movq	-72(%rbp), %rax
	salq	$3, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, -16(%rbp)
	movq	$0, -40(%rbp)
	jmp	.L8
.L9:
	movq	-40(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movq	$0, (%rax)
	addq	$1, -40(%rbp)
.L8:
	movq	-72(%rbp), %rax
	cmpq	%rax, -40(%rbp)
	jl	.L9
	movq	$0, -32(%rbp)
	movq	$0, -40(%rbp)
	jmp	.L10
.L16:
	leaq	-56(%rbp), %rdx
	leaq	-64(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	-64(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rax
	cmpq	$-1, %rax
	jne	.L11
	movq	-56(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rax
	cmpq	$-1, %rax
	jne	.L11
	movq	-64(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	movq	-24(%rbp), %rax
	addq	%rax, %rdx
	movq	-32(%rbp), %rax
	movq	%rax, (%rdx)
	movq	-56(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	movq	-24(%rbp), %rax
	addq	%rax, %rdx
	movq	-32(%rbp), %rax
	movq	%rax, (%rdx)
	movq	-32(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rdx
	movq	-32(%rbp), %rax
	leaq	0(,%rax,8), %rcx
	movq	-16(%rbp), %rax
	addq	%rcx, %rax
	addq	$2, %rdx
	movq	%rdx, (%rax)
	addq	$1, -32(%rbp)
	jmp	.L12
.L11:
	movq	-64(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rax
	cmpq	$-1, %rax
	je	.L13
	movq	-56(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rax
	cmpq	$-1, %rax
	jne	.L13
	movq	-64(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movq	-56(%rbp), %rdx
	leaq	0(,%rdx,8), %rcx
	movq	-24(%rbp), %rdx
	addq	%rcx, %rdx
	movq	(%rax), %rax
	movq	%rax, (%rdx)
	movq	-64(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rax
	leaq	0(,%rax,8), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rdx
	addq	$1, %rdx
	movq	%rdx, (%rax)
	jmp	.L12
.L13:
	movq	-64(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rax
	cmpq	$-1, %rax
	jne	.L14
	movq	-56(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rax
	cmpq	$-1, %rax
	je	.L14
	movq	-56(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movq	-64(%rbp), %rdx
	leaq	0(,%rdx,8), %rcx
	movq	-24(%rbp), %rdx
	addq	%rcx, %rdx
	movq	(%rax), %rax
	movq	%rax, (%rdx)
	movq	-56(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rax
	leaq	0(,%rax,8), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rdx
	addq	$1, %rdx
	movq	%rdx, (%rax)
	jmp	.L12
.L14:
	movq	-64(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rdx
	movq	-56(%rbp), %rax
	leaq	0(,%rax,8), %rcx
	movq	-24(%rbp), %rax
	addq	%rcx, %rax
	movq	(%rax), %rax
	cmpq	%rax, %rdx
	je	.L12
	movq	-64(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rdx
	movq	-56(%rbp), %rax
	leaq	0(,%rax,8), %rcx
	movq	-24(%rbp), %rax
	addq	%rcx, %rax
	movq	(%rax), %rax
	cmpq	%rax, %rdx
	jge	.L15
	movq	-56(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rcx
	movq	-64(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rdx
	movq	-16(%rbp), %rsi
	movq	-24(%rbp), %rax
	movq	%rax, %rdi
	call	unite
	jmp	.L12
.L15:
	movq	-64(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rcx
	movq	-56(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rdx
	movq	-16(%rbp), %rsi
	movq	-24(%rbp), %rax
	movq	%rax, %rdi
	call	unite
.L12:
	addq	$1, -40(%rbp)
.L10:
	movq	-72(%rbp), %rax
	cmpq	%rax, -40(%rbp)
	jl	.L16
	leaq	-48(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	$0, -40(%rbp)
	jmp	.L17
.L20:
	leaq	-56(%rbp), %rdx
	leaq	-64(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	-64(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rdx
	movq	-56(%rbp), %rax
	leaq	0(,%rax,8), %rcx
	movq	-24(%rbp), %rax
	addq	%rcx, %rax
	movq	(%rax), %rax
	cmpq	%rax, %rdx
	jne	.L18
	movq	-64(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rax
	cmpq	$-1, %rax
	je	.L18
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	jmp	.L19
.L18:
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
.L19:
	addq	$1, -40(%rbp)
.L17:
	movq	-48(%rbp), %rax
	cmpq	%rax, -40(%rbp)
	jl	.L20
	movq	-24(%rbp), %rax
	movq	%rax, %rdi
	call	free@PLT
	movq	-16(%rbp), %rax
	movq	%rax, %rdi
	call	free@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L22
	call	__stack_chk_fail@PLT
.L22:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.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	unite
	.type	unite, @function
unite:
.LFB39:
	.cfi_startproc
	endbr64
	leaq	(%rsi,%rcx,8), %r9
	movq	(%r9), %r8
	testq	%r8, %r8
	jle	.L2
	xorl	%eax, %eax
	.p2align 4,,10
	.p2align 3
.L5:
	cmpq	%rcx, (%rdi)
	je	.L7
	addq	$8, %rdi
	cmpq	%r8, %rax
	jl	.L5
.L2:
	addq	%r8, (%rsi,%rdx,8)
	ret
	.p2align 4,,10
	.p2align 3
.L7:
	movq	%rdx, (%rdi)
	movq	(%r9), %r8
	addq	$1, %rax
	addq	$8, %rdi
	cmpq	%r8, %rax
	jl	.L5
	addq	%r8, (%rsi,%rdx,8)
	ret
	.cfi_endproc
.LFE39:
	.size	unite, .-unite
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%ld %ld"
.LC1:
	.string	"%ld"
.LC2:
	.string	"yes"
.LC3:
	.string	"no"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB40:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	leaq	.LC0(%rip), %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movq	%r13, %rdi
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$72, %rsp
	.cfi_def_cfa_offset 128
	movq	%fs:40, %rax
	movq	%rax, 56(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rdx
	leaq	16(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movq	16(%rsp), %rbx
	leaq	0(,%rbx,8), %r12
	movq	%r12, %rdi
	call	malloc@PLT
	movq	%rax, %rbp
	testq	%rbx, %rbx
	jle	.L12
	movq	%r12, %rdx
	movl	$255, %esi
	movq	%rax, %rdi
	call	memset@PLT
.L12:
	movq	24(%rsp), %rbx
	movl	$1, %esi
	leaq	0(,%rbx,8), %rdi
	call	calloc@PLT
	movq	%rax, %r12
	testq	%rbx, %rbx
	jle	.L11
	movq	$0, 8(%rsp)
	xorl	%ebx, %ebx
	leaq	40(%rsp), %r15
	leaq	32(%rsp), %r14
	.p2align 4,,10
	.p2align 3
.L10:
	movq	%r15, %rdx
	movq	%r14, %rsi
	movq	%r13, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movq	32(%rsp), %rax
	leaq	0(%rbp,%rax,8), %rdx
	movq	(%rdx), %rax
	cmpq	$-1, %rax
	je	.L47
	movq	40(%rsp), %rcx
	leaq	0(%rbp,%rcx,8), %rsi
	movq	(%rsi), %rcx
	cmpq	$-1, %rcx
	je	.L48
	cmpq	%rcx, %rax
	je	.L17
	leaq	(%r12,%rcx,8), %r10
	leaq	(%r12,%rax,8), %r11
	movq	%rbp, %rdx
	movl	$0, %edi
	movq	(%r10), %rsi
	movq	(%r11), %r9
	jl	.L19
	testq	%r9, %r9
	jle	.L28
	.p2align 4,,10
	.p2align 3
.L29:
	cmpq	(%rdx), %rax
	je	.L49
	addq	$8, %rdx
	cmpq	%rdi, %r9
	jg	.L29
.L28:
	addq	%r9, %rsi
	movq	%rsi, (%r10)
	.p2align 4,,10
	.p2align 3
.L17:
	addq	$1, %rbx
	cmpq	%rbx, 24(%rsp)
	jg	.L10
.L11:
	xorl	%eax, %eax
	leaq	48(%rsp), %rsi
	leaq	.LC1(%rip), %rdi
	xorl	%ebx, %ebx
	call	__isoc99_scanf@PLT
	cmpq	$0, 48(%rsp)
	leaq	40(%rsp), %r15
	leaq	32(%rsp), %r14
	jle	.L14
	.p2align 4,,10
	.p2align 3
.L13:
	movq	%r15, %rdx
	movq	%r14, %rsi
	movq	%r13, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movq	32(%rsp), %rax
	movq	40(%rsp), %rdx
	movq	0(%rbp,%rax,8), %rax
	cmpq	%rax, 0(%rbp,%rdx,8)
	jne	.L30
	cmpq	$-1, %rax
	jne	.L50
.L30:
	leaq	.LC3(%rip), %rdi
	addq	$1, %rbx
	call	puts@PLT
	cmpq	%rbx, 48(%rsp)
	jg	.L13
.L14:
	movq	%rbp, %rdi
	call	free@PLT
	movq	%r12, %rdi
	call	free@PLT
	movq	56(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L51
	addq	$72, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L49:
	.cfi_restore_state
	addq	$1, %rdi
	movq	%rcx, (%rdx)
	addq	$8, %rdx
	cmpq	%r9, %rdi
	jl	.L29
	jmp	.L28
	.p2align 4,,10
	.p2align 3
.L47:
	movq	40(%rsp), %rax
	leaq	0(%rbp,%rax,8), %rax
	movq	(%rax), %rcx
	cmpq	$-1, %rcx
	je	.L52
	movq	%rcx, (%rdx)
	movq	(%rax), %rax
	addq	$1, (%r12,%rax,8)
	jmp	.L17
	.p2align 4,,10
	.p2align 3
.L50:
	leaq	.LC2(%rip), %rdi
	addq	$1, %rbx
	call	puts@PLT
	cmpq	%rbx, 48(%rsp)
	jg	.L13
	jmp	.L14
	.p2align 4,,10
	.p2align 3
.L48:
	movq	%rax, (%rsi)
	movq	(%rdx), %rax
	addq	$1, (%r12,%rax,8)
	jmp	.L17
	.p2align 4,,10
	.p2align 3
.L19:
	testq	%rsi, %rsi
	jle	.L24
	.p2align 4,,10
	.p2align 3
.L25:
	cmpq	(%rdx), %rcx
	je	.L53
	addq	$8, %rdx
	cmpq	%rdi, %rsi
	jg	.L25
.L24:
	addq	%r9, %rsi
	movq	%rsi, (%r11)
	jmp	.L17
	.p2align 4,,10
	.p2align 3
.L53:
	addq	$1, %rdi
	movq	%rax, (%rdx)
	addq	$8, %rdx
	cmpq	%rdi, %rsi
	jg	.L25
	jmp	.L24
	.p2align 4,,10
	.p2align 3
.L52:
	movq	8(%rsp), %rcx
	movq	%rcx, (%rdx)
	addq	$2, (%r12,%rcx,8)
	movq	%rcx, (%rax)
	addq	$1, %rcx
	movq	%rcx, 8(%rsp)
	jmp	.L17
.L51:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE40:
	.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:

rule
	.file	"temp.c"
	.text
	.p2align 4
	.globl	unite
	.type	unite, @function
unite:
.LFB39:
	.cfi_startproc
	endbr64
	leaq	(%rsi,%rcx,8), %r9
	movq	(%r9), %r8
	testq	%r8, %r8
	jle	.L2
	xorl	%eax, %eax
	.p2align 4,,10
	.p2align 3
.L5:
	cmpq	%rcx, (%rdi)
	je	.L7
	addq	$8, %rdi
	cmpq	%r8, %rax
	jl	.L5
.L2:
	addq	%r8, (%rsi,%rdx,8)
	ret
	.p2align 4,,10
	.p2align 3
.L7:
	movq	%rdx, (%rdi)
	movq	(%r9), %r8
	addq	$1, %rax
	addq	$8, %rdi
	cmpq	%r8, %rax
	jl	.L5
	addq	%r8, (%rsi,%rdx,8)
	ret
	.cfi_endproc
.LFE39:
	.size	unite, .-unite
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%ld %ld"
.LC1:
	.string	"%ld"
.LC2:
	.string	"yes"
.LC3:
	.string	"no"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB40:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	leaq	.LC0(%rip), %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movq	%r13, %rdi
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$72, %rsp
	.cfi_def_cfa_offset 128
	movq	%fs:40, %rax
	movq	%rax, 56(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rdx
	leaq	16(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movq	16(%rsp), %rbx
	leaq	0(,%rbx,8), %r12
	movq	%r12, %rdi
	call	malloc@PLT
	movq	%rax, %rbp
	testq	%rbx, %rbx
	jle	.L12
	movq	%r12, %rdx
	movl	$255, %esi
	movq	%rax, %rdi
	call	memset@PLT
.L12:
	movq	24(%rsp), %rbx
	movl	$1, %esi
	leaq	0(,%rbx,8), %rdi
	call	calloc@PLT
	movq	%rax, %r12
	testq	%rbx, %rbx
	jle	.L11
	movq	$0, 8(%rsp)
	xorl	%ebx, %ebx
	leaq	40(%rsp), %r15
	leaq	32(%rsp), %r14
	.p2align 4,,10
	.p2align 3
.L10:
	movq	%r15, %rdx
	movq	%r14, %rsi
	movq	%r13, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movq	32(%rsp), %rax
	leaq	0(%rbp,%rax,8), %rdx
	movq	(%rdx), %rax
	cmpq	$-1, %rax
	je	.L47
	movq	40(%rsp), %rcx
	leaq	0(%rbp,%rcx,8), %rsi
	movq	(%rsi), %rcx
	cmpq	$-1, %rcx
	je	.L48
	cmpq	%rcx, %rax
	je	.L17
	leaq	(%r12,%rcx,8), %r10
	leaq	(%r12,%rax,8), %r11
	movq	%rbp, %rdx
	movl	$0, %edi
	movq	(%r10), %rsi
	movq	(%r11), %r9
	jl	.L19
	testq	%r9, %r9
	jle	.L28
	.p2align 4,,10
	.p2align 3
.L29:
	cmpq	(%rdx), %rax
	je	.L49
	addq	$8, %rdx
	cmpq	%rdi, %r9
	jg	.L29
.L28:
	addq	%r9, %rsi
	movq	%rsi, (%r10)
	.p2align 4,,10
	.p2align 3
.L17:
	addq	$1, %rbx
	cmpq	%rbx, 24(%rsp)
	jg	.L10
.L11:
	xorl	%eax, %eax
	leaq	48(%rsp), %rsi
	leaq	.LC1(%rip), %rdi
	xorl	%ebx, %ebx
	call	__isoc99_scanf@PLT
	cmpq	$0, 48(%rsp)
	leaq	40(%rsp), %r15
	leaq	32(%rsp), %r14
	jle	.L14
	.p2align 4,,10
	.p2align 3
.L13:
	movq	%r15, %rdx
	movq	%r14, %rsi
	movq	%r13, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movq	32(%rsp), %rax
	movq	40(%rsp), %rdx
	movq	0(%rbp,%rax,8), %rax
	cmpq	%rax, 0(%rbp,%rdx,8)
	jne	.L30
	cmpq	$-1, %rax
	jne	.L50
.L30:
	leaq	.LC3(%rip), %rdi
	addq	$1, %rbx
	call	puts@PLT
	cmpq	%rbx, 48(%rsp)
	jg	.L13
.L14:
	movq	%rbp, %rdi
	call	free@PLT
	movq	%r12, %rdi
	call	free@PLT
	movq	56(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L51
	addq	$72, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L49:
	.cfi_restore_state
	addq	$1, %rdi
	movq	%rcx, (%rdx)
	addq	$8, %rdx
	cmpq	%r9, %rdi
	jl	.L29
	jmp	.L28
	.p2align 4,,10
	.p2align 3
.L47:
	movq	40(%rsp), %rax
	leaq	0(%rbp,%rax,8), %rax
	movq	(%rax), %rcx
	cmpq	$-1, %rcx
	je	.L52
	movq	%rcx, (%rdx)
	movq	(%rax), %rax
	addq	$1, (%r12,%rax,8)
	jmp	.L17
	.p2align 4,,10
	.p2align 3
.L50:
	leaq	.LC2(%rip), %rdi
	addq	$1, %rbx
	call	puts@PLT
	cmpq	%rbx, 48(%rsp)
	jg	.L13
	jmp	.L14
	.p2align 4,,10
	.p2align 3
.L48:
	movq	%rax, (%rsi)
	movq	(%rdx), %rax
	addq	$1, (%r12,%rax,8)
	jmp	.L17
	.p2align 4,,10
	.p2align 3
.L19:
	testq	%rsi, %rsi
	jle	.L24
	.p2align 4,,10
	.p2align 3
.L25:
	cmpq	(%rdx), %rcx
	je	.L53
	addq	$8, %rdx
	cmpq	%rdi, %rsi
	jg	.L25
.L24:
	addq	%r9, %rsi
	movq	%rsi, (%r11)
	jmp	.L17
	.p2align 4,,10
	.p2align 3
.L53:
	addq	$1, %rdi
	movq	%rax, (%rdx)
	addq	$8, %rdx
	cmpq	%rdi, %rsi
	jg	.L25
	jmp	.L24
	.p2align 4,,10
	.p2align 3
.L52:
	movq	8(%rsp), %rcx
	movq	%rcx, (%rdx)
	addq	$2, (%r12,%rcx,8)
	movq	%rcx, (%rax)
	addq	$1, %rcx
	movq	%rcx, 8(%rsp)
	jmp	.L17
.L51:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE40:
	.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:

#include <stdio.h>
#include <stdlib.h>
 
void unite(long *affiliation, long *group, long p, long q) {
  long i,j;
  j = 0;
  for (i = 0; j < group[q]; i++) {
    if(affiliation[i] == q) {
      affiliation[i] = p;
      j++;
    }
  }
  group[p] += group[q];
}
 
int main()
{
  long n,m,i,s,t,p,q;
  long *affiliation,*group;
  scanf("%ld %ld",&n,&m);
  affiliation = (long*)malloc(sizeof(long) * n);
  for (i = 0; i < n; i++) affiliation[i] = -1;
  group = (long*)malloc(sizeof(long) * m);
  for (i = 0; i < m; i++) group[i] = 0;
  p = 0;
  for (i = 0; i < m; i++) {
    scanf("%ld %ld", &s, &t);
    if(affiliation[s] == -1 && affiliation[t] == -1) {
      affiliation[s] = p;
      affiliation[t] = p;
      group[p] += 2;
      p++;
    }
    else if(affiliation[s] != -1 && affiliation[t] == -1) {
      affiliation[t] = affiliation[s];
      group[affiliation[s]]++;
    }
    else if(affiliation[s] == -1 && affiliation[t] != -1) {
      affiliation[s] = affiliation[t];
      group[affiliation[t]]++;
    }
    else if(affiliation[s] != affiliation[t]){
      (affiliation[s] < affiliation[t]) ? unite(affiliation,group,affiliation[s],affiliation[t]):unite(affiliation,group,affiliation[t],affiliation[s]);
    }
  }
  scanf("%ld",&q);
  for (i = 0; i < q; i++) {
    scanf("%ld %ld", &s, &t);
    if(affiliation[s] == affiliation[t] && affiliation[s] != -1) printf("yes\n");
    else printf("no\n");
  }
  free(affiliation);
  free(group);
   
  return 0;
}
10 9
0 1
0 2
3 4
5 7
5 6
3 7
6 8
7 8
8 9
3
0 1
5 9
1 3
 16 9
0 2
0 2
3 4
5 7
5 6
3 7
6 13
7 8
8 9
3
0 1
5 9
1 3
 16 9
0 2
0 2
3 4
2 7
5 6
3 7
6 13
7 8
8 9
3
0 1
5 9
1 3
 16 9
0 2
0 2
3 4
2 7
5 6
3 7
6 13
7 8
8 9
3
0 0
5 9
1 3
 10 9
0 1
0 2
3 4
5 7
5 6
3 7
0 8
7 8
8 9
3
0 1
5 9
1 3
 16 9
0 2
0 2
3 4
2 7
5 6
3 7
0 13
7 8
8 9
3
1 0
5 2
2 3
 16 9
0 2
0 2
3 4
2 7
5 6
3 7
0 13
7 8
8 9
3
1 0
4 2
2 3
 10 9
0 1
0 2
3 4
5 7
5 6
3 7
0 8
7 8
8 5
3
0 1
5 9
1 3
 16 9
0 2
0 2
0 4
2 7
5 6
3 11
6 13
3 8
8 9
1
0 1
5 9
1 3
 16 9
0 2
1 2
0 4
4 7
5 6
3 11
6 7
3 8
8 9
1
0 1
5 9
1 3

yes
yes
no
 no
yes
no
 no
no
no
 yes
no
no
 yes
yes
yes
 no
no
yes
 no
yes
yes
 yes
no
yes
 no
 yes

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>
 
void unite(long *affiliation, long *group, long p, long q) {
  long i,j;
  j = 0;
  for (i = 0; j < group[q]; i++) {
    if(affiliation[i] == q) {
      affiliation[i] = p;
      j++;
    }
  }
  group[p] += group[q];
}
 
int main()
{
  long n,m,i,s,t,p,q;
  long *affiliation,*group;
  scanf("%ld %ld",&n,&m);
  affiliation = (long*)malloc(sizeof(long) * n);
  for (i = 0; i < n; i++) affiliation[i] = -1;
  group = (long*)malloc(sizeof(long) * m);
  for (i = 0; i < m; i++) group[i] = 0;
  p = 0;
  for (i = 0; i < m; i++) {
    scanf("%ld %ld", &s, &t);
    if(affiliation[s] == -1 && affiliation[t] == -1) {
      affiliation[s] = p;
      affiliation[t] = p;
      group[p] += 2;
      p++;
    }
    else if(affiliation[s] != -1 && affiliation[t] == -1) {
      affiliation[t] = affiliation[s];
      group[affiliation[s]]++;
    }
    else if(affiliation[s] == -1 && affiliation[t] != -1) {
      affiliation[s] = affiliation[t];
      group[affiliation[t]]++;
    }
    else if(affiliation[s] != affiliation[t]){
      (affiliation[s] < affiliation[t]) ? unite(affiliation,group,affiliation[s],affiliation[t]):unite(affiliation,group,affiliation[t],affiliation[s]);
    }
  }
  scanf("%ld",&q);
  for (i = 0; i < q; i++) {
    scanf("%ld %ld", &s, &t);
    if(affiliation[s] == affiliation[t] && affiliation[s] != -1) printf("yes\n");
    else printf("no\n");
  }
  free(affiliation);
  free(group);
   
  return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	unite
	.type	unite, @function
unite:
.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, -24(%rbp)
	movq	%rsi, -32(%rbp)
	movq	%rdx, -40(%rbp)
	movq	%rcx, -48(%rbp)
	movq	$0, -8(%rbp)
	movq	$0, -16(%rbp)
	jmp	.L2
.L4:
	movq	-16(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rax
	cmpq	%rax, -48(%rbp)
	jne	.L3
	movq	-16(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	movq	-24(%rbp), %rax
	addq	%rax, %rdx
	movq	-40(%rbp), %rax
	movq	%rax, (%rdx)
	addq	$1, -8(%rbp)
.L3:
	addq	$1, -16(%rbp)
.L2:
	movq	-48(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	movq	-32(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rax
	cmpq	%rax, -8(%rbp)
	jl	.L4
	movq	-40(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	movq	-32(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rcx
	movq	-48(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	movq	-32(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rdx
	movq	-40(%rbp), %rax
	leaq	0(,%rax,8), %rsi
	movq	-32(%rbp), %rax
	addq	%rsi, %rax
	addq	%rcx, %rdx
	movq	%rdx, (%rax)
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	unite, .-unite
	.section	.rodata
.LC0:
	.string	"%ld %ld"
.LC1:
	.string	"%ld"
.LC2:
	.string	"yes"
.LC3:
	.string	"no"
	.text
	.globl	main
	.type	main, @function
main:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$80, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-72(%rbp), %rdx
	leaq	-80(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	-80(%rbp), %rax
	salq	$3, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, -24(%rbp)
	movq	$0, -40(%rbp)
	jmp	.L6
.L7:
	movq	-40(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movq	$-1, (%rax)
	addq	$1, -40(%rbp)
.L6:
	movq	-80(%rbp), %rax
	cmpq	%rax, -40(%rbp)
	jl	.L7
	movq	-72(%rbp), %rax
	salq	$3, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, -16(%rbp)
	movq	$0, -40(%rbp)
	jmp	.L8
.L9:
	movq	-40(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movq	$0, (%rax)
	addq	$1, -40(%rbp)
.L8:
	movq	-72(%rbp), %rax
	cmpq	%rax, -40(%rbp)
	jl	.L9
	movq	$0, -32(%rbp)
	movq	$0, -40(%rbp)
	jmp	.L10
.L16:
	leaq	-56(%rbp), %rdx
	leaq	-64(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	-64(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rax
	cmpq	$-1, %rax
	jne	.L11
	movq	-56(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rax
	cmpq	$-1, %rax
	jne	.L11
	movq	-64(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	movq	-24(%rbp), %rax
	addq	%rax, %rdx
	movq	-32(%rbp), %rax
	movq	%rax, (%rdx)
	movq	-56(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	movq	-24(%rbp), %rax
	addq	%rax, %rdx
	movq	-32(%rbp), %rax
	movq	%rax, (%rdx)
	movq	-32(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rdx
	movq	-32(%rbp), %rax
	leaq	0(,%rax,8), %rcx
	movq	-16(%rbp), %rax
	addq	%rcx, %rax
	addq	$2, %rdx
	movq	%rdx, (%rax)
	addq	$1, -32(%rbp)
	jmp	.L12
.L11:
	movq	-64(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rax
	cmpq	$-1, %rax
	je	.L13
	movq	-56(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rax
	cmpq	$-1, %rax
	jne	.L13
	movq	-64(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movq	-56(%rbp), %rdx
	leaq	0(,%rdx,8), %rcx
	movq	-24(%rbp), %rdx
	addq	%rcx, %rdx
	movq	(%rax), %rax
	movq	%rax, (%rdx)
	movq	-64(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rax
	leaq	0(,%rax,8), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rdx
	addq	$1, %rdx
	movq	%rdx, (%rax)
	jmp	.L12
.L13:
	movq	-64(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rax
	cmpq	$-1, %rax
	jne	.L14
	movq	-56(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rax
	cmpq	$-1, %rax
	je	.L14
	movq	-56(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movq	-64(%rbp), %rdx
	leaq	0(,%rdx,8), %rcx
	movq	-24(%rbp), %rdx
	addq	%rcx, %rdx
	movq	(%rax), %rax
	movq	%rax, (%rdx)
	movq	-56(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rax
	leaq	0(,%rax,8), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rdx
	addq	$1, %rdx
	movq	%rdx, (%rax)
	jmp	.L12
.L14:
	movq	-64(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rdx
	movq	-56(%rbp), %rax
	leaq	0(,%rax,8), %rcx
	movq	-24(%rbp), %rax
	addq	%rcx, %rax
	movq	(%rax), %rax
	cmpq	%rax, %rdx
	je	.L12
	movq	-64(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rdx
	movq	-56(%rbp), %rax
	leaq	0(,%rax,8), %rcx
	movq	-24(%rbp), %rax
	addq	%rcx, %rax
	movq	(%rax), %rax
	cmpq	%rax, %rdx
	jge	.L15
	movq	-56(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rcx
	movq	-64(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rdx
	movq	-16(%rbp), %rsi
	movq	-24(%rbp), %rax
	movq	%rax, %rdi
	call	unite
	jmp	.L12
.L15:
	movq	-64(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rcx
	movq	-56(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rdx
	movq	-16(%rbp), %rsi
	movq	-24(%rbp), %rax
	movq	%rax, %rdi
	call	unite
.L12:
	addq	$1, -40(%rbp)
.L10:
	movq	-72(%rbp), %rax
	cmpq	%rax, -40(%rbp)
	jl	.L16
	leaq	-48(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	$0, -40(%rbp)
	jmp	.L17
.L20:
	leaq	-56(%rbp), %rdx
	leaq	-64(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	-64(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rdx
	movq	-56(%rbp), %rax
	leaq	0(,%rax,8), %rcx
	movq	-24(%rbp), %rax
	addq	%rcx, %rax
	movq	(%rax), %rax
	cmpq	%rax, %rdx
	jne	.L18
	movq	-64(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rax
	cmpq	$-1, %rax
	je	.L18
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	jmp	.L19
.L18:
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
.L19:
	addq	$1, -40(%rbp)
.L17:
	movq	-48(%rbp), %rax
	cmpq	%rax, -40(%rbp)
	jl	.L20
	movq	-24(%rbp), %rax
	movq	%rax, %rdi
	call	free@PLT
	movq	-16(%rbp), %rax
	movq	%rax, %rdi
	call	free@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L22
	call	__stack_chk_fail@PLT
.L22:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.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	unite
	.type	unite, @function
unite:
.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, -24(%rbp)
	movq	%rsi, -32(%rbp)
	movq	%rdx, -40(%rbp)
	movq	%rcx, -48(%rbp)
	movq	$0, -8(%rbp)
	movq	$0, -16(%rbp)
	jmp	.L2
.L4:
	movq	-16(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rax
	cmpq	%rax, -48(%rbp)
	jne	.L3
	movq	-16(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	movq	-24(%rbp), %rax
	addq	%rax, %rdx
	movq	-40(%rbp), %rax
	movq	%rax, (%rdx)
	addq	$1, -8(%rbp)
.L3:
	addq	$1, -16(%rbp)
.L2:
	movq	-48(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	movq	-32(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rax
	cmpq	%rax, -8(%rbp)
	jl	.L4
	movq	-40(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	movq	-32(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rcx
	movq	-48(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	movq	-32(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rdx
	movq	-40(%rbp), %rax
	leaq	0(,%rax,8), %rsi
	movq	-32(%rbp), %rax
	addq	%rsi, %rax
	addq	%rcx, %rdx
	movq	%rdx, (%rax)
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	unite, .-unite
	.section	.rodata
.LC0:
	.string	"%ld %ld"
.LC1:
	.string	"%ld"
.LC2:
	.string	"yes"
.LC3:
	.string	"no"
	.text
	.globl	main
	.type	main, @function
main:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$80, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-72(%rbp), %rdx
	leaq	-80(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	-80(%rbp), %rax
	salq	$3, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, -24(%rbp)
	movq	$0, -40(%rbp)
	jmp	.L6
.L7:
	movq	-40(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movq	$-1, (%rax)
	addq	$1, -40(%rbp)
.L6:
	movq	-80(%rbp), %rax
	cmpq	%rax, -40(%rbp)
	jl	.L7
	movq	-72(%rbp), %rax
	salq	$3, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, -16(%rbp)
	movq	$0, -40(%rbp)
	jmp	.L8
.L9:
	movq	-40(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movq	$0, (%rax)
	addq	$1, -40(%rbp)
.L8:
	movq	-72(%rbp), %rax
	cmpq	%rax, -40(%rbp)
	jl	.L9
	movq	$0, -32(%rbp)
	movq	$0, -40(%rbp)
	jmp	.L10
.L16:
	leaq	-56(%rbp), %rdx
	leaq	-64(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	-64(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rax
	cmpq	$-1, %rax
	jne	.L11
	movq	-56(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rax
	cmpq	$-1, %rax
	jne	.L11
	movq	-64(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	movq	-24(%rbp), %rax
	addq	%rax, %rdx
	movq	-32(%rbp), %rax
	movq	%rax, (%rdx)
	movq	-56(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	movq	-24(%rbp), %rax
	addq	%rax, %rdx
	movq	-32(%rbp), %rax
	movq	%rax, (%rdx)
	movq	-32(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rdx
	movq	-32(%rbp), %rax
	leaq	0(,%rax,8), %rcx
	movq	-16(%rbp), %rax
	addq	%rcx, %rax
	addq	$2, %rdx
	movq	%rdx, (%rax)
	addq	$1, -32(%rbp)
	jmp	.L12
.L11:
	movq	-64(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rax
	cmpq	$-1, %rax
	je	.L13
	movq	-56(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rax
	cmpq	$-1, %rax
	jne	.L13
	movq	-64(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movq	-56(%rbp), %rdx
	leaq	0(,%rdx,8), %rcx
	movq	-24(%rbp), %rdx
	addq	%rcx, %rdx
	movq	(%rax), %rax
	movq	%rax, (%rdx)
	movq	-64(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rax
	leaq	0(,%rax,8), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rdx
	addq	$1, %rdx
	movq	%rdx, (%rax)
	jmp	.L12
.L13:
	movq	-64(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rax
	cmpq	$-1, %rax
	jne	.L14
	movq	-56(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rax
	cmpq	$-1, %rax
	je	.L14
	movq	-56(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movq	-64(%rbp), %rdx
	leaq	0(,%rdx,8), %rcx
	movq	-24(%rbp), %rdx
	addq	%rcx, %rdx
	movq	(%rax), %rax
	movq	%rax, (%rdx)
	movq	-56(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rax
	leaq	0(,%rax,8), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rdx
	addq	$1, %rdx
	movq	%rdx, (%rax)
	jmp	.L12
.L14:
	movq	-64(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rdx
	movq	-56(%rbp), %rax
	leaq	0(,%rax,8), %rcx
	movq	-24(%rbp), %rax
	addq	%rcx, %rax
	movq	(%rax), %rax
	cmpq	%rax, %rdx
	je	.L12
	movq	-64(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rdx
	movq	-56(%rbp), %rax
	leaq	0(,%rax,8), %rcx
	movq	-24(%rbp), %rax
	addq	%rcx, %rax
	movq	(%rax), %rax
	cmpq	%rax, %rdx
	jge	.L15
	movq	-56(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rcx
	movq	-64(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rdx
	movq	-16(%rbp), %rsi
	movq	-24(%rbp), %rax
	movq	%rax, %rdi
	call	unite
	jmp	.L12
.L15:
	movq	-64(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rcx
	movq	-56(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rdx
	movq	-16(%rbp), %rsi
	movq	-24(%rbp), %rax
	movq	%rax, %rdi
	call	unite
.L12:
	addq	$1, -40(%rbp)
.L10:
	movq	-72(%rbp), %rax
	cmpq	%rax, -40(%rbp)
	jl	.L16
	leaq	-48(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	$0, -40(%rbp)
	jmp	.L17
.L20:
	leaq	-56(%rbp), %rdx
	leaq	-64(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	-64(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rdx
	movq	-56(%rbp), %rax
	leaq	0(,%rax,8), %rcx
	movq	-24(%rbp), %rax
	addq	%rcx, %rax
	movq	(%rax), %rax
	cmpq	%rax, %rdx
	jne	.L18
	movq	-64(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rax
	cmpq	$-1, %rax
	je	.L18
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	jmp	.L19
.L18:
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
.L19:
	addq	$1, -40(%rbp)
.L17:
	movq	-48(%rbp), %rax
	cmpq	%rax, -40(%rbp)
	jl	.L20
	movq	-24(%rbp), %rax
	movq	%rax, %rdi
	call	free@PLT
	movq	-16(%rbp), %rax
	movq	%rax, %rdi
	call	free@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L22
	call	__stack_chk_fail@PLT
.L22:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.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:
