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(void) {
	char s[1024];
	int i,k = 0,u = 0,p = 0,c = 0;
	scanf("%s",s);
	for(i = 0;i <= 299;i++){
		switch(s[i]){
			case 'K':
			k++;
			break;
			case 'U':
			u++;
			break;
			case 'P':
			p++;
			break;
			case 'C':
			c++;
			break;
		}
	}
	if (k > u){
		k = u;
	}
	if (k > p){
		k = p;
	}
	if (k > c){
		k = c;
	}
	printf("%d\n",k);
	return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%s"
.LC1:
	.string	"%d\n"
	.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	$1072, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -1056(%rbp)
	movl	$0, -1052(%rbp)
	movl	$0, -1048(%rbp)
	movl	$0, -1044(%rbp)
	leaq	-1040(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -1060(%rbp)
	jmp	.L2
.L7:
	movl	-1060(%rbp), %eax
	cltq
	movzbl	-1040(%rbp,%rax), %eax
	movsbl	%al, %eax
	cmpl	$85, %eax
	je	.L3
	cmpl	$85, %eax
	jg	.L4
	cmpl	$80, %eax
	je	.L5
	cmpl	$80, %eax
	jg	.L4
	cmpl	$67, %eax
	je	.L6
	cmpl	$75, %eax
	jne	.L4
	addl	$1, -1056(%rbp)
	jmp	.L4
.L3:
	addl	$1, -1052(%rbp)
	jmp	.L4
.L5:
	addl	$1, -1048(%rbp)
	jmp	.L4
.L6:
	addl	$1, -1044(%rbp)
	nop
.L4:
	addl	$1, -1060(%rbp)
.L2:
	cmpl	$299, -1060(%rbp)
	jle	.L7
	movl	-1056(%rbp), %eax
	cmpl	-1052(%rbp), %eax
	jle	.L8
	movl	-1052(%rbp), %eax
	movl	%eax, -1056(%rbp)
.L8:
	movl	-1056(%rbp), %eax
	cmpl	-1048(%rbp), %eax
	jle	.L9
	movl	-1048(%rbp), %eax
	movl	%eax, -1056(%rbp)
.L9:
	movl	-1056(%rbp), %eax
	cmpl	-1044(%rbp), %eax
	jle	.L10
	movl	-1044(%rbp), %eax
	movl	%eax, -1056(%rbp)
.L10:
	movl	-1056(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L12
	call	__stack_chk_fail@PLT
.L12:
	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	"%s"
.LC1:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	leaq	.LC0(%rip), %rdi
	subq	$1040, %rsp
	.cfi_def_cfa_offset 1056
	movq	%fs:40, %rax
	movq	%rax, 1032(%rsp)
	xorl	%eax, %eax
	movq	%rsp, %rbx
	movq	%rbx, %rsi
	call	__isoc99_scanf@PLT
	movq	%rbx, %rdx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	leaq	300(%rsp), %rsi
	xorl	%ecx, %ecx
	xorl	%edi, %edi
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L14:
	cmpb	$75, %al
	jne	.L6
	addl	$1, %edi
	.p2align 4,,10
	.p2align 3
.L6:
	addq	$1, %rdx
	cmpq	%rdx, %rsi
	je	.L13
.L8:
	movzbl	(%rdx), %eax
	cmpb	$80, %al
	je	.L2
	jg	.L3
	cmpb	$67, %al
	jne	.L14
	addq	$1, %rdx
	addl	$1, %r8d
	cmpq	%rdx, %rsi
	jne	.L8
.L13:
	cmpl	%ecx, %edi
	movl	%ecx, %eax
	leaq	.LC1(%rip), %rsi
	movl	%r8d, %edx
	cmovle	%edi, %eax
	movl	$1, %edi
	cmpl	%r9d, %eax
	cmovg	%r9d, %eax
	cmpl	%r8d, %eax
	cmovle	%eax, %edx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	1032(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L15
	addq	$1040, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 16
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L3:
	.cfi_restore_state
	cmpb	$85, %al
	sete	%al
	movzbl	%al, %eax
	addl	%eax, %ecx
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L2:
	addl	$1, %r9d
	jmp	.L6
.L15:
	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	"%s"
.LC1:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	leaq	.LC0(%rip), %rdi
	subq	$1040, %rsp
	.cfi_def_cfa_offset 1056
	movq	%fs:40, %rax
	movq	%rax, 1032(%rsp)
	xorl	%eax, %eax
	movq	%rsp, %rbx
	movq	%rbx, %rsi
	call	__isoc99_scanf@PLT
	movq	%rbx, %rdx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	leaq	300(%rsp), %rsi
	xorl	%ecx, %ecx
	xorl	%edi, %edi
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L14:
	cmpb	$75, %al
	jne	.L6
	addl	$1, %edi
	.p2align 4,,10
	.p2align 3
.L6:
	addq	$1, %rdx
	cmpq	%rdx, %rsi
	je	.L13
.L8:
	movzbl	(%rdx), %eax
	cmpb	$80, %al
	je	.L2
	jg	.L3
	cmpb	$67, %al
	jne	.L14
	addq	$1, %rdx
	addl	$1, %r8d
	cmpq	%rdx, %rsi
	jne	.L8
.L13:
	cmpl	%ecx, %edi
	movl	%ecx, %eax
	leaq	.LC1(%rip), %rsi
	movl	%r8d, %edx
	cmovle	%edi, %eax
	movl	$1, %edi
	cmpl	%r9d, %eax
	cmovg	%r9d, %eax
	cmpl	%r8d, %eax
	cmovle	%eax, %edx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	1032(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L15
	addq	$1040, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 16
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L3:
	.cfi_restore_state
	cmpb	$85, %al
	sete	%al
	movzbl	%al, %eax
	addl	%eax, %ecx
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L2:
	addl	$1, %r9d
	jmp	.L6
.L15:
	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(void) {
	char s[1024];
	int i,k = 0,u = 0,p = 0,c = 0;
	scanf("%s",s);
	for(i = 0;i <= 299;i++){
		switch(s[i]){
			case 'K':
			k++;
			break;
			case 'U':
			u++;
			break;
			case 'P':
			p++;
			break;
			case 'C':
			c++;
			break;
		}
	}
	if (k > u){
		k = u;
	}
	if (k > p){
		k = p;
	}
	if (k > c){
		k = c;
	}
	printf("%d\n",k);
	return 0;
}
KUPCkupcKUPC

2

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(void) {
	char s[1024];
	int i,k = 0,u = 0,p = 0,c = 0;
	scanf("%s",s);
	for(i = 0;i <= 299;i++){
		switch(s[i]){
			case 'K':
			k++;
			break;
			case 'U':
			u++;
			break;
			case 'P':
			p++;
			break;
			case 'C':
			c++;
			break;
		}
	}
	if (k > u){
		k = u;
	}
	if (k > p){
		k = p;
	}
	if (k > c){
		k = c;
	}
	printf("%d\n",k);
	return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%s"
.LC1:
	.string	"%d\n"
	.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	$1072, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -1056(%rbp)
	movl	$0, -1052(%rbp)
	movl	$0, -1048(%rbp)
	movl	$0, -1044(%rbp)
	leaq	-1040(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -1060(%rbp)
	jmp	.L2
.L7:
	movl	-1060(%rbp), %eax
	cltq
	movzbl	-1040(%rbp,%rax), %eax
	movsbl	%al, %eax
	cmpl	$85, %eax
	je	.L3
	cmpl	$85, %eax
	jg	.L4
	cmpl	$80, %eax
	je	.L5
	cmpl	$80, %eax
	jg	.L4
	cmpl	$67, %eax
	je	.L6
	cmpl	$75, %eax
	jne	.L4
	addl	$1, -1056(%rbp)
	jmp	.L4
.L3:
	addl	$1, -1052(%rbp)
	jmp	.L4
.L5:
	addl	$1, -1048(%rbp)
	jmp	.L4
.L6:
	addl	$1, -1044(%rbp)
	nop
.L4:
	addl	$1, -1060(%rbp)
.L2:
	cmpl	$299, -1060(%rbp)
	jle	.L7
	movl	-1056(%rbp), %eax
	cmpl	-1052(%rbp), %eax
	jle	.L8
	movl	-1052(%rbp), %eax
	movl	%eax, -1056(%rbp)
.L8:
	movl	-1056(%rbp), %eax
	cmpl	-1048(%rbp), %eax
	jle	.L9
	movl	-1048(%rbp), %eax
	movl	%eax, -1056(%rbp)
.L9:
	movl	-1056(%rbp), %eax
	cmpl	-1044(%rbp), %eax
	jle	.L10
	movl	-1044(%rbp), %eax
	movl	%eax, -1056(%rbp)
.L10:
	movl	-1056(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L12
	call	__stack_chk_fail@PLT
.L12:
	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	"%s"
.LC1:
	.string	"%d\n"
	.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	$1072, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -1056(%rbp)
	movl	$0, -1052(%rbp)
	movl	$0, -1048(%rbp)
	movl	$0, -1044(%rbp)
	leaq	-1040(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -1060(%rbp)
	jmp	.L2
.L7:
	movl	-1060(%rbp), %eax
	cltq
	movzbl	-1040(%rbp,%rax), %eax
	movsbl	%al, %eax
	cmpl	$85, %eax
	je	.L3
	cmpl	$85, %eax
	jg	.L4
	cmpl	$80, %eax
	je	.L5
	cmpl	$80, %eax
	jg	.L4
	cmpl	$67, %eax
	je	.L6
	cmpl	$75, %eax
	jne	.L4
	addl	$1, -1056(%rbp)
	jmp	.L4
.L3:
	addl	$1, -1052(%rbp)
	jmp	.L4
.L5:
	addl	$1, -1048(%rbp)
	jmp	.L4
.L6:
	addl	$1, -1044(%rbp)
	nop
.L4:
	addl	$1, -1060(%rbp)
.L2:
	cmpl	$299, -1060(%rbp)
	jle	.L7
	movl	-1056(%rbp), %eax
	cmpl	-1052(%rbp), %eax
	jle	.L8
	movl	-1052(%rbp), %eax
	movl	%eax, -1056(%rbp)
.L8:
	movl	-1056(%rbp), %eax
	cmpl	-1048(%rbp), %eax
	jle	.L9
	movl	-1048(%rbp), %eax
	movl	%eax, -1056(%rbp)
.L9:
	movl	-1056(%rbp), %eax
	cmpl	-1044(%rbp), %eax
	jle	.L10
	movl	-1044(%rbp), %eax
	movl	%eax, -1056(%rbp)
.L10:
	movl	-1056(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L12
	call	__stack_chk_fail@PLT
.L12:
	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:
