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

```c
// AOJ 0270: Modular Query
// 2017.8.24 bal4u@uu
// 2019.1.19

#include <stdio.h>

char tbl[300005];

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int main()
{
	int N, Q, i, k, q, max;
	char s[13];

	N = in(), Q = in();
	tbl[0] = 1, max = 0;
	while (N--) {
		tbl[k=in()] = 1;
		if (k > max) max = k;
		tbl[k & 1] = 1, tbl[k & 3] = 1, tbl[k & 7] = 1;
	}
	sprintf(s, "%d", max);
	while (Q--) {
		q = in();
		if (q > max) puts(s);
		else {
			for (k = q-1; ; k--) {
				for (i = k; i <= max; i += q)
					if (tbl[i]) { printf("%d\n", k); goto Done; }
			}
			Done:;
		}
	}
	return 0;
}

```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	tbl
	.bss
	.align 32
	.type	tbl, @object
	.size	tbl, 300005
tbl:
	.zero	300005
	.text
	.globl	in
	.type	in, @function
in:
.LFB0:
	.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
	movl	$0, -8(%rbp)
	call	getchar_unlocked@PLT
	movl	%eax, -4(%rbp)
.L2:
	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_unlocked@PLT
	movl	%eax, -4(%rbp)
	cmpl	$47, -4(%rbp)
	jg	.L2
	movl	-8(%rbp), %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	in, .-in
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$48, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, %eax
	call	in
	movl	%eax, -48(%rbp)
	movl	$0, %eax
	call	in
	movl	%eax, -44(%rbp)
	movb	$1, tbl(%rip)
	movl	$0, -32(%rbp)
	jmp	.L5
.L7:
	movl	$0, %eax
	call	in
	movl	%eax, -36(%rbp)
	movl	-36(%rbp), %eax
	cltq
	leaq	tbl(%rip), %rdx
	movb	$1, (%rax,%rdx)
	movl	-36(%rbp), %eax
	cmpl	-32(%rbp), %eax
	jle	.L6
	movl	-36(%rbp), %eax
	movl	%eax, -32(%rbp)
.L6:
	movl	-36(%rbp), %eax
	andl	$1, %eax
	cltq
	leaq	tbl(%rip), %rdx
	movb	$1, (%rax,%rdx)
	movl	-36(%rbp), %eax
	andl	$3, %eax
	cltq
	leaq	tbl(%rip), %rdx
	movb	$1, (%rax,%rdx)
	movl	-36(%rbp), %eax
	andl	$7, %eax
	cltq
	leaq	tbl(%rip), %rdx
	movb	$1, (%rax,%rdx)
.L5:
	movl	-48(%rbp), %eax
	leal	-1(%rax), %edx
	movl	%edx, -48(%rbp)
	testl	%eax, %eax
	jne	.L7
	movl	-32(%rbp), %edx
	leaq	-21(%rbp), %rax
	leaq	.LC0(%rip), %rcx
	movq	%rcx, %rsi
	movq	%rax, %rdi
	movl	$0, %eax
	call	sprintf@PLT
	jmp	.L8
.L15:
	movl	$0, %eax
	call	in
	movl	%eax, -28(%rbp)
	movl	-28(%rbp), %eax
	cmpl	-32(%rbp), %eax
	jle	.L9
	leaq	-21(%rbp), %rax
	movq	%rax, %rdi
	call	puts@PLT
	jmp	.L8
.L9:
	movl	-28(%rbp), %eax
	subl	$1, %eax
	movl	%eax, -36(%rbp)
.L14:
	movl	-36(%rbp), %eax
	movl	%eax, -40(%rbp)
	jmp	.L10
.L13:
	movl	-40(%rbp), %eax
	cltq
	leaq	tbl(%rip), %rdx
	movzbl	(%rax,%rdx), %eax
	testb	%al, %al
	je	.L11
	movl	-36(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	nop
.L12:
	jmp	.L8
.L11:
	movl	-28(%rbp), %eax
	addl	%eax, -40(%rbp)
.L10:
	movl	-40(%rbp), %eax
	cmpl	-32(%rbp), %eax
	jle	.L13
	subl	$1, -36(%rbp)
	jmp	.L14
.L8:
	movl	-44(%rbp), %eax
	leal	-1(%rax), %edx
	movl	%edx, -44(%rbp)
	testl	%eax, %eax
	jne	.L15
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L17
	call	__stack_chk_fail@PLT
.L17:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.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	in
	.type	in, @function
in:
.LFB23:
	.cfi_startproc
	endbr64
	movq	stdin(%rip), %rdi
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movq	8(%rdi), %rax
	movq	16(%rdi), %rcx
	cmpq	%rcx, %rax
	jnb	.L11
	leaq	1(%rax), %rdx
	movq	%rdx, 8(%rdi)
	movzbl	(%rax), %eax
.L3:
	xorl	%r12d, %r12d
	jmp	.L7
	.p2align 4,,10
	.p2align 3
.L4:
	leaq	1(%rdx), %rax
	movq	%rax, 8(%rdi)
	movzbl	(%rdx), %eax
	cmpl	$47, %eax
	jle	.L1
.L5:
	movq	8(%rdi), %rdx
	movq	16(%rdi), %rcx
.L7:
	leal	(%r12,%r12,4), %esi
	andl	$15, %eax
	leal	(%rax,%rsi,2), %r12d
	cmpq	%rcx, %rdx
	jb	.L4
	call	__uflow@PLT
	cmpl	$47, %eax
	jle	.L1
	movq	stdin(%rip), %rdi
	jmp	.L5
	.p2align 4,,10
	.p2align 3
.L1:
	movl	%r12d, %eax
	popq	%r12
	.cfi_remember_state
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L11:
	.cfi_restore_state
	call	__uflow@PLT
	movq	stdin(%rip), %rdi
	movq	8(%rdi), %rdx
	movq	16(%rdi), %rcx
	jmp	.L3
	.cfi_endproc
.LFE23:
	.size	in, .-in
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB24:
	.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
	subq	$40, %rsp
	.cfi_def_cfa_offset 96
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	call	in
	movl	%eax, %r13d
	xorl	%eax, %eax
	call	in
	movb	$1, tbl(%rip)
	movl	%eax, %ebx
	testl	%r13d, %r13d
	je	.L13
	movl	%r13d, %ebp
	leaq	tbl(%rip), %r14
	xorl	%r13d, %r13d
	.p2align 4,,10
	.p2align 3
.L20:
	movq	stdin(%rip), %rdi
	movq	8(%rdi), %rax
	movq	16(%rdi), %rcx
	cmpq	%rcx, %rax
	jnb	.L48
	leaq	1(%rax), %rdx
	movq	%rdx, 8(%rdi)
	movzbl	(%rax), %eax
.L15:
	xorl	%r12d, %r12d
	jmp	.L19
	.p2align 4,,10
	.p2align 3
.L16:
	leaq	1(%rdx), %rax
	movq	%rax, 8(%rdi)
	movzbl	(%rdx), %eax
	cmpl	$47, %eax
	jle	.L18
.L17:
	movq	8(%rdi), %rdx
	movq	16(%rdi), %rcx
.L19:
	leal	(%r12,%r12,4), %esi
	andl	$15, %eax
	leal	(%rax,%rsi,2), %r12d
	cmpq	%rcx, %rdx
	jb	.L16
	call	__uflow@PLT
	cmpl	$47, %eax
	jle	.L18
	movq	stdin(%rip), %rdi
	jmp	.L17
	.p2align 4,,10
	.p2align 3
.L18:
	movslq	%r12d, %rax
	cmpl	%r12d, %r13d
	movb	$1, (%r14,%rax)
	movl	%r12d, %eax
	cmovl	%r12d, %r13d
	andl	$1, %eax
	movb	$1, (%r14,%rax)
	movl	%r12d, %eax
	andl	$7, %r12d
	andl	$3, %eax
	movb	$1, (%r14,%rax)
	movb	$1, (%r14,%r12)
	subl	$1, %ebp
	jne	.L20
.L13:
	leaq	11(%rsp), %rbp
	movl	%r13d, %r8d
	movl	$13, %edx
	xorl	%eax, %eax
	leaq	.LC0(%rip), %rcx
	movl	$1, %esi
	movq	%rbp, %rdi
	call	__sprintf_chk@PLT
	leaq	tbl(%rip), %r14
	leaq	.LC1(%rip), %r12
	testl	%ebx, %ebx
	je	.L35
	.p2align 4,,10
	.p2align 3
.L34:
	movq	stdin(%rip), %rdi
	movq	8(%rdi), %rax
	movq	16(%rdi), %rcx
	cmpq	%rcx, %rax
	jnb	.L49
	leaq	1(%rax), %rdx
	movq	%rdx, 8(%rdi)
	movzbl	(%rax), %eax
.L23:
	xorl	%r15d, %r15d
	jmp	.L27
	.p2align 4,,10
	.p2align 3
.L24:
	leaq	1(%rdx), %rax
	movq	%rax, 8(%rdi)
	movzbl	(%rdx), %eax
	cmpl	$47, %eax
	jle	.L26
.L25:
	movq	8(%rdi), %rdx
	movq	16(%rdi), %rcx
.L27:
	leal	(%r15,%r15,4), %esi
	andl	$15, %eax
	leal	(%rax,%rsi,2), %r15d
	cmpq	%rcx, %rdx
	jb	.L24
	call	__uflow@PLT
	cmpl	$47, %eax
	jle	.L26
	movq	stdin(%rip), %rdi
	jmp	.L25
	.p2align 4,,10
	.p2align 3
.L26:
	cmpl	%r15d, %r13d
	jge	.L28
	movq	%rbp, %rdi
	call	puts@PLT
.L29:
	subl	$1, %ebx
	jne	.L34
.L35:
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L50
	addq	$40, %rsp
	.cfi_remember_state
	.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
	.p2align 4,,10
	.p2align 3
.L28:
	.cfi_restore_state
	leal	-1(%r15), %edx
	movslq	%r15d, %r15
	movslq	%edx, %rcx
.L33:
	cmpl	%r13d, %edx
	jg	.L30
	movq	%rcx, %rax
	jmp	.L32
	.p2align 4,,10
	.p2align 3
.L31:
	addq	%r15, %rax
	cmpl	%eax, %r13d
	jl	.L30
.L32:
	cmpb	$0, (%r14,%rax)
	je	.L31
	movq	%r12, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L29
	.p2align 4,,10
	.p2align 3
.L30:
	subl	$1, %edx
	subq	$1, %rcx
	jmp	.L33
	.p2align 4,,10
	.p2align 3
.L48:
	call	__uflow@PLT
	movq	stdin(%rip), %rdi
	movq	8(%rdi), %rdx
	movq	16(%rdi), %rcx
	jmp	.L15
	.p2align 4,,10
	.p2align 3
.L49:
	call	__uflow@PLT
	movq	stdin(%rip), %rdi
	movq	8(%rdi), %rdx
	movq	16(%rdi), %rcx
	jmp	.L23
.L50:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE24:
	.size	main, .-main
	.globl	tbl
	.bss
	.align 32
	.type	tbl, @object
	.size	tbl, 300005
tbl:
	.zero	300005
	.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	in
	.type	in, @function
in:
.LFB23:
	.cfi_startproc
	endbr64
	movq	stdin(%rip), %rdi
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movq	8(%rdi), %rax
	movq	16(%rdi), %rcx
	cmpq	%rcx, %rax
	jnb	.L11
	leaq	1(%rax), %rdx
	movq	%rdx, 8(%rdi)
	movzbl	(%rax), %eax
.L3:
	xorl	%r12d, %r12d
	jmp	.L7
	.p2align 4,,10
	.p2align 3
.L4:
	leaq	1(%rdx), %rax
	movq	%rax, 8(%rdi)
	movzbl	(%rdx), %eax
	cmpl	$47, %eax
	jle	.L1
.L5:
	movq	8(%rdi), %rdx
	movq	16(%rdi), %rcx
.L7:
	leal	(%r12,%r12,4), %esi
	andl	$15, %eax
	leal	(%rax,%rsi,2), %r12d
	cmpq	%rcx, %rdx
	jb	.L4
	call	__uflow@PLT
	cmpl	$47, %eax
	jle	.L1
	movq	stdin(%rip), %rdi
	jmp	.L5
	.p2align 4,,10
	.p2align 3
.L1:
	movl	%r12d, %eax
	popq	%r12
	.cfi_remember_state
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L11:
	.cfi_restore_state
	call	__uflow@PLT
	movq	stdin(%rip), %rdi
	movq	8(%rdi), %rdx
	movq	16(%rdi), %rcx
	jmp	.L3
	.cfi_endproc
.LFE23:
	.size	in, .-in
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB24:
	.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
	subq	$40, %rsp
	.cfi_def_cfa_offset 96
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	call	in
	movl	%eax, %r13d
	xorl	%eax, %eax
	call	in
	movb	$1, tbl(%rip)
	movl	%eax, %ebx
	testl	%r13d, %r13d
	je	.L13
	movl	%r13d, %ebp
	leaq	tbl(%rip), %r14
	xorl	%r13d, %r13d
	.p2align 4,,10
	.p2align 3
.L20:
	movq	stdin(%rip), %rdi
	movq	8(%rdi), %rax
	movq	16(%rdi), %rcx
	cmpq	%rcx, %rax
	jnb	.L48
	leaq	1(%rax), %rdx
	movq	%rdx, 8(%rdi)
	movzbl	(%rax), %eax
.L15:
	xorl	%r12d, %r12d
	jmp	.L19
	.p2align 4,,10
	.p2align 3
.L16:
	leaq	1(%rdx), %rax
	movq	%rax, 8(%rdi)
	movzbl	(%rdx), %eax
	cmpl	$47, %eax
	jle	.L18
.L17:
	movq	8(%rdi), %rdx
	movq	16(%rdi), %rcx
.L19:
	leal	(%r12,%r12,4), %esi
	andl	$15, %eax
	leal	(%rax,%rsi,2), %r12d
	cmpq	%rcx, %rdx
	jb	.L16
	call	__uflow@PLT
	cmpl	$47, %eax
	jle	.L18
	movq	stdin(%rip), %rdi
	jmp	.L17
	.p2align 4,,10
	.p2align 3
.L18:
	movslq	%r12d, %rax
	cmpl	%r12d, %r13d
	movb	$1, (%r14,%rax)
	movl	%r12d, %eax
	cmovl	%r12d, %r13d
	andl	$1, %eax
	movb	$1, (%r14,%rax)
	movl	%r12d, %eax
	andl	$7, %r12d
	andl	$3, %eax
	movb	$1, (%r14,%rax)
	movb	$1, (%r14,%r12)
	subl	$1, %ebp
	jne	.L20
.L13:
	leaq	11(%rsp), %rbp
	movl	%r13d, %r8d
	movl	$13, %edx
	xorl	%eax, %eax
	leaq	.LC0(%rip), %rcx
	movl	$1, %esi
	movq	%rbp, %rdi
	call	__sprintf_chk@PLT
	leaq	tbl(%rip), %r14
	leaq	.LC1(%rip), %r12
	testl	%ebx, %ebx
	je	.L35
	.p2align 4,,10
	.p2align 3
.L34:
	movq	stdin(%rip), %rdi
	movq	8(%rdi), %rax
	movq	16(%rdi), %rcx
	cmpq	%rcx, %rax
	jnb	.L49
	leaq	1(%rax), %rdx
	movq	%rdx, 8(%rdi)
	movzbl	(%rax), %eax
.L23:
	xorl	%r15d, %r15d
	jmp	.L27
	.p2align 4,,10
	.p2align 3
.L24:
	leaq	1(%rdx), %rax
	movq	%rax, 8(%rdi)
	movzbl	(%rdx), %eax
	cmpl	$47, %eax
	jle	.L26
.L25:
	movq	8(%rdi), %rdx
	movq	16(%rdi), %rcx
.L27:
	leal	(%r15,%r15,4), %esi
	andl	$15, %eax
	leal	(%rax,%rsi,2), %r15d
	cmpq	%rcx, %rdx
	jb	.L24
	call	__uflow@PLT
	cmpl	$47, %eax
	jle	.L26
	movq	stdin(%rip), %rdi
	jmp	.L25
	.p2align 4,,10
	.p2align 3
.L26:
	cmpl	%r15d, %r13d
	jge	.L28
	movq	%rbp, %rdi
	call	puts@PLT
.L29:
	subl	$1, %ebx
	jne	.L34
.L35:
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L50
	addq	$40, %rsp
	.cfi_remember_state
	.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
	.p2align 4,,10
	.p2align 3
.L28:
	.cfi_restore_state
	leal	-1(%r15), %edx
	movslq	%r15d, %r15
	movslq	%edx, %rcx
.L33:
	cmpl	%r13d, %edx
	jg	.L30
	movq	%rcx, %rax
	jmp	.L32
	.p2align 4,,10
	.p2align 3
.L31:
	addq	%r15, %rax
	cmpl	%eax, %r13d
	jl	.L30
.L32:
	cmpb	$0, (%r14,%rax)
	je	.L31
	movq	%r12, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L29
	.p2align 4,,10
	.p2align 3
.L30:
	subl	$1, %edx
	subq	$1, %rcx
	jmp	.L33
	.p2align 4,,10
	.p2align 3
.L48:
	call	__uflow@PLT
	movq	stdin(%rip), %rdi
	movq	8(%rdi), %rdx
	movq	16(%rdi), %rcx
	jmp	.L15
	.p2align 4,,10
	.p2align 3
.L49:
	call	__uflow@PLT
	movq	stdin(%rip), %rdi
	movq	8(%rdi), %rdx
	movq	16(%rdi), %rcx
	jmp	.L23
.L50:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE24:
	.size	main, .-main
	.globl	tbl
	.bss
	.align 32
	.type	tbl, @object
	.size	tbl, 300005
tbl:
	.zero	300005
	.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 0270: Modular Query
// 2017.8.24 bal4u@uu
// 2019.1.19

#include <stdio.h>

char tbl[300005];

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int main()
{
	int N, Q, i, k, q, max;
	char s[13];

	N = in(), Q = in();
	tbl[0] = 1, max = 0;
	while (N--) {
		tbl[k=in()] = 1;
		if (k > max) max = k;
		tbl[k & 1] = 1, tbl[k & 3] = 1, tbl[k & 7] = 1;
	}
	sprintf(s, "%d", max);
	while (Q--) {
		q = in();
		if (q > max) puts(s);
		else {
			for (k = q-1; ; k--) {
				for (i = k; i <= max; i += q)
					if (tbl[i]) { printf("%d\n", k); goto Done; }
			}
			Done:;
		}
	}
	return 0;
}


3 3
9 3 8
6
6
5
 3 3
9 3 10
6
6
5
 3 3
9 3 8
4
6
3
 3 3
9 3 8
6
6
2
 3 2
1 3 8
4
6
3
 3 3
9 2 8
4
6
5
 3 3
12 3 8
6
6
5
 3 3
9 3 8
4
6
1
 3 3
9 3 8
12
6
2
 3 2
1 3 11
4
6
3

3
3
4
 4
4
4
 3
3
2
 3
3
1
 3
3
 2
3
4
 4
4
4
 3
3
0
 9
3
1
 3
5

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

```c
// AOJ 0270: Modular Query
// 2017.8.24 bal4u@uu
// 2019.1.19

#include <stdio.h>

char tbl[300005];

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int main()
{
	int N, Q, i, k, q, max;
	char s[13];

	N = in(), Q = in();
	tbl[0] = 1, max = 0;
	while (N--) {
		tbl[k=in()] = 1;
		if (k > max) max = k;
		tbl[k & 1] = 1, tbl[k & 3] = 1, tbl[k & 7] = 1;
	}
	sprintf(s, "%d", max);
	while (Q--) {
		q = in();
		if (q > max) puts(s);
		else {
			for (k = q-1; ; k--) {
				for (i = k; i <= max; i += q)
					if (tbl[i]) { printf("%d\n", k); goto Done; }
			}
			Done:;
		}
	}
	return 0;
}

```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	tbl
	.bss
	.align 32
	.type	tbl, @object
	.size	tbl, 300005
tbl:
	.zero	300005
	.text
	.globl	in
	.type	in, @function
in:
.LFB0:
	.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
	movl	$0, -8(%rbp)
	call	getchar_unlocked@PLT
	movl	%eax, -4(%rbp)
.L2:
	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_unlocked@PLT
	movl	%eax, -4(%rbp)
	cmpl	$47, -4(%rbp)
	jg	.L2
	movl	-8(%rbp), %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	in, .-in
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$48, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, %eax
	call	in
	movl	%eax, -48(%rbp)
	movl	$0, %eax
	call	in
	movl	%eax, -44(%rbp)
	movb	$1, tbl(%rip)
	movl	$0, -32(%rbp)
	jmp	.L5
.L7:
	movl	$0, %eax
	call	in
	movl	%eax, -36(%rbp)
	movl	-36(%rbp), %eax
	cltq
	leaq	tbl(%rip), %rdx
	movb	$1, (%rax,%rdx)
	movl	-36(%rbp), %eax
	cmpl	-32(%rbp), %eax
	jle	.L6
	movl	-36(%rbp), %eax
	movl	%eax, -32(%rbp)
.L6:
	movl	-36(%rbp), %eax
	andl	$1, %eax
	cltq
	leaq	tbl(%rip), %rdx
	movb	$1, (%rax,%rdx)
	movl	-36(%rbp), %eax
	andl	$3, %eax
	cltq
	leaq	tbl(%rip), %rdx
	movb	$1, (%rax,%rdx)
	movl	-36(%rbp), %eax
	andl	$7, %eax
	cltq
	leaq	tbl(%rip), %rdx
	movb	$1, (%rax,%rdx)
.L5:
	movl	-48(%rbp), %eax
	leal	-1(%rax), %edx
	movl	%edx, -48(%rbp)
	testl	%eax, %eax
	jne	.L7
	movl	-32(%rbp), %edx
	leaq	-21(%rbp), %rax
	leaq	.LC0(%rip), %rcx
	movq	%rcx, %rsi
	movq	%rax, %rdi
	movl	$0, %eax
	call	sprintf@PLT
	jmp	.L8
.L15:
	movl	$0, %eax
	call	in
	movl	%eax, -28(%rbp)
	movl	-28(%rbp), %eax
	cmpl	-32(%rbp), %eax
	jle	.L9
	leaq	-21(%rbp), %rax
	movq	%rax, %rdi
	call	puts@PLT
	jmp	.L8
.L9:
	movl	-28(%rbp), %eax
	subl	$1, %eax
	movl	%eax, -36(%rbp)
.L14:
	movl	-36(%rbp), %eax
	movl	%eax, -40(%rbp)
	jmp	.L10
.L13:
	movl	-40(%rbp), %eax
	cltq
	leaq	tbl(%rip), %rdx
	movzbl	(%rax,%rdx), %eax
	testb	%al, %al
	je	.L11
	movl	-36(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	nop
.L12:
	jmp	.L8
.L11:
	movl	-28(%rbp), %eax
	addl	%eax, -40(%rbp)
.L10:
	movl	-40(%rbp), %eax
	cmpl	-32(%rbp), %eax
	jle	.L13
	subl	$1, -36(%rbp)
	jmp	.L14
.L8:
	movl	-44(%rbp), %eax
	leal	-1(%rax), %edx
	movl	%edx, -44(%rbp)
	testl	%eax, %eax
	jne	.L15
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L17
	call	__stack_chk_fail@PLT
.L17:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.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	tbl
	.bss
	.align 32
	.type	tbl, @object
	.size	tbl, 300005
tbl:
	.zero	300005
	.text
	.globl	in
	.type	in, @function
in:
.LFB0:
	.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
	movl	$0, -8(%rbp)
	call	getchar_unlocked@PLT
	movl	%eax, -4(%rbp)
.L2:
	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_unlocked@PLT
	movl	%eax, -4(%rbp)
	cmpl	$47, -4(%rbp)
	jg	.L2
	movl	-8(%rbp), %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	in, .-in
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$48, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, %eax
	call	in
	movl	%eax, -48(%rbp)
	movl	$0, %eax
	call	in
	movl	%eax, -44(%rbp)
	movb	$1, tbl(%rip)
	movl	$0, -32(%rbp)
	jmp	.L5
.L7:
	movl	$0, %eax
	call	in
	movl	%eax, -36(%rbp)
	movl	-36(%rbp), %eax
	cltq
	leaq	tbl(%rip), %rdx
	movb	$1, (%rax,%rdx)
	movl	-36(%rbp), %eax
	cmpl	-32(%rbp), %eax
	jle	.L6
	movl	-36(%rbp), %eax
	movl	%eax, -32(%rbp)
.L6:
	movl	-36(%rbp), %eax
	andl	$1, %eax
	cltq
	leaq	tbl(%rip), %rdx
	movb	$1, (%rax,%rdx)
	movl	-36(%rbp), %eax
	andl	$3, %eax
	cltq
	leaq	tbl(%rip), %rdx
	movb	$1, (%rax,%rdx)
	movl	-36(%rbp), %eax
	andl	$7, %eax
	cltq
	leaq	tbl(%rip), %rdx
	movb	$1, (%rax,%rdx)
.L5:
	movl	-48(%rbp), %eax
	leal	-1(%rax), %edx
	movl	%edx, -48(%rbp)
	testl	%eax, %eax
	jne	.L7
	movl	-32(%rbp), %edx
	leaq	-21(%rbp), %rax
	leaq	.LC0(%rip), %rcx
	movq	%rcx, %rsi
	movq	%rax, %rdi
	movl	$0, %eax
	call	sprintf@PLT
	jmp	.L8
.L15:
	movl	$0, %eax
	call	in
	movl	%eax, -28(%rbp)
	movl	-28(%rbp), %eax
	cmpl	-32(%rbp), %eax
	jle	.L9
	leaq	-21(%rbp), %rax
	movq	%rax, %rdi
	call	puts@PLT
	jmp	.L8
.L9:
	movl	-28(%rbp), %eax
	subl	$1, %eax
	movl	%eax, -36(%rbp)
.L14:
	movl	-36(%rbp), %eax
	movl	%eax, -40(%rbp)
	jmp	.L10
.L13:
	movl	-40(%rbp), %eax
	cltq
	leaq	tbl(%rip), %rdx
	movzbl	(%rax,%rdx), %eax
	testb	%al, %al
	je	.L11
	movl	-36(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	nop
.L12:
	jmp	.L8
.L11:
	movl	-28(%rbp), %eax
	addl	%eax, -40(%rbp)
.L10:
	movl	-40(%rbp), %eax
	cmpl	-32(%rbp), %eax
	jle	.L13
	subl	$1, -36(%rbp)
	jmp	.L14
.L8:
	movl	-44(%rbp), %eax
	leal	-1(%rax), %edx
	movl	%edx, -44(%rbp)
	testl	%eax, %eax
	jne	.L15
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L17
	call	__stack_chk_fail@PLT
.L17:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.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:
