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 num(){
    char s[11];
    int i, n;
    for(i=0; i<sizeof(s); i++){
        s[i] = getchar();
        if(s[i] == ' ' || s[i] == '\n'){
            s[i] = '\0';
            break;
        }
    }
    sscanf(s, "%d", &n);
    return n;
}
void sort(int x[], int n){
    int y, i, j;
    for(i=n; i>1; i--){
        for(j=0; j<=i-2; j++){
            if(x[j] > x[j+1]){
                y = x[j];
                x[j] = x[j+1];
                x[j+1] = y;
            }
        }
    }
}
void sort2(int x[], int n){
    int y, i, j;
    for(i=n; i>1; i--){
        for(j=0; j<=i-2; j++){
            if(x[j] < x[j+1]){
                y = x[j];
                x[j] = x[j+1];
                x[j+1] = y;
            }
        }
    }
}
int main(void){
    int n, x;
    int a[100];
    int i, y, cou=0;
    
    n = num();
    x = num();
    for(i=0; i<n; i++){
        a[i] = num();
    }
    
    sort(a, n);
    
    for(i=0; i<n; i++){
        if(x >= a[i]){
            x -= a[i];
            cou++;
        }
    }
    
    sort2(a, n);
    
    if(cou == n){
        y = 1;
    }
    else{
        y = 0;
    }
    i=0;
    while(x > 0){
//        x -= a[i];
        if(y==1){
            cou--;
        }
        x -= a[i];
        if(x < 0){
            x *= -1;
        }
        if(a[i] >= x){
            break;
        }
        
    }
//    if(x < 0){
//        cou++;
//    }
    
    printf("%d\n", cou);
    
    return 0;
    
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d"
	.text
	.globl	num
	.type	num, @function
num:
.LFB6:
	.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
	movl	$0, -24(%rbp)
	jmp	.L2
.L6:
	call	getchar@PLT
	movl	%eax, %edx
	movl	-24(%rbp), %eax
	cltq
	movb	%dl, -19(%rbp,%rax)
	movl	-24(%rbp), %eax
	cltq
	movzbl	-19(%rbp,%rax), %eax
	cmpb	$32, %al
	je	.L3
	movl	-24(%rbp), %eax
	cltq
	movzbl	-19(%rbp,%rax), %eax
	cmpb	$10, %al
	jne	.L4
.L3:
	movl	-24(%rbp), %eax
	cltq
	movb	$0, -19(%rbp,%rax)
	jmp	.L5
.L4:
	addl	$1, -24(%rbp)
.L2:
	movl	-24(%rbp), %eax
	cmpl	$10, %eax
	jbe	.L6
.L5:
	leaq	-28(%rbp), %rdx
	leaq	-19(%rbp), %rax
	leaq	.LC0(%rip), %rcx
	movq	%rcx, %rsi
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_sscanf@PLT
	movl	-28(%rbp), %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
.LFE6:
	.size	num, .-num
	.globl	sort
	.type	sort, @function
sort:
.LFB7:
	.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	-28(%rbp), %eax
	movl	%eax, -12(%rbp)
	jmp	.L10
.L14:
	movl	$0, -8(%rbp)
	jmp	.L11
.L13:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movl	-8(%rbp), %eax
	cltq
	addq	$1, %rax
	leaq	0(,%rax,4), %rcx
	movq	-24(%rbp), %rax
	addq	%rcx, %rax
	movl	(%rax), %eax
	cmpl	%eax, %edx
	jle	.L12
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, -4(%rbp)
	movl	-8(%rbp), %eax
	cltq
	addq	$1, %rax
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	-8(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	movq	-24(%rbp), %rdx
	addq	%rcx, %rdx
	movl	(%rax), %eax
	movl	%eax, (%rdx)
	movl	-8(%rbp), %eax
	cltq
	addq	$1, %rax
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rax, %rdx
	movl	-4(%rbp), %eax
	movl	%eax, (%rdx)
.L12:
	addl	$1, -8(%rbp)
.L11:
	movl	-12(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -8(%rbp)
	jl	.L13
	subl	$1, -12(%rbp)
.L10:
	cmpl	$1, -12(%rbp)
	jg	.L14
	nop
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	sort, .-sort
	.globl	sort2
	.type	sort2, @function
sort2:
.LFB8:
	.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	-28(%rbp), %eax
	movl	%eax, -12(%rbp)
	jmp	.L16
.L20:
	movl	$0, -8(%rbp)
	jmp	.L17
.L19:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movl	-8(%rbp), %eax
	cltq
	addq	$1, %rax
	leaq	0(,%rax,4), %rcx
	movq	-24(%rbp), %rax
	addq	%rcx, %rax
	movl	(%rax), %eax
	cmpl	%eax, %edx
	jge	.L18
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, -4(%rbp)
	movl	-8(%rbp), %eax
	cltq
	addq	$1, %rax
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	-8(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	movq	-24(%rbp), %rdx
	addq	%rcx, %rdx
	movl	(%rax), %eax
	movl	%eax, (%rdx)
	movl	-8(%rbp), %eax
	cltq
	addq	$1, %rax
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rax, %rdx
	movl	-4(%rbp), %eax
	movl	%eax, (%rdx)
.L18:
	addl	$1, -8(%rbp)
.L17:
	movl	-12(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -8(%rbp)
	jl	.L19
	subl	$1, -12(%rbp)
.L16:
	cmpl	$1, -12(%rbp)
	jg	.L20
	nop
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.size	sort2, .-sort2
	.section	.rodata
.LC1:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB9:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$448, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -424(%rbp)
	movl	$0, %eax
	call	num
	movl	%eax, -420(%rbp)
	movl	$0, %eax
	call	num
	movl	%eax, -436(%rbp)
	movl	$0, -432(%rbp)
	jmp	.L22
.L23:
	movl	$0, %eax
	call	num
	movl	-432(%rbp), %edx
	movslq	%edx, %rdx
	movl	%eax, -416(%rbp,%rdx,4)
	addl	$1, -432(%rbp)
.L22:
	movl	-432(%rbp), %eax
	cmpl	-420(%rbp), %eax
	jl	.L23
	movl	-420(%rbp), %edx
	leaq	-416(%rbp), %rax
	movl	%edx, %esi
	movq	%rax, %rdi
	call	sort
	movl	$0, -432(%rbp)
	jmp	.L24
.L26:
	movl	-432(%rbp), %eax
	cltq
	movl	-416(%rbp,%rax,4), %eax
	cmpl	%eax, -436(%rbp)
	jl	.L25
	movl	-432(%rbp), %eax
	cltq
	movl	-416(%rbp,%rax,4), %eax
	subl	%eax, -436(%rbp)
	addl	$1, -424(%rbp)
.L25:
	addl	$1, -432(%rbp)
.L24:
	movl	-432(%rbp), %eax
	cmpl	-420(%rbp), %eax
	jl	.L26
	movl	-420(%rbp), %edx
	leaq	-416(%rbp), %rax
	movl	%edx, %esi
	movq	%rax, %rdi
	call	sort2
	movl	-424(%rbp), %eax
	cmpl	-420(%rbp), %eax
	jne	.L27
	movl	$1, -428(%rbp)
	jmp	.L28
.L27:
	movl	$0, -428(%rbp)
.L28:
	movl	$0, -432(%rbp)
	jmp	.L29
.L33:
	cmpl	$1, -428(%rbp)
	jne	.L30
	subl	$1, -424(%rbp)
.L30:
	movl	-432(%rbp), %eax
	cltq
	movl	-416(%rbp,%rax,4), %eax
	subl	%eax, -436(%rbp)
	cmpl	$0, -436(%rbp)
	jns	.L31
	negl	-436(%rbp)
.L31:
	movl	-432(%rbp), %eax
	cltq
	movl	-416(%rbp,%rax,4), %eax
	cmpl	%eax, -436(%rbp)
	jle	.L36
.L29:
	cmpl	$0, -436(%rbp)
	jg	.L33
	jmp	.L32
.L36:
	nop
.L32:
	movl	-424(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L35
	call	__stack_chk_fail@PLT
.L35:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE9:
	.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"
	.text
	.p2align 4
	.globl	num
	.type	num, @function
num:
.LFB39:
	.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
	xorl	%ebx, %ebx
	subq	$32, %rsp
	.cfi_def_cfa_offset 64
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	leaq	13(%rsp), %rbp
	.p2align 4,,10
	.p2align 3
.L5:
	movq	stdin(%rip), %rdi
	movslq	%ebx, %r12
	call	getc@PLT
	movb	%al, 0(%rbp,%rbx)
	cmpb	$32, %al
	je	.L7
	cmpb	$10, %al
	je	.L7
	addq	$1, %rbx
	cmpq	$11, %rbx
	jne	.L5
.L4:
	leaq	8(%rsp), %rdx
	leaq	.LC0(%rip), %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	__isoc99_sscanf@PLT
	movl	8(%rsp), %eax
	movq	24(%rsp), %rdx
	subq	%fs:40, %rdx
	jne	.L11
	addq	$32, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 32
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L7:
	.cfi_restore_state
	movb	$0, 13(%rsp,%r12)
	jmp	.L4
.L11:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE39:
	.size	num, .-num
	.p2align 4
	.globl	sort
	.type	sort, @function
sort:
.LFB40:
	.cfi_startproc
	endbr64
	cmpl	$1, %esi
	jle	.L22
	.p2align 4,,10
	.p2align 3
.L13:
	subl	$1, %esi
	xorl	%edx, %edx
	.p2align 4,,10
	.p2align 3
.L16:
	movq	(%rdi,%rdx,4), %xmm0
	pshufd	$0xe5, %xmm0, %xmm2
	movd	%xmm0, %ecx
	movd	%xmm2, %eax
	pshufd	$225, %xmm0, %xmm1
	cmpl	%eax, %ecx
	jle	.L15
	movq	%xmm1, (%rdi,%rdx,4)
.L15:
	addq	$1, %rdx
	cmpl	%edx, %esi
	jg	.L16
	cmpl	$1, %esi
	jne	.L13
	ret
.L22:
	ret
	.cfi_endproc
.LFE40:
	.size	sort, .-sort
	.p2align 4
	.globl	sort2
	.type	sort2, @function
sort2:
.LFB41:
	.cfi_startproc
	endbr64
	cmpl	$1, %esi
	jle	.L33
	.p2align 4,,10
	.p2align 3
.L24:
	subl	$1, %esi
	xorl	%edx, %edx
	.p2align 4,,10
	.p2align 3
.L27:
	movq	(%rdi,%rdx,4), %xmm0
	pshufd	$0xe5, %xmm0, %xmm2
	movd	%xmm0, %ecx
	movd	%xmm2, %eax
	pshufd	$225, %xmm0, %xmm1
	cmpl	%eax, %ecx
	jge	.L26
	movq	%xmm1, (%rdi,%rdx,4)
.L26:
	addq	$1, %rdx
	cmpl	%edx, %esi
	jg	.L27
	cmpl	$1, %esi
	jne	.L24
	ret
.L33:
	ret
	.cfi_endproc
.LFE41:
	.size	sort2, .-sort2
	.section	.rodata.str1.1
.LC1:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB42:
	.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
	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	$488, %rsp
	.cfi_def_cfa_offset 544
	movq	%fs:40, %rax
	movq	%rax, 472(%rsp)
	xorl	%eax, %eax
	call	num
	movl	%eax, 12(%rsp)
	movl	%eax, %ebx
	xorl	%eax, %eax
	call	num
	movl	%eax, %r12d
	testl	%ebx, %ebx
	jle	.L60
	movl	%ebx, %eax
	leaq	48(%rsp), %r14
	leaq	461(%rsp), %rbp
	subl	$1, %eax
	movq	%r14, %r13
	leaq	52(%rsp,%rax,4), %rax
	movq	%rax, 16(%rsp)
	leaq	44(%rsp), %rax
	movq	%rax, 24(%rsp)
	.p2align 4,,10
	.p2align 3
.L36:
	xorl	%r15d, %r15d
	.p2align 4,,10
	.p2align 3
.L40:
	movq	stdin(%rip), %rdi
	movslq	%r15d, %rbx
	call	getc@PLT
	movb	%al, 0(%rbp,%r15)
	cmpb	$32, %al
	je	.L63
	cmpb	$10, %al
	je	.L63
	addq	$1, %r15
	cmpq	$11, %r15
	jne	.L40
.L39:
	movq	24(%rsp), %rdx
	movq	%rbp, %rdi
	xorl	%eax, %eax
	addq	$4, %r13
	leaq	.LC0(%rip), %rsi
	call	__isoc99_sscanf@PLT
	movl	44(%rsp), %eax
	movl	%eax, -4(%r13)
	cmpq	16(%rsp), %r13
	jne	.L36
	cmpl	$1, 12(%rsp)
	je	.L44
	movl	12(%rsp), %edi
	.p2align 4,,10
	.p2align 3
.L58:
	subl	$1, %edi
	movq	%r14, %rdx
	xorl	%ecx, %ecx
	.p2align 4,,10
	.p2align 3
.L43:
	movq	(%rdx), %xmm0
	pshufd	$0xe5, %xmm0, %xmm2
	movd	%xmm0, %esi
	movd	%xmm2, %eax
	pshufd	$225, %xmm0, %xmm1
	cmpl	%eax, %esi
	jle	.L42
	movq	%xmm1, (%rdx)
.L42:
	addl	$1, %ecx
	addq	$4, %rdx
	cmpl	%edi, %ecx
	jl	.L43
	cmpl	$1, %edi
	jne	.L58
.L44:
	xorl	%eax, %eax
	xorl	%r8d, %r8d
	.p2align 4,,10
	.p2align 3
.L46:
	movl	(%r14,%rax,4), %edx
	cmpl	%r12d, %edx
	jg	.L45
	subl	%edx, %r12d
	addl	$1, %r8d
.L45:
	addq	$1, %rax
	cmpl	%eax, 12(%rsp)
	jg	.L46
	cmpl	$1, 12(%rsp)
	jle	.L35
	movl	12(%rsp), %edi
	.p2align 4,,10
	.p2align 3
.L47:
	subl	$1, %edi
	movq	%r14, %rdx
	xorl	%ecx, %ecx
	.p2align 4,,10
	.p2align 3
.L49:
	movq	(%rdx), %xmm0
	pshufd	$0xe5, %xmm0, %xmm3
	movd	%xmm0, %esi
	movd	%xmm3, %eax
	pshufd	$225, %xmm0, %xmm1
	cmpl	%eax, %esi
	jge	.L48
	movq	%xmm1, (%rdx)
.L48:
	addl	$1, %ecx
	addq	$4, %rdx
	cmpl	%edi, %ecx
	jl	.L49
	cmpl	$1, %edi
	jne	.L47
.L35:
	movl	48(%rsp), %eax
	cmpl	%r8d, 12(%rsp)
	jne	.L54
	jmp	.L50
	.p2align 4,,10
	.p2align 3
.L52:
	cmpl	%edx, %eax
	jge	.L51
.L53:
	movl	%edx, %r12d
.L54:
	testl	%r12d, %r12d
	jle	.L51
	movl	%r12d, %edx
	subl	%eax, %edx
	jns	.L52
	movl	%eax, %edx
	subl	%r12d, %edx
	cmpl	%edx, %eax
	jl	.L53
	.p2align 4,,10
	.p2align 3
.L51:
	xorl	%eax, %eax
	movl	%r8d, %edx
	movl	$1, %edi
	leaq	.LC1(%rip), %rsi
	call	__printf_chk@PLT
	movq	472(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L77
	addq	$488, %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
.L55:
	.cfi_restore_state
	cmpl	%edx, %eax
	jge	.L51
.L56:
	movl	%edx, %r12d
.L50:
	testl	%r12d, %r12d
	jle	.L51
	movl	%r12d, %edx
	subl	$1, %r8d
	subl	%eax, %edx
	jns	.L55
	movl	%eax, %edx
	subl	%r12d, %edx
	cmpl	%edx, %eax
	jl	.L56
	jmp	.L51
	.p2align 4,,10
	.p2align 3
.L63:
	movb	$0, 461(%rsp,%rbx)
	jmp	.L39
.L60:
	xorl	%r8d, %r8d
	jmp	.L35
.L77:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE42:
	.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"
	.text
	.p2align 4
	.globl	num
	.type	num, @function
num:
.LFB39:
	.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
	xorl	%ebx, %ebx
	subq	$32, %rsp
	.cfi_def_cfa_offset 64
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	leaq	13(%rsp), %rbp
	.p2align 4,,10
	.p2align 3
.L5:
	movq	stdin(%rip), %rdi
	movslq	%ebx, %r12
	call	getc@PLT
	movb	%al, 0(%rbp,%rbx)
	cmpb	$32, %al
	je	.L7
	cmpb	$10, %al
	je	.L7
	addq	$1, %rbx
	cmpq	$11, %rbx
	jne	.L5
.L4:
	leaq	8(%rsp), %rdx
	leaq	.LC0(%rip), %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	__isoc99_sscanf@PLT
	movl	8(%rsp), %eax
	movq	24(%rsp), %rdx
	subq	%fs:40, %rdx
	jne	.L11
	addq	$32, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 32
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L7:
	.cfi_restore_state
	movb	$0, 13(%rsp,%r12)
	jmp	.L4
.L11:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE39:
	.size	num, .-num
	.p2align 4
	.globl	sort
	.type	sort, @function
sort:
.LFB40:
	.cfi_startproc
	endbr64
	cmpl	$1, %esi
	jle	.L22
	.p2align 4,,10
	.p2align 3
.L13:
	subl	$1, %esi
	xorl	%edx, %edx
	.p2align 4,,10
	.p2align 3
.L16:
	movq	(%rdi,%rdx,4), %xmm0
	pshufd	$0xe5, %xmm0, %xmm2
	movd	%xmm0, %ecx
	movd	%xmm2, %eax
	pshufd	$225, %xmm0, %xmm1
	cmpl	%eax, %ecx
	jle	.L15
	movq	%xmm1, (%rdi,%rdx,4)
.L15:
	addq	$1, %rdx
	cmpl	%edx, %esi
	jg	.L16
	cmpl	$1, %esi
	jne	.L13
	ret
.L22:
	ret
	.cfi_endproc
.LFE40:
	.size	sort, .-sort
	.p2align 4
	.globl	sort2
	.type	sort2, @function
sort2:
.LFB41:
	.cfi_startproc
	endbr64
	cmpl	$1, %esi
	jle	.L33
	.p2align 4,,10
	.p2align 3
.L24:
	subl	$1, %esi
	xorl	%edx, %edx
	.p2align 4,,10
	.p2align 3
.L27:
	movq	(%rdi,%rdx,4), %xmm0
	pshufd	$0xe5, %xmm0, %xmm2
	movd	%xmm0, %ecx
	movd	%xmm2, %eax
	pshufd	$225, %xmm0, %xmm1
	cmpl	%eax, %ecx
	jge	.L26
	movq	%xmm1, (%rdi,%rdx,4)
.L26:
	addq	$1, %rdx
	cmpl	%edx, %esi
	jg	.L27
	cmpl	$1, %esi
	jne	.L24
	ret
.L33:
	ret
	.cfi_endproc
.LFE41:
	.size	sort2, .-sort2
	.section	.rodata.str1.1
.LC1:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB42:
	.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
	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	$488, %rsp
	.cfi_def_cfa_offset 544
	movq	%fs:40, %rax
	movq	%rax, 472(%rsp)
	xorl	%eax, %eax
	call	num
	movl	%eax, 12(%rsp)
	movl	%eax, %ebx
	xorl	%eax, %eax
	call	num
	movl	%eax, %r12d
	testl	%ebx, %ebx
	jle	.L60
	movl	%ebx, %eax
	leaq	48(%rsp), %r14
	leaq	461(%rsp), %rbp
	subl	$1, %eax
	movq	%r14, %r13
	leaq	52(%rsp,%rax,4), %rax
	movq	%rax, 16(%rsp)
	leaq	44(%rsp), %rax
	movq	%rax, 24(%rsp)
	.p2align 4,,10
	.p2align 3
.L36:
	xorl	%r15d, %r15d
	.p2align 4,,10
	.p2align 3
.L40:
	movq	stdin(%rip), %rdi
	movslq	%r15d, %rbx
	call	getc@PLT
	movb	%al, 0(%rbp,%r15)
	cmpb	$32, %al
	je	.L63
	cmpb	$10, %al
	je	.L63
	addq	$1, %r15
	cmpq	$11, %r15
	jne	.L40
.L39:
	movq	24(%rsp), %rdx
	movq	%rbp, %rdi
	xorl	%eax, %eax
	addq	$4, %r13
	leaq	.LC0(%rip), %rsi
	call	__isoc99_sscanf@PLT
	movl	44(%rsp), %eax
	movl	%eax, -4(%r13)
	cmpq	16(%rsp), %r13
	jne	.L36
	cmpl	$1, 12(%rsp)
	je	.L44
	movl	12(%rsp), %edi
	.p2align 4,,10
	.p2align 3
.L58:
	subl	$1, %edi
	movq	%r14, %rdx
	xorl	%ecx, %ecx
	.p2align 4,,10
	.p2align 3
.L43:
	movq	(%rdx), %xmm0
	pshufd	$0xe5, %xmm0, %xmm2
	movd	%xmm0, %esi
	movd	%xmm2, %eax
	pshufd	$225, %xmm0, %xmm1
	cmpl	%eax, %esi
	jle	.L42
	movq	%xmm1, (%rdx)
.L42:
	addl	$1, %ecx
	addq	$4, %rdx
	cmpl	%edi, %ecx
	jl	.L43
	cmpl	$1, %edi
	jne	.L58
.L44:
	xorl	%eax, %eax
	xorl	%r8d, %r8d
	.p2align 4,,10
	.p2align 3
.L46:
	movl	(%r14,%rax,4), %edx
	cmpl	%r12d, %edx
	jg	.L45
	subl	%edx, %r12d
	addl	$1, %r8d
.L45:
	addq	$1, %rax
	cmpl	%eax, 12(%rsp)
	jg	.L46
	cmpl	$1, 12(%rsp)
	jle	.L35
	movl	12(%rsp), %edi
	.p2align 4,,10
	.p2align 3
.L47:
	subl	$1, %edi
	movq	%r14, %rdx
	xorl	%ecx, %ecx
	.p2align 4,,10
	.p2align 3
.L49:
	movq	(%rdx), %xmm0
	pshufd	$0xe5, %xmm0, %xmm3
	movd	%xmm0, %esi
	movd	%xmm3, %eax
	pshufd	$225, %xmm0, %xmm1
	cmpl	%eax, %esi
	jge	.L48
	movq	%xmm1, (%rdx)
.L48:
	addl	$1, %ecx
	addq	$4, %rdx
	cmpl	%edi, %ecx
	jl	.L49
	cmpl	$1, %edi
	jne	.L47
.L35:
	movl	48(%rsp), %eax
	cmpl	%r8d, 12(%rsp)
	jne	.L54
	jmp	.L50
	.p2align 4,,10
	.p2align 3
.L52:
	cmpl	%edx, %eax
	jge	.L51
.L53:
	movl	%edx, %r12d
.L54:
	testl	%r12d, %r12d
	jle	.L51
	movl	%r12d, %edx
	subl	%eax, %edx
	jns	.L52
	movl	%eax, %edx
	subl	%r12d, %edx
	cmpl	%edx, %eax
	jl	.L53
	.p2align 4,,10
	.p2align 3
.L51:
	xorl	%eax, %eax
	movl	%r8d, %edx
	movl	$1, %edi
	leaq	.LC1(%rip), %rsi
	call	__printf_chk@PLT
	movq	472(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L77
	addq	$488, %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
.L55:
	.cfi_restore_state
	cmpl	%edx, %eax
	jge	.L51
.L56:
	movl	%edx, %r12d
.L50:
	testl	%r12d, %r12d
	jle	.L51
	movl	%r12d, %edx
	subl	$1, %r8d
	subl	%eax, %edx
	jns	.L55
	movl	%eax, %edx
	subl	%r12d, %edx
	cmpl	%edx, %eax
	jl	.L56
	jmp	.L51
	.p2align 4,,10
	.p2align 3
.L63:
	movb	$0, 461(%rsp,%rbx)
	jmp	.L39
.L60:
	xorl	%r8d, %r8d
	jmp	.L35
.L77:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE42:
	.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 num(){
    char s[11];
    int i, n;
    for(i=0; i<sizeof(s); i++){
        s[i] = getchar();
        if(s[i] == ' ' || s[i] == '\n'){
            s[i] = '\0';
            break;
        }
    }
    sscanf(s, "%d", &n);
    return n;
}
void sort(int x[], int n){
    int y, i, j;
    for(i=n; i>1; i--){
        for(j=0; j<=i-2; j++){
            if(x[j] > x[j+1]){
                y = x[j];
                x[j] = x[j+1];
                x[j+1] = y;
            }
        }
    }
}
void sort2(int x[], int n){
    int y, i, j;
    for(i=n; i>1; i--){
        for(j=0; j<=i-2; j++){
            if(x[j] < x[j+1]){
                y = x[j];
                x[j] = x[j+1];
                x[j+1] = y;
            }
        }
    }
}
int main(void){
    int n, x;
    int a[100];
    int i, y, cou=0;
    
    n = num();
    x = num();
    for(i=0; i<n; i++){
        a[i] = num();
    }
    
    sort(a, n);
    
    for(i=0; i<n; i++){
        if(x >= a[i]){
            x -= a[i];
            cou++;
        }
    }
    
    sort2(a, n);
    
    if(cou == n){
        y = 1;
    }
    else{
        y = 0;
    }
    i=0;
    while(x > 0){
//        x -= a[i];
        if(y==1){
            cou--;
        }
        x -= a[i];
        if(x < 0){
            x *= -1;
        }
        if(a[i] >= x){
            break;
        }
        
    }
//    if(x < 0){
//        cou++;
//    }
    
    printf("%d\n", cou);
    
    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 num(){
    char s[11];
    int i, n;
    for(i=0; i<sizeof(s); i++){
        s[i] = getchar();
        if(s[i] == ' ' || s[i] == '\n'){
            s[i] = '\0';
            break;
        }
    }
    sscanf(s, "%d", &n);
    return n;
}
void sort(int x[], int n){
    int y, i, j;
    for(i=n; i>1; i--){
        for(j=0; j<=i-2; j++){
            if(x[j] > x[j+1]){
                y = x[j];
                x[j] = x[j+1];
                x[j+1] = y;
            }
        }
    }
}
void sort2(int x[], int n){
    int y, i, j;
    for(i=n; i>1; i--){
        for(j=0; j<=i-2; j++){
            if(x[j] < x[j+1]){
                y = x[j];
                x[j] = x[j+1];
                x[j+1] = y;
            }
        }
    }
}
int main(void){
    int n, x;
    int a[100];
    int i, y, cou=0;
    
    n = num();
    x = num();
    for(i=0; i<n; i++){
        a[i] = num();
    }
    
    sort(a, n);
    
    for(i=0; i<n; i++){
        if(x >= a[i]){
            x -= a[i];
            cou++;
        }
    }
    
    sort2(a, n);
    
    if(cou == n){
        y = 1;
    }
    else{
        y = 0;
    }
    i=0;
    while(x > 0){
//        x -= a[i];
        if(y==1){
            cou--;
        }
        x -= a[i];
        if(x < 0){
            x *= -1;
        }
        if(a[i] >= x){
            break;
        }
        
    }
//    if(x < 0){
//        cou++;
//    }
    
    printf("%d\n", cou);
    
    return 0;
    
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d"
	.text
	.globl	num
	.type	num, @function
num:
.LFB6:
	.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
	movl	$0, -24(%rbp)
	jmp	.L2
.L6:
	call	getchar@PLT
	movl	%eax, %edx
	movl	-24(%rbp), %eax
	cltq
	movb	%dl, -19(%rbp,%rax)
	movl	-24(%rbp), %eax
	cltq
	movzbl	-19(%rbp,%rax), %eax
	cmpb	$32, %al
	je	.L3
	movl	-24(%rbp), %eax
	cltq
	movzbl	-19(%rbp,%rax), %eax
	cmpb	$10, %al
	jne	.L4
.L3:
	movl	-24(%rbp), %eax
	cltq
	movb	$0, -19(%rbp,%rax)
	jmp	.L5
.L4:
	addl	$1, -24(%rbp)
.L2:
	movl	-24(%rbp), %eax
	cmpl	$10, %eax
	jbe	.L6
.L5:
	leaq	-28(%rbp), %rdx
	leaq	-19(%rbp), %rax
	leaq	.LC0(%rip), %rcx
	movq	%rcx, %rsi
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_sscanf@PLT
	movl	-28(%rbp), %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
.LFE6:
	.size	num, .-num
	.globl	sort
	.type	sort, @function
sort:
.LFB7:
	.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	-28(%rbp), %eax
	movl	%eax, -12(%rbp)
	jmp	.L10
.L14:
	movl	$0, -8(%rbp)
	jmp	.L11
.L13:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movl	-8(%rbp), %eax
	cltq
	addq	$1, %rax
	leaq	0(,%rax,4), %rcx
	movq	-24(%rbp), %rax
	addq	%rcx, %rax
	movl	(%rax), %eax
	cmpl	%eax, %edx
	jle	.L12
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, -4(%rbp)
	movl	-8(%rbp), %eax
	cltq
	addq	$1, %rax
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	-8(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	movq	-24(%rbp), %rdx
	addq	%rcx, %rdx
	movl	(%rax), %eax
	movl	%eax, (%rdx)
	movl	-8(%rbp), %eax
	cltq
	addq	$1, %rax
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rax, %rdx
	movl	-4(%rbp), %eax
	movl	%eax, (%rdx)
.L12:
	addl	$1, -8(%rbp)
.L11:
	movl	-12(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -8(%rbp)
	jl	.L13
	subl	$1, -12(%rbp)
.L10:
	cmpl	$1, -12(%rbp)
	jg	.L14
	nop
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	sort, .-sort
	.globl	sort2
	.type	sort2, @function
sort2:
.LFB8:
	.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	-28(%rbp), %eax
	movl	%eax, -12(%rbp)
	jmp	.L16
.L20:
	movl	$0, -8(%rbp)
	jmp	.L17
.L19:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movl	-8(%rbp), %eax
	cltq
	addq	$1, %rax
	leaq	0(,%rax,4), %rcx
	movq	-24(%rbp), %rax
	addq	%rcx, %rax
	movl	(%rax), %eax
	cmpl	%eax, %edx
	jge	.L18
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, -4(%rbp)
	movl	-8(%rbp), %eax
	cltq
	addq	$1, %rax
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	-8(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	movq	-24(%rbp), %rdx
	addq	%rcx, %rdx
	movl	(%rax), %eax
	movl	%eax, (%rdx)
	movl	-8(%rbp), %eax
	cltq
	addq	$1, %rax
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rax, %rdx
	movl	-4(%rbp), %eax
	movl	%eax, (%rdx)
.L18:
	addl	$1, -8(%rbp)
.L17:
	movl	-12(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -8(%rbp)
	jl	.L19
	subl	$1, -12(%rbp)
.L16:
	cmpl	$1, -12(%rbp)
	jg	.L20
	nop
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.size	sort2, .-sort2
	.section	.rodata
.LC1:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB9:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$448, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -424(%rbp)
	movl	$0, %eax
	call	num
	movl	%eax, -420(%rbp)
	movl	$0, %eax
	call	num
	movl	%eax, -436(%rbp)
	movl	$0, -432(%rbp)
	jmp	.L22
.L23:
	movl	$0, %eax
	call	num
	movl	-432(%rbp), %edx
	movslq	%edx, %rdx
	movl	%eax, -416(%rbp,%rdx,4)
	addl	$1, -432(%rbp)
.L22:
	movl	-432(%rbp), %eax
	cmpl	-420(%rbp), %eax
	jl	.L23
	movl	-420(%rbp), %edx
	leaq	-416(%rbp), %rax
	movl	%edx, %esi
	movq	%rax, %rdi
	call	sort
	movl	$0, -432(%rbp)
	jmp	.L24
.L26:
	movl	-432(%rbp), %eax
	cltq
	movl	-416(%rbp,%rax,4), %eax
	cmpl	%eax, -436(%rbp)
	jl	.L25
	movl	-432(%rbp), %eax
	cltq
	movl	-416(%rbp,%rax,4), %eax
	subl	%eax, -436(%rbp)
	addl	$1, -424(%rbp)
.L25:
	addl	$1, -432(%rbp)
.L24:
	movl	-432(%rbp), %eax
	cmpl	-420(%rbp), %eax
	jl	.L26
	movl	-420(%rbp), %edx
	leaq	-416(%rbp), %rax
	movl	%edx, %esi
	movq	%rax, %rdi
	call	sort2
	movl	-424(%rbp), %eax
	cmpl	-420(%rbp), %eax
	jne	.L27
	movl	$1, -428(%rbp)
	jmp	.L28
.L27:
	movl	$0, -428(%rbp)
.L28:
	movl	$0, -432(%rbp)
	jmp	.L29
.L33:
	cmpl	$1, -428(%rbp)
	jne	.L30
	subl	$1, -424(%rbp)
.L30:
	movl	-432(%rbp), %eax
	cltq
	movl	-416(%rbp,%rax,4), %eax
	subl	%eax, -436(%rbp)
	cmpl	$0, -436(%rbp)
	jns	.L31
	negl	-436(%rbp)
.L31:
	movl	-432(%rbp), %eax
	cltq
	movl	-416(%rbp,%rax,4), %eax
	cmpl	%eax, -436(%rbp)
	jle	.L36
.L29:
	cmpl	$0, -436(%rbp)
	jg	.L33
	jmp	.L32
.L36:
	nop
.L32:
	movl	-424(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L35
	call	__stack_chk_fail@PLT
.L35:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE9:
	.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	num
	.type	num, @function
num:
.LFB6:
	.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
	movl	$0, -24(%rbp)
	jmp	.L2
.L6:
	call	getchar@PLT
	movl	%eax, %edx
	movl	-24(%rbp), %eax
	cltq
	movb	%dl, -19(%rbp,%rax)
	movl	-24(%rbp), %eax
	cltq
	movzbl	-19(%rbp,%rax), %eax
	cmpb	$32, %al
	je	.L3
	movl	-24(%rbp), %eax
	cltq
	movzbl	-19(%rbp,%rax), %eax
	cmpb	$10, %al
	jne	.L4
.L3:
	movl	-24(%rbp), %eax
	cltq
	movb	$0, -19(%rbp,%rax)
	jmp	.L5
.L4:
	addl	$1, -24(%rbp)
.L2:
	movl	-24(%rbp), %eax
	cmpl	$10, %eax
	jbe	.L6
.L5:
	leaq	-28(%rbp), %rdx
	leaq	-19(%rbp), %rax
	leaq	.LC0(%rip), %rcx
	movq	%rcx, %rsi
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_sscanf@PLT
	movl	-28(%rbp), %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
.LFE6:
	.size	num, .-num
	.globl	sort
	.type	sort, @function
sort:
.LFB7:
	.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	-28(%rbp), %eax
	movl	%eax, -12(%rbp)
	jmp	.L10
.L14:
	movl	$0, -8(%rbp)
	jmp	.L11
.L13:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movl	-8(%rbp), %eax
	cltq
	addq	$1, %rax
	leaq	0(,%rax,4), %rcx
	movq	-24(%rbp), %rax
	addq	%rcx, %rax
	movl	(%rax), %eax
	cmpl	%eax, %edx
	jle	.L12
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, -4(%rbp)
	movl	-8(%rbp), %eax
	cltq
	addq	$1, %rax
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	-8(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	movq	-24(%rbp), %rdx
	addq	%rcx, %rdx
	movl	(%rax), %eax
	movl	%eax, (%rdx)
	movl	-8(%rbp), %eax
	cltq
	addq	$1, %rax
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rax, %rdx
	movl	-4(%rbp), %eax
	movl	%eax, (%rdx)
.L12:
	addl	$1, -8(%rbp)
.L11:
	movl	-12(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -8(%rbp)
	jl	.L13
	subl	$1, -12(%rbp)
.L10:
	cmpl	$1, -12(%rbp)
	jg	.L14
	nop
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	sort, .-sort
	.globl	sort2
	.type	sort2, @function
sort2:
.LFB8:
	.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	-28(%rbp), %eax
	movl	%eax, -12(%rbp)
	jmp	.L16
.L20:
	movl	$0, -8(%rbp)
	jmp	.L17
.L19:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movl	-8(%rbp), %eax
	cltq
	addq	$1, %rax
	leaq	0(,%rax,4), %rcx
	movq	-24(%rbp), %rax
	addq	%rcx, %rax
	movl	(%rax), %eax
	cmpl	%eax, %edx
	jge	.L18
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, -4(%rbp)
	movl	-8(%rbp), %eax
	cltq
	addq	$1, %rax
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	-8(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	movq	-24(%rbp), %rdx
	addq	%rcx, %rdx
	movl	(%rax), %eax
	movl	%eax, (%rdx)
	movl	-8(%rbp), %eax
	cltq
	addq	$1, %rax
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rax, %rdx
	movl	-4(%rbp), %eax
	movl	%eax, (%rdx)
.L18:
	addl	$1, -8(%rbp)
.L17:
	movl	-12(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -8(%rbp)
	jl	.L19
	subl	$1, -12(%rbp)
.L16:
	cmpl	$1, -12(%rbp)
	jg	.L20
	nop
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.size	sort2, .-sort2
	.section	.rodata
.LC1:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB9:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$448, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -424(%rbp)
	movl	$0, %eax
	call	num
	movl	%eax, -420(%rbp)
	movl	$0, %eax
	call	num
	movl	%eax, -436(%rbp)
	movl	$0, -432(%rbp)
	jmp	.L22
.L23:
	movl	$0, %eax
	call	num
	movl	-432(%rbp), %edx
	movslq	%edx, %rdx
	movl	%eax, -416(%rbp,%rdx,4)
	addl	$1, -432(%rbp)
.L22:
	movl	-432(%rbp), %eax
	cmpl	-420(%rbp), %eax
	jl	.L23
	movl	-420(%rbp), %edx
	leaq	-416(%rbp), %rax
	movl	%edx, %esi
	movq	%rax, %rdi
	call	sort
	movl	$0, -432(%rbp)
	jmp	.L24
.L26:
	movl	-432(%rbp), %eax
	cltq
	movl	-416(%rbp,%rax,4), %eax
	cmpl	%eax, -436(%rbp)
	jl	.L25
	movl	-432(%rbp), %eax
	cltq
	movl	-416(%rbp,%rax,4), %eax
	subl	%eax, -436(%rbp)
	addl	$1, -424(%rbp)
.L25:
	addl	$1, -432(%rbp)
.L24:
	movl	-432(%rbp), %eax
	cmpl	-420(%rbp), %eax
	jl	.L26
	movl	-420(%rbp), %edx
	leaq	-416(%rbp), %rax
	movl	%edx, %esi
	movq	%rax, %rdi
	call	sort2
	movl	-424(%rbp), %eax
	cmpl	-420(%rbp), %eax
	jne	.L27
	movl	$1, -428(%rbp)
	jmp	.L28
.L27:
	movl	$0, -428(%rbp)
.L28:
	movl	$0, -432(%rbp)
	jmp	.L29
.L33:
	cmpl	$1, -428(%rbp)
	jne	.L30
	subl	$1, -424(%rbp)
.L30:
	movl	-432(%rbp), %eax
	cltq
	movl	-416(%rbp,%rax,4), %eax
	subl	%eax, -436(%rbp)
	cmpl	$0, -436(%rbp)
	jns	.L31
	negl	-436(%rbp)
.L31:
	movl	-432(%rbp), %eax
	cltq
	movl	-416(%rbp,%rax,4), %eax
	cmpl	%eax, -436(%rbp)
	jle	.L36
.L29:
	cmpl	$0, -436(%rbp)
	jg	.L33
	jmp	.L32
.L36:
	nop
.L32:
	movl	-424(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L35
	call	__stack_chk_fail@PLT
.L35:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE9:
	.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:
