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 <string.h>

int main(void){
	int i,j,k;
	int n,m,val,a[7],b[7];
	int dp[8][1001];

	while(scanf("%d",&n), n){
		for(i=0;i<n;i++){
			scanf("%d%d",&a[i],&b[i]);
		}

		memset(dp,0,sizeof(dp));
		dp[0][0] = 1;

		for(i=0;i<n;i++){
			for(j=0;j<=1000;j++){
				for(k=0;k<=b[i];k++){
					if(j+a[i]*k>1000) continue;
					dp[i+1][j+a[i]*k] += dp[i][j];
				}
			}
		}

		scanf("%d",&m);
		while(m--){
			scanf("%d",&val);
			printf("%d\n",dp[n][val]);
		}
	}

	return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d%d"
.LC1:
	.string	"%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
	leaq	-28672(%rsp), %r11
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	subq	$3472, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	jmp	.L2
.L15:
	movl	$0, -32124(%rbp)
	jmp	.L3
.L4:
	leaq	-32080(%rbp), %rdx
	movl	-32124(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rax, %rdx
	leaq	-32112(%rbp), %rcx
	movl	-32124(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rcx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -32124(%rbp)
.L3:
	movl	-32136(%rbp), %eax
	cmpl	%eax, -32124(%rbp)
	jl	.L4
	leaq	-32048(%rbp), %rax
	movl	$32032, %edx
	movl	$0, %esi
	movq	%rax, %rdi
	call	memset@PLT
	movl	$1, -32048(%rbp)
	movl	$0, -32124(%rbp)
	jmp	.L5
.L12:
	movl	$0, -32120(%rbp)
	jmp	.L6
.L11:
	movl	$0, -32116(%rbp)
	jmp	.L7
.L10:
	movl	-32124(%rbp), %eax
	cltq
	movl	-32112(%rbp,%rax,4), %eax
	imull	-32116(%rbp), %eax
	movl	%eax, %edx
	movl	-32120(%rbp), %eax
	addl	%edx, %eax
	cmpl	$1000, %eax
	jg	.L18
	movl	-32124(%rbp), %eax
	leal	1(%rax), %edx
	movl	-32124(%rbp), %eax
	cltq
	movl	-32112(%rbp,%rax,4), %eax
	imull	-32116(%rbp), %eax
	movl	%eax, %ecx
	movl	-32120(%rbp), %eax
	addl	%ecx, %eax
	movslq	%eax, %rcx
	movslq	%edx, %rax
	imulq	$1001, %rax, %rax
	addq	%rcx, %rax
	movl	-32048(%rbp,%rax,4), %esi
	movl	-32120(%rbp), %eax
	movslq	%eax, %rdx
	movl	-32124(%rbp), %eax
	cltq
	imulq	$1001, %rax, %rax
	addq	%rdx, %rax
	movl	-32048(%rbp,%rax,4), %edx
	movl	-32124(%rbp), %eax
	leal	1(%rax), %ecx
	movl	-32124(%rbp), %eax
	cltq
	movl	-32112(%rbp,%rax,4), %eax
	imull	-32116(%rbp), %eax
	movl	%eax, %edi
	movl	-32120(%rbp), %eax
	addl	%edi, %eax
	addl	%esi, %edx
	movslq	%eax, %rsi
	movslq	%ecx, %rax
	imulq	$1001, %rax, %rax
	addq	%rsi, %rax
	movl	%edx, -32048(%rbp,%rax,4)
	jmp	.L9
.L18:
	nop
.L9:
	addl	$1, -32116(%rbp)
.L7:
	movl	-32124(%rbp), %eax
	cltq
	movl	-32080(%rbp,%rax,4), %eax
	cmpl	%eax, -32116(%rbp)
	jle	.L10
	addl	$1, -32120(%rbp)
.L6:
	cmpl	$1000, -32120(%rbp)
	jle	.L11
	addl	$1, -32124(%rbp)
.L5:
	movl	-32136(%rbp), %eax
	cmpl	%eax, -32124(%rbp)
	jl	.L12
	leaq	-32132(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	jmp	.L13
.L14:
	leaq	-32128(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-32136(%rbp), %eax
	movl	-32128(%rbp), %edx
	movslq	%edx, %rdx
	cltq
	imulq	$1001, %rax, %rax
	addq	%rdx, %rax
	movl	-32048(%rbp,%rax,4), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L13:
	movl	-32132(%rbp), %eax
	leal	-1(%rax), %edx
	movl	%edx, -32132(%rbp)
	testl	%eax, %eax
	jne	.L14
.L2:
	leaq	-32136(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-32136(%rbp), %eax
	testl	%eax, %eax
	jne	.L15
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L17
	call	__stack_chk_fail@PLT
.L17:
	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"
.LC2:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB35:
	.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	-28672(%rsp), %r11
	.cfi_def_cfa 11, 28728
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	.cfi_def_cfa_register 7
	subq	$3480, %rsp
	.cfi_def_cfa_offset 32208
	movq	%fs:40, %rax
	movq	%rax, 32136(%rsp)
	xorl	%eax, %eax
	leaq	20(%rsp), %rax
	leaq	96(%rsp), %r12
	movq	%rax, (%rsp)
	leaq	64(%rsp), %rbp
.L2:
	movq	(%rsp), %rsi
	leaq	.LC1(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	20(%rsp), %eax
	testl	%eax, %eax
	je	.L12
	jle	.L31
	leaq	32(%rsp), %r14
	movq	%r12, %rbx
	xorl	%r15d, %r15d
	movq	%rbp, %r12
	movq	%r14, %rbp
.L3:
	leaq	(%r12,%r15,4), %rdx
	movq	%rbp, %rsi
	leaq	.LC0(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	20(%rsp), %ecx
	addq	$1, %r15
	movq	%r12, %r13
	addq	$4, %rbp
	cmpl	%r15d, %ecx
	jg	.L3
	movl	$32032, %edx
	xorl	%esi, %esi
	movq	%rbx, %rdi
	movl	%ecx, 12(%rsp)
	call	memset@PLT
	movl	12(%rsp), %ecx
	movq	%r12, %rbp
	movl	$1, 96(%rsp)
	movq	%rbx, %r12
	testl	%ecx, %ecx
	jle	.L15
	leal	-1(%rcx), %eax
	leaq	4100(%rsp), %r11
	leaq	68(%rsp,%rax,4), %r15
.L5:
	movl	0(%r13), %eax
	testl	%eax, %eax
	js	.L8
	movslq	(%r14), %rsi
	movq	%r11, %r9
	xorl	%r10d, %r10d
	leal	1(%rax), %r8d
	movq	%rsi, %rdi
	salq	$2, %rsi
	.p2align 4,,10
	.p2align 3
.L9:
	movl	%r10d, %ecx
	movq	%r9, %rax
	xorl	%edx, %edx
	.p2align 4,,10
	.p2align 3
.L7:
	cmpl	$1000, %ecx
	jg	.L6
	movl	-4004(%r9), %ebx
	addl	%ebx, (%rax)
.L6:
	addl	$1, %edx
	addl	%edi, %ecx
	addq	%rsi, %rax
	cmpl	%edx, %r8d
	jne	.L7
	addl	$1, %r10d
	addq	$4, %r9
	cmpl	$1001, %r10d
	jne	.L9
.L8:
	addq	$4, %r13
	addq	$4004, %r11
	addq	$4, %r14
	cmpq	%r15, %r13
	jne	.L5
.L15:
	leaq	24(%rsp), %rsi
	leaq	.LC1(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	24(%rsp), %eax
	leaq	28(%rsp), %r13
	leal	-1(%rax), %edx
	movl	%edx, 24(%rsp)
	testl	%eax, %eax
	je	.L2
.L10:
	movq	%r13, %rsi
	leaq	.LC1(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movslq	20(%rsp), %rax
	movslq	28(%rsp), %rdx
	leaq	.LC2(%rip), %rsi
	movl	$1, %edi
	imulq	$1001, %rax, %rax
	addq	%rdx, %rax
	movl	96(%rsp,%rax,4), %edx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	24(%rsp), %eax
	leal	-1(%rax), %edx
	movl	%edx, 24(%rsp)
	testl	%eax, %eax
	jne	.L10
	jmp	.L2
.L31:
	movl	$32032, %edx
	xorl	%esi, %esi
	movq	%r12, %rdi
	call	memset@PLT
	movl	$1, 96(%rsp)
	jmp	.L15
.L12:
	movq	32136(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L32
	addq	$32152, %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
.L32:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE35:
	.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"
.LC2:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB35:
	.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	-28672(%rsp), %r11
	.cfi_def_cfa 11, 28728
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	.cfi_def_cfa_register 7
	subq	$3480, %rsp
	.cfi_def_cfa_offset 32208
	movq	%fs:40, %rax
	movq	%rax, 32136(%rsp)
	xorl	%eax, %eax
	leaq	20(%rsp), %rax
	leaq	96(%rsp), %r12
	movq	%rax, (%rsp)
	leaq	64(%rsp), %rbp
.L2:
	movq	(%rsp), %rsi
	leaq	.LC1(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	20(%rsp), %eax
	testl	%eax, %eax
	je	.L12
	jle	.L31
	leaq	32(%rsp), %r14
	movq	%r12, %rbx
	xorl	%r15d, %r15d
	movq	%rbp, %r12
	movq	%r14, %rbp
.L3:
	leaq	(%r12,%r15,4), %rdx
	movq	%rbp, %rsi
	leaq	.LC0(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	20(%rsp), %ecx
	addq	$1, %r15
	movq	%r12, %r13
	addq	$4, %rbp
	cmpl	%r15d, %ecx
	jg	.L3
	movl	$32032, %edx
	xorl	%esi, %esi
	movq	%rbx, %rdi
	movl	%ecx, 12(%rsp)
	call	memset@PLT
	movl	12(%rsp), %ecx
	movq	%r12, %rbp
	movl	$1, 96(%rsp)
	movq	%rbx, %r12
	testl	%ecx, %ecx
	jle	.L15
	leal	-1(%rcx), %eax
	leaq	4100(%rsp), %r11
	leaq	68(%rsp,%rax,4), %r15
.L5:
	movl	0(%r13), %eax
	testl	%eax, %eax
	js	.L8
	movslq	(%r14), %rsi
	movq	%r11, %r9
	xorl	%r10d, %r10d
	leal	1(%rax), %r8d
	movq	%rsi, %rdi
	salq	$2, %rsi
	.p2align 4,,10
	.p2align 3
.L9:
	movl	%r10d, %ecx
	movq	%r9, %rax
	xorl	%edx, %edx
	.p2align 4,,10
	.p2align 3
.L7:
	cmpl	$1000, %ecx
	jg	.L6
	movl	-4004(%r9), %ebx
	addl	%ebx, (%rax)
.L6:
	addl	$1, %edx
	addl	%edi, %ecx
	addq	%rsi, %rax
	cmpl	%edx, %r8d
	jne	.L7
	addl	$1, %r10d
	addq	$4, %r9
	cmpl	$1001, %r10d
	jne	.L9
.L8:
	addq	$4, %r13
	addq	$4004, %r11
	addq	$4, %r14
	cmpq	%r15, %r13
	jne	.L5
.L15:
	leaq	24(%rsp), %rsi
	leaq	.LC1(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	24(%rsp), %eax
	leaq	28(%rsp), %r13
	leal	-1(%rax), %edx
	movl	%edx, 24(%rsp)
	testl	%eax, %eax
	je	.L2
.L10:
	movq	%r13, %rsi
	leaq	.LC1(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movslq	20(%rsp), %rax
	movslq	28(%rsp), %rdx
	leaq	.LC2(%rip), %rsi
	movl	$1, %edi
	imulq	$1001, %rax, %rax
	addq	%rdx, %rax
	movl	96(%rsp,%rax,4), %edx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	24(%rsp), %eax
	leal	-1(%rax), %edx
	movl	%edx, 24(%rsp)
	testl	%eax, %eax
	jne	.L10
	jmp	.L2
.L31:
	movl	$32032, %edx
	xorl	%esi, %esi
	movq	%r12, %rdi
	call	memset@PLT
	movl	$1, 96(%rsp)
	jmp	.L15
.L12:
	movq	32136(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L32
	addq	$32152, %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
.L32:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE35:
	.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 <string.h>

int main(void){
	int i,j,k;
	int n,m,val,a[7],b[7];
	int dp[8][1001];

	while(scanf("%d",&n), n){
		for(i=0;i<n;i++){
			scanf("%d%d",&a[i],&b[i]);
		}

		memset(dp,0,sizeof(dp));
		dp[0][0] = 1;

		for(i=0;i<n;i++){
			for(j=0;j<=1000;j++){
				for(k=0;k<=b[i];k++){
					if(j+a[i]*k>1000) continue;
					dp[i+1][j+a[i]*k] += dp[i][j];
				}
			}
		}

		scanf("%d",&m);
		while(m--){
			scanf("%d",&val);
			printf("%d\n",dp[n][val]);
		}
	}

	return 0;
}
5
1 10
5 3
10 3
25 2
50 2
4
120
500
100
168
7
1 10
3 10
5 10
10 10
25 10
10 10
100 10
3
452
574
787
0
 5
2 10
5 3
10 3
25 2
50 2
4
120
500
100
168
7
1 10
3 10
5 10
10 10
25 10
10 10
100 10
3
452
574
787
0
 5
2 10
5 3
5 3
25 2
50 2
4
120
500
100
168
7
1 10
3 10
5 10
10 10
25 10
10 10
100 10
3
452
574
787
0
 5
2 10
5 3
5 2
25 2
50 2
4
120
500
100
168
7
1 10
3 10
5 10
10 10
25 10
10 10
100 10
3
452
574
787
0
 5
2 10
5 3
5 2
25 2
50 1
4
120
500
100
168
7
1 10
3 10
5 10
10 10
25 10
10 10
100 10
3
452
574
787
0
 5
2 10
5 4
5 2
25 2
50 1
4
120
500
100
168
7
1 10
3 10
5 10
10 10
25 10
10 10
100 10
3
452
574
787
0
 5
2 10
5 4
5 2
25 2
50 1
4
120
500
100
168
7
1 10
3 10
5 10
10 15
25 10
10 10
100 10
3
452
574
787
0
 5
2 10
5 4
5 2
25 2
50 1
4
120
500
100
168
7
1 10
3 10
5 10
17 15
25 10
10 10
100 10
3
452
574
787
0
 5
2 10
5 4
5 2
25 2
50 2
4
120
500
100
168
7
1 10
3 10
5 10
17 15
25 10
10 10
100 10
3
452
574
787
0
 5
2 10
5 4
5 2
25 2
50 2
4
120
500
101
168
7
1 10
3 10
5 10
17 15
25 10
10 10
100 10
3
452
574
787
0

16
0
12
7
17574
17580
17578
 15
0
13
7
17574
17580
17578
 16
0
12
6
17574
17580
17578
 13
0
8
5
17574
17580
17578
 7
0
7
0
17574
17580
17578
 9
0
10
0
17574
17580
17578
 9
0
10
0
25384
25563
25591
 9
0
10
0
23233
25734
25772
 16
0
11
6
23233
25734
25772
 16
0
6
6
23233
25734
25772

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 <string.h>

int main(void){
	int i,j,k;
	int n,m,val,a[7],b[7];
	int dp[8][1001];

	while(scanf("%d",&n), n){
		for(i=0;i<n;i++){
			scanf("%d%d",&a[i],&b[i]);
		}

		memset(dp,0,sizeof(dp));
		dp[0][0] = 1;

		for(i=0;i<n;i++){
			for(j=0;j<=1000;j++){
				for(k=0;k<=b[i];k++){
					if(j+a[i]*k>1000) continue;
					dp[i+1][j+a[i]*k] += dp[i][j];
				}
			}
		}

		scanf("%d",&m);
		while(m--){
			scanf("%d",&val);
			printf("%d\n",dp[n][val]);
		}
	}

	return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d%d"
.LC1:
	.string	"%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
	leaq	-28672(%rsp), %r11
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	subq	$3472, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	jmp	.L2
.L15:
	movl	$0, -32124(%rbp)
	jmp	.L3
.L4:
	leaq	-32080(%rbp), %rdx
	movl	-32124(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rax, %rdx
	leaq	-32112(%rbp), %rcx
	movl	-32124(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rcx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -32124(%rbp)
.L3:
	movl	-32136(%rbp), %eax
	cmpl	%eax, -32124(%rbp)
	jl	.L4
	leaq	-32048(%rbp), %rax
	movl	$32032, %edx
	movl	$0, %esi
	movq	%rax, %rdi
	call	memset@PLT
	movl	$1, -32048(%rbp)
	movl	$0, -32124(%rbp)
	jmp	.L5
.L12:
	movl	$0, -32120(%rbp)
	jmp	.L6
.L11:
	movl	$0, -32116(%rbp)
	jmp	.L7
.L10:
	movl	-32124(%rbp), %eax
	cltq
	movl	-32112(%rbp,%rax,4), %eax
	imull	-32116(%rbp), %eax
	movl	%eax, %edx
	movl	-32120(%rbp), %eax
	addl	%edx, %eax
	cmpl	$1000, %eax
	jg	.L18
	movl	-32124(%rbp), %eax
	leal	1(%rax), %edx
	movl	-32124(%rbp), %eax
	cltq
	movl	-32112(%rbp,%rax,4), %eax
	imull	-32116(%rbp), %eax
	movl	%eax, %ecx
	movl	-32120(%rbp), %eax
	addl	%ecx, %eax
	movslq	%eax, %rcx
	movslq	%edx, %rax
	imulq	$1001, %rax, %rax
	addq	%rcx, %rax
	movl	-32048(%rbp,%rax,4), %esi
	movl	-32120(%rbp), %eax
	movslq	%eax, %rdx
	movl	-32124(%rbp), %eax
	cltq
	imulq	$1001, %rax, %rax
	addq	%rdx, %rax
	movl	-32048(%rbp,%rax,4), %edx
	movl	-32124(%rbp), %eax
	leal	1(%rax), %ecx
	movl	-32124(%rbp), %eax
	cltq
	movl	-32112(%rbp,%rax,4), %eax
	imull	-32116(%rbp), %eax
	movl	%eax, %edi
	movl	-32120(%rbp), %eax
	addl	%edi, %eax
	addl	%esi, %edx
	movslq	%eax, %rsi
	movslq	%ecx, %rax
	imulq	$1001, %rax, %rax
	addq	%rsi, %rax
	movl	%edx, -32048(%rbp,%rax,4)
	jmp	.L9
.L18:
	nop
.L9:
	addl	$1, -32116(%rbp)
.L7:
	movl	-32124(%rbp), %eax
	cltq
	movl	-32080(%rbp,%rax,4), %eax
	cmpl	%eax, -32116(%rbp)
	jle	.L10
	addl	$1, -32120(%rbp)
.L6:
	cmpl	$1000, -32120(%rbp)
	jle	.L11
	addl	$1, -32124(%rbp)
.L5:
	movl	-32136(%rbp), %eax
	cmpl	%eax, -32124(%rbp)
	jl	.L12
	leaq	-32132(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	jmp	.L13
.L14:
	leaq	-32128(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-32136(%rbp), %eax
	movl	-32128(%rbp), %edx
	movslq	%edx, %rdx
	cltq
	imulq	$1001, %rax, %rax
	addq	%rdx, %rax
	movl	-32048(%rbp,%rax,4), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L13:
	movl	-32132(%rbp), %eax
	leal	-1(%rax), %edx
	movl	%edx, -32132(%rbp)
	testl	%eax, %eax
	jne	.L14
.L2:
	leaq	-32136(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-32136(%rbp), %eax
	testl	%eax, %eax
	jne	.L15
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L17
	call	__stack_chk_fail@PLT
.L17:
	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"
.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
	leaq	-28672(%rsp), %r11
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	subq	$3472, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	jmp	.L2
.L15:
	movl	$0, -32124(%rbp)
	jmp	.L3
.L4:
	leaq	-32080(%rbp), %rdx
	movl	-32124(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rax, %rdx
	leaq	-32112(%rbp), %rcx
	movl	-32124(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rcx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -32124(%rbp)
.L3:
	movl	-32136(%rbp), %eax
	cmpl	%eax, -32124(%rbp)
	jl	.L4
	leaq	-32048(%rbp), %rax
	movl	$32032, %edx
	movl	$0, %esi
	movq	%rax, %rdi
	call	memset@PLT
	movl	$1, -32048(%rbp)
	movl	$0, -32124(%rbp)
	jmp	.L5
.L12:
	movl	$0, -32120(%rbp)
	jmp	.L6
.L11:
	movl	$0, -32116(%rbp)
	jmp	.L7
.L10:
	movl	-32124(%rbp), %eax
	cltq
	movl	-32112(%rbp,%rax,4), %eax
	imull	-32116(%rbp), %eax
	movl	%eax, %edx
	movl	-32120(%rbp), %eax
	addl	%edx, %eax
	cmpl	$1000, %eax
	jg	.L18
	movl	-32124(%rbp), %eax
	leal	1(%rax), %edx
	movl	-32124(%rbp), %eax
	cltq
	movl	-32112(%rbp,%rax,4), %eax
	imull	-32116(%rbp), %eax
	movl	%eax, %ecx
	movl	-32120(%rbp), %eax
	addl	%ecx, %eax
	movslq	%eax, %rcx
	movslq	%edx, %rax
	imulq	$1001, %rax, %rax
	addq	%rcx, %rax
	movl	-32048(%rbp,%rax,4), %esi
	movl	-32120(%rbp), %eax
	movslq	%eax, %rdx
	movl	-32124(%rbp), %eax
	cltq
	imulq	$1001, %rax, %rax
	addq	%rdx, %rax
	movl	-32048(%rbp,%rax,4), %edx
	movl	-32124(%rbp), %eax
	leal	1(%rax), %ecx
	movl	-32124(%rbp), %eax
	cltq
	movl	-32112(%rbp,%rax,4), %eax
	imull	-32116(%rbp), %eax
	movl	%eax, %edi
	movl	-32120(%rbp), %eax
	addl	%edi, %eax
	addl	%esi, %edx
	movslq	%eax, %rsi
	movslq	%ecx, %rax
	imulq	$1001, %rax, %rax
	addq	%rsi, %rax
	movl	%edx, -32048(%rbp,%rax,4)
	jmp	.L9
.L18:
	nop
.L9:
	addl	$1, -32116(%rbp)
.L7:
	movl	-32124(%rbp), %eax
	cltq
	movl	-32080(%rbp,%rax,4), %eax
	cmpl	%eax, -32116(%rbp)
	jle	.L10
	addl	$1, -32120(%rbp)
.L6:
	cmpl	$1000, -32120(%rbp)
	jle	.L11
	addl	$1, -32124(%rbp)
.L5:
	movl	-32136(%rbp), %eax
	cmpl	%eax, -32124(%rbp)
	jl	.L12
	leaq	-32132(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	jmp	.L13
.L14:
	leaq	-32128(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-32136(%rbp), %eax
	movl	-32128(%rbp), %edx
	movslq	%edx, %rdx
	cltq
	imulq	$1001, %rax, %rax
	addq	%rdx, %rax
	movl	-32048(%rbp,%rax,4), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L13:
	movl	-32132(%rbp), %eax
	leal	-1(%rax), %edx
	movl	%edx, -32132(%rbp)
	testl	%eax, %eax
	jne	.L14
.L2:
	leaq	-32136(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-32136(%rbp), %eax
	testl	%eax, %eax
	jne	.L15
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L17
	call	__stack_chk_fail@PLT
.L17:
	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:
