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>

#define N 1000
#define M 500

#define MAX(A,B) ((A) < (B) ? (B) : (A))

static int n;
static int m;
static int d[M][2];

int compare(const void *a, const void *b) {
  if (*(const int*)a < *(const int*)b)
    return -1;
  if (*(const int*)b < *(const int*)a)
    return 1;
  return 0;
}

static void read(void) {
  int i, sp;
  
  scanf("%d%d", &n, &m);
  for (i = 0; i < m; ++i) {
    scanf("%d%d", &d[i][0], &d[i][1]);
  }
  qsort(d, m, sizeof(int) * 2, compare);
  
  sp = 0;
  for (i = 1; i < m; ++i) {
    if (d[i][0] <= d[sp][1]) {
      d[sp][1] = MAX(d[sp][1], d[i][1]);
    } else {
      ++sp;
      d[sp][0] = d[i][0];
      d[sp][1] = d[i][1];
    }
  }
  m = sp + 1;
}

static int eval(void) {
  int pos, rval;
  int i;
  
  pos = 0;
  rval = 0;
  for (i = 0; i < m; ++i) {
    rval += d[i][1] - pos;
    rval += (d[i][1] - d[i][0]) * 2;
    pos = d[i][1];
  }
  rval += n - pos + 1;
  
  return rval;
}

int main(void) {
  read();
  printf("%d\n", eval());

  return EXIT_SUCCESS;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.local	n
	.comm	n,4,4
	.local	m
	.comm	m,4,4
	.local	d
	.comm	d,4000,32
	.globl	compare
	.type	compare, @function
compare:
.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), %eax
	cmpl	%eax, %edx
	jge	.L2
	movl	$-1, %eax
	jmp	.L3
.L2:
	movq	-16(%rbp), %rax
	movl	(%rax), %edx
	movq	-8(%rbp), %rax
	movl	(%rax), %eax
	cmpl	%eax, %edx
	jge	.L4
	movl	$1, %eax
	jmp	.L3
.L4:
	movl	$0, %eax
.L3:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	compare, .-compare
	.section	.rodata
.LC0:
	.string	"%d%d"
	.text
	.type	read, @function
read:
.LFB7:
	.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
	leaq	m(%rip), %rax
	movq	%rax, %rdx
	leaq	n(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -8(%rbp)
	jmp	.L6
.L7:
	movl	-8(%rbp), %eax
	cltq
	salq	$3, %rax
	leaq	4(%rax), %rdx
	leaq	d(%rip), %rax
	addq	%rax, %rdx
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rcx
	leaq	d(%rip), %rax
	addq	%rcx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -8(%rbp)
.L6:
	movl	m(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jl	.L7
	movl	m(%rip), %eax
	cltq
	leaq	compare(%rip), %rdx
	movq	%rdx, %rcx
	movl	$8, %edx
	movq	%rax, %rsi
	leaq	d(%rip), %rax
	movq	%rax, %rdi
	call	qsort@PLT
	movl	$0, -4(%rbp)
	movl	$1, -8(%rbp)
	jmp	.L8
.L11:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	d(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rcx
	leaq	4+d(%rip), %rax
	movl	(%rcx,%rax), %eax
	cmpl	%eax, %edx
	jg	.L9
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	4+d(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rcx
	leaq	4+d(%rip), %rax
	movl	(%rcx,%rax), %eax
	cmpl	%eax, %edx
	cmovge	%edx, %eax
	movl	-4(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,8), %rcx
	leaq	4+d(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	jmp	.L10
.L9:
	addl	$1, -4(%rbp)
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	d(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-4(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,8), %rcx
	leaq	d(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	4+d(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-4(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,8), %rcx
	leaq	4+d(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
.L10:
	addl	$1, -8(%rbp)
.L8:
	movl	m(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jl	.L11
	movl	-4(%rbp), %eax
	addl	$1, %eax
	movl	%eax, m(%rip)
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	read, .-read
	.type	eval, @function
eval:
.LFB8:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	$0, -12(%rbp)
	movl	$0, -8(%rbp)
	movl	$0, -4(%rbp)
	jmp	.L13
.L14:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	4+d(%rip), %rax
	movl	(%rdx,%rax), %eax
	subl	-12(%rbp), %eax
	addl	%eax, -8(%rbp)
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	4+d(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-4(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,8), %rcx
	leaq	d(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	subl	%edx, %eax
	addl	%eax, %eax
	addl	%eax, -8(%rbp)
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	4+d(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -12(%rbp)
	addl	$1, -4(%rbp)
.L13:
	movl	m(%rip), %eax
	cmpl	%eax, -4(%rbp)
	jl	.L14
	movl	n(%rip), %eax
	subl	-12(%rbp), %eax
	addl	$1, %eax
	addl	%eax, -8(%rbp)
	movl	-8(%rbp), %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.size	eval, .-eval
	.section	.rodata
.LC1:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB9:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	call	read
	call	eval
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE9:
	.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	compare
	.type	compare, @function
compare:
.LFB39:
	.cfi_startproc
	endbr64
	movl	(%rsi), %eax
	cmpl	%eax, (%rdi)
	movl	$-1, %edx
	setg	%al
	movzbl	%al, %eax
	cmovl	%edx, %eax
	ret
	.cfi_endproc
.LFE39:
	.size	compare, .-compare
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d%d"
.LC1:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB42:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	leaq	.LC0(%rip), %r13
	leaq	n(%rip), %rsi
	xorl	%eax, %eax
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	leaq	m(%rip), %rdx
	movq	%r13, %rdi
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	leaq	d(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	subq	$8, %rsp
	.cfi_def_cfa_offset 48
	call	__isoc99_scanf@PLT
	movslq	m(%rip), %rsi
	testl	%esi, %esi
	jle	.L6
	movq	%rbp, %rbx
	xorl	%r12d, %r12d
	.p2align 4,,10
	.p2align 3
.L7:
	movq	%rbx, %rsi
	leaq	4(%rbx), %rdx
	movq	%r13, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movslq	m(%rip), %rsi
	addl	$1, %r12d
	addq	$8, %rbx
	cmpl	%esi, %r12d
	jl	.L7
.L6:
	leaq	compare(%rip), %rcx
	movl	$8, %edx
	movq	%rbp, %rdi
	call	qsort@PLT
	movl	m(%rip), %ecx
	cmpl	$1, %ecx
	jle	.L13
	leaq	12+d(%rip), %rax
	leal	-2(%rcx), %esi
	movl	4+d(%rip), %edx
	leaq	8(%rax), %rcx
	leaq	(%rcx,%rsi,8), %r8
	xorl	%esi, %esi
	jmp	.L11
	.p2align 4,,10
	.p2align 3
.L19:
	movl	(%rax), %ecx
	movslq	%esi, %rdi
	cmpl	%ecx, %edx
	cmovl	%ecx, %edx
	addq	$8, %rax
	movl	%edx, 4(%rbp,%rdi,8)
	cmpq	%rax, %r8
	je	.L8
.L11:
	movl	-4(%rax), %ecx
	cmpl	%edx, %ecx
	jle	.L19
	movl	(%rax), %edx
	addl	$1, %esi
	movd	%ecx, %xmm0
	addq	$8, %rax
	movslq	%esi, %rdi
	movd	%edx, %xmm1
	punpckldq	%xmm1, %xmm0
	movq	%xmm0, 0(%rbp,%rdi,8)
	cmpq	%rax, %r8
	jne	.L11
.L8:
	leaq	d(%rip), %rax
	addl	$1, %esi
	leaq	8(%rax), %rdx
	movl	%esi, m(%rip)
	xorl	%esi, %esi
	leaq	(%rdx,%rdi,8), %r8
	xorl	%edx, %edx
	.p2align 4,,10
	.p2align 3
.L12:
	movl	%edx, %edi
	movl	4(%rax), %edx
	addq	$8, %rax
	movl	%edx, %ecx
	subl	%edi, %ecx
	addl	%esi, %ecx
	movl	%edx, %esi
	subl	-8(%rax), %esi
	leal	(%rcx,%rsi,2), %esi
	cmpq	%rax, %r8
	jne	.L12
	movl	n(%rip), %eax
	movl	$1, %edi
	subl	%edx, %eax
	leal	1(%rsi,%rax), %edx
	leaq	.LC1(%rip), %rsi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	addq	$8, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
.L13:
	.cfi_restore_state
	xorl	%esi, %esi
	xorl	%edi, %edi
	jmp	.L8
	.cfi_endproc
.LFE42:
	.size	main, .-main
	.local	d
	.comm	d,4000,32
	.local	m
	.comm	m,4,4
	.local	n
	.comm	n,4,4
	.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	compare
	.type	compare, @function
compare:
.LFB39:
	.cfi_startproc
	endbr64
	movl	(%rsi), %eax
	cmpl	%eax, (%rdi)
	movl	$-1, %edx
	setg	%al
	movzbl	%al, %eax
	cmovl	%edx, %eax
	ret
	.cfi_endproc
.LFE39:
	.size	compare, .-compare
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d%d"
.LC1:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB42:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	leaq	.LC0(%rip), %r13
	leaq	n(%rip), %rsi
	xorl	%eax, %eax
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	leaq	m(%rip), %rdx
	movq	%r13, %rdi
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	leaq	d(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	subq	$8, %rsp
	.cfi_def_cfa_offset 48
	call	__isoc99_scanf@PLT
	movslq	m(%rip), %rsi
	testl	%esi, %esi
	jle	.L6
	movq	%rbp, %rbx
	xorl	%r12d, %r12d
	.p2align 4,,10
	.p2align 3
.L7:
	movq	%rbx, %rsi
	leaq	4(%rbx), %rdx
	movq	%r13, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movslq	m(%rip), %rsi
	addl	$1, %r12d
	addq	$8, %rbx
	cmpl	%esi, %r12d
	jl	.L7
.L6:
	leaq	compare(%rip), %rcx
	movl	$8, %edx
	movq	%rbp, %rdi
	call	qsort@PLT
	movl	m(%rip), %ecx
	cmpl	$1, %ecx
	jle	.L13
	leaq	12+d(%rip), %rax
	leal	-2(%rcx), %esi
	movl	4+d(%rip), %edx
	leaq	8(%rax), %rcx
	leaq	(%rcx,%rsi,8), %r8
	xorl	%esi, %esi
	jmp	.L11
	.p2align 4,,10
	.p2align 3
.L19:
	movl	(%rax), %ecx
	movslq	%esi, %rdi
	cmpl	%ecx, %edx
	cmovl	%ecx, %edx
	addq	$8, %rax
	movl	%edx, 4(%rbp,%rdi,8)
	cmpq	%rax, %r8
	je	.L8
.L11:
	movl	-4(%rax), %ecx
	cmpl	%edx, %ecx
	jle	.L19
	movl	(%rax), %edx
	addl	$1, %esi
	movd	%ecx, %xmm0
	addq	$8, %rax
	movslq	%esi, %rdi
	movd	%edx, %xmm1
	punpckldq	%xmm1, %xmm0
	movq	%xmm0, 0(%rbp,%rdi,8)
	cmpq	%rax, %r8
	jne	.L11
.L8:
	leaq	d(%rip), %rax
	addl	$1, %esi
	leaq	8(%rax), %rdx
	movl	%esi, m(%rip)
	xorl	%esi, %esi
	leaq	(%rdx,%rdi,8), %r8
	xorl	%edx, %edx
	.p2align 4,,10
	.p2align 3
.L12:
	movl	%edx, %edi
	movl	4(%rax), %edx
	addq	$8, %rax
	movl	%edx, %ecx
	subl	%edi, %ecx
	addl	%esi, %ecx
	movl	%edx, %esi
	subl	-8(%rax), %esi
	leal	(%rcx,%rsi,2), %esi
	cmpq	%rax, %r8
	jne	.L12
	movl	n(%rip), %eax
	movl	$1, %edi
	subl	%edx, %eax
	leal	1(%rsi,%rax), %edx
	leaq	.LC1(%rip), %rsi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	addq	$8, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
.L13:
	.cfi_restore_state
	xorl	%esi, %esi
	xorl	%edi, %edi
	jmp	.L8
	.cfi_endproc
.LFE42:
	.size	main, .-main
	.local	d
	.comm	d,4000,32
	.local	m
	.comm	m,4,4
	.local	n
	.comm	n,4,4
	.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>

#define N 1000
#define M 500

#define MAX(A,B) ((A) < (B) ? (B) : (A))

static int n;
static int m;
static int d[M][2];

int compare(const void *a, const void *b) {
  if (*(const int*)a < *(const int*)b)
    return -1;
  if (*(const int*)b < *(const int*)a)
    return 1;
  return 0;
}

static void read(void) {
  int i, sp;
  
  scanf("%d%d", &n, &m);
  for (i = 0; i < m; ++i) {
    scanf("%d%d", &d[i][0], &d[i][1]);
  }
  qsort(d, m, sizeof(int) * 2, compare);
  
  sp = 0;
  for (i = 1; i < m; ++i) {
    if (d[i][0] <= d[sp][1]) {
      d[sp][1] = MAX(d[sp][1], d[i][1]);
    } else {
      ++sp;
      d[sp][0] = d[i][0];
      d[sp][1] = d[i][1];
    }
  }
  m = sp + 1;
}

static int eval(void) {
  int pos, rval;
  int i;
  
  pos = 0;
  rval = 0;
  for (i = 0; i < m; ++i) {
    rval += d[i][1] - pos;
    rval += (d[i][1] - d[i][0]) * 2;
    pos = d[i][1];
  }
  rval += n - pos + 1;
  
  return rval;
}

int main(void) {
  read();
  printf("%d\n", eval());

  return EXIT_SUCCESS;
}
10 3
3 7
8 9
3 5
 10 3
3 7
8 9
3 8
 10 3
2 8
8 9
3 8
 10 3
3 7
8 9
1 8
 9 3
3 7
8 9
1 5
 10 3
3 10
8 9
1 5
 10 3
3 4
8 9
4 5
 18 3
3 7
7 9
2 5
 18 3
3 7
7 9
1 5
 18 3
3 7
7 17
1 5

21
 23
 25
 27
 24
 29
 17
 33
 35
 51

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>

#define N 1000
#define M 500

#define MAX(A,B) ((A) < (B) ? (B) : (A))

static int n;
static int m;
static int d[M][2];

int compare(const void *a, const void *b) {
  if (*(const int*)a < *(const int*)b)
    return -1;
  if (*(const int*)b < *(const int*)a)
    return 1;
  return 0;
}

static void read(void) {
  int i, sp;
  
  scanf("%d%d", &n, &m);
  for (i = 0; i < m; ++i) {
    scanf("%d%d", &d[i][0], &d[i][1]);
  }
  qsort(d, m, sizeof(int) * 2, compare);
  
  sp = 0;
  for (i = 1; i < m; ++i) {
    if (d[i][0] <= d[sp][1]) {
      d[sp][1] = MAX(d[sp][1], d[i][1]);
    } else {
      ++sp;
      d[sp][0] = d[i][0];
      d[sp][1] = d[i][1];
    }
  }
  m = sp + 1;
}

static int eval(void) {
  int pos, rval;
  int i;
  
  pos = 0;
  rval = 0;
  for (i = 0; i < m; ++i) {
    rval += d[i][1] - pos;
    rval += (d[i][1] - d[i][0]) * 2;
    pos = d[i][1];
  }
  rval += n - pos + 1;
  
  return rval;
}

int main(void) {
  read();
  printf("%d\n", eval());

  return EXIT_SUCCESS;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.local	n
	.comm	n,4,4
	.local	m
	.comm	m,4,4
	.local	d
	.comm	d,4000,32
	.globl	compare
	.type	compare, @function
compare:
.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), %eax
	cmpl	%eax, %edx
	jge	.L2
	movl	$-1, %eax
	jmp	.L3
.L2:
	movq	-16(%rbp), %rax
	movl	(%rax), %edx
	movq	-8(%rbp), %rax
	movl	(%rax), %eax
	cmpl	%eax, %edx
	jge	.L4
	movl	$1, %eax
	jmp	.L3
.L4:
	movl	$0, %eax
.L3:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	compare, .-compare
	.section	.rodata
.LC0:
	.string	"%d%d"
	.text
	.type	read, @function
read:
.LFB7:
	.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
	leaq	m(%rip), %rax
	movq	%rax, %rdx
	leaq	n(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -8(%rbp)
	jmp	.L6
.L7:
	movl	-8(%rbp), %eax
	cltq
	salq	$3, %rax
	leaq	4(%rax), %rdx
	leaq	d(%rip), %rax
	addq	%rax, %rdx
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rcx
	leaq	d(%rip), %rax
	addq	%rcx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -8(%rbp)
.L6:
	movl	m(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jl	.L7
	movl	m(%rip), %eax
	cltq
	leaq	compare(%rip), %rdx
	movq	%rdx, %rcx
	movl	$8, %edx
	movq	%rax, %rsi
	leaq	d(%rip), %rax
	movq	%rax, %rdi
	call	qsort@PLT
	movl	$0, -4(%rbp)
	movl	$1, -8(%rbp)
	jmp	.L8
.L11:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	d(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rcx
	leaq	4+d(%rip), %rax
	movl	(%rcx,%rax), %eax
	cmpl	%eax, %edx
	jg	.L9
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	4+d(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rcx
	leaq	4+d(%rip), %rax
	movl	(%rcx,%rax), %eax
	cmpl	%eax, %edx
	cmovge	%edx, %eax
	movl	-4(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,8), %rcx
	leaq	4+d(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	jmp	.L10
.L9:
	addl	$1, -4(%rbp)
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	d(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-4(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,8), %rcx
	leaq	d(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	4+d(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-4(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,8), %rcx
	leaq	4+d(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
.L10:
	addl	$1, -8(%rbp)
.L8:
	movl	m(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jl	.L11
	movl	-4(%rbp), %eax
	addl	$1, %eax
	movl	%eax, m(%rip)
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	read, .-read
	.type	eval, @function
eval:
.LFB8:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	$0, -12(%rbp)
	movl	$0, -8(%rbp)
	movl	$0, -4(%rbp)
	jmp	.L13
.L14:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	4+d(%rip), %rax
	movl	(%rdx,%rax), %eax
	subl	-12(%rbp), %eax
	addl	%eax, -8(%rbp)
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	4+d(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-4(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,8), %rcx
	leaq	d(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	subl	%edx, %eax
	addl	%eax, %eax
	addl	%eax, -8(%rbp)
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	4+d(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -12(%rbp)
	addl	$1, -4(%rbp)
.L13:
	movl	m(%rip), %eax
	cmpl	%eax, -4(%rbp)
	jl	.L14
	movl	n(%rip), %eax
	subl	-12(%rbp), %eax
	addl	$1, %eax
	addl	%eax, -8(%rbp)
	movl	-8(%rbp), %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.size	eval, .-eval
	.section	.rodata
.LC1:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB9:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	call	read
	call	eval
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE9:
	.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
	.local	n
	.comm	n,4,4
	.local	m
	.comm	m,4,4
	.local	d
	.comm	d,4000,32
	.globl	compare
	.type	compare, @function
compare:
.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), %eax
	cmpl	%eax, %edx
	jge	.L2
	movl	$-1, %eax
	jmp	.L3
.L2:
	movq	-16(%rbp), %rax
	movl	(%rax), %edx
	movq	-8(%rbp), %rax
	movl	(%rax), %eax
	cmpl	%eax, %edx
	jge	.L4
	movl	$1, %eax
	jmp	.L3
.L4:
	movl	$0, %eax
.L3:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	compare, .-compare
	.section	.rodata
.LC0:
	.string	"%d%d"
	.text
	.type	read, @function
read:
.LFB7:
	.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
	leaq	m(%rip), %rax
	movq	%rax, %rdx
	leaq	n(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -8(%rbp)
	jmp	.L6
.L7:
	movl	-8(%rbp), %eax
	cltq
	salq	$3, %rax
	leaq	4(%rax), %rdx
	leaq	d(%rip), %rax
	addq	%rax, %rdx
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rcx
	leaq	d(%rip), %rax
	addq	%rcx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -8(%rbp)
.L6:
	movl	m(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jl	.L7
	movl	m(%rip), %eax
	cltq
	leaq	compare(%rip), %rdx
	movq	%rdx, %rcx
	movl	$8, %edx
	movq	%rax, %rsi
	leaq	d(%rip), %rax
	movq	%rax, %rdi
	call	qsort@PLT
	movl	$0, -4(%rbp)
	movl	$1, -8(%rbp)
	jmp	.L8
.L11:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	d(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rcx
	leaq	4+d(%rip), %rax
	movl	(%rcx,%rax), %eax
	cmpl	%eax, %edx
	jg	.L9
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	4+d(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rcx
	leaq	4+d(%rip), %rax
	movl	(%rcx,%rax), %eax
	cmpl	%eax, %edx
	cmovge	%edx, %eax
	movl	-4(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,8), %rcx
	leaq	4+d(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	jmp	.L10
.L9:
	addl	$1, -4(%rbp)
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	d(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-4(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,8), %rcx
	leaq	d(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	4+d(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-4(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,8), %rcx
	leaq	4+d(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
.L10:
	addl	$1, -8(%rbp)
.L8:
	movl	m(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jl	.L11
	movl	-4(%rbp), %eax
	addl	$1, %eax
	movl	%eax, m(%rip)
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	read, .-read
	.type	eval, @function
eval:
.LFB8:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	$0, -12(%rbp)
	movl	$0, -8(%rbp)
	movl	$0, -4(%rbp)
	jmp	.L13
.L14:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	4+d(%rip), %rax
	movl	(%rdx,%rax), %eax
	subl	-12(%rbp), %eax
	addl	%eax, -8(%rbp)
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	4+d(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-4(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,8), %rcx
	leaq	d(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	subl	%edx, %eax
	addl	%eax, %eax
	addl	%eax, -8(%rbp)
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	4+d(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -12(%rbp)
	addl	$1, -4(%rbp)
.L13:
	movl	m(%rip), %eax
	cmpl	%eax, -4(%rbp)
	jl	.L14
	movl	n(%rip), %eax
	subl	-12(%rbp), %eax
	addl	$1, %eax
	addl	%eax, -8(%rbp)
	movl	-8(%rbp), %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.size	eval, .-eval
	.section	.rodata
.LC1:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB9:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	call	read
	call	eval
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE9:
	.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:
