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 M 50
int X[M];long long Z[M+1][M*M+1];
int main(){
	int N,A,S=0;
	long long R=0;
	scanf("%d%d",&N,&A);
	for(int i=0;i<N;i++)scanf("%d",X+i);
	Z[0][0]=1;
	for(int i=0;i<N;i++){
		S+=X[i];
		for(int k=i;k>=0;k--)for(int j=S;j>=X[i];j--)Z[k+1][j]+=Z[k][j-X[i]];
	}
	for(int i=1;i<=N;i++)R+=Z[i][i*A];
	printf("%lld\n",R);
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	X
	.bss
	.align 32
	.type	X, @object
	.size	X, 200
X:
	.zero	200
	.globl	Z
	.align 32
	.type	Z, @object
	.size	Z, 1020408
Z:
	.zero	1020408
	.section	.rodata
.LC0:
	.string	"%d%d"
.LC1:
	.string	"%d"
.LC2:
	.string	"%lld\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	$48, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -40(%rbp)
	movq	$0, -16(%rbp)
	leaq	-44(%rbp), %rdx
	leaq	-48(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -36(%rbp)
	jmp	.L2
.L3:
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	X(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -36(%rbp)
.L2:
	movl	-48(%rbp), %eax
	cmpl	%eax, -36(%rbp)
	jl	.L3
	movq	$1, Z(%rip)
	movl	$0, -32(%rbp)
	jmp	.L4
.L9:
	movl	-32(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	X(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%eax, -40(%rbp)
	movl	-32(%rbp), %eax
	movl	%eax, -28(%rbp)
	jmp	.L5
.L8:
	movl	-40(%rbp), %eax
	movl	%eax, -24(%rbp)
	jmp	.L6
.L7:
	movl	-28(%rbp), %eax
	leal	1(%rax), %edx
	movl	-24(%rbp), %eax
	movslq	%eax, %rcx
	movslq	%edx, %rax
	imulq	$2501, %rax, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,8), %rdx
	leaq	Z(%rip), %rax
	movq	(%rdx,%rax), %rsi
	movl	-32(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	X(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-24(%rbp), %eax
	subl	%edx, %eax
	movslq	%eax, %rdx
	movl	-28(%rbp), %eax
	cltq
	imulq	$2501, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rdx
	leaq	Z(%rip), %rax
	movq	(%rdx,%rax), %rcx
	movl	-28(%rbp), %eax
	leal	1(%rax), %edx
	addq	%rsi, %rcx
	movl	-24(%rbp), %eax
	movslq	%eax, %rsi
	movslq	%edx, %rax
	imulq	$2501, %rax, %rax
	addq	%rsi, %rax
	leaq	0(,%rax,8), %rdx
	leaq	Z(%rip), %rax
	movq	%rcx, (%rdx,%rax)
	subl	$1, -24(%rbp)
.L6:
	movl	-32(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	X(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -24(%rbp)
	jge	.L7
	subl	$1, -28(%rbp)
.L5:
	cmpl	$0, -28(%rbp)
	jns	.L8
	addl	$1, -32(%rbp)
.L4:
	movl	-48(%rbp), %eax
	cmpl	%eax, -32(%rbp)
	jl	.L9
	movl	$1, -20(%rbp)
	jmp	.L10
.L11:
	movl	-44(%rbp), %eax
	imull	-20(%rbp), %eax
	movslq	%eax, %rdx
	movl	-20(%rbp), %eax
	cltq
	imulq	$2501, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rdx
	leaq	Z(%rip), %rax
	movq	(%rdx,%rax), %rax
	addq	%rax, -16(%rbp)
	addl	$1, -20(%rbp)
.L10:
	movl	-48(%rbp), %eax
	cmpl	%eax, -20(%rbp)
	jle	.L11
	movq	-16(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L13
	call	__stack_chk_fail@PLT
.L13:
	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%d"
.LC1:
	.string	"%d"
.LC2:
	.string	"%lld\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	.LC0(%rip), %rdi
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	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
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$88, %rsp
	.cfi_def_cfa_offset 144
	movq	%fs:40, %rax
	movq	%rax, 72(%rsp)
	xorl	%eax, %eax
	leaq	68(%rsp), %rdx
	leaq	64(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movl	64(%rsp), %eax
	testl	%eax, %eax
	jle	.L2
	leaq	X(%rip), %rbp
	xorl	%ebx, %ebx
	leaq	.LC1(%rip), %r12
	.p2align 4,,10
	.p2align 3
.L3:
	movq	%rbp, %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	addl	$1, %ebx
	call	__isoc99_scanf@PLT
	movl	64(%rsp), %eax
	addq	$4, %rbp
	cmpl	%ebx, %eax
	jg	.L3
	movl	%eax, 52(%rsp)
	movq	$1, Z(%rip)
	testl	%eax, %eax
	jle	.L4
	leal	-1(%rax), %ebx
	movq	%rax, 40(%rsp)
	leaq	Z(%rip), %r14
	movq	%rbx, 56(%rsp)
	movq	$0, 32(%rsp)
	movq	$0, 8(%rsp)
	movl	$0, 48(%rsp)
	.p2align 4,,10
	.p2align 3
.L13:
	movq	8(%rsp), %rax
	leaq	X(%rip), %rbx
	movl	48(%rsp), %r15d
	movl	(%rbx,%rax,4), %edi
	movl	%eax, %esi
	movl	%r15d, %eax
	addl	%edi, %r15d
	movl	%r15d, 48(%rsp)
	cmpl	%r15d, %edi
	jg	.L5
	movslq	%edi, %rbx
	leal	1(%rax), %r13d
	leaq	20016(,%rbx,8), %rdx
	movl	%r13d, %r11d
	movl	%r13d, %r8d
	testq	%rdx, %rdx
	setne	%bpl
	cmpl	$1, %eax
	seta	%dl
	andl	$-2, %r11d
	shrl	%r8d
	andl	%edx, %ebp
	movslq	%eax, %rdx
	movl	%eax, %eax
	subl	%r11d, %r15d
	leaq	(%rbx,%rdx), %rcx
	movslq	%r15d, %r9
	subl	$1, %r8d
	movl	%r11d, 4(%rsp)
	leaq	(%r14,%rcx,8), %r12
	subq	%rax, %rcx
	movl	%r9d, %r10d
	notq	%r8
	subl	%edi, %r10d
	movq	32(%rsp), %r11
	salq	$4, %r8
	negq	%rbx
	leaq	20008(%r12), %rax
	leaq	-8(%r14,%rdx,8), %r15
	addq	$20000, %r12
	movslq	%r10d, %r10
	movq	%rax, 16(%rsp)
	leaq	20000+Z(%rip), %rax
	leaq	(%rax,%rcx,8), %rax
	movq	%rax, 24(%rsp)
	.p2align 4,,10
	.p2align 3
.L6:
	leal	1(%rsi), %eax
	testb	%bpl, %bpl
	je	.L33
	leaq	(%r12,%r11), %rcx
	leaq	(%r15,%r11), %rdi
	xorl	%edx, %edx
	.p2align 4,,10
	.p2align 3
.L7:
	movdqu	(%rcx,%rdx), %xmm0
	movdqu	(%rdi,%rdx), %xmm1
	shufpd	$1, %xmm0, %xmm0
	shufpd	$1, %xmm1, %xmm1
	paddq	%xmm1, %xmm0
	shufpd	$1, %xmm0, %xmm0
	movups	%xmm0, (%rcx,%rdx)
	subq	$16, %rdx
	cmpq	%r8, %rdx
	jne	.L7
	cmpl	4(%rsp), %r13d
	je	.L10
	cltq
	movslq	%esi, %rdx
	imulq	$2501, %rax, %rax
	imulq	$2501, %rdx, %rdx
	addq	%r9, %rax
	addq	%r10, %rdx
	movq	(%r14,%rdx,8), %rdx
	addq	%rdx, (%r14,%rax,8)
.L10:
	subl	$1, %esi
	subq	$20008, %r11
	cmpl	$-1, %esi
	jne	.L6
.L5:
	addq	$1, 8(%rsp)
	movq	8(%rsp), %rax
	addq	$20008, 32(%rsp)
	cmpq	40(%rsp), %rax
	jne	.L13
	movslq	68(%rsp), %rax
	cmpl	$1, %eax
	jne	.L34
	imulq	$20016, 56(%rsp), %rcx
	leaq	20016+Z(%rip), %rax
	leaq	20016(%rax), %rdx
	addq	%rdx, %rcx
	xorl	%edx, %edx
	.p2align 4,,10
	.p2align 3
.L17:
	addq	(%rax), %rdx
	addq	$20016, %rax
	cmpq	%rcx, %rax
	jne	.L17
.L18:
	xorl	%eax, %eax
	leaq	.LC2(%rip), %rsi
	movl	$1, %edi
	call	__printf_chk@PLT
	movq	72(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L35
	addq	$88, %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
	.p2align 4,,10
	.p2align 3
.L33:
	.cfi_restore_state
	movq	16(%rsp), %rax
	movq	24(%rsp), %rdi
	addq	%r11, %rax
	leaq	(%rdi,%r11), %rcx
	.p2align 4,,10
	.p2align 3
.L9:
	movq	-20008(%rax,%rbx,8), %rdx
	addq	%rdx, (%rax)
	subq	$8, %rax
	cmpq	%rcx, %rax
	jne	.L9
	jmp	.L10
.L34:
	leaq	20008(,%rax,8), %rdi
	movl	$1, %ecx
	xorl	%edx, %edx
	leaq	Z(%rip), %rax
	leaq	-20008(%rax,%rdi), %rsi
	movl	52(%rsp), %eax
	addl	$1, %eax
.L15:
	addl	$1, %ecx
	addq	20008(%rsi), %rdx
	addq	%rdi, %rsi
	cmpl	%eax, %ecx
	jne	.L15
	jmp	.L18
.L2:
	movq	$1, Z(%rip)
.L4:
	xorl	%edx, %edx
	jmp	.L18
.L35:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.globl	Z
	.bss
	.align 32
	.type	Z, @object
	.size	Z, 1020408
Z:
	.zero	1020408
	.globl	X
	.align 32
	.type	X, @object
	.size	X, 200
X:
	.zero	200
	.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%d"
.LC1:
	.string	"%d"
.LC2:
	.string	"%lld\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	.LC0(%rip), %rdi
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	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
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$88, %rsp
	.cfi_def_cfa_offset 144
	movq	%fs:40, %rax
	movq	%rax, 72(%rsp)
	xorl	%eax, %eax
	leaq	68(%rsp), %rdx
	leaq	64(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movl	64(%rsp), %eax
	testl	%eax, %eax
	jle	.L2
	leaq	X(%rip), %rbp
	xorl	%ebx, %ebx
	leaq	.LC1(%rip), %r12
	.p2align 4,,10
	.p2align 3
.L3:
	movq	%rbp, %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	addl	$1, %ebx
	call	__isoc99_scanf@PLT
	movl	64(%rsp), %eax
	addq	$4, %rbp
	cmpl	%ebx, %eax
	jg	.L3
	movl	%eax, 52(%rsp)
	movq	$1, Z(%rip)
	testl	%eax, %eax
	jle	.L4
	leal	-1(%rax), %ebx
	movq	%rax, 40(%rsp)
	leaq	Z(%rip), %r14
	movq	%rbx, 56(%rsp)
	movq	$0, 32(%rsp)
	movq	$0, 8(%rsp)
	movl	$0, 48(%rsp)
	.p2align 4,,10
	.p2align 3
.L13:
	movq	8(%rsp), %rax
	leaq	X(%rip), %rbx
	movl	48(%rsp), %r15d
	movl	(%rbx,%rax,4), %edi
	movl	%eax, %esi
	movl	%r15d, %eax
	addl	%edi, %r15d
	movl	%r15d, 48(%rsp)
	cmpl	%r15d, %edi
	jg	.L5
	movslq	%edi, %rbx
	leal	1(%rax), %r13d
	leaq	20016(,%rbx,8), %rdx
	movl	%r13d, %r11d
	movl	%r13d, %r8d
	testq	%rdx, %rdx
	setne	%bpl
	cmpl	$1, %eax
	seta	%dl
	andl	$-2, %r11d
	shrl	%r8d
	andl	%edx, %ebp
	movslq	%eax, %rdx
	movl	%eax, %eax
	subl	%r11d, %r15d
	leaq	(%rbx,%rdx), %rcx
	movslq	%r15d, %r9
	subl	$1, %r8d
	movl	%r11d, 4(%rsp)
	leaq	(%r14,%rcx,8), %r12
	subq	%rax, %rcx
	movl	%r9d, %r10d
	notq	%r8
	subl	%edi, %r10d
	movq	32(%rsp), %r11
	salq	$4, %r8
	negq	%rbx
	leaq	20008(%r12), %rax
	leaq	-8(%r14,%rdx,8), %r15
	addq	$20000, %r12
	movslq	%r10d, %r10
	movq	%rax, 16(%rsp)
	leaq	20000+Z(%rip), %rax
	leaq	(%rax,%rcx,8), %rax
	movq	%rax, 24(%rsp)
	.p2align 4,,10
	.p2align 3
.L6:
	leal	1(%rsi), %eax
	testb	%bpl, %bpl
	je	.L33
	leaq	(%r12,%r11), %rcx
	leaq	(%r15,%r11), %rdi
	xorl	%edx, %edx
	.p2align 4,,10
	.p2align 3
.L7:
	movdqu	(%rcx,%rdx), %xmm0
	movdqu	(%rdi,%rdx), %xmm1
	shufpd	$1, %xmm0, %xmm0
	shufpd	$1, %xmm1, %xmm1
	paddq	%xmm1, %xmm0
	shufpd	$1, %xmm0, %xmm0
	movups	%xmm0, (%rcx,%rdx)
	subq	$16, %rdx
	cmpq	%r8, %rdx
	jne	.L7
	cmpl	4(%rsp), %r13d
	je	.L10
	cltq
	movslq	%esi, %rdx
	imulq	$2501, %rax, %rax
	imulq	$2501, %rdx, %rdx
	addq	%r9, %rax
	addq	%r10, %rdx
	movq	(%r14,%rdx,8), %rdx
	addq	%rdx, (%r14,%rax,8)
.L10:
	subl	$1, %esi
	subq	$20008, %r11
	cmpl	$-1, %esi
	jne	.L6
.L5:
	addq	$1, 8(%rsp)
	movq	8(%rsp), %rax
	addq	$20008, 32(%rsp)
	cmpq	40(%rsp), %rax
	jne	.L13
	movslq	68(%rsp), %rax
	cmpl	$1, %eax
	jne	.L34
	imulq	$20016, 56(%rsp), %rcx
	leaq	20016+Z(%rip), %rax
	leaq	20016(%rax), %rdx
	addq	%rdx, %rcx
	xorl	%edx, %edx
	.p2align 4,,10
	.p2align 3
.L17:
	addq	(%rax), %rdx
	addq	$20016, %rax
	cmpq	%rcx, %rax
	jne	.L17
.L18:
	xorl	%eax, %eax
	leaq	.LC2(%rip), %rsi
	movl	$1, %edi
	call	__printf_chk@PLT
	movq	72(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L35
	addq	$88, %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
	.p2align 4,,10
	.p2align 3
.L33:
	.cfi_restore_state
	movq	16(%rsp), %rax
	movq	24(%rsp), %rdi
	addq	%r11, %rax
	leaq	(%rdi,%r11), %rcx
	.p2align 4,,10
	.p2align 3
.L9:
	movq	-20008(%rax,%rbx,8), %rdx
	addq	%rdx, (%rax)
	subq	$8, %rax
	cmpq	%rcx, %rax
	jne	.L9
	jmp	.L10
.L34:
	leaq	20008(,%rax,8), %rdi
	movl	$1, %ecx
	xorl	%edx, %edx
	leaq	Z(%rip), %rax
	leaq	-20008(%rax,%rdi), %rsi
	movl	52(%rsp), %eax
	addl	$1, %eax
.L15:
	addl	$1, %ecx
	addq	20008(%rsi), %rdx
	addq	%rdi, %rsi
	cmpl	%eax, %ecx
	jne	.L15
	jmp	.L18
.L2:
	movq	$1, Z(%rip)
.L4:
	xorl	%edx, %edx
	jmp	.L18
.L35:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.globl	Z
	.bss
	.align 32
	.type	Z, @object
	.size	Z, 1020408
Z:
	.zero	1020408
	.globl	X
	.align 32
	.type	X, @object
	.size	X, 200
X:
	.zero	200
	.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 M 50
int X[M];long long Z[M+1][M*M+1];
int main(){
	int N,A,S=0;
	long long R=0;
	scanf("%d%d",&N,&A);
	for(int i=0;i<N;i++)scanf("%d",X+i);
	Z[0][0]=1;
	for(int i=0;i<N;i++){
		S+=X[i];
		for(int k=i;k>=0;k--)for(int j=S;j>=X[i];j--)Z[k+1][j]+=Z[k][j-X[i]];
	}
	for(int i=1;i<=N;i++)R+=Z[i][i*A];
	printf("%lld\n",R);
}
4 8
7 12 8 9
 3 8
9 6 9
 33 3
3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 1 3 3 3 3
 8 5
3 6 2 8 7 2 5 9
 3 8
15 6 9
 33 3
3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 1 3 3 3 3 3 3 3 3 3 3 3 1 3 3 3 3
 8 5
3 6 2 8 7 2 5 16
 33 3
3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 1 0 3 3 3 3 3 3 3 3 3 3 1 3 3 3 3
 8 5
3 6 2 8 3 2 5 16
 8 8
3 6 2 8 3 2 5 16

3
 1
 4294967295
 25
 0
 2147483647
 17
 1073741823
 7
 9

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 M 50
int X[M];long long Z[M+1][M*M+1];
int main(){
	int N,A,S=0;
	long long R=0;
	scanf("%d%d",&N,&A);
	for(int i=0;i<N;i++)scanf("%d",X+i);
	Z[0][0]=1;
	for(int i=0;i<N;i++){
		S+=X[i];
		for(int k=i;k>=0;k--)for(int j=S;j>=X[i];j--)Z[k+1][j]+=Z[k][j-X[i]];
	}
	for(int i=1;i<=N;i++)R+=Z[i][i*A];
	printf("%lld\n",R);
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	X
	.bss
	.align 32
	.type	X, @object
	.size	X, 200
X:
	.zero	200
	.globl	Z
	.align 32
	.type	Z, @object
	.size	Z, 1020408
Z:
	.zero	1020408
	.section	.rodata
.LC0:
	.string	"%d%d"
.LC1:
	.string	"%d"
.LC2:
	.string	"%lld\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	$48, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -40(%rbp)
	movq	$0, -16(%rbp)
	leaq	-44(%rbp), %rdx
	leaq	-48(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -36(%rbp)
	jmp	.L2
.L3:
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	X(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -36(%rbp)
.L2:
	movl	-48(%rbp), %eax
	cmpl	%eax, -36(%rbp)
	jl	.L3
	movq	$1, Z(%rip)
	movl	$0, -32(%rbp)
	jmp	.L4
.L9:
	movl	-32(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	X(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%eax, -40(%rbp)
	movl	-32(%rbp), %eax
	movl	%eax, -28(%rbp)
	jmp	.L5
.L8:
	movl	-40(%rbp), %eax
	movl	%eax, -24(%rbp)
	jmp	.L6
.L7:
	movl	-28(%rbp), %eax
	leal	1(%rax), %edx
	movl	-24(%rbp), %eax
	movslq	%eax, %rcx
	movslq	%edx, %rax
	imulq	$2501, %rax, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,8), %rdx
	leaq	Z(%rip), %rax
	movq	(%rdx,%rax), %rsi
	movl	-32(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	X(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-24(%rbp), %eax
	subl	%edx, %eax
	movslq	%eax, %rdx
	movl	-28(%rbp), %eax
	cltq
	imulq	$2501, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rdx
	leaq	Z(%rip), %rax
	movq	(%rdx,%rax), %rcx
	movl	-28(%rbp), %eax
	leal	1(%rax), %edx
	addq	%rsi, %rcx
	movl	-24(%rbp), %eax
	movslq	%eax, %rsi
	movslq	%edx, %rax
	imulq	$2501, %rax, %rax
	addq	%rsi, %rax
	leaq	0(,%rax,8), %rdx
	leaq	Z(%rip), %rax
	movq	%rcx, (%rdx,%rax)
	subl	$1, -24(%rbp)
.L6:
	movl	-32(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	X(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -24(%rbp)
	jge	.L7
	subl	$1, -28(%rbp)
.L5:
	cmpl	$0, -28(%rbp)
	jns	.L8
	addl	$1, -32(%rbp)
.L4:
	movl	-48(%rbp), %eax
	cmpl	%eax, -32(%rbp)
	jl	.L9
	movl	$1, -20(%rbp)
	jmp	.L10
.L11:
	movl	-44(%rbp), %eax
	imull	-20(%rbp), %eax
	movslq	%eax, %rdx
	movl	-20(%rbp), %eax
	cltq
	imulq	$2501, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rdx
	leaq	Z(%rip), %rax
	movq	(%rdx,%rax), %rax
	addq	%rax, -16(%rbp)
	addl	$1, -20(%rbp)
.L10:
	movl	-48(%rbp), %eax
	cmpl	%eax, -20(%rbp)
	jle	.L11
	movq	-16(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L13
	call	__stack_chk_fail@PLT
.L13:
	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
	.globl	X
	.bss
	.align 32
	.type	X, @object
	.size	X, 200
X:
	.zero	200
	.globl	Z
	.align 32
	.type	Z, @object
	.size	Z, 1020408
Z:
	.zero	1020408
	.section	.rodata
.LC0:
	.string	"%d%d"
.LC1:
	.string	"%d"
.LC2:
	.string	"%lld\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	$48, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -40(%rbp)
	movq	$0, -16(%rbp)
	leaq	-44(%rbp), %rdx
	leaq	-48(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -36(%rbp)
	jmp	.L2
.L3:
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	X(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -36(%rbp)
.L2:
	movl	-48(%rbp), %eax
	cmpl	%eax, -36(%rbp)
	jl	.L3
	movq	$1, Z(%rip)
	movl	$0, -32(%rbp)
	jmp	.L4
.L9:
	movl	-32(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	X(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%eax, -40(%rbp)
	movl	-32(%rbp), %eax
	movl	%eax, -28(%rbp)
	jmp	.L5
.L8:
	movl	-40(%rbp), %eax
	movl	%eax, -24(%rbp)
	jmp	.L6
.L7:
	movl	-28(%rbp), %eax
	leal	1(%rax), %edx
	movl	-24(%rbp), %eax
	movslq	%eax, %rcx
	movslq	%edx, %rax
	imulq	$2501, %rax, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,8), %rdx
	leaq	Z(%rip), %rax
	movq	(%rdx,%rax), %rsi
	movl	-32(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	X(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-24(%rbp), %eax
	subl	%edx, %eax
	movslq	%eax, %rdx
	movl	-28(%rbp), %eax
	cltq
	imulq	$2501, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rdx
	leaq	Z(%rip), %rax
	movq	(%rdx,%rax), %rcx
	movl	-28(%rbp), %eax
	leal	1(%rax), %edx
	addq	%rsi, %rcx
	movl	-24(%rbp), %eax
	movslq	%eax, %rsi
	movslq	%edx, %rax
	imulq	$2501, %rax, %rax
	addq	%rsi, %rax
	leaq	0(,%rax,8), %rdx
	leaq	Z(%rip), %rax
	movq	%rcx, (%rdx,%rax)
	subl	$1, -24(%rbp)
.L6:
	movl	-32(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	X(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -24(%rbp)
	jge	.L7
	subl	$1, -28(%rbp)
.L5:
	cmpl	$0, -28(%rbp)
	jns	.L8
	addl	$1, -32(%rbp)
.L4:
	movl	-48(%rbp), %eax
	cmpl	%eax, -32(%rbp)
	jl	.L9
	movl	$1, -20(%rbp)
	jmp	.L10
.L11:
	movl	-44(%rbp), %eax
	imull	-20(%rbp), %eax
	movslq	%eax, %rdx
	movl	-20(%rbp), %eax
	cltq
	imulq	$2501, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rdx
	leaq	Z(%rip), %rax
	movq	(%rdx,%rax), %rax
	addq	%rax, -16(%rbp)
	addl	$1, -20(%rbp)
.L10:
	movl	-48(%rbp), %eax
	cmpl	%eax, -20(%rbp)
	jle	.L11
	movq	-16(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L13
	call	__stack_chk_fail@PLT
.L13:
	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:
