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>

int main(void) {
	int n, m;
	
	while (scanf("%d%d", &n, &m), n) {
		int i, j, max = 0;
		int l[100000], r[100000];
		
		long long s = 0;
		long long ss = 0;
		
		l[0] = 0;
		r[0] = 0;

		for (i = 1; i < m; ++i) {
			l[i] = 30001; // ??????????????????
			r[i] = -1;    // ??????????????????
		}
		
		for (i = 1; i <= n; ++i) {
			unsigned int t;
			scanf("%u", &t);
			s = (s + t) % m;
			ss += t;
			
			l[s] = i < l[s] ? i : l[s]; // ??????
			r[s] = i > r[s] ? i : r[s]; // ??????
			
			max = max < s ? s : max;
		}
		
		if (ss < m) {
			printf("%d\n", (int)ss);
			continue;
		}
		
		// ????????????????????°???
		for (i = 1; i < m; ++i) {
			if (r[i] <= 0) {
				continue;
			}
			
			// ??????????????????????????´(i+1)????????°???
			for (j = 1; j < m - max; ++j) {
				// ?????´????????¢???????????°???????????´??°
				if (l[i + j] < r[i]) {
					max = m - j;
					break;
				}
			}
		}

		printf("%d\n", max);
	}
	
	return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%u"
.LC1:
	.string	"%d\n"
.LC2:
	.string	"%d%d"
	.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
	leaq	-798720(%rsp), %r11
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	subq	$1344, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	jmp	.L2
.L15:
	movl	$0, -800036(%rbp)
	movq	$0, -800032(%rbp)
	movq	$0, -800024(%rbp)
	movl	$0, -800016(%rbp)
	movl	$0, -400016(%rbp)
	movl	$1, -800044(%rbp)
	jmp	.L3
.L4:
	movl	-800044(%rbp), %eax
	cltq
	movl	$30001, -800016(%rbp,%rax,4)
	movl	-800044(%rbp), %eax
	cltq
	movl	$-1, -400016(%rbp,%rax,4)
	addl	$1, -800044(%rbp)
.L3:
	movl	-800052(%rbp), %eax
	cmpl	%eax, -800044(%rbp)
	jl	.L4
	movl	$1, -800044(%rbp)
	jmp	.L5
.L6:
	leaq	-800048(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-800048(%rbp), %eax
	movl	%eax, %edx
	movq	-800032(%rbp), %rax
	addq	%rdx, %rax
	movl	-800052(%rbp), %edx
	movslq	%edx, %rcx
	cqto
	idivq	%rcx
	movq	%rdx, -800032(%rbp)
	movl	-800048(%rbp), %eax
	movl	%eax, %eax
	addq	%rax, -800024(%rbp)
	movq	-800032(%rbp), %rax
	movl	-800016(%rbp,%rax,4), %edx
	movl	-800044(%rbp), %eax
	cmpl	%eax, %edx
	cmovg	%eax, %edx
	movq	-800032(%rbp), %rax
	movl	%edx, -800016(%rbp,%rax,4)
	movq	-800032(%rbp), %rax
	movl	-400016(%rbp,%rax,4), %edx
	movl	-800044(%rbp), %eax
	cmpl	%eax, %edx
	cmovl	%eax, %edx
	movq	-800032(%rbp), %rax
	movl	%edx, -400016(%rbp,%rax,4)
	movl	-800036(%rbp), %eax
	movslq	%eax, %rdx
	movq	-800032(%rbp), %rax
	cmpq	%rax, %rdx
	cmovge	%rdx, %rax
	movl	%eax, -800036(%rbp)
	addl	$1, -800044(%rbp)
.L5:
	movl	-800056(%rbp), %eax
	cmpl	%eax, -800044(%rbp)
	jle	.L6
	movl	-800052(%rbp), %eax
	cltq
	cmpq	%rax, -800024(%rbp)
	jge	.L7
	movq	-800024(%rbp), %rax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L2
.L7:
	movl	$1, -800044(%rbp)
	jmp	.L8
.L14:
	movl	-800044(%rbp), %eax
	cltq
	movl	-400016(%rbp,%rax,4), %eax
	testl	%eax, %eax
	jle	.L18
	movl	$1, -800040(%rbp)
	jmp	.L11
.L13:
	movl	-800044(%rbp), %edx
	movl	-800040(%rbp), %eax
	addl	%edx, %eax
	cltq
	movl	-800016(%rbp,%rax,4), %edx
	movl	-800044(%rbp), %eax
	cltq
	movl	-400016(%rbp,%rax,4), %eax
	cmpl	%eax, %edx
	jge	.L12
	movl	-800052(%rbp), %eax
	subl	-800040(%rbp), %eax
	movl	%eax, -800036(%rbp)
	jmp	.L10
.L12:
	addl	$1, -800040(%rbp)
.L11:
	movl	-800052(%rbp), %eax
	subl	-800036(%rbp), %eax
	cmpl	%eax, -800040(%rbp)
	jl	.L13
	jmp	.L10
.L18:
	nop
.L10:
	addl	$1, -800044(%rbp)
.L8:
	movl	-800052(%rbp), %eax
	cmpl	%eax, -800044(%rbp)
	jl	.L14
	movl	-800036(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L2:
	leaq	-800052(%rbp), %rdx
	leaq	-800056(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-800056(%rbp), %eax
	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
.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
.LC1:
	.string	"%u"
.LC2:
	.string	"%d\n"
.LC3:
	.string	"%d%d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.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	-798720(%rsp), %r11
	.cfi_def_cfa 11, 798776
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	.cfi_def_cfa_register 7
	subq	$1352, %rsp
	.cfi_def_cfa_offset 800128
	leaq	.LC1(%rip), %r12
	movq	%fs:40, %rax
	movq	%rax, 800056(%rsp)
	xorl	%eax, %eax
	leaq	40(%rsp), %rax
	movq	%rax, 16(%rsp)
	leaq	36(%rsp), %rax
	movq	%rax, 8(%rsp)
	leaq	400052(%rsp), %rax
	movq	%rax, 24(%rsp)
	.p2align 4,,10
	.p2align 3
.L2:
	movq	16(%rsp), %rdx
	movq	8(%rsp), %rsi
	leaq	.LC3(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	36(%rsp), %ebx
	testl	%ebx, %ebx
	je	.L32
	movl	40(%rsp), %ebp
	movl	$0, 48(%rsp)
	movl	$0, 400048(%rsp)
	cmpl	$1, %ebp
	jle	.L9
	leal	-2(%rbp), %eax
	leal	-1(%rbp), %edx
	cmpl	$2, %eax
	jbe	.L22
	movl	%edx, %ecx
	leaq	52(%rsp), %rax
	shrl	$2, %ecx
	subl	$1, %ecx
	salq	$4, %rcx
	leaq	68(%rsp,%rcx), %rcx
	.p2align 4,,10
	.p2align 3
.L7:
	movdqa	.LC0(%rip), %xmm0
	addq	$16, %rax
	movups	%xmm0, -16(%rax)
	cmpq	%rcx, %rax
	jne	.L7
	movl	%edx, %ecx
	andl	$-4, %ecx
	leal	1(%rcx), %eax
	cmpl	%edx, %ecx
	je	.L8
.L6:
	movslq	%eax, %rcx
	movl	$30001, 48(%rsp,%rcx,4)
	leal	1(%rax), %ecx
	cmpl	%ebp, %ecx
	jge	.L8
	movslq	%ecx, %rcx
	addl	$2, %eax
	movl	$30001, 48(%rsp,%rcx,4)
	cmpl	%eax, %ebp
	jle	.L8
	cltq
	movl	$30001, 48(%rsp,%rax,4)
.L8:
	movq	24(%rsp), %rdi
	salq	$2, %rdx
	movl	$255, %esi
	call	memset@PLT
.L9:
	testl	%ebx, %ebx
	jle	.L33
	xorl	%edx, %edx
	xorl	%ebx, %ebx
	xorl	%r14d, %r14d
	movl	$1, %r13d
	leaq	44(%rsp), %r15
	movq	%rdx, %rbp
	.p2align 4,,10
	.p2align 3
.L4:
	movq	%r15, %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	movslq	%r14d, %r14
	call	__isoc99_scanf@PLT
	movl	44(%rsp), %edi
	movslq	40(%rsp), %rsi
	leaq	(%rdi,%rbp), %rax
	addq	%rdi, %rbx
	cqto
	idivq	%rsi
	movl	48(%rsp,%rdx,4), %eax
	movq	%rdx, %rbp
	cmpl	%r13d, %eax
	cmovg	%r13d, %eax
	movl	%eax, 48(%rsp,%rdx,4)
	movl	400048(%rsp,%rdx,4), %eax
	cmpl	%r13d, %eax
	cmovl	%r13d, %eax
	cmpq	%rdx, %r14
	cmovl	%rdx, %r14
	addl	$1, %r13d
	movl	%eax, 400048(%rsp,%rdx,4)
	cmpl	%r13d, 36(%rsp)
	jge	.L4
	movl	%esi, %ebp
.L10:
	cmpq	%rbx, %rsi
	jg	.L11
	leaq	52(%rsp), %rdx
	movl	$1, %r11d
	leaq	400048(%rsp), %rbx
	cmpl	$1, %ebp
	jle	.L13
	.p2align 4,,10
	.p2align 3
.L18:
	movl	(%rbx,%r11,4), %ecx
	testl	%ecx, %ecx
	jle	.L15
	movl	%ebp, %edi
	subl	%r14d, %edi
	cmpl	$1, %edi
	jle	.L15
	movslq	%edi, %rdi
	movl	$1, %eax
	jmp	.L17
	.p2align 4,,10
	.p2align 3
.L16:
	addq	$1, %rax
	cmpq	%rax, %rdi
	je	.L15
.L17:
	cmpl	(%rdx,%rax,4), %ecx
	jle	.L16
	movl	%ebp, %r14d
	subl	%eax, %r14d
.L15:
	addq	$1, %r11
	addq	$4, %rdx
	cmpq	%rsi, %r11
	jne	.L18
.L13:
	movl	%r14d, %edx
	leaq	.LC2(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L2
	.p2align 4,,10
	.p2align 3
.L11:
	movl	%ebx, %edx
	leaq	.LC2(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L2
.L32:
	movq	800056(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L34
	addq	$800072, %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
.L33:
	.cfi_restore_state
	movslq	%ebp, %rsi
	xorl	%ebx, %ebx
	xorl	%r14d, %r14d
	jmp	.L10
.L22:
	movl	$1, %eax
	jmp	.L6
.L34:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC0:
	.long	30001
	.long	30001
	.long	30001
	.long	30001
	.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
.LC1:
	.string	"%u"
.LC2:
	.string	"%d\n"
.LC3:
	.string	"%d%d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.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	-798720(%rsp), %r11
	.cfi_def_cfa 11, 798776
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	.cfi_def_cfa_register 7
	subq	$1352, %rsp
	.cfi_def_cfa_offset 800128
	leaq	.LC1(%rip), %r12
	movq	%fs:40, %rax
	movq	%rax, 800056(%rsp)
	xorl	%eax, %eax
	leaq	40(%rsp), %rax
	movq	%rax, 16(%rsp)
	leaq	36(%rsp), %rax
	movq	%rax, 8(%rsp)
	leaq	400052(%rsp), %rax
	movq	%rax, 24(%rsp)
	.p2align 4,,10
	.p2align 3
.L2:
	movq	16(%rsp), %rdx
	movq	8(%rsp), %rsi
	leaq	.LC3(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	36(%rsp), %ebx
	testl	%ebx, %ebx
	je	.L32
	movl	40(%rsp), %ebp
	movl	$0, 48(%rsp)
	movl	$0, 400048(%rsp)
	cmpl	$1, %ebp
	jle	.L9
	leal	-2(%rbp), %eax
	leal	-1(%rbp), %edx
	cmpl	$2, %eax
	jbe	.L22
	movl	%edx, %ecx
	leaq	52(%rsp), %rax
	shrl	$2, %ecx
	subl	$1, %ecx
	salq	$4, %rcx
	leaq	68(%rsp,%rcx), %rcx
	.p2align 4,,10
	.p2align 3
.L7:
	movdqa	.LC0(%rip), %xmm0
	addq	$16, %rax
	movups	%xmm0, -16(%rax)
	cmpq	%rcx, %rax
	jne	.L7
	movl	%edx, %ecx
	andl	$-4, %ecx
	leal	1(%rcx), %eax
	cmpl	%edx, %ecx
	je	.L8
.L6:
	movslq	%eax, %rcx
	movl	$30001, 48(%rsp,%rcx,4)
	leal	1(%rax), %ecx
	cmpl	%ebp, %ecx
	jge	.L8
	movslq	%ecx, %rcx
	addl	$2, %eax
	movl	$30001, 48(%rsp,%rcx,4)
	cmpl	%eax, %ebp
	jle	.L8
	cltq
	movl	$30001, 48(%rsp,%rax,4)
.L8:
	movq	24(%rsp), %rdi
	salq	$2, %rdx
	movl	$255, %esi
	call	memset@PLT
.L9:
	testl	%ebx, %ebx
	jle	.L33
	xorl	%edx, %edx
	xorl	%ebx, %ebx
	xorl	%r14d, %r14d
	movl	$1, %r13d
	leaq	44(%rsp), %r15
	movq	%rdx, %rbp
	.p2align 4,,10
	.p2align 3
.L4:
	movq	%r15, %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	movslq	%r14d, %r14
	call	__isoc99_scanf@PLT
	movl	44(%rsp), %edi
	movslq	40(%rsp), %rsi
	leaq	(%rdi,%rbp), %rax
	addq	%rdi, %rbx
	cqto
	idivq	%rsi
	movl	48(%rsp,%rdx,4), %eax
	movq	%rdx, %rbp
	cmpl	%r13d, %eax
	cmovg	%r13d, %eax
	movl	%eax, 48(%rsp,%rdx,4)
	movl	400048(%rsp,%rdx,4), %eax
	cmpl	%r13d, %eax
	cmovl	%r13d, %eax
	cmpq	%rdx, %r14
	cmovl	%rdx, %r14
	addl	$1, %r13d
	movl	%eax, 400048(%rsp,%rdx,4)
	cmpl	%r13d, 36(%rsp)
	jge	.L4
	movl	%esi, %ebp
.L10:
	cmpq	%rbx, %rsi
	jg	.L11
	leaq	52(%rsp), %rdx
	movl	$1, %r11d
	leaq	400048(%rsp), %rbx
	cmpl	$1, %ebp
	jle	.L13
	.p2align 4,,10
	.p2align 3
.L18:
	movl	(%rbx,%r11,4), %ecx
	testl	%ecx, %ecx
	jle	.L15
	movl	%ebp, %edi
	subl	%r14d, %edi
	cmpl	$1, %edi
	jle	.L15
	movslq	%edi, %rdi
	movl	$1, %eax
	jmp	.L17
	.p2align 4,,10
	.p2align 3
.L16:
	addq	$1, %rax
	cmpq	%rax, %rdi
	je	.L15
.L17:
	cmpl	(%rdx,%rax,4), %ecx
	jle	.L16
	movl	%ebp, %r14d
	subl	%eax, %r14d
.L15:
	addq	$1, %r11
	addq	$4, %rdx
	cmpq	%rsi, %r11
	jne	.L18
.L13:
	movl	%r14d, %edx
	leaq	.LC2(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L2
	.p2align 4,,10
	.p2align 3
.L11:
	movl	%ebx, %edx
	leaq	.LC2(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L2
.L32:
	movq	800056(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L34
	addq	$800072, %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
.L33:
	.cfi_restore_state
	movslq	%ebp, %rsi
	xorl	%ebx, %ebx
	xorl	%r14d, %r14d
	jmp	.L10
.L22:
	movl	$1, %eax
	jmp	.L6
.L34:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC0:
	.long	30001
	.long	30001
	.long	30001
	.long	30001
	.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>

int main(void) {
	int n, m;
	
	while (scanf("%d%d", &n, &m), n) {
		int i, j, max = 0;
		int l[100000], r[100000];
		
		long long s = 0;
		long long ss = 0;
		
		l[0] = 0;
		r[0] = 0;

		for (i = 1; i < m; ++i) {
			l[i] = 30001; // ??????????????????
			r[i] = -1;    // ??????????????????
		}
		
		for (i = 1; i <= n; ++i) {
			unsigned int t;
			scanf("%u", &t);
			s = (s + t) % m;
			ss += t;
			
			l[s] = i < l[s] ? i : l[s]; // ??????
			r[s] = i > r[s] ? i : r[s]; // ??????
			
			max = max < s ? s : max;
		}
		
		if (ss < m) {
			printf("%d\n", (int)ss);
			continue;
		}
		
		// ????????????????????°???
		for (i = 1; i < m; ++i) {
			if (r[i] <= 0) {
				continue;
			}
			
			// ??????????????????????????´(i+1)????????°???
			for (j = 1; j < m - max; ++j) {
				// ?????´????????¢???????????°???????????´??°
				if (l[i + j] < r[i]) {
					max = m - j;
					break;
				}
			}
		}

		printf("%d\n", max);
	}
	
	return 0;
}
5 11
11 27 34 45 56
8 5
0 2 1 5 4 6 8 3
5 2
2 4 2 4 6
10 18
10 15 12 31 12 50 11 11 43 181
1 100
5
0 0
 5 11
7 27 34 45 94
8 5
0 2 1 5 4 6 8 3
5 2
2 4 2 4 6
10 18
10 15 12 31 12 50 11 11 43 181
1 101
5
0 0
 5 11
7 36 34 45 94
8 5
0 2 1 5 4 6 8 2
5 2
2 4 2 4 6
10 18
10 15 12 31 12 50 11 11 43 181
1 101
5
0 0
 5 11
7 36 34 45 94
8 5
0 2 1 5 4 6 8 2
5 2
2 4 2 4 6
10 18
10 15 12 56 12 50 11 11 84 181
1 101
5
0 0
 5 11
7 36 34 45 94
8 10
-1 2 1 5 4 6 8 2
5 2
2 4 2 4 6
10 18
10 15 12 56 12 67 11 6 22 181
1 101
5
0 0
 5 11
7 36 34 45 94
8 10
-1 2 1 5 4 6 8 2
5 2
2 4 2 4 8
10 18
10 15 12 56 12 67 11 6 22 181
1 101
8
0 0
 5 11
11 27 34 45 56
8 5
0 2 1 5 4 6 8 3
5 3
2 4 2 4 6
10 18
10 15 12 31 12 50 11 11 43 181
1 100
5
0 0
 5 11
11 27 34 45 94
8 5
0 2 1 5 4 6 8 3
5 2
2 4 2 4 1
10 18
10 15 12 31 12 50 11 11 43 181
1 101
5
0 0
 5 11
7 36 34 45 94
8 5
0 2 1 5 4 6 8 2
5 2
2 4 2 4 1
10 18
10 15 12 31 12 50 11 11 43 181
1 101
5
0 0
 5 11
7 36 34 45 94
8 5
0 2 1 5 4 6 8 2
5 2
2 4 2 4 6
10 3
10 15 12 56 12 50 11 11 43 181
1 101
5
0 0

8
4
0
16
5
 9
4
0
16
5
 10
4
0
16
5
 10
4
0
17
5
 10
9
0
17
5
 10
9
0
17
8
 8
4
2
16
5
 8
4
1
16
5
 10
4
1
16
5
 10
4
0
2
5

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>

int main(void) {
	int n, m;
	
	while (scanf("%d%d", &n, &m), n) {
		int i, j, max = 0;
		int l[100000], r[100000];
		
		long long s = 0;
		long long ss = 0;
		
		l[0] = 0;
		r[0] = 0;

		for (i = 1; i < m; ++i) {
			l[i] = 30001; // ??????????????????
			r[i] = -1;    // ??????????????????
		}
		
		for (i = 1; i <= n; ++i) {
			unsigned int t;
			scanf("%u", &t);
			s = (s + t) % m;
			ss += t;
			
			l[s] = i < l[s] ? i : l[s]; // ??????
			r[s] = i > r[s] ? i : r[s]; // ??????
			
			max = max < s ? s : max;
		}
		
		if (ss < m) {
			printf("%d\n", (int)ss);
			continue;
		}
		
		// ????????????????????°???
		for (i = 1; i < m; ++i) {
			if (r[i] <= 0) {
				continue;
			}
			
			// ??????????????????????????´(i+1)????????°???
			for (j = 1; j < m - max; ++j) {
				// ?????´????????¢???????????°???????????´??°
				if (l[i + j] < r[i]) {
					max = m - j;
					break;
				}
			}
		}

		printf("%d\n", max);
	}
	
	return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%u"
.LC1:
	.string	"%d\n"
.LC2:
	.string	"%d%d"
	.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
	leaq	-798720(%rsp), %r11
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	subq	$1344, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	jmp	.L2
.L15:
	movl	$0, -800036(%rbp)
	movq	$0, -800032(%rbp)
	movq	$0, -800024(%rbp)
	movl	$0, -800016(%rbp)
	movl	$0, -400016(%rbp)
	movl	$1, -800044(%rbp)
	jmp	.L3
.L4:
	movl	-800044(%rbp), %eax
	cltq
	movl	$30001, -800016(%rbp,%rax,4)
	movl	-800044(%rbp), %eax
	cltq
	movl	$-1, -400016(%rbp,%rax,4)
	addl	$1, -800044(%rbp)
.L3:
	movl	-800052(%rbp), %eax
	cmpl	%eax, -800044(%rbp)
	jl	.L4
	movl	$1, -800044(%rbp)
	jmp	.L5
.L6:
	leaq	-800048(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-800048(%rbp), %eax
	movl	%eax, %edx
	movq	-800032(%rbp), %rax
	addq	%rdx, %rax
	movl	-800052(%rbp), %edx
	movslq	%edx, %rcx
	cqto
	idivq	%rcx
	movq	%rdx, -800032(%rbp)
	movl	-800048(%rbp), %eax
	movl	%eax, %eax
	addq	%rax, -800024(%rbp)
	movq	-800032(%rbp), %rax
	movl	-800016(%rbp,%rax,4), %edx
	movl	-800044(%rbp), %eax
	cmpl	%eax, %edx
	cmovg	%eax, %edx
	movq	-800032(%rbp), %rax
	movl	%edx, -800016(%rbp,%rax,4)
	movq	-800032(%rbp), %rax
	movl	-400016(%rbp,%rax,4), %edx
	movl	-800044(%rbp), %eax
	cmpl	%eax, %edx
	cmovl	%eax, %edx
	movq	-800032(%rbp), %rax
	movl	%edx, -400016(%rbp,%rax,4)
	movl	-800036(%rbp), %eax
	movslq	%eax, %rdx
	movq	-800032(%rbp), %rax
	cmpq	%rax, %rdx
	cmovge	%rdx, %rax
	movl	%eax, -800036(%rbp)
	addl	$1, -800044(%rbp)
.L5:
	movl	-800056(%rbp), %eax
	cmpl	%eax, -800044(%rbp)
	jle	.L6
	movl	-800052(%rbp), %eax
	cltq
	cmpq	%rax, -800024(%rbp)
	jge	.L7
	movq	-800024(%rbp), %rax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L2
.L7:
	movl	$1, -800044(%rbp)
	jmp	.L8
.L14:
	movl	-800044(%rbp), %eax
	cltq
	movl	-400016(%rbp,%rax,4), %eax
	testl	%eax, %eax
	jle	.L18
	movl	$1, -800040(%rbp)
	jmp	.L11
.L13:
	movl	-800044(%rbp), %edx
	movl	-800040(%rbp), %eax
	addl	%edx, %eax
	cltq
	movl	-800016(%rbp,%rax,4), %edx
	movl	-800044(%rbp), %eax
	cltq
	movl	-400016(%rbp,%rax,4), %eax
	cmpl	%eax, %edx
	jge	.L12
	movl	-800052(%rbp), %eax
	subl	-800040(%rbp), %eax
	movl	%eax, -800036(%rbp)
	jmp	.L10
.L12:
	addl	$1, -800040(%rbp)
.L11:
	movl	-800052(%rbp), %eax
	subl	-800036(%rbp), %eax
	cmpl	%eax, -800040(%rbp)
	jl	.L13
	jmp	.L10
.L18:
	nop
.L10:
	addl	$1, -800044(%rbp)
.L8:
	movl	-800052(%rbp), %eax
	cmpl	%eax, -800044(%rbp)
	jl	.L14
	movl	-800036(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L2:
	leaq	-800052(%rbp), %rdx
	leaq	-800056(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-800056(%rbp), %eax
	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
.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
	.section	.rodata
.LC0:
	.string	"%u"
.LC1:
	.string	"%d\n"
.LC2:
	.string	"%d%d"
	.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
	leaq	-798720(%rsp), %r11
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	subq	$1344, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	jmp	.L2
.L15:
	movl	$0, -800036(%rbp)
	movq	$0, -800032(%rbp)
	movq	$0, -800024(%rbp)
	movl	$0, -800016(%rbp)
	movl	$0, -400016(%rbp)
	movl	$1, -800044(%rbp)
	jmp	.L3
.L4:
	movl	-800044(%rbp), %eax
	cltq
	movl	$30001, -800016(%rbp,%rax,4)
	movl	-800044(%rbp), %eax
	cltq
	movl	$-1, -400016(%rbp,%rax,4)
	addl	$1, -800044(%rbp)
.L3:
	movl	-800052(%rbp), %eax
	cmpl	%eax, -800044(%rbp)
	jl	.L4
	movl	$1, -800044(%rbp)
	jmp	.L5
.L6:
	leaq	-800048(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-800048(%rbp), %eax
	movl	%eax, %edx
	movq	-800032(%rbp), %rax
	addq	%rdx, %rax
	movl	-800052(%rbp), %edx
	movslq	%edx, %rcx
	cqto
	idivq	%rcx
	movq	%rdx, -800032(%rbp)
	movl	-800048(%rbp), %eax
	movl	%eax, %eax
	addq	%rax, -800024(%rbp)
	movq	-800032(%rbp), %rax
	movl	-800016(%rbp,%rax,4), %edx
	movl	-800044(%rbp), %eax
	cmpl	%eax, %edx
	cmovg	%eax, %edx
	movq	-800032(%rbp), %rax
	movl	%edx, -800016(%rbp,%rax,4)
	movq	-800032(%rbp), %rax
	movl	-400016(%rbp,%rax,4), %edx
	movl	-800044(%rbp), %eax
	cmpl	%eax, %edx
	cmovl	%eax, %edx
	movq	-800032(%rbp), %rax
	movl	%edx, -400016(%rbp,%rax,4)
	movl	-800036(%rbp), %eax
	movslq	%eax, %rdx
	movq	-800032(%rbp), %rax
	cmpq	%rax, %rdx
	cmovge	%rdx, %rax
	movl	%eax, -800036(%rbp)
	addl	$1, -800044(%rbp)
.L5:
	movl	-800056(%rbp), %eax
	cmpl	%eax, -800044(%rbp)
	jle	.L6
	movl	-800052(%rbp), %eax
	cltq
	cmpq	%rax, -800024(%rbp)
	jge	.L7
	movq	-800024(%rbp), %rax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L2
.L7:
	movl	$1, -800044(%rbp)
	jmp	.L8
.L14:
	movl	-800044(%rbp), %eax
	cltq
	movl	-400016(%rbp,%rax,4), %eax
	testl	%eax, %eax
	jle	.L18
	movl	$1, -800040(%rbp)
	jmp	.L11
.L13:
	movl	-800044(%rbp), %edx
	movl	-800040(%rbp), %eax
	addl	%edx, %eax
	cltq
	movl	-800016(%rbp,%rax,4), %edx
	movl	-800044(%rbp), %eax
	cltq
	movl	-400016(%rbp,%rax,4), %eax
	cmpl	%eax, %edx
	jge	.L12
	movl	-800052(%rbp), %eax
	subl	-800040(%rbp), %eax
	movl	%eax, -800036(%rbp)
	jmp	.L10
.L12:
	addl	$1, -800040(%rbp)
.L11:
	movl	-800052(%rbp), %eax
	subl	-800036(%rbp), %eax
	cmpl	%eax, -800040(%rbp)
	jl	.L13
	jmp	.L10
.L18:
	nop
.L10:
	addl	$1, -800044(%rbp)
.L8:
	movl	-800052(%rbp), %eax
	cmpl	%eax, -800044(%rbp)
	jl	.L14
	movl	-800036(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L2:
	leaq	-800052(%rbp), %rdx
	leaq	-800056(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-800056(%rbp), %eax
	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
.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:
