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() {
	int n;
	int result = 0;

	scanf("%d", &n);

	int i_flag, j_flag, k_flag;
	for (int cor = 1; cor <= n; cor++)
	{
		result = 0;
		i_flag = 0, j_flag = 0, k_flag = 0;
		for (int i = 1; i_flag == 0; i++)
		{
			j_flag = 0;
			for (int j = 1; j_flag == 0; j++)
			{
				k_flag = 0;
				for (int k = 1; k_flag == 0; k++)
				{
					int cal = i * i + j * j + k * k + i * j + j * k + k * i;
					if (cal == cor) {
						result += 1;
					}
					else if (cal > cor) {
						k_flag = 1;
						if (k == 1) {
							j_flag = 1;
							if (j == 1) {
								i_flag = 1;
								printf("%d\n", result);
							}
						}
					}
				}
			}
		}
	}

	return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d\n"
	.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	$48, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -44(%rbp)
	leaq	-48(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$1, -28(%rbp)
	jmp	.L2
.L11:
	movl	$0, -44(%rbp)
	movl	$0, -40(%rbp)
	movl	$0, -36(%rbp)
	movl	$0, -32(%rbp)
	movl	$1, -24(%rbp)
	jmp	.L3
.L10:
	movl	$0, -36(%rbp)
	movl	$1, -20(%rbp)
	jmp	.L4
.L9:
	movl	$0, -32(%rbp)
	movl	$1, -16(%rbp)
	jmp	.L5
.L8:
	movl	-24(%rbp), %eax
	imull	%eax, %eax
	movl	%eax, %edx
	movl	-20(%rbp), %eax
	imull	%eax, %eax
	addl	%eax, %edx
	movl	-16(%rbp), %eax
	imull	%eax, %eax
	addl	%eax, %edx
	movl	-24(%rbp), %eax
	imull	-20(%rbp), %eax
	addl	%eax, %edx
	movl	-20(%rbp), %eax
	imull	-16(%rbp), %eax
	addl	%eax, %edx
	movl	-16(%rbp), %eax
	imull	-24(%rbp), %eax
	addl	%edx, %eax
	movl	%eax, -12(%rbp)
	movl	-12(%rbp), %eax
	cmpl	-28(%rbp), %eax
	jne	.L6
	addl	$1, -44(%rbp)
	jmp	.L7
.L6:
	movl	-12(%rbp), %eax
	cmpl	-28(%rbp), %eax
	jle	.L7
	movl	$1, -32(%rbp)
	cmpl	$1, -16(%rbp)
	jne	.L7
	movl	$1, -36(%rbp)
	cmpl	$1, -20(%rbp)
	jne	.L7
	movl	$1, -40(%rbp)
	movl	-44(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L7:
	addl	$1, -16(%rbp)
.L5:
	cmpl	$0, -32(%rbp)
	je	.L8
	addl	$1, -20(%rbp)
.L4:
	cmpl	$0, -36(%rbp)
	je	.L9
	addl	$1, -24(%rbp)
.L3:
	cmpl	$0, -40(%rbp)
	je	.L10
	addl	$1, -28(%rbp)
.L2:
	movl	-48(%rbp), %eax
	cmpl	%eax, -28(%rbp)
	jle	.L11
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L13
	call	__stack_chk_fail@PLT
.L13:
	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"
.LC1:
	.string	"%d\n"
	.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
	leaq	.LC0(%rip), %rdi
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	movl	$1, %ebp
	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), %rsi
	call	__isoc99_scanf@PLT
	movl	4(%rsp), %eax
	testl	%eax, %eax
	jle	.L3
	.p2align 4,,10
	.p2align 3
.L2:
	movl	$1, %r11d
	xorl	%r12d, %r12d
	.p2align 4,,10
	.p2align 3
.L10:
	movl	%r11d, %r13d
	movl	%r11d, %r8d
	movl	$1, %r9d
	imull	%r11d, %r13d
	jmp	.L9
	.p2align 4,,10
	.p2align 3
.L4:
	jle	.L5
	addl	%r11d, %r8d
	cmpl	$1, %edx
	je	.L19
	addl	$1, %r9d
.L9:
	movl	%r9d, %r10d
	movl	%r11d, %edi
	movl	%r9d, %esi
	movl	$2, %ecx
	imull	%r9d, %r10d
	addl	%r13d, %r10d
	.p2align 4,,10
	.p2align 3
.L8:
	leal	-1(%rcx), %edx
	movl	%edx, %eax
	imull	%edx, %eax
	addl	%r10d, %eax
	addl	%r8d, %eax
	addl	%esi, %eax
	addl	%edi, %eax
	cmpl	%ebp, %eax
	jne	.L4
	addl	$1, %r12d
.L5:
	addl	%r9d, %esi
	addl	%r11d, %edi
	addl	$1, %ecx
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L19:
	cmpl	$1, %r9d
	je	.L20
	addl	$1, %r11d
	jmp	.L10
	.p2align 4,,10
	.p2align 3
.L20:
	movl	%r12d, %edx
	movq	%rbx, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	addl	$1, %ebp
	cmpl	%ebp, 4(%rsp)
	jge	.L2
.L3:
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L21
	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
.L21:
	.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"
.LC1:
	.string	"%d\n"
	.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
	leaq	.LC0(%rip), %rdi
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	movl	$1, %ebp
	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), %rsi
	call	__isoc99_scanf@PLT
	movl	4(%rsp), %eax
	testl	%eax, %eax
	jle	.L3
	.p2align 4,,10
	.p2align 3
.L2:
	movl	$1, %r11d
	xorl	%r12d, %r12d
	.p2align 4,,10
	.p2align 3
.L10:
	movl	%r11d, %r13d
	movl	%r11d, %r8d
	movl	$1, %r9d
	imull	%r11d, %r13d
	jmp	.L9
	.p2align 4,,10
	.p2align 3
.L4:
	jle	.L5
	addl	%r11d, %r8d
	cmpl	$1, %edx
	je	.L19
	addl	$1, %r9d
.L9:
	movl	%r9d, %r10d
	movl	%r11d, %edi
	movl	%r9d, %esi
	movl	$2, %ecx
	imull	%r9d, %r10d
	addl	%r13d, %r10d
	.p2align 4,,10
	.p2align 3
.L8:
	leal	-1(%rcx), %edx
	movl	%edx, %eax
	imull	%edx, %eax
	addl	%r10d, %eax
	addl	%r8d, %eax
	addl	%esi, %eax
	addl	%edi, %eax
	cmpl	%ebp, %eax
	jne	.L4
	addl	$1, %r12d
.L5:
	addl	%r9d, %esi
	addl	%r11d, %edi
	addl	$1, %ecx
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L19:
	cmpl	$1, %r9d
	je	.L20
	addl	$1, %r11d
	jmp	.L10
	.p2align 4,,10
	.p2align 3
.L20:
	movl	%r12d, %edx
	movq	%rbx, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	addl	$1, %ebp
	cmpl	%ebp, 4(%rsp)
	jge	.L2
.L3:
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L21
	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
.L21:
	.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() {
	int n;
	int result = 0;

	scanf("%d", &n);

	int i_flag, j_flag, k_flag;
	for (int cor = 1; cor <= n; cor++)
	{
		result = 0;
		i_flag = 0, j_flag = 0, k_flag = 0;
		for (int i = 1; i_flag == 0; i++)
		{
			j_flag = 0;
			for (int j = 1; j_flag == 0; j++)
			{
				k_flag = 0;
				for (int k = 1; k_flag == 0; k++)
				{
					int cal = i * i + j * j + k * k + i * j + j * k + k * i;
					if (cal == cor) {
						result += 1;
					}
					else if (cal > cor) {
						k_flag = 1;
						if (k == 1) {
							j_flag = 1;
							if (j == 1) {
								i_flag = 1;
								printf("%d\n", result);
							}
						}
					}
				}
			}
		}
	}

	return 0;
}
27
 13
 3
 2
 4
 8
 14
 1
 31
 53

0
0
0
0
0
1
0
0
0
0
3
0
0
0
0
0
3
3
0
0
0
0
0
1
6
0
3
 0
0
0
0
0
1
0
0
0
0
3
0
0
 0
0
0
 0
0
 0
0
0
0
 0
0
0
0
0
1
0
0
 0
0
0
0
0
1
0
0
0
0
3
0
0
0
 0
 0
0
0
0
0
1
0
0
0
0
3
0
0
0
0
0
3
3
0
0
0
0
0
1
6
0
3
0
0
0
0
 0
0
0
0
0
1
0
0
0
0
3
0
0
0
0
0
3
3
0
0
0
0
0
1
6
0
3
0
0
0
0
0
3
3
6
0
0
3
0
0
0
0
3
3
6
0
6
0
0
0
3
0
0

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() {
	int n;
	int result = 0;

	scanf("%d", &n);

	int i_flag, j_flag, k_flag;
	for (int cor = 1; cor <= n; cor++)
	{
		result = 0;
		i_flag = 0, j_flag = 0, k_flag = 0;
		for (int i = 1; i_flag == 0; i++)
		{
			j_flag = 0;
			for (int j = 1; j_flag == 0; j++)
			{
				k_flag = 0;
				for (int k = 1; k_flag == 0; k++)
				{
					int cal = i * i + j * j + k * k + i * j + j * k + k * i;
					if (cal == cor) {
						result += 1;
					}
					else if (cal > cor) {
						k_flag = 1;
						if (k == 1) {
							j_flag = 1;
							if (j == 1) {
								i_flag = 1;
								printf("%d\n", result);
							}
						}
					}
				}
			}
		}
	}

	return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d\n"
	.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	$48, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -44(%rbp)
	leaq	-48(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$1, -28(%rbp)
	jmp	.L2
.L11:
	movl	$0, -44(%rbp)
	movl	$0, -40(%rbp)
	movl	$0, -36(%rbp)
	movl	$0, -32(%rbp)
	movl	$1, -24(%rbp)
	jmp	.L3
.L10:
	movl	$0, -36(%rbp)
	movl	$1, -20(%rbp)
	jmp	.L4
.L9:
	movl	$0, -32(%rbp)
	movl	$1, -16(%rbp)
	jmp	.L5
.L8:
	movl	-24(%rbp), %eax
	imull	%eax, %eax
	movl	%eax, %edx
	movl	-20(%rbp), %eax
	imull	%eax, %eax
	addl	%eax, %edx
	movl	-16(%rbp), %eax
	imull	%eax, %eax
	addl	%eax, %edx
	movl	-24(%rbp), %eax
	imull	-20(%rbp), %eax
	addl	%eax, %edx
	movl	-20(%rbp), %eax
	imull	-16(%rbp), %eax
	addl	%eax, %edx
	movl	-16(%rbp), %eax
	imull	-24(%rbp), %eax
	addl	%edx, %eax
	movl	%eax, -12(%rbp)
	movl	-12(%rbp), %eax
	cmpl	-28(%rbp), %eax
	jne	.L6
	addl	$1, -44(%rbp)
	jmp	.L7
.L6:
	movl	-12(%rbp), %eax
	cmpl	-28(%rbp), %eax
	jle	.L7
	movl	$1, -32(%rbp)
	cmpl	$1, -16(%rbp)
	jne	.L7
	movl	$1, -36(%rbp)
	cmpl	$1, -20(%rbp)
	jne	.L7
	movl	$1, -40(%rbp)
	movl	-44(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L7:
	addl	$1, -16(%rbp)
.L5:
	cmpl	$0, -32(%rbp)
	je	.L8
	addl	$1, -20(%rbp)
.L4:
	cmpl	$0, -36(%rbp)
	je	.L9
	addl	$1, -24(%rbp)
.L3:
	cmpl	$0, -40(%rbp)
	je	.L10
	addl	$1, -28(%rbp)
.L2:
	movl	-48(%rbp), %eax
	cmpl	%eax, -28(%rbp)
	jle	.L11
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L13
	call	__stack_chk_fail@PLT
.L13:
	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"
.LC1:
	.string	"%d\n"
	.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	$48, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -44(%rbp)
	leaq	-48(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$1, -28(%rbp)
	jmp	.L2
.L11:
	movl	$0, -44(%rbp)
	movl	$0, -40(%rbp)
	movl	$0, -36(%rbp)
	movl	$0, -32(%rbp)
	movl	$1, -24(%rbp)
	jmp	.L3
.L10:
	movl	$0, -36(%rbp)
	movl	$1, -20(%rbp)
	jmp	.L4
.L9:
	movl	$0, -32(%rbp)
	movl	$1, -16(%rbp)
	jmp	.L5
.L8:
	movl	-24(%rbp), %eax
	imull	%eax, %eax
	movl	%eax, %edx
	movl	-20(%rbp), %eax
	imull	%eax, %eax
	addl	%eax, %edx
	movl	-16(%rbp), %eax
	imull	%eax, %eax
	addl	%eax, %edx
	movl	-24(%rbp), %eax
	imull	-20(%rbp), %eax
	addl	%eax, %edx
	movl	-20(%rbp), %eax
	imull	-16(%rbp), %eax
	addl	%eax, %edx
	movl	-16(%rbp), %eax
	imull	-24(%rbp), %eax
	addl	%edx, %eax
	movl	%eax, -12(%rbp)
	movl	-12(%rbp), %eax
	cmpl	-28(%rbp), %eax
	jne	.L6
	addl	$1, -44(%rbp)
	jmp	.L7
.L6:
	movl	-12(%rbp), %eax
	cmpl	-28(%rbp), %eax
	jle	.L7
	movl	$1, -32(%rbp)
	cmpl	$1, -16(%rbp)
	jne	.L7
	movl	$1, -36(%rbp)
	cmpl	$1, -20(%rbp)
	jne	.L7
	movl	$1, -40(%rbp)
	movl	-44(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L7:
	addl	$1, -16(%rbp)
.L5:
	cmpl	$0, -32(%rbp)
	je	.L8
	addl	$1, -20(%rbp)
.L4:
	cmpl	$0, -36(%rbp)
	je	.L9
	addl	$1, -24(%rbp)
.L3:
	cmpl	$0, -40(%rbp)
	je	.L10
	addl	$1, -28(%rbp)
.L2:
	movl	-48(%rbp), %eax
	cmpl	%eax, -28(%rbp)
	jle	.L11
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L13
	call	__stack_chk_fail@PLT
.L13:
	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:
