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 main(void){
	int i,j;
	int n,cube,tetra;
	int max;

	while(scanf("%d",&n) && n){
		max = 0;
		for(i=0;(cube=i*i*i)<=n;i++){
			for(j=0;cube+(tetra=j*(j+1)*(j+2)/6)<=n;j++){
				if(cube + tetra > max) max = cube + tetra;
			}
		}
		printf("%d\n",max);
	}

	return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d\n"
.LC1:
	.string	"%d"
	.text
	.globl	main
	.type	main, @function
main:
.LFB0:
	.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
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	jmp	.L2
.L9:
	movl	$0, -20(%rbp)
	movl	$0, -28(%rbp)
	jmp	.L3
.L7:
	movl	$0, -24(%rbp)
	jmp	.L4
.L6:
	movl	-16(%rbp), %edx
	movl	-12(%rbp), %eax
	addl	%edx, %eax
	cmpl	%eax, -20(%rbp)
	jge	.L5
	movl	-16(%rbp), %edx
	movl	-12(%rbp), %eax
	addl	%edx, %eax
	movl	%eax, -20(%rbp)
.L5:
	addl	$1, -24(%rbp)
.L4:
	movl	-24(%rbp), %eax
	addl	$1, %eax
	imull	-24(%rbp), %eax
	movl	-24(%rbp), %edx
	addl	$2, %edx
	imull	%edx, %eax
	movslq	%eax, %rdx
	imulq	$715827883, %rdx, %rdx
	shrq	$32, %rdx
	sarl	$31, %eax
	movl	%eax, %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	movl	%eax, -12(%rbp)
	movl	-12(%rbp), %edx
	movl	-16(%rbp), %eax
	addl	%eax, %edx
	movl	-32(%rbp), %eax
	cmpl	%eax, %edx
	jle	.L6
	addl	$1, -28(%rbp)
.L3:
	movl	-28(%rbp), %eax
	imull	%eax, %eax
	movl	-28(%rbp), %edx
	imull	%edx, %eax
	movl	%eax, -16(%rbp)
	movl	-32(%rbp), %eax
	cmpl	%eax, -16(%rbp)
	jle	.L7
	movl	-20(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L2:
	leaq	-32(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	testl	%eax, %eax
	je	.L8
	movl	-32(%rbp), %eax
	testl	%eax, %eax
	jne	.L9
.L8:
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L11
	call	__stack_chk_fail@PLT
.L11:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.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
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d\n"
.LC1:
	.string	"%d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	movl	$2863311531, %r13d
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	leaq	.LC0(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	leaq	.LC1(%rip), %rbx
	subq	$24, %rsp
	.cfi_def_cfa_offset 64
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	leaq	4(%rsp), %rbp
	.p2align 4,,10
	.p2align 3
.L2:
	xorl	%eax, %eax
	movq	%rbp, %rsi
	movq	%rbx, %rdi
	call	__isoc99_scanf@PLT
	testl	%eax, %eax
	je	.L6
	movl	4(%rsp), %edi
	testl	%edi, %edi
	je	.L6
	movl	$0, %esi
	movl	$0, %r8d
	movl	$0, %r9d
	js	.L4
	.p2align 4,,10
	.p2align 3
.L7:
	movl	%esi, %eax
	movl	$1, %ecx
	cmpl	%esi, %edi
	jl	.L5
	.p2align 4,,10
	.p2align 3
.L3:
	cmpl	%eax, %r8d
	movl	%ecx, %edx
	cmovl	%eax, %r8d
	addl	$1, %ecx
	movl	%ecx, %eax
	imull	%edx, %eax
	addl	$2, %edx
	imull	%edx, %eax
	imulq	%r13, %rax
	shrq	$34, %rax
	addl	%esi, %eax
	cmpl	%edi, %eax
	jle	.L3
.L5:
	addl	$1, %r9d
	movl	%r9d, %esi
	imull	%r9d, %esi
	imull	%r9d, %esi
	cmpl	%esi, %edi
	jge	.L7
.L4:
	movl	%r8d, %edx
	movq	%r12, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L2
.L6:
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L22
	addq	$24, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
.L22:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.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
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d\n"
.LC1:
	.string	"%d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	movl	$2863311531, %r13d
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	leaq	.LC0(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	leaq	.LC1(%rip), %rbx
	subq	$24, %rsp
	.cfi_def_cfa_offset 64
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	leaq	4(%rsp), %rbp
	.p2align 4,,10
	.p2align 3
.L2:
	xorl	%eax, %eax
	movq	%rbp, %rsi
	movq	%rbx, %rdi
	call	__isoc99_scanf@PLT
	testl	%eax, %eax
	je	.L6
	movl	4(%rsp), %edi
	testl	%edi, %edi
	je	.L6
	movl	$0, %esi
	movl	$0, %r8d
	movl	$0, %r9d
	js	.L4
	.p2align 4,,10
	.p2align 3
.L7:
	movl	%esi, %eax
	movl	$1, %ecx
	cmpl	%esi, %edi
	jl	.L5
	.p2align 4,,10
	.p2align 3
.L3:
	cmpl	%eax, %r8d
	movl	%ecx, %edx
	cmovl	%eax, %r8d
	addl	$1, %ecx
	movl	%ecx, %eax
	imull	%edx, %eax
	addl	$2, %edx
	imull	%edx, %eax
	imulq	%r13, %rax
	shrq	$34, %rax
	addl	%esi, %eax
	cmpl	%edi, %eax
	jle	.L3
.L5:
	addl	$1, %r9d
	movl	%r9d, %esi
	imull	%r9d, %esi
	imull	%r9d, %esi
	cmpl	%esi, %edi
	jge	.L7
.L4:
	movl	%r8d, %edx
	movq	%r12, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L2
.L6:
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L22
	addq	$24, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
.L22:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.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 main(void){
	int i,j;
	int n,cube,tetra;
	int max;

	while(scanf("%d",&n) && n){
		max = 0;
		for(i=0;(cube=i*i*i)<=n;i++){
			for(j=0;cube+(tetra=j*(j+1)*(j+2)/6)<=n;j++){
				if(cube + tetra > max) max = cube + tetra;
			}
		}
		printf("%d\n",max);
	}

	return 0;
}
100
84
50
20
151200
0
 100
84
50
20
150323
0
 100
160
50
20
150323
0
 100
64
50
17
151200
0
 100
50
50
20
151200
0
 100
63
50
20
150323
0
 100
5
50
17
151200
0
 100
50
74
20
151200
0
 100
69
50
20
150323
0
 100
5
50
6
151200
0

99
84
47
20
151200
 99
84
47
20
150303
 99
160
47
20
150303
 99
64
47
12
151200
 99
47
47
20
151200
 99
62
47
20
150303
 99
5
47
12
151200
 99
47
74
20
151200
 99
68
47
20
150303
 99
5
47
5
151200

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 main(void){
	int i,j;
	int n,cube,tetra;
	int max;

	while(scanf("%d",&n) && n){
		max = 0;
		for(i=0;(cube=i*i*i)<=n;i++){
			for(j=0;cube+(tetra=j*(j+1)*(j+2)/6)<=n;j++){
				if(cube + tetra > max) max = cube + tetra;
			}
		}
		printf("%d\n",max);
	}

	return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d\n"
.LC1:
	.string	"%d"
	.text
	.globl	main
	.type	main, @function
main:
.LFB0:
	.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
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	jmp	.L2
.L9:
	movl	$0, -20(%rbp)
	movl	$0, -28(%rbp)
	jmp	.L3
.L7:
	movl	$0, -24(%rbp)
	jmp	.L4
.L6:
	movl	-16(%rbp), %edx
	movl	-12(%rbp), %eax
	addl	%edx, %eax
	cmpl	%eax, -20(%rbp)
	jge	.L5
	movl	-16(%rbp), %edx
	movl	-12(%rbp), %eax
	addl	%edx, %eax
	movl	%eax, -20(%rbp)
.L5:
	addl	$1, -24(%rbp)
.L4:
	movl	-24(%rbp), %eax
	addl	$1, %eax
	imull	-24(%rbp), %eax
	movl	-24(%rbp), %edx
	addl	$2, %edx
	imull	%edx, %eax
	movslq	%eax, %rdx
	imulq	$715827883, %rdx, %rdx
	shrq	$32, %rdx
	sarl	$31, %eax
	movl	%eax, %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	movl	%eax, -12(%rbp)
	movl	-12(%rbp), %edx
	movl	-16(%rbp), %eax
	addl	%eax, %edx
	movl	-32(%rbp), %eax
	cmpl	%eax, %edx
	jle	.L6
	addl	$1, -28(%rbp)
.L3:
	movl	-28(%rbp), %eax
	imull	%eax, %eax
	movl	-28(%rbp), %edx
	imull	%edx, %eax
	movl	%eax, -16(%rbp)
	movl	-32(%rbp), %eax
	cmpl	%eax, -16(%rbp)
	jle	.L7
	movl	-20(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L2:
	leaq	-32(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	testl	%eax, %eax
	je	.L8
	movl	-32(%rbp), %eax
	testl	%eax, %eax
	jne	.L9
.L8:
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L11
	call	__stack_chk_fail@PLT
.L11:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.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
	.section	.rodata
.LC0:
	.string	"%d\n"
.LC1:
	.string	"%d"
	.text
	.globl	main
	.type	main, @function
main:
.LFB0:
	.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
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	jmp	.L2
.L9:
	movl	$0, -20(%rbp)
	movl	$0, -28(%rbp)
	jmp	.L3
.L7:
	movl	$0, -24(%rbp)
	jmp	.L4
.L6:
	movl	-16(%rbp), %edx
	movl	-12(%rbp), %eax
	addl	%edx, %eax
	cmpl	%eax, -20(%rbp)
	jge	.L5
	movl	-16(%rbp), %edx
	movl	-12(%rbp), %eax
	addl	%edx, %eax
	movl	%eax, -20(%rbp)
.L5:
	addl	$1, -24(%rbp)
.L4:
	movl	-24(%rbp), %eax
	addl	$1, %eax
	imull	-24(%rbp), %eax
	movl	-24(%rbp), %edx
	addl	$2, %edx
	imull	%edx, %eax
	movslq	%eax, %rdx
	imulq	$715827883, %rdx, %rdx
	shrq	$32, %rdx
	sarl	$31, %eax
	movl	%eax, %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	movl	%eax, -12(%rbp)
	movl	-12(%rbp), %edx
	movl	-16(%rbp), %eax
	addl	%eax, %edx
	movl	-32(%rbp), %eax
	cmpl	%eax, %edx
	jle	.L6
	addl	$1, -28(%rbp)
.L3:
	movl	-28(%rbp), %eax
	imull	%eax, %eax
	movl	-28(%rbp), %edx
	imull	%edx, %eax
	movl	%eax, -16(%rbp)
	movl	-32(%rbp), %eax
	cmpl	%eax, -16(%rbp)
	jle	.L7
	movl	-20(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L2:
	leaq	-32(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	testl	%eax, %eax
	je	.L8
	movl	-32(%rbp), %eax
	testl	%eax, %eax
	jne	.L9
.L8:
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L11
	call	__stack_chk_fail@PLT
.L11:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.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:
