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

```c
// AOJ 0539: Pizza
// 2017.9.1 bal4u@uu
// 2018.1.2

#include <stdio.h>
#include <stdlib.h>

#define getchar_unlocked()  getchar()

int N;
int d[100002];
int k[10002];

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

int in()
{
	int n, c;

	while ((c = getchar_unlocked()) < '0');
	n = 0;
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int bsrch(int l, int x)
{
	int m, r = N;
    while (l < r) {
        m = (l + r) >> 1;
        if (d[m] < x) l = m + 1; else r = m;
    }
	return l;
}

int main()
{
	int D, M, i, j, t, ans;

	while (D = in()) {
		N = in();
		M = in();

		d[0] = 0; for (i = 1; i < N; i++) d[i] = in();
		qsort(d, N, sizeof(int), cmp);
		d[N] = D;

		for (i = 0; i < M; i++) k[i] = in();
		qsort(k, M, sizeof(int), cmp);
		k[M] = -1;

		ans = 0, j = 0;
		i = 0; while (!k[i]) i++; 
		while (i < M) {
			if (d[j] < k[i]) j = bsrch(j, k[i]);
			if (k[i] != d[j]) {
				t = k[i]-d[j-1];
				if (d[j]-k[i] < t) t= d[j]-k[i];
				ans += t;
			}
			i++;
		}
		printf("%d\n", ans);
	}
	return 0;
}

```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	N
	.bss
	.align 4
	.type	N, @object
	.size	N, 4
N:
	.zero	4
	.globl	d
	.align 32
	.type	d, @object
	.size	d, 400008
d:
	.zero	400008
	.globl	k
	.align 32
	.type	k, @object
	.size	k, 40008
k:
	.zero	40008
	.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
	.globl	in
	.type	in, @function
in:
.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
	nop
.L4:
	call	getchar@PLT
	movl	%eax, -4(%rbp)
	cmpl	$47, -4(%rbp)
	jle	.L4
	movl	$0, -8(%rbp)
.L5:
	movl	-8(%rbp), %eax
	leal	0(,%rax,8), %edx
	movl	-8(%rbp), %eax
	addl	%eax, %eax
	addl	%eax, %edx
	movl	-4(%rbp), %eax
	andl	$15, %eax
	addl	%edx, %eax
	movl	%eax, -8(%rbp)
	call	getchar@PLT
	movl	%eax, -4(%rbp)
	cmpl	$47, -4(%rbp)
	jg	.L5
	movl	-8(%rbp), %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	in, .-in
	.globl	bsrch
	.type	bsrch, @function
bsrch:
.LFB8:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -20(%rbp)
	movl	%esi, -24(%rbp)
	movl	N(%rip), %eax
	movl	%eax, -8(%rbp)
	jmp	.L8
.L10:
	movl	-20(%rbp), %edx
	movl	-8(%rbp), %eax
	addl	%edx, %eax
	sarl	%eax
	movl	%eax, -4(%rbp)
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -24(%rbp)
	jle	.L9
	movl	-4(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -20(%rbp)
	jmp	.L8
.L9:
	movl	-4(%rbp), %eax
	movl	%eax, -8(%rbp)
.L8:
	movl	-20(%rbp), %eax
	cmpl	-8(%rbp), %eax
	jl	.L10
	movl	-20(%rbp), %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.size	bsrch, .-bsrch
	.section	.rodata
.LC0:
	.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
	subq	$32, %rsp
	jmp	.L13
.L25:
	movl	$0, %eax
	call	in
	movl	%eax, N(%rip)
	movl	$0, %eax
	call	in
	movl	%eax, -4(%rbp)
	movl	$0, d(%rip)
	movl	$1, -24(%rbp)
	jmp	.L14
.L15:
	movl	$0, %eax
	call	in
	movl	-24(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	d(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	addl	$1, -24(%rbp)
.L14:
	movl	N(%rip), %eax
	cmpl	%eax, -24(%rbp)
	jl	.L15
	movl	N(%rip), %eax
	cltq
	leaq	cmp(%rip), %rdx
	movq	%rdx, %rcx
	movl	$4, %edx
	movq	%rax, %rsi
	leaq	d(%rip), %rax
	movq	%rax, %rdi
	call	qsort@PLT
	movl	N(%rip), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	d(%rip), %rdx
	movl	-8(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	movl	$0, -24(%rbp)
	jmp	.L16
.L17:
	movl	$0, %eax
	call	in
	movl	-24(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	k(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	addl	$1, -24(%rbp)
.L16:
	movl	-24(%rbp), %eax
	cmpl	-4(%rbp), %eax
	jl	.L17
	movl	-4(%rbp), %eax
	cltq
	leaq	cmp(%rip), %rdx
	movq	%rdx, %rcx
	movl	$4, %edx
	movq	%rax, %rsi
	leaq	k(%rip), %rax
	movq	%rax, %rdi
	call	qsort@PLT
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	k(%rip), %rax
	movl	$-1, (%rdx,%rax)
	movl	$0, -12(%rbp)
	movl	$0, -20(%rbp)
	movl	$0, -24(%rbp)
	jmp	.L18
.L19:
	addl	$1, -24(%rbp)
.L18:
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	k(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	je	.L19
	jmp	.L20
.L24:
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	k(%rip), %rax
	movl	(%rcx,%rax), %eax
	cmpl	%eax, %edx
	jge	.L21
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	k(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-20(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	bsrch
	movl	%eax, -20(%rbp)
.L21:
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	k(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	d(%rip), %rax
	movl	(%rcx,%rax), %eax
	cmpl	%eax, %edx
	je	.L22
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	k(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-20(%rbp), %edx
	subl	$1, %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	d(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	subl	%edx, %eax
	movl	%eax, -16(%rbp)
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-24(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	k(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	subl	%edx, %eax
	cmpl	%eax, -16(%rbp)
	jle	.L23
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-24(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	k(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	subl	%edx, %eax
	movl	%eax, -16(%rbp)
.L23:
	movl	-16(%rbp), %eax
	addl	%eax, -12(%rbp)
.L22:
	addl	$1, -24(%rbp)
.L20:
	movl	-24(%rbp), %eax
	cmpl	-4(%rbp), %eax
	jl	.L24
	movl	-12(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L13:
	movl	$0, %eax
	call	in
	movl	%eax, -8(%rbp)
	cmpl	$0, -8(%rbp)
	jne	.L25
	movl	$0, %eax
	leave
	.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	cmp
	.type	cmp, @function
cmp:
.LFB39:
	.cfi_startproc
	endbr64
	movl	(%rdi), %eax
	subl	(%rsi), %eax
	ret
	.cfi_endproc
.LFE39:
	.size	cmp, .-cmp
	.p2align 4
	.globl	in
	.type	in, @function
in:
.LFB40:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	.p2align 4,,10
	.p2align 3
.L4:
	movq	stdin(%rip), %rdi
	call	getc@PLT
	cmpl	$47, %eax
	jle	.L4
	xorl	%r12d, %r12d
	.p2align 4,,10
	.p2align 3
.L5:
	movq	stdin(%rip), %rdi
	andl	$15, %eax
	leal	(%r12,%r12,4), %edx
	leal	(%rax,%rdx,2), %r12d
	call	getc@PLT
	cmpl	$47, %eax
	jg	.L5
	movl	%r12d, %eax
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE40:
	.size	in, .-in
	.p2align 4
	.globl	bsrch
	.type	bsrch, @function
bsrch:
.LFB41:
	.cfi_startproc
	endbr64
	movl	N(%rip), %ecx
	movl	%edi, %eax
	leaq	d(%rip), %r8
	jmp	.L11
	.p2align 4,,10
	.p2align 3
.L12:
	leal	(%rcx,%rax), %edx
	sarl	%edx
	movslq	%edx, %rdi
	cmpl	%esi, (%r8,%rdi,4)
	jl	.L14
	movl	%edx, %ecx
.L11:
	cmpl	%eax, %ecx
	jg	.L12
	ret
	.p2align 4,,10
	.p2align 3
.L14:
	leal	1(%rdx), %eax
	jmp	.L11
	.cfi_endproc
.LFE41:
	.size	bsrch, .-bsrch
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB42:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	leaq	d(%rip), %rbx
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
	.p2align 4,,10
	.p2align 3
.L39:
	movq	stdin(%rip), %rdi
	call	getc@PLT
	cmpl	$47, %eax
	jle	.L39
	xorl	%r12d, %r12d
	.p2align 4,,10
	.p2align 3
.L40:
	movq	stdin(%rip), %rdi
	andl	$15, %eax
	leal	(%r12,%r12,4), %edx
	leal	(%rax,%rdx,2), %r12d
	call	getc@PLT
	cmpl	$47, %eax
	jg	.L40
	testl	%r12d, %r12d
	je	.L64
	.p2align 4,,10
	.p2align 3
.L17:
	movq	stdin(%rip), %rdi
	call	getc@PLT
	cmpl	$47, %eax
	jle	.L17
	xorl	%ebp, %ebp
	.p2align 4,,10
	.p2align 3
.L18:
	movq	stdin(%rip), %rdi
	andl	$15, %eax
	leal	0(%rbp,%rbp,4), %edx
	leal	(%rax,%rdx,2), %ebp
	call	getc@PLT
	cmpl	$47, %eax
	jg	.L18
	movl	%ebp, N(%rip)
	.p2align 4,,10
	.p2align 3
.L19:
	movq	stdin(%rip), %rdi
	call	getc@PLT
	cmpl	$47, %eax
	jle	.L19
	xorl	%ebp, %ebp
	.p2align 4,,10
	.p2align 3
.L20:
	movq	stdin(%rip), %rdi
	andl	$15, %eax
	leal	0(%rbp,%rbp,4), %edx
	leal	(%rax,%rdx,2), %ebp
	call	getc@PLT
	cmpl	$47, %eax
	jg	.L20
	movl	$0, d(%rip)
	movl	N(%rip), %eax
	cmpl	$1, %eax
	jle	.L21
	movl	$1, %r13d
	.p2align 4,,10
	.p2align 3
.L22:
	movq	stdin(%rip), %rdi
	call	getc@PLT
	cmpl	$47, %eax
	jle	.L22
	xorl	%r14d, %r14d
	.p2align 4,,10
	.p2align 3
.L23:
	movq	stdin(%rip), %rdi
	andl	$15, %eax
	leal	(%r14,%r14,4), %edx
	leal	(%rax,%rdx,2), %r14d
	call	getc@PLT
	cmpl	$47, %eax
	jg	.L23
	movl	N(%rip), %eax
	movl	%r14d, (%rbx,%r13,4)
	addq	$1, %r13
	cmpl	%r13d, %eax
	jg	.L22
.L21:
	movslq	%eax, %rsi
	leaq	cmp(%rip), %rcx
	movl	$4, %edx
	movq	%rbx, %rdi
	call	qsort@PLT
	movslq	N(%rip), %rax
	movl	%r12d, (%rbx,%rax,4)
	movslq	%ebp, %rax
	movq	%rax, 8(%rsp)
	testl	%ebp, %ebp
	jle	.L25
	leaq	k(%rip), %r13
	leal	-1(%rbp), %eax
	leaq	4(%r13), %rdx
	movq	%r13, %r12
	leaq	(%rdx,%rax,4), %r14
	.p2align 4,,10
	.p2align 3
.L26:
	movq	stdin(%rip), %rdi
	call	getc@PLT
	cmpl	$47, %eax
	jle	.L26
	xorl	%r15d, %r15d
	.p2align 4,,10
	.p2align 3
.L27:
	movq	stdin(%rip), %rdi
	andl	$15, %eax
	leal	(%r15,%r15,4), %edx
	leal	(%rax,%rdx,2), %r15d
	call	getc@PLT
	cmpl	$47, %eax
	jg	.L27
	movl	%r15d, (%r12)
	addq	$4, %r12
	cmpq	%r12, %r14
	jne	.L26
	movq	8(%rsp), %r15
	movl	$4, %edx
	leaq	cmp(%rip), %rcx
	movq	%r13, %rdi
	movq	%r15, %rsi
	call	qsort@PLT
	xorl	%r8d, %r8d
	movl	$-1, 0(%r13,%r15,4)
	movl	k(%rip), %edx
	testl	%edx, %edx
	jne	.L31
.L41:
	movl	$1, %eax
	leaq	-4+k(%rip), %rdx
	.p2align 4,,10
	.p2align 3
.L30:
	movslq	%eax, %r8
	addq	$1, %rax
	movl	(%rdx,%rax,4), %ecx
	testl	%ecx, %ecx
	je	.L30
	cmpl	%ebp, %r8d
	jge	.L42
.L31:
	movl	N(%rip), %r9d
	movl	(%rbx), %edx
	xorl	%r10d, %r10d
	xorl	%ecx, %ecx
	jmp	.L38
	.p2align 4,,10
	.p2align 3
.L34:
	cmpl	%edx, %edi
	je	.L37
	leal	-1(%rcx), %eax
	movl	%edi, %esi
	cltq
	subl	(%rbx,%rax,4), %esi
	movl	%esi, %eax
	movl	%edx, %esi
	subl	%edi, %esi
	cmpl	%esi, %eax
	cmovg	%esi, %eax
	addl	%eax, %r10d
.L37:
	addq	$1, %r8
	cmpl	%r8d, %ebp
	jle	.L32
.L38:
	movl	0(%r13,%r8,4), %edi
	cmpl	%edx, %edi
	jle	.L34
	movl	%r9d, %edx
	jmp	.L35
	.p2align 4,,10
	.p2align 3
.L36:
	leal	(%rdx,%rcx), %eax
	sarl	%eax
	movslq	%eax, %rsi
	cmpl	(%rbx,%rsi,4), %edi
	jg	.L65
	movl	%eax, %edx
.L35:
	cmpl	%ecx, %edx
	jg	.L36
	movslq	%ecx, %rax
	movl	(%rbx,%rax,4), %edx
	jmp	.L34
	.p2align 4,,10
	.p2align 3
.L65:
	leal	1(%rax), %ecx
	jmp	.L35
.L25:
	movslq	%ebp, %r15
	leaq	k(%rip), %r13
	movl	$4, %edx
	leaq	cmp(%rip), %rcx
	movq	%r15, %rsi
	movq	%r13, %rdi
	call	qsort@PLT
	movl	$-1, 0(%r13,%r15,4)
	movl	k(%rip), %eax
	testl	%eax, %eax
	je	.L41
.L42:
	xorl	%r10d, %r10d
	.p2align 4,,10
	.p2align 3
.L32:
	movl	%r10d, %edx
	leaq	.LC0(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L39
.L64:
	addq	$24, %rsp
	.cfi_def_cfa_offset 56
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE42:
	.size	main, .-main
	.globl	k
	.bss
	.align 32
	.type	k, @object
	.size	k, 40008
k:
	.zero	40008
	.globl	d
	.align 32
	.type	d, @object
	.size	d, 400008
d:
	.zero	400008
	.globl	N
	.align 4
	.type	N, @object
	.size	N, 4
N:
	.zero	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	cmp
	.type	cmp, @function
cmp:
.LFB39:
	.cfi_startproc
	endbr64
	movl	(%rdi), %eax
	subl	(%rsi), %eax
	ret
	.cfi_endproc
.LFE39:
	.size	cmp, .-cmp
	.p2align 4
	.globl	in
	.type	in, @function
in:
.LFB40:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	.p2align 4,,10
	.p2align 3
.L4:
	movq	stdin(%rip), %rdi
	call	getc@PLT
	cmpl	$47, %eax
	jle	.L4
	xorl	%r12d, %r12d
	.p2align 4,,10
	.p2align 3
.L5:
	movq	stdin(%rip), %rdi
	andl	$15, %eax
	leal	(%r12,%r12,4), %edx
	leal	(%rax,%rdx,2), %r12d
	call	getc@PLT
	cmpl	$47, %eax
	jg	.L5
	movl	%r12d, %eax
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE40:
	.size	in, .-in
	.p2align 4
	.globl	bsrch
	.type	bsrch, @function
bsrch:
.LFB41:
	.cfi_startproc
	endbr64
	movl	N(%rip), %ecx
	movl	%edi, %eax
	leaq	d(%rip), %r8
	jmp	.L11
	.p2align 4,,10
	.p2align 3
.L12:
	leal	(%rcx,%rax), %edx
	sarl	%edx
	movslq	%edx, %rdi
	cmpl	%esi, (%r8,%rdi,4)
	jl	.L14
	movl	%edx, %ecx
.L11:
	cmpl	%eax, %ecx
	jg	.L12
	ret
	.p2align 4,,10
	.p2align 3
.L14:
	leal	1(%rdx), %eax
	jmp	.L11
	.cfi_endproc
.LFE41:
	.size	bsrch, .-bsrch
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB42:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	leaq	d(%rip), %rbx
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
	.p2align 4,,10
	.p2align 3
.L39:
	movq	stdin(%rip), %rdi
	call	getc@PLT
	cmpl	$47, %eax
	jle	.L39
	xorl	%r12d, %r12d
	.p2align 4,,10
	.p2align 3
.L40:
	movq	stdin(%rip), %rdi
	andl	$15, %eax
	leal	(%r12,%r12,4), %edx
	leal	(%rax,%rdx,2), %r12d
	call	getc@PLT
	cmpl	$47, %eax
	jg	.L40
	testl	%r12d, %r12d
	je	.L64
	.p2align 4,,10
	.p2align 3
.L17:
	movq	stdin(%rip), %rdi
	call	getc@PLT
	cmpl	$47, %eax
	jle	.L17
	xorl	%ebp, %ebp
	.p2align 4,,10
	.p2align 3
.L18:
	movq	stdin(%rip), %rdi
	andl	$15, %eax
	leal	0(%rbp,%rbp,4), %edx
	leal	(%rax,%rdx,2), %ebp
	call	getc@PLT
	cmpl	$47, %eax
	jg	.L18
	movl	%ebp, N(%rip)
	.p2align 4,,10
	.p2align 3
.L19:
	movq	stdin(%rip), %rdi
	call	getc@PLT
	cmpl	$47, %eax
	jle	.L19
	xorl	%ebp, %ebp
	.p2align 4,,10
	.p2align 3
.L20:
	movq	stdin(%rip), %rdi
	andl	$15, %eax
	leal	0(%rbp,%rbp,4), %edx
	leal	(%rax,%rdx,2), %ebp
	call	getc@PLT
	cmpl	$47, %eax
	jg	.L20
	movl	$0, d(%rip)
	movl	N(%rip), %eax
	cmpl	$1, %eax
	jle	.L21
	movl	$1, %r13d
	.p2align 4,,10
	.p2align 3
.L22:
	movq	stdin(%rip), %rdi
	call	getc@PLT
	cmpl	$47, %eax
	jle	.L22
	xorl	%r14d, %r14d
	.p2align 4,,10
	.p2align 3
.L23:
	movq	stdin(%rip), %rdi
	andl	$15, %eax
	leal	(%r14,%r14,4), %edx
	leal	(%rax,%rdx,2), %r14d
	call	getc@PLT
	cmpl	$47, %eax
	jg	.L23
	movl	N(%rip), %eax
	movl	%r14d, (%rbx,%r13,4)
	addq	$1, %r13
	cmpl	%r13d, %eax
	jg	.L22
.L21:
	movslq	%eax, %rsi
	leaq	cmp(%rip), %rcx
	movl	$4, %edx
	movq	%rbx, %rdi
	call	qsort@PLT
	movslq	N(%rip), %rax
	movl	%r12d, (%rbx,%rax,4)
	movslq	%ebp, %rax
	movq	%rax, 8(%rsp)
	testl	%ebp, %ebp
	jle	.L25
	leaq	k(%rip), %r13
	leal	-1(%rbp), %eax
	leaq	4(%r13), %rdx
	movq	%r13, %r12
	leaq	(%rdx,%rax,4), %r14
	.p2align 4,,10
	.p2align 3
.L26:
	movq	stdin(%rip), %rdi
	call	getc@PLT
	cmpl	$47, %eax
	jle	.L26
	xorl	%r15d, %r15d
	.p2align 4,,10
	.p2align 3
.L27:
	movq	stdin(%rip), %rdi
	andl	$15, %eax
	leal	(%r15,%r15,4), %edx
	leal	(%rax,%rdx,2), %r15d
	call	getc@PLT
	cmpl	$47, %eax
	jg	.L27
	movl	%r15d, (%r12)
	addq	$4, %r12
	cmpq	%r12, %r14
	jne	.L26
	movq	8(%rsp), %r15
	movl	$4, %edx
	leaq	cmp(%rip), %rcx
	movq	%r13, %rdi
	movq	%r15, %rsi
	call	qsort@PLT
	xorl	%r8d, %r8d
	movl	$-1, 0(%r13,%r15,4)
	movl	k(%rip), %edx
	testl	%edx, %edx
	jne	.L31
.L41:
	movl	$1, %eax
	leaq	-4+k(%rip), %rdx
	.p2align 4,,10
	.p2align 3
.L30:
	movslq	%eax, %r8
	addq	$1, %rax
	movl	(%rdx,%rax,4), %ecx
	testl	%ecx, %ecx
	je	.L30
	cmpl	%ebp, %r8d
	jge	.L42
.L31:
	movl	N(%rip), %r9d
	movl	(%rbx), %edx
	xorl	%r10d, %r10d
	xorl	%ecx, %ecx
	jmp	.L38
	.p2align 4,,10
	.p2align 3
.L34:
	cmpl	%edx, %edi
	je	.L37
	leal	-1(%rcx), %eax
	movl	%edi, %esi
	cltq
	subl	(%rbx,%rax,4), %esi
	movl	%esi, %eax
	movl	%edx, %esi
	subl	%edi, %esi
	cmpl	%esi, %eax
	cmovg	%esi, %eax
	addl	%eax, %r10d
.L37:
	addq	$1, %r8
	cmpl	%r8d, %ebp
	jle	.L32
.L38:
	movl	0(%r13,%r8,4), %edi
	cmpl	%edx, %edi
	jle	.L34
	movl	%r9d, %edx
	jmp	.L35
	.p2align 4,,10
	.p2align 3
.L36:
	leal	(%rdx,%rcx), %eax
	sarl	%eax
	movslq	%eax, %rsi
	cmpl	(%rbx,%rsi,4), %edi
	jg	.L65
	movl	%eax, %edx
.L35:
	cmpl	%ecx, %edx
	jg	.L36
	movslq	%ecx, %rax
	movl	(%rbx,%rax,4), %edx
	jmp	.L34
	.p2align 4,,10
	.p2align 3
.L65:
	leal	1(%rax), %ecx
	jmp	.L35
.L25:
	movslq	%ebp, %r15
	leaq	k(%rip), %r13
	movl	$4, %edx
	leaq	cmp(%rip), %rcx
	movq	%r15, %rsi
	movq	%r13, %rdi
	call	qsort@PLT
	movl	$-1, 0(%r13,%r15,4)
	movl	k(%rip), %eax
	testl	%eax, %eax
	je	.L41
.L42:
	xorl	%r10d, %r10d
	.p2align 4,,10
	.p2align 3
.L32:
	movl	%r10d, %edx
	leaq	.LC0(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L39
.L64:
	addq	$24, %rsp
	.cfi_def_cfa_offset 56
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE42:
	.size	main, .-main
	.globl	k
	.bss
	.align 32
	.type	k, @object
	.size	k, 40008
k:
	.zero	40008
	.globl	d
	.align 32
	.type	d, @object
	.size	d, 400008
d:
	.zero	400008
	.globl	N
	.align 4
	.type	N, @object
	.size	N, 4
N:
	.zero	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:

// AOJ 0539: Pizza
// 2017.9.1 bal4u@uu
// 2018.1.2

#include <stdio.h>
#include <stdlib.h>

#define getchar_unlocked()  getchar()

int N;
int d[100002];
int k[10002];

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

int in()
{
	int n, c;

	while ((c = getchar_unlocked()) < '0');
	n = 0;
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int bsrch(int l, int x)
{
	int m, r = N;
    while (l < r) {
        m = (l + r) >> 1;
        if (d[m] < x) l = m + 1; else r = m;
    }
	return l;
}

int main()
{
	int D, M, i, j, t, ans;

	while (D = in()) {
		N = in();
		M = in();

		d[0] = 0; for (i = 1; i < N; i++) d[i] = in();
		qsort(d, N, sizeof(int), cmp);
		d[N] = D;

		for (i = 0; i < M; i++) k[i] = in();
		qsort(k, M, sizeof(int), cmp);
		k[M] = -1;

		ans = 0, j = 0;
		i = 0; while (!k[i]) i++; 
		while (i < M) {
			if (d[j] < k[i]) j = bsrch(j, k[i]);
			if (k[i] != d[j]) {
				t = k[i]-d[j-1];
				if (d[j]-k[i] < t) t= d[j]-k[i];
				ans += t;
			}
			i++;
		}
		printf("%d\n", ans);
	}
	return 0;
}


8
3
2
3
1
4
6
20
4
4
10
8
16
7
7
11
8
0
 8
3
2
3
1
4
6
20
4
4
12
8
16
7
7
4
8
0
 8
3
2
3
1
4
6
20
4
4
14
8
16
7
7
11
8
0
 8
3
2
3
1
7
7
12
4
4
12
8
16
7
7
4
8
0
 8
3
2
3
1
7
6
20
4
4
12
0
16
7
7
4
8
0
 8
3
2
3
1
7
6
12
4
4
12
8
16
4
7
4
8
0
 8
3
2
3
1
4
6
20
4
4
12
8
16
12
7
7
8
0
 8
3
2
3
0
4
6
20
4
4
14
14
23
7
7
11
8
0
 8
3
2
3
1
7
7
12
4
4
3
8
16
1
7
4
8
0
 8
3
2
3
1
4
6
20
4
4
1
8
16
11
7
4
8
0

3
3
 3
6
 3
5
 2
6
 3
18
 3
9
 3
2
 3
23
 2
3
 3
7

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

```c
// AOJ 0539: Pizza
// 2017.9.1 bal4u@uu
// 2018.1.2

#include <stdio.h>
#include <stdlib.h>

#define getchar_unlocked()  getchar()

int N;
int d[100002];
int k[10002];

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

int in()
{
	int n, c;

	while ((c = getchar_unlocked()) < '0');
	n = 0;
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int bsrch(int l, int x)
{
	int m, r = N;
    while (l < r) {
        m = (l + r) >> 1;
        if (d[m] < x) l = m + 1; else r = m;
    }
	return l;
}

int main()
{
	int D, M, i, j, t, ans;

	while (D = in()) {
		N = in();
		M = in();

		d[0] = 0; for (i = 1; i < N; i++) d[i] = in();
		qsort(d, N, sizeof(int), cmp);
		d[N] = D;

		for (i = 0; i < M; i++) k[i] = in();
		qsort(k, M, sizeof(int), cmp);
		k[M] = -1;

		ans = 0, j = 0;
		i = 0; while (!k[i]) i++; 
		while (i < M) {
			if (d[j] < k[i]) j = bsrch(j, k[i]);
			if (k[i] != d[j]) {
				t = k[i]-d[j-1];
				if (d[j]-k[i] < t) t= d[j]-k[i];
				ans += t;
			}
			i++;
		}
		printf("%d\n", ans);
	}
	return 0;
}

```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	N
	.bss
	.align 4
	.type	N, @object
	.size	N, 4
N:
	.zero	4
	.globl	d
	.align 32
	.type	d, @object
	.size	d, 400008
d:
	.zero	400008
	.globl	k
	.align 32
	.type	k, @object
	.size	k, 40008
k:
	.zero	40008
	.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
	.globl	in
	.type	in, @function
in:
.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
	nop
.L4:
	call	getchar@PLT
	movl	%eax, -4(%rbp)
	cmpl	$47, -4(%rbp)
	jle	.L4
	movl	$0, -8(%rbp)
.L5:
	movl	-8(%rbp), %eax
	leal	0(,%rax,8), %edx
	movl	-8(%rbp), %eax
	addl	%eax, %eax
	addl	%eax, %edx
	movl	-4(%rbp), %eax
	andl	$15, %eax
	addl	%edx, %eax
	movl	%eax, -8(%rbp)
	call	getchar@PLT
	movl	%eax, -4(%rbp)
	cmpl	$47, -4(%rbp)
	jg	.L5
	movl	-8(%rbp), %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	in, .-in
	.globl	bsrch
	.type	bsrch, @function
bsrch:
.LFB8:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -20(%rbp)
	movl	%esi, -24(%rbp)
	movl	N(%rip), %eax
	movl	%eax, -8(%rbp)
	jmp	.L8
.L10:
	movl	-20(%rbp), %edx
	movl	-8(%rbp), %eax
	addl	%edx, %eax
	sarl	%eax
	movl	%eax, -4(%rbp)
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -24(%rbp)
	jle	.L9
	movl	-4(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -20(%rbp)
	jmp	.L8
.L9:
	movl	-4(%rbp), %eax
	movl	%eax, -8(%rbp)
.L8:
	movl	-20(%rbp), %eax
	cmpl	-8(%rbp), %eax
	jl	.L10
	movl	-20(%rbp), %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.size	bsrch, .-bsrch
	.section	.rodata
.LC0:
	.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
	subq	$32, %rsp
	jmp	.L13
.L25:
	movl	$0, %eax
	call	in
	movl	%eax, N(%rip)
	movl	$0, %eax
	call	in
	movl	%eax, -4(%rbp)
	movl	$0, d(%rip)
	movl	$1, -24(%rbp)
	jmp	.L14
.L15:
	movl	$0, %eax
	call	in
	movl	-24(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	d(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	addl	$1, -24(%rbp)
.L14:
	movl	N(%rip), %eax
	cmpl	%eax, -24(%rbp)
	jl	.L15
	movl	N(%rip), %eax
	cltq
	leaq	cmp(%rip), %rdx
	movq	%rdx, %rcx
	movl	$4, %edx
	movq	%rax, %rsi
	leaq	d(%rip), %rax
	movq	%rax, %rdi
	call	qsort@PLT
	movl	N(%rip), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	d(%rip), %rdx
	movl	-8(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	movl	$0, -24(%rbp)
	jmp	.L16
.L17:
	movl	$0, %eax
	call	in
	movl	-24(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	k(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	addl	$1, -24(%rbp)
.L16:
	movl	-24(%rbp), %eax
	cmpl	-4(%rbp), %eax
	jl	.L17
	movl	-4(%rbp), %eax
	cltq
	leaq	cmp(%rip), %rdx
	movq	%rdx, %rcx
	movl	$4, %edx
	movq	%rax, %rsi
	leaq	k(%rip), %rax
	movq	%rax, %rdi
	call	qsort@PLT
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	k(%rip), %rax
	movl	$-1, (%rdx,%rax)
	movl	$0, -12(%rbp)
	movl	$0, -20(%rbp)
	movl	$0, -24(%rbp)
	jmp	.L18
.L19:
	addl	$1, -24(%rbp)
.L18:
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	k(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	je	.L19
	jmp	.L20
.L24:
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	k(%rip), %rax
	movl	(%rcx,%rax), %eax
	cmpl	%eax, %edx
	jge	.L21
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	k(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-20(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	bsrch
	movl	%eax, -20(%rbp)
.L21:
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	k(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	d(%rip), %rax
	movl	(%rcx,%rax), %eax
	cmpl	%eax, %edx
	je	.L22
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	k(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-20(%rbp), %edx
	subl	$1, %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	d(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	subl	%edx, %eax
	movl	%eax, -16(%rbp)
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-24(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	k(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	subl	%edx, %eax
	cmpl	%eax, -16(%rbp)
	jle	.L23
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-24(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	k(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	subl	%edx, %eax
	movl	%eax, -16(%rbp)
.L23:
	movl	-16(%rbp), %eax
	addl	%eax, -12(%rbp)
.L22:
	addl	$1, -24(%rbp)
.L20:
	movl	-24(%rbp), %eax
	cmpl	-4(%rbp), %eax
	jl	.L24
	movl	-12(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L13:
	movl	$0, %eax
	call	in
	movl	%eax, -8(%rbp)
	cmpl	$0, -8(%rbp)
	jne	.L25
	movl	$0, %eax
	leave
	.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
	.globl	N
	.bss
	.align 4
	.type	N, @object
	.size	N, 4
N:
	.zero	4
	.globl	d
	.align 32
	.type	d, @object
	.size	d, 400008
d:
	.zero	400008
	.globl	k
	.align 32
	.type	k, @object
	.size	k, 40008
k:
	.zero	40008
	.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
	.globl	in
	.type	in, @function
in:
.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
	nop
.L4:
	call	getchar@PLT
	movl	%eax, -4(%rbp)
	cmpl	$47, -4(%rbp)
	jle	.L4
	movl	$0, -8(%rbp)
.L5:
	movl	-8(%rbp), %eax
	leal	0(,%rax,8), %edx
	movl	-8(%rbp), %eax
	addl	%eax, %eax
	addl	%eax, %edx
	movl	-4(%rbp), %eax
	andl	$15, %eax
	addl	%edx, %eax
	movl	%eax, -8(%rbp)
	call	getchar@PLT
	movl	%eax, -4(%rbp)
	cmpl	$47, -4(%rbp)
	jg	.L5
	movl	-8(%rbp), %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	in, .-in
	.globl	bsrch
	.type	bsrch, @function
bsrch:
.LFB8:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -20(%rbp)
	movl	%esi, -24(%rbp)
	movl	N(%rip), %eax
	movl	%eax, -8(%rbp)
	jmp	.L8
.L10:
	movl	-20(%rbp), %edx
	movl	-8(%rbp), %eax
	addl	%edx, %eax
	sarl	%eax
	movl	%eax, -4(%rbp)
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -24(%rbp)
	jle	.L9
	movl	-4(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -20(%rbp)
	jmp	.L8
.L9:
	movl	-4(%rbp), %eax
	movl	%eax, -8(%rbp)
.L8:
	movl	-20(%rbp), %eax
	cmpl	-8(%rbp), %eax
	jl	.L10
	movl	-20(%rbp), %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.size	bsrch, .-bsrch
	.section	.rodata
.LC0:
	.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
	subq	$32, %rsp
	jmp	.L13
.L25:
	movl	$0, %eax
	call	in
	movl	%eax, N(%rip)
	movl	$0, %eax
	call	in
	movl	%eax, -4(%rbp)
	movl	$0, d(%rip)
	movl	$1, -24(%rbp)
	jmp	.L14
.L15:
	movl	$0, %eax
	call	in
	movl	-24(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	d(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	addl	$1, -24(%rbp)
.L14:
	movl	N(%rip), %eax
	cmpl	%eax, -24(%rbp)
	jl	.L15
	movl	N(%rip), %eax
	cltq
	leaq	cmp(%rip), %rdx
	movq	%rdx, %rcx
	movl	$4, %edx
	movq	%rax, %rsi
	leaq	d(%rip), %rax
	movq	%rax, %rdi
	call	qsort@PLT
	movl	N(%rip), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	d(%rip), %rdx
	movl	-8(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	movl	$0, -24(%rbp)
	jmp	.L16
.L17:
	movl	$0, %eax
	call	in
	movl	-24(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	k(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	addl	$1, -24(%rbp)
.L16:
	movl	-24(%rbp), %eax
	cmpl	-4(%rbp), %eax
	jl	.L17
	movl	-4(%rbp), %eax
	cltq
	leaq	cmp(%rip), %rdx
	movq	%rdx, %rcx
	movl	$4, %edx
	movq	%rax, %rsi
	leaq	k(%rip), %rax
	movq	%rax, %rdi
	call	qsort@PLT
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	k(%rip), %rax
	movl	$-1, (%rdx,%rax)
	movl	$0, -12(%rbp)
	movl	$0, -20(%rbp)
	movl	$0, -24(%rbp)
	jmp	.L18
.L19:
	addl	$1, -24(%rbp)
.L18:
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	k(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	je	.L19
	jmp	.L20
.L24:
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	k(%rip), %rax
	movl	(%rcx,%rax), %eax
	cmpl	%eax, %edx
	jge	.L21
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	k(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-20(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	bsrch
	movl	%eax, -20(%rbp)
.L21:
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	k(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	d(%rip), %rax
	movl	(%rcx,%rax), %eax
	cmpl	%eax, %edx
	je	.L22
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	k(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-20(%rbp), %edx
	subl	$1, %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	d(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	subl	%edx, %eax
	movl	%eax, -16(%rbp)
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-24(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	k(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	subl	%edx, %eax
	cmpl	%eax, -16(%rbp)
	jle	.L23
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-24(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	k(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	subl	%edx, %eax
	movl	%eax, -16(%rbp)
.L23:
	movl	-16(%rbp), %eax
	addl	%eax, -12(%rbp)
.L22:
	addl	$1, -24(%rbp)
.L20:
	movl	-24(%rbp), %eax
	cmpl	-4(%rbp), %eax
	jl	.L24
	movl	-12(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L13:
	movl	$0, %eax
	call	in
	movl	%eax, -8(%rbp)
	cmpl	$0, -8(%rbp)
	jne	.L25
	movl	$0, %eax
	leave
	.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:
