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>

struct ITEM{
  char name[101];
  int cost;
};

int main(){
  struct ITEM item[100];
  int n, i, j, l, m, k, cost;
  char o[101], q[101];
  while(scanf("%d", &n) && n){
    for(i = 0; i < n; ++i) scanf("%s %d", item[i].name, &item[i].cost);

    scanf("%d", &m);
    for(i = 0; i < m; ++i){
      scanf("%s %d", o, &k);
      cost = 0;
      for(j = 0; j < k; ++j){
	scanf("%s", q);
	for(l = 0; l < n; ++l) if(strcmp(item[l].name, q) == 0) break;
	cost += item[l].cost;
      }
      for(j = 0; j < n; ++j) if(strcmp(item[j].name, o) == 0) break;
      if(cost < item[j].cost) item[j].cost = cost;
    }

    scanf("%s", o);
    for(i = 0; i < n; ++i) if(strcmp(item[i].name, o) == 0) break;
    printf("%d\n", item[i].cost);
  }
  return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%s %d"
.LC1:
	.string	"%d"
.LC2:
	.string	"%s"
.LC3:
	.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	$4096, %rsp
	orq	$0, (%rsp)
	subq	$4096, %rsp
	orq	$0, (%rsp)
	subq	$2864, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	jmp	.L2
.L23:
	movl	$0, -11040(%rbp)
	jmp	.L3
.L4:
	leaq	-11024(%rbp), %rcx
	movl	-11040(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rdx
	addq	%rdx, %rax
	salq	$2, %rax
	addq	$96, %rax
	addq	%rcx, %rax
	leaq	8(%rax), %rdx
	leaq	-11024(%rbp), %rsi
	movl	-11040(%rbp), %eax
	movslq	%eax, %rcx
	movq	%rcx, %rax
	addq	%rax, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,8), %rcx
	addq	%rcx, %rax
	salq	$2, %rax
	addq	%rsi, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -11040(%rbp)
.L3:
	movl	-11052(%rbp), %eax
	cmpl	%eax, -11040(%rbp)
	jl	.L4
	leaq	-11048(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -11040(%rbp)
	jmp	.L5
.L17:
	leaq	-11044(%rbp), %rdx
	leaq	-224(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -11028(%rbp)
	movl	$0, -11036(%rbp)
	jmp	.L6
.L11:
	leaq	-112(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -11032(%rbp)
	jmp	.L7
.L10:
	leaq	-11024(%rbp), %rcx
	movl	-11032(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rdx
	addq	%rdx, %rax
	salq	$2, %rax
	leaq	(%rcx,%rax), %rdx
	leaq	-112(%rbp), %rax
	movq	%rax, %rsi
	movq	%rdx, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	je	.L26
	addl	$1, -11032(%rbp)
.L7:
	movl	-11052(%rbp), %eax
	cmpl	%eax, -11032(%rbp)
	jl	.L10
	jmp	.L9
.L26:
	nop
.L9:
	movl	-11032(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rdx
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rbp, %rax
	subq	$10920, %rax
	movl	(%rax), %eax
	addl	%eax, -11028(%rbp)
	addl	$1, -11036(%rbp)
.L6:
	movl	-11044(%rbp), %eax
	cmpl	%eax, -11036(%rbp)
	jl	.L11
	movl	$0, -11036(%rbp)
	jmp	.L12
.L15:
	leaq	-11024(%rbp), %rcx
	movl	-11036(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rdx
	addq	%rdx, %rax
	salq	$2, %rax
	leaq	(%rcx,%rax), %rdx
	leaq	-224(%rbp), %rax
	movq	%rax, %rsi
	movq	%rdx, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	je	.L27
	addl	$1, -11036(%rbp)
.L12:
	movl	-11052(%rbp), %eax
	cmpl	%eax, -11036(%rbp)
	jl	.L15
	jmp	.L14
.L27:
	nop
.L14:
	movl	-11036(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rdx
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rbp, %rax
	subq	$10920, %rax
	movl	(%rax), %eax
	cmpl	%eax, -11028(%rbp)
	jge	.L16
	movl	-11036(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rdx
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rbp, %rax
	leaq	-10920(%rax), %rdx
	movl	-11028(%rbp), %eax
	movl	%eax, (%rdx)
.L16:
	addl	$1, -11040(%rbp)
.L5:
	movl	-11048(%rbp), %eax
	cmpl	%eax, -11040(%rbp)
	jl	.L17
	leaq	-224(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -11040(%rbp)
	jmp	.L18
.L21:
	leaq	-11024(%rbp), %rcx
	movl	-11040(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rdx
	addq	%rdx, %rax
	salq	$2, %rax
	leaq	(%rcx,%rax), %rdx
	leaq	-224(%rbp), %rax
	movq	%rax, %rsi
	movq	%rdx, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	je	.L28
	addl	$1, -11040(%rbp)
.L18:
	movl	-11052(%rbp), %eax
	cmpl	%eax, -11040(%rbp)
	jl	.L21
	jmp	.L20
.L28:
	nop
.L20:
	movl	-11040(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rdx
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rbp, %rax
	subq	$10920, %rax
	movl	(%rax), %eax
	movl	%eax, %esi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L2:
	leaq	-11052(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	testl	%eax, %eax
	je	.L22
	movl	-11052(%rbp), %eax
	testl	%eax, %eax
	jne	.L23
.L22:
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L25
	call	__stack_chk_fail@PLT
.L25:
	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	"%s %d"
.LC1:
	.string	"%d"
.LC2:
	.string	"%s"
.LC3:
	.string	"%d\n"
	.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
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$4096, %rsp
	.cfi_def_cfa_offset 4152
	orq	$0, (%rsp)
	subq	$4096, %rsp
	.cfi_def_cfa_offset 8248
	orq	$0, (%rsp)
	subq	$2888, %rsp
	.cfi_def_cfa_offset 11136
	movq	%fs:40, %rax
	movq	%rax, 11064(%rsp)
	xorl	%eax, %eax
	leaq	36(%rsp), %rax
	movq	%rax, 24(%rsp)
.L2:
	movq	24(%rsp), %rsi
	xorl	%eax, %eax
	leaq	.LC1(%rip), %rdi
	call	__isoc99_scanf@PLT
	testl	%eax, %eax
	je	.L18
	movl	36(%rsp), %eax
	testl	%eax, %eax
	je	.L18
	leaq	48(%rsp), %rbx
	movl	$0, %ebp
	jle	.L20
	.p2align 4,,10
	.p2align 3
.L3:
	leaq	104(%rbx), %rdx
	movq	%rbx, %rsi
	leaq	.LC0(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	addl	$1, %ebp
	addq	$108, %rbx
	cmpl	%ebp, 36(%rsp)
	jg	.L3
.L20:
	leaq	40(%rsp), %rsi
	leaq	.LC1(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	leaq	10848(%rsp), %rax
	movl	40(%rsp), %edx
	movl	$0, 12(%rsp)
	movq	%rax, (%rsp)
	leaq	44(%rsp), %rax
	movq	%rax, 16(%rsp)
	testl	%edx, %edx
	jle	.L16
	.p2align 4,,10
	.p2align 3
.L4:
	movq	16(%rsp), %rdx
	movq	(%rsp), %rsi
	leaq	.LC0(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	44(%rsp), %eax
	testl	%eax, %eax
	jle	.L7
	xorl	%r13d, %r13d
	xorl	%r12d, %r12d
	leaq	10960(%rsp), %rbp
	.p2align 4,,10
	.p2align 3
.L10:
	movq	%rbp, %rsi
	leaq	.LC2(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	36(%rsp), %ebx
	testl	%ebx, %ebx
	jle	.L23
	leaq	48(%rsp), %r14
	xorl	%r15d, %r15d
	jmp	.L9
	.p2align 4,,10
	.p2align 3
.L49:
	addl	$1, %r15d
	addq	$108, %r14
	cmpl	%ebx, %r15d
	je	.L8
.L9:
	movq	%rbp, %rsi
	movq	%r14, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L49
.L8:
	movslq	%r15d, %rdx
	addl	$1, %r12d
	leaq	(%rdx,%rdx,2), %rax
	leaq	(%rax,%rax,8), %rax
	addl	152(%rsp,%rax,4), %r13d
	cmpl	%r12d, 44(%rsp)
	jg	.L10
	testl	%ebx, %ebx
	jle	.L24
.L52:
	leaq	48(%rsp), %r12
	xorl	%ebp, %ebp
	jmp	.L13
	.p2align 4,,10
	.p2align 3
.L50:
	addl	$1, %ebp
	addq	$108, %r12
	cmpl	%ebx, %ebp
	je	.L12
.L13:
	movq	(%rsp), %rsi
	movq	%r12, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L50
.L12:
	movslq	%ebp, %rbp
	leaq	0(%rbp,%rbp,2), %rax
	leaq	(%rax,%rax,8), %rax
	leaq	0(,%rax,4), %rdx
	cmpl	%r13d, 152(%rsp,%rax,4)
	jle	.L14
	addl	$1, 12(%rsp)
	movl	12(%rsp), %eax
	movl	%r13d, 152(%rsp,%rdx)
	cmpl	%eax, 40(%rsp)
	jg	.L4
.L16:
	movq	(%rsp), %rsi
	leaq	.LC2(%rip), %rdi
	xorl	%eax, %eax
	xorl	%ebp, %ebp
	leaq	48(%rsp), %r12
	call	__isoc99_scanf@PLT
	movl	36(%rsp), %ebx
	testl	%ebx, %ebx
	jg	.L17
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L51:
	addl	$1, %ebp
	addq	$108, %r12
	cmpl	%ebp, %ebx
	je	.L6
.L17:
	movq	(%rsp), %rsi
	movq	%r12, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L51
.L6:
	movslq	%ebp, %rbp
	leaq	.LC3(%rip), %rsi
	movl	$1, %edi
	leaq	0(%rbp,%rbp,2), %rax
	leaq	(%rax,%rax,8), %rax
	movl	152(%rsp,%rax,4), %edx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L2
.L14:
	addl	$1, 12(%rsp)
	movl	12(%rsp), %eax
	cmpl	%eax, 40(%rsp)
	jg	.L4
	jmp	.L16
.L23:
	xorl	%r15d, %r15d
	jmp	.L8
.L7:
	movl	36(%rsp), %ebx
	xorl	%r13d, %r13d
	testl	%ebx, %ebx
	jg	.L52
.L24:
	xorl	%ebp, %ebp
	jmp	.L12
.L18:
	movq	11064(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L53
	addq	$11080, %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
.L53:
	.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	"%s %d"
.LC1:
	.string	"%d"
.LC2:
	.string	"%s"
.LC3:
	.string	"%d\n"
	.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
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$4096, %rsp
	.cfi_def_cfa_offset 4152
	orq	$0, (%rsp)
	subq	$4096, %rsp
	.cfi_def_cfa_offset 8248
	orq	$0, (%rsp)
	subq	$2888, %rsp
	.cfi_def_cfa_offset 11136
	movq	%fs:40, %rax
	movq	%rax, 11064(%rsp)
	xorl	%eax, %eax
	leaq	36(%rsp), %rax
	movq	%rax, 24(%rsp)
.L2:
	movq	24(%rsp), %rsi
	xorl	%eax, %eax
	leaq	.LC1(%rip), %rdi
	call	__isoc99_scanf@PLT
	testl	%eax, %eax
	je	.L18
	movl	36(%rsp), %eax
	testl	%eax, %eax
	je	.L18
	leaq	48(%rsp), %rbx
	movl	$0, %ebp
	jle	.L20
	.p2align 4,,10
	.p2align 3
.L3:
	leaq	104(%rbx), %rdx
	movq	%rbx, %rsi
	leaq	.LC0(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	addl	$1, %ebp
	addq	$108, %rbx
	cmpl	%ebp, 36(%rsp)
	jg	.L3
.L20:
	leaq	40(%rsp), %rsi
	leaq	.LC1(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	leaq	10848(%rsp), %rax
	movl	40(%rsp), %edx
	movl	$0, 12(%rsp)
	movq	%rax, (%rsp)
	leaq	44(%rsp), %rax
	movq	%rax, 16(%rsp)
	testl	%edx, %edx
	jle	.L16
	.p2align 4,,10
	.p2align 3
.L4:
	movq	16(%rsp), %rdx
	movq	(%rsp), %rsi
	leaq	.LC0(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	44(%rsp), %eax
	testl	%eax, %eax
	jle	.L7
	xorl	%r13d, %r13d
	xorl	%r12d, %r12d
	leaq	10960(%rsp), %rbp
	.p2align 4,,10
	.p2align 3
.L10:
	movq	%rbp, %rsi
	leaq	.LC2(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	36(%rsp), %ebx
	testl	%ebx, %ebx
	jle	.L23
	leaq	48(%rsp), %r14
	xorl	%r15d, %r15d
	jmp	.L9
	.p2align 4,,10
	.p2align 3
.L49:
	addl	$1, %r15d
	addq	$108, %r14
	cmpl	%ebx, %r15d
	je	.L8
.L9:
	movq	%rbp, %rsi
	movq	%r14, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L49
.L8:
	movslq	%r15d, %rdx
	addl	$1, %r12d
	leaq	(%rdx,%rdx,2), %rax
	leaq	(%rax,%rax,8), %rax
	addl	152(%rsp,%rax,4), %r13d
	cmpl	%r12d, 44(%rsp)
	jg	.L10
	testl	%ebx, %ebx
	jle	.L24
.L52:
	leaq	48(%rsp), %r12
	xorl	%ebp, %ebp
	jmp	.L13
	.p2align 4,,10
	.p2align 3
.L50:
	addl	$1, %ebp
	addq	$108, %r12
	cmpl	%ebx, %ebp
	je	.L12
.L13:
	movq	(%rsp), %rsi
	movq	%r12, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L50
.L12:
	movslq	%ebp, %rbp
	leaq	0(%rbp,%rbp,2), %rax
	leaq	(%rax,%rax,8), %rax
	leaq	0(,%rax,4), %rdx
	cmpl	%r13d, 152(%rsp,%rax,4)
	jle	.L14
	addl	$1, 12(%rsp)
	movl	12(%rsp), %eax
	movl	%r13d, 152(%rsp,%rdx)
	cmpl	%eax, 40(%rsp)
	jg	.L4
.L16:
	movq	(%rsp), %rsi
	leaq	.LC2(%rip), %rdi
	xorl	%eax, %eax
	xorl	%ebp, %ebp
	leaq	48(%rsp), %r12
	call	__isoc99_scanf@PLT
	movl	36(%rsp), %ebx
	testl	%ebx, %ebx
	jg	.L17
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L51:
	addl	$1, %ebp
	addq	$108, %r12
	cmpl	%ebp, %ebx
	je	.L6
.L17:
	movq	(%rsp), %rsi
	movq	%r12, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L51
.L6:
	movslq	%ebp, %rbp
	leaq	.LC3(%rip), %rsi
	movl	$1, %edi
	leaq	0(%rbp,%rbp,2), %rax
	leaq	(%rax,%rax,8), %rax
	movl	152(%rsp,%rax,4), %edx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L2
.L14:
	addl	$1, 12(%rsp)
	movl	12(%rsp), %eax
	cmpl	%eax, 40(%rsp)
	jg	.L4
	jmp	.L16
.L23:
	xorl	%r15d, %r15d
	jmp	.L8
.L7:
	movl	36(%rsp), %ebx
	xorl	%r13d, %r13d
	testl	%ebx, %ebx
	jg	.L52
.L24:
	xorl	%ebp, %ebp
	jmp	.L12
.L18:
	movq	11064(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L53
	addq	$11080, %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
.L53:
	.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>

struct ITEM{
  char name[101];
  int cost;
};

int main(){
  struct ITEM item[100];
  int n, i, j, l, m, k, cost;
  char o[101], q[101];
  while(scanf("%d", &n) && n){
    for(i = 0; i < n; ++i) scanf("%s %d", item[i].name, &item[i].cost);

    scanf("%d", &m);
    for(i = 0; i < m; ++i){
      scanf("%s %d", o, &k);
      cost = 0;
      for(j = 0; j < k; ++j){
	scanf("%s", q);
	for(l = 0; l < n; ++l) if(strcmp(item[l].name, q) == 0) break;
	cost += item[l].cost;
      }
      for(j = 0; j < n; ++j) if(strcmp(item[j].name, o) == 0) break;
      if(cost < item[j].cost) item[j].cost = cost;
    }

    scanf("%s", o);
    for(i = 0; i < n; ++i) if(strcmp(item[i].name, o) == 0) break;
    printf("%d\n", item[i].cost);
  }
  return 0;
}
8
wood 3000
string 800
rice 36
water 0
racket 5000
microphone 4961
onigiri 140
guitar 98000
3
racket 2 wood string
onigiri 2 rice water
guitar 3 racket microphone onigiri
guitar
1
computer 300000
0
computer
0
 8
wood 5003
string 800
rice 36
water 0
racket 5000
microphone 4961
onigiri 140
guitar 98000
3
racket 2 wood string
onigiri 2 rice water
guitar 3 racket microphone onigiri
guitar
1
computer 300000
0
computer
0
 8
wood 5003
string 800
rice 36
water 0
racket 5000
microphone 4961
onigiri 140
guitar 98000
3
racket 2 wood string
onigiri 2 rice water
guitar 3 racket microphone onigiri
guitar
1
computer 112750
0
computer
0
 8
wood 3000
string 800
rice 1
water 0
racket 5000
microphone 4961
onigiri 113
guitar 98000
3
racket 2 wood string
onigiri 2 rice water
guitar 3 racket microphone onigiri
guitar
1
computer 300000
0
computer
0
 8
wood 5003
string 800
rice 36
water 0
racket 5000
microphone 4961
onigiri 140
guitar 98000
3
racket 2 wood string
onigiri 2 rice water
guitar 3 tekcar microphone onigiri
guitar
1
computer 112750
0
computer
0
 8
wood 3000
string 800
rice 1
water 0
racket 5000
enohporcim 4961
onigiri 113
guitar 98000
3
racket 2 wood string
onigiri 2 rice water
guitar 3 racket microphone onigiri
guitar
1
computer 300000
0
computer
0
 8
wood 5003
string 800
rice 36
water 0
racket 5000
microphone 4961
onigiri 140
guitar 98000
3
racket 2 wood string
onigiri 2 rice water
guitar 3 tekcar enohporcim onigiri
guitar
1
computer 112750
0
computer
0
 8
wood 5003
string 800
rice 36
water 0
racket 196
microphone 4961
onigiri 140
guitar 98000
3
racket 2 wood string
onigiri 2 rice water
guitar 3 racket microphone onigiri
guitar
1
computer 112750
-1
computer
0
 8
wood 5003
string 800
rice 36
water 0
racket 5000
microphone 4961
onigiri 140
guitar 98000
3
racket 2 wood string
onigiri 2 reci water
guitar 3 tekcar enohporcim onigiri
guitar
1
computer 112750
0
computer
0
 8
wood 5003
string 800
rice 36
wrtea 0
racket 196
microphone 4961
onigiri 140
guitar 98000
3
racket 2 wood string
onigiri 2 rice water
guitar 3 racket microohone onigiri
guitar
1
computer 112750
-1
computer
0

8797
300000
 9997
300000
 9997
112750
 8762
300000
 4997
112750
 3801
300000
 36
112750
 5193
112750
 0
112750
 232
112750

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>

struct ITEM{
  char name[101];
  int cost;
};

int main(){
  struct ITEM item[100];
  int n, i, j, l, m, k, cost;
  char o[101], q[101];
  while(scanf("%d", &n) && n){
    for(i = 0; i < n; ++i) scanf("%s %d", item[i].name, &item[i].cost);

    scanf("%d", &m);
    for(i = 0; i < m; ++i){
      scanf("%s %d", o, &k);
      cost = 0;
      for(j = 0; j < k; ++j){
	scanf("%s", q);
	for(l = 0; l < n; ++l) if(strcmp(item[l].name, q) == 0) break;
	cost += item[l].cost;
      }
      for(j = 0; j < n; ++j) if(strcmp(item[j].name, o) == 0) break;
      if(cost < item[j].cost) item[j].cost = cost;
    }

    scanf("%s", o);
    for(i = 0; i < n; ++i) if(strcmp(item[i].name, o) == 0) break;
    printf("%d\n", item[i].cost);
  }
  return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%s %d"
.LC1:
	.string	"%d"
.LC2:
	.string	"%s"
.LC3:
	.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	$4096, %rsp
	orq	$0, (%rsp)
	subq	$4096, %rsp
	orq	$0, (%rsp)
	subq	$2864, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	jmp	.L2
.L23:
	movl	$0, -11040(%rbp)
	jmp	.L3
.L4:
	leaq	-11024(%rbp), %rcx
	movl	-11040(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rdx
	addq	%rdx, %rax
	salq	$2, %rax
	addq	$96, %rax
	addq	%rcx, %rax
	leaq	8(%rax), %rdx
	leaq	-11024(%rbp), %rsi
	movl	-11040(%rbp), %eax
	movslq	%eax, %rcx
	movq	%rcx, %rax
	addq	%rax, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,8), %rcx
	addq	%rcx, %rax
	salq	$2, %rax
	addq	%rsi, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -11040(%rbp)
.L3:
	movl	-11052(%rbp), %eax
	cmpl	%eax, -11040(%rbp)
	jl	.L4
	leaq	-11048(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -11040(%rbp)
	jmp	.L5
.L17:
	leaq	-11044(%rbp), %rdx
	leaq	-224(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -11028(%rbp)
	movl	$0, -11036(%rbp)
	jmp	.L6
.L11:
	leaq	-112(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -11032(%rbp)
	jmp	.L7
.L10:
	leaq	-11024(%rbp), %rcx
	movl	-11032(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rdx
	addq	%rdx, %rax
	salq	$2, %rax
	leaq	(%rcx,%rax), %rdx
	leaq	-112(%rbp), %rax
	movq	%rax, %rsi
	movq	%rdx, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	je	.L26
	addl	$1, -11032(%rbp)
.L7:
	movl	-11052(%rbp), %eax
	cmpl	%eax, -11032(%rbp)
	jl	.L10
	jmp	.L9
.L26:
	nop
.L9:
	movl	-11032(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rdx
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rbp, %rax
	subq	$10920, %rax
	movl	(%rax), %eax
	addl	%eax, -11028(%rbp)
	addl	$1, -11036(%rbp)
.L6:
	movl	-11044(%rbp), %eax
	cmpl	%eax, -11036(%rbp)
	jl	.L11
	movl	$0, -11036(%rbp)
	jmp	.L12
.L15:
	leaq	-11024(%rbp), %rcx
	movl	-11036(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rdx
	addq	%rdx, %rax
	salq	$2, %rax
	leaq	(%rcx,%rax), %rdx
	leaq	-224(%rbp), %rax
	movq	%rax, %rsi
	movq	%rdx, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	je	.L27
	addl	$1, -11036(%rbp)
.L12:
	movl	-11052(%rbp), %eax
	cmpl	%eax, -11036(%rbp)
	jl	.L15
	jmp	.L14
.L27:
	nop
.L14:
	movl	-11036(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rdx
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rbp, %rax
	subq	$10920, %rax
	movl	(%rax), %eax
	cmpl	%eax, -11028(%rbp)
	jge	.L16
	movl	-11036(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rdx
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rbp, %rax
	leaq	-10920(%rax), %rdx
	movl	-11028(%rbp), %eax
	movl	%eax, (%rdx)
.L16:
	addl	$1, -11040(%rbp)
.L5:
	movl	-11048(%rbp), %eax
	cmpl	%eax, -11040(%rbp)
	jl	.L17
	leaq	-224(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -11040(%rbp)
	jmp	.L18
.L21:
	leaq	-11024(%rbp), %rcx
	movl	-11040(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rdx
	addq	%rdx, %rax
	salq	$2, %rax
	leaq	(%rcx,%rax), %rdx
	leaq	-224(%rbp), %rax
	movq	%rax, %rsi
	movq	%rdx, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	je	.L28
	addl	$1, -11040(%rbp)
.L18:
	movl	-11052(%rbp), %eax
	cmpl	%eax, -11040(%rbp)
	jl	.L21
	jmp	.L20
.L28:
	nop
.L20:
	movl	-11040(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rdx
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rbp, %rax
	subq	$10920, %rax
	movl	(%rax), %eax
	movl	%eax, %esi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L2:
	leaq	-11052(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	testl	%eax, %eax
	je	.L22
	movl	-11052(%rbp), %eax
	testl	%eax, %eax
	jne	.L23
.L22:
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L25
	call	__stack_chk_fail@PLT
.L25:
	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	"%s %d"
.LC1:
	.string	"%d"
.LC2:
	.string	"%s"
.LC3:
	.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	$4096, %rsp
	orq	$0, (%rsp)
	subq	$4096, %rsp
	orq	$0, (%rsp)
	subq	$2864, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	jmp	.L2
.L23:
	movl	$0, -11040(%rbp)
	jmp	.L3
.L4:
	leaq	-11024(%rbp), %rcx
	movl	-11040(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rdx
	addq	%rdx, %rax
	salq	$2, %rax
	addq	$96, %rax
	addq	%rcx, %rax
	leaq	8(%rax), %rdx
	leaq	-11024(%rbp), %rsi
	movl	-11040(%rbp), %eax
	movslq	%eax, %rcx
	movq	%rcx, %rax
	addq	%rax, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,8), %rcx
	addq	%rcx, %rax
	salq	$2, %rax
	addq	%rsi, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -11040(%rbp)
.L3:
	movl	-11052(%rbp), %eax
	cmpl	%eax, -11040(%rbp)
	jl	.L4
	leaq	-11048(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -11040(%rbp)
	jmp	.L5
.L17:
	leaq	-11044(%rbp), %rdx
	leaq	-224(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -11028(%rbp)
	movl	$0, -11036(%rbp)
	jmp	.L6
.L11:
	leaq	-112(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -11032(%rbp)
	jmp	.L7
.L10:
	leaq	-11024(%rbp), %rcx
	movl	-11032(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rdx
	addq	%rdx, %rax
	salq	$2, %rax
	leaq	(%rcx,%rax), %rdx
	leaq	-112(%rbp), %rax
	movq	%rax, %rsi
	movq	%rdx, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	je	.L26
	addl	$1, -11032(%rbp)
.L7:
	movl	-11052(%rbp), %eax
	cmpl	%eax, -11032(%rbp)
	jl	.L10
	jmp	.L9
.L26:
	nop
.L9:
	movl	-11032(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rdx
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rbp, %rax
	subq	$10920, %rax
	movl	(%rax), %eax
	addl	%eax, -11028(%rbp)
	addl	$1, -11036(%rbp)
.L6:
	movl	-11044(%rbp), %eax
	cmpl	%eax, -11036(%rbp)
	jl	.L11
	movl	$0, -11036(%rbp)
	jmp	.L12
.L15:
	leaq	-11024(%rbp), %rcx
	movl	-11036(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rdx
	addq	%rdx, %rax
	salq	$2, %rax
	leaq	(%rcx,%rax), %rdx
	leaq	-224(%rbp), %rax
	movq	%rax, %rsi
	movq	%rdx, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	je	.L27
	addl	$1, -11036(%rbp)
.L12:
	movl	-11052(%rbp), %eax
	cmpl	%eax, -11036(%rbp)
	jl	.L15
	jmp	.L14
.L27:
	nop
.L14:
	movl	-11036(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rdx
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rbp, %rax
	subq	$10920, %rax
	movl	(%rax), %eax
	cmpl	%eax, -11028(%rbp)
	jge	.L16
	movl	-11036(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rdx
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rbp, %rax
	leaq	-10920(%rax), %rdx
	movl	-11028(%rbp), %eax
	movl	%eax, (%rdx)
.L16:
	addl	$1, -11040(%rbp)
.L5:
	movl	-11048(%rbp), %eax
	cmpl	%eax, -11040(%rbp)
	jl	.L17
	leaq	-224(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -11040(%rbp)
	jmp	.L18
.L21:
	leaq	-11024(%rbp), %rcx
	movl	-11040(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rdx
	addq	%rdx, %rax
	salq	$2, %rax
	leaq	(%rcx,%rax), %rdx
	leaq	-224(%rbp), %rax
	movq	%rax, %rsi
	movq	%rdx, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	je	.L28
	addl	$1, -11040(%rbp)
.L18:
	movl	-11052(%rbp), %eax
	cmpl	%eax, -11040(%rbp)
	jl	.L21
	jmp	.L20
.L28:
	nop
.L20:
	movl	-11040(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rdx
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rbp, %rax
	subq	$10920, %rax
	movl	(%rax), %eax
	movl	%eax, %esi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L2:
	leaq	-11052(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	testl	%eax, %eax
	je	.L22
	movl	-11052(%rbp), %eax
	testl	%eax, %eax
	jne	.L23
.L22:
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L25
	call	__stack_chk_fail@PLT
.L25:
	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:
