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>
#include<string.h>
#define N 1000

int main(){
  int i,j,n,k=0,sum=0,tlen,plen,v[N];
  char T[N],P[N];

  scanf("%s%s",T,P);
  tlen=strlen(T);
  plen=strlen(P);
  //printf("%d %d\n",tlen,plen);
  for(i=0;i<tlen;i++){
    if(T[i]==P[0]){
      j=i+1;
      n=1;
      while(n<plen){
        if(T[j]!=P[n])
          break;
        j++;
	n++;
      }
      if(n==plen){
        v[k]=i;
        sum++;
	k++;
      }
    }
  }
  for(k=0;k<sum;k++){
    printf("%d\n",v[k]);
  }
  //printf("%d\n",sum);
  return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%s%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	$4096, %rsp
	orq	$0, (%rsp)
	subq	$1952, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -6032(%rbp)
	movl	$0, -6028(%rbp)
	leaq	-1008(%rbp), %rdx
	leaq	-2016(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	leaq	-2016(%rbp), %rax
	movq	%rax, %rdi
	call	strlen@PLT
	movl	%eax, -6024(%rbp)
	leaq	-1008(%rbp), %rax
	movq	%rax, %rdi
	call	strlen@PLT
	movl	%eax, -6020(%rbp)
	movl	$0, -6044(%rbp)
	jmp	.L2
.L8:
	movl	-6044(%rbp), %eax
	cltq
	movzbl	-2016(%rbp,%rax), %edx
	movzbl	-1008(%rbp), %eax
	cmpb	%al, %dl
	jne	.L3
	movl	-6044(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -6040(%rbp)
	movl	$1, -6036(%rbp)
	jmp	.L4
.L7:
	movl	-6040(%rbp), %eax
	cltq
	movzbl	-2016(%rbp,%rax), %edx
	movl	-6036(%rbp), %eax
	cltq
	movzbl	-1008(%rbp,%rax), %eax
	cmpb	%al, %dl
	jne	.L13
	addl	$1, -6040(%rbp)
	addl	$1, -6036(%rbp)
.L4:
	movl	-6036(%rbp), %eax
	cmpl	-6020(%rbp), %eax
	jl	.L7
	jmp	.L6
.L13:
	nop
.L6:
	movl	-6036(%rbp), %eax
	cmpl	-6020(%rbp), %eax
	jne	.L3
	movl	-6032(%rbp), %eax
	cltq
	movl	-6044(%rbp), %edx
	movl	%edx, -6016(%rbp,%rax,4)
	addl	$1, -6028(%rbp)
	addl	$1, -6032(%rbp)
.L3:
	addl	$1, -6044(%rbp)
.L2:
	movl	-6044(%rbp), %eax
	cmpl	-6024(%rbp), %eax
	jl	.L8
	movl	$0, -6032(%rbp)
	jmp	.L9
.L10:
	movl	-6032(%rbp), %eax
	cltq
	movl	-6016(%rbp,%rax,4), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	addl	$1, -6032(%rbp)
.L9:
	movl	-6032(%rbp), %eax
	cmpl	-6028(%rbp), %eax
	jl	.L10
	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%s"
.LC1:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB35:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	subq	$4096, %rsp
	.cfi_def_cfa_offset 4136
	orq	$0, (%rsp)
	subq	$1928, %rsp
	.cfi_def_cfa_offset 6064
	leaq	.LC0(%rip), %rdi
	movq	%fs:40, %rax
	movq	%rax, 6008(%rsp)
	xorl	%eax, %eax
	leaq	5008(%rsp), %r13
	leaq	4000(%rsp), %rbx
	movq	%r13, %rdx
	movq	%rbx, %rsi
	call	__isoc99_scanf@PLT
	movq	%rbx, %rdi
	call	strlen@PLT
	movq	%r13, %rdi
	movq	%rax, %r12
	movl	%eax, %ebp
	call	strlen@PLT
	testq	%r12, %r12
	je	.L7
	movl	%eax, %r13d
	movq	%rbx, %rcx
	xorl	%r12d, %r12d
	xorl	%esi, %esi
	movzbl	5008(%rsp), %r10d
	leal	1(%rax), %r8d
	leaq	5007(%rsp), %rdi
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L3:
	addq	$1, %rcx
	cmpl	%ebp, %esi
	je	.L20
.L6:
	movl	%esi, %r11d
	addl	$1, %esi
	cmpb	%r10b, (%rcx)
	jne	.L3
	cmpq	$1, %rax
	jbe	.L10
	movl	$2, %edx
	.p2align 4,,10
	.p2align 3
.L5:
	movzbl	(%rdi,%rdx), %ebx
	cmpb	%bl, -1(%rdx,%rcx)
	jne	.L3
	movl	%edx, %r9d
	addq	$1, %rdx
	cmpq	%r8, %rdx
	jne	.L5
.L4:
	cmpl	%r9d, %r13d
	jne	.L3
	movslq	%r12d, %rdx
	addl	$1, %r12d
	movl	%r11d, (%rsp,%rdx,4)
	jmp	.L3
	.p2align 4,,10
	.p2align 3
.L20:
	testl	%r12d, %r12d
	je	.L7
	leal	-1(%r12), %eax
	movq	%rsp, %rbx
	leaq	.LC1(%rip), %rbp
	leaq	4(%rsp,%rax,4), %r12
	.p2align 4,,10
	.p2align 3
.L8:
	movl	(%rbx), %edx
	movq	%rbp, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	addq	$4, %rbx
	call	__printf_chk@PLT
	cmpq	%r12, %rbx
	jne	.L8
.L7:
	movq	6008(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L21
	addq	$6024, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
.L10:
	.cfi_restore_state
	movl	$1, %r9d
	jmp	.L4
.L21:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE35:
	.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%s"
.LC1:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB35:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	subq	$4096, %rsp
	.cfi_def_cfa_offset 4136
	orq	$0, (%rsp)
	subq	$1928, %rsp
	.cfi_def_cfa_offset 6064
	leaq	.LC0(%rip), %rdi
	movq	%fs:40, %rax
	movq	%rax, 6008(%rsp)
	xorl	%eax, %eax
	leaq	5008(%rsp), %r13
	leaq	4000(%rsp), %rbx
	movq	%r13, %rdx
	movq	%rbx, %rsi
	call	__isoc99_scanf@PLT
	movq	%rbx, %rdi
	call	strlen@PLT
	movq	%r13, %rdi
	movq	%rax, %r12
	movl	%eax, %ebp
	call	strlen@PLT
	testq	%r12, %r12
	je	.L7
	movl	%eax, %r13d
	movq	%rbx, %rcx
	xorl	%r12d, %r12d
	xorl	%esi, %esi
	movzbl	5008(%rsp), %r10d
	leal	1(%rax), %r8d
	leaq	5007(%rsp), %rdi
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L3:
	addq	$1, %rcx
	cmpl	%ebp, %esi
	je	.L20
.L6:
	movl	%esi, %r11d
	addl	$1, %esi
	cmpb	%r10b, (%rcx)
	jne	.L3
	cmpq	$1, %rax
	jbe	.L10
	movl	$2, %edx
	.p2align 4,,10
	.p2align 3
.L5:
	movzbl	(%rdi,%rdx), %ebx
	cmpb	%bl, -1(%rdx,%rcx)
	jne	.L3
	movl	%edx, %r9d
	addq	$1, %rdx
	cmpq	%r8, %rdx
	jne	.L5
.L4:
	cmpl	%r9d, %r13d
	jne	.L3
	movslq	%r12d, %rdx
	addl	$1, %r12d
	movl	%r11d, (%rsp,%rdx,4)
	jmp	.L3
	.p2align 4,,10
	.p2align 3
.L20:
	testl	%r12d, %r12d
	je	.L7
	leal	-1(%r12), %eax
	movq	%rsp, %rbx
	leaq	.LC1(%rip), %rbp
	leaq	4(%rsp,%rax,4), %r12
	.p2align 4,,10
	.p2align 3
.L8:
	movl	(%rbx), %edx
	movq	%rbp, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	addq	$4, %rbx
	call	__printf_chk@PLT
	cmpq	%r12, %rbx
	jne	.L8
.L7:
	movq	6008(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L21
	addq	$6024, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
.L10:
	.cfi_restore_state
	movl	$1, %r9d
	jmp	.L4
.L21:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE35:
	.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>
#include<string.h>
#define N 1000

int main(){
  int i,j,n,k=0,sum=0,tlen,plen,v[N];
  char T[N],P[N];

  scanf("%s%s",T,P);
  tlen=strlen(T);
  plen=strlen(P);
  //printf("%d %d\n",tlen,plen);
  for(i=0;i<tlen;i++){
    if(T[i]==P[0]){
      j=i+1;
      n=1;
      while(n<plen){
        if(T[j]!=P[n])
          break;
        j++;
	n++;
      }
      if(n==plen){
        v[k]=i;
        sum++;
	k++;
      }
    }
  }
  for(k=0;k<sum;k++){
    printf("%d\n",v[k]);
  }
  //printf("%d\n",sum);
  return 0;
}
aaabaa
aa
 aabaaa
ba
 aaabaa
ba
 aab`aa
aa
 xyzy
yz
 aaaaba
aa
 abaaaa
aa
 abaaaa
ab
 aaacab
aa
 aaaaba
ba

0
1
4
 2
 3
 0
4
 1
 0
1
2
 2
3
4
 0
 0
1
 4

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>
#include<string.h>
#define N 1000

int main(){
  int i,j,n,k=0,sum=0,tlen,plen,v[N];
  char T[N],P[N];

  scanf("%s%s",T,P);
  tlen=strlen(T);
  plen=strlen(P);
  //printf("%d %d\n",tlen,plen);
  for(i=0;i<tlen;i++){
    if(T[i]==P[0]){
      j=i+1;
      n=1;
      while(n<plen){
        if(T[j]!=P[n])
          break;
        j++;
	n++;
      }
      if(n==plen){
        v[k]=i;
        sum++;
	k++;
      }
    }
  }
  for(k=0;k<sum;k++){
    printf("%d\n",v[k]);
  }
  //printf("%d\n",sum);
  return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%s%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	$4096, %rsp
	orq	$0, (%rsp)
	subq	$1952, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -6032(%rbp)
	movl	$0, -6028(%rbp)
	leaq	-1008(%rbp), %rdx
	leaq	-2016(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	leaq	-2016(%rbp), %rax
	movq	%rax, %rdi
	call	strlen@PLT
	movl	%eax, -6024(%rbp)
	leaq	-1008(%rbp), %rax
	movq	%rax, %rdi
	call	strlen@PLT
	movl	%eax, -6020(%rbp)
	movl	$0, -6044(%rbp)
	jmp	.L2
.L8:
	movl	-6044(%rbp), %eax
	cltq
	movzbl	-2016(%rbp,%rax), %edx
	movzbl	-1008(%rbp), %eax
	cmpb	%al, %dl
	jne	.L3
	movl	-6044(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -6040(%rbp)
	movl	$1, -6036(%rbp)
	jmp	.L4
.L7:
	movl	-6040(%rbp), %eax
	cltq
	movzbl	-2016(%rbp,%rax), %edx
	movl	-6036(%rbp), %eax
	cltq
	movzbl	-1008(%rbp,%rax), %eax
	cmpb	%al, %dl
	jne	.L13
	addl	$1, -6040(%rbp)
	addl	$1, -6036(%rbp)
.L4:
	movl	-6036(%rbp), %eax
	cmpl	-6020(%rbp), %eax
	jl	.L7
	jmp	.L6
.L13:
	nop
.L6:
	movl	-6036(%rbp), %eax
	cmpl	-6020(%rbp), %eax
	jne	.L3
	movl	-6032(%rbp), %eax
	cltq
	movl	-6044(%rbp), %edx
	movl	%edx, -6016(%rbp,%rax,4)
	addl	$1, -6028(%rbp)
	addl	$1, -6032(%rbp)
.L3:
	addl	$1, -6044(%rbp)
.L2:
	movl	-6044(%rbp), %eax
	cmpl	-6024(%rbp), %eax
	jl	.L8
	movl	$0, -6032(%rbp)
	jmp	.L9
.L10:
	movl	-6032(%rbp), %eax
	cltq
	movl	-6016(%rbp,%rax,4), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	addl	$1, -6032(%rbp)
.L9:
	movl	-6032(%rbp), %eax
	cmpl	-6028(%rbp), %eax
	jl	.L10
	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%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	$4096, %rsp
	orq	$0, (%rsp)
	subq	$1952, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -6032(%rbp)
	movl	$0, -6028(%rbp)
	leaq	-1008(%rbp), %rdx
	leaq	-2016(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	leaq	-2016(%rbp), %rax
	movq	%rax, %rdi
	call	strlen@PLT
	movl	%eax, -6024(%rbp)
	leaq	-1008(%rbp), %rax
	movq	%rax, %rdi
	call	strlen@PLT
	movl	%eax, -6020(%rbp)
	movl	$0, -6044(%rbp)
	jmp	.L2
.L8:
	movl	-6044(%rbp), %eax
	cltq
	movzbl	-2016(%rbp,%rax), %edx
	movzbl	-1008(%rbp), %eax
	cmpb	%al, %dl
	jne	.L3
	movl	-6044(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -6040(%rbp)
	movl	$1, -6036(%rbp)
	jmp	.L4
.L7:
	movl	-6040(%rbp), %eax
	cltq
	movzbl	-2016(%rbp,%rax), %edx
	movl	-6036(%rbp), %eax
	cltq
	movzbl	-1008(%rbp,%rax), %eax
	cmpb	%al, %dl
	jne	.L13
	addl	$1, -6040(%rbp)
	addl	$1, -6036(%rbp)
.L4:
	movl	-6036(%rbp), %eax
	cmpl	-6020(%rbp), %eax
	jl	.L7
	jmp	.L6
.L13:
	nop
.L6:
	movl	-6036(%rbp), %eax
	cmpl	-6020(%rbp), %eax
	jne	.L3
	movl	-6032(%rbp), %eax
	cltq
	movl	-6044(%rbp), %edx
	movl	%edx, -6016(%rbp,%rax,4)
	addl	$1, -6028(%rbp)
	addl	$1, -6032(%rbp)
.L3:
	addl	$1, -6044(%rbp)
.L2:
	movl	-6044(%rbp), %eax
	cmpl	-6024(%rbp), %eax
	jl	.L8
	movl	$0, -6032(%rbp)
	jmp	.L9
.L10:
	movl	-6032(%rbp), %eax
	cltq
	movl	-6016(%rbp,%rax,4), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	addl	$1, -6032(%rbp)
.L9:
	movl	-6032(%rbp), %eax
	cmpl	-6028(%rbp), %eax
	jl	.L10
	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:
