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>

int m,n;
int thickness[100];

int ok(int x){
	int i,j=0,w;
	for(i=0;i<m;i++){
		w=x;
		while(j<n&&thickness[j]<=w)w-=thickness[j++];
		if(j==n)break;
	}
	return j==n;
}
int main(){
	int i,l,mid,r;
	while(scanf("%d%d",&m,&n)==2&&(m||n)){
		for(i=0;i<n;i++)scanf("%d",&thickness[i]);
		l=1;r=1500000;
		while(1<r-l){
			mid=(l+r)/2;
			if(ok(mid))r=mid;
			else l=mid;
		}
		printf("%d\n",r);
	}
}```

Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.p2align 4
	.globl	ok
	.type	ok, @function
ok:
.LFB23:
	.cfi_startproc
	endbr64
	movl	m(%rip), %r10d
	movl	n(%rip), %r8d
	xorl	%eax, %eax
	xorl	%r9d, %r9d
	leaq	thickness(%rip), %r11
	testl	%r10d, %r10d
	jle	.L22
	.p2align 4,,10
	.p2align 3
.L2:
	cmpl	%r8d, %eax
	jge	.L10
	movslq	%eax, %rdx
	leaq	(%r11,%rdx,4), %rcx
	movl	%edi, %edx
	jmp	.L11
	.p2align 4,,10
	.p2align 3
.L5:
	addl	$1, %eax
	subl	%esi, %edx
	addq	$4, %rcx
	cmpl	%r8d, %eax
	je	.L15
.L11:
	movl	(%rcx), %esi
	cmpl	%edx, %esi
	jle	.L5
	addl	$1, %r9d
	cmpl	%r10d, %r9d
	jne	.L2
.L8:
	cmpl	%r8d, %eax
	sete	%al
	movzbl	%al, %eax
	ret
.L10:
	je	.L15
	leal	1(%r9), %edx
	cmpl	%r10d, %edx
	je	.L8
.L7:
	addl	$1, %edx
	cmpl	%edx, %r10d
	jle	.L8
	cmpl	%r8d, %eax
	jne	.L7
.L15:
	movl	$1, %eax
	ret
.L22:
	xorl	%eax, %eax
	testl	%r8d, %r8d
	sete	%al
	ret
	.cfi_endproc
.LFE23:
	.size	ok, .-ok
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	"%d\n"
.LC2:
	.string	"%d%d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB24:
	.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	thickness(%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
	leaq	.LC0(%rip), %rbx
	subq	$8, %rsp
	.cfi_def_cfa_offset 64
.L24:
	xorl	%eax, %eax
	movq	%r12, %rdx
	leaq	.LC2(%rip), %rdi
	movq	%rbp, %rsi
	call	__isoc99_scanf@PLT
	cmpl	$2, %eax
	jne	.L44
	movl	m(%rip), %r10d
	movl	n(%rip), %edi
	movl	%r10d, %eax
	orl	%edi, %eax
	je	.L44
	leaq	thickness(%rip), %r15
	xorl	%r14d, %r14d
	testl	%edi, %edi
	jle	.L40
.L25:
	movq	%r15, %rsi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	addl	$1, %r14d
	call	__isoc99_scanf@PLT
	movl	n(%rip), %edi
	addq	$4, %r15
	cmpl	%r14d, %edi
	jg	.L25
	movl	m(%rip), %r10d
.L40:
	movl	$1, %r15d
	movl	$1500000, %r11d
	.p2align 4,,10
	.p2align 3
.L26:
	leal	(%r15,%r11), %eax
	movl	$1, %r8d
	movl	%eax, %r9d
	shrl	$31, %r9d
	addl	%eax, %r9d
	xorl	%eax, %eax
	sarl	%r9d
	movl	%r9d, %r14d
	testl	%r10d, %r10d
	jle	.L28
	cmpl	%eax, %edi
	jle	.L34
	.p2align 4,,10
	.p2align 3
.L55:
	movslq	%eax, %rdx
	leaq	0(%r13,%rdx,4), %rcx
	movl	%r9d, %edx
	jmp	.L35
	.p2align 4,,10
	.p2align 3
.L30:
	addl	$1, %eax
	subl	%esi, %edx
	addq	$4, %rcx
	cmpl	%edi, %eax
	je	.L29
.L35:
	movl	(%rcx), %esi
	cmpl	%edx, %esi
	jle	.L30
	cmpl	%r10d, %r8d
	jge	.L28
	addl	$1, %r8d
	cmpl	%eax, %edi
	jg	.L55
.L34:
	je	.L29
.L32:
	movl	%r11d, %eax
	subl	%r9d, %eax
	cmpl	$1, %eax
	jle	.L56
	movl	%r9d, %r15d
	movl	%r11d, %r14d
	.p2align 4,,10
	.p2align 3
.L36:
	movl	%r14d, %r11d
	jmp	.L26
.L28:
	cmpl	%eax, %edi
	jne	.L32
	.p2align 4,,10
	.p2align 3
.L29:
	subl	%r15d, %r9d
	cmpl	$1, %r9d
	jg	.L36
.L37:
	movl	%r14d, %edx
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L24
.L44:
	addq	$8, %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
.L56:
	.cfi_restore_state
	movl	%r11d, %r14d
	jmp	.L37
	.cfi_endproc
.LFE24:
	.size	main, .-main
	.globl	thickness
	.bss
	.align 32
	.type	thickness, @object
	.size	thickness, 400
thickness:
	.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	ok
	.type	ok, @function
ok:
.LFB23:
	.cfi_startproc
	endbr64
	movl	m(%rip), %r10d
	movl	n(%rip), %r8d
	xorl	%eax, %eax
	xorl	%r9d, %r9d
	leaq	thickness(%rip), %r11
	testl	%r10d, %r10d
	jle	.L22
	.p2align 4,,10
	.p2align 3
.L2:
	cmpl	%r8d, %eax
	jge	.L10
	movslq	%eax, %rdx
	leaq	(%r11,%rdx,4), %rcx
	movl	%edi, %edx
	jmp	.L11
	.p2align 4,,10
	.p2align 3
.L5:
	addl	$1, %eax
	subl	%esi, %edx
	addq	$4, %rcx
	cmpl	%r8d, %eax
	je	.L15
.L11:
	movl	(%rcx), %esi
	cmpl	%edx, %esi
	jle	.L5
	addl	$1, %r9d
	cmpl	%r10d, %r9d
	jne	.L2
.L8:
	cmpl	%r8d, %eax
	sete	%al
	movzbl	%al, %eax
	ret
.L10:
	je	.L15
	leal	1(%r9), %edx
	cmpl	%r10d, %edx
	je	.L8
.L7:
	addl	$1, %edx
	cmpl	%edx, %r10d
	jle	.L8
	cmpl	%r8d, %eax
	jne	.L7
.L15:
	movl	$1, %eax
	ret
.L22:
	xorl	%eax, %eax
	testl	%r8d, %r8d
	sete	%al
	ret
	.cfi_endproc
.LFE23:
	.size	ok, .-ok
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	"%d\n"
.LC2:
	.string	"%d%d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB24:
	.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	thickness(%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
	leaq	.LC0(%rip), %rbx
	subq	$8, %rsp
	.cfi_def_cfa_offset 64
.L24:
	xorl	%eax, %eax
	movq	%r12, %rdx
	leaq	.LC2(%rip), %rdi
	movq	%rbp, %rsi
	call	__isoc99_scanf@PLT
	cmpl	$2, %eax
	jne	.L44
	movl	m(%rip), %r10d
	movl	n(%rip), %edi
	movl	%r10d, %eax
	orl	%edi, %eax
	je	.L44
	leaq	thickness(%rip), %r15
	xorl	%r14d, %r14d
	testl	%edi, %edi
	jle	.L40
.L25:
	movq	%r15, %rsi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	addl	$1, %r14d
	call	__isoc99_scanf@PLT
	movl	n(%rip), %edi
	addq	$4, %r15
	cmpl	%r14d, %edi
	jg	.L25
	movl	m(%rip), %r10d
.L40:
	movl	$1, %r15d
	movl	$1500000, %r11d
	.p2align 4,,10
	.p2align 3
.L26:
	leal	(%r15,%r11), %eax
	movl	$1, %r8d
	movl	%eax, %r9d
	shrl	$31, %r9d
	addl	%eax, %r9d
	xorl	%eax, %eax
	sarl	%r9d
	movl	%r9d, %r14d
	testl	%r10d, %r10d
	jle	.L28
	cmpl	%eax, %edi
	jle	.L34
	.p2align 4,,10
	.p2align 3
.L55:
	movslq	%eax, %rdx
	leaq	0(%r13,%rdx,4), %rcx
	movl	%r9d, %edx
	jmp	.L35
	.p2align 4,,10
	.p2align 3
.L30:
	addl	$1, %eax
	subl	%esi, %edx
	addq	$4, %rcx
	cmpl	%edi, %eax
	je	.L29
.L35:
	movl	(%rcx), %esi
	cmpl	%edx, %esi
	jle	.L30
	cmpl	%r10d, %r8d
	jge	.L28
	addl	$1, %r8d
	cmpl	%eax, %edi
	jg	.L55
.L34:
	je	.L29
.L32:
	movl	%r11d, %eax
	subl	%r9d, %eax
	cmpl	$1, %eax
	jle	.L56
	movl	%r9d, %r15d
	movl	%r11d, %r14d
	.p2align 4,,10
	.p2align 3
.L36:
	movl	%r14d, %r11d
	jmp	.L26
.L28:
	cmpl	%eax, %edi
	jne	.L32
	.p2align 4,,10
	.p2align 3
.L29:
	subl	%r15d, %r9d
	cmpl	$1, %r9d
	jg	.L36
.L37:
	movl	%r14d, %edx
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L24
.L44:
	addq	$8, %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
.L56:
	.cfi_restore_state
	movl	%r11d, %r14d
	jmp	.L37
	.cfi_endproc
.LFE24:
	.size	main, .-main
	.globl	thickness
	.bss
	.align 32
	.type	thickness, @object
	.size	thickness, 400
thickness:
	.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	ok
	.type	ok, @function
ok:
.LFB23:
	.cfi_startproc
	endbr64
	movl	m(%rip), %r10d
	movl	n(%rip), %r8d
	xorl	%eax, %eax
	xorl	%r9d, %r9d
	leaq	thickness(%rip), %r11
	testl	%r10d, %r10d
	jle	.L22
	.p2align 4,,10
	.p2align 3
.L2:
	cmpl	%r8d, %eax
	jge	.L10
	movslq	%eax, %rdx
	leaq	(%r11,%rdx,4), %rcx
	movl	%edi, %edx
	jmp	.L11
	.p2align 4,,10
	.p2align 3
.L5:
	addl	$1, %eax
	subl	%esi, %edx
	addq	$4, %rcx
	cmpl	%r8d, %eax
	je	.L15
.L11:
	movl	(%rcx), %esi
	cmpl	%edx, %esi
	jle	.L5
	addl	$1, %r9d
	cmpl	%r10d, %r9d
	jne	.L2
.L8:
	cmpl	%r8d, %eax
	sete	%al
	movzbl	%al, %eax
	ret
.L10:
	je	.L15
	leal	1(%r9), %edx
	cmpl	%r10d, %edx
	je	.L8
.L7:
	addl	$1, %edx
	cmpl	%edx, %r10d
	jle	.L8
	cmpl	%r8d, %eax
	jne	.L7
.L15:
	movl	$1, %eax
	ret
.L22:
	xorl	%eax, %eax
	testl	%r8d, %r8d
	sete	%al
	ret
	.cfi_endproc
.LFE23:
	.size	ok, .-ok
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	"%d\n"
.LC2:
	.string	"%d%d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB24:
	.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	thickness(%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
	leaq	.LC0(%rip), %rbx
	subq	$8, %rsp
	.cfi_def_cfa_offset 64
.L24:
	xorl	%eax, %eax
	movq	%r12, %rdx
	leaq	.LC2(%rip), %rdi
	movq	%rbp, %rsi
	call	__isoc99_scanf@PLT
	cmpl	$2, %eax
	jne	.L44
	movl	m(%rip), %r10d
	movl	n(%rip), %edi
	movl	%r10d, %eax
	orl	%edi, %eax
	je	.L44
	leaq	thickness(%rip), %r15
	xorl	%r14d, %r14d
	testl	%edi, %edi
	jle	.L40
.L25:
	movq	%r15, %rsi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	addl	$1, %r14d
	call	__isoc99_scanf@PLT
	movl	n(%rip), %edi
	addq	$4, %r15
	cmpl	%r14d, %edi
	jg	.L25
	movl	m(%rip), %r10d
.L40:
	movl	$1, %r15d
	movl	$1500000, %r11d
	.p2align 4,,10
	.p2align 3
.L26:
	leal	(%r15,%r11), %eax
	movl	$1, %r8d
	movl	%eax, %r9d
	shrl	$31, %r9d
	addl	%eax, %r9d
	xorl	%eax, %eax
	sarl	%r9d
	movl	%r9d, %r14d
	testl	%r10d, %r10d
	jle	.L28
	cmpl	%eax, %edi
	jle	.L34
	.p2align 4,,10
	.p2align 3
.L55:
	movslq	%eax, %rdx
	leaq	0(%r13,%rdx,4), %rcx
	movl	%r9d, %edx
	jmp	.L35
	.p2align 4,,10
	.p2align 3
.L30:
	addl	$1, %eax
	subl	%esi, %edx
	addq	$4, %rcx
	cmpl	%edi, %eax
	je	.L29
.L35:
	movl	(%rcx), %esi
	cmpl	%edx, %esi
	jle	.L30
	cmpl	%r10d, %r8d
	jge	.L28
	addl	$1, %r8d
	cmpl	%eax, %edi
	jg	.L55
.L34:
	je	.L29
.L32:
	movl	%r11d, %eax
	subl	%r9d, %eax
	cmpl	$1, %eax
	jle	.L56
	movl	%r9d, %r15d
	movl	%r11d, %r14d
	.p2align 4,,10
	.p2align 3
.L36:
	movl	%r14d, %r11d
	jmp	.L26
.L28:
	cmpl	%eax, %edi
	jne	.L32
	.p2align 4,,10
	.p2align 3
.L29:
	subl	%r15d, %r9d
	cmpl	$1, %r9d
	jg	.L36
.L37:
	movl	%r14d, %edx
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L24
.L44:
	addq	$8, %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
.L56:
	.cfi_restore_state
	movl	%r11d, %r14d
	jmp	.L37
	.cfi_endproc
.LFE24:
	.size	main, .-main
	.globl	thickness
	.bss
	.align 32
	.type	thickness, @object
	.size	thickness, 400
thickness:
	.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>

int m,n;
int thickness[100];

int ok(int x){
	int i,j=0,w;
	for(i=0;i<m;i++){
		w=x;
		while(j<n&&thickness[j]<=w)w-=thickness[j++];
		if(j==n)break;
	}
	return j==n;
}
int main(){
	int i,l,mid,r;
	while(scanf("%d%d",&m,&n)==2&&(m||n)){
		for(i=0;i<n;i++)scanf("%d",&thickness[i]);
		l=1;r=1500000;
		while(1<r-l){
			mid=(l+r)/2;
			if(ok(mid))r=mid;
			else l=mid;
		}
		printf("%d\n",r);
	}
}```
Given the following C code, your task is to generate highly optimized x86-64 assembly code.
C Code:

```c
#include<stdio.h>

int m,n;
int thickness[100];

int ok(int x){
	int i,j=0,w;
	for(i=0;i<m;i++){
		w=x;
		while(j<n&&thickness[j]<=w)w-=thickness[j++];
		if(j==n)break;
	}
	return j==n;
}
int main(){
	int i,l,mid,r;
	while(scanf("%d%d",&m,&n)==2&&(m||n)){
		for(i=0;i<n;i++)scanf("%d",&thickness[i]);
		l=1;r=1500000;
		while(1<r-l){
			mid=(l+r)/2;
			if(ok(mid))r=mid;
			else l=mid;
		}
		printf("%d\n",r);
	}
}```

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>

int m,n;
int thickness[100];

int ok(int x){
	int i,j=0,w;
	for(i=0;i<m;i++){
		w=x;
		while(j<n&&thickness[j]<=w)w-=thickness[j++];
		if(j==n)break;
	}
	return j==n;
}
int main(){
	int i,l,mid,r;
	while(scanf("%d%d",&m,&n)==2&&(m||n)){
		for(i=0;i<n;i++)scanf("%d",&thickness[i]);
		l=1;r=1500000;
		while(1<r-l){
			mid=(l+r)/2;
			if(ok(mid))r=mid;
			else l=mid;
		}
		printf("%d\n",r);
	}
}```

Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.p2align 4
	.globl	ok
	.type	ok, @function
ok:
.LFB23:
	.cfi_startproc
	endbr64
	movl	m(%rip), %r10d
	movl	n(%rip), %r8d
	xorl	%eax, %eax
	xorl	%r9d, %r9d
	leaq	thickness(%rip), %r11
	testl	%r10d, %r10d
	jle	.L22
	.p2align 4,,10
	.p2align 3
.L2:
	cmpl	%r8d, %eax
	jge	.L10
	movslq	%eax, %rdx
	leaq	(%r11,%rdx,4), %rcx
	movl	%edi, %edx
	jmp	.L11
	.p2align 4,,10
	.p2align 3
.L5:
	addl	$1, %eax
	subl	%esi, %edx
	addq	$4, %rcx
	cmpl	%r8d, %eax
	je	.L15
.L11:
	movl	(%rcx), %esi
	cmpl	%edx, %esi
	jle	.L5
	addl	$1, %r9d
	cmpl	%r10d, %r9d
	jne	.L2
.L8:
	cmpl	%r8d, %eax
	sete	%al
	movzbl	%al, %eax
	ret
.L10:
	je	.L15
	leal	1(%r9), %edx
	cmpl	%r10d, %edx
	je	.L8
.L7:
	addl	$1, %edx
	cmpl	%edx, %r10d
	jle	.L8
	cmpl	%r8d, %eax
	jne	.L7
.L15:
	movl	$1, %eax
	ret
.L22:
	xorl	%eax, %eax
	testl	%r8d, %r8d
	sete	%al
	ret
	.cfi_endproc
.LFE23:
	.size	ok, .-ok
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	"%d\n"
.LC2:
	.string	"%d%d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB24:
	.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	thickness(%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
	leaq	.LC0(%rip), %rbx
	subq	$8, %rsp
	.cfi_def_cfa_offset 64
.L24:
	xorl	%eax, %eax
	movq	%r12, %rdx
	leaq	.LC2(%rip), %rdi
	movq	%rbp, %rsi
	call	__isoc99_scanf@PLT
	cmpl	$2, %eax
	jne	.L44
	movl	m(%rip), %r10d
	movl	n(%rip), %edi
	movl	%r10d, %eax
	orl	%edi, %eax
	je	.L44
	leaq	thickness(%rip), %r15
	xorl	%r14d, %r14d
	testl	%edi, %edi
	jle	.L40
.L25:
	movq	%r15, %rsi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	addl	$1, %r14d
	call	__isoc99_scanf@PLT
	movl	n(%rip), %edi
	addq	$4, %r15
	cmpl	%r14d, %edi
	jg	.L25
	movl	m(%rip), %r10d
.L40:
	movl	$1, %r15d
	movl	$1500000, %r11d
	.p2align 4,,10
	.p2align 3
.L26:
	leal	(%r15,%r11), %eax
	movl	$1, %r8d
	movl	%eax, %r9d
	shrl	$31, %r9d
	addl	%eax, %r9d
	xorl	%eax, %eax
	sarl	%r9d
	movl	%r9d, %r14d
	testl	%r10d, %r10d
	jle	.L28
	cmpl	%eax, %edi
	jle	.L34
	.p2align 4,,10
	.p2align 3
.L55:
	movslq	%eax, %rdx
	leaq	0(%r13,%rdx,4), %rcx
	movl	%r9d, %edx
	jmp	.L35
	.p2align 4,,10
	.p2align 3
.L30:
	addl	$1, %eax
	subl	%esi, %edx
	addq	$4, %rcx
	cmpl	%edi, %eax
	je	.L29
.L35:
	movl	(%rcx), %esi
	cmpl	%edx, %esi
	jle	.L30
	cmpl	%r10d, %r8d
	jge	.L28
	addl	$1, %r8d
	cmpl	%eax, %edi
	jg	.L55
.L34:
	je	.L29
.L32:
	movl	%r11d, %eax
	subl	%r9d, %eax
	cmpl	$1, %eax
	jle	.L56
	movl	%r9d, %r15d
	movl	%r11d, %r14d
	.p2align 4,,10
	.p2align 3
.L36:
	movl	%r14d, %r11d
	jmp	.L26
.L28:
	cmpl	%eax, %edi
	jne	.L32
	.p2align 4,,10
	.p2align 3
.L29:
	subl	%r15d, %r9d
	cmpl	$1, %r9d
	jg	.L36
.L37:
	movl	%r14d, %edx
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L24
.L44:
	addq	$8, %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
.L56:
	.cfi_restore_state
	movl	%r11d, %r14d
	jmp	.L37
	.cfi_endproc
.LFE24:
	.size	main, .-main
	.globl	thickness
	.bss
	.align 32
	.type	thickness, @object
	.size	thickness, 400
thickness:
	.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	ok
	.type	ok, @function
ok:
.LFB23:
	.cfi_startproc
	endbr64
	movl	m(%rip), %r10d
	movl	n(%rip), %r8d
	xorl	%eax, %eax
	xorl	%r9d, %r9d
	leaq	thickness(%rip), %r11
	testl	%r10d, %r10d
	jle	.L22
	.p2align 4,,10
	.p2align 3
.L2:
	cmpl	%r8d, %eax
	jge	.L10
	movslq	%eax, %rdx
	leaq	(%r11,%rdx,4), %rcx
	movl	%edi, %edx
	jmp	.L11
	.p2align 4,,10
	.p2align 3
.L5:
	addl	$1, %eax
	subl	%esi, %edx
	addq	$4, %rcx
	cmpl	%r8d, %eax
	je	.L15
.L11:
	movl	(%rcx), %esi
	cmpl	%edx, %esi
	jle	.L5
	addl	$1, %r9d
	cmpl	%r10d, %r9d
	jne	.L2
.L8:
	cmpl	%r8d, %eax
	sete	%al
	movzbl	%al, %eax
	ret
.L10:
	je	.L15
	leal	1(%r9), %edx
	cmpl	%r10d, %edx
	je	.L8
.L7:
	addl	$1, %edx
	cmpl	%edx, %r10d
	jle	.L8
	cmpl	%r8d, %eax
	jne	.L7
.L15:
	movl	$1, %eax
	ret
.L22:
	xorl	%eax, %eax
	testl	%r8d, %r8d
	sete	%al
	ret
	.cfi_endproc
.LFE23:
	.size	ok, .-ok
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	"%d\n"
.LC2:
	.string	"%d%d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB24:
	.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	thickness(%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
	leaq	.LC0(%rip), %rbx
	subq	$8, %rsp
	.cfi_def_cfa_offset 64
.L24:
	xorl	%eax, %eax
	movq	%r12, %rdx
	leaq	.LC2(%rip), %rdi
	movq	%rbp, %rsi
	call	__isoc99_scanf@PLT
	cmpl	$2, %eax
	jne	.L44
	movl	m(%rip), %r10d
	movl	n(%rip), %edi
	movl	%r10d, %eax
	orl	%edi, %eax
	je	.L44
	leaq	thickness(%rip), %r15
	xorl	%r14d, %r14d
	testl	%edi, %edi
	jle	.L40
.L25:
	movq	%r15, %rsi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	addl	$1, %r14d
	call	__isoc99_scanf@PLT
	movl	n(%rip), %edi
	addq	$4, %r15
	cmpl	%r14d, %edi
	jg	.L25
	movl	m(%rip), %r10d
.L40:
	movl	$1, %r15d
	movl	$1500000, %r11d
	.p2align 4,,10
	.p2align 3
.L26:
	leal	(%r15,%r11), %eax
	movl	$1, %r8d
	movl	%eax, %r9d
	shrl	$31, %r9d
	addl	%eax, %r9d
	xorl	%eax, %eax
	sarl	%r9d
	movl	%r9d, %r14d
	testl	%r10d, %r10d
	jle	.L28
	cmpl	%eax, %edi
	jle	.L34
	.p2align 4,,10
	.p2align 3
.L55:
	movslq	%eax, %rdx
	leaq	0(%r13,%rdx,4), %rcx
	movl	%r9d, %edx
	jmp	.L35
	.p2align 4,,10
	.p2align 3
.L30:
	addl	$1, %eax
	subl	%esi, %edx
	addq	$4, %rcx
	cmpl	%edi, %eax
	je	.L29
.L35:
	movl	(%rcx), %esi
	cmpl	%edx, %esi
	jle	.L30
	cmpl	%r10d, %r8d
	jge	.L28
	addl	$1, %r8d
	cmpl	%eax, %edi
	jg	.L55
.L34:
	je	.L29
.L32:
	movl	%r11d, %eax
	subl	%r9d, %eax
	cmpl	$1, %eax
	jle	.L56
	movl	%r9d, %r15d
	movl	%r11d, %r14d
	.p2align 4,,10
	.p2align 3
.L36:
	movl	%r14d, %r11d
	jmp	.L26
.L28:
	cmpl	%eax, %edi
	jne	.L32
	.p2align 4,,10
	.p2align 3
.L29:
	subl	%r15d, %r9d
	cmpl	$1, %r9d
	jg	.L36
.L37:
	movl	%r14d, %edx
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L24
.L44:
	addq	$8, %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
.L56:
	.cfi_restore_state
	movl	%r11d, %r14d
	jmp	.L37
	.cfi_endproc
.LFE24:
	.size	main, .-main
	.globl	thickness
	.bss
	.align 32
	.type	thickness, @object
	.size	thickness, 400
thickness:
	.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:
```