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 m, n;
int w[100];

int IsStorable( int width ) {

    int row = 0, c = 0, i = 0;

    while ( i < n ) {
	if ( c + w[i] <= width ) {
	    c += w[i];
	    ++i;
	}
	else if ( ++row < m ) c = 0;
	else return 0;
    }

    return 1;
}

int main() {
    int i, minw, maxw, mid;

    while ( scanf("%d %d", &m, &n) == 2 && m && n ) {

	for ( i=0; i<n; ++i ) scanf("%d", &w[i]);

	minw = 1;
	maxw = 1500000;
	if ( !IsStorable( maxw ) ) printf("NA\n");

	while ( maxw > minw ) {
	    mid = (maxw + minw)/2;
	    if ( IsStorable(mid) ) maxw = mid;
	    else                   minw = mid + 1;
	}

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

```

Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.p2align 4
	.globl	IsStorable
	.type	IsStorable, @function
IsStorable:
.LFB39:
	.cfi_startproc
	endbr64
	movl	n(%rip), %r8d
	testl	%r8d, %r8d
	jle	.L6
	movl	m(%rip), %r10d
	xorl	%edx, %edx
	xorl	%eax, %eax
	xorl	%esi, %esi
	leaq	w(%rip), %r9
	jmp	.L5
	.p2align 4,,10
	.p2align 3
.L10:
	addl	$1, %edx
.L4:
	cmpl	%r8d, %edx
	jge	.L6
.L5:
	movslq	%edx, %rcx
	addl	(%r9,%rcx,4), %eax
	cmpl	%edi, %eax
	jle	.L10
	addl	$1, %esi
	xorl	%eax, %eax
	cmpl	%esi, %r10d
	jg	.L4
	ret
	.p2align 4,,10
	.p2align 3
.L6:
	movl	$1, %eax
	ret
	.cfi_endproc
.LFE39:
	.size	IsStorable, .-IsStorable
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	"%d\n"
.LC2:
	.string	"%d %d"
.LC3:
	.string	"NA"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB40:
	.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
	leaq	w(%rip), %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	leaq	n(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	leaq	m(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$8, %rsp
	.cfi_def_cfa_offset 64
.L12:
	xorl	%eax, %eax
	movq	%r12, %rdx
	leaq	.LC2(%rip), %rdi
	movq	%rbp, %rsi
	call	__isoc99_scanf@PLT
	cmpl	$2, %eax
	jne	.L32
	movl	m(%rip), %r9d
	testl	%r9d, %r9d
	je	.L32
	movl	n(%rip), %r8d
	testl	%r8d, %r8d
	je	.L32
	movq	%r13, %rbx
	movl	$0, %r15d
	leaq	.LC0(%rip), %r14
	jle	.L14
	.p2align 4,,10
	.p2align 3
.L13:
	movq	%rbx, %rsi
	movq	%r14, %rdi
	xorl	%eax, %eax
	addl	$1, %r15d
	call	__isoc99_scanf@PLT
	movl	n(%rip), %r8d
	addq	$4, %rbx
	cmpl	%r15d, %r8d
	jg	.L13
	movl	m(%rip), %r9d
	testl	%r8d, %r8d
	jle	.L14
	xorl	%esi, %esi
	xorl	%eax, %eax
	xorl	%edx, %edx
	jmp	.L18
	.p2align 4,,10
	.p2align 3
.L42:
	addl	$1, %edx
	cmpl	%edx, %r8d
	jle	.L14
.L18:
	movslq	%edx, %rcx
	addl	0(%r13,%rcx,4), %eax
	cmpl	$1500000, %eax
	jle	.L42
	addl	$1, %esi
	cmpl	%r9d, %esi
	jge	.L17
	xorl	%eax, %eax
	cmpl	%edx, %r8d
	jg	.L18
.L14:
	movl	$1, %r10d
	movl	$1500000, %r11d
	.p2align 4,,10
	.p2align 3
.L28:
	leal	(%r10,%r11), %edi
	sarl	%edi
	testl	%r8d, %r8d
	jle	.L19
	xorl	%esi, %esi
	xorl	%eax, %eax
	xorl	%edx, %edx
	jmp	.L23
	.p2align 4,,10
	.p2align 3
.L43:
	addl	$1, %edx
	cmpl	%edx, %r8d
	jle	.L19
.L23:
	movslq	%edx, %rcx
	addl	0(%r13,%rcx,4), %eax
	cmpl	%eax, %edi
	jge	.L43
	addl	$1, %esi
	cmpl	%r9d, %esi
	jge	.L22
	xorl	%eax, %eax
	cmpl	%edx, %r8d
	jg	.L23
.L19:
	cmpl	%r10d, %edi
	jle	.L27
.L24:
	movl	%edi, %r11d
	jmp	.L28
.L27:
	movl	%r10d, %edx
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L12
	.p2align 4,,10
	.p2align 3
.L22:
	leal	1(%rdi), %r10d
	cmpl	%r11d, %r10d
	jge	.L27
	movl	%r11d, %edi
	jmp	.L24
.L17:
	leaq	.LC3(%rip), %rdi
	call	puts@PLT
	movl	n(%rip), %r8d
	movl	m(%rip), %r9d
	jmp	.L14
.L32:
	addq	$8, %rsp
	.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
	.cfi_endproc
.LFE40:
	.size	main, .-main
	.globl	w
	.bss
	.align 32
	.type	w, @object
	.size	w, 400
w:
	.zero	400
	.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
	.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
	.p2align 4
	.globl	IsStorable
	.type	IsStorable, @function
IsStorable:
.LFB39:
	.cfi_startproc
	endbr64
	movl	n(%rip), %r8d
	testl	%r8d, %r8d
	jle	.L6
	movl	m(%rip), %r10d
	xorl	%edx, %edx
	xorl	%eax, %eax
	xorl	%esi, %esi
	leaq	w(%rip), %r9
	jmp	.L5
	.p2align 4,,10
	.p2align 3
.L10:
	addl	$1, %edx
.L4:
	cmpl	%r8d, %edx
	jge	.L6
.L5:
	movslq	%edx, %rcx
	addl	(%r9,%rcx,4), %eax
	cmpl	%edi, %eax
	jle	.L10
	addl	$1, %esi
	xorl	%eax, %eax
	cmpl	%esi, %r10d
	jg	.L4
	ret
	.p2align 4,,10
	.p2align 3
.L6:
	movl	$1, %eax
	ret
	.cfi_endproc
.LFE39:
	.size	IsStorable, .-IsStorable
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	"%d\n"
.LC2:
	.string	"%d %d"
.LC3:
	.string	"NA"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB40:
	.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
	leaq	w(%rip), %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	leaq	n(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	leaq	m(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$8, %rsp
	.cfi_def_cfa_offset 64
.L12:
	xorl	%eax, %eax
	movq	%r12, %rdx
	leaq	.LC2(%rip), %rdi
	movq	%rbp, %rsi
	call	__isoc99_scanf@PLT
	cmpl	$2, %eax
	jne	.L32
	movl	m(%rip), %r9d
	testl	%r9d, %r9d
	je	.L32
	movl	n(%rip), %r8d
	testl	%r8d, %r8d
	je	.L32
	movq	%r13, %rbx
	movl	$0, %r15d
	leaq	.LC0(%rip), %r14
	jle	.L14
	.p2align 4,,10
	.p2align 3
.L13:
	movq	%rbx, %rsi
	movq	%r14, %rdi
	xorl	%eax, %eax
	addl	$1, %r15d
	call	__isoc99_scanf@PLT
	movl	n(%rip), %r8d
	addq	$4, %rbx
	cmpl	%r15d, %r8d
	jg	.L13
	movl	m(%rip), %r9d
	testl	%r8d, %r8d
	jle	.L14
	xorl	%esi, %esi
	xorl	%eax, %eax
	xorl	%edx, %edx
	jmp	.L18
	.p2align 4,,10
	.p2align 3
.L42:
	addl	$1, %edx
	cmpl	%edx, %r8d
	jle	.L14
.L18:
	movslq	%edx, %rcx
	addl	0(%r13,%rcx,4), %eax
	cmpl	$1500000, %eax
	jle	.L42
	addl	$1, %esi
	cmpl	%r9d, %esi
	jge	.L17
	xorl	%eax, %eax
	cmpl	%edx, %r8d
	jg	.L18
.L14:
	movl	$1, %r10d
	movl	$1500000, %r11d
	.p2align 4,,10
	.p2align 3
.L28:
	leal	(%r10,%r11), %edi
	sarl	%edi
	testl	%r8d, %r8d
	jle	.L19
	xorl	%esi, %esi
	xorl	%eax, %eax
	xorl	%edx, %edx
	jmp	.L23
	.p2align 4,,10
	.p2align 3
.L43:
	addl	$1, %edx
	cmpl	%edx, %r8d
	jle	.L19
.L23:
	movslq	%edx, %rcx
	addl	0(%r13,%rcx,4), %eax
	cmpl	%eax, %edi
	jge	.L43
	addl	$1, %esi
	cmpl	%r9d, %esi
	jge	.L22
	xorl	%eax, %eax
	cmpl	%edx, %r8d
	jg	.L23
.L19:
	cmpl	%r10d, %edi
	jle	.L27
.L24:
	movl	%edi, %r11d
	jmp	.L28
.L27:
	movl	%r10d, %edx
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L12
	.p2align 4,,10
	.p2align 3
.L22:
	leal	1(%rdi), %r10d
	cmpl	%r11d, %r10d
	jge	.L27
	movl	%r11d, %edi
	jmp	.L24
.L17:
	leaq	.LC3(%rip), %rdi
	call	puts@PLT
	movl	n(%rip), %r8d
	movl	m(%rip), %r9d
	jmp	.L14
.L32:
	addq	$8, %rsp
	.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
	.cfi_endproc
.LFE40:
	.size	main, .-main
	.globl	w
	.bss
	.align 32
	.type	w, @object
	.size	w, 400
w:
	.zero	400
	.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
	.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
	.p2align 4
	.globl	IsStorable
	.type	IsStorable, @function
IsStorable:
.LFB39:
	.cfi_startproc
	endbr64
	movl	n(%rip), %r8d
	testl	%r8d, %r8d
	jle	.L6
	movl	m(%rip), %r10d
	xorl	%edx, %edx
	xorl	%eax, %eax
	xorl	%esi, %esi
	leaq	w(%rip), %r9
	jmp	.L5
	.p2align 4,,10
	.p2align 3
.L10:
	addl	$1, %edx
.L4:
	cmpl	%r8d, %edx
	jge	.L6
.L5:
	movslq	%edx, %rcx
	addl	(%r9,%rcx,4), %eax
	cmpl	%edi, %eax
	jle	.L10
	addl	$1, %esi
	xorl	%eax, %eax
	cmpl	%esi, %r10d
	jg	.L4
	ret
	.p2align 4,,10
	.p2align 3
.L6:
	movl	$1, %eax
	ret
	.cfi_endproc
.LFE39:
	.size	IsStorable, .-IsStorable
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	"%d\n"
.LC2:
	.string	"%d %d"
.LC3:
	.string	"NA"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB40:
	.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
	leaq	w(%rip), %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	leaq	n(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	leaq	m(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$8, %rsp
	.cfi_def_cfa_offset 64
.L12:
	xorl	%eax, %eax
	movq	%r12, %rdx
	leaq	.LC2(%rip), %rdi
	movq	%rbp, %rsi
	call	__isoc99_scanf@PLT
	cmpl	$2, %eax
	jne	.L32
	movl	m(%rip), %r9d
	testl	%r9d, %r9d
	je	.L32
	movl	n(%rip), %r8d
	testl	%r8d, %r8d
	je	.L32
	movq	%r13, %rbx
	movl	$0, %r15d
	leaq	.LC0(%rip), %r14
	jle	.L14
	.p2align 4,,10
	.p2align 3
.L13:
	movq	%rbx, %rsi
	movq	%r14, %rdi
	xorl	%eax, %eax
	addl	$1, %r15d
	call	__isoc99_scanf@PLT
	movl	n(%rip), %r8d
	addq	$4, %rbx
	cmpl	%r15d, %r8d
	jg	.L13
	movl	m(%rip), %r9d
	testl	%r8d, %r8d
	jle	.L14
	xorl	%esi, %esi
	xorl	%eax, %eax
	xorl	%edx, %edx
	jmp	.L18
	.p2align 4,,10
	.p2align 3
.L42:
	addl	$1, %edx
	cmpl	%edx, %r8d
	jle	.L14
.L18:
	movslq	%edx, %rcx
	addl	0(%r13,%rcx,4), %eax
	cmpl	$1500000, %eax
	jle	.L42
	addl	$1, %esi
	cmpl	%r9d, %esi
	jge	.L17
	xorl	%eax, %eax
	cmpl	%edx, %r8d
	jg	.L18
.L14:
	movl	$1, %r10d
	movl	$1500000, %r11d
	.p2align 4,,10
	.p2align 3
.L28:
	leal	(%r10,%r11), %edi
	sarl	%edi
	testl	%r8d, %r8d
	jle	.L19
	xorl	%esi, %esi
	xorl	%eax, %eax
	xorl	%edx, %edx
	jmp	.L23
	.p2align 4,,10
	.p2align 3
.L43:
	addl	$1, %edx
	cmpl	%edx, %r8d
	jle	.L19
.L23:
	movslq	%edx, %rcx
	addl	0(%r13,%rcx,4), %eax
	cmpl	%eax, %edi
	jge	.L43
	addl	$1, %esi
	cmpl	%r9d, %esi
	jge	.L22
	xorl	%eax, %eax
	cmpl	%edx, %r8d
	jg	.L23
.L19:
	cmpl	%r10d, %edi
	jle	.L27
.L24:
	movl	%edi, %r11d
	jmp	.L28
.L27:
	movl	%r10d, %edx
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L12
	.p2align 4,,10
	.p2align 3
.L22:
	leal	1(%rdi), %r10d
	cmpl	%r11d, %r10d
	jge	.L27
	movl	%r11d, %edi
	jmp	.L24
.L17:
	leaq	.LC3(%rip), %rdi
	call	puts@PLT
	movl	n(%rip), %r8d
	movl	m(%rip), %r9d
	jmp	.L14
.L32:
	addq	$8, %rsp
	.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
	.cfi_endproc
.LFE40:
	.size	main, .-main
	.globl	w
	.bss
	.align 32
	.type	w, @object
	.size	w, 400
w:
	.zero	400
	.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
	.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 m, n;
int w[100];

int IsStorable( int width ) {

    int row = 0, c = 0, i = 0;

    while ( i < n ) {
	if ( c + w[i] <= width ) {
	    c += w[i];
	    ++i;
	}
	else if ( ++row < m ) c = 0;
	else return 0;
    }

    return 1;
}

int main() {
    int i, minw, maxw, mid;

    while ( scanf("%d %d", &m, &n) == 2 && m && n ) {

	for ( i=0; i<n; ++i ) scanf("%d", &w[i]);

	minw = 1;
	maxw = 1500000;
	if ( !IsStorable( maxw ) ) printf("NA\n");

	while ( maxw > minw ) {
	    mid = (maxw + minw)/2;
	    if ( IsStorable(mid) ) maxw = mid;
	    else                   minw = mid + 1;
	}

	printf("%d\n", minw);
    }
    
    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 m, n;
int w[100];

int IsStorable( int width ) {

    int row = 0, c = 0, i = 0;

    while ( i < n ) {
	if ( c + w[i] <= width ) {
	    c += w[i];
	    ++i;
	}
	else if ( ++row < m ) c = 0;
	else return 0;
    }

    return 1;
}

int main() {
    int i, minw, maxw, mid;

    while ( scanf("%d %d", &m, &n) == 2 && m && n ) {

	for ( i=0; i<n; ++i ) scanf("%d", &w[i]);

	minw = 1;
	maxw = 1500000;
	if ( !IsStorable( maxw ) ) printf("NA\n");

	while ( maxw > minw ) {
	    mid = (maxw + minw)/2;
	    if ( IsStorable(mid) ) maxw = mid;
	    else                   minw = mid + 1;
	}

	printf("%d\n", minw);
    }
    
    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 9
500
300
800
200
100
600
900
700
400
4 3
1000
1000
1010
0 0
 3 9
500
311
800
335
100
600
900
700
400
4 3
1000
1000
1010
0 0
 3 9
559
311
800
335
100
563
900
700
400
4 3
1000
1000
1010
0 0
 3 9
500
300
800
200
100
600
900
1032
400
4 3
1000
1000
1000
0 0
 3 9
500
300
800
200
000
600
900
700
400
4 3
1000
1000
1010
0 0
 3 9
500
253
800
335
100
600
900
700
400
4 3
1000
1000
1010
0 0
 3 9
559
311
800
335
110
600
900
700
400
4 3
1000
1000
1010
0 0
 3 9
559
311
656
335
100
563
900
700
400
4 3
1000
1000
1010
0 0
 3 9
500
300
800
200
100
871
900
1032
400
4 3
1000
1000
1000
0 0
 3 9
500
300
800
200
001
600
900
700
400
4 3
1000
1000
1010
0 0

1800
1010
 1935
1010
 1898
1010
 1800
1000
 1700
1010
 1888
1010
 1945
1010
 1861
1010
 1871
1000
 1701
1010

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 m, n;
int w[100];

int IsStorable( int width ) {

    int row = 0, c = 0, i = 0;

    while ( i < n ) {
	if ( c + w[i] <= width ) {
	    c += w[i];
	    ++i;
	}
	else if ( ++row < m ) c = 0;
	else return 0;
    }

    return 1;
}

int main() {
    int i, minw, maxw, mid;

    while ( scanf("%d %d", &m, &n) == 2 && m && n ) {

	for ( i=0; i<n; ++i ) scanf("%d", &w[i]);

	minw = 1;
	maxw = 1500000;
	if ( !IsStorable( maxw ) ) printf("NA\n");

	while ( maxw > minw ) {
	    mid = (maxw + minw)/2;
	    if ( IsStorable(mid) ) maxw = mid;
	    else                   minw = mid + 1;
	}

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

```

Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.p2align 4
	.globl	IsStorable
	.type	IsStorable, @function
IsStorable:
.LFB39:
	.cfi_startproc
	endbr64
	movl	n(%rip), %r8d
	testl	%r8d, %r8d
	jle	.L6
	movl	m(%rip), %r10d
	xorl	%edx, %edx
	xorl	%eax, %eax
	xorl	%esi, %esi
	leaq	w(%rip), %r9
	jmp	.L5
	.p2align 4,,10
	.p2align 3
.L10:
	addl	$1, %edx
.L4:
	cmpl	%r8d, %edx
	jge	.L6
.L5:
	movslq	%edx, %rcx
	addl	(%r9,%rcx,4), %eax
	cmpl	%edi, %eax
	jle	.L10
	addl	$1, %esi
	xorl	%eax, %eax
	cmpl	%esi, %r10d
	jg	.L4
	ret
	.p2align 4,,10
	.p2align 3
.L6:
	movl	$1, %eax
	ret
	.cfi_endproc
.LFE39:
	.size	IsStorable, .-IsStorable
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	"%d\n"
.LC2:
	.string	"%d %d"
.LC3:
	.string	"NA"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB40:
	.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
	leaq	w(%rip), %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	leaq	n(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	leaq	m(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$8, %rsp
	.cfi_def_cfa_offset 64
.L12:
	xorl	%eax, %eax
	movq	%r12, %rdx
	leaq	.LC2(%rip), %rdi
	movq	%rbp, %rsi
	call	__isoc99_scanf@PLT
	cmpl	$2, %eax
	jne	.L32
	movl	m(%rip), %r9d
	testl	%r9d, %r9d
	je	.L32
	movl	n(%rip), %r8d
	testl	%r8d, %r8d
	je	.L32
	movq	%r13, %rbx
	movl	$0, %r15d
	leaq	.LC0(%rip), %r14
	jle	.L14
	.p2align 4,,10
	.p2align 3
.L13:
	movq	%rbx, %rsi
	movq	%r14, %rdi
	xorl	%eax, %eax
	addl	$1, %r15d
	call	__isoc99_scanf@PLT
	movl	n(%rip), %r8d
	addq	$4, %rbx
	cmpl	%r15d, %r8d
	jg	.L13
	movl	m(%rip), %r9d
	testl	%r8d, %r8d
	jle	.L14
	xorl	%esi, %esi
	xorl	%eax, %eax
	xorl	%edx, %edx
	jmp	.L18
	.p2align 4,,10
	.p2align 3
.L42:
	addl	$1, %edx
	cmpl	%edx, %r8d
	jle	.L14
.L18:
	movslq	%edx, %rcx
	addl	0(%r13,%rcx,4), %eax
	cmpl	$1500000, %eax
	jle	.L42
	addl	$1, %esi
	cmpl	%r9d, %esi
	jge	.L17
	xorl	%eax, %eax
	cmpl	%edx, %r8d
	jg	.L18
.L14:
	movl	$1, %r10d
	movl	$1500000, %r11d
	.p2align 4,,10
	.p2align 3
.L28:
	leal	(%r10,%r11), %edi
	sarl	%edi
	testl	%r8d, %r8d
	jle	.L19
	xorl	%esi, %esi
	xorl	%eax, %eax
	xorl	%edx, %edx
	jmp	.L23
	.p2align 4,,10
	.p2align 3
.L43:
	addl	$1, %edx
	cmpl	%edx, %r8d
	jle	.L19
.L23:
	movslq	%edx, %rcx
	addl	0(%r13,%rcx,4), %eax
	cmpl	%eax, %edi
	jge	.L43
	addl	$1, %esi
	cmpl	%r9d, %esi
	jge	.L22
	xorl	%eax, %eax
	cmpl	%edx, %r8d
	jg	.L23
.L19:
	cmpl	%r10d, %edi
	jle	.L27
.L24:
	movl	%edi, %r11d
	jmp	.L28
.L27:
	movl	%r10d, %edx
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L12
	.p2align 4,,10
	.p2align 3
.L22:
	leal	1(%rdi), %r10d
	cmpl	%r11d, %r10d
	jge	.L27
	movl	%r11d, %edi
	jmp	.L24
.L17:
	leaq	.LC3(%rip), %rdi
	call	puts@PLT
	movl	n(%rip), %r8d
	movl	m(%rip), %r9d
	jmp	.L14
.L32:
	addq	$8, %rsp
	.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
	.cfi_endproc
.LFE40:
	.size	main, .-main
	.globl	w
	.bss
	.align 32
	.type	w, @object
	.size	w, 400
w:
	.zero	400
	.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
	.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
	.p2align 4
	.globl	IsStorable
	.type	IsStorable, @function
IsStorable:
.LFB39:
	.cfi_startproc
	endbr64
	movl	n(%rip), %r8d
	testl	%r8d, %r8d
	jle	.L6
	movl	m(%rip), %r10d
	xorl	%edx, %edx
	xorl	%eax, %eax
	xorl	%esi, %esi
	leaq	w(%rip), %r9
	jmp	.L5
	.p2align 4,,10
	.p2align 3
.L10:
	addl	$1, %edx
.L4:
	cmpl	%r8d, %edx
	jge	.L6
.L5:
	movslq	%edx, %rcx
	addl	(%r9,%rcx,4), %eax
	cmpl	%edi, %eax
	jle	.L10
	addl	$1, %esi
	xorl	%eax, %eax
	cmpl	%esi, %r10d
	jg	.L4
	ret
	.p2align 4,,10
	.p2align 3
.L6:
	movl	$1, %eax
	ret
	.cfi_endproc
.LFE39:
	.size	IsStorable, .-IsStorable
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	"%d\n"
.LC2:
	.string	"%d %d"
.LC3:
	.string	"NA"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB40:
	.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
	leaq	w(%rip), %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	leaq	n(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	leaq	m(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$8, %rsp
	.cfi_def_cfa_offset 64
.L12:
	xorl	%eax, %eax
	movq	%r12, %rdx
	leaq	.LC2(%rip), %rdi
	movq	%rbp, %rsi
	call	__isoc99_scanf@PLT
	cmpl	$2, %eax
	jne	.L32
	movl	m(%rip), %r9d
	testl	%r9d, %r9d
	je	.L32
	movl	n(%rip), %r8d
	testl	%r8d, %r8d
	je	.L32
	movq	%r13, %rbx
	movl	$0, %r15d
	leaq	.LC0(%rip), %r14
	jle	.L14
	.p2align 4,,10
	.p2align 3
.L13:
	movq	%rbx, %rsi
	movq	%r14, %rdi
	xorl	%eax, %eax
	addl	$1, %r15d
	call	__isoc99_scanf@PLT
	movl	n(%rip), %r8d
	addq	$4, %rbx
	cmpl	%r15d, %r8d
	jg	.L13
	movl	m(%rip), %r9d
	testl	%r8d, %r8d
	jle	.L14
	xorl	%esi, %esi
	xorl	%eax, %eax
	xorl	%edx, %edx
	jmp	.L18
	.p2align 4,,10
	.p2align 3
.L42:
	addl	$1, %edx
	cmpl	%edx, %r8d
	jle	.L14
.L18:
	movslq	%edx, %rcx
	addl	0(%r13,%rcx,4), %eax
	cmpl	$1500000, %eax
	jle	.L42
	addl	$1, %esi
	cmpl	%r9d, %esi
	jge	.L17
	xorl	%eax, %eax
	cmpl	%edx, %r8d
	jg	.L18
.L14:
	movl	$1, %r10d
	movl	$1500000, %r11d
	.p2align 4,,10
	.p2align 3
.L28:
	leal	(%r10,%r11), %edi
	sarl	%edi
	testl	%r8d, %r8d
	jle	.L19
	xorl	%esi, %esi
	xorl	%eax, %eax
	xorl	%edx, %edx
	jmp	.L23
	.p2align 4,,10
	.p2align 3
.L43:
	addl	$1, %edx
	cmpl	%edx, %r8d
	jle	.L19
.L23:
	movslq	%edx, %rcx
	addl	0(%r13,%rcx,4), %eax
	cmpl	%eax, %edi
	jge	.L43
	addl	$1, %esi
	cmpl	%r9d, %esi
	jge	.L22
	xorl	%eax, %eax
	cmpl	%edx, %r8d
	jg	.L23
.L19:
	cmpl	%r10d, %edi
	jle	.L27
.L24:
	movl	%edi, %r11d
	jmp	.L28
.L27:
	movl	%r10d, %edx
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L12
	.p2align 4,,10
	.p2align 3
.L22:
	leal	1(%rdi), %r10d
	cmpl	%r11d, %r10d
	jge	.L27
	movl	%r11d, %edi
	jmp	.L24
.L17:
	leaq	.LC3(%rip), %rdi
	call	puts@PLT
	movl	n(%rip), %r8d
	movl	m(%rip), %r9d
	jmp	.L14
.L32:
	addq	$8, %rsp
	.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
	.cfi_endproc
.LFE40:
	.size	main, .-main
	.globl	w
	.bss
	.align 32
	.type	w, @object
	.size	w, 400
w:
	.zero	400
	.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
	.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:
```