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()
{
    int n,k,i,count=0;
    char s[100000];
    scanf("%d%d",&n,&k);
    scanf("%s",s);
    for(i=0;i<n;i++)
    {
        if(s[i]=='L')
        {
            if(i!=0&&s[i]==s[i-1]) count++;
        }
        else
            if(i!=(n-1)&&s[i]==s[i+1]) count++;
    }
    count+=2*k;
    if(count<=(n-1)) printf("%d\n",count);
    else printf("%d",n-1);
    return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d%d"
.LC1:
	.string	"%s"
.LC2:
	.string	"%d\n"
.LC3:
	.string	"%d"
	.text
	.globl	main
	.type	main, @function
main:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	leaq	-98304(%rsp), %r11
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	subq	$1728, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -100020(%rbp)
	leaq	-100028(%rbp), %rdx
	leaq	-100032(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	leaq	-100016(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -100024(%rbp)
	jmp	.L2
.L5:
	movl	-100024(%rbp), %eax
	cltq
	movzbl	-100016(%rbp,%rax), %eax
	cmpb	$76, %al
	jne	.L3
	cmpl	$0, -100024(%rbp)
	je	.L4
	movl	-100024(%rbp), %eax
	cltq
	movzbl	-100016(%rbp,%rax), %edx
	movl	-100024(%rbp), %eax
	subl	$1, %eax
	cltq
	movzbl	-100016(%rbp,%rax), %eax
	cmpb	%al, %dl
	jne	.L4
	addl	$1, -100020(%rbp)
	jmp	.L4
.L3:
	movl	-100032(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -100024(%rbp)
	je	.L4
	movl	-100024(%rbp), %eax
	cltq
	movzbl	-100016(%rbp,%rax), %edx
	movl	-100024(%rbp), %eax
	addl	$1, %eax
	cltq
	movzbl	-100016(%rbp,%rax), %eax
	cmpb	%al, %dl
	jne	.L4
	addl	$1, -100020(%rbp)
.L4:
	addl	$1, -100024(%rbp)
.L2:
	movl	-100032(%rbp), %eax
	cmpl	%eax, -100024(%rbp)
	jl	.L5
	movl	-100028(%rbp), %eax
	addl	%eax, %eax
	addl	%eax, -100020(%rbp)
	movl	-100032(%rbp), %eax
	cmpl	%eax, -100020(%rbp)
	jge	.L6
	movl	-100020(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L7
.L6:
	movl	-100032(%rbp), %eax
	subl	$1, %eax
	movl	%eax, %esi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L7:
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L9
	call	__stack_chk_fail@PLT
.L9:
	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	"%s"
.LC2:
	.string	"%d\n"
.LC3:
	.string	"%d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	leaq	-98304(%rsp), %r11
	.cfi_def_cfa 11, 98320
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	.cfi_def_cfa_register 7
	subq	$1728, %rsp
	.cfi_def_cfa_offset 100048
	leaq	.LC0(%rip), %rdi
	movq	%fs:40, %rax
	movq	%rax, 100024(%rsp)
	xorl	%eax, %eax
	leaq	12(%rsp), %rdx
	leaq	8(%rsp), %rsi
	leaq	16(%rsp), %rbx
	call	__isoc99_scanf@PLT
	movq	%rbx, %rsi
	leaq	.LC1(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	8(%rsp), %edx
	testl	%edx, %edx
	jle	.L9
	movq	%rbx, %rcx
	movslq	%edx, %r8
	xorl	%eax, %eax
	xorl	%edi, %edi
	leal	-1(%rdx), %r9d
	jmp	.L5
	.p2align 4,,10
	.p2align 3
.L3:
	cmpl	%eax, %r9d
	je	.L4
	cmpb	1(%rcx), %sil
	sete	%sil
	movzbl	%sil, %esi
	addl	%esi, %edi
.L4:
	addq	$1, %rax
	addq	$1, %rcx
	cmpq	%r8, %rax
	je	.L2
.L5:
	movzbl	(%rcx), %esi
	cmpb	$76, %sil
	jne	.L3
	testq	%rax, %rax
	je	.L4
	xorl	%esi, %esi
	cmpb	$76, -1(%rcx)
	sete	%sil
	addq	$1, %rax
	addq	$1, %rcx
	addl	%esi, %edi
	cmpq	%r8, %rax
	jne	.L5
	.p2align 4,,10
	.p2align 3
.L2:
	movl	12(%rsp), %eax
	leal	(%rdi,%rax,2), %r8d
	cmpl	%edx, %r8d
	jge	.L6
	movl	%r8d, %edx
	leaq	.LC2(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L7:
	movq	100024(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L16
	addq	$100032, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 16
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 8
	ret
.L6:
	.cfi_restore_state
	subl	$1, %edx
	leaq	.LC3(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L7
.L9:
	xorl	%edi, %edi
	jmp	.L2
.L16:
	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	"%s"
.LC2:
	.string	"%d\n"
.LC3:
	.string	"%d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	leaq	-98304(%rsp), %r11
	.cfi_def_cfa 11, 98320
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	.cfi_def_cfa_register 7
	subq	$1728, %rsp
	.cfi_def_cfa_offset 100048
	leaq	.LC0(%rip), %rdi
	movq	%fs:40, %rax
	movq	%rax, 100024(%rsp)
	xorl	%eax, %eax
	leaq	12(%rsp), %rdx
	leaq	8(%rsp), %rsi
	leaq	16(%rsp), %rbx
	call	__isoc99_scanf@PLT
	movq	%rbx, %rsi
	leaq	.LC1(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	8(%rsp), %edx
	testl	%edx, %edx
	jle	.L9
	movq	%rbx, %rcx
	movslq	%edx, %r8
	xorl	%eax, %eax
	xorl	%edi, %edi
	leal	-1(%rdx), %r9d
	jmp	.L5
	.p2align 4,,10
	.p2align 3
.L3:
	cmpl	%eax, %r9d
	je	.L4
	cmpb	1(%rcx), %sil
	sete	%sil
	movzbl	%sil, %esi
	addl	%esi, %edi
.L4:
	addq	$1, %rax
	addq	$1, %rcx
	cmpq	%r8, %rax
	je	.L2
.L5:
	movzbl	(%rcx), %esi
	cmpb	$76, %sil
	jne	.L3
	testq	%rax, %rax
	je	.L4
	xorl	%esi, %esi
	cmpb	$76, -1(%rcx)
	sete	%sil
	addq	$1, %rax
	addq	$1, %rcx
	addl	%esi, %edi
	cmpq	%r8, %rax
	jne	.L5
	.p2align 4,,10
	.p2align 3
.L2:
	movl	12(%rsp), %eax
	leal	(%rdi,%rax,2), %r8d
	cmpl	%edx, %r8d
	jge	.L6
	movl	%r8d, %edx
	leaq	.LC2(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L7:
	movq	100024(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L16
	addq	$100032, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 16
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 8
	ret
.L6:
	.cfi_restore_state
	subl	$1, %edx
	leaq	.LC3(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L7
.L9:
	xorl	%edi, %edi
	jmp	.L2
.L16:
	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()
{
    int n,k,i,count=0;
    char s[100000];
    scanf("%d%d",&n,&k);
    scanf("%s",s);
    for(i=0;i<n;i++)
    {
        if(s[i]=='L')
        {
            if(i!=0&&s[i]==s[i-1]) count++;
        }
        else
            if(i!=(n-1)&&s[i]==s[i+1]) count++;
    }
    count+=2*k;
    if(count<=(n-1)) printf("%d\n",count);
    else printf("%d",n-1);
    return 0;
}
6 2
LRLRRL
 9 3
RRRLRLRLL
 9 0
RRRLRLRLL
 6 0
LRRLRL
 9 1
RRRRLLRLL
 9 1
RLRRLLLRR
 6 1
RRLLRL
 10 2
LLLLLRRRRR
 13 4
LRRLRLRRLRLLR
 13 8
LRRLRLRRLRLLR

5
 8 3
 1
 7
 6
 4
 9 11
 12
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()
{
    int n,k,i,count=0;
    char s[100000];
    scanf("%d%d",&n,&k);
    scanf("%s",s);
    for(i=0;i<n;i++)
    {
        if(s[i]=='L')
        {
            if(i!=0&&s[i]==s[i-1]) count++;
        }
        else
            if(i!=(n-1)&&s[i]==s[i+1]) count++;
    }
    count+=2*k;
    if(count<=(n-1)) printf("%d\n",count);
    else printf("%d",n-1);
    return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d%d"
.LC1:
	.string	"%s"
.LC2:
	.string	"%d\n"
.LC3:
	.string	"%d"
	.text
	.globl	main
	.type	main, @function
main:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	leaq	-98304(%rsp), %r11
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	subq	$1728, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -100020(%rbp)
	leaq	-100028(%rbp), %rdx
	leaq	-100032(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	leaq	-100016(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -100024(%rbp)
	jmp	.L2
.L5:
	movl	-100024(%rbp), %eax
	cltq
	movzbl	-100016(%rbp,%rax), %eax
	cmpb	$76, %al
	jne	.L3
	cmpl	$0, -100024(%rbp)
	je	.L4
	movl	-100024(%rbp), %eax
	cltq
	movzbl	-100016(%rbp,%rax), %edx
	movl	-100024(%rbp), %eax
	subl	$1, %eax
	cltq
	movzbl	-100016(%rbp,%rax), %eax
	cmpb	%al, %dl
	jne	.L4
	addl	$1, -100020(%rbp)
	jmp	.L4
.L3:
	movl	-100032(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -100024(%rbp)
	je	.L4
	movl	-100024(%rbp), %eax
	cltq
	movzbl	-100016(%rbp,%rax), %edx
	movl	-100024(%rbp), %eax
	addl	$1, %eax
	cltq
	movzbl	-100016(%rbp,%rax), %eax
	cmpb	%al, %dl
	jne	.L4
	addl	$1, -100020(%rbp)
.L4:
	addl	$1, -100024(%rbp)
.L2:
	movl	-100032(%rbp), %eax
	cmpl	%eax, -100024(%rbp)
	jl	.L5
	movl	-100028(%rbp), %eax
	addl	%eax, %eax
	addl	%eax, -100020(%rbp)
	movl	-100032(%rbp), %eax
	cmpl	%eax, -100020(%rbp)
	jge	.L6
	movl	-100020(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L7
.L6:
	movl	-100032(%rbp), %eax
	subl	$1, %eax
	movl	%eax, %esi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L7:
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L9
	call	__stack_chk_fail@PLT
.L9:
	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	"%s"
.LC2:
	.string	"%d\n"
.LC3:
	.string	"%d"
	.text
	.globl	main
	.type	main, @function
main:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	leaq	-98304(%rsp), %r11
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	subq	$1728, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -100020(%rbp)
	leaq	-100028(%rbp), %rdx
	leaq	-100032(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	leaq	-100016(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -100024(%rbp)
	jmp	.L2
.L5:
	movl	-100024(%rbp), %eax
	cltq
	movzbl	-100016(%rbp,%rax), %eax
	cmpb	$76, %al
	jne	.L3
	cmpl	$0, -100024(%rbp)
	je	.L4
	movl	-100024(%rbp), %eax
	cltq
	movzbl	-100016(%rbp,%rax), %edx
	movl	-100024(%rbp), %eax
	subl	$1, %eax
	cltq
	movzbl	-100016(%rbp,%rax), %eax
	cmpb	%al, %dl
	jne	.L4
	addl	$1, -100020(%rbp)
	jmp	.L4
.L3:
	movl	-100032(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -100024(%rbp)
	je	.L4
	movl	-100024(%rbp), %eax
	cltq
	movzbl	-100016(%rbp,%rax), %edx
	movl	-100024(%rbp), %eax
	addl	$1, %eax
	cltq
	movzbl	-100016(%rbp,%rax), %eax
	cmpb	%al, %dl
	jne	.L4
	addl	$1, -100020(%rbp)
.L4:
	addl	$1, -100024(%rbp)
.L2:
	movl	-100032(%rbp), %eax
	cmpl	%eax, -100024(%rbp)
	jl	.L5
	movl	-100028(%rbp), %eax
	addl	%eax, %eax
	addl	%eax, -100020(%rbp)
	movl	-100032(%rbp), %eax
	cmpl	%eax, -100020(%rbp)
	jge	.L6
	movl	-100020(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L7
.L6:
	movl	-100032(%rbp), %eax
	subl	$1, %eax
	movl	%eax, %esi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L7:
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L9
	call	__stack_chk_fail@PLT
.L9:
	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:
