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>
#include<math.h>
#define ll long long int

void sort(int array[],ll n){

ll i,j,temp;

for(i=0;i<n;i++)
{

    for(j=0;j<n;j++)
    {

        if (array[j] > array[j + 1])
            {
                temp = array[j];
                array[j] = array[j + 1];
                array[j + 1] = temp;
            }

    }



}




}



int main()
{


ll n,i,k,r,s,p,sum,temp;
char a[100000];
char x[100000];

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

scanf("%lld%lld%lld",&r,&s,&p);

scanf("%s",a);


sum=0;
temp=0;
for(i=0;i<n;i++)
{
    temp++;
    if(temp>k)
    {
        if(a[i]=='r')
        {
            if(x[i-k]!='p')
            {
                sum=sum+p;
                x[i]='p';
            }
            else{
                x[i]='a';
            }


        }
        if(a[i]=='s')
        {
            if(x[i-k]!='r')
            {
                sum=sum+r;
                x[i]='r';

            }
            else{
                x[i]='a';
            }

        }

        if(a[i]=='p'){
            if(x[i-k]!='s'){
                sum=sum+s;
                x[i]='s';
            }
            else{
                x[i]='a';
            }
        }
    }

    else{

        if(a[i]=='r')
        {
           x[i]='p';
           sum=sum+p;
        }
        if(a[i]=='s')
        {
            x[i]='r';
            sum=sum+r;

        }
        if(a[i]=='p')
        {
            x[i]='s';
            sum=sum+s;

        }

    }




}



printf("%lld",sum);



    return 0;
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	sort
	.type	sort, @function
sort:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -40(%rbp)
	movq	%rsi, -48(%rbp)
	movq	$0, -24(%rbp)
	jmp	.L2
.L6:
	movq	$0, -16(%rbp)
	jmp	.L3
.L5:
	movq	-16(%rbp), %rax
	leaq	0(,%rax,4), %rdx
	movq	-40(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movq	-16(%rbp), %rax
	addq	$1, %rax
	leaq	0(,%rax,4), %rcx
	movq	-40(%rbp), %rax
	addq	%rcx, %rax
	movl	(%rax), %eax
	cmpl	%eax, %edx
	jle	.L4
	movq	-16(%rbp), %rax
	leaq	0(,%rax,4), %rdx
	movq	-40(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cltq
	movq	%rax, -8(%rbp)
	movq	-16(%rbp), %rax
	addq	$1, %rax
	leaq	0(,%rax,4), %rdx
	movq	-40(%rbp), %rax
	addq	%rdx, %rax
	movq	-16(%rbp), %rdx
	leaq	0(,%rdx,4), %rcx
	movq	-40(%rbp), %rdx
	addq	%rcx, %rdx
	movl	(%rax), %eax
	movl	%eax, (%rdx)
	movq	-16(%rbp), %rax
	addq	$1, %rax
	leaq	0(,%rax,4), %rdx
	movq	-40(%rbp), %rax
	addq	%rdx, %rax
	movq	-8(%rbp), %rdx
	movl	%edx, (%rax)
.L4:
	addq	$1, -16(%rbp)
.L3:
	movq	-16(%rbp), %rax
	cmpq	-48(%rbp), %rax
	jl	.L5
	addq	$1, -24(%rbp)
.L2:
	movq	-24(%rbp), %rax
	cmpq	-48(%rbp), %rax
	jl	.L6
	nop
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	sort, .-sort
	.section	.rodata
.LC0:
	.string	"%lld%lld"
.LC1:
	.string	"%lld%lld%lld"
.LC2:
	.string	"%s"
.LC3:
	.string	"%lld"
	.text
	.globl	main
	.type	main, @function
main:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	leaq	-196608(%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
	leaq	-200072(%rbp), %rdx
	leaq	-200080(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	leaq	-200048(%rbp), %rcx
	leaq	-200056(%rbp), %rdx
	leaq	-200064(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	leaq	-200016(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	$0, -200032(%rbp)
	movq	$0, -200024(%rbp)
	movq	$0, -200040(%rbp)
	jmp	.L8
.L18:
	addq	$1, -200024(%rbp)
	movq	-200072(%rbp), %rax
	cmpq	%rax, -200024(%rbp)
	jle	.L9
	leaq	-200016(%rbp), %rdx
	movq	-200040(%rbp), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	$114, %al
	jne	.L10
	movq	-200072(%rbp), %rdx
	movq	-200040(%rbp), %rax
	subq	%rdx, %rax
	movzbl	-100016(%rbp,%rax), %eax
	cmpb	$112, %al
	je	.L11
	movq	-200048(%rbp), %rax
	addq	%rax, -200032(%rbp)
	leaq	-100016(%rbp), %rdx
	movq	-200040(%rbp), %rax
	addq	%rdx, %rax
	movb	$112, (%rax)
	jmp	.L10
.L11:
	leaq	-100016(%rbp), %rdx
	movq	-200040(%rbp), %rax
	addq	%rdx, %rax
	movb	$97, (%rax)
.L10:
	leaq	-200016(%rbp), %rdx
	movq	-200040(%rbp), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	$115, %al
	jne	.L12
	movq	-200072(%rbp), %rdx
	movq	-200040(%rbp), %rax
	subq	%rdx, %rax
	movzbl	-100016(%rbp,%rax), %eax
	cmpb	$114, %al
	je	.L13
	movq	-200064(%rbp), %rax
	addq	%rax, -200032(%rbp)
	leaq	-100016(%rbp), %rdx
	movq	-200040(%rbp), %rax
	addq	%rdx, %rax
	movb	$114, (%rax)
	jmp	.L12
.L13:
	leaq	-100016(%rbp), %rdx
	movq	-200040(%rbp), %rax
	addq	%rdx, %rax
	movb	$97, (%rax)
.L12:
	leaq	-200016(%rbp), %rdx
	movq	-200040(%rbp), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	$112, %al
	jne	.L14
	movq	-200072(%rbp), %rdx
	movq	-200040(%rbp), %rax
	subq	%rdx, %rax
	movzbl	-100016(%rbp,%rax), %eax
	cmpb	$115, %al
	je	.L15
	movq	-200056(%rbp), %rax
	addq	%rax, -200032(%rbp)
	leaq	-100016(%rbp), %rdx
	movq	-200040(%rbp), %rax
	addq	%rdx, %rax
	movb	$115, (%rax)
	jmp	.L14
.L15:
	leaq	-100016(%rbp), %rdx
	movq	-200040(%rbp), %rax
	addq	%rdx, %rax
	movb	$97, (%rax)
	jmp	.L14
.L9:
	leaq	-200016(%rbp), %rdx
	movq	-200040(%rbp), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	$114, %al
	jne	.L16
	leaq	-100016(%rbp), %rdx
	movq	-200040(%rbp), %rax
	addq	%rdx, %rax
	movb	$112, (%rax)
	movq	-200048(%rbp), %rax
	addq	%rax, -200032(%rbp)
.L16:
	leaq	-200016(%rbp), %rdx
	movq	-200040(%rbp), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	$115, %al
	jne	.L17
	leaq	-100016(%rbp), %rdx
	movq	-200040(%rbp), %rax
	addq	%rdx, %rax
	movb	$114, (%rax)
	movq	-200064(%rbp), %rax
	addq	%rax, -200032(%rbp)
.L17:
	leaq	-200016(%rbp), %rdx
	movq	-200040(%rbp), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	$112, %al
	jne	.L14
	leaq	-100016(%rbp), %rdx
	movq	-200040(%rbp), %rax
	addq	%rdx, %rax
	movb	$115, (%rax)
	movq	-200056(%rbp), %rax
	addq	%rax, -200032(%rbp)
.L14:
	addq	$1, -200040(%rbp)
.L8:
	movq	-200080(%rbp), %rax
	cmpq	%rax, -200040(%rbp)
	jl	.L18
	movq	-200032(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L20
	call	__stack_chk_fail@PLT
.L20:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.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
	.p2align 4
	.globl	sort
	.type	sort, @function
sort:
.LFB35:
	.cfi_startproc
	endbr64
	testq	%rsi, %rsi
	jle	.L1
	leaq	(%rdi,%rsi,4), %r8
	xorl	%r9d, %r9d
	.p2align 4,,10
	.p2align 3
.L3:
	movq	%rdi, %rdx
	.p2align 4,,10
	.p2align 3
.L5:
	movq	(%rdx), %xmm0
	pshufd	$0xe5, %xmm0, %xmm2
	movd	%xmm0, %ecx
	movd	%xmm2, %eax
	pshufd	$225, %xmm0, %xmm1
	cmpl	%eax, %ecx
	jle	.L4
	movq	%xmm1, (%rdx)
.L4:
	addq	$4, %rdx
	cmpq	%r8, %rdx
	jne	.L5
	addq	$1, %r9
	cmpq	%r9, %rsi
	jne	.L3
.L1:
	ret
	.cfi_endproc
.LFE35:
	.size	sort, .-sort
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%lld%lld"
.LC1:
	.string	"%lld%lld%lld"
.LC2:
	.string	"%s"
.LC3:
	.string	"%lld"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB36:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	leaq	-196608(%rsp), %r11
	.cfi_def_cfa 11, 196632
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	.cfi_def_cfa_register 7
	subq	$3464, %rsp
	.cfi_def_cfa_offset 200096
	leaq	.LC0(%rip), %rdi
	movq	%fs:40, %rax
	movq	%rax, 200056(%rsp)
	xorl	%eax, %eax
	leaq	16(%rsp), %rdx
	leaq	8(%rsp), %rsi
	call	__isoc99_scanf@PLT
	leaq	40(%rsp), %rcx
	xorl	%eax, %eax
	leaq	32(%rsp), %rdx
	leaq	24(%rsp), %rsi
	leaq	.LC1(%rip), %rdi
	call	__isoc99_scanf@PLT
	leaq	48(%rsp), %rsi
	leaq	.LC2(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movq	8(%rsp), %rsi
	testq	%rsi, %rsi
	jle	.L23
	movq	16(%rsp), %rdi
	movq	32(%rsp), %rbp
	xorl	%r8d, %r8d
	xorl	%eax, %eax
	movq	24(%rsp), %rbx
	movq	40(%rsp), %r11
	leaq	47(%rsp), %r9
	leaq	100048(%rsp), %rdx
	movq	%rdx, %r10
	subq	%rdi, %r10
	jmp	.L21
	.p2align 4,,10
	.p2align 3
.L30:
	cmpb	$114, %cl
	je	.L29
	cmpb	$115, %cl
	je	.L13
	cmpb	$112, %cl
	jne	.L15
	cmpb	$115, -1(%r10,%rax)
	je	.L17
	movb	$115, (%rdx)
	addq	%rbp, %r8
	.p2align 4,,10
	.p2align 3
.L15:
	addq	$1, %rdx
	cmpq	%rsi, %rax
	je	.L9
.L21:
	addq	$1, %rax
	movzbl	(%r9,%rax), %ecx
	cmpq	%rax, %rdi
	jl	.L30
	cmpb	$114, %cl
	je	.L31
	cmpb	$115, %cl
	je	.L19
	cmpb	$112, %cl
	jne	.L15
	movb	$115, (%rdx)
	addq	%rbp, %r8
	addq	$1, %rdx
	cmpq	%rsi, %rax
	jne	.L21
	.p2align 4,,10
	.p2align 3
.L9:
	xorl	%eax, %eax
	movq	%r8, %rdx
	movl	$1, %edi
	leaq	.LC3(%rip), %rsi
	call	__printf_chk@PLT
	movq	200056(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L32
	addq	$200072, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 24
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L13:
	.cfi_restore_state
	cmpb	$114, -1(%r10,%rax)
	movl	$97, %ecx
	je	.L12
	addq	%rbx, %r8
	movl	$114, %ecx
.L12:
	movb	%cl, (%rdx)
	jmp	.L15
	.p2align 4,,10
	.p2align 3
.L19:
	movb	$114, (%rdx)
	addq	%rbx, %r8
	jmp	.L15
	.p2align 4,,10
	.p2align 3
.L31:
	movb	$112, (%rdx)
	addq	%r11, %r8
	jmp	.L15
	.p2align 4,,10
	.p2align 3
.L29:
	cmpb	$112, -1(%r10,%rax)
	movl	$97, %ecx
	je	.L12
	movl	$112, %ecx
	addq	%r11, %r8
	movb	%cl, (%rdx)
	jmp	.L15
.L17:
	movb	$97, (%rdx)
	jmp	.L15
.L23:
	xorl	%r8d, %r8d
	jmp	.L9
.L32:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE36:
	.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
	.p2align 4
	.globl	sort
	.type	sort, @function
sort:
.LFB35:
	.cfi_startproc
	endbr64
	testq	%rsi, %rsi
	jle	.L1
	leaq	(%rdi,%rsi,4), %r8
	xorl	%r9d, %r9d
	.p2align 4,,10
	.p2align 3
.L3:
	movq	%rdi, %rdx
	.p2align 4,,10
	.p2align 3
.L5:
	movq	(%rdx), %xmm0
	pshufd	$0xe5, %xmm0, %xmm2
	movd	%xmm0, %ecx
	movd	%xmm2, %eax
	pshufd	$225, %xmm0, %xmm1
	cmpl	%eax, %ecx
	jle	.L4
	movq	%xmm1, (%rdx)
.L4:
	addq	$4, %rdx
	cmpq	%r8, %rdx
	jne	.L5
	addq	$1, %r9
	cmpq	%r9, %rsi
	jne	.L3
.L1:
	ret
	.cfi_endproc
.LFE35:
	.size	sort, .-sort
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%lld%lld"
.LC1:
	.string	"%lld%lld%lld"
.LC2:
	.string	"%s"
.LC3:
	.string	"%lld"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB36:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	leaq	-196608(%rsp), %r11
	.cfi_def_cfa 11, 196632
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	.cfi_def_cfa_register 7
	subq	$3464, %rsp
	.cfi_def_cfa_offset 200096
	leaq	.LC0(%rip), %rdi
	movq	%fs:40, %rax
	movq	%rax, 200056(%rsp)
	xorl	%eax, %eax
	leaq	16(%rsp), %rdx
	leaq	8(%rsp), %rsi
	call	__isoc99_scanf@PLT
	leaq	40(%rsp), %rcx
	xorl	%eax, %eax
	leaq	32(%rsp), %rdx
	leaq	24(%rsp), %rsi
	leaq	.LC1(%rip), %rdi
	call	__isoc99_scanf@PLT
	leaq	48(%rsp), %rsi
	leaq	.LC2(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movq	8(%rsp), %rsi
	testq	%rsi, %rsi
	jle	.L23
	movq	16(%rsp), %rdi
	movq	32(%rsp), %rbp
	xorl	%r8d, %r8d
	xorl	%eax, %eax
	movq	24(%rsp), %rbx
	movq	40(%rsp), %r11
	leaq	47(%rsp), %r9
	leaq	100048(%rsp), %rdx
	movq	%rdx, %r10
	subq	%rdi, %r10
	jmp	.L21
	.p2align 4,,10
	.p2align 3
.L30:
	cmpb	$114, %cl
	je	.L29
	cmpb	$115, %cl
	je	.L13
	cmpb	$112, %cl
	jne	.L15
	cmpb	$115, -1(%r10,%rax)
	je	.L17
	movb	$115, (%rdx)
	addq	%rbp, %r8
	.p2align 4,,10
	.p2align 3
.L15:
	addq	$1, %rdx
	cmpq	%rsi, %rax
	je	.L9
.L21:
	addq	$1, %rax
	movzbl	(%r9,%rax), %ecx
	cmpq	%rax, %rdi
	jl	.L30
	cmpb	$114, %cl
	je	.L31
	cmpb	$115, %cl
	je	.L19
	cmpb	$112, %cl
	jne	.L15
	movb	$115, (%rdx)
	addq	%rbp, %r8
	addq	$1, %rdx
	cmpq	%rsi, %rax
	jne	.L21
	.p2align 4,,10
	.p2align 3
.L9:
	xorl	%eax, %eax
	movq	%r8, %rdx
	movl	$1, %edi
	leaq	.LC3(%rip), %rsi
	call	__printf_chk@PLT
	movq	200056(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L32
	addq	$200072, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 24
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L13:
	.cfi_restore_state
	cmpb	$114, -1(%r10,%rax)
	movl	$97, %ecx
	je	.L12
	addq	%rbx, %r8
	movl	$114, %ecx
.L12:
	movb	%cl, (%rdx)
	jmp	.L15
	.p2align 4,,10
	.p2align 3
.L19:
	movb	$114, (%rdx)
	addq	%rbx, %r8
	jmp	.L15
	.p2align 4,,10
	.p2align 3
.L31:
	movb	$112, (%rdx)
	addq	%r11, %r8
	jmp	.L15
	.p2align 4,,10
	.p2align 3
.L29:
	cmpb	$112, -1(%r10,%rax)
	movl	$97, %ecx
	je	.L12
	movl	$112, %ecx
	addq	%r11, %r8
	movb	%cl, (%rdx)
	jmp	.L15
.L17:
	movb	$97, (%rdx)
	jmp	.L15
.L23:
	xorl	%r8d, %r8d
	jmp	.L9
.L32:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE36:
	.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>
#include<math.h>
#define ll long long int

void sort(int array[],ll n){

ll i,j,temp;

for(i=0;i<n;i++)
{

    for(j=0;j<n;j++)
    {

        if (array[j] > array[j + 1])
            {
                temp = array[j];
                array[j] = array[j + 1];
                array[j + 1] = temp;
            }

    }



}




}



int main()
{


ll n,i,k,r,s,p,sum,temp;
char a[100000];
char x[100000];

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

scanf("%lld%lld%lld",&r,&s,&p);

scanf("%s",a);


sum=0;
temp=0;
for(i=0;i<n;i++)
{
    temp++;
    if(temp>k)
    {
        if(a[i]=='r')
        {
            if(x[i-k]!='p')
            {
                sum=sum+p;
                x[i]='p';
            }
            else{
                x[i]='a';
            }


        }
        if(a[i]=='s')
        {
            if(x[i-k]!='r')
            {
                sum=sum+r;
                x[i]='r';

            }
            else{
                x[i]='a';
            }

        }

        if(a[i]=='p'){
            if(x[i-k]!='s'){
                sum=sum+s;
                x[i]='s';
            }
            else{
                x[i]='a';
            }
        }
    }

    else{

        if(a[i]=='r')
        {
           x[i]='p';
           sum=sum+p;
        }
        if(a[i]=='s')
        {
            x[i]='r';
            sum=sum+r;

        }
        if(a[i]=='p')
        {
            x[i]='s';
            sum=sum+s;

        }

    }




}



printf("%lld",sum);



    return 0;
}

30 6
325 234 123
rspsspspsrpspsppprpsprpssprpsr
 30 6
42 234 123
rspsspspsrpspsppprpsprpssprpsr
 30 6
30 234 123
rspsspspsrpspsppprpsprpssprpsr
 30 6
30 234 123
rspsspspsrpspsppprpsprpssprpss
 30 6
30 234 165
rspsspspsrpspsppprpsprpssprpss
 30 9
30 234 165
rspsspspsrpspsppprpsprpssprpss
 30 9
30 234 88
rspsspspsrpspsppprpsprpssprpss
 30 9
30 234 88
rrpsspspsrpspsppprpsprpssprpss
 30 9
30 234 21
rrpsspspsrpspsppprpsprpssprpss
 30 3
30 234 21
rrpsspspsrpspsppprpsprpssprpss

6328 3498 3378 3255 3465 3135 2904 2962 2694 2502
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>
#include<math.h>
#define ll long long int

void sort(int array[],ll n){

ll i,j,temp;

for(i=0;i<n;i++)
{

    for(j=0;j<n;j++)
    {

        if (array[j] > array[j + 1])
            {
                temp = array[j];
                array[j] = array[j + 1];
                array[j + 1] = temp;
            }

    }



}




}



int main()
{


ll n,i,k,r,s,p,sum,temp;
char a[100000];
char x[100000];

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

scanf("%lld%lld%lld",&r,&s,&p);

scanf("%s",a);


sum=0;
temp=0;
for(i=0;i<n;i++)
{
    temp++;
    if(temp>k)
    {
        if(a[i]=='r')
        {
            if(x[i-k]!='p')
            {
                sum=sum+p;
                x[i]='p';
            }
            else{
                x[i]='a';
            }


        }
        if(a[i]=='s')
        {
            if(x[i-k]!='r')
            {
                sum=sum+r;
                x[i]='r';

            }
            else{
                x[i]='a';
            }

        }

        if(a[i]=='p'){
            if(x[i-k]!='s'){
                sum=sum+s;
                x[i]='s';
            }
            else{
                x[i]='a';
            }
        }
    }

    else{

        if(a[i]=='r')
        {
           x[i]='p';
           sum=sum+p;
        }
        if(a[i]=='s')
        {
            x[i]='r';
            sum=sum+r;

        }
        if(a[i]=='p')
        {
            x[i]='s';
            sum=sum+s;

        }

    }




}



printf("%lld",sum);



    return 0;
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	sort
	.type	sort, @function
sort:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -40(%rbp)
	movq	%rsi, -48(%rbp)
	movq	$0, -24(%rbp)
	jmp	.L2
.L6:
	movq	$0, -16(%rbp)
	jmp	.L3
.L5:
	movq	-16(%rbp), %rax
	leaq	0(,%rax,4), %rdx
	movq	-40(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movq	-16(%rbp), %rax
	addq	$1, %rax
	leaq	0(,%rax,4), %rcx
	movq	-40(%rbp), %rax
	addq	%rcx, %rax
	movl	(%rax), %eax
	cmpl	%eax, %edx
	jle	.L4
	movq	-16(%rbp), %rax
	leaq	0(,%rax,4), %rdx
	movq	-40(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cltq
	movq	%rax, -8(%rbp)
	movq	-16(%rbp), %rax
	addq	$1, %rax
	leaq	0(,%rax,4), %rdx
	movq	-40(%rbp), %rax
	addq	%rdx, %rax
	movq	-16(%rbp), %rdx
	leaq	0(,%rdx,4), %rcx
	movq	-40(%rbp), %rdx
	addq	%rcx, %rdx
	movl	(%rax), %eax
	movl	%eax, (%rdx)
	movq	-16(%rbp), %rax
	addq	$1, %rax
	leaq	0(,%rax,4), %rdx
	movq	-40(%rbp), %rax
	addq	%rdx, %rax
	movq	-8(%rbp), %rdx
	movl	%edx, (%rax)
.L4:
	addq	$1, -16(%rbp)
.L3:
	movq	-16(%rbp), %rax
	cmpq	-48(%rbp), %rax
	jl	.L5
	addq	$1, -24(%rbp)
.L2:
	movq	-24(%rbp), %rax
	cmpq	-48(%rbp), %rax
	jl	.L6
	nop
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	sort, .-sort
	.section	.rodata
.LC0:
	.string	"%lld%lld"
.LC1:
	.string	"%lld%lld%lld"
.LC2:
	.string	"%s"
.LC3:
	.string	"%lld"
	.text
	.globl	main
	.type	main, @function
main:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	leaq	-196608(%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
	leaq	-200072(%rbp), %rdx
	leaq	-200080(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	leaq	-200048(%rbp), %rcx
	leaq	-200056(%rbp), %rdx
	leaq	-200064(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	leaq	-200016(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	$0, -200032(%rbp)
	movq	$0, -200024(%rbp)
	movq	$0, -200040(%rbp)
	jmp	.L8
.L18:
	addq	$1, -200024(%rbp)
	movq	-200072(%rbp), %rax
	cmpq	%rax, -200024(%rbp)
	jle	.L9
	leaq	-200016(%rbp), %rdx
	movq	-200040(%rbp), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	$114, %al
	jne	.L10
	movq	-200072(%rbp), %rdx
	movq	-200040(%rbp), %rax
	subq	%rdx, %rax
	movzbl	-100016(%rbp,%rax), %eax
	cmpb	$112, %al
	je	.L11
	movq	-200048(%rbp), %rax
	addq	%rax, -200032(%rbp)
	leaq	-100016(%rbp), %rdx
	movq	-200040(%rbp), %rax
	addq	%rdx, %rax
	movb	$112, (%rax)
	jmp	.L10
.L11:
	leaq	-100016(%rbp), %rdx
	movq	-200040(%rbp), %rax
	addq	%rdx, %rax
	movb	$97, (%rax)
.L10:
	leaq	-200016(%rbp), %rdx
	movq	-200040(%rbp), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	$115, %al
	jne	.L12
	movq	-200072(%rbp), %rdx
	movq	-200040(%rbp), %rax
	subq	%rdx, %rax
	movzbl	-100016(%rbp,%rax), %eax
	cmpb	$114, %al
	je	.L13
	movq	-200064(%rbp), %rax
	addq	%rax, -200032(%rbp)
	leaq	-100016(%rbp), %rdx
	movq	-200040(%rbp), %rax
	addq	%rdx, %rax
	movb	$114, (%rax)
	jmp	.L12
.L13:
	leaq	-100016(%rbp), %rdx
	movq	-200040(%rbp), %rax
	addq	%rdx, %rax
	movb	$97, (%rax)
.L12:
	leaq	-200016(%rbp), %rdx
	movq	-200040(%rbp), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	$112, %al
	jne	.L14
	movq	-200072(%rbp), %rdx
	movq	-200040(%rbp), %rax
	subq	%rdx, %rax
	movzbl	-100016(%rbp,%rax), %eax
	cmpb	$115, %al
	je	.L15
	movq	-200056(%rbp), %rax
	addq	%rax, -200032(%rbp)
	leaq	-100016(%rbp), %rdx
	movq	-200040(%rbp), %rax
	addq	%rdx, %rax
	movb	$115, (%rax)
	jmp	.L14
.L15:
	leaq	-100016(%rbp), %rdx
	movq	-200040(%rbp), %rax
	addq	%rdx, %rax
	movb	$97, (%rax)
	jmp	.L14
.L9:
	leaq	-200016(%rbp), %rdx
	movq	-200040(%rbp), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	$114, %al
	jne	.L16
	leaq	-100016(%rbp), %rdx
	movq	-200040(%rbp), %rax
	addq	%rdx, %rax
	movb	$112, (%rax)
	movq	-200048(%rbp), %rax
	addq	%rax, -200032(%rbp)
.L16:
	leaq	-200016(%rbp), %rdx
	movq	-200040(%rbp), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	$115, %al
	jne	.L17
	leaq	-100016(%rbp), %rdx
	movq	-200040(%rbp), %rax
	addq	%rdx, %rax
	movb	$114, (%rax)
	movq	-200064(%rbp), %rax
	addq	%rax, -200032(%rbp)
.L17:
	leaq	-200016(%rbp), %rdx
	movq	-200040(%rbp), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	$112, %al
	jne	.L14
	leaq	-100016(%rbp), %rdx
	movq	-200040(%rbp), %rax
	addq	%rdx, %rax
	movb	$115, (%rax)
	movq	-200056(%rbp), %rax
	addq	%rax, -200032(%rbp)
.L14:
	addq	$1, -200040(%rbp)
.L8:
	movq	-200080(%rbp), %rax
	cmpq	%rax, -200040(%rbp)
	jl	.L18
	movq	-200032(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L20
	call	__stack_chk_fail@PLT
.L20:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.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	sort
	.type	sort, @function
sort:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -40(%rbp)
	movq	%rsi, -48(%rbp)
	movq	$0, -24(%rbp)
	jmp	.L2
.L6:
	movq	$0, -16(%rbp)
	jmp	.L3
.L5:
	movq	-16(%rbp), %rax
	leaq	0(,%rax,4), %rdx
	movq	-40(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movq	-16(%rbp), %rax
	addq	$1, %rax
	leaq	0(,%rax,4), %rcx
	movq	-40(%rbp), %rax
	addq	%rcx, %rax
	movl	(%rax), %eax
	cmpl	%eax, %edx
	jle	.L4
	movq	-16(%rbp), %rax
	leaq	0(,%rax,4), %rdx
	movq	-40(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cltq
	movq	%rax, -8(%rbp)
	movq	-16(%rbp), %rax
	addq	$1, %rax
	leaq	0(,%rax,4), %rdx
	movq	-40(%rbp), %rax
	addq	%rdx, %rax
	movq	-16(%rbp), %rdx
	leaq	0(,%rdx,4), %rcx
	movq	-40(%rbp), %rdx
	addq	%rcx, %rdx
	movl	(%rax), %eax
	movl	%eax, (%rdx)
	movq	-16(%rbp), %rax
	addq	$1, %rax
	leaq	0(,%rax,4), %rdx
	movq	-40(%rbp), %rax
	addq	%rdx, %rax
	movq	-8(%rbp), %rdx
	movl	%edx, (%rax)
.L4:
	addq	$1, -16(%rbp)
.L3:
	movq	-16(%rbp), %rax
	cmpq	-48(%rbp), %rax
	jl	.L5
	addq	$1, -24(%rbp)
.L2:
	movq	-24(%rbp), %rax
	cmpq	-48(%rbp), %rax
	jl	.L6
	nop
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	sort, .-sort
	.section	.rodata
.LC0:
	.string	"%lld%lld"
.LC1:
	.string	"%lld%lld%lld"
.LC2:
	.string	"%s"
.LC3:
	.string	"%lld"
	.text
	.globl	main
	.type	main, @function
main:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	leaq	-196608(%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
	leaq	-200072(%rbp), %rdx
	leaq	-200080(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	leaq	-200048(%rbp), %rcx
	leaq	-200056(%rbp), %rdx
	leaq	-200064(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	leaq	-200016(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	$0, -200032(%rbp)
	movq	$0, -200024(%rbp)
	movq	$0, -200040(%rbp)
	jmp	.L8
.L18:
	addq	$1, -200024(%rbp)
	movq	-200072(%rbp), %rax
	cmpq	%rax, -200024(%rbp)
	jle	.L9
	leaq	-200016(%rbp), %rdx
	movq	-200040(%rbp), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	$114, %al
	jne	.L10
	movq	-200072(%rbp), %rdx
	movq	-200040(%rbp), %rax
	subq	%rdx, %rax
	movzbl	-100016(%rbp,%rax), %eax
	cmpb	$112, %al
	je	.L11
	movq	-200048(%rbp), %rax
	addq	%rax, -200032(%rbp)
	leaq	-100016(%rbp), %rdx
	movq	-200040(%rbp), %rax
	addq	%rdx, %rax
	movb	$112, (%rax)
	jmp	.L10
.L11:
	leaq	-100016(%rbp), %rdx
	movq	-200040(%rbp), %rax
	addq	%rdx, %rax
	movb	$97, (%rax)
.L10:
	leaq	-200016(%rbp), %rdx
	movq	-200040(%rbp), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	$115, %al
	jne	.L12
	movq	-200072(%rbp), %rdx
	movq	-200040(%rbp), %rax
	subq	%rdx, %rax
	movzbl	-100016(%rbp,%rax), %eax
	cmpb	$114, %al
	je	.L13
	movq	-200064(%rbp), %rax
	addq	%rax, -200032(%rbp)
	leaq	-100016(%rbp), %rdx
	movq	-200040(%rbp), %rax
	addq	%rdx, %rax
	movb	$114, (%rax)
	jmp	.L12
.L13:
	leaq	-100016(%rbp), %rdx
	movq	-200040(%rbp), %rax
	addq	%rdx, %rax
	movb	$97, (%rax)
.L12:
	leaq	-200016(%rbp), %rdx
	movq	-200040(%rbp), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	$112, %al
	jne	.L14
	movq	-200072(%rbp), %rdx
	movq	-200040(%rbp), %rax
	subq	%rdx, %rax
	movzbl	-100016(%rbp,%rax), %eax
	cmpb	$115, %al
	je	.L15
	movq	-200056(%rbp), %rax
	addq	%rax, -200032(%rbp)
	leaq	-100016(%rbp), %rdx
	movq	-200040(%rbp), %rax
	addq	%rdx, %rax
	movb	$115, (%rax)
	jmp	.L14
.L15:
	leaq	-100016(%rbp), %rdx
	movq	-200040(%rbp), %rax
	addq	%rdx, %rax
	movb	$97, (%rax)
	jmp	.L14
.L9:
	leaq	-200016(%rbp), %rdx
	movq	-200040(%rbp), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	$114, %al
	jne	.L16
	leaq	-100016(%rbp), %rdx
	movq	-200040(%rbp), %rax
	addq	%rdx, %rax
	movb	$112, (%rax)
	movq	-200048(%rbp), %rax
	addq	%rax, -200032(%rbp)
.L16:
	leaq	-200016(%rbp), %rdx
	movq	-200040(%rbp), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	$115, %al
	jne	.L17
	leaq	-100016(%rbp), %rdx
	movq	-200040(%rbp), %rax
	addq	%rdx, %rax
	movb	$114, (%rax)
	movq	-200064(%rbp), %rax
	addq	%rax, -200032(%rbp)
.L17:
	leaq	-200016(%rbp), %rdx
	movq	-200040(%rbp), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	$112, %al
	jne	.L14
	leaq	-100016(%rbp), %rdx
	movq	-200040(%rbp), %rax
	addq	%rdx, %rax
	movb	$115, (%rax)
	movq	-200056(%rbp), %rax
	addq	%rax, -200032(%rbp)
.L14:
	addq	$1, -200040(%rbp)
.L8:
	movq	-200080(%rbp), %rax
	cmpq	%rax, -200040(%rbp)
	jl	.L18
	movq	-200032(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L20
	call	__stack_chk_fail@PLT
.L20:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.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:
