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>

int cost(int x,int y){
	if(x>=y){
		return (x-y);
	}else{
		return (y-x);
	}
}

int main(void){
	int n,a[100001],i,sum=0,ans;
	scanf("%d",&n);
	a[0]=0;
	for(i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	a[n+1]=0;
	for(i=1;i<=n+1;i++){
		if(a[i]>=a[i-1]){
			sum=sum+(a[i]-a[i-1]);
		}else{
			sum=sum+(a[i-1]-a[i]);
		}
	}
	for(i=1;i<=n;i++){
		ans=sum+cost(a[i+1],a[i-1])-cost(a[i+1],a[i])-cost(a[i],a[i-1]);
		printf("%d\n",ans);
	}
	return 0;
}

```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	cost
	.type	cost, @function
cost:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -4(%rbp)
	movl	%esi, -8(%rbp)
	movl	-4(%rbp), %eax
	cmpl	-8(%rbp), %eax
	jl	.L2
	movl	-4(%rbp), %eax
	subl	-8(%rbp), %eax
	jmp	.L3
.L2:
	movl	-8(%rbp), %eax
	subl	-4(%rbp), %eax
.L3:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	cost, .-cost
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d\n"
	.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
	pushq	%rbx
	leaq	-397312(%rsp), %r11
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	subq	$2728, %rsp
	.cfi_offset 3, -24
	movq	%fs:40, %rax
	movq	%rax, -24(%rbp)
	xorl	%eax, %eax
	movl	$0, -400040(%rbp)
	leaq	-400048(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -400032(%rbp)
	movl	$1, -400044(%rbp)
	jmp	.L5
.L6:
	leaq	-400032(%rbp), %rdx
	movl	-400044(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -400044(%rbp)
.L5:
	movl	-400048(%rbp), %eax
	cmpl	%eax, -400044(%rbp)
	jle	.L6
	movl	-400048(%rbp), %eax
	addl	$1, %eax
	cltq
	movl	$0, -400032(%rbp,%rax,4)
	movl	$1, -400044(%rbp)
	jmp	.L7
.L10:
	movl	-400044(%rbp), %eax
	cltq
	movl	-400032(%rbp,%rax,4), %edx
	movl	-400044(%rbp), %eax
	subl	$1, %eax
	cltq
	movl	-400032(%rbp,%rax,4), %eax
	cmpl	%eax, %edx
	jl	.L8
	movl	-400044(%rbp), %eax
	cltq
	movl	-400032(%rbp,%rax,4), %edx
	movl	-400044(%rbp), %eax
	subl	$1, %eax
	cltq
	movl	-400032(%rbp,%rax,4), %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	addl	%eax, -400040(%rbp)
	jmp	.L9
.L8:
	movl	-400044(%rbp), %eax
	subl	$1, %eax
	cltq
	movl	-400032(%rbp,%rax,4), %edx
	movl	-400044(%rbp), %eax
	cltq
	movl	-400032(%rbp,%rax,4), %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	addl	%eax, -400040(%rbp)
.L9:
	addl	$1, -400044(%rbp)
.L7:
	movl	-400048(%rbp), %eax
	addl	$1, %eax
	cmpl	%eax, -400044(%rbp)
	jle	.L10
	movl	$1, -400044(%rbp)
	jmp	.L11
.L12:
	movl	-400044(%rbp), %eax
	subl	$1, %eax
	cltq
	movl	-400032(%rbp,%rax,4), %edx
	movl	-400044(%rbp), %eax
	addl	$1, %eax
	cltq
	movl	-400032(%rbp,%rax,4), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	cost
	movl	-400040(%rbp), %edx
	leal	(%rax,%rdx), %ebx
	movl	-400044(%rbp), %eax
	cltq
	movl	-400032(%rbp,%rax,4), %edx
	movl	-400044(%rbp), %eax
	addl	$1, %eax
	cltq
	movl	-400032(%rbp,%rax,4), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	cost
	subl	%eax, %ebx
	movl	-400044(%rbp), %eax
	subl	$1, %eax
	cltq
	movl	-400032(%rbp,%rax,4), %edx
	movl	-400044(%rbp), %eax
	cltq
	movl	-400032(%rbp,%rax,4), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	cost
	movl	%eax, %edx
	movl	%ebx, %eax
	subl	%edx, %eax
	movl	%eax, -400036(%rbp)
	movl	-400036(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	addl	$1, -400044(%rbp)
.L11:
	movl	-400048(%rbp), %eax
	cmpl	%eax, -400044(%rbp)
	jle	.L12
	movl	$0, %eax
	movq	-24(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L14
	call	__stack_chk_fail@PLT
.L14:
	movq	-8(%rbp), %rbx
	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	cost
	.type	cost, @function
cost:
.LFB23:
	.cfi_startproc
	endbr64
	movl	%edi, %edx
	movl	%esi, %eax
	subl	%esi, %edx
	subl	%edi, %eax
	cmpl	%esi, %edi
	cmovge	%edx, %eax
	ret
	.cfi_endproc
.LFE23:
	.size	cost, .-cost
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB24:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	leaq	-397312(%rsp), %r11
	.cfi_def_cfa 11, 397352
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	.cfi_def_cfa_register 7
	subq	$2728, %rsp
	.cfi_def_cfa_offset 400080
	leaq	.LC0(%rip), %r12
	movq	%r12, %rdi
	movq	%fs:40, %rax
	movq	%rax, 400024(%rsp)
	xorl	%eax, %eax
	leaq	12(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %esi
	movl	$0, 16(%rsp)
	testl	%esi, %esi
	jle	.L6
	leaq	20(%rsp), %rbp
	movl	$1, %ebx
	.p2align 4,,10
	.p2align 3
.L7:
	movq	%rbp, %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	addl	$1, %ebx
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %esi
	addq	$4, %rbp
	cmpl	%ebx, %esi
	jge	.L7
	leal	1(%rsi), %eax
	movslq	%eax, %rdx
	movl	$0, 16(%rsp,%rdx,4)
	testl	%eax, %eax
	jle	.L28
	cmpl	$1, %esi
	jle	.L9
	movl	16(%rsp), %eax
	leaq	24(%rsp), %rcx
	xorl	%r12d, %r12d
	movl	$1, %edi
.L14:
	movl	-4(%rcx), %edx
	cmpl	%edx, %eax
	jle	.L40
	subl	%edx, %eax
	leal	(%rax,%r12), %r8d
.L11:
	movl	(%rcx), %eax
	cmpl	%eax, %edx
	jle	.L12
	subl	%eax, %edx
	leal	(%rdx,%r8), %r12d
.L13:
	addl	$2, %edi
	addq	$8, %rcx
	cmpl	%edi, %esi
	jg	.L14
.L15:
	movslq	%edi, %rax
	leaq	16(%rsp,%rax,4), %rax
	jmp	.L18
	.p2align 4,,10
	.p2align 3
.L41:
	subl	%edx, %ecx
	addq	$4, %rax
	leal	1(%rdi), %edx
	addl	%ecx, %r12d
	cmpl	%esi, %edi
	jg	.L8
.L29:
	movl	%edx, %edi
.L18:
	movl	(%rax), %ecx
	movl	-4(%rax), %edx
	cmpl	%ecx, %edx
	jle	.L41
	subl	%ecx, %edx
	addq	$4, %rax
	addl	%edx, %r12d
	leal	1(%rdi), %edx
	cmpl	%esi, %edi
	jle	.L29
.L8:
	movl	$1, %ebp
	leaq	16(%rsp), %r13
	leaq	.LC1(%rip), %rbx
	testl	%esi, %esi
	jle	.L26
	.p2align 4,,10
	.p2align 3
.L19:
	movl	4(%r13,%rbp,4), %esi
	movl	-4(%r13,%rbp,4), %ecx
	movl	%esi, %eax
	movl	%ecx, %edx
	movl	%esi, %r8d
	subl	%ecx, %eax
	subl	%esi, %edx
	cmpl	%esi, %ecx
	cmovle	%eax, %edx
	movl	0(%r13,%rbp,4), %eax
	subl	%eax, %r8d
	movl	%eax, %edi
	addl	%r12d, %edx
	subl	%esi, %edi
	cmpl	%eax, %esi
	movl	%r8d, %esi
	cmovl	%edi, %esi
	movl	%eax, %edi
	subl	%ecx, %edi
	subl	%esi, %edx
	movl	%ecx, %esi
	subl	%eax, %esi
	cmpl	%eax, %ecx
	movl	%edi, %eax
	movl	$1, %edi
	cmovg	%esi, %eax
	movq	%rbx, %rsi
	addq	$1, %rbp
	subl	%eax, %edx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	cmpl	%ebp, 12(%rsp)
	jge	.L19
.L26:
	movq	400024(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L42
	addq	$400040, %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
.L40:
	.cfi_restore_state
	movl	%edx, %r8d
	subl	%eax, %r8d
	addl	%r12d, %r8d
	jmp	.L11
.L12:
	movl	%eax, %r12d
	subl	%edx, %r12d
	addl	%r8d, %r12d
	jmp	.L13
.L6:
	leal	1(%rsi), %eax
	movslq	%eax, %rdx
	subl	$1, %eax
	movl	$0, 16(%rsp,%rdx,4)
	jne	.L26
.L9:
	xorl	%r12d, %r12d
	movl	$1, %edi
	jmp	.L15
.L28:
	xorl	%r12d, %r12d
	jmp	.L8
.L42:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE24:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:

rule
	.file	"temp.c"
	.text
	.p2align 4
	.globl	cost
	.type	cost, @function
cost:
.LFB23:
	.cfi_startproc
	endbr64
	movl	%edi, %edx
	movl	%esi, %eax
	subl	%esi, %edx
	subl	%edi, %eax
	cmpl	%esi, %edi
	cmovge	%edx, %eax
	ret
	.cfi_endproc
.LFE23:
	.size	cost, .-cost
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB24:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	leaq	-397312(%rsp), %r11
	.cfi_def_cfa 11, 397352
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	.cfi_def_cfa_register 7
	subq	$2728, %rsp
	.cfi_def_cfa_offset 400080
	leaq	.LC0(%rip), %r12
	movq	%r12, %rdi
	movq	%fs:40, %rax
	movq	%rax, 400024(%rsp)
	xorl	%eax, %eax
	leaq	12(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %esi
	movl	$0, 16(%rsp)
	testl	%esi, %esi
	jle	.L6
	leaq	20(%rsp), %rbp
	movl	$1, %ebx
	.p2align 4,,10
	.p2align 3
.L7:
	movq	%rbp, %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	addl	$1, %ebx
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %esi
	addq	$4, %rbp
	cmpl	%ebx, %esi
	jge	.L7
	leal	1(%rsi), %eax
	movslq	%eax, %rdx
	movl	$0, 16(%rsp,%rdx,4)
	testl	%eax, %eax
	jle	.L28
	cmpl	$1, %esi
	jle	.L9
	movl	16(%rsp), %eax
	leaq	24(%rsp), %rcx
	xorl	%r12d, %r12d
	movl	$1, %edi
.L14:
	movl	-4(%rcx), %edx
	cmpl	%edx, %eax
	jle	.L40
	subl	%edx, %eax
	leal	(%rax,%r12), %r8d
.L11:
	movl	(%rcx), %eax
	cmpl	%eax, %edx
	jle	.L12
	subl	%eax, %edx
	leal	(%rdx,%r8), %r12d
.L13:
	addl	$2, %edi
	addq	$8, %rcx
	cmpl	%edi, %esi
	jg	.L14
.L15:
	movslq	%edi, %rax
	leaq	16(%rsp,%rax,4), %rax
	jmp	.L18
	.p2align 4,,10
	.p2align 3
.L41:
	subl	%edx, %ecx
	addq	$4, %rax
	leal	1(%rdi), %edx
	addl	%ecx, %r12d
	cmpl	%esi, %edi
	jg	.L8
.L29:
	movl	%edx, %edi
.L18:
	movl	(%rax), %ecx
	movl	-4(%rax), %edx
	cmpl	%ecx, %edx
	jle	.L41
	subl	%ecx, %edx
	addq	$4, %rax
	addl	%edx, %r12d
	leal	1(%rdi), %edx
	cmpl	%esi, %edi
	jle	.L29
.L8:
	movl	$1, %ebp
	leaq	16(%rsp), %r13
	leaq	.LC1(%rip), %rbx
	testl	%esi, %esi
	jle	.L26
	.p2align 4,,10
	.p2align 3
.L19:
	movl	4(%r13,%rbp,4), %esi
	movl	-4(%r13,%rbp,4), %ecx
	movl	%esi, %eax
	movl	%ecx, %edx
	movl	%esi, %r8d
	subl	%ecx, %eax
	subl	%esi, %edx
	cmpl	%esi, %ecx
	cmovle	%eax, %edx
	movl	0(%r13,%rbp,4), %eax
	subl	%eax, %r8d
	movl	%eax, %edi
	addl	%r12d, %edx
	subl	%esi, %edi
	cmpl	%eax, %esi
	movl	%r8d, %esi
	cmovl	%edi, %esi
	movl	%eax, %edi
	subl	%ecx, %edi
	subl	%esi, %edx
	movl	%ecx, %esi
	subl	%eax, %esi
	cmpl	%eax, %ecx
	movl	%edi, %eax
	movl	$1, %edi
	cmovg	%esi, %eax
	movq	%rbx, %rsi
	addq	$1, %rbp
	subl	%eax, %edx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	cmpl	%ebp, 12(%rsp)
	jge	.L19
.L26:
	movq	400024(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L42
	addq	$400040, %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
.L40:
	.cfi_restore_state
	movl	%edx, %r8d
	subl	%eax, %r8d
	addl	%r12d, %r8d
	jmp	.L11
.L12:
	movl	%eax, %r12d
	subl	%edx, %r12d
	addl	%r8d, %r12d
	jmp	.L13
.L6:
	leal	1(%rsi), %eax
	movslq	%eax, %rdx
	subl	$1, %eax
	movl	$0, 16(%rsp,%rdx,4)
	jne	.L26
.L9:
	xorl	%r12d, %r12d
	movl	$1, %edi
	jmp	.L15
.L28:
	xorl	%r12d, %r12d
	jmp	.L8
.L42:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE24:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:

#include<stdio.h>

int cost(int x,int y){
	if(x>=y){
		return (x-y);
	}else{
		return (y-x);
	}
}

int main(void){
	int n,a[100001],i,sum=0,ans;
	scanf("%d",&n);
	a[0]=0;
	for(i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	a[n+1]=0;
	for(i=1;i<=n+1;i++){
		if(a[i]>=a[i-1]){
			sum=sum+(a[i]-a[i-1]);
		}else{
			sum=sum+(a[i-1]-a[i]);
		}
	}
	for(i=1;i<=n;i++){
		ans=sum+cost(a[i+1],a[i-1])-cost(a[i+1],a[i])-cost(a[i],a[i-1]);
		printf("%d\n",ans);
	}
	return 0;
}


6
-679 -3431 -3258 3095 -3291 -4462
 5
1 1 0 2 0
 3
2 5 -1
 6
-679 -3431 -3258 3095 -3291 -2101
 5
1 0 0 2 0
 3
2 5 -2
 6
-679 -3431 -3258 3095 -4122 -2101
 5
1 0 0 2 1
 3
3 5 -2
 6
-679 -52 -3258 3095 -4122 -2101

21976
21630
21976
9270
21976
19634
 6
6
4
2
6
 12
6
10
 19634
19288
19634
6928
17254
19634
 4
6
6
2
6
 14
8
10
 21296
20950
21296
8590
17254
21296
 4
6
6
4
6
 14
10
10
 20950
20950
15792
9498
18162
22204

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>

int cost(int x,int y){
	if(x>=y){
		return (x-y);
	}else{
		return (y-x);
	}
}

int main(void){
	int n,a[100001],i,sum=0,ans;
	scanf("%d",&n);
	a[0]=0;
	for(i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	a[n+1]=0;
	for(i=1;i<=n+1;i++){
		if(a[i]>=a[i-1]){
			sum=sum+(a[i]-a[i-1]);
		}else{
			sum=sum+(a[i-1]-a[i]);
		}
	}
	for(i=1;i<=n;i++){
		ans=sum+cost(a[i+1],a[i-1])-cost(a[i+1],a[i])-cost(a[i],a[i-1]);
		printf("%d\n",ans);
	}
	return 0;
}

```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	cost
	.type	cost, @function
cost:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -4(%rbp)
	movl	%esi, -8(%rbp)
	movl	-4(%rbp), %eax
	cmpl	-8(%rbp), %eax
	jl	.L2
	movl	-4(%rbp), %eax
	subl	-8(%rbp), %eax
	jmp	.L3
.L2:
	movl	-8(%rbp), %eax
	subl	-4(%rbp), %eax
.L3:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	cost, .-cost
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d\n"
	.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
	pushq	%rbx
	leaq	-397312(%rsp), %r11
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	subq	$2728, %rsp
	.cfi_offset 3, -24
	movq	%fs:40, %rax
	movq	%rax, -24(%rbp)
	xorl	%eax, %eax
	movl	$0, -400040(%rbp)
	leaq	-400048(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -400032(%rbp)
	movl	$1, -400044(%rbp)
	jmp	.L5
.L6:
	leaq	-400032(%rbp), %rdx
	movl	-400044(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -400044(%rbp)
.L5:
	movl	-400048(%rbp), %eax
	cmpl	%eax, -400044(%rbp)
	jle	.L6
	movl	-400048(%rbp), %eax
	addl	$1, %eax
	cltq
	movl	$0, -400032(%rbp,%rax,4)
	movl	$1, -400044(%rbp)
	jmp	.L7
.L10:
	movl	-400044(%rbp), %eax
	cltq
	movl	-400032(%rbp,%rax,4), %edx
	movl	-400044(%rbp), %eax
	subl	$1, %eax
	cltq
	movl	-400032(%rbp,%rax,4), %eax
	cmpl	%eax, %edx
	jl	.L8
	movl	-400044(%rbp), %eax
	cltq
	movl	-400032(%rbp,%rax,4), %edx
	movl	-400044(%rbp), %eax
	subl	$1, %eax
	cltq
	movl	-400032(%rbp,%rax,4), %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	addl	%eax, -400040(%rbp)
	jmp	.L9
.L8:
	movl	-400044(%rbp), %eax
	subl	$1, %eax
	cltq
	movl	-400032(%rbp,%rax,4), %edx
	movl	-400044(%rbp), %eax
	cltq
	movl	-400032(%rbp,%rax,4), %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	addl	%eax, -400040(%rbp)
.L9:
	addl	$1, -400044(%rbp)
.L7:
	movl	-400048(%rbp), %eax
	addl	$1, %eax
	cmpl	%eax, -400044(%rbp)
	jle	.L10
	movl	$1, -400044(%rbp)
	jmp	.L11
.L12:
	movl	-400044(%rbp), %eax
	subl	$1, %eax
	cltq
	movl	-400032(%rbp,%rax,4), %edx
	movl	-400044(%rbp), %eax
	addl	$1, %eax
	cltq
	movl	-400032(%rbp,%rax,4), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	cost
	movl	-400040(%rbp), %edx
	leal	(%rax,%rdx), %ebx
	movl	-400044(%rbp), %eax
	cltq
	movl	-400032(%rbp,%rax,4), %edx
	movl	-400044(%rbp), %eax
	addl	$1, %eax
	cltq
	movl	-400032(%rbp,%rax,4), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	cost
	subl	%eax, %ebx
	movl	-400044(%rbp), %eax
	subl	$1, %eax
	cltq
	movl	-400032(%rbp,%rax,4), %edx
	movl	-400044(%rbp), %eax
	cltq
	movl	-400032(%rbp,%rax,4), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	cost
	movl	%eax, %edx
	movl	%ebx, %eax
	subl	%edx, %eax
	movl	%eax, -400036(%rbp)
	movl	-400036(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	addl	$1, -400044(%rbp)
.L11:
	movl	-400048(%rbp), %eax
	cmpl	%eax, -400044(%rbp)
	jle	.L12
	movl	$0, %eax
	movq	-24(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L14
	call	__stack_chk_fail@PLT
.L14:
	movq	-8(%rbp), %rbx
	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	cost
	.type	cost, @function
cost:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -4(%rbp)
	movl	%esi, -8(%rbp)
	movl	-4(%rbp), %eax
	cmpl	-8(%rbp), %eax
	jl	.L2
	movl	-4(%rbp), %eax
	subl	-8(%rbp), %eax
	jmp	.L3
.L2:
	movl	-8(%rbp), %eax
	subl	-4(%rbp), %eax
.L3:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	cost, .-cost
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d\n"
	.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
	pushq	%rbx
	leaq	-397312(%rsp), %r11
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	subq	$2728, %rsp
	.cfi_offset 3, -24
	movq	%fs:40, %rax
	movq	%rax, -24(%rbp)
	xorl	%eax, %eax
	movl	$0, -400040(%rbp)
	leaq	-400048(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -400032(%rbp)
	movl	$1, -400044(%rbp)
	jmp	.L5
.L6:
	leaq	-400032(%rbp), %rdx
	movl	-400044(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -400044(%rbp)
.L5:
	movl	-400048(%rbp), %eax
	cmpl	%eax, -400044(%rbp)
	jle	.L6
	movl	-400048(%rbp), %eax
	addl	$1, %eax
	cltq
	movl	$0, -400032(%rbp,%rax,4)
	movl	$1, -400044(%rbp)
	jmp	.L7
.L10:
	movl	-400044(%rbp), %eax
	cltq
	movl	-400032(%rbp,%rax,4), %edx
	movl	-400044(%rbp), %eax
	subl	$1, %eax
	cltq
	movl	-400032(%rbp,%rax,4), %eax
	cmpl	%eax, %edx
	jl	.L8
	movl	-400044(%rbp), %eax
	cltq
	movl	-400032(%rbp,%rax,4), %edx
	movl	-400044(%rbp), %eax
	subl	$1, %eax
	cltq
	movl	-400032(%rbp,%rax,4), %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	addl	%eax, -400040(%rbp)
	jmp	.L9
.L8:
	movl	-400044(%rbp), %eax
	subl	$1, %eax
	cltq
	movl	-400032(%rbp,%rax,4), %edx
	movl	-400044(%rbp), %eax
	cltq
	movl	-400032(%rbp,%rax,4), %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	addl	%eax, -400040(%rbp)
.L9:
	addl	$1, -400044(%rbp)
.L7:
	movl	-400048(%rbp), %eax
	addl	$1, %eax
	cmpl	%eax, -400044(%rbp)
	jle	.L10
	movl	$1, -400044(%rbp)
	jmp	.L11
.L12:
	movl	-400044(%rbp), %eax
	subl	$1, %eax
	cltq
	movl	-400032(%rbp,%rax,4), %edx
	movl	-400044(%rbp), %eax
	addl	$1, %eax
	cltq
	movl	-400032(%rbp,%rax,4), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	cost
	movl	-400040(%rbp), %edx
	leal	(%rax,%rdx), %ebx
	movl	-400044(%rbp), %eax
	cltq
	movl	-400032(%rbp,%rax,4), %edx
	movl	-400044(%rbp), %eax
	addl	$1, %eax
	cltq
	movl	-400032(%rbp,%rax,4), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	cost
	subl	%eax, %ebx
	movl	-400044(%rbp), %eax
	subl	$1, %eax
	cltq
	movl	-400032(%rbp,%rax,4), %edx
	movl	-400044(%rbp), %eax
	cltq
	movl	-400032(%rbp,%rax,4), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	cost
	movl	%eax, %edx
	movl	%ebx, %eax
	subl	%edx, %eax
	movl	%eax, -400036(%rbp)
	movl	-400036(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	addl	$1, -400044(%rbp)
.L11:
	movl	-400048(%rbp), %eax
	cmpl	%eax, -400044(%rbp)
	jle	.L12
	movl	$0, %eax
	movq	-24(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L14
	call	__stack_chk_fail@PLT
.L14:
	movq	-8(%rbp), %rbx
	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:
