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>

typedef struct {
	int pNum;
	double pTime;
} Record;

void sort(Record *data, int n)
{
	int i, j;
	Record temp;

	for (i = 0; i < n - 1; i++){
		for (j = 0; j < n - i - 1; j++){
			if (data[j].pTime > data[j + 1].pTime){
				temp = data[j];
				data[j] = data[j + 1];
				data[j + 1] = temp;
			}
		}
	}
}


int main(void)
{
	Record in[3][8];
	Record chance[6];
	int i, j;

	for (i = 0; i < 3;i++){
		for (j = 0; j < 8; j++){
			scanf("%d%lf", &in[i][j].pNum, &in[i][j].pTime);
		}
		sort(in[i], 8);
		printf("%d %.2lf\n%d %.2lf\n", in[i][0].pNum, in[i][0].pTime, in[i][1].pNum, in[i][1].pTime);
		chance[i * 2] = in[i][2];
		chance[i * 2 + 1] = in[i][3];
	}

	sort(chance, 6);

	printf("%d %.2lf\n%d %.2lf\n", chance[0].pNum, chance[0].pTime, chance[1].pNum, chance[1].pTime);
	return (0);
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	sort
	.type	sort, @function
sort:
.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, -40(%rbp)
	movl	%esi, -44(%rbp)
	movl	$0, -24(%rbp)
	jmp	.L2
.L7:
	movl	$0, -20(%rbp)
	jmp	.L3
.L6:
	movl	-20(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	movq	-40(%rbp), %rax
	addq	%rdx, %rax
	movsd	8(%rax), %xmm0
	movl	-20(%rbp), %eax
	cltq
	addq	$1, %rax
	salq	$4, %rax
	movq	%rax, %rdx
	movq	-40(%rbp), %rax
	addq	%rdx, %rax
	movsd	8(%rax), %xmm1
	comisd	%xmm1, %xmm0
	jbe	.L4
	movl	-20(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	movq	-40(%rbp), %rax
	addq	%rdx, %rax
	movq	8(%rax), %rdx
	movq	(%rax), %rax
	movq	%rax, -16(%rbp)
	movq	%rdx, -8(%rbp)
	movl	-20(%rbp), %eax
	cltq
	addq	$1, %rax
	salq	$4, %rax
	movq	%rax, %rdx
	movq	-40(%rbp), %rax
	addq	%rdx, %rax
	movl	-20(%rbp), %edx
	movslq	%edx, %rdx
	movq	%rdx, %rcx
	salq	$4, %rcx
	movq	-40(%rbp), %rdx
	addq	%rdx, %rcx
	movq	8(%rax), %rdx
	movq	(%rax), %rax
	movq	%rax, (%rcx)
	movq	%rdx, 8(%rcx)
	movl	-20(%rbp), %eax
	cltq
	addq	$1, %rax
	salq	$4, %rax
	movq	%rax, %rdx
	movq	-40(%rbp), %rax
	leaq	(%rdx,%rax), %rcx
	movq	-16(%rbp), %rax
	movq	-8(%rbp), %rdx
	movq	%rax, (%rcx)
	movq	%rdx, 8(%rcx)
.L4:
	addl	$1, -20(%rbp)
.L3:
	movl	-44(%rbp), %eax
	subl	-24(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -20(%rbp)
	jl	.L6
	addl	$1, -24(%rbp)
.L2:
	movl	-44(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -24(%rbp)
	jl	.L7
	nop
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	sort, .-sort
	.section	.rodata
.LC0:
	.string	"%d%lf"
.LC1:
	.string	"%d %.2lf\n%d %.2lf\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	$512, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -504(%rbp)
	jmp	.L10
.L13:
	movl	$0, -500(%rbp)
	jmp	.L11
.L12:
	leaq	-400(%rbp), %rdx
	movl	-500(%rbp), %eax
	movslq	%eax, %rcx
	movl	-504(%rbp), %eax
	cltq
	salq	$3, %rax
	addq	%rcx, %rax
	salq	$4, %rax
	addq	%rdx, %rax
	leaq	8(%rax), %rdx
	leaq	-400(%rbp), %rcx
	movl	-500(%rbp), %eax
	movslq	%eax, %rsi
	movl	-504(%rbp), %eax
	cltq
	salq	$3, %rax
	addq	%rsi, %rax
	salq	$4, %rax
	addq	%rcx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -500(%rbp)
.L11:
	cmpl	$7, -500(%rbp)
	jle	.L12
	leaq	-400(%rbp), %rdx
	movl	-504(%rbp), %eax
	cltq
	salq	$7, %rax
	addq	%rdx, %rax
	movl	$8, %esi
	movq	%rax, %rdi
	call	sort
	movl	-504(%rbp), %eax
	cltq
	salq	$7, %rax
	addq	%rbp, %rax
	subq	$376, %rax
	movsd	(%rax), %xmm0
	movl	-504(%rbp), %eax
	cltq
	salq	$7, %rax
	addq	%rbp, %rax
	subq	$384, %rax
	movl	(%rax), %edx
	movl	-504(%rbp), %eax
	cltq
	salq	$7, %rax
	addq	%rbp, %rax
	subq	$392, %rax
	movq	(%rax), %rcx
	movl	-504(%rbp), %eax
	cltq
	salq	$7, %rax
	addq	%rbp, %rax
	subq	$400, %rax
	movl	(%rax), %eax
	movapd	%xmm0, %xmm1
	movq	%rcx, %xmm0
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$2, %eax
	call	printf@PLT
	movl	-504(%rbp), %eax
	addl	%eax, %eax
	cltq
	salq	$4, %rax
	addq	%rbp, %rax
	leaq	-496(%rax), %rcx
	movl	-504(%rbp), %eax
	cltq
	salq	$7, %rax
	addq	%rbp, %rax
	subq	$368, %rax
	movq	8(%rax), %rdx
	movq	(%rax), %rax
	movq	%rax, (%rcx)
	movq	%rdx, 8(%rcx)
	movl	-504(%rbp), %eax
	addl	%eax, %eax
	addl	$1, %eax
	cltq
	salq	$4, %rax
	addq	%rbp, %rax
	leaq	-496(%rax), %rcx
	movl	-504(%rbp), %eax
	cltq
	salq	$7, %rax
	addq	%rbp, %rax
	subq	$352, %rax
	movq	8(%rax), %rdx
	movq	(%rax), %rax
	movq	%rax, (%rcx)
	movq	%rdx, 8(%rcx)
	addl	$1, -504(%rbp)
.L10:
	cmpl	$2, -504(%rbp)
	jle	.L13
	leaq	-496(%rbp), %rax
	movl	$6, %esi
	movq	%rax, %rdi
	call	sort
	movsd	-472(%rbp), %xmm0
	movl	-480(%rbp), %edx
	movq	-488(%rbp), %rcx
	movl	-496(%rbp), %eax
	movapd	%xmm0, %xmm1
	movq	%rcx, %xmm0
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$2, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L15
	call	__stack_chk_fail@PLT
.L15:
	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	sort
	.type	sort, @function
sort:
.LFB39:
	.cfi_startproc
	endbr64
	leal	-1(%rsi), %edx
	testl	%edx, %edx
	jle	.L1
	leaq	16(%rdi), %r8
	.p2align 4,,10
	.p2align 3
.L3:
	subl	$1, %edx
	movq	%rdi, %rax
	movq	%rdx, %rsi
	salq	$4, %rdx
	addq	%r8, %rdx
	.p2align 4,,10
	.p2align 3
.L6:
	movsd	8(%rax), %xmm0
	comisd	24(%rax), %xmm0
	jbe	.L4
	movl	(%rax), %ecx
	movdqu	16(%rax), %xmm1
	movsd	%xmm0, 24(%rax)
	movl	%ecx, 16(%rax)
	movups	%xmm1, (%rax)
.L4:
	addq	$16, %rax
	cmpq	%rdx, %rax
	jne	.L6
	movl	%esi, %edx
	testl	%esi, %esi
	jne	.L3
.L1:
	ret
	.cfi_endproc
.LFE39:
	.size	sort, .-sort
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d%lf"
.LC1:
	.string	"%d %.2lf\n%d %.2lf\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
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	leaq	.LC1(%rip), %r14
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	xorl	%r12d, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	leaq	.LC0(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$520, %rsp
	.cfi_def_cfa_offset 576
	movq	%fs:40, %rax
	movq	%rax, 504(%rsp)
	xorl	%eax, %eax
	leaq	624(%rsp), %rax
	leaq	240(%rsp), %rbx
	movq	%rax, 8(%rsp)
	leaq	16(%rsp), %r13
.L14:
	leaq	-128(%rbx), %r15
	.p2align 4,,10
	.p2align 3
.L15:
	leaq	8(%r15), %rdx
	movq	%r15, %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	addq	$16, %r15
	cmpq	%rbx, %r15
	jne	.L15
	movsd	-120(%rbx), %xmm0
	movl	$7, %eax
	jmp	.L16
	.p2align 4,,10
	.p2align 3
.L60:
	movsd	-104(%rbx), %xmm1
	comisd	-88(%rbx), %xmm1
	jbe	.L24
	movl	-112(%rbx), %edx
	movdqa	-96(%rbx), %xmm3
	movsd	%xmm1, -88(%rbx)
	movl	%edx, -96(%rbx)
	movaps	%xmm3, -112(%rbx)
.L24:
	cmpl	$2, %eax
	je	.L19
	movsd	-88(%rbx), %xmm1
	comisd	-72(%rbx), %xmm1
	jbe	.L26
	movl	-96(%rbx), %edx
	movdqa	-80(%rbx), %xmm4
	movsd	%xmm1, -72(%rbx)
	movl	%edx, -80(%rbx)
	movaps	%xmm4, -96(%rbx)
.L26:
	cmpl	$3, %eax
	je	.L19
	movsd	-72(%rbx), %xmm1
	comisd	-56(%rbx), %xmm1
	jbe	.L28
	movl	-80(%rbx), %edx
	movdqa	-64(%rbx), %xmm5
	movsd	%xmm1, -56(%rbx)
	movl	%edx, -64(%rbx)
	movaps	%xmm5, -80(%rbx)
.L28:
	cmpl	$4, %eax
	je	.L19
	movsd	-56(%rbx), %xmm1
	comisd	-40(%rbx), %xmm1
	jbe	.L30
	movl	-64(%rbx), %edx
	movdqa	-48(%rbx), %xmm6
	movsd	%xmm1, -40(%rbx)
	movl	%edx, -48(%rbx)
	movaps	%xmm6, -64(%rbx)
.L30:
	cmpl	$5, %eax
	je	.L19
	movsd	-40(%rbx), %xmm1
	comisd	-24(%rbx), %xmm1
	jbe	.L32
	movl	-48(%rbx), %edx
	movdqa	-32(%rbx), %xmm7
	movsd	%xmm1, -24(%rbx)
	movl	%edx, -32(%rbx)
	movaps	%xmm7, -48(%rbx)
.L32:
	cmpl	$7, %eax
	jne	.L19
	movsd	-24(%rbx), %xmm1
	comisd	-8(%rbx), %xmm1
	jbe	.L19
	movl	-32(%rbx), %edx
	movdqa	-16(%rbx), %xmm7
	movsd	%xmm1, -8(%rbx)
	movl	%edx, -16(%rbx)
	movaps	%xmm7, -32(%rbx)
.L19:
	subl	$1, %eax
.L16:
	comisd	-104(%rbx), %xmm0
	jbe	.L21
	movl	-128(%rbx), %edx
	movdqa	-112(%rbx), %xmm2
	movsd	%xmm0, -104(%rbx)
	movl	%edx, -112(%rbx)
	movaps	%xmm2, -128(%rbx)
	movsd	-120(%rbx), %xmm0
.L21:
	cmpl	$1, %eax
	jne	.L60
	movl	-112(%rbx), %ecx
	movl	-128(%rbx), %edx
	movq	%r14, %rsi
	movl	$1, %edi
	movsd	-104(%rbx), %xmm1
	movl	$2, %eax
	subq	$-128, %rbx
	call	__printf_chk@PLT
	movdqa	-224(%rbx), %xmm6
	movdqa	-208(%rbx), %xmm5
	movaps	%xmm6, 0(%r13,%r12,4)
	movaps	%xmm5, 16(%r13,%r12,4)
	addq	$8, %r12
	cmpq	8(%rsp), %rbx
	jne	.L14
	movl	$6, %esi
	movq	%r13, %rdi
	call	sort
	movl	32(%rsp), %ecx
	movl	16(%rsp), %edx
	movq	%r14, %rsi
	movsd	40(%rsp), %xmm1
	movsd	24(%rsp), %xmm0
	movl	$1, %edi
	movl	$2, %eax
	call	__printf_chk@PLT
	movq	504(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L61
	addq	$520, %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
.L61:
	.cfi_restore_state
	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	sort
	.type	sort, @function
sort:
.LFB39:
	.cfi_startproc
	endbr64
	leal	-1(%rsi), %edx
	testl	%edx, %edx
	jle	.L1
	leaq	16(%rdi), %r8
	.p2align 4,,10
	.p2align 3
.L3:
	subl	$1, %edx
	movq	%rdi, %rax
	movq	%rdx, %rsi
	salq	$4, %rdx
	addq	%r8, %rdx
	.p2align 4,,10
	.p2align 3
.L6:
	movsd	8(%rax), %xmm0
	comisd	24(%rax), %xmm0
	jbe	.L4
	movl	(%rax), %ecx
	movdqu	16(%rax), %xmm1
	movsd	%xmm0, 24(%rax)
	movl	%ecx, 16(%rax)
	movups	%xmm1, (%rax)
.L4:
	addq	$16, %rax
	cmpq	%rdx, %rax
	jne	.L6
	movl	%esi, %edx
	testl	%esi, %esi
	jne	.L3
.L1:
	ret
	.cfi_endproc
.LFE39:
	.size	sort, .-sort
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d%lf"
.LC1:
	.string	"%d %.2lf\n%d %.2lf\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
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	leaq	.LC1(%rip), %r14
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	xorl	%r12d, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	leaq	.LC0(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$520, %rsp
	.cfi_def_cfa_offset 576
	movq	%fs:40, %rax
	movq	%rax, 504(%rsp)
	xorl	%eax, %eax
	leaq	624(%rsp), %rax
	leaq	240(%rsp), %rbx
	movq	%rax, 8(%rsp)
	leaq	16(%rsp), %r13
.L14:
	leaq	-128(%rbx), %r15
	.p2align 4,,10
	.p2align 3
.L15:
	leaq	8(%r15), %rdx
	movq	%r15, %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	addq	$16, %r15
	cmpq	%rbx, %r15
	jne	.L15
	movsd	-120(%rbx), %xmm0
	movl	$7, %eax
	jmp	.L16
	.p2align 4,,10
	.p2align 3
.L60:
	movsd	-104(%rbx), %xmm1
	comisd	-88(%rbx), %xmm1
	jbe	.L24
	movl	-112(%rbx), %edx
	movdqa	-96(%rbx), %xmm3
	movsd	%xmm1, -88(%rbx)
	movl	%edx, -96(%rbx)
	movaps	%xmm3, -112(%rbx)
.L24:
	cmpl	$2, %eax
	je	.L19
	movsd	-88(%rbx), %xmm1
	comisd	-72(%rbx), %xmm1
	jbe	.L26
	movl	-96(%rbx), %edx
	movdqa	-80(%rbx), %xmm4
	movsd	%xmm1, -72(%rbx)
	movl	%edx, -80(%rbx)
	movaps	%xmm4, -96(%rbx)
.L26:
	cmpl	$3, %eax
	je	.L19
	movsd	-72(%rbx), %xmm1
	comisd	-56(%rbx), %xmm1
	jbe	.L28
	movl	-80(%rbx), %edx
	movdqa	-64(%rbx), %xmm5
	movsd	%xmm1, -56(%rbx)
	movl	%edx, -64(%rbx)
	movaps	%xmm5, -80(%rbx)
.L28:
	cmpl	$4, %eax
	je	.L19
	movsd	-56(%rbx), %xmm1
	comisd	-40(%rbx), %xmm1
	jbe	.L30
	movl	-64(%rbx), %edx
	movdqa	-48(%rbx), %xmm6
	movsd	%xmm1, -40(%rbx)
	movl	%edx, -48(%rbx)
	movaps	%xmm6, -64(%rbx)
.L30:
	cmpl	$5, %eax
	je	.L19
	movsd	-40(%rbx), %xmm1
	comisd	-24(%rbx), %xmm1
	jbe	.L32
	movl	-48(%rbx), %edx
	movdqa	-32(%rbx), %xmm7
	movsd	%xmm1, -24(%rbx)
	movl	%edx, -32(%rbx)
	movaps	%xmm7, -48(%rbx)
.L32:
	cmpl	$7, %eax
	jne	.L19
	movsd	-24(%rbx), %xmm1
	comisd	-8(%rbx), %xmm1
	jbe	.L19
	movl	-32(%rbx), %edx
	movdqa	-16(%rbx), %xmm7
	movsd	%xmm1, -8(%rbx)
	movl	%edx, -16(%rbx)
	movaps	%xmm7, -32(%rbx)
.L19:
	subl	$1, %eax
.L16:
	comisd	-104(%rbx), %xmm0
	jbe	.L21
	movl	-128(%rbx), %edx
	movdqa	-112(%rbx), %xmm2
	movsd	%xmm0, -104(%rbx)
	movl	%edx, -112(%rbx)
	movaps	%xmm2, -128(%rbx)
	movsd	-120(%rbx), %xmm0
.L21:
	cmpl	$1, %eax
	jne	.L60
	movl	-112(%rbx), %ecx
	movl	-128(%rbx), %edx
	movq	%r14, %rsi
	movl	$1, %edi
	movsd	-104(%rbx), %xmm1
	movl	$2, %eax
	subq	$-128, %rbx
	call	__printf_chk@PLT
	movdqa	-224(%rbx), %xmm6
	movdqa	-208(%rbx), %xmm5
	movaps	%xmm6, 0(%r13,%r12,4)
	movaps	%xmm5, 16(%r13,%r12,4)
	addq	$8, %r12
	cmpq	8(%rsp), %rbx
	jne	.L14
	movl	$6, %esi
	movq	%r13, %rdi
	call	sort
	movl	32(%rsp), %ecx
	movl	16(%rsp), %edx
	movq	%r14, %rsi
	movsd	40(%rsp), %xmm1
	movsd	24(%rsp), %xmm0
	movl	$1, %edi
	movl	$2, %eax
	call	__printf_chk@PLT
	movq	504(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L61
	addq	$520, %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
.L61:
	.cfi_restore_state
	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>

typedef struct {
	int pNum;
	double pTime;
} Record;

void sort(Record *data, int n)
{
	int i, j;
	Record temp;

	for (i = 0; i < n - 1; i++){
		for (j = 0; j < n - i - 1; j++){
			if (data[j].pTime > data[j + 1].pTime){
				temp = data[j];
				data[j] = data[j + 1];
				data[j + 1] = temp;
			}
		}
	}
}


int main(void)
{
	Record in[3][8];
	Record chance[6];
	int i, j;

	for (i = 0; i < 3;i++){
		for (j = 0; j < 8; j++){
			scanf("%d%lf", &in[i][j].pNum, &in[i][j].pTime);
		}
		sort(in[i], 8);
		printf("%d %.2lf\n%d %.2lf\n", in[i][0].pNum, in[i][0].pTime, in[i][1].pNum, in[i][1].pTime);
		chance[i * 2] = in[i][2];
		chance[i * 2 + 1] = in[i][3];
	}

	sort(chance, 6);

	printf("%d %.2lf\n%d %.2lf\n", chance[0].pNum, chance[0].pTime, chance[1].pNum, chance[1].pTime);
	return (0);
}
18 25.46
16 26.23
3 23.00
10 24.79
5 22.88
11 23.87
19 23.90
1 25.11
23 23.88
4 23.46
7 24.12
12 22.91
13 21.99
14 22.86
21 23.12
9 24.09
17 22.51
22 23.49
6 23.02
20 22.23
8 21.89
15 24.14
8 23.77
2 23.42
 18 25.46
16 26.23
3 23.00
10 24.79
5 22.88
11 23.87
19 23.90
1 25.11
23 23.88
4 23.46
7 24.12
12 22.91
13 21.99
14 23.479546478837634
21 23.12
9 24.09
17 22.51
22 23.49
6 23.02
20 22.23
8 21.89
15 24.14
8 23.77
2 23.42
 18 25.46
16 26.23
3 23.00
10 24.79
5 22.88
11 23.87
19 23.90
1 25.11
23 23.88
4 23.46
7 24.12
12 22.91
13 21.99
14 22.86
8 23.12
9 24.09
17 22.51
22 23.49
6 23.02
20 22.23
24 21.89
15 24.14
8 23.77
2 23.42
 18 25.46
16 26.23
3 23.00
10 24.79
5 22.88
11 23.87
19 23.90
1 25.11
23 23.88
4 23.46
7 24.12
12 23.88090204379987
13 21.99
14 22.86
8 23.12
9 24.09
17 22.51
22 23.49
6 23.02
20 22.23
24 21.89
15 24.14
8 23.77
2 23.42
 27 25.46
16 26.23
3 23.00
10 24.79
5 22.88
11 23.87
19 23.90
2 25.11
23 23.88
4 23.46
7 24.12
12 22.91
13 21.99
14 22.86
21 23.12
9 24.09
26 22.51
22 23.49
6 23.02
20 22.23
8 21.89
15 24.14
8 23.77
2 23.42
 18 26.1511190671642
16 26.23
3 23.00
10 24.79
5 22.88
11 23.87
19 23.90
1 25.11
23 23.88
4 23.844314504002764
7 24.12
12 23.88090204379987
13 21.99
14 22.86
8 23.12
9 24.09
17 22.51
22 23.49
6 23.02
20 22.23
8 21.89
15 24.14
8 23.77
2 23.42
 18 25.46
16 26.23
3 23.00
10 24.79
7 22.88
11 23.87
19 23.90
1 25.11
24 23.88
4 23.46
7 24.12
12 22.91
13 21.99
14 22.86
21 23.12
0 24.09
17 22.51
22 23.49
6 23.02
20 22.23
24 21.89
15 24.14
8 23.77
2 23.42
 18 25.46
16 26.23
3 23.00
10 24.79
5 22.88
14 23.87
19 23.90
1 25.11
23 23.88
4 23.46
7 24.297502254604733
12 23.88090204379987
13 21.99
14 23.678873066875145
8 23.12
9 24.09
17 22.51
22 23.49
6 23.02
20 22.23
24 21.89
15 24.14
8 23.77
2 23.42
 18 26.1511190671642
16 26.23
3 23.00
10 24.79
5 22.88
11 23.87
19 23.90
1 25.11
23 23.88
4 23.844314504002764
7 24.12
12 23.88090204379987
5 21.99
14 22.86
8 23.12
9 24.09
17 22.51
22 23.49
6 23.02
20 22.23
8 21.89
15 24.14
8 23.77
2 23.42
 18 25.46
16 26.23
3 23.00
10 24.79
5 22.88
11 23.87
19 23.90
1 25.11
23 24.38005748103999
4 24.19242299546192
7 24.126116190100998
12 22.91
13 21.99
14 23.479546478837634
21 23.12
9 24.09
17 23.500621169356034
22 23.49
6 23.02
20 22.23
8 21.89
15 24.14
8 23.77
2 23.42

5 22.88
3 23.00
13 21.99
14 22.86
8 21.89
20 22.23
17 22.51
12 22.91
 5 22.88
3 23.00
13 21.99
12 22.91
8 21.89
20 22.23
17 22.51
6 23.02
 5 22.88
3 23.00
13 21.99
14 22.86
24 21.89
20 22.23
17 22.51
12 22.91
 5 22.88
3 23.00
13 21.99
14 22.86
24 21.89
20 22.23
17 22.51
6 23.02
 5 22.88
3 23.00
13 21.99
14 22.86
8 21.89
20 22.23
26 22.51
12 22.91
 5 22.88
3 23.00
13 21.99
14 22.86
8 21.89
20 22.23
17 22.51
6 23.02
 7 22.88
3 23.00
13 21.99
14 22.86
24 21.89
20 22.23
17 22.51
12 22.91
 5 22.88
3 23.00
13 21.99
8 23.12
24 21.89
20 22.23
17 22.51
6 23.02
 5 22.88
3 23.00
5 21.99
14 22.86
8 21.89
20 22.23
17 22.51
6 23.02
 5 22.88
3 23.00
13 21.99
12 22.91
8 21.89
20 22.23
6 23.02
21 23.12

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>

typedef struct {
	int pNum;
	double pTime;
} Record;

void sort(Record *data, int n)
{
	int i, j;
	Record temp;

	for (i = 0; i < n - 1; i++){
		for (j = 0; j < n - i - 1; j++){
			if (data[j].pTime > data[j + 1].pTime){
				temp = data[j];
				data[j] = data[j + 1];
				data[j + 1] = temp;
			}
		}
	}
}


int main(void)
{
	Record in[3][8];
	Record chance[6];
	int i, j;

	for (i = 0; i < 3;i++){
		for (j = 0; j < 8; j++){
			scanf("%d%lf", &in[i][j].pNum, &in[i][j].pTime);
		}
		sort(in[i], 8);
		printf("%d %.2lf\n%d %.2lf\n", in[i][0].pNum, in[i][0].pTime, in[i][1].pNum, in[i][1].pTime);
		chance[i * 2] = in[i][2];
		chance[i * 2 + 1] = in[i][3];
	}

	sort(chance, 6);

	printf("%d %.2lf\n%d %.2lf\n", chance[0].pNum, chance[0].pTime, chance[1].pNum, chance[1].pTime);
	return (0);
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	sort
	.type	sort, @function
sort:
.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, -40(%rbp)
	movl	%esi, -44(%rbp)
	movl	$0, -24(%rbp)
	jmp	.L2
.L7:
	movl	$0, -20(%rbp)
	jmp	.L3
.L6:
	movl	-20(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	movq	-40(%rbp), %rax
	addq	%rdx, %rax
	movsd	8(%rax), %xmm0
	movl	-20(%rbp), %eax
	cltq
	addq	$1, %rax
	salq	$4, %rax
	movq	%rax, %rdx
	movq	-40(%rbp), %rax
	addq	%rdx, %rax
	movsd	8(%rax), %xmm1
	comisd	%xmm1, %xmm0
	jbe	.L4
	movl	-20(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	movq	-40(%rbp), %rax
	addq	%rdx, %rax
	movq	8(%rax), %rdx
	movq	(%rax), %rax
	movq	%rax, -16(%rbp)
	movq	%rdx, -8(%rbp)
	movl	-20(%rbp), %eax
	cltq
	addq	$1, %rax
	salq	$4, %rax
	movq	%rax, %rdx
	movq	-40(%rbp), %rax
	addq	%rdx, %rax
	movl	-20(%rbp), %edx
	movslq	%edx, %rdx
	movq	%rdx, %rcx
	salq	$4, %rcx
	movq	-40(%rbp), %rdx
	addq	%rdx, %rcx
	movq	8(%rax), %rdx
	movq	(%rax), %rax
	movq	%rax, (%rcx)
	movq	%rdx, 8(%rcx)
	movl	-20(%rbp), %eax
	cltq
	addq	$1, %rax
	salq	$4, %rax
	movq	%rax, %rdx
	movq	-40(%rbp), %rax
	leaq	(%rdx,%rax), %rcx
	movq	-16(%rbp), %rax
	movq	-8(%rbp), %rdx
	movq	%rax, (%rcx)
	movq	%rdx, 8(%rcx)
.L4:
	addl	$1, -20(%rbp)
.L3:
	movl	-44(%rbp), %eax
	subl	-24(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -20(%rbp)
	jl	.L6
	addl	$1, -24(%rbp)
.L2:
	movl	-44(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -24(%rbp)
	jl	.L7
	nop
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	sort, .-sort
	.section	.rodata
.LC0:
	.string	"%d%lf"
.LC1:
	.string	"%d %.2lf\n%d %.2lf\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	$512, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -504(%rbp)
	jmp	.L10
.L13:
	movl	$0, -500(%rbp)
	jmp	.L11
.L12:
	leaq	-400(%rbp), %rdx
	movl	-500(%rbp), %eax
	movslq	%eax, %rcx
	movl	-504(%rbp), %eax
	cltq
	salq	$3, %rax
	addq	%rcx, %rax
	salq	$4, %rax
	addq	%rdx, %rax
	leaq	8(%rax), %rdx
	leaq	-400(%rbp), %rcx
	movl	-500(%rbp), %eax
	movslq	%eax, %rsi
	movl	-504(%rbp), %eax
	cltq
	salq	$3, %rax
	addq	%rsi, %rax
	salq	$4, %rax
	addq	%rcx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -500(%rbp)
.L11:
	cmpl	$7, -500(%rbp)
	jle	.L12
	leaq	-400(%rbp), %rdx
	movl	-504(%rbp), %eax
	cltq
	salq	$7, %rax
	addq	%rdx, %rax
	movl	$8, %esi
	movq	%rax, %rdi
	call	sort
	movl	-504(%rbp), %eax
	cltq
	salq	$7, %rax
	addq	%rbp, %rax
	subq	$376, %rax
	movsd	(%rax), %xmm0
	movl	-504(%rbp), %eax
	cltq
	salq	$7, %rax
	addq	%rbp, %rax
	subq	$384, %rax
	movl	(%rax), %edx
	movl	-504(%rbp), %eax
	cltq
	salq	$7, %rax
	addq	%rbp, %rax
	subq	$392, %rax
	movq	(%rax), %rcx
	movl	-504(%rbp), %eax
	cltq
	salq	$7, %rax
	addq	%rbp, %rax
	subq	$400, %rax
	movl	(%rax), %eax
	movapd	%xmm0, %xmm1
	movq	%rcx, %xmm0
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$2, %eax
	call	printf@PLT
	movl	-504(%rbp), %eax
	addl	%eax, %eax
	cltq
	salq	$4, %rax
	addq	%rbp, %rax
	leaq	-496(%rax), %rcx
	movl	-504(%rbp), %eax
	cltq
	salq	$7, %rax
	addq	%rbp, %rax
	subq	$368, %rax
	movq	8(%rax), %rdx
	movq	(%rax), %rax
	movq	%rax, (%rcx)
	movq	%rdx, 8(%rcx)
	movl	-504(%rbp), %eax
	addl	%eax, %eax
	addl	$1, %eax
	cltq
	salq	$4, %rax
	addq	%rbp, %rax
	leaq	-496(%rax), %rcx
	movl	-504(%rbp), %eax
	cltq
	salq	$7, %rax
	addq	%rbp, %rax
	subq	$352, %rax
	movq	8(%rax), %rdx
	movq	(%rax), %rax
	movq	%rax, (%rcx)
	movq	%rdx, 8(%rcx)
	addl	$1, -504(%rbp)
.L10:
	cmpl	$2, -504(%rbp)
	jle	.L13
	leaq	-496(%rbp), %rax
	movl	$6, %esi
	movq	%rax, %rdi
	call	sort
	movsd	-472(%rbp), %xmm0
	movl	-480(%rbp), %edx
	movq	-488(%rbp), %rcx
	movl	-496(%rbp), %eax
	movapd	%xmm0, %xmm1
	movq	%rcx, %xmm0
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$2, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L15
	call	__stack_chk_fail@PLT
.L15:
	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	sort
	.type	sort, @function
sort:
.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, -40(%rbp)
	movl	%esi, -44(%rbp)
	movl	$0, -24(%rbp)
	jmp	.L2
.L7:
	movl	$0, -20(%rbp)
	jmp	.L3
.L6:
	movl	-20(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	movq	-40(%rbp), %rax
	addq	%rdx, %rax
	movsd	8(%rax), %xmm0
	movl	-20(%rbp), %eax
	cltq
	addq	$1, %rax
	salq	$4, %rax
	movq	%rax, %rdx
	movq	-40(%rbp), %rax
	addq	%rdx, %rax
	movsd	8(%rax), %xmm1
	comisd	%xmm1, %xmm0
	jbe	.L4
	movl	-20(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	movq	-40(%rbp), %rax
	addq	%rdx, %rax
	movq	8(%rax), %rdx
	movq	(%rax), %rax
	movq	%rax, -16(%rbp)
	movq	%rdx, -8(%rbp)
	movl	-20(%rbp), %eax
	cltq
	addq	$1, %rax
	salq	$4, %rax
	movq	%rax, %rdx
	movq	-40(%rbp), %rax
	addq	%rdx, %rax
	movl	-20(%rbp), %edx
	movslq	%edx, %rdx
	movq	%rdx, %rcx
	salq	$4, %rcx
	movq	-40(%rbp), %rdx
	addq	%rdx, %rcx
	movq	8(%rax), %rdx
	movq	(%rax), %rax
	movq	%rax, (%rcx)
	movq	%rdx, 8(%rcx)
	movl	-20(%rbp), %eax
	cltq
	addq	$1, %rax
	salq	$4, %rax
	movq	%rax, %rdx
	movq	-40(%rbp), %rax
	leaq	(%rdx,%rax), %rcx
	movq	-16(%rbp), %rax
	movq	-8(%rbp), %rdx
	movq	%rax, (%rcx)
	movq	%rdx, 8(%rcx)
.L4:
	addl	$1, -20(%rbp)
.L3:
	movl	-44(%rbp), %eax
	subl	-24(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -20(%rbp)
	jl	.L6
	addl	$1, -24(%rbp)
.L2:
	movl	-44(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -24(%rbp)
	jl	.L7
	nop
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	sort, .-sort
	.section	.rodata
.LC0:
	.string	"%d%lf"
.LC1:
	.string	"%d %.2lf\n%d %.2lf\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	$512, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -504(%rbp)
	jmp	.L10
.L13:
	movl	$0, -500(%rbp)
	jmp	.L11
.L12:
	leaq	-400(%rbp), %rdx
	movl	-500(%rbp), %eax
	movslq	%eax, %rcx
	movl	-504(%rbp), %eax
	cltq
	salq	$3, %rax
	addq	%rcx, %rax
	salq	$4, %rax
	addq	%rdx, %rax
	leaq	8(%rax), %rdx
	leaq	-400(%rbp), %rcx
	movl	-500(%rbp), %eax
	movslq	%eax, %rsi
	movl	-504(%rbp), %eax
	cltq
	salq	$3, %rax
	addq	%rsi, %rax
	salq	$4, %rax
	addq	%rcx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -500(%rbp)
.L11:
	cmpl	$7, -500(%rbp)
	jle	.L12
	leaq	-400(%rbp), %rdx
	movl	-504(%rbp), %eax
	cltq
	salq	$7, %rax
	addq	%rdx, %rax
	movl	$8, %esi
	movq	%rax, %rdi
	call	sort
	movl	-504(%rbp), %eax
	cltq
	salq	$7, %rax
	addq	%rbp, %rax
	subq	$376, %rax
	movsd	(%rax), %xmm0
	movl	-504(%rbp), %eax
	cltq
	salq	$7, %rax
	addq	%rbp, %rax
	subq	$384, %rax
	movl	(%rax), %edx
	movl	-504(%rbp), %eax
	cltq
	salq	$7, %rax
	addq	%rbp, %rax
	subq	$392, %rax
	movq	(%rax), %rcx
	movl	-504(%rbp), %eax
	cltq
	salq	$7, %rax
	addq	%rbp, %rax
	subq	$400, %rax
	movl	(%rax), %eax
	movapd	%xmm0, %xmm1
	movq	%rcx, %xmm0
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$2, %eax
	call	printf@PLT
	movl	-504(%rbp), %eax
	addl	%eax, %eax
	cltq
	salq	$4, %rax
	addq	%rbp, %rax
	leaq	-496(%rax), %rcx
	movl	-504(%rbp), %eax
	cltq
	salq	$7, %rax
	addq	%rbp, %rax
	subq	$368, %rax
	movq	8(%rax), %rdx
	movq	(%rax), %rax
	movq	%rax, (%rcx)
	movq	%rdx, 8(%rcx)
	movl	-504(%rbp), %eax
	addl	%eax, %eax
	addl	$1, %eax
	cltq
	salq	$4, %rax
	addq	%rbp, %rax
	leaq	-496(%rax), %rcx
	movl	-504(%rbp), %eax
	cltq
	salq	$7, %rax
	addq	%rbp, %rax
	subq	$352, %rax
	movq	8(%rax), %rdx
	movq	(%rax), %rax
	movq	%rax, (%rcx)
	movq	%rdx, 8(%rcx)
	addl	$1, -504(%rbp)
.L10:
	cmpl	$2, -504(%rbp)
	jle	.L13
	leaq	-496(%rbp), %rax
	movl	$6, %esi
	movq	%rax, %rdi
	call	sort
	movsd	-472(%rbp), %xmm0
	movl	-480(%rbp), %edx
	movq	-488(%rbp), %rcx
	movl	-496(%rbp), %eax
	movapd	%xmm0, %xmm1
	movq	%rcx, %xmm0
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$2, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L15
	call	__stack_chk_fail@PLT
.L15:
	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:
