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>

int main() {

  int n,i,j,k,sum,t;
  int c[12],count = 0;
  char s[101],kara;

  while(1) {


    //    scanf("%d %c" ,&n,&kara);
    scanf("%d" ,&n);

    if(n == 0) break;

    for(i=0;i<n+1;i++) c[i] = 0;

  scanf("%s",s);

    j = 1;
    sum = 0;



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

      if(j == n+1){
	j = 1;
      }

      if(s[i] == 'M') {
	c[j] += 1;
      } else if(s[i] == 'S') {
	sum += c[j]+1;
	c[j] = 0;
      } else if(s[i] == 'L'){
	c[j] += sum +1;
	sum = 0;
      }
      count++;
      //printf("s = %c c[%d] = %d  sum = %d count = %d\n",s[i],j,c[j],sum,count);
   
      j++;
    }

    for(j=1;j<=n;j++) {
    for(i=1;i<=n;i++) {
      
      if(c[j] < c[i]){
	t = c[j];
	c[j] = c[i];
	c[i] = t;
      }
    }
    }

   

    for(i=1;i<=n;i++){
      printf("%d ",c[i]);
    }

    printf("%d\n",sum);

  }

  return 0;

}
     ```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%s"
.LC2:
	.string	"%d "
.LC3:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$192, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -168(%rbp)
.L19:
	leaq	-184(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-184(%rbp), %eax
	testl	%eax, %eax
	je	.L23
	movl	$0, -180(%rbp)
	jmp	.L4
.L5:
	movl	-180(%rbp), %eax
	cltq
	movl	$0, -160(%rbp,%rax,4)
	addl	$1, -180(%rbp)
.L4:
	movl	-184(%rbp), %eax
	cmpl	%eax, -180(%rbp)
	jle	.L5
	leaq	-112(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$1, -176(%rbp)
	movl	$0, -172(%rbp)
	movl	$0, -180(%rbp)
	jmp	.L6
.L11:
	movl	-184(%rbp), %eax
	addl	$1, %eax
	cmpl	%eax, -176(%rbp)
	jne	.L7
	movl	$1, -176(%rbp)
.L7:
	movl	-180(%rbp), %eax
	cltq
	movzbl	-112(%rbp,%rax), %eax
	cmpb	$77, %al
	jne	.L8
	movl	-176(%rbp), %eax
	cltq
	movl	-160(%rbp,%rax,4), %eax
	leal	1(%rax), %edx
	movl	-176(%rbp), %eax
	cltq
	movl	%edx, -160(%rbp,%rax,4)
	jmp	.L9
.L8:
	movl	-180(%rbp), %eax
	cltq
	movzbl	-112(%rbp,%rax), %eax
	cmpb	$83, %al
	jne	.L10
	movl	-176(%rbp), %eax
	cltq
	movl	-160(%rbp,%rax,4), %eax
	addl	$1, %eax
	addl	%eax, -172(%rbp)
	movl	-176(%rbp), %eax
	cltq
	movl	$0, -160(%rbp,%rax,4)
	jmp	.L9
.L10:
	movl	-180(%rbp), %eax
	cltq
	movzbl	-112(%rbp,%rax), %eax
	cmpb	$76, %al
	jne	.L9
	movl	-176(%rbp), %eax
	cltq
	movl	-160(%rbp,%rax,4), %edx
	movl	-172(%rbp), %eax
	addl	$1, %eax
	addl	%eax, %edx
	movl	-176(%rbp), %eax
	cltq
	movl	%edx, -160(%rbp,%rax,4)
	movl	$0, -172(%rbp)
.L9:
	addl	$1, -168(%rbp)
	addl	$1, -176(%rbp)
	addl	$1, -180(%rbp)
.L6:
	cmpl	$99, -180(%rbp)
	jle	.L11
	movl	$1, -176(%rbp)
	jmp	.L12
.L16:
	movl	$1, -180(%rbp)
	jmp	.L13
.L15:
	movl	-176(%rbp), %eax
	cltq
	movl	-160(%rbp,%rax,4), %edx
	movl	-180(%rbp), %eax
	cltq
	movl	-160(%rbp,%rax,4), %eax
	cmpl	%eax, %edx
	jge	.L14
	movl	-176(%rbp), %eax
	cltq
	movl	-160(%rbp,%rax,4), %eax
	movl	%eax, -164(%rbp)
	movl	-180(%rbp), %eax
	cltq
	movl	-160(%rbp,%rax,4), %edx
	movl	-176(%rbp), %eax
	cltq
	movl	%edx, -160(%rbp,%rax,4)
	movl	-180(%rbp), %eax
	cltq
	movl	-164(%rbp), %edx
	movl	%edx, -160(%rbp,%rax,4)
.L14:
	addl	$1, -180(%rbp)
.L13:
	movl	-184(%rbp), %eax
	cmpl	%eax, -180(%rbp)
	jle	.L15
	addl	$1, -176(%rbp)
.L12:
	movl	-184(%rbp), %eax
	cmpl	%eax, -176(%rbp)
	jle	.L16
	movl	$1, -180(%rbp)
	jmp	.L17
.L18:
	movl	-180(%rbp), %eax
	cltq
	movl	-160(%rbp,%rax,4), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	addl	$1, -180(%rbp)
.L17:
	movl	-184(%rbp), %eax
	cmpl	%eax, -180(%rbp)
	jle	.L18
	movl	-172(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L19
.L23:
	nop
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L21
	call	__stack_chk_fail@PLT
.L21:
	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"
.LC1:
	.string	"%s"
.LC2:
	.string	"%d\n"
.LC3:
	.string	"%d "
	.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
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	leaq	.LC0(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	leaq	.LC3(%rip), %rbx
	subq	$184, %rsp
	.cfi_def_cfa_offset 240
	movq	%fs:40, %rax
	movq	%rax, 168(%rsp)
	xorl	%eax, %eax
	leaq	12(%rsp), %r12
	.p2align 4,,10
	.p2align 3
.L11:
	movq	%r12, %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movslq	12(%rsp), %rax
	testl	%eax, %eax
	je	.L2
	js	.L5
	leaq	16(%rsp), %r13
	leaq	4(,%rax,4), %rdx
	xorl	%esi, %esi
	movq	%r13, %rdi
	call	memset@PLT
.L5:
	leaq	64(%rsp), %r14
	leaq	.LC1(%rip), %rdi
	xorl	%eax, %eax
	movq	%r14, %rsi
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %r9d
	movq	%r14, %rax
	leaq	164(%rsp), %rdi
	xorl	%r14d, %r14d
	movl	$1, %ecx
	leal	1(%r9), %r8d
	jmp	.L4
	.p2align 4,,10
	.p2align 3
.L67:
	movzbl	(%rax), %esi
	movslq	%ecx, %rdx
	addl	$1, %ecx
	cmpb	$77, %sil
	je	.L64
.L7:
	cmpb	$83, %sil
	je	.L65
	cmpb	$76, %sil
	jne	.L8
	movl	16(%rsp,%rdx,4), %esi
	leal	1(%r14,%rsi), %esi
	xorl	%r14d, %r14d
	movl	%esi, 16(%rsp,%rdx,4)
.L8:
	addq	$1, %rax
	cmpq	%rdi, %rax
	je	.L66
.L4:
	cmpl	%ecx, %r8d
	jne	.L67
	movzbl	(%rax), %esi
	movl	$2, %ecx
	movl	$1, %edx
	cmpb	$77, %sil
	jne	.L7
.L64:
	addq	$1, %rax
	addl	$1, 16(%rsp,%rdx,4)
	cmpq	%rdi, %rax
	jne	.L4
.L66:
	testl	%r9d, %r9d
	jle	.L26
	leal	-1(%r9), %edx
	leaq	20(%rsp), %rax
	leaq	24(%rsp,%rdx,4), %rsi
	.p2align 4,,10
	.p2align 3
.L24:
	movl	(%rax), %edx
	movl	20(%rsp), %ecx
	cmpl	%edx, %ecx
	jle	.L12
	movl	%ecx, (%rax)
	movl	%edx, 20(%rsp)
.L12:
	cmpl	$1, %r9d
	je	.L13
	movl	(%rax), %edx
	movl	24(%rsp), %ecx
	cmpl	%edx, %ecx
	jle	.L14
	movl	%ecx, (%rax)
	movl	%edx, 24(%rsp)
.L14:
	cmpl	$2, %r9d
	je	.L13
	movl	(%rax), %edx
	movl	28(%rsp), %ecx
	cmpl	%edx, %ecx
	jle	.L15
	movl	%ecx, (%rax)
	movl	%edx, 28(%rsp)
.L15:
	cmpl	$3, %r9d
	je	.L13
	movl	(%rax), %edx
	movl	32(%rsp), %ecx
	cmpl	%ecx, %edx
	jge	.L16
	movl	%ecx, (%rax)
	movl	%edx, 32(%rsp)
.L16:
	cmpl	$4, %r9d
	je	.L13
	movl	(%rax), %edx
	movl	36(%rsp), %ecx
	cmpl	%ecx, %edx
	jge	.L17
	movl	%ecx, (%rax)
	movl	%edx, 36(%rsp)
.L17:
	cmpl	$5, %r9d
	je	.L13
	movl	(%rax), %edx
	movl	40(%rsp), %ecx
	cmpl	%ecx, %edx
	jge	.L18
	movl	%ecx, (%rax)
	movl	%edx, 40(%rsp)
.L18:
	cmpl	$6, %r9d
	je	.L13
	movl	(%rax), %edx
	movl	44(%rsp), %ecx
	cmpl	%ecx, %edx
	jge	.L19
	movl	%ecx, (%rax)
	movl	%edx, 44(%rsp)
.L19:
	cmpl	$7, %r9d
	je	.L13
	movl	(%rax), %edx
	movl	48(%rsp), %ecx
	cmpl	%ecx, %edx
	jge	.L20
	movl	%ecx, (%rax)
	movl	%edx, 48(%rsp)
.L20:
	cmpl	$8, %r9d
	je	.L13
	movl	(%rax), %edx
	movl	52(%rsp), %ecx
	cmpl	%ecx, %edx
	jge	.L21
	movl	%ecx, (%rax)
	movl	%edx, 52(%rsp)
.L21:
	cmpl	$9, %r9d
	je	.L13
	movl	(%rax), %edx
	movl	56(%rsp), %ecx
	cmpl	%ecx, %edx
	jge	.L22
	movl	%ecx, (%rax)
	movl	%edx, 56(%rsp)
.L22:
	cmpl	$10, %r9d
	je	.L13
	movl	(%rax), %edx
	movl	60(%rsp), %ecx
	cmpl	%ecx, %edx
	jge	.L13
	movl	%ecx, (%rax)
	movl	%edx, 60(%rsp)
	.p2align 4,,10
	.p2align 3
.L13:
	addq	$4, %rax
	cmpq	%rsi, %rax
	jne	.L24
	movl	$1, %r15d
	leaq	16(%rsp), %r13
	.p2align 4,,10
	.p2align 3
.L25:
	movl	0(%r13,%r15,4), %edx
	movq	%rbx, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	addq	$1, %r15
	call	__printf_chk@PLT
	cmpl	%r15d, 12(%rsp)
	jge	.L25
.L26:
	movl	%r14d, %edx
	leaq	.LC2(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L11
	.p2align 4,,10
	.p2align 3
.L65:
	movl	16(%rsp,%rdx,4), %esi
	movl	$0, 16(%rsp,%rdx,4)
	leal	1(%r14,%rsi), %r14d
	jmp	.L8
.L2:
	movq	168(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L68
	addq	$184, %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
.L68:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE35:
	.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"
.LC1:
	.string	"%s"
.LC2:
	.string	"%d\n"
.LC3:
	.string	"%d "
	.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
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	leaq	.LC0(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	leaq	.LC3(%rip), %rbx
	subq	$184, %rsp
	.cfi_def_cfa_offset 240
	movq	%fs:40, %rax
	movq	%rax, 168(%rsp)
	xorl	%eax, %eax
	leaq	12(%rsp), %r12
	.p2align 4,,10
	.p2align 3
.L11:
	movq	%r12, %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movslq	12(%rsp), %rax
	testl	%eax, %eax
	je	.L2
	js	.L5
	leaq	16(%rsp), %r13
	leaq	4(,%rax,4), %rdx
	xorl	%esi, %esi
	movq	%r13, %rdi
	call	memset@PLT
.L5:
	leaq	64(%rsp), %r14
	leaq	.LC1(%rip), %rdi
	xorl	%eax, %eax
	movq	%r14, %rsi
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %r9d
	movq	%r14, %rax
	leaq	164(%rsp), %rdi
	xorl	%r14d, %r14d
	movl	$1, %ecx
	leal	1(%r9), %r8d
	jmp	.L4
	.p2align 4,,10
	.p2align 3
.L67:
	movzbl	(%rax), %esi
	movslq	%ecx, %rdx
	addl	$1, %ecx
	cmpb	$77, %sil
	je	.L64
.L7:
	cmpb	$83, %sil
	je	.L65
	cmpb	$76, %sil
	jne	.L8
	movl	16(%rsp,%rdx,4), %esi
	leal	1(%r14,%rsi), %esi
	xorl	%r14d, %r14d
	movl	%esi, 16(%rsp,%rdx,4)
.L8:
	addq	$1, %rax
	cmpq	%rdi, %rax
	je	.L66
.L4:
	cmpl	%ecx, %r8d
	jne	.L67
	movzbl	(%rax), %esi
	movl	$2, %ecx
	movl	$1, %edx
	cmpb	$77, %sil
	jne	.L7
.L64:
	addq	$1, %rax
	addl	$1, 16(%rsp,%rdx,4)
	cmpq	%rdi, %rax
	jne	.L4
.L66:
	testl	%r9d, %r9d
	jle	.L26
	leal	-1(%r9), %edx
	leaq	20(%rsp), %rax
	leaq	24(%rsp,%rdx,4), %rsi
	.p2align 4,,10
	.p2align 3
.L24:
	movl	(%rax), %edx
	movl	20(%rsp), %ecx
	cmpl	%edx, %ecx
	jle	.L12
	movl	%ecx, (%rax)
	movl	%edx, 20(%rsp)
.L12:
	cmpl	$1, %r9d
	je	.L13
	movl	(%rax), %edx
	movl	24(%rsp), %ecx
	cmpl	%edx, %ecx
	jle	.L14
	movl	%ecx, (%rax)
	movl	%edx, 24(%rsp)
.L14:
	cmpl	$2, %r9d
	je	.L13
	movl	(%rax), %edx
	movl	28(%rsp), %ecx
	cmpl	%edx, %ecx
	jle	.L15
	movl	%ecx, (%rax)
	movl	%edx, 28(%rsp)
.L15:
	cmpl	$3, %r9d
	je	.L13
	movl	(%rax), %edx
	movl	32(%rsp), %ecx
	cmpl	%ecx, %edx
	jge	.L16
	movl	%ecx, (%rax)
	movl	%edx, 32(%rsp)
.L16:
	cmpl	$4, %r9d
	je	.L13
	movl	(%rax), %edx
	movl	36(%rsp), %ecx
	cmpl	%ecx, %edx
	jge	.L17
	movl	%ecx, (%rax)
	movl	%edx, 36(%rsp)
.L17:
	cmpl	$5, %r9d
	je	.L13
	movl	(%rax), %edx
	movl	40(%rsp), %ecx
	cmpl	%ecx, %edx
	jge	.L18
	movl	%ecx, (%rax)
	movl	%edx, 40(%rsp)
.L18:
	cmpl	$6, %r9d
	je	.L13
	movl	(%rax), %edx
	movl	44(%rsp), %ecx
	cmpl	%ecx, %edx
	jge	.L19
	movl	%ecx, (%rax)
	movl	%edx, 44(%rsp)
.L19:
	cmpl	$7, %r9d
	je	.L13
	movl	(%rax), %edx
	movl	48(%rsp), %ecx
	cmpl	%ecx, %edx
	jge	.L20
	movl	%ecx, (%rax)
	movl	%edx, 48(%rsp)
.L20:
	cmpl	$8, %r9d
	je	.L13
	movl	(%rax), %edx
	movl	52(%rsp), %ecx
	cmpl	%ecx, %edx
	jge	.L21
	movl	%ecx, (%rax)
	movl	%edx, 52(%rsp)
.L21:
	cmpl	$9, %r9d
	je	.L13
	movl	(%rax), %edx
	movl	56(%rsp), %ecx
	cmpl	%ecx, %edx
	jge	.L22
	movl	%ecx, (%rax)
	movl	%edx, 56(%rsp)
.L22:
	cmpl	$10, %r9d
	je	.L13
	movl	(%rax), %edx
	movl	60(%rsp), %ecx
	cmpl	%ecx, %edx
	jge	.L13
	movl	%ecx, (%rax)
	movl	%edx, 60(%rsp)
	.p2align 4,,10
	.p2align 3
.L13:
	addq	$4, %rax
	cmpq	%rsi, %rax
	jne	.L24
	movl	$1, %r15d
	leaq	16(%rsp), %r13
	.p2align 4,,10
	.p2align 3
.L25:
	movl	0(%r13,%r15,4), %edx
	movq	%rbx, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	addq	$1, %r15
	call	__printf_chk@PLT
	cmpl	%r15d, 12(%rsp)
	jge	.L25
.L26:
	movl	%r14d, %edx
	leaq	.LC2(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L11
	.p2align 4,,10
	.p2align 3
.L65:
	movl	16(%rsp,%rdx,4), %esi
	movl	$0, 16(%rsp,%rdx,4)
	leal	1(%r14,%rsi), %r14d
	jmp	.L8
.L2:
	movq	168(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L68
	addq	$184, %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
.L68:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE35:
	.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>

int main() {

  int n,i,j,k,sum,t;
  int c[12],count = 0;
  char s[101],kara;

  while(1) {


    //    scanf("%d %c" ,&n,&kara);
    scanf("%d" ,&n);

    if(n == 0) break;

    for(i=0;i<n+1;i++) c[i] = 0;

  scanf("%s",s);

    j = 1;
    sum = 0;



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

      if(j == n+1){
	j = 1;
      }

      if(s[i] == 'M') {
	c[j] += 1;
      } else if(s[i] == 'S') {
	sum += c[j]+1;
	c[j] = 0;
      } else if(s[i] == 'L'){
	c[j] += sum +1;
	sum = 0;
      }
      count++;
      //printf("s = %c c[%d] = %d  sum = %d count = %d\n",s[i],j,c[j],sum,count);
   
      j++;
    }

    for(j=1;j<=n;j++) {
    for(i=1;i<=n;i++) {
      
      if(c[j] < c[i]){
	t = c[j];
	c[j] = c[i];
	c[i] = t;
      }
    }
    }

   

    for(i=1;i<=n;i++){
      printf("%d ",c[i]);
    }

    printf("%d\n",sum);

  }

  return 0;

}
     
2
SSSSSSSSSSSSSSSLLLLLLLLLLLLLLLLLLLLLMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
2
SSSSSSSSSSSSSSLLLLLLLLLLLLLLLLLLLLMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMSL
5
MMMMMMSLSLLMMMSMMSLMMMLMMMMLSLLLLMLSMMLMMLLMSSSLMMMMLMLSSLMSMMMMMMMMMMMMMMLMMMMMSMMMLMMLMMMMMMMMMSSM
0
 2
SSSSSSSSSSSSSSSLLLLLLLLLLLLLLLLLLLLLMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
2
SSSSSSSSSSSSSSLLLLLLLLLLLLLLLLLLLLMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMLMMMMMMSL
5
MMMMMMSLSLLMMMSMMSLMMMLMMMMLSLLLLMLSMMLMMLLMSSSLM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LLLLLLLLLLLLLLLLLLMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMSL
8
MMMMMMSMSLLMMMSMMSLMMMLMMMMLSLLLLMLSMMLMMLLMSSSLMMMMLMLSMLMSMMMMMMMSMMMMMMLMMMMMSMMMLMMLMMMMMMMMMSSM
0
 2
SSSSSSSSSSSSSSSLLLLLLLLLLLLLLLLLLLLLMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
5
SSSSSSSSSSSSSSLLLLLLLLLLLLLLLLLLLLMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMSL
5
MMMMMMSLSLLMMMSMMSLMMMLMMMMLSLLLLMLSMMLMMLLMSSSLMMMMLMLSSLMSMMMMMMMMMMMMMMLMMMMMSMMMLMMLMMMMMMMMMSSM
0

42 58 0
0 100 0
0 0 3 8 16 73
 42 58 0
0 100 0
0 0 3 10 59 28
 42 58 0
0 100 0
1 99
 42 58 0
0 0 100
0 0 3 10 59 28
 42 58 0
0 0 100
 42 58 0
0 100 0
 42 58 0
0 21 21 58 0
0 0 3 8 16 73
 42 58 0
0 100 0
1 1 2 7 81 8
 42 58 0
0 100 0
0 0 2 4 5 6 6 15 62
 42 58 0
0 17 17 17 49 0
0 0 3 8 16 73

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>

int main() {

  int n,i,j,k,sum,t;
  int c[12],count = 0;
  char s[101],kara;

  while(1) {


    //    scanf("%d %c" ,&n,&kara);
    scanf("%d" ,&n);

    if(n == 0) break;

    for(i=0;i<n+1;i++) c[i] = 0;

  scanf("%s",s);

    j = 1;
    sum = 0;



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

      if(j == n+1){
	j = 1;
      }

      if(s[i] == 'M') {
	c[j] += 1;
      } else if(s[i] == 'S') {
	sum += c[j]+1;
	c[j] = 0;
      } else if(s[i] == 'L'){
	c[j] += sum +1;
	sum = 0;
      }
      count++;
      //printf("s = %c c[%d] = %d  sum = %d count = %d\n",s[i],j,c[j],sum,count);
   
      j++;
    }

    for(j=1;j<=n;j++) {
    for(i=1;i<=n;i++) {
      
      if(c[j] < c[i]){
	t = c[j];
	c[j] = c[i];
	c[i] = t;
      }
    }
    }

   

    for(i=1;i<=n;i++){
      printf("%d ",c[i]);
    }

    printf("%d\n",sum);

  }

  return 0;

}
     ```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%s"
.LC2:
	.string	"%d "
.LC3:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$192, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -168(%rbp)
.L19:
	leaq	-184(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-184(%rbp), %eax
	testl	%eax, %eax
	je	.L23
	movl	$0, -180(%rbp)
	jmp	.L4
.L5:
	movl	-180(%rbp), %eax
	cltq
	movl	$0, -160(%rbp,%rax,4)
	addl	$1, -180(%rbp)
.L4:
	movl	-184(%rbp), %eax
	cmpl	%eax, -180(%rbp)
	jle	.L5
	leaq	-112(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$1, -176(%rbp)
	movl	$0, -172(%rbp)
	movl	$0, -180(%rbp)
	jmp	.L6
.L11:
	movl	-184(%rbp), %eax
	addl	$1, %eax
	cmpl	%eax, -176(%rbp)
	jne	.L7
	movl	$1, -176(%rbp)
.L7:
	movl	-180(%rbp), %eax
	cltq
	movzbl	-112(%rbp,%rax), %eax
	cmpb	$77, %al
	jne	.L8
	movl	-176(%rbp), %eax
	cltq
	movl	-160(%rbp,%rax,4), %eax
	leal	1(%rax), %edx
	movl	-176(%rbp), %eax
	cltq
	movl	%edx, -160(%rbp,%rax,4)
	jmp	.L9
.L8:
	movl	-180(%rbp), %eax
	cltq
	movzbl	-112(%rbp,%rax), %eax
	cmpb	$83, %al
	jne	.L10
	movl	-176(%rbp), %eax
	cltq
	movl	-160(%rbp,%rax,4), %eax
	addl	$1, %eax
	addl	%eax, -172(%rbp)
	movl	-176(%rbp), %eax
	cltq
	movl	$0, -160(%rbp,%rax,4)
	jmp	.L9
.L10:
	movl	-180(%rbp), %eax
	cltq
	movzbl	-112(%rbp,%rax), %eax
	cmpb	$76, %al
	jne	.L9
	movl	-176(%rbp), %eax
	cltq
	movl	-160(%rbp,%rax,4), %edx
	movl	-172(%rbp), %eax
	addl	$1, %eax
	addl	%eax, %edx
	movl	-176(%rbp), %eax
	cltq
	movl	%edx, -160(%rbp,%rax,4)
	movl	$0, -172(%rbp)
.L9:
	addl	$1, -168(%rbp)
	addl	$1, -176(%rbp)
	addl	$1, -180(%rbp)
.L6:
	cmpl	$99, -180(%rbp)
	jle	.L11
	movl	$1, -176(%rbp)
	jmp	.L12
.L16:
	movl	$1, -180(%rbp)
	jmp	.L13
.L15:
	movl	-176(%rbp), %eax
	cltq
	movl	-160(%rbp,%rax,4), %edx
	movl	-180(%rbp), %eax
	cltq
	movl	-160(%rbp,%rax,4), %eax
	cmpl	%eax, %edx
	jge	.L14
	movl	-176(%rbp), %eax
	cltq
	movl	-160(%rbp,%rax,4), %eax
	movl	%eax, -164(%rbp)
	movl	-180(%rbp), %eax
	cltq
	movl	-160(%rbp,%rax,4), %edx
	movl	-176(%rbp), %eax
	cltq
	movl	%edx, -160(%rbp,%rax,4)
	movl	-180(%rbp), %eax
	cltq
	movl	-164(%rbp), %edx
	movl	%edx, -160(%rbp,%rax,4)
.L14:
	addl	$1, -180(%rbp)
.L13:
	movl	-184(%rbp), %eax
	cmpl	%eax, -180(%rbp)
	jle	.L15
	addl	$1, -176(%rbp)
.L12:
	movl	-184(%rbp), %eax
	cmpl	%eax, -176(%rbp)
	jle	.L16
	movl	$1, -180(%rbp)
	jmp	.L17
.L18:
	movl	-180(%rbp), %eax
	cltq
	movl	-160(%rbp,%rax,4), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	addl	$1, -180(%rbp)
.L17:
	movl	-184(%rbp), %eax
	cmpl	%eax, -180(%rbp)
	jle	.L18
	movl	-172(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L19
.L23:
	nop
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L21
	call	__stack_chk_fail@PLT
.L21:
	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"
.LC1:
	.string	"%s"
.LC2:
	.string	"%d "
.LC3:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$192, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -168(%rbp)
.L19:
	leaq	-184(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-184(%rbp), %eax
	testl	%eax, %eax
	je	.L23
	movl	$0, -180(%rbp)
	jmp	.L4
.L5:
	movl	-180(%rbp), %eax
	cltq
	movl	$0, -160(%rbp,%rax,4)
	addl	$1, -180(%rbp)
.L4:
	movl	-184(%rbp), %eax
	cmpl	%eax, -180(%rbp)
	jle	.L5
	leaq	-112(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$1, -176(%rbp)
	movl	$0, -172(%rbp)
	movl	$0, -180(%rbp)
	jmp	.L6
.L11:
	movl	-184(%rbp), %eax
	addl	$1, %eax
	cmpl	%eax, -176(%rbp)
	jne	.L7
	movl	$1, -176(%rbp)
.L7:
	movl	-180(%rbp), %eax
	cltq
	movzbl	-112(%rbp,%rax), %eax
	cmpb	$77, %al
	jne	.L8
	movl	-176(%rbp), %eax
	cltq
	movl	-160(%rbp,%rax,4), %eax
	leal	1(%rax), %edx
	movl	-176(%rbp), %eax
	cltq
	movl	%edx, -160(%rbp,%rax,4)
	jmp	.L9
.L8:
	movl	-180(%rbp), %eax
	cltq
	movzbl	-112(%rbp,%rax), %eax
	cmpb	$83, %al
	jne	.L10
	movl	-176(%rbp), %eax
	cltq
	movl	-160(%rbp,%rax,4), %eax
	addl	$1, %eax
	addl	%eax, -172(%rbp)
	movl	-176(%rbp), %eax
	cltq
	movl	$0, -160(%rbp,%rax,4)
	jmp	.L9
.L10:
	movl	-180(%rbp), %eax
	cltq
	movzbl	-112(%rbp,%rax), %eax
	cmpb	$76, %al
	jne	.L9
	movl	-176(%rbp), %eax
	cltq
	movl	-160(%rbp,%rax,4), %edx
	movl	-172(%rbp), %eax
	addl	$1, %eax
	addl	%eax, %edx
	movl	-176(%rbp), %eax
	cltq
	movl	%edx, -160(%rbp,%rax,4)
	movl	$0, -172(%rbp)
.L9:
	addl	$1, -168(%rbp)
	addl	$1, -176(%rbp)
	addl	$1, -180(%rbp)
.L6:
	cmpl	$99, -180(%rbp)
	jle	.L11
	movl	$1, -176(%rbp)
	jmp	.L12
.L16:
	movl	$1, -180(%rbp)
	jmp	.L13
.L15:
	movl	-176(%rbp), %eax
	cltq
	movl	-160(%rbp,%rax,4), %edx
	movl	-180(%rbp), %eax
	cltq
	movl	-160(%rbp,%rax,4), %eax
	cmpl	%eax, %edx
	jge	.L14
	movl	-176(%rbp), %eax
	cltq
	movl	-160(%rbp,%rax,4), %eax
	movl	%eax, -164(%rbp)
	movl	-180(%rbp), %eax
	cltq
	movl	-160(%rbp,%rax,4), %edx
	movl	-176(%rbp), %eax
	cltq
	movl	%edx, -160(%rbp,%rax,4)
	movl	-180(%rbp), %eax
	cltq
	movl	-164(%rbp), %edx
	movl	%edx, -160(%rbp,%rax,4)
.L14:
	addl	$1, -180(%rbp)
.L13:
	movl	-184(%rbp), %eax
	cmpl	%eax, -180(%rbp)
	jle	.L15
	addl	$1, -176(%rbp)
.L12:
	movl	-184(%rbp), %eax
	cmpl	%eax, -176(%rbp)
	jle	.L16
	movl	$1, -180(%rbp)
	jmp	.L17
.L18:
	movl	-180(%rbp), %eax
	cltq
	movl	-160(%rbp,%rax,4), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	addl	$1, -180(%rbp)
.L17:
	movl	-184(%rbp), %eax
	cmpl	%eax, -180(%rbp)
	jle	.L18
	movl	-172(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L19
.L23:
	nop
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L21
	call	__stack_chk_fail@PLT
.L21:
	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:
