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(){
  int n,i,j,count=0;
  int a[11][11];
  for(i=0;i<10;i++)
    for(j=0;j<10;j++)
      a[i][j]=0;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    j=i;
    while(j/10!=0)
      j/=10;
    a[j][i%10]++;
  }
  for(i=1;i<=9;i++){
    for(j=i;j<=9;j++){
      if(i==j)
        count+=a[i][j]*a[i][j];
      else
        count+=2*a[i][j]*a[j][i];
    }
  }
  printf("%d\n",count);
  return 0;
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d"
.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	$512, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -500(%rbp)
	movl	$0, -508(%rbp)
	jmp	.L2
.L5:
	movl	$0, -504(%rbp)
	jmp	.L3
.L4:
	movl	-504(%rbp), %eax
	movslq	%eax, %rcx
	movl	-508(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	addq	%rcx, %rax
	movl	$0, -496(%rbp,%rax,4)
	addl	$1, -504(%rbp)
.L3:
	cmpl	$9, -504(%rbp)
	jle	.L4
	addl	$1, -508(%rbp)
.L2:
	cmpl	$9, -508(%rbp)
	jle	.L5
	leaq	-512(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$1, -508(%rbp)
	jmp	.L6
.L9:
	movl	-508(%rbp), %eax
	movl	%eax, -504(%rbp)
	jmp	.L7
.L8:
	movl	-504(%rbp), %eax
	movslq	%eax, %rdx
	imulq	$1717986919, %rdx, %rdx
	shrq	$32, %rdx
	sarl	$2, %edx
	sarl	$31, %eax
	movl	%eax, %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	movl	%eax, -504(%rbp)
.L7:
	movl	-504(%rbp), %eax
	addl	$9, %eax
	cmpl	$18, %eax
	ja	.L8
	movl	-508(%rbp), %ecx
	movslq	%ecx, %rax
	imulq	$1717986919, %rax, %rax
	shrq	$32, %rax
	sarl	$2, %eax
	movl	%ecx, %esi
	sarl	$31, %esi
	subl	%esi, %eax
	movl	%eax, %edx
	movl	%edx, %eax
	sall	$2, %eax
	addl	%edx, %eax
	addl	%eax, %eax
	subl	%eax, %ecx
	movl	%ecx, %edx
	movslq	%edx, %rsi
	movl	-504(%rbp), %eax
	movslq	%eax, %rcx
	movq	%rcx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	addq	%rax, %rax
	addq	%rcx, %rax
	addq	%rsi, %rax
	movl	-496(%rbp,%rax,4), %eax
	leal	1(%rax), %ecx
	movslq	%edx, %rsi
	movl	-504(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	addq	%rsi, %rax
	movl	%ecx, -496(%rbp,%rax,4)
	addl	$1, -508(%rbp)
.L6:
	movl	-512(%rbp), %eax
	cmpl	%eax, -508(%rbp)
	jle	.L9
	movl	$1, -508(%rbp)
	jmp	.L10
.L15:
	movl	-508(%rbp), %eax
	movl	%eax, -504(%rbp)
	jmp	.L11
.L14:
	movl	-508(%rbp), %eax
	cmpl	-504(%rbp), %eax
	jne	.L12
	movl	-504(%rbp), %eax
	movslq	%eax, %rcx
	movl	-508(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	addq	%rcx, %rax
	movl	-496(%rbp,%rax,4), %ecx
	movl	-504(%rbp), %eax
	movslq	%eax, %rsi
	movl	-508(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	addq	%rsi, %rax
	movl	-496(%rbp,%rax,4), %eax
	imull	%ecx, %eax
	addl	%eax, -500(%rbp)
	jmp	.L13
.L12:
	movl	-504(%rbp), %eax
	movslq	%eax, %rcx
	movl	-508(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	addq	%rcx, %rax
	movl	-496(%rbp,%rax,4), %ecx
	movl	-508(%rbp), %eax
	movslq	%eax, %rsi
	movl	-504(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	addq	%rsi, %rax
	movl	-496(%rbp,%rax,4), %eax
	imull	%ecx, %eax
	addl	%eax, %eax
	addl	%eax, -500(%rbp)
.L13:
	addl	$1, -504(%rbp)
.L11:
	cmpl	$9, -504(%rbp)
	jle	.L14
	addl	$1, -508(%rbp)
.L10:
	cmpl	$9, -508(%rbp)
	jle	.L15
	movl	-500(%rbp), %eax
	movl	%eax, %esi
	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	.L17
	call	__stack_chk_fail@PLT
.L17:
	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	"%d\n"
	.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
	pxor	%xmm0, %xmm0
	leaq	.LC0(%rip), %rdi
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	subq	$512, %rsp
	.cfi_def_cfa_offset 544
	movq	%fs:40, %rax
	movq	%rax, 504(%rsp)
	xorl	%eax, %eax
	leaq	12(%rsp), %rsi
	movaps	%xmm0, 16(%rsp)
	movaps	%xmm0, 32(%rsp)
	movups	%xmm0, 60(%rsp)
	movups	%xmm0, 76(%rsp)
	movups	%xmm0, 104(%rsp)
	movups	%xmm0, 120(%rsp)
	movups	%xmm0, 148(%rsp)
	movups	%xmm0, 164(%rsp)
	movaps	%xmm0, 192(%rsp)
	movaps	%xmm0, 208(%rsp)
	movups	%xmm0, 236(%rsp)
	movups	%xmm0, 252(%rsp)
	movups	%xmm0, 280(%rsp)
	movups	%xmm0, 296(%rsp)
	movups	%xmm0, 324(%rsp)
	movups	%xmm0, 340(%rsp)
	movaps	%xmm0, 368(%rsp)
	movaps	%xmm0, 384(%rsp)
	movq	$0, 48(%rsp)
	movq	$0, 92(%rsp)
	movq	$0, 136(%rsp)
	movq	$0, 180(%rsp)
	movq	$0, 224(%rsp)
	movq	$0, 268(%rsp)
	movq	$0, 312(%rsp)
	movq	$0, 356(%rsp)
	movq	$0, 400(%rsp)
	movq	$0, 444(%rsp)
	movups	%xmm0, 412(%rsp)
	movups	%xmm0, 428(%rsp)
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %eax
	testl	%eax, %eax
	jle	.L2
	leal	1(%rax), %r8d
	movl	$2, %esi
	movl	$3435973837, %ecx
	movl	$1, 64(%rsp)
	cmpl	$1, %eax
	je	.L2
	.p2align 4,,10
	.p2align 3
.L6:
	leal	9(%rsi), %eax
	cmpl	$18, %eax
	movl	%esi, %eax
	jbe	.L7
	.p2align 4,,10
	.p2align 3
.L5:
	movl	%eax, %eax
	imulq	%rcx, %rax
	shrq	$35, %rax
	leal	9(%rax), %edx
	cmpl	$18, %edx
	ja	.L5
.L7:
	movl	%esi, %edx
	cltq
	imulq	%rcx, %rdx
	shrq	$35, %rdx
	leal	(%rdx,%rdx,4), %edi
	movl	%esi, %edx
	addl	$1, %esi
	addl	%edi, %edi
	subl	%edi, %edx
	leaq	(%rax,%rax,4), %rdi
	movslq	%edx, %rdx
	leaq	(%rax,%rdi,2), %rax
	addq	%rdx, %rax
	addl	$1, 16(%rsp,%rax,4)
	cmpl	%r8d, %esi
	jne	.L6
.L2:
	leaq	64(%rsp), %rax
	movl	$9, %ebp
	xorl	%edx, %edx
	movl	$8, %ebx
	movl	$7, %r11d
	movl	$3, %edi
	movl	$1, %ecx
	movl	$6, %r10d
	movl	$5, %r9d
	movl	$4, %r8d
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L55:
	imull	88(%rax), %r12d
	leal	(%rdx,%r12,2), %edx
.L14:
	cmpl	$10, %r8d
	je	.L12
	movl	12(%rax), %r12d
	cmpl	%r8d, %esi
	je	.L15
	imull	132(%rax), %r12d
	leal	(%rdx,%r12,2), %edx
.L16:
	cmpl	$10, %r9d
	je	.L12
	movl	16(%rax), %r12d
	cmpl	%r9d, %esi
	je	.L17
	imull	176(%rax), %r12d
	leal	(%rdx,%r12,2), %edx
.L18:
	cmpl	$10, %r10d
	je	.L12
	movl	20(%rax), %r12d
	cmpl	%r10d, %esi
	je	.L19
	imull	220(%rax), %r12d
	leal	(%rdx,%r12,2), %edx
.L20:
	cmpl	$10, %r11d
	je	.L12
	movl	24(%rax), %r12d
	cmpl	%r11d, %esi
	je	.L21
	imull	264(%rax), %r12d
	leal	(%rdx,%r12,2), %edx
.L22:
	cmpl	$10, %ebx
	je	.L12
	movl	28(%rax), %r12d
	cmpl	%ebx, %esi
	je	.L23
	imull	308(%rax), %r12d
	leal	(%rdx,%r12,2), %edx
.L24:
	cmpl	$10, %ebp
	je	.L12
	movl	32(%rax), %r12d
	cmpl	%ebp, %esi
	je	.L54
	imull	352(%rax), %r12d
	leal	(%rdx,%r12,2), %edx
.L12:
	addq	$1, %rcx
	addq	$48, %rax
	addl	$1, %edi
	addl	$1, %r8d
	addl	$1, %r9d
	addl	$1, %r10d
	addl	$1, %r11d
	addl	$1, %ebx
	addl	$1, %ebp
	cmpq	$10, %rcx
	je	.L11
.L8:
	movl	(%rax), %esi
	imull	%esi, %esi
	addl	%esi, %edx
	cmpq	$9, %rcx
	je	.L12
	movl	4(%rax), %esi
	imull	44(%rax), %esi
	leal	(%rdx,%rsi,2), %edx
	cmpl	$10, %edi
	je	.L12
	movl	8(%rax), %r12d
	movl	%ecx, %esi
	cmpl	%edi, %ecx
	jne	.L55
	imull	%r12d, %r12d
	addl	%r12d, %edx
	jmp	.L14
	.p2align 4,,10
	.p2align 3
.L15:
	imull	%r12d, %r12d
	addl	%r12d, %edx
	jmp	.L16
	.p2align 4,,10
	.p2align 3
.L17:
	imull	%r12d, %r12d
	addl	%r12d, %edx
	jmp	.L18
.L19:
	imull	%r12d, %r12d
	addl	%r12d, %edx
	jmp	.L20
.L11:
	xorl	%eax, %eax
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	call	__printf_chk@PLT
	movq	504(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L56
	addq	$512, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 32
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
.L21:
	.cfi_restore_state
	imull	%r12d, %r12d
	addl	%r12d, %edx
	jmp	.L22
.L23:
	imull	%r12d, %r12d
	addl	%r12d, %edx
	jmp	.L24
.L54:
	imull	%r12d, %r12d
	addl	%r12d, %edx
	jmp	.L12
.L56:
	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	"%d\n"
	.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
	pxor	%xmm0, %xmm0
	leaq	.LC0(%rip), %rdi
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	subq	$512, %rsp
	.cfi_def_cfa_offset 544
	movq	%fs:40, %rax
	movq	%rax, 504(%rsp)
	xorl	%eax, %eax
	leaq	12(%rsp), %rsi
	movaps	%xmm0, 16(%rsp)
	movaps	%xmm0, 32(%rsp)
	movups	%xmm0, 60(%rsp)
	movups	%xmm0, 76(%rsp)
	movups	%xmm0, 104(%rsp)
	movups	%xmm0, 120(%rsp)
	movups	%xmm0, 148(%rsp)
	movups	%xmm0, 164(%rsp)
	movaps	%xmm0, 192(%rsp)
	movaps	%xmm0, 208(%rsp)
	movups	%xmm0, 236(%rsp)
	movups	%xmm0, 252(%rsp)
	movups	%xmm0, 280(%rsp)
	movups	%xmm0, 296(%rsp)
	movups	%xmm0, 324(%rsp)
	movups	%xmm0, 340(%rsp)
	movaps	%xmm0, 368(%rsp)
	movaps	%xmm0, 384(%rsp)
	movq	$0, 48(%rsp)
	movq	$0, 92(%rsp)
	movq	$0, 136(%rsp)
	movq	$0, 180(%rsp)
	movq	$0, 224(%rsp)
	movq	$0, 268(%rsp)
	movq	$0, 312(%rsp)
	movq	$0, 356(%rsp)
	movq	$0, 400(%rsp)
	movq	$0, 444(%rsp)
	movups	%xmm0, 412(%rsp)
	movups	%xmm0, 428(%rsp)
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %eax
	testl	%eax, %eax
	jle	.L2
	leal	1(%rax), %r8d
	movl	$2, %esi
	movl	$3435973837, %ecx
	movl	$1, 64(%rsp)
	cmpl	$1, %eax
	je	.L2
	.p2align 4,,10
	.p2align 3
.L6:
	leal	9(%rsi), %eax
	cmpl	$18, %eax
	movl	%esi, %eax
	jbe	.L7
	.p2align 4,,10
	.p2align 3
.L5:
	movl	%eax, %eax
	imulq	%rcx, %rax
	shrq	$35, %rax
	leal	9(%rax), %edx
	cmpl	$18, %edx
	ja	.L5
.L7:
	movl	%esi, %edx
	cltq
	imulq	%rcx, %rdx
	shrq	$35, %rdx
	leal	(%rdx,%rdx,4), %edi
	movl	%esi, %edx
	addl	$1, %esi
	addl	%edi, %edi
	subl	%edi, %edx
	leaq	(%rax,%rax,4), %rdi
	movslq	%edx, %rdx
	leaq	(%rax,%rdi,2), %rax
	addq	%rdx, %rax
	addl	$1, 16(%rsp,%rax,4)
	cmpl	%r8d, %esi
	jne	.L6
.L2:
	leaq	64(%rsp), %rax
	movl	$9, %ebp
	xorl	%edx, %edx
	movl	$8, %ebx
	movl	$7, %r11d
	movl	$3, %edi
	movl	$1, %ecx
	movl	$6, %r10d
	movl	$5, %r9d
	movl	$4, %r8d
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L55:
	imull	88(%rax), %r12d
	leal	(%rdx,%r12,2), %edx
.L14:
	cmpl	$10, %r8d
	je	.L12
	movl	12(%rax), %r12d
	cmpl	%r8d, %esi
	je	.L15
	imull	132(%rax), %r12d
	leal	(%rdx,%r12,2), %edx
.L16:
	cmpl	$10, %r9d
	je	.L12
	movl	16(%rax), %r12d
	cmpl	%r9d, %esi
	je	.L17
	imull	176(%rax), %r12d
	leal	(%rdx,%r12,2), %edx
.L18:
	cmpl	$10, %r10d
	je	.L12
	movl	20(%rax), %r12d
	cmpl	%r10d, %esi
	je	.L19
	imull	220(%rax), %r12d
	leal	(%rdx,%r12,2), %edx
.L20:
	cmpl	$10, %r11d
	je	.L12
	movl	24(%rax), %r12d
	cmpl	%r11d, %esi
	je	.L21
	imull	264(%rax), %r12d
	leal	(%rdx,%r12,2), %edx
.L22:
	cmpl	$10, %ebx
	je	.L12
	movl	28(%rax), %r12d
	cmpl	%ebx, %esi
	je	.L23
	imull	308(%rax), %r12d
	leal	(%rdx,%r12,2), %edx
.L24:
	cmpl	$10, %ebp
	je	.L12
	movl	32(%rax), %r12d
	cmpl	%ebp, %esi
	je	.L54
	imull	352(%rax), %r12d
	leal	(%rdx,%r12,2), %edx
.L12:
	addq	$1, %rcx
	addq	$48, %rax
	addl	$1, %edi
	addl	$1, %r8d
	addl	$1, %r9d
	addl	$1, %r10d
	addl	$1, %r11d
	addl	$1, %ebx
	addl	$1, %ebp
	cmpq	$10, %rcx
	je	.L11
.L8:
	movl	(%rax), %esi
	imull	%esi, %esi
	addl	%esi, %edx
	cmpq	$9, %rcx
	je	.L12
	movl	4(%rax), %esi
	imull	44(%rax), %esi
	leal	(%rdx,%rsi,2), %edx
	cmpl	$10, %edi
	je	.L12
	movl	8(%rax), %r12d
	movl	%ecx, %esi
	cmpl	%edi, %ecx
	jne	.L55
	imull	%r12d, %r12d
	addl	%r12d, %edx
	jmp	.L14
	.p2align 4,,10
	.p2align 3
.L15:
	imull	%r12d, %r12d
	addl	%r12d, %edx
	jmp	.L16
	.p2align 4,,10
	.p2align 3
.L17:
	imull	%r12d, %r12d
	addl	%r12d, %edx
	jmp	.L18
.L19:
	imull	%r12d, %r12d
	addl	%r12d, %edx
	jmp	.L20
.L11:
	xorl	%eax, %eax
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	call	__printf_chk@PLT
	movq	504(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L56
	addq	$512, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 32
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
.L21:
	.cfi_restore_state
	imull	%r12d, %r12d
	addl	%r12d, %edx
	jmp	.L22
.L23:
	imull	%r12d, %r12d
	addl	%r12d, %edx
	jmp	.L24
.L54:
	imull	%r12d, %r12d
	addl	%r12d, %edx
	jmp	.L12
.L56:
	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(){
  int n,i,j,count=0;
  int a[11][11];
  for(i=0;i<10;i++)
    for(j=0;j<10;j++)
      a[i][j]=0;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    j=i;
    while(j/10!=0)
      j/=10;
    a[j][i%10]++;
  }
  for(i=1;i<=9;i++){
    for(j=i;j<=9;j++){
      if(i==j)
        count+=a[i][j]*a[i][j];
      else
        count+=2*a[i][j]*a[j][i];
    }
  }
  printf("%d\n",count);
  return 0;
}

73
 3093
 50
 101
 0
 11
 1020
 78
 001
 6

63
 95976
 33
 113
 0
 12
 10412
 72
 1
 6

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(){
  int n,i,j,count=0;
  int a[11][11];
  for(i=0;i<10;i++)
    for(j=0;j<10;j++)
      a[i][j]=0;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    j=i;
    while(j/10!=0)
      j/=10;
    a[j][i%10]++;
  }
  for(i=1;i<=9;i++){
    for(j=i;j<=9;j++){
      if(i==j)
        count+=a[i][j]*a[i][j];
      else
        count+=2*a[i][j]*a[j][i];
    }
  }
  printf("%d\n",count);
  return 0;
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d"
.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	$512, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -500(%rbp)
	movl	$0, -508(%rbp)
	jmp	.L2
.L5:
	movl	$0, -504(%rbp)
	jmp	.L3
.L4:
	movl	-504(%rbp), %eax
	movslq	%eax, %rcx
	movl	-508(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	addq	%rcx, %rax
	movl	$0, -496(%rbp,%rax,4)
	addl	$1, -504(%rbp)
.L3:
	cmpl	$9, -504(%rbp)
	jle	.L4
	addl	$1, -508(%rbp)
.L2:
	cmpl	$9, -508(%rbp)
	jle	.L5
	leaq	-512(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$1, -508(%rbp)
	jmp	.L6
.L9:
	movl	-508(%rbp), %eax
	movl	%eax, -504(%rbp)
	jmp	.L7
.L8:
	movl	-504(%rbp), %eax
	movslq	%eax, %rdx
	imulq	$1717986919, %rdx, %rdx
	shrq	$32, %rdx
	sarl	$2, %edx
	sarl	$31, %eax
	movl	%eax, %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	movl	%eax, -504(%rbp)
.L7:
	movl	-504(%rbp), %eax
	addl	$9, %eax
	cmpl	$18, %eax
	ja	.L8
	movl	-508(%rbp), %ecx
	movslq	%ecx, %rax
	imulq	$1717986919, %rax, %rax
	shrq	$32, %rax
	sarl	$2, %eax
	movl	%ecx, %esi
	sarl	$31, %esi
	subl	%esi, %eax
	movl	%eax, %edx
	movl	%edx, %eax
	sall	$2, %eax
	addl	%edx, %eax
	addl	%eax, %eax
	subl	%eax, %ecx
	movl	%ecx, %edx
	movslq	%edx, %rsi
	movl	-504(%rbp), %eax
	movslq	%eax, %rcx
	movq	%rcx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	addq	%rax, %rax
	addq	%rcx, %rax
	addq	%rsi, %rax
	movl	-496(%rbp,%rax,4), %eax
	leal	1(%rax), %ecx
	movslq	%edx, %rsi
	movl	-504(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	addq	%rsi, %rax
	movl	%ecx, -496(%rbp,%rax,4)
	addl	$1, -508(%rbp)
.L6:
	movl	-512(%rbp), %eax
	cmpl	%eax, -508(%rbp)
	jle	.L9
	movl	$1, -508(%rbp)
	jmp	.L10
.L15:
	movl	-508(%rbp), %eax
	movl	%eax, -504(%rbp)
	jmp	.L11
.L14:
	movl	-508(%rbp), %eax
	cmpl	-504(%rbp), %eax
	jne	.L12
	movl	-504(%rbp), %eax
	movslq	%eax, %rcx
	movl	-508(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	addq	%rcx, %rax
	movl	-496(%rbp,%rax,4), %ecx
	movl	-504(%rbp), %eax
	movslq	%eax, %rsi
	movl	-508(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	addq	%rsi, %rax
	movl	-496(%rbp,%rax,4), %eax
	imull	%ecx, %eax
	addl	%eax, -500(%rbp)
	jmp	.L13
.L12:
	movl	-504(%rbp), %eax
	movslq	%eax, %rcx
	movl	-508(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	addq	%rcx, %rax
	movl	-496(%rbp,%rax,4), %ecx
	movl	-508(%rbp), %eax
	movslq	%eax, %rsi
	movl	-504(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	addq	%rsi, %rax
	movl	-496(%rbp,%rax,4), %eax
	imull	%ecx, %eax
	addl	%eax, %eax
	addl	%eax, -500(%rbp)
.L13:
	addl	$1, -504(%rbp)
.L11:
	cmpl	$9, -504(%rbp)
	jle	.L14
	addl	$1, -508(%rbp)
.L10:
	cmpl	$9, -508(%rbp)
	jle	.L15
	movl	-500(%rbp), %eax
	movl	%eax, %esi
	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	.L17
	call	__stack_chk_fail@PLT
.L17:
	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	"%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	$512, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -500(%rbp)
	movl	$0, -508(%rbp)
	jmp	.L2
.L5:
	movl	$0, -504(%rbp)
	jmp	.L3
.L4:
	movl	-504(%rbp), %eax
	movslq	%eax, %rcx
	movl	-508(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	addq	%rcx, %rax
	movl	$0, -496(%rbp,%rax,4)
	addl	$1, -504(%rbp)
.L3:
	cmpl	$9, -504(%rbp)
	jle	.L4
	addl	$1, -508(%rbp)
.L2:
	cmpl	$9, -508(%rbp)
	jle	.L5
	leaq	-512(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$1, -508(%rbp)
	jmp	.L6
.L9:
	movl	-508(%rbp), %eax
	movl	%eax, -504(%rbp)
	jmp	.L7
.L8:
	movl	-504(%rbp), %eax
	movslq	%eax, %rdx
	imulq	$1717986919, %rdx, %rdx
	shrq	$32, %rdx
	sarl	$2, %edx
	sarl	$31, %eax
	movl	%eax, %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	movl	%eax, -504(%rbp)
.L7:
	movl	-504(%rbp), %eax
	addl	$9, %eax
	cmpl	$18, %eax
	ja	.L8
	movl	-508(%rbp), %ecx
	movslq	%ecx, %rax
	imulq	$1717986919, %rax, %rax
	shrq	$32, %rax
	sarl	$2, %eax
	movl	%ecx, %esi
	sarl	$31, %esi
	subl	%esi, %eax
	movl	%eax, %edx
	movl	%edx, %eax
	sall	$2, %eax
	addl	%edx, %eax
	addl	%eax, %eax
	subl	%eax, %ecx
	movl	%ecx, %edx
	movslq	%edx, %rsi
	movl	-504(%rbp), %eax
	movslq	%eax, %rcx
	movq	%rcx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	addq	%rax, %rax
	addq	%rcx, %rax
	addq	%rsi, %rax
	movl	-496(%rbp,%rax,4), %eax
	leal	1(%rax), %ecx
	movslq	%edx, %rsi
	movl	-504(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	addq	%rsi, %rax
	movl	%ecx, -496(%rbp,%rax,4)
	addl	$1, -508(%rbp)
.L6:
	movl	-512(%rbp), %eax
	cmpl	%eax, -508(%rbp)
	jle	.L9
	movl	$1, -508(%rbp)
	jmp	.L10
.L15:
	movl	-508(%rbp), %eax
	movl	%eax, -504(%rbp)
	jmp	.L11
.L14:
	movl	-508(%rbp), %eax
	cmpl	-504(%rbp), %eax
	jne	.L12
	movl	-504(%rbp), %eax
	movslq	%eax, %rcx
	movl	-508(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	addq	%rcx, %rax
	movl	-496(%rbp,%rax,4), %ecx
	movl	-504(%rbp), %eax
	movslq	%eax, %rsi
	movl	-508(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	addq	%rsi, %rax
	movl	-496(%rbp,%rax,4), %eax
	imull	%ecx, %eax
	addl	%eax, -500(%rbp)
	jmp	.L13
.L12:
	movl	-504(%rbp), %eax
	movslq	%eax, %rcx
	movl	-508(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	addq	%rcx, %rax
	movl	-496(%rbp,%rax,4), %ecx
	movl	-508(%rbp), %eax
	movslq	%eax, %rsi
	movl	-504(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	addq	%rsi, %rax
	movl	-496(%rbp,%rax,4), %eax
	imull	%ecx, %eax
	addl	%eax, %eax
	addl	%eax, -500(%rbp)
.L13:
	addl	$1, -504(%rbp)
.L11:
	cmpl	$9, -504(%rbp)
	jle	.L14
	addl	$1, -508(%rbp)
.L10:
	cmpl	$9, -508(%rbp)
	jle	.L15
	movl	-500(%rbp), %eax
	movl	%eax, %esi
	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	.L17
	call	__stack_chk_fail@PLT
.L17:
	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:
