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>

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

#define POS(i,j) ((i)*(n+1)+(j))

void run(void){
  int n;
  scanf("%d",&n);
  int *a=(int *)calloc(n,sizeof(int));
  int i;
  for(i=0;i<n;i++) scanf("%d",a+i);
  int64 *dp=(int64 *)calloc((n+1)*(n+1),sizeof(int64));
  for(int len=2;len<=n;len++){
    for(i=0;i<=n-len;i++){
      int64 sum=0;
      int j;
      for(j=i;j<i+len;j++) sum+=a[j];
      int64 local=dp[POS(i,1)]+dp[POS(i+1,len-1)];
      for(j=2;j<len;j++) local=MIN(local,dp[POS(i,j)]+dp[POS(i+j,len-j)]);
      dp[POS(i,len)]=local+sum;
    }
  }
  printf("%lld\n",dp[POS(0,n)]);
}

int main(void){
  run();
  return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%lld\n"
	.text
	.globl	run
	.type	run, @function
run:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$64, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-56(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-56(%rbp), %eax
	cltq
	movl	$4, %esi
	movq	%rax, %rdi
	call	calloc@PLT
	movq	%rax, -24(%rbp)
	movl	$0, -52(%rbp)
	jmp	.L2
.L3:
	movl	-52(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -52(%rbp)
.L2:
	movl	-56(%rbp), %eax
	cmpl	%eax, -52(%rbp)
	jl	.L3
	movl	-56(%rbp), %eax
	leal	1(%rax), %edx
	movl	-56(%rbp), %eax
	addl	$1, %eax
	imull	%edx, %eax
	cltq
	movl	$8, %esi
	movq	%rax, %rdi
	call	calloc@PLT
	movq	%rax, -16(%rbp)
	movl	$2, -48(%rbp)
	jmp	.L4
.L11:
	movl	$0, -52(%rbp)
	jmp	.L5
.L10:
	movq	$0, -40(%rbp)
	movl	-52(%rbp), %eax
	movl	%eax, -44(%rbp)
	jmp	.L6
.L7:
	movl	-44(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cltq
	addq	%rax, -40(%rbp)
	addl	$1, -44(%rbp)
.L6:
	movl	-52(%rbp), %edx
	movl	-48(%rbp), %eax
	addl	%edx, %eax
	cmpl	%eax, -44(%rbp)
	jl	.L7
	movl	-56(%rbp), %eax
	addl	$1, %eax
	imull	-52(%rbp), %eax
	cltq
	addq	$1, %rax
	leaq	0(,%rax,8), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rcx
	movl	-52(%rbp), %eax
	leal	1(%rax), %edx
	movl	-56(%rbp), %eax
	addl	$1, %eax
	imull	%eax, %edx
	movl	-48(%rbp), %eax
	subl	$1, %eax
	addl	%edx, %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rax
	addq	%rcx, %rax
	movq	%rax, -32(%rbp)
	movl	$2, -44(%rbp)
	jmp	.L8
.L9:
	movl	-56(%rbp), %eax
	addl	$1, %eax
	imull	-52(%rbp), %eax
	movl	%eax, %edx
	movl	-44(%rbp), %eax
	addl	%edx, %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rcx
	movl	-52(%rbp), %edx
	movl	-44(%rbp), %eax
	addl	%eax, %edx
	movl	-56(%rbp), %eax
	addl	$1, %eax
	imull	%eax, %edx
	movl	-48(%rbp), %eax
	subl	-44(%rbp), %eax
	addl	%edx, %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rax
	leaq	(%rcx,%rax), %rdx
	movq	-32(%rbp), %rax
	cmpq	%rdx, %rax
	cmovg	%rdx, %rax
	movq	%rax, -32(%rbp)
	addl	$1, -44(%rbp)
.L8:
	movl	-44(%rbp), %eax
	cmpl	-48(%rbp), %eax
	jl	.L9
	movl	-56(%rbp), %eax
	addl	$1, %eax
	imull	-52(%rbp), %eax
	movl	%eax, %edx
	movl	-48(%rbp), %eax
	addl	%edx, %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movq	-32(%rbp), %rcx
	movq	-40(%rbp), %rdx
	addq	%rcx, %rdx
	movq	%rdx, (%rax)
	addl	$1, -52(%rbp)
.L5:
	movl	-56(%rbp), %eax
	subl	-48(%rbp), %eax
	cmpl	%eax, -52(%rbp)
	jle	.L10
	addl	$1, -48(%rbp)
.L4:
	movl	-56(%rbp), %eax
	cmpl	%eax, -48(%rbp)
	jle	.L11
	movl	-56(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	nop
	movq	-8(%rbp), %rax
	subq	%fs:40, %rax
	je	.L12
	call	__stack_chk_fail@PLT
.L12:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	run, .-run
	.globl	main
	.type	main, @function
main:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	call	run
	movl	$0, %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.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"
	.text
	.p2align 4
	.globl	run
	.type	run, @function
run:
.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	$88, %rsp
	.cfi_def_cfa_offset 144
	movq	%fs:40, %rax
	movq	%rax, 72(%rsp)
	xorl	%eax, %eax
	leaq	68(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movslq	68(%rsp), %rax
	movl	$4, %esi
	movq	%rax, %rbx
	movq	%rax, %rdi
	movq	%rax, 56(%rsp)
	call	calloc@PLT
	testl	%ebx, %ebx
	jle	.L2
	movq	%rax, %r12
	movq	%rax, %rbp
	xorl	%ebx, %ebx
	.p2align 4,,10
	.p2align 3
.L3:
	movq	%rbp, %rsi
	movq	%r13, %rdi
	xorl	%eax, %eax
	addl	$1, %ebx
	call	__isoc99_scanf@PLT
	movl	68(%rsp), %eax
	addq	$4, %rbp
	cmpl	%ebx, %eax
	jg	.L3
	cltq
	movl	$8, %esi
	leal	1(%rax), %r14d
	movl	%eax, 36(%rsp)
	movq	%rax, %rbx
	movl	%r14d, %edi
	movq	%rax, 56(%rsp)
	imull	%r14d, %edi
	movslq	%edi, %rdi
	call	calloc@PLT
	movq	%rax, 40(%rsp)
	cmpl	$1, %ebx
	jle	.L5
	movl	36(%rsp), %eax
	movslq	%r14d, %r14
	movl	$2, %esi
	leaq	0(,%r14,8), %r15
	leal	-1(%rax), %r8d
	movq	40(%rsp), %rax
	leaq	16(%rax), %rcx
	xorl	%eax, %eax
	.p2align 4,,10
	.p2align 3
.L21:
	xorl	%edi, %edi
	leal	1(%rax), %edx
	cmpl	%esi, %eax
	jge	.L9
	movslq	%eax, %rdx
	movslq	(%r12,%rdx,4), %rdi
	leaq	0(,%rdx,4), %r9
	leal	1(%rax), %edx
	cmpl	%esi, %edx
	jge	.L9
	movslq	4(%r12,%r9), %r10
	addl	$2, %eax
	addq	%r10, %rdi
	cmpl	%esi, %eax
	jge	.L9
	movslq	8(%r12,%r9), %rax
	addq	%rax, %rdi
.L9:
	movl	%edx, %eax
	movq	-8(%rcx,%r14,8), %rdx
	addq	-8(%rcx), %rdx
	addl	$1, %esi
	addq	%rdi, %rdx
	movq	%rdx, (%rcx)
	addq	%r15, %rcx
	cmpl	%r8d, %eax
	jne	.L21
	movl	36(%rsp), %eax
	cmpl	$2, %eax
	je	.L5
	subl	$2, %eax
	movl	$2, 32(%rsp)
	leaq	-8(,%r14,8), %r10
	movl	$3, %r9d
	movl	%eax, 4(%rsp)
	movq	40(%rsp), %rax
	pxor	%xmm4, %xmm4
	movq	%r14, 16(%rsp)
	addq	$24, %rax
	movq	%rax, 48(%rsp)
	movq	%r14, %rax
	salq	$4, %rax
	movq	%rax, 8(%rsp)
	.p2align 4,,10
	.p2align 3
.L19:
	cmpl	%r9d, 36(%rsp)
	js	.L11
	movl	%r9d, %eax
	movl	%r9d, %r14d
	movq	40(%rsp), %rdi
	movq	48(%rsp), %r11
	shrl	$2, %eax
	movq	%r12, %r13
	andl	$-4, %r14d
	movl	%r9d, %ebp
	subl	$1, %eax
	xorl	%ebx, %ebx
	addq	$1, %rax
	salq	$4, %rax
	movq	%rax, 24(%rsp)
	.p2align 4,,10
	.p2align 3
.L14:
	cmpl	%ebp, %ebx
	jge	.L32
	cmpl	$2, 32(%rsp)
	je	.L23
	movq	24(%rsp), %rax
	pxor	%xmm0, %xmm0
	leaq	(%rax,%r13), %rdx
	movq	%r13, %rax
	.p2align 4,,10
	.p2align 3
.L16:
	movdqu	(%rax), %xmm2
	movdqa	%xmm4, %xmm3
	addq	$16, %rax
	pcmpgtd	%xmm2, %xmm3
	movdqa	%xmm2, %xmm1
	punpckldq	%xmm3, %xmm1
	punpckhdq	%xmm3, %xmm2
	paddq	%xmm1, %xmm0
	paddq	%xmm2, %xmm0
	cmpq	%rdx, %rax
	jne	.L16
	movdqa	%xmm0, %xmm1
	leal	(%r14,%rbx), %eax
	psrldq	$8, %xmm1
	paddq	%xmm1, %xmm0
	movq	%xmm0, %r8
	cmpl	%r9d, %r14d
	je	.L18
.L15:
	movslq	%eax, %rdx
	leaq	0(,%rdx,4), %rcx
	movslq	(%r12,%rdx,4), %rdx
	addq	%rdx, %r8
	leal	1(%rax), %edx
	cmpl	%ebp, %edx
	jge	.L18
	movslq	4(%r12,%rcx), %rdx
	addl	$2, %eax
	addq	%rdx, %r8
	cmpl	%ebp, %eax
	jge	.L18
	movslq	8(%r12,%rcx), %rax
	addq	%rax, %r8
.L18:
	movq	16(%rsp), %rax
	movq	8(%rdi), %rcx
	addl	$1, %ebx
	movl	$2, %edx
	addq	-8(%r11,%rax,8), %rcx
	movq	8(%rsp), %rax
	leaq	(%r11,%rax), %rsi
	.p2align 4,,10
	.p2align 3
.L13:
	movq	(%rdi,%rdx,8), %rax
	addq	-16(%rsi), %rax
	cmpq	%rax, %rcx
	cmovg	%rax, %rcx
	addq	$1, %rdx
	addq	%r10, %rsi
	cmpl	%edx, %r9d
	jg	.L13
	addq	%r8, %rcx
	addl	$1, %ebp
	addq	%r15, %rdi
	addq	$4, %r13
	movq	%rcx, (%r11)
	addq	%r15, %r11
	cmpl	4(%rsp), %ebx
	jne	.L14
.L11:
	subl	$1, 4(%rsp)
	leal	1(%r9), %eax
	addl	$1, 32(%rsp)
	addq	$8, 48(%rsp)
	cmpl	%r9d, 36(%rsp)
	je	.L5
	movl	%eax, %r9d
	jmp	.L19
	.p2align 4,,10
	.p2align 3
.L32:
	xorl	%r8d, %r8d
	jmp	.L18
.L23:
	movl	%ebx, %eax
	xorl	%r8d, %r8d
	jmp	.L15
.L2:
	addl	$1, %ebx
	movl	$8, %esi
	imull	%ebx, %ebx
	movslq	%ebx, %rdi
	call	calloc@PLT
	movq	%rax, 40(%rsp)
.L5:
	movq	40(%rsp), %rax
	movq	56(%rsp), %rbx
	movl	$1, %edi
	leaq	.LC1(%rip), %rsi
	movq	(%rax,%rbx,8), %rdx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	72(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L33
	addq	$88, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	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
.L33:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE39:
	.size	run, .-run
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB40:
	.cfi_startproc
	endbr64
	subq	$8, %rsp
	.cfi_def_cfa_offset 16
	call	run
	xorl	%eax, %eax
	addq	$8, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE40:
	.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"
	.text
	.p2align 4
	.globl	run
	.type	run, @function
run:
.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	$88, %rsp
	.cfi_def_cfa_offset 144
	movq	%fs:40, %rax
	movq	%rax, 72(%rsp)
	xorl	%eax, %eax
	leaq	68(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movslq	68(%rsp), %rax
	movl	$4, %esi
	movq	%rax, %rbx
	movq	%rax, %rdi
	movq	%rax, 56(%rsp)
	call	calloc@PLT
	testl	%ebx, %ebx
	jle	.L2
	movq	%rax, %r12
	movq	%rax, %rbp
	xorl	%ebx, %ebx
	.p2align 4,,10
	.p2align 3
.L3:
	movq	%rbp, %rsi
	movq	%r13, %rdi
	xorl	%eax, %eax
	addl	$1, %ebx
	call	__isoc99_scanf@PLT
	movl	68(%rsp), %eax
	addq	$4, %rbp
	cmpl	%ebx, %eax
	jg	.L3
	cltq
	movl	$8, %esi
	leal	1(%rax), %r14d
	movl	%eax, 36(%rsp)
	movq	%rax, %rbx
	movl	%r14d, %edi
	movq	%rax, 56(%rsp)
	imull	%r14d, %edi
	movslq	%edi, %rdi
	call	calloc@PLT
	movq	%rax, 40(%rsp)
	cmpl	$1, %ebx
	jle	.L5
	movl	36(%rsp), %eax
	movslq	%r14d, %r14
	movl	$2, %esi
	leaq	0(,%r14,8), %r15
	leal	-1(%rax), %r8d
	movq	40(%rsp), %rax
	leaq	16(%rax), %rcx
	xorl	%eax, %eax
	.p2align 4,,10
	.p2align 3
.L21:
	xorl	%edi, %edi
	leal	1(%rax), %edx
	cmpl	%esi, %eax
	jge	.L9
	movslq	%eax, %rdx
	movslq	(%r12,%rdx,4), %rdi
	leaq	0(,%rdx,4), %r9
	leal	1(%rax), %edx
	cmpl	%esi, %edx
	jge	.L9
	movslq	4(%r12,%r9), %r10
	addl	$2, %eax
	addq	%r10, %rdi
	cmpl	%esi, %eax
	jge	.L9
	movslq	8(%r12,%r9), %rax
	addq	%rax, %rdi
.L9:
	movl	%edx, %eax
	movq	-8(%rcx,%r14,8), %rdx
	addq	-8(%rcx), %rdx
	addl	$1, %esi
	addq	%rdi, %rdx
	movq	%rdx, (%rcx)
	addq	%r15, %rcx
	cmpl	%r8d, %eax
	jne	.L21
	movl	36(%rsp), %eax
	cmpl	$2, %eax
	je	.L5
	subl	$2, %eax
	movl	$2, 32(%rsp)
	leaq	-8(,%r14,8), %r10
	movl	$3, %r9d
	movl	%eax, 4(%rsp)
	movq	40(%rsp), %rax
	pxor	%xmm4, %xmm4
	movq	%r14, 16(%rsp)
	addq	$24, %rax
	movq	%rax, 48(%rsp)
	movq	%r14, %rax
	salq	$4, %rax
	movq	%rax, 8(%rsp)
	.p2align 4,,10
	.p2align 3
.L19:
	cmpl	%r9d, 36(%rsp)
	js	.L11
	movl	%r9d, %eax
	movl	%r9d, %r14d
	movq	40(%rsp), %rdi
	movq	48(%rsp), %r11
	shrl	$2, %eax
	movq	%r12, %r13
	andl	$-4, %r14d
	movl	%r9d, %ebp
	subl	$1, %eax
	xorl	%ebx, %ebx
	addq	$1, %rax
	salq	$4, %rax
	movq	%rax, 24(%rsp)
	.p2align 4,,10
	.p2align 3
.L14:
	cmpl	%ebp, %ebx
	jge	.L32
	cmpl	$2, 32(%rsp)
	je	.L23
	movq	24(%rsp), %rax
	pxor	%xmm0, %xmm0
	leaq	(%rax,%r13), %rdx
	movq	%r13, %rax
	.p2align 4,,10
	.p2align 3
.L16:
	movdqu	(%rax), %xmm2
	movdqa	%xmm4, %xmm3
	addq	$16, %rax
	pcmpgtd	%xmm2, %xmm3
	movdqa	%xmm2, %xmm1
	punpckldq	%xmm3, %xmm1
	punpckhdq	%xmm3, %xmm2
	paddq	%xmm1, %xmm0
	paddq	%xmm2, %xmm0
	cmpq	%rdx, %rax
	jne	.L16
	movdqa	%xmm0, %xmm1
	leal	(%r14,%rbx), %eax
	psrldq	$8, %xmm1
	paddq	%xmm1, %xmm0
	movq	%xmm0, %r8
	cmpl	%r9d, %r14d
	je	.L18
.L15:
	movslq	%eax, %rdx
	leaq	0(,%rdx,4), %rcx
	movslq	(%r12,%rdx,4), %rdx
	addq	%rdx, %r8
	leal	1(%rax), %edx
	cmpl	%ebp, %edx
	jge	.L18
	movslq	4(%r12,%rcx), %rdx
	addl	$2, %eax
	addq	%rdx, %r8
	cmpl	%ebp, %eax
	jge	.L18
	movslq	8(%r12,%rcx), %rax
	addq	%rax, %r8
.L18:
	movq	16(%rsp), %rax
	movq	8(%rdi), %rcx
	addl	$1, %ebx
	movl	$2, %edx
	addq	-8(%r11,%rax,8), %rcx
	movq	8(%rsp), %rax
	leaq	(%r11,%rax), %rsi
	.p2align 4,,10
	.p2align 3
.L13:
	movq	(%rdi,%rdx,8), %rax
	addq	-16(%rsi), %rax
	cmpq	%rax, %rcx
	cmovg	%rax, %rcx
	addq	$1, %rdx
	addq	%r10, %rsi
	cmpl	%edx, %r9d
	jg	.L13
	addq	%r8, %rcx
	addl	$1, %ebp
	addq	%r15, %rdi
	addq	$4, %r13
	movq	%rcx, (%r11)
	addq	%r15, %r11
	cmpl	4(%rsp), %ebx
	jne	.L14
.L11:
	subl	$1, 4(%rsp)
	leal	1(%r9), %eax
	addl	$1, 32(%rsp)
	addq	$8, 48(%rsp)
	cmpl	%r9d, 36(%rsp)
	je	.L5
	movl	%eax, %r9d
	jmp	.L19
	.p2align 4,,10
	.p2align 3
.L32:
	xorl	%r8d, %r8d
	jmp	.L18
.L23:
	movl	%ebx, %eax
	xorl	%r8d, %r8d
	jmp	.L15
.L2:
	addl	$1, %ebx
	movl	$8, %esi
	imull	%ebx, %ebx
	movslq	%ebx, %rdi
	call	calloc@PLT
	movq	%rax, 40(%rsp)
.L5:
	movq	40(%rsp), %rax
	movq	56(%rsp), %rbx
	movl	$1, %edi
	leaq	.LC1(%rip), %rsi
	movq	(%rax,%rbx,8), %rdx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	72(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L33
	addq	$88, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	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
.L33:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE39:
	.size	run, .-run
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB40:
	.cfi_startproc
	endbr64
	subq	$8, %rsp
	.cfi_def_cfa_offset 16
	call	run
	xorl	%eax, %eax
	addq	$8, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE40:
	.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>

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

#define POS(i,j) ((i)*(n+1)+(j))

void run(void){
  int n;
  scanf("%d",&n);
  int *a=(int *)calloc(n,sizeof(int));
  int i;
  for(i=0;i<n;i++) scanf("%d",a+i);
  int64 *dp=(int64 *)calloc((n+1)*(n+1),sizeof(int64));
  for(int len=2;len<=n;len++){
    for(i=0;i<=n-len;i++){
      int64 sum=0;
      int j;
      for(j=i;j<i+len;j++) sum+=a[j];
      int64 local=dp[POS(i,1)]+dp[POS(i+1,len-1)];
      for(j=2;j<len;j++) local=MIN(local,dp[POS(i,j)]+dp[POS(i+j,len-j)]);
      dp[POS(i,len)]=local+sum;
    }
  }
  printf("%lld\n",dp[POS(0,n)]);
}

int main(void){
  run();
  return 0;
}
6
7 9 8 6 1 1
 5
10 8 10 10 10
 3
1001000000 1000000000 1000000000
 4
10 20 30 46
 6
7 9 13 6 1 1
 5
19 8 10 10 10
 3
1001000000 1000000001 1000000000
 4
10 5 30 46
 6
7 9 13 6 1 2
 5
19 8 10 10 1

74
 114
 5001000000
 196
 84
 132
 5001000002
 151
 88
 106

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>

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

#define POS(i,j) ((i)*(n+1)+(j))

void run(void){
  int n;
  scanf("%d",&n);
  int *a=(int *)calloc(n,sizeof(int));
  int i;
  for(i=0;i<n;i++) scanf("%d",a+i);
  int64 *dp=(int64 *)calloc((n+1)*(n+1),sizeof(int64));
  for(int len=2;len<=n;len++){
    for(i=0;i<=n-len;i++){
      int64 sum=0;
      int j;
      for(j=i;j<i+len;j++) sum+=a[j];
      int64 local=dp[POS(i,1)]+dp[POS(i+1,len-1)];
      for(j=2;j<len;j++) local=MIN(local,dp[POS(i,j)]+dp[POS(i+j,len-j)]);
      dp[POS(i,len)]=local+sum;
    }
  }
  printf("%lld\n",dp[POS(0,n)]);
}

int main(void){
  run();
  return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%lld\n"
	.text
	.globl	run
	.type	run, @function
run:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$64, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-56(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-56(%rbp), %eax
	cltq
	movl	$4, %esi
	movq	%rax, %rdi
	call	calloc@PLT
	movq	%rax, -24(%rbp)
	movl	$0, -52(%rbp)
	jmp	.L2
.L3:
	movl	-52(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -52(%rbp)
.L2:
	movl	-56(%rbp), %eax
	cmpl	%eax, -52(%rbp)
	jl	.L3
	movl	-56(%rbp), %eax
	leal	1(%rax), %edx
	movl	-56(%rbp), %eax
	addl	$1, %eax
	imull	%edx, %eax
	cltq
	movl	$8, %esi
	movq	%rax, %rdi
	call	calloc@PLT
	movq	%rax, -16(%rbp)
	movl	$2, -48(%rbp)
	jmp	.L4
.L11:
	movl	$0, -52(%rbp)
	jmp	.L5
.L10:
	movq	$0, -40(%rbp)
	movl	-52(%rbp), %eax
	movl	%eax, -44(%rbp)
	jmp	.L6
.L7:
	movl	-44(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cltq
	addq	%rax, -40(%rbp)
	addl	$1, -44(%rbp)
.L6:
	movl	-52(%rbp), %edx
	movl	-48(%rbp), %eax
	addl	%edx, %eax
	cmpl	%eax, -44(%rbp)
	jl	.L7
	movl	-56(%rbp), %eax
	addl	$1, %eax
	imull	-52(%rbp), %eax
	cltq
	addq	$1, %rax
	leaq	0(,%rax,8), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rcx
	movl	-52(%rbp), %eax
	leal	1(%rax), %edx
	movl	-56(%rbp), %eax
	addl	$1, %eax
	imull	%eax, %edx
	movl	-48(%rbp), %eax
	subl	$1, %eax
	addl	%edx, %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rax
	addq	%rcx, %rax
	movq	%rax, -32(%rbp)
	movl	$2, -44(%rbp)
	jmp	.L8
.L9:
	movl	-56(%rbp), %eax
	addl	$1, %eax
	imull	-52(%rbp), %eax
	movl	%eax, %edx
	movl	-44(%rbp), %eax
	addl	%edx, %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rcx
	movl	-52(%rbp), %edx
	movl	-44(%rbp), %eax
	addl	%eax, %edx
	movl	-56(%rbp), %eax
	addl	$1, %eax
	imull	%eax, %edx
	movl	-48(%rbp), %eax
	subl	-44(%rbp), %eax
	addl	%edx, %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rax
	leaq	(%rcx,%rax), %rdx
	movq	-32(%rbp), %rax
	cmpq	%rdx, %rax
	cmovg	%rdx, %rax
	movq	%rax, -32(%rbp)
	addl	$1, -44(%rbp)
.L8:
	movl	-44(%rbp), %eax
	cmpl	-48(%rbp), %eax
	jl	.L9
	movl	-56(%rbp), %eax
	addl	$1, %eax
	imull	-52(%rbp), %eax
	movl	%eax, %edx
	movl	-48(%rbp), %eax
	addl	%edx, %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movq	-32(%rbp), %rcx
	movq	-40(%rbp), %rdx
	addq	%rcx, %rdx
	movq	%rdx, (%rax)
	addl	$1, -52(%rbp)
.L5:
	movl	-56(%rbp), %eax
	subl	-48(%rbp), %eax
	cmpl	%eax, -52(%rbp)
	jle	.L10
	addl	$1, -48(%rbp)
.L4:
	movl	-56(%rbp), %eax
	cmpl	%eax, -48(%rbp)
	jle	.L11
	movl	-56(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	nop
	movq	-8(%rbp), %rax
	subq	%fs:40, %rax
	je	.L12
	call	__stack_chk_fail@PLT
.L12:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	run, .-run
	.globl	main
	.type	main, @function
main:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	call	run
	movl	$0, %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.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	run
	.type	run, @function
run:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$64, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-56(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-56(%rbp), %eax
	cltq
	movl	$4, %esi
	movq	%rax, %rdi
	call	calloc@PLT
	movq	%rax, -24(%rbp)
	movl	$0, -52(%rbp)
	jmp	.L2
.L3:
	movl	-52(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -52(%rbp)
.L2:
	movl	-56(%rbp), %eax
	cmpl	%eax, -52(%rbp)
	jl	.L3
	movl	-56(%rbp), %eax
	leal	1(%rax), %edx
	movl	-56(%rbp), %eax
	addl	$1, %eax
	imull	%edx, %eax
	cltq
	movl	$8, %esi
	movq	%rax, %rdi
	call	calloc@PLT
	movq	%rax, -16(%rbp)
	movl	$2, -48(%rbp)
	jmp	.L4
.L11:
	movl	$0, -52(%rbp)
	jmp	.L5
.L10:
	movq	$0, -40(%rbp)
	movl	-52(%rbp), %eax
	movl	%eax, -44(%rbp)
	jmp	.L6
.L7:
	movl	-44(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cltq
	addq	%rax, -40(%rbp)
	addl	$1, -44(%rbp)
.L6:
	movl	-52(%rbp), %edx
	movl	-48(%rbp), %eax
	addl	%edx, %eax
	cmpl	%eax, -44(%rbp)
	jl	.L7
	movl	-56(%rbp), %eax
	addl	$1, %eax
	imull	-52(%rbp), %eax
	cltq
	addq	$1, %rax
	leaq	0(,%rax,8), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rcx
	movl	-52(%rbp), %eax
	leal	1(%rax), %edx
	movl	-56(%rbp), %eax
	addl	$1, %eax
	imull	%eax, %edx
	movl	-48(%rbp), %eax
	subl	$1, %eax
	addl	%edx, %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rax
	addq	%rcx, %rax
	movq	%rax, -32(%rbp)
	movl	$2, -44(%rbp)
	jmp	.L8
.L9:
	movl	-56(%rbp), %eax
	addl	$1, %eax
	imull	-52(%rbp), %eax
	movl	%eax, %edx
	movl	-44(%rbp), %eax
	addl	%edx, %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rcx
	movl	-52(%rbp), %edx
	movl	-44(%rbp), %eax
	addl	%eax, %edx
	movl	-56(%rbp), %eax
	addl	$1, %eax
	imull	%eax, %edx
	movl	-48(%rbp), %eax
	subl	-44(%rbp), %eax
	addl	%edx, %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rax
	leaq	(%rcx,%rax), %rdx
	movq	-32(%rbp), %rax
	cmpq	%rdx, %rax
	cmovg	%rdx, %rax
	movq	%rax, -32(%rbp)
	addl	$1, -44(%rbp)
.L8:
	movl	-44(%rbp), %eax
	cmpl	-48(%rbp), %eax
	jl	.L9
	movl	-56(%rbp), %eax
	addl	$1, %eax
	imull	-52(%rbp), %eax
	movl	%eax, %edx
	movl	-48(%rbp), %eax
	addl	%edx, %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movq	-32(%rbp), %rcx
	movq	-40(%rbp), %rdx
	addq	%rcx, %rdx
	movq	%rdx, (%rax)
	addl	$1, -52(%rbp)
.L5:
	movl	-56(%rbp), %eax
	subl	-48(%rbp), %eax
	cmpl	%eax, -52(%rbp)
	jle	.L10
	addl	$1, -48(%rbp)
.L4:
	movl	-56(%rbp), %eax
	cmpl	%eax, -48(%rbp)
	jle	.L11
	movl	-56(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	nop
	movq	-8(%rbp), %rax
	subq	%fs:40, %rax
	je	.L12
	call	__stack_chk_fail@PLT
.L12:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	run, .-run
	.globl	main
	.type	main, @function
main:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	call	run
	movl	$0, %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.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:
