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 <inttypes.h>

#define INF UINT64_C(123456789012345678)

int N;
uint64_t A[114514];

uint64_t saidai[114514];

int main(void) {
	int i;
	uint64_t chotensu = 0;
	uint64_t active = 1;
	if (scanf("%d", &N) != 1) return 1;
	for (i = 0; i <= N; i++) {
		if (scanf("%" SCNu64, &A[i]) != 1) return 1;
	}

	for (i = 0; i <= N; i++) {
		if (A[i] > active) {
			puts("-1");
			return 0;
		}
		saidai[i] = active - A[i];
		active = saidai[i] * 2;
		if (active > INF) active = INF;
	}

	chotensu = A[N];
	active = chotensu;
	for (i = N - 1; i >= 0; i--) {
		if (saidai[i] * 2 < active) {
			puts("-1");
			return 0;
		}
		if (active > saidai[i]) active = saidai[i];
		active += A[i];
		chotensu += active;
	}

	printf("%" PRIu64 "\n", chotensu);
	return 0;
}

/*

頂点数を最大にしたいので、1個から2個生やすより、2個から2個生やした方が有利
制約によって、各深さに置ける最大ノード数が決まる

*/
```

Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	"%lu"
.LC2:
	.string	"-1"
.LC3:
	.string	"%lu\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	xorl	%eax, %eax
	leaq	N(%rip), %rsi
	leaq	.LC0(%rip), %rdi
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	subq	$8, %rsp
	.cfi_def_cfa_offset 48
	call	__isoc99_scanf@PLT
	cmpl	$1, %eax
	jne	.L5
	movl	N(%rip), %edx
	leaq	A(%rip), %rbx
	testl	%edx, %edx
	js	.L4
	movq	%rbx, %rbp
	xorl	%r12d, %r12d
	leaq	.LC1(%rip), %r13
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L20:
	movl	N(%rip), %edx
	addl	$1, %r12d
	addq	$8, %rbp
	cmpl	%r12d, %edx
	jl	.L19
.L6:
	xorl	%eax, %eax
	movq	%rbp, %rsi
	movq	%r13, %rdi
	call	__isoc99_scanf@PLT
	cmpl	$1, %eax
	je	.L20
.L5:
	movl	$1, %eax
.L1:
	addq	$8, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
.L19:
	.cfi_restore_state
	testl	%edx, %edx
	js	.L4
	xorl	%ecx, %ecx
	movl	$1, %eax
	leaq	saidai(%rip), %rdi
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L7:
	subq	%rsi, %rax
	movabsq	$123456789012345678, %rsi
	movq	%rax, (%rdi,%rcx,8)
	addq	%rax, %rax
	cmpq	%rsi, %rax
	cmova	%rsi, %rax
	addq	$1, %rcx
	cmpl	%ecx, %edx
	jl	.L4
.L8:
	movq	(%rbx,%rcx,8), %rsi
	cmpq	%rax, %rsi
	jbe	.L7
.L10:
	leaq	.LC2(%rip), %rdi
	call	puts@PLT
	xorl	%eax, %eax
	jmp	.L1
.L4:
	movslq	%edx, %rax
	movq	(%rbx,%rax,8), %r8
	subl	$1, %edx
	js	.L9
	movslq	%edx, %rdx
	movq	%r8, %rax
	leaq	saidai(%rip), %rdi
	jmp	.L11
	.p2align 4,,10
	.p2align 3
.L21:
	cmpq	%rax, %rcx
	cmovbe	%rcx, %rax
	addq	(%rbx,%rdx,8), %rax
	subq	$1, %rdx
	addq	%rax, %r8
	testl	%edx, %edx
	js	.L9
.L11:
	movq	(%rdi,%rdx,8), %rcx
	leaq	(%rcx,%rcx), %rsi
	cmpq	%rax, %rsi
	jnb	.L21
	jmp	.L10
.L9:
	movq	%r8, %rdx
	leaq	.LC3(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	xorl	%eax, %eax
	jmp	.L1
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.globl	saidai
	.bss
	.align 32
	.type	saidai, @object
	.size	saidai, 916112
saidai:
	.zero	916112
	.globl	A
	.align 32
	.type	A, @object
	.size	A, 916112
A:
	.zero	916112
	.globl	N
	.align 4
	.type	N, @object
	.size	N, 4
N:
	.zero	4
	.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	"%lu"
.LC2:
	.string	"-1"
.LC3:
	.string	"%lu\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	xorl	%eax, %eax
	leaq	N(%rip), %rsi
	leaq	.LC0(%rip), %rdi
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	subq	$8, %rsp
	.cfi_def_cfa_offset 48
	call	__isoc99_scanf@PLT
	cmpl	$1, %eax
	jne	.L5
	movl	N(%rip), %edx
	leaq	A(%rip), %rbx
	testl	%edx, %edx
	js	.L4
	movq	%rbx, %rbp
	xorl	%r12d, %r12d
	leaq	.LC1(%rip), %r13
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L20:
	movl	N(%rip), %edx
	addl	$1, %r12d
	addq	$8, %rbp
	cmpl	%r12d, %edx
	jl	.L19
.L6:
	xorl	%eax, %eax
	movq	%rbp, %rsi
	movq	%r13, %rdi
	call	__isoc99_scanf@PLT
	cmpl	$1, %eax
	je	.L20
.L5:
	movl	$1, %eax
.L1:
	addq	$8, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
.L19:
	.cfi_restore_state
	testl	%edx, %edx
	js	.L4
	xorl	%ecx, %ecx
	movl	$1, %eax
	leaq	saidai(%rip), %rdi
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L7:
	subq	%rsi, %rax
	movabsq	$123456789012345678, %rsi
	movq	%rax, (%rdi,%rcx,8)
	addq	%rax, %rax
	cmpq	%rsi, %rax
	cmova	%rsi, %rax
	addq	$1, %rcx
	cmpl	%ecx, %edx
	jl	.L4
.L8:
	movq	(%rbx,%rcx,8), %rsi
	cmpq	%rax, %rsi
	jbe	.L7
.L10:
	leaq	.LC2(%rip), %rdi
	call	puts@PLT
	xorl	%eax, %eax
	jmp	.L1
.L4:
	movslq	%edx, %rax
	movq	(%rbx,%rax,8), %r8
	subl	$1, %edx
	js	.L9
	movslq	%edx, %rdx
	movq	%r8, %rax
	leaq	saidai(%rip), %rdi
	jmp	.L11
	.p2align 4,,10
	.p2align 3
.L21:
	cmpq	%rax, %rcx
	cmovbe	%rcx, %rax
	addq	(%rbx,%rdx,8), %rax
	subq	$1, %rdx
	addq	%rax, %r8
	testl	%edx, %edx
	js	.L9
.L11:
	movq	(%rdi,%rdx,8), %rcx
	leaq	(%rcx,%rcx), %rsi
	cmpq	%rax, %rsi
	jnb	.L21
	jmp	.L10
.L9:
	movq	%r8, %rdx
	leaq	.LC3(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	xorl	%eax, %eax
	jmp	.L1
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.globl	saidai
	.bss
	.align 32
	.type	saidai, @object
	.size	saidai, 916112
saidai:
	.zero	916112
	.globl	A
	.align 32
	.type	A, @object
	.size	A, 916112
A:
	.zero	916112
	.globl	N
	.align 4
	.type	N, @object
	.size	N, 4
N:
	.zero	4
	.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	"%lu"
.LC2:
	.string	"-1"
.LC3:
	.string	"%lu\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	xorl	%eax, %eax
	leaq	N(%rip), %rsi
	leaq	.LC0(%rip), %rdi
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	subq	$8, %rsp
	.cfi_def_cfa_offset 48
	call	__isoc99_scanf@PLT
	cmpl	$1, %eax
	jne	.L5
	movl	N(%rip), %edx
	leaq	A(%rip), %rbx
	testl	%edx, %edx
	js	.L4
	movq	%rbx, %rbp
	xorl	%r12d, %r12d
	leaq	.LC1(%rip), %r13
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L20:
	movl	N(%rip), %edx
	addl	$1, %r12d
	addq	$8, %rbp
	cmpl	%r12d, %edx
	jl	.L19
.L6:
	xorl	%eax, %eax
	movq	%rbp, %rsi
	movq	%r13, %rdi
	call	__isoc99_scanf@PLT
	cmpl	$1, %eax
	je	.L20
.L5:
	movl	$1, %eax
.L1:
	addq	$8, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
.L19:
	.cfi_restore_state
	testl	%edx, %edx
	js	.L4
	xorl	%ecx, %ecx
	movl	$1, %eax
	leaq	saidai(%rip), %rdi
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L7:
	subq	%rsi, %rax
	movabsq	$123456789012345678, %rsi
	movq	%rax, (%rdi,%rcx,8)
	addq	%rax, %rax
	cmpq	%rsi, %rax
	cmova	%rsi, %rax
	addq	$1, %rcx
	cmpl	%ecx, %edx
	jl	.L4
.L8:
	movq	(%rbx,%rcx,8), %rsi
	cmpq	%rax, %rsi
	jbe	.L7
.L10:
	leaq	.LC2(%rip), %rdi
	call	puts@PLT
	xorl	%eax, %eax
	jmp	.L1
.L4:
	movslq	%edx, %rax
	movq	(%rbx,%rax,8), %r8
	subl	$1, %edx
	js	.L9
	movslq	%edx, %rdx
	movq	%r8, %rax
	leaq	saidai(%rip), %rdi
	jmp	.L11
	.p2align 4,,10
	.p2align 3
.L21:
	cmpq	%rax, %rcx
	cmovbe	%rcx, %rax
	addq	(%rbx,%rdx,8), %rax
	subq	$1, %rdx
	addq	%rax, %r8
	testl	%edx, %edx
	js	.L9
.L11:
	movq	(%rdi,%rdx,8), %rcx
	leaq	(%rcx,%rcx), %rsi
	cmpq	%rax, %rsi
	jnb	.L21
	jmp	.L10
.L9:
	movq	%r8, %rdx
	leaq	.LC3(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	xorl	%eax, %eax
	jmp	.L1
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.globl	saidai
	.bss
	.align 32
	.type	saidai, @object
	.size	saidai, 916112
saidai:
	.zero	916112
	.globl	A
	.align 32
	.type	A, @object
	.size	A, 916112
A:
	.zero	916112
	.globl	N
	.align 4
	.type	N, @object
	.size	N, 4
N:
	.zero	4
	.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 <inttypes.h>

#define INF UINT64_C(123456789012345678)

int N;
uint64_t A[114514];

uint64_t saidai[114514];

int main(void) {
	int i;
	uint64_t chotensu = 0;
	uint64_t active = 1;
	if (scanf("%d", &N) != 1) return 1;
	for (i = 0; i <= N; i++) {
		if (scanf("%" SCNu64, &A[i]) != 1) return 1;
	}

	for (i = 0; i <= N; i++) {
		if (A[i] > active) {
			puts("-1");
			return 0;
		}
		saidai[i] = active - A[i];
		active = saidai[i] * 2;
		if (active > INF) active = INF;
	}

	chotensu = A[N];
	active = chotensu;
	for (i = N - 1; i >= 0; i--) {
		if (saidai[i] * 2 < active) {
			puts("-1");
			return 0;
		}
		if (active > saidai[i]) active = saidai[i];
		active += A[i];
		chotensu += active;
	}

	printf("%" PRIu64 "\n", chotensu);
	return 0;
}

/*

頂点数を最大にしたいので、1個から2個生やすより、2個から2個生やした方が有利
制約によって、各深さに置ける最大ノード数が決まる

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

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

#define INF UINT64_C(123456789012345678)

int N;
uint64_t A[114514];

uint64_t saidai[114514];

int main(void) {
	int i;
	uint64_t chotensu = 0;
	uint64_t active = 1;
	if (scanf("%d", &N) != 1) return 1;
	for (i = 0; i <= N; i++) {
		if (scanf("%" SCNu64, &A[i]) != 1) return 1;
	}

	for (i = 0; i <= N; i++) {
		if (A[i] > active) {
			puts("-1");
			return 0;
		}
		saidai[i] = active - A[i];
		active = saidai[i] * 2;
		if (active > INF) active = INF;
	}

	chotensu = A[N];
	active = chotensu;
	for (i = N - 1; i >= 0; i--) {
		if (saidai[i] * 2 < active) {
			puts("-1");
			return 0;
		}
		if (active > saidai[i]) active = saidai[i];
		active += A[i];
		chotensu += active;
	}

	printf("%" PRIu64 "\n", chotensu);
	return 0;
}

/*

頂点数を最大にしたいので、1個から2個生やすより、2個から2個生やした方が有利
制約によって、各深さに置ける最大ノード数が決まる

*/
```

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
0 0 0 0 2
 3
0 1 1 1
 10
0 0 1 0 2 3 5 8 13 21 34
 2
0 3 2
 10
0 0 1 0 2 3 5 8 13 23 34
 10
0 0 1 0 3 3 5 8 13 23 34
 2
-1 3 2
 10
0 0 1 1 3 3 5 8 13 23 34
 2
-2 3 2
 4
0 1 0 1 2

9
 6
 294
 -1
 298
 284
 -1
 236
 -1
 10

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 <inttypes.h>

#define INF UINT64_C(123456789012345678)

int N;
uint64_t A[114514];

uint64_t saidai[114514];

int main(void) {
	int i;
	uint64_t chotensu = 0;
	uint64_t active = 1;
	if (scanf("%d", &N) != 1) return 1;
	for (i = 0; i <= N; i++) {
		if (scanf("%" SCNu64, &A[i]) != 1) return 1;
	}

	for (i = 0; i <= N; i++) {
		if (A[i] > active) {
			puts("-1");
			return 0;
		}
		saidai[i] = active - A[i];
		active = saidai[i] * 2;
		if (active > INF) active = INF;
	}

	chotensu = A[N];
	active = chotensu;
	for (i = N - 1; i >= 0; i--) {
		if (saidai[i] * 2 < active) {
			puts("-1");
			return 0;
		}
		if (active > saidai[i]) active = saidai[i];
		active += A[i];
		chotensu += active;
	}

	printf("%" PRIu64 "\n", chotensu);
	return 0;
}

/*

頂点数を最大にしたいので、1個から2個生やすより、2個から2個生やした方が有利
制約によって、各深さに置ける最大ノード数が決まる

*/
```

Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	"%lu"
.LC2:
	.string	"-1"
.LC3:
	.string	"%lu\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	xorl	%eax, %eax
	leaq	N(%rip), %rsi
	leaq	.LC0(%rip), %rdi
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	subq	$8, %rsp
	.cfi_def_cfa_offset 48
	call	__isoc99_scanf@PLT
	cmpl	$1, %eax
	jne	.L5
	movl	N(%rip), %edx
	leaq	A(%rip), %rbx
	testl	%edx, %edx
	js	.L4
	movq	%rbx, %rbp
	xorl	%r12d, %r12d
	leaq	.LC1(%rip), %r13
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L20:
	movl	N(%rip), %edx
	addl	$1, %r12d
	addq	$8, %rbp
	cmpl	%r12d, %edx
	jl	.L19
.L6:
	xorl	%eax, %eax
	movq	%rbp, %rsi
	movq	%r13, %rdi
	call	__isoc99_scanf@PLT
	cmpl	$1, %eax
	je	.L20
.L5:
	movl	$1, %eax
.L1:
	addq	$8, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
.L19:
	.cfi_restore_state
	testl	%edx, %edx
	js	.L4
	xorl	%ecx, %ecx
	movl	$1, %eax
	leaq	saidai(%rip), %rdi
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L7:
	subq	%rsi, %rax
	movabsq	$123456789012345678, %rsi
	movq	%rax, (%rdi,%rcx,8)
	addq	%rax, %rax
	cmpq	%rsi, %rax
	cmova	%rsi, %rax
	addq	$1, %rcx
	cmpl	%ecx, %edx
	jl	.L4
.L8:
	movq	(%rbx,%rcx,8), %rsi
	cmpq	%rax, %rsi
	jbe	.L7
.L10:
	leaq	.LC2(%rip), %rdi
	call	puts@PLT
	xorl	%eax, %eax
	jmp	.L1
.L4:
	movslq	%edx, %rax
	movq	(%rbx,%rax,8), %r8
	subl	$1, %edx
	js	.L9
	movslq	%edx, %rdx
	movq	%r8, %rax
	leaq	saidai(%rip), %rdi
	jmp	.L11
	.p2align 4,,10
	.p2align 3
.L21:
	cmpq	%rax, %rcx
	cmovbe	%rcx, %rax
	addq	(%rbx,%rdx,8), %rax
	subq	$1, %rdx
	addq	%rax, %r8
	testl	%edx, %edx
	js	.L9
.L11:
	movq	(%rdi,%rdx,8), %rcx
	leaq	(%rcx,%rcx), %rsi
	cmpq	%rax, %rsi
	jnb	.L21
	jmp	.L10
.L9:
	movq	%r8, %rdx
	leaq	.LC3(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	xorl	%eax, %eax
	jmp	.L1
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.globl	saidai
	.bss
	.align 32
	.type	saidai, @object
	.size	saidai, 916112
saidai:
	.zero	916112
	.globl	A
	.align 32
	.type	A, @object
	.size	A, 916112
A:
	.zero	916112
	.globl	N
	.align 4
	.type	N, @object
	.size	N, 4
N:
	.zero	4
	.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	"%lu"
.LC2:
	.string	"-1"
.LC3:
	.string	"%lu\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	xorl	%eax, %eax
	leaq	N(%rip), %rsi
	leaq	.LC0(%rip), %rdi
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	subq	$8, %rsp
	.cfi_def_cfa_offset 48
	call	__isoc99_scanf@PLT
	cmpl	$1, %eax
	jne	.L5
	movl	N(%rip), %edx
	leaq	A(%rip), %rbx
	testl	%edx, %edx
	js	.L4
	movq	%rbx, %rbp
	xorl	%r12d, %r12d
	leaq	.LC1(%rip), %r13
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L20:
	movl	N(%rip), %edx
	addl	$1, %r12d
	addq	$8, %rbp
	cmpl	%r12d, %edx
	jl	.L19
.L6:
	xorl	%eax, %eax
	movq	%rbp, %rsi
	movq	%r13, %rdi
	call	__isoc99_scanf@PLT
	cmpl	$1, %eax
	je	.L20
.L5:
	movl	$1, %eax
.L1:
	addq	$8, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
.L19:
	.cfi_restore_state
	testl	%edx, %edx
	js	.L4
	xorl	%ecx, %ecx
	movl	$1, %eax
	leaq	saidai(%rip), %rdi
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L7:
	subq	%rsi, %rax
	movabsq	$123456789012345678, %rsi
	movq	%rax, (%rdi,%rcx,8)
	addq	%rax, %rax
	cmpq	%rsi, %rax
	cmova	%rsi, %rax
	addq	$1, %rcx
	cmpl	%ecx, %edx
	jl	.L4
.L8:
	movq	(%rbx,%rcx,8), %rsi
	cmpq	%rax, %rsi
	jbe	.L7
.L10:
	leaq	.LC2(%rip), %rdi
	call	puts@PLT
	xorl	%eax, %eax
	jmp	.L1
.L4:
	movslq	%edx, %rax
	movq	(%rbx,%rax,8), %r8
	subl	$1, %edx
	js	.L9
	movslq	%edx, %rdx
	movq	%r8, %rax
	leaq	saidai(%rip), %rdi
	jmp	.L11
	.p2align 4,,10
	.p2align 3
.L21:
	cmpq	%rax, %rcx
	cmovbe	%rcx, %rax
	addq	(%rbx,%rdx,8), %rax
	subq	$1, %rdx
	addq	%rax, %r8
	testl	%edx, %edx
	js	.L9
.L11:
	movq	(%rdi,%rdx,8), %rcx
	leaq	(%rcx,%rcx), %rsi
	cmpq	%rax, %rsi
	jnb	.L21
	jmp	.L10
.L9:
	movq	%r8, %rdx
	leaq	.LC3(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	xorl	%eax, %eax
	jmp	.L1
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.globl	saidai
	.bss
	.align 32
	.type	saidai, @object
	.size	saidai, 916112
saidai:
	.zero	916112
	.globl	A
	.align 32
	.type	A, @object
	.size	A, 916112
A:
	.zero	916112
	.globl	N
	.align 4
	.type	N, @object
	.size	N, 4
N:
	.zero	4
	.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:
```