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,sum,i;

  while(1){

    scanf("%d",&n);
    if(n == 0) break;
    if(n == 1){

      printf("deficient number\n");
      continue;

    }

    sum=1;

    for(i = 2; i*i <= n; i++){

      if(n%i == 0){

        sum += i+n/i;
        if(i == n/i) sum -= i;

      }

      if(sum > n) break;

    }

    if(sum == n) printf("perfect number\n");
    if(sum < n) printf("deficient number\n");
    if(sum > n) printf("abundant number\n");

  }

  return 0;

}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"deficient number"
.LC2:
	.string	"perfect number"
.LC3:
	.string	"abundant number"
	.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
.L13:
	leaq	-20(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-20(%rbp), %eax
	testl	%eax, %eax
	je	.L17
	movl	-20(%rbp), %eax
	cmpl	$1, %eax
	jne	.L4
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	jmp	.L5
.L4:
	movl	$1, -16(%rbp)
	movl	$2, -12(%rbp)
	jmp	.L6
.L10:
	movl	-20(%rbp), %eax
	cltd
	idivl	-12(%rbp)
	movl	%edx, %eax
	testl	%eax, %eax
	jne	.L7
	movl	-20(%rbp), %eax
	cltd
	idivl	-12(%rbp)
	movl	%eax, %edx
	movl	-12(%rbp), %eax
	addl	%edx, %eax
	addl	%eax, -16(%rbp)
	movl	-20(%rbp), %eax
	cltd
	idivl	-12(%rbp)
	cmpl	%eax, -12(%rbp)
	jne	.L7
	movl	-12(%rbp), %eax
	subl	%eax, -16(%rbp)
.L7:
	movl	-20(%rbp), %eax
	cmpl	%eax, -16(%rbp)
	jg	.L18
	addl	$1, -12(%rbp)
.L6:
	movl	-12(%rbp), %eax
	imull	%eax, %eax
	movl	%eax, %edx
	movl	-20(%rbp), %eax
	cmpl	%eax, %edx
	jle	.L10
	jmp	.L9
.L18:
	nop
.L9:
	movl	-20(%rbp), %eax
	cmpl	%eax, -16(%rbp)
	jne	.L11
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
.L11:
	movl	-20(%rbp), %eax
	cmpl	%eax, -16(%rbp)
	jge	.L12
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
.L12:
	movl	-20(%rbp), %eax
	cmpl	%eax, -16(%rbp)
	jle	.L13
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
.L5:
	jmp	.L13
.L17:
	nop
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L15
	call	__stack_chk_fail@PLT
.L15:
	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	"deficient number"
.LC2:
	.string	"perfect number"
.LC3:
	.string	"abundant number"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.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
	leaq	.LC2(%rip), %r14
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	leaq	.LC3(%rip), %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	leaq	.LC1(%rip), %r12
	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	$24, %rsp
	.cfi_def_cfa_offset 80
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	leaq	4(%rsp), %rbp
	.p2align 4,,10
	.p2align 3
.L2:
	movq	%rbp, %rsi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	4(%rsp), %esi
	testl	%esi, %esi
	je	.L3
	cmpl	$1, %esi
	je	.L4
	movl	$2, %ecx
	movl	$1, %r15d
	cmpl	$3, %esi
	jg	.L5
	jmp	.L11
	.p2align 4,,10
	.p2align 3
.L21:
	addl	$1, %ecx
	movl	%ecx, %eax
	imull	%ecx, %eax
	cmpl	%eax, %esi
	jl	.L20
.L5:
	movl	%esi, %eax
	cltd
	idivl	%ecx
	testl	%edx, %edx
	jne	.L8
	leal	(%rax,%rcx), %edx
	addl	%edx, %r15d
	movl	%r15d, %edx
	subl	%ecx, %edx
	cmpl	%ecx, %eax
	cmove	%edx, %r15d
.L8:
	cmpl	%r15d, %esi
	jge	.L21
.L11:
	cmpl	%esi, %r15d
	jl	.L12
.L10:
	cmpl	%r15d, %esi
	jge	.L2
	movq	%r13, %rdi
	call	puts@PLT
	jmp	.L2
	.p2align 4,,10
	.p2align 3
.L20:
	cmpl	%r15d, %esi
	je	.L22
	jle	.L2
.L12:
	movq	%r12, %rdi
	call	puts@PLT
	movl	4(%rsp), %esi
	jmp	.L10
	.p2align 4,,10
	.p2align 3
.L4:
	movq	%r12, %rdi
	call	puts@PLT
	jmp	.L2
	.p2align 4,,10
	.p2align 3
.L22:
	movq	%r14, %rdi
	call	puts@PLT
	movl	4(%rsp), %esi
	jmp	.L11
	.p2align 4,,10
	.p2align 3
.L3:
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L23
	addq	$24, %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
.L23:
	.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	"deficient number"
.LC2:
	.string	"perfect number"
.LC3:
	.string	"abundant number"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.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
	leaq	.LC2(%rip), %r14
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	leaq	.LC3(%rip), %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	leaq	.LC1(%rip), %r12
	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	$24, %rsp
	.cfi_def_cfa_offset 80
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	leaq	4(%rsp), %rbp
	.p2align 4,,10
	.p2align 3
.L2:
	movq	%rbp, %rsi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	4(%rsp), %esi
	testl	%esi, %esi
	je	.L3
	cmpl	$1, %esi
	je	.L4
	movl	$2, %ecx
	movl	$1, %r15d
	cmpl	$3, %esi
	jg	.L5
	jmp	.L11
	.p2align 4,,10
	.p2align 3
.L21:
	addl	$1, %ecx
	movl	%ecx, %eax
	imull	%ecx, %eax
	cmpl	%eax, %esi
	jl	.L20
.L5:
	movl	%esi, %eax
	cltd
	idivl	%ecx
	testl	%edx, %edx
	jne	.L8
	leal	(%rax,%rcx), %edx
	addl	%edx, %r15d
	movl	%r15d, %edx
	subl	%ecx, %edx
	cmpl	%ecx, %eax
	cmove	%edx, %r15d
.L8:
	cmpl	%r15d, %esi
	jge	.L21
.L11:
	cmpl	%esi, %r15d
	jl	.L12
.L10:
	cmpl	%r15d, %esi
	jge	.L2
	movq	%r13, %rdi
	call	puts@PLT
	jmp	.L2
	.p2align 4,,10
	.p2align 3
.L20:
	cmpl	%r15d, %esi
	je	.L22
	jle	.L2
.L12:
	movq	%r12, %rdi
	call	puts@PLT
	movl	4(%rsp), %esi
	jmp	.L10
	.p2align 4,,10
	.p2align 3
.L4:
	movq	%r12, %rdi
	call	puts@PLT
	jmp	.L2
	.p2align 4,,10
	.p2align 3
.L22:
	movq	%r14, %rdi
	call	puts@PLT
	movl	4(%rsp), %esi
	jmp	.L11
	.p2align 4,,10
	.p2align 3
.L3:
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L23
	addq	$24, %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
.L23:
	.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,sum,i;

  while(1){

    scanf("%d",&n);
    if(n == 0) break;
    if(n == 1){

      printf("deficient number\n");
      continue;

    }

    sum=1;

    for(i = 2; i*i <= n; i++){

      if(n%i == 0){

        sum += i+n/i;
        if(i == n/i) sum -= i;

      }

      if(sum > n) break;

    }

    if(sum == n) printf("perfect number\n");
    if(sum < n) printf("deficient number\n");
    if(sum > n) printf("abundant number\n");

  }

  return 0;

}
1
2
3
4
6
12
16
28
33550336
99999998
99999999
100001000
0
 1
2
5
4
6
12
16
28
820514
99999998
99999999
100001100
0
 1
2
5
4
6
12
18
28
820514
99999998
99999999
100001100
0
 1
1
5
0
6
12
16
28
33550336
99999998
99999999
100001100
0
 1
1
5
4
6
12
18
4
820514
99999998
99999999
100001100
0
 1
2
3
6
6
12
29
28
33550336
99999998
99999999
100001000
0
 1
1
5
4
6
12
18
4
820514
99999998
699564
100001100
0
 1
2
3
6
6
12
29
28
27350355
99999998
99999999
100001000
0
 1
2
5
3
7
12
16
28
33550336
119648219
124798312
100001000
0
 1
2
1
3
6
12
16
28
256736
48969127
99999999
100001100
0

deficient number
deficient number
deficient number
deficient number
perfect number
abundant number
deficient number
perfect number
perfect number
deficient number
deficient number
abundant number
 deficient number
deficient number
deficient number
deficient number
perfect number
abundant number
deficient number
perfect number
deficient number
deficient number
deficient number
abundant number
 deficient number
deficient number
deficient number
deficient number
perfect number
abundant number
abundant number
perfect number
deficient number
deficient number
deficient number
abundant number
 deficient number
deficient number
deficient number
 deficient number
deficient number
deficient number
deficient number
perfect number
abundant number
abundant number
deficient number
deficient number
deficient number
deficient number
abundant number
 deficient number
deficient number
deficient number
perfect number
perfect number
abundant number
deficient number
perfect number
perfect number
deficient number
deficient number
abundant number
 deficient number
deficient number
deficient number
deficient number
perfect number
abundant number
abundant number
deficient number
deficient number
deficient number
abundant number
abundant number
 deficient number
deficient number
deficient number
perfect number
perfect number
abundant number
deficient number
perfect number
deficient number
deficient number
deficient number
abundant number
 deficient number
deficient number
deficient number
deficient number
deficient number
abundant number
deficient number
perfect number
perfect number
deficient number
deficient number
abundant number
 deficient number
deficient number
deficient number
deficient number
perfect number
abundant number
deficient number
perfect number
abundant number
deficient number
deficient number
abundant number

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,sum,i;

  while(1){

    scanf("%d",&n);
    if(n == 0) break;
    if(n == 1){

      printf("deficient number\n");
      continue;

    }

    sum=1;

    for(i = 2; i*i <= n; i++){

      if(n%i == 0){

        sum += i+n/i;
        if(i == n/i) sum -= i;

      }

      if(sum > n) break;

    }

    if(sum == n) printf("perfect number\n");
    if(sum < n) printf("deficient number\n");
    if(sum > n) printf("abundant number\n");

  }

  return 0;

}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"deficient number"
.LC2:
	.string	"perfect number"
.LC3:
	.string	"abundant number"
	.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
.L13:
	leaq	-20(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-20(%rbp), %eax
	testl	%eax, %eax
	je	.L17
	movl	-20(%rbp), %eax
	cmpl	$1, %eax
	jne	.L4
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	jmp	.L5
.L4:
	movl	$1, -16(%rbp)
	movl	$2, -12(%rbp)
	jmp	.L6
.L10:
	movl	-20(%rbp), %eax
	cltd
	idivl	-12(%rbp)
	movl	%edx, %eax
	testl	%eax, %eax
	jne	.L7
	movl	-20(%rbp), %eax
	cltd
	idivl	-12(%rbp)
	movl	%eax, %edx
	movl	-12(%rbp), %eax
	addl	%edx, %eax
	addl	%eax, -16(%rbp)
	movl	-20(%rbp), %eax
	cltd
	idivl	-12(%rbp)
	cmpl	%eax, -12(%rbp)
	jne	.L7
	movl	-12(%rbp), %eax
	subl	%eax, -16(%rbp)
.L7:
	movl	-20(%rbp), %eax
	cmpl	%eax, -16(%rbp)
	jg	.L18
	addl	$1, -12(%rbp)
.L6:
	movl	-12(%rbp), %eax
	imull	%eax, %eax
	movl	%eax, %edx
	movl	-20(%rbp), %eax
	cmpl	%eax, %edx
	jle	.L10
	jmp	.L9
.L18:
	nop
.L9:
	movl	-20(%rbp), %eax
	cmpl	%eax, -16(%rbp)
	jne	.L11
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
.L11:
	movl	-20(%rbp), %eax
	cmpl	%eax, -16(%rbp)
	jge	.L12
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
.L12:
	movl	-20(%rbp), %eax
	cmpl	%eax, -16(%rbp)
	jle	.L13
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
.L5:
	jmp	.L13
.L17:
	nop
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L15
	call	__stack_chk_fail@PLT
.L15:
	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	"deficient number"
.LC2:
	.string	"perfect number"
.LC3:
	.string	"abundant number"
	.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
.L13:
	leaq	-20(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-20(%rbp), %eax
	testl	%eax, %eax
	je	.L17
	movl	-20(%rbp), %eax
	cmpl	$1, %eax
	jne	.L4
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	jmp	.L5
.L4:
	movl	$1, -16(%rbp)
	movl	$2, -12(%rbp)
	jmp	.L6
.L10:
	movl	-20(%rbp), %eax
	cltd
	idivl	-12(%rbp)
	movl	%edx, %eax
	testl	%eax, %eax
	jne	.L7
	movl	-20(%rbp), %eax
	cltd
	idivl	-12(%rbp)
	movl	%eax, %edx
	movl	-12(%rbp), %eax
	addl	%edx, %eax
	addl	%eax, -16(%rbp)
	movl	-20(%rbp), %eax
	cltd
	idivl	-12(%rbp)
	cmpl	%eax, -12(%rbp)
	jne	.L7
	movl	-12(%rbp), %eax
	subl	%eax, -16(%rbp)
.L7:
	movl	-20(%rbp), %eax
	cmpl	%eax, -16(%rbp)
	jg	.L18
	addl	$1, -12(%rbp)
.L6:
	movl	-12(%rbp), %eax
	imull	%eax, %eax
	movl	%eax, %edx
	movl	-20(%rbp), %eax
	cmpl	%eax, %edx
	jle	.L10
	jmp	.L9
.L18:
	nop
.L9:
	movl	-20(%rbp), %eax
	cmpl	%eax, -16(%rbp)
	jne	.L11
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
.L11:
	movl	-20(%rbp), %eax
	cmpl	%eax, -16(%rbp)
	jge	.L12
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
.L12:
	movl	-20(%rbp), %eax
	cmpl	%eax, -16(%rbp)
	jle	.L13
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
.L5:
	jmp	.L13
.L17:
	nop
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L15
	call	__stack_chk_fail@PLT
.L15:
	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:
