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 main(void){
    long long n,ans=0;
    scanf("%lld",&n);
    long long a[n+1];
    a[n]=0;
    for (long long i=0; i<n; i++){
        scanf("%lld",&a[i]);
    }
    if (n==1){
        if (a[0]==0){
            printf("0\n");
        } else {
            printf("-1\n");
        }
        return 0;
    }
    for (long long i=1; i<n; i++){
        if (a[i]>a[i-1]+1 || a[i]>i || a[0]!=0){
            printf("-1\n");
            return 0;
        } else if (a[i]>=a[i+1]){
            ans+=a[i];
        }
    }
    printf("%lld\n",ans); 
    return 0;   
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%lld"
.LC1:
	.string	"0"
.LC2:
	.string	"-1"
.LC3:
	.string	"%lld\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB0:
	.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	$72, %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
	movq	$0, -96(%rbp)
	leaq	-104(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	-104(%rbp), %rax
	addq	$1, %rax
	leaq	-1(%rax), %rdx
	movq	%rdx, -72(%rbp)
	movq	%rax, %rdx
	movq	%rdx, %r14
	movl	$0, %r15d
	movq	%rax, %rdx
	movq	%rdx, %r12
	movl	$0, %r13d
	leaq	0(,%rax,8), %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
.L2:
	cmpq	%rdx, %rsp
	je	.L3
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L2
.L3:
	movq	%rax, %rdx
	andl	$4095, %edx
	subq	%rdx, %rsp
	movq	%rax, %rdx
	andl	$4095, %edx
	testq	%rdx, %rdx
	je	.L4
	andl	$4095, %eax
	subq	$8, %rax
	addq	%rsp, %rax
	orq	$0, (%rax)
.L4:
	movq	%rsp, %rax
	addq	$7, %rax
	shrq	$3, %rax
	salq	$3, %rax
	movq	%rax, -64(%rbp)
	movq	-104(%rbp), %rdx
	movq	-64(%rbp), %rax
	movq	$0, (%rax,%rdx,8)
	movq	$0, -88(%rbp)
	jmp	.L5
.L6:
	movq	-88(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	movq	-64(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addq	$1, -88(%rbp)
.L5:
	movq	-104(%rbp), %rax
	cmpq	%rax, -88(%rbp)
	jl	.L6
	movq	-104(%rbp), %rax
	cmpq	$1, %rax
	jne	.L7
	movq	-64(%rbp), %rax
	movq	(%rax), %rax
	testq	%rax, %rax
	jne	.L8
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	jmp	.L9
.L8:
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
.L9:
	movl	$0, %eax
	jmp	.L10
.L7:
	movq	$1, -80(%rbp)
	jmp	.L11
.L15:
	movq	-64(%rbp), %rax
	movq	-80(%rbp), %rdx
	movq	(%rax,%rdx,8), %rdx
	movq	-80(%rbp), %rax
	leaq	-1(%rax), %rcx
	movq	-64(%rbp), %rax
	movq	(%rax,%rcx,8), %rax
	addq	$1, %rax
	cmpq	%rax, %rdx
	jg	.L12
	movq	-64(%rbp), %rax
	movq	-80(%rbp), %rdx
	movq	(%rax,%rdx,8), %rax
	cmpq	%rax, -80(%rbp)
	jl	.L12
	movq	-64(%rbp), %rax
	movq	(%rax), %rax
	testq	%rax, %rax
	je	.L13
.L12:
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	movl	$0, %eax
	jmp	.L10
.L13:
	movq	-64(%rbp), %rax
	movq	-80(%rbp), %rdx
	movq	(%rax,%rdx,8), %rdx
	movq	-80(%rbp), %rax
	leaq	1(%rax), %rcx
	movq	-64(%rbp), %rax
	movq	(%rax,%rcx,8), %rax
	cmpq	%rax, %rdx
	jl	.L14
	movq	-64(%rbp), %rax
	movq	-80(%rbp), %rdx
	movq	(%rax,%rdx,8), %rax
	addq	%rax, -96(%rbp)
.L14:
	addq	$1, -80(%rbp)
.L11:
	movq	-104(%rbp), %rax
	cmpq	%rax, -80(%rbp)
	jl	.L15
	movq	-96(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
.L10:
	movq	%rbx, %rsp
	movq	-56(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L17
	call	__stack_chk_fail@PLT
.L17:
	leaq	-40(%rbp), %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.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	"%lld"
.LC1:
	.string	"0"
.LC2:
	.string	"-1"
.LC3:
	.string	"%lld\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.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
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	leaq	.LC0(%rip), %r14
	leaq	-64(%rbp), %rsi
	pushq	%r13
	movq	%r14, %rdi
	pushq	%r12
	pushq	%rbx
	subq	$24, %rsp
	.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
	movq	-64(%rbp), %rsi
	movq	%rsp, %rcx
	leaq	23(,%rsi,8), %rax
	movq	%rax, %rdx
	andq	$-4096, %rax
	subq	%rax, %rcx
	andq	$-16, %rdx
	cmpq	%rcx, %rsp
	je	.L3
.L21:
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	cmpq	%rcx, %rsp
	jne	.L21
.L3:
	andl	$4095, %edx
	subq	%rdx, %rsp
	testq	%rdx, %rdx
	jne	.L22
.L4:
	leaq	7(%rsp), %r15
	movq	%r15, %r13
	andq	$-8, %r15
	movq	$0, (%r15,%rsi,8)
	shrq	$3, %r13
	testq	%rsi, %rsi
	jle	.L5
	movq	%r15, %r12
	xorl	%ebx, %ebx
	.p2align 4,,10
	.p2align 3
.L6:
	movq	%r12, %rsi
	movq	%r14, %rdi
	xorl	%eax, %eax
	addq	$1, %rbx
	call	__isoc99_scanf@PLT
	movq	-64(%rbp), %rsi
	addq	$8, %r12
	cmpq	%rbx, %rsi
	jg	.L6
	cmpq	$1, %rsi
	je	.L7
.L5:
	cmpq	$1, %rsi
	jle	.L14
	movq	0(,%r13,8), %r8
	movl	$1, %edx
	movq	8(,%r13,8), %rcx
	leaq	1(%r8), %rax
	testq	%rax, %rax
	cmovg	%rdx, %rax
	cmpq	%rax, %rcx
	jg	.L9
	testq	%r8, %r8
	jne	.L9
	movl	$1, %eax
	.p2align 4,,10
	.p2align 3
.L11:
	addq	$1, %rax
	movq	%rcx, %rdx
	movq	(%r15,%rax,8), %rcx
	leaq	(%r8,%rdx), %rdi
	cmpq	%rcx, %rdx
	cmovge	%rdi, %r8
	cmpq	%rax, %rsi
	je	.L8
	movq	-8(%r15,%rax,8), %rbx
	leaq	1(%rbx), %rdx
	cmpq	%rax, %rdx
	cmovg	%rax, %rdx
	cmpq	%rcx, %rdx
	jge	.L11
.L9:
	leaq	.LC2(%rip), %rdi
	call	puts@PLT
.L12:
	movq	-56(%rbp), %rax
	subq	%fs:40, %rax
	jne	.L23
	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
.L7:
	.cfi_restore_state
	cmpq	$0, 0(,%r13,8)
	jne	.L9
	leaq	.LC1(%rip), %rdi
	call	puts@PLT
	jmp	.L12
.L14:
	xorl	%r8d, %r8d
.L8:
	movq	%r8, %rdx
	leaq	.LC3(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L12
.L22:
	orq	$0, -8(%rsp,%rdx)
	jmp	.L4
.L23:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.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	"%lld"
.LC1:
	.string	"0"
.LC2:
	.string	"-1"
.LC3:
	.string	"%lld\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.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
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	leaq	.LC0(%rip), %r14
	leaq	-64(%rbp), %rsi
	pushq	%r13
	movq	%r14, %rdi
	pushq	%r12
	pushq	%rbx
	subq	$24, %rsp
	.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
	movq	-64(%rbp), %rsi
	movq	%rsp, %rcx
	leaq	23(,%rsi,8), %rax
	movq	%rax, %rdx
	andq	$-4096, %rax
	subq	%rax, %rcx
	andq	$-16, %rdx
	cmpq	%rcx, %rsp
	je	.L3
.L21:
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	cmpq	%rcx, %rsp
	jne	.L21
.L3:
	andl	$4095, %edx
	subq	%rdx, %rsp
	testq	%rdx, %rdx
	jne	.L22
.L4:
	leaq	7(%rsp), %r15
	movq	%r15, %r13
	andq	$-8, %r15
	movq	$0, (%r15,%rsi,8)
	shrq	$3, %r13
	testq	%rsi, %rsi
	jle	.L5
	movq	%r15, %r12
	xorl	%ebx, %ebx
	.p2align 4,,10
	.p2align 3
.L6:
	movq	%r12, %rsi
	movq	%r14, %rdi
	xorl	%eax, %eax
	addq	$1, %rbx
	call	__isoc99_scanf@PLT
	movq	-64(%rbp), %rsi
	addq	$8, %r12
	cmpq	%rbx, %rsi
	jg	.L6
	cmpq	$1, %rsi
	je	.L7
.L5:
	cmpq	$1, %rsi
	jle	.L14
	movq	0(,%r13,8), %r8
	movl	$1, %edx
	movq	8(,%r13,8), %rcx
	leaq	1(%r8), %rax
	testq	%rax, %rax
	cmovg	%rdx, %rax
	cmpq	%rax, %rcx
	jg	.L9
	testq	%r8, %r8
	jne	.L9
	movl	$1, %eax
	.p2align 4,,10
	.p2align 3
.L11:
	addq	$1, %rax
	movq	%rcx, %rdx
	movq	(%r15,%rax,8), %rcx
	leaq	(%r8,%rdx), %rdi
	cmpq	%rcx, %rdx
	cmovge	%rdi, %r8
	cmpq	%rax, %rsi
	je	.L8
	movq	-8(%r15,%rax,8), %rbx
	leaq	1(%rbx), %rdx
	cmpq	%rax, %rdx
	cmovg	%rax, %rdx
	cmpq	%rcx, %rdx
	jge	.L11
.L9:
	leaq	.LC2(%rip), %rdi
	call	puts@PLT
.L12:
	movq	-56(%rbp), %rax
	subq	%fs:40, %rax
	jne	.L23
	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
.L7:
	.cfi_restore_state
	cmpq	$0, 0(,%r13,8)
	jne	.L9
	leaq	.LC1(%rip), %rdi
	call	puts@PLT
	jmp	.L12
.L14:
	xorl	%r8d, %r8d
.L8:
	movq	%r8, %rdx
	leaq	.LC3(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L12
.L22:
	orq	$0, -8(%rsp,%rdx)
	jmp	.L4
.L23:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.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 main(void){
    long long n,ans=0;
    scanf("%lld",&n);
    long long a[n+1];
    a[n]=0;
    for (long long i=0; i<n; i++){
        scanf("%lld",&a[i]);
    }
    if (n==1){
        if (a[0]==0){
            printf("0\n");
        } else {
            printf("-1\n");
        }
        return 0;
    }
    for (long long i=1; i<n; i++){
        if (a[i]>a[i-1]+1 || a[i]>i || a[0]!=0){
            printf("-1\n");
            return 0;
        } else if (a[i]>=a[i+1]){
            ans+=a[i];
        }
    }
    printf("%lld\n",ans); 
    return 0;   
}
3
0
2
1
 4
0
0
1
2
 3
0
1
0
 3
0
0
0
 9
0
1
1
0
2
2
2
1
2
 3
0
2
2
 9
0
1
1
0
2
2
2
1
4
 4
0
0
0
2
 3
0
1
2
 9
0
1
1
0
2
2
2
1
3

-1
 2
 1
 0
 -1
 -1
 -1
 -1
 2
 -1

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 main(void){
    long long n,ans=0;
    scanf("%lld",&n);
    long long a[n+1];
    a[n]=0;
    for (long long i=0; i<n; i++){
        scanf("%lld",&a[i]);
    }
    if (n==1){
        if (a[0]==0){
            printf("0\n");
        } else {
            printf("-1\n");
        }
        return 0;
    }
    for (long long i=1; i<n; i++){
        if (a[i]>a[i-1]+1 || a[i]>i || a[0]!=0){
            printf("-1\n");
            return 0;
        } else if (a[i]>=a[i+1]){
            ans+=a[i];
        }
    }
    printf("%lld\n",ans); 
    return 0;   
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%lld"
.LC1:
	.string	"0"
.LC2:
	.string	"-1"
.LC3:
	.string	"%lld\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB0:
	.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	$72, %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
	movq	$0, -96(%rbp)
	leaq	-104(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	-104(%rbp), %rax
	addq	$1, %rax
	leaq	-1(%rax), %rdx
	movq	%rdx, -72(%rbp)
	movq	%rax, %rdx
	movq	%rdx, %r14
	movl	$0, %r15d
	movq	%rax, %rdx
	movq	%rdx, %r12
	movl	$0, %r13d
	leaq	0(,%rax,8), %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
.L2:
	cmpq	%rdx, %rsp
	je	.L3
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L2
.L3:
	movq	%rax, %rdx
	andl	$4095, %edx
	subq	%rdx, %rsp
	movq	%rax, %rdx
	andl	$4095, %edx
	testq	%rdx, %rdx
	je	.L4
	andl	$4095, %eax
	subq	$8, %rax
	addq	%rsp, %rax
	orq	$0, (%rax)
.L4:
	movq	%rsp, %rax
	addq	$7, %rax
	shrq	$3, %rax
	salq	$3, %rax
	movq	%rax, -64(%rbp)
	movq	-104(%rbp), %rdx
	movq	-64(%rbp), %rax
	movq	$0, (%rax,%rdx,8)
	movq	$0, -88(%rbp)
	jmp	.L5
.L6:
	movq	-88(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	movq	-64(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addq	$1, -88(%rbp)
.L5:
	movq	-104(%rbp), %rax
	cmpq	%rax, -88(%rbp)
	jl	.L6
	movq	-104(%rbp), %rax
	cmpq	$1, %rax
	jne	.L7
	movq	-64(%rbp), %rax
	movq	(%rax), %rax
	testq	%rax, %rax
	jne	.L8
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	jmp	.L9
.L8:
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
.L9:
	movl	$0, %eax
	jmp	.L10
.L7:
	movq	$1, -80(%rbp)
	jmp	.L11
.L15:
	movq	-64(%rbp), %rax
	movq	-80(%rbp), %rdx
	movq	(%rax,%rdx,8), %rdx
	movq	-80(%rbp), %rax
	leaq	-1(%rax), %rcx
	movq	-64(%rbp), %rax
	movq	(%rax,%rcx,8), %rax
	addq	$1, %rax
	cmpq	%rax, %rdx
	jg	.L12
	movq	-64(%rbp), %rax
	movq	-80(%rbp), %rdx
	movq	(%rax,%rdx,8), %rax
	cmpq	%rax, -80(%rbp)
	jl	.L12
	movq	-64(%rbp), %rax
	movq	(%rax), %rax
	testq	%rax, %rax
	je	.L13
.L12:
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	movl	$0, %eax
	jmp	.L10
.L13:
	movq	-64(%rbp), %rax
	movq	-80(%rbp), %rdx
	movq	(%rax,%rdx,8), %rdx
	movq	-80(%rbp), %rax
	leaq	1(%rax), %rcx
	movq	-64(%rbp), %rax
	movq	(%rax,%rcx,8), %rax
	cmpq	%rax, %rdx
	jl	.L14
	movq	-64(%rbp), %rax
	movq	-80(%rbp), %rdx
	movq	(%rax,%rdx,8), %rax
	addq	%rax, -96(%rbp)
.L14:
	addq	$1, -80(%rbp)
.L11:
	movq	-104(%rbp), %rax
	cmpq	%rax, -80(%rbp)
	jl	.L15
	movq	-96(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
.L10:
	movq	%rbx, %rsp
	movq	-56(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L17
	call	__stack_chk_fail@PLT
.L17:
	leaq	-40(%rbp), %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.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.
val
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%lld"
.LC1:
	.string	"0"
.LC2:
	.string	"-1"
.LC3:
	.string	"%lld\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB0:
	.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	$72, %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
	movq	$0, -96(%rbp)
	leaq	-104(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	-104(%rbp), %rax
	addq	$1, %rax
	leaq	-1(%rax), %rdx
	movq	%rdx, -72(%rbp)
	movq	%rax, %rdx
	movq	%rdx, %r14
	movl	$0, %r15d
	movq	%rax, %rdx
	movq	%rdx, %r12
	movl	$0, %r13d
	leaq	0(,%rax,8), %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
.L2:
	cmpq	%rdx, %rsp
	je	.L3
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L2
.L3:
	movq	%rax, %rdx
	andl	$4095, %edx
	subq	%rdx, %rsp
	movq	%rax, %rdx
	andl	$4095, %edx
	testq	%rdx, %rdx
	je	.L4
	andl	$4095, %eax
	subq	$8, %rax
	addq	%rsp, %rax
	orq	$0, (%rax)
.L4:
	movq	%rsp, %rax
	addq	$7, %rax
	shrq	$3, %rax
	salq	$3, %rax
	movq	%rax, -64(%rbp)
	movq	-104(%rbp), %rdx
	movq	-64(%rbp), %rax
	movq	$0, (%rax,%rdx,8)
	movq	$0, -88(%rbp)
	jmp	.L5
.L6:
	movq	-88(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	movq	-64(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addq	$1, -88(%rbp)
.L5:
	movq	-104(%rbp), %rax
	cmpq	%rax, -88(%rbp)
	jl	.L6
	movq	-104(%rbp), %rax
	cmpq	$1, %rax
	jne	.L7
	movq	-64(%rbp), %rax
	movq	(%rax), %rax
	testq	%rax, %rax
	jne	.L8
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	jmp	.L9
.L8:
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
.L9:
	movl	$0, %eax
	jmp	.L10
.L7:
	movq	$1, -80(%rbp)
	jmp	.L11
.L15:
	movq	-64(%rbp), %rax
	movq	-80(%rbp), %rdx
	movq	(%rax,%rdx,8), %rdx
	movq	-80(%rbp), %rax
	leaq	-1(%rax), %rcx
	movq	-64(%rbp), %rax
	movq	(%rax,%rcx,8), %rax
	addq	$1, %rax
	cmpq	%rax, %rdx
	jg	.L12
	movq	-64(%rbp), %rax
	movq	-80(%rbp), %rdx
	movq	(%rax,%rdx,8), %rax
	cmpq	%rax, -80(%rbp)
	jl	.L12
	movq	-64(%rbp), %rax
	movq	(%rax), %rax
	testq	%rax, %rax
	je	.L13
.L12:
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	movl	$0, %eax
	jmp	.L10
.L13:
	movq	-64(%rbp), %rax
	movq	-80(%rbp), %rdx
	movq	(%rax,%rdx,8), %rdx
	movq	-80(%rbp), %rax
	leaq	1(%rax), %rcx
	movq	-64(%rbp), %rax
	movq	(%rax,%rcx,8), %rax
	cmpq	%rax, %rdx
	jl	.L14
	movq	-64(%rbp), %rax
	movq	-80(%rbp), %rdx
	movq	(%rax,%rdx,8), %rax
	addq	%rax, -96(%rbp)
.L14:
	addq	$1, -80(%rbp)
.L11:
	movq	-104(%rbp), %rax
	cmpq	%rax, -80(%rbp)
	jl	.L15
	movq	-96(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
.L10:
	movq	%rbx, %rsp
	movq	-56(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L17
	call	__stack_chk_fail@PLT
.L17:
	leaq	-40(%rbp), %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.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:
