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

```c
// Aizu Vol-10 1036: Monster Factory
// 2017.8.21 bal4u@uu

#include <stdio.h>
char *gets();

#define MAX 10000
char in1[MAX+5], in2[MAX+5], out[MAX+5];

int main()
{
	char k, *i1, *i2, *o;

	while (1) {
		gets(in1); if (in1[0] == '-') break;
		gets(in2), gets(out);
		i1 = in1, i2 = in2, o = out, k = *i2++;
		while (*i1 || *i2) {
			if (*o == k) k = *i1++, o++;
			else {
				putchar(k);
				if (*i2) k = *i2++;
				else goto NEXT;
			}
		}
		putchar(k);
NEXT:;	putchar('\n');
	}
	return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	in1
	.bss
	.align 32
	.type	in1, @object
	.size	in1, 10005
in1:
	.zero	10005
	.globl	in2
	.align 32
	.type	in2, @object
	.size	in2, 10005
in2:
	.zero	10005
	.globl	out
	.align 32
	.type	out, @object
	.size	out, 10005
out:
	.zero	10005
	.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	$32, %rsp
.L9:
	leaq	in1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	gets@PLT
	movzbl	in1(%rip), %eax
	cmpb	$45, %al
	je	.L12
	leaq	in2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	gets@PLT
	leaq	out(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	gets@PLT
	leaq	in1(%rip), %rax
	movq	%rax, -24(%rbp)
	leaq	in2(%rip), %rax
	movq	%rax, -16(%rbp)
	leaq	out(%rip), %rax
	movq	%rax, -8(%rbp)
	movq	-16(%rbp), %rax
	leaq	1(%rax), %rdx
	movq	%rdx, -16(%rbp)
	movzbl	(%rax), %eax
	movb	%al, -25(%rbp)
	jmp	.L4
.L8:
	movq	-8(%rbp), %rax
	movzbl	(%rax), %eax
	cmpb	%al, -25(%rbp)
	jne	.L5
	movq	-24(%rbp), %rax
	leaq	1(%rax), %rdx
	movq	%rdx, -24(%rbp)
	movzbl	(%rax), %eax
	movb	%al, -25(%rbp)
	addq	$1, -8(%rbp)
	jmp	.L4
.L5:
	movsbl	-25(%rbp), %eax
	movl	%eax, %edi
	call	putchar@PLT
	movq	-16(%rbp), %rax
	movzbl	(%rax), %eax
	testb	%al, %al
	je	.L13
	movq	-16(%rbp), %rax
	leaq	1(%rax), %rdx
	movq	%rdx, -16(%rbp)
	movzbl	(%rax), %eax
	movb	%al, -25(%rbp)
.L4:
	movq	-24(%rbp), %rax
	movzbl	(%rax), %eax
	testb	%al, %al
	jne	.L8
	movq	-16(%rbp), %rax
	movzbl	(%rax), %eax
	testb	%al, %al
	jne	.L8
	movsbl	-25(%rbp), %eax
	movl	%eax, %edi
	call	putchar@PLT
	jmp	.L7
.L13:
	nop
.L7:
	movl	$10, %edi
	call	putchar@PLT
	jmp	.L9
.L12:
	nop
	movl	$0, %eax
	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	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	xorl	%eax, %eax
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	leaq	out(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	leaq	in2(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	leaq	in1(%rip), %rbx
	movq	%rbx, %rdi
	subq	$8, %rsp
	.cfi_def_cfa_offset 64
	call	gets@PLT
	cmpb	$45, (%rbx)
	je	.L2
	.p2align 4,,10
	.p2align 3
.L18:
	movq	%rbp, %rdi
	xorl	%eax, %eax
	leaq	out(%rip), %r14
	call	gets@PLT
	movq	%r12, %rdi
	xorl	%eax, %eax
	leaq	1+in2(%rip), %r15
	call	gets@PLT
	movsbl	0(%rbp), %edi
	movq	stdout(%rip), %rsi
	leaq	in1(%rip), %r13
	.p2align 4,,10
	.p2align 3
.L3:
	movzbl	0(%r13), %eax
	testb	%al, %al
	jne	.L7
.L16:
	cmpb	$0, (%r15)
	je	.L15
.L7:
	cmpb	%dil, (%r14)
	jne	.L4
.L17:
	addq	$1, %r13
	movsbl	%al, %edi
	addq	$1, %r14
	movzbl	0(%r13), %eax
	testb	%al, %al
	je	.L16
	cmpb	%dil, (%r14)
	je	.L17
.L4:
	call	putc@PLT
	movsbl	(%r15), %edi
	testb	%dil, %dil
	je	.L6
	movq	stdout(%rip), %rsi
	addq	$1, %r15
	jmp	.L3
	.p2align 4,,10
	.p2align 3
.L15:
	call	putc@PLT
.L6:
	movq	stdout(%rip), %rsi
	movl	$10, %edi
	call	putc@PLT
	xorl	%eax, %eax
	movq	%rbx, %rdi
	call	gets@PLT
	cmpb	$45, (%rbx)
	jne	.L18
.L2:
	addq	$8, %rsp
	.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
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.globl	out
	.bss
	.align 32
	.type	out, @object
	.size	out, 10005
out:
	.zero	10005
	.globl	in2
	.align 32
	.type	in2, @object
	.size	in2, 10005
in2:
	.zero	10005
	.globl	in1
	.align 32
	.type	in1, @object
	.size	in1, 10005
in1:
	.zero	10005
	.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	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	xorl	%eax, %eax
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	leaq	out(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	leaq	in2(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	leaq	in1(%rip), %rbx
	movq	%rbx, %rdi
	subq	$8, %rsp
	.cfi_def_cfa_offset 64
	call	gets@PLT
	cmpb	$45, (%rbx)
	je	.L2
	.p2align 4,,10
	.p2align 3
.L18:
	movq	%rbp, %rdi
	xorl	%eax, %eax
	leaq	out(%rip), %r14
	call	gets@PLT
	movq	%r12, %rdi
	xorl	%eax, %eax
	leaq	1+in2(%rip), %r15
	call	gets@PLT
	movsbl	0(%rbp), %edi
	movq	stdout(%rip), %rsi
	leaq	in1(%rip), %r13
	.p2align 4,,10
	.p2align 3
.L3:
	movzbl	0(%r13), %eax
	testb	%al, %al
	jne	.L7
.L16:
	cmpb	$0, (%r15)
	je	.L15
.L7:
	cmpb	%dil, (%r14)
	jne	.L4
.L17:
	addq	$1, %r13
	movsbl	%al, %edi
	addq	$1, %r14
	movzbl	0(%r13), %eax
	testb	%al, %al
	je	.L16
	cmpb	%dil, (%r14)
	je	.L17
.L4:
	call	putc@PLT
	movsbl	(%r15), %edi
	testb	%dil, %dil
	je	.L6
	movq	stdout(%rip), %rsi
	addq	$1, %r15
	jmp	.L3
	.p2align 4,,10
	.p2align 3
.L15:
	call	putc@PLT
.L6:
	movq	stdout(%rip), %rsi
	movl	$10, %edi
	call	putc@PLT
	xorl	%eax, %eax
	movq	%rbx, %rdi
	call	gets@PLT
	cmpb	$45, (%rbx)
	jne	.L18
.L2:
	addq	$8, %rsp
	.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
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.globl	out
	.bss
	.align 32
	.type	out, @object
	.size	out, 10005
out:
	.zero	10005
	.globl	in2
	.align 32
	.type	in2, @object
	.size	in2, 10005
in2:
	.zero	10005
	.globl	in1
	.align 32
	.type	in1, @object
	.size	in1, 10005
in1:
	.zero	10005
	.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:

// Aizu Vol-10 1036: Monster Factory
// 2017.8.21 bal4u@uu

#include <stdio.h>
char *gets();

#define MAX 10000
char in1[MAX+5], in2[MAX+5], out[MAX+5];

int main()
{
	char k, *i1, *i2, *o;

	while (1) {
		gets(in1); if (in1[0] == '-') break;
		gets(in2), gets(out);
		i1 = in1, i2 = in2, o = out, k = *i2++;
		while (*i1 || *i2) {
			if (*o == k) k = *i1++, o++;
			else {
				putchar(k);
				if (*i2) k = *i2++;
				else goto NEXT;
			}
		}
		putchar(k);
NEXT:;	putchar('\n');
	}
	return 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
// Aizu Vol-10 1036: Monster Factory
// 2017.8.21 bal4u@uu

#include <stdio.h>
char *gets();

#define MAX 10000
char in1[MAX+5], in2[MAX+5], out[MAX+5];

int main()
{
	char k, *i1, *i2, *o;

	while (1) {
		gets(in1); if (in1[0] == '-') break;
		gets(in2), gets(out);
		i1 = in1, i2 = in2, o = out, k = *i2++;
		while (*i1 || *i2) {
			if (*o == k) k = *i1++, o++;
			else {
				putchar(k);
				if (*i2) k = *i2++;
				else goto NEXT;
			}
		}
		putchar(k);
NEXT:;	putchar('\n');
	}
	return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	in1
	.bss
	.align 32
	.type	in1, @object
	.size	in1, 10005
in1:
	.zero	10005
	.globl	in2
	.align 32
	.type	in2, @object
	.size	in2, 10005
in2:
	.zero	10005
	.globl	out
	.align 32
	.type	out, @object
	.size	out, 10005
out:
	.zero	10005
	.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	$32, %rsp
.L9:
	leaq	in1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	gets@PLT
	movzbl	in1(%rip), %eax
	cmpb	$45, %al
	je	.L12
	leaq	in2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	gets@PLT
	leaq	out(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	gets@PLT
	leaq	in1(%rip), %rax
	movq	%rax, -24(%rbp)
	leaq	in2(%rip), %rax
	movq	%rax, -16(%rbp)
	leaq	out(%rip), %rax
	movq	%rax, -8(%rbp)
	movq	-16(%rbp), %rax
	leaq	1(%rax), %rdx
	movq	%rdx, -16(%rbp)
	movzbl	(%rax), %eax
	movb	%al, -25(%rbp)
	jmp	.L4
.L8:
	movq	-8(%rbp), %rax
	movzbl	(%rax), %eax
	cmpb	%al, -25(%rbp)
	jne	.L5
	movq	-24(%rbp), %rax
	leaq	1(%rax), %rdx
	movq	%rdx, -24(%rbp)
	movzbl	(%rax), %eax
	movb	%al, -25(%rbp)
	addq	$1, -8(%rbp)
	jmp	.L4
.L5:
	movsbl	-25(%rbp), %eax
	movl	%eax, %edi
	call	putchar@PLT
	movq	-16(%rbp), %rax
	movzbl	(%rax), %eax
	testb	%al, %al
	je	.L13
	movq	-16(%rbp), %rax
	leaq	1(%rax), %rdx
	movq	%rdx, -16(%rbp)
	movzbl	(%rax), %eax
	movb	%al, -25(%rbp)
.L4:
	movq	-24(%rbp), %rax
	movzbl	(%rax), %eax
	testb	%al, %al
	jne	.L8
	movq	-16(%rbp), %rax
	movzbl	(%rax), %eax
	testb	%al, %al
	jne	.L8
	movsbl	-25(%rbp), %eax
	movl	%eax, %edi
	call	putchar@PLT
	jmp	.L7
.L13:
	nop
.L7:
	movl	$10, %edi
	call	putchar@PLT
	jmp	.L9
.L12:
	nop
	movl	$0, %eax
	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	in1
	.bss
	.align 32
	.type	in1, @object
	.size	in1, 10005
in1:
	.zero	10005
	.globl	in2
	.align 32
	.type	in2, @object
	.size	in2, 10005
in2:
	.zero	10005
	.globl	out
	.align 32
	.type	out, @object
	.size	out, 10005
out:
	.zero	10005
	.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	$32, %rsp
.L9:
	leaq	in1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	gets@PLT
	movzbl	in1(%rip), %eax
	cmpb	$45, %al
	je	.L12
	leaq	in2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	gets@PLT
	leaq	out(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	gets@PLT
	leaq	in1(%rip), %rax
	movq	%rax, -24(%rbp)
	leaq	in2(%rip), %rax
	movq	%rax, -16(%rbp)
	leaq	out(%rip), %rax
	movq	%rax, -8(%rbp)
	movq	-16(%rbp), %rax
	leaq	1(%rax), %rdx
	movq	%rdx, -16(%rbp)
	movzbl	(%rax), %eax
	movb	%al, -25(%rbp)
	jmp	.L4
.L8:
	movq	-8(%rbp), %rax
	movzbl	(%rax), %eax
	cmpb	%al, -25(%rbp)
	jne	.L5
	movq	-24(%rbp), %rax
	leaq	1(%rax), %rdx
	movq	%rdx, -24(%rbp)
	movzbl	(%rax), %eax
	movb	%al, -25(%rbp)
	addq	$1, -8(%rbp)
	jmp	.L4
.L5:
	movsbl	-25(%rbp), %eax
	movl	%eax, %edi
	call	putchar@PLT
	movq	-16(%rbp), %rax
	movzbl	(%rax), %eax
	testb	%al, %al
	je	.L13
	movq	-16(%rbp), %rax
	leaq	1(%rax), %rdx
	movq	%rdx, -16(%rbp)
	movzbl	(%rax), %eax
	movb	%al, -25(%rbp)
.L4:
	movq	-24(%rbp), %rax
	movzbl	(%rax), %eax
	testb	%al, %al
	jne	.L8
	movq	-16(%rbp), %rax
	movzbl	(%rax), %eax
	testb	%al, %al
	jne	.L8
	movsbl	-25(%rbp), %eax
	movl	%eax, %edi
	call	putchar@PLT
	jmp	.L7
.L13:
	nop
.L7:
	movl	$10, %edi
	call	putchar@PLT
	jmp	.L9
.L12:
	nop
	movl	$0, %eax
	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:
