Given the following C code and assembly code, your task is to generate highly optimized x86-64 assembly code.
C Code:

```c
#include <stdio.h>

int main(void){
	char num[1000];
	int total=0,count=0,i;
	while(1){
		scanf("%s",num);
		if(num[0]=='0') break;
		while(num[count]!='\0'){
			count++;
		}
		for(i=0;i<count;i++){
			total+=num[i]-'0';
		}
		printf("%d\n",total);
		total=0;
		count=0;
	}
	return 0;
}```

Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%s"
.LC2:
	.string	"%d\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
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	leaq	.LC2(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	leaq	.LC0(%rip), %rbx
	subq	$1016, %rsp
	.cfi_def_cfa_offset 1056
	movq	%fs:40, %rax
	movq	%rax, 1000(%rsp)
	xorl	%eax, %eax
	movq	%rsp, %r13
	leaq	16(%rsp), %r12
	.p2align 4,,10
	.p2align 3
.L8:
	movq	%r13, %rsi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movzbl	(%rsp), %eax
	cmpb	$48, %al
	je	.L2
	testb	%al, %al
	movdqa	.LC1(%rip), %xmm4
	je	.L10
	xorl	%eax, %eax
	.p2align 4,,10
	.p2align 3
.L4:
	movl	%eax, %ecx
	addq	$1, %rax
	cmpb	$0, 0(%r13,%rax)
	jne	.L4
	leal	1(%rcx), %esi
	cmpl	$14, %ecx
	jbe	.L11
	movl	%esi, %edx
	pxor	%xmm1, %xmm1
	pxor	%xmm6, %xmm6
	movq	%r13, %rax
	shrl	$4, %edx
	pxor	%xmm5, %xmm5
	subl	$1, %edx
	salq	$4, %rdx
	addq	%r12, %rdx
	.p2align 4,,10
	.p2align 3
.L6:
	movdqa	(%rax), %xmm0
	movdqa	%xmm6, %xmm3
	addq	$16, %rax
	pcmpgtb	%xmm0, %xmm3
	movdqa	%xmm0, %xmm2
	punpcklbw	%xmm3, %xmm2
	punpckhbw	%xmm3, %xmm0
	movdqa	%xmm5, %xmm3
	paddw	%xmm4, %xmm2
	paddw	%xmm4, %xmm0
	pcmpgtw	%xmm2, %xmm3
	movdqa	%xmm2, %xmm7
	punpcklwd	%xmm3, %xmm7
	punpckhwd	%xmm3, %xmm2
	movdqa	%xmm0, %xmm3
	paddd	%xmm7, %xmm1
	paddd	%xmm2, %xmm1
	movdqa	%xmm5, %xmm2
	pcmpgtw	%xmm0, %xmm2
	punpcklwd	%xmm2, %xmm3
	punpckhwd	%xmm2, %xmm0
	paddd	%xmm3, %xmm1
	paddd	%xmm0, %xmm1
	cmpq	%rdx, %rax
	jne	.L6
	movdqa	%xmm1, %xmm0
	movl	%esi, %eax
	psrldq	$8, %xmm0
	andl	$-16, %eax
	andl	$15, %esi
	paddd	%xmm0, %xmm1
	movdqa	%xmm1, %xmm0
	psrldq	$4, %xmm0
	paddd	%xmm0, %xmm1
	movd	%xmm1, %edx
	je	.L3
.L5:
	movslq	%eax, %rsi
	movsbl	(%rsp,%rsi), %esi
	leal	-48(%rdx,%rsi), %edx
	leal	1(%rax), %esi
	cmpl	%eax, %ecx
	jle	.L3
	movslq	%esi, %rdi
	movsbl	(%rsp,%rdi), %edi
	leal	-48(%rdx,%rdi), %edx
	leal	2(%rax), %edi
	cmpl	%ecx, %esi
	jge	.L3
	movslq	%edi, %rsi
	movsbl	(%rsp,%rsi), %esi
	leal	-48(%rdx,%rsi), %edx
	leal	3(%rax), %esi
	cmpl	%edi, %ecx
	jle	.L3
	movslq	%esi, %rdi
	movsbl	(%rsp,%rdi), %edi
	leal	-48(%rdx,%rdi), %edx
	leal	4(%rax), %edi
	cmpl	%ecx, %esi
	jge	.L3
	movslq	%edi, %rsi
	movsbl	(%rsp,%rsi), %esi
	leal	-48(%rdx,%rsi), %edx
	leal	5(%rax), %esi
	cmpl	%edi, %ecx
	jle	.L3
	movslq	%esi, %rdi
	movsbl	(%rsp,%rdi), %edi
	leal	-48(%rdx,%rdi), %edx
	leal	6(%rax), %edi
	cmpl	%esi, %ecx
	jle	.L3
	movslq	%edi, %rsi
	movsbl	(%rsp,%rsi), %esi
	leal	-48(%rdx,%rsi), %edx
	leal	7(%rax), %esi
	cmpl	%edi, %ecx
	jle	.L3
	movslq	%esi, %rdi
	movsbl	(%rsp,%rdi), %edi
	leal	-48(%rdx,%rdi), %edx
	leal	8(%rax), %edi
	cmpl	%esi, %ecx
	jle	.L3
	movslq	%edi, %rsi
	movsbl	(%rsp,%rsi), %esi
	leal	-48(%rdx,%rsi), %edx
	leal	9(%rax), %esi
	cmpl	%edi, %ecx
	jle	.L3
	movslq	%esi, %rdi
	movsbl	(%rsp,%rdi), %edi
	leal	-48(%rdx,%rdi), %edx
	leal	10(%rax), %edi
	cmpl	%esi, %ecx
	jle	.L3
	movslq	%edi, %rsi
	movsbl	(%rsp,%rsi), %esi
	leal	-48(%rdx,%rsi), %edx
	leal	11(%rax), %esi
	cmpl	%edi, %ecx
	jle	.L3
	movslq	%esi, %rdi
	movsbl	(%rsp,%rdi), %edi
	leal	-48(%rdx,%rdi), %edx
	leal	12(%rax), %edi
	cmpl	%esi, %ecx
	jle	.L3
	movslq	%edi, %rsi
	movsbl	(%rsp,%rsi), %esi
	leal	-48(%rdx,%rsi), %edx
	leal	13(%rax), %esi
	cmpl	%edi, %ecx
	jle	.L3
	movslq	%esi, %rdi
	addl	$14, %eax
	movsbl	(%rsp,%rdi), %edi
	leal	-48(%rdx,%rdi), %edx
	cmpl	%esi, %ecx
	jle	.L3
	cltq
	movsbl	(%rsp,%rax), %eax
	leal	-48(%rdx,%rax), %edx
	.p2align 4,,10
	.p2align 3
.L3:
	movq	%rbp, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L2:
	movq	1000(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L16
	addq	$1016, %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
.L10:
	.cfi_restore_state
	xorl	%edx, %edx
	jmp	.L3
.L11:
	xorl	%eax, %eax
	xorl	%edx, %edx
	jmp	.L5
.L16:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC1:
	.value	-48
	.value	-48
	.value	-48
	.value	-48
	.value	-48
	.value	-48
	.value	-48
	.value	-48
	.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.
Optimized Assembly Code:

user
```assembly
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%s"
.LC2:
	.string	"%d\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
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	leaq	.LC2(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	leaq	.LC0(%rip), %rbx
	subq	$1016, %rsp
	.cfi_def_cfa_offset 1056
	movq	%fs:40, %rax
	movq	%rax, 1000(%rsp)
	xorl	%eax, %eax
	movq	%rsp, %r13
	leaq	16(%rsp), %r12
	.p2align 4,,10
	.p2align 3
.L8:
	movq	%r13, %rsi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movzbl	(%rsp), %eax
	cmpb	$48, %al
	je	.L2
	testb	%al, %al
	movdqa	.LC1(%rip), %xmm4
	je	.L10
	xorl	%eax, %eax
	.p2align 4,,10
	.p2align 3
.L4:
	movl	%eax, %ecx
	addq	$1, %rax
	cmpb	$0, 0(%r13,%rax)
	jne	.L4
	leal	1(%rcx), %esi
	cmpl	$14, %ecx
	jbe	.L11
	movl	%esi, %edx
	pxor	%xmm1, %xmm1
	pxor	%xmm6, %xmm6
	movq	%r13, %rax
	shrl	$4, %edx
	pxor	%xmm5, %xmm5
	subl	$1, %edx
	salq	$4, %rdx
	addq	%r12, %rdx
	.p2align 4,,10
	.p2align 3
.L6:
	movdqa	(%rax), %xmm0
	movdqa	%xmm6, %xmm3
	addq	$16, %rax
	pcmpgtb	%xmm0, %xmm3
	movdqa	%xmm0, %xmm2
	punpcklbw	%xmm3, %xmm2
	punpckhbw	%xmm3, %xmm0
	movdqa	%xmm5, %xmm3
	paddw	%xmm4, %xmm2
	paddw	%xmm4, %xmm0
	pcmpgtw	%xmm2, %xmm3
	movdqa	%xmm2, %xmm7
	punpcklwd	%xmm3, %xmm7
	punpckhwd	%xmm3, %xmm2
	movdqa	%xmm0, %xmm3
	paddd	%xmm7, %xmm1
	paddd	%xmm2, %xmm1
	movdqa	%xmm5, %xmm2
	pcmpgtw	%xmm0, %xmm2
	punpcklwd	%xmm2, %xmm3
	punpckhwd	%xmm2, %xmm0
	paddd	%xmm3, %xmm1
	paddd	%xmm0, %xmm1
	cmpq	%rdx, %rax
	jne	.L6
	movdqa	%xmm1, %xmm0
	movl	%esi, %eax
	psrldq	$8, %xmm0
	andl	$-16, %eax
	andl	$15, %esi
	paddd	%xmm0, %xmm1
	movdqa	%xmm1, %xmm0
	psrldq	$4, %xmm0
	paddd	%xmm0, %xmm1
	movd	%xmm1, %edx
	je	.L3
.L5:
	movslq	%eax, %rsi
	movsbl	(%rsp,%rsi), %esi
	leal	-48(%rdx,%rsi), %edx
	leal	1(%rax), %esi
	cmpl	%eax, %ecx
	jle	.L3
	movslq	%esi, %rdi
	movsbl	(%rsp,%rdi), %edi
	leal	-48(%rdx,%rdi), %edx
	leal	2(%rax), %edi
	cmpl	%ecx, %esi
	jge	.L3
	movslq	%edi, %rsi
	movsbl	(%rsp,%rsi), %esi
	leal	-48(%rdx,%rsi), %edx
	leal	3(%rax), %esi
	cmpl	%edi, %ecx
	jle	.L3
	movslq	%esi, %rdi
	movsbl	(%rsp,%rdi), %edi
	leal	-48(%rdx,%rdi), %edx
	leal	4(%rax), %edi
	cmpl	%ecx, %esi
	jge	.L3
	movslq	%edi, %rsi
	movsbl	(%rsp,%rsi), %esi
	leal	-48(%rdx,%rsi), %edx
	leal	5(%rax), %esi
	cmpl	%edi, %ecx
	jle	.L3
	movslq	%esi, %rdi
	movsbl	(%rsp,%rdi), %edi
	leal	-48(%rdx,%rdi), %edx
	leal	6(%rax), %edi
	cmpl	%esi, %ecx
	jle	.L3
	movslq	%edi, %rsi
	movsbl	(%rsp,%rsi), %esi
	leal	-48(%rdx,%rsi), %edx
	leal	7(%rax), %esi
	cmpl	%edi, %ecx
	jle	.L3
	movslq	%esi, %rdi
	movsbl	(%rsp,%rdi), %edi
	leal	-48(%rdx,%rdi), %edx
	leal	8(%rax), %edi
	cmpl	%esi, %ecx
	jle	.L3
	movslq	%edi, %rsi
	movsbl	(%rsp,%rsi), %esi
	leal	-48(%rdx,%rsi), %edx
	leal	9(%rax), %esi
	cmpl	%edi, %ecx
	jle	.L3
	movslq	%esi, %rdi
	movsbl	(%rsp,%rdi), %edi
	leal	-48(%rdx,%rdi), %edx
	leal	10(%rax), %edi
	cmpl	%esi, %ecx
	jle	.L3
	movslq	%edi, %rsi
	movsbl	(%rsp,%rsi), %esi
	leal	-48(%rdx,%rsi), %edx
	leal	11(%rax), %esi
	cmpl	%edi, %ecx
	jle	.L3
	movslq	%esi, %rdi
	movsbl	(%rsp,%rdi), %edi
	leal	-48(%rdx,%rdi), %edx
	leal	12(%rax), %edi
	cmpl	%esi, %ecx
	jle	.L3
	movslq	%edi, %rsi
	movsbl	(%rsp,%rsi), %esi
	leal	-48(%rdx,%rsi), %edx
	leal	13(%rax), %esi
	cmpl	%edi, %ecx
	jle	.L3
	movslq	%esi, %rdi
	addl	$14, %eax
	movsbl	(%rsp,%rdi), %edi
	leal	-48(%rdx,%rdi), %edx
	cmpl	%esi, %ecx
	jle	.L3
	cltq
	movsbl	(%rsp,%rax), %eax
	leal	-48(%rdx,%rax), %edx
	.p2align 4,,10
	.p2align 3
.L3:
	movq	%rbp, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L2:
	movq	1000(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L16
	addq	$1016, %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
.L10:
	.cfi_restore_state
	xorl	%edx, %edx
	jmp	.L3
.L11:
	xorl	%eax, %eax
	xorl	%edx, %edx
	jmp	.L5
.L16:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC1:
	.value	-48
	.value	-48
	.value	-48
	.value	-48
	.value	-48
	.value	-48
	.value	-48
	.value	-48
	.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
```assembly
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%s"
.LC2:
	.string	"%d\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
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	leaq	.LC2(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	leaq	.LC0(%rip), %rbx
	subq	$1016, %rsp
	.cfi_def_cfa_offset 1056
	movq	%fs:40, %rax
	movq	%rax, 1000(%rsp)
	xorl	%eax, %eax
	movq	%rsp, %r13
	leaq	16(%rsp), %r12
	.p2align 4,,10
	.p2align 3
.L8:
	movq	%r13, %rsi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movzbl	(%rsp), %eax
	cmpb	$48, %al
	je	.L2
	testb	%al, %al
	movdqa	.LC1(%rip), %xmm4
	je	.L10
	xorl	%eax, %eax
	.p2align 4,,10
	.p2align 3
.L4:
	movl	%eax, %ecx
	addq	$1, %rax
	cmpb	$0, 0(%r13,%rax)
	jne	.L4
	leal	1(%rcx), %esi
	cmpl	$14, %ecx
	jbe	.L11
	movl	%esi, %edx
	pxor	%xmm1, %xmm1
	pxor	%xmm6, %xmm6
	movq	%r13, %rax
	shrl	$4, %edx
	pxor	%xmm5, %xmm5
	subl	$1, %edx
	salq	$4, %rdx
	addq	%r12, %rdx
	.p2align 4,,10
	.p2align 3
.L6:
	movdqa	(%rax), %xmm0
	movdqa	%xmm6, %xmm3
	addq	$16, %rax
	pcmpgtb	%xmm0, %xmm3
	movdqa	%xmm0, %xmm2
	punpcklbw	%xmm3, %xmm2
	punpckhbw	%xmm3, %xmm0
	movdqa	%xmm5, %xmm3
	paddw	%xmm4, %xmm2
	paddw	%xmm4, %xmm0
	pcmpgtw	%xmm2, %xmm3
	movdqa	%xmm2, %xmm7
	punpcklwd	%xmm3, %xmm7
	punpckhwd	%xmm3, %xmm2
	movdqa	%xmm0, %xmm3
	paddd	%xmm7, %xmm1
	paddd	%xmm2, %xmm1
	movdqa	%xmm5, %xmm2
	pcmpgtw	%xmm0, %xmm2
	punpcklwd	%xmm2, %xmm3
	punpckhwd	%xmm2, %xmm0
	paddd	%xmm3, %xmm1
	paddd	%xmm0, %xmm1
	cmpq	%rdx, %rax
	jne	.L6
	movdqa	%xmm1, %xmm0
	movl	%esi, %eax
	psrldq	$8, %xmm0
	andl	$-16, %eax
	andl	$15, %esi
	paddd	%xmm0, %xmm1
	movdqa	%xmm1, %xmm0
	psrldq	$4, %xmm0
	paddd	%xmm0, %xmm1
	movd	%xmm1, %edx
	je	.L3
.L5:
	movslq	%eax, %rsi
	movsbl	(%rsp,%rsi), %esi
	leal	-48(%rdx,%rsi), %edx
	leal	1(%rax), %esi
	cmpl	%eax, %ecx
	jle	.L3
	movslq	%esi, %rdi
	movsbl	(%rsp,%rdi), %edi
	leal	-48(%rdx,%rdi), %edx
	leal	2(%rax), %edi
	cmpl	%ecx, %esi
	jge	.L3
	movslq	%edi, %rsi
	movsbl	(%rsp,%rsi), %esi
	leal	-48(%rdx,%rsi), %edx
	leal	3(%rax), %esi
	cmpl	%edi, %ecx
	jle	.L3
	movslq	%esi, %rdi
	movsbl	(%rsp,%rdi), %edi
	leal	-48(%rdx,%rdi), %edx
	leal	4(%rax), %edi
	cmpl	%ecx, %esi
	jge	.L3
	movslq	%edi, %rsi
	movsbl	(%rsp,%rsi), %esi
	leal	-48(%rdx,%rsi), %edx
	leal	5(%rax), %esi
	cmpl	%edi, %ecx
	jle	.L3
	movslq	%esi, %rdi
	movsbl	(%rsp,%rdi), %edi
	leal	-48(%rdx,%rdi), %edx
	leal	6(%rax), %edi
	cmpl	%esi, %ecx
	jle	.L3
	movslq	%edi, %rsi
	movsbl	(%rsp,%rsi), %esi
	leal	-48(%rdx,%rsi), %edx
	leal	7(%rax), %esi
	cmpl	%edi, %ecx
	jle	.L3
	movslq	%esi, %rdi
	movsbl	(%rsp,%rdi), %edi
	leal	-48(%rdx,%rdi), %edx
	leal	8(%rax), %edi
	cmpl	%esi, %ecx
	jle	.L3
	movslq	%edi, %rsi
	movsbl	(%rsp,%rsi), %esi
	leal	-48(%rdx,%rsi), %edx
	leal	9(%rax), %esi
	cmpl	%edi, %ecx
	jle	.L3
	movslq	%esi, %rdi
	movsbl	(%rsp,%rdi), %edi
	leal	-48(%rdx,%rdi), %edx
	leal	10(%rax), %edi
	cmpl	%esi, %ecx
	jle	.L3
	movslq	%edi, %rsi
	movsbl	(%rsp,%rsi), %esi
	leal	-48(%rdx,%rsi), %edx
	leal	11(%rax), %esi
	cmpl	%edi, %ecx
	jle	.L3
	movslq	%esi, %rdi
	movsbl	(%rsp,%rdi), %edi
	leal	-48(%rdx,%rdi), %edx
	leal	12(%rax), %edi
	cmpl	%esi, %ecx
	jle	.L3
	movslq	%edi, %rsi
	movsbl	(%rsp,%rsi), %esi
	leal	-48(%rdx,%rsi), %edx
	leal	13(%rax), %esi
	cmpl	%edi, %ecx
	jle	.L3
	movslq	%esi, %rdi
	addl	$14, %eax
	movsbl	(%rsp,%rdi), %edi
	leal	-48(%rdx,%rdi), %edx
	cmpl	%esi, %ecx
	jle	.L3
	cltq
	movsbl	(%rsp,%rax), %eax
	leal	-48(%rdx,%rax), %edx
	.p2align 4,,10
	.p2align 3
.L3:
	movq	%rbp, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L2:
	movq	1000(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L16
	addq	$1016, %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
.L10:
	.cfi_restore_state
	xorl	%edx, %edx
	jmp	.L3
.L11:
	xorl	%eax, %eax
	xorl	%edx, %edx
	jmp	.L5
.L16:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC1:
	.value	-48
	.value	-48
	.value	-48
	.value	-48
	.value	-48
	.value	-48
	.value	-48
	.value	-48
	.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:
```
```c
#include <stdio.h>

int main(void){
	char num[1000];
	int total=0,count=0,i;
	while(1){
		scanf("%s",num);
		if(num[0]=='0') break;
		while(num[count]!='\0'){
			count++;
		}
		for(i=0;i<count;i++){
			total+=num[i]-'0';
		}
		printf("%d\n",total);
		total=0;
		count=0;
	}
	return 0;
}```
Given the following C code, your task is to generate highly optimized x86-64 assembly code.
C Code:

```c
#include <stdio.h>

int main(void){
	char num[1000];
	int total=0,count=0,i;
	while(1){
		scanf("%s",num);
		if(num[0]=='0') break;
		while(num[count]!='\0'){
			count++;
		}
		for(i=0;i<count;i++){
			total+=num[i]-'0';
		}
		printf("%d\n",total);
		total=0;
		count=0;
	}
	return 0;
}```

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.
Optimized Assembly Code:

123
55
1001
0
 123
69
1000
0
 123
69
1010
0
 123
69
1110
0
 123
55
0001
0
 123
55
1101
0
 123
69
1111
0
 123
23
1001
0
 123
65
0001
0
 123
151
1101
0

6
10
2
 6
15
1
 6
15
2
 6
15
3
 6
10
 6
10
3
 6
15
4
 6
5
2
 6
11
 6
7
3

Given the following C code and assembly code, your task is to generate highly optimized x86-64 assembly code.
C Code:

```c
#include <stdio.h>

int main(void){
	char num[1000];
	int total=0,count=0,i;
	while(1){
		scanf("%s",num);
		if(num[0]=='0') break;
		while(num[count]!='\0'){
			count++;
		}
		for(i=0;i<count;i++){
			total+=num[i]-'0';
		}
		printf("%d\n",total);
		total=0;
		count=0;
	}
	return 0;
}```

Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%s"
.LC2:
	.string	"%d\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
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	leaq	.LC2(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	leaq	.LC0(%rip), %rbx
	subq	$1016, %rsp
	.cfi_def_cfa_offset 1056
	movq	%fs:40, %rax
	movq	%rax, 1000(%rsp)
	xorl	%eax, %eax
	movq	%rsp, %r13
	leaq	16(%rsp), %r12
	.p2align 4,,10
	.p2align 3
.L8:
	movq	%r13, %rsi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movzbl	(%rsp), %eax
	cmpb	$48, %al
	je	.L2
	testb	%al, %al
	movdqa	.LC1(%rip), %xmm4
	je	.L10
	xorl	%eax, %eax
	.p2align 4,,10
	.p2align 3
.L4:
	movl	%eax, %ecx
	addq	$1, %rax
	cmpb	$0, 0(%r13,%rax)
	jne	.L4
	leal	1(%rcx), %esi
	cmpl	$14, %ecx
	jbe	.L11
	movl	%esi, %edx
	pxor	%xmm1, %xmm1
	pxor	%xmm6, %xmm6
	movq	%r13, %rax
	shrl	$4, %edx
	pxor	%xmm5, %xmm5
	subl	$1, %edx
	salq	$4, %rdx
	addq	%r12, %rdx
	.p2align 4,,10
	.p2align 3
.L6:
	movdqa	(%rax), %xmm0
	movdqa	%xmm6, %xmm3
	addq	$16, %rax
	pcmpgtb	%xmm0, %xmm3
	movdqa	%xmm0, %xmm2
	punpcklbw	%xmm3, %xmm2
	punpckhbw	%xmm3, %xmm0
	movdqa	%xmm5, %xmm3
	paddw	%xmm4, %xmm2
	paddw	%xmm4, %xmm0
	pcmpgtw	%xmm2, %xmm3
	movdqa	%xmm2, %xmm7
	punpcklwd	%xmm3, %xmm7
	punpckhwd	%xmm3, %xmm2
	movdqa	%xmm0, %xmm3
	paddd	%xmm7, %xmm1
	paddd	%xmm2, %xmm1
	movdqa	%xmm5, %xmm2
	pcmpgtw	%xmm0, %xmm2
	punpcklwd	%xmm2, %xmm3
	punpckhwd	%xmm2, %xmm0
	paddd	%xmm3, %xmm1
	paddd	%xmm0, %xmm1
	cmpq	%rdx, %rax
	jne	.L6
	movdqa	%xmm1, %xmm0
	movl	%esi, %eax
	psrldq	$8, %xmm0
	andl	$-16, %eax
	andl	$15, %esi
	paddd	%xmm0, %xmm1
	movdqa	%xmm1, %xmm0
	psrldq	$4, %xmm0
	paddd	%xmm0, %xmm1
	movd	%xmm1, %edx
	je	.L3
.L5:
	movslq	%eax, %rsi
	movsbl	(%rsp,%rsi), %esi
	leal	-48(%rdx,%rsi), %edx
	leal	1(%rax), %esi
	cmpl	%eax, %ecx
	jle	.L3
	movslq	%esi, %rdi
	movsbl	(%rsp,%rdi), %edi
	leal	-48(%rdx,%rdi), %edx
	leal	2(%rax), %edi
	cmpl	%ecx, %esi
	jge	.L3
	movslq	%edi, %rsi
	movsbl	(%rsp,%rsi), %esi
	leal	-48(%rdx,%rsi), %edx
	leal	3(%rax), %esi
	cmpl	%edi, %ecx
	jle	.L3
	movslq	%esi, %rdi
	movsbl	(%rsp,%rdi), %edi
	leal	-48(%rdx,%rdi), %edx
	leal	4(%rax), %edi
	cmpl	%ecx, %esi
	jge	.L3
	movslq	%edi, %rsi
	movsbl	(%rsp,%rsi), %esi
	leal	-48(%rdx,%rsi), %edx
	leal	5(%rax), %esi
	cmpl	%edi, %ecx
	jle	.L3
	movslq	%esi, %rdi
	movsbl	(%rsp,%rdi), %edi
	leal	-48(%rdx,%rdi), %edx
	leal	6(%rax), %edi
	cmpl	%esi, %ecx
	jle	.L3
	movslq	%edi, %rsi
	movsbl	(%rsp,%rsi), %esi
	leal	-48(%rdx,%rsi), %edx
	leal	7(%rax), %esi
	cmpl	%edi, %ecx
	jle	.L3
	movslq	%esi, %rdi
	movsbl	(%rsp,%rdi), %edi
	leal	-48(%rdx,%rdi), %edx
	leal	8(%rax), %edi
	cmpl	%esi, %ecx
	jle	.L3
	movslq	%edi, %rsi
	movsbl	(%rsp,%rsi), %esi
	leal	-48(%rdx,%rsi), %edx
	leal	9(%rax), %esi
	cmpl	%edi, %ecx
	jle	.L3
	movslq	%esi, %rdi
	movsbl	(%rsp,%rdi), %edi
	leal	-48(%rdx,%rdi), %edx
	leal	10(%rax), %edi
	cmpl	%esi, %ecx
	jle	.L3
	movslq	%edi, %rsi
	movsbl	(%rsp,%rsi), %esi
	leal	-48(%rdx,%rsi), %edx
	leal	11(%rax), %esi
	cmpl	%edi, %ecx
	jle	.L3
	movslq	%esi, %rdi
	movsbl	(%rsp,%rdi), %edi
	leal	-48(%rdx,%rdi), %edx
	leal	12(%rax), %edi
	cmpl	%esi, %ecx
	jle	.L3
	movslq	%edi, %rsi
	movsbl	(%rsp,%rsi), %esi
	leal	-48(%rdx,%rsi), %edx
	leal	13(%rax), %esi
	cmpl	%edi, %ecx
	jle	.L3
	movslq	%esi, %rdi
	addl	$14, %eax
	movsbl	(%rsp,%rdi), %edi
	leal	-48(%rdx,%rdi), %edx
	cmpl	%esi, %ecx
	jle	.L3
	cltq
	movsbl	(%rsp,%rax), %eax
	leal	-48(%rdx,%rax), %edx
	.p2align 4,,10
	.p2align 3
.L3:
	movq	%rbp, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L2:
	movq	1000(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L16
	addq	$1016, %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
.L10:
	.cfi_restore_state
	xorl	%edx, %edx
	jmp	.L3
.L11:
	xorl	%eax, %eax
	xorl	%edx, %edx
	jmp	.L5
.L16:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC1:
	.value	-48
	.value	-48
	.value	-48
	.value	-48
	.value	-48
	.value	-48
	.value	-48
	.value	-48
	.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.
Optimized Assembly Code:

train
```assembly
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%s"
.LC2:
	.string	"%d\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
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	leaq	.LC2(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	leaq	.LC0(%rip), %rbx
	subq	$1016, %rsp
	.cfi_def_cfa_offset 1056
	movq	%fs:40, %rax
	movq	%rax, 1000(%rsp)
	xorl	%eax, %eax
	movq	%rsp, %r13
	leaq	16(%rsp), %r12
	.p2align 4,,10
	.p2align 3
.L8:
	movq	%r13, %rsi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movzbl	(%rsp), %eax
	cmpb	$48, %al
	je	.L2
	testb	%al, %al
	movdqa	.LC1(%rip), %xmm4
	je	.L10
	xorl	%eax, %eax
	.p2align 4,,10
	.p2align 3
.L4:
	movl	%eax, %ecx
	addq	$1, %rax
	cmpb	$0, 0(%r13,%rax)
	jne	.L4
	leal	1(%rcx), %esi
	cmpl	$14, %ecx
	jbe	.L11
	movl	%esi, %edx
	pxor	%xmm1, %xmm1
	pxor	%xmm6, %xmm6
	movq	%r13, %rax
	shrl	$4, %edx
	pxor	%xmm5, %xmm5
	subl	$1, %edx
	salq	$4, %rdx
	addq	%r12, %rdx
	.p2align 4,,10
	.p2align 3
.L6:
	movdqa	(%rax), %xmm0
	movdqa	%xmm6, %xmm3
	addq	$16, %rax
	pcmpgtb	%xmm0, %xmm3
	movdqa	%xmm0, %xmm2
	punpcklbw	%xmm3, %xmm2
	punpckhbw	%xmm3, %xmm0
	movdqa	%xmm5, %xmm3
	paddw	%xmm4, %xmm2
	paddw	%xmm4, %xmm0
	pcmpgtw	%xmm2, %xmm3
	movdqa	%xmm2, %xmm7
	punpcklwd	%xmm3, %xmm7
	punpckhwd	%xmm3, %xmm2
	movdqa	%xmm0, %xmm3
	paddd	%xmm7, %xmm1
	paddd	%xmm2, %xmm1
	movdqa	%xmm5, %xmm2
	pcmpgtw	%xmm0, %xmm2
	punpcklwd	%xmm2, %xmm3
	punpckhwd	%xmm2, %xmm0
	paddd	%xmm3, %xmm1
	paddd	%xmm0, %xmm1
	cmpq	%rdx, %rax
	jne	.L6
	movdqa	%xmm1, %xmm0
	movl	%esi, %eax
	psrldq	$8, %xmm0
	andl	$-16, %eax
	andl	$15, %esi
	paddd	%xmm0, %xmm1
	movdqa	%xmm1, %xmm0
	psrldq	$4, %xmm0
	paddd	%xmm0, %xmm1
	movd	%xmm1, %edx
	je	.L3
.L5:
	movslq	%eax, %rsi
	movsbl	(%rsp,%rsi), %esi
	leal	-48(%rdx,%rsi), %edx
	leal	1(%rax), %esi
	cmpl	%eax, %ecx
	jle	.L3
	movslq	%esi, %rdi
	movsbl	(%rsp,%rdi), %edi
	leal	-48(%rdx,%rdi), %edx
	leal	2(%rax), %edi
	cmpl	%ecx, %esi
	jge	.L3
	movslq	%edi, %rsi
	movsbl	(%rsp,%rsi), %esi
	leal	-48(%rdx,%rsi), %edx
	leal	3(%rax), %esi
	cmpl	%edi, %ecx
	jle	.L3
	movslq	%esi, %rdi
	movsbl	(%rsp,%rdi), %edi
	leal	-48(%rdx,%rdi), %edx
	leal	4(%rax), %edi
	cmpl	%ecx, %esi
	jge	.L3
	movslq	%edi, %rsi
	movsbl	(%rsp,%rsi), %esi
	leal	-48(%rdx,%rsi), %edx
	leal	5(%rax), %esi
	cmpl	%edi, %ecx
	jle	.L3
	movslq	%esi, %rdi
	movsbl	(%rsp,%rdi), %edi
	leal	-48(%rdx,%rdi), %edx
	leal	6(%rax), %edi
	cmpl	%esi, %ecx
	jle	.L3
	movslq	%edi, %rsi
	movsbl	(%rsp,%rsi), %esi
	leal	-48(%rdx,%rsi), %edx
	leal	7(%rax), %esi
	cmpl	%edi, %ecx
	jle	.L3
	movslq	%esi, %rdi
	movsbl	(%rsp,%rdi), %edi
	leal	-48(%rdx,%rdi), %edx
	leal	8(%rax), %edi
	cmpl	%esi, %ecx
	jle	.L3
	movslq	%edi, %rsi
	movsbl	(%rsp,%rsi), %esi
	leal	-48(%rdx,%rsi), %edx
	leal	9(%rax), %esi
	cmpl	%edi, %ecx
	jle	.L3
	movslq	%esi, %rdi
	movsbl	(%rsp,%rdi), %edi
	leal	-48(%rdx,%rdi), %edx
	leal	10(%rax), %edi
	cmpl	%esi, %ecx
	jle	.L3
	movslq	%edi, %rsi
	movsbl	(%rsp,%rsi), %esi
	leal	-48(%rdx,%rsi), %edx
	leal	11(%rax), %esi
	cmpl	%edi, %ecx
	jle	.L3
	movslq	%esi, %rdi
	movsbl	(%rsp,%rdi), %edi
	leal	-48(%rdx,%rdi), %edx
	leal	12(%rax), %edi
	cmpl	%esi, %ecx
	jle	.L3
	movslq	%edi, %rsi
	movsbl	(%rsp,%rsi), %esi
	leal	-48(%rdx,%rsi), %edx
	leal	13(%rax), %esi
	cmpl	%edi, %ecx
	jle	.L3
	movslq	%esi, %rdi
	addl	$14, %eax
	movsbl	(%rsp,%rdi), %edi
	leal	-48(%rdx,%rdi), %edx
	cmpl	%esi, %ecx
	jle	.L3
	cltq
	movsbl	(%rsp,%rax), %eax
	leal	-48(%rdx,%rax), %edx
	.p2align 4,,10
	.p2align 3
.L3:
	movq	%rbp, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L2:
	movq	1000(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L16
	addq	$1016, %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
.L10:
	.cfi_restore_state
	xorl	%edx, %edx
	jmp	.L3
.L11:
	xorl	%eax, %eax
	xorl	%edx, %edx
	jmp	.L5
.L16:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC1:
	.value	-48
	.value	-48
	.value	-48
	.value	-48
	.value	-48
	.value	-48
	.value	-48
	.value	-48
	.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:
```