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

```c
// Ver19.03
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF (1 << 29) * 2
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

typedef struct
{
  ll b;
  ll c;
} hoge;

int downll_hoge(const void *aa, const void *bb) { return ((hoge *)aa)->c < ((hoge *)bb)->c ? 1 : ((hoge *)aa)->c > ((hoge *)bb)->c ? -1 : 0; }

ll a[100005];
int main()
{
  ll n, m, ans = 0;
  scanf("%lld%lld", &n, &m);
  hoge fuga[m];
  for (ll i = 0; i < n; i++)
  {
    ll aaa;
    scanf("%lld", &aaa);
    a[i] = aaa;
    ans += aaa;
  }
  sortup(a, n);
  for (ll i = 0; i < m; i++)
  {
    ll b, c;
    scanf("%lld%lld", &b, &c);
    fuga[i].b = b, fuga[i].c = c;
  }
  qsort(fuga, m, sizeof(hoge), downll_hoge);
  ll j = 0;
  for (ll i = 0; i < n; i++)
  {
    if (!fuga[j].b)
    {
      i--;
      j++;
      continue;
    }
    if (j >= m)
      break;
    if (a[i] < fuga[j].c)
    {
      ans += (fuga[j].c - a[i]);
      fuga[j].b--;
      // printf("yayay: %lld\n", fuga[j].c - a[i]);
      // printf("yayay: %lld\n", fuga[j].c);
      // printf("yayay: %lld\n", a[i]);
      // printf("j: %lld\n", j);
      // puts("");
    }
    else
      break;
  }
  printf("%lld\n", ans);
  return 0;
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	upll
	.type	upll, @function
upll:
.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
	movq	(%rax), %rdx
	movq	-16(%rbp), %rax
	movq	(%rax), %rax
	cmpq	%rax, %rdx
	jl	.L2
	movq	-8(%rbp), %rax
	movq	(%rax), %rdx
	movq	-16(%rbp), %rax
	movq	(%rax), %rax
	cmpq	%rax, %rdx
	setg	%al
	movzbl	%al, %eax
	jmp	.L4
.L2:
	movl	$-1, %eax
.L4:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	upll, .-upll
	.globl	downll
	.type	downll, @function
downll:
.LFB7:
	.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
	movq	(%rax), %rdx
	movq	-16(%rbp), %rax
	movq	(%rax), %rax
	cmpq	%rax, %rdx
	jl	.L6
	movq	-8(%rbp), %rax
	movq	(%rax), %rdx
	movq	-16(%rbp), %rax
	movq	(%rax), %rax
	cmpq	%rax, %rdx
	jle	.L7
	movl	$-1, %eax
	jmp	.L10
.L7:
	movl	$0, %eax
	jmp	.L10
.L6:
	movl	$1, %eax
.L10:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	downll, .-downll
	.globl	sortup
	.type	sortup, @function
sortup:
.LFB8:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$16, %rsp
	movq	%rdi, -8(%rbp)
	movl	%esi, -12(%rbp)
	movl	-12(%rbp), %eax
	movslq	%eax, %rsi
	movq	-8(%rbp), %rax
	leaq	upll(%rip), %rdx
	movq	%rdx, %rcx
	movl	$8, %edx
	movq	%rax, %rdi
	call	qsort@PLT
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.size	sortup, .-sortup
	.globl	sortdown
	.type	sortdown, @function
sortdown:
.LFB9:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$16, %rsp
	movq	%rdi, -8(%rbp)
	movl	%esi, -12(%rbp)
	movl	-12(%rbp), %eax
	movslq	%eax, %rsi
	movq	-8(%rbp), %rax
	leaq	downll(%rip), %rdx
	movq	%rdx, %rcx
	movl	$8, %edx
	movq	%rax, %rdi
	call	qsort@PLT
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE9:
	.size	sortdown, .-sortdown
	.globl	downll_hoge
	.type	downll_hoge, @function
downll_hoge:
.LFB10:
	.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
	movq	8(%rax), %rdx
	movq	-16(%rbp), %rax
	movq	8(%rax), %rax
	cmpq	%rax, %rdx
	jl	.L14
	movq	-8(%rbp), %rax
	movq	8(%rax), %rdx
	movq	-16(%rbp), %rax
	movq	8(%rax), %rax
	cmpq	%rax, %rdx
	jle	.L15
	movl	$-1, %eax
	jmp	.L18
.L15:
	movl	$0, %eax
	jmp	.L18
.L14:
	movl	$1, %eax
.L18:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE10:
	.size	downll_hoge, .-downll_hoge
	.globl	a
	.bss
	.align 32
	.type	a, @object
	.size	a, 800040
a:
	.zero	800040
	.section	.rodata
.LC0:
	.string	"%lld%lld"
.LC1:
	.string	"%lld"
.LC2:
	.string	"%lld\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB11:
	.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	$104, %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
	movq	$0, -112(%rbp)
	leaq	-136(%rbp), %rdx
	leaq	-144(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	-136(%rbp), %rax
	leaq	-1(%rax), %rdx
	movq	%rdx, -72(%rbp)
	movq	%rax, %rdx
	movq	%rdx, %r14
	movl	$0, %r15d
	movq	%rax, %rdx
	movq	%rdx, %r12
	movl	$0, %r13d
	salq	$4, %rax
	movq	%rax, %rdx
	movl	$16, %eax
	subq	$1, %rax
	addq	%rdx, %rax
	movl	$16, %edi
	movl	$0, %edx
	divq	%rdi
	imulq	$16, %rax, %rax
	movq	%rax, %rcx
	andq	$-4096, %rcx
	movq	%rsp, %rdx
	subq	%rcx, %rdx
.L20:
	cmpq	%rdx, %rsp
	je	.L21
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L20
.L21:
	movq	%rax, %rdx
	andl	$4095, %edx
	subq	%rdx, %rsp
	movq	%rax, %rdx
	andl	$4095, %edx
	testq	%rdx, %rdx
	je	.L22
	andl	$4095, %eax
	subq	$8, %rax
	addq	%rsp, %rax
	orq	$0, (%rax)
.L22:
	movq	%rsp, %rax
	addq	$7, %rax
	shrq	$3, %rax
	salq	$3, %rax
	movq	%rax, -64(%rbp)
	movq	$0, -104(%rbp)
	jmp	.L23
.L24:
	leaq	-120(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	-120(%rbp), %rax
	movq	-104(%rbp), %rdx
	leaq	0(,%rdx,8), %rcx
	leaq	a(%rip), %rdx
	movq	%rax, (%rcx,%rdx)
	movq	-120(%rbp), %rax
	addq	%rax, -112(%rbp)
	addq	$1, -104(%rbp)
.L23:
	movq	-144(%rbp), %rax
	cmpq	%rax, -104(%rbp)
	jl	.L24
	movq	-144(%rbp), %rax
	movl	%eax, %esi
	leaq	a(%rip), %rax
	movq	%rax, %rdi
	call	sortup
	movq	$0, -96(%rbp)
	jmp	.L25
.L26:
	leaq	-120(%rbp), %rdx
	leaq	-128(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	-128(%rbp), %rax
	movq	-64(%rbp), %rcx
	movq	-96(%rbp), %rdx
	salq	$4, %rdx
	addq	%rcx, %rdx
	movq	%rax, (%rdx)
	movq	-120(%rbp), %rax
	movq	-64(%rbp), %rcx
	movq	-96(%rbp), %rdx
	salq	$4, %rdx
	addq	%rcx, %rdx
	addq	$8, %rdx
	movq	%rax, (%rdx)
	addq	$1, -96(%rbp)
.L25:
	movq	-136(%rbp), %rax
	cmpq	%rax, -96(%rbp)
	jl	.L26
	movq	-136(%rbp), %rax
	movq	%rax, %rsi
	movq	-64(%rbp), %rax
	leaq	downll_hoge(%rip), %rdx
	movq	%rdx, %rcx
	movl	$16, %edx
	movq	%rax, %rdi
	call	qsort@PLT
	movq	$0, -88(%rbp)
	movq	$0, -80(%rbp)
	jmp	.L27
.L33:
	movq	-64(%rbp), %rdx
	movq	-88(%rbp), %rax
	salq	$4, %rax
	addq	%rdx, %rax
	movq	(%rax), %rax
	testq	%rax, %rax
	jne	.L28
	subq	$1, -80(%rbp)
	addq	$1, -88(%rbp)
	jmp	.L29
.L28:
	movq	-136(%rbp), %rax
	cmpq	%rax, -88(%rbp)
	jge	.L36
	movq	-80(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	leaq	a(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movq	-64(%rbp), %rcx
	movq	-88(%rbp), %rax
	salq	$4, %rax
	addq	%rcx, %rax
	addq	$8, %rax
	movq	(%rax), %rax
	cmpq	%rax, %rdx
	jge	.L37
	movq	-64(%rbp), %rdx
	movq	-88(%rbp), %rax
	salq	$4, %rax
	addq	%rdx, %rax
	addq	$8, %rax
	movq	(%rax), %rax
	movq	-80(%rbp), %rdx
	leaq	0(,%rdx,8), %rcx
	leaq	a(%rip), %rdx
	movq	(%rcx,%rdx), %rdx
	subq	%rdx, %rax
	addq	%rax, -112(%rbp)
	movq	-64(%rbp), %rdx
	movq	-88(%rbp), %rax
	salq	$4, %rax
	addq	%rdx, %rax
	movq	(%rax), %rax
	leaq	-1(%rax), %rdx
	movq	-64(%rbp), %rcx
	movq	-88(%rbp), %rax
	salq	$4, %rax
	addq	%rcx, %rax
	movq	%rdx, (%rax)
.L29:
	addq	$1, -80(%rbp)
.L27:
	movq	-144(%rbp), %rax
	cmpq	%rax, -80(%rbp)
	jl	.L33
	jmp	.L31
.L36:
	nop
	jmp	.L31
.L37:
	nop
.L31:
	movq	-112(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	%rbx, %rsp
	movq	-56(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L35
	call	__stack_chk_fail@PLT
.L35:
	leaq	-40(%rbp), %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE11:
	.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	upll
	.type	upll, @function
upll:
.LFB51:
	.cfi_startproc
	endbr64
	movq	(%rsi), %rax
	cmpq	%rax, (%rdi)
	movl	$-1, %edx
	setg	%al
	movzbl	%al, %eax
	cmovl	%edx, %eax
	ret
	.cfi_endproc
.LFE51:
	.size	upll, .-upll
	.p2align 4
	.globl	downll
	.type	downll, @function
downll:
.LFB52:
	.cfi_startproc
	endbr64
	movq	(%rsi), %rdx
	movl	$1, %eax
	cmpq	%rdx, (%rdi)
	jl	.L5
	setg	%al
	movzbl	%al, %eax
	negl	%eax
.L5:
	ret
	.cfi_endproc
.LFE52:
	.size	downll, .-downll
	.p2align 4
	.globl	downll_hoge
	.type	downll_hoge, @function
downll_hoge:
.LFB55:
	.cfi_startproc
	endbr64
	movq	8(%rsi), %rdx
	movl	$1, %eax
	cmpq	%rdx, 8(%rdi)
	jl	.L8
	setg	%al
	movzbl	%al, %eax
	negl	%eax
.L8:
	ret
	.cfi_endproc
.LFE55:
	.size	downll_hoge, .-downll_hoge
	.p2align 4
	.globl	sortup
	.type	sortup, @function
sortup:
.LFB53:
	.cfi_startproc
	endbr64
	movslq	%esi, %rsi
	leaq	upll(%rip), %rcx
	movl	$8, %edx
	jmp	qsort@PLT
	.cfi_endproc
.LFE53:
	.size	sortup, .-sortup
	.p2align 4
	.globl	sortdown
	.type	sortdown, @function
sortdown:
.LFB54:
	.cfi_startproc
	endbr64
	movslq	%esi, %rsi
	leaq	downll(%rip), %rcx
	movl	$8, %edx
	jmp	qsort@PLT
	.cfi_endproc
.LFE54:
	.size	sortdown, .-sortdown
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%lld%lld"
.LC1:
	.string	"%lld"
.LC2:
	.string	"%lld\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB56:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	leaq	.LC0(%rip), %rdi
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%r15
	pushq	%r14
	leaq	-80(%rbp), %rdx
	leaq	-88(%rbp), %rsi
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	subq	$72, %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
	call	__isoc99_scanf@PLT
	movq	%rsp, %rdx
	movabsq	$1152921504606846975, %rax
	andq	-80(%rbp), %rax
	salq	$4, %rax
	movq	%rax, %rcx
	andq	$-4096, %rcx
	subq	%rcx, %rdx
	cmpq	%rdx, %rsp
	je	.L15
.L34:
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	cmpq	%rdx, %rsp
	jne	.L34
.L15:
	andl	$4095, %eax
	subq	%rax, %rsp
	testq	%rax, %rax
	jne	.L35
.L16:
	movq	-88(%rbp), %rsi
	movq	%rsp, %rbx
	testq	%rsi, %rsi
	jle	.L26
	xorl	%r15d, %r15d
	xorl	%r12d, %r12d
	leaq	-64(%rbp), %r13
	leaq	a(%rip), %r14
	.p2align 4,,10
	.p2align 3
.L18:
	movq	%r13, %rsi
	leaq	.LC1(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movq	-64(%rbp), %rax
	movq	-88(%rbp), %rsi
	movq	%rax, (%r14,%r15,8)
	addq	$1, %r15
	addq	%rax, %r12
	cmpq	%r15, %rsi
	jg	.L18
.L17:
	movslq	%esi, %rsi
	leaq	upll(%rip), %rcx
	movl	$8, %edx
	movq	%r14, %rdi
	call	qsort@PLT
	movq	-80(%rbp), %rsi
	testq	%rsi, %rsi
	jle	.L19
	leaq	-72(%rbp), %rax
	xorl	%r15d, %r15d
	leaq	-64(%rbp), %r13
	movq	%rax, -104(%rbp)
	.p2align 4,,10
	.p2align 3
.L20:
	movq	-104(%rbp), %rsi
	movq	%r13, %rdx
	leaq	.LC0(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movq	-72(%rbp), %xmm0
	movq	%r15, %rax
	movq	-80(%rbp), %rsi
	salq	$4, %rax
	addq	$1, %r15
	movhps	-64(%rbp), %xmm0
	movups	%xmm0, (%rbx,%rax)
	cmpq	%r15, %rsi
	jg	.L20
.L19:
	leaq	downll_hoge(%rip), %rcx
	movl	$16, %edx
	movq	%rbx, %rdi
	call	qsort@PLT
	movq	-88(%rbp), %r9
	testq	%r9, %r9
	jle	.L21
	movq	-80(%rbp), %r10
	xorl	%esi, %esi
	xorl	%edi, %edi
	jmp	.L24
	.p2align 4,,10
	.p2align 3
.L22:
	cmpq	%rdi, %r10
	jle	.L21
	movq	(%r14,%rsi,8), %r8
	movq	8(%rax), %rcx
	cmpq	%rcx, %r8
	jge	.L21
	subq	%r8, %rcx
	subq	$1, %rdx
	addq	$1, %rsi
	movq	%rdx, (%rax)
	addq	%rcx, %r12
	cmpq	%r9, %rsi
	jge	.L21
.L24:
	movq	%rdi, %rax
	salq	$4, %rax
	addq	%rbx, %rax
	movq	(%rax), %rdx
	testq	%rdx, %rdx
	jne	.L22
	addq	$1, %rdi
	cmpq	%r9, %rsi
	jl	.L24
	.p2align 4,,10
	.p2align 3
.L21:
	xorl	%eax, %eax
	movq	%r12, %rdx
	movl	$1, %edi
	leaq	.LC2(%rip), %rsi
	call	__printf_chk@PLT
	movq	-56(%rbp), %rax
	subq	%fs:40, %rax
	jne	.L36
	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
.L35:
	.cfi_restore_state
	orq	$0, -8(%rsp,%rax)
	jmp	.L16
.L26:
	xorl	%r12d, %r12d
	leaq	a(%rip), %r14
	jmp	.L17
.L36:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE56:
	.size	main, .-main
	.globl	a
	.bss
	.align 32
	.type	a, @object
	.size	a, 800040
a:
	.zero	800040
	.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	upll
	.type	upll, @function
upll:
.LFB51:
	.cfi_startproc
	endbr64
	movq	(%rsi), %rax
	cmpq	%rax, (%rdi)
	movl	$-1, %edx
	setg	%al
	movzbl	%al, %eax
	cmovl	%edx, %eax
	ret
	.cfi_endproc
.LFE51:
	.size	upll, .-upll
	.p2align 4
	.globl	downll
	.type	downll, @function
downll:
.LFB52:
	.cfi_startproc
	endbr64
	movq	(%rsi), %rdx
	movl	$1, %eax
	cmpq	%rdx, (%rdi)
	jl	.L5
	setg	%al
	movzbl	%al, %eax
	negl	%eax
.L5:
	ret
	.cfi_endproc
.LFE52:
	.size	downll, .-downll
	.p2align 4
	.globl	downll_hoge
	.type	downll_hoge, @function
downll_hoge:
.LFB55:
	.cfi_startproc
	endbr64
	movq	8(%rsi), %rdx
	movl	$1, %eax
	cmpq	%rdx, 8(%rdi)
	jl	.L8
	setg	%al
	movzbl	%al, %eax
	negl	%eax
.L8:
	ret
	.cfi_endproc
.LFE55:
	.size	downll_hoge, .-downll_hoge
	.p2align 4
	.globl	sortup
	.type	sortup, @function
sortup:
.LFB53:
	.cfi_startproc
	endbr64
	movslq	%esi, %rsi
	leaq	upll(%rip), %rcx
	movl	$8, %edx
	jmp	qsort@PLT
	.cfi_endproc
.LFE53:
	.size	sortup, .-sortup
	.p2align 4
	.globl	sortdown
	.type	sortdown, @function
sortdown:
.LFB54:
	.cfi_startproc
	endbr64
	movslq	%esi, %rsi
	leaq	downll(%rip), %rcx
	movl	$8, %edx
	jmp	qsort@PLT
	.cfi_endproc
.LFE54:
	.size	sortdown, .-sortdown
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%lld%lld"
.LC1:
	.string	"%lld"
.LC2:
	.string	"%lld\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB56:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	leaq	.LC0(%rip), %rdi
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%r15
	pushq	%r14
	leaq	-80(%rbp), %rdx
	leaq	-88(%rbp), %rsi
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	subq	$72, %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
	call	__isoc99_scanf@PLT
	movq	%rsp, %rdx
	movabsq	$1152921504606846975, %rax
	andq	-80(%rbp), %rax
	salq	$4, %rax
	movq	%rax, %rcx
	andq	$-4096, %rcx
	subq	%rcx, %rdx
	cmpq	%rdx, %rsp
	je	.L15
.L34:
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	cmpq	%rdx, %rsp
	jne	.L34
.L15:
	andl	$4095, %eax
	subq	%rax, %rsp
	testq	%rax, %rax
	jne	.L35
.L16:
	movq	-88(%rbp), %rsi
	movq	%rsp, %rbx
	testq	%rsi, %rsi
	jle	.L26
	xorl	%r15d, %r15d
	xorl	%r12d, %r12d
	leaq	-64(%rbp), %r13
	leaq	a(%rip), %r14
	.p2align 4,,10
	.p2align 3
.L18:
	movq	%r13, %rsi
	leaq	.LC1(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movq	-64(%rbp), %rax
	movq	-88(%rbp), %rsi
	movq	%rax, (%r14,%r15,8)
	addq	$1, %r15
	addq	%rax, %r12
	cmpq	%r15, %rsi
	jg	.L18
.L17:
	movslq	%esi, %rsi
	leaq	upll(%rip), %rcx
	movl	$8, %edx
	movq	%r14, %rdi
	call	qsort@PLT
	movq	-80(%rbp), %rsi
	testq	%rsi, %rsi
	jle	.L19
	leaq	-72(%rbp), %rax
	xorl	%r15d, %r15d
	leaq	-64(%rbp), %r13
	movq	%rax, -104(%rbp)
	.p2align 4,,10
	.p2align 3
.L20:
	movq	-104(%rbp), %rsi
	movq	%r13, %rdx
	leaq	.LC0(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movq	-72(%rbp), %xmm0
	movq	%r15, %rax
	movq	-80(%rbp), %rsi
	salq	$4, %rax
	addq	$1, %r15
	movhps	-64(%rbp), %xmm0
	movups	%xmm0, (%rbx,%rax)
	cmpq	%r15, %rsi
	jg	.L20
.L19:
	leaq	downll_hoge(%rip), %rcx
	movl	$16, %edx
	movq	%rbx, %rdi
	call	qsort@PLT
	movq	-88(%rbp), %r9
	testq	%r9, %r9
	jle	.L21
	movq	-80(%rbp), %r10
	xorl	%esi, %esi
	xorl	%edi, %edi
	jmp	.L24
	.p2align 4,,10
	.p2align 3
.L22:
	cmpq	%rdi, %r10
	jle	.L21
	movq	(%r14,%rsi,8), %r8
	movq	8(%rax), %rcx
	cmpq	%rcx, %r8
	jge	.L21
	subq	%r8, %rcx
	subq	$1, %rdx
	addq	$1, %rsi
	movq	%rdx, (%rax)
	addq	%rcx, %r12
	cmpq	%r9, %rsi
	jge	.L21
.L24:
	movq	%rdi, %rax
	salq	$4, %rax
	addq	%rbx, %rax
	movq	(%rax), %rdx
	testq	%rdx, %rdx
	jne	.L22
	addq	$1, %rdi
	cmpq	%r9, %rsi
	jl	.L24
	.p2align 4,,10
	.p2align 3
.L21:
	xorl	%eax, %eax
	movq	%r12, %rdx
	movl	$1, %edi
	leaq	.LC2(%rip), %rsi
	call	__printf_chk@PLT
	movq	-56(%rbp), %rax
	subq	%fs:40, %rax
	jne	.L36
	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
.L35:
	.cfi_restore_state
	orq	$0, -8(%rsp,%rax)
	jmp	.L16
.L26:
	xorl	%r12d, %r12d
	leaq	a(%rip), %r14
	jmp	.L17
.L36:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE56:
	.size	main, .-main
	.globl	a
	.bss
	.align 32
	.type	a, @object
	.size	a, 800040
a:
	.zero	800040
	.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:

// Ver19.03
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF (1 << 29) * 2
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

typedef struct
{
  ll b;
  ll c;
} hoge;

int downll_hoge(const void *aa, const void *bb) { return ((hoge *)aa)->c < ((hoge *)bb)->c ? 1 : ((hoge *)aa)->c > ((hoge *)bb)->c ? -1 : 0; }

ll a[100005];
int main()
{
  ll n, m, ans = 0;
  scanf("%lld%lld", &n, &m);
  hoge fuga[m];
  for (ll i = 0; i < n; i++)
  {
    ll aaa;
    scanf("%lld", &aaa);
    a[i] = aaa;
    ans += aaa;
  }
  sortup(a, n);
  for (ll i = 0; i < m; i++)
  {
    ll b, c;
    scanf("%lld%lld", &b, &c);
    fuga[i].b = b, fuga[i].c = c;
  }
  qsort(fuga, m, sizeof(hoge), downll_hoge);
  ll j = 0;
  for (ll i = 0; i < n; i++)
  {
    if (!fuga[j].b)
    {
      i--;
      j++;
      continue;
    }
    if (j >= m)
      break;
    if (a[i] < fuga[j].c)
    {
      ans += (fuga[j].c - a[i]);
      fuga[j].b--;
      // printf("yayay: %lld\n", fuga[j].c - a[i]);
      // printf("yayay: %lld\n", fuga[j].c);
      // printf("yayay: %lld\n", a[i]);
      // printf("j: %lld\n", j);
      // puts("");
    }
    else
      break;
  }
  printf("%lld\n", ans);
  return 0;
}

10 3
1 8 5 7 100 4 7 33 13 5
3 10
4 30
1 4
 3 2
5 1 1
2 3
1 5
 3 2
100 100 100
0 99
3 99
 11 3
1 1 1 1 1 1 1 1 1 1 1
3 1000000000
4 1000000000
3 1000000001
 10 2
0 8 5 7 100 4 7 33 24 5
3 10
4 30
1 4
 3 2
5 1 1
2 3
1 7
 10 2
0 8 5 7 100 4 7 33 24 5
3 15
4 30
1 4
 3 2
5 1 1
2 3
1 6
 3 2
5 1 1
2 3
2 6
 10 2
0 4 5 7 100 4 7 33 33 5
3 15
4 30
1 4

296
 13
 300
 10000000004
 307
 15
 322
 14
 17
 331

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

```c
// Ver19.03
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF (1 << 29) * 2
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

typedef struct
{
  ll b;
  ll c;
} hoge;

int downll_hoge(const void *aa, const void *bb) { return ((hoge *)aa)->c < ((hoge *)bb)->c ? 1 : ((hoge *)aa)->c > ((hoge *)bb)->c ? -1 : 0; }

ll a[100005];
int main()
{
  ll n, m, ans = 0;
  scanf("%lld%lld", &n, &m);
  hoge fuga[m];
  for (ll i = 0; i < n; i++)
  {
    ll aaa;
    scanf("%lld", &aaa);
    a[i] = aaa;
    ans += aaa;
  }
  sortup(a, n);
  for (ll i = 0; i < m; i++)
  {
    ll b, c;
    scanf("%lld%lld", &b, &c);
    fuga[i].b = b, fuga[i].c = c;
  }
  qsort(fuga, m, sizeof(hoge), downll_hoge);
  ll j = 0;
  for (ll i = 0; i < n; i++)
  {
    if (!fuga[j].b)
    {
      i--;
      j++;
      continue;
    }
    if (j >= m)
      break;
    if (a[i] < fuga[j].c)
    {
      ans += (fuga[j].c - a[i]);
      fuga[j].b--;
      // printf("yayay: %lld\n", fuga[j].c - a[i]);
      // printf("yayay: %lld\n", fuga[j].c);
      // printf("yayay: %lld\n", a[i]);
      // printf("j: %lld\n", j);
      // puts("");
    }
    else
      break;
  }
  printf("%lld\n", ans);
  return 0;
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	upll
	.type	upll, @function
upll:
.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
	movq	(%rax), %rdx
	movq	-16(%rbp), %rax
	movq	(%rax), %rax
	cmpq	%rax, %rdx
	jl	.L2
	movq	-8(%rbp), %rax
	movq	(%rax), %rdx
	movq	-16(%rbp), %rax
	movq	(%rax), %rax
	cmpq	%rax, %rdx
	setg	%al
	movzbl	%al, %eax
	jmp	.L4
.L2:
	movl	$-1, %eax
.L4:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	upll, .-upll
	.globl	downll
	.type	downll, @function
downll:
.LFB7:
	.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
	movq	(%rax), %rdx
	movq	-16(%rbp), %rax
	movq	(%rax), %rax
	cmpq	%rax, %rdx
	jl	.L6
	movq	-8(%rbp), %rax
	movq	(%rax), %rdx
	movq	-16(%rbp), %rax
	movq	(%rax), %rax
	cmpq	%rax, %rdx
	jle	.L7
	movl	$-1, %eax
	jmp	.L10
.L7:
	movl	$0, %eax
	jmp	.L10
.L6:
	movl	$1, %eax
.L10:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	downll, .-downll
	.globl	sortup
	.type	sortup, @function
sortup:
.LFB8:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$16, %rsp
	movq	%rdi, -8(%rbp)
	movl	%esi, -12(%rbp)
	movl	-12(%rbp), %eax
	movslq	%eax, %rsi
	movq	-8(%rbp), %rax
	leaq	upll(%rip), %rdx
	movq	%rdx, %rcx
	movl	$8, %edx
	movq	%rax, %rdi
	call	qsort@PLT
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.size	sortup, .-sortup
	.globl	sortdown
	.type	sortdown, @function
sortdown:
.LFB9:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$16, %rsp
	movq	%rdi, -8(%rbp)
	movl	%esi, -12(%rbp)
	movl	-12(%rbp), %eax
	movslq	%eax, %rsi
	movq	-8(%rbp), %rax
	leaq	downll(%rip), %rdx
	movq	%rdx, %rcx
	movl	$8, %edx
	movq	%rax, %rdi
	call	qsort@PLT
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE9:
	.size	sortdown, .-sortdown
	.globl	downll_hoge
	.type	downll_hoge, @function
downll_hoge:
.LFB10:
	.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
	movq	8(%rax), %rdx
	movq	-16(%rbp), %rax
	movq	8(%rax), %rax
	cmpq	%rax, %rdx
	jl	.L14
	movq	-8(%rbp), %rax
	movq	8(%rax), %rdx
	movq	-16(%rbp), %rax
	movq	8(%rax), %rax
	cmpq	%rax, %rdx
	jle	.L15
	movl	$-1, %eax
	jmp	.L18
.L15:
	movl	$0, %eax
	jmp	.L18
.L14:
	movl	$1, %eax
.L18:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE10:
	.size	downll_hoge, .-downll_hoge
	.globl	a
	.bss
	.align 32
	.type	a, @object
	.size	a, 800040
a:
	.zero	800040
	.section	.rodata
.LC0:
	.string	"%lld%lld"
.LC1:
	.string	"%lld"
.LC2:
	.string	"%lld\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB11:
	.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	$104, %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
	movq	$0, -112(%rbp)
	leaq	-136(%rbp), %rdx
	leaq	-144(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	-136(%rbp), %rax
	leaq	-1(%rax), %rdx
	movq	%rdx, -72(%rbp)
	movq	%rax, %rdx
	movq	%rdx, %r14
	movl	$0, %r15d
	movq	%rax, %rdx
	movq	%rdx, %r12
	movl	$0, %r13d
	salq	$4, %rax
	movq	%rax, %rdx
	movl	$16, %eax
	subq	$1, %rax
	addq	%rdx, %rax
	movl	$16, %edi
	movl	$0, %edx
	divq	%rdi
	imulq	$16, %rax, %rax
	movq	%rax, %rcx
	andq	$-4096, %rcx
	movq	%rsp, %rdx
	subq	%rcx, %rdx
.L20:
	cmpq	%rdx, %rsp
	je	.L21
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L20
.L21:
	movq	%rax, %rdx
	andl	$4095, %edx
	subq	%rdx, %rsp
	movq	%rax, %rdx
	andl	$4095, %edx
	testq	%rdx, %rdx
	je	.L22
	andl	$4095, %eax
	subq	$8, %rax
	addq	%rsp, %rax
	orq	$0, (%rax)
.L22:
	movq	%rsp, %rax
	addq	$7, %rax
	shrq	$3, %rax
	salq	$3, %rax
	movq	%rax, -64(%rbp)
	movq	$0, -104(%rbp)
	jmp	.L23
.L24:
	leaq	-120(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	-120(%rbp), %rax
	movq	-104(%rbp), %rdx
	leaq	0(,%rdx,8), %rcx
	leaq	a(%rip), %rdx
	movq	%rax, (%rcx,%rdx)
	movq	-120(%rbp), %rax
	addq	%rax, -112(%rbp)
	addq	$1, -104(%rbp)
.L23:
	movq	-144(%rbp), %rax
	cmpq	%rax, -104(%rbp)
	jl	.L24
	movq	-144(%rbp), %rax
	movl	%eax, %esi
	leaq	a(%rip), %rax
	movq	%rax, %rdi
	call	sortup
	movq	$0, -96(%rbp)
	jmp	.L25
.L26:
	leaq	-120(%rbp), %rdx
	leaq	-128(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	-128(%rbp), %rax
	movq	-64(%rbp), %rcx
	movq	-96(%rbp), %rdx
	salq	$4, %rdx
	addq	%rcx, %rdx
	movq	%rax, (%rdx)
	movq	-120(%rbp), %rax
	movq	-64(%rbp), %rcx
	movq	-96(%rbp), %rdx
	salq	$4, %rdx
	addq	%rcx, %rdx
	addq	$8, %rdx
	movq	%rax, (%rdx)
	addq	$1, -96(%rbp)
.L25:
	movq	-136(%rbp), %rax
	cmpq	%rax, -96(%rbp)
	jl	.L26
	movq	-136(%rbp), %rax
	movq	%rax, %rsi
	movq	-64(%rbp), %rax
	leaq	downll_hoge(%rip), %rdx
	movq	%rdx, %rcx
	movl	$16, %edx
	movq	%rax, %rdi
	call	qsort@PLT
	movq	$0, -88(%rbp)
	movq	$0, -80(%rbp)
	jmp	.L27
.L33:
	movq	-64(%rbp), %rdx
	movq	-88(%rbp), %rax
	salq	$4, %rax
	addq	%rdx, %rax
	movq	(%rax), %rax
	testq	%rax, %rax
	jne	.L28
	subq	$1, -80(%rbp)
	addq	$1, -88(%rbp)
	jmp	.L29
.L28:
	movq	-136(%rbp), %rax
	cmpq	%rax, -88(%rbp)
	jge	.L36
	movq	-80(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	leaq	a(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movq	-64(%rbp), %rcx
	movq	-88(%rbp), %rax
	salq	$4, %rax
	addq	%rcx, %rax
	addq	$8, %rax
	movq	(%rax), %rax
	cmpq	%rax, %rdx
	jge	.L37
	movq	-64(%rbp), %rdx
	movq	-88(%rbp), %rax
	salq	$4, %rax
	addq	%rdx, %rax
	addq	$8, %rax
	movq	(%rax), %rax
	movq	-80(%rbp), %rdx
	leaq	0(,%rdx,8), %rcx
	leaq	a(%rip), %rdx
	movq	(%rcx,%rdx), %rdx
	subq	%rdx, %rax
	addq	%rax, -112(%rbp)
	movq	-64(%rbp), %rdx
	movq	-88(%rbp), %rax
	salq	$4, %rax
	addq	%rdx, %rax
	movq	(%rax), %rax
	leaq	-1(%rax), %rdx
	movq	-64(%rbp), %rcx
	movq	-88(%rbp), %rax
	salq	$4, %rax
	addq	%rcx, %rax
	movq	%rdx, (%rax)
.L29:
	addq	$1, -80(%rbp)
.L27:
	movq	-144(%rbp), %rax
	cmpq	%rax, -80(%rbp)
	jl	.L33
	jmp	.L31
.L36:
	nop
	jmp	.L31
.L37:
	nop
.L31:
	movq	-112(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	%rbx, %rsp
	movq	-56(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L35
	call	__stack_chk_fail@PLT
.L35:
	leaq	-40(%rbp), %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE11:
	.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	upll
	.type	upll, @function
upll:
.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
	movq	(%rax), %rdx
	movq	-16(%rbp), %rax
	movq	(%rax), %rax
	cmpq	%rax, %rdx
	jl	.L2
	movq	-8(%rbp), %rax
	movq	(%rax), %rdx
	movq	-16(%rbp), %rax
	movq	(%rax), %rax
	cmpq	%rax, %rdx
	setg	%al
	movzbl	%al, %eax
	jmp	.L4
.L2:
	movl	$-1, %eax
.L4:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	upll, .-upll
	.globl	downll
	.type	downll, @function
downll:
.LFB7:
	.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
	movq	(%rax), %rdx
	movq	-16(%rbp), %rax
	movq	(%rax), %rax
	cmpq	%rax, %rdx
	jl	.L6
	movq	-8(%rbp), %rax
	movq	(%rax), %rdx
	movq	-16(%rbp), %rax
	movq	(%rax), %rax
	cmpq	%rax, %rdx
	jle	.L7
	movl	$-1, %eax
	jmp	.L10
.L7:
	movl	$0, %eax
	jmp	.L10
.L6:
	movl	$1, %eax
.L10:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	downll, .-downll
	.globl	sortup
	.type	sortup, @function
sortup:
.LFB8:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$16, %rsp
	movq	%rdi, -8(%rbp)
	movl	%esi, -12(%rbp)
	movl	-12(%rbp), %eax
	movslq	%eax, %rsi
	movq	-8(%rbp), %rax
	leaq	upll(%rip), %rdx
	movq	%rdx, %rcx
	movl	$8, %edx
	movq	%rax, %rdi
	call	qsort@PLT
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.size	sortup, .-sortup
	.globl	sortdown
	.type	sortdown, @function
sortdown:
.LFB9:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$16, %rsp
	movq	%rdi, -8(%rbp)
	movl	%esi, -12(%rbp)
	movl	-12(%rbp), %eax
	movslq	%eax, %rsi
	movq	-8(%rbp), %rax
	leaq	downll(%rip), %rdx
	movq	%rdx, %rcx
	movl	$8, %edx
	movq	%rax, %rdi
	call	qsort@PLT
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE9:
	.size	sortdown, .-sortdown
	.globl	downll_hoge
	.type	downll_hoge, @function
downll_hoge:
.LFB10:
	.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
	movq	8(%rax), %rdx
	movq	-16(%rbp), %rax
	movq	8(%rax), %rax
	cmpq	%rax, %rdx
	jl	.L14
	movq	-8(%rbp), %rax
	movq	8(%rax), %rdx
	movq	-16(%rbp), %rax
	movq	8(%rax), %rax
	cmpq	%rax, %rdx
	jle	.L15
	movl	$-1, %eax
	jmp	.L18
.L15:
	movl	$0, %eax
	jmp	.L18
.L14:
	movl	$1, %eax
.L18:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE10:
	.size	downll_hoge, .-downll_hoge
	.globl	a
	.bss
	.align 32
	.type	a, @object
	.size	a, 800040
a:
	.zero	800040
	.section	.rodata
.LC0:
	.string	"%lld%lld"
.LC1:
	.string	"%lld"
.LC2:
	.string	"%lld\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB11:
	.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	$104, %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
	movq	$0, -112(%rbp)
	leaq	-136(%rbp), %rdx
	leaq	-144(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	-136(%rbp), %rax
	leaq	-1(%rax), %rdx
	movq	%rdx, -72(%rbp)
	movq	%rax, %rdx
	movq	%rdx, %r14
	movl	$0, %r15d
	movq	%rax, %rdx
	movq	%rdx, %r12
	movl	$0, %r13d
	salq	$4, %rax
	movq	%rax, %rdx
	movl	$16, %eax
	subq	$1, %rax
	addq	%rdx, %rax
	movl	$16, %edi
	movl	$0, %edx
	divq	%rdi
	imulq	$16, %rax, %rax
	movq	%rax, %rcx
	andq	$-4096, %rcx
	movq	%rsp, %rdx
	subq	%rcx, %rdx
.L20:
	cmpq	%rdx, %rsp
	je	.L21
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L20
.L21:
	movq	%rax, %rdx
	andl	$4095, %edx
	subq	%rdx, %rsp
	movq	%rax, %rdx
	andl	$4095, %edx
	testq	%rdx, %rdx
	je	.L22
	andl	$4095, %eax
	subq	$8, %rax
	addq	%rsp, %rax
	orq	$0, (%rax)
.L22:
	movq	%rsp, %rax
	addq	$7, %rax
	shrq	$3, %rax
	salq	$3, %rax
	movq	%rax, -64(%rbp)
	movq	$0, -104(%rbp)
	jmp	.L23
.L24:
	leaq	-120(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	-120(%rbp), %rax
	movq	-104(%rbp), %rdx
	leaq	0(,%rdx,8), %rcx
	leaq	a(%rip), %rdx
	movq	%rax, (%rcx,%rdx)
	movq	-120(%rbp), %rax
	addq	%rax, -112(%rbp)
	addq	$1, -104(%rbp)
.L23:
	movq	-144(%rbp), %rax
	cmpq	%rax, -104(%rbp)
	jl	.L24
	movq	-144(%rbp), %rax
	movl	%eax, %esi
	leaq	a(%rip), %rax
	movq	%rax, %rdi
	call	sortup
	movq	$0, -96(%rbp)
	jmp	.L25
.L26:
	leaq	-120(%rbp), %rdx
	leaq	-128(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	-128(%rbp), %rax
	movq	-64(%rbp), %rcx
	movq	-96(%rbp), %rdx
	salq	$4, %rdx
	addq	%rcx, %rdx
	movq	%rax, (%rdx)
	movq	-120(%rbp), %rax
	movq	-64(%rbp), %rcx
	movq	-96(%rbp), %rdx
	salq	$4, %rdx
	addq	%rcx, %rdx
	addq	$8, %rdx
	movq	%rax, (%rdx)
	addq	$1, -96(%rbp)
.L25:
	movq	-136(%rbp), %rax
	cmpq	%rax, -96(%rbp)
	jl	.L26
	movq	-136(%rbp), %rax
	movq	%rax, %rsi
	movq	-64(%rbp), %rax
	leaq	downll_hoge(%rip), %rdx
	movq	%rdx, %rcx
	movl	$16, %edx
	movq	%rax, %rdi
	call	qsort@PLT
	movq	$0, -88(%rbp)
	movq	$0, -80(%rbp)
	jmp	.L27
.L33:
	movq	-64(%rbp), %rdx
	movq	-88(%rbp), %rax
	salq	$4, %rax
	addq	%rdx, %rax
	movq	(%rax), %rax
	testq	%rax, %rax
	jne	.L28
	subq	$1, -80(%rbp)
	addq	$1, -88(%rbp)
	jmp	.L29
.L28:
	movq	-136(%rbp), %rax
	cmpq	%rax, -88(%rbp)
	jge	.L36
	movq	-80(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	leaq	a(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movq	-64(%rbp), %rcx
	movq	-88(%rbp), %rax
	salq	$4, %rax
	addq	%rcx, %rax
	addq	$8, %rax
	movq	(%rax), %rax
	cmpq	%rax, %rdx
	jge	.L37
	movq	-64(%rbp), %rdx
	movq	-88(%rbp), %rax
	salq	$4, %rax
	addq	%rdx, %rax
	addq	$8, %rax
	movq	(%rax), %rax
	movq	-80(%rbp), %rdx
	leaq	0(,%rdx,8), %rcx
	leaq	a(%rip), %rdx
	movq	(%rcx,%rdx), %rdx
	subq	%rdx, %rax
	addq	%rax, -112(%rbp)
	movq	-64(%rbp), %rdx
	movq	-88(%rbp), %rax
	salq	$4, %rax
	addq	%rdx, %rax
	movq	(%rax), %rax
	leaq	-1(%rax), %rdx
	movq	-64(%rbp), %rcx
	movq	-88(%rbp), %rax
	salq	$4, %rax
	addq	%rcx, %rax
	movq	%rdx, (%rax)
.L29:
	addq	$1, -80(%rbp)
.L27:
	movq	-144(%rbp), %rax
	cmpq	%rax, -80(%rbp)
	jl	.L33
	jmp	.L31
.L36:
	nop
	jmp	.L31
.L37:
	nop
.L31:
	movq	-112(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	%rbx, %rsp
	movq	-56(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L35
	call	__stack_chk_fail@PLT
.L35:
	leaq	-40(%rbp), %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE11:
	.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:
