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,k,a,b,c,sum;
    char s[4];
    while(~scanf("%s",s))
    {
        sum=0;
        b=0;
        a=0;

        for(i=0; i<4; i++)
        {
            if(s[i]=='+')
            {
                a++;
            }
            if(s[i]=='-')
            {
                b--;
            }

        }
        sum=a+b;
        printf("%d\n",sum);
    }
    return 0;
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d\n"
.LC1:
	.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	$32, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	jmp	.L2
.L7:
	movl	$0, -16(%rbp)
	movl	$0, -20(%rbp)
	movl	$0, -24(%rbp)
	movl	$0, -28(%rbp)
	jmp	.L3
.L6:
	movl	-28(%rbp), %eax
	cltq
	movzbl	-12(%rbp,%rax), %eax
	cmpb	$43, %al
	jne	.L4
	addl	$1, -24(%rbp)
.L4:
	movl	-28(%rbp), %eax
	cltq
	movzbl	-12(%rbp,%rax), %eax
	cmpb	$45, %al
	jne	.L5
	subl	$1, -20(%rbp)
.L5:
	addl	$1, -28(%rbp)
.L3:
	cmpl	$3, -28(%rbp)
	jle	.L6
	movl	-24(%rbp), %edx
	movl	-20(%rbp), %eax
	addl	%edx, %eax
	movl	%eax, -16(%rbp)
	movl	-16(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L2:
	leaq	-12(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	cmpl	$-1, %eax
	jne	.L7
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L9
	call	__stack_chk_fail@PLT
.L9:
	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	"%s"
.LC1:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB51:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	leaq	.LC1(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	leaq	.LC0(%rip), %rbx
	subq	$16, %rsp
	.cfi_def_cfa_offset 48
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	leaq	4(%rsp), %rbp
	jmp	.L9
	.p2align 4,,10
	.p2align 3
.L17:
	cmpb	$45, %al
	movzbl	5(%rsp), %ecx
	movl	$1, %esi
	sete	%al
	xorl	%edx, %edx
	movzbl	%al, %eax
	negl	%eax
	cmpb	$43, %cl
	je	.L12
.L18:
	cmpb	$45, %cl
	sete	%cl
	movzbl	%cl, %ecx
	subl	%ecx, %eax
	movzbl	6(%rsp), %ecx
	cmpb	$43, %cl
	je	.L15
.L5:
	cmpb	$45, %cl
	sete	%cl
	movzbl	%cl, %ecx
	subl	%ecx, %eax
	movzbl	7(%rsp), %ecx
	cmpb	$43, %cl
	je	.L16
.L7:
	cmpb	$45, %cl
	sete	%cl
	movzbl	%cl, %ecx
	subl	%ecx, %eax
.L8:
	addl	%eax, %edx
	movq	%r12, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L9:
	xorl	%eax, %eax
	movq	%rbp, %rsi
	movq	%rbx, %rdi
	call	__isoc99_scanf@PLT
	cmpl	$-1, %eax
	je	.L2
	movzbl	4(%rsp), %eax
	cmpb	$43, %al
	jne	.L17
	movzbl	5(%rsp), %ecx
	movl	$2, %esi
	movl	$1, %edx
	xorl	%eax, %eax
	cmpb	$43, %cl
	jne	.L18
.L12:
	movzbl	6(%rsp), %ecx
	movl	%esi, %edx
	cmpb	$43, %cl
	jne	.L5
.L15:
	movzbl	7(%rsp), %ecx
	addl	$1, %edx
	cmpb	$43, %cl
	jne	.L7
.L16:
	addl	$1, %edx
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L2:
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L19
	addq	$16, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 32
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
.L19:
	.cfi_restore_state
	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	"%s"
.LC1:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB51:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	leaq	.LC1(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	leaq	.LC0(%rip), %rbx
	subq	$16, %rsp
	.cfi_def_cfa_offset 48
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	leaq	4(%rsp), %rbp
	jmp	.L9
	.p2align 4,,10
	.p2align 3
.L17:
	cmpb	$45, %al
	movzbl	5(%rsp), %ecx
	movl	$1, %esi
	sete	%al
	xorl	%edx, %edx
	movzbl	%al, %eax
	negl	%eax
	cmpb	$43, %cl
	je	.L12
.L18:
	cmpb	$45, %cl
	sete	%cl
	movzbl	%cl, %ecx
	subl	%ecx, %eax
	movzbl	6(%rsp), %ecx
	cmpb	$43, %cl
	je	.L15
.L5:
	cmpb	$45, %cl
	sete	%cl
	movzbl	%cl, %ecx
	subl	%ecx, %eax
	movzbl	7(%rsp), %ecx
	cmpb	$43, %cl
	je	.L16
.L7:
	cmpb	$45, %cl
	sete	%cl
	movzbl	%cl, %ecx
	subl	%ecx, %eax
.L8:
	addl	%eax, %edx
	movq	%r12, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L9:
	xorl	%eax, %eax
	movq	%rbp, %rsi
	movq	%rbx, %rdi
	call	__isoc99_scanf@PLT
	cmpl	$-1, %eax
	je	.L2
	movzbl	4(%rsp), %eax
	cmpb	$43, %al
	jne	.L17
	movzbl	5(%rsp), %ecx
	movl	$2, %esi
	movl	$1, %edx
	xorl	%eax, %eax
	cmpb	$43, %cl
	jne	.L18
.L12:
	movzbl	6(%rsp), %ecx
	movl	%esi, %edx
	cmpb	$43, %cl
	jne	.L5
.L15:
	movzbl	7(%rsp), %ecx
	addl	$1, %edx
	cmpb	$43, %cl
	jne	.L7
.L16:
	addl	$1, %edx
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L2:
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L19
	addq	$16, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 32
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
.L19:
	.cfi_restore_state
	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,k,a,b,c,sum;
    char s[4];
    while(~scanf("%s",s))
    {
        sum=0;
        b=0;
        a=0;

        for(i=0; i<4; i++)
        {
            if(s[i]=='+')
            {
                a++;
            }
            if(s[i]=='-')
            {
                b--;
            }

        }
        sum=a+b;
        printf("%d\n",sum);
    }
    return 0;
}

--+-
 ++-+
 ++++
 -+-+
 ---+
 +---
 -+++
 +++-
 ++--
 +--+

-2
 2
 4
 0
 -2
 -2
 2
 2
 0
 0

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,k,a,b,c,sum;
    char s[4];
    while(~scanf("%s",s))
    {
        sum=0;
        b=0;
        a=0;

        for(i=0; i<4; i++)
        {
            if(s[i]=='+')
            {
                a++;
            }
            if(s[i]=='-')
            {
                b--;
            }

        }
        sum=a+b;
        printf("%d\n",sum);
    }
    return 0;
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d\n"
.LC1:
	.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	$32, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	jmp	.L2
.L7:
	movl	$0, -16(%rbp)
	movl	$0, -20(%rbp)
	movl	$0, -24(%rbp)
	movl	$0, -28(%rbp)
	jmp	.L3
.L6:
	movl	-28(%rbp), %eax
	cltq
	movzbl	-12(%rbp,%rax), %eax
	cmpb	$43, %al
	jne	.L4
	addl	$1, -24(%rbp)
.L4:
	movl	-28(%rbp), %eax
	cltq
	movzbl	-12(%rbp,%rax), %eax
	cmpb	$45, %al
	jne	.L5
	subl	$1, -20(%rbp)
.L5:
	addl	$1, -28(%rbp)
.L3:
	cmpl	$3, -28(%rbp)
	jle	.L6
	movl	-24(%rbp), %edx
	movl	-20(%rbp), %eax
	addl	%edx, %eax
	movl	%eax, -16(%rbp)
	movl	-16(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L2:
	leaq	-12(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	cmpl	$-1, %eax
	jne	.L7
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L9
	call	__stack_chk_fail@PLT
.L9:
	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\n"
.LC1:
	.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	$32, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	jmp	.L2
.L7:
	movl	$0, -16(%rbp)
	movl	$0, -20(%rbp)
	movl	$0, -24(%rbp)
	movl	$0, -28(%rbp)
	jmp	.L3
.L6:
	movl	-28(%rbp), %eax
	cltq
	movzbl	-12(%rbp,%rax), %eax
	cmpb	$43, %al
	jne	.L4
	addl	$1, -24(%rbp)
.L4:
	movl	-28(%rbp), %eax
	cltq
	movzbl	-12(%rbp,%rax), %eax
	cmpb	$45, %al
	jne	.L5
	subl	$1, -20(%rbp)
.L5:
	addl	$1, -28(%rbp)
.L3:
	cmpl	$3, -28(%rbp)
	jle	.L6
	movl	-24(%rbp), %edx
	movl	-20(%rbp), %eax
	addl	%edx, %eax
	movl	%eax, -16(%rbp)
	movl	-16(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L2:
	leaq	-12(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	cmpl	$-1, %eax
	jne	.L7
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L9
	call	__stack_chk_fail@PLT
.L9:
	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:
