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>
#include<stdlib.h>
#include<string.h>

int n,m;
struct element{
  char name[101];
  int cost;
} *product;

struct recipe{
  char name[101];
  int num_of_prod;
  char zairyo[100][101];
} *menu;

void minimum_cost(int number);

int main(void){
  int i,j;
  char final[101];
  while(scanf("%d",&n) && n){
    product=(struct element *)calloc(n,sizeof(struct element));
    for(i=0;i<n;i++){
      scanf("%s %d%*c", product[i].name,&product[i].cost);
    }
    /*
    for(i=0;i<n;i++){
      printf("%s %d\n", product[i].name,product[i].cost);
      }*/

    scanf("%d",&m);
    menu=(struct recipe *)calloc(m,sizeof(struct recipe));
    for(i=0;i<m;i++){
      scanf("%s %d%*c", menu[i].name,&menu[i].num_of_prod);
      for(j=0;j<menu[i].num_of_prod;j++){
	scanf("%s%*c",menu[i].zairyo[j]);
      }
    }
    /*
    for(i=0;i<m;i++){
      printf("%s %d ", menu[i].name,menu[i].num_of_prod);
      for(j=0;j<menu[i].num_of_prod;j++){
	printf("%s ",menu[i].zairyo[j]);
      }
      putchar('\n');
      }*/
    
    scanf("%s%*c",final);
    for(i=0;i<n;i++){
      if(!strcmp(final,product[i].name)){
	minimum_cost(i);
	printf("%d\n",product[i].cost);
	break;
      }
    }
    
    free(menu);
    free(product);
  }
  return 0;
}

void minimum_cost(int number){
  int i,j,k;
  int sum=0;
  //printf("%d %d\n",m,n);
  //printf("%s recipe is searching...\n",product[number].name);
  for(i=0;i<m;i++){
    //printf("%lu %lu\n",strlen(product[number].name),strlen(menu[i].name));
    if(!strcmp(product[number].name,menu[i].name)){
      //printf("%s menu found!\n",product[number].name);
      for(j=0;j<menu[i].num_of_prod;j++){
	for(k=0;k<n;k++){
	  if(!strcmp(menu[i].zairyo[j],product[k].name)){
	    minimum_cost(k);
	    sum+=product[k].cost;
	    break;
	  }
	}	
      }
      //printf("%s cost is from %d to ",product[number].name,product[number].cost);
      if(sum<product[number].cost) product[number].cost=sum;
      //printf("%d \n",product[number].cost);
      break;
    }
  }
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	n
	.bss
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	m
	.align 4
	.type	m, @object
	.size	m, 4
m:
	.zero	4
	.globl	product
	.align 8
	.type	product, @object
	.size	product, 8
product:
	.zero	8
	.globl	menu
	.align 8
	.type	menu, @object
	.size	menu, 8
menu:
	.zero	8
	.section	.rodata
.LC0:
	.string	"%s %d%*c"
.LC1:
	.string	"%d"
.LC2:
	.string	"%s%*c"
.LC3:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	addq	$-128, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	jmp	.L2
.L14:
	movl	n(%rip), %eax
	cltq
	movl	$108, %esi
	movq	%rax, %rdi
	call	calloc@PLT
	movq	%rax, product(%rip)
	movl	$0, -120(%rbp)
	jmp	.L3
.L4:
	movq	product(%rip), %rcx
	movl	-120(%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	%rcx, %rax
	leaq	104(%rax), %rdx
	movq	product(%rip), %rsi
	movl	-120(%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, -120(%rbp)
.L3:
	movl	n(%rip), %eax
	cmpl	%eax, -120(%rbp)
	jl	.L4
	leaq	m(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	m(%rip), %eax
	cltq
	movl	$10208, %esi
	movq	%rax, %rdi
	call	calloc@PLT
	movq	%rax, menu(%rip)
	movl	$0, -120(%rbp)
	jmp	.L5
.L8:
	movq	menu(%rip), %rdx
	movl	-120(%rbp), %eax
	cltq
	imulq	$10208, %rax, %rax
	addq	%rdx, %rax
	addq	$104, %rax
	movq	menu(%rip), %rcx
	movl	-120(%rbp), %edx
	movslq	%edx, %rdx
	imulq	$10208, %rdx, %rdx
	addq	%rcx, %rdx
	movq	%rdx, %rcx
	movq	%rax, %rdx
	movq	%rcx, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -116(%rbp)
	jmp	.L6
.L7:
	movq	menu(%rip), %rdx
	movl	-120(%rbp), %eax
	cltq
	imulq	$10208, %rax, %rax
	leaq	(%rdx,%rax), %rsi
	movl	-116(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rcx
	addq	%rcx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	$96, %rax
	addq	%rsi, %rax
	addq	$12, %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -116(%rbp)
.L6:
	movq	menu(%rip), %rdx
	movl	-120(%rbp), %eax
	cltq
	imulq	$10208, %rax, %rax
	addq	%rdx, %rax
	movl	104(%rax), %eax
	cmpl	%eax, -116(%rbp)
	jl	.L7
	addl	$1, -120(%rbp)
.L5:
	movl	m(%rip), %eax
	cmpl	%eax, -120(%rbp)
	jl	.L8
	leaq	-112(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -120(%rbp)
	jmp	.L9
.L12:
	movq	product(%rip), %rcx
	movl	-120(%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	%rcx, %rax
	movq	%rax, %rdx
	leaq	-112(%rbp), %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L10
	movl	-120(%rbp), %eax
	movl	%eax, %edi
	call	minimum_cost
	movq	product(%rip), %rcx
	movl	-120(%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	%rcx, %rax
	movl	104(%rax), %eax
	movl	%eax, %esi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L11
.L10:
	addl	$1, -120(%rbp)
.L9:
	movl	n(%rip), %eax
	cmpl	%eax, -120(%rbp)
	jl	.L12
.L11:
	movq	menu(%rip), %rax
	movq	%rax, %rdi
	call	free@PLT
	movq	product(%rip), %rax
	movq	%rax, %rdi
	call	free@PLT
.L2:
	leaq	n(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	testl	%eax, %eax
	je	.L13
	movl	n(%rip), %eax
	testl	%eax, %eax
	jne	.L14
.L13:
	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
.LFE6:
	.size	main, .-main
	.globl	minimum_cost
	.type	minimum_cost, @function
minimum_cost:
.LFB7:
	.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
	movl	%edi, -20(%rbp)
	movl	$0, -4(%rbp)
	movl	$0, -16(%rbp)
	jmp	.L18
.L28:
	movq	menu(%rip), %rdx
	movl	-16(%rbp), %eax
	cltq
	imulq	$10208, %rax, %rax
	addq	%rdx, %rax
	movq	%rax, %rcx
	movq	product(%rip), %rsi
	movl	-20(%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	%rsi, %rax
	movq	%rcx, %rsi
	movq	%rax, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L19
	movl	$0, -12(%rbp)
	jmp	.L20
.L25:
	movl	$0, -8(%rbp)
	jmp	.L21
.L24:
	movq	product(%rip), %rcx
	movl	-8(%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	%rcx, %rax
	movq	%rax, %rcx
	movq	menu(%rip), %rdx
	movl	-16(%rbp), %eax
	cltq
	imulq	$10208, %rax, %rax
	leaq	(%rdx,%rax), %rdi
	movl	-12(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rsi
	addq	%rsi, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	$96, %rax
	addq	%rdi, %rax
	addq	$12, %rax
	movq	%rcx, %rsi
	movq	%rax, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L22
	movl	-8(%rbp), %eax
	movl	%eax, %edi
	call	minimum_cost
	movq	product(%rip), %rcx
	movl	-8(%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	%rcx, %rax
	movl	104(%rax), %eax
	addl	%eax, -4(%rbp)
	jmp	.L23
.L22:
	addl	$1, -8(%rbp)
.L21:
	movl	n(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jl	.L24
.L23:
	addl	$1, -12(%rbp)
.L20:
	movq	menu(%rip), %rdx
	movl	-16(%rbp), %eax
	cltq
	imulq	$10208, %rax, %rax
	addq	%rdx, %rax
	movl	104(%rax), %eax
	cmpl	%eax, -12(%rbp)
	jl	.L25
	movq	product(%rip), %rcx
	movl	-20(%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	%rcx, %rax
	movl	104(%rax), %eax
	cmpl	%eax, -4(%rbp)
	jge	.L29
	movq	product(%rip), %rcx
	movl	-20(%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
	movl	-4(%rbp), %eax
	movl	%eax, 104(%rdx)
	jmp	.L29
.L19:
	addl	$1, -16(%rbp)
.L18:
	movl	m(%rip), %eax
	cmpl	%eax, -16(%rbp)
	jl	.L28
	jmp	.L30
.L29:
	nop
.L30:
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	minimum_cost, .-minimum_cost
	.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
	.p2align 4
	.globl	minimum_cost
	.type	minimum_cost, @function
minimum_cost:
.LFB52:
	.cfi_startproc
	endbr64
	movl	m(%rip), %edx
	testl	%edx, %edx
	jle	.L18
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movslq	%edi, %rax
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	leaq	(%rax,%rax,2), %rax
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	leaq	(%rax,%rax,8), %rax
	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	$24, %rsp
	.cfi_def_cfa_offset 80
	movq	product(%rip), %rcx
	movq	menu(%rip), %rbx
	leaq	(%rcx,%rax,4), %r12
	leal	-1(%rdx), %eax
	movq	%rcx, (%rsp)
	imulq	$10208, %rax, %rax
	leaq	10208(%rbx,%rax), %rbp
	jmp	.L12
	.p2align 4,,10
	.p2align 3
.L3:
	addq	$10208, %rbx
	cmpq	%rbx, %rbp
	je	.L1
.L12:
	movq	%rbx, %rsi
	movq	%r12, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L3
	movl	104(%rbx), %eax
	movl	%eax, 8(%rsp)
	testl	%eax, %eax
	jle	.L22
	movl	$0, 12(%rsp)
	addq	$108, %rbx
	xorl	%r13d, %r13d
.L13:
	movl	n(%rip), %ebp
	testl	%ebp, %ebp
	jle	.L5
	movq	(%rsp), %r15
	xorl	%r14d, %r14d
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L6:
	addl	$1, %r14d
	addq	$108, %r15
	cmpl	%r14d, %ebp
	je	.L7
.L8:
	movq	%r15, %rsi
	movq	%rbx, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L6
	movl	%r14d, %edi
	call	minimum_cost
	movl	104(%r15), %edx
	addl	%edx, 12(%rsp)
.L7:
	addl	$1, %r13d
	cmpl	%r13d, 8(%rsp)
	je	.L5
	addq	$101, %rbx
	jmp	.L13
.L22:
	movl	$0, 12(%rsp)
	.p2align 4,,10
	.p2align 3
.L5:
	movl	12(%rsp), %eax
	cmpl	%eax, 104(%r12)
	jle	.L1
	movl	%eax, 104(%r12)
.L1:
	addq	$24, %rsp
	.cfi_def_cfa_offset 56
	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
.L18:
	.cfi_restore 3
	.cfi_restore 6
	.cfi_restore 12
	.cfi_restore 13
	.cfi_restore 14
	.cfi_restore 15
	ret
	.cfi_endproc
.LFE52:
	.size	minimum_cost, .-minimum_cost
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%s %d%*c"
.LC1:
	.string	"%d"
.LC2:
	.string	"%s%*c"
.LC3:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB51:
	.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
	leaq	.LC0(%rip), %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	leaq	.LC2(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$120, %rsp
	.cfi_def_cfa_offset 176
	movq	%fs:40, %rax
	movq	%rax, 104(%rsp)
	xorl	%eax, %eax
	.p2align 4,,10
	.p2align 3
.L24:
	xorl	%eax, %eax
	leaq	n(%rip), %rsi
	leaq	.LC1(%rip), %rdi
	call	__isoc99_scanf@PLT
	testl	%eax, %eax
	je	.L35
	movl	n(%rip), %ebx
	testl	%ebx, %ebx
	je	.L35
	movl	$108, %esi
	movslq	%ebx, %rdi
	call	calloc@PLT
	movq	%rax, product(%rip)
	movq	%rax, %rsi
	testl	%ebx, %ebx
	jle	.L25
	xorl	%r12d, %r12d
	xorl	%ebx, %ebx
	jmp	.L26
	.p2align 4,,10
	.p2align 3
.L48:
	movq	product(%rip), %rsi
.L26:
	addq	%r12, %rsi
	xorl	%eax, %eax
	movq	%r13, %rdi
	addl	$1, %ebx
	leaq	104(%rsi), %rdx
	addq	$108, %r12
	call	__isoc99_scanf@PLT
	cmpl	%ebx, n(%rip)
	jg	.L48
.L25:
	leaq	m(%rip), %rsi
	xorl	%eax, %eax
	xorl	%ebx, %ebx
	xorl	%r12d, %r12d
	leaq	.LC1(%rip), %rdi
	call	__isoc99_scanf@PLT
	movslq	m(%rip), %rdi
	movl	$10208, %esi
	movq	%rdi, %r14
	call	calloc@PLT
	movq	%rax, menu(%rip)
	testl	%r14d, %r14d
	jle	.L32
	.p2align 4,,10
	.p2align 3
.L27:
	leaq	(%rax,%rbx), %rsi
	movq	%r13, %rdi
	xorl	%eax, %eax
	leaq	104(%rsi), %rdx
	call	__isoc99_scanf@PLT
	movq	menu(%rip), %rax
	leaq	(%rax,%rbx), %rsi
	movl	104(%rsi), %edx
	testl	%edx, %edx
	jle	.L30
	movl	$108, %r15d
	xorl	%r14d, %r14d
	.p2align 4,,10
	.p2align 3
.L31:
	addq	%r15, %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	addl	$1, %r14d
	call	__isoc99_scanf@PLT
	movq	menu(%rip), %rax
	addq	$101, %r15
	leaq	(%rax,%rbx), %rsi
	cmpl	%r14d, 104(%rsi)
	jg	.L31
.L30:
	addl	$1, %r12d
	addq	$10208, %rbx
	cmpl	%r12d, m(%rip)
	jg	.L27
.L32:
	movq	%rsp, %rbx
	movq	%rbp, %rdi
	xorl	%eax, %eax
	xorl	%r14d, %r14d
	movq	%rbx, %rsi
	call	__isoc99_scanf@PLT
	movl	n(%rip), %r12d
	movq	product(%rip), %r15
	testl	%r12d, %r12d
	jg	.L34
	jmp	.L29
	.p2align 4,,10
	.p2align 3
.L33:
	addl	$1, %r14d
	addq	$108, %r15
	cmpl	%r14d, %r12d
	je	.L29
.L34:
	movq	%r15, %rsi
	movq	%rbx, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L33
	movl	%r14d, %edi
	call	minimum_cost
	movl	104(%r15), %edx
	movl	$1, %edi
	xorl	%eax, %eax
	leaq	.LC3(%rip), %rsi
	call	__printf_chk@PLT
.L29:
	movq	menu(%rip), %rdi
	call	free@PLT
	movq	product(%rip), %rdi
	call	free@PLT
	jmp	.L24
.L35:
	movq	104(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L49
	addq	$120, %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
.L49:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE51:
	.size	main, .-main
	.globl	menu
	.bss
	.align 8
	.type	menu, @object
	.size	menu, 8
menu:
	.zero	8
	.globl	product
	.align 8
	.type	product, @object
	.size	product, 8
product:
	.zero	8
	.globl	m
	.align 4
	.type	m, @object
	.size	m, 4
m:
	.zero	4
	.globl	n
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.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
	.file	"temp.c"
	.text
	.p2align 4
	.globl	minimum_cost
	.type	minimum_cost, @function
minimum_cost:
.LFB52:
	.cfi_startproc
	endbr64
	movl	m(%rip), %edx
	testl	%edx, %edx
	jle	.L18
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movslq	%edi, %rax
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	leaq	(%rax,%rax,2), %rax
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	leaq	(%rax,%rax,8), %rax
	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	$24, %rsp
	.cfi_def_cfa_offset 80
	movq	product(%rip), %rcx
	movq	menu(%rip), %rbx
	leaq	(%rcx,%rax,4), %r12
	leal	-1(%rdx), %eax
	movq	%rcx, (%rsp)
	imulq	$10208, %rax, %rax
	leaq	10208(%rbx,%rax), %rbp
	jmp	.L12
	.p2align 4,,10
	.p2align 3
.L3:
	addq	$10208, %rbx
	cmpq	%rbx, %rbp
	je	.L1
.L12:
	movq	%rbx, %rsi
	movq	%r12, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L3
	movl	104(%rbx), %eax
	movl	%eax, 8(%rsp)
	testl	%eax, %eax
	jle	.L22
	movl	$0, 12(%rsp)
	addq	$108, %rbx
	xorl	%r13d, %r13d
.L13:
	movl	n(%rip), %ebp
	testl	%ebp, %ebp
	jle	.L5
	movq	(%rsp), %r15
	xorl	%r14d, %r14d
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L6:
	addl	$1, %r14d
	addq	$108, %r15
	cmpl	%r14d, %ebp
	je	.L7
.L8:
	movq	%r15, %rsi
	movq	%rbx, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L6
	movl	%r14d, %edi
	call	minimum_cost
	movl	104(%r15), %edx
	addl	%edx, 12(%rsp)
.L7:
	addl	$1, %r13d
	cmpl	%r13d, 8(%rsp)
	je	.L5
	addq	$101, %rbx
	jmp	.L13
.L22:
	movl	$0, 12(%rsp)
	.p2align 4,,10
	.p2align 3
.L5:
	movl	12(%rsp), %eax
	cmpl	%eax, 104(%r12)
	jle	.L1
	movl	%eax, 104(%r12)
.L1:
	addq	$24, %rsp
	.cfi_def_cfa_offset 56
	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
.L18:
	.cfi_restore 3
	.cfi_restore 6
	.cfi_restore 12
	.cfi_restore 13
	.cfi_restore 14
	.cfi_restore 15
	ret
	.cfi_endproc
.LFE52:
	.size	minimum_cost, .-minimum_cost
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%s %d%*c"
.LC1:
	.string	"%d"
.LC2:
	.string	"%s%*c"
.LC3:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB51:
	.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
	leaq	.LC0(%rip), %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	leaq	.LC2(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$120, %rsp
	.cfi_def_cfa_offset 176
	movq	%fs:40, %rax
	movq	%rax, 104(%rsp)
	xorl	%eax, %eax
	.p2align 4,,10
	.p2align 3
.L24:
	xorl	%eax, %eax
	leaq	n(%rip), %rsi
	leaq	.LC1(%rip), %rdi
	call	__isoc99_scanf@PLT
	testl	%eax, %eax
	je	.L35
	movl	n(%rip), %ebx
	testl	%ebx, %ebx
	je	.L35
	movl	$108, %esi
	movslq	%ebx, %rdi
	call	calloc@PLT
	movq	%rax, product(%rip)
	movq	%rax, %rsi
	testl	%ebx, %ebx
	jle	.L25
	xorl	%r12d, %r12d
	xorl	%ebx, %ebx
	jmp	.L26
	.p2align 4,,10
	.p2align 3
.L48:
	movq	product(%rip), %rsi
.L26:
	addq	%r12, %rsi
	xorl	%eax, %eax
	movq	%r13, %rdi
	addl	$1, %ebx
	leaq	104(%rsi), %rdx
	addq	$108, %r12
	call	__isoc99_scanf@PLT
	cmpl	%ebx, n(%rip)
	jg	.L48
.L25:
	leaq	m(%rip), %rsi
	xorl	%eax, %eax
	xorl	%ebx, %ebx
	xorl	%r12d, %r12d
	leaq	.LC1(%rip), %rdi
	call	__isoc99_scanf@PLT
	movslq	m(%rip), %rdi
	movl	$10208, %esi
	movq	%rdi, %r14
	call	calloc@PLT
	movq	%rax, menu(%rip)
	testl	%r14d, %r14d
	jle	.L32
	.p2align 4,,10
	.p2align 3
.L27:
	leaq	(%rax,%rbx), %rsi
	movq	%r13, %rdi
	xorl	%eax, %eax
	leaq	104(%rsi), %rdx
	call	__isoc99_scanf@PLT
	movq	menu(%rip), %rax
	leaq	(%rax,%rbx), %rsi
	movl	104(%rsi), %edx
	testl	%edx, %edx
	jle	.L30
	movl	$108, %r15d
	xorl	%r14d, %r14d
	.p2align 4,,10
	.p2align 3
.L31:
	addq	%r15, %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	addl	$1, %r14d
	call	__isoc99_scanf@PLT
	movq	menu(%rip), %rax
	addq	$101, %r15
	leaq	(%rax,%rbx), %rsi
	cmpl	%r14d, 104(%rsi)
	jg	.L31
.L30:
	addl	$1, %r12d
	addq	$10208, %rbx
	cmpl	%r12d, m(%rip)
	jg	.L27
.L32:
	movq	%rsp, %rbx
	movq	%rbp, %rdi
	xorl	%eax, %eax
	xorl	%r14d, %r14d
	movq	%rbx, %rsi
	call	__isoc99_scanf@PLT
	movl	n(%rip), %r12d
	movq	product(%rip), %r15
	testl	%r12d, %r12d
	jg	.L34
	jmp	.L29
	.p2align 4,,10
	.p2align 3
.L33:
	addl	$1, %r14d
	addq	$108, %r15
	cmpl	%r14d, %r12d
	je	.L29
.L34:
	movq	%r15, %rsi
	movq	%rbx, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L33
	movl	%r14d, %edi
	call	minimum_cost
	movl	104(%r15), %edx
	movl	$1, %edi
	xorl	%eax, %eax
	leaq	.LC3(%rip), %rsi
	call	__printf_chk@PLT
.L29:
	movq	menu(%rip), %rdi
	call	free@PLT
	movq	product(%rip), %rdi
	call	free@PLT
	jmp	.L24
.L35:
	movq	104(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L49
	addq	$120, %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
.L49:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE51:
	.size	main, .-main
	.globl	menu
	.bss
	.align 8
	.type	menu, @object
	.size	menu, 8
menu:
	.zero	8
	.globl	product
	.align 8
	.type	product, @object
	.size	product, 8
product:
	.zero	8
	.globl	m
	.align 4
	.type	m, @object
	.size	m, 4
m:
	.zero	4
	.globl	n
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.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:

#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int n,m;
struct element{
  char name[101];
  int cost;
} *product;

struct recipe{
  char name[101];
  int num_of_prod;
  char zairyo[100][101];
} *menu;

void minimum_cost(int number);

int main(void){
  int i,j;
  char final[101];
  while(scanf("%d",&n) && n){
    product=(struct element *)calloc(n,sizeof(struct element));
    for(i=0;i<n;i++){
      scanf("%s %d%*c", product[i].name,&product[i].cost);
    }
    /*
    for(i=0;i<n;i++){
      printf("%s %d\n", product[i].name,product[i].cost);
      }*/

    scanf("%d",&m);
    menu=(struct recipe *)calloc(m,sizeof(struct recipe));
    for(i=0;i<m;i++){
      scanf("%s %d%*c", menu[i].name,&menu[i].num_of_prod);
      for(j=0;j<menu[i].num_of_prod;j++){
	scanf("%s%*c",menu[i].zairyo[j]);
      }
    }
    /*
    for(i=0;i<m;i++){
      printf("%s %d ", menu[i].name,menu[i].num_of_prod);
      for(j=0;j<menu[i].num_of_prod;j++){
	printf("%s ",menu[i].zairyo[j]);
      }
      putchar('\n');
      }*/
    
    scanf("%s%*c",final);
    for(i=0;i<n;i++){
      if(!strcmp(final,product[i].name)){
	minimum_cost(i);
	printf("%d\n",product[i].cost);
	break;
      }
    }
    
    free(menu);
    free(product);
  }
  return 0;
}

void minimum_cost(int number){
  int i,j,k;
  int sum=0;
  //printf("%d %d\n",m,n);
  //printf("%s recipe is searching...\n",product[number].name);
  for(i=0;i<m;i++){
    //printf("%lu %lu\n",strlen(product[number].name),strlen(menu[i].name));
    if(!strcmp(product[number].name,menu[i].name)){
      //printf("%s menu found!\n",product[number].name);
      for(j=0;j<menu[i].num_of_prod;j++){
	for(k=0;k<n;k++){
	  if(!strcmp(menu[i].zairyo[j],product[k].name)){
	    minimum_cost(k);
	    sum+=product[k].cost;
	    break;
	  }
	}	
      }
      //printf("%s cost is from %d to ",product[number].name,product[number].cost);
      if(sum<product[number].cost) product[number].cost=sum;
      //printf("%d \n",product[number].cost);
      break;
    }
  }
}
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>
#include<stdlib.h>
#include<string.h>

int n,m;
struct element{
  char name[101];
  int cost;
} *product;

struct recipe{
  char name[101];
  int num_of_prod;
  char zairyo[100][101];
} *menu;

void minimum_cost(int number);

int main(void){
  int i,j;
  char final[101];
  while(scanf("%d",&n) && n){
    product=(struct element *)calloc(n,sizeof(struct element));
    for(i=0;i<n;i++){
      scanf("%s %d%*c", product[i].name,&product[i].cost);
    }
    /*
    for(i=0;i<n;i++){
      printf("%s %d\n", product[i].name,product[i].cost);
      }*/

    scanf("%d",&m);
    menu=(struct recipe *)calloc(m,sizeof(struct recipe));
    for(i=0;i<m;i++){
      scanf("%s %d%*c", menu[i].name,&menu[i].num_of_prod);
      for(j=0;j<menu[i].num_of_prod;j++){
	scanf("%s%*c",menu[i].zairyo[j]);
      }
    }
    /*
    for(i=0;i<m;i++){
      printf("%s %d ", menu[i].name,menu[i].num_of_prod);
      for(j=0;j<menu[i].num_of_prod;j++){
	printf("%s ",menu[i].zairyo[j]);
      }
      putchar('\n');
      }*/
    
    scanf("%s%*c",final);
    for(i=0;i<n;i++){
      if(!strcmp(final,product[i].name)){
	minimum_cost(i);
	printf("%d\n",product[i].cost);
	break;
      }
    }
    
    free(menu);
    free(product);
  }
  return 0;
}

void minimum_cost(int number){
  int i,j,k;
  int sum=0;
  //printf("%d %d\n",m,n);
  //printf("%s recipe is searching...\n",product[number].name);
  for(i=0;i<m;i++){
    //printf("%lu %lu\n",strlen(product[number].name),strlen(menu[i].name));
    if(!strcmp(product[number].name,menu[i].name)){
      //printf("%s menu found!\n",product[number].name);
      for(j=0;j<menu[i].num_of_prod;j++){
	for(k=0;k<n;k++){
	  if(!strcmp(menu[i].zairyo[j],product[k].name)){
	    minimum_cost(k);
	    sum+=product[k].cost;
	    break;
	  }
	}	
      }
      //printf("%s cost is from %d to ",product[number].name,product[number].cost);
      if(sum<product[number].cost) product[number].cost=sum;
      //printf("%d \n",product[number].cost);
      break;
    }
  }
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	n
	.bss
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	m
	.align 4
	.type	m, @object
	.size	m, 4
m:
	.zero	4
	.globl	product
	.align 8
	.type	product, @object
	.size	product, 8
product:
	.zero	8
	.globl	menu
	.align 8
	.type	menu, @object
	.size	menu, 8
menu:
	.zero	8
	.section	.rodata
.LC0:
	.string	"%s %d%*c"
.LC1:
	.string	"%d"
.LC2:
	.string	"%s%*c"
.LC3:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	addq	$-128, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	jmp	.L2
.L14:
	movl	n(%rip), %eax
	cltq
	movl	$108, %esi
	movq	%rax, %rdi
	call	calloc@PLT
	movq	%rax, product(%rip)
	movl	$0, -120(%rbp)
	jmp	.L3
.L4:
	movq	product(%rip), %rcx
	movl	-120(%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	%rcx, %rax
	leaq	104(%rax), %rdx
	movq	product(%rip), %rsi
	movl	-120(%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, -120(%rbp)
.L3:
	movl	n(%rip), %eax
	cmpl	%eax, -120(%rbp)
	jl	.L4
	leaq	m(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	m(%rip), %eax
	cltq
	movl	$10208, %esi
	movq	%rax, %rdi
	call	calloc@PLT
	movq	%rax, menu(%rip)
	movl	$0, -120(%rbp)
	jmp	.L5
.L8:
	movq	menu(%rip), %rdx
	movl	-120(%rbp), %eax
	cltq
	imulq	$10208, %rax, %rax
	addq	%rdx, %rax
	addq	$104, %rax
	movq	menu(%rip), %rcx
	movl	-120(%rbp), %edx
	movslq	%edx, %rdx
	imulq	$10208, %rdx, %rdx
	addq	%rcx, %rdx
	movq	%rdx, %rcx
	movq	%rax, %rdx
	movq	%rcx, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -116(%rbp)
	jmp	.L6
.L7:
	movq	menu(%rip), %rdx
	movl	-120(%rbp), %eax
	cltq
	imulq	$10208, %rax, %rax
	leaq	(%rdx,%rax), %rsi
	movl	-116(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rcx
	addq	%rcx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	$96, %rax
	addq	%rsi, %rax
	addq	$12, %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -116(%rbp)
.L6:
	movq	menu(%rip), %rdx
	movl	-120(%rbp), %eax
	cltq
	imulq	$10208, %rax, %rax
	addq	%rdx, %rax
	movl	104(%rax), %eax
	cmpl	%eax, -116(%rbp)
	jl	.L7
	addl	$1, -120(%rbp)
.L5:
	movl	m(%rip), %eax
	cmpl	%eax, -120(%rbp)
	jl	.L8
	leaq	-112(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -120(%rbp)
	jmp	.L9
.L12:
	movq	product(%rip), %rcx
	movl	-120(%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	%rcx, %rax
	movq	%rax, %rdx
	leaq	-112(%rbp), %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L10
	movl	-120(%rbp), %eax
	movl	%eax, %edi
	call	minimum_cost
	movq	product(%rip), %rcx
	movl	-120(%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	%rcx, %rax
	movl	104(%rax), %eax
	movl	%eax, %esi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L11
.L10:
	addl	$1, -120(%rbp)
.L9:
	movl	n(%rip), %eax
	cmpl	%eax, -120(%rbp)
	jl	.L12
.L11:
	movq	menu(%rip), %rax
	movq	%rax, %rdi
	call	free@PLT
	movq	product(%rip), %rax
	movq	%rax, %rdi
	call	free@PLT
.L2:
	leaq	n(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	testl	%eax, %eax
	je	.L13
	movl	n(%rip), %eax
	testl	%eax, %eax
	jne	.L14
.L13:
	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
.LFE6:
	.size	main, .-main
	.globl	minimum_cost
	.type	minimum_cost, @function
minimum_cost:
.LFB7:
	.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
	movl	%edi, -20(%rbp)
	movl	$0, -4(%rbp)
	movl	$0, -16(%rbp)
	jmp	.L18
.L28:
	movq	menu(%rip), %rdx
	movl	-16(%rbp), %eax
	cltq
	imulq	$10208, %rax, %rax
	addq	%rdx, %rax
	movq	%rax, %rcx
	movq	product(%rip), %rsi
	movl	-20(%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	%rsi, %rax
	movq	%rcx, %rsi
	movq	%rax, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L19
	movl	$0, -12(%rbp)
	jmp	.L20
.L25:
	movl	$0, -8(%rbp)
	jmp	.L21
.L24:
	movq	product(%rip), %rcx
	movl	-8(%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	%rcx, %rax
	movq	%rax, %rcx
	movq	menu(%rip), %rdx
	movl	-16(%rbp), %eax
	cltq
	imulq	$10208, %rax, %rax
	leaq	(%rdx,%rax), %rdi
	movl	-12(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rsi
	addq	%rsi, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	$96, %rax
	addq	%rdi, %rax
	addq	$12, %rax
	movq	%rcx, %rsi
	movq	%rax, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L22
	movl	-8(%rbp), %eax
	movl	%eax, %edi
	call	minimum_cost
	movq	product(%rip), %rcx
	movl	-8(%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	%rcx, %rax
	movl	104(%rax), %eax
	addl	%eax, -4(%rbp)
	jmp	.L23
.L22:
	addl	$1, -8(%rbp)
.L21:
	movl	n(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jl	.L24
.L23:
	addl	$1, -12(%rbp)
.L20:
	movq	menu(%rip), %rdx
	movl	-16(%rbp), %eax
	cltq
	imulq	$10208, %rax, %rax
	addq	%rdx, %rax
	movl	104(%rax), %eax
	cmpl	%eax, -12(%rbp)
	jl	.L25
	movq	product(%rip), %rcx
	movl	-20(%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	%rcx, %rax
	movl	104(%rax), %eax
	cmpl	%eax, -4(%rbp)
	jge	.L29
	movq	product(%rip), %rcx
	movl	-20(%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
	movl	-4(%rbp), %eax
	movl	%eax, 104(%rdx)
	jmp	.L29
.L19:
	addl	$1, -16(%rbp)
.L18:
	movl	m(%rip), %eax
	cmpl	%eax, -16(%rbp)
	jl	.L28
	jmp	.L30
.L29:
	nop
.L30:
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	minimum_cost, .-minimum_cost
	.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
	.globl	n
	.bss
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	m
	.align 4
	.type	m, @object
	.size	m, 4
m:
	.zero	4
	.globl	product
	.align 8
	.type	product, @object
	.size	product, 8
product:
	.zero	8
	.globl	menu
	.align 8
	.type	menu, @object
	.size	menu, 8
menu:
	.zero	8
	.section	.rodata
.LC0:
	.string	"%s %d%*c"
.LC1:
	.string	"%d"
.LC2:
	.string	"%s%*c"
.LC3:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	addq	$-128, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	jmp	.L2
.L14:
	movl	n(%rip), %eax
	cltq
	movl	$108, %esi
	movq	%rax, %rdi
	call	calloc@PLT
	movq	%rax, product(%rip)
	movl	$0, -120(%rbp)
	jmp	.L3
.L4:
	movq	product(%rip), %rcx
	movl	-120(%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	%rcx, %rax
	leaq	104(%rax), %rdx
	movq	product(%rip), %rsi
	movl	-120(%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, -120(%rbp)
.L3:
	movl	n(%rip), %eax
	cmpl	%eax, -120(%rbp)
	jl	.L4
	leaq	m(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	m(%rip), %eax
	cltq
	movl	$10208, %esi
	movq	%rax, %rdi
	call	calloc@PLT
	movq	%rax, menu(%rip)
	movl	$0, -120(%rbp)
	jmp	.L5
.L8:
	movq	menu(%rip), %rdx
	movl	-120(%rbp), %eax
	cltq
	imulq	$10208, %rax, %rax
	addq	%rdx, %rax
	addq	$104, %rax
	movq	menu(%rip), %rcx
	movl	-120(%rbp), %edx
	movslq	%edx, %rdx
	imulq	$10208, %rdx, %rdx
	addq	%rcx, %rdx
	movq	%rdx, %rcx
	movq	%rax, %rdx
	movq	%rcx, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -116(%rbp)
	jmp	.L6
.L7:
	movq	menu(%rip), %rdx
	movl	-120(%rbp), %eax
	cltq
	imulq	$10208, %rax, %rax
	leaq	(%rdx,%rax), %rsi
	movl	-116(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rcx
	addq	%rcx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	$96, %rax
	addq	%rsi, %rax
	addq	$12, %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -116(%rbp)
.L6:
	movq	menu(%rip), %rdx
	movl	-120(%rbp), %eax
	cltq
	imulq	$10208, %rax, %rax
	addq	%rdx, %rax
	movl	104(%rax), %eax
	cmpl	%eax, -116(%rbp)
	jl	.L7
	addl	$1, -120(%rbp)
.L5:
	movl	m(%rip), %eax
	cmpl	%eax, -120(%rbp)
	jl	.L8
	leaq	-112(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -120(%rbp)
	jmp	.L9
.L12:
	movq	product(%rip), %rcx
	movl	-120(%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	%rcx, %rax
	movq	%rax, %rdx
	leaq	-112(%rbp), %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L10
	movl	-120(%rbp), %eax
	movl	%eax, %edi
	call	minimum_cost
	movq	product(%rip), %rcx
	movl	-120(%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	%rcx, %rax
	movl	104(%rax), %eax
	movl	%eax, %esi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L11
.L10:
	addl	$1, -120(%rbp)
.L9:
	movl	n(%rip), %eax
	cmpl	%eax, -120(%rbp)
	jl	.L12
.L11:
	movq	menu(%rip), %rax
	movq	%rax, %rdi
	call	free@PLT
	movq	product(%rip), %rax
	movq	%rax, %rdi
	call	free@PLT
.L2:
	leaq	n(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	testl	%eax, %eax
	je	.L13
	movl	n(%rip), %eax
	testl	%eax, %eax
	jne	.L14
.L13:
	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
.LFE6:
	.size	main, .-main
	.globl	minimum_cost
	.type	minimum_cost, @function
minimum_cost:
.LFB7:
	.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
	movl	%edi, -20(%rbp)
	movl	$0, -4(%rbp)
	movl	$0, -16(%rbp)
	jmp	.L18
.L28:
	movq	menu(%rip), %rdx
	movl	-16(%rbp), %eax
	cltq
	imulq	$10208, %rax, %rax
	addq	%rdx, %rax
	movq	%rax, %rcx
	movq	product(%rip), %rsi
	movl	-20(%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	%rsi, %rax
	movq	%rcx, %rsi
	movq	%rax, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L19
	movl	$0, -12(%rbp)
	jmp	.L20
.L25:
	movl	$0, -8(%rbp)
	jmp	.L21
.L24:
	movq	product(%rip), %rcx
	movl	-8(%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	%rcx, %rax
	movq	%rax, %rcx
	movq	menu(%rip), %rdx
	movl	-16(%rbp), %eax
	cltq
	imulq	$10208, %rax, %rax
	leaq	(%rdx,%rax), %rdi
	movl	-12(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rsi
	addq	%rsi, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	$96, %rax
	addq	%rdi, %rax
	addq	$12, %rax
	movq	%rcx, %rsi
	movq	%rax, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L22
	movl	-8(%rbp), %eax
	movl	%eax, %edi
	call	minimum_cost
	movq	product(%rip), %rcx
	movl	-8(%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	%rcx, %rax
	movl	104(%rax), %eax
	addl	%eax, -4(%rbp)
	jmp	.L23
.L22:
	addl	$1, -8(%rbp)
.L21:
	movl	n(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jl	.L24
.L23:
	addl	$1, -12(%rbp)
.L20:
	movq	menu(%rip), %rdx
	movl	-16(%rbp), %eax
	cltq
	imulq	$10208, %rax, %rax
	addq	%rdx, %rax
	movl	104(%rax), %eax
	cmpl	%eax, -12(%rbp)
	jl	.L25
	movq	product(%rip), %rcx
	movl	-20(%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	%rcx, %rax
	movl	104(%rax), %eax
	cmpl	%eax, -4(%rbp)
	jge	.L29
	movq	product(%rip), %rcx
	movl	-20(%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
	movl	-4(%rbp), %eax
	movl	%eax, 104(%rdx)
	jmp	.L29
.L19:
	addl	$1, -16(%rbp)
.L18:
	movl	m(%rip), %eax
	cmpl	%eax, -16(%rbp)
	jl	.L28
	jmp	.L30
.L29:
	nop
.L30:
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	minimum_cost, .-minimum_cost
	.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:
