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>
long a[100001];
int main(void){
    long N,K,i,x,y;
    scanf("%ld%ld",&N,&K);
    for(i=0;i<N;i++){
        scanf("%ld%ld",&x,&y);
        a[x]+=y;
    }
    long g=0;
    for(i=0;i<100001;i++){
        g+=a[i];
        if(g>=K) break;
    }
    printf("%ld\n",i);
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	a
	.bss
	.align 32
	.type	a, @object
	.size	a, 800008
a:
	.zero	800008
	.section	.rodata
.LC0:
	.string	"%ld%ld"
.LC1:
	.string	"%ld\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	$64, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-48(%rbp), %rdx
	leaq	-56(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	$0, -24(%rbp)
	jmp	.L2
.L3:
	leaq	-32(%rbp), %rdx
	leaq	-40(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	-40(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	leaq	a(%rip), %rax
	movq	(%rdx,%rax), %rcx
	movq	-32(%rbp), %rdx
	movq	-40(%rbp), %rax
	addq	%rdx, %rcx
	leaq	0(,%rax,8), %rdx
	leaq	a(%rip), %rax
	movq	%rcx, (%rdx,%rax)
	addq	$1, -24(%rbp)
.L2:
	movq	-56(%rbp), %rax
	cmpq	%rax, -24(%rbp)
	jl	.L3
	movq	$0, -16(%rbp)
	movq	$0, -24(%rbp)
	jmp	.L4
.L7:
	movq	-24(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	leaq	a(%rip), %rax
	movq	(%rdx,%rax), %rax
	addq	%rax, -16(%rbp)
	movq	-48(%rbp), %rax
	cmpq	%rax, -16(%rbp)
	jge	.L10
	addq	$1, -24(%rbp)
.L4:
	cmpq	$100000, -24(%rbp)
	jle	.L7
	jmp	.L6
.L10:
	nop
.L6:
	movq	-24(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L9
	call	__stack_chk_fail@PLT
.L9:
	leave
	.cfi_def_cfa 7, 8
	ret
	.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	"%ld%ld"
.LC1:
	.string	"%ld\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.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
	leaq	.LC0(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	movq	%r12, %rdi
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	leaq	a(%rip), %rbx
	subq	$48, %rsp
	.cfi_def_cfa_offset 96
	movq	%fs:40, %rax
	movq	%rax, 40(%rsp)
	xorl	%eax, %eax
	leaq	16(%rsp), %rdx
	leaq	8(%rsp), %rsi
	call	__isoc99_scanf@PLT
	cmpq	$0, 8(%rsp)
	jle	.L2
	xorl	%ebp, %ebp
	leaq	32(%rsp), %r14
	leaq	24(%rsp), %r13
	.p2align 4,,10
	.p2align 3
.L3:
	movq	%r14, %rdx
	movq	%r13, %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movq	24(%rsp), %rax
	movq	32(%rsp), %rdx
	addq	$1, %rbp
	addq	%rdx, (%rbx,%rax,8)
	cmpq	%rbp, 8(%rsp)
	jg	.L3
.L2:
	movq	16(%rsp), %rcx
	xorl	%eax, %eax
	xorl	%edx, %edx
	jmp	.L5
	.p2align 4,,10
	.p2align 3
.L12:
	addq	$1, %rdx
	cmpq	$100001, %rdx
	je	.L4
.L5:
	addq	(%rbx,%rdx,8), %rax
	cmpq	%rax, %rcx
	jg	.L12
.L4:
	xorl	%eax, %eax
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	call	__printf_chk@PLT
	movq	40(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L13
	addq	$48, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 48
	xorl	%eax, %eax
	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
.L13:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.globl	a
	.bss
	.align 32
	.type	a, @object
	.size	a, 800008
a:
	.zero	800008
	.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	"%ld%ld"
.LC1:
	.string	"%ld\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.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
	leaq	.LC0(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	movq	%r12, %rdi
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	leaq	a(%rip), %rbx
	subq	$48, %rsp
	.cfi_def_cfa_offset 96
	movq	%fs:40, %rax
	movq	%rax, 40(%rsp)
	xorl	%eax, %eax
	leaq	16(%rsp), %rdx
	leaq	8(%rsp), %rsi
	call	__isoc99_scanf@PLT
	cmpq	$0, 8(%rsp)
	jle	.L2
	xorl	%ebp, %ebp
	leaq	32(%rsp), %r14
	leaq	24(%rsp), %r13
	.p2align 4,,10
	.p2align 3
.L3:
	movq	%r14, %rdx
	movq	%r13, %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movq	24(%rsp), %rax
	movq	32(%rsp), %rdx
	addq	$1, %rbp
	addq	%rdx, (%rbx,%rax,8)
	cmpq	%rbp, 8(%rsp)
	jg	.L3
.L2:
	movq	16(%rsp), %rcx
	xorl	%eax, %eax
	xorl	%edx, %edx
	jmp	.L5
	.p2align 4,,10
	.p2align 3
.L12:
	addq	$1, %rdx
	cmpq	$100001, %rdx
	je	.L4
.L5:
	addq	(%rbx,%rdx,8), %rax
	cmpq	%rax, %rcx
	jg	.L12
.L4:
	xorl	%eax, %eax
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	call	__printf_chk@PLT
	movq	40(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L13
	addq	$48, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 48
	xorl	%eax, %eax
	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
.L13:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.globl	a
	.bss
	.align 32
	.type	a, @object
	.size	a, 800008
a:
	.zero	800008
	.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>
long a[100001];
int main(void){
    long N,K,i,x,y;
    scanf("%ld%ld",&N,&K);
    for(i=0;i<N;i++){
        scanf("%ld%ld",&x,&y);
        a[x]+=y;
    }
    long g=0;
    for(i=0;i<100001;i++){
        g+=a[i];
        if(g>=K) break;
    }
    printf("%ld\n",i);
}
3 4
1 1
2 2
3 2
 10 500000
1 100000
1 100001
1 100000
1 100000
1 100000
100000 100000
100000 100000
100000 100000
100000 100000
100000 100000
 3 4
1 1
2 3
3 2
 3 4
1 1
4 3
3 2
 3 5
2 2
1 1
8 3
 3 5
2 2
1 1
15 3
 10 878093
1 100000
1 110001
1 100000
1 100001
1 100000
100000 100000
100000 100000
100000 100000
100000 100000
100000 100000
 3 3
2 2
1 0
5 3
 3 3
2 2
1 0
7 3
 3 4
1 0
2 1
6 6

3
 1
 2
 4
 8
 15
 100000
 5
 7
 6

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>
long a[100001];
int main(void){
    long N,K,i,x,y;
    scanf("%ld%ld",&N,&K);
    for(i=0;i<N;i++){
        scanf("%ld%ld",&x,&y);
        a[x]+=y;
    }
    long g=0;
    for(i=0;i<100001;i++){
        g+=a[i];
        if(g>=K) break;
    }
    printf("%ld\n",i);
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	a
	.bss
	.align 32
	.type	a, @object
	.size	a, 800008
a:
	.zero	800008
	.section	.rodata
.LC0:
	.string	"%ld%ld"
.LC1:
	.string	"%ld\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	$64, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-48(%rbp), %rdx
	leaq	-56(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	$0, -24(%rbp)
	jmp	.L2
.L3:
	leaq	-32(%rbp), %rdx
	leaq	-40(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	-40(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	leaq	a(%rip), %rax
	movq	(%rdx,%rax), %rcx
	movq	-32(%rbp), %rdx
	movq	-40(%rbp), %rax
	addq	%rdx, %rcx
	leaq	0(,%rax,8), %rdx
	leaq	a(%rip), %rax
	movq	%rcx, (%rdx,%rax)
	addq	$1, -24(%rbp)
.L2:
	movq	-56(%rbp), %rax
	cmpq	%rax, -24(%rbp)
	jl	.L3
	movq	$0, -16(%rbp)
	movq	$0, -24(%rbp)
	jmp	.L4
.L7:
	movq	-24(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	leaq	a(%rip), %rax
	movq	(%rdx,%rax), %rax
	addq	%rax, -16(%rbp)
	movq	-48(%rbp), %rax
	cmpq	%rax, -16(%rbp)
	jge	.L10
	addq	$1, -24(%rbp)
.L4:
	cmpq	$100000, -24(%rbp)
	jle	.L7
	jmp	.L6
.L10:
	nop
.L6:
	movq	-24(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L9
	call	__stack_chk_fail@PLT
.L9:
	leave
	.cfi_def_cfa 7, 8
	ret
	.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	a
	.bss
	.align 32
	.type	a, @object
	.size	a, 800008
a:
	.zero	800008
	.section	.rodata
.LC0:
	.string	"%ld%ld"
.LC1:
	.string	"%ld\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	$64, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-48(%rbp), %rdx
	leaq	-56(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	$0, -24(%rbp)
	jmp	.L2
.L3:
	leaq	-32(%rbp), %rdx
	leaq	-40(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	-40(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	leaq	a(%rip), %rax
	movq	(%rdx,%rax), %rcx
	movq	-32(%rbp), %rdx
	movq	-40(%rbp), %rax
	addq	%rdx, %rcx
	leaq	0(,%rax,8), %rdx
	leaq	a(%rip), %rax
	movq	%rcx, (%rdx,%rax)
	addq	$1, -24(%rbp)
.L2:
	movq	-56(%rbp), %rax
	cmpq	%rax, -24(%rbp)
	jl	.L3
	movq	$0, -16(%rbp)
	movq	$0, -24(%rbp)
	jmp	.L4
.L7:
	movq	-24(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	leaq	a(%rip), %rax
	movq	(%rdx,%rax), %rax
	addq	%rax, -16(%rbp)
	movq	-48(%rbp), %rax
	cmpq	%rax, -16(%rbp)
	jge	.L10
	addq	$1, -24(%rbp)
.L4:
	cmpq	$100000, -24(%rbp)
	jle	.L7
	jmp	.L6
.L10:
	nop
.L6:
	movq	-24(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L9
	call	__stack_chk_fail@PLT
.L9:
	leave
	.cfi_def_cfa 7, 8
	ret
	.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:
