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>

int varied(char *str)
{
	int i;
	int j;
	char temp;
	int flag;

	i = 0;
	flag = 0;
	while (str[i])
	{
		j = i + 1;
		while (str[j])
		{
			if (str[i] == str[j])
			{
				flag = 1;
				return (1);
			}
			j++;
		}
		i++;
	}
	return (0);
}

int		main(void)
{
	char s[27];
	int res;

	scanf("%s", s);
	res = varied(s);
	if (res == 1)
	{
		printf("no\n");
	}
	else if(res == 0)
	{
		printf("yes\n");
	}
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	varied
	.type	varied, @function
varied:
.LFB0:
	.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)
	movl	$0, -12(%rbp)
	movl	$0, -4(%rbp)
	jmp	.L2
.L7:
	movl	-12(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -8(%rbp)
	jmp	.L3
.L6:
	movl	-12(%rbp), %eax
	movslq	%eax, %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %edx
	movl	-8(%rbp), %eax
	movslq	%eax, %rcx
	movq	-24(%rbp), %rax
	addq	%rcx, %rax
	movzbl	(%rax), %eax
	cmpb	%al, %dl
	jne	.L4
	movl	$1, -4(%rbp)
	movl	$1, %eax
	jmp	.L5
.L4:
	addl	$1, -8(%rbp)
.L3:
	movl	-8(%rbp), %eax
	movslq	%eax, %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	testb	%al, %al
	jne	.L6
	addl	$1, -12(%rbp)
.L2:
	movl	-12(%rbp), %eax
	movslq	%eax, %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	testb	%al, %al
	jne	.L7
	movl	$0, %eax
.L5:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	varied, .-varied
	.section	.rodata
.LC0:
	.string	"%s"
.LC1:
	.string	"no"
.LC2:
	.string	"yes"
	.text
	.globl	main
	.type	main, @function
main:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$64, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-48(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	leaq	-48(%rbp), %rax
	movq	%rax, %rdi
	call	varied
	movl	%eax, -52(%rbp)
	cmpl	$1, -52(%rbp)
	jne	.L9
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	jmp	.L10
.L9:
	cmpl	$0, -52(%rbp)
	jne	.L10
	leaq	.LC2(%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
.LFE1:
	.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
	.p2align 4
	.globl	varied
	.type	varied, @function
varied:
.LFB23:
	.cfi_startproc
	endbr64
	movzbl	(%rdi), %ecx
	testb	%cl, %cl
	je	.L7
	leaq	1(%rdi), %rsi
	movzbl	(%rsi), %edi
	testb	%dil, %dil
	je	.L7
.L14:
	movq	%rsi, %rdx
	movl	%edi, %eax
	jmp	.L3
	.p2align 4,,10
	.p2align 3
.L13:
	movzbl	1(%rdx), %eax
	addq	$1, %rdx
	testb	%al, %al
	je	.L12
.L3:
	cmpb	%cl, %al
	jne	.L13
	movl	$1, %eax
	ret
	.p2align 4,,10
	.p2align 3
.L12:
	addq	$1, %rsi
	movl	%edi, %ecx
	movzbl	(%rsi), %edi
	testb	%dil, %dil
	jne	.L14
.L7:
	xorl	%eax, %eax
	ret
	.cfi_endproc
.LFE23:
	.size	varied, .-varied
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%s"
.LC1:
	.string	"no"
.LC2:
	.string	"yes"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB24:
	.cfi_startproc
	endbr64
	subq	$56, %rsp
	.cfi_def_cfa_offset 64
	leaq	.LC0(%rip), %rdi
	movq	%fs:40, %rax
	movq	%rax, 40(%rsp)
	xorl	%eax, %eax
	movq	%rsp, %rsi
	call	__isoc99_scanf@PLT
	movzbl	(%rsp), %ecx
	testb	%cl, %cl
	je	.L16
	movzbl	1(%rsp), %esi
	leaq	2(%rsp), %rdi
	testb	%sil, %sil
	je	.L16
.L35:
	movq	%rdi, %rdx
	movl	%esi, %eax
	jmp	.L18
	.p2align 4,,10
	.p2align 3
.L34:
	movzbl	(%rdx), %eax
	addq	$1, %rdx
	testb	%al, %al
	je	.L33
.L18:
	cmpb	%cl, %al
	jne	.L34
	leaq	.LC1(%rip), %rdi
	call	puts@PLT
	jmp	.L20
	.p2align 4,,10
	.p2align 3
.L33:
	addq	$1, %rdi
	movl	%esi, %ecx
	movzbl	-1(%rdi), %esi
	testb	%sil, %sil
	jne	.L35
.L16:
	leaq	.LC2(%rip), %rdi
	call	puts@PLT
.L20:
	movq	40(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L36
	xorl	%eax, %eax
	addq	$56, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 8
	ret
.L36:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE24:
	.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
	.p2align 4
	.globl	varied
	.type	varied, @function
varied:
.LFB23:
	.cfi_startproc
	endbr64
	movzbl	(%rdi), %ecx
	testb	%cl, %cl
	je	.L7
	leaq	1(%rdi), %rsi
	movzbl	(%rsi), %edi
	testb	%dil, %dil
	je	.L7
.L14:
	movq	%rsi, %rdx
	movl	%edi, %eax
	jmp	.L3
	.p2align 4,,10
	.p2align 3
.L13:
	movzbl	1(%rdx), %eax
	addq	$1, %rdx
	testb	%al, %al
	je	.L12
.L3:
	cmpb	%cl, %al
	jne	.L13
	movl	$1, %eax
	ret
	.p2align 4,,10
	.p2align 3
.L12:
	addq	$1, %rsi
	movl	%edi, %ecx
	movzbl	(%rsi), %edi
	testb	%dil, %dil
	jne	.L14
.L7:
	xorl	%eax, %eax
	ret
	.cfi_endproc
.LFE23:
	.size	varied, .-varied
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%s"
.LC1:
	.string	"no"
.LC2:
	.string	"yes"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB24:
	.cfi_startproc
	endbr64
	subq	$56, %rsp
	.cfi_def_cfa_offset 64
	leaq	.LC0(%rip), %rdi
	movq	%fs:40, %rax
	movq	%rax, 40(%rsp)
	xorl	%eax, %eax
	movq	%rsp, %rsi
	call	__isoc99_scanf@PLT
	movzbl	(%rsp), %ecx
	testb	%cl, %cl
	je	.L16
	movzbl	1(%rsp), %esi
	leaq	2(%rsp), %rdi
	testb	%sil, %sil
	je	.L16
.L35:
	movq	%rdi, %rdx
	movl	%esi, %eax
	jmp	.L18
	.p2align 4,,10
	.p2align 3
.L34:
	movzbl	(%rdx), %eax
	addq	$1, %rdx
	testb	%al, %al
	je	.L33
.L18:
	cmpb	%cl, %al
	jne	.L34
	leaq	.LC1(%rip), %rdi
	call	puts@PLT
	jmp	.L20
	.p2align 4,,10
	.p2align 3
.L33:
	addq	$1, %rdi
	movl	%esi, %ecx
	movzbl	-1(%rdi), %esi
	testb	%sil, %sil
	jne	.L35
.L16:
	leaq	.LC2(%rip), %rdi
	call	puts@PLT
.L20:
	movq	40(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L36
	xorl	%eax, %eax
	addq	$56, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 8
	ret
.L36:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE24:
	.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>

int varied(char *str)
{
	int i;
	int j;
	char temp;
	int flag;

	i = 0;
	flag = 0;
	while (str[i])
	{
		j = i + 1;
		while (str[j])
		{
			if (str[i] == str[j])
			{
				flag = 1;
				return (1);
			}
			j++;
		}
		i++;
	}
	return (0);
}

int		main(void)
{
	char s[27];
	int res;

	scanf("%s", s);
	res = varied(s);
	if (res == 1)
	{
		printf("no\n");
	}
	else if(res == 0)
	{
		printf("yes\n");
	}
}
uncopyrightacle
 np
 tnereffid
 elcathgirypocnu
 dnereffit
 mp
 elcathgirxpocnu
 enereffit
 pm
 elcathgiqxpocnu

no
 yes
 no
 no
 no
 yes
 no
 no
 yes
 no

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>

int varied(char *str)
{
	int i;
	int j;
	char temp;
	int flag;

	i = 0;
	flag = 0;
	while (str[i])
	{
		j = i + 1;
		while (str[j])
		{
			if (str[i] == str[j])
			{
				flag = 1;
				return (1);
			}
			j++;
		}
		i++;
	}
	return (0);
}

int		main(void)
{
	char s[27];
	int res;

	scanf("%s", s);
	res = varied(s);
	if (res == 1)
	{
		printf("no\n");
	}
	else if(res == 0)
	{
		printf("yes\n");
	}
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	varied
	.type	varied, @function
varied:
.LFB0:
	.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)
	movl	$0, -12(%rbp)
	movl	$0, -4(%rbp)
	jmp	.L2
.L7:
	movl	-12(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -8(%rbp)
	jmp	.L3
.L6:
	movl	-12(%rbp), %eax
	movslq	%eax, %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %edx
	movl	-8(%rbp), %eax
	movslq	%eax, %rcx
	movq	-24(%rbp), %rax
	addq	%rcx, %rax
	movzbl	(%rax), %eax
	cmpb	%al, %dl
	jne	.L4
	movl	$1, -4(%rbp)
	movl	$1, %eax
	jmp	.L5
.L4:
	addl	$1, -8(%rbp)
.L3:
	movl	-8(%rbp), %eax
	movslq	%eax, %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	testb	%al, %al
	jne	.L6
	addl	$1, -12(%rbp)
.L2:
	movl	-12(%rbp), %eax
	movslq	%eax, %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	testb	%al, %al
	jne	.L7
	movl	$0, %eax
.L5:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	varied, .-varied
	.section	.rodata
.LC0:
	.string	"%s"
.LC1:
	.string	"no"
.LC2:
	.string	"yes"
	.text
	.globl	main
	.type	main, @function
main:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$64, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-48(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	leaq	-48(%rbp), %rax
	movq	%rax, %rdi
	call	varied
	movl	%eax, -52(%rbp)
	cmpl	$1, -52(%rbp)
	jne	.L9
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	jmp	.L10
.L9:
	cmpl	$0, -52(%rbp)
	jne	.L10
	leaq	.LC2(%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
.LFE1:
	.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
	.globl	varied
	.type	varied, @function
varied:
.LFB0:
	.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)
	movl	$0, -12(%rbp)
	movl	$0, -4(%rbp)
	jmp	.L2
.L7:
	movl	-12(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -8(%rbp)
	jmp	.L3
.L6:
	movl	-12(%rbp), %eax
	movslq	%eax, %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %edx
	movl	-8(%rbp), %eax
	movslq	%eax, %rcx
	movq	-24(%rbp), %rax
	addq	%rcx, %rax
	movzbl	(%rax), %eax
	cmpb	%al, %dl
	jne	.L4
	movl	$1, -4(%rbp)
	movl	$1, %eax
	jmp	.L5
.L4:
	addl	$1, -8(%rbp)
.L3:
	movl	-8(%rbp), %eax
	movslq	%eax, %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	testb	%al, %al
	jne	.L6
	addl	$1, -12(%rbp)
.L2:
	movl	-12(%rbp), %eax
	movslq	%eax, %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	testb	%al, %al
	jne	.L7
	movl	$0, %eax
.L5:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	varied, .-varied
	.section	.rodata
.LC0:
	.string	"%s"
.LC1:
	.string	"no"
.LC2:
	.string	"yes"
	.text
	.globl	main
	.type	main, @function
main:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$64, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-48(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	leaq	-48(%rbp), %rax
	movq	%rax, %rdi
	call	varied
	movl	%eax, -52(%rbp)
	cmpl	$1, -52(%rbp)
	jne	.L9
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	jmp	.L10
.L9:
	cmpl	$0, -52(%rbp)
	jne	.L10
	leaq	.LC2(%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
.LFE1:
	.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:
