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>
char *p,s[999];main(i){for(;fgets(s,999,stdin),memcmp(p=s,"END OF I",8);puts(""))for(s[strlen(s)-1]=' ';*p;printf("%d",i))for(i=0;*p++!=' ';i++);exit(0);}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	p
	.bss
	.align 8
	.type	p, @object
	.size	p, 8
p:
	.zero	8
	.globl	s
	.align 32
	.type	s, @object
	.size	s, 999
s:
	.zero	999
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	""
.LC2:
	.string	"END OF I"
	.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	$16, %rsp
	movl	%edi, -4(%rbp)
	jmp	.L2
.L7:
	leaq	s(%rip), %rax
	movq	%rax, %rdi
	call	strlen@PLT
	leaq	-1(%rax), %rdx
	leaq	s(%rip), %rax
	movb	$32, (%rdx,%rax)
	jmp	.L3
.L6:
	movl	$0, -4(%rbp)
	jmp	.L4
.L5:
	addl	$1, -4(%rbp)
.L4:
	movq	p(%rip), %rax
	leaq	1(%rax), %rdx
	movq	%rdx, p(%rip)
	movzbl	(%rax), %eax
	cmpb	$32, %al
	jne	.L5
	movl	-4(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L3:
	movq	p(%rip), %rax
	movzbl	(%rax), %eax
	testb	%al, %al
	jne	.L6
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
.L2:
	movq	stdin(%rip), %rax
	movq	%rax, %rdx
	movl	$999, %esi
	leaq	s(%rip), %rax
	movq	%rax, %rdi
	call	fgets@PLT
	leaq	s(%rip), %rax
	movq	%rax, p(%rip)
	movq	p(%rip), %rax
	movl	$8, %edx
	leaq	.LC2(%rip), %rcx
	movq	%rcx, %rsi
	movq	%rax, %rdi
	call	memcmp@PLT
	testl	%eax, %eax
	jne	.L7
	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	"%d"
.LC1:
	.string	""
.LC2:
	.string	"END OF I"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	leaq	.LC2(%rip), %r13
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	leaq	s(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	leaq	.LC0(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	movl	$1, %ebx
	subq	$8, %rsp
	.cfi_def_cfa_offset 48
	.p2align 4,,10
	.p2align 3
.L2:
	movq	stdin(%rip), %rdx
	movl	$999, %esi
	movq	%r12, %rdi
	call	fgets@PLT
	movl	$8, %edx
	movq	%r13, %rsi
	movq	%r12, %rdi
	movq	%r12, p(%rip)
	call	memcmp@PLT
	testl	%eax, %eax
	je	.L15
	movq	%r12, %rdi
	call	strlen@PLT
	movq	%r12, %rdx
	movb	$32, -1(%r12,%rax)
	cmpb	$0, (%r12)
	je	.L4
	.p2align 4,,10
	.p2align 3
.L3:
	leaq	1(%rdx), %rax
	movl	%ebx, %ecx
	movq	%rax, p(%rip)
	subl	%eax, %ecx
	cmpb	$32, (%rdx)
	je	.L16
	.p2align 4,,10
	.p2align 3
.L5:
	leal	(%rcx,%rax), %edx
	addq	$1, %rax
	movq	%rax, p(%rip)
	cmpb	$32, -1(%rax)
	jne	.L5
.L6:
	xorl	%eax, %eax
	movq	%rbp, %rsi
	movl	$1, %edi
	call	__printf_chk@PLT
	movq	p(%rip), %rdx
	cmpb	$0, (%rdx)
	jne	.L3
.L4:
	leaq	.LC1(%rip), %rdi
	call	puts@PLT
	jmp	.L2
	.p2align 4,,10
	.p2align 3
.L16:
	xorl	%edx, %edx
	jmp	.L6
.L15:
	xorl	%edi, %edi
	call	exit@PLT
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.globl	s
	.bss
	.align 32
	.type	s, @object
	.size	s, 999
s:
	.zero	999
	.globl	p
	.align 8
	.type	p, @object
	.size	p, 8
p:
	.zero	8
	.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	""
.LC2:
	.string	"END OF I"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	leaq	.LC2(%rip), %r13
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	leaq	s(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	leaq	.LC0(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	movl	$1, %ebx
	subq	$8, %rsp
	.cfi_def_cfa_offset 48
	.p2align 4,,10
	.p2align 3
.L2:
	movq	stdin(%rip), %rdx
	movl	$999, %esi
	movq	%r12, %rdi
	call	fgets@PLT
	movl	$8, %edx
	movq	%r13, %rsi
	movq	%r12, %rdi
	movq	%r12, p(%rip)
	call	memcmp@PLT
	testl	%eax, %eax
	je	.L15
	movq	%r12, %rdi
	call	strlen@PLT
	movq	%r12, %rdx
	movb	$32, -1(%r12,%rax)
	cmpb	$0, (%r12)
	je	.L4
	.p2align 4,,10
	.p2align 3
.L3:
	leaq	1(%rdx), %rax
	movl	%ebx, %ecx
	movq	%rax, p(%rip)
	subl	%eax, %ecx
	cmpb	$32, (%rdx)
	je	.L16
	.p2align 4,,10
	.p2align 3
.L5:
	leal	(%rcx,%rax), %edx
	addq	$1, %rax
	movq	%rax, p(%rip)
	cmpb	$32, -1(%rax)
	jne	.L5
.L6:
	xorl	%eax, %eax
	movq	%rbp, %rsi
	movl	$1, %edi
	call	__printf_chk@PLT
	movq	p(%rip), %rdx
	cmpb	$0, (%rdx)
	jne	.L3
.L4:
	leaq	.LC1(%rip), %rdi
	call	puts@PLT
	jmp	.L2
	.p2align 4,,10
	.p2align 3
.L16:
	xorl	%edx, %edx
	jmp	.L6
.L15:
	xorl	%edi, %edi
	call	exit@PLT
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.globl	s
	.bss
	.align 32
	.type	s, @object
	.size	s, 999
s:
	.zero	999
	.globl	p
	.align 8
	.type	p, @object
	.size	p, 8
p:
	.zero	8
	.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>
char *p,s[999];main(i){for(;fgets(s,999,stdin),memcmp(p=s,"END OF I",8);puts(""))for(s[strlen(s)-1]=' ';*p;printf("%d",i))for(i=0;*p++!=' ';i++);exit(0);}
Yes I have a number
How I wish I could calculate an unused bolor for space
Thank you
END OF INPUT
 Yes I have a rebmun
How I wish I could calculate an unused bolor for space
Thank you
END OF INPUT
 Yes I have a rebmun
How J wish I could calculate an unused bolor for space
Thank you
END OF INPUT
 Yes H have a rebmun
How J wish I could calculate an unused bolor for space
Thank you
END OF INPUT
 Yes H have a rebmun
How J hisw I could calculate an unused bolor for space
Thank you
END OF INPUT
 Yes H have a rebmun
How J hisw J could calculate an unused bolor for space
Thank you
END OF INPUT
 Yes H have a rebmun
How J hisw J could calculate an unused bolor rof space
Thank you
END OF INPUT
 Yes H havd a rebmun
How J hisw J could calculate an unused bolor rof space
Thank you
END OF INPUT
 Yes H hvad a rebmun
How J hisw J could calculate an unused bolor rof space
Thank you
END OF INPUT
 Yes H hvad a rebmun
How J hisw J could calculate an unused bolor rof space
Tiank you
END OF INPUT

31416
31415926535
53
 31416
31415926535
53
 31416
31415926535
53
 31416
31415926535
53
 31416
31415926535
53
 31416
31415926535
53
 31416
31415926535
53
 31416
31415926535
53
 31416
31415926535
53
 31416
31415926535
53

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>
char *p,s[999];main(i){for(;fgets(s,999,stdin),memcmp(p=s,"END OF I",8);puts(""))for(s[strlen(s)-1]=' ';*p;printf("%d",i))for(i=0;*p++!=' ';i++);exit(0);}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	p
	.bss
	.align 8
	.type	p, @object
	.size	p, 8
p:
	.zero	8
	.globl	s
	.align 32
	.type	s, @object
	.size	s, 999
s:
	.zero	999
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	""
.LC2:
	.string	"END OF I"
	.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	$16, %rsp
	movl	%edi, -4(%rbp)
	jmp	.L2
.L7:
	leaq	s(%rip), %rax
	movq	%rax, %rdi
	call	strlen@PLT
	leaq	-1(%rax), %rdx
	leaq	s(%rip), %rax
	movb	$32, (%rdx,%rax)
	jmp	.L3
.L6:
	movl	$0, -4(%rbp)
	jmp	.L4
.L5:
	addl	$1, -4(%rbp)
.L4:
	movq	p(%rip), %rax
	leaq	1(%rax), %rdx
	movq	%rdx, p(%rip)
	movzbl	(%rax), %eax
	cmpb	$32, %al
	jne	.L5
	movl	-4(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L3:
	movq	p(%rip), %rax
	movzbl	(%rax), %eax
	testb	%al, %al
	jne	.L6
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
.L2:
	movq	stdin(%rip), %rax
	movq	%rax, %rdx
	movl	$999, %esi
	leaq	s(%rip), %rax
	movq	%rax, %rdi
	call	fgets@PLT
	leaq	s(%rip), %rax
	movq	%rax, p(%rip)
	movq	p(%rip), %rax
	movl	$8, %edx
	leaq	.LC2(%rip), %rcx
	movq	%rcx, %rsi
	movq	%rax, %rdi
	call	memcmp@PLT
	testl	%eax, %eax
	jne	.L7
	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	p
	.bss
	.align 8
	.type	p, @object
	.size	p, 8
p:
	.zero	8
	.globl	s
	.align 32
	.type	s, @object
	.size	s, 999
s:
	.zero	999
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	""
.LC2:
	.string	"END OF I"
	.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	$16, %rsp
	movl	%edi, -4(%rbp)
	jmp	.L2
.L7:
	leaq	s(%rip), %rax
	movq	%rax, %rdi
	call	strlen@PLT
	leaq	-1(%rax), %rdx
	leaq	s(%rip), %rax
	movb	$32, (%rdx,%rax)
	jmp	.L3
.L6:
	movl	$0, -4(%rbp)
	jmp	.L4
.L5:
	addl	$1, -4(%rbp)
.L4:
	movq	p(%rip), %rax
	leaq	1(%rax), %rdx
	movq	%rdx, p(%rip)
	movzbl	(%rax), %eax
	cmpb	$32, %al
	jne	.L5
	movl	-4(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L3:
	movq	p(%rip), %rax
	movzbl	(%rax), %eax
	testb	%al, %al
	jne	.L6
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
.L2:
	movq	stdin(%rip), %rax
	movq	%rax, %rdx
	movl	$999, %esi
	leaq	s(%rip), %rax
	movq	%rax, %rdi
	call	fgets@PLT
	leaq	s(%rip), %rax
	movq	%rax, p(%rip)
	movq	p(%rip), %rax
	movl	$8, %edx
	leaq	.LC2(%rip), %rcx
	movq	%rcx, %rsi
	movq	%rax, %rdi
	call	memcmp@PLT
	testl	%eax, %eax
	jne	.L7
	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:
