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>

int sortfnc(const void *a,const void *b){
	if(*(int *)a > *(int *)b){return 1;}
	if(*(int *)a == *(int *)b){return 0;}
	return -1;
}

int main(void) {
	int n,c[16],field,turn,i;
	char s[128];
	while(scanf("%d",&n) , n != 0){
		scanf("%s",s);
		for(i = 0;i < 16;i++){c[i] = 0;}
		field = 0;
		for(i = 0;i < 100;i++){
			turn = i % n;
			if(s[i] == 'M'){c[turn]++;}
			if(s[i] == 'S'){c[turn]++;field+=c[turn];c[turn] = 0;}
			if(s[i] == 'L'){c[turn]++;c[turn]+=field;field = 0;}
		}
		qsort(c,n,sizeof(int),sortfnc);
		for(i = 0;i < n;i++){printf("%d ",c[i]);}
		printf("%d\n",field);
	}
	return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	sortfnc
	.type	sortfnc, @function
sortfnc:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -8(%rbp)
	movq	%rsi, -16(%rbp)
	movq	-8(%rbp), %rax
	movl	(%rax), %edx
	movq	-16(%rbp), %rax
	movl	(%rax), %eax
	cmpl	%eax, %edx
	jle	.L2
	movl	$1, %eax
	jmp	.L3
.L2:
	movq	-8(%rbp), %rax
	movl	(%rax), %edx
	movq	-16(%rbp), %rax
	movl	(%rax), %eax
	cmpl	%eax, %edx
	jne	.L4
	movl	$0, %eax
	jmp	.L3
.L4:
	movl	$-1, %eax
.L3:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	sortfnc, .-sortfnc
	.section	.rodata
.LC0:
	.string	"%s"
.LC1:
	.string	"%d "
.LC2:
	.string	"%d\n"
.LC3:
	.string	"%d"
	.text
	.globl	main
	.type	main, @function
main:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$224, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	jmp	.L6
.L16:
	leaq	-144(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -216(%rbp)
	jmp	.L7
.L8:
	movl	-216(%rbp), %eax
	cltq
	movl	$0, -208(%rbp,%rax,4)
	addl	$1, -216(%rbp)
.L7:
	cmpl	$15, -216(%rbp)
	jle	.L8
	movl	$0, -220(%rbp)
	movl	$0, -216(%rbp)
	jmp	.L9
.L13:
	movl	-224(%rbp), %ecx
	movl	-216(%rbp), %eax
	cltd
	idivl	%ecx
	movl	%edx, -212(%rbp)
	movl	-216(%rbp), %eax
	cltq
	movzbl	-144(%rbp,%rax), %eax
	cmpb	$77, %al
	jne	.L10
	movl	-212(%rbp), %eax
	cltq
	movl	-208(%rbp,%rax,4), %eax
	leal	1(%rax), %edx
	movl	-212(%rbp), %eax
	cltq
	movl	%edx, -208(%rbp,%rax,4)
.L10:
	movl	-216(%rbp), %eax
	cltq
	movzbl	-144(%rbp,%rax), %eax
	cmpb	$83, %al
	jne	.L11
	movl	-212(%rbp), %eax
	cltq
	movl	-208(%rbp,%rax,4), %eax
	leal	1(%rax), %edx
	movl	-212(%rbp), %eax
	cltq
	movl	%edx, -208(%rbp,%rax,4)
	movl	-212(%rbp), %eax
	cltq
	movl	-208(%rbp,%rax,4), %eax
	addl	%eax, -220(%rbp)
	movl	-212(%rbp), %eax
	cltq
	movl	$0, -208(%rbp,%rax,4)
.L11:
	movl	-216(%rbp), %eax
	cltq
	movzbl	-144(%rbp,%rax), %eax
	cmpb	$76, %al
	jne	.L12
	movl	-212(%rbp), %eax
	cltq
	movl	-208(%rbp,%rax,4), %eax
	leal	1(%rax), %edx
	movl	-212(%rbp), %eax
	cltq
	movl	%edx, -208(%rbp,%rax,4)
	movl	-212(%rbp), %eax
	cltq
	movl	-208(%rbp,%rax,4), %edx
	movl	-220(%rbp), %eax
	addl	%eax, %edx
	movl	-212(%rbp), %eax
	cltq
	movl	%edx, -208(%rbp,%rax,4)
	movl	$0, -220(%rbp)
.L12:
	addl	$1, -216(%rbp)
.L9:
	cmpl	$99, -216(%rbp)
	jle	.L13
	movl	-224(%rbp), %eax
	movslq	%eax, %rsi
	leaq	-208(%rbp), %rax
	leaq	sortfnc(%rip), %rdx
	movq	%rdx, %rcx
	movl	$4, %edx
	movq	%rax, %rdi
	call	qsort@PLT
	movl	$0, -216(%rbp)
	jmp	.L14
.L15:
	movl	-216(%rbp), %eax
	cltq
	movl	-208(%rbp,%rax,4), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	addl	$1, -216(%rbp)
.L14:
	movl	-224(%rbp), %eax
	cmpl	%eax, -216(%rbp)
	jl	.L15
	movl	-220(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L6:
	leaq	-224(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-224(%rbp), %eax
	testl	%eax, %eax
	jne	.L16
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L18
	call	__stack_chk_fail@PLT
.L18:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.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	sortfnc
	.type	sortfnc, @function
sortfnc:
.LFB39:
	.cfi_startproc
	endbr64
	movl	(%rsi), %edx
	movl	$1, %eax
	cmpl	%edx, (%rdi)
	jg	.L1
	setne	%al
	movzbl	%al, %eax
	negl	%eax
.L1:
	ret
	.cfi_endproc
.LFE39:
	.size	sortfnc, .-sortfnc
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%s"
.LC1:
	.string	"%d "
.LC2:
	.string	"%d\n"
.LC3:
	.string	"%d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB40:
	.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	.LC3(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	leaq	.LC1(%rip), %rbx
	subq	$232, %rsp
	.cfi_def_cfa_offset 288
	movq	%fs:40, %rax
	movq	%rax, 216(%rsp)
	xorl	%eax, %eax
	leaq	12(%rsp), %r12
	.p2align 4,,10
	.p2align 3
.L6:
	movq	%r12, %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %eax
	testl	%eax, %eax
	je	.L19
	leaq	80(%rsp), %r14
	leaq	.LC0(%rip), %rdi
	xorl	%eax, %eax
	xorl	%r13d, %r13d
	movq	%r14, %rsi
	call	__isoc99_scanf@PLT
	pxor	%xmm0, %xmm0
	movl	12(%rsp), %edi
	xorl	%ecx, %ecx
	movaps	%xmm0, 16(%rsp)
	movaps	%xmm0, 32(%rsp)
	movaps	%xmm0, 48(%rsp)
	movaps	%xmm0, 64(%rsp)
	jmp	.L11
	.p2align 4,,10
	.p2align 3
.L7:
	cmpb	$83, %al
	je	.L9
	cmpb	$76, %al
	jne	.L8
	movslq	%edx, %rdx
	movl	16(%rsp,%rdx,4), %eax
	leal	1(%r13,%rax), %eax
	xorl	%r13d, %r13d
	movl	%eax, 16(%rsp,%rdx,4)
.L8:
	addq	$1, %rcx
	cmpq	$100, %rcx
	je	.L20
.L11:
	movl	%ecx, %eax
	cltd
	idivl	%edi
	movzbl	(%r14,%rcx), %eax
	cmpb	$77, %al
	jne	.L7
	movslq	%edx, %rdx
	addq	$1, %rcx
	addl	$1, 16(%rsp,%rdx,4)
	cmpq	$100, %rcx
	jne	.L11
.L20:
	leaq	16(%rsp), %r15
	movslq	%edi, %rsi
	movl	$4, %edx
	leaq	sortfnc(%rip), %rcx
	movq	%r15, %rdi
	call	qsort@PLT
	movl	12(%rsp), %edx
	testl	%edx, %edx
	jle	.L12
	xorl	%r14d, %r14d
	.p2align 4,,10
	.p2align 3
.L13:
	movl	(%r15,%r14,4), %edx
	movq	%rbx, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	addq	$1, %r14
	call	__printf_chk@PLT
	cmpl	%r14d, 12(%rsp)
	jg	.L13
.L12:
	movl	%r13d, %edx
	leaq	.LC2(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L9:
	movslq	%edx, %rdx
	movl	16(%rsp,%rdx,4), %eax
	movl	$0, 16(%rsp,%rdx,4)
	leal	1(%r13,%rax), %r13d
	jmp	.L8
.L19:
	movq	216(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L21
	addq	$232, %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
.L21:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE40:
	.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	sortfnc
	.type	sortfnc, @function
sortfnc:
.LFB39:
	.cfi_startproc
	endbr64
	movl	(%rsi), %edx
	movl	$1, %eax
	cmpl	%edx, (%rdi)
	jg	.L1
	setne	%al
	movzbl	%al, %eax
	negl	%eax
.L1:
	ret
	.cfi_endproc
.LFE39:
	.size	sortfnc, .-sortfnc
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%s"
.LC1:
	.string	"%d "
.LC2:
	.string	"%d\n"
.LC3:
	.string	"%d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB40:
	.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	.LC3(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	leaq	.LC1(%rip), %rbx
	subq	$232, %rsp
	.cfi_def_cfa_offset 288
	movq	%fs:40, %rax
	movq	%rax, 216(%rsp)
	xorl	%eax, %eax
	leaq	12(%rsp), %r12
	.p2align 4,,10
	.p2align 3
.L6:
	movq	%r12, %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %eax
	testl	%eax, %eax
	je	.L19
	leaq	80(%rsp), %r14
	leaq	.LC0(%rip), %rdi
	xorl	%eax, %eax
	xorl	%r13d, %r13d
	movq	%r14, %rsi
	call	__isoc99_scanf@PLT
	pxor	%xmm0, %xmm0
	movl	12(%rsp), %edi
	xorl	%ecx, %ecx
	movaps	%xmm0, 16(%rsp)
	movaps	%xmm0, 32(%rsp)
	movaps	%xmm0, 48(%rsp)
	movaps	%xmm0, 64(%rsp)
	jmp	.L11
	.p2align 4,,10
	.p2align 3
.L7:
	cmpb	$83, %al
	je	.L9
	cmpb	$76, %al
	jne	.L8
	movslq	%edx, %rdx
	movl	16(%rsp,%rdx,4), %eax
	leal	1(%r13,%rax), %eax
	xorl	%r13d, %r13d
	movl	%eax, 16(%rsp,%rdx,4)
.L8:
	addq	$1, %rcx
	cmpq	$100, %rcx
	je	.L20
.L11:
	movl	%ecx, %eax
	cltd
	idivl	%edi
	movzbl	(%r14,%rcx), %eax
	cmpb	$77, %al
	jne	.L7
	movslq	%edx, %rdx
	addq	$1, %rcx
	addl	$1, 16(%rsp,%rdx,4)
	cmpq	$100, %rcx
	jne	.L11
.L20:
	leaq	16(%rsp), %r15
	movslq	%edi, %rsi
	movl	$4, %edx
	leaq	sortfnc(%rip), %rcx
	movq	%r15, %rdi
	call	qsort@PLT
	movl	12(%rsp), %edx
	testl	%edx, %edx
	jle	.L12
	xorl	%r14d, %r14d
	.p2align 4,,10
	.p2align 3
.L13:
	movl	(%r15,%r14,4), %edx
	movq	%rbx, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	addq	$1, %r14
	call	__printf_chk@PLT
	cmpl	%r14d, 12(%rsp)
	jg	.L13
.L12:
	movl	%r13d, %edx
	leaq	.LC2(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L9:
	movslq	%edx, %rdx
	movl	16(%rsp,%rdx,4), %eax
	movl	$0, 16(%rsp,%rdx,4)
	leal	1(%r13,%rax), %r13d
	jmp	.L8
.L19:
	movq	216(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L21
	addq	$232, %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
.L21:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE40:
	.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>

int sortfnc(const void *a,const void *b){
	if(*(int *)a > *(int *)b){return 1;}
	if(*(int *)a == *(int *)b){return 0;}
	return -1;
}

int main(void) {
	int n,c[16],field,turn,i;
	char s[128];
	while(scanf("%d",&n) , n != 0){
		scanf("%s",s);
		for(i = 0;i < 16;i++){c[i] = 0;}
		field = 0;
		for(i = 0;i < 100;i++){
			turn = i % n;
			if(s[i] == 'M'){c[turn]++;}
			if(s[i] == 'S'){c[turn]++;field+=c[turn];c[turn] =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MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMSL
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 <stdlib.h>

int sortfnc(const void *a,const void *b){
	if(*(int *)a > *(int *)b){return 1;}
	if(*(int *)a == *(int *)b){return 0;}
	return -1;
}

int main(void) {
	int n,c[16],field,turn,i;
	char s[128];
	while(scanf("%d",&n) , n != 0){
		scanf("%s",s);
		for(i = 0;i < 16;i++){c[i] = 0;}
		field = 0;
		for(i = 0;i < 100;i++){
			turn = i % n;
			if(s[i] == 'M'){c[turn]++;}
			if(s[i] == 'S'){c[turn]++;field+=c[turn];c[turn] = 0;}
			if(s[i] == 'L'){c[turn]++;c[turn]+=field;field = 0;}
		}
		qsort(c,n,sizeof(int),sortfnc);
		for(i = 0;i < n;i++){printf("%d ",c[i]);}
		printf("%d\n",field);
	}
	return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	sortfnc
	.type	sortfnc, @function
sortfnc:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -8(%rbp)
	movq	%rsi, -16(%rbp)
	movq	-8(%rbp), %rax
	movl	(%rax), %edx
	movq	-16(%rbp), %rax
	movl	(%rax), %eax
	cmpl	%eax, %edx
	jle	.L2
	movl	$1, %eax
	jmp	.L3
.L2:
	movq	-8(%rbp), %rax
	movl	(%rax), %edx
	movq	-16(%rbp), %rax
	movl	(%rax), %eax
	cmpl	%eax, %edx
	jne	.L4
	movl	$0, %eax
	jmp	.L3
.L4:
	movl	$-1, %eax
.L3:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	sortfnc, .-sortfnc
	.section	.rodata
.LC0:
	.string	"%s"
.LC1:
	.string	"%d "
.LC2:
	.string	"%d\n"
.LC3:
	.string	"%d"
	.text
	.globl	main
	.type	main, @function
main:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$224, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	jmp	.L6
.L16:
	leaq	-144(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -216(%rbp)
	jmp	.L7
.L8:
	movl	-216(%rbp), %eax
	cltq
	movl	$0, -208(%rbp,%rax,4)
	addl	$1, -216(%rbp)
.L7:
	cmpl	$15, -216(%rbp)
	jle	.L8
	movl	$0, -220(%rbp)
	movl	$0, -216(%rbp)
	jmp	.L9
.L13:
	movl	-224(%rbp), %ecx
	movl	-216(%rbp), %eax
	cltd
	idivl	%ecx
	movl	%edx, -212(%rbp)
	movl	-216(%rbp), %eax
	cltq
	movzbl	-144(%rbp,%rax), %eax
	cmpb	$77, %al
	jne	.L10
	movl	-212(%rbp), %eax
	cltq
	movl	-208(%rbp,%rax,4), %eax
	leal	1(%rax), %edx
	movl	-212(%rbp), %eax
	cltq
	movl	%edx, -208(%rbp,%rax,4)
.L10:
	movl	-216(%rbp), %eax
	cltq
	movzbl	-144(%rbp,%rax), %eax
	cmpb	$83, %al
	jne	.L11
	movl	-212(%rbp), %eax
	cltq
	movl	-208(%rbp,%rax,4), %eax
	leal	1(%rax), %edx
	movl	-212(%rbp), %eax
	cltq
	movl	%edx, -208(%rbp,%rax,4)
	movl	-212(%rbp), %eax
	cltq
	movl	-208(%rbp,%rax,4), %eax
	addl	%eax, -220(%rbp)
	movl	-212(%rbp), %eax
	cltq
	movl	$0, -208(%rbp,%rax,4)
.L11:
	movl	-216(%rbp), %eax
	cltq
	movzbl	-144(%rbp,%rax), %eax
	cmpb	$76, %al
	jne	.L12
	movl	-212(%rbp), %eax
	cltq
	movl	-208(%rbp,%rax,4), %eax
	leal	1(%rax), %edx
	movl	-212(%rbp), %eax
	cltq
	movl	%edx, -208(%rbp,%rax,4)
	movl	-212(%rbp), %eax
	cltq
	movl	-208(%rbp,%rax,4), %edx
	movl	-220(%rbp), %eax
	addl	%eax, %edx
	movl	-212(%rbp), %eax
	cltq
	movl	%edx, -208(%rbp,%rax,4)
	movl	$0, -220(%rbp)
.L12:
	addl	$1, -216(%rbp)
.L9:
	cmpl	$99, -216(%rbp)
	jle	.L13
	movl	-224(%rbp), %eax
	movslq	%eax, %rsi
	leaq	-208(%rbp), %rax
	leaq	sortfnc(%rip), %rdx
	movq	%rdx, %rcx
	movl	$4, %edx
	movq	%rax, %rdi
	call	qsort@PLT
	movl	$0, -216(%rbp)
	jmp	.L14
.L15:
	movl	-216(%rbp), %eax
	cltq
	movl	-208(%rbp,%rax,4), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	addl	$1, -216(%rbp)
.L14:
	movl	-224(%rbp), %eax
	cmpl	%eax, -216(%rbp)
	jl	.L15
	movl	-220(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L6:
	leaq	-224(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-224(%rbp), %eax
	testl	%eax, %eax
	jne	.L16
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L18
	call	__stack_chk_fail@PLT
.L18:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.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	sortfnc
	.type	sortfnc, @function
sortfnc:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -8(%rbp)
	movq	%rsi, -16(%rbp)
	movq	-8(%rbp), %rax
	movl	(%rax), %edx
	movq	-16(%rbp), %rax
	movl	(%rax), %eax
	cmpl	%eax, %edx
	jle	.L2
	movl	$1, %eax
	jmp	.L3
.L2:
	movq	-8(%rbp), %rax
	movl	(%rax), %edx
	movq	-16(%rbp), %rax
	movl	(%rax), %eax
	cmpl	%eax, %edx
	jne	.L4
	movl	$0, %eax
	jmp	.L3
.L4:
	movl	$-1, %eax
.L3:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	sortfnc, .-sortfnc
	.section	.rodata
.LC0:
	.string	"%s"
.LC1:
	.string	"%d "
.LC2:
	.string	"%d\n"
.LC3:
	.string	"%d"
	.text
	.globl	main
	.type	main, @function
main:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$224, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	jmp	.L6
.L16:
	leaq	-144(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -216(%rbp)
	jmp	.L7
.L8:
	movl	-216(%rbp), %eax
	cltq
	movl	$0, -208(%rbp,%rax,4)
	addl	$1, -216(%rbp)
.L7:
	cmpl	$15, -216(%rbp)
	jle	.L8
	movl	$0, -220(%rbp)
	movl	$0, -216(%rbp)
	jmp	.L9
.L13:
	movl	-224(%rbp), %ecx
	movl	-216(%rbp), %eax
	cltd
	idivl	%ecx
	movl	%edx, -212(%rbp)
	movl	-216(%rbp), %eax
	cltq
	movzbl	-144(%rbp,%rax), %eax
	cmpb	$77, %al
	jne	.L10
	movl	-212(%rbp), %eax
	cltq
	movl	-208(%rbp,%rax,4), %eax
	leal	1(%rax), %edx
	movl	-212(%rbp), %eax
	cltq
	movl	%edx, -208(%rbp,%rax,4)
.L10:
	movl	-216(%rbp), %eax
	cltq
	movzbl	-144(%rbp,%rax), %eax
	cmpb	$83, %al
	jne	.L11
	movl	-212(%rbp), %eax
	cltq
	movl	-208(%rbp,%rax,4), %eax
	leal	1(%rax), %edx
	movl	-212(%rbp), %eax
	cltq
	movl	%edx, -208(%rbp,%rax,4)
	movl	-212(%rbp), %eax
	cltq
	movl	-208(%rbp,%rax,4), %eax
	addl	%eax, -220(%rbp)
	movl	-212(%rbp), %eax
	cltq
	movl	$0, -208(%rbp,%rax,4)
.L11:
	movl	-216(%rbp), %eax
	cltq
	movzbl	-144(%rbp,%rax), %eax
	cmpb	$76, %al
	jne	.L12
	movl	-212(%rbp), %eax
	cltq
	movl	-208(%rbp,%rax,4), %eax
	leal	1(%rax), %edx
	movl	-212(%rbp), %eax
	cltq
	movl	%edx, -208(%rbp,%rax,4)
	movl	-212(%rbp), %eax
	cltq
	movl	-208(%rbp,%rax,4), %edx
	movl	-220(%rbp), %eax
	addl	%eax, %edx
	movl	-212(%rbp), %eax
	cltq
	movl	%edx, -208(%rbp,%rax,4)
	movl	$0, -220(%rbp)
.L12:
	addl	$1, -216(%rbp)
.L9:
	cmpl	$99, -216(%rbp)
	jle	.L13
	movl	-224(%rbp), %eax
	movslq	%eax, %rsi
	leaq	-208(%rbp), %rax
	leaq	sortfnc(%rip), %rdx
	movq	%rdx, %rcx
	movl	$4, %edx
	movq	%rax, %rdi
	call	qsort@PLT
	movl	$0, -216(%rbp)
	jmp	.L14
.L15:
	movl	-216(%rbp), %eax
	cltq
	movl	-208(%rbp,%rax,4), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	addl	$1, -216(%rbp)
.L14:
	movl	-224(%rbp), %eax
	cmpl	%eax, -216(%rbp)
	jl	.L15
	movl	-220(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L6:
	leaq	-224(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-224(%rbp), %eax
	testl	%eax, %eax
	jne	.L16
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L18
	call	__stack_chk_fail@PLT
.L18:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.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:
