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 f;
	int i;
	int l, s, n;
	int b[10];
	int w, w2;
	int count;
	int num[4];
	
	while (scanf("%d", &n), n != 0){
		count = 0;
		f = 0;
		while (n != 6174){
			w = 1000;
			for (i = 0; i < 10; i++){
				b[i] = 0;
			}
			for (i = 0; i < 4; i++){
				num[i] = n / w;
				n %= w;
				w /= 10;
				b[num[i]]++;
			}
			
			w = 1000; w2 = 1;
			s = 0; l = 0;
			for (i = 0; i < 10; i++){
				while (b[i] > 0){
					s += i * w;
					w /= 10;
					l += i * w2;
					w2 *= 10;
					b[i]--;
				}
			}
			n = l - s;
			count++;
			if (n == 0){
				printf("NA\n");
				f = 1;
				break;
			}
		}
		if (f == 0){
			printf("%d\n", count);
		}
	}
	
	return (0);
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"NA"
.LC1:
	.string	"%d\n"
.LC2:
	.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	$96, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	jmp	.L2
.L14:
	movl	$0, -68(%rbp)
	movl	$0, -92(%rbp)
	jmp	.L3
.L13:
	movl	$1000, -76(%rbp)
	movl	$0, -88(%rbp)
	jmp	.L4
.L5:
	movl	-88(%rbp), %eax
	cltq
	movl	$0, -48(%rbp,%rax,4)
	addl	$1, -88(%rbp)
.L4:
	cmpl	$9, -88(%rbp)
	jle	.L5
	movl	$0, -88(%rbp)
	jmp	.L6
.L7:
	movl	-96(%rbp), %eax
	cltd
	idivl	-76(%rbp)
	movl	%eax, %edx
	movl	-88(%rbp), %eax
	cltq
	movl	%edx, -64(%rbp,%rax,4)
	movl	-96(%rbp), %eax
	cltd
	idivl	-76(%rbp)
	movl	%edx, %eax
	movl	%eax, -96(%rbp)
	movl	-76(%rbp), %eax
	movslq	%eax, %rdx
	imulq	$1717986919, %rdx, %rdx
	shrq	$32, %rdx
	sarl	$2, %edx
	sarl	$31, %eax
	movl	%eax, %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	movl	%eax, -76(%rbp)
	movl	-88(%rbp), %eax
	cltq
	movl	-64(%rbp,%rax,4), %eax
	movslq	%eax, %rdx
	movl	-48(%rbp,%rdx,4), %edx
	addl	$1, %edx
	cltq
	movl	%edx, -48(%rbp,%rax,4)
	addl	$1, -88(%rbp)
.L6:
	cmpl	$3, -88(%rbp)
	jle	.L7
	movl	$1000, -76(%rbp)
	movl	$1, -72(%rbp)
	movl	$0, -80(%rbp)
	movl	$0, -84(%rbp)
	movl	$0, -88(%rbp)
	jmp	.L8
.L10:
	movl	-88(%rbp), %eax
	imull	-76(%rbp), %eax
	addl	%eax, -80(%rbp)
	movl	-76(%rbp), %eax
	movslq	%eax, %rdx
	imulq	$1717986919, %rdx, %rdx
	shrq	$32, %rdx
	sarl	$2, %edx
	sarl	$31, %eax
	movl	%eax, %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	movl	%eax, -76(%rbp)
	movl	-88(%rbp), %eax
	imull	-72(%rbp), %eax
	addl	%eax, -84(%rbp)
	movl	-72(%rbp), %edx
	movl	%edx, %eax
	sall	$2, %eax
	addl	%edx, %eax
	addl	%eax, %eax
	movl	%eax, -72(%rbp)
	movl	-88(%rbp), %eax
	cltq
	movl	-48(%rbp,%rax,4), %eax
	leal	-1(%rax), %edx
	movl	-88(%rbp), %eax
	cltq
	movl	%edx, -48(%rbp,%rax,4)
.L9:
	movl	-88(%rbp), %eax
	cltq
	movl	-48(%rbp,%rax,4), %eax
	testl	%eax, %eax
	jg	.L10
	addl	$1, -88(%rbp)
.L8:
	cmpl	$9, -88(%rbp)
	jle	.L9
	movl	-84(%rbp), %eax
	subl	-80(%rbp), %eax
	movl	%eax, -96(%rbp)
	addl	$1, -68(%rbp)
	movl	-96(%rbp), %eax
	testl	%eax, %eax
	jne	.L3
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	movl	$1, -92(%rbp)
	jmp	.L12
.L3:
	movl	-96(%rbp), %eax
	cmpl	$6174, %eax
	jne	.L13
.L12:
	cmpl	$0, -92(%rbp)
	jne	.L2
	movl	-68(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L2:
	leaq	-96(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-96(%rbp), %eax
	testl	%eax, %eax
	jne	.L14
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L16
	call	__stack_chk_fail@PLT
.L16:
	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	"NA"
.LC1:
	.string	"%d\n"
.LC2:
	.string	"%d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	leaq	.LC2(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	leaq	.LC1(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	leaq	.LC0(%rip), %rbx
	subq	$64, %rsp
	.cfi_def_cfa_offset 112
	movq	%fs:40, %rax
	movq	%rax, 56(%rsp)
	xorl	%eax, %eax
	leaq	12(%rsp), %r13
.L2:
	xorl	%eax, %eax
	movq	%r13, %rsi
	movq	%r12, %rdi
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %r8d
	pxor	%xmm0, %xmm0
	testl	%r8d, %r8d
	je	.L21
	xorl	%eax, %eax
	xorl	%r9d, %r9d
	.p2align 4,,10
	.p2align 3
.L6:
	cmpl	$6174, %r8d
	je	.L8
	movslq	%r8d, %rax
	movl	%r8d, %edx
	movaps	%xmm0, 16(%rsp)
	leaq	16(%rsp), %r11
	imulq	$274877907, %rax, %rax
	sarl	$31, %edx
	xorl	%r10d, %r10d
	xorl	%edi, %edi
	movq	$0, 48(%rsp)
	movl	$1000, %ecx
	movaps	%xmm0, 32(%rsp)
	sarq	$38, %rax
	subl	%edx, %eax
	imull	$1000, %eax, %edx
	cltq
	addl	$1, 16(%rsp,%rax,4)
	subl	%edx, %r8d
	movslq	%r8d, %rax
	movl	%r8d, %edx
	imulq	$1374389535, %rax, %rax
	sarl	$31, %edx
	sarq	$37, %rax
	subl	%edx, %eax
	imull	$100, %eax, %edx
	cltq
	addl	$1, 16(%rsp,%rax,4)
	subl	%edx, %r8d
	movslq	%r8d, %rax
	movl	%r8d, %edx
	imulq	$1717986919, %rax, %rax
	sarl	$31, %edx
	sarq	$34, %rax
	subl	%edx, %eax
	leal	(%rax,%rax,4), %edx
	cltq
	addl	%edx, %edx
	addl	$1, 16(%rsp,%rax,4)
	subl	%edx, %r8d
	movslq	%r8d, %rax
	xorl	%r8d, %r8d
	addl	$1, 16(%rsp,%rax,4)
	movl	$1, %eax
	.p2align 4,,10
	.p2align 3
.L9:
	movl	(%r11), %esi
	testl	%esi, %esi
	jle	.L5
	.p2align 4,,10
	.p2align 3
.L3:
	movl	%edi, %edx
	imull	%ecx, %edx
	addl	%edx, %r10d
	movslq	%ecx, %rdx
	sarl	$31, %ecx
	imulq	$1717986919, %rdx, %rdx
	movl	%ecx, %r14d
	sarq	$34, %rdx
	movl	%edx, %ecx
	movl	%edi, %edx
	imull	%eax, %edx
	leal	(%rax,%rax,4), %eax
	subl	%r14d, %ecx
	addl	%eax, %eax
	addl	%edx, %r8d
	subl	$1, %esi
	jne	.L3
	movl	$0, (%r11)
.L5:
	addl	$1, %edi
	addq	$4, %r11
	cmpl	$10, %edi
	jne	.L9
	addl	$1, %r9d
	movl	$1, %eax
	subl	%r10d, %r8d
	jne	.L6
	movq	%rbx, %rdi
	movl	$0, 12(%rsp)
	call	puts@PLT
	jmp	.L2
.L8:
	testb	%al, %al
	je	.L10
	movl	$6174, 12(%rsp)
.L10:
	movl	%r9d, %edx
	movq	%rbp, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L2
.L21:
	movq	56(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L22
	addq	$64, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 48
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.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	"NA"
.LC1:
	.string	"%d\n"
.LC2:
	.string	"%d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	leaq	.LC2(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	leaq	.LC1(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	leaq	.LC0(%rip), %rbx
	subq	$64, %rsp
	.cfi_def_cfa_offset 112
	movq	%fs:40, %rax
	movq	%rax, 56(%rsp)
	xorl	%eax, %eax
	leaq	12(%rsp), %r13
.L2:
	xorl	%eax, %eax
	movq	%r13, %rsi
	movq	%r12, %rdi
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %r8d
	pxor	%xmm0, %xmm0
	testl	%r8d, %r8d
	je	.L21
	xorl	%eax, %eax
	xorl	%r9d, %r9d
	.p2align 4,,10
	.p2align 3
.L6:
	cmpl	$6174, %r8d
	je	.L8
	movslq	%r8d, %rax
	movl	%r8d, %edx
	movaps	%xmm0, 16(%rsp)
	leaq	16(%rsp), %r11
	imulq	$274877907, %rax, %rax
	sarl	$31, %edx
	xorl	%r10d, %r10d
	xorl	%edi, %edi
	movq	$0, 48(%rsp)
	movl	$1000, %ecx
	movaps	%xmm0, 32(%rsp)
	sarq	$38, %rax
	subl	%edx, %eax
	imull	$1000, %eax, %edx
	cltq
	addl	$1, 16(%rsp,%rax,4)
	subl	%edx, %r8d
	movslq	%r8d, %rax
	movl	%r8d, %edx
	imulq	$1374389535, %rax, %rax
	sarl	$31, %edx
	sarq	$37, %rax
	subl	%edx, %eax
	imull	$100, %eax, %edx
	cltq
	addl	$1, 16(%rsp,%rax,4)
	subl	%edx, %r8d
	movslq	%r8d, %rax
	movl	%r8d, %edx
	imulq	$1717986919, %rax, %rax
	sarl	$31, %edx
	sarq	$34, %rax
	subl	%edx, %eax
	leal	(%rax,%rax,4), %edx
	cltq
	addl	%edx, %edx
	addl	$1, 16(%rsp,%rax,4)
	subl	%edx, %r8d
	movslq	%r8d, %rax
	xorl	%r8d, %r8d
	addl	$1, 16(%rsp,%rax,4)
	movl	$1, %eax
	.p2align 4,,10
	.p2align 3
.L9:
	movl	(%r11), %esi
	testl	%esi, %esi
	jle	.L5
	.p2align 4,,10
	.p2align 3
.L3:
	movl	%edi, %edx
	imull	%ecx, %edx
	addl	%edx, %r10d
	movslq	%ecx, %rdx
	sarl	$31, %ecx
	imulq	$1717986919, %rdx, %rdx
	movl	%ecx, %r14d
	sarq	$34, %rdx
	movl	%edx, %ecx
	movl	%edi, %edx
	imull	%eax, %edx
	leal	(%rax,%rax,4), %eax
	subl	%r14d, %ecx
	addl	%eax, %eax
	addl	%edx, %r8d
	subl	$1, %esi
	jne	.L3
	movl	$0, (%r11)
.L5:
	addl	$1, %edi
	addq	$4, %r11
	cmpl	$10, %edi
	jne	.L9
	addl	$1, %r9d
	movl	$1, %eax
	subl	%r10d, %r8d
	jne	.L6
	movq	%rbx, %rdi
	movl	$0, 12(%rsp)
	call	puts@PLT
	jmp	.L2
.L8:
	testb	%al, %al
	je	.L10
	movl	$6174, 12(%rsp)
.L10:
	movl	%r9d, %edx
	movq	%rbp, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L2
.L21:
	movq	56(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L22
	addq	$64, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 48
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.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 f;
	int i;
	int l, s, n;
	int b[10];
	int w, w2;
	int count;
	int num[4];
	
	while (scanf("%d", &n), n != 0){
		count = 0;
		f = 0;
		while (n != 6174){
			w = 1000;
			for (i = 0; i < 10; i++){
				b[i] = 0;
			}
			for (i = 0; i < 4; i++){
				num[i] = n / w;
				n %= w;
				w /= 10;
				b[num[i]]++;
			}
			
			w = 1000; w2 = 1;
			s = 0; l = 0;
			for (i = 0; i < 10; i++){
				while (b[i] > 0){
					s += i * w;
					w /= 10;
					l += i * w2;
					w2 *= 10;
					b[i]--;
				}
			}
			n = l - s;
			count++;
			if (n == 0){
				printf("NA\n");
				f = 1;
				break;
			}
		}
		if (f == 0){
			printf("%d\n", count);
		}
	}
	
	return (0);
}
6174
3985
3333
0000
 6174
1779
3333
0000
 6174
1779
2211
0000
 6174
2012
3078
0000
 6174
3985
5889
0000
 6174
2012
3639
0000
 6174
1794
3333
0000
 6174
1779
1275
0000
 6174
1289
3078
0000
 6174
3985
4510
0000

0
3
NA
 0
6
NA
 0
6
4
 0
3
2
 0
3
4
 0
3
3
 0
5
NA
 0
6
3
 0
2
2
 0
3
5

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 f;
	int i;
	int l, s, n;
	int b[10];
	int w, w2;
	int count;
	int num[4];
	
	while (scanf("%d", &n), n != 0){
		count = 0;
		f = 0;
		while (n != 6174){
			w = 1000;
			for (i = 0; i < 10; i++){
				b[i] = 0;
			}
			for (i = 0; i < 4; i++){
				num[i] = n / w;
				n %= w;
				w /= 10;
				b[num[i]]++;
			}
			
			w = 1000; w2 = 1;
			s = 0; l = 0;
			for (i = 0; i < 10; i++){
				while (b[i] > 0){
					s += i * w;
					w /= 10;
					l += i * w2;
					w2 *= 10;
					b[i]--;
				}
			}
			n = l - s;
			count++;
			if (n == 0){
				printf("NA\n");
				f = 1;
				break;
			}
		}
		if (f == 0){
			printf("%d\n", count);
		}
	}
	
	return (0);
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"NA"
.LC1:
	.string	"%d\n"
.LC2:
	.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	$96, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	jmp	.L2
.L14:
	movl	$0, -68(%rbp)
	movl	$0, -92(%rbp)
	jmp	.L3
.L13:
	movl	$1000, -76(%rbp)
	movl	$0, -88(%rbp)
	jmp	.L4
.L5:
	movl	-88(%rbp), %eax
	cltq
	movl	$0, -48(%rbp,%rax,4)
	addl	$1, -88(%rbp)
.L4:
	cmpl	$9, -88(%rbp)
	jle	.L5
	movl	$0, -88(%rbp)
	jmp	.L6
.L7:
	movl	-96(%rbp), %eax
	cltd
	idivl	-76(%rbp)
	movl	%eax, %edx
	movl	-88(%rbp), %eax
	cltq
	movl	%edx, -64(%rbp,%rax,4)
	movl	-96(%rbp), %eax
	cltd
	idivl	-76(%rbp)
	movl	%edx, %eax
	movl	%eax, -96(%rbp)
	movl	-76(%rbp), %eax
	movslq	%eax, %rdx
	imulq	$1717986919, %rdx, %rdx
	shrq	$32, %rdx
	sarl	$2, %edx
	sarl	$31, %eax
	movl	%eax, %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	movl	%eax, -76(%rbp)
	movl	-88(%rbp), %eax
	cltq
	movl	-64(%rbp,%rax,4), %eax
	movslq	%eax, %rdx
	movl	-48(%rbp,%rdx,4), %edx
	addl	$1, %edx
	cltq
	movl	%edx, -48(%rbp,%rax,4)
	addl	$1, -88(%rbp)
.L6:
	cmpl	$3, -88(%rbp)
	jle	.L7
	movl	$1000, -76(%rbp)
	movl	$1, -72(%rbp)
	movl	$0, -80(%rbp)
	movl	$0, -84(%rbp)
	movl	$0, -88(%rbp)
	jmp	.L8
.L10:
	movl	-88(%rbp), %eax
	imull	-76(%rbp), %eax
	addl	%eax, -80(%rbp)
	movl	-76(%rbp), %eax
	movslq	%eax, %rdx
	imulq	$1717986919, %rdx, %rdx
	shrq	$32, %rdx
	sarl	$2, %edx
	sarl	$31, %eax
	movl	%eax, %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	movl	%eax, -76(%rbp)
	movl	-88(%rbp), %eax
	imull	-72(%rbp), %eax
	addl	%eax, -84(%rbp)
	movl	-72(%rbp), %edx
	movl	%edx, %eax
	sall	$2, %eax
	addl	%edx, %eax
	addl	%eax, %eax
	movl	%eax, -72(%rbp)
	movl	-88(%rbp), %eax
	cltq
	movl	-48(%rbp,%rax,4), %eax
	leal	-1(%rax), %edx
	movl	-88(%rbp), %eax
	cltq
	movl	%edx, -48(%rbp,%rax,4)
.L9:
	movl	-88(%rbp), %eax
	cltq
	movl	-48(%rbp,%rax,4), %eax
	testl	%eax, %eax
	jg	.L10
	addl	$1, -88(%rbp)
.L8:
	cmpl	$9, -88(%rbp)
	jle	.L9
	movl	-84(%rbp), %eax
	subl	-80(%rbp), %eax
	movl	%eax, -96(%rbp)
	addl	$1, -68(%rbp)
	movl	-96(%rbp), %eax
	testl	%eax, %eax
	jne	.L3
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	movl	$1, -92(%rbp)
	jmp	.L12
.L3:
	movl	-96(%rbp), %eax
	cmpl	$6174, %eax
	jne	.L13
.L12:
	cmpl	$0, -92(%rbp)
	jne	.L2
	movl	-68(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L2:
	leaq	-96(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-96(%rbp), %eax
	testl	%eax, %eax
	jne	.L14
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L16
	call	__stack_chk_fail@PLT
.L16:
	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	"NA"
.LC1:
	.string	"%d\n"
.LC2:
	.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	$96, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	jmp	.L2
.L14:
	movl	$0, -68(%rbp)
	movl	$0, -92(%rbp)
	jmp	.L3
.L13:
	movl	$1000, -76(%rbp)
	movl	$0, -88(%rbp)
	jmp	.L4
.L5:
	movl	-88(%rbp), %eax
	cltq
	movl	$0, -48(%rbp,%rax,4)
	addl	$1, -88(%rbp)
.L4:
	cmpl	$9, -88(%rbp)
	jle	.L5
	movl	$0, -88(%rbp)
	jmp	.L6
.L7:
	movl	-96(%rbp), %eax
	cltd
	idivl	-76(%rbp)
	movl	%eax, %edx
	movl	-88(%rbp), %eax
	cltq
	movl	%edx, -64(%rbp,%rax,4)
	movl	-96(%rbp), %eax
	cltd
	idivl	-76(%rbp)
	movl	%edx, %eax
	movl	%eax, -96(%rbp)
	movl	-76(%rbp), %eax
	movslq	%eax, %rdx
	imulq	$1717986919, %rdx, %rdx
	shrq	$32, %rdx
	sarl	$2, %edx
	sarl	$31, %eax
	movl	%eax, %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	movl	%eax, -76(%rbp)
	movl	-88(%rbp), %eax
	cltq
	movl	-64(%rbp,%rax,4), %eax
	movslq	%eax, %rdx
	movl	-48(%rbp,%rdx,4), %edx
	addl	$1, %edx
	cltq
	movl	%edx, -48(%rbp,%rax,4)
	addl	$1, -88(%rbp)
.L6:
	cmpl	$3, -88(%rbp)
	jle	.L7
	movl	$1000, -76(%rbp)
	movl	$1, -72(%rbp)
	movl	$0, -80(%rbp)
	movl	$0, -84(%rbp)
	movl	$0, -88(%rbp)
	jmp	.L8
.L10:
	movl	-88(%rbp), %eax
	imull	-76(%rbp), %eax
	addl	%eax, -80(%rbp)
	movl	-76(%rbp), %eax
	movslq	%eax, %rdx
	imulq	$1717986919, %rdx, %rdx
	shrq	$32, %rdx
	sarl	$2, %edx
	sarl	$31, %eax
	movl	%eax, %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	movl	%eax, -76(%rbp)
	movl	-88(%rbp), %eax
	imull	-72(%rbp), %eax
	addl	%eax, -84(%rbp)
	movl	-72(%rbp), %edx
	movl	%edx, %eax
	sall	$2, %eax
	addl	%edx, %eax
	addl	%eax, %eax
	movl	%eax, -72(%rbp)
	movl	-88(%rbp), %eax
	cltq
	movl	-48(%rbp,%rax,4), %eax
	leal	-1(%rax), %edx
	movl	-88(%rbp), %eax
	cltq
	movl	%edx, -48(%rbp,%rax,4)
.L9:
	movl	-88(%rbp), %eax
	cltq
	movl	-48(%rbp,%rax,4), %eax
	testl	%eax, %eax
	jg	.L10
	addl	$1, -88(%rbp)
.L8:
	cmpl	$9, -88(%rbp)
	jle	.L9
	movl	-84(%rbp), %eax
	subl	-80(%rbp), %eax
	movl	%eax, -96(%rbp)
	addl	$1, -68(%rbp)
	movl	-96(%rbp), %eax
	testl	%eax, %eax
	jne	.L3
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	movl	$1, -92(%rbp)
	jmp	.L12
.L3:
	movl	-96(%rbp), %eax
	cmpl	$6174, %eax
	jne	.L13
.L12:
	cmpl	$0, -92(%rbp)
	jne	.L2
	movl	-68(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L2:
	leaq	-96(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-96(%rbp), %eax
	testl	%eax, %eax
	jne	.L14
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L16
	call	__stack_chk_fail@PLT
.L16:
	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:
