Given the following C code and unoptimized assembly code, your task is to generate highly optimized x86-64 assembly code.
C Code:

```c
// AOJ 1240: Unreliable Message
// 2017.10.17 bal4u@uu

#include <stdio.h>
#include <string.h>
#include <ctype.h>

char msg[2][30]; int w;

int main()
{
	int t, k1, k2, i;
	char ord[7], *s, *p, *q;

	scanf("%d", &t);
	while (t-- > 0) {
		scanf("%s%s", ord, msg[0]);
		w = strlen(msg[0]); msg[1][w] = 0; s = ord + strlen(ord)-1;
		for (k1 = 0, k2 = 1; s >= ord; s--, k1 = k2, k2 = !k2) {
			p = msg[k1], q = msg[k2];
			if (*s == 'A') {
				q += w;	while (*p) *--q = *p++;
			} else if (*s == 'C') {
				*(q+w-1) = *p++; while (*p) *q++ = *p++;
			} else if (*s == 'E') {
				i = w/2; q += i; if (w & 1) q++;
				while(i-- > 0) *q++ = *p++;
				q = msg[k2]; if (w & 1) *(q+w/2) = *p++;
				while(*p) *q++ = *p++;
			} else if (*s == 'J') {
				*q++ = *(p+w-1); while (*p) *q++ = *p++;
				*(q-1) = 0;
			} else if (*s == 'M') {
				while (*p) {
					if (isdigit(*p)) {
						if (*p == '9') *q = '0'; else *q = (*p)+1;
					} else *q = *p;
					p++, q++;
				}
			} else {
				while (*p) {
					if (isdigit(*p)) {
						if (*p == '0') *q = '9'; else *q = (*p)-1;
					} else *q = *p;
					p++, q++;
				}
			}
		}
		puts(msg[k1]);
	}
 	return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	msg
	.bss
	.align 32
	.type	msg, @object
	.size	msg, 60
msg:
	.zero	60
	.globl	w
	.align 4
	.type	w, @object
	.size	w, 4
w:
	.zero	4
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%s%s"
	.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	$64, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-56(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	jmp	.L2
.L33:
	leaq	-15(%rbp), %rax
	leaq	msg(%rip), %rdx
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	leaq	msg(%rip), %rax
	movq	%rax, %rdi
	call	strlen@PLT
	movl	%eax, w(%rip)
	movl	w(%rip), %eax
	cltq
	leaq	30+msg(%rip), %rdx
	movb	$0, (%rax,%rdx)
	leaq	-15(%rbp), %rax
	movq	%rax, %rdi
	call	strlen@PLT
	leaq	-1(%rax), %rdx
	leaq	-15(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, -40(%rbp)
	movl	$0, -52(%rbp)
	movl	$1, -48(%rbp)
	jmp	.L3
.L32:
	movl	-52(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$4, %rax
	subq	%rdx, %rax
	addq	%rax, %rax
	leaq	msg(%rip), %rdx
	addq	%rdx, %rax
	movq	%rax, -32(%rbp)
	movl	-48(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$4, %rax
	subq	%rdx, %rax
	addq	%rax, %rax
	leaq	msg(%rip), %rdx
	addq	%rdx, %rax
	movq	%rax, -24(%rbp)
	movq	-40(%rbp), %rax
	movzbl	(%rax), %eax
	cmpb	$65, %al
	jne	.L4
	movl	w(%rip), %eax
	cltq
	addq	%rax, -24(%rbp)
	jmp	.L5
.L6:
	movq	-32(%rbp), %rax
	leaq	1(%rax), %rdx
	movq	%rdx, -32(%rbp)
	subq	$1, -24(%rbp)
	movzbl	(%rax), %edx
	movq	-24(%rbp), %rax
	movb	%dl, (%rax)
.L5:
	movq	-32(%rbp), %rax
	movzbl	(%rax), %eax
	testb	%al, %al
	jne	.L6
	jmp	.L7
.L4:
	movq	-40(%rbp), %rax
	movzbl	(%rax), %eax
	cmpb	$67, %al
	jne	.L8
	movq	-32(%rbp), %rax
	leaq	1(%rax), %rdx
	movq	%rdx, -32(%rbp)
	movl	w(%rip), %edx
	movslq	%edx, %rdx
	leaq	-1(%rdx), %rcx
	movq	-24(%rbp), %rdx
	addq	%rcx, %rdx
	movzbl	(%rax), %eax
	movb	%al, (%rdx)
	jmp	.L9
.L10:
	movq	-32(%rbp), %rdx
	leaq	1(%rdx), %rax
	movq	%rax, -32(%rbp)
	movq	-24(%rbp), %rax
	leaq	1(%rax), %rcx
	movq	%rcx, -24(%rbp)
	movzbl	(%rdx), %edx
	movb	%dl, (%rax)
.L9:
	movq	-32(%rbp), %rax
	movzbl	(%rax), %eax
	testb	%al, %al
	jne	.L10
	jmp	.L7
.L8:
	movq	-40(%rbp), %rax
	movzbl	(%rax), %eax
	cmpb	$69, %al
	jne	.L11
	movl	w(%rip), %eax
	movl	%eax, %edx
	shrl	$31, %edx
	addl	%edx, %eax
	sarl	%eax
	movl	%eax, -44(%rbp)
	movl	-44(%rbp), %eax
	cltq
	addq	%rax, -24(%rbp)
	movl	w(%rip), %eax
	andl	$1, %eax
	testl	%eax, %eax
	je	.L13
	addq	$1, -24(%rbp)
	jmp	.L13
.L14:
	movq	-32(%rbp), %rdx
	leaq	1(%rdx), %rax
	movq	%rax, -32(%rbp)
	movq	-24(%rbp), %rax
	leaq	1(%rax), %rcx
	movq	%rcx, -24(%rbp)
	movzbl	(%rdx), %edx
	movb	%dl, (%rax)
.L13:
	movl	-44(%rbp), %eax
	leal	-1(%rax), %edx
	movl	%edx, -44(%rbp)
	testl	%eax, %eax
	jg	.L14
	movl	-48(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$4, %rax
	subq	%rdx, %rax
	addq	%rax, %rax
	leaq	msg(%rip), %rdx
	addq	%rdx, %rax
	movq	%rax, -24(%rbp)
	movl	w(%rip), %eax
	andl	$1, %eax
	testl	%eax, %eax
	je	.L16
	movq	-32(%rbp), %rax
	leaq	1(%rax), %rdx
	movq	%rdx, -32(%rbp)
	movl	w(%rip), %edx
	movl	%edx, %ecx
	shrl	$31, %ecx
	addl	%ecx, %edx
	sarl	%edx
	movslq	%edx, %rcx
	movq	-24(%rbp), %rdx
	addq	%rcx, %rdx
	movzbl	(%rax), %eax
	movb	%al, (%rdx)
	jmp	.L16
.L17:
	movq	-32(%rbp), %rdx
	leaq	1(%rdx), %rax
	movq	%rax, -32(%rbp)
	movq	-24(%rbp), %rax
	leaq	1(%rax), %rcx
	movq	%rcx, -24(%rbp)
	movzbl	(%rdx), %edx
	movb	%dl, (%rax)
.L16:
	movq	-32(%rbp), %rax
	movzbl	(%rax), %eax
	testb	%al, %al
	jne	.L17
	jmp	.L7
.L11:
	movq	-40(%rbp), %rax
	movzbl	(%rax), %eax
	cmpb	$74, %al
	jne	.L18
	movl	w(%rip), %eax
	cltq
	leaq	-1(%rax), %rdx
	movq	-32(%rbp), %rax
	leaq	(%rdx,%rax), %rcx
	movq	-24(%rbp), %rax
	leaq	1(%rax), %rdx
	movq	%rdx, -24(%rbp)
	movzbl	(%rcx), %edx
	movb	%dl, (%rax)
	jmp	.L19
.L20:
	movq	-32(%rbp), %rdx
	leaq	1(%rdx), %rax
	movq	%rax, -32(%rbp)
	movq	-24(%rbp), %rax
	leaq	1(%rax), %rcx
	movq	%rcx, -24(%rbp)
	movzbl	(%rdx), %edx
	movb	%dl, (%rax)
.L19:
	movq	-32(%rbp), %rax
	movzbl	(%rax), %eax
	testb	%al, %al
	jne	.L20
	movq	-24(%rbp), %rax
	subq	$1, %rax
	movb	$0, (%rax)
	jmp	.L7
.L18:
	movq	-40(%rbp), %rax
	movzbl	(%rax), %eax
	cmpb	$77, %al
	jne	.L27
	jmp	.L22
.L26:
	call	__ctype_b_loc@PLT
	movq	(%rax), %rdx
	movq	-32(%rbp), %rax
	movzbl	(%rax), %eax
	movsbq	%al, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	movzwl	(%rax), %eax
	movzwl	%ax, %eax
	andl	$2048, %eax
	testl	%eax, %eax
	je	.L23
	movq	-32(%rbp), %rax
	movzbl	(%rax), %eax
	cmpb	$57, %al
	jne	.L24
	movq	-24(%rbp), %rax
	movb	$48, (%rax)
	jmp	.L25
.L24:
	movq	-32(%rbp), %rax
	movzbl	(%rax), %eax
	addl	$1, %eax
	movl	%eax, %edx
	movq	-24(%rbp), %rax
	movb	%dl, (%rax)
	jmp	.L25
.L23:
	movq	-32(%rbp), %rax
	movzbl	(%rax), %edx
	movq	-24(%rbp), %rax
	movb	%dl, (%rax)
.L25:
	addq	$1, -32(%rbp)
	addq	$1, -24(%rbp)
.L22:
	movq	-32(%rbp), %rax
	movzbl	(%rax), %eax
	testb	%al, %al
	jne	.L26
	jmp	.L7
.L31:
	call	__ctype_b_loc@PLT
	movq	(%rax), %rdx
	movq	-32(%rbp), %rax
	movzbl	(%rax), %eax
	movsbq	%al, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	movzwl	(%rax), %eax
	movzwl	%ax, %eax
	andl	$2048, %eax
	testl	%eax, %eax
	je	.L28
	movq	-32(%rbp), %rax
	movzbl	(%rax), %eax
	cmpb	$48, %al
	jne	.L29
	movq	-24(%rbp), %rax
	movb	$57, (%rax)
	jmp	.L30
.L29:
	movq	-32(%rbp), %rax
	movzbl	(%rax), %eax
	subl	$1, %eax
	movl	%eax, %edx
	movq	-24(%rbp), %rax
	movb	%dl, (%rax)
	jmp	.L30
.L28:
	movq	-32(%rbp), %rax
	movzbl	(%rax), %edx
	movq	-24(%rbp), %rax
	movb	%dl, (%rax)
.L30:
	addq	$1, -32(%rbp)
	addq	$1, -24(%rbp)
.L27:
	movq	-32(%rbp), %rax
	movzbl	(%rax), %eax
	testb	%al, %al
	jne	.L31
.L7:
	subq	$1, -40(%rbp)
	movl	-48(%rbp), %eax
	movl	%eax, -52(%rbp)
	cmpl	$0, -48(%rbp)
	sete	%al
	movzbl	%al, %eax
	movl	%eax, -48(%rbp)
.L3:
	leaq	-15(%rbp), %rax
	cmpq	%rax, -40(%rbp)
	jnb	.L32
	movl	-52(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$4, %rax
	subq	%rdx, %rax
	addq	%rax, %rax
	leaq	msg(%rip), %rdx
	addq	%rdx, %rax
	movq	%rax, %rdi
	call	puts@PLT
.L2:
	movl	-56(%rbp), %eax
	leal	-1(%rax), %edx
	movl	%edx, -56(%rbp)
	testl	%eax, %eax
	jg	.L33
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L35
	call	__stack_chk_fail@PLT
.L35:
	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	"%d"
.LC1:
	.string	"%s%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
	leaq	.LC0(%rip), %rdi
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	leaq	msg(%rip), %r14
	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	$136, %rsp
	.cfi_def_cfa_offset 192
	movq	%fs:40, %rax
	movq	%rax, 120(%rsp)
	xorl	%eax, %eax
	leaq	108(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movl	108(%rsp), %eax
	leal	-1(%rax), %edx
	movl	%edx, 108(%rsp)
	leaq	113(%rsp), %rdx
	movq	%rdx, 80(%rsp)
	testl	%eax, %eax
	jle	.L31
	.p2align 4,,10
	.p2align 3
.L2:
	movq	80(%rsp), %rbx
	movq	%r14, %rdx
	xorl	%eax, %eax
	movq	%r14, %rbp
	leaq	.LC1(%rip), %rdi
	movq	%rbx, %rsi
	call	__isoc99_scanf@PLT
	movq	%r14, %rdi
	call	strlen@PLT
	movq	%rbx, %rdi
	movl	%eax, w(%rip)
	movq	%rax, %r13
	cltq
	movb	$0, 30(%r14,%rax)
	call	strlen@PLT
	leaq	-1(%rbx,%rax), %r12
	cmpq	%rbx, %r12
	jb	.L3
	movl	%r13d, %eax
	movl	$1, %r15d
	movq	%r13, 16(%rsp)
	sarl	%eax
	movslq	%eax, %rdx
	movl	%eax, 64(%rsp)
	movq	%rdx, 48(%rsp)
	movl	%r13d, %edx
	movl	%r15d, %r13d
	movq	%r12, %r15
	andl	$1, %edx
	movl	%edx, 28(%rsp)
	leal	-1(%rax), %edx
	xorl	%eax, %eax
	testl	%edx, %edx
	movl	%edx, 92(%rsp)
	cmovns	%edx, %eax
	xorl	%ecx, %ecx
	movl	%eax, %esi
	movl	%eax, 68(%rsp)
	leal	1(%rax), %eax
	movl	%eax, %edi
	movl	%eax, 32(%rsp)
	cltq
	andl	$-16, %edi
	movq	%rax, 56(%rsp)
	subl	%edi, %edx
	subl	%edi, %esi
	movl	%edi, %ebx
	movl	%edi, 36(%rsp)
	movl	%edx, 72(%rsp)
	leal	1(%rsi), %eax
	leaq	112(%rsp), %rdx
	movq	%rbx, 40(%rsp)
	movq	%rdx, 8(%rsp)
	movl	%esi, 76(%rsp)
	movl	%eax, 88(%rsp)
	.p2align 4,,10
	.p2align 3
.L30:
	movq	%rcx, %rax
	movslq	%r13d, %rdi
	salq	$4, %rax
	subq	%rcx, %rax
	movq	%rdi, %rcx
	salq	$4, %rcx
	addq	%rax, %rax
	subq	%rdi, %rcx
	movzbl	(%r15), %edi
	leaq	(%r14,%rax), %rbx
	leaq	(%r14,%rcx,2), %rbp
	cmpb	$65, %dil
	je	.L87
	cmpb	$67, %dil
	je	.L88
	cmpb	$69, %dil
	je	.L89
	cmpb	$74, %dil
	je	.L90
	movzbl	(%rbx), %r12d
	cmpb	$77, %dil
	je	.L24
	testb	%r12b, %r12b
	je	.L6
	call	__ctype_b_loc@PLT
	movl	$57, %edx
	movq	%rax, %r9
	xorl	%eax, %eax
	.p2align 4,,10
	.p2align 3
.L29:
	movq	(%r9), %rsi
	movsbq	%r12b, %rcx
	testb	$8, 1(%rsi,%rcx,2)
	je	.L28
	leal	-1(%r12), %ecx
	cmpb	$48, %r12b
	cmove	%edx, %ecx
	movl	%ecx, %r12d
.L28:
	movb	%r12b, 0(%rbp,%rax)
	addq	$1, %rax
	movzbl	(%rbx,%rax), %r12d
	testb	%r12b, %r12b
	jne	.L29
.L6:
	movl	%r13d, %eax
	subq	$1, %r15
	movslq	%r13d, %rcx
	xorl	$1, %eax
	cmpq	8(%rsp), %r15
	je	.L3
	movl	%eax, %r13d
	jmp	.L30
	.p2align 4,,10
	.p2align 3
.L24:
	testb	%r12b, %r12b
	je	.L6
	call	__ctype_b_loc@PLT
	movq	%rax, %r9
	xorl	%eax, %eax
	.p2align 4,,10
	.p2align 3
.L27:
	movq	(%r9), %rsi
	movsbq	%r12b, %rcx
	testb	$8, 1(%rsi,%rcx,2)
	je	.L26
	leal	1(%r12), %ecx
	cmpb	$57, %r12b
	movl	$48, %r12d
	cmovne	%ecx, %r12d
.L26:
	movb	%r12b, 0(%rbp,%rax)
	addq	$1, %rax
	movzbl	(%rbx,%rax), %r12d
	testb	%r12b, %r12b
	jne	.L27
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L87:
	movq	16(%rsp), %rax
	leaq	0(%rbp,%rax), %rcx
	movzbl	(%rbx), %eax
	testb	%al, %al
	je	.L6
	.p2align 4,,10
	.p2align 3
.L5:
	addq	$1, %rbx
	movb	%al, -1(%rcx)
	subq	$1, %rcx
	movzbl	(%rbx), %eax
	testb	%al, %al
	jne	.L5
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L88:
	movzbl	(%rbx), %eax
	movq	16(%rsp), %rsi
	movb	%al, -1(%rbp,%rsi)
	movzbl	1(%rbx), %ecx
	testb	%cl, %cl
	je	.L6
	xorl	%eax, %eax
	.p2align 4,,10
	.p2align 3
.L9:
	movb	%cl, 0(%rbp,%rax)
	addq	$1, %rax
	movzbl	1(%rbx,%rax), %ecx
	testb	%cl, %cl
	jne	.L9
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L3:
	movq	%rbp, %rdi
	call	puts@PLT
	movl	108(%rsp), %eax
	leal	-1(%rax), %edx
	movl	%edx, 108(%rsp)
	testl	%eax, %eax
	jg	.L2
.L31:
	movq	120(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L91
	addq	$136, %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
.L89:
	.cfi_restore_state
	movq	48(%rsp), %rsi
	movl	28(%rsp), %r8d
	addq	%rbp, %rsi
	testl	%r8d, %r8d
	je	.L11
	movl	64(%rsp), %edi
	leaq	1(%rsi), %rcx
	testl	%edi, %edi
	je	.L12
.L32:
	leaq	1(%r14,%rax), %r8
	movq	%rcx, %rdi
	subq	%r8, %rdi
	cmpq	$14, %rdi
	jbe	.L36
	movl	68(%rsp), %edi
	cmpl	$6, %edi
	jbe	.L36
	cmpl	$14, %edi
	jbe	.L14
	movq	40(%rsp), %r11
	movdqu	(%rbx), %xmm0
	movl	36(%rsp), %r10d
	movups	%xmm0, (%rcx)
	leaq	(%rbx,%r11), %rdi
	leaq	(%rcx,%r11), %r8
	cmpl	%r10d, 32(%rsp)
	je	.L18
	cmpl	$6, 76(%rsp)
	movl	88(%rsp), %r11d
	movl	72(%rsp), %r9d
	jbe	.L16
.L33:
	addq	%r14, %rax
	movq	(%rax,%r10), %rax
	movq	%rax, (%rcx,%r10)
	movl	%r11d, %eax
	andl	$-8, %eax
	movl	%eax, %ecx
	subl	%eax, %r9d
	addq	%rcx, %rdi
	addq	%rcx, %r8
	cmpl	%eax, %r11d
	je	.L18
.L16:
	movzbl	(%rdi), %eax
	movb	%al, (%r8)
	testl	%r9d, %r9d
	jle	.L18
	movzbl	1(%rdi), %eax
	movb	%al, 1(%r8)
	cmpl	$1, %r9d
	jle	.L18
	movzbl	2(%rdi), %eax
	movb	%al, 2(%r8)
	cmpl	$2, %r9d
	jle	.L18
	movzbl	3(%rdi), %eax
	movb	%al, 3(%r8)
	cmpl	$3, %r9d
	jle	.L18
	movzbl	4(%rdi), %eax
	movb	%al, 4(%r8)
	cmpl	$4, %r9d
	jle	.L18
	movzbl	5(%rdi), %eax
	movb	%al, 5(%r8)
	cmpl	$5, %r9d
	jle	.L18
	movzbl	6(%rdi), %eax
	movb	%al, 6(%r8)
.L18:
	movl	28(%rsp), %ecx
	addq	56(%rsp), %rbx
	testl	%ecx, %ecx
	je	.L19
.L12:
	movzbl	(%rbx), %eax
	addq	$1, %rbx
	movb	%al, (%rsi)
.L19:
	movzbl	(%rbx), %ecx
	testb	%cl, %cl
	je	.L6
	xorl	%eax, %eax
	.p2align 4,,10
	.p2align 3
.L20:
	movb	%cl, 0(%rbp,%rax)
	addq	$1, %rax
	movzbl	(%rbx,%rax), %ecx
	testb	%cl, %cl
	jne	.L20
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L90:
	movq	16(%rsp), %rsi
	leaq	1(%rbp), %rax
	movzbl	-1(%rbx,%rsi), %ecx
	movb	%cl, 0(%rbp)
	movzbl	(%rbx), %ecx
	testb	%cl, %cl
	je	.L22
	.p2align 4,,10
	.p2align 3
.L23:
	addq	$1, %rbx
	movb	%cl, (%rax)
	addq	$1, %rax
	movzbl	(%rbx), %ecx
	testb	%cl, %cl
	jne	.L23
.L22:
	movb	$0, -1(%rax)
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L11:
	movl	64(%rsp), %edx
	movq	%rsi, %rcx
	testl	%edx, %edx
	jne	.L32
	jmp	.L19
.L36:
	movl	64(%rsp), %r8d
	xorl	%eax, %eax
	.p2align 4,,10
	.p2align 3
.L13:
	movzbl	(%rbx,%rax), %edi
	movb	%dil, (%rcx,%rax)
	addq	$1, %rax
	movl	%r8d, %edi
	subl	%eax, %edi
	testl	%edi, %edi
	jg	.L13
	jmp	.L18
.L14:
	movl	32(%rsp), %r11d
	movl	92(%rsp), %r9d
	movq	%rcx, %r8
	movq	%rbx, %rdi
	xorl	%r10d, %r10d
	jmp	.L33
.L91:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE37:
	.size	main, .-main
	.globl	w
	.bss
	.align 4
	.type	w, @object
	.size	w, 4
w:
	.zero	4
	.globl	msg
	.align 32
	.type	msg, @object
	.size	msg, 60
msg:
	.zero	60
	.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	"%d"
.LC1:
	.string	"%s%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
	leaq	.LC0(%rip), %rdi
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	leaq	msg(%rip), %r14
	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	$136, %rsp
	.cfi_def_cfa_offset 192
	movq	%fs:40, %rax
	movq	%rax, 120(%rsp)
	xorl	%eax, %eax
	leaq	108(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movl	108(%rsp), %eax
	leal	-1(%rax), %edx
	movl	%edx, 108(%rsp)
	leaq	113(%rsp), %rdx
	movq	%rdx, 80(%rsp)
	testl	%eax, %eax
	jle	.L31
	.p2align 4,,10
	.p2align 3
.L2:
	movq	80(%rsp), %rbx
	movq	%r14, %rdx
	xorl	%eax, %eax
	movq	%r14, %rbp
	leaq	.LC1(%rip), %rdi
	movq	%rbx, %rsi
	call	__isoc99_scanf@PLT
	movq	%r14, %rdi
	call	strlen@PLT
	movq	%rbx, %rdi
	movl	%eax, w(%rip)
	movq	%rax, %r13
	cltq
	movb	$0, 30(%r14,%rax)
	call	strlen@PLT
	leaq	-1(%rbx,%rax), %r12
	cmpq	%rbx, %r12
	jb	.L3
	movl	%r13d, %eax
	movl	$1, %r15d
	movq	%r13, 16(%rsp)
	sarl	%eax
	movslq	%eax, %rdx
	movl	%eax, 64(%rsp)
	movq	%rdx, 48(%rsp)
	movl	%r13d, %edx
	movl	%r15d, %r13d
	movq	%r12, %r15
	andl	$1, %edx
	movl	%edx, 28(%rsp)
	leal	-1(%rax), %edx
	xorl	%eax, %eax
	testl	%edx, %edx
	movl	%edx, 92(%rsp)
	cmovns	%edx, %eax
	xorl	%ecx, %ecx
	movl	%eax, %esi
	movl	%eax, 68(%rsp)
	leal	1(%rax), %eax
	movl	%eax, %edi
	movl	%eax, 32(%rsp)
	cltq
	andl	$-16, %edi
	movq	%rax, 56(%rsp)
	subl	%edi, %edx
	subl	%edi, %esi
	movl	%edi, %ebx
	movl	%edi, 36(%rsp)
	movl	%edx, 72(%rsp)
	leal	1(%rsi), %eax
	leaq	112(%rsp), %rdx
	movq	%rbx, 40(%rsp)
	movq	%rdx, 8(%rsp)
	movl	%esi, 76(%rsp)
	movl	%eax, 88(%rsp)
	.p2align 4,,10
	.p2align 3
.L30:
	movq	%rcx, %rax
	movslq	%r13d, %rdi
	salq	$4, %rax
	subq	%rcx, %rax
	movq	%rdi, %rcx
	salq	$4, %rcx
	addq	%rax, %rax
	subq	%rdi, %rcx
	movzbl	(%r15), %edi
	leaq	(%r14,%rax), %rbx
	leaq	(%r14,%rcx,2), %rbp
	cmpb	$65, %dil
	je	.L87
	cmpb	$67, %dil
	je	.L88
	cmpb	$69, %dil
	je	.L89
	cmpb	$74, %dil
	je	.L90
	movzbl	(%rbx), %r12d
	cmpb	$77, %dil
	je	.L24
	testb	%r12b, %r12b
	je	.L6
	call	__ctype_b_loc@PLT
	movl	$57, %edx
	movq	%rax, %r9
	xorl	%eax, %eax
	.p2align 4,,10
	.p2align 3
.L29:
	movq	(%r9), %rsi
	movsbq	%r12b, %rcx
	testb	$8, 1(%rsi,%rcx,2)
	je	.L28
	leal	-1(%r12), %ecx
	cmpb	$48, %r12b
	cmove	%edx, %ecx
	movl	%ecx, %r12d
.L28:
	movb	%r12b, 0(%rbp,%rax)
	addq	$1, %rax
	movzbl	(%rbx,%rax), %r12d
	testb	%r12b, %r12b
	jne	.L29
.L6:
	movl	%r13d, %eax
	subq	$1, %r15
	movslq	%r13d, %rcx
	xorl	$1, %eax
	cmpq	8(%rsp), %r15
	je	.L3
	movl	%eax, %r13d
	jmp	.L30
	.p2align 4,,10
	.p2align 3
.L24:
	testb	%r12b, %r12b
	je	.L6
	call	__ctype_b_loc@PLT
	movq	%rax, %r9
	xorl	%eax, %eax
	.p2align 4,,10
	.p2align 3
.L27:
	movq	(%r9), %rsi
	movsbq	%r12b, %rcx
	testb	$8, 1(%rsi,%rcx,2)
	je	.L26
	leal	1(%r12), %ecx
	cmpb	$57, %r12b
	movl	$48, %r12d
	cmovne	%ecx, %r12d
.L26:
	movb	%r12b, 0(%rbp,%rax)
	addq	$1, %rax
	movzbl	(%rbx,%rax), %r12d
	testb	%r12b, %r12b
	jne	.L27
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L87:
	movq	16(%rsp), %rax
	leaq	0(%rbp,%rax), %rcx
	movzbl	(%rbx), %eax
	testb	%al, %al
	je	.L6
	.p2align 4,,10
	.p2align 3
.L5:
	addq	$1, %rbx
	movb	%al, -1(%rcx)
	subq	$1, %rcx
	movzbl	(%rbx), %eax
	testb	%al, %al
	jne	.L5
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L88:
	movzbl	(%rbx), %eax
	movq	16(%rsp), %rsi
	movb	%al, -1(%rbp,%rsi)
	movzbl	1(%rbx), %ecx
	testb	%cl, %cl
	je	.L6
	xorl	%eax, %eax
	.p2align 4,,10
	.p2align 3
.L9:
	movb	%cl, 0(%rbp,%rax)
	addq	$1, %rax
	movzbl	1(%rbx,%rax), %ecx
	testb	%cl, %cl
	jne	.L9
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L3:
	movq	%rbp, %rdi
	call	puts@PLT
	movl	108(%rsp), %eax
	leal	-1(%rax), %edx
	movl	%edx, 108(%rsp)
	testl	%eax, %eax
	jg	.L2
.L31:
	movq	120(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L91
	addq	$136, %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
.L89:
	.cfi_restore_state
	movq	48(%rsp), %rsi
	movl	28(%rsp), %r8d
	addq	%rbp, %rsi
	testl	%r8d, %r8d
	je	.L11
	movl	64(%rsp), %edi
	leaq	1(%rsi), %rcx
	testl	%edi, %edi
	je	.L12
.L32:
	leaq	1(%r14,%rax), %r8
	movq	%rcx, %rdi
	subq	%r8, %rdi
	cmpq	$14, %rdi
	jbe	.L36
	movl	68(%rsp), %edi
	cmpl	$6, %edi
	jbe	.L36
	cmpl	$14, %edi
	jbe	.L14
	movq	40(%rsp), %r11
	movdqu	(%rbx), %xmm0
	movl	36(%rsp), %r10d
	movups	%xmm0, (%rcx)
	leaq	(%rbx,%r11), %rdi
	leaq	(%rcx,%r11), %r8
	cmpl	%r10d, 32(%rsp)
	je	.L18
	cmpl	$6, 76(%rsp)
	movl	88(%rsp), %r11d
	movl	72(%rsp), %r9d
	jbe	.L16
.L33:
	addq	%r14, %rax
	movq	(%rax,%r10), %rax
	movq	%rax, (%rcx,%r10)
	movl	%r11d, %eax
	andl	$-8, %eax
	movl	%eax, %ecx
	subl	%eax, %r9d
	addq	%rcx, %rdi
	addq	%rcx, %r8
	cmpl	%eax, %r11d
	je	.L18
.L16:
	movzbl	(%rdi), %eax
	movb	%al, (%r8)
	testl	%r9d, %r9d
	jle	.L18
	movzbl	1(%rdi), %eax
	movb	%al, 1(%r8)
	cmpl	$1, %r9d
	jle	.L18
	movzbl	2(%rdi), %eax
	movb	%al, 2(%r8)
	cmpl	$2, %r9d
	jle	.L18
	movzbl	3(%rdi), %eax
	movb	%al, 3(%r8)
	cmpl	$3, %r9d
	jle	.L18
	movzbl	4(%rdi), %eax
	movb	%al, 4(%r8)
	cmpl	$4, %r9d
	jle	.L18
	movzbl	5(%rdi), %eax
	movb	%al, 5(%r8)
	cmpl	$5, %r9d
	jle	.L18
	movzbl	6(%rdi), %eax
	movb	%al, 6(%r8)
.L18:
	movl	28(%rsp), %ecx
	addq	56(%rsp), %rbx
	testl	%ecx, %ecx
	je	.L19
.L12:
	movzbl	(%rbx), %eax
	addq	$1, %rbx
	movb	%al, (%rsi)
.L19:
	movzbl	(%rbx), %ecx
	testb	%cl, %cl
	je	.L6
	xorl	%eax, %eax
	.p2align 4,,10
	.p2align 3
.L20:
	movb	%cl, 0(%rbp,%rax)
	addq	$1, %rax
	movzbl	(%rbx,%rax), %ecx
	testb	%cl, %cl
	jne	.L20
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L90:
	movq	16(%rsp), %rsi
	leaq	1(%rbp), %rax
	movzbl	-1(%rbx,%rsi), %ecx
	movb	%cl, 0(%rbp)
	movzbl	(%rbx), %ecx
	testb	%cl, %cl
	je	.L22
	.p2align 4,,10
	.p2align 3
.L23:
	addq	$1, %rbx
	movb	%cl, (%rax)
	addq	$1, %rax
	movzbl	(%rbx), %ecx
	testb	%cl, %cl
	jne	.L23
.L22:
	movb	$0, -1(%rax)
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L11:
	movl	64(%rsp), %edx
	movq	%rsi, %rcx
	testl	%edx, %edx
	jne	.L32
	jmp	.L19
.L36:
	movl	64(%rsp), %r8d
	xorl	%eax, %eax
	.p2align 4,,10
	.p2align 3
.L13:
	movzbl	(%rbx,%rax), %edi
	movb	%dil, (%rcx,%rax)
	addq	$1, %rax
	movl	%r8d, %edi
	subl	%eax, %edi
	testl	%edi, %edi
	jg	.L13
	jmp	.L18
.L14:
	movl	32(%rsp), %r11d
	movl	92(%rsp), %r9d
	movq	%rcx, %r8
	movq	%rbx, %rdi
	xorl	%r10d, %r10d
	jmp	.L33
.L91:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE37:
	.size	main, .-main
	.globl	w
	.bss
	.align 4
	.type	w, @object
	.size	w, 4
w:
	.zero	4
	.globl	msg
	.align 32
	.type	msg, @object
	.size	msg, 60
msg:
	.zero	60
	.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:

// AOJ 1240: Unreliable Message
// 2017.10.17 bal4u@uu

#include <stdio.h>
#include <string.h>
#include <ctype.h>

char msg[2][30]; int w;

int main()
{
	int t, k1, k2, i;
	char ord[7], *s, *p, *q;

	scanf("%d", &t);
	while (t-- > 0) {
		scanf("%s%s", ord, msg[0]);
		w = strlen(msg[0]); msg[1][w] = 0; s = ord + strlen(ord)-1;
		for (k1 = 0, k2 = 1; s >= ord; s--, k1 = k2, k2 = !k2) {
			p = msg[k1], q = msg[k2];
			if (*s == 'A') {
				q += w;	while (*p) *--q = *p++;
			} else if (*s == 'C') {
				*(q+w-1) = *p++; while (*p) *q++ = *p++;
			} else if (*s == 'E') {
				i = w/2; q += i; if (w & 1) q++;
				while(i-- > 0) *q++ = *p++;
				q = msg[k2]; if (w & 1) *(q+w/2) = *p++;
				while(*p) *q++ = *p++;
			} else if (*s == 'J') {
				*q++ = *(p+w-1); while (*p) *q++ = *p++;
				*(q-1) = 0;
			} else if (*s == 'M') {
				while (*p) {
					if (isdigit(*p)) {
						if (*p == '9') *q = '0'; else *q = (*p)+1;
					} else *q = *p;
					p++, q++;
				}
			} else {
				while (*p) {
					if (isdigit(*p)) {
						if (*p == '0') *q = '9'; else *q = (*p)-1;
					} else *q = *p;
					p++, q++;
				}
			}
		}
		puts(msg[k1]);
	}
 	return 0;
}
5
AJMP
aB33d
E
86AE
AM
6
JPEM
WaEaETC302Q
CP
rTurnAGundam1isdefferentf
 5
AJMP
aB33d
E
86AE
AM
6
EPJM
WaEaETC302Q
CP
rTurnAGundam1isdefferentf
 5
AJMP
aB33d
E
86AE
AM
0
EPJM
WaEaETC302Q
CP
rTurnAGundam1isdefferentf
 5
AJMP
aB33d
E
86AE
AM
0
MPJE
WaEaETC302Q
CP
rTurnAGundam1isdefferentf
 5
AJMP
aB33d
E
86AE
AM
0
MPJE
WaEaETC302Q
CP
rTurnAGumdam1isdefferentf
 5
AJMP
aB33d
E
86AE
AM
1
MPJE
WaEaETC302Q
CP
rTurnAGumdam1isdefferentf
 5
AJMP
aB23d
E
EA68
AM
6
JPEM
WaEaETC302Q
CP
rTurnAGundam1isdefferentf
 5
AJMP
aB33d
E
EA68
AM
6
JPEM
WaEaETC302Q
CP
rTurnAGundam1isdefferentf
 5
AJMP
aB33d
E
86AE
AM
1
EPJM
WaEaETC302Q
CP
rTurnAGundam1isdefferentf
 5
AJMP
aB33d
E
86AE
AM
-1
MPJE
WaEaETC302Q
CP
rTurnAGumdam1isdefferentf

33Bad
AE86
7
EC302QTWaEa
TurnAGundam0isdefferentfr
 33Bad
AE86
7
TC302EQWaEa
TurnAGundam0isdefferentfr
 33Bad
AE86
1
TC302EQWaEa
TurnAGundam0isdefferentfr
 33Bad
AE86
1
EC302QTWaEa
TurnAGundam0isdefferentfr
 33Bad
AE86
1
EC302QTWaEa
TurnAGumdam0isdefferentfr
 33Bad
AE86
2
EC302QTWaEa
TurnAGumdam0isdefferentfr
 32Bad
68EA
7
EC302QTWaEa
TurnAGundam0isdefferentfr
 33Bad
68EA
7
EC302QTWaEa
TurnAGundam0isdefferentfr
 33Bad
AE86
2
TC302EQWaEa
TurnAGundam0isdefferentfr
 33Bad
AE86
2-
EC302QTWaEa
TurnAGumdam0isdefferentfr

Given the following C code and unoptimized assembly code, your task is to generate highly optimized x86-64 assembly code.
C Code:

```c
// AOJ 1240: Unreliable Message
// 2017.10.17 bal4u@uu

#include <stdio.h>
#include <string.h>
#include <ctype.h>

char msg[2][30]; int w;

int main()
{
	int t, k1, k2, i;
	char ord[7], *s, *p, *q;

	scanf("%d", &t);
	while (t-- > 0) {
		scanf("%s%s", ord, msg[0]);
		w = strlen(msg[0]); msg[1][w] = 0; s = ord + strlen(ord)-1;
		for (k1 = 0, k2 = 1; s >= ord; s--, k1 = k2, k2 = !k2) {
			p = msg[k1], q = msg[k2];
			if (*s == 'A') {
				q += w;	while (*p) *--q = *p++;
			} else if (*s == 'C') {
				*(q+w-1) = *p++; while (*p) *q++ = *p++;
			} else if (*s == 'E') {
				i = w/2; q += i; if (w & 1) q++;
				while(i-- > 0) *q++ = *p++;
				q = msg[k2]; if (w & 1) *(q+w/2) = *p++;
				while(*p) *q++ = *p++;
			} else if (*s == 'J') {
				*q++ = *(p+w-1); while (*p) *q++ = *p++;
				*(q-1) = 0;
			} else if (*s == 'M') {
				while (*p) {
					if (isdigit(*p)) {
						if (*p == '9') *q = '0'; else *q = (*p)+1;
					} else *q = *p;
					p++, q++;
				}
			} else {
				while (*p) {
					if (isdigit(*p)) {
						if (*p == '0') *q = '9'; else *q = (*p)-1;
					} else *q = *p;
					p++, q++;
				}
			}
		}
		puts(msg[k1]);
	}
 	return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	msg
	.bss
	.align 32
	.type	msg, @object
	.size	msg, 60
msg:
	.zero	60
	.globl	w
	.align 4
	.type	w, @object
	.size	w, 4
w:
	.zero	4
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%s%s"
	.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	$64, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-56(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	jmp	.L2
.L33:
	leaq	-15(%rbp), %rax
	leaq	msg(%rip), %rdx
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	leaq	msg(%rip), %rax
	movq	%rax, %rdi
	call	strlen@PLT
	movl	%eax, w(%rip)
	movl	w(%rip), %eax
	cltq
	leaq	30+msg(%rip), %rdx
	movb	$0, (%rax,%rdx)
	leaq	-15(%rbp), %rax
	movq	%rax, %rdi
	call	strlen@PLT
	leaq	-1(%rax), %rdx
	leaq	-15(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, -40(%rbp)
	movl	$0, -52(%rbp)
	movl	$1, -48(%rbp)
	jmp	.L3
.L32:
	movl	-52(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$4, %rax
	subq	%rdx, %rax
	addq	%rax, %rax
	leaq	msg(%rip), %rdx
	addq	%rdx, %rax
	movq	%rax, -32(%rbp)
	movl	-48(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$4, %rax
	subq	%rdx, %rax
	addq	%rax, %rax
	leaq	msg(%rip), %rdx
	addq	%rdx, %rax
	movq	%rax, -24(%rbp)
	movq	-40(%rbp), %rax
	movzbl	(%rax), %eax
	cmpb	$65, %al
	jne	.L4
	movl	w(%rip), %eax
	cltq
	addq	%rax, -24(%rbp)
	jmp	.L5
.L6:
	movq	-32(%rbp), %rax
	leaq	1(%rax), %rdx
	movq	%rdx, -32(%rbp)
	subq	$1, -24(%rbp)
	movzbl	(%rax), %edx
	movq	-24(%rbp), %rax
	movb	%dl, (%rax)
.L5:
	movq	-32(%rbp), %rax
	movzbl	(%rax), %eax
	testb	%al, %al
	jne	.L6
	jmp	.L7
.L4:
	movq	-40(%rbp), %rax
	movzbl	(%rax), %eax
	cmpb	$67, %al
	jne	.L8
	movq	-32(%rbp), %rax
	leaq	1(%rax), %rdx
	movq	%rdx, -32(%rbp)
	movl	w(%rip), %edx
	movslq	%edx, %rdx
	leaq	-1(%rdx), %rcx
	movq	-24(%rbp), %rdx
	addq	%rcx, %rdx
	movzbl	(%rax), %eax
	movb	%al, (%rdx)
	jmp	.L9
.L10:
	movq	-32(%rbp), %rdx
	leaq	1(%rdx), %rax
	movq	%rax, -32(%rbp)
	movq	-24(%rbp), %rax
	leaq	1(%rax), %rcx
	movq	%rcx, -24(%rbp)
	movzbl	(%rdx), %edx
	movb	%dl, (%rax)
.L9:
	movq	-32(%rbp), %rax
	movzbl	(%rax), %eax
	testb	%al, %al
	jne	.L10
	jmp	.L7
.L8:
	movq	-40(%rbp), %rax
	movzbl	(%rax), %eax
	cmpb	$69, %al
	jne	.L11
	movl	w(%rip), %eax
	movl	%eax, %edx
	shrl	$31, %edx
	addl	%edx, %eax
	sarl	%eax
	movl	%eax, -44(%rbp)
	movl	-44(%rbp), %eax
	cltq
	addq	%rax, -24(%rbp)
	movl	w(%rip), %eax
	andl	$1, %eax
	testl	%eax, %eax
	je	.L13
	addq	$1, -24(%rbp)
	jmp	.L13
.L14:
	movq	-32(%rbp), %rdx
	leaq	1(%rdx), %rax
	movq	%rax, -32(%rbp)
	movq	-24(%rbp), %rax
	leaq	1(%rax), %rcx
	movq	%rcx, -24(%rbp)
	movzbl	(%rdx), %edx
	movb	%dl, (%rax)
.L13:
	movl	-44(%rbp), %eax
	leal	-1(%rax), %edx
	movl	%edx, -44(%rbp)
	testl	%eax, %eax
	jg	.L14
	movl	-48(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$4, %rax
	subq	%rdx, %rax
	addq	%rax, %rax
	leaq	msg(%rip), %rdx
	addq	%rdx, %rax
	movq	%rax, -24(%rbp)
	movl	w(%rip), %eax
	andl	$1, %eax
	testl	%eax, %eax
	je	.L16
	movq	-32(%rbp), %rax
	leaq	1(%rax), %rdx
	movq	%rdx, -32(%rbp)
	movl	w(%rip), %edx
	movl	%edx, %ecx
	shrl	$31, %ecx
	addl	%ecx, %edx
	sarl	%edx
	movslq	%edx, %rcx
	movq	-24(%rbp), %rdx
	addq	%rcx, %rdx
	movzbl	(%rax), %eax
	movb	%al, (%rdx)
	jmp	.L16
.L17:
	movq	-32(%rbp), %rdx
	leaq	1(%rdx), %rax
	movq	%rax, -32(%rbp)
	movq	-24(%rbp), %rax
	leaq	1(%rax), %rcx
	movq	%rcx, -24(%rbp)
	movzbl	(%rdx), %edx
	movb	%dl, (%rax)
.L16:
	movq	-32(%rbp), %rax
	movzbl	(%rax), %eax
	testb	%al, %al
	jne	.L17
	jmp	.L7
.L11:
	movq	-40(%rbp), %rax
	movzbl	(%rax), %eax
	cmpb	$74, %al
	jne	.L18
	movl	w(%rip), %eax
	cltq
	leaq	-1(%rax), %rdx
	movq	-32(%rbp), %rax
	leaq	(%rdx,%rax), %rcx
	movq	-24(%rbp), %rax
	leaq	1(%rax), %rdx
	movq	%rdx, -24(%rbp)
	movzbl	(%rcx), %edx
	movb	%dl, (%rax)
	jmp	.L19
.L20:
	movq	-32(%rbp), %rdx
	leaq	1(%rdx), %rax
	movq	%rax, -32(%rbp)
	movq	-24(%rbp), %rax
	leaq	1(%rax), %rcx
	movq	%rcx, -24(%rbp)
	movzbl	(%rdx), %edx
	movb	%dl, (%rax)
.L19:
	movq	-32(%rbp), %rax
	movzbl	(%rax), %eax
	testb	%al, %al
	jne	.L20
	movq	-24(%rbp), %rax
	subq	$1, %rax
	movb	$0, (%rax)
	jmp	.L7
.L18:
	movq	-40(%rbp), %rax
	movzbl	(%rax), %eax
	cmpb	$77, %al
	jne	.L27
	jmp	.L22
.L26:
	call	__ctype_b_loc@PLT
	movq	(%rax), %rdx
	movq	-32(%rbp), %rax
	movzbl	(%rax), %eax
	movsbq	%al, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	movzwl	(%rax), %eax
	movzwl	%ax, %eax
	andl	$2048, %eax
	testl	%eax, %eax
	je	.L23
	movq	-32(%rbp), %rax
	movzbl	(%rax), %eax
	cmpb	$57, %al
	jne	.L24
	movq	-24(%rbp), %rax
	movb	$48, (%rax)
	jmp	.L25
.L24:
	movq	-32(%rbp), %rax
	movzbl	(%rax), %eax
	addl	$1, %eax
	movl	%eax, %edx
	movq	-24(%rbp), %rax
	movb	%dl, (%rax)
	jmp	.L25
.L23:
	movq	-32(%rbp), %rax
	movzbl	(%rax), %edx
	movq	-24(%rbp), %rax
	movb	%dl, (%rax)
.L25:
	addq	$1, -32(%rbp)
	addq	$1, -24(%rbp)
.L22:
	movq	-32(%rbp), %rax
	movzbl	(%rax), %eax
	testb	%al, %al
	jne	.L26
	jmp	.L7
.L31:
	call	__ctype_b_loc@PLT
	movq	(%rax), %rdx
	movq	-32(%rbp), %rax
	movzbl	(%rax), %eax
	movsbq	%al, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	movzwl	(%rax), %eax
	movzwl	%ax, %eax
	andl	$2048, %eax
	testl	%eax, %eax
	je	.L28
	movq	-32(%rbp), %rax
	movzbl	(%rax), %eax
	cmpb	$48, %al
	jne	.L29
	movq	-24(%rbp), %rax
	movb	$57, (%rax)
	jmp	.L30
.L29:
	movq	-32(%rbp), %rax
	movzbl	(%rax), %eax
	subl	$1, %eax
	movl	%eax, %edx
	movq	-24(%rbp), %rax
	movb	%dl, (%rax)
	jmp	.L30
.L28:
	movq	-32(%rbp), %rax
	movzbl	(%rax), %edx
	movq	-24(%rbp), %rax
	movb	%dl, (%rax)
.L30:
	addq	$1, -32(%rbp)
	addq	$1, -24(%rbp)
.L27:
	movq	-32(%rbp), %rax
	movzbl	(%rax), %eax
	testb	%al, %al
	jne	.L31
.L7:
	subq	$1, -40(%rbp)
	movl	-48(%rbp), %eax
	movl	%eax, -52(%rbp)
	cmpl	$0, -48(%rbp)
	sete	%al
	movzbl	%al, %eax
	movl	%eax, -48(%rbp)
.L3:
	leaq	-15(%rbp), %rax
	cmpq	%rax, -40(%rbp)
	jnb	.L32
	movl	-52(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$4, %rax
	subq	%rdx, %rax
	addq	%rax, %rax
	leaq	msg(%rip), %rdx
	addq	%rdx, %rax
	movq	%rax, %rdi
	call	puts@PLT
.L2:
	movl	-56(%rbp), %eax
	leal	-1(%rax), %edx
	movl	%edx, -56(%rbp)
	testl	%eax, %eax
	jg	.L33
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L35
	call	__stack_chk_fail@PLT
.L35:
	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
	.globl	msg
	.bss
	.align 32
	.type	msg, @object
	.size	msg, 60
msg:
	.zero	60
	.globl	w
	.align 4
	.type	w, @object
	.size	w, 4
w:
	.zero	4
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%s%s"
	.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	$64, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-56(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	jmp	.L2
.L33:
	leaq	-15(%rbp), %rax
	leaq	msg(%rip), %rdx
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	leaq	msg(%rip), %rax
	movq	%rax, %rdi
	call	strlen@PLT
	movl	%eax, w(%rip)
	movl	w(%rip), %eax
	cltq
	leaq	30+msg(%rip), %rdx
	movb	$0, (%rax,%rdx)
	leaq	-15(%rbp), %rax
	movq	%rax, %rdi
	call	strlen@PLT
	leaq	-1(%rax), %rdx
	leaq	-15(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, -40(%rbp)
	movl	$0, -52(%rbp)
	movl	$1, -48(%rbp)
	jmp	.L3
.L32:
	movl	-52(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$4, %rax
	subq	%rdx, %rax
	addq	%rax, %rax
	leaq	msg(%rip), %rdx
	addq	%rdx, %rax
	movq	%rax, -32(%rbp)
	movl	-48(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$4, %rax
	subq	%rdx, %rax
	addq	%rax, %rax
	leaq	msg(%rip), %rdx
	addq	%rdx, %rax
	movq	%rax, -24(%rbp)
	movq	-40(%rbp), %rax
	movzbl	(%rax), %eax
	cmpb	$65, %al
	jne	.L4
	movl	w(%rip), %eax
	cltq
	addq	%rax, -24(%rbp)
	jmp	.L5
.L6:
	movq	-32(%rbp), %rax
	leaq	1(%rax), %rdx
	movq	%rdx, -32(%rbp)
	subq	$1, -24(%rbp)
	movzbl	(%rax), %edx
	movq	-24(%rbp), %rax
	movb	%dl, (%rax)
.L5:
	movq	-32(%rbp), %rax
	movzbl	(%rax), %eax
	testb	%al, %al
	jne	.L6
	jmp	.L7
.L4:
	movq	-40(%rbp), %rax
	movzbl	(%rax), %eax
	cmpb	$67, %al
	jne	.L8
	movq	-32(%rbp), %rax
	leaq	1(%rax), %rdx
	movq	%rdx, -32(%rbp)
	movl	w(%rip), %edx
	movslq	%edx, %rdx
	leaq	-1(%rdx), %rcx
	movq	-24(%rbp), %rdx
	addq	%rcx, %rdx
	movzbl	(%rax), %eax
	movb	%al, (%rdx)
	jmp	.L9
.L10:
	movq	-32(%rbp), %rdx
	leaq	1(%rdx), %rax
	movq	%rax, -32(%rbp)
	movq	-24(%rbp), %rax
	leaq	1(%rax), %rcx
	movq	%rcx, -24(%rbp)
	movzbl	(%rdx), %edx
	movb	%dl, (%rax)
.L9:
	movq	-32(%rbp), %rax
	movzbl	(%rax), %eax
	testb	%al, %al
	jne	.L10
	jmp	.L7
.L8:
	movq	-40(%rbp), %rax
	movzbl	(%rax), %eax
	cmpb	$69, %al
	jne	.L11
	movl	w(%rip), %eax
	movl	%eax, %edx
	shrl	$31, %edx
	addl	%edx, %eax
	sarl	%eax
	movl	%eax, -44(%rbp)
	movl	-44(%rbp), %eax
	cltq
	addq	%rax, -24(%rbp)
	movl	w(%rip), %eax
	andl	$1, %eax
	testl	%eax, %eax
	je	.L13
	addq	$1, -24(%rbp)
	jmp	.L13
.L14:
	movq	-32(%rbp), %rdx
	leaq	1(%rdx), %rax
	movq	%rax, -32(%rbp)
	movq	-24(%rbp), %rax
	leaq	1(%rax), %rcx
	movq	%rcx, -24(%rbp)
	movzbl	(%rdx), %edx
	movb	%dl, (%rax)
.L13:
	movl	-44(%rbp), %eax
	leal	-1(%rax), %edx
	movl	%edx, -44(%rbp)
	testl	%eax, %eax
	jg	.L14
	movl	-48(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$4, %rax
	subq	%rdx, %rax
	addq	%rax, %rax
	leaq	msg(%rip), %rdx
	addq	%rdx, %rax
	movq	%rax, -24(%rbp)
	movl	w(%rip), %eax
	andl	$1, %eax
	testl	%eax, %eax
	je	.L16
	movq	-32(%rbp), %rax
	leaq	1(%rax), %rdx
	movq	%rdx, -32(%rbp)
	movl	w(%rip), %edx
	movl	%edx, %ecx
	shrl	$31, %ecx
	addl	%ecx, %edx
	sarl	%edx
	movslq	%edx, %rcx
	movq	-24(%rbp), %rdx
	addq	%rcx, %rdx
	movzbl	(%rax), %eax
	movb	%al, (%rdx)
	jmp	.L16
.L17:
	movq	-32(%rbp), %rdx
	leaq	1(%rdx), %rax
	movq	%rax, -32(%rbp)
	movq	-24(%rbp), %rax
	leaq	1(%rax), %rcx
	movq	%rcx, -24(%rbp)
	movzbl	(%rdx), %edx
	movb	%dl, (%rax)
.L16:
	movq	-32(%rbp), %rax
	movzbl	(%rax), %eax
	testb	%al, %al
	jne	.L17
	jmp	.L7
.L11:
	movq	-40(%rbp), %rax
	movzbl	(%rax), %eax
	cmpb	$74, %al
	jne	.L18
	movl	w(%rip), %eax
	cltq
	leaq	-1(%rax), %rdx
	movq	-32(%rbp), %rax
	leaq	(%rdx,%rax), %rcx
	movq	-24(%rbp), %rax
	leaq	1(%rax), %rdx
	movq	%rdx, -24(%rbp)
	movzbl	(%rcx), %edx
	movb	%dl, (%rax)
	jmp	.L19
.L20:
	movq	-32(%rbp), %rdx
	leaq	1(%rdx), %rax
	movq	%rax, -32(%rbp)
	movq	-24(%rbp), %rax
	leaq	1(%rax), %rcx
	movq	%rcx, -24(%rbp)
	movzbl	(%rdx), %edx
	movb	%dl, (%rax)
.L19:
	movq	-32(%rbp), %rax
	movzbl	(%rax), %eax
	testb	%al, %al
	jne	.L20
	movq	-24(%rbp), %rax
	subq	$1, %rax
	movb	$0, (%rax)
	jmp	.L7
.L18:
	movq	-40(%rbp), %rax
	movzbl	(%rax), %eax
	cmpb	$77, %al
	jne	.L27
	jmp	.L22
.L26:
	call	__ctype_b_loc@PLT
	movq	(%rax), %rdx
	movq	-32(%rbp), %rax
	movzbl	(%rax), %eax
	movsbq	%al, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	movzwl	(%rax), %eax
	movzwl	%ax, %eax
	andl	$2048, %eax
	testl	%eax, %eax
	je	.L23
	movq	-32(%rbp), %rax
	movzbl	(%rax), %eax
	cmpb	$57, %al
	jne	.L24
	movq	-24(%rbp), %rax
	movb	$48, (%rax)
	jmp	.L25
.L24:
	movq	-32(%rbp), %rax
	movzbl	(%rax), %eax
	addl	$1, %eax
	movl	%eax, %edx
	movq	-24(%rbp), %rax
	movb	%dl, (%rax)
	jmp	.L25
.L23:
	movq	-32(%rbp), %rax
	movzbl	(%rax), %edx
	movq	-24(%rbp), %rax
	movb	%dl, (%rax)
.L25:
	addq	$1, -32(%rbp)
	addq	$1, -24(%rbp)
.L22:
	movq	-32(%rbp), %rax
	movzbl	(%rax), %eax
	testb	%al, %al
	jne	.L26
	jmp	.L7
.L31:
	call	__ctype_b_loc@PLT
	movq	(%rax), %rdx
	movq	-32(%rbp), %rax
	movzbl	(%rax), %eax
	movsbq	%al, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	movzwl	(%rax), %eax
	movzwl	%ax, %eax
	andl	$2048, %eax
	testl	%eax, %eax
	je	.L28
	movq	-32(%rbp), %rax
	movzbl	(%rax), %eax
	cmpb	$48, %al
	jne	.L29
	movq	-24(%rbp), %rax
	movb	$57, (%rax)
	jmp	.L30
.L29:
	movq	-32(%rbp), %rax
	movzbl	(%rax), %eax
	subl	$1, %eax
	movl	%eax, %edx
	movq	-24(%rbp), %rax
	movb	%dl, (%rax)
	jmp	.L30
.L28:
	movq	-32(%rbp), %rax
	movzbl	(%rax), %edx
	movq	-24(%rbp), %rax
	movb	%dl, (%rax)
.L30:
	addq	$1, -32(%rbp)
	addq	$1, -24(%rbp)
.L27:
	movq	-32(%rbp), %rax
	movzbl	(%rax), %eax
	testb	%al, %al
	jne	.L31
.L7:
	subq	$1, -40(%rbp)
	movl	-48(%rbp), %eax
	movl	%eax, -52(%rbp)
	cmpl	$0, -48(%rbp)
	sete	%al
	movzbl	%al, %eax
	movl	%eax, -48(%rbp)
.L3:
	leaq	-15(%rbp), %rax
	cmpq	%rax, -40(%rbp)
	jnb	.L32
	movl	-52(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$4, %rax
	subq	%rdx, %rax
	addq	%rax, %rax
	leaq	msg(%rip), %rdx
	addq	%rdx, %rax
	movq	%rax, %rdi
	call	puts@PLT
.L2:
	movl	-56(%rbp), %eax
	leal	-1(%rax), %edx
	movl	%edx, -56(%rbp)
	testl	%eax, %eax
	jg	.L33
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L35
	call	__stack_chk_fail@PLT
.L35:
	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:
