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 <stdlib.h>
int compare_int(const void *a, const void *b){
    return *(int*)a - *(int*)b;
}

int main(void){
    int n, x;
    int a[100+5];
    scanf("%d %d", &n, &x);
    for(int i=0; i<n; i++)scanf("%d", &a[i]);
    qsort(a, n, sizeof(int), compare_int);
    
    int ans=0;
    for(int i=0; i<n; i++){
        if(a[i]<=x){
            x-=a[i];
            ans++;
            if(i==n-1 && x!=0)ans--;
        }
    }
    
    printf("%d\n", ans);
    return 0;
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	compare_int
	.type	compare_int, @function
compare_int:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -8(%rbp)
	movq	%rsi, -16(%rbp)
	movq	-8(%rbp), %rax
	movl	(%rax), %edx
	movq	-16(%rbp), %rax
	movl	(%rax), %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	compare_int, .-compare_int
	.section	.rodata
.LC0:
	.string	"%d %d"
.LC1:
	.string	"%d"
.LC2:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$464, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-448(%rbp), %rdx
	leaq	-452(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -444(%rbp)
	jmp	.L4
.L5:
	leaq	-432(%rbp), %rdx
	movl	-444(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -444(%rbp)
.L4:
	movl	-452(%rbp), %eax
	cmpl	%eax, -444(%rbp)
	jl	.L5
	movl	-452(%rbp), %eax
	movslq	%eax, %rsi
	leaq	-432(%rbp), %rax
	leaq	compare_int(%rip), %rdx
	movq	%rdx, %rcx
	movl	$4, %edx
	movq	%rax, %rdi
	call	qsort@PLT
	movl	$0, -440(%rbp)
	movl	$0, -436(%rbp)
	jmp	.L6
.L8:
	movl	-436(%rbp), %eax
	cltq
	movl	-432(%rbp,%rax,4), %edx
	movl	-448(%rbp), %eax
	cmpl	%eax, %edx
	jg	.L7
	movl	-448(%rbp), %edx
	movl	-436(%rbp), %eax
	cltq
	movl	-432(%rbp,%rax,4), %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	movl	%eax, -448(%rbp)
	addl	$1, -440(%rbp)
	movl	-452(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -436(%rbp)
	jne	.L7
	movl	-448(%rbp), %eax
	testl	%eax, %eax
	je	.L7
	subl	$1, -440(%rbp)
.L7:
	addl	$1, -436(%rbp)
.L6:
	movl	-452(%rbp), %eax
	cmpl	%eax, -436(%rbp)
	jl	.L8
	movl	-440(%rbp), %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	.L10
	call	__stack_chk_fail@PLT
.L10:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.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	compare_int
	.type	compare_int, @function
compare_int:
.LFB39:
	.cfi_startproc
	endbr64
	movl	(%rdi), %eax
	subl	(%rsi), %eax
	ret
	.cfi_endproc
.LFE39:
	.size	compare_int, .-compare_int
	.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:
.LFB40:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	leaq	.LC0(%rip), %rdi
	leaq	.LC1(%rip), %r13
	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
	xorl	%ebx, %ebx
	subq	$456, %rsp
	.cfi_def_cfa_offset 496
	movq	%fs:40, %rax
	movq	%rax, 440(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rsi
	leaq	12(%rsp), %rdx
	leaq	16(%rsp), %r12
	movq	%r12, %rbp
	call	__isoc99_scanf@PLT
	movslq	8(%rsp), %rsi
	testl	%esi, %esi
	jle	.L4
	.p2align 4,,10
	.p2align 3
.L5:
	movq	%rbp, %rsi
	movq	%r13, %rdi
	xorl	%eax, %eax
	addl	$1, %ebx
	call	__isoc99_scanf@PLT
	movslq	8(%rsp), %rsi
	addq	$4, %rbp
	cmpl	%ebx, %esi
	jg	.L5
.L4:
	leaq	compare_int(%rip), %rcx
	movl	$4, %edx
	movq	%r12, %rdi
	call	qsort@PLT
	movl	8(%rsp), %r9d
	testl	%r9d, %r9d
	jle	.L11
	movl	12(%rsp), %ecx
	movslq	%r9d, %rdi
	xorl	%eax, %eax
	xorl	%esi, %esi
	xorl	%r8d, %r8d
	subl	$1, %r9d
	.p2align 4,,10
	.p2align 3
.L8:
	movl	(%r12,%rax,4), %edx
	cmpl	%edx, %ecx
	jl	.L7
	cmpl	%eax, %r9d
	leal	1(%r8), %r10d
	sete	%sil
	subl	%edx, %ecx
	setne	%dl
	andb	%dl, %sil
	jne	.L7
	movl	%r10d, %r8d
	movl	$1, %esi
.L7:
	addq	$1, %rax
	cmpq	%rax, %rdi
	jne	.L8
	testb	%sil, %sil
	je	.L6
	movl	%ecx, 12(%rsp)
.L6:
	xorl	%eax, %eax
	movl	%r8d, %edx
	movl	$1, %edi
	leaq	.LC2(%rip), %rsi
	call	__printf_chk@PLT
	movq	440(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L20
	addq	$456, %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
.L11:
	.cfi_restore_state
	xorl	%r8d, %r8d
	jmp	.L6
.L20:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE40:
	.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
	.p2align 4
	.globl	compare_int
	.type	compare_int, @function
compare_int:
.LFB39:
	.cfi_startproc
	endbr64
	movl	(%rdi), %eax
	subl	(%rsi), %eax
	ret
	.cfi_endproc
.LFE39:
	.size	compare_int, .-compare_int
	.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:
.LFB40:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	leaq	.LC0(%rip), %rdi
	leaq	.LC1(%rip), %r13
	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
	xorl	%ebx, %ebx
	subq	$456, %rsp
	.cfi_def_cfa_offset 496
	movq	%fs:40, %rax
	movq	%rax, 440(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rsi
	leaq	12(%rsp), %rdx
	leaq	16(%rsp), %r12
	movq	%r12, %rbp
	call	__isoc99_scanf@PLT
	movslq	8(%rsp), %rsi
	testl	%esi, %esi
	jle	.L4
	.p2align 4,,10
	.p2align 3
.L5:
	movq	%rbp, %rsi
	movq	%r13, %rdi
	xorl	%eax, %eax
	addl	$1, %ebx
	call	__isoc99_scanf@PLT
	movslq	8(%rsp), %rsi
	addq	$4, %rbp
	cmpl	%ebx, %esi
	jg	.L5
.L4:
	leaq	compare_int(%rip), %rcx
	movl	$4, %edx
	movq	%r12, %rdi
	call	qsort@PLT
	movl	8(%rsp), %r9d
	testl	%r9d, %r9d
	jle	.L11
	movl	12(%rsp), %ecx
	movslq	%r9d, %rdi
	xorl	%eax, %eax
	xorl	%esi, %esi
	xorl	%r8d, %r8d
	subl	$1, %r9d
	.p2align 4,,10
	.p2align 3
.L8:
	movl	(%r12,%rax,4), %edx
	cmpl	%edx, %ecx
	jl	.L7
	cmpl	%eax, %r9d
	leal	1(%r8), %r10d
	sete	%sil
	subl	%edx, %ecx
	setne	%dl
	andb	%dl, %sil
	jne	.L7
	movl	%r10d, %r8d
	movl	$1, %esi
.L7:
	addq	$1, %rax
	cmpq	%rax, %rdi
	jne	.L8
	testb	%sil, %sil
	je	.L6
	movl	%ecx, 12(%rsp)
.L6:
	xorl	%eax, %eax
	movl	%r8d, %edx
	movl	$1, %edi
	leaq	.LC2(%rip), %rsi
	call	__printf_chk@PLT
	movq	440(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L20
	addq	$456, %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
.L11:
	.cfi_restore_state
	xorl	%r8d, %r8d
	jmp	.L6
.L20:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE40:
	.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 <stdlib.h>
int compare_int(const void *a, const void *b){
    return *(int*)a - *(int*)b;
}

int main(void){
    int n, x;
    int a[100+5];
    scanf("%d %d", &n, &x);
    for(int i=0; i<n; i++)scanf("%d", &a[i]);
    qsort(a, n, sizeof(int), compare_int);
    
    int ans=0;
    for(int i=0; i<n; i++){
        if(a[i]<=x){
            x-=a[i];
            ans++;
            if(i==n-1 && x!=0)ans--;
        }
    }
    
    printf("%d\n", ans);
    return 0;
}

3 70
20 30 5
 3 10
20 18 10
 2 10
29 20
 4 1111
1 5 100 1000
 4 1111
-1 2 110 1000
 3 70
20 49 5
 3 10
20 9 10
 2 10
30 20
 3 70
4 49 5
 3 10
20 4 10

2
 1
 0
 3
 4
 2
 1
 0
 2
 1

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 <stdlib.h>
int compare_int(const void *a, const void *b){
    return *(int*)a - *(int*)b;
}

int main(void){
    int n, x;
    int a[100+5];
    scanf("%d %d", &n, &x);
    for(int i=0; i<n; i++)scanf("%d", &a[i]);
    qsort(a, n, sizeof(int), compare_int);
    
    int ans=0;
    for(int i=0; i<n; i++){
        if(a[i]<=x){
            x-=a[i];
            ans++;
            if(i==n-1 && x!=0)ans--;
        }
    }
    
    printf("%d\n", ans);
    return 0;
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	compare_int
	.type	compare_int, @function
compare_int:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -8(%rbp)
	movq	%rsi, -16(%rbp)
	movq	-8(%rbp), %rax
	movl	(%rax), %edx
	movq	-16(%rbp), %rax
	movl	(%rax), %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	compare_int, .-compare_int
	.section	.rodata
.LC0:
	.string	"%d %d"
.LC1:
	.string	"%d"
.LC2:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$464, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-448(%rbp), %rdx
	leaq	-452(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -444(%rbp)
	jmp	.L4
.L5:
	leaq	-432(%rbp), %rdx
	movl	-444(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -444(%rbp)
.L4:
	movl	-452(%rbp), %eax
	cmpl	%eax, -444(%rbp)
	jl	.L5
	movl	-452(%rbp), %eax
	movslq	%eax, %rsi
	leaq	-432(%rbp), %rax
	leaq	compare_int(%rip), %rdx
	movq	%rdx, %rcx
	movl	$4, %edx
	movq	%rax, %rdi
	call	qsort@PLT
	movl	$0, -440(%rbp)
	movl	$0, -436(%rbp)
	jmp	.L6
.L8:
	movl	-436(%rbp), %eax
	cltq
	movl	-432(%rbp,%rax,4), %edx
	movl	-448(%rbp), %eax
	cmpl	%eax, %edx
	jg	.L7
	movl	-448(%rbp), %edx
	movl	-436(%rbp), %eax
	cltq
	movl	-432(%rbp,%rax,4), %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	movl	%eax, -448(%rbp)
	addl	$1, -440(%rbp)
	movl	-452(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -436(%rbp)
	jne	.L7
	movl	-448(%rbp), %eax
	testl	%eax, %eax
	je	.L7
	subl	$1, -440(%rbp)
.L7:
	addl	$1, -436(%rbp)
.L6:
	movl	-452(%rbp), %eax
	cmpl	%eax, -436(%rbp)
	jl	.L8
	movl	-440(%rbp), %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	.L10
	call	__stack_chk_fail@PLT
.L10:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.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	compare_int
	.type	compare_int, @function
compare_int:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -8(%rbp)
	movq	%rsi, -16(%rbp)
	movq	-8(%rbp), %rax
	movl	(%rax), %edx
	movq	-16(%rbp), %rax
	movl	(%rax), %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	compare_int, .-compare_int
	.section	.rodata
.LC0:
	.string	"%d %d"
.LC1:
	.string	"%d"
.LC2:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$464, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-448(%rbp), %rdx
	leaq	-452(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -444(%rbp)
	jmp	.L4
.L5:
	leaq	-432(%rbp), %rdx
	movl	-444(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -444(%rbp)
.L4:
	movl	-452(%rbp), %eax
	cmpl	%eax, -444(%rbp)
	jl	.L5
	movl	-452(%rbp), %eax
	movslq	%eax, %rsi
	leaq	-432(%rbp), %rax
	leaq	compare_int(%rip), %rdx
	movq	%rdx, %rcx
	movl	$4, %edx
	movq	%rax, %rdi
	call	qsort@PLT
	movl	$0, -440(%rbp)
	movl	$0, -436(%rbp)
	jmp	.L6
.L8:
	movl	-436(%rbp), %eax
	cltq
	movl	-432(%rbp,%rax,4), %edx
	movl	-448(%rbp), %eax
	cmpl	%eax, %edx
	jg	.L7
	movl	-448(%rbp), %edx
	movl	-436(%rbp), %eax
	cltq
	movl	-432(%rbp,%rax,4), %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	movl	%eax, -448(%rbp)
	addl	$1, -440(%rbp)
	movl	-452(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -436(%rbp)
	jne	.L7
	movl	-448(%rbp), %eax
	testl	%eax, %eax
	je	.L7
	subl	$1, -440(%rbp)
.L7:
	addl	$1, -436(%rbp)
.L6:
	movl	-452(%rbp), %eax
	cmpl	%eax, -436(%rbp)
	jl	.L8
	movl	-440(%rbp), %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	.L10
	call	__stack_chk_fail@PLT
.L10:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.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:
