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>

typedef struct sweet{
        int num, p, q, r, col;
} Sweet;

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

                Sweet sweets[n];
                for(i=0; i<n; i++){
                        int num, p, q, r;
                        scanf("%d %d %d %d", &sweets[i].num, &sweets[i].p, &sweets[i].q, &sweets[i].r);
                        sweets[i].col = sweets[i].p*4 + sweets[i].q*9 + sweets[i].r*4;
                }

                int p, q, r, c, cnt=0;
                scanf("%d %d %d %d", &p, &q, &r, &c);

                for(i=0; i<n; i++){
                        Sweet sw = sweets[i];
                        if(sw.p<=p && sw.q<=q && sw.r<=r && sw.col<=c){
                                printf("%d\n", sw.num);
                                cnt++;
                        }
                }
                if(cnt==0) puts("NA");
        }
        return 0;
}

```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d %d %d %d"
.LC2:
	.string	"%d\n"
.LC3:
	.string	"NA"
	.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
	pushq	%r15
	pushq	%r14
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	subq	$88, %rsp
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	.cfi_offset 12, -48
	.cfi_offset 3, -56
	movq	%fs:40, %rax
	movq	%rax, -56(%rbp)
	xorl	%eax, %eax
.L13:
	movq	%rsp, %rax
	movq	%rax, %rbx
	leaq	-124(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-124(%rbp), %eax
	testl	%eax, %eax
	jne	.L2
	movq	%rbx, %rsp
	movl	$0, %eax
	movq	-56(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L14
	jmp	.L15
.L2:
	movl	-124(%rbp), %ecx
	movslq	%ecx, %rax
	subq	$1, %rax
	movq	%rax, -96(%rbp)
	movslq	%ecx, %rax
	movq	%rax, %r12
	movl	$0, %r13d
	imulq	$160, %r13, %rdx
	imulq	$0, %r12, %rax
	leaq	(%rdx,%rax), %rsi
	movl	$160, %eax
	mulq	%r12
	addq	%rdx, %rsi
	movq	%rsi, %rdx
	movslq	%ecx, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movslq	%ecx, %rax
	movq	%rax, %r14
	movl	$0, %r15d
	imulq	$160, %r15, %rdx
	imulq	$0, %r14, %rax
	leaq	(%rdx,%rax), %rsi
	movl	$160, %eax
	mulq	%r14
	addq	%rdx, %rsi
	movq	%rsi, %rdx
	movslq	%ecx, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	movl	$16, %eax
	subq	$1, %rax
	addq	%rdx, %rax
	movl	$16, %edi
	movl	$0, %edx
	divq	%rdi
	imulq	$16, %rax, %rax
	movq	%rax, %rcx
	andq	$-4096, %rcx
	movq	%rsp, %rdx
	subq	%rcx, %rdx
.L4:
	cmpq	%rdx, %rsp
	je	.L5
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L4
.L5:
	movq	%rax, %rdx
	andl	$4095, %edx
	subq	%rdx, %rsp
	movq	%rax, %rdx
	andl	$4095, %edx
	testq	%rdx, %rdx
	je	.L6
	andl	$4095, %eax
	subq	$8, %rax
	addq	%rsp, %rax
	orq	$0, (%rax)
.L6:
	movq	%rsp, %rax
	addq	$3, %rax
	shrq	$2, %rax
	salq	$2, %rax
	movq	%rax, -88(%rbp)
	movl	$0, -104(%rbp)
	jmp	.L7
.L8:
	movl	-104(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	-88(%rbp), %rdx
	addq	%rdx, %rax
	leaq	12(%rax), %rdi
	movl	-104(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	-88(%rbp), %rdx
	addq	%rdx, %rax
	leaq	8(%rax), %rcx
	movl	-104(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	-88(%rbp), %rdx
	addq	%rdx, %rax
	leaq	4(%rax), %rdx
	movl	-104(%rbp), %eax
	movslq	%eax, %rsi
	movq	%rsi, %rax
	salq	$2, %rax
	addq	%rsi, %rax
	salq	$2, %rax
	movq	-88(%rbp), %rsi
	addq	%rsi, %rax
	movq	%rdi, %r8
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	-88(%rbp), %rcx
	movl	-104(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	addq	$4, %rax
	movl	(%rax), %eax
	leal	0(,%rax,4), %esi
	movq	-88(%rbp), %rcx
	movl	-104(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	addq	$8, %rax
	movl	(%rax), %edx
	movl	%edx, %eax
	sall	$3, %eax
	addl	%edx, %eax
	addl	%eax, %esi
	movq	-88(%rbp), %rcx
	movl	-104(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	addq	$12, %rax
	movl	(%rax), %eax
	sall	$2, %eax
	leal	(%rsi,%rax), %ecx
	movq	-88(%rbp), %rsi
	movl	-104(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rsi, %rax
	addq	$16, %rax
	movl	%ecx, (%rax)
	addl	$1, -104(%rbp)
.L7:
	movl	-124(%rbp), %eax
	cmpl	%eax, -104(%rbp)
	jl	.L8
	movl	$0, -100(%rbp)
	leaq	-108(%rbp), %rsi
	leaq	-112(%rbp), %rcx
	leaq	-116(%rbp), %rdx
	leaq	-120(%rbp), %rax
	movq	%rsi, %r8
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -104(%rbp)
	jmp	.L9
.L11:
	movq	-88(%rbp), %rcx
	movl	-104(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rax, %rcx
	movq	(%rcx), %rax
	movq	8(%rcx), %rdx
	movq	%rax, -80(%rbp)
	movq	%rdx, -72(%rbp)
	movl	16(%rcx), %eax
	movl	%eax, -64(%rbp)
	movl	-76(%rbp), %edx
	movl	-120(%rbp), %eax
	cmpl	%eax, %edx
	jg	.L10
	movl	-72(%rbp), %edx
	movl	-116(%rbp), %eax
	cmpl	%eax, %edx
	jg	.L10
	movl	-68(%rbp), %edx
	movl	-112(%rbp), %eax
	cmpl	%eax, %edx
	jg	.L10
	movl	-64(%rbp), %edx
	movl	-108(%rbp), %eax
	cmpl	%eax, %edx
	jg	.L10
	movl	-80(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	addl	$1, -100(%rbp)
.L10:
	addl	$1, -104(%rbp)
.L9:
	movl	-124(%rbp), %eax
	cmpl	%eax, -104(%rbp)
	jl	.L11
	cmpl	$0, -100(%rbp)
	jne	.L12
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
.L12:
	movq	%rbx, %rsp
	jmp	.L13
.L15:
	call	__stack_chk_fail@PLT
.L14:
	leaq	-40(%rbp), %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.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 %d %d %d"
.LC2:
	.string	"NA"
.LC3:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%r15
	pushq	%r14
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	leaq	-76(%rbp), %r15
	pushq	%r13
	pushq	%r12
	.cfi_offset 13, -40
	.cfi_offset 12, -48
	leaq	.LC1(%rip), %r12
	pushq	%rbx
	subq	$56, %rsp
	.cfi_offset 3, -56
	movq	%fs:40, %rax
	movq	%rax, -56(%rbp)
	xorl	%eax, %eax
	.p2align 4,,10
	.p2align 3
.L14:
	movq	%r15, %rsi
	leaq	.LC0(%rip), %rdi
	xorl	%eax, %eax
	movq	%rsp, %r13
	call	__isoc99_scanf@PLT
	movl	-76(%rbp), %ecx
	testl	%ecx, %ecx
	je	.L2
	movslq	%ecx, %rax
	movq	%rsp, %rsi
	leaq	(%rax,%rax,4), %rax
	leaq	15(,%rax,4), %rax
	movq	%rax, %rdx
	andq	$-4096, %rax
	subq	%rax, %rsi
	andq	$-16, %rdx
	cmpq	%rsi, %rsp
	je	.L4
.L28:
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	cmpq	%rsi, %rsp
	jne	.L28
.L4:
	andl	$4095, %edx
	subq	%rdx, %rsp
	testq	%rdx, %rdx
	je	.L5
	orq	$0, -8(%rsp,%rdx)
.L5:
	movq	%rsp, %rax
	xorl	%ebx, %ebx
	movq	%rax, -88(%rbp)
	leaq	4(%rax), %r14
	testl	%ecx, %ecx
	jle	.L10
	.p2align 4,,10
	.p2align 3
.L9:
	leaq	4(%r14), %rcx
	leaq	-4(%r14), %rsi
	movq	%r14, %rdx
	movq	%r12, %rdi
	leaq	8(%r14), %r8
	xorl	%eax, %eax
	addl	$1, %ebx
	addq	$20, %r14
	call	__isoc99_scanf@PLT
	movl	-16(%r14), %eax
	movl	-20(%r14), %ecx
	leal	(%rax,%rax,8), %eax
	leal	(%rax,%rcx,4), %eax
	movl	-12(%r14), %ecx
	leal	(%rax,%rcx,4), %eax
	movl	%eax, -8(%r14)
	cmpl	%ebx, -76(%rbp)
	jg	.L9
.L10:
	leaq	-64(%rbp), %rcx
	leaq	-60(%rbp), %r8
	movq	%r12, %rdi
	xorl	%eax, %eax
	leaq	-68(%rbp), %rdx
	leaq	-72(%rbp), %rsi
	call	__isoc99_scanf@PLT
	movl	-76(%rbp), %eax
	movq	-88(%rbp), %rbx
	xorl	%r8d, %r8d
	xorl	%ecx, %ecx
	testl	%eax, %eax
	jle	.L8
	.p2align 4,,10
	.p2align 3
.L13:
	movl	4(%rbx), %edi
	cmpl	%edi, -72(%rbp)
	jl	.L12
	movl	8(%rbx), %edx
	cmpl	%edx, -68(%rbp)
	jl	.L12
	movl	12(%rbx), %edx
	cmpl	%edx, -64(%rbp)
	jl	.L12
	movl	16(%rbx), %edi
	cmpl	%edi, -60(%rbp)
	jge	.L29
	.p2align 4,,10
	.p2align 3
.L12:
	addl	$1, %ecx
	addq	$20, %rbx
	cmpl	%eax, %ecx
	jl	.L13
	testl	%r8d, %r8d
	je	.L8
.L11:
	movq	%r13, %rsp
	jmp	.L14
	.p2align 4,,10
	.p2align 3
.L29:
	movl	(%rbx), %edx
	leaq	.LC3(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	movl	%ecx, -92(%rbp)
	movl	%r8d, -88(%rbp)
	call	__printf_chk@PLT
	movl	-88(%rbp), %r8d
	movl	-76(%rbp), %eax
	movl	-92(%rbp), %ecx
	addl	$1, %r8d
	jmp	.L12
	.p2align 4,,10
	.p2align 3
.L8:
	leaq	.LC2(%rip), %rdi
	call	puts@PLT
	jmp	.L11
	.p2align 4,,10
	.p2align 3
.L2:
	movq	-56(%rbp), %rax
	subq	%fs:40, %rax
	jne	.L30
	leaq	-40(%rbp), %rsp
	xorl	%eax, %eax
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_remember_state
	.cfi_def_cfa 7, 8
	ret
.L30:
	.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 %d %d %d"
.LC2:
	.string	"NA"
.LC3:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%r15
	pushq	%r14
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	leaq	-76(%rbp), %r15
	pushq	%r13
	pushq	%r12
	.cfi_offset 13, -40
	.cfi_offset 12, -48
	leaq	.LC1(%rip), %r12
	pushq	%rbx
	subq	$56, %rsp
	.cfi_offset 3, -56
	movq	%fs:40, %rax
	movq	%rax, -56(%rbp)
	xorl	%eax, %eax
	.p2align 4,,10
	.p2align 3
.L14:
	movq	%r15, %rsi
	leaq	.LC0(%rip), %rdi
	xorl	%eax, %eax
	movq	%rsp, %r13
	call	__isoc99_scanf@PLT
	movl	-76(%rbp), %ecx
	testl	%ecx, %ecx
	je	.L2
	movslq	%ecx, %rax
	movq	%rsp, %rsi
	leaq	(%rax,%rax,4), %rax
	leaq	15(,%rax,4), %rax
	movq	%rax, %rdx
	andq	$-4096, %rax
	subq	%rax, %rsi
	andq	$-16, %rdx
	cmpq	%rsi, %rsp
	je	.L4
.L28:
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	cmpq	%rsi, %rsp
	jne	.L28
.L4:
	andl	$4095, %edx
	subq	%rdx, %rsp
	testq	%rdx, %rdx
	je	.L5
	orq	$0, -8(%rsp,%rdx)
.L5:
	movq	%rsp, %rax
	xorl	%ebx, %ebx
	movq	%rax, -88(%rbp)
	leaq	4(%rax), %r14
	testl	%ecx, %ecx
	jle	.L10
	.p2align 4,,10
	.p2align 3
.L9:
	leaq	4(%r14), %rcx
	leaq	-4(%r14), %rsi
	movq	%r14, %rdx
	movq	%r12, %rdi
	leaq	8(%r14), %r8
	xorl	%eax, %eax
	addl	$1, %ebx
	addq	$20, %r14
	call	__isoc99_scanf@PLT
	movl	-16(%r14), %eax
	movl	-20(%r14), %ecx
	leal	(%rax,%rax,8), %eax
	leal	(%rax,%rcx,4), %eax
	movl	-12(%r14), %ecx
	leal	(%rax,%rcx,4), %eax
	movl	%eax, -8(%r14)
	cmpl	%ebx, -76(%rbp)
	jg	.L9
.L10:
	leaq	-64(%rbp), %rcx
	leaq	-60(%rbp), %r8
	movq	%r12, %rdi
	xorl	%eax, %eax
	leaq	-68(%rbp), %rdx
	leaq	-72(%rbp), %rsi
	call	__isoc99_scanf@PLT
	movl	-76(%rbp), %eax
	movq	-88(%rbp), %rbx
	xorl	%r8d, %r8d
	xorl	%ecx, %ecx
	testl	%eax, %eax
	jle	.L8
	.p2align 4,,10
	.p2align 3
.L13:
	movl	4(%rbx), %edi
	cmpl	%edi, -72(%rbp)
	jl	.L12
	movl	8(%rbx), %edx
	cmpl	%edx, -68(%rbp)
	jl	.L12
	movl	12(%rbx), %edx
	cmpl	%edx, -64(%rbp)
	jl	.L12
	movl	16(%rbx), %edi
	cmpl	%edi, -60(%rbp)
	jge	.L29
	.p2align 4,,10
	.p2align 3
.L12:
	addl	$1, %ecx
	addq	$20, %rbx
	cmpl	%eax, %ecx
	jl	.L13
	testl	%r8d, %r8d
	je	.L8
.L11:
	movq	%r13, %rsp
	jmp	.L14
	.p2align 4,,10
	.p2align 3
.L29:
	movl	(%rbx), %edx
	leaq	.LC3(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	movl	%ecx, -92(%rbp)
	movl	%r8d, -88(%rbp)
	call	__printf_chk@PLT
	movl	-88(%rbp), %r8d
	movl	-76(%rbp), %eax
	movl	-92(%rbp), %ecx
	addl	$1, %r8d
	jmp	.L12
	.p2align 4,,10
	.p2align 3
.L8:
	leaq	.LC2(%rip), %rdi
	call	puts@PLT
	jmp	.L11
	.p2align 4,,10
	.p2align 3
.L2:
	movq	-56(%rbp), %rax
	subq	%fs:40, %rax
	jne	.L30
	leaq	-40(%rbp), %rsp
	xorl	%eax, %eax
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_remember_state
	.cfi_def_cfa 7, 8
	ret
.L30:
	.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>

typedef struct sweet{
        int num, p, q, r, col;
} Sweet;

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

                Sweet sweets[n];
                for(i=0; i<n; i++){
                        int num, p, q, r;
                        scanf("%d %d %d %d", &sweets[i].num, &sweets[i].p, &sweets[i].q, &sweets[i].r);
                        sweets[i].col = sweets[i].p*4 + sweets[i].q*9 + sweets[i].r*4;
                }

                int p, q, r, c, cnt=0;
                scanf("%d %d %d %d", &p, &q, &r, &c);

                for(i=0; i<n; i++){
                        Sweet sw = sweets[i];
                        if(sw.p<=p && sw.q<=q && sw.r<=r && sw.col<=c){
                                printf("%d\n", sw.num);
                                cnt++;
                        }
                }
                if(cnt==0) puts("NA");
        }
        return 0;
}


4
1 7 14 47
2 5 35 55
3 6 3 59
4 6 5 15
10 15 50 110
2
1 8 10 78
2 4 18 33
10 10 50 300
0
 4
1 7 14 47
2 7 35 55
3 6 3 78
4 2 7 15
10 15 50 110
2
1 8 10 215
0 4 8 33
4 10 50 300
0
 4
1 7 14 47
2 5 35 55
3 6 3 59
4 6 5 15
10 15 50 318
2
1 8 10 78
2 4 18 33
10 10 50 300
0
 4
1 7 24 67
2 7 35 55
3 7 3 78
8 2 9 16
8 15 50 110
2
1 8 10 254
1 3 9 33
4 10 50 300
0
 4
0 5 24 67
0 7 35 15
3 14 1 74
4 2 9 18
8 29 50 100
0
1 8 10 254
1 7 9 33
3 1 28 300
0
 4
1 7 24 67
2 7 35 55
3 7 3 78
8 2 9 16
8 15 50 100
2
1 8 10 254
2 3 9 33
4 10 50 300
0
 4
1 3 14 47
0 7 35 55
3 6 3 14
4 2 7 31
10 15 50 110
2
1 8 10 254
1 5 8 33
4 2 50 300
0
 4
0 5 24 100
0 14 48 15
3 14 0 74
2 2 2 9
5 29 102 111
2
1 1 10 147
0 7 3 0
3 1 33 278
0
 4
1 5 24 67
4 7 35 45
3 3 1 78
4 1 1 18
3 15 50 101
0
1 8 3 397
1 7 4 33
4 1 28 553
0
 4
0 3 24 100
0 14 25 15
3 14 0 23
0 1 2 9
9 37 73 111
2
1 8 5 254
0 7 7 33
2 1 31 278
0

NA
NA
 NA
0
 4
NA
 NA
1
 NA
 NA
2
 3
NA
 2
NA
 4
 0
NA

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>

typedef struct sweet{
        int num, p, q, r, col;
} Sweet;

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

                Sweet sweets[n];
                for(i=0; i<n; i++){
                        int num, p, q, r;
                        scanf("%d %d %d %d", &sweets[i].num, &sweets[i].p, &sweets[i].q, &sweets[i].r);
                        sweets[i].col = sweets[i].p*4 + sweets[i].q*9 + sweets[i].r*4;
                }

                int p, q, r, c, cnt=0;
                scanf("%d %d %d %d", &p, &q, &r, &c);

                for(i=0; i<n; i++){
                        Sweet sw = sweets[i];
                        if(sw.p<=p && sw.q<=q && sw.r<=r && sw.col<=c){
                                printf("%d\n", sw.num);
                                cnt++;
                        }
                }
                if(cnt==0) puts("NA");
        }
        return 0;
}

```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d %d %d %d"
.LC2:
	.string	"%d\n"
.LC3:
	.string	"NA"
	.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
	pushq	%r15
	pushq	%r14
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	subq	$88, %rsp
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	.cfi_offset 12, -48
	.cfi_offset 3, -56
	movq	%fs:40, %rax
	movq	%rax, -56(%rbp)
	xorl	%eax, %eax
.L13:
	movq	%rsp, %rax
	movq	%rax, %rbx
	leaq	-124(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-124(%rbp), %eax
	testl	%eax, %eax
	jne	.L2
	movq	%rbx, %rsp
	movl	$0, %eax
	movq	-56(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L14
	jmp	.L15
.L2:
	movl	-124(%rbp), %ecx
	movslq	%ecx, %rax
	subq	$1, %rax
	movq	%rax, -96(%rbp)
	movslq	%ecx, %rax
	movq	%rax, %r12
	movl	$0, %r13d
	imulq	$160, %r13, %rdx
	imulq	$0, %r12, %rax
	leaq	(%rdx,%rax), %rsi
	movl	$160, %eax
	mulq	%r12
	addq	%rdx, %rsi
	movq	%rsi, %rdx
	movslq	%ecx, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movslq	%ecx, %rax
	movq	%rax, %r14
	movl	$0, %r15d
	imulq	$160, %r15, %rdx
	imulq	$0, %r14, %rax
	leaq	(%rdx,%rax), %rsi
	movl	$160, %eax
	mulq	%r14
	addq	%rdx, %rsi
	movq	%rsi, %rdx
	movslq	%ecx, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	movl	$16, %eax
	subq	$1, %rax
	addq	%rdx, %rax
	movl	$16, %edi
	movl	$0, %edx
	divq	%rdi
	imulq	$16, %rax, %rax
	movq	%rax, %rcx
	andq	$-4096, %rcx
	movq	%rsp, %rdx
	subq	%rcx, %rdx
.L4:
	cmpq	%rdx, %rsp
	je	.L5
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L4
.L5:
	movq	%rax, %rdx
	andl	$4095, %edx
	subq	%rdx, %rsp
	movq	%rax, %rdx
	andl	$4095, %edx
	testq	%rdx, %rdx
	je	.L6
	andl	$4095, %eax
	subq	$8, %rax
	addq	%rsp, %rax
	orq	$0, (%rax)
.L6:
	movq	%rsp, %rax
	addq	$3, %rax
	shrq	$2, %rax
	salq	$2, %rax
	movq	%rax, -88(%rbp)
	movl	$0, -104(%rbp)
	jmp	.L7
.L8:
	movl	-104(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	-88(%rbp), %rdx
	addq	%rdx, %rax
	leaq	12(%rax), %rdi
	movl	-104(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	-88(%rbp), %rdx
	addq	%rdx, %rax
	leaq	8(%rax), %rcx
	movl	-104(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	-88(%rbp), %rdx
	addq	%rdx, %rax
	leaq	4(%rax), %rdx
	movl	-104(%rbp), %eax
	movslq	%eax, %rsi
	movq	%rsi, %rax
	salq	$2, %rax
	addq	%rsi, %rax
	salq	$2, %rax
	movq	-88(%rbp), %rsi
	addq	%rsi, %rax
	movq	%rdi, %r8
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	-88(%rbp), %rcx
	movl	-104(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	addq	$4, %rax
	movl	(%rax), %eax
	leal	0(,%rax,4), %esi
	movq	-88(%rbp), %rcx
	movl	-104(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	addq	$8, %rax
	movl	(%rax), %edx
	movl	%edx, %eax
	sall	$3, %eax
	addl	%edx, %eax
	addl	%eax, %esi
	movq	-88(%rbp), %rcx
	movl	-104(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	addq	$12, %rax
	movl	(%rax), %eax
	sall	$2, %eax
	leal	(%rsi,%rax), %ecx
	movq	-88(%rbp), %rsi
	movl	-104(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rsi, %rax
	addq	$16, %rax
	movl	%ecx, (%rax)
	addl	$1, -104(%rbp)
.L7:
	movl	-124(%rbp), %eax
	cmpl	%eax, -104(%rbp)
	jl	.L8
	movl	$0, -100(%rbp)
	leaq	-108(%rbp), %rsi
	leaq	-112(%rbp), %rcx
	leaq	-116(%rbp), %rdx
	leaq	-120(%rbp), %rax
	movq	%rsi, %r8
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -104(%rbp)
	jmp	.L9
.L11:
	movq	-88(%rbp), %rcx
	movl	-104(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rax, %rcx
	movq	(%rcx), %rax
	movq	8(%rcx), %rdx
	movq	%rax, -80(%rbp)
	movq	%rdx, -72(%rbp)
	movl	16(%rcx), %eax
	movl	%eax, -64(%rbp)
	movl	-76(%rbp), %edx
	movl	-120(%rbp), %eax
	cmpl	%eax, %edx
	jg	.L10
	movl	-72(%rbp), %edx
	movl	-116(%rbp), %eax
	cmpl	%eax, %edx
	jg	.L10
	movl	-68(%rbp), %edx
	movl	-112(%rbp), %eax
	cmpl	%eax, %edx
	jg	.L10
	movl	-64(%rbp), %edx
	movl	-108(%rbp), %eax
	cmpl	%eax, %edx
	jg	.L10
	movl	-80(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	addl	$1, -100(%rbp)
.L10:
	addl	$1, -104(%rbp)
.L9:
	movl	-124(%rbp), %eax
	cmpl	%eax, -104(%rbp)
	jl	.L11
	cmpl	$0, -100(%rbp)
	jne	.L12
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
.L12:
	movq	%rbx, %rsp
	jmp	.L13
.L15:
	call	__stack_chk_fail@PLT
.L14:
	leaq	-40(%rbp), %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.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 %d %d %d"
.LC2:
	.string	"%d\n"
.LC3:
	.string	"NA"
	.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
	pushq	%r15
	pushq	%r14
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	subq	$88, %rsp
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	.cfi_offset 12, -48
	.cfi_offset 3, -56
	movq	%fs:40, %rax
	movq	%rax, -56(%rbp)
	xorl	%eax, %eax
.L13:
	movq	%rsp, %rax
	movq	%rax, %rbx
	leaq	-124(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-124(%rbp), %eax
	testl	%eax, %eax
	jne	.L2
	movq	%rbx, %rsp
	movl	$0, %eax
	movq	-56(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L14
	jmp	.L15
.L2:
	movl	-124(%rbp), %ecx
	movslq	%ecx, %rax
	subq	$1, %rax
	movq	%rax, -96(%rbp)
	movslq	%ecx, %rax
	movq	%rax, %r12
	movl	$0, %r13d
	imulq	$160, %r13, %rdx
	imulq	$0, %r12, %rax
	leaq	(%rdx,%rax), %rsi
	movl	$160, %eax
	mulq	%r12
	addq	%rdx, %rsi
	movq	%rsi, %rdx
	movslq	%ecx, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movslq	%ecx, %rax
	movq	%rax, %r14
	movl	$0, %r15d
	imulq	$160, %r15, %rdx
	imulq	$0, %r14, %rax
	leaq	(%rdx,%rax), %rsi
	movl	$160, %eax
	mulq	%r14
	addq	%rdx, %rsi
	movq	%rsi, %rdx
	movslq	%ecx, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	movl	$16, %eax
	subq	$1, %rax
	addq	%rdx, %rax
	movl	$16, %edi
	movl	$0, %edx
	divq	%rdi
	imulq	$16, %rax, %rax
	movq	%rax, %rcx
	andq	$-4096, %rcx
	movq	%rsp, %rdx
	subq	%rcx, %rdx
.L4:
	cmpq	%rdx, %rsp
	je	.L5
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L4
.L5:
	movq	%rax, %rdx
	andl	$4095, %edx
	subq	%rdx, %rsp
	movq	%rax, %rdx
	andl	$4095, %edx
	testq	%rdx, %rdx
	je	.L6
	andl	$4095, %eax
	subq	$8, %rax
	addq	%rsp, %rax
	orq	$0, (%rax)
.L6:
	movq	%rsp, %rax
	addq	$3, %rax
	shrq	$2, %rax
	salq	$2, %rax
	movq	%rax, -88(%rbp)
	movl	$0, -104(%rbp)
	jmp	.L7
.L8:
	movl	-104(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	-88(%rbp), %rdx
	addq	%rdx, %rax
	leaq	12(%rax), %rdi
	movl	-104(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	-88(%rbp), %rdx
	addq	%rdx, %rax
	leaq	8(%rax), %rcx
	movl	-104(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	-88(%rbp), %rdx
	addq	%rdx, %rax
	leaq	4(%rax), %rdx
	movl	-104(%rbp), %eax
	movslq	%eax, %rsi
	movq	%rsi, %rax
	salq	$2, %rax
	addq	%rsi, %rax
	salq	$2, %rax
	movq	-88(%rbp), %rsi
	addq	%rsi, %rax
	movq	%rdi, %r8
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	-88(%rbp), %rcx
	movl	-104(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	addq	$4, %rax
	movl	(%rax), %eax
	leal	0(,%rax,4), %esi
	movq	-88(%rbp), %rcx
	movl	-104(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	addq	$8, %rax
	movl	(%rax), %edx
	movl	%edx, %eax
	sall	$3, %eax
	addl	%edx, %eax
	addl	%eax, %esi
	movq	-88(%rbp), %rcx
	movl	-104(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	addq	$12, %rax
	movl	(%rax), %eax
	sall	$2, %eax
	leal	(%rsi,%rax), %ecx
	movq	-88(%rbp), %rsi
	movl	-104(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rsi, %rax
	addq	$16, %rax
	movl	%ecx, (%rax)
	addl	$1, -104(%rbp)
.L7:
	movl	-124(%rbp), %eax
	cmpl	%eax, -104(%rbp)
	jl	.L8
	movl	$0, -100(%rbp)
	leaq	-108(%rbp), %rsi
	leaq	-112(%rbp), %rcx
	leaq	-116(%rbp), %rdx
	leaq	-120(%rbp), %rax
	movq	%rsi, %r8
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -104(%rbp)
	jmp	.L9
.L11:
	movq	-88(%rbp), %rcx
	movl	-104(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rax, %rcx
	movq	(%rcx), %rax
	movq	8(%rcx), %rdx
	movq	%rax, -80(%rbp)
	movq	%rdx, -72(%rbp)
	movl	16(%rcx), %eax
	movl	%eax, -64(%rbp)
	movl	-76(%rbp), %edx
	movl	-120(%rbp), %eax
	cmpl	%eax, %edx
	jg	.L10
	movl	-72(%rbp), %edx
	movl	-116(%rbp), %eax
	cmpl	%eax, %edx
	jg	.L10
	movl	-68(%rbp), %edx
	movl	-112(%rbp), %eax
	cmpl	%eax, %edx
	jg	.L10
	movl	-64(%rbp), %edx
	movl	-108(%rbp), %eax
	cmpl	%eax, %edx
	jg	.L10
	movl	-80(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	addl	$1, -100(%rbp)
.L10:
	addl	$1, -104(%rbp)
.L9:
	movl	-124(%rbp), %eax
	cmpl	%eax, -104(%rbp)
	jl	.L11
	cmpl	$0, -100(%rbp)
	jne	.L12
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
.L12:
	movq	%rbx, %rsp
	jmp	.L13
.L15:
	call	__stack_chk_fail@PLT
.L14:
	leaq	-40(%rbp), %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.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:
