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 <stdlib.h>
#include <math.h>

int vals_compare(const void *a, const void *b)
{
  int *vals_a, *vals_b;
  vals_a = (int *)a;
  vals_b = (int *)b;
  if ( vals_a[0] < vals_b[0] )
    return -1;
  if ( vals_a[0] > vals_b[0] )
    return 1;
  if ( vals_b[0] < vals_b[0] )
    return -1;
  if ( vals_b[0] > vals_b[0] )
    return 1;
  return 0;
}

int main()
{
  char line[256];
  int i, j, n, i2, j2, x, y, x2, y2, *vals, min, min2, mint;

  /* Input */
  fgets(line, 256, stdin);
  sscanf(line, "%d", &n);
  vals = (int *)malloc(sizeof(int) * n * 2);
  for (i = 0; i < n; i ++) {
    fgets(line, 256, stdin);
    sscanf(line, "%d %d", vals+i*2, vals+i*2+1);
  }
  /* sort */
  qsort(vals, n, sizeof(int)*2, vals_compare);
  /* Calculate */
  min = 100000000;
  mint = 10000;
  for (i = 0; i < n-1; i ++) {
    i2 = i * 2;
    x = vals[i2];
    y = vals[i2+1];
    for (j = i + 1; j < n; j ++) {
      j2 = j * 2;
      x2 = vals[j2];
      y2 = vals[j2+1];
      if ( x2-x >= mint ) break;
      x2 -= x;
      y2 -= y;
      min2 = x2 * x2 + y2 * y2;
      if ( min > min2 ) {
	min = min2;
	mint = (int)sqrt(min2);
      }
    }
  }
  printf("%d\n", min);

  /* Finish */
  free(vals);
  return 0;
}

```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	vals_compare
	.type	vals_compare, @function
vals_compare:
.LFB6:
	.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	%rsi, -32(%rbp)
	movq	-24(%rbp), %rax
	movq	%rax, -16(%rbp)
	movq	-32(%rbp), %rax
	movq	%rax, -8(%rbp)
	movq	-16(%rbp), %rax
	movl	(%rax), %edx
	movq	-8(%rbp), %rax
	movl	(%rax), %eax
	cmpl	%eax, %edx
	jge	.L2
	movl	$-1, %eax
	jmp	.L3
.L2:
	movq	-16(%rbp), %rax
	movl	(%rax), %edx
	movq	-8(%rbp), %rax
	movl	(%rax), %eax
	cmpl	%eax, %edx
	jle	.L4
	movl	$1, %eax
	jmp	.L3
.L4:
	movl	$0, %eax
.L3:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	vals_compare, .-vals_compare
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d %d"
.LC2:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$336, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movq	stdin(%rip), %rdx
	leaq	-272(%rbp), %rax
	movl	$256, %esi
	movq	%rax, %rdi
	call	fgets@PLT
	leaq	-328(%rbp), %rdx
	leaq	-272(%rbp), %rax
	leaq	.LC0(%rip), %rcx
	movq	%rcx, %rsi
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_sscanf@PLT
	movl	-328(%rbp), %eax
	cltq
	salq	$3, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, -280(%rbp)
	movl	$0, -324(%rbp)
	jmp	.L6
.L7:
	movq	stdin(%rip), %rdx
	leaq	-272(%rbp), %rax
	movl	$256, %esi
	movq	%rax, %rdi
	call	fgets@PLT
	movl	-324(%rbp), %eax
	addl	%eax, %eax
	cltq
	addq	$1, %rax
	leaq	0(,%rax,4), %rdx
	movq	-280(%rbp), %rax
	leaq	(%rdx,%rax), %rcx
	movl	-324(%rbp), %eax
	addl	%eax, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-280(%rbp), %rax
	addq	%rax, %rdx
	leaq	-272(%rbp), %rax
	leaq	.LC1(%rip), %rsi
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_sscanf@PLT
	addl	$1, -324(%rbp)
.L6:
	movl	-328(%rbp), %eax
	cmpl	%eax, -324(%rbp)
	jl	.L7
	movl	-328(%rbp), %eax
	movslq	%eax, %rsi
	movq	-280(%rbp), %rax
	leaq	vals_compare(%rip), %rdx
	movq	%rdx, %rcx
	movl	$8, %edx
	movq	%rax, %rdi
	call	qsort@PLT
	movl	$100000000, -316(%rbp)
	movl	$10000, -312(%rbp)
	movl	$0, -324(%rbp)
	jmp	.L8
.L14:
	movl	-324(%rbp), %eax
	addl	%eax, %eax
	movl	%eax, -308(%rbp)
	movl	-308(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-280(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, -304(%rbp)
	movl	-308(%rbp), %eax
	cltq
	addq	$1, %rax
	leaq	0(,%rax,4), %rdx
	movq	-280(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, -300(%rbp)
	movl	-324(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -320(%rbp)
	jmp	.L9
.L13:
	movl	-320(%rbp), %eax
	addl	%eax, %eax
	movl	%eax, -296(%rbp)
	movl	-296(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-280(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, -292(%rbp)
	movl	-296(%rbp), %eax
	cltq
	addq	$1, %rax
	leaq	0(,%rax,4), %rdx
	movq	-280(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, -288(%rbp)
	movl	-292(%rbp), %eax
	subl	-304(%rbp), %eax
	cmpl	%eax, -312(%rbp)
	jle	.L17
	movl	-304(%rbp), %eax
	subl	%eax, -292(%rbp)
	movl	-300(%rbp), %eax
	subl	%eax, -288(%rbp)
	movl	-292(%rbp), %eax
	imull	%eax, %eax
	movl	%eax, %edx
	movl	-288(%rbp), %eax
	imull	%eax, %eax
	addl	%edx, %eax
	movl	%eax, -284(%rbp)
	movl	-316(%rbp), %eax
	cmpl	-284(%rbp), %eax
	jle	.L12
	movl	-284(%rbp), %eax
	movl	%eax, -316(%rbp)
	pxor	%xmm1, %xmm1
	cvtsi2sdl	-284(%rbp), %xmm1
	movq	%xmm1, %rax
	movq	%rax, %xmm0
	call	sqrt@PLT
	cvttsd2sil	%xmm0, %eax
	movl	%eax, -312(%rbp)
.L12:
	addl	$1, -320(%rbp)
.L9:
	movl	-328(%rbp), %eax
	cmpl	%eax, -320(%rbp)
	jl	.L13
	jmp	.L11
.L17:
	nop
.L11:
	addl	$1, -324(%rbp)
.L8:
	movl	-328(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -324(%rbp)
	jl	.L14
	movl	-316(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movq	-280(%rbp), %rax
	movq	%rax, %rdi
	call	free@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L16
	call	__stack_chk_fail@PLT
.L16:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.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	vals_compare
	.type	vals_compare, @function
vals_compare:
.LFB39:
	.cfi_startproc
	endbr64
	movl	(%rsi), %eax
	cmpl	%eax, (%rdi)
	movl	$-1, %edx
	setg	%al
	movzbl	%al, %eax
	cmovl	%edx, %eax
	ret
	.cfi_endproc
.LFE39:
	.size	vals_compare, .-vals_compare
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	"%d %d"
.LC3:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB40:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movl	$256, %esi
	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	$312, %rsp
	.cfi_def_cfa_offset 368
	movq	stdin(%rip), %rdx
	movq	%fs:40, %rax
	movq	%rax, 296(%rsp)
	xorl	%eax, %eax
	leaq	32(%rsp), %r14
	movq	%r14, %rdi
	call	fgets@PLT
	leaq	28(%rsp), %rdx
	movq	%r14, %rdi
	xorl	%eax, %eax
	leaq	.LC0(%rip), %rsi
	call	__isoc99_sscanf@PLT
	movslq	28(%rsp), %rbp
	leaq	0(,%rbp,8), %rdi
	call	malloc@PLT
	movq	%rax, %r12
	testl	%ebp, %ebp
	jle	.L6
	movq	%rax, %rbx
	xorl	%ebp, %ebp
	leaq	.LC1(%rip), %r15
	.p2align 4,,10
	.p2align 3
.L7:
	movq	stdin(%rip), %rdx
	movl	$256, %esi
	movq	%r14, %rdi
	addl	$1, %ebp
	call	fgets@PLT
	leaq	4(%rbx), %rcx
	movq	%rbx, %rdx
	movq	%r15, %rsi
	movq	%r14, %rdi
	xorl	%eax, %eax
	addq	$8, %rbx
	call	__isoc99_sscanf@PLT
	movl	28(%rsp), %r13d
	cmpl	%ebp, %r13d
	jg	.L7
	movslq	%r13d, %rbp
.L6:
	movq	%rbp, %rsi
	leaq	vals_compare(%rip), %rcx
	movl	$8, %edx
	movq	%r12, %rdi
	call	qsort@PLT
	movl	28(%rsp), %esi
	cmpl	$1, %esi
	jle	.L17
	leal	-2(%rsi), %edi
	movl	$1, %r15d
	movl	$10000, %ecx
	movl	$100000000, %r8d
	addq	$2, %rdi
	pxor	%xmm1, %xmm1
	.p2align 4,,10
	.p2align 3
.L15:
	movl	-8(%r12,%r15,8), %ebp
	movl	-4(%r12,%r15,8), %r13d
	cmpl	%r15d, %esi
	jle	.L9
	leal	(%r15,%r15), %eax
	cltq
	leaq	(%r12,%rax,4), %rbx
	leal	-1(%rsi), %eax
	subl	%r15d, %eax
	leaq	-1(%r15,%rax), %rax
	leaq	16(%r12,%rax,8), %r14
	jmp	.L14
	.p2align 4,,10
	.p2align 3
.L10:
	addq	$8, %rbx
	cmpq	%rbx, %r14
	je	.L9
.L14:
	movl	(%rbx), %eax
	movl	4(%rbx), %edx
	subl	%ebp, %eax
	cmpl	%ecx, %eax
	jge	.L9
	subl	%r13d, %edx
	imull	%eax, %eax
	imull	%edx, %edx
	addl	%edx, %eax
	cmpl	%r8d, %eax
	jge	.L10
	pxor	%xmm0, %xmm0
	cvtsi2sdl	%eax, %xmm0
	ucomisd	%xmm0, %xmm1
	ja	.L22
	sqrtsd	%xmm0, %xmm0
.L13:
	addq	$8, %rbx
	cvttsd2sil	%xmm0, %ecx
	movl	%eax, %r8d
	cmpq	%rbx, %r14
	jne	.L14
	.p2align 4,,10
	.p2align 3
.L9:
	addq	$1, %r15
	cmpq	%r15, %rdi
	jne	.L15
.L8:
	movl	$1, %edi
	xorl	%eax, %eax
	movl	%r8d, %edx
	leaq	.LC3(%rip), %rsi
	call	__printf_chk@PLT
	movq	%r12, %rdi
	call	free@PLT
	movq	296(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L24
	addq	$312, %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
.L17:
	.cfi_restore_state
	movl	$100000000, %r8d
	jmp	.L8
.L22:
	movl	%esi, 12(%rsp)
	movl	%eax, 8(%rsp)
	movq	%rdi, (%rsp)
	call	sqrt@PLT
	movl	12(%rsp), %esi
	movl	8(%rsp), %eax
	pxor	%xmm1, %xmm1
	movq	(%rsp), %rdi
	jmp	.L13
.L24:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE40:
	.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
	.p2align 4
	.globl	vals_compare
	.type	vals_compare, @function
vals_compare:
.LFB39:
	.cfi_startproc
	endbr64
	movl	(%rsi), %eax
	cmpl	%eax, (%rdi)
	movl	$-1, %edx
	setg	%al
	movzbl	%al, %eax
	cmovl	%edx, %eax
	ret
	.cfi_endproc
.LFE39:
	.size	vals_compare, .-vals_compare
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	"%d %d"
.LC3:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB40:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movl	$256, %esi
	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	$312, %rsp
	.cfi_def_cfa_offset 368
	movq	stdin(%rip), %rdx
	movq	%fs:40, %rax
	movq	%rax, 296(%rsp)
	xorl	%eax, %eax
	leaq	32(%rsp), %r14
	movq	%r14, %rdi
	call	fgets@PLT
	leaq	28(%rsp), %rdx
	movq	%r14, %rdi
	xorl	%eax, %eax
	leaq	.LC0(%rip), %rsi
	call	__isoc99_sscanf@PLT
	movslq	28(%rsp), %rbp
	leaq	0(,%rbp,8), %rdi
	call	malloc@PLT
	movq	%rax, %r12
	testl	%ebp, %ebp
	jle	.L6
	movq	%rax, %rbx
	xorl	%ebp, %ebp
	leaq	.LC1(%rip), %r15
	.p2align 4,,10
	.p2align 3
.L7:
	movq	stdin(%rip), %rdx
	movl	$256, %esi
	movq	%r14, %rdi
	addl	$1, %ebp
	call	fgets@PLT
	leaq	4(%rbx), %rcx
	movq	%rbx, %rdx
	movq	%r15, %rsi
	movq	%r14, %rdi
	xorl	%eax, %eax
	addq	$8, %rbx
	call	__isoc99_sscanf@PLT
	movl	28(%rsp), %r13d
	cmpl	%ebp, %r13d
	jg	.L7
	movslq	%r13d, %rbp
.L6:
	movq	%rbp, %rsi
	leaq	vals_compare(%rip), %rcx
	movl	$8, %edx
	movq	%r12, %rdi
	call	qsort@PLT
	movl	28(%rsp), %esi
	cmpl	$1, %esi
	jle	.L17
	leal	-2(%rsi), %edi
	movl	$1, %r15d
	movl	$10000, %ecx
	movl	$100000000, %r8d
	addq	$2, %rdi
	pxor	%xmm1, %xmm1
	.p2align 4,,10
	.p2align 3
.L15:
	movl	-8(%r12,%r15,8), %ebp
	movl	-4(%r12,%r15,8), %r13d
	cmpl	%r15d, %esi
	jle	.L9
	leal	(%r15,%r15), %eax
	cltq
	leaq	(%r12,%rax,4), %rbx
	leal	-1(%rsi), %eax
	subl	%r15d, %eax
	leaq	-1(%r15,%rax), %rax
	leaq	16(%r12,%rax,8), %r14
	jmp	.L14
	.p2align 4,,10
	.p2align 3
.L10:
	addq	$8, %rbx
	cmpq	%rbx, %r14
	je	.L9
.L14:
	movl	(%rbx), %eax
	movl	4(%rbx), %edx
	subl	%ebp, %eax
	cmpl	%ecx, %eax
	jge	.L9
	subl	%r13d, %edx
	imull	%eax, %eax
	imull	%edx, %edx
	addl	%edx, %eax
	cmpl	%r8d, %eax
	jge	.L10
	pxor	%xmm0, %xmm0
	cvtsi2sdl	%eax, %xmm0
	ucomisd	%xmm0, %xmm1
	ja	.L22
	sqrtsd	%xmm0, %xmm0
.L13:
	addq	$8, %rbx
	cvttsd2sil	%xmm0, %ecx
	movl	%eax, %r8d
	cmpq	%rbx, %r14
	jne	.L14
	.p2align 4,,10
	.p2align 3
.L9:
	addq	$1, %r15
	cmpq	%r15, %rdi
	jne	.L15
.L8:
	movl	$1, %edi
	xorl	%eax, %eax
	movl	%r8d, %edx
	leaq	.LC3(%rip), %rsi
	call	__printf_chk@PLT
	movq	%r12, %rdi
	call	free@PLT
	movq	296(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L24
	addq	$312, %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
.L17:
	.cfi_restore_state
	movl	$100000000, %r8d
	jmp	.L8
.L22:
	movl	%esi, 12(%rsp)
	movl	%eax, 8(%rsp)
	movq	%rdi, (%rsp)
	call	sqrt@PLT
	movl	12(%rsp), %esi
	movl	8(%rsp), %eax
	pxor	%xmm1, %xmm1
	movq	(%rsp), %rdi
	jmp	.L13
.L24:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE40:
	.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 <stdlib.h>
#include <math.h>

int vals_compare(const void *a, const void *b)
{
  int *vals_a, *vals_b;
  vals_a = (int *)a;
  vals_b = (int *)b;
  if ( vals_a[0] < vals_b[0] )
    return -1;
  if ( vals_a[0] > vals_b[0] )
    return 1;
  if ( vals_b[0] < vals_b[0] )
    return -1;
  if ( vals_b[0] > vals_b[0] )
    return 1;
  return 0;
}

int main()
{
  char line[256];
  int i, j, n, i2, j2, x, y, x2, y2, *vals, min, min2, mint;

  /* Input */
  fgets(line, 256, stdin);
  sscanf(line, "%d", &n);
  vals = (int *)malloc(sizeof(int) * n * 2);
  for (i = 0; i < n; i ++) {
    fgets(line, 256, stdin);
    sscanf(line, "%d %d", vals+i*2, vals+i*2+1);
  }
  /* sort */
  qsort(vals, n, sizeof(int)*2, vals_compare);
  /* Calculate */
  min = 100000000;
  mint = 10000;
  for (i = 0; i < n-1; i ++) {
    i2 = i * 2;
    x = vals[i2];
    y = vals[i2+1];
    for (j = i + 1; j < n; j ++) {
      j2 = j * 2;
      x2 = vals[j2];
      y2 = vals[j2+1];
      if ( x2-x >= mint ) break;
      x2 -= x;
      y2 -= y;
      min2 = x2 * x2 + y2 * y2;
      if ( min > min2 ) {
	min = min2;
	mint = (int)sqrt(min2);
      }
    }
  }
  printf("%d\n", min);

  /* Finish */
  free(vals);
  return 0;
}


2
0 0
1 1

2

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 <stdlib.h>
#include <math.h>

int vals_compare(const void *a, const void *b)
{
  int *vals_a, *vals_b;
  vals_a = (int *)a;
  vals_b = (int *)b;
  if ( vals_a[0] < vals_b[0] )
    return -1;
  if ( vals_a[0] > vals_b[0] )
    return 1;
  if ( vals_b[0] < vals_b[0] )
    return -1;
  if ( vals_b[0] > vals_b[0] )
    return 1;
  return 0;
}

int main()
{
  char line[256];
  int i, j, n, i2, j2, x, y, x2, y2, *vals, min, min2, mint;

  /* Input */
  fgets(line, 256, stdin);
  sscanf(line, "%d", &n);
  vals = (int *)malloc(sizeof(int) * n * 2);
  for (i = 0; i < n; i ++) {
    fgets(line, 256, stdin);
    sscanf(line, "%d %d", vals+i*2, vals+i*2+1);
  }
  /* sort */
  qsort(vals, n, sizeof(int)*2, vals_compare);
  /* Calculate */
  min = 100000000;
  mint = 10000;
  for (i = 0; i < n-1; i ++) {
    i2 = i * 2;
    x = vals[i2];
    y = vals[i2+1];
    for (j = i + 1; j < n; j ++) {
      j2 = j * 2;
      x2 = vals[j2];
      y2 = vals[j2+1];
      if ( x2-x >= mint ) break;
      x2 -= x;
      y2 -= y;
      min2 = x2 * x2 + y2 * y2;
      if ( min > min2 ) {
	min = min2;
	mint = (int)sqrt(min2);
      }
    }
  }
  printf("%d\n", min);

  /* Finish */
  free(vals);
  return 0;
}

```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	vals_compare
	.type	vals_compare, @function
vals_compare:
.LFB6:
	.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	%rsi, -32(%rbp)
	movq	-24(%rbp), %rax
	movq	%rax, -16(%rbp)
	movq	-32(%rbp), %rax
	movq	%rax, -8(%rbp)
	movq	-16(%rbp), %rax
	movl	(%rax), %edx
	movq	-8(%rbp), %rax
	movl	(%rax), %eax
	cmpl	%eax, %edx
	jge	.L2
	movl	$-1, %eax
	jmp	.L3
.L2:
	movq	-16(%rbp), %rax
	movl	(%rax), %edx
	movq	-8(%rbp), %rax
	movl	(%rax), %eax
	cmpl	%eax, %edx
	jle	.L4
	movl	$1, %eax
	jmp	.L3
.L4:
	movl	$0, %eax
.L3:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	vals_compare, .-vals_compare
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d %d"
.LC2:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$336, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movq	stdin(%rip), %rdx
	leaq	-272(%rbp), %rax
	movl	$256, %esi
	movq	%rax, %rdi
	call	fgets@PLT
	leaq	-328(%rbp), %rdx
	leaq	-272(%rbp), %rax
	leaq	.LC0(%rip), %rcx
	movq	%rcx, %rsi
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_sscanf@PLT
	movl	-328(%rbp), %eax
	cltq
	salq	$3, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, -280(%rbp)
	movl	$0, -324(%rbp)
	jmp	.L6
.L7:
	movq	stdin(%rip), %rdx
	leaq	-272(%rbp), %rax
	movl	$256, %esi
	movq	%rax, %rdi
	call	fgets@PLT
	movl	-324(%rbp), %eax
	addl	%eax, %eax
	cltq
	addq	$1, %rax
	leaq	0(,%rax,4), %rdx
	movq	-280(%rbp), %rax
	leaq	(%rdx,%rax), %rcx
	movl	-324(%rbp), %eax
	addl	%eax, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-280(%rbp), %rax
	addq	%rax, %rdx
	leaq	-272(%rbp), %rax
	leaq	.LC1(%rip), %rsi
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_sscanf@PLT
	addl	$1, -324(%rbp)
.L6:
	movl	-328(%rbp), %eax
	cmpl	%eax, -324(%rbp)
	jl	.L7
	movl	-328(%rbp), %eax
	movslq	%eax, %rsi
	movq	-280(%rbp), %rax
	leaq	vals_compare(%rip), %rdx
	movq	%rdx, %rcx
	movl	$8, %edx
	movq	%rax, %rdi
	call	qsort@PLT
	movl	$100000000, -316(%rbp)
	movl	$10000, -312(%rbp)
	movl	$0, -324(%rbp)
	jmp	.L8
.L14:
	movl	-324(%rbp), %eax
	addl	%eax, %eax
	movl	%eax, -308(%rbp)
	movl	-308(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-280(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, -304(%rbp)
	movl	-308(%rbp), %eax
	cltq
	addq	$1, %rax
	leaq	0(,%rax,4), %rdx
	movq	-280(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, -300(%rbp)
	movl	-324(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -320(%rbp)
	jmp	.L9
.L13:
	movl	-320(%rbp), %eax
	addl	%eax, %eax
	movl	%eax, -296(%rbp)
	movl	-296(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-280(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, -292(%rbp)
	movl	-296(%rbp), %eax
	cltq
	addq	$1, %rax
	leaq	0(,%rax,4), %rdx
	movq	-280(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, -288(%rbp)
	movl	-292(%rbp), %eax
	subl	-304(%rbp), %eax
	cmpl	%eax, -312(%rbp)
	jle	.L17
	movl	-304(%rbp), %eax
	subl	%eax, -292(%rbp)
	movl	-300(%rbp), %eax
	subl	%eax, -288(%rbp)
	movl	-292(%rbp), %eax
	imull	%eax, %eax
	movl	%eax, %edx
	movl	-288(%rbp), %eax
	imull	%eax, %eax
	addl	%edx, %eax
	movl	%eax, -284(%rbp)
	movl	-316(%rbp), %eax
	cmpl	-284(%rbp), %eax
	jle	.L12
	movl	-284(%rbp), %eax
	movl	%eax, -316(%rbp)
	pxor	%xmm1, %xmm1
	cvtsi2sdl	-284(%rbp), %xmm1
	movq	%xmm1, %rax
	movq	%rax, %xmm0
	call	sqrt@PLT
	cvttsd2sil	%xmm0, %eax
	movl	%eax, -312(%rbp)
.L12:
	addl	$1, -320(%rbp)
.L9:
	movl	-328(%rbp), %eax
	cmpl	%eax, -320(%rbp)
	jl	.L13
	jmp	.L11
.L17:
	nop
.L11:
	addl	$1, -324(%rbp)
.L8:
	movl	-328(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -324(%rbp)
	jl	.L14
	movl	-316(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movq	-280(%rbp), %rax
	movq	%rax, %rdi
	call	free@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L16
	call	__stack_chk_fail@PLT
.L16:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.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	vals_compare
	.type	vals_compare, @function
vals_compare:
.LFB6:
	.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	%rsi, -32(%rbp)
	movq	-24(%rbp), %rax
	movq	%rax, -16(%rbp)
	movq	-32(%rbp), %rax
	movq	%rax, -8(%rbp)
	movq	-16(%rbp), %rax
	movl	(%rax), %edx
	movq	-8(%rbp), %rax
	movl	(%rax), %eax
	cmpl	%eax, %edx
	jge	.L2
	movl	$-1, %eax
	jmp	.L3
.L2:
	movq	-16(%rbp), %rax
	movl	(%rax), %edx
	movq	-8(%rbp), %rax
	movl	(%rax), %eax
	cmpl	%eax, %edx
	jle	.L4
	movl	$1, %eax
	jmp	.L3
.L4:
	movl	$0, %eax
.L3:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	vals_compare, .-vals_compare
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d %d"
.LC2:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$336, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movq	stdin(%rip), %rdx
	leaq	-272(%rbp), %rax
	movl	$256, %esi
	movq	%rax, %rdi
	call	fgets@PLT
	leaq	-328(%rbp), %rdx
	leaq	-272(%rbp), %rax
	leaq	.LC0(%rip), %rcx
	movq	%rcx, %rsi
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_sscanf@PLT
	movl	-328(%rbp), %eax
	cltq
	salq	$3, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, -280(%rbp)
	movl	$0, -324(%rbp)
	jmp	.L6
.L7:
	movq	stdin(%rip), %rdx
	leaq	-272(%rbp), %rax
	movl	$256, %esi
	movq	%rax, %rdi
	call	fgets@PLT
	movl	-324(%rbp), %eax
	addl	%eax, %eax
	cltq
	addq	$1, %rax
	leaq	0(,%rax,4), %rdx
	movq	-280(%rbp), %rax
	leaq	(%rdx,%rax), %rcx
	movl	-324(%rbp), %eax
	addl	%eax, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-280(%rbp), %rax
	addq	%rax, %rdx
	leaq	-272(%rbp), %rax
	leaq	.LC1(%rip), %rsi
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_sscanf@PLT
	addl	$1, -324(%rbp)
.L6:
	movl	-328(%rbp), %eax
	cmpl	%eax, -324(%rbp)
	jl	.L7
	movl	-328(%rbp), %eax
	movslq	%eax, %rsi
	movq	-280(%rbp), %rax
	leaq	vals_compare(%rip), %rdx
	movq	%rdx, %rcx
	movl	$8, %edx
	movq	%rax, %rdi
	call	qsort@PLT
	movl	$100000000, -316(%rbp)
	movl	$10000, -312(%rbp)
	movl	$0, -324(%rbp)
	jmp	.L8
.L14:
	movl	-324(%rbp), %eax
	addl	%eax, %eax
	movl	%eax, -308(%rbp)
	movl	-308(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-280(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, -304(%rbp)
	movl	-308(%rbp), %eax
	cltq
	addq	$1, %rax
	leaq	0(,%rax,4), %rdx
	movq	-280(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, -300(%rbp)
	movl	-324(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -320(%rbp)
	jmp	.L9
.L13:
	movl	-320(%rbp), %eax
	addl	%eax, %eax
	movl	%eax, -296(%rbp)
	movl	-296(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-280(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, -292(%rbp)
	movl	-296(%rbp), %eax
	cltq
	addq	$1, %rax
	leaq	0(,%rax,4), %rdx
	movq	-280(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, -288(%rbp)
	movl	-292(%rbp), %eax
	subl	-304(%rbp), %eax
	cmpl	%eax, -312(%rbp)
	jle	.L17
	movl	-304(%rbp), %eax
	subl	%eax, -292(%rbp)
	movl	-300(%rbp), %eax
	subl	%eax, -288(%rbp)
	movl	-292(%rbp), %eax
	imull	%eax, %eax
	movl	%eax, %edx
	movl	-288(%rbp), %eax
	imull	%eax, %eax
	addl	%edx, %eax
	movl	%eax, -284(%rbp)
	movl	-316(%rbp), %eax
	cmpl	-284(%rbp), %eax
	jle	.L12
	movl	-284(%rbp), %eax
	movl	%eax, -316(%rbp)
	pxor	%xmm1, %xmm1
	cvtsi2sdl	-284(%rbp), %xmm1
	movq	%xmm1, %rax
	movq	%rax, %xmm0
	call	sqrt@PLT
	cvttsd2sil	%xmm0, %eax
	movl	%eax, -312(%rbp)
.L12:
	addl	$1, -320(%rbp)
.L9:
	movl	-328(%rbp), %eax
	cmpl	%eax, -320(%rbp)
	jl	.L13
	jmp	.L11
.L17:
	nop
.L11:
	addl	$1, -324(%rbp)
.L8:
	movl	-328(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -324(%rbp)
	jl	.L14
	movl	-316(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movq	-280(%rbp), %rax
	movq	%rax, %rdi
	call	free@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L16
	call	__stack_chk_fail@PLT
.L16:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.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:
