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

char
win(char c)
{
    char tp;
    switch(c) {
        case 'r':
            tp = 'p';
            break;
        case 's':
            tp = 'r';
            break;
        case 'p':
            tp = 's';
            break;
    }
    return tp;
}

void
solver(int n, int k, int r, int s, int p, char *t)
{
    int total=0;
    int i;
    char u[100001], tp;

    for (i=0; i<n; i++) {
        tp = win(t[i]);
        
        if (i+1>k && tp==u[i-k]) {
            if (i>n-k || t[i+k]==tp)
                tp = t[i];
            else {
                tp = t[i+k];
            }
        }
        else {
            switch(tp) {
                case 'r':
                    total += r;
                    break;
                case 's':
                    total += s;
                    break;
                case 'p':
                    total += p;
                    break;
            }
        }
        u[i] = tp;
    }

    printf("%d\n", total);
}

int
main(int argc, char *argv[])
{
    int N, K;
    int R, S, P;
    char T[100001];

    scanf("%d%d", &N, &K);
    scanf("%d%d%d", &R, &S, &P);
    scanf("%s", T);

    solver(N, K, R, S, P, T);

    return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	win
	.type	win, @function
win:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, %eax
	movb	%al, -20(%rbp)
	movsbl	-20(%rbp), %eax
	cmpl	$115, %eax
	je	.L2
	cmpl	$115, %eax
	jg	.L3
	cmpl	$112, %eax
	je	.L4
	cmpl	$114, %eax
	jne	.L3
	movb	$112, -1(%rbp)
	jmp	.L3
.L2:
	movb	$114, -1(%rbp)
	jmp	.L3
.L4:
	movb	$115, -1(%rbp)
	nop
.L3:
	movzbl	-1(%rbp), %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	win, .-win
	.section	.rodata
.LC0:
	.string	"%d\n"
	.text
	.globl	solver
	.type	solver, @function
solver:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	leaq	-98304(%rsp), %r11
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	subq	$1760, %rsp
	movl	%edi, -100036(%rbp)
	movl	%esi, -100040(%rbp)
	movl	%edx, -100044(%rbp)
	movl	%ecx, -100048(%rbp)
	movl	%r8d, -100052(%rbp)
	movq	%r9, -100064(%rbp)
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -100024(%rbp)
	movl	$0, -100020(%rbp)
	jmp	.L7
.L15:
	movl	-100020(%rbp), %eax
	movslq	%eax, %rdx
	movq	-100064(%rbp), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	movsbl	%al, %eax
	movl	%eax, %edi
	call	win
	movb	%al, -100025(%rbp)
	movl	-100020(%rbp), %eax
	cmpl	-100040(%rbp), %eax
	jl	.L8
	movl	-100020(%rbp), %eax
	subl	-100040(%rbp), %eax
	cltq
	movzbl	-100016(%rbp,%rax), %eax
	cmpb	%al, -100025(%rbp)
	jne	.L8
	movl	-100036(%rbp), %eax
	subl	-100040(%rbp), %eax
	cmpl	%eax, -100020(%rbp)
	jg	.L9
	movl	-100020(%rbp), %edx
	movl	-100040(%rbp), %eax
	addl	%edx, %eax
	movslq	%eax, %rdx
	movq	-100064(%rbp), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	%al, -100025(%rbp)
	jne	.L10
.L9:
	movl	-100020(%rbp), %eax
	movslq	%eax, %rdx
	movq	-100064(%rbp), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	movb	%al, -100025(%rbp)
	jmp	.L12
.L10:
	movl	-100020(%rbp), %edx
	movl	-100040(%rbp), %eax
	addl	%edx, %eax
	movslq	%eax, %rdx
	movq	-100064(%rbp), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	movb	%al, -100025(%rbp)
	jmp	.L12
.L8:
	movsbl	-100025(%rbp), %eax
	cmpl	$115, %eax
	je	.L13
	cmpl	$115, %eax
	jg	.L12
	cmpl	$112, %eax
	je	.L14
	cmpl	$114, %eax
	jne	.L12
	movl	-100044(%rbp), %eax
	addl	%eax, -100024(%rbp)
	jmp	.L12
.L13:
	movl	-100048(%rbp), %eax
	addl	%eax, -100024(%rbp)
	jmp	.L12
.L14:
	movl	-100052(%rbp), %eax
	addl	%eax, -100024(%rbp)
	nop
.L12:
	movl	-100020(%rbp), %eax
	cltq
	movzbl	-100025(%rbp), %edx
	movb	%dl, -100016(%rbp,%rax)
	addl	$1, -100020(%rbp)
.L7:
	movl	-100020(%rbp), %eax
	cmpl	-100036(%rbp), %eax
	jl	.L15
	movl	-100024(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	nop
	movq	-8(%rbp), %rax
	subq	%fs:40, %rax
	je	.L16
	call	__stack_chk_fail@PLT
.L16:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	solver, .-solver
	.section	.rodata
.LC1:
	.string	"%d%d"
.LC2:
	.string	"%d%d%d"
.LC3:
	.string	"%s"
	.text
	.globl	main
	.type	main, @function
main:
.LFB8:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	leaq	-98304(%rsp), %r11
.LPSRL1:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL1
	subq	$1760, %rsp
	movl	%edi, -100052(%rbp)
	movq	%rsi, -100064(%rbp)
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-100032(%rbp), %rdx
	leaq	-100036(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	leaq	-100020(%rbp), %rcx
	leaq	-100024(%rbp), %rdx
	leaq	-100028(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	leaq	-100016(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-100020(%rbp), %edi
	movl	-100024(%rbp), %ecx
	movl	-100028(%rbp), %edx
	movl	-100032(%rbp), %esi
	movl	-100036(%rbp), %eax
	leaq	-100016(%rbp), %r8
	movq	%r8, %r9
	movl	%edi, %r8d
	movl	%eax, %edi
	call	solver
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L19
	call	__stack_chk_fail@PLT
.L19:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.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	win
	.type	win, @function
win:
.LFB39:
	.cfi_startproc
	endbr64
	movl	$112, %eax
	cmpb	$114, %dil
	je	.L1
	cmpb	$115, %dil
	je	.L4
	cmpb	$112, %dil
	movl	$115, %edx
	cmove	%edx, %eax
	ret
	.p2align 4,,10
	.p2align 3
.L4:
	movl	$114, %eax
.L1:
	ret
	.cfi_endproc
.LFE39:
	.size	win, .-win
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d\n"
	.text
	.p2align 4
	.globl	solver
	.type	solver, @function
solver:
.LFB40:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	leaq	-98304(%rsp), %r11
	.cfi_def_cfa 11, 98352
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	.cfi_def_cfa_register 7
	subq	$1712, %rsp
	.cfi_def_cfa_offset 100064
	movq	%fs:40, %rax
	movq	%rax, 100008(%rsp)
	xorl	%eax, %eax
	testl	%edi, %edi
	jle	.L30
	movl	%edi, %eax
	movl	%edi, %r11d
	movl	%edx, %ebx
	movl	%ecx, %ebp
	subl	%esi, %eax
	js	.L31
	leal	-1(%rdi), %r13d
	movl	%esi, %edi
	movq	%rsp, %r12
	cmpl	%eax, %r13d
	cmovg	%eax, %r13d
	negl	%edi
	xorl	%eax, %eax
	xorl	%r10d, %r10d
	jmp	.L16
	.p2align 4,,10
	.p2align 3
.L43:
	cmpl	%eax, %esi
	jle	.L41
.L11:
	addl	%r8d, %r10d
	movl	$112, %edx
.L15:
	movb	%dl, (%r12,%rax)
	leal	1(%rax), %ecx
	addq	$1, %rax
	addl	$1, %edi
	cmpl	%eax, %r13d
	jl	.L42
.L16:
	movzbl	(%r9,%rax), %edx
	cmpb	$112, %dl
	je	.L9
	cmpb	$115, %dl
	jne	.L43
	cmpl	%eax, %esi
	jg	.L13
	movslq	%edi, %rcx
	movzbl	(%rsp,%rcx), %ecx
	cmpb	$114, %cl
	je	.L12
.L13:
	addl	%ebx, %r10d
	movl	$114, %edx
	jmp	.L15
	.p2align 4,,10
	.p2align 3
.L9:
	cmpl	%eax, %esi
	jg	.L14
	movslq	%edi, %rcx
	movzbl	(%rsp,%rcx), %ecx
	cmpb	$115, %cl
	je	.L12
.L14:
	addl	%ebp, %r10d
	movl	$115, %edx
	jmp	.L15
	.p2align 4,,10
	.p2align 3
.L41:
	movslq	%edi, %rcx
	movzbl	(%rsp,%rcx), %ecx
	cmpb	$112, %cl
	jne	.L11
.L12:
	leal	(%rsi,%rax), %r14d
	movslq	%r14d, %r14
	movzbl	(%r9,%r14), %r14d
	cmpb	%cl, %r14b
	cmovne	%r14d, %edx
	jmp	.L15
	.p2align 4,,10
	.p2align 3
.L42:
	cmpl	%ecx, %r11d
	jle	.L7
.L8:
	movslq	%ecx, %rax
	subl	%esi, %ecx
	jmp	.L24
	.p2align 4,,10
	.p2align 3
.L45:
	cmpl	%eax, %esi
	jle	.L44
.L19:
	addl	%r8d, %r10d
	movl	$112, %edx
.L20:
	movb	%dl, (%r12,%rax)
	addq	$1, %rax
	addl	$1, %ecx
	cmpl	%eax, %r11d
	jle	.L7
.L24:
	movzbl	(%r9,%rax), %edx
	cmpb	$112, %dl
	je	.L17
	cmpb	$115, %dl
	jne	.L45
	cmpl	%eax, %esi
	jg	.L21
	movslq	%ecx, %rdi
	cmpb	$114, (%rsp,%rdi)
	je	.L20
.L21:
	movl	$114, %edx
	addl	%ebx, %r10d
	addl	$1, %ecx
	movb	%dl, (%r12,%rax)
	addq	$1, %rax
	cmpl	%eax, %r11d
	jg	.L24
	.p2align 4,,10
	.p2align 3
.L7:
	movq	100008(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L46
	addq	$100016, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 48
	movl	%r10d, %edx
	movl	$1, %edi
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 40
	leaq	.LC0(%rip), %rsi
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	jmp	__printf_chk@PLT
	.p2align 4,,10
	.p2align 3
.L17:
	.cfi_restore_state
	cmpl	%eax, %esi
	jg	.L22
	movslq	%ecx, %rdi
	cmpb	$115, (%rsp,%rdi)
	je	.L20
.L22:
	addl	%ebp, %r10d
	movl	$115, %edx
	jmp	.L20
	.p2align 4,,10
	.p2align 3
.L44:
	movslq	%ecx, %rdi
	cmpb	$112, (%rsp,%rdi)
	jne	.L19
	jmp	.L20
	.p2align 4,,10
	.p2align 3
.L31:
	xorl	%ecx, %ecx
	xorl	%r10d, %r10d
	movq	%rsp, %r12
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L30:
	xorl	%r10d, %r10d
	jmp	.L7
.L46:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE40:
	.size	solver, .-solver
	.section	.rodata.str1.1
.LC1:
	.string	"%d%d"
.LC2:
	.string	"%d%d%d"
.LC3:
	.string	"%s"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB41:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	leaq	-98304(%rsp), %r11
	.cfi_def_cfa 11, 98320
.LPSRL1:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL1
	.cfi_def_cfa_register 7
	subq	$1744, %rsp
	.cfi_def_cfa_offset 100064
	leaq	.LC1(%rip), %rdi
	movq	%fs:40, %rax
	movq	%rax, 100040(%rsp)
	xorl	%eax, %eax
	leaq	16(%rsp), %rdx
	leaq	12(%rsp), %rsi
	leaq	32(%rsp), %rbx
	call	__isoc99_scanf@PLT
	leaq	28(%rsp), %rcx
	xorl	%eax, %eax
	leaq	24(%rsp), %rdx
	leaq	20(%rsp), %rsi
	leaq	.LC2(%rip), %rdi
	call	__isoc99_scanf@PLT
	movq	%rbx, %rsi
	leaq	.LC3(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	24(%rsp), %ecx
	movl	20(%rsp), %edx
	movq	%rbx, %r9
	movl	28(%rsp), %r8d
	movl	16(%rsp), %esi
	movl	12(%rsp), %edi
	call	solver
	movq	100040(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L50
	addq	$100048, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 16
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 8
	ret
.L50:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE41:
	.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	win
	.type	win, @function
win:
.LFB39:
	.cfi_startproc
	endbr64
	movl	$112, %eax
	cmpb	$114, %dil
	je	.L1
	cmpb	$115, %dil
	je	.L4
	cmpb	$112, %dil
	movl	$115, %edx
	cmove	%edx, %eax
	ret
	.p2align 4,,10
	.p2align 3
.L4:
	movl	$114, %eax
.L1:
	ret
	.cfi_endproc
.LFE39:
	.size	win, .-win
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d\n"
	.text
	.p2align 4
	.globl	solver
	.type	solver, @function
solver:
.LFB40:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	leaq	-98304(%rsp), %r11
	.cfi_def_cfa 11, 98352
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	.cfi_def_cfa_register 7
	subq	$1712, %rsp
	.cfi_def_cfa_offset 100064
	movq	%fs:40, %rax
	movq	%rax, 100008(%rsp)
	xorl	%eax, %eax
	testl	%edi, %edi
	jle	.L30
	movl	%edi, %eax
	movl	%edi, %r11d
	movl	%edx, %ebx
	movl	%ecx, %ebp
	subl	%esi, %eax
	js	.L31
	leal	-1(%rdi), %r13d
	movl	%esi, %edi
	movq	%rsp, %r12
	cmpl	%eax, %r13d
	cmovg	%eax, %r13d
	negl	%edi
	xorl	%eax, %eax
	xorl	%r10d, %r10d
	jmp	.L16
	.p2align 4,,10
	.p2align 3
.L43:
	cmpl	%eax, %esi
	jle	.L41
.L11:
	addl	%r8d, %r10d
	movl	$112, %edx
.L15:
	movb	%dl, (%r12,%rax)
	leal	1(%rax), %ecx
	addq	$1, %rax
	addl	$1, %edi
	cmpl	%eax, %r13d
	jl	.L42
.L16:
	movzbl	(%r9,%rax), %edx
	cmpb	$112, %dl
	je	.L9
	cmpb	$115, %dl
	jne	.L43
	cmpl	%eax, %esi
	jg	.L13
	movslq	%edi, %rcx
	movzbl	(%rsp,%rcx), %ecx
	cmpb	$114, %cl
	je	.L12
.L13:
	addl	%ebx, %r10d
	movl	$114, %edx
	jmp	.L15
	.p2align 4,,10
	.p2align 3
.L9:
	cmpl	%eax, %esi
	jg	.L14
	movslq	%edi, %rcx
	movzbl	(%rsp,%rcx), %ecx
	cmpb	$115, %cl
	je	.L12
.L14:
	addl	%ebp, %r10d
	movl	$115, %edx
	jmp	.L15
	.p2align 4,,10
	.p2align 3
.L41:
	movslq	%edi, %rcx
	movzbl	(%rsp,%rcx), %ecx
	cmpb	$112, %cl
	jne	.L11
.L12:
	leal	(%rsi,%rax), %r14d
	movslq	%r14d, %r14
	movzbl	(%r9,%r14), %r14d
	cmpb	%cl, %r14b
	cmovne	%r14d, %edx
	jmp	.L15
	.p2align 4,,10
	.p2align 3
.L42:
	cmpl	%ecx, %r11d
	jle	.L7
.L8:
	movslq	%ecx, %rax
	subl	%esi, %ecx
	jmp	.L24
	.p2align 4,,10
	.p2align 3
.L45:
	cmpl	%eax, %esi
	jle	.L44
.L19:
	addl	%r8d, %r10d
	movl	$112, %edx
.L20:
	movb	%dl, (%r12,%rax)
	addq	$1, %rax
	addl	$1, %ecx
	cmpl	%eax, %r11d
	jle	.L7
.L24:
	movzbl	(%r9,%rax), %edx
	cmpb	$112, %dl
	je	.L17
	cmpb	$115, %dl
	jne	.L45
	cmpl	%eax, %esi
	jg	.L21
	movslq	%ecx, %rdi
	cmpb	$114, (%rsp,%rdi)
	je	.L20
.L21:
	movl	$114, %edx
	addl	%ebx, %r10d
	addl	$1, %ecx
	movb	%dl, (%r12,%rax)
	addq	$1, %rax
	cmpl	%eax, %r11d
	jg	.L24
	.p2align 4,,10
	.p2align 3
.L7:
	movq	100008(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L46
	addq	$100016, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 48
	movl	%r10d, %edx
	movl	$1, %edi
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 40
	leaq	.LC0(%rip), %rsi
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	jmp	__printf_chk@PLT
	.p2align 4,,10
	.p2align 3
.L17:
	.cfi_restore_state
	cmpl	%eax, %esi
	jg	.L22
	movslq	%ecx, %rdi
	cmpb	$115, (%rsp,%rdi)
	je	.L20
.L22:
	addl	%ebp, %r10d
	movl	$115, %edx
	jmp	.L20
	.p2align 4,,10
	.p2align 3
.L44:
	movslq	%ecx, %rdi
	cmpb	$112, (%rsp,%rdi)
	jne	.L19
	jmp	.L20
	.p2align 4,,10
	.p2align 3
.L31:
	xorl	%ecx, %ecx
	xorl	%r10d, %r10d
	movq	%rsp, %r12
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L30:
	xorl	%r10d, %r10d
	jmp	.L7
.L46:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE40:
	.size	solver, .-solver
	.section	.rodata.str1.1
.LC1:
	.string	"%d%d"
.LC2:
	.string	"%d%d%d"
.LC3:
	.string	"%s"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB41:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	leaq	-98304(%rsp), %r11
	.cfi_def_cfa 11, 98320
.LPSRL1:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL1
	.cfi_def_cfa_register 7
	subq	$1744, %rsp
	.cfi_def_cfa_offset 100064
	leaq	.LC1(%rip), %rdi
	movq	%fs:40, %rax
	movq	%rax, 100040(%rsp)
	xorl	%eax, %eax
	leaq	16(%rsp), %rdx
	leaq	12(%rsp), %rsi
	leaq	32(%rsp), %rbx
	call	__isoc99_scanf@PLT
	leaq	28(%rsp), %rcx
	xorl	%eax, %eax
	leaq	24(%rsp), %rdx
	leaq	20(%rsp), %rsi
	leaq	.LC2(%rip), %rdi
	call	__isoc99_scanf@PLT
	movq	%rbx, %rsi
	leaq	.LC3(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	24(%rsp), %ecx
	movl	20(%rsp), %edx
	movq	%rbx, %r9
	movl	28(%rsp), %r8d
	movl	16(%rsp), %esi
	movl	12(%rsp), %edi
	call	solver
	movq	100040(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L50
	addq	$100048, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 16
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 8
	ret
.L50:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE41:
	.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 <stdlib.h>

char
win(char c)
{
    char tp;
    switch(c) {
        case 'r':
            tp = 'p';
            break;
        case 's':
            tp = 'r';
            break;
        case 'p':
            tp = 's';
            break;
    }
    return tp;
}

void
solver(int n, int k, int r, int s, int p, char *t)
{
    int total=0;
    int i;
    char u[100001], tp;

    for (i=0; i<n; i++) {
        tp = win(t[i]);
        
        if (i+1>k && tp==u[i-k]) {
            if (i>n-k || t[i+k]==tp)
                tp = t[i];
            else {
                tp = t[i+k];
            }
        }
        else {
            switch(tp) {
                case 'r':
                    total += r;
                    break;
                case 's':
                    total += s;
                    break;
                case 'p':
                    total += p;
                    break;
            }
        }
        u[i] = tp;
    }

    printf("%d\n", total);
}

int
main(int argc, char *argv[])
{
    int N, K;
    int R, S, P;
    char T[100001];

    scanf("%d%d", &N, &K);
    scanf("%d%d%d", &R, &S, &P);
    scanf("%s", T);

    solver(N, K, R, S, P, T);

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

char
win(char c)
{
    char tp;
    switch(c) {
        case 'r':
            tp = 'p';
            break;
        case 's':
            tp = 'r';
            break;
        case 'p':
            tp = 's';
            break;
    }
    return tp;
}

void
solver(int n, int k, int r, int s, int p, char *t)
{
    int total=0;
    int i;
    char u[100001], tp;

    for (i=0; i<n; i++) {
        tp = win(t[i]);
        
        if (i+1>k && tp==u[i-k]) {
            if (i>n-k || t[i+k]==tp)
                tp = t[i];
            else {
                tp = t[i+k];
            }
        }
        else {
            switch(tp) {
                case 'r':
                    total += r;
                    break;
                case 's':
                    total += s;
                    break;
                case 'p':
                    total += p;
                    break;
            }
        }
        u[i] = tp;
    }

    printf("%d\n", total);
}

int
main(int argc, char *argv[])
{
    int N, K;
    int R, S, P;
    char T[100001];

    scanf("%d%d", &N, &K);
    scanf("%d%d%d", &R, &S, &P);
    scanf("%s", T);

    solver(N, K, R, S, P, T);

    return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	win
	.type	win, @function
win:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, %eax
	movb	%al, -20(%rbp)
	movsbl	-20(%rbp), %eax
	cmpl	$115, %eax
	je	.L2
	cmpl	$115, %eax
	jg	.L3
	cmpl	$112, %eax
	je	.L4
	cmpl	$114, %eax
	jne	.L3
	movb	$112, -1(%rbp)
	jmp	.L3
.L2:
	movb	$114, -1(%rbp)
	jmp	.L3
.L4:
	movb	$115, -1(%rbp)
	nop
.L3:
	movzbl	-1(%rbp), %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	win, .-win
	.section	.rodata
.LC0:
	.string	"%d\n"
	.text
	.globl	solver
	.type	solver, @function
solver:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	leaq	-98304(%rsp), %r11
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	subq	$1760, %rsp
	movl	%edi, -100036(%rbp)
	movl	%esi, -100040(%rbp)
	movl	%edx, -100044(%rbp)
	movl	%ecx, -100048(%rbp)
	movl	%r8d, -100052(%rbp)
	movq	%r9, -100064(%rbp)
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -100024(%rbp)
	movl	$0, -100020(%rbp)
	jmp	.L7
.L15:
	movl	-100020(%rbp), %eax
	movslq	%eax, %rdx
	movq	-100064(%rbp), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	movsbl	%al, %eax
	movl	%eax, %edi
	call	win
	movb	%al, -100025(%rbp)
	movl	-100020(%rbp), %eax
	cmpl	-100040(%rbp), %eax
	jl	.L8
	movl	-100020(%rbp), %eax
	subl	-100040(%rbp), %eax
	cltq
	movzbl	-100016(%rbp,%rax), %eax
	cmpb	%al, -100025(%rbp)
	jne	.L8
	movl	-100036(%rbp), %eax
	subl	-100040(%rbp), %eax
	cmpl	%eax, -100020(%rbp)
	jg	.L9
	movl	-100020(%rbp), %edx
	movl	-100040(%rbp), %eax
	addl	%edx, %eax
	movslq	%eax, %rdx
	movq	-100064(%rbp), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	%al, -100025(%rbp)
	jne	.L10
.L9:
	movl	-100020(%rbp), %eax
	movslq	%eax, %rdx
	movq	-100064(%rbp), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	movb	%al, -100025(%rbp)
	jmp	.L12
.L10:
	movl	-100020(%rbp), %edx
	movl	-100040(%rbp), %eax
	addl	%edx, %eax
	movslq	%eax, %rdx
	movq	-100064(%rbp), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	movb	%al, -100025(%rbp)
	jmp	.L12
.L8:
	movsbl	-100025(%rbp), %eax
	cmpl	$115, %eax
	je	.L13
	cmpl	$115, %eax
	jg	.L12
	cmpl	$112, %eax
	je	.L14
	cmpl	$114, %eax
	jne	.L12
	movl	-100044(%rbp), %eax
	addl	%eax, -100024(%rbp)
	jmp	.L12
.L13:
	movl	-100048(%rbp), %eax
	addl	%eax, -100024(%rbp)
	jmp	.L12
.L14:
	movl	-100052(%rbp), %eax
	addl	%eax, -100024(%rbp)
	nop
.L12:
	movl	-100020(%rbp), %eax
	cltq
	movzbl	-100025(%rbp), %edx
	movb	%dl, -100016(%rbp,%rax)
	addl	$1, -100020(%rbp)
.L7:
	movl	-100020(%rbp), %eax
	cmpl	-100036(%rbp), %eax
	jl	.L15
	movl	-100024(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	nop
	movq	-8(%rbp), %rax
	subq	%fs:40, %rax
	je	.L16
	call	__stack_chk_fail@PLT
.L16:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	solver, .-solver
	.section	.rodata
.LC1:
	.string	"%d%d"
.LC2:
	.string	"%d%d%d"
.LC3:
	.string	"%s"
	.text
	.globl	main
	.type	main, @function
main:
.LFB8:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	leaq	-98304(%rsp), %r11
.LPSRL1:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL1
	subq	$1760, %rsp
	movl	%edi, -100052(%rbp)
	movq	%rsi, -100064(%rbp)
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-100032(%rbp), %rdx
	leaq	-100036(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	leaq	-100020(%rbp), %rcx
	leaq	-100024(%rbp), %rdx
	leaq	-100028(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	leaq	-100016(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-100020(%rbp), %edi
	movl	-100024(%rbp), %ecx
	movl	-100028(%rbp), %edx
	movl	-100032(%rbp), %esi
	movl	-100036(%rbp), %eax
	leaq	-100016(%rbp), %r8
	movq	%r8, %r9
	movl	%edi, %r8d
	movl	%eax, %edi
	call	solver
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L19
	call	__stack_chk_fail@PLT
.L19:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.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	win
	.type	win, @function
win:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, %eax
	movb	%al, -20(%rbp)
	movsbl	-20(%rbp), %eax
	cmpl	$115, %eax
	je	.L2
	cmpl	$115, %eax
	jg	.L3
	cmpl	$112, %eax
	je	.L4
	cmpl	$114, %eax
	jne	.L3
	movb	$112, -1(%rbp)
	jmp	.L3
.L2:
	movb	$114, -1(%rbp)
	jmp	.L3
.L4:
	movb	$115, -1(%rbp)
	nop
.L3:
	movzbl	-1(%rbp), %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	win, .-win
	.section	.rodata
.LC0:
	.string	"%d\n"
	.text
	.globl	solver
	.type	solver, @function
solver:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	leaq	-98304(%rsp), %r11
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	subq	$1760, %rsp
	movl	%edi, -100036(%rbp)
	movl	%esi, -100040(%rbp)
	movl	%edx, -100044(%rbp)
	movl	%ecx, -100048(%rbp)
	movl	%r8d, -100052(%rbp)
	movq	%r9, -100064(%rbp)
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -100024(%rbp)
	movl	$0, -100020(%rbp)
	jmp	.L7
.L15:
	movl	-100020(%rbp), %eax
	movslq	%eax, %rdx
	movq	-100064(%rbp), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	movsbl	%al, %eax
	movl	%eax, %edi
	call	win
	movb	%al, -100025(%rbp)
	movl	-100020(%rbp), %eax
	cmpl	-100040(%rbp), %eax
	jl	.L8
	movl	-100020(%rbp), %eax
	subl	-100040(%rbp), %eax
	cltq
	movzbl	-100016(%rbp,%rax), %eax
	cmpb	%al, -100025(%rbp)
	jne	.L8
	movl	-100036(%rbp), %eax
	subl	-100040(%rbp), %eax
	cmpl	%eax, -100020(%rbp)
	jg	.L9
	movl	-100020(%rbp), %edx
	movl	-100040(%rbp), %eax
	addl	%edx, %eax
	movslq	%eax, %rdx
	movq	-100064(%rbp), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	%al, -100025(%rbp)
	jne	.L10
.L9:
	movl	-100020(%rbp), %eax
	movslq	%eax, %rdx
	movq	-100064(%rbp), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	movb	%al, -100025(%rbp)
	jmp	.L12
.L10:
	movl	-100020(%rbp), %edx
	movl	-100040(%rbp), %eax
	addl	%edx, %eax
	movslq	%eax, %rdx
	movq	-100064(%rbp), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	movb	%al, -100025(%rbp)
	jmp	.L12
.L8:
	movsbl	-100025(%rbp), %eax
	cmpl	$115, %eax
	je	.L13
	cmpl	$115, %eax
	jg	.L12
	cmpl	$112, %eax
	je	.L14
	cmpl	$114, %eax
	jne	.L12
	movl	-100044(%rbp), %eax
	addl	%eax, -100024(%rbp)
	jmp	.L12
.L13:
	movl	-100048(%rbp), %eax
	addl	%eax, -100024(%rbp)
	jmp	.L12
.L14:
	movl	-100052(%rbp), %eax
	addl	%eax, -100024(%rbp)
	nop
.L12:
	movl	-100020(%rbp), %eax
	cltq
	movzbl	-100025(%rbp), %edx
	movb	%dl, -100016(%rbp,%rax)
	addl	$1, -100020(%rbp)
.L7:
	movl	-100020(%rbp), %eax
	cmpl	-100036(%rbp), %eax
	jl	.L15
	movl	-100024(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	nop
	movq	-8(%rbp), %rax
	subq	%fs:40, %rax
	je	.L16
	call	__stack_chk_fail@PLT
.L16:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	solver, .-solver
	.section	.rodata
.LC1:
	.string	"%d%d"
.LC2:
	.string	"%d%d%d"
.LC3:
	.string	"%s"
	.text
	.globl	main
	.type	main, @function
main:
.LFB8:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	leaq	-98304(%rsp), %r11
.LPSRL1:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL1
	subq	$1760, %rsp
	movl	%edi, -100052(%rbp)
	movq	%rsi, -100064(%rbp)
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-100032(%rbp), %rdx
	leaq	-100036(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	leaq	-100020(%rbp), %rcx
	leaq	-100024(%rbp), %rdx
	leaq	-100028(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	leaq	-100016(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-100020(%rbp), %edi
	movl	-100024(%rbp), %ecx
	movl	-100028(%rbp), %edx
	movl	-100032(%rbp), %esi
	movl	-100036(%rbp), %eax
	leaq	-100016(%rbp), %r8
	movq	%r8, %r9
	movl	%edi, %r8d
	movl	%eax, %edi
	call	solver
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L19
	call	__stack_chk_fail@PLT
.L19:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.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:
