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>
typedef struct 
{
  char mark;
  int number;
}card;

void bubblesort(card*,int);
void selectionsort(card*,card*,int);

int main(){
  int n,i,j,t;
   card detail[36],detail2[36];
  char a;
  

  scanf("%d",&n);
  
  for(i=0; i<n; i++)
    {
    scanf(" %c%c",&detail[i].mark,&a);
    detail[i].number = atoi(&a);
  }

  for(i=0; i<n; i++)
  detail2[i]=detail[i];
  bubblesort(detail,n);
  selectionsort(detail,detail2,n);
  return 0;
}
  

void bubblesort(card a[],int n){
  int i,j;
  card tmp;
  for(i=0;i<n;i++){
    for(j=n-1;j>i;j--){
      if(a[j].number<a[j-1].number){
	tmp=a[j];  //swap
	a[j]=a[j-1];
	a[j-1]=tmp;
      }
    }
  }

  for(i=0; i<n; i++){
    if(i>0)printf(" ");
    printf("%c%d",a[i].mark,a[i].number);
  }

  printf("\n");
  printf("Stable\n");    
}


void  selectionsort(card a[],card a2[],int n){
  int i,j,minj,count=0;
  card tmp;
  for(i=0; i<=n; i++){
    minj=i;
    for(j=i; j<n; j++){
      if(a2[j].number<a2[minj].number){
	minj=j;
      }
    }
    tmp=a2[i];
    a2[i]=a2[minj];
    a2[minj]=tmp;
}
  for(i=0; i<n; i++){
    if(i>0)printf(" ");
    printf("%c%d",a2[i].mark,a2[i].number);
  }
  printf("\n");

  for(i=0;i<n;i++){
    if(a[i].mark != a2[i].mark || a[i].number != a2[i].number){
      printf("Not stable\n");
      count=1;
      break;
    }
  }
  if(count == 0) printf("Stable\n");
  
}

 

```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	" %c%c"
	.text
	.globl	main
	.type	main, @function
main:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$608, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-600(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -596(%rbp)
	jmp	.L2
.L3:
	leaq	-592(%rbp), %rdx
	movl	-596(%rbp), %eax
	cltq
	salq	$3, %rax
	leaq	(%rdx,%rax), %rcx
	leaq	-601(%rbp), %rax
	movq	%rax, %rdx
	movq	%rcx, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	leaq	-601(%rbp), %rax
	movq	%rax, %rdi
	call	atoi@PLT
	movl	-596(%rbp), %edx
	movslq	%edx, %rdx
	movl	%eax, -588(%rbp,%rdx,8)
	addl	$1, -596(%rbp)
.L2:
	movl	-600(%rbp), %eax
	cmpl	%eax, -596(%rbp)
	jl	.L3
	movl	$0, -596(%rbp)
	jmp	.L4
.L5:
	movl	-596(%rbp), %eax
	cltq
	movl	-596(%rbp), %edx
	movslq	%edx, %rdx
	movq	-592(%rbp,%rdx,8), %rdx
	movq	%rdx, -304(%rbp,%rax,8)
	addl	$1, -596(%rbp)
.L4:
	movl	-600(%rbp), %eax
	cmpl	%eax, -596(%rbp)
	jl	.L5
	movl	-600(%rbp), %edx
	leaq	-592(%rbp), %rax
	movl	%edx, %esi
	movq	%rax, %rdi
	call	bubblesort
	movl	-600(%rbp), %edx
	leaq	-304(%rbp), %rcx
	leaq	-592(%rbp), %rax
	movq	%rcx, %rsi
	movq	%rax, %rdi
	call	selectionsort
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L7
	call	__stack_chk_fail@PLT
.L7:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	main, .-main
	.section	.rodata
.LC2:
	.string	"%c%d"
.LC3:
	.string	"Stable"
	.text
	.globl	bubblesort
	.type	bubblesort, @function
bubblesort:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movq	%rdi, -24(%rbp)
	movl	%esi, -28(%rbp)
	movl	$0, -16(%rbp)
	jmp	.L9
.L13:
	movl	-28(%rbp), %eax
	subl	$1, %eax
	movl	%eax, -12(%rbp)
	jmp	.L10
.L12:
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	4(%rax), %edx
	movl	-12(%rbp), %eax
	cltq
	salq	$3, %rax
	leaq	-8(%rax), %rcx
	movq	-24(%rbp), %rax
	addq	%rcx, %rax
	movl	4(%rax), %eax
	cmpl	%eax, %edx
	jge	.L11
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rax
	movq	%rax, -8(%rbp)
	movl	-12(%rbp), %eax
	cltq
	salq	$3, %rax
	leaq	-8(%rax), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	-12(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,8), %rcx
	movq	-24(%rbp), %rdx
	addq	%rcx, %rdx
	movq	(%rax), %rax
	movq	%rax, (%rdx)
	movl	-12(%rbp), %eax
	cltq
	salq	$3, %rax
	leaq	-8(%rax), %rdx
	movq	-24(%rbp), %rax
	addq	%rax, %rdx
	movq	-8(%rbp), %rax
	movq	%rax, (%rdx)
.L11:
	subl	$1, -12(%rbp)
.L10:
	movl	-12(%rbp), %eax
	cmpl	-16(%rbp), %eax
	jg	.L12
	addl	$1, -16(%rbp)
.L9:
	movl	-16(%rbp), %eax
	cmpl	-28(%rbp), %eax
	jl	.L13
	movl	$0, -16(%rbp)
	jmp	.L14
.L16:
	cmpl	$0, -16(%rbp)
	jle	.L15
	movl	$32, %edi
	call	putchar@PLT
.L15:
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	4(%rax), %edx
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rcx
	movq	-24(%rbp), %rax
	addq	%rcx, %rax
	movzbl	(%rax), %eax
	movsbl	%al, %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	addl	$1, -16(%rbp)
.L14:
	movl	-16(%rbp), %eax
	cmpl	-28(%rbp), %eax
	jl	.L16
	movl	$10, %edi
	call	putchar@PLT
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	bubblesort, .-bubblesort
	.section	.rodata
.LC4:
	.string	"Not stable"
	.text
	.globl	selectionsort
	.type	selectionsort, @function
selectionsort:
.LFB8:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$64, %rsp
	movq	%rdi, -40(%rbp)
	movq	%rsi, -48(%rbp)
	movl	%edx, -52(%rbp)
	movl	$0, -12(%rbp)
	movl	$0, -24(%rbp)
	jmp	.L18
.L22:
	movl	-24(%rbp), %eax
	movl	%eax, -16(%rbp)
	movl	-24(%rbp), %eax
	movl	%eax, -20(%rbp)
	jmp	.L19
.L21:
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-48(%rbp), %rax
	addq	%rdx, %rax
	movl	4(%rax), %edx
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rcx
	movq	-48(%rbp), %rax
	addq	%rcx, %rax
	movl	4(%rax), %eax
	cmpl	%eax, %edx
	jge	.L20
	movl	-20(%rbp), %eax
	movl	%eax, -16(%rbp)
.L20:
	addl	$1, -20(%rbp)
.L19:
	movl	-20(%rbp), %eax
	cmpl	-52(%rbp), %eax
	jl	.L21
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-48(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rax
	movq	%rax, -8(%rbp)
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-48(%rbp), %rax
	addq	%rdx, %rax
	movl	-24(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,8), %rcx
	movq	-48(%rbp), %rdx
	addq	%rcx, %rdx
	movq	(%rax), %rax
	movq	%rax, (%rdx)
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-48(%rbp), %rax
	addq	%rax, %rdx
	movq	-8(%rbp), %rax
	movq	%rax, (%rdx)
	addl	$1, -24(%rbp)
.L18:
	movl	-24(%rbp), %eax
	cmpl	-52(%rbp), %eax
	jle	.L22
	movl	$0, -24(%rbp)
	jmp	.L23
.L25:
	cmpl	$0, -24(%rbp)
	jle	.L24
	movl	$32, %edi
	call	putchar@PLT
.L24:
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-48(%rbp), %rax
	addq	%rdx, %rax
	movl	4(%rax), %edx
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rcx
	movq	-48(%rbp), %rax
	addq	%rcx, %rax
	movzbl	(%rax), %eax
	movsbl	%al, %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	addl	$1, -24(%rbp)
.L23:
	movl	-24(%rbp), %eax
	cmpl	-52(%rbp), %eax
	jl	.L25
	movl	$10, %edi
	call	putchar@PLT
	movl	$0, -24(%rbp)
	jmp	.L26
.L30:
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-40(%rbp), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %edx
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rcx
	movq	-48(%rbp), %rax
	addq	%rcx, %rax
	movzbl	(%rax), %eax
	cmpb	%al, %dl
	jne	.L27
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-40(%rbp), %rax
	addq	%rdx, %rax
	movl	4(%rax), %edx
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rcx
	movq	-48(%rbp), %rax
	addq	%rcx, %rax
	movl	4(%rax), %eax
	cmpl	%eax, %edx
	je	.L28
.L27:
	leaq	.LC4(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	movl	$1, -12(%rbp)
	jmp	.L29
.L28:
	addl	$1, -24(%rbp)
.L26:
	movl	-24(%rbp), %eax
	cmpl	-52(%rbp), %eax
	jl	.L30
.L29:
	cmpl	$0, -12(%rbp)
	jne	.L32
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
.L32:
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.size	selectionsort, .-selectionsort
	.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	"Stable"
.LC1:
	.string	"%c%d"
	.text
	.p2align 4
	.globl	bubblesort
	.type	bubblesort, @function
bubblesort:
.LFB40:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	subq	$8, %rsp
	.cfi_def_cfa_offset 48
	testl	%esi, %esi
	jle	.L10
	movl	%esi, %r9d
	movq	%rdi, %rbx
	movslq	%esi, %rbp
	subl	$1, %r9d
	je	.L3
	leaq	(%rdi,%rbp,8), %r10
	xorl	%esi, %esi
	.p2align 4,,10
	.p2align 3
.L5:
	movq	%r10, %rax
	movl	%r9d, %edx
	.p2align 4,,10
	.p2align 3
.L4:
	movl	-4(%rax), %ecx
	cmpl	-12(%rax), %ecx
	jge	.L6
	movq	-16(%rax), %r8
	movzbl	-8(%rax), %edi
	movl	%ecx, -12(%rax)
	movq	%r8, -8(%rax)
	movb	%dil, -16(%rax)
.L6:
	subl	$1, %edx
	subq	$8, %rax
	cmpl	%esi, %edx
	jg	.L4
	addl	$1, %esi
	cmpl	%r9d, %esi
	jl	.L5
.L3:
	xorl	%r12d, %r12d
	leaq	.LC1(%rip), %r13
.L11:
	testq	%r12, %r12
	jne	.L18
	movl	4(%rbx,%r12,8), %ecx
	movsbl	(%rbx,%r12,8), %edx
	movq	%r13, %rsi
	xorl	%eax, %eax
	movl	$1, %edi
	movl	$1, %r12d
	call	__printf_chk@PLT
	cmpq	%rbp, %r12
	je	.L10
.L18:
	movl	$32, %edi
	call	putchar@PLT
	movl	4(%rbx,%r12,8), %ecx
	movq	%r13, %rsi
	xorl	%eax, %eax
	movsbl	(%rbx,%r12,8), %edx
	movl	$1, %edi
	addq	$1, %r12
	call	__printf_chk@PLT
	cmpq	%rbp, %r12
	jne	.L11
.L10:
	movl	$10, %edi
	call	putchar@PLT
	addq	$8, %rsp
	.cfi_def_cfa_offset 40
	leaq	.LC0(%rip), %rdi
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	jmp	puts@PLT
	.cfi_endproc
.LFE40:
	.size	bubblesort, .-bubblesort
	.section	.rodata.str1.1
.LC2:
	.string	"Not stable"
	.text
	.p2align 4
	.globl	selectionsort
	.type	selectionsort, @function
selectionsort:
.LFB41:
	.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
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$8, %rsp
	.cfi_def_cfa_offset 64
	testl	%edx, %edx
	js	.L22
	movq	%rdi, %rbx
	movq	%rsi, %r12
	movl	%edx, %ebp
	jne	.L23
	xorl	%r9d, %r9d
	.p2align 4,,10
	.p2align 3
.L28:
	addl	$1, %r9d
	cmpl	%r9d, %ebp
	jge	.L28
	testl	%ebp, %ebp
	jle	.L22
	leal	-1(%rbp), %eax
	movq	%r12, %r13
	leaq	.LC1(%rip), %r14
	leaq	8(%r12,%rax,8), %r15
	jmp	.L30
	.p2align 4,,10
	.p2align 3
.L31:
	movl	$32, %edi
	call	putchar@PLT
.L30:
	movl	4(%r13), %ecx
	movsbl	0(%r13), %edx
	movq	%r14, %rsi
	xorl	%eax, %eax
	movl	$1, %edi
	addq	$8, %r13
	call	__printf_chk@PLT
	cmpq	%r15, %r13
	jne	.L31
	movl	$10, %edi
	movl	%ebp, %ebp
	call	putchar@PLT
	xorl	%eax, %eax
	jmp	.L35
	.p2align 4,,10
	.p2align 3
.L46:
	movl	4(%r12,%rax,8), %esi
	cmpl	%esi, 4(%rbx,%rax,8)
	jne	.L33
	addq	$1, %rax
	cmpq	%rbp, %rax
	je	.L36
.L35:
	movzbl	(%r12,%rax,8), %edi
	cmpb	%dil, (%rbx,%rax,8)
	je	.L46
.L33:
	leaq	.LC2(%rip), %rdi
.L45:
	addq	$8, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	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
	jmp	puts@PLT
	.p2align 4,,10
	.p2align 3
.L23:
	.cfi_restore_state
	movq	%rsi, %r10
	xorl	%r9d, %r9d
	.p2align 4,,10
	.p2align 3
.L27:
	movl	4(%r10), %r11d
	movq	%r10, %rax
	movl	%r9d, %r8d
	movl	%r9d, %edx
	movl	%r11d, %edi
	jmp	.L26
	.p2align 4,,10
	.p2align 3
.L48:
	movslq	%r8d, %rcx
	addl	$1, %edx
	addq	$8, %rax
	leaq	(%r12,%rcx,8), %rsi
	cmpl	%edx, %ebp
	jle	.L47
.L26:
	movl	4(%rax), %ecx
	movq	%rax, %rsi
	cmpl	%edi, %ecx
	jge	.L48
	movl	%edx, %r8d
	addl	$1, %edx
	movl	%ecx, %edi
	addq	$8, %rax
	cmpl	%edx, %ebp
	jg	.L26
.L47:
	movzbl	(%r10), %eax
	movq	(%rsi), %rdx
	addl	$1, %r9d
	addq	$8, %r10
	movq	%rdx, -8(%r10)
	movb	%al, (%rsi)
	movl	%r11d, 4(%rsi)
	cmpl	%r9d, %ebp
	jne	.L27
	jmp	.L28
.L22:
	movl	$10, %edi
	call	putchar@PLT
.L36:
	leaq	.LC0(%rip), %rdi
	jmp	.L45
	.cfi_endproc
.LFE41:
	.size	selectionsort, .-selectionsort
	.section	.rodata.str1.1
.LC3:
	.string	"%d"
.LC4:
	.string	" %c%c"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB39:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	leaq	.LC3(%rip), %rdi
	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
	subq	$608, %rsp
	.cfi_def_cfa_offset 656
	movq	%fs:40, %rax
	movq	%rax, 600(%rsp)
	xorl	%eax, %eax
	leaq	12(%rsp), %rsi
	leaq	16(%rsp), %r14
	leaq	304(%rsp), %rbp
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %r8d
	testl	%r8d, %r8d
	jle	.L50
	movq	%r14, %rbx
	xorl	%ebp, %ebp
	leaq	11(%rsp), %r12
	leaq	.LC4(%rip), %r13
	.p2align 4,,10
	.p2align 3
.L51:
	movq	%rbx, %rsi
	movq	%r12, %rdx
	movq	%r13, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	$10, %edx
	xorl	%esi, %esi
	movq	%r12, %rdi
	call	strtol@PLT
	movl	12(%rsp), %r8d
	addl	$1, %ebp
	addq	$8, %rbx
	movl	%eax, -4(%rbx)
	cmpl	%ebp, %r8d
	jg	.L51
	leaq	304(%rsp), %rbp
	testl	%r8d, %r8d
	jle	.L50
	movl	%r8d, %ecx
	movq	%rbp, %rdi
	movq	%r14, %rsi
	andl	$536870911, %ecx
	rep movsq
.L50:
	movl	%r8d, %esi
	movq	%r14, %rdi
	call	bubblesort
	movl	12(%rsp), %edx
	movq	%rbp, %rsi
	movq	%r14, %rdi
	call	selectionsort
	movq	600(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L62
	addq	$608, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 48
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 40
	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
	ret
.L62:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE39:
	.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	"Stable"
.LC1:
	.string	"%c%d"
	.text
	.p2align 4
	.globl	bubblesort
	.type	bubblesort, @function
bubblesort:
.LFB40:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	subq	$8, %rsp
	.cfi_def_cfa_offset 48
	testl	%esi, %esi
	jle	.L10
	movl	%esi, %r9d
	movq	%rdi, %rbx
	movslq	%esi, %rbp
	subl	$1, %r9d
	je	.L3
	leaq	(%rdi,%rbp,8), %r10
	xorl	%esi, %esi
	.p2align 4,,10
	.p2align 3
.L5:
	movq	%r10, %rax
	movl	%r9d, %edx
	.p2align 4,,10
	.p2align 3
.L4:
	movl	-4(%rax), %ecx
	cmpl	-12(%rax), %ecx
	jge	.L6
	movq	-16(%rax), %r8
	movzbl	-8(%rax), %edi
	movl	%ecx, -12(%rax)
	movq	%r8, -8(%rax)
	movb	%dil, -16(%rax)
.L6:
	subl	$1, %edx
	subq	$8, %rax
	cmpl	%esi, %edx
	jg	.L4
	addl	$1, %esi
	cmpl	%r9d, %esi
	jl	.L5
.L3:
	xorl	%r12d, %r12d
	leaq	.LC1(%rip), %r13
.L11:
	testq	%r12, %r12
	jne	.L18
	movl	4(%rbx,%r12,8), %ecx
	movsbl	(%rbx,%r12,8), %edx
	movq	%r13, %rsi
	xorl	%eax, %eax
	movl	$1, %edi
	movl	$1, %r12d
	call	__printf_chk@PLT
	cmpq	%rbp, %r12
	je	.L10
.L18:
	movl	$32, %edi
	call	putchar@PLT
	movl	4(%rbx,%r12,8), %ecx
	movq	%r13, %rsi
	xorl	%eax, %eax
	movsbl	(%rbx,%r12,8), %edx
	movl	$1, %edi
	addq	$1, %r12
	call	__printf_chk@PLT
	cmpq	%rbp, %r12
	jne	.L11
.L10:
	movl	$10, %edi
	call	putchar@PLT
	addq	$8, %rsp
	.cfi_def_cfa_offset 40
	leaq	.LC0(%rip), %rdi
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	jmp	puts@PLT
	.cfi_endproc
.LFE40:
	.size	bubblesort, .-bubblesort
	.section	.rodata.str1.1
.LC2:
	.string	"Not stable"
	.text
	.p2align 4
	.globl	selectionsort
	.type	selectionsort, @function
selectionsort:
.LFB41:
	.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
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$8, %rsp
	.cfi_def_cfa_offset 64
	testl	%edx, %edx
	js	.L22
	movq	%rdi, %rbx
	movq	%rsi, %r12
	movl	%edx, %ebp
	jne	.L23
	xorl	%r9d, %r9d
	.p2align 4,,10
	.p2align 3
.L28:
	addl	$1, %r9d
	cmpl	%r9d, %ebp
	jge	.L28
	testl	%ebp, %ebp
	jle	.L22
	leal	-1(%rbp), %eax
	movq	%r12, %r13
	leaq	.LC1(%rip), %r14
	leaq	8(%r12,%rax,8), %r15
	jmp	.L30
	.p2align 4,,10
	.p2align 3
.L31:
	movl	$32, %edi
	call	putchar@PLT
.L30:
	movl	4(%r13), %ecx
	movsbl	0(%r13), %edx
	movq	%r14, %rsi
	xorl	%eax, %eax
	movl	$1, %edi
	addq	$8, %r13
	call	__printf_chk@PLT
	cmpq	%r15, %r13
	jne	.L31
	movl	$10, %edi
	movl	%ebp, %ebp
	call	putchar@PLT
	xorl	%eax, %eax
	jmp	.L35
	.p2align 4,,10
	.p2align 3
.L46:
	movl	4(%r12,%rax,8), %esi
	cmpl	%esi, 4(%rbx,%rax,8)
	jne	.L33
	addq	$1, %rax
	cmpq	%rbp, %rax
	je	.L36
.L35:
	movzbl	(%r12,%rax,8), %edi
	cmpb	%dil, (%rbx,%rax,8)
	je	.L46
.L33:
	leaq	.LC2(%rip), %rdi
.L45:
	addq	$8, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	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
	jmp	puts@PLT
	.p2align 4,,10
	.p2align 3
.L23:
	.cfi_restore_state
	movq	%rsi, %r10
	xorl	%r9d, %r9d
	.p2align 4,,10
	.p2align 3
.L27:
	movl	4(%r10), %r11d
	movq	%r10, %rax
	movl	%r9d, %r8d
	movl	%r9d, %edx
	movl	%r11d, %edi
	jmp	.L26
	.p2align 4,,10
	.p2align 3
.L48:
	movslq	%r8d, %rcx
	addl	$1, %edx
	addq	$8, %rax
	leaq	(%r12,%rcx,8), %rsi
	cmpl	%edx, %ebp
	jle	.L47
.L26:
	movl	4(%rax), %ecx
	movq	%rax, %rsi
	cmpl	%edi, %ecx
	jge	.L48
	movl	%edx, %r8d
	addl	$1, %edx
	movl	%ecx, %edi
	addq	$8, %rax
	cmpl	%edx, %ebp
	jg	.L26
.L47:
	movzbl	(%r10), %eax
	movq	(%rsi), %rdx
	addl	$1, %r9d
	addq	$8, %r10
	movq	%rdx, -8(%r10)
	movb	%al, (%rsi)
	movl	%r11d, 4(%rsi)
	cmpl	%r9d, %ebp
	jne	.L27
	jmp	.L28
.L22:
	movl	$10, %edi
	call	putchar@PLT
.L36:
	leaq	.LC0(%rip), %rdi
	jmp	.L45
	.cfi_endproc
.LFE41:
	.size	selectionsort, .-selectionsort
	.section	.rodata.str1.1
.LC3:
	.string	"%d"
.LC4:
	.string	" %c%c"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB39:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	leaq	.LC3(%rip), %rdi
	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
	subq	$608, %rsp
	.cfi_def_cfa_offset 656
	movq	%fs:40, %rax
	movq	%rax, 600(%rsp)
	xorl	%eax, %eax
	leaq	12(%rsp), %rsi
	leaq	16(%rsp), %r14
	leaq	304(%rsp), %rbp
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %r8d
	testl	%r8d, %r8d
	jle	.L50
	movq	%r14, %rbx
	xorl	%ebp, %ebp
	leaq	11(%rsp), %r12
	leaq	.LC4(%rip), %r13
	.p2align 4,,10
	.p2align 3
.L51:
	movq	%rbx, %rsi
	movq	%r12, %rdx
	movq	%r13, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	$10, %edx
	xorl	%esi, %esi
	movq	%r12, %rdi
	call	strtol@PLT
	movl	12(%rsp), %r8d
	addl	$1, %ebp
	addq	$8, %rbx
	movl	%eax, -4(%rbx)
	cmpl	%ebp, %r8d
	jg	.L51
	leaq	304(%rsp), %rbp
	testl	%r8d, %r8d
	jle	.L50
	movl	%r8d, %ecx
	movq	%rbp, %rdi
	movq	%r14, %rsi
	andl	$536870911, %ecx
	rep movsq
.L50:
	movl	%r8d, %esi
	movq	%r14, %rdi
	call	bubblesort
	movl	12(%rsp), %edx
	movq	%rbp, %rsi
	movq	%r14, %rdi
	call	selectionsort
	movq	600(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L62
	addq	$608, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 48
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 40
	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
	ret
.L62:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE39:
	.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>
typedef struct 
{
  char mark;
  int number;
}card;

void bubblesort(card*,int);
void selectionsort(card*,card*,int);

int main(){
  int n,i,j,t;
   card detail[36],detail2[36];
  char a;
  

  scanf("%d",&n);
  
  for(i=0; i<n; i++)
    {
    scanf(" %c%c",&detail[i].mark,&a);
    detail[i].number = atoi(&a);
  }

  for(i=0; i<n; i++)
  detail2[i]=detail[i];
  bubblesort(detail,n);
  selectionsort(detail,detail2,n);
  return 0;
}
  

void bubblesort(card a[],int n){
  int i,j;
  card tmp;
  for(i=0;i<n;i++){
    for(j=n-1;j>i;j--){
      if(a[j].number<a[j-1].number){
	tmp=a[j];  //swap
	a[j]=a[j-1];
	a[j-1]=tmp;
      }
    }
  }

  for(i=0; i<n; i++){
    if(i>0)printf(" ");
    printf("%c%d",a[i].mark,a[i].number);
  }

  printf("\n");
  printf("Stable\n");    
}


void  selectionsort(card a[],card a2[],int n){
  int i,j,minj,count=0;
  card tmp;
  for(i=0; i<=n; i++){
    minj=i;
    for(j=i; j<n; j++){
      if(a2[j].number<a2[minj].number){
	minj=j;
      }
    }
    tmp=a2[i];
    a2[i]=a2[minj];
    a2[minj]=tmp;
}
  for(i=0; i<n; i++){
    if(i>0)printf(" ");
    printf("%c%d",a2[i].mark,a2[i].number);
  }
  printf("\n");

  for(i=0;i<n;i++){
    if(a[i].mark != a2[i].mark || a[i].number != a2[i].number){
      printf("Not stable\n");
      count=1;
      break;
    }
  }
  if(count == 0) printf("Stable\n");
  
}

 


5
H4 B9 S4 D2 C3
 5
H4 C9 S4 D2 C2
 5
H4 B9 S4 E2 C3
 5
I4 C9 S4 D2 C2
 5
H3 B9 S4 E2 C3
 5
H3 B9 S4 E2 B3
 5
H3 B9 S4 E3 B3
 5
H3 A9 S4 E3 B3
 5
H4 C9 S4 C2 C3
 5
H4 B9 T4 D2 C3

D2 C3 H4 S4 B9
Stable
D2 C3 S4 H4 B9
Not stable
 D2 C2 H4 S4 C9
Stable
D2 C2 S4 H4 C9
Not stable
 E2 C3 H4 S4 B9
Stable
E2 C3 S4 H4 B9
Not stable
 D2 C2 I4 S4 C9
Stable
D2 C2 S4 I4 C9
Not stable
 E2 H3 C3 S4 B9
Stable
E2 H3 C3 S4 B9
Stable
 E2 H3 B3 S4 B9
Stable
E2 H3 B3 S4 B9
Stable
 H3 E3 B3 S4 B9
Stable
H3 E3 B3 S4 B9
Stable
 H3 E3 B3 S4 A9
Stable
H3 E3 B3 S4 A9
Stable
 C2 C3 H4 S4 C9
Stable
C2 C3 S4 H4 C9
Not stable
 D2 C3 H4 T4 B9
Stable
D2 C3 T4 H4 B9
Not stable

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>
typedef struct 
{
  char mark;
  int number;
}card;

void bubblesort(card*,int);
void selectionsort(card*,card*,int);

int main(){
  int n,i,j,t;
   card detail[36],detail2[36];
  char a;
  

  scanf("%d",&n);
  
  for(i=0; i<n; i++)
    {
    scanf(" %c%c",&detail[i].mark,&a);
    detail[i].number = atoi(&a);
  }

  for(i=0; i<n; i++)
  detail2[i]=detail[i];
  bubblesort(detail,n);
  selectionsort(detail,detail2,n);
  return 0;
}
  

void bubblesort(card a[],int n){
  int i,j;
  card tmp;
  for(i=0;i<n;i++){
    for(j=n-1;j>i;j--){
      if(a[j].number<a[j-1].number){
	tmp=a[j];  //swap
	a[j]=a[j-1];
	a[j-1]=tmp;
      }
    }
  }

  for(i=0; i<n; i++){
    if(i>0)printf(" ");
    printf("%c%d",a[i].mark,a[i].number);
  }

  printf("\n");
  printf("Stable\n");    
}


void  selectionsort(card a[],card a2[],int n){
  int i,j,minj,count=0;
  card tmp;
  for(i=0; i<=n; i++){
    minj=i;
    for(j=i; j<n; j++){
      if(a2[j].number<a2[minj].number){
	minj=j;
      }
    }
    tmp=a2[i];
    a2[i]=a2[minj];
    a2[minj]=tmp;
}
  for(i=0; i<n; i++){
    if(i>0)printf(" ");
    printf("%c%d",a2[i].mark,a2[i].number);
  }
  printf("\n");

  for(i=0;i<n;i++){
    if(a[i].mark != a2[i].mark || a[i].number != a2[i].number){
      printf("Not stable\n");
      count=1;
      break;
    }
  }
  if(count == 0) printf("Stable\n");
  
}

 

```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	" %c%c"
	.text
	.globl	main
	.type	main, @function
main:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$608, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-600(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -596(%rbp)
	jmp	.L2
.L3:
	leaq	-592(%rbp), %rdx
	movl	-596(%rbp), %eax
	cltq
	salq	$3, %rax
	leaq	(%rdx,%rax), %rcx
	leaq	-601(%rbp), %rax
	movq	%rax, %rdx
	movq	%rcx, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	leaq	-601(%rbp), %rax
	movq	%rax, %rdi
	call	atoi@PLT
	movl	-596(%rbp), %edx
	movslq	%edx, %rdx
	movl	%eax, -588(%rbp,%rdx,8)
	addl	$1, -596(%rbp)
.L2:
	movl	-600(%rbp), %eax
	cmpl	%eax, -596(%rbp)
	jl	.L3
	movl	$0, -596(%rbp)
	jmp	.L4
.L5:
	movl	-596(%rbp), %eax
	cltq
	movl	-596(%rbp), %edx
	movslq	%edx, %rdx
	movq	-592(%rbp,%rdx,8), %rdx
	movq	%rdx, -304(%rbp,%rax,8)
	addl	$1, -596(%rbp)
.L4:
	movl	-600(%rbp), %eax
	cmpl	%eax, -596(%rbp)
	jl	.L5
	movl	-600(%rbp), %edx
	leaq	-592(%rbp), %rax
	movl	%edx, %esi
	movq	%rax, %rdi
	call	bubblesort
	movl	-600(%rbp), %edx
	leaq	-304(%rbp), %rcx
	leaq	-592(%rbp), %rax
	movq	%rcx, %rsi
	movq	%rax, %rdi
	call	selectionsort
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L7
	call	__stack_chk_fail@PLT
.L7:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	main, .-main
	.section	.rodata
.LC2:
	.string	"%c%d"
.LC3:
	.string	"Stable"
	.text
	.globl	bubblesort
	.type	bubblesort, @function
bubblesort:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movq	%rdi, -24(%rbp)
	movl	%esi, -28(%rbp)
	movl	$0, -16(%rbp)
	jmp	.L9
.L13:
	movl	-28(%rbp), %eax
	subl	$1, %eax
	movl	%eax, -12(%rbp)
	jmp	.L10
.L12:
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	4(%rax), %edx
	movl	-12(%rbp), %eax
	cltq
	salq	$3, %rax
	leaq	-8(%rax), %rcx
	movq	-24(%rbp), %rax
	addq	%rcx, %rax
	movl	4(%rax), %eax
	cmpl	%eax, %edx
	jge	.L11
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rax
	movq	%rax, -8(%rbp)
	movl	-12(%rbp), %eax
	cltq
	salq	$3, %rax
	leaq	-8(%rax), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	-12(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,8), %rcx
	movq	-24(%rbp), %rdx
	addq	%rcx, %rdx
	movq	(%rax), %rax
	movq	%rax, (%rdx)
	movl	-12(%rbp), %eax
	cltq
	salq	$3, %rax
	leaq	-8(%rax), %rdx
	movq	-24(%rbp), %rax
	addq	%rax, %rdx
	movq	-8(%rbp), %rax
	movq	%rax, (%rdx)
.L11:
	subl	$1, -12(%rbp)
.L10:
	movl	-12(%rbp), %eax
	cmpl	-16(%rbp), %eax
	jg	.L12
	addl	$1, -16(%rbp)
.L9:
	movl	-16(%rbp), %eax
	cmpl	-28(%rbp), %eax
	jl	.L13
	movl	$0, -16(%rbp)
	jmp	.L14
.L16:
	cmpl	$0, -16(%rbp)
	jle	.L15
	movl	$32, %edi
	call	putchar@PLT
.L15:
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	4(%rax), %edx
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rcx
	movq	-24(%rbp), %rax
	addq	%rcx, %rax
	movzbl	(%rax), %eax
	movsbl	%al, %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	addl	$1, -16(%rbp)
.L14:
	movl	-16(%rbp), %eax
	cmpl	-28(%rbp), %eax
	jl	.L16
	movl	$10, %edi
	call	putchar@PLT
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	bubblesort, .-bubblesort
	.section	.rodata
.LC4:
	.string	"Not stable"
	.text
	.globl	selectionsort
	.type	selectionsort, @function
selectionsort:
.LFB8:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$64, %rsp
	movq	%rdi, -40(%rbp)
	movq	%rsi, -48(%rbp)
	movl	%edx, -52(%rbp)
	movl	$0, -12(%rbp)
	movl	$0, -24(%rbp)
	jmp	.L18
.L22:
	movl	-24(%rbp), %eax
	movl	%eax, -16(%rbp)
	movl	-24(%rbp), %eax
	movl	%eax, -20(%rbp)
	jmp	.L19
.L21:
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-48(%rbp), %rax
	addq	%rdx, %rax
	movl	4(%rax), %edx
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rcx
	movq	-48(%rbp), %rax
	addq	%rcx, %rax
	movl	4(%rax), %eax
	cmpl	%eax, %edx
	jge	.L20
	movl	-20(%rbp), %eax
	movl	%eax, -16(%rbp)
.L20:
	addl	$1, -20(%rbp)
.L19:
	movl	-20(%rbp), %eax
	cmpl	-52(%rbp), %eax
	jl	.L21
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-48(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rax
	movq	%rax, -8(%rbp)
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-48(%rbp), %rax
	addq	%rdx, %rax
	movl	-24(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,8), %rcx
	movq	-48(%rbp), %rdx
	addq	%rcx, %rdx
	movq	(%rax), %rax
	movq	%rax, (%rdx)
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-48(%rbp), %rax
	addq	%rax, %rdx
	movq	-8(%rbp), %rax
	movq	%rax, (%rdx)
	addl	$1, -24(%rbp)
.L18:
	movl	-24(%rbp), %eax
	cmpl	-52(%rbp), %eax
	jle	.L22
	movl	$0, -24(%rbp)
	jmp	.L23
.L25:
	cmpl	$0, -24(%rbp)
	jle	.L24
	movl	$32, %edi
	call	putchar@PLT
.L24:
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-48(%rbp), %rax
	addq	%rdx, %rax
	movl	4(%rax), %edx
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rcx
	movq	-48(%rbp), %rax
	addq	%rcx, %rax
	movzbl	(%rax), %eax
	movsbl	%al, %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	addl	$1, -24(%rbp)
.L23:
	movl	-24(%rbp), %eax
	cmpl	-52(%rbp), %eax
	jl	.L25
	movl	$10, %edi
	call	putchar@PLT
	movl	$0, -24(%rbp)
	jmp	.L26
.L30:
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-40(%rbp), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %edx
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rcx
	movq	-48(%rbp), %rax
	addq	%rcx, %rax
	movzbl	(%rax), %eax
	cmpb	%al, %dl
	jne	.L27
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-40(%rbp), %rax
	addq	%rdx, %rax
	movl	4(%rax), %edx
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rcx
	movq	-48(%rbp), %rax
	addq	%rcx, %rax
	movl	4(%rax), %eax
	cmpl	%eax, %edx
	je	.L28
.L27:
	leaq	.LC4(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	movl	$1, -12(%rbp)
	jmp	.L29
.L28:
	addl	$1, -24(%rbp)
.L26:
	movl	-24(%rbp), %eax
	cmpl	-52(%rbp), %eax
	jl	.L30
.L29:
	cmpl	$0, -12(%rbp)
	jne	.L32
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
.L32:
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.size	selectionsort, .-selectionsort
	.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	" %c%c"
	.text
	.globl	main
	.type	main, @function
main:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$608, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-600(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -596(%rbp)
	jmp	.L2
.L3:
	leaq	-592(%rbp), %rdx
	movl	-596(%rbp), %eax
	cltq
	salq	$3, %rax
	leaq	(%rdx,%rax), %rcx
	leaq	-601(%rbp), %rax
	movq	%rax, %rdx
	movq	%rcx, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	leaq	-601(%rbp), %rax
	movq	%rax, %rdi
	call	atoi@PLT
	movl	-596(%rbp), %edx
	movslq	%edx, %rdx
	movl	%eax, -588(%rbp,%rdx,8)
	addl	$1, -596(%rbp)
.L2:
	movl	-600(%rbp), %eax
	cmpl	%eax, -596(%rbp)
	jl	.L3
	movl	$0, -596(%rbp)
	jmp	.L4
.L5:
	movl	-596(%rbp), %eax
	cltq
	movl	-596(%rbp), %edx
	movslq	%edx, %rdx
	movq	-592(%rbp,%rdx,8), %rdx
	movq	%rdx, -304(%rbp,%rax,8)
	addl	$1, -596(%rbp)
.L4:
	movl	-600(%rbp), %eax
	cmpl	%eax, -596(%rbp)
	jl	.L5
	movl	-600(%rbp), %edx
	leaq	-592(%rbp), %rax
	movl	%edx, %esi
	movq	%rax, %rdi
	call	bubblesort
	movl	-600(%rbp), %edx
	leaq	-304(%rbp), %rcx
	leaq	-592(%rbp), %rax
	movq	%rcx, %rsi
	movq	%rax, %rdi
	call	selectionsort
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L7
	call	__stack_chk_fail@PLT
.L7:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	main, .-main
	.section	.rodata
.LC2:
	.string	"%c%d"
.LC3:
	.string	"Stable"
	.text
	.globl	bubblesort
	.type	bubblesort, @function
bubblesort:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movq	%rdi, -24(%rbp)
	movl	%esi, -28(%rbp)
	movl	$0, -16(%rbp)
	jmp	.L9
.L13:
	movl	-28(%rbp), %eax
	subl	$1, %eax
	movl	%eax, -12(%rbp)
	jmp	.L10
.L12:
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	4(%rax), %edx
	movl	-12(%rbp), %eax
	cltq
	salq	$3, %rax
	leaq	-8(%rax), %rcx
	movq	-24(%rbp), %rax
	addq	%rcx, %rax
	movl	4(%rax), %eax
	cmpl	%eax, %edx
	jge	.L11
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rax
	movq	%rax, -8(%rbp)
	movl	-12(%rbp), %eax
	cltq
	salq	$3, %rax
	leaq	-8(%rax), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	-12(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,8), %rcx
	movq	-24(%rbp), %rdx
	addq	%rcx, %rdx
	movq	(%rax), %rax
	movq	%rax, (%rdx)
	movl	-12(%rbp), %eax
	cltq
	salq	$3, %rax
	leaq	-8(%rax), %rdx
	movq	-24(%rbp), %rax
	addq	%rax, %rdx
	movq	-8(%rbp), %rax
	movq	%rax, (%rdx)
.L11:
	subl	$1, -12(%rbp)
.L10:
	movl	-12(%rbp), %eax
	cmpl	-16(%rbp), %eax
	jg	.L12
	addl	$1, -16(%rbp)
.L9:
	movl	-16(%rbp), %eax
	cmpl	-28(%rbp), %eax
	jl	.L13
	movl	$0, -16(%rbp)
	jmp	.L14
.L16:
	cmpl	$0, -16(%rbp)
	jle	.L15
	movl	$32, %edi
	call	putchar@PLT
.L15:
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	4(%rax), %edx
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rcx
	movq	-24(%rbp), %rax
	addq	%rcx, %rax
	movzbl	(%rax), %eax
	movsbl	%al, %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	addl	$1, -16(%rbp)
.L14:
	movl	-16(%rbp), %eax
	cmpl	-28(%rbp), %eax
	jl	.L16
	movl	$10, %edi
	call	putchar@PLT
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	bubblesort, .-bubblesort
	.section	.rodata
.LC4:
	.string	"Not stable"
	.text
	.globl	selectionsort
	.type	selectionsort, @function
selectionsort:
.LFB8:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$64, %rsp
	movq	%rdi, -40(%rbp)
	movq	%rsi, -48(%rbp)
	movl	%edx, -52(%rbp)
	movl	$0, -12(%rbp)
	movl	$0, -24(%rbp)
	jmp	.L18
.L22:
	movl	-24(%rbp), %eax
	movl	%eax, -16(%rbp)
	movl	-24(%rbp), %eax
	movl	%eax, -20(%rbp)
	jmp	.L19
.L21:
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-48(%rbp), %rax
	addq	%rdx, %rax
	movl	4(%rax), %edx
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rcx
	movq	-48(%rbp), %rax
	addq	%rcx, %rax
	movl	4(%rax), %eax
	cmpl	%eax, %edx
	jge	.L20
	movl	-20(%rbp), %eax
	movl	%eax, -16(%rbp)
.L20:
	addl	$1, -20(%rbp)
.L19:
	movl	-20(%rbp), %eax
	cmpl	-52(%rbp), %eax
	jl	.L21
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-48(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rax
	movq	%rax, -8(%rbp)
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-48(%rbp), %rax
	addq	%rdx, %rax
	movl	-24(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,8), %rcx
	movq	-48(%rbp), %rdx
	addq	%rcx, %rdx
	movq	(%rax), %rax
	movq	%rax, (%rdx)
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-48(%rbp), %rax
	addq	%rax, %rdx
	movq	-8(%rbp), %rax
	movq	%rax, (%rdx)
	addl	$1, -24(%rbp)
.L18:
	movl	-24(%rbp), %eax
	cmpl	-52(%rbp), %eax
	jle	.L22
	movl	$0, -24(%rbp)
	jmp	.L23
.L25:
	cmpl	$0, -24(%rbp)
	jle	.L24
	movl	$32, %edi
	call	putchar@PLT
.L24:
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-48(%rbp), %rax
	addq	%rdx, %rax
	movl	4(%rax), %edx
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rcx
	movq	-48(%rbp), %rax
	addq	%rcx, %rax
	movzbl	(%rax), %eax
	movsbl	%al, %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	addl	$1, -24(%rbp)
.L23:
	movl	-24(%rbp), %eax
	cmpl	-52(%rbp), %eax
	jl	.L25
	movl	$10, %edi
	call	putchar@PLT
	movl	$0, -24(%rbp)
	jmp	.L26
.L30:
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-40(%rbp), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %edx
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rcx
	movq	-48(%rbp), %rax
	addq	%rcx, %rax
	movzbl	(%rax), %eax
	cmpb	%al, %dl
	jne	.L27
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-40(%rbp), %rax
	addq	%rdx, %rax
	movl	4(%rax), %edx
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rcx
	movq	-48(%rbp), %rax
	addq	%rcx, %rax
	movl	4(%rax), %eax
	cmpl	%eax, %edx
	je	.L28
.L27:
	leaq	.LC4(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	movl	$1, -12(%rbp)
	jmp	.L29
.L28:
	addl	$1, -24(%rbp)
.L26:
	movl	-24(%rbp), %eax
	cmpl	-52(%rbp), %eax
	jl	.L30
.L29:
	cmpl	$0, -12(%rbp)
	jne	.L32
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
.L32:
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.size	selectionsort, .-selectionsort
	.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:
