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>

typedef long long int ll;
ll n,ans=0;

ll dfs(ll a,ll n3,ll n5,ll n7){
  if(a>n)return ans;
  if(n3+n5+n7==3)ans++;
  dfs(a*10+3,1,n5,n7);
  dfs(a*10+5,n3,1,n7);
  dfs(a*10+7,n3,n5,1);
  return ans;
}

int main(){
    scanf("%lld",&n);
    printf("%lld\n",dfs(0,0,0,0));
    return 0;
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	n
	.bss
	.align 8
	.type	n, @object
	.size	n, 8
n:
	.zero	8
	.globl	ans
	.align 8
	.type	ans, @object
	.size	ans, 8
ans:
	.zero	8
	.text
	.globl	dfs
	.type	dfs, @function
dfs:
.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	%rdi, -8(%rbp)
	movq	%rsi, -16(%rbp)
	movq	%rdx, -24(%rbp)
	movq	%rcx, -32(%rbp)
	movq	n(%rip), %rax
	cmpq	%rax, -8(%rbp)
	jle	.L2
	movq	ans(%rip), %rax
	jmp	.L3
.L2:
	movq	-16(%rbp), %rdx
	movq	-24(%rbp), %rax
	addq	%rax, %rdx
	movq	-32(%rbp), %rax
	addq	%rdx, %rax
	cmpq	$3, %rax
	jne	.L4
	movq	ans(%rip), %rax
	addq	$1, %rax
	movq	%rax, ans(%rip)
.L4:
	movq	-8(%rbp), %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	leaq	3(%rax), %rdi
	movq	-32(%rbp), %rdx
	movq	-24(%rbp), %rax
	movq	%rdx, %rcx
	movq	%rax, %rdx
	movl	$1, %esi
	call	dfs
	movq	-8(%rbp), %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	leaq	5(%rax), %rdi
	movq	-32(%rbp), %rdx
	movq	-16(%rbp), %rax
	movq	%rdx, %rcx
	movl	$1, %edx
	movq	%rax, %rsi
	call	dfs
	movq	-8(%rbp), %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	leaq	7(%rax), %rdi
	movq	-24(%rbp), %rdx
	movq	-16(%rbp), %rax
	movl	$1, %ecx
	movq	%rax, %rsi
	call	dfs
	movq	ans(%rip), %rax
.L3:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	dfs, .-dfs
	.section	.rodata
.LC0:
	.string	"%lld"
.LC1:
	.string	"%lld\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	leaq	n(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, %ecx
	movl	$0, %edx
	movl	$0, %esi
	movl	$0, %edi
	call	dfs
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.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	dfs
	.type	dfs, @function
dfs:
.LFB23:
	.cfi_startproc
	endbr64
	movq	n(%rip), %rax
	cmpq	%rdi, %rax
	jl	.L45
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	leaq	(%rsi,%rdx), %r14
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movq	%rdx, %r13
	leaq	(%rcx,%r14), %rdx
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movq	%rcx, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movq	%rsi, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
	cmpq	$3, %rdx
	je	.L46
	leaq	(%rdi,%rdi,4), %rbx
	addq	%rbx, %rbx
	leaq	3(%rbx), %rdx
	cmpq	%rdx, %rax
	jl	.L5
.L56:
	leaq	(%rdx,%rdx,4), %r8
	leaq	1(%r13,%r12), %rcx
	addq	%r8, %r8
	leaq	3(%r8), %rdx
	cmpq	$3, %rcx
	je	.L47
	cmpq	%rdx, %rax
	jl	.L8
.L36:
	leaq	(%rdx,%rdx,4), %r15
	movq	%r12, %rcx
	movq	%r13, %rdx
	movl	$1, %esi
	addq	%r15, %r15
	movq	%r8, (%rsp)
	leaq	3(%r15), %rdi
	call	dfs
	leaq	5(%r15), %rdi
	movq	%r12, %rcx
	movl	$1, %edx
	movl	$1, %esi
	call	dfs
	leaq	7(%r15), %rdi
	movl	$1, %ecx
	movq	%r13, %rdx
	movl	$1, %esi
	call	dfs
	movq	n(%rip), %rax
	movq	(%rsp), %r8
.L8:
	leaq	5(%r8), %rdx
	cmpq	%rax, %rdx
	jg	.L9
	cmpq	$1, %r12
	je	.L48
.L10:
	leaq	(%rdx,%rdx,4), %r15
	movq	%r12, %rcx
	movl	$1, %edx
	movq	%r8, (%rsp)
	addq	%r15, %r15
	movl	$1, %esi
	leaq	3(%r15), %rdi
	call	dfs
	leaq	5(%r15), %rdi
	movq	%r12, %rcx
	movl	$1, %edx
	movl	$1, %esi
	call	dfs
	leaq	7(%r15), %rdi
	movl	$1, %ecx
	movl	$1, %edx
	movl	$1, %esi
	call	dfs
	movq	n(%rip), %rax
	movq	(%rsp), %r8
.L9:
	addq	$7, %r8
	cmpq	%rax, %r8
	jg	.L5
	cmpq	$1, %r13
	je	.L49
.L11:
	leaq	(%r8,%r8,4), %rdi
	movl	$1, %ecx
	movq	%r13, %rdx
	movl	$1, %esi
	leaq	(%rdi,%rdi), %r15
	leaq	3(%r15), %rdi
	call	dfs
	leaq	5(%r15), %rdi
	movl	$1, %ecx
	movl	$1, %edx
	movl	$1, %esi
	call	dfs
	leaq	7(%r15), %rdi
	movl	$1, %ecx
	movq	%r13, %rdx
	movl	$1, %esi
	call	dfs
	movq	n(%rip), %rax
.L5:
	leaq	5(%rbx), %rdx
	cmpq	%rax, %rdx
	jg	.L12
	leaq	1(%rbp,%r12), %r9
	cmpq	$3, %r9
	jne	.L13
	addq	$1, ans(%rip)
.L13:
	leaq	(%rdx,%rdx,4), %r8
	addq	%r8, %r8
	leaq	3(%r8), %rdx
	cmpq	%rax, %rdx
	jg	.L14
	cmpq	$1, %r12
	je	.L50
.L15:
	leaq	(%rdx,%rdx,4), %r15
	movq	%r12, %rcx
	movl	$1, %edx
	movq	%r9, (%rsp)
	addq	%r15, %r15
	movl	$1, %esi
	movq	%r8, 8(%rsp)
	leaq	3(%r15), %rdi
	call	dfs
	leaq	5(%r15), %rdi
	movq	%r12, %rcx
	movl	$1, %edx
	movl	$1, %esi
	call	dfs
	leaq	7(%r15), %rdi
	movl	$1, %ecx
	movl	$1, %edx
	movl	$1, %esi
	call	dfs
	movq	n(%rip), %rax
	movq	8(%rsp), %r8
	movq	(%rsp), %r9
.L14:
	leaq	5(%r8), %rdx
	cmpq	%rax, %rdx
	jg	.L16
	cmpq	$3, %r9
	je	.L51
.L17:
	leaq	(%rdx,%rdx,4), %r15
	movq	%r12, %rcx
	movl	$1, %edx
	movq	%r8, (%rsp)
	addq	%r15, %r15
	movl	$1, %esi
	leaq	3(%r15), %rdi
	call	dfs
	leaq	5(%r15), %rdi
	movq	%r12, %rcx
	movq	%rbp, %rsi
	movl	$1, %edx
	call	dfs
	leaq	7(%r15), %rdi
	movl	$1, %ecx
	movq	%rbp, %rsi
	movl	$1, %edx
	call	dfs
	movq	n(%rip), %rax
	movq	(%rsp), %r8
.L16:
	addq	$7, %r8
	cmpq	%rax, %r8
	jg	.L12
	cmpq	$1, %rbp
	je	.L52
.L18:
	leaq	(%r8,%r8,4), %rdi
	movl	$1, %ecx
	movl	$1, %edx
	movl	$1, %esi
	leaq	(%rdi,%rdi), %r12
	leaq	3(%r12), %rdi
	call	dfs
	leaq	5(%r12), %rdi
	movl	$1, %ecx
	movq	%rbp, %rsi
	movl	$1, %edx
	call	dfs
	leaq	7(%r12), %rdi
	movl	$1, %ecx
	movq	%rbp, %rsi
	movl	$1, %edx
	call	dfs
	movq	n(%rip), %rax
.L12:
	addq	$7, %rbx
	cmpq	%rax, %rbx
	jg	.L20
	cmpq	$2, %r14
	jne	.L21
	addq	$1, ans(%rip)
.L21:
	leaq	(%rbx,%rbx,4), %rbx
	addq	%rbx, %rbx
	leaq	3(%rbx), %rdx
	cmpq	%rax, %rdx
	jg	.L22
	cmpq	$1, %r13
	je	.L53
.L23:
	leaq	(%rdx,%rdx,4), %r12
	movl	$1, %ecx
	movq	%r13, %rdx
	movl	$1, %esi
	addq	%r12, %r12
	leaq	3(%r12), %rdi
	call	dfs
	leaq	5(%r12), %rax
	cmpq	n(%rip), %rax
	jg	.L24
	leaq	(%rax,%rax,4), %rdi
	movl	$1, %ecx
	movl	$1, %edx
	movl	$1, %esi
	leaq	(%rdi,%rdi), %r15
	addq	$1, ans(%rip)
	leaq	3(%r15), %rdi
	call	dfs
	leaq	5(%r15), %rdi
	movl	$1, %ecx
	movl	$1, %edx
	movl	$1, %esi
	call	dfs
	leaq	7(%r15), %rdi
	movl	$1, %ecx
	movl	$1, %edx
	movl	$1, %esi
	call	dfs
.L24:
	leaq	7(%r12), %rdi
	movl	$1, %ecx
	movq	%r13, %rdx
	movl	$1, %esi
	call	dfs
	movq	n(%rip), %rax
.L22:
	leaq	5(%rbx), %rdx
	cmpq	%rax, %rdx
	jg	.L25
	leaq	(%rdx,%rdx,4), %rax
	addq	%rax, %rax
	leaq	5(%rax), %r15
	leaq	3(%rax), %rdi
	leaq	7(%rax), %r12
	cmpq	$1, %rbp
	je	.L54
	movl	$1, %ecx
	movl	$1, %edx
	movl	$1, %esi
	call	dfs
	movq	n(%rip), %rax
	cmpq	%rax, %r15
	jg	.L43
	leaq	(%r15,%r15,4), %r15
	movl	$1, %ecx
	movl	$1, %edx
	movl	$1, %esi
	addq	%r15, %r15
	leaq	3(%r15), %rdi
	call	dfs
	leaq	5(%r15), %rdi
	movl	$1, %ecx
	movq	%rbp, %rsi
	movl	$1, %edx
	call	dfs
	leaq	7(%r15), %rdi
	movl	$1, %ecx
	movq	%rbp, %rsi
	movl	$1, %edx
	call	dfs
	movq	n(%rip), %rax
.L43:
	cmpq	%r12, %rax
	jl	.L25
.L29:
	leaq	(%r12,%r12,4), %rdi
	movl	$1, %ecx
	movl	$1, %edx
	movl	$1, %esi
	leaq	(%rdi,%rdi), %r12
	leaq	3(%r12), %rdi
	call	dfs
	leaq	5(%r12), %rdi
	movl	$1, %ecx
	movq	%rbp, %rsi
	movl	$1, %edx
	call	dfs
	leaq	7(%r12), %rdi
	movl	$1, %ecx
	movq	%rbp, %rsi
	movl	$1, %edx
	call	dfs
	movq	n(%rip), %rax
.L25:
	addq	$7, %rbx
	cmpq	%rax, %rbx
	jg	.L20
	cmpq	$2, %r14
	je	.L55
.L31:
	leaq	(%rbx,%rbx,4), %rbx
	movl	$1, %ecx
	movq	%r13, %rdx
	movl	$1, %esi
	addq	%rbx, %rbx
	leaq	3(%rbx), %rdi
	call	dfs
	leaq	5(%rbx), %rax
	cmpq	n(%rip), %rax
	jg	.L32
	cmpq	$1, %rbp
	jne	.L33
	addq	$1, ans(%rip)
.L33:
	leaq	(%rax,%rax,4), %r12
	movl	$1, %ecx
	movl	$1, %edx
	movl	$1, %esi
	addq	%r12, %r12
	leaq	3(%r12), %rdi
	call	dfs
	leaq	5(%r12), %rdi
	movl	$1, %ecx
	movq	%rbp, %rsi
	movl	$1, %edx
	call	dfs
	leaq	7(%r12), %rdi
	movl	$1, %ecx
	movq	%rbp, %rsi
	movl	$1, %edx
	call	dfs
.L32:
	leaq	7(%rbx), %rdi
	movl	$1, %ecx
	movq	%r13, %rdx
	movq	%rbp, %rsi
	call	dfs
.L20:
	movq	ans(%rip), %rax
	addq	$24, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	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
.L46:
	.cfi_restore_state
	leaq	(%rdi,%rdi,4), %rbx
	addq	$1, ans(%rip)
	addq	%rbx, %rbx
	leaq	3(%rbx), %rdx
	cmpq	%rdx, %rax
	jge	.L56
	jmp	.L5
	.p2align 4,,10
	.p2align 3
.L45:
	.cfi_def_cfa_offset 8
	.cfi_restore 3
	.cfi_restore 6
	.cfi_restore 12
	.cfi_restore 13
	.cfi_restore 14
	.cfi_restore 15
	movq	ans(%rip), %rax
	ret
	.p2align 4,,10
	.p2align 3
.L50:
	.cfi_def_cfa_offset 80
	.cfi_offset 3, -56
	.cfi_offset 6, -48
	.cfi_offset 12, -40
	.cfi_offset 13, -32
	.cfi_offset 14, -24
	.cfi_offset 15, -16
	addq	$1, ans(%rip)
	jmp	.L15
	.p2align 4,,10
	.p2align 3
.L55:
	addq	$1, ans(%rip)
	jmp	.L31
	.p2align 4,,10
	.p2align 3
.L54:
	movl	$1, %ecx
	movl	$1, %edx
	movl	$1, %esi
	addq	$1, ans(%rip)
	call	dfs
	movq	n(%rip), %rax
	cmpq	%rax, %r15
	jg	.L27
	leaq	(%r15,%r15,4), %r15
	movl	$1, %ecx
	movl	$1, %edx
	movl	$1, %esi
	addq	%r15, %r15
	addq	$1, ans(%rip)
	leaq	3(%r15), %rdi
	call	dfs
	leaq	5(%r15), %rdi
	movl	$1, %ecx
	movl	$1, %edx
	movl	$1, %esi
	call	dfs
	leaq	7(%r15), %rdi
	movl	$1, %ecx
	movl	$1, %edx
	movl	$1, %esi
	call	dfs
	movq	n(%rip), %rax
	cmpq	%r12, %rax
	jl	.L25
.L28:
	addq	$1, ans(%rip)
	jmp	.L29
	.p2align 4,,10
	.p2align 3
.L52:
	addq	$1, ans(%rip)
	jmp	.L18
	.p2align 4,,10
	.p2align 3
.L51:
	addq	$1, ans(%rip)
	jmp	.L17
	.p2align 4,,10
	.p2align 3
.L53:
	addq	$1, ans(%rip)
	jmp	.L23
	.p2align 4,,10
	.p2align 3
.L49:
	addq	$1, ans(%rip)
	jmp	.L11
	.p2align 4,,10
	.p2align 3
.L48:
	addq	$1, ans(%rip)
	jmp	.L10
	.p2align 4,,10
	.p2align 3
.L47:
	movq	ans(%rip), %rcx
	cmpq	%rdx, %rax
	jl	.L57
	addq	$2, %rcx
	movq	%rcx, ans(%rip)
	jmp	.L36
	.p2align 4,,10
	.p2align 3
.L57:
	addq	$1, %rcx
	movq	%rcx, ans(%rip)
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L27:
	cmpq	%rax, %r12
	jle	.L28
	jmp	.L25
	.cfi_endproc
.LFE23:
	.size	dfs, .-dfs
	.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:
.LFB24:
	.cfi_startproc
	endbr64
	subq	$8, %rsp
	.cfi_def_cfa_offset 16
	leaq	n(%rip), %rsi
	leaq	.LC0(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movq	n(%rip), %rax
	testq	%rax, %rax
	js	.L63
	cmpq	$2, %rax
	jle	.L61
	xorl	%ecx, %ecx
	xorl	%edx, %edx
	movl	$1, %esi
	movl	$33, %edi
	call	dfs
	xorl	%ecx, %ecx
	movl	$1, %edx
	movl	$1, %esi
	movl	$35, %edi
	call	dfs
	movl	$1, %ecx
	xorl	%edx, %edx
	movl	$1, %esi
	movl	$37, %edi
	call	dfs
.L61:
	xorl	%ecx, %ecx
	movl	$1, %edx
	xorl	%esi, %esi
	movl	$5, %edi
	call	dfs
	movl	$1, %ecx
	xorl	%edx, %edx
	xorl	%esi, %esi
	movl	$7, %edi
	call	dfs
.L63:
	movq	ans(%rip), %rdx
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	xorl	%eax, %eax
	addq	$8, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE24:
	.size	main, .-main
	.globl	ans
	.bss
	.align 8
	.type	ans, @object
	.size	ans, 8
ans:
	.zero	8
	.globl	n
	.align 8
	.type	n, @object
	.size	n, 8
n:
	.zero	8
	.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	dfs
	.type	dfs, @function
dfs:
.LFB23:
	.cfi_startproc
	endbr64
	movq	n(%rip), %rax
	cmpq	%rdi, %rax
	jl	.L45
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	leaq	(%rsi,%rdx), %r14
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movq	%rdx, %r13
	leaq	(%rcx,%r14), %rdx
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movq	%rcx, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movq	%rsi, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
	cmpq	$3, %rdx
	je	.L46
	leaq	(%rdi,%rdi,4), %rbx
	addq	%rbx, %rbx
	leaq	3(%rbx), %rdx
	cmpq	%rdx, %rax
	jl	.L5
.L56:
	leaq	(%rdx,%rdx,4), %r8
	leaq	1(%r13,%r12), %rcx
	addq	%r8, %r8
	leaq	3(%r8), %rdx
	cmpq	$3, %rcx
	je	.L47
	cmpq	%rdx, %rax
	jl	.L8
.L36:
	leaq	(%rdx,%rdx,4), %r15
	movq	%r12, %rcx
	movq	%r13, %rdx
	movl	$1, %esi
	addq	%r15, %r15
	movq	%r8, (%rsp)
	leaq	3(%r15), %rdi
	call	dfs
	leaq	5(%r15), %rdi
	movq	%r12, %rcx
	movl	$1, %edx
	movl	$1, %esi
	call	dfs
	leaq	7(%r15), %rdi
	movl	$1, %ecx
	movq	%r13, %rdx
	movl	$1, %esi
	call	dfs
	movq	n(%rip), %rax
	movq	(%rsp), %r8
.L8:
	leaq	5(%r8), %rdx
	cmpq	%rax, %rdx
	jg	.L9
	cmpq	$1, %r12
	je	.L48
.L10:
	leaq	(%rdx,%rdx,4), %r15
	movq	%r12, %rcx
	movl	$1, %edx
	movq	%r8, (%rsp)
	addq	%r15, %r15
	movl	$1, %esi
	leaq	3(%r15), %rdi
	call	dfs
	leaq	5(%r15), %rdi
	movq	%r12, %rcx
	movl	$1, %edx
	movl	$1, %esi
	call	dfs
	leaq	7(%r15), %rdi
	movl	$1, %ecx
	movl	$1, %edx
	movl	$1, %esi
	call	dfs
	movq	n(%rip), %rax
	movq	(%rsp), %r8
.L9:
	addq	$7, %r8
	cmpq	%rax, %r8
	jg	.L5
	cmpq	$1, %r13
	je	.L49
.L11:
	leaq	(%r8,%r8,4), %rdi
	movl	$1, %ecx
	movq	%r13, %rdx
	movl	$1, %esi
	leaq	(%rdi,%rdi), %r15
	leaq	3(%r15), %rdi
	call	dfs
	leaq	5(%r15), %rdi
	movl	$1, %ecx
	movl	$1, %edx
	movl	$1, %esi
	call	dfs
	leaq	7(%r15), %rdi
	movl	$1, %ecx
	movq	%r13, %rdx
	movl	$1, %esi
	call	dfs
	movq	n(%rip), %rax
.L5:
	leaq	5(%rbx), %rdx
	cmpq	%rax, %rdx
	jg	.L12
	leaq	1(%rbp,%r12), %r9
	cmpq	$3, %r9
	jne	.L13
	addq	$1, ans(%rip)
.L13:
	leaq	(%rdx,%rdx,4), %r8
	addq	%r8, %r8
	leaq	3(%r8), %rdx
	cmpq	%rax, %rdx
	jg	.L14
	cmpq	$1, %r12
	je	.L50
.L15:
	leaq	(%rdx,%rdx,4), %r15
	movq	%r12, %rcx
	movl	$1, %edx
	movq	%r9, (%rsp)
	addq	%r15, %r15
	movl	$1, %esi
	movq	%r8, 8(%rsp)
	leaq	3(%r15), %rdi
	call	dfs
	leaq	5(%r15), %rdi
	movq	%r12, %rcx
	movl	$1, %edx
	movl	$1, %esi
	call	dfs
	leaq	7(%r15), %rdi
	movl	$1, %ecx
	movl	$1, %edx
	movl	$1, %esi
	call	dfs
	movq	n(%rip), %rax
	movq	8(%rsp), %r8
	movq	(%rsp), %r9
.L14:
	leaq	5(%r8), %rdx
	cmpq	%rax, %rdx
	jg	.L16
	cmpq	$3, %r9
	je	.L51
.L17:
	leaq	(%rdx,%rdx,4), %r15
	movq	%r12, %rcx
	movl	$1, %edx
	movq	%r8, (%rsp)
	addq	%r15, %r15
	movl	$1, %esi
	leaq	3(%r15), %rdi
	call	dfs
	leaq	5(%r15), %rdi
	movq	%r12, %rcx
	movq	%rbp, %rsi
	movl	$1, %edx
	call	dfs
	leaq	7(%r15), %rdi
	movl	$1, %ecx
	movq	%rbp, %rsi
	movl	$1, %edx
	call	dfs
	movq	n(%rip), %rax
	movq	(%rsp), %r8
.L16:
	addq	$7, %r8
	cmpq	%rax, %r8
	jg	.L12
	cmpq	$1, %rbp
	je	.L52
.L18:
	leaq	(%r8,%r8,4), %rdi
	movl	$1, %ecx
	movl	$1, %edx
	movl	$1, %esi
	leaq	(%rdi,%rdi), %r12
	leaq	3(%r12), %rdi
	call	dfs
	leaq	5(%r12), %rdi
	movl	$1, %ecx
	movq	%rbp, %rsi
	movl	$1, %edx
	call	dfs
	leaq	7(%r12), %rdi
	movl	$1, %ecx
	movq	%rbp, %rsi
	movl	$1, %edx
	call	dfs
	movq	n(%rip), %rax
.L12:
	addq	$7, %rbx
	cmpq	%rax, %rbx
	jg	.L20
	cmpq	$2, %r14
	jne	.L21
	addq	$1, ans(%rip)
.L21:
	leaq	(%rbx,%rbx,4), %rbx
	addq	%rbx, %rbx
	leaq	3(%rbx), %rdx
	cmpq	%rax, %rdx
	jg	.L22
	cmpq	$1, %r13
	je	.L53
.L23:
	leaq	(%rdx,%rdx,4), %r12
	movl	$1, %ecx
	movq	%r13, %rdx
	movl	$1, %esi
	addq	%r12, %r12
	leaq	3(%r12), %rdi
	call	dfs
	leaq	5(%r12), %rax
	cmpq	n(%rip), %rax
	jg	.L24
	leaq	(%rax,%rax,4), %rdi
	movl	$1, %ecx
	movl	$1, %edx
	movl	$1, %esi
	leaq	(%rdi,%rdi), %r15
	addq	$1, ans(%rip)
	leaq	3(%r15), %rdi
	call	dfs
	leaq	5(%r15), %rdi
	movl	$1, %ecx
	movl	$1, %edx
	movl	$1, %esi
	call	dfs
	leaq	7(%r15), %rdi
	movl	$1, %ecx
	movl	$1, %edx
	movl	$1, %esi
	call	dfs
.L24:
	leaq	7(%r12), %rdi
	movl	$1, %ecx
	movq	%r13, %rdx
	movl	$1, %esi
	call	dfs
	movq	n(%rip), %rax
.L22:
	leaq	5(%rbx), %rdx
	cmpq	%rax, %rdx
	jg	.L25
	leaq	(%rdx,%rdx,4), %rax
	addq	%rax, %rax
	leaq	5(%rax), %r15
	leaq	3(%rax), %rdi
	leaq	7(%rax), %r12
	cmpq	$1, %rbp
	je	.L54
	movl	$1, %ecx
	movl	$1, %edx
	movl	$1, %esi
	call	dfs
	movq	n(%rip), %rax
	cmpq	%rax, %r15
	jg	.L43
	leaq	(%r15,%r15,4), %r15
	movl	$1, %ecx
	movl	$1, %edx
	movl	$1, %esi
	addq	%r15, %r15
	leaq	3(%r15), %rdi
	call	dfs
	leaq	5(%r15), %rdi
	movl	$1, %ecx
	movq	%rbp, %rsi
	movl	$1, %edx
	call	dfs
	leaq	7(%r15), %rdi
	movl	$1, %ecx
	movq	%rbp, %rsi
	movl	$1, %edx
	call	dfs
	movq	n(%rip), %rax
.L43:
	cmpq	%r12, %rax
	jl	.L25
.L29:
	leaq	(%r12,%r12,4), %rdi
	movl	$1, %ecx
	movl	$1, %edx
	movl	$1, %esi
	leaq	(%rdi,%rdi), %r12
	leaq	3(%r12), %rdi
	call	dfs
	leaq	5(%r12), %rdi
	movl	$1, %ecx
	movq	%rbp, %rsi
	movl	$1, %edx
	call	dfs
	leaq	7(%r12), %rdi
	movl	$1, %ecx
	movq	%rbp, %rsi
	movl	$1, %edx
	call	dfs
	movq	n(%rip), %rax
.L25:
	addq	$7, %rbx
	cmpq	%rax, %rbx
	jg	.L20
	cmpq	$2, %r14
	je	.L55
.L31:
	leaq	(%rbx,%rbx,4), %rbx
	movl	$1, %ecx
	movq	%r13, %rdx
	movl	$1, %esi
	addq	%rbx, %rbx
	leaq	3(%rbx), %rdi
	call	dfs
	leaq	5(%rbx), %rax
	cmpq	n(%rip), %rax
	jg	.L32
	cmpq	$1, %rbp
	jne	.L33
	addq	$1, ans(%rip)
.L33:
	leaq	(%rax,%rax,4), %r12
	movl	$1, %ecx
	movl	$1, %edx
	movl	$1, %esi
	addq	%r12, %r12
	leaq	3(%r12), %rdi
	call	dfs
	leaq	5(%r12), %rdi
	movl	$1, %ecx
	movq	%rbp, %rsi
	movl	$1, %edx
	call	dfs
	leaq	7(%r12), %rdi
	movl	$1, %ecx
	movq	%rbp, %rsi
	movl	$1, %edx
	call	dfs
.L32:
	leaq	7(%rbx), %rdi
	movl	$1, %ecx
	movq	%r13, %rdx
	movq	%rbp, %rsi
	call	dfs
.L20:
	movq	ans(%rip), %rax
	addq	$24, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	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
.L46:
	.cfi_restore_state
	leaq	(%rdi,%rdi,4), %rbx
	addq	$1, ans(%rip)
	addq	%rbx, %rbx
	leaq	3(%rbx), %rdx
	cmpq	%rdx, %rax
	jge	.L56
	jmp	.L5
	.p2align 4,,10
	.p2align 3
.L45:
	.cfi_def_cfa_offset 8
	.cfi_restore 3
	.cfi_restore 6
	.cfi_restore 12
	.cfi_restore 13
	.cfi_restore 14
	.cfi_restore 15
	movq	ans(%rip), %rax
	ret
	.p2align 4,,10
	.p2align 3
.L50:
	.cfi_def_cfa_offset 80
	.cfi_offset 3, -56
	.cfi_offset 6, -48
	.cfi_offset 12, -40
	.cfi_offset 13, -32
	.cfi_offset 14, -24
	.cfi_offset 15, -16
	addq	$1, ans(%rip)
	jmp	.L15
	.p2align 4,,10
	.p2align 3
.L55:
	addq	$1, ans(%rip)
	jmp	.L31
	.p2align 4,,10
	.p2align 3
.L54:
	movl	$1, %ecx
	movl	$1, %edx
	movl	$1, %esi
	addq	$1, ans(%rip)
	call	dfs
	movq	n(%rip), %rax
	cmpq	%rax, %r15
	jg	.L27
	leaq	(%r15,%r15,4), %r15
	movl	$1, %ecx
	movl	$1, %edx
	movl	$1, %esi
	addq	%r15, %r15
	addq	$1, ans(%rip)
	leaq	3(%r15), %rdi
	call	dfs
	leaq	5(%r15), %rdi
	movl	$1, %ecx
	movl	$1, %edx
	movl	$1, %esi
	call	dfs
	leaq	7(%r15), %rdi
	movl	$1, %ecx
	movl	$1, %edx
	movl	$1, %esi
	call	dfs
	movq	n(%rip), %rax
	cmpq	%r12, %rax
	jl	.L25
.L28:
	addq	$1, ans(%rip)
	jmp	.L29
	.p2align 4,,10
	.p2align 3
.L52:
	addq	$1, ans(%rip)
	jmp	.L18
	.p2align 4,,10
	.p2align 3
.L51:
	addq	$1, ans(%rip)
	jmp	.L17
	.p2align 4,,10
	.p2align 3
.L53:
	addq	$1, ans(%rip)
	jmp	.L23
	.p2align 4,,10
	.p2align 3
.L49:
	addq	$1, ans(%rip)
	jmp	.L11
	.p2align 4,,10
	.p2align 3
.L48:
	addq	$1, ans(%rip)
	jmp	.L10
	.p2align 4,,10
	.p2align 3
.L47:
	movq	ans(%rip), %rcx
	cmpq	%rdx, %rax
	jl	.L57
	addq	$2, %rcx
	movq	%rcx, ans(%rip)
	jmp	.L36
	.p2align 4,,10
	.p2align 3
.L57:
	addq	$1, %rcx
	movq	%rcx, ans(%rip)
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L27:
	cmpq	%rax, %r12
	jle	.L28
	jmp	.L25
	.cfi_endproc
.LFE23:
	.size	dfs, .-dfs
	.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:
.LFB24:
	.cfi_startproc
	endbr64
	subq	$8, %rsp
	.cfi_def_cfa_offset 16
	leaq	n(%rip), %rsi
	leaq	.LC0(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movq	n(%rip), %rax
	testq	%rax, %rax
	js	.L63
	cmpq	$2, %rax
	jle	.L61
	xorl	%ecx, %ecx
	xorl	%edx, %edx
	movl	$1, %esi
	movl	$33, %edi
	call	dfs
	xorl	%ecx, %ecx
	movl	$1, %edx
	movl	$1, %esi
	movl	$35, %edi
	call	dfs
	movl	$1, %ecx
	xorl	%edx, %edx
	movl	$1, %esi
	movl	$37, %edi
	call	dfs
.L61:
	xorl	%ecx, %ecx
	movl	$1, %edx
	xorl	%esi, %esi
	movl	$5, %edi
	call	dfs
	movl	$1, %ecx
	xorl	%edx, %edx
	xorl	%esi, %esi
	movl	$7, %edi
	call	dfs
.L63:
	movq	ans(%rip), %rdx
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	xorl	%eax, %eax
	addq	$8, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE24:
	.size	main, .-main
	.globl	ans
	.bss
	.align 8
	.type	ans, @object
	.size	ans, 8
ans:
	.zero	8
	.globl	n
	.align 8
	.type	n, @object
	.size	n, 8
n:
	.zero	8
	.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>

typedef long long int ll;
ll n,ans=0;

ll dfs(ll a,ll n3,ll n5,ll n7){
  if(a>n)return ans;
  if(n3+n5+n7==3)ans++;
  dfs(a*10+3,1,n5,n7);
  dfs(a*10+5,n3,1,n7);
  dfs(a*10+7,n3,n5,1);
  return ans;
}

int main(){
    scanf("%lld",&n);
    printf("%lld\n",dfs(0,0,0,0));
    return 0;
}

60
 1134
 656396080
 1260308870
 251112438
 3669
 4753
 3412
 5825
 471776498

0
 6
 20434
 26484
 8334
 13
 18
 8
 30
 14384

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>

typedef long long int ll;
ll n,ans=0;

ll dfs(ll a,ll n3,ll n5,ll n7){
  if(a>n)return ans;
  if(n3+n5+n7==3)ans++;
  dfs(a*10+3,1,n5,n7);
  dfs(a*10+5,n3,1,n7);
  dfs(a*10+7,n3,n5,1);
  return ans;
}

int main(){
    scanf("%lld",&n);
    printf("%lld\n",dfs(0,0,0,0));
    return 0;
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	n
	.bss
	.align 8
	.type	n, @object
	.size	n, 8
n:
	.zero	8
	.globl	ans
	.align 8
	.type	ans, @object
	.size	ans, 8
ans:
	.zero	8
	.text
	.globl	dfs
	.type	dfs, @function
dfs:
.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	%rdi, -8(%rbp)
	movq	%rsi, -16(%rbp)
	movq	%rdx, -24(%rbp)
	movq	%rcx, -32(%rbp)
	movq	n(%rip), %rax
	cmpq	%rax, -8(%rbp)
	jle	.L2
	movq	ans(%rip), %rax
	jmp	.L3
.L2:
	movq	-16(%rbp), %rdx
	movq	-24(%rbp), %rax
	addq	%rax, %rdx
	movq	-32(%rbp), %rax
	addq	%rdx, %rax
	cmpq	$3, %rax
	jne	.L4
	movq	ans(%rip), %rax
	addq	$1, %rax
	movq	%rax, ans(%rip)
.L4:
	movq	-8(%rbp), %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	leaq	3(%rax), %rdi
	movq	-32(%rbp), %rdx
	movq	-24(%rbp), %rax
	movq	%rdx, %rcx
	movq	%rax, %rdx
	movl	$1, %esi
	call	dfs
	movq	-8(%rbp), %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	leaq	5(%rax), %rdi
	movq	-32(%rbp), %rdx
	movq	-16(%rbp), %rax
	movq	%rdx, %rcx
	movl	$1, %edx
	movq	%rax, %rsi
	call	dfs
	movq	-8(%rbp), %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	leaq	7(%rax), %rdi
	movq	-24(%rbp), %rdx
	movq	-16(%rbp), %rax
	movl	$1, %ecx
	movq	%rax, %rsi
	call	dfs
	movq	ans(%rip), %rax
.L3:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	dfs, .-dfs
	.section	.rodata
.LC0:
	.string	"%lld"
.LC1:
	.string	"%lld\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	leaq	n(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, %ecx
	movl	$0, %edx
	movl	$0, %esi
	movl	$0, %edi
	call	dfs
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.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	n
	.bss
	.align 8
	.type	n, @object
	.size	n, 8
n:
	.zero	8
	.globl	ans
	.align 8
	.type	ans, @object
	.size	ans, 8
ans:
	.zero	8
	.text
	.globl	dfs
	.type	dfs, @function
dfs:
.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	%rdi, -8(%rbp)
	movq	%rsi, -16(%rbp)
	movq	%rdx, -24(%rbp)
	movq	%rcx, -32(%rbp)
	movq	n(%rip), %rax
	cmpq	%rax, -8(%rbp)
	jle	.L2
	movq	ans(%rip), %rax
	jmp	.L3
.L2:
	movq	-16(%rbp), %rdx
	movq	-24(%rbp), %rax
	addq	%rax, %rdx
	movq	-32(%rbp), %rax
	addq	%rdx, %rax
	cmpq	$3, %rax
	jne	.L4
	movq	ans(%rip), %rax
	addq	$1, %rax
	movq	%rax, ans(%rip)
.L4:
	movq	-8(%rbp), %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	leaq	3(%rax), %rdi
	movq	-32(%rbp), %rdx
	movq	-24(%rbp), %rax
	movq	%rdx, %rcx
	movq	%rax, %rdx
	movl	$1, %esi
	call	dfs
	movq	-8(%rbp), %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	leaq	5(%rax), %rdi
	movq	-32(%rbp), %rdx
	movq	-16(%rbp), %rax
	movq	%rdx, %rcx
	movl	$1, %edx
	movq	%rax, %rsi
	call	dfs
	movq	-8(%rbp), %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	leaq	7(%rax), %rdi
	movq	-24(%rbp), %rdx
	movq	-16(%rbp), %rax
	movl	$1, %ecx
	movq	%rax, %rsi
	call	dfs
	movq	ans(%rip), %rax
.L3:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	dfs, .-dfs
	.section	.rodata
.LC0:
	.string	"%lld"
.LC1:
	.string	"%lld\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	leaq	n(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, %ecx
	movl	$0, %edx
	movl	$0, %esi
	movl	$0, %edi
	call	dfs
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.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:
