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

```c
#define M 300001
a[M],i,j;main(n,q,x){
	for(scanf("%d%d",&n,&q);i<n;i++)scanf("%d",&x),a[x]=x;
	for(i=1;i<M;i++)if(!a[i])a[i]=a[i-1];
	for(i=0;i<q;printf("%d\n",n),i++)for(n=0,scanf("%d",&x),j=x;j<=M;j+=x)if(n<a[j-1]%x)n=a[j-1]%x;
	exit(0);
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	a
	.bss
	.align 32
	.type	a, @object
	.size	a, 1200004
a:
	.zero	1200004
	.globl	i
	.align 4
	.type	i, @object
	.size	i, 4
i:
	.zero	4
	.globl	j
	.align 4
	.type	j, @object
	.size	j, 4
j:
	.zero	4
	.section	.rodata
.LC0:
	.string	"%d%d"
.LC1:
	.string	"%d"
.LC2:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.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	%edi, -4(%rbp)
	movl	%esi, -8(%rbp)
	movl	%edx, -12(%rbp)
	leaq	-8(%rbp), %rdx
	leaq	-4(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	scanf@PLT
	jmp	.L2
.L3:
	leaq	-12(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	scanf@PLT
	movl	-12(%rbp), %edx
	movl	-12(%rbp), %eax
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	a(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movl	i(%rip), %eax
	addl	$1, %eax
	movl	%eax, i(%rip)
.L2:
	movl	i(%rip), %edx
	movl	-4(%rbp), %eax
	cmpl	%eax, %edx
	jl	.L3
	movl	$1, i(%rip)
	jmp	.L4
.L6:
	movl	i(%rip), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	jne	.L5
	movl	i(%rip), %eax
	subl	$1, %eax
	movl	i(%rip), %edx
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	a(%rip), %rax
	movl	(%rcx,%rax), %eax
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	a(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
.L5:
	movl	i(%rip), %eax
	addl	$1, %eax
	movl	%eax, i(%rip)
.L4:
	movl	i(%rip), %eax
	cmpl	$300000, %eax
	jle	.L6
	movl	$0, i(%rip)
	jmp	.L7
.L11:
	movl	$0, -4(%rbp)
	leaq	-12(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	scanf@PLT
	movl	-12(%rbp), %eax
	movl	%eax, j(%rip)
	jmp	.L8
.L10:
	movl	j(%rip), %eax
	subl	$1, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-12(%rbp), %ecx
	cltd
	idivl	%ecx
	movl	-4(%rbp), %eax
	cmpl	%eax, %edx
	jle	.L9
	movl	j(%rip), %eax
	subl	$1, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-12(%rbp), %ecx
	cltd
	idivl	%ecx
	movl	%edx, %eax
	movl	%eax, -4(%rbp)
.L9:
	movl	j(%rip), %edx
	movl	-12(%rbp), %eax
	addl	%edx, %eax
	movl	%eax, j(%rip)
.L8:
	movl	j(%rip), %eax
	cmpl	$300001, %eax
	jle	.L10
	movl	-4(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	i(%rip), %eax
	addl	$1, %eax
	movl	%eax, i(%rip)
.L7:
	movl	i(%rip), %edx
	movl	-8(%rbp), %eax
	cmpl	%eax, %edx
	jl	.L11
	movl	$0, %edi
	call	exit@PLT
	.cfi_endproc
.LFE0:
	.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
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d%d"
.LC1:
	.string	"%d"
.LC2:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	xorl	%eax, %eax
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	leaq	a(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	leaq	.LC1(%rip), %rbx
	subq	$16, %rsp
	.cfi_def_cfa_offset 64
	movl	%edi, 12(%rsp)
	leaq	.LC0(%rip), %rdi
	leaq	4(%rsp), %rbp
	movl	%esi, 8(%rsp)
	leaq	12(%rsp), %rsi
	movl	%edx, 4(%rsp)
	leaq	8(%rsp), %rdx
	call	scanf@PLT
	movl	12(%rsp), %eax
	cmpl	%eax, i(%rip)
	jge	.L4
	.p2align 4,,10
	.p2align 3
.L2:
	movq	%rbp, %rsi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	call	scanf@PLT
	movl	i(%rip), %eax
	movslq	4(%rsp), %rdx
	addl	$1, %eax
	movl	%edx, (%r12,%rdx,4)
	movl	%eax, i(%rip)
	cmpl	12(%rsp), %eax
	jl	.L2
.L4:
	leaq	4+a(%rip), %rax
	leaq	1200000(%rax), %rdx
	.p2align 4,,10
	.p2align 3
.L3:
	movl	(%rax), %ecx
	testl	%ecx, %ecx
	jne	.L5
	movl	-4(%rax), %ecx
	movl	%ecx, (%rax)
.L5:
	addq	$4, %rax
	cmpq	%rax, %rdx
	jne	.L3
	movl	8(%rsp), %eax
	leaq	4(%rsp), %rbp
	movl	$0, i(%rip)
	leaq	.LC1(%rip), %rbx
	leaq	.LC2(%rip), %r13
	movl	$300002, %r14d
	leaq	-4+a(%rip), %r12
	testl	%eax, %eax
	jle	.L16
	.p2align 4,,10
	.p2align 3
.L6:
	movq	%rbp, %rsi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	movl	$0, 12(%rsp)
	call	scanf@PLT
	movl	4(%rsp), %ecx
	movl	12(%rsp), %r9d
	movl	%ecx, j(%rip)
	cmpl	$300001, %ecx
	jg	.L8
	movl	%r9d, %edi
	xorl	%r8d, %r8d
	cmpl	$1, %ecx
	jne	.L36
.L9:
	testl	%edi, %edi
	jns	.L13
	cmpl	$300001, %ecx
	je	.L15
	addl	$2, %ecx
	cmpl	$300002, %ecx
	je	.L15
	movl	$1, %r8d
	xorl	%edi, %edi
.L13:
	addl	$1, %ecx
	cmpl	$300002, %ecx
	jne	.L9
	movl	$300002, %eax
	movl	%eax, j(%rip)
	testb	%r8b, %r8b
	jne	.L37
	.p2align 4,,10
	.p2align 3
.L8:
	movl	%r9d, %esi
	movq	%r13, %rdi
	xorl	%eax, %eax
	call	printf@PLT
	movl	i(%rip), %eax
	addl	$1, %eax
	movl	%eax, i(%rip)
	cmpl	8(%rsp), %eax
	jl	.L6
.L16:
	xorl	%edi, %edi
	call	exit@PLT
	.p2align 4,,10
	.p2align 3
.L15:
	movl	%r14d, j(%rip)
	xorl	%r9d, %r9d
.L17:
	movl	%r9d, 12(%rsp)
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L36:
	movslq	%ecx, %r10
	movq	%r10, %rsi
	.p2align 4,,10
	.p2align 3
.L11:
	movl	(%r12,%rsi,4), %eax
	cltd
	idivl	%ecx
	cmpl	%edx, %edi
	jge	.L10
	movl	%edx, %edi
	movl	$1, %r8d
.L10:
	leal	(%rcx,%rsi), %eax
	addq	%r10, %rsi
	cmpl	$300001, %esi
	jle	.L11
	movl	%eax, j(%rip)
	testb	%r8b, %r8b
	je	.L8
.L37:
	movl	%edi, %r9d
	jmp	.L17
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.globl	j
	.bss
	.align 4
	.type	j, @object
	.size	j, 4
j:
	.zero	4
	.globl	i
	.align 4
	.type	i, @object
	.size	i, 4
i:
	.zero	4
	.globl	a
	.align 32
	.type	a, @object
	.size	a, 1200004
a:
	.zero	1200004
	.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
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d%d"
.LC1:
	.string	"%d"
.LC2:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	xorl	%eax, %eax
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	leaq	a(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	leaq	.LC1(%rip), %rbx
	subq	$16, %rsp
	.cfi_def_cfa_offset 64
	movl	%edi, 12(%rsp)
	leaq	.LC0(%rip), %rdi
	leaq	4(%rsp), %rbp
	movl	%esi, 8(%rsp)
	leaq	12(%rsp), %rsi
	movl	%edx, 4(%rsp)
	leaq	8(%rsp), %rdx
	call	scanf@PLT
	movl	12(%rsp), %eax
	cmpl	%eax, i(%rip)
	jge	.L4
	.p2align 4,,10
	.p2align 3
.L2:
	movq	%rbp, %rsi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	call	scanf@PLT
	movl	i(%rip), %eax
	movslq	4(%rsp), %rdx
	addl	$1, %eax
	movl	%edx, (%r12,%rdx,4)
	movl	%eax, i(%rip)
	cmpl	12(%rsp), %eax
	jl	.L2
.L4:
	leaq	4+a(%rip), %rax
	leaq	1200000(%rax), %rdx
	.p2align 4,,10
	.p2align 3
.L3:
	movl	(%rax), %ecx
	testl	%ecx, %ecx
	jne	.L5
	movl	-4(%rax), %ecx
	movl	%ecx, (%rax)
.L5:
	addq	$4, %rax
	cmpq	%rax, %rdx
	jne	.L3
	movl	8(%rsp), %eax
	leaq	4(%rsp), %rbp
	movl	$0, i(%rip)
	leaq	.LC1(%rip), %rbx
	leaq	.LC2(%rip), %r13
	movl	$300002, %r14d
	leaq	-4+a(%rip), %r12
	testl	%eax, %eax
	jle	.L16
	.p2align 4,,10
	.p2align 3
.L6:
	movq	%rbp, %rsi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	movl	$0, 12(%rsp)
	call	scanf@PLT
	movl	4(%rsp), %ecx
	movl	12(%rsp), %r9d
	movl	%ecx, j(%rip)
	cmpl	$300001, %ecx
	jg	.L8
	movl	%r9d, %edi
	xorl	%r8d, %r8d
	cmpl	$1, %ecx
	jne	.L36
.L9:
	testl	%edi, %edi
	jns	.L13
	cmpl	$300001, %ecx
	je	.L15
	addl	$2, %ecx
	cmpl	$300002, %ecx
	je	.L15
	movl	$1, %r8d
	xorl	%edi, %edi
.L13:
	addl	$1, %ecx
	cmpl	$300002, %ecx
	jne	.L9
	movl	$300002, %eax
	movl	%eax, j(%rip)
	testb	%r8b, %r8b
	jne	.L37
	.p2align 4,,10
	.p2align 3
.L8:
	movl	%r9d, %esi
	movq	%r13, %rdi
	xorl	%eax, %eax
	call	printf@PLT
	movl	i(%rip), %eax
	addl	$1, %eax
	movl	%eax, i(%rip)
	cmpl	8(%rsp), %eax
	jl	.L6
.L16:
	xorl	%edi, %edi
	call	exit@PLT
	.p2align 4,,10
	.p2align 3
.L15:
	movl	%r14d, j(%rip)
	xorl	%r9d, %r9d
.L17:
	movl	%r9d, 12(%rsp)
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L36:
	movslq	%ecx, %r10
	movq	%r10, %rsi
	.p2align 4,,10
	.p2align 3
.L11:
	movl	(%r12,%rsi,4), %eax
	cltd
	idivl	%ecx
	cmpl	%edx, %edi
	jge	.L10
	movl	%edx, %edi
	movl	$1, %r8d
.L10:
	leal	(%rcx,%rsi), %eax
	addq	%r10, %rsi
	cmpl	$300001, %esi
	jle	.L11
	movl	%eax, j(%rip)
	testb	%r8b, %r8b
	je	.L8
.L37:
	movl	%edi, %r9d
	jmp	.L17
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.globl	j
	.bss
	.align 4
	.type	j, @object
	.size	j, 4
j:
	.zero	4
	.globl	i
	.align 4
	.type	i, @object
	.size	i, 4
i:
	.zero	4
	.globl	a
	.align 32
	.type	a, @object
	.size	a, 1200004
a:
	.zero	1200004
	.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:

#define M 300001
a[M],i,j;main(n,q,x){
	for(scanf("%d%d",&n,&q);i<n;i++)scanf("%d",&x),a[x]=x;
	for(i=1;i<M;i++)if(!a[i])a[i]=a[i-1];
	for(i=0;i<q;printf("%d\n",n),i++)for(n=0,scanf("%d",&x),j=x;j<=M;j+=x)if(n<a[j-1]%x)n=a[j-1]%x;
	exit(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
 3
3
3
 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
#define M 300001
a[M],i,j;main(n,q,x){
	for(scanf("%d%d",&n,&q);i<n;i++)scanf("%d",&x),a[x]=x;
	for(i=1;i<M;i++)if(!a[i])a[i]=a[i-1];
	for(i=0;i<q;printf("%d\n",n),i++)for(n=0,scanf("%d",&x),j=x;j<=M;j+=x)if(n<a[j-1]%x)n=a[j-1]%x;
	exit(0);
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	a
	.bss
	.align 32
	.type	a, @object
	.size	a, 1200004
a:
	.zero	1200004
	.globl	i
	.align 4
	.type	i, @object
	.size	i, 4
i:
	.zero	4
	.globl	j
	.align 4
	.type	j, @object
	.size	j, 4
j:
	.zero	4
	.section	.rodata
.LC0:
	.string	"%d%d"
.LC1:
	.string	"%d"
.LC2:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.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	%edi, -4(%rbp)
	movl	%esi, -8(%rbp)
	movl	%edx, -12(%rbp)
	leaq	-8(%rbp), %rdx
	leaq	-4(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	scanf@PLT
	jmp	.L2
.L3:
	leaq	-12(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	scanf@PLT
	movl	-12(%rbp), %edx
	movl	-12(%rbp), %eax
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	a(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movl	i(%rip), %eax
	addl	$1, %eax
	movl	%eax, i(%rip)
.L2:
	movl	i(%rip), %edx
	movl	-4(%rbp), %eax
	cmpl	%eax, %edx
	jl	.L3
	movl	$1, i(%rip)
	jmp	.L4
.L6:
	movl	i(%rip), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	jne	.L5
	movl	i(%rip), %eax
	subl	$1, %eax
	movl	i(%rip), %edx
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	a(%rip), %rax
	movl	(%rcx,%rax), %eax
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	a(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
.L5:
	movl	i(%rip), %eax
	addl	$1, %eax
	movl	%eax, i(%rip)
.L4:
	movl	i(%rip), %eax
	cmpl	$300000, %eax
	jle	.L6
	movl	$0, i(%rip)
	jmp	.L7
.L11:
	movl	$0, -4(%rbp)
	leaq	-12(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	scanf@PLT
	movl	-12(%rbp), %eax
	movl	%eax, j(%rip)
	jmp	.L8
.L10:
	movl	j(%rip), %eax
	subl	$1, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-12(%rbp), %ecx
	cltd
	idivl	%ecx
	movl	-4(%rbp), %eax
	cmpl	%eax, %edx
	jle	.L9
	movl	j(%rip), %eax
	subl	$1, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-12(%rbp), %ecx
	cltd
	idivl	%ecx
	movl	%edx, %eax
	movl	%eax, -4(%rbp)
.L9:
	movl	j(%rip), %edx
	movl	-12(%rbp), %eax
	addl	%edx, %eax
	movl	%eax, j(%rip)
.L8:
	movl	j(%rip), %eax
	cmpl	$300001, %eax
	jle	.L10
	movl	-4(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	i(%rip), %eax
	addl	$1, %eax
	movl	%eax, i(%rip)
.L7:
	movl	i(%rip), %edx
	movl	-8(%rbp), %eax
	cmpl	%eax, %edx
	jl	.L11
	movl	$0, %edi
	call	exit@PLT
	.cfi_endproc
.LFE0:
	.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	a
	.bss
	.align 32
	.type	a, @object
	.size	a, 1200004
a:
	.zero	1200004
	.globl	i
	.align 4
	.type	i, @object
	.size	i, 4
i:
	.zero	4
	.globl	j
	.align 4
	.type	j, @object
	.size	j, 4
j:
	.zero	4
	.section	.rodata
.LC0:
	.string	"%d%d"
.LC1:
	.string	"%d"
.LC2:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.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	%edi, -4(%rbp)
	movl	%esi, -8(%rbp)
	movl	%edx, -12(%rbp)
	leaq	-8(%rbp), %rdx
	leaq	-4(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	scanf@PLT
	jmp	.L2
.L3:
	leaq	-12(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	scanf@PLT
	movl	-12(%rbp), %edx
	movl	-12(%rbp), %eax
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	a(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movl	i(%rip), %eax
	addl	$1, %eax
	movl	%eax, i(%rip)
.L2:
	movl	i(%rip), %edx
	movl	-4(%rbp), %eax
	cmpl	%eax, %edx
	jl	.L3
	movl	$1, i(%rip)
	jmp	.L4
.L6:
	movl	i(%rip), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	jne	.L5
	movl	i(%rip), %eax
	subl	$1, %eax
	movl	i(%rip), %edx
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	a(%rip), %rax
	movl	(%rcx,%rax), %eax
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	a(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
.L5:
	movl	i(%rip), %eax
	addl	$1, %eax
	movl	%eax, i(%rip)
.L4:
	movl	i(%rip), %eax
	cmpl	$300000, %eax
	jle	.L6
	movl	$0, i(%rip)
	jmp	.L7
.L11:
	movl	$0, -4(%rbp)
	leaq	-12(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	scanf@PLT
	movl	-12(%rbp), %eax
	movl	%eax, j(%rip)
	jmp	.L8
.L10:
	movl	j(%rip), %eax
	subl	$1, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-12(%rbp), %ecx
	cltd
	idivl	%ecx
	movl	-4(%rbp), %eax
	cmpl	%eax, %edx
	jle	.L9
	movl	j(%rip), %eax
	subl	$1, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-12(%rbp), %ecx
	cltd
	idivl	%ecx
	movl	%edx, %eax
	movl	%eax, -4(%rbp)
.L9:
	movl	j(%rip), %edx
	movl	-12(%rbp), %eax
	addl	%edx, %eax
	movl	%eax, j(%rip)
.L8:
	movl	j(%rip), %eax
	cmpl	$300001, %eax
	jle	.L10
	movl	-4(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	i(%rip), %eax
	addl	$1, %eax
	movl	%eax, i(%rip)
.L7:
	movl	i(%rip), %edx
	movl	-8(%rbp), %eax
	cmpl	%eax, %edx
	jl	.L11
	movl	$0, %edi
	call	exit@PLT
	.cfi_endproc
.LFE0:
	.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:
