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(void) {
	char str[1001], tmp[1001], in[10];
	int q, a, b;
	int i;

	scanf("%s", str);
	scanf("%d", &q);

	while (q--) {
		scanf("%s %d %d", in, &a, &b);
		if (strcmp(in, "print") == 0) {
			for (i = a; i <= b; i++) putchar(str[i]);
			puts("");
		}
		else if (strcmp(in, "replace") == 0) {
			scanf("%s", tmp);
			strncpy(&str[a], tmp, b - a + 1);
		}
		else {
			strcpy(tmp, str);
			for (i = 0; i <= b - a; i++) tmp[a + i] = str[b - i];
			strcpy(str, tmp);
		}
	}

	return 0;
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%s"
.LC1:
	.string	"%d"
.LC2:
	.string	"%s %d %d"
.LC3:
	.string	"print"
.LC4:
	.string	""
.LC5:
	.string	"replace"
	.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	$2064, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-2032(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	leaq	-2060(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	jmp	.L2
.L9:
	leaq	-2052(%rbp), %rcx
	leaq	-2056(%rbp), %rdx
	leaq	-2042(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	leaq	-2042(%rbp), %rax
	leaq	.LC3(%rip), %rdx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L3
	movl	-2056(%rbp), %eax
	movl	%eax, -2048(%rbp)
	jmp	.L4
.L5:
	movl	-2048(%rbp), %eax
	cltq
	movzbl	-2032(%rbp,%rax), %eax
	movsbl	%al, %eax
	movl	%eax, %edi
	call	putchar@PLT
	addl	$1, -2048(%rbp)
.L4:
	movl	-2052(%rbp), %eax
	cmpl	%eax, -2048(%rbp)
	jle	.L5
	leaq	.LC4(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	jmp	.L2
.L3:
	leaq	-2042(%rbp), %rax
	leaq	.LC5(%rip), %rdx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L6
	leaq	-1024(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-2052(%rbp), %eax
	movl	-2056(%rbp), %edx
	subl	%edx, %eax
	addl	$1, %eax
	movslq	%eax, %rdx
	movl	-2056(%rbp), %eax
	leaq	-2032(%rbp), %rcx
	cltq
	addq	%rax, %rcx
	leaq	-1024(%rbp), %rax
	movq	%rax, %rsi
	movq	%rcx, %rdi
	call	strncpy@PLT
	jmp	.L2
.L6:
	leaq	-2032(%rbp), %rdx
	leaq	-1024(%rbp), %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strcpy@PLT
	movl	$0, -2048(%rbp)
	jmp	.L7
.L8:
	movl	-2052(%rbp), %eax
	subl	-2048(%rbp), %eax
	movl	-2056(%rbp), %ecx
	movl	-2048(%rbp), %edx
	addl	%edx, %ecx
	cltq
	movzbl	-2032(%rbp,%rax), %edx
	movslq	%ecx, %rax
	movb	%dl, -1024(%rbp,%rax)
	addl	$1, -2048(%rbp)
.L7:
	movl	-2052(%rbp), %eax
	movl	-2056(%rbp), %edx
	subl	%edx, %eax
	cmpl	%eax, -2048(%rbp)
	jle	.L8
	leaq	-1024(%rbp), %rdx
	leaq	-2032(%rbp), %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strcpy@PLT
.L2:
	movl	-2060(%rbp), %eax
	leal	-1(%rax), %edx
	movl	%edx, -2060(%rbp)
	testl	%eax, %eax
	jne	.L9
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L11
	call	__stack_chk_fail@PLT
.L11:
	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	"%s"
.LC1:
	.string	"%d"
.LC2:
	.string	"%s %d %d"
.LC3:
	.string	"print"
.LC4:
	.string	""
.LC5:
	.string	"replace"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB35:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	.LC0(%rip), %rdi
	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
	subq	$2088, %rsp
	.cfi_def_cfa_offset 2144
	movq	%fs:40, %rax
	movq	%rax, 2072(%rsp)
	xorl	%eax, %eax
	leaq	48(%rsp), %rbx
	movq	%rbx, %rsi
	call	__isoc99_scanf@PLT
	leaq	24(%rsp), %rsi
	leaq	.LC1(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	24(%rsp), %eax
	leal	-1(%rax), %edx
	movl	%edx, 24(%rsp)
	testl	%eax, %eax
	je	.L2
	leaq	47(%rsp), %rax
	leaq	32(%rsp), %r15
	movq	%rax, 8(%rsp)
	leaq	28(%rsp), %r14
	leaq	38(%rsp), %rbp
	leaq	1056(%rsp), %r12
	.p2align 4,,10
	.p2align 3
.L14:
	xorl	%eax, %eax
	movq	%r15, %rcx
	movq	%r14, %rdx
	movq	%rbp, %rsi
	leaq	.LC2(%rip), %rdi
	call	__isoc99_scanf@PLT
	cmpl	$1852404336, 0(%rbp)
	je	.L26
.L3:
	movabsq	$28538242730059122, %rax
	cmpq	%rax, 0(%rbp)
	je	.L27
	movq	%rbx, %rsi
	movl	$1001, %edx
	movq	%r12, %rdi
	call	__strcpy_chk@PLT
	movslq	32(%rsp), %rcx
	movslq	28(%rsp), %rax
	movl	%ecx, %esi
	subl	%eax, %esi
	js	.L12
	leaq	(%rbx,%rcx), %rdx
	movslq	%esi, %rsi
	addq	8(%rsp), %rcx
	addq	%r12, %rax
	subq	%rsi, %rcx
	.p2align 4,,10
	.p2align 3
.L13:
	movzbl	(%rdx), %esi
	subq	$1, %rdx
	addq	$1, %rax
	movb	%sil, -1(%rax)
	cmpq	%rcx, %rdx
	jne	.L13
.L12:
	movl	$1001, %edx
	movq	%r12, %rsi
	movq	%rbx, %rdi
	call	__strcpy_chk@PLT
.L8:
	movl	24(%rsp), %eax
	leal	-1(%rax), %edx
	movl	%edx, 24(%rsp)
	testl	%eax, %eax
	jne	.L14
.L2:
	movq	2072(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L28
	addq	$2088, %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
	.p2align 4,,10
	.p2align 3
.L26:
	.cfi_restore_state
	cmpw	$116, 4(%rbp)
	jne	.L3
	movl	28(%rsp), %edx
	movslq	%edx, %r13
	cmpl	32(%rsp), %edx
	jg	.L6
	.p2align 4,,10
	.p2align 3
.L7:
	movsbl	(%rbx,%r13), %edi
	movq	stdout(%rip), %rsi
	addq	$1, %r13
	call	putc@PLT
	cmpl	%r13d, 32(%rsp)
	jge	.L7
.L6:
	leaq	.LC4(%rip), %rdi
	call	puts@PLT
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L27:
	movq	%r12, %rsi
	leaq	.LC0(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movslq	28(%rsp), %rdi
	movl	32(%rsp), %edx
	movq	%r12, %rsi
	subl	%edi, %edx
	addq	%rbx, %rdi
	addl	$1, %edx
	movslq	%edx, %rdx
	call	strncpy@PLT
	jmp	.L8
.L28:
	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	"%s"
.LC1:
	.string	"%d"
.LC2:
	.string	"%s %d %d"
.LC3:
	.string	"print"
.LC4:
	.string	""
.LC5:
	.string	"replace"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB35:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	.LC0(%rip), %rdi
	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
	subq	$2088, %rsp
	.cfi_def_cfa_offset 2144
	movq	%fs:40, %rax
	movq	%rax, 2072(%rsp)
	xorl	%eax, %eax
	leaq	48(%rsp), %rbx
	movq	%rbx, %rsi
	call	__isoc99_scanf@PLT
	leaq	24(%rsp), %rsi
	leaq	.LC1(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	24(%rsp), %eax
	leal	-1(%rax), %edx
	movl	%edx, 24(%rsp)
	testl	%eax, %eax
	je	.L2
	leaq	47(%rsp), %rax
	leaq	32(%rsp), %r15
	movq	%rax, 8(%rsp)
	leaq	28(%rsp), %r14
	leaq	38(%rsp), %rbp
	leaq	1056(%rsp), %r12
	.p2align 4,,10
	.p2align 3
.L14:
	xorl	%eax, %eax
	movq	%r15, %rcx
	movq	%r14, %rdx
	movq	%rbp, %rsi
	leaq	.LC2(%rip), %rdi
	call	__isoc99_scanf@PLT
	cmpl	$1852404336, 0(%rbp)
	je	.L26
.L3:
	movabsq	$28538242730059122, %rax
	cmpq	%rax, 0(%rbp)
	je	.L27
	movq	%rbx, %rsi
	movl	$1001, %edx
	movq	%r12, %rdi
	call	__strcpy_chk@PLT
	movslq	32(%rsp), %rcx
	movslq	28(%rsp), %rax
	movl	%ecx, %esi
	subl	%eax, %esi
	js	.L12
	leaq	(%rbx,%rcx), %rdx
	movslq	%esi, %rsi
	addq	8(%rsp), %rcx
	addq	%r12, %rax
	subq	%rsi, %rcx
	.p2align 4,,10
	.p2align 3
.L13:
	movzbl	(%rdx), %esi
	subq	$1, %rdx
	addq	$1, %rax
	movb	%sil, -1(%rax)
	cmpq	%rcx, %rdx
	jne	.L13
.L12:
	movl	$1001, %edx
	movq	%r12, %rsi
	movq	%rbx, %rdi
	call	__strcpy_chk@PLT
.L8:
	movl	24(%rsp), %eax
	leal	-1(%rax), %edx
	movl	%edx, 24(%rsp)
	testl	%eax, %eax
	jne	.L14
.L2:
	movq	2072(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L28
	addq	$2088, %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
	.p2align 4,,10
	.p2align 3
.L26:
	.cfi_restore_state
	cmpw	$116, 4(%rbp)
	jne	.L3
	movl	28(%rsp), %edx
	movslq	%edx, %r13
	cmpl	32(%rsp), %edx
	jg	.L6
	.p2align 4,,10
	.p2align 3
.L7:
	movsbl	(%rbx,%r13), %edi
	movq	stdout(%rip), %rsi
	addq	$1, %r13
	call	putc@PLT
	cmpl	%r13d, 32(%rsp)
	jge	.L7
.L6:
	leaq	.LC4(%rip), %rdi
	call	puts@PLT
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L27:
	movq	%r12, %rsi
	leaq	.LC0(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movslq	28(%rsp), %rdi
	movl	32(%rsp), %edx
	movq	%r12, %rsi
	subl	%edi, %edx
	addq	%rbx, %rdi
	addl	$1, %edx
	movslq	%edx, %rdx
	call	strncpy@PLT
	jmp	.L8
.L28:
	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(void) {
	char str[1001], tmp[1001], in[10];
	int q, a, b;
	int i;

	scanf("%s", str);
	scanf("%d", &q);

	while (q--) {
		scanf("%s %d %d", in, &a, &b);
		if (strcmp(in, "print") == 0) {
			for (i = a; i <= b; i++) putchar(str[i]);
			puts("");
		}
		else if (strcmp(in, "replace") == 0) {
			scanf("%s", tmp);
			strncpy(&str[a], tmp, b - a + 1);
		}
		else {
			strcpy(tmp, str);
			for (i = 0; i <= b - a; i++) tmp[a + i] = str[b - i];
			strcpy(str, tmp);
		}
	}

	return 0;
}

abcde
3
replace 1 3 xy{
reverse 0 2
print 1 4
 xyz
3
print 0 2
replace 1 2 abc
print 0 2
 abcde
3
replace 1 3 xy{
reverse 0 2
print 1 2
 abcde
3
replace 1 3 yy{
reverse 0 2
print 1 2
 abcde
3
replace 1 3 yy{
reverse 0 2
print 1 1
 xyz
1
print 0 2
replace 0 2 abc
print 0 2
 abcde
3
replace 1 3 xy{
reverse 0 2
print 1 3
 xyz
3
print 0 1
replace 1 2 abc
print 0 2
 abcde
3
replace 1 3 yy{
reverse -1 2
print 1 2
 abcde
3
replace 1 3 xy{
reverse 0 2
print 1 1

xa{e
 xyz
xab
 xa
 ya
 y
 xyz
 xa{
 xy
xab
 a
 x

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(void) {
	char str[1001], tmp[1001], in[10];
	int q, a, b;
	int i;

	scanf("%s", str);
	scanf("%d", &q);

	while (q--) {
		scanf("%s %d %d", in, &a, &b);
		if (strcmp(in, "print") == 0) {
			for (i = a; i <= b; i++) putchar(str[i]);
			puts("");
		}
		else if (strcmp(in, "replace") == 0) {
			scanf("%s", tmp);
			strncpy(&str[a], tmp, b - a + 1);
		}
		else {
			strcpy(tmp, str);
			for (i = 0; i <= b - a; i++) tmp[a + i] = str[b - i];
			strcpy(str, tmp);
		}
	}

	return 0;
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%s"
.LC1:
	.string	"%d"
.LC2:
	.string	"%s %d %d"
.LC3:
	.string	"print"
.LC4:
	.string	""
.LC5:
	.string	"replace"
	.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	$2064, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-2032(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	leaq	-2060(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	jmp	.L2
.L9:
	leaq	-2052(%rbp), %rcx
	leaq	-2056(%rbp), %rdx
	leaq	-2042(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	leaq	-2042(%rbp), %rax
	leaq	.LC3(%rip), %rdx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L3
	movl	-2056(%rbp), %eax
	movl	%eax, -2048(%rbp)
	jmp	.L4
.L5:
	movl	-2048(%rbp), %eax
	cltq
	movzbl	-2032(%rbp,%rax), %eax
	movsbl	%al, %eax
	movl	%eax, %edi
	call	putchar@PLT
	addl	$1, -2048(%rbp)
.L4:
	movl	-2052(%rbp), %eax
	cmpl	%eax, -2048(%rbp)
	jle	.L5
	leaq	.LC4(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	jmp	.L2
.L3:
	leaq	-2042(%rbp), %rax
	leaq	.LC5(%rip), %rdx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L6
	leaq	-1024(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-2052(%rbp), %eax
	movl	-2056(%rbp), %edx
	subl	%edx, %eax
	addl	$1, %eax
	movslq	%eax, %rdx
	movl	-2056(%rbp), %eax
	leaq	-2032(%rbp), %rcx
	cltq
	addq	%rax, %rcx
	leaq	-1024(%rbp), %rax
	movq	%rax, %rsi
	movq	%rcx, %rdi
	call	strncpy@PLT
	jmp	.L2
.L6:
	leaq	-2032(%rbp), %rdx
	leaq	-1024(%rbp), %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strcpy@PLT
	movl	$0, -2048(%rbp)
	jmp	.L7
.L8:
	movl	-2052(%rbp), %eax
	subl	-2048(%rbp), %eax
	movl	-2056(%rbp), %ecx
	movl	-2048(%rbp), %edx
	addl	%edx, %ecx
	cltq
	movzbl	-2032(%rbp,%rax), %edx
	movslq	%ecx, %rax
	movb	%dl, -1024(%rbp,%rax)
	addl	$1, -2048(%rbp)
.L7:
	movl	-2052(%rbp), %eax
	movl	-2056(%rbp), %edx
	subl	%edx, %eax
	cmpl	%eax, -2048(%rbp)
	jle	.L8
	leaq	-1024(%rbp), %rdx
	leaq	-2032(%rbp), %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strcpy@PLT
.L2:
	movl	-2060(%rbp), %eax
	leal	-1(%rax), %edx
	movl	%edx, -2060(%rbp)
	testl	%eax, %eax
	jne	.L9
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L11
	call	__stack_chk_fail@PLT
.L11:
	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	"%s"
.LC1:
	.string	"%d"
.LC2:
	.string	"%s %d %d"
.LC3:
	.string	"print"
.LC4:
	.string	""
.LC5:
	.string	"replace"
	.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	$2064, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-2032(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	leaq	-2060(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	jmp	.L2
.L9:
	leaq	-2052(%rbp), %rcx
	leaq	-2056(%rbp), %rdx
	leaq	-2042(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	leaq	-2042(%rbp), %rax
	leaq	.LC3(%rip), %rdx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L3
	movl	-2056(%rbp), %eax
	movl	%eax, -2048(%rbp)
	jmp	.L4
.L5:
	movl	-2048(%rbp), %eax
	cltq
	movzbl	-2032(%rbp,%rax), %eax
	movsbl	%al, %eax
	movl	%eax, %edi
	call	putchar@PLT
	addl	$1, -2048(%rbp)
.L4:
	movl	-2052(%rbp), %eax
	cmpl	%eax, -2048(%rbp)
	jle	.L5
	leaq	.LC4(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	jmp	.L2
.L3:
	leaq	-2042(%rbp), %rax
	leaq	.LC5(%rip), %rdx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L6
	leaq	-1024(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-2052(%rbp), %eax
	movl	-2056(%rbp), %edx
	subl	%edx, %eax
	addl	$1, %eax
	movslq	%eax, %rdx
	movl	-2056(%rbp), %eax
	leaq	-2032(%rbp), %rcx
	cltq
	addq	%rax, %rcx
	leaq	-1024(%rbp), %rax
	movq	%rax, %rsi
	movq	%rcx, %rdi
	call	strncpy@PLT
	jmp	.L2
.L6:
	leaq	-2032(%rbp), %rdx
	leaq	-1024(%rbp), %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strcpy@PLT
	movl	$0, -2048(%rbp)
	jmp	.L7
.L8:
	movl	-2052(%rbp), %eax
	subl	-2048(%rbp), %eax
	movl	-2056(%rbp), %ecx
	movl	-2048(%rbp), %edx
	addl	%edx, %ecx
	cltq
	movzbl	-2032(%rbp,%rax), %edx
	movslq	%ecx, %rax
	movb	%dl, -1024(%rbp,%rax)
	addl	$1, -2048(%rbp)
.L7:
	movl	-2052(%rbp), %eax
	movl	-2056(%rbp), %edx
	subl	%edx, %eax
	cmpl	%eax, -2048(%rbp)
	jle	.L8
	leaq	-1024(%rbp), %rdx
	leaq	-2032(%rbp), %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strcpy@PLT
.L2:
	movl	-2060(%rbp), %eax
	leal	-1(%rax), %edx
	movl	%edx, -2060(%rbp)
	testl	%eax, %eax
	jne	.L9
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L11
	call	__stack_chk_fail@PLT
.L11:
	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:
