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>

long long int p_array[5001];
long long int c_array[5001];


int main()
{
	long long int score = -1000000001, n, k;
	long long int current_score;

	scanf("%lld %lld", &n, &k);

	for (int i = 1; i <= n; i++)
	{
		scanf("%lld", &p_array[i]);
	}

	for (int i = 1; i <= n; i++)
	{
		scanf("%lld", &c_array[i]);
	}

	for (int i = 1; i <= n; i++)
	{
		int first_step = i;
		int next_step = p_array[first_step];
		long long int step_num = 0;
		current_score = 0;

		while ((first_step != next_step) && (step_num < k))
		{
			current_score += c_array[next_step];
			step_num++;

			next_step = p_array[next_step];

			if (score < current_score)
			{
				score = current_score;
			}

			if ((first_step == next_step) && (step_num < k))
			{
				current_score += c_array[next_step];
				step_num++;
			}


			if (score < current_score)
			{
				score = current_score;
			}
		}


		if ((current_score > 0) && (step_num < k))
		{
			long long int round_scoure = 0;
			round_scoure = ((k - step_num) / step_num)*current_score;

			first_step = i;
			next_step = p_array[first_step];;

			for (long long int j = 0; j<((k%step_num) + step_num); j++)
			{
				round_scoure += c_array[next_step];
				next_step = p_array[next_step];

				if (round_scoure > score)
				{
					score = round_scoure;
				}
			}

		}

	}


	printf("%lld", score);

	return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	p_array
	.bss
	.align 32
	.type	p_array, @object
	.size	p_array, 40008
p_array:
	.zero	40008
	.globl	c_array
	.align 32
	.type	c_array, @object
	.size	c_array, 40008
c_array:
	.zero	40008
	.section	.rodata
.LC0:
	.string	"%lld %lld"
.LC1:
	.string	"%lld"
	.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	$96, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movq	$-1000000001, -48(%rbp)
	leaq	-56(%rbp), %rdx
	leaq	-64(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$1, -84(%rbp)
	jmp	.L2
.L3:
	movl	-84(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	p_array(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -84(%rbp)
.L2:
	movl	-84(%rbp), %eax
	movslq	%eax, %rdx
	movq	-64(%rbp), %rax
	cmpq	%rax, %rdx
	jle	.L3
	movl	$1, -80(%rbp)
	jmp	.L4
.L5:
	movl	-80(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	c_array(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -80(%rbp)
.L4:
	movl	-80(%rbp), %eax
	movslq	%eax, %rdx
	movq	-64(%rbp), %rax
	cmpq	%rax, %rdx
	jle	.L5
	movl	$1, -76(%rbp)
	jmp	.L6
.L16:
	movl	-76(%rbp), %eax
	movl	%eax, -68(%rbp)
	movl	-68(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	p_array(%rip), %rax
	movq	(%rdx,%rax), %rax
	movl	%eax, -72(%rbp)
	movq	$0, -32(%rbp)
	movq	$0, -40(%rbp)
	jmp	.L7
.L11:
	movl	-72(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	c_array(%rip), %rax
	movq	(%rdx,%rax), %rax
	addq	%rax, -40(%rbp)
	addq	$1, -32(%rbp)
	movl	-72(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	p_array(%rip), %rax
	movq	(%rdx,%rax), %rax
	movl	%eax, -72(%rbp)
	movq	-48(%rbp), %rax
	cmpq	-40(%rbp), %rax
	jge	.L8
	movq	-40(%rbp), %rax
	movq	%rax, -48(%rbp)
.L8:
	movl	-68(%rbp), %eax
	cmpl	-72(%rbp), %eax
	jne	.L9
	movq	-56(%rbp), %rax
	cmpq	%rax, -32(%rbp)
	jge	.L9
	movl	-72(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	c_array(%rip), %rax
	movq	(%rdx,%rax), %rax
	addq	%rax, -40(%rbp)
	addq	$1, -32(%rbp)
.L9:
	movq	-48(%rbp), %rax
	cmpq	-40(%rbp), %rax
	jge	.L7
	movq	-40(%rbp), %rax
	movq	%rax, -48(%rbp)
.L7:
	movl	-68(%rbp), %eax
	cmpl	-72(%rbp), %eax
	je	.L10
	movq	-56(%rbp), %rax
	cmpq	%rax, -32(%rbp)
	jl	.L11
.L10:
	cmpq	$0, -40(%rbp)
	jle	.L12
	movq	-56(%rbp), %rax
	cmpq	%rax, -32(%rbp)
	jge	.L12
	movq	$0, -24(%rbp)
	movq	-56(%rbp), %rax
	subq	-32(%rbp), %rax
	cqto
	idivq	-32(%rbp)
	movq	%rax, %rdx
	movq	-40(%rbp), %rax
	imulq	%rdx, %rax
	movq	%rax, -24(%rbp)
	movl	-76(%rbp), %eax
	movl	%eax, -68(%rbp)
	movl	-68(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	p_array(%rip), %rax
	movq	(%rdx,%rax), %rax
	movl	%eax, -72(%rbp)
	movq	$0, -16(%rbp)
	jmp	.L13
.L15:
	movl	-72(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	c_array(%rip), %rax
	movq	(%rdx,%rax), %rax
	addq	%rax, -24(%rbp)
	movl	-72(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	p_array(%rip), %rax
	movq	(%rdx,%rax), %rax
	movl	%eax, -72(%rbp)
	movq	-24(%rbp), %rax
	cmpq	-48(%rbp), %rax
	jle	.L14
	movq	-24(%rbp), %rax
	movq	%rax, -48(%rbp)
.L14:
	addq	$1, -16(%rbp)
.L13:
	movq	-56(%rbp), %rax
	cqto
	idivq	-32(%rbp)
	movq	-32(%rbp), %rax
	addq	%rdx, %rax
	cmpq	%rax, -16(%rbp)
	jl	.L15
.L12:
	addl	$1, -76(%rbp)
.L6:
	movl	-76(%rbp), %eax
	movslq	%eax, %rdx
	movq	-64(%rbp), %rax
	cmpq	%rax, %rdx
	jle	.L16
	movq	-48(%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	.L18
	call	__stack_chk_fail@PLT
.L18:
	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	"%lld %lld"
.LC1:
	.string	"%lld"
	.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
	leaq	.LC0(%rip), %rdi
	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
	leaq	.LC1(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$40, %rsp
	.cfi_def_cfa_offset 96
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	leaq	16(%rsp), %rdx
	leaq	8(%rsp), %rsi
	call	__isoc99_scanf@PLT
	cmpq	$0, 8(%rsp)
	jle	.L5
	leaq	8+p_array(%rip), %rbp
	xorl	%ebx, %ebx
	leaq	.LC1(%rip), %r12
	.p2align 4,,10
	.p2align 3
.L3:
	movq	%rbp, %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	addq	$8, %rbp
	call	__isoc99_scanf@PLT
	movq	%rbx, %rax
	movq	8(%rsp), %rdx
	addq	$1, %rbx
	addq	$2, %rax
	cmpq	%rax, %rdx
	jge	.L3
	testq	%rdx, %rdx
	jle	.L5
	leaq	8+c_array(%rip), %rbp
	xorl	%ebx, %ebx
	.p2align 4,,10
	.p2align 3
.L4:
	movq	%rbp, %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	addq	$8, %rbp
	call	__isoc99_scanf@PLT
	movq	%rbx, %rax
	movq	8(%rsp), %r13
	addq	$1, %rbx
	addq	$2, %rax
	cmpq	%rax, %r13
	jge	.L4
	testq	%r13, %r13
	jle	.L5
	movq	16(%rsp), %r9
	movl	$1, %ebp
	movq	$-1000000001, %r8
	leaq	p_array(%rip), %r11
	leaq	c_array(%rip), %r10
	.p2align 4,,10
	.p2align 3
.L12:
	movq	(%r11,%rbp,8), %rdx
	movl	%ebp, %r15d
	xorl	%r14d, %r14d
	xorl	%ecx, %ecx
	movslq	%edx, %rbx
	movslq	%edx, %rax
	cmpl	%ebp, %edx
	jne	.L6
	jmp	.L7
	.p2align 4,,10
	.p2align 3
.L8:
	cmpq	%rdx, %r8
	cmovl	%rdx, %r8
	cmpl	%r15d, %esi
	je	.L9
	movq	%rdi, %r14
.L6:
	cmpq	%r14, %r9
	jle	.L7
	movq	(%r10,%rax,8), %rdx
	movq	(%r11,%rax,8), %rsi
	leaq	1(%r14), %rdi
	addq	%rcx, %rdx
	movslq	%esi, %rax
	cmpq	%r8, %rdx
	movq	%rdx, %rcx
	cmovge	%rdx, %r8
	cmpq	%rdi, %r9
	jle	.L8
	cmpl	%esi, %r15d
	jne	.L8
	addq	(%r10,%rax,8), %rcx
	leaq	2(%r14), %rdi
	cmpq	%rcx, %r8
	cmovl	%rcx, %r8
.L9:
	testq	%rcx, %rcx
	jle	.L7
	cmpq	%rdi, %r9
	jle	.L7
	movq	%r9, %rax
	subq	%rdi, %rax
	cqto
	idivq	%rdi
	imulq	%rax, %rcx
	movq	%r9, %rax
	cqto
	idivq	%rdi
	xorl	%eax, %eax
	addq	%rdi, %rdx
	.p2align 4,,10
	.p2align 3
.L11:
	addq	(%r10,%rbx,8), %rcx
	movslq	(%r11,%rbx,8), %rbx
	cmpq	%rcx, %r8
	cmovl	%rcx, %r8
	addq	$1, %rax
	cmpq	%rdx, %rax
	jne	.L11
	.p2align 4,,10
	.p2align 3
.L7:
	leaq	1(%rbp), %rax
	cmpq	%rbp, %r13
	je	.L13
	movq	%rax, %rbp
	jmp	.L12
.L5:
	movq	$-1000000001, %r8
	.p2align 4,,10
	.p2align 3
.L13:
	xorl	%eax, %eax
	movq	%r8, %rdx
	movq	%r12, %rsi
	movl	$1, %edi
	call	__printf_chk@PLT
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L32
	addq	$40, %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
	.globl	c_array
	.bss
	.align 32
	.type	c_array, @object
	.size	c_array, 40008
c_array:
	.zero	40008
	.globl	p_array
	.align 32
	.type	p_array, @object
	.size	p_array, 40008
p_array:
	.zero	40008
	.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	"%lld %lld"
.LC1:
	.string	"%lld"
	.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
	leaq	.LC0(%rip), %rdi
	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
	leaq	.LC1(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$40, %rsp
	.cfi_def_cfa_offset 96
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	leaq	16(%rsp), %rdx
	leaq	8(%rsp), %rsi
	call	__isoc99_scanf@PLT
	cmpq	$0, 8(%rsp)
	jle	.L5
	leaq	8+p_array(%rip), %rbp
	xorl	%ebx, %ebx
	leaq	.LC1(%rip), %r12
	.p2align 4,,10
	.p2align 3
.L3:
	movq	%rbp, %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	addq	$8, %rbp
	call	__isoc99_scanf@PLT
	movq	%rbx, %rax
	movq	8(%rsp), %rdx
	addq	$1, %rbx
	addq	$2, %rax
	cmpq	%rax, %rdx
	jge	.L3
	testq	%rdx, %rdx
	jle	.L5
	leaq	8+c_array(%rip), %rbp
	xorl	%ebx, %ebx
	.p2align 4,,10
	.p2align 3
.L4:
	movq	%rbp, %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	addq	$8, %rbp
	call	__isoc99_scanf@PLT
	movq	%rbx, %rax
	movq	8(%rsp), %r13
	addq	$1, %rbx
	addq	$2, %rax
	cmpq	%rax, %r13
	jge	.L4
	testq	%r13, %r13
	jle	.L5
	movq	16(%rsp), %r9
	movl	$1, %ebp
	movq	$-1000000001, %r8
	leaq	p_array(%rip), %r11
	leaq	c_array(%rip), %r10
	.p2align 4,,10
	.p2align 3
.L12:
	movq	(%r11,%rbp,8), %rdx
	movl	%ebp, %r15d
	xorl	%r14d, %r14d
	xorl	%ecx, %ecx
	movslq	%edx, %rbx
	movslq	%edx, %rax
	cmpl	%ebp, %edx
	jne	.L6
	jmp	.L7
	.p2align 4,,10
	.p2align 3
.L8:
	cmpq	%rdx, %r8
	cmovl	%rdx, %r8
	cmpl	%r15d, %esi
	je	.L9
	movq	%rdi, %r14
.L6:
	cmpq	%r14, %r9
	jle	.L7
	movq	(%r10,%rax,8), %rdx
	movq	(%r11,%rax,8), %rsi
	leaq	1(%r14), %rdi
	addq	%rcx, %rdx
	movslq	%esi, %rax
	cmpq	%r8, %rdx
	movq	%rdx, %rcx
	cmovge	%rdx, %r8
	cmpq	%rdi, %r9
	jle	.L8
	cmpl	%esi, %r15d
	jne	.L8
	addq	(%r10,%rax,8), %rcx
	leaq	2(%r14), %rdi
	cmpq	%rcx, %r8
	cmovl	%rcx, %r8
.L9:
	testq	%rcx, %rcx
	jle	.L7
	cmpq	%rdi, %r9
	jle	.L7
	movq	%r9, %rax
	subq	%rdi, %rax
	cqto
	idivq	%rdi
	imulq	%rax, %rcx
	movq	%r9, %rax
	cqto
	idivq	%rdi
	xorl	%eax, %eax
	addq	%rdi, %rdx
	.p2align 4,,10
	.p2align 3
.L11:
	addq	(%r10,%rbx,8), %rcx
	movslq	(%r11,%rbx,8), %rbx
	cmpq	%rcx, %r8
	cmovl	%rcx, %r8
	addq	$1, %rax
	cmpq	%rdx, %rax
	jne	.L11
	.p2align 4,,10
	.p2align 3
.L7:
	leaq	1(%rbp), %rax
	cmpq	%rbp, %r13
	je	.L13
	movq	%rax, %rbp
	jmp	.L12
.L5:
	movq	$-1000000001, %r8
	.p2align 4,,10
	.p2align 3
.L13:
	xorl	%eax, %eax
	movq	%r8, %rdx
	movq	%r12, %rsi
	movl	$1, %edi
	call	__printf_chk@PLT
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L32
	addq	$40, %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
	.globl	c_array
	.bss
	.align 32
	.type	c_array, @object
	.size	c_array, 40008
c_array:
	.zero	40008
	.globl	p_array
	.align 32
	.type	p_array, @object
	.size	p_array, 40008
p_array:
	.zero	40008
	.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>

long long int p_array[5001];
long long int c_array[5001];


int main()
{
	long long int score = -1000000001, n, k;
	long long int current_score;

	scanf("%lld %lld", &n, &k);

	for (int i = 1; i <= n; i++)
	{
		scanf("%lld", &p_array[i]);
	}

	for (int i = 1; i <= n; i++)
	{
		scanf("%lld", &c_array[i]);
	}

	for (int i = 1; i <= n; i++)
	{
		int first_step = i;
		int next_step = p_array[first_step];
		long long int step_num = 0;
		current_score = 0;

		while ((first_step != next_step) && (step_num < k))
		{
			current_score += c_array[next_step];
			step_num++;

			next_step = p_array[next_step];

			if (score < current_score)
			{
				score = current_score;
			}

			if ((first_step == next_step) && (step_num < k))
			{
				current_score += c_array[next_step];
				step_num++;
			}


			if (score < current_score)
			{
				score = current_score;
			}
		}


		if ((current_score > 0) && (step_num < k))
		{
			long long int round_scoure = 0;
			round_scoure = ((k - step_num) / step_num)*current_score;

			first_step = i;
			next_step = p_array[first_step];;

			for (long long int j = 0; j<((k%step_num) + step_num); j++)
			{
				round_scoure += c_array[next_step];
				next_step = p_array[next_step];

				if (round_scoure > score)
				{
					score = round_scoure;
				}
			}

		}

	}


	printf("%lld", score);

	return 0;
}
10 58
9 1 6 7 8 4 3 2 10 5
695279662 988782657 -119067776 382975538 -151885171 -243968758 -169777795 37619092 389386780 980092719
 10 58
9 1 6 7 8 4 3 2 10 5
1020768626 988782657 -119067776 382975538 -151885171 -177220596 -169777795 37619092 389386780 980092719
 3 3
3 1 2
-1000 -2000 -3052
 10 58
9 1 6 7 8 4 3 2 10 5
695279662 903489508 -119067776 382975538 -151885171 -243968758 -169777795 37619092 389386780 980092719
 10 58
9 1 6 7 8 4 3 2 10 5
97711577 988782657 -119067776 382975538 -151885171 -269784707 -169777795 37619092 389386780 980092719
 10 58
9 1 6 7 8 4 3 2 10 5
1020768626 988782657 -119067776 382975538 -151885171 -177220596 -169777795 37619092 333701688 980092719
 10 58
9 1 6 7 8 4 3 2 10 5
97711577 988782657 -119067776 382975538 -151885171 -269784707 -169777795 37619092 389386780 607177473
 3 3
3 1 2
-653 -2000 -3000
 2 3
2 1
10 -13
 10 58
9 1 6 7 8 4 3 2 10 5
695279662 988782657 -119067776 382975538 -151885171 -243968758 -169777795 37619092 737953331 980092719

29507023469 32761913109 -1000 28654091979 23531342619 32205062189 19802190159 -653 10 32992688979
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>

long long int p_array[5001];
long long int c_array[5001];


int main()
{
	long long int score = -1000000001, n, k;
	long long int current_score;

	scanf("%lld %lld", &n, &k);

	for (int i = 1; i <= n; i++)
	{
		scanf("%lld", &p_array[i]);
	}

	for (int i = 1; i <= n; i++)
	{
		scanf("%lld", &c_array[i]);
	}

	for (int i = 1; i <= n; i++)
	{
		int first_step = i;
		int next_step = p_array[first_step];
		long long int step_num = 0;
		current_score = 0;

		while ((first_step != next_step) && (step_num < k))
		{
			current_score += c_array[next_step];
			step_num++;

			next_step = p_array[next_step];

			if (score < current_score)
			{
				score = current_score;
			}

			if ((first_step == next_step) && (step_num < k))
			{
				current_score += c_array[next_step];
				step_num++;
			}


			if (score < current_score)
			{
				score = current_score;
			}
		}


		if ((current_score > 0) && (step_num < k))
		{
			long long int round_scoure = 0;
			round_scoure = ((k - step_num) / step_num)*current_score;

			first_step = i;
			next_step = p_array[first_step];;

			for (long long int j = 0; j<((k%step_num) + step_num); j++)
			{
				round_scoure += c_array[next_step];
				next_step = p_array[next_step];

				if (round_scoure > score)
				{
					score = round_scoure;
				}
			}

		}

	}


	printf("%lld", score);

	return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	p_array
	.bss
	.align 32
	.type	p_array, @object
	.size	p_array, 40008
p_array:
	.zero	40008
	.globl	c_array
	.align 32
	.type	c_array, @object
	.size	c_array, 40008
c_array:
	.zero	40008
	.section	.rodata
.LC0:
	.string	"%lld %lld"
.LC1:
	.string	"%lld"
	.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	$96, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movq	$-1000000001, -48(%rbp)
	leaq	-56(%rbp), %rdx
	leaq	-64(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$1, -84(%rbp)
	jmp	.L2
.L3:
	movl	-84(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	p_array(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -84(%rbp)
.L2:
	movl	-84(%rbp), %eax
	movslq	%eax, %rdx
	movq	-64(%rbp), %rax
	cmpq	%rax, %rdx
	jle	.L3
	movl	$1, -80(%rbp)
	jmp	.L4
.L5:
	movl	-80(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	c_array(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -80(%rbp)
.L4:
	movl	-80(%rbp), %eax
	movslq	%eax, %rdx
	movq	-64(%rbp), %rax
	cmpq	%rax, %rdx
	jle	.L5
	movl	$1, -76(%rbp)
	jmp	.L6
.L16:
	movl	-76(%rbp), %eax
	movl	%eax, -68(%rbp)
	movl	-68(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	p_array(%rip), %rax
	movq	(%rdx,%rax), %rax
	movl	%eax, -72(%rbp)
	movq	$0, -32(%rbp)
	movq	$0, -40(%rbp)
	jmp	.L7
.L11:
	movl	-72(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	c_array(%rip), %rax
	movq	(%rdx,%rax), %rax
	addq	%rax, -40(%rbp)
	addq	$1, -32(%rbp)
	movl	-72(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	p_array(%rip), %rax
	movq	(%rdx,%rax), %rax
	movl	%eax, -72(%rbp)
	movq	-48(%rbp), %rax
	cmpq	-40(%rbp), %rax
	jge	.L8
	movq	-40(%rbp), %rax
	movq	%rax, -48(%rbp)
.L8:
	movl	-68(%rbp), %eax
	cmpl	-72(%rbp), %eax
	jne	.L9
	movq	-56(%rbp), %rax
	cmpq	%rax, -32(%rbp)
	jge	.L9
	movl	-72(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	c_array(%rip), %rax
	movq	(%rdx,%rax), %rax
	addq	%rax, -40(%rbp)
	addq	$1, -32(%rbp)
.L9:
	movq	-48(%rbp), %rax
	cmpq	-40(%rbp), %rax
	jge	.L7
	movq	-40(%rbp), %rax
	movq	%rax, -48(%rbp)
.L7:
	movl	-68(%rbp), %eax
	cmpl	-72(%rbp), %eax
	je	.L10
	movq	-56(%rbp), %rax
	cmpq	%rax, -32(%rbp)
	jl	.L11
.L10:
	cmpq	$0, -40(%rbp)
	jle	.L12
	movq	-56(%rbp), %rax
	cmpq	%rax, -32(%rbp)
	jge	.L12
	movq	$0, -24(%rbp)
	movq	-56(%rbp), %rax
	subq	-32(%rbp), %rax
	cqto
	idivq	-32(%rbp)
	movq	%rax, %rdx
	movq	-40(%rbp), %rax
	imulq	%rdx, %rax
	movq	%rax, -24(%rbp)
	movl	-76(%rbp), %eax
	movl	%eax, -68(%rbp)
	movl	-68(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	p_array(%rip), %rax
	movq	(%rdx,%rax), %rax
	movl	%eax, -72(%rbp)
	movq	$0, -16(%rbp)
	jmp	.L13
.L15:
	movl	-72(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	c_array(%rip), %rax
	movq	(%rdx,%rax), %rax
	addq	%rax, -24(%rbp)
	movl	-72(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	p_array(%rip), %rax
	movq	(%rdx,%rax), %rax
	movl	%eax, -72(%rbp)
	movq	-24(%rbp), %rax
	cmpq	-48(%rbp), %rax
	jle	.L14
	movq	-24(%rbp), %rax
	movq	%rax, -48(%rbp)
.L14:
	addq	$1, -16(%rbp)
.L13:
	movq	-56(%rbp), %rax
	cqto
	idivq	-32(%rbp)
	movq	-32(%rbp), %rax
	addq	%rdx, %rax
	cmpq	%rax, -16(%rbp)
	jl	.L15
.L12:
	addl	$1, -76(%rbp)
.L6:
	movl	-76(%rbp), %eax
	movslq	%eax, %rdx
	movq	-64(%rbp), %rax
	cmpq	%rax, %rdx
	jle	.L16
	movq	-48(%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	.L18
	call	__stack_chk_fail@PLT
.L18:
	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	p_array
	.bss
	.align 32
	.type	p_array, @object
	.size	p_array, 40008
p_array:
	.zero	40008
	.globl	c_array
	.align 32
	.type	c_array, @object
	.size	c_array, 40008
c_array:
	.zero	40008
	.section	.rodata
.LC0:
	.string	"%lld %lld"
.LC1:
	.string	"%lld"
	.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	$96, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movq	$-1000000001, -48(%rbp)
	leaq	-56(%rbp), %rdx
	leaq	-64(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$1, -84(%rbp)
	jmp	.L2
.L3:
	movl	-84(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	p_array(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -84(%rbp)
.L2:
	movl	-84(%rbp), %eax
	movslq	%eax, %rdx
	movq	-64(%rbp), %rax
	cmpq	%rax, %rdx
	jle	.L3
	movl	$1, -80(%rbp)
	jmp	.L4
.L5:
	movl	-80(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	c_array(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -80(%rbp)
.L4:
	movl	-80(%rbp), %eax
	movslq	%eax, %rdx
	movq	-64(%rbp), %rax
	cmpq	%rax, %rdx
	jle	.L5
	movl	$1, -76(%rbp)
	jmp	.L6
.L16:
	movl	-76(%rbp), %eax
	movl	%eax, -68(%rbp)
	movl	-68(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	p_array(%rip), %rax
	movq	(%rdx,%rax), %rax
	movl	%eax, -72(%rbp)
	movq	$0, -32(%rbp)
	movq	$0, -40(%rbp)
	jmp	.L7
.L11:
	movl	-72(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	c_array(%rip), %rax
	movq	(%rdx,%rax), %rax
	addq	%rax, -40(%rbp)
	addq	$1, -32(%rbp)
	movl	-72(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	p_array(%rip), %rax
	movq	(%rdx,%rax), %rax
	movl	%eax, -72(%rbp)
	movq	-48(%rbp), %rax
	cmpq	-40(%rbp), %rax
	jge	.L8
	movq	-40(%rbp), %rax
	movq	%rax, -48(%rbp)
.L8:
	movl	-68(%rbp), %eax
	cmpl	-72(%rbp), %eax
	jne	.L9
	movq	-56(%rbp), %rax
	cmpq	%rax, -32(%rbp)
	jge	.L9
	movl	-72(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	c_array(%rip), %rax
	movq	(%rdx,%rax), %rax
	addq	%rax, -40(%rbp)
	addq	$1, -32(%rbp)
.L9:
	movq	-48(%rbp), %rax
	cmpq	-40(%rbp), %rax
	jge	.L7
	movq	-40(%rbp), %rax
	movq	%rax, -48(%rbp)
.L7:
	movl	-68(%rbp), %eax
	cmpl	-72(%rbp), %eax
	je	.L10
	movq	-56(%rbp), %rax
	cmpq	%rax, -32(%rbp)
	jl	.L11
.L10:
	cmpq	$0, -40(%rbp)
	jle	.L12
	movq	-56(%rbp), %rax
	cmpq	%rax, -32(%rbp)
	jge	.L12
	movq	$0, -24(%rbp)
	movq	-56(%rbp), %rax
	subq	-32(%rbp), %rax
	cqto
	idivq	-32(%rbp)
	movq	%rax, %rdx
	movq	-40(%rbp), %rax
	imulq	%rdx, %rax
	movq	%rax, -24(%rbp)
	movl	-76(%rbp), %eax
	movl	%eax, -68(%rbp)
	movl	-68(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	p_array(%rip), %rax
	movq	(%rdx,%rax), %rax
	movl	%eax, -72(%rbp)
	movq	$0, -16(%rbp)
	jmp	.L13
.L15:
	movl	-72(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	c_array(%rip), %rax
	movq	(%rdx,%rax), %rax
	addq	%rax, -24(%rbp)
	movl	-72(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	p_array(%rip), %rax
	movq	(%rdx,%rax), %rax
	movl	%eax, -72(%rbp)
	movq	-24(%rbp), %rax
	cmpq	-48(%rbp), %rax
	jle	.L14
	movq	-24(%rbp), %rax
	movq	%rax, -48(%rbp)
.L14:
	addq	$1, -16(%rbp)
.L13:
	movq	-56(%rbp), %rax
	cqto
	idivq	-32(%rbp)
	movq	-32(%rbp), %rax
	addq	%rdx, %rax
	cmpq	%rax, -16(%rbp)
	jl	.L15
.L12:
	addl	$1, -76(%rbp)
.L6:
	movl	-76(%rbp), %eax
	movslq	%eax, %rdx
	movq	-64(%rbp), %rax
	cmpq	%rax, %rdx
	jle	.L16
	movq	-48(%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	.L18
	call	__stack_chk_fail@PLT
.L18:
	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:
