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>
#define int long long

int S(int a){
	int ans = 0;
	while(a > 0){
		ans += a % 10;
		a /= 10;
	}
	return ans;
}

int min(int a, int b){
	if(a * S(b) <= b * S(a)){
		return a;
	}
	else{
		return b;
	}
}

int f(int N){
	int i, j, d, lO, ans = N;
	for(i = 0, lO = 1; i < 16; i++, lO *= 10){
		d = (N / lO) % 10;
		for(j = 1; d + j <= 10; j++){
			ans = min(ans, ((N / lO) + j) * lO - 1);
		}
	}
	return ans;
}

signed main(){
	int K, N = 1, i;
	scanf("%lld", &K);
	for(i = 0; i < K; i++){
		printf("%lld\n", N);
		N = f(N + 1);
	}
	return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	S
	.type	S, @function
S:
.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, -24(%rbp)
	movq	$0, -8(%rbp)
	jmp	.L2
.L3:
	movq	-24(%rbp), %rcx
	movabsq	$7378697629483820647, %rdx
	movq	%rcx, %rax
	imulq	%rdx
	movq	%rdx, %rax
	sarq	$2, %rax
	movq	%rcx, %rsi
	sarq	$63, %rsi
	subq	%rsi, %rax
	movq	%rax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	subq	%rax, %rcx
	movq	%rcx, %rdx
	addq	%rdx, -8(%rbp)
	movq	-24(%rbp), %rcx
	movabsq	$7378697629483820647, %rdx
	movq	%rcx, %rax
	imulq	%rdx
	movq	%rdx, %rax
	sarq	$2, %rax
	sarq	$63, %rcx
	movq	%rcx, %rdx
	subq	%rdx, %rax
	movq	%rax, -24(%rbp)
.L2:
	cmpq	$0, -24(%rbp)
	jg	.L3
	movq	-8(%rbp), %rax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	S, .-S
	.globl	min
	.type	min, @function
min:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%rbx
	subq	$16, %rsp
	.cfi_offset 3, -24
	movq	%rdi, -16(%rbp)
	movq	%rsi, -24(%rbp)
	movq	-24(%rbp), %rax
	movq	%rax, %rdi
	call	S
	imulq	-16(%rbp), %rax
	movq	%rax, %rbx
	movq	-16(%rbp), %rax
	movq	%rax, %rdi
	call	S
	imulq	-24(%rbp), %rax
	cmpq	%rax, %rbx
	jg	.L6
	movq	-16(%rbp), %rax
	jmp	.L7
.L6:
	movq	-24(%rbp), %rax
.L7:
	movq	-8(%rbp), %rbx
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	min, .-min
	.globl	f
	.type	f, @function
f:
.LFB8:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$56, %rsp
	movq	%rdi, -56(%rbp)
	movq	-56(%rbp), %rax
	movq	%rax, -16(%rbp)
	movq	$0, -40(%rbp)
	movq	$1, -24(%rbp)
	jmp	.L9
.L12:
	movq	-56(%rbp), %rax
	cqto
	idivq	-24(%rbp)
	movq	%rax, %rcx
	movabsq	$7378697629483820647, %rdx
	movq	%rcx, %rax
	imulq	%rdx
	movq	%rdx, %rax
	sarq	$2, %rax
	movq	%rcx, %rdx
	sarq	$63, %rdx
	subq	%rdx, %rax
	movq	%rax, -8(%rbp)
	movq	-8(%rbp), %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	subq	%rax, %rcx
	movq	%rcx, %rdx
	movq	%rdx, -8(%rbp)
	movq	$1, -32(%rbp)
	jmp	.L10
.L11:
	movq	-56(%rbp), %rax
	cqto
	idivq	-24(%rbp)
	movq	%rax, %rdx
	movq	-32(%rbp), %rax
	addq	%rdx, %rax
	imulq	-24(%rbp), %rax
	leaq	-1(%rax), %rdx
	movq	-16(%rbp), %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	min
	movq	%rax, -16(%rbp)
	addq	$1, -32(%rbp)
.L10:
	movq	-8(%rbp), %rdx
	movq	-32(%rbp), %rax
	addq	%rdx, %rax
	cmpq	$10, %rax
	jle	.L11
	addq	$1, -40(%rbp)
	movq	-24(%rbp), %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	movq	%rax, -24(%rbp)
.L9:
	cmpq	$15, -40(%rbp)
	jle	.L12
	movq	-16(%rbp), %rax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.size	f, .-f
	.section	.rodata
.LC0:
	.string	"%lld"
.LC1:
	.string	"%lld\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	$32, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movq	$1, -24(%rbp)
	leaq	-32(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	$0, -16(%rbp)
	jmp	.L15
.L16:
	movq	-24(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movq	-24(%rbp), %rax
	addq	$1, %rax
	movq	%rax, %rdi
	call	f
	movq	%rax, -24(%rbp)
	addq	$1, -16(%rbp)
.L15:
	movq	-32(%rbp), %rax
	cmpq	%rax, -16(%rbp)
	jl	.L16
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L18
	call	__stack_chk_fail@PLT
.L18:
	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
	.p2align 4
	.globl	S
	.type	S, @function
S:
.LFB39:
	.cfi_startproc
	endbr64
	xorl	%r8d, %r8d
	testq	%rdi, %rdi
	jle	.L1
	movabsq	$-3689348814741910323, %rsi
	.p2align 4,,10
	.p2align 3
.L3:
	movq	%rdi, %rax
	movq	%rdi, %rcx
	mulq	%rsi
	shrq	$3, %rdx
	leaq	(%rdx,%rdx,4), %rax
	addq	%rax, %rax
	subq	%rax, %rcx
	movq	%rdi, %rax
	movq	%rdx, %rdi
	addq	%rcx, %r8
	cmpq	$9, %rax
	jg	.L3
.L1:
	movq	%r8, %rax
	ret
	.cfi_endproc
.LFE39:
	.size	S, .-S
	.p2align 4
	.globl	min
	.type	min, @function
min:
.LFB40:
	.cfi_startproc
	endbr64
	movq	%rsi, %r8
	testq	%rsi, %rsi
	jle	.L8
	movabsq	$-3689348814741910323, %r10
	movq	%rsi, %rcx
	xorl	%esi, %esi
	.p2align 4,,10
	.p2align 3
.L9:
	movq	%rcx, %rax
	movq	%rcx, %r9
	mulq	%r10
	shrq	$3, %rdx
	leaq	(%rdx,%rdx,4), %rax
	addq	%rax, %rax
	subq	%rax, %r9
	movq	%rcx, %rax
	movq	%rdx, %rcx
	addq	%r9, %rsi
	cmpq	$9, %rax
	jg	.L9
	imulq	%rdi, %rsi
	movq	%rsi, %r9
	testq	%rdi, %rdi
	jle	.L14
.L13:
	movabsq	$-3689348814741910323, %r11
	movq	%rdi, %rcx
	xorl	%esi, %esi
	.p2align 4,,10
	.p2align 3
.L11:
	movq	%rcx, %rax
	movq	%rcx, %r10
	mulq	%r11
	shrq	$3, %rdx
	leaq	(%rdx,%rdx,4), %rax
	addq	%rax, %rax
	subq	%rax, %r10
	movq	%rcx, %rax
	movq	%rdx, %rcx
	addq	%r10, %rsi
	cmpq	$9, %rax
	jg	.L11
	imulq	%r8, %rsi
.L10:
	cmpq	%rsi, %r9
	movq	%r8, %rax
	cmovle	%rdi, %rax
	ret
	.p2align 4,,10
	.p2align 3
.L8:
	xorl	%r9d, %r9d
	testq	%rdi, %rdi
	jg	.L13
	movq	%rdi, %rax
	ret
	.p2align 4,,10
	.p2align 3
.L14:
	xorl	%esi, %esi
	jmp	.L10
	.cfi_endproc
.LFE40:
	.size	min, .-min
	.p2align 4
	.globl	f
	.type	f, @function
f:
.LFB41:
	.cfi_startproc
	endbr64
	movabsq	$-3689348814741910323, %r8
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movq	%rdi, %r10
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movabsq	$7378697629483820647, %r14
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movl	$11, %r13d
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movl	$16, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movl	$1, %ebx
	movq	%rdi, -8(%rsp)
	.p2align 4,,10
	.p2align 3
.L26:
	movq	-8(%rsp), %rax
	movq	%r13, %rbp
	movl	$1, %r11d
	cqto
	idivq	%rbx
	movq	%rax, %rcx
	leaq	1(%rax), %r9
	imulq	%r14
	movq	%rcx, %rax
	sarq	$63, %rax
	imulq	%rbx, %r9
	sarq	$2, %rdx
	subq	%rax, %rdx
	subq	$1, %r9
	leaq	(%rdx,%rdx,4), %rax
	addq	%rax, %rax
	subq	%rax, %rcx
	subq	%rcx, %rbp
	.p2align 4,,10
	.p2align 3
.L25:
	testq	%r9, %r9
	jle	.L20
	movq	%r9, %rcx
	xorl	%esi, %esi
	.p2align 4,,10
	.p2align 3
.L21:
	movq	%rcx, %rax
	movq	%rcx, %rdi
	mulq	%r8
	shrq	$3, %rdx
	leaq	(%rdx,%rdx,4), %rax
	addq	%rax, %rax
	subq	%rax, %rdi
	movq	%rcx, %rax
	movq	%rdx, %rcx
	addq	%rdi, %rsi
	cmpq	$9, %rax
	jg	.L21
	imulq	%r10, %rsi
	testq	%r10, %r10
	jle	.L28
.L27:
	movq	%r10, %rcx
	xorl	%edi, %edi
	.p2align 4,,10
	.p2align 3
.L23:
	movq	%rcx, %rax
	movq	%rcx, %r15
	mulq	%r8
	shrq	$3, %rdx
	leaq	(%rdx,%rdx,4), %rax
	addq	%rax, %rax
	subq	%rax, %r15
	movq	%rcx, %rax
	movq	%rdx, %rcx
	addq	%r15, %rdi
	cmpq	$9, %rax
	jg	.L23
	imulq	%r9, %rdi
.L22:
	cmpq	%rdi, %rsi
	cmovg	%r9, %r10
.L24:
	addq	$1, %r11
	addq	%rbx, %r9
	cmpq	%rbp, %r11
	jne	.L25
	leaq	(%rbx,%rbx,4), %rbx
	addq	%rbx, %rbx
	subq	$1, %r12
	jne	.L26
	popq	%rbx
	.cfi_remember_state
	.cfi_def_cfa_offset 48
	movq	%r10, %rax
	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
.L20:
	.cfi_restore_state
	xorl	%esi, %esi
	testq	%r10, %r10
	jg	.L27
	jmp	.L24
	.p2align 4,,10
	.p2align 3
.L28:
	xorl	%edi, %edi
	jmp	.L22
	.cfi_endproc
.LFE41:
	.size	f, .-f
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%lld"
.LC1:
	.string	"%lld\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
	leaq	.LC0(%rip), %rdi
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movabsq	$-3689348814741910323, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movl	$1, %ebx
	subq	$40, %rsp
	.cfi_def_cfa_offset 96
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	leaq	16(%rsp), %rsi
	call	__isoc99_scanf@PLT
	cmpq	$0, 16(%rsp)
	movq	$0, 8(%rsp)
	jle	.L45
.L37:
	movq	%rbx, %rdx
	movl	$1, %edi
	xorl	%eax, %eax
	movl	$16, %ebp
	leaq	.LC1(%rip), %rsi
	movl	$11, %r13d
	movabsq	$7378697629483820647, %r14
	call	__printf_chk@PLT
	leaq	1(%rbx), %rax
	movl	$1, %r10d
	movq	%rax, (%rsp)
	movq	%rax, %rbx
	.p2align 4,,10
	.p2align 3
.L44:
	movq	(%rsp), %rax
	movq	%r13, %r11
	movl	$1, %r8d
	cqto
	idivq	%r10
	movq	%rax, %rsi
	leaq	1(%rax), %rcx
	imulq	%r14
	movq	%rsi, %rax
	sarq	$63, %rax
	imulq	%r10, %rcx
	sarq	$2, %rdx
	subq	%rax, %rdx
	subq	$1, %rcx
	leaq	(%rdx,%rdx,4), %rax
	addq	%rax, %rax
	subq	%rax, %rsi
	subq	%rsi, %r11
	.p2align 4,,10
	.p2align 3
.L43:
	testq	%rcx, %rcx
	jle	.L38
	movq	%rcx, %rdi
	xorl	%esi, %esi
	.p2align 4,,10
	.p2align 3
.L39:
	movq	%rdi, %rax
	movq	%rdi, %r9
	mulq	%r12
	shrq	$3, %rdx
	leaq	(%rdx,%rdx,4), %rax
	addq	%rax, %rax
	subq	%rax, %r9
	movq	%rdi, %rax
	movq	%rdx, %rdi
	addq	%r9, %rsi
	cmpq	$9, %rax
	jg	.L39
	movq	%rsi, %rdi
	imulq	%rbx, %rdi
	testq	%rbx, %rbx
	jle	.L49
.L46:
	movq	%rbx, %r9
	xorl	%esi, %esi
	.p2align 4,,10
	.p2align 3
.L41:
	movq	%r9, %rax
	movq	%r9, %r15
	mulq	%r12
	shrq	$3, %rdx
	leaq	(%rdx,%rdx,4), %rax
	addq	%rax, %rax
	subq	%rax, %r15
	movq	%r9, %rax
	movq	%rdx, %r9
	addq	%r15, %rsi
	cmpq	$9, %rax
	jg	.L41
	imulq	%rcx, %rsi
.L40:
	cmpq	%rsi, %rdi
	cmovg	%rcx, %rbx
.L42:
	addq	$1, %r8
	addq	%r10, %rcx
	cmpq	%r11, %r8
	jne	.L43
	leaq	(%r10,%r10,4), %r10
	addq	%r10, %r10
	subq	$1, %rbp
	jne	.L44
	addq	$1, 8(%rsp)
	movq	8(%rsp), %rax
	cmpq	%rax, 16(%rsp)
	jg	.L37
.L45:
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L61
	addq	$40, %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
.L38:
	.cfi_restore_state
	xorl	%edi, %edi
	testq	%rbx, %rbx
	jg	.L46
	jmp	.L42
	.p2align 4,,10
	.p2align 3
.L49:
	xorl	%esi, %esi
	jmp	.L40
.L61:
	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
	.p2align 4
	.globl	S
	.type	S, @function
S:
.LFB39:
	.cfi_startproc
	endbr64
	xorl	%r8d, %r8d
	testq	%rdi, %rdi
	jle	.L1
	movabsq	$-3689348814741910323, %rsi
	.p2align 4,,10
	.p2align 3
.L3:
	movq	%rdi, %rax
	movq	%rdi, %rcx
	mulq	%rsi
	shrq	$3, %rdx
	leaq	(%rdx,%rdx,4), %rax
	addq	%rax, %rax
	subq	%rax, %rcx
	movq	%rdi, %rax
	movq	%rdx, %rdi
	addq	%rcx, %r8
	cmpq	$9, %rax
	jg	.L3
.L1:
	movq	%r8, %rax
	ret
	.cfi_endproc
.LFE39:
	.size	S, .-S
	.p2align 4
	.globl	min
	.type	min, @function
min:
.LFB40:
	.cfi_startproc
	endbr64
	movq	%rsi, %r8
	testq	%rsi, %rsi
	jle	.L8
	movabsq	$-3689348814741910323, %r10
	movq	%rsi, %rcx
	xorl	%esi, %esi
	.p2align 4,,10
	.p2align 3
.L9:
	movq	%rcx, %rax
	movq	%rcx, %r9
	mulq	%r10
	shrq	$3, %rdx
	leaq	(%rdx,%rdx,4), %rax
	addq	%rax, %rax
	subq	%rax, %r9
	movq	%rcx, %rax
	movq	%rdx, %rcx
	addq	%r9, %rsi
	cmpq	$9, %rax
	jg	.L9
	imulq	%rdi, %rsi
	movq	%rsi, %r9
	testq	%rdi, %rdi
	jle	.L14
.L13:
	movabsq	$-3689348814741910323, %r11
	movq	%rdi, %rcx
	xorl	%esi, %esi
	.p2align 4,,10
	.p2align 3
.L11:
	movq	%rcx, %rax
	movq	%rcx, %r10
	mulq	%r11
	shrq	$3, %rdx
	leaq	(%rdx,%rdx,4), %rax
	addq	%rax, %rax
	subq	%rax, %r10
	movq	%rcx, %rax
	movq	%rdx, %rcx
	addq	%r10, %rsi
	cmpq	$9, %rax
	jg	.L11
	imulq	%r8, %rsi
.L10:
	cmpq	%rsi, %r9
	movq	%r8, %rax
	cmovle	%rdi, %rax
	ret
	.p2align 4,,10
	.p2align 3
.L8:
	xorl	%r9d, %r9d
	testq	%rdi, %rdi
	jg	.L13
	movq	%rdi, %rax
	ret
	.p2align 4,,10
	.p2align 3
.L14:
	xorl	%esi, %esi
	jmp	.L10
	.cfi_endproc
.LFE40:
	.size	min, .-min
	.p2align 4
	.globl	f
	.type	f, @function
f:
.LFB41:
	.cfi_startproc
	endbr64
	movabsq	$-3689348814741910323, %r8
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movq	%rdi, %r10
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movabsq	$7378697629483820647, %r14
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movl	$11, %r13d
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movl	$16, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movl	$1, %ebx
	movq	%rdi, -8(%rsp)
	.p2align 4,,10
	.p2align 3
.L26:
	movq	-8(%rsp), %rax
	movq	%r13, %rbp
	movl	$1, %r11d
	cqto
	idivq	%rbx
	movq	%rax, %rcx
	leaq	1(%rax), %r9
	imulq	%r14
	movq	%rcx, %rax
	sarq	$63, %rax
	imulq	%rbx, %r9
	sarq	$2, %rdx
	subq	%rax, %rdx
	subq	$1, %r9
	leaq	(%rdx,%rdx,4), %rax
	addq	%rax, %rax
	subq	%rax, %rcx
	subq	%rcx, %rbp
	.p2align 4,,10
	.p2align 3
.L25:
	testq	%r9, %r9
	jle	.L20
	movq	%r9, %rcx
	xorl	%esi, %esi
	.p2align 4,,10
	.p2align 3
.L21:
	movq	%rcx, %rax
	movq	%rcx, %rdi
	mulq	%r8
	shrq	$3, %rdx
	leaq	(%rdx,%rdx,4), %rax
	addq	%rax, %rax
	subq	%rax, %rdi
	movq	%rcx, %rax
	movq	%rdx, %rcx
	addq	%rdi, %rsi
	cmpq	$9, %rax
	jg	.L21
	imulq	%r10, %rsi
	testq	%r10, %r10
	jle	.L28
.L27:
	movq	%r10, %rcx
	xorl	%edi, %edi
	.p2align 4,,10
	.p2align 3
.L23:
	movq	%rcx, %rax
	movq	%rcx, %r15
	mulq	%r8
	shrq	$3, %rdx
	leaq	(%rdx,%rdx,4), %rax
	addq	%rax, %rax
	subq	%rax, %r15
	movq	%rcx, %rax
	movq	%rdx, %rcx
	addq	%r15, %rdi
	cmpq	$9, %rax
	jg	.L23
	imulq	%r9, %rdi
.L22:
	cmpq	%rdi, %rsi
	cmovg	%r9, %r10
.L24:
	addq	$1, %r11
	addq	%rbx, %r9
	cmpq	%rbp, %r11
	jne	.L25
	leaq	(%rbx,%rbx,4), %rbx
	addq	%rbx, %rbx
	subq	$1, %r12
	jne	.L26
	popq	%rbx
	.cfi_remember_state
	.cfi_def_cfa_offset 48
	movq	%r10, %rax
	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
.L20:
	.cfi_restore_state
	xorl	%esi, %esi
	testq	%r10, %r10
	jg	.L27
	jmp	.L24
	.p2align 4,,10
	.p2align 3
.L28:
	xorl	%edi, %edi
	jmp	.L22
	.cfi_endproc
.LFE41:
	.size	f, .-f
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%lld"
.LC1:
	.string	"%lld\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
	leaq	.LC0(%rip), %rdi
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movabsq	$-3689348814741910323, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movl	$1, %ebx
	subq	$40, %rsp
	.cfi_def_cfa_offset 96
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	leaq	16(%rsp), %rsi
	call	__isoc99_scanf@PLT
	cmpq	$0, 16(%rsp)
	movq	$0, 8(%rsp)
	jle	.L45
.L37:
	movq	%rbx, %rdx
	movl	$1, %edi
	xorl	%eax, %eax
	movl	$16, %ebp
	leaq	.LC1(%rip), %rsi
	movl	$11, %r13d
	movabsq	$7378697629483820647, %r14
	call	__printf_chk@PLT
	leaq	1(%rbx), %rax
	movl	$1, %r10d
	movq	%rax, (%rsp)
	movq	%rax, %rbx
	.p2align 4,,10
	.p2align 3
.L44:
	movq	(%rsp), %rax
	movq	%r13, %r11
	movl	$1, %r8d
	cqto
	idivq	%r10
	movq	%rax, %rsi
	leaq	1(%rax), %rcx
	imulq	%r14
	movq	%rsi, %rax
	sarq	$63, %rax
	imulq	%r10, %rcx
	sarq	$2, %rdx
	subq	%rax, %rdx
	subq	$1, %rcx
	leaq	(%rdx,%rdx,4), %rax
	addq	%rax, %rax
	subq	%rax, %rsi
	subq	%rsi, %r11
	.p2align 4,,10
	.p2align 3
.L43:
	testq	%rcx, %rcx
	jle	.L38
	movq	%rcx, %rdi
	xorl	%esi, %esi
	.p2align 4,,10
	.p2align 3
.L39:
	movq	%rdi, %rax
	movq	%rdi, %r9
	mulq	%r12
	shrq	$3, %rdx
	leaq	(%rdx,%rdx,4), %rax
	addq	%rax, %rax
	subq	%rax, %r9
	movq	%rdi, %rax
	movq	%rdx, %rdi
	addq	%r9, %rsi
	cmpq	$9, %rax
	jg	.L39
	movq	%rsi, %rdi
	imulq	%rbx, %rdi
	testq	%rbx, %rbx
	jle	.L49
.L46:
	movq	%rbx, %r9
	xorl	%esi, %esi
	.p2align 4,,10
	.p2align 3
.L41:
	movq	%r9, %rax
	movq	%r9, %r15
	mulq	%r12
	shrq	$3, %rdx
	leaq	(%rdx,%rdx,4), %rax
	addq	%rax, %rax
	subq	%rax, %r15
	movq	%r9, %rax
	movq	%rdx, %r9
	addq	%r15, %rsi
	cmpq	$9, %rax
	jg	.L41
	imulq	%rcx, %rsi
.L40:
	cmpq	%rsi, %rdi
	cmovg	%rcx, %rbx
.L42:
	addq	$1, %r8
	addq	%r10, %rcx
	cmpq	%r11, %r8
	jne	.L43
	leaq	(%r10,%r10,4), %r10
	addq	%r10, %r10
	subq	$1, %rbp
	jne	.L44
	addq	$1, 8(%rsp)
	movq	8(%rsp), %rax
	cmpq	%rax, 16(%rsp)
	jg	.L37
.L45:
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L61
	addq	$40, %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
.L38:
	.cfi_restore_state
	xorl	%edi, %edi
	testq	%rbx, %rbx
	jg	.L46
	jmp	.L42
	.p2align 4,,10
	.p2align 3
.L49:
	xorl	%esi, %esi
	jmp	.L40
.L61:
	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>
#define int long long

int S(int a){
	int ans = 0;
	while(a > 0){
		ans += a % 10;
		a /= 10;
	}
	return ans;
}

int min(int a, int b){
	if(a * S(b) <= b * S(a)){
		return a;
	}
	else{
		return b;
	}
}

int f(int N){
	int i, j, d, lO, ans = N;
	for(i = 0, lO = 1; i < 16; i++, lO *= 10){
		d = (N / lO) % 10;
		for(j = 1; d + j <= 10; j++){
			ans = min(ans, ((N / lO) + j) * lO - 1);
		}
	}
	return ans;
}

signed main(){
	int K, N = 1, i;
	scanf("%lld", &K);
	for(i = 0; i < K; i++){
		printf("%lld\n", N);
		N = f(N + 1);
	}
	return 0;
}
10

1
2
3
4
5
6
7
8
9
19

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>
#define int long long

int S(int a){
	int ans = 0;
	while(a > 0){
		ans += a % 10;
		a /= 10;
	}
	return ans;
}

int min(int a, int b){
	if(a * S(b) <= b * S(a)){
		return a;
	}
	else{
		return b;
	}
}

int f(int N){
	int i, j, d, lO, ans = N;
	for(i = 0, lO = 1; i < 16; i++, lO *= 10){
		d = (N / lO) % 10;
		for(j = 1; d + j <= 10; j++){
			ans = min(ans, ((N / lO) + j) * lO - 1);
		}
	}
	return ans;
}

signed main(){
	int K, N = 1, i;
	scanf("%lld", &K);
	for(i = 0; i < K; i++){
		printf("%lld\n", N);
		N = f(N + 1);
	}
	return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	S
	.type	S, @function
S:
.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, -24(%rbp)
	movq	$0, -8(%rbp)
	jmp	.L2
.L3:
	movq	-24(%rbp), %rcx
	movabsq	$7378697629483820647, %rdx
	movq	%rcx, %rax
	imulq	%rdx
	movq	%rdx, %rax
	sarq	$2, %rax
	movq	%rcx, %rsi
	sarq	$63, %rsi
	subq	%rsi, %rax
	movq	%rax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	subq	%rax, %rcx
	movq	%rcx, %rdx
	addq	%rdx, -8(%rbp)
	movq	-24(%rbp), %rcx
	movabsq	$7378697629483820647, %rdx
	movq	%rcx, %rax
	imulq	%rdx
	movq	%rdx, %rax
	sarq	$2, %rax
	sarq	$63, %rcx
	movq	%rcx, %rdx
	subq	%rdx, %rax
	movq	%rax, -24(%rbp)
.L2:
	cmpq	$0, -24(%rbp)
	jg	.L3
	movq	-8(%rbp), %rax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	S, .-S
	.globl	min
	.type	min, @function
min:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%rbx
	subq	$16, %rsp
	.cfi_offset 3, -24
	movq	%rdi, -16(%rbp)
	movq	%rsi, -24(%rbp)
	movq	-24(%rbp), %rax
	movq	%rax, %rdi
	call	S
	imulq	-16(%rbp), %rax
	movq	%rax, %rbx
	movq	-16(%rbp), %rax
	movq	%rax, %rdi
	call	S
	imulq	-24(%rbp), %rax
	cmpq	%rax, %rbx
	jg	.L6
	movq	-16(%rbp), %rax
	jmp	.L7
.L6:
	movq	-24(%rbp), %rax
.L7:
	movq	-8(%rbp), %rbx
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	min, .-min
	.globl	f
	.type	f, @function
f:
.LFB8:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$56, %rsp
	movq	%rdi, -56(%rbp)
	movq	-56(%rbp), %rax
	movq	%rax, -16(%rbp)
	movq	$0, -40(%rbp)
	movq	$1, -24(%rbp)
	jmp	.L9
.L12:
	movq	-56(%rbp), %rax
	cqto
	idivq	-24(%rbp)
	movq	%rax, %rcx
	movabsq	$7378697629483820647, %rdx
	movq	%rcx, %rax
	imulq	%rdx
	movq	%rdx, %rax
	sarq	$2, %rax
	movq	%rcx, %rdx
	sarq	$63, %rdx
	subq	%rdx, %rax
	movq	%rax, -8(%rbp)
	movq	-8(%rbp), %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	subq	%rax, %rcx
	movq	%rcx, %rdx
	movq	%rdx, -8(%rbp)
	movq	$1, -32(%rbp)
	jmp	.L10
.L11:
	movq	-56(%rbp), %rax
	cqto
	idivq	-24(%rbp)
	movq	%rax, %rdx
	movq	-32(%rbp), %rax
	addq	%rdx, %rax
	imulq	-24(%rbp), %rax
	leaq	-1(%rax), %rdx
	movq	-16(%rbp), %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	min
	movq	%rax, -16(%rbp)
	addq	$1, -32(%rbp)
.L10:
	movq	-8(%rbp), %rdx
	movq	-32(%rbp), %rax
	addq	%rdx, %rax
	cmpq	$10, %rax
	jle	.L11
	addq	$1, -40(%rbp)
	movq	-24(%rbp), %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	movq	%rax, -24(%rbp)
.L9:
	cmpq	$15, -40(%rbp)
	jle	.L12
	movq	-16(%rbp), %rax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.size	f, .-f
	.section	.rodata
.LC0:
	.string	"%lld"
.LC1:
	.string	"%lld\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	$32, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movq	$1, -24(%rbp)
	leaq	-32(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	$0, -16(%rbp)
	jmp	.L15
.L16:
	movq	-24(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movq	-24(%rbp), %rax
	addq	$1, %rax
	movq	%rax, %rdi
	call	f
	movq	%rax, -24(%rbp)
	addq	$1, -16(%rbp)
.L15:
	movq	-32(%rbp), %rax
	cmpq	%rax, -16(%rbp)
	jl	.L16
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L18
	call	__stack_chk_fail@PLT
.L18:
	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
	.globl	S
	.type	S, @function
S:
.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, -24(%rbp)
	movq	$0, -8(%rbp)
	jmp	.L2
.L3:
	movq	-24(%rbp), %rcx
	movabsq	$7378697629483820647, %rdx
	movq	%rcx, %rax
	imulq	%rdx
	movq	%rdx, %rax
	sarq	$2, %rax
	movq	%rcx, %rsi
	sarq	$63, %rsi
	subq	%rsi, %rax
	movq	%rax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	subq	%rax, %rcx
	movq	%rcx, %rdx
	addq	%rdx, -8(%rbp)
	movq	-24(%rbp), %rcx
	movabsq	$7378697629483820647, %rdx
	movq	%rcx, %rax
	imulq	%rdx
	movq	%rdx, %rax
	sarq	$2, %rax
	sarq	$63, %rcx
	movq	%rcx, %rdx
	subq	%rdx, %rax
	movq	%rax, -24(%rbp)
.L2:
	cmpq	$0, -24(%rbp)
	jg	.L3
	movq	-8(%rbp), %rax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	S, .-S
	.globl	min
	.type	min, @function
min:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%rbx
	subq	$16, %rsp
	.cfi_offset 3, -24
	movq	%rdi, -16(%rbp)
	movq	%rsi, -24(%rbp)
	movq	-24(%rbp), %rax
	movq	%rax, %rdi
	call	S
	imulq	-16(%rbp), %rax
	movq	%rax, %rbx
	movq	-16(%rbp), %rax
	movq	%rax, %rdi
	call	S
	imulq	-24(%rbp), %rax
	cmpq	%rax, %rbx
	jg	.L6
	movq	-16(%rbp), %rax
	jmp	.L7
.L6:
	movq	-24(%rbp), %rax
.L7:
	movq	-8(%rbp), %rbx
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	min, .-min
	.globl	f
	.type	f, @function
f:
.LFB8:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$56, %rsp
	movq	%rdi, -56(%rbp)
	movq	-56(%rbp), %rax
	movq	%rax, -16(%rbp)
	movq	$0, -40(%rbp)
	movq	$1, -24(%rbp)
	jmp	.L9
.L12:
	movq	-56(%rbp), %rax
	cqto
	idivq	-24(%rbp)
	movq	%rax, %rcx
	movabsq	$7378697629483820647, %rdx
	movq	%rcx, %rax
	imulq	%rdx
	movq	%rdx, %rax
	sarq	$2, %rax
	movq	%rcx, %rdx
	sarq	$63, %rdx
	subq	%rdx, %rax
	movq	%rax, -8(%rbp)
	movq	-8(%rbp), %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	subq	%rax, %rcx
	movq	%rcx, %rdx
	movq	%rdx, -8(%rbp)
	movq	$1, -32(%rbp)
	jmp	.L10
.L11:
	movq	-56(%rbp), %rax
	cqto
	idivq	-24(%rbp)
	movq	%rax, %rdx
	movq	-32(%rbp), %rax
	addq	%rdx, %rax
	imulq	-24(%rbp), %rax
	leaq	-1(%rax), %rdx
	movq	-16(%rbp), %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	min
	movq	%rax, -16(%rbp)
	addq	$1, -32(%rbp)
.L10:
	movq	-8(%rbp), %rdx
	movq	-32(%rbp), %rax
	addq	%rdx, %rax
	cmpq	$10, %rax
	jle	.L11
	addq	$1, -40(%rbp)
	movq	-24(%rbp), %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	movq	%rax, -24(%rbp)
.L9:
	cmpq	$15, -40(%rbp)
	jle	.L12
	movq	-16(%rbp), %rax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.size	f, .-f
	.section	.rodata
.LC0:
	.string	"%lld"
.LC1:
	.string	"%lld\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	$32, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movq	$1, -24(%rbp)
	leaq	-32(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	$0, -16(%rbp)
	jmp	.L15
.L16:
	movq	-24(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movq	-24(%rbp), %rax
	addq	$1, %rax
	movq	%rax, %rdi
	call	f
	movq	%rax, -24(%rbp)
	addq	$1, -16(%rbp)
.L15:
	movq	-32(%rbp), %rax
	cmpq	%rax, -16(%rbp)
	jl	.L16
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L18
	call	__stack_chk_fail@PLT
.L18:
	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:
