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>


typedef struct Node {
  int val;
  struct Node *next;  
} node_t;

node_t *G[100000];
int connected[100000];
int color;

node_t* add_node(node_t *node, int val)
{
    node_t *n = (node_t*)malloc(sizeof(node_t));
    n->val = val;
    n->next = node;
    return n;     
}

void add(int u, int v)
{
    G[u] = add_node(G[u], v);
    G[v] = add_node(G[v], u);
}

void dfs(int v)
{
    node_t *p;
    if (connected[v]) return;
    connected[v] = color;
    for (p = G[v]; p != NULL; p = p->next) {
        dfs(p->val);
    }
}

int main()
{
    int i;    
    int n, m;
    int s, t;
    scanf("%d %d", &n, &m);
    
    for (i = 0; i < m; i++) {
        scanf("%d %d", &s, &t);
        add(s, t);        
    }
    
    for (i = 0; i < n; i++) {
        color = i + 1;
        dfs(i);
    }
    
    int q;
    scanf("%d", &q);
    for (i = 0; i < q; i++) {
        scanf("%d %d", &s, &t);
        if (connected[s] == connected[t]) puts("yes");
        else puts("no");
    }
    
    return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	G
	.bss
	.align 32
	.type	G, @object
	.size	G, 800000
G:
	.zero	800000
	.globl	connected
	.align 32
	.type	connected, @object
	.size	connected, 400000
connected:
	.zero	400000
	.globl	color
	.align 4
	.type	color, @object
	.size	color, 4
color:
	.zero	4
	.text
	.globl	add_node
	.type	add_node, @function
add_node:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movq	%rdi, -24(%rbp)
	movl	%esi, -28(%rbp)
	movl	$16, %edi
	call	malloc@PLT
	movq	%rax, -8(%rbp)
	movq	-8(%rbp), %rax
	movl	-28(%rbp), %edx
	movl	%edx, (%rax)
	movq	-8(%rbp), %rax
	movq	-24(%rbp), %rdx
	movq	%rdx, 8(%rax)
	movq	-8(%rbp), %rax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	add_node, .-add_node
	.globl	add
	.type	add, @function
add:
.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	%esi, -8(%rbp)
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	G(%rip), %rax
	movq	(%rdx,%rax), %rax
	movl	-8(%rbp), %edx
	movl	%edx, %esi
	movq	%rax, %rdi
	call	add_node
	movl	-4(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,8), %rcx
	leaq	G(%rip), %rdx
	movq	%rax, (%rcx,%rdx)
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	G(%rip), %rax
	movq	(%rdx,%rax), %rax
	movl	-4(%rbp), %edx
	movl	%edx, %esi
	movq	%rax, %rdi
	call	add_node
	movl	-8(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,8), %rcx
	leaq	G(%rip), %rdx
	movq	%rax, (%rcx,%rdx)
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	add, .-add
	.globl	dfs
	.type	dfs, @function
dfs:
.LFB8:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movl	%edi, -20(%rbp)
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	connected(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	jne	.L9
	movl	color(%rip), %eax
	movl	-20(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	connected(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	G(%rip), %rax
	movq	(%rdx,%rax), %rax
	movq	%rax, -8(%rbp)
	jmp	.L7
.L8:
	movq	-8(%rbp), %rax
	movl	(%rax), %eax
	movl	%eax, %edi
	call	dfs
	movq	-8(%rbp), %rax
	movq	8(%rax), %rax
	movq	%rax, -8(%rbp)
.L7:
	cmpq	$0, -8(%rbp)
	jne	.L8
	jmp	.L4
.L9:
	nop
.L4:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.size	dfs, .-dfs
	.section	.rodata
.LC0:
	.string	"%d %d"
.LC1:
	.string	"%d"
.LC2:
	.string	"yes"
.LC3:
	.string	"no"
	.text
	.globl	main
	.type	main, @function
main:
.LFB9:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-28(%rbp), %rdx
	leaq	-32(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -12(%rbp)
	jmp	.L11
.L12:
	leaq	-20(%rbp), %rdx
	leaq	-24(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-20(%rbp), %edx
	movl	-24(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	add
	addl	$1, -12(%rbp)
.L11:
	movl	-28(%rbp), %eax
	cmpl	%eax, -12(%rbp)
	jl	.L12
	movl	$0, -12(%rbp)
	jmp	.L13
.L14:
	movl	-12(%rbp), %eax
	addl	$1, %eax
	movl	%eax, color(%rip)
	movl	-12(%rbp), %eax
	movl	%eax, %edi
	call	dfs
	addl	$1, -12(%rbp)
.L13:
	movl	-32(%rbp), %eax
	cmpl	%eax, -12(%rbp)
	jl	.L14
	leaq	-16(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -12(%rbp)
	jmp	.L15
.L18:
	leaq	-20(%rbp), %rdx
	leaq	-24(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	connected(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	connected(%rip), %rax
	movl	(%rcx,%rax), %eax
	cmpl	%eax, %edx
	jne	.L16
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	jmp	.L17
.L16:
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
.L17:
	addl	$1, -12(%rbp)
.L15:
	movl	-16(%rbp), %eax
	cmpl	%eax, -12(%rbp)
	jl	.L18
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L20
	call	__stack_chk_fail@PLT
.L20:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE9:
	.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
	.type	dfs.part.0, @function
dfs.part.0:
.LFB43:
	.cfi_startproc
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movslq	%edi, %rax
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	leaq	G(%rip), %r14
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	leaq	connected(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
	movl	color(%rip), %edx
	movq	(%r14,%rax,8), %rcx
	movl	%edx, 0(%rbp,%rax,4)
	testq	%rcx, %rcx
	je	.L1
.L13:
	movslq	(%rcx), %rax
	movl	0(%rbp,%rax,4), %r8d
	testl	%r8d, %r8d
	jne	.L3
	movl	color(%rip), %edx
	movq	(%r14,%rax,8), %r15
	movl	%edx, 0(%rbp,%rax,4)
	testq	%r15, %r15
	je	.L3
.L12:
	movslq	(%r15), %rax
	movl	0(%rbp,%rax,4), %edi
	testl	%edi, %edi
	jne	.L4
	movl	color(%rip), %edx
	movq	(%r14,%rax,8), %r13
	movl	%edx, 0(%rbp,%rax,4)
	testq	%r13, %r13
	je	.L4
.L11:
	movslq	0(%r13), %rax
	movl	0(%rbp,%rax,4), %esi
	testl	%esi, %esi
	jne	.L5
	movl	color(%rip), %edx
	movq	(%r14,%rax,8), %r12
	movl	%edx, 0(%rbp,%rax,4)
	testq	%r12, %r12
	je	.L5
.L10:
	movslq	(%r12), %rax
	movl	0(%rbp,%rax,4), %edx
	testl	%edx, %edx
	jne	.L6
	movl	color(%rip), %edx
	movq	(%r14,%rax,8), %rbx
	movl	%edx, 0(%rbp,%rax,4)
	testq	%rbx, %rbx
	je	.L6
.L9:
	movslq	(%rbx), %rax
	movq	%rax, %rdi
	movl	0(%rbp,%rax,4), %eax
	testl	%eax, %eax
	jne	.L7
	movq	%rcx, 8(%rsp)
	call	dfs.part.0
	movq	8(%rbx), %rbx
	movq	8(%rsp), %rcx
	testq	%rbx, %rbx
	jne	.L9
	.p2align 4,,10
	.p2align 3
.L6:
	movq	8(%r12), %r12
	testq	%r12, %r12
	jne	.L10
.L5:
	movq	8(%r13), %r13
	testq	%r13, %r13
	jne	.L11
.L4:
	movq	8(%r15), %r15
	testq	%r15, %r15
	jne	.L12
.L3:
	movq	8(%rcx), %rcx
	testq	%rcx, %rcx
	jne	.L13
.L1:
	addq	$24, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	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
.L7:
	.cfi_restore_state
	movq	8(%rbx), %rbx
	testq	%rbx, %rbx
	jne	.L9
	movq	8(%r12), %r12
	testq	%r12, %r12
	jne	.L10
	jmp	.L5
	.cfi_endproc
.LFE43:
	.size	dfs.part.0, .-dfs.part.0
	.p2align 4
	.globl	add_node
	.type	add_node, @function
add_node:
.LFB39:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movl	%esi, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	movq	%rdi, %rbx
	movl	$16, %edi
	subq	$8, %rsp
	.cfi_def_cfa_offset 32
	call	malloc@PLT
	movl	%ebp, (%rax)
	movq	%rbx, 8(%rax)
	addq	$8, %rsp
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE39:
	.size	add_node, .-add_node
	.p2align 4
	.globl	add
	.type	add, @function
add:
.LFB40:
	.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
	movslq	%edi, %r13
	movl	$16, %edi
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	movq	%r13, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	leaq	G(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	movq	0(%rbp,%r13,8), %r14
	movslq	%esi, %rbx
	call	malloc@PLT
	movl	$16, %edi
	movl	%ebx, (%rax)
	movq	%r14, 8(%rax)
	movq	%rax, 0(%rbp,%r13,8)
	movq	0(%rbp,%rbx,8), %r13
	call	malloc@PLT
	movl	%r12d, (%rax)
	movq	%r13, 8(%rax)
	movq	%rax, 0(%rbp,%rbx,8)
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE40:
	.size	add, .-add
	.p2align 4
	.globl	dfs
	.type	dfs, @function
dfs:
.LFB41:
	.cfi_startproc
	endbr64
	leaq	connected(%rip), %r10
	movslq	%edi, %rdi
	movl	(%r10,%rdi,4), %ecx
	testl	%ecx, %ecx
	jne	.L54
	movl	color(%rip), %eax
	movl	%eax, (%r10,%rdi,4)
	leaq	G(%rip), %rax
	movq	(%rax,%rdi,8), %r9
	testq	%r9, %r9
	je	.L54
.L55:
	movslq	(%r9), %rax
	movq	%rax, %rdi
	movl	(%r10,%rax,4), %eax
	testl	%eax, %eax
	jne	.L59
	subq	$8, %rsp
	.cfi_def_cfa_offset 16
.L57:
	call	dfs.part.0
	movq	8(%r9), %r9
	testq	%r9, %r9
	je	.L42
.L46:
	movslq	(%r9), %rax
	movl	(%r10,%rax,4), %edx
	movq	%rax, %rdi
	testl	%edx, %edx
	je	.L57
	movq	8(%r9), %r9
	testq	%r9, %r9
	jne	.L46
.L42:
	addq	$8, %rsp
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L54:
	ret
	.p2align 4,,10
	.p2align 3
.L59:
	movq	8(%r9), %r9
	testq	%r9, %r9
	jne	.L55
	ret
	.cfi_endproc
.LFE41:
	.size	dfs, .-dfs
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d %d"
.LC1:
	.string	"%d"
.LC2:
	.string	"yes"
.LC3:
	.string	"no"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB42:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	leaq	.LC0(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movq	%r12, %rdi
	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	40(%rsp), %rdx
	leaq	36(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movl	40(%rsp), %edi
	testl	%edi, %edi
	jle	.L64
	xorl	%r15d, %r15d
	leaq	48(%rsp), %r14
	leaq	44(%rsp), %r13
	leaq	G(%rip), %rbp
	.p2align 4,,10
	.p2align 3
.L61:
	movq	%r14, %rdx
	movq	%r13, %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movslq	44(%rsp), %rcx
	movl	$16, %edi
	movslq	48(%rsp), %rbx
	addl	$1, %r15d
	movq	0(%rbp,%rcx,8), %rsi
	movl	%ecx, 28(%rsp)
	movq	%rcx, 16(%rsp)
	movq	%rsi, 8(%rsp)
	call	malloc@PLT
	movq	8(%rsp), %rsi
	movq	16(%rsp), %rcx
	movl	$16, %edi
	movl	%ebx, (%rax)
	movq	%rax, 0(%rbp,%rcx,8)
	movq	0(%rbp,%rbx,8), %rcx
	movq	%rsi, 8(%rax)
	movq	%rcx, 8(%rsp)
	call	malloc@PLT
	movl	28(%rsp), %edx
	movq	8(%rsp), %rcx
	movq	%rax, 0(%rbp,%rbx,8)
	movl	%edx, (%rax)
	movq	%rcx, 8(%rax)
	cmpl	%r15d, 40(%rsp)
	jg	.L61
.L64:
	movl	36(%rsp), %edx
	xorl	%r10d, %r10d
	leaq	connected(%rip), %rbx
	leaq	G(%rip), %r11
	testl	%edx, %edx
	jle	.L63
	.p2align 4,,10
	.p2align 3
.L62:
	movl	(%rbx,%r10,4), %ecx
	leal	1(%r10), %eax
	movl	%eax, color(%rip)
	testl	%ecx, %ecx
	jne	.L67
	movq	(%r11,%r10,8), %r9
	movl	%eax, (%rbx,%r10,4)
	testq	%r9, %r9
	je	.L67
.L68:
	movslq	(%r9), %rax
	movq	%rax, %rdi
	movl	(%rbx,%rax,4), %eax
	testl	%eax, %eax
	jne	.L69
	call	dfs.part.0
	movq	8(%r9), %r9
	testq	%r9, %r9
	jne	.L68
.L71:
	movl	36(%rsp), %edx
.L67:
	addq	$1, %r10
	cmpl	%r10d, %edx
	jg	.L62
.L63:
	leaq	52(%rsp), %rsi
	leaq	.LC1(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	52(%rsp), %esi
	testl	%esi, %esi
	jle	.L66
	xorl	%ebp, %ebp
	leaq	48(%rsp), %r14
	leaq	44(%rsp), %r13
	leaq	connected(%rip), %rbx
	leaq	.LC3(%rip), %r15
	.p2align 4,,10
	.p2align 3
.L65:
	movq	%r14, %rdx
	movq	%r13, %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movslq	48(%rsp), %rax
	movslq	44(%rsp), %rdx
	movl	(%rbx,%rax,4), %eax
	cmpl	%eax, (%rbx,%rdx,4)
	je	.L87
	movq	%r15, %rdi
	addl	$1, %ebp
	call	puts@PLT
	cmpl	%ebp, 52(%rsp)
	jg	.L65
.L66:
	movq	56(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L88
	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
.L69:
	.cfi_restore_state
	movq	8(%r9), %r9
	testq	%r9, %r9
	jne	.L68
	jmp	.L71
	.p2align 4,,10
	.p2align 3
.L87:
	leaq	.LC2(%rip), %rdi
	addl	$1, %ebp
	call	puts@PLT
	cmpl	%ebp, 52(%rsp)
	jg	.L65
	jmp	.L66
.L88:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE42:
	.size	main, .-main
	.globl	color
	.bss
	.align 4
	.type	color, @object
	.size	color, 4
color:
	.zero	4
	.globl	connected
	.align 32
	.type	connected, @object
	.size	connected, 400000
connected:
	.zero	400000
	.globl	G
	.align 32
	.type	G, @object
	.size	G, 800000
G:
	.zero	800000
	.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
	.type	dfs.part.0, @function
dfs.part.0:
.LFB43:
	.cfi_startproc
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movslq	%edi, %rax
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	leaq	G(%rip), %r14
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	leaq	connected(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
	movl	color(%rip), %edx
	movq	(%r14,%rax,8), %rcx
	movl	%edx, 0(%rbp,%rax,4)
	testq	%rcx, %rcx
	je	.L1
.L13:
	movslq	(%rcx), %rax
	movl	0(%rbp,%rax,4), %r8d
	testl	%r8d, %r8d
	jne	.L3
	movl	color(%rip), %edx
	movq	(%r14,%rax,8), %r15
	movl	%edx, 0(%rbp,%rax,4)
	testq	%r15, %r15
	je	.L3
.L12:
	movslq	(%r15), %rax
	movl	0(%rbp,%rax,4), %edi
	testl	%edi, %edi
	jne	.L4
	movl	color(%rip), %edx
	movq	(%r14,%rax,8), %r13
	movl	%edx, 0(%rbp,%rax,4)
	testq	%r13, %r13
	je	.L4
.L11:
	movslq	0(%r13), %rax
	movl	0(%rbp,%rax,4), %esi
	testl	%esi, %esi
	jne	.L5
	movl	color(%rip), %edx
	movq	(%r14,%rax,8), %r12
	movl	%edx, 0(%rbp,%rax,4)
	testq	%r12, %r12
	je	.L5
.L10:
	movslq	(%r12), %rax
	movl	0(%rbp,%rax,4), %edx
	testl	%edx, %edx
	jne	.L6
	movl	color(%rip), %edx
	movq	(%r14,%rax,8), %rbx
	movl	%edx, 0(%rbp,%rax,4)
	testq	%rbx, %rbx
	je	.L6
.L9:
	movslq	(%rbx), %rax
	movq	%rax, %rdi
	movl	0(%rbp,%rax,4), %eax
	testl	%eax, %eax
	jne	.L7
	movq	%rcx, 8(%rsp)
	call	dfs.part.0
	movq	8(%rbx), %rbx
	movq	8(%rsp), %rcx
	testq	%rbx, %rbx
	jne	.L9
	.p2align 4,,10
	.p2align 3
.L6:
	movq	8(%r12), %r12
	testq	%r12, %r12
	jne	.L10
.L5:
	movq	8(%r13), %r13
	testq	%r13, %r13
	jne	.L11
.L4:
	movq	8(%r15), %r15
	testq	%r15, %r15
	jne	.L12
.L3:
	movq	8(%rcx), %rcx
	testq	%rcx, %rcx
	jne	.L13
.L1:
	addq	$24, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	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
.L7:
	.cfi_restore_state
	movq	8(%rbx), %rbx
	testq	%rbx, %rbx
	jne	.L9
	movq	8(%r12), %r12
	testq	%r12, %r12
	jne	.L10
	jmp	.L5
	.cfi_endproc
.LFE43:
	.size	dfs.part.0, .-dfs.part.0
	.p2align 4
	.globl	add_node
	.type	add_node, @function
add_node:
.LFB39:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movl	%esi, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	movq	%rdi, %rbx
	movl	$16, %edi
	subq	$8, %rsp
	.cfi_def_cfa_offset 32
	call	malloc@PLT
	movl	%ebp, (%rax)
	movq	%rbx, 8(%rax)
	addq	$8, %rsp
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE39:
	.size	add_node, .-add_node
	.p2align 4
	.globl	add
	.type	add, @function
add:
.LFB40:
	.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
	movslq	%edi, %r13
	movl	$16, %edi
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	movq	%r13, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	leaq	G(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	movq	0(%rbp,%r13,8), %r14
	movslq	%esi, %rbx
	call	malloc@PLT
	movl	$16, %edi
	movl	%ebx, (%rax)
	movq	%r14, 8(%rax)
	movq	%rax, 0(%rbp,%r13,8)
	movq	0(%rbp,%rbx,8), %r13
	call	malloc@PLT
	movl	%r12d, (%rax)
	movq	%r13, 8(%rax)
	movq	%rax, 0(%rbp,%rbx,8)
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE40:
	.size	add, .-add
	.p2align 4
	.globl	dfs
	.type	dfs, @function
dfs:
.LFB41:
	.cfi_startproc
	endbr64
	leaq	connected(%rip), %r10
	movslq	%edi, %rdi
	movl	(%r10,%rdi,4), %ecx
	testl	%ecx, %ecx
	jne	.L54
	movl	color(%rip), %eax
	movl	%eax, (%r10,%rdi,4)
	leaq	G(%rip), %rax
	movq	(%rax,%rdi,8), %r9
	testq	%r9, %r9
	je	.L54
.L55:
	movslq	(%r9), %rax
	movq	%rax, %rdi
	movl	(%r10,%rax,4), %eax
	testl	%eax, %eax
	jne	.L59
	subq	$8, %rsp
	.cfi_def_cfa_offset 16
.L57:
	call	dfs.part.0
	movq	8(%r9), %r9
	testq	%r9, %r9
	je	.L42
.L46:
	movslq	(%r9), %rax
	movl	(%r10,%rax,4), %edx
	movq	%rax, %rdi
	testl	%edx, %edx
	je	.L57
	movq	8(%r9), %r9
	testq	%r9, %r9
	jne	.L46
.L42:
	addq	$8, %rsp
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L54:
	ret
	.p2align 4,,10
	.p2align 3
.L59:
	movq	8(%r9), %r9
	testq	%r9, %r9
	jne	.L55
	ret
	.cfi_endproc
.LFE41:
	.size	dfs, .-dfs
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d %d"
.LC1:
	.string	"%d"
.LC2:
	.string	"yes"
.LC3:
	.string	"no"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB42:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	leaq	.LC0(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movq	%r12, %rdi
	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	40(%rsp), %rdx
	leaq	36(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movl	40(%rsp), %edi
	testl	%edi, %edi
	jle	.L64
	xorl	%r15d, %r15d
	leaq	48(%rsp), %r14
	leaq	44(%rsp), %r13
	leaq	G(%rip), %rbp
	.p2align 4,,10
	.p2align 3
.L61:
	movq	%r14, %rdx
	movq	%r13, %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movslq	44(%rsp), %rcx
	movl	$16, %edi
	movslq	48(%rsp), %rbx
	addl	$1, %r15d
	movq	0(%rbp,%rcx,8), %rsi
	movl	%ecx, 28(%rsp)
	movq	%rcx, 16(%rsp)
	movq	%rsi, 8(%rsp)
	call	malloc@PLT
	movq	8(%rsp), %rsi
	movq	16(%rsp), %rcx
	movl	$16, %edi
	movl	%ebx, (%rax)
	movq	%rax, 0(%rbp,%rcx,8)
	movq	0(%rbp,%rbx,8), %rcx
	movq	%rsi, 8(%rax)
	movq	%rcx, 8(%rsp)
	call	malloc@PLT
	movl	28(%rsp), %edx
	movq	8(%rsp), %rcx
	movq	%rax, 0(%rbp,%rbx,8)
	movl	%edx, (%rax)
	movq	%rcx, 8(%rax)
	cmpl	%r15d, 40(%rsp)
	jg	.L61
.L64:
	movl	36(%rsp), %edx
	xorl	%r10d, %r10d
	leaq	connected(%rip), %rbx
	leaq	G(%rip), %r11
	testl	%edx, %edx
	jle	.L63
	.p2align 4,,10
	.p2align 3
.L62:
	movl	(%rbx,%r10,4), %ecx
	leal	1(%r10), %eax
	movl	%eax, color(%rip)
	testl	%ecx, %ecx
	jne	.L67
	movq	(%r11,%r10,8), %r9
	movl	%eax, (%rbx,%r10,4)
	testq	%r9, %r9
	je	.L67
.L68:
	movslq	(%r9), %rax
	movq	%rax, %rdi
	movl	(%rbx,%rax,4), %eax
	testl	%eax, %eax
	jne	.L69
	call	dfs.part.0
	movq	8(%r9), %r9
	testq	%r9, %r9
	jne	.L68
.L71:
	movl	36(%rsp), %edx
.L67:
	addq	$1, %r10
	cmpl	%r10d, %edx
	jg	.L62
.L63:
	leaq	52(%rsp), %rsi
	leaq	.LC1(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	52(%rsp), %esi
	testl	%esi, %esi
	jle	.L66
	xorl	%ebp, %ebp
	leaq	48(%rsp), %r14
	leaq	44(%rsp), %r13
	leaq	connected(%rip), %rbx
	leaq	.LC3(%rip), %r15
	.p2align 4,,10
	.p2align 3
.L65:
	movq	%r14, %rdx
	movq	%r13, %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movslq	48(%rsp), %rax
	movslq	44(%rsp), %rdx
	movl	(%rbx,%rax,4), %eax
	cmpl	%eax, (%rbx,%rdx,4)
	je	.L87
	movq	%r15, %rdi
	addl	$1, %ebp
	call	puts@PLT
	cmpl	%ebp, 52(%rsp)
	jg	.L65
.L66:
	movq	56(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L88
	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
.L69:
	.cfi_restore_state
	movq	8(%r9), %r9
	testq	%r9, %r9
	jne	.L68
	jmp	.L71
	.p2align 4,,10
	.p2align 3
.L87:
	leaq	.LC2(%rip), %rdi
	addl	$1, %ebp
	call	puts@PLT
	cmpl	%ebp, 52(%rsp)
	jg	.L65
	jmp	.L66
.L88:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE42:
	.size	main, .-main
	.globl	color
	.bss
	.align 4
	.type	color, @object
	.size	color, 4
color:
	.zero	4
	.globl	connected
	.align 32
	.type	connected, @object
	.size	connected, 400000
connected:
	.zero	400000
	.globl	G
	.align 32
	.type	G, @object
	.size	G, 800000
G:
	.zero	800000
	.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>


typedef struct Node {
  int val;
  struct Node *next;  
} node_t;

node_t *G[100000];
int connected[100000];
int color;

node_t* add_node(node_t *node, int val)
{
    node_t *n = (node_t*)malloc(sizeof(node_t));
    n->val = val;
    n->next = node;
    return n;     
}

void add(int u, int v)
{
    G[u] = add_node(G[u], v);
    G[v] = add_node(G[v], u);
}

void dfs(int v)
{
    node_t *p;
    if (connected[v]) return;
    connected[v] = color;
    for (p = G[v]; p != NULL; p = p->next) {
        dfs(p->val);
    }
}

int main()
{
    int i;    
    int n, m;
    int s, t;
    scanf("%d %d", &n, &m);
    
    for (i = 0; i < m; i++) {
        scanf("%d %d", &s, &t);
        add(s, t);        
    }
    
    for (i = 0; i < n; i++) {
        color = i + 1;
        dfs(i);
    }
    
    int q;
    scanf("%d", &q);
    for (i = 0; i < q; i++) {
        scanf("%d %d", &s, &t);
        if (connected[s] == connected[t]) puts("yes");
        else puts("no");
    }
    
    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>


typedef struct Node {
  int val;
  struct Node *next;  
} node_t;

node_t *G[100000];
int connected[100000];
int color;

node_t* add_node(node_t *node, int val)
{
    node_t *n = (node_t*)malloc(sizeof(node_t));
    n->val = val;
    n->next = node;
    return n;     
}

void add(int u, int v)
{
    G[u] = add_node(G[u], v);
    G[v] = add_node(G[v], u);
}

void dfs(int v)
{
    node_t *p;
    if (connected[v]) return;
    connected[v] = color;
    for (p = G[v]; p != NULL; p = p->next) {
        dfs(p->val);
    }
}

int main()
{
    int i;    
    int n, m;
    int s, t;
    scanf("%d %d", &n, &m);
    
    for (i = 0; i < m; i++) {
        scanf("%d %d", &s, &t);
        add(s, t);        
    }
    
    for (i = 0; i < n; i++) {
        color = i + 1;
        dfs(i);
    }
    
    int q;
    scanf("%d", &q);
    for (i = 0; i < q; i++) {
        scanf("%d %d", &s, &t);
        if (connected[s] == connected[t]) puts("yes");
        else puts("no");
    }
    
    return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	G
	.bss
	.align 32
	.type	G, @object
	.size	G, 800000
G:
	.zero	800000
	.globl	connected
	.align 32
	.type	connected, @object
	.size	connected, 400000
connected:
	.zero	400000
	.globl	color
	.align 4
	.type	color, @object
	.size	color, 4
color:
	.zero	4
	.text
	.globl	add_node
	.type	add_node, @function
add_node:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movq	%rdi, -24(%rbp)
	movl	%esi, -28(%rbp)
	movl	$16, %edi
	call	malloc@PLT
	movq	%rax, -8(%rbp)
	movq	-8(%rbp), %rax
	movl	-28(%rbp), %edx
	movl	%edx, (%rax)
	movq	-8(%rbp), %rax
	movq	-24(%rbp), %rdx
	movq	%rdx, 8(%rax)
	movq	-8(%rbp), %rax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	add_node, .-add_node
	.globl	add
	.type	add, @function
add:
.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	%esi, -8(%rbp)
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	G(%rip), %rax
	movq	(%rdx,%rax), %rax
	movl	-8(%rbp), %edx
	movl	%edx, %esi
	movq	%rax, %rdi
	call	add_node
	movl	-4(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,8), %rcx
	leaq	G(%rip), %rdx
	movq	%rax, (%rcx,%rdx)
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	G(%rip), %rax
	movq	(%rdx,%rax), %rax
	movl	-4(%rbp), %edx
	movl	%edx, %esi
	movq	%rax, %rdi
	call	add_node
	movl	-8(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,8), %rcx
	leaq	G(%rip), %rdx
	movq	%rax, (%rcx,%rdx)
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	add, .-add
	.globl	dfs
	.type	dfs, @function
dfs:
.LFB8:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movl	%edi, -20(%rbp)
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	connected(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	jne	.L9
	movl	color(%rip), %eax
	movl	-20(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	connected(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	G(%rip), %rax
	movq	(%rdx,%rax), %rax
	movq	%rax, -8(%rbp)
	jmp	.L7
.L8:
	movq	-8(%rbp), %rax
	movl	(%rax), %eax
	movl	%eax, %edi
	call	dfs
	movq	-8(%rbp), %rax
	movq	8(%rax), %rax
	movq	%rax, -8(%rbp)
.L7:
	cmpq	$0, -8(%rbp)
	jne	.L8
	jmp	.L4
.L9:
	nop
.L4:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.size	dfs, .-dfs
	.section	.rodata
.LC0:
	.string	"%d %d"
.LC1:
	.string	"%d"
.LC2:
	.string	"yes"
.LC3:
	.string	"no"
	.text
	.globl	main
	.type	main, @function
main:
.LFB9:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-28(%rbp), %rdx
	leaq	-32(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -12(%rbp)
	jmp	.L11
.L12:
	leaq	-20(%rbp), %rdx
	leaq	-24(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-20(%rbp), %edx
	movl	-24(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	add
	addl	$1, -12(%rbp)
.L11:
	movl	-28(%rbp), %eax
	cmpl	%eax, -12(%rbp)
	jl	.L12
	movl	$0, -12(%rbp)
	jmp	.L13
.L14:
	movl	-12(%rbp), %eax
	addl	$1, %eax
	movl	%eax, color(%rip)
	movl	-12(%rbp), %eax
	movl	%eax, %edi
	call	dfs
	addl	$1, -12(%rbp)
.L13:
	movl	-32(%rbp), %eax
	cmpl	%eax, -12(%rbp)
	jl	.L14
	leaq	-16(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -12(%rbp)
	jmp	.L15
.L18:
	leaq	-20(%rbp), %rdx
	leaq	-24(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	connected(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	connected(%rip), %rax
	movl	(%rcx,%rax), %eax
	cmpl	%eax, %edx
	jne	.L16
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	jmp	.L17
.L16:
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
.L17:
	addl	$1, -12(%rbp)
.L15:
	movl	-16(%rbp), %eax
	cmpl	%eax, -12(%rbp)
	jl	.L18
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L20
	call	__stack_chk_fail@PLT
.L20:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE9:
	.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	G
	.bss
	.align 32
	.type	G, @object
	.size	G, 800000
G:
	.zero	800000
	.globl	connected
	.align 32
	.type	connected, @object
	.size	connected, 400000
connected:
	.zero	400000
	.globl	color
	.align 4
	.type	color, @object
	.size	color, 4
color:
	.zero	4
	.text
	.globl	add_node
	.type	add_node, @function
add_node:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movq	%rdi, -24(%rbp)
	movl	%esi, -28(%rbp)
	movl	$16, %edi
	call	malloc@PLT
	movq	%rax, -8(%rbp)
	movq	-8(%rbp), %rax
	movl	-28(%rbp), %edx
	movl	%edx, (%rax)
	movq	-8(%rbp), %rax
	movq	-24(%rbp), %rdx
	movq	%rdx, 8(%rax)
	movq	-8(%rbp), %rax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	add_node, .-add_node
	.globl	add
	.type	add, @function
add:
.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	%esi, -8(%rbp)
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	G(%rip), %rax
	movq	(%rdx,%rax), %rax
	movl	-8(%rbp), %edx
	movl	%edx, %esi
	movq	%rax, %rdi
	call	add_node
	movl	-4(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,8), %rcx
	leaq	G(%rip), %rdx
	movq	%rax, (%rcx,%rdx)
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	G(%rip), %rax
	movq	(%rdx,%rax), %rax
	movl	-4(%rbp), %edx
	movl	%edx, %esi
	movq	%rax, %rdi
	call	add_node
	movl	-8(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,8), %rcx
	leaq	G(%rip), %rdx
	movq	%rax, (%rcx,%rdx)
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	add, .-add
	.globl	dfs
	.type	dfs, @function
dfs:
.LFB8:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movl	%edi, -20(%rbp)
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	connected(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	jne	.L9
	movl	color(%rip), %eax
	movl	-20(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	connected(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	G(%rip), %rax
	movq	(%rdx,%rax), %rax
	movq	%rax, -8(%rbp)
	jmp	.L7
.L8:
	movq	-8(%rbp), %rax
	movl	(%rax), %eax
	movl	%eax, %edi
	call	dfs
	movq	-8(%rbp), %rax
	movq	8(%rax), %rax
	movq	%rax, -8(%rbp)
.L7:
	cmpq	$0, -8(%rbp)
	jne	.L8
	jmp	.L4
.L9:
	nop
.L4:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.size	dfs, .-dfs
	.section	.rodata
.LC0:
	.string	"%d %d"
.LC1:
	.string	"%d"
.LC2:
	.string	"yes"
.LC3:
	.string	"no"
	.text
	.globl	main
	.type	main, @function
main:
.LFB9:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-28(%rbp), %rdx
	leaq	-32(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -12(%rbp)
	jmp	.L11
.L12:
	leaq	-20(%rbp), %rdx
	leaq	-24(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-20(%rbp), %edx
	movl	-24(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	add
	addl	$1, -12(%rbp)
.L11:
	movl	-28(%rbp), %eax
	cmpl	%eax, -12(%rbp)
	jl	.L12
	movl	$0, -12(%rbp)
	jmp	.L13
.L14:
	movl	-12(%rbp), %eax
	addl	$1, %eax
	movl	%eax, color(%rip)
	movl	-12(%rbp), %eax
	movl	%eax, %edi
	call	dfs
	addl	$1, -12(%rbp)
.L13:
	movl	-32(%rbp), %eax
	cmpl	%eax, -12(%rbp)
	jl	.L14
	leaq	-16(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -12(%rbp)
	jmp	.L15
.L18:
	leaq	-20(%rbp), %rdx
	leaq	-24(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	connected(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	connected(%rip), %rax
	movl	(%rcx,%rax), %eax
	cmpl	%eax, %edx
	jne	.L16
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	jmp	.L17
.L16:
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
.L17:
	addl	$1, -12(%rbp)
.L15:
	movl	-16(%rbp), %eax
	cmpl	%eax, -12(%rbp)
	jl	.L18
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L20
	call	__stack_chk_fail@PLT
.L20:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE9:
	.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:
