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(){
  int n, d;  scanf("%d %d", &n, &d);
  int x[13][13];
  for(int i=1; i<=n; i++)
    for(int j=1; j<=d; j++)
      scanf("%d", &x[i][j]);
  int count = 0;
  for(int i=1; i<n; i++){
    for(int j=i+1; j<=n; j++){
      int dis = 0;
      for(int k=1; k<=d; k++)
	dis = dis + (x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
      if(dis == (int)sqrt(dis)*(int)sqrt(dis)){
	count++;
      }
    }
  }
  printf("%d\n", count);
  return 0;
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d %d"
.LC1:
	.string	"%d"
.LC2:
	.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
	pushq	%rbx
	subq	$744, %rsp
	.cfi_offset 3, -24
	movq	%fs:40, %rax
	movq	%rax, -24(%rbp)
	xorl	%eax, %eax
	leaq	-736(%rbp), %rdx
	leaq	-740(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$1, -732(%rbp)
	jmp	.L2
.L5:
	movl	$1, -728(%rbp)
	jmp	.L3
.L4:
	leaq	-704(%rbp), %rcx
	movl	-728(%rbp), %eax
	movslq	%eax, %rsi
	movl	-732(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rsi, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -728(%rbp)
.L3:
	movl	-736(%rbp), %eax
	cmpl	%eax, -728(%rbp)
	jle	.L4
	addl	$1, -732(%rbp)
.L2:
	movl	-740(%rbp), %eax
	cmpl	%eax, -732(%rbp)
	jle	.L5
	movl	$0, -724(%rbp)
	movl	$1, -720(%rbp)
	jmp	.L6
.L12:
	movl	-720(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -716(%rbp)
	jmp	.L7
.L11:
	movl	$0, -712(%rbp)
	movl	$1, -708(%rbp)
	jmp	.L8
.L9:
	movl	-708(%rbp), %eax
	movslq	%eax, %rcx
	movl	-720(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rcx, %rax
	movl	-704(%rbp,%rax,4), %ecx
	movl	-708(%rbp), %eax
	movslq	%eax, %rsi
	movl	-716(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rsi, %rax
	movl	-704(%rbp,%rax,4), %eax
	movl	%ecx, %esi
	subl	%eax, %esi
	movl	-708(%rbp), %eax
	movslq	%eax, %rcx
	movl	-720(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rcx, %rax
	movl	-704(%rbp,%rax,4), %ecx
	movl	-708(%rbp), %eax
	movslq	%eax, %rdi
	movl	-716(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rdi, %rax
	movl	-704(%rbp,%rax,4), %edx
	movl	%ecx, %eax
	subl	%edx, %eax
	imull	%esi, %eax
	addl	%eax, -712(%rbp)
	addl	$1, -708(%rbp)
.L8:
	movl	-736(%rbp), %eax
	cmpl	%eax, -708(%rbp)
	jle	.L9
	pxor	%xmm1, %xmm1
	cvtsi2sdl	-712(%rbp), %xmm1
	movq	%xmm1, %rax
	movq	%rax, %xmm0
	call	sqrt@PLT
	cvttsd2sil	%xmm0, %ebx
	pxor	%xmm2, %xmm2
	cvtsi2sdl	-712(%rbp), %xmm2
	movq	%xmm2, %rax
	movq	%rax, %xmm0
	call	sqrt@PLT
	cvttsd2sil	%xmm0, %eax
	imull	%ebx, %eax
	cmpl	%eax, -712(%rbp)
	jne	.L10
	addl	$1, -724(%rbp)
.L10:
	addl	$1, -716(%rbp)
.L7:
	movl	-740(%rbp), %eax
	cmpl	%eax, -716(%rbp)
	jle	.L11
	addl	$1, -720(%rbp)
.L6:
	movl	-740(%rbp), %eax
	cmpl	%eax, -720(%rbp)
	jl	.L12
	movl	-724(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-24(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L14
	call	__stack_chk_fail@PLT
.L14:
	movq	-8(%rbp), %rbx
	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
.LC1:
	.string	"%d %d"
.LC2:
	.string	"%d"
.LC3:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	.LC1(%rip), %rdi
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$776, %rsp
	.cfi_def_cfa_offset 832
	movq	%fs:40, %rax
	movq	%rax, 760(%rsp)
	xorl	%eax, %eax
	leaq	76(%rsp), %rdx
	leaq	72(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movl	72(%rsp), %eax
	testl	%eax, %eax
	jle	.L24
	movl	76(%rsp), %r15d
	leaq	136(%rsp), %r13
	movl	$1, %r12d
	leaq	.LC2(%rip), %rbp
	testl	%r15d, %r15d
	jle	.L38
	.p2align 4,,10
	.p2align 3
.L25:
	movq	%r13, %r14
	movl	$1, %ebx
	.p2align 4,,10
	.p2align 3
.L4:
	movq	%r14, %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	addl	$1, %ebx
	call	__isoc99_scanf@PLT
	movl	76(%rsp), %r15d
	addq	$4, %r14
	cmpl	%ebx, %r15d
	jge	.L4
	movl	72(%rsp), %eax
	addl	$1, %r12d
	cmpl	%r12d, %eax
	jl	.L39
	addq	$52, %r13
	testl	%r15d, %r15d
	jg	.L25
.L38:
	movl	%eax, 32(%rsp)
	cmpl	%r12d, %eax
	jle	.L6
.L7:
	movl	32(%rsp), %eax
	movl	$1, %r14d
	xorl	%r11d, %r11d
	pxor	%xmm2, %xmm2
	leaq	188(%rsp), %r10
	addl	$1, %eax
	movq	%r10, %r13
	movslq	%r14d, %r10
	movl	%r11d, %r14d
	movl	%eax, 8(%rsp)
.L21:
	leal	1(%r10), %ebp
	movl	%ebp, 28(%rsp)
	cmpl	%ebp, 32(%rsp)
	jl	.L9
.L40:
	movl	%r15d, %r11d
	leal	-1(%r15), %eax
	movl	%r15d, %edi
	movq	%r13, %r12
	andl	$-4, %r11d
	movl	%eax, 12(%rsp)
	shrl	$2, %edi
	leal	1(%r11), %eax
	movl	%eax, 24(%rsp)
	leaq	(%r10,%r10,2), %rax
	salq	$2, %rax
	movq	%rax, 16(%rsp)
	.p2align 4,,10
	.p2align 3
.L10:
	xorl	%ebx, %ebx
	movapd	%xmm2, %xmm1
	testl	%r15d, %r15d
	jle	.L20
	cmpl	$2, 12(%rsp)
	jbe	.L26
	movdqu	-52(%r13), %xmm1
	movdqu	(%r12), %xmm4
	psubd	%xmm4, %xmm1
	movdqa	%xmm1, %xmm0
	pmuludq	%xmm1, %xmm0
	psrlq	$32, %xmm1
	pmuludq	%xmm1, %xmm1
	pshufd	$8, %xmm0, %xmm0
	pshufd	$8, %xmm1, %xmm1
	punpckldq	%xmm1, %xmm0
	cmpl	$1, %edi
	jbe	.L12
	movdqu	-36(%r13), %xmm1
	movdqu	16(%r12), %xmm5
	psubd	%xmm5, %xmm1
	movdqa	%xmm1, %xmm3
	pmuludq	%xmm1, %xmm3
	psrlq	$32, %xmm1
	pmuludq	%xmm1, %xmm1
	pshufd	$8, %xmm3, %xmm3
	pshufd	$8, %xmm1, %xmm1
	punpckldq	%xmm1, %xmm3
	paddd	%xmm3, %xmm0
	cmpl	$2, %edi
	je	.L12
	movdqu	-20(%r13), %xmm1
	movdqu	32(%r12), %xmm6
	psubd	%xmm6, %xmm1
	movdqa	%xmm1, %xmm3
	pmuludq	%xmm1, %xmm3
	psrlq	$32, %xmm1
	pmuludq	%xmm1, %xmm1
	pshufd	$8, %xmm3, %xmm3
	pshufd	$8, %xmm1, %xmm1
	punpckldq	%xmm1, %xmm3
	paddd	%xmm3, %xmm0
.L12:
	movdqa	%xmm0, %xmm1
	psrldq	$8, %xmm1
	paddd	%xmm1, %xmm0
	movdqa	%xmm0, %xmm1
	psrldq	$4, %xmm1
	paddd	%xmm1, %xmm0
	movd	%xmm0, %ebx
	cmpl	%r15d, %r11d
	je	.L13
	movl	24(%rsp), %eax
.L11:
	movslq	%ebp, %rsi
	movq	16(%rsp), %rcx
	movslq	%eax, %rdx
	leaq	(%rsi,%rsi,2), %r9
	addq	%r10, %rcx
	leaq	(%rsi,%r9,4), %rsi
	leaq	(%rcx,%rdx), %r8
	addq	%rsi, %rdx
	movl	80(%rsp,%r8,4), %r8d
	subl	80(%rsp,%rdx,4), %r8d
	leal	1(%rax), %edx
	imull	%r8d, %r8d
	addl	%r8d, %ebx
	cmpl	%r15d, %edx
	jg	.L13
	movslq	%edx, %rdx
	addl	$2, %eax
	leaq	(%rcx,%rdx), %r8
	addq	%rsi, %rdx
	movl	80(%rsp,%r8,4), %r8d
	subl	80(%rsp,%rdx,4), %r8d
	imull	%r8d, %r8d
	addl	%r8d, %ebx
	cmpl	%eax, %r15d
	jl	.L13
	cltq
	leaq	(%rsi,%rax), %rdx
	addq	%rax, %rcx
	movl	80(%rsp,%rcx,4), %eax
	subl	80(%rsp,%rdx,4), %eax
	imull	%eax, %eax
	addl	%eax, %ebx
.L13:
	pxor	%xmm1, %xmm1
	cvtsi2sdl	%ebx, %xmm1
	ucomisd	%xmm1, %xmm2
	ja	.L32
.L20:
	sqrtsd	%xmm1, %xmm1
	cvttsd2sil	%xmm1, %eax
	movl	%eax, %edx
.L16:
	imull	%edx, %eax
	cmpl	%ebx, %eax
	sete	%al
	addl	$1, %ebp
	addq	$52, %r12
	movzbl	%al, %eax
	addl	%eax, %r14d
	cmpl	8(%rsp), %ebp
	jne	.L10
	movl	28(%rsp), %edi
	addq	$52, %r13
	cmpl	%edi, 32(%rsp)
	je	.L34
	movslq	%edi, %r10
	movl	76(%rsp), %r15d
	leal	1(%r10), %ebp
	movl	%ebp, 28(%rsp)
	cmpl	%ebp, 32(%rsp)
	jge	.L40
.L9:
	addq	$52, %r13
	movslq	%ebp, %r10
	jmp	.L21
.L26:
	movl	$1, %eax
	xorl	%ebx, %ebx
	jmp	.L11
.L34:
	movl	%r14d, %r11d
.L2:
	xorl	%eax, %eax
	movl	%r11d, %edx
	movl	$1, %edi
	leaq	.LC3(%rip), %rsi
	call	__printf_chk@PLT
	movq	760(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L41
	addq	$776, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	xorl	%eax, %eax
	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
.L39:
	.cfi_restore_state
	movl	%eax, 32(%rsp)
.L6:
	cmpl	$1, 32(%rsp)
	jg	.L7
.L24:
	xorl	%r11d, %r11d
	jmp	.L2
.L32:
	movapd	%xmm1, %xmm0
	movq	%r10, 56(%rsp)
	movl	%edi, 52(%rsp)
	movl	%r11d, 48(%rsp)
	movsd	%xmm1, 40(%rsp)
	call	sqrt@PLT
	movsd	40(%rsp), %xmm1
	cvttsd2sil	%xmm0, %edx
	movapd	%xmm1, %xmm0
	movl	%edx, 36(%rsp)
	call	sqrt@PLT
	movq	56(%rsp), %r10
	movl	52(%rsp), %edi
	pxor	%xmm2, %xmm2
	cvttsd2sil	%xmm0, %eax
	movl	48(%rsp), %r11d
	movl	36(%rsp), %edx
	jmp	.L16
.L41:
	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
.LC1:
	.string	"%d %d"
.LC2:
	.string	"%d"
.LC3:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	.LC1(%rip), %rdi
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$776, %rsp
	.cfi_def_cfa_offset 832
	movq	%fs:40, %rax
	movq	%rax, 760(%rsp)
	xorl	%eax, %eax
	leaq	76(%rsp), %rdx
	leaq	72(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movl	72(%rsp), %eax
	testl	%eax, %eax
	jle	.L24
	movl	76(%rsp), %r15d
	leaq	136(%rsp), %r13
	movl	$1, %r12d
	leaq	.LC2(%rip), %rbp
	testl	%r15d, %r15d
	jle	.L38
	.p2align 4,,10
	.p2align 3
.L25:
	movq	%r13, %r14
	movl	$1, %ebx
	.p2align 4,,10
	.p2align 3
.L4:
	movq	%r14, %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	addl	$1, %ebx
	call	__isoc99_scanf@PLT
	movl	76(%rsp), %r15d
	addq	$4, %r14
	cmpl	%ebx, %r15d
	jge	.L4
	movl	72(%rsp), %eax
	addl	$1, %r12d
	cmpl	%r12d, %eax
	jl	.L39
	addq	$52, %r13
	testl	%r15d, %r15d
	jg	.L25
.L38:
	movl	%eax, 32(%rsp)
	cmpl	%r12d, %eax
	jle	.L6
.L7:
	movl	32(%rsp), %eax
	movl	$1, %r14d
	xorl	%r11d, %r11d
	pxor	%xmm2, %xmm2
	leaq	188(%rsp), %r10
	addl	$1, %eax
	movq	%r10, %r13
	movslq	%r14d, %r10
	movl	%r11d, %r14d
	movl	%eax, 8(%rsp)
.L21:
	leal	1(%r10), %ebp
	movl	%ebp, 28(%rsp)
	cmpl	%ebp, 32(%rsp)
	jl	.L9
.L40:
	movl	%r15d, %r11d
	leal	-1(%r15), %eax
	movl	%r15d, %edi
	movq	%r13, %r12
	andl	$-4, %r11d
	movl	%eax, 12(%rsp)
	shrl	$2, %edi
	leal	1(%r11), %eax
	movl	%eax, 24(%rsp)
	leaq	(%r10,%r10,2), %rax
	salq	$2, %rax
	movq	%rax, 16(%rsp)
	.p2align 4,,10
	.p2align 3
.L10:
	xorl	%ebx, %ebx
	movapd	%xmm2, %xmm1
	testl	%r15d, %r15d
	jle	.L20
	cmpl	$2, 12(%rsp)
	jbe	.L26
	movdqu	-52(%r13), %xmm1
	movdqu	(%r12), %xmm4
	psubd	%xmm4, %xmm1
	movdqa	%xmm1, %xmm0
	pmuludq	%xmm1, %xmm0
	psrlq	$32, %xmm1
	pmuludq	%xmm1, %xmm1
	pshufd	$8, %xmm0, %xmm0
	pshufd	$8, %xmm1, %xmm1
	punpckldq	%xmm1, %xmm0
	cmpl	$1, %edi
	jbe	.L12
	movdqu	-36(%r13), %xmm1
	movdqu	16(%r12), %xmm5
	psubd	%xmm5, %xmm1
	movdqa	%xmm1, %xmm3
	pmuludq	%xmm1, %xmm3
	psrlq	$32, %xmm1
	pmuludq	%xmm1, %xmm1
	pshufd	$8, %xmm3, %xmm3
	pshufd	$8, %xmm1, %xmm1
	punpckldq	%xmm1, %xmm3
	paddd	%xmm3, %xmm0
	cmpl	$2, %edi
	je	.L12
	movdqu	-20(%r13), %xmm1
	movdqu	32(%r12), %xmm6
	psubd	%xmm6, %xmm1
	movdqa	%xmm1, %xmm3
	pmuludq	%xmm1, %xmm3
	psrlq	$32, %xmm1
	pmuludq	%xmm1, %xmm1
	pshufd	$8, %xmm3, %xmm3
	pshufd	$8, %xmm1, %xmm1
	punpckldq	%xmm1, %xmm3
	paddd	%xmm3, %xmm0
.L12:
	movdqa	%xmm0, %xmm1
	psrldq	$8, %xmm1
	paddd	%xmm1, %xmm0
	movdqa	%xmm0, %xmm1
	psrldq	$4, %xmm1
	paddd	%xmm1, %xmm0
	movd	%xmm0, %ebx
	cmpl	%r15d, %r11d
	je	.L13
	movl	24(%rsp), %eax
.L11:
	movslq	%ebp, %rsi
	movq	16(%rsp), %rcx
	movslq	%eax, %rdx
	leaq	(%rsi,%rsi,2), %r9
	addq	%r10, %rcx
	leaq	(%rsi,%r9,4), %rsi
	leaq	(%rcx,%rdx), %r8
	addq	%rsi, %rdx
	movl	80(%rsp,%r8,4), %r8d
	subl	80(%rsp,%rdx,4), %r8d
	leal	1(%rax), %edx
	imull	%r8d, %r8d
	addl	%r8d, %ebx
	cmpl	%r15d, %edx
	jg	.L13
	movslq	%edx, %rdx
	addl	$2, %eax
	leaq	(%rcx,%rdx), %r8
	addq	%rsi, %rdx
	movl	80(%rsp,%r8,4), %r8d
	subl	80(%rsp,%rdx,4), %r8d
	imull	%r8d, %r8d
	addl	%r8d, %ebx
	cmpl	%eax, %r15d
	jl	.L13
	cltq
	leaq	(%rsi,%rax), %rdx
	addq	%rax, %rcx
	movl	80(%rsp,%rcx,4), %eax
	subl	80(%rsp,%rdx,4), %eax
	imull	%eax, %eax
	addl	%eax, %ebx
.L13:
	pxor	%xmm1, %xmm1
	cvtsi2sdl	%ebx, %xmm1
	ucomisd	%xmm1, %xmm2
	ja	.L32
.L20:
	sqrtsd	%xmm1, %xmm1
	cvttsd2sil	%xmm1, %eax
	movl	%eax, %edx
.L16:
	imull	%edx, %eax
	cmpl	%ebx, %eax
	sete	%al
	addl	$1, %ebp
	addq	$52, %r12
	movzbl	%al, %eax
	addl	%eax, %r14d
	cmpl	8(%rsp), %ebp
	jne	.L10
	movl	28(%rsp), %edi
	addq	$52, %r13
	cmpl	%edi, 32(%rsp)
	je	.L34
	movslq	%edi, %r10
	movl	76(%rsp), %r15d
	leal	1(%r10), %ebp
	movl	%ebp, 28(%rsp)
	cmpl	%ebp, 32(%rsp)
	jge	.L40
.L9:
	addq	$52, %r13
	movslq	%ebp, %r10
	jmp	.L21
.L26:
	movl	$1, %eax
	xorl	%ebx, %ebx
	jmp	.L11
.L34:
	movl	%r14d, %r11d
.L2:
	xorl	%eax, %eax
	movl	%r11d, %edx
	movl	$1, %edi
	leaq	.LC3(%rip), %rsi
	call	__printf_chk@PLT
	movq	760(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L41
	addq	$776, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	xorl	%eax, %eax
	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
.L39:
	.cfi_restore_state
	movl	%eax, 32(%rsp)
.L6:
	cmpl	$1, 32(%rsp)
	jg	.L7
.L24:
	xorl	%r11d, %r11d
	jmp	.L2
.L32:
	movapd	%xmm1, %xmm0
	movq	%r10, 56(%rsp)
	movl	%edi, 52(%rsp)
	movl	%r11d, 48(%rsp)
	movsd	%xmm1, 40(%rsp)
	call	sqrt@PLT
	movsd	40(%rsp), %xmm1
	cvttsd2sil	%xmm0, %edx
	movapd	%xmm1, %xmm0
	movl	%edx, 36(%rsp)
	call	sqrt@PLT
	movq	56(%rsp), %r10
	movl	52(%rsp), %edi
	pxor	%xmm2, %xmm2
	cvttsd2sil	%xmm0, %eax
	movl	48(%rsp), %r11d
	movl	36(%rsp), %edx
	jmp	.L16
.L41:
	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>
#include <math.h>

int main(){
  int n, d;  scanf("%d %d", &n, &d);
  int x[13][13];
  for(int i=1; i<=n; i++)
    for(int j=1; j<=d; j++)
      scanf("%d", &x[i][j]);
  int count = 0;
  for(int i=1; i<n; i++){
    for(int j=i+1; j<=n; j++){
      int dis = 0;
      for(int k=1; k<=d; k++)
	dis = dis + (x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
      if(dis == (int)sqrt(dis)*(int)sqrt(dis)){
	count++;
      }
    }
  }
  printf("%d\n", count);
  return 0;
}

3 4
-3 7 8 2
-12 1 10 2
-2 8 9 0
 1 1
1
2
3
4
5
 5 1
0
2
3
4
5
 3 2
1 8
5 5
-2 8
 3 2
1 4
5 5
-2 8
 3 4
-3 7 8 2
-12 1 10 2
-2 8 13 0
 3 2
2 4
5 5
-2 8
 0 1
1
2
3
4
5
 3 4
-3 7 8 2
-18 1 10 2
-2 8 13 0
 3 2
0 4
5 5
-2 8

1
 0
 10
 2
 1
 1
 0
 0
 0
 0

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(){
  int n, d;  scanf("%d %d", &n, &d);
  int x[13][13];
  for(int i=1; i<=n; i++)
    for(int j=1; j<=d; j++)
      scanf("%d", &x[i][j]);
  int count = 0;
  for(int i=1; i<n; i++){
    for(int j=i+1; j<=n; j++){
      int dis = 0;
      for(int k=1; k<=d; k++)
	dis = dis + (x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
      if(dis == (int)sqrt(dis)*(int)sqrt(dis)){
	count++;
      }
    }
  }
  printf("%d\n", count);
  return 0;
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d %d"
.LC1:
	.string	"%d"
.LC2:
	.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
	pushq	%rbx
	subq	$744, %rsp
	.cfi_offset 3, -24
	movq	%fs:40, %rax
	movq	%rax, -24(%rbp)
	xorl	%eax, %eax
	leaq	-736(%rbp), %rdx
	leaq	-740(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$1, -732(%rbp)
	jmp	.L2
.L5:
	movl	$1, -728(%rbp)
	jmp	.L3
.L4:
	leaq	-704(%rbp), %rcx
	movl	-728(%rbp), %eax
	movslq	%eax, %rsi
	movl	-732(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rsi, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -728(%rbp)
.L3:
	movl	-736(%rbp), %eax
	cmpl	%eax, -728(%rbp)
	jle	.L4
	addl	$1, -732(%rbp)
.L2:
	movl	-740(%rbp), %eax
	cmpl	%eax, -732(%rbp)
	jle	.L5
	movl	$0, -724(%rbp)
	movl	$1, -720(%rbp)
	jmp	.L6
.L12:
	movl	-720(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -716(%rbp)
	jmp	.L7
.L11:
	movl	$0, -712(%rbp)
	movl	$1, -708(%rbp)
	jmp	.L8
.L9:
	movl	-708(%rbp), %eax
	movslq	%eax, %rcx
	movl	-720(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rcx, %rax
	movl	-704(%rbp,%rax,4), %ecx
	movl	-708(%rbp), %eax
	movslq	%eax, %rsi
	movl	-716(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rsi, %rax
	movl	-704(%rbp,%rax,4), %eax
	movl	%ecx, %esi
	subl	%eax, %esi
	movl	-708(%rbp), %eax
	movslq	%eax, %rcx
	movl	-720(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rcx, %rax
	movl	-704(%rbp,%rax,4), %ecx
	movl	-708(%rbp), %eax
	movslq	%eax, %rdi
	movl	-716(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rdi, %rax
	movl	-704(%rbp,%rax,4), %edx
	movl	%ecx, %eax
	subl	%edx, %eax
	imull	%esi, %eax
	addl	%eax, -712(%rbp)
	addl	$1, -708(%rbp)
.L8:
	movl	-736(%rbp), %eax
	cmpl	%eax, -708(%rbp)
	jle	.L9
	pxor	%xmm1, %xmm1
	cvtsi2sdl	-712(%rbp), %xmm1
	movq	%xmm1, %rax
	movq	%rax, %xmm0
	call	sqrt@PLT
	cvttsd2sil	%xmm0, %ebx
	pxor	%xmm2, %xmm2
	cvtsi2sdl	-712(%rbp), %xmm2
	movq	%xmm2, %rax
	movq	%rax, %xmm0
	call	sqrt@PLT
	cvttsd2sil	%xmm0, %eax
	imull	%ebx, %eax
	cmpl	%eax, -712(%rbp)
	jne	.L10
	addl	$1, -724(%rbp)
.L10:
	addl	$1, -716(%rbp)
.L7:
	movl	-740(%rbp), %eax
	cmpl	%eax, -716(%rbp)
	jle	.L11
	addl	$1, -720(%rbp)
.L6:
	movl	-740(%rbp), %eax
	cmpl	%eax, -720(%rbp)
	jl	.L12
	movl	-724(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-24(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L14
	call	__stack_chk_fail@PLT
.L14:
	movq	-8(%rbp), %rbx
	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 %d"
.LC1:
	.string	"%d"
.LC2:
	.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
	pushq	%rbx
	subq	$744, %rsp
	.cfi_offset 3, -24
	movq	%fs:40, %rax
	movq	%rax, -24(%rbp)
	xorl	%eax, %eax
	leaq	-736(%rbp), %rdx
	leaq	-740(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$1, -732(%rbp)
	jmp	.L2
.L5:
	movl	$1, -728(%rbp)
	jmp	.L3
.L4:
	leaq	-704(%rbp), %rcx
	movl	-728(%rbp), %eax
	movslq	%eax, %rsi
	movl	-732(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rsi, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -728(%rbp)
.L3:
	movl	-736(%rbp), %eax
	cmpl	%eax, -728(%rbp)
	jle	.L4
	addl	$1, -732(%rbp)
.L2:
	movl	-740(%rbp), %eax
	cmpl	%eax, -732(%rbp)
	jle	.L5
	movl	$0, -724(%rbp)
	movl	$1, -720(%rbp)
	jmp	.L6
.L12:
	movl	-720(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -716(%rbp)
	jmp	.L7
.L11:
	movl	$0, -712(%rbp)
	movl	$1, -708(%rbp)
	jmp	.L8
.L9:
	movl	-708(%rbp), %eax
	movslq	%eax, %rcx
	movl	-720(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rcx, %rax
	movl	-704(%rbp,%rax,4), %ecx
	movl	-708(%rbp), %eax
	movslq	%eax, %rsi
	movl	-716(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rsi, %rax
	movl	-704(%rbp,%rax,4), %eax
	movl	%ecx, %esi
	subl	%eax, %esi
	movl	-708(%rbp), %eax
	movslq	%eax, %rcx
	movl	-720(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rcx, %rax
	movl	-704(%rbp,%rax,4), %ecx
	movl	-708(%rbp), %eax
	movslq	%eax, %rdi
	movl	-716(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rdi, %rax
	movl	-704(%rbp,%rax,4), %edx
	movl	%ecx, %eax
	subl	%edx, %eax
	imull	%esi, %eax
	addl	%eax, -712(%rbp)
	addl	$1, -708(%rbp)
.L8:
	movl	-736(%rbp), %eax
	cmpl	%eax, -708(%rbp)
	jle	.L9
	pxor	%xmm1, %xmm1
	cvtsi2sdl	-712(%rbp), %xmm1
	movq	%xmm1, %rax
	movq	%rax, %xmm0
	call	sqrt@PLT
	cvttsd2sil	%xmm0, %ebx
	pxor	%xmm2, %xmm2
	cvtsi2sdl	-712(%rbp), %xmm2
	movq	%xmm2, %rax
	movq	%rax, %xmm0
	call	sqrt@PLT
	cvttsd2sil	%xmm0, %eax
	imull	%ebx, %eax
	cmpl	%eax, -712(%rbp)
	jne	.L10
	addl	$1, -724(%rbp)
.L10:
	addl	$1, -716(%rbp)
.L7:
	movl	-740(%rbp), %eax
	cmpl	%eax, -716(%rbp)
	jle	.L11
	addl	$1, -720(%rbp)
.L6:
	movl	-740(%rbp), %eax
	cmpl	%eax, -720(%rbp)
	jl	.L12
	movl	-724(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-24(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L14
	call	__stack_chk_fail@PLT
.L14:
	movq	-8(%rbp), %rbx
	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:
