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 <math.h>
int main()
{
	int n,i,j,k,sum=0;
	scanf("%d",&n);
	int tri[n];
	for(i=0;i<n;i++)
	{
		scanf("%d",&tri[i]);
	}
	for(i=0;i<n-1;i++)
	{
		for(j=i+1;j<n;j++)
		{
			if(tri[i]>tri[j])
			{
				tri[i]=tri[i]+tri[j];
				tri[j]=tri[i]-tri[j];
				tri[i]=tri[i]-tri[j];
			}
		}
	}
	for(i=0;i<n-2;i++)
	{
		for(j=i+1;j<n-1;j++)
		{
			for(k=j+1;k<n;k++)
			{
				if(tri[i]+tri[j]>tri[k]) sum++;
			}
		}
	}
	printf("%d",sum);
} ```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d"
	.text
	.globl	main
	.type	main, @function
main:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%r15
	pushq	%r14
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	subq	$56, %rsp
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	.cfi_offset 12, -48
	.cfi_offset 3, -56
	movq	%fs:40, %rax
	movq	%rax, -56(%rbp)
	xorl	%eax, %eax
	movq	%rsp, %rax
	movq	%rax, %rbx
	movl	$0, -76(%rbp)
	leaq	-92(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-92(%rbp), %eax
	movslq	%eax, %rdx
	subq	$1, %rdx
	movq	%rdx, -72(%rbp)
	movslq	%eax, %rdx
	movq	%rdx, %r14
	movl	$0, %r15d
	movslq	%eax, %rdx
	movq	%rdx, %r12
	movl	$0, %r13d
	cltq
	leaq	0(,%rax,4), %rdx
	movl	$16, %eax
	subq	$1, %rax
	addq	%rdx, %rax
	movl	$16, %esi
	movl	$0, %edx
	divq	%rsi
	imulq	$16, %rax, %rax
	movq	%rax, %rcx
	andq	$-4096, %rcx
	movq	%rsp, %rdx
	subq	%rcx, %rdx
.L2:
	cmpq	%rdx, %rsp
	je	.L3
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L2
.L3:
	movq	%rax, %rdx
	andl	$4095, %edx
	subq	%rdx, %rsp
	movq	%rax, %rdx
	andl	$4095, %edx
	testq	%rdx, %rdx
	je	.L4
	andl	$4095, %eax
	subq	$8, %rax
	addq	%rsp, %rax
	orq	$0, (%rax)
.L4:
	movq	%rsp, %rax
	addq	$3, %rax
	shrq	$2, %rax
	salq	$2, %rax
	movq	%rax, -64(%rbp)
	movl	$0, -88(%rbp)
	jmp	.L5
.L6:
	movl	-88(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-64(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -88(%rbp)
.L5:
	movl	-92(%rbp), %eax
	cmpl	%eax, -88(%rbp)
	jl	.L6
	movl	$0, -88(%rbp)
	jmp	.L7
.L11:
	movl	-88(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -84(%rbp)
	jmp	.L8
.L10:
	movq	-64(%rbp), %rax
	movl	-88(%rbp), %edx
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %ecx
	movq	-64(%rbp), %rax
	movl	-84(%rbp), %edx
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %eax
	cmpl	%eax, %ecx
	jle	.L9
	movq	-64(%rbp), %rax
	movl	-88(%rbp), %edx
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %ecx
	movq	-64(%rbp), %rax
	movl	-84(%rbp), %edx
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %eax
	addl	%eax, %ecx
	movq	-64(%rbp), %rax
	movl	-88(%rbp), %edx
	movslq	%edx, %rdx
	movl	%ecx, (%rax,%rdx,4)
	movq	-64(%rbp), %rax
	movl	-88(%rbp), %edx
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %ecx
	movq	-64(%rbp), %rax
	movl	-84(%rbp), %edx
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %eax
	subl	%eax, %ecx
	movq	-64(%rbp), %rax
	movl	-84(%rbp), %edx
	movslq	%edx, %rdx
	movl	%ecx, (%rax,%rdx,4)
	movq	-64(%rbp), %rax
	movl	-88(%rbp), %edx
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %ecx
	movq	-64(%rbp), %rax
	movl	-84(%rbp), %edx
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %eax
	subl	%eax, %ecx
	movq	-64(%rbp), %rax
	movl	-88(%rbp), %edx
	movslq	%edx, %rdx
	movl	%ecx, (%rax,%rdx,4)
.L9:
	addl	$1, -84(%rbp)
.L8:
	movl	-92(%rbp), %eax
	cmpl	%eax, -84(%rbp)
	jl	.L10
	addl	$1, -88(%rbp)
.L7:
	movl	-92(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -88(%rbp)
	jl	.L11
	movl	$0, -88(%rbp)
	jmp	.L12
.L18:
	movl	-88(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -84(%rbp)
	jmp	.L13
.L17:
	movl	-84(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -80(%rbp)
	jmp	.L14
.L16:
	movq	-64(%rbp), %rax
	movl	-88(%rbp), %edx
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %ecx
	movq	-64(%rbp), %rax
	movl	-84(%rbp), %edx
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %eax
	addl	%eax, %ecx
	movq	-64(%rbp), %rax
	movl	-80(%rbp), %edx
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %eax
	cmpl	%eax, %ecx
	jle	.L15
	addl	$1, -76(%rbp)
.L15:
	addl	$1, -80(%rbp)
.L14:
	movl	-92(%rbp), %eax
	cmpl	%eax, -80(%rbp)
	jl	.L16
	addl	$1, -84(%rbp)
.L13:
	movl	-92(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -84(%rbp)
	jl	.L17
	addl	$1, -88(%rbp)
.L12:
	movl	-92(%rbp), %eax
	subl	$2, %eax
	cmpl	%eax, -88(%rbp)
	jl	.L18
	movl	-76(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movq	%rbx, %rsp
	movl	$0, %eax
	movq	-56(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L20
	call	__stack_chk_fail@PLT
.L20:
	leaq	-40(%rbp), %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.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"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%r15
	pushq	%r14
	leaq	-60(%rbp), %rsi
	pushq	%r13
	pushq	%r12
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	.cfi_offset 12, -48
	leaq	.LC0(%rip), %r12
	pushq	%rbx
	movq	%r12, %rdi
	subq	$40, %rsp
	.cfi_offset 3, -56
	movq	%fs:40, %rax
	movq	%rax, -56(%rbp)
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movslq	-60(%rbp), %rax
	movq	%rsp, %rcx
	leaq	15(,%rax,4), %rdx
	movq	%rax, %r11
	movq	%rdx, %rax
	andq	$-4096, %rdx
	subq	%rdx, %rcx
	andq	$-16, %rax
	cmpq	%rcx, %rsp
	je	.L3
.L44:
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	cmpq	%rcx, %rsp
	jne	.L44
.L3:
	andl	$4095, %eax
	subq	%rax, %rsp
	testq	%rax, %rax
	jne	.L45
.L4:
	movq	%rsp, %rbx
	testl	%r11d, %r11d
	jle	.L5
	movq	%rbx, %r14
	xorl	%r13d, %r13d
	.p2align 4,,10
	.p2align 3
.L6:
	movq	%r14, %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	addl	$1, %r13d
	call	__isoc99_scanf@PLT
	movl	-60(%rbp), %r11d
	addq	$4, %r14
	cmpl	%r13d, %r11d
	jg	.L6
.L5:
	leal	-1(%r11), %r13d
	testl	%r13d, %r13d
	jle	.L46
	leal	-2(%r11), %r8d
	movq	%rbx, %rcx
	leaq	4(%rbx), %r9
	movl	$1, %edi
	movl	%r8d, -68(%rbp)
	addq	$2, %r8
	.p2align 4,,10
	.p2align 3
.L11:
	cmpl	%edi, %r11d
	jle	.L15
	movl	%r13d, %eax
	movl	(%rcx), %r10d
	movq	%rcx, %rdx
	subl	%edi, %eax
	leaq	-1(%rdi,%rax), %rax
	leaq	(%r9,%rax,4), %rsi
	.p2align 4,,10
	.p2align 3
.L14:
	movl	4(%rdx), %eax
	cmpl	%eax, %r10d
	jle	.L13
	addl	%r10d, %eax
	movl	%eax, (%rcx)
	subl	4(%rdx), %eax
	movl	%eax, 4(%rdx)
	movl	(%rcx), %r10d
	subl	%eax, %r10d
	movl	%r10d, (%rcx)
.L13:
	addq	$4, %rdx
	cmpq	%rsi, %rdx
	jne	.L14
.L15:
	addq	$1, %rdi
	addq	$4, %rcx
	cmpq	%r8, %rdi
	jne	.L11
.L12:
	movl	-68(%rbp), %eax
	leaq	8(%rbx), %r14
	xorl	%r8d, %r8d
	xorl	%r15d, %r15d
	testl	%eax, %eax
	jle	.L9
	.p2align 4,,10
	.p2align 3
.L27:
	addl	$1, %r15d
	cmpl	%r13d, %r15d
	jge	.L16
	movl	%r13d, %r9d
	movq	%r14, %rdi
	movl	%r15d, %esi
	subl	%r15d, %r9d
	.p2align 4,,10
	.p2align 3
.L26:
	addl	$1, %esi
	leal	-1(%r9), %r10d
	cmpl	%r11d, %esi
	jge	.L17
	leal	-1(%r9), %r10d
	movl	-4(%rdi), %ecx
	addl	-8(%r14), %ecx
	cmpl	$2, %r10d
	jbe	.L29
	movl	%r9d, %eax
	movd	%ecx, %xmm4
	pxor	%xmm0, %xmm0
	shrl	$2, %eax
	pshufd	$0, %xmm4, %xmm2
	subl	$1, %eax
	salq	$4, %rax
	leaq	16(%rdi,%rax), %rdx
	movq	%rdi, %rax
	.p2align 4,,10
	.p2align 3
.L19:
	movdqu	(%rax), %xmm3
	movdqa	%xmm2, %xmm1
	addq	$16, %rax
	pcmpgtd	%xmm3, %xmm1
	psubd	%xmm1, %xmm0
	cmpq	%rdx, %rax
	jne	.L19
	movdqa	%xmm0, %xmm1
	movl	%r9d, %edx
	psrldq	$8, %xmm1
	andl	$-4, %edx
	paddd	%xmm1, %xmm0
	movdqa	%xmm0, %xmm1
	psrldq	$4, %xmm1
	paddd	%xmm1, %xmm0
	movd	%xmm0, %eax
	addl	%eax, %r8d
	leal	(%rdx,%rsi), %eax
	cmpl	%edx, %r9d
	je	.L17
.L18:
	movslq	%eax, %rdx
	xorl	%r9d, %r9d
	leaq	(%rbx,%rdx,4), %rdx
	cmpl	(%rdx), %ecx
	setg	%r9b
	addl	%r9d, %r8d
	leal	1(%rax), %r9d
	cmpl	%r11d, %r9d
	jge	.L17
	xorl	%r9d, %r9d
	cmpl	4(%rdx), %ecx
	setg	%r9b
	addl	$2, %eax
	addl	%r9d, %r8d
	cmpl	%r11d, %eax
	jge	.L17
	xorl	%eax, %eax
	cmpl	8(%rdx), %ecx
	setg	%al
	addl	%eax, %r8d
.L17:
	movl	%r10d, %r9d
	addq	$4, %rdi
	cmpl	%r13d, %esi
	jne	.L26
.L16:
	addq	$4, %r14
	cmpl	-68(%rbp), %r15d
	jne	.L27
.L9:
	xorl	%eax, %eax
	movl	%r8d, %edx
	movq	%r12, %rsi
	movl	$1, %edi
	call	__printf_chk@PLT
	movq	-56(%rbp), %rax
	subq	%fs:40, %rax
	jne	.L47
	leaq	-40(%rbp), %rsp
	xorl	%eax, %eax
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_remember_state
	.cfi_def_cfa 7, 8
	ret
.L29:
	.cfi_restore_state
	movl	%esi, %eax
	jmp	.L18
.L45:
	orq	$0, -8(%rsp,%rax)
	jmp	.L4
.L46:
	leal	-2(%r11), %eax
	movl	%eax, -68(%rbp)
	jmp	.L12
.L47:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.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"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%r15
	pushq	%r14
	leaq	-60(%rbp), %rsi
	pushq	%r13
	pushq	%r12
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	.cfi_offset 12, -48
	leaq	.LC0(%rip), %r12
	pushq	%rbx
	movq	%r12, %rdi
	subq	$40, %rsp
	.cfi_offset 3, -56
	movq	%fs:40, %rax
	movq	%rax, -56(%rbp)
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movslq	-60(%rbp), %rax
	movq	%rsp, %rcx
	leaq	15(,%rax,4), %rdx
	movq	%rax, %r11
	movq	%rdx, %rax
	andq	$-4096, %rdx
	subq	%rdx, %rcx
	andq	$-16, %rax
	cmpq	%rcx, %rsp
	je	.L3
.L44:
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	cmpq	%rcx, %rsp
	jne	.L44
.L3:
	andl	$4095, %eax
	subq	%rax, %rsp
	testq	%rax, %rax
	jne	.L45
.L4:
	movq	%rsp, %rbx
	testl	%r11d, %r11d
	jle	.L5
	movq	%rbx, %r14
	xorl	%r13d, %r13d
	.p2align 4,,10
	.p2align 3
.L6:
	movq	%r14, %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	addl	$1, %r13d
	call	__isoc99_scanf@PLT
	movl	-60(%rbp), %r11d
	addq	$4, %r14
	cmpl	%r13d, %r11d
	jg	.L6
.L5:
	leal	-1(%r11), %r13d
	testl	%r13d, %r13d
	jle	.L46
	leal	-2(%r11), %r8d
	movq	%rbx, %rcx
	leaq	4(%rbx), %r9
	movl	$1, %edi
	movl	%r8d, -68(%rbp)
	addq	$2, %r8
	.p2align 4,,10
	.p2align 3
.L11:
	cmpl	%edi, %r11d
	jle	.L15
	movl	%r13d, %eax
	movl	(%rcx), %r10d
	movq	%rcx, %rdx
	subl	%edi, %eax
	leaq	-1(%rdi,%rax), %rax
	leaq	(%r9,%rax,4), %rsi
	.p2align 4,,10
	.p2align 3
.L14:
	movl	4(%rdx), %eax
	cmpl	%eax, %r10d
	jle	.L13
	addl	%r10d, %eax
	movl	%eax, (%rcx)
	subl	4(%rdx), %eax
	movl	%eax, 4(%rdx)
	movl	(%rcx), %r10d
	subl	%eax, %r10d
	movl	%r10d, (%rcx)
.L13:
	addq	$4, %rdx
	cmpq	%rsi, %rdx
	jne	.L14
.L15:
	addq	$1, %rdi
	addq	$4, %rcx
	cmpq	%r8, %rdi
	jne	.L11
.L12:
	movl	-68(%rbp), %eax
	leaq	8(%rbx), %r14
	xorl	%r8d, %r8d
	xorl	%r15d, %r15d
	testl	%eax, %eax
	jle	.L9
	.p2align 4,,10
	.p2align 3
.L27:
	addl	$1, %r15d
	cmpl	%r13d, %r15d
	jge	.L16
	movl	%r13d, %r9d
	movq	%r14, %rdi
	movl	%r15d, %esi
	subl	%r15d, %r9d
	.p2align 4,,10
	.p2align 3
.L26:
	addl	$1, %esi
	leal	-1(%r9), %r10d
	cmpl	%r11d, %esi
	jge	.L17
	leal	-1(%r9), %r10d
	movl	-4(%rdi), %ecx
	addl	-8(%r14), %ecx
	cmpl	$2, %r10d
	jbe	.L29
	movl	%r9d, %eax
	movd	%ecx, %xmm4
	pxor	%xmm0, %xmm0
	shrl	$2, %eax
	pshufd	$0, %xmm4, %xmm2
	subl	$1, %eax
	salq	$4, %rax
	leaq	16(%rdi,%rax), %rdx
	movq	%rdi, %rax
	.p2align 4,,10
	.p2align 3
.L19:
	movdqu	(%rax), %xmm3
	movdqa	%xmm2, %xmm1
	addq	$16, %rax
	pcmpgtd	%xmm3, %xmm1
	psubd	%xmm1, %xmm0
	cmpq	%rdx, %rax
	jne	.L19
	movdqa	%xmm0, %xmm1
	movl	%r9d, %edx
	psrldq	$8, %xmm1
	andl	$-4, %edx
	paddd	%xmm1, %xmm0
	movdqa	%xmm0, %xmm1
	psrldq	$4, %xmm1
	paddd	%xmm1, %xmm0
	movd	%xmm0, %eax
	addl	%eax, %r8d
	leal	(%rdx,%rsi), %eax
	cmpl	%edx, %r9d
	je	.L17
.L18:
	movslq	%eax, %rdx
	xorl	%r9d, %r9d
	leaq	(%rbx,%rdx,4), %rdx
	cmpl	(%rdx), %ecx
	setg	%r9b
	addl	%r9d, %r8d
	leal	1(%rax), %r9d
	cmpl	%r11d, %r9d
	jge	.L17
	xorl	%r9d, %r9d
	cmpl	4(%rdx), %ecx
	setg	%r9b
	addl	$2, %eax
	addl	%r9d, %r8d
	cmpl	%r11d, %eax
	jge	.L17
	xorl	%eax, %eax
	cmpl	8(%rdx), %ecx
	setg	%al
	addl	%eax, %r8d
.L17:
	movl	%r10d, %r9d
	addq	$4, %rdi
	cmpl	%r13d, %esi
	jne	.L26
.L16:
	addq	$4, %r14
	cmpl	-68(%rbp), %r15d
	jne	.L27
.L9:
	xorl	%eax, %eax
	movl	%r8d, %edx
	movq	%r12, %rsi
	movl	$1, %edi
	call	__printf_chk@PLT
	movq	-56(%rbp), %rax
	subq	%fs:40, %rax
	jne	.L47
	leaq	-40(%rbp), %rsp
	xorl	%eax, %eax
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_remember_state
	.cfi_def_cfa 7, 8
	ret
.L29:
	.cfi_restore_state
	movl	%esi, %eax
	jmp	.L18
.L45:
	orq	$0, -8(%rsp,%rax)
	jmp	.L4
.L46:
	leal	-2(%r11), %eax
	movl	%eax, -68(%rbp)
	jmp	.L12
.L47:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.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 <math.h>
int main()
{
	int n,i,j,k,sum=0;
	scanf("%d",&n);
	int tri[n];
	for(i=0;i<n;i++)
	{
		scanf("%d",&tri[i]);
	}
	for(i=0;i<n-1;i++)
	{
		for(j=i+1;j<n;j++)
		{
			if(tri[i]>tri[j])
			{
				tri[i]=tri[i]+tri[j];
				tri[j]=tri[i]-tri[j];
				tri[i]=tri[i]-tri[j];
			}
		}
	}
	for(i=0;i<n-2;i++)
	{
		for(j=i+1;j<n-1;j++)
		{
			for(k=j+1;k<n;k++)
			{
				if(tri[i]+tri[j]>tri[k]) sum++;
			}
		}
	}
	printf("%d",sum);
} 
4
5 4 2 1
 7
218 1140 704 233 645 728 389
 3
1 1000 2
 7
218 1140 704 233 645 890 389
 7
218 1140 1051 233 449 890 389
 7
218 1140 1051 16 636 890 389
 7
218 1140 551 40 636 890 487
 7
218 1140 551 40 660 890 487
 7
116 1499 551 40 806 890 487
 7
116 1499 551 40 297 890 487

1 14 0 13 15 10 11 12 7 3
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 <math.h>
int main()
{
	int n,i,j,k,sum=0;
	scanf("%d",&n);
	int tri[n];
	for(i=0;i<n;i++)
	{
		scanf("%d",&tri[i]);
	}
	for(i=0;i<n-1;i++)
	{
		for(j=i+1;j<n;j++)
		{
			if(tri[i]>tri[j])
			{
				tri[i]=tri[i]+tri[j];
				tri[j]=tri[i]-tri[j];
				tri[i]=tri[i]-tri[j];
			}
		}
	}
	for(i=0;i<n-2;i++)
	{
		for(j=i+1;j<n-1;j++)
		{
			for(k=j+1;k<n;k++)
			{
				if(tri[i]+tri[j]>tri[k]) sum++;
			}
		}
	}
	printf("%d",sum);
} ```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d"
	.text
	.globl	main
	.type	main, @function
main:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%r15
	pushq	%r14
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	subq	$56, %rsp
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	.cfi_offset 12, -48
	.cfi_offset 3, -56
	movq	%fs:40, %rax
	movq	%rax, -56(%rbp)
	xorl	%eax, %eax
	movq	%rsp, %rax
	movq	%rax, %rbx
	movl	$0, -76(%rbp)
	leaq	-92(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-92(%rbp), %eax
	movslq	%eax, %rdx
	subq	$1, %rdx
	movq	%rdx, -72(%rbp)
	movslq	%eax, %rdx
	movq	%rdx, %r14
	movl	$0, %r15d
	movslq	%eax, %rdx
	movq	%rdx, %r12
	movl	$0, %r13d
	cltq
	leaq	0(,%rax,4), %rdx
	movl	$16, %eax
	subq	$1, %rax
	addq	%rdx, %rax
	movl	$16, %esi
	movl	$0, %edx
	divq	%rsi
	imulq	$16, %rax, %rax
	movq	%rax, %rcx
	andq	$-4096, %rcx
	movq	%rsp, %rdx
	subq	%rcx, %rdx
.L2:
	cmpq	%rdx, %rsp
	je	.L3
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L2
.L3:
	movq	%rax, %rdx
	andl	$4095, %edx
	subq	%rdx, %rsp
	movq	%rax, %rdx
	andl	$4095, %edx
	testq	%rdx, %rdx
	je	.L4
	andl	$4095, %eax
	subq	$8, %rax
	addq	%rsp, %rax
	orq	$0, (%rax)
.L4:
	movq	%rsp, %rax
	addq	$3, %rax
	shrq	$2, %rax
	salq	$2, %rax
	movq	%rax, -64(%rbp)
	movl	$0, -88(%rbp)
	jmp	.L5
.L6:
	movl	-88(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-64(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -88(%rbp)
.L5:
	movl	-92(%rbp), %eax
	cmpl	%eax, -88(%rbp)
	jl	.L6
	movl	$0, -88(%rbp)
	jmp	.L7
.L11:
	movl	-88(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -84(%rbp)
	jmp	.L8
.L10:
	movq	-64(%rbp), %rax
	movl	-88(%rbp), %edx
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %ecx
	movq	-64(%rbp), %rax
	movl	-84(%rbp), %edx
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %eax
	cmpl	%eax, %ecx
	jle	.L9
	movq	-64(%rbp), %rax
	movl	-88(%rbp), %edx
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %ecx
	movq	-64(%rbp), %rax
	movl	-84(%rbp), %edx
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %eax
	addl	%eax, %ecx
	movq	-64(%rbp), %rax
	movl	-88(%rbp), %edx
	movslq	%edx, %rdx
	movl	%ecx, (%rax,%rdx,4)
	movq	-64(%rbp), %rax
	movl	-88(%rbp), %edx
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %ecx
	movq	-64(%rbp), %rax
	movl	-84(%rbp), %edx
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %eax
	subl	%eax, %ecx
	movq	-64(%rbp), %rax
	movl	-84(%rbp), %edx
	movslq	%edx, %rdx
	movl	%ecx, (%rax,%rdx,4)
	movq	-64(%rbp), %rax
	movl	-88(%rbp), %edx
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %ecx
	movq	-64(%rbp), %rax
	movl	-84(%rbp), %edx
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %eax
	subl	%eax, %ecx
	movq	-64(%rbp), %rax
	movl	-88(%rbp), %edx
	movslq	%edx, %rdx
	movl	%ecx, (%rax,%rdx,4)
.L9:
	addl	$1, -84(%rbp)
.L8:
	movl	-92(%rbp), %eax
	cmpl	%eax, -84(%rbp)
	jl	.L10
	addl	$1, -88(%rbp)
.L7:
	movl	-92(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -88(%rbp)
	jl	.L11
	movl	$0, -88(%rbp)
	jmp	.L12
.L18:
	movl	-88(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -84(%rbp)
	jmp	.L13
.L17:
	movl	-84(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -80(%rbp)
	jmp	.L14
.L16:
	movq	-64(%rbp), %rax
	movl	-88(%rbp), %edx
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %ecx
	movq	-64(%rbp), %rax
	movl	-84(%rbp), %edx
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %eax
	addl	%eax, %ecx
	movq	-64(%rbp), %rax
	movl	-80(%rbp), %edx
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %eax
	cmpl	%eax, %ecx
	jle	.L15
	addl	$1, -76(%rbp)
.L15:
	addl	$1, -80(%rbp)
.L14:
	movl	-92(%rbp), %eax
	cmpl	%eax, -80(%rbp)
	jl	.L16
	addl	$1, -84(%rbp)
.L13:
	movl	-92(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -84(%rbp)
	jl	.L17
	addl	$1, -88(%rbp)
.L12:
	movl	-92(%rbp), %eax
	subl	$2, %eax
	cmpl	%eax, -88(%rbp)
	jl	.L18
	movl	-76(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movq	%rbx, %rsp
	movl	$0, %eax
	movq	-56(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L20
	call	__stack_chk_fail@PLT
.L20:
	leaq	-40(%rbp), %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.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"
	.text
	.globl	main
	.type	main, @function
main:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%r15
	pushq	%r14
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	subq	$56, %rsp
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	.cfi_offset 12, -48
	.cfi_offset 3, -56
	movq	%fs:40, %rax
	movq	%rax, -56(%rbp)
	xorl	%eax, %eax
	movq	%rsp, %rax
	movq	%rax, %rbx
	movl	$0, -76(%rbp)
	leaq	-92(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-92(%rbp), %eax
	movslq	%eax, %rdx
	subq	$1, %rdx
	movq	%rdx, -72(%rbp)
	movslq	%eax, %rdx
	movq	%rdx, %r14
	movl	$0, %r15d
	movslq	%eax, %rdx
	movq	%rdx, %r12
	movl	$0, %r13d
	cltq
	leaq	0(,%rax,4), %rdx
	movl	$16, %eax
	subq	$1, %rax
	addq	%rdx, %rax
	movl	$16, %esi
	movl	$0, %edx
	divq	%rsi
	imulq	$16, %rax, %rax
	movq	%rax, %rcx
	andq	$-4096, %rcx
	movq	%rsp, %rdx
	subq	%rcx, %rdx
.L2:
	cmpq	%rdx, %rsp
	je	.L3
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L2
.L3:
	movq	%rax, %rdx
	andl	$4095, %edx
	subq	%rdx, %rsp
	movq	%rax, %rdx
	andl	$4095, %edx
	testq	%rdx, %rdx
	je	.L4
	andl	$4095, %eax
	subq	$8, %rax
	addq	%rsp, %rax
	orq	$0, (%rax)
.L4:
	movq	%rsp, %rax
	addq	$3, %rax
	shrq	$2, %rax
	salq	$2, %rax
	movq	%rax, -64(%rbp)
	movl	$0, -88(%rbp)
	jmp	.L5
.L6:
	movl	-88(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-64(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -88(%rbp)
.L5:
	movl	-92(%rbp), %eax
	cmpl	%eax, -88(%rbp)
	jl	.L6
	movl	$0, -88(%rbp)
	jmp	.L7
.L11:
	movl	-88(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -84(%rbp)
	jmp	.L8
.L10:
	movq	-64(%rbp), %rax
	movl	-88(%rbp), %edx
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %ecx
	movq	-64(%rbp), %rax
	movl	-84(%rbp), %edx
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %eax
	cmpl	%eax, %ecx
	jle	.L9
	movq	-64(%rbp), %rax
	movl	-88(%rbp), %edx
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %ecx
	movq	-64(%rbp), %rax
	movl	-84(%rbp), %edx
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %eax
	addl	%eax, %ecx
	movq	-64(%rbp), %rax
	movl	-88(%rbp), %edx
	movslq	%edx, %rdx
	movl	%ecx, (%rax,%rdx,4)
	movq	-64(%rbp), %rax
	movl	-88(%rbp), %edx
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %ecx
	movq	-64(%rbp), %rax
	movl	-84(%rbp), %edx
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %eax
	subl	%eax, %ecx
	movq	-64(%rbp), %rax
	movl	-84(%rbp), %edx
	movslq	%edx, %rdx
	movl	%ecx, (%rax,%rdx,4)
	movq	-64(%rbp), %rax
	movl	-88(%rbp), %edx
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %ecx
	movq	-64(%rbp), %rax
	movl	-84(%rbp), %edx
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %eax
	subl	%eax, %ecx
	movq	-64(%rbp), %rax
	movl	-88(%rbp), %edx
	movslq	%edx, %rdx
	movl	%ecx, (%rax,%rdx,4)
.L9:
	addl	$1, -84(%rbp)
.L8:
	movl	-92(%rbp), %eax
	cmpl	%eax, -84(%rbp)
	jl	.L10
	addl	$1, -88(%rbp)
.L7:
	movl	-92(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -88(%rbp)
	jl	.L11
	movl	$0, -88(%rbp)
	jmp	.L12
.L18:
	movl	-88(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -84(%rbp)
	jmp	.L13
.L17:
	movl	-84(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -80(%rbp)
	jmp	.L14
.L16:
	movq	-64(%rbp), %rax
	movl	-88(%rbp), %edx
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %ecx
	movq	-64(%rbp), %rax
	movl	-84(%rbp), %edx
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %eax
	addl	%eax, %ecx
	movq	-64(%rbp), %rax
	movl	-80(%rbp), %edx
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %eax
	cmpl	%eax, %ecx
	jle	.L15
	addl	$1, -76(%rbp)
.L15:
	addl	$1, -80(%rbp)
.L14:
	movl	-92(%rbp), %eax
	cmpl	%eax, -80(%rbp)
	jl	.L16
	addl	$1, -84(%rbp)
.L13:
	movl	-92(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -84(%rbp)
	jl	.L17
	addl	$1, -88(%rbp)
.L12:
	movl	-92(%rbp), %eax
	subl	$2, %eax
	cmpl	%eax, -88(%rbp)
	jl	.L18
	movl	-76(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movq	%rbx, %rsp
	movl	$0, %eax
	movq	-56(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L20
	call	__stack_chk_fail@PLT
.L20:
	leaq	-40(%rbp), %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.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:
