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<math.h>
 
int main(){
  long n,i=0,flag=0,j;
  scanf("%ld",&n);
  if(n!=0)
  i=(int)log10(n);
  j=pow(10.0,i);
  if(n/j!=(n+1)/j) flag=1;
  n/=j;
  if(!i) printf("%ld\n",n);
  else printf("%ld\t",i*9-1+flag+n);
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%ld"
.LC2:
	.string	"%ld\n"
.LC3:
	.string	"%ld\t"
	.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	$48, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movq	$0, -32(%rbp)
	movq	$0, -24(%rbp)
	leaq	-40(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	-40(%rbp), %rax
	testq	%rax, %rax
	je	.L2
	movq	-40(%rbp), %rax
	pxor	%xmm2, %xmm2
	cvtsi2sdq	%rax, %xmm2
	movq	%xmm2, %rax
	movq	%rax, %xmm0
	call	log10@PLT
	cvttsd2sil	%xmm0, %eax
	cltq
	movq	%rax, -32(%rbp)
.L2:
	pxor	%xmm0, %xmm0
	cvtsi2sdq	-32(%rbp), %xmm0
	movq	.LC1(%rip), %rax
	movapd	%xmm0, %xmm1
	movq	%rax, %xmm0
	call	pow@PLT
	cvttsd2siq	%xmm0, %rax
	movq	%rax, -16(%rbp)
	movq	-40(%rbp), %rax
	cqto
	idivq	-16(%rbp)
	movq	%rax, %rcx
	movq	-40(%rbp), %rax
	addq	$1, %rax
	cqto
	idivq	-16(%rbp)
	cmpq	%rax, %rcx
	je	.L3
	movq	$1, -24(%rbp)
.L3:
	movq	-40(%rbp), %rax
	cqto
	idivq	-16(%rbp)
	movq	%rax, -40(%rbp)
	cmpq	$0, -32(%rbp)
	jne	.L4
	movq	-40(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L5
.L4:
	movq	-32(%rbp), %rdx
	movq	%rdx, %rax
	salq	$3, %rax
	addq	%rdx, %rax
	leaq	-1(%rax), %rdx
	movq	-24(%rbp), %rax
	addq	%rax, %rdx
	movq	-40(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L5:
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L7
	call	__stack_chk_fail@PLT
.L7:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.section	.rodata
	.align 8
.LC1:
	.long	0
	.long	1076101120
	.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	"%ld"
.LC2:
	.string	"%ld\n"
.LC3:
	.string	"%ld\t"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	leaq	.LC0(%rip), %rdi
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	subq	$24, %rsp
	.cfi_def_cfa_offset 48
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	movq	%rsp, %rsi
	call	__isoc99_scanf@PLT
	movq	(%rsp), %r12
	testq	%r12, %r12
	jne	.L11
.L2:
	movq	%r12, %rdx
	leaq	.LC2(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L4:
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L12
	addq	$24, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 24
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
.L11:
	.cfi_restore_state
	pxor	%xmm0, %xmm0
	cvtsi2sdq	%r12, %xmm0
	call	log10@PLT
	pxor	%xmm1, %xmm1
	cvttsd2sil	%xmm0, %eax
	movsd	.LC1(%rip), %xmm0
	cvtsi2sdl	%eax, %xmm1
	movslq	%eax, %rbx
	call	pow@PLT
	movq	%r12, %rax
	cvttsd2siq	%xmm0, %rcx
	cqto
	idivq	%rcx
	movq	%rax, %rsi
	leaq	1(%r12), %rax
	cqto
	movq	%rsi, (%rsp)
	idivq	%rcx
	cmpq	%rsi, %rax
	setne	%al
	movzbl	%al, %eax
	testq	%rbx, %rbx
	je	.L13
	leaq	(%rbx,%rbx,8), %rbx
	movl	$1, %edi
	leaq	-1(%rax,%rbx), %rdx
	xorl	%eax, %eax
	addq	%rsi, %rdx
	leaq	.LC3(%rip), %rsi
	call	__printf_chk@PLT
	jmp	.L4
.L12:
	call	__stack_chk_fail@PLT
.L13:
	movq	%rsi, %r12
	jmp	.L2
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC1:
	.long	0
	.long	1076101120
	.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	"%ld"
.LC2:
	.string	"%ld\n"
.LC3:
	.string	"%ld\t"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	leaq	.LC0(%rip), %rdi
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	subq	$24, %rsp
	.cfi_def_cfa_offset 48
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	movq	%rsp, %rsi
	call	__isoc99_scanf@PLT
	movq	(%rsp), %r12
	testq	%r12, %r12
	jne	.L11
.L2:
	movq	%r12, %rdx
	leaq	.LC2(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L4:
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L12
	addq	$24, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 24
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
.L11:
	.cfi_restore_state
	pxor	%xmm0, %xmm0
	cvtsi2sdq	%r12, %xmm0
	call	log10@PLT
	pxor	%xmm1, %xmm1
	cvttsd2sil	%xmm0, %eax
	movsd	.LC1(%rip), %xmm0
	cvtsi2sdl	%eax, %xmm1
	movslq	%eax, %rbx
	call	pow@PLT
	movq	%r12, %rax
	cvttsd2siq	%xmm0, %rcx
	cqto
	idivq	%rcx
	movq	%rax, %rsi
	leaq	1(%r12), %rax
	cqto
	movq	%rsi, (%rsp)
	idivq	%rcx
	cmpq	%rsi, %rax
	setne	%al
	movzbl	%al, %eax
	testq	%rbx, %rbx
	je	.L13
	leaq	(%rbx,%rbx,8), %rbx
	movl	$1, %edi
	leaq	-1(%rax,%rbx), %rdx
	xorl	%eax, %eax
	addq	%rsi, %rdx
	leaq	.LC3(%rip), %rsi
	call	__printf_chk@PLT
	jmp	.L4
.L12:
	call	__stack_chk_fail@PLT
.L13:
	movq	%rsi, %r12
	jmp	.L2
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC1:
	.long	0
	.long	1076101120
	.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<math.h>
 
int main(){
  long n,i=0,flag=0,j;
  scanf("%ld",&n);
  if(n!=0)
  i=(int)log10(n);
  j=pow(10.0,i);
  if(n/j!=(n+1)/j) flag=1;
  n/=j;
  if(!i) printf("%ld\n",n);
  else printf("%ld\t",i*9-1+flag+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>
#include<math.h>
 
int main(){
  long n,i=0,flag=0,j;
  scanf("%ld",&n);
  if(n!=0)
  i=(int)log10(n);
  j=pow(10.0,i);
  if(n/j!=(n+1)/j) flag=1;
  n/=j;
  if(!i) printf("%ld\n",n);
  else printf("%ld\t",i*9-1+flag+n);
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%ld"
.LC2:
	.string	"%ld\n"
.LC3:
	.string	"%ld\t"
	.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	$48, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movq	$0, -32(%rbp)
	movq	$0, -24(%rbp)
	leaq	-40(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	-40(%rbp), %rax
	testq	%rax, %rax
	je	.L2
	movq	-40(%rbp), %rax
	pxor	%xmm2, %xmm2
	cvtsi2sdq	%rax, %xmm2
	movq	%xmm2, %rax
	movq	%rax, %xmm0
	call	log10@PLT
	cvttsd2sil	%xmm0, %eax
	cltq
	movq	%rax, -32(%rbp)
.L2:
	pxor	%xmm0, %xmm0
	cvtsi2sdq	-32(%rbp), %xmm0
	movq	.LC1(%rip), %rax
	movapd	%xmm0, %xmm1
	movq	%rax, %xmm0
	call	pow@PLT
	cvttsd2siq	%xmm0, %rax
	movq	%rax, -16(%rbp)
	movq	-40(%rbp), %rax
	cqto
	idivq	-16(%rbp)
	movq	%rax, %rcx
	movq	-40(%rbp), %rax
	addq	$1, %rax
	cqto
	idivq	-16(%rbp)
	cmpq	%rax, %rcx
	je	.L3
	movq	$1, -24(%rbp)
.L3:
	movq	-40(%rbp), %rax
	cqto
	idivq	-16(%rbp)
	movq	%rax, -40(%rbp)
	cmpq	$0, -32(%rbp)
	jne	.L4
	movq	-40(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L5
.L4:
	movq	-32(%rbp), %rdx
	movq	%rdx, %rax
	salq	$3, %rax
	addq	%rdx, %rax
	leaq	-1(%rax), %rdx
	movq	-24(%rbp), %rax
	addq	%rax, %rdx
	movq	-40(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L5:
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L7
	call	__stack_chk_fail@PLT
.L7:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.section	.rodata
	.align 8
.LC1:
	.long	0
	.long	1076101120
	.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	"%ld"
.LC2:
	.string	"%ld\n"
.LC3:
	.string	"%ld\t"
	.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	$48, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movq	$0, -32(%rbp)
	movq	$0, -24(%rbp)
	leaq	-40(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	-40(%rbp), %rax
	testq	%rax, %rax
	je	.L2
	movq	-40(%rbp), %rax
	pxor	%xmm2, %xmm2
	cvtsi2sdq	%rax, %xmm2
	movq	%xmm2, %rax
	movq	%rax, %xmm0
	call	log10@PLT
	cvttsd2sil	%xmm0, %eax
	cltq
	movq	%rax, -32(%rbp)
.L2:
	pxor	%xmm0, %xmm0
	cvtsi2sdq	-32(%rbp), %xmm0
	movq	.LC1(%rip), %rax
	movapd	%xmm0, %xmm1
	movq	%rax, %xmm0
	call	pow@PLT
	cvttsd2siq	%xmm0, %rax
	movq	%rax, -16(%rbp)
	movq	-40(%rbp), %rax
	cqto
	idivq	-16(%rbp)
	movq	%rax, %rcx
	movq	-40(%rbp), %rax
	addq	$1, %rax
	cqto
	idivq	-16(%rbp)
	cmpq	%rax, %rcx
	je	.L3
	movq	$1, -24(%rbp)
.L3:
	movq	-40(%rbp), %rax
	cqto
	idivq	-16(%rbp)
	movq	%rax, -40(%rbp)
	cmpq	$0, -32(%rbp)
	jne	.L4
	movq	-40(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L5
.L4:
	movq	-32(%rbp), %rdx
	movq	%rdx, %rax
	salq	$3, %rax
	addq	%rdx, %rax
	leaq	-1(%rax), %rdx
	movq	-24(%rbp), %rax
	addq	%rax, %rdx
	movq	-40(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L5:
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L7
	call	__stack_chk_fail@PLT
.L7:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.section	.rodata
	.align 8
.LC1:
	.long	0
	.long	1076101120
	.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:
