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>

#define absmin(a,b) (((a) > 0) && 
int main(void) {
    int N;
    int a[100];
    int i,cnt;
    char str[512];
    char *p;

    int rd=0,ru=0,minus=0 ;
    int rdchk=0,ruchk=0,minux=0;
    
    fgets(str, 512, stdin);
    N = atoi(str);
    fgets(str, 512, stdin);
    p = str;
    for(i=0,cnt=0;i<512;i++){
        if(str[i] == ' '){
            str[i] = '\0';
            a[cnt++] = atoi(p);
            p = &str[i+1];
        }
    }
    a[cnt] = atoi(p);

    for(cnt=0;cnt<N;cnt++){
        rd +=a[cnt];
    }

    rd = rd / N;
    ru = rd + 1;
    minus = rd - 1;

    for(cnt=0;cnt<N;cnt++){
        rdchk += (a[cnt] - rd) * (a[cnt] - rd);
        ruchk += (a[cnt] - ru) * (a[cnt] - ru);
        minux += (a[cnt] - minus) * (a[cnt]-minus);
    }
    
    if(rdchk > ruchk) {
        if(ruchk > minux) {
        printf("%d\n", minux);
        } else {
        printf("%d\n", ruchk);
        }
    } else {
        if(rdchk > minux) {
        printf("%d\n", minux);
        } else {
        printf("%d\n", rdchk);
        }
    }

    return 0;
    
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB6:
	.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	$984, %rsp
	.cfi_offset 3, -24
	movq	%fs:40, %rax
	movq	%rax, -24(%rbp)
	xorl	%eax, %eax
	movl	$0, -980(%rbp)
	movl	$0, -964(%rbp)
	movl	$0, -960(%rbp)
	movl	$0, -976(%rbp)
	movl	$0, -972(%rbp)
	movl	$0, -968(%rbp)
	movq	stdin(%rip), %rdx
	leaq	-544(%rbp), %rax
	movl	$512, %esi
	movq	%rax, %rdi
	call	fgets@PLT
	leaq	-544(%rbp), %rax
	movq	%rax, %rdi
	call	atoi@PLT
	movl	%eax, -956(%rbp)
	movq	stdin(%rip), %rdx
	leaq	-544(%rbp), %rax
	movl	$512, %esi
	movq	%rax, %rdi
	call	fgets@PLT
	leaq	-544(%rbp), %rax
	movq	%rax, -952(%rbp)
	movl	$0, -988(%rbp)
	movl	$0, -984(%rbp)
	jmp	.L2
.L4:
	movl	-988(%rbp), %eax
	cltq
	movzbl	-544(%rbp,%rax), %eax
	cmpb	$32, %al
	jne	.L3
	movl	-988(%rbp), %eax
	cltq
	movb	$0, -544(%rbp,%rax)
	movl	-984(%rbp), %ebx
	leal	1(%rbx), %eax
	movl	%eax, -984(%rbp)
	movq	-952(%rbp), %rax
	movq	%rax, %rdi
	call	atoi@PLT
	movslq	%ebx, %rdx
	movl	%eax, -944(%rbp,%rdx,4)
	movl	-988(%rbp), %eax
	addl	$1, %eax
	leaq	-544(%rbp), %rdx
	cltq
	addq	%rdx, %rax
	movq	%rax, -952(%rbp)
.L3:
	addl	$1, -988(%rbp)
.L2:
	cmpl	$511, -988(%rbp)
	jle	.L4
	movq	-952(%rbp), %rax
	movq	%rax, %rdi
	call	atoi@PLT
	movl	-984(%rbp), %edx
	movslq	%edx, %rdx
	movl	%eax, -944(%rbp,%rdx,4)
	movl	$0, -984(%rbp)
	jmp	.L5
.L6:
	movl	-984(%rbp), %eax
	cltq
	movl	-944(%rbp,%rax,4), %eax
	addl	%eax, -980(%rbp)
	addl	$1, -984(%rbp)
.L5:
	movl	-984(%rbp), %eax
	cmpl	-956(%rbp), %eax
	jl	.L6
	movl	-980(%rbp), %eax
	cltd
	idivl	-956(%rbp)
	movl	%eax, -980(%rbp)
	movl	-980(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -964(%rbp)
	movl	-980(%rbp), %eax
	subl	$1, %eax
	movl	%eax, -960(%rbp)
	movl	$0, -984(%rbp)
	jmp	.L7
.L8:
	movl	-984(%rbp), %eax
	cltq
	movl	-944(%rbp,%rax,4), %eax
	subl	-980(%rbp), %eax
	movl	%eax, %edx
	movl	-984(%rbp), %eax
	cltq
	movl	-944(%rbp,%rax,4), %eax
	subl	-980(%rbp), %eax
	imull	%edx, %eax
	addl	%eax, -976(%rbp)
	movl	-984(%rbp), %eax
	cltq
	movl	-944(%rbp,%rax,4), %eax
	subl	-964(%rbp), %eax
	movl	%eax, %edx
	movl	-984(%rbp), %eax
	cltq
	movl	-944(%rbp,%rax,4), %eax
	subl	-964(%rbp), %eax
	imull	%edx, %eax
	addl	%eax, -972(%rbp)
	movl	-984(%rbp), %eax
	cltq
	movl	-944(%rbp,%rax,4), %eax
	subl	-960(%rbp), %eax
	movl	%eax, %edx
	movl	-984(%rbp), %eax
	cltq
	movl	-944(%rbp,%rax,4), %eax
	subl	-960(%rbp), %eax
	imull	%edx, %eax
	addl	%eax, -968(%rbp)
	addl	$1, -984(%rbp)
.L7:
	movl	-984(%rbp), %eax
	cmpl	-956(%rbp), %eax
	jl	.L8
	movl	-976(%rbp), %eax
	cmpl	-972(%rbp), %eax
	jle	.L9
	movl	-972(%rbp), %eax
	cmpl	-968(%rbp), %eax
	jle	.L10
	movl	-968(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L11
.L10:
	movl	-972(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L11
.L9:
	movl	-976(%rbp), %eax
	cmpl	-968(%rbp), %eax
	jle	.L12
	movl	-968(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L11
.L12:
	movl	-976(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L11:
	movl	$0, %eax
	movq	-24(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L14
	call	__stack_chk_fail@PLT
.L14:
	movq	-8(%rbp), %rbx
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.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
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB39:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movl	$512, %esi
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$936, %rsp
	.cfi_def_cfa_offset 992
	movq	stdin(%rip), %rdx
	leaq	400(%rsp), %rbp
	leaq	401(%rsp), %rbx
	movq	%fs:40, %rax
	movq	%rax, 920(%rsp)
	xorl	%eax, %eax
	movq	%rbp, %rdi
	leaq	913(%rsp), %r15
	call	fgets@PLT
	movq	%rbp, %rdi
	movl	$10, %edx
	xorl	%esi, %esi
	call	strtol@PLT
	movq	stdin(%rip), %rdx
	movq	%rbp, %rdi
	movl	$512, %esi
	movq	%rax, %r12
	movl	%eax, %r13d
	call	fgets@PLT
	movq	%rbp, %rdi
	xorl	%ebp, %ebp
	jmp	.L3
	.p2align 4,,10
	.p2align 3
.L2:
	addq	$1, %rbx
	cmpq	%r15, %rbx
	je	.L28
.L3:
	cmpb	$32, -1(%rbx)
	jne	.L2
	movl	$10, %edx
	xorl	%esi, %esi
	movb	$0, -1(%rbx)
	leal	1(%rbp), %r14d
	call	strtol@PLT
	movq	%rbx, %rdi
	addq	$1, %rbx
	movl	%eax, (%rsp,%rbp,4)
	movslq	%r14d, %rbp
	cmpq	%r15, %rbx
	jne	.L3
.L28:
	movl	$10, %edx
	xorl	%esi, %esi
	call	strtol@PLT
	movl	%eax, (%rsp,%rbp,4)
	testl	%r12d, %r12d
	jle	.L16
	leal	-1(%r12), %ecx
	cmpl	$2, %ecx
	jbe	.L17
	movl	%r12d, %edx
	movq	%rsp, %rax
	pxor	%xmm0, %xmm0
	shrl	$2, %edx
	subl	$1, %edx
	salq	$4, %rdx
	leaq	16(%rsp,%rdx), %rdx
	.p2align 4,,10
	.p2align 3
.L6:
	paddd	(%rax), %xmm0
	addq	$16, %rax
	cmpq	%rdx, %rax
	jne	.L6
	movdqa	%xmm0, %xmm1
	movl	%r12d, %edx
	psrldq	$8, %xmm1
	andl	$-4, %edx
	paddd	%xmm1, %xmm0
	movdqa	%xmm0, %xmm1
	psrldq	$4, %xmm1
	paddd	%xmm1, %xmm0
	movd	%xmm0, %eax
	testb	$3, %r12b
	je	.L7
.L5:
	movslq	%edx, %rsi
	addl	(%rsp,%rsi,4), %eax
	leal	1(%rdx), %esi
	cmpl	%esi, %r12d
	jle	.L7
	movslq	%esi, %rsi
	addl	$2, %edx
	addl	(%rsp,%rsi,4), %eax
	cmpl	%edx, %r12d
	jle	.L7
	movslq	%edx, %rdx
	addl	(%rsp,%rdx,4), %eax
.L7:
	cltd
	idivl	%r13d
	leal	1(%rax), %r10d
	leal	-1(%rax), %edi
	cmpl	$3, %ecx
	jbe	.L18
	movl	%r12d, %ecx
	movd	%eax, %xmm5
	movd	%edi, %xmm2
	movq	%rsp, %rdx
	shrl	$2, %ecx
	pxor	%xmm4, %xmm4
	movd	%r10d, %xmm6
	subl	$1, %ecx
	pshufd	$0, %xmm5, %xmm7
	pshufd	$0, %xmm6, %xmm6
	salq	$4, %rcx
	pshufd	$0, %xmm2, %xmm5
	movdqa	%xmm4, %xmm3
	leaq	16(%rsp,%rcx), %rcx
	movdqa	%xmm4, %xmm2
	.p2align 4,,10
	.p2align 3
.L9:
	movdqa	(%rdx), %xmm0
	addq	$16, %rdx
	movdqa	%xmm0, %xmm1
	psubd	%xmm7, %xmm1
	movdqa	%xmm1, %xmm8
	pmuludq	%xmm1, %xmm8
	psrlq	$32, %xmm1
	pmuludq	%xmm1, %xmm1
	pshufd	$8, %xmm8, %xmm8
	pshufd	$8, %xmm1, %xmm1
	punpckldq	%xmm1, %xmm8
	movdqa	%xmm0, %xmm1
	psubd	%xmm5, %xmm0
	psubd	%xmm6, %xmm1
	paddd	%xmm8, %xmm2
	movdqa	%xmm1, %xmm8
	pmuludq	%xmm1, %xmm8
	psrlq	$32, %xmm1
	pmuludq	%xmm1, %xmm1
	pshufd	$8, %xmm8, %xmm8
	pshufd	$8, %xmm1, %xmm1
	punpckldq	%xmm1, %xmm8
	movdqa	%xmm0, %xmm1
	pmuludq	%xmm0, %xmm1
	psrlq	$32, %xmm0
	paddd	%xmm8, %xmm3
	pmuludq	%xmm0, %xmm0
	pshufd	$8, %xmm1, %xmm1
	pshufd	$8, %xmm0, %xmm0
	punpckldq	%xmm0, %xmm1
	paddd	%xmm1, %xmm4
	cmpq	%rdx, %rcx
	jne	.L9
	movdqa	%xmm4, %xmm0
	movl	%r12d, %ecx
	psrldq	$8, %xmm0
	andl	$-4, %ecx
	paddd	%xmm4, %xmm0
	movdqa	%xmm0, %xmm1
	psrldq	$4, %xmm1
	paddd	%xmm1, %xmm0
	movd	%xmm0, %r9d
	movdqa	%xmm3, %xmm0
	psrldq	$8, %xmm0
	paddd	%xmm3, %xmm0
	movdqa	%xmm0, %xmm1
	psrldq	$4, %xmm1
	paddd	%xmm1, %xmm0
	movd	%xmm0, %edx
	movdqa	%xmm2, %xmm0
	psrldq	$8, %xmm0
	paddd	%xmm2, %xmm0
	movdqa	%xmm0, %xmm1
	psrldq	$4, %xmm1
	paddd	%xmm1, %xmm0
	movd	%xmm0, %r8d
	testb	$3, %r12b
	je	.L8
.L14:
	movslq	%ecx, %rsi
	movl	(%rsp,%rsi,4), %esi
	movl	%esi, %r11d
	subl	%eax, %r11d
	imull	%r11d, %r11d
	addl	%r11d, %r8d
	movl	%esi, %r11d
	subl	%edi, %esi
	imull	%esi, %esi
	subl	%r10d, %r11d
	imull	%r11d, %r11d
	addl	%esi, %r9d
	leal	1(%rcx), %esi
	addl	%r11d, %edx
	cmpl	%r12d, %esi
	jge	.L8
	movslq	%esi, %rsi
	movl	(%rsp,%rsi,4), %esi
	movl	%esi, %r11d
	subl	%eax, %r11d
	imull	%r11d, %r11d
	addl	%r11d, %r8d
	movl	%esi, %r11d
	subl	%edi, %esi
	imull	%esi, %esi
	subl	%r10d, %r11d
	imull	%r11d, %r11d
	addl	%esi, %r9d
	leal	2(%rcx), %esi
	addl	%r11d, %edx
	cmpl	%esi, %r12d
	jle	.L8
	movslq	%esi, %rsi
	addl	$3, %ecx
	movl	(%rsp,%rsi,4), %esi
	movl	%esi, %r11d
	subl	%eax, %r11d
	imull	%r11d, %r11d
	addl	%r11d, %r8d
	movl	%esi, %r11d
	subl	%edi, %esi
	subl	%r10d, %r11d
	imull	%esi, %esi
	imull	%r11d, %r11d
	addl	%esi, %r9d
	addl	%r11d, %edx
	cmpl	%ecx, %r12d
	jle	.L8
	movslq	%ecx, %rcx
	movl	(%rsp,%rcx,4), %ecx
	movl	%ecx, %esi
	subl	%eax, %esi
	movl	%ecx, %eax
	subl	%edi, %ecx
	subl	%r10d, %eax
	imull	%esi, %esi
	imull	%eax, %eax
	imull	%ecx, %ecx
	addl	%esi, %r8d
	addl	%eax, %edx
	addl	%ecx, %r9d
.L8:
	cmpl	%r8d, %edx
	jge	.L11
	cmpl	%edx, %r9d
	jl	.L25
.L26:
	leaq	.LC0(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L13:
	movq	920(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L29
	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
.L11:
	.cfi_restore_state
	cmpl	%r8d, %r9d
	jge	.L4
.L25:
	movl	%r9d, %edx
	leaq	.LC0(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L13
.L16:
	xorl	%r8d, %r8d
.L4:
	movl	%r8d, %edx
	jmp	.L26
.L18:
	xorl	%r9d, %r9d
	xorl	%edx, %edx
	xorl	%r8d, %r8d
	xorl	%ecx, %ecx
	jmp	.L14
.L17:
	xorl	%eax, %eax
	xorl	%edx, %edx
	jmp	.L5
.L29:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE39:
	.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
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB39:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movl	$512, %esi
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$936, %rsp
	.cfi_def_cfa_offset 992
	movq	stdin(%rip), %rdx
	leaq	400(%rsp), %rbp
	leaq	401(%rsp), %rbx
	movq	%fs:40, %rax
	movq	%rax, 920(%rsp)
	xorl	%eax, %eax
	movq	%rbp, %rdi
	leaq	913(%rsp), %r15
	call	fgets@PLT
	movq	%rbp, %rdi
	movl	$10, %edx
	xorl	%esi, %esi
	call	strtol@PLT
	movq	stdin(%rip), %rdx
	movq	%rbp, %rdi
	movl	$512, %esi
	movq	%rax, %r12
	movl	%eax, %r13d
	call	fgets@PLT
	movq	%rbp, %rdi
	xorl	%ebp, %ebp
	jmp	.L3
	.p2align 4,,10
	.p2align 3
.L2:
	addq	$1, %rbx
	cmpq	%r15, %rbx
	je	.L28
.L3:
	cmpb	$32, -1(%rbx)
	jne	.L2
	movl	$10, %edx
	xorl	%esi, %esi
	movb	$0, -1(%rbx)
	leal	1(%rbp), %r14d
	call	strtol@PLT
	movq	%rbx, %rdi
	addq	$1, %rbx
	movl	%eax, (%rsp,%rbp,4)
	movslq	%r14d, %rbp
	cmpq	%r15, %rbx
	jne	.L3
.L28:
	movl	$10, %edx
	xorl	%esi, %esi
	call	strtol@PLT
	movl	%eax, (%rsp,%rbp,4)
	testl	%r12d, %r12d
	jle	.L16
	leal	-1(%r12), %ecx
	cmpl	$2, %ecx
	jbe	.L17
	movl	%r12d, %edx
	movq	%rsp, %rax
	pxor	%xmm0, %xmm0
	shrl	$2, %edx
	subl	$1, %edx
	salq	$4, %rdx
	leaq	16(%rsp,%rdx), %rdx
	.p2align 4,,10
	.p2align 3
.L6:
	paddd	(%rax), %xmm0
	addq	$16, %rax
	cmpq	%rdx, %rax
	jne	.L6
	movdqa	%xmm0, %xmm1
	movl	%r12d, %edx
	psrldq	$8, %xmm1
	andl	$-4, %edx
	paddd	%xmm1, %xmm0
	movdqa	%xmm0, %xmm1
	psrldq	$4, %xmm1
	paddd	%xmm1, %xmm0
	movd	%xmm0, %eax
	testb	$3, %r12b
	je	.L7
.L5:
	movslq	%edx, %rsi
	addl	(%rsp,%rsi,4), %eax
	leal	1(%rdx), %esi
	cmpl	%esi, %r12d
	jle	.L7
	movslq	%esi, %rsi
	addl	$2, %edx
	addl	(%rsp,%rsi,4), %eax
	cmpl	%edx, %r12d
	jle	.L7
	movslq	%edx, %rdx
	addl	(%rsp,%rdx,4), %eax
.L7:
	cltd
	idivl	%r13d
	leal	1(%rax), %r10d
	leal	-1(%rax), %edi
	cmpl	$3, %ecx
	jbe	.L18
	movl	%r12d, %ecx
	movd	%eax, %xmm5
	movd	%edi, %xmm2
	movq	%rsp, %rdx
	shrl	$2, %ecx
	pxor	%xmm4, %xmm4
	movd	%r10d, %xmm6
	subl	$1, %ecx
	pshufd	$0, %xmm5, %xmm7
	pshufd	$0, %xmm6, %xmm6
	salq	$4, %rcx
	pshufd	$0, %xmm2, %xmm5
	movdqa	%xmm4, %xmm3
	leaq	16(%rsp,%rcx), %rcx
	movdqa	%xmm4, %xmm2
	.p2align 4,,10
	.p2align 3
.L9:
	movdqa	(%rdx), %xmm0
	addq	$16, %rdx
	movdqa	%xmm0, %xmm1
	psubd	%xmm7, %xmm1
	movdqa	%xmm1, %xmm8
	pmuludq	%xmm1, %xmm8
	psrlq	$32, %xmm1
	pmuludq	%xmm1, %xmm1
	pshufd	$8, %xmm8, %xmm8
	pshufd	$8, %xmm1, %xmm1
	punpckldq	%xmm1, %xmm8
	movdqa	%xmm0, %xmm1
	psubd	%xmm5, %xmm0
	psubd	%xmm6, %xmm1
	paddd	%xmm8, %xmm2
	movdqa	%xmm1, %xmm8
	pmuludq	%xmm1, %xmm8
	psrlq	$32, %xmm1
	pmuludq	%xmm1, %xmm1
	pshufd	$8, %xmm8, %xmm8
	pshufd	$8, %xmm1, %xmm1
	punpckldq	%xmm1, %xmm8
	movdqa	%xmm0, %xmm1
	pmuludq	%xmm0, %xmm1
	psrlq	$32, %xmm0
	paddd	%xmm8, %xmm3
	pmuludq	%xmm0, %xmm0
	pshufd	$8, %xmm1, %xmm1
	pshufd	$8, %xmm0, %xmm0
	punpckldq	%xmm0, %xmm1
	paddd	%xmm1, %xmm4
	cmpq	%rdx, %rcx
	jne	.L9
	movdqa	%xmm4, %xmm0
	movl	%r12d, %ecx
	psrldq	$8, %xmm0
	andl	$-4, %ecx
	paddd	%xmm4, %xmm0
	movdqa	%xmm0, %xmm1
	psrldq	$4, %xmm1
	paddd	%xmm1, %xmm0
	movd	%xmm0, %r9d
	movdqa	%xmm3, %xmm0
	psrldq	$8, %xmm0
	paddd	%xmm3, %xmm0
	movdqa	%xmm0, %xmm1
	psrldq	$4, %xmm1
	paddd	%xmm1, %xmm0
	movd	%xmm0, %edx
	movdqa	%xmm2, %xmm0
	psrldq	$8, %xmm0
	paddd	%xmm2, %xmm0
	movdqa	%xmm0, %xmm1
	psrldq	$4, %xmm1
	paddd	%xmm1, %xmm0
	movd	%xmm0, %r8d
	testb	$3, %r12b
	je	.L8
.L14:
	movslq	%ecx, %rsi
	movl	(%rsp,%rsi,4), %esi
	movl	%esi, %r11d
	subl	%eax, %r11d
	imull	%r11d, %r11d
	addl	%r11d, %r8d
	movl	%esi, %r11d
	subl	%edi, %esi
	imull	%esi, %esi
	subl	%r10d, %r11d
	imull	%r11d, %r11d
	addl	%esi, %r9d
	leal	1(%rcx), %esi
	addl	%r11d, %edx
	cmpl	%r12d, %esi
	jge	.L8
	movslq	%esi, %rsi
	movl	(%rsp,%rsi,4), %esi
	movl	%esi, %r11d
	subl	%eax, %r11d
	imull	%r11d, %r11d
	addl	%r11d, %r8d
	movl	%esi, %r11d
	subl	%edi, %esi
	imull	%esi, %esi
	subl	%r10d, %r11d
	imull	%r11d, %r11d
	addl	%esi, %r9d
	leal	2(%rcx), %esi
	addl	%r11d, %edx
	cmpl	%esi, %r12d
	jle	.L8
	movslq	%esi, %rsi
	addl	$3, %ecx
	movl	(%rsp,%rsi,4), %esi
	movl	%esi, %r11d
	subl	%eax, %r11d
	imull	%r11d, %r11d
	addl	%r11d, %r8d
	movl	%esi, %r11d
	subl	%edi, %esi
	subl	%r10d, %r11d
	imull	%esi, %esi
	imull	%r11d, %r11d
	addl	%esi, %r9d
	addl	%r11d, %edx
	cmpl	%ecx, %r12d
	jle	.L8
	movslq	%ecx, %rcx
	movl	(%rsp,%rcx,4), %ecx
	movl	%ecx, %esi
	subl	%eax, %esi
	movl	%ecx, %eax
	subl	%edi, %ecx
	subl	%r10d, %eax
	imull	%esi, %esi
	imull	%eax, %eax
	imull	%ecx, %ecx
	addl	%esi, %r8d
	addl	%eax, %edx
	addl	%ecx, %r9d
.L8:
	cmpl	%r8d, %edx
	jge	.L11
	cmpl	%edx, %r9d
	jl	.L25
.L26:
	leaq	.LC0(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L13:
	movq	920(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L29
	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
.L11:
	.cfi_restore_state
	cmpl	%r8d, %r9d
	jge	.L4
.L25:
	movl	%r9d, %edx
	leaq	.LC0(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L13
.L16:
	xorl	%r8d, %r8d
.L4:
	movl	%r8d, %edx
	jmp	.L26
.L18:
	xorl	%r9d, %r9d
	xorl	%edx, %edx
	xorl	%r8d, %r8d
	xorl	%ecx, %ecx
	jmp	.L14
.L17:
	xorl	%eax, %eax
	xorl	%edx, %edx
	jmp	.L5
.L29:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE39:
	.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>

#define absmin(a,b) (((a) > 0) && 
int main(void) {
    int N;
    int a[100];
    int i,cnt;
    char str[512];
    char *p;

    int rd=0,ru=0,minus=0 ;
    int rdchk=0,ruchk=0,minux=0;
    
    fgets(str, 512, stdin);
    N = atoi(str);
    fgets(str, 512, stdin);
    p = str;
    for(i=0,cnt=0;i<512;i++){
        if(str[i] == ' '){
            str[i] = '\0';
            a[cnt++] = atoi(p);
            p = &str[i+1];
        }
    }
    a[cnt] = atoi(p);

    for(cnt=0;cnt<N;cnt++){
        rd +=a[cnt];
    }

    rd = rd / N;
    ru = rd + 1;
    minus = rd - 1;

    for(cnt=0;cnt<N;cnt++){
        rdchk += (a[cnt] - rd) * (a[cnt] - rd);
        ruchk += (a[cnt] - ru) * (a[cnt] - ru);
        minux += (a[cnt] - minus) * (a[cnt]-minus);
    }
    
    if(rdchk > ruchk) {
        if(ruchk > minux) {
        printf("%d\n", minux);
        } else {
        printf("%d\n", ruchk);
        }
    } else {
        if(rdchk > minux) {
        printf("%d\n", minux);
        } else {
        printf("%d\n", rdchk);
        }
    }

    return 0;
    
}

2
5 8
 3
1 1 6
 3
4 3 5
 4
-100 -45 -100 -100
 2
5 11
 3
1 1 8
 3
3 3 5
 3
0 1 8
 3
3 0 5
 2
10 6

5
 17
 2
 2269
 18
 33
 3
 38
 13
 8

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>

#define absmin(a,b) (((a) > 0) && 
int main(void) {
    int N;
    int a[100];
    int i,cnt;
    char str[512];
    char *p;

    int rd=0,ru=0,minus=0 ;
    int rdchk=0,ruchk=0,minux=0;
    
    fgets(str, 512, stdin);
    N = atoi(str);
    fgets(str, 512, stdin);
    p = str;
    for(i=0,cnt=0;i<512;i++){
        if(str[i] == ' '){
            str[i] = '\0';
            a[cnt++] = atoi(p);
            p = &str[i+1];
        }
    }
    a[cnt] = atoi(p);

    for(cnt=0;cnt<N;cnt++){
        rd +=a[cnt];
    }

    rd = rd / N;
    ru = rd + 1;
    minus = rd - 1;

    for(cnt=0;cnt<N;cnt++){
        rdchk += (a[cnt] - rd) * (a[cnt] - rd);
        ruchk += (a[cnt] - ru) * (a[cnt] - ru);
        minux += (a[cnt] - minus) * (a[cnt]-minus);
    }
    
    if(rdchk > ruchk) {
        if(ruchk > minux) {
        printf("%d\n", minux);
        } else {
        printf("%d\n", ruchk);
        }
    } else {
        if(rdchk > minux) {
        printf("%d\n", minux);
        } else {
        printf("%d\n", rdchk);
        }
    }

    return 0;
    
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB6:
	.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	$984, %rsp
	.cfi_offset 3, -24
	movq	%fs:40, %rax
	movq	%rax, -24(%rbp)
	xorl	%eax, %eax
	movl	$0, -980(%rbp)
	movl	$0, -964(%rbp)
	movl	$0, -960(%rbp)
	movl	$0, -976(%rbp)
	movl	$0, -972(%rbp)
	movl	$0, -968(%rbp)
	movq	stdin(%rip), %rdx
	leaq	-544(%rbp), %rax
	movl	$512, %esi
	movq	%rax, %rdi
	call	fgets@PLT
	leaq	-544(%rbp), %rax
	movq	%rax, %rdi
	call	atoi@PLT
	movl	%eax, -956(%rbp)
	movq	stdin(%rip), %rdx
	leaq	-544(%rbp), %rax
	movl	$512, %esi
	movq	%rax, %rdi
	call	fgets@PLT
	leaq	-544(%rbp), %rax
	movq	%rax, -952(%rbp)
	movl	$0, -988(%rbp)
	movl	$0, -984(%rbp)
	jmp	.L2
.L4:
	movl	-988(%rbp), %eax
	cltq
	movzbl	-544(%rbp,%rax), %eax
	cmpb	$32, %al
	jne	.L3
	movl	-988(%rbp), %eax
	cltq
	movb	$0, -544(%rbp,%rax)
	movl	-984(%rbp), %ebx
	leal	1(%rbx), %eax
	movl	%eax, -984(%rbp)
	movq	-952(%rbp), %rax
	movq	%rax, %rdi
	call	atoi@PLT
	movslq	%ebx, %rdx
	movl	%eax, -944(%rbp,%rdx,4)
	movl	-988(%rbp), %eax
	addl	$1, %eax
	leaq	-544(%rbp), %rdx
	cltq
	addq	%rdx, %rax
	movq	%rax, -952(%rbp)
.L3:
	addl	$1, -988(%rbp)
.L2:
	cmpl	$511, -988(%rbp)
	jle	.L4
	movq	-952(%rbp), %rax
	movq	%rax, %rdi
	call	atoi@PLT
	movl	-984(%rbp), %edx
	movslq	%edx, %rdx
	movl	%eax, -944(%rbp,%rdx,4)
	movl	$0, -984(%rbp)
	jmp	.L5
.L6:
	movl	-984(%rbp), %eax
	cltq
	movl	-944(%rbp,%rax,4), %eax
	addl	%eax, -980(%rbp)
	addl	$1, -984(%rbp)
.L5:
	movl	-984(%rbp), %eax
	cmpl	-956(%rbp), %eax
	jl	.L6
	movl	-980(%rbp), %eax
	cltd
	idivl	-956(%rbp)
	movl	%eax, -980(%rbp)
	movl	-980(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -964(%rbp)
	movl	-980(%rbp), %eax
	subl	$1, %eax
	movl	%eax, -960(%rbp)
	movl	$0, -984(%rbp)
	jmp	.L7
.L8:
	movl	-984(%rbp), %eax
	cltq
	movl	-944(%rbp,%rax,4), %eax
	subl	-980(%rbp), %eax
	movl	%eax, %edx
	movl	-984(%rbp), %eax
	cltq
	movl	-944(%rbp,%rax,4), %eax
	subl	-980(%rbp), %eax
	imull	%edx, %eax
	addl	%eax, -976(%rbp)
	movl	-984(%rbp), %eax
	cltq
	movl	-944(%rbp,%rax,4), %eax
	subl	-964(%rbp), %eax
	movl	%eax, %edx
	movl	-984(%rbp), %eax
	cltq
	movl	-944(%rbp,%rax,4), %eax
	subl	-964(%rbp), %eax
	imull	%edx, %eax
	addl	%eax, -972(%rbp)
	movl	-984(%rbp), %eax
	cltq
	movl	-944(%rbp,%rax,4), %eax
	subl	-960(%rbp), %eax
	movl	%eax, %edx
	movl	-984(%rbp), %eax
	cltq
	movl	-944(%rbp,%rax,4), %eax
	subl	-960(%rbp), %eax
	imull	%edx, %eax
	addl	%eax, -968(%rbp)
	addl	$1, -984(%rbp)
.L7:
	movl	-984(%rbp), %eax
	cmpl	-956(%rbp), %eax
	jl	.L8
	movl	-976(%rbp), %eax
	cmpl	-972(%rbp), %eax
	jle	.L9
	movl	-972(%rbp), %eax
	cmpl	-968(%rbp), %eax
	jle	.L10
	movl	-968(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L11
.L10:
	movl	-972(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L11
.L9:
	movl	-976(%rbp), %eax
	cmpl	-968(%rbp), %eax
	jle	.L12
	movl	-968(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L11
.L12:
	movl	-976(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L11:
	movl	$0, %eax
	movq	-24(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L14
	call	__stack_chk_fail@PLT
.L14:
	movq	-8(%rbp), %rbx
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.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.
val
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB6:
	.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	$984, %rsp
	.cfi_offset 3, -24
	movq	%fs:40, %rax
	movq	%rax, -24(%rbp)
	xorl	%eax, %eax
	movl	$0, -980(%rbp)
	movl	$0, -964(%rbp)
	movl	$0, -960(%rbp)
	movl	$0, -976(%rbp)
	movl	$0, -972(%rbp)
	movl	$0, -968(%rbp)
	movq	stdin(%rip), %rdx
	leaq	-544(%rbp), %rax
	movl	$512, %esi
	movq	%rax, %rdi
	call	fgets@PLT
	leaq	-544(%rbp), %rax
	movq	%rax, %rdi
	call	atoi@PLT
	movl	%eax, -956(%rbp)
	movq	stdin(%rip), %rdx
	leaq	-544(%rbp), %rax
	movl	$512, %esi
	movq	%rax, %rdi
	call	fgets@PLT
	leaq	-544(%rbp), %rax
	movq	%rax, -952(%rbp)
	movl	$0, -988(%rbp)
	movl	$0, -984(%rbp)
	jmp	.L2
.L4:
	movl	-988(%rbp), %eax
	cltq
	movzbl	-544(%rbp,%rax), %eax
	cmpb	$32, %al
	jne	.L3
	movl	-988(%rbp), %eax
	cltq
	movb	$0, -544(%rbp,%rax)
	movl	-984(%rbp), %ebx
	leal	1(%rbx), %eax
	movl	%eax, -984(%rbp)
	movq	-952(%rbp), %rax
	movq	%rax, %rdi
	call	atoi@PLT
	movslq	%ebx, %rdx
	movl	%eax, -944(%rbp,%rdx,4)
	movl	-988(%rbp), %eax
	addl	$1, %eax
	leaq	-544(%rbp), %rdx
	cltq
	addq	%rdx, %rax
	movq	%rax, -952(%rbp)
.L3:
	addl	$1, -988(%rbp)
.L2:
	cmpl	$511, -988(%rbp)
	jle	.L4
	movq	-952(%rbp), %rax
	movq	%rax, %rdi
	call	atoi@PLT
	movl	-984(%rbp), %edx
	movslq	%edx, %rdx
	movl	%eax, -944(%rbp,%rdx,4)
	movl	$0, -984(%rbp)
	jmp	.L5
.L6:
	movl	-984(%rbp), %eax
	cltq
	movl	-944(%rbp,%rax,4), %eax
	addl	%eax, -980(%rbp)
	addl	$1, -984(%rbp)
.L5:
	movl	-984(%rbp), %eax
	cmpl	-956(%rbp), %eax
	jl	.L6
	movl	-980(%rbp), %eax
	cltd
	idivl	-956(%rbp)
	movl	%eax, -980(%rbp)
	movl	-980(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -964(%rbp)
	movl	-980(%rbp), %eax
	subl	$1, %eax
	movl	%eax, -960(%rbp)
	movl	$0, -984(%rbp)
	jmp	.L7
.L8:
	movl	-984(%rbp), %eax
	cltq
	movl	-944(%rbp,%rax,4), %eax
	subl	-980(%rbp), %eax
	movl	%eax, %edx
	movl	-984(%rbp), %eax
	cltq
	movl	-944(%rbp,%rax,4), %eax
	subl	-980(%rbp), %eax
	imull	%edx, %eax
	addl	%eax, -976(%rbp)
	movl	-984(%rbp), %eax
	cltq
	movl	-944(%rbp,%rax,4), %eax
	subl	-964(%rbp), %eax
	movl	%eax, %edx
	movl	-984(%rbp), %eax
	cltq
	movl	-944(%rbp,%rax,4), %eax
	subl	-964(%rbp), %eax
	imull	%edx, %eax
	addl	%eax, -972(%rbp)
	movl	-984(%rbp), %eax
	cltq
	movl	-944(%rbp,%rax,4), %eax
	subl	-960(%rbp), %eax
	movl	%eax, %edx
	movl	-984(%rbp), %eax
	cltq
	movl	-944(%rbp,%rax,4), %eax
	subl	-960(%rbp), %eax
	imull	%edx, %eax
	addl	%eax, -968(%rbp)
	addl	$1, -984(%rbp)
.L7:
	movl	-984(%rbp), %eax
	cmpl	-956(%rbp), %eax
	jl	.L8
	movl	-976(%rbp), %eax
	cmpl	-972(%rbp), %eax
	jle	.L9
	movl	-972(%rbp), %eax
	cmpl	-968(%rbp), %eax
	jle	.L10
	movl	-968(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L11
.L10:
	movl	-972(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L11
.L9:
	movl	-976(%rbp), %eax
	cmpl	-968(%rbp), %eax
	jle	.L12
	movl	-968(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L11
.L12:
	movl	-976(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L11:
	movl	$0, %eax
	movq	-24(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L14
	call	__stack_chk_fail@PLT
.L14:
	movq	-8(%rbp), %rbx
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.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:
