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>
#define min(x,y) (((x)<(y))?(x):(y))

int main(){
    int N;
    scanf("%d",&N);
    int *B = malloc(sizeof(int)*(N-1));
    int *A = malloc(sizeof(int)*N);
    int i;
    for(i=0;i<N-1;i++) scanf("%d",&B[i]);
    A[0]=B[0];
    A[N-1]=B[N-2];
    for(i=1; i<N-1; i++) A[i] = min(B[i-1],B[i]);
    int sum=0;
    for(i=0; i<N; i++) sum+=A[i];
    printf("%d\n",sum);
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$48, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-36(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-36(%rbp), %eax
	subl	$1, %eax
	cltq
	salq	$2, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, -24(%rbp)
	movl	-36(%rbp), %eax
	cltq
	salq	$2, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, -16(%rbp)
	movl	$0, -32(%rbp)
	jmp	.L2
.L3:
	movl	-32(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -32(%rbp)
.L2:
	movl	-36(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -32(%rbp)
	jl	.L3
	movq	-24(%rbp), %rax
	movl	(%rax), %edx
	movq	-16(%rbp), %rax
	movl	%edx, (%rax)
	movl	-36(%rbp), %eax
	cltq
	salq	$2, %rax
	leaq	-8(%rax), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	-36(%rbp), %edx
	movslq	%edx, %rdx
	salq	$2, %rdx
	leaq	-4(%rdx), %rcx
	movq	-16(%rbp), %rdx
	addq	%rcx, %rdx
	movl	(%rax), %eax
	movl	%eax, (%rdx)
	movl	$1, -32(%rbp)
	jmp	.L4
.L5:
	movl	-32(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movl	-32(%rbp), %eax
	cltq
	salq	$2, %rax
	leaq	-4(%rax), %rcx
	movq	-24(%rbp), %rax
	addq	%rcx, %rax
	movl	(%rax), %eax
	movl	-32(%rbp), %ecx
	movslq	%ecx, %rcx
	leaq	0(,%rcx,4), %rsi
	movq	-16(%rbp), %rcx
	addq	%rsi, %rcx
	cmpl	%eax, %edx
	cmovle	%edx, %eax
	movl	%eax, (%rcx)
	addl	$1, -32(%rbp)
.L4:
	movl	-36(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -32(%rbp)
	jl	.L5
	movl	$0, -28(%rbp)
	movl	$0, -32(%rbp)
	jmp	.L6
.L7:
	movl	-32(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	addl	%eax, -28(%rbp)
	addl	$1, -32(%rbp)
.L6:
	movl	-36(%rbp), %eax
	cmpl	%eax, -32(%rbp)
	jl	.L7
	movl	-28(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L9
	call	__stack_chk_fail@PLT
.L9:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.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
	.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:
.LFB39:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	.LC0(%rip), %r15
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movq	%r15, %rdi
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$40, %rsp
	.cfi_def_cfa_offset 96
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	leaq	20(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movl	20(%rsp), %ebx
	leal	-1(%rbx), %r13d
	movslq	%r13d, %rbp
	salq	$2, %rbp
	movq	%rbp, %rdi
	call	malloc@PLT
	leaq	4(%rbp), %rdi
	movq	%rax, %r14
	call	malloc@PLT
	movq	%rax, 8(%rsp)
	testl	%r13d, %r13d
	jle	.L2
	movq	%r14, %r12
	xorl	%ebp, %ebp
	.p2align 4,,10
	.p2align 3
.L3:
	movq	%r12, %rsi
	movq	%r15, %rdi
	xorl	%eax, %eax
	addl	$1, %ebp
	call	__isoc99_scanf@PLT
	movl	20(%rsp), %ebx
	addq	$4, %r12
	leal	-1(%rbx), %r13d
	cmpl	%ebp, %r13d
	jg	.L3
	movl	(%r14), %eax
	movq	8(%rsp), %rdi
	movl	%eax, (%rdi)
	movslq	%ebx, %rax
	salq	$2, %rax
	movl	-8(%r14,%rax), %ecx
	movl	%ecx, -4(%rdi,%rax)
	cmpl	$1, %r13d
	jle	.L4
	leal	-3(%rbx), %eax
	leal	-2(%rbx), %esi
	cmpl	$2, %eax
	jbe	.L15
	movl	%esi, %eax
	shrl	$2, %eax
	leal	-1(%rax), %ecx
	movl	$4, %eax
	salq	$4, %rcx
	addq	$20, %rcx
	.p2align 4,,10
	.p2align 3
.L6:
	movdqu	-4(%r14,%rax), %xmm2
	movdqu	(%r14,%rax), %xmm0
	movdqu	(%r14,%rax), %xmm3
	movq	8(%rsp), %rdx
	pcmpgtd	%xmm2, %xmm0
	movdqa	%xmm2, %xmm1
	pand	%xmm0, %xmm1
	pandn	%xmm3, %xmm0
	por	%xmm1, %xmm0
	movups	%xmm0, (%rdx,%rax)
	addq	$16, %rax
	cmpq	%rax, %rcx
	jne	.L6
	movl	%esi, %eax
	andl	$-4, %eax
	leal	1(%rax), %ecx
	cmpl	%eax, %esi
	je	.L4
.L5:
	movslq	%ecx, %rax
	leal	1(%rcx), %r8d
	movq	%rax, %rdi
	leaq	(%r14,%rax,4), %r9
	cmpl	%esi, %r8d
	jge	.L8
	cmpl	%ecx, %r13d
	jle	.L8
	movl	-4(%r9), %edi
.L9:
	movl	(%r14,%rax,4), %ecx
	cmpl	%ecx, %edi
	cmovg	%ecx, %edi
	movd	%edi, %xmm0
	movl	4(%r14,%rax,4), %edi
	cmpl	%edi, %ecx
	cmovg	%edi, %ecx
	movd	%ecx, %xmm5
	movq	8(%rsp), %rcx
	punpckldq	%xmm5, %xmm0
	movq	%xmm0, (%rcx,%rax,4)
	leal	2(%rax), %ecx
	addq	$2, %rax
	leal	1(%rax), %r8d
	cmpl	%r8d, %esi
	jg	.L9
	movslq	%ecx, %rdi
	leal	1(%rcx), %r8d
.L8:
	leaq	0(,%rdi,4), %r9
	movl	(%r14,%rdi,4), %eax
	movq	8(%rsp), %rdx
	movl	-4(%r14,%r9), %esi
	cmpl	%eax, %esi
	cmovg	%eax, %esi
	movl	%esi, (%rdx,%rdi,4)
	cmpl	%r8d, %r13d
	jle	.L4
	movl	4(%r14,%r9), %esi
	cmpl	%eax, %esi
	cmovle	%esi, %eax
	addl	$2, %ecx
	movl	%eax, 4(%rdx,%r9)
	cmpl	%ecx, %r13d
	jle	.L4
	movl	8(%r14,%r9), %eax
	cmpl	%eax, %esi
	cmovg	%eax, %esi
	movl	%esi, 8(%rdx,%r9)
.L4:
	testl	%ebx, %ebx
	jle	.L16
	cmpl	$2, %r13d
	jbe	.L17
	movl	%ebx, %edx
	movq	8(%rsp), %rsi
	pxor	%xmm0, %xmm0
	shrl	$2, %edx
	subl	$1, %edx
	movq	%rsi, %rax
	salq	$4, %rdx
	leaq	16(%rsi,%rdx), %rdx
	.p2align 4,,10
	.p2align 3
.L12:
	movdqu	(%rax), %xmm4
	addq	$16, %rax
	paddd	%xmm4, %xmm0
	cmpq	%rax, %rdx
	jne	.L12
	movdqa	%xmm0, %xmm1
	movl	%ebx, %eax
	psrldq	$8, %xmm1
	andl	$-4, %eax
	paddd	%xmm1, %xmm0
	movdqa	%xmm0, %xmm1
	psrldq	$4, %xmm1
	paddd	%xmm1, %xmm0
	movd	%xmm0, %edx
	testb	$3, %bl
	je	.L10
.L11:
	movq	8(%rsp), %rdi
	movslq	%eax, %rcx
	leaq	0(,%rcx,4), %rsi
	addl	(%rdi,%rcx,4), %edx
	leal	1(%rax), %ecx
	cmpl	%ecx, %ebx
	jle	.L10
	addl	$2, %eax
	addl	4(%rdi,%rsi), %edx
	cmpl	%eax, %ebx
	jle	.L10
	addl	8(%rdi,%rsi), %edx
.L10:
	xorl	%eax, %eax
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	call	__printf_chk@PLT
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L31
	addq	$40, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
.L2:
	.cfi_restore_state
	movl	(%r14), %eax
	movq	8(%rsp), %rsi
	movl	%eax, (%rsi)
	movslq	%ebx, %rax
	salq	$2, %rax
	movl	-8(%r14,%rax), %edx
	movl	%edx, -4(%rsi,%rax)
	jmp	.L4
.L16:
	xorl	%edx, %edx
	jmp	.L10
.L17:
	xorl	%edx, %edx
	xorl	%eax, %eax
	jmp	.L11
.L15:
	movl	$1, %ecx
	jmp	.L5
.L31:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE39:
	.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
	.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:
.LFB39:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	.LC0(%rip), %r15
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movq	%r15, %rdi
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$40, %rsp
	.cfi_def_cfa_offset 96
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	leaq	20(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movl	20(%rsp), %ebx
	leal	-1(%rbx), %r13d
	movslq	%r13d, %rbp
	salq	$2, %rbp
	movq	%rbp, %rdi
	call	malloc@PLT
	leaq	4(%rbp), %rdi
	movq	%rax, %r14
	call	malloc@PLT
	movq	%rax, 8(%rsp)
	testl	%r13d, %r13d
	jle	.L2
	movq	%r14, %r12
	xorl	%ebp, %ebp
	.p2align 4,,10
	.p2align 3
.L3:
	movq	%r12, %rsi
	movq	%r15, %rdi
	xorl	%eax, %eax
	addl	$1, %ebp
	call	__isoc99_scanf@PLT
	movl	20(%rsp), %ebx
	addq	$4, %r12
	leal	-1(%rbx), %r13d
	cmpl	%ebp, %r13d
	jg	.L3
	movl	(%r14), %eax
	movq	8(%rsp), %rdi
	movl	%eax, (%rdi)
	movslq	%ebx, %rax
	salq	$2, %rax
	movl	-8(%r14,%rax), %ecx
	movl	%ecx, -4(%rdi,%rax)
	cmpl	$1, %r13d
	jle	.L4
	leal	-3(%rbx), %eax
	leal	-2(%rbx), %esi
	cmpl	$2, %eax
	jbe	.L15
	movl	%esi, %eax
	shrl	$2, %eax
	leal	-1(%rax), %ecx
	movl	$4, %eax
	salq	$4, %rcx
	addq	$20, %rcx
	.p2align 4,,10
	.p2align 3
.L6:
	movdqu	-4(%r14,%rax), %xmm2
	movdqu	(%r14,%rax), %xmm0
	movdqu	(%r14,%rax), %xmm3
	movq	8(%rsp), %rdx
	pcmpgtd	%xmm2, %xmm0
	movdqa	%xmm2, %xmm1
	pand	%xmm0, %xmm1
	pandn	%xmm3, %xmm0
	por	%xmm1, %xmm0
	movups	%xmm0, (%rdx,%rax)
	addq	$16, %rax
	cmpq	%rax, %rcx
	jne	.L6
	movl	%esi, %eax
	andl	$-4, %eax
	leal	1(%rax), %ecx
	cmpl	%eax, %esi
	je	.L4
.L5:
	movslq	%ecx, %rax
	leal	1(%rcx), %r8d
	movq	%rax, %rdi
	leaq	(%r14,%rax,4), %r9
	cmpl	%esi, %r8d
	jge	.L8
	cmpl	%ecx, %r13d
	jle	.L8
	movl	-4(%r9), %edi
.L9:
	movl	(%r14,%rax,4), %ecx
	cmpl	%ecx, %edi
	cmovg	%ecx, %edi
	movd	%edi, %xmm0
	movl	4(%r14,%rax,4), %edi
	cmpl	%edi, %ecx
	cmovg	%edi, %ecx
	movd	%ecx, %xmm5
	movq	8(%rsp), %rcx
	punpckldq	%xmm5, %xmm0
	movq	%xmm0, (%rcx,%rax,4)
	leal	2(%rax), %ecx
	addq	$2, %rax
	leal	1(%rax), %r8d
	cmpl	%r8d, %esi
	jg	.L9
	movslq	%ecx, %rdi
	leal	1(%rcx), %r8d
.L8:
	leaq	0(,%rdi,4), %r9
	movl	(%r14,%rdi,4), %eax
	movq	8(%rsp), %rdx
	movl	-4(%r14,%r9), %esi
	cmpl	%eax, %esi
	cmovg	%eax, %esi
	movl	%esi, (%rdx,%rdi,4)
	cmpl	%r8d, %r13d
	jle	.L4
	movl	4(%r14,%r9), %esi
	cmpl	%eax, %esi
	cmovle	%esi, %eax
	addl	$2, %ecx
	movl	%eax, 4(%rdx,%r9)
	cmpl	%ecx, %r13d
	jle	.L4
	movl	8(%r14,%r9), %eax
	cmpl	%eax, %esi
	cmovg	%eax, %esi
	movl	%esi, 8(%rdx,%r9)
.L4:
	testl	%ebx, %ebx
	jle	.L16
	cmpl	$2, %r13d
	jbe	.L17
	movl	%ebx, %edx
	movq	8(%rsp), %rsi
	pxor	%xmm0, %xmm0
	shrl	$2, %edx
	subl	$1, %edx
	movq	%rsi, %rax
	salq	$4, %rdx
	leaq	16(%rsi,%rdx), %rdx
	.p2align 4,,10
	.p2align 3
.L12:
	movdqu	(%rax), %xmm4
	addq	$16, %rax
	paddd	%xmm4, %xmm0
	cmpq	%rax, %rdx
	jne	.L12
	movdqa	%xmm0, %xmm1
	movl	%ebx, %eax
	psrldq	$8, %xmm1
	andl	$-4, %eax
	paddd	%xmm1, %xmm0
	movdqa	%xmm0, %xmm1
	psrldq	$4, %xmm1
	paddd	%xmm1, %xmm0
	movd	%xmm0, %edx
	testb	$3, %bl
	je	.L10
.L11:
	movq	8(%rsp), %rdi
	movslq	%eax, %rcx
	leaq	0(,%rcx,4), %rsi
	addl	(%rdi,%rcx,4), %edx
	leal	1(%rax), %ecx
	cmpl	%ecx, %ebx
	jle	.L10
	addl	$2, %eax
	addl	4(%rdi,%rsi), %edx
	cmpl	%eax, %ebx
	jle	.L10
	addl	8(%rdi,%rsi), %edx
.L10:
	xorl	%eax, %eax
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	call	__printf_chk@PLT
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L31
	addq	$40, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
.L2:
	.cfi_restore_state
	movl	(%r14), %eax
	movq	8(%rsp), %rsi
	movl	%eax, (%rsi)
	movslq	%ebx, %rax
	salq	$2, %rax
	movl	-8(%r14,%rax), %edx
	movl	%edx, -4(%rsi,%rax)
	jmp	.L4
.L16:
	xorl	%edx, %edx
	jmp	.L10
.L17:
	xorl	%edx, %edx
	xorl	%eax, %eax
	jmp	.L11
.L15:
	movl	$1, %ecx
	jmp	.L5
.L31:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE39:
	.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>
#include <stdlib.h>
#define min(x,y) (((x)<(y))?(x):(y))

int main(){
    int N;
    scanf("%d",&N);
    int *B = malloc(sizeof(int)*(N-1));
    int *A = malloc(sizeof(int)*N);
    int i;
    for(i=0;i<N-1;i++) scanf("%d",&B[i]);
    A[0]=B[0];
    A[N-1]=B[N-2];
    for(i=1; i<N-1; i++) A[i] = min(B[i-1],B[i]);
    int sum=0;
    for(i=0; i<N; i++) sum+=A[i];
    printf("%d\n",sum);
}
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>
#include <stdlib.h>
#define min(x,y) (((x)<(y))?(x):(y))

int main(){
    int N;
    scanf("%d",&N);
    int *B = malloc(sizeof(int)*(N-1));
    int *A = malloc(sizeof(int)*N);
    int i;
    for(i=0;i<N-1;i++) scanf("%d",&B[i]);
    A[0]=B[0];
    A[N-1]=B[N-2];
    for(i=1; i<N-1; i++) A[i] = min(B[i-1],B[i]);
    int sum=0;
    for(i=0; i<N; i++) sum+=A[i];
    printf("%d\n",sum);
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$48, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-36(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-36(%rbp), %eax
	subl	$1, %eax
	cltq
	salq	$2, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, -24(%rbp)
	movl	-36(%rbp), %eax
	cltq
	salq	$2, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, -16(%rbp)
	movl	$0, -32(%rbp)
	jmp	.L2
.L3:
	movl	-32(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -32(%rbp)
.L2:
	movl	-36(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -32(%rbp)
	jl	.L3
	movq	-24(%rbp), %rax
	movl	(%rax), %edx
	movq	-16(%rbp), %rax
	movl	%edx, (%rax)
	movl	-36(%rbp), %eax
	cltq
	salq	$2, %rax
	leaq	-8(%rax), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	-36(%rbp), %edx
	movslq	%edx, %rdx
	salq	$2, %rdx
	leaq	-4(%rdx), %rcx
	movq	-16(%rbp), %rdx
	addq	%rcx, %rdx
	movl	(%rax), %eax
	movl	%eax, (%rdx)
	movl	$1, -32(%rbp)
	jmp	.L4
.L5:
	movl	-32(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movl	-32(%rbp), %eax
	cltq
	salq	$2, %rax
	leaq	-4(%rax), %rcx
	movq	-24(%rbp), %rax
	addq	%rcx, %rax
	movl	(%rax), %eax
	movl	-32(%rbp), %ecx
	movslq	%ecx, %rcx
	leaq	0(,%rcx,4), %rsi
	movq	-16(%rbp), %rcx
	addq	%rsi, %rcx
	cmpl	%eax, %edx
	cmovle	%edx, %eax
	movl	%eax, (%rcx)
	addl	$1, -32(%rbp)
.L4:
	movl	-36(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -32(%rbp)
	jl	.L5
	movl	$0, -28(%rbp)
	movl	$0, -32(%rbp)
	jmp	.L6
.L7:
	movl	-32(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	addl	%eax, -28(%rbp)
	addl	$1, -32(%rbp)
.L6:
	movl	-36(%rbp), %eax
	cmpl	%eax, -32(%rbp)
	jl	.L7
	movl	-28(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L9
	call	__stack_chk_fail@PLT
.L9:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.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
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$48, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-36(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-36(%rbp), %eax
	subl	$1, %eax
	cltq
	salq	$2, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, -24(%rbp)
	movl	-36(%rbp), %eax
	cltq
	salq	$2, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, -16(%rbp)
	movl	$0, -32(%rbp)
	jmp	.L2
.L3:
	movl	-32(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -32(%rbp)
.L2:
	movl	-36(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -32(%rbp)
	jl	.L3
	movq	-24(%rbp), %rax
	movl	(%rax), %edx
	movq	-16(%rbp), %rax
	movl	%edx, (%rax)
	movl	-36(%rbp), %eax
	cltq
	salq	$2, %rax
	leaq	-8(%rax), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	-36(%rbp), %edx
	movslq	%edx, %rdx
	salq	$2, %rdx
	leaq	-4(%rdx), %rcx
	movq	-16(%rbp), %rdx
	addq	%rcx, %rdx
	movl	(%rax), %eax
	movl	%eax, (%rdx)
	movl	$1, -32(%rbp)
	jmp	.L4
.L5:
	movl	-32(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movl	-32(%rbp), %eax
	cltq
	salq	$2, %rax
	leaq	-4(%rax), %rcx
	movq	-24(%rbp), %rax
	addq	%rcx, %rax
	movl	(%rax), %eax
	movl	-32(%rbp), %ecx
	movslq	%ecx, %rcx
	leaq	0(,%rcx,4), %rsi
	movq	-16(%rbp), %rcx
	addq	%rsi, %rcx
	cmpl	%eax, %edx
	cmovle	%edx, %eax
	movl	%eax, (%rcx)
	addl	$1, -32(%rbp)
.L4:
	movl	-36(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -32(%rbp)
	jl	.L5
	movl	$0, -28(%rbp)
	movl	$0, -32(%rbp)
	jmp	.L6
.L7:
	movl	-32(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	addl	%eax, -28(%rbp)
	addl	$1, -32(%rbp)
.L6:
	movl	-36(%rbp), %eax
	cmpl	%eax, -32(%rbp)
	jl	.L7
	movl	-28(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L9
	call	__stack_chk_fail@PLT
.L9:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.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:
