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

```c
#include<stdio.h>
#include<stdlib.h>

int main(void) {
	int N, M, x, ans = 0;
	int a;
	
	while (1) {
		scanf("%d %d", &N, &M);
		if (N == 0 && M == 0) {
			break;
		}
		x = M / N;
		for (int i = 0; i < N; i++) {
			scanf("%d", &a);
			if (x > a) ans += a;
			else ans += x;
		}
		printf("%d\n", ans);
		ans = 0;
	}

	return 0;
}


```

Assembly Code:

```assembly
	.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:
.LFB39:
	.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
	leaq	.LC1(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$56, %rsp
	.cfi_def_cfa_offset 112
	movq	%fs:40, %rax
	movq	%rax, 40(%rsp)
	xorl	%eax, %eax
	leaq	28(%rsp), %rax
	leaq	32(%rsp), %r15
	movq	%rax, 8(%rsp)
	leaq	36(%rsp), %r12
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L15:
	movl	32(%rsp), %eax
	testl	%eax, %eax
	je	.L14
.L4:
	movl	%r13d, %edx
	leaq	.LC2(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L8:
	movq	8(%rsp), %rsi
	movq	%r15, %rdx
	leaq	.LC0(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	28(%rsp), %r13d
	testl	%r13d, %r13d
	je	.L15
	movl	32(%rsp), %eax
	cltd
	idivl	%r13d
	movl	%eax, %ebx
	testl	%r13d, %r13d
	jle	.L10
	xorl	%r14d, %r14d
	xorl	%r13d, %r13d
	.p2align 4,,10
	.p2align 3
.L7:
	xorl	%eax, %eax
	movq	%r12, %rsi
	movq	%rbp, %rdi
	call	__isoc99_scanf@PLT
	movl	36(%rsp), %eax
	leal	0(%r13,%rbx), %r8d
	leal	0(%r13,%rax), %ecx
	cmpl	%ebx, %eax
	cmovge	%r8d, %ecx
	addl	$1, %r14d
	movl	%ecx, %r13d
	cmpl	%r14d, 28(%rsp)
	jg	.L7
	jmp	.L4
.L14:
	movq	40(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L16
	addq	$56, %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
.L10:
	.cfi_restore_state
	xorl	%r13d, %r13d
	jmp	.L4
.L16:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE39:
	.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.
Optimized Assembly Code:

user
```assembly
	.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:
.LFB39:
	.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
	leaq	.LC1(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$56, %rsp
	.cfi_def_cfa_offset 112
	movq	%fs:40, %rax
	movq	%rax, 40(%rsp)
	xorl	%eax, %eax
	leaq	28(%rsp), %rax
	leaq	32(%rsp), %r15
	movq	%rax, 8(%rsp)
	leaq	36(%rsp), %r12
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L15:
	movl	32(%rsp), %eax
	testl	%eax, %eax
	je	.L14
.L4:
	movl	%r13d, %edx
	leaq	.LC2(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L8:
	movq	8(%rsp), %rsi
	movq	%r15, %rdx
	leaq	.LC0(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	28(%rsp), %r13d
	testl	%r13d, %r13d
	je	.L15
	movl	32(%rsp), %eax
	cltd
	idivl	%r13d
	movl	%eax, %ebx
	testl	%r13d, %r13d
	jle	.L10
	xorl	%r14d, %r14d
	xorl	%r13d, %r13d
	.p2align 4,,10
	.p2align 3
.L7:
	xorl	%eax, %eax
	movq	%r12, %rsi
	movq	%rbp, %rdi
	call	__isoc99_scanf@PLT
	movl	36(%rsp), %eax
	leal	0(%r13,%rbx), %r8d
	leal	0(%r13,%rax), %ecx
	cmpl	%ebx, %eax
	cmovge	%r8d, %ecx
	addl	$1, %r14d
	movl	%ecx, %r13d
	cmpl	%r14d, 28(%rsp)
	jg	.L7
	jmp	.L4
.L14:
	movq	40(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L16
	addq	$56, %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
.L10:
	.cfi_restore_state
	xorl	%r13d, %r13d
	jmp	.L4
.L16:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE39:
	.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
```assembly
	.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:
.LFB39:
	.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
	leaq	.LC1(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$56, %rsp
	.cfi_def_cfa_offset 112
	movq	%fs:40, %rax
	movq	%rax, 40(%rsp)
	xorl	%eax, %eax
	leaq	28(%rsp), %rax
	leaq	32(%rsp), %r15
	movq	%rax, 8(%rsp)
	leaq	36(%rsp), %r12
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L15:
	movl	32(%rsp), %eax
	testl	%eax, %eax
	je	.L14
.L4:
	movl	%r13d, %edx
	leaq	.LC2(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L8:
	movq	8(%rsp), %rsi
	movq	%r15, %rdx
	leaq	.LC0(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	28(%rsp), %r13d
	testl	%r13d, %r13d
	je	.L15
	movl	32(%rsp), %eax
	cltd
	idivl	%r13d
	movl	%eax, %ebx
	testl	%r13d, %r13d
	jle	.L10
	xorl	%r14d, %r14d
	xorl	%r13d, %r13d
	.p2align 4,,10
	.p2align 3
.L7:
	xorl	%eax, %eax
	movq	%r12, %rsi
	movq	%rbp, %rdi
	call	__isoc99_scanf@PLT
	movl	36(%rsp), %eax
	leal	0(%r13,%rbx), %r8d
	leal	0(%r13,%rax), %ecx
	cmpl	%ebx, %eax
	cmovge	%r8d, %ecx
	addl	$1, %r14d
	movl	%ecx, %r13d
	cmpl	%r14d, 28(%rsp)
	jg	.L7
	jmp	.L4
.L14:
	movq	40(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L16
	addq	$56, %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
.L10:
	.cfi_restore_state
	xorl	%r13d, %r13d
	jmp	.L4
.L16:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE39:
	.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:
```
```c
#include<stdio.h>
#include<stdlib.h>

int main(void) {
	int N, M, x, ans = 0;
	int a;
	
	while (1) {
		scanf("%d %d", &N, &M);
		if (N == 0 && M == 0) {
			break;
		}
		x = M / N;
		for (int i = 0; i < N; i++) {
			scanf("%d", &a);
			if (x > a) ans += a;
			else ans += x;
		}
		printf("%d\n", ans);
		ans = 0;
	}

	return 0;
}


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

```c
#include<stdio.h>
#include<stdlib.h>

int main(void) {
	int N, M, x, ans = 0;
	int a;
	
	while (1) {
		scanf("%d %d", &N, &M);
		if (N == 0 && M == 0) {
			break;
		}
		x = M / N;
		for (int i = 0; i < N; i++) {
			scanf("%d", &a);
			if (x > a) ans += a;
			else ans += x;
		}
		printf("%d\n", ans);
		ans = 0;
	}

	return 0;
}


```

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.
Optimized Assembly Code:

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
0
5
 280
3
709
5
 264
3
709
5
 276
3
709
5
 276
3
709
4
 190
4
0
5
 280
25
800
5
 280
3
800
0

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

```c
#include<stdio.h>
#include<stdlib.h>

int main(void) {
	int N, M, x, ans = 0;
	int a;
	
	while (1) {
		scanf("%d %d", &N, &M);
		if (N == 0 && M == 0) {
			break;
		}
		x = M / N;
		for (int i = 0; i < N; i++) {
			scanf("%d", &a);
			if (x > a) ans += a;
			else ans += x;
		}
		printf("%d\n", ans);
		ans = 0;
	}

	return 0;
}


```

Assembly Code:

```assembly
	.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:
.LFB39:
	.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
	leaq	.LC1(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$56, %rsp
	.cfi_def_cfa_offset 112
	movq	%fs:40, %rax
	movq	%rax, 40(%rsp)
	xorl	%eax, %eax
	leaq	28(%rsp), %rax
	leaq	32(%rsp), %r15
	movq	%rax, 8(%rsp)
	leaq	36(%rsp), %r12
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L15:
	movl	32(%rsp), %eax
	testl	%eax, %eax
	je	.L14
.L4:
	movl	%r13d, %edx
	leaq	.LC2(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L8:
	movq	8(%rsp), %rsi
	movq	%r15, %rdx
	leaq	.LC0(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	28(%rsp), %r13d
	testl	%r13d, %r13d
	je	.L15
	movl	32(%rsp), %eax
	cltd
	idivl	%r13d
	movl	%eax, %ebx
	testl	%r13d, %r13d
	jle	.L10
	xorl	%r14d, %r14d
	xorl	%r13d, %r13d
	.p2align 4,,10
	.p2align 3
.L7:
	xorl	%eax, %eax
	movq	%r12, %rsi
	movq	%rbp, %rdi
	call	__isoc99_scanf@PLT
	movl	36(%rsp), %eax
	leal	0(%r13,%rbx), %r8d
	leal	0(%r13,%rax), %ecx
	cmpl	%ebx, %eax
	cmovge	%r8d, %ecx
	addl	$1, %r14d
	movl	%ecx, %r13d
	cmpl	%r14d, 28(%rsp)
	jg	.L7
	jmp	.L4
.L14:
	movq	40(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L16
	addq	$56, %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
.L10:
	.cfi_restore_state
	xorl	%r13d, %r13d
	jmp	.L4
.L16:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE39:
	.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.
Optimized Assembly Code:

train
```assembly
	.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:
.LFB39:
	.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
	leaq	.LC1(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$56, %rsp
	.cfi_def_cfa_offset 112
	movq	%fs:40, %rax
	movq	%rax, 40(%rsp)
	xorl	%eax, %eax
	leaq	28(%rsp), %rax
	leaq	32(%rsp), %r15
	movq	%rax, 8(%rsp)
	leaq	36(%rsp), %r12
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L15:
	movl	32(%rsp), %eax
	testl	%eax, %eax
	je	.L14
.L4:
	movl	%r13d, %edx
	leaq	.LC2(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L8:
	movq	8(%rsp), %rsi
	movq	%r15, %rdx
	leaq	.LC0(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	28(%rsp), %r13d
	testl	%r13d, %r13d
	je	.L15
	movl	32(%rsp), %eax
	cltd
	idivl	%r13d
	movl	%eax, %ebx
	testl	%r13d, %r13d
	jle	.L10
	xorl	%r14d, %r14d
	xorl	%r13d, %r13d
	.p2align 4,,10
	.p2align 3
.L7:
	xorl	%eax, %eax
	movq	%r12, %rsi
	movq	%rbp, %rdi
	call	__isoc99_scanf@PLT
	movl	36(%rsp), %eax
	leal	0(%r13,%rbx), %r8d
	leal	0(%r13,%rax), %ecx
	cmpl	%ebx, %eax
	cmovge	%r8d, %ecx
	addl	$1, %r14d
	movl	%ecx, %r13d
	cmpl	%r14d, 28(%rsp)
	jg	.L7
	jmp	.L4
.L14:
	movq	40(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L16
	addq	$56, %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
.L10:
	.cfi_restore_state
	xorl	%r13d, %r13d
	jmp	.L4
.L16:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE39:
	.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:
```