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 solve(int *b, int n, int w, int m)
{
	int v, i, p;

	p = 0;
	for (i = 0; i < m; i++){
		v = 0;
		while (p < n && v + b[p] <= w){
			v += b[p];
			p++;
		}
		if (p == n) return (1);
	}
	return (0);
}

int main(void)
{
	int books[128];
	int n, m;
	int f, l;
	int ans;
	int i;

	while (scanf("%d %d", &m, &n), m){
		for (i = 0; i < n; i++){
			scanf("%d", books + i);
		}

		f = 0;
		l = 1500000;
		while (f != l){
			int v = f + l >> 1;
			if (solve(books, n, v, m)){
				ans = v;
				l = v;
			}
			else f = v + 1;
		}
		printf("%d\n", ans);
	}
	return (0);
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	solve
	.type	solve, @function
solve:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -24(%rbp)
	movl	%esi, -28(%rbp)
	movl	%edx, -32(%rbp)
	movl	%ecx, -36(%rbp)
	movl	$0, -4(%rbp)
	movl	$0, -8(%rbp)
	jmp	.L2
.L8:
	movl	$0, -12(%rbp)
	jmp	.L3
.L5:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	addl	%eax, -12(%rbp)
	addl	$1, -4(%rbp)
.L3:
	movl	-4(%rbp), %eax
	cmpl	-28(%rbp), %eax
	jge	.L4
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movl	-12(%rbp), %eax
	addl	%edx, %eax
	cmpl	%eax, -32(%rbp)
	jge	.L5
.L4:
	movl	-4(%rbp), %eax
	cmpl	-28(%rbp), %eax
	jne	.L6
	movl	$1, %eax
	jmp	.L7
.L6:
	addl	$1, -8(%rbp)
.L2:
	movl	-8(%rbp), %eax
	cmpl	-36(%rbp), %eax
	jl	.L8
	movl	$0, %eax
.L7:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	solve, .-solve
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d\n"
.LC2:
	.string	"%d %d"
	.text
	.globl	main
	.type	main, @function
main:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$560, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	jmp	.L10
.L16:
	movl	$0, -536(%rbp)
	jmp	.L11
.L12:
	movl	-536(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	-528(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -536(%rbp)
.L11:
	movl	-556(%rbp), %eax
	cmpl	%eax, -536(%rbp)
	jl	.L12
	movl	$0, -548(%rbp)
	movl	$1500000, -544(%rbp)
	jmp	.L13
.L15:
	movl	-548(%rbp), %edx
	movl	-544(%rbp), %eax
	addl	%edx, %eax
	sarl	%eax
	movl	%eax, -532(%rbp)
	movl	-552(%rbp), %ecx
	movl	-556(%rbp), %esi
	movl	-532(%rbp), %edx
	leaq	-528(%rbp), %rax
	movq	%rax, %rdi
	call	solve
	testl	%eax, %eax
	je	.L14
	movl	-532(%rbp), %eax
	movl	%eax, -540(%rbp)
	movl	-532(%rbp), %eax
	movl	%eax, -544(%rbp)
	jmp	.L13
.L14:
	movl	-532(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -548(%rbp)
.L13:
	movl	-548(%rbp), %eax
	cmpl	-544(%rbp), %eax
	jne	.L15
	movl	-540(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L10:
	leaq	-556(%rbp), %rdx
	leaq	-552(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-552(%rbp), %eax
	testl	%eax, %eax
	jne	.L16
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L18
	call	__stack_chk_fail@PLT
.L18:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.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	solve
	.type	solve, @function
solve:
.LFB23:
	.cfi_startproc
	endbr64
	movq	%rdi, %r9
	xorl	%r10d, %r10d
	xorl	%r11d, %r11d
	testl	%ecx, %ecx
	jle	.L17
	.p2align 4,,10
	.p2align 3
.L2:
	cmpl	%r10d, %esi
	jle	.L13
.L21:
	movslq	%r10d, %rax
	movl	(%r9,%rax,4), %edi
	leal	1(%r10), %eax
	cltq
	cmpl	%edi, %edx
	jge	.L5
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L20:
	addl	(%r9,%rax,4), %edi
	addq	$1, %rax
	cmpl	%edx, %edi
	jg	.L19
.L5:
	movl	%eax, %r8d
	cmpl	%eax, %esi
	jg	.L20
	cmpl	%r8d, %esi
	je	.L10
.L22:
	addl	$1, %r11d
	cmpl	%r11d, %ecx
	je	.L17
	cmpl	%r10d, %esi
	jle	.L17
	movl	%r8d, %r10d
	cmpl	%r10d, %esi
	jg	.L21
.L13:
	movl	%r10d, %r8d
	cmpl	%r8d, %esi
	jne	.L22
.L10:
	movl	$1, %eax
	ret
	.p2align 4,,10
	.p2align 3
.L19:
	movl	%r8d, %r10d
.L6:
	addl	$1, %r11d
	cmpl	%r11d, %ecx
	jne	.L2
.L17:
	xorl	%eax, %eax
	ret
	.cfi_endproc
.LFE23:
	.size	solve, .-solve
	.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
	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	.LC0(%rip), %rbx
	subq	$552, %rsp
	.cfi_def_cfa_offset 608
	movq	%fs:40, %rax
	movq	%rax, 536(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %r13
	leaq	12(%rsp), %r12
.L24:
	movq	%r13, %rdx
	movq	%r12, %rsi
	leaq	.LC2(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %r10d
	testl	%r10d, %r10d
	je	.L35
	movl	8(%rsp), %ecx
	leaq	16(%rsp), %r15
	xorl	%ebp, %ebp
	testl	%ecx, %ecx
	jle	.L37
.L25:
	movq	%r15, %rsi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	addl	$1, %ebp
	call	__isoc99_scanf@PLT
	movl	8(%rsp), %ecx
	addq	$4, %r15
	cmpl	%ebp, %ecx
	jg	.L25
	movl	12(%rsp), %r10d
.L37:
	movl	%r14d, %ebp
	movl	$1500000, %r11d
	xorl	%r14d, %r14d
	.p2align 4,,10
	.p2align 3
.L26:
	leal	(%r14,%r11), %edi
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	sarl	%edi
	testl	%r10d, %r10d
	jle	.L28
	.p2align 4,,10
	.p2align 3
.L27:
	cmpl	%r8d, %ecx
	jle	.L42
.L60:
	movslq	%r8d, %rax
	movl	16(%rsp,%rax,4), %edx
	leal	1(%r8), %eax
	cltq
	cmpl	%edx, %edi
	jge	.L30
	jmp	.L31
	.p2align 4,,10
	.p2align 3
.L59:
	addl	16(%rsp,%rax,4), %edx
	addq	$1, %rax
	cmpl	%edx, %edi
	jl	.L58
.L30:
	movl	%eax, %esi
	cmpl	%eax, %ecx
	jg	.L59
	cmpl	%esi, %ecx
	je	.L32
.L61:
	addl	$1, %r9d
	cmpl	%r9d, %r10d
	je	.L28
	cmpl	%r8d, %ecx
	jle	.L28
	movl	%esi, %r8d
	cmpl	%r8d, %ecx
	jg	.L60
.L42:
	movl	%r8d, %esi
	cmpl	%esi, %ecx
	jne	.L61
.L32:
	cmpl	%r14d, %edi
	je	.L38
	movl	%edi, %ebp
	jmp	.L34
	.p2align 4,,10
	.p2align 3
.L58:
	movl	%esi, %r8d
.L31:
	addl	$1, %r9d
	cmpl	%r9d, %r10d
	jne	.L27
	.p2align 4,,10
	.p2align 3
.L28:
	leal	1(%rdi), %r14d
	cmpl	%r11d, %r14d
	je	.L62
	movl	%r11d, %edi
	.p2align 4,,10
	.p2align 3
.L34:
	movl	%edi, %r11d
	jmp	.L26
.L62:
	movl	%ebp, %r14d
.L38:
	movl	%r14d, %edx
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L24
.L35:
	movq	536(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L63
	addq	$552, %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
.L63:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE24:
	.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	solve
	.type	solve, @function
solve:
.LFB23:
	.cfi_startproc
	endbr64
	movq	%rdi, %r9
	xorl	%r10d, %r10d
	xorl	%r11d, %r11d
	testl	%ecx, %ecx
	jle	.L17
	.p2align 4,,10
	.p2align 3
.L2:
	cmpl	%r10d, %esi
	jle	.L13
.L21:
	movslq	%r10d, %rax
	movl	(%r9,%rax,4), %edi
	leal	1(%r10), %eax
	cltq
	cmpl	%edi, %edx
	jge	.L5
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L20:
	addl	(%r9,%rax,4), %edi
	addq	$1, %rax
	cmpl	%edx, %edi
	jg	.L19
.L5:
	movl	%eax, %r8d
	cmpl	%eax, %esi
	jg	.L20
	cmpl	%r8d, %esi
	je	.L10
.L22:
	addl	$1, %r11d
	cmpl	%r11d, %ecx
	je	.L17
	cmpl	%r10d, %esi
	jle	.L17
	movl	%r8d, %r10d
	cmpl	%r10d, %esi
	jg	.L21
.L13:
	movl	%r10d, %r8d
	cmpl	%r8d, %esi
	jne	.L22
.L10:
	movl	$1, %eax
	ret
	.p2align 4,,10
	.p2align 3
.L19:
	movl	%r8d, %r10d
.L6:
	addl	$1, %r11d
	cmpl	%r11d, %ecx
	jne	.L2
.L17:
	xorl	%eax, %eax
	ret
	.cfi_endproc
.LFE23:
	.size	solve, .-solve
	.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
	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	.LC0(%rip), %rbx
	subq	$552, %rsp
	.cfi_def_cfa_offset 608
	movq	%fs:40, %rax
	movq	%rax, 536(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %r13
	leaq	12(%rsp), %r12
.L24:
	movq	%r13, %rdx
	movq	%r12, %rsi
	leaq	.LC2(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %r10d
	testl	%r10d, %r10d
	je	.L35
	movl	8(%rsp), %ecx
	leaq	16(%rsp), %r15
	xorl	%ebp, %ebp
	testl	%ecx, %ecx
	jle	.L37
.L25:
	movq	%r15, %rsi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	addl	$1, %ebp
	call	__isoc99_scanf@PLT
	movl	8(%rsp), %ecx
	addq	$4, %r15
	cmpl	%ebp, %ecx
	jg	.L25
	movl	12(%rsp), %r10d
.L37:
	movl	%r14d, %ebp
	movl	$1500000, %r11d
	xorl	%r14d, %r14d
	.p2align 4,,10
	.p2align 3
.L26:
	leal	(%r14,%r11), %edi
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	sarl	%edi
	testl	%r10d, %r10d
	jle	.L28
	.p2align 4,,10
	.p2align 3
.L27:
	cmpl	%r8d, %ecx
	jle	.L42
.L60:
	movslq	%r8d, %rax
	movl	16(%rsp,%rax,4), %edx
	leal	1(%r8), %eax
	cltq
	cmpl	%edx, %edi
	jge	.L30
	jmp	.L31
	.p2align 4,,10
	.p2align 3
.L59:
	addl	16(%rsp,%rax,4), %edx
	addq	$1, %rax
	cmpl	%edx, %edi
	jl	.L58
.L30:
	movl	%eax, %esi
	cmpl	%eax, %ecx
	jg	.L59
	cmpl	%esi, %ecx
	je	.L32
.L61:
	addl	$1, %r9d
	cmpl	%r9d, %r10d
	je	.L28
	cmpl	%r8d, %ecx
	jle	.L28
	movl	%esi, %r8d
	cmpl	%r8d, %ecx
	jg	.L60
.L42:
	movl	%r8d, %esi
	cmpl	%esi, %ecx
	jne	.L61
.L32:
	cmpl	%r14d, %edi
	je	.L38
	movl	%edi, %ebp
	jmp	.L34
	.p2align 4,,10
	.p2align 3
.L58:
	movl	%esi, %r8d
.L31:
	addl	$1, %r9d
	cmpl	%r9d, %r10d
	jne	.L27
	.p2align 4,,10
	.p2align 3
.L28:
	leal	1(%rdi), %r14d
	cmpl	%r11d, %r14d
	je	.L62
	movl	%r11d, %edi
	.p2align 4,,10
	.p2align 3
.L34:
	movl	%edi, %r11d
	jmp	.L26
.L62:
	movl	%ebp, %r14d
.L38:
	movl	%r14d, %edx
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L24
.L35:
	movq	536(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L63
	addq	$552, %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
.L63:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE24:
	.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:

#include <stdio.h>

int solve(int *b, int n, int w, int m)
{
	int v, i, p;

	p = 0;
	for (i = 0; i < m; i++){
		v = 0;
		while (p < n && v + b[p] <= w){
			v += b[p];
			p++;
		}
		if (p == n) return (1);
	}
	return (0);
}

int main(void)
{
	int books[128];
	int n, m;
	int f, l;
	int ans;
	int i;

	while (scanf("%d %d", &m, &n), m){
		for (i = 0; i < n; i++){
			scanf("%d", books + i);
		}

		f = 0;
		l = 1500000;
		while (f != l){
			int v = f + l >> 1;
			if (solve(books, n, v, m)){
				ans = v;
				l = v;
			}
			else f = v + 1;
		}
		printf("%d\n", ans);
	}
	return (0);
}
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 unoptimized assembly code, your task is to generate highly optimized x86-64 assembly code.
C Code:

```c
#include <stdio.h>

int solve(int *b, int n, int w, int m)
{
	int v, i, p;

	p = 0;
	for (i = 0; i < m; i++){
		v = 0;
		while (p < n && v + b[p] <= w){
			v += b[p];
			p++;
		}
		if (p == n) return (1);
	}
	return (0);
}

int main(void)
{
	int books[128];
	int n, m;
	int f, l;
	int ans;
	int i;

	while (scanf("%d %d", &m, &n), m){
		for (i = 0; i < n; i++){
			scanf("%d", books + i);
		}

		f = 0;
		l = 1500000;
		while (f != l){
			int v = f + l >> 1;
			if (solve(books, n, v, m)){
				ans = v;
				l = v;
			}
			else f = v + 1;
		}
		printf("%d\n", ans);
	}
	return (0);
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	solve
	.type	solve, @function
solve:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -24(%rbp)
	movl	%esi, -28(%rbp)
	movl	%edx, -32(%rbp)
	movl	%ecx, -36(%rbp)
	movl	$0, -4(%rbp)
	movl	$0, -8(%rbp)
	jmp	.L2
.L8:
	movl	$0, -12(%rbp)
	jmp	.L3
.L5:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	addl	%eax, -12(%rbp)
	addl	$1, -4(%rbp)
.L3:
	movl	-4(%rbp), %eax
	cmpl	-28(%rbp), %eax
	jge	.L4
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movl	-12(%rbp), %eax
	addl	%edx, %eax
	cmpl	%eax, -32(%rbp)
	jge	.L5
.L4:
	movl	-4(%rbp), %eax
	cmpl	-28(%rbp), %eax
	jne	.L6
	movl	$1, %eax
	jmp	.L7
.L6:
	addl	$1, -8(%rbp)
.L2:
	movl	-8(%rbp), %eax
	cmpl	-36(%rbp), %eax
	jl	.L8
	movl	$0, %eax
.L7:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	solve, .-solve
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d\n"
.LC2:
	.string	"%d %d"
	.text
	.globl	main
	.type	main, @function
main:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$560, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	jmp	.L10
.L16:
	movl	$0, -536(%rbp)
	jmp	.L11
.L12:
	movl	-536(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	-528(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -536(%rbp)
.L11:
	movl	-556(%rbp), %eax
	cmpl	%eax, -536(%rbp)
	jl	.L12
	movl	$0, -548(%rbp)
	movl	$1500000, -544(%rbp)
	jmp	.L13
.L15:
	movl	-548(%rbp), %edx
	movl	-544(%rbp), %eax
	addl	%edx, %eax
	sarl	%eax
	movl	%eax, -532(%rbp)
	movl	-552(%rbp), %ecx
	movl	-556(%rbp), %esi
	movl	-532(%rbp), %edx
	leaq	-528(%rbp), %rax
	movq	%rax, %rdi
	call	solve
	testl	%eax, %eax
	je	.L14
	movl	-532(%rbp), %eax
	movl	%eax, -540(%rbp)
	movl	-532(%rbp), %eax
	movl	%eax, -544(%rbp)
	jmp	.L13
.L14:
	movl	-532(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -548(%rbp)
.L13:
	movl	-548(%rbp), %eax
	cmpl	-544(%rbp), %eax
	jne	.L15
	movl	-540(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L10:
	leaq	-556(%rbp), %rdx
	leaq	-552(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-552(%rbp), %eax
	testl	%eax, %eax
	jne	.L16
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L18
	call	__stack_chk_fail@PLT
.L18:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.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	solve
	.type	solve, @function
solve:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -24(%rbp)
	movl	%esi, -28(%rbp)
	movl	%edx, -32(%rbp)
	movl	%ecx, -36(%rbp)
	movl	$0, -4(%rbp)
	movl	$0, -8(%rbp)
	jmp	.L2
.L8:
	movl	$0, -12(%rbp)
	jmp	.L3
.L5:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	addl	%eax, -12(%rbp)
	addl	$1, -4(%rbp)
.L3:
	movl	-4(%rbp), %eax
	cmpl	-28(%rbp), %eax
	jge	.L4
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movl	-12(%rbp), %eax
	addl	%edx, %eax
	cmpl	%eax, -32(%rbp)
	jge	.L5
.L4:
	movl	-4(%rbp), %eax
	cmpl	-28(%rbp), %eax
	jne	.L6
	movl	$1, %eax
	jmp	.L7
.L6:
	addl	$1, -8(%rbp)
.L2:
	movl	-8(%rbp), %eax
	cmpl	-36(%rbp), %eax
	jl	.L8
	movl	$0, %eax
.L7:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	solve, .-solve
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d\n"
.LC2:
	.string	"%d %d"
	.text
	.globl	main
	.type	main, @function
main:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$560, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	jmp	.L10
.L16:
	movl	$0, -536(%rbp)
	jmp	.L11
.L12:
	movl	-536(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	-528(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -536(%rbp)
.L11:
	movl	-556(%rbp), %eax
	cmpl	%eax, -536(%rbp)
	jl	.L12
	movl	$0, -548(%rbp)
	movl	$1500000, -544(%rbp)
	jmp	.L13
.L15:
	movl	-548(%rbp), %edx
	movl	-544(%rbp), %eax
	addl	%edx, %eax
	sarl	%eax
	movl	%eax, -532(%rbp)
	movl	-552(%rbp), %ecx
	movl	-556(%rbp), %esi
	movl	-532(%rbp), %edx
	leaq	-528(%rbp), %rax
	movq	%rax, %rdi
	call	solve
	testl	%eax, %eax
	je	.L14
	movl	-532(%rbp), %eax
	movl	%eax, -540(%rbp)
	movl	-532(%rbp), %eax
	movl	%eax, -544(%rbp)
	jmp	.L13
.L14:
	movl	-532(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -548(%rbp)
.L13:
	movl	-548(%rbp), %eax
	cmpl	-544(%rbp), %eax
	jne	.L15
	movl	-540(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L10:
	leaq	-556(%rbp), %rdx
	leaq	-552(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-552(%rbp), %eax
	testl	%eax, %eax
	jne	.L16
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L18
	call	__stack_chk_fail@PLT
.L18:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.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:
