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>
#include <math.h>

int main(void){
    int N;

    scanf("%d", &N);

    int *A = (int *) malloc(sizeof(int) * N);
    int i;

    for(i = 0; i < N; i ++){
        scanf("%d", A + i);
    }
    int sum = abs(A[0] - 0);

    for(i = 1; i < N; i ++){
        sum += abs(A[i] - A[i - 1]);
    }
    sum += abs(0 - A[N - 1]);

    printf("%d\n", sum - abs(A[0] - 0) - abs(A[1] - A[0]) + abs(A[1] - 0));
    
    for(i = 1; i < N - 1; i ++){
        printf("%d\n", sum - abs(A[i] - A[i-1]) - abs(A[i + 1] - A[i]) + abs(A[i + 1] - A[i - 1]));
    }
    printf("%d\n", sum - abs(A[N - 1] - A[N - 2]) - abs(0 - A[N - 1]) + abs(0 - A[N - 2]));

    return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.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
	subq	$32, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-28(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-28(%rbp), %eax
	cltq
	salq	$2, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, -16(%rbp)
	movl	$0, -24(%rbp)
	jmp	.L2
.L3:
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -24(%rbp)
.L2:
	movl	-28(%rbp), %eax
	cmpl	%eax, -24(%rbp)
	jl	.L3
	movq	-16(%rbp), %rax
	movl	(%rax), %eax
	movl	%eax, %edx
	negl	%edx
	cmovns	%edx, %eax
	movl	%eax, -20(%rbp)
	movl	$1, -24(%rbp)
	jmp	.L4
.L5:
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	-24(%rbp), %edx
	movslq	%edx, %rdx
	salq	$2, %rdx
	leaq	-4(%rdx), %rcx
	movq	-16(%rbp), %rdx
	addq	%rcx, %rdx
	movl	(%rdx), %edx
	subl	%edx, %eax
	movl	%eax, %edx
	negl	%edx
	cmovns	%edx, %eax
	addl	%eax, -20(%rbp)
	addl	$1, -24(%rbp)
.L4:
	movl	-28(%rbp), %eax
	cmpl	%eax, -24(%rbp)
	jl	.L5
	movl	-28(%rbp), %eax
	cltq
	salq	$2, %rax
	leaq	-4(%rax), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, %edx
	negl	%edx
	cmovns	%edx, %eax
	addl	%eax, -20(%rbp)
	movq	-16(%rbp), %rax
	movl	(%rax), %eax
	movl	%eax, %edx
	negl	%edx
	cmovs	%eax, %edx
	movl	-20(%rbp), %eax
	subl	%edx, %eax
	movl	%eax, %ecx
	movq	-16(%rbp), %rax
	addq	$4, %rax
	movl	(%rax), %edx
	movq	-16(%rbp), %rax
	movl	(%rax), %esi
	movl	%edx, %eax
	subl	%esi, %eax
	movl	%eax, %edx
	negl	%edx
	cmovns	%edx, %eax
	subl	%eax, %ecx
	movq	-16(%rbp), %rax
	addq	$4, %rax
	movl	(%rax), %eax
	movl	%eax, %edx
	negl	%edx
	cmovns	%edx, %eax
	addl	%ecx, %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$1, -24(%rbp)
	jmp	.L6
.L7:
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	-24(%rbp), %edx
	movslq	%edx, %rdx
	salq	$2, %rdx
	leaq	-4(%rdx), %rcx
	movq	-16(%rbp), %rdx
	addq	%rcx, %rdx
	movl	(%rdx), %edx
	subl	%edx, %eax
	movl	%eax, %edx
	negl	%edx
	cmovs	%eax, %edx
	movl	-20(%rbp), %eax
	subl	%edx, %eax
	movl	%eax, %ecx
	movl	-24(%rbp), %eax
	cltq
	addq	$1, %rax
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	-24(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rsi
	movq	-16(%rbp), %rdx
	addq	%rsi, %rdx
	movl	(%rdx), %edx
	subl	%edx, %eax
	movl	%eax, %edx
	negl	%edx
	cmovns	%edx, %eax
	subl	%eax, %ecx
	movl	-24(%rbp), %eax
	cltq
	addq	$1, %rax
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	-24(%rbp), %edx
	movslq	%edx, %rdx
	salq	$2, %rdx
	leaq	-4(%rdx), %rsi
	movq	-16(%rbp), %rdx
	addq	%rsi, %rdx
	movl	(%rdx), %edx
	subl	%edx, %eax
	movl	%eax, %edx
	negl	%edx
	cmovns	%edx, %eax
	addl	%ecx, %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	addl	$1, -24(%rbp)
.L6:
	movl	-28(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -24(%rbp)
	jl	.L7
	movl	-28(%rbp), %eax
	cltq
	salq	$2, %rax
	leaq	-4(%rax), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	-28(%rbp), %edx
	movslq	%edx, %rdx
	salq	$2, %rdx
	leaq	-8(%rdx), %rcx
	movq	-16(%rbp), %rdx
	addq	%rcx, %rdx
	movl	(%rdx), %edx
	subl	%edx, %eax
	movl	%eax, %edx
	negl	%edx
	cmovns	%edx, %eax
	movl	%eax, %ecx
	movl	-20(%rbp), %eax
	subl	%ecx, %eax
	movl	%eax, %edx
	movl	-28(%rbp), %eax
	cltq
	salq	$2, %rax
	leaq	-4(%rax), %rcx
	movq	-16(%rbp), %rax
	addq	%rcx, %rax
	movl	(%rax), %eax
	movl	%eax, %ecx
	negl	%ecx
	cmovns	%ecx, %eax
	movl	%edx, %ecx
	subl	%eax, %ecx
	movl	-28(%rbp), %eax
	cltq
	salq	$2, %rax
	leaq	-8(%rax), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, %edx
	negl	%edx
	cmovns	%edx, %eax
	addl	%ecx, %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L9
	call	__stack_chk_fail@PLT
.L9:
	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"
.LC1:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB39:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	leaq	.LC0(%rip), %r14
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	movq	%r14, %rdi
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	subq	$16, %rsp
	.cfi_def_cfa_offset 64
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	leaq	4(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movslq	4(%rsp), %rbx
	leaq	0(,%rbx,4), %rdi
	call	malloc@PLT
	movq	%rax, %r12
	testl	%ebx, %ebx
	jle	.L2
	movq	%rax, %rbp
	xorl	%ebx, %ebx
	.p2align 4,,10
	.p2align 3
.L3:
	movq	%rbp, %rsi
	movq	%r14, %rdi
	xorl	%eax, %eax
	addl	$1, %ebx
	call	__isoc99_scanf@PLT
	movl	4(%rsp), %r13d
	addq	$4, %rbp
	cmpl	%ebx, %r13d
	jg	.L3
	movl	(%r12), %edi
	movl	%edi, %esi
	negl	%esi
	cmovs	%edi, %esi
	cmpl	$1, %r13d
	jle	.L37
	leal	-2(%r13), %eax
	leal	-1(%r13), %r8d
	cmpl	$2, %eax
	jbe	.L15
	movl	%r8d, %edx
	movq	%r12, %rax
	pxor	%xmm1, %xmm1
	shrl	$2, %edx
	subl	$1, %edx
	salq	$4, %rdx
	leaq	16(%r12,%rdx), %rdx
	.p2align 4,,10
	.p2align 3
.L6:
	movdqu	4(%rax), %xmm0
	movdqu	(%rax), %xmm3
	addq	$16, %rax
	psubd	%xmm3, %xmm0
	movdqa	%xmm0, %xmm2
	psrad	$31, %xmm2
	pxor	%xmm2, %xmm0
	psubd	%xmm2, %xmm0
	paddd	%xmm0, %xmm1
	cmpq	%rax, %rdx
	jne	.L6
	movdqa	%xmm1, %xmm0
	movl	%r8d, %edx
	psrldq	$8, %xmm0
	andl	$-4, %edx
	paddd	%xmm0, %xmm1
	leal	1(%rdx), %ecx
	movdqa	%xmm1, %xmm0
	psrldq	$4, %xmm0
	paddd	%xmm0, %xmm1
	movd	%xmm1, %eax
	addl	%esi, %eax
	cmpl	%r8d, %edx
	je	.L35
.L5:
	movslq	%ecx, %rdx
	leal	1(%rcx), %r10d
	movq	%rdx, %r9
	leaq	(%r12,%rdx,4), %r11
	cmpl	%r8d, %r10d
	jge	.L10
	cmpl	%ecx, %r13d
	jle	.L10
	movl	-4(%r11), %r9d
.L11:
	movl	(%r12,%rdx,4), %r11d
	movl	%r11d, %r10d
	subl	%r9d, %r10d
	movl	4(%r12,%rdx,4), %r9d
	movl	%r10d, %ecx
	negl	%ecx
	cmovs	%r10d, %ecx
	movl	%r9d, %r10d
	subl	%r11d, %r10d
	addl	%eax, %ecx
	movl	%r10d, %eax
	negl	%eax
	cmovs	%r10d, %eax
	addl	%ecx, %eax
	leal	2(%rdx), %ecx
	addq	$2, %rdx
	leal	1(%rdx), %r10d
	cmpl	%r10d, %r8d
	jg	.L11
	movslq	%ecx, %r9
	leal	1(%rcx), %r10d
.L10:
	movl	(%r12,%r9,4), %ebx
	leaq	0(,%r9,4), %r11
	movl	%ebx, %r8d
	subl	-4(%r12,%r9,4), %r8d
	movl	%r8d, %edx
	negl	%edx
	cmovs	%r8d, %edx
	addl	%edx, %eax
	cmpl	%r10d, %r13d
	jle	.L35
	movl	4(%r12,%r11), %edx
	subl	%ebx, %edx
	movl	%edx, %r8d
	negl	%r8d
	cmovns	%r8d, %edx
	addl	$2, %ecx
	addl	%edx, %eax
	cmpl	%ecx, %r13d
	jle	.L35
	movl	8(%r12,%r11), %edx
	subl	4(%r12,%r11), %edx
	movl	%edx, %ecx
	negl	%ecx
	cmovns	%ecx, %edx
	addl	%edx, %eax
.L35:
	movslq	%r13d, %rbx
.L8:
	movl	-4(%r12,%rbx,4), %edx
	leaq	.LC1(%rip), %r13
	movl	%edx, %ebp
	negl	%ebp
	cmovs	%edx, %ebp
	addl	%eax, %ebp
	movl	4(%r12), %eax
	movl	%ebp, %edx
	subl	%esi, %edx
	movl	%eax, %esi
	subl	%edi, %esi
	movl	$1, %edi
	movl	%esi, %ecx
	negl	%ecx
	cmovs	%esi, %ecx
	movq	%r13, %rsi
	subl	%ecx, %edx
	movl	%eax, %ecx
	negl	%ecx
	cmovns	%ecx, %eax
	addl	%eax, %edx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movslq	4(%rsp), %rax
	cmpl	$2, %eax
	jle	.L12
	movl	$1, %ebx
	.p2align 4,,10
	.p2align 3
.L13:
	movl	(%r12,%rbx,4), %edi
	movl	4(%r12,%rbx,4), %eax
	movl	%edi, %edx
	subl	-4(%r12,%rbx,4), %edx
	movl	%eax, %esi
	movl	%edx, %ecx
	negl	%ecx
	cmovs	%edx, %ecx
	subl	%edi, %esi
	movl	%ebp, %edx
	movl	$1, %edi
	subl	%ecx, %edx
	movl	%esi, %ecx
	negl	%ecx
	cmovs	%esi, %ecx
	subl	-4(%r12,%rbx,4), %eax
	movq	%r13, %rsi
	subl	%ecx, %edx
	movl	%eax, %ecx
	negl	%ecx
	cmovns	%ecx, %eax
	addq	$1, %rbx
	addl	%eax, %edx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movslq	4(%rsp), %rax
	leal	-1(%rax), %edx
	cmpl	%ebx, %edx
	jg	.L13
.L12:
	salq	$2, %rax
	movl	$1, %edi
	movl	-4(%r12,%rax), %edx
	movl	-8(%r12,%rax), %eax
	movl	%edx, %esi
	subl	%eax, %esi
	movl	%esi, %ecx
	negl	%ecx
	cmovs	%esi, %ecx
	movq	%r13, %rsi
	subl	%ecx, %ebp
	movl	%edx, %ecx
	negl	%ecx
	cmovns	%ecx, %edx
	subl	%edx, %ebp
	movl	%eax, %edx
	negl	%edx
	cmovns	%edx, %eax
	leal	0(%rbp,%rax), %edx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L38
	addq	$16, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 48
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	ret
.L2:
	.cfi_restore_state
	movl	(%rax), %edi
	movl	%edi, %esi
	negl	%esi
	cmovs	%edi, %esi
	movl	%esi, %eax
	jmp	.L8
.L15:
	movl	%esi, %eax
	movl	$1, %ecx
	jmp	.L5
.L37:
	movslq	%r13d, %rbx
	movl	%esi, %eax
	jmp	.L8
.L38:
	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"
.LC1:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB39:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	leaq	.LC0(%rip), %r14
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	movq	%r14, %rdi
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	subq	$16, %rsp
	.cfi_def_cfa_offset 64
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	leaq	4(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movslq	4(%rsp), %rbx
	leaq	0(,%rbx,4), %rdi
	call	malloc@PLT
	movq	%rax, %r12
	testl	%ebx, %ebx
	jle	.L2
	movq	%rax, %rbp
	xorl	%ebx, %ebx
	.p2align 4,,10
	.p2align 3
.L3:
	movq	%rbp, %rsi
	movq	%r14, %rdi
	xorl	%eax, %eax
	addl	$1, %ebx
	call	__isoc99_scanf@PLT
	movl	4(%rsp), %r13d
	addq	$4, %rbp
	cmpl	%ebx, %r13d
	jg	.L3
	movl	(%r12), %edi
	movl	%edi, %esi
	negl	%esi
	cmovs	%edi, %esi
	cmpl	$1, %r13d
	jle	.L37
	leal	-2(%r13), %eax
	leal	-1(%r13), %r8d
	cmpl	$2, %eax
	jbe	.L15
	movl	%r8d, %edx
	movq	%r12, %rax
	pxor	%xmm1, %xmm1
	shrl	$2, %edx
	subl	$1, %edx
	salq	$4, %rdx
	leaq	16(%r12,%rdx), %rdx
	.p2align 4,,10
	.p2align 3
.L6:
	movdqu	4(%rax), %xmm0
	movdqu	(%rax), %xmm3
	addq	$16, %rax
	psubd	%xmm3, %xmm0
	movdqa	%xmm0, %xmm2
	psrad	$31, %xmm2
	pxor	%xmm2, %xmm0
	psubd	%xmm2, %xmm0
	paddd	%xmm0, %xmm1
	cmpq	%rax, %rdx
	jne	.L6
	movdqa	%xmm1, %xmm0
	movl	%r8d, %edx
	psrldq	$8, %xmm0
	andl	$-4, %edx
	paddd	%xmm0, %xmm1
	leal	1(%rdx), %ecx
	movdqa	%xmm1, %xmm0
	psrldq	$4, %xmm0
	paddd	%xmm0, %xmm1
	movd	%xmm1, %eax
	addl	%esi, %eax
	cmpl	%r8d, %edx
	je	.L35
.L5:
	movslq	%ecx, %rdx
	leal	1(%rcx), %r10d
	movq	%rdx, %r9
	leaq	(%r12,%rdx,4), %r11
	cmpl	%r8d, %r10d
	jge	.L10
	cmpl	%ecx, %r13d
	jle	.L10
	movl	-4(%r11), %r9d
.L11:
	movl	(%r12,%rdx,4), %r11d
	movl	%r11d, %r10d
	subl	%r9d, %r10d
	movl	4(%r12,%rdx,4), %r9d
	movl	%r10d, %ecx
	negl	%ecx
	cmovs	%r10d, %ecx
	movl	%r9d, %r10d
	subl	%r11d, %r10d
	addl	%eax, %ecx
	movl	%r10d, %eax
	negl	%eax
	cmovs	%r10d, %eax
	addl	%ecx, %eax
	leal	2(%rdx), %ecx
	addq	$2, %rdx
	leal	1(%rdx), %r10d
	cmpl	%r10d, %r8d
	jg	.L11
	movslq	%ecx, %r9
	leal	1(%rcx), %r10d
.L10:
	movl	(%r12,%r9,4), %ebx
	leaq	0(,%r9,4), %r11
	movl	%ebx, %r8d
	subl	-4(%r12,%r9,4), %r8d
	movl	%r8d, %edx
	negl	%edx
	cmovs	%r8d, %edx
	addl	%edx, %eax
	cmpl	%r10d, %r13d
	jle	.L35
	movl	4(%r12,%r11), %edx
	subl	%ebx, %edx
	movl	%edx, %r8d
	negl	%r8d
	cmovns	%r8d, %edx
	addl	$2, %ecx
	addl	%edx, %eax
	cmpl	%ecx, %r13d
	jle	.L35
	movl	8(%r12,%r11), %edx
	subl	4(%r12,%r11), %edx
	movl	%edx, %ecx
	negl	%ecx
	cmovns	%ecx, %edx
	addl	%edx, %eax
.L35:
	movslq	%r13d, %rbx
.L8:
	movl	-4(%r12,%rbx,4), %edx
	leaq	.LC1(%rip), %r13
	movl	%edx, %ebp
	negl	%ebp
	cmovs	%edx, %ebp
	addl	%eax, %ebp
	movl	4(%r12), %eax
	movl	%ebp, %edx
	subl	%esi, %edx
	movl	%eax, %esi
	subl	%edi, %esi
	movl	$1, %edi
	movl	%esi, %ecx
	negl	%ecx
	cmovs	%esi, %ecx
	movq	%r13, %rsi
	subl	%ecx, %edx
	movl	%eax, %ecx
	negl	%ecx
	cmovns	%ecx, %eax
	addl	%eax, %edx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movslq	4(%rsp), %rax
	cmpl	$2, %eax
	jle	.L12
	movl	$1, %ebx
	.p2align 4,,10
	.p2align 3
.L13:
	movl	(%r12,%rbx,4), %edi
	movl	4(%r12,%rbx,4), %eax
	movl	%edi, %edx
	subl	-4(%r12,%rbx,4), %edx
	movl	%eax, %esi
	movl	%edx, %ecx
	negl	%ecx
	cmovs	%edx, %ecx
	subl	%edi, %esi
	movl	%ebp, %edx
	movl	$1, %edi
	subl	%ecx, %edx
	movl	%esi, %ecx
	negl	%ecx
	cmovs	%esi, %ecx
	subl	-4(%r12,%rbx,4), %eax
	movq	%r13, %rsi
	subl	%ecx, %edx
	movl	%eax, %ecx
	negl	%ecx
	cmovns	%ecx, %eax
	addq	$1, %rbx
	addl	%eax, %edx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movslq	4(%rsp), %rax
	leal	-1(%rax), %edx
	cmpl	%ebx, %edx
	jg	.L13
.L12:
	salq	$2, %rax
	movl	$1, %edi
	movl	-4(%r12,%rax), %edx
	movl	-8(%r12,%rax), %eax
	movl	%edx, %esi
	subl	%eax, %esi
	movl	%esi, %ecx
	negl	%ecx
	cmovs	%esi, %ecx
	movq	%r13, %rsi
	subl	%ecx, %ebp
	movl	%edx, %ecx
	negl	%ecx
	cmovns	%ecx, %edx
	subl	%edx, %ebp
	movl	%eax, %edx
	negl	%edx
	cmovns	%edx, %eax
	leal	0(%rbp,%rax), %edx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L38
	addq	$16, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 48
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	ret
.L2:
	.cfi_restore_state
	movl	(%rax), %edi
	movl	%edi, %esi
	negl	%esi
	cmovs	%edi, %esi
	movl	%esi, %eax
	jmp	.L8
.L15:
	movl	%esi, %eax
	movl	$1, %ecx
	jmp	.L5
.L37:
	movslq	%r13d, %rbx
	movl	%esi, %eax
	jmp	.L8
.L38:
	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>
#include <math.h>

int main(void){
    int N;

    scanf("%d", &N);

    int *A = (int *) malloc(sizeof(int) * N);
    int i;

    for(i = 0; i < N; i ++){
        scanf("%d", A + i);
    }
    int sum = abs(A[0] - 0);

    for(i = 1; i < N; i ++){
        sum += abs(A[i] - A[i - 1]);
    }
    sum += abs(0 - A[N - 1]);

    printf("%d\n", sum - abs(A[0] - 0) - abs(A[1] - A[0]) + abs(A[1] - 0));
    
    for(i = 1; i < N - 1; i ++){
        printf("%d\n", sum - abs(A[i] - A[i-1]) - abs(A[i + 1] - A[i]) + abs(A[i + 1] - A[i - 1]));
    }
    printf("%d\n", sum - abs(A[N - 1] - A[N - 2]) - abs(0 - A[N - 1]) + abs(0 - A[N - 2]));

    return 0;
}
3
3 5 -1

12
8
10

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>
#include <math.h>

int main(void){
    int N;

    scanf("%d", &N);

    int *A = (int *) malloc(sizeof(int) * N);
    int i;

    for(i = 0; i < N; i ++){
        scanf("%d", A + i);
    }
    int sum = abs(A[0] - 0);

    for(i = 1; i < N; i ++){
        sum += abs(A[i] - A[i - 1]);
    }
    sum += abs(0 - A[N - 1]);

    printf("%d\n", sum - abs(A[0] - 0) - abs(A[1] - A[0]) + abs(A[1] - 0));
    
    for(i = 1; i < N - 1; i ++){
        printf("%d\n", sum - abs(A[i] - A[i-1]) - abs(A[i + 1] - A[i]) + abs(A[i + 1] - A[i - 1]));
    }
    printf("%d\n", sum - abs(A[N - 1] - A[N - 2]) - abs(0 - A[N - 1]) + abs(0 - A[N - 2]));

    return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.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
	subq	$32, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-28(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-28(%rbp), %eax
	cltq
	salq	$2, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, -16(%rbp)
	movl	$0, -24(%rbp)
	jmp	.L2
.L3:
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -24(%rbp)
.L2:
	movl	-28(%rbp), %eax
	cmpl	%eax, -24(%rbp)
	jl	.L3
	movq	-16(%rbp), %rax
	movl	(%rax), %eax
	movl	%eax, %edx
	negl	%edx
	cmovns	%edx, %eax
	movl	%eax, -20(%rbp)
	movl	$1, -24(%rbp)
	jmp	.L4
.L5:
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	-24(%rbp), %edx
	movslq	%edx, %rdx
	salq	$2, %rdx
	leaq	-4(%rdx), %rcx
	movq	-16(%rbp), %rdx
	addq	%rcx, %rdx
	movl	(%rdx), %edx
	subl	%edx, %eax
	movl	%eax, %edx
	negl	%edx
	cmovns	%edx, %eax
	addl	%eax, -20(%rbp)
	addl	$1, -24(%rbp)
.L4:
	movl	-28(%rbp), %eax
	cmpl	%eax, -24(%rbp)
	jl	.L5
	movl	-28(%rbp), %eax
	cltq
	salq	$2, %rax
	leaq	-4(%rax), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, %edx
	negl	%edx
	cmovns	%edx, %eax
	addl	%eax, -20(%rbp)
	movq	-16(%rbp), %rax
	movl	(%rax), %eax
	movl	%eax, %edx
	negl	%edx
	cmovs	%eax, %edx
	movl	-20(%rbp), %eax
	subl	%edx, %eax
	movl	%eax, %ecx
	movq	-16(%rbp), %rax
	addq	$4, %rax
	movl	(%rax), %edx
	movq	-16(%rbp), %rax
	movl	(%rax), %esi
	movl	%edx, %eax
	subl	%esi, %eax
	movl	%eax, %edx
	negl	%edx
	cmovns	%edx, %eax
	subl	%eax, %ecx
	movq	-16(%rbp), %rax
	addq	$4, %rax
	movl	(%rax), %eax
	movl	%eax, %edx
	negl	%edx
	cmovns	%edx, %eax
	addl	%ecx, %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$1, -24(%rbp)
	jmp	.L6
.L7:
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	-24(%rbp), %edx
	movslq	%edx, %rdx
	salq	$2, %rdx
	leaq	-4(%rdx), %rcx
	movq	-16(%rbp), %rdx
	addq	%rcx, %rdx
	movl	(%rdx), %edx
	subl	%edx, %eax
	movl	%eax, %edx
	negl	%edx
	cmovs	%eax, %edx
	movl	-20(%rbp), %eax
	subl	%edx, %eax
	movl	%eax, %ecx
	movl	-24(%rbp), %eax
	cltq
	addq	$1, %rax
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	-24(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rsi
	movq	-16(%rbp), %rdx
	addq	%rsi, %rdx
	movl	(%rdx), %edx
	subl	%edx, %eax
	movl	%eax, %edx
	negl	%edx
	cmovns	%edx, %eax
	subl	%eax, %ecx
	movl	-24(%rbp), %eax
	cltq
	addq	$1, %rax
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	-24(%rbp), %edx
	movslq	%edx, %rdx
	salq	$2, %rdx
	leaq	-4(%rdx), %rsi
	movq	-16(%rbp), %rdx
	addq	%rsi, %rdx
	movl	(%rdx), %edx
	subl	%edx, %eax
	movl	%eax, %edx
	negl	%edx
	cmovns	%edx, %eax
	addl	%ecx, %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	addl	$1, -24(%rbp)
.L6:
	movl	-28(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -24(%rbp)
	jl	.L7
	movl	-28(%rbp), %eax
	cltq
	salq	$2, %rax
	leaq	-4(%rax), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	-28(%rbp), %edx
	movslq	%edx, %rdx
	salq	$2, %rdx
	leaq	-8(%rdx), %rcx
	movq	-16(%rbp), %rdx
	addq	%rcx, %rdx
	movl	(%rdx), %edx
	subl	%edx, %eax
	movl	%eax, %edx
	negl	%edx
	cmovns	%edx, %eax
	movl	%eax, %ecx
	movl	-20(%rbp), %eax
	subl	%ecx, %eax
	movl	%eax, %edx
	movl	-28(%rbp), %eax
	cltq
	salq	$2, %rax
	leaq	-4(%rax), %rcx
	movq	-16(%rbp), %rax
	addq	%rcx, %rax
	movl	(%rax), %eax
	movl	%eax, %ecx
	negl	%ecx
	cmovns	%ecx, %eax
	movl	%edx, %ecx
	subl	%eax, %ecx
	movl	-28(%rbp), %eax
	cltq
	salq	$2, %rax
	leaq	-8(%rax), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, %edx
	negl	%edx
	cmovns	%edx, %eax
	addl	%ecx, %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L9
	call	__stack_chk_fail@PLT
.L9:
	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.
train
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.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
	subq	$32, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-28(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-28(%rbp), %eax
	cltq
	salq	$2, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, -16(%rbp)
	movl	$0, -24(%rbp)
	jmp	.L2
.L3:
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -24(%rbp)
.L2:
	movl	-28(%rbp), %eax
	cmpl	%eax, -24(%rbp)
	jl	.L3
	movq	-16(%rbp), %rax
	movl	(%rax), %eax
	movl	%eax, %edx
	negl	%edx
	cmovns	%edx, %eax
	movl	%eax, -20(%rbp)
	movl	$1, -24(%rbp)
	jmp	.L4
.L5:
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	-24(%rbp), %edx
	movslq	%edx, %rdx
	salq	$2, %rdx
	leaq	-4(%rdx), %rcx
	movq	-16(%rbp), %rdx
	addq	%rcx, %rdx
	movl	(%rdx), %edx
	subl	%edx, %eax
	movl	%eax, %edx
	negl	%edx
	cmovns	%edx, %eax
	addl	%eax, -20(%rbp)
	addl	$1, -24(%rbp)
.L4:
	movl	-28(%rbp), %eax
	cmpl	%eax, -24(%rbp)
	jl	.L5
	movl	-28(%rbp), %eax
	cltq
	salq	$2, %rax
	leaq	-4(%rax), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, %edx
	negl	%edx
	cmovns	%edx, %eax
	addl	%eax, -20(%rbp)
	movq	-16(%rbp), %rax
	movl	(%rax), %eax
	movl	%eax, %edx
	negl	%edx
	cmovs	%eax, %edx
	movl	-20(%rbp), %eax
	subl	%edx, %eax
	movl	%eax, %ecx
	movq	-16(%rbp), %rax
	addq	$4, %rax
	movl	(%rax), %edx
	movq	-16(%rbp), %rax
	movl	(%rax), %esi
	movl	%edx, %eax
	subl	%esi, %eax
	movl	%eax, %edx
	negl	%edx
	cmovns	%edx, %eax
	subl	%eax, %ecx
	movq	-16(%rbp), %rax
	addq	$4, %rax
	movl	(%rax), %eax
	movl	%eax, %edx
	negl	%edx
	cmovns	%edx, %eax
	addl	%ecx, %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$1, -24(%rbp)
	jmp	.L6
.L7:
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	-24(%rbp), %edx
	movslq	%edx, %rdx
	salq	$2, %rdx
	leaq	-4(%rdx), %rcx
	movq	-16(%rbp), %rdx
	addq	%rcx, %rdx
	movl	(%rdx), %edx
	subl	%edx, %eax
	movl	%eax, %edx
	negl	%edx
	cmovs	%eax, %edx
	movl	-20(%rbp), %eax
	subl	%edx, %eax
	movl	%eax, %ecx
	movl	-24(%rbp), %eax
	cltq
	addq	$1, %rax
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	-24(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rsi
	movq	-16(%rbp), %rdx
	addq	%rsi, %rdx
	movl	(%rdx), %edx
	subl	%edx, %eax
	movl	%eax, %edx
	negl	%edx
	cmovns	%edx, %eax
	subl	%eax, %ecx
	movl	-24(%rbp), %eax
	cltq
	addq	$1, %rax
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	-24(%rbp), %edx
	movslq	%edx, %rdx
	salq	$2, %rdx
	leaq	-4(%rdx), %rsi
	movq	-16(%rbp), %rdx
	addq	%rsi, %rdx
	movl	(%rdx), %edx
	subl	%edx, %eax
	movl	%eax, %edx
	negl	%edx
	cmovns	%edx, %eax
	addl	%ecx, %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	addl	$1, -24(%rbp)
.L6:
	movl	-28(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -24(%rbp)
	jl	.L7
	movl	-28(%rbp), %eax
	cltq
	salq	$2, %rax
	leaq	-4(%rax), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	-28(%rbp), %edx
	movslq	%edx, %rdx
	salq	$2, %rdx
	leaq	-8(%rdx), %rcx
	movq	-16(%rbp), %rdx
	addq	%rcx, %rdx
	movl	(%rdx), %edx
	subl	%edx, %eax
	movl	%eax, %edx
	negl	%edx
	cmovns	%edx, %eax
	movl	%eax, %ecx
	movl	-20(%rbp), %eax
	subl	%ecx, %eax
	movl	%eax, %edx
	movl	-28(%rbp), %eax
	cltq
	salq	$2, %rax
	leaq	-4(%rax), %rcx
	movq	-16(%rbp), %rax
	addq	%rcx, %rax
	movl	(%rax), %eax
	movl	%eax, %ecx
	negl	%ecx
	cmovns	%ecx, %eax
	movl	%edx, %ecx
	subl	%eax, %ecx
	movl	-28(%rbp), %eax
	cltq
	salq	$2, %rax
	leaq	-8(%rax), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, %edx
	negl	%edx
	cmovns	%edx, %eax
	addl	%ecx, %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L9
	call	__stack_chk_fail@PLT
.L9:
	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:
