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() {
  int N;
  int *A;
  int *a;
  int minabs = INFINITY;
  int minabs_pos;
  long long int sum = 0;
  int i;

  scanf("%d", &N);

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

  for(i = 0; i < N; i++) {
    scanf("%d", a);
    a++;
    if(abs(A[i]) < minabs) {
      minabs = abs(A[i]);
      minabs_pos = i;
    }
  }

  for(i = 0; i < minabs_pos; i++) {
    if(A[i] < 0) {
      A[i] *= -1;
      A[i+1] *= -1;
    }
  }

  for(i = N - 1; i > minabs_pos; i--) {
    if(A[i] < 0) {
      A[i-1] *= -1;
      A[i] *= -1;
    }
  }

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

  printf("%lld\n", sum);

  free(A);

  return 0;
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%lld\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	$48, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$2147483647, -44(%rbp)
	movq	$0, -24(%rbp)
	leaq	-48(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-48(%rbp), %eax
	cltq
	salq	$2, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, -16(%rbp)
	movq	-16(%rbp), %rax
	movq	%rax, -32(%rbp)
	movl	$0, -36(%rbp)
	jmp	.L2
.L4:
	movq	-32(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addq	$4, -32(%rbp)
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, %edx
	negl	%edx
	cmovns	%edx, %eax
	cmpl	%eax, -44(%rbp)
	jle	.L3
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, %edx
	negl	%edx
	cmovns	%edx, %eax
	movl	%eax, -44(%rbp)
	movl	-36(%rbp), %eax
	movl	%eax, -40(%rbp)
.L3:
	addl	$1, -36(%rbp)
.L2:
	movl	-48(%rbp), %eax
	cmpl	%eax, -36(%rbp)
	jl	.L4
	movl	$0, -36(%rbp)
	jmp	.L5
.L7:
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	testl	%eax, %eax
	jns	.L6
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	movq	-16(%rbp), %rax
	addq	%rcx, %rax
	negl	%edx
	movl	%edx, (%rax)
	movl	-36(%rbp), %eax
	cltq
	addq	$1, %rax
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movl	-36(%rbp), %eax
	cltq
	addq	$1, %rax
	leaq	0(,%rax,4), %rcx
	movq	-16(%rbp), %rax
	addq	%rcx, %rax
	negl	%edx
	movl	%edx, (%rax)
.L6:
	addl	$1, -36(%rbp)
.L5:
	movl	-36(%rbp), %eax
	cmpl	-40(%rbp), %eax
	jl	.L7
	movl	-48(%rbp), %eax
	subl	$1, %eax
	movl	%eax, -36(%rbp)
	jmp	.L8
.L10:
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	testl	%eax, %eax
	jns	.L9
	movl	-36(%rbp), %eax
	cltq
	salq	$2, %rax
	leaq	-4(%rax), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movl	-36(%rbp), %eax
	cltq
	salq	$2, %rax
	leaq	-4(%rax), %rcx
	movq	-16(%rbp), %rax
	addq	%rcx, %rax
	negl	%edx
	movl	%edx, (%rax)
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	movq	-16(%rbp), %rax
	addq	%rcx, %rax
	negl	%edx
	movl	%edx, (%rax)
.L9:
	subl	$1, -36(%rbp)
.L8:
	movl	-36(%rbp), %eax
	cmpl	-40(%rbp), %eax
	jg	.L10
	movl	$0, -36(%rbp)
	jmp	.L11
.L12:
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cltq
	addq	%rax, -24(%rbp)
	addl	$1, -36(%rbp)
.L11:
	movl	-48(%rbp), %eax
	cmpl	%eax, -36(%rbp)
	jl	.L12
	movq	-24(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movq	-16(%rbp), %rax
	movq	%rax, %rdi
	call	free@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L14
	call	__stack_chk_fail@PLT
.L14:
	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	"%lld\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
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	leaq	.LC0(%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	$40, %rsp
	.cfi_def_cfa_offset 96
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	leaq	20(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movslq	20(%rsp), %rdi
	movl	%edi, 12(%rsp)
	salq	$2, %rdi
	call	malloc@PLT
	movl	12(%rsp), %ecx
	movq	%rax, %rbp
	testl	%ecx, %ecx
	jle	.L2
	movq	%rax, %r14
	xorl	%r15d, %r15d
	movl	$2147483647, %r12d
	.p2align 4,,10
	.p2align 3
.L4:
	movq	%r14, %rsi
	xorl	%eax, %eax
	addq	$4, %r14
	movq	%r13, %rdi
	call	__isoc99_scanf@PLT
	movl	-4(%r14), %edx
	movl	%edx, %eax
	negl	%eax
	cmovs	%edx, %eax
	cmpl	%r12d, %eax
	jge	.L3
	movl	%r15d, %ebx
	movl	%eax, %r12d
.L3:
	movl	20(%rsp), %ecx
	addl	$1, %r15d
	cmpl	%r15d, %ecx
	jg	.L4
.L2:
	testl	%ebx, %ebx
	je	.L5
	leal	-1(%rbx), %edx
	movq	%rbp, %rax
	leaq	4(%rbp,%rdx,4), %rsi
	.p2align 4,,10
	.p2align 3
.L7:
	movl	(%rax), %edx
	testl	%edx, %edx
	jns	.L6
	negl	%edx
	negl	4(%rax)
	movl	%edx, (%rax)
.L6:
	addq	$4, %rax
	cmpq	%rsi, %rax
	jne	.L7
.L5:
	leal	-1(%rcx), %edi
	cmpl	%ebx, %edi
	jle	.L8
	movslq	%edi, %rdx
	salq	$2, %rdx
	leaq	-4(%rbp,%rdx), %rsi
	leaq	0(%rbp,%rdx), %rax
	leal	-2(%rcx), %edx
	subl	%ebx, %edx
	salq	$2, %rdx
	subq	%rdx, %rsi
	.p2align 4,,10
	.p2align 3
.L10:
	movl	(%rax), %edx
	testl	%edx, %edx
	jns	.L9
	negl	%edx
	negl	-4(%rax)
	movl	%edx, (%rax)
.L9:
	subq	$4, %rax
	cmpq	%rsi, %rax
	jne	.L10
.L8:
	testl	%ecx, %ecx
	jle	.L16
	cmpl	$2, %edi
	jbe	.L17
	movl	%ecx, %edx
	pxor	%xmm0, %xmm0
	pxor	%xmm4, %xmm4
	movq	%rbp, %rax
	shrl	$2, %edx
	subl	$1, %edx
	salq	$4, %rdx
	leaq	16(%rbp,%rdx), %rdx
	.p2align 4,,10
	.p2align 3
.L13:
	movdqu	(%rax), %xmm1
	movdqa	%xmm4, %xmm2
	addq	$16, %rax
	pcmpgtd	%xmm1, %xmm2
	movdqa	%xmm1, %xmm3
	punpckldq	%xmm2, %xmm3
	punpckhdq	%xmm2, %xmm1
	paddq	%xmm3, %xmm0
	paddq	%xmm1, %xmm0
	cmpq	%rax, %rdx
	jne	.L13
	movdqa	%xmm0, %xmm1
	movl	%ecx, %eax
	psrldq	$8, %xmm1
	andl	$-4, %eax
	paddq	%xmm1, %xmm0
	movq	%xmm0, %rdx
	testb	$3, %cl
	je	.L11
.L12:
	movslq	%eax, %rsi
	leaq	0(,%rsi,4), %rdi
	movslq	0(%rbp,%rsi,4), %rsi
	addq	%rsi, %rdx
	leal	1(%rax), %esi
	cmpl	%ecx, %esi
	jge	.L11
	movslq	4(%rbp,%rdi), %rsi
	addl	$2, %eax
	addq	%rsi, %rdx
	cmpl	%ecx, %eax
	jge	.L11
	movslq	8(%rbp,%rdi), %rax
	addq	%rax, %rdx
.L11:
	movl	$1, %edi
	xorl	%eax, %eax
	leaq	.LC1(%rip), %rsi
	call	__printf_chk@PLT
	movq	%rbp, %rdi
	call	free@PLT
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L27
	addq	$40, %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
.L16:
	.cfi_restore_state
	xorl	%edx, %edx
	jmp	.L11
.L17:
	xorl	%eax, %eax
	xorl	%edx, %edx
	jmp	.L12
.L27:
	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	"%lld\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
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	leaq	.LC0(%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	$40, %rsp
	.cfi_def_cfa_offset 96
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	leaq	20(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movslq	20(%rsp), %rdi
	movl	%edi, 12(%rsp)
	salq	$2, %rdi
	call	malloc@PLT
	movl	12(%rsp), %ecx
	movq	%rax, %rbp
	testl	%ecx, %ecx
	jle	.L2
	movq	%rax, %r14
	xorl	%r15d, %r15d
	movl	$2147483647, %r12d
	.p2align 4,,10
	.p2align 3
.L4:
	movq	%r14, %rsi
	xorl	%eax, %eax
	addq	$4, %r14
	movq	%r13, %rdi
	call	__isoc99_scanf@PLT
	movl	-4(%r14), %edx
	movl	%edx, %eax
	negl	%eax
	cmovs	%edx, %eax
	cmpl	%r12d, %eax
	jge	.L3
	movl	%r15d, %ebx
	movl	%eax, %r12d
.L3:
	movl	20(%rsp), %ecx
	addl	$1, %r15d
	cmpl	%r15d, %ecx
	jg	.L4
.L2:
	testl	%ebx, %ebx
	je	.L5
	leal	-1(%rbx), %edx
	movq	%rbp, %rax
	leaq	4(%rbp,%rdx,4), %rsi
	.p2align 4,,10
	.p2align 3
.L7:
	movl	(%rax), %edx
	testl	%edx, %edx
	jns	.L6
	negl	%edx
	negl	4(%rax)
	movl	%edx, (%rax)
.L6:
	addq	$4, %rax
	cmpq	%rsi, %rax
	jne	.L7
.L5:
	leal	-1(%rcx), %edi
	cmpl	%ebx, %edi
	jle	.L8
	movslq	%edi, %rdx
	salq	$2, %rdx
	leaq	-4(%rbp,%rdx), %rsi
	leaq	0(%rbp,%rdx), %rax
	leal	-2(%rcx), %edx
	subl	%ebx, %edx
	salq	$2, %rdx
	subq	%rdx, %rsi
	.p2align 4,,10
	.p2align 3
.L10:
	movl	(%rax), %edx
	testl	%edx, %edx
	jns	.L9
	negl	%edx
	negl	-4(%rax)
	movl	%edx, (%rax)
.L9:
	subq	$4, %rax
	cmpq	%rsi, %rax
	jne	.L10
.L8:
	testl	%ecx, %ecx
	jle	.L16
	cmpl	$2, %edi
	jbe	.L17
	movl	%ecx, %edx
	pxor	%xmm0, %xmm0
	pxor	%xmm4, %xmm4
	movq	%rbp, %rax
	shrl	$2, %edx
	subl	$1, %edx
	salq	$4, %rdx
	leaq	16(%rbp,%rdx), %rdx
	.p2align 4,,10
	.p2align 3
.L13:
	movdqu	(%rax), %xmm1
	movdqa	%xmm4, %xmm2
	addq	$16, %rax
	pcmpgtd	%xmm1, %xmm2
	movdqa	%xmm1, %xmm3
	punpckldq	%xmm2, %xmm3
	punpckhdq	%xmm2, %xmm1
	paddq	%xmm3, %xmm0
	paddq	%xmm1, %xmm0
	cmpq	%rax, %rdx
	jne	.L13
	movdqa	%xmm0, %xmm1
	movl	%ecx, %eax
	psrldq	$8, %xmm1
	andl	$-4, %eax
	paddq	%xmm1, %xmm0
	movq	%xmm0, %rdx
	testb	$3, %cl
	je	.L11
.L12:
	movslq	%eax, %rsi
	leaq	0(,%rsi,4), %rdi
	movslq	0(%rbp,%rsi,4), %rsi
	addq	%rsi, %rdx
	leal	1(%rax), %esi
	cmpl	%ecx, %esi
	jge	.L11
	movslq	4(%rbp,%rdi), %rsi
	addl	$2, %eax
	addq	%rsi, %rdx
	cmpl	%ecx, %eax
	jge	.L11
	movslq	8(%rbp,%rdi), %rax
	addq	%rax, %rdx
.L11:
	movl	$1, %edi
	xorl	%eax, %eax
	leaq	.LC1(%rip), %rsi
	call	__printf_chk@PLT
	movq	%rbp, %rdi
	call	free@PLT
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L27
	addq	$40, %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
.L16:
	.cfi_restore_state
	xorl	%edx, %edx
	jmp	.L11
.L17:
	xorl	%eax, %eax
	xorl	%edx, %edx
	jmp	.L12
.L27:
	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() {
  int N;
  int *A;
  int *a;
  int minabs = INFINITY;
  int minabs_pos;
  long long int sum = 0;
  int i;

  scanf("%d", &N);

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

  for(i = 0; i < N; i++) {
    scanf("%d", a);
    a++;
    if(abs(A[i]) < minabs) {
      minabs = abs(A[i]);
      minabs_pos = i;
    }
  }

  for(i = 0; i < minabs_pos; i++) {
    if(A[i] < 0) {
      A[i] *= -1;
      A[i+1] *= -1;
    }
  }

  for(i = N - 1; i > minabs_pos; i--) {
    if(A[i] < 0) {
      A[i-1] *= -1;
      A[i] *= -1;
    }
  }

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

  printf("%lld\n", sum);

  free(A);

  return 0;
}

11
-1000000000 1000000000 -364513171 1000000000 -1000000000 0 1000000000 -1000000000 1000000000 -1000000000 1000000000
 5
10 -4 -8 -11 5
 3
-10 5 0
 11
-1000000000 1000000000 -364513171 1000000000 -1000000000 0 1000000000 -1000000000 1000000000 -1000000000 1000000100
 5
10 -4 -4 -11 5
 3
-14 5 0
 11
-1000000000 1000000000 -364513171 1000000000 -1000000000 0 1000000000 -1000000000 1000000100 -1000000000 1000000100
 5
10 -4 -4 -14 5
 3
-14 5 1
 11
-1000000000 1000000000 -364513171 1000000000 -1382285407 0 1000000000 -1000000000 1000000000 -1000000000 1000000100

9364513171
 30
 15
 9364513271
 26
 19
 9364513371
 29
 18
 9746798678

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() {
  int N;
  int *A;
  int *a;
  int minabs = INFINITY;
  int minabs_pos;
  long long int sum = 0;
  int i;

  scanf("%d", &N);

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

  for(i = 0; i < N; i++) {
    scanf("%d", a);
    a++;
    if(abs(A[i]) < minabs) {
      minabs = abs(A[i]);
      minabs_pos = i;
    }
  }

  for(i = 0; i < minabs_pos; i++) {
    if(A[i] < 0) {
      A[i] *= -1;
      A[i+1] *= -1;
    }
  }

  for(i = N - 1; i > minabs_pos; i--) {
    if(A[i] < 0) {
      A[i-1] *= -1;
      A[i] *= -1;
    }
  }

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

  printf("%lld\n", sum);

  free(A);

  return 0;
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%lld\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	$48, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$2147483647, -44(%rbp)
	movq	$0, -24(%rbp)
	leaq	-48(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-48(%rbp), %eax
	cltq
	salq	$2, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, -16(%rbp)
	movq	-16(%rbp), %rax
	movq	%rax, -32(%rbp)
	movl	$0, -36(%rbp)
	jmp	.L2
.L4:
	movq	-32(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addq	$4, -32(%rbp)
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, %edx
	negl	%edx
	cmovns	%edx, %eax
	cmpl	%eax, -44(%rbp)
	jle	.L3
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, %edx
	negl	%edx
	cmovns	%edx, %eax
	movl	%eax, -44(%rbp)
	movl	-36(%rbp), %eax
	movl	%eax, -40(%rbp)
.L3:
	addl	$1, -36(%rbp)
.L2:
	movl	-48(%rbp), %eax
	cmpl	%eax, -36(%rbp)
	jl	.L4
	movl	$0, -36(%rbp)
	jmp	.L5
.L7:
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	testl	%eax, %eax
	jns	.L6
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	movq	-16(%rbp), %rax
	addq	%rcx, %rax
	negl	%edx
	movl	%edx, (%rax)
	movl	-36(%rbp), %eax
	cltq
	addq	$1, %rax
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movl	-36(%rbp), %eax
	cltq
	addq	$1, %rax
	leaq	0(,%rax,4), %rcx
	movq	-16(%rbp), %rax
	addq	%rcx, %rax
	negl	%edx
	movl	%edx, (%rax)
.L6:
	addl	$1, -36(%rbp)
.L5:
	movl	-36(%rbp), %eax
	cmpl	-40(%rbp), %eax
	jl	.L7
	movl	-48(%rbp), %eax
	subl	$1, %eax
	movl	%eax, -36(%rbp)
	jmp	.L8
.L10:
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	testl	%eax, %eax
	jns	.L9
	movl	-36(%rbp), %eax
	cltq
	salq	$2, %rax
	leaq	-4(%rax), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movl	-36(%rbp), %eax
	cltq
	salq	$2, %rax
	leaq	-4(%rax), %rcx
	movq	-16(%rbp), %rax
	addq	%rcx, %rax
	negl	%edx
	movl	%edx, (%rax)
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	movq	-16(%rbp), %rax
	addq	%rcx, %rax
	negl	%edx
	movl	%edx, (%rax)
.L9:
	subl	$1, -36(%rbp)
.L8:
	movl	-36(%rbp), %eax
	cmpl	-40(%rbp), %eax
	jg	.L10
	movl	$0, -36(%rbp)
	jmp	.L11
.L12:
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cltq
	addq	%rax, -24(%rbp)
	addl	$1, -36(%rbp)
.L11:
	movl	-48(%rbp), %eax
	cmpl	%eax, -36(%rbp)
	jl	.L12
	movq	-24(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movq	-16(%rbp), %rax
	movq	%rax, %rdi
	call	free@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L14
	call	__stack_chk_fail@PLT
.L14:
	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	"%lld\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	$48, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$2147483647, -44(%rbp)
	movq	$0, -24(%rbp)
	leaq	-48(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-48(%rbp), %eax
	cltq
	salq	$2, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, -16(%rbp)
	movq	-16(%rbp), %rax
	movq	%rax, -32(%rbp)
	movl	$0, -36(%rbp)
	jmp	.L2
.L4:
	movq	-32(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addq	$4, -32(%rbp)
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, %edx
	negl	%edx
	cmovns	%edx, %eax
	cmpl	%eax, -44(%rbp)
	jle	.L3
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, %edx
	negl	%edx
	cmovns	%edx, %eax
	movl	%eax, -44(%rbp)
	movl	-36(%rbp), %eax
	movl	%eax, -40(%rbp)
.L3:
	addl	$1, -36(%rbp)
.L2:
	movl	-48(%rbp), %eax
	cmpl	%eax, -36(%rbp)
	jl	.L4
	movl	$0, -36(%rbp)
	jmp	.L5
.L7:
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	testl	%eax, %eax
	jns	.L6
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	movq	-16(%rbp), %rax
	addq	%rcx, %rax
	negl	%edx
	movl	%edx, (%rax)
	movl	-36(%rbp), %eax
	cltq
	addq	$1, %rax
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movl	-36(%rbp), %eax
	cltq
	addq	$1, %rax
	leaq	0(,%rax,4), %rcx
	movq	-16(%rbp), %rax
	addq	%rcx, %rax
	negl	%edx
	movl	%edx, (%rax)
.L6:
	addl	$1, -36(%rbp)
.L5:
	movl	-36(%rbp), %eax
	cmpl	-40(%rbp), %eax
	jl	.L7
	movl	-48(%rbp), %eax
	subl	$1, %eax
	movl	%eax, -36(%rbp)
	jmp	.L8
.L10:
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	testl	%eax, %eax
	jns	.L9
	movl	-36(%rbp), %eax
	cltq
	salq	$2, %rax
	leaq	-4(%rax), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movl	-36(%rbp), %eax
	cltq
	salq	$2, %rax
	leaq	-4(%rax), %rcx
	movq	-16(%rbp), %rax
	addq	%rcx, %rax
	negl	%edx
	movl	%edx, (%rax)
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	movq	-16(%rbp), %rax
	addq	%rcx, %rax
	negl	%edx
	movl	%edx, (%rax)
.L9:
	subl	$1, -36(%rbp)
.L8:
	movl	-36(%rbp), %eax
	cmpl	-40(%rbp), %eax
	jg	.L10
	movl	$0, -36(%rbp)
	jmp	.L11
.L12:
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cltq
	addq	%rax, -24(%rbp)
	addl	$1, -36(%rbp)
.L11:
	movl	-48(%rbp), %eax
	cmpl	%eax, -36(%rbp)
	jl	.L12
	movq	-24(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movq	-16(%rbp), %rax
	movq	%rax, %rdi
	call	free@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L14
	call	__stack_chk_fail@PLT
.L14:
	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:
