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 main(){
  int i,n,all,j;
  char *x;
 
char str2[100];
  int t[50];
  scanf("%d",&n);
      

char *pstr[50];          /* 1. */
char str[100];          /* 2. */

for(i = 0; i < n; i++){
    scanf("%s %d",str,&t[i]);   
    pstr[i] = (char *)malloc(sizeof(char) * (strlen(str)+1)); /* 4. */
    strcpy(pstr[i],str); 
}
 
  scanf("%s",str2);
  
  x=(char *)malloc(sizeof(char) * (strlen(str2)+1));
  strcpy(x, str2);
  
  all=0;
  
  for(i=0;i<n;i++){
  if(strcmp(pstr[i],x)==0){
    for(j=i+1;j<n;j++){
      all=t[j]+all;
  }
  }
  }
  printf("%d",all);
}
  ```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%s %d"
.LC2:
	.string	"%s"
	.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
	subq	$864, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-856(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -852(%rbp)
	jmp	.L2
.L3:
	leaq	-832(%rbp), %rdx
	movl	-852(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rax, %rdx
	leaq	-112(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	leaq	-112(%rbp), %rax
	movq	%rax, %rdi
	call	strlen@PLT
	addq	$1, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, %rdx
	movl	-852(%rbp), %eax
	cltq
	movq	%rdx, -624(%rbp,%rax,8)
	movl	-852(%rbp), %eax
	cltq
	movq	-624(%rbp,%rax,8), %rax
	leaq	-112(%rbp), %rdx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strcpy@PLT
	addl	$1, -852(%rbp)
.L2:
	movl	-856(%rbp), %eax
	cmpl	%eax, -852(%rbp)
	jl	.L3
	leaq	-224(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	leaq	-224(%rbp), %rax
	movq	%rax, %rdi
	call	strlen@PLT
	addq	$1, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, -840(%rbp)
	leaq	-224(%rbp), %rdx
	movq	-840(%rbp), %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strcpy@PLT
	movl	$0, -848(%rbp)
	movl	$0, -852(%rbp)
	jmp	.L4
.L8:
	movl	-852(%rbp), %eax
	cltq
	movq	-624(%rbp,%rax,8), %rax
	movq	-840(%rbp), %rdx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L5
	movl	-852(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -844(%rbp)
	jmp	.L6
.L7:
	movl	-844(%rbp), %eax
	cltq
	movl	-832(%rbp,%rax,4), %eax
	addl	%eax, -848(%rbp)
	addl	$1, -844(%rbp)
.L6:
	movl	-856(%rbp), %eax
	cmpl	%eax, -844(%rbp)
	jl	.L7
.L5:
	addl	$1, -852(%rbp)
.L4:
	movl	-856(%rbp), %eax
	cmpl	%eax, -852(%rbp)
	jl	.L8
	movl	-848(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L10
	call	__stack_chk_fail@PLT
.L10:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.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	"%s"
.LC2:
	.string	"%s %d"
	.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
	leaq	.LC0(%rip), %rdi
	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	$872, %rsp
	.cfi_def_cfa_offset 928
	movq	%fs:40, %rax
	movq	%rax, 856(%rsp)
	xorl	%eax, %eax
	leaq	28(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movl	28(%rsp), %eax
	testl	%eax, %eax
	jle	.L14
	leaq	32(%rsp), %r13
	xorl	%r14d, %r14d
	leaq	752(%rsp), %r15
	leaq	.LC2(%rip), %r12
	leaq	240(%rsp), %rbp
	jmp	.L13
	.p2align 4,,10
	.p2align 3
.L68:
	testb	$4, %bl
	jne	.L66
	testl	%ebx, %ebx
	je	.L10
	movzbl	(%r15), %ecx
	movb	%cl, (%rax)
	testb	$2, %bl
	jne	.L67
.L10:
	addq	$1, %r14
	addq	$4, %r13
	cmpl	%r14d, 28(%rsp)
	jle	.L14
.L13:
	movq	%r13, %rdx
	movq	%r15, %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movq	%r15, %rdi
	call	strlen@PLT
	leaq	1(%rax), %rbx
	movq	%rbx, %rdi
	call	malloc@PLT
	movq	%rax, 0(%rbp,%r14,8)
	cmpl	$8, %ebx
	jb	.L68
	movl	%ebx, %ecx
	movq	%rax, %rdi
	addq	$1, %r14
	addq	$4, %r13
	movq	-8(%r15,%rcx), %rsi
	movq	%rsi, -8(%rax,%rcx)
	leal	-1(%rbx), %ecx
	movq	%r15, %rsi
	shrl	$3, %ecx
	rep movsq
	cmpl	%r14d, 28(%rsp)
	jg	.L13
.L14:
	leaq	640(%rsp), %rbp
	leaq	.LC1(%rip), %rdi
	xorl	%eax, %eax
	movq	%rbp, %rsi
	call	__isoc99_scanf@PLT
	movq	%rbp, %rdi
	call	strlen@PLT
	leaq	1(%rax), %rbx
	movq	%rbx, %rdi
	call	malloc@PLT
	movq	%rax, %r14
	cmpl	$8, %ebx
	jnb	.L3
	testb	$4, %bl
	jne	.L69
	testl	%ebx, %ebx
	je	.L4
	movzbl	640(%rsp), %eax
	movb	%al, (%r14)
	testb	$2, %bl
	je	.L4
	movl	%ebx, %ebx
	movzwl	-2(%rbp,%rbx), %eax
	movw	%ax, -2(%r14,%rbx)
	jmp	.L4
.L3:
	movl	%ebx, %eax
	leal	-1(%rbx), %ecx
	movq	%r14, %rdi
	movq	%rbp, %rsi
	movq	-8(%rbp,%rax), %rdx
	shrl	$3, %ecx
	movq	%rdx, -8(%r14,%rax)
	rep movsq
.L4:
	movl	28(%rsp), %eax
	xorl	%r12d, %r12d
	movl	%eax, 12(%rsp)
	testl	%eax, %eax
	jle	.L8
	leal	-1(%rax), %r15d
	leaq	36(%rsp), %r13
	movl	$1, %ebx
	xorl	%r12d, %r12d
	leaq	240(%rsp), %rbp
	jmp	.L19
	.p2align 4,,10
	.p2align 3
.L15:
	addq	$1, %rbx
	movl	%esi, %r15d
	addq	$4, %r13
	cmpl	$-1, %esi
	je	.L8
.L19:
	movq	-8(%rbp,%rbx,8), %rdi
	movq	%r14, %rsi
	call	strcmp@PLT
	movl	%ebx, %ecx
	leal	-1(%r15), %esi
	testl	%eax, %eax
	jne	.L15
	cmpl	%ebx, 12(%rsp)
	jle	.L15
	cmpl	$2, %esi
	jbe	.L16
	movl	%r15d, %eax
	movdqu	0(%r13), %xmm0
	shrl	$2, %eax
	cmpl	$1, %eax
	je	.L17
	movdqu	16(%r13), %xmm2
	paddd	%xmm2, %xmm0
	cmpl	$2, %eax
	je	.L17
	movdqu	32(%r13), %xmm3
	paddd	%xmm3, %xmm0
	cmpl	$3, %eax
	je	.L17
	movdqu	48(%r13), %xmm4
	paddd	%xmm4, %xmm0
	cmpl	$4, %eax
	je	.L17
	movdqu	64(%r13), %xmm5
	paddd	%xmm5, %xmm0
	cmpl	$5, %eax
	je	.L17
	movdqu	80(%r13), %xmm6
	paddd	%xmm6, %xmm0
	cmpl	$6, %eax
	je	.L17
	movdqu	96(%r13), %xmm7
	paddd	%xmm7, %xmm0
	cmpl	$7, %eax
	je	.L17
	movdqu	112(%r13), %xmm7
	paddd	%xmm7, %xmm0
	cmpl	$8, %eax
	je	.L17
	movdqu	128(%r13), %xmm6
	paddd	%xmm6, %xmm0
	cmpl	$9, %eax
	je	.L17
	movdqu	144(%r13), %xmm5
	paddd	%xmm5, %xmm0
	cmpl	$10, %eax
	je	.L17
	movdqu	160(%r13), %xmm4
	paddd	%xmm4, %xmm0
	cmpl	$11, %eax
	je	.L17
	movdqu	176(%r13), %xmm7
	paddd	%xmm7, %xmm0
	.p2align 4,,10
	.p2align 3
.L17:
	movdqa	%xmm0, %xmm1
	psrldq	$8, %xmm1
	paddd	%xmm1, %xmm0
	movdqa	%xmm0, %xmm1
	psrldq	$4, %xmm1
	paddd	%xmm1, %xmm0
	movd	%xmm0, %eax
	addl	%eax, %r12d
	movl	%r15d, %eax
	andl	$-4, %eax
	addl	%eax, %ecx
	cmpl	%eax, %r15d
	je	.L15
.L16:
	movslq	%ecx, %rax
	movl	12(%rsp), %edx
	addl	32(%rsp,%rax,4), %r12d
	leal	1(%rcx), %eax
	cmpl	%edx, %eax
	jge	.L15
	cltq
	addl	$2, %ecx
	addl	32(%rsp,%rax,4), %r12d
	cmpl	%ecx, %edx
	jle	.L15
	movslq	%ecx, %rcx
	addq	$1, %rbx
	movl	%esi, %r15d
	addq	$4, %r13
	addl	32(%rsp,%rcx,4), %r12d
	cmpl	$-1, %esi
	jne	.L19
	.p2align 4,,10
	.p2align 3
.L8:
	xorl	%eax, %eax
	movl	%r12d, %edx
	movl	$1, %edi
	leaq	.LC0(%rip), %rsi
	call	__printf_chk@PLT
	movq	856(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L70
	addq	$872, %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
.L66:
	.cfi_restore_state
	movl	(%r15), %ecx
	movl	%ebx, %ebx
	movl	%ecx, (%rax)
	movl	-4(%r15,%rbx), %ecx
	movl	%ecx, -4(%rax,%rbx)
	jmp	.L10
.L69:
	movl	640(%rsp), %eax
	movl	%ebx, %ebx
	movl	%eax, (%r14)
	movl	-4(%rbp,%rbx), %eax
	movl	%eax, -4(%r14,%rbx)
	jmp	.L4
.L67:
	movl	%ebx, %ebx
	movzwl	-2(%r15,%rbx), %ecx
	movw	%cx, -2(%rax,%rbx)
	jmp	.L10
.L70:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE51:
	.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	"%s"
.LC2:
	.string	"%s %d"
	.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
	leaq	.LC0(%rip), %rdi
	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	$872, %rsp
	.cfi_def_cfa_offset 928
	movq	%fs:40, %rax
	movq	%rax, 856(%rsp)
	xorl	%eax, %eax
	leaq	28(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movl	28(%rsp), %eax
	testl	%eax, %eax
	jle	.L14
	leaq	32(%rsp), %r13
	xorl	%r14d, %r14d
	leaq	752(%rsp), %r15
	leaq	.LC2(%rip), %r12
	leaq	240(%rsp), %rbp
	jmp	.L13
	.p2align 4,,10
	.p2align 3
.L68:
	testb	$4, %bl
	jne	.L66
	testl	%ebx, %ebx
	je	.L10
	movzbl	(%r15), %ecx
	movb	%cl, (%rax)
	testb	$2, %bl
	jne	.L67
.L10:
	addq	$1, %r14
	addq	$4, %r13
	cmpl	%r14d, 28(%rsp)
	jle	.L14
.L13:
	movq	%r13, %rdx
	movq	%r15, %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movq	%r15, %rdi
	call	strlen@PLT
	leaq	1(%rax), %rbx
	movq	%rbx, %rdi
	call	malloc@PLT
	movq	%rax, 0(%rbp,%r14,8)
	cmpl	$8, %ebx
	jb	.L68
	movl	%ebx, %ecx
	movq	%rax, %rdi
	addq	$1, %r14
	addq	$4, %r13
	movq	-8(%r15,%rcx), %rsi
	movq	%rsi, -8(%rax,%rcx)
	leal	-1(%rbx), %ecx
	movq	%r15, %rsi
	shrl	$3, %ecx
	rep movsq
	cmpl	%r14d, 28(%rsp)
	jg	.L13
.L14:
	leaq	640(%rsp), %rbp
	leaq	.LC1(%rip), %rdi
	xorl	%eax, %eax
	movq	%rbp, %rsi
	call	__isoc99_scanf@PLT
	movq	%rbp, %rdi
	call	strlen@PLT
	leaq	1(%rax), %rbx
	movq	%rbx, %rdi
	call	malloc@PLT
	movq	%rax, %r14
	cmpl	$8, %ebx
	jnb	.L3
	testb	$4, %bl
	jne	.L69
	testl	%ebx, %ebx
	je	.L4
	movzbl	640(%rsp), %eax
	movb	%al, (%r14)
	testb	$2, %bl
	je	.L4
	movl	%ebx, %ebx
	movzwl	-2(%rbp,%rbx), %eax
	movw	%ax, -2(%r14,%rbx)
	jmp	.L4
.L3:
	movl	%ebx, %eax
	leal	-1(%rbx), %ecx
	movq	%r14, %rdi
	movq	%rbp, %rsi
	movq	-8(%rbp,%rax), %rdx
	shrl	$3, %ecx
	movq	%rdx, -8(%r14,%rax)
	rep movsq
.L4:
	movl	28(%rsp), %eax
	xorl	%r12d, %r12d
	movl	%eax, 12(%rsp)
	testl	%eax, %eax
	jle	.L8
	leal	-1(%rax), %r15d
	leaq	36(%rsp), %r13
	movl	$1, %ebx
	xorl	%r12d, %r12d
	leaq	240(%rsp), %rbp
	jmp	.L19
	.p2align 4,,10
	.p2align 3
.L15:
	addq	$1, %rbx
	movl	%esi, %r15d
	addq	$4, %r13
	cmpl	$-1, %esi
	je	.L8
.L19:
	movq	-8(%rbp,%rbx,8), %rdi
	movq	%r14, %rsi
	call	strcmp@PLT
	movl	%ebx, %ecx
	leal	-1(%r15), %esi
	testl	%eax, %eax
	jne	.L15
	cmpl	%ebx, 12(%rsp)
	jle	.L15
	cmpl	$2, %esi
	jbe	.L16
	movl	%r15d, %eax
	movdqu	0(%r13), %xmm0
	shrl	$2, %eax
	cmpl	$1, %eax
	je	.L17
	movdqu	16(%r13), %xmm2
	paddd	%xmm2, %xmm0
	cmpl	$2, %eax
	je	.L17
	movdqu	32(%r13), %xmm3
	paddd	%xmm3, %xmm0
	cmpl	$3, %eax
	je	.L17
	movdqu	48(%r13), %xmm4
	paddd	%xmm4, %xmm0
	cmpl	$4, %eax
	je	.L17
	movdqu	64(%r13), %xmm5
	paddd	%xmm5, %xmm0
	cmpl	$5, %eax
	je	.L17
	movdqu	80(%r13), %xmm6
	paddd	%xmm6, %xmm0
	cmpl	$6, %eax
	je	.L17
	movdqu	96(%r13), %xmm7
	paddd	%xmm7, %xmm0
	cmpl	$7, %eax
	je	.L17
	movdqu	112(%r13), %xmm7
	paddd	%xmm7, %xmm0
	cmpl	$8, %eax
	je	.L17
	movdqu	128(%r13), %xmm6
	paddd	%xmm6, %xmm0
	cmpl	$9, %eax
	je	.L17
	movdqu	144(%r13), %xmm5
	paddd	%xmm5, %xmm0
	cmpl	$10, %eax
	je	.L17
	movdqu	160(%r13), %xmm4
	paddd	%xmm4, %xmm0
	cmpl	$11, %eax
	je	.L17
	movdqu	176(%r13), %xmm7
	paddd	%xmm7, %xmm0
	.p2align 4,,10
	.p2align 3
.L17:
	movdqa	%xmm0, %xmm1
	psrldq	$8, %xmm1
	paddd	%xmm1, %xmm0
	movdqa	%xmm0, %xmm1
	psrldq	$4, %xmm1
	paddd	%xmm1, %xmm0
	movd	%xmm0, %eax
	addl	%eax, %r12d
	movl	%r15d, %eax
	andl	$-4, %eax
	addl	%eax, %ecx
	cmpl	%eax, %r15d
	je	.L15
.L16:
	movslq	%ecx, %rax
	movl	12(%rsp), %edx
	addl	32(%rsp,%rax,4), %r12d
	leal	1(%rcx), %eax
	cmpl	%edx, %eax
	jge	.L15
	cltq
	addl	$2, %ecx
	addl	32(%rsp,%rax,4), %r12d
	cmpl	%ecx, %edx
	jle	.L15
	movslq	%ecx, %rcx
	addq	$1, %rbx
	movl	%esi, %r15d
	addq	$4, %r13
	addl	32(%rsp,%rcx,4), %r12d
	cmpl	$-1, %esi
	jne	.L19
	.p2align 4,,10
	.p2align 3
.L8:
	xorl	%eax, %eax
	movl	%r12d, %edx
	movl	$1, %edi
	leaq	.LC0(%rip), %rsi
	call	__printf_chk@PLT
	movq	856(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L70
	addq	$872, %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
.L66:
	.cfi_restore_state
	movl	(%r15), %ecx
	movl	%ebx, %ebx
	movl	%ecx, (%rax)
	movl	-4(%r15,%rbx), %ecx
	movl	%ecx, -4(%rax,%rbx)
	jmp	.L10
.L69:
	movl	640(%rsp), %eax
	movl	%ebx, %ebx
	movl	%eax, (%r14)
	movl	-4(%rbp,%rbx), %eax
	movl	%eax, -4(%r14,%rbx)
	jmp	.L4
.L67:
	movl	%ebx, %ebx
	movzwl	-2(%r15,%rbx), %ecx
	movw	%cx, -2(%rax,%rbx)
	jmp	.L10
.L70:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE51:
	.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>
#include<stdlib.h>
#include<string.h>
int main(){
  int i,n,all,j;
  char *x;
 
char str2[100];
  int t[50];
  scanf("%d",&n);
      

char *pstr[50];          /* 1. */
char str[100];          /* 2. */

for(i = 0; i < n; i++){
    scanf("%s %d",str,&t[i]);   
    pstr[i] = (char *)malloc(sizeof(char) * (strlen(str)+1)); /* 4. */
    strcpy(pstr[i],str); 
}
 
  scanf("%s",str2);
  
  x=(char *)malloc(sizeof(char) * (strlen(str2)+1));
  strcpy(x, str2);
  
  all=0;
  
  for(i=0;i<n;i++){
  if(strcmp(pstr[i],x)==0){
    for(j=i+1;j<n;j++){
      all=t[j]+all;
  }
  }
  }
  printf("%d",all);
}
  
15
ypnxn 279
kgjgwx 464
qquhuwq 327
rxing 549
pmuduhznoaqu 832
dagktgdarveusju 595
wunfagppcoi 200
dhavrncwfw 720
jpcmigg 658
wrczqxycivdqn 639
mcmkkbnjfeod 992
zstythbkgkvqth 130
twflegsjz 467
dswxxrxuzzfhkp 989
szfwtzfpnscgue 958
pmuduhznoaqu
 1
abcde 0000
abcde
 15
ypnxn 279
kgjfwx 464
qquhuwq 327
rxing 549
pmuduhznoaqu 832
dagktgdarveusju 595
wunfagppcoi 200
dhavrncwfw 720
jpcmigg 658
wrczqxycivdqn 639
mcmkkbnjfeod 992
zstythbkgkvqth 130
twflegsjz 809
dswxxrxuzzfhkp 989
szfwtzfpnscgue 958
pmuduhznoaqu
 15
ynpxn 307
jgfjwx 127
qquhuwq 319
rxing 549
pmuduhznoaqu 832
dagktgdarveusju 595
iunfagppcow 200
dhavrncwfw 1135
ggimcpj 658
wrczqxycivdqn 639
mcmkkbnjfeod 992
zstythbkgkwqth 130
twflegsjz 809
dswzxrxuzxfhkp 989
szfwtzfpnscgue 958
pmuduhznoaqu
 3
dwango 2
sixth 5
prelims 4
dwango
 15
ypnxn 279
kgjgwx 464
qquhuwq 327
rxing 549
pmuduhznoaqu 832
dagktgdarveusju 595
wunfagppcoi 200
dhavrncwfw 720
jpcmigg 658
wrczqxycivdqn 639
mcmkkbnjfeod 992
zstythbkgkvqth 130
twflegsjz 467
dswxxrxuzzfhkp 1344
szfwtzfpnscgue 958
pmuduhznoaqu
 15
ypnxn 279
kgjfwx 464
qquhuwq 327
rxing 549
pmuduhznoaqu 832
dagktgdarveusju 595
wunfagppcoi 200
dhavrncwfw 720
jpcmigg 1050
wrczqxycivdqn 639
mcmkkbnjfeod 992
zstythbkgkvqth 130
twflegsjz 467
dswxxrxuzzfhkp 989
szfwtzfpnscgue 958
pmuduhznoaqu
 15
ynpxn 279
jgjfwx 127
qquhuwq 319
rxing 549
pmuduhznoaqu 832
dagktgdarveusju 595
iunfagppcow 200
dhavrncwfw 720
ggimcpj 658
wrczqxycivdqn 19
mcmkkbnjfeod 992
zstythbkgkwqth 130
twflegsjz 809
dswzxrxuzxfhkp 989
szfwtzfpnscgue 958
pmuduhznoaqu
 15
ynpxn 279
jgfjwx 127
qquhuwq 319
rxing 549
pmuduhznoaqu 832
dagktgdarveusju 595
iunfagppcow 200
dhavrncwfw 720
ggimcpj 658
wrczqxycivdqn 639
mcmkkbnjfeod 327
zstythbkgkwqth 130
twflegsjz 809
dswzxrxuzxfhkp 989
szfwtzfpnscgue 958
pmuduhznoaqu
 3
dwango 2
sixth 5
prelims 7
dwango

6348 0 6690 7105 9 6703 6740 6070 6025 12
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 main(){
  int i,n,all,j;
  char *x;
 
char str2[100];
  int t[50];
  scanf("%d",&n);
      

char *pstr[50];          /* 1. */
char str[100];          /* 2. */

for(i = 0; i < n; i++){
    scanf("%s %d",str,&t[i]);   
    pstr[i] = (char *)malloc(sizeof(char) * (strlen(str)+1)); /* 4. */
    strcpy(pstr[i],str); 
}
 
  scanf("%s",str2);
  
  x=(char *)malloc(sizeof(char) * (strlen(str2)+1));
  strcpy(x, str2);
  
  all=0;
  
  for(i=0;i<n;i++){
  if(strcmp(pstr[i],x)==0){
    for(j=i+1;j<n;j++){
      all=t[j]+all;
  }
  }
  }
  printf("%d",all);
}
  ```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%s %d"
.LC2:
	.string	"%s"
	.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
	subq	$864, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-856(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -852(%rbp)
	jmp	.L2
.L3:
	leaq	-832(%rbp), %rdx
	movl	-852(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rax, %rdx
	leaq	-112(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	leaq	-112(%rbp), %rax
	movq	%rax, %rdi
	call	strlen@PLT
	addq	$1, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, %rdx
	movl	-852(%rbp), %eax
	cltq
	movq	%rdx, -624(%rbp,%rax,8)
	movl	-852(%rbp), %eax
	cltq
	movq	-624(%rbp,%rax,8), %rax
	leaq	-112(%rbp), %rdx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strcpy@PLT
	addl	$1, -852(%rbp)
.L2:
	movl	-856(%rbp), %eax
	cmpl	%eax, -852(%rbp)
	jl	.L3
	leaq	-224(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	leaq	-224(%rbp), %rax
	movq	%rax, %rdi
	call	strlen@PLT
	addq	$1, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, -840(%rbp)
	leaq	-224(%rbp), %rdx
	movq	-840(%rbp), %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strcpy@PLT
	movl	$0, -848(%rbp)
	movl	$0, -852(%rbp)
	jmp	.L4
.L8:
	movl	-852(%rbp), %eax
	cltq
	movq	-624(%rbp,%rax,8), %rax
	movq	-840(%rbp), %rdx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L5
	movl	-852(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -844(%rbp)
	jmp	.L6
.L7:
	movl	-844(%rbp), %eax
	cltq
	movl	-832(%rbp,%rax,4), %eax
	addl	%eax, -848(%rbp)
	addl	$1, -844(%rbp)
.L6:
	movl	-856(%rbp), %eax
	cmpl	%eax, -844(%rbp)
	jl	.L7
.L5:
	addl	$1, -852(%rbp)
.L4:
	movl	-856(%rbp), %eax
	cmpl	%eax, -852(%rbp)
	jl	.L8
	movl	-848(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L10
	call	__stack_chk_fail@PLT
.L10:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.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	"%s %d"
.LC2:
	.string	"%s"
	.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
	subq	$864, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-856(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -852(%rbp)
	jmp	.L2
.L3:
	leaq	-832(%rbp), %rdx
	movl	-852(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rax, %rdx
	leaq	-112(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	leaq	-112(%rbp), %rax
	movq	%rax, %rdi
	call	strlen@PLT
	addq	$1, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, %rdx
	movl	-852(%rbp), %eax
	cltq
	movq	%rdx, -624(%rbp,%rax,8)
	movl	-852(%rbp), %eax
	cltq
	movq	-624(%rbp,%rax,8), %rax
	leaq	-112(%rbp), %rdx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strcpy@PLT
	addl	$1, -852(%rbp)
.L2:
	movl	-856(%rbp), %eax
	cmpl	%eax, -852(%rbp)
	jl	.L3
	leaq	-224(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	leaq	-224(%rbp), %rax
	movq	%rax, %rdi
	call	strlen@PLT
	addq	$1, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, -840(%rbp)
	leaq	-224(%rbp), %rdx
	movq	-840(%rbp), %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strcpy@PLT
	movl	$0, -848(%rbp)
	movl	$0, -852(%rbp)
	jmp	.L4
.L8:
	movl	-852(%rbp), %eax
	cltq
	movq	-624(%rbp,%rax,8), %rax
	movq	-840(%rbp), %rdx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L5
	movl	-852(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -844(%rbp)
	jmp	.L6
.L7:
	movl	-844(%rbp), %eax
	cltq
	movl	-832(%rbp,%rax,4), %eax
	addl	%eax, -848(%rbp)
	addl	$1, -844(%rbp)
.L6:
	movl	-856(%rbp), %eax
	cmpl	%eax, -844(%rbp)
	jl	.L7
.L5:
	addl	$1, -852(%rbp)
.L4:
	movl	-856(%rbp), %eax
	cmpl	%eax, -852(%rbp)
	jl	.L8
	movl	-848(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L10
	call	__stack_chk_fail@PLT
.L10:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.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:
