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

```c
i[100012],d[100012],s,n,a,x,y;main(w){for(w=scanf("%d",&n);a++<n;d[y]++)scanf("%d%d",&x,&y),i[x]++;for(a=2;a<=n+1;w-=d[a++])w+=i[a],w>=a?s=a-1:0;printf("%d\n",s);exit(0);}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	i
	.bss
	.align 32
	.type	i, @object
	.size	i, 400048
i:
	.zero	400048
	.globl	d
	.align 32
	.type	d, @object
	.size	d, 400048
d:
	.zero	400048
	.globl	s
	.align 4
	.type	s, @object
	.size	s, 4
s:
	.zero	4
	.globl	n
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	a
	.align 4
	.type	a, @object
	.size	a, 4
a:
	.zero	4
	.globl	x
	.align 4
	.type	x, @object
	.size	x, 4
x:
	.zero	4
	.globl	y
	.align 4
	.type	y, @object
	.size	y, 4
y:
	.zero	4
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d%d"
.LC2:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB0:
	.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)
	leaq	n(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	scanf@PLT
	movl	%eax, -4(%rbp)
	jmp	.L2
.L3:
	leaq	y(%rip), %rax
	movq	%rax, %rdx
	leaq	x(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	scanf@PLT
	movl	x(%rip), %eax
	movslq	%eax, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	i(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	leal	1(%rdx), %ecx
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	i(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	y(%rip), %eax
	movslq	%eax, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	d(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	leal	1(%rdx), %ecx
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	%ecx, (%rdx,%rax)
.L2:
	movl	a(%rip), %eax
	leal	1(%rax), %edx
	movl	%edx, a(%rip)
	movl	n(%rip), %edx
	cmpl	%edx, %eax
	jl	.L3
	movl	$2, a(%rip)
	jmp	.L4
.L7:
	movl	a(%rip), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	i(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%eax, -4(%rbp)
	movl	a(%rip), %eax
	cmpl	%eax, -4(%rbp)
	jl	.L6
	movl	a(%rip), %eax
	subl	$1, %eax
	movl	%eax, s(%rip)
.L6:
	movl	a(%rip), %eax
	leal	1(%rax), %edx
	movl	%edx, a(%rip)
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	(%rdx,%rax), %eax
	subl	%eax, -4(%rbp)
.L4:
	movl	n(%rip), %eax
	leal	1(%rax), %edx
	movl	a(%rip), %eax
	cmpl	%eax, %edx
	jge	.L7
	movl	s(%rip), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %edi
	call	exit@PLT
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:
```

Only output the optimized assembly code. Do not include any other text. Do not write any comments in the assembly code. Wrap the assembly code in ```assembly``` tags.
user
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	"%d%d"
.LC2:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	n(%rip), %rsi
	leaq	.LC0(%rip), %rdi
	xorl	%eax, %eax
	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
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
	call	scanf@PLT
	movl	n(%rip), %esi
	movl	%eax, %ebx
	movl	a(%rip), %eax
	leal	1(%rax), %edx
	movl	%edx, a(%rip)
	cmpl	%esi, %eax
	jge	.L2
	leaq	y(%rip), %r15
	leaq	x(%rip), %r14
	leaq	.LC1(%rip), %r12
	leaq	i(%rip), %r13
	leaq	d(%rip), %rbp
	.p2align 4,,10
	.p2align 3
.L3:
	movq	%r15, %rdx
	movq	%r14, %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	call	scanf@PLT
	movslq	x(%rip), %rax
	movl	n(%rip), %esi
	addl	$1, 0(%r13,%rax,4)
	movslq	y(%rip), %rax
	addl	$1, 0(%rbp,%rax,4)
	movl	a(%rip), %eax
	leal	1(%rax), %edx
	movl	%edx, a(%rip)
	cmpl	%esi, %eax
	jl	.L3
.L2:
	movl	$2, a(%rip)
	testl	%esi, %esi
	jle	.L5
	leal	-1(%rsi), %edi
	movl	$2, %eax
	xorl	%r8d, %r8d
	addq	$3, %rdi
	leaq	i(%rip), %r13
	leaq	d(%rip), %rbp
	.p2align 4,,10
	.p2align 3
.L7:
	addl	0(%r13,%rax,4), %ebx
	movl	%ebx, %edx
	cmpl	%eax, %ebx
	jl	.L6
	leal	-1(%rax), %ecx
	movl	$1, %r8d
	movl	%ecx, 12(%rsp)
.L6:
	movl	%edx, %ebx
	subl	0(%rbp,%rax,4), %ebx
	addq	$1, %rax
	cmpq	%rax, %rdi
	jne	.L7
	addl	$2, %esi
	movl	%esi, a(%rip)
	testb	%r8b, %r8b
	je	.L5
	movl	12(%rsp), %eax
	movl	%eax, s(%rip)
.L5:
	movl	s(%rip), %esi
	leaq	.LC2(%rip), %rdi
	xorl	%eax, %eax
	call	printf@PLT
	xorl	%edi, %edi
	call	exit@PLT
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.globl	y
	.bss
	.align 4
	.type	y, @object
	.size	y, 4
y:
	.zero	4
	.globl	x
	.align 4
	.type	x, @object
	.size	x, 4
x:
	.zero	4
	.globl	a
	.align 4
	.type	a, @object
	.size	a, 4
a:
	.zero	4
	.globl	n
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	s
	.align 4
	.type	s, @object
	.size	s, 4
s:
	.zero	4
	.globl	d
	.align 32
	.type	d, @object
	.size	d, 400048
d:
	.zero	400048
	.globl	i
	.align 32
	.type	i, @object
	.size	i, 400048
i:
	.zero	400048
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:

rule
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	"%d%d"
.LC2:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	n(%rip), %rsi
	leaq	.LC0(%rip), %rdi
	xorl	%eax, %eax
	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
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
	call	scanf@PLT
	movl	n(%rip), %esi
	movl	%eax, %ebx
	movl	a(%rip), %eax
	leal	1(%rax), %edx
	movl	%edx, a(%rip)
	cmpl	%esi, %eax
	jge	.L2
	leaq	y(%rip), %r15
	leaq	x(%rip), %r14
	leaq	.LC1(%rip), %r12
	leaq	i(%rip), %r13
	leaq	d(%rip), %rbp
	.p2align 4,,10
	.p2align 3
.L3:
	movq	%r15, %rdx
	movq	%r14, %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	call	scanf@PLT
	movslq	x(%rip), %rax
	movl	n(%rip), %esi
	addl	$1, 0(%r13,%rax,4)
	movslq	y(%rip), %rax
	addl	$1, 0(%rbp,%rax,4)
	movl	a(%rip), %eax
	leal	1(%rax), %edx
	movl	%edx, a(%rip)
	cmpl	%esi, %eax
	jl	.L3
.L2:
	movl	$2, a(%rip)
	testl	%esi, %esi
	jle	.L5
	leal	-1(%rsi), %edi
	movl	$2, %eax
	xorl	%r8d, %r8d
	addq	$3, %rdi
	leaq	i(%rip), %r13
	leaq	d(%rip), %rbp
	.p2align 4,,10
	.p2align 3
.L7:
	addl	0(%r13,%rax,4), %ebx
	movl	%ebx, %edx
	cmpl	%eax, %ebx
	jl	.L6
	leal	-1(%rax), %ecx
	movl	$1, %r8d
	movl	%ecx, 12(%rsp)
.L6:
	movl	%edx, %ebx
	subl	0(%rbp,%rax,4), %ebx
	addq	$1, %rax
	cmpq	%rax, %rdi
	jne	.L7
	addl	$2, %esi
	movl	%esi, a(%rip)
	testb	%r8b, %r8b
	je	.L5
	movl	12(%rsp), %eax
	movl	%eax, s(%rip)
.L5:
	movl	s(%rip), %esi
	leaq	.LC2(%rip), %rdi
	xorl	%eax, %eax
	call	printf@PLT
	xorl	%edi, %edi
	call	exit@PLT
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.globl	y
	.bss
	.align 4
	.type	y, @object
	.size	y, 4
y:
	.zero	4
	.globl	x
	.align 4
	.type	x, @object
	.size	x, 4
x:
	.zero	4
	.globl	a
	.align 4
	.type	a, @object
	.size	a, 4
a:
	.zero	4
	.globl	n
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	s
	.align 4
	.type	s, @object
	.size	s, 4
s:
	.zero	4
	.globl	d
	.align 32
	.type	d, @object
	.size	d, 400048
d:
	.zero	400048
	.globl	i
	.align 32
	.type	i, @object
	.size	i, 400048
i:
	.zero	400048
	.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:

i[100012],d[100012],s,n,a,x,y;main(w){for(w=scanf("%d",&n);a++<n;d[y]++)scanf("%d%d",&x,&y),i[x]++;for(a=2;a<=n+1;w-=d[a++])w+=i[a],w>=a?s=a-1:0;printf("%d\n",s);exit(0);}
5
8 100001
14 100001
12 100001
8 100001
3 100001
 4
2 5
4 7
2 4
5 6
 6
2 9
4 8
6 7
6 6
5 4
2 100001
 4
2 1
4 7
2 4
5 6
 5
8 100001
7 100001
12 100001
3 100001
3 100001
 6
2 9
2 8
6 7
6 6
5 4
2 100001
 6
4 9
2 8
6 7
6 6
5 4
2 100001
 5
6 100001
7 100001
12 100001
8 100001
3 100001
 4
2 2
4 7
2 4
3 6
 4
2 6
4 7
2 4
5 6

0
 3
 5
 3
 2
 5
 5
 0
 3
 3

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

```c
i[100012],d[100012],s,n,a,x,y;main(w){for(w=scanf("%d",&n);a++<n;d[y]++)scanf("%d%d",&x,&y),i[x]++;for(a=2;a<=n+1;w-=d[a++])w+=i[a],w>=a?s=a-1:0;printf("%d\n",s);exit(0);}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	i
	.bss
	.align 32
	.type	i, @object
	.size	i, 400048
i:
	.zero	400048
	.globl	d
	.align 32
	.type	d, @object
	.size	d, 400048
d:
	.zero	400048
	.globl	s
	.align 4
	.type	s, @object
	.size	s, 4
s:
	.zero	4
	.globl	n
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	a
	.align 4
	.type	a, @object
	.size	a, 4
a:
	.zero	4
	.globl	x
	.align 4
	.type	x, @object
	.size	x, 4
x:
	.zero	4
	.globl	y
	.align 4
	.type	y, @object
	.size	y, 4
y:
	.zero	4
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d%d"
.LC2:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB0:
	.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)
	leaq	n(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	scanf@PLT
	movl	%eax, -4(%rbp)
	jmp	.L2
.L3:
	leaq	y(%rip), %rax
	movq	%rax, %rdx
	leaq	x(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	scanf@PLT
	movl	x(%rip), %eax
	movslq	%eax, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	i(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	leal	1(%rdx), %ecx
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	i(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	y(%rip), %eax
	movslq	%eax, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	d(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	leal	1(%rdx), %ecx
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	%ecx, (%rdx,%rax)
.L2:
	movl	a(%rip), %eax
	leal	1(%rax), %edx
	movl	%edx, a(%rip)
	movl	n(%rip), %edx
	cmpl	%edx, %eax
	jl	.L3
	movl	$2, a(%rip)
	jmp	.L4
.L7:
	movl	a(%rip), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	i(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%eax, -4(%rbp)
	movl	a(%rip), %eax
	cmpl	%eax, -4(%rbp)
	jl	.L6
	movl	a(%rip), %eax
	subl	$1, %eax
	movl	%eax, s(%rip)
.L6:
	movl	a(%rip), %eax
	leal	1(%rax), %edx
	movl	%edx, a(%rip)
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	(%rdx,%rax), %eax
	subl	%eax, -4(%rbp)
.L4:
	movl	n(%rip), %eax
	leal	1(%rax), %edx
	movl	a(%rip), %eax
	cmpl	%eax, %edx
	jge	.L7
	movl	s(%rip), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %edi
	call	exit@PLT
	.cfi_endproc
.LFE0:
	.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	i
	.bss
	.align 32
	.type	i, @object
	.size	i, 400048
i:
	.zero	400048
	.globl	d
	.align 32
	.type	d, @object
	.size	d, 400048
d:
	.zero	400048
	.globl	s
	.align 4
	.type	s, @object
	.size	s, 4
s:
	.zero	4
	.globl	n
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	a
	.align 4
	.type	a, @object
	.size	a, 4
a:
	.zero	4
	.globl	x
	.align 4
	.type	x, @object
	.size	x, 4
x:
	.zero	4
	.globl	y
	.align 4
	.type	y, @object
	.size	y, 4
y:
	.zero	4
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d%d"
.LC2:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB0:
	.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)
	leaq	n(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	scanf@PLT
	movl	%eax, -4(%rbp)
	jmp	.L2
.L3:
	leaq	y(%rip), %rax
	movq	%rax, %rdx
	leaq	x(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	scanf@PLT
	movl	x(%rip), %eax
	movslq	%eax, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	i(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	leal	1(%rdx), %ecx
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	i(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	y(%rip), %eax
	movslq	%eax, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	d(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	leal	1(%rdx), %ecx
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	%ecx, (%rdx,%rax)
.L2:
	movl	a(%rip), %eax
	leal	1(%rax), %edx
	movl	%edx, a(%rip)
	movl	n(%rip), %edx
	cmpl	%edx, %eax
	jl	.L3
	movl	$2, a(%rip)
	jmp	.L4
.L7:
	movl	a(%rip), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	i(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%eax, -4(%rbp)
	movl	a(%rip), %eax
	cmpl	%eax, -4(%rbp)
	jl	.L6
	movl	a(%rip), %eax
	subl	$1, %eax
	movl	%eax, s(%rip)
.L6:
	movl	a(%rip), %eax
	leal	1(%rax), %edx
	movl	%edx, a(%rip)
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	(%rdx,%rax), %eax
	subl	%eax, -4(%rbp)
.L4:
	movl	n(%rip), %eax
	leal	1(%rax), %edx
	movl	a(%rip), %eax
	cmpl	%eax, %edx
	jge	.L7
	movl	s(%rip), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %edi
	call	exit@PLT
	.cfi_endproc
.LFE0:
	.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:
