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>

int horieyui(const void* x, const void* y) {
	int a = *(const int*)x, b = *(const int*)y;
	return a < b ? -1 : a > b;
}

int N, Q;
int a[114514];
int l[114514], r[114514];

int main(void) {
	int i;
	if (scanf("%d%d", &N, &Q) != 2) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%d", &a[i]) != 1) return 1;
	}
	for (i = 0; i < Q; i++) {
		if (scanf("%d%d", &l[i], &r[i]) != 2) return 1;
	}
	a[N] = -1;
	a[N + 1] = 1111111111;
	N += 2;
	qsort(a, N, sizeof(*a), horieyui);
	for (i = 0; i < Q; i++) {
		int under, hidari, migi, over;
		under = 0; hidari = N - 1;
		while (under + 1 < hidari) {
			int mid = under + (hidari - under) / 2;
			if (l[i] <= a[mid]) hidari = mid; else under = mid;
		}
		migi = 0; over = N - 1;
		while (migi + 1 < over) {
			int mid = migi + (over - migi) / 2;
			if (a[mid] <= r[i]) migi = mid; else over = mid;
		}
		printf("%d\n", migi - hidari + 1);
	}
	return 0;
}

```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	horieyui
	.type	horieyui, @function
horieyui:
.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, -24(%rbp)
	movq	%rsi, -32(%rbp)
	movq	-24(%rbp), %rax
	movl	(%rax), %eax
	movl	%eax, -8(%rbp)
	movq	-32(%rbp), %rax
	movl	(%rax), %eax
	movl	%eax, -4(%rbp)
	movl	-8(%rbp), %eax
	cmpl	-4(%rbp), %eax
	jl	.L2
	movl	-8(%rbp), %eax
	cmpl	-4(%rbp), %eax
	setg	%al
	movzbl	%al, %eax
	jmp	.L4
.L2:
	movl	$-1, %eax
.L4:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	horieyui, .-horieyui
	.globl	N
	.bss
	.align 4
	.type	N, @object
	.size	N, 4
N:
	.zero	4
	.globl	Q
	.align 4
	.type	Q, @object
	.size	Q, 4
Q:
	.zero	4
	.globl	a
	.align 32
	.type	a, @object
	.size	a, 458056
a:
	.zero	458056
	.globl	l
	.align 32
	.type	l, @object
	.size	l, 458056
l:
	.zero	458056
	.globl	r
	.align 32
	.type	r, @object
	.size	r, 458056
r:
	.zero	458056
	.section	.rodata
.LC0:
	.string	"%d%d"
.LC1:
	.string	"%d"
.LC2:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	leaq	Q(%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
	cmpl	$2, %eax
	je	.L6
	movl	$1, %eax
	jmp	.L7
.L6:
	movl	$0, -28(%rbp)
	jmp	.L8
.L10:
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	cmpl	$1, %eax
	je	.L9
	movl	$1, %eax
	jmp	.L7
.L9:
	addl	$1, -28(%rbp)
.L8:
	movl	N(%rip), %eax
	cmpl	%eax, -28(%rbp)
	jl	.L10
	movl	$0, -28(%rbp)
	jmp	.L11
.L13:
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	r(%rip), %rax
	addq	%rax, %rdx
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	l(%rip), %rax
	addq	%rcx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	cmpl	$2, %eax
	je	.L12
	movl	$1, %eax
	jmp	.L7
.L12:
	addl	$1, -28(%rbp)
.L11:
	movl	Q(%rip), %eax
	cmpl	%eax, -28(%rbp)
	jl	.L13
	movl	N(%rip), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	$-1, (%rdx,%rax)
	movl	N(%rip), %eax
	addl	$1, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	$1111111111, (%rdx,%rax)
	movl	N(%rip), %eax
	addl	$2, %eax
	movl	%eax, N(%rip)
	movl	N(%rip), %eax
	cltq
	leaq	horieyui(%rip), %rdx
	movq	%rdx, %rcx
	movl	$4, %edx
	movq	%rax, %rsi
	leaq	a(%rip), %rax
	movq	%rax, %rdi
	call	qsort@PLT
	movl	$0, -28(%rbp)
	jmp	.L14
.L21:
	movl	$0, -24(%rbp)
	movl	N(%rip), %eax
	subl	$1, %eax
	movl	%eax, -20(%rbp)
	jmp	.L15
.L17:
	movl	-20(%rbp), %eax
	subl	-24(%rbp), %eax
	movl	%eax, %edx
	shrl	$31, %edx
	addl	%edx, %eax
	sarl	%eax
	movl	%eax, %edx
	movl	-24(%rbp), %eax
	addl	%edx, %eax
	movl	%eax, -4(%rbp)
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	l(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	a(%rip), %rax
	movl	(%rcx,%rax), %eax
	cmpl	%eax, %edx
	jg	.L16
	movl	-4(%rbp), %eax
	movl	%eax, -20(%rbp)
	jmp	.L15
.L16:
	movl	-4(%rbp), %eax
	movl	%eax, -24(%rbp)
.L15:
	movl	-24(%rbp), %eax
	addl	$1, %eax
	cmpl	%eax, -20(%rbp)
	jg	.L17
	movl	$0, -16(%rbp)
	movl	N(%rip), %eax
	subl	$1, %eax
	movl	%eax, -12(%rbp)
	jmp	.L18
.L20:
	movl	-12(%rbp), %eax
	subl	-16(%rbp), %eax
	movl	%eax, %edx
	shrl	$31, %edx
	addl	%edx, %eax
	sarl	%eax
	movl	%eax, %edx
	movl	-16(%rbp), %eax
	addl	%edx, %eax
	movl	%eax, -8(%rbp)
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	r(%rip), %rax
	movl	(%rcx,%rax), %eax
	cmpl	%eax, %edx
	jg	.L19
	movl	-8(%rbp), %eax
	movl	%eax, -16(%rbp)
	jmp	.L18
.L19:
	movl	-8(%rbp), %eax
	movl	%eax, -12(%rbp)
.L18:
	movl	-16(%rbp), %eax
	addl	$1, %eax
	cmpl	%eax, -12(%rbp)
	jg	.L20
	movl	-16(%rbp), %eax
	subl	-20(%rbp), %eax
	addl	$1, %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	addl	$1, -28(%rbp)
.L14:
	movl	Q(%rip), %eax
	cmpl	%eax, -28(%rbp)
	jl	.L21
	movl	$0, %eax
.L7:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.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	horieyui
	.type	horieyui, @function
horieyui:
.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	horieyui, .-horieyui
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d%d"
.LC1:
	.string	"%d"
.LC3:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB40:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	xorl	%eax, %eax
	leaq	Q(%rip), %rdx
	leaq	N(%rip), %rsi
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	leaq	.LC0(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	movq	%r12, %rdi
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	call	__isoc99_scanf@PLT
	cmpl	$2, %eax
	jne	.L11
	xorl	%ebp, %ebp
	cmpl	$0, N(%rip)
	leaq	a(%rip), %rbx
	leaq	.LC1(%rip), %r13
	jg	.L12
.L13:
	xorl	%ebx, %ebx
	cmpl	$0, Q(%rip)
	leaq	l(%rip), %rbp
	leaq	r(%rip), %r13
	jg	.L16
	jmp	.L10
	.p2align 4,,10
	.p2align 3
.L33:
	addq	$1, %rbx
	addq	$4, %rbp
	cmpl	%ebx, Q(%rip)
	jle	.L10
.L16:
	xorl	%eax, %eax
	leaq	0(%r13,%rbx,4), %rdx
	movq	%rbp, %rsi
	movq	%r12, %rdi
	call	__isoc99_scanf@PLT
	cmpl	$2, %eax
	je	.L33
	.p2align 4,,10
	.p2align 3
.L11:
	movl	$1, %eax
.L5:
	popq	%rbx
	.cfi_remember_state
	.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
	.p2align 4,,10
	.p2align 3
.L34:
	.cfi_restore_state
	addl	$1, %ebp
	addq	$4, %rbx
	cmpl	%ebp, N(%rip)
	jle	.L13
.L12:
	xorl	%eax, %eax
	movq	%rbx, %rsi
	movq	%r13, %rdi
	call	__isoc99_scanf@PLT
	cmpl	$1, %eax
	je	.L34
	jmp	.L11
.L10:
	movslq	N(%rip), %rdx
	movq	.LC2(%rip), %rcx
	xorl	%r14d, %r14d
	leaq	a(%rip), %rbp
	movq	%rbp, %rdi
	leaq	r(%rip), %r13
	leaq	l(%rip), %r12
	movq	%rcx, 0(%rbp,%rdx,4)
	movq	%rdx, %rax
	leaq	horieyui(%rip), %rcx
	movl	$4, %edx
	addl	$2, %eax
	leaq	.LC3(%rip), %rbx
	movslq	%eax, %rsi
	movl	%eax, N(%rip)
	call	qsort@PLT
	cmpl	$0, Q(%rip)
	jle	.L15
	.p2align 4,,10
	.p2align 3
.L23:
	movl	N(%rip), %eax
	xorl	%edi, %edi
	leal	-1(%rax), %esi
	movl	%esi, %ecx
.L17:
	leal	1(%rdi), %r8d
	jmp	.L18
	.p2align 4,,10
	.p2align 3
.L19:
	movl	%ecx, %edx
	subl	%edi, %edx
	movl	%edx, %eax
	shrl	$31, %eax
	addl	%edx, %eax
	sarl	%eax
	addl	%edi, %eax
	movslq	%eax, %rdx
	movl	0(%rbp,%rdx,4), %edx
	cmpl	%edx, (%r12)
	jg	.L35
	movl	%eax, %ecx
.L18:
	cmpl	%r8d, %ecx
	jg	.L19
	xorl	%edx, %edx
	movl	$1, %r8d
	jmp	.L21
	.p2align 4,,10
	.p2align 3
.L22:
	movl	%esi, %edi
	movl	0(%r13), %r9d
	subl	%edx, %edi
	movl	%edi, %eax
	shrl	$31, %eax
	addl	%edi, %eax
	sarl	%eax
	addl	%edx, %eax
	movslq	%eax, %rdi
	cmpl	%r9d, 0(%rbp,%rdi,4)
	jg	.L36
	movl	%eax, %edx
	leal	1(%rax), %r8d
.L21:
	cmpl	%r8d, %esi
	jg	.L22
	subl	%ecx, %edx
	xorl	%eax, %eax
	movq	%rbx, %rsi
	movl	$1, %edi
	addl	$1, %edx
	addl	$1, %r14d
	addq	$4, %r13
	addq	$4, %r12
	call	__printf_chk@PLT
	cmpl	%r14d, Q(%rip)
	jg	.L23
.L15:
	xorl	%eax, %eax
	jmp	.L5
	.p2align 4,,10
	.p2align 3
.L35:
	movl	%eax, %edi
	jmp	.L17
	.p2align 4,,10
	.p2align 3
.L36:
	movl	%eax, %esi
	jmp	.L21
	.cfi_endproc
.LFE40:
	.size	main, .-main
	.globl	r
	.bss
	.align 32
	.type	r, @object
	.size	r, 458056
r:
	.zero	458056
	.globl	l
	.align 32
	.type	l, @object
	.size	l, 458056
l:
	.zero	458056
	.globl	a
	.align 32
	.type	a, @object
	.size	a, 458056
a:
	.zero	458056
	.globl	Q
	.align 4
	.type	Q, @object
	.size	Q, 4
Q:
	.zero	4
	.globl	N
	.align 4
	.type	N, @object
	.size	N, 4
N:
	.zero	4
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC2:
	.long	-1
	.long	1111111111
	.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	horieyui
	.type	horieyui, @function
horieyui:
.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	horieyui, .-horieyui
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d%d"
.LC1:
	.string	"%d"
.LC3:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB40:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	xorl	%eax, %eax
	leaq	Q(%rip), %rdx
	leaq	N(%rip), %rsi
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	leaq	.LC0(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	movq	%r12, %rdi
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	call	__isoc99_scanf@PLT
	cmpl	$2, %eax
	jne	.L11
	xorl	%ebp, %ebp
	cmpl	$0, N(%rip)
	leaq	a(%rip), %rbx
	leaq	.LC1(%rip), %r13
	jg	.L12
.L13:
	xorl	%ebx, %ebx
	cmpl	$0, Q(%rip)
	leaq	l(%rip), %rbp
	leaq	r(%rip), %r13
	jg	.L16
	jmp	.L10
	.p2align 4,,10
	.p2align 3
.L33:
	addq	$1, %rbx
	addq	$4, %rbp
	cmpl	%ebx, Q(%rip)
	jle	.L10
.L16:
	xorl	%eax, %eax
	leaq	0(%r13,%rbx,4), %rdx
	movq	%rbp, %rsi
	movq	%r12, %rdi
	call	__isoc99_scanf@PLT
	cmpl	$2, %eax
	je	.L33
	.p2align 4,,10
	.p2align 3
.L11:
	movl	$1, %eax
.L5:
	popq	%rbx
	.cfi_remember_state
	.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
	.p2align 4,,10
	.p2align 3
.L34:
	.cfi_restore_state
	addl	$1, %ebp
	addq	$4, %rbx
	cmpl	%ebp, N(%rip)
	jle	.L13
.L12:
	xorl	%eax, %eax
	movq	%rbx, %rsi
	movq	%r13, %rdi
	call	__isoc99_scanf@PLT
	cmpl	$1, %eax
	je	.L34
	jmp	.L11
.L10:
	movslq	N(%rip), %rdx
	movq	.LC2(%rip), %rcx
	xorl	%r14d, %r14d
	leaq	a(%rip), %rbp
	movq	%rbp, %rdi
	leaq	r(%rip), %r13
	leaq	l(%rip), %r12
	movq	%rcx, 0(%rbp,%rdx,4)
	movq	%rdx, %rax
	leaq	horieyui(%rip), %rcx
	movl	$4, %edx
	addl	$2, %eax
	leaq	.LC3(%rip), %rbx
	movslq	%eax, %rsi
	movl	%eax, N(%rip)
	call	qsort@PLT
	cmpl	$0, Q(%rip)
	jle	.L15
	.p2align 4,,10
	.p2align 3
.L23:
	movl	N(%rip), %eax
	xorl	%edi, %edi
	leal	-1(%rax), %esi
	movl	%esi, %ecx
.L17:
	leal	1(%rdi), %r8d
	jmp	.L18
	.p2align 4,,10
	.p2align 3
.L19:
	movl	%ecx, %edx
	subl	%edi, %edx
	movl	%edx, %eax
	shrl	$31, %eax
	addl	%edx, %eax
	sarl	%eax
	addl	%edi, %eax
	movslq	%eax, %rdx
	movl	0(%rbp,%rdx,4), %edx
	cmpl	%edx, (%r12)
	jg	.L35
	movl	%eax, %ecx
.L18:
	cmpl	%r8d, %ecx
	jg	.L19
	xorl	%edx, %edx
	movl	$1, %r8d
	jmp	.L21
	.p2align 4,,10
	.p2align 3
.L22:
	movl	%esi, %edi
	movl	0(%r13), %r9d
	subl	%edx, %edi
	movl	%edi, %eax
	shrl	$31, %eax
	addl	%edi, %eax
	sarl	%eax
	addl	%edx, %eax
	movslq	%eax, %rdi
	cmpl	%r9d, 0(%rbp,%rdi,4)
	jg	.L36
	movl	%eax, %edx
	leal	1(%rax), %r8d
.L21:
	cmpl	%r8d, %esi
	jg	.L22
	subl	%ecx, %edx
	xorl	%eax, %eax
	movq	%rbx, %rsi
	movl	$1, %edi
	addl	$1, %edx
	addl	$1, %r14d
	addq	$4, %r13
	addq	$4, %r12
	call	__printf_chk@PLT
	cmpl	%r14d, Q(%rip)
	jg	.L23
.L15:
	xorl	%eax, %eax
	jmp	.L5
	.p2align 4,,10
	.p2align 3
.L35:
	movl	%eax, %edi
	jmp	.L17
	.p2align 4,,10
	.p2align 3
.L36:
	movl	%eax, %esi
	jmp	.L21
	.cfi_endproc
.LFE40:
	.size	main, .-main
	.globl	r
	.bss
	.align 32
	.type	r, @object
	.size	r, 458056
r:
	.zero	458056
	.globl	l
	.align 32
	.type	l, @object
	.size	l, 458056
l:
	.zero	458056
	.globl	a
	.align 32
	.type	a, @object
	.size	a, 458056
a:
	.zero	458056
	.globl	Q
	.align 4
	.type	Q, @object
	.size	Q, 4
Q:
	.zero	4
	.globl	N
	.align 4
	.type	N, @object
	.size	N, 4
N:
	.zero	4
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC2:
	.long	-1
	.long	1111111111
	.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>

int horieyui(const void* x, const void* y) {
	int a = *(const int*)x, b = *(const int*)y;
	return a < b ? -1 : a > b;
}

int N, Q;
int a[114514];
int l[114514], r[114514];

int main(void) {
	int i;
	if (scanf("%d%d", &N, &Q) != 2) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%d", &a[i]) != 1) return 1;
	}
	for (i = 0; i < Q; i++) {
		if (scanf("%d%d", &l[i], &r[i]) != 2) return 1;
	}
	a[N] = -1;
	a[N + 1] = 1111111111;
	N += 2;
	qsort(a, N, sizeof(*a), horieyui);
	for (i = 0; i < Q; i++) {
		int under, hidari, migi, over;
		under = 0; hidari = N - 1;
		while (under + 1 < hidari) {
			int mid = under + (hidari - under) / 2;
			if (l[i] <= a[mid]) hidari = mid; else under = mid;
		}
		migi = 0; over = N - 1;
		while (migi + 1 < over) {
			int mid = migi + (over - migi) / 2;
			if (a[mid] <= r[i]) migi = mid; else over = mid;
		}
		printf("%d\n", migi - hidari + 1);
	}
	return 0;
}


6 3
8 6 15 1 2 1
2 8
1 7
3 5
 6 3
8 6 15 1 1 1
2 8
1 7
3 5
 6 3
8 6 12 3 1 1
2 7
1 7
3 4
 6 3
4 6 12 3 1 1
2 7
1 7
3 4
 6 3
4 6 1 3 1 1
2 7
1 7
3 4
 6 3
4 6 1 0 1 1
2 7
1 7
3 4
 6 3
4 6 1 0 2 1
2 7
1 7
3 4
 6 1
3 11 1 0 2 1
2 7
1 7
3 4
 6 1
3 11 1 0 2 2
2 7
1 7
3 4
 6 1
3 11 -1 0 0 1
2 5
1 7
2 4

3
4
0
 2
4
0
 2
4
1
 3
5
2
 3
6
2
 2
5
1
 3
5
1
 2
 3
 1

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>

int horieyui(const void* x, const void* y) {
	int a = *(const int*)x, b = *(const int*)y;
	return a < b ? -1 : a > b;
}

int N, Q;
int a[114514];
int l[114514], r[114514];

int main(void) {
	int i;
	if (scanf("%d%d", &N, &Q) != 2) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%d", &a[i]) != 1) return 1;
	}
	for (i = 0; i < Q; i++) {
		if (scanf("%d%d", &l[i], &r[i]) != 2) return 1;
	}
	a[N] = -1;
	a[N + 1] = 1111111111;
	N += 2;
	qsort(a, N, sizeof(*a), horieyui);
	for (i = 0; i < Q; i++) {
		int under, hidari, migi, over;
		under = 0; hidari = N - 1;
		while (under + 1 < hidari) {
			int mid = under + (hidari - under) / 2;
			if (l[i] <= a[mid]) hidari = mid; else under = mid;
		}
		migi = 0; over = N - 1;
		while (migi + 1 < over) {
			int mid = migi + (over - migi) / 2;
			if (a[mid] <= r[i]) migi = mid; else over = mid;
		}
		printf("%d\n", migi - hidari + 1);
	}
	return 0;
}

```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	horieyui
	.type	horieyui, @function
horieyui:
.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, -24(%rbp)
	movq	%rsi, -32(%rbp)
	movq	-24(%rbp), %rax
	movl	(%rax), %eax
	movl	%eax, -8(%rbp)
	movq	-32(%rbp), %rax
	movl	(%rax), %eax
	movl	%eax, -4(%rbp)
	movl	-8(%rbp), %eax
	cmpl	-4(%rbp), %eax
	jl	.L2
	movl	-8(%rbp), %eax
	cmpl	-4(%rbp), %eax
	setg	%al
	movzbl	%al, %eax
	jmp	.L4
.L2:
	movl	$-1, %eax
.L4:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	horieyui, .-horieyui
	.globl	N
	.bss
	.align 4
	.type	N, @object
	.size	N, 4
N:
	.zero	4
	.globl	Q
	.align 4
	.type	Q, @object
	.size	Q, 4
Q:
	.zero	4
	.globl	a
	.align 32
	.type	a, @object
	.size	a, 458056
a:
	.zero	458056
	.globl	l
	.align 32
	.type	l, @object
	.size	l, 458056
l:
	.zero	458056
	.globl	r
	.align 32
	.type	r, @object
	.size	r, 458056
r:
	.zero	458056
	.section	.rodata
.LC0:
	.string	"%d%d"
.LC1:
	.string	"%d"
.LC2:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	leaq	Q(%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
	cmpl	$2, %eax
	je	.L6
	movl	$1, %eax
	jmp	.L7
.L6:
	movl	$0, -28(%rbp)
	jmp	.L8
.L10:
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	cmpl	$1, %eax
	je	.L9
	movl	$1, %eax
	jmp	.L7
.L9:
	addl	$1, -28(%rbp)
.L8:
	movl	N(%rip), %eax
	cmpl	%eax, -28(%rbp)
	jl	.L10
	movl	$0, -28(%rbp)
	jmp	.L11
.L13:
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	r(%rip), %rax
	addq	%rax, %rdx
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	l(%rip), %rax
	addq	%rcx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	cmpl	$2, %eax
	je	.L12
	movl	$1, %eax
	jmp	.L7
.L12:
	addl	$1, -28(%rbp)
.L11:
	movl	Q(%rip), %eax
	cmpl	%eax, -28(%rbp)
	jl	.L13
	movl	N(%rip), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	$-1, (%rdx,%rax)
	movl	N(%rip), %eax
	addl	$1, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	$1111111111, (%rdx,%rax)
	movl	N(%rip), %eax
	addl	$2, %eax
	movl	%eax, N(%rip)
	movl	N(%rip), %eax
	cltq
	leaq	horieyui(%rip), %rdx
	movq	%rdx, %rcx
	movl	$4, %edx
	movq	%rax, %rsi
	leaq	a(%rip), %rax
	movq	%rax, %rdi
	call	qsort@PLT
	movl	$0, -28(%rbp)
	jmp	.L14
.L21:
	movl	$0, -24(%rbp)
	movl	N(%rip), %eax
	subl	$1, %eax
	movl	%eax, -20(%rbp)
	jmp	.L15
.L17:
	movl	-20(%rbp), %eax
	subl	-24(%rbp), %eax
	movl	%eax, %edx
	shrl	$31, %edx
	addl	%edx, %eax
	sarl	%eax
	movl	%eax, %edx
	movl	-24(%rbp), %eax
	addl	%edx, %eax
	movl	%eax, -4(%rbp)
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	l(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	a(%rip), %rax
	movl	(%rcx,%rax), %eax
	cmpl	%eax, %edx
	jg	.L16
	movl	-4(%rbp), %eax
	movl	%eax, -20(%rbp)
	jmp	.L15
.L16:
	movl	-4(%rbp), %eax
	movl	%eax, -24(%rbp)
.L15:
	movl	-24(%rbp), %eax
	addl	$1, %eax
	cmpl	%eax, -20(%rbp)
	jg	.L17
	movl	$0, -16(%rbp)
	movl	N(%rip), %eax
	subl	$1, %eax
	movl	%eax, -12(%rbp)
	jmp	.L18
.L20:
	movl	-12(%rbp), %eax
	subl	-16(%rbp), %eax
	movl	%eax, %edx
	shrl	$31, %edx
	addl	%edx, %eax
	sarl	%eax
	movl	%eax, %edx
	movl	-16(%rbp), %eax
	addl	%edx, %eax
	movl	%eax, -8(%rbp)
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	r(%rip), %rax
	movl	(%rcx,%rax), %eax
	cmpl	%eax, %edx
	jg	.L19
	movl	-8(%rbp), %eax
	movl	%eax, -16(%rbp)
	jmp	.L18
.L19:
	movl	-8(%rbp), %eax
	movl	%eax, -12(%rbp)
.L18:
	movl	-16(%rbp), %eax
	addl	$1, %eax
	cmpl	%eax, -12(%rbp)
	jg	.L20
	movl	-16(%rbp), %eax
	subl	-20(%rbp), %eax
	addl	$1, %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	addl	$1, -28(%rbp)
.L14:
	movl	Q(%rip), %eax
	cmpl	%eax, -28(%rbp)
	jl	.L21
	movl	$0, %eax
.L7:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.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	horieyui
	.type	horieyui, @function
horieyui:
.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, -24(%rbp)
	movq	%rsi, -32(%rbp)
	movq	-24(%rbp), %rax
	movl	(%rax), %eax
	movl	%eax, -8(%rbp)
	movq	-32(%rbp), %rax
	movl	(%rax), %eax
	movl	%eax, -4(%rbp)
	movl	-8(%rbp), %eax
	cmpl	-4(%rbp), %eax
	jl	.L2
	movl	-8(%rbp), %eax
	cmpl	-4(%rbp), %eax
	setg	%al
	movzbl	%al, %eax
	jmp	.L4
.L2:
	movl	$-1, %eax
.L4:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	horieyui, .-horieyui
	.globl	N
	.bss
	.align 4
	.type	N, @object
	.size	N, 4
N:
	.zero	4
	.globl	Q
	.align 4
	.type	Q, @object
	.size	Q, 4
Q:
	.zero	4
	.globl	a
	.align 32
	.type	a, @object
	.size	a, 458056
a:
	.zero	458056
	.globl	l
	.align 32
	.type	l, @object
	.size	l, 458056
l:
	.zero	458056
	.globl	r
	.align 32
	.type	r, @object
	.size	r, 458056
r:
	.zero	458056
	.section	.rodata
.LC0:
	.string	"%d%d"
.LC1:
	.string	"%d"
.LC2:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	leaq	Q(%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
	cmpl	$2, %eax
	je	.L6
	movl	$1, %eax
	jmp	.L7
.L6:
	movl	$0, -28(%rbp)
	jmp	.L8
.L10:
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	cmpl	$1, %eax
	je	.L9
	movl	$1, %eax
	jmp	.L7
.L9:
	addl	$1, -28(%rbp)
.L8:
	movl	N(%rip), %eax
	cmpl	%eax, -28(%rbp)
	jl	.L10
	movl	$0, -28(%rbp)
	jmp	.L11
.L13:
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	r(%rip), %rax
	addq	%rax, %rdx
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	l(%rip), %rax
	addq	%rcx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	cmpl	$2, %eax
	je	.L12
	movl	$1, %eax
	jmp	.L7
.L12:
	addl	$1, -28(%rbp)
.L11:
	movl	Q(%rip), %eax
	cmpl	%eax, -28(%rbp)
	jl	.L13
	movl	N(%rip), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	$-1, (%rdx,%rax)
	movl	N(%rip), %eax
	addl	$1, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	$1111111111, (%rdx,%rax)
	movl	N(%rip), %eax
	addl	$2, %eax
	movl	%eax, N(%rip)
	movl	N(%rip), %eax
	cltq
	leaq	horieyui(%rip), %rdx
	movq	%rdx, %rcx
	movl	$4, %edx
	movq	%rax, %rsi
	leaq	a(%rip), %rax
	movq	%rax, %rdi
	call	qsort@PLT
	movl	$0, -28(%rbp)
	jmp	.L14
.L21:
	movl	$0, -24(%rbp)
	movl	N(%rip), %eax
	subl	$1, %eax
	movl	%eax, -20(%rbp)
	jmp	.L15
.L17:
	movl	-20(%rbp), %eax
	subl	-24(%rbp), %eax
	movl	%eax, %edx
	shrl	$31, %edx
	addl	%edx, %eax
	sarl	%eax
	movl	%eax, %edx
	movl	-24(%rbp), %eax
	addl	%edx, %eax
	movl	%eax, -4(%rbp)
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	l(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	a(%rip), %rax
	movl	(%rcx,%rax), %eax
	cmpl	%eax, %edx
	jg	.L16
	movl	-4(%rbp), %eax
	movl	%eax, -20(%rbp)
	jmp	.L15
.L16:
	movl	-4(%rbp), %eax
	movl	%eax, -24(%rbp)
.L15:
	movl	-24(%rbp), %eax
	addl	$1, %eax
	cmpl	%eax, -20(%rbp)
	jg	.L17
	movl	$0, -16(%rbp)
	movl	N(%rip), %eax
	subl	$1, %eax
	movl	%eax, -12(%rbp)
	jmp	.L18
.L20:
	movl	-12(%rbp), %eax
	subl	-16(%rbp), %eax
	movl	%eax, %edx
	shrl	$31, %edx
	addl	%edx, %eax
	sarl	%eax
	movl	%eax, %edx
	movl	-16(%rbp), %eax
	addl	%edx, %eax
	movl	%eax, -8(%rbp)
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	r(%rip), %rax
	movl	(%rcx,%rax), %eax
	cmpl	%eax, %edx
	jg	.L19
	movl	-8(%rbp), %eax
	movl	%eax, -16(%rbp)
	jmp	.L18
.L19:
	movl	-8(%rbp), %eax
	movl	%eax, -12(%rbp)
.L18:
	movl	-16(%rbp), %eax
	addl	$1, %eax
	cmpl	%eax, -12(%rbp)
	jg	.L20
	movl	-16(%rbp), %eax
	subl	-20(%rbp), %eax
	addl	$1, %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	addl	$1, -28(%rbp)
.L14:
	movl	Q(%rip), %eax
	cmpl	%eax, -28(%rbp)
	jl	.L21
	movl	$0, %eax
.L7:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.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:
