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 get_keta(long long n);
int all_9(long long n);
int saijoui(long long n, int keta);

int main()
{
    long long n;
    int keta;

    scanf("%lld", &n);
    keta = get_keta(n);

    if(all_9(n)){
        printf("%d\n", saijoui(n, keta) + 9 * (keta-1));
    }else{
        printf("%d\n", saijoui(n, keta)-1+(keta-1) * 9);
    }
    
    return 0;
}

int get_keta(long long n)
{
    int keta = 0;
    while(n > 0) {n /= 10; keta++;}
    return keta;
}

int all_9(long long n)
{
    int cnt = 0;

    while(n > 9){
        if(n % 10 != 9) return 0;
        n /= 10;
        cnt++;
    }

    return 1;
}

int saijoui(long long n, int keta)
{
    int i;
    for(i = 0; i < keta-1; i++) n /= 10;
    return (int)n;
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%lld"
.LC1:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-16(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	-16(%rbp), %rax
	movq	%rax, %rdi
	call	get_keta
	movl	%eax, -20(%rbp)
	movq	-16(%rbp), %rax
	movq	%rax, %rdi
	call	all_9
	testl	%eax, %eax
	je	.L2
	movq	-16(%rbp), %rax
	movl	-20(%rbp), %edx
	movl	%edx, %esi
	movq	%rax, %rdi
	call	saijoui
	movl	%eax, %ecx
	movl	-20(%rbp), %eax
	leal	-1(%rax), %edx
	movl	%edx, %eax
	sall	$3, %eax
	addl	%edx, %eax
	addl	%ecx, %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L3
.L2:
	movq	-16(%rbp), %rax
	movl	-20(%rbp), %edx
	movl	%edx, %esi
	movq	%rax, %rdi
	call	saijoui
	leal	-1(%rax), %ecx
	movl	-20(%rbp), %eax
	leal	-1(%rax), %edx
	movl	%edx, %eax
	sall	$3, %eax
	addl	%edx, %eax
	addl	%ecx, %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L3:
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L5
	call	__stack_chk_fail@PLT
.L5:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.globl	get_keta
	.type	get_keta, @function
get_keta:
.LFB1:
	.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	$0, -4(%rbp)
	jmp	.L7
.L8:
	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)
	addl	$1, -4(%rbp)
.L7:
	cmpq	$0, -24(%rbp)
	jg	.L8
	movl	-4(%rbp), %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	get_keta, .-get_keta
	.globl	all_9
	.type	all_9, @function
all_9:
.LFB2:
	.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	$0, -4(%rbp)
	jmp	.L11
.L14:
	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
	cmpq	$9, %rdx
	je	.L12
	movl	$0, %eax
	jmp	.L13
.L12:
	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)
	addl	$1, -4(%rbp)
.L11:
	cmpq	$9, -24(%rbp)
	jg	.L14
	movl	$1, %eax
.L13:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2:
	.size	all_9, .-all_9
	.globl	saijoui
	.type	saijoui, @function
saijoui:
.LFB3:
	.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	$0, -4(%rbp)
	jmp	.L16
.L17:
	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)
	addl	$1, -4(%rbp)
.L16:
	movl	-28(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -4(%rbp)
	jl	.L17
	movq	-24(%rbp), %rax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE3:
	.size	saijoui, .-saijoui
	.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	"%lld"
.LC1:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	leaq	.LC0(%rip), %rdi
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	movq	%rsp, %rsi
	call	__isoc99_scanf@PLT
	movq	(%rsp), %rsi
	testq	%rsi, %rsi
	jle	.L13
	movabsq	$-3689348814741910323, %r9
	movq	%rsi, %rdx
	xorl	%r8d, %r8d
	.p2align 4,,10
	.p2align 3
.L3:
	movq	%rdx, %rax
	movq	%rdx, %rcx
	movl	%r8d, %edi
	mulq	%r9
	leal	1(%r8), %r8d
	shrq	$3, %rdx
	cmpq	$9, %rcx
	jg	.L3
	cmpq	$9, %rsi
	jle	.L4
	movabsq	$7378697629483820647, %rdx
	movq	%rsi, %rax
	imulq	%rdx
	movq	%rsi, %rax
	sarq	$63, %rax
	sarq	$2, %rdx
	subq	%rax, %rdx
	leaq	(%rdx,%rdx,4), %rax
	movq	%rsi, %rdx
	addq	%rax, %rax
	subq	%rax, %rdx
	cmpq	$9, %rdx
	jne	.L5
	movabsq	$-3689348814741910323, %r9
	movq	%rsi, %rcx
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L9:
	movq	%rcx, %rax
	mulq	%r9
	shrq	$3, %rdx
	leaq	(%rdx,%rdx,4), %rax
	movq	%rcx, %rdx
	addq	%rax, %rax
	subq	%rax, %rdx
	cmpq	$9, %rdx
	jne	.L5
.L6:
	movq	%rcx, %rax
	movq	%rcx, %r8
	mulq	%r9
	movq	%rdx, %rcx
	shrq	$3, %rcx
	cmpq	$99, %r8
	jg	.L9
.L4:
	testl	%edi, %edi
	je	.L2
	movabsq	$-3689348814741910323, %r8
	xorl	%ecx, %ecx
	.p2align 4,,10
	.p2align 3
.L10:
	movq	%rsi, %rax
	addl	$1, %ecx
	mulq	%r8
	movq	%rdx, %rsi
	shrq	$3, %rsi
	cmpl	%edi, %ecx
	jne	.L10
.L2:
	leal	(%rdi,%rdi,8), %edx
	xorl	%eax, %eax
	movl	$1, %edi
	addl	%esi, %edx
	leaq	.LC1(%rip), %rsi
	call	__printf_chk@PLT
.L11:
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L26
	xorl	%eax, %eax
	addq	$24, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 8
	ret
.L5:
	.cfi_restore_state
	movabsq	$7378697629483820647, %r8
	xorl	%ecx, %ecx
	testl	%edi, %edi
	je	.L8
	.p2align 4,,10
	.p2align 3
.L7:
	movq	%rsi, %rax
	addl	$1, %ecx
	imulq	%r8
	movq	%rsi, %rax
	sarq	$63, %rax
	sarq	$2, %rdx
	movq	%rdx, %rsi
	subq	%rax, %rsi
	cmpl	%edi, %ecx
	jne	.L7
.L8:
	leal	(%rdi,%rdi,8), %edi
	xorl	%eax, %eax
	leal	-1(%rdi,%rsi), %edx
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	call	__printf_chk@PLT
	jmp	.L11
.L13:
	orl	$-1, %edi
	jmp	.L2
.L26:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.text
	.p2align 4
	.globl	get_keta
	.type	get_keta, @function
get_keta:
.LFB24:
	.cfi_startproc
	endbr64
	movq	%rdi, %rdx
	xorl	%r8d, %r8d
	testq	%rdi, %rdi
	jle	.L27
	movabsq	$-3689348814741910323, %rsi
	.p2align 4,,10
	.p2align 3
.L29:
	movq	%rdx, %rax
	movq	%rdx, %rcx
	addl	$1, %r8d
	mulq	%rsi
	shrq	$3, %rdx
	cmpq	$9, %rcx
	jg	.L29
.L27:
	movl	%r8d, %eax
	ret
	.cfi_endproc
.LFE24:
	.size	get_keta, .-get_keta
	.p2align 4
	.globl	all_9
	.type	all_9, @function
all_9:
.LFB25:
	.cfi_startproc
	endbr64
	movq	%rdi, %rcx
	cmpq	$9, %rdi
	jle	.L36
	movabsq	$7378697629483820647, %rdx
	movq	%rdi, %rax
	imulq	%rdx
	movq	%rdi, %rax
	sarq	$63, %rax
	sarq	$2, %rdx
	subq	%rax, %rdx
	leaq	(%rdx,%rdx,4), %rax
	movq	%rdi, %rdx
	movabsq	$-3689348814741910323, %rdi
	addq	%rax, %rax
	subq	%rax, %rdx
	cmpq	$9, %rdx
	je	.L34
	jmp	.L38
	.p2align 4,,10
	.p2align 3
.L35:
	movq	%rcx, %rax
	mulq	%rdi
	shrq	$3, %rdx
	leaq	(%rdx,%rdx,4), %rax
	movq	%rcx, %rdx
	addq	%rax, %rax
	subq	%rax, %rdx
	cmpq	$9, %rdx
	jne	.L38
.L34:
	movq	%rcx, %rax
	movq	%rcx, %rsi
	mulq	%rdi
	movq	%rdx, %rcx
	shrq	$3, %rcx
	cmpq	$99, %rsi
	jg	.L35
.L36:
	movl	$1, %eax
	ret
	.p2align 4,,10
	.p2align 3
.L38:
	xorl	%eax, %eax
	ret
	.cfi_endproc
.LFE25:
	.size	all_9, .-all_9
	.p2align 4
	.globl	saijoui
	.type	saijoui, @function
saijoui:
.LFB26:
	.cfi_startproc
	endbr64
	subl	$1, %esi
	testl	%esi, %esi
	jle	.L40
	movabsq	$7378697629483820647, %r8
	xorl	%ecx, %ecx
	.p2align 4,,10
	.p2align 3
.L41:
	movq	%rdi, %rax
	addl	$1, %ecx
	imulq	%r8
	movq	%rdi, %rax
	sarq	$63, %rax
	sarq	$2, %rdx
	movq	%rdx, %rdi
	subq	%rax, %rdi
	cmpl	%esi, %ecx
	jne	.L41
.L40:
	movl	%edi, %eax
	ret
	.cfi_endproc
.LFE26:
	.size	saijoui, .-saijoui
	.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	"%lld"
.LC1:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	leaq	.LC0(%rip), %rdi
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	movq	%rsp, %rsi
	call	__isoc99_scanf@PLT
	movq	(%rsp), %rsi
	testq	%rsi, %rsi
	jle	.L13
	movabsq	$-3689348814741910323, %r9
	movq	%rsi, %rdx
	xorl	%r8d, %r8d
	.p2align 4,,10
	.p2align 3
.L3:
	movq	%rdx, %rax
	movq	%rdx, %rcx
	movl	%r8d, %edi
	mulq	%r9
	leal	1(%r8), %r8d
	shrq	$3, %rdx
	cmpq	$9, %rcx
	jg	.L3
	cmpq	$9, %rsi
	jle	.L4
	movabsq	$7378697629483820647, %rdx
	movq	%rsi, %rax
	imulq	%rdx
	movq	%rsi, %rax
	sarq	$63, %rax
	sarq	$2, %rdx
	subq	%rax, %rdx
	leaq	(%rdx,%rdx,4), %rax
	movq	%rsi, %rdx
	addq	%rax, %rax
	subq	%rax, %rdx
	cmpq	$9, %rdx
	jne	.L5
	movabsq	$-3689348814741910323, %r9
	movq	%rsi, %rcx
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L9:
	movq	%rcx, %rax
	mulq	%r9
	shrq	$3, %rdx
	leaq	(%rdx,%rdx,4), %rax
	movq	%rcx, %rdx
	addq	%rax, %rax
	subq	%rax, %rdx
	cmpq	$9, %rdx
	jne	.L5
.L6:
	movq	%rcx, %rax
	movq	%rcx, %r8
	mulq	%r9
	movq	%rdx, %rcx
	shrq	$3, %rcx
	cmpq	$99, %r8
	jg	.L9
.L4:
	testl	%edi, %edi
	je	.L2
	movabsq	$-3689348814741910323, %r8
	xorl	%ecx, %ecx
	.p2align 4,,10
	.p2align 3
.L10:
	movq	%rsi, %rax
	addl	$1, %ecx
	mulq	%r8
	movq	%rdx, %rsi
	shrq	$3, %rsi
	cmpl	%edi, %ecx
	jne	.L10
.L2:
	leal	(%rdi,%rdi,8), %edx
	xorl	%eax, %eax
	movl	$1, %edi
	addl	%esi, %edx
	leaq	.LC1(%rip), %rsi
	call	__printf_chk@PLT
.L11:
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L26
	xorl	%eax, %eax
	addq	$24, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 8
	ret
.L5:
	.cfi_restore_state
	movabsq	$7378697629483820647, %r8
	xorl	%ecx, %ecx
	testl	%edi, %edi
	je	.L8
	.p2align 4,,10
	.p2align 3
.L7:
	movq	%rsi, %rax
	addl	$1, %ecx
	imulq	%r8
	movq	%rsi, %rax
	sarq	$63, %rax
	sarq	$2, %rdx
	movq	%rdx, %rsi
	subq	%rax, %rsi
	cmpl	%edi, %ecx
	jne	.L7
.L8:
	leal	(%rdi,%rdi,8), %edi
	xorl	%eax, %eax
	leal	-1(%rdi,%rsi), %edx
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	call	__printf_chk@PLT
	jmp	.L11
.L13:
	orl	$-1, %edi
	jmp	.L2
.L26:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.text
	.p2align 4
	.globl	get_keta
	.type	get_keta, @function
get_keta:
.LFB24:
	.cfi_startproc
	endbr64
	movq	%rdi, %rdx
	xorl	%r8d, %r8d
	testq	%rdi, %rdi
	jle	.L27
	movabsq	$-3689348814741910323, %rsi
	.p2align 4,,10
	.p2align 3
.L29:
	movq	%rdx, %rax
	movq	%rdx, %rcx
	addl	$1, %r8d
	mulq	%rsi
	shrq	$3, %rdx
	cmpq	$9, %rcx
	jg	.L29
.L27:
	movl	%r8d, %eax
	ret
	.cfi_endproc
.LFE24:
	.size	get_keta, .-get_keta
	.p2align 4
	.globl	all_9
	.type	all_9, @function
all_9:
.LFB25:
	.cfi_startproc
	endbr64
	movq	%rdi, %rcx
	cmpq	$9, %rdi
	jle	.L36
	movabsq	$7378697629483820647, %rdx
	movq	%rdi, %rax
	imulq	%rdx
	movq	%rdi, %rax
	sarq	$63, %rax
	sarq	$2, %rdx
	subq	%rax, %rdx
	leaq	(%rdx,%rdx,4), %rax
	movq	%rdi, %rdx
	movabsq	$-3689348814741910323, %rdi
	addq	%rax, %rax
	subq	%rax, %rdx
	cmpq	$9, %rdx
	je	.L34
	jmp	.L38
	.p2align 4,,10
	.p2align 3
.L35:
	movq	%rcx, %rax
	mulq	%rdi
	shrq	$3, %rdx
	leaq	(%rdx,%rdx,4), %rax
	movq	%rcx, %rdx
	addq	%rax, %rax
	subq	%rax, %rdx
	cmpq	$9, %rdx
	jne	.L38
.L34:
	movq	%rcx, %rax
	movq	%rcx, %rsi
	mulq	%rdi
	movq	%rdx, %rcx
	shrq	$3, %rcx
	cmpq	$99, %rsi
	jg	.L35
.L36:
	movl	$1, %eax
	ret
	.p2align 4,,10
	.p2align 3
.L38:
	xorl	%eax, %eax
	ret
	.cfi_endproc
.LFE25:
	.size	all_9, .-all_9
	.p2align 4
	.globl	saijoui
	.type	saijoui, @function
saijoui:
.LFB26:
	.cfi_startproc
	endbr64
	subl	$1, %esi
	testl	%esi, %esi
	jle	.L40
	movabsq	$7378697629483820647, %r8
	xorl	%ecx, %ecx
	.p2align 4,,10
	.p2align 3
.L41:
	movq	%rdi, %rax
	addl	$1, %ecx
	imulq	%r8
	movq	%rdi, %rax
	sarq	$63, %rax
	sarq	$2, %rdx
	movq	%rdx, %rdi
	subq	%rax, %rdi
	cmpl	%esi, %ecx
	jne	.L41
.L40:
	movl	%edi, %eax
	ret
	.cfi_endproc
.LFE26:
	.size	saijoui, .-saijoui
	.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 get_keta(long long n);
int all_9(long long n);
int saijoui(long long n, int keta);

int main()
{
    long long n;
    int keta;

    scanf("%lld", &n);
    keta = get_keta(n);

    if(all_9(n)){
        printf("%d\n", saijoui(n, keta) + 9 * (keta-1));
    }else{
        printf("%d\n", saijoui(n, keta)-1+(keta-1) * 9);
    }
    
    return 0;
}

int get_keta(long long n)
{
    int keta = 0;
    while(n > 0) {n /= 10; keta++;}
    return keta;
}

int all_9(long long n)
{
    int cnt = 0;

    while(n > 9){
        if(n % 10 != 9) return 0;
        n /= 10;
        cnt++;
    }

    return 1;
}

int saijoui(long long n, int keta)
{
    int i;
    for(i = 0; i < keta-1; i++) n /= 10;
    return (int)n;
}

1265641936938969
 101
 613
 1180
 2005985506723837
 78
 813322357948504
 127248513971408
 46390584841058
 51

135
 18
 23
 27
 136
 15
 133
 126
 120
 13

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 get_keta(long long n);
int all_9(long long n);
int saijoui(long long n, int keta);

int main()
{
    long long n;
    int keta;

    scanf("%lld", &n);
    keta = get_keta(n);

    if(all_9(n)){
        printf("%d\n", saijoui(n, keta) + 9 * (keta-1));
    }else{
        printf("%d\n", saijoui(n, keta)-1+(keta-1) * 9);
    }
    
    return 0;
}

int get_keta(long long n)
{
    int keta = 0;
    while(n > 0) {n /= 10; keta++;}
    return keta;
}

int all_9(long long n)
{
    int cnt = 0;

    while(n > 9){
        if(n % 10 != 9) return 0;
        n /= 10;
        cnt++;
    }

    return 1;
}

int saijoui(long long n, int keta)
{
    int i;
    for(i = 0; i < keta-1; i++) n /= 10;
    return (int)n;
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%lld"
.LC1:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-16(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	-16(%rbp), %rax
	movq	%rax, %rdi
	call	get_keta
	movl	%eax, -20(%rbp)
	movq	-16(%rbp), %rax
	movq	%rax, %rdi
	call	all_9
	testl	%eax, %eax
	je	.L2
	movq	-16(%rbp), %rax
	movl	-20(%rbp), %edx
	movl	%edx, %esi
	movq	%rax, %rdi
	call	saijoui
	movl	%eax, %ecx
	movl	-20(%rbp), %eax
	leal	-1(%rax), %edx
	movl	%edx, %eax
	sall	$3, %eax
	addl	%edx, %eax
	addl	%ecx, %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L3
.L2:
	movq	-16(%rbp), %rax
	movl	-20(%rbp), %edx
	movl	%edx, %esi
	movq	%rax, %rdi
	call	saijoui
	leal	-1(%rax), %ecx
	movl	-20(%rbp), %eax
	leal	-1(%rax), %edx
	movl	%edx, %eax
	sall	$3, %eax
	addl	%edx, %eax
	addl	%ecx, %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L3:
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L5
	call	__stack_chk_fail@PLT
.L5:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.globl	get_keta
	.type	get_keta, @function
get_keta:
.LFB1:
	.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	$0, -4(%rbp)
	jmp	.L7
.L8:
	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)
	addl	$1, -4(%rbp)
.L7:
	cmpq	$0, -24(%rbp)
	jg	.L8
	movl	-4(%rbp), %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	get_keta, .-get_keta
	.globl	all_9
	.type	all_9, @function
all_9:
.LFB2:
	.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	$0, -4(%rbp)
	jmp	.L11
.L14:
	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
	cmpq	$9, %rdx
	je	.L12
	movl	$0, %eax
	jmp	.L13
.L12:
	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)
	addl	$1, -4(%rbp)
.L11:
	cmpq	$9, -24(%rbp)
	jg	.L14
	movl	$1, %eax
.L13:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2:
	.size	all_9, .-all_9
	.globl	saijoui
	.type	saijoui, @function
saijoui:
.LFB3:
	.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	$0, -4(%rbp)
	jmp	.L16
.L17:
	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)
	addl	$1, -4(%rbp)
.L16:
	movl	-28(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -4(%rbp)
	jl	.L17
	movq	-24(%rbp), %rax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE3:
	.size	saijoui, .-saijoui
	.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	"%lld"
.LC1:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-16(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	-16(%rbp), %rax
	movq	%rax, %rdi
	call	get_keta
	movl	%eax, -20(%rbp)
	movq	-16(%rbp), %rax
	movq	%rax, %rdi
	call	all_9
	testl	%eax, %eax
	je	.L2
	movq	-16(%rbp), %rax
	movl	-20(%rbp), %edx
	movl	%edx, %esi
	movq	%rax, %rdi
	call	saijoui
	movl	%eax, %ecx
	movl	-20(%rbp), %eax
	leal	-1(%rax), %edx
	movl	%edx, %eax
	sall	$3, %eax
	addl	%edx, %eax
	addl	%ecx, %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L3
.L2:
	movq	-16(%rbp), %rax
	movl	-20(%rbp), %edx
	movl	%edx, %esi
	movq	%rax, %rdi
	call	saijoui
	leal	-1(%rax), %ecx
	movl	-20(%rbp), %eax
	leal	-1(%rax), %edx
	movl	%edx, %eax
	sall	$3, %eax
	addl	%edx, %eax
	addl	%ecx, %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L3:
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L5
	call	__stack_chk_fail@PLT
.L5:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.globl	get_keta
	.type	get_keta, @function
get_keta:
.LFB1:
	.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	$0, -4(%rbp)
	jmp	.L7
.L8:
	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)
	addl	$1, -4(%rbp)
.L7:
	cmpq	$0, -24(%rbp)
	jg	.L8
	movl	-4(%rbp), %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	get_keta, .-get_keta
	.globl	all_9
	.type	all_9, @function
all_9:
.LFB2:
	.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	$0, -4(%rbp)
	jmp	.L11
.L14:
	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
	cmpq	$9, %rdx
	je	.L12
	movl	$0, %eax
	jmp	.L13
.L12:
	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)
	addl	$1, -4(%rbp)
.L11:
	cmpq	$9, -24(%rbp)
	jg	.L14
	movl	$1, %eax
.L13:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2:
	.size	all_9, .-all_9
	.globl	saijoui
	.type	saijoui, @function
saijoui:
.LFB3:
	.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	$0, -4(%rbp)
	jmp	.L16
.L17:
	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)
	addl	$1, -4(%rbp)
.L16:
	movl	-28(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -4(%rbp)
	jl	.L17
	movq	-24(%rbp), %rax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE3:
	.size	saijoui, .-saijoui
	.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:
