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>
int main() {
  int n, i;
  double a[20], sum = 0;
  char s[4];
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%lf %s", &a[i], s);
    if(s[0] == 'B')
    a[i] = a[i] * 380000;
    sum = sum + a[i];
  }
  printf("%f\n", sum);
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC1:
	.string	"%d"
.LC2:
	.string	"%lf %s"
.LC4:
	.string	"%f\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	$192, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	pxor	%xmm0, %xmm0
	movsd	%xmm0, -184(%rbp)
	leaq	-192(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -188(%rbp)
	jmp	.L2
.L4:
	leaq	-176(%rbp), %rdx
	movl	-188(%rbp), %eax
	cltq
	salq	$3, %rax
	leaq	(%rdx,%rax), %rcx
	leaq	-12(%rbp), %rax
	movq	%rax, %rdx
	movq	%rcx, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movzbl	-12(%rbp), %eax
	cmpb	$66, %al
	jne	.L3
	movl	-188(%rbp), %eax
	cltq
	movsd	-176(%rbp,%rax,8), %xmm1
	movsd	.LC3(%rip), %xmm0
	mulsd	%xmm1, %xmm0
	movl	-188(%rbp), %eax
	cltq
	movsd	%xmm0, -176(%rbp,%rax,8)
.L3:
	movl	-188(%rbp), %eax
	cltq
	movsd	-176(%rbp,%rax,8), %xmm0
	movsd	-184(%rbp), %xmm1
	addsd	%xmm1, %xmm0
	movsd	%xmm0, -184(%rbp)
	addl	$1, -188(%rbp)
.L2:
	movl	-192(%rbp), %eax
	cmpl	%eax, -188(%rbp)
	jl	.L4
	movq	-184(%rbp), %rax
	movq	%rax, %xmm0
	leaq	.LC4(%rip), %rax
	movq	%rax, %rdi
	movl	$1, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L6
	call	__stack_chk_fail@PLT
.L6:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.section	.rodata
	.align 8
.LC3:
	.long	0
	.long	1092039040
	.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
.LC1:
	.string	"%d"
.LC2:
	.string	"%lf %s"
.LC4:
	.string	"%f\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	leaq	.LC1(%rip), %rdi
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	subq	$216, %rsp
	.cfi_def_cfa_offset 256
	movq	%fs:40, %rax
	movq	%rax, 200(%rsp)
	xorl	%eax, %eax
	leaq	28(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movl	28(%rsp), %eax
	testl	%eax, %eax
	jle	.L7
	leaq	32(%rsp), %rbx
	pxor	%xmm0, %xmm0
	xorl	%ebp, %ebp
	leaq	196(%rsp), %r13
	leaq	.LC2(%rip), %r12
	.p2align 4,,10
	.p2align 3
.L5:
	xorl	%eax, %eax
	movq	%r13, %rdx
	movq	%rbx, %rsi
	movq	%r12, %rdi
	movsd	%xmm0, 8(%rsp)
	call	__isoc99_scanf@PLT
	cmpb	$66, 196(%rsp)
	movsd	8(%rsp), %xmm0
	je	.L3
	addsd	(%rbx), %xmm0
	addl	$1, %ebp
	addq	$8, %rbx
	cmpl	28(%rsp), %ebp
	jl	.L5
.L2:
	leaq	.LC4(%rip), %rsi
	movl	$1, %edi
	movl	$1, %eax
	call	__printf_chk@PLT
	movq	200(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L10
	addq	$216, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L3:
	.cfi_restore_state
	movsd	.LC3(%rip), %xmm1
	mulsd	(%rbx), %xmm1
	addl	$1, %ebp
	addq	$8, %rbx
	movsd	%xmm1, -8(%rbx)
	addsd	%xmm1, %xmm0
	cmpl	%ebp, 28(%rsp)
	jg	.L5
	jmp	.L2
.L7:
	pxor	%xmm0, %xmm0
	jmp	.L2
.L10:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC3:
	.long	0
	.long	1092039040
	.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
.LC1:
	.string	"%d"
.LC2:
	.string	"%lf %s"
.LC4:
	.string	"%f\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	leaq	.LC1(%rip), %rdi
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	subq	$216, %rsp
	.cfi_def_cfa_offset 256
	movq	%fs:40, %rax
	movq	%rax, 200(%rsp)
	xorl	%eax, %eax
	leaq	28(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movl	28(%rsp), %eax
	testl	%eax, %eax
	jle	.L7
	leaq	32(%rsp), %rbx
	pxor	%xmm0, %xmm0
	xorl	%ebp, %ebp
	leaq	196(%rsp), %r13
	leaq	.LC2(%rip), %r12
	.p2align 4,,10
	.p2align 3
.L5:
	xorl	%eax, %eax
	movq	%r13, %rdx
	movq	%rbx, %rsi
	movq	%r12, %rdi
	movsd	%xmm0, 8(%rsp)
	call	__isoc99_scanf@PLT
	cmpb	$66, 196(%rsp)
	movsd	8(%rsp), %xmm0
	je	.L3
	addsd	(%rbx), %xmm0
	addl	$1, %ebp
	addq	$8, %rbx
	cmpl	28(%rsp), %ebp
	jl	.L5
.L2:
	leaq	.LC4(%rip), %rsi
	movl	$1, %edi
	movl	$1, %eax
	call	__printf_chk@PLT
	movq	200(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L10
	addq	$216, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L3:
	.cfi_restore_state
	movsd	.LC3(%rip), %xmm1
	mulsd	(%rbx), %xmm1
	addl	$1, %ebp
	addq	$8, %rbx
	movsd	%xmm1, -8(%rbx)
	addsd	%xmm1, %xmm0
	cmpl	%ebp, 28(%rsp)
	jg	.L5
	jmp	.L2
.L7:
	pxor	%xmm0, %xmm0
	jmp	.L2
.L10:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC3:
	.long	0
	.long	1092039040
	.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>
int main() {
  int n, i;
  double a[20], sum = 0;
  char s[4];
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%lf %s", &a[i], s);
    if(s[0] == 'B')
    a[i] = a[i] * 380000;
    sum = sum + a[i];
  }
  printf("%f\n", sum);
}

2
00000 JPY
0.10000000 BTC
 2
00000 JPY
0.7411383442474536 BTC
 2
10000 JPY
0.7411383442474536 BTC
 2
01000 JPY
0.10000000 BTC
 2
00010 JPY
0.7411383442474536 BTC
 2
10000 JPY
1.729349410778393 BTC
 2
10000 JPY
0.17314902569100102 BTC
 3
100000000 JPY
100.00000000 BTC
0.3694804465533971 BTC
 2
00000 JPY
0.10189738901396564 BTC
 2
00000 JPY
1.673334956965359 BTC

38000.000000
 281632.570814
 291632.570814
 39000.000000
 281642.570814
 667152.776096
 75796.629763
 138140402.569690
 38721.007825
 635867.283647

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>
int main() {
  int n, i;
  double a[20], sum = 0;
  char s[4];
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%lf %s", &a[i], s);
    if(s[0] == 'B')
    a[i] = a[i] * 380000;
    sum = sum + a[i];
  }
  printf("%f\n", sum);
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC1:
	.string	"%d"
.LC2:
	.string	"%lf %s"
.LC4:
	.string	"%f\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	$192, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	pxor	%xmm0, %xmm0
	movsd	%xmm0, -184(%rbp)
	leaq	-192(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -188(%rbp)
	jmp	.L2
.L4:
	leaq	-176(%rbp), %rdx
	movl	-188(%rbp), %eax
	cltq
	salq	$3, %rax
	leaq	(%rdx,%rax), %rcx
	leaq	-12(%rbp), %rax
	movq	%rax, %rdx
	movq	%rcx, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movzbl	-12(%rbp), %eax
	cmpb	$66, %al
	jne	.L3
	movl	-188(%rbp), %eax
	cltq
	movsd	-176(%rbp,%rax,8), %xmm1
	movsd	.LC3(%rip), %xmm0
	mulsd	%xmm1, %xmm0
	movl	-188(%rbp), %eax
	cltq
	movsd	%xmm0, -176(%rbp,%rax,8)
.L3:
	movl	-188(%rbp), %eax
	cltq
	movsd	-176(%rbp,%rax,8), %xmm0
	movsd	-184(%rbp), %xmm1
	addsd	%xmm1, %xmm0
	movsd	%xmm0, -184(%rbp)
	addl	$1, -188(%rbp)
.L2:
	movl	-192(%rbp), %eax
	cmpl	%eax, -188(%rbp)
	jl	.L4
	movq	-184(%rbp), %rax
	movq	%rax, %xmm0
	leaq	.LC4(%rip), %rax
	movq	%rax, %rdi
	movl	$1, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L6
	call	__stack_chk_fail@PLT
.L6:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.section	.rodata
	.align 8
.LC3:
	.long	0
	.long	1092039040
	.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
.LC1:
	.string	"%d"
.LC2:
	.string	"%lf %s"
.LC4:
	.string	"%f\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	$192, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	pxor	%xmm0, %xmm0
	movsd	%xmm0, -184(%rbp)
	leaq	-192(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -188(%rbp)
	jmp	.L2
.L4:
	leaq	-176(%rbp), %rdx
	movl	-188(%rbp), %eax
	cltq
	salq	$3, %rax
	leaq	(%rdx,%rax), %rcx
	leaq	-12(%rbp), %rax
	movq	%rax, %rdx
	movq	%rcx, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movzbl	-12(%rbp), %eax
	cmpb	$66, %al
	jne	.L3
	movl	-188(%rbp), %eax
	cltq
	movsd	-176(%rbp,%rax,8), %xmm1
	movsd	.LC3(%rip), %xmm0
	mulsd	%xmm1, %xmm0
	movl	-188(%rbp), %eax
	cltq
	movsd	%xmm0, -176(%rbp,%rax,8)
.L3:
	movl	-188(%rbp), %eax
	cltq
	movsd	-176(%rbp,%rax,8), %xmm0
	movsd	-184(%rbp), %xmm1
	addsd	%xmm1, %xmm0
	movsd	%xmm0, -184(%rbp)
	addl	$1, -188(%rbp)
.L2:
	movl	-192(%rbp), %eax
	cmpl	%eax, -188(%rbp)
	jl	.L4
	movq	-184(%rbp), %rax
	movq	%rax, %xmm0
	leaq	.LC4(%rip), %rax
	movq	%rax, %rdi
	movl	$1, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L6
	call	__stack_chk_fail@PLT
.L6:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.section	.rodata
	.align 8
.LC3:
	.long	0
	.long	1092039040
	.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:
