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

```c
char r[99],g[99],d[99];main(c,i,j,k){for(;scanf("%s%s%s",r,g,d)>2;puts(""))for(i=j=k=0,c=g[j++];i+j<=strlen(r)+strlen(g);)if(c==d[k])k++,c=r[i++];else putchar(c),c=g[j++];exit(0);}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	r
	.bss
	.align 32
	.type	r, @object
	.size	r, 99
r:
	.zero	99
	.globl	g
	.align 32
	.type	g, @object
	.size	g, 99
g:
	.zero	99
	.globl	d
	.align 32
	.type	d, @object
	.size	d, 99
d:
	.zero	99
	.section	.rodata
.LC0:
	.string	""
.LC1:
	.string	"%s%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
	pushq	%r12
	pushq	%rbx
	subq	$16, %rsp
	.cfi_offset 12, -24
	.cfi_offset 3, -32
	movl	%edi, -20(%rbp)
	movl	%esi, -24(%rbp)
	movl	%edx, -28(%rbp)
	movl	%ecx, -32(%rbp)
	jmp	.L2
.L6:
	movl	$0, -32(%rbp)
	movl	-32(%rbp), %eax
	movl	%eax, -28(%rbp)
	movl	-28(%rbp), %eax
	movl	%eax, -24(%rbp)
	movl	-28(%rbp), %eax
	leal	1(%rax), %edx
	movl	%edx, -28(%rbp)
	cltq
	leaq	g(%rip), %rdx
	movzbl	(%rax,%rdx), %eax
	movsbl	%al, %eax
	movl	%eax, -20(%rbp)
	jmp	.L3
.L5:
	movl	-32(%rbp), %eax
	cltq
	leaq	d(%rip), %rdx
	movzbl	(%rax,%rdx), %eax
	movsbl	%al, %eax
	cmpl	%eax, -20(%rbp)
	jne	.L4
	addl	$1, -32(%rbp)
	movl	-24(%rbp), %eax
	leal	1(%rax), %edx
	movl	%edx, -24(%rbp)
	cltq
	leaq	r(%rip), %rdx
	movzbl	(%rax,%rdx), %eax
	movsbl	%al, %eax
	movl	%eax, -20(%rbp)
	jmp	.L3
.L4:
	movl	-20(%rbp), %eax
	movl	%eax, %edi
	call	putchar@PLT
	movl	-28(%rbp), %eax
	leal	1(%rax), %edx
	movl	%edx, -28(%rbp)
	cltq
	leaq	g(%rip), %rdx
	movzbl	(%rax,%rdx), %eax
	movsbl	%al, %eax
	movl	%eax, -20(%rbp)
.L3:
	movl	-24(%rbp), %edx
	movl	-28(%rbp), %eax
	addl	%edx, %eax
	movslq	%eax, %rbx
	leaq	r(%rip), %rax
	movq	%rax, %rdi
	call	strlen@PLT
	movq	%rax, %r12
	leaq	g(%rip), %rax
	movq	%rax, %rdi
	call	strlen@PLT
	addq	%r12, %rax
	cmpq	%rax, %rbx
	jbe	.L5
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
.L2:
	leaq	d(%rip), %rax
	movq	%rax, %rcx
	leaq	g(%rip), %rax
	movq	%rax, %rdx
	leaq	r(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	scanf@PLT
	cmpl	$2, %eax
	jg	.L6
	movl	$0, %edi
	call	exit@PLT
	.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	""
.LC1:
	.string	"%s%s%s"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB0:
	.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	r(%rip), %r14
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	leaq	g(%rip), %r13
	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	$8, %rsp
	.cfi_def_cfa_offset 64
	.p2align 4,,10
	.p2align 3
.L2:
	xorl	%eax, %eax
	leaq	d(%rip), %rcx
	movq	%r13, %rdx
	movq	%r14, %rsi
	leaq	.LC1(%rip), %rdi
	call	scanf@PLT
	cmpl	$2, %eax
	jle	.L10
	movsbl	0(%r13), %r15d
	movl	$1, %r12d
	xorl	%ebp, %ebp
	.p2align 4,,10
	.p2align 3
.L3:
	movq	%r14, %rdi
	call	strlen@PLT
	movq	%r13, %rdi
	movq	%rax, %rbx
	call	strlen@PLT
	movq	%rax, %r9
	leal	0(%rbp,%r12), %eax
	cltq
	addq	%r9, %rbx
	cmpq	%rbx, %rax
	ja	.L11
	movslq	%ebp, %rax
	leaq	d(%rip), %rcx
	movsbl	(%rcx,%rax), %edx
	cmpl	%r15d, %edx
	jne	.L4
	movsbl	(%r14,%rax), %r15d
	addl	$1, %ebp
	jmp	.L3
	.p2align 4,,10
	.p2align 3
.L4:
	movl	%r15d, %edi
	call	putchar@PLT
	movslq	%r12d, %rax
	addl	$1, %r12d
	movsbl	0(%r13,%rax), %r15d
	jmp	.L3
	.p2align 4,,10
	.p2align 3
.L11:
	leaq	.LC0(%rip), %rdi
	call	puts@PLT
	jmp	.L2
	.p2align 4,,10
	.p2align 3
.L10:
	xorl	%edi, %edi
	call	exit@PLT
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.globl	d
	.bss
	.align 32
	.type	d, @object
	.size	d, 99
d:
	.zero	99
	.globl	g
	.align 32
	.type	g, @object
	.size	g, 99
g:
	.zero	99
	.globl	r
	.align 32
	.type	r, @object
	.size	r, 99
r:
	.zero	99
	.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	""
.LC1:
	.string	"%s%s%s"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB0:
	.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	r(%rip), %r14
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	leaq	g(%rip), %r13
	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	$8, %rsp
	.cfi_def_cfa_offset 64
	.p2align 4,,10
	.p2align 3
.L2:
	xorl	%eax, %eax
	leaq	d(%rip), %rcx
	movq	%r13, %rdx
	movq	%r14, %rsi
	leaq	.LC1(%rip), %rdi
	call	scanf@PLT
	cmpl	$2, %eax
	jle	.L10
	movsbl	0(%r13), %r15d
	movl	$1, %r12d
	xorl	%ebp, %ebp
	.p2align 4,,10
	.p2align 3
.L3:
	movq	%r14, %rdi
	call	strlen@PLT
	movq	%r13, %rdi
	movq	%rax, %rbx
	call	strlen@PLT
	movq	%rax, %r9
	leal	0(%rbp,%r12), %eax
	cltq
	addq	%r9, %rbx
	cmpq	%rbx, %rax
	ja	.L11
	movslq	%ebp, %rax
	leaq	d(%rip), %rcx
	movsbl	(%rcx,%rax), %edx
	cmpl	%r15d, %edx
	jne	.L4
	movsbl	(%r14,%rax), %r15d
	addl	$1, %ebp
	jmp	.L3
	.p2align 4,,10
	.p2align 3
.L4:
	movl	%r15d, %edi
	call	putchar@PLT
	movslq	%r12d, %rax
	addl	$1, %r12d
	movsbl	0(%r13,%rax), %r15d
	jmp	.L3
	.p2align 4,,10
	.p2align 3
.L11:
	leaq	.LC0(%rip), %rdi
	call	puts@PLT
	jmp	.L2
	.p2align 4,,10
	.p2align 3
.L10:
	xorl	%edi, %edi
	call	exit@PLT
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.globl	d
	.bss
	.align 32
	.type	d, @object
	.size	d, 99
d:
	.zero	99
	.globl	g
	.align 32
	.type	g, @object
	.size	g, 99
g:
	.zero	99
	.globl	r
	.align 32
	.type	r, @object
	.size	r, 99
r:
	.zero	99
	.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:

char r[99],g[99],d[99];main(c,i,j,k){for(;scanf("%s%s%s",r,g,d)>2;puts(""))for(i=j=k=0,c=g[j++];i+j<=strlen(r)+strlen(g);)if(c==d[k])k++,c=r[i++];else putchar(c),c=g[j++];exit(0);}
CBA
cba
cCa
X
YZ
Z
-
 CBA
cba
cCa
Y
YZ
Z
-
 CBA
cca
cCa
X
ZY
Z
-
 CAB
cba
cCa
X
YZ
Z
-
 CAB
cca
cCa
X
YZ
Z
-
 CAA
cca
cCa
X
YZ
Z
-
 CBA
abc
aCc
X
ZY
Z
-
 CBA
cba
cCa
X
XZ
Z
-
 CBB
cca
cCa
X
ZY
Z
-
 CAB
cba
cCa
X
ZY
Z
-

BbA
YX
 BbA
YY
 BcA
XY
 AbB
YX
 AcB
YX
 AcA
YX
 BbA
XY
 BbA
XX
 BcB
XY
 AbB
XY

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

```c
char r[99],g[99],d[99];main(c,i,j,k){for(;scanf("%s%s%s",r,g,d)>2;puts(""))for(i=j=k=0,c=g[j++];i+j<=strlen(r)+strlen(g);)if(c==d[k])k++,c=r[i++];else putchar(c),c=g[j++];exit(0);}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	r
	.bss
	.align 32
	.type	r, @object
	.size	r, 99
r:
	.zero	99
	.globl	g
	.align 32
	.type	g, @object
	.size	g, 99
g:
	.zero	99
	.globl	d
	.align 32
	.type	d, @object
	.size	d, 99
d:
	.zero	99
	.section	.rodata
.LC0:
	.string	""
.LC1:
	.string	"%s%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
	pushq	%r12
	pushq	%rbx
	subq	$16, %rsp
	.cfi_offset 12, -24
	.cfi_offset 3, -32
	movl	%edi, -20(%rbp)
	movl	%esi, -24(%rbp)
	movl	%edx, -28(%rbp)
	movl	%ecx, -32(%rbp)
	jmp	.L2
.L6:
	movl	$0, -32(%rbp)
	movl	-32(%rbp), %eax
	movl	%eax, -28(%rbp)
	movl	-28(%rbp), %eax
	movl	%eax, -24(%rbp)
	movl	-28(%rbp), %eax
	leal	1(%rax), %edx
	movl	%edx, -28(%rbp)
	cltq
	leaq	g(%rip), %rdx
	movzbl	(%rax,%rdx), %eax
	movsbl	%al, %eax
	movl	%eax, -20(%rbp)
	jmp	.L3
.L5:
	movl	-32(%rbp), %eax
	cltq
	leaq	d(%rip), %rdx
	movzbl	(%rax,%rdx), %eax
	movsbl	%al, %eax
	cmpl	%eax, -20(%rbp)
	jne	.L4
	addl	$1, -32(%rbp)
	movl	-24(%rbp), %eax
	leal	1(%rax), %edx
	movl	%edx, -24(%rbp)
	cltq
	leaq	r(%rip), %rdx
	movzbl	(%rax,%rdx), %eax
	movsbl	%al, %eax
	movl	%eax, -20(%rbp)
	jmp	.L3
.L4:
	movl	-20(%rbp), %eax
	movl	%eax, %edi
	call	putchar@PLT
	movl	-28(%rbp), %eax
	leal	1(%rax), %edx
	movl	%edx, -28(%rbp)
	cltq
	leaq	g(%rip), %rdx
	movzbl	(%rax,%rdx), %eax
	movsbl	%al, %eax
	movl	%eax, -20(%rbp)
.L3:
	movl	-24(%rbp), %edx
	movl	-28(%rbp), %eax
	addl	%edx, %eax
	movslq	%eax, %rbx
	leaq	r(%rip), %rax
	movq	%rax, %rdi
	call	strlen@PLT
	movq	%rax, %r12
	leaq	g(%rip), %rax
	movq	%rax, %rdi
	call	strlen@PLT
	addq	%r12, %rax
	cmpq	%rax, %rbx
	jbe	.L5
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
.L2:
	leaq	d(%rip), %rax
	movq	%rax, %rcx
	leaq	g(%rip), %rax
	movq	%rax, %rdx
	leaq	r(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	scanf@PLT
	cmpl	$2, %eax
	jg	.L6
	movl	$0, %edi
	call	exit@PLT
	.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	r
	.bss
	.align 32
	.type	r, @object
	.size	r, 99
r:
	.zero	99
	.globl	g
	.align 32
	.type	g, @object
	.size	g, 99
g:
	.zero	99
	.globl	d
	.align 32
	.type	d, @object
	.size	d, 99
d:
	.zero	99
	.section	.rodata
.LC0:
	.string	""
.LC1:
	.string	"%s%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
	pushq	%r12
	pushq	%rbx
	subq	$16, %rsp
	.cfi_offset 12, -24
	.cfi_offset 3, -32
	movl	%edi, -20(%rbp)
	movl	%esi, -24(%rbp)
	movl	%edx, -28(%rbp)
	movl	%ecx, -32(%rbp)
	jmp	.L2
.L6:
	movl	$0, -32(%rbp)
	movl	-32(%rbp), %eax
	movl	%eax, -28(%rbp)
	movl	-28(%rbp), %eax
	movl	%eax, -24(%rbp)
	movl	-28(%rbp), %eax
	leal	1(%rax), %edx
	movl	%edx, -28(%rbp)
	cltq
	leaq	g(%rip), %rdx
	movzbl	(%rax,%rdx), %eax
	movsbl	%al, %eax
	movl	%eax, -20(%rbp)
	jmp	.L3
.L5:
	movl	-32(%rbp), %eax
	cltq
	leaq	d(%rip), %rdx
	movzbl	(%rax,%rdx), %eax
	movsbl	%al, %eax
	cmpl	%eax, -20(%rbp)
	jne	.L4
	addl	$1, -32(%rbp)
	movl	-24(%rbp), %eax
	leal	1(%rax), %edx
	movl	%edx, -24(%rbp)
	cltq
	leaq	r(%rip), %rdx
	movzbl	(%rax,%rdx), %eax
	movsbl	%al, %eax
	movl	%eax, -20(%rbp)
	jmp	.L3
.L4:
	movl	-20(%rbp), %eax
	movl	%eax, %edi
	call	putchar@PLT
	movl	-28(%rbp), %eax
	leal	1(%rax), %edx
	movl	%edx, -28(%rbp)
	cltq
	leaq	g(%rip), %rdx
	movzbl	(%rax,%rdx), %eax
	movsbl	%al, %eax
	movl	%eax, -20(%rbp)
.L3:
	movl	-24(%rbp), %edx
	movl	-28(%rbp), %eax
	addl	%edx, %eax
	movslq	%eax, %rbx
	leaq	r(%rip), %rax
	movq	%rax, %rdi
	call	strlen@PLT
	movq	%rax, %r12
	leaq	g(%rip), %rax
	movq	%rax, %rdi
	call	strlen@PLT
	addq	%r12, %rax
	cmpq	%rax, %rbx
	jbe	.L5
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
.L2:
	leaq	d(%rip), %rax
	movq	%rax, %rcx
	leaq	g(%rip), %rax
	movq	%rax, %rdx
	leaq	r(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	scanf@PLT
	cmpl	$2, %eax
	jg	.L6
	movl	$0, %edi
	call	exit@PLT
	.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:
