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>
#define N 2000001

int A[N], B[N], C[10001];

void CountingSort(int k, int n){
  int i;
  for(i=0;i<=k;i++) C[i]=0;
  for(i=0;i<n;i++) C[A[i]]=C[A[i]]+1;
  for(i=1;i<=k;i++) C[i]=C[i]+C[i-1];
  for(i=n-1;i>=0;i--){
    B[C[A[i]]-1]=A[i];
    C[A[i]]=C[A[i]]-1;
  }
}

int main(){
  int n,k;
  int i;
  k=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
    if(k<A[i]) k=A[i];
  }
  CountingSort(k,n);
  printf("%d",B[0]);
  for(i=1;i<n;i++) printf(" %d",B[i]);
  printf("\n");
  return 0;
}


```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	A
	.bss
	.align 32
	.type	A, @object
	.size	A, 8000004
A:
	.zero	8000004
	.globl	B
	.align 32
	.type	B, @object
	.size	B, 8000004
B:
	.zero	8000004
	.globl	C
	.align 32
	.type	C, @object
	.size	C, 40004
C:
	.zero	40004
	.text
	.globl	CountingSort
	.type	CountingSort, @function
CountingSort:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -20(%rbp)
	movl	%esi, -24(%rbp)
	movl	$0, -4(%rbp)
	jmp	.L2
.L3:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	C(%rip), %rax
	movl	$0, (%rdx,%rax)
	addl	$1, -4(%rbp)
.L2:
	movl	-4(%rbp), %eax
	cmpl	-20(%rbp), %eax
	jle	.L3
	movl	$0, -4(%rbp)
	jmp	.L4
.L5:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	A(%rip), %rax
	movl	(%rdx,%rax), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	C(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	A(%rip), %rax
	movl	(%rcx,%rax), %eax
	leal	1(%rdx), %ecx
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	C(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	addl	$1, -4(%rbp)
.L4:
	movl	-4(%rbp), %eax
	cmpl	-24(%rbp), %eax
	jl	.L5
	movl	$1, -4(%rbp)
	jmp	.L6
.L7:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	C(%rip), %rax
	movl	(%rdx,%rax), %ecx
	movl	-4(%rbp), %eax
	subl	$1, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	C(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%eax, %ecx
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	C(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	addl	$1, -4(%rbp)
.L6:
	movl	-4(%rbp), %eax
	cmpl	-20(%rbp), %eax
	jle	.L7
	movl	-24(%rbp), %eax
	subl	$1, %eax
	movl	%eax, -4(%rbp)
	jmp	.L8
.L9:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	A(%rip), %rax
	movl	(%rdx,%rax), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	C(%rip), %rax
	movl	(%rdx,%rax), %eax
	leal	-1(%rax), %ecx
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	A(%rip), %rax
	movl	(%rdx,%rax), %eax
	movslq	%ecx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	B(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	A(%rip), %rax
	movl	(%rdx,%rax), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	C(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	A(%rip), %rax
	movl	(%rcx,%rax), %eax
	leal	-1(%rdx), %ecx
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	C(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	subl	$1, -4(%rbp)
.L8:
	cmpl	$0, -4(%rbp)
	jns	.L9
	nop
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	CountingSort, .-CountingSort
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	" %d"
	.text
	.globl	main
	.type	main, @function
main:
.LFB1:
	.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	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -16(%rbp)
	leaq	-20(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -12(%rbp)
	jmp	.L11
.L13:
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	A(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	A(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -16(%rbp)
	jge	.L12
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	A(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -16(%rbp)
.L12:
	addl	$1, -12(%rbp)
.L11:
	movl	-20(%rbp), %eax
	cmpl	%eax, -12(%rbp)
	jl	.L13
	movl	-20(%rbp), %edx
	movl	-16(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	CountingSort
	movl	B(%rip), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$1, -12(%rbp)
	jmp	.L14
.L15:
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	B(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	addl	$1, -12(%rbp)
.L14:
	movl	-20(%rbp), %eax
	cmpl	%eax, -12(%rbp)
	jl	.L15
	movl	$10, %edi
	call	putchar@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L17
	call	__stack_chk_fail@PLT
.L17:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.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	CountingSort
	.type	CountingSort, @function
CountingSort:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movl	%edi, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	movl	%esi, %ebx
	subq	$8, %rsp
	.cfi_def_cfa_offset 32
	testl	%edi, %edi
	js	.L5
	movslq	%edi, %rax
	xorl	%esi, %esi
	leaq	C(%rip), %rdi
	leaq	4(,%rax,4), %rdx
	call	memset@PLT
.L5:
	testl	%ebx, %ebx
	jle	.L24
	leaq	A(%rip), %r9
	leal	-1(%rbx), %esi
	leaq	4(%r9), %rcx
	movq	%rsi, %rax
	movq	%r9, %rdx
	leaq	(%rcx,%rsi,4), %rsi
	leaq	C(%rip), %rdi
	.p2align 4,,10
	.p2align 3
.L6:
	movslq	(%rdx), %rcx
	addq	$4, %rdx
	addl	$1, (%rdi,%rcx,4)
	cmpq	%rdx, %rsi
	jne	.L6
	testl	%ebp, %ebp
	jle	.L10
.L8:
	movl	C(%rip), %ecx
	movl	$1, %edx
	.p2align 4,,10
	.p2align 3
.L11:
	addl	(%rdi,%rdx,4), %ecx
	movl	%ecx, (%rdi,%rdx,4)
	addq	$1, %rdx
	cmpl	%edx, %ebp
	jge	.L11
	leaq	A(%rip), %r9
	testl	%eax, %eax
	js	.L1
.L10:
	cltq
	leaq	B(%rip), %r10
	.p2align 4,,10
	.p2align 3
.L13:
	movslq	(%r9,%rax,4), %rcx
	subq	$1, %rax
	movl	(%rdi,%rcx,4), %ebx
	leal	-1(%rbx), %edx
	movslq	%edx, %r8
	movl	%edx, (%rdi,%rcx,4)
	movl	%ecx, (%r10,%r8,4)
	testl	%eax, %eax
	jns	.L13
.L1:
	addq	$8, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L24:
	.cfi_restore_state
	leaq	C(%rip), %rdi
	leal	-1(%rbx), %eax
	testl	%ebp, %ebp
	jg	.L8
	jmp	.L1
	.cfi_endproc
.LFE23:
	.size	CountingSort, .-CountingSort
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	" %d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB24:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	leaq	.LC0(%rip), %r13
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	movq	%r13, %rdi
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	subq	$24, %rsp
	.cfi_def_cfa_offset 64
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	leaq	4(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movl	4(%rsp), %esi
	testl	%esi, %esi
	jle	.L31
	leaq	A(%rip), %rbx
	xorl	%r12d, %r12d
	xorl	%ebp, %ebp
	.p2align 4,,10
	.p2align 3
.L27:
	movq	%rbx, %rsi
	xorl	%eax, %eax
	movq	%r13, %rdi
	call	__isoc99_scanf@PLT
	movl	(%rbx), %eax
	movl	4(%rsp), %esi
	cmpl	%eax, %ebp
	cmovl	%eax, %ebp
	addl	$1, %r12d
	addq	$4, %rbx
	cmpl	%r12d, %esi
	jg	.L27
.L26:
	movl	%ebp, %edi
	call	CountingSort
	movl	B(%rip), %edx
	xorl	%eax, %eax
	movq	%r13, %rsi
	movl	$1, %edi
	call	__printf_chk@PLT
	cmpl	$1, 4(%rsp)
	jle	.L28
	movl	$1, %ebx
	leaq	B(%rip), %r12
	leaq	.LC1(%rip), %rbp
	.p2align 4,,10
	.p2align 3
.L29:
	movl	(%r12,%rbx,4), %edx
	movq	%rbp, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	addq	$1, %rbx
	call	__printf_chk@PLT
	cmpl	%ebx, 4(%rsp)
	jg	.L29
.L28:
	movl	$10, %edi
	call	putchar@PLT
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L35
	addq	$24, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	xorl	%eax, %eax
	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
	ret
.L31:
	.cfi_restore_state
	xorl	%ebp, %ebp
	jmp	.L26
.L35:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE24:
	.size	main, .-main
	.globl	C
	.bss
	.align 32
	.type	C, @object
	.size	C, 40004
C:
	.zero	40004
	.globl	B
	.align 32
	.type	B, @object
	.size	B, 8000004
B:
	.zero	8000004
	.globl	A
	.align 32
	.type	A, @object
	.size	A, 8000004
A:
	.zero	8000004
	.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	CountingSort
	.type	CountingSort, @function
CountingSort:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movl	%edi, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	movl	%esi, %ebx
	subq	$8, %rsp
	.cfi_def_cfa_offset 32
	testl	%edi, %edi
	js	.L5
	movslq	%edi, %rax
	xorl	%esi, %esi
	leaq	C(%rip), %rdi
	leaq	4(,%rax,4), %rdx
	call	memset@PLT
.L5:
	testl	%ebx, %ebx
	jle	.L24
	leaq	A(%rip), %r9
	leal	-1(%rbx), %esi
	leaq	4(%r9), %rcx
	movq	%rsi, %rax
	movq	%r9, %rdx
	leaq	(%rcx,%rsi,4), %rsi
	leaq	C(%rip), %rdi
	.p2align 4,,10
	.p2align 3
.L6:
	movslq	(%rdx), %rcx
	addq	$4, %rdx
	addl	$1, (%rdi,%rcx,4)
	cmpq	%rdx, %rsi
	jne	.L6
	testl	%ebp, %ebp
	jle	.L10
.L8:
	movl	C(%rip), %ecx
	movl	$1, %edx
	.p2align 4,,10
	.p2align 3
.L11:
	addl	(%rdi,%rdx,4), %ecx
	movl	%ecx, (%rdi,%rdx,4)
	addq	$1, %rdx
	cmpl	%edx, %ebp
	jge	.L11
	leaq	A(%rip), %r9
	testl	%eax, %eax
	js	.L1
.L10:
	cltq
	leaq	B(%rip), %r10
	.p2align 4,,10
	.p2align 3
.L13:
	movslq	(%r9,%rax,4), %rcx
	subq	$1, %rax
	movl	(%rdi,%rcx,4), %ebx
	leal	-1(%rbx), %edx
	movslq	%edx, %r8
	movl	%edx, (%rdi,%rcx,4)
	movl	%ecx, (%r10,%r8,4)
	testl	%eax, %eax
	jns	.L13
.L1:
	addq	$8, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L24:
	.cfi_restore_state
	leaq	C(%rip), %rdi
	leal	-1(%rbx), %eax
	testl	%ebp, %ebp
	jg	.L8
	jmp	.L1
	.cfi_endproc
.LFE23:
	.size	CountingSort, .-CountingSort
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	" %d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB24:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	leaq	.LC0(%rip), %r13
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	movq	%r13, %rdi
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	subq	$24, %rsp
	.cfi_def_cfa_offset 64
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	leaq	4(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movl	4(%rsp), %esi
	testl	%esi, %esi
	jle	.L31
	leaq	A(%rip), %rbx
	xorl	%r12d, %r12d
	xorl	%ebp, %ebp
	.p2align 4,,10
	.p2align 3
.L27:
	movq	%rbx, %rsi
	xorl	%eax, %eax
	movq	%r13, %rdi
	call	__isoc99_scanf@PLT
	movl	(%rbx), %eax
	movl	4(%rsp), %esi
	cmpl	%eax, %ebp
	cmovl	%eax, %ebp
	addl	$1, %r12d
	addq	$4, %rbx
	cmpl	%r12d, %esi
	jg	.L27
.L26:
	movl	%ebp, %edi
	call	CountingSort
	movl	B(%rip), %edx
	xorl	%eax, %eax
	movq	%r13, %rsi
	movl	$1, %edi
	call	__printf_chk@PLT
	cmpl	$1, 4(%rsp)
	jle	.L28
	movl	$1, %ebx
	leaq	B(%rip), %r12
	leaq	.LC1(%rip), %rbp
	.p2align 4,,10
	.p2align 3
.L29:
	movl	(%r12,%rbx,4), %edx
	movq	%rbp, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	addq	$1, %rbx
	call	__printf_chk@PLT
	cmpl	%ebx, 4(%rsp)
	jg	.L29
.L28:
	movl	$10, %edi
	call	putchar@PLT
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L35
	addq	$24, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	xorl	%eax, %eax
	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
	ret
.L31:
	.cfi_restore_state
	xorl	%ebp, %ebp
	jmp	.L26
.L35:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE24:
	.size	main, .-main
	.globl	C
	.bss
	.align 32
	.type	C, @object
	.size	C, 40004
C:
	.zero	40004
	.globl	B
	.align 32
	.type	B, @object
	.size	B, 8000004
B:
	.zero	8000004
	.globl	A
	.align 32
	.type	A, @object
	.size	A, 8000004
A:
	.zero	8000004
	.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>
#define N 2000001

int A[N], B[N], C[10001];

void CountingSort(int k, int n){
  int i;
  for(i=0;i<=k;i++) C[i]=0;
  for(i=0;i<n;i++) C[A[i]]=C[A[i]]+1;
  for(i=1;i<=k;i++) C[i]=C[i]+C[i-1];
  for(i=n-1;i>=0;i--){
    B[C[A[i]]-1]=A[i];
    C[A[i]]=C[A[i]]-1;
  }
}

int main(){
  int n,k;
  int i;
  k=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
    if(k<A[i]) k=A[i];
  }
  CountingSort(k,n);
  printf("%d",B[0]);
  for(i=1;i<n;i++) 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>
#define N 2000001

int A[N], B[N], C[10001];

void CountingSort(int k, int n){
  int i;
  for(i=0;i<=k;i++) C[i]=0;
  for(i=0;i<n;i++) C[A[i]]=C[A[i]]+1;
  for(i=1;i<=k;i++) C[i]=C[i]+C[i-1];
  for(i=n-1;i>=0;i--){
    B[C[A[i]]-1]=A[i];
    C[A[i]]=C[A[i]]-1;
  }
}

int main(){
  int n,k;
  int i;
  k=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
    if(k<A[i]) k=A[i];
  }
  CountingSort(k,n);
  printf("%d",B[0]);
  for(i=1;i<n;i++) printf(" %d",B[i]);
  printf("\n");
  return 0;
}


```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	A
	.bss
	.align 32
	.type	A, @object
	.size	A, 8000004
A:
	.zero	8000004
	.globl	B
	.align 32
	.type	B, @object
	.size	B, 8000004
B:
	.zero	8000004
	.globl	C
	.align 32
	.type	C, @object
	.size	C, 40004
C:
	.zero	40004
	.text
	.globl	CountingSort
	.type	CountingSort, @function
CountingSort:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -20(%rbp)
	movl	%esi, -24(%rbp)
	movl	$0, -4(%rbp)
	jmp	.L2
.L3:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	C(%rip), %rax
	movl	$0, (%rdx,%rax)
	addl	$1, -4(%rbp)
.L2:
	movl	-4(%rbp), %eax
	cmpl	-20(%rbp), %eax
	jle	.L3
	movl	$0, -4(%rbp)
	jmp	.L4
.L5:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	A(%rip), %rax
	movl	(%rdx,%rax), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	C(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	A(%rip), %rax
	movl	(%rcx,%rax), %eax
	leal	1(%rdx), %ecx
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	C(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	addl	$1, -4(%rbp)
.L4:
	movl	-4(%rbp), %eax
	cmpl	-24(%rbp), %eax
	jl	.L5
	movl	$1, -4(%rbp)
	jmp	.L6
.L7:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	C(%rip), %rax
	movl	(%rdx,%rax), %ecx
	movl	-4(%rbp), %eax
	subl	$1, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	C(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%eax, %ecx
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	C(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	addl	$1, -4(%rbp)
.L6:
	movl	-4(%rbp), %eax
	cmpl	-20(%rbp), %eax
	jle	.L7
	movl	-24(%rbp), %eax
	subl	$1, %eax
	movl	%eax, -4(%rbp)
	jmp	.L8
.L9:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	A(%rip), %rax
	movl	(%rdx,%rax), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	C(%rip), %rax
	movl	(%rdx,%rax), %eax
	leal	-1(%rax), %ecx
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	A(%rip), %rax
	movl	(%rdx,%rax), %eax
	movslq	%ecx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	B(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	A(%rip), %rax
	movl	(%rdx,%rax), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	C(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	A(%rip), %rax
	movl	(%rcx,%rax), %eax
	leal	-1(%rdx), %ecx
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	C(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	subl	$1, -4(%rbp)
.L8:
	cmpl	$0, -4(%rbp)
	jns	.L9
	nop
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	CountingSort, .-CountingSort
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	" %d"
	.text
	.globl	main
	.type	main, @function
main:
.LFB1:
	.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	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -16(%rbp)
	leaq	-20(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -12(%rbp)
	jmp	.L11
.L13:
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	A(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	A(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -16(%rbp)
	jge	.L12
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	A(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -16(%rbp)
.L12:
	addl	$1, -12(%rbp)
.L11:
	movl	-20(%rbp), %eax
	cmpl	%eax, -12(%rbp)
	jl	.L13
	movl	-20(%rbp), %edx
	movl	-16(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	CountingSort
	movl	B(%rip), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$1, -12(%rbp)
	jmp	.L14
.L15:
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	B(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	addl	$1, -12(%rbp)
.L14:
	movl	-20(%rbp), %eax
	cmpl	%eax, -12(%rbp)
	jl	.L15
	movl	$10, %edi
	call	putchar@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L17
	call	__stack_chk_fail@PLT
.L17:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.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	A
	.bss
	.align 32
	.type	A, @object
	.size	A, 8000004
A:
	.zero	8000004
	.globl	B
	.align 32
	.type	B, @object
	.size	B, 8000004
B:
	.zero	8000004
	.globl	C
	.align 32
	.type	C, @object
	.size	C, 40004
C:
	.zero	40004
	.text
	.globl	CountingSort
	.type	CountingSort, @function
CountingSort:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -20(%rbp)
	movl	%esi, -24(%rbp)
	movl	$0, -4(%rbp)
	jmp	.L2
.L3:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	C(%rip), %rax
	movl	$0, (%rdx,%rax)
	addl	$1, -4(%rbp)
.L2:
	movl	-4(%rbp), %eax
	cmpl	-20(%rbp), %eax
	jle	.L3
	movl	$0, -4(%rbp)
	jmp	.L4
.L5:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	A(%rip), %rax
	movl	(%rdx,%rax), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	C(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	A(%rip), %rax
	movl	(%rcx,%rax), %eax
	leal	1(%rdx), %ecx
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	C(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	addl	$1, -4(%rbp)
.L4:
	movl	-4(%rbp), %eax
	cmpl	-24(%rbp), %eax
	jl	.L5
	movl	$1, -4(%rbp)
	jmp	.L6
.L7:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	C(%rip), %rax
	movl	(%rdx,%rax), %ecx
	movl	-4(%rbp), %eax
	subl	$1, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	C(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%eax, %ecx
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	C(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	addl	$1, -4(%rbp)
.L6:
	movl	-4(%rbp), %eax
	cmpl	-20(%rbp), %eax
	jle	.L7
	movl	-24(%rbp), %eax
	subl	$1, %eax
	movl	%eax, -4(%rbp)
	jmp	.L8
.L9:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	A(%rip), %rax
	movl	(%rdx,%rax), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	C(%rip), %rax
	movl	(%rdx,%rax), %eax
	leal	-1(%rax), %ecx
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	A(%rip), %rax
	movl	(%rdx,%rax), %eax
	movslq	%ecx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	B(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	A(%rip), %rax
	movl	(%rdx,%rax), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	C(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	A(%rip), %rax
	movl	(%rcx,%rax), %eax
	leal	-1(%rdx), %ecx
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	C(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	subl	$1, -4(%rbp)
.L8:
	cmpl	$0, -4(%rbp)
	jns	.L9
	nop
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	CountingSort, .-CountingSort
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	" %d"
	.text
	.globl	main
	.type	main, @function
main:
.LFB1:
	.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	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -16(%rbp)
	leaq	-20(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -12(%rbp)
	jmp	.L11
.L13:
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	A(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	A(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -16(%rbp)
	jge	.L12
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	A(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -16(%rbp)
.L12:
	addl	$1, -12(%rbp)
.L11:
	movl	-20(%rbp), %eax
	cmpl	%eax, -12(%rbp)
	jl	.L13
	movl	-20(%rbp), %edx
	movl	-16(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	CountingSort
	movl	B(%rip), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$1, -12(%rbp)
	jmp	.L14
.L15:
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	B(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	addl	$1, -12(%rbp)
.L14:
	movl	-20(%rbp), %eax
	cmpl	%eax, -12(%rbp)
	jl	.L15
	movl	$10, %edi
	call	putchar@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L17
	call	__stack_chk_fail@PLT
.L17:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.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:
