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>

#define MAX(A,B)    (A)>(B) ? A : B

static char ch[5000];
static int A[5000];

int maxPrefixZAlgo( char S[], int size ) {
    int i, j;
    int c;
    int val;

    val = 0;
    c = 0;
    for (i=1; i<size; ++i) {
        // Z window の内側の場合
        if ( i+A[i-c] < c+A[c] ){
            A[i] = A[i-c];
        } else {
            j = MAX( 0, c+A[c]-i );
            while ( ( i+j < size )          // 文字列サイズ以下
                &&  ( S[j] == S[i+j] ) ) {  // かつ 文字が同じ場合
                ++j;    // 同一文字数をインクリメント
            }
            A[i] = j;
            c = i;

            // 問題用の結果の更新
            if ( ( A[i] > val )         // 文字長がこれまでより長い場合
              && ( i >= A[i] ) ) {      // 部分文字列の重複がない
                val = A[i];
            } 
        }
    }
    // printf("A: ");
    // for (i=0;i<size;++i) {
    //     printf("%d ", A[i]);
    // }
    // printf("\nval : %d\n", val);

    return val;
}


int main( void ) {
    int N;
    int i;
    int val, tmp;

    scanf("%d", &N);
    N = N > 5000 ? 5000 : N;
    scanf("%s", ch);

    // for(i=0;i<N;++i) {
    //     printf("%c", ch[i]);
    // }
    val = 0;
    for (i=0;i<N;++i) {
        tmp = maxPrefixZAlgo( &ch[i], N-i );
        // printf("tmp : %d\n", tmp);
        if ( tmp > val ) {
            val = tmp;
        }
        if ( val > N-i-1 ) {
            break;
        }
    }

    printf("%d", val);

    return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.local	ch
	.comm	ch,5000,32
	.local	A
	.comm	A,20000,32
	.globl	maxPrefixZAlgo
	.type	maxPrefixZAlgo, @function
maxPrefixZAlgo:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -24(%rbp)
	movl	%esi, -28(%rbp)
	movl	$0, -4(%rbp)
	movl	$0, -8(%rbp)
	movl	$1, -16(%rbp)
	jmp	.L2
.L8:
	movl	-16(%rbp), %eax
	subl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	A(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-16(%rbp), %eax
	leal	(%rdx,%rax), %ecx
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	A(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-8(%rbp), %eax
	addl	%edx, %eax
	cmpl	%eax, %ecx
	jge	.L3
	movl	-16(%rbp), %eax
	subl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	A(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-16(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	A(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	jmp	.L4
.L3:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	A(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-8(%rbp), %eax
	addl	%edx, %eax
	subl	-16(%rbp), %eax
	movl	$0, %edx
	testl	%eax, %eax
	cmovs	%edx, %eax
	movl	%eax, -12(%rbp)
	jmp	.L5
.L7:
	addl	$1, -12(%rbp)
.L5:
	movl	-16(%rbp), %edx
	movl	-12(%rbp), %eax
	addl	%edx, %eax
	cmpl	%eax, -28(%rbp)
	jle	.L6
	movl	-12(%rbp), %eax
	movslq	%eax, %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %edx
	movl	-16(%rbp), %ecx
	movl	-12(%rbp), %eax
	addl	%ecx, %eax
	movslq	%eax, %rcx
	movq	-24(%rbp), %rax
	addq	%rcx, %rax
	movzbl	(%rax), %eax
	cmpb	%al, %dl
	je	.L7
.L6:
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	A(%rip), %rdx
	movl	-12(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	movl	-16(%rbp), %eax
	movl	%eax, -8(%rbp)
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	A(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -4(%rbp)
	jge	.L4
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	A(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -16(%rbp)
	jl	.L4
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	A(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -4(%rbp)
.L4:
	addl	$1, -16(%rbp)
.L2:
	movl	-16(%rbp), %eax
	cmpl	-28(%rbp), %eax
	jl	.L8
	movl	-4(%rbp), %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	maxPrefixZAlgo, .-maxPrefixZAlgo
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%s"
	.text
	.globl	main
	.type	main, @function
main:
.LFB1:
	.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
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-24(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-24(%rbp), %eax
	movl	$5000, %edx
	cmpl	%edx, %eax
	cmovg	%edx, %eax
	movl	%eax, -24(%rbp)
	leaq	ch(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -16(%rbp)
	movl	$0, -20(%rbp)
	jmp	.L11
.L15:
	movl	-24(%rbp), %eax
	subl	-20(%rbp), %eax
	movl	-20(%rbp), %edx
	movslq	%edx, %rdx
	leaq	ch(%rip), %rcx
	addq	%rcx, %rdx
	movl	%eax, %esi
	movq	%rdx, %rdi
	call	maxPrefixZAlgo
	movl	%eax, -12(%rbp)
	movl	-12(%rbp), %eax
	cmpl	-16(%rbp), %eax
	jle	.L12
	movl	-12(%rbp), %eax
	movl	%eax, -16(%rbp)
.L12:
	movl	-24(%rbp), %eax
	subl	-20(%rbp), %eax
	cmpl	%eax, -16(%rbp)
	jge	.L18
	addl	$1, -20(%rbp)
.L11:
	movl	-24(%rbp), %eax
	cmpl	%eax, -20(%rbp)
	jl	.L15
	jmp	.L14
.L18:
	nop
.L14:
	movl	-16(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L17
	call	__stack_chk_fail@PLT
.L17:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.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
	.p2align 4
	.globl	maxPrefixZAlgo
	.type	maxPrefixZAlgo, @function
maxPrefixZAlgo:
.LFB23:
	.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
	cmpl	$1, %esi
	jle	.L9
	movq	%rdi, %rbp
	movl	%esi, %r9d
	movslq	%esi, %rbx
	movl	$1, %ecx
	xorl	%r12d, %r12d
	xorl	%edx, %edx
	leaq	A(%rip), %r10
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L3:
	movl	%eax, (%r10,%rcx,4)
	addq	$1, %rcx
	cmpq	%rcx, %rbx
	je	.L1
.L8:
	movl	%ecx, %eax
	movslq	%edx, %rsi
	movl	%ecx, %r8d
	movl	%ecx, %r11d
	subl	%edx, %eax
	movl	(%r10,%rsi,4), %edi
	cltq
	movl	(%r10,%rax,4), %eax
	addl	%edx, %edi
	movl	%edi, %esi
	leal	(%rax,%rcx), %edi
	cmpl	%esi, %edi
	jl	.L3
	movl	%esi, %eax
	movl	$0, %edx
	subl	%ecx, %eax
	cmovs	%edx, %eax
	leal	(%rax,%rcx), %edi
	cmpl	%edi, %r9d
	jle	.L4
	movslq	%eax, %r13
	movslq	%edi, %rdi
	leaq	0(%rbp,%r13), %rdx
	jmp	.L5
	.p2align 4,,10
	.p2align 3
.L6:
	addl	$1, %eax
	addq	$1, %rdx
	leal	(%rax,%r8), %esi
	cmpl	%esi, %r9d
	jle	.L4
.L5:
	movq	%rdx, %rsi
	subq	%r13, %rsi
	movzbl	(%rsi,%rdi), %esi
	cmpb	%sil, (%rdx)
	je	.L6
.L4:
	cmpl	%ecx, %eax
	jg	.L17
	cmpl	%r12d, %eax
	jle	.L17
	movl	%eax, %r12d
.L17:
	movl	%eax, (%r10,%rcx,4)
	addq	$1, %rcx
	movl	%r11d, %edx
	cmpq	%rcx, %rbx
	jne	.L8
.L1:
	popq	%rbx
	.cfi_remember_state
	.cfi_def_cfa_offset 32
	movl	%r12d, %eax
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
.L9:
	.cfi_restore_state
	xorl	%r12d, %r12d
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	movl	%r12d, %eax
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE23:
	.size	maxPrefixZAlgo, .-maxPrefixZAlgo
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	"%s"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB24:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	leaq	ch(%rip), %r14
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	leaq	.LC0(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movq	%rbp, %rdi
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	leaq	4(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movl	4(%rsp), %eax
	movq	%r14, %rsi
	movl	$5000, %edx
	leaq	.LC1(%rip), %rdi
	cmpl	%edx, %eax
	cmovg	%edx, %eax
	xorl	%r15d, %r15d
	movl	%eax, 4(%rsp)
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	4(%rsp), %r9d
	testl	%r9d, %r9d
	jle	.L20
	leaq	A(%rip), %r10
	cmpl	$1, %r9d
	je	.L20
	.p2align 4,,10
	.p2align 3
.L47:
	movl	%r9d, %r12d
	movl	$1, %ecx
	xorl	%r13d, %r13d
	xorl	%edx, %edx
	jmp	.L26
	.p2align 4,,10
	.p2align 3
.L21:
	movl	%eax, (%r10,%rcx,4)
	addq	$1, %rcx
	cmpq	%rcx, %r12
	je	.L46
.L26:
	movl	%ecx, %eax
	movslq	%edx, %rsi
	movl	%ecx, %r8d
	movl	%ecx, %ebx
	subl	%edx, %eax
	movl	(%r10,%rsi,4), %edi
	cltq
	movl	(%r10,%rax,4), %eax
	addl	%edx, %edi
	movl	%edi, %esi
	leal	(%rax,%rcx), %edi
	cmpl	%esi, %edi
	jl	.L21
	movl	%esi, %eax
	movl	$0, %edx
	subl	%ecx, %eax
	cmovs	%edx, %eax
	leal	(%rax,%rcx), %edi
	cmpl	%r9d, %edi
	jge	.L22
	movslq	%eax, %r11
	movslq	%edi, %rdi
	leaq	(%r14,%r11), %rdx
	jmp	.L23
	.p2align 4,,10
	.p2align 3
.L24:
	addl	$1, %eax
	addq	$1, %rdx
	leal	(%rax,%r8), %esi
	cmpl	%esi, %r9d
	jle	.L22
.L23:
	movq	%rdx, %rsi
	subq	%r11, %rsi
	movzbl	(%rsi,%rdi), %esi
	cmpb	%sil, (%rdx)
	je	.L24
.L22:
	cmpl	%r13d, %eax
	jle	.L45
	cmpl	%ecx, %eax
	jg	.L45
	movl	%eax, %r13d
.L45:
	movl	%eax, (%r10,%rcx,4)
	addq	$1, %rcx
	movl	%ebx, %edx
	cmpq	%rcx, %r12
	jne	.L26
.L46:
	cmpl	%r13d, %r15d
	cmovl	%r13d, %r15d
	cmpl	%r9d, %r15d
	jge	.L20
	subl	$1, %r9d
	addq	$1, %r14
	cmpl	$1, %r9d
	jne	.L47
.L20:
	xorl	%eax, %eax
	movl	%r15d, %edx
	movq	%rbp, %rsi
	movl	$1, %edi
	call	__printf_chk@PLT
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L48
	addq	$24, %rsp
	.cfi_remember_state
	.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
.L48:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE24:
	.size	main, .-main
	.local	A
	.comm	A,20000,32
	.local	ch
	.comm	ch,5000,32
	.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
	.p2align 4
	.globl	maxPrefixZAlgo
	.type	maxPrefixZAlgo, @function
maxPrefixZAlgo:
.LFB23:
	.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
	cmpl	$1, %esi
	jle	.L9
	movq	%rdi, %rbp
	movl	%esi, %r9d
	movslq	%esi, %rbx
	movl	$1, %ecx
	xorl	%r12d, %r12d
	xorl	%edx, %edx
	leaq	A(%rip), %r10
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L3:
	movl	%eax, (%r10,%rcx,4)
	addq	$1, %rcx
	cmpq	%rcx, %rbx
	je	.L1
.L8:
	movl	%ecx, %eax
	movslq	%edx, %rsi
	movl	%ecx, %r8d
	movl	%ecx, %r11d
	subl	%edx, %eax
	movl	(%r10,%rsi,4), %edi
	cltq
	movl	(%r10,%rax,4), %eax
	addl	%edx, %edi
	movl	%edi, %esi
	leal	(%rax,%rcx), %edi
	cmpl	%esi, %edi
	jl	.L3
	movl	%esi, %eax
	movl	$0, %edx
	subl	%ecx, %eax
	cmovs	%edx, %eax
	leal	(%rax,%rcx), %edi
	cmpl	%edi, %r9d
	jle	.L4
	movslq	%eax, %r13
	movslq	%edi, %rdi
	leaq	0(%rbp,%r13), %rdx
	jmp	.L5
	.p2align 4,,10
	.p2align 3
.L6:
	addl	$1, %eax
	addq	$1, %rdx
	leal	(%rax,%r8), %esi
	cmpl	%esi, %r9d
	jle	.L4
.L5:
	movq	%rdx, %rsi
	subq	%r13, %rsi
	movzbl	(%rsi,%rdi), %esi
	cmpb	%sil, (%rdx)
	je	.L6
.L4:
	cmpl	%ecx, %eax
	jg	.L17
	cmpl	%r12d, %eax
	jle	.L17
	movl	%eax, %r12d
.L17:
	movl	%eax, (%r10,%rcx,4)
	addq	$1, %rcx
	movl	%r11d, %edx
	cmpq	%rcx, %rbx
	jne	.L8
.L1:
	popq	%rbx
	.cfi_remember_state
	.cfi_def_cfa_offset 32
	movl	%r12d, %eax
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
.L9:
	.cfi_restore_state
	xorl	%r12d, %r12d
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	movl	%r12d, %eax
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE23:
	.size	maxPrefixZAlgo, .-maxPrefixZAlgo
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	"%s"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB24:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	leaq	ch(%rip), %r14
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	leaq	.LC0(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movq	%rbp, %rdi
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	leaq	4(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movl	4(%rsp), %eax
	movq	%r14, %rsi
	movl	$5000, %edx
	leaq	.LC1(%rip), %rdi
	cmpl	%edx, %eax
	cmovg	%edx, %eax
	xorl	%r15d, %r15d
	movl	%eax, 4(%rsp)
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	4(%rsp), %r9d
	testl	%r9d, %r9d
	jle	.L20
	leaq	A(%rip), %r10
	cmpl	$1, %r9d
	je	.L20
	.p2align 4,,10
	.p2align 3
.L47:
	movl	%r9d, %r12d
	movl	$1, %ecx
	xorl	%r13d, %r13d
	xorl	%edx, %edx
	jmp	.L26
	.p2align 4,,10
	.p2align 3
.L21:
	movl	%eax, (%r10,%rcx,4)
	addq	$1, %rcx
	cmpq	%rcx, %r12
	je	.L46
.L26:
	movl	%ecx, %eax
	movslq	%edx, %rsi
	movl	%ecx, %r8d
	movl	%ecx, %ebx
	subl	%edx, %eax
	movl	(%r10,%rsi,4), %edi
	cltq
	movl	(%r10,%rax,4), %eax
	addl	%edx, %edi
	movl	%edi, %esi
	leal	(%rax,%rcx), %edi
	cmpl	%esi, %edi
	jl	.L21
	movl	%esi, %eax
	movl	$0, %edx
	subl	%ecx, %eax
	cmovs	%edx, %eax
	leal	(%rax,%rcx), %edi
	cmpl	%r9d, %edi
	jge	.L22
	movslq	%eax, %r11
	movslq	%edi, %rdi
	leaq	(%r14,%r11), %rdx
	jmp	.L23
	.p2align 4,,10
	.p2align 3
.L24:
	addl	$1, %eax
	addq	$1, %rdx
	leal	(%rax,%r8), %esi
	cmpl	%esi, %r9d
	jle	.L22
.L23:
	movq	%rdx, %rsi
	subq	%r11, %rsi
	movzbl	(%rsi,%rdi), %esi
	cmpb	%sil, (%rdx)
	je	.L24
.L22:
	cmpl	%r13d, %eax
	jle	.L45
	cmpl	%ecx, %eax
	jg	.L45
	movl	%eax, %r13d
.L45:
	movl	%eax, (%r10,%rcx,4)
	addq	$1, %rcx
	movl	%ebx, %edx
	cmpq	%rcx, %r12
	jne	.L26
.L46:
	cmpl	%r13d, %r15d
	cmovl	%r13d, %r15d
	cmpl	%r9d, %r15d
	jge	.L20
	subl	$1, %r9d
	addq	$1, %r14
	cmpl	$1, %r9d
	jne	.L47
.L20:
	xorl	%eax, %eax
	movl	%r15d, %edx
	movq	%rbp, %rsi
	movl	$1, %edi
	call	__printf_chk@PLT
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L48
	addq	$24, %rsp
	.cfi_remember_state
	.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
.L48:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE24:
	.size	main, .-main
	.local	A
	.comm	A,20000,32
	.local	ch
	.comm	ch,5000,32
	.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>

#define MAX(A,B)    (A)>(B) ? A : B

static char ch[5000];
static int A[5000];

int maxPrefixZAlgo( char S[], int size ) {
    int i, j;
    int c;
    int val;

    val = 0;
    c = 0;
    for (i=1; i<size; ++i) {
        // Z window の内側の場合
        if ( i+A[i-c] < c+A[c] ){
            A[i] = A[i-c];
        } else {
            j = MAX( 0, c+A[c]-i );
            while ( ( i+j < size )          // 文字列サイズ以下
                &&  ( S[j] == S[i+j] ) ) {  // かつ 文字が同じ場合
                ++j;    // 同一文字数をインクリメント
            }
            A[i] = j;
            c = i;

            // 問題用の結果の更新
            if ( ( A[i] > val )         // 文字長がこれまでより長い場合
              && ( i >= A[i] ) ) {      // 部分文字列の重複がない
                val = A[i];
            } 
        }
    }
    // printf("A: ");
    // for (i=0;i<size;++i) {
    //     printf("%d ", A[i]);
    // }
    // printf("\nval : %d\n", val);

    return val;
}


int main( void ) {
    int N;
    int i;
    int val, tmp;

    scanf("%d", &N);
    N = N > 5000 ? 5000 : N;
    scanf("%s", ch);

    // for(i=0;i<N;++i) {
    //     printf("%c", ch[i]);
    // }
    val = 0;
    for (i=0;i<N;++i) {
        tmp = maxPrefixZAlgo( &ch[i], N-i );
        // printf("tmp : %d\n", tmp);
        if ( tmp > val ) {
            val = tmp;
        }
        if ( val > N-i-1 ) {
            break;
        }
    }

    printf("%d", val);

    return 0;
}
13
strangeoranfe
 2
wy
 5
`baba
 5
abac`
 13
efnaroegnarts
 2
vy
 5
abab`
 13
efnarotgnares
 2
yx
 13
serangtoranfe

3 0 2 1 3 0 2 3 0 3
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>

#define MAX(A,B)    (A)>(B) ? A : B

static char ch[5000];
static int A[5000];

int maxPrefixZAlgo( char S[], int size ) {
    int i, j;
    int c;
    int val;

    val = 0;
    c = 0;
    for (i=1; i<size; ++i) {
        // Z window の内側の場合
        if ( i+A[i-c] < c+A[c] ){
            A[i] = A[i-c];
        } else {
            j = MAX( 0, c+A[c]-i );
            while ( ( i+j < size )          // 文字列サイズ以下
                &&  ( S[j] == S[i+j] ) ) {  // かつ 文字が同じ場合
                ++j;    // 同一文字数をインクリメント
            }
            A[i] = j;
            c = i;

            // 問題用の結果の更新
            if ( ( A[i] > val )         // 文字長がこれまでより長い場合
              && ( i >= A[i] ) ) {      // 部分文字列の重複がない
                val = A[i];
            } 
        }
    }
    // printf("A: ");
    // for (i=0;i<size;++i) {
    //     printf("%d ", A[i]);
    // }
    // printf("\nval : %d\n", val);

    return val;
}


int main( void ) {
    int N;
    int i;
    int val, tmp;

    scanf("%d", &N);
    N = N > 5000 ? 5000 : N;
    scanf("%s", ch);

    // for(i=0;i<N;++i) {
    //     printf("%c", ch[i]);
    // }
    val = 0;
    for (i=0;i<N;++i) {
        tmp = maxPrefixZAlgo( &ch[i], N-i );
        // printf("tmp : %d\n", tmp);
        if ( tmp > val ) {
            val = tmp;
        }
        if ( val > N-i-1 ) {
            break;
        }
    }

    printf("%d", val);

    return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.local	ch
	.comm	ch,5000,32
	.local	A
	.comm	A,20000,32
	.globl	maxPrefixZAlgo
	.type	maxPrefixZAlgo, @function
maxPrefixZAlgo:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -24(%rbp)
	movl	%esi, -28(%rbp)
	movl	$0, -4(%rbp)
	movl	$0, -8(%rbp)
	movl	$1, -16(%rbp)
	jmp	.L2
.L8:
	movl	-16(%rbp), %eax
	subl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	A(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-16(%rbp), %eax
	leal	(%rdx,%rax), %ecx
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	A(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-8(%rbp), %eax
	addl	%edx, %eax
	cmpl	%eax, %ecx
	jge	.L3
	movl	-16(%rbp), %eax
	subl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	A(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-16(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	A(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	jmp	.L4
.L3:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	A(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-8(%rbp), %eax
	addl	%edx, %eax
	subl	-16(%rbp), %eax
	movl	$0, %edx
	testl	%eax, %eax
	cmovs	%edx, %eax
	movl	%eax, -12(%rbp)
	jmp	.L5
.L7:
	addl	$1, -12(%rbp)
.L5:
	movl	-16(%rbp), %edx
	movl	-12(%rbp), %eax
	addl	%edx, %eax
	cmpl	%eax, -28(%rbp)
	jle	.L6
	movl	-12(%rbp), %eax
	movslq	%eax, %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %edx
	movl	-16(%rbp), %ecx
	movl	-12(%rbp), %eax
	addl	%ecx, %eax
	movslq	%eax, %rcx
	movq	-24(%rbp), %rax
	addq	%rcx, %rax
	movzbl	(%rax), %eax
	cmpb	%al, %dl
	je	.L7
.L6:
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	A(%rip), %rdx
	movl	-12(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	movl	-16(%rbp), %eax
	movl	%eax, -8(%rbp)
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	A(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -4(%rbp)
	jge	.L4
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	A(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -16(%rbp)
	jl	.L4
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	A(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -4(%rbp)
.L4:
	addl	$1, -16(%rbp)
.L2:
	movl	-16(%rbp), %eax
	cmpl	-28(%rbp), %eax
	jl	.L8
	movl	-4(%rbp), %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	maxPrefixZAlgo, .-maxPrefixZAlgo
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%s"
	.text
	.globl	main
	.type	main, @function
main:
.LFB1:
	.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
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-24(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-24(%rbp), %eax
	movl	$5000, %edx
	cmpl	%edx, %eax
	cmovg	%edx, %eax
	movl	%eax, -24(%rbp)
	leaq	ch(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -16(%rbp)
	movl	$0, -20(%rbp)
	jmp	.L11
.L15:
	movl	-24(%rbp), %eax
	subl	-20(%rbp), %eax
	movl	-20(%rbp), %edx
	movslq	%edx, %rdx
	leaq	ch(%rip), %rcx
	addq	%rcx, %rdx
	movl	%eax, %esi
	movq	%rdx, %rdi
	call	maxPrefixZAlgo
	movl	%eax, -12(%rbp)
	movl	-12(%rbp), %eax
	cmpl	-16(%rbp), %eax
	jle	.L12
	movl	-12(%rbp), %eax
	movl	%eax, -16(%rbp)
.L12:
	movl	-24(%rbp), %eax
	subl	-20(%rbp), %eax
	cmpl	%eax, -16(%rbp)
	jge	.L18
	addl	$1, -20(%rbp)
.L11:
	movl	-24(%rbp), %eax
	cmpl	%eax, -20(%rbp)
	jl	.L15
	jmp	.L14
.L18:
	nop
.L14:
	movl	-16(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L17
	call	__stack_chk_fail@PLT
.L17:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.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
	.local	ch
	.comm	ch,5000,32
	.local	A
	.comm	A,20000,32
	.globl	maxPrefixZAlgo
	.type	maxPrefixZAlgo, @function
maxPrefixZAlgo:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -24(%rbp)
	movl	%esi, -28(%rbp)
	movl	$0, -4(%rbp)
	movl	$0, -8(%rbp)
	movl	$1, -16(%rbp)
	jmp	.L2
.L8:
	movl	-16(%rbp), %eax
	subl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	A(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-16(%rbp), %eax
	leal	(%rdx,%rax), %ecx
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	A(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-8(%rbp), %eax
	addl	%edx, %eax
	cmpl	%eax, %ecx
	jge	.L3
	movl	-16(%rbp), %eax
	subl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	A(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-16(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	A(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	jmp	.L4
.L3:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	A(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-8(%rbp), %eax
	addl	%edx, %eax
	subl	-16(%rbp), %eax
	movl	$0, %edx
	testl	%eax, %eax
	cmovs	%edx, %eax
	movl	%eax, -12(%rbp)
	jmp	.L5
.L7:
	addl	$1, -12(%rbp)
.L5:
	movl	-16(%rbp), %edx
	movl	-12(%rbp), %eax
	addl	%edx, %eax
	cmpl	%eax, -28(%rbp)
	jle	.L6
	movl	-12(%rbp), %eax
	movslq	%eax, %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %edx
	movl	-16(%rbp), %ecx
	movl	-12(%rbp), %eax
	addl	%ecx, %eax
	movslq	%eax, %rcx
	movq	-24(%rbp), %rax
	addq	%rcx, %rax
	movzbl	(%rax), %eax
	cmpb	%al, %dl
	je	.L7
.L6:
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	A(%rip), %rdx
	movl	-12(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	movl	-16(%rbp), %eax
	movl	%eax, -8(%rbp)
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	A(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -4(%rbp)
	jge	.L4
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	A(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -16(%rbp)
	jl	.L4
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	A(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -4(%rbp)
.L4:
	addl	$1, -16(%rbp)
.L2:
	movl	-16(%rbp), %eax
	cmpl	-28(%rbp), %eax
	jl	.L8
	movl	-4(%rbp), %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	maxPrefixZAlgo, .-maxPrefixZAlgo
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%s"
	.text
	.globl	main
	.type	main, @function
main:
.LFB1:
	.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
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-24(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-24(%rbp), %eax
	movl	$5000, %edx
	cmpl	%edx, %eax
	cmovg	%edx, %eax
	movl	%eax, -24(%rbp)
	leaq	ch(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -16(%rbp)
	movl	$0, -20(%rbp)
	jmp	.L11
.L15:
	movl	-24(%rbp), %eax
	subl	-20(%rbp), %eax
	movl	-20(%rbp), %edx
	movslq	%edx, %rdx
	leaq	ch(%rip), %rcx
	addq	%rcx, %rdx
	movl	%eax, %esi
	movq	%rdx, %rdi
	call	maxPrefixZAlgo
	movl	%eax, -12(%rbp)
	movl	-12(%rbp), %eax
	cmpl	-16(%rbp), %eax
	jle	.L12
	movl	-12(%rbp), %eax
	movl	%eax, -16(%rbp)
.L12:
	movl	-24(%rbp), %eax
	subl	-20(%rbp), %eax
	cmpl	%eax, -16(%rbp)
	jge	.L18
	addl	$1, -20(%rbp)
.L11:
	movl	-24(%rbp), %eax
	cmpl	%eax, -20(%rbp)
	jl	.L15
	jmp	.L14
.L18:
	nop
.L14:
	movl	-16(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L17
	call	__stack_chk_fail@PLT
.L17:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.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:
