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

```c
// AOJ 2944 Equal Split
// 2019.8.8 bal4u

#include <stdio.h>

#if 1
#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)
#else
#define gc() getchar()
#define pc(c) putchar(c)
#endif

int in() {   // 非負整数の入力
	int n = 0, c = gc();
	do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0');
	return n;
}

void out(int n) { // 正整数の表示（出力）
	int i;
	char b[20];
	i = 0; while (n) b[i++] = n % 10 + '0', n /= 10;
	while (i--) pc(b[i]);
	pc('\n');
}

int main()
{
	int i, a, N, M, ans;
	
	while (N = in()) {
		M = in(), M /= N;
		ans = 0;
		for (i = 0; i < N; i++) {
			a = in();
			ans += (a >= M)? M: a;
		}
		out(ans);
	}
	return 0;
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.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), %edx
	movl	%edx, %eax
	sall	$2, %eax
	addl	%edx, %eax
	addl	%eax, %eax
	movl	%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
	.globl	out
	.type	out, @function
out:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$64, %rsp
	movl	%edi, -52(%rbp)
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -36(%rbp)
	jmp	.L5
.L6:
	movl	-52(%rbp), %edx
	movslq	%edx, %rax
	imulq	$1717986919, %rax, %rax
	shrq	$32, %rax
	sarl	$2, %eax
	movl	%edx, %esi
	sarl	$31, %esi
	subl	%esi, %eax
	movl	%eax, %ecx
	movl	%ecx, %eax
	sall	$2, %eax
	addl	%ecx, %eax
	addl	%eax, %eax
	movl	%edx, %ecx
	subl	%eax, %ecx
	movl	%ecx, %eax
	leal	48(%rax), %ecx
	movl	-36(%rbp), %eax
	leal	1(%rax), %edx
	movl	%edx, -36(%rbp)
	movl	%ecx, %edx
	cltq
	movb	%dl, -32(%rbp,%rax)
	movl	-52(%rbp), %eax
	movslq	%eax, %rdx
	imulq	$1717986919, %rdx, %rdx
	shrq	$32, %rdx
	sarl	$2, %edx
	sarl	$31, %eax
	movl	%eax, %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	movl	%eax, -52(%rbp)
.L5:
	cmpl	$0, -52(%rbp)
	jne	.L6
	jmp	.L7
.L8:
	movl	-36(%rbp), %eax
	cltq
	movzbl	-32(%rbp,%rax), %eax
	movsbl	%al, %eax
	movl	%eax, %edi
	call	putchar_unlocked@PLT
.L7:
	movl	-36(%rbp), %eax
	leal	-1(%rax), %edx
	movl	%edx, -36(%rbp)
	testl	%eax, %eax
	jne	.L8
	movl	$10, %edi
	call	putchar_unlocked@PLT
	nop
	movq	-8(%rbp), %rax
	subq	%fs:40, %rax
	je	.L9
	call	__stack_chk_fail@PLT
.L9:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	out, .-out
	.globl	main
	.type	main, @function
main:
.LFB2:
	.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	.L11
.L14:
	movl	$0, %eax
	call	in
	movl	%eax, -8(%rbp)
	movl	-8(%rbp), %eax
	cltd
	idivl	-12(%rbp)
	movl	%eax, -8(%rbp)
	movl	$0, -16(%rbp)
	movl	$0, -20(%rbp)
	jmp	.L12
.L13:
	movl	$0, %eax
	call	in
	movl	%eax, -4(%rbp)
	movl	-8(%rbp), %edx
	movl	-4(%rbp), %eax
	cmpl	%eax, %edx
	cmovle	%edx, %eax
	addl	%eax, -16(%rbp)
	addl	$1, -20(%rbp)
.L12:
	movl	-20(%rbp), %eax
	cmpl	-12(%rbp), %eax
	jl	.L13
	movl	-16(%rbp), %eax
	movl	%eax, %edi
	call	out
.L11:
	movl	$0, %eax
	call	in
	movl	%eax, -12(%rbp)
	cmpl	$0, -12(%rbp)
	jne	.L14
	movl	$0, %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2:
	.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
	.p2align 4
	.globl	out
	.type	out, @function
out:
.LFB24:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	subq	$40, %rsp
	.cfi_def_cfa_offset 64
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	testl	%edi, %edi
	je	.L13
	xorl	%edx, %edx
	movq	%rsp, %rbx
	.p2align 4,,10
	.p2align 3
.L14:
	movslq	%edi, %rax
	movl	%edi, %ecx
	movslq	%edx, %rsi
	imulq	$1717986919, %rax, %rax
	sarl	$31, %ecx
	sarq	$34, %rax
	subl	%ecx, %eax
	leal	(%rax,%rax,4), %ecx
	addl	%ecx, %ecx
	subl	%ecx, %edi
	addl	$48, %edi
	movb	%dil, (%rbx,%rdx)
	movl	%eax, %edi
	movq	%rdx, %rax
	addq	$1, %rdx
	testl	%edi, %edi
	jne	.L14
	leaq	-1(%rsp,%rsi), %rbp
	addq	%rsi, %rbx
	subq	%rax, %rbp
	.p2align 4,,10
	.p2align 3
.L20:
	movq	stdout(%rip), %rdi
	movzbl	(%rbx), %esi
	movq	40(%rdi), %rax
	cmpq	48(%rdi), %rax
	jnb	.L32
	leaq	1(%rax), %rdx
	movq	%rdx, 40(%rdi)
	movb	%sil, (%rax)
.L19:
	subq	$1, %rbx
	cmpq	%rbx, %rbp
	jne	.L20
.L13:
	movq	stdout(%rip), %rdi
	movq	40(%rdi), %rax
	cmpq	48(%rdi), %rax
	jnb	.L33
	leaq	1(%rax), %rdx
	movq	%rdx, 40(%rdi)
	movb	$10, (%rax)
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L31
	addq	$40, %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
.L32:
	.cfi_restore_state
	call	__overflow@PLT
	jmp	.L19
	.p2align 4,,10
	.p2align 3
.L33:
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L31
	addq	$40, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 24
	movl	$10, %esi
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	jmp	__overflow@PLT
.L31:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE24:
	.size	out, .-out
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB25:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	.p2align 4,,10
	.p2align 3
.L35:
	movq	stdin(%rip), %rdi
	movq	8(%rdi), %rax
	movq	16(%rdi), %rcx
	cmpq	%rcx, %rax
	jnb	.L60
	leaq	1(%rax), %rdx
	movq	%rdx, 8(%rdi)
	movzbl	(%rax), %eax
.L51:
	xorl	%r13d, %r13d
	jmp	.L55
	.p2align 4,,10
	.p2align 3
.L52:
	leaq	1(%rdx), %rax
	movq	%rax, 8(%rdi)
	movzbl	(%rdx), %eax
	cmpl	$47, %eax
	jle	.L54
.L53:
	movq	8(%rdi), %rdx
	movq	16(%rdi), %rcx
.L55:
	leal	0(%r13,%r13,4), %esi
	andl	$15, %eax
	leal	(%rax,%rsi,2), %r13d
	cmpq	%rcx, %rdx
	jb	.L52
	call	__uflow@PLT
	cmpl	$47, %eax
	jle	.L54
	movq	stdin(%rip), %rdi
	jmp	.L53
	.p2align 4,,10
	.p2align 3
.L54:
	testl	%r13d, %r13d
	je	.L61
	movq	stdin(%rip), %rdi
	movq	8(%rdi), %rax
	movq	16(%rdi), %rcx
	cmpq	%rcx, %rax
	jnb	.L62
	leaq	1(%rax), %rdx
	movq	%rdx, 8(%rdi)
	movzbl	(%rax), %eax
.L37:
	xorl	%ebx, %ebx
	jmp	.L41
	.p2align 4,,10
	.p2align 3
.L38:
	leaq	1(%rdx), %rsi
	movq	%rsi, 8(%rdi)
	movzbl	(%rdx), %eax
	cmpl	$47, %eax
	jle	.L40
.L39:
	movq	%rsi, %rdx
.L41:
	leal	(%rbx,%rbx,4), %esi
	andl	$15, %eax
	leal	(%rax,%rsi,2), %ebx
	cmpq	%rcx, %rdx
	jb	.L38
	call	__uflow@PLT
	movq	stdin(%rip), %rdi
	movq	8(%rdi), %rsi
	movq	16(%rdi), %rcx
	cmpl	$47, %eax
	jg	.L39
	.p2align 4,,10
	.p2align 3
.L40:
	movl	%ebx, %eax
	xorl	%ebp, %ebp
	xorl	%r14d, %r14d
	cltd
	idivl	%r13d
	movl	%eax, %ebx
	cmpq	%rcx, %rsi
	jnb	.L63
	.p2align 4,,10
	.p2align 3
.L42:
	leaq	1(%rsi), %rdx
	movq	%rdx, 8(%rdi)
	movzbl	(%rsi), %eax
.L43:
	xorl	%r12d, %r12d
	jmp	.L47
	.p2align 4,,10
	.p2align 3
.L44:
	leaq	1(%rdx), %rax
	movq	%rax, 8(%rdi)
	movzbl	(%rdx), %eax
	cmpl	$47, %eax
	jle	.L46
.L45:
	movq	8(%rdi), %rdx
	movq	16(%rdi), %rcx
.L47:
	leal	(%r12,%r12,4), %esi
	andl	$15, %eax
	leal	(%rax,%rsi,2), %r12d
	cmpq	%rcx, %rdx
	jb	.L44
	call	__uflow@PLT
	cmpl	$47, %eax
	jle	.L46
	movq	stdin(%rip), %rdi
	jmp	.L45
	.p2align 4,,10
	.p2align 3
.L46:
	cmpl	%r12d, %ebx
	cmovle	%ebx, %r12d
	addl	$1, %r14d
	addl	%r12d, %ebp
	cmpl	%r13d, %r14d
	je	.L48
	movq	stdin(%rip), %rdi
	movq	8(%rdi), %rsi
	movq	16(%rdi), %rcx
	cmpq	%rcx, %rsi
	jb	.L42
.L63:
	call	__uflow@PLT
	movq	stdin(%rip), %rdi
	movq	8(%rdi), %rdx
	movq	16(%rdi), %rcx
	jmp	.L43
	.p2align 4,,10
	.p2align 3
.L48:
	movl	%ebp, %edi
	call	out
	jmp	.L35
.L61:
	popq	%rbx
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	xorl	%eax, %eax
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	ret
.L60:
	.cfi_restore_state
	call	__uflow@PLT
	movq	stdin(%rip), %rdi
	movq	8(%rdi), %rdx
	movq	16(%rdi), %rcx
	jmp	.L51
.L62:
	call	__uflow@PLT
	movq	stdin(%rip), %rdi
	movq	8(%rdi), %rdx
	movq	16(%rdi), %rcx
	jmp	.L37
	.cfi_endproc
.LFE25:
	.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:

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
	.p2align 4
	.globl	out
	.type	out, @function
out:
.LFB24:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	subq	$40, %rsp
	.cfi_def_cfa_offset 64
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	testl	%edi, %edi
	je	.L13
	xorl	%edx, %edx
	movq	%rsp, %rbx
	.p2align 4,,10
	.p2align 3
.L14:
	movslq	%edi, %rax
	movl	%edi, %ecx
	movslq	%edx, %rsi
	imulq	$1717986919, %rax, %rax
	sarl	$31, %ecx
	sarq	$34, %rax
	subl	%ecx, %eax
	leal	(%rax,%rax,4), %ecx
	addl	%ecx, %ecx
	subl	%ecx, %edi
	addl	$48, %edi
	movb	%dil, (%rbx,%rdx)
	movl	%eax, %edi
	movq	%rdx, %rax
	addq	$1, %rdx
	testl	%edi, %edi
	jne	.L14
	leaq	-1(%rsp,%rsi), %rbp
	addq	%rsi, %rbx
	subq	%rax, %rbp
	.p2align 4,,10
	.p2align 3
.L20:
	movq	stdout(%rip), %rdi
	movzbl	(%rbx), %esi
	movq	40(%rdi), %rax
	cmpq	48(%rdi), %rax
	jnb	.L32
	leaq	1(%rax), %rdx
	movq	%rdx, 40(%rdi)
	movb	%sil, (%rax)
.L19:
	subq	$1, %rbx
	cmpq	%rbx, %rbp
	jne	.L20
.L13:
	movq	stdout(%rip), %rdi
	movq	40(%rdi), %rax
	cmpq	48(%rdi), %rax
	jnb	.L33
	leaq	1(%rax), %rdx
	movq	%rdx, 40(%rdi)
	movb	$10, (%rax)
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L31
	addq	$40, %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
.L32:
	.cfi_restore_state
	call	__overflow@PLT
	jmp	.L19
	.p2align 4,,10
	.p2align 3
.L33:
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L31
	addq	$40, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 24
	movl	$10, %esi
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	jmp	__overflow@PLT
.L31:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE24:
	.size	out, .-out
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB25:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	.p2align 4,,10
	.p2align 3
.L35:
	movq	stdin(%rip), %rdi
	movq	8(%rdi), %rax
	movq	16(%rdi), %rcx
	cmpq	%rcx, %rax
	jnb	.L60
	leaq	1(%rax), %rdx
	movq	%rdx, 8(%rdi)
	movzbl	(%rax), %eax
.L51:
	xorl	%r13d, %r13d
	jmp	.L55
	.p2align 4,,10
	.p2align 3
.L52:
	leaq	1(%rdx), %rax
	movq	%rax, 8(%rdi)
	movzbl	(%rdx), %eax
	cmpl	$47, %eax
	jle	.L54
.L53:
	movq	8(%rdi), %rdx
	movq	16(%rdi), %rcx
.L55:
	leal	0(%r13,%r13,4), %esi
	andl	$15, %eax
	leal	(%rax,%rsi,2), %r13d
	cmpq	%rcx, %rdx
	jb	.L52
	call	__uflow@PLT
	cmpl	$47, %eax
	jle	.L54
	movq	stdin(%rip), %rdi
	jmp	.L53
	.p2align 4,,10
	.p2align 3
.L54:
	testl	%r13d, %r13d
	je	.L61
	movq	stdin(%rip), %rdi
	movq	8(%rdi), %rax
	movq	16(%rdi), %rcx
	cmpq	%rcx, %rax
	jnb	.L62
	leaq	1(%rax), %rdx
	movq	%rdx, 8(%rdi)
	movzbl	(%rax), %eax
.L37:
	xorl	%ebx, %ebx
	jmp	.L41
	.p2align 4,,10
	.p2align 3
.L38:
	leaq	1(%rdx), %rsi
	movq	%rsi, 8(%rdi)
	movzbl	(%rdx), %eax
	cmpl	$47, %eax
	jle	.L40
.L39:
	movq	%rsi, %rdx
.L41:
	leal	(%rbx,%rbx,4), %esi
	andl	$15, %eax
	leal	(%rax,%rsi,2), %ebx
	cmpq	%rcx, %rdx
	jb	.L38
	call	__uflow@PLT
	movq	stdin(%rip), %rdi
	movq	8(%rdi), %rsi
	movq	16(%rdi), %rcx
	cmpl	$47, %eax
	jg	.L39
	.p2align 4,,10
	.p2align 3
.L40:
	movl	%ebx, %eax
	xorl	%ebp, %ebp
	xorl	%r14d, %r14d
	cltd
	idivl	%r13d
	movl	%eax, %ebx
	cmpq	%rcx, %rsi
	jnb	.L63
	.p2align 4,,10
	.p2align 3
.L42:
	leaq	1(%rsi), %rdx
	movq	%rdx, 8(%rdi)
	movzbl	(%rsi), %eax
.L43:
	xorl	%r12d, %r12d
	jmp	.L47
	.p2align 4,,10
	.p2align 3
.L44:
	leaq	1(%rdx), %rax
	movq	%rax, 8(%rdi)
	movzbl	(%rdx), %eax
	cmpl	$47, %eax
	jle	.L46
.L45:
	movq	8(%rdi), %rdx
	movq	16(%rdi), %rcx
.L47:
	leal	(%r12,%r12,4), %esi
	andl	$15, %eax
	leal	(%rax,%rsi,2), %r12d
	cmpq	%rcx, %rdx
	jb	.L44
	call	__uflow@PLT
	cmpl	$47, %eax
	jle	.L46
	movq	stdin(%rip), %rdi
	jmp	.L45
	.p2align 4,,10
	.p2align 3
.L46:
	cmpl	%r12d, %ebx
	cmovle	%ebx, %r12d
	addl	$1, %r14d
	addl	%r12d, %ebp
	cmpl	%r13d, %r14d
	je	.L48
	movq	stdin(%rip), %rdi
	movq	8(%rdi), %rsi
	movq	16(%rdi), %rcx
	cmpq	%rcx, %rsi
	jb	.L42
.L63:
	call	__uflow@PLT
	movq	stdin(%rip), %rdi
	movq	8(%rdi), %rdx
	movq	16(%rdi), %rcx
	jmp	.L43
	.p2align 4,,10
	.p2align 3
.L48:
	movl	%ebp, %edi
	call	out
	jmp	.L35
.L61:
	popq	%rbx
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	xorl	%eax, %eax
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	ret
.L60:
	.cfi_restore_state
	call	__uflow@PLT
	movq	stdin(%rip), %rdi
	movq	8(%rdi), %rdx
	movq	16(%rdi), %rcx
	jmp	.L51
.L62:
	call	__uflow@PLT
	movq	stdin(%rip), %rdi
	movq	8(%rdi), %rdx
	movq	16(%rdi), %rcx
	jmp	.L37
	.cfi_endproc
.LFE25:
	.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:

// AOJ 2944 Equal Split
// 2019.8.8 bal4u

#include <stdio.h>

#if 1
#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)
#else
#define gc() getchar()
#define pc(c) putchar(c)
#endif

int in() {   // 非負整数の入力
	int n = 0, c = gc();
	do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0');
	return n;
}

void out(int n) { // 正整数の表示（出力）
	int i;
	char b[20];
	i = 0; while (n) b[i++] = n % 10 + '0', n /= 10;
	while (i--) pc(b[i]);
	pc('\n');
}

int main()
{
	int i, a, N, M, ans;
	
	while (N = in()) {
		M = in(), M /= N;
		ans = 0;
		for (i = 0; i < N; i++) {
			a = in();
			ans += (a >= M)? M: a;
		}
		out(ans);
	}
	return 0;
}

3 300
120 100 80
3 5
10 20 5
4 1000
100 200 300 400
5 5
2523 8430 3 4199 632
0 0
 3 300
120 100 80
3 5
10 20 5
4 1000
100 260 300 400
5 5
2523 8430 3 4199 632
0 0
 3 300
120 100 80
2 5
10 34 5
4 1000
100 200 300 400
5 5
2523 8430 3 4199 632
0 0
 3 300
120 101 80
3 5
10 34 5
4 1000
100 200 159 400
5 5
183 8430 3 4199 632
0 0
 3 276
120 101 80
3 5
10 34 10
4 1000
100 200 159 400
5 5
183 8430 3 4199 632
0 0
 3 276
120 101 93
3 5
10 34 10
4 1000
100 200 159 400
5 5
127 8430 3 4199 632
0 0
 3 276
120 101 93
3 5
10 34 10
4 1000
100 200 159 400
5 5
127 8430 0 4199 632
0 0
 3 300
120 010 80
2 5
12 34 5
4 0000
110 200 300 400
5 5
2523 8430 3 4199 201
0 0
 3 300
120 100 80
3 30
10 20 5
4 1000
100 200 300 400
5 5
2523 8430 3 4199 987
0 0
 3 300
120 101 80
3 5
10 34 5
4 1000
100 200 300 400
5 1
2523 8430 3 4199 632
0 0

280
3
800
5
 280
3
850
5
 280
4

5
 280
3
709
5
 264
3
709
5
 276
3
709
5
 276
3
709
4
 190
4

5
 280
25
800
5
 280
3
800


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

```c
// AOJ 2944 Equal Split
// 2019.8.8 bal4u

#include <stdio.h>

#if 1
#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)
#else
#define gc() getchar()
#define pc(c) putchar(c)
#endif

int in() {   // 非負整数の入力
	int n = 0, c = gc();
	do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0');
	return n;
}

void out(int n) { // 正整数の表示（出力）
	int i;
	char b[20];
	i = 0; while (n) b[i++] = n % 10 + '0', n /= 10;
	while (i--) pc(b[i]);
	pc('\n');
}

int main()
{
	int i, a, N, M, ans;
	
	while (N = in()) {
		M = in(), M /= N;
		ans = 0;
		for (i = 0; i < N; i++) {
			a = in();
			ans += (a >= M)? M: a;
		}
		out(ans);
	}
	return 0;
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.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), %edx
	movl	%edx, %eax
	sall	$2, %eax
	addl	%edx, %eax
	addl	%eax, %eax
	movl	%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
	.globl	out
	.type	out, @function
out:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$64, %rsp
	movl	%edi, -52(%rbp)
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -36(%rbp)
	jmp	.L5
.L6:
	movl	-52(%rbp), %edx
	movslq	%edx, %rax
	imulq	$1717986919, %rax, %rax
	shrq	$32, %rax
	sarl	$2, %eax
	movl	%edx, %esi
	sarl	$31, %esi
	subl	%esi, %eax
	movl	%eax, %ecx
	movl	%ecx, %eax
	sall	$2, %eax
	addl	%ecx, %eax
	addl	%eax, %eax
	movl	%edx, %ecx
	subl	%eax, %ecx
	movl	%ecx, %eax
	leal	48(%rax), %ecx
	movl	-36(%rbp), %eax
	leal	1(%rax), %edx
	movl	%edx, -36(%rbp)
	movl	%ecx, %edx
	cltq
	movb	%dl, -32(%rbp,%rax)
	movl	-52(%rbp), %eax
	movslq	%eax, %rdx
	imulq	$1717986919, %rdx, %rdx
	shrq	$32, %rdx
	sarl	$2, %edx
	sarl	$31, %eax
	movl	%eax, %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	movl	%eax, -52(%rbp)
.L5:
	cmpl	$0, -52(%rbp)
	jne	.L6
	jmp	.L7
.L8:
	movl	-36(%rbp), %eax
	cltq
	movzbl	-32(%rbp,%rax), %eax
	movsbl	%al, %eax
	movl	%eax, %edi
	call	putchar_unlocked@PLT
.L7:
	movl	-36(%rbp), %eax
	leal	-1(%rax), %edx
	movl	%edx, -36(%rbp)
	testl	%eax, %eax
	jne	.L8
	movl	$10, %edi
	call	putchar_unlocked@PLT
	nop
	movq	-8(%rbp), %rax
	subq	%fs:40, %rax
	je	.L9
	call	__stack_chk_fail@PLT
.L9:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	out, .-out
	.globl	main
	.type	main, @function
main:
.LFB2:
	.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	.L11
.L14:
	movl	$0, %eax
	call	in
	movl	%eax, -8(%rbp)
	movl	-8(%rbp), %eax
	cltd
	idivl	-12(%rbp)
	movl	%eax, -8(%rbp)
	movl	$0, -16(%rbp)
	movl	$0, -20(%rbp)
	jmp	.L12
.L13:
	movl	$0, %eax
	call	in
	movl	%eax, -4(%rbp)
	movl	-8(%rbp), %edx
	movl	-4(%rbp), %eax
	cmpl	%eax, %edx
	cmovle	%edx, %eax
	addl	%eax, -16(%rbp)
	addl	$1, -20(%rbp)
.L12:
	movl	-20(%rbp), %eax
	cmpl	-12(%rbp), %eax
	jl	.L13
	movl	-16(%rbp), %eax
	movl	%eax, %edi
	call	out
.L11:
	movl	$0, %eax
	call	in
	movl	%eax, -12(%rbp)
	cmpl	$0, -12(%rbp)
	jne	.L14
	movl	$0, %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2:
	.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	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), %edx
	movl	%edx, %eax
	sall	$2, %eax
	addl	%edx, %eax
	addl	%eax, %eax
	movl	%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
	.globl	out
	.type	out, @function
out:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$64, %rsp
	movl	%edi, -52(%rbp)
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -36(%rbp)
	jmp	.L5
.L6:
	movl	-52(%rbp), %edx
	movslq	%edx, %rax
	imulq	$1717986919, %rax, %rax
	shrq	$32, %rax
	sarl	$2, %eax
	movl	%edx, %esi
	sarl	$31, %esi
	subl	%esi, %eax
	movl	%eax, %ecx
	movl	%ecx, %eax
	sall	$2, %eax
	addl	%ecx, %eax
	addl	%eax, %eax
	movl	%edx, %ecx
	subl	%eax, %ecx
	movl	%ecx, %eax
	leal	48(%rax), %ecx
	movl	-36(%rbp), %eax
	leal	1(%rax), %edx
	movl	%edx, -36(%rbp)
	movl	%ecx, %edx
	cltq
	movb	%dl, -32(%rbp,%rax)
	movl	-52(%rbp), %eax
	movslq	%eax, %rdx
	imulq	$1717986919, %rdx, %rdx
	shrq	$32, %rdx
	sarl	$2, %edx
	sarl	$31, %eax
	movl	%eax, %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	movl	%eax, -52(%rbp)
.L5:
	cmpl	$0, -52(%rbp)
	jne	.L6
	jmp	.L7
.L8:
	movl	-36(%rbp), %eax
	cltq
	movzbl	-32(%rbp,%rax), %eax
	movsbl	%al, %eax
	movl	%eax, %edi
	call	putchar_unlocked@PLT
.L7:
	movl	-36(%rbp), %eax
	leal	-1(%rax), %edx
	movl	%edx, -36(%rbp)
	testl	%eax, %eax
	jne	.L8
	movl	$10, %edi
	call	putchar_unlocked@PLT
	nop
	movq	-8(%rbp), %rax
	subq	%fs:40, %rax
	je	.L9
	call	__stack_chk_fail@PLT
.L9:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	out, .-out
	.globl	main
	.type	main, @function
main:
.LFB2:
	.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	.L11
.L14:
	movl	$0, %eax
	call	in
	movl	%eax, -8(%rbp)
	movl	-8(%rbp), %eax
	cltd
	idivl	-12(%rbp)
	movl	%eax, -8(%rbp)
	movl	$0, -16(%rbp)
	movl	$0, -20(%rbp)
	jmp	.L12
.L13:
	movl	$0, %eax
	call	in
	movl	%eax, -4(%rbp)
	movl	-8(%rbp), %edx
	movl	-4(%rbp), %eax
	cmpl	%eax, %edx
	cmovle	%edx, %eax
	addl	%eax, -16(%rbp)
	addl	$1, -20(%rbp)
.L12:
	movl	-20(%rbp), %eax
	cmpl	-12(%rbp), %eax
	jl	.L13
	movl	-16(%rbp), %eax
	movl	%eax, %edi
	call	out
.L11:
	movl	$0, %eax
	call	in
	movl	%eax, -12(%rbp)
	cmpl	$0, -12(%rbp)
	jne	.L14
	movl	$0, %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2:
	.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:
