Given the following C code and assembly code, your task is to generate highly optimized x86-64 assembly code.
C Code:

```c
#include <stdio.h>
#include <stdlib.h>

int compare( const void *a, const void *b ) {
	return *(int *)a - *(int *)b;
}

int main( void ) {
	int i;
	int n;

	while ( scanf( "%d", &n ), n ) {
		int data[ 10000 ];
		long long sum;

		for ( i = 0; i < n; i++ )
			scanf( "%d", data + i );
		qsort( data, n, sizeof(int), &compare );

		sum = 0LL;
		for ( i = 0; i < n; i++ )
			sum += data[ i ] * ( n - i - 1 );

		printf( "%lld\n", sum );
	}

	return 0;
}```

Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.p2align 4
	.globl	compare
	.type	compare, @function
compare:
.LFB39:
	.cfi_startproc
	endbr64
	movl	(%rdi), %eax
	subl	(%rsi), %eax
	ret
	.cfi_endproc
.LFE39:
	.size	compare, .-compare
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC1:
	.string	"%d"
.LC3:
	.string	"%lld\n"
	.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
	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	.LC1(%rip), %r12
	leaq	compare(%rip), %r15
	movq	%fs:40, %rax
	movq	%rax, 40024(%rsp)
	xorl	%eax, %eax
	leaq	12(%rsp), %r13
	.p2align 4,,10
	.p2align 3
.L4:
	movq	%r13, %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movslq	12(%rsp), %rsi
	testl	%esi, %esi
	je	.L11
	leaq	16(%rsp), %rbx
	movl	$0, %ebp
	movq	%rbx, %r14
	jle	.L13
	.p2align 4,,10
	.p2align 3
.L5:
	movq	%r14, %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	addl	$1, %ebp
	call	__isoc99_scanf@PLT
	movslq	12(%rsp), %rsi
	addq	$4, %r14
	cmpl	%ebp, %esi
	jg	.L5
.L13:
	movq	%r15, %rcx
	movl	$4, %edx
	movq	%rbx, %rdi
	call	qsort@PLT
	movl	12(%rsp), %eax
	testl	%eax, %eax
	jle	.L15
	leal	-1(%rax), %edx
	cmpl	$2, %edx
	jbe	.L16
	movd	%eax, %xmm7
	pxor	%xmm6, %xmm6
	pxor	%xmm4, %xmm4
	movl	%eax, %edx
	shrl	$2, %edx
	movdqa	.LC0(%rip), %xmm3
	pshufd	$0, %xmm7, %xmm5
	subl	$1, %edx
	salq	$4, %rdx
	leaq	32(%rsp,%rdx), %rdx
	.p2align 4,,10
	.p2align 3
.L8:
	movdqa	%xmm3, %xmm1
	movdqa	%xmm5, %xmm0
	movdqa	(%rbx), %xmm2
	addq	$16, %rbx
	psubd	%xmm1, %xmm0
	paddd	.LC4(%rip), %xmm0
	psrlq	$32, %xmm2
	paddd	.LC2(%rip), %xmm3
	movdqa	%xmm0, %xmm1
	psrlq	$32, %xmm0
	pmuludq	-16(%rbx), %xmm1
	pshufd	$8, %xmm1, %xmm1
	pmuludq	%xmm2, %xmm0
	movdqa	%xmm4, %xmm2
	pshufd	$8, %xmm0, %xmm0
	punpckldq	%xmm0, %xmm1
	pcmpgtd	%xmm1, %xmm2
	movdqa	%xmm1, %xmm0
	punpckldq	%xmm2, %xmm0
	punpckhdq	%xmm2, %xmm1
	paddq	%xmm6, %xmm0
	movdqa	%xmm0, %xmm6
	paddq	%xmm1, %xmm6
	cmpq	%rdx, %rbx
	jne	.L8
	movdqa	%xmm6, %xmm0
	movl	%eax, %ecx
	psrldq	$8, %xmm0
	andl	$-4, %ecx
	paddq	%xmm0, %xmm6
	movq	%xmm6, %rdx
	testb	$3, %al
	je	.L6
.L7:
	movl	%eax, %esi
	movslq	%ecx, %rdi
	subl	%ecx, %esi
	subl	$1, %esi
	imull	16(%rsp,%rdi,4), %esi
	leal	1(%rcx), %edi
	movslq	%esi, %rsi
	addq	%rsi, %rdx
	cmpl	%eax, %edi
	jge	.L6
	movl	%eax, %esi
	addl	$2, %ecx
	subl	%edi, %esi
	movslq	%edi, %rdi
	subl	$1, %esi
	imull	16(%rsp,%rdi,4), %esi
	movslq	%esi, %rsi
	addq	%rsi, %rdx
	cmpl	%ecx, %eax
	jle	.L6
	subl	%ecx, %eax
	movslq	%ecx, %rcx
	subl	$1, %eax
	imull	16(%rsp,%rcx,4), %eax
	cltq
	addq	%rax, %rdx
.L6:
	leaq	.LC3(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L4
	.p2align 4,,10
	.p2align 3
.L11:
	movq	40024(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L21
	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
	.p2align 4,,10
	.p2align 3
.L15:
	.cfi_restore_state
	xorl	%edx, %edx
	jmp	.L6
.L16:
	xorl	%edx, %edx
	xorl	%ecx, %ecx
	jmp	.L7
.L21:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE40:
	.size	main, .-main
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC0:
	.long	0
	.long	1
	.long	2
	.long	3
	.align 16
.LC2:
	.long	4
	.long	4
	.long	4
	.long	4
	.align 16
.LC4:
	.long	-1
	.long	-1
	.long	-1
	.long	-1
	.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.
Optimized Assembly Code:

user
```assembly
	.file	"temp.c"
	.text
	.p2align 4
	.globl	compare
	.type	compare, @function
compare:
.LFB39:
	.cfi_startproc
	endbr64
	movl	(%rdi), %eax
	subl	(%rsi), %eax
	ret
	.cfi_endproc
.LFE39:
	.size	compare, .-compare
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC1:
	.string	"%d"
.LC3:
	.string	"%lld\n"
	.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
	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	.LC1(%rip), %r12
	leaq	compare(%rip), %r15
	movq	%fs:40, %rax
	movq	%rax, 40024(%rsp)
	xorl	%eax, %eax
	leaq	12(%rsp), %r13
	.p2align 4,,10
	.p2align 3
.L4:
	movq	%r13, %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movslq	12(%rsp), %rsi
	testl	%esi, %esi
	je	.L11
	leaq	16(%rsp), %rbx
	movl	$0, %ebp
	movq	%rbx, %r14
	jle	.L13
	.p2align 4,,10
	.p2align 3
.L5:
	movq	%r14, %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	addl	$1, %ebp
	call	__isoc99_scanf@PLT
	movslq	12(%rsp), %rsi
	addq	$4, %r14
	cmpl	%ebp, %esi
	jg	.L5
.L13:
	movq	%r15, %rcx
	movl	$4, %edx
	movq	%rbx, %rdi
	call	qsort@PLT
	movl	12(%rsp), %eax
	testl	%eax, %eax
	jle	.L15
	leal	-1(%rax), %edx
	cmpl	$2, %edx
	jbe	.L16
	movd	%eax, %xmm7
	pxor	%xmm6, %xmm6
	pxor	%xmm4, %xmm4
	movl	%eax, %edx
	shrl	$2, %edx
	movdqa	.LC0(%rip), %xmm3
	pshufd	$0, %xmm7, %xmm5
	subl	$1, %edx
	salq	$4, %rdx
	leaq	32(%rsp,%rdx), %rdx
	.p2align 4,,10
	.p2align 3
.L8:
	movdqa	%xmm3, %xmm1
	movdqa	%xmm5, %xmm0
	movdqa	(%rbx), %xmm2
	addq	$16, %rbx
	psubd	%xmm1, %xmm0
	paddd	.LC4(%rip), %xmm0
	psrlq	$32, %xmm2
	paddd	.LC2(%rip), %xmm3
	movdqa	%xmm0, %xmm1
	psrlq	$32, %xmm0
	pmuludq	-16(%rbx), %xmm1
	pshufd	$8, %xmm1, %xmm1
	pmuludq	%xmm2, %xmm0
	movdqa	%xmm4, %xmm2
	pshufd	$8, %xmm0, %xmm0
	punpckldq	%xmm0, %xmm1
	pcmpgtd	%xmm1, %xmm2
	movdqa	%xmm1, %xmm0
	punpckldq	%xmm2, %xmm0
	punpckhdq	%xmm2, %xmm1
	paddq	%xmm6, %xmm0
	movdqa	%xmm0, %xmm6
	paddq	%xmm1, %xmm6
	cmpq	%rdx, %rbx
	jne	.L8
	movdqa	%xmm6, %xmm0
	movl	%eax, %ecx
	psrldq	$8, %xmm0
	andl	$-4, %ecx
	paddq	%xmm0, %xmm6
	movq	%xmm6, %rdx
	testb	$3, %al
	je	.L6
.L7:
	movl	%eax, %esi
	movslq	%ecx, %rdi
	subl	%ecx, %esi
	subl	$1, %esi
	imull	16(%rsp,%rdi,4), %esi
	leal	1(%rcx), %edi
	movslq	%esi, %rsi
	addq	%rsi, %rdx
	cmpl	%eax, %edi
	jge	.L6
	movl	%eax, %esi
	addl	$2, %ecx
	subl	%edi, %esi
	movslq	%edi, %rdi
	subl	$1, %esi
	imull	16(%rsp,%rdi,4), %esi
	movslq	%esi, %rsi
	addq	%rsi, %rdx
	cmpl	%ecx, %eax
	jle	.L6
	subl	%ecx, %eax
	movslq	%ecx, %rcx
	subl	$1, %eax
	imull	16(%rsp,%rcx,4), %eax
	cltq
	addq	%rax, %rdx
.L6:
	leaq	.LC3(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L4
	.p2align 4,,10
	.p2align 3
.L11:
	movq	40024(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L21
	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
	.p2align 4,,10
	.p2align 3
.L15:
	.cfi_restore_state
	xorl	%edx, %edx
	jmp	.L6
.L16:
	xorl	%edx, %edx
	xorl	%ecx, %ecx
	jmp	.L7
.L21:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE40:
	.size	main, .-main
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC0:
	.long	0
	.long	1
	.long	2
	.long	3
	.align 16
.LC2:
	.long	4
	.long	4
	.long	4
	.long	4
	.align 16
.LC4:
	.long	-1
	.long	-1
	.long	-1
	.long	-1
	.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
```assembly
	.file	"temp.c"
	.text
	.p2align 4
	.globl	compare
	.type	compare, @function
compare:
.LFB39:
	.cfi_startproc
	endbr64
	movl	(%rdi), %eax
	subl	(%rsi), %eax
	ret
	.cfi_endproc
.LFE39:
	.size	compare, .-compare
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC1:
	.string	"%d"
.LC3:
	.string	"%lld\n"
	.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
	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	.LC1(%rip), %r12
	leaq	compare(%rip), %r15
	movq	%fs:40, %rax
	movq	%rax, 40024(%rsp)
	xorl	%eax, %eax
	leaq	12(%rsp), %r13
	.p2align 4,,10
	.p2align 3
.L4:
	movq	%r13, %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movslq	12(%rsp), %rsi
	testl	%esi, %esi
	je	.L11
	leaq	16(%rsp), %rbx
	movl	$0, %ebp
	movq	%rbx, %r14
	jle	.L13
	.p2align 4,,10
	.p2align 3
.L5:
	movq	%r14, %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	addl	$1, %ebp
	call	__isoc99_scanf@PLT
	movslq	12(%rsp), %rsi
	addq	$4, %r14
	cmpl	%ebp, %esi
	jg	.L5
.L13:
	movq	%r15, %rcx
	movl	$4, %edx
	movq	%rbx, %rdi
	call	qsort@PLT
	movl	12(%rsp), %eax
	testl	%eax, %eax
	jle	.L15
	leal	-1(%rax), %edx
	cmpl	$2, %edx
	jbe	.L16
	movd	%eax, %xmm7
	pxor	%xmm6, %xmm6
	pxor	%xmm4, %xmm4
	movl	%eax, %edx
	shrl	$2, %edx
	movdqa	.LC0(%rip), %xmm3
	pshufd	$0, %xmm7, %xmm5
	subl	$1, %edx
	salq	$4, %rdx
	leaq	32(%rsp,%rdx), %rdx
	.p2align 4,,10
	.p2align 3
.L8:
	movdqa	%xmm3, %xmm1
	movdqa	%xmm5, %xmm0
	movdqa	(%rbx), %xmm2
	addq	$16, %rbx
	psubd	%xmm1, %xmm0
	paddd	.LC4(%rip), %xmm0
	psrlq	$32, %xmm2
	paddd	.LC2(%rip), %xmm3
	movdqa	%xmm0, %xmm1
	psrlq	$32, %xmm0
	pmuludq	-16(%rbx), %xmm1
	pshufd	$8, %xmm1, %xmm1
	pmuludq	%xmm2, %xmm0
	movdqa	%xmm4, %xmm2
	pshufd	$8, %xmm0, %xmm0
	punpckldq	%xmm0, %xmm1
	pcmpgtd	%xmm1, %xmm2
	movdqa	%xmm1, %xmm0
	punpckldq	%xmm2, %xmm0
	punpckhdq	%xmm2, %xmm1
	paddq	%xmm6, %xmm0
	movdqa	%xmm0, %xmm6
	paddq	%xmm1, %xmm6
	cmpq	%rdx, %rbx
	jne	.L8
	movdqa	%xmm6, %xmm0
	movl	%eax, %ecx
	psrldq	$8, %xmm0
	andl	$-4, %ecx
	paddq	%xmm0, %xmm6
	movq	%xmm6, %rdx
	testb	$3, %al
	je	.L6
.L7:
	movl	%eax, %esi
	movslq	%ecx, %rdi
	subl	%ecx, %esi
	subl	$1, %esi
	imull	16(%rsp,%rdi,4), %esi
	leal	1(%rcx), %edi
	movslq	%esi, %rsi
	addq	%rsi, %rdx
	cmpl	%eax, %edi
	jge	.L6
	movl	%eax, %esi
	addl	$2, %ecx
	subl	%edi, %esi
	movslq	%edi, %rdi
	subl	$1, %esi
	imull	16(%rsp,%rdi,4), %esi
	movslq	%esi, %rsi
	addq	%rsi, %rdx
	cmpl	%ecx, %eax
	jle	.L6
	subl	%ecx, %eax
	movslq	%ecx, %rcx
	subl	$1, %eax
	imull	16(%rsp,%rcx,4), %eax
	cltq
	addq	%rax, %rdx
.L6:
	leaq	.LC3(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L4
	.p2align 4,,10
	.p2align 3
.L11:
	movq	40024(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L21
	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
	.p2align 4,,10
	.p2align 3
.L15:
	.cfi_restore_state
	xorl	%edx, %edx
	jmp	.L6
.L16:
	xorl	%edx, %edx
	xorl	%ecx, %ecx
	jmp	.L7
.L21:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE40:
	.size	main, .-main
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC0:
	.long	0
	.long	1
	.long	2
	.long	3
	.align 16
.LC2:
	.long	4
	.long	4
	.long	4
	.long	4
	.align 16
.LC4:
	.long	-1
	.long	-1
	.long	-1
	.long	-1
	.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:
```
```c
#include <stdio.h>
#include <stdlib.h>

int compare( const void *a, const void *b ) {
	return *(int *)a - *(int *)b;
}

int main( void ) {
	int i;
	int n;

	while ( scanf( "%d", &n ), n ) {
		int data[ 10000 ];
		long long sum;

		for ( i = 0; i < n; i++ )
			scanf( "%d", data + i );
		qsort( data, n, sizeof(int), &compare );

		sum = 0LL;
		for ( i = 0; i < n; i++ )
			sum += data[ i ] * ( n - i - 1 );

		printf( "%lld\n", sum );
	}

	return 0;
}```
Given the following C code, your task is to generate highly optimized x86-64 assembly code.
C Code:

```c
#include <stdio.h>
#include <stdlib.h>

int compare( const void *a, const void *b ) {
	return *(int *)a - *(int *)b;
}

int main( void ) {
	int i;
	int n;

	while ( scanf( "%d", &n ), n ) {
		int data[ 10000 ];
		long long sum;

		for ( i = 0; i < n; i++ )
			scanf( "%d", data + i );
		qsort( data, n, sizeof(int), &compare );

		sum = 0LL;
		for ( i = 0; i < n; i++ )
			sum += data[ i ] * ( n - i - 1 );

		printf( "%lld\n", sum );
	}

	return 0;
}```

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.
Optimized Assembly Code:

5
2
6
4
6
9
0
 5
2
10
4
6
9
0
 5
2
6
4
7
9
0
 5
2
10
4
7
9
0
 5
2
17
8
7
9
0
 5
4
6
4
7
14
0
 5
2
17
8
7
12
0
 5
4
6
5
7
14
0
 5
1
17
8
7
12
0
 5
0
17
8
7
12
0

38
 41
 39
 43
 54
 47
 57
 50
 53
 49

Given the following C code and assembly code, your task is to generate highly optimized x86-64 assembly code.
C Code:

```c
#include <stdio.h>
#include <stdlib.h>

int compare( const void *a, const void *b ) {
	return *(int *)a - *(int *)b;
}

int main( void ) {
	int i;
	int n;

	while ( scanf( "%d", &n ), n ) {
		int data[ 10000 ];
		long long sum;

		for ( i = 0; i < n; i++ )
			scanf( "%d", data + i );
		qsort( data, n, sizeof(int), &compare );

		sum = 0LL;
		for ( i = 0; i < n; i++ )
			sum += data[ i ] * ( n - i - 1 );

		printf( "%lld\n", sum );
	}

	return 0;
}```

Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.p2align 4
	.globl	compare
	.type	compare, @function
compare:
.LFB39:
	.cfi_startproc
	endbr64
	movl	(%rdi), %eax
	subl	(%rsi), %eax
	ret
	.cfi_endproc
.LFE39:
	.size	compare, .-compare
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC1:
	.string	"%d"
.LC3:
	.string	"%lld\n"
	.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
	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	.LC1(%rip), %r12
	leaq	compare(%rip), %r15
	movq	%fs:40, %rax
	movq	%rax, 40024(%rsp)
	xorl	%eax, %eax
	leaq	12(%rsp), %r13
	.p2align 4,,10
	.p2align 3
.L4:
	movq	%r13, %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movslq	12(%rsp), %rsi
	testl	%esi, %esi
	je	.L11
	leaq	16(%rsp), %rbx
	movl	$0, %ebp
	movq	%rbx, %r14
	jle	.L13
	.p2align 4,,10
	.p2align 3
.L5:
	movq	%r14, %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	addl	$1, %ebp
	call	__isoc99_scanf@PLT
	movslq	12(%rsp), %rsi
	addq	$4, %r14
	cmpl	%ebp, %esi
	jg	.L5
.L13:
	movq	%r15, %rcx
	movl	$4, %edx
	movq	%rbx, %rdi
	call	qsort@PLT
	movl	12(%rsp), %eax
	testl	%eax, %eax
	jle	.L15
	leal	-1(%rax), %edx
	cmpl	$2, %edx
	jbe	.L16
	movd	%eax, %xmm7
	pxor	%xmm6, %xmm6
	pxor	%xmm4, %xmm4
	movl	%eax, %edx
	shrl	$2, %edx
	movdqa	.LC0(%rip), %xmm3
	pshufd	$0, %xmm7, %xmm5
	subl	$1, %edx
	salq	$4, %rdx
	leaq	32(%rsp,%rdx), %rdx
	.p2align 4,,10
	.p2align 3
.L8:
	movdqa	%xmm3, %xmm1
	movdqa	%xmm5, %xmm0
	movdqa	(%rbx), %xmm2
	addq	$16, %rbx
	psubd	%xmm1, %xmm0
	paddd	.LC4(%rip), %xmm0
	psrlq	$32, %xmm2
	paddd	.LC2(%rip), %xmm3
	movdqa	%xmm0, %xmm1
	psrlq	$32, %xmm0
	pmuludq	-16(%rbx), %xmm1
	pshufd	$8, %xmm1, %xmm1
	pmuludq	%xmm2, %xmm0
	movdqa	%xmm4, %xmm2
	pshufd	$8, %xmm0, %xmm0
	punpckldq	%xmm0, %xmm1
	pcmpgtd	%xmm1, %xmm2
	movdqa	%xmm1, %xmm0
	punpckldq	%xmm2, %xmm0
	punpckhdq	%xmm2, %xmm1
	paddq	%xmm6, %xmm0
	movdqa	%xmm0, %xmm6
	paddq	%xmm1, %xmm6
	cmpq	%rdx, %rbx
	jne	.L8
	movdqa	%xmm6, %xmm0
	movl	%eax, %ecx
	psrldq	$8, %xmm0
	andl	$-4, %ecx
	paddq	%xmm0, %xmm6
	movq	%xmm6, %rdx
	testb	$3, %al
	je	.L6
.L7:
	movl	%eax, %esi
	movslq	%ecx, %rdi
	subl	%ecx, %esi
	subl	$1, %esi
	imull	16(%rsp,%rdi,4), %esi
	leal	1(%rcx), %edi
	movslq	%esi, %rsi
	addq	%rsi, %rdx
	cmpl	%eax, %edi
	jge	.L6
	movl	%eax, %esi
	addl	$2, %ecx
	subl	%edi, %esi
	movslq	%edi, %rdi
	subl	$1, %esi
	imull	16(%rsp,%rdi,4), %esi
	movslq	%esi, %rsi
	addq	%rsi, %rdx
	cmpl	%ecx, %eax
	jle	.L6
	subl	%ecx, %eax
	movslq	%ecx, %rcx
	subl	$1, %eax
	imull	16(%rsp,%rcx,4), %eax
	cltq
	addq	%rax, %rdx
.L6:
	leaq	.LC3(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L4
	.p2align 4,,10
	.p2align 3
.L11:
	movq	40024(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L21
	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
	.p2align 4,,10
	.p2align 3
.L15:
	.cfi_restore_state
	xorl	%edx, %edx
	jmp	.L6
.L16:
	xorl	%edx, %edx
	xorl	%ecx, %ecx
	jmp	.L7
.L21:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE40:
	.size	main, .-main
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC0:
	.long	0
	.long	1
	.long	2
	.long	3
	.align 16
.LC2:
	.long	4
	.long	4
	.long	4
	.long	4
	.align 16
.LC4:
	.long	-1
	.long	-1
	.long	-1
	.long	-1
	.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.
Optimized Assembly Code:

train
```assembly
	.file	"temp.c"
	.text
	.p2align 4
	.globl	compare
	.type	compare, @function
compare:
.LFB39:
	.cfi_startproc
	endbr64
	movl	(%rdi), %eax
	subl	(%rsi), %eax
	ret
	.cfi_endproc
.LFE39:
	.size	compare, .-compare
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC1:
	.string	"%d"
.LC3:
	.string	"%lld\n"
	.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
	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	.LC1(%rip), %r12
	leaq	compare(%rip), %r15
	movq	%fs:40, %rax
	movq	%rax, 40024(%rsp)
	xorl	%eax, %eax
	leaq	12(%rsp), %r13
	.p2align 4,,10
	.p2align 3
.L4:
	movq	%r13, %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movslq	12(%rsp), %rsi
	testl	%esi, %esi
	je	.L11
	leaq	16(%rsp), %rbx
	movl	$0, %ebp
	movq	%rbx, %r14
	jle	.L13
	.p2align 4,,10
	.p2align 3
.L5:
	movq	%r14, %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	addl	$1, %ebp
	call	__isoc99_scanf@PLT
	movslq	12(%rsp), %rsi
	addq	$4, %r14
	cmpl	%ebp, %esi
	jg	.L5
.L13:
	movq	%r15, %rcx
	movl	$4, %edx
	movq	%rbx, %rdi
	call	qsort@PLT
	movl	12(%rsp), %eax
	testl	%eax, %eax
	jle	.L15
	leal	-1(%rax), %edx
	cmpl	$2, %edx
	jbe	.L16
	movd	%eax, %xmm7
	pxor	%xmm6, %xmm6
	pxor	%xmm4, %xmm4
	movl	%eax, %edx
	shrl	$2, %edx
	movdqa	.LC0(%rip), %xmm3
	pshufd	$0, %xmm7, %xmm5
	subl	$1, %edx
	salq	$4, %rdx
	leaq	32(%rsp,%rdx), %rdx
	.p2align 4,,10
	.p2align 3
.L8:
	movdqa	%xmm3, %xmm1
	movdqa	%xmm5, %xmm0
	movdqa	(%rbx), %xmm2
	addq	$16, %rbx
	psubd	%xmm1, %xmm0
	paddd	.LC4(%rip), %xmm0
	psrlq	$32, %xmm2
	paddd	.LC2(%rip), %xmm3
	movdqa	%xmm0, %xmm1
	psrlq	$32, %xmm0
	pmuludq	-16(%rbx), %xmm1
	pshufd	$8, %xmm1, %xmm1
	pmuludq	%xmm2, %xmm0
	movdqa	%xmm4, %xmm2
	pshufd	$8, %xmm0, %xmm0
	punpckldq	%xmm0, %xmm1
	pcmpgtd	%xmm1, %xmm2
	movdqa	%xmm1, %xmm0
	punpckldq	%xmm2, %xmm0
	punpckhdq	%xmm2, %xmm1
	paddq	%xmm6, %xmm0
	movdqa	%xmm0, %xmm6
	paddq	%xmm1, %xmm6
	cmpq	%rdx, %rbx
	jne	.L8
	movdqa	%xmm6, %xmm0
	movl	%eax, %ecx
	psrldq	$8, %xmm0
	andl	$-4, %ecx
	paddq	%xmm0, %xmm6
	movq	%xmm6, %rdx
	testb	$3, %al
	je	.L6
.L7:
	movl	%eax, %esi
	movslq	%ecx, %rdi
	subl	%ecx, %esi
	subl	$1, %esi
	imull	16(%rsp,%rdi,4), %esi
	leal	1(%rcx), %edi
	movslq	%esi, %rsi
	addq	%rsi, %rdx
	cmpl	%eax, %edi
	jge	.L6
	movl	%eax, %esi
	addl	$2, %ecx
	subl	%edi, %esi
	movslq	%edi, %rdi
	subl	$1, %esi
	imull	16(%rsp,%rdi,4), %esi
	movslq	%esi, %rsi
	addq	%rsi, %rdx
	cmpl	%ecx, %eax
	jle	.L6
	subl	%ecx, %eax
	movslq	%ecx, %rcx
	subl	$1, %eax
	imull	16(%rsp,%rcx,4), %eax
	cltq
	addq	%rax, %rdx
.L6:
	leaq	.LC3(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L4
	.p2align 4,,10
	.p2align 3
.L11:
	movq	40024(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L21
	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
	.p2align 4,,10
	.p2align 3
.L15:
	.cfi_restore_state
	xorl	%edx, %edx
	jmp	.L6
.L16:
	xorl	%edx, %edx
	xorl	%ecx, %ecx
	jmp	.L7
.L21:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE40:
	.size	main, .-main
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC0:
	.long	0
	.long	1
	.long	2
	.long	3
	.align 16
.LC2:
	.long	4
	.long	4
	.long	4
	.long	4
	.align 16
.LC4:
	.long	-1
	.long	-1
	.long	-1
	.long	-1
	.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:
```