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>
#define MAX 2000001
#define VMAX 10000

int main(){
  unsigned short *A, *B;
  int C[VMAX+1];
  int n, i, j;

  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

  for(i=0;i<=VMAX;i++)C[i]=0;

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

    scanf("%hu",&A[i+1]);
    C[A[i+1]]++;
  }

  for(i=1;i<=VMAX;i++)C[i]=C[i]+C[i-1];

  for(j=n;j>=1;j--){
    B[C[A[j]]]=A[j];
    C[A[j]]--;
  }
  for(i=1;i<=n;i++){
    if(i>1)printf(" ");
    printf("%d",B[i]);
  }
  printf("\n");
  

  return 0;
}

```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%hu"
	.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
	leaq	-36864(%rsp), %r11
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	subq	$3184, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-40044(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-40044(%rbp), %eax
	cltq
	addq	%rax, %rax
	addq	$1, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, -40032(%rbp)
	movl	-40044(%rbp), %eax
	cltq
	addq	%rax, %rax
	addq	$1, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, -40024(%rbp)
	movl	$0, -40040(%rbp)
	jmp	.L2
.L3:
	movl	-40040(%rbp), %eax
	cltq
	movl	$0, -40016(%rbp,%rax,4)
	addl	$1, -40040(%rbp)
.L2:
	cmpl	$10000, -40040(%rbp)
	jle	.L3
	movl	$0, -40040(%rbp)
	jmp	.L4
.L5:
	movl	-40040(%rbp), %eax
	cltq
	addq	$1, %rax
	leaq	(%rax,%rax), %rdx
	movq	-40032(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-40040(%rbp), %eax
	cltq
	addq	$1, %rax
	leaq	(%rax,%rax), %rdx
	movq	-40032(%rbp), %rax
	addq	%rdx, %rax
	movzwl	(%rax), %eax
	movzwl	%ax, %eax
	movslq	%eax, %rdx
	movl	-40016(%rbp,%rdx,4), %edx
	addl	$1, %edx
	cltq
	movl	%edx, -40016(%rbp,%rax,4)
	addl	$1, -40040(%rbp)
.L4:
	movl	-40044(%rbp), %eax
	cmpl	%eax, -40040(%rbp)
	jl	.L5
	movl	$1, -40040(%rbp)
	jmp	.L6
.L7:
	movl	-40040(%rbp), %eax
	cltq
	movl	-40016(%rbp,%rax,4), %edx
	movl	-40040(%rbp), %eax
	subl	$1, %eax
	cltq
	movl	-40016(%rbp,%rax,4), %eax
	addl	%eax, %edx
	movl	-40040(%rbp), %eax
	cltq
	movl	%edx, -40016(%rbp,%rax,4)
	addl	$1, -40040(%rbp)
.L6:
	cmpl	$10000, -40040(%rbp)
	jle	.L7
	movl	-40044(%rbp), %eax
	movl	%eax, -40036(%rbp)
	jmp	.L8
.L9:
	movl	-40036(%rbp), %eax
	cltq
	leaq	(%rax,%rax), %rdx
	movq	-40032(%rbp), %rax
	leaq	(%rdx,%rax), %rcx
	movl	-40036(%rbp), %eax
	cltq
	leaq	(%rax,%rax), %rdx
	movq	-40032(%rbp), %rax
	addq	%rdx, %rax
	movzwl	(%rax), %eax
	movzwl	%ax, %eax
	cltq
	movl	-40016(%rbp,%rax,4), %eax
	cltq
	leaq	(%rax,%rax), %rdx
	movq	-40024(%rbp), %rax
	addq	%rax, %rdx
	movzwl	(%rcx), %eax
	movw	%ax, (%rdx)
	movl	-40036(%rbp), %eax
	cltq
	leaq	(%rax,%rax), %rdx
	movq	-40032(%rbp), %rax
	addq	%rdx, %rax
	movzwl	(%rax), %eax
	movzwl	%ax, %eax
	movslq	%eax, %rdx
	movl	-40016(%rbp,%rdx,4), %edx
	subl	$1, %edx
	cltq
	movl	%edx, -40016(%rbp,%rax,4)
	subl	$1, -40036(%rbp)
.L8:
	cmpl	$0, -40036(%rbp)
	jg	.L9
	movl	$1, -40040(%rbp)
	jmp	.L10
.L12:
	cmpl	$1, -40040(%rbp)
	jle	.L11
	movl	$32, %edi
	call	putchar@PLT
.L11:
	movl	-40040(%rbp), %eax
	cltq
	leaq	(%rax,%rax), %rdx
	movq	-40024(%rbp), %rax
	addq	%rdx, %rax
	movzwl	(%rax), %eax
	movzwl	%ax, %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	addl	$1, -40040(%rbp)
.L10:
	movl	-40044(%rbp), %eax
	cmpl	%eax, -40040(%rbp)
	jle	.L12
	movl	$10, %edi
	call	putchar@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L14
	call	__stack_chk_fail@PLT
.L14:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.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	"%hu"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB39:
	.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
	leaq	-36864(%rsp), %r11
	.cfi_def_cfa 11, 36920
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	.cfi_def_cfa_register 7
	subq	$3176, %rsp
	.cfi_def_cfa_offset 40096
	leaq	.LC0(%rip), %r12
	movq	%r12, %rdi
	movq	%fs:40, %rax
	movq	%rax, 40024(%rsp)
	xorl	%eax, %eax
	leaq	12(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movslq	12(%rsp), %rax
	leaq	1(%rax,%rax), %r14
	movq	%rax, %r13
	movq	%r14, %rdi
	call	malloc@PLT
	movq	%r14, %rdi
	movq	%rax, %rbp
	call	malloc@PLT
	xorl	%esi, %esi
	leaq	16(%rsp), %rdi
	movl	$40004, %edx
	movq	%rax, %rbx
	call	memset@PLT
	testl	%r13d, %r13d
	jle	.L2
	leaq	2(%rbp), %r14
	xorl	%r15d, %r15d
	.p2align 4,,10
	.p2align 3
.L3:
	movq	%r14, %rsi
	leaq	.LC1(%rip), %rdi
	xorl	%eax, %eax
	addl	$1, %r15d
	call	__isoc99_scanf@PLT
	movzwl	(%r14), %eax
	movl	12(%rsp), %r13d
	addq	$2, %r14
	addl	$1, 16(%rsp,%rax,4)
	cmpl	%r15d, %r13d
	jg	.L3
.L2:
	movl	16(%rsp), %edx
	leaq	20(%rsp), %rax
	leaq	40020(%rsp), %rcx
	.p2align 4,,10
	.p2align 3
.L4:
	addl	(%rax), %edx
	addq	$4, %rax
	movl	%edx, -4(%rax)
	cmpq	%rax, %rcx
	jne	.L4
	testl	%r13d, %r13d
	jle	.L5
	movslq	%r13d, %rax
	.p2align 4,,10
	.p2align 3
.L6:
	movzwl	0(%rbp,%rax,2), %ecx
	subq	$1, %rax
	movslq	16(%rsp,%rcx,4), %rdi
	movq	%rdi, %rdx
	movw	%cx, (%rbx,%rdi,2)
	subl	$1, %edx
	movl	%edx, 16(%rsp,%rcx,4)
	testl	%eax, %eax
	jg	.L6
	movl	$1, %ebp
	jmp	.L7
	.p2align 4,,10
	.p2align 3
.L8:
	movl	$32, %edi
	call	putchar@PLT
.L7:
	movzwl	(%rbx,%rbp,2), %edx
	movq	%r12, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	addq	$1, %rbp
	call	__printf_chk@PLT
	cmpl	%ebp, 12(%rsp)
	jge	.L8
.L5:
	movl	$10, %edi
	call	putchar@PLT
	movq	40024(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L16
	addq	$40040, %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
.L16:
	.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	"%d"
.LC1:
	.string	"%hu"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB39:
	.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
	leaq	-36864(%rsp), %r11
	.cfi_def_cfa 11, 36920
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	.cfi_def_cfa_register 7
	subq	$3176, %rsp
	.cfi_def_cfa_offset 40096
	leaq	.LC0(%rip), %r12
	movq	%r12, %rdi
	movq	%fs:40, %rax
	movq	%rax, 40024(%rsp)
	xorl	%eax, %eax
	leaq	12(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movslq	12(%rsp), %rax
	leaq	1(%rax,%rax), %r14
	movq	%rax, %r13
	movq	%r14, %rdi
	call	malloc@PLT
	movq	%r14, %rdi
	movq	%rax, %rbp
	call	malloc@PLT
	xorl	%esi, %esi
	leaq	16(%rsp), %rdi
	movl	$40004, %edx
	movq	%rax, %rbx
	call	memset@PLT
	testl	%r13d, %r13d
	jle	.L2
	leaq	2(%rbp), %r14
	xorl	%r15d, %r15d
	.p2align 4,,10
	.p2align 3
.L3:
	movq	%r14, %rsi
	leaq	.LC1(%rip), %rdi
	xorl	%eax, %eax
	addl	$1, %r15d
	call	__isoc99_scanf@PLT
	movzwl	(%r14), %eax
	movl	12(%rsp), %r13d
	addq	$2, %r14
	addl	$1, 16(%rsp,%rax,4)
	cmpl	%r15d, %r13d
	jg	.L3
.L2:
	movl	16(%rsp), %edx
	leaq	20(%rsp), %rax
	leaq	40020(%rsp), %rcx
	.p2align 4,,10
	.p2align 3
.L4:
	addl	(%rax), %edx
	addq	$4, %rax
	movl	%edx, -4(%rax)
	cmpq	%rax, %rcx
	jne	.L4
	testl	%r13d, %r13d
	jle	.L5
	movslq	%r13d, %rax
	.p2align 4,,10
	.p2align 3
.L6:
	movzwl	0(%rbp,%rax,2), %ecx
	subq	$1, %rax
	movslq	16(%rsp,%rcx,4), %rdi
	movq	%rdi, %rdx
	movw	%cx, (%rbx,%rdi,2)
	subl	$1, %edx
	movl	%edx, 16(%rsp,%rcx,4)
	testl	%eax, %eax
	jg	.L6
	movl	$1, %ebp
	jmp	.L7
	.p2align 4,,10
	.p2align 3
.L8:
	movl	$32, %edi
	call	putchar@PLT
.L7:
	movzwl	(%rbx,%rbp,2), %edx
	movq	%r12, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	addq	$1, %rbp
	call	__printf_chk@PLT
	cmpl	%ebp, 12(%rsp)
	jge	.L8
.L5:
	movl	$10, %edi
	call	putchar@PLT
	movq	40024(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L16
	addq	$40040, %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
.L16:
	.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>
#define MAX 2000001
#define VMAX 10000

int main(){
  unsigned short *A, *B;
  int C[VMAX+1];
  int n, i, j;

  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

  for(i=0;i<=VMAX;i++)C[i]=0;

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

    scanf("%hu",&A[i+1]);
    C[A[i+1]]++;
  }

  for(i=1;i<=VMAX;i++)C[i]=C[i]+C[i-1];

  for(j=n;j>=1;j--){
    B[C[A[j]]]=A[j];
    C[A[j]]--;
  }
  for(i=1;i<=n;i++){
    if(i>1)printf(" ");
    printf("%d",B[i]);
  }
  printf("\n");
  

  return 0;
}


7
2 5 1 3 2 3 1
 7
2 5 1 3 4 3 1
 7
2 5 2 3 4 3 1
 7
4 5 2 3 4 3 1
 7
4 9 2 3 4 3 1
 7
4 9 2 3 4 3 2
 7
4 9 2 1 4 3 2
 7
4 9 2 0 4 3 3
 7
8 9 2 0 4 3 3
 7
8 9 2 0 6 3 3

1 1 2 2 3 3 5
 1 1 2 3 3 4 5
 1 2 2 3 3 4 5
 1 2 3 3 4 4 5
 1 2 3 3 4 4 9
 2 2 3 3 4 4 9
 1 2 2 3 4 4 9
 0 2 3 3 4 4 9
 0 2 3 3 4 8 9
 0 2 3 3 6 8 9

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>
#define MAX 2000001
#define VMAX 10000

int main(){
  unsigned short *A, *B;
  int C[VMAX+1];
  int n, i, j;

  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

  for(i=0;i<=VMAX;i++)C[i]=0;

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

    scanf("%hu",&A[i+1]);
    C[A[i+1]]++;
  }

  for(i=1;i<=VMAX;i++)C[i]=C[i]+C[i-1];

  for(j=n;j>=1;j--){
    B[C[A[j]]]=A[j];
    C[A[j]]--;
  }
  for(i=1;i<=n;i++){
    if(i>1)printf(" ");
    printf("%d",B[i]);
  }
  printf("\n");
  

  return 0;
}

```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%hu"
	.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
	leaq	-36864(%rsp), %r11
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	subq	$3184, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-40044(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-40044(%rbp), %eax
	cltq
	addq	%rax, %rax
	addq	$1, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, -40032(%rbp)
	movl	-40044(%rbp), %eax
	cltq
	addq	%rax, %rax
	addq	$1, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, -40024(%rbp)
	movl	$0, -40040(%rbp)
	jmp	.L2
.L3:
	movl	-40040(%rbp), %eax
	cltq
	movl	$0, -40016(%rbp,%rax,4)
	addl	$1, -40040(%rbp)
.L2:
	cmpl	$10000, -40040(%rbp)
	jle	.L3
	movl	$0, -40040(%rbp)
	jmp	.L4
.L5:
	movl	-40040(%rbp), %eax
	cltq
	addq	$1, %rax
	leaq	(%rax,%rax), %rdx
	movq	-40032(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-40040(%rbp), %eax
	cltq
	addq	$1, %rax
	leaq	(%rax,%rax), %rdx
	movq	-40032(%rbp), %rax
	addq	%rdx, %rax
	movzwl	(%rax), %eax
	movzwl	%ax, %eax
	movslq	%eax, %rdx
	movl	-40016(%rbp,%rdx,4), %edx
	addl	$1, %edx
	cltq
	movl	%edx, -40016(%rbp,%rax,4)
	addl	$1, -40040(%rbp)
.L4:
	movl	-40044(%rbp), %eax
	cmpl	%eax, -40040(%rbp)
	jl	.L5
	movl	$1, -40040(%rbp)
	jmp	.L6
.L7:
	movl	-40040(%rbp), %eax
	cltq
	movl	-40016(%rbp,%rax,4), %edx
	movl	-40040(%rbp), %eax
	subl	$1, %eax
	cltq
	movl	-40016(%rbp,%rax,4), %eax
	addl	%eax, %edx
	movl	-40040(%rbp), %eax
	cltq
	movl	%edx, -40016(%rbp,%rax,4)
	addl	$1, -40040(%rbp)
.L6:
	cmpl	$10000, -40040(%rbp)
	jle	.L7
	movl	-40044(%rbp), %eax
	movl	%eax, -40036(%rbp)
	jmp	.L8
.L9:
	movl	-40036(%rbp), %eax
	cltq
	leaq	(%rax,%rax), %rdx
	movq	-40032(%rbp), %rax
	leaq	(%rdx,%rax), %rcx
	movl	-40036(%rbp), %eax
	cltq
	leaq	(%rax,%rax), %rdx
	movq	-40032(%rbp), %rax
	addq	%rdx, %rax
	movzwl	(%rax), %eax
	movzwl	%ax, %eax
	cltq
	movl	-40016(%rbp,%rax,4), %eax
	cltq
	leaq	(%rax,%rax), %rdx
	movq	-40024(%rbp), %rax
	addq	%rax, %rdx
	movzwl	(%rcx), %eax
	movw	%ax, (%rdx)
	movl	-40036(%rbp), %eax
	cltq
	leaq	(%rax,%rax), %rdx
	movq	-40032(%rbp), %rax
	addq	%rdx, %rax
	movzwl	(%rax), %eax
	movzwl	%ax, %eax
	movslq	%eax, %rdx
	movl	-40016(%rbp,%rdx,4), %edx
	subl	$1, %edx
	cltq
	movl	%edx, -40016(%rbp,%rax,4)
	subl	$1, -40036(%rbp)
.L8:
	cmpl	$0, -40036(%rbp)
	jg	.L9
	movl	$1, -40040(%rbp)
	jmp	.L10
.L12:
	cmpl	$1, -40040(%rbp)
	jle	.L11
	movl	$32, %edi
	call	putchar@PLT
.L11:
	movl	-40040(%rbp), %eax
	cltq
	leaq	(%rax,%rax), %rdx
	movq	-40024(%rbp), %rax
	addq	%rdx, %rax
	movzwl	(%rax), %eax
	movzwl	%ax, %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	addl	$1, -40040(%rbp)
.L10:
	movl	-40044(%rbp), %eax
	cmpl	%eax, -40040(%rbp)
	jle	.L12
	movl	$10, %edi
	call	putchar@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L14
	call	__stack_chk_fail@PLT
.L14:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.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	"%hu"
	.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
	leaq	-36864(%rsp), %r11
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	subq	$3184, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-40044(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-40044(%rbp), %eax
	cltq
	addq	%rax, %rax
	addq	$1, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, -40032(%rbp)
	movl	-40044(%rbp), %eax
	cltq
	addq	%rax, %rax
	addq	$1, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, -40024(%rbp)
	movl	$0, -40040(%rbp)
	jmp	.L2
.L3:
	movl	-40040(%rbp), %eax
	cltq
	movl	$0, -40016(%rbp,%rax,4)
	addl	$1, -40040(%rbp)
.L2:
	cmpl	$10000, -40040(%rbp)
	jle	.L3
	movl	$0, -40040(%rbp)
	jmp	.L4
.L5:
	movl	-40040(%rbp), %eax
	cltq
	addq	$1, %rax
	leaq	(%rax,%rax), %rdx
	movq	-40032(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-40040(%rbp), %eax
	cltq
	addq	$1, %rax
	leaq	(%rax,%rax), %rdx
	movq	-40032(%rbp), %rax
	addq	%rdx, %rax
	movzwl	(%rax), %eax
	movzwl	%ax, %eax
	movslq	%eax, %rdx
	movl	-40016(%rbp,%rdx,4), %edx
	addl	$1, %edx
	cltq
	movl	%edx, -40016(%rbp,%rax,4)
	addl	$1, -40040(%rbp)
.L4:
	movl	-40044(%rbp), %eax
	cmpl	%eax, -40040(%rbp)
	jl	.L5
	movl	$1, -40040(%rbp)
	jmp	.L6
.L7:
	movl	-40040(%rbp), %eax
	cltq
	movl	-40016(%rbp,%rax,4), %edx
	movl	-40040(%rbp), %eax
	subl	$1, %eax
	cltq
	movl	-40016(%rbp,%rax,4), %eax
	addl	%eax, %edx
	movl	-40040(%rbp), %eax
	cltq
	movl	%edx, -40016(%rbp,%rax,4)
	addl	$1, -40040(%rbp)
.L6:
	cmpl	$10000, -40040(%rbp)
	jle	.L7
	movl	-40044(%rbp), %eax
	movl	%eax, -40036(%rbp)
	jmp	.L8
.L9:
	movl	-40036(%rbp), %eax
	cltq
	leaq	(%rax,%rax), %rdx
	movq	-40032(%rbp), %rax
	leaq	(%rdx,%rax), %rcx
	movl	-40036(%rbp), %eax
	cltq
	leaq	(%rax,%rax), %rdx
	movq	-40032(%rbp), %rax
	addq	%rdx, %rax
	movzwl	(%rax), %eax
	movzwl	%ax, %eax
	cltq
	movl	-40016(%rbp,%rax,4), %eax
	cltq
	leaq	(%rax,%rax), %rdx
	movq	-40024(%rbp), %rax
	addq	%rax, %rdx
	movzwl	(%rcx), %eax
	movw	%ax, (%rdx)
	movl	-40036(%rbp), %eax
	cltq
	leaq	(%rax,%rax), %rdx
	movq	-40032(%rbp), %rax
	addq	%rdx, %rax
	movzwl	(%rax), %eax
	movzwl	%ax, %eax
	movslq	%eax, %rdx
	movl	-40016(%rbp,%rdx,4), %edx
	subl	$1, %edx
	cltq
	movl	%edx, -40016(%rbp,%rax,4)
	subl	$1, -40036(%rbp)
.L8:
	cmpl	$0, -40036(%rbp)
	jg	.L9
	movl	$1, -40040(%rbp)
	jmp	.L10
.L12:
	cmpl	$1, -40040(%rbp)
	jle	.L11
	movl	$32, %edi
	call	putchar@PLT
.L11:
	movl	-40040(%rbp), %eax
	cltq
	leaq	(%rax,%rax), %rdx
	movq	-40024(%rbp), %rax
	addq	%rdx, %rax
	movzwl	(%rax), %eax
	movzwl	%ax, %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	addl	$1, -40040(%rbp)
.L10:
	movl	-40044(%rbp), %eax
	cmpl	%eax, -40040(%rbp)
	jle	.L12
	movl	$10, %edi
	call	putchar@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L14
	call	__stack_chk_fail@PLT
.L14:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.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:
