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>

#define FOR(i, a, b) for(i = a; i < b; ++i)
#define REP(i, n) FOR(i, 0, n)
#define comp(a, b) comp(const void *a, const void *b)
#define N 100000

typedef unsigned int uint;
typedef unsigned long ulong;
typedef unsigned long long ull;

void yes_or_no(char boolean){
    if(boolean){
        printf("YES\n");
    }else{
        printf("NO\n");
    }
}


void substr(char str[], char sub[], int num, int end){
    int i;
    REP(i, num){
        sub[i] = str[i - num + end];
    }
    sub[num] = '\0';
}


int main(){
    char str[N], sub[10];
    char* list[] = {"dream", "dreamer", "erase", "eraser"};
    int length[] = {5, 7, 5, 6};
    int sublen = 0;
    char boolean = 1, flag = 0;
    int i;
    scanf("%s", str);

    uint len = strlen(str);

    while(len > 0){
        REP(i, 4){
            substr(str, sub, length[i], len);
            if(strcmp(sub, list[i]) == 0){
                sublen = length[i];
                flag = 1;
                break;
            }
        }
        if(flag == 0){
            boolean = 0;
            break;
        }
        flag = 0;
        len -= sublen;
    }
    yes_or_no(boolean);
    return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"YES"
.LC1:
	.string	"NO"
	.text
	.globl	yes_or_no
	.type	yes_or_no, @function
yes_or_no:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$16, %rsp
	movl	%edi, %eax
	movb	%al, -4(%rbp)
	cmpb	$0, -4(%rbp)
	je	.L2
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	jmp	.L4
.L2:
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
.L4:
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	yes_or_no, .-yes_or_no
	.globl	substr
	.type	substr, @function
substr:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -24(%rbp)
	movq	%rsi, -32(%rbp)
	movl	%edx, -36(%rbp)
	movl	%ecx, -40(%rbp)
	movl	$0, -4(%rbp)
	jmp	.L6
.L7:
	movl	-4(%rbp), %eax
	subl	-36(%rbp), %eax
	movl	%eax, %edx
	movl	-40(%rbp), %eax
	addl	%edx, %eax
	movslq	%eax, %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	-4(%rbp), %edx
	movslq	%edx, %rcx
	movq	-32(%rbp), %rdx
	addq	%rcx, %rdx
	movzbl	(%rax), %eax
	movb	%al, (%rdx)
	addl	$1, -4(%rbp)
.L6:
	movl	-4(%rbp), %eax
	cmpl	-36(%rbp), %eax
	jl	.L7
	movl	-36(%rbp), %eax
	movslq	%eax, %rdx
	movq	-32(%rbp), %rax
	addq	%rdx, %rax
	movb	$0, (%rax)
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	substr, .-substr
	.section	.rodata
.LC2:
	.string	"dream"
.LC3:
	.string	"dreamer"
.LC4:
	.string	"erase"
.LC5:
	.string	"eraser"
.LC6:
	.string	"%s"
	.text
	.globl	main
	.type	main, @function
main:
.LFB2:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	leaq	-98304(%rsp), %r11
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	subq	$1792, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	.LC2(%rip), %rax
	movq	%rax, -100064(%rbp)
	leaq	.LC3(%rip), %rax
	movq	%rax, -100056(%rbp)
	leaq	.LC4(%rip), %rax
	movq	%rax, -100048(%rbp)
	leaq	.LC5(%rip), %rax
	movq	%rax, -100040(%rbp)
	movl	$5, -100080(%rbp)
	movl	$7, -100076(%rbp)
	movl	$5, -100072(%rbp)
	movl	$6, -100068(%rbp)
	movl	$0, -100092(%rbp)
	movb	$1, -100094(%rbp)
	movb	$0, -100093(%rbp)
	leaq	-100016(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC6(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	leaq	-100016(%rbp), %rax
	movq	%rax, %rdi
	call	strlen@PLT
	movl	%eax, -100084(%rbp)
	jmp	.L9
.L16:
	movl	$0, -100088(%rbp)
	jmp	.L10
.L13:
	movl	-100084(%rbp), %ecx
	movl	-100088(%rbp), %eax
	cltq
	movl	-100080(%rbp,%rax,4), %edx
	leaq	-100026(%rbp), %rsi
	leaq	-100016(%rbp), %rax
	movq	%rax, %rdi
	call	substr
	movl	-100088(%rbp), %eax
	cltq
	movq	-100064(%rbp,%rax,8), %rdx
	leaq	-100026(%rbp), %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L11
	movl	-100088(%rbp), %eax
	cltq
	movl	-100080(%rbp,%rax,4), %eax
	movl	%eax, -100092(%rbp)
	movb	$1, -100093(%rbp)
	jmp	.L12
.L11:
	addl	$1, -100088(%rbp)
.L10:
	cmpl	$3, -100088(%rbp)
	jle	.L13
.L12:
	cmpb	$0, -100093(%rbp)
	jne	.L14
	movb	$0, -100094(%rbp)
	jmp	.L15
.L14:
	movb	$0, -100093(%rbp)
	movl	-100092(%rbp), %eax
	subl	%eax, -100084(%rbp)
.L9:
	cmpl	$0, -100084(%rbp)
	jne	.L16
.L15:
	movsbl	-100094(%rbp), %eax
	movl	%eax, %edi
	call	yes_or_no
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L18
	call	__stack_chk_fail@PLT
.L18:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2:
	.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	"YES"
.LC1:
	.string	"NO"
	.text
	.p2align 4
	.globl	yes_or_no
	.type	yes_or_no, @function
yes_or_no:
.LFB35:
	.cfi_startproc
	endbr64
	testb	%dil, %dil
	je	.L2
	leaq	.LC0(%rip), %rdi
	jmp	puts@PLT
	.p2align 4,,10
	.p2align 3
.L2:
	leaq	.LC1(%rip), %rdi
	jmp	puts@PLT
	.cfi_endproc
.LFE35:
	.size	yes_or_no, .-yes_or_no
	.p2align 4
	.globl	substr
	.type	substr, @function
substr:
.LFB36:
	.cfi_startproc
	endbr64
	testl	%edx, %edx
	jle	.L28
	movl	%ecx, %r10d
	movslq	%edx, %r9
	movslq	%ecx, %rcx
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	subq	%r9, %rcx
	movq	%rsi, %r8
	leal	-1(%rdx), %eax
	movl	%edx, %r11d
	leaq	1(%rdi,%rcx), %rbx
	subq	%rbx, %r8
	cmpq	$14, %r8
	jbe	.L6
	cmpl	$6, %eax
	jbe	.L6
	cmpl	$14, %eax
	jbe	.L14
	movl	%edx, %r8d
	addq	%rdi, %rcx
	xorl	%eax, %eax
	shrl	$4, %r8d
	salq	$4, %r8
	.p2align 4,,10
	.p2align 3
.L8:
	movdqu	(%rcx,%rax), %xmm0
	movups	%xmm0, (%rsi,%rax)
	addq	$16, %rax
	cmpq	%rax, %r8
	jne	.L8
	movl	%edx, %r8d
	andl	$-16, %r8d
	movl	%r8d, %eax
	cmpl	%r8d, %edx
	je	.L5
	movl	%edx, %r11d
	subl	%r8d, %r11d
	leal	-1(%r11), %ebx
	cmpl	$6, %ebx
	jbe	.L10
.L7:
	movq	(%rcx,%r8), %rcx
	movq	%rcx, (%rsi,%r8)
	movl	%r11d, %ecx
	andl	$-8, %ecx
	addl	%ecx, %eax
	cmpl	%ecx, %r11d
	je	.L5
.L10:
	movl	%eax, %ecx
	subl	%edx, %ecx
	addl	%r10d, %ecx
	movslq	%ecx, %rcx
	movzbl	(%rdi,%rcx), %r8d
	movslq	%eax, %rcx
	movb	%r8b, (%rsi,%rcx)
	leal	1(%rax), %ecx
	cmpl	%ecx, %edx
	jle	.L5
	movl	%ecx, %r8d
	movslq	%ecx, %rcx
	subl	%edx, %r8d
	addl	%r10d, %r8d
	movslq	%r8d, %r8
	movzbl	(%rdi,%r8), %r8d
	movb	%r8b, (%rsi,%rcx)
	leal	2(%rax), %ecx
	cmpl	%ecx, %edx
	jle	.L5
	movl	%ecx, %r8d
	movslq	%ecx, %rcx
	subl	%edx, %r8d
	addl	%r10d, %r8d
	movslq	%r8d, %r8
	movzbl	(%rdi,%r8), %r8d
	movb	%r8b, (%rsi,%rcx)
	leal	3(%rax), %ecx
	cmpl	%ecx, %edx
	jle	.L5
	movl	%ecx, %r8d
	movslq	%ecx, %rcx
	subl	%edx, %r8d
	addl	%r10d, %r8d
	movslq	%r8d, %r8
	movzbl	(%rdi,%r8), %r8d
	movb	%r8b, (%rsi,%rcx)
	leal	4(%rax), %ecx
	cmpl	%ecx, %edx
	jle	.L5
	movl	%ecx, %r8d
	movslq	%ecx, %rcx
	subl	%edx, %r8d
	addl	%r10d, %r8d
	movslq	%r8d, %r8
	movzbl	(%rdi,%r8), %r8d
	movb	%r8b, (%rsi,%rcx)
	leal	5(%rax), %ecx
	cmpl	%ecx, %edx
	jle	.L5
	movl	%ecx, %r8d
	addl	$6, %eax
	movslq	%ecx, %rcx
	subl	%edx, %r8d
	addl	%r10d, %r8d
	movslq	%r8d, %r8
	movzbl	(%rdi,%r8), %r8d
	movb	%r8b, (%rsi,%rcx)
	cmpl	%eax, %edx
	jle	.L5
	movl	%eax, %ecx
	cltq
	subl	%edx, %ecx
	leal	(%rcx,%r10), %edx
	movslq	%edx, %rdx
	movzbl	(%rdi,%rdx), %edx
	movb	%dl, (%rsi,%rax)
.L5:
	movb	$0, (%rsi,%r9)
	popq	%rbx
	.cfi_remember_state
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L6:
	.cfi_restore_state
	movl	%edx, %edx
	xorl	%eax, %eax
	addq	%rdi, %rcx
	.p2align 4,,10
	.p2align 3
.L12:
	movzbl	(%rcx,%rax), %edi
	movb	%dil, (%rsi,%rax)
	addq	$1, %rax
	cmpq	%rdx, %rax
	jne	.L12
	movb	$0, (%rsi,%r9)
	popq	%rbx
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L28:
	.cfi_restore 3
	movslq	%edx, %r9
	movb	$0, (%rsi,%r9)
	ret
.L14:
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	xorl	%r8d, %r8d
	xorl	%eax, %eax
	addq	%rdi, %rcx
	jmp	.L7
	.cfi_endproc
.LFE36:
	.size	substr, .-substr
	.section	.rodata.str1.1
.LC2:
	.string	"dream"
.LC3:
	.string	"dreamer"
.LC4:
	.string	"erase"
.LC5:
	.string	"eraser"
.LC7:
	.string	"%s"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB37:
	.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
	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	-98304(%rsp), %r11
	.cfi_def_cfa 11, 98360
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	.cfi_def_cfa_register 7
	subq	$1816, %rsp
	.cfi_def_cfa_offset 100176
	leaq	.LC2(%rip), %rcx
	leaq	.LC7(%rip), %rdi
	movq	%rcx, %xmm0
	leaq	.LC4(%rip), %rcx
	movq	%fs:40, %rax
	movq	%rax, 100104(%rsp)
	leaq	.LC3(%rip), %rax
	leaq	96(%rsp), %r12
	movq	%r12, %rsi
	movq	%rax, %xmm1
	leaq	.LC5(%rip), %rax
	punpcklqdq	%xmm1, %xmm0
	movq	%rax, %xmm2
	xorl	%eax, %eax
	movaps	%xmm0, 48(%rsp)
	movq	%rcx, %xmm0
	punpcklqdq	%xmm2, %xmm0
	movaps	%xmm0, 64(%rsp)
	movdqa	.LC6(%rip), %xmm0
	movaps	%xmm0, 32(%rsp)
	call	__isoc99_scanf@PLT
	movq	%r12, %rdi
	call	strlen@PLT
	movl	%eax, 28(%rsp)
	testq	%rax, %rax
	je	.L30
	leaq	32(%rsp), %rax
	leaq	48(%rsp), %r13
	movq	%rax, 8(%rsp)
	leaq	86(%rsp), %rbp
.L37:
	movslq	28(%rsp), %rax
	xorl	%r15d, %r15d
	movq	%rax, 16(%rsp)
.L35:
	movq	8(%rsp), %rax
	movl	(%rax,%r15,4), %ebx
	movslq	%ebx, %r14
	testl	%ebx, %ebx
	jle	.L34
	movq	16(%rsp), %rsi
	movq	%r14, %rdx
	movq	%rbp, %rdi
	subq	%r14, %rsi
	addq	%r12, %rsi
	call	memcpy@PLT
.L34:
	movq	0(%r13,%r15,8), %rsi
	movq	%rbp, %rdi
	movb	$0, 86(%rsp,%r14)
	call	strcmp@PLT
	testl	%eax, %eax
	je	.L49
	addq	$1, %r15
	cmpq	$4, %r15
	jne	.L35
	leaq	.LC1(%rip), %rdi
	call	puts@PLT
.L38:
	movq	100104(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L50
	addq	$100120, %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
.L49:
	.cfi_restore_state
	subl	%ebx, 28(%rsp)
	jne	.L37
.L30:
	leaq	.LC0(%rip), %rdi
	call	puts@PLT
	jmp	.L38
.L50:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE37:
	.size	main, .-main
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC6:
	.long	5
	.long	7
	.long	5
	.long	6
	.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	"YES"
.LC1:
	.string	"NO"
	.text
	.p2align 4
	.globl	yes_or_no
	.type	yes_or_no, @function
yes_or_no:
.LFB35:
	.cfi_startproc
	endbr64
	testb	%dil, %dil
	je	.L2
	leaq	.LC0(%rip), %rdi
	jmp	puts@PLT
	.p2align 4,,10
	.p2align 3
.L2:
	leaq	.LC1(%rip), %rdi
	jmp	puts@PLT
	.cfi_endproc
.LFE35:
	.size	yes_or_no, .-yes_or_no
	.p2align 4
	.globl	substr
	.type	substr, @function
substr:
.LFB36:
	.cfi_startproc
	endbr64
	testl	%edx, %edx
	jle	.L28
	movl	%ecx, %r10d
	movslq	%edx, %r9
	movslq	%ecx, %rcx
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	subq	%r9, %rcx
	movq	%rsi, %r8
	leal	-1(%rdx), %eax
	movl	%edx, %r11d
	leaq	1(%rdi,%rcx), %rbx
	subq	%rbx, %r8
	cmpq	$14, %r8
	jbe	.L6
	cmpl	$6, %eax
	jbe	.L6
	cmpl	$14, %eax
	jbe	.L14
	movl	%edx, %r8d
	addq	%rdi, %rcx
	xorl	%eax, %eax
	shrl	$4, %r8d
	salq	$4, %r8
	.p2align 4,,10
	.p2align 3
.L8:
	movdqu	(%rcx,%rax), %xmm0
	movups	%xmm0, (%rsi,%rax)
	addq	$16, %rax
	cmpq	%rax, %r8
	jne	.L8
	movl	%edx, %r8d
	andl	$-16, %r8d
	movl	%r8d, %eax
	cmpl	%r8d, %edx
	je	.L5
	movl	%edx, %r11d
	subl	%r8d, %r11d
	leal	-1(%r11), %ebx
	cmpl	$6, %ebx
	jbe	.L10
.L7:
	movq	(%rcx,%r8), %rcx
	movq	%rcx, (%rsi,%r8)
	movl	%r11d, %ecx
	andl	$-8, %ecx
	addl	%ecx, %eax
	cmpl	%ecx, %r11d
	je	.L5
.L10:
	movl	%eax, %ecx
	subl	%edx, %ecx
	addl	%r10d, %ecx
	movslq	%ecx, %rcx
	movzbl	(%rdi,%rcx), %r8d
	movslq	%eax, %rcx
	movb	%r8b, (%rsi,%rcx)
	leal	1(%rax), %ecx
	cmpl	%ecx, %edx
	jle	.L5
	movl	%ecx, %r8d
	movslq	%ecx, %rcx
	subl	%edx, %r8d
	addl	%r10d, %r8d
	movslq	%r8d, %r8
	movzbl	(%rdi,%r8), %r8d
	movb	%r8b, (%rsi,%rcx)
	leal	2(%rax), %ecx
	cmpl	%ecx, %edx
	jle	.L5
	movl	%ecx, %r8d
	movslq	%ecx, %rcx
	subl	%edx, %r8d
	addl	%r10d, %r8d
	movslq	%r8d, %r8
	movzbl	(%rdi,%r8), %r8d
	movb	%r8b, (%rsi,%rcx)
	leal	3(%rax), %ecx
	cmpl	%ecx, %edx
	jle	.L5
	movl	%ecx, %r8d
	movslq	%ecx, %rcx
	subl	%edx, %r8d
	addl	%r10d, %r8d
	movslq	%r8d, %r8
	movzbl	(%rdi,%r8), %r8d
	movb	%r8b, (%rsi,%rcx)
	leal	4(%rax), %ecx
	cmpl	%ecx, %edx
	jle	.L5
	movl	%ecx, %r8d
	movslq	%ecx, %rcx
	subl	%edx, %r8d
	addl	%r10d, %r8d
	movslq	%r8d, %r8
	movzbl	(%rdi,%r8), %r8d
	movb	%r8b, (%rsi,%rcx)
	leal	5(%rax), %ecx
	cmpl	%ecx, %edx
	jle	.L5
	movl	%ecx, %r8d
	addl	$6, %eax
	movslq	%ecx, %rcx
	subl	%edx, %r8d
	addl	%r10d, %r8d
	movslq	%r8d, %r8
	movzbl	(%rdi,%r8), %r8d
	movb	%r8b, (%rsi,%rcx)
	cmpl	%eax, %edx
	jle	.L5
	movl	%eax, %ecx
	cltq
	subl	%edx, %ecx
	leal	(%rcx,%r10), %edx
	movslq	%edx, %rdx
	movzbl	(%rdi,%rdx), %edx
	movb	%dl, (%rsi,%rax)
.L5:
	movb	$0, (%rsi,%r9)
	popq	%rbx
	.cfi_remember_state
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L6:
	.cfi_restore_state
	movl	%edx, %edx
	xorl	%eax, %eax
	addq	%rdi, %rcx
	.p2align 4,,10
	.p2align 3
.L12:
	movzbl	(%rcx,%rax), %edi
	movb	%dil, (%rsi,%rax)
	addq	$1, %rax
	cmpq	%rdx, %rax
	jne	.L12
	movb	$0, (%rsi,%r9)
	popq	%rbx
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L28:
	.cfi_restore 3
	movslq	%edx, %r9
	movb	$0, (%rsi,%r9)
	ret
.L14:
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	xorl	%r8d, %r8d
	xorl	%eax, %eax
	addq	%rdi, %rcx
	jmp	.L7
	.cfi_endproc
.LFE36:
	.size	substr, .-substr
	.section	.rodata.str1.1
.LC2:
	.string	"dream"
.LC3:
	.string	"dreamer"
.LC4:
	.string	"erase"
.LC5:
	.string	"eraser"
.LC7:
	.string	"%s"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB37:
	.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
	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	-98304(%rsp), %r11
	.cfi_def_cfa 11, 98360
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	.cfi_def_cfa_register 7
	subq	$1816, %rsp
	.cfi_def_cfa_offset 100176
	leaq	.LC2(%rip), %rcx
	leaq	.LC7(%rip), %rdi
	movq	%rcx, %xmm0
	leaq	.LC4(%rip), %rcx
	movq	%fs:40, %rax
	movq	%rax, 100104(%rsp)
	leaq	.LC3(%rip), %rax
	leaq	96(%rsp), %r12
	movq	%r12, %rsi
	movq	%rax, %xmm1
	leaq	.LC5(%rip), %rax
	punpcklqdq	%xmm1, %xmm0
	movq	%rax, %xmm2
	xorl	%eax, %eax
	movaps	%xmm0, 48(%rsp)
	movq	%rcx, %xmm0
	punpcklqdq	%xmm2, %xmm0
	movaps	%xmm0, 64(%rsp)
	movdqa	.LC6(%rip), %xmm0
	movaps	%xmm0, 32(%rsp)
	call	__isoc99_scanf@PLT
	movq	%r12, %rdi
	call	strlen@PLT
	movl	%eax, 28(%rsp)
	testq	%rax, %rax
	je	.L30
	leaq	32(%rsp), %rax
	leaq	48(%rsp), %r13
	movq	%rax, 8(%rsp)
	leaq	86(%rsp), %rbp
.L37:
	movslq	28(%rsp), %rax
	xorl	%r15d, %r15d
	movq	%rax, 16(%rsp)
.L35:
	movq	8(%rsp), %rax
	movl	(%rax,%r15,4), %ebx
	movslq	%ebx, %r14
	testl	%ebx, %ebx
	jle	.L34
	movq	16(%rsp), %rsi
	movq	%r14, %rdx
	movq	%rbp, %rdi
	subq	%r14, %rsi
	addq	%r12, %rsi
	call	memcpy@PLT
.L34:
	movq	0(%r13,%r15,8), %rsi
	movq	%rbp, %rdi
	movb	$0, 86(%rsp,%r14)
	call	strcmp@PLT
	testl	%eax, %eax
	je	.L49
	addq	$1, %r15
	cmpq	$4, %r15
	jne	.L35
	leaq	.LC1(%rip), %rdi
	call	puts@PLT
.L38:
	movq	100104(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L50
	addq	$100120, %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
.L49:
	.cfi_restore_state
	subl	%ebx, 28(%rsp)
	jne	.L37
.L30:
	leaq	.LC0(%rip), %rdi
	call	puts@PLT
	jmp	.L38
.L50:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE37:
	.size	main, .-main
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC6:
	.long	5
	.long	7
	.long	5
	.long	6
	.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>

#define FOR(i, a, b) for(i = a; i < b; ++i)
#define REP(i, n) FOR(i, 0, n)
#define comp(a, b) comp(const void *a, const void *b)
#define N 100000

typedef unsigned int uint;
typedef unsigned long ulong;
typedef unsigned long long ull;

void yes_or_no(char boolean){
    if(boolean){
        printf("YES\n");
    }else{
        printf("NO\n");
    }
}


void substr(char str[], char sub[], int num, int end){
    int i;
    REP(i, num){
        sub[i] = str[i - num + end];
    }
    sub[num] = '\0';
}


int main(){
    char str[N], sub[10];
    char* list[] = {"dream", "dreamer", "erase", "eraser"};
    int length[] = {5, 7, 5, 6};
    int sublen = 0;
    char boolean = 1, flag = 0;
    int i;
    scanf("%s", str);

    uint len = strlen(str);

    while(len > 0){
        REP(i, 4){
            substr(str, sub, length[i], len);
            if(strcmp(sub, list[i]) == 0){
                sublen = length[i];
                flag = 1;
                break;
            }
        }
        if(flag == 0){
            boolean = 0;
            break;
        }
        flag = 0;
        len -= sublen;
    }
    yes_or_no(boolean);
    return 0;
}
erasedream

YES

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>

#define FOR(i, a, b) for(i = a; i < b; ++i)
#define REP(i, n) FOR(i, 0, n)
#define comp(a, b) comp(const void *a, const void *b)
#define N 100000

typedef unsigned int uint;
typedef unsigned long ulong;
typedef unsigned long long ull;

void yes_or_no(char boolean){
    if(boolean){
        printf("YES\n");
    }else{
        printf("NO\n");
    }
}


void substr(char str[], char sub[], int num, int end){
    int i;
    REP(i, num){
        sub[i] = str[i - num + end];
    }
    sub[num] = '\0';
}


int main(){
    char str[N], sub[10];
    char* list[] = {"dream", "dreamer", "erase", "eraser"};
    int length[] = {5, 7, 5, 6};
    int sublen = 0;
    char boolean = 1, flag = 0;
    int i;
    scanf("%s", str);

    uint len = strlen(str);

    while(len > 0){
        REP(i, 4){
            substr(str, sub, length[i], len);
            if(strcmp(sub, list[i]) == 0){
                sublen = length[i];
                flag = 1;
                break;
            }
        }
        if(flag == 0){
            boolean = 0;
            break;
        }
        flag = 0;
        len -= sublen;
    }
    yes_or_no(boolean);
    return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"YES"
.LC1:
	.string	"NO"
	.text
	.globl	yes_or_no
	.type	yes_or_no, @function
yes_or_no:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$16, %rsp
	movl	%edi, %eax
	movb	%al, -4(%rbp)
	cmpb	$0, -4(%rbp)
	je	.L2
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	jmp	.L4
.L2:
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
.L4:
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	yes_or_no, .-yes_or_no
	.globl	substr
	.type	substr, @function
substr:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -24(%rbp)
	movq	%rsi, -32(%rbp)
	movl	%edx, -36(%rbp)
	movl	%ecx, -40(%rbp)
	movl	$0, -4(%rbp)
	jmp	.L6
.L7:
	movl	-4(%rbp), %eax
	subl	-36(%rbp), %eax
	movl	%eax, %edx
	movl	-40(%rbp), %eax
	addl	%edx, %eax
	movslq	%eax, %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	-4(%rbp), %edx
	movslq	%edx, %rcx
	movq	-32(%rbp), %rdx
	addq	%rcx, %rdx
	movzbl	(%rax), %eax
	movb	%al, (%rdx)
	addl	$1, -4(%rbp)
.L6:
	movl	-4(%rbp), %eax
	cmpl	-36(%rbp), %eax
	jl	.L7
	movl	-36(%rbp), %eax
	movslq	%eax, %rdx
	movq	-32(%rbp), %rax
	addq	%rdx, %rax
	movb	$0, (%rax)
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	substr, .-substr
	.section	.rodata
.LC2:
	.string	"dream"
.LC3:
	.string	"dreamer"
.LC4:
	.string	"erase"
.LC5:
	.string	"eraser"
.LC6:
	.string	"%s"
	.text
	.globl	main
	.type	main, @function
main:
.LFB2:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	leaq	-98304(%rsp), %r11
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	subq	$1792, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	.LC2(%rip), %rax
	movq	%rax, -100064(%rbp)
	leaq	.LC3(%rip), %rax
	movq	%rax, -100056(%rbp)
	leaq	.LC4(%rip), %rax
	movq	%rax, -100048(%rbp)
	leaq	.LC5(%rip), %rax
	movq	%rax, -100040(%rbp)
	movl	$5, -100080(%rbp)
	movl	$7, -100076(%rbp)
	movl	$5, -100072(%rbp)
	movl	$6, -100068(%rbp)
	movl	$0, -100092(%rbp)
	movb	$1, -100094(%rbp)
	movb	$0, -100093(%rbp)
	leaq	-100016(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC6(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	leaq	-100016(%rbp), %rax
	movq	%rax, %rdi
	call	strlen@PLT
	movl	%eax, -100084(%rbp)
	jmp	.L9
.L16:
	movl	$0, -100088(%rbp)
	jmp	.L10
.L13:
	movl	-100084(%rbp), %ecx
	movl	-100088(%rbp), %eax
	cltq
	movl	-100080(%rbp,%rax,4), %edx
	leaq	-100026(%rbp), %rsi
	leaq	-100016(%rbp), %rax
	movq	%rax, %rdi
	call	substr
	movl	-100088(%rbp), %eax
	cltq
	movq	-100064(%rbp,%rax,8), %rdx
	leaq	-100026(%rbp), %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L11
	movl	-100088(%rbp), %eax
	cltq
	movl	-100080(%rbp,%rax,4), %eax
	movl	%eax, -100092(%rbp)
	movb	$1, -100093(%rbp)
	jmp	.L12
.L11:
	addl	$1, -100088(%rbp)
.L10:
	cmpl	$3, -100088(%rbp)
	jle	.L13
.L12:
	cmpb	$0, -100093(%rbp)
	jne	.L14
	movb	$0, -100094(%rbp)
	jmp	.L15
.L14:
	movb	$0, -100093(%rbp)
	movl	-100092(%rbp), %eax
	subl	%eax, -100084(%rbp)
.L9:
	cmpl	$0, -100084(%rbp)
	jne	.L16
.L15:
	movsbl	-100094(%rbp), %eax
	movl	%eax, %edi
	call	yes_or_no
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L18
	call	__stack_chk_fail@PLT
.L18:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2:
	.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	"YES"
.LC1:
	.string	"NO"
	.text
	.globl	yes_or_no
	.type	yes_or_no, @function
yes_or_no:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$16, %rsp
	movl	%edi, %eax
	movb	%al, -4(%rbp)
	cmpb	$0, -4(%rbp)
	je	.L2
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	jmp	.L4
.L2:
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
.L4:
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	yes_or_no, .-yes_or_no
	.globl	substr
	.type	substr, @function
substr:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -24(%rbp)
	movq	%rsi, -32(%rbp)
	movl	%edx, -36(%rbp)
	movl	%ecx, -40(%rbp)
	movl	$0, -4(%rbp)
	jmp	.L6
.L7:
	movl	-4(%rbp), %eax
	subl	-36(%rbp), %eax
	movl	%eax, %edx
	movl	-40(%rbp), %eax
	addl	%edx, %eax
	movslq	%eax, %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	-4(%rbp), %edx
	movslq	%edx, %rcx
	movq	-32(%rbp), %rdx
	addq	%rcx, %rdx
	movzbl	(%rax), %eax
	movb	%al, (%rdx)
	addl	$1, -4(%rbp)
.L6:
	movl	-4(%rbp), %eax
	cmpl	-36(%rbp), %eax
	jl	.L7
	movl	-36(%rbp), %eax
	movslq	%eax, %rdx
	movq	-32(%rbp), %rax
	addq	%rdx, %rax
	movb	$0, (%rax)
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	substr, .-substr
	.section	.rodata
.LC2:
	.string	"dream"
.LC3:
	.string	"dreamer"
.LC4:
	.string	"erase"
.LC5:
	.string	"eraser"
.LC6:
	.string	"%s"
	.text
	.globl	main
	.type	main, @function
main:
.LFB2:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	leaq	-98304(%rsp), %r11
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	subq	$1792, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	.LC2(%rip), %rax
	movq	%rax, -100064(%rbp)
	leaq	.LC3(%rip), %rax
	movq	%rax, -100056(%rbp)
	leaq	.LC4(%rip), %rax
	movq	%rax, -100048(%rbp)
	leaq	.LC5(%rip), %rax
	movq	%rax, -100040(%rbp)
	movl	$5, -100080(%rbp)
	movl	$7, -100076(%rbp)
	movl	$5, -100072(%rbp)
	movl	$6, -100068(%rbp)
	movl	$0, -100092(%rbp)
	movb	$1, -100094(%rbp)
	movb	$0, -100093(%rbp)
	leaq	-100016(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC6(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	leaq	-100016(%rbp), %rax
	movq	%rax, %rdi
	call	strlen@PLT
	movl	%eax, -100084(%rbp)
	jmp	.L9
.L16:
	movl	$0, -100088(%rbp)
	jmp	.L10
.L13:
	movl	-100084(%rbp), %ecx
	movl	-100088(%rbp), %eax
	cltq
	movl	-100080(%rbp,%rax,4), %edx
	leaq	-100026(%rbp), %rsi
	leaq	-100016(%rbp), %rax
	movq	%rax, %rdi
	call	substr
	movl	-100088(%rbp), %eax
	cltq
	movq	-100064(%rbp,%rax,8), %rdx
	leaq	-100026(%rbp), %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L11
	movl	-100088(%rbp), %eax
	cltq
	movl	-100080(%rbp,%rax,4), %eax
	movl	%eax, -100092(%rbp)
	movb	$1, -100093(%rbp)
	jmp	.L12
.L11:
	addl	$1, -100088(%rbp)
.L10:
	cmpl	$3, -100088(%rbp)
	jle	.L13
.L12:
	cmpb	$0, -100093(%rbp)
	jne	.L14
	movb	$0, -100094(%rbp)
	jmp	.L15
.L14:
	movb	$0, -100093(%rbp)
	movl	-100092(%rbp), %eax
	subl	%eax, -100084(%rbp)
.L9:
	cmpl	$0, -100084(%rbp)
	jne	.L16
.L15:
	movsbl	-100094(%rbp), %eax
	movl	%eax, %edi
	call	yes_or_no
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L18
	call	__stack_chk_fail@PLT
.L18:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2:
	.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:
