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 MAX 1000
#define OP  10

void Print(char S[], int x, int y);
void Reverse(char S[], int x, int y);
void Replace(char S[], char P[], int x, int y);

int main(void) {
  char str[MAX];
  char op[OP];
  char p[MAX];
  int q;
  int i = 0;
  int a, b;

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

  while(i < q) {
    scanf("%s", op);
    scanf("%d %d", &a, &b);

    if(strcmp(op, "print") == 0) {
      Print(str, a, b);
    }
    else if(strcmp(op, "reverse") == 0) {
      Reverse(str, a, b);
    }
    else if(strcmp(op, "replace") == 0) {
      scanf("%s", p);
      Replace(str, p, a, b);
    }
    i++;
  }

  return 0;
}

void Print(char S[], int x, int y) {

  for(int i=x; i<= y; ++i) {
    printf("%c", S[i]);
  }
  printf("\n");
}

void Reverse(char S[], int x, int y) {
  char tmp;
  int i = x;
  int j = y;

  while (i <= (x+y)/2) {
    tmp = S[i];
    S[i] = S[j];
    S[j] = tmp;
    i++;
    j--;
  }
}

void Replace(char S[], char P[], int x, int y) {
  int i=x, j=0;

  while(i <= y) {
    S[i++] = P[j++];
  }
}

```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%s"
.LC1:
	.string	"%d"
.LC2:
	.string	"%d %d"
.LC3:
	.string	"print"
.LC4:
	.string	"reverse"
.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	$2048, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -2032(%rbp)
	leaq	-2016(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	leaq	-2044(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	jmp	.L2
.L6:
	leaq	-2026(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	leaq	-2036(%rbp), %rdx
	leaq	-2040(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	leaq	-2026(%rbp), %rax
	leaq	.LC3(%rip), %rdx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L3
	movl	-2036(%rbp), %edx
	movl	-2040(%rbp), %ecx
	leaq	-2016(%rbp), %rax
	movl	%ecx, %esi
	movq	%rax, %rdi
	call	Print
	jmp	.L4
.L3:
	leaq	-2026(%rbp), %rax
	leaq	.LC4(%rip), %rdx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L5
	movl	-2036(%rbp), %edx
	movl	-2040(%rbp), %ecx
	leaq	-2016(%rbp), %rax
	movl	%ecx, %esi
	movq	%rax, %rdi
	call	Reverse
	jmp	.L4
.L5:
	leaq	-2026(%rbp), %rax
	leaq	.LC5(%rip), %rdx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L4
	leaq	-1008(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-2036(%rbp), %ecx
	movl	-2040(%rbp), %edx
	leaq	-1008(%rbp), %rsi
	leaq	-2016(%rbp), %rax
	movq	%rax, %rdi
	call	Replace
.L4:
	addl	$1, -2032(%rbp)
.L2:
	movl	-2044(%rbp), %eax
	cmpl	%eax, -2032(%rbp)
	jl	.L6
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L8
	call	__stack_chk_fail@PLT
.L8:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.globl	Print
	.type	Print, @function
Print:
.LFB1:
	.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	%rdi, -24(%rbp)
	movl	%esi, -28(%rbp)
	movl	%edx, -32(%rbp)
	movl	-28(%rbp), %eax
	movl	%eax, -4(%rbp)
	jmp	.L10
.L11:
	movl	-4(%rbp), %eax
	movslq	%eax, %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	movsbl	%al, %eax
	movl	%eax, %edi
	call	putchar@PLT
	addl	$1, -4(%rbp)
.L10:
	movl	-4(%rbp), %eax
	cmpl	-32(%rbp), %eax
	jle	.L11
	movl	$10, %edi
	call	putchar@PLT
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	Print, .-Print
	.globl	Reverse
	.type	Reverse, @function
Reverse:
.LFB2:
	.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	%esi, -28(%rbp)
	movl	%edx, -32(%rbp)
	movl	-28(%rbp), %eax
	movl	%eax, -8(%rbp)
	movl	-32(%rbp), %eax
	movl	%eax, -4(%rbp)
	jmp	.L13
.L14:
	movl	-8(%rbp), %eax
	movslq	%eax, %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	movb	%al, -9(%rbp)
	movl	-4(%rbp), %eax
	movslq	%eax, %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	-8(%rbp), %edx
	movslq	%edx, %rcx
	movq	-24(%rbp), %rdx
	addq	%rcx, %rdx
	movzbl	(%rax), %eax
	movb	%al, (%rdx)
	movl	-4(%rbp), %eax
	movslq	%eax, %rdx
	movq	-24(%rbp), %rax
	addq	%rax, %rdx
	movzbl	-9(%rbp), %eax
	movb	%al, (%rdx)
	addl	$1, -8(%rbp)
	subl	$1, -4(%rbp)
.L13:
	movl	-28(%rbp), %edx
	movl	-32(%rbp), %eax
	addl	%edx, %eax
	movl	%eax, %edx
	shrl	$31, %edx
	addl	%edx, %eax
	sarl	%eax
	cmpl	%eax, -8(%rbp)
	jle	.L14
	nop
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2:
	.size	Reverse, .-Reverse
	.globl	Replace
	.type	Replace, @function
Replace:
.LFB3:
	.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	-36(%rbp), %eax
	movl	%eax, -8(%rbp)
	movl	$0, -4(%rbp)
	jmp	.L16
.L17:
	movl	-4(%rbp), %eax
	leal	1(%rax), %edx
	movl	%edx, -4(%rbp)
	movslq	%eax, %rdx
	movq	-32(%rbp), %rax
	leaq	(%rdx,%rax), %rcx
	movl	-8(%rbp), %eax
	leal	1(%rax), %edx
	movl	%edx, -8(%rbp)
	movslq	%eax, %rdx
	movq	-24(%rbp), %rax
	addq	%rax, %rdx
	movzbl	(%rcx), %eax
	movb	%al, (%rdx)
.L16:
	movl	-8(%rbp), %eax
	cmpl	-40(%rbp), %eax
	jle	.L17
	nop
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE3:
	.size	Replace, .-Replace
	.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	"%d %d"
.LC3:
	.string	"print"
.LC4:
	.string	"reverse"
.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
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	leaq	.LC0(%rip), %r14
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movq	%r14, %rdi
	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	64(%rsp), %rbp
	movq	%rbp, %rsi
	call	__isoc99_scanf@PLT
	leaq	40(%rsp), %rsi
	leaq	.LC1(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	40(%rsp), %eax
	testl	%eax, %eax
	jle	.L2
	leaq	48(%rsp), %rax
	xorl	%r12d, %r12d
	leaq	54(%rsp), %rbx
	movq	%rax, 8(%rsp)
	leaq	44(%rsp), %rax
	movq	%rax, (%rsp)
	leaq	1072(%rsp), %rax
	movq	%rax, 16(%rsp)
	leaq	63(%rsp), %rax
	movq	%rax, 24(%rsp)
	jmp	.L16
	.p2align 4,,10
	.p2align 3
.L3:
	movabsq	$28555907813500274, %rax
	cmpq	%rax, (%rbx)
	je	.L27
	movabsq	$28538242730059122, %rax
	cmpq	%rax, (%rbx)
	je	.L28
.L8:
	addl	$1, %r12d
	cmpl	%r12d, 40(%rsp)
	jle	.L2
.L16:
	movq	%rbx, %rsi
	movq	%r14, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movq	8(%rsp), %rdx
	movq	(%rsp), %rsi
	xorl	%eax, %eax
	leaq	.LC2(%rip), %rdi
	call	__isoc99_scanf@PLT
	cmpl	$1852404336, (%rbx)
	jne	.L3
	cmpw	$116, 4(%rbx)
	jne	.L3
	movl	44(%rsp), %edx
	movl	48(%rsp), %r13d
	movslq	%edx, %r15
	cmpl	%edx, %r13d
	jl	.L6
	.p2align 4,,10
	.p2align 3
.L7:
	movsbl	0(%rbp,%r15), %edi
	addq	$1, %r15
	call	putchar@PLT
	cmpl	%r15d, %r13d
	jge	.L7
.L6:
	movl	$10, %edi
	addl	$1, %r12d
	call	putchar@PLT
	cmpl	%r12d, 40(%rsp)
	jg	.L16
.L2:
	movq	2072(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L29
	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
.L27:
	.cfi_restore_state
	movl	48(%rsp), %eax
	movl	44(%rsp), %edi
	leal	(%rax,%rdi), %edx
	movl	%edx, %esi
	shrl	$31, %esi
	addl	%edx, %esi
	sarl	%esi
	cmpl	%esi, %edi
	jg	.L8
	movslq	%eax, %rcx
	movslq	%edi, %rdx
	subl	%edi, %esi
	leaq	0(%rbp,%rcx), %rax
	addq	24(%rsp), %rcx
	addq	%rbp, %rdx
	subq	%rsi, %rcx
	.p2align 4,,10
	.p2align 3
.L13:
	movzbl	(%rdx), %esi
	movzbl	(%rax), %edi
	subq	$1, %rax
	addq	$1, %rdx
	movb	%dil, -1(%rdx)
	movb	%sil, 1(%rax)
	cmpq	%rax, %rcx
	jne	.L13
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L28:
	movq	16(%rsp), %r15
	movq	%r14, %rdi
	xorl	%eax, %eax
	movq	%r15, %rsi
	call	__isoc99_scanf@PLT
	movl	48(%rsp), %edx
	movl	44(%rsp), %eax
	cmpl	%eax, %edx
	jl	.L8
	subl	%eax, %edx
	movslq	%eax, %rdi
	movq	%r15, %rsi
	addq	%rbp, %rdi
	addq	$1, %rdx
	call	memcpy@PLT
	jmp	.L8
.L29:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE35:
	.size	main, .-main
	.text
	.p2align 4
	.globl	Print
	.type	Print, @function
Print:
.LFB36:
	.cfi_startproc
	endbr64
	cmpl	%edx, %esi
	jg	.L35
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movq	%rdi, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	movl	%edx, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	movslq	%esi, %rbx
	.p2align 4,,10
	.p2align 3
.L32:
	movsbl	(%r12,%rbx), %edi
	addq	$1, %rbx
	call	putchar@PLT
	cmpl	%ebx, %ebp
	jge	.L32
	popq	%rbx
	.cfi_restore 3
	.cfi_def_cfa_offset 24
	movl	$10, %edi
	popq	%rbp
	.cfi_restore 6
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_restore 12
	.cfi_def_cfa_offset 8
	jmp	putchar@PLT
	.p2align 4,,10
	.p2align 3
.L35:
	movl	$10, %edi
	jmp	putchar@PLT
	.cfi_endproc
.LFE36:
	.size	Print, .-Print
	.p2align 4
	.globl	Reverse
	.type	Reverse, @function
Reverse:
.LFB37:
	.cfi_startproc
	endbr64
	leal	(%rsi,%rdx), %eax
	movl	%eax, %r8d
	shrl	$31, %r8d
	addl	%eax, %r8d
	sarl	%r8d
	cmpl	%r8d, %esi
	jg	.L38
	movslq	%edx, %rdx
	movslq	%esi, %rcx
	subl	%esi, %r8d
	addq	%rdi, %rcx
	leaq	(%rdi,%rdx), %rax
	leaq	-1(%rdi,%rdx), %rdi
	subq	%r8, %rdi
	.p2align 4,,10
	.p2align 3
.L40:
	movzbl	(%rcx), %edx
	movzbl	(%rax), %esi
	subq	$1, %rax
	addq	$1, %rcx
	movb	%sil, -1(%rcx)
	movb	%dl, 1(%rax)
	cmpq	%rdi, %rax
	jne	.L40
.L38:
	ret
	.cfi_endproc
.LFE37:
	.size	Reverse, .-Reverse
	.p2align 4
	.globl	Replace
	.type	Replace, @function
Replace:
.LFB38:
	.cfi_startproc
	endbr64
	movq	%rdi, %r10
	movl	%ecx, %r8d
	cmpl	%ecx, %edx
	jg	.L42
	movl	%ecx, %r9d
	movslq	%edx, %rcx
	addq	%rdi, %rcx
	leaq	1(%rsi), %rdi
	subl	%edx, %r9d
	movq	%rcx, %rax
	subq	%rdi, %rax
	cmpq	$14, %rax
	jbe	.L44
	cmpl	$6, %r9d
	jbe	.L44
	leal	1(%r9), %r11d
	cmpl	$14, %r9d
	jbe	.L45
	movl	%r11d, %edi
	xorl	%eax, %eax
	shrl	$4, %edi
	salq	$4, %rdi
	.p2align 4,,10
	.p2align 3
.L46:
	movdqu	(%rsi,%rax), %xmm0
	movups	%xmm0, (%rcx,%rax)
	addq	$16, %rax
	cmpq	%rdi, %rax
	jne	.L46
	movl	%r11d, %eax
	andl	$-16, %eax
	movl	%eax, %edi
	addl	%eax, %edx
	cmpl	%eax, %r11d
	je	.L42
	subl	%eax, %r9d
	leal	1(%r9), %r11d
	cmpl	$6, %r9d
	jbe	.L48
.L52:
	movq	(%rsi,%rax), %r9
	movq	%r9, (%rcx,%rax)
	movl	%r11d, %eax
	andl	$-8, %eax
	addl	%eax, %edx
	addl	%eax, %edi
	cmpl	%eax, %r11d
	je	.L42
.L48:
	movslq	%edi, %rcx
	leal	1(%rdx), %eax
	leal	1(%rdi), %r9d
	movzbl	(%rsi,%rcx), %r11d
	movslq	%edx, %rcx
	movb	%r11b, (%r10,%rcx)
	cmpl	%r8d, %eax
	jg	.L42
	movslq	%r9d, %r9
	leal	2(%rdx), %ecx
	leal	2(%rdi), %r11d
	cltq
	movzbl	(%rsi,%r9), %r9d
	movb	%r9b, (%r10,%rax)
	cmpl	%ecx, %r8d
	jl	.L42
	movslq	%r11d, %r11
	leal	3(%rdx), %eax
	leal	3(%rdi), %r9d
	movslq	%ecx, %rcx
	movzbl	(%rsi,%r11), %r11d
	movb	%r11b, (%r10,%rcx)
	cmpl	%eax, %r8d
	jl	.L42
	movslq	%r9d, %r9
	leal	4(%rdx), %ecx
	leal	4(%rdi), %r11d
	cltq
	movzbl	(%rsi,%r9), %r9d
	movb	%r9b, (%r10,%rax)
	cmpl	%ecx, %r8d
	jl	.L42
	movslq	%r11d, %r11
	leal	5(%rdx), %eax
	leal	5(%rdi), %r9d
	movslq	%ecx, %rcx
	movzbl	(%rsi,%r11), %r11d
	movb	%r11b, (%r10,%rcx)
	cmpl	%eax, %r8d
	jl	.L42
	movslq	%r9d, %r9
	cltq
	addl	$6, %edx
	addl	$6, %edi
	movzbl	(%rsi,%r9), %ecx
	movb	%cl, (%r10,%rax)
	cmpl	%edx, %r8d
	jl	.L42
	movslq	%edi, %rdi
	movslq	%edx, %rdx
	movzbl	(%rsi,%rdi), %eax
	movb	%al, (%r10,%rdx)
	ret
	.p2align 4,,10
	.p2align 3
.L42:
	ret
	.p2align 4,,10
	.p2align 3
.L44:
	xorl	%eax, %eax
	.p2align 4,,10
	.p2align 3
.L50:
	movzbl	(%rsi,%rax), %edx
	movb	%dl, (%rcx,%rax)
	movq	%rax, %rdx
	addq	$1, %rax
	cmpq	%r9, %rdx
	jne	.L50
	ret
.L45:
	xorl	%eax, %eax
	xorl	%edi, %edi
	jmp	.L52
	.cfi_endproc
.LFE38:
	.size	Replace, .-Replace
	.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	"%d %d"
.LC3:
	.string	"print"
.LC4:
	.string	"reverse"
.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
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	leaq	.LC0(%rip), %r14
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movq	%r14, %rdi
	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	64(%rsp), %rbp
	movq	%rbp, %rsi
	call	__isoc99_scanf@PLT
	leaq	40(%rsp), %rsi
	leaq	.LC1(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	40(%rsp), %eax
	testl	%eax, %eax
	jle	.L2
	leaq	48(%rsp), %rax
	xorl	%r12d, %r12d
	leaq	54(%rsp), %rbx
	movq	%rax, 8(%rsp)
	leaq	44(%rsp), %rax
	movq	%rax, (%rsp)
	leaq	1072(%rsp), %rax
	movq	%rax, 16(%rsp)
	leaq	63(%rsp), %rax
	movq	%rax, 24(%rsp)
	jmp	.L16
	.p2align 4,,10
	.p2align 3
.L3:
	movabsq	$28555907813500274, %rax
	cmpq	%rax, (%rbx)
	je	.L27
	movabsq	$28538242730059122, %rax
	cmpq	%rax, (%rbx)
	je	.L28
.L8:
	addl	$1, %r12d
	cmpl	%r12d, 40(%rsp)
	jle	.L2
.L16:
	movq	%rbx, %rsi
	movq	%r14, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movq	8(%rsp), %rdx
	movq	(%rsp), %rsi
	xorl	%eax, %eax
	leaq	.LC2(%rip), %rdi
	call	__isoc99_scanf@PLT
	cmpl	$1852404336, (%rbx)
	jne	.L3
	cmpw	$116, 4(%rbx)
	jne	.L3
	movl	44(%rsp), %edx
	movl	48(%rsp), %r13d
	movslq	%edx, %r15
	cmpl	%edx, %r13d
	jl	.L6
	.p2align 4,,10
	.p2align 3
.L7:
	movsbl	0(%rbp,%r15), %edi
	addq	$1, %r15
	call	putchar@PLT
	cmpl	%r15d, %r13d
	jge	.L7
.L6:
	movl	$10, %edi
	addl	$1, %r12d
	call	putchar@PLT
	cmpl	%r12d, 40(%rsp)
	jg	.L16
.L2:
	movq	2072(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L29
	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
.L27:
	.cfi_restore_state
	movl	48(%rsp), %eax
	movl	44(%rsp), %edi
	leal	(%rax,%rdi), %edx
	movl	%edx, %esi
	shrl	$31, %esi
	addl	%edx, %esi
	sarl	%esi
	cmpl	%esi, %edi
	jg	.L8
	movslq	%eax, %rcx
	movslq	%edi, %rdx
	subl	%edi, %esi
	leaq	0(%rbp,%rcx), %rax
	addq	24(%rsp), %rcx
	addq	%rbp, %rdx
	subq	%rsi, %rcx
	.p2align 4,,10
	.p2align 3
.L13:
	movzbl	(%rdx), %esi
	movzbl	(%rax), %edi
	subq	$1, %rax
	addq	$1, %rdx
	movb	%dil, -1(%rdx)
	movb	%sil, 1(%rax)
	cmpq	%rax, %rcx
	jne	.L13
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L28:
	movq	16(%rsp), %r15
	movq	%r14, %rdi
	xorl	%eax, %eax
	movq	%r15, %rsi
	call	__isoc99_scanf@PLT
	movl	48(%rsp), %edx
	movl	44(%rsp), %eax
	cmpl	%eax, %edx
	jl	.L8
	subl	%eax, %edx
	movslq	%eax, %rdi
	movq	%r15, %rsi
	addq	%rbp, %rdi
	addq	$1, %rdx
	call	memcpy@PLT
	jmp	.L8
.L29:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE35:
	.size	main, .-main
	.text
	.p2align 4
	.globl	Print
	.type	Print, @function
Print:
.LFB36:
	.cfi_startproc
	endbr64
	cmpl	%edx, %esi
	jg	.L35
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movq	%rdi, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	movl	%edx, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	movslq	%esi, %rbx
	.p2align 4,,10
	.p2align 3
.L32:
	movsbl	(%r12,%rbx), %edi
	addq	$1, %rbx
	call	putchar@PLT
	cmpl	%ebx, %ebp
	jge	.L32
	popq	%rbx
	.cfi_restore 3
	.cfi_def_cfa_offset 24
	movl	$10, %edi
	popq	%rbp
	.cfi_restore 6
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_restore 12
	.cfi_def_cfa_offset 8
	jmp	putchar@PLT
	.p2align 4,,10
	.p2align 3
.L35:
	movl	$10, %edi
	jmp	putchar@PLT
	.cfi_endproc
.LFE36:
	.size	Print, .-Print
	.p2align 4
	.globl	Reverse
	.type	Reverse, @function
Reverse:
.LFB37:
	.cfi_startproc
	endbr64
	leal	(%rsi,%rdx), %eax
	movl	%eax, %r8d
	shrl	$31, %r8d
	addl	%eax, %r8d
	sarl	%r8d
	cmpl	%r8d, %esi
	jg	.L38
	movslq	%edx, %rdx
	movslq	%esi, %rcx
	subl	%esi, %r8d
	addq	%rdi, %rcx
	leaq	(%rdi,%rdx), %rax
	leaq	-1(%rdi,%rdx), %rdi
	subq	%r8, %rdi
	.p2align 4,,10
	.p2align 3
.L40:
	movzbl	(%rcx), %edx
	movzbl	(%rax), %esi
	subq	$1, %rax
	addq	$1, %rcx
	movb	%sil, -1(%rcx)
	movb	%dl, 1(%rax)
	cmpq	%rdi, %rax
	jne	.L40
.L38:
	ret
	.cfi_endproc
.LFE37:
	.size	Reverse, .-Reverse
	.p2align 4
	.globl	Replace
	.type	Replace, @function
Replace:
.LFB38:
	.cfi_startproc
	endbr64
	movq	%rdi, %r10
	movl	%ecx, %r8d
	cmpl	%ecx, %edx
	jg	.L42
	movl	%ecx, %r9d
	movslq	%edx, %rcx
	addq	%rdi, %rcx
	leaq	1(%rsi), %rdi
	subl	%edx, %r9d
	movq	%rcx, %rax
	subq	%rdi, %rax
	cmpq	$14, %rax
	jbe	.L44
	cmpl	$6, %r9d
	jbe	.L44
	leal	1(%r9), %r11d
	cmpl	$14, %r9d
	jbe	.L45
	movl	%r11d, %edi
	xorl	%eax, %eax
	shrl	$4, %edi
	salq	$4, %rdi
	.p2align 4,,10
	.p2align 3
.L46:
	movdqu	(%rsi,%rax), %xmm0
	movups	%xmm0, (%rcx,%rax)
	addq	$16, %rax
	cmpq	%rdi, %rax
	jne	.L46
	movl	%r11d, %eax
	andl	$-16, %eax
	movl	%eax, %edi
	addl	%eax, %edx
	cmpl	%eax, %r11d
	je	.L42
	subl	%eax, %r9d
	leal	1(%r9), %r11d
	cmpl	$6, %r9d
	jbe	.L48
.L52:
	movq	(%rsi,%rax), %r9
	movq	%r9, (%rcx,%rax)
	movl	%r11d, %eax
	andl	$-8, %eax
	addl	%eax, %edx
	addl	%eax, %edi
	cmpl	%eax, %r11d
	je	.L42
.L48:
	movslq	%edi, %rcx
	leal	1(%rdx), %eax
	leal	1(%rdi), %r9d
	movzbl	(%rsi,%rcx), %r11d
	movslq	%edx, %rcx
	movb	%r11b, (%r10,%rcx)
	cmpl	%r8d, %eax
	jg	.L42
	movslq	%r9d, %r9
	leal	2(%rdx), %ecx
	leal	2(%rdi), %r11d
	cltq
	movzbl	(%rsi,%r9), %r9d
	movb	%r9b, (%r10,%rax)
	cmpl	%ecx, %r8d
	jl	.L42
	movslq	%r11d, %r11
	leal	3(%rdx), %eax
	leal	3(%rdi), %r9d
	movslq	%ecx, %rcx
	movzbl	(%rsi,%r11), %r11d
	movb	%r11b, (%r10,%rcx)
	cmpl	%eax, %r8d
	jl	.L42
	movslq	%r9d, %r9
	leal	4(%rdx), %ecx
	leal	4(%rdi), %r11d
	cltq
	movzbl	(%rsi,%r9), %r9d
	movb	%r9b, (%r10,%rax)
	cmpl	%ecx, %r8d
	jl	.L42
	movslq	%r11d, %r11
	leal	5(%rdx), %eax
	leal	5(%rdi), %r9d
	movslq	%ecx, %rcx
	movzbl	(%rsi,%r11), %r11d
	movb	%r11b, (%r10,%rcx)
	cmpl	%eax, %r8d
	jl	.L42
	movslq	%r9d, %r9
	cltq
	addl	$6, %edx
	addl	$6, %edi
	movzbl	(%rsi,%r9), %ecx
	movb	%cl, (%r10,%rax)
	cmpl	%edx, %r8d
	jl	.L42
	movslq	%edi, %rdi
	movslq	%edx, %rdx
	movzbl	(%rsi,%rdi), %eax
	movb	%al, (%r10,%rdx)
	ret
	.p2align 4,,10
	.p2align 3
.L42:
	ret
	.p2align 4,,10
	.p2align 3
.L44:
	xorl	%eax, %eax
	.p2align 4,,10
	.p2align 3
.L50:
	movzbl	(%rsi,%rax), %edx
	movb	%dl, (%rcx,%rax)
	movq	%rax, %rdx
	addq	$1, %rax
	cmpq	%r9, %rdx
	jne	.L50
	ret
.L45:
	xorl	%eax, %eax
	xorl	%edi, %edi
	jmp	.L52
	.cfi_endproc
.LFE38:
	.size	Replace, .-Replace
	.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 MAX 1000
#define OP  10

void Print(char S[], int x, int y);
void Reverse(char S[], int x, int y);
void Replace(char S[], char P[], int x, int y);

int main(void) {
  char str[MAX];
  char op[OP];
  char p[MAX];
  int q;
  int i = 0;
  int a, b;

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

  while(i < q) {
    scanf("%s", op);
    scanf("%d %d", &a, &b);

    if(strcmp(op, "print") == 0) {
      Print(str, a, b);
    }
    else if(strcmp(op, "reverse") == 0) {
      Reverse(str, a, b);
    }
    else if(strcmp(op, "replace") == 0) {
      scanf("%s", p);
      Replace(str, p, a, b);
    }
    i++;
  }

  return 0;
}

void Print(char S[], int x, int y) {

  for(int i=x; i<= y; ++i) {
    printf("%c", S[i]);
  }
  printf("\n");
}

void Reverse(char S[], int x, int y) {
  char tmp;
  int i = x;
  int j = y;

  while (i <= (x+y)/2) {
    tmp = S[i];
    S[i] = S[j];
    S[j] = tmp;
    i++;
    j--;
  }
}

void Replace(char S[], char P[], int x, int y) {
  int i=x, j=0;

  while(i <= y) {
    S[i++] = P[j++];
  }
}


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>

#define MAX 1000
#define OP  10

void Print(char S[], int x, int y);
void Reverse(char S[], int x, int y);
void Replace(char S[], char P[], int x, int y);

int main(void) {
  char str[MAX];
  char op[OP];
  char p[MAX];
  int q;
  int i = 0;
  int a, b;

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

  while(i < q) {
    scanf("%s", op);
    scanf("%d %d", &a, &b);

    if(strcmp(op, "print") == 0) {
      Print(str, a, b);
    }
    else if(strcmp(op, "reverse") == 0) {
      Reverse(str, a, b);
    }
    else if(strcmp(op, "replace") == 0) {
      scanf("%s", p);
      Replace(str, p, a, b);
    }
    i++;
  }

  return 0;
}

void Print(char S[], int x, int y) {

  for(int i=x; i<= y; ++i) {
    printf("%c", S[i]);
  }
  printf("\n");
}

void Reverse(char S[], int x, int y) {
  char tmp;
  int i = x;
  int j = y;

  while (i <= (x+y)/2) {
    tmp = S[i];
    S[i] = S[j];
    S[j] = tmp;
    i++;
    j--;
  }
}

void Replace(char S[], char P[], int x, int y) {
  int i=x, j=0;

  while(i <= y) {
    S[i++] = P[j++];
  }
}

```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%s"
.LC1:
	.string	"%d"
.LC2:
	.string	"%d %d"
.LC3:
	.string	"print"
.LC4:
	.string	"reverse"
.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	$2048, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -2032(%rbp)
	leaq	-2016(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	leaq	-2044(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	jmp	.L2
.L6:
	leaq	-2026(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	leaq	-2036(%rbp), %rdx
	leaq	-2040(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	leaq	-2026(%rbp), %rax
	leaq	.LC3(%rip), %rdx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L3
	movl	-2036(%rbp), %edx
	movl	-2040(%rbp), %ecx
	leaq	-2016(%rbp), %rax
	movl	%ecx, %esi
	movq	%rax, %rdi
	call	Print
	jmp	.L4
.L3:
	leaq	-2026(%rbp), %rax
	leaq	.LC4(%rip), %rdx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L5
	movl	-2036(%rbp), %edx
	movl	-2040(%rbp), %ecx
	leaq	-2016(%rbp), %rax
	movl	%ecx, %esi
	movq	%rax, %rdi
	call	Reverse
	jmp	.L4
.L5:
	leaq	-2026(%rbp), %rax
	leaq	.LC5(%rip), %rdx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L4
	leaq	-1008(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-2036(%rbp), %ecx
	movl	-2040(%rbp), %edx
	leaq	-1008(%rbp), %rsi
	leaq	-2016(%rbp), %rax
	movq	%rax, %rdi
	call	Replace
.L4:
	addl	$1, -2032(%rbp)
.L2:
	movl	-2044(%rbp), %eax
	cmpl	%eax, -2032(%rbp)
	jl	.L6
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L8
	call	__stack_chk_fail@PLT
.L8:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.globl	Print
	.type	Print, @function
Print:
.LFB1:
	.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	%rdi, -24(%rbp)
	movl	%esi, -28(%rbp)
	movl	%edx, -32(%rbp)
	movl	-28(%rbp), %eax
	movl	%eax, -4(%rbp)
	jmp	.L10
.L11:
	movl	-4(%rbp), %eax
	movslq	%eax, %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	movsbl	%al, %eax
	movl	%eax, %edi
	call	putchar@PLT
	addl	$1, -4(%rbp)
.L10:
	movl	-4(%rbp), %eax
	cmpl	-32(%rbp), %eax
	jle	.L11
	movl	$10, %edi
	call	putchar@PLT
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	Print, .-Print
	.globl	Reverse
	.type	Reverse, @function
Reverse:
.LFB2:
	.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	%esi, -28(%rbp)
	movl	%edx, -32(%rbp)
	movl	-28(%rbp), %eax
	movl	%eax, -8(%rbp)
	movl	-32(%rbp), %eax
	movl	%eax, -4(%rbp)
	jmp	.L13
.L14:
	movl	-8(%rbp), %eax
	movslq	%eax, %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	movb	%al, -9(%rbp)
	movl	-4(%rbp), %eax
	movslq	%eax, %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	-8(%rbp), %edx
	movslq	%edx, %rcx
	movq	-24(%rbp), %rdx
	addq	%rcx, %rdx
	movzbl	(%rax), %eax
	movb	%al, (%rdx)
	movl	-4(%rbp), %eax
	movslq	%eax, %rdx
	movq	-24(%rbp), %rax
	addq	%rax, %rdx
	movzbl	-9(%rbp), %eax
	movb	%al, (%rdx)
	addl	$1, -8(%rbp)
	subl	$1, -4(%rbp)
.L13:
	movl	-28(%rbp), %edx
	movl	-32(%rbp), %eax
	addl	%edx, %eax
	movl	%eax, %edx
	shrl	$31, %edx
	addl	%edx, %eax
	sarl	%eax
	cmpl	%eax, -8(%rbp)
	jle	.L14
	nop
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2:
	.size	Reverse, .-Reverse
	.globl	Replace
	.type	Replace, @function
Replace:
.LFB3:
	.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	-36(%rbp), %eax
	movl	%eax, -8(%rbp)
	movl	$0, -4(%rbp)
	jmp	.L16
.L17:
	movl	-4(%rbp), %eax
	leal	1(%rax), %edx
	movl	%edx, -4(%rbp)
	movslq	%eax, %rdx
	movq	-32(%rbp), %rax
	leaq	(%rdx,%rax), %rcx
	movl	-8(%rbp), %eax
	leal	1(%rax), %edx
	movl	%edx, -8(%rbp)
	movslq	%eax, %rdx
	movq	-24(%rbp), %rax
	addq	%rax, %rdx
	movzbl	(%rcx), %eax
	movb	%al, (%rdx)
.L16:
	movl	-8(%rbp), %eax
	cmpl	-40(%rbp), %eax
	jle	.L17
	nop
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE3:
	.size	Replace, .-Replace
	.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	"%d %d"
.LC3:
	.string	"print"
.LC4:
	.string	"reverse"
.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	$2048, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -2032(%rbp)
	leaq	-2016(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	leaq	-2044(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	jmp	.L2
.L6:
	leaq	-2026(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	leaq	-2036(%rbp), %rdx
	leaq	-2040(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	leaq	-2026(%rbp), %rax
	leaq	.LC3(%rip), %rdx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L3
	movl	-2036(%rbp), %edx
	movl	-2040(%rbp), %ecx
	leaq	-2016(%rbp), %rax
	movl	%ecx, %esi
	movq	%rax, %rdi
	call	Print
	jmp	.L4
.L3:
	leaq	-2026(%rbp), %rax
	leaq	.LC4(%rip), %rdx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L5
	movl	-2036(%rbp), %edx
	movl	-2040(%rbp), %ecx
	leaq	-2016(%rbp), %rax
	movl	%ecx, %esi
	movq	%rax, %rdi
	call	Reverse
	jmp	.L4
.L5:
	leaq	-2026(%rbp), %rax
	leaq	.LC5(%rip), %rdx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L4
	leaq	-1008(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-2036(%rbp), %ecx
	movl	-2040(%rbp), %edx
	leaq	-1008(%rbp), %rsi
	leaq	-2016(%rbp), %rax
	movq	%rax, %rdi
	call	Replace
.L4:
	addl	$1, -2032(%rbp)
.L2:
	movl	-2044(%rbp), %eax
	cmpl	%eax, -2032(%rbp)
	jl	.L6
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L8
	call	__stack_chk_fail@PLT
.L8:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.globl	Print
	.type	Print, @function
Print:
.LFB1:
	.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	%rdi, -24(%rbp)
	movl	%esi, -28(%rbp)
	movl	%edx, -32(%rbp)
	movl	-28(%rbp), %eax
	movl	%eax, -4(%rbp)
	jmp	.L10
.L11:
	movl	-4(%rbp), %eax
	movslq	%eax, %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	movsbl	%al, %eax
	movl	%eax, %edi
	call	putchar@PLT
	addl	$1, -4(%rbp)
.L10:
	movl	-4(%rbp), %eax
	cmpl	-32(%rbp), %eax
	jle	.L11
	movl	$10, %edi
	call	putchar@PLT
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	Print, .-Print
	.globl	Reverse
	.type	Reverse, @function
Reverse:
.LFB2:
	.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	%esi, -28(%rbp)
	movl	%edx, -32(%rbp)
	movl	-28(%rbp), %eax
	movl	%eax, -8(%rbp)
	movl	-32(%rbp), %eax
	movl	%eax, -4(%rbp)
	jmp	.L13
.L14:
	movl	-8(%rbp), %eax
	movslq	%eax, %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	movb	%al, -9(%rbp)
	movl	-4(%rbp), %eax
	movslq	%eax, %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	-8(%rbp), %edx
	movslq	%edx, %rcx
	movq	-24(%rbp), %rdx
	addq	%rcx, %rdx
	movzbl	(%rax), %eax
	movb	%al, (%rdx)
	movl	-4(%rbp), %eax
	movslq	%eax, %rdx
	movq	-24(%rbp), %rax
	addq	%rax, %rdx
	movzbl	-9(%rbp), %eax
	movb	%al, (%rdx)
	addl	$1, -8(%rbp)
	subl	$1, -4(%rbp)
.L13:
	movl	-28(%rbp), %edx
	movl	-32(%rbp), %eax
	addl	%edx, %eax
	movl	%eax, %edx
	shrl	$31, %edx
	addl	%edx, %eax
	sarl	%eax
	cmpl	%eax, -8(%rbp)
	jle	.L14
	nop
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2:
	.size	Reverse, .-Reverse
	.globl	Replace
	.type	Replace, @function
Replace:
.LFB3:
	.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	-36(%rbp), %eax
	movl	%eax, -8(%rbp)
	movl	$0, -4(%rbp)
	jmp	.L16
.L17:
	movl	-4(%rbp), %eax
	leal	1(%rax), %edx
	movl	%edx, -4(%rbp)
	movslq	%eax, %rdx
	movq	-32(%rbp), %rax
	leaq	(%rdx,%rax), %rcx
	movl	-8(%rbp), %eax
	leal	1(%rax), %edx
	movl	%edx, -8(%rbp)
	movslq	%eax, %rdx
	movq	-24(%rbp), %rax
	addq	%rax, %rdx
	movzbl	(%rcx), %eax
	movb	%al, (%rdx)
.L16:
	movl	-8(%rbp), %eax
	cmpl	-40(%rbp), %eax
	jle	.L17
	nop
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE3:
	.size	Replace, .-Replace
	.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:
