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 n,m;
int c[20],array[50001];
void bubblesort(void);
void survey(int,int *);

int main(void){
    int i,v;
    scanf("%d%d",&n,&m);
    for(i = 0;i < m;i++){
        scanf("%d",&c[i]);
    }
    array[0] = 0;
    bubblesort();
    v = 0;
    for(i = 1;i < n + 1;i++){
        survey(i,&v);
    }
    printf("%d\n",array[n]);
    return 0;
}

void bubblesort(void){
    int i,j,k;
    for(i = m;i > 1;i--){
        for(j = 1;j < i;j++){
            if(c[j - 1] > c[j]){
                k = c[j]; c[j] = c[j - 1]; c[j - 1] = k;
            }
        }
    }
    return;
}

void survey(int p, int *q){
    int i,reply;
    if(p >= c[*q + 1] && *q < m - 1){
        (*q)++;
    }
    reply = 50002;
    for(i = 0;i < *q + 1;i++){
        if(reply > array[p - c[i]] + 1){
            reply = array[p - c[i]] + 1;
        }
    }
    array[p] = reply;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	n
	.bss
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	m
	.align 4
	.type	m, @object
	.size	m, 4
m:
	.zero	4
	.globl	c
	.align 32
	.type	c, @object
	.size	c, 80
c:
	.zero	80
	.globl	array
	.align 32
	.type	array, @object
	.size	array, 200004
array:
	.zero	200004
	.section	.rodata
.LC0:
	.string	"%d%d"
.LC1:
	.string	"%d"
.LC2:
	.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	$16, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	m(%rip), %rax
	movq	%rax, %rdx
	leaq	n(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -12(%rbp)
	jmp	.L2
.L3:
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	c(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -12(%rbp)
.L2:
	movl	m(%rip), %eax
	cmpl	%eax, -12(%rbp)
	jl	.L3
	movl	$0, array(%rip)
	call	bubblesort
	movl	$0, -16(%rbp)
	movl	$1, -12(%rbp)
	jmp	.L4
.L5:
	leaq	-16(%rbp), %rdx
	movl	-12(%rbp), %eax
	movq	%rdx, %rsi
	movl	%eax, %edi
	call	survey
	addl	$1, -12(%rbp)
.L4:
	movl	n(%rip), %eax
	cmpl	%eax, -12(%rbp)
	jle	.L5
	movl	n(%rip), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	array(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, %esi
	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	.L7
	call	__stack_chk_fail@PLT
.L7:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.globl	bubblesort
	.type	bubblesort, @function
bubblesort:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	m(%rip), %eax
	movl	%eax, -12(%rbp)
	jmp	.L9
.L13:
	movl	$1, -8(%rbp)
	jmp	.L10
.L12:
	movl	-8(%rbp), %eax
	subl	$1, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	c(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	c(%rip), %rax
	movl	(%rcx,%rax), %eax
	cmpl	%eax, %edx
	jle	.L11
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	c(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -4(%rbp)
	movl	-8(%rbp), %eax
	subl	$1, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	c(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-8(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	c(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movl	-8(%rbp), %eax
	subl	$1, %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	c(%rip), %rdx
	movl	-4(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
.L11:
	addl	$1, -8(%rbp)
.L10:
	movl	-8(%rbp), %eax
	cmpl	-12(%rbp), %eax
	jl	.L12
	subl	$1, -12(%rbp)
.L9:
	cmpl	$1, -12(%rbp)
	jg	.L13
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	bubblesort, .-bubblesort
	.globl	survey
	.type	survey, @function
survey:
.LFB2:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -20(%rbp)
	movq	%rsi, -32(%rbp)
	movq	-32(%rbp), %rax
	movl	(%rax), %eax
	addl	$1, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	c(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -20(%rbp)
	jl	.L16
	movq	-32(%rbp), %rax
	movl	(%rax), %eax
	movl	m(%rip), %edx
	subl	$1, %edx
	cmpl	%edx, %eax
	jge	.L16
	movq	-32(%rbp), %rax
	movl	(%rax), %eax
	leal	1(%rax), %edx
	movq	-32(%rbp), %rax
	movl	%edx, (%rax)
.L16:
	movl	$50002, -4(%rbp)
	movl	$0, -8(%rbp)
	jmp	.L17
.L19:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	c(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-20(%rbp), %eax
	subl	%edx, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	array(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	$1, %eax
	cmpl	%eax, -4(%rbp)
	jle	.L18
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	c(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-20(%rbp), %eax
	subl	%edx, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	array(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	$1, %eax
	movl	%eax, -4(%rbp)
.L18:
	addl	$1, -8(%rbp)
.L17:
	movq	-32(%rbp), %rax
	movl	(%rax), %eax
	cmpl	%eax, -8(%rbp)
	jle	.L19
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	array(%rip), %rdx
	movl	-4(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2:
	.size	survey, .-survey
	.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	bubblesort
	.type	bubblesort, @function
bubblesort:
.LFB24:
	.cfi_startproc
	endbr64
	movl	m(%rip), %edi
	cmpl	$1, %edi
	jle	.L1
	.p2align 4,,10
	.p2align 3
.L5:
	leaq	c(%rip), %rdx
	movl	$1, %ecx
	.p2align 4,,10
	.p2align 3
.L4:
	movq	(%rdx), %xmm0
	pshufd	$0xe5, %xmm0, %xmm2
	movd	%xmm0, %esi
	movd	%xmm2, %eax
	pshufd	$225, %xmm0, %xmm1
	cmpl	%eax, %esi
	jle	.L3
	movq	%xmm1, (%rdx)
.L3:
	addl	$1, %ecx
	addq	$4, %rdx
	cmpl	%ecx, %edi
	jg	.L4
	subl	$1, %edi
	cmpl	$1, %edi
	jne	.L5
.L1:
	ret
	.cfi_endproc
.LFE24:
	.size	bubblesort, .-bubblesort
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d%d"
.LC1:
	.string	"%d"
.LC2:
	.string	"%d\n"
	.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	m(%rip), %rdx
	leaq	n(%rip), %rsi
	xorl	%eax, %eax
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	leaq	.LC0(%rip), %rdi
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	subq	$8, %rsp
	.cfi_def_cfa_offset 48
	call	__isoc99_scanf@PLT
	movl	m(%rip), %eax
	testl	%eax, %eax
	jle	.L10
	leaq	c(%rip), %rbp
	xorl	%ebx, %ebx
	leaq	.LC1(%rip), %r12
	.p2align 4,,10
	.p2align 3
.L11:
	movq	%rbp, %rsi
	xorl	%eax, %eax
	movq	%r12, %rdi
	addl	$1, %ebx
	call	__isoc99_scanf@PLT
	addq	$4, %rbp
	cmpl	%ebx, m(%rip)
	jg	.L11
.L10:
	movl	$0, array(%rip)
	call	bubblesort
	movslq	n(%rip), %r13
	leaq	array(%rip), %rsi
	testl	%r13d, %r13d
	jle	.L12
	movl	m(%rip), %eax
	leaq	c(%rip), %rbx
	leal	1(%r13), %ebp
	xorl	%r10d, %r10d
	movl	$1, %r9d
	leaq	4(%rbx), %r11
	leal	-1(%rax), %r12d
	.p2align 4,,10
	.p2align 3
.L15:
	leal	1(%r10), %eax
	movl	%r9d, %r8d
	movslq	%eax, %rdx
	cmpl	%r9d, (%rbx,%rdx,4)
	jg	.L13
	cmpl	%r10d, %r12d
	cmovg	%eax, %r10d
.L13:
	movslq	%r10d, %rax
	leaq	c(%rip), %rdx
	movl	$50002, %ecx
	leaq	(%r11,%rax,4), %rdi
	.p2align 4,,10
	.p2align 3
.L14:
	movl	%r8d, %eax
	subl	(%rdx), %eax
	cltq
	movl	(%rsi,%rax,4), %eax
	addl	$1, %eax
	cmpl	%eax, %ecx
	cmovg	%eax, %ecx
	addq	$4, %rdx
	cmpq	%rdx, %rdi
	jne	.L14
	movl	%ecx, (%rsi,%r9,4)
	addq	$1, %r9
	cmpq	%r9, %rbp
	jne	.L15
.L12:
	movl	(%rsi,%r13,4), %edx
	movl	$1, %edi
	xorl	%eax, %eax
	leaq	.LC2(%rip), %rsi
	call	__printf_chk@PLT
	addq	$8, %rsp
	.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
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.text
	.p2align 4
	.globl	survey
	.type	survey, @function
survey:
.LFB25:
	.cfi_startproc
	endbr64
	movslq	(%rsi), %rax
	leaq	c(%rip), %rcx
	leal	1(%rax), %edx
	movslq	%edx, %r8
	cmpl	%edi, (%rcx,%r8,4)
	jg	.L22
	movl	m(%rip), %ecx
	subl	$1, %ecx
	cmpl	%ecx, %eax
	jl	.L27
.L22:
	testl	%eax, %eax
	js	.L25
.L28:
	leaq	c(%rip), %rdx
	leaq	array(%rip), %rsi
	leaq	4(%rdx), %rcx
	leaq	(%rcx,%rax,4), %r8
	movl	$50002, %ecx
	.p2align 4,,10
	.p2align 3
.L24:
	movl	%edi, %eax
	subl	(%rdx), %eax
	cltq
	movl	(%rsi,%rax,4), %eax
	addl	$1, %eax
	cmpl	%eax, %ecx
	cmovg	%eax, %ecx
	addq	$4, %rdx
	cmpq	%rdx, %r8
	jne	.L24
	movslq	%edi, %rdi
	movl	%ecx, (%rsi,%rdi,4)
	ret
	.p2align 4,,10
	.p2align 3
.L27:
	movslq	%edx, %rax
	movl	%edx, (%rsi)
	testl	%eax, %eax
	jns	.L28
.L25:
	movl	$50002, %ecx
	leaq	array(%rip), %rsi
	movslq	%edi, %rdi
	movl	%ecx, (%rsi,%rdi,4)
	ret
	.cfi_endproc
.LFE25:
	.size	survey, .-survey
	.globl	array
	.bss
	.align 32
	.type	array, @object
	.size	array, 200004
array:
	.zero	200004
	.globl	c
	.align 32
	.type	c, @object
	.size	c, 80
c:
	.zero	80
	.globl	m
	.align 4
	.type	m, @object
	.size	m, 4
m:
	.zero	4
	.globl	n
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.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	bubblesort
	.type	bubblesort, @function
bubblesort:
.LFB24:
	.cfi_startproc
	endbr64
	movl	m(%rip), %edi
	cmpl	$1, %edi
	jle	.L1
	.p2align 4,,10
	.p2align 3
.L5:
	leaq	c(%rip), %rdx
	movl	$1, %ecx
	.p2align 4,,10
	.p2align 3
.L4:
	movq	(%rdx), %xmm0
	pshufd	$0xe5, %xmm0, %xmm2
	movd	%xmm0, %esi
	movd	%xmm2, %eax
	pshufd	$225, %xmm0, %xmm1
	cmpl	%eax, %esi
	jle	.L3
	movq	%xmm1, (%rdx)
.L3:
	addl	$1, %ecx
	addq	$4, %rdx
	cmpl	%ecx, %edi
	jg	.L4
	subl	$1, %edi
	cmpl	$1, %edi
	jne	.L5
.L1:
	ret
	.cfi_endproc
.LFE24:
	.size	bubblesort, .-bubblesort
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d%d"
.LC1:
	.string	"%d"
.LC2:
	.string	"%d\n"
	.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	m(%rip), %rdx
	leaq	n(%rip), %rsi
	xorl	%eax, %eax
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	leaq	.LC0(%rip), %rdi
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	subq	$8, %rsp
	.cfi_def_cfa_offset 48
	call	__isoc99_scanf@PLT
	movl	m(%rip), %eax
	testl	%eax, %eax
	jle	.L10
	leaq	c(%rip), %rbp
	xorl	%ebx, %ebx
	leaq	.LC1(%rip), %r12
	.p2align 4,,10
	.p2align 3
.L11:
	movq	%rbp, %rsi
	xorl	%eax, %eax
	movq	%r12, %rdi
	addl	$1, %ebx
	call	__isoc99_scanf@PLT
	addq	$4, %rbp
	cmpl	%ebx, m(%rip)
	jg	.L11
.L10:
	movl	$0, array(%rip)
	call	bubblesort
	movslq	n(%rip), %r13
	leaq	array(%rip), %rsi
	testl	%r13d, %r13d
	jle	.L12
	movl	m(%rip), %eax
	leaq	c(%rip), %rbx
	leal	1(%r13), %ebp
	xorl	%r10d, %r10d
	movl	$1, %r9d
	leaq	4(%rbx), %r11
	leal	-1(%rax), %r12d
	.p2align 4,,10
	.p2align 3
.L15:
	leal	1(%r10), %eax
	movl	%r9d, %r8d
	movslq	%eax, %rdx
	cmpl	%r9d, (%rbx,%rdx,4)
	jg	.L13
	cmpl	%r10d, %r12d
	cmovg	%eax, %r10d
.L13:
	movslq	%r10d, %rax
	leaq	c(%rip), %rdx
	movl	$50002, %ecx
	leaq	(%r11,%rax,4), %rdi
	.p2align 4,,10
	.p2align 3
.L14:
	movl	%r8d, %eax
	subl	(%rdx), %eax
	cltq
	movl	(%rsi,%rax,4), %eax
	addl	$1, %eax
	cmpl	%eax, %ecx
	cmovg	%eax, %ecx
	addq	$4, %rdx
	cmpq	%rdx, %rdi
	jne	.L14
	movl	%ecx, (%rsi,%r9,4)
	addq	$1, %r9
	cmpq	%r9, %rbp
	jne	.L15
.L12:
	movl	(%rsi,%r13,4), %edx
	movl	$1, %edi
	xorl	%eax, %eax
	leaq	.LC2(%rip), %rsi
	call	__printf_chk@PLT
	addq	$8, %rsp
	.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
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.text
	.p2align 4
	.globl	survey
	.type	survey, @function
survey:
.LFB25:
	.cfi_startproc
	endbr64
	movslq	(%rsi), %rax
	leaq	c(%rip), %rcx
	leal	1(%rax), %edx
	movslq	%edx, %r8
	cmpl	%edi, (%rcx,%r8,4)
	jg	.L22
	movl	m(%rip), %ecx
	subl	$1, %ecx
	cmpl	%ecx, %eax
	jl	.L27
.L22:
	testl	%eax, %eax
	js	.L25
.L28:
	leaq	c(%rip), %rdx
	leaq	array(%rip), %rsi
	leaq	4(%rdx), %rcx
	leaq	(%rcx,%rax,4), %r8
	movl	$50002, %ecx
	.p2align 4,,10
	.p2align 3
.L24:
	movl	%edi, %eax
	subl	(%rdx), %eax
	cltq
	movl	(%rsi,%rax,4), %eax
	addl	$1, %eax
	cmpl	%eax, %ecx
	cmovg	%eax, %ecx
	addq	$4, %rdx
	cmpq	%rdx, %r8
	jne	.L24
	movslq	%edi, %rdi
	movl	%ecx, (%rsi,%rdi,4)
	ret
	.p2align 4,,10
	.p2align 3
.L27:
	movslq	%edx, %rax
	movl	%edx, (%rsi)
	testl	%eax, %eax
	jns	.L28
.L25:
	movl	$50002, %ecx
	leaq	array(%rip), %rsi
	movslq	%edi, %rdi
	movl	%ecx, (%rsi,%rdi,4)
	ret
	.cfi_endproc
.LFE25:
	.size	survey, .-survey
	.globl	array
	.bss
	.align 32
	.type	array, @object
	.size	array, 200004
array:
	.zero	200004
	.globl	c
	.align 32
	.type	c, @object
	.size	c, 80
c:
	.zero	80
	.globl	m
	.align 4
	.type	m, @object
	.size	m, 4
m:
	.zero	4
	.globl	n
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.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 n,m;
int c[20],array[50001];
void bubblesort(void);
void survey(int,int *);

int main(void){
    int i,v;
    scanf("%d%d",&n,&m);
    for(i = 0;i < m;i++){
        scanf("%d",&c[i]);
    }
    array[0] = 0;
    bubblesort();
    v = 0;
    for(i = 1;i < n + 1;i++){
        survey(i,&v);
    }
    printf("%d\n",array[n]);
    return 0;
}

void bubblesort(void){
    int i,j,k;
    for(i = m;i > 1;i--){
        for(j = 1;j < i;j++){
            if(c[j - 1] > c[j]){
                k = c[j]; c[j] = c[j - 1]; c[j - 1] = k;
            }
        }
    }
    return;
}

void survey(int p, int *q){
    int i,reply;
    if(p >= c[*q + 1] && *q < m - 1){
        (*q)++;
    }
    reply = 50002;
    for(i = 0;i < *q + 1;i++){
        if(reply > array[p - c[i]] + 1){
            reply = array[p - c[i]] + 1;
        }
    }
    array[p] = reply;
}
55 4
1 5 10 50

2

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 n,m;
int c[20],array[50001];
void bubblesort(void);
void survey(int,int *);

int main(void){
    int i,v;
    scanf("%d%d",&n,&m);
    for(i = 0;i < m;i++){
        scanf("%d",&c[i]);
    }
    array[0] = 0;
    bubblesort();
    v = 0;
    for(i = 1;i < n + 1;i++){
        survey(i,&v);
    }
    printf("%d\n",array[n]);
    return 0;
}

void bubblesort(void){
    int i,j,k;
    for(i = m;i > 1;i--){
        for(j = 1;j < i;j++){
            if(c[j - 1] > c[j]){
                k = c[j]; c[j] = c[j - 1]; c[j - 1] = k;
            }
        }
    }
    return;
}

void survey(int p, int *q){
    int i,reply;
    if(p >= c[*q + 1] && *q < m - 1){
        (*q)++;
    }
    reply = 50002;
    for(i = 0;i < *q + 1;i++){
        if(reply > array[p - c[i]] + 1){
            reply = array[p - c[i]] + 1;
        }
    }
    array[p] = reply;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	n
	.bss
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	m
	.align 4
	.type	m, @object
	.size	m, 4
m:
	.zero	4
	.globl	c
	.align 32
	.type	c, @object
	.size	c, 80
c:
	.zero	80
	.globl	array
	.align 32
	.type	array, @object
	.size	array, 200004
array:
	.zero	200004
	.section	.rodata
.LC0:
	.string	"%d%d"
.LC1:
	.string	"%d"
.LC2:
	.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	$16, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	m(%rip), %rax
	movq	%rax, %rdx
	leaq	n(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -12(%rbp)
	jmp	.L2
.L3:
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	c(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -12(%rbp)
.L2:
	movl	m(%rip), %eax
	cmpl	%eax, -12(%rbp)
	jl	.L3
	movl	$0, array(%rip)
	call	bubblesort
	movl	$0, -16(%rbp)
	movl	$1, -12(%rbp)
	jmp	.L4
.L5:
	leaq	-16(%rbp), %rdx
	movl	-12(%rbp), %eax
	movq	%rdx, %rsi
	movl	%eax, %edi
	call	survey
	addl	$1, -12(%rbp)
.L4:
	movl	n(%rip), %eax
	cmpl	%eax, -12(%rbp)
	jle	.L5
	movl	n(%rip), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	array(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, %esi
	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	.L7
	call	__stack_chk_fail@PLT
.L7:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.globl	bubblesort
	.type	bubblesort, @function
bubblesort:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	m(%rip), %eax
	movl	%eax, -12(%rbp)
	jmp	.L9
.L13:
	movl	$1, -8(%rbp)
	jmp	.L10
.L12:
	movl	-8(%rbp), %eax
	subl	$1, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	c(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	c(%rip), %rax
	movl	(%rcx,%rax), %eax
	cmpl	%eax, %edx
	jle	.L11
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	c(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -4(%rbp)
	movl	-8(%rbp), %eax
	subl	$1, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	c(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-8(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	c(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movl	-8(%rbp), %eax
	subl	$1, %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	c(%rip), %rdx
	movl	-4(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
.L11:
	addl	$1, -8(%rbp)
.L10:
	movl	-8(%rbp), %eax
	cmpl	-12(%rbp), %eax
	jl	.L12
	subl	$1, -12(%rbp)
.L9:
	cmpl	$1, -12(%rbp)
	jg	.L13
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	bubblesort, .-bubblesort
	.globl	survey
	.type	survey, @function
survey:
.LFB2:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -20(%rbp)
	movq	%rsi, -32(%rbp)
	movq	-32(%rbp), %rax
	movl	(%rax), %eax
	addl	$1, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	c(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -20(%rbp)
	jl	.L16
	movq	-32(%rbp), %rax
	movl	(%rax), %eax
	movl	m(%rip), %edx
	subl	$1, %edx
	cmpl	%edx, %eax
	jge	.L16
	movq	-32(%rbp), %rax
	movl	(%rax), %eax
	leal	1(%rax), %edx
	movq	-32(%rbp), %rax
	movl	%edx, (%rax)
.L16:
	movl	$50002, -4(%rbp)
	movl	$0, -8(%rbp)
	jmp	.L17
.L19:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	c(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-20(%rbp), %eax
	subl	%edx, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	array(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	$1, %eax
	cmpl	%eax, -4(%rbp)
	jle	.L18
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	c(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-20(%rbp), %eax
	subl	%edx, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	array(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	$1, %eax
	movl	%eax, -4(%rbp)
.L18:
	addl	$1, -8(%rbp)
.L17:
	movq	-32(%rbp), %rax
	movl	(%rax), %eax
	cmpl	%eax, -8(%rbp)
	jle	.L19
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	array(%rip), %rdx
	movl	-4(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2:
	.size	survey, .-survey
	.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	n
	.bss
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	m
	.align 4
	.type	m, @object
	.size	m, 4
m:
	.zero	4
	.globl	c
	.align 32
	.type	c, @object
	.size	c, 80
c:
	.zero	80
	.globl	array
	.align 32
	.type	array, @object
	.size	array, 200004
array:
	.zero	200004
	.section	.rodata
.LC0:
	.string	"%d%d"
.LC1:
	.string	"%d"
.LC2:
	.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	$16, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	m(%rip), %rax
	movq	%rax, %rdx
	leaq	n(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -12(%rbp)
	jmp	.L2
.L3:
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	c(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -12(%rbp)
.L2:
	movl	m(%rip), %eax
	cmpl	%eax, -12(%rbp)
	jl	.L3
	movl	$0, array(%rip)
	call	bubblesort
	movl	$0, -16(%rbp)
	movl	$1, -12(%rbp)
	jmp	.L4
.L5:
	leaq	-16(%rbp), %rdx
	movl	-12(%rbp), %eax
	movq	%rdx, %rsi
	movl	%eax, %edi
	call	survey
	addl	$1, -12(%rbp)
.L4:
	movl	n(%rip), %eax
	cmpl	%eax, -12(%rbp)
	jle	.L5
	movl	n(%rip), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	array(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, %esi
	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	.L7
	call	__stack_chk_fail@PLT
.L7:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.globl	bubblesort
	.type	bubblesort, @function
bubblesort:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	m(%rip), %eax
	movl	%eax, -12(%rbp)
	jmp	.L9
.L13:
	movl	$1, -8(%rbp)
	jmp	.L10
.L12:
	movl	-8(%rbp), %eax
	subl	$1, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	c(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	c(%rip), %rax
	movl	(%rcx,%rax), %eax
	cmpl	%eax, %edx
	jle	.L11
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	c(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -4(%rbp)
	movl	-8(%rbp), %eax
	subl	$1, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	c(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-8(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	c(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movl	-8(%rbp), %eax
	subl	$1, %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	c(%rip), %rdx
	movl	-4(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
.L11:
	addl	$1, -8(%rbp)
.L10:
	movl	-8(%rbp), %eax
	cmpl	-12(%rbp), %eax
	jl	.L12
	subl	$1, -12(%rbp)
.L9:
	cmpl	$1, -12(%rbp)
	jg	.L13
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	bubblesort, .-bubblesort
	.globl	survey
	.type	survey, @function
survey:
.LFB2:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -20(%rbp)
	movq	%rsi, -32(%rbp)
	movq	-32(%rbp), %rax
	movl	(%rax), %eax
	addl	$1, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	c(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -20(%rbp)
	jl	.L16
	movq	-32(%rbp), %rax
	movl	(%rax), %eax
	movl	m(%rip), %edx
	subl	$1, %edx
	cmpl	%edx, %eax
	jge	.L16
	movq	-32(%rbp), %rax
	movl	(%rax), %eax
	leal	1(%rax), %edx
	movq	-32(%rbp), %rax
	movl	%edx, (%rax)
.L16:
	movl	$50002, -4(%rbp)
	movl	$0, -8(%rbp)
	jmp	.L17
.L19:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	c(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-20(%rbp), %eax
	subl	%edx, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	array(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	$1, %eax
	cmpl	%eax, -4(%rbp)
	jle	.L18
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	c(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-20(%rbp), %eax
	subl	%edx, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	array(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	$1, %eax
	movl	%eax, -4(%rbp)
.L18:
	addl	$1, -8(%rbp)
.L17:
	movq	-32(%rbp), %rax
	movl	(%rax), %eax
	cmpl	%eax, -8(%rbp)
	jle	.L19
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	array(%rip), %rdx
	movl	-4(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2:
	.size	survey, .-survey
	.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:
