Given the following C code and assembly code, your task is to generate highly optimized x86-64 assembly code.
C Code:

```c
#include<stdio.h>
#include<stdlib.h>

typedef long long int int64;

void run(void){
  int n;
  scanf("%d",&n);
  int *a=(int *)malloc(sizeof(int)*n);
  int i;
  for(i=0;i<n;i++) scanf("%d",a+i);
  if(a[0]!=0){
    printf("-1\n");
    return;
  }
  int zeroIndex=0;
  for(i=1;i<n;i++){
    if(a[i]==0){
      zeroIndex=i;
    } else if(a[i]>i-zeroIndex || a[i-1]<a[i]-1){
      printf("-1\n");
      return;
    }
  }
  int64 ans=0;
  i=n-1;
  while(i>=0){
    int j=i-1;
    while(j>=0 && a[j]+1==a[j+1]) j--;
    ans+=a[i];
    i=j;
  }
  printf("%lld\n",ans);
}

int main(void){
  run();
  return 0;
}
```

Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	"-1"
.LC2:
	.string	"%lld\n"
	.text
	.p2align 4
	.globl	run
	.type	run, @function
run:
.LFB39:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	leaq	.LC0(%rip), %r14
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	movq	%r14, %rdi
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	subq	$16, %rsp
	.cfi_def_cfa_offset 64
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	leaq	4(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movslq	4(%rsp), %rdi
	movq	%rdi, %rbx
	salq	$2, %rdi
	call	malloc@PLT
	movq	%rax, %rbp
	testl	%ebx, %ebx
	jle	.L2
	movq	%rax, %r13
	xorl	%r12d, %r12d
	.p2align 4,,10
	.p2align 3
.L3:
	movq	%r13, %rsi
	movq	%r14, %rdi
	xorl	%eax, %eax
	addl	$1, %r12d
	call	__isoc99_scanf@PLT
	movl	4(%rsp), %ebx
	addq	$4, %r13
	cmpl	%r12d, %ebx
	jg	.L3
.L2:
	movl	0(%rbp), %ecx
	testl	%ecx, %ecx
	jne	.L4
	movslq	%ebx, %rsi
	movl	$1, %eax
	xorl	%r9d, %r9d
	cmpl	$1, %ebx
	jg	.L9
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L28:
	movl	%eax, %edi
	subl	%ecx, %edi
	cmpl	%edi, %edx
	jg	.L4
	subl	$1, %edx
	cmpl	%edx, -4(%rbp,%rax,4)
	jl	.L4
	addq	$1, %rax
	cmpq	%rax, %rsi
	je	.L27
.L9:
	movl	0(%rbp,%rax,4), %edx
	testl	%edx, %edx
	jne	.L28
	movl	%eax, %ecx
	addq	$1, %rax
	cmpq	%rax, %rsi
	jne	.L9
.L27:
	leal	-1(%rbx), %ecx
	xorl	%r9d, %r9d
	.p2align 4,,10
	.p2align 3
.L14:
	leal	-1(%rcx), %eax
	testl	%ecx, %ecx
	je	.L6
	movslq	%ecx, %rcx
	cltq
	movslq	0(%rbp,%rcx,4), %r8
	movl	%r8d, %edx
	jmp	.L11
	.p2align 4,,10
	.p2align 3
.L13:
	subq	$1, %rax
	cmpl	$-1, %eax
	je	.L12
.L11:
	movl	%edx, %esi
	movl	0(%rbp,%rax,4), %edx
	movl	%eax, %ecx
	leal	1(%rdx), %edi
	cmpl	%esi, %edi
	je	.L13
	addq	%r8, %r9
	cmpl	$-1, %eax
	jne	.L14
	.p2align 4,,10
	.p2align 3
.L6:
	movq	%r9, %rdx
	leaq	.LC2(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L1
	.p2align 4,,10
	.p2align 3
.L4:
	leaq	.LC1(%rip), %rdi
	call	puts@PLT
.L1:
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L29
	addq	$16, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 48
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L12:
	.cfi_restore_state
	addq	%r8, %r9
	jmp	.L6
.L29:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE39:
	.size	run, .-run
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB40:
	.cfi_startproc
	endbr64
	subq	$8, %rsp
	.cfi_def_cfa_offset 16
	call	run
	xorl	%eax, %eax
	addq	$8, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE40:
	.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.
Optimized Assembly Code:

user
```assembly
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	"-1"
.LC2:
	.string	"%lld\n"
	.text
	.p2align 4
	.globl	run
	.type	run, @function
run:
.LFB39:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	leaq	.LC0(%rip), %r14
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	movq	%r14, %rdi
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	subq	$16, %rsp
	.cfi_def_cfa_offset 64
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	leaq	4(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movslq	4(%rsp), %rdi
	movq	%rdi, %rbx
	salq	$2, %rdi
	call	malloc@PLT
	movq	%rax, %rbp
	testl	%ebx, %ebx
	jle	.L2
	movq	%rax, %r13
	xorl	%r12d, %r12d
	.p2align 4,,10
	.p2align 3
.L3:
	movq	%r13, %rsi
	movq	%r14, %rdi
	xorl	%eax, %eax
	addl	$1, %r12d
	call	__isoc99_scanf@PLT
	movl	4(%rsp), %ebx
	addq	$4, %r13
	cmpl	%r12d, %ebx
	jg	.L3
.L2:
	movl	0(%rbp), %ecx
	testl	%ecx, %ecx
	jne	.L4
	movslq	%ebx, %rsi
	movl	$1, %eax
	xorl	%r9d, %r9d
	cmpl	$1, %ebx
	jg	.L9
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L28:
	movl	%eax, %edi
	subl	%ecx, %edi
	cmpl	%edi, %edx
	jg	.L4
	subl	$1, %edx
	cmpl	%edx, -4(%rbp,%rax,4)
	jl	.L4
	addq	$1, %rax
	cmpq	%rax, %rsi
	je	.L27
.L9:
	movl	0(%rbp,%rax,4), %edx
	testl	%edx, %edx
	jne	.L28
	movl	%eax, %ecx
	addq	$1, %rax
	cmpq	%rax, %rsi
	jne	.L9
.L27:
	leal	-1(%rbx), %ecx
	xorl	%r9d, %r9d
	.p2align 4,,10
	.p2align 3
.L14:
	leal	-1(%rcx), %eax
	testl	%ecx, %ecx
	je	.L6
	movslq	%ecx, %rcx
	cltq
	movslq	0(%rbp,%rcx,4), %r8
	movl	%r8d, %edx
	jmp	.L11
	.p2align 4,,10
	.p2align 3
.L13:
	subq	$1, %rax
	cmpl	$-1, %eax
	je	.L12
.L11:
	movl	%edx, %esi
	movl	0(%rbp,%rax,4), %edx
	movl	%eax, %ecx
	leal	1(%rdx), %edi
	cmpl	%esi, %edi
	je	.L13
	addq	%r8, %r9
	cmpl	$-1, %eax
	jne	.L14
	.p2align 4,,10
	.p2align 3
.L6:
	movq	%r9, %rdx
	leaq	.LC2(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L1
	.p2align 4,,10
	.p2align 3
.L4:
	leaq	.LC1(%rip), %rdi
	call	puts@PLT
.L1:
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L29
	addq	$16, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 48
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L12:
	.cfi_restore_state
	addq	%r8, %r9
	jmp	.L6
.L29:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE39:
	.size	run, .-run
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB40:
	.cfi_startproc
	endbr64
	subq	$8, %rsp
	.cfi_def_cfa_offset 16
	call	run
	xorl	%eax, %eax
	addq	$8, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE40:
	.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
```assembly
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	"-1"
.LC2:
	.string	"%lld\n"
	.text
	.p2align 4
	.globl	run
	.type	run, @function
run:
.LFB39:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	leaq	.LC0(%rip), %r14
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	movq	%r14, %rdi
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	subq	$16, %rsp
	.cfi_def_cfa_offset 64
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	leaq	4(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movslq	4(%rsp), %rdi
	movq	%rdi, %rbx
	salq	$2, %rdi
	call	malloc@PLT
	movq	%rax, %rbp
	testl	%ebx, %ebx
	jle	.L2
	movq	%rax, %r13
	xorl	%r12d, %r12d
	.p2align 4,,10
	.p2align 3
.L3:
	movq	%r13, %rsi
	movq	%r14, %rdi
	xorl	%eax, %eax
	addl	$1, %r12d
	call	__isoc99_scanf@PLT
	movl	4(%rsp), %ebx
	addq	$4, %r13
	cmpl	%r12d, %ebx
	jg	.L3
.L2:
	movl	0(%rbp), %ecx
	testl	%ecx, %ecx
	jne	.L4
	movslq	%ebx, %rsi
	movl	$1, %eax
	xorl	%r9d, %r9d
	cmpl	$1, %ebx
	jg	.L9
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L28:
	movl	%eax, %edi
	subl	%ecx, %edi
	cmpl	%edi, %edx
	jg	.L4
	subl	$1, %edx
	cmpl	%edx, -4(%rbp,%rax,4)
	jl	.L4
	addq	$1, %rax
	cmpq	%rax, %rsi
	je	.L27
.L9:
	movl	0(%rbp,%rax,4), %edx
	testl	%edx, %edx
	jne	.L28
	movl	%eax, %ecx
	addq	$1, %rax
	cmpq	%rax, %rsi
	jne	.L9
.L27:
	leal	-1(%rbx), %ecx
	xorl	%r9d, %r9d
	.p2align 4,,10
	.p2align 3
.L14:
	leal	-1(%rcx), %eax
	testl	%ecx, %ecx
	je	.L6
	movslq	%ecx, %rcx
	cltq
	movslq	0(%rbp,%rcx,4), %r8
	movl	%r8d, %edx
	jmp	.L11
	.p2align 4,,10
	.p2align 3
.L13:
	subq	$1, %rax
	cmpl	$-1, %eax
	je	.L12
.L11:
	movl	%edx, %esi
	movl	0(%rbp,%rax,4), %edx
	movl	%eax, %ecx
	leal	1(%rdx), %edi
	cmpl	%esi, %edi
	je	.L13
	addq	%r8, %r9
	cmpl	$-1, %eax
	jne	.L14
	.p2align 4,,10
	.p2align 3
.L6:
	movq	%r9, %rdx
	leaq	.LC2(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L1
	.p2align 4,,10
	.p2align 3
.L4:
	leaq	.LC1(%rip), %rdi
	call	puts@PLT
.L1:
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L29
	addq	$16, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 48
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L12:
	.cfi_restore_state
	addq	%r8, %r9
	jmp	.L6
.L29:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE39:
	.size	run, .-run
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB40:
	.cfi_startproc
	endbr64
	subq	$8, %rsp
	.cfi_def_cfa_offset 16
	call	run
	xorl	%eax, %eax
	addq	$8, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE40:
	.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:
```
```c
#include<stdio.h>
#include<stdlib.h>

typedef long long int int64;

void run(void){
  int n;
  scanf("%d",&n);
  int *a=(int *)malloc(sizeof(int)*n);
  int i;
  for(i=0;i<n;i++) scanf("%d",a+i);
  if(a[0]!=0){
    printf("-1\n");
    return;
  }
  int zeroIndex=0;
  for(i=1;i<n;i++){
    if(a[i]==0){
      zeroIndex=i;
    } else if(a[i]>i-zeroIndex || a[i-1]<a[i]-1){
      printf("-1\n");
      return;
    }
  }
  int64 ans=0;
  i=n-1;
  while(i>=0){
    int j=i-1;
    while(j>=0 && a[j]+1==a[j+1]) j--;
    ans+=a[i];
    i=j;
  }
  printf("%lld\n",ans);
}

int main(void){
  run();
  return 0;
}
```
Given the following C code, your task is to generate highly optimized x86-64 assembly code.
C Code:

```c
#include<stdio.h>
#include<stdlib.h>

typedef long long int int64;

void run(void){
  int n;
  scanf("%d",&n);
  int *a=(int *)malloc(sizeof(int)*n);
  int i;
  for(i=0;i<n;i++) scanf("%d",a+i);
  if(a[0]!=0){
    printf("-1\n");
    return;
  }
  int zeroIndex=0;
  for(i=1;i<n;i++){
    if(a[i]==0){
      zeroIndex=i;
    } else if(a[i]>i-zeroIndex || a[i-1]<a[i]-1){
      printf("-1\n");
      return;
    }
  }
  int64 ans=0;
  i=n-1;
  while(i>=0){
    int j=i-1;
    while(j>=0 && a[j]+1==a[j+1]) j--;
    ans+=a[i];
    i=j;
  }
  printf("%lld\n",ans);
}

int main(void){
  run();
  return 0;
}
```

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.
Optimized Assembly Code:

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 assembly code, your task is to generate highly optimized x86-64 assembly code.
C Code:

```c
#include<stdio.h>
#include<stdlib.h>

typedef long long int int64;

void run(void){
  int n;
  scanf("%d",&n);
  int *a=(int *)malloc(sizeof(int)*n);
  int i;
  for(i=0;i<n;i++) scanf("%d",a+i);
  if(a[0]!=0){
    printf("-1\n");
    return;
  }
  int zeroIndex=0;
  for(i=1;i<n;i++){
    if(a[i]==0){
      zeroIndex=i;
    } else if(a[i]>i-zeroIndex || a[i-1]<a[i]-1){
      printf("-1\n");
      return;
    }
  }
  int64 ans=0;
  i=n-1;
  while(i>=0){
    int j=i-1;
    while(j>=0 && a[j]+1==a[j+1]) j--;
    ans+=a[i];
    i=j;
  }
  printf("%lld\n",ans);
}

int main(void){
  run();
  return 0;
}
```

Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	"-1"
.LC2:
	.string	"%lld\n"
	.text
	.p2align 4
	.globl	run
	.type	run, @function
run:
.LFB39:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	leaq	.LC0(%rip), %r14
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	movq	%r14, %rdi
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	subq	$16, %rsp
	.cfi_def_cfa_offset 64
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	leaq	4(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movslq	4(%rsp), %rdi
	movq	%rdi, %rbx
	salq	$2, %rdi
	call	malloc@PLT
	movq	%rax, %rbp
	testl	%ebx, %ebx
	jle	.L2
	movq	%rax, %r13
	xorl	%r12d, %r12d
	.p2align 4,,10
	.p2align 3
.L3:
	movq	%r13, %rsi
	movq	%r14, %rdi
	xorl	%eax, %eax
	addl	$1, %r12d
	call	__isoc99_scanf@PLT
	movl	4(%rsp), %ebx
	addq	$4, %r13
	cmpl	%r12d, %ebx
	jg	.L3
.L2:
	movl	0(%rbp), %ecx
	testl	%ecx, %ecx
	jne	.L4
	movslq	%ebx, %rsi
	movl	$1, %eax
	xorl	%r9d, %r9d
	cmpl	$1, %ebx
	jg	.L9
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L28:
	movl	%eax, %edi
	subl	%ecx, %edi
	cmpl	%edi, %edx
	jg	.L4
	subl	$1, %edx
	cmpl	%edx, -4(%rbp,%rax,4)
	jl	.L4
	addq	$1, %rax
	cmpq	%rax, %rsi
	je	.L27
.L9:
	movl	0(%rbp,%rax,4), %edx
	testl	%edx, %edx
	jne	.L28
	movl	%eax, %ecx
	addq	$1, %rax
	cmpq	%rax, %rsi
	jne	.L9
.L27:
	leal	-1(%rbx), %ecx
	xorl	%r9d, %r9d
	.p2align 4,,10
	.p2align 3
.L14:
	leal	-1(%rcx), %eax
	testl	%ecx, %ecx
	je	.L6
	movslq	%ecx, %rcx
	cltq
	movslq	0(%rbp,%rcx,4), %r8
	movl	%r8d, %edx
	jmp	.L11
	.p2align 4,,10
	.p2align 3
.L13:
	subq	$1, %rax
	cmpl	$-1, %eax
	je	.L12
.L11:
	movl	%edx, %esi
	movl	0(%rbp,%rax,4), %edx
	movl	%eax, %ecx
	leal	1(%rdx), %edi
	cmpl	%esi, %edi
	je	.L13
	addq	%r8, %r9
	cmpl	$-1, %eax
	jne	.L14
	.p2align 4,,10
	.p2align 3
.L6:
	movq	%r9, %rdx
	leaq	.LC2(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L1
	.p2align 4,,10
	.p2align 3
.L4:
	leaq	.LC1(%rip), %rdi
	call	puts@PLT
.L1:
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L29
	addq	$16, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 48
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L12:
	.cfi_restore_state
	addq	%r8, %r9
	jmp	.L6
.L29:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE39:
	.size	run, .-run
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB40:
	.cfi_startproc
	endbr64
	subq	$8, %rsp
	.cfi_def_cfa_offset 16
	call	run
	xorl	%eax, %eax
	addq	$8, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE40:
	.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.
Optimized Assembly Code:

train
```assembly
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	"-1"
.LC2:
	.string	"%lld\n"
	.text
	.p2align 4
	.globl	run
	.type	run, @function
run:
.LFB39:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	leaq	.LC0(%rip), %r14
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	movq	%r14, %rdi
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	subq	$16, %rsp
	.cfi_def_cfa_offset 64
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	leaq	4(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movslq	4(%rsp), %rdi
	movq	%rdi, %rbx
	salq	$2, %rdi
	call	malloc@PLT
	movq	%rax, %rbp
	testl	%ebx, %ebx
	jle	.L2
	movq	%rax, %r13
	xorl	%r12d, %r12d
	.p2align 4,,10
	.p2align 3
.L3:
	movq	%r13, %rsi
	movq	%r14, %rdi
	xorl	%eax, %eax
	addl	$1, %r12d
	call	__isoc99_scanf@PLT
	movl	4(%rsp), %ebx
	addq	$4, %r13
	cmpl	%r12d, %ebx
	jg	.L3
.L2:
	movl	0(%rbp), %ecx
	testl	%ecx, %ecx
	jne	.L4
	movslq	%ebx, %rsi
	movl	$1, %eax
	xorl	%r9d, %r9d
	cmpl	$1, %ebx
	jg	.L9
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L28:
	movl	%eax, %edi
	subl	%ecx, %edi
	cmpl	%edi, %edx
	jg	.L4
	subl	$1, %edx
	cmpl	%edx, -4(%rbp,%rax,4)
	jl	.L4
	addq	$1, %rax
	cmpq	%rax, %rsi
	je	.L27
.L9:
	movl	0(%rbp,%rax,4), %edx
	testl	%edx, %edx
	jne	.L28
	movl	%eax, %ecx
	addq	$1, %rax
	cmpq	%rax, %rsi
	jne	.L9
.L27:
	leal	-1(%rbx), %ecx
	xorl	%r9d, %r9d
	.p2align 4,,10
	.p2align 3
.L14:
	leal	-1(%rcx), %eax
	testl	%ecx, %ecx
	je	.L6
	movslq	%ecx, %rcx
	cltq
	movslq	0(%rbp,%rcx,4), %r8
	movl	%r8d, %edx
	jmp	.L11
	.p2align 4,,10
	.p2align 3
.L13:
	subq	$1, %rax
	cmpl	$-1, %eax
	je	.L12
.L11:
	movl	%edx, %esi
	movl	0(%rbp,%rax,4), %edx
	movl	%eax, %ecx
	leal	1(%rdx), %edi
	cmpl	%esi, %edi
	je	.L13
	addq	%r8, %r9
	cmpl	$-1, %eax
	jne	.L14
	.p2align 4,,10
	.p2align 3
.L6:
	movq	%r9, %rdx
	leaq	.LC2(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L1
	.p2align 4,,10
	.p2align 3
.L4:
	leaq	.LC1(%rip), %rdi
	call	puts@PLT
.L1:
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L29
	addq	$16, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 48
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L12:
	.cfi_restore_state
	addq	%r8, %r9
	jmp	.L6
.L29:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE39:
	.size	run, .-run
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB40:
	.cfi_startproc
	endbr64
	subq	$8, %rsp
	.cfi_def_cfa_offset 16
	call	run
	xorl	%eax, %eax
	addq	$8, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE40:
	.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:
```