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 <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

ll a[410];
ll cum[410];
ll dp[410][410];//dp[i][j]=[i,j)を1体にまとめるための最小コスト
int flag[410][410];

ll f(int l,int r){
	if(r-l==1)return 0;
	if(flag[l][r])return dp[l][r];
	flag[l][r]=1;
	ll ans=INF;
	rep(k,l+1,r){
		ll temp=f(l,k)+f(k,r)+cum[r]-cum[l];
		ans=min(ans,temp);
	}
	return dp[l][r]=ans;
}

int main(){
	ll n;
	scanf("%lld",&n);
	rep(i,0,n)scanf("%lld",a+i);
	rep(i,0,n)cum[i+1]=cum[i]+a[i];
	printf("%lld\n",f(0,n));
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	upll
	.type	upll, @function
upll:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -8(%rbp)
	movq	%rsi, -16(%rbp)
	movq	-8(%rbp), %rax
	movq	(%rax), %rdx
	movq	-16(%rbp), %rax
	movq	(%rax), %rax
	cmpq	%rax, %rdx
	jl	.L2
	movq	-8(%rbp), %rax
	movq	(%rax), %rdx
	movq	-16(%rbp), %rax
	movq	(%rax), %rax
	cmpq	%rax, %rdx
	setg	%al
	movzbl	%al, %eax
	jmp	.L4
.L2:
	movl	$-1, %eax
.L4:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	upll, .-upll
	.globl	downll
	.type	downll, @function
downll:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -8(%rbp)
	movq	%rsi, -16(%rbp)
	movq	-8(%rbp), %rax
	movq	(%rax), %rdx
	movq	-16(%rbp), %rax
	movq	(%rax), %rax
	cmpq	%rax, %rdx
	jl	.L6
	movq	-8(%rbp), %rax
	movq	(%rax), %rdx
	movq	-16(%rbp), %rax
	movq	(%rax), %rax
	cmpq	%rax, %rdx
	jle	.L7
	movl	$-1, %eax
	jmp	.L10
.L7:
	movl	$0, %eax
	jmp	.L10
.L6:
	movl	$1, %eax
.L10:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	downll, .-downll
	.globl	sortup
	.type	sortup, @function
sortup:
.LFB8:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$16, %rsp
	movq	%rdi, -8(%rbp)
	movl	%esi, -12(%rbp)
	movl	-12(%rbp), %eax
	movslq	%eax, %rsi
	movq	-8(%rbp), %rax
	leaq	upll(%rip), %rdx
	movq	%rdx, %rcx
	movl	$8, %edx
	movq	%rax, %rdi
	call	qsort@PLT
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.size	sortup, .-sortup
	.globl	sortdown
	.type	sortdown, @function
sortdown:
.LFB9:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$16, %rsp
	movq	%rdi, -8(%rbp)
	movl	%esi, -12(%rbp)
	movl	-12(%rbp), %eax
	movslq	%eax, %rsi
	movq	-8(%rbp), %rax
	leaq	downll(%rip), %rdx
	movq	%rdx, %rcx
	movl	$8, %edx
	movq	%rax, %rdi
	call	qsort@PLT
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE9:
	.size	sortdown, .-sortdown
	.globl	pom
	.type	pom, @function
pom:
.LFB10:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -24(%rbp)
	movq	%rsi, -32(%rbp)
	movl	%edx, -36(%rbp)
	movq	$1, -8(%rbp)
	movl	-36(%rbp), %eax
	movslq	%eax, %rcx
	movq	-24(%rbp), %rax
	cqto
	idivq	%rcx
	movq	%rdx, -24(%rbp)
	jmp	.L14
.L17:
	movq	-32(%rbp), %rax
	andl	$1, %eax
	testq	%rax, %rax
	je	.L16
	movq	-8(%rbp), %rax
	imulq	-24(%rbp), %rax
	movl	-36(%rbp), %edx
	movslq	%edx, %rcx
	cqto
	idivq	%rcx
	movq	%rdx, -8(%rbp)
.L16:
	movq	-24(%rbp), %rax
	imulq	%rax, %rax
	movl	-36(%rbp), %edx
	movslq	%edx, %rcx
	cqto
	idivq	%rcx
	movq	%rdx, -24(%rbp)
	movq	-32(%rbp), %rax
	movq	%rax, %rdx
	shrq	$63, %rdx
	addq	%rdx, %rax
	sarq	%rax
	movq	%rax, -32(%rbp)
.L14:
	cmpq	$0, -32(%rbp)
	jne	.L17
	movq	-8(%rbp), %rax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE10:
	.size	pom, .-pom
	.globl	a
	.bss
	.align 32
	.type	a, @object
	.size	a, 3280
a:
	.zero	3280
	.globl	cum
	.align 32
	.type	cum, @object
	.size	cum, 3280
cum:
	.zero	3280
	.globl	dp
	.align 32
	.type	dp, @object
	.size	dp, 1344800
dp:
	.zero	1344800
	.globl	flag
	.align 32
	.type	flag, @object
	.size	flag, 672400
flag:
	.zero	672400
	.text
	.globl	f
	.type	f, @function
f:
.LFB11:
	.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	$56, %rsp
	.cfi_offset 3, -24
	movl	%edi, -52(%rbp)
	movl	%esi, -56(%rbp)
	movl	-56(%rbp), %eax
	subl	-52(%rbp), %eax
	cmpl	$1, %eax
	jne	.L20
	movl	$0, %eax
	jmp	.L21
.L20:
	movl	-56(%rbp), %eax
	movslq	%eax, %rdx
	movl	-52(%rbp), %eax
	cltq
	imulq	$410, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	flag(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	je	.L22
	movl	-56(%rbp), %eax
	movslq	%eax, %rdx
	movl	-52(%rbp), %eax
	cltq
	imulq	$410, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rdx
	leaq	dp(%rip), %rax
	movq	(%rdx,%rax), %rax
	jmp	.L21
.L22:
	movl	-56(%rbp), %eax
	movslq	%eax, %rdx
	movl	-52(%rbp), %eax
	cltq
	imulq	$410, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	flag(%rip), %rax
	movl	$1, (%rdx,%rax)
	movabsq	$4611686016279904256, %rax
	movq	%rax, -40(%rbp)
	movl	-52(%rbp), %eax
	addl	$1, %eax
	cltq
	movq	%rax, -32(%rbp)
	jmp	.L23
.L24:
	movq	-32(%rbp), %rax
	movl	%eax, %edx
	movl	-52(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	f
	movq	%rax, %rbx
	movq	-32(%rbp), %rax
	movl	%eax, %edx
	movl	-56(%rbp), %eax
	movl	%eax, %esi
	movl	%edx, %edi
	call	f
	leaq	(%rbx,%rax), %rcx
	movl	-56(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	cum(%rip), %rax
	movq	(%rdx,%rax), %rax
	addq	%rax, %rcx
	movl	-52(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	cum(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movq	%rcx, %rax
	subq	%rdx, %rax
	movq	%rax, -24(%rbp)
	movq	-40(%rbp), %rdx
	movq	-24(%rbp), %rax
	cmpq	%rax, %rdx
	cmovle	%rdx, %rax
	movq	%rax, -40(%rbp)
	addq	$1, -32(%rbp)
.L23:
	movl	-56(%rbp), %eax
	cltq
	cmpq	%rax, -32(%rbp)
	jl	.L24
	movl	-56(%rbp), %eax
	movslq	%eax, %rdx
	movl	-52(%rbp), %eax
	cltq
	imulq	$410, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rcx
	leaq	dp(%rip), %rdx
	movq	-40(%rbp), %rax
	movq	%rax, (%rcx,%rdx)
	movl	-56(%rbp), %eax
	movslq	%eax, %rdx
	movl	-52(%rbp), %eax
	cltq
	imulq	$410, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rdx
	leaq	dp(%rip), %rax
	movq	(%rdx,%rax), %rax
.L21:
	movq	-8(%rbp), %rbx
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE11:
	.size	f, .-f
	.section	.rodata
.LC0:
	.string	"%lld"
.LC1:
	.string	"%lld\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB12:
	.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	-32(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	$0, -24(%rbp)
	jmp	.L26
.L27:
	movq	-24(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	leaq	a(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addq	$1, -24(%rbp)
.L26:
	movq	-32(%rbp), %rax
	cmpq	%rax, -24(%rbp)
	jl	.L27
	movq	$0, -16(%rbp)
	jmp	.L28
.L29:
	movq	-16(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	leaq	cum(%rip), %rax
	movq	(%rdx,%rax), %rcx
	movq	-16(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	leaq	a(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movq	-16(%rbp), %rax
	addq	$1, %rax
	addq	%rdx, %rcx
	leaq	0(,%rax,8), %rdx
	leaq	cum(%rip), %rax
	movq	%rcx, (%rdx,%rax)
	addq	$1, -16(%rbp)
.L28:
	movq	-32(%rbp), %rax
	cmpq	%rax, -16(%rbp)
	jl	.L29
	movq	-32(%rbp), %rax
	movl	%eax, %esi
	movl	$0, %edi
	call	f
	movq	%rax, %rsi
	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	.L31
	call	__stack_chk_fail@PLT
.L31:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE12:
	.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
	.p2align 4
	.globl	upll
	.type	upll, @function
upll:
.LFB51:
	.cfi_startproc
	endbr64
	movq	(%rsi), %rax
	cmpq	%rax, (%rdi)
	movl	$-1, %edx
	setg	%al
	movzbl	%al, %eax
	cmovl	%edx, %eax
	ret
	.cfi_endproc
.LFE51:
	.size	upll, .-upll
	.p2align 4
	.globl	downll
	.type	downll, @function
downll:
.LFB52:
	.cfi_startproc
	endbr64
	movq	(%rsi), %rdx
	movl	$1, %eax
	cmpq	%rdx, (%rdi)
	jl	.L5
	setg	%al
	movzbl	%al, %eax
	negl	%eax
.L5:
	ret
	.cfi_endproc
.LFE52:
	.size	downll, .-downll
	.p2align 4
	.type	f.part.0, @function
f.part.0:
.LFB58:
	.cfi_startproc
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	flag(%rip), %r8
	leaq	dp(%rip), %r10
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movslq	%edi, %r14
	imulq	$410, %r14, %r9
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movabsq	$4611686016279904256, %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movslq	%esi, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	leal	1(%r14), %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	leaq	(%r9,%r12), %rax
	movslq	%ebp, %rbp
	subq	$40, %rsp
	.cfi_def_cfa_offset 96
	movl	$1, (%r8,%rax,4)
	cmpq	%r12, %rbp
	jge	.L9
	movq	%r14, %r15
	movq	%r12, %rdx
	leaq	cum(%rip), %rcx
.L14:
	movl	%ebp, %eax
	movl	%ebp, %r11d
	xorl	%ebx, %ebx
	subl	%r15d, %eax
	cmpl	$1, %eax
	je	.L10
	movslq	%ebp, %rax
	addq	%r9, %rax
	movl	(%r8,%rax,4), %edi
	testl	%edi, %edi
	jne	.L23
	movl	%ebp, %esi
	movl	%r15d, %edi
	movq	%r9, 24(%rsp)
	movl	%edx, 16(%rsp)
	movl	%ebp, 12(%rsp)
	call	f.part.0
	movq	24(%rsp), %r9
	movl	16(%rsp), %edx
	leaq	flag(%rip), %r8
	movl	12(%rsp), %r11d
	movq	%rax, %rbx
	leaq	cum(%rip), %rcx
	leaq	dp(%rip), %r10
.L10:
	movl	%edx, %eax
	subl	%r11d, %eax
	cmpl	$1, %eax
	je	.L12
	movslq	%r11d, %rax
	imulq	$410, %rax, %rax
	addq	%r12, %rax
	movl	(%r8,%rax,4), %esi
	testl	%esi, %esi
	jne	.L24
	movl	%edx, %esi
	movl	%r11d, %edi
	movq	%r9, 16(%rsp)
	movl	%edx, 12(%rsp)
	call	f.part.0
	movq	16(%rsp), %r9
	movl	12(%rsp), %edx
	leaq	flag(%rip), %r8
	addq	%rax, %rbx
	leaq	cum(%rip), %rcx
	leaq	dp(%rip), %r10
.L12:
	addq	(%rcx,%r12,8), %rbx
	subq	(%rcx,%r14,8), %rbx
	cmpq	%rbx, %r13
	cmovg	%rbx, %r13
	addq	$1, %rbp
	cmpq	%r12, %rbp
	jne	.L14
.L9:
	imulq	$410, %r14, %r14
	movq	%r13, %rax
	addq	%r12, %r14
	movq	%r13, (%r10,%r14,8)
	addq	$40, %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
	.p2align 4,,10
	.p2align 3
.L24:
	.cfi_restore_state
	addq	(%r10,%rax,8), %rbx
	jmp	.L12
	.p2align 4,,10
	.p2align 3
.L23:
	movq	(%r10,%rax,8), %rbx
	jmp	.L10
	.cfi_endproc
.LFE58:
	.size	f.part.0, .-f.part.0
	.p2align 4
	.globl	sortup
	.type	sortup, @function
sortup:
.LFB53:
	.cfi_startproc
	endbr64
	movslq	%esi, %rsi
	leaq	upll(%rip), %rcx
	movl	$8, %edx
	jmp	qsort@PLT
	.cfi_endproc
.LFE53:
	.size	sortup, .-sortup
	.p2align 4
	.globl	sortdown
	.type	sortdown, @function
sortdown:
.LFB54:
	.cfi_startproc
	endbr64
	movslq	%esi, %rsi
	leaq	downll(%rip), %rcx
	movl	$8, %edx
	jmp	qsort@PLT
	.cfi_endproc
.LFE54:
	.size	sortdown, .-sortdown
	.p2align 4
	.globl	pom
	.type	pom, @function
pom:
.LFB55:
	.cfi_startproc
	endbr64
	movq	%rdi, %rax
	movslq	%edx, %r8
	movl	$1, %r9d
	cqto
	idivq	%r8
	movq	%rdx, %rcx
	testq	%rsi, %rsi
	je	.L27
	.p2align 4,,10
	.p2align 3
.L30:
	testb	$1, %sil
	je	.L29
	movq	%r9, %rax
	imulq	%rcx, %rax
	cqto
	idivq	%r8
	movq	%rdx, %r9
.L29:
	imulq	%rcx, %rcx
	movq	%rcx, %rax
	cqto
	idivq	%r8
	movq	%rsi, %rax
	shrq	$63, %rax
	addq	%rax, %rsi
	sarq	%rsi
	movq	%rdx, %rcx
	jne	.L30
.L27:
	movq	%r9, %rax
	ret
	.cfi_endproc
.LFE55:
	.size	pom, .-pom
	.p2align 4
	.globl	f
	.type	f, @function
f:
.LFB56:
	.cfi_startproc
	endbr64
	movl	%esi, %eax
	subl	%edi, %eax
	cmpl	$1, %eax
	je	.L39
	movslq	%edi, %rax
	movslq	%esi, %rdx
	imulq	$410, %rax, %rax
	addq	%rdx, %rax
	leaq	flag(%rip), %rdx
	movl	(%rdx,%rax,4), %edx
	testl	%edx, %edx
	jne	.L40
	jmp	f.part.0
	.p2align 4,,10
	.p2align 3
.L40:
	leaq	dp(%rip), %rdx
	movq	(%rdx,%rax,8), %rax
	ret
	.p2align 4,,10
	.p2align 3
.L39:
	xorl	%eax, %eax
	ret
	.cfi_endproc
.LFE56:
	.size	f, .-f
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%lld"
.LC1:
	.string	"%lld\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB57:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	leaq	.LC0(%rip), %r13
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	movq	%r13, %rdi
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	subq	$24, %rsp
	.cfi_def_cfa_offset 64
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	movq	%rsp, %rsi
	call	__isoc99_scanf@PLT
	movq	(%rsp), %rsi
	testq	%rsi, %rsi
	jle	.L42
	leaq	a(%rip), %r12
	xorl	%ebx, %ebx
	movq	%r12, %rbp
	.p2align 4,,10
	.p2align 3
.L43:
	movq	%rbp, %rsi
	movq	%r13, %rdi
	xorl	%eax, %eax
	addq	$1, %rbx
	call	__isoc99_scanf@PLT
	movq	(%rsp), %rax
	addq	$8, %rbp
	cmpq	%rbx, %rax
	jg	.L43
	testq	%rax, %rax
	jle	.L46
	movq	cum(%rip), %rdx
	xorl	%esi, %esi
	leaq	cum(%rip), %rdi
	.p2align 4,,10
	.p2align 3
.L44:
	movq	(%r12,%rsi,8), %rcx
	addq	$1, %rsi
	addq	%rcx, %rdx
	movq	%rdx, (%rdi,%rsi,8)
	cmpq	%rsi, %rax
	jne	.L44
.L42:
	xorl	%edi, %edi
	call	f
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	movq	%rax, %rdx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L50
	addq	$24, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
.L46:
	.cfi_restore_state
	movq	%rax, %rsi
	jmp	.L42
.L50:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE57:
	.size	main, .-main
	.globl	flag
	.bss
	.align 32
	.type	flag, @object
	.size	flag, 672400
flag:
	.zero	672400
	.globl	dp
	.align 32
	.type	dp, @object
	.size	dp, 1344800
dp:
	.zero	1344800
	.globl	cum
	.align 32
	.type	cum, @object
	.size	cum, 3280
cum:
	.zero	3280
	.globl	a
	.align 32
	.type	a, @object
	.size	a, 3280
a:
	.zero	3280
	.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
	.p2align 4
	.globl	upll
	.type	upll, @function
upll:
.LFB51:
	.cfi_startproc
	endbr64
	movq	(%rsi), %rax
	cmpq	%rax, (%rdi)
	movl	$-1, %edx
	setg	%al
	movzbl	%al, %eax
	cmovl	%edx, %eax
	ret
	.cfi_endproc
.LFE51:
	.size	upll, .-upll
	.p2align 4
	.globl	downll
	.type	downll, @function
downll:
.LFB52:
	.cfi_startproc
	endbr64
	movq	(%rsi), %rdx
	movl	$1, %eax
	cmpq	%rdx, (%rdi)
	jl	.L5
	setg	%al
	movzbl	%al, %eax
	negl	%eax
.L5:
	ret
	.cfi_endproc
.LFE52:
	.size	downll, .-downll
	.p2align 4
	.type	f.part.0, @function
f.part.0:
.LFB58:
	.cfi_startproc
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	flag(%rip), %r8
	leaq	dp(%rip), %r10
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movslq	%edi, %r14
	imulq	$410, %r14, %r9
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movabsq	$4611686016279904256, %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movslq	%esi, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	leal	1(%r14), %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	leaq	(%r9,%r12), %rax
	movslq	%ebp, %rbp
	subq	$40, %rsp
	.cfi_def_cfa_offset 96
	movl	$1, (%r8,%rax,4)
	cmpq	%r12, %rbp
	jge	.L9
	movq	%r14, %r15
	movq	%r12, %rdx
	leaq	cum(%rip), %rcx
.L14:
	movl	%ebp, %eax
	movl	%ebp, %r11d
	xorl	%ebx, %ebx
	subl	%r15d, %eax
	cmpl	$1, %eax
	je	.L10
	movslq	%ebp, %rax
	addq	%r9, %rax
	movl	(%r8,%rax,4), %edi
	testl	%edi, %edi
	jne	.L23
	movl	%ebp, %esi
	movl	%r15d, %edi
	movq	%r9, 24(%rsp)
	movl	%edx, 16(%rsp)
	movl	%ebp, 12(%rsp)
	call	f.part.0
	movq	24(%rsp), %r9
	movl	16(%rsp), %edx
	leaq	flag(%rip), %r8
	movl	12(%rsp), %r11d
	movq	%rax, %rbx
	leaq	cum(%rip), %rcx
	leaq	dp(%rip), %r10
.L10:
	movl	%edx, %eax
	subl	%r11d, %eax
	cmpl	$1, %eax
	je	.L12
	movslq	%r11d, %rax
	imulq	$410, %rax, %rax
	addq	%r12, %rax
	movl	(%r8,%rax,4), %esi
	testl	%esi, %esi
	jne	.L24
	movl	%edx, %esi
	movl	%r11d, %edi
	movq	%r9, 16(%rsp)
	movl	%edx, 12(%rsp)
	call	f.part.0
	movq	16(%rsp), %r9
	movl	12(%rsp), %edx
	leaq	flag(%rip), %r8
	addq	%rax, %rbx
	leaq	cum(%rip), %rcx
	leaq	dp(%rip), %r10
.L12:
	addq	(%rcx,%r12,8), %rbx
	subq	(%rcx,%r14,8), %rbx
	cmpq	%rbx, %r13
	cmovg	%rbx, %r13
	addq	$1, %rbp
	cmpq	%r12, %rbp
	jne	.L14
.L9:
	imulq	$410, %r14, %r14
	movq	%r13, %rax
	addq	%r12, %r14
	movq	%r13, (%r10,%r14,8)
	addq	$40, %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
	.p2align 4,,10
	.p2align 3
.L24:
	.cfi_restore_state
	addq	(%r10,%rax,8), %rbx
	jmp	.L12
	.p2align 4,,10
	.p2align 3
.L23:
	movq	(%r10,%rax,8), %rbx
	jmp	.L10
	.cfi_endproc
.LFE58:
	.size	f.part.0, .-f.part.0
	.p2align 4
	.globl	sortup
	.type	sortup, @function
sortup:
.LFB53:
	.cfi_startproc
	endbr64
	movslq	%esi, %rsi
	leaq	upll(%rip), %rcx
	movl	$8, %edx
	jmp	qsort@PLT
	.cfi_endproc
.LFE53:
	.size	sortup, .-sortup
	.p2align 4
	.globl	sortdown
	.type	sortdown, @function
sortdown:
.LFB54:
	.cfi_startproc
	endbr64
	movslq	%esi, %rsi
	leaq	downll(%rip), %rcx
	movl	$8, %edx
	jmp	qsort@PLT
	.cfi_endproc
.LFE54:
	.size	sortdown, .-sortdown
	.p2align 4
	.globl	pom
	.type	pom, @function
pom:
.LFB55:
	.cfi_startproc
	endbr64
	movq	%rdi, %rax
	movslq	%edx, %r8
	movl	$1, %r9d
	cqto
	idivq	%r8
	movq	%rdx, %rcx
	testq	%rsi, %rsi
	je	.L27
	.p2align 4,,10
	.p2align 3
.L30:
	testb	$1, %sil
	je	.L29
	movq	%r9, %rax
	imulq	%rcx, %rax
	cqto
	idivq	%r8
	movq	%rdx, %r9
.L29:
	imulq	%rcx, %rcx
	movq	%rcx, %rax
	cqto
	idivq	%r8
	movq	%rsi, %rax
	shrq	$63, %rax
	addq	%rax, %rsi
	sarq	%rsi
	movq	%rdx, %rcx
	jne	.L30
.L27:
	movq	%r9, %rax
	ret
	.cfi_endproc
.LFE55:
	.size	pom, .-pom
	.p2align 4
	.globl	f
	.type	f, @function
f:
.LFB56:
	.cfi_startproc
	endbr64
	movl	%esi, %eax
	subl	%edi, %eax
	cmpl	$1, %eax
	je	.L39
	movslq	%edi, %rax
	movslq	%esi, %rdx
	imulq	$410, %rax, %rax
	addq	%rdx, %rax
	leaq	flag(%rip), %rdx
	movl	(%rdx,%rax,4), %edx
	testl	%edx, %edx
	jne	.L40
	jmp	f.part.0
	.p2align 4,,10
	.p2align 3
.L40:
	leaq	dp(%rip), %rdx
	movq	(%rdx,%rax,8), %rax
	ret
	.p2align 4,,10
	.p2align 3
.L39:
	xorl	%eax, %eax
	ret
	.cfi_endproc
.LFE56:
	.size	f, .-f
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%lld"
.LC1:
	.string	"%lld\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB57:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	leaq	.LC0(%rip), %r13
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	movq	%r13, %rdi
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	subq	$24, %rsp
	.cfi_def_cfa_offset 64
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	movq	%rsp, %rsi
	call	__isoc99_scanf@PLT
	movq	(%rsp), %rsi
	testq	%rsi, %rsi
	jle	.L42
	leaq	a(%rip), %r12
	xorl	%ebx, %ebx
	movq	%r12, %rbp
	.p2align 4,,10
	.p2align 3
.L43:
	movq	%rbp, %rsi
	movq	%r13, %rdi
	xorl	%eax, %eax
	addq	$1, %rbx
	call	__isoc99_scanf@PLT
	movq	(%rsp), %rax
	addq	$8, %rbp
	cmpq	%rbx, %rax
	jg	.L43
	testq	%rax, %rax
	jle	.L46
	movq	cum(%rip), %rdx
	xorl	%esi, %esi
	leaq	cum(%rip), %rdi
	.p2align 4,,10
	.p2align 3
.L44:
	movq	(%r12,%rsi,8), %rcx
	addq	$1, %rsi
	addq	%rcx, %rdx
	movq	%rdx, (%rdi,%rsi,8)
	cmpq	%rsi, %rax
	jne	.L44
.L42:
	xorl	%edi, %edi
	call	f
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	movq	%rax, %rdx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L50
	addq	$24, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
.L46:
	.cfi_restore_state
	movq	%rax, %rsi
	jmp	.L42
.L50:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE57:
	.size	main, .-main
	.globl	flag
	.bss
	.align 32
	.type	flag, @object
	.size	flag, 672400
flag:
	.zero	672400
	.globl	dp
	.align 32
	.type	dp, @object
	.size	dp, 1344800
dp:
	.zero	1344800
	.globl	cum
	.align 32
	.type	cum, @object
	.size	cum, 3280
cum:
	.zero	3280
	.globl	a
	.align 32
	.type	a, @object
	.size	a, 3280
a:
	.zero	3280
	.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 <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

ll a[410];
ll cum[410];
ll dp[410][410];//dp[i][j]=[i,j)を1体にまとめるための最小コスト
int flag[410][410];

ll f(int l,int r){
	if(r-l==1)return 0;
	if(flag[l][r])return dp[l][r];
	flag[l][r]=1;
	ll ans=INF;
	rep(k,l+1,r){
		ll temp=f(l,k)+f(k,r)+cum[r]-cum[l];
		ans=min(ans,temp);
	}
	return dp[l][r]=ans;
}

int main(){
	ll n;
	scanf("%lld",&n);
	rep(i,0,n)scanf("%lld",a+i);
	rep(i,0,n)cum[i+1]=cum[i]+a[i];
	printf("%lld\n",f(0,n));
}
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 <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

ll a[410];
ll cum[410];
ll dp[410][410];//dp[i][j]=[i,j)を1体にまとめるための最小コスト
int flag[410][410];

ll f(int l,int r){
	if(r-l==1)return 0;
	if(flag[l][r])return dp[l][r];
	flag[l][r]=1;
	ll ans=INF;
	rep(k,l+1,r){
		ll temp=f(l,k)+f(k,r)+cum[r]-cum[l];
		ans=min(ans,temp);
	}
	return dp[l][r]=ans;
}

int main(){
	ll n;
	scanf("%lld",&n);
	rep(i,0,n)scanf("%lld",a+i);
	rep(i,0,n)cum[i+1]=cum[i]+a[i];
	printf("%lld\n",f(0,n));
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	upll
	.type	upll, @function
upll:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -8(%rbp)
	movq	%rsi, -16(%rbp)
	movq	-8(%rbp), %rax
	movq	(%rax), %rdx
	movq	-16(%rbp), %rax
	movq	(%rax), %rax
	cmpq	%rax, %rdx
	jl	.L2
	movq	-8(%rbp), %rax
	movq	(%rax), %rdx
	movq	-16(%rbp), %rax
	movq	(%rax), %rax
	cmpq	%rax, %rdx
	setg	%al
	movzbl	%al, %eax
	jmp	.L4
.L2:
	movl	$-1, %eax
.L4:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	upll, .-upll
	.globl	downll
	.type	downll, @function
downll:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -8(%rbp)
	movq	%rsi, -16(%rbp)
	movq	-8(%rbp), %rax
	movq	(%rax), %rdx
	movq	-16(%rbp), %rax
	movq	(%rax), %rax
	cmpq	%rax, %rdx
	jl	.L6
	movq	-8(%rbp), %rax
	movq	(%rax), %rdx
	movq	-16(%rbp), %rax
	movq	(%rax), %rax
	cmpq	%rax, %rdx
	jle	.L7
	movl	$-1, %eax
	jmp	.L10
.L7:
	movl	$0, %eax
	jmp	.L10
.L6:
	movl	$1, %eax
.L10:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	downll, .-downll
	.globl	sortup
	.type	sortup, @function
sortup:
.LFB8:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$16, %rsp
	movq	%rdi, -8(%rbp)
	movl	%esi, -12(%rbp)
	movl	-12(%rbp), %eax
	movslq	%eax, %rsi
	movq	-8(%rbp), %rax
	leaq	upll(%rip), %rdx
	movq	%rdx, %rcx
	movl	$8, %edx
	movq	%rax, %rdi
	call	qsort@PLT
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.size	sortup, .-sortup
	.globl	sortdown
	.type	sortdown, @function
sortdown:
.LFB9:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$16, %rsp
	movq	%rdi, -8(%rbp)
	movl	%esi, -12(%rbp)
	movl	-12(%rbp), %eax
	movslq	%eax, %rsi
	movq	-8(%rbp), %rax
	leaq	downll(%rip), %rdx
	movq	%rdx, %rcx
	movl	$8, %edx
	movq	%rax, %rdi
	call	qsort@PLT
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE9:
	.size	sortdown, .-sortdown
	.globl	pom
	.type	pom, @function
pom:
.LFB10:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -24(%rbp)
	movq	%rsi, -32(%rbp)
	movl	%edx, -36(%rbp)
	movq	$1, -8(%rbp)
	movl	-36(%rbp), %eax
	movslq	%eax, %rcx
	movq	-24(%rbp), %rax
	cqto
	idivq	%rcx
	movq	%rdx, -24(%rbp)
	jmp	.L14
.L17:
	movq	-32(%rbp), %rax
	andl	$1, %eax
	testq	%rax, %rax
	je	.L16
	movq	-8(%rbp), %rax
	imulq	-24(%rbp), %rax
	movl	-36(%rbp), %edx
	movslq	%edx, %rcx
	cqto
	idivq	%rcx
	movq	%rdx, -8(%rbp)
.L16:
	movq	-24(%rbp), %rax
	imulq	%rax, %rax
	movl	-36(%rbp), %edx
	movslq	%edx, %rcx
	cqto
	idivq	%rcx
	movq	%rdx, -24(%rbp)
	movq	-32(%rbp), %rax
	movq	%rax, %rdx
	shrq	$63, %rdx
	addq	%rdx, %rax
	sarq	%rax
	movq	%rax, -32(%rbp)
.L14:
	cmpq	$0, -32(%rbp)
	jne	.L17
	movq	-8(%rbp), %rax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE10:
	.size	pom, .-pom
	.globl	a
	.bss
	.align 32
	.type	a, @object
	.size	a, 3280
a:
	.zero	3280
	.globl	cum
	.align 32
	.type	cum, @object
	.size	cum, 3280
cum:
	.zero	3280
	.globl	dp
	.align 32
	.type	dp, @object
	.size	dp, 1344800
dp:
	.zero	1344800
	.globl	flag
	.align 32
	.type	flag, @object
	.size	flag, 672400
flag:
	.zero	672400
	.text
	.globl	f
	.type	f, @function
f:
.LFB11:
	.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	$56, %rsp
	.cfi_offset 3, -24
	movl	%edi, -52(%rbp)
	movl	%esi, -56(%rbp)
	movl	-56(%rbp), %eax
	subl	-52(%rbp), %eax
	cmpl	$1, %eax
	jne	.L20
	movl	$0, %eax
	jmp	.L21
.L20:
	movl	-56(%rbp), %eax
	movslq	%eax, %rdx
	movl	-52(%rbp), %eax
	cltq
	imulq	$410, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	flag(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	je	.L22
	movl	-56(%rbp), %eax
	movslq	%eax, %rdx
	movl	-52(%rbp), %eax
	cltq
	imulq	$410, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rdx
	leaq	dp(%rip), %rax
	movq	(%rdx,%rax), %rax
	jmp	.L21
.L22:
	movl	-56(%rbp), %eax
	movslq	%eax, %rdx
	movl	-52(%rbp), %eax
	cltq
	imulq	$410, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	flag(%rip), %rax
	movl	$1, (%rdx,%rax)
	movabsq	$4611686016279904256, %rax
	movq	%rax, -40(%rbp)
	movl	-52(%rbp), %eax
	addl	$1, %eax
	cltq
	movq	%rax, -32(%rbp)
	jmp	.L23
.L24:
	movq	-32(%rbp), %rax
	movl	%eax, %edx
	movl	-52(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	f
	movq	%rax, %rbx
	movq	-32(%rbp), %rax
	movl	%eax, %edx
	movl	-56(%rbp), %eax
	movl	%eax, %esi
	movl	%edx, %edi
	call	f
	leaq	(%rbx,%rax), %rcx
	movl	-56(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	cum(%rip), %rax
	movq	(%rdx,%rax), %rax
	addq	%rax, %rcx
	movl	-52(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	cum(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movq	%rcx, %rax
	subq	%rdx, %rax
	movq	%rax, -24(%rbp)
	movq	-40(%rbp), %rdx
	movq	-24(%rbp), %rax
	cmpq	%rax, %rdx
	cmovle	%rdx, %rax
	movq	%rax, -40(%rbp)
	addq	$1, -32(%rbp)
.L23:
	movl	-56(%rbp), %eax
	cltq
	cmpq	%rax, -32(%rbp)
	jl	.L24
	movl	-56(%rbp), %eax
	movslq	%eax, %rdx
	movl	-52(%rbp), %eax
	cltq
	imulq	$410, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rcx
	leaq	dp(%rip), %rdx
	movq	-40(%rbp), %rax
	movq	%rax, (%rcx,%rdx)
	movl	-56(%rbp), %eax
	movslq	%eax, %rdx
	movl	-52(%rbp), %eax
	cltq
	imulq	$410, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rdx
	leaq	dp(%rip), %rax
	movq	(%rdx,%rax), %rax
.L21:
	movq	-8(%rbp), %rbx
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE11:
	.size	f, .-f
	.section	.rodata
.LC0:
	.string	"%lld"
.LC1:
	.string	"%lld\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB12:
	.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	-32(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	$0, -24(%rbp)
	jmp	.L26
.L27:
	movq	-24(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	leaq	a(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addq	$1, -24(%rbp)
.L26:
	movq	-32(%rbp), %rax
	cmpq	%rax, -24(%rbp)
	jl	.L27
	movq	$0, -16(%rbp)
	jmp	.L28
.L29:
	movq	-16(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	leaq	cum(%rip), %rax
	movq	(%rdx,%rax), %rcx
	movq	-16(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	leaq	a(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movq	-16(%rbp), %rax
	addq	$1, %rax
	addq	%rdx, %rcx
	leaq	0(,%rax,8), %rdx
	leaq	cum(%rip), %rax
	movq	%rcx, (%rdx,%rax)
	addq	$1, -16(%rbp)
.L28:
	movq	-32(%rbp), %rax
	cmpq	%rax, -16(%rbp)
	jl	.L29
	movq	-32(%rbp), %rax
	movl	%eax, %esi
	movl	$0, %edi
	call	f
	movq	%rax, %rsi
	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	.L31
	call	__stack_chk_fail@PLT
.L31:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE12:
	.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
	.globl	upll
	.type	upll, @function
upll:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -8(%rbp)
	movq	%rsi, -16(%rbp)
	movq	-8(%rbp), %rax
	movq	(%rax), %rdx
	movq	-16(%rbp), %rax
	movq	(%rax), %rax
	cmpq	%rax, %rdx
	jl	.L2
	movq	-8(%rbp), %rax
	movq	(%rax), %rdx
	movq	-16(%rbp), %rax
	movq	(%rax), %rax
	cmpq	%rax, %rdx
	setg	%al
	movzbl	%al, %eax
	jmp	.L4
.L2:
	movl	$-1, %eax
.L4:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	upll, .-upll
	.globl	downll
	.type	downll, @function
downll:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -8(%rbp)
	movq	%rsi, -16(%rbp)
	movq	-8(%rbp), %rax
	movq	(%rax), %rdx
	movq	-16(%rbp), %rax
	movq	(%rax), %rax
	cmpq	%rax, %rdx
	jl	.L6
	movq	-8(%rbp), %rax
	movq	(%rax), %rdx
	movq	-16(%rbp), %rax
	movq	(%rax), %rax
	cmpq	%rax, %rdx
	jle	.L7
	movl	$-1, %eax
	jmp	.L10
.L7:
	movl	$0, %eax
	jmp	.L10
.L6:
	movl	$1, %eax
.L10:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	downll, .-downll
	.globl	sortup
	.type	sortup, @function
sortup:
.LFB8:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$16, %rsp
	movq	%rdi, -8(%rbp)
	movl	%esi, -12(%rbp)
	movl	-12(%rbp), %eax
	movslq	%eax, %rsi
	movq	-8(%rbp), %rax
	leaq	upll(%rip), %rdx
	movq	%rdx, %rcx
	movl	$8, %edx
	movq	%rax, %rdi
	call	qsort@PLT
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.size	sortup, .-sortup
	.globl	sortdown
	.type	sortdown, @function
sortdown:
.LFB9:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$16, %rsp
	movq	%rdi, -8(%rbp)
	movl	%esi, -12(%rbp)
	movl	-12(%rbp), %eax
	movslq	%eax, %rsi
	movq	-8(%rbp), %rax
	leaq	downll(%rip), %rdx
	movq	%rdx, %rcx
	movl	$8, %edx
	movq	%rax, %rdi
	call	qsort@PLT
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE9:
	.size	sortdown, .-sortdown
	.globl	pom
	.type	pom, @function
pom:
.LFB10:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -24(%rbp)
	movq	%rsi, -32(%rbp)
	movl	%edx, -36(%rbp)
	movq	$1, -8(%rbp)
	movl	-36(%rbp), %eax
	movslq	%eax, %rcx
	movq	-24(%rbp), %rax
	cqto
	idivq	%rcx
	movq	%rdx, -24(%rbp)
	jmp	.L14
.L17:
	movq	-32(%rbp), %rax
	andl	$1, %eax
	testq	%rax, %rax
	je	.L16
	movq	-8(%rbp), %rax
	imulq	-24(%rbp), %rax
	movl	-36(%rbp), %edx
	movslq	%edx, %rcx
	cqto
	idivq	%rcx
	movq	%rdx, -8(%rbp)
.L16:
	movq	-24(%rbp), %rax
	imulq	%rax, %rax
	movl	-36(%rbp), %edx
	movslq	%edx, %rcx
	cqto
	idivq	%rcx
	movq	%rdx, -24(%rbp)
	movq	-32(%rbp), %rax
	movq	%rax, %rdx
	shrq	$63, %rdx
	addq	%rdx, %rax
	sarq	%rax
	movq	%rax, -32(%rbp)
.L14:
	cmpq	$0, -32(%rbp)
	jne	.L17
	movq	-8(%rbp), %rax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE10:
	.size	pom, .-pom
	.globl	a
	.bss
	.align 32
	.type	a, @object
	.size	a, 3280
a:
	.zero	3280
	.globl	cum
	.align 32
	.type	cum, @object
	.size	cum, 3280
cum:
	.zero	3280
	.globl	dp
	.align 32
	.type	dp, @object
	.size	dp, 1344800
dp:
	.zero	1344800
	.globl	flag
	.align 32
	.type	flag, @object
	.size	flag, 672400
flag:
	.zero	672400
	.text
	.globl	f
	.type	f, @function
f:
.LFB11:
	.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	$56, %rsp
	.cfi_offset 3, -24
	movl	%edi, -52(%rbp)
	movl	%esi, -56(%rbp)
	movl	-56(%rbp), %eax
	subl	-52(%rbp), %eax
	cmpl	$1, %eax
	jne	.L20
	movl	$0, %eax
	jmp	.L21
.L20:
	movl	-56(%rbp), %eax
	movslq	%eax, %rdx
	movl	-52(%rbp), %eax
	cltq
	imulq	$410, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	flag(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	je	.L22
	movl	-56(%rbp), %eax
	movslq	%eax, %rdx
	movl	-52(%rbp), %eax
	cltq
	imulq	$410, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rdx
	leaq	dp(%rip), %rax
	movq	(%rdx,%rax), %rax
	jmp	.L21
.L22:
	movl	-56(%rbp), %eax
	movslq	%eax, %rdx
	movl	-52(%rbp), %eax
	cltq
	imulq	$410, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	flag(%rip), %rax
	movl	$1, (%rdx,%rax)
	movabsq	$4611686016279904256, %rax
	movq	%rax, -40(%rbp)
	movl	-52(%rbp), %eax
	addl	$1, %eax
	cltq
	movq	%rax, -32(%rbp)
	jmp	.L23
.L24:
	movq	-32(%rbp), %rax
	movl	%eax, %edx
	movl	-52(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	f
	movq	%rax, %rbx
	movq	-32(%rbp), %rax
	movl	%eax, %edx
	movl	-56(%rbp), %eax
	movl	%eax, %esi
	movl	%edx, %edi
	call	f
	leaq	(%rbx,%rax), %rcx
	movl	-56(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	cum(%rip), %rax
	movq	(%rdx,%rax), %rax
	addq	%rax, %rcx
	movl	-52(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	cum(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movq	%rcx, %rax
	subq	%rdx, %rax
	movq	%rax, -24(%rbp)
	movq	-40(%rbp), %rdx
	movq	-24(%rbp), %rax
	cmpq	%rax, %rdx
	cmovle	%rdx, %rax
	movq	%rax, -40(%rbp)
	addq	$1, -32(%rbp)
.L23:
	movl	-56(%rbp), %eax
	cltq
	cmpq	%rax, -32(%rbp)
	jl	.L24
	movl	-56(%rbp), %eax
	movslq	%eax, %rdx
	movl	-52(%rbp), %eax
	cltq
	imulq	$410, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rcx
	leaq	dp(%rip), %rdx
	movq	-40(%rbp), %rax
	movq	%rax, (%rcx,%rdx)
	movl	-56(%rbp), %eax
	movslq	%eax, %rdx
	movl	-52(%rbp), %eax
	cltq
	imulq	$410, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rdx
	leaq	dp(%rip), %rax
	movq	(%rdx,%rax), %rax
.L21:
	movq	-8(%rbp), %rbx
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE11:
	.size	f, .-f
	.section	.rodata
.LC0:
	.string	"%lld"
.LC1:
	.string	"%lld\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB12:
	.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	-32(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	$0, -24(%rbp)
	jmp	.L26
.L27:
	movq	-24(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	leaq	a(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addq	$1, -24(%rbp)
.L26:
	movq	-32(%rbp), %rax
	cmpq	%rax, -24(%rbp)
	jl	.L27
	movq	$0, -16(%rbp)
	jmp	.L28
.L29:
	movq	-16(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	leaq	cum(%rip), %rax
	movq	(%rdx,%rax), %rcx
	movq	-16(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	leaq	a(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movq	-16(%rbp), %rax
	addq	$1, %rax
	addq	%rdx, %rcx
	leaq	0(,%rax,8), %rdx
	leaq	cum(%rip), %rax
	movq	%rcx, (%rdx,%rax)
	addq	$1, -16(%rbp)
.L28:
	movq	-32(%rbp), %rax
	cmpq	%rax, -16(%rbp)
	jl	.L29
	movq	-32(%rbp), %rax
	movl	%eax, %esi
	movl	$0, %edi
	call	f
	movq	%rax, %rsi
	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	.L31
	call	__stack_chk_fail@PLT
.L31:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE12:
	.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:
