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>
typedef long long ll;

ll	digit_sum(ll n)
{
	ll sum = 0;
	while (1)
	{
		sum += n % 10;
		if (n < 10)
			break;
		n /= 10;
	}
	return sum;
}

ll digit_n(ll n)
{
	long cnt = 1;
	while (n > 9)
	{
		n /= 10;
		cnt++;
	}
	return cnt;
}

int main(void)
{
	ll n;
	scanf("%lld", &n);
	ll j = n;
	ll cnt = 0;
	// printf("%lld\n", digit_n(n));
	ll k = digit_n(n);
	ll d = pow(10, k - 1);
	ll c = n / d;
	ll i = 0;

	while (i < k - 1)
	{
		if (j % 10 == 9)
			cnt++;
		j /= 10;
		i++;
	}
	if (cnt == k - 1)
		printf("%lld\n", c + (9 * (k - 1)));
	else if (n % 10 != 9)
		printf("%lld\n", ((c-1) + (9 * (k - 1) )));
	return 0;
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	digit_sum
	.type	digit_sum, @function
digit_sum:
.LFB0:
	.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)
.L4:
	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)
	cmpq	$9, -24(%rbp)
	jle	.L7
	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)
	jmp	.L4
.L7:
	nop
	movq	-8(%rbp), %rax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	digit_sum, .-digit_sum
	.globl	digit_n
	.type	digit_n, @function
digit_n:
.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)
	movq	$1, -8(%rbp)
	jmp	.L9
.L10:
	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)
	addq	$1, -8(%rbp)
.L9:
	cmpq	$9, -24(%rbp)
	jg	.L10
	movq	-8(%rbp), %rax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	digit_n, .-digit_n
	.section	.rodata
.LC0:
	.string	"%lld"
.LC2:
	.string	"%lld\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB2:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$64, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-64(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	-64(%rbp), %rax
	movq	%rax, -56(%rbp)
	movq	$0, -48(%rbp)
	movq	-64(%rbp), %rax
	movq	%rax, %rdi
	call	digit_n
	movq	%rax, -32(%rbp)
	movq	-32(%rbp), %rax
	subq	$1, %rax
	pxor	%xmm0, %xmm0
	cvtsi2sdq	%rax, %xmm0
	movq	.LC1(%rip), %rax
	movapd	%xmm0, %xmm1
	movq	%rax, %xmm0
	call	pow@PLT
	cvttsd2siq	%xmm0, %rax
	movq	%rax, -24(%rbp)
	movq	-64(%rbp), %rax
	cqto
	idivq	-24(%rbp)
	movq	%rax, -16(%rbp)
	movq	$0, -40(%rbp)
	jmp	.L13
.L15:
	movq	-56(%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
	jne	.L14
	addq	$1, -48(%rbp)
.L14:
	movq	-56(%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, -56(%rbp)
	addq	$1, -40(%rbp)
.L13:
	movq	-32(%rbp), %rax
	subq	$1, %rax
	cmpq	%rax, -40(%rbp)
	jl	.L15
	movq	-32(%rbp), %rax
	subq	$1, %rax
	cmpq	%rax, -48(%rbp)
	jne	.L16
	movq	-32(%rbp), %rax
	leaq	-1(%rax), %rdx
	movq	%rdx, %rax
	salq	$3, %rax
	addq	%rax, %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L17
.L16:
	movq	-64(%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	.L17
	movq	-16(%rbp), %rax
	leaq	-1(%rax), %rcx
	movq	-32(%rbp), %rax
	leaq	-1(%rax), %rdx
	movq	%rdx, %rax
	salq	$3, %rax
	addq	%rdx, %rax
	addq	%rcx, %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L17:
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L19
	call	__stack_chk_fail@PLT
.L19:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2:
	.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
	.p2align 4
	.globl	digit_sum
	.type	digit_sum, @function
digit_sum:
.LFB23:
	.cfi_startproc
	endbr64
	movq	%rdi, %rax
	movq	%rdi, %r8
	movq	%rdi, %rcx
	movabsq	$7378697629483820647, %rdx
	imulq	%rdx
	movq	%rdi, %rax
	sarq	$63, %rax
	sarq	$2, %rdx
	subq	%rax, %rdx
	leaq	(%rdx,%rdx,4), %rax
	addq	%rax, %rax
	subq	%rax, %r8
	cmpq	$9, %rdi
	jle	.L1
	movabsq	$-3689348814741910323, %rdi
	.p2align 4,,10
	.p2align 3
.L3:
	movq	%rcx, %rax
	movq	%rcx, %rsi
	mulq	%rdi
	movq	%rdx, %rcx
	shrq	$3, %rcx
	movq	%rcx, %rax
	mulq	%rdi
	shrq	$3, %rdx
	leaq	(%rdx,%rdx,4), %rax
	movq	%rcx, %rdx
	addq	%rax, %rax
	subq	%rax, %rdx
	addq	%rdx, %r8
	cmpq	$99, %rsi
	jg	.L3
.L1:
	movq	%r8, %rax
	ret
	.cfi_endproc
.LFE23:
	.size	digit_sum, .-digit_sum
	.p2align 4
	.globl	digit_n
	.type	digit_n, @function
digit_n:
.LFB24:
	.cfi_startproc
	endbr64
	movq	%rdi, %rdx
	movl	$1, %r8d
	cmpq	$9, %rdi
	jle	.L6
	movabsq	$-3689348814741910323, %rsi
	.p2align 4,,10
	.p2align 3
.L8:
	movq	%rdx, %rax
	movq	%rdx, %rcx
	addq	$1, %r8
	mulq	%rsi
	shrq	$3, %rdx
	cmpq	$99, %rcx
	jg	.L8
.L6:
	movq	%r8, %rax
	ret
	.cfi_endproc
.LFE24:
	.size	digit_n, .-digit_n
	.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:
.LFB25:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -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), %rbp
	cmpq	$9, %rbp
	jle	.L20
	movq	%rbp, %rdx
	movl	$1, %esi
	movabsq	$-3689348814741910323, %rdi
	.p2align 4,,10
	.p2align 3
.L13:
	movq	%rdx, %rax
	movq	%rdx, %rcx
	movq	%rsi, %rbx
	mulq	%rdi
	leaq	1(%rsi), %rsi
	shrq	$3, %rdx
	cmpq	$99, %rcx
	jg	.L13
	pxor	%xmm1, %xmm1
	movsd	.LC2(%rip), %xmm0
	cvtsi2sdq	%rbx, %xmm1
	call	pow@PLT
	movq	%rbp, %rax
	xorl	%edi, %edi
	xorl	%r8d, %r8d
	cvttsd2siq	%xmm0, %rcx
	cqto
	movabsq	$7378697629483820647, %r9
	idivq	%rcx
	movq	%rbp, %rcx
	movq	%rax, %r10
	movq	%rax, %r11
	.p2align 4,,10
	.p2align 3
.L16:
	movq	%rcx, %rax
	imulq	%r9
	movq	%rcx, %rax
	sarq	$63, %rax
	sarq	$2, %rdx
	subq	%rax, %rdx
	xorl	%eax, %eax
	leaq	(%rdx,%rdx,4), %rsi
	addq	%rsi, %rsi
	subq	%rsi, %rcx
	cmpq	$9, %rcx
	movq	%rdx, %rcx
	sete	%al
	addq	$1, %rdi
	addq	%rax, %r8
	cmpq	%rdi, %rbx
	jne	.L16
	cmpq	%rbx, %r8
	je	.L12
	movq	%rbp, %rax
	imulq	%r9
	movq	%rbp, %rax
	sarq	$63, %rax
	sarq	$2, %rdx
	subq	%rax, %rdx
	leaq	(%rdx,%rdx,4), %rax
	addq	%rax, %rax
	subq	%rax, %rbp
	cmpq	$9, %rbp
	jne	.L29
.L18:
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L30
	addq	$24, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 24
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
.L29:
	.cfi_restore_state
	leaq	(%rbx,%rbx,8), %rbx
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	leaq	-1(%rbx,%r10), %rdx
	call	__printf_chk@PLT
	jmp	.L18
.L20:
	movq	%rbp, %r11
	xorl	%edi, %edi
.L12:
	leaq	(%rdi,%rdi,8), %rdx
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	addq	%r11, %rdx
	call	__printf_chk@PLT
	jmp	.L18
.L30:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE25:
	.size	main, .-main
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC2:
	.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
	.p2align 4
	.globl	digit_sum
	.type	digit_sum, @function
digit_sum:
.LFB23:
	.cfi_startproc
	endbr64
	movq	%rdi, %rax
	movq	%rdi, %r8
	movq	%rdi, %rcx
	movabsq	$7378697629483820647, %rdx
	imulq	%rdx
	movq	%rdi, %rax
	sarq	$63, %rax
	sarq	$2, %rdx
	subq	%rax, %rdx
	leaq	(%rdx,%rdx,4), %rax
	addq	%rax, %rax
	subq	%rax, %r8
	cmpq	$9, %rdi
	jle	.L1
	movabsq	$-3689348814741910323, %rdi
	.p2align 4,,10
	.p2align 3
.L3:
	movq	%rcx, %rax
	movq	%rcx, %rsi
	mulq	%rdi
	movq	%rdx, %rcx
	shrq	$3, %rcx
	movq	%rcx, %rax
	mulq	%rdi
	shrq	$3, %rdx
	leaq	(%rdx,%rdx,4), %rax
	movq	%rcx, %rdx
	addq	%rax, %rax
	subq	%rax, %rdx
	addq	%rdx, %r8
	cmpq	$99, %rsi
	jg	.L3
.L1:
	movq	%r8, %rax
	ret
	.cfi_endproc
.LFE23:
	.size	digit_sum, .-digit_sum
	.p2align 4
	.globl	digit_n
	.type	digit_n, @function
digit_n:
.LFB24:
	.cfi_startproc
	endbr64
	movq	%rdi, %rdx
	movl	$1, %r8d
	cmpq	$9, %rdi
	jle	.L6
	movabsq	$-3689348814741910323, %rsi
	.p2align 4,,10
	.p2align 3
.L8:
	movq	%rdx, %rax
	movq	%rdx, %rcx
	addq	$1, %r8
	mulq	%rsi
	shrq	$3, %rdx
	cmpq	$99, %rcx
	jg	.L8
.L6:
	movq	%r8, %rax
	ret
	.cfi_endproc
.LFE24:
	.size	digit_n, .-digit_n
	.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:
.LFB25:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -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), %rbp
	cmpq	$9, %rbp
	jle	.L20
	movq	%rbp, %rdx
	movl	$1, %esi
	movabsq	$-3689348814741910323, %rdi
	.p2align 4,,10
	.p2align 3
.L13:
	movq	%rdx, %rax
	movq	%rdx, %rcx
	movq	%rsi, %rbx
	mulq	%rdi
	leaq	1(%rsi), %rsi
	shrq	$3, %rdx
	cmpq	$99, %rcx
	jg	.L13
	pxor	%xmm1, %xmm1
	movsd	.LC2(%rip), %xmm0
	cvtsi2sdq	%rbx, %xmm1
	call	pow@PLT
	movq	%rbp, %rax
	xorl	%edi, %edi
	xorl	%r8d, %r8d
	cvttsd2siq	%xmm0, %rcx
	cqto
	movabsq	$7378697629483820647, %r9
	idivq	%rcx
	movq	%rbp, %rcx
	movq	%rax, %r10
	movq	%rax, %r11
	.p2align 4,,10
	.p2align 3
.L16:
	movq	%rcx, %rax
	imulq	%r9
	movq	%rcx, %rax
	sarq	$63, %rax
	sarq	$2, %rdx
	subq	%rax, %rdx
	xorl	%eax, %eax
	leaq	(%rdx,%rdx,4), %rsi
	addq	%rsi, %rsi
	subq	%rsi, %rcx
	cmpq	$9, %rcx
	movq	%rdx, %rcx
	sete	%al
	addq	$1, %rdi
	addq	%rax, %r8
	cmpq	%rdi, %rbx
	jne	.L16
	cmpq	%rbx, %r8
	je	.L12
	movq	%rbp, %rax
	imulq	%r9
	movq	%rbp, %rax
	sarq	$63, %rax
	sarq	$2, %rdx
	subq	%rax, %rdx
	leaq	(%rdx,%rdx,4), %rax
	addq	%rax, %rax
	subq	%rax, %rbp
	cmpq	$9, %rbp
	jne	.L29
.L18:
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L30
	addq	$24, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 24
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
.L29:
	.cfi_restore_state
	leaq	(%rbx,%rbx,8), %rbx
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	leaq	-1(%rbx,%r10), %rdx
	call	__printf_chk@PLT
	jmp	.L18
.L20:
	movq	%rbp, %r11
	xorl	%edi, %edi
.L12:
	leaq	(%rdi,%rdi,8), %rdx
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	addq	%r11, %rdx
	call	__printf_chk@PLT
	jmp	.L18
.L30:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE25:
	.size	main, .-main
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC2:
	.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>
typedef long long ll;

ll	digit_sum(ll n)
{
	ll sum = 0;
	while (1)
	{
		sum += n % 10;
		if (n < 10)
			break;
		n /= 10;
	}
	return sum;
}

ll digit_n(ll n)
{
	long cnt = 1;
	while (n > 9)
	{
		n /= 10;
		cnt++;
	}
	return cnt;
}

int main(void)
{
	ll n;
	scanf("%lld", &n);
	ll j = n;
	ll cnt = 0;
	// printf("%lld\n", digit_n(n));
	ll k = digit_n(n);
	ll d = pow(10, k - 1);
	ll c = n / d;
	ll i = 0;

	while (i < k - 1)
	{
		if (j % 10 == 9)
			cnt++;
		j /= 10;
		i++;
	}
	if (cnt == k - 1)
		printf("%lld\n", c + (9 * (k - 1)));
	else if (n % 10 != 9)
		printf("%lld\n", ((c-1) + (9 * (k - 1) )));
	return 0;
}

1265641936938969
 101
 613
 1180
 2005985506723837
 78
 813322357948504
 127248513971408
 46390584841058
 51

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>
typedef long long ll;

ll	digit_sum(ll n)
{
	ll sum = 0;
	while (1)
	{
		sum += n % 10;
		if (n < 10)
			break;
		n /= 10;
	}
	return sum;
}

ll digit_n(ll n)
{
	long cnt = 1;
	while (n > 9)
	{
		n /= 10;
		cnt++;
	}
	return cnt;
}

int main(void)
{
	ll n;
	scanf("%lld", &n);
	ll j = n;
	ll cnt = 0;
	// printf("%lld\n", digit_n(n));
	ll k = digit_n(n);
	ll d = pow(10, k - 1);
	ll c = n / d;
	ll i = 0;

	while (i < k - 1)
	{
		if (j % 10 == 9)
			cnt++;
		j /= 10;
		i++;
	}
	if (cnt == k - 1)
		printf("%lld\n", c + (9 * (k - 1)));
	else if (n % 10 != 9)
		printf("%lld\n", ((c-1) + (9 * (k - 1) )));
	return 0;
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	digit_sum
	.type	digit_sum, @function
digit_sum:
.LFB0:
	.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)
.L4:
	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)
	cmpq	$9, -24(%rbp)
	jle	.L7
	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)
	jmp	.L4
.L7:
	nop
	movq	-8(%rbp), %rax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	digit_sum, .-digit_sum
	.globl	digit_n
	.type	digit_n, @function
digit_n:
.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)
	movq	$1, -8(%rbp)
	jmp	.L9
.L10:
	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)
	addq	$1, -8(%rbp)
.L9:
	cmpq	$9, -24(%rbp)
	jg	.L10
	movq	-8(%rbp), %rax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	digit_n, .-digit_n
	.section	.rodata
.LC0:
	.string	"%lld"
.LC2:
	.string	"%lld\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB2:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$64, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-64(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	-64(%rbp), %rax
	movq	%rax, -56(%rbp)
	movq	$0, -48(%rbp)
	movq	-64(%rbp), %rax
	movq	%rax, %rdi
	call	digit_n
	movq	%rax, -32(%rbp)
	movq	-32(%rbp), %rax
	subq	$1, %rax
	pxor	%xmm0, %xmm0
	cvtsi2sdq	%rax, %xmm0
	movq	.LC1(%rip), %rax
	movapd	%xmm0, %xmm1
	movq	%rax, %xmm0
	call	pow@PLT
	cvttsd2siq	%xmm0, %rax
	movq	%rax, -24(%rbp)
	movq	-64(%rbp), %rax
	cqto
	idivq	-24(%rbp)
	movq	%rax, -16(%rbp)
	movq	$0, -40(%rbp)
	jmp	.L13
.L15:
	movq	-56(%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
	jne	.L14
	addq	$1, -48(%rbp)
.L14:
	movq	-56(%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, -56(%rbp)
	addq	$1, -40(%rbp)
.L13:
	movq	-32(%rbp), %rax
	subq	$1, %rax
	cmpq	%rax, -40(%rbp)
	jl	.L15
	movq	-32(%rbp), %rax
	subq	$1, %rax
	cmpq	%rax, -48(%rbp)
	jne	.L16
	movq	-32(%rbp), %rax
	leaq	-1(%rax), %rdx
	movq	%rdx, %rax
	salq	$3, %rax
	addq	%rax, %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L17
.L16:
	movq	-64(%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	.L17
	movq	-16(%rbp), %rax
	leaq	-1(%rax), %rcx
	movq	-32(%rbp), %rax
	leaq	-1(%rax), %rdx
	movq	%rdx, %rax
	salq	$3, %rax
	addq	%rdx, %rax
	addq	%rcx, %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L17:
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L19
	call	__stack_chk_fail@PLT
.L19:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2:
	.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.
val
	.file	"temp.c"
	.text
	.globl	digit_sum
	.type	digit_sum, @function
digit_sum:
.LFB0:
	.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)
.L4:
	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)
	cmpq	$9, -24(%rbp)
	jle	.L7
	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)
	jmp	.L4
.L7:
	nop
	movq	-8(%rbp), %rax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	digit_sum, .-digit_sum
	.globl	digit_n
	.type	digit_n, @function
digit_n:
.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)
	movq	$1, -8(%rbp)
	jmp	.L9
.L10:
	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)
	addq	$1, -8(%rbp)
.L9:
	cmpq	$9, -24(%rbp)
	jg	.L10
	movq	-8(%rbp), %rax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	digit_n, .-digit_n
	.section	.rodata
.LC0:
	.string	"%lld"
.LC2:
	.string	"%lld\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB2:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$64, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-64(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	-64(%rbp), %rax
	movq	%rax, -56(%rbp)
	movq	$0, -48(%rbp)
	movq	-64(%rbp), %rax
	movq	%rax, %rdi
	call	digit_n
	movq	%rax, -32(%rbp)
	movq	-32(%rbp), %rax
	subq	$1, %rax
	pxor	%xmm0, %xmm0
	cvtsi2sdq	%rax, %xmm0
	movq	.LC1(%rip), %rax
	movapd	%xmm0, %xmm1
	movq	%rax, %xmm0
	call	pow@PLT
	cvttsd2siq	%xmm0, %rax
	movq	%rax, -24(%rbp)
	movq	-64(%rbp), %rax
	cqto
	idivq	-24(%rbp)
	movq	%rax, -16(%rbp)
	movq	$0, -40(%rbp)
	jmp	.L13
.L15:
	movq	-56(%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
	jne	.L14
	addq	$1, -48(%rbp)
.L14:
	movq	-56(%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, -56(%rbp)
	addq	$1, -40(%rbp)
.L13:
	movq	-32(%rbp), %rax
	subq	$1, %rax
	cmpq	%rax, -40(%rbp)
	jl	.L15
	movq	-32(%rbp), %rax
	subq	$1, %rax
	cmpq	%rax, -48(%rbp)
	jne	.L16
	movq	-32(%rbp), %rax
	leaq	-1(%rax), %rdx
	movq	%rdx, %rax
	salq	$3, %rax
	addq	%rax, %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L17
.L16:
	movq	-64(%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	.L17
	movq	-16(%rbp), %rax
	leaq	-1(%rax), %rcx
	movq	-32(%rbp), %rax
	leaq	-1(%rax), %rdx
	movq	%rdx, %rax
	salq	$3, %rax
	addq	%rdx, %rax
	addq	%rcx, %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L17:
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L19
	call	__stack_chk_fail@PLT
.L19:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2:
	.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:
