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 long long int int64;

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

void run(void){
  int n;
  scanf("%d",&n);
  int *a=(int *)calloc(3*n,sizeof(int));
  int i;
  for(i=0;i<3*n;i++) scanf("%d",a+i);
  qsort(a,n,sizeof(int),cmp);
  qsort(a+n,n,sizeof(int),cmp);
  qsort(a+2*n,n,sizeof(int),cmp);
  int64 ans=0;
  int j=0;
  int k=0;
  for(i=0;i<n;i++){
    while(j<n && a[j]<a[n+i]) j++;
    while(k<n && a[n+i]>=a[k+2*n]) k++;
    ans+=(int64)j*(n-k);
  }
  printf("%lld\n",ans);
}

int main(void){
  run();
  return 0;
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	cmp
	.type	cmp, @function
cmp:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -8(%rbp)
	movq	%rsi, -16(%rbp)
	movq	-8(%rbp), %rax
	movl	(%rax), %edx
	movq	-16(%rbp), %rax
	movl	(%rax), %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	cmp, .-cmp
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%lld\n"
	.text
	.globl	run
	.type	run, @function
run:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$48, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-40(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-40(%rbp), %edx
	movl	%edx, %eax
	addl	%eax, %eax
	addl	%edx, %eax
	cltq
	movl	$4, %esi
	movq	%rax, %rdi
	call	calloc@PLT
	movq	%rax, -16(%rbp)
	movl	$0, -36(%rbp)
	jmp	.L4
.L5:
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -36(%rbp)
.L4:
	movl	-40(%rbp), %edx
	movl	%edx, %eax
	addl	%eax, %eax
	addl	%edx, %eax
	cmpl	%eax, -36(%rbp)
	jl	.L5
	movl	-40(%rbp), %eax
	movslq	%eax, %rsi
	movq	-16(%rbp), %rax
	leaq	cmp(%rip), %rdx
	movq	%rdx, %rcx
	movl	$4, %edx
	movq	%rax, %rdi
	call	qsort@PLT
	movl	-40(%rbp), %eax
	cltq
	movl	-40(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	movq	-16(%rbp), %rdx
	leaq	(%rcx,%rdx), %rdi
	leaq	cmp(%rip), %rdx
	movq	%rdx, %rcx
	movl	$4, %edx
	movq	%rax, %rsi
	call	qsort@PLT
	movl	-40(%rbp), %eax
	cltq
	movl	-40(%rbp), %edx
	addl	%edx, %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	movq	-16(%rbp), %rdx
	leaq	(%rcx,%rdx), %rdi
	leaq	cmp(%rip), %rdx
	movq	%rdx, %rcx
	movl	$4, %edx
	movq	%rax, %rsi
	call	qsort@PLT
	movq	$0, -24(%rbp)
	movl	$0, -32(%rbp)
	movl	$0, -28(%rbp)
	movl	$0, -36(%rbp)
	jmp	.L6
.L9:
	addl	$1, -32(%rbp)
.L7:
	movl	-40(%rbp), %eax
	cmpl	%eax, -32(%rbp)
	jge	.L10
	movl	-32(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movl	-40(%rbp), %ecx
	movl	-36(%rbp), %eax
	addl	%ecx, %eax
	cltq
	leaq	0(,%rax,4), %rcx
	movq	-16(%rbp), %rax
	addq	%rcx, %rax
	movl	(%rax), %eax
	cmpl	%eax, %edx
	jl	.L9
	jmp	.L10
.L12:
	addl	$1, -28(%rbp)
.L10:
	movl	-40(%rbp), %eax
	cmpl	%eax, -28(%rbp)
	jge	.L11
	movl	-40(%rbp), %edx
	movl	-36(%rbp), %eax
	addl	%edx, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movl	-40(%rbp), %eax
	leal	(%rax,%rax), %ecx
	movl	-28(%rbp), %eax
	addl	%ecx, %eax
	cltq
	leaq	0(,%rax,4), %rcx
	movq	-16(%rbp), %rax
	addq	%rcx, %rax
	movl	(%rax), %eax
	cmpl	%eax, %edx
	jge	.L12
.L11:
	movl	-32(%rbp), %eax
	movslq	%eax, %rdx
	movl	-40(%rbp), %eax
	subl	-28(%rbp), %eax
	cltq
	imulq	%rdx, %rax
	addq	%rax, -24(%rbp)
	addl	$1, -36(%rbp)
.L6:
	movl	-40(%rbp), %eax
	cmpl	%eax, -36(%rbp)
	jl	.L7
	movq	-24(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	nop
	movq	-8(%rbp), %rax
	subq	%fs:40, %rax
	je	.L14
	call	__stack_chk_fail@PLT
.L14:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	run, .-run
	.globl	main
	.type	main, @function
main:
.LFB8:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	call	run
	movl	$0, %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.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	cmp
	.type	cmp, @function
cmp:
.LFB39:
	.cfi_startproc
	endbr64
	movl	(%rdi), %eax
	subl	(%rsi), %eax
	ret
	.cfi_endproc
.LFE39:
	.size	cmp, .-cmp
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	"%lld\n"
	.text
	.p2align 4
	.globl	run
	.type	run, @function
run:
.LFB40:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	leaq	.LC0(%rip), %r14
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	movq	%r14, %rdi
	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	$16, %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), %ebp
	movl	$4, %esi
	leal	0(%rbp,%rbp,2), %r12d
	movslq	%r12d, %rdi
	call	calloc@PLT
	movq	%rax, %rbx
	testl	%r12d, %r12d
	jle	.L4
	movq	%rax, %r13
	xorl	%r12d, %r12d
	.p2align 4,,10
	.p2align 3
.L5:
	movq	%r13, %rsi
	movq	%r14, %rdi
	xorl	%eax, %eax
	addl	$1, %r12d
	call	__isoc99_scanf@PLT
	movl	4(%rsp), %ebp
	addq	$4, %r13
	leal	0(%rbp,%rbp,2), %eax
	cmpl	%r12d, %eax
	jg	.L5
.L4:
	leaq	cmp(%rip), %r12
	movslq	%ebp, %rsi
	movl	$4, %edx
	movq	%rbx, %rdi
	movq	%r12, %rcx
	call	qsort@PLT
	movslq	4(%rsp), %rsi
	movq	%r12, %rcx
	movl	$4, %edx
	leaq	(%rbx,%rsi,4), %rdi
	call	qsort@PLT
	movslq	4(%rsp), %rsi
	movl	$4, %edx
	movq	%r12, %rcx
	movq	%rsi, %rax
	addl	%eax, %eax
	cltq
	leaq	(%rbx,%rax,4), %rdi
	call	qsort@PLT
	movl	4(%rsp), %edx
	testl	%edx, %edx
	jle	.L21
	leal	(%rdx,%rdx), %r10d
	movl	$1, %ebp
	movl	%edx, %r8d
	xorl	%eax, %eax
	leal	-1(%r10), %r12d
	xorl	%r9d, %r9d
	xorl	%r11d, %r11d
	movslq	%r10d, %r13
	subl	%edx, %ebp
	.p2align 4,,10
	.p2align 3
.L7:
	movl	%r9d, %ecx
	cmpl	%r9d, %edx
	jle	.L12
	movslq	%r8d, %rcx
	movl	(%rbx,%rcx,4), %edi
	movslq	%r9d, %rcx
	leaq	(%rbx,%rcx,4), %rsi
	movl	%r9d, %ecx
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L11:
	addl	$1, %ecx
	addq	$4, %rsi
	cmpl	%edx, %ecx
	je	.L12
.L8:
	cmpl	%edi, (%rsi)
	jl	.L11
.L12:
	cmpl	%eax, %edx
	jle	.L9
	movslq	%r8d, %rsi
	movl	(%rbx,%rsi,4), %edi
	movslq	%eax, %rsi
	addq	%r13, %rsi
	leaq	(%rbx,%rsi,4), %rsi
	jmp	.L10
	.p2align 4,,10
	.p2align 3
.L13:
	addl	$1, %eax
	addq	$4, %rsi
	cmpl	%edx, %eax
	je	.L9
.L10:
	cmpl	(%rsi), %edi
	jge	.L13
.L9:
	movl	%edx, %esi
	movslq	%ecx, %r14
	leal	0(%rbp,%r8), %edi
	subl	%eax, %esi
	movslq	%esi, %rsi
	imulq	%r14, %rsi
	addq	%rsi, %r11
	cmpl	%r12d, %r8d
	je	.L6
	addl	$1, %r8d
	cmpl	%r9d, %edx
	jle	.L29
	movl	%ecx, %r9d
	jmp	.L7
	.p2align 4,,10
	.p2align 3
.L29:
	movslq	%r10d, %r10
.L17:
	cmpl	%eax, %edx
	jle	.L15
	leal	(%rdi,%rdx), %ecx
	movslq	%ecx, %rcx
	movl	(%rbx,%rcx,4), %esi
	movslq	%eax, %rcx
	addq	%r10, %rcx
	leaq	(%rbx,%rcx,4), %rcx
	jmp	.L16
	.p2align 4,,10
	.p2align 3
.L30:
	addl	$1, %eax
	addq	$4, %rcx
	cmpl	%edx, %eax
	je	.L15
.L16:
	cmpl	%esi, (%rcx)
	jle	.L30
.L15:
	movl	%edx, %ecx
	addl	$1, %edi
	subl	%eax, %ecx
	movslq	%ecx, %rcx
	imulq	%r14, %rcx
	addq	%rcx, %r11
	cmpl	%edx, %edi
	jl	.L17
.L6:
	xorl	%eax, %eax
	movq	%r11, %rdx
	movl	$1, %edi
	leaq	.LC1(%rip), %rsi
	call	__printf_chk@PLT
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L31
	addq	$16, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 48
	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
.L21:
	.cfi_restore_state
	xorl	%r11d, %r11d
	jmp	.L6
.L31:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE40:
	.size	run, .-run
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB41:
	.cfi_startproc
	endbr64
	subq	$8, %rsp
	.cfi_def_cfa_offset 16
	call	run
	xorl	%eax, %eax
	addq	$8, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE41:
	.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
	.p2align 4
	.globl	cmp
	.type	cmp, @function
cmp:
.LFB39:
	.cfi_startproc
	endbr64
	movl	(%rdi), %eax
	subl	(%rsi), %eax
	ret
	.cfi_endproc
.LFE39:
	.size	cmp, .-cmp
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	"%lld\n"
	.text
	.p2align 4
	.globl	run
	.type	run, @function
run:
.LFB40:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	leaq	.LC0(%rip), %r14
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	movq	%r14, %rdi
	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	$16, %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), %ebp
	movl	$4, %esi
	leal	0(%rbp,%rbp,2), %r12d
	movslq	%r12d, %rdi
	call	calloc@PLT
	movq	%rax, %rbx
	testl	%r12d, %r12d
	jle	.L4
	movq	%rax, %r13
	xorl	%r12d, %r12d
	.p2align 4,,10
	.p2align 3
.L5:
	movq	%r13, %rsi
	movq	%r14, %rdi
	xorl	%eax, %eax
	addl	$1, %r12d
	call	__isoc99_scanf@PLT
	movl	4(%rsp), %ebp
	addq	$4, %r13
	leal	0(%rbp,%rbp,2), %eax
	cmpl	%r12d, %eax
	jg	.L5
.L4:
	leaq	cmp(%rip), %r12
	movslq	%ebp, %rsi
	movl	$4, %edx
	movq	%rbx, %rdi
	movq	%r12, %rcx
	call	qsort@PLT
	movslq	4(%rsp), %rsi
	movq	%r12, %rcx
	movl	$4, %edx
	leaq	(%rbx,%rsi,4), %rdi
	call	qsort@PLT
	movslq	4(%rsp), %rsi
	movl	$4, %edx
	movq	%r12, %rcx
	movq	%rsi, %rax
	addl	%eax, %eax
	cltq
	leaq	(%rbx,%rax,4), %rdi
	call	qsort@PLT
	movl	4(%rsp), %edx
	testl	%edx, %edx
	jle	.L21
	leal	(%rdx,%rdx), %r10d
	movl	$1, %ebp
	movl	%edx, %r8d
	xorl	%eax, %eax
	leal	-1(%r10), %r12d
	xorl	%r9d, %r9d
	xorl	%r11d, %r11d
	movslq	%r10d, %r13
	subl	%edx, %ebp
	.p2align 4,,10
	.p2align 3
.L7:
	movl	%r9d, %ecx
	cmpl	%r9d, %edx
	jle	.L12
	movslq	%r8d, %rcx
	movl	(%rbx,%rcx,4), %edi
	movslq	%r9d, %rcx
	leaq	(%rbx,%rcx,4), %rsi
	movl	%r9d, %ecx
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L11:
	addl	$1, %ecx
	addq	$4, %rsi
	cmpl	%edx, %ecx
	je	.L12
.L8:
	cmpl	%edi, (%rsi)
	jl	.L11
.L12:
	cmpl	%eax, %edx
	jle	.L9
	movslq	%r8d, %rsi
	movl	(%rbx,%rsi,4), %edi
	movslq	%eax, %rsi
	addq	%r13, %rsi
	leaq	(%rbx,%rsi,4), %rsi
	jmp	.L10
	.p2align 4,,10
	.p2align 3
.L13:
	addl	$1, %eax
	addq	$4, %rsi
	cmpl	%edx, %eax
	je	.L9
.L10:
	cmpl	(%rsi), %edi
	jge	.L13
.L9:
	movl	%edx, %esi
	movslq	%ecx, %r14
	leal	0(%rbp,%r8), %edi
	subl	%eax, %esi
	movslq	%esi, %rsi
	imulq	%r14, %rsi
	addq	%rsi, %r11
	cmpl	%r12d, %r8d
	je	.L6
	addl	$1, %r8d
	cmpl	%r9d, %edx
	jle	.L29
	movl	%ecx, %r9d
	jmp	.L7
	.p2align 4,,10
	.p2align 3
.L29:
	movslq	%r10d, %r10
.L17:
	cmpl	%eax, %edx
	jle	.L15
	leal	(%rdi,%rdx), %ecx
	movslq	%ecx, %rcx
	movl	(%rbx,%rcx,4), %esi
	movslq	%eax, %rcx
	addq	%r10, %rcx
	leaq	(%rbx,%rcx,4), %rcx
	jmp	.L16
	.p2align 4,,10
	.p2align 3
.L30:
	addl	$1, %eax
	addq	$4, %rcx
	cmpl	%edx, %eax
	je	.L15
.L16:
	cmpl	%esi, (%rcx)
	jle	.L30
.L15:
	movl	%edx, %ecx
	addl	$1, %edi
	subl	%eax, %ecx
	movslq	%ecx, %rcx
	imulq	%r14, %rcx
	addq	%rcx, %r11
	cmpl	%edx, %edi
	jl	.L17
.L6:
	xorl	%eax, %eax
	movq	%r11, %rdx
	movl	$1, %edi
	leaq	.LC1(%rip), %rsi
	call	__printf_chk@PLT
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L31
	addq	$16, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 48
	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
.L21:
	.cfi_restore_state
	xorl	%r11d, %r11d
	jmp	.L6
.L31:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE40:
	.size	run, .-run
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB41:
	.cfi_startproc
	endbr64
	subq	$8, %rsp
	.cfi_def_cfa_offset 16
	call	run
	xorl	%eax, %eax
	addq	$8, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE41:
	.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 long long int int64;

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

void run(void){
  int n;
  scanf("%d",&n);
  int *a=(int *)calloc(3*n,sizeof(int));
  int i;
  for(i=0;i<3*n;i++) scanf("%d",a+i);
  qsort(a,n,sizeof(int),cmp);
  qsort(a+n,n,sizeof(int),cmp);
  qsort(a+2*n,n,sizeof(int),cmp);
  int64 ans=0;
  int j=0;
  int k=0;
  for(i=0;i<n;i++){
    while(j<n && a[j]<a[n+i]) j++;
    while(k<n && a[n+i]>=a[k+2*n]) k++;
    ans+=(int64)j*(n-k);
  }
  printf("%lld\n",ans);
}

int main(void){
  run();
  return 0;
}

3
1 0 1
2 2 2
3 3 3
 2
1 5
2 4
2 6
 6
3 14 159 2 6 53
58 9 7 323 84 6
2643 383 2 79 50 288
 3
1 0 2
2 2 2
3 3 3
 2
2 5
2 4
2 6
 6
3 14 159 2 6 53
58 9 7 323 84 6
2643 383 2 79 50 430
 3
1 0 4
2 2 2
3 1 3
 3
0 0 4
2 2 2
3 1 1
 6
5 14 159 0 6 53
58 9 7 323 166 6
2643 383 3 79 50 430
 3
0 0 0
2 2 2
3 1 1

27
 2
 87
 18
 1
 93
 12
 6
 96
 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>

typedef long long int int64;

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

void run(void){
  int n;
  scanf("%d",&n);
  int *a=(int *)calloc(3*n,sizeof(int));
  int i;
  for(i=0;i<3*n;i++) scanf("%d",a+i);
  qsort(a,n,sizeof(int),cmp);
  qsort(a+n,n,sizeof(int),cmp);
  qsort(a+2*n,n,sizeof(int),cmp);
  int64 ans=0;
  int j=0;
  int k=0;
  for(i=0;i<n;i++){
    while(j<n && a[j]<a[n+i]) j++;
    while(k<n && a[n+i]>=a[k+2*n]) k++;
    ans+=(int64)j*(n-k);
  }
  printf("%lld\n",ans);
}

int main(void){
  run();
  return 0;
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	cmp
	.type	cmp, @function
cmp:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -8(%rbp)
	movq	%rsi, -16(%rbp)
	movq	-8(%rbp), %rax
	movl	(%rax), %edx
	movq	-16(%rbp), %rax
	movl	(%rax), %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	cmp, .-cmp
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%lld\n"
	.text
	.globl	run
	.type	run, @function
run:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$48, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-40(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-40(%rbp), %edx
	movl	%edx, %eax
	addl	%eax, %eax
	addl	%edx, %eax
	cltq
	movl	$4, %esi
	movq	%rax, %rdi
	call	calloc@PLT
	movq	%rax, -16(%rbp)
	movl	$0, -36(%rbp)
	jmp	.L4
.L5:
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -36(%rbp)
.L4:
	movl	-40(%rbp), %edx
	movl	%edx, %eax
	addl	%eax, %eax
	addl	%edx, %eax
	cmpl	%eax, -36(%rbp)
	jl	.L5
	movl	-40(%rbp), %eax
	movslq	%eax, %rsi
	movq	-16(%rbp), %rax
	leaq	cmp(%rip), %rdx
	movq	%rdx, %rcx
	movl	$4, %edx
	movq	%rax, %rdi
	call	qsort@PLT
	movl	-40(%rbp), %eax
	cltq
	movl	-40(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	movq	-16(%rbp), %rdx
	leaq	(%rcx,%rdx), %rdi
	leaq	cmp(%rip), %rdx
	movq	%rdx, %rcx
	movl	$4, %edx
	movq	%rax, %rsi
	call	qsort@PLT
	movl	-40(%rbp), %eax
	cltq
	movl	-40(%rbp), %edx
	addl	%edx, %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	movq	-16(%rbp), %rdx
	leaq	(%rcx,%rdx), %rdi
	leaq	cmp(%rip), %rdx
	movq	%rdx, %rcx
	movl	$4, %edx
	movq	%rax, %rsi
	call	qsort@PLT
	movq	$0, -24(%rbp)
	movl	$0, -32(%rbp)
	movl	$0, -28(%rbp)
	movl	$0, -36(%rbp)
	jmp	.L6
.L9:
	addl	$1, -32(%rbp)
.L7:
	movl	-40(%rbp), %eax
	cmpl	%eax, -32(%rbp)
	jge	.L10
	movl	-32(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movl	-40(%rbp), %ecx
	movl	-36(%rbp), %eax
	addl	%ecx, %eax
	cltq
	leaq	0(,%rax,4), %rcx
	movq	-16(%rbp), %rax
	addq	%rcx, %rax
	movl	(%rax), %eax
	cmpl	%eax, %edx
	jl	.L9
	jmp	.L10
.L12:
	addl	$1, -28(%rbp)
.L10:
	movl	-40(%rbp), %eax
	cmpl	%eax, -28(%rbp)
	jge	.L11
	movl	-40(%rbp), %edx
	movl	-36(%rbp), %eax
	addl	%edx, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movl	-40(%rbp), %eax
	leal	(%rax,%rax), %ecx
	movl	-28(%rbp), %eax
	addl	%ecx, %eax
	cltq
	leaq	0(,%rax,4), %rcx
	movq	-16(%rbp), %rax
	addq	%rcx, %rax
	movl	(%rax), %eax
	cmpl	%eax, %edx
	jge	.L12
.L11:
	movl	-32(%rbp), %eax
	movslq	%eax, %rdx
	movl	-40(%rbp), %eax
	subl	-28(%rbp), %eax
	cltq
	imulq	%rdx, %rax
	addq	%rax, -24(%rbp)
	addl	$1, -36(%rbp)
.L6:
	movl	-40(%rbp), %eax
	cmpl	%eax, -36(%rbp)
	jl	.L7
	movq	-24(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	nop
	movq	-8(%rbp), %rax
	subq	%fs:40, %rax
	je	.L14
	call	__stack_chk_fail@PLT
.L14:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	run, .-run
	.globl	main
	.type	main, @function
main:
.LFB8:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	call	run
	movl	$0, %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.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.
val
	.file	"temp.c"
	.text
	.globl	cmp
	.type	cmp, @function
cmp:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -8(%rbp)
	movq	%rsi, -16(%rbp)
	movq	-8(%rbp), %rax
	movl	(%rax), %edx
	movq	-16(%rbp), %rax
	movl	(%rax), %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	cmp, .-cmp
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%lld\n"
	.text
	.globl	run
	.type	run, @function
run:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$48, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-40(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-40(%rbp), %edx
	movl	%edx, %eax
	addl	%eax, %eax
	addl	%edx, %eax
	cltq
	movl	$4, %esi
	movq	%rax, %rdi
	call	calloc@PLT
	movq	%rax, -16(%rbp)
	movl	$0, -36(%rbp)
	jmp	.L4
.L5:
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -36(%rbp)
.L4:
	movl	-40(%rbp), %edx
	movl	%edx, %eax
	addl	%eax, %eax
	addl	%edx, %eax
	cmpl	%eax, -36(%rbp)
	jl	.L5
	movl	-40(%rbp), %eax
	movslq	%eax, %rsi
	movq	-16(%rbp), %rax
	leaq	cmp(%rip), %rdx
	movq	%rdx, %rcx
	movl	$4, %edx
	movq	%rax, %rdi
	call	qsort@PLT
	movl	-40(%rbp), %eax
	cltq
	movl	-40(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	movq	-16(%rbp), %rdx
	leaq	(%rcx,%rdx), %rdi
	leaq	cmp(%rip), %rdx
	movq	%rdx, %rcx
	movl	$4, %edx
	movq	%rax, %rsi
	call	qsort@PLT
	movl	-40(%rbp), %eax
	cltq
	movl	-40(%rbp), %edx
	addl	%edx, %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	movq	-16(%rbp), %rdx
	leaq	(%rcx,%rdx), %rdi
	leaq	cmp(%rip), %rdx
	movq	%rdx, %rcx
	movl	$4, %edx
	movq	%rax, %rsi
	call	qsort@PLT
	movq	$0, -24(%rbp)
	movl	$0, -32(%rbp)
	movl	$0, -28(%rbp)
	movl	$0, -36(%rbp)
	jmp	.L6
.L9:
	addl	$1, -32(%rbp)
.L7:
	movl	-40(%rbp), %eax
	cmpl	%eax, -32(%rbp)
	jge	.L10
	movl	-32(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movl	-40(%rbp), %ecx
	movl	-36(%rbp), %eax
	addl	%ecx, %eax
	cltq
	leaq	0(,%rax,4), %rcx
	movq	-16(%rbp), %rax
	addq	%rcx, %rax
	movl	(%rax), %eax
	cmpl	%eax, %edx
	jl	.L9
	jmp	.L10
.L12:
	addl	$1, -28(%rbp)
.L10:
	movl	-40(%rbp), %eax
	cmpl	%eax, -28(%rbp)
	jge	.L11
	movl	-40(%rbp), %edx
	movl	-36(%rbp), %eax
	addl	%edx, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movl	-40(%rbp), %eax
	leal	(%rax,%rax), %ecx
	movl	-28(%rbp), %eax
	addl	%ecx, %eax
	cltq
	leaq	0(,%rax,4), %rcx
	movq	-16(%rbp), %rax
	addq	%rcx, %rax
	movl	(%rax), %eax
	cmpl	%eax, %edx
	jge	.L12
.L11:
	movl	-32(%rbp), %eax
	movslq	%eax, %rdx
	movl	-40(%rbp), %eax
	subl	-28(%rbp), %eax
	cltq
	imulq	%rdx, %rax
	addq	%rax, -24(%rbp)
	addl	$1, -36(%rbp)
.L6:
	movl	-40(%rbp), %eax
	cmpl	%eax, -36(%rbp)
	jl	.L7
	movq	-24(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	nop
	movq	-8(%rbp), %rax
	subq	%fs:40, %rax
	je	.L14
	call	__stack_chk_fail@PLT
.L14:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	run, .-run
	.globl	main
	.type	main, @function
main:
.LFB8:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	call	run
	movl	$0, %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.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:
