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

```c
#define _CRT_SECURE_NO_WARNINGS
//#define _USE_MATH_DEFINES
#include<stdio.h>
//#include<stdlib.h>
//#include<math.h>
//#include<string.h>
//#include<time.h>
//#define pi acos(-1.0)
#define P(type,x) fprintf(stdout,"%"#type"\n",x)
#define S(type,x) fscanf(stdin,"%"#type,&x)
int main() {
	while (1) {
		int a,ans,ace;
		char dum;
		ans = ace = 0;
		while (~fscanf(stdin, "%d%c", &a,&dum)) {
			if (a == 0) return 0;
			if (a > 10) ans += 10;
			else if (a == 1) ace++,ans++;
			else ans += a;
			if (dum == '\n') break;
		}
		if (ans > 21) ans = 0;
		else {
			while (ace) {
				if (ans + 10 <= 21) ans += 10;
				ace--;
			}
		}
		P(d, ans);
	}
	return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d%c"
.LC1:
	.string	"%d\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	$32, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
.L15:
	movl	$0, -12(%rbp)
	movl	-12(%rbp), %eax
	movl	%eax, -16(%rbp)
	jmp	.L2
.L9:
	movl	-20(%rbp), %eax
	testl	%eax, %eax
	jne	.L3
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L16
	jmp	.L17
.L3:
	movl	-20(%rbp), %eax
	cmpl	$10, %eax
	jle	.L5
	addl	$10, -16(%rbp)
	jmp	.L6
.L5:
	movl	-20(%rbp), %eax
	cmpl	$1, %eax
	jne	.L7
	addl	$1, -12(%rbp)
	addl	$1, -16(%rbp)
	jmp	.L6
.L7:
	movl	-20(%rbp), %eax
	addl	%eax, -16(%rbp)
.L6:
	movzbl	-21(%rbp), %eax
	cmpb	$10, %al
	je	.L18
.L2:
	movq	stdin(%rip), %rax
	leaq	-21(%rbp), %rcx
	leaq	-20(%rbp), %rdx
	leaq	.LC0(%rip), %rsi
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_fscanf@PLT
	cmpl	$-1, %eax
	jne	.L9
	jmp	.L8
.L18:
	nop
.L8:
	cmpl	$21, -16(%rbp)
	jle	.L12
	movl	$0, -16(%rbp)
	jmp	.L11
.L14:
	cmpl	$11, -16(%rbp)
	jg	.L13
	addl	$10, -16(%rbp)
.L13:
	subl	$1, -12(%rbp)
.L12:
	cmpl	$0, -12(%rbp)
	jne	.L14
.L11:
	movq	stdout(%rip), %rax
	movl	-16(%rbp), %edx
	leaq	.LC1(%rip), %rcx
	movq	%rcx, %rsi
	movq	%rax, %rdi
	movl	$0, %eax
	call	fprintf@PLT
	jmp	.L15
.L17:
	call	__stack_chk_fail@PLT
.L16:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.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%c"
.LC1:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.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
	leaq	.LC1(%rip), %r14
	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
	leaq	.LC0(%rip), %rbx
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	leaq	3(%rsp), %r12
	leaq	4(%rsp), %rbp
.L11:
	xorl	%r13d, %r13d
	xorl	%r15d, %r15d
	jmp	.L2
	.p2align 4,,10
	.p2align 3
.L22:
	addl	$10, %r15d
.L5:
	cmpb	$10, 3(%rsp)
	je	.L7
.L2:
	movq	stdin(%rip), %rdi
	xorl	%eax, %eax
	movq	%r12, %rcx
	movq	%rbp, %rdx
	movq	%rbx, %rsi
	call	__isoc99_fscanf@PLT
	cmpl	$-1, %eax
	je	.L7
	movl	4(%rsp), %eax
	testl	%eax, %eax
	je	.L21
	cmpl	$10, %eax
	jg	.L22
	cmpl	$1, %eax
	je	.L23
	addl	%eax, %r15d
	cmpb	$10, 3(%rsp)
	jne	.L2
	.p2align 4,,10
	.p2align 3
.L7:
	cmpl	$21, %r15d
	jle	.L24
	xorl	%r15d, %r15d
.L9:
	movq	stdout(%rip), %rdi
	movl	%r15d, %ecx
	movq	%r14, %rdx
	xorl	%eax, %eax
	movl	$1, %esi
	call	__fprintf_chk@PLT
	jmp	.L11
	.p2align 4,,10
	.p2align 3
.L23:
	addl	$1, %r13d
	addl	$1, %r15d
	jmp	.L5
	.p2align 4,,10
	.p2align 3
.L21:
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L25
	addq	$24, %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
.L24:
	.cfi_restore_state
	testl	%r13d, %r13d
	je	.L9
	.p2align 4,,10
	.p2align 3
.L10:
	cmpl	$11, %r15d
	jg	.L9
	addl	$10, %r15d
	subl	$1, %r13d
	jne	.L10
	jmp	.L9
.L25:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.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%c"
.LC1:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.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
	leaq	.LC1(%rip), %r14
	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
	leaq	.LC0(%rip), %rbx
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	leaq	3(%rsp), %r12
	leaq	4(%rsp), %rbp
.L11:
	xorl	%r13d, %r13d
	xorl	%r15d, %r15d
	jmp	.L2
	.p2align 4,,10
	.p2align 3
.L22:
	addl	$10, %r15d
.L5:
	cmpb	$10, 3(%rsp)
	je	.L7
.L2:
	movq	stdin(%rip), %rdi
	xorl	%eax, %eax
	movq	%r12, %rcx
	movq	%rbp, %rdx
	movq	%rbx, %rsi
	call	__isoc99_fscanf@PLT
	cmpl	$-1, %eax
	je	.L7
	movl	4(%rsp), %eax
	testl	%eax, %eax
	je	.L21
	cmpl	$10, %eax
	jg	.L22
	cmpl	$1, %eax
	je	.L23
	addl	%eax, %r15d
	cmpb	$10, 3(%rsp)
	jne	.L2
	.p2align 4,,10
	.p2align 3
.L7:
	cmpl	$21, %r15d
	jle	.L24
	xorl	%r15d, %r15d
.L9:
	movq	stdout(%rip), %rdi
	movl	%r15d, %ecx
	movq	%r14, %rdx
	xorl	%eax, %eax
	movl	$1, %esi
	call	__fprintf_chk@PLT
	jmp	.L11
	.p2align 4,,10
	.p2align 3
.L23:
	addl	$1, %r13d
	addl	$1, %r15d
	jmp	.L5
	.p2align 4,,10
	.p2align 3
.L21:
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L25
	addq	$24, %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
.L24:
	.cfi_restore_state
	testl	%r13d, %r13d
	je	.L9
	.p2align 4,,10
	.p2align 3
.L10:
	cmpl	$11, %r15d
	jg	.L9
	addl	$10, %r15d
	subl	$1, %r13d
	jne	.L10
	jmp	.L9
.L25:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.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:

#define _CRT_SECURE_NO_WARNINGS
//#define _USE_MATH_DEFINES
#include<stdio.h>
//#include<stdlib.h>
//#include<math.h>
//#include<string.h>
//#include<time.h>
//#define pi acos(-1.0)
#define P(type,x) fprintf(stdout,"%"#type"\n",x)
#define S(type,x) fscanf(stdin,"%"#type,&x)
int main() {
	while (1) {
		int a,ans,ace;
		char dum;
		ans = ace = 0;
		while (~fscanf(stdin, "%d%c", &a,&dum)) {
			if (a == 0) return 0;
			if (a > 10) ans += 10;
			else if (a == 1) ace++,ans++;
			else ans += a;
			if (dum == '\n') break;
		}
		if (ans > 21) ans = 0;
		else {
			while (ace) {
				if (ans + 10 <= 21) ans += 10;
				ace--;
			}
		}
		P(d, ans);
	}
	return 0;
}
1
7 7 7
7 7 8
12 1
10 1 2
0
 1
7 7 7
7 7 8
10 1
10 1 1
0
 1
7 7 7
7 7 8
2 1
10 2 1
0
 1
7 9 7
7 7 8
2 1
10 2 1
0
 1
7 9 7
1 9 8
2 1
10 2 1
0
 1
7 4 7
1 9 8
2 1
10 2 1
0
 1
7 4 2
1 9 8
2 1
10 2 1
0
 1
7 3 2
1 9 8
2 1
10 2 1
0
 1
7 3 4
1 9 8
2 1
10 2 1
0
 1
7 3 4
1 9 8
2 1
10 3 1
0

11
21
0
21
13
 11
21
0
21
12
 11
21
0
13
13
 11
0
0
13
13
 11
0
18
13
13
 11
18
18
13
13
 11
13
18
13
13
 11
12
18
13
13
 11
14
18
13
13
 11
14
18
13
14

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

```c
#define _CRT_SECURE_NO_WARNINGS
//#define _USE_MATH_DEFINES
#include<stdio.h>
//#include<stdlib.h>
//#include<math.h>
//#include<string.h>
//#include<time.h>
//#define pi acos(-1.0)
#define P(type,x) fprintf(stdout,"%"#type"\n",x)
#define S(type,x) fscanf(stdin,"%"#type,&x)
int main() {
	while (1) {
		int a,ans,ace;
		char dum;
		ans = ace = 0;
		while (~fscanf(stdin, "%d%c", &a,&dum)) {
			if (a == 0) return 0;
			if (a > 10) ans += 10;
			else if (a == 1) ace++,ans++;
			else ans += a;
			if (dum == '\n') break;
		}
		if (ans > 21) ans = 0;
		else {
			while (ace) {
				if (ans + 10 <= 21) ans += 10;
				ace--;
			}
		}
		P(d, ans);
	}
	return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d%c"
.LC1:
	.string	"%d\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	$32, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
.L15:
	movl	$0, -12(%rbp)
	movl	-12(%rbp), %eax
	movl	%eax, -16(%rbp)
	jmp	.L2
.L9:
	movl	-20(%rbp), %eax
	testl	%eax, %eax
	jne	.L3
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L16
	jmp	.L17
.L3:
	movl	-20(%rbp), %eax
	cmpl	$10, %eax
	jle	.L5
	addl	$10, -16(%rbp)
	jmp	.L6
.L5:
	movl	-20(%rbp), %eax
	cmpl	$1, %eax
	jne	.L7
	addl	$1, -12(%rbp)
	addl	$1, -16(%rbp)
	jmp	.L6
.L7:
	movl	-20(%rbp), %eax
	addl	%eax, -16(%rbp)
.L6:
	movzbl	-21(%rbp), %eax
	cmpb	$10, %al
	je	.L18
.L2:
	movq	stdin(%rip), %rax
	leaq	-21(%rbp), %rcx
	leaq	-20(%rbp), %rdx
	leaq	.LC0(%rip), %rsi
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_fscanf@PLT
	cmpl	$-1, %eax
	jne	.L9
	jmp	.L8
.L18:
	nop
.L8:
	cmpl	$21, -16(%rbp)
	jle	.L12
	movl	$0, -16(%rbp)
	jmp	.L11
.L14:
	cmpl	$11, -16(%rbp)
	jg	.L13
	addl	$10, -16(%rbp)
.L13:
	subl	$1, -12(%rbp)
.L12:
	cmpl	$0, -12(%rbp)
	jne	.L14
.L11:
	movq	stdout(%rip), %rax
	movl	-16(%rbp), %edx
	leaq	.LC1(%rip), %rcx
	movq	%rcx, %rsi
	movq	%rax, %rdi
	movl	$0, %eax
	call	fprintf@PLT
	jmp	.L15
.L17:
	call	__stack_chk_fail@PLT
.L16:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.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%c"
.LC1:
	.string	"%d\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	$32, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
.L15:
	movl	$0, -12(%rbp)
	movl	-12(%rbp), %eax
	movl	%eax, -16(%rbp)
	jmp	.L2
.L9:
	movl	-20(%rbp), %eax
	testl	%eax, %eax
	jne	.L3
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L16
	jmp	.L17
.L3:
	movl	-20(%rbp), %eax
	cmpl	$10, %eax
	jle	.L5
	addl	$10, -16(%rbp)
	jmp	.L6
.L5:
	movl	-20(%rbp), %eax
	cmpl	$1, %eax
	jne	.L7
	addl	$1, -12(%rbp)
	addl	$1, -16(%rbp)
	jmp	.L6
.L7:
	movl	-20(%rbp), %eax
	addl	%eax, -16(%rbp)
.L6:
	movzbl	-21(%rbp), %eax
	cmpb	$10, %al
	je	.L18
.L2:
	movq	stdin(%rip), %rax
	leaq	-21(%rbp), %rcx
	leaq	-20(%rbp), %rdx
	leaq	.LC0(%rip), %rsi
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_fscanf@PLT
	cmpl	$-1, %eax
	jne	.L9
	jmp	.L8
.L18:
	nop
.L8:
	cmpl	$21, -16(%rbp)
	jle	.L12
	movl	$0, -16(%rbp)
	jmp	.L11
.L14:
	cmpl	$11, -16(%rbp)
	jg	.L13
	addl	$10, -16(%rbp)
.L13:
	subl	$1, -12(%rbp)
.L12:
	cmpl	$0, -12(%rbp)
	jne	.L14
.L11:
	movq	stdout(%rip), %rax
	movl	-16(%rbp), %edx
	leaq	.LC1(%rip), %rcx
	movq	%rcx, %rsi
	movq	%rax, %rdi
	movl	$0, %eax
	call	fprintf@PLT
	jmp	.L15
.L17:
	call	__stack_chk_fail@PLT
.L16:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.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:
