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()
{
    int n,a,bucket[100000] = {0};
    int i,j;

    scanf("%d",&n);
    for (i = 0; i < n; i++)
    {
        scanf("%d",&a);
        bucket[a]++;
    }
    
    int buf = 0,max = 0;
    for (i = 2; i < 100000; i++)
    {
        buf = bucket[i - 2] + bucket[i - 1] + bucket[i];
        if(buf > max)max = buf;
    }
    
    printf("%d",max);
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d"
	.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
	leaq	-397312(%rsp), %r11
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	subq	$2736, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-400016(%rbp), %rax
	movl	$400000, %edx
	movl	$0, %esi
	movq	%rax, %rdi
	call	memset@PLT
	leaq	-400036(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -400028(%rbp)
	jmp	.L2
.L3:
	leaq	-400032(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-400032(%rbp), %eax
	movslq	%eax, %rdx
	movl	-400016(%rbp,%rdx,4), %edx
	addl	$1, %edx
	cltq
	movl	%edx, -400016(%rbp,%rax,4)
	addl	$1, -400028(%rbp)
.L2:
	movl	-400036(%rbp), %eax
	cmpl	%eax, -400028(%rbp)
	jl	.L3
	movl	$0, -400020(%rbp)
	movl	$0, -400024(%rbp)
	movl	$2, -400028(%rbp)
	jmp	.L4
.L6:
	movl	-400028(%rbp), %eax
	subl	$2, %eax
	cltq
	movl	-400016(%rbp,%rax,4), %edx
	movl	-400028(%rbp), %eax
	subl	$1, %eax
	cltq
	movl	-400016(%rbp,%rax,4), %eax
	addl	%eax, %edx
	movl	-400028(%rbp), %eax
	cltq
	movl	-400016(%rbp,%rax,4), %eax
	addl	%edx, %eax
	movl	%eax, -400020(%rbp)
	movl	-400020(%rbp), %eax
	cmpl	-400024(%rbp), %eax
	jle	.L5
	movl	-400020(%rbp), %eax
	movl	%eax, -400024(%rbp)
.L5:
	addl	$1, -400028(%rbp)
.L4:
	cmpl	$99999, -400028(%rbp)
	jle	.L6
	movl	-400024(%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	.L8
	call	__stack_chk_fail@PLT
.L8:
	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	"%d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	leaq	-397312(%rsp), %r11
	.cfi_def_cfa 11, 397344
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	.cfi_def_cfa_register 7
	subq	$2720, %rsp
	.cfi_def_cfa_offset 400064
	movl	$400000, %edx
	xorl	%esi, %esi
	leaq	.LC0(%rip), %rbp
	movq	%fs:40, %rax
	movq	%rax, 400024(%rsp)
	xorl	%eax, %eax
	leaq	16(%rsp), %rdi
	call	memset@PLT
	leaq	8(%rsp), %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	8(%rsp), %eax
	testl	%eax, %eax
	jle	.L2
	xorl	%ebx, %ebx
	leaq	12(%rsp), %r12
	.p2align 4,,10
	.p2align 3
.L3:
	movq	%r12, %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	addl	$1, %ebx
	call	__isoc99_scanf@PLT
	movslq	12(%rsp), %rax
	addl	$1, 16(%rsp,%rax,4)
	cmpl	%ebx, 8(%rsp)
	jg	.L3
.L2:
	leaq	24(%rsp), %rax
	leaq	400008(%rsp), %rdx
	pxor	%xmm2, %xmm2
	.p2align 4,,10
	.p2align 3
.L4:
	movdqu	-4(%rax), %xmm0
	movdqu	(%rax), %xmm3
	addq	$16, %rax
	paddd	-24(%rax), %xmm0
	paddd	%xmm3, %xmm0
	movdqa	%xmm0, %xmm1
	pcmpgtd	%xmm2, %xmm1
	pand	%xmm1, %xmm0
	pandn	%xmm2, %xmm1
	movdqa	%xmm1, %xmm2
	por	%xmm0, %xmm2
	cmpq	%rax, %rdx
	jne	.L4
	movdqa	%xmm2, %xmm0
	movl	400004(%rsp), %ecx
	movq	%rbp, %rsi
	movl	$1, %edi
	psrldq	$8, %xmm0
	movl	400008(%rsp), %eax
	movdqa	%xmm0, %xmm1
	pcmpgtd	%xmm2, %xmm1
	addl	%ecx, %eax
	addl	400000(%rsp), %ecx
	addl	400012(%rsp), %eax
	addl	400008(%rsp), %ecx
	cmpl	%ecx, %eax
	pand	%xmm1, %xmm0
	pandn	%xmm2, %xmm1
	cmovl	%ecx, %eax
	por	%xmm0, %xmm1
	movdqa	%xmm1, %xmm2
	psrldq	$4, %xmm2
	movdqa	%xmm2, %xmm0
	pcmpgtd	%xmm1, %xmm0
	pand	%xmm0, %xmm2
	pandn	%xmm1, %xmm0
	por	%xmm2, %xmm0
	movd	%xmm0, %edx
	cmpl	%edx, %eax
	cmovge	%eax, %edx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	400024(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L10
	addq	$400032, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 32
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
.L10:
	.cfi_restore_state
	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	"%d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	leaq	-397312(%rsp), %r11
	.cfi_def_cfa 11, 397344
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	.cfi_def_cfa_register 7
	subq	$2720, %rsp
	.cfi_def_cfa_offset 400064
	movl	$400000, %edx
	xorl	%esi, %esi
	leaq	.LC0(%rip), %rbp
	movq	%fs:40, %rax
	movq	%rax, 400024(%rsp)
	xorl	%eax, %eax
	leaq	16(%rsp), %rdi
	call	memset@PLT
	leaq	8(%rsp), %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	8(%rsp), %eax
	testl	%eax, %eax
	jle	.L2
	xorl	%ebx, %ebx
	leaq	12(%rsp), %r12
	.p2align 4,,10
	.p2align 3
.L3:
	movq	%r12, %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	addl	$1, %ebx
	call	__isoc99_scanf@PLT
	movslq	12(%rsp), %rax
	addl	$1, 16(%rsp,%rax,4)
	cmpl	%ebx, 8(%rsp)
	jg	.L3
.L2:
	leaq	24(%rsp), %rax
	leaq	400008(%rsp), %rdx
	pxor	%xmm2, %xmm2
	.p2align 4,,10
	.p2align 3
.L4:
	movdqu	-4(%rax), %xmm0
	movdqu	(%rax), %xmm3
	addq	$16, %rax
	paddd	-24(%rax), %xmm0
	paddd	%xmm3, %xmm0
	movdqa	%xmm0, %xmm1
	pcmpgtd	%xmm2, %xmm1
	pand	%xmm1, %xmm0
	pandn	%xmm2, %xmm1
	movdqa	%xmm1, %xmm2
	por	%xmm0, %xmm2
	cmpq	%rax, %rdx
	jne	.L4
	movdqa	%xmm2, %xmm0
	movl	400004(%rsp), %ecx
	movq	%rbp, %rsi
	movl	$1, %edi
	psrldq	$8, %xmm0
	movl	400008(%rsp), %eax
	movdqa	%xmm0, %xmm1
	pcmpgtd	%xmm2, %xmm1
	addl	%ecx, %eax
	addl	400000(%rsp), %ecx
	addl	400012(%rsp), %eax
	addl	400008(%rsp), %ecx
	cmpl	%ecx, %eax
	pand	%xmm1, %xmm0
	pandn	%xmm2, %xmm1
	cmovl	%ecx, %eax
	por	%xmm0, %xmm1
	movdqa	%xmm1, %xmm2
	psrldq	$4, %xmm2
	movdqa	%xmm2, %xmm0
	pcmpgtd	%xmm1, %xmm0
	pand	%xmm0, %xmm2
	pandn	%xmm1, %xmm0
	por	%xmm2, %xmm0
	movd	%xmm0, %edx
	cmpl	%edx, %eax
	cmovge	%eax, %edx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	400024(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L10
	addq	$400032, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 32
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
.L10:
	.cfi_restore_state
	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()
{
    int n,a,bucket[100000] = {0};
    int i,j;

    scanf("%d",&n);
    for (i = 0; i < n; i++)
    {
        scanf("%d",&a);
        bucket[a]++;
    }
    
    int buf = 0,max = 0;
    for (i = 2; i < 100000; i++)
    {
        buf = bucket[i - 2] + bucket[i - 1] + bucket[i];
        if(buf > max)max = buf;
    }
    
    printf("%d",max);
}

7
3 1 4 1 5 9 2

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>

int main()
{
    int n,a,bucket[100000] = {0};
    int i,j;

    scanf("%d",&n);
    for (i = 0; i < n; i++)
    {
        scanf("%d",&a);
        bucket[a]++;
    }
    
    int buf = 0,max = 0;
    for (i = 2; i < 100000; i++)
    {
        buf = bucket[i - 2] + bucket[i - 1] + bucket[i];
        if(buf > max)max = buf;
    }
    
    printf("%d",max);
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d"
	.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
	leaq	-397312(%rsp), %r11
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	subq	$2736, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-400016(%rbp), %rax
	movl	$400000, %edx
	movl	$0, %esi
	movq	%rax, %rdi
	call	memset@PLT
	leaq	-400036(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -400028(%rbp)
	jmp	.L2
.L3:
	leaq	-400032(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-400032(%rbp), %eax
	movslq	%eax, %rdx
	movl	-400016(%rbp,%rdx,4), %edx
	addl	$1, %edx
	cltq
	movl	%edx, -400016(%rbp,%rax,4)
	addl	$1, -400028(%rbp)
.L2:
	movl	-400036(%rbp), %eax
	cmpl	%eax, -400028(%rbp)
	jl	.L3
	movl	$0, -400020(%rbp)
	movl	$0, -400024(%rbp)
	movl	$2, -400028(%rbp)
	jmp	.L4
.L6:
	movl	-400028(%rbp), %eax
	subl	$2, %eax
	cltq
	movl	-400016(%rbp,%rax,4), %edx
	movl	-400028(%rbp), %eax
	subl	$1, %eax
	cltq
	movl	-400016(%rbp,%rax,4), %eax
	addl	%eax, %edx
	movl	-400028(%rbp), %eax
	cltq
	movl	-400016(%rbp,%rax,4), %eax
	addl	%edx, %eax
	movl	%eax, -400020(%rbp)
	movl	-400020(%rbp), %eax
	cmpl	-400024(%rbp), %eax
	jle	.L5
	movl	-400020(%rbp), %eax
	movl	%eax, -400024(%rbp)
.L5:
	addl	$1, -400028(%rbp)
.L4:
	cmpl	$99999, -400028(%rbp)
	jle	.L6
	movl	-400024(%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	.L8
	call	__stack_chk_fail@PLT
.L8:
	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	"%d"
	.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
	leaq	-397312(%rsp), %r11
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	subq	$2736, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-400016(%rbp), %rax
	movl	$400000, %edx
	movl	$0, %esi
	movq	%rax, %rdi
	call	memset@PLT
	leaq	-400036(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -400028(%rbp)
	jmp	.L2
.L3:
	leaq	-400032(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-400032(%rbp), %eax
	movslq	%eax, %rdx
	movl	-400016(%rbp,%rdx,4), %edx
	addl	$1, %edx
	cltq
	movl	%edx, -400016(%rbp,%rax,4)
	addl	$1, -400028(%rbp)
.L2:
	movl	-400036(%rbp), %eax
	cmpl	%eax, -400028(%rbp)
	jl	.L3
	movl	$0, -400020(%rbp)
	movl	$0, -400024(%rbp)
	movl	$2, -400028(%rbp)
	jmp	.L4
.L6:
	movl	-400028(%rbp), %eax
	subl	$2, %eax
	cltq
	movl	-400016(%rbp,%rax,4), %edx
	movl	-400028(%rbp), %eax
	subl	$1, %eax
	cltq
	movl	-400016(%rbp,%rax,4), %eax
	addl	%eax, %edx
	movl	-400028(%rbp), %eax
	cltq
	movl	-400016(%rbp,%rax,4), %eax
	addl	%edx, %eax
	movl	%eax, -400020(%rbp)
	movl	-400020(%rbp), %eax
	cmpl	-400024(%rbp), %eax
	jle	.L5
	movl	-400020(%rbp), %eax
	movl	%eax, -400024(%rbp)
.L5:
	addl	$1, -400028(%rbp)
.L4:
	cmpl	$99999, -400028(%rbp)
	jle	.L6
	movl	-400024(%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	.L8
	call	__stack_chk_fail@PLT
.L8:
	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:
