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

```c
typedef long long W;i,j,N,M;W a[8<<14],v,r;c(W*a,W*b){return*a-*b;}main(){for(scanf("%d%d",&N,&M);~scanf("%lld",++i+a);a[i]=(a[i]+a[i-1])%M);qsort(a+1,N,8,c);for(i=j=0;i++<N;)if(a[i]-a[j]){r=i-j;v+=r*=r-1;j=i;}r=i-j;v+=r*=r-1;printf("%lld\n",v/2);i=0;}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	i
	.bss
	.align 4
	.type	i, @object
	.size	i, 4
i:
	.zero	4
	.globl	j
	.align 4
	.type	j, @object
	.size	j, 4
j:
	.zero	4
	.globl	N
	.align 4
	.type	N, @object
	.size	N, 4
N:
	.zero	4
	.globl	M
	.align 4
	.type	M, @object
	.size	M, 4
M:
	.zero	4
	.globl	a
	.align 32
	.type	a, @object
	.size	a, 1048576
a:
	.zero	1048576
	.globl	v
	.align 8
	.type	v, @object
	.size	v, 8
v:
	.zero	8
	.globl	r
	.align 8
	.type	r, @object
	.size	r, 8
r:
	.zero	8
	.text
	.globl	c
	.type	c, @function
c:
.LFB0:
	.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
	movq	(%rax), %rax
	movl	%eax, %edx
	movq	-16(%rbp), %rax
	movq	(%rax), %rax
	movl	%eax, %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	c, .-c
	.section	.rodata
.LC0:
	.string	"%d%d"
.LC1:
	.string	"%lld"
.LC2:
	.string	"%lld\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
	leaq	M(%rip), %rax
	movq	%rax, %rdx
	leaq	N(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	scanf@PLT
	jmp	.L4
.L5:
	movl	i(%rip), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	a(%rip), %rax
	movq	(%rdx,%rax), %rcx
	movl	i(%rip), %eax
	subl	$1, %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	a(%rip), %rax
	movq	(%rdx,%rax), %rax
	addq	%rcx, %rax
	movl	M(%rip), %edx
	movslq	%edx, %rsi
	movl	i(%rip), %ecx
	cqto
	idivq	%rsi
	movq	%rdx, %rsi
	movslq	%ecx, %rax
	leaq	0(,%rax,8), %rdx
	leaq	a(%rip), %rax
	movq	%rsi, (%rdx,%rax)
.L4:
	movl	i(%rip), %eax
	addl	$1, %eax
	movl	%eax, i(%rip)
	movl	i(%rip), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	a(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	scanf@PLT
	cmpl	$-1, %eax
	jne	.L5
	movl	N(%rip), %eax
	leaq	8+a(%rip), %rdi
	leaq	c(%rip), %rdx
	movq	%rdx, %rcx
	movl	$8, %edx
	movl	%eax, %esi
	movl	$0, %eax
	call	qsort@PLT
	movl	$0, j(%rip)
	movl	j(%rip), %eax
	movl	%eax, i(%rip)
	jmp	.L6
.L7:
	movl	i(%rip), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	a(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movl	j(%rip), %eax
	cltq
	leaq	0(,%rax,8), %rcx
	leaq	a(%rip), %rax
	movq	(%rcx,%rax), %rax
	cmpq	%rax, %rdx
	je	.L6
	movl	i(%rip), %eax
	movl	j(%rip), %edx
	subl	%edx, %eax
	cltq
	movq	%rax, r(%rip)
	movq	r(%rip), %rax
	leaq	-1(%rax), %rdx
	movq	r(%rip), %rax
	imulq	%rdx, %rax
	movq	%rax, r(%rip)
	movq	r(%rip), %rdx
	movq	v(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, v(%rip)
	movl	i(%rip), %eax
	movl	%eax, j(%rip)
.L6:
	movl	i(%rip), %eax
	leal	1(%rax), %edx
	movl	%edx, i(%rip)
	movl	N(%rip), %edx
	cmpl	%edx, %eax
	jl	.L7
	movl	i(%rip), %eax
	movl	j(%rip), %edx
	subl	%edx, %eax
	cltq
	movq	%rax, r(%rip)
	movq	r(%rip), %rax
	leaq	-1(%rax), %rdx
	movq	r(%rip), %rax
	imulq	%rdx, %rax
	movq	%rax, r(%rip)
	movq	r(%rip), %rdx
	movq	v(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, v(%rip)
	movq	v(%rip), %rax
	movq	%rax, %rdx
	shrq	$63, %rdx
	addq	%rdx, %rax
	sarq	%rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, i(%rip)
	movl	$0, %eax
	popq	%rbp
	.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	c
	.type	c, @function
c:
.LFB0:
	.cfi_startproc
	endbr64
	movq	(%rdi), %rax
	subl	(%rsi), %eax
	ret
	.cfi_endproc
.LFE0:
	.size	c, .-c
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d%d"
.LC1:
	.string	"%lld"
.LC2:
	.string	"%lld\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	leaq	M(%rip), %rdx
	leaq	N(%rip), %rsi
	xorl	%eax, %eax
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	leaq	.LC0(%rip), %rdi
	leaq	a(%rip), %rbx
	leaq	.LC1(%rip), %rbp
	subq	$8, %rsp
	.cfi_def_cfa_offset 32
	call	scanf@PLT
	movl	i(%rip), %ecx
	jmp	.L4
	.p2align 4,,10
	.p2align 3
.L5:
	movslq	i(%rip), %rsi
	movslq	M(%rip), %rdi
	leal	-1(%rsi), %edx
	movq	(%rbx,%rsi,8), %rax
	movq	%rsi, %rcx
	movslq	%edx, %rdx
	addq	(%rbx,%rdx,8), %rax
	cqto
	idivq	%rdi
	movq	%rdx, (%rbx,%rsi,8)
.L4:
	addl	$1, %ecx
	xorl	%eax, %eax
	movq	%rbp, %rdi
	movl	%ecx, i(%rip)
	movslq	%ecx, %rcx
	leaq	(%rbx,%rcx,8), %rsi
	call	scanf@PLT
	cmpl	$-1, %eax
	jne	.L5
	movl	N(%rip), %esi
	leaq	c(%rip), %rcx
	movl	$8, %edx
	xorl	%eax, %eax
	leaq	8+a(%rip), %rdi
	call	qsort@PLT
	movq	v(%rip), %r10
	xorl	%r11d, %r11d
	xorl	%r8d, %r8d
	movl	$0, j(%rip)
	movl	N(%rip), %esi
	movq	%r10, %r9
.L6:
	leal	1(%r8), %eax
	movslq	%r8d, %rdi
	cltq
	jmp	.L7
	.p2align 4,,10
	.p2align 3
.L8:
	movq	(%rbx,%rax,8), %rdx
	addq	$1, %rax
	cmpq	(%rbx,%rdi,8), %rdx
	jne	.L13
.L7:
	leal	-1(%rax), %edx
	movl	%eax, %ecx
	cmpl	%edx, %esi
	jg	.L8
	movl	%eax, i(%rip)
	testb	%r11b, %r11b
	je	.L10
	movl	%r8d, j(%rip)
.L9:
	subl	j(%rip), %ecx
	leaq	.LC2(%rip), %rdi
	movslq	%ecx, %rcx
	leaq	-1(%rcx), %rax
	imulq	%rcx, %rax
	movq	%rax, r(%rip)
	addq	%r9, %rax
	movq	%rax, %rsi
	movq	%rax, v(%rip)
	shrq	$63, %rsi
	addq	%rax, %rsi
	xorl	%eax, %eax
	sarq	%rsi
	call	printf@PLT
	xorl	%eax, %eax
	movl	$0, i(%rip)
	addq	$8, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L13:
	.cfi_restore_state
	movl	%ecx, %eax
	movl	$1, %r11d
	subl	%r8d, %eax
	movl	%ecx, %r8d
	cltq
	leaq	-1(%rax), %rdx
	imulq	%rdx, %rax
	addq	%rax, %r9
	jmp	.L6
.L10:
	movq	%r10, %r9
	jmp	.L9
	.cfi_endproc
.LFE1:
	.size	main, .-main
	.globl	r
	.bss
	.align 8
	.type	r, @object
	.size	r, 8
r:
	.zero	8
	.globl	v
	.align 8
	.type	v, @object
	.size	v, 8
v:
	.zero	8
	.globl	a
	.align 32
	.type	a, @object
	.size	a, 1048576
a:
	.zero	1048576
	.globl	M
	.align 4
	.type	M, @object
	.size	M, 4
M:
	.zero	4
	.globl	N
	.align 4
	.type	N, @object
	.size	N, 4
N:
	.zero	4
	.globl	j
	.align 4
	.type	j, @object
	.size	j, 4
j:
	.zero	4
	.globl	i
	.align 4
	.type	i, @object
	.size	i, 4
i:
	.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	c
	.type	c, @function
c:
.LFB0:
	.cfi_startproc
	endbr64
	movq	(%rdi), %rax
	subl	(%rsi), %eax
	ret
	.cfi_endproc
.LFE0:
	.size	c, .-c
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d%d"
.LC1:
	.string	"%lld"
.LC2:
	.string	"%lld\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	leaq	M(%rip), %rdx
	leaq	N(%rip), %rsi
	xorl	%eax, %eax
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	leaq	.LC0(%rip), %rdi
	leaq	a(%rip), %rbx
	leaq	.LC1(%rip), %rbp
	subq	$8, %rsp
	.cfi_def_cfa_offset 32
	call	scanf@PLT
	movl	i(%rip), %ecx
	jmp	.L4
	.p2align 4,,10
	.p2align 3
.L5:
	movslq	i(%rip), %rsi
	movslq	M(%rip), %rdi
	leal	-1(%rsi), %edx
	movq	(%rbx,%rsi,8), %rax
	movq	%rsi, %rcx
	movslq	%edx, %rdx
	addq	(%rbx,%rdx,8), %rax
	cqto
	idivq	%rdi
	movq	%rdx, (%rbx,%rsi,8)
.L4:
	addl	$1, %ecx
	xorl	%eax, %eax
	movq	%rbp, %rdi
	movl	%ecx, i(%rip)
	movslq	%ecx, %rcx
	leaq	(%rbx,%rcx,8), %rsi
	call	scanf@PLT
	cmpl	$-1, %eax
	jne	.L5
	movl	N(%rip), %esi
	leaq	c(%rip), %rcx
	movl	$8, %edx
	xorl	%eax, %eax
	leaq	8+a(%rip), %rdi
	call	qsort@PLT
	movq	v(%rip), %r10
	xorl	%r11d, %r11d
	xorl	%r8d, %r8d
	movl	$0, j(%rip)
	movl	N(%rip), %esi
	movq	%r10, %r9
.L6:
	leal	1(%r8), %eax
	movslq	%r8d, %rdi
	cltq
	jmp	.L7
	.p2align 4,,10
	.p2align 3
.L8:
	movq	(%rbx,%rax,8), %rdx
	addq	$1, %rax
	cmpq	(%rbx,%rdi,8), %rdx
	jne	.L13
.L7:
	leal	-1(%rax), %edx
	movl	%eax, %ecx
	cmpl	%edx, %esi
	jg	.L8
	movl	%eax, i(%rip)
	testb	%r11b, %r11b
	je	.L10
	movl	%r8d, j(%rip)
.L9:
	subl	j(%rip), %ecx
	leaq	.LC2(%rip), %rdi
	movslq	%ecx, %rcx
	leaq	-1(%rcx), %rax
	imulq	%rcx, %rax
	movq	%rax, r(%rip)
	addq	%r9, %rax
	movq	%rax, %rsi
	movq	%rax, v(%rip)
	shrq	$63, %rsi
	addq	%rax, %rsi
	xorl	%eax, %eax
	sarq	%rsi
	call	printf@PLT
	xorl	%eax, %eax
	movl	$0, i(%rip)
	addq	$8, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L13:
	.cfi_restore_state
	movl	%ecx, %eax
	movl	$1, %r11d
	subl	%r8d, %eax
	movl	%ecx, %r8d
	cltq
	leaq	-1(%rax), %rdx
	imulq	%rdx, %rax
	addq	%rax, %r9
	jmp	.L6
.L10:
	movq	%r10, %r9
	jmp	.L9
	.cfi_endproc
.LFE1:
	.size	main, .-main
	.globl	r
	.bss
	.align 8
	.type	r, @object
	.size	r, 8
r:
	.zero	8
	.globl	v
	.align 8
	.type	v, @object
	.size	v, 8
v:
	.zero	8
	.globl	a
	.align 32
	.type	a, @object
	.size	a, 1048576
a:
	.zero	1048576
	.globl	M
	.align 4
	.type	M, @object
	.size	M, 4
M:
	.zero	4
	.globl	N
	.align 4
	.type	N, @object
	.size	N, 4
N:
	.zero	4
	.globl	j
	.align 4
	.type	j, @object
	.size	j, 4
j:
	.zero	4
	.globl	i
	.align 4
	.type	i, @object
	.size	i, 4
i:
	.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:

typedef long long W;i,j,N,M;W a[8<<14],v,r;c(W*a,W*b){return*a-*b;}main(){for(scanf("%d%d",&N,&M);~scanf("%lld",++i+a);a[i]=(a[i]+a[i-1])%M);qsort(a+1,N,8,c);for(i=j=0;i++<N;)if(a[i]-a[j]){r=i-j;v+=r*=r-1;j=i;}r=i-j;v+=r*=r-1;printf("%lld\n",v/2);i=0;}
10 400000000
1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000010 1000000000 1000000000
 13 17
29 7 5 7 18 51 7 13 8 55 42 9 81
 10 400000000
1000000000 1100000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000010 1000000000 1000000000
 13 17
29 7 5 3 18 51 7 13 8 55 42 9 81
 13 17
29 9 6 3 18 51 7 13 16 55 8 9 81
 13 17
29 9 6 3 34 51 7 13 16 55 8 9 81
 13 17
15 9 2 3 34 64 12 13 8 34 8 9 81
 10 400000000
1000000000 1000000010 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000
 13 17
29 11 6 3 34 51 7 13 16 55 8 9 81
 13 17
15 9 2 3 34 64 7 13 8 61 8 9 81

13
 3
 7
 4
 5
 6
 9
 16
 10
 8

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

```c
typedef long long W;i,j,N,M;W a[8<<14],v,r;c(W*a,W*b){return*a-*b;}main(){for(scanf("%d%d",&N,&M);~scanf("%lld",++i+a);a[i]=(a[i]+a[i-1])%M);qsort(a+1,N,8,c);for(i=j=0;i++<N;)if(a[i]-a[j]){r=i-j;v+=r*=r-1;j=i;}r=i-j;v+=r*=r-1;printf("%lld\n",v/2);i=0;}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	i
	.bss
	.align 4
	.type	i, @object
	.size	i, 4
i:
	.zero	4
	.globl	j
	.align 4
	.type	j, @object
	.size	j, 4
j:
	.zero	4
	.globl	N
	.align 4
	.type	N, @object
	.size	N, 4
N:
	.zero	4
	.globl	M
	.align 4
	.type	M, @object
	.size	M, 4
M:
	.zero	4
	.globl	a
	.align 32
	.type	a, @object
	.size	a, 1048576
a:
	.zero	1048576
	.globl	v
	.align 8
	.type	v, @object
	.size	v, 8
v:
	.zero	8
	.globl	r
	.align 8
	.type	r, @object
	.size	r, 8
r:
	.zero	8
	.text
	.globl	c
	.type	c, @function
c:
.LFB0:
	.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
	movq	(%rax), %rax
	movl	%eax, %edx
	movq	-16(%rbp), %rax
	movq	(%rax), %rax
	movl	%eax, %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	c, .-c
	.section	.rodata
.LC0:
	.string	"%d%d"
.LC1:
	.string	"%lld"
.LC2:
	.string	"%lld\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
	leaq	M(%rip), %rax
	movq	%rax, %rdx
	leaq	N(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	scanf@PLT
	jmp	.L4
.L5:
	movl	i(%rip), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	a(%rip), %rax
	movq	(%rdx,%rax), %rcx
	movl	i(%rip), %eax
	subl	$1, %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	a(%rip), %rax
	movq	(%rdx,%rax), %rax
	addq	%rcx, %rax
	movl	M(%rip), %edx
	movslq	%edx, %rsi
	movl	i(%rip), %ecx
	cqto
	idivq	%rsi
	movq	%rdx, %rsi
	movslq	%ecx, %rax
	leaq	0(,%rax,8), %rdx
	leaq	a(%rip), %rax
	movq	%rsi, (%rdx,%rax)
.L4:
	movl	i(%rip), %eax
	addl	$1, %eax
	movl	%eax, i(%rip)
	movl	i(%rip), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	a(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	scanf@PLT
	cmpl	$-1, %eax
	jne	.L5
	movl	N(%rip), %eax
	leaq	8+a(%rip), %rdi
	leaq	c(%rip), %rdx
	movq	%rdx, %rcx
	movl	$8, %edx
	movl	%eax, %esi
	movl	$0, %eax
	call	qsort@PLT
	movl	$0, j(%rip)
	movl	j(%rip), %eax
	movl	%eax, i(%rip)
	jmp	.L6
.L7:
	movl	i(%rip), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	a(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movl	j(%rip), %eax
	cltq
	leaq	0(,%rax,8), %rcx
	leaq	a(%rip), %rax
	movq	(%rcx,%rax), %rax
	cmpq	%rax, %rdx
	je	.L6
	movl	i(%rip), %eax
	movl	j(%rip), %edx
	subl	%edx, %eax
	cltq
	movq	%rax, r(%rip)
	movq	r(%rip), %rax
	leaq	-1(%rax), %rdx
	movq	r(%rip), %rax
	imulq	%rdx, %rax
	movq	%rax, r(%rip)
	movq	r(%rip), %rdx
	movq	v(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, v(%rip)
	movl	i(%rip), %eax
	movl	%eax, j(%rip)
.L6:
	movl	i(%rip), %eax
	leal	1(%rax), %edx
	movl	%edx, i(%rip)
	movl	N(%rip), %edx
	cmpl	%edx, %eax
	jl	.L7
	movl	i(%rip), %eax
	movl	j(%rip), %edx
	subl	%edx, %eax
	cltq
	movq	%rax, r(%rip)
	movq	r(%rip), %rax
	leaq	-1(%rax), %rdx
	movq	r(%rip), %rax
	imulq	%rdx, %rax
	movq	%rax, r(%rip)
	movq	r(%rip), %rdx
	movq	v(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, v(%rip)
	movq	v(%rip), %rax
	movq	%rax, %rdx
	shrq	$63, %rdx
	addq	%rdx, %rax
	sarq	%rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, i(%rip)
	movl	$0, %eax
	popq	%rbp
	.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	i
	.bss
	.align 4
	.type	i, @object
	.size	i, 4
i:
	.zero	4
	.globl	j
	.align 4
	.type	j, @object
	.size	j, 4
j:
	.zero	4
	.globl	N
	.align 4
	.type	N, @object
	.size	N, 4
N:
	.zero	4
	.globl	M
	.align 4
	.type	M, @object
	.size	M, 4
M:
	.zero	4
	.globl	a
	.align 32
	.type	a, @object
	.size	a, 1048576
a:
	.zero	1048576
	.globl	v
	.align 8
	.type	v, @object
	.size	v, 8
v:
	.zero	8
	.globl	r
	.align 8
	.type	r, @object
	.size	r, 8
r:
	.zero	8
	.text
	.globl	c
	.type	c, @function
c:
.LFB0:
	.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
	movq	(%rax), %rax
	movl	%eax, %edx
	movq	-16(%rbp), %rax
	movq	(%rax), %rax
	movl	%eax, %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	c, .-c
	.section	.rodata
.LC0:
	.string	"%d%d"
.LC1:
	.string	"%lld"
.LC2:
	.string	"%lld\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
	leaq	M(%rip), %rax
	movq	%rax, %rdx
	leaq	N(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	scanf@PLT
	jmp	.L4
.L5:
	movl	i(%rip), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	a(%rip), %rax
	movq	(%rdx,%rax), %rcx
	movl	i(%rip), %eax
	subl	$1, %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	a(%rip), %rax
	movq	(%rdx,%rax), %rax
	addq	%rcx, %rax
	movl	M(%rip), %edx
	movslq	%edx, %rsi
	movl	i(%rip), %ecx
	cqto
	idivq	%rsi
	movq	%rdx, %rsi
	movslq	%ecx, %rax
	leaq	0(,%rax,8), %rdx
	leaq	a(%rip), %rax
	movq	%rsi, (%rdx,%rax)
.L4:
	movl	i(%rip), %eax
	addl	$1, %eax
	movl	%eax, i(%rip)
	movl	i(%rip), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	a(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	scanf@PLT
	cmpl	$-1, %eax
	jne	.L5
	movl	N(%rip), %eax
	leaq	8+a(%rip), %rdi
	leaq	c(%rip), %rdx
	movq	%rdx, %rcx
	movl	$8, %edx
	movl	%eax, %esi
	movl	$0, %eax
	call	qsort@PLT
	movl	$0, j(%rip)
	movl	j(%rip), %eax
	movl	%eax, i(%rip)
	jmp	.L6
.L7:
	movl	i(%rip), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	a(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movl	j(%rip), %eax
	cltq
	leaq	0(,%rax,8), %rcx
	leaq	a(%rip), %rax
	movq	(%rcx,%rax), %rax
	cmpq	%rax, %rdx
	je	.L6
	movl	i(%rip), %eax
	movl	j(%rip), %edx
	subl	%edx, %eax
	cltq
	movq	%rax, r(%rip)
	movq	r(%rip), %rax
	leaq	-1(%rax), %rdx
	movq	r(%rip), %rax
	imulq	%rdx, %rax
	movq	%rax, r(%rip)
	movq	r(%rip), %rdx
	movq	v(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, v(%rip)
	movl	i(%rip), %eax
	movl	%eax, j(%rip)
.L6:
	movl	i(%rip), %eax
	leal	1(%rax), %edx
	movl	%edx, i(%rip)
	movl	N(%rip), %edx
	cmpl	%edx, %eax
	jl	.L7
	movl	i(%rip), %eax
	movl	j(%rip), %edx
	subl	%edx, %eax
	cltq
	movq	%rax, r(%rip)
	movq	r(%rip), %rax
	leaq	-1(%rax), %rdx
	movq	r(%rip), %rax
	imulq	%rdx, %rax
	movq	%rax, r(%rip)
	movq	r(%rip), %rdx
	movq	v(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, v(%rip)
	movq	v(%rip), %rax
	movq	%rax, %rdx
	shrq	$63, %rdx
	addq	%rdx, %rax
	sarq	%rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, i(%rip)
	movl	$0, %eax
	popq	%rbp
	.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:
