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>
struct data{
	int d,p;
};
int main(void){
	struct data D[10000],tmp;
	int n,m,i,j,ans;
	while(1){
		scanf("%d %d",&n,&m);
		if(!n)
			break;
		for(i=0;i<n;i++)
			scanf("%d %d",&D[i].d,&D[i].p);
		for(i=0;i<n-1;i++){
			for(j=n-1;j>i;j--){
				if(D[j-1].p<D[j].p){
					tmp=D[j-1];
					D[j-1]=D[j];
					D[j]=tmp;
				}
			}
		}
		for(i=0;i<n;i++){
			if(!m)
				break;
			if(D[i].d<m){
				m-=D[i].d;
				D[i].d=0;
			}
			else{
				D[i].d-=m;
				m=0;
			}
		}
		ans=0;
		for(i=0;i<n;i++)
			ans+=D[i].d*D[i].p;
		printf("%d\n",ans);
	}
	return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d %d"
.LC1:
	.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
	leaq	-77824(%rsp), %r11
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	subq	$2224, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
.L19:
	leaq	-80040(%rbp), %rdx
	leaq	-80044(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-80044(%rbp), %eax
	testl	%eax, %eax
	je	.L23
	movl	$0, -80036(%rbp)
	jmp	.L4
.L5:
	leaq	-80016(%rbp), %rdx
	movl	-80036(%rbp), %eax
	cltq
	salq	$3, %rax
	addq	%rdx, %rax
	leaq	4(%rax), %rdx
	leaq	-80016(%rbp), %rcx
	movl	-80036(%rbp), %eax
	cltq
	salq	$3, %rax
	addq	%rcx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -80036(%rbp)
.L4:
	movl	-80044(%rbp), %eax
	cmpl	%eax, -80036(%rbp)
	jl	.L5
	movl	$0, -80036(%rbp)
	jmp	.L6
.L10:
	movl	-80044(%rbp), %eax
	subl	$1, %eax
	movl	%eax, -80032(%rbp)
	jmp	.L7
.L9:
	movl	-80032(%rbp), %eax
	subl	$1, %eax
	cltq
	movl	-80012(%rbp,%rax,8), %edx
	movl	-80032(%rbp), %eax
	cltq
	movl	-80012(%rbp,%rax,8), %eax
	cmpl	%eax, %edx
	jge	.L8
	movl	-80032(%rbp), %eax
	subl	$1, %eax
	cltq
	movq	-80016(%rbp,%rax,8), %rax
	movq	%rax, -80024(%rbp)
	movl	-80032(%rbp), %eax
	subl	$1, %eax
	cltq
	movl	-80032(%rbp), %edx
	movslq	%edx, %rdx
	movq	-80016(%rbp,%rdx,8), %rdx
	movq	%rdx, -80016(%rbp,%rax,8)
	movl	-80032(%rbp), %eax
	cltq
	movq	-80024(%rbp), %rdx
	movq	%rdx, -80016(%rbp,%rax,8)
.L8:
	subl	$1, -80032(%rbp)
.L7:
	movl	-80032(%rbp), %eax
	cmpl	-80036(%rbp), %eax
	jg	.L9
	addl	$1, -80036(%rbp)
.L6:
	movl	-80044(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -80036(%rbp)
	jl	.L10
	movl	$0, -80036(%rbp)
	jmp	.L11
.L16:
	movl	-80040(%rbp), %eax
	testl	%eax, %eax
	je	.L24
	movl	-80036(%rbp), %eax
	cltq
	movl	-80016(%rbp,%rax,8), %edx
	movl	-80040(%rbp), %eax
	cmpl	%eax, %edx
	jge	.L14
	movl	-80040(%rbp), %edx
	movl	-80036(%rbp), %eax
	cltq
	movl	-80016(%rbp,%rax,8), %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	movl	%eax, -80040(%rbp)
	movl	-80036(%rbp), %eax
	cltq
	movl	$0, -80016(%rbp,%rax,8)
	jmp	.L15
.L14:
	movl	-80036(%rbp), %eax
	cltq
	movl	-80016(%rbp,%rax,8), %eax
	movl	-80040(%rbp), %ecx
	subl	%ecx, %eax
	movl	%eax, %edx
	movl	-80036(%rbp), %eax
	cltq
	movl	%edx, -80016(%rbp,%rax,8)
	movl	$0, -80040(%rbp)
.L15:
	addl	$1, -80036(%rbp)
.L11:
	movl	-80044(%rbp), %eax
	cmpl	%eax, -80036(%rbp)
	jl	.L16
	jmp	.L13
.L24:
	nop
.L13:
	movl	$0, -80028(%rbp)
	movl	$0, -80036(%rbp)
	jmp	.L17
.L18:
	movl	-80036(%rbp), %eax
	cltq
	movl	-80016(%rbp,%rax,8), %edx
	movl	-80036(%rbp), %eax
	cltq
	movl	-80012(%rbp,%rax,8), %eax
	imull	%edx, %eax
	addl	%eax, -80028(%rbp)
	addl	$1, -80036(%rbp)
.L17:
	movl	-80044(%rbp), %eax
	cmpl	%eax, -80036(%rbp)
	jl	.L18
	movl	-80028(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L19
.L23:
	nop
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L21
	call	__stack_chk_fail@PLT
.L21:
	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	"%d %d"
.LC1:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.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
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	leaq	-77824(%rsp), %r11
	.cfi_def_cfa 11, 77880
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	.cfi_def_cfa_register 7
	subq	$2232, %rsp
	.cfi_def_cfa_offset 80112
	leaq	.LC0(%rip), %rbx
	movq	%fs:40, %rax
	movq	%rax, 80040(%rsp)
	xorl	%eax, %eax
	leaq	40(%rsp), %rax
	leaq	28(%rsp), %r13
	movq	%rax, 8(%rsp)
	leaq	24(%rsp), %r12
	leaq	32(%rsp), %rbp
	.p2align 4,,10
	.p2align 3
.L20:
	movq	%r13, %rdx
	movq	%r12, %rsi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	24(%rsp), %eax
	testl	%eax, %eax
	je	.L2
	jle	.L23
	movq	%rbp, %r14
	xorl	%r15d, %r15d
	.p2align 4,,10
	.p2align 3
.L4:
	leaq	4(%r14), %rdx
	movq	%r14, %rsi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	24(%rsp), %edi
	addl	$1, %r15d
	addq	$8, %r14
	cmpl	%r15d, %edi
	jg	.L4
	leal	-1(%rdi), %r8d
	testl	%r8d, %r8d
	jle	.L10
	movslq	%edi, %rax
	xorl	%esi, %esi
	leaq	0(%rbp,%rax,8), %r9
	.p2align 4,,10
	.p2align 3
.L9:
	movq	%r9, %rax
	movl	%r8d, %ecx
	.p2align 4,,10
	.p2align 3
.L8:
	movl	-12(%rax), %edx
	subl	$1, %ecx
	cmpl	-4(%rax), %edx
	jge	.L7
	movd	%edx, %xmm4
	movq	-8(%rax), %rdx
	movd	-16(%rax), %xmm0
	movq	%rdx, -16(%rax)
	punpckldq	%xmm4, %xmm0
	movq	%xmm0, -8(%rax)
.L7:
	subq	$8, %rax
	cmpl	%esi, %ecx
	jg	.L8
	addl	$1, %esi
	cmpl	%esi, %r8d
	jne	.L9
.L10:
	testl	%edi, %edi
	jle	.L23
	movq	8(%rsp), %rdx
	movl	%r8d, %eax
	movl	28(%rsp), %ecx
	movq	%rbp, %rsi
	leaq	(%rdx,%rax,8), %r9
	movq	%rbp, %rax
	xorl	%edx, %edx
	jmp	.L14
	.p2align 4,,10
	.p2align 3
.L38:
	movl	$0, (%rax)
	addq	$8, %rax
	subl	%edx, %ecx
	movl	$1, %edx
	cmpq	%r9, %rax
	je	.L15
.L14:
	testl	%ecx, %ecx
	je	.L37
	movl	(%rax), %edx
	cmpl	%ecx, %edx
	jl	.L38
	subl	%ecx, %edx
	addq	$8, %rax
	xorl	%ecx, %ecx
	movl	%edx, -8(%rax)
	cmpq	%r9, %rax
	je	.L15
.L16:
	movl	$0, 28(%rsp)
.L12:
	cmpl	$2, %r8d
	jbe	.L24
.L40:
	movl	%edi, %eax
	pxor	%xmm3, %xmm3
	shrl	$2, %eax
	leal	-1(%rax), %edx
	leaq	32(%rbp), %rax
	salq	$5, %rdx
	addq	%rax, %rdx
	jmp	.L18
	.p2align 4,,10
	.p2align 3
.L39:
	addq	$32, %rax
.L18:
	movdqa	(%rsi), %xmm1
	movdqa	16(%rsi), %xmm2
	movq	%rax, %rsi
	movdqa	%xmm1, %xmm0
	shufps	$221, %xmm2, %xmm1
	shufps	$136, %xmm2, %xmm0
	movdqa	%xmm0, %xmm2
	psrlq	$32, %xmm0
	pmuludq	%xmm1, %xmm2
	psrlq	$32, %xmm1
	pmuludq	%xmm1, %xmm0
	pshufd	$8, %xmm2, %xmm1
	pshufd	$8, %xmm0, %xmm0
	punpckldq	%xmm0, %xmm1
	paddd	%xmm1, %xmm3
	cmpq	%rdx, %rax
	jne	.L39
	movdqa	%xmm3, %xmm0
	movl	%edi, %eax
	psrldq	$8, %xmm0
	andl	$-4, %eax
	paddd	%xmm0, %xmm3
	movdqa	%xmm3, %xmm0
	psrldq	$4, %xmm0
	paddd	%xmm0, %xmm3
	movd	%xmm3, %edx
	testb	$3, %dil
	je	.L3
.L21:
	movslq	%eax, %rsi
	movl	32(%rsp,%rsi,8), %ecx
	imull	36(%rsp,%rsi,8), %ecx
	addl	%ecx, %edx
	leal	1(%rax), %ecx
	cmpl	%ecx, %edi
	jle	.L3
	movslq	%ecx, %rcx
	addl	$2, %eax
	movl	32(%rsp,%rcx,8), %esi
	imull	36(%rsp,%rcx,8), %esi
	addl	%esi, %edx
	cmpl	%eax, %edi
	jle	.L3
	cltq
	movl	36(%rsp,%rax,8), %ecx
	imull	32(%rsp,%rax,8), %ecx
	addl	%ecx, %edx
.L3:
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L20
.L15:
	movl	%ecx, 28(%rsp)
	cmpl	$2, %r8d
	ja	.L40
.L24:
	xorl	%edx, %edx
	xorl	%eax, %eax
	jmp	.L21
.L37:
	testb	%dl, %dl
	je	.L12
	jmp	.L16
	.p2align 4,,10
	.p2align 3
.L23:
	xorl	%edx, %edx
	jmp	.L3
.L2:
	movq	80040(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L41
	addq	$80056, %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
.L41:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.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
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d %d"
.LC1:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.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
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	leaq	-77824(%rsp), %r11
	.cfi_def_cfa 11, 77880
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	.cfi_def_cfa_register 7
	subq	$2232, %rsp
	.cfi_def_cfa_offset 80112
	leaq	.LC0(%rip), %rbx
	movq	%fs:40, %rax
	movq	%rax, 80040(%rsp)
	xorl	%eax, %eax
	leaq	40(%rsp), %rax
	leaq	28(%rsp), %r13
	movq	%rax, 8(%rsp)
	leaq	24(%rsp), %r12
	leaq	32(%rsp), %rbp
	.p2align 4,,10
	.p2align 3
.L20:
	movq	%r13, %rdx
	movq	%r12, %rsi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	24(%rsp), %eax
	testl	%eax, %eax
	je	.L2
	jle	.L23
	movq	%rbp, %r14
	xorl	%r15d, %r15d
	.p2align 4,,10
	.p2align 3
.L4:
	leaq	4(%r14), %rdx
	movq	%r14, %rsi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	24(%rsp), %edi
	addl	$1, %r15d
	addq	$8, %r14
	cmpl	%r15d, %edi
	jg	.L4
	leal	-1(%rdi), %r8d
	testl	%r8d, %r8d
	jle	.L10
	movslq	%edi, %rax
	xorl	%esi, %esi
	leaq	0(%rbp,%rax,8), %r9
	.p2align 4,,10
	.p2align 3
.L9:
	movq	%r9, %rax
	movl	%r8d, %ecx
	.p2align 4,,10
	.p2align 3
.L8:
	movl	-12(%rax), %edx
	subl	$1, %ecx
	cmpl	-4(%rax), %edx
	jge	.L7
	movd	%edx, %xmm4
	movq	-8(%rax), %rdx
	movd	-16(%rax), %xmm0
	movq	%rdx, -16(%rax)
	punpckldq	%xmm4, %xmm0
	movq	%xmm0, -8(%rax)
.L7:
	subq	$8, %rax
	cmpl	%esi, %ecx
	jg	.L8
	addl	$1, %esi
	cmpl	%esi, %r8d
	jne	.L9
.L10:
	testl	%edi, %edi
	jle	.L23
	movq	8(%rsp), %rdx
	movl	%r8d, %eax
	movl	28(%rsp), %ecx
	movq	%rbp, %rsi
	leaq	(%rdx,%rax,8), %r9
	movq	%rbp, %rax
	xorl	%edx, %edx
	jmp	.L14
	.p2align 4,,10
	.p2align 3
.L38:
	movl	$0, (%rax)
	addq	$8, %rax
	subl	%edx, %ecx
	movl	$1, %edx
	cmpq	%r9, %rax
	je	.L15
.L14:
	testl	%ecx, %ecx
	je	.L37
	movl	(%rax), %edx
	cmpl	%ecx, %edx
	jl	.L38
	subl	%ecx, %edx
	addq	$8, %rax
	xorl	%ecx, %ecx
	movl	%edx, -8(%rax)
	cmpq	%r9, %rax
	je	.L15
.L16:
	movl	$0, 28(%rsp)
.L12:
	cmpl	$2, %r8d
	jbe	.L24
.L40:
	movl	%edi, %eax
	pxor	%xmm3, %xmm3
	shrl	$2, %eax
	leal	-1(%rax), %edx
	leaq	32(%rbp), %rax
	salq	$5, %rdx
	addq	%rax, %rdx
	jmp	.L18
	.p2align 4,,10
	.p2align 3
.L39:
	addq	$32, %rax
.L18:
	movdqa	(%rsi), %xmm1
	movdqa	16(%rsi), %xmm2
	movq	%rax, %rsi
	movdqa	%xmm1, %xmm0
	shufps	$221, %xmm2, %xmm1
	shufps	$136, %xmm2, %xmm0
	movdqa	%xmm0, %xmm2
	psrlq	$32, %xmm0
	pmuludq	%xmm1, %xmm2
	psrlq	$32, %xmm1
	pmuludq	%xmm1, %xmm0
	pshufd	$8, %xmm2, %xmm1
	pshufd	$8, %xmm0, %xmm0
	punpckldq	%xmm0, %xmm1
	paddd	%xmm1, %xmm3
	cmpq	%rdx, %rax
	jne	.L39
	movdqa	%xmm3, %xmm0
	movl	%edi, %eax
	psrldq	$8, %xmm0
	andl	$-4, %eax
	paddd	%xmm0, %xmm3
	movdqa	%xmm3, %xmm0
	psrldq	$4, %xmm0
	paddd	%xmm0, %xmm3
	movd	%xmm3, %edx
	testb	$3, %dil
	je	.L3
.L21:
	movslq	%eax, %rsi
	movl	32(%rsp,%rsi,8), %ecx
	imull	36(%rsp,%rsi,8), %ecx
	addl	%ecx, %edx
	leal	1(%rax), %ecx
	cmpl	%ecx, %edi
	jle	.L3
	movslq	%ecx, %rcx
	addl	$2, %eax
	movl	32(%rsp,%rcx,8), %esi
	imull	36(%rsp,%rcx,8), %esi
	addl	%esi, %edx
	cmpl	%eax, %edi
	jle	.L3
	cltq
	movl	36(%rsp,%rax,8), %ecx
	imull	32(%rsp,%rax,8), %ecx
	addl	%ecx, %edx
.L3:
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L20
.L15:
	movl	%ecx, 28(%rsp)
	cmpl	$2, %r8d
	ja	.L40
.L24:
	xorl	%edx, %edx
	xorl	%eax, %eax
	jmp	.L21
.L37:
	testb	%dl, %dl
	je	.L12
	jmp	.L16
	.p2align 4,,10
	.p2align 3
.L23:
	xorl	%edx, %edx
	jmp	.L3
.L2:
	movq	80040(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L41
	addq	$80056, %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
.L41:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.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>
struct data{
	int d,p;
};
int main(void){
	struct data D[10000],tmp;
	int n,m,i,j,ans;
	while(1){
		scanf("%d %d",&n,&m);
		if(!n)
			break;
		for(i=0;i<n;i++)
			scanf("%d %d",&D[i].d,&D[i].p);
		for(i=0;i<n-1;i++){
			for(j=n-1;j>i;j--){
				if(D[j-1].p<D[j].p){
					tmp=D[j-1];
					D[j-1]=D[j];
					D[j]=tmp;
				}
			}
		}
		for(i=0;i<n;i++){
			if(!m)
				break;
			if(D[i].d<m){
				m-=D[i].d;
				D[i].d=0;
			}
			else{
				D[i].d-=m;
				m=0;
			}
		}
		ans=0;
		for(i=0;i<n;i++)
			ans+=D[i].d*D[i].p;
		printf("%d\n",ans);
	}
	return 0;
}
2 8
5 6
4 5
3 2
5 10
5 10
5 10
0 0
 2 8
5 6
4 5
3 2
5 10
3 10
5 10
0 0
 2 8
5 6
4 5
3 2
1 10
5 10
5 10
0 0
 2 8
5 6
4 5
3 1
3 10
5 10
5 10
0 0
 2 8
5 6
4 5
3 2
5 10
7 10
5 10
0 0
 2 8
5 6
4 5
3 2
0 10
5 10
5 10
0 0
 2 8
5 6
4 5
3 2
0 10
7 10
5 10
0 0
 2 8
5 6
4 5
3 4
0 5
5 10
5 10
0 0
 2 8
5 6
4 5
3 2
0 6
7 10
4 7
0 0
 2 8
7 6
4 5
3 2
5 10
3 10
5 10
0 0

5
130
 5
110
 5
90
 5
120
 5
150
 5
80
 5
100
 5
60
 5
78
 15
110

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>
struct data{
	int d,p;
};
int main(void){
	struct data D[10000],tmp;
	int n,m,i,j,ans;
	while(1){
		scanf("%d %d",&n,&m);
		if(!n)
			break;
		for(i=0;i<n;i++)
			scanf("%d %d",&D[i].d,&D[i].p);
		for(i=0;i<n-1;i++){
			for(j=n-1;j>i;j--){
				if(D[j-1].p<D[j].p){
					tmp=D[j-1];
					D[j-1]=D[j];
					D[j]=tmp;
				}
			}
		}
		for(i=0;i<n;i++){
			if(!m)
				break;
			if(D[i].d<m){
				m-=D[i].d;
				D[i].d=0;
			}
			else{
				D[i].d-=m;
				m=0;
			}
		}
		ans=0;
		for(i=0;i<n;i++)
			ans+=D[i].d*D[i].p;
		printf("%d\n",ans);
	}
	return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d %d"
.LC1:
	.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
	leaq	-77824(%rsp), %r11
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	subq	$2224, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
.L19:
	leaq	-80040(%rbp), %rdx
	leaq	-80044(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-80044(%rbp), %eax
	testl	%eax, %eax
	je	.L23
	movl	$0, -80036(%rbp)
	jmp	.L4
.L5:
	leaq	-80016(%rbp), %rdx
	movl	-80036(%rbp), %eax
	cltq
	salq	$3, %rax
	addq	%rdx, %rax
	leaq	4(%rax), %rdx
	leaq	-80016(%rbp), %rcx
	movl	-80036(%rbp), %eax
	cltq
	salq	$3, %rax
	addq	%rcx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -80036(%rbp)
.L4:
	movl	-80044(%rbp), %eax
	cmpl	%eax, -80036(%rbp)
	jl	.L5
	movl	$0, -80036(%rbp)
	jmp	.L6
.L10:
	movl	-80044(%rbp), %eax
	subl	$1, %eax
	movl	%eax, -80032(%rbp)
	jmp	.L7
.L9:
	movl	-80032(%rbp), %eax
	subl	$1, %eax
	cltq
	movl	-80012(%rbp,%rax,8), %edx
	movl	-80032(%rbp), %eax
	cltq
	movl	-80012(%rbp,%rax,8), %eax
	cmpl	%eax, %edx
	jge	.L8
	movl	-80032(%rbp), %eax
	subl	$1, %eax
	cltq
	movq	-80016(%rbp,%rax,8), %rax
	movq	%rax, -80024(%rbp)
	movl	-80032(%rbp), %eax
	subl	$1, %eax
	cltq
	movl	-80032(%rbp), %edx
	movslq	%edx, %rdx
	movq	-80016(%rbp,%rdx,8), %rdx
	movq	%rdx, -80016(%rbp,%rax,8)
	movl	-80032(%rbp), %eax
	cltq
	movq	-80024(%rbp), %rdx
	movq	%rdx, -80016(%rbp,%rax,8)
.L8:
	subl	$1, -80032(%rbp)
.L7:
	movl	-80032(%rbp), %eax
	cmpl	-80036(%rbp), %eax
	jg	.L9
	addl	$1, -80036(%rbp)
.L6:
	movl	-80044(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -80036(%rbp)
	jl	.L10
	movl	$0, -80036(%rbp)
	jmp	.L11
.L16:
	movl	-80040(%rbp), %eax
	testl	%eax, %eax
	je	.L24
	movl	-80036(%rbp), %eax
	cltq
	movl	-80016(%rbp,%rax,8), %edx
	movl	-80040(%rbp), %eax
	cmpl	%eax, %edx
	jge	.L14
	movl	-80040(%rbp), %edx
	movl	-80036(%rbp), %eax
	cltq
	movl	-80016(%rbp,%rax,8), %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	movl	%eax, -80040(%rbp)
	movl	-80036(%rbp), %eax
	cltq
	movl	$0, -80016(%rbp,%rax,8)
	jmp	.L15
.L14:
	movl	-80036(%rbp), %eax
	cltq
	movl	-80016(%rbp,%rax,8), %eax
	movl	-80040(%rbp), %ecx
	subl	%ecx, %eax
	movl	%eax, %edx
	movl	-80036(%rbp), %eax
	cltq
	movl	%edx, -80016(%rbp,%rax,8)
	movl	$0, -80040(%rbp)
.L15:
	addl	$1, -80036(%rbp)
.L11:
	movl	-80044(%rbp), %eax
	cmpl	%eax, -80036(%rbp)
	jl	.L16
	jmp	.L13
.L24:
	nop
.L13:
	movl	$0, -80028(%rbp)
	movl	$0, -80036(%rbp)
	jmp	.L17
.L18:
	movl	-80036(%rbp), %eax
	cltq
	movl	-80016(%rbp,%rax,8), %edx
	movl	-80036(%rbp), %eax
	cltq
	movl	-80012(%rbp,%rax,8), %eax
	imull	%edx, %eax
	addl	%eax, -80028(%rbp)
	addl	$1, -80036(%rbp)
.L17:
	movl	-80044(%rbp), %eax
	cmpl	%eax, -80036(%rbp)
	jl	.L18
	movl	-80028(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L19
.L23:
	nop
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L21
	call	__stack_chk_fail@PLT
.L21:
	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
	.section	.rodata
.LC0:
	.string	"%d %d"
.LC1:
	.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
	leaq	-77824(%rsp), %r11
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	subq	$2224, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
.L19:
	leaq	-80040(%rbp), %rdx
	leaq	-80044(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-80044(%rbp), %eax
	testl	%eax, %eax
	je	.L23
	movl	$0, -80036(%rbp)
	jmp	.L4
.L5:
	leaq	-80016(%rbp), %rdx
	movl	-80036(%rbp), %eax
	cltq
	salq	$3, %rax
	addq	%rdx, %rax
	leaq	4(%rax), %rdx
	leaq	-80016(%rbp), %rcx
	movl	-80036(%rbp), %eax
	cltq
	salq	$3, %rax
	addq	%rcx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -80036(%rbp)
.L4:
	movl	-80044(%rbp), %eax
	cmpl	%eax, -80036(%rbp)
	jl	.L5
	movl	$0, -80036(%rbp)
	jmp	.L6
.L10:
	movl	-80044(%rbp), %eax
	subl	$1, %eax
	movl	%eax, -80032(%rbp)
	jmp	.L7
.L9:
	movl	-80032(%rbp), %eax
	subl	$1, %eax
	cltq
	movl	-80012(%rbp,%rax,8), %edx
	movl	-80032(%rbp), %eax
	cltq
	movl	-80012(%rbp,%rax,8), %eax
	cmpl	%eax, %edx
	jge	.L8
	movl	-80032(%rbp), %eax
	subl	$1, %eax
	cltq
	movq	-80016(%rbp,%rax,8), %rax
	movq	%rax, -80024(%rbp)
	movl	-80032(%rbp), %eax
	subl	$1, %eax
	cltq
	movl	-80032(%rbp), %edx
	movslq	%edx, %rdx
	movq	-80016(%rbp,%rdx,8), %rdx
	movq	%rdx, -80016(%rbp,%rax,8)
	movl	-80032(%rbp), %eax
	cltq
	movq	-80024(%rbp), %rdx
	movq	%rdx, -80016(%rbp,%rax,8)
.L8:
	subl	$1, -80032(%rbp)
.L7:
	movl	-80032(%rbp), %eax
	cmpl	-80036(%rbp), %eax
	jg	.L9
	addl	$1, -80036(%rbp)
.L6:
	movl	-80044(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -80036(%rbp)
	jl	.L10
	movl	$0, -80036(%rbp)
	jmp	.L11
.L16:
	movl	-80040(%rbp), %eax
	testl	%eax, %eax
	je	.L24
	movl	-80036(%rbp), %eax
	cltq
	movl	-80016(%rbp,%rax,8), %edx
	movl	-80040(%rbp), %eax
	cmpl	%eax, %edx
	jge	.L14
	movl	-80040(%rbp), %edx
	movl	-80036(%rbp), %eax
	cltq
	movl	-80016(%rbp,%rax,8), %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	movl	%eax, -80040(%rbp)
	movl	-80036(%rbp), %eax
	cltq
	movl	$0, -80016(%rbp,%rax,8)
	jmp	.L15
.L14:
	movl	-80036(%rbp), %eax
	cltq
	movl	-80016(%rbp,%rax,8), %eax
	movl	-80040(%rbp), %ecx
	subl	%ecx, %eax
	movl	%eax, %edx
	movl	-80036(%rbp), %eax
	cltq
	movl	%edx, -80016(%rbp,%rax,8)
	movl	$0, -80040(%rbp)
.L15:
	addl	$1, -80036(%rbp)
.L11:
	movl	-80044(%rbp), %eax
	cmpl	%eax, -80036(%rbp)
	jl	.L16
	jmp	.L13
.L24:
	nop
.L13:
	movl	$0, -80028(%rbp)
	movl	$0, -80036(%rbp)
	jmp	.L17
.L18:
	movl	-80036(%rbp), %eax
	cltq
	movl	-80016(%rbp,%rax,8), %edx
	movl	-80036(%rbp), %eax
	cltq
	movl	-80012(%rbp,%rax,8), %eax
	imull	%edx, %eax
	addl	%eax, -80028(%rbp)
	addl	$1, -80036(%rbp)
.L17:
	movl	-80044(%rbp), %eax
	cmpl	%eax, -80036(%rbp)
	jl	.L18
	movl	-80028(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L19
.L23:
	nop
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L21
	call	__stack_chk_fail@PLT
.L21:
	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:
