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>
long a[100000];

int main(int argc, char const *argv[]){
	long sum,bsum,ans=0,n,i,f=0,min=1;
	scanf("%ld",&n);
	scanf("%ld",&a[0]);
	if(a[0]==0){
		ans++;
		sum=1;
		f=1;
	}else sum=a[0];
	for(i=1;i<n;i++){
		scanf("%ld",&a[i]);
		bsum=sum;
		sum+=a[i];
		if(bsum>0){
			if(sum>=0){
				ans+=sum+1;
				sum=-1;
			}
		}else{
			if(sum<=0){
				ans+=1-sum;
				sum=1;
			}
		}
	}
		if(a[0]>=0){
			min=a[0]+1;
			sum=-1;
		}else{
			min=1-a[0];
			sum=1;
		}
		for(i=1;i<n;i++){
			bsum=sum;
			sum+=a[i];
			if(bsum>0){
				if(sum>=0){
					min+=sum+1;
					sum=-1;
				}
			}else{
				if(sum<=0){
					min+=1-sum;
					sum=1;
				}
			}
		}
		if(ans<min) printf("%ld\n",ans);
		else printf("%ld\n",min);
	return 0;
}```

Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%ld"
.LC1:
	.string	"%ld\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	leaq	.LC0(%rip), %r14
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movq	%r14, %rdi
	leaq	a(%rip), %r13
	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	$24, %rsp
	.cfi_def_cfa_offset 80
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	movq	%rsp, %rsi
	call	__isoc99_scanf@PLT
	movq	%r13, %rsi
	movq	%r14, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movq	a(%rip), %rbx
	movq	(%rsp), %rsi
	testq	%rbx, %rbx
	je	.L2
	cmpq	$1, %rsi
	jle	.L20
	xorl	%r12d, %r12d
.L17:
	leaq	8+a(%rip), %rbp
	movl	$1, %r15d
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L34:
	testq	%rax, %rax
	js	.L5
	leaq	1(%rax,%r12), %r12
	movq	$-1, %rbx
.L5:
	movq	(%rsp), %rsi
	addq	$1, %r15
	addq	$8, %rbp
	cmpq	%r15, %rsi
	jle	.L33
.L6:
	xorl	%eax, %eax
	movq	%rbp, %rsi
	movq	%r14, %rdi
	call	__isoc99_scanf@PLT
	movq	0(%rbp), %rax
	addq	%rbx, %rax
	testq	%rbx, %rbx
	movq	%rax, %rbx
	jg	.L34
	testq	%rax, %rax
	jg	.L5
	movl	$1, %eax
	subq	%rbx, %rax
	movl	$1, %ebx
	addq	%rax, %r12
	jmp	.L5
.L2:
	movl	$1, %r12d
	movl	$1, %ebx
	cmpq	$1, %rsi
	jg	.L17
	xorl	%edx, %edx
	jmp	.L16
	.p2align 4,,10
	.p2align 3
.L33:
	movq	a(%rip), %rax
.L3:
	movq	%rax, %rdx
	testq	%rax, %rax
	js	.L7
.L16:
	addq	$1, %rdx
	orq	$-1, %rax
.L10:
	leaq	8+a(%rip), %rcx
	leaq	0(%r13,%rsi,8), %rdi
	movl	$1, %r8d
	cmpq	$1, %rsi
	jg	.L13
	jmp	.L9
	.p2align 4,,10
	.p2align 3
.L35:
	testq	%rsi, %rsi
	js	.L12
	leaq	1(%rsi,%rdx), %rdx
	movq	$-1, %rax
.L12:
	addq	$8, %rcx
	cmpq	%rdi, %rcx
	je	.L9
.L13:
	movq	(%rcx), %rsi
	addq	%rax, %rsi
	testq	%rax, %rax
	movq	%rsi, %rax
	jg	.L35
	testq	%rsi, %rsi
	jg	.L12
	movq	%r8, %rsi
	addq	$8, %rcx
	subq	%rax, %rsi
	movl	$1, %eax
	addq	%rsi, %rdx
	cmpq	%rdi, %rcx
	jne	.L13
	.p2align 4,,10
	.p2align 3
.L9:
	cmpq	%r12, %rdx
	jle	.L14
	movq	%r12, %rdx
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L15:
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L36
	addq	$24, %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
.L14:
	.cfi_restore_state
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L15
.L7:
	movl	$1, %edx
	subq	%rax, %rdx
	movl	$1, %eax
	jmp	.L10
.L20:
	movq	%rbx, %rax
	xorl	%r12d, %r12d
	jmp	.L3
.L36:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.globl	a
	.bss
	.align 32
	.type	a, @object
	.size	a, 800000
a:
	.zero	800000
	.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	"%ld"
.LC1:
	.string	"%ld\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	leaq	.LC0(%rip), %r14
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movq	%r14, %rdi
	leaq	a(%rip), %r13
	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	$24, %rsp
	.cfi_def_cfa_offset 80
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	movq	%rsp, %rsi
	call	__isoc99_scanf@PLT
	movq	%r13, %rsi
	movq	%r14, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movq	a(%rip), %rbx
	movq	(%rsp), %rsi
	testq	%rbx, %rbx
	je	.L2
	cmpq	$1, %rsi
	jle	.L20
	xorl	%r12d, %r12d
.L17:
	leaq	8+a(%rip), %rbp
	movl	$1, %r15d
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L34:
	testq	%rax, %rax
	js	.L5
	leaq	1(%rax,%r12), %r12
	movq	$-1, %rbx
.L5:
	movq	(%rsp), %rsi
	addq	$1, %r15
	addq	$8, %rbp
	cmpq	%r15, %rsi
	jle	.L33
.L6:
	xorl	%eax, %eax
	movq	%rbp, %rsi
	movq	%r14, %rdi
	call	__isoc99_scanf@PLT
	movq	0(%rbp), %rax
	addq	%rbx, %rax
	testq	%rbx, %rbx
	movq	%rax, %rbx
	jg	.L34
	testq	%rax, %rax
	jg	.L5
	movl	$1, %eax
	subq	%rbx, %rax
	movl	$1, %ebx
	addq	%rax, %r12
	jmp	.L5
.L2:
	movl	$1, %r12d
	movl	$1, %ebx
	cmpq	$1, %rsi
	jg	.L17
	xorl	%edx, %edx
	jmp	.L16
	.p2align 4,,10
	.p2align 3
.L33:
	movq	a(%rip), %rax
.L3:
	movq	%rax, %rdx
	testq	%rax, %rax
	js	.L7
.L16:
	addq	$1, %rdx
	orq	$-1, %rax
.L10:
	leaq	8+a(%rip), %rcx
	leaq	0(%r13,%rsi,8), %rdi
	movl	$1, %r8d
	cmpq	$1, %rsi
	jg	.L13
	jmp	.L9
	.p2align 4,,10
	.p2align 3
.L35:
	testq	%rsi, %rsi
	js	.L12
	leaq	1(%rsi,%rdx), %rdx
	movq	$-1, %rax
.L12:
	addq	$8, %rcx
	cmpq	%rdi, %rcx
	je	.L9
.L13:
	movq	(%rcx), %rsi
	addq	%rax, %rsi
	testq	%rax, %rax
	movq	%rsi, %rax
	jg	.L35
	testq	%rsi, %rsi
	jg	.L12
	movq	%r8, %rsi
	addq	$8, %rcx
	subq	%rax, %rsi
	movl	$1, %eax
	addq	%rsi, %rdx
	cmpq	%rdi, %rcx
	jne	.L13
	.p2align 4,,10
	.p2align 3
.L9:
	cmpq	%r12, %rdx
	jle	.L14
	movq	%r12, %rdx
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L15:
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L36
	addq	$24, %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
.L14:
	.cfi_restore_state
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L15
.L7:
	movl	$1, %edx
	subq	%rax, %rdx
	movl	$1, %eax
	jmp	.L10
.L20:
	movq	%rbx, %rax
	xorl	%r12d, %r12d
	jmp	.L3
.L36:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.globl	a
	.bss
	.align 32
	.type	a, @object
	.size	a, 800000
a:
	.zero	800000
	.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	"%ld"
.LC1:
	.string	"%ld\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	leaq	.LC0(%rip), %r14
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movq	%r14, %rdi
	leaq	a(%rip), %r13
	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	$24, %rsp
	.cfi_def_cfa_offset 80
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	movq	%rsp, %rsi
	call	__isoc99_scanf@PLT
	movq	%r13, %rsi
	movq	%r14, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movq	a(%rip), %rbx
	movq	(%rsp), %rsi
	testq	%rbx, %rbx
	je	.L2
	cmpq	$1, %rsi
	jle	.L20
	xorl	%r12d, %r12d
.L17:
	leaq	8+a(%rip), %rbp
	movl	$1, %r15d
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L34:
	testq	%rax, %rax
	js	.L5
	leaq	1(%rax,%r12), %r12
	movq	$-1, %rbx
.L5:
	movq	(%rsp), %rsi
	addq	$1, %r15
	addq	$8, %rbp
	cmpq	%r15, %rsi
	jle	.L33
.L6:
	xorl	%eax, %eax
	movq	%rbp, %rsi
	movq	%r14, %rdi
	call	__isoc99_scanf@PLT
	movq	0(%rbp), %rax
	addq	%rbx, %rax
	testq	%rbx, %rbx
	movq	%rax, %rbx
	jg	.L34
	testq	%rax, %rax
	jg	.L5
	movl	$1, %eax
	subq	%rbx, %rax
	movl	$1, %ebx
	addq	%rax, %r12
	jmp	.L5
.L2:
	movl	$1, %r12d
	movl	$1, %ebx
	cmpq	$1, %rsi
	jg	.L17
	xorl	%edx, %edx
	jmp	.L16
	.p2align 4,,10
	.p2align 3
.L33:
	movq	a(%rip), %rax
.L3:
	movq	%rax, %rdx
	testq	%rax, %rax
	js	.L7
.L16:
	addq	$1, %rdx
	orq	$-1, %rax
.L10:
	leaq	8+a(%rip), %rcx
	leaq	0(%r13,%rsi,8), %rdi
	movl	$1, %r8d
	cmpq	$1, %rsi
	jg	.L13
	jmp	.L9
	.p2align 4,,10
	.p2align 3
.L35:
	testq	%rsi, %rsi
	js	.L12
	leaq	1(%rsi,%rdx), %rdx
	movq	$-1, %rax
.L12:
	addq	$8, %rcx
	cmpq	%rdi, %rcx
	je	.L9
.L13:
	movq	(%rcx), %rsi
	addq	%rax, %rsi
	testq	%rax, %rax
	movq	%rsi, %rax
	jg	.L35
	testq	%rsi, %rsi
	jg	.L12
	movq	%r8, %rsi
	addq	$8, %rcx
	subq	%rax, %rsi
	movl	$1, %eax
	addq	%rsi, %rdx
	cmpq	%rdi, %rcx
	jne	.L13
	.p2align 4,,10
	.p2align 3
.L9:
	cmpq	%r12, %rdx
	jle	.L14
	movq	%r12, %rdx
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L15:
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L36
	addq	$24, %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
.L14:
	.cfi_restore_state
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L15
.L7:
	movl	$1, %edx
	subq	%rax, %rdx
	movl	$1, %eax
	jmp	.L10
.L20:
	movq	%rbx, %rax
	xorl	%r12d, %r12d
	jmp	.L3
.L36:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.globl	a
	.bss
	.align 32
	.type	a, @object
	.size	a, 800000
a:
	.zero	800000
	.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>
long a[100000];

int main(int argc, char const *argv[]){
	long sum,bsum,ans=0,n,i,f=0,min=1;
	scanf("%ld",&n);
	scanf("%ld",&a[0]);
	if(a[0]==0){
		ans++;
		sum=1;
		f=1;
	}else sum=a[0];
	for(i=1;i<n;i++){
		scanf("%ld",&a[i]);
		bsum=sum;
		sum+=a[i];
		if(bsum>0){
			if(sum>=0){
				ans+=sum+1;
				sum=-1;
			}
		}else{
			if(sum<=0){
				ans+=1-sum;
				sum=1;
			}
		}
	}
		if(a[0]>=0){
			min=a[0]+1;
			sum=-1;
		}else{
			min=1-a[0];
			sum=1;
		}
		for(i=1;i<n;i++){
			bsum=sum;
			sum+=a[i];
			if(bsum>0){
				if(sum>=0){
					min+=sum+1;
					sum=-1;
				}
			}else{
				if(sum<=0){
					min+=1-sum;
					sum=1;
				}
			}
		}
		if(ans<min) printf("%ld\n",ans);
		else printf("%ld\n",min);
	return 0;
}```
Given the following C code, your task is to generate highly optimized x86-64 assembly code.
C Code:

```c
#include<stdio.h>
long a[100000];

int main(int argc, char const *argv[]){
	long sum,bsum,ans=0,n,i,f=0,min=1;
	scanf("%ld",&n);
	scanf("%ld",&a[0]);
	if(a[0]==0){
		ans++;
		sum=1;
		f=1;
	}else sum=a[0];
	for(i=1;i<n;i++){
		scanf("%ld",&a[i]);
		bsum=sum;
		sum+=a[i];
		if(bsum>0){
			if(sum>=0){
				ans+=sum+1;
				sum=-1;
			}
		}else{
			if(sum<=0){
				ans+=1-sum;
				sum=1;
			}
		}
	}
		if(a[0]>=0){
			min=a[0]+1;
			sum=-1;
		}else{
			min=1-a[0];
			sum=1;
		}
		for(i=1;i<n;i++){
			bsum=sum;
			sum+=a[i];
			if(bsum>0){
				if(sum>=0){
					min+=sum+1;
					sum=-1;
				}
			}else{
				if(sum<=0){
					min+=1-sum;
					sum=1;
				}
			}
		}
		if(ans<min) printf("%ld\n",ans);
		else printf("%ld\n",min);
	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:

4
1 -3 1 0

4

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>
long a[100000];

int main(int argc, char const *argv[]){
	long sum,bsum,ans=0,n,i,f=0,min=1;
	scanf("%ld",&n);
	scanf("%ld",&a[0]);
	if(a[0]==0){
		ans++;
		sum=1;
		f=1;
	}else sum=a[0];
	for(i=1;i<n;i++){
		scanf("%ld",&a[i]);
		bsum=sum;
		sum+=a[i];
		if(bsum>0){
			if(sum>=0){
				ans+=sum+1;
				sum=-1;
			}
		}else{
			if(sum<=0){
				ans+=1-sum;
				sum=1;
			}
		}
	}
		if(a[0]>=0){
			min=a[0]+1;
			sum=-1;
		}else{
			min=1-a[0];
			sum=1;
		}
		for(i=1;i<n;i++){
			bsum=sum;
			sum+=a[i];
			if(bsum>0){
				if(sum>=0){
					min+=sum+1;
					sum=-1;
				}
			}else{
				if(sum<=0){
					min+=1-sum;
					sum=1;
				}
			}
		}
		if(ans<min) printf("%ld\n",ans);
		else printf("%ld\n",min);
	return 0;
}```

Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%ld"
.LC1:
	.string	"%ld\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	leaq	.LC0(%rip), %r14
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movq	%r14, %rdi
	leaq	a(%rip), %r13
	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	$24, %rsp
	.cfi_def_cfa_offset 80
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	movq	%rsp, %rsi
	call	__isoc99_scanf@PLT
	movq	%r13, %rsi
	movq	%r14, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movq	a(%rip), %rbx
	movq	(%rsp), %rsi
	testq	%rbx, %rbx
	je	.L2
	cmpq	$1, %rsi
	jle	.L20
	xorl	%r12d, %r12d
.L17:
	leaq	8+a(%rip), %rbp
	movl	$1, %r15d
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L34:
	testq	%rax, %rax
	js	.L5
	leaq	1(%rax,%r12), %r12
	movq	$-1, %rbx
.L5:
	movq	(%rsp), %rsi
	addq	$1, %r15
	addq	$8, %rbp
	cmpq	%r15, %rsi
	jle	.L33
.L6:
	xorl	%eax, %eax
	movq	%rbp, %rsi
	movq	%r14, %rdi
	call	__isoc99_scanf@PLT
	movq	0(%rbp), %rax
	addq	%rbx, %rax
	testq	%rbx, %rbx
	movq	%rax, %rbx
	jg	.L34
	testq	%rax, %rax
	jg	.L5
	movl	$1, %eax
	subq	%rbx, %rax
	movl	$1, %ebx
	addq	%rax, %r12
	jmp	.L5
.L2:
	movl	$1, %r12d
	movl	$1, %ebx
	cmpq	$1, %rsi
	jg	.L17
	xorl	%edx, %edx
	jmp	.L16
	.p2align 4,,10
	.p2align 3
.L33:
	movq	a(%rip), %rax
.L3:
	movq	%rax, %rdx
	testq	%rax, %rax
	js	.L7
.L16:
	addq	$1, %rdx
	orq	$-1, %rax
.L10:
	leaq	8+a(%rip), %rcx
	leaq	0(%r13,%rsi,8), %rdi
	movl	$1, %r8d
	cmpq	$1, %rsi
	jg	.L13
	jmp	.L9
	.p2align 4,,10
	.p2align 3
.L35:
	testq	%rsi, %rsi
	js	.L12
	leaq	1(%rsi,%rdx), %rdx
	movq	$-1, %rax
.L12:
	addq	$8, %rcx
	cmpq	%rdi, %rcx
	je	.L9
.L13:
	movq	(%rcx), %rsi
	addq	%rax, %rsi
	testq	%rax, %rax
	movq	%rsi, %rax
	jg	.L35
	testq	%rsi, %rsi
	jg	.L12
	movq	%r8, %rsi
	addq	$8, %rcx
	subq	%rax, %rsi
	movl	$1, %eax
	addq	%rsi, %rdx
	cmpq	%rdi, %rcx
	jne	.L13
	.p2align 4,,10
	.p2align 3
.L9:
	cmpq	%r12, %rdx
	jle	.L14
	movq	%r12, %rdx
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L15:
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L36
	addq	$24, %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
.L14:
	.cfi_restore_state
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L15
.L7:
	movl	$1, %edx
	subq	%rax, %rdx
	movl	$1, %eax
	jmp	.L10
.L20:
	movq	%rbx, %rax
	xorl	%r12d, %r12d
	jmp	.L3
.L36:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.globl	a
	.bss
	.align 32
	.type	a, @object
	.size	a, 800000
a:
	.zero	800000
	.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	"%ld"
.LC1:
	.string	"%ld\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	leaq	.LC0(%rip), %r14
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movq	%r14, %rdi
	leaq	a(%rip), %r13
	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	$24, %rsp
	.cfi_def_cfa_offset 80
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	movq	%rsp, %rsi
	call	__isoc99_scanf@PLT
	movq	%r13, %rsi
	movq	%r14, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movq	a(%rip), %rbx
	movq	(%rsp), %rsi
	testq	%rbx, %rbx
	je	.L2
	cmpq	$1, %rsi
	jle	.L20
	xorl	%r12d, %r12d
.L17:
	leaq	8+a(%rip), %rbp
	movl	$1, %r15d
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L34:
	testq	%rax, %rax
	js	.L5
	leaq	1(%rax,%r12), %r12
	movq	$-1, %rbx
.L5:
	movq	(%rsp), %rsi
	addq	$1, %r15
	addq	$8, %rbp
	cmpq	%r15, %rsi
	jle	.L33
.L6:
	xorl	%eax, %eax
	movq	%rbp, %rsi
	movq	%r14, %rdi
	call	__isoc99_scanf@PLT
	movq	0(%rbp), %rax
	addq	%rbx, %rax
	testq	%rbx, %rbx
	movq	%rax, %rbx
	jg	.L34
	testq	%rax, %rax
	jg	.L5
	movl	$1, %eax
	subq	%rbx, %rax
	movl	$1, %ebx
	addq	%rax, %r12
	jmp	.L5
.L2:
	movl	$1, %r12d
	movl	$1, %ebx
	cmpq	$1, %rsi
	jg	.L17
	xorl	%edx, %edx
	jmp	.L16
	.p2align 4,,10
	.p2align 3
.L33:
	movq	a(%rip), %rax
.L3:
	movq	%rax, %rdx
	testq	%rax, %rax
	js	.L7
.L16:
	addq	$1, %rdx
	orq	$-1, %rax
.L10:
	leaq	8+a(%rip), %rcx
	leaq	0(%r13,%rsi,8), %rdi
	movl	$1, %r8d
	cmpq	$1, %rsi
	jg	.L13
	jmp	.L9
	.p2align 4,,10
	.p2align 3
.L35:
	testq	%rsi, %rsi
	js	.L12
	leaq	1(%rsi,%rdx), %rdx
	movq	$-1, %rax
.L12:
	addq	$8, %rcx
	cmpq	%rdi, %rcx
	je	.L9
.L13:
	movq	(%rcx), %rsi
	addq	%rax, %rsi
	testq	%rax, %rax
	movq	%rsi, %rax
	jg	.L35
	testq	%rsi, %rsi
	jg	.L12
	movq	%r8, %rsi
	addq	$8, %rcx
	subq	%rax, %rsi
	movl	$1, %eax
	addq	%rsi, %rdx
	cmpq	%rdi, %rcx
	jne	.L13
	.p2align 4,,10
	.p2align 3
.L9:
	cmpq	%r12, %rdx
	jle	.L14
	movq	%r12, %rdx
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L15:
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L36
	addq	$24, %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
.L14:
	.cfi_restore_state
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L15
.L7:
	movl	$1, %edx
	subq	%rax, %rdx
	movl	$1, %eax
	jmp	.L10
.L20:
	movq	%rbx, %rax
	xorl	%r12d, %r12d
	jmp	.L3
.L36:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.globl	a
	.bss
	.align 32
	.type	a, @object
	.size	a, 800000
a:
	.zero	800000
	.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:
```