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>

/* 値を入れ替える関数 */
void swap (int *x, int *y) {
  int temp;    // 値を一時保存する変数

  temp = *x;
  *x = *y;
  *y = temp;
}

/***
* pivotを決め、
* 全データをpivotを境目に振り分け、
* pivotの添え字を返す
***/
int partition (int h[], int left, int right) {
  int i, j, pivot;
  i = left;
  j = right + 1;
  pivot = left;   // 先頭要素をpivotとする

  do {
    do { i++; } while (h[i] < h[pivot]);
    do { j--; } while (h[pivot] < h[j]);
    // pivotより小さいものを左へ、大きいものを右へ
    if (i < j) { swap(&h[i], &h[j]); }
  } while (i < j);

  swap(&h[pivot], &h[j]);   //pivotを更新

  return j;
}

/* クイックソート */
void quick_sort (int h[], int left, int right) {
  int pivot;

  if (left < right) {
    pivot = partition(h, left, right);
    quick_sort(h, left, pivot-1);   // pivotを境に再帰的にクイックソート
    quick_sort(h, pivot+1, right);
  }
}

int main(void){
  int N,K,i;
  scanf("%d %d",&N,&K);
  int h[N];
  for(i=0;i<N;i++){
    scanf("%d",&h[i]);
  }
  
  quick_sort(h, 0, N-1);
  
  int min=h[K-1]-h[0];
  for(i=K;i<N;i++){
    if(min>h[i]-h[i-K+1]){
      min=h[i]-h[i-K+1];
    }
  }
  printf("%d",min);
  return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	swap
	.type	swap, @function
swap:
.LFB0:
	.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
	movl	(%rax), %eax
	movl	%eax, -4(%rbp)
	movq	-32(%rbp), %rax
	movl	(%rax), %edx
	movq	-24(%rbp), %rax
	movl	%edx, (%rax)
	movq	-32(%rbp), %rax
	movl	-4(%rbp), %edx
	movl	%edx, (%rax)
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	swap, .-swap
	.globl	partition
	.type	partition, @function
partition:
.LFB1:
	.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, -24(%rbp)
	movl	%esi, -28(%rbp)
	movl	%edx, -32(%rbp)
	movl	-28(%rbp), %eax
	movl	%eax, -12(%rbp)
	movl	-32(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -8(%rbp)
	movl	-28(%rbp), %eax
	movl	%eax, -4(%rbp)
.L3:
	addl	$1, -12(%rbp)
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	movq	-24(%rbp), %rax
	addq	%rcx, %rax
	movl	(%rax), %eax
	cmpl	%eax, %edx
	jl	.L3
.L4:
	subl	$1, -8(%rbp)
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	movq	-24(%rbp), %rax
	addq	%rcx, %rax
	movl	(%rax), %eax
	cmpl	%eax, %edx
	jl	.L4
	movl	-12(%rbp), %eax
	cmpl	-8(%rbp), %eax
	jge	.L5
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rax, %rdx
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	movq	-24(%rbp), %rax
	addq	%rcx, %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	swap
.L5:
	movl	-12(%rbp), %eax
	cmpl	-8(%rbp), %eax
	jl	.L3
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rax, %rdx
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	movq	-24(%rbp), %rax
	addq	%rcx, %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	swap
	movl	-8(%rbp), %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	partition, .-partition
	.globl	quick_sort
	.type	quick_sort, @function
quick_sort:
.LFB2:
	.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, -24(%rbp)
	movl	%esi, -28(%rbp)
	movl	%edx, -32(%rbp)
	movl	-28(%rbp), %eax
	cmpl	-32(%rbp), %eax
	jge	.L9
	movl	-32(%rbp), %edx
	movl	-28(%rbp), %ecx
	movq	-24(%rbp), %rax
	movl	%ecx, %esi
	movq	%rax, %rdi
	call	partition
	movl	%eax, -4(%rbp)
	movl	-4(%rbp), %eax
	leal	-1(%rax), %edx
	movl	-28(%rbp), %ecx
	movq	-24(%rbp), %rax
	movl	%ecx, %esi
	movq	%rax, %rdi
	call	quick_sort
	movl	-4(%rbp), %eax
	leal	1(%rax), %ecx
	movl	-32(%rbp), %edx
	movq	-24(%rbp), %rax
	movl	%ecx, %esi
	movq	%rax, %rdi
	call	quick_sort
.L9:
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2:
	.size	quick_sort, .-quick_sort
	.section	.rodata
.LC0:
	.string	"%d %d"
.LC1:
	.string	"%d"
	.text
	.globl	main
	.type	main, @function
main:
.LFB3:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%r15
	pushq	%r14
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	subq	$56, %rsp
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	.cfi_offset 12, -48
	.cfi_offset 3, -56
	movq	%fs:40, %rax
	movq	%rax, -56(%rbp)
	xorl	%eax, %eax
	movq	%rsp, %rax
	movq	%rax, %rbx
	leaq	-84(%rbp), %rdx
	leaq	-88(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-88(%rbp), %eax
	movslq	%eax, %rdx
	subq	$1, %rdx
	movq	%rdx, -72(%rbp)
	movslq	%eax, %rdx
	movq	%rdx, %r14
	movl	$0, %r15d
	movslq	%eax, %rdx
	movq	%rdx, %r12
	movl	$0, %r13d
	cltq
	leaq	0(,%rax,4), %rdx
	movl	$16, %eax
	subq	$1, %rax
	addq	%rdx, %rax
	movl	$16, %esi
	movl	$0, %edx
	divq	%rsi
	imulq	$16, %rax, %rax
	movq	%rax, %rcx
	andq	$-4096, %rcx
	movq	%rsp, %rdx
	subq	%rcx, %rdx
.L11:
	cmpq	%rdx, %rsp
	je	.L12
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L11
.L12:
	movq	%rax, %rdx
	andl	$4095, %edx
	subq	%rdx, %rsp
	movq	%rax, %rdx
	andl	$4095, %edx
	testq	%rdx, %rdx
	je	.L13
	andl	$4095, %eax
	subq	$8, %rax
	addq	%rsp, %rax
	orq	$0, (%rax)
.L13:
	movq	%rsp, %rax
	addq	$3, %rax
	shrq	$2, %rax
	salq	$2, %rax
	movq	%rax, -64(%rbp)
	movl	$0, -80(%rbp)
	jmp	.L14
.L15:
	movl	-80(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-64(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -80(%rbp)
.L14:
	movl	-88(%rbp), %eax
	cmpl	%eax, -80(%rbp)
	jl	.L15
	movl	-88(%rbp), %eax
	leal	-1(%rax), %edx
	movq	-64(%rbp), %rax
	movl	$0, %esi
	movq	%rax, %rdi
	call	quick_sort
	movl	-84(%rbp), %eax
	leal	-1(%rax), %edx
	movq	-64(%rbp), %rax
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %edx
	movq	-64(%rbp), %rax
	movl	(%rax), %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	movl	%eax, -76(%rbp)
	movl	-84(%rbp), %eax
	movl	%eax, -80(%rbp)
	jmp	.L16
.L18:
	movq	-64(%rbp), %rax
	movl	-80(%rbp), %edx
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %ecx
	movl	-84(%rbp), %edx
	movl	-80(%rbp), %eax
	subl	%edx, %eax
	leal	1(%rax), %edx
	movq	-64(%rbp), %rax
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %edx
	movl	%ecx, %eax
	subl	%edx, %eax
	cmpl	%eax, -76(%rbp)
	jle	.L17
	movq	-64(%rbp), %rax
	movl	-80(%rbp), %edx
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %ecx
	movl	-84(%rbp), %edx
	movl	-80(%rbp), %eax
	subl	%edx, %eax
	leal	1(%rax), %edx
	movq	-64(%rbp), %rax
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %edx
	movl	%ecx, %eax
	subl	%edx, %eax
	movl	%eax, -76(%rbp)
.L17:
	addl	$1, -80(%rbp)
.L16:
	movl	-88(%rbp), %eax
	cmpl	%eax, -80(%rbp)
	jl	.L18
	movl	-76(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	%rbx, %rsp
	movq	-56(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L20
	call	__stack_chk_fail@PLT
.L20:
	leaq	-40(%rbp), %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE3:
	.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	swap
	.type	swap, @function
swap:
.LFB23:
	.cfi_startproc
	endbr64
	movl	(%rdi), %eax
	movl	(%rsi), %edx
	movl	%edx, (%rdi)
	movl	%eax, (%rsi)
	ret
	.cfi_endproc
.LFE23:
	.size	swap, .-swap
	.p2align 4
	.globl	partition
	.type	partition, @function
partition:
.LFB24:
	.cfi_startproc
	endbr64
	movslq	%esi, %rax
	addl	$1, %esi
	leal	1(%rdx), %r8d
	movq	%rdi, %r10
	leaq	(%rdi,%rax,4), %r11
	movslq	%esi, %rdi
	movl	(%r11), %ecx
	.p2align 4,,10
	.p2align 3
.L4:
	movl	(%r10,%rdi,4), %r9d
	cmpl	%ecx, %r9d
	jl	.L5
	movslq	%r8d, %rax
	leaq	-4(%r10,%rax,4), %rax
	.p2align 4,,10
	.p2align 3
.L6:
	movq	%rax, %rsi
	movl	(%rax), %edx
	subq	$4, %rax
	subl	$1, %r8d
	cmpl	%edx, %ecx
	jl	.L6
	cmpl	%edi, %r8d
	jg	.L9
	movl	%edx, (%r11)
	movl	%r8d, %eax
	movl	%ecx, (%rsi)
	ret
	.p2align 4,,10
	.p2align 3
.L9:
	movl	%edx, (%r10,%rdi,4)
	movl	%r9d, (%rsi)
	movl	(%r11), %ecx
.L5:
	addq	$1, %rdi
	jmp	.L4
	.cfi_endproc
.LFE24:
	.size	partition, .-partition
	.p2align 4
	.globl	quick_sort
	.type	quick_sort, @function
quick_sort:
.LFB25:
	.cfi_startproc
	endbr64
	cmpl	%esi, %edx
	jle	.L20
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	movl	%esi, %r10d
	movq	%rdi, %r13
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	leal	1(%rdx), %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	movl	%edx, %ebx
	subq	$8, %rsp
	.cfi_def_cfa_offset 48
.L16:
	movslq	%r10d, %rax
	leal	1(%r10), %r8d
	movl	%ebp, %edx
	leaq	0(%r13,%rax,4), %r11
	movslq	%r8d, %r8
	movl	(%r11), %esi
	.p2align 4,,10
	.p2align 3
.L12:
	movl	0(%r13,%r8,4), %r9d
	cmpl	%esi, %r9d
	jl	.L13
	movslq	%edx, %rax
	leaq	-4(%r13,%rax,4), %rax
	.p2align 4,,10
	.p2align 3
.L14:
	movq	%rax, %rdi
	movl	(%rax), %ecx
	movl	%edx, %r12d
	subq	$4, %rax
	subl	$1, %edx
	cmpl	%ecx, %esi
	jl	.L14
	cmpl	%r8d, %edx
	jg	.L23
	movl	%ecx, (%r11)
	leal	-2(%r12), %edx
	movl	%esi, (%rdi)
	movl	%r10d, %esi
	movq	%r13, %rdi
	call	quick_sort
	cmpl	%r12d, %ebx
	jle	.L24
	movl	%r12d, %r10d
	jmp	.L16
	.p2align 4,,10
	.p2align 3
.L23:
	movl	%ecx, 0(%r13,%r8,4)
	movl	%r9d, (%rdi)
	movl	(%r11), %esi
.L13:
	addq	$1, %r8
	jmp	.L12
.L24:
	addq	$8, %rsp
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
.L20:
	.cfi_restore 3
	.cfi_restore 6
	.cfi_restore 12
	.cfi_restore 13
	ret
	.cfi_endproc
.LFE25:
	.size	quick_sort, .-quick_sort
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d %d"
.LC1:
	.string	"%d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB26:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	leaq	.LC0(%rip), %rdi
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%r15
	pushq	%r14
	leaq	-60(%rbp), %rdx
	leaq	-64(%rbp), %rsi
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	subq	$24, %rsp
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	.cfi_offset 12, -48
	.cfi_offset 3, -56
	movq	%fs:40, %rax
	movq	%rax, -56(%rbp)
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movslq	-64(%rbp), %rax
	movq	%rsp, %rsi
	movq	%rax, %rdx
	leaq	15(,%rax,4), %rax
	movq	%rax, %rcx
	andq	$-4096, %rax
	subq	%rax, %rsi
	andq	$-16, %rcx
	cmpq	%rsi, %rsp
	je	.L27
.L45:
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	cmpq	%rsi, %rsp
	jne	.L45
.L27:
	andl	$4095, %ecx
	subq	%rcx, %rsp
	testq	%rcx, %rcx
	jne	.L46
.L28:
	leaq	3(%rsp), %r13
	leaq	.LC1(%rip), %r14
	movq	%r13, %r15
	andq	$-4, %r13
	shrq	$2, %r15
	testl	%edx, %edx
	jle	.L29
	movq	%r13, %r12
	xorl	%ebx, %ebx
	.p2align 4,,10
	.p2align 3
.L30:
	movq	%r12, %rsi
	movq	%r14, %rdi
	xorl	%eax, %eax
	addl	$1, %ebx
	call	__isoc99_scanf@PLT
	movl	-64(%rbp), %edx
	addq	$4, %r12
	cmpl	%ebx, %edx
	jg	.L30
.L29:
	subl	$1, %edx
	movq	%r13, %rdi
	xorl	%esi, %esi
	call	quick_sort
	movl	-60(%rbp), %ecx
	movl	-64(%rbp), %edi
	leal	-1(%rcx), %eax
	cltq
	movl	0(%r13,%rax,4), %edx
	subl	0(,%r15,4), %edx
	cmpl	%edi, %ecx
	jge	.L31
	movl	%edi, %r8d
	subl	%ecx, %r8d
	leal	-1(%r8), %eax
	cmpl	$2, %eax
	jbe	.L37
	movd	%edx, %xmm4
	movl	%r8d, %edx
	movslq	%ecx, %rax
	shrl	$2, %edx
	leaq	0(%r13,%rax,4), %rsi
	pshufd	$0, %xmm4, %xmm0
	xorl	%eax, %eax
	salq	$4, %rdx
	.p2align 4,,10
	.p2align 3
.L33:
	movdqu	(%rsi,%rax), %xmm2
	movdqu	4(%r13,%rax), %xmm3
	addq	$16, %rax
	psubd	%xmm3, %xmm2
	movdqa	%xmm2, %xmm1
	pcmpgtd	%xmm0, %xmm1
	pand	%xmm1, %xmm0
	pandn	%xmm2, %xmm1
	por	%xmm1, %xmm0
	cmpq	%rdx, %rax
	jne	.L33
	movdqa	%xmm0, %xmm2
	movl	%r8d, %esi
	psrldq	$8, %xmm2
	andl	$-4, %esi
	movdqa	%xmm2, %xmm1
	leal	(%rsi,%rcx), %eax
	pcmpgtd	%xmm0, %xmm1
	pand	%xmm1, %xmm0
	pandn	%xmm2, %xmm1
	por	%xmm1, %xmm0
	movdqa	%xmm0, %xmm2
	psrldq	$4, %xmm2
	movdqa	%xmm2, %xmm1
	pcmpgtd	%xmm0, %xmm1
	pand	%xmm1, %xmm0
	pandn	%xmm2, %xmm1
	por	%xmm0, %xmm1
	movd	%xmm1, %edx
	cmpl	%esi, %r8d
	je	.L31
.L32:
	movslq	%eax, %rsi
	leaq	0(%r13,%rsi,4), %r8
	movl	%eax, %esi
	subl	%ecx, %esi
	movl	(%r8), %r9d
	addl	$1, %esi
	movslq	%esi, %rsi
	subl	0(%r13,%rsi,4), %r9d
	leal	1(%rax), %esi
	cmpl	%r9d, %edx
	cmovg	%r9d, %edx
	cmpl	%edi, %esi
	jge	.L31
	subl	%ecx, %esi
	movl	4(%r8), %r9d
	addl	$1, %esi
	movslq	%esi, %rsi
	subl	0(%r13,%rsi,4), %r9d
	cmpl	%r9d, %edx
	cmovg	%r9d, %edx
	addl	$2, %eax
	cmpl	%eax, %edi
	jle	.L31
	subl	%ecx, %eax
	movl	8(%r8), %ecx
	addl	$1, %eax
	cltq
	subl	0(%r13,%rax,4), %ecx
	cmpl	%ecx, %edx
	cmovg	%ecx, %edx
.L31:
	xorl	%eax, %eax
	movq	%r14, %rsi
	movl	$1, %edi
	call	__printf_chk@PLT
	movq	-56(%rbp), %rax
	subq	%fs:40, %rax
	jne	.L47
	leaq	-40(%rbp), %rsp
	xorl	%eax, %eax
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_remember_state
	.cfi_def_cfa 7, 8
	ret
.L46:
	.cfi_restore_state
	orq	$0, -8(%rsp,%rcx)
	jmp	.L28
.L37:
	movl	%ecx, %eax
	jmp	.L32
.L47:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE26:
	.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	swap
	.type	swap, @function
swap:
.LFB23:
	.cfi_startproc
	endbr64
	movl	(%rdi), %eax
	movl	(%rsi), %edx
	movl	%edx, (%rdi)
	movl	%eax, (%rsi)
	ret
	.cfi_endproc
.LFE23:
	.size	swap, .-swap
	.p2align 4
	.globl	partition
	.type	partition, @function
partition:
.LFB24:
	.cfi_startproc
	endbr64
	movslq	%esi, %rax
	addl	$1, %esi
	leal	1(%rdx), %r8d
	movq	%rdi, %r10
	leaq	(%rdi,%rax,4), %r11
	movslq	%esi, %rdi
	movl	(%r11), %ecx
	.p2align 4,,10
	.p2align 3
.L4:
	movl	(%r10,%rdi,4), %r9d
	cmpl	%ecx, %r9d
	jl	.L5
	movslq	%r8d, %rax
	leaq	-4(%r10,%rax,4), %rax
	.p2align 4,,10
	.p2align 3
.L6:
	movq	%rax, %rsi
	movl	(%rax), %edx
	subq	$4, %rax
	subl	$1, %r8d
	cmpl	%edx, %ecx
	jl	.L6
	cmpl	%edi, %r8d
	jg	.L9
	movl	%edx, (%r11)
	movl	%r8d, %eax
	movl	%ecx, (%rsi)
	ret
	.p2align 4,,10
	.p2align 3
.L9:
	movl	%edx, (%r10,%rdi,4)
	movl	%r9d, (%rsi)
	movl	(%r11), %ecx
.L5:
	addq	$1, %rdi
	jmp	.L4
	.cfi_endproc
.LFE24:
	.size	partition, .-partition
	.p2align 4
	.globl	quick_sort
	.type	quick_sort, @function
quick_sort:
.LFB25:
	.cfi_startproc
	endbr64
	cmpl	%esi, %edx
	jle	.L20
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	movl	%esi, %r10d
	movq	%rdi, %r13
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	leal	1(%rdx), %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	movl	%edx, %ebx
	subq	$8, %rsp
	.cfi_def_cfa_offset 48
.L16:
	movslq	%r10d, %rax
	leal	1(%r10), %r8d
	movl	%ebp, %edx
	leaq	0(%r13,%rax,4), %r11
	movslq	%r8d, %r8
	movl	(%r11), %esi
	.p2align 4,,10
	.p2align 3
.L12:
	movl	0(%r13,%r8,4), %r9d
	cmpl	%esi, %r9d
	jl	.L13
	movslq	%edx, %rax
	leaq	-4(%r13,%rax,4), %rax
	.p2align 4,,10
	.p2align 3
.L14:
	movq	%rax, %rdi
	movl	(%rax), %ecx
	movl	%edx, %r12d
	subq	$4, %rax
	subl	$1, %edx
	cmpl	%ecx, %esi
	jl	.L14
	cmpl	%r8d, %edx
	jg	.L23
	movl	%ecx, (%r11)
	leal	-2(%r12), %edx
	movl	%esi, (%rdi)
	movl	%r10d, %esi
	movq	%r13, %rdi
	call	quick_sort
	cmpl	%r12d, %ebx
	jle	.L24
	movl	%r12d, %r10d
	jmp	.L16
	.p2align 4,,10
	.p2align 3
.L23:
	movl	%ecx, 0(%r13,%r8,4)
	movl	%r9d, (%rdi)
	movl	(%r11), %esi
.L13:
	addq	$1, %r8
	jmp	.L12
.L24:
	addq	$8, %rsp
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
.L20:
	.cfi_restore 3
	.cfi_restore 6
	.cfi_restore 12
	.cfi_restore 13
	ret
	.cfi_endproc
.LFE25:
	.size	quick_sort, .-quick_sort
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d %d"
.LC1:
	.string	"%d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB26:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	leaq	.LC0(%rip), %rdi
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%r15
	pushq	%r14
	leaq	-60(%rbp), %rdx
	leaq	-64(%rbp), %rsi
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	subq	$24, %rsp
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	.cfi_offset 12, -48
	.cfi_offset 3, -56
	movq	%fs:40, %rax
	movq	%rax, -56(%rbp)
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movslq	-64(%rbp), %rax
	movq	%rsp, %rsi
	movq	%rax, %rdx
	leaq	15(,%rax,4), %rax
	movq	%rax, %rcx
	andq	$-4096, %rax
	subq	%rax, %rsi
	andq	$-16, %rcx
	cmpq	%rsi, %rsp
	je	.L27
.L45:
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	cmpq	%rsi, %rsp
	jne	.L45
.L27:
	andl	$4095, %ecx
	subq	%rcx, %rsp
	testq	%rcx, %rcx
	jne	.L46
.L28:
	leaq	3(%rsp), %r13
	leaq	.LC1(%rip), %r14
	movq	%r13, %r15
	andq	$-4, %r13
	shrq	$2, %r15
	testl	%edx, %edx
	jle	.L29
	movq	%r13, %r12
	xorl	%ebx, %ebx
	.p2align 4,,10
	.p2align 3
.L30:
	movq	%r12, %rsi
	movq	%r14, %rdi
	xorl	%eax, %eax
	addl	$1, %ebx
	call	__isoc99_scanf@PLT
	movl	-64(%rbp), %edx
	addq	$4, %r12
	cmpl	%ebx, %edx
	jg	.L30
.L29:
	subl	$1, %edx
	movq	%r13, %rdi
	xorl	%esi, %esi
	call	quick_sort
	movl	-60(%rbp), %ecx
	movl	-64(%rbp), %edi
	leal	-1(%rcx), %eax
	cltq
	movl	0(%r13,%rax,4), %edx
	subl	0(,%r15,4), %edx
	cmpl	%edi, %ecx
	jge	.L31
	movl	%edi, %r8d
	subl	%ecx, %r8d
	leal	-1(%r8), %eax
	cmpl	$2, %eax
	jbe	.L37
	movd	%edx, %xmm4
	movl	%r8d, %edx
	movslq	%ecx, %rax
	shrl	$2, %edx
	leaq	0(%r13,%rax,4), %rsi
	pshufd	$0, %xmm4, %xmm0
	xorl	%eax, %eax
	salq	$4, %rdx
	.p2align 4,,10
	.p2align 3
.L33:
	movdqu	(%rsi,%rax), %xmm2
	movdqu	4(%r13,%rax), %xmm3
	addq	$16, %rax
	psubd	%xmm3, %xmm2
	movdqa	%xmm2, %xmm1
	pcmpgtd	%xmm0, %xmm1
	pand	%xmm1, %xmm0
	pandn	%xmm2, %xmm1
	por	%xmm1, %xmm0
	cmpq	%rdx, %rax
	jne	.L33
	movdqa	%xmm0, %xmm2
	movl	%r8d, %esi
	psrldq	$8, %xmm2
	andl	$-4, %esi
	movdqa	%xmm2, %xmm1
	leal	(%rsi,%rcx), %eax
	pcmpgtd	%xmm0, %xmm1
	pand	%xmm1, %xmm0
	pandn	%xmm2, %xmm1
	por	%xmm1, %xmm0
	movdqa	%xmm0, %xmm2
	psrldq	$4, %xmm2
	movdqa	%xmm2, %xmm1
	pcmpgtd	%xmm0, %xmm1
	pand	%xmm1, %xmm0
	pandn	%xmm2, %xmm1
	por	%xmm0, %xmm1
	movd	%xmm1, %edx
	cmpl	%esi, %r8d
	je	.L31
.L32:
	movslq	%eax, %rsi
	leaq	0(%r13,%rsi,4), %r8
	movl	%eax, %esi
	subl	%ecx, %esi
	movl	(%r8), %r9d
	addl	$1, %esi
	movslq	%esi, %rsi
	subl	0(%r13,%rsi,4), %r9d
	leal	1(%rax), %esi
	cmpl	%r9d, %edx
	cmovg	%r9d, %edx
	cmpl	%edi, %esi
	jge	.L31
	subl	%ecx, %esi
	movl	4(%r8), %r9d
	addl	$1, %esi
	movslq	%esi, %rsi
	subl	0(%r13,%rsi,4), %r9d
	cmpl	%r9d, %edx
	cmovg	%r9d, %edx
	addl	$2, %eax
	cmpl	%eax, %edi
	jle	.L31
	subl	%ecx, %eax
	movl	8(%r8), %ecx
	addl	$1, %eax
	cltq
	subl	0(%r13,%rax,4), %ecx
	cmpl	%ecx, %edx
	cmovg	%ecx, %edx
.L31:
	xorl	%eax, %eax
	movq	%r14, %rsi
	movl	$1, %edi
	call	__printf_chk@PLT
	movq	-56(%rbp), %rax
	subq	%fs:40, %rax
	jne	.L47
	leaq	-40(%rbp), %rsp
	xorl	%eax, %eax
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_remember_state
	.cfi_def_cfa 7, 8
	ret
.L46:
	.cfi_restore_state
	orq	$0, -8(%rsp,%rcx)
	jmp	.L28
.L37:
	movl	%ecx, %eax
	jmp	.L32
.L47:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE26:
	.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>

/* 値を入れ替える関数 */
void swap (int *x, int *y) {
  int temp;    // 値を一時保存する変数

  temp = *x;
  *x = *y;
  *y = temp;
}

/***
* pivotを決め、
* 全データをpivotを境目に振り分け、
* pivotの添え字を返す
***/
int partition (int h[], int left, int right) {
  int i, j, pivot;
  i = left;
  j = right + 1;
  pivot = left;   // 先頭要素をpivotとする

  do {
    do { i++; } while (h[i] < h[pivot]);
    do { j--; } while (h[pivot] < h[j]);
    // pivotより小さいものを左へ、大きいものを右へ
    if (i < j) { swap(&h[i], &h[j]); }
  } while (i < j);

  swap(&h[pivot], &h[j]);   //pivotを更新

  return j;
}

/* クイックソート */
void quick_sort (int h[], int left, int right) {
  int pivot;

  if (left < right) {
    pivot = partition(h, left, right);
    quick_sort(h, left, pivot-1);   // pivotを境に再帰的にクイックソート
    quick_sort(h, pivot+1, right);
  }
}

int main(void){
  int N,K,i;
  scanf("%d %d",&N,&K);
  int h[N];
  for(i=0;i<N;i++){
    scanf("%d",&h[i]);
  }
  
  quick_sort(h, 0, N-1);
  
  int min=h[K-1]-h[0];
  for(i=K;i<N;i++){
    if(min>h[i]-h[i-K+1]){
      min=h[i]-h[i-K+1];
    }
  }
  printf("%d",min);
  return 0;
}
5 3
5
7
10
7
7
 5 3
5
7
10
0
7
 5 3
8
7
10
0
7
 3 3
5
7
10
7
7
 5 3
0
15
11
15
12
 5 3
10
21
10
0
6
 3 3
10
7
1
1
5
 5 3
10
21
19
0
6
 4 3
10
21
19
0
6
 3 3
5
7
0
1
7

0 2 1 5 3 4 9 10 11 7
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>

/* 値を入れ替える関数 */
void swap (int *x, int *y) {
  int temp;    // 値を一時保存する変数

  temp = *x;
  *x = *y;
  *y = temp;
}

/***
* pivotを決め、
* 全データをpivotを境目に振り分け、
* pivotの添え字を返す
***/
int partition (int h[], int left, int right) {
  int i, j, pivot;
  i = left;
  j = right + 1;
  pivot = left;   // 先頭要素をpivotとする

  do {
    do { i++; } while (h[i] < h[pivot]);
    do { j--; } while (h[pivot] < h[j]);
    // pivotより小さいものを左へ、大きいものを右へ
    if (i < j) { swap(&h[i], &h[j]); }
  } while (i < j);

  swap(&h[pivot], &h[j]);   //pivotを更新

  return j;
}

/* クイックソート */
void quick_sort (int h[], int left, int right) {
  int pivot;

  if (left < right) {
    pivot = partition(h, left, right);
    quick_sort(h, left, pivot-1);   // pivotを境に再帰的にクイックソート
    quick_sort(h, pivot+1, right);
  }
}

int main(void){
  int N,K,i;
  scanf("%d %d",&N,&K);
  int h[N];
  for(i=0;i<N;i++){
    scanf("%d",&h[i]);
  }
  
  quick_sort(h, 0, N-1);
  
  int min=h[K-1]-h[0];
  for(i=K;i<N;i++){
    if(min>h[i]-h[i-K+1]){
      min=h[i]-h[i-K+1];
    }
  }
  printf("%d",min);
  return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	swap
	.type	swap, @function
swap:
.LFB0:
	.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
	movl	(%rax), %eax
	movl	%eax, -4(%rbp)
	movq	-32(%rbp), %rax
	movl	(%rax), %edx
	movq	-24(%rbp), %rax
	movl	%edx, (%rax)
	movq	-32(%rbp), %rax
	movl	-4(%rbp), %edx
	movl	%edx, (%rax)
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	swap, .-swap
	.globl	partition
	.type	partition, @function
partition:
.LFB1:
	.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, -24(%rbp)
	movl	%esi, -28(%rbp)
	movl	%edx, -32(%rbp)
	movl	-28(%rbp), %eax
	movl	%eax, -12(%rbp)
	movl	-32(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -8(%rbp)
	movl	-28(%rbp), %eax
	movl	%eax, -4(%rbp)
.L3:
	addl	$1, -12(%rbp)
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	movq	-24(%rbp), %rax
	addq	%rcx, %rax
	movl	(%rax), %eax
	cmpl	%eax, %edx
	jl	.L3
.L4:
	subl	$1, -8(%rbp)
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	movq	-24(%rbp), %rax
	addq	%rcx, %rax
	movl	(%rax), %eax
	cmpl	%eax, %edx
	jl	.L4
	movl	-12(%rbp), %eax
	cmpl	-8(%rbp), %eax
	jge	.L5
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rax, %rdx
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	movq	-24(%rbp), %rax
	addq	%rcx, %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	swap
.L5:
	movl	-12(%rbp), %eax
	cmpl	-8(%rbp), %eax
	jl	.L3
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rax, %rdx
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	movq	-24(%rbp), %rax
	addq	%rcx, %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	swap
	movl	-8(%rbp), %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	partition, .-partition
	.globl	quick_sort
	.type	quick_sort, @function
quick_sort:
.LFB2:
	.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, -24(%rbp)
	movl	%esi, -28(%rbp)
	movl	%edx, -32(%rbp)
	movl	-28(%rbp), %eax
	cmpl	-32(%rbp), %eax
	jge	.L9
	movl	-32(%rbp), %edx
	movl	-28(%rbp), %ecx
	movq	-24(%rbp), %rax
	movl	%ecx, %esi
	movq	%rax, %rdi
	call	partition
	movl	%eax, -4(%rbp)
	movl	-4(%rbp), %eax
	leal	-1(%rax), %edx
	movl	-28(%rbp), %ecx
	movq	-24(%rbp), %rax
	movl	%ecx, %esi
	movq	%rax, %rdi
	call	quick_sort
	movl	-4(%rbp), %eax
	leal	1(%rax), %ecx
	movl	-32(%rbp), %edx
	movq	-24(%rbp), %rax
	movl	%ecx, %esi
	movq	%rax, %rdi
	call	quick_sort
.L9:
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2:
	.size	quick_sort, .-quick_sort
	.section	.rodata
.LC0:
	.string	"%d %d"
.LC1:
	.string	"%d"
	.text
	.globl	main
	.type	main, @function
main:
.LFB3:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%r15
	pushq	%r14
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	subq	$56, %rsp
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	.cfi_offset 12, -48
	.cfi_offset 3, -56
	movq	%fs:40, %rax
	movq	%rax, -56(%rbp)
	xorl	%eax, %eax
	movq	%rsp, %rax
	movq	%rax, %rbx
	leaq	-84(%rbp), %rdx
	leaq	-88(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-88(%rbp), %eax
	movslq	%eax, %rdx
	subq	$1, %rdx
	movq	%rdx, -72(%rbp)
	movslq	%eax, %rdx
	movq	%rdx, %r14
	movl	$0, %r15d
	movslq	%eax, %rdx
	movq	%rdx, %r12
	movl	$0, %r13d
	cltq
	leaq	0(,%rax,4), %rdx
	movl	$16, %eax
	subq	$1, %rax
	addq	%rdx, %rax
	movl	$16, %esi
	movl	$0, %edx
	divq	%rsi
	imulq	$16, %rax, %rax
	movq	%rax, %rcx
	andq	$-4096, %rcx
	movq	%rsp, %rdx
	subq	%rcx, %rdx
.L11:
	cmpq	%rdx, %rsp
	je	.L12
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L11
.L12:
	movq	%rax, %rdx
	andl	$4095, %edx
	subq	%rdx, %rsp
	movq	%rax, %rdx
	andl	$4095, %edx
	testq	%rdx, %rdx
	je	.L13
	andl	$4095, %eax
	subq	$8, %rax
	addq	%rsp, %rax
	orq	$0, (%rax)
.L13:
	movq	%rsp, %rax
	addq	$3, %rax
	shrq	$2, %rax
	salq	$2, %rax
	movq	%rax, -64(%rbp)
	movl	$0, -80(%rbp)
	jmp	.L14
.L15:
	movl	-80(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-64(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -80(%rbp)
.L14:
	movl	-88(%rbp), %eax
	cmpl	%eax, -80(%rbp)
	jl	.L15
	movl	-88(%rbp), %eax
	leal	-1(%rax), %edx
	movq	-64(%rbp), %rax
	movl	$0, %esi
	movq	%rax, %rdi
	call	quick_sort
	movl	-84(%rbp), %eax
	leal	-1(%rax), %edx
	movq	-64(%rbp), %rax
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %edx
	movq	-64(%rbp), %rax
	movl	(%rax), %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	movl	%eax, -76(%rbp)
	movl	-84(%rbp), %eax
	movl	%eax, -80(%rbp)
	jmp	.L16
.L18:
	movq	-64(%rbp), %rax
	movl	-80(%rbp), %edx
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %ecx
	movl	-84(%rbp), %edx
	movl	-80(%rbp), %eax
	subl	%edx, %eax
	leal	1(%rax), %edx
	movq	-64(%rbp), %rax
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %edx
	movl	%ecx, %eax
	subl	%edx, %eax
	cmpl	%eax, -76(%rbp)
	jle	.L17
	movq	-64(%rbp), %rax
	movl	-80(%rbp), %edx
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %ecx
	movl	-84(%rbp), %edx
	movl	-80(%rbp), %eax
	subl	%edx, %eax
	leal	1(%rax), %edx
	movq	-64(%rbp), %rax
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %edx
	movl	%ecx, %eax
	subl	%edx, %eax
	movl	%eax, -76(%rbp)
.L17:
	addl	$1, -80(%rbp)
.L16:
	movl	-88(%rbp), %eax
	cmpl	%eax, -80(%rbp)
	jl	.L18
	movl	-76(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	%rbx, %rsp
	movq	-56(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L20
	call	__stack_chk_fail@PLT
.L20:
	leaq	-40(%rbp), %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE3:
	.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	swap
	.type	swap, @function
swap:
.LFB0:
	.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
	movl	(%rax), %eax
	movl	%eax, -4(%rbp)
	movq	-32(%rbp), %rax
	movl	(%rax), %edx
	movq	-24(%rbp), %rax
	movl	%edx, (%rax)
	movq	-32(%rbp), %rax
	movl	-4(%rbp), %edx
	movl	%edx, (%rax)
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	swap, .-swap
	.globl	partition
	.type	partition, @function
partition:
.LFB1:
	.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, -24(%rbp)
	movl	%esi, -28(%rbp)
	movl	%edx, -32(%rbp)
	movl	-28(%rbp), %eax
	movl	%eax, -12(%rbp)
	movl	-32(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -8(%rbp)
	movl	-28(%rbp), %eax
	movl	%eax, -4(%rbp)
.L3:
	addl	$1, -12(%rbp)
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	movq	-24(%rbp), %rax
	addq	%rcx, %rax
	movl	(%rax), %eax
	cmpl	%eax, %edx
	jl	.L3
.L4:
	subl	$1, -8(%rbp)
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	movq	-24(%rbp), %rax
	addq	%rcx, %rax
	movl	(%rax), %eax
	cmpl	%eax, %edx
	jl	.L4
	movl	-12(%rbp), %eax
	cmpl	-8(%rbp), %eax
	jge	.L5
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rax, %rdx
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	movq	-24(%rbp), %rax
	addq	%rcx, %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	swap
.L5:
	movl	-12(%rbp), %eax
	cmpl	-8(%rbp), %eax
	jl	.L3
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rax, %rdx
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	movq	-24(%rbp), %rax
	addq	%rcx, %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	swap
	movl	-8(%rbp), %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	partition, .-partition
	.globl	quick_sort
	.type	quick_sort, @function
quick_sort:
.LFB2:
	.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, -24(%rbp)
	movl	%esi, -28(%rbp)
	movl	%edx, -32(%rbp)
	movl	-28(%rbp), %eax
	cmpl	-32(%rbp), %eax
	jge	.L9
	movl	-32(%rbp), %edx
	movl	-28(%rbp), %ecx
	movq	-24(%rbp), %rax
	movl	%ecx, %esi
	movq	%rax, %rdi
	call	partition
	movl	%eax, -4(%rbp)
	movl	-4(%rbp), %eax
	leal	-1(%rax), %edx
	movl	-28(%rbp), %ecx
	movq	-24(%rbp), %rax
	movl	%ecx, %esi
	movq	%rax, %rdi
	call	quick_sort
	movl	-4(%rbp), %eax
	leal	1(%rax), %ecx
	movl	-32(%rbp), %edx
	movq	-24(%rbp), %rax
	movl	%ecx, %esi
	movq	%rax, %rdi
	call	quick_sort
.L9:
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2:
	.size	quick_sort, .-quick_sort
	.section	.rodata
.LC0:
	.string	"%d %d"
.LC1:
	.string	"%d"
	.text
	.globl	main
	.type	main, @function
main:
.LFB3:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%r15
	pushq	%r14
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	subq	$56, %rsp
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	.cfi_offset 12, -48
	.cfi_offset 3, -56
	movq	%fs:40, %rax
	movq	%rax, -56(%rbp)
	xorl	%eax, %eax
	movq	%rsp, %rax
	movq	%rax, %rbx
	leaq	-84(%rbp), %rdx
	leaq	-88(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-88(%rbp), %eax
	movslq	%eax, %rdx
	subq	$1, %rdx
	movq	%rdx, -72(%rbp)
	movslq	%eax, %rdx
	movq	%rdx, %r14
	movl	$0, %r15d
	movslq	%eax, %rdx
	movq	%rdx, %r12
	movl	$0, %r13d
	cltq
	leaq	0(,%rax,4), %rdx
	movl	$16, %eax
	subq	$1, %rax
	addq	%rdx, %rax
	movl	$16, %esi
	movl	$0, %edx
	divq	%rsi
	imulq	$16, %rax, %rax
	movq	%rax, %rcx
	andq	$-4096, %rcx
	movq	%rsp, %rdx
	subq	%rcx, %rdx
.L11:
	cmpq	%rdx, %rsp
	je	.L12
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L11
.L12:
	movq	%rax, %rdx
	andl	$4095, %edx
	subq	%rdx, %rsp
	movq	%rax, %rdx
	andl	$4095, %edx
	testq	%rdx, %rdx
	je	.L13
	andl	$4095, %eax
	subq	$8, %rax
	addq	%rsp, %rax
	orq	$0, (%rax)
.L13:
	movq	%rsp, %rax
	addq	$3, %rax
	shrq	$2, %rax
	salq	$2, %rax
	movq	%rax, -64(%rbp)
	movl	$0, -80(%rbp)
	jmp	.L14
.L15:
	movl	-80(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-64(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -80(%rbp)
.L14:
	movl	-88(%rbp), %eax
	cmpl	%eax, -80(%rbp)
	jl	.L15
	movl	-88(%rbp), %eax
	leal	-1(%rax), %edx
	movq	-64(%rbp), %rax
	movl	$0, %esi
	movq	%rax, %rdi
	call	quick_sort
	movl	-84(%rbp), %eax
	leal	-1(%rax), %edx
	movq	-64(%rbp), %rax
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %edx
	movq	-64(%rbp), %rax
	movl	(%rax), %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	movl	%eax, -76(%rbp)
	movl	-84(%rbp), %eax
	movl	%eax, -80(%rbp)
	jmp	.L16
.L18:
	movq	-64(%rbp), %rax
	movl	-80(%rbp), %edx
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %ecx
	movl	-84(%rbp), %edx
	movl	-80(%rbp), %eax
	subl	%edx, %eax
	leal	1(%rax), %edx
	movq	-64(%rbp), %rax
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %edx
	movl	%ecx, %eax
	subl	%edx, %eax
	cmpl	%eax, -76(%rbp)
	jle	.L17
	movq	-64(%rbp), %rax
	movl	-80(%rbp), %edx
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %ecx
	movl	-84(%rbp), %edx
	movl	-80(%rbp), %eax
	subl	%edx, %eax
	leal	1(%rax), %edx
	movq	-64(%rbp), %rax
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %edx
	movl	%ecx, %eax
	subl	%edx, %eax
	movl	%eax, -76(%rbp)
.L17:
	addl	$1, -80(%rbp)
.L16:
	movl	-88(%rbp), %eax
	cmpl	%eax, -80(%rbp)
	jl	.L18
	movl	-76(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	%rbx, %rsp
	movq	-56(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L20
	call	__stack_chk_fail@PLT
.L20:
	leaq	-40(%rbp), %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE3:
	.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:
