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 main(){
char ch[1001];
int i=0;
while(scanf("%c",&ch[i])!=EOF){
if('D'<=ch[i] && 'Z'>=ch[i]) ch[i]-=3; else if(ch[i]=='C') ch[i]='Z'; else if(ch[i]=='B') ch[i]='Y';
else if(ch[i]=='A') ch[i]='X'; 
printf("%c",ch[i]);
i++;
}
return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%c"
	.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	$1040, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -1028(%rbp)
	jmp	.L2
.L7:
	movl	-1028(%rbp), %eax
	cltq
	movzbl	-1024(%rbp,%rax), %eax
	cmpb	$67, %al
	jle	.L3
	movl	-1028(%rbp), %eax
	cltq
	movzbl	-1024(%rbp,%rax), %eax
	cmpb	$90, %al
	jg	.L3
	movl	-1028(%rbp), %eax
	cltq
	movzbl	-1024(%rbp,%rax), %eax
	subl	$3, %eax
	movl	%eax, %edx
	movl	-1028(%rbp), %eax
	cltq
	movb	%dl, -1024(%rbp,%rax)
	jmp	.L4
.L3:
	movl	-1028(%rbp), %eax
	cltq
	movzbl	-1024(%rbp,%rax), %eax
	cmpb	$67, %al
	jne	.L5
	movl	-1028(%rbp), %eax
	cltq
	movb	$90, -1024(%rbp,%rax)
	jmp	.L4
.L5:
	movl	-1028(%rbp), %eax
	cltq
	movzbl	-1024(%rbp,%rax), %eax
	cmpb	$66, %al
	jne	.L6
	movl	-1028(%rbp), %eax
	cltq
	movb	$89, -1024(%rbp,%rax)
	jmp	.L4
.L6:
	movl	-1028(%rbp), %eax
	cltq
	movzbl	-1024(%rbp,%rax), %eax
	cmpb	$65, %al
	jne	.L4
	movl	-1028(%rbp), %eax
	cltq
	movb	$88, -1024(%rbp,%rax)
.L4:
	movl	-1028(%rbp), %eax
	cltq
	movzbl	-1024(%rbp,%rax), %eax
	movsbl	%al, %eax
	movl	%eax, %edi
	call	putchar@PLT
	addl	$1, -1028(%rbp)
.L2:
	leaq	-1024(%rbp), %rdx
	movl	-1028(%rbp), %eax
	cltq
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	cmpl	$-1, %eax
	jne	.L7
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L9
	call	__stack_chk_fail@PLT
.L9:
	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	"%c"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	leaq	.LC0(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	subq	$1032, %rsp
	.cfi_def_cfa_offset 1056
	movq	%fs:40, %rax
	movq	%rax, 1016(%rsp)
	xorl	%eax, %eax
	movq	%rsp, %rbx
	jmp	.L2
	.p2align 4,,10
	.p2align 3
.L13:
	subl	$3, %edi
	movb	%dil, (%rbx)
	movzbl	%dil, %edi
.L4:
	call	putchar@PLT
	addq	$1, %rbx
.L2:
	xorl	%eax, %eax
	movq	%rbx, %rsi
	movq	%rbp, %rdi
	call	__isoc99_scanf@PLT
	cmpl	$-1, %eax
	je	.L12
	movsbl	(%rbx), %edi
	leal	-68(%rdi), %eax
	cmpb	$22, %al
	jbe	.L13
	cmpb	$67, %dil
	je	.L14
	cmpb	$66, %dil
	je	.L15
	cmpb	$65, %dil
	jne	.L4
	movb	$88, (%rbx)
	movl	$88, %edi
	jmp	.L4
	.p2align 4,,10
	.p2align 3
.L14:
	movb	$90, (%rbx)
	movl	$90, %edi
	jmp	.L4
	.p2align 4,,10
	.p2align 3
.L12:
	movq	1016(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L16
	addq	$1032, %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
.L15:
	.cfi_restore_state
	movb	$89, (%rbx)
	movl	$89, %edi
	jmp	.L4
.L16:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.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	"%c"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	leaq	.LC0(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	subq	$1032, %rsp
	.cfi_def_cfa_offset 1056
	movq	%fs:40, %rax
	movq	%rax, 1016(%rsp)
	xorl	%eax, %eax
	movq	%rsp, %rbx
	jmp	.L2
	.p2align 4,,10
	.p2align 3
.L13:
	subl	$3, %edi
	movb	%dil, (%rbx)
	movzbl	%dil, %edi
.L4:
	call	putchar@PLT
	addq	$1, %rbx
.L2:
	xorl	%eax, %eax
	movq	%rbx, %rsi
	movq	%rbp, %rdi
	call	__isoc99_scanf@PLT
	cmpl	$-1, %eax
	je	.L12
	movsbl	(%rbx), %edi
	leal	-68(%rdi), %eax
	cmpb	$22, %al
	jbe	.L13
	cmpb	$67, %dil
	je	.L14
	cmpb	$66, %dil
	je	.L15
	cmpb	$65, %dil
	jne	.L4
	movb	$88, (%rbx)
	movl	$88, %edi
	jmp	.L4
	.p2align 4,,10
	.p2align 3
.L14:
	movb	$90, (%rbx)
	movl	$90, %edi
	jmp	.L4
	.p2align 4,,10
	.p2align 3
.L12:
	movq	1016(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L16
	addq	$1032, %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
.L15:
	.cfi_restore_state
	movb	$89, (%rbx)
	movl	$89, %edi
	jmp	.L4
.L16:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.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 main(){
char ch[1001];
int i=0;
while(scanf("%c",&ch[i])!=EOF){
if('D'<=ch[i] && 'Z'>=ch[i]) ch[i]-=3; else if(ch[i]=='C') ch[i]='Z'; else if(ch[i]=='B') ch[i]='Y';
else if(ch[i]=='A') ch[i]='X'; 
printf("%c",ch[i]);
i++;
}
return 0;
}
MRL

JOI

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 main(){
char ch[1001];
int i=0;
while(scanf("%c",&ch[i])!=EOF){
if('D'<=ch[i] && 'Z'>=ch[i]) ch[i]-=3; else if(ch[i]=='C') ch[i]='Z'; else if(ch[i]=='B') ch[i]='Y';
else if(ch[i]=='A') ch[i]='X'; 
printf("%c",ch[i]);
i++;
}
return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%c"
	.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	$1040, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -1028(%rbp)
	jmp	.L2
.L7:
	movl	-1028(%rbp), %eax
	cltq
	movzbl	-1024(%rbp,%rax), %eax
	cmpb	$67, %al
	jle	.L3
	movl	-1028(%rbp), %eax
	cltq
	movzbl	-1024(%rbp,%rax), %eax
	cmpb	$90, %al
	jg	.L3
	movl	-1028(%rbp), %eax
	cltq
	movzbl	-1024(%rbp,%rax), %eax
	subl	$3, %eax
	movl	%eax, %edx
	movl	-1028(%rbp), %eax
	cltq
	movb	%dl, -1024(%rbp,%rax)
	jmp	.L4
.L3:
	movl	-1028(%rbp), %eax
	cltq
	movzbl	-1024(%rbp,%rax), %eax
	cmpb	$67, %al
	jne	.L5
	movl	-1028(%rbp), %eax
	cltq
	movb	$90, -1024(%rbp,%rax)
	jmp	.L4
.L5:
	movl	-1028(%rbp), %eax
	cltq
	movzbl	-1024(%rbp,%rax), %eax
	cmpb	$66, %al
	jne	.L6
	movl	-1028(%rbp), %eax
	cltq
	movb	$89, -1024(%rbp,%rax)
	jmp	.L4
.L6:
	movl	-1028(%rbp), %eax
	cltq
	movzbl	-1024(%rbp,%rax), %eax
	cmpb	$65, %al
	jne	.L4
	movl	-1028(%rbp), %eax
	cltq
	movb	$88, -1024(%rbp,%rax)
.L4:
	movl	-1028(%rbp), %eax
	cltq
	movzbl	-1024(%rbp,%rax), %eax
	movsbl	%al, %eax
	movl	%eax, %edi
	call	putchar@PLT
	addl	$1, -1028(%rbp)
.L2:
	leaq	-1024(%rbp), %rdx
	movl	-1028(%rbp), %eax
	cltq
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	cmpl	$-1, %eax
	jne	.L7
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L9
	call	__stack_chk_fail@PLT
.L9:
	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	"%c"
	.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	$1040, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -1028(%rbp)
	jmp	.L2
.L7:
	movl	-1028(%rbp), %eax
	cltq
	movzbl	-1024(%rbp,%rax), %eax
	cmpb	$67, %al
	jle	.L3
	movl	-1028(%rbp), %eax
	cltq
	movzbl	-1024(%rbp,%rax), %eax
	cmpb	$90, %al
	jg	.L3
	movl	-1028(%rbp), %eax
	cltq
	movzbl	-1024(%rbp,%rax), %eax
	subl	$3, %eax
	movl	%eax, %edx
	movl	-1028(%rbp), %eax
	cltq
	movb	%dl, -1024(%rbp,%rax)
	jmp	.L4
.L3:
	movl	-1028(%rbp), %eax
	cltq
	movzbl	-1024(%rbp,%rax), %eax
	cmpb	$67, %al
	jne	.L5
	movl	-1028(%rbp), %eax
	cltq
	movb	$90, -1024(%rbp,%rax)
	jmp	.L4
.L5:
	movl	-1028(%rbp), %eax
	cltq
	movzbl	-1024(%rbp,%rax), %eax
	cmpb	$66, %al
	jne	.L6
	movl	-1028(%rbp), %eax
	cltq
	movb	$89, -1024(%rbp,%rax)
	jmp	.L4
.L6:
	movl	-1028(%rbp), %eax
	cltq
	movzbl	-1024(%rbp,%rax), %eax
	cmpb	$65, %al
	jne	.L4
	movl	-1028(%rbp), %eax
	cltq
	movb	$88, -1024(%rbp,%rax)
.L4:
	movl	-1028(%rbp), %eax
	cltq
	movzbl	-1024(%rbp,%rax), %eax
	movsbl	%al, %eax
	movl	%eax, %edi
	call	putchar@PLT
	addl	$1, -1028(%rbp)
.L2:
	leaq	-1024(%rbp), %rdx
	movl	-1028(%rbp), %eax
	cltq
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	cmpl	$-1, %eax
	jne	.L7
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L9
	call	__stack_chk_fail@PLT
.L9:
	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:
