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

```c
i,S,m;main(n){for(;~scanf("%d",&n);i||(S=m=0))++i>0?i>3?i=-n:(S+=n*n,m=n>m?n:m):puts(S-m*m<n*n*4?"OK":"NA");}```

Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"OK"
.LC1:
	.string	"NA"
.LC2:
	.string	"%d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	leaq	.LC0(%rip), %r13
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	leaq	.LC1(%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	.LC2(%rip), %rbx
	subq	$24, %rsp
	.cfi_def_cfa_offset 64
	movl	%edi, 12(%rsp)
	leaq	12(%rsp), %rbp
	.p2align 4,,10
	.p2align 3
.L9:
	xorl	%eax, %eax
	movq	%rbp, %rsi
	movq	%rbx, %rdi
	call	scanf@PLT
	cmpl	$-1, %eax
	je	.L14
	movl	i(%rip), %eax
	leal	1(%rax), %edx
	movl	12(%rsp), %eax
	movl	%edx, i(%rip)
	testl	%edx, %edx
	jle	.L3
	cmpl	$3, %edx
	jle	.L4
	negl	%eax
	movl	%eax, i(%rip)
.L5:
	testl	%eax, %eax
	jne	.L9
	movl	$0, m(%rip)
	movl	$0, S(%rip)
	jmp	.L9
	.p2align 4,,10
	.p2align 3
.L3:
	movl	m(%rip), %edx
	imull	%eax, %eax
	movl	S(%rip), %ecx
	movq	%r12, %rdi
	imull	%edx, %edx
	sall	$2, %eax
	subl	%edx, %ecx
	cmpl	%eax, %ecx
	cmovl	%r13, %rdi
	call	puts@PLT
	movl	i(%rip), %eax
	jmp	.L5
	.p2align 4,,10
	.p2align 3
.L4:
	movl	%eax, %edx
	imull	%eax, %edx
	addl	%edx, S(%rip)
	movl	m(%rip), %edx
	cmpl	%eax, %edx
	cmovl	%eax, %edx
	movl	%edx, m(%rip)
	jmp	.L9
	.p2align 4,,10
	.p2align 3
.L14:
	addq	$24, %rsp
	.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
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.globl	m
	.bss
	.align 4
	.type	m, @object
	.size	m, 4
m:
	.zero	4
	.globl	S
	.align 4
	.type	S, @object
	.size	S, 4
S:
	.zero	4
	.globl	i
	.align 4
	.type	i, @object
	.size	i, 4
i:
	.zero	4
	.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.
Optimized Assembly Code:

user
```assembly
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"OK"
.LC1:
	.string	"NA"
.LC2:
	.string	"%d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	leaq	.LC0(%rip), %r13
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	leaq	.LC1(%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	.LC2(%rip), %rbx
	subq	$24, %rsp
	.cfi_def_cfa_offset 64
	movl	%edi, 12(%rsp)
	leaq	12(%rsp), %rbp
	.p2align 4,,10
	.p2align 3
.L9:
	xorl	%eax, %eax
	movq	%rbp, %rsi
	movq	%rbx, %rdi
	call	scanf@PLT
	cmpl	$-1, %eax
	je	.L14
	movl	i(%rip), %eax
	leal	1(%rax), %edx
	movl	12(%rsp), %eax
	movl	%edx, i(%rip)
	testl	%edx, %edx
	jle	.L3
	cmpl	$3, %edx
	jle	.L4
	negl	%eax
	movl	%eax, i(%rip)
.L5:
	testl	%eax, %eax
	jne	.L9
	movl	$0, m(%rip)
	movl	$0, S(%rip)
	jmp	.L9
	.p2align 4,,10
	.p2align 3
.L3:
	movl	m(%rip), %edx
	imull	%eax, %eax
	movl	S(%rip), %ecx
	movq	%r12, %rdi
	imull	%edx, %edx
	sall	$2, %eax
	subl	%edx, %ecx
	cmpl	%eax, %ecx
	cmovl	%r13, %rdi
	call	puts@PLT
	movl	i(%rip), %eax
	jmp	.L5
	.p2align 4,,10
	.p2align 3
.L4:
	movl	%eax, %edx
	imull	%eax, %edx
	addl	%edx, S(%rip)
	movl	m(%rip), %edx
	cmpl	%eax, %edx
	cmovl	%eax, %edx
	movl	%edx, m(%rip)
	jmp	.L9
	.p2align 4,,10
	.p2align 3
.L14:
	addq	$24, %rsp
	.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
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.globl	m
	.bss
	.align 4
	.type	m, @object
	.size	m, 4
m:
	.zero	4
	.globl	S
	.align 4
	.type	S, @object
	.size	S, 4
S:
	.zero	4
	.globl	i
	.align 4
	.type	i, @object
	.size	i, 4
i:
	.zero	4
	.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
```assembly
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"OK"
.LC1:
	.string	"NA"
.LC2:
	.string	"%d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	leaq	.LC0(%rip), %r13
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	leaq	.LC1(%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	.LC2(%rip), %rbx
	subq	$24, %rsp
	.cfi_def_cfa_offset 64
	movl	%edi, 12(%rsp)
	leaq	12(%rsp), %rbp
	.p2align 4,,10
	.p2align 3
.L9:
	xorl	%eax, %eax
	movq	%rbp, %rsi
	movq	%rbx, %rdi
	call	scanf@PLT
	cmpl	$-1, %eax
	je	.L14
	movl	i(%rip), %eax
	leal	1(%rax), %edx
	movl	12(%rsp), %eax
	movl	%edx, i(%rip)
	testl	%edx, %edx
	jle	.L3
	cmpl	$3, %edx
	jle	.L4
	negl	%eax
	movl	%eax, i(%rip)
.L5:
	testl	%eax, %eax
	jne	.L9
	movl	$0, m(%rip)
	movl	$0, S(%rip)
	jmp	.L9
	.p2align 4,,10
	.p2align 3
.L3:
	movl	m(%rip), %edx
	imull	%eax, %eax
	movl	S(%rip), %ecx
	movq	%r12, %rdi
	imull	%edx, %edx
	sall	$2, %eax
	subl	%edx, %ecx
	cmpl	%eax, %ecx
	cmovl	%r13, %rdi
	call	puts@PLT
	movl	i(%rip), %eax
	jmp	.L5
	.p2align 4,,10
	.p2align 3
.L4:
	movl	%eax, %edx
	imull	%eax, %edx
	addl	%edx, S(%rip)
	movl	m(%rip), %edx
	cmpl	%eax, %edx
	cmovl	%eax, %edx
	movl	%edx, m(%rip)
	jmp	.L9
	.p2align 4,,10
	.p2align 3
.L14:
	addq	$24, %rsp
	.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
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.globl	m
	.bss
	.align 4
	.type	m, @object
	.size	m, 4
m:
	.zero	4
	.globl	S
	.align 4
	.type	S, @object
	.size	S, 4
S:
	.zero	4
	.globl	i
	.align 4
	.type	i, @object
	.size	i, 4
i:
	.zero	4
	.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:
```
```c
i,S,m;main(n){for(;~scanf("%d",&n);i||(S=m=0))++i>0?i>3?i=-n:(S+=n*n,m=n>m?n:m):puts(S-m*m<n*n*4?"OK":"NA");}```
Given the following C code, your task is to generate highly optimized x86-64 assembly code.
C Code:

```c
i,S,m;main(n){for(;~scanf("%d",&n);i||(S=m=0))++i>0?i>3?i=-n:(S+=n*n,m=n>m?n:m):puts(S-m*m<n*n*4?"OK":"NA");}```

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.
Optimized Assembly Code:

10 6 8
5
4
1
6
2
5
0 0 0
 10 6 8
5
4
0
0
2
5
0 0 0
 10 6 8
5
4
0
0
2
7
0 0 0
 10 6 8
5
1
8
6
2
5
0 0 0
 10 6 4
5
4
0
-1
2
7
0 0 0
 10 6 4
5
4
0
-1
4
7
0 0 0
 10 3 8
5
4
0
6
2
5
0 0 0
 10 6 8
5
1
8
3
2
5
0 0 0
 10 2 8
5
1
8
11
2
5
0 0 0
 10 6 7
5
4
1
-2
8
7
0 0 0

NA
NA
OK
NA
NA
 NA
NA
NA
NA
NA
 NA
NA
NA
NA
OK
 NA
OK
OK
NA
NA
 OK
NA
NA
NA
OK
 OK
NA
NA
OK
OK
 NA
NA
OK
NA
OK
 NA
OK
NA
NA
NA
 NA
OK
OK
NA
OK
 NA
NA
NA
OK
OK

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

```c
i,S,m;main(n){for(;~scanf("%d",&n);i||(S=m=0))++i>0?i>3?i=-n:(S+=n*n,m=n>m?n:m):puts(S-m*m<n*n*4?"OK":"NA");}```

Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"OK"
.LC1:
	.string	"NA"
.LC2:
	.string	"%d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	leaq	.LC0(%rip), %r13
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	leaq	.LC1(%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	.LC2(%rip), %rbx
	subq	$24, %rsp
	.cfi_def_cfa_offset 64
	movl	%edi, 12(%rsp)
	leaq	12(%rsp), %rbp
	.p2align 4,,10
	.p2align 3
.L9:
	xorl	%eax, %eax
	movq	%rbp, %rsi
	movq	%rbx, %rdi
	call	scanf@PLT
	cmpl	$-1, %eax
	je	.L14
	movl	i(%rip), %eax
	leal	1(%rax), %edx
	movl	12(%rsp), %eax
	movl	%edx, i(%rip)
	testl	%edx, %edx
	jle	.L3
	cmpl	$3, %edx
	jle	.L4
	negl	%eax
	movl	%eax, i(%rip)
.L5:
	testl	%eax, %eax
	jne	.L9
	movl	$0, m(%rip)
	movl	$0, S(%rip)
	jmp	.L9
	.p2align 4,,10
	.p2align 3
.L3:
	movl	m(%rip), %edx
	imull	%eax, %eax
	movl	S(%rip), %ecx
	movq	%r12, %rdi
	imull	%edx, %edx
	sall	$2, %eax
	subl	%edx, %ecx
	cmpl	%eax, %ecx
	cmovl	%r13, %rdi
	call	puts@PLT
	movl	i(%rip), %eax
	jmp	.L5
	.p2align 4,,10
	.p2align 3
.L4:
	movl	%eax, %edx
	imull	%eax, %edx
	addl	%edx, S(%rip)
	movl	m(%rip), %edx
	cmpl	%eax, %edx
	cmovl	%eax, %edx
	movl	%edx, m(%rip)
	jmp	.L9
	.p2align 4,,10
	.p2align 3
.L14:
	addq	$24, %rsp
	.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
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.globl	m
	.bss
	.align 4
	.type	m, @object
	.size	m, 4
m:
	.zero	4
	.globl	S
	.align 4
	.type	S, @object
	.size	S, 4
S:
	.zero	4
	.globl	i
	.align 4
	.type	i, @object
	.size	i, 4
i:
	.zero	4
	.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.
Optimized Assembly Code:

train
```assembly
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"OK"
.LC1:
	.string	"NA"
.LC2:
	.string	"%d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	leaq	.LC0(%rip), %r13
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	leaq	.LC1(%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	.LC2(%rip), %rbx
	subq	$24, %rsp
	.cfi_def_cfa_offset 64
	movl	%edi, 12(%rsp)
	leaq	12(%rsp), %rbp
	.p2align 4,,10
	.p2align 3
.L9:
	xorl	%eax, %eax
	movq	%rbp, %rsi
	movq	%rbx, %rdi
	call	scanf@PLT
	cmpl	$-1, %eax
	je	.L14
	movl	i(%rip), %eax
	leal	1(%rax), %edx
	movl	12(%rsp), %eax
	movl	%edx, i(%rip)
	testl	%edx, %edx
	jle	.L3
	cmpl	$3, %edx
	jle	.L4
	negl	%eax
	movl	%eax, i(%rip)
.L5:
	testl	%eax, %eax
	jne	.L9
	movl	$0, m(%rip)
	movl	$0, S(%rip)
	jmp	.L9
	.p2align 4,,10
	.p2align 3
.L3:
	movl	m(%rip), %edx
	imull	%eax, %eax
	movl	S(%rip), %ecx
	movq	%r12, %rdi
	imull	%edx, %edx
	sall	$2, %eax
	subl	%edx, %ecx
	cmpl	%eax, %ecx
	cmovl	%r13, %rdi
	call	puts@PLT
	movl	i(%rip), %eax
	jmp	.L5
	.p2align 4,,10
	.p2align 3
.L4:
	movl	%eax, %edx
	imull	%eax, %edx
	addl	%edx, S(%rip)
	movl	m(%rip), %edx
	cmpl	%eax, %edx
	cmovl	%eax, %edx
	movl	%edx, m(%rip)
	jmp	.L9
	.p2align 4,,10
	.p2align 3
.L14:
	addq	$24, %rsp
	.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
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.globl	m
	.bss
	.align 4
	.type	m, @object
	.size	m, 4
m:
	.zero	4
	.globl	S
	.align 4
	.type	S, @object
	.size	S, 4
S:
	.zero	4
	.globl	i
	.align 4
	.type	i, @object
	.size	i, 4
i:
	.zero	4
	.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:
```