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

```c
#include<stdio.h>
int main(){
    char Sa[100],Sb[100],Sc[100];
    int i=0,j=0,k=0;
    char p='a';
    scanf("%s",Sa);
    scanf("%s",Sb);
    scanf("%s",Sc);
    while(1){
        switch(p){
            case 'a':{
                if(Sa[i]=='a')p='a';
                else if(Sa[i]=='b')p='b';
                else p='c';
                i++; break;
            }
            case 'b':{
                if(Sb[j]=='a')p='a';
                else if(Sb[j]=='b')p='b';
                else p='c';
                j++; break;
            }
            case 'c':{
                if(Sc[k]=='a')p='a';
                else if(Sc[k]=='b')p='b';
                else p='c';
                k++; break;
            }
        }
        if(p=='a'){
            if(Sa[i]=='\0'){
                printf("A");
                break;
            }
        }else if(p=='b'){
            if(Sb[j]=='\0'){
                printf("B");
                break;
            }
        }else{
            if(Sc[k]=='\0'){
                printf("C");
                break;
            }
        }
        
    }
    return 0;
}
```

Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%s"
	.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
	movq	%rbp, %rdi
	subq	$336, %rsp
	.cfi_def_cfa_offset 352
	movq	%fs:40, %rax
	movq	%rax, 328(%rsp)
	xorl	%eax, %eax
	movq	%rsp, %rsi
	call	__isoc99_scanf@PLT
	leaq	112(%rsp), %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	leaq	224(%rsp), %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movzbl	(%rsp), %eax
	leaq	1(%rsp), %rsi
	xorl	%ecx, %ecx
	xorl	%edi, %edi
	leaq	223(%rsp), %r8
	leaq	111(%rsp), %r9
	.p2align 4,,10
	.p2align 3
.L9:
	cmpb	$97, %al
	je	.L2
	cmpb	$98, %al
	je	.L8
.L5:
	addl	$1, %ecx
	movslq	%ecx, %rdx
.L7:
	movzbl	(%r8,%rdx), %eax
	testb	%al, %al
	je	.L34
	movl	%edx, %ecx
	cmpb	$97, %al
	je	.L2
	addq	$1, %rdx
	cmpb	$98, %al
	jne	.L7
.L8:
	addl	$1, %edi
	movslq	%edi, %rax
	movzbl	(%r9,%rax), %edx
	testb	%dl, %dl
	je	.L35
.L11:
	movl	%eax, %edi
	cmpb	$97, %dl
	je	.L2
	addq	$1, %rax
	cmpb	$98, %dl
	jne	.L5
	movzbl	(%r9,%rax), %edx
	testb	%dl, %dl
	jne	.L11
.L35:
	movl	$66, %edi
	call	putchar@PLT
	jmp	.L10
	.p2align 4,,10
	.p2align 3
.L2:
	movzbl	(%rsi), %eax
	addq	$1, %rsi
	testb	%al, %al
	jne	.L9
	movl	$65, %edi
	call	putchar@PLT
.L10:
	movq	328(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L36
	addq	$336, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 16
	xorl	%eax, %eax
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
.L34:
	.cfi_restore_state
	movl	$67, %edi
	call	putchar@PLT
	jmp	.L10
.L36:
	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:
```

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.
Optimized Assembly Code:

user
```assembly
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%s"
	.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
	movq	%rbp, %rdi
	subq	$336, %rsp
	.cfi_def_cfa_offset 352
	movq	%fs:40, %rax
	movq	%rax, 328(%rsp)
	xorl	%eax, %eax
	movq	%rsp, %rsi
	call	__isoc99_scanf@PLT
	leaq	112(%rsp), %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	leaq	224(%rsp), %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movzbl	(%rsp), %eax
	leaq	1(%rsp), %rsi
	xorl	%ecx, %ecx
	xorl	%edi, %edi
	leaq	223(%rsp), %r8
	leaq	111(%rsp), %r9
	.p2align 4,,10
	.p2align 3
.L9:
	cmpb	$97, %al
	je	.L2
	cmpb	$98, %al
	je	.L8
.L5:
	addl	$1, %ecx
	movslq	%ecx, %rdx
.L7:
	movzbl	(%r8,%rdx), %eax
	testb	%al, %al
	je	.L34
	movl	%edx, %ecx
	cmpb	$97, %al
	je	.L2
	addq	$1, %rdx
	cmpb	$98, %al
	jne	.L7
.L8:
	addl	$1, %edi
	movslq	%edi, %rax
	movzbl	(%r9,%rax), %edx
	testb	%dl, %dl
	je	.L35
.L11:
	movl	%eax, %edi
	cmpb	$97, %dl
	je	.L2
	addq	$1, %rax
	cmpb	$98, %dl
	jne	.L5
	movzbl	(%r9,%rax), %edx
	testb	%dl, %dl
	jne	.L11
.L35:
	movl	$66, %edi
	call	putchar@PLT
	jmp	.L10
	.p2align 4,,10
	.p2align 3
.L2:
	movzbl	(%rsi), %eax
	addq	$1, %rsi
	testb	%al, %al
	jne	.L9
	movl	$65, %edi
	call	putchar@PLT
.L10:
	movq	328(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L36
	addq	$336, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 16
	xorl	%eax, %eax
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
.L34:
	.cfi_restore_state
	movl	$67, %edi
	call	putchar@PLT
	jmp	.L10
.L36:
	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
```assembly
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%s"
	.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
	movq	%rbp, %rdi
	subq	$336, %rsp
	.cfi_def_cfa_offset 352
	movq	%fs:40, %rax
	movq	%rax, 328(%rsp)
	xorl	%eax, %eax
	movq	%rsp, %rsi
	call	__isoc99_scanf@PLT
	leaq	112(%rsp), %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	leaq	224(%rsp), %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movzbl	(%rsp), %eax
	leaq	1(%rsp), %rsi
	xorl	%ecx, %ecx
	xorl	%edi, %edi
	leaq	223(%rsp), %r8
	leaq	111(%rsp), %r9
	.p2align 4,,10
	.p2align 3
.L9:
	cmpb	$97, %al
	je	.L2
	cmpb	$98, %al
	je	.L8
.L5:
	addl	$1, %ecx
	movslq	%ecx, %rdx
.L7:
	movzbl	(%r8,%rdx), %eax
	testb	%al, %al
	je	.L34
	movl	%edx, %ecx
	cmpb	$97, %al
	je	.L2
	addq	$1, %rdx
	cmpb	$98, %al
	jne	.L7
.L8:
	addl	$1, %edi
	movslq	%edi, %rax
	movzbl	(%r9,%rax), %edx
	testb	%dl, %dl
	je	.L35
.L11:
	movl	%eax, %edi
	cmpb	$97, %dl
	je	.L2
	addq	$1, %rax
	cmpb	$98, %dl
	jne	.L5
	movzbl	(%r9,%rax), %edx
	testb	%dl, %dl
	jne	.L11
.L35:
	movl	$66, %edi
	call	putchar@PLT
	jmp	.L10
	.p2align 4,,10
	.p2align 3
.L2:
	movzbl	(%rsi), %eax
	addq	$1, %rsi
	testb	%al, %al
	jne	.L9
	movl	$65, %edi
	call	putchar@PLT
.L10:
	movq	328(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L36
	addq	$336, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 16
	xorl	%eax, %eax
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
.L34:
	.cfi_restore_state
	movl	$67, %edi
	call	putchar@PLT
	jmp	.L10
.L36:
	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:
```
```c
#include<stdio.h>
int main(){
    char Sa[100],Sb[100],Sc[100];
    int i=0,j=0,k=0;
    char p='a';
    scanf("%s",Sa);
    scanf("%s",Sb);
    scanf("%s",Sc);
    while(1){
        switch(p){
            case 'a':{
                if(Sa[i]=='a')p='a';
                else if(Sa[i]=='b')p='b';
                else p='c';
                i++; break;
            }
            case 'b':{
                if(Sb[j]=='a')p='a';
                else if(Sb[j]=='b')p='b';
                else p='c';
                j++; break;
            }
            case 'c':{
                if(Sc[k]=='a')p='a';
                else if(Sc[k]=='b')p='b';
                else p='c';
                k++; break;
            }
        }
        if(p=='a'){
            if(Sa[i]=='\0'){
                printf("A");
                break;
            }
        }else if(p=='b'){
            if(Sb[j]=='\0'){
                printf("B");
                break;
            }
        }else{
            if(Sc[k]=='\0'){
                printf("C");
                break;
            }
        }
        
    }
    return 0;
}
```
Given the following C code, your task is to generate highly optimized x86-64 assembly code.
C Code:

```c
#include<stdio.h>
int main(){
    char Sa[100],Sb[100],Sc[100];
    int i=0,j=0,k=0;
    char p='a';
    scanf("%s",Sa);
    scanf("%s",Sb);
    scanf("%s",Sc);
    while(1){
        switch(p){
            case 'a':{
                if(Sa[i]=='a')p='a';
                else if(Sa[i]=='b')p='b';
                else p='c';
                i++; break;
            }
            case 'b':{
                if(Sb[j]=='a')p='a';
                else if(Sb[j]=='b')p='b';
                else p='c';
                j++; break;
            }
            case 'c':{
                if(Sc[k]=='a')p='a';
                else if(Sc[k]=='b')p='b';
                else p='c';
                k++; break;
            }
        }
        if(p=='a'){
            if(Sa[i]=='\0'){
                printf("A");
                break;
            }
        }else if(p=='b'){
            if(Sb[j]=='\0'){
                printf("B");
                break;
            }
        }else{
            if(Sc[k]=='\0'){
                printf("C");
                break;
            }
        }
        
    }
    return 0;
}
```

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.
Optimized Assembly Code:

abcb
aabb
bccc
 caa
accc
ca
 aaca
aabb
cccc
 abcb
bbaa
bccc
 aacb
bbaa
bccc
 aacb
bbaa
cccb
 aaca
bbaa
cccb
 aaca
aabb
cccb
 acaa
aabb
cccc
 acaa
abab
cccc

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

```c
#include<stdio.h>
int main(){
    char Sa[100],Sb[100],Sc[100];
    int i=0,j=0,k=0;
    char p='a';
    scanf("%s",Sa);
    scanf("%s",Sb);
    scanf("%s",Sc);
    while(1){
        switch(p){
            case 'a':{
                if(Sa[i]=='a')p='a';
                else if(Sa[i]=='b')p='b';
                else p='c';
                i++; break;
            }
            case 'b':{
                if(Sb[j]=='a')p='a';
                else if(Sb[j]=='b')p='b';
                else p='c';
                j++; break;
            }
            case 'c':{
                if(Sc[k]=='a')p='a';
                else if(Sc[k]=='b')p='b';
                else p='c';
                k++; break;
            }
        }
        if(p=='a'){
            if(Sa[i]=='\0'){
                printf("A");
                break;
            }
        }else if(p=='b'){
            if(Sb[j]=='\0'){
                printf("B");
                break;
            }
        }else{
            if(Sc[k]=='\0'){
                printf("C");
                break;
            }
        }
        
    }
    return 0;
}
```

Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%s"
	.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
	movq	%rbp, %rdi
	subq	$336, %rsp
	.cfi_def_cfa_offset 352
	movq	%fs:40, %rax
	movq	%rax, 328(%rsp)
	xorl	%eax, %eax
	movq	%rsp, %rsi
	call	__isoc99_scanf@PLT
	leaq	112(%rsp), %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	leaq	224(%rsp), %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movzbl	(%rsp), %eax
	leaq	1(%rsp), %rsi
	xorl	%ecx, %ecx
	xorl	%edi, %edi
	leaq	223(%rsp), %r8
	leaq	111(%rsp), %r9
	.p2align 4,,10
	.p2align 3
.L9:
	cmpb	$97, %al
	je	.L2
	cmpb	$98, %al
	je	.L8
.L5:
	addl	$1, %ecx
	movslq	%ecx, %rdx
.L7:
	movzbl	(%r8,%rdx), %eax
	testb	%al, %al
	je	.L34
	movl	%edx, %ecx
	cmpb	$97, %al
	je	.L2
	addq	$1, %rdx
	cmpb	$98, %al
	jne	.L7
.L8:
	addl	$1, %edi
	movslq	%edi, %rax
	movzbl	(%r9,%rax), %edx
	testb	%dl, %dl
	je	.L35
.L11:
	movl	%eax, %edi
	cmpb	$97, %dl
	je	.L2
	addq	$1, %rax
	cmpb	$98, %dl
	jne	.L5
	movzbl	(%r9,%rax), %edx
	testb	%dl, %dl
	jne	.L11
.L35:
	movl	$66, %edi
	call	putchar@PLT
	jmp	.L10
	.p2align 4,,10
	.p2align 3
.L2:
	movzbl	(%rsi), %eax
	addq	$1, %rsi
	testb	%al, %al
	jne	.L9
	movl	$65, %edi
	call	putchar@PLT
.L10:
	movq	328(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L36
	addq	$336, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 16
	xorl	%eax, %eax
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
.L34:
	.cfi_restore_state
	movl	$67, %edi
	call	putchar@PLT
	jmp	.L10
.L36:
	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:
```

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.
Optimized Assembly Code:

train
```assembly
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%s"
	.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
	movq	%rbp, %rdi
	subq	$336, %rsp
	.cfi_def_cfa_offset 352
	movq	%fs:40, %rax
	movq	%rax, 328(%rsp)
	xorl	%eax, %eax
	movq	%rsp, %rsi
	call	__isoc99_scanf@PLT
	leaq	112(%rsp), %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	leaq	224(%rsp), %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movzbl	(%rsp), %eax
	leaq	1(%rsp), %rsi
	xorl	%ecx, %ecx
	xorl	%edi, %edi
	leaq	223(%rsp), %r8
	leaq	111(%rsp), %r9
	.p2align 4,,10
	.p2align 3
.L9:
	cmpb	$97, %al
	je	.L2
	cmpb	$98, %al
	je	.L8
.L5:
	addl	$1, %ecx
	movslq	%ecx, %rdx
.L7:
	movzbl	(%r8,%rdx), %eax
	testb	%al, %al
	je	.L34
	movl	%edx, %ecx
	cmpb	$97, %al
	je	.L2
	addq	$1, %rdx
	cmpb	$98, %al
	jne	.L7
.L8:
	addl	$1, %edi
	movslq	%edi, %rax
	movzbl	(%r9,%rax), %edx
	testb	%dl, %dl
	je	.L35
.L11:
	movl	%eax, %edi
	cmpb	$97, %dl
	je	.L2
	addq	$1, %rax
	cmpb	$98, %dl
	jne	.L5
	movzbl	(%r9,%rax), %edx
	testb	%dl, %dl
	jne	.L11
.L35:
	movl	$66, %edi
	call	putchar@PLT
	jmp	.L10
	.p2align 4,,10
	.p2align 3
.L2:
	movzbl	(%rsi), %eax
	addq	$1, %rsi
	testb	%al, %al
	jne	.L9
	movl	$65, %edi
	call	putchar@PLT
.L10:
	movq	328(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L36
	addq	$336, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 16
	xorl	%eax, %eax
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
.L34:
	.cfi_restore_state
	movl	$67, %edi
	call	putchar@PLT
	jmp	.L10
.L36:
	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:
```