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 <string.h>
int main()
{
    char S[10];
    gets(S);
    int i,flag = 0,len;
    len = strlen(S);
    for(i=0;i<len;i++)
    {
        if(S[5]=='0')
        {
            if(S[6]>='1' && S[6]<='4')
            {
                if(S[8]>='0' && S[8]<='2')
                {
                    if(S[9]>='0' && S[9]<='9')
                    {
                        flag = 1;
                    }
                }
                else if(S[8]=='3')
                {
                    if(S[9]=='0')
                    {
                        flag = 1;
                    }
                }
            }
        }
    }
    if(flag==1)
    {
        printf("Heisei\n");
    }
    else
    {
        printf("TBD\n");
    }
    return 0;
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"Heisei"
.LC1:
	.string	"TBD"
	.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
	leaq	-18(%rbp), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	gets@PLT
	movl	$0, -28(%rbp)
	leaq	-18(%rbp), %rax
	movq	%rax, %rdi
	call	strlen@PLT
	movl	%eax, -24(%rbp)
	movl	$0, -32(%rbp)
	jmp	.L2
.L6:
	movzbl	-13(%rbp), %eax
	cmpb	$48, %al
	jne	.L3
	movzbl	-12(%rbp), %eax
	cmpb	$48, %al
	jle	.L3
	movzbl	-12(%rbp), %eax
	cmpb	$52, %al
	jg	.L3
	movzbl	-10(%rbp), %eax
	cmpb	$47, %al
	jle	.L4
	movzbl	-10(%rbp), %eax
	cmpb	$50, %al
	jg	.L4
	movzbl	-9(%rbp), %eax
	cmpb	$47, %al
	jle	.L11
	movzbl	-9(%rbp), %eax
	cmpb	$57, %al
	jg	.L11
	movl	$1, -28(%rbp)
	jmp	.L11
.L4:
	movzbl	-10(%rbp), %eax
	cmpb	$51, %al
	jne	.L3
	movzbl	-9(%rbp), %eax
	cmpb	$48, %al
	jne	.L3
	movl	$1, -28(%rbp)
	jmp	.L3
.L11:
	nop
.L3:
	addl	$1, -32(%rbp)
.L2:
	movl	-32(%rbp), %eax
	cmpl	-24(%rbp), %eax
	jl	.L6
	cmpl	$1, -28(%rbp)
	jne	.L7
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	jmp	.L8
.L7:
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
.L8:
	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
.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	"Heisei"
.LC1:
	.string	"TBD"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB35:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	subq	$32, %rsp
	.cfi_def_cfa_offset 48
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	leaq	14(%rsp), %rbp
	movq	%rbp, %rdi
	call	gets@PLT
	movq	%rbp, %rdi
	call	strlen@PLT
	testq	%rax, %rax
	je	.L2
	movl	%eax, %esi
	movzbl	20(%rsp), %eax
	movzbl	22(%rsp), %edx
	movzbl	23(%rsp), %ecx
	subl	$49, %eax
	cmpb	$48, 19(%rsp)
	leal	-48(%rdx), %r8d
	leal	-48(%rcx), %edi
	je	.L18
.L2:
	leaq	.LC1(%rip), %rdi
	call	puts@PLT
.L8:
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L19
	addq	$32, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 16
	xorl	%eax, %eax
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
.L18:
	.cfi_restore_state
	cmpb	$9, %dil
	ja	.L2
	cmpb	$2, %r8b
	jbe	.L3
	cmpb	$3, %al
	ja	.L2
	xorl	%edi, %edi
	xorl	%eax, %eax
	movl	$1, %r8d
	jmp	.L5
.L4:
	addl	$1, %eax
	cmpl	%eax, %esi
	je	.L20
.L5:
	cmpb	$51, %dl
	jne	.L4
	cmpb	$48, %cl
	cmove	%r8d, %edi
	jmp	.L4
.L3:
	cmpb	$3, %al
	ja	.L2
.L7:
	leaq	.LC0(%rip), %rdi
	call	puts@PLT
	jmp	.L8
.L20:
	subl	$1, %edi
	je	.L7
	jmp	.L2
.L19:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE35:
	.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	"Heisei"
.LC1:
	.string	"TBD"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB35:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	subq	$32, %rsp
	.cfi_def_cfa_offset 48
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	leaq	14(%rsp), %rbp
	movq	%rbp, %rdi
	call	gets@PLT
	movq	%rbp, %rdi
	call	strlen@PLT
	testq	%rax, %rax
	je	.L2
	movl	%eax, %esi
	movzbl	20(%rsp), %eax
	movzbl	22(%rsp), %edx
	movzbl	23(%rsp), %ecx
	subl	$49, %eax
	cmpb	$48, 19(%rsp)
	leal	-48(%rdx), %r8d
	leal	-48(%rcx), %edi
	je	.L18
.L2:
	leaq	.LC1(%rip), %rdi
	call	puts@PLT
.L8:
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L19
	addq	$32, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 16
	xorl	%eax, %eax
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
.L18:
	.cfi_restore_state
	cmpb	$9, %dil
	ja	.L2
	cmpb	$2, %r8b
	jbe	.L3
	cmpb	$3, %al
	ja	.L2
	xorl	%edi, %edi
	xorl	%eax, %eax
	movl	$1, %r8d
	jmp	.L5
.L4:
	addl	$1, %eax
	cmpl	%eax, %esi
	je	.L20
.L5:
	cmpb	$51, %dl
	jne	.L4
	cmpb	$48, %cl
	cmove	%r8d, %edi
	jmp	.L4
.L3:
	cmpb	$3, %al
	ja	.L2
.L7:
	leaq	.LC0(%rip), %rdi
	call	puts@PLT
	jmp	.L8
.L20:
	subl	$1, %edi
	je	.L7
	jmp	.L2
.L19:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE35:
	.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 <string.h>
int main()
{
    char S[10];
    gets(S);
    int i,flag = 0,len;
    len = strlen(S);
    for(i=0;i<len;i++)
    {
        if(S[5]=='0')
        {
            if(S[6]>='1' && S[6]<='4')
            {
                if(S[8]>='0' && S[8]<='2')
                {
                    if(S[9]>='0' && S[9]<='9')
                    {
                        flag = 1;
                    }
                }
                else if(S[8]=='3')
                {
                    if(S[9]=='0')
                    {
                        flag = 1;
                    }
                }
            }
        }
    }
    if(flag==1)
    {
        printf("Heisei\n");
    }
    else
    {
        printf("TBD\n");
    }
    return 0;
}

2019/03/30
 2019/11/00
 2019/04/20
 2019/12/01
 2019/14/20
 2119/12/01
 2019/24/10
 1019/04/30
 2119/10/01
 2029/11/00

Heisei
 TBD
 Heisei
 TBD
 TBD
 TBD
 TBD
 Heisei
 TBD
 TBD

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 <string.h>
int main()
{
    char S[10];
    gets(S);
    int i,flag = 0,len;
    len = strlen(S);
    for(i=0;i<len;i++)
    {
        if(S[5]=='0')
        {
            if(S[6]>='1' && S[6]<='4')
            {
                if(S[8]>='0' && S[8]<='2')
                {
                    if(S[9]>='0' && S[9]<='9')
                    {
                        flag = 1;
                    }
                }
                else if(S[8]=='3')
                {
                    if(S[9]=='0')
                    {
                        flag = 1;
                    }
                }
            }
        }
    }
    if(flag==1)
    {
        printf("Heisei\n");
    }
    else
    {
        printf("TBD\n");
    }
    return 0;
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"Heisei"
.LC1:
	.string	"TBD"
	.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
	leaq	-18(%rbp), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	gets@PLT
	movl	$0, -28(%rbp)
	leaq	-18(%rbp), %rax
	movq	%rax, %rdi
	call	strlen@PLT
	movl	%eax, -24(%rbp)
	movl	$0, -32(%rbp)
	jmp	.L2
.L6:
	movzbl	-13(%rbp), %eax
	cmpb	$48, %al
	jne	.L3
	movzbl	-12(%rbp), %eax
	cmpb	$48, %al
	jle	.L3
	movzbl	-12(%rbp), %eax
	cmpb	$52, %al
	jg	.L3
	movzbl	-10(%rbp), %eax
	cmpb	$47, %al
	jle	.L4
	movzbl	-10(%rbp), %eax
	cmpb	$50, %al
	jg	.L4
	movzbl	-9(%rbp), %eax
	cmpb	$47, %al
	jle	.L11
	movzbl	-9(%rbp), %eax
	cmpb	$57, %al
	jg	.L11
	movl	$1, -28(%rbp)
	jmp	.L11
.L4:
	movzbl	-10(%rbp), %eax
	cmpb	$51, %al
	jne	.L3
	movzbl	-9(%rbp), %eax
	cmpb	$48, %al
	jne	.L3
	movl	$1, -28(%rbp)
	jmp	.L3
.L11:
	nop
.L3:
	addl	$1, -32(%rbp)
.L2:
	movl	-32(%rbp), %eax
	cmpl	-24(%rbp), %eax
	jl	.L6
	cmpl	$1, -28(%rbp)
	jne	.L7
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	jmp	.L8
.L7:
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
.L8:
	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
.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	"Heisei"
.LC1:
	.string	"TBD"
	.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
	leaq	-18(%rbp), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	gets@PLT
	movl	$0, -28(%rbp)
	leaq	-18(%rbp), %rax
	movq	%rax, %rdi
	call	strlen@PLT
	movl	%eax, -24(%rbp)
	movl	$0, -32(%rbp)
	jmp	.L2
.L6:
	movzbl	-13(%rbp), %eax
	cmpb	$48, %al
	jne	.L3
	movzbl	-12(%rbp), %eax
	cmpb	$48, %al
	jle	.L3
	movzbl	-12(%rbp), %eax
	cmpb	$52, %al
	jg	.L3
	movzbl	-10(%rbp), %eax
	cmpb	$47, %al
	jle	.L4
	movzbl	-10(%rbp), %eax
	cmpb	$50, %al
	jg	.L4
	movzbl	-9(%rbp), %eax
	cmpb	$47, %al
	jle	.L11
	movzbl	-9(%rbp), %eax
	cmpb	$57, %al
	jg	.L11
	movl	$1, -28(%rbp)
	jmp	.L11
.L4:
	movzbl	-10(%rbp), %eax
	cmpb	$51, %al
	jne	.L3
	movzbl	-9(%rbp), %eax
	cmpb	$48, %al
	jne	.L3
	movl	$1, -28(%rbp)
	jmp	.L3
.L11:
	nop
.L3:
	addl	$1, -32(%rbp)
.L2:
	movl	-32(%rbp), %eax
	cmpl	-24(%rbp), %eax
	jl	.L6
	cmpl	$1, -28(%rbp)
	jne	.L7
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	jmp	.L8
.L7:
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
.L8:
	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
.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:
