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 str[21];
    int num;
    int i;
    int ch[5]={0};

    gets(str);
    num = strlen(str);
    if(num>5) ch[0]=1;
    
    for(i=0;i<num;i++){
        if(str[i]>47 && str[i]<58){
            ch[1]=1;
        }
        else if(str[i]>64 && str[i]<91){
            ch[2]=1;
        }
        else if(str[i]>96 && str[i]<123){
            ch[3]=1;
        }
        else{
            ch[4]=-1;
        }
    }
    if(ch[0]==1 && ch[1]==1 && ch[2]==1 && ch[3]==1 && ch[4]!=-1){
        printf("VALID\n");
    }
    else{
        printf("INVALID\n"); 
    }

    return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"VALID"
.LC1:
	.string	"INVALID"
	.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	$80, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movq	$0, -64(%rbp)
	movq	$0, -56(%rbp)
	movl	$0, -48(%rbp)
	leaq	-32(%rbp), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	gets@PLT
	leaq	-32(%rbp), %rax
	movq	%rax, %rdi
	call	strlen@PLT
	movl	%eax, -68(%rbp)
	cmpl	$5, -68(%rbp)
	jle	.L2
	movl	$1, -64(%rbp)
.L2:
	movl	$0, -72(%rbp)
	jmp	.L3
.L8:
	movl	-72(%rbp), %eax
	cltq
	movzbl	-32(%rbp,%rax), %eax
	cmpb	$47, %al
	jle	.L4
	movl	-72(%rbp), %eax
	cltq
	movzbl	-32(%rbp,%rax), %eax
	cmpb	$57, %al
	jg	.L4
	movl	$1, -60(%rbp)
	jmp	.L5
.L4:
	movl	-72(%rbp), %eax
	cltq
	movzbl	-32(%rbp,%rax), %eax
	cmpb	$64, %al
	jle	.L6
	movl	-72(%rbp), %eax
	cltq
	movzbl	-32(%rbp,%rax), %eax
	cmpb	$90, %al
	jg	.L6
	movl	$1, -56(%rbp)
	jmp	.L5
.L6:
	movl	-72(%rbp), %eax
	cltq
	movzbl	-32(%rbp,%rax), %eax
	cmpb	$96, %al
	jle	.L7
	movl	-72(%rbp), %eax
	cltq
	movzbl	-32(%rbp,%rax), %eax
	cmpb	$122, %al
	jg	.L7
	movl	$1, -52(%rbp)
	jmp	.L5
.L7:
	movl	$-1, -48(%rbp)
.L5:
	addl	$1, -72(%rbp)
.L3:
	movl	-72(%rbp), %eax
	cmpl	-68(%rbp), %eax
	jl	.L8
	movl	-64(%rbp), %eax
	cmpl	$1, %eax
	jne	.L9
	movl	-60(%rbp), %eax
	cmpl	$1, %eax
	jne	.L9
	movl	-56(%rbp), %eax
	cmpl	$1, %eax
	jne	.L9
	movl	-52(%rbp), %eax
	cmpl	$1, %eax
	jne	.L9
	movl	-48(%rbp), %eax
	cmpl	$-1, %eax
	je	.L9
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	jmp	.L10
.L9:
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
.L10:
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L12
	call	__stack_chk_fail@PLT
.L12:
	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	"VALID"
.LC1:
	.string	"INVALID"
	.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
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	subq	$40, %rsp
	.cfi_def_cfa_offset 64
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	movq	%rsp, %rbx
	movq	%rbx, %rdi
	call	gets@PLT
	movq	%rbx, %rdi
	call	strlen@PLT
	cmpq	$5, %rax
	seta	%bpl
	testq	%rax, %rax
	je	.L2
	subl	$1, %eax
	movq	%rbx, %rdx
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	leaq	1(%rsp,%rax), %rdi
	xorl	%r10d, %r10d
	xorl	%esi, %esi
	movl	$1, %ebx
	movl	$-1, %r11d
	jmp	.L4
	.p2align 4,,10
	.p2align 3
.L23:
	leal	-65(%rax), %ecx
	cmpb	$25, %cl
	jbe	.L8
	subl	$97, %eax
	cmpb	$26, %al
	cmovnb	%r11d, %r9d
	cmovb	%ebx, %r8d
.L3:
	addq	$1, %rdx
	cmpq	%rdx, %rdi
	je	.L22
.L4:
	movzbl	(%rdx), %eax
	leal	-48(%rax), %ecx
	cmpb	$9, %cl
	ja	.L23
	addq	$1, %rdx
	movl	$1, %esi
	cmpq	%rdx, %rdi
	jne	.L4
.L22:
	andl	%r10d, %esi
	andl	%ebp, %esi
	testb	%r8b, %sil
	je	.L2
	addl	$1, %r9d
	jne	.L24
.L2:
	leaq	.LC1(%rip), %rdi
	call	puts@PLT
.L5:
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L25
	addq	$40, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 24
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L8:
	.cfi_restore_state
	movl	$1, %r10d
	jmp	.L3
.L24:
	leaq	.LC0(%rip), %rdi
	call	puts@PLT
	jmp	.L5
.L25:
	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	"VALID"
.LC1:
	.string	"INVALID"
	.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
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	subq	$40, %rsp
	.cfi_def_cfa_offset 64
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	movq	%rsp, %rbx
	movq	%rbx, %rdi
	call	gets@PLT
	movq	%rbx, %rdi
	call	strlen@PLT
	cmpq	$5, %rax
	seta	%bpl
	testq	%rax, %rax
	je	.L2
	subl	$1, %eax
	movq	%rbx, %rdx
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	leaq	1(%rsp,%rax), %rdi
	xorl	%r10d, %r10d
	xorl	%esi, %esi
	movl	$1, %ebx
	movl	$-1, %r11d
	jmp	.L4
	.p2align 4,,10
	.p2align 3
.L23:
	leal	-65(%rax), %ecx
	cmpb	$25, %cl
	jbe	.L8
	subl	$97, %eax
	cmpb	$26, %al
	cmovnb	%r11d, %r9d
	cmovb	%ebx, %r8d
.L3:
	addq	$1, %rdx
	cmpq	%rdx, %rdi
	je	.L22
.L4:
	movzbl	(%rdx), %eax
	leal	-48(%rax), %ecx
	cmpb	$9, %cl
	ja	.L23
	addq	$1, %rdx
	movl	$1, %esi
	cmpq	%rdx, %rdi
	jne	.L4
.L22:
	andl	%r10d, %esi
	andl	%ebp, %esi
	testb	%r8b, %sil
	je	.L2
	addl	$1, %r9d
	jne	.L24
.L2:
	leaq	.LC1(%rip), %rdi
	call	puts@PLT
.L5:
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L25
	addq	$40, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 24
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L8:
	.cfi_restore_state
	movl	$1, %r10d
	jmp	.L3
.L24:
	leaq	.LC0(%rip), %rdi
	call	puts@PLT
	jmp	.L5
.L25:
	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 str[21];
    int num;
    int i;
    int ch[5]={0};

    gets(str);
    num = strlen(str);
    if(num>5) ch[0]=1;
    
    for(i=0;i<num;i++){
        if(str[i]>47 && str[i]<58){
            ch[1]=1;
        }
        else if(str[i]>64 && str[i]<91){
            ch[2]=1;
        }
        else if(str[i]>96 && str[i]<123){
            ch[3]=1;
        }
        else{
            ch[4]=-1;
        }
    }
    if(ch[0]==1 && ch[1]==1 && ch[2]==1 && ch[3]==1 && ch[4]!=-1){
        printf("VALID\n");
    }
    else{
        printf("INVALID\n"); 
    }

    return 0;
}
passxord
 parsxosd
 parsxpsd
 qarsxpsd
 qarxspsd
 dspsxraq
 qarxspsc
 cspsxraq
 capsxrsq
 capsxqsr

INVALID
 INVALID
 INVALID
 INVALID
 INVALID
 INVALID
 INVALID
 INVALID
 INVALID
 INVALID

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 str[21];
    int num;
    int i;
    int ch[5]={0};

    gets(str);
    num = strlen(str);
    if(num>5) ch[0]=1;
    
    for(i=0;i<num;i++){
        if(str[i]>47 && str[i]<58){
            ch[1]=1;
        }
        else if(str[i]>64 && str[i]<91){
            ch[2]=1;
        }
        else if(str[i]>96 && str[i]<123){
            ch[3]=1;
        }
        else{
            ch[4]=-1;
        }
    }
    if(ch[0]==1 && ch[1]==1 && ch[2]==1 && ch[3]==1 && ch[4]!=-1){
        printf("VALID\n");
    }
    else{
        printf("INVALID\n"); 
    }

    return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"VALID"
.LC1:
	.string	"INVALID"
	.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	$80, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movq	$0, -64(%rbp)
	movq	$0, -56(%rbp)
	movl	$0, -48(%rbp)
	leaq	-32(%rbp), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	gets@PLT
	leaq	-32(%rbp), %rax
	movq	%rax, %rdi
	call	strlen@PLT
	movl	%eax, -68(%rbp)
	cmpl	$5, -68(%rbp)
	jle	.L2
	movl	$1, -64(%rbp)
.L2:
	movl	$0, -72(%rbp)
	jmp	.L3
.L8:
	movl	-72(%rbp), %eax
	cltq
	movzbl	-32(%rbp,%rax), %eax
	cmpb	$47, %al
	jle	.L4
	movl	-72(%rbp), %eax
	cltq
	movzbl	-32(%rbp,%rax), %eax
	cmpb	$57, %al
	jg	.L4
	movl	$1, -60(%rbp)
	jmp	.L5
.L4:
	movl	-72(%rbp), %eax
	cltq
	movzbl	-32(%rbp,%rax), %eax
	cmpb	$64, %al
	jle	.L6
	movl	-72(%rbp), %eax
	cltq
	movzbl	-32(%rbp,%rax), %eax
	cmpb	$90, %al
	jg	.L6
	movl	$1, -56(%rbp)
	jmp	.L5
.L6:
	movl	-72(%rbp), %eax
	cltq
	movzbl	-32(%rbp,%rax), %eax
	cmpb	$96, %al
	jle	.L7
	movl	-72(%rbp), %eax
	cltq
	movzbl	-32(%rbp,%rax), %eax
	cmpb	$122, %al
	jg	.L7
	movl	$1, -52(%rbp)
	jmp	.L5
.L7:
	movl	$-1, -48(%rbp)
.L5:
	addl	$1, -72(%rbp)
.L3:
	movl	-72(%rbp), %eax
	cmpl	-68(%rbp), %eax
	jl	.L8
	movl	-64(%rbp), %eax
	cmpl	$1, %eax
	jne	.L9
	movl	-60(%rbp), %eax
	cmpl	$1, %eax
	jne	.L9
	movl	-56(%rbp), %eax
	cmpl	$1, %eax
	jne	.L9
	movl	-52(%rbp), %eax
	cmpl	$1, %eax
	jne	.L9
	movl	-48(%rbp), %eax
	cmpl	$-1, %eax
	je	.L9
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	jmp	.L10
.L9:
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
.L10:
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L12
	call	__stack_chk_fail@PLT
.L12:
	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	"VALID"
.LC1:
	.string	"INVALID"
	.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	$80, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movq	$0, -64(%rbp)
	movq	$0, -56(%rbp)
	movl	$0, -48(%rbp)
	leaq	-32(%rbp), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	gets@PLT
	leaq	-32(%rbp), %rax
	movq	%rax, %rdi
	call	strlen@PLT
	movl	%eax, -68(%rbp)
	cmpl	$5, -68(%rbp)
	jle	.L2
	movl	$1, -64(%rbp)
.L2:
	movl	$0, -72(%rbp)
	jmp	.L3
.L8:
	movl	-72(%rbp), %eax
	cltq
	movzbl	-32(%rbp,%rax), %eax
	cmpb	$47, %al
	jle	.L4
	movl	-72(%rbp), %eax
	cltq
	movzbl	-32(%rbp,%rax), %eax
	cmpb	$57, %al
	jg	.L4
	movl	$1, -60(%rbp)
	jmp	.L5
.L4:
	movl	-72(%rbp), %eax
	cltq
	movzbl	-32(%rbp,%rax), %eax
	cmpb	$64, %al
	jle	.L6
	movl	-72(%rbp), %eax
	cltq
	movzbl	-32(%rbp,%rax), %eax
	cmpb	$90, %al
	jg	.L6
	movl	$1, -56(%rbp)
	jmp	.L5
.L6:
	movl	-72(%rbp), %eax
	cltq
	movzbl	-32(%rbp,%rax), %eax
	cmpb	$96, %al
	jle	.L7
	movl	-72(%rbp), %eax
	cltq
	movzbl	-32(%rbp,%rax), %eax
	cmpb	$122, %al
	jg	.L7
	movl	$1, -52(%rbp)
	jmp	.L5
.L7:
	movl	$-1, -48(%rbp)
.L5:
	addl	$1, -72(%rbp)
.L3:
	movl	-72(%rbp), %eax
	cmpl	-68(%rbp), %eax
	jl	.L8
	movl	-64(%rbp), %eax
	cmpl	$1, %eax
	jne	.L9
	movl	-60(%rbp), %eax
	cmpl	$1, %eax
	jne	.L9
	movl	-56(%rbp), %eax
	cmpl	$1, %eax
	jne	.L9
	movl	-52(%rbp), %eax
	cmpl	$1, %eax
	jne	.L9
	movl	-48(%rbp), %eax
	cmpl	$-1, %eax
	je	.L9
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	jmp	.L10
.L9:
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
.L10:
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L12
	call	__stack_chk_fail@PLT
.L12:
	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:
