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>

int main(void)
{
	int a,f,i;
	double b[110],c=101,d,e,x=0;
	scanf("%d",&a);
	for(i=0;i<a;i++){
		scanf("%lf",&b[i]);
		x=x+b[i];
	}
	e=x/a;
	for(i=0;i<a;i++){
		if(e-b[i]<0){
			d=b[i]-e;
		}else{
			d=e-b[i];
		}
		if(c>d){
			f=i;
			c=d;
		}
	}
	printf("%d",f);
	return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC2:
	.string	"%d"
.LC3:
	.string	"%lf"
	.text
	.globl	main
	.type	main, @function
main:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$944, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movsd	.LC0(%rip), %xmm0
	movsd	%xmm0, -928(%rbp)
	pxor	%xmm0, %xmm0
	movsd	%xmm0, -912(%rbp)
	leaq	-940(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -932(%rbp)
	jmp	.L2
.L3:
	leaq	-896(%rbp), %rdx
	movl	-932(%rbp), %eax
	cltq
	salq	$3, %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-932(%rbp), %eax
	cltq
	movsd	-896(%rbp,%rax,8), %xmm0
	movsd	-912(%rbp), %xmm1
	addsd	%xmm1, %xmm0
	movsd	%xmm0, -912(%rbp)
	addl	$1, -932(%rbp)
.L2:
	movl	-940(%rbp), %eax
	cmpl	%eax, -932(%rbp)
	jl	.L3
	movl	-940(%rbp), %eax
	pxor	%xmm1, %xmm1
	cvtsi2sdl	%eax, %xmm1
	movsd	-912(%rbp), %xmm0
	divsd	%xmm1, %xmm0
	movsd	%xmm0, -904(%rbp)
	movl	$0, -932(%rbp)
	jmp	.L4
.L10:
	movl	-932(%rbp), %eax
	cltq
	movsd	-896(%rbp,%rax,8), %xmm2
	movsd	-904(%rbp), %xmm0
	movapd	%xmm0, %xmm1
	subsd	%xmm2, %xmm1
	pxor	%xmm0, %xmm0
	comisd	%xmm1, %xmm0
	jbe	.L15
	movl	-932(%rbp), %eax
	cltq
	movsd	-896(%rbp,%rax,8), %xmm0
	subsd	-904(%rbp), %xmm0
	movsd	%xmm0, -920(%rbp)
	jmp	.L7
.L15:
	movl	-932(%rbp), %eax
	cltq
	movsd	-896(%rbp,%rax,8), %xmm1
	movsd	-904(%rbp), %xmm0
	subsd	%xmm1, %xmm0
	movsd	%xmm0, -920(%rbp)
.L7:
	movsd	-928(%rbp), %xmm0
	comisd	-920(%rbp), %xmm0
	jbe	.L8
	movl	-932(%rbp), %eax
	movl	%eax, -936(%rbp)
	movsd	-920(%rbp), %xmm0
	movsd	%xmm0, -928(%rbp)
.L8:
	addl	$1, -932(%rbp)
.L4:
	movl	-940(%rbp), %eax
	cmpl	%eax, -932(%rbp)
	jl	.L10
	movl	-936(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L12
	call	__stack_chk_fail@PLT
.L12:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.section	.rodata
	.align 8
.LC0:
	.long	0
	.long	1079590912
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:
```

Only output the optimized assembly code. Do not include any other text. Do not write any comments in the assembly code. Wrap the assembly code in ```assembly``` tags.
user
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC2:
	.string	"%d"
.LC3:
	.string	"%lf"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	leaq	.LC2(%rip), %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movq	%r13, %rdi
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$936, %rsp
	.cfi_def_cfa_offset 992
	movq	%fs:40, %rax
	movq	%rax, 920(%rsp)
	xorl	%eax, %eax
	leaq	28(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movl	28(%rsp), %eax
	testl	%eax, %eax
	jle	.L9
	leaq	32(%rsp), %rbp
	pxor	%xmm1, %xmm1
	xorl	%r15d, %r15d
	movq	%rbp, %rbx
	leaq	.LC3(%rip), %r14
	.p2align 4,,10
	.p2align 3
.L3:
	movq	%rbx, %rsi
	movq	%r14, %rdi
	xorl	%eax, %eax
	movsd	%xmm1, 8(%rsp)
	call	__isoc99_scanf@PLT
	movl	28(%rsp), %eax
	addl	$1, %r15d
	movsd	8(%rsp), %xmm1
	addq	$8, %rbx
	addsd	-8(%rbx), %xmm1
	cmpl	%r15d, %eax
	jg	.L3
	pxor	%xmm2, %xmm2
	cvtsi2sdl	%eax, %xmm2
	divsd	%xmm2, %xmm1
	testl	%eax, %eax
	jle	.L9
	movsd	.LC1(%rip), %xmm2
	movslq	%eax, %rdx
	xorl	%eax, %eax
	.p2align 4,,10
	.p2align 3
.L8:
	movsd	0(%rbp,%rax,8), %xmm3
	movapd	%xmm1, %xmm0
	pxor	%xmm4, %xmm4
	movl	%eax, %ecx
	subsd	%xmm3, %xmm0
	comisd	%xmm0, %xmm4
	jbe	.L4
	subsd	%xmm1, %xmm3
	movapd	%xmm3, %xmm0
.L4:
	comisd	%xmm0, %xmm2
	minsd	%xmm2, %xmm0
	cmova	%ecx, %r12d
	addq	$1, %rax
	movapd	%xmm0, %xmm2
	cmpq	%rax, %rdx
	jne	.L8
.L9:
	xorl	%eax, %eax
	movl	%r12d, %edx
	movq	%r13, %rsi
	movl	$1, %edi
	call	__printf_chk@PLT
	movq	920(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L17
	addq	$936, %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
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC1:
	.long	0
	.long	1079590912
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:

rule
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC2:
	.string	"%d"
.LC3:
	.string	"%lf"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	leaq	.LC2(%rip), %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movq	%r13, %rdi
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$936, %rsp
	.cfi_def_cfa_offset 992
	movq	%fs:40, %rax
	movq	%rax, 920(%rsp)
	xorl	%eax, %eax
	leaq	28(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movl	28(%rsp), %eax
	testl	%eax, %eax
	jle	.L9
	leaq	32(%rsp), %rbp
	pxor	%xmm1, %xmm1
	xorl	%r15d, %r15d
	movq	%rbp, %rbx
	leaq	.LC3(%rip), %r14
	.p2align 4,,10
	.p2align 3
.L3:
	movq	%rbx, %rsi
	movq	%r14, %rdi
	xorl	%eax, %eax
	movsd	%xmm1, 8(%rsp)
	call	__isoc99_scanf@PLT
	movl	28(%rsp), %eax
	addl	$1, %r15d
	movsd	8(%rsp), %xmm1
	addq	$8, %rbx
	addsd	-8(%rbx), %xmm1
	cmpl	%r15d, %eax
	jg	.L3
	pxor	%xmm2, %xmm2
	cvtsi2sdl	%eax, %xmm2
	divsd	%xmm2, %xmm1
	testl	%eax, %eax
	jle	.L9
	movsd	.LC1(%rip), %xmm2
	movslq	%eax, %rdx
	xorl	%eax, %eax
	.p2align 4,,10
	.p2align 3
.L8:
	movsd	0(%rbp,%rax,8), %xmm3
	movapd	%xmm1, %xmm0
	pxor	%xmm4, %xmm4
	movl	%eax, %ecx
	subsd	%xmm3, %xmm0
	comisd	%xmm0, %xmm4
	jbe	.L4
	subsd	%xmm1, %xmm3
	movapd	%xmm3, %xmm0
.L4:
	comisd	%xmm0, %xmm2
	minsd	%xmm2, %xmm0
	cmova	%ecx, %r12d
	addq	$1, %rax
	movapd	%xmm0, %xmm2
	cmpq	%rax, %rdx
	jne	.L8
.L9:
	xorl	%eax, %eax
	movl	%r12d, %edx
	movq	%r13, %rsi
	movl	$1, %edi
	call	__printf_chk@PLT
	movq	920(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L17
	addq	$936, %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
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC1:
	.long	0
	.long	1079590912
	.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>

int main(void)
{
	int a,f,i;
	double b[110],c=101,d,e,x=0;
	scanf("%d",&a);
	for(i=0;i<a;i++){
		scanf("%lf",&b[i]);
		x=x+b[i];
	}
	e=x/a;
	for(i=0;i<a;i++){
		if(e-b[i]<0){
			d=b[i]-e;
		}else{
			d=e-b[i];
		}
		if(c>d){
			f=i;
			c=d;
		}
	}
	printf("%d",f);
	return 0;
}
3
0 2 3
 4
2 5 3 5
 3
0 0 3
 4
3 9 3 5
 4
3 5 3 5
 3
0 0 1
 4
5 9 3 5
 4
5 14 3 5
 4
5 14 6 5
 4
0 14 6 5

1 2 0 3 0 0 0 0 2 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>

int main(void)
{
	int a,f,i;
	double b[110],c=101,d,e,x=0;
	scanf("%d",&a);
	for(i=0;i<a;i++){
		scanf("%lf",&b[i]);
		x=x+b[i];
	}
	e=x/a;
	for(i=0;i<a;i++){
		if(e-b[i]<0){
			d=b[i]-e;
		}else{
			d=e-b[i];
		}
		if(c>d){
			f=i;
			c=d;
		}
	}
	printf("%d",f);
	return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC2:
	.string	"%d"
.LC3:
	.string	"%lf"
	.text
	.globl	main
	.type	main, @function
main:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$944, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movsd	.LC0(%rip), %xmm0
	movsd	%xmm0, -928(%rbp)
	pxor	%xmm0, %xmm0
	movsd	%xmm0, -912(%rbp)
	leaq	-940(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -932(%rbp)
	jmp	.L2
.L3:
	leaq	-896(%rbp), %rdx
	movl	-932(%rbp), %eax
	cltq
	salq	$3, %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-932(%rbp), %eax
	cltq
	movsd	-896(%rbp,%rax,8), %xmm0
	movsd	-912(%rbp), %xmm1
	addsd	%xmm1, %xmm0
	movsd	%xmm0, -912(%rbp)
	addl	$1, -932(%rbp)
.L2:
	movl	-940(%rbp), %eax
	cmpl	%eax, -932(%rbp)
	jl	.L3
	movl	-940(%rbp), %eax
	pxor	%xmm1, %xmm1
	cvtsi2sdl	%eax, %xmm1
	movsd	-912(%rbp), %xmm0
	divsd	%xmm1, %xmm0
	movsd	%xmm0, -904(%rbp)
	movl	$0, -932(%rbp)
	jmp	.L4
.L10:
	movl	-932(%rbp), %eax
	cltq
	movsd	-896(%rbp,%rax,8), %xmm2
	movsd	-904(%rbp), %xmm0
	movapd	%xmm0, %xmm1
	subsd	%xmm2, %xmm1
	pxor	%xmm0, %xmm0
	comisd	%xmm1, %xmm0
	jbe	.L15
	movl	-932(%rbp), %eax
	cltq
	movsd	-896(%rbp,%rax,8), %xmm0
	subsd	-904(%rbp), %xmm0
	movsd	%xmm0, -920(%rbp)
	jmp	.L7
.L15:
	movl	-932(%rbp), %eax
	cltq
	movsd	-896(%rbp,%rax,8), %xmm1
	movsd	-904(%rbp), %xmm0
	subsd	%xmm1, %xmm0
	movsd	%xmm0, -920(%rbp)
.L7:
	movsd	-928(%rbp), %xmm0
	comisd	-920(%rbp), %xmm0
	jbe	.L8
	movl	-932(%rbp), %eax
	movl	%eax, -936(%rbp)
	movsd	-920(%rbp), %xmm0
	movsd	%xmm0, -928(%rbp)
.L8:
	addl	$1, -932(%rbp)
.L4:
	movl	-940(%rbp), %eax
	cmpl	%eax, -932(%rbp)
	jl	.L10
	movl	-936(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L12
	call	__stack_chk_fail@PLT
.L12:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.section	.rodata
	.align 8
.LC0:
	.long	0
	.long	1079590912
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:
```

Only output the optimized assembly code. Do not include any other text. Do not write any comments in the assembly code. Wrap the assembly code in ```assembly``` tags.
train
	.file	"temp.c"
	.text
	.section	.rodata
.LC2:
	.string	"%d"
.LC3:
	.string	"%lf"
	.text
	.globl	main
	.type	main, @function
main:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$944, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movsd	.LC0(%rip), %xmm0
	movsd	%xmm0, -928(%rbp)
	pxor	%xmm0, %xmm0
	movsd	%xmm0, -912(%rbp)
	leaq	-940(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -932(%rbp)
	jmp	.L2
.L3:
	leaq	-896(%rbp), %rdx
	movl	-932(%rbp), %eax
	cltq
	salq	$3, %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-932(%rbp), %eax
	cltq
	movsd	-896(%rbp,%rax,8), %xmm0
	movsd	-912(%rbp), %xmm1
	addsd	%xmm1, %xmm0
	movsd	%xmm0, -912(%rbp)
	addl	$1, -932(%rbp)
.L2:
	movl	-940(%rbp), %eax
	cmpl	%eax, -932(%rbp)
	jl	.L3
	movl	-940(%rbp), %eax
	pxor	%xmm1, %xmm1
	cvtsi2sdl	%eax, %xmm1
	movsd	-912(%rbp), %xmm0
	divsd	%xmm1, %xmm0
	movsd	%xmm0, -904(%rbp)
	movl	$0, -932(%rbp)
	jmp	.L4
.L10:
	movl	-932(%rbp), %eax
	cltq
	movsd	-896(%rbp,%rax,8), %xmm2
	movsd	-904(%rbp), %xmm0
	movapd	%xmm0, %xmm1
	subsd	%xmm2, %xmm1
	pxor	%xmm0, %xmm0
	comisd	%xmm1, %xmm0
	jbe	.L15
	movl	-932(%rbp), %eax
	cltq
	movsd	-896(%rbp,%rax,8), %xmm0
	subsd	-904(%rbp), %xmm0
	movsd	%xmm0, -920(%rbp)
	jmp	.L7
.L15:
	movl	-932(%rbp), %eax
	cltq
	movsd	-896(%rbp,%rax,8), %xmm1
	movsd	-904(%rbp), %xmm0
	subsd	%xmm1, %xmm0
	movsd	%xmm0, -920(%rbp)
.L7:
	movsd	-928(%rbp), %xmm0
	comisd	-920(%rbp), %xmm0
	jbe	.L8
	movl	-932(%rbp), %eax
	movl	%eax, -936(%rbp)
	movsd	-920(%rbp), %xmm0
	movsd	%xmm0, -928(%rbp)
.L8:
	addl	$1, -932(%rbp)
.L4:
	movl	-940(%rbp), %eax
	cmpl	%eax, -932(%rbp)
	jl	.L10
	movl	-936(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L12
	call	__stack_chk_fail@PLT
.L12:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.section	.rodata
	.align 8
.LC0:
	.long	0
	.long	1079590912
	.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:
