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>
int main(void){
	int n,m,i,sum,ans;
	int	masu[1000],sai;

	while(1){
		sum=ans=0;
		scanf("%d%d",&n,&m);
		if(n==0&&m==0) break;
		for(i=0;i<n;i++){
			scanf("%d",&masu[i]);
		}
		for(i=0;i<m;i++){
			scanf("%d",&sai);
			if(sum<n){
				sum+=sai+masu[sum+sai];
				ans++;
			}
		}
		printf("%d\n",ans);
	}
	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
	subq	$4048, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
.L9:
	movl	$0, -4020(%rbp)
	movl	-4020(%rbp), %eax
	movl	%eax, -4024(%rbp)
	leaq	-4036(%rbp), %rdx
	leaq	-4040(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-4040(%rbp), %eax
	testl	%eax, %eax
	jne	.L2
	movl	-4036(%rbp), %eax
	testl	%eax, %eax
	je	.L13
.L2:
	movl	$0, -4028(%rbp)
	jmp	.L4
.L5:
	leaq	-4016(%rbp), %rdx
	movl	-4028(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -4028(%rbp)
.L4:
	movl	-4040(%rbp), %eax
	cmpl	%eax, -4028(%rbp)
	jl	.L5
	movl	$0, -4028(%rbp)
	jmp	.L6
.L8:
	leaq	-4032(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-4040(%rbp), %eax
	cmpl	%eax, -4024(%rbp)
	jge	.L7
	movl	-4032(%rbp), %edx
	movl	-4024(%rbp), %eax
	addl	%edx, %eax
	cltq
	movl	-4016(%rbp,%rax,4), %edx
	movl	-4032(%rbp), %eax
	addl	%edx, %eax
	addl	%eax, -4024(%rbp)
	addl	$1, -4020(%rbp)
.L7:
	addl	$1, -4028(%rbp)
.L6:
	movl	-4036(%rbp), %eax
	cmpl	%eax, -4028(%rbp)
	jl	.L8
	movl	-4020(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L9
.L13:
	nop
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L11
	call	__stack_chk_fail@PLT
.L11:
	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:
.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	.LC1(%rip), %rbx
	subq	$4056, %rsp
	.cfi_def_cfa_offset 4112
	movq	%fs:40, %rax
	movq	%rax, 4040(%rsp)
	xorl	%eax, %eax
	leaq	20(%rsp), %rax
	leaq	24(%rsp), %r15
	movq	%rax, 8(%rsp)
	leaq	28(%rsp), %rbp
	.p2align 4,,10
	.p2align 3
.L11:
	movq	8(%rsp), %rsi
	movq	%r15, %rdx
	leaq	.LC0(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	20(%rsp), %eax
	testl	%eax, %eax
	jne	.L19
	movl	24(%rsp), %eax
	testl	%eax, %eax
	je	.L20
.L6:
	xorl	%r12d, %r12d
	testl	%eax, %eax
	jle	.L8
	xorl	%r14d, %r14d
	xorl	%r13d, %r13d
	.p2align 4,,10
	.p2align 3
.L10:
	xorl	%eax, %eax
	movq	%rbp, %rsi
	movq	%rbx, %rdi
	call	__isoc99_scanf@PLT
	cmpl	%r14d, 20(%rsp)
	jle	.L9
	movl	28(%rsp), %eax
	addl	$1, %r12d
	leal	(%rax,%r14), %esi
	movslq	%esi, %rsi
	addl	32(%rsp,%rsi,4), %eax
	addl	%eax, %r14d
.L9:
	addl	$1, %r13d
	cmpl	%r13d, 24(%rsp)
	jg	.L10
.L8:
	movl	%r12d, %edx
	leaq	.LC2(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L11
	.p2align 4,,10
	.p2align 3
.L19:
	jle	.L16
	leaq	32(%rsp), %r13
	xorl	%r12d, %r12d
	.p2align 4,,10
	.p2align 3
.L7:
	movq	%r13, %rsi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	addl	$1, %r12d
	call	__isoc99_scanf@PLT
	addq	$4, %r13
	cmpl	%r12d, 20(%rsp)
	jg	.L7
.L16:
	movl	24(%rsp), %eax
	jmp	.L6
.L20:
	movq	4040(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L21
	addq	$4056, %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
.L21:
	.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"
.LC2:
	.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	.LC1(%rip), %rbx
	subq	$4056, %rsp
	.cfi_def_cfa_offset 4112
	movq	%fs:40, %rax
	movq	%rax, 4040(%rsp)
	xorl	%eax, %eax
	leaq	20(%rsp), %rax
	leaq	24(%rsp), %r15
	movq	%rax, 8(%rsp)
	leaq	28(%rsp), %rbp
	.p2align 4,,10
	.p2align 3
.L11:
	movq	8(%rsp), %rsi
	movq	%r15, %rdx
	leaq	.LC0(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	20(%rsp), %eax
	testl	%eax, %eax
	jne	.L19
	movl	24(%rsp), %eax
	testl	%eax, %eax
	je	.L20
.L6:
	xorl	%r12d, %r12d
	testl	%eax, %eax
	jle	.L8
	xorl	%r14d, %r14d
	xorl	%r13d, %r13d
	.p2align 4,,10
	.p2align 3
.L10:
	xorl	%eax, %eax
	movq	%rbp, %rsi
	movq	%rbx, %rdi
	call	__isoc99_scanf@PLT
	cmpl	%r14d, 20(%rsp)
	jle	.L9
	movl	28(%rsp), %eax
	addl	$1, %r12d
	leal	(%rax,%r14), %esi
	movslq	%esi, %rsi
	addl	32(%rsp,%rsi,4), %eax
	addl	%eax, %r14d
.L9:
	addl	$1, %r13d
	cmpl	%r13d, 24(%rsp)
	jg	.L10
.L8:
	movl	%r12d, %edx
	leaq	.LC2(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L11
	.p2align 4,,10
	.p2align 3
.L19:
	jle	.L16
	leaq	32(%rsp), %r13
	xorl	%r12d, %r12d
	.p2align 4,,10
	.p2align 3
.L7:
	movq	%r13, %rsi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	addl	$1, %r12d
	call	__isoc99_scanf@PLT
	addq	$4, %r13
	cmpl	%r12d, 20(%rsp)
	jg	.L7
.L16:
	movl	24(%rsp), %eax
	jmp	.L6
.L20:
	movq	4040(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L21
	addq	$4056, %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
.L21:
	.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>
int main(void){
	int n,m,i,sum,ans;
	int	masu[1000],sai;

	while(1){
		sum=ans=0;
		scanf("%d%d",&n,&m);
		if(n==0&&m==0) break;
		for(i=0;i<n;i++){
			scanf("%d",&masu[i]);
		}
		for(i=0;i<m;i++){
			scanf("%d",&sai);
			if(sum<n){
				sum+=sai+masu[sum+sai];
				ans++;
			}
		}
		printf("%d\n",ans);
	}
	return 0;
}
10 5
0
0
5
6
-3
8
1
8
-4
0
1
3
5
1
5
10 10
0
-1
-1
4
4
-5
0
1
-6
0
1
5
2
5
6
5
5
4
1
6
0 0
 10 5
0
0
5
6
-2
8
1
8
-4
0
1
3
5
1
5
10 10
0
-1
-1
4
4
-5
0
1
-6
0
2
5
2
4
6
5
5
4
1
6
0 0
 10 5
0
1
5
6
-2
8
1
8
-4
0
1
3
5
1
5
10 10
0
-1
-1
4
4
-5
0
1
-6
0
2
5
2
4
6
5
5
4
1
6
0 0
 10 5
0
0
5
6
-3
8
2
8
-4
0
1
3
5
1
5
10 10
0
-1
-1
4
4
-5
0
1
-6
0
1
5
2
4
6
5
5
4
1
6
0 0
 10 5
0
1
5
6
-2
8
1
8
-4
0
1
3
5
1
5
10 10
0
-1
-1
4
4
-5
0
1
-6
0
3
5
2
4
6
5
5
4
1
6
0 0
 10 5
0
1
5
6
-2
8
1
8
-4
0
1
3
5
1
5
10 10
0
-1
0
4
4
-5
0
1
-6
0
2
5
2
5
6
5
5
4
1
6
0 0
 10 5
0
1
5
6
-2
7
1
8
-5
0
2
1
6
1
5
10 10
0
-1
-1
3
4
-5
0
1
-10
0
2
5
2
5
2
5
3
4
3
6
0 0
 10 5
0
0
5
6
-3
8
1
8
-4
0
2
3
5
1
5
10 10
0
-1
-1
4
4
-5
0
1
-6
0
1
5
1
5
6
5
5
4
1
6
0 0
 10 5
0
2
5
6
-2
8
1
8
-4
0
1
3
5
1
5
10 10
0
-1
0
4
4
-5
0
1
-6
0
2
5
2
5
6
5
5
4
1
6
0 0
 10 5
0
1
5
6
-2
8
1
8
-5
0
2
1
5
1
5
10 10
0
-1
-1
4
4
-5
0
1
-6
0
4
5
2
5
6
5
3
4
3
6
0 0

5
5
 3
5
 2
5
 5
6
 2
2
 2
3
 4
8
 2
6
 3
3
 5
2

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>
int main(void){
	int n,m,i,sum,ans;
	int	masu[1000],sai;

	while(1){
		sum=ans=0;
		scanf("%d%d",&n,&m);
		if(n==0&&m==0) break;
		for(i=0;i<n;i++){
			scanf("%d",&masu[i]);
		}
		for(i=0;i<m;i++){
			scanf("%d",&sai);
			if(sum<n){
				sum+=sai+masu[sum+sai];
				ans++;
			}
		}
		printf("%d\n",ans);
	}
	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
	subq	$4048, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
.L9:
	movl	$0, -4020(%rbp)
	movl	-4020(%rbp), %eax
	movl	%eax, -4024(%rbp)
	leaq	-4036(%rbp), %rdx
	leaq	-4040(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-4040(%rbp), %eax
	testl	%eax, %eax
	jne	.L2
	movl	-4036(%rbp), %eax
	testl	%eax, %eax
	je	.L13
.L2:
	movl	$0, -4028(%rbp)
	jmp	.L4
.L5:
	leaq	-4016(%rbp), %rdx
	movl	-4028(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -4028(%rbp)
.L4:
	movl	-4040(%rbp), %eax
	cmpl	%eax, -4028(%rbp)
	jl	.L5
	movl	$0, -4028(%rbp)
	jmp	.L6
.L8:
	leaq	-4032(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-4040(%rbp), %eax
	cmpl	%eax, -4024(%rbp)
	jge	.L7
	movl	-4032(%rbp), %edx
	movl	-4024(%rbp), %eax
	addl	%edx, %eax
	cltq
	movl	-4016(%rbp,%rax,4), %edx
	movl	-4032(%rbp), %eax
	addl	%edx, %eax
	addl	%eax, -4024(%rbp)
	addl	$1, -4020(%rbp)
.L7:
	addl	$1, -4028(%rbp)
.L6:
	movl	-4036(%rbp), %eax
	cmpl	%eax, -4028(%rbp)
	jl	.L8
	movl	-4020(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L9
.L13:
	nop
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L11
	call	__stack_chk_fail@PLT
.L11:
	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
	subq	$4048, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
.L9:
	movl	$0, -4020(%rbp)
	movl	-4020(%rbp), %eax
	movl	%eax, -4024(%rbp)
	leaq	-4036(%rbp), %rdx
	leaq	-4040(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-4040(%rbp), %eax
	testl	%eax, %eax
	jne	.L2
	movl	-4036(%rbp), %eax
	testl	%eax, %eax
	je	.L13
.L2:
	movl	$0, -4028(%rbp)
	jmp	.L4
.L5:
	leaq	-4016(%rbp), %rdx
	movl	-4028(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -4028(%rbp)
.L4:
	movl	-4040(%rbp), %eax
	cmpl	%eax, -4028(%rbp)
	jl	.L5
	movl	$0, -4028(%rbp)
	jmp	.L6
.L8:
	leaq	-4032(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-4040(%rbp), %eax
	cmpl	%eax, -4024(%rbp)
	jge	.L7
	movl	-4032(%rbp), %edx
	movl	-4024(%rbp), %eax
	addl	%edx, %eax
	cltq
	movl	-4016(%rbp,%rax,4), %edx
	movl	-4032(%rbp), %eax
	addl	%edx, %eax
	addl	%eax, -4024(%rbp)
	addl	$1, -4020(%rbp)
.L7:
	addl	$1, -4028(%rbp)
.L6:
	movl	-4036(%rbp), %eax
	cmpl	%eax, -4028(%rbp)
	jl	.L8
	movl	-4020(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L9
.L13:
	nop
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L11
	call	__stack_chk_fail@PLT
.L11:
	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:
