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 n;
ll a[200010];
ll p[200010],m[200010];
//p[i]=(0<=a[i]<=...<=a[n-1]となるために必要な操作の回数)/2
//m[i]=(a[0]>=...>=a[i]>=0となるために必要な操作の回数)/2
ll sti[200010],stc[200010],stcnt;

void f(ll *p){
	//pを構成する
	stcnt=0;
	for(int i=n-2;i>=0;i--){
		if(a[i]<=a[i+1]){
			p[i]=p[i+1];
			ll temp=a[i],cnt=0;
			while(temp*4<=a[i+1])temp*=4,cnt++;
			if(cnt){
				sti[stcnt]=i+1;
				stc[stcnt]=cnt;
				stcnt++;
			}
		}else{
			ll temp=a[i+1],cnt=0;
			while(a[i]>temp)temp*=4,cnt++;
			//本当はi+1～n-1までをcnt回やりたいけど、マイナスがあったらそこで軽減される
			ll t=(n-1-i)*cnt;
			while(stcnt&&cnt){
				ll k=min(cnt,stc[stcnt-1]);
				t-=k*(n-sti[stcnt-1]);
				cnt-=k;
				stc[stcnt-1]-=k;
				if(!stc[stcnt-1])stcnt--;
			}
			p[i]=p[i+1]+t;
		}
//		rep(x,0,stcnt)printf("%d:%d ",sti[x],stc[x]);puts("");
	}
}


int main(){
	scanf("%lld",&n);
	rep(i,0,n)scanf("%lld",a+i);
	f(p);
	rep(i,0,n){
		if(i>=n-1-i)break;
		ll t=a[i];
		a[i]=a[n-1-i];
		a[n-1-i]=t;
	}
	f(m);

//	rep(i,0,n)printf("%2lld ",p[i]);puts("");
//	rep(i,0,n)printf("%2lld ",m[n-i]);puts("");
	//0がどこに入るか全探索
	ll ans=INF;
	rep(i,0,n+1)ans=min(ans,p[i]*2+m[n-i]*2+i);
	printf("%lld",ans);
}```

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	n
	.bss
	.align 8
	.type	n, @object
	.size	n, 8
n:
	.zero	8
	.globl	a
	.align 32
	.type	a, @object
	.size	a, 1600080
a:
	.zero	1600080
	.globl	p
	.align 32
	.type	p, @object
	.size	p, 1600080
p:
	.zero	1600080
	.globl	m
	.align 32
	.type	m, @object
	.size	m, 1600080
m:
	.zero	1600080
	.globl	sti
	.align 32
	.type	sti, @object
	.size	sti, 1600080
sti:
	.zero	1600080
	.globl	stc
	.align 32
	.type	stc, @object
	.size	stc, 1600080
stc:
	.zero	1600080
	.globl	stcnt
	.align 8
	.type	stcnt, @object
	.size	stcnt, 8
stcnt:
	.zero	8
	.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
	movq	%rdi, -72(%rbp)
	movq	$0, stcnt(%rip)
	movq	n(%rip), %rax
	subl	$2, %eax
	movl	%eax, -52(%rbp)
	jmp	.L20
.L30:
	movl	-52(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	a(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movl	-52(%rbp), %eax
	addl	$1, %eax
	cltq
	leaq	0(,%rax,8), %rcx
	leaq	a(%rip), %rax
	movq	(%rcx,%rax), %rax
	cmpq	%rax, %rdx
	jg	.L21
	movl	-52(%rbp), %eax
	cltq
	addq	$1, %rax
	leaq	0(,%rax,8), %rdx
	movq	-72(%rbp), %rax
	addq	%rdx, %rax
	movl	-52(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,8), %rcx
	movq	-72(%rbp), %rdx
	addq	%rcx, %rdx
	movq	(%rax), %rax
	movq	%rax, (%rdx)
	movl	-52(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	a(%rip), %rax
	movq	(%rdx,%rax), %rax
	movq	%rax, -48(%rbp)
	movq	$0, -40(%rbp)
	jmp	.L22
.L23:
	salq	$2, -48(%rbp)
	addq	$1, -40(%rbp)
.L22:
	movq	-48(%rbp), %rax
	leaq	0(,%rax,4), %rcx
	movl	-52(%rbp), %eax
	addl	$1, %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	a(%rip), %rax
	movq	(%rdx,%rax), %rax
	cmpq	%rax, %rcx
	jle	.L23
	cmpq	$0, -40(%rbp)
	je	.L24
	movl	-52(%rbp), %eax
	addl	$1, %eax
	movq	stcnt(%rip), %rdx
	cltq
	leaq	0(,%rdx,8), %rcx
	leaq	sti(%rip), %rdx
	movq	%rax, (%rcx,%rdx)
	movq	stcnt(%rip), %rax
	leaq	0(,%rax,8), %rcx
	leaq	stc(%rip), %rdx
	movq	-40(%rbp), %rax
	movq	%rax, (%rcx,%rdx)
	movq	stcnt(%rip), %rax
	addq	$1, %rax
	movq	%rax, stcnt(%rip)
	jmp	.L24
.L21:
	movl	-52(%rbp), %eax
	addl	$1, %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	a(%rip), %rax
	movq	(%rdx,%rax), %rax
	movq	%rax, -32(%rbp)
	movq	$0, -24(%rbp)
	jmp	.L25
.L26:
	salq	$2, -32(%rbp)
	addq	$1, -24(%rbp)
.L25:
	movl	-52(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	a(%rip), %rax
	movq	(%rdx,%rax), %rax
	cmpq	%rax, -32(%rbp)
	jl	.L26
	movq	n(%rip), %rax
	leaq	-1(%rax), %rdx
	movl	-52(%rbp), %eax
	cltq
	subq	%rax, %rdx
	movq	-24(%rbp), %rax
	imulq	%rdx, %rax
	movq	%rax, -16(%rbp)
	jmp	.L27
.L29:
	movq	stcnt(%rip), %rax
	subq	$1, %rax
	leaq	0(,%rax,8), %rdx
	leaq	stc(%rip), %rax
	movq	(%rdx,%rax), %rax
	movq	-24(%rbp), %rdx
	cmpq	%rax, %rdx
	cmovle	%rdx, %rax
	movq	%rax, -8(%rbp)
	movq	n(%rip), %rax
	movq	stcnt(%rip), %rdx
	subq	$1, %rdx
	leaq	0(,%rdx,8), %rcx
	leaq	sti(%rip), %rdx
	movq	(%rcx,%rdx), %rdx
	subq	%rdx, %rax
	imulq	-8(%rbp), %rax
	subq	%rax, -16(%rbp)
	movq	-8(%rbp), %rax
	subq	%rax, -24(%rbp)
	movq	stcnt(%rip), %rax
	subq	$1, %rax
	leaq	0(,%rax,8), %rdx
	leaq	stc(%rip), %rax
	movq	(%rdx,%rax), %rax
	movq	stcnt(%rip), %rdx
	subq	$1, %rdx
	subq	-8(%rbp), %rax
	leaq	0(,%rdx,8), %rcx
	leaq	stc(%rip), %rdx
	movq	%rax, (%rcx,%rdx)
	movq	stcnt(%rip), %rax
	subq	$1, %rax
	leaq	0(,%rax,8), %rdx
	leaq	stc(%rip), %rax
	movq	(%rdx,%rax), %rax
	testq	%rax, %rax
	jne	.L27
	movq	stcnt(%rip), %rax
	subq	$1, %rax
	movq	%rax, stcnt(%rip)
.L27:
	movq	stcnt(%rip), %rax
	testq	%rax, %rax
	je	.L28
	cmpq	$0, -24(%rbp)
	jne	.L29
.L28:
	movl	-52(%rbp), %eax
	cltq
	addq	$1, %rax
	leaq	0(,%rax,8), %rdx
	movq	-72(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rcx
	movl	-52(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-72(%rbp), %rax
	addq	%rdx, %rax
	movq	-16(%rbp), %rdx
	addq	%rcx, %rdx
	movq	%rdx, (%rax)
.L24:
	subl	$1, -52(%rbp)
.L20:
	cmpl	$0, -52(%rbp)
	jns	.L30
	nop
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE11:
	.size	f, .-f
	.section	.rodata
.LC0:
	.string	"%lld"
	.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	$48, %rsp
	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	.L32
.L33:
	movq	-40(%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, -40(%rbp)
.L32:
	movq	n(%rip), %rax
	cmpq	%rax, -40(%rbp)
	jl	.L33
	leaq	p(%rip), %rax
	movq	%rax, %rdi
	call	f
	movq	$0, -32(%rbp)
	jmp	.L34
.L37:
	movq	n(%rip), %rax
	subq	$1, %rax
	subq	-32(%rbp), %rax
	cmpq	%rax, -32(%rbp)
	jge	.L41
	movq	-32(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	leaq	a(%rip), %rax
	movq	(%rdx,%rax), %rax
	movq	%rax, -8(%rbp)
	movq	n(%rip), %rax
	subq	$1, %rax
	subq	-32(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	leaq	a(%rip), %rax
	movq	(%rdx,%rax), %rax
	movq	-32(%rbp), %rdx
	leaq	0(,%rdx,8), %rcx
	leaq	a(%rip), %rdx
	movq	%rax, (%rcx,%rdx)
	movq	n(%rip), %rax
	subq	$1, %rax
	subq	-32(%rbp), %rax
	leaq	0(,%rax,8), %rcx
	leaq	a(%rip), %rdx
	movq	-8(%rbp), %rax
	movq	%rax, (%rcx,%rdx)
	addq	$1, -32(%rbp)
.L34:
	movq	n(%rip), %rax
	cmpq	%rax, -32(%rbp)
	jl	.L37
	jmp	.L36
.L41:
	nop
.L36:
	leaq	m(%rip), %rax
	movq	%rax, %rdi
	call	f
	movabsq	$4611686016279904256, %rax
	movq	%rax, -24(%rbp)
	movq	$0, -16(%rbp)
	jmp	.L38
.L39:
	movq	-16(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	leaq	p(%rip), %rax
	movq	(%rdx,%rax), %rcx
	movq	n(%rip), %rax
	subq	-16(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	leaq	m(%rip), %rax
	movq	(%rdx,%rax), %rax
	addq	%rcx, %rax
	leaq	(%rax,%rax), %rdx
	movq	-16(%rbp), %rax
	addq	%rax, %rdx
	movq	-24(%rbp), %rax
	cmpq	%rdx, %rax
	cmovg	%rdx, %rax
	movq	%rax, -24(%rbp)
	addq	$1, -16(%rbp)
.L38:
	movq	n(%rip), %rax
	cmpq	%rax, -16(%rbp)
	jle	.L39
	movq	-24(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	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
	.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	.L10
	.p2align 4,,10
	.p2align 3
.L13:
	testb	$1, %sil
	je	.L12
	movq	%r9, %rax
	imulq	%rcx, %rax
	cqto
	idivq	%r8
	movq	%rdx, %r9
.L12:
	imulq	%rcx, %rcx
	movq	%rcx, %rax
	cqto
	idivq	%r8
	movq	%rsi, %rax
	shrq	$63, %rax
	addq	%rax, %rsi
	sarq	%rsi
	movq	%rdx, %rcx
	jne	.L13
.L10:
	movq	%r9, %rax
	ret
	.cfi_endproc
.LFE55:
	.size	pom, .-pom
	.p2align 4
	.globl	f
	.type	f, @function
f:
.LFB56:
	.cfi_startproc
	endbr64
	movq	n(%rip), %rax
	movq	$0, stcnt(%rip)
	movl	%eax, %r11d
	subl	$2, %r11d
	js	.L49
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	subl	$1, %eax
	movq	%rdi, %r15
	leaq	a(%rip), %rdi
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	cltq
	movslq	%r11d, %r11
	leaq	stc(%rip), %r10
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	leaq	(%rdi,%rax,8), %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	leaq	sti(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	.p2align 4,,10
	.p2align 3
.L31:
	leaq	a(%rip), %rbx
	movq	0(%r13), %rdx
	movq	(%rbx,%r11,8), %rcx
	cmpq	%rdx, %rcx
	jg	.L33
	movq	8(%r15,%r11,8), %rax
	movq	%rax, (%r15,%r11,8)
	movq	(%rbx,%r11,8), %rax
	movq	0(%r13), %rcx
	movq	%rax, -8(%rsp)
	salq	$2, %rax
	cmpq	%rcx, %rax
	jg	.L22
	xorl	%edx, %edx
	.p2align 4,,10
	.p2align 3
.L23:
	salq	$2, %rax
	addq	$1, %rdx
	cmpq	%rcx, %rax
	jle	.L23
	movq	stcnt(%rip), %rax
	leaq	1(%r11), %rcx
	movq	%rcx, 0(%rbp,%rax,8)
	movq	%rdx, (%r10,%rax,8)
	addq	$1, %rax
	movq	%rax, stcnt(%rip)
.L22:
	subq	$1, %r11
	subq	$8, %r13
	testl	%r11d, %r11d
	jns	.L31
	popq	%rbx
	.cfi_remember_state
	.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
.L33:
	.cfi_restore_state
	xorl	%eax, %eax
	.p2align 4,,10
	.p2align 3
.L21:
	salq	$2, %rdx
	addq	$1, %rax
	cmpq	%rdx, %rcx
	jg	.L21
	movq	n(%rip), %r9
	movq	stcnt(%rip), %r12
	leaq	-1(%r9), %rdi
	subq	%r11, %rdi
	imulq	%rax, %rdi
	testq	%r12, %r12
	je	.L24
	xorl	%r8d, %r8d
	leaq	-1(%r12), %rcx
	.p2align 4,,10
	.p2align 3
.L29:
	movq	(%r10,%rcx,8), %rdx
	movq	%rax, %rsi
	movq	%r9, %r14
	movq	%rcx, %rbx
	cmpq	%rax, %rdx
	cmovle	%rdx, %rsi
	subq	0(%rbp,%rcx,8), %r14
	imulq	%rsi, %r14
	subq	%rsi, %rax
	subq	%r14, %rdi
	subq	%rsi, %rdx
	je	.L25
	movq	%rdx, (%r10,%rcx,8)
	testq	%rax, %rax
	jne	.L29
	testb	%r8b, %r8b
	jne	.L52
.L24:
	addq	8(%r15,%r11,8), %rdi
	movq	%rdi, (%r15,%r11,8)
	jmp	.L22
	.p2align 4,,10
	.p2align 3
.L25:
	testq	%rcx, %rcx
	movq	$0, (%r10,%rcx,8)
	setne	%r8b
	testq	%rax, %rax
	setne	%dl
	andb	%dl, %r8b
	je	.L28
	movq	%rcx, %r12
	subq	$1, %rcx
	jmp	.L29
	.p2align 4,,10
	.p2align 3
.L52:
	movq	%r12, %rbx
.L28:
	movq	%rbx, stcnt(%rip)
	jmp	.L24
.L49:
	.cfi_def_cfa_offset 8
	.cfi_restore 3
	.cfi_restore 6
	.cfi_restore 12
	.cfi_restore 13
	.cfi_restore 14
	.cfi_restore 15
	ret
	.cfi_endproc
.LFE56:
	.size	f, .-f
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%lld"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB57:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	xorl	%eax, %eax
	leaq	n(%rip), %rsi
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	leaq	.LC0(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	movq	%rbp, %rdi
	call	__isoc99_scanf@PLT
	cmpq	$0, n(%rip)
	jle	.L54
	leaq	a(%rip), %r12
	xorl	%ebx, %ebx
	.p2align 4,,10
	.p2align 3
.L55:
	movq	%r12, %rsi
	xorl	%eax, %eax
	movq	%rbp, %rdi
	addq	$1, %rbx
	call	__isoc99_scanf@PLT
	addq	$8, %r12
	cmpq	%rbx, n(%rip)
	jg	.L55
.L54:
	leaq	p(%rip), %rbx
	movq	%rbx, %rdi
	call	f
	movq	n(%rip), %rax
	testq	%rax, %rax
	jle	.L59
	subq	$1, %rax
	je	.L59
	xorl	%edx, %edx
	leaq	a(%rip), %rcx
	.p2align 4,,10
	.p2align 3
.L60:
	movq	(%rcx,%rdx,8), %rsi
	movq	(%rcx,%rax,8), %rdi
	movq	%rdi, (%rcx,%rdx,8)
	addq	$1, %rdx
	movq	%rsi, (%rcx,%rax,8)
	subq	$1, %rax
	cmpq	%rdx, %rax
	jg	.L60
.L59:
	leaq	m(%rip), %r12
	movq	%r12, %rdi
	call	f
	movq	n(%rip), %rsi
	movabsq	$4611686016279904256, %r8
	testq	%rsi, %rsi
	js	.L58
	movabsq	$4611686016279904256, %r8
	leaq	(%r12,%rsi,8), %rcx
	xorl	%eax, %eax
	addq	$1, %rsi
	.p2align 4,,10
	.p2align 3
.L61:
	movq	(%rcx), %rdx
	addq	(%rbx,%rax,8), %rdx
	leaq	(%rax,%rdx,2), %rdx
	cmpq	%rdx, %r8
	cmovg	%rdx, %r8
	addq	$1, %rax
	subq	$8, %rcx
	cmpq	%rsi, %rax
	jne	.L61
.L58:
	movq	%rbp, %rsi
	movq	%r8, %rdx
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	popq	%rbx
	.cfi_def_cfa_offset 24
	xorl	%eax, %eax
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE57:
	.size	main, .-main
	.globl	stcnt
	.bss
	.align 8
	.type	stcnt, @object
	.size	stcnt, 8
stcnt:
	.zero	8
	.globl	stc
	.align 32
	.type	stc, @object
	.size	stc, 1600080
stc:
	.zero	1600080
	.globl	sti
	.align 32
	.type	sti, @object
	.size	sti, 1600080
sti:
	.zero	1600080
	.globl	m
	.align 32
	.type	m, @object
	.size	m, 1600080
m:
	.zero	1600080
	.globl	p
	.align 32
	.type	p, @object
	.size	p, 1600080
p:
	.zero	1600080
	.globl	a
	.align 32
	.type	a, @object
	.size	a, 1600080
a:
	.zero	1600080
	.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	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
	.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	.L10
	.p2align 4,,10
	.p2align 3
.L13:
	testb	$1, %sil
	je	.L12
	movq	%r9, %rax
	imulq	%rcx, %rax
	cqto
	idivq	%r8
	movq	%rdx, %r9
.L12:
	imulq	%rcx, %rcx
	movq	%rcx, %rax
	cqto
	idivq	%r8
	movq	%rsi, %rax
	shrq	$63, %rax
	addq	%rax, %rsi
	sarq	%rsi
	movq	%rdx, %rcx
	jne	.L13
.L10:
	movq	%r9, %rax
	ret
	.cfi_endproc
.LFE55:
	.size	pom, .-pom
	.p2align 4
	.globl	f
	.type	f, @function
f:
.LFB56:
	.cfi_startproc
	endbr64
	movq	n(%rip), %rax
	movq	$0, stcnt(%rip)
	movl	%eax, %r11d
	subl	$2, %r11d
	js	.L49
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	subl	$1, %eax
	movq	%rdi, %r15
	leaq	a(%rip), %rdi
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	cltq
	movslq	%r11d, %r11
	leaq	stc(%rip), %r10
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	leaq	(%rdi,%rax,8), %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	leaq	sti(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	.p2align 4,,10
	.p2align 3
.L31:
	leaq	a(%rip), %rbx
	movq	0(%r13), %rdx
	movq	(%rbx,%r11,8), %rcx
	cmpq	%rdx, %rcx
	jg	.L33
	movq	8(%r15,%r11,8), %rax
	movq	%rax, (%r15,%r11,8)
	movq	(%rbx,%r11,8), %rax
	movq	0(%r13), %rcx
	movq	%rax, -8(%rsp)
	salq	$2, %rax
	cmpq	%rcx, %rax
	jg	.L22
	xorl	%edx, %edx
	.p2align 4,,10
	.p2align 3
.L23:
	salq	$2, %rax
	addq	$1, %rdx
	cmpq	%rcx, %rax
	jle	.L23
	movq	stcnt(%rip), %rax
	leaq	1(%r11), %rcx
	movq	%rcx, 0(%rbp,%rax,8)
	movq	%rdx, (%r10,%rax,8)
	addq	$1, %rax
	movq	%rax, stcnt(%rip)
.L22:
	subq	$1, %r11
	subq	$8, %r13
	testl	%r11d, %r11d
	jns	.L31
	popq	%rbx
	.cfi_remember_state
	.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
.L33:
	.cfi_restore_state
	xorl	%eax, %eax
	.p2align 4,,10
	.p2align 3
.L21:
	salq	$2, %rdx
	addq	$1, %rax
	cmpq	%rdx, %rcx
	jg	.L21
	movq	n(%rip), %r9
	movq	stcnt(%rip), %r12
	leaq	-1(%r9), %rdi
	subq	%r11, %rdi
	imulq	%rax, %rdi
	testq	%r12, %r12
	je	.L24
	xorl	%r8d, %r8d
	leaq	-1(%r12), %rcx
	.p2align 4,,10
	.p2align 3
.L29:
	movq	(%r10,%rcx,8), %rdx
	movq	%rax, %rsi
	movq	%r9, %r14
	movq	%rcx, %rbx
	cmpq	%rax, %rdx
	cmovle	%rdx, %rsi
	subq	0(%rbp,%rcx,8), %r14
	imulq	%rsi, %r14
	subq	%rsi, %rax
	subq	%r14, %rdi
	subq	%rsi, %rdx
	je	.L25
	movq	%rdx, (%r10,%rcx,8)
	testq	%rax, %rax
	jne	.L29
	testb	%r8b, %r8b
	jne	.L52
.L24:
	addq	8(%r15,%r11,8), %rdi
	movq	%rdi, (%r15,%r11,8)
	jmp	.L22
	.p2align 4,,10
	.p2align 3
.L25:
	testq	%rcx, %rcx
	movq	$0, (%r10,%rcx,8)
	setne	%r8b
	testq	%rax, %rax
	setne	%dl
	andb	%dl, %r8b
	je	.L28
	movq	%rcx, %r12
	subq	$1, %rcx
	jmp	.L29
	.p2align 4,,10
	.p2align 3
.L52:
	movq	%r12, %rbx
.L28:
	movq	%rbx, stcnt(%rip)
	jmp	.L24
.L49:
	.cfi_def_cfa_offset 8
	.cfi_restore 3
	.cfi_restore 6
	.cfi_restore 12
	.cfi_restore 13
	.cfi_restore 14
	.cfi_restore 15
	ret
	.cfi_endproc
.LFE56:
	.size	f, .-f
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%lld"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB57:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	xorl	%eax, %eax
	leaq	n(%rip), %rsi
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	leaq	.LC0(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	movq	%rbp, %rdi
	call	__isoc99_scanf@PLT
	cmpq	$0, n(%rip)
	jle	.L54
	leaq	a(%rip), %r12
	xorl	%ebx, %ebx
	.p2align 4,,10
	.p2align 3
.L55:
	movq	%r12, %rsi
	xorl	%eax, %eax
	movq	%rbp, %rdi
	addq	$1, %rbx
	call	__isoc99_scanf@PLT
	addq	$8, %r12
	cmpq	%rbx, n(%rip)
	jg	.L55
.L54:
	leaq	p(%rip), %rbx
	movq	%rbx, %rdi
	call	f
	movq	n(%rip), %rax
	testq	%rax, %rax
	jle	.L59
	subq	$1, %rax
	je	.L59
	xorl	%edx, %edx
	leaq	a(%rip), %rcx
	.p2align 4,,10
	.p2align 3
.L60:
	movq	(%rcx,%rdx,8), %rsi
	movq	(%rcx,%rax,8), %rdi
	movq	%rdi, (%rcx,%rdx,8)
	addq	$1, %rdx
	movq	%rsi, (%rcx,%rax,8)
	subq	$1, %rax
	cmpq	%rdx, %rax
	jg	.L60
.L59:
	leaq	m(%rip), %r12
	movq	%r12, %rdi
	call	f
	movq	n(%rip), %rsi
	movabsq	$4611686016279904256, %r8
	testq	%rsi, %rsi
	js	.L58
	movabsq	$4611686016279904256, %r8
	leaq	(%r12,%rsi,8), %rcx
	xorl	%eax, %eax
	addq	$1, %rsi
	.p2align 4,,10
	.p2align 3
.L61:
	movq	(%rcx), %rdx
	addq	(%rbx,%rax,8), %rdx
	leaq	(%rax,%rdx,2), %rdx
	cmpq	%rdx, %r8
	cmovg	%rdx, %r8
	addq	$1, %rax
	subq	$8, %rcx
	cmpq	%rsi, %rax
	jne	.L61
.L58:
	movq	%rbp, %rsi
	movq	%r8, %rdx
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	popq	%rbx
	.cfi_def_cfa_offset 24
	xorl	%eax, %eax
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE57:
	.size	main, .-main
	.globl	stcnt
	.bss
	.align 8
	.type	stcnt, @object
	.size	stcnt, 8
stcnt:
	.zero	8
	.globl	stc
	.align 32
	.type	stc, @object
	.size	stc, 1600080
stc:
	.zero	1600080
	.globl	sti
	.align 32
	.type	sti, @object
	.size	sti, 1600080
sti:
	.zero	1600080
	.globl	m
	.align 32
	.type	m, @object
	.size	m, 1600080
m:
	.zero	1600080
	.globl	p
	.align 32
	.type	p, @object
	.size	p, 1600080
p:
	.zero	1600080
	.globl	a
	.align 32
	.type	a, @object
	.size	a, 1600080
a:
	.zero	1600080
	.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>
#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 n;
ll a[200010];
ll p[200010],m[200010];
//p[i]=(0<=a[i]<=...<=a[n-1]となるために必要な操作の回数)/2
//m[i]=(a[0]>=...>=a[i]>=0となるために必要な操作の回数)/2
ll sti[200010],stc[200010],stcnt;

void f(ll *p){
	//pを構成する
	stcnt=0;
	for(int i=n-2;i>=0;i--){
		if(a[i]<=a[i+1]){
			p[i]=p[i+1];
			ll temp=a[i],cnt=0;
			while(temp*4<=a[i+1])temp*=4,cnt++;
			if(cnt){
				sti[stcnt]=i+1;
				stc[stcnt]=cnt;
				stcnt++;
			}
		}else{
			ll temp=a[i+1],cnt=0;
			while(a[i]>temp)temp*=4,cnt++;
			//本当はi+1～n-1までをcnt回やりたいけど、マイナスがあったらそこで軽減される
			ll t=(n-1-i)*cnt;
			while(stcnt&&cnt){
				ll k=min(cnt,stc[stcnt-1]);
				t-=k*(n-sti[stcnt-1]);
				cnt-=k;
				stc[stcnt-1]-=k;
				if(!stc[stcnt-1])stcnt--;
			}
			p[i]=p[i+1]+t;
		}
//		rep(x,0,stcnt)printf("%d:%d ",sti[x],stc[x]);puts("");
	}
}


int main(){
	scanf("%lld",&n);
	rep(i,0,n)scanf("%lld",a+i);
	f(p);
	rep(i,0,n){
		if(i>=n-1-i)break;
		ll t=a[i];
		a[i]=a[n-1-i];
		a[n-1-i]=t;
	}
	f(m);

//	rep(i,0,n)printf("%2lld ",p[i]);puts("");
//	rep(i,0,n)printf("%2lld ",m[n-i]);puts("");
	//0がどこに入るか全探索
	ll ans=INF;
	rep(i,0,n+1)ans=min(ans,p[i]*2+m[n-i]*2+i);
	printf("%lld",ans);
}
4
2 1 4 1
 8
347554626 129662684 181537270 324043958 468214806 916875077 825989291 319670097
 5
1 2 2 4 5
 8
67210447 129662684 181537270 324043958 468214806 916875077 825989291 319670097
 5
1 2 2 8 5
 4
3 1 4 4
 8
989919 129662684 181537270 289484339 259507721 916875077 745256200 319670097
 8
1273050 129662684 181537270 135628006 259507721 916875077 745256200 319670097
 8
1273050 129662684 181537270 135628006 259507721 916875077 1160167182 319670097
 8
657312726 129662684 181537270 131300599 468214806 916875077 825989291 319670097

3 7 0 6 2 1 14 16 12 11
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 n;
ll a[200010];
ll p[200010],m[200010];
//p[i]=(0<=a[i]<=...<=a[n-1]となるために必要な操作の回数)/2
//m[i]=(a[0]>=...>=a[i]>=0となるために必要な操作の回数)/2
ll sti[200010],stc[200010],stcnt;

void f(ll *p){
	//pを構成する
	stcnt=0;
	for(int i=n-2;i>=0;i--){
		if(a[i]<=a[i+1]){
			p[i]=p[i+1];
			ll temp=a[i],cnt=0;
			while(temp*4<=a[i+1])temp*=4,cnt++;
			if(cnt){
				sti[stcnt]=i+1;
				stc[stcnt]=cnt;
				stcnt++;
			}
		}else{
			ll temp=a[i+1],cnt=0;
			while(a[i]>temp)temp*=4,cnt++;
			//本当はi+1～n-1までをcnt回やりたいけど、マイナスがあったらそこで軽減される
			ll t=(n-1-i)*cnt;
			while(stcnt&&cnt){
				ll k=min(cnt,stc[stcnt-1]);
				t-=k*(n-sti[stcnt-1]);
				cnt-=k;
				stc[stcnt-1]-=k;
				if(!stc[stcnt-1])stcnt--;
			}
			p[i]=p[i+1]+t;
		}
//		rep(x,0,stcnt)printf("%d:%d ",sti[x],stc[x]);puts("");
	}
}


int main(){
	scanf("%lld",&n);
	rep(i,0,n)scanf("%lld",a+i);
	f(p);
	rep(i,0,n){
		if(i>=n-1-i)break;
		ll t=a[i];
		a[i]=a[n-1-i];
		a[n-1-i]=t;
	}
	f(m);

//	rep(i,0,n)printf("%2lld ",p[i]);puts("");
//	rep(i,0,n)printf("%2lld ",m[n-i]);puts("");
	//0がどこに入るか全探索
	ll ans=INF;
	rep(i,0,n+1)ans=min(ans,p[i]*2+m[n-i]*2+i);
	printf("%lld",ans);
}```

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	n
	.bss
	.align 8
	.type	n, @object
	.size	n, 8
n:
	.zero	8
	.globl	a
	.align 32
	.type	a, @object
	.size	a, 1600080
a:
	.zero	1600080
	.globl	p
	.align 32
	.type	p, @object
	.size	p, 1600080
p:
	.zero	1600080
	.globl	m
	.align 32
	.type	m, @object
	.size	m, 1600080
m:
	.zero	1600080
	.globl	sti
	.align 32
	.type	sti, @object
	.size	sti, 1600080
sti:
	.zero	1600080
	.globl	stc
	.align 32
	.type	stc, @object
	.size	stc, 1600080
stc:
	.zero	1600080
	.globl	stcnt
	.align 8
	.type	stcnt, @object
	.size	stcnt, 8
stcnt:
	.zero	8
	.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
	movq	%rdi, -72(%rbp)
	movq	$0, stcnt(%rip)
	movq	n(%rip), %rax
	subl	$2, %eax
	movl	%eax, -52(%rbp)
	jmp	.L20
.L30:
	movl	-52(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	a(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movl	-52(%rbp), %eax
	addl	$1, %eax
	cltq
	leaq	0(,%rax,8), %rcx
	leaq	a(%rip), %rax
	movq	(%rcx,%rax), %rax
	cmpq	%rax, %rdx
	jg	.L21
	movl	-52(%rbp), %eax
	cltq
	addq	$1, %rax
	leaq	0(,%rax,8), %rdx
	movq	-72(%rbp), %rax
	addq	%rdx, %rax
	movl	-52(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,8), %rcx
	movq	-72(%rbp), %rdx
	addq	%rcx, %rdx
	movq	(%rax), %rax
	movq	%rax, (%rdx)
	movl	-52(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	a(%rip), %rax
	movq	(%rdx,%rax), %rax
	movq	%rax, -48(%rbp)
	movq	$0, -40(%rbp)
	jmp	.L22
.L23:
	salq	$2, -48(%rbp)
	addq	$1, -40(%rbp)
.L22:
	movq	-48(%rbp), %rax
	leaq	0(,%rax,4), %rcx
	movl	-52(%rbp), %eax
	addl	$1, %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	a(%rip), %rax
	movq	(%rdx,%rax), %rax
	cmpq	%rax, %rcx
	jle	.L23
	cmpq	$0, -40(%rbp)
	je	.L24
	movl	-52(%rbp), %eax
	addl	$1, %eax
	movq	stcnt(%rip), %rdx
	cltq
	leaq	0(,%rdx,8), %rcx
	leaq	sti(%rip), %rdx
	movq	%rax, (%rcx,%rdx)
	movq	stcnt(%rip), %rax
	leaq	0(,%rax,8), %rcx
	leaq	stc(%rip), %rdx
	movq	-40(%rbp), %rax
	movq	%rax, (%rcx,%rdx)
	movq	stcnt(%rip), %rax
	addq	$1, %rax
	movq	%rax, stcnt(%rip)
	jmp	.L24
.L21:
	movl	-52(%rbp), %eax
	addl	$1, %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	a(%rip), %rax
	movq	(%rdx,%rax), %rax
	movq	%rax, -32(%rbp)
	movq	$0, -24(%rbp)
	jmp	.L25
.L26:
	salq	$2, -32(%rbp)
	addq	$1, -24(%rbp)
.L25:
	movl	-52(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	a(%rip), %rax
	movq	(%rdx,%rax), %rax
	cmpq	%rax, -32(%rbp)
	jl	.L26
	movq	n(%rip), %rax
	leaq	-1(%rax), %rdx
	movl	-52(%rbp), %eax
	cltq
	subq	%rax, %rdx
	movq	-24(%rbp), %rax
	imulq	%rdx, %rax
	movq	%rax, -16(%rbp)
	jmp	.L27
.L29:
	movq	stcnt(%rip), %rax
	subq	$1, %rax
	leaq	0(,%rax,8), %rdx
	leaq	stc(%rip), %rax
	movq	(%rdx,%rax), %rax
	movq	-24(%rbp), %rdx
	cmpq	%rax, %rdx
	cmovle	%rdx, %rax
	movq	%rax, -8(%rbp)
	movq	n(%rip), %rax
	movq	stcnt(%rip), %rdx
	subq	$1, %rdx
	leaq	0(,%rdx,8), %rcx
	leaq	sti(%rip), %rdx
	movq	(%rcx,%rdx), %rdx
	subq	%rdx, %rax
	imulq	-8(%rbp), %rax
	subq	%rax, -16(%rbp)
	movq	-8(%rbp), %rax
	subq	%rax, -24(%rbp)
	movq	stcnt(%rip), %rax
	subq	$1, %rax
	leaq	0(,%rax,8), %rdx
	leaq	stc(%rip), %rax
	movq	(%rdx,%rax), %rax
	movq	stcnt(%rip), %rdx
	subq	$1, %rdx
	subq	-8(%rbp), %rax
	leaq	0(,%rdx,8), %rcx
	leaq	stc(%rip), %rdx
	movq	%rax, (%rcx,%rdx)
	movq	stcnt(%rip), %rax
	subq	$1, %rax
	leaq	0(,%rax,8), %rdx
	leaq	stc(%rip), %rax
	movq	(%rdx,%rax), %rax
	testq	%rax, %rax
	jne	.L27
	movq	stcnt(%rip), %rax
	subq	$1, %rax
	movq	%rax, stcnt(%rip)
.L27:
	movq	stcnt(%rip), %rax
	testq	%rax, %rax
	je	.L28
	cmpq	$0, -24(%rbp)
	jne	.L29
.L28:
	movl	-52(%rbp), %eax
	cltq
	addq	$1, %rax
	leaq	0(,%rax,8), %rdx
	movq	-72(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rcx
	movl	-52(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-72(%rbp), %rax
	addq	%rdx, %rax
	movq	-16(%rbp), %rdx
	addq	%rcx, %rdx
	movq	%rdx, (%rax)
.L24:
	subl	$1, -52(%rbp)
.L20:
	cmpl	$0, -52(%rbp)
	jns	.L30
	nop
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE11:
	.size	f, .-f
	.section	.rodata
.LC0:
	.string	"%lld"
	.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	$48, %rsp
	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	.L32
.L33:
	movq	-40(%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, -40(%rbp)
.L32:
	movq	n(%rip), %rax
	cmpq	%rax, -40(%rbp)
	jl	.L33
	leaq	p(%rip), %rax
	movq	%rax, %rdi
	call	f
	movq	$0, -32(%rbp)
	jmp	.L34
.L37:
	movq	n(%rip), %rax
	subq	$1, %rax
	subq	-32(%rbp), %rax
	cmpq	%rax, -32(%rbp)
	jge	.L41
	movq	-32(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	leaq	a(%rip), %rax
	movq	(%rdx,%rax), %rax
	movq	%rax, -8(%rbp)
	movq	n(%rip), %rax
	subq	$1, %rax
	subq	-32(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	leaq	a(%rip), %rax
	movq	(%rdx,%rax), %rax
	movq	-32(%rbp), %rdx
	leaq	0(,%rdx,8), %rcx
	leaq	a(%rip), %rdx
	movq	%rax, (%rcx,%rdx)
	movq	n(%rip), %rax
	subq	$1, %rax
	subq	-32(%rbp), %rax
	leaq	0(,%rax,8), %rcx
	leaq	a(%rip), %rdx
	movq	-8(%rbp), %rax
	movq	%rax, (%rcx,%rdx)
	addq	$1, -32(%rbp)
.L34:
	movq	n(%rip), %rax
	cmpq	%rax, -32(%rbp)
	jl	.L37
	jmp	.L36
.L41:
	nop
.L36:
	leaq	m(%rip), %rax
	movq	%rax, %rdi
	call	f
	movabsq	$4611686016279904256, %rax
	movq	%rax, -24(%rbp)
	movq	$0, -16(%rbp)
	jmp	.L38
.L39:
	movq	-16(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	leaq	p(%rip), %rax
	movq	(%rdx,%rax), %rcx
	movq	n(%rip), %rax
	subq	-16(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	leaq	m(%rip), %rax
	movq	(%rdx,%rax), %rax
	addq	%rcx, %rax
	leaq	(%rax,%rax), %rdx
	movq	-16(%rbp), %rax
	addq	%rax, %rdx
	movq	-24(%rbp), %rax
	cmpq	%rdx, %rax
	cmovg	%rdx, %rax
	movq	%rax, -24(%rbp)
	addq	$1, -16(%rbp)
.L38:
	movq	n(%rip), %rax
	cmpq	%rax, -16(%rbp)
	jle	.L39
	movq	-24(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	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	n
	.bss
	.align 8
	.type	n, @object
	.size	n, 8
n:
	.zero	8
	.globl	a
	.align 32
	.type	a, @object
	.size	a, 1600080
a:
	.zero	1600080
	.globl	p
	.align 32
	.type	p, @object
	.size	p, 1600080
p:
	.zero	1600080
	.globl	m
	.align 32
	.type	m, @object
	.size	m, 1600080
m:
	.zero	1600080
	.globl	sti
	.align 32
	.type	sti, @object
	.size	sti, 1600080
sti:
	.zero	1600080
	.globl	stc
	.align 32
	.type	stc, @object
	.size	stc, 1600080
stc:
	.zero	1600080
	.globl	stcnt
	.align 8
	.type	stcnt, @object
	.size	stcnt, 8
stcnt:
	.zero	8
	.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
	movq	%rdi, -72(%rbp)
	movq	$0, stcnt(%rip)
	movq	n(%rip), %rax
	subl	$2, %eax
	movl	%eax, -52(%rbp)
	jmp	.L20
.L30:
	movl	-52(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	a(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movl	-52(%rbp), %eax
	addl	$1, %eax
	cltq
	leaq	0(,%rax,8), %rcx
	leaq	a(%rip), %rax
	movq	(%rcx,%rax), %rax
	cmpq	%rax, %rdx
	jg	.L21
	movl	-52(%rbp), %eax
	cltq
	addq	$1, %rax
	leaq	0(,%rax,8), %rdx
	movq	-72(%rbp), %rax
	addq	%rdx, %rax
	movl	-52(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,8), %rcx
	movq	-72(%rbp), %rdx
	addq	%rcx, %rdx
	movq	(%rax), %rax
	movq	%rax, (%rdx)
	movl	-52(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	a(%rip), %rax
	movq	(%rdx,%rax), %rax
	movq	%rax, -48(%rbp)
	movq	$0, -40(%rbp)
	jmp	.L22
.L23:
	salq	$2, -48(%rbp)
	addq	$1, -40(%rbp)
.L22:
	movq	-48(%rbp), %rax
	leaq	0(,%rax,4), %rcx
	movl	-52(%rbp), %eax
	addl	$1, %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	a(%rip), %rax
	movq	(%rdx,%rax), %rax
	cmpq	%rax, %rcx
	jle	.L23
	cmpq	$0, -40(%rbp)
	je	.L24
	movl	-52(%rbp), %eax
	addl	$1, %eax
	movq	stcnt(%rip), %rdx
	cltq
	leaq	0(,%rdx,8), %rcx
	leaq	sti(%rip), %rdx
	movq	%rax, (%rcx,%rdx)
	movq	stcnt(%rip), %rax
	leaq	0(,%rax,8), %rcx
	leaq	stc(%rip), %rdx
	movq	-40(%rbp), %rax
	movq	%rax, (%rcx,%rdx)
	movq	stcnt(%rip), %rax
	addq	$1, %rax
	movq	%rax, stcnt(%rip)
	jmp	.L24
.L21:
	movl	-52(%rbp), %eax
	addl	$1, %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	a(%rip), %rax
	movq	(%rdx,%rax), %rax
	movq	%rax, -32(%rbp)
	movq	$0, -24(%rbp)
	jmp	.L25
.L26:
	salq	$2, -32(%rbp)
	addq	$1, -24(%rbp)
.L25:
	movl	-52(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	a(%rip), %rax
	movq	(%rdx,%rax), %rax
	cmpq	%rax, -32(%rbp)
	jl	.L26
	movq	n(%rip), %rax
	leaq	-1(%rax), %rdx
	movl	-52(%rbp), %eax
	cltq
	subq	%rax, %rdx
	movq	-24(%rbp), %rax
	imulq	%rdx, %rax
	movq	%rax, -16(%rbp)
	jmp	.L27
.L29:
	movq	stcnt(%rip), %rax
	subq	$1, %rax
	leaq	0(,%rax,8), %rdx
	leaq	stc(%rip), %rax
	movq	(%rdx,%rax), %rax
	movq	-24(%rbp), %rdx
	cmpq	%rax, %rdx
	cmovle	%rdx, %rax
	movq	%rax, -8(%rbp)
	movq	n(%rip), %rax
	movq	stcnt(%rip), %rdx
	subq	$1, %rdx
	leaq	0(,%rdx,8), %rcx
	leaq	sti(%rip), %rdx
	movq	(%rcx,%rdx), %rdx
	subq	%rdx, %rax
	imulq	-8(%rbp), %rax
	subq	%rax, -16(%rbp)
	movq	-8(%rbp), %rax
	subq	%rax, -24(%rbp)
	movq	stcnt(%rip), %rax
	subq	$1, %rax
	leaq	0(,%rax,8), %rdx
	leaq	stc(%rip), %rax
	movq	(%rdx,%rax), %rax
	movq	stcnt(%rip), %rdx
	subq	$1, %rdx
	subq	-8(%rbp), %rax
	leaq	0(,%rdx,8), %rcx
	leaq	stc(%rip), %rdx
	movq	%rax, (%rcx,%rdx)
	movq	stcnt(%rip), %rax
	subq	$1, %rax
	leaq	0(,%rax,8), %rdx
	leaq	stc(%rip), %rax
	movq	(%rdx,%rax), %rax
	testq	%rax, %rax
	jne	.L27
	movq	stcnt(%rip), %rax
	subq	$1, %rax
	movq	%rax, stcnt(%rip)
.L27:
	movq	stcnt(%rip), %rax
	testq	%rax, %rax
	je	.L28
	cmpq	$0, -24(%rbp)
	jne	.L29
.L28:
	movl	-52(%rbp), %eax
	cltq
	addq	$1, %rax
	leaq	0(,%rax,8), %rdx
	movq	-72(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rcx
	movl	-52(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-72(%rbp), %rax
	addq	%rdx, %rax
	movq	-16(%rbp), %rdx
	addq	%rcx, %rdx
	movq	%rdx, (%rax)
.L24:
	subl	$1, -52(%rbp)
.L20:
	cmpl	$0, -52(%rbp)
	jns	.L30
	nop
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE11:
	.size	f, .-f
	.section	.rodata
.LC0:
	.string	"%lld"
	.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	$48, %rsp
	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	.L32
.L33:
	movq	-40(%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, -40(%rbp)
.L32:
	movq	n(%rip), %rax
	cmpq	%rax, -40(%rbp)
	jl	.L33
	leaq	p(%rip), %rax
	movq	%rax, %rdi
	call	f
	movq	$0, -32(%rbp)
	jmp	.L34
.L37:
	movq	n(%rip), %rax
	subq	$1, %rax
	subq	-32(%rbp), %rax
	cmpq	%rax, -32(%rbp)
	jge	.L41
	movq	-32(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	leaq	a(%rip), %rax
	movq	(%rdx,%rax), %rax
	movq	%rax, -8(%rbp)
	movq	n(%rip), %rax
	subq	$1, %rax
	subq	-32(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	leaq	a(%rip), %rax
	movq	(%rdx,%rax), %rax
	movq	-32(%rbp), %rdx
	leaq	0(,%rdx,8), %rcx
	leaq	a(%rip), %rdx
	movq	%rax, (%rcx,%rdx)
	movq	n(%rip), %rax
	subq	$1, %rax
	subq	-32(%rbp), %rax
	leaq	0(,%rax,8), %rcx
	leaq	a(%rip), %rdx
	movq	-8(%rbp), %rax
	movq	%rax, (%rcx,%rdx)
	addq	$1, -32(%rbp)
.L34:
	movq	n(%rip), %rax
	cmpq	%rax, -32(%rbp)
	jl	.L37
	jmp	.L36
.L41:
	nop
.L36:
	leaq	m(%rip), %rax
	movq	%rax, %rdi
	call	f
	movabsq	$4611686016279904256, %rax
	movq	%rax, -24(%rbp)
	movq	$0, -16(%rbp)
	jmp	.L38
.L39:
	movq	-16(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	leaq	p(%rip), %rax
	movq	(%rdx,%rax), %rcx
	movq	n(%rip), %rax
	subq	-16(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	leaq	m(%rip), %rax
	movq	(%rdx,%rax), %rax
	addq	%rcx, %rax
	leaq	(%rax,%rax), %rdx
	movq	-16(%rbp), %rax
	addq	%rax, %rdx
	movq	-24(%rbp), %rax
	cmpq	%rdx, %rax
	cmovg	%rdx, %rax
	movq	%rax, -24(%rbp)
	addq	$1, -16(%rbp)
.L38:
	movq	n(%rip), %rax
	cmpq	%rax, -16(%rbp)
	jle	.L39
	movq	-24(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	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:
