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 min(int a,int b){
  if(a<=b){
    return a;
  }
  else {
    return b;
  }
}


int main(){
  int N;
  scanf("%d",&N);
  int b[N-1];
  int a[N];
  
  for (int i=0;i<=N-1;i++){
    scanf("%d",&b[i]);
  }
  
  a[0]=b[0];
  
  for (int i=1;i<=N-2;i++){
    a[i]=min(b[i],b[i-1]);
  }
  
  a[N-1]=b[N-2];
  
  int ans=0;
  for (int i=0;i<N;i++){
    ans+=a[i];
  }
  
  printf("%d",ans);
  
  return 0;
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	min
	.type	min, @function
min:
.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
	jg	.L2
	movl	-4(%rbp), %eax
	jmp	.L3
.L2:
	movl	-8(%rbp), %eax
.L3:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	min, .-min
	.section	.rodata
.LC0:
	.string	"%d"
	.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	%r15
	pushq	%r14
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	subq	$104, %rsp
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	.cfi_offset 12, -48
	.cfi_offset 3, -56
	movq	%fs:40, %rax
	movq	%rax, -56(%rbp)
	xorl	%eax, %eax
	movq	%rsp, %rax
	movq	%rax, %rbx
	leaq	-108(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-108(%rbp), %eax
	subl	$1, %eax
	movslq	%eax, %rdx
	subq	$1, %rdx
	movq	%rdx, -88(%rbp)
	movslq	%eax, %rdx
	movq	%rdx, -128(%rbp)
	movq	$0, -120(%rbp)
	movslq	%eax, %rdx
	movq	%rdx, -144(%rbp)
	movq	$0, -136(%rbp)
	cltq
	leaq	0(,%rax,4), %rdx
	movl	$16, %eax
	subq	$1, %rax
	addq	%rdx, %rax
	movl	$16, %edi
	movl	$0, %edx
	divq	%rdi
	imulq	$16, %rax, %rax
	movq	%rax, %rcx
	andq	$-4096, %rcx
	movq	%rsp, %rdx
	subq	%rcx, %rdx
.L5:
	cmpq	%rdx, %rsp
	je	.L6
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L5
.L6:
	movq	%rax, %rdx
	andl	$4095, %edx
	subq	%rdx, %rsp
	movq	%rax, %rdx
	andl	$4095, %edx
	testq	%rdx, %rdx
	je	.L7
	andl	$4095, %eax
	subq	$8, %rax
	addq	%rsp, %rax
	orq	$0, (%rax)
.L7:
	movq	%rsp, %rax
	addq	$3, %rax
	shrq	$2, %rax
	salq	$2, %rax
	movq	%rax, -80(%rbp)
	movl	-108(%rbp), %eax
	movslq	%eax, %rdx
	subq	$1, %rdx
	movq	%rdx, -72(%rbp)
	movslq	%eax, %rdx
	movq	%rdx, %r14
	movl	$0, %r15d
	movslq	%eax, %rdx
	movq	%rdx, %r12
	movl	$0, %r13d
	cltq
	leaq	0(,%rax,4), %rdx
	movl	$16, %eax
	subq	$1, %rax
	addq	%rdx, %rax
	movl	$16, %esi
	movl	$0, %edx
	divq	%rsi
	imulq	$16, %rax, %rax
	movq	%rax, %rcx
	andq	$-4096, %rcx
	movq	%rsp, %rdx
	subq	%rcx, %rdx
.L8:
	cmpq	%rdx, %rsp
	je	.L9
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L8
.L9:
	movq	%rax, %rdx
	andl	$4095, %edx
	subq	%rdx, %rsp
	movq	%rax, %rdx
	andl	$4095, %edx
	testq	%rdx, %rdx
	je	.L10
	andl	$4095, %eax
	subq	$8, %rax
	addq	%rsp, %rax
	orq	$0, (%rax)
.L10:
	movq	%rsp, %rax
	addq	$3, %rax
	shrq	$2, %rax
	salq	$2, %rax
	movq	%rax, -64(%rbp)
	movl	$0, -104(%rbp)
	jmp	.L11
.L12:
	movl	-104(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-80(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -104(%rbp)
.L11:
	movl	-108(%rbp), %eax
	cmpl	%eax, -104(%rbp)
	jl	.L12
	movq	-80(%rbp), %rax
	movl	(%rax), %edx
	movq	-64(%rbp), %rax
	movl	%edx, (%rax)
	movl	$1, -100(%rbp)
	jmp	.L13
.L14:
	movl	-100(%rbp), %eax
	leal	-1(%rax), %edx
	movq	-80(%rbp), %rax
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %edx
	movq	-80(%rbp), %rax
	movl	-100(%rbp), %ecx
	movslq	%ecx, %rcx
	movl	(%rax,%rcx,4), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	min
	movq	-64(%rbp), %rdx
	movl	-100(%rbp), %ecx
	movslq	%ecx, %rcx
	movl	%eax, (%rdx,%rcx,4)
	addl	$1, -100(%rbp)
.L13:
	movl	-108(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -100(%rbp)
	jl	.L14
	movl	-108(%rbp), %eax
	leal	-2(%rax), %edx
	movl	-108(%rbp), %eax
	leal	-1(%rax), %esi
	movq	-80(%rbp), %rax
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %ecx
	movq	-64(%rbp), %rax
	movslq	%esi, %rdx
	movl	%ecx, (%rax,%rdx,4)
	movl	$0, -96(%rbp)
	movl	$0, -92(%rbp)
	jmp	.L15
.L16:
	movq	-64(%rbp), %rax
	movl	-92(%rbp), %edx
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %eax
	addl	%eax, -96(%rbp)
	addl	$1, -92(%rbp)
.L15:
	movl	-108(%rbp), %eax
	cmpl	%eax, -92(%rbp)
	jl	.L16
	movl	-96(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	%rbx, %rsp
	movq	-56(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L18
	call	__stack_chk_fail@PLT
.L18:
	leaq	-40(%rbp), %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.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	min
	.type	min, @function
min:
.LFB23:
	.cfi_startproc
	endbr64
	cmpl	%esi, %edi
	movl	%esi, %eax
	cmovle	%edi, %eax
	ret
	.cfi_endproc
.LFE23:
	.size	min, .-min
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB24:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%r15
	.cfi_offset 15, -24
	leaq	.LC0(%rip), %r15
	pushq	%r14
	leaq	-60(%rbp), %rsi
	movq	%r15, %rdi
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	subq	$40, %rsp
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	.cfi_offset 12, -48
	.cfi_offset 3, -56
	movq	%fs:40, %rax
	movq	%rax, -56(%rbp)
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	-60(%rbp), %esi
	movq	%rsp, %rdi
	leal	-1(%rsi), %eax
	cltq
	salq	$2, %rax
	leaq	15(%rax), %rdx
	movq	%rdx, %rcx
	andq	$-4096, %rdx
	subq	%rdx, %rdi
	andq	$-16, %rcx
	cmpq	%rdi, %rsp
	je	.L5
.L36:
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	cmpq	%rdi, %rsp
	jne	.L36
.L5:
	andl	$4095, %ecx
	subq	%rcx, %rsp
	testq	%rcx, %rcx
	jne	.L37
.L6:
	leaq	3(%rsp), %rcx
	addq	$19, %rax
	movq	%rsp, %rdi
	movq	%rcx, %rbx
	movq	%rax, %rdx
	andq	$-4, %rcx
	andq	$-4096, %rax
	shrq	$2, %rbx
	movq	%rcx, %r14
	andq	$-16, %rdx
	subq	%rax, %rdi
	movq	%rbx, -72(%rbp)
.L7:
	cmpq	%rdi, %rsp
	je	.L8
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L7
.L37:
	orq	$0, -8(%rsp,%rcx)
	jmp	.L6
.L8:
	andl	$4095, %edx
	subq	%rdx, %rsp
	testq	%rdx, %rdx
	jne	.L38
.L9:
	leaq	3(%rsp), %r13
	movq	%r13, %rax
	andq	$-4, %r13
	shrq	$2, %rax
	movq	%rax, -80(%rbp)
	testl	%esi, %esi
	jle	.L22
	movq	%r14, %r12
	xorl	%ebx, %ebx
	.p2align 4,,10
	.p2align 3
.L11:
	movq	%r12, %rsi
	movq	%r15, %rdi
	xorl	%eax, %eax
	addl	$1, %ebx
	call	__isoc99_scanf@PLT
	movl	-60(%rbp), %edx
	addq	$4, %r12
	cmpl	%ebx, %edx
	jg	.L11
	movq	-72(%rbp), %rax
	movq	-80(%rbp), %rbx
	leal	-1(%rdx), %r8d
	leal	-2(%rdx), %edi
	movl	0(,%rax,4), %eax
	movl	%eax, 0(,%rbx,4)
	cmpl	$1, %r8d
	jle	.L12
	leal	-3(%rdx), %eax
	cmpl	$2, %eax
	jbe	.L21
	movl	%edi, %eax
	shrl	$2, %eax
	leal	-1(%rax), %esi
	movl	$4, %eax
	salq	$4, %rsi
	addq	$20, %rsi
	.p2align 4,,10
	.p2align 3
.L14:
	movdqu	(%r14,%rax), %xmm2
	movdqu	-4(%r14,%rax), %xmm0
	movdqu	-4(%r14,%rax), %xmm3
	pcmpgtd	%xmm2, %xmm0
	movdqa	%xmm2, %xmm1
	pand	%xmm0, %xmm1
	pandn	%xmm3, %xmm0
	por	%xmm1, %xmm0
	movups	%xmm0, 0(%r13,%rax)
	addq	$16, %rax
	cmpq	%rax, %rsi
	jne	.L14
	movl	%edi, %eax
	andl	$-4, %eax
	leal	1(%rax), %r10d
	cmpl	%eax, %edi
	je	.L12
.L13:
	movslq	%r10d, %rsi
	salq	$2, %rsi
	leaq	(%r14,%rsi), %rbx
	leaq	0(%r13,%rsi), %r11
	movl	-4(%r14,%rsi), %esi
	movl	(%rbx), %eax
	cmpl	%eax, %esi
	cmovg	%eax, %esi
	movl	%esi, (%r11)
	leal	1(%r10), %esi
	cmpl	%esi, %r8d
	jle	.L12
	movl	4(%rbx), %esi
	cmpl	%esi, %eax
	cmovg	%esi, %eax
	addl	$2, %r10d
	movl	%eax, 4(%r11)
	cmpl	%r10d, %r8d
	jle	.L12
	movl	8(%rbx), %eax
	cmpl	%esi, %eax
	cmovg	%esi, %eax
	movl	%eax, 8(%r11)
.L12:
	movslq	%edi, %rdi
	movslq	%r8d, %rax
	movl	(%r14,%rdi,4), %ecx
	movl	%ecx, 0(%r13,%rax,4)
	testl	%edx, %edx
	jle	.L22
	cmpl	$2, %r8d
	jbe	.L23
	movl	%edx, %ecx
	movq	%r13, %rax
	pxor	%xmm0, %xmm0
	shrl	$2, %ecx
	subl	$1, %ecx
	salq	$4, %rcx
	leaq	16(%r13,%rcx), %rcx
	.p2align 4,,10
	.p2align 3
.L17:
	movdqu	(%rax), %xmm4
	addq	$16, %rax
	paddd	%xmm4, %xmm0
	cmpq	%rax, %rcx
	jne	.L17
	movdqa	%xmm0, %xmm1
	movl	%edx, %eax
	psrldq	$8, %xmm1
	andl	$-4, %eax
	paddd	%xmm1, %xmm0
	movdqa	%xmm0, %xmm1
	psrldq	$4, %xmm1
	paddd	%xmm1, %xmm0
	movd	%xmm0, %r8d
	testb	$3, %dl
	je	.L10
.L16:
	movslq	%eax, %rcx
	leal	1(%rax), %esi
	leaq	0(%r13,%rcx,4), %rcx
	addl	(%rcx), %r8d
	cmpl	%esi, %edx
	jle	.L10
	addl	$2, %eax
	addl	4(%rcx), %r8d
	cmpl	%eax, %edx
	jle	.L10
	addl	8(%rcx), %r8d
.L10:
	xorl	%eax, %eax
	movl	%r8d, %edx
	movq	%r15, %rsi
	movl	$1, %edi
	call	__printf_chk@PLT
	movq	-56(%rbp), %rax
	subq	%fs:40, %rax
	jne	.L39
	leaq	-40(%rbp), %rsp
	xorl	%eax, %eax
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_remember_state
	.cfi_def_cfa 7, 8
	ret
.L22:
	.cfi_restore_state
	xorl	%r8d, %r8d
	jmp	.L10
.L23:
	xorl	%eax, %eax
	xorl	%r8d, %r8d
	jmp	.L16
.L21:
	movl	$1, %r10d
	jmp	.L13
.L38:
	orq	$0, -8(%rsp,%rdx)
	jmp	.L9
.L39:
	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	min
	.type	min, @function
min:
.LFB23:
	.cfi_startproc
	endbr64
	cmpl	%esi, %edi
	movl	%esi, %eax
	cmovle	%edi, %eax
	ret
	.cfi_endproc
.LFE23:
	.size	min, .-min
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB24:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%r15
	.cfi_offset 15, -24
	leaq	.LC0(%rip), %r15
	pushq	%r14
	leaq	-60(%rbp), %rsi
	movq	%r15, %rdi
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	subq	$40, %rsp
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	.cfi_offset 12, -48
	.cfi_offset 3, -56
	movq	%fs:40, %rax
	movq	%rax, -56(%rbp)
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	-60(%rbp), %esi
	movq	%rsp, %rdi
	leal	-1(%rsi), %eax
	cltq
	salq	$2, %rax
	leaq	15(%rax), %rdx
	movq	%rdx, %rcx
	andq	$-4096, %rdx
	subq	%rdx, %rdi
	andq	$-16, %rcx
	cmpq	%rdi, %rsp
	je	.L5
.L36:
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	cmpq	%rdi, %rsp
	jne	.L36
.L5:
	andl	$4095, %ecx
	subq	%rcx, %rsp
	testq	%rcx, %rcx
	jne	.L37
.L6:
	leaq	3(%rsp), %rcx
	addq	$19, %rax
	movq	%rsp, %rdi
	movq	%rcx, %rbx
	movq	%rax, %rdx
	andq	$-4, %rcx
	andq	$-4096, %rax
	shrq	$2, %rbx
	movq	%rcx, %r14
	andq	$-16, %rdx
	subq	%rax, %rdi
	movq	%rbx, -72(%rbp)
.L7:
	cmpq	%rdi, %rsp
	je	.L8
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L7
.L37:
	orq	$0, -8(%rsp,%rcx)
	jmp	.L6
.L8:
	andl	$4095, %edx
	subq	%rdx, %rsp
	testq	%rdx, %rdx
	jne	.L38
.L9:
	leaq	3(%rsp), %r13
	movq	%r13, %rax
	andq	$-4, %r13
	shrq	$2, %rax
	movq	%rax, -80(%rbp)
	testl	%esi, %esi
	jle	.L22
	movq	%r14, %r12
	xorl	%ebx, %ebx
	.p2align 4,,10
	.p2align 3
.L11:
	movq	%r12, %rsi
	movq	%r15, %rdi
	xorl	%eax, %eax
	addl	$1, %ebx
	call	__isoc99_scanf@PLT
	movl	-60(%rbp), %edx
	addq	$4, %r12
	cmpl	%ebx, %edx
	jg	.L11
	movq	-72(%rbp), %rax
	movq	-80(%rbp), %rbx
	leal	-1(%rdx), %r8d
	leal	-2(%rdx), %edi
	movl	0(,%rax,4), %eax
	movl	%eax, 0(,%rbx,4)
	cmpl	$1, %r8d
	jle	.L12
	leal	-3(%rdx), %eax
	cmpl	$2, %eax
	jbe	.L21
	movl	%edi, %eax
	shrl	$2, %eax
	leal	-1(%rax), %esi
	movl	$4, %eax
	salq	$4, %rsi
	addq	$20, %rsi
	.p2align 4,,10
	.p2align 3
.L14:
	movdqu	(%r14,%rax), %xmm2
	movdqu	-4(%r14,%rax), %xmm0
	movdqu	-4(%r14,%rax), %xmm3
	pcmpgtd	%xmm2, %xmm0
	movdqa	%xmm2, %xmm1
	pand	%xmm0, %xmm1
	pandn	%xmm3, %xmm0
	por	%xmm1, %xmm0
	movups	%xmm0, 0(%r13,%rax)
	addq	$16, %rax
	cmpq	%rax, %rsi
	jne	.L14
	movl	%edi, %eax
	andl	$-4, %eax
	leal	1(%rax), %r10d
	cmpl	%eax, %edi
	je	.L12
.L13:
	movslq	%r10d, %rsi
	salq	$2, %rsi
	leaq	(%r14,%rsi), %rbx
	leaq	0(%r13,%rsi), %r11
	movl	-4(%r14,%rsi), %esi
	movl	(%rbx), %eax
	cmpl	%eax, %esi
	cmovg	%eax, %esi
	movl	%esi, (%r11)
	leal	1(%r10), %esi
	cmpl	%esi, %r8d
	jle	.L12
	movl	4(%rbx), %esi
	cmpl	%esi, %eax
	cmovg	%esi, %eax
	addl	$2, %r10d
	movl	%eax, 4(%r11)
	cmpl	%r10d, %r8d
	jle	.L12
	movl	8(%rbx), %eax
	cmpl	%esi, %eax
	cmovg	%esi, %eax
	movl	%eax, 8(%r11)
.L12:
	movslq	%edi, %rdi
	movslq	%r8d, %rax
	movl	(%r14,%rdi,4), %ecx
	movl	%ecx, 0(%r13,%rax,4)
	testl	%edx, %edx
	jle	.L22
	cmpl	$2, %r8d
	jbe	.L23
	movl	%edx, %ecx
	movq	%r13, %rax
	pxor	%xmm0, %xmm0
	shrl	$2, %ecx
	subl	$1, %ecx
	salq	$4, %rcx
	leaq	16(%r13,%rcx), %rcx
	.p2align 4,,10
	.p2align 3
.L17:
	movdqu	(%rax), %xmm4
	addq	$16, %rax
	paddd	%xmm4, %xmm0
	cmpq	%rax, %rcx
	jne	.L17
	movdqa	%xmm0, %xmm1
	movl	%edx, %eax
	psrldq	$8, %xmm1
	andl	$-4, %eax
	paddd	%xmm1, %xmm0
	movdqa	%xmm0, %xmm1
	psrldq	$4, %xmm1
	paddd	%xmm1, %xmm0
	movd	%xmm0, %r8d
	testb	$3, %dl
	je	.L10
.L16:
	movslq	%eax, %rcx
	leal	1(%rax), %esi
	leaq	0(%r13,%rcx,4), %rcx
	addl	(%rcx), %r8d
	cmpl	%esi, %edx
	jle	.L10
	addl	$2, %eax
	addl	4(%rcx), %r8d
	cmpl	%eax, %edx
	jle	.L10
	addl	8(%rcx), %r8d
.L10:
	xorl	%eax, %eax
	movl	%r8d, %edx
	movq	%r15, %rsi
	movl	$1, %edi
	call	__printf_chk@PLT
	movq	-56(%rbp), %rax
	subq	%fs:40, %rax
	jne	.L39
	leaq	-40(%rbp), %rsp
	xorl	%eax, %eax
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_remember_state
	.cfi_def_cfa 7, 8
	ret
.L22:
	.cfi_restore_state
	xorl	%r8d, %r8d
	jmp	.L10
.L23:
	xorl	%eax, %eax
	xorl	%r8d, %r8d
	jmp	.L16
.L21:
	movl	$1, %r10d
	jmp	.L13
.L38:
	orq	$0, -8(%rsp,%rdx)
	jmp	.L9
.L39:
	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 min(int a,int b){
  if(a<=b){
    return a;
  }
  else {
    return b;
  }
}


int main(){
  int N;
  scanf("%d",&N);
  int b[N-1];
  int a[N];
  
  for (int i=0;i<=N-1;i++){
    scanf("%d",&b[i]);
  }
  
  a[0]=b[0];
  
  for (int i=1;i<=N-2;i++){
    a[i]=min(b[i],b[i-1]);
  }
  
  a[N-1]=b[N-2];
  
  int ans=0;
  for (int i=0;i<N;i++){
    ans+=a[i];
  }
  
  printf("%d",ans);
  
  return 0;
}

2
5
 6
0 153 10 14 23
 3
2 9
 2
4
 6
0 153 10 14 17
 3
2 12
 2
1
 6
0 153 10 14 26
 3
1 12
 2
0

10 57 13 8 51 16 2 60 14 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>
int min(int a,int b){
  if(a<=b){
    return a;
  }
  else {
    return b;
  }
}


int main(){
  int N;
  scanf("%d",&N);
  int b[N-1];
  int a[N];
  
  for (int i=0;i<=N-1;i++){
    scanf("%d",&b[i]);
  }
  
  a[0]=b[0];
  
  for (int i=1;i<=N-2;i++){
    a[i]=min(b[i],b[i-1]);
  }
  
  a[N-1]=b[N-2];
  
  int ans=0;
  for (int i=0;i<N;i++){
    ans+=a[i];
  }
  
  printf("%d",ans);
  
  return 0;
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	min
	.type	min, @function
min:
.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
	jg	.L2
	movl	-4(%rbp), %eax
	jmp	.L3
.L2:
	movl	-8(%rbp), %eax
.L3:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	min, .-min
	.section	.rodata
.LC0:
	.string	"%d"
	.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	%r15
	pushq	%r14
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	subq	$104, %rsp
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	.cfi_offset 12, -48
	.cfi_offset 3, -56
	movq	%fs:40, %rax
	movq	%rax, -56(%rbp)
	xorl	%eax, %eax
	movq	%rsp, %rax
	movq	%rax, %rbx
	leaq	-108(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-108(%rbp), %eax
	subl	$1, %eax
	movslq	%eax, %rdx
	subq	$1, %rdx
	movq	%rdx, -88(%rbp)
	movslq	%eax, %rdx
	movq	%rdx, -128(%rbp)
	movq	$0, -120(%rbp)
	movslq	%eax, %rdx
	movq	%rdx, -144(%rbp)
	movq	$0, -136(%rbp)
	cltq
	leaq	0(,%rax,4), %rdx
	movl	$16, %eax
	subq	$1, %rax
	addq	%rdx, %rax
	movl	$16, %edi
	movl	$0, %edx
	divq	%rdi
	imulq	$16, %rax, %rax
	movq	%rax, %rcx
	andq	$-4096, %rcx
	movq	%rsp, %rdx
	subq	%rcx, %rdx
.L5:
	cmpq	%rdx, %rsp
	je	.L6
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L5
.L6:
	movq	%rax, %rdx
	andl	$4095, %edx
	subq	%rdx, %rsp
	movq	%rax, %rdx
	andl	$4095, %edx
	testq	%rdx, %rdx
	je	.L7
	andl	$4095, %eax
	subq	$8, %rax
	addq	%rsp, %rax
	orq	$0, (%rax)
.L7:
	movq	%rsp, %rax
	addq	$3, %rax
	shrq	$2, %rax
	salq	$2, %rax
	movq	%rax, -80(%rbp)
	movl	-108(%rbp), %eax
	movslq	%eax, %rdx
	subq	$1, %rdx
	movq	%rdx, -72(%rbp)
	movslq	%eax, %rdx
	movq	%rdx, %r14
	movl	$0, %r15d
	movslq	%eax, %rdx
	movq	%rdx, %r12
	movl	$0, %r13d
	cltq
	leaq	0(,%rax,4), %rdx
	movl	$16, %eax
	subq	$1, %rax
	addq	%rdx, %rax
	movl	$16, %esi
	movl	$0, %edx
	divq	%rsi
	imulq	$16, %rax, %rax
	movq	%rax, %rcx
	andq	$-4096, %rcx
	movq	%rsp, %rdx
	subq	%rcx, %rdx
.L8:
	cmpq	%rdx, %rsp
	je	.L9
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L8
.L9:
	movq	%rax, %rdx
	andl	$4095, %edx
	subq	%rdx, %rsp
	movq	%rax, %rdx
	andl	$4095, %edx
	testq	%rdx, %rdx
	je	.L10
	andl	$4095, %eax
	subq	$8, %rax
	addq	%rsp, %rax
	orq	$0, (%rax)
.L10:
	movq	%rsp, %rax
	addq	$3, %rax
	shrq	$2, %rax
	salq	$2, %rax
	movq	%rax, -64(%rbp)
	movl	$0, -104(%rbp)
	jmp	.L11
.L12:
	movl	-104(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-80(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -104(%rbp)
.L11:
	movl	-108(%rbp), %eax
	cmpl	%eax, -104(%rbp)
	jl	.L12
	movq	-80(%rbp), %rax
	movl	(%rax), %edx
	movq	-64(%rbp), %rax
	movl	%edx, (%rax)
	movl	$1, -100(%rbp)
	jmp	.L13
.L14:
	movl	-100(%rbp), %eax
	leal	-1(%rax), %edx
	movq	-80(%rbp), %rax
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %edx
	movq	-80(%rbp), %rax
	movl	-100(%rbp), %ecx
	movslq	%ecx, %rcx
	movl	(%rax,%rcx,4), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	min
	movq	-64(%rbp), %rdx
	movl	-100(%rbp), %ecx
	movslq	%ecx, %rcx
	movl	%eax, (%rdx,%rcx,4)
	addl	$1, -100(%rbp)
.L13:
	movl	-108(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -100(%rbp)
	jl	.L14
	movl	-108(%rbp), %eax
	leal	-2(%rax), %edx
	movl	-108(%rbp), %eax
	leal	-1(%rax), %esi
	movq	-80(%rbp), %rax
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %ecx
	movq	-64(%rbp), %rax
	movslq	%esi, %rdx
	movl	%ecx, (%rax,%rdx,4)
	movl	$0, -96(%rbp)
	movl	$0, -92(%rbp)
	jmp	.L15
.L16:
	movq	-64(%rbp), %rax
	movl	-92(%rbp), %edx
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %eax
	addl	%eax, -96(%rbp)
	addl	$1, -92(%rbp)
.L15:
	movl	-108(%rbp), %eax
	cmpl	%eax, -92(%rbp)
	jl	.L16
	movl	-96(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	%rbx, %rsp
	movq	-56(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L18
	call	__stack_chk_fail@PLT
.L18:
	leaq	-40(%rbp), %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.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	min
	.type	min, @function
min:
.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
	jg	.L2
	movl	-4(%rbp), %eax
	jmp	.L3
.L2:
	movl	-8(%rbp), %eax
.L3:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	min, .-min
	.section	.rodata
.LC0:
	.string	"%d"
	.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	%r15
	pushq	%r14
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	subq	$104, %rsp
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	.cfi_offset 12, -48
	.cfi_offset 3, -56
	movq	%fs:40, %rax
	movq	%rax, -56(%rbp)
	xorl	%eax, %eax
	movq	%rsp, %rax
	movq	%rax, %rbx
	leaq	-108(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-108(%rbp), %eax
	subl	$1, %eax
	movslq	%eax, %rdx
	subq	$1, %rdx
	movq	%rdx, -88(%rbp)
	movslq	%eax, %rdx
	movq	%rdx, -128(%rbp)
	movq	$0, -120(%rbp)
	movslq	%eax, %rdx
	movq	%rdx, -144(%rbp)
	movq	$0, -136(%rbp)
	cltq
	leaq	0(,%rax,4), %rdx
	movl	$16, %eax
	subq	$1, %rax
	addq	%rdx, %rax
	movl	$16, %edi
	movl	$0, %edx
	divq	%rdi
	imulq	$16, %rax, %rax
	movq	%rax, %rcx
	andq	$-4096, %rcx
	movq	%rsp, %rdx
	subq	%rcx, %rdx
.L5:
	cmpq	%rdx, %rsp
	je	.L6
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L5
.L6:
	movq	%rax, %rdx
	andl	$4095, %edx
	subq	%rdx, %rsp
	movq	%rax, %rdx
	andl	$4095, %edx
	testq	%rdx, %rdx
	je	.L7
	andl	$4095, %eax
	subq	$8, %rax
	addq	%rsp, %rax
	orq	$0, (%rax)
.L7:
	movq	%rsp, %rax
	addq	$3, %rax
	shrq	$2, %rax
	salq	$2, %rax
	movq	%rax, -80(%rbp)
	movl	-108(%rbp), %eax
	movslq	%eax, %rdx
	subq	$1, %rdx
	movq	%rdx, -72(%rbp)
	movslq	%eax, %rdx
	movq	%rdx, %r14
	movl	$0, %r15d
	movslq	%eax, %rdx
	movq	%rdx, %r12
	movl	$0, %r13d
	cltq
	leaq	0(,%rax,4), %rdx
	movl	$16, %eax
	subq	$1, %rax
	addq	%rdx, %rax
	movl	$16, %esi
	movl	$0, %edx
	divq	%rsi
	imulq	$16, %rax, %rax
	movq	%rax, %rcx
	andq	$-4096, %rcx
	movq	%rsp, %rdx
	subq	%rcx, %rdx
.L8:
	cmpq	%rdx, %rsp
	je	.L9
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L8
.L9:
	movq	%rax, %rdx
	andl	$4095, %edx
	subq	%rdx, %rsp
	movq	%rax, %rdx
	andl	$4095, %edx
	testq	%rdx, %rdx
	je	.L10
	andl	$4095, %eax
	subq	$8, %rax
	addq	%rsp, %rax
	orq	$0, (%rax)
.L10:
	movq	%rsp, %rax
	addq	$3, %rax
	shrq	$2, %rax
	salq	$2, %rax
	movq	%rax, -64(%rbp)
	movl	$0, -104(%rbp)
	jmp	.L11
.L12:
	movl	-104(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-80(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -104(%rbp)
.L11:
	movl	-108(%rbp), %eax
	cmpl	%eax, -104(%rbp)
	jl	.L12
	movq	-80(%rbp), %rax
	movl	(%rax), %edx
	movq	-64(%rbp), %rax
	movl	%edx, (%rax)
	movl	$1, -100(%rbp)
	jmp	.L13
.L14:
	movl	-100(%rbp), %eax
	leal	-1(%rax), %edx
	movq	-80(%rbp), %rax
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %edx
	movq	-80(%rbp), %rax
	movl	-100(%rbp), %ecx
	movslq	%ecx, %rcx
	movl	(%rax,%rcx,4), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	min
	movq	-64(%rbp), %rdx
	movl	-100(%rbp), %ecx
	movslq	%ecx, %rcx
	movl	%eax, (%rdx,%rcx,4)
	addl	$1, -100(%rbp)
.L13:
	movl	-108(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -100(%rbp)
	jl	.L14
	movl	-108(%rbp), %eax
	leal	-2(%rax), %edx
	movl	-108(%rbp), %eax
	leal	-1(%rax), %esi
	movq	-80(%rbp), %rax
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %ecx
	movq	-64(%rbp), %rax
	movslq	%esi, %rdx
	movl	%ecx, (%rax,%rdx,4)
	movl	$0, -96(%rbp)
	movl	$0, -92(%rbp)
	jmp	.L15
.L16:
	movq	-64(%rbp), %rax
	movl	-92(%rbp), %edx
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %eax
	addl	%eax, -96(%rbp)
	addl	$1, -92(%rbp)
.L15:
	movl	-108(%rbp), %eax
	cmpl	%eax, -92(%rbp)
	jl	.L16
	movl	-96(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	%rbx, %rsp
	movq	-56(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L18
	call	__stack_chk_fail@PLT
.L18:
	leaq	-40(%rbp), %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.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:
