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>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define min(p,q)((p)<(q)?(p):(q))

ll n,a,b;
ll p[5010];
ll ip[5010];//pの逆引き
ll cnt[5010][5010];//cnt[i][j]=区間[i,j)に存在する、p[i]より小さいものの個数
ll memo[5010][5010];
ll f(int R,int K){
	if(R<=0||K<0)return 0;
	if(memo[R][K])return memo[R][K]-1;
	if(ip[K]>=R)return (memo[R][K]=f(R,K-1)+1)-1;
	
	ll ans;
	if(cnt[ip[K]][R]){
		ll v1=f(ip[K],K-1)+cnt[ip[K]][R]*b;
		ll v2=f(    R,K-1)+a;
		ans=min(v1,v2);
	}else{
		ans=f(R,K-1);
	}
	return (memo[R][K]=ans+1)-1;
}

int main(){
	scanf("%lld%lld%lld",&n,&a,&b);
	rep(i,0,n){
		ll t;
		scanf("%lld",&t);
		t--;
		p[i]=t;
		ip[t]=i;
	}
	rep(i,0,n){
		ll c=0;
		rep(j,i+1,n+1){
			cnt[i][j]=c;
			if(p[j]<p[i])c++;
		}
	}
	printf("%lld",f(n,n-1));
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	n
	.bss
	.align 8
	.type	n, @object
	.size	n, 8
n:
	.zero	8
	.globl	a
	.align 8
	.type	a, @object
	.size	a, 8
a:
	.zero	8
	.globl	b
	.align 8
	.type	b, @object
	.size	b, 8
b:
	.zero	8
	.globl	p
	.align 32
	.type	p, @object
	.size	p, 40080
p:
	.zero	40080
	.globl	ip
	.align 32
	.type	ip, @object
	.size	ip, 40080
ip:
	.zero	40080
	.globl	cnt
	.align 32
	.type	cnt, @object
	.size	cnt, 200800800
cnt:
	.zero	200800800
	.globl	memo
	.align 32
	.type	memo, @object
	.size	memo, 200800800
memo:
	.zero	200800800
	.text
	.globl	f
	.type	f, @function
f:
.LFB0:
	.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
	movl	%edi, -36(%rbp)
	movl	%esi, -40(%rbp)
	cmpl	$0, -36(%rbp)
	jle	.L2
	cmpl	$0, -40(%rbp)
	jns	.L3
.L2:
	movl	$0, %eax
	jmp	.L4
.L3:
	movl	-40(%rbp), %eax
	movslq	%eax, %rdx
	movl	-36(%rbp), %eax
	cltq
	imulq	$5010, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rdx
	leaq	memo(%rip), %rax
	movq	(%rdx,%rax), %rax
	testq	%rax, %rax
	je	.L5
	movl	-40(%rbp), %eax
	movslq	%eax, %rdx
	movl	-36(%rbp), %eax
	cltq
	imulq	$5010, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rdx
	leaq	memo(%rip), %rax
	movq	(%rdx,%rax), %rax
	subq	$1, %rax
	jmp	.L4
.L5:
	movl	-40(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	ip(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movl	-36(%rbp), %eax
	cltq
	cmpq	%rax, %rdx
	jl	.L6
	movl	-40(%rbp), %eax
	leal	-1(%rax), %edx
	movl	-36(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	f
	leaq	1(%rax), %rcx
	movl	-40(%rbp), %eax
	movslq	%eax, %rdx
	movl	-36(%rbp), %eax
	cltq
	imulq	$5010, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rdx
	leaq	memo(%rip), %rax
	movq	%rcx, (%rdx,%rax)
	movl	-40(%rbp), %eax
	movslq	%eax, %rdx
	movl	-36(%rbp), %eax
	cltq
	imulq	$5010, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rdx
	leaq	memo(%rip), %rax
	movq	(%rdx,%rax), %rax
	subq	$1, %rax
	jmp	.L4
.L6:
	movl	-40(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	ip(%rip), %rax
	movq	(%rdx,%rax), %rax
	movl	-36(%rbp), %edx
	movslq	%edx, %rdx
	imulq	$5010, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rdx
	leaq	cnt(%rip), %rax
	movq	(%rdx,%rax), %rax
	testq	%rax, %rax
	je	.L7
	movl	-40(%rbp), %eax
	subl	$1, %eax
	movl	-40(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,8), %rcx
	leaq	ip(%rip), %rdx
	movq	(%rcx,%rdx), %rdx
	movl	%eax, %esi
	movl	%edx, %edi
	call	f
	movq	%rax, %rcx
	movl	-40(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	ip(%rip), %rax
	movq	(%rdx,%rax), %rax
	movl	-36(%rbp), %edx
	movslq	%edx, %rdx
	imulq	$5010, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rdx
	leaq	cnt(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movq	b(%rip), %rax
	imulq	%rdx, %rax
	addq	%rcx, %rax
	movq	%rax, -16(%rbp)
	movl	-40(%rbp), %eax
	leal	-1(%rax), %edx
	movl	-36(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	f
	movq	a(%rip), %rdx
	addq	%rdx, %rax
	movq	%rax, -8(%rbp)
	movq	-8(%rbp), %rdx
	movq	-16(%rbp), %rax
	cmpq	%rax, %rdx
	cmovle	%rdx, %rax
	movq	%rax, -24(%rbp)
	jmp	.L8
.L7:
	movl	-40(%rbp), %eax
	leal	-1(%rax), %edx
	movl	-36(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	f
	movq	%rax, -24(%rbp)
.L8:
	movq	-24(%rbp), %rax
	leaq	1(%rax), %rcx
	movl	-40(%rbp), %eax
	movslq	%eax, %rdx
	movl	-36(%rbp), %eax
	cltq
	imulq	$5010, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rdx
	leaq	memo(%rip), %rax
	movq	%rcx, (%rdx,%rax)
	movl	-40(%rbp), %eax
	movslq	%eax, %rdx
	movl	-36(%rbp), %eax
	cltq
	imulq	$5010, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rdx
	leaq	memo(%rip), %rax
	movq	(%rdx,%rax), %rax
	subq	$1, %rax
.L4:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	f, .-f
	.section	.rodata
.LC0:
	.string	"%lld%lld%lld"
.LC1:
	.string	"%lld"
	.text
	.globl	main
	.type	main, @function
main:
.LFB1:
	.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
	leaq	b(%rip), %rax
	movq	%rax, %rcx
	leaq	a(%rip), %rax
	movq	%rax, %rdx
	leaq	n(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	$0, -40(%rbp)
	jmp	.L10
.L11:
	leaq	-48(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	-48(%rbp), %rax
	subq	$1, %rax
	movq	%rax, -48(%rbp)
	movq	-48(%rbp), %rax
	movq	-40(%rbp), %rdx
	leaq	0(,%rdx,8), %rcx
	leaq	p(%rip), %rdx
	movq	%rax, (%rcx,%rdx)
	movq	-48(%rbp), %rax
	leaq	0(,%rax,8), %rcx
	leaq	ip(%rip), %rdx
	movq	-40(%rbp), %rax
	movq	%rax, (%rcx,%rdx)
	addq	$1, -40(%rbp)
.L10:
	movq	n(%rip), %rax
	cmpq	%rax, -40(%rbp)
	jl	.L11
	movq	$0, -32(%rbp)
	jmp	.L12
.L16:
	movq	$0, -24(%rbp)
	movq	-32(%rbp), %rax
	addq	$1, %rax
	movq	%rax, -16(%rbp)
	jmp	.L13
.L15:
	movq	-32(%rbp), %rax
	imulq	$5010, %rax, %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rcx
	leaq	cnt(%rip), %rdx
	movq	-24(%rbp), %rax
	movq	%rax, (%rcx,%rdx)
	movq	-16(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	leaq	p(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movq	-32(%rbp), %rax
	leaq	0(,%rax,8), %rcx
	leaq	p(%rip), %rax
	movq	(%rcx,%rax), %rax
	cmpq	%rax, %rdx
	jge	.L14
	addq	$1, -24(%rbp)
.L14:
	addq	$1, -16(%rbp)
.L13:
	movq	n(%rip), %rax
	cmpq	%rax, -16(%rbp)
	jle	.L15
	addq	$1, -32(%rbp)
.L12:
	movq	n(%rip), %rax
	cmpq	%rax, -32(%rbp)
	jl	.L16
	movq	n(%rip), %rax
	subl	$1, %eax
	movl	%eax, %edx
	movq	n(%rip), %rax
	movl	%edx, %esi
	movl	%eax, %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	.L18
	call	__stack_chk_fail@PLT
.L18:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.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	f
	.type	f, @function
f:
.LFB23:
	.cfi_startproc
	endbr64
	testl	%edi, %edi
	jle	.L7
	testl	%esi, %esi
	js	.L7
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movslq	%edi, %r15
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movslq	%esi, %r14
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	imulq	$5010, %r15, %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movl	%edi, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	addq	%r14, %r13
	leaq	memo(%rip), %rbx
	subq	$8, %rsp
	.cfi_def_cfa_offset 64
	movq	(%rbx,%r13,8), %rax
	testq	%rax, %rax
	jne	.L13
	leaq	ip(%rip), %rdx
	leal	-1(%rsi), %ebp
	movq	(%rdx,%r14,8), %rdi
	cmpq	%r15, %rdi
	jge	.L14
	imulq	$5010, %rdi, %rax
	leaq	cnt(%rip), %r13
	movl	%ebp, %esi
	addq	%r15, %rax
	cmpq	$0, 0(%r13,%rax,8)
	jne	.L15
	movl	%r12d, %edi
	call	f
.L6:
	imulq	$5010, %r15, %rdx
	leaq	1(%rax), %rcx
	addq	%r14, %rdx
	movq	%rcx, (%rbx,%rdx,8)
	addq	$8, %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
.L13:
	.cfi_restore_state
	subq	$1, %rax
.L1:
	addq	$8, %rsp
	.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
.L7:
	.cfi_restore 3
	.cfi_restore 6
	.cfi_restore 12
	.cfi_restore 13
	.cfi_restore 14
	.cfi_restore 15
	xorl	%eax, %eax
	ret
	.p2align 4,,10
	.p2align 3
.L15:
	.cfi_def_cfa_offset 64
	.cfi_offset 3, -56
	.cfi_offset 6, -48
	.cfi_offset 12, -40
	.cfi_offset 13, -32
	.cfi_offset 14, -24
	.cfi_offset 15, -16
	call	f
	leaq	ip(%rip), %rdx
	movl	%ebp, %esi
	movl	%r12d, %edi
	movq	%rax, %r8
	imulq	$5010, (%rdx,%r14,8), %rax
	addq	%r15, %rax
	movq	0(%r13,%rax,8), %r13
	imulq	b(%rip), %r13
	addq	%r8, %r13
	call	f
	addq	a(%rip), %rax
	cmpq	%r13, %rax
	cmovg	%r13, %rax
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L14:
	movl	%ebp, %esi
	movl	%r12d, %edi
	call	f
	leaq	1(%rax), %rdx
	movq	%rdx, (%rbx,%r13,8)
	jmp	.L1
	.cfi_endproc
.LFE23:
	.size	f, .-f
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%lld%lld%lld"
.LC1:
	.string	"%lld"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB24:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	leaq	.LC0(%rip), %rdi
	leaq	b(%rip), %rcx
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	leaq	a(%rip), %rdx
	leaq	n(%rip), %rsi
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	leaq	.LC1(%rip), %r12
	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
	call	__isoc99_scanf@PLT
	movq	n(%rip), %rdi
	testq	%rdi, %rdi
	jle	.L17
	xorl	%ebp, %ebp
	movq	%rsp, %r14
	leaq	p(%rip), %rbx
	leaq	ip(%rip), %r13
	.p2align 4,,10
	.p2align 3
.L18:
	movq	%r14, %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movq	(%rsp), %rax
	movq	n(%rip), %r9
	subq	$1, %rax
	movq	%rax, (%rbx,%rbp,8)
	movq	%rbp, 0(%r13,%rax,8)
	addq	$1, %rbp
	cmpq	%rbp, %r9
	jg	.L18
	testq	%r9, %r9
	jle	.L25
	leaq	cnt(%rip), %rcx
	xorl	%edi, %edi
	leaq	-8+p(%rip), %r10
	leaq	1(%r9), %r8
	.p2align 4,,10
	.p2align 3
.L22:
	addq	$1, %rdi
	cmpq	%rdi, %r9
	jl	.L19
	movq	(%r10,%rdi,8), %rsi
	movq	%rdi, %rax
	xorl	%edx, %edx
	.p2align 4,,10
	.p2align 3
.L21:
	movq	%rdx, (%rcx,%rax,8)
	cmpq	(%rbx,%rax,8), %rsi
	jle	.L20
	addq	$1, %rdx
.L20:
	addq	$1, %rax
	cmpq	%rax, %r8
	jne	.L21
	addq	$40080, %rcx
	cmpq	%rdi, %r9
	jne	.L22
.L17:
	leal	-1(%rdi), %esi
	call	f
	movq	%r12, %rsi
	movl	$1, %edi
	movq	%rax, %rdx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L31
	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
	.p2align 4,,10
	.p2align 3
.L19:
	.cfi_restore_state
	addq	$40080, %rcx
	jmp	.L22
.L25:
	movq	%r9, %rdi
	jmp	.L17
.L31:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE24:
	.size	main, .-main
	.globl	memo
	.bss
	.align 32
	.type	memo, @object
	.size	memo, 200800800
memo:
	.zero	200800800
	.globl	cnt
	.align 32
	.type	cnt, @object
	.size	cnt, 200800800
cnt:
	.zero	200800800
	.globl	ip
	.align 32
	.type	ip, @object
	.size	ip, 40080
ip:
	.zero	40080
	.globl	p
	.align 32
	.type	p, @object
	.size	p, 40080
p:
	.zero	40080
	.globl	b
	.align 8
	.type	b, @object
	.size	b, 8
b:
	.zero	8
	.globl	a
	.align 8
	.type	a, @object
	.size	a, 8
a:
	.zero	8
	.globl	n
	.align 8
	.type	n, @object
	.size	n, 8
n:
	.zero	8
	.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	f
	.type	f, @function
f:
.LFB23:
	.cfi_startproc
	endbr64
	testl	%edi, %edi
	jle	.L7
	testl	%esi, %esi
	js	.L7
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movslq	%edi, %r15
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movslq	%esi, %r14
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	imulq	$5010, %r15, %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movl	%edi, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	addq	%r14, %r13
	leaq	memo(%rip), %rbx
	subq	$8, %rsp
	.cfi_def_cfa_offset 64
	movq	(%rbx,%r13,8), %rax
	testq	%rax, %rax
	jne	.L13
	leaq	ip(%rip), %rdx
	leal	-1(%rsi), %ebp
	movq	(%rdx,%r14,8), %rdi
	cmpq	%r15, %rdi
	jge	.L14
	imulq	$5010, %rdi, %rax
	leaq	cnt(%rip), %r13
	movl	%ebp, %esi
	addq	%r15, %rax
	cmpq	$0, 0(%r13,%rax,8)
	jne	.L15
	movl	%r12d, %edi
	call	f
.L6:
	imulq	$5010, %r15, %rdx
	leaq	1(%rax), %rcx
	addq	%r14, %rdx
	movq	%rcx, (%rbx,%rdx,8)
	addq	$8, %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
.L13:
	.cfi_restore_state
	subq	$1, %rax
.L1:
	addq	$8, %rsp
	.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
.L7:
	.cfi_restore 3
	.cfi_restore 6
	.cfi_restore 12
	.cfi_restore 13
	.cfi_restore 14
	.cfi_restore 15
	xorl	%eax, %eax
	ret
	.p2align 4,,10
	.p2align 3
.L15:
	.cfi_def_cfa_offset 64
	.cfi_offset 3, -56
	.cfi_offset 6, -48
	.cfi_offset 12, -40
	.cfi_offset 13, -32
	.cfi_offset 14, -24
	.cfi_offset 15, -16
	call	f
	leaq	ip(%rip), %rdx
	movl	%ebp, %esi
	movl	%r12d, %edi
	movq	%rax, %r8
	imulq	$5010, (%rdx,%r14,8), %rax
	addq	%r15, %rax
	movq	0(%r13,%rax,8), %r13
	imulq	b(%rip), %r13
	addq	%r8, %r13
	call	f
	addq	a(%rip), %rax
	cmpq	%r13, %rax
	cmovg	%r13, %rax
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L14:
	movl	%ebp, %esi
	movl	%r12d, %edi
	call	f
	leaq	1(%rax), %rdx
	movq	%rdx, (%rbx,%r13,8)
	jmp	.L1
	.cfi_endproc
.LFE23:
	.size	f, .-f
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%lld%lld%lld"
.LC1:
	.string	"%lld"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB24:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	leaq	.LC0(%rip), %rdi
	leaq	b(%rip), %rcx
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	leaq	a(%rip), %rdx
	leaq	n(%rip), %rsi
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	leaq	.LC1(%rip), %r12
	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
	call	__isoc99_scanf@PLT
	movq	n(%rip), %rdi
	testq	%rdi, %rdi
	jle	.L17
	xorl	%ebp, %ebp
	movq	%rsp, %r14
	leaq	p(%rip), %rbx
	leaq	ip(%rip), %r13
	.p2align 4,,10
	.p2align 3
.L18:
	movq	%r14, %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movq	(%rsp), %rax
	movq	n(%rip), %r9
	subq	$1, %rax
	movq	%rax, (%rbx,%rbp,8)
	movq	%rbp, 0(%r13,%rax,8)
	addq	$1, %rbp
	cmpq	%rbp, %r9
	jg	.L18
	testq	%r9, %r9
	jle	.L25
	leaq	cnt(%rip), %rcx
	xorl	%edi, %edi
	leaq	-8+p(%rip), %r10
	leaq	1(%r9), %r8
	.p2align 4,,10
	.p2align 3
.L22:
	addq	$1, %rdi
	cmpq	%rdi, %r9
	jl	.L19
	movq	(%r10,%rdi,8), %rsi
	movq	%rdi, %rax
	xorl	%edx, %edx
	.p2align 4,,10
	.p2align 3
.L21:
	movq	%rdx, (%rcx,%rax,8)
	cmpq	(%rbx,%rax,8), %rsi
	jle	.L20
	addq	$1, %rdx
.L20:
	addq	$1, %rax
	cmpq	%rax, %r8
	jne	.L21
	addq	$40080, %rcx
	cmpq	%rdi, %r9
	jne	.L22
.L17:
	leal	-1(%rdi), %esi
	call	f
	movq	%r12, %rsi
	movl	$1, %edi
	movq	%rax, %rdx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L31
	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
	.p2align 4,,10
	.p2align 3
.L19:
	.cfi_restore_state
	addq	$40080, %rcx
	jmp	.L22
.L25:
	movq	%r9, %rdi
	jmp	.L17
.L31:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE24:
	.size	main, .-main
	.globl	memo
	.bss
	.align 32
	.type	memo, @object
	.size	memo, 200800800
memo:
	.zero	200800800
	.globl	cnt
	.align 32
	.type	cnt, @object
	.size	cnt, 200800800
cnt:
	.zero	200800800
	.globl	ip
	.align 32
	.type	ip, @object
	.size	ip, 40080
ip:
	.zero	40080
	.globl	p
	.align 32
	.type	p, @object
	.size	p, 40080
p:
	.zero	40080
	.globl	b
	.align 8
	.type	b, @object
	.size	b, 8
b:
	.zero	8
	.globl	a
	.align 8
	.type	a, @object
	.size	a, 8
a:
	.zero	8
	.globl	n
	.align 8
	.type	n, @object
	.size	n, 8
n:
	.zero	8
	.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>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define min(p,q)((p)<(q)?(p):(q))

ll n,a,b;
ll p[5010];
ll ip[5010];//pの逆引き
ll cnt[5010][5010];//cnt[i][j]=区間[i,j)に存在する、p[i]より小さいものの個数
ll memo[5010][5010];
ll f(int R,int K){
	if(R<=0||K<0)return 0;
	if(memo[R][K])return memo[R][K]-1;
	if(ip[K]>=R)return (memo[R][K]=f(R,K-1)+1)-1;
	
	ll ans;
	if(cnt[ip[K]][R]){
		ll v1=f(ip[K],K-1)+cnt[ip[K]][R]*b;
		ll v2=f(    R,K-1)+a;
		ans=min(v1,v2);
	}else{
		ans=f(R,K-1);
	}
	return (memo[R][K]=ans+1)-1;
}

int main(){
	scanf("%lld%lld%lld",&n,&a,&b);
	rep(i,0,n){
		ll t;
		scanf("%lld",&t);
		t--;
		p[i]=t;
		ip[t]=i;
	}
	rep(i,0,n){
		ll c=0;
		rep(j,i+1,n+1){
			cnt[i][j]=c;
			if(p[j]<p[i])c++;
		}
	}
	printf("%lld",f(n,n-1));
}
3 26 30
3 1 2
 4 20 30
3 2 3 1
 9 40 87
5 3 4 7 6 1 2 9 8
 4 8 30
3 2 3 1
 4 11 30
3 2 3 1
 4 20 36
4 2 3 1
 4 20 46
4 2 3 1
 9 67 87
5 3 4 7 6 1 3 12 8
 9 72 87
5 3 4 7 6 1 3 12 8
 1 8 10
1

26 50 240 24 33 56 60 348 348 0
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>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define min(p,q)((p)<(q)?(p):(q))

ll n,a,b;
ll p[5010];
ll ip[5010];//pの逆引き
ll cnt[5010][5010];//cnt[i][j]=区間[i,j)に存在する、p[i]より小さいものの個数
ll memo[5010][5010];
ll f(int R,int K){
	if(R<=0||K<0)return 0;
	if(memo[R][K])return memo[R][K]-1;
	if(ip[K]>=R)return (memo[R][K]=f(R,K-1)+1)-1;
	
	ll ans;
	if(cnt[ip[K]][R]){
		ll v1=f(ip[K],K-1)+cnt[ip[K]][R]*b;
		ll v2=f(    R,K-1)+a;
		ans=min(v1,v2);
	}else{
		ans=f(R,K-1);
	}
	return (memo[R][K]=ans+1)-1;
}

int main(){
	scanf("%lld%lld%lld",&n,&a,&b);
	rep(i,0,n){
		ll t;
		scanf("%lld",&t);
		t--;
		p[i]=t;
		ip[t]=i;
	}
	rep(i,0,n){
		ll c=0;
		rep(j,i+1,n+1){
			cnt[i][j]=c;
			if(p[j]<p[i])c++;
		}
	}
	printf("%lld",f(n,n-1));
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	n
	.bss
	.align 8
	.type	n, @object
	.size	n, 8
n:
	.zero	8
	.globl	a
	.align 8
	.type	a, @object
	.size	a, 8
a:
	.zero	8
	.globl	b
	.align 8
	.type	b, @object
	.size	b, 8
b:
	.zero	8
	.globl	p
	.align 32
	.type	p, @object
	.size	p, 40080
p:
	.zero	40080
	.globl	ip
	.align 32
	.type	ip, @object
	.size	ip, 40080
ip:
	.zero	40080
	.globl	cnt
	.align 32
	.type	cnt, @object
	.size	cnt, 200800800
cnt:
	.zero	200800800
	.globl	memo
	.align 32
	.type	memo, @object
	.size	memo, 200800800
memo:
	.zero	200800800
	.text
	.globl	f
	.type	f, @function
f:
.LFB0:
	.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
	movl	%edi, -36(%rbp)
	movl	%esi, -40(%rbp)
	cmpl	$0, -36(%rbp)
	jle	.L2
	cmpl	$0, -40(%rbp)
	jns	.L3
.L2:
	movl	$0, %eax
	jmp	.L4
.L3:
	movl	-40(%rbp), %eax
	movslq	%eax, %rdx
	movl	-36(%rbp), %eax
	cltq
	imulq	$5010, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rdx
	leaq	memo(%rip), %rax
	movq	(%rdx,%rax), %rax
	testq	%rax, %rax
	je	.L5
	movl	-40(%rbp), %eax
	movslq	%eax, %rdx
	movl	-36(%rbp), %eax
	cltq
	imulq	$5010, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rdx
	leaq	memo(%rip), %rax
	movq	(%rdx,%rax), %rax
	subq	$1, %rax
	jmp	.L4
.L5:
	movl	-40(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	ip(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movl	-36(%rbp), %eax
	cltq
	cmpq	%rax, %rdx
	jl	.L6
	movl	-40(%rbp), %eax
	leal	-1(%rax), %edx
	movl	-36(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	f
	leaq	1(%rax), %rcx
	movl	-40(%rbp), %eax
	movslq	%eax, %rdx
	movl	-36(%rbp), %eax
	cltq
	imulq	$5010, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rdx
	leaq	memo(%rip), %rax
	movq	%rcx, (%rdx,%rax)
	movl	-40(%rbp), %eax
	movslq	%eax, %rdx
	movl	-36(%rbp), %eax
	cltq
	imulq	$5010, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rdx
	leaq	memo(%rip), %rax
	movq	(%rdx,%rax), %rax
	subq	$1, %rax
	jmp	.L4
.L6:
	movl	-40(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	ip(%rip), %rax
	movq	(%rdx,%rax), %rax
	movl	-36(%rbp), %edx
	movslq	%edx, %rdx
	imulq	$5010, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rdx
	leaq	cnt(%rip), %rax
	movq	(%rdx,%rax), %rax
	testq	%rax, %rax
	je	.L7
	movl	-40(%rbp), %eax
	subl	$1, %eax
	movl	-40(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,8), %rcx
	leaq	ip(%rip), %rdx
	movq	(%rcx,%rdx), %rdx
	movl	%eax, %esi
	movl	%edx, %edi
	call	f
	movq	%rax, %rcx
	movl	-40(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	ip(%rip), %rax
	movq	(%rdx,%rax), %rax
	movl	-36(%rbp), %edx
	movslq	%edx, %rdx
	imulq	$5010, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rdx
	leaq	cnt(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movq	b(%rip), %rax
	imulq	%rdx, %rax
	addq	%rcx, %rax
	movq	%rax, -16(%rbp)
	movl	-40(%rbp), %eax
	leal	-1(%rax), %edx
	movl	-36(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	f
	movq	a(%rip), %rdx
	addq	%rdx, %rax
	movq	%rax, -8(%rbp)
	movq	-8(%rbp), %rdx
	movq	-16(%rbp), %rax
	cmpq	%rax, %rdx
	cmovle	%rdx, %rax
	movq	%rax, -24(%rbp)
	jmp	.L8
.L7:
	movl	-40(%rbp), %eax
	leal	-1(%rax), %edx
	movl	-36(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	f
	movq	%rax, -24(%rbp)
.L8:
	movq	-24(%rbp), %rax
	leaq	1(%rax), %rcx
	movl	-40(%rbp), %eax
	movslq	%eax, %rdx
	movl	-36(%rbp), %eax
	cltq
	imulq	$5010, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rdx
	leaq	memo(%rip), %rax
	movq	%rcx, (%rdx,%rax)
	movl	-40(%rbp), %eax
	movslq	%eax, %rdx
	movl	-36(%rbp), %eax
	cltq
	imulq	$5010, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rdx
	leaq	memo(%rip), %rax
	movq	(%rdx,%rax), %rax
	subq	$1, %rax
.L4:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	f, .-f
	.section	.rodata
.LC0:
	.string	"%lld%lld%lld"
.LC1:
	.string	"%lld"
	.text
	.globl	main
	.type	main, @function
main:
.LFB1:
	.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
	leaq	b(%rip), %rax
	movq	%rax, %rcx
	leaq	a(%rip), %rax
	movq	%rax, %rdx
	leaq	n(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	$0, -40(%rbp)
	jmp	.L10
.L11:
	leaq	-48(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	-48(%rbp), %rax
	subq	$1, %rax
	movq	%rax, -48(%rbp)
	movq	-48(%rbp), %rax
	movq	-40(%rbp), %rdx
	leaq	0(,%rdx,8), %rcx
	leaq	p(%rip), %rdx
	movq	%rax, (%rcx,%rdx)
	movq	-48(%rbp), %rax
	leaq	0(,%rax,8), %rcx
	leaq	ip(%rip), %rdx
	movq	-40(%rbp), %rax
	movq	%rax, (%rcx,%rdx)
	addq	$1, -40(%rbp)
.L10:
	movq	n(%rip), %rax
	cmpq	%rax, -40(%rbp)
	jl	.L11
	movq	$0, -32(%rbp)
	jmp	.L12
.L16:
	movq	$0, -24(%rbp)
	movq	-32(%rbp), %rax
	addq	$1, %rax
	movq	%rax, -16(%rbp)
	jmp	.L13
.L15:
	movq	-32(%rbp), %rax
	imulq	$5010, %rax, %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rcx
	leaq	cnt(%rip), %rdx
	movq	-24(%rbp), %rax
	movq	%rax, (%rcx,%rdx)
	movq	-16(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	leaq	p(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movq	-32(%rbp), %rax
	leaq	0(,%rax,8), %rcx
	leaq	p(%rip), %rax
	movq	(%rcx,%rax), %rax
	cmpq	%rax, %rdx
	jge	.L14
	addq	$1, -24(%rbp)
.L14:
	addq	$1, -16(%rbp)
.L13:
	movq	n(%rip), %rax
	cmpq	%rax, -16(%rbp)
	jle	.L15
	addq	$1, -32(%rbp)
.L12:
	movq	n(%rip), %rax
	cmpq	%rax, -32(%rbp)
	jl	.L16
	movq	n(%rip), %rax
	subl	$1, %eax
	movl	%eax, %edx
	movq	n(%rip), %rax
	movl	%edx, %esi
	movl	%eax, %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	.L18
	call	__stack_chk_fail@PLT
.L18:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.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	n
	.bss
	.align 8
	.type	n, @object
	.size	n, 8
n:
	.zero	8
	.globl	a
	.align 8
	.type	a, @object
	.size	a, 8
a:
	.zero	8
	.globl	b
	.align 8
	.type	b, @object
	.size	b, 8
b:
	.zero	8
	.globl	p
	.align 32
	.type	p, @object
	.size	p, 40080
p:
	.zero	40080
	.globl	ip
	.align 32
	.type	ip, @object
	.size	ip, 40080
ip:
	.zero	40080
	.globl	cnt
	.align 32
	.type	cnt, @object
	.size	cnt, 200800800
cnt:
	.zero	200800800
	.globl	memo
	.align 32
	.type	memo, @object
	.size	memo, 200800800
memo:
	.zero	200800800
	.text
	.globl	f
	.type	f, @function
f:
.LFB0:
	.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
	movl	%edi, -36(%rbp)
	movl	%esi, -40(%rbp)
	cmpl	$0, -36(%rbp)
	jle	.L2
	cmpl	$0, -40(%rbp)
	jns	.L3
.L2:
	movl	$0, %eax
	jmp	.L4
.L3:
	movl	-40(%rbp), %eax
	movslq	%eax, %rdx
	movl	-36(%rbp), %eax
	cltq
	imulq	$5010, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rdx
	leaq	memo(%rip), %rax
	movq	(%rdx,%rax), %rax
	testq	%rax, %rax
	je	.L5
	movl	-40(%rbp), %eax
	movslq	%eax, %rdx
	movl	-36(%rbp), %eax
	cltq
	imulq	$5010, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rdx
	leaq	memo(%rip), %rax
	movq	(%rdx,%rax), %rax
	subq	$1, %rax
	jmp	.L4
.L5:
	movl	-40(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	ip(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movl	-36(%rbp), %eax
	cltq
	cmpq	%rax, %rdx
	jl	.L6
	movl	-40(%rbp), %eax
	leal	-1(%rax), %edx
	movl	-36(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	f
	leaq	1(%rax), %rcx
	movl	-40(%rbp), %eax
	movslq	%eax, %rdx
	movl	-36(%rbp), %eax
	cltq
	imulq	$5010, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rdx
	leaq	memo(%rip), %rax
	movq	%rcx, (%rdx,%rax)
	movl	-40(%rbp), %eax
	movslq	%eax, %rdx
	movl	-36(%rbp), %eax
	cltq
	imulq	$5010, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rdx
	leaq	memo(%rip), %rax
	movq	(%rdx,%rax), %rax
	subq	$1, %rax
	jmp	.L4
.L6:
	movl	-40(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	ip(%rip), %rax
	movq	(%rdx,%rax), %rax
	movl	-36(%rbp), %edx
	movslq	%edx, %rdx
	imulq	$5010, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rdx
	leaq	cnt(%rip), %rax
	movq	(%rdx,%rax), %rax
	testq	%rax, %rax
	je	.L7
	movl	-40(%rbp), %eax
	subl	$1, %eax
	movl	-40(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,8), %rcx
	leaq	ip(%rip), %rdx
	movq	(%rcx,%rdx), %rdx
	movl	%eax, %esi
	movl	%edx, %edi
	call	f
	movq	%rax, %rcx
	movl	-40(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	ip(%rip), %rax
	movq	(%rdx,%rax), %rax
	movl	-36(%rbp), %edx
	movslq	%edx, %rdx
	imulq	$5010, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rdx
	leaq	cnt(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movq	b(%rip), %rax
	imulq	%rdx, %rax
	addq	%rcx, %rax
	movq	%rax, -16(%rbp)
	movl	-40(%rbp), %eax
	leal	-1(%rax), %edx
	movl	-36(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	f
	movq	a(%rip), %rdx
	addq	%rdx, %rax
	movq	%rax, -8(%rbp)
	movq	-8(%rbp), %rdx
	movq	-16(%rbp), %rax
	cmpq	%rax, %rdx
	cmovle	%rdx, %rax
	movq	%rax, -24(%rbp)
	jmp	.L8
.L7:
	movl	-40(%rbp), %eax
	leal	-1(%rax), %edx
	movl	-36(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	f
	movq	%rax, -24(%rbp)
.L8:
	movq	-24(%rbp), %rax
	leaq	1(%rax), %rcx
	movl	-40(%rbp), %eax
	movslq	%eax, %rdx
	movl	-36(%rbp), %eax
	cltq
	imulq	$5010, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rdx
	leaq	memo(%rip), %rax
	movq	%rcx, (%rdx,%rax)
	movl	-40(%rbp), %eax
	movslq	%eax, %rdx
	movl	-36(%rbp), %eax
	cltq
	imulq	$5010, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rdx
	leaq	memo(%rip), %rax
	movq	(%rdx,%rax), %rax
	subq	$1, %rax
.L4:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	f, .-f
	.section	.rodata
.LC0:
	.string	"%lld%lld%lld"
.LC1:
	.string	"%lld"
	.text
	.globl	main
	.type	main, @function
main:
.LFB1:
	.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
	leaq	b(%rip), %rax
	movq	%rax, %rcx
	leaq	a(%rip), %rax
	movq	%rax, %rdx
	leaq	n(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	$0, -40(%rbp)
	jmp	.L10
.L11:
	leaq	-48(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	-48(%rbp), %rax
	subq	$1, %rax
	movq	%rax, -48(%rbp)
	movq	-48(%rbp), %rax
	movq	-40(%rbp), %rdx
	leaq	0(,%rdx,8), %rcx
	leaq	p(%rip), %rdx
	movq	%rax, (%rcx,%rdx)
	movq	-48(%rbp), %rax
	leaq	0(,%rax,8), %rcx
	leaq	ip(%rip), %rdx
	movq	-40(%rbp), %rax
	movq	%rax, (%rcx,%rdx)
	addq	$1, -40(%rbp)
.L10:
	movq	n(%rip), %rax
	cmpq	%rax, -40(%rbp)
	jl	.L11
	movq	$0, -32(%rbp)
	jmp	.L12
.L16:
	movq	$0, -24(%rbp)
	movq	-32(%rbp), %rax
	addq	$1, %rax
	movq	%rax, -16(%rbp)
	jmp	.L13
.L15:
	movq	-32(%rbp), %rax
	imulq	$5010, %rax, %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rcx
	leaq	cnt(%rip), %rdx
	movq	-24(%rbp), %rax
	movq	%rax, (%rcx,%rdx)
	movq	-16(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	leaq	p(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movq	-32(%rbp), %rax
	leaq	0(,%rax,8), %rcx
	leaq	p(%rip), %rax
	movq	(%rcx,%rax), %rax
	cmpq	%rax, %rdx
	jge	.L14
	addq	$1, -24(%rbp)
.L14:
	addq	$1, -16(%rbp)
.L13:
	movq	n(%rip), %rax
	cmpq	%rax, -16(%rbp)
	jle	.L15
	addq	$1, -32(%rbp)
.L12:
	movq	n(%rip), %rax
	cmpq	%rax, -32(%rbp)
	jl	.L16
	movq	n(%rip), %rax
	subl	$1, %eax
	movl	%eax, %edx
	movq	n(%rip), %rax
	movl	%edx, %esi
	movl	%eax, %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	.L18
	call	__stack_chk_fail@PLT
.L18:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.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:
