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 main() {
	const long long int mod = 7 + 1e9;
	int n;
	long long int ans = 0, n9 = 1, n8 = 1, n10 = 1;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		n9 *= 9;
		n9 = n9 % mod;
		n8 *= 8;
		n8 = n8 % mod;
		n10 *= 10;
		n10 = n10 % mod;
	}
	ans = n10 - 2 * n9 + n8;
	for (int i = 0;; i++) {
		if (ans < 0)ans += mod;
		if (mod <= ans)ans -= mod;
		if (0 <= ans && ans < mod)break;
	}
	printf("%lld", ans);
	return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%lld"
	.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	$64, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movq	$1000000007, -16(%rbp)
	movq	$0, -48(%rbp)
	movq	$1, -40(%rbp)
	movq	$1, -32(%rbp)
	movq	$1, -24(%rbp)
	leaq	-60(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -56(%rbp)
	jmp	.L2
.L3:
	movq	-40(%rbp), %rdx
	movq	%rdx, %rax
	salq	$3, %rax
	addq	%rdx, %rax
	movq	%rax, -40(%rbp)
	movq	-40(%rbp), %rax
	cqto
	idivq	-16(%rbp)
	movq	%rdx, -40(%rbp)
	salq	$3, -32(%rbp)
	movq	-32(%rbp), %rax
	cqto
	idivq	-16(%rbp)
	movq	%rdx, -32(%rbp)
	movq	-24(%rbp), %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	movq	%rax, -24(%rbp)
	movq	-24(%rbp), %rax
	cqto
	idivq	-16(%rbp)
	movq	%rdx, -24(%rbp)
	addl	$1, -56(%rbp)
.L2:
	movl	-60(%rbp), %eax
	cmpl	%eax, -56(%rbp)
	jl	.L3
	movq	-40(%rbp), %rax
	leaq	(%rax,%rax), %rcx
	movq	-24(%rbp), %rax
	subq	%rcx, %rax
	movq	%rax, %rdx
	movq	-32(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, -48(%rbp)
	movl	$0, -52(%rbp)
.L8:
	cmpq	$0, -48(%rbp)
	jns	.L4
	movq	-16(%rbp), %rax
	addq	%rax, -48(%rbp)
.L4:
	movq	-16(%rbp), %rax
	cmpq	-48(%rbp), %rax
	jg	.L5
	movq	-16(%rbp), %rax
	subq	%rax, -48(%rbp)
.L5:
	cmpq	$0, -48(%rbp)
	js	.L6
	movq	-48(%rbp), %rax
	cmpq	-16(%rbp), %rax
	jl	.L12
.L6:
	addl	$1, -52(%rbp)
	jmp	.L8
.L12:
	nop
	movq	-48(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %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	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	"%d"
.LC1:
	.string	"%lld"
	.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
	leaq	4(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movl	4(%rsp), %r11d
	testl	%r11d, %r11d
	jle	.L8
	xorl	%r10d, %r10d
	movl	$1, %ecx
	movl	$1, %r8d
	movl	$1, %edi
	movabsq	$-8543223828751151131, %r9
	.p2align 4,,10
	.p2align 3
.L3:
	leaq	(%rdi,%rdi,8), %rsi
	addl	$1, %r10d
	movq	%rsi, %rax
	imulq	%r9
	movq	%rsi, %rax
	sarq	$63, %rax
	leaq	(%rdx,%rsi), %rdi
	sarq	$29, %rdi
	subq	%rax, %rdi
	imulq	$1000000007, %rdi, %rax
	movq	%rsi, %rdi
	leaq	0(,%r8,8), %rsi
	subq	%rax, %rdi
	movq	%rsi, %rax
	imulq	%r9
	movq	%rsi, %rax
	sarq	$63, %rax
	leaq	(%rdx,%rsi), %r8
	sarq	$29, %r8
	subq	%rax, %r8
	imulq	$1000000007, %r8, %rax
	subq	%rax, %rsi
	movq	%rsi, %r8
	leaq	(%rcx,%rcx,4), %rsi
	addq	%rsi, %rsi
	movq	%rsi, %rax
	imulq	%r9
	movq	%rsi, %rax
	sarq	$63, %rax
	leaq	(%rdx,%rsi), %rcx
	sarq	$29, %rcx
	subq	%rax, %rcx
	imulq	$1000000007, %rcx, %rax
	movq	%rsi, %rcx
	subq	%rax, %rcx
	cmpl	%r10d, %r11d
	jne	.L3
.L2:
	addq	%rdi, %rdi
	subq	%rdi, %rcx
	leaq	(%rcx,%r8), %rdx
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L4:
	leaq	-1000000007(%rdx), %rax
	cmpq	$1000000006, %rdx
	cmovg	%rax, %rdx
	cmpq	$1000000006, %rdx
	jbe	.L13
.L6:
	testq	%rdx, %rdx
	jns	.L4
	addq	$1000000007, %rdx
	cmpq	$1000000006, %rdx
	ja	.L6
.L13:
	xorl	%eax, %eax
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	call	__printf_chk@PLT
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L14
	xorl	%eax, %eax
	addq	$24, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 8
	ret
.L8:
	.cfi_restore_state
	movl	$1, %ecx
	movl	$1, %r8d
	movl	$1, %edi
	jmp	.L2
.L14:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.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	"%d"
.LC1:
	.string	"%lld"
	.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
	leaq	4(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movl	4(%rsp), %r11d
	testl	%r11d, %r11d
	jle	.L8
	xorl	%r10d, %r10d
	movl	$1, %ecx
	movl	$1, %r8d
	movl	$1, %edi
	movabsq	$-8543223828751151131, %r9
	.p2align 4,,10
	.p2align 3
.L3:
	leaq	(%rdi,%rdi,8), %rsi
	addl	$1, %r10d
	movq	%rsi, %rax
	imulq	%r9
	movq	%rsi, %rax
	sarq	$63, %rax
	leaq	(%rdx,%rsi), %rdi
	sarq	$29, %rdi
	subq	%rax, %rdi
	imulq	$1000000007, %rdi, %rax
	movq	%rsi, %rdi
	leaq	0(,%r8,8), %rsi
	subq	%rax, %rdi
	movq	%rsi, %rax
	imulq	%r9
	movq	%rsi, %rax
	sarq	$63, %rax
	leaq	(%rdx,%rsi), %r8
	sarq	$29, %r8
	subq	%rax, %r8
	imulq	$1000000007, %r8, %rax
	subq	%rax, %rsi
	movq	%rsi, %r8
	leaq	(%rcx,%rcx,4), %rsi
	addq	%rsi, %rsi
	movq	%rsi, %rax
	imulq	%r9
	movq	%rsi, %rax
	sarq	$63, %rax
	leaq	(%rdx,%rsi), %rcx
	sarq	$29, %rcx
	subq	%rax, %rcx
	imulq	$1000000007, %rcx, %rax
	movq	%rsi, %rcx
	subq	%rax, %rcx
	cmpl	%r10d, %r11d
	jne	.L3
.L2:
	addq	%rdi, %rdi
	subq	%rdi, %rcx
	leaq	(%rcx,%r8), %rdx
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L4:
	leaq	-1000000007(%rdx), %rax
	cmpq	$1000000006, %rdx
	cmovg	%rax, %rdx
	cmpq	$1000000006, %rdx
	jbe	.L13
.L6:
	testq	%rdx, %rdx
	jns	.L4
	addq	$1000000007, %rdx
	cmpq	$1000000006, %rdx
	ja	.L6
.L13:
	xorl	%eax, %eax
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	call	__printf_chk@PLT
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L14
	xorl	%eax, %eax
	addq	$24, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 8
	ret
.L8:
	.cfi_restore_state
	movl	$1, %ecx
	movl	$1, %r8d
	movl	$1, %edi
	jmp	.L2
.L14:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.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 main() {
	const long long int mod = 7 + 1e9;
	int n;
	long long int ans = 0, n9 = 1, n8 = 1, n10 = 1;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		n9 *= 9;
		n9 = n9 % mod;
		n8 *= 8;
		n8 = n8 % mod;
		n10 *= 10;
		n10 = n10 % mod;
	}
	ans = n10 - 2 * n9 + n8;
	for (int i = 0;; i++) {
		if (ans < 0)ans += mod;
		if (mod <= ans)ans -= mod;
		if (0 <= ans && ans < mod)break;
	}
	printf("%lld", ans);
	return 0;
}
226564
 0
 3
 241465
 5
 127499
 10
 99752
 7
 112403

498733826 0 54 202510248 14670 463923590 100172994 794180853 2531214 286663221
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 main() {
	const long long int mod = 7 + 1e9;
	int n;
	long long int ans = 0, n9 = 1, n8 = 1, n10 = 1;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		n9 *= 9;
		n9 = n9 % mod;
		n8 *= 8;
		n8 = n8 % mod;
		n10 *= 10;
		n10 = n10 % mod;
	}
	ans = n10 - 2 * n9 + n8;
	for (int i = 0;; i++) {
		if (ans < 0)ans += mod;
		if (mod <= ans)ans -= mod;
		if (0 <= ans && ans < mod)break;
	}
	printf("%lld", ans);
	return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%lld"
	.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	$64, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movq	$1000000007, -16(%rbp)
	movq	$0, -48(%rbp)
	movq	$1, -40(%rbp)
	movq	$1, -32(%rbp)
	movq	$1, -24(%rbp)
	leaq	-60(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -56(%rbp)
	jmp	.L2
.L3:
	movq	-40(%rbp), %rdx
	movq	%rdx, %rax
	salq	$3, %rax
	addq	%rdx, %rax
	movq	%rax, -40(%rbp)
	movq	-40(%rbp), %rax
	cqto
	idivq	-16(%rbp)
	movq	%rdx, -40(%rbp)
	salq	$3, -32(%rbp)
	movq	-32(%rbp), %rax
	cqto
	idivq	-16(%rbp)
	movq	%rdx, -32(%rbp)
	movq	-24(%rbp), %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	movq	%rax, -24(%rbp)
	movq	-24(%rbp), %rax
	cqto
	idivq	-16(%rbp)
	movq	%rdx, -24(%rbp)
	addl	$1, -56(%rbp)
.L2:
	movl	-60(%rbp), %eax
	cmpl	%eax, -56(%rbp)
	jl	.L3
	movq	-40(%rbp), %rax
	leaq	(%rax,%rax), %rcx
	movq	-24(%rbp), %rax
	subq	%rcx, %rax
	movq	%rax, %rdx
	movq	-32(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, -48(%rbp)
	movl	$0, -52(%rbp)
.L8:
	cmpq	$0, -48(%rbp)
	jns	.L4
	movq	-16(%rbp), %rax
	addq	%rax, -48(%rbp)
.L4:
	movq	-16(%rbp), %rax
	cmpq	-48(%rbp), %rax
	jg	.L5
	movq	-16(%rbp), %rax
	subq	%rax, -48(%rbp)
.L5:
	cmpq	$0, -48(%rbp)
	js	.L6
	movq	-48(%rbp), %rax
	cmpq	-16(%rbp), %rax
	jl	.L12
.L6:
	addl	$1, -52(%rbp)
	jmp	.L8
.L12:
	nop
	movq	-48(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %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	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	"%d"
.LC1:
	.string	"%lld"
	.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	$64, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movq	$1000000007, -16(%rbp)
	movq	$0, -48(%rbp)
	movq	$1, -40(%rbp)
	movq	$1, -32(%rbp)
	movq	$1, -24(%rbp)
	leaq	-60(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -56(%rbp)
	jmp	.L2
.L3:
	movq	-40(%rbp), %rdx
	movq	%rdx, %rax
	salq	$3, %rax
	addq	%rdx, %rax
	movq	%rax, -40(%rbp)
	movq	-40(%rbp), %rax
	cqto
	idivq	-16(%rbp)
	movq	%rdx, -40(%rbp)
	salq	$3, -32(%rbp)
	movq	-32(%rbp), %rax
	cqto
	idivq	-16(%rbp)
	movq	%rdx, -32(%rbp)
	movq	-24(%rbp), %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	movq	%rax, -24(%rbp)
	movq	-24(%rbp), %rax
	cqto
	idivq	-16(%rbp)
	movq	%rdx, -24(%rbp)
	addl	$1, -56(%rbp)
.L2:
	movl	-60(%rbp), %eax
	cmpl	%eax, -56(%rbp)
	jl	.L3
	movq	-40(%rbp), %rax
	leaq	(%rax,%rax), %rcx
	movq	-24(%rbp), %rax
	subq	%rcx, %rax
	movq	%rax, %rdx
	movq	-32(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, -48(%rbp)
	movl	$0, -52(%rbp)
.L8:
	cmpq	$0, -48(%rbp)
	jns	.L4
	movq	-16(%rbp), %rax
	addq	%rax, -48(%rbp)
.L4:
	movq	-16(%rbp), %rax
	cmpq	-48(%rbp), %rax
	jg	.L5
	movq	-16(%rbp), %rax
	subq	%rax, -48(%rbp)
.L5:
	cmpq	$0, -48(%rbp)
	js	.L6
	movq	-48(%rbp), %rax
	cmpq	-16(%rbp), %rax
	jl	.L12
.L6:
	addl	$1, -52(%rbp)
	jmp	.L8
.L12:
	nop
	movq	-48(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %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	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:
