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 getNextNumber(int n,int L) {
	char format[100];
	char buffer[100];
	int max,min;
	int i,j;
	char temp;
	sprintf(format,"%%0%dd",L);
	sprintf(buffer,format,n);
	for(i=L-1;i>0;i--) {
		for(j=0;j<i;j++) {
			if(buffer[j]<buffer[j+1]) {
				temp=buffer[j];
				buffer[j]=buffer[j+1];
				buffer[j+1]=temp;
			}
		}
	}
	sscanf(buffer,"%d",&max);
	for(i=0;i+i<L;i++) {
		temp=buffer[i];
		buffer[i]=buffer[L-i-1];
		buffer[L-i-1]=temp;
	}
	sscanf(buffer,"%d",&min);
	return max-min;
}

int main(void) {
	int a,L;
	int numbers[21];
	int i,j,found;
	while(scanf("%d%d",&a,&L)==2 && (a|L)!=0) {
		numbers[0]=a;
		for(i=1;i<21;i++)numbers[i]=getNextNumber(numbers[i-1],L);
		for(i=1;i<21;i++) {
			found=0;
			for(j=0;j<i;j++) {
				if(numbers[i]==numbers[j]) {
					found=1;
					break;
				}
			}
			if(found)break;
		}
		if(i>=21)return 1;
		printf("%d %d %d\n",j,numbers[j],i-j);
	}
	return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%%0%dd"
.LC1:
	.string	"%d"
	.text
	.globl	getNextNumber
	.type	getNextNumber, @function
getNextNumber:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$272, %rsp
	movl	%edi, -260(%rbp)
	movl	%esi, -264(%rbp)
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	-264(%rbp), %edx
	leaq	-224(%rbp), %rax
	leaq	.LC0(%rip), %rcx
	movq	%rcx, %rsi
	movq	%rax, %rdi
	movl	$0, %eax
	call	sprintf@PLT
	movl	-260(%rbp), %edx
	leaq	-224(%rbp), %rcx
	leaq	-112(%rbp), %rax
	movq	%rcx, %rsi
	movq	%rax, %rdi
	movl	$0, %eax
	call	sprintf@PLT
	movl	-264(%rbp), %eax
	subl	$1, %eax
	movl	%eax, -232(%rbp)
	jmp	.L2
.L6:
	movl	$0, -228(%rbp)
	jmp	.L3
.L5:
	movl	-228(%rbp), %eax
	cltq
	movzbl	-112(%rbp,%rax), %edx
	movl	-228(%rbp), %eax
	addl	$1, %eax
	cltq
	movzbl	-112(%rbp,%rax), %eax
	cmpb	%al, %dl
	jge	.L4
	movl	-228(%rbp), %eax
	cltq
	movzbl	-112(%rbp,%rax), %eax
	movb	%al, -241(%rbp)
	movl	-228(%rbp), %eax
	addl	$1, %eax
	cltq
	movzbl	-112(%rbp,%rax), %edx
	movl	-228(%rbp), %eax
	cltq
	movb	%dl, -112(%rbp,%rax)
	movl	-228(%rbp), %eax
	addl	$1, %eax
	cltq
	movzbl	-241(%rbp), %edx
	movb	%dl, -112(%rbp,%rax)
.L4:
	addl	$1, -228(%rbp)
.L3:
	movl	-228(%rbp), %eax
	cmpl	-232(%rbp), %eax
	jl	.L5
	subl	$1, -232(%rbp)
.L2:
	cmpl	$0, -232(%rbp)
	jg	.L6
	leaq	-240(%rbp), %rdx
	leaq	-112(%rbp), %rax
	leaq	.LC1(%rip), %rcx
	movq	%rcx, %rsi
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_sscanf@PLT
	movl	$0, -232(%rbp)
	jmp	.L7
.L8:
	movl	-232(%rbp), %eax
	cltq
	movzbl	-112(%rbp,%rax), %eax
	movb	%al, -241(%rbp)
	movl	-264(%rbp), %eax
	subl	-232(%rbp), %eax
	subl	$1, %eax
	cltq
	movzbl	-112(%rbp,%rax), %edx
	movl	-232(%rbp), %eax
	cltq
	movb	%dl, -112(%rbp,%rax)
	movl	-264(%rbp), %eax
	subl	-232(%rbp), %eax
	subl	$1, %eax
	cltq
	movzbl	-241(%rbp), %edx
	movb	%dl, -112(%rbp,%rax)
	addl	$1, -232(%rbp)
.L7:
	movl	-232(%rbp), %eax
	addl	%eax, %eax
	cmpl	%eax, -264(%rbp)
	jg	.L8
	leaq	-236(%rbp), %rdx
	leaq	-112(%rbp), %rax
	leaq	.LC1(%rip), %rcx
	movq	%rcx, %rsi
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_sscanf@PLT
	movl	-240(%rbp), %eax
	movl	-236(%rbp), %edx
	subl	%edx, %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
.LFE0:
	.size	getNextNumber, .-getNextNumber
	.section	.rodata
.LC2:
	.string	"%d %d %d\n"
.LC3:
	.string	"%d%d"
	.text
	.globl	main
	.type	main, @function
main:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	addq	$-128, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	jmp	.L12
.L26:
	movl	-116(%rbp), %eax
	movl	%eax, -96(%rbp)
	movl	$1, -108(%rbp)
	jmp	.L13
.L14:
	movl	-112(%rbp), %edx
	movl	-108(%rbp), %eax
	subl	$1, %eax
	cltq
	movl	-96(%rbp,%rax,4), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	getNextNumber
	movl	-108(%rbp), %edx
	movslq	%edx, %rdx
	movl	%eax, -96(%rbp,%rdx,4)
	addl	$1, -108(%rbp)
.L13:
	cmpl	$20, -108(%rbp)
	jle	.L14
	movl	$1, -108(%rbp)
	jmp	.L15
.L22:
	movl	$0, -100(%rbp)
	movl	$0, -104(%rbp)
	jmp	.L16
.L19:
	movl	-108(%rbp), %eax
	cltq
	movl	-96(%rbp,%rax,4), %edx
	movl	-104(%rbp), %eax
	cltq
	movl	-96(%rbp,%rax,4), %eax
	cmpl	%eax, %edx
	jne	.L17
	movl	$1, -100(%rbp)
	jmp	.L18
.L17:
	addl	$1, -104(%rbp)
.L16:
	movl	-104(%rbp), %eax
	cmpl	-108(%rbp), %eax
	jl	.L19
.L18:
	cmpl	$0, -100(%rbp)
	jne	.L29
	addl	$1, -108(%rbp)
.L15:
	cmpl	$20, -108(%rbp)
	jle	.L22
	jmp	.L21
.L29:
	nop
.L21:
	cmpl	$20, -108(%rbp)
	jle	.L23
	movl	$1, %eax
	jmp	.L27
.L23:
	movl	-108(%rbp), %eax
	subl	-104(%rbp), %eax
	movl	%eax, %ecx
	movl	-104(%rbp), %eax
	cltq
	movl	-96(%rbp,%rax,4), %edx
	movl	-104(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L12:
	leaq	-112(%rbp), %rdx
	leaq	-116(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	cmpl	$2, %eax
	jne	.L25
	movl	-116(%rbp), %edx
	movl	-112(%rbp), %eax
	orl	%edx, %eax
	testl	%eax, %eax
	jne	.L26
.L25:
	movl	$0, %eax
.L27:
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L28
	call	__stack_chk_fail@PLT
.L28:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.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	"%%0%dd"
.LC1:
	.string	"%d"
	.text
	.p2align 4
	.globl	getNextNumber
	.type	getNextNumber, @function
getNextNumber:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	movl	%esi, %r8d
	movl	$100, %edx
	leaq	.LC0(%rip), %rcx
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	movl	%edi, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	movl	%esi, %ebx
	movl	$1, %esi
	subq	$248, %rsp
	.cfi_def_cfa_offset 288
	movq	%fs:40, %rax
	movq	%rax, 232(%rsp)
	xorl	%eax, %eax
	leaq	16(%rsp), %r13
	leaq	128(%rsp), %rbp
	movq	%r13, %rdi
	call	__sprintf_chk@PLT
	movl	%r12d, %r8d
	movq	%r13, %rcx
	movl	$100, %edx
	movl	$1, %esi
	movq	%rbp, %rdi
	leal	-1(%rbx), %r12d
	xorl	%eax, %eax
	call	__sprintf_chk@PLT
	testl	%r12d, %r12d
	jle	.L2
	movl	%r12d, %edi
	.p2align 4,,10
	.p2align 3
.L5:
	movq	%rbp, %rax
	xorl	%edx, %edx
	.p2align 4,,10
	.p2align 3
.L4:
	movzbl	(%rax), %ecx
	movzbl	1(%rax), %esi
	addl	$1, %edx
	cmpb	%sil, %cl
	jge	.L3
	movb	%sil, (%rax)
	movb	%cl, 1(%rax)
.L3:
	addq	$1, %rax
	cmpl	%edi, %edx
	jl	.L4
	subl	$1, %edi
	jne	.L5
.L2:
	leaq	.LC1(%rip), %r13
	xorl	%eax, %eax
	leaq	8(%rsp), %rdx
	movq	%rbp, %rdi
	movq	%r13, %rsi
	call	__isoc99_sscanf@PLT
	testl	%ebx, %ebx
	jle	.L6
	shrl	%r12d
	movslq	%ebx, %rdx
	movq	%rbp, %rax
	movl	%r12d, %ecx
	addq	%rbp, %rdx
	leaq	129(%rsp,%rcx), %rdi
	.p2align 4,,10
	.p2align 3
.L7:
	movzbl	-1(%rdx), %esi
	movzbl	(%rax), %ecx
	addq	$1, %rax
	subq	$1, %rdx
	movb	%sil, -1(%rax)
	movb	%cl, (%rdx)
	cmpq	%rdi, %rax
	jne	.L7
.L6:
	leaq	12(%rsp), %rdx
	movq	%r13, %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	__isoc99_sscanf@PLT
	movl	8(%rsp), %eax
	subl	12(%rsp), %eax
	movq	232(%rsp), %rdx
	subq	%fs:40, %rdx
	jne	.L14
	addq	$248, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	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
.L14:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.size	getNextNumber, .-getNextNumber
	.section	.rodata.str1.1
.LC2:
	.string	"%d%d"
.LC3:
	.string	"%d %d %d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB24:
	.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
	leaq	.LC2(%rip), %rbx
	subq	$120, %rsp
	.cfi_def_cfa_offset 176
	movq	%fs:40, %rax
	movq	%rax, 104(%rsp)
	xorl	%eax, %eax
	leaq	12(%rsp), %r12
	leaq	8(%rsp), %rbp
.L16:
	xorl	%eax, %eax
	movq	%r12, %rdx
	movq	%rbp, %rsi
	movq	%rbx, %rdi
	call	__isoc99_scanf@PLT
	cmpl	$2, %eax
	jne	.L26
	movl	8(%rsp), %eax
	movl	12(%rsp), %esi
	movl	%eax, %r8d
	orl	%esi, %r8d
	je	.L15
	leaq	16(%rsp), %r13
	movl	%eax, 16(%rsp)
	leaq	96(%rsp), %r15
	movq	%r13, %r14
	jmp	.L18
	.p2align 4,,10
	.p2align 3
.L31:
	movl	12(%rsp), %esi
.L18:
	movl	(%r14), %edi
	addq	$4, %r14
	call	getNextNumber
	movl	%eax, (%r14)
	cmpq	%r14, %r15
	jne	.L31
	movl	$1, %edx
	.p2align 4,,10
	.p2align 3
.L17:
	movl	0(%r13,%rdx,4), %r9d
	movl	%edx, %r8d
	xorl	%eax, %eax
	.p2align 4,,10
	.p2align 3
.L20:
	cmpl	0(%r13,%rax,4), %r9d
	je	.L19
	addq	$1, %rax
	cmpq	%rdx, %rax
	jne	.L20
	leaq	1(%rax), %rdx
	cmpq	$20, %rax
	jne	.L17
	movl	$1, %r8d
.L15:
	movq	104(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L32
	addq	$120, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	movl	%r8d, %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
.L19:
	.cfi_restore_state
	subl	%eax, %r8d
	movl	%eax, %edx
	movl	%r9d, %ecx
	movl	$1, %edi
	leaq	.LC3(%rip), %rsi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L16
.L26:
	xorl	%r8d, %r8d
	jmp	.L15
.L32:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE24:
	.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	"%%0%dd"
.LC1:
	.string	"%d"
	.text
	.p2align 4
	.globl	getNextNumber
	.type	getNextNumber, @function
getNextNumber:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	movl	%esi, %r8d
	movl	$100, %edx
	leaq	.LC0(%rip), %rcx
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	movl	%edi, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	movl	%esi, %ebx
	movl	$1, %esi
	subq	$248, %rsp
	.cfi_def_cfa_offset 288
	movq	%fs:40, %rax
	movq	%rax, 232(%rsp)
	xorl	%eax, %eax
	leaq	16(%rsp), %r13
	leaq	128(%rsp), %rbp
	movq	%r13, %rdi
	call	__sprintf_chk@PLT
	movl	%r12d, %r8d
	movq	%r13, %rcx
	movl	$100, %edx
	movl	$1, %esi
	movq	%rbp, %rdi
	leal	-1(%rbx), %r12d
	xorl	%eax, %eax
	call	__sprintf_chk@PLT
	testl	%r12d, %r12d
	jle	.L2
	movl	%r12d, %edi
	.p2align 4,,10
	.p2align 3
.L5:
	movq	%rbp, %rax
	xorl	%edx, %edx
	.p2align 4,,10
	.p2align 3
.L4:
	movzbl	(%rax), %ecx
	movzbl	1(%rax), %esi
	addl	$1, %edx
	cmpb	%sil, %cl
	jge	.L3
	movb	%sil, (%rax)
	movb	%cl, 1(%rax)
.L3:
	addq	$1, %rax
	cmpl	%edi, %edx
	jl	.L4
	subl	$1, %edi
	jne	.L5
.L2:
	leaq	.LC1(%rip), %r13
	xorl	%eax, %eax
	leaq	8(%rsp), %rdx
	movq	%rbp, %rdi
	movq	%r13, %rsi
	call	__isoc99_sscanf@PLT
	testl	%ebx, %ebx
	jle	.L6
	shrl	%r12d
	movslq	%ebx, %rdx
	movq	%rbp, %rax
	movl	%r12d, %ecx
	addq	%rbp, %rdx
	leaq	129(%rsp,%rcx), %rdi
	.p2align 4,,10
	.p2align 3
.L7:
	movzbl	-1(%rdx), %esi
	movzbl	(%rax), %ecx
	addq	$1, %rax
	subq	$1, %rdx
	movb	%sil, -1(%rax)
	movb	%cl, (%rdx)
	cmpq	%rdi, %rax
	jne	.L7
.L6:
	leaq	12(%rsp), %rdx
	movq	%r13, %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	__isoc99_sscanf@PLT
	movl	8(%rsp), %eax
	subl	12(%rsp), %eax
	movq	232(%rsp), %rdx
	subq	%fs:40, %rdx
	jne	.L14
	addq	$248, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	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
.L14:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.size	getNextNumber, .-getNextNumber
	.section	.rodata.str1.1
.LC2:
	.string	"%d%d"
.LC3:
	.string	"%d %d %d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB24:
	.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
	leaq	.LC2(%rip), %rbx
	subq	$120, %rsp
	.cfi_def_cfa_offset 176
	movq	%fs:40, %rax
	movq	%rax, 104(%rsp)
	xorl	%eax, %eax
	leaq	12(%rsp), %r12
	leaq	8(%rsp), %rbp
.L16:
	xorl	%eax, %eax
	movq	%r12, %rdx
	movq	%rbp, %rsi
	movq	%rbx, %rdi
	call	__isoc99_scanf@PLT
	cmpl	$2, %eax
	jne	.L26
	movl	8(%rsp), %eax
	movl	12(%rsp), %esi
	movl	%eax, %r8d
	orl	%esi, %r8d
	je	.L15
	leaq	16(%rsp), %r13
	movl	%eax, 16(%rsp)
	leaq	96(%rsp), %r15
	movq	%r13, %r14
	jmp	.L18
	.p2align 4,,10
	.p2align 3
.L31:
	movl	12(%rsp), %esi
.L18:
	movl	(%r14), %edi
	addq	$4, %r14
	call	getNextNumber
	movl	%eax, (%r14)
	cmpq	%r14, %r15
	jne	.L31
	movl	$1, %edx
	.p2align 4,,10
	.p2align 3
.L17:
	movl	0(%r13,%rdx,4), %r9d
	movl	%edx, %r8d
	xorl	%eax, %eax
	.p2align 4,,10
	.p2align 3
.L20:
	cmpl	0(%r13,%rax,4), %r9d
	je	.L19
	addq	$1, %rax
	cmpq	%rdx, %rax
	jne	.L20
	leaq	1(%rax), %rdx
	cmpq	$20, %rax
	jne	.L17
	movl	$1, %r8d
.L15:
	movq	104(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L32
	addq	$120, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	movl	%r8d, %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
.L19:
	.cfi_restore_state
	subl	%eax, %r8d
	movl	%eax, %edx
	movl	%r9d, %ecx
	movl	$1, %edi
	leaq	.LC3(%rip), %rsi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L16
.L26:
	xorl	%r8d, %r8d
	jmp	.L15
.L32:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE24:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:

#include <stdio.h>

int getNextNumber(int n,int L) {
	char format[100];
	char buffer[100];
	int max,min;
	int i,j;
	char temp;
	sprintf(format,"%%0%dd",L);
	sprintf(buffer,format,n);
	for(i=L-1;i>0;i--) {
		for(j=0;j<i;j++) {
			if(buffer[j]<buffer[j+1]) {
				temp=buffer[j];
				buffer[j]=buffer[j+1];
				buffer[j+1]=temp;
			}
		}
	}
	sscanf(buffer,"%d",&max);
	for(i=0;i+i<L;i++) {
		temp=buffer[i];
		buffer[i]=buffer[L-i-1];
		buffer[L-i-1]=temp;
	}
	sscanf(buffer,"%d",&min);
	return max-min;
}

int main(void) {
	int a,L;
	int numbers[21];
	int i,j,found;
	while(scanf("%d%d",&a,&L)==2 && (a|L)!=0) {
		numbers[0]=a;
		for(i=1;i<21;i++)numbers[i]=getNextNumber(numbers[i-1],L);
		for(i=1;i<21;i++) {
			found=0;
			for(j=0;j<i;j++) {
				if(numbers[i]==numbers[j]) {
					found=1;
					break;
				}
			}
			if(found)break;
		}
		if(i>=21)return 1;
		printf("%d %d %d\n",j,numbers[j],i-j);
	}
	return 0;
}
2012 4
83268 3
1112 4
0 1
99 2
0 0
 2012 4
83268 6
1112 4
0 1
99 1
0 0
 2012 4
83268 3
1112 4
0 1
17 2
0 0
 2012 4
83268 6
1112 3
0 1
99 1
0 0
 2012 4
83268 6
1112 4
0 0
99 1
0 0
 2012 4
83268 3
1112 6
0 1
17 2
0 0
 2012 4
83268 3
1112 3
0 1
99 1
0 0
 338 4
83268 3
1112 6
0 1
17 2
0 0
 3214 4
83268 6
1112 4
1 0
99 1
0 0
 338 4
83268 5
125 6
0 1
17 2
0 0

3 6174 1
2 49500 1
5 6174 1
0 0 1
1 0 1
 3 6174 1
1 862632 7
5 6174 1
0 0 1
1 0 1
 3 6174 1
2 49500 1
5 6174 1
0 0 1
2 9 5
 3 6174 1
1 862632 7
1 0 1
0 0 1
1 0 1
 3 6174 1
1 862632 7
5 6174 1
 3 6174 1
2 49500 1
9 851742 7
0 0 1
2 9 5
 3 6174 1
2 49500 1
1 0 1
0 0 1
1 0 1
 6 6174 1
2 49500 1
9 851742 7
0 0 1
2 9 5
 3 6174 1
1 862632 7
5 6174 1
1 0 1
1 0 1
 6 6174 1
5 74943 4
4 420876 7
0 0 1
2 9 5

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 getNextNumber(int n,int L) {
	char format[100];
	char buffer[100];
	int max,min;
	int i,j;
	char temp;
	sprintf(format,"%%0%dd",L);
	sprintf(buffer,format,n);
	for(i=L-1;i>0;i--) {
		for(j=0;j<i;j++) {
			if(buffer[j]<buffer[j+1]) {
				temp=buffer[j];
				buffer[j]=buffer[j+1];
				buffer[j+1]=temp;
			}
		}
	}
	sscanf(buffer,"%d",&max);
	for(i=0;i+i<L;i++) {
		temp=buffer[i];
		buffer[i]=buffer[L-i-1];
		buffer[L-i-1]=temp;
	}
	sscanf(buffer,"%d",&min);
	return max-min;
}

int main(void) {
	int a,L;
	int numbers[21];
	int i,j,found;
	while(scanf("%d%d",&a,&L)==2 && (a|L)!=0) {
		numbers[0]=a;
		for(i=1;i<21;i++)numbers[i]=getNextNumber(numbers[i-1],L);
		for(i=1;i<21;i++) {
			found=0;
			for(j=0;j<i;j++) {
				if(numbers[i]==numbers[j]) {
					found=1;
					break;
				}
			}
			if(found)break;
		}
		if(i>=21)return 1;
		printf("%d %d %d\n",j,numbers[j],i-j);
	}
	return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%%0%dd"
.LC1:
	.string	"%d"
	.text
	.globl	getNextNumber
	.type	getNextNumber, @function
getNextNumber:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$272, %rsp
	movl	%edi, -260(%rbp)
	movl	%esi, -264(%rbp)
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	-264(%rbp), %edx
	leaq	-224(%rbp), %rax
	leaq	.LC0(%rip), %rcx
	movq	%rcx, %rsi
	movq	%rax, %rdi
	movl	$0, %eax
	call	sprintf@PLT
	movl	-260(%rbp), %edx
	leaq	-224(%rbp), %rcx
	leaq	-112(%rbp), %rax
	movq	%rcx, %rsi
	movq	%rax, %rdi
	movl	$0, %eax
	call	sprintf@PLT
	movl	-264(%rbp), %eax
	subl	$1, %eax
	movl	%eax, -232(%rbp)
	jmp	.L2
.L6:
	movl	$0, -228(%rbp)
	jmp	.L3
.L5:
	movl	-228(%rbp), %eax
	cltq
	movzbl	-112(%rbp,%rax), %edx
	movl	-228(%rbp), %eax
	addl	$1, %eax
	cltq
	movzbl	-112(%rbp,%rax), %eax
	cmpb	%al, %dl
	jge	.L4
	movl	-228(%rbp), %eax
	cltq
	movzbl	-112(%rbp,%rax), %eax
	movb	%al, -241(%rbp)
	movl	-228(%rbp), %eax
	addl	$1, %eax
	cltq
	movzbl	-112(%rbp,%rax), %edx
	movl	-228(%rbp), %eax
	cltq
	movb	%dl, -112(%rbp,%rax)
	movl	-228(%rbp), %eax
	addl	$1, %eax
	cltq
	movzbl	-241(%rbp), %edx
	movb	%dl, -112(%rbp,%rax)
.L4:
	addl	$1, -228(%rbp)
.L3:
	movl	-228(%rbp), %eax
	cmpl	-232(%rbp), %eax
	jl	.L5
	subl	$1, -232(%rbp)
.L2:
	cmpl	$0, -232(%rbp)
	jg	.L6
	leaq	-240(%rbp), %rdx
	leaq	-112(%rbp), %rax
	leaq	.LC1(%rip), %rcx
	movq	%rcx, %rsi
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_sscanf@PLT
	movl	$0, -232(%rbp)
	jmp	.L7
.L8:
	movl	-232(%rbp), %eax
	cltq
	movzbl	-112(%rbp,%rax), %eax
	movb	%al, -241(%rbp)
	movl	-264(%rbp), %eax
	subl	-232(%rbp), %eax
	subl	$1, %eax
	cltq
	movzbl	-112(%rbp,%rax), %edx
	movl	-232(%rbp), %eax
	cltq
	movb	%dl, -112(%rbp,%rax)
	movl	-264(%rbp), %eax
	subl	-232(%rbp), %eax
	subl	$1, %eax
	cltq
	movzbl	-241(%rbp), %edx
	movb	%dl, -112(%rbp,%rax)
	addl	$1, -232(%rbp)
.L7:
	movl	-232(%rbp), %eax
	addl	%eax, %eax
	cmpl	%eax, -264(%rbp)
	jg	.L8
	leaq	-236(%rbp), %rdx
	leaq	-112(%rbp), %rax
	leaq	.LC1(%rip), %rcx
	movq	%rcx, %rsi
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_sscanf@PLT
	movl	-240(%rbp), %eax
	movl	-236(%rbp), %edx
	subl	%edx, %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
.LFE0:
	.size	getNextNumber, .-getNextNumber
	.section	.rodata
.LC2:
	.string	"%d %d %d\n"
.LC3:
	.string	"%d%d"
	.text
	.globl	main
	.type	main, @function
main:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	addq	$-128, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	jmp	.L12
.L26:
	movl	-116(%rbp), %eax
	movl	%eax, -96(%rbp)
	movl	$1, -108(%rbp)
	jmp	.L13
.L14:
	movl	-112(%rbp), %edx
	movl	-108(%rbp), %eax
	subl	$1, %eax
	cltq
	movl	-96(%rbp,%rax,4), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	getNextNumber
	movl	-108(%rbp), %edx
	movslq	%edx, %rdx
	movl	%eax, -96(%rbp,%rdx,4)
	addl	$1, -108(%rbp)
.L13:
	cmpl	$20, -108(%rbp)
	jle	.L14
	movl	$1, -108(%rbp)
	jmp	.L15
.L22:
	movl	$0, -100(%rbp)
	movl	$0, -104(%rbp)
	jmp	.L16
.L19:
	movl	-108(%rbp), %eax
	cltq
	movl	-96(%rbp,%rax,4), %edx
	movl	-104(%rbp), %eax
	cltq
	movl	-96(%rbp,%rax,4), %eax
	cmpl	%eax, %edx
	jne	.L17
	movl	$1, -100(%rbp)
	jmp	.L18
.L17:
	addl	$1, -104(%rbp)
.L16:
	movl	-104(%rbp), %eax
	cmpl	-108(%rbp), %eax
	jl	.L19
.L18:
	cmpl	$0, -100(%rbp)
	jne	.L29
	addl	$1, -108(%rbp)
.L15:
	cmpl	$20, -108(%rbp)
	jle	.L22
	jmp	.L21
.L29:
	nop
.L21:
	cmpl	$20, -108(%rbp)
	jle	.L23
	movl	$1, %eax
	jmp	.L27
.L23:
	movl	-108(%rbp), %eax
	subl	-104(%rbp), %eax
	movl	%eax, %ecx
	movl	-104(%rbp), %eax
	cltq
	movl	-96(%rbp,%rax,4), %edx
	movl	-104(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L12:
	leaq	-112(%rbp), %rdx
	leaq	-116(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	cmpl	$2, %eax
	jne	.L25
	movl	-116(%rbp), %edx
	movl	-112(%rbp), %eax
	orl	%edx, %eax
	testl	%eax, %eax
	jne	.L26
.L25:
	movl	$0, %eax
.L27:
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L28
	call	__stack_chk_fail@PLT
.L28:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.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	"%%0%dd"
.LC1:
	.string	"%d"
	.text
	.globl	getNextNumber
	.type	getNextNumber, @function
getNextNumber:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$272, %rsp
	movl	%edi, -260(%rbp)
	movl	%esi, -264(%rbp)
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	-264(%rbp), %edx
	leaq	-224(%rbp), %rax
	leaq	.LC0(%rip), %rcx
	movq	%rcx, %rsi
	movq	%rax, %rdi
	movl	$0, %eax
	call	sprintf@PLT
	movl	-260(%rbp), %edx
	leaq	-224(%rbp), %rcx
	leaq	-112(%rbp), %rax
	movq	%rcx, %rsi
	movq	%rax, %rdi
	movl	$0, %eax
	call	sprintf@PLT
	movl	-264(%rbp), %eax
	subl	$1, %eax
	movl	%eax, -232(%rbp)
	jmp	.L2
.L6:
	movl	$0, -228(%rbp)
	jmp	.L3
.L5:
	movl	-228(%rbp), %eax
	cltq
	movzbl	-112(%rbp,%rax), %edx
	movl	-228(%rbp), %eax
	addl	$1, %eax
	cltq
	movzbl	-112(%rbp,%rax), %eax
	cmpb	%al, %dl
	jge	.L4
	movl	-228(%rbp), %eax
	cltq
	movzbl	-112(%rbp,%rax), %eax
	movb	%al, -241(%rbp)
	movl	-228(%rbp), %eax
	addl	$1, %eax
	cltq
	movzbl	-112(%rbp,%rax), %edx
	movl	-228(%rbp), %eax
	cltq
	movb	%dl, -112(%rbp,%rax)
	movl	-228(%rbp), %eax
	addl	$1, %eax
	cltq
	movzbl	-241(%rbp), %edx
	movb	%dl, -112(%rbp,%rax)
.L4:
	addl	$1, -228(%rbp)
.L3:
	movl	-228(%rbp), %eax
	cmpl	-232(%rbp), %eax
	jl	.L5
	subl	$1, -232(%rbp)
.L2:
	cmpl	$0, -232(%rbp)
	jg	.L6
	leaq	-240(%rbp), %rdx
	leaq	-112(%rbp), %rax
	leaq	.LC1(%rip), %rcx
	movq	%rcx, %rsi
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_sscanf@PLT
	movl	$0, -232(%rbp)
	jmp	.L7
.L8:
	movl	-232(%rbp), %eax
	cltq
	movzbl	-112(%rbp,%rax), %eax
	movb	%al, -241(%rbp)
	movl	-264(%rbp), %eax
	subl	-232(%rbp), %eax
	subl	$1, %eax
	cltq
	movzbl	-112(%rbp,%rax), %edx
	movl	-232(%rbp), %eax
	cltq
	movb	%dl, -112(%rbp,%rax)
	movl	-264(%rbp), %eax
	subl	-232(%rbp), %eax
	subl	$1, %eax
	cltq
	movzbl	-241(%rbp), %edx
	movb	%dl, -112(%rbp,%rax)
	addl	$1, -232(%rbp)
.L7:
	movl	-232(%rbp), %eax
	addl	%eax, %eax
	cmpl	%eax, -264(%rbp)
	jg	.L8
	leaq	-236(%rbp), %rdx
	leaq	-112(%rbp), %rax
	leaq	.LC1(%rip), %rcx
	movq	%rcx, %rsi
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_sscanf@PLT
	movl	-240(%rbp), %eax
	movl	-236(%rbp), %edx
	subl	%edx, %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
.LFE0:
	.size	getNextNumber, .-getNextNumber
	.section	.rodata
.LC2:
	.string	"%d %d %d\n"
.LC3:
	.string	"%d%d"
	.text
	.globl	main
	.type	main, @function
main:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	addq	$-128, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	jmp	.L12
.L26:
	movl	-116(%rbp), %eax
	movl	%eax, -96(%rbp)
	movl	$1, -108(%rbp)
	jmp	.L13
.L14:
	movl	-112(%rbp), %edx
	movl	-108(%rbp), %eax
	subl	$1, %eax
	cltq
	movl	-96(%rbp,%rax,4), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	getNextNumber
	movl	-108(%rbp), %edx
	movslq	%edx, %rdx
	movl	%eax, -96(%rbp,%rdx,4)
	addl	$1, -108(%rbp)
.L13:
	cmpl	$20, -108(%rbp)
	jle	.L14
	movl	$1, -108(%rbp)
	jmp	.L15
.L22:
	movl	$0, -100(%rbp)
	movl	$0, -104(%rbp)
	jmp	.L16
.L19:
	movl	-108(%rbp), %eax
	cltq
	movl	-96(%rbp,%rax,4), %edx
	movl	-104(%rbp), %eax
	cltq
	movl	-96(%rbp,%rax,4), %eax
	cmpl	%eax, %edx
	jne	.L17
	movl	$1, -100(%rbp)
	jmp	.L18
.L17:
	addl	$1, -104(%rbp)
.L16:
	movl	-104(%rbp), %eax
	cmpl	-108(%rbp), %eax
	jl	.L19
.L18:
	cmpl	$0, -100(%rbp)
	jne	.L29
	addl	$1, -108(%rbp)
.L15:
	cmpl	$20, -108(%rbp)
	jle	.L22
	jmp	.L21
.L29:
	nop
.L21:
	cmpl	$20, -108(%rbp)
	jle	.L23
	movl	$1, %eax
	jmp	.L27
.L23:
	movl	-108(%rbp), %eax
	subl	-104(%rbp), %eax
	movl	%eax, %ecx
	movl	-104(%rbp), %eax
	cltq
	movl	-96(%rbp,%rax,4), %edx
	movl	-104(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L12:
	leaq	-112(%rbp), %rdx
	leaq	-116(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	cmpl	$2, %eax
	jne	.L25
	movl	-116(%rbp), %edx
	movl	-112(%rbp), %eax
	orl	%edx, %eax
	testl	%eax, %eax
	jne	.L26
.L25:
	movl	$0, %eax
.L27:
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L28
	call	__stack_chk_fail@PLT
.L28:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.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:
