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

```c
main(x,y,z,e,m){for(;scanf("%d",&e),e;printf("%d\n",m))for(m=e,z=0;z*z*z<=e;z++)for(y=0;y*y+z*z*z<=e;y++)if(x=e-z*z*z-y*y,m>x+y+z)m=x+y+z;exit(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
	movl	%edi, -4(%rbp)
	movl	%esi, -8(%rbp)
	movl	%edx, -12(%rbp)
	movl	%ecx, -16(%rbp)
	movl	%r8d, -20(%rbp)
	jmp	.L2
.L8:
	movl	-16(%rbp), %eax
	movl	%eax, -20(%rbp)
	movl	$0, -12(%rbp)
	jmp	.L3
.L7:
	movl	$0, -8(%rbp)
	jmp	.L4
.L6:
	movl	-16(%rbp), %edx
	movl	-12(%rbp), %eax
	imull	%eax, %eax
	imull	-12(%rbp), %eax
	subl	%eax, %edx
	movl	-8(%rbp), %eax
	imull	%eax, %eax
	movl	%eax, %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	movl	%eax, -4(%rbp)
	movl	-4(%rbp), %edx
	movl	-8(%rbp), %eax
	addl	%eax, %edx
	movl	-12(%rbp), %eax
	addl	%edx, %eax
	cmpl	%eax, -20(%rbp)
	jle	.L5
	movl	-4(%rbp), %edx
	movl	-8(%rbp), %eax
	addl	%eax, %edx
	movl	-12(%rbp), %eax
	addl	%edx, %eax
	movl	%eax, -20(%rbp)
.L5:
	addl	$1, -8(%rbp)
.L4:
	movl	-8(%rbp), %eax
	imull	%eax, %eax
	movl	%eax, %edx
	movl	-12(%rbp), %eax
	imull	%eax, %eax
	imull	-12(%rbp), %eax
	addl	%eax, %edx
	movl	-16(%rbp), %eax
	cmpl	%eax, %edx
	jle	.L6
	addl	$1, -12(%rbp)
.L3:
	movl	-12(%rbp), %eax
	imull	%eax, %eax
	imull	-12(%rbp), %eax
	movl	%eax, %edx
	movl	-16(%rbp), %eax
	cmpl	%eax, %edx
	jle	.L7
	movl	-20(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L2:
	leaq	-16(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	scanf@PLT
	movl	-16(%rbp), %eax
	testl	%eax, %eax
	jne	.L8
	movl	$0, %edi
	call	exit@PLT
	.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:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	leaq	.LC0(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	leaq	.LC1(%rip), %rbx
	subq	$16, %rsp
	.cfi_def_cfa_offset 48
	movl	%ecx, 12(%rsp)
	leaq	12(%rsp), %rbp
	.p2align 4,,10
	.p2align 3
.L2:
	movq	%rbp, %rsi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	call	scanf@PLT
	movl	12(%rsp), %r9d
	testl	%r9d, %r9d
	je	.L7
	movl	%r9d, %esi
	xorl	%r8d, %r8d
	xorl	%edi, %edi
	testl	%r9d, %r9d
	js	.L4
	.p2align 4,,10
	.p2align 3
.L8:
	movl	%r9d, %r10d
	xorl	%edx, %edx
	xorl	%ecx, %ecx
	subl	%edi, %r10d
	cmpl	%edi, %r9d
	jl	.L6
	.p2align 4,,10
	.p2align 3
.L3:
	movl	%r10d, %eax
	subl	%ecx, %eax
	addl	%edx, %eax
	addl	%r8d, %eax
	cmpl	%eax, %esi
	cmovg	%eax, %esi
	addl	$1, %edx
	movl	%edx, %ecx
	imull	%edx, %ecx
	leal	(%rcx,%rdi), %eax
	cmpl	%r9d, %eax
	jle	.L3
.L6:
	addl	$1, %r8d
	movl	%r8d, %edi
	imull	%r8d, %edi
	imull	%r8d, %edi
	cmpl	%r9d, %edi
	jle	.L8
.L4:
	movq	%r12, %rdi
	xorl	%eax, %eax
	call	printf@PLT
	jmp	.L2
.L7:
	xorl	%edi, %edi
	call	exit@PLT
	.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:

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:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	leaq	.LC0(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	leaq	.LC1(%rip), %rbx
	subq	$16, %rsp
	.cfi_def_cfa_offset 48
	movl	%ecx, 12(%rsp)
	leaq	12(%rsp), %rbp
	.p2align 4,,10
	.p2align 3
.L2:
	movq	%rbp, %rsi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	call	scanf@PLT
	movl	12(%rsp), %r9d
	testl	%r9d, %r9d
	je	.L7
	movl	%r9d, %esi
	xorl	%r8d, %r8d
	xorl	%edi, %edi
	testl	%r9d, %r9d
	js	.L4
	.p2align 4,,10
	.p2align 3
.L8:
	movl	%r9d, %r10d
	xorl	%edx, %edx
	xorl	%ecx, %ecx
	subl	%edi, %r10d
	cmpl	%edi, %r9d
	jl	.L6
	.p2align 4,,10
	.p2align 3
.L3:
	movl	%r10d, %eax
	subl	%ecx, %eax
	addl	%edx, %eax
	addl	%r8d, %eax
	cmpl	%eax, %esi
	cmovg	%eax, %esi
	addl	$1, %edx
	movl	%edx, %ecx
	imull	%edx, %ecx
	leal	(%rcx,%rdi), %eax
	cmpl	%r9d, %eax
	jle	.L3
.L6:
	addl	$1, %r8d
	movl	%r8d, %edi
	imull	%r8d, %edi
	imull	%r8d, %edi
	cmpl	%r9d, %edi
	jle	.L8
.L4:
	movq	%r12, %rdi
	xorl	%eax, %eax
	call	printf@PLT
	jmp	.L2
.L7:
	xorl	%edi, %edi
	call	exit@PLT
	.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:

main(x,y,z,e,m){for(;scanf("%d",&e),e;printf("%d\n",m))for(m=e,z=0;z*z*z<=e;z++)for(y=0;y*y+z*z*z<=e;y++)if(x=e-z*z*z-y*y,m>x+y+z)m=x+y+z;exit(0);}
1
2
4
6
300
1250
0
 1
2
4
2
300
1250
0
 1
2
4
3
300
1250
0
 1
2
4
3
76
1250
0
 1
2
4
27
557
1250
0
 1
2
4
6
300
1687
0
 1
1
4
2
300
1250
0
 1
2
5
3
300
1250
0
 1
2
3
3
76
1250
0
 1
2
4
27
266
1250
0

1
2
2
4
18
44
 1
2
2
2
18
44
 1
2
2
3
18
44
 1
2
2
3
10
44
 1
2
2
3
23
44
 1
2
2
4
18
47
 1
1
2
2
18
44
 1
2
3
3
18
44
 1
2
3
3
10
44
 1
2
2
3
14
44

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

```c
main(x,y,z,e,m){for(;scanf("%d",&e),e;printf("%d\n",m))for(m=e,z=0;z*z*z<=e;z++)for(y=0;y*y+z*z*z<=e;y++)if(x=e-z*z*z-y*y,m>x+y+z)m=x+y+z;exit(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
	movl	%edi, -4(%rbp)
	movl	%esi, -8(%rbp)
	movl	%edx, -12(%rbp)
	movl	%ecx, -16(%rbp)
	movl	%r8d, -20(%rbp)
	jmp	.L2
.L8:
	movl	-16(%rbp), %eax
	movl	%eax, -20(%rbp)
	movl	$0, -12(%rbp)
	jmp	.L3
.L7:
	movl	$0, -8(%rbp)
	jmp	.L4
.L6:
	movl	-16(%rbp), %edx
	movl	-12(%rbp), %eax
	imull	%eax, %eax
	imull	-12(%rbp), %eax
	subl	%eax, %edx
	movl	-8(%rbp), %eax
	imull	%eax, %eax
	movl	%eax, %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	movl	%eax, -4(%rbp)
	movl	-4(%rbp), %edx
	movl	-8(%rbp), %eax
	addl	%eax, %edx
	movl	-12(%rbp), %eax
	addl	%edx, %eax
	cmpl	%eax, -20(%rbp)
	jle	.L5
	movl	-4(%rbp), %edx
	movl	-8(%rbp), %eax
	addl	%eax, %edx
	movl	-12(%rbp), %eax
	addl	%edx, %eax
	movl	%eax, -20(%rbp)
.L5:
	addl	$1, -8(%rbp)
.L4:
	movl	-8(%rbp), %eax
	imull	%eax, %eax
	movl	%eax, %edx
	movl	-12(%rbp), %eax
	imull	%eax, %eax
	imull	-12(%rbp), %eax
	addl	%eax, %edx
	movl	-16(%rbp), %eax
	cmpl	%eax, %edx
	jle	.L6
	addl	$1, -12(%rbp)
.L3:
	movl	-12(%rbp), %eax
	imull	%eax, %eax
	imull	-12(%rbp), %eax
	movl	%eax, %edx
	movl	-16(%rbp), %eax
	cmpl	%eax, %edx
	jle	.L7
	movl	-20(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L2:
	leaq	-16(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	scanf@PLT
	movl	-16(%rbp), %eax
	testl	%eax, %eax
	jne	.L8
	movl	$0, %edi
	call	exit@PLT
	.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
	movl	%edi, -4(%rbp)
	movl	%esi, -8(%rbp)
	movl	%edx, -12(%rbp)
	movl	%ecx, -16(%rbp)
	movl	%r8d, -20(%rbp)
	jmp	.L2
.L8:
	movl	-16(%rbp), %eax
	movl	%eax, -20(%rbp)
	movl	$0, -12(%rbp)
	jmp	.L3
.L7:
	movl	$0, -8(%rbp)
	jmp	.L4
.L6:
	movl	-16(%rbp), %edx
	movl	-12(%rbp), %eax
	imull	%eax, %eax
	imull	-12(%rbp), %eax
	subl	%eax, %edx
	movl	-8(%rbp), %eax
	imull	%eax, %eax
	movl	%eax, %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	movl	%eax, -4(%rbp)
	movl	-4(%rbp), %edx
	movl	-8(%rbp), %eax
	addl	%eax, %edx
	movl	-12(%rbp), %eax
	addl	%edx, %eax
	cmpl	%eax, -20(%rbp)
	jle	.L5
	movl	-4(%rbp), %edx
	movl	-8(%rbp), %eax
	addl	%eax, %edx
	movl	-12(%rbp), %eax
	addl	%edx, %eax
	movl	%eax, -20(%rbp)
.L5:
	addl	$1, -8(%rbp)
.L4:
	movl	-8(%rbp), %eax
	imull	%eax, %eax
	movl	%eax, %edx
	movl	-12(%rbp), %eax
	imull	%eax, %eax
	imull	-12(%rbp), %eax
	addl	%eax, %edx
	movl	-16(%rbp), %eax
	cmpl	%eax, %edx
	jle	.L6
	addl	$1, -12(%rbp)
.L3:
	movl	-12(%rbp), %eax
	imull	%eax, %eax
	imull	-12(%rbp), %eax
	movl	%eax, %edx
	movl	-16(%rbp), %eax
	cmpl	%eax, %edx
	jle	.L7
	movl	-20(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L2:
	leaq	-16(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	scanf@PLT
	movl	-16(%rbp), %eax
	testl	%eax, %eax
	jne	.L8
	movl	$0, %edi
	call	exit@PLT
	.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:
