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>

double dot(double x1, double y1, double x2, double y2){
    return(x1 * x2 + y1 * y2);
}

double scalar2(double x, double y){
    return(x * x + y * y);
}

int main(void){
    double xp1, yp1, xp2, yp2, *xp, *yp;
    int q, i;
    double *x, *y, a;
    
    scanf("%lf %lf %lf %lf", &xp1, &yp1, &xp2, &yp2);
    scanf("%d", &q);
    
    xp = (double *)malloc(sizeof(double) * q);
    yp = (double *)malloc(sizeof(double) * q);
    x = (double *)malloc(sizeof(double) * q);
    y = (double *)malloc(sizeof(double) * q);
    
    for(i = 0; i < q; i ++){
        scanf("%lf %lf", &xp[i], &yp[i]);
    }
    
    for(i = 0; i < q; i ++){
        a = dot(xp2 - xp1, yp2 - yp1, xp1 - xp[i], yp1 - yp[i]) / (scalar2(xp2 - xp1, yp2 - yp1));
        x[i] = xp1 + a * (xp1 - xp2);
        y[i] = yp1 + a * (yp1 - yp2);
        
        printf("%.8f %.8f\n", x[i], y[i]);
    }
    
    free(xp);
    free(yp);
    free(x);
    free(y);
    
    return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	dot
	.type	dot, @function
dot:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movsd	%xmm0, -8(%rbp)
	movsd	%xmm1, -16(%rbp)
	movsd	%xmm2, -24(%rbp)
	movsd	%xmm3, -32(%rbp)
	movsd	-8(%rbp), %xmm0
	movapd	%xmm0, %xmm1
	mulsd	-24(%rbp), %xmm1
	movsd	-16(%rbp), %xmm0
	mulsd	-32(%rbp), %xmm0
	addsd	%xmm1, %xmm0
	movq	%xmm0, %rax
	movq	%rax, %xmm0
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	dot, .-dot
	.globl	scalar2
	.type	scalar2, @function
scalar2:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movsd	%xmm0, -8(%rbp)
	movsd	%xmm1, -16(%rbp)
	movsd	-8(%rbp), %xmm0
	movapd	%xmm0, %xmm1
	mulsd	%xmm0, %xmm1
	movsd	-16(%rbp), %xmm0
	mulsd	%xmm0, %xmm0
	addsd	%xmm1, %xmm0
	movq	%xmm0, %rax
	movq	%rax, %xmm0
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	scalar2, .-scalar2
	.section	.rodata
.LC0:
	.string	"%lf %lf %lf %lf"
.LC1:
	.string	"%d"
.LC2:
	.string	"%lf %lf"
.LC3:
	.string	"%.8f %.8f\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB8:
	.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	$104, %rsp
	.cfi_offset 3, -24
	movq	%fs:40, %rax
	movq	%rax, -24(%rbp)
	xorl	%eax, %eax
	leaq	-72(%rbp), %rsi
	leaq	-80(%rbp), %rcx
	leaq	-88(%rbp), %rdx
	leaq	-96(%rbp), %rax
	movq	%rsi, %r8
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	leaq	-104(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-104(%rbp), %eax
	cltq
	salq	$3, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, -64(%rbp)
	movl	-104(%rbp), %eax
	cltq
	salq	$3, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, -56(%rbp)
	movl	-104(%rbp), %eax
	cltq
	salq	$3, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, -48(%rbp)
	movl	-104(%rbp), %eax
	cltq
	salq	$3, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, -40(%rbp)
	movl	$0, -100(%rbp)
	jmp	.L6
.L7:
	movl	-100(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-56(%rbp), %rax
	addq	%rax, %rdx
	movl	-100(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rcx
	movq	-64(%rbp), %rax
	addq	%rcx, %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -100(%rbp)
.L6:
	movl	-104(%rbp), %eax
	cmpl	%eax, -100(%rbp)
	jl	.L7
	movl	$0, -100(%rbp)
	jmp	.L8
.L9:
	movsd	-88(%rbp), %xmm0
	movl	-100(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-56(%rbp), %rax
	addq	%rdx, %rax
	movsd	(%rax), %xmm1
	movapd	%xmm0, %xmm3
	subsd	%xmm1, %xmm3
	movsd	-96(%rbp), %xmm0
	movl	-100(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-64(%rbp), %rax
	addq	%rdx, %rax
	movsd	(%rax), %xmm1
	movapd	%xmm0, %xmm2
	subsd	%xmm1, %xmm2
	movsd	-72(%rbp), %xmm0
	movsd	-88(%rbp), %xmm1
	movapd	%xmm0, %xmm4
	subsd	%xmm1, %xmm4
	movsd	-80(%rbp), %xmm0
	movsd	-96(%rbp), %xmm1
	subsd	%xmm1, %xmm0
	movq	%xmm0, %rax
	movapd	%xmm4, %xmm1
	movq	%rax, %xmm0
	call	dot
	movq	%xmm0, %rbx
	movsd	-72(%rbp), %xmm0
	movsd	-88(%rbp), %xmm1
	movapd	%xmm0, %xmm2
	subsd	%xmm1, %xmm2
	movsd	-80(%rbp), %xmm0
	movsd	-96(%rbp), %xmm1
	subsd	%xmm1, %xmm0
	movq	%xmm0, %rax
	movapd	%xmm2, %xmm1
	movq	%rax, %xmm0
	call	scalar2
	movapd	%xmm0, %xmm1
	movq	%rbx, %xmm0
	divsd	%xmm1, %xmm0
	movsd	%xmm0, -32(%rbp)
	movsd	-96(%rbp), %xmm0
	movsd	-80(%rbp), %xmm1
	subsd	%xmm1, %xmm0
	movapd	%xmm0, %xmm1
	mulsd	-32(%rbp), %xmm1
	movsd	-96(%rbp), %xmm0
	movl	-100(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-48(%rbp), %rax
	addq	%rdx, %rax
	addsd	%xmm1, %xmm0
	movsd	%xmm0, (%rax)
	movsd	-88(%rbp), %xmm0
	movsd	-72(%rbp), %xmm1
	subsd	%xmm1, %xmm0
	movapd	%xmm0, %xmm1
	mulsd	-32(%rbp), %xmm1
	movsd	-88(%rbp), %xmm0
	movl	-100(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-40(%rbp), %rax
	addq	%rdx, %rax
	addsd	%xmm1, %xmm0
	movsd	%xmm0, (%rax)
	movl	-100(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-40(%rbp), %rax
	addq	%rdx, %rax
	movsd	(%rax), %xmm0
	movl	-100(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-48(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rax
	movapd	%xmm0, %xmm1
	movq	%rax, %xmm0
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$2, %eax
	call	printf@PLT
	addl	$1, -100(%rbp)
.L8:
	movl	-104(%rbp), %eax
	cmpl	%eax, -100(%rbp)
	jl	.L9
	movq	-64(%rbp), %rax
	movq	%rax, %rdi
	call	free@PLT
	movq	-56(%rbp), %rax
	movq	%rax, %rdi
	call	free@PLT
	movq	-48(%rbp), %rax
	movq	%rax, %rdi
	call	free@PLT
	movq	-40(%rbp), %rax
	movq	%rax, %rdi
	call	free@PLT
	movl	$0, %eax
	movq	-24(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L11
	call	__stack_chk_fail@PLT
.L11:
	movq	-8(%rbp), %rbx
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.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	dot
	.type	dot, @function
dot:
.LFB39:
	.cfi_startproc
	endbr64
	mulsd	%xmm2, %xmm0
	mulsd	%xmm3, %xmm1
	addsd	%xmm1, %xmm0
	ret
	.cfi_endproc
.LFE39:
	.size	dot, .-dot
	.p2align 4
	.globl	scalar2
	.type	scalar2, @function
scalar2:
.LFB40:
	.cfi_startproc
	endbr64
	mulsd	%xmm1, %xmm1
	mulsd	%xmm0, %xmm0
	addsd	%xmm1, %xmm0
	ret
	.cfi_endproc
.LFE40:
	.size	scalar2, .-scalar2
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%lf %lf %lf %lf"
.LC1:
	.string	"%d"
.LC2:
	.string	"%lf %lf"
.LC3:
	.string	"%.8f %.8f\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB41:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	.LC0(%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	$72, %rsp
	.cfi_def_cfa_offset 128
	movq	%fs:40, %rax
	movq	%rax, 56(%rsp)
	xorl	%eax, %eax
	leaq	40(%rsp), %rcx
	leaq	32(%rsp), %rdx
	leaq	48(%rsp), %r8
	leaq	24(%rsp), %rsi
	call	__isoc99_scanf@PLT
	leaq	20(%rsp), %rsi
	leaq	.LC1(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movslq	20(%rsp), %r14
	movq	%r14, %rbx
	salq	$3, %r14
	movq	%r14, %rdi
	call	malloc@PLT
	movq	%r14, %rdi
	movq	%rax, %rbp
	call	malloc@PLT
	movq	%r14, %rdi
	movq	%rax, %r12
	call	malloc@PLT
	movq	%r14, %rdi
	movq	%rax, (%rsp)
	call	malloc@PLT
	movq	%rax, 8(%rsp)
	testl	%ebx, %ebx
	jle	.L7
	movq	%rbp, %r14
	movq	%r12, %r13
	leaq	.LC2(%rip), %r15
	xorl	%ebx, %ebx
	.p2align 4,,10
	.p2align 3
.L6:
	movq	%r13, %rdx
	movq	%r14, %rsi
	movq	%r15, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	20(%rsp), %eax
	addl	$1, %ebx
	addq	$8, %r14
	addq	$8, %r13
	cmpl	%ebx, %eax
	jg	.L6
	testl	%eax, %eax
	jle	.L7
	xorl	%r15d, %r15d
	leaq	.LC3(%rip), %rbx
	.p2align 4,,10
	.p2align 3
.L8:
	movsd	48(%rsp), %xmm5
	movsd	40(%rsp), %xmm7
	movq	%rbx, %rsi
	movl	$1, %edi
	movsd	32(%rsp), %xmm3
	movsd	24(%rsp), %xmm4
	movapd	%xmm5, %xmm1
	movapd	%xmm7, %xmm0
	movq	(%rsp), %rax
	subsd	%xmm3, %xmm1
	subsd	%xmm4, %xmm0
	movapd	%xmm4, %xmm2
	movapd	%xmm3, %xmm6
	subsd	0(%rbp,%r15,8), %xmm2
	subsd	(%r12,%r15,8), %xmm6
	mulsd	%xmm0, %xmm2
	mulsd	%xmm1, %xmm6
	mulsd	%xmm0, %xmm0
	mulsd	%xmm1, %xmm1
	addsd	%xmm6, %xmm2
	addsd	%xmm1, %xmm0
	movapd	%xmm3, %xmm1
	subsd	%xmm5, %xmm1
	divsd	%xmm0, %xmm2
	movapd	%xmm4, %xmm0
	subsd	%xmm7, %xmm0
	mulsd	%xmm2, %xmm0
	mulsd	%xmm2, %xmm1
	addsd	%xmm4, %xmm0
	addsd	%xmm3, %xmm1
	movsd	%xmm0, (%rax,%r15,8)
	movq	8(%rsp), %rax
	movsd	%xmm1, (%rax,%r15,8)
	movl	$2, %eax
	addq	$1, %r15
	call	__printf_chk@PLT
	cmpl	%r15d, 20(%rsp)
	jg	.L8
.L7:
	movq	%rbp, %rdi
	call	free@PLT
	movq	%r12, %rdi
	call	free@PLT
	movq	(%rsp), %rdi
	call	free@PLT
	movq	8(%rsp), %rdi
	call	free@PLT
	movq	56(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L14
	addq	$72, %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
.L14:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE41:
	.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	dot
	.type	dot, @function
dot:
.LFB39:
	.cfi_startproc
	endbr64
	mulsd	%xmm2, %xmm0
	mulsd	%xmm3, %xmm1
	addsd	%xmm1, %xmm0
	ret
	.cfi_endproc
.LFE39:
	.size	dot, .-dot
	.p2align 4
	.globl	scalar2
	.type	scalar2, @function
scalar2:
.LFB40:
	.cfi_startproc
	endbr64
	mulsd	%xmm1, %xmm1
	mulsd	%xmm0, %xmm0
	addsd	%xmm1, %xmm0
	ret
	.cfi_endproc
.LFE40:
	.size	scalar2, .-scalar2
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%lf %lf %lf %lf"
.LC1:
	.string	"%d"
.LC2:
	.string	"%lf %lf"
.LC3:
	.string	"%.8f %.8f\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB41:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	.LC0(%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	$72, %rsp
	.cfi_def_cfa_offset 128
	movq	%fs:40, %rax
	movq	%rax, 56(%rsp)
	xorl	%eax, %eax
	leaq	40(%rsp), %rcx
	leaq	32(%rsp), %rdx
	leaq	48(%rsp), %r8
	leaq	24(%rsp), %rsi
	call	__isoc99_scanf@PLT
	leaq	20(%rsp), %rsi
	leaq	.LC1(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movslq	20(%rsp), %r14
	movq	%r14, %rbx
	salq	$3, %r14
	movq	%r14, %rdi
	call	malloc@PLT
	movq	%r14, %rdi
	movq	%rax, %rbp
	call	malloc@PLT
	movq	%r14, %rdi
	movq	%rax, %r12
	call	malloc@PLT
	movq	%r14, %rdi
	movq	%rax, (%rsp)
	call	malloc@PLT
	movq	%rax, 8(%rsp)
	testl	%ebx, %ebx
	jle	.L7
	movq	%rbp, %r14
	movq	%r12, %r13
	leaq	.LC2(%rip), %r15
	xorl	%ebx, %ebx
	.p2align 4,,10
	.p2align 3
.L6:
	movq	%r13, %rdx
	movq	%r14, %rsi
	movq	%r15, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	20(%rsp), %eax
	addl	$1, %ebx
	addq	$8, %r14
	addq	$8, %r13
	cmpl	%ebx, %eax
	jg	.L6
	testl	%eax, %eax
	jle	.L7
	xorl	%r15d, %r15d
	leaq	.LC3(%rip), %rbx
	.p2align 4,,10
	.p2align 3
.L8:
	movsd	48(%rsp), %xmm5
	movsd	40(%rsp), %xmm7
	movq	%rbx, %rsi
	movl	$1, %edi
	movsd	32(%rsp), %xmm3
	movsd	24(%rsp), %xmm4
	movapd	%xmm5, %xmm1
	movapd	%xmm7, %xmm0
	movq	(%rsp), %rax
	subsd	%xmm3, %xmm1
	subsd	%xmm4, %xmm0
	movapd	%xmm4, %xmm2
	movapd	%xmm3, %xmm6
	subsd	0(%rbp,%r15,8), %xmm2
	subsd	(%r12,%r15,8), %xmm6
	mulsd	%xmm0, %xmm2
	mulsd	%xmm1, %xmm6
	mulsd	%xmm0, %xmm0
	mulsd	%xmm1, %xmm1
	addsd	%xmm6, %xmm2
	addsd	%xmm1, %xmm0
	movapd	%xmm3, %xmm1
	subsd	%xmm5, %xmm1
	divsd	%xmm0, %xmm2
	movapd	%xmm4, %xmm0
	subsd	%xmm7, %xmm0
	mulsd	%xmm2, %xmm0
	mulsd	%xmm2, %xmm1
	addsd	%xmm4, %xmm0
	addsd	%xmm3, %xmm1
	movsd	%xmm0, (%rax,%r15,8)
	movq	8(%rsp), %rax
	movsd	%xmm1, (%rax,%r15,8)
	movl	$2, %eax
	addq	$1, %r15
	call	__printf_chk@PLT
	cmpl	%r15d, 20(%rsp)
	jg	.L8
.L7:
	movq	%rbp, %rdi
	call	free@PLT
	movq	%r12, %rdi
	call	free@PLT
	movq	(%rsp), %rdi
	call	free@PLT
	movq	8(%rsp), %rdi
	call	free@PLT
	movq	56(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L14
	addq	$72, %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
.L14:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE41:
	.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>

double dot(double x1, double y1, double x2, double y2){
    return(x1 * x2 + y1 * y2);
}

double scalar2(double x, double y){
    return(x * x + y * y);
}

int main(void){
    double xp1, yp1, xp2, yp2, *xp, *yp;
    int q, i;
    double *x, *y, a;
    
    scanf("%lf %lf %lf %lf", &xp1, &yp1, &xp2, &yp2);
    scanf("%d", &q);
    
    xp = (double *)malloc(sizeof(double) * q);
    yp = (double *)malloc(sizeof(double) * q);
    x = (double *)malloc(sizeof(double) * q);
    y = (double *)malloc(sizeof(double) * q);
    
    for(i = 0; i < q; i ++){
        scanf("%lf %lf", &xp[i], &yp[i]);
    }
    
    for(i = 0; i < q; i ++){
        a = dot(xp2 - xp1, yp2 - yp1, xp1 - xp[i], yp1 - yp[i]) / (scalar2(xp2 - xp1, yp2 - yp1));
        x[i] = xp1 + a * (xp1 - xp2);
        y[i] = yp1 + a * (yp1 - yp2);
        
        printf("%.8f %.8f\n", x[i], y[i]);
    }
    
    free(xp);
    free(yp);
    free(x);
    free(y);
    
    return 0;
}
0 0 1 4
1
2 5
 0 0 2 0
3
-1 1
0 2
1 1
 0 0 1 4
1
2 9
 0 0 1 6
1
2 9
 0 -1 1 6
1
2 9
 0 -1 2 6
1
2 9
 0 -1 2 2
1
2 9
 0 -1 4 2
1
2 9
 0 -2 4 2
1
2 9
 0 0 2 0
3
-1 1
0 1
0 1

1.29411765 5.17647059
 -1.00000000 0.00000000
0.00000000 0.00000000
1.00000000 0.00000000
 2.23529412 8.94117647
 1.51351351 9.08108108
 1.44000000 9.08000000
 2.79245283 8.77358491
 5.23076923 6.84615385
 6.08000000 3.56000000
 6.50000000 4.50000000
 -1.00000000 0.00000000
0.00000000 0.00000000
0.00000000 0.00000000

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>

double dot(double x1, double y1, double x2, double y2){
    return(x1 * x2 + y1 * y2);
}

double scalar2(double x, double y){
    return(x * x + y * y);
}

int main(void){
    double xp1, yp1, xp2, yp2, *xp, *yp;
    int q, i;
    double *x, *y, a;
    
    scanf("%lf %lf %lf %lf", &xp1, &yp1, &xp2, &yp2);
    scanf("%d", &q);
    
    xp = (double *)malloc(sizeof(double) * q);
    yp = (double *)malloc(sizeof(double) * q);
    x = (double *)malloc(sizeof(double) * q);
    y = (double *)malloc(sizeof(double) * q);
    
    for(i = 0; i < q; i ++){
        scanf("%lf %lf", &xp[i], &yp[i]);
    }
    
    for(i = 0; i < q; i ++){
        a = dot(xp2 - xp1, yp2 - yp1, xp1 - xp[i], yp1 - yp[i]) / (scalar2(xp2 - xp1, yp2 - yp1));
        x[i] = xp1 + a * (xp1 - xp2);
        y[i] = yp1 + a * (yp1 - yp2);
        
        printf("%.8f %.8f\n", x[i], y[i]);
    }
    
    free(xp);
    free(yp);
    free(x);
    free(y);
    
    return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	dot
	.type	dot, @function
dot:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movsd	%xmm0, -8(%rbp)
	movsd	%xmm1, -16(%rbp)
	movsd	%xmm2, -24(%rbp)
	movsd	%xmm3, -32(%rbp)
	movsd	-8(%rbp), %xmm0
	movapd	%xmm0, %xmm1
	mulsd	-24(%rbp), %xmm1
	movsd	-16(%rbp), %xmm0
	mulsd	-32(%rbp), %xmm0
	addsd	%xmm1, %xmm0
	movq	%xmm0, %rax
	movq	%rax, %xmm0
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	dot, .-dot
	.globl	scalar2
	.type	scalar2, @function
scalar2:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movsd	%xmm0, -8(%rbp)
	movsd	%xmm1, -16(%rbp)
	movsd	-8(%rbp), %xmm0
	movapd	%xmm0, %xmm1
	mulsd	%xmm0, %xmm1
	movsd	-16(%rbp), %xmm0
	mulsd	%xmm0, %xmm0
	addsd	%xmm1, %xmm0
	movq	%xmm0, %rax
	movq	%rax, %xmm0
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	scalar2, .-scalar2
	.section	.rodata
.LC0:
	.string	"%lf %lf %lf %lf"
.LC1:
	.string	"%d"
.LC2:
	.string	"%lf %lf"
.LC3:
	.string	"%.8f %.8f\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB8:
	.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	$104, %rsp
	.cfi_offset 3, -24
	movq	%fs:40, %rax
	movq	%rax, -24(%rbp)
	xorl	%eax, %eax
	leaq	-72(%rbp), %rsi
	leaq	-80(%rbp), %rcx
	leaq	-88(%rbp), %rdx
	leaq	-96(%rbp), %rax
	movq	%rsi, %r8
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	leaq	-104(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-104(%rbp), %eax
	cltq
	salq	$3, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, -64(%rbp)
	movl	-104(%rbp), %eax
	cltq
	salq	$3, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, -56(%rbp)
	movl	-104(%rbp), %eax
	cltq
	salq	$3, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, -48(%rbp)
	movl	-104(%rbp), %eax
	cltq
	salq	$3, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, -40(%rbp)
	movl	$0, -100(%rbp)
	jmp	.L6
.L7:
	movl	-100(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-56(%rbp), %rax
	addq	%rax, %rdx
	movl	-100(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rcx
	movq	-64(%rbp), %rax
	addq	%rcx, %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -100(%rbp)
.L6:
	movl	-104(%rbp), %eax
	cmpl	%eax, -100(%rbp)
	jl	.L7
	movl	$0, -100(%rbp)
	jmp	.L8
.L9:
	movsd	-88(%rbp), %xmm0
	movl	-100(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-56(%rbp), %rax
	addq	%rdx, %rax
	movsd	(%rax), %xmm1
	movapd	%xmm0, %xmm3
	subsd	%xmm1, %xmm3
	movsd	-96(%rbp), %xmm0
	movl	-100(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-64(%rbp), %rax
	addq	%rdx, %rax
	movsd	(%rax), %xmm1
	movapd	%xmm0, %xmm2
	subsd	%xmm1, %xmm2
	movsd	-72(%rbp), %xmm0
	movsd	-88(%rbp), %xmm1
	movapd	%xmm0, %xmm4
	subsd	%xmm1, %xmm4
	movsd	-80(%rbp), %xmm0
	movsd	-96(%rbp), %xmm1
	subsd	%xmm1, %xmm0
	movq	%xmm0, %rax
	movapd	%xmm4, %xmm1
	movq	%rax, %xmm0
	call	dot
	movq	%xmm0, %rbx
	movsd	-72(%rbp), %xmm0
	movsd	-88(%rbp), %xmm1
	movapd	%xmm0, %xmm2
	subsd	%xmm1, %xmm2
	movsd	-80(%rbp), %xmm0
	movsd	-96(%rbp), %xmm1
	subsd	%xmm1, %xmm0
	movq	%xmm0, %rax
	movapd	%xmm2, %xmm1
	movq	%rax, %xmm0
	call	scalar2
	movapd	%xmm0, %xmm1
	movq	%rbx, %xmm0
	divsd	%xmm1, %xmm0
	movsd	%xmm0, -32(%rbp)
	movsd	-96(%rbp), %xmm0
	movsd	-80(%rbp), %xmm1
	subsd	%xmm1, %xmm0
	movapd	%xmm0, %xmm1
	mulsd	-32(%rbp), %xmm1
	movsd	-96(%rbp), %xmm0
	movl	-100(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-48(%rbp), %rax
	addq	%rdx, %rax
	addsd	%xmm1, %xmm0
	movsd	%xmm0, (%rax)
	movsd	-88(%rbp), %xmm0
	movsd	-72(%rbp), %xmm1
	subsd	%xmm1, %xmm0
	movapd	%xmm0, %xmm1
	mulsd	-32(%rbp), %xmm1
	movsd	-88(%rbp), %xmm0
	movl	-100(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-40(%rbp), %rax
	addq	%rdx, %rax
	addsd	%xmm1, %xmm0
	movsd	%xmm0, (%rax)
	movl	-100(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-40(%rbp), %rax
	addq	%rdx, %rax
	movsd	(%rax), %xmm0
	movl	-100(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-48(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rax
	movapd	%xmm0, %xmm1
	movq	%rax, %xmm0
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$2, %eax
	call	printf@PLT
	addl	$1, -100(%rbp)
.L8:
	movl	-104(%rbp), %eax
	cmpl	%eax, -100(%rbp)
	jl	.L9
	movq	-64(%rbp), %rax
	movq	%rax, %rdi
	call	free@PLT
	movq	-56(%rbp), %rax
	movq	%rax, %rdi
	call	free@PLT
	movq	-48(%rbp), %rax
	movq	%rax, %rdi
	call	free@PLT
	movq	-40(%rbp), %rax
	movq	%rax, %rdi
	call	free@PLT
	movl	$0, %eax
	movq	-24(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L11
	call	__stack_chk_fail@PLT
.L11:
	movq	-8(%rbp), %rbx
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.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	dot
	.type	dot, @function
dot:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movsd	%xmm0, -8(%rbp)
	movsd	%xmm1, -16(%rbp)
	movsd	%xmm2, -24(%rbp)
	movsd	%xmm3, -32(%rbp)
	movsd	-8(%rbp), %xmm0
	movapd	%xmm0, %xmm1
	mulsd	-24(%rbp), %xmm1
	movsd	-16(%rbp), %xmm0
	mulsd	-32(%rbp), %xmm0
	addsd	%xmm1, %xmm0
	movq	%xmm0, %rax
	movq	%rax, %xmm0
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	dot, .-dot
	.globl	scalar2
	.type	scalar2, @function
scalar2:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movsd	%xmm0, -8(%rbp)
	movsd	%xmm1, -16(%rbp)
	movsd	-8(%rbp), %xmm0
	movapd	%xmm0, %xmm1
	mulsd	%xmm0, %xmm1
	movsd	-16(%rbp), %xmm0
	mulsd	%xmm0, %xmm0
	addsd	%xmm1, %xmm0
	movq	%xmm0, %rax
	movq	%rax, %xmm0
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	scalar2, .-scalar2
	.section	.rodata
.LC0:
	.string	"%lf %lf %lf %lf"
.LC1:
	.string	"%d"
.LC2:
	.string	"%lf %lf"
.LC3:
	.string	"%.8f %.8f\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB8:
	.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	$104, %rsp
	.cfi_offset 3, -24
	movq	%fs:40, %rax
	movq	%rax, -24(%rbp)
	xorl	%eax, %eax
	leaq	-72(%rbp), %rsi
	leaq	-80(%rbp), %rcx
	leaq	-88(%rbp), %rdx
	leaq	-96(%rbp), %rax
	movq	%rsi, %r8
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	leaq	-104(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-104(%rbp), %eax
	cltq
	salq	$3, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, -64(%rbp)
	movl	-104(%rbp), %eax
	cltq
	salq	$3, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, -56(%rbp)
	movl	-104(%rbp), %eax
	cltq
	salq	$3, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, -48(%rbp)
	movl	-104(%rbp), %eax
	cltq
	salq	$3, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, -40(%rbp)
	movl	$0, -100(%rbp)
	jmp	.L6
.L7:
	movl	-100(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-56(%rbp), %rax
	addq	%rax, %rdx
	movl	-100(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rcx
	movq	-64(%rbp), %rax
	addq	%rcx, %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -100(%rbp)
.L6:
	movl	-104(%rbp), %eax
	cmpl	%eax, -100(%rbp)
	jl	.L7
	movl	$0, -100(%rbp)
	jmp	.L8
.L9:
	movsd	-88(%rbp), %xmm0
	movl	-100(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-56(%rbp), %rax
	addq	%rdx, %rax
	movsd	(%rax), %xmm1
	movapd	%xmm0, %xmm3
	subsd	%xmm1, %xmm3
	movsd	-96(%rbp), %xmm0
	movl	-100(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-64(%rbp), %rax
	addq	%rdx, %rax
	movsd	(%rax), %xmm1
	movapd	%xmm0, %xmm2
	subsd	%xmm1, %xmm2
	movsd	-72(%rbp), %xmm0
	movsd	-88(%rbp), %xmm1
	movapd	%xmm0, %xmm4
	subsd	%xmm1, %xmm4
	movsd	-80(%rbp), %xmm0
	movsd	-96(%rbp), %xmm1
	subsd	%xmm1, %xmm0
	movq	%xmm0, %rax
	movapd	%xmm4, %xmm1
	movq	%rax, %xmm0
	call	dot
	movq	%xmm0, %rbx
	movsd	-72(%rbp), %xmm0
	movsd	-88(%rbp), %xmm1
	movapd	%xmm0, %xmm2
	subsd	%xmm1, %xmm2
	movsd	-80(%rbp), %xmm0
	movsd	-96(%rbp), %xmm1
	subsd	%xmm1, %xmm0
	movq	%xmm0, %rax
	movapd	%xmm2, %xmm1
	movq	%rax, %xmm0
	call	scalar2
	movapd	%xmm0, %xmm1
	movq	%rbx, %xmm0
	divsd	%xmm1, %xmm0
	movsd	%xmm0, -32(%rbp)
	movsd	-96(%rbp), %xmm0
	movsd	-80(%rbp), %xmm1
	subsd	%xmm1, %xmm0
	movapd	%xmm0, %xmm1
	mulsd	-32(%rbp), %xmm1
	movsd	-96(%rbp), %xmm0
	movl	-100(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-48(%rbp), %rax
	addq	%rdx, %rax
	addsd	%xmm1, %xmm0
	movsd	%xmm0, (%rax)
	movsd	-88(%rbp), %xmm0
	movsd	-72(%rbp), %xmm1
	subsd	%xmm1, %xmm0
	movapd	%xmm0, %xmm1
	mulsd	-32(%rbp), %xmm1
	movsd	-88(%rbp), %xmm0
	movl	-100(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-40(%rbp), %rax
	addq	%rdx, %rax
	addsd	%xmm1, %xmm0
	movsd	%xmm0, (%rax)
	movl	-100(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-40(%rbp), %rax
	addq	%rdx, %rax
	movsd	(%rax), %xmm0
	movl	-100(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-48(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rax
	movapd	%xmm0, %xmm1
	movq	%rax, %xmm0
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$2, %eax
	call	printf@PLT
	addl	$1, -100(%rbp)
.L8:
	movl	-104(%rbp), %eax
	cmpl	%eax, -100(%rbp)
	jl	.L9
	movq	-64(%rbp), %rax
	movq	%rax, %rdi
	call	free@PLT
	movq	-56(%rbp), %rax
	movq	%rax, %rdi
	call	free@PLT
	movq	-48(%rbp), %rax
	movq	%rax, %rdi
	call	free@PLT
	movq	-40(%rbp), %rax
	movq	%rax, %rdi
	call	free@PLT
	movl	$0, %eax
	movq	-24(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L11
	call	__stack_chk_fail@PLT
.L11:
	movq	-8(%rbp), %rbx
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.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:
